require-jquery.js 338 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421
  1. /** vim: et:ts=4:sw=4:sts=4
  2. * @license RequireJS 2.1.1 Copyright (c) 2010-2012, The Dojo Foundation All Rights Reserved.
  3. * Available via the MIT or new BSD license.
  4. * see: http://github.com/jrburke/requirejs for details
  5. */
  6. //Not using strict: uneven strict support in browsers, #392, and causes
  7. //problems with requirejs.exec()/transpiler plugins that may not be strict.
  8. /*jslint regexp: true, nomen: true, sloppy: true */
  9. /*global window, navigator, document, importScripts, jQuery, setTimeout, opera */
  10. var requirejs, require, define;
  11. (function (global) {
  12. var req, s, head, baseElement, dataMain, src,
  13. interactiveScript, currentlyAddingScript, mainScript, subPath,
  14. version = '2.1.1',
  15. commentRegExp = /(\/\*([\s\S]*?)\*\/|([^:]|^)\/\/(.*)$)/mg,
  16. cjsRequireRegExp = /[^.]\s*require\s*\(\s*["']([^'"\s]+)["']\s*\)/g,
  17. jsSuffixRegExp = /\.js$/,
  18. currDirRegExp = /^\.\//,
  19. op = Object.prototype,
  20. ostring = op.toString,
  21. hasOwn = op.hasOwnProperty,
  22. ap = Array.prototype,
  23. aps = ap.slice,
  24. apsp = ap.splice,
  25. isBrowser = !!(typeof window !== 'undefined' && navigator && document),
  26. isWebWorker = !isBrowser && typeof importScripts !== 'undefined',
  27. //PS3 indicates loaded and complete, but need to wait for complete
  28. //specifically. Sequence is 'loading', 'loaded', execution,
  29. // then 'complete'. The UA check is unfortunate, but not sure how
  30. //to feature test w/o causing perf issues.
  31. readyRegExp = isBrowser && navigator.platform === 'PLAYSTATION 3' ?
  32. /^complete$/ : /^(complete|loaded)$/,
  33. defContextName = '_',
  34. //Oh the tragedy, detecting opera. See the usage of isOpera for reason.
  35. isOpera = typeof opera !== 'undefined' && opera.toString() === '[object Opera]',
  36. contexts = {},
  37. cfg = {},
  38. globalDefQueue = [],
  39. useInteractive = false;
  40. function isFunction(it) {
  41. return ostring.call(it) === '[object Function]';
  42. }
  43. function isArray(it) {
  44. return ostring.call(it) === '[object Array]';
  45. }
  46. /**
  47. * Helper function for iterating over an array. If the func returns
  48. * a true value, it will break out of the loop.
  49. */
  50. function each(ary, func) {
  51. if (ary) {
  52. var i;
  53. for (i = 0; i < ary.length; i += 1) {
  54. if (ary[i] && func(ary[i], i, ary)) {
  55. break;
  56. }
  57. }
  58. }
  59. }
  60. /**
  61. * Helper function for iterating over an array backwards. If the func
  62. * returns a true value, it will break out of the loop.
  63. */
  64. function eachReverse(ary, func) {
  65. if (ary) {
  66. var i;
  67. for (i = ary.length - 1; i > -1; i -= 1) {
  68. if (ary[i] && func(ary[i], i, ary)) {
  69. break;
  70. }
  71. }
  72. }
  73. }
  74. function hasProp(obj, prop) {
  75. return hasOwn.call(obj, prop);
  76. }
  77. /**
  78. * Cycles over properties in an object and calls a function for each
  79. * property value. If the function returns a truthy value, then the
  80. * iteration is stopped.
  81. */
  82. function eachProp(obj, func) {
  83. var prop;
  84. for (prop in obj) {
  85. if (obj.hasOwnProperty(prop)) {
  86. if (func(obj[prop], prop)) {
  87. break;
  88. }
  89. }
  90. }
  91. }
  92. /**
  93. * Simple function to mix in properties from source into target,
  94. * but only if target does not already have a property of the same name.
  95. */
  96. function mixin(target, source, force, deepStringMixin) {
  97. if (source) {
  98. eachProp(source, function (value, prop) {
  99. if (force || !hasProp(target, prop)) {
  100. if (deepStringMixin && typeof value !== 'string') {
  101. if (!target[prop]) {
  102. target[prop] = {};
  103. }
  104. mixin(target[prop], value, force, deepStringMixin);
  105. } else {
  106. target[prop] = value;
  107. }
  108. }
  109. });
  110. }
  111. return target;
  112. }
  113. //Similar to Function.prototype.bind, but the 'this' object is specified
  114. //first, since it is easier to read/figure out what 'this' will be.
  115. function bind(obj, fn) {
  116. return function () {
  117. return fn.apply(obj, arguments);
  118. };
  119. }
  120. function scripts() {
  121. return document.getElementsByTagName('script');
  122. }
  123. //Allow getting a global that expressed in
  124. //dot notation, like 'a.b.c'.
  125. function getGlobal(value) {
  126. if (!value) {
  127. return value;
  128. }
  129. var g = global;
  130. each(value.split('.'), function (part) {
  131. g = g[part];
  132. });
  133. return g;
  134. }
  135. /**
  136. * Constructs an error with a pointer to an URL with more information.
  137. * @param {String} id the error ID that maps to an ID on a web page.
  138. * @param {String} message human readable error.
  139. * @param {Error} [err] the original error, if there is one.
  140. *
  141. * @returns {Error}
  142. */
  143. function makeError(id, msg, err, requireModules) {
  144. var e = new Error(msg + '\nhttp://requirejs.org/docs/errors.html#' + id);
  145. e.requireType = id;
  146. e.requireModules = requireModules;
  147. if (err) {
  148. e.originalError = err;
  149. }
  150. return e;
  151. }
  152. if (typeof define !== 'undefined') {
  153. //If a define is already in play via another AMD loader,
  154. //do not overwrite.
  155. return;
  156. }
  157. if (typeof requirejs !== 'undefined') {
  158. if (isFunction(requirejs)) {
  159. //Do not overwrite and existing requirejs instance.
  160. return;
  161. }
  162. cfg = requirejs;
  163. requirejs = undefined;
  164. }
  165. //Allow for a require config object
  166. if (typeof require !== 'undefined' && !isFunction(require)) {
  167. //assume it is a config object.
  168. cfg = require;
  169. require = undefined;
  170. }
  171. function newContext(contextName) {
  172. var inCheckLoaded, Module, context, handlers,
  173. checkLoadedTimeoutId,
  174. config = {
  175. waitSeconds: 7,
  176. baseUrl: './',
  177. paths: {},
  178. pkgs: {},
  179. shim: {},
  180. map: {},
  181. config: {}
  182. },
  183. registry = {},
  184. undefEvents = {},
  185. defQueue = [],
  186. defined = {},
  187. urlFetched = {},
  188. requireCounter = 1,
  189. unnormalizedCounter = 1;
  190. /**
  191. * Trims the . and .. from an array of path segments.
  192. * It will keep a leading path segment if a .. will become
  193. * the first path segment, to help with module name lookups,
  194. * which act like paths, but can be remapped. But the end result,
  195. * all paths that use this function should look normalized.
  196. * NOTE: this method MODIFIES the input array.
  197. * @param {Array} ary the array of path segments.
  198. */
  199. function trimDots(ary) {
  200. var i, part;
  201. for (i = 0; ary[i]; i += 1) {
  202. part = ary[i];
  203. if (part === '.') {
  204. ary.splice(i, 1);
  205. i -= 1;
  206. } else if (part === '..') {
  207. if (i === 1 && (ary[2] === '..' || ary[0] === '..')) {
  208. //End of the line. Keep at least one non-dot
  209. //path segment at the front so it can be mapped
  210. //correctly to disk. Otherwise, there is likely
  211. //no path mapping for a path starting with '..'.
  212. //This can still fail, but catches the most reasonable
  213. //uses of ..
  214. break;
  215. } else if (i > 0) {
  216. ary.splice(i - 1, 2);
  217. i -= 2;
  218. }
  219. }
  220. }
  221. }
  222. /**
  223. * Given a relative module name, like ./something, normalize it to
  224. * a real name that can be mapped to a path.
  225. * @param {String} name the relative name
  226. * @param {String} baseName a real name that the name arg is relative
  227. * to.
  228. * @param {Boolean} applyMap apply the map config to the value. Should
  229. * only be done if this normalization is for a dependency ID.
  230. * @returns {String} normalized name
  231. */
  232. function normalize(name, baseName, applyMap) {
  233. var pkgName, pkgConfig, mapValue, nameParts, i, j, nameSegment,
  234. foundMap, foundI, foundStarMap, starI,
  235. baseParts = baseName && baseName.split('/'),
  236. normalizedBaseParts = baseParts,
  237. map = config.map,
  238. starMap = map && map['*'];
  239. //Adjust any relative paths.
  240. if (name && name.charAt(0) === '.') {
  241. //If have a base name, try to normalize against it,
  242. //otherwise, assume it is a top-level require that will
  243. //be relative to baseUrl in the end.
  244. if (baseName) {
  245. if (config.pkgs[baseName]) {
  246. //If the baseName is a package name, then just treat it as one
  247. //name to concat the name with.
  248. normalizedBaseParts = baseParts = [baseName];
  249. } else {
  250. //Convert baseName to array, and lop off the last part,
  251. //so that . matches that 'directory' and not name of the baseName's
  252. //module. For instance, baseName of 'one/two/three', maps to
  253. //'one/two/three.js', but we want the directory, 'one/two' for
  254. //this normalization.
  255. normalizedBaseParts = baseParts.slice(0, baseParts.length - 1);
  256. }
  257. name = normalizedBaseParts.concat(name.split('/'));
  258. trimDots(name);
  259. //Some use of packages may use a . path to reference the
  260. //'main' module name, so normalize for that.
  261. pkgConfig = config.pkgs[(pkgName = name[0])];
  262. name = name.join('/');
  263. if (pkgConfig && name === pkgName + '/' + pkgConfig.main) {
  264. name = pkgName;
  265. }
  266. } else if (name.indexOf('./') === 0) {
  267. // No baseName, so this is ID is resolved relative
  268. // to baseUrl, pull off the leading dot.
  269. name = name.substring(2);
  270. }
  271. }
  272. //Apply map config if available.
  273. if (applyMap && (baseParts || starMap) && map) {
  274. nameParts = name.split('/');
  275. for (i = nameParts.length; i > 0; i -= 1) {
  276. nameSegment = nameParts.slice(0, i).join('/');
  277. if (baseParts) {
  278. //Find the longest baseName segment match in the config.
  279. //So, do joins on the biggest to smallest lengths of baseParts.
  280. for (j = baseParts.length; j > 0; j -= 1) {
  281. mapValue = map[baseParts.slice(0, j).join('/')];
  282. //baseName segment has config, find if it has one for
  283. //this name.
  284. if (mapValue) {
  285. mapValue = mapValue[nameSegment];
  286. if (mapValue) {
  287. //Match, update name to the new value.
  288. foundMap = mapValue;
  289. foundI = i;
  290. break;
  291. }
  292. }
  293. }
  294. }
  295. if (foundMap) {
  296. break;
  297. }
  298. //Check for a star map match, but just hold on to it,
  299. //if there is a shorter segment match later in a matching
  300. //config, then favor over this star map.
  301. if (!foundStarMap && starMap && starMap[nameSegment]) {
  302. foundStarMap = starMap[nameSegment];
  303. starI = i;
  304. }
  305. }
  306. if (!foundMap && foundStarMap) {
  307. foundMap = foundStarMap;
  308. foundI = starI;
  309. }
  310. if (foundMap) {
  311. nameParts.splice(0, foundI, foundMap);
  312. name = nameParts.join('/');
  313. }
  314. }
  315. return name;
  316. }
  317. function removeScript(name) {
  318. if (isBrowser) {
  319. each(scripts(), function (scriptNode) {
  320. if (scriptNode.getAttribute('data-requiremodule') === name &&
  321. scriptNode.getAttribute('data-requirecontext') === context.contextName) {
  322. scriptNode.parentNode.removeChild(scriptNode);
  323. return true;
  324. }
  325. });
  326. }
  327. }
  328. function hasPathFallback(id) {
  329. var pathConfig = config.paths[id];
  330. if (pathConfig && isArray(pathConfig) && pathConfig.length > 1) {
  331. removeScript(id);
  332. //Pop off the first array value, since it failed, and
  333. //retry
  334. pathConfig.shift();
  335. context.require.undef(id);
  336. context.require([id]);
  337. return true;
  338. }
  339. }
  340. //Turns a plugin!resource to [plugin, resource]
  341. //with the plugin being undefined if the name
  342. //did not have a plugin prefix.
  343. function splitPrefix(name) {
  344. var prefix,
  345. index = name ? name.indexOf('!') : -1;
  346. if (index > -1) {
  347. prefix = name.substring(0, index);
  348. name = name.substring(index + 1, name.length);
  349. }
  350. return [prefix, name];
  351. }
  352. /**
  353. * Creates a module mapping that includes plugin prefix, module
  354. * name, and path. If parentModuleMap is provided it will
  355. * also normalize the name via require.normalize()
  356. *
  357. * @param {String} name the module name
  358. * @param {String} [parentModuleMap] parent module map
  359. * for the module name, used to resolve relative names.
  360. * @param {Boolean} isNormalized: is the ID already normalized.
  361. * This is true if this call is done for a define() module ID.
  362. * @param {Boolean} applyMap: apply the map config to the ID.
  363. * Should only be true if this map is for a dependency.
  364. *
  365. * @returns {Object}
  366. */
  367. function makeModuleMap(name, parentModuleMap, isNormalized, applyMap) {
  368. var url, pluginModule, suffix, nameParts,
  369. prefix = null,
  370. parentName = parentModuleMap ? parentModuleMap.name : null,
  371. originalName = name,
  372. isDefine = true,
  373. normalizedName = '';
  374. //If no name, then it means it is a require call, generate an
  375. //internal name.
  376. if (!name) {
  377. isDefine = false;
  378. name = '_@r' + (requireCounter += 1);
  379. }
  380. nameParts = splitPrefix(name);
  381. prefix = nameParts[0];
  382. name = nameParts[1];
  383. if (prefix) {
  384. prefix = normalize(prefix, parentName, applyMap);
  385. pluginModule = defined[prefix];
  386. }
  387. //Account for relative paths if there is a base name.
  388. if (name) {
  389. if (prefix) {
  390. if (pluginModule && pluginModule.normalize) {
  391. //Plugin is loaded, use its normalize method.
  392. normalizedName = pluginModule.normalize(name, function (name) {
  393. return normalize(name, parentName, applyMap);
  394. });
  395. } else {
  396. normalizedName = normalize(name, parentName, applyMap);
  397. }
  398. } else {
  399. //A regular module.
  400. normalizedName = normalize(name, parentName, applyMap);
  401. //Normalized name may be a plugin ID due to map config
  402. //application in normalize. The map config values must
  403. //already be normalized, so do not need to redo that part.
  404. nameParts = splitPrefix(normalizedName);
  405. prefix = nameParts[0];
  406. normalizedName = nameParts[1];
  407. isNormalized = true;
  408. url = context.nameToUrl(normalizedName);
  409. }
  410. }
  411. //If the id is a plugin id that cannot be determined if it needs
  412. //normalization, stamp it with a unique ID so two matching relative
  413. //ids that may conflict can be separate.
  414. suffix = prefix && !pluginModule && !isNormalized ?
  415. '_unnormalized' + (unnormalizedCounter += 1) :
  416. '';
  417. return {
  418. prefix: prefix,
  419. name: normalizedName,
  420. parentMap: parentModuleMap,
  421. unnormalized: !!suffix,
  422. url: url,
  423. originalName: originalName,
  424. isDefine: isDefine,
  425. id: (prefix ?
  426. prefix + '!' + normalizedName :
  427. normalizedName) + suffix
  428. };
  429. }
  430. function getModule(depMap) {
  431. var id = depMap.id,
  432. mod = registry[id];
  433. if (!mod) {
  434. mod = registry[id] = new context.Module(depMap);
  435. }
  436. return mod;
  437. }
  438. function on(depMap, name, fn) {
  439. var id = depMap.id,
  440. mod = registry[id];
  441. if (hasProp(defined, id) &&
  442. (!mod || mod.defineEmitComplete)) {
  443. if (name === 'defined') {
  444. fn(defined[id]);
  445. }
  446. } else {
  447. getModule(depMap).on(name, fn);
  448. }
  449. }
  450. function onError(err, errback) {
  451. var ids = err.requireModules,
  452. notified = false;
  453. if (errback) {
  454. errback(err);
  455. } else {
  456. each(ids, function (id) {
  457. var mod = registry[id];
  458. if (mod) {
  459. //Set error on module, so it skips timeout checks.
  460. mod.error = err;
  461. if (mod.events.error) {
  462. notified = true;
  463. mod.emit('error', err);
  464. }
  465. }
  466. });
  467. if (!notified) {
  468. req.onError(err);
  469. }
  470. }
  471. }
  472. /**
  473. * Internal method to transfer globalQueue items to this context's
  474. * defQueue.
  475. */
  476. function takeGlobalQueue() {
  477. //Push all the globalDefQueue items into the context's defQueue
  478. if (globalDefQueue.length) {
  479. //Array splice in the values since the context code has a
  480. //local var ref to defQueue, so cannot just reassign the one
  481. //on context.
  482. apsp.apply(defQueue,
  483. [defQueue.length - 1, 0].concat(globalDefQueue));
  484. globalDefQueue = [];
  485. }
  486. }
  487. handlers = {
  488. 'require': function (mod) {
  489. if (mod.require) {
  490. return mod.require;
  491. } else {
  492. return (mod.require = context.makeRequire(mod.map));
  493. }
  494. },
  495. 'exports': function (mod) {
  496. mod.usingExports = true;
  497. if (mod.map.isDefine) {
  498. if (mod.exports) {
  499. return mod.exports;
  500. } else {
  501. return (mod.exports = defined[mod.map.id] = {});
  502. }
  503. }
  504. },
  505. 'module': function (mod) {
  506. if (mod.module) {
  507. return mod.module;
  508. } else {
  509. return (mod.module = {
  510. id: mod.map.id,
  511. uri: mod.map.url,
  512. config: function () {
  513. return (config.config && config.config[mod.map.id]) || {};
  514. },
  515. exports: defined[mod.map.id]
  516. });
  517. }
  518. }
  519. };
  520. function cleanRegistry(id) {
  521. //Clean up machinery used for waiting modules.
  522. delete registry[id];
  523. }
  524. function breakCycle(mod, traced, processed) {
  525. var id = mod.map.id;
  526. if (mod.error) {
  527. mod.emit('error', mod.error);
  528. } else {
  529. traced[id] = true;
  530. each(mod.depMaps, function (depMap, i) {
  531. var depId = depMap.id,
  532. dep = registry[depId];
  533. //Only force things that have not completed
  534. //being defined, so still in the registry,
  535. //and only if it has not been matched up
  536. //in the module already.
  537. if (dep && !mod.depMatched[i] && !processed[depId]) {
  538. if (traced[depId]) {
  539. mod.defineDep(i, defined[depId]);
  540. mod.check(); //pass false?
  541. } else {
  542. breakCycle(dep, traced, processed);
  543. }
  544. }
  545. });
  546. processed[id] = true;
  547. }
  548. }
  549. function checkLoaded() {
  550. var map, modId, err, usingPathFallback,
  551. waitInterval = config.waitSeconds * 1000,
  552. //It is possible to disable the wait interval by using waitSeconds of 0.
  553. expired = waitInterval && (context.startTime + waitInterval) < new Date().getTime(),
  554. noLoads = [],
  555. reqCalls = [],
  556. stillLoading = false,
  557. needCycleCheck = true;
  558. //Do not bother if this call was a result of a cycle break.
  559. if (inCheckLoaded) {
  560. return;
  561. }
  562. inCheckLoaded = true;
  563. //Figure out the state of all the modules.
  564. eachProp(registry, function (mod) {
  565. map = mod.map;
  566. modId = map.id;
  567. //Skip things that are not enabled or in error state.
  568. if (!mod.enabled) {
  569. return;
  570. }
  571. if (!map.isDefine) {
  572. reqCalls.push(mod);
  573. }
  574. if (!mod.error) {
  575. //If the module should be executed, and it has not
  576. //been inited and time is up, remember it.
  577. if (!mod.inited && expired) {
  578. if (hasPathFallback(modId)) {
  579. usingPathFallback = true;
  580. stillLoading = true;
  581. } else {
  582. noLoads.push(modId);
  583. removeScript(modId);
  584. }
  585. } else if (!mod.inited && mod.fetched && map.isDefine) {
  586. stillLoading = true;
  587. if (!map.prefix) {
  588. //No reason to keep looking for unfinished
  589. //loading. If the only stillLoading is a
  590. //plugin resource though, keep going,
  591. //because it may be that a plugin resource
  592. //is waiting on a non-plugin cycle.
  593. return (needCycleCheck = false);
  594. }
  595. }
  596. }
  597. });
  598. if (expired && noLoads.length) {
  599. //If wait time expired, throw error of unloaded modules.
  600. err = makeError('timeout', 'Load timeout for modules: ' + noLoads, null, noLoads);
  601. err.contextName = context.contextName;
  602. return onError(err);
  603. }
  604. //Not expired, check for a cycle.
  605. if (needCycleCheck) {
  606. each(reqCalls, function (mod) {
  607. breakCycle(mod, {}, {});
  608. });
  609. }
  610. //If still waiting on loads, and the waiting load is something
  611. //other than a plugin resource, or there are still outstanding
  612. //scripts, then just try back later.
  613. if ((!expired || usingPathFallback) && stillLoading) {
  614. //Something is still waiting to load. Wait for it, but only
  615. //if a timeout is not already in effect.
  616. if ((isBrowser || isWebWorker) && !checkLoadedTimeoutId) {
  617. checkLoadedTimeoutId = setTimeout(function () {
  618. checkLoadedTimeoutId = 0;
  619. checkLoaded();
  620. }, 50);
  621. }
  622. }
  623. inCheckLoaded = false;
  624. }
  625. Module = function (map) {
  626. this.events = undefEvents[map.id] || {};
  627. this.map = map;
  628. this.shim = config.shim[map.id];
  629. this.depExports = [];
  630. this.depMaps = [];
  631. this.depMatched = [];
  632. this.pluginMaps = {};
  633. this.depCount = 0;
  634. /* this.exports this.factory
  635. this.depMaps = [],
  636. this.enabled, this.fetched
  637. */
  638. };
  639. Module.prototype = {
  640. init: function (depMaps, factory, errback, options) {
  641. options = options || {};
  642. //Do not do more inits if already done. Can happen if there
  643. //are multiple define calls for the same module. That is not
  644. //a normal, common case, but it is also not unexpected.
  645. if (this.inited) {
  646. return;
  647. }
  648. this.factory = factory;
  649. if (errback) {
  650. //Register for errors on this module.
  651. this.on('error', errback);
  652. } else if (this.events.error) {
  653. //If no errback already, but there are error listeners
  654. //on this module, set up an errback to pass to the deps.
  655. errback = bind(this, function (err) {
  656. this.emit('error', err);
  657. });
  658. }
  659. //Do a copy of the dependency array, so that
  660. //source inputs are not modified. For example
  661. //"shim" deps are passed in here directly, and
  662. //doing a direct modification of the depMaps array
  663. //would affect that config.
  664. this.depMaps = depMaps && depMaps.slice(0);
  665. this.errback = errback;
  666. //Indicate this module has be initialized
  667. this.inited = true;
  668. this.ignore = options.ignore;
  669. //Could have option to init this module in enabled mode,
  670. //or could have been previously marked as enabled. However,
  671. //the dependencies are not known until init is called. So
  672. //if enabled previously, now trigger dependencies as enabled.
  673. if (options.enabled || this.enabled) {
  674. //Enable this module and dependencies.
  675. //Will call this.check()
  676. this.enable();
  677. } else {
  678. this.check();
  679. }
  680. },
  681. defineDep: function (i, depExports) {
  682. //Because of cycles, defined callback for a given
  683. //export can be called more than once.
  684. if (!this.depMatched[i]) {
  685. this.depMatched[i] = true;
  686. this.depCount -= 1;
  687. this.depExports[i] = depExports;
  688. }
  689. },
  690. fetch: function () {
  691. if (this.fetched) {
  692. return;
  693. }
  694. this.fetched = true;
  695. context.startTime = (new Date()).getTime();
  696. var map = this.map;
  697. //If the manager is for a plugin managed resource,
  698. //ask the plugin to load it now.
  699. if (this.shim) {
  700. context.makeRequire(this.map, {
  701. enableBuildCallback: true
  702. })(this.shim.deps || [], bind(this, function () {
  703. return map.prefix ? this.callPlugin() : this.load();
  704. }));
  705. } else {
  706. //Regular dependency.
  707. return map.prefix ? this.callPlugin() : this.load();
  708. }
  709. },
  710. load: function () {
  711. var url = this.map.url;
  712. //Regular dependency.
  713. if (!urlFetched[url]) {
  714. urlFetched[url] = true;
  715. context.load(this.map.id, url);
  716. }
  717. },
  718. /**
  719. * Checks is the module is ready to define itself, and if so,
  720. * define it.
  721. */
  722. check: function () {
  723. if (!this.enabled || this.enabling) {
  724. return;
  725. }
  726. var err, cjsModule,
  727. id = this.map.id,
  728. depExports = this.depExports,
  729. exports = this.exports,
  730. factory = this.factory;
  731. if (!this.inited) {
  732. this.fetch();
  733. } else if (this.error) {
  734. this.emit('error', this.error);
  735. } else if (!this.defining) {
  736. //The factory could trigger another require call
  737. //that would result in checking this module to
  738. //define itself again. If already in the process
  739. //of doing that, skip this work.
  740. this.defining = true;
  741. if (this.depCount < 1 && !this.defined) {
  742. if (isFunction(factory)) {
  743. //If there is an error listener, favor passing
  744. //to that instead of throwing an error.
  745. if (this.events.error) {
  746. try {
  747. exports = context.execCb(id, factory, depExports, exports);
  748. } catch (e) {
  749. err = e;
  750. }
  751. } else {
  752. exports = context.execCb(id, factory, depExports, exports);
  753. }
  754. if (this.map.isDefine) {
  755. //If setting exports via 'module' is in play,
  756. //favor that over return value and exports. After that,
  757. //favor a non-undefined return value over exports use.
  758. cjsModule = this.module;
  759. if (cjsModule &&
  760. cjsModule.exports !== undefined &&
  761. //Make sure it is not already the exports value
  762. cjsModule.exports !== this.exports) {
  763. exports = cjsModule.exports;
  764. } else if (exports === undefined && this.usingExports) {
  765. //exports already set the defined value.
  766. exports = this.exports;
  767. }
  768. }
  769. if (err) {
  770. err.requireMap = this.map;
  771. err.requireModules = [this.map.id];
  772. err.requireType = 'define';
  773. return onError((this.error = err));
  774. }
  775. } else {
  776. //Just a literal value
  777. exports = factory;
  778. }
  779. this.exports = exports;
  780. if (this.map.isDefine && !this.ignore) {
  781. defined[id] = exports;
  782. if (req.onResourceLoad) {
  783. req.onResourceLoad(context, this.map, this.depMaps);
  784. }
  785. }
  786. //Clean up
  787. delete registry[id];
  788. this.defined = true;
  789. }
  790. //Finished the define stage. Allow calling check again
  791. //to allow define notifications below in the case of a
  792. //cycle.
  793. this.defining = false;
  794. if (this.defined && !this.defineEmitted) {
  795. this.defineEmitted = true;
  796. this.emit('defined', this.exports);
  797. this.defineEmitComplete = true;
  798. }
  799. }
  800. },
  801. callPlugin: function () {
  802. var map = this.map,
  803. id = map.id,
  804. //Map already normalized the prefix.
  805. pluginMap = makeModuleMap(map.prefix);
  806. //Mark this as a dependency for this plugin, so it
  807. //can be traced for cycles.
  808. this.depMaps.push(pluginMap);
  809. on(pluginMap, 'defined', bind(this, function (plugin) {
  810. var load, normalizedMap, normalizedMod,
  811. name = this.map.name,
  812. parentName = this.map.parentMap ? this.map.parentMap.name : null,
  813. localRequire = context.makeRequire(map.parentMap, {
  814. enableBuildCallback: true,
  815. skipMap: true
  816. });
  817. //If current map is not normalized, wait for that
  818. //normalized name to load instead of continuing.
  819. if (this.map.unnormalized) {
  820. //Normalize the ID if the plugin allows it.
  821. if (plugin.normalize) {
  822. name = plugin.normalize(name, function (name) {
  823. return normalize(name, parentName, true);
  824. }) || '';
  825. }
  826. //prefix and name should already be normalized, no need
  827. //for applying map config again either.
  828. normalizedMap = makeModuleMap(map.prefix + '!' + name,
  829. this.map.parentMap);
  830. on(normalizedMap,
  831. 'defined', bind(this, function (value) {
  832. this.init([], function () { return value; }, null, {
  833. enabled: true,
  834. ignore: true
  835. });
  836. }));
  837. normalizedMod = registry[normalizedMap.id];
  838. if (normalizedMod) {
  839. //Mark this as a dependency for this plugin, so it
  840. //can be traced for cycles.
  841. this.depMaps.push(normalizedMap);
  842. if (this.events.error) {
  843. normalizedMod.on('error', bind(this, function (err) {
  844. this.emit('error', err);
  845. }));
  846. }
  847. normalizedMod.enable();
  848. }
  849. return;
  850. }
  851. load = bind(this, function (value) {
  852. this.init([], function () { return value; }, null, {
  853. enabled: true
  854. });
  855. });
  856. load.error = bind(this, function (err) {
  857. this.inited = true;
  858. this.error = err;
  859. err.requireModules = [id];
  860. //Remove temp unnormalized modules for this module,
  861. //since they will never be resolved otherwise now.
  862. eachProp(registry, function (mod) {
  863. if (mod.map.id.indexOf(id + '_unnormalized') === 0) {
  864. cleanRegistry(mod.map.id);
  865. }
  866. });
  867. onError(err);
  868. });
  869. //Allow plugins to load other code without having to know the
  870. //context or how to 'complete' the load.
  871. load.fromText = bind(this, function (text, textAlt) {
  872. /*jslint evil: true */
  873. var moduleName = map.name,
  874. moduleMap = makeModuleMap(moduleName),
  875. hasInteractive = useInteractive;
  876. //As of 2.1.0, support just passing the text, to reinforce
  877. //fromText only being called once per resource. Still
  878. //support old style of passing moduleName but discard
  879. //that moduleName in favor of the internal ref.
  880. if (textAlt) {
  881. text = textAlt;
  882. }
  883. //Turn off interactive script matching for IE for any define
  884. //calls in the text, then turn it back on at the end.
  885. if (hasInteractive) {
  886. useInteractive = false;
  887. }
  888. //Prime the system by creating a module instance for
  889. //it.
  890. getModule(moduleMap);
  891. try {
  892. req.exec(text);
  893. } catch (e) {
  894. throw new Error('fromText eval for ' + moduleName +
  895. ' failed: ' + e);
  896. }
  897. if (hasInteractive) {
  898. useInteractive = true;
  899. }
  900. //Mark this as a dependency for the plugin
  901. //resource
  902. this.depMaps.push(moduleMap);
  903. //Support anonymous modules.
  904. context.completeLoad(moduleName);
  905. //Bind the value of that module to the value for this
  906. //resource ID.
  907. localRequire([moduleName], load);
  908. });
  909. //Use parentName here since the plugin's name is not reliable,
  910. //could be some weird string with no path that actually wants to
  911. //reference the parentName's path.
  912. plugin.load(map.name, localRequire, load, config);
  913. }));
  914. context.enable(pluginMap, this);
  915. this.pluginMaps[pluginMap.id] = pluginMap;
  916. },
  917. enable: function () {
  918. this.enabled = true;
  919. //Set flag mentioning that the module is enabling,
  920. //so that immediate calls to the defined callbacks
  921. //for dependencies do not trigger inadvertent load
  922. //with the depCount still being zero.
  923. this.enabling = true;
  924. //Enable each dependency
  925. each(this.depMaps, bind(this, function (depMap, i) {
  926. var id, mod, handler;
  927. if (typeof depMap === 'string') {
  928. //Dependency needs to be converted to a depMap
  929. //and wired up to this module.
  930. depMap = makeModuleMap(depMap,
  931. (this.map.isDefine ? this.map : this.map.parentMap),
  932. false,
  933. !this.skipMap);
  934. this.depMaps[i] = depMap;
  935. handler = handlers[depMap.id];
  936. if (handler) {
  937. this.depExports[i] = handler(this);
  938. return;
  939. }
  940. this.depCount += 1;
  941. on(depMap, 'defined', bind(this, function (depExports) {
  942. this.defineDep(i, depExports);
  943. this.check();
  944. }));
  945. if (this.errback) {
  946. on(depMap, 'error', this.errback);
  947. }
  948. }
  949. id = depMap.id;
  950. mod = registry[id];
  951. //Skip special modules like 'require', 'exports', 'module'
  952. //Also, don't call enable if it is already enabled,
  953. //important in circular dependency cases.
  954. if (!handlers[id] && mod && !mod.enabled) {
  955. context.enable(depMap, this);
  956. }
  957. }));
  958. //Enable each plugin that is used in
  959. //a dependency
  960. eachProp(this.pluginMaps, bind(this, function (pluginMap) {
  961. var mod = registry[pluginMap.id];
  962. if (mod && !mod.enabled) {
  963. context.enable(pluginMap, this);
  964. }
  965. }));
  966. this.enabling = false;
  967. this.check();
  968. },
  969. on: function (name, cb) {
  970. var cbs = this.events[name];
  971. if (!cbs) {
  972. cbs = this.events[name] = [];
  973. }
  974. cbs.push(cb);
  975. },
  976. emit: function (name, evt) {
  977. each(this.events[name], function (cb) {
  978. cb(evt);
  979. });
  980. if (name === 'error') {
  981. //Now that the error handler was triggered, remove
  982. //the listeners, since this broken Module instance
  983. //can stay around for a while in the registry.
  984. delete this.events[name];
  985. }
  986. }
  987. };
  988. function callGetModule(args) {
  989. getModule(makeModuleMap(args[0], null, true)).init(args[1], args[2]);
  990. }
  991. function removeListener(node, func, name, ieName) {
  992. //Favor detachEvent because of IE9
  993. //issue, see attachEvent/addEventListener comment elsewhere
  994. //in this file.
  995. if (node.detachEvent && !isOpera) {
  996. //Probably IE. If not it will throw an error, which will be
  997. //useful to know.
  998. if (ieName) {
  999. node.detachEvent(ieName, func);
  1000. }
  1001. } else {
  1002. node.removeEventListener(name, func, false);
  1003. }
  1004. }
  1005. /**
  1006. * Given an event from a script node, get the requirejs info from it,
  1007. * and then removes the event listeners on the node.
  1008. * @param {Event} evt
  1009. * @returns {Object}
  1010. */
  1011. function getScriptData(evt) {
  1012. //Using currentTarget instead of target for Firefox 2.0's sake. Not
  1013. //all old browsers will be supported, but this one was easy enough
  1014. //to support and still makes sense.
  1015. var node = evt.currentTarget || evt.srcElement;
  1016. //Remove the listeners once here.
  1017. removeListener(node, context.onScriptLoad, 'load', 'onreadystatechange');
  1018. removeListener(node, context.onScriptError, 'error');
  1019. return {
  1020. node: node,
  1021. id: node && node.getAttribute('data-requiremodule')
  1022. };
  1023. }
  1024. function intakeDefines() {
  1025. var args;
  1026. //Any defined modules in the global queue, intake them now.
  1027. takeGlobalQueue();
  1028. //Make sure any remaining defQueue items get properly processed.
  1029. while (defQueue.length) {
  1030. args = defQueue.shift();
  1031. if (args[0] === null) {
  1032. return onError(makeError('mismatch', 'Mismatched anonymous define() module: ' + args[args.length - 1]));
  1033. } else {
  1034. //args are id, deps, factory. Should be normalized by the
  1035. //define() function.
  1036. callGetModule(args);
  1037. }
  1038. }
  1039. }
  1040. context = {
  1041. config: config,
  1042. contextName: contextName,
  1043. registry: registry,
  1044. defined: defined,
  1045. urlFetched: urlFetched,
  1046. defQueue: defQueue,
  1047. Module: Module,
  1048. makeModuleMap: makeModuleMap,
  1049. nextTick: req.nextTick,
  1050. /**
  1051. * Set a configuration for the context.
  1052. * @param {Object} cfg config object to integrate.
  1053. */
  1054. configure: function (cfg) {
  1055. //Make sure the baseUrl ends in a slash.
  1056. if (cfg.baseUrl) {
  1057. if (cfg.baseUrl.charAt(cfg.baseUrl.length - 1) !== '/') {
  1058. cfg.baseUrl += '/';
  1059. }
  1060. }
  1061. //Save off the paths and packages since they require special processing,
  1062. //they are additive.
  1063. var pkgs = config.pkgs,
  1064. shim = config.shim,
  1065. objs = {
  1066. paths: true,
  1067. config: true,
  1068. map: true
  1069. };
  1070. eachProp(cfg, function (value, prop) {
  1071. if (objs[prop]) {
  1072. if (prop === 'map') {
  1073. mixin(config[prop], value, true, true);
  1074. } else {
  1075. mixin(config[prop], value, true);
  1076. }
  1077. } else {
  1078. config[prop] = value;
  1079. }
  1080. });
  1081. //Merge shim
  1082. if (cfg.shim) {
  1083. eachProp(cfg.shim, function (value, id) {
  1084. //Normalize the structure
  1085. if (isArray(value)) {
  1086. value = {
  1087. deps: value
  1088. };
  1089. }
  1090. if (value.exports && !value.exportsFn) {
  1091. value.exportsFn = context.makeShimExports(value);
  1092. }
  1093. shim[id] = value;
  1094. });
  1095. config.shim = shim;
  1096. }
  1097. //Adjust packages if necessary.
  1098. if (cfg.packages) {
  1099. each(cfg.packages, function (pkgObj) {
  1100. var location;
  1101. pkgObj = typeof pkgObj === 'string' ? { name: pkgObj } : pkgObj;
  1102. location = pkgObj.location;
  1103. //Create a brand new object on pkgs, since currentPackages can
  1104. //be passed in again, and config.pkgs is the internal transformed
  1105. //state for all package configs.
  1106. pkgs[pkgObj.name] = {
  1107. name: pkgObj.name,
  1108. location: location || pkgObj.name,
  1109. //Remove leading dot in main, so main paths are normalized,
  1110. //and remove any trailing .js, since different package
  1111. //envs have different conventions: some use a module name,
  1112. //some use a file name.
  1113. main: (pkgObj.main || 'main')
  1114. .replace(currDirRegExp, '')
  1115. .replace(jsSuffixRegExp, '')
  1116. };
  1117. });
  1118. //Done with modifications, assing packages back to context config
  1119. config.pkgs = pkgs;
  1120. }
  1121. //If there are any "waiting to execute" modules in the registry,
  1122. //update the maps for them, since their info, like URLs to load,
  1123. //may have changed.
  1124. eachProp(registry, function (mod, id) {
  1125. //If module already has init called, since it is too
  1126. //late to modify them, and ignore unnormalized ones
  1127. //since they are transient.
  1128. if (!mod.inited && !mod.map.unnormalized) {
  1129. mod.map = makeModuleMap(id);
  1130. }
  1131. });
  1132. //If a deps array or a config callback is specified, then call
  1133. //require with those args. This is useful when require is defined as a
  1134. //config object before require.js is loaded.
  1135. if (cfg.deps || cfg.callback) {
  1136. context.require(cfg.deps || [], cfg.callback);
  1137. }
  1138. },
  1139. makeShimExports: function (value) {
  1140. function fn() {
  1141. var ret;
  1142. if (value.init) {
  1143. ret = value.init.apply(global, arguments);
  1144. }
  1145. return ret || getGlobal(value.exports);
  1146. }
  1147. return fn;
  1148. },
  1149. makeRequire: function (relMap, options) {
  1150. options = options || {};
  1151. function localRequire(deps, callback, errback) {
  1152. var id, map, requireMod;
  1153. if (options.enableBuildCallback && callback && isFunction(callback)) {
  1154. callback.__requireJsBuild = true;
  1155. }
  1156. if (typeof deps === 'string') {
  1157. if (isFunction(callback)) {
  1158. //Invalid call
  1159. return onError(makeError('requireargs', 'Invalid require call'), errback);
  1160. }
  1161. //If require|exports|module are requested, get the
  1162. //value for them from the special handlers. Caveat:
  1163. //this only works while module is being defined.
  1164. if (relMap && handlers[deps]) {
  1165. return handlers[deps](registry[relMap.id]);
  1166. }
  1167. //Synchronous access to one module. If require.get is
  1168. //available (as in the Node adapter), prefer that.
  1169. if (req.get) {
  1170. return req.get(context, deps, relMap);
  1171. }
  1172. //Normalize module name, if it contains . or ..
  1173. map = makeModuleMap(deps, relMap, false, true);
  1174. id = map.id;
  1175. if (!hasProp(defined, id)) {
  1176. return onError(makeError('notloaded', 'Module name "' +
  1177. id +
  1178. '" has not been loaded yet for context: ' +
  1179. contextName +
  1180. (relMap ? '' : '. Use require([])')));
  1181. }
  1182. return defined[id];
  1183. }
  1184. //Grab defines waiting in the global queue.
  1185. intakeDefines();
  1186. //Mark all the dependencies as needing to be loaded.
  1187. context.nextTick(function () {
  1188. //Some defines could have been added since the
  1189. //require call, collect them.
  1190. intakeDefines();
  1191. requireMod = getModule(makeModuleMap(null, relMap));
  1192. //Store if map config should be applied to this require
  1193. //call for dependencies.
  1194. requireMod.skipMap = options.skipMap;
  1195. requireMod.init(deps, callback, errback, {
  1196. enabled: true
  1197. });
  1198. checkLoaded();
  1199. });
  1200. return localRequire;
  1201. }
  1202. mixin(localRequire, {
  1203. isBrowser: isBrowser,
  1204. /**
  1205. * Converts a module name + .extension into an URL path.
  1206. * *Requires* the use of a module name. It does not support using
  1207. * plain URLs like nameToUrl.
  1208. */
  1209. toUrl: function (moduleNamePlusExt) {
  1210. var index = moduleNamePlusExt.lastIndexOf('.'),
  1211. ext = null;
  1212. if (index !== -1) {
  1213. ext = moduleNamePlusExt.substring(index, moduleNamePlusExt.length);
  1214. moduleNamePlusExt = moduleNamePlusExt.substring(0, index);
  1215. }
  1216. return context.nameToUrl(normalize(moduleNamePlusExt,
  1217. relMap && relMap.id, true), ext);
  1218. },
  1219. defined: function (id) {
  1220. return hasProp(defined, makeModuleMap(id, relMap, false, true).id);
  1221. },
  1222. specified: function (id) {
  1223. id = makeModuleMap(id, relMap, false, true).id;
  1224. return hasProp(defined, id) || hasProp(registry, id);
  1225. }
  1226. });
  1227. //Only allow undef on top level require calls
  1228. if (!relMap) {
  1229. localRequire.undef = function (id) {
  1230. //Bind any waiting define() calls to this context,
  1231. //fix for #408
  1232. takeGlobalQueue();
  1233. var map = makeModuleMap(id, relMap, true),
  1234. mod = registry[id];
  1235. delete defined[id];
  1236. delete urlFetched[map.url];
  1237. delete undefEvents[id];
  1238. if (mod) {
  1239. //Hold on to listeners in case the
  1240. //module will be attempted to be reloaded
  1241. //using a different config.
  1242. if (mod.events.defined) {
  1243. undefEvents[id] = mod.events;
  1244. }
  1245. cleanRegistry(id);
  1246. }
  1247. };
  1248. }
  1249. return localRequire;
  1250. },
  1251. /**
  1252. * Called to enable a module if it is still in the registry
  1253. * awaiting enablement. parent module is passed in for context,
  1254. * used by the optimizer.
  1255. */
  1256. enable: function (depMap, parent) {
  1257. var mod = registry[depMap.id];
  1258. if (mod) {
  1259. getModule(depMap).enable();
  1260. }
  1261. },
  1262. /**
  1263. * Internal method used by environment adapters to complete a load event.
  1264. * A load event could be a script load or just a load pass from a synchronous
  1265. * load call.
  1266. * @param {String} moduleName the name of the module to potentially complete.
  1267. */
  1268. completeLoad: function (moduleName) {
  1269. var found, args, mod,
  1270. shim = config.shim[moduleName] || {},
  1271. shExports = shim.exports;
  1272. takeGlobalQueue();
  1273. while (defQueue.length) {
  1274. args = defQueue.shift();
  1275. if (args[0] === null) {
  1276. args[0] = moduleName;
  1277. //If already found an anonymous module and bound it
  1278. //to this name, then this is some other anon module
  1279. //waiting for its completeLoad to fire.
  1280. if (found) {
  1281. break;
  1282. }
  1283. found = true;
  1284. } else if (args[0] === moduleName) {
  1285. //Found matching define call for this script!
  1286. found = true;
  1287. }
  1288. callGetModule(args);
  1289. }
  1290. //Do this after the cycle of callGetModule in case the result
  1291. //of those calls/init calls changes the registry.
  1292. mod = registry[moduleName];
  1293. if (!found && !defined[moduleName] && mod && !mod.inited) {
  1294. if (config.enforceDefine && (!shExports || !getGlobal(shExports))) {
  1295. if (hasPathFallback(moduleName)) {
  1296. return;
  1297. } else {
  1298. return onError(makeError('nodefine',
  1299. 'No define call for ' + moduleName,
  1300. null,
  1301. [moduleName]));
  1302. }
  1303. } else {
  1304. //A script that does not call define(), so just simulate
  1305. //the call for it.
  1306. callGetModule([moduleName, (shim.deps || []), shim.exportsFn]);
  1307. }
  1308. }
  1309. checkLoaded();
  1310. },
  1311. /**
  1312. * Converts a module name to a file path. Supports cases where
  1313. * moduleName may actually be just an URL.
  1314. * Note that it **does not** call normalize on the moduleName,
  1315. * it is assumed to have already been normalized. This is an
  1316. * internal API, not a public one. Use toUrl for the public API.
  1317. */
  1318. nameToUrl: function (moduleName, ext) {
  1319. var paths, pkgs, pkg, pkgPath, syms, i, parentModule, url,
  1320. parentPath;
  1321. //If a colon is in the URL, it indicates a protocol is used and it is just
  1322. //an URL to a file, or if it starts with a slash, contains a query arg (i.e. ?)
  1323. //or ends with .js, then assume the user meant to use an url and not a module id.
  1324. //The slash is important for protocol-less URLs as well as full paths.
  1325. if (req.jsExtRegExp.test(moduleName)) {
  1326. //Just a plain path, not module name lookup, so just return it.
  1327. //Add extension if it is included. This is a bit wonky, only non-.js things pass
  1328. //an extension, this method probably needs to be reworked.
  1329. url = moduleName + (ext || '');
  1330. } else {
  1331. //A module that needs to be converted to a path.
  1332. paths = config.paths;
  1333. pkgs = config.pkgs;
  1334. syms = moduleName.split('/');
  1335. //For each module name segment, see if there is a path
  1336. //registered for it. Start with most specific name
  1337. //and work up from it.
  1338. for (i = syms.length; i > 0; i -= 1) {
  1339. parentModule = syms.slice(0, i).join('/');
  1340. pkg = pkgs[parentModule];
  1341. parentPath = paths[parentModule];
  1342. if (parentPath) {
  1343. //If an array, it means there are a few choices,
  1344. //Choose the one that is desired
  1345. if (isArray(parentPath)) {
  1346. parentPath = parentPath[0];
  1347. }
  1348. syms.splice(0, i, parentPath);
  1349. break;
  1350. } else if (pkg) {
  1351. //If module name is just the package name, then looking
  1352. //for the main module.
  1353. if (moduleName === pkg.name) {
  1354. pkgPath = pkg.location + '/' + pkg.main;
  1355. } else {
  1356. pkgPath = pkg.location;
  1357. }
  1358. syms.splice(0, i, pkgPath);
  1359. break;
  1360. }
  1361. }
  1362. //Join the path parts together, then figure out if baseUrl is needed.
  1363. url = syms.join('/');
  1364. url += (ext || (/\?/.test(url) ? '' : '.js'));
  1365. url = (url.charAt(0) === '/' || url.match(/^[\w\+\.\-]+:/) ? '' : config.baseUrl) + url;
  1366. }
  1367. return config.urlArgs ? url +
  1368. ((url.indexOf('?') === -1 ? '?' : '&') +
  1369. config.urlArgs) : url;
  1370. },
  1371. //Delegates to req.load. Broken out as a separate function to
  1372. //allow overriding in the optimizer.
  1373. load: function (id, url) {
  1374. req.load(context, id, url);
  1375. },
  1376. /**
  1377. * Executes a module callack function. Broken out as a separate function
  1378. * solely to allow the build system to sequence the files in the built
  1379. * layer in the right sequence.
  1380. *
  1381. * @private
  1382. */
  1383. execCb: function (name, callback, args, exports) {
  1384. return callback.apply(exports, args);
  1385. },
  1386. /**
  1387. * callback for script loads, used to check status of loading.
  1388. *
  1389. * @param {Event} evt the event from the browser for the script
  1390. * that was loaded.
  1391. */
  1392. onScriptLoad: function (evt) {
  1393. //Using currentTarget instead of target for Firefox 2.0's sake. Not
  1394. //all old browsers will be supported, but this one was easy enough
  1395. //to support and still makes sense.
  1396. if (evt.type === 'load' ||
  1397. (readyRegExp.test((evt.currentTarget || evt.srcElement).readyState))) {
  1398. //Reset interactive script so a script node is not held onto for
  1399. //to long.
  1400. interactiveScript = null;
  1401. //Pull out the name of the module and the context.
  1402. var data = getScriptData(evt);
  1403. context.completeLoad(data.id);
  1404. }
  1405. },
  1406. /**
  1407. * Callback for script errors.
  1408. */
  1409. onScriptError: function (evt) {
  1410. var data = getScriptData(evt);
  1411. if (!hasPathFallback(data.id)) {
  1412. return onError(makeError('scripterror', 'Script error', evt, [data.id]));
  1413. }
  1414. }
  1415. };
  1416. context.require = context.makeRequire();
  1417. return context;
  1418. }
  1419. /**
  1420. * Main entry point.
  1421. *
  1422. * If the only argument to require is a string, then the module that
  1423. * is represented by that string is fetched for the appropriate context.
  1424. *
  1425. * If the first argument is an array, then it will be treated as an array
  1426. * of dependency string names to fetch. An optional function callback can
  1427. * be specified to execute when all of those dependencies are available.
  1428. *
  1429. * Make a local req variable to help Caja compliance (it assumes things
  1430. * on a require that are not standardized), and to give a short
  1431. * name for minification/local scope use.
  1432. */
  1433. req = requirejs = function (deps, callback, errback, optional) {
  1434. //Find the right context, use default
  1435. var context, config,
  1436. contextName = defContextName;
  1437. // Determine if have config object in the call.
  1438. if (!isArray(deps) && typeof deps !== 'string') {
  1439. // deps is a config object
  1440. config = deps;
  1441. if (isArray(callback)) {
  1442. // Adjust args if there are dependencies
  1443. deps = callback;
  1444. callback = errback;
  1445. errback = optional;
  1446. } else {
  1447. deps = [];
  1448. }
  1449. }
  1450. if (config && config.context) {
  1451. contextName = config.context;
  1452. }
  1453. context = contexts[contextName];
  1454. if (!context) {
  1455. context = contexts[contextName] = req.s.newContext(contextName);
  1456. }
  1457. if (config) {
  1458. context.configure(config);
  1459. }
  1460. return context.require(deps, callback, errback);
  1461. };
  1462. /**
  1463. * Support require.config() to make it easier to cooperate with other
  1464. * AMD loaders on globally agreed names.
  1465. */
  1466. req.config = function (config) {
  1467. return req(config);
  1468. };
  1469. /**
  1470. * Execute something after the current tick
  1471. * of the event loop. Override for other envs
  1472. * that have a better solution than setTimeout.
  1473. * @param {Function} fn function to execute later.
  1474. */
  1475. req.nextTick = typeof setTimeout !== 'undefined' ? function (fn) {
  1476. setTimeout(fn, 4);
  1477. } : function (fn) { fn(); };
  1478. /**
  1479. * Export require as a global, but only if it does not already exist.
  1480. */
  1481. if (!require) {
  1482. require = req;
  1483. }
  1484. req.version = version;
  1485. //Used to filter out dependencies that are already paths.
  1486. req.jsExtRegExp = /^\/|:|\?|\.js$/;
  1487. req.isBrowser = isBrowser;
  1488. s = req.s = {
  1489. contexts: contexts,
  1490. newContext: newContext
  1491. };
  1492. //Create default context.
  1493. req({});
  1494. //Exports some context-sensitive methods on global require.
  1495. each([
  1496. 'toUrl',
  1497. 'undef',
  1498. 'defined',
  1499. 'specified'
  1500. ], function (prop) {
  1501. //Reference from contexts instead of early binding to default context,
  1502. //so that during builds, the latest instance of the default context
  1503. //with its config gets used.
  1504. req[prop] = function () {
  1505. var ctx = contexts[defContextName];
  1506. return ctx.require[prop].apply(ctx, arguments);
  1507. };
  1508. });
  1509. if (isBrowser) {
  1510. head = s.head = document.getElementsByTagName('head')[0];
  1511. //If BASE tag is in play, using appendChild is a problem for IE6.
  1512. //When that browser dies, this can be removed. Details in this jQuery bug:
  1513. //http://dev.jquery.com/ticket/2709
  1514. baseElement = document.getElementsByTagName('base')[0];
  1515. if (baseElement) {
  1516. head = s.head = baseElement.parentNode;
  1517. }
  1518. }
  1519. /**
  1520. * Any errors that require explicitly generates will be passed to this
  1521. * function. Intercept/override it if you want custom error handling.
  1522. * @param {Error} err the error object.
  1523. */
  1524. req.onError = function (err) {
  1525. throw err;
  1526. };
  1527. /**
  1528. * Does the request to load a module for the browser case.
  1529. * Make this a separate function to allow other environments
  1530. * to override it.
  1531. *
  1532. * @param {Object} context the require context to find state.
  1533. * @param {String} moduleName the name of the module.
  1534. * @param {Object} url the URL to the module.
  1535. */
  1536. req.load = function (context, moduleName, url) {
  1537. var config = (context && context.config) || {},
  1538. node;
  1539. if (isBrowser) {
  1540. //In the browser so use a script tag
  1541. node = config.xhtml ?
  1542. document.createElementNS('http://www.w3.org/1999/xhtml', 'html:script') :
  1543. document.createElement('script');
  1544. node.type = config.scriptType || 'text/javascript';
  1545. node.charset = 'utf-8';
  1546. node.async = true;
  1547. node.setAttribute('data-requirecontext', context.contextName);
  1548. node.setAttribute('data-requiremodule', moduleName);
  1549. //Set up load listener. Test attachEvent first because IE9 has
  1550. //a subtle issue in its addEventListener and script onload firings
  1551. //that do not match the behavior of all other browsers with
  1552. //addEventListener support, which fire the onload event for a
  1553. //script right after the script execution. See:
  1554. //https://connect.microsoft.com/IE/feedback/details/648057/script-onload-event-is-not-fired-immediately-after-script-execution
  1555. //UNFORTUNATELY Opera implements attachEvent but does not follow the script
  1556. //script execution mode.
  1557. if (node.attachEvent &&
  1558. //Check if node.attachEvent is artificially added by custom script or
  1559. //natively supported by browser
  1560. //read https://github.com/jrburke/requirejs/issues/187
  1561. //if we can NOT find [native code] then it must NOT natively supported.
  1562. //in IE8, node.attachEvent does not have toString()
  1563. //Note the test for "[native code" with no closing brace, see:
  1564. //https://github.com/jrburke/requirejs/issues/273
  1565. !(node.attachEvent.toString && node.attachEvent.toString().indexOf('[native code') < 0) &&
  1566. !isOpera) {
  1567. //Probably IE. IE (at least 6-8) do not fire
  1568. //script onload right after executing the script, so
  1569. //we cannot tie the anonymous define call to a name.
  1570. //However, IE reports the script as being in 'interactive'
  1571. //readyState at the time of the define call.
  1572. useInteractive = true;
  1573. node.attachEvent('onreadystatechange', context.onScriptLoad);
  1574. //It would be great to add an error handler here to catch
  1575. //404s in IE9+. However, onreadystatechange will fire before
  1576. //the error handler, so that does not help. If addEvenListener
  1577. //is used, then IE will fire error before load, but we cannot
  1578. //use that pathway given the connect.microsoft.com issue
  1579. //mentioned above about not doing the 'script execute,
  1580. //then fire the script load event listener before execute
  1581. //next script' that other browsers do.
  1582. //Best hope: IE10 fixes the issues,
  1583. //and then destroys all installs of IE 6-9.
  1584. //node.attachEvent('onerror', context.onScriptError);
  1585. } else {
  1586. node.addEventListener('load', context.onScriptLoad, false);
  1587. node.addEventListener('error', context.onScriptError, false);
  1588. }
  1589. node.src = url;
  1590. //For some cache cases in IE 6-8, the script executes before the end
  1591. //of the appendChild execution, so to tie an anonymous define
  1592. //call to the module name (which is stored on the node), hold on
  1593. //to a reference to this node, but clear after the DOM insertion.
  1594. currentlyAddingScript = node;
  1595. if (baseElement) {
  1596. head.insertBefore(node, baseElement);
  1597. } else {
  1598. head.appendChild(node);
  1599. }
  1600. currentlyAddingScript = null;
  1601. return node;
  1602. } else if (isWebWorker) {
  1603. //In a web worker, use importScripts. This is not a very
  1604. //efficient use of importScripts, importScripts will block until
  1605. //its script is downloaded and evaluated. However, if web workers
  1606. //are in play, the expectation that a build has been done so that
  1607. //only one script needs to be loaded anyway. This may need to be
  1608. //reevaluated if other use cases become common.
  1609. importScripts(url);
  1610. //Account for anonymous modules
  1611. context.completeLoad(moduleName);
  1612. }
  1613. };
  1614. function getInteractiveScript() {
  1615. if (interactiveScript && interactiveScript.readyState === 'interactive') {
  1616. return interactiveScript;
  1617. }
  1618. eachReverse(scripts(), function (script) {
  1619. if (script.readyState === 'interactive') {
  1620. return (interactiveScript = script);
  1621. }
  1622. });
  1623. return interactiveScript;
  1624. }
  1625. //Look for a data-main script attribute, which could also adjust the baseUrl.
  1626. if (isBrowser) {
  1627. //Figure out baseUrl. Get it from the script tag with require.js in it.
  1628. eachReverse(scripts(), function (script) {
  1629. //Set the 'head' where we can append children by
  1630. //using the script's parent.
  1631. if (!head) {
  1632. head = script.parentNode;
  1633. }
  1634. //Look for a data-main attribute to set main script for the page
  1635. //to load. If it is there, the path to data main becomes the
  1636. //baseUrl, if it is not already set.
  1637. dataMain = script.getAttribute('data-main');
  1638. if (dataMain) {
  1639. //Set final baseUrl if there is not already an explicit one.
  1640. if (!cfg.baseUrl) {
  1641. //Pull off the directory of data-main for use as the
  1642. //baseUrl.
  1643. src = dataMain.split('/');
  1644. mainScript = src.pop();
  1645. subPath = src.length ? src.join('/') + '/' : './';
  1646. cfg.baseUrl = subPath;
  1647. dataMain = mainScript;
  1648. }
  1649. //Strip off any trailing .js since dataMain is now
  1650. //like a module name.
  1651. dataMain = dataMain.replace(jsSuffixRegExp, '');
  1652. //Put the data-main script in the files to load.
  1653. cfg.deps = cfg.deps ? cfg.deps.concat(dataMain) : [dataMain];
  1654. return true;
  1655. }
  1656. });
  1657. }
  1658. /**
  1659. * The function that handles definitions of modules. Differs from
  1660. * require() in that a string for the module should be the first argument,
  1661. * and the function to execute after dependencies are loaded should
  1662. * return a value to define the module corresponding to the first argument's
  1663. * name.
  1664. */
  1665. define = function (name, deps, callback) {
  1666. var node, context;
  1667. //Allow for anonymous modules
  1668. if (typeof name !== 'string') {
  1669. //Adjust args appropriately
  1670. callback = deps;
  1671. deps = name;
  1672. name = null;
  1673. }
  1674. //This module may not have dependencies
  1675. if (!isArray(deps)) {
  1676. callback = deps;
  1677. deps = [];
  1678. }
  1679. //If no name, and callback is a function, then figure out if it a
  1680. //CommonJS thing with dependencies.
  1681. if (!deps.length && isFunction(callback)) {
  1682. //Remove comments from the callback string,
  1683. //look for require calls, and pull them into the dependencies,
  1684. //but only if there are function args.
  1685. if (callback.length) {
  1686. callback
  1687. .toString()
  1688. .replace(commentRegExp, '')
  1689. .replace(cjsRequireRegExp, function (match, dep) {
  1690. deps.push(dep);
  1691. });
  1692. //May be a CommonJS thing even without require calls, but still
  1693. //could use exports, and module. Avoid doing exports and module
  1694. //work though if it just needs require.
  1695. //REQUIRES the function to expect the CommonJS variables in the
  1696. //order listed below.
  1697. deps = (callback.length === 1 ? ['require'] : ['require', 'exports', 'module']).concat(deps);
  1698. }
  1699. }
  1700. //If in IE 6-8 and hit an anonymous define() call, do the interactive
  1701. //work.
  1702. if (useInteractive) {
  1703. node = currentlyAddingScript || getInteractiveScript();
  1704. if (node) {
  1705. if (!name) {
  1706. name = node.getAttribute('data-requiremodule');
  1707. }
  1708. context = contexts[node.getAttribute('data-requirecontext')];
  1709. }
  1710. }
  1711. //Always save off evaluating the def call until the script onload handler.
  1712. //This allows multiple modules to be in a file without prematurely
  1713. //tracing dependencies, and allows for anonymous module support,
  1714. //where the module name is not known until the script onload event
  1715. //occurs. If no context, use the global queue, and get it processed
  1716. //in the onscript load callback.
  1717. (context ? context.defQueue : globalDefQueue).push([name, deps, callback]);
  1718. };
  1719. define.amd = {
  1720. jQuery: true
  1721. };
  1722. /**
  1723. * Executes the text. Normally just uses eval, but can be modified
  1724. * to use a better, environment-specific call. Only used for transpiling
  1725. * loader plugins, not for plain JS modules.
  1726. * @param {String} text the text to execute/evaluate.
  1727. */
  1728. req.exec = function (text) {
  1729. /*jslint evil: true */
  1730. return eval(text);
  1731. };
  1732. //Set up with config info.
  1733. req(cfg);
  1734. }(this));
  1735. /*!
  1736. * jQuery JavaScript Library v1.8.2
  1737. * http://jquery.com/
  1738. *
  1739. * Includes Sizzle.js
  1740. * http://sizzlejs.com/
  1741. *
  1742. * Copyright 2012 jQuery Foundation and other contributors
  1743. * Released under the MIT license
  1744. * http://jquery.org/license
  1745. *
  1746. * Date: Thu Sep 20 2012 21:13:05 GMT-0400 (Eastern Daylight Time)
  1747. */
  1748. (function( window, undefined ) {
  1749. var
  1750. // A central reference to the root jQuery(document)
  1751. rootjQuery,
  1752. // The deferred used on DOM ready
  1753. readyList,
  1754. // Use the correct document accordingly with window argument (sandbox)
  1755. document = window.document,
  1756. location = window.location,
  1757. navigator = window.navigator,
  1758. // Map over jQuery in case of overwrite
  1759. _jQuery = window.jQuery,
  1760. // Map over the $ in case of overwrite
  1761. _$ = window.$,
  1762. // Save a reference to some core methods
  1763. core_push = Array.prototype.push,
  1764. core_slice = Array.prototype.slice,
  1765. core_indexOf = Array.prototype.indexOf,
  1766. core_toString = Object.prototype.toString,
  1767. core_hasOwn = Object.prototype.hasOwnProperty,
  1768. core_trim = String.prototype.trim,
  1769. // Define a local copy of jQuery
  1770. jQuery = function( selector, context ) {
  1771. // The jQuery object is actually just the init constructor 'enhanced'
  1772. return new jQuery.fn.init( selector, context, rootjQuery );
  1773. },
  1774. // Used for matching numbers
  1775. core_pnum = /[\-+]?(?:\d*\.|)\d+(?:[eE][\-+]?\d+|)/.source,
  1776. // Used for detecting and trimming whitespace
  1777. core_rnotwhite = /\S/,
  1778. core_rspace = /\s+/,
  1779. // Make sure we trim BOM and NBSP (here's looking at you, Safari 5.0 and IE)
  1780. rtrim = /^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,
  1781. // A simple way to check for HTML strings
  1782. // Prioritize #id over <tag> to avoid XSS via location.hash (#9521)
  1783. rquickExpr = /^(?:[^#<]*(<[\w\W]+>)[^>]*$|#([\w\-]*)$)/,
  1784. // Match a standalone tag
  1785. rsingleTag = /^<(\w+)\s*\/?>(?:<\/\1>|)$/,
  1786. // JSON RegExp
  1787. rvalidchars = /^[\],:{}\s]*$/,
  1788. rvalidbraces = /(?:^|:|,)(?:\s*\[)+/g,
  1789. rvalidescape = /\\(?:["\\\/bfnrt]|u[\da-fA-F]{4})/g,
  1790. rvalidtokens = /"[^"\\\r\n]*"|true|false|null|-?(?:\d\d*\.|)\d+(?:[eE][\-+]?\d+|)/g,
  1791. // Matches dashed string for camelizing
  1792. rmsPrefix = /^-ms-/,
  1793. rdashAlpha = /-([\da-z])/gi,
  1794. // Used by jQuery.camelCase as callback to replace()
  1795. fcamelCase = function( all, letter ) {
  1796. return ( letter + "" ).toUpperCase();
  1797. },
  1798. // The ready event handler and self cleanup method
  1799. DOMContentLoaded = function() {
  1800. if ( document.addEventListener ) {
  1801. document.removeEventListener( "DOMContentLoaded", DOMContentLoaded, false );
  1802. jQuery.ready();
  1803. } else if ( document.readyState === "complete" ) {
  1804. // we're here because readyState === "complete" in oldIE
  1805. // which is good enough for us to call the dom ready!
  1806. document.detachEvent( "onreadystatechange", DOMContentLoaded );
  1807. jQuery.ready();
  1808. }
  1809. },
  1810. // [[Class]] -> type pairs
  1811. class2type = {};
  1812. jQuery.fn = jQuery.prototype = {
  1813. constructor: jQuery,
  1814. init: function( selector, context, rootjQuery ) {
  1815. var match, elem, ret, doc;
  1816. // Handle $(""), $(null), $(undefined), $(false)
  1817. if ( !selector ) {
  1818. return this;
  1819. }
  1820. // Handle $(DOMElement)
  1821. if ( selector.nodeType ) {
  1822. this.context = this[0] = selector;
  1823. this.length = 1;
  1824. return this;
  1825. }
  1826. // Handle HTML strings
  1827. if ( typeof selector === "string" ) {
  1828. if ( selector.charAt(0) === "<" && selector.charAt( selector.length - 1 ) === ">" && selector.length >= 3 ) {
  1829. // Assume that strings that start and end with <> are HTML and skip the regex check
  1830. match = [ null, selector, null ];
  1831. } else {
  1832. match = rquickExpr.exec( selector );
  1833. }
  1834. // Match html or make sure no context is specified for #id
  1835. if ( match && (match[1] || !context) ) {
  1836. // HANDLE: $(html) -> $(array)
  1837. if ( match[1] ) {
  1838. context = context instanceof jQuery ? context[0] : context;
  1839. doc = ( context && context.nodeType ? context.ownerDocument || context : document );
  1840. // scripts is true for back-compat
  1841. selector = jQuery.parseHTML( match[1], doc, true );
  1842. if ( rsingleTag.test( match[1] ) && jQuery.isPlainObject( context ) ) {
  1843. this.attr.call( selector, context, true );
  1844. }
  1845. return jQuery.merge( this, selector );
  1846. // HANDLE: $(#id)
  1847. } else {
  1848. elem = document.getElementById( match[2] );
  1849. // Check parentNode to catch when Blackberry 4.6 returns
  1850. // nodes that are no longer in the document #6963
  1851. if ( elem && elem.parentNode ) {
  1852. // Handle the case where IE and Opera return items
  1853. // by name instead of ID
  1854. if ( elem.id !== match[2] ) {
  1855. return rootjQuery.find( selector );
  1856. }
  1857. // Otherwise, we inject the element directly into the jQuery object
  1858. this.length = 1;
  1859. this[0] = elem;
  1860. }
  1861. this.context = document;
  1862. this.selector = selector;
  1863. return this;
  1864. }
  1865. // HANDLE: $(expr, $(...))
  1866. } else if ( !context || context.jquery ) {
  1867. return ( context || rootjQuery ).find( selector );
  1868. // HANDLE: $(expr, context)
  1869. // (which is just equivalent to: $(context).find(expr)
  1870. } else {
  1871. return this.constructor( context ).find( selector );
  1872. }
  1873. // HANDLE: $(function)
  1874. // Shortcut for document ready
  1875. } else if ( jQuery.isFunction( selector ) ) {
  1876. return rootjQuery.ready( selector );
  1877. }
  1878. if ( selector.selector !== undefined ) {
  1879. this.selector = selector.selector;
  1880. this.context = selector.context;
  1881. }
  1882. return jQuery.makeArray( selector, this );
  1883. },
  1884. // Start with an empty selector
  1885. selector: "",
  1886. // The current version of jQuery being used
  1887. jquery: "1.8.2",
  1888. // The default length of a jQuery object is 0
  1889. length: 0,
  1890. // The number of elements contained in the matched element set
  1891. size: function() {
  1892. return this.length;
  1893. },
  1894. toArray: function() {
  1895. return core_slice.call( this );
  1896. },
  1897. // Get the Nth element in the matched element set OR
  1898. // Get the whole matched element set as a clean array
  1899. get: function( num ) {
  1900. return num == null ?
  1901. // Return a 'clean' array
  1902. this.toArray() :
  1903. // Return just the object
  1904. ( num < 0 ? this[ this.length + num ] : this[ num ] );
  1905. },
  1906. // Take an array of elements and push it onto the stack
  1907. // (returning the new matched element set)
  1908. pushStack: function( elems, name, selector ) {
  1909. // Build a new jQuery matched element set
  1910. var ret = jQuery.merge( this.constructor(), elems );
  1911. // Add the old object onto the stack (as a reference)
  1912. ret.prevObject = this;
  1913. ret.context = this.context;
  1914. if ( name === "find" ) {
  1915. ret.selector = this.selector + ( this.selector ? " " : "" ) + selector;
  1916. } else if ( name ) {
  1917. ret.selector = this.selector + "." + name + "(" + selector + ")";
  1918. }
  1919. // Return the newly-formed element set
  1920. return ret;
  1921. },
  1922. // Execute a callback for every element in the matched set.
  1923. // (You can seed the arguments with an array of args, but this is
  1924. // only used internally.)
  1925. each: function( callback, args ) {
  1926. return jQuery.each( this, callback, args );
  1927. },
  1928. ready: function( fn ) {
  1929. // Add the callback
  1930. jQuery.ready.promise().done( fn );
  1931. return this;
  1932. },
  1933. eq: function( i ) {
  1934. i = +i;
  1935. return i === -1 ?
  1936. this.slice( i ) :
  1937. this.slice( i, i + 1 );
  1938. },
  1939. first: function() {
  1940. return this.eq( 0 );
  1941. },
  1942. last: function() {
  1943. return this.eq( -1 );
  1944. },
  1945. slice: function() {
  1946. return this.pushStack( core_slice.apply( this, arguments ),
  1947. "slice", core_slice.call(arguments).join(",") );
  1948. },
  1949. map: function( callback ) {
  1950. return this.pushStack( jQuery.map(this, function( elem, i ) {
  1951. return callback.call( elem, i, elem );
  1952. }));
  1953. },
  1954. end: function() {
  1955. return this.prevObject || this.constructor(null);
  1956. },
  1957. // For internal use only.
  1958. // Behaves like an Array's method, not like a jQuery method.
  1959. push: core_push,
  1960. sort: [].sort,
  1961. splice: [].splice
  1962. };
  1963. // Give the init function the jQuery prototype for later instantiation
  1964. jQuery.fn.init.prototype = jQuery.fn;
  1965. jQuery.extend = jQuery.fn.extend = function() {
  1966. var options, name, src, copy, copyIsArray, clone,
  1967. target = arguments[0] || {},
  1968. i = 1,
  1969. length = arguments.length,
  1970. deep = false;
  1971. // Handle a deep copy situation
  1972. if ( typeof target === "boolean" ) {
  1973. deep = target;
  1974. target = arguments[1] || {};
  1975. // skip the boolean and the target
  1976. i = 2;
  1977. }
  1978. // Handle case when target is a string or something (possible in deep copy)
  1979. if ( typeof target !== "object" && !jQuery.isFunction(target) ) {
  1980. target = {};
  1981. }
  1982. // extend jQuery itself if only one argument is passed
  1983. if ( length === i ) {
  1984. target = this;
  1985. --i;
  1986. }
  1987. for ( ; i < length; i++ ) {
  1988. // Only deal with non-null/undefined values
  1989. if ( (options = arguments[ i ]) != null ) {
  1990. // Extend the base object
  1991. for ( name in options ) {
  1992. src = target[ name ];
  1993. copy = options[ name ];
  1994. // Prevent never-ending loop
  1995. if ( target === copy ) {
  1996. continue;
  1997. }
  1998. // Recurse if we're merging plain objects or arrays
  1999. if ( deep && copy && ( jQuery.isPlainObject(copy) || (copyIsArray = jQuery.isArray(copy)) ) ) {
  2000. if ( copyIsArray ) {
  2001. copyIsArray = false;
  2002. clone = src && jQuery.isArray(src) ? src : [];
  2003. } else {
  2004. clone = src && jQuery.isPlainObject(src) ? src : {};
  2005. }
  2006. // Never move original objects, clone them
  2007. target[ name ] = jQuery.extend( deep, clone, copy );
  2008. // Don't bring in undefined values
  2009. } else if ( copy !== undefined ) {
  2010. target[ name ] = copy;
  2011. }
  2012. }
  2013. }
  2014. }
  2015. // Return the modified object
  2016. return target;
  2017. };
  2018. jQuery.extend({
  2019. noConflict: function( deep ) {
  2020. if ( window.$ === jQuery ) {
  2021. window.$ = _$;
  2022. }
  2023. if ( deep && window.jQuery === jQuery ) {
  2024. window.jQuery = _jQuery;
  2025. }
  2026. return jQuery;
  2027. },
  2028. // Is the DOM ready to be used? Set to true once it occurs.
  2029. isReady: false,
  2030. // A counter to track how many items to wait for before
  2031. // the ready event fires. See #6781
  2032. readyWait: 1,
  2033. // Hold (or release) the ready event
  2034. holdReady: function( hold ) {
  2035. if ( hold ) {
  2036. jQuery.readyWait++;
  2037. } else {
  2038. jQuery.ready( true );
  2039. }
  2040. },
  2041. // Handle when the DOM is ready
  2042. ready: function( wait ) {
  2043. // Abort if there are pending holds or we're already ready
  2044. if ( wait === true ? --jQuery.readyWait : jQuery.isReady ) {
  2045. return;
  2046. }
  2047. // Make sure body exists, at least, in case IE gets a little overzealous (ticket #5443).
  2048. if ( !document.body ) {
  2049. return setTimeout( jQuery.ready, 1 );
  2050. }
  2051. // Remember that the DOM is ready
  2052. jQuery.isReady = true;
  2053. // If a normal DOM Ready event fired, decrement, and wait if need be
  2054. if ( wait !== true && --jQuery.readyWait > 0 ) {
  2055. return;
  2056. }
  2057. // If there are functions bound, to execute
  2058. readyList.resolveWith( document, [ jQuery ] );
  2059. // Trigger any bound ready events
  2060. if ( jQuery.fn.trigger ) {
  2061. jQuery( document ).trigger("ready").off("ready");
  2062. }
  2063. },
  2064. // See test/unit/core.js for details concerning isFunction.
  2065. // Since version 1.3, DOM methods and functions like alert
  2066. // aren't supported. They return false on IE (#2968).
  2067. isFunction: function( obj ) {
  2068. return jQuery.type(obj) === "function";
  2069. },
  2070. isArray: Array.isArray || function( obj ) {
  2071. return jQuery.type(obj) === "array";
  2072. },
  2073. isWindow: function( obj ) {
  2074. return obj != null && obj == obj.window;
  2075. },
  2076. isNumeric: function( obj ) {
  2077. return !isNaN( parseFloat(obj) ) && isFinite( obj );
  2078. },
  2079. type: function( obj ) {
  2080. return obj == null ?
  2081. String( obj ) :
  2082. class2type[ core_toString.call(obj) ] || "object";
  2083. },
  2084. isPlainObject: function( obj ) {
  2085. // Must be an Object.
  2086. // Because of IE, we also have to check the presence of the constructor property.
  2087. // Make sure that DOM nodes and window objects don't pass through, as well
  2088. if ( !obj || jQuery.type(obj) !== "object" || obj.nodeType || jQuery.isWindow( obj ) ) {
  2089. return false;
  2090. }
  2091. try {
  2092. // Not own constructor property must be Object
  2093. if ( obj.constructor &&
  2094. !core_hasOwn.call(obj, "constructor") &&
  2095. !core_hasOwn.call(obj.constructor.prototype, "isPrototypeOf") ) {
  2096. return false;
  2097. }
  2098. } catch ( e ) {
  2099. // IE8,9 Will throw exceptions on certain host objects #9897
  2100. return false;
  2101. }
  2102. // Own properties are enumerated firstly, so to speed up,
  2103. // if last one is own, then all properties are own.
  2104. var key;
  2105. for ( key in obj ) {}
  2106. return key === undefined || core_hasOwn.call( obj, key );
  2107. },
  2108. isEmptyObject: function( obj ) {
  2109. var name;
  2110. for ( name in obj ) {
  2111. return false;
  2112. }
  2113. return true;
  2114. },
  2115. error: function( msg ) {
  2116. throw new Error( msg );
  2117. },
  2118. // data: string of html
  2119. // context (optional): If specified, the fragment will be created in this context, defaults to document
  2120. // scripts (optional): If true, will include scripts passed in the html string
  2121. parseHTML: function( data, context, scripts ) {
  2122. var parsed;
  2123. if ( !data || typeof data !== "string" ) {
  2124. return null;
  2125. }
  2126. if ( typeof context === "boolean" ) {
  2127. scripts = context;
  2128. context = 0;
  2129. }
  2130. context = context || document;
  2131. // Single tag
  2132. if ( (parsed = rsingleTag.exec( data )) ) {
  2133. return [ context.createElement( parsed[1] ) ];
  2134. }
  2135. parsed = jQuery.buildFragment( [ data ], context, scripts ? null : [] );
  2136. return jQuery.merge( [],
  2137. (parsed.cacheable ? jQuery.clone( parsed.fragment ) : parsed.fragment).childNodes );
  2138. },
  2139. parseJSON: function( data ) {
  2140. if ( !data || typeof data !== "string") {
  2141. return null;
  2142. }
  2143. // Make sure leading/trailing whitespace is removed (IE can't handle it)
  2144. data = jQuery.trim( data );
  2145. // Attempt to parse using the native JSON parser first
  2146. if ( window.JSON && window.JSON.parse ) {
  2147. return window.JSON.parse( data );
  2148. }
  2149. // Make sure the incoming data is actual JSON
  2150. // Logic borrowed from http://json.org/json2.js
  2151. if ( rvalidchars.test( data.replace( rvalidescape, "@" )
  2152. .replace( rvalidtokens, "]" )
  2153. .replace( rvalidbraces, "")) ) {
  2154. return ( new Function( "return " + data ) )();
  2155. }
  2156. jQuery.error( "Invalid JSON: " + data );
  2157. },
  2158. // Cross-browser xml parsing
  2159. parseXML: function( data ) {
  2160. var xml, tmp;
  2161. if ( !data || typeof data !== "string" ) {
  2162. return null;
  2163. }
  2164. try {
  2165. if ( window.DOMParser ) { // Standard
  2166. tmp = new DOMParser();
  2167. xml = tmp.parseFromString( data , "text/xml" );
  2168. } else { // IE
  2169. xml = new ActiveXObject( "Microsoft.XMLDOM" );
  2170. xml.async = "false";
  2171. xml.loadXML( data );
  2172. }
  2173. } catch( e ) {
  2174. xml = undefined;
  2175. }
  2176. if ( !xml || !xml.documentElement || xml.getElementsByTagName( "parsererror" ).length ) {
  2177. jQuery.error( "Invalid XML: " + data );
  2178. }
  2179. return xml;
  2180. },
  2181. noop: function() {},
  2182. // Evaluates a script in a global context
  2183. // Workarounds based on findings by Jim Driscoll
  2184. // http://weblogs.java.net/blog/driscoll/archive/2009/09/08/eval-javascript-global-context
  2185. globalEval: function( data ) {
  2186. if ( data && core_rnotwhite.test( data ) ) {
  2187. // We use execScript on Internet Explorer
  2188. // We use an anonymous function so that context is window
  2189. // rather than jQuery in Firefox
  2190. ( window.execScript || function( data ) {
  2191. window[ "eval" ].call( window, data );
  2192. } )( data );
  2193. }
  2194. },
  2195. // Convert dashed to camelCase; used by the css and data modules
  2196. // Microsoft forgot to hump their vendor prefix (#9572)
  2197. camelCase: function( string ) {
  2198. return string.replace( rmsPrefix, "ms-" ).replace( rdashAlpha, fcamelCase );
  2199. },
  2200. nodeName: function( elem, name ) {
  2201. return elem.nodeName && elem.nodeName.toLowerCase() === name.toLowerCase();
  2202. },
  2203. // args is for internal usage only
  2204. each: function( obj, callback, args ) {
  2205. var name,
  2206. i = 0,
  2207. length = obj.length,
  2208. isObj = length === undefined || jQuery.isFunction( obj );
  2209. if ( args ) {
  2210. if ( isObj ) {
  2211. for ( name in obj ) {
  2212. if ( callback.apply( obj[ name ], args ) === false ) {
  2213. break;
  2214. }
  2215. }
  2216. } else {
  2217. for ( ; i < length; ) {
  2218. if ( callback.apply( obj[ i++ ], args ) === false ) {
  2219. break;
  2220. }
  2221. }
  2222. }
  2223. // A special, fast, case for the most common use of each
  2224. } else {
  2225. if ( isObj ) {
  2226. for ( name in obj ) {
  2227. if ( callback.call( obj[ name ], name, obj[ name ] ) === false ) {
  2228. break;
  2229. }
  2230. }
  2231. } else {
  2232. for ( ; i < length; ) {
  2233. if ( callback.call( obj[ i ], i, obj[ i++ ] ) === false ) {
  2234. break;
  2235. }
  2236. }
  2237. }
  2238. }
  2239. return obj;
  2240. },
  2241. // Use native String.trim function wherever possible
  2242. trim: core_trim && !core_trim.call("\uFEFF\xA0") ?
  2243. function( text ) {
  2244. return text == null ?
  2245. "" :
  2246. core_trim.call( text );
  2247. } :
  2248. // Otherwise use our own trimming functionality
  2249. function( text ) {
  2250. return text == null ?
  2251. "" :
  2252. ( text + "" ).replace( rtrim, "" );
  2253. },
  2254. // results is for internal usage only
  2255. makeArray: function( arr, results ) {
  2256. var type,
  2257. ret = results || [];
  2258. if ( arr != null ) {
  2259. // The window, strings (and functions) also have 'length'
  2260. // Tweaked logic slightly to handle Blackberry 4.7 RegExp issues #6930
  2261. type = jQuery.type( arr );
  2262. if ( arr.length == null || type === "string" || type === "function" || type === "regexp" || jQuery.isWindow( arr ) ) {
  2263. core_push.call( ret, arr );
  2264. } else {
  2265. jQuery.merge( ret, arr );
  2266. }
  2267. }
  2268. return ret;
  2269. },
  2270. inArray: function( elem, arr, i ) {
  2271. var len;
  2272. if ( arr ) {
  2273. if ( core_indexOf ) {
  2274. return core_indexOf.call( arr, elem, i );
  2275. }
  2276. len = arr.length;
  2277. i = i ? i < 0 ? Math.max( 0, len + i ) : i : 0;
  2278. for ( ; i < len; i++ ) {
  2279. // Skip accessing in sparse arrays
  2280. if ( i in arr && arr[ i ] === elem ) {
  2281. return i;
  2282. }
  2283. }
  2284. }
  2285. return -1;
  2286. },
  2287. merge: function( first, second ) {
  2288. var l = second.length,
  2289. i = first.length,
  2290. j = 0;
  2291. if ( typeof l === "number" ) {
  2292. for ( ; j < l; j++ ) {
  2293. first[ i++ ] = second[ j ];
  2294. }
  2295. } else {
  2296. while ( second[j] !== undefined ) {
  2297. first[ i++ ] = second[ j++ ];
  2298. }
  2299. }
  2300. first.length = i;
  2301. return first;
  2302. },
  2303. grep: function( elems, callback, inv ) {
  2304. var retVal,
  2305. ret = [],
  2306. i = 0,
  2307. length = elems.length;
  2308. inv = !!inv;
  2309. // Go through the array, only saving the items
  2310. // that pass the validator function
  2311. for ( ; i < length; i++ ) {
  2312. retVal = !!callback( elems[ i ], i );
  2313. if ( inv !== retVal ) {
  2314. ret.push( elems[ i ] );
  2315. }
  2316. }
  2317. return ret;
  2318. },
  2319. // arg is for internal usage only
  2320. map: function( elems, callback, arg ) {
  2321. var value, key,
  2322. ret = [],
  2323. i = 0,
  2324. length = elems.length,
  2325. // jquery objects are treated as arrays
  2326. isArray = elems instanceof jQuery || length !== undefined && typeof length === "number" && ( ( length > 0 && elems[ 0 ] && elems[ length -1 ] ) || length === 0 || jQuery.isArray( elems ) ) ;
  2327. // Go through the array, translating each of the items to their
  2328. if ( isArray ) {
  2329. for ( ; i < length; i++ ) {
  2330. value = callback( elems[ i ], i, arg );
  2331. if ( value != null ) {
  2332. ret[ ret.length ] = value;
  2333. }
  2334. }
  2335. // Go through every key on the object,
  2336. } else {
  2337. for ( key in elems ) {
  2338. value = callback( elems[ key ], key, arg );
  2339. if ( value != null ) {
  2340. ret[ ret.length ] = value;
  2341. }
  2342. }
  2343. }
  2344. // Flatten any nested arrays
  2345. return ret.concat.apply( [], ret );
  2346. },
  2347. // A global GUID counter for objects
  2348. guid: 1,
  2349. // Bind a function to a context, optionally partially applying any
  2350. // arguments.
  2351. proxy: function( fn, context ) {
  2352. var tmp, args, proxy;
  2353. if ( typeof context === "string" ) {
  2354. tmp = fn[ context ];
  2355. context = fn;
  2356. fn = tmp;
  2357. }
  2358. // Quick check to determine if target is callable, in the spec
  2359. // this throws a TypeError, but we will just return undefined.
  2360. if ( !jQuery.isFunction( fn ) ) {
  2361. return undefined;
  2362. }
  2363. // Simulated bind
  2364. args = core_slice.call( arguments, 2 );
  2365. proxy = function() {
  2366. return fn.apply( context, args.concat( core_slice.call( arguments ) ) );
  2367. };
  2368. // Set the guid of unique handler to the same of original handler, so it can be removed
  2369. proxy.guid = fn.guid = fn.guid || jQuery.guid++;
  2370. return proxy;
  2371. },
  2372. // Multifunctional method to get and set values of a collection
  2373. // The value/s can optionally be executed if it's a function
  2374. access: function( elems, fn, key, value, chainable, emptyGet, pass ) {
  2375. var exec,
  2376. bulk = key == null,
  2377. i = 0,
  2378. length = elems.length;
  2379. // Sets many values
  2380. if ( key && typeof key === "object" ) {
  2381. for ( i in key ) {
  2382. jQuery.access( elems, fn, i, key[i], 1, emptyGet, value );
  2383. }
  2384. chainable = 1;
  2385. // Sets one value
  2386. } else if ( value !== undefined ) {
  2387. // Optionally, function values get executed if exec is true
  2388. exec = pass === undefined && jQuery.isFunction( value );
  2389. if ( bulk ) {
  2390. // Bulk operations only iterate when executing function values
  2391. if ( exec ) {
  2392. exec = fn;
  2393. fn = function( elem, key, value ) {
  2394. return exec.call( jQuery( elem ), value );
  2395. };
  2396. // Otherwise they run against the entire set
  2397. } else {
  2398. fn.call( elems, value );
  2399. fn = null;
  2400. }
  2401. }
  2402. if ( fn ) {
  2403. for (; i < length; i++ ) {
  2404. fn( elems[i], key, exec ? value.call( elems[i], i, fn( elems[i], key ) ) : value, pass );
  2405. }
  2406. }
  2407. chainable = 1;
  2408. }
  2409. return chainable ?
  2410. elems :
  2411. // Gets
  2412. bulk ?
  2413. fn.call( elems ) :
  2414. length ? fn( elems[0], key ) : emptyGet;
  2415. },
  2416. now: function() {
  2417. return ( new Date() ).getTime();
  2418. }
  2419. });
  2420. jQuery.ready.promise = function( obj ) {
  2421. if ( !readyList ) {
  2422. readyList = jQuery.Deferred();
  2423. // Catch cases where $(document).ready() is called after the browser event has already occurred.
  2424. // we once tried to use readyState "interactive" here, but it caused issues like the one
  2425. // discovered by ChrisS here: http://bugs.jquery.com/ticket/12282#comment:15
  2426. if ( document.readyState === "complete" ) {
  2427. // Handle it asynchronously to allow scripts the opportunity to delay ready
  2428. setTimeout( jQuery.ready, 1 );
  2429. // Standards-based browsers support DOMContentLoaded
  2430. } else if ( document.addEventListener ) {
  2431. // Use the handy event callback
  2432. document.addEventListener( "DOMContentLoaded", DOMContentLoaded, false );
  2433. // A fallback to window.onload, that will always work
  2434. window.addEventListener( "load", jQuery.ready, false );
  2435. // If IE event model is used
  2436. } else {
  2437. // Ensure firing before onload, maybe late but safe also for iframes
  2438. document.attachEvent( "onreadystatechange", DOMContentLoaded );
  2439. // A fallback to window.onload, that will always work
  2440. window.attachEvent( "onload", jQuery.ready );
  2441. // If IE and not a frame
  2442. // continually check to see if the document is ready
  2443. var top = false;
  2444. try {
  2445. top = window.frameElement == null && document.documentElement;
  2446. } catch(e) {}
  2447. if ( top && top.doScroll ) {
  2448. (function doScrollCheck() {
  2449. if ( !jQuery.isReady ) {
  2450. try {
  2451. // Use the trick by Diego Perini
  2452. // http://javascript.nwbox.com/IEContentLoaded/
  2453. top.doScroll("left");
  2454. } catch(e) {
  2455. return setTimeout( doScrollCheck, 50 );
  2456. }
  2457. // and execute any waiting functions
  2458. jQuery.ready();
  2459. }
  2460. })();
  2461. }
  2462. }
  2463. }
  2464. return readyList.promise( obj );
  2465. };
  2466. // Populate the class2type map
  2467. jQuery.each("Boolean Number String Function Array Date RegExp Object".split(" "), function(i, name) {
  2468. class2type[ "[object " + name + "]" ] = name.toLowerCase();
  2469. });
  2470. // All jQuery objects should point back to these
  2471. rootjQuery = jQuery(document);
  2472. // String to Object options format cache
  2473. var optionsCache = {};
  2474. // Convert String-formatted options into Object-formatted ones and store in cache
  2475. function createOptions( options ) {
  2476. var object = optionsCache[ options ] = {};
  2477. jQuery.each( options.split( core_rspace ), function( _, flag ) {
  2478. object[ flag ] = true;
  2479. });
  2480. return object;
  2481. }
  2482. /*
  2483. * Create a callback list using the following parameters:
  2484. *
  2485. * options: an optional list of space-separated options that will change how
  2486. * the callback list behaves or a more traditional option object
  2487. *
  2488. * By default a callback list will act like an event callback list and can be
  2489. * "fired" multiple times.
  2490. *
  2491. * Possible options:
  2492. *
  2493. * once: will ensure the callback list can only be fired once (like a Deferred)
  2494. *
  2495. * memory: will keep track of previous values and will call any callback added
  2496. * after the list has been fired right away with the latest "memorized"
  2497. * values (like a Deferred)
  2498. *
  2499. * unique: will ensure a callback can only be added once (no duplicate in the list)
  2500. *
  2501. * stopOnFalse: interrupt callings when a callback returns false
  2502. *
  2503. */
  2504. jQuery.Callbacks = function( options ) {
  2505. // Convert options from String-formatted to Object-formatted if needed
  2506. // (we check in cache first)
  2507. options = typeof options === "string" ?
  2508. ( optionsCache[ options ] || createOptions( options ) ) :
  2509. jQuery.extend( {}, options );
  2510. var // Last fire value (for non-forgettable lists)
  2511. memory,
  2512. // Flag to know if list was already fired
  2513. fired,
  2514. // Flag to know if list is currently firing
  2515. firing,
  2516. // First callback to fire (used internally by add and fireWith)
  2517. firingStart,
  2518. // End of the loop when firing
  2519. firingLength,
  2520. // Index of currently firing callback (modified by remove if needed)
  2521. firingIndex,
  2522. // Actual callback list
  2523. list = [],
  2524. // Stack of fire calls for repeatable lists
  2525. stack = !options.once && [],
  2526. // Fire callbacks
  2527. fire = function( data ) {
  2528. memory = options.memory && data;
  2529. fired = true;
  2530. firingIndex = firingStart || 0;
  2531. firingStart = 0;
  2532. firingLength = list.length;
  2533. firing = true;
  2534. for ( ; list && firingIndex < firingLength; firingIndex++ ) {
  2535. if ( list[ firingIndex ].apply( data[ 0 ], data[ 1 ] ) === false && options.stopOnFalse ) {
  2536. memory = false; // To prevent further calls using add
  2537. break;
  2538. }
  2539. }
  2540. firing = false;
  2541. if ( list ) {
  2542. if ( stack ) {
  2543. if ( stack.length ) {
  2544. fire( stack.shift() );
  2545. }
  2546. } else if ( memory ) {
  2547. list = [];
  2548. } else {
  2549. self.disable();
  2550. }
  2551. }
  2552. },
  2553. // Actual Callbacks object
  2554. self = {
  2555. // Add a callback or a collection of callbacks to the list
  2556. add: function() {
  2557. if ( list ) {
  2558. // First, we save the current length
  2559. var start = list.length;
  2560. (function add( args ) {
  2561. jQuery.each( args, function( _, arg ) {
  2562. var type = jQuery.type( arg );
  2563. if ( type === "function" && ( !options.unique || !self.has( arg ) ) ) {
  2564. list.push( arg );
  2565. } else if ( arg && arg.length && type !== "string" ) {
  2566. // Inspect recursively
  2567. add( arg );
  2568. }
  2569. });
  2570. })( arguments );
  2571. // Do we need to add the callbacks to the
  2572. // current firing batch?
  2573. if ( firing ) {
  2574. firingLength = list.length;
  2575. // With memory, if we're not firing then
  2576. // we should call right away
  2577. } else if ( memory ) {
  2578. firingStart = start;
  2579. fire( memory );
  2580. }
  2581. }
  2582. return this;
  2583. },
  2584. // Remove a callback from the list
  2585. remove: function() {
  2586. if ( list ) {
  2587. jQuery.each( arguments, function( _, arg ) {
  2588. var index;
  2589. while( ( index = jQuery.inArray( arg, list, index ) ) > -1 ) {
  2590. list.splice( index, 1 );
  2591. // Handle firing indexes
  2592. if ( firing ) {
  2593. if ( index <= firingLength ) {
  2594. firingLength--;
  2595. }
  2596. if ( index <= firingIndex ) {
  2597. firingIndex--;
  2598. }
  2599. }
  2600. }
  2601. });
  2602. }
  2603. return this;
  2604. },
  2605. // Control if a given callback is in the list
  2606. has: function( fn ) {
  2607. return jQuery.inArray( fn, list ) > -1;
  2608. },
  2609. // Remove all callbacks from the list
  2610. empty: function() {
  2611. list = [];
  2612. return this;
  2613. },
  2614. // Have the list do nothing anymore
  2615. disable: function() {
  2616. list = stack = memory = undefined;
  2617. return this;
  2618. },
  2619. // Is it disabled?
  2620. disabled: function() {
  2621. return !list;
  2622. },
  2623. // Lock the list in its current state
  2624. lock: function() {
  2625. stack = undefined;
  2626. if ( !memory ) {
  2627. self.disable();
  2628. }
  2629. return this;
  2630. },
  2631. // Is it locked?
  2632. locked: function() {
  2633. return !stack;
  2634. },
  2635. // Call all callbacks with the given context and arguments
  2636. fireWith: function( context, args ) {
  2637. args = args || [];
  2638. args = [ context, args.slice ? args.slice() : args ];
  2639. if ( list && ( !fired || stack ) ) {
  2640. if ( firing ) {
  2641. stack.push( args );
  2642. } else {
  2643. fire( args );
  2644. }
  2645. }
  2646. return this;
  2647. },
  2648. // Call all the callbacks with the given arguments
  2649. fire: function() {
  2650. self.fireWith( this, arguments );
  2651. return this;
  2652. },
  2653. // To know if the callbacks have already been called at least once
  2654. fired: function() {
  2655. return !!fired;
  2656. }
  2657. };
  2658. return self;
  2659. };
  2660. jQuery.extend({
  2661. Deferred: function( func ) {
  2662. var tuples = [
  2663. // action, add listener, listener list, final state
  2664. [ "resolve", "done", jQuery.Callbacks("once memory"), "resolved" ],
  2665. [ "reject", "fail", jQuery.Callbacks("once memory"), "rejected" ],
  2666. [ "notify", "progress", jQuery.Callbacks("memory") ]
  2667. ],
  2668. state = "pending",
  2669. promise = {
  2670. state: function() {
  2671. return state;
  2672. },
  2673. always: function() {
  2674. deferred.done( arguments ).fail( arguments );
  2675. return this;
  2676. },
  2677. then: function( /* fnDone, fnFail, fnProgress */ ) {
  2678. var fns = arguments;
  2679. return jQuery.Deferred(function( newDefer ) {
  2680. jQuery.each( tuples, function( i, tuple ) {
  2681. var action = tuple[ 0 ],
  2682. fn = fns[ i ];
  2683. // deferred[ done | fail | progress ] for forwarding actions to newDefer
  2684. deferred[ tuple[1] ]( jQuery.isFunction( fn ) ?
  2685. function() {
  2686. var returned = fn.apply( this, arguments );
  2687. if ( returned && jQuery.isFunction( returned.promise ) ) {
  2688. returned.promise()
  2689. .done( newDefer.resolve )
  2690. .fail( newDefer.reject )
  2691. .progress( newDefer.notify );
  2692. } else {
  2693. newDefer[ action + "With" ]( this === deferred ? newDefer : this, [ returned ] );
  2694. }
  2695. } :
  2696. newDefer[ action ]
  2697. );
  2698. });
  2699. fns = null;
  2700. }).promise();
  2701. },
  2702. // Get a promise for this deferred
  2703. // If obj is provided, the promise aspect is added to the object
  2704. promise: function( obj ) {
  2705. return obj != null ? jQuery.extend( obj, promise ) : promise;
  2706. }
  2707. },
  2708. deferred = {};
  2709. // Keep pipe for back-compat
  2710. promise.pipe = promise.then;
  2711. // Add list-specific methods
  2712. jQuery.each( tuples, function( i, tuple ) {
  2713. var list = tuple[ 2 ],
  2714. stateString = tuple[ 3 ];
  2715. // promise[ done | fail | progress ] = list.add
  2716. promise[ tuple[1] ] = list.add;
  2717. // Handle state
  2718. if ( stateString ) {
  2719. list.add(function() {
  2720. // state = [ resolved | rejected ]
  2721. state = stateString;
  2722. // [ reject_list | resolve_list ].disable; progress_list.lock
  2723. }, tuples[ i ^ 1 ][ 2 ].disable, tuples[ 2 ][ 2 ].lock );
  2724. }
  2725. // deferred[ resolve | reject | notify ] = list.fire
  2726. deferred[ tuple[0] ] = list.fire;
  2727. deferred[ tuple[0] + "With" ] = list.fireWith;
  2728. });
  2729. // Make the deferred a promise
  2730. promise.promise( deferred );
  2731. // Call given func if any
  2732. if ( func ) {
  2733. func.call( deferred, deferred );
  2734. }
  2735. // All done!
  2736. return deferred;
  2737. },
  2738. // Deferred helper
  2739. when: function( subordinate /* , ..., subordinateN */ ) {
  2740. var i = 0,
  2741. resolveValues = core_slice.call( arguments ),
  2742. length = resolveValues.length,
  2743. // the count of uncompleted subordinates
  2744. remaining = length !== 1 || ( subordinate && jQuery.isFunction( subordinate.promise ) ) ? length : 0,
  2745. // the master Deferred. If resolveValues consist of only a single Deferred, just use that.
  2746. deferred = remaining === 1 ? subordinate : jQuery.Deferred(),
  2747. // Update function for both resolve and progress values
  2748. updateFunc = function( i, contexts, values ) {
  2749. return function( value ) {
  2750. contexts[ i ] = this;
  2751. values[ i ] = arguments.length > 1 ? core_slice.call( arguments ) : value;
  2752. if( values === progressValues ) {
  2753. deferred.notifyWith( contexts, values );
  2754. } else if ( !( --remaining ) ) {
  2755. deferred.resolveWith( contexts, values );
  2756. }
  2757. };
  2758. },
  2759. progressValues, progressContexts, resolveContexts;
  2760. // add listeners to Deferred subordinates; treat others as resolved
  2761. if ( length > 1 ) {
  2762. progressValues = new Array( length );
  2763. progressContexts = new Array( length );
  2764. resolveContexts = new Array( length );
  2765. for ( ; i < length; i++ ) {
  2766. if ( resolveValues[ i ] && jQuery.isFunction( resolveValues[ i ].promise ) ) {
  2767. resolveValues[ i ].promise()
  2768. .done( updateFunc( i, resolveContexts, resolveValues ) )
  2769. .fail( deferred.reject )
  2770. .progress( updateFunc( i, progressContexts, progressValues ) );
  2771. } else {
  2772. --remaining;
  2773. }
  2774. }
  2775. }
  2776. // if we're not waiting on anything, resolve the master
  2777. if ( !remaining ) {
  2778. deferred.resolveWith( resolveContexts, resolveValues );
  2779. }
  2780. return deferred.promise();
  2781. }
  2782. });
  2783. jQuery.support = (function() {
  2784. var support,
  2785. all,
  2786. a,
  2787. select,
  2788. opt,
  2789. input,
  2790. fragment,
  2791. eventName,
  2792. i,
  2793. isSupported,
  2794. clickFn,
  2795. div = document.createElement("div");
  2796. // Preliminary tests
  2797. div.setAttribute( "className", "t" );
  2798. div.innerHTML = " <link/><table></table><a href='/a'>a</a><input type='checkbox'/>";
  2799. all = div.getElementsByTagName("*");
  2800. a = div.getElementsByTagName("a")[ 0 ];
  2801. a.style.cssText = "top:1px;float:left;opacity:.5";
  2802. // Can't get basic test support
  2803. if ( !all || !all.length ) {
  2804. return {};
  2805. }
  2806. // First batch of supports tests
  2807. select = document.createElement("select");
  2808. opt = select.appendChild( document.createElement("option") );
  2809. input = div.getElementsByTagName("input")[ 0 ];
  2810. support = {
  2811. // IE strips leading whitespace when .innerHTML is used
  2812. leadingWhitespace: ( div.firstChild.nodeType === 3 ),
  2813. // Make sure that tbody elements aren't automatically inserted
  2814. // IE will insert them into empty tables
  2815. tbody: !div.getElementsByTagName("tbody").length,
  2816. // Make sure that link elements get serialized correctly by innerHTML
  2817. // This requires a wrapper element in IE
  2818. htmlSerialize: !!div.getElementsByTagName("link").length,
  2819. // Get the style information from getAttribute
  2820. // (IE uses .cssText instead)
  2821. style: /top/.test( a.getAttribute("style") ),
  2822. // Make sure that URLs aren't manipulated
  2823. // (IE normalizes it by default)
  2824. hrefNormalized: ( a.getAttribute("href") === "/a" ),
  2825. // Make sure that element opacity exists
  2826. // (IE uses filter instead)
  2827. // Use a regex to work around a WebKit issue. See #5145
  2828. opacity: /^0.5/.test( a.style.opacity ),
  2829. // Verify style float existence
  2830. // (IE uses styleFloat instead of cssFloat)
  2831. cssFloat: !!a.style.cssFloat,
  2832. // Make sure that if no value is specified for a checkbox
  2833. // that it defaults to "on".
  2834. // (WebKit defaults to "" instead)
  2835. checkOn: ( input.value === "on" ),
  2836. // Make sure that a selected-by-default option has a working selected property.
  2837. // (WebKit defaults to false instead of true, IE too, if it's in an optgroup)
  2838. optSelected: opt.selected,
  2839. // Test setAttribute on camelCase class. If it works, we need attrFixes when doing get/setAttribute (ie6/7)
  2840. getSetAttribute: div.className !== "t",
  2841. // Tests for enctype support on a form(#6743)
  2842. enctype: !!document.createElement("form").enctype,
  2843. // Makes sure cloning an html5 element does not cause problems
  2844. // Where outerHTML is undefined, this still works
  2845. html5Clone: document.createElement("nav").cloneNode( true ).outerHTML !== "<:nav></:nav>",
  2846. // jQuery.support.boxModel DEPRECATED in 1.8 since we don't support Quirks Mode
  2847. boxModel: ( document.compatMode === "CSS1Compat" ),
  2848. // Will be defined later
  2849. submitBubbles: true,
  2850. changeBubbles: true,
  2851. focusinBubbles: false,
  2852. deleteExpando: true,
  2853. noCloneEvent: true,
  2854. inlineBlockNeedsLayout: false,
  2855. shrinkWrapBlocks: false,
  2856. reliableMarginRight: true,
  2857. boxSizingReliable: true,
  2858. pixelPosition: false
  2859. };
  2860. // Make sure checked status is properly cloned
  2861. input.checked = true;
  2862. support.noCloneChecked = input.cloneNode( true ).checked;
  2863. // Make sure that the options inside disabled selects aren't marked as disabled
  2864. // (WebKit marks them as disabled)
  2865. select.disabled = true;
  2866. support.optDisabled = !opt.disabled;
  2867. // Test to see if it's possible to delete an expando from an element
  2868. // Fails in Internet Explorer
  2869. try {
  2870. delete div.test;
  2871. } catch( e ) {
  2872. support.deleteExpando = false;
  2873. }
  2874. if ( !div.addEventListener && div.attachEvent && div.fireEvent ) {
  2875. div.attachEvent( "onclick", clickFn = function() {
  2876. // Cloning a node shouldn't copy over any
  2877. // bound event handlers (IE does this)
  2878. support.noCloneEvent = false;
  2879. });
  2880. div.cloneNode( true ).fireEvent("onclick");
  2881. div.detachEvent( "onclick", clickFn );
  2882. }
  2883. // Check if a radio maintains its value
  2884. // after being appended to the DOM
  2885. input = document.createElement("input");
  2886. input.value = "t";
  2887. input.setAttribute( "type", "radio" );
  2888. support.radioValue = input.value === "t";
  2889. input.setAttribute( "checked", "checked" );
  2890. // #11217 - WebKit loses check when the name is after the checked attribute
  2891. input.setAttribute( "name", "t" );
  2892. div.appendChild( input );
  2893. fragment = document.createDocumentFragment();
  2894. fragment.appendChild( div.lastChild );
  2895. // WebKit doesn't clone checked state correctly in fragments
  2896. support.checkClone = fragment.cloneNode( true ).cloneNode( true ).lastChild.checked;
  2897. // Check if a disconnected checkbox will retain its checked
  2898. // value of true after appended to the DOM (IE6/7)
  2899. support.appendChecked = input.checked;
  2900. fragment.removeChild( input );
  2901. fragment.appendChild( div );
  2902. // Technique from Juriy Zaytsev
  2903. // http://perfectionkills.com/detecting-event-support-without-browser-sniffing/
  2904. // We only care about the case where non-standard event systems
  2905. // are used, namely in IE. Short-circuiting here helps us to
  2906. // avoid an eval call (in setAttribute) which can cause CSP
  2907. // to go haywire. See: https://developer.mozilla.org/en/Security/CSP
  2908. if ( div.attachEvent ) {
  2909. for ( i in {
  2910. submit: true,
  2911. change: true,
  2912. focusin: true
  2913. }) {
  2914. eventName = "on" + i;
  2915. isSupported = ( eventName in div );
  2916. if ( !isSupported ) {
  2917. div.setAttribute( eventName, "return;" );
  2918. isSupported = ( typeof div[ eventName ] === "function" );
  2919. }
  2920. support[ i + "Bubbles" ] = isSupported;
  2921. }
  2922. }
  2923. // Run tests that need a body at doc ready
  2924. jQuery(function() {
  2925. var container, div, tds, marginDiv,
  2926. divReset = "padding:0;margin:0;border:0;display:block;overflow:hidden;",
  2927. body = document.getElementsByTagName("body")[0];
  2928. if ( !body ) {
  2929. // Return for frameset docs that don't have a body
  2930. return;
  2931. }
  2932. container = document.createElement("div");
  2933. container.style.cssText = "visibility:hidden;border:0;width:0;height:0;position:static;top:0;margin-top:1px";
  2934. body.insertBefore( container, body.firstChild );
  2935. // Construct the test element
  2936. div = document.createElement("div");
  2937. container.appendChild( div );
  2938. // Check if table cells still have offsetWidth/Height when they are set
  2939. // to display:none and there are still other visible table cells in a
  2940. // table row; if so, offsetWidth/Height are not reliable for use when
  2941. // determining if an element has been hidden directly using
  2942. // display:none (it is still safe to use offsets if a parent element is
  2943. // hidden; don safety goggles and see bug #4512 for more information).
  2944. // (only IE 8 fails this test)
  2945. div.innerHTML = "<table><tr><td></td><td>t</td></tr></table>";
  2946. tds = div.getElementsByTagName("td");
  2947. tds[ 0 ].style.cssText = "padding:0;margin:0;border:0;display:none";
  2948. isSupported = ( tds[ 0 ].offsetHeight === 0 );
  2949. tds[ 0 ].style.display = "";
  2950. tds[ 1 ].style.display = "none";
  2951. // Check if empty table cells still have offsetWidth/Height
  2952. // (IE <= 8 fail this test)
  2953. support.reliableHiddenOffsets = isSupported && ( tds[ 0 ].offsetHeight === 0 );
  2954. // Check box-sizing and margin behavior
  2955. div.innerHTML = "";
  2956. div.style.cssText = "box-sizing:border-box;-moz-box-sizing:border-box;-webkit-box-sizing:border-box;padding:1px;border:1px;display:block;width:4px;margin-top:1%;position:absolute;top:1%;";
  2957. support.boxSizing = ( div.offsetWidth === 4 );
  2958. support.doesNotIncludeMarginInBodyOffset = ( body.offsetTop !== 1 );
  2959. // NOTE: To any future maintainer, we've window.getComputedStyle
  2960. // because jsdom on node.js will break without it.
  2961. if ( window.getComputedStyle ) {
  2962. support.pixelPosition = ( window.getComputedStyle( div, null ) || {} ).top !== "1%";
  2963. support.boxSizingReliable = ( window.getComputedStyle( div, null ) || { width: "4px" } ).width === "4px";
  2964. // Check if div with explicit width and no margin-right incorrectly
  2965. // gets computed margin-right based on width of container. For more
  2966. // info see bug #3333
  2967. // Fails in WebKit before Feb 2011 nightlies
  2968. // WebKit Bug 13343 - getComputedStyle returns wrong value for margin-right
  2969. marginDiv = document.createElement("div");
  2970. marginDiv.style.cssText = div.style.cssText = divReset;
  2971. marginDiv.style.marginRight = marginDiv.style.width = "0";
  2972. div.style.width = "1px";
  2973. div.appendChild( marginDiv );
  2974. support.reliableMarginRight =
  2975. !parseFloat( ( window.getComputedStyle( marginDiv, null ) || {} ).marginRight );
  2976. }
  2977. if ( typeof div.style.zoom !== "undefined" ) {
  2978. // Check if natively block-level elements act like inline-block
  2979. // elements when setting their display to 'inline' and giving
  2980. // them layout
  2981. // (IE < 8 does this)
  2982. div.innerHTML = "";
  2983. div.style.cssText = divReset + "width:1px;padding:1px;display:inline;zoom:1";
  2984. support.inlineBlockNeedsLayout = ( div.offsetWidth === 3 );
  2985. // Check if elements with layout shrink-wrap their children
  2986. // (IE 6 does this)
  2987. div.style.display = "block";
  2988. div.style.overflow = "visible";
  2989. div.innerHTML = "<div></div>";
  2990. div.firstChild.style.width = "5px";
  2991. support.shrinkWrapBlocks = ( div.offsetWidth !== 3 );
  2992. container.style.zoom = 1;
  2993. }
  2994. // Null elements to avoid leaks in IE
  2995. body.removeChild( container );
  2996. container = div = tds = marginDiv = null;
  2997. });
  2998. // Null elements to avoid leaks in IE
  2999. fragment.removeChild( div );
  3000. all = a = select = opt = input = fragment = div = null;
  3001. return support;
  3002. })();
  3003. var rbrace = /(?:\{[\s\S]*\}|\[[\s\S]*\])$/,
  3004. rmultiDash = /([A-Z])/g;
  3005. jQuery.extend({
  3006. cache: {},
  3007. deletedIds: [],
  3008. // Remove at next major release (1.9/2.0)
  3009. uuid: 0,
  3010. // Unique for each copy of jQuery on the page
  3011. // Non-digits removed to match rinlinejQuery
  3012. expando: "jQuery" + ( jQuery.fn.jquery + Math.random() ).replace( /\D/g, "" ),
  3013. // The following elements throw uncatchable exceptions if you
  3014. // attempt to add expando properties to them.
  3015. noData: {
  3016. "embed": true,
  3017. // Ban all objects except for Flash (which handle expandos)
  3018. "object": "clsid:D27CDB6E-AE6D-11cf-96B8-444553540000",
  3019. "applet": true
  3020. },
  3021. hasData: function( elem ) {
  3022. elem = elem.nodeType ? jQuery.cache[ elem[jQuery.expando] ] : elem[ jQuery.expando ];
  3023. return !!elem && !isEmptyDataObject( elem );
  3024. },
  3025. data: function( elem, name, data, pvt /* Internal Use Only */ ) {
  3026. if ( !jQuery.acceptData( elem ) ) {
  3027. return;
  3028. }
  3029. var thisCache, ret,
  3030. internalKey = jQuery.expando,
  3031. getByName = typeof name === "string",
  3032. // We have to handle DOM nodes and JS objects differently because IE6-7
  3033. // can't GC object references properly across the DOM-JS boundary
  3034. isNode = elem.nodeType,
  3035. // Only DOM nodes need the global jQuery cache; JS object data is
  3036. // attached directly to the object so GC can occur automatically
  3037. cache = isNode ? jQuery.cache : elem,
  3038. // Only defining an ID for JS objects if its cache already exists allows
  3039. // the code to shortcut on the same path as a DOM node with no cache
  3040. id = isNode ? elem[ internalKey ] : elem[ internalKey ] && internalKey;
  3041. // Avoid doing any more work than we need to when trying to get data on an
  3042. // object that has no data at all
  3043. if ( (!id || !cache[id] || (!pvt && !cache[id].data)) && getByName && data === undefined ) {
  3044. return;
  3045. }
  3046. if ( !id ) {
  3047. // Only DOM nodes need a new unique ID for each element since their data
  3048. // ends up in the global cache
  3049. if ( isNode ) {
  3050. elem[ internalKey ] = id = jQuery.deletedIds.pop() || jQuery.guid++;
  3051. } else {
  3052. id = internalKey;
  3053. }
  3054. }
  3055. if ( !cache[ id ] ) {
  3056. cache[ id ] = {};
  3057. // Avoids exposing jQuery metadata on plain JS objects when the object
  3058. // is serialized using JSON.stringify
  3059. if ( !isNode ) {
  3060. cache[ id ].toJSON = jQuery.noop;
  3061. }
  3062. }
  3063. // An object can be passed to jQuery.data instead of a key/value pair; this gets
  3064. // shallow copied over onto the existing cache
  3065. if ( typeof name === "object" || typeof name === "function" ) {
  3066. if ( pvt ) {
  3067. cache[ id ] = jQuery.extend( cache[ id ], name );
  3068. } else {
  3069. cache[ id ].data = jQuery.extend( cache[ id ].data, name );
  3070. }
  3071. }
  3072. thisCache = cache[ id ];
  3073. // jQuery data() is stored in a separate object inside the object's internal data
  3074. // cache in order to avoid key collisions between internal data and user-defined
  3075. // data.
  3076. if ( !pvt ) {
  3077. if ( !thisCache.data ) {
  3078. thisCache.data = {};
  3079. }
  3080. thisCache = thisCache.data;
  3081. }
  3082. if ( data !== undefined ) {
  3083. thisCache[ jQuery.camelCase( name ) ] = data;
  3084. }
  3085. // Check for both converted-to-camel and non-converted data property names
  3086. // If a data property was specified
  3087. if ( getByName ) {
  3088. // First Try to find as-is property data
  3089. ret = thisCache[ name ];
  3090. // Test for null|undefined property data
  3091. if ( ret == null ) {
  3092. // Try to find the camelCased property
  3093. ret = thisCache[ jQuery.camelCase( name ) ];
  3094. }
  3095. } else {
  3096. ret = thisCache;
  3097. }
  3098. return ret;
  3099. },
  3100. removeData: function( elem, name, pvt /* Internal Use Only */ ) {
  3101. if ( !jQuery.acceptData( elem ) ) {
  3102. return;
  3103. }
  3104. var thisCache, i, l,
  3105. isNode = elem.nodeType,
  3106. // See jQuery.data for more information
  3107. cache = isNode ? jQuery.cache : elem,
  3108. id = isNode ? elem[ jQuery.expando ] : jQuery.expando;
  3109. // If there is already no cache entry for this object, there is no
  3110. // purpose in continuing
  3111. if ( !cache[ id ] ) {
  3112. return;
  3113. }
  3114. if ( name ) {
  3115. thisCache = pvt ? cache[ id ] : cache[ id ].data;
  3116. if ( thisCache ) {
  3117. // Support array or space separated string names for data keys
  3118. if ( !jQuery.isArray( name ) ) {
  3119. // try the string as a key before any manipulation
  3120. if ( name in thisCache ) {
  3121. name = [ name ];
  3122. } else {
  3123. // split the camel cased version by spaces unless a key with the spaces exists
  3124. name = jQuery.camelCase( name );
  3125. if ( name in thisCache ) {
  3126. name = [ name ];
  3127. } else {
  3128. name = name.split(" ");
  3129. }
  3130. }
  3131. }
  3132. for ( i = 0, l = name.length; i < l; i++ ) {
  3133. delete thisCache[ name[i] ];
  3134. }
  3135. // If there is no data left in the cache, we want to continue
  3136. // and let the cache object itself get destroyed
  3137. if ( !( pvt ? isEmptyDataObject : jQuery.isEmptyObject )( thisCache ) ) {
  3138. return;
  3139. }
  3140. }
  3141. }
  3142. // See jQuery.data for more information
  3143. if ( !pvt ) {
  3144. delete cache[ id ].data;
  3145. // Don't destroy the parent cache unless the internal data object
  3146. // had been the only thing left in it
  3147. if ( !isEmptyDataObject( cache[ id ] ) ) {
  3148. return;
  3149. }
  3150. }
  3151. // Destroy the cache
  3152. if ( isNode ) {
  3153. jQuery.cleanData( [ elem ], true );
  3154. // Use delete when supported for expandos or `cache` is not a window per isWindow (#10080)
  3155. } else if ( jQuery.support.deleteExpando || cache != cache.window ) {
  3156. delete cache[ id ];
  3157. // When all else fails, null
  3158. } else {
  3159. cache[ id ] = null;
  3160. }
  3161. },
  3162. // For internal use only.
  3163. _data: function( elem, name, data ) {
  3164. return jQuery.data( elem, name, data, true );
  3165. },
  3166. // A method for determining if a DOM node can handle the data expando
  3167. acceptData: function( elem ) {
  3168. var noData = elem.nodeName && jQuery.noData[ elem.nodeName.toLowerCase() ];
  3169. // nodes accept data unless otherwise specified; rejection can be conditional
  3170. return !noData || noData !== true && elem.getAttribute("classid") === noData;
  3171. }
  3172. });
  3173. jQuery.fn.extend({
  3174. data: function( key, value ) {
  3175. var parts, part, attr, name, l,
  3176. elem = this[0],
  3177. i = 0,
  3178. data = null;
  3179. // Gets all values
  3180. if ( key === undefined ) {
  3181. if ( this.length ) {
  3182. data = jQuery.data( elem );
  3183. if ( elem.nodeType === 1 && !jQuery._data( elem, "parsedAttrs" ) ) {
  3184. attr = elem.attributes;
  3185. for ( l = attr.length; i < l; i++ ) {
  3186. name = attr[i].name;
  3187. if ( !name.indexOf( "data-" ) ) {
  3188. name = jQuery.camelCase( name.substring(5) );
  3189. dataAttr( elem, name, data[ name ] );
  3190. }
  3191. }
  3192. jQuery._data( elem, "parsedAttrs", true );
  3193. }
  3194. }
  3195. return data;
  3196. }
  3197. // Sets multiple values
  3198. if ( typeof key === "object" ) {
  3199. return this.each(function() {
  3200. jQuery.data( this, key );
  3201. });
  3202. }
  3203. parts = key.split( ".", 2 );
  3204. parts[1] = parts[1] ? "." + parts[1] : "";
  3205. part = parts[1] + "!";
  3206. return jQuery.access( this, function( value ) {
  3207. if ( value === undefined ) {
  3208. data = this.triggerHandler( "getData" + part, [ parts[0] ] );
  3209. // Try to fetch any internally stored data first
  3210. if ( data === undefined && elem ) {
  3211. data = jQuery.data( elem, key );
  3212. data = dataAttr( elem, key, data );
  3213. }
  3214. return data === undefined && parts[1] ?
  3215. this.data( parts[0] ) :
  3216. data;
  3217. }
  3218. parts[1] = value;
  3219. this.each(function() {
  3220. var self = jQuery( this );
  3221. self.triggerHandler( "setData" + part, parts );
  3222. jQuery.data( this, key, value );
  3223. self.triggerHandler( "changeData" + part, parts );
  3224. });
  3225. }, null, value, arguments.length > 1, null, false );
  3226. },
  3227. removeData: function( key ) {
  3228. return this.each(function() {
  3229. jQuery.removeData( this, key );
  3230. });
  3231. }
  3232. });
  3233. function dataAttr( elem, key, data ) {
  3234. // If nothing was found internally, try to fetch any
  3235. // data from the HTML5 data-* attribute
  3236. if ( data === undefined && elem.nodeType === 1 ) {
  3237. var name = "data-" + key.replace( rmultiDash, "-$1" ).toLowerCase();
  3238. data = elem.getAttribute( name );
  3239. if ( typeof data === "string" ) {
  3240. try {
  3241. data = data === "true" ? true :
  3242. data === "false" ? false :
  3243. data === "null" ? null :
  3244. // Only convert to a number if it doesn't change the string
  3245. +data + "" === data ? +data :
  3246. rbrace.test( data ) ? jQuery.parseJSON( data ) :
  3247. data;
  3248. } catch( e ) {}
  3249. // Make sure we set the data so it isn't changed later
  3250. jQuery.data( elem, key, data );
  3251. } else {
  3252. data = undefined;
  3253. }
  3254. }
  3255. return data;
  3256. }
  3257. // checks a cache object for emptiness
  3258. function isEmptyDataObject( obj ) {
  3259. var name;
  3260. for ( name in obj ) {
  3261. // if the public data object is empty, the private is still empty
  3262. if ( name === "data" && jQuery.isEmptyObject( obj[name] ) ) {
  3263. continue;
  3264. }
  3265. if ( name !== "toJSON" ) {
  3266. return false;
  3267. }
  3268. }
  3269. return true;
  3270. }
  3271. jQuery.extend({
  3272. queue: function( elem, type, data ) {
  3273. var queue;
  3274. if ( elem ) {
  3275. type = ( type || "fx" ) + "queue";
  3276. queue = jQuery._data( elem, type );
  3277. // Speed up dequeue by getting out quickly if this is just a lookup
  3278. if ( data ) {
  3279. if ( !queue || jQuery.isArray(data) ) {
  3280. queue = jQuery._data( elem, type, jQuery.makeArray(data) );
  3281. } else {
  3282. queue.push( data );
  3283. }
  3284. }
  3285. return queue || [];
  3286. }
  3287. },
  3288. dequeue: function( elem, type ) {
  3289. type = type || "fx";
  3290. var queue = jQuery.queue( elem, type ),
  3291. startLength = queue.length,
  3292. fn = queue.shift(),
  3293. hooks = jQuery._queueHooks( elem, type ),
  3294. next = function() {
  3295. jQuery.dequeue( elem, type );
  3296. };
  3297. // If the fx queue is dequeued, always remove the progress sentinel
  3298. if ( fn === "inprogress" ) {
  3299. fn = queue.shift();
  3300. startLength--;
  3301. }
  3302. if ( fn ) {
  3303. // Add a progress sentinel to prevent the fx queue from being
  3304. // automatically dequeued
  3305. if ( type === "fx" ) {
  3306. queue.unshift( "inprogress" );
  3307. }
  3308. // clear up the last queue stop function
  3309. delete hooks.stop;
  3310. fn.call( elem, next, hooks );
  3311. }
  3312. if ( !startLength && hooks ) {
  3313. hooks.empty.fire();
  3314. }
  3315. },
  3316. // not intended for public consumption - generates a queueHooks object, or returns the current one
  3317. _queueHooks: function( elem, type ) {
  3318. var key = type + "queueHooks";
  3319. return jQuery._data( elem, key ) || jQuery._data( elem, key, {
  3320. empty: jQuery.Callbacks("once memory").add(function() {
  3321. jQuery.removeData( elem, type + "queue", true );
  3322. jQuery.removeData( elem, key, true );
  3323. })
  3324. });
  3325. }
  3326. });
  3327. jQuery.fn.extend({
  3328. queue: function( type, data ) {
  3329. var setter = 2;
  3330. if ( typeof type !== "string" ) {
  3331. data = type;
  3332. type = "fx";
  3333. setter--;
  3334. }
  3335. if ( arguments.length < setter ) {
  3336. return jQuery.queue( this[0], type );
  3337. }
  3338. return data === undefined ?
  3339. this :
  3340. this.each(function() {
  3341. var queue = jQuery.queue( this, type, data );
  3342. // ensure a hooks for this queue
  3343. jQuery._queueHooks( this, type );
  3344. if ( type === "fx" && queue[0] !== "inprogress" ) {
  3345. jQuery.dequeue( this, type );
  3346. }
  3347. });
  3348. },
  3349. dequeue: function( type ) {
  3350. return this.each(function() {
  3351. jQuery.dequeue( this, type );
  3352. });
  3353. },
  3354. // Based off of the plugin by Clint Helfers, with permission.
  3355. // http://blindsignals.com/index.php/2009/07/jquery-delay/
  3356. delay: function( time, type ) {
  3357. time = jQuery.fx ? jQuery.fx.speeds[ time ] || time : time;
  3358. type = type || "fx";
  3359. return this.queue( type, function( next, hooks ) {
  3360. var timeout = setTimeout( next, time );
  3361. hooks.stop = function() {
  3362. clearTimeout( timeout );
  3363. };
  3364. });
  3365. },
  3366. clearQueue: function( type ) {
  3367. return this.queue( type || "fx", [] );
  3368. },
  3369. // Get a promise resolved when queues of a certain type
  3370. // are emptied (fx is the type by default)
  3371. promise: function( type, obj ) {
  3372. var tmp,
  3373. count = 1,
  3374. defer = jQuery.Deferred(),
  3375. elements = this,
  3376. i = this.length,
  3377. resolve = function() {
  3378. if ( !( --count ) ) {
  3379. defer.resolveWith( elements, [ elements ] );
  3380. }
  3381. };
  3382. if ( typeof type !== "string" ) {
  3383. obj = type;
  3384. type = undefined;
  3385. }
  3386. type = type || "fx";
  3387. while( i-- ) {
  3388. tmp = jQuery._data( elements[ i ], type + "queueHooks" );
  3389. if ( tmp && tmp.empty ) {
  3390. count++;
  3391. tmp.empty.add( resolve );
  3392. }
  3393. }
  3394. resolve();
  3395. return defer.promise( obj );
  3396. }
  3397. });
  3398. var nodeHook, boolHook, fixSpecified,
  3399. rclass = /[\t\r\n]/g,
  3400. rreturn = /\r/g,
  3401. rtype = /^(?:button|input)$/i,
  3402. rfocusable = /^(?:button|input|object|select|textarea)$/i,
  3403. rclickable = /^a(?:rea|)$/i,
  3404. rboolean = /^(?:autofocus|autoplay|async|checked|controls|defer|disabled|hidden|loop|multiple|open|readonly|required|scoped|selected)$/i,
  3405. getSetAttribute = jQuery.support.getSetAttribute;
  3406. jQuery.fn.extend({
  3407. attr: function( name, value ) {
  3408. return jQuery.access( this, jQuery.attr, name, value, arguments.length > 1 );
  3409. },
  3410. removeAttr: function( name ) {
  3411. return this.each(function() {
  3412. jQuery.removeAttr( this, name );
  3413. });
  3414. },
  3415. prop: function( name, value ) {
  3416. return jQuery.access( this, jQuery.prop, name, value, arguments.length > 1 );
  3417. },
  3418. removeProp: function( name ) {
  3419. name = jQuery.propFix[ name ] || name;
  3420. return this.each(function() {
  3421. // try/catch handles cases where IE balks (such as removing a property on window)
  3422. try {
  3423. this[ name ] = undefined;
  3424. delete this[ name ];
  3425. } catch( e ) {}
  3426. });
  3427. },
  3428. addClass: function( value ) {
  3429. var classNames, i, l, elem,
  3430. setClass, c, cl;
  3431. if ( jQuery.isFunction( value ) ) {
  3432. return this.each(function( j ) {
  3433. jQuery( this ).addClass( value.call(this, j, this.className) );
  3434. });
  3435. }
  3436. if ( value && typeof value === "string" ) {
  3437. classNames = value.split( core_rspace );
  3438. for ( i = 0, l = this.length; i < l; i++ ) {
  3439. elem = this[ i ];
  3440. if ( elem.nodeType === 1 ) {
  3441. if ( !elem.className && classNames.length === 1 ) {
  3442. elem.className = value;
  3443. } else {
  3444. setClass = " " + elem.className + " ";
  3445. for ( c = 0, cl = classNames.length; c < cl; c++ ) {
  3446. if ( setClass.indexOf( " " + classNames[ c ] + " " ) < 0 ) {
  3447. setClass += classNames[ c ] + " ";
  3448. }
  3449. }
  3450. elem.className = jQuery.trim( setClass );
  3451. }
  3452. }
  3453. }
  3454. }
  3455. return this;
  3456. },
  3457. removeClass: function( value ) {
  3458. var removes, className, elem, c, cl, i, l;
  3459. if ( jQuery.isFunction( value ) ) {
  3460. return this.each(function( j ) {
  3461. jQuery( this ).removeClass( value.call(this, j, this.className) );
  3462. });
  3463. }
  3464. if ( (value && typeof value === "string") || value === undefined ) {
  3465. removes = ( value || "" ).split( core_rspace );
  3466. for ( i = 0, l = this.length; i < l; i++ ) {
  3467. elem = this[ i ];
  3468. if ( elem.nodeType === 1 && elem.className ) {
  3469. className = (" " + elem.className + " ").replace( rclass, " " );
  3470. // loop over each item in the removal list
  3471. for ( c = 0, cl = removes.length; c < cl; c++ ) {
  3472. // Remove until there is nothing to remove,
  3473. while ( className.indexOf(" " + removes[ c ] + " ") >= 0 ) {
  3474. className = className.replace( " " + removes[ c ] + " " , " " );
  3475. }
  3476. }
  3477. elem.className = value ? jQuery.trim( className ) : "";
  3478. }
  3479. }
  3480. }
  3481. return this;
  3482. },
  3483. toggleClass: function( value, stateVal ) {
  3484. var type = typeof value,
  3485. isBool = typeof stateVal === "boolean";
  3486. if ( jQuery.isFunction( value ) ) {
  3487. return this.each(function( i ) {
  3488. jQuery( this ).toggleClass( value.call(this, i, this.className, stateVal), stateVal );
  3489. });
  3490. }
  3491. return this.each(function() {
  3492. if ( type === "string" ) {
  3493. // toggle individual class names
  3494. var className,
  3495. i = 0,
  3496. self = jQuery( this ),
  3497. state = stateVal,
  3498. classNames = value.split( core_rspace );
  3499. while ( (className = classNames[ i++ ]) ) {
  3500. // check each className given, space separated list
  3501. state = isBool ? state : !self.hasClass( className );
  3502. self[ state ? "addClass" : "removeClass" ]( className );
  3503. }
  3504. } else if ( type === "undefined" || type === "boolean" ) {
  3505. if ( this.className ) {
  3506. // store className if set
  3507. jQuery._data( this, "__className__", this.className );
  3508. }
  3509. // toggle whole className
  3510. this.className = this.className || value === false ? "" : jQuery._data( this, "__className__" ) || "";
  3511. }
  3512. });
  3513. },
  3514. hasClass: function( selector ) {
  3515. var className = " " + selector + " ",
  3516. i = 0,
  3517. l = this.length;
  3518. for ( ; i < l; i++ ) {
  3519. if ( this[i].nodeType === 1 && (" " + this[i].className + " ").replace(rclass, " ").indexOf( className ) >= 0 ) {
  3520. return true;
  3521. }
  3522. }
  3523. return false;
  3524. },
  3525. val: function( value ) {
  3526. var hooks, ret, isFunction,
  3527. elem = this[0];
  3528. if ( !arguments.length ) {
  3529. if ( elem ) {
  3530. hooks = jQuery.valHooks[ elem.type ] || jQuery.valHooks[ elem.nodeName.toLowerCase() ];
  3531. if ( hooks && "get" in hooks && (ret = hooks.get( elem, "value" )) !== undefined ) {
  3532. return ret;
  3533. }
  3534. ret = elem.value;
  3535. return typeof ret === "string" ?
  3536. // handle most common string cases
  3537. ret.replace(rreturn, "") :
  3538. // handle cases where value is null/undef or number
  3539. ret == null ? "" : ret;
  3540. }
  3541. return;
  3542. }
  3543. isFunction = jQuery.isFunction( value );
  3544. return this.each(function( i ) {
  3545. var val,
  3546. self = jQuery(this);
  3547. if ( this.nodeType !== 1 ) {
  3548. return;
  3549. }
  3550. if ( isFunction ) {
  3551. val = value.call( this, i, self.val() );
  3552. } else {
  3553. val = value;
  3554. }
  3555. // Treat null/undefined as ""; convert numbers to string
  3556. if ( val == null ) {
  3557. val = "";
  3558. } else if ( typeof val === "number" ) {
  3559. val += "";
  3560. } else if ( jQuery.isArray( val ) ) {
  3561. val = jQuery.map(val, function ( value ) {
  3562. return value == null ? "" : value + "";
  3563. });
  3564. }
  3565. hooks = jQuery.valHooks[ this.type ] || jQuery.valHooks[ this.nodeName.toLowerCase() ];
  3566. // If set returns undefined, fall back to normal setting
  3567. if ( !hooks || !("set" in hooks) || hooks.set( this, val, "value" ) === undefined ) {
  3568. this.value = val;
  3569. }
  3570. });
  3571. }
  3572. });
  3573. jQuery.extend({
  3574. valHooks: {
  3575. option: {
  3576. get: function( elem ) {
  3577. // attributes.value is undefined in Blackberry 4.7 but
  3578. // uses .value. See #6932
  3579. var val = elem.attributes.value;
  3580. return !val || val.specified ? elem.value : elem.text;
  3581. }
  3582. },
  3583. select: {
  3584. get: function( elem ) {
  3585. var value, i, max, option,
  3586. index = elem.selectedIndex,
  3587. values = [],
  3588. options = elem.options,
  3589. one = elem.type === "select-one";
  3590. // Nothing was selected
  3591. if ( index < 0 ) {
  3592. return null;
  3593. }
  3594. // Loop through all the selected options
  3595. i = one ? index : 0;
  3596. max = one ? index + 1 : options.length;
  3597. for ( ; i < max; i++ ) {
  3598. option = options[ i ];
  3599. // Don't return options that are disabled or in a disabled optgroup
  3600. if ( option.selected && (jQuery.support.optDisabled ? !option.disabled : option.getAttribute("disabled") === null) &&
  3601. (!option.parentNode.disabled || !jQuery.nodeName( option.parentNode, "optgroup" )) ) {
  3602. // Get the specific value for the option
  3603. value = jQuery( option ).val();
  3604. // We don't need an array for one selects
  3605. if ( one ) {
  3606. return value;
  3607. }
  3608. // Multi-Selects return an array
  3609. values.push( value );
  3610. }
  3611. }
  3612. // Fixes Bug #2551 -- select.val() broken in IE after form.reset()
  3613. if ( one && !values.length && options.length ) {
  3614. return jQuery( options[ index ] ).val();
  3615. }
  3616. return values;
  3617. },
  3618. set: function( elem, value ) {
  3619. var values = jQuery.makeArray( value );
  3620. jQuery(elem).find("option").each(function() {
  3621. this.selected = jQuery.inArray( jQuery(this).val(), values ) >= 0;
  3622. });
  3623. if ( !values.length ) {
  3624. elem.selectedIndex = -1;
  3625. }
  3626. return values;
  3627. }
  3628. }
  3629. },
  3630. // Unused in 1.8, left in so attrFn-stabbers won't die; remove in 1.9
  3631. attrFn: {},
  3632. attr: function( elem, name, value, pass ) {
  3633. var ret, hooks, notxml,
  3634. nType = elem.nodeType;
  3635. // don't get/set attributes on text, comment and attribute nodes
  3636. if ( !elem || nType === 3 || nType === 8 || nType === 2 ) {
  3637. return;
  3638. }
  3639. if ( pass && jQuery.isFunction( jQuery.fn[ name ] ) ) {
  3640. return jQuery( elem )[ name ]( value );
  3641. }
  3642. // Fallback to prop when attributes are not supported
  3643. if ( typeof elem.getAttribute === "undefined" ) {
  3644. return jQuery.prop( elem, name, value );
  3645. }
  3646. notxml = nType !== 1 || !jQuery.isXMLDoc( elem );
  3647. // All attributes are lowercase
  3648. // Grab necessary hook if one is defined
  3649. if ( notxml ) {
  3650. name = name.toLowerCase();
  3651. hooks = jQuery.attrHooks[ name ] || ( rboolean.test( name ) ? boolHook : nodeHook );
  3652. }
  3653. if ( value !== undefined ) {
  3654. if ( value === null ) {
  3655. jQuery.removeAttr( elem, name );
  3656. return;
  3657. } else if ( hooks && "set" in hooks && notxml && (ret = hooks.set( elem, value, name )) !== undefined ) {
  3658. return ret;
  3659. } else {
  3660. elem.setAttribute( name, value + "" );
  3661. return value;
  3662. }
  3663. } else if ( hooks && "get" in hooks && notxml && (ret = hooks.get( elem, name )) !== null ) {
  3664. return ret;
  3665. } else {
  3666. ret = elem.getAttribute( name );
  3667. // Non-existent attributes return null, we normalize to undefined
  3668. return ret === null ?
  3669. undefined :
  3670. ret;
  3671. }
  3672. },
  3673. removeAttr: function( elem, value ) {
  3674. var propName, attrNames, name, isBool,
  3675. i = 0;
  3676. if ( value && elem.nodeType === 1 ) {
  3677. attrNames = value.split( core_rspace );
  3678. for ( ; i < attrNames.length; i++ ) {
  3679. name = attrNames[ i ];
  3680. if ( name ) {
  3681. propName = jQuery.propFix[ name ] || name;
  3682. isBool = rboolean.test( name );
  3683. // See #9699 for explanation of this approach (setting first, then removal)
  3684. // Do not do this for boolean attributes (see #10870)
  3685. if ( !isBool ) {
  3686. jQuery.attr( elem, name, "" );
  3687. }
  3688. elem.removeAttribute( getSetAttribute ? name : propName );
  3689. // Set corresponding property to false for boolean attributes
  3690. if ( isBool && propName in elem ) {
  3691. elem[ propName ] = false;
  3692. }
  3693. }
  3694. }
  3695. }
  3696. },
  3697. attrHooks: {
  3698. type: {
  3699. set: function( elem, value ) {
  3700. // We can't allow the type property to be changed (since it causes problems in IE)
  3701. if ( rtype.test( elem.nodeName ) && elem.parentNode ) {
  3702. jQuery.error( "type property can't be changed" );
  3703. } else if ( !jQuery.support.radioValue && value === "radio" && jQuery.nodeName(elem, "input") ) {
  3704. // Setting the type on a radio button after the value resets the value in IE6-9
  3705. // Reset value to it's default in case type is set after value
  3706. // This is for element creation
  3707. var val = elem.value;
  3708. elem.setAttribute( "type", value );
  3709. if ( val ) {
  3710. elem.value = val;
  3711. }
  3712. return value;
  3713. }
  3714. }
  3715. },
  3716. // Use the value property for back compat
  3717. // Use the nodeHook for button elements in IE6/7 (#1954)
  3718. value: {
  3719. get: function( elem, name ) {
  3720. if ( nodeHook && jQuery.nodeName( elem, "button" ) ) {
  3721. return nodeHook.get( elem, name );
  3722. }
  3723. return name in elem ?
  3724. elem.value :
  3725. null;
  3726. },
  3727. set: function( elem, value, name ) {
  3728. if ( nodeHook && jQuery.nodeName( elem, "button" ) ) {
  3729. return nodeHook.set( elem, value, name );
  3730. }
  3731. // Does not return so that setAttribute is also used
  3732. elem.value = value;
  3733. }
  3734. }
  3735. },
  3736. propFix: {
  3737. tabindex: "tabIndex",
  3738. readonly: "readOnly",
  3739. "for": "htmlFor",
  3740. "class": "className",
  3741. maxlength: "maxLength",
  3742. cellspacing: "cellSpacing",
  3743. cellpadding: "cellPadding",
  3744. rowspan: "rowSpan",
  3745. colspan: "colSpan",
  3746. usemap: "useMap",
  3747. frameborder: "frameBorder",
  3748. contenteditable: "contentEditable"
  3749. },
  3750. prop: function( elem, name, value ) {
  3751. var ret, hooks, notxml,
  3752. nType = elem.nodeType;
  3753. // don't get/set properties on text, comment and attribute nodes
  3754. if ( !elem || nType === 3 || nType === 8 || nType === 2 ) {
  3755. return;
  3756. }
  3757. notxml = nType !== 1 || !jQuery.isXMLDoc( elem );
  3758. if ( notxml ) {
  3759. // Fix name and attach hooks
  3760. name = jQuery.propFix[ name ] || name;
  3761. hooks = jQuery.propHooks[ name ];
  3762. }
  3763. if ( value !== undefined ) {
  3764. if ( hooks && "set" in hooks && (ret = hooks.set( elem, value, name )) !== undefined ) {
  3765. return ret;
  3766. } else {
  3767. return ( elem[ name ] = value );
  3768. }
  3769. } else {
  3770. if ( hooks && "get" in hooks && (ret = hooks.get( elem, name )) !== null ) {
  3771. return ret;
  3772. } else {
  3773. return elem[ name ];
  3774. }
  3775. }
  3776. },
  3777. propHooks: {
  3778. tabIndex: {
  3779. get: function( elem ) {
  3780. // elem.tabIndex doesn't always return the correct value when it hasn't been explicitly set
  3781. // http://fluidproject.org/blog/2008/01/09/getting-setting-and-removing-tabindex-values-with-javascript/
  3782. var attributeNode = elem.getAttributeNode("tabindex");
  3783. return attributeNode && attributeNode.specified ?
  3784. parseInt( attributeNode.value, 10 ) :
  3785. rfocusable.test( elem.nodeName ) || rclickable.test( elem.nodeName ) && elem.href ?
  3786. 0 :
  3787. undefined;
  3788. }
  3789. }
  3790. }
  3791. });
  3792. // Hook for boolean attributes
  3793. boolHook = {
  3794. get: function( elem, name ) {
  3795. // Align boolean attributes with corresponding properties
  3796. // Fall back to attribute presence where some booleans are not supported
  3797. var attrNode,
  3798. property = jQuery.prop( elem, name );
  3799. return property === true || typeof property !== "boolean" && ( attrNode = elem.getAttributeNode(name) ) && attrNode.nodeValue !== false ?
  3800. name.toLowerCase() :
  3801. undefined;
  3802. },
  3803. set: function( elem, value, name ) {
  3804. var propName;
  3805. if ( value === false ) {
  3806. // Remove boolean attributes when set to false
  3807. jQuery.removeAttr( elem, name );
  3808. } else {
  3809. // value is true since we know at this point it's type boolean and not false
  3810. // Set boolean attributes to the same name and set the DOM property
  3811. propName = jQuery.propFix[ name ] || name;
  3812. if ( propName in elem ) {
  3813. // Only set the IDL specifically if it already exists on the element
  3814. elem[ propName ] = true;
  3815. }
  3816. elem.setAttribute( name, name.toLowerCase() );
  3817. }
  3818. return name;
  3819. }
  3820. };
  3821. // IE6/7 do not support getting/setting some attributes with get/setAttribute
  3822. if ( !getSetAttribute ) {
  3823. fixSpecified = {
  3824. name: true,
  3825. id: true,
  3826. coords: true
  3827. };
  3828. // Use this for any attribute in IE6/7
  3829. // This fixes almost every IE6/7 issue
  3830. nodeHook = jQuery.valHooks.button = {
  3831. get: function( elem, name ) {
  3832. var ret;
  3833. ret = elem.getAttributeNode( name );
  3834. return ret && ( fixSpecified[ name ] ? ret.value !== "" : ret.specified ) ?
  3835. ret.value :
  3836. undefined;
  3837. },
  3838. set: function( elem, value, name ) {
  3839. // Set the existing or create a new attribute node
  3840. var ret = elem.getAttributeNode( name );
  3841. if ( !ret ) {
  3842. ret = document.createAttribute( name );
  3843. elem.setAttributeNode( ret );
  3844. }
  3845. return ( ret.value = value + "" );
  3846. }
  3847. };
  3848. // Set width and height to auto instead of 0 on empty string( Bug #8150 )
  3849. // This is for removals
  3850. jQuery.each([ "width", "height" ], function( i, name ) {
  3851. jQuery.attrHooks[ name ] = jQuery.extend( jQuery.attrHooks[ name ], {
  3852. set: function( elem, value ) {
  3853. if ( value === "" ) {
  3854. elem.setAttribute( name, "auto" );
  3855. return value;
  3856. }
  3857. }
  3858. });
  3859. });
  3860. // Set contenteditable to false on removals(#10429)
  3861. // Setting to empty string throws an error as an invalid value
  3862. jQuery.attrHooks.contenteditable = {
  3863. get: nodeHook.get,
  3864. set: function( elem, value, name ) {
  3865. if ( value === "" ) {
  3866. value = "false";
  3867. }
  3868. nodeHook.set( elem, value, name );
  3869. }
  3870. };
  3871. }
  3872. // Some attributes require a special call on IE
  3873. if ( !jQuery.support.hrefNormalized ) {
  3874. jQuery.each([ "href", "src", "width", "height" ], function( i, name ) {
  3875. jQuery.attrHooks[ name ] = jQuery.extend( jQuery.attrHooks[ name ], {
  3876. get: function( elem ) {
  3877. var ret = elem.getAttribute( name, 2 );
  3878. return ret === null ? undefined : ret;
  3879. }
  3880. });
  3881. });
  3882. }
  3883. if ( !jQuery.support.style ) {
  3884. jQuery.attrHooks.style = {
  3885. get: function( elem ) {
  3886. // Return undefined in the case of empty string
  3887. // Normalize to lowercase since IE uppercases css property names
  3888. return elem.style.cssText.toLowerCase() || undefined;
  3889. },
  3890. set: function( elem, value ) {
  3891. return ( elem.style.cssText = value + "" );
  3892. }
  3893. };
  3894. }
  3895. // Safari mis-reports the default selected property of an option
  3896. // Accessing the parent's selectedIndex property fixes it
  3897. if ( !jQuery.support.optSelected ) {
  3898. jQuery.propHooks.selected = jQuery.extend( jQuery.propHooks.selected, {
  3899. get: function( elem ) {
  3900. var parent = elem.parentNode;
  3901. if ( parent ) {
  3902. parent.selectedIndex;
  3903. // Make sure that it also works with optgroups, see #5701
  3904. if ( parent.parentNode ) {
  3905. parent.parentNode.selectedIndex;
  3906. }
  3907. }
  3908. return null;
  3909. }
  3910. });
  3911. }
  3912. // IE6/7 call enctype encoding
  3913. if ( !jQuery.support.enctype ) {
  3914. jQuery.propFix.enctype = "encoding";
  3915. }
  3916. // Radios and checkboxes getter/setter
  3917. if ( !jQuery.support.checkOn ) {
  3918. jQuery.each([ "radio", "checkbox" ], function() {
  3919. jQuery.valHooks[ this ] = {
  3920. get: function( elem ) {
  3921. // Handle the case where in Webkit "" is returned instead of "on" if a value isn't specified
  3922. return elem.getAttribute("value") === null ? "on" : elem.value;
  3923. }
  3924. };
  3925. });
  3926. }
  3927. jQuery.each([ "radio", "checkbox" ], function() {
  3928. jQuery.valHooks[ this ] = jQuery.extend( jQuery.valHooks[ this ], {
  3929. set: function( elem, value ) {
  3930. if ( jQuery.isArray( value ) ) {
  3931. return ( elem.checked = jQuery.inArray( jQuery(elem).val(), value ) >= 0 );
  3932. }
  3933. }
  3934. });
  3935. });
  3936. var rformElems = /^(?:textarea|input|select)$/i,
  3937. rtypenamespace = /^([^\.]*|)(?:\.(.+)|)$/,
  3938. rhoverHack = /(?:^|\s)hover(\.\S+|)\b/,
  3939. rkeyEvent = /^key/,
  3940. rmouseEvent = /^(?:mouse|contextmenu)|click/,
  3941. rfocusMorph = /^(?:focusinfocus|focusoutblur)$/,
  3942. hoverHack = function( events ) {
  3943. return jQuery.event.special.hover ? events : events.replace( rhoverHack, "mouseenter$1 mouseleave$1" );
  3944. };
  3945. /*
  3946. * Helper functions for managing events -- not part of the public interface.
  3947. * Props to Dean Edwards' addEvent library for many of the ideas.
  3948. */
  3949. jQuery.event = {
  3950. add: function( elem, types, handler, data, selector ) {
  3951. var elemData, eventHandle, events,
  3952. t, tns, type, namespaces, handleObj,
  3953. handleObjIn, handlers, special;
  3954. // Don't attach events to noData or text/comment nodes (allow plain objects tho)
  3955. if ( elem.nodeType === 3 || elem.nodeType === 8 || !types || !handler || !(elemData = jQuery._data( elem )) ) {
  3956. return;
  3957. }
  3958. // Caller can pass in an object of custom data in lieu of the handler
  3959. if ( handler.handler ) {
  3960. handleObjIn = handler;
  3961. handler = handleObjIn.handler;
  3962. selector = handleObjIn.selector;
  3963. }
  3964. // Make sure that the handler has a unique ID, used to find/remove it later
  3965. if ( !handler.guid ) {
  3966. handler.guid = jQuery.guid++;
  3967. }
  3968. // Init the element's event structure and main handler, if this is the first
  3969. events = elemData.events;
  3970. if ( !events ) {
  3971. elemData.events = events = {};
  3972. }
  3973. eventHandle = elemData.handle;
  3974. if ( !eventHandle ) {
  3975. elemData.handle = eventHandle = function( e ) {
  3976. // Discard the second event of a jQuery.event.trigger() and
  3977. // when an event is called after a page has unloaded
  3978. return typeof jQuery !== "undefined" && (!e || jQuery.event.triggered !== e.type) ?
  3979. jQuery.event.dispatch.apply( eventHandle.elem, arguments ) :
  3980. undefined;
  3981. };
  3982. // Add elem as a property of the handle fn to prevent a memory leak with IE non-native events
  3983. eventHandle.elem = elem;
  3984. }
  3985. // Handle multiple events separated by a space
  3986. // jQuery(...).bind("mouseover mouseout", fn);
  3987. types = jQuery.trim( hoverHack(types) ).split( " " );
  3988. for ( t = 0; t < types.length; t++ ) {
  3989. tns = rtypenamespace.exec( types[t] ) || [];
  3990. type = tns[1];
  3991. namespaces = ( tns[2] || "" ).split( "." ).sort();
  3992. // If event changes its type, use the special event handlers for the changed type
  3993. special = jQuery.event.special[ type ] || {};
  3994. // If selector defined, determine special event api type, otherwise given type
  3995. type = ( selector ? special.delegateType : special.bindType ) || type;
  3996. // Update special based on newly reset type
  3997. special = jQuery.event.special[ type ] || {};
  3998. // handleObj is passed to all event handlers
  3999. handleObj = jQuery.extend({
  4000. type: type,
  4001. origType: tns[1],
  4002. data: data,
  4003. handler: handler,
  4004. guid: handler.guid,
  4005. selector: selector,
  4006. needsContext: selector && jQuery.expr.match.needsContext.test( selector ),
  4007. namespace: namespaces.join(".")
  4008. }, handleObjIn );
  4009. // Init the event handler queue if we're the first
  4010. handlers = events[ type ];
  4011. if ( !handlers ) {
  4012. handlers = events[ type ] = [];
  4013. handlers.delegateCount = 0;
  4014. // Only use addEventListener/attachEvent if the special events handler returns false
  4015. if ( !special.setup || special.setup.call( elem, data, namespaces, eventHandle ) === false ) {
  4016. // Bind the global event handler to the element
  4017. if ( elem.addEventListener ) {
  4018. elem.addEventListener( type, eventHandle, false );
  4019. } else if ( elem.attachEvent ) {
  4020. elem.attachEvent( "on" + type, eventHandle );
  4021. }
  4022. }
  4023. }
  4024. if ( special.add ) {
  4025. special.add.call( elem, handleObj );
  4026. if ( !handleObj.handler.guid ) {
  4027. handleObj.handler.guid = handler.guid;
  4028. }
  4029. }
  4030. // Add to the element's handler list, delegates in front
  4031. if ( selector ) {
  4032. handlers.splice( handlers.delegateCount++, 0, handleObj );
  4033. } else {
  4034. handlers.push( handleObj );
  4035. }
  4036. // Keep track of which events have ever been used, for event optimization
  4037. jQuery.event.global[ type ] = true;
  4038. }
  4039. // Nullify elem to prevent memory leaks in IE
  4040. elem = null;
  4041. },
  4042. global: {},
  4043. // Detach an event or set of events from an element
  4044. remove: function( elem, types, handler, selector, mappedTypes ) {
  4045. var t, tns, type, origType, namespaces, origCount,
  4046. j, events, special, eventType, handleObj,
  4047. elemData = jQuery.hasData( elem ) && jQuery._data( elem );
  4048. if ( !elemData || !(events = elemData.events) ) {
  4049. return;
  4050. }
  4051. // Once for each type.namespace in types; type may be omitted
  4052. types = jQuery.trim( hoverHack( types || "" ) ).split(" ");
  4053. for ( t = 0; t < types.length; t++ ) {
  4054. tns = rtypenamespace.exec( types[t] ) || [];
  4055. type = origType = tns[1];
  4056. namespaces = tns[2];
  4057. // Unbind all events (on this namespace, if provided) for the element
  4058. if ( !type ) {
  4059. for ( type in events ) {
  4060. jQuery.event.remove( elem, type + types[ t ], handler, selector, true );
  4061. }
  4062. continue;
  4063. }
  4064. special = jQuery.event.special[ type ] || {};
  4065. type = ( selector? special.delegateType : special.bindType ) || type;
  4066. eventType = events[ type ] || [];
  4067. origCount = eventType.length;
  4068. namespaces = namespaces ? new RegExp("(^|\\.)" + namespaces.split(".").sort().join("\\.(?:.*\\.|)") + "(\\.|$)") : null;
  4069. // Remove matching events
  4070. for ( j = 0; j < eventType.length; j++ ) {
  4071. handleObj = eventType[ j ];
  4072. if ( ( mappedTypes || origType === handleObj.origType ) &&
  4073. ( !handler || handler.guid === handleObj.guid ) &&
  4074. ( !namespaces || namespaces.test( handleObj.namespace ) ) &&
  4075. ( !selector || selector === handleObj.selector || selector === "**" && handleObj.selector ) ) {
  4076. eventType.splice( j--, 1 );
  4077. if ( handleObj.selector ) {
  4078. eventType.delegateCount--;
  4079. }
  4080. if ( special.remove ) {
  4081. special.remove.call( elem, handleObj );
  4082. }
  4083. }
  4084. }
  4085. // Remove generic event handler if we removed something and no more handlers exist
  4086. // (avoids potential for endless recursion during removal of special event handlers)
  4087. if ( eventType.length === 0 && origCount !== eventType.length ) {
  4088. if ( !special.teardown || special.teardown.call( elem, namespaces, elemData.handle ) === false ) {
  4089. jQuery.removeEvent( elem, type, elemData.handle );
  4090. }
  4091. delete events[ type ];
  4092. }
  4093. }
  4094. // Remove the expando if it's no longer used
  4095. if ( jQuery.isEmptyObject( events ) ) {
  4096. delete elemData.handle;
  4097. // removeData also checks for emptiness and clears the expando if empty
  4098. // so use it instead of delete
  4099. jQuery.removeData( elem, "events", true );
  4100. }
  4101. },
  4102. // Events that are safe to short-circuit if no handlers are attached.
  4103. // Native DOM events should not be added, they may have inline handlers.
  4104. customEvent: {
  4105. "getData": true,
  4106. "setData": true,
  4107. "changeData": true
  4108. },
  4109. trigger: function( event, data, elem, onlyHandlers ) {
  4110. // Don't do events on text and comment nodes
  4111. if ( elem && (elem.nodeType === 3 || elem.nodeType === 8) ) {
  4112. return;
  4113. }
  4114. // Event object or event type
  4115. var cache, exclusive, i, cur, old, ontype, special, handle, eventPath, bubbleType,
  4116. type = event.type || event,
  4117. namespaces = [];
  4118. // focus/blur morphs to focusin/out; ensure we're not firing them right now
  4119. if ( rfocusMorph.test( type + jQuery.event.triggered ) ) {
  4120. return;
  4121. }
  4122. if ( type.indexOf( "!" ) >= 0 ) {
  4123. // Exclusive events trigger only for the exact event (no namespaces)
  4124. type = type.slice(0, -1);
  4125. exclusive = true;
  4126. }
  4127. if ( type.indexOf( "." ) >= 0 ) {
  4128. // Namespaced trigger; create a regexp to match event type in handle()
  4129. namespaces = type.split(".");
  4130. type = namespaces.shift();
  4131. namespaces.sort();
  4132. }
  4133. if ( (!elem || jQuery.event.customEvent[ type ]) && !jQuery.event.global[ type ] ) {
  4134. // No jQuery handlers for this event type, and it can't have inline handlers
  4135. return;
  4136. }
  4137. // Caller can pass in an Event, Object, or just an event type string
  4138. event = typeof event === "object" ?
  4139. // jQuery.Event object
  4140. event[ jQuery.expando ] ? event :
  4141. // Object literal
  4142. new jQuery.Event( type, event ) :
  4143. // Just the event type (string)
  4144. new jQuery.Event( type );
  4145. event.type = type;
  4146. event.isTrigger = true;
  4147. event.exclusive = exclusive;
  4148. event.namespace = namespaces.join( "." );
  4149. event.namespace_re = event.namespace? new RegExp("(^|\\.)" + namespaces.join("\\.(?:.*\\.|)") + "(\\.|$)") : null;
  4150. ontype = type.indexOf( ":" ) < 0 ? "on" + type : "";
  4151. // Handle a global trigger
  4152. if ( !elem ) {
  4153. // TODO: Stop taunting the data cache; remove global events and always attach to document
  4154. cache = jQuery.cache;
  4155. for ( i in cache ) {
  4156. if ( cache[ i ].events && cache[ i ].events[ type ] ) {
  4157. jQuery.event.trigger( event, data, cache[ i ].handle.elem, true );
  4158. }
  4159. }
  4160. return;
  4161. }
  4162. // Clean up the event in case it is being reused
  4163. event.result = undefined;
  4164. if ( !event.target ) {
  4165. event.target = elem;
  4166. }
  4167. // Clone any incoming data and prepend the event, creating the handler arg list
  4168. data = data != null ? jQuery.makeArray( data ) : [];
  4169. data.unshift( event );
  4170. // Allow special events to draw outside the lines
  4171. special = jQuery.event.special[ type ] || {};
  4172. if ( special.trigger && special.trigger.apply( elem, data ) === false ) {
  4173. return;
  4174. }
  4175. // Determine event propagation path in advance, per W3C events spec (#9951)
  4176. // Bubble up to document, then to window; watch for a global ownerDocument var (#9724)
  4177. eventPath = [[ elem, special.bindType || type ]];
  4178. if ( !onlyHandlers && !special.noBubble && !jQuery.isWindow( elem ) ) {
  4179. bubbleType = special.delegateType || type;
  4180. cur = rfocusMorph.test( bubbleType + type ) ? elem : elem.parentNode;
  4181. for ( old = elem; cur; cur = cur.parentNode ) {
  4182. eventPath.push([ cur, bubbleType ]);
  4183. old = cur;
  4184. }
  4185. // Only add window if we got to document (e.g., not plain obj or detached DOM)
  4186. if ( old === (elem.ownerDocument || document) ) {
  4187. eventPath.push([ old.defaultView || old.parentWindow || window, bubbleType ]);
  4188. }
  4189. }
  4190. // Fire handlers on the event path
  4191. for ( i = 0; i < eventPath.length && !event.isPropagationStopped(); i++ ) {
  4192. cur = eventPath[i][0];
  4193. event.type = eventPath[i][1];
  4194. handle = ( jQuery._data( cur, "events" ) || {} )[ event.type ] && jQuery._data( cur, "handle" );
  4195. if ( handle ) {
  4196. handle.apply( cur, data );
  4197. }
  4198. // Note that this is a bare JS function and not a jQuery handler
  4199. handle = ontype && cur[ ontype ];
  4200. if ( handle && jQuery.acceptData( cur ) && handle.apply && handle.apply( cur, data ) === false ) {
  4201. event.preventDefault();
  4202. }
  4203. }
  4204. event.type = type;
  4205. // If nobody prevented the default action, do it now
  4206. if ( !onlyHandlers && !event.isDefaultPrevented() ) {
  4207. if ( (!special._default || special._default.apply( elem.ownerDocument, data ) === false) &&
  4208. !(type === "click" && jQuery.nodeName( elem, "a" )) && jQuery.acceptData( elem ) ) {
  4209. // Call a native DOM method on the target with the same name name as the event.
  4210. // Can't use an .isFunction() check here because IE6/7 fails that test.
  4211. // Don't do default actions on window, that's where global variables be (#6170)
  4212. // IE<9 dies on focus/blur to hidden element (#1486)
  4213. if ( ontype && elem[ type ] && ((type !== "focus" && type !== "blur") || event.target.offsetWidth !== 0) && !jQuery.isWindow( elem ) ) {
  4214. // Don't re-trigger an onFOO event when we call its FOO() method
  4215. old = elem[ ontype ];
  4216. if ( old ) {
  4217. elem[ ontype ] = null;
  4218. }
  4219. // Prevent re-triggering of the same event, since we already bubbled it above
  4220. jQuery.event.triggered = type;
  4221. elem[ type ]();
  4222. jQuery.event.triggered = undefined;
  4223. if ( old ) {
  4224. elem[ ontype ] = old;
  4225. }
  4226. }
  4227. }
  4228. }
  4229. return event.result;
  4230. },
  4231. dispatch: function( event ) {
  4232. // Make a writable jQuery.Event from the native event object
  4233. event = jQuery.event.fix( event || window.event );
  4234. var i, j, cur, ret, selMatch, matched, matches, handleObj, sel, related,
  4235. handlers = ( (jQuery._data( this, "events" ) || {} )[ event.type ] || []),
  4236. delegateCount = handlers.delegateCount,
  4237. args = core_slice.call( arguments ),
  4238. run_all = !event.exclusive && !event.namespace,
  4239. special = jQuery.event.special[ event.type ] || {},
  4240. handlerQueue = [];
  4241. // Use the fix-ed jQuery.Event rather than the (read-only) native event
  4242. args[0] = event;
  4243. event.delegateTarget = this;
  4244. // Call the preDispatch hook for the mapped type, and let it bail if desired
  4245. if ( special.preDispatch && special.preDispatch.call( this, event ) === false ) {
  4246. return;
  4247. }
  4248. // Determine handlers that should run if there are delegated events
  4249. // Avoid non-left-click bubbling in Firefox (#3861)
  4250. if ( delegateCount && !(event.button && event.type === "click") ) {
  4251. for ( cur = event.target; cur != this; cur = cur.parentNode || this ) {
  4252. // Don't process clicks (ONLY) on disabled elements (#6911, #8165, #11382, #11764)
  4253. if ( cur.disabled !== true || event.type !== "click" ) {
  4254. selMatch = {};
  4255. matches = [];
  4256. for ( i = 0; i < delegateCount; i++ ) {
  4257. handleObj = handlers[ i ];
  4258. sel = handleObj.selector;
  4259. if ( selMatch[ sel ] === undefined ) {
  4260. selMatch[ sel ] = handleObj.needsContext ?
  4261. jQuery( sel, this ).index( cur ) >= 0 :
  4262. jQuery.find( sel, this, null, [ cur ] ).length;
  4263. }
  4264. if ( selMatch[ sel ] ) {
  4265. matches.push( handleObj );
  4266. }
  4267. }
  4268. if ( matches.length ) {
  4269. handlerQueue.push({ elem: cur, matches: matches });
  4270. }
  4271. }
  4272. }
  4273. }
  4274. // Add the remaining (directly-bound) handlers
  4275. if ( handlers.length > delegateCount ) {
  4276. handlerQueue.push({ elem: this, matches: handlers.slice( delegateCount ) });
  4277. }
  4278. // Run delegates first; they may want to stop propagation beneath us
  4279. for ( i = 0; i < handlerQueue.length && !event.isPropagationStopped(); i++ ) {
  4280. matched = handlerQueue[ i ];
  4281. event.currentTarget = matched.elem;
  4282. for ( j = 0; j < matched.matches.length && !event.isImmediatePropagationStopped(); j++ ) {
  4283. handleObj = matched.matches[ j ];
  4284. // Triggered event must either 1) be non-exclusive and have no namespace, or
  4285. // 2) have namespace(s) a subset or equal to those in the bound event (both can have no namespace).
  4286. if ( run_all || (!event.namespace && !handleObj.namespace) || event.namespace_re && event.namespace_re.test( handleObj.namespace ) ) {
  4287. event.data = handleObj.data;
  4288. event.handleObj = handleObj;
  4289. ret = ( (jQuery.event.special[ handleObj.origType ] || {}).handle || handleObj.handler )
  4290. .apply( matched.elem, args );
  4291. if ( ret !== undefined ) {
  4292. event.result = ret;
  4293. if ( ret === false ) {
  4294. event.preventDefault();
  4295. event.stopPropagation();
  4296. }
  4297. }
  4298. }
  4299. }
  4300. }
  4301. // Call the postDispatch hook for the mapped type
  4302. if ( special.postDispatch ) {
  4303. special.postDispatch.call( this, event );
  4304. }
  4305. return event.result;
  4306. },
  4307. // Includes some event props shared by KeyEvent and MouseEvent
  4308. // *** attrChange attrName relatedNode srcElement are not normalized, non-W3C, deprecated, will be removed in 1.8 ***
  4309. props: "attrChange attrName relatedNode srcElement altKey bubbles cancelable ctrlKey currentTarget eventPhase metaKey relatedTarget shiftKey target timeStamp view which".split(" "),
  4310. fixHooks: {},
  4311. keyHooks: {
  4312. props: "char charCode key keyCode".split(" "),
  4313. filter: function( event, original ) {
  4314. // Add which for key events
  4315. if ( event.which == null ) {
  4316. event.which = original.charCode != null ? original.charCode : original.keyCode;
  4317. }
  4318. return event;
  4319. }
  4320. },
  4321. mouseHooks: {
  4322. props: "button buttons clientX clientY fromElement offsetX offsetY pageX pageY screenX screenY toElement".split(" "),
  4323. filter: function( event, original ) {
  4324. var eventDoc, doc, body,
  4325. button = original.button,
  4326. fromElement = original.fromElement;
  4327. // Calculate pageX/Y if missing and clientX/Y available
  4328. if ( event.pageX == null && original.clientX != null ) {
  4329. eventDoc = event.target.ownerDocument || document;
  4330. doc = eventDoc.documentElement;
  4331. body = eventDoc.body;
  4332. event.pageX = original.clientX + ( doc && doc.scrollLeft || body && body.scrollLeft || 0 ) - ( doc && doc.clientLeft || body && body.clientLeft || 0 );
  4333. event.pageY = original.clientY + ( doc && doc.scrollTop || body && body.scrollTop || 0 ) - ( doc && doc.clientTop || body && body.clientTop || 0 );
  4334. }
  4335. // Add relatedTarget, if necessary
  4336. if ( !event.relatedTarget && fromElement ) {
  4337. event.relatedTarget = fromElement === event.target ? original.toElement : fromElement;
  4338. }
  4339. // Add which for click: 1 === left; 2 === middle; 3 === right
  4340. // Note: button is not normalized, so don't use it
  4341. if ( !event.which && button !== undefined ) {
  4342. event.which = ( button & 1 ? 1 : ( button & 2 ? 3 : ( button & 4 ? 2 : 0 ) ) );
  4343. }
  4344. return event;
  4345. }
  4346. },
  4347. fix: function( event ) {
  4348. if ( event[ jQuery.expando ] ) {
  4349. return event;
  4350. }
  4351. // Create a writable copy of the event object and normalize some properties
  4352. var i, prop,
  4353. originalEvent = event,
  4354. fixHook = jQuery.event.fixHooks[ event.type ] || {},
  4355. copy = fixHook.props ? this.props.concat( fixHook.props ) : this.props;
  4356. event = jQuery.Event( originalEvent );
  4357. for ( i = copy.length; i; ) {
  4358. prop = copy[ --i ];
  4359. event[ prop ] = originalEvent[ prop ];
  4360. }
  4361. // Fix target property, if necessary (#1925, IE 6/7/8 & Safari2)
  4362. if ( !event.target ) {
  4363. event.target = originalEvent.srcElement || document;
  4364. }
  4365. // Target should not be a text node (#504, Safari)
  4366. if ( event.target.nodeType === 3 ) {
  4367. event.target = event.target.parentNode;
  4368. }
  4369. // For mouse/key events, metaKey==false if it's undefined (#3368, #11328; IE6/7/8)
  4370. event.metaKey = !!event.metaKey;
  4371. return fixHook.filter? fixHook.filter( event, originalEvent ) : event;
  4372. },
  4373. special: {
  4374. load: {
  4375. // Prevent triggered image.load events from bubbling to window.load
  4376. noBubble: true
  4377. },
  4378. focus: {
  4379. delegateType: "focusin"
  4380. },
  4381. blur: {
  4382. delegateType: "focusout"
  4383. },
  4384. beforeunload: {
  4385. setup: function( data, namespaces, eventHandle ) {
  4386. // We only want to do this special case on windows
  4387. if ( jQuery.isWindow( this ) ) {
  4388. this.onbeforeunload = eventHandle;
  4389. }
  4390. },
  4391. teardown: function( namespaces, eventHandle ) {
  4392. if ( this.onbeforeunload === eventHandle ) {
  4393. this.onbeforeunload = null;
  4394. }
  4395. }
  4396. }
  4397. },
  4398. simulate: function( type, elem, event, bubble ) {
  4399. // Piggyback on a donor event to simulate a different one.
  4400. // Fake originalEvent to avoid donor's stopPropagation, but if the
  4401. // simulated event prevents default then we do the same on the donor.
  4402. var e = jQuery.extend(
  4403. new jQuery.Event(),
  4404. event,
  4405. { type: type,
  4406. isSimulated: true,
  4407. originalEvent: {}
  4408. }
  4409. );
  4410. if ( bubble ) {
  4411. jQuery.event.trigger( e, null, elem );
  4412. } else {
  4413. jQuery.event.dispatch.call( elem, e );
  4414. }
  4415. if ( e.isDefaultPrevented() ) {
  4416. event.preventDefault();
  4417. }
  4418. }
  4419. };
  4420. // Some plugins are using, but it's undocumented/deprecated and will be removed.
  4421. // The 1.7 special event interface should provide all the hooks needed now.
  4422. jQuery.event.handle = jQuery.event.dispatch;
  4423. jQuery.removeEvent = document.removeEventListener ?
  4424. function( elem, type, handle ) {
  4425. if ( elem.removeEventListener ) {
  4426. elem.removeEventListener( type, handle, false );
  4427. }
  4428. } :
  4429. function( elem, type, handle ) {
  4430. var name = "on" + type;
  4431. if ( elem.detachEvent ) {
  4432. // #8545, #7054, preventing memory leaks for custom events in IE6-8 –
  4433. // detachEvent needed property on element, by name of that event, to properly expose it to GC
  4434. if ( typeof elem[ name ] === "undefined" ) {
  4435. elem[ name ] = null;
  4436. }
  4437. elem.detachEvent( name, handle );
  4438. }
  4439. };
  4440. jQuery.Event = function( src, props ) {
  4441. // Allow instantiation without the 'new' keyword
  4442. if ( !(this instanceof jQuery.Event) ) {
  4443. return new jQuery.Event( src, props );
  4444. }
  4445. // Event object
  4446. if ( src && src.type ) {
  4447. this.originalEvent = src;
  4448. this.type = src.type;
  4449. // Events bubbling up the document may have been marked as prevented
  4450. // by a handler lower down the tree; reflect the correct value.
  4451. this.isDefaultPrevented = ( src.defaultPrevented || src.returnValue === false ||
  4452. src.getPreventDefault && src.getPreventDefault() ) ? returnTrue : returnFalse;
  4453. // Event type
  4454. } else {
  4455. this.type = src;
  4456. }
  4457. // Put explicitly provided properties onto the event object
  4458. if ( props ) {
  4459. jQuery.extend( this, props );
  4460. }
  4461. // Create a timestamp if incoming event doesn't have one
  4462. this.timeStamp = src && src.timeStamp || jQuery.now();
  4463. // Mark it as fixed
  4464. this[ jQuery.expando ] = true;
  4465. };
  4466. function returnFalse() {
  4467. return false;
  4468. }
  4469. function returnTrue() {
  4470. return true;
  4471. }
  4472. // jQuery.Event is based on DOM3 Events as specified by the ECMAScript Language Binding
  4473. // http://www.w3.org/TR/2003/WD-DOM-Level-3-Events-20030331/ecma-script-binding.html
  4474. jQuery.Event.prototype = {
  4475. preventDefault: function() {
  4476. this.isDefaultPrevented = returnTrue;
  4477. var e = this.originalEvent;
  4478. if ( !e ) {
  4479. return;
  4480. }
  4481. // if preventDefault exists run it on the original event
  4482. if ( e.preventDefault ) {
  4483. e.preventDefault();
  4484. // otherwise set the returnValue property of the original event to false (IE)
  4485. } else {
  4486. e.returnValue = false;
  4487. }
  4488. },
  4489. stopPropagation: function() {
  4490. this.isPropagationStopped = returnTrue;
  4491. var e = this.originalEvent;
  4492. if ( !e ) {
  4493. return;
  4494. }
  4495. // if stopPropagation exists run it on the original event
  4496. if ( e.stopPropagation ) {
  4497. e.stopPropagation();
  4498. }
  4499. // otherwise set the cancelBubble property of the original event to true (IE)
  4500. e.cancelBubble = true;
  4501. },
  4502. stopImmediatePropagation: function() {
  4503. this.isImmediatePropagationStopped = returnTrue;
  4504. this.stopPropagation();
  4505. },
  4506. isDefaultPrevented: returnFalse,
  4507. isPropagationStopped: returnFalse,
  4508. isImmediatePropagationStopped: returnFalse
  4509. };
  4510. // Create mouseenter/leave events using mouseover/out and event-time checks
  4511. jQuery.each({
  4512. mouseenter: "mouseover",
  4513. mouseleave: "mouseout"
  4514. }, function( orig, fix ) {
  4515. jQuery.event.special[ orig ] = {
  4516. delegateType: fix,
  4517. bindType: fix,
  4518. handle: function( event ) {
  4519. var ret,
  4520. target = this,
  4521. related = event.relatedTarget,
  4522. handleObj = event.handleObj,
  4523. selector = handleObj.selector;
  4524. // For mousenter/leave call the handler if related is outside the target.
  4525. // NB: No relatedTarget if the mouse left/entered the browser window
  4526. if ( !related || (related !== target && !jQuery.contains( target, related )) ) {
  4527. event.type = handleObj.origType;
  4528. ret = handleObj.handler.apply( this, arguments );
  4529. event.type = fix;
  4530. }
  4531. return ret;
  4532. }
  4533. };
  4534. });
  4535. // IE submit delegation
  4536. if ( !jQuery.support.submitBubbles ) {
  4537. jQuery.event.special.submit = {
  4538. setup: function() {
  4539. // Only need this for delegated form submit events
  4540. if ( jQuery.nodeName( this, "form" ) ) {
  4541. return false;
  4542. }
  4543. // Lazy-add a submit handler when a descendant form may potentially be submitted
  4544. jQuery.event.add( this, "click._submit keypress._submit", function( e ) {
  4545. // Node name check avoids a VML-related crash in IE (#9807)
  4546. var elem = e.target,
  4547. form = jQuery.nodeName( elem, "input" ) || jQuery.nodeName( elem, "button" ) ? elem.form : undefined;
  4548. if ( form && !jQuery._data( form, "_submit_attached" ) ) {
  4549. jQuery.event.add( form, "submit._submit", function( event ) {
  4550. event._submit_bubble = true;
  4551. });
  4552. jQuery._data( form, "_submit_attached", true );
  4553. }
  4554. });
  4555. // return undefined since we don't need an event listener
  4556. },
  4557. postDispatch: function( event ) {
  4558. // If form was submitted by the user, bubble the event up the tree
  4559. if ( event._submit_bubble ) {
  4560. delete event._submit_bubble;
  4561. if ( this.parentNode && !event.isTrigger ) {
  4562. jQuery.event.simulate( "submit", this.parentNode, event, true );
  4563. }
  4564. }
  4565. },
  4566. teardown: function() {
  4567. // Only need this for delegated form submit events
  4568. if ( jQuery.nodeName( this, "form" ) ) {
  4569. return false;
  4570. }
  4571. // Remove delegated handlers; cleanData eventually reaps submit handlers attached above
  4572. jQuery.event.remove( this, "._submit" );
  4573. }
  4574. };
  4575. }
  4576. // IE change delegation and checkbox/radio fix
  4577. if ( !jQuery.support.changeBubbles ) {
  4578. jQuery.event.special.change = {
  4579. setup: function() {
  4580. if ( rformElems.test( this.nodeName ) ) {
  4581. // IE doesn't fire change on a check/radio until blur; trigger it on click
  4582. // after a propertychange. Eat the blur-change in special.change.handle.
  4583. // This still fires onchange a second time for check/radio after blur.
  4584. if ( this.type === "checkbox" || this.type === "radio" ) {
  4585. jQuery.event.add( this, "propertychange._change", function( event ) {
  4586. if ( event.originalEvent.propertyName === "checked" ) {
  4587. this._just_changed = true;
  4588. }
  4589. });
  4590. jQuery.event.add( this, "click._change", function( event ) {
  4591. if ( this._just_changed && !event.isTrigger ) {
  4592. this._just_changed = false;
  4593. }
  4594. // Allow triggered, simulated change events (#11500)
  4595. jQuery.event.simulate( "change", this, event, true );
  4596. });
  4597. }
  4598. return false;
  4599. }
  4600. // Delegated event; lazy-add a change handler on descendant inputs
  4601. jQuery.event.add( this, "beforeactivate._change", function( e ) {
  4602. var elem = e.target;
  4603. if ( rformElems.test( elem.nodeName ) && !jQuery._data( elem, "_change_attached" ) ) {
  4604. jQuery.event.add( elem, "change._change", function( event ) {
  4605. if ( this.parentNode && !event.isSimulated && !event.isTrigger ) {
  4606. jQuery.event.simulate( "change", this.parentNode, event, true );
  4607. }
  4608. });
  4609. jQuery._data( elem, "_change_attached", true );
  4610. }
  4611. });
  4612. },
  4613. handle: function( event ) {
  4614. var elem = event.target;
  4615. // Swallow native change events from checkbox/radio, we already triggered them above
  4616. if ( this !== elem || event.isSimulated || event.isTrigger || (elem.type !== "radio" && elem.type !== "checkbox") ) {
  4617. return event.handleObj.handler.apply( this, arguments );
  4618. }
  4619. },
  4620. teardown: function() {
  4621. jQuery.event.remove( this, "._change" );
  4622. return !rformElems.test( this.nodeName );
  4623. }
  4624. };
  4625. }
  4626. // Create "bubbling" focus and blur events
  4627. if ( !jQuery.support.focusinBubbles ) {
  4628. jQuery.each({ focus: "focusin", blur: "focusout" }, function( orig, fix ) {
  4629. // Attach a single capturing handler while someone wants focusin/focusout
  4630. var attaches = 0,
  4631. handler = function( event ) {
  4632. jQuery.event.simulate( fix, event.target, jQuery.event.fix( event ), true );
  4633. };
  4634. jQuery.event.special[ fix ] = {
  4635. setup: function() {
  4636. if ( attaches++ === 0 ) {
  4637. document.addEventListener( orig, handler, true );
  4638. }
  4639. },
  4640. teardown: function() {
  4641. if ( --attaches === 0 ) {
  4642. document.removeEventListener( orig, handler, true );
  4643. }
  4644. }
  4645. };
  4646. });
  4647. }
  4648. jQuery.fn.extend({
  4649. on: function( types, selector, data, fn, /*INTERNAL*/ one ) {
  4650. var origFn, type;
  4651. // Types can be a map of types/handlers
  4652. if ( typeof types === "object" ) {
  4653. // ( types-Object, selector, data )
  4654. if ( typeof selector !== "string" ) { // && selector != null
  4655. // ( types-Object, data )
  4656. data = data || selector;
  4657. selector = undefined;
  4658. }
  4659. for ( type in types ) {
  4660. this.on( type, selector, data, types[ type ], one );
  4661. }
  4662. return this;
  4663. }
  4664. if ( data == null && fn == null ) {
  4665. // ( types, fn )
  4666. fn = selector;
  4667. data = selector = undefined;
  4668. } else if ( fn == null ) {
  4669. if ( typeof selector === "string" ) {
  4670. // ( types, selector, fn )
  4671. fn = data;
  4672. data = undefined;
  4673. } else {
  4674. // ( types, data, fn )
  4675. fn = data;
  4676. data = selector;
  4677. selector = undefined;
  4678. }
  4679. }
  4680. if ( fn === false ) {
  4681. fn = returnFalse;
  4682. } else if ( !fn ) {
  4683. return this;
  4684. }
  4685. if ( one === 1 ) {
  4686. origFn = fn;
  4687. fn = function( event ) {
  4688. // Can use an empty set, since event contains the info
  4689. jQuery().off( event );
  4690. return origFn.apply( this, arguments );
  4691. };
  4692. // Use same guid so caller can remove using origFn
  4693. fn.guid = origFn.guid || ( origFn.guid = jQuery.guid++ );
  4694. }
  4695. return this.each( function() {
  4696. jQuery.event.add( this, types, fn, data, selector );
  4697. });
  4698. },
  4699. one: function( types, selector, data, fn ) {
  4700. return this.on( types, selector, data, fn, 1 );
  4701. },
  4702. off: function( types, selector, fn ) {
  4703. var handleObj, type;
  4704. if ( types && types.preventDefault && types.handleObj ) {
  4705. // ( event ) dispatched jQuery.Event
  4706. handleObj = types.handleObj;
  4707. jQuery( types.delegateTarget ).off(
  4708. handleObj.namespace ? handleObj.origType + "." + handleObj.namespace : handleObj.origType,
  4709. handleObj.selector,
  4710. handleObj.handler
  4711. );
  4712. return this;
  4713. }
  4714. if ( typeof types === "object" ) {
  4715. // ( types-object [, selector] )
  4716. for ( type in types ) {
  4717. this.off( type, selector, types[ type ] );
  4718. }
  4719. return this;
  4720. }
  4721. if ( selector === false || typeof selector === "function" ) {
  4722. // ( types [, fn] )
  4723. fn = selector;
  4724. selector = undefined;
  4725. }
  4726. if ( fn === false ) {
  4727. fn = returnFalse;
  4728. }
  4729. return this.each(function() {
  4730. jQuery.event.remove( this, types, fn, selector );
  4731. });
  4732. },
  4733. bind: function( types, data, fn ) {
  4734. return this.on( types, null, data, fn );
  4735. },
  4736. unbind: function( types, fn ) {
  4737. return this.off( types, null, fn );
  4738. },
  4739. live: function( types, data, fn ) {
  4740. jQuery( this.context ).on( types, this.selector, data, fn );
  4741. return this;
  4742. },
  4743. die: function( types, fn ) {
  4744. jQuery( this.context ).off( types, this.selector || "**", fn );
  4745. return this;
  4746. },
  4747. delegate: function( selector, types, data, fn ) {
  4748. return this.on( types, selector, data, fn );
  4749. },
  4750. undelegate: function( selector, types, fn ) {
  4751. // ( namespace ) or ( selector, types [, fn] )
  4752. return arguments.length === 1 ? this.off( selector, "**" ) : this.off( types, selector || "**", fn );
  4753. },
  4754. trigger: function( type, data ) {
  4755. return this.each(function() {
  4756. jQuery.event.trigger( type, data, this );
  4757. });
  4758. },
  4759. triggerHandler: function( type, data ) {
  4760. if ( this[0] ) {
  4761. return jQuery.event.trigger( type, data, this[0], true );
  4762. }
  4763. },
  4764. toggle: function( fn ) {
  4765. // Save reference to arguments for access in closure
  4766. var args = arguments,
  4767. guid = fn.guid || jQuery.guid++,
  4768. i = 0,
  4769. toggler = function( event ) {
  4770. // Figure out which function to execute
  4771. var lastToggle = ( jQuery._data( this, "lastToggle" + fn.guid ) || 0 ) % i;
  4772. jQuery._data( this, "lastToggle" + fn.guid, lastToggle + 1 );
  4773. // Make sure that clicks stop
  4774. event.preventDefault();
  4775. // and execute the function
  4776. return args[ lastToggle ].apply( this, arguments ) || false;
  4777. };
  4778. // link all the functions, so any of them can unbind this click handler
  4779. toggler.guid = guid;
  4780. while ( i < args.length ) {
  4781. args[ i++ ].guid = guid;
  4782. }
  4783. return this.click( toggler );
  4784. },
  4785. hover: function( fnOver, fnOut ) {
  4786. return this.mouseenter( fnOver ).mouseleave( fnOut || fnOver );
  4787. }
  4788. });
  4789. jQuery.each( ("blur focus focusin focusout load resize scroll unload click dblclick " +
  4790. "mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave " +
  4791. "change select submit keydown keypress keyup error contextmenu").split(" "), function( i, name ) {
  4792. // Handle event binding
  4793. jQuery.fn[ name ] = function( data, fn ) {
  4794. if ( fn == null ) {
  4795. fn = data;
  4796. data = null;
  4797. }
  4798. return arguments.length > 0 ?
  4799. this.on( name, null, data, fn ) :
  4800. this.trigger( name );
  4801. };
  4802. if ( rkeyEvent.test( name ) ) {
  4803. jQuery.event.fixHooks[ name ] = jQuery.event.keyHooks;
  4804. }
  4805. if ( rmouseEvent.test( name ) ) {
  4806. jQuery.event.fixHooks[ name ] = jQuery.event.mouseHooks;
  4807. }
  4808. });
  4809. /*!
  4810. * Sizzle CSS Selector Engine
  4811. * Copyright 2012 jQuery Foundation and other contributors
  4812. * Released under the MIT license
  4813. * http://sizzlejs.com/
  4814. */
  4815. (function( window, undefined ) {
  4816. var cachedruns,
  4817. assertGetIdNotName,
  4818. Expr,
  4819. getText,
  4820. isXML,
  4821. contains,
  4822. compile,
  4823. sortOrder,
  4824. hasDuplicate,
  4825. outermostContext,
  4826. baseHasDuplicate = true,
  4827. strundefined = "undefined",
  4828. expando = ( "sizcache" + Math.random() ).replace( ".", "" ),
  4829. Token = String,
  4830. document = window.document,
  4831. docElem = document.documentElement,
  4832. dirruns = 0,
  4833. done = 0,
  4834. pop = [].pop,
  4835. push = [].push,
  4836. slice = [].slice,
  4837. // Use a stripped-down indexOf if a native one is unavailable
  4838. indexOf = [].indexOf || function( elem ) {
  4839. var i = 0,
  4840. len = this.length;
  4841. for ( ; i < len; i++ ) {
  4842. if ( this[i] === elem ) {
  4843. return i;
  4844. }
  4845. }
  4846. return -1;
  4847. },
  4848. // Augment a function for special use by Sizzle
  4849. markFunction = function( fn, value ) {
  4850. fn[ expando ] = value == null || value;
  4851. return fn;
  4852. },
  4853. createCache = function() {
  4854. var cache = {},
  4855. keys = [];
  4856. return markFunction(function( key, value ) {
  4857. // Only keep the most recent entries
  4858. if ( keys.push( key ) > Expr.cacheLength ) {
  4859. delete cache[ keys.shift() ];
  4860. }
  4861. return (cache[ key ] = value);
  4862. }, cache );
  4863. },
  4864. classCache = createCache(),
  4865. tokenCache = createCache(),
  4866. compilerCache = createCache(),
  4867. // Regex
  4868. // Whitespace characters http://www.w3.org/TR/css3-selectors/#whitespace
  4869. whitespace = "[\\x20\\t\\r\\n\\f]",
  4870. // http://www.w3.org/TR/css3-syntax/#characters
  4871. characterEncoding = "(?:\\\\.|[-\\w]|[^\\x00-\\xa0])+",
  4872. // Loosely modeled on CSS identifier characters
  4873. // An unquoted value should be a CSS identifier (http://www.w3.org/TR/css3-selectors/#attribute-selectors)
  4874. // Proper syntax: http://www.w3.org/TR/CSS21/syndata.html#value-def-identifier
  4875. identifier = characterEncoding.replace( "w", "w#" ),
  4876. // Acceptable operators http://www.w3.org/TR/selectors/#attribute-selectors
  4877. operators = "([*^$|!~]?=)",
  4878. attributes = "\\[" + whitespace + "*(" + characterEncoding + ")" + whitespace +
  4879. "*(?:" + operators + whitespace + "*(?:(['\"])((?:\\\\.|[^\\\\])*?)\\3|(" + identifier + ")|)|)" + whitespace + "*\\]",
  4880. // Prefer arguments not in parens/brackets,
  4881. // then attribute selectors and non-pseudos (denoted by :),
  4882. // then anything else
  4883. // These preferences are here to reduce the number of selectors
  4884. // needing tokenize in the PSEUDO preFilter
  4885. pseudos = ":(" + characterEncoding + ")(?:\\((?:(['\"])((?:\\\\.|[^\\\\])*?)\\2|([^()[\\]]*|(?:(?:" + attributes + ")|[^:]|\\\\.)*|.*))\\)|)",
  4886. // For matchExpr.POS and matchExpr.needsContext
  4887. pos = ":(even|odd|eq|gt|lt|nth|first|last)(?:\\(" + whitespace +
  4888. "*((?:-\\d)?\\d*)" + whitespace + "*\\)|)(?=[^-]|$)",
  4889. // Leading and non-escaped trailing whitespace, capturing some non-whitespace characters preceding the latter
  4890. rtrim = new RegExp( "^" + whitespace + "+|((?:^|[^\\\\])(?:\\\\.)*)" + whitespace + "+$", "g" ),
  4891. rcomma = new RegExp( "^" + whitespace + "*," + whitespace + "*" ),
  4892. rcombinators = new RegExp( "^" + whitespace + "*([\\x20\\t\\r\\n\\f>+~])" + whitespace + "*" ),
  4893. rpseudo = new RegExp( pseudos ),
  4894. // Easily-parseable/retrievable ID or TAG or CLASS selectors
  4895. rquickExpr = /^(?:#([\w\-]+)|(\w+)|\.([\w\-]+))$/,
  4896. rnot = /^:not/,
  4897. rsibling = /[\x20\t\r\n\f]*[+~]/,
  4898. rendsWithNot = /:not\($/,
  4899. rheader = /h\d/i,
  4900. rinputs = /input|select|textarea|button/i,
  4901. rbackslash = /\\(?!\\)/g,
  4902. matchExpr = {
  4903. "ID": new RegExp( "^#(" + characterEncoding + ")" ),
  4904. "CLASS": new RegExp( "^\\.(" + characterEncoding + ")" ),
  4905. "NAME": new RegExp( "^\\[name=['\"]?(" + characterEncoding + ")['\"]?\\]" ),
  4906. "TAG": new RegExp( "^(" + characterEncoding.replace( "w", "w*" ) + ")" ),
  4907. "ATTR": new RegExp( "^" + attributes ),
  4908. "PSEUDO": new RegExp( "^" + pseudos ),
  4909. "POS": new RegExp( pos, "i" ),
  4910. "CHILD": new RegExp( "^:(only|nth|first|last)-child(?:\\(" + whitespace +
  4911. "*(even|odd|(([+-]|)(\\d*)n|)" + whitespace + "*(?:([+-]|)" + whitespace +
  4912. "*(\\d+)|))" + whitespace + "*\\)|)", "i" ),
  4913. // For use in libraries implementing .is()
  4914. "needsContext": new RegExp( "^" + whitespace + "*[>+~]|" + pos, "i" )
  4915. },
  4916. // Support
  4917. // Used for testing something on an element
  4918. assert = function( fn ) {
  4919. var div = document.createElement("div");
  4920. try {
  4921. return fn( div );
  4922. } catch (e) {
  4923. return false;
  4924. } finally {
  4925. // release memory in IE
  4926. div = null;
  4927. }
  4928. },
  4929. // Check if getElementsByTagName("*") returns only elements
  4930. assertTagNameNoComments = assert(function( div ) {
  4931. div.appendChild( document.createComment("") );
  4932. return !div.getElementsByTagName("*").length;
  4933. }),
  4934. // Check if getAttribute returns normalized href attributes
  4935. assertHrefNotNormalized = assert(function( div ) {
  4936. div.innerHTML = "<a href='#'></a>";
  4937. return div.firstChild && typeof div.firstChild.getAttribute !== strundefined &&
  4938. div.firstChild.getAttribute("href") === "#";
  4939. }),
  4940. // Check if attributes should be retrieved by attribute nodes
  4941. assertAttributes = assert(function( div ) {
  4942. div.innerHTML = "<select></select>";
  4943. var type = typeof div.lastChild.getAttribute("multiple");
  4944. // IE8 returns a string for some attributes even when not present
  4945. return type !== "boolean" && type !== "string";
  4946. }),
  4947. // Check if getElementsByClassName can be trusted
  4948. assertUsableClassName = assert(function( div ) {
  4949. // Opera can't find a second classname (in 9.6)
  4950. div.innerHTML = "<div class='hidden e'></div><div class='hidden'></div>";
  4951. if ( !div.getElementsByClassName || !div.getElementsByClassName("e").length ) {
  4952. return false;
  4953. }
  4954. // Safari 3.2 caches class attributes and doesn't catch changes
  4955. div.lastChild.className = "e";
  4956. return div.getElementsByClassName("e").length === 2;
  4957. }),
  4958. // Check if getElementById returns elements by name
  4959. // Check if getElementsByName privileges form controls or returns elements by ID
  4960. assertUsableName = assert(function( div ) {
  4961. // Inject content
  4962. div.id = expando + 0;
  4963. div.innerHTML = "<a name='" + expando + "'></a><div name='" + expando + "'></div>";
  4964. docElem.insertBefore( div, docElem.firstChild );
  4965. // Test
  4966. var pass = document.getElementsByName &&
  4967. // buggy browsers will return fewer than the correct 2
  4968. document.getElementsByName( expando ).length === 2 +
  4969. // buggy browsers will return more than the correct 0
  4970. document.getElementsByName( expando + 0 ).length;
  4971. assertGetIdNotName = !document.getElementById( expando );
  4972. // Cleanup
  4973. docElem.removeChild( div );
  4974. return pass;
  4975. });
  4976. // If slice is not available, provide a backup
  4977. try {
  4978. slice.call( docElem.childNodes, 0 )[0].nodeType;
  4979. } catch ( e ) {
  4980. slice = function( i ) {
  4981. var elem,
  4982. results = [];
  4983. for ( ; (elem = this[i]); i++ ) {
  4984. results.push( elem );
  4985. }
  4986. return results;
  4987. };
  4988. }
  4989. function Sizzle( selector, context, results, seed ) {
  4990. results = results || [];
  4991. context = context || document;
  4992. var match, elem, xml, m,
  4993. nodeType = context.nodeType;
  4994. if ( !selector || typeof selector !== "string" ) {
  4995. return results;
  4996. }
  4997. if ( nodeType !== 1 && nodeType !== 9 ) {
  4998. return [];
  4999. }
  5000. xml = isXML( context );
  5001. if ( !xml && !seed ) {
  5002. if ( (match = rquickExpr.exec( selector )) ) {
  5003. // Speed-up: Sizzle("#ID")
  5004. if ( (m = match[1]) ) {
  5005. if ( nodeType === 9 ) {
  5006. elem = context.getElementById( m );
  5007. // Check parentNode to catch when Blackberry 4.6 returns
  5008. // nodes that are no longer in the document #6963
  5009. if ( elem && elem.parentNode ) {
  5010. // Handle the case where IE, Opera, and Webkit return items
  5011. // by name instead of ID
  5012. if ( elem.id === m ) {
  5013. results.push( elem );
  5014. return results;
  5015. }
  5016. } else {
  5017. return results;
  5018. }
  5019. } else {
  5020. // Context is not a document
  5021. if ( context.ownerDocument && (elem = context.ownerDocument.getElementById( m )) &&
  5022. contains( context, elem ) && elem.id === m ) {
  5023. results.push( elem );
  5024. return results;
  5025. }
  5026. }
  5027. // Speed-up: Sizzle("TAG")
  5028. } else if ( match[2] ) {
  5029. push.apply( results, slice.call(context.getElementsByTagName( selector ), 0) );
  5030. return results;
  5031. // Speed-up: Sizzle(".CLASS")
  5032. } else if ( (m = match[3]) && assertUsableClassName && context.getElementsByClassName ) {
  5033. push.apply( results, slice.call(context.getElementsByClassName( m ), 0) );
  5034. return results;
  5035. }
  5036. }
  5037. }
  5038. // All others
  5039. return select( selector.replace( rtrim, "$1" ), context, results, seed, xml );
  5040. }
  5041. Sizzle.matches = function( expr, elements ) {
  5042. return Sizzle( expr, null, null, elements );
  5043. };
  5044. Sizzle.matchesSelector = function( elem, expr ) {
  5045. return Sizzle( expr, null, null, [ elem ] ).length > 0;
  5046. };
  5047. // Returns a function to use in pseudos for input types
  5048. function createInputPseudo( type ) {
  5049. return function( elem ) {
  5050. var name = elem.nodeName.toLowerCase();
  5051. return name === "input" && elem.type === type;
  5052. };
  5053. }
  5054. // Returns a function to use in pseudos for buttons
  5055. function createButtonPseudo( type ) {
  5056. return function( elem ) {
  5057. var name = elem.nodeName.toLowerCase();
  5058. return (name === "input" || name === "button") && elem.type === type;
  5059. };
  5060. }
  5061. // Returns a function to use in pseudos for positionals
  5062. function createPositionalPseudo( fn ) {
  5063. return markFunction(function( argument ) {
  5064. argument = +argument;
  5065. return markFunction(function( seed, matches ) {
  5066. var j,
  5067. matchIndexes = fn( [], seed.length, argument ),
  5068. i = matchIndexes.length;
  5069. // Match elements found at the specified indexes
  5070. while ( i-- ) {
  5071. if ( seed[ (j = matchIndexes[i]) ] ) {
  5072. seed[j] = !(matches[j] = seed[j]);
  5073. }
  5074. }
  5075. });
  5076. });
  5077. }
  5078. /**
  5079. * Utility function for retrieving the text value of an array of DOM nodes
  5080. * @param {Array|Element} elem
  5081. */
  5082. getText = Sizzle.getText = function( elem ) {
  5083. var node,
  5084. ret = "",
  5085. i = 0,
  5086. nodeType = elem.nodeType;
  5087. if ( nodeType ) {
  5088. if ( nodeType === 1 || nodeType === 9 || nodeType === 11 ) {
  5089. // Use textContent for elements
  5090. // innerText usage removed for consistency of new lines (see #11153)
  5091. if ( typeof elem.textContent === "string" ) {
  5092. return elem.textContent;
  5093. } else {
  5094. // Traverse its children
  5095. for ( elem = elem.firstChild; elem; elem = elem.nextSibling ) {
  5096. ret += getText( elem );
  5097. }
  5098. }
  5099. } else if ( nodeType === 3 || nodeType === 4 ) {
  5100. return elem.nodeValue;
  5101. }
  5102. // Do not include comment or processing instruction nodes
  5103. } else {
  5104. // If no nodeType, this is expected to be an array
  5105. for ( ; (node = elem[i]); i++ ) {
  5106. // Do not traverse comment nodes
  5107. ret += getText( node );
  5108. }
  5109. }
  5110. return ret;
  5111. };
  5112. isXML = Sizzle.isXML = function( elem ) {
  5113. // documentElement is verified for cases where it doesn't yet exist
  5114. // (such as loading iframes in IE - #4833)
  5115. var documentElement = elem && (elem.ownerDocument || elem).documentElement;
  5116. return documentElement ? documentElement.nodeName !== "HTML" : false;
  5117. };
  5118. // Element contains another
  5119. contains = Sizzle.contains = docElem.contains ?
  5120. function( a, b ) {
  5121. var adown = a.nodeType === 9 ? a.documentElement : a,
  5122. bup = b && b.parentNode;
  5123. return a === bup || !!( bup && bup.nodeType === 1 && adown.contains && adown.contains(bup) );
  5124. } :
  5125. docElem.compareDocumentPosition ?
  5126. function( a, b ) {
  5127. return b && !!( a.compareDocumentPosition( b ) & 16 );
  5128. } :
  5129. function( a, b ) {
  5130. while ( (b = b.parentNode) ) {
  5131. if ( b === a ) {
  5132. return true;
  5133. }
  5134. }
  5135. return false;
  5136. };
  5137. Sizzle.attr = function( elem, name ) {
  5138. var val,
  5139. xml = isXML( elem );
  5140. if ( !xml ) {
  5141. name = name.toLowerCase();
  5142. }
  5143. if ( (val = Expr.attrHandle[ name ]) ) {
  5144. return val( elem );
  5145. }
  5146. if ( xml || assertAttributes ) {
  5147. return elem.getAttribute( name );
  5148. }
  5149. val = elem.getAttributeNode( name );
  5150. return val ?
  5151. typeof elem[ name ] === "boolean" ?
  5152. elem[ name ] ? name : null :
  5153. val.specified ? val.value : null :
  5154. null;
  5155. };
  5156. Expr = Sizzle.selectors = {
  5157. // Can be adjusted by the user
  5158. cacheLength: 50,
  5159. createPseudo: markFunction,
  5160. match: matchExpr,
  5161. // IE6/7 return a modified href
  5162. attrHandle: assertHrefNotNormalized ?
  5163. {} :
  5164. {
  5165. "href": function( elem ) {
  5166. return elem.getAttribute( "href", 2 );
  5167. },
  5168. "type": function( elem ) {
  5169. return elem.getAttribute("type");
  5170. }
  5171. },
  5172. find: {
  5173. "ID": assertGetIdNotName ?
  5174. function( id, context, xml ) {
  5175. if ( typeof context.getElementById !== strundefined && !xml ) {
  5176. var m = context.getElementById( id );
  5177. // Check parentNode to catch when Blackberry 4.6 returns
  5178. // nodes that are no longer in the document #6963
  5179. return m && m.parentNode ? [m] : [];
  5180. }
  5181. } :
  5182. function( id, context, xml ) {
  5183. if ( typeof context.getElementById !== strundefined && !xml ) {
  5184. var m = context.getElementById( id );
  5185. return m ?
  5186. m.id === id || typeof m.getAttributeNode !== strundefined && m.getAttributeNode("id").value === id ?
  5187. [m] :
  5188. undefined :
  5189. [];
  5190. }
  5191. },
  5192. "TAG": assertTagNameNoComments ?
  5193. function( tag, context ) {
  5194. if ( typeof context.getElementsByTagName !== strundefined ) {
  5195. return context.getElementsByTagName( tag );
  5196. }
  5197. } :
  5198. function( tag, context ) {
  5199. var results = context.getElementsByTagName( tag );
  5200. // Filter out possible comments
  5201. if ( tag === "*" ) {
  5202. var elem,
  5203. tmp = [],
  5204. i = 0;
  5205. for ( ; (elem = results[i]); i++ ) {
  5206. if ( elem.nodeType === 1 ) {
  5207. tmp.push( elem );
  5208. }
  5209. }
  5210. return tmp;
  5211. }
  5212. return results;
  5213. },
  5214. "NAME": assertUsableName && function( tag, context ) {
  5215. if ( typeof context.getElementsByName !== strundefined ) {
  5216. return context.getElementsByName( name );
  5217. }
  5218. },
  5219. "CLASS": assertUsableClassName && function( className, context, xml ) {
  5220. if ( typeof context.getElementsByClassName !== strundefined && !xml ) {
  5221. return context.getElementsByClassName( className );
  5222. }
  5223. }
  5224. },
  5225. relative: {
  5226. ">": { dir: "parentNode", first: true },
  5227. " ": { dir: "parentNode" },
  5228. "+": { dir: "previousSibling", first: true },
  5229. "~": { dir: "previousSibling" }
  5230. },
  5231. preFilter: {
  5232. "ATTR": function( match ) {
  5233. match[1] = match[1].replace( rbackslash, "" );
  5234. // Move the given value to match[3] whether quoted or unquoted
  5235. match[3] = ( match[4] || match[5] || "" ).replace( rbackslash, "" );
  5236. if ( match[2] === "~=" ) {
  5237. match[3] = " " + match[3] + " ";
  5238. }
  5239. return match.slice( 0, 4 );
  5240. },
  5241. "CHILD": function( match ) {
  5242. /* matches from matchExpr["CHILD"]
  5243. 1 type (only|nth|...)
  5244. 2 argument (even|odd|\d*|\d*n([+-]\d+)?|...)
  5245. 3 xn-component of xn+y argument ([+-]?\d*n|)
  5246. 4 sign of xn-component
  5247. 5 x of xn-component
  5248. 6 sign of y-component
  5249. 7 y of y-component
  5250. */
  5251. match[1] = match[1].toLowerCase();
  5252. if ( match[1] === "nth" ) {
  5253. // nth-child requires argument
  5254. if ( !match[2] ) {
  5255. Sizzle.error( match[0] );
  5256. }
  5257. // numeric x and y parameters for Expr.filter.CHILD
  5258. // remember that false/true cast respectively to 0/1
  5259. match[3] = +( match[3] ? match[4] + (match[5] || 1) : 2 * ( match[2] === "even" || match[2] === "odd" ) );
  5260. match[4] = +( ( match[6] + match[7] ) || match[2] === "odd" );
  5261. // other types prohibit arguments
  5262. } else if ( match[2] ) {
  5263. Sizzle.error( match[0] );
  5264. }
  5265. return match;
  5266. },
  5267. "PSEUDO": function( match ) {
  5268. var unquoted, excess;
  5269. if ( matchExpr["CHILD"].test( match[0] ) ) {
  5270. return null;
  5271. }
  5272. if ( match[3] ) {
  5273. match[2] = match[3];
  5274. } else if ( (unquoted = match[4]) ) {
  5275. // Only check arguments that contain a pseudo
  5276. if ( rpseudo.test(unquoted) &&
  5277. // Get excess from tokenize (recursively)
  5278. (excess = tokenize( unquoted, true )) &&
  5279. // advance to the next closing parenthesis
  5280. (excess = unquoted.indexOf( ")", unquoted.length - excess ) - unquoted.length) ) {
  5281. // excess is a negative index
  5282. unquoted = unquoted.slice( 0, excess );
  5283. match[0] = match[0].slice( 0, excess );
  5284. }
  5285. match[2] = unquoted;
  5286. }
  5287. // Return only captures needed by the pseudo filter method (type and argument)
  5288. return match.slice( 0, 3 );
  5289. }
  5290. },
  5291. filter: {
  5292. "ID": assertGetIdNotName ?
  5293. function( id ) {
  5294. id = id.replace( rbackslash, "" );
  5295. return function( elem ) {
  5296. return elem.getAttribute("id") === id;
  5297. };
  5298. } :
  5299. function( id ) {
  5300. id = id.replace( rbackslash, "" );
  5301. return function( elem ) {
  5302. var node = typeof elem.getAttributeNode !== strundefined && elem.getAttributeNode("id");
  5303. return node && node.value === id;
  5304. };
  5305. },
  5306. "TAG": function( nodeName ) {
  5307. if ( nodeName === "*" ) {
  5308. return function() { return true; };
  5309. }
  5310. nodeName = nodeName.replace( rbackslash, "" ).toLowerCase();
  5311. return function( elem ) {
  5312. return elem.nodeName && elem.nodeName.toLowerCase() === nodeName;
  5313. };
  5314. },
  5315. "CLASS": function( className ) {
  5316. var pattern = classCache[ expando ][ className ];
  5317. if ( !pattern ) {
  5318. pattern = classCache( className, new RegExp("(^|" + whitespace + ")" + className + "(" + whitespace + "|$)") );
  5319. }
  5320. return function( elem ) {
  5321. return pattern.test( elem.className || (typeof elem.getAttribute !== strundefined && elem.getAttribute("class")) || "" );
  5322. };
  5323. },
  5324. "ATTR": function( name, operator, check ) {
  5325. return function( elem, context ) {
  5326. var result = Sizzle.attr( elem, name );
  5327. if ( result == null ) {
  5328. return operator === "!=";
  5329. }
  5330. if ( !operator ) {
  5331. return true;
  5332. }
  5333. result += "";
  5334. return operator === "=" ? result === check :
  5335. operator === "!=" ? result !== check :
  5336. operator === "^=" ? check && result.indexOf( check ) === 0 :
  5337. operator === "*=" ? check && result.indexOf( check ) > -1 :
  5338. operator === "$=" ? check && result.substr( result.length - check.length ) === check :
  5339. operator === "~=" ? ( " " + result + " " ).indexOf( check ) > -1 :
  5340. operator === "|=" ? result === check || result.substr( 0, check.length + 1 ) === check + "-" :
  5341. false;
  5342. };
  5343. },
  5344. "CHILD": function( type, argument, first, last ) {
  5345. if ( type === "nth" ) {
  5346. return function( elem ) {
  5347. var node, diff,
  5348. parent = elem.parentNode;
  5349. if ( first === 1 && last === 0 ) {
  5350. return true;
  5351. }
  5352. if ( parent ) {
  5353. diff = 0;
  5354. for ( node = parent.firstChild; node; node = node.nextSibling ) {
  5355. if ( node.nodeType === 1 ) {
  5356. diff++;
  5357. if ( elem === node ) {
  5358. break;
  5359. }
  5360. }
  5361. }
  5362. }
  5363. // Incorporate the offset (or cast to NaN), then check against cycle size
  5364. diff -= last;
  5365. return diff === first || ( diff % first === 0 && diff / first >= 0 );
  5366. };
  5367. }
  5368. return function( elem ) {
  5369. var node = elem;
  5370. switch ( type ) {
  5371. case "only":
  5372. case "first":
  5373. while ( (node = node.previousSibling) ) {
  5374. if ( node.nodeType === 1 ) {
  5375. return false;
  5376. }
  5377. }
  5378. if ( type === "first" ) {
  5379. return true;
  5380. }
  5381. node = elem;
  5382. /* falls through */
  5383. case "last":
  5384. while ( (node = node.nextSibling) ) {
  5385. if ( node.nodeType === 1 ) {
  5386. return false;
  5387. }
  5388. }
  5389. return true;
  5390. }
  5391. };
  5392. },
  5393. "PSEUDO": function( pseudo, argument ) {
  5394. // pseudo-class names are case-insensitive
  5395. // http://www.w3.org/TR/selectors/#pseudo-classes
  5396. // Prioritize by case sensitivity in case custom pseudos are added with uppercase letters
  5397. // Remember that setFilters inherits from pseudos
  5398. var args,
  5399. fn = Expr.pseudos[ pseudo ] || Expr.setFilters[ pseudo.toLowerCase() ] ||
  5400. Sizzle.error( "unsupported pseudo: " + pseudo );
  5401. // The user may use createPseudo to indicate that
  5402. // arguments are needed to create the filter function
  5403. // just as Sizzle does
  5404. if ( fn[ expando ] ) {
  5405. return fn( argument );
  5406. }
  5407. // But maintain support for old signatures
  5408. if ( fn.length > 1 ) {
  5409. args = [ pseudo, pseudo, "", argument ];
  5410. return Expr.setFilters.hasOwnProperty( pseudo.toLowerCase() ) ?
  5411. markFunction(function( seed, matches ) {
  5412. var idx,
  5413. matched = fn( seed, argument ),
  5414. i = matched.length;
  5415. while ( i-- ) {
  5416. idx = indexOf.call( seed, matched[i] );
  5417. seed[ idx ] = !( matches[ idx ] = matched[i] );
  5418. }
  5419. }) :
  5420. function( elem ) {
  5421. return fn( elem, 0, args );
  5422. };
  5423. }
  5424. return fn;
  5425. }
  5426. },
  5427. pseudos: {
  5428. "not": markFunction(function( selector ) {
  5429. // Trim the selector passed to compile
  5430. // to avoid treating leading and trailing
  5431. // spaces as combinators
  5432. var input = [],
  5433. results = [],
  5434. matcher = compile( selector.replace( rtrim, "$1" ) );
  5435. return matcher[ expando ] ?
  5436. markFunction(function( seed, matches, context, xml ) {
  5437. var elem,
  5438. unmatched = matcher( seed, null, xml, [] ),
  5439. i = seed.length;
  5440. // Match elements unmatched by `matcher`
  5441. while ( i-- ) {
  5442. if ( (elem = unmatched[i]) ) {
  5443. seed[i] = !(matches[i] = elem);
  5444. }
  5445. }
  5446. }) :
  5447. function( elem, context, xml ) {
  5448. input[0] = elem;
  5449. matcher( input, null, xml, results );
  5450. return !results.pop();
  5451. };
  5452. }),
  5453. "has": markFunction(function( selector ) {
  5454. return function( elem ) {
  5455. return Sizzle( selector, elem ).length > 0;
  5456. };
  5457. }),
  5458. "contains": markFunction(function( text ) {
  5459. return function( elem ) {
  5460. return ( elem.textContent || elem.innerText || getText( elem ) ).indexOf( text ) > -1;
  5461. };
  5462. }),
  5463. "enabled": function( elem ) {
  5464. return elem.disabled === false;
  5465. },
  5466. "disabled": function( elem ) {
  5467. return elem.disabled === true;
  5468. },
  5469. "checked": function( elem ) {
  5470. // In CSS3, :checked should return both checked and selected elements
  5471. // http://www.w3.org/TR/2011/REC-css3-selectors-20110929/#checked
  5472. var nodeName = elem.nodeName.toLowerCase();
  5473. return (nodeName === "input" && !!elem.checked) || (nodeName === "option" && !!elem.selected);
  5474. },
  5475. "selected": function( elem ) {
  5476. // Accessing this property makes selected-by-default
  5477. // options in Safari work properly
  5478. if ( elem.parentNode ) {
  5479. elem.parentNode.selectedIndex;
  5480. }
  5481. return elem.selected === true;
  5482. },
  5483. "parent": function( elem ) {
  5484. return !Expr.pseudos["empty"]( elem );
  5485. },
  5486. "empty": function( elem ) {
  5487. // http://www.w3.org/TR/selectors/#empty-pseudo
  5488. // :empty is only affected by element nodes and content nodes(including text(3), cdata(4)),
  5489. // not comment, processing instructions, or others
  5490. // Thanks to Diego Perini for the nodeName shortcut
  5491. // Greater than "@" means alpha characters (specifically not starting with "#" or "?")
  5492. var nodeType;
  5493. elem = elem.firstChild;
  5494. while ( elem ) {
  5495. if ( elem.nodeName > "@" || (nodeType = elem.nodeType) === 3 || nodeType === 4 ) {
  5496. return false;
  5497. }
  5498. elem = elem.nextSibling;
  5499. }
  5500. return true;
  5501. },
  5502. "header": function( elem ) {
  5503. return rheader.test( elem.nodeName );
  5504. },
  5505. "text": function( elem ) {
  5506. var type, attr;
  5507. // IE6 and 7 will map elem.type to 'text' for new HTML5 types (search, etc)
  5508. // use getAttribute instead to test this case
  5509. return elem.nodeName.toLowerCase() === "input" &&
  5510. (type = elem.type) === "text" &&
  5511. ( (attr = elem.getAttribute("type")) == null || attr.toLowerCase() === type );
  5512. },
  5513. // Input types
  5514. "radio": createInputPseudo("radio"),
  5515. "checkbox": createInputPseudo("checkbox"),
  5516. "file": createInputPseudo("file"),
  5517. "password": createInputPseudo("password"),
  5518. "image": createInputPseudo("image"),
  5519. "submit": createButtonPseudo("submit"),
  5520. "reset": createButtonPseudo("reset"),
  5521. "button": function( elem ) {
  5522. var name = elem.nodeName.toLowerCase();
  5523. return name === "input" && elem.type === "button" || name === "button";
  5524. },
  5525. "input": function( elem ) {
  5526. return rinputs.test( elem.nodeName );
  5527. },
  5528. "focus": function( elem ) {
  5529. var doc = elem.ownerDocument;
  5530. return elem === doc.activeElement && (!doc.hasFocus || doc.hasFocus()) && !!(elem.type || elem.href);
  5531. },
  5532. "active": function( elem ) {
  5533. return elem === elem.ownerDocument.activeElement;
  5534. },
  5535. // Positional types
  5536. "first": createPositionalPseudo(function( matchIndexes, length, argument ) {
  5537. return [ 0 ];
  5538. }),
  5539. "last": createPositionalPseudo(function( matchIndexes, length, argument ) {
  5540. return [ length - 1 ];
  5541. }),
  5542. "eq": createPositionalPseudo(function( matchIndexes, length, argument ) {
  5543. return [ argument < 0 ? argument + length : argument ];
  5544. }),
  5545. "even": createPositionalPseudo(function( matchIndexes, length, argument ) {
  5546. for ( var i = 0; i < length; i += 2 ) {
  5547. matchIndexes.push( i );
  5548. }
  5549. return matchIndexes;
  5550. }),
  5551. "odd": createPositionalPseudo(function( matchIndexes, length, argument ) {
  5552. for ( var i = 1; i < length; i += 2 ) {
  5553. matchIndexes.push( i );
  5554. }
  5555. return matchIndexes;
  5556. }),
  5557. "lt": createPositionalPseudo(function( matchIndexes, length, argument ) {
  5558. for ( var i = argument < 0 ? argument + length : argument; --i >= 0; ) {
  5559. matchIndexes.push( i );
  5560. }
  5561. return matchIndexes;
  5562. }),
  5563. "gt": createPositionalPseudo(function( matchIndexes, length, argument ) {
  5564. for ( var i = argument < 0 ? argument + length : argument; ++i < length; ) {
  5565. matchIndexes.push( i );
  5566. }
  5567. return matchIndexes;
  5568. })
  5569. }
  5570. };
  5571. function siblingCheck( a, b, ret ) {
  5572. if ( a === b ) {
  5573. return ret;
  5574. }
  5575. var cur = a.nextSibling;
  5576. while ( cur ) {
  5577. if ( cur === b ) {
  5578. return -1;
  5579. }
  5580. cur = cur.nextSibling;
  5581. }
  5582. return 1;
  5583. }
  5584. sortOrder = docElem.compareDocumentPosition ?
  5585. function( a, b ) {
  5586. if ( a === b ) {
  5587. hasDuplicate = true;
  5588. return 0;
  5589. }
  5590. return ( !a.compareDocumentPosition || !b.compareDocumentPosition ?
  5591. a.compareDocumentPosition :
  5592. a.compareDocumentPosition(b) & 4
  5593. ) ? -1 : 1;
  5594. } :
  5595. function( a, b ) {
  5596. // The nodes are identical, we can exit early
  5597. if ( a === b ) {
  5598. hasDuplicate = true;
  5599. return 0;
  5600. // Fallback to using sourceIndex (in IE) if it's available on both nodes
  5601. } else if ( a.sourceIndex && b.sourceIndex ) {
  5602. return a.sourceIndex - b.sourceIndex;
  5603. }
  5604. var al, bl,
  5605. ap = [],
  5606. bp = [],
  5607. aup = a.parentNode,
  5608. bup = b.parentNode,
  5609. cur = aup;
  5610. // If the nodes are siblings (or identical) we can do a quick check
  5611. if ( aup === bup ) {
  5612. return siblingCheck( a, b );
  5613. // If no parents were found then the nodes are disconnected
  5614. } else if ( !aup ) {
  5615. return -1;
  5616. } else if ( !bup ) {
  5617. return 1;
  5618. }
  5619. // Otherwise they're somewhere else in the tree so we need
  5620. // to build up a full list of the parentNodes for comparison
  5621. while ( cur ) {
  5622. ap.unshift( cur );
  5623. cur = cur.parentNode;
  5624. }
  5625. cur = bup;
  5626. while ( cur ) {
  5627. bp.unshift( cur );
  5628. cur = cur.parentNode;
  5629. }
  5630. al = ap.length;
  5631. bl = bp.length;
  5632. // Start walking down the tree looking for a discrepancy
  5633. for ( var i = 0; i < al && i < bl; i++ ) {
  5634. if ( ap[i] !== bp[i] ) {
  5635. return siblingCheck( ap[i], bp[i] );
  5636. }
  5637. }
  5638. // We ended someplace up the tree so do a sibling check
  5639. return i === al ?
  5640. siblingCheck( a, bp[i], -1 ) :
  5641. siblingCheck( ap[i], b, 1 );
  5642. };
  5643. // Always assume the presence of duplicates if sort doesn't
  5644. // pass them to our comparison function (as in Google Chrome).
  5645. [0, 0].sort( sortOrder );
  5646. baseHasDuplicate = !hasDuplicate;
  5647. // Document sorting and removing duplicates
  5648. Sizzle.uniqueSort = function( results ) {
  5649. var elem,
  5650. i = 1;
  5651. hasDuplicate = baseHasDuplicate;
  5652. results.sort( sortOrder );
  5653. if ( hasDuplicate ) {
  5654. for ( ; (elem = results[i]); i++ ) {
  5655. if ( elem === results[ i - 1 ] ) {
  5656. results.splice( i--, 1 );
  5657. }
  5658. }
  5659. }
  5660. return results;
  5661. };
  5662. Sizzle.error = function( msg ) {
  5663. throw new Error( "Syntax error, unrecognized expression: " + msg );
  5664. };
  5665. function tokenize( selector, parseOnly ) {
  5666. var matched, match, tokens, type, soFar, groups, preFilters,
  5667. cached = tokenCache[ expando ][ selector ];
  5668. if ( cached ) {
  5669. return parseOnly ? 0 : cached.slice( 0 );
  5670. }
  5671. soFar = selector;
  5672. groups = [];
  5673. preFilters = Expr.preFilter;
  5674. while ( soFar ) {
  5675. // Comma and first run
  5676. if ( !matched || (match = rcomma.exec( soFar )) ) {
  5677. if ( match ) {
  5678. soFar = soFar.slice( match[0].length );
  5679. }
  5680. groups.push( tokens = [] );
  5681. }
  5682. matched = false;
  5683. // Combinators
  5684. if ( (match = rcombinators.exec( soFar )) ) {
  5685. tokens.push( matched = new Token( match.shift() ) );
  5686. soFar = soFar.slice( matched.length );
  5687. // Cast descendant combinators to space
  5688. matched.type = match[0].replace( rtrim, " " );
  5689. }
  5690. // Filters
  5691. for ( type in Expr.filter ) {
  5692. if ( (match = matchExpr[ type ].exec( soFar )) && (!preFilters[ type ] ||
  5693. // The last two arguments here are (context, xml) for backCompat
  5694. (match = preFilters[ type ]( match, document, true ))) ) {
  5695. tokens.push( matched = new Token( match.shift() ) );
  5696. soFar = soFar.slice( matched.length );
  5697. matched.type = type;
  5698. matched.matches = match;
  5699. }
  5700. }
  5701. if ( !matched ) {
  5702. break;
  5703. }
  5704. }
  5705. // Return the length of the invalid excess
  5706. // if we're just parsing
  5707. // Otherwise, throw an error or return tokens
  5708. return parseOnly ?
  5709. soFar.length :
  5710. soFar ?
  5711. Sizzle.error( selector ) :
  5712. // Cache the tokens
  5713. tokenCache( selector, groups ).slice( 0 );
  5714. }
  5715. function addCombinator( matcher, combinator, base ) {
  5716. var dir = combinator.dir,
  5717. checkNonElements = base && combinator.dir === "parentNode",
  5718. doneName = done++;
  5719. return combinator.first ?
  5720. // Check against closest ancestor/preceding element
  5721. function( elem, context, xml ) {
  5722. while ( (elem = elem[ dir ]) ) {
  5723. if ( checkNonElements || elem.nodeType === 1 ) {
  5724. return matcher( elem, context, xml );
  5725. }
  5726. }
  5727. } :
  5728. // Check against all ancestor/preceding elements
  5729. function( elem, context, xml ) {
  5730. // We can't set arbitrary data on XML nodes, so they don't benefit from dir caching
  5731. if ( !xml ) {
  5732. var cache,
  5733. dirkey = dirruns + " " + doneName + " ",
  5734. cachedkey = dirkey + cachedruns;
  5735. while ( (elem = elem[ dir ]) ) {
  5736. if ( checkNonElements || elem.nodeType === 1 ) {
  5737. if ( (cache = elem[ expando ]) === cachedkey ) {
  5738. return elem.sizset;
  5739. } else if ( typeof cache === "string" && cache.indexOf(dirkey) === 0 ) {
  5740. if ( elem.sizset ) {
  5741. return elem;
  5742. }
  5743. } else {
  5744. elem[ expando ] = cachedkey;
  5745. if ( matcher( elem, context, xml ) ) {
  5746. elem.sizset = true;
  5747. return elem;
  5748. }
  5749. elem.sizset = false;
  5750. }
  5751. }
  5752. }
  5753. } else {
  5754. while ( (elem = elem[ dir ]) ) {
  5755. if ( checkNonElements || elem.nodeType === 1 ) {
  5756. if ( matcher( elem, context, xml ) ) {
  5757. return elem;
  5758. }
  5759. }
  5760. }
  5761. }
  5762. };
  5763. }
  5764. function elementMatcher( matchers ) {
  5765. return matchers.length > 1 ?
  5766. function( elem, context, xml ) {
  5767. var i = matchers.length;
  5768. while ( i-- ) {
  5769. if ( !matchers[i]( elem, context, xml ) ) {
  5770. return false;
  5771. }
  5772. }
  5773. return true;
  5774. } :
  5775. matchers[0];
  5776. }
  5777. function condense( unmatched, map, filter, context, xml ) {
  5778. var elem,
  5779. newUnmatched = [],
  5780. i = 0,
  5781. len = unmatched.length,
  5782. mapped = map != null;
  5783. for ( ; i < len; i++ ) {
  5784. if ( (elem = unmatched[i]) ) {
  5785. if ( !filter || filter( elem, context, xml ) ) {
  5786. newUnmatched.push( elem );
  5787. if ( mapped ) {
  5788. map.push( i );
  5789. }
  5790. }
  5791. }
  5792. }
  5793. return newUnmatched;
  5794. }
  5795. function setMatcher( preFilter, selector, matcher, postFilter, postFinder, postSelector ) {
  5796. if ( postFilter && !postFilter[ expando ] ) {
  5797. postFilter = setMatcher( postFilter );
  5798. }
  5799. if ( postFinder && !postFinder[ expando ] ) {
  5800. postFinder = setMatcher( postFinder, postSelector );
  5801. }
  5802. return markFunction(function( seed, results, context, xml ) {
  5803. // Positional selectors apply to seed elements, so it is invalid to follow them with relative ones
  5804. if ( seed && postFinder ) {
  5805. return;
  5806. }
  5807. var i, elem, postFilterIn,
  5808. preMap = [],
  5809. postMap = [],
  5810. preexisting = results.length,
  5811. // Get initial elements from seed or context
  5812. elems = seed || multipleContexts( selector || "*", context.nodeType ? [ context ] : context, [], seed ),
  5813. // Prefilter to get matcher input, preserving a map for seed-results synchronization
  5814. matcherIn = preFilter && ( seed || !selector ) ?
  5815. condense( elems, preMap, preFilter, context, xml ) :
  5816. elems,
  5817. matcherOut = matcher ?
  5818. // If we have a postFinder, or filtered seed, or non-seed postFilter or preexisting results,
  5819. postFinder || ( seed ? preFilter : preexisting || postFilter ) ?
  5820. // ...intermediate processing is necessary
  5821. [] :
  5822. // ...otherwise use results directly
  5823. results :
  5824. matcherIn;
  5825. // Find primary matches
  5826. if ( matcher ) {
  5827. matcher( matcherIn, matcherOut, context, xml );
  5828. }
  5829. // Apply postFilter
  5830. if ( postFilter ) {
  5831. postFilterIn = condense( matcherOut, postMap );
  5832. postFilter( postFilterIn, [], context, xml );
  5833. // Un-match failing elements by moving them back to matcherIn
  5834. i = postFilterIn.length;
  5835. while ( i-- ) {
  5836. if ( (elem = postFilterIn[i]) ) {
  5837. matcherOut[ postMap[i] ] = !(matcherIn[ postMap[i] ] = elem);
  5838. }
  5839. }
  5840. }
  5841. // Keep seed and results synchronized
  5842. if ( seed ) {
  5843. // Ignore postFinder because it can't coexist with seed
  5844. i = preFilter && matcherOut.length;
  5845. while ( i-- ) {
  5846. if ( (elem = matcherOut[i]) ) {
  5847. seed[ preMap[i] ] = !(results[ preMap[i] ] = elem);
  5848. }
  5849. }
  5850. } else {
  5851. matcherOut = condense(
  5852. matcherOut === results ?
  5853. matcherOut.splice( preexisting, matcherOut.length ) :
  5854. matcherOut
  5855. );
  5856. if ( postFinder ) {
  5857. postFinder( null, results, matcherOut, xml );
  5858. } else {
  5859. push.apply( results, matcherOut );
  5860. }
  5861. }
  5862. });
  5863. }
  5864. function matcherFromTokens( tokens ) {
  5865. var checkContext, matcher, j,
  5866. len = tokens.length,
  5867. leadingRelative = Expr.relative[ tokens[0].type ],
  5868. implicitRelative = leadingRelative || Expr.relative[" "],
  5869. i = leadingRelative ? 1 : 0,
  5870. // The foundational matcher ensures that elements are reachable from top-level context(s)
  5871. matchContext = addCombinator( function( elem ) {
  5872. return elem === checkContext;
  5873. }, implicitRelative, true ),
  5874. matchAnyContext = addCombinator( function( elem ) {
  5875. return indexOf.call( checkContext, elem ) > -1;
  5876. }, implicitRelative, true ),
  5877. matchers = [ function( elem, context, xml ) {
  5878. return ( !leadingRelative && ( xml || context !== outermostContext ) ) || (
  5879. (checkContext = context).nodeType ?
  5880. matchContext( elem, context, xml ) :
  5881. matchAnyContext( elem, context, xml ) );
  5882. } ];
  5883. for ( ; i < len; i++ ) {
  5884. if ( (matcher = Expr.relative[ tokens[i].type ]) ) {
  5885. matchers = [ addCombinator( elementMatcher( matchers ), matcher ) ];
  5886. } else {
  5887. // The concatenated values are (context, xml) for backCompat
  5888. matcher = Expr.filter[ tokens[i].type ].apply( null, tokens[i].matches );
  5889. // Return special upon seeing a positional matcher
  5890. if ( matcher[ expando ] ) {
  5891. // Find the next relative operator (if any) for proper handling
  5892. j = ++i;
  5893. for ( ; j < len; j++ ) {
  5894. if ( Expr.relative[ tokens[j].type ] ) {
  5895. break;
  5896. }
  5897. }
  5898. return setMatcher(
  5899. i > 1 && elementMatcher( matchers ),
  5900. i > 1 && tokens.slice( 0, i - 1 ).join("").replace( rtrim, "$1" ),
  5901. matcher,
  5902. i < j && matcherFromTokens( tokens.slice( i, j ) ),
  5903. j < len && matcherFromTokens( (tokens = tokens.slice( j )) ),
  5904. j < len && tokens.join("")
  5905. );
  5906. }
  5907. matchers.push( matcher );
  5908. }
  5909. }
  5910. return elementMatcher( matchers );
  5911. }
  5912. function matcherFromGroupMatchers( elementMatchers, setMatchers ) {
  5913. var bySet = setMatchers.length > 0,
  5914. byElement = elementMatchers.length > 0,
  5915. superMatcher = function( seed, context, xml, results, expandContext ) {
  5916. var elem, j, matcher,
  5917. setMatched = [],
  5918. matchedCount = 0,
  5919. i = "0",
  5920. unmatched = seed && [],
  5921. outermost = expandContext != null,
  5922. contextBackup = outermostContext,
  5923. // We must always have either seed elements or context
  5924. elems = seed || byElement && Expr.find["TAG"]( "*", expandContext && context.parentNode || context ),
  5925. // Nested matchers should use non-integer dirruns
  5926. dirrunsUnique = (dirruns += contextBackup == null ? 1 : Math.E);
  5927. if ( outermost ) {
  5928. outermostContext = context !== document && context;
  5929. cachedruns = superMatcher.el;
  5930. }
  5931. // Add elements passing elementMatchers directly to results
  5932. for ( ; (elem = elems[i]) != null; i++ ) {
  5933. if ( byElement && elem ) {
  5934. for ( j = 0; (matcher = elementMatchers[j]); j++ ) {
  5935. if ( matcher( elem, context, xml ) ) {
  5936. results.push( elem );
  5937. break;
  5938. }
  5939. }
  5940. if ( outermost ) {
  5941. dirruns = dirrunsUnique;
  5942. cachedruns = ++superMatcher.el;
  5943. }
  5944. }
  5945. // Track unmatched elements for set filters
  5946. if ( bySet ) {
  5947. // They will have gone through all possible matchers
  5948. if ( (elem = !matcher && elem) ) {
  5949. matchedCount--;
  5950. }
  5951. // Lengthen the array for every element, matched or not
  5952. if ( seed ) {
  5953. unmatched.push( elem );
  5954. }
  5955. }
  5956. }
  5957. // Apply set filters to unmatched elements
  5958. matchedCount += i;
  5959. if ( bySet && i !== matchedCount ) {
  5960. for ( j = 0; (matcher = setMatchers[j]); j++ ) {
  5961. matcher( unmatched, setMatched, context, xml );
  5962. }
  5963. if ( seed ) {
  5964. // Reintegrate element matches to eliminate the need for sorting
  5965. if ( matchedCount > 0 ) {
  5966. while ( i-- ) {
  5967. if ( !(unmatched[i] || setMatched[i]) ) {
  5968. setMatched[i] = pop.call( results );
  5969. }
  5970. }
  5971. }
  5972. // Discard index placeholder values to get only actual matches
  5973. setMatched = condense( setMatched );
  5974. }
  5975. // Add matches to results
  5976. push.apply( results, setMatched );
  5977. // Seedless set matches succeeding multiple successful matchers stipulate sorting
  5978. if ( outermost && !seed && setMatched.length > 0 &&
  5979. ( matchedCount + setMatchers.length ) > 1 ) {
  5980. Sizzle.uniqueSort( results );
  5981. }
  5982. }
  5983. // Override manipulation of globals by nested matchers
  5984. if ( outermost ) {
  5985. dirruns = dirrunsUnique;
  5986. outermostContext = contextBackup;
  5987. }
  5988. return unmatched;
  5989. };
  5990. superMatcher.el = 0;
  5991. return bySet ?
  5992. markFunction( superMatcher ) :
  5993. superMatcher;
  5994. }
  5995. compile = Sizzle.compile = function( selector, group /* Internal Use Only */ ) {
  5996. var i,
  5997. setMatchers = [],
  5998. elementMatchers = [],
  5999. cached = compilerCache[ expando ][ selector ];
  6000. if ( !cached ) {
  6001. // Generate a function of recursive functions that can be used to check each element
  6002. if ( !group ) {
  6003. group = tokenize( selector );
  6004. }
  6005. i = group.length;
  6006. while ( i-- ) {
  6007. cached = matcherFromTokens( group[i] );
  6008. if ( cached[ expando ] ) {
  6009. setMatchers.push( cached );
  6010. } else {
  6011. elementMatchers.push( cached );
  6012. }
  6013. }
  6014. // Cache the compiled function
  6015. cached = compilerCache( selector, matcherFromGroupMatchers( elementMatchers, setMatchers ) );
  6016. }
  6017. return cached;
  6018. };
  6019. function multipleContexts( selector, contexts, results, seed ) {
  6020. var i = 0,
  6021. len = contexts.length;
  6022. for ( ; i < len; i++ ) {
  6023. Sizzle( selector, contexts[i], results, seed );
  6024. }
  6025. return results;
  6026. }
  6027. function select( selector, context, results, seed, xml ) {
  6028. var i, tokens, token, type, find,
  6029. match = tokenize( selector ),
  6030. j = match.length;
  6031. if ( !seed ) {
  6032. // Try to minimize operations if there is only one group
  6033. if ( match.length === 1 ) {
  6034. // Take a shortcut and set the context if the root selector is an ID
  6035. tokens = match[0] = match[0].slice( 0 );
  6036. if ( tokens.length > 2 && (token = tokens[0]).type === "ID" &&
  6037. context.nodeType === 9 && !xml &&
  6038. Expr.relative[ tokens[1].type ] ) {
  6039. context = Expr.find["ID"]( token.matches[0].replace( rbackslash, "" ), context, xml )[0];
  6040. if ( !context ) {
  6041. return results;
  6042. }
  6043. selector = selector.slice( tokens.shift().length );
  6044. }
  6045. // Fetch a seed set for right-to-left matching
  6046. for ( i = matchExpr["POS"].test( selector ) ? -1 : tokens.length - 1; i >= 0; i-- ) {
  6047. token = tokens[i];
  6048. // Abort if we hit a combinator
  6049. if ( Expr.relative[ (type = token.type) ] ) {
  6050. break;
  6051. }
  6052. if ( (find = Expr.find[ type ]) ) {
  6053. // Search, expanding context for leading sibling combinators
  6054. if ( (seed = find(
  6055. token.matches[0].replace( rbackslash, "" ),
  6056. rsibling.test( tokens[0].type ) && context.parentNode || context,
  6057. xml
  6058. )) ) {
  6059. // If seed is empty or no tokens remain, we can return early
  6060. tokens.splice( i, 1 );
  6061. selector = seed.length && tokens.join("");
  6062. if ( !selector ) {
  6063. push.apply( results, slice.call( seed, 0 ) );
  6064. return results;
  6065. }
  6066. break;
  6067. }
  6068. }
  6069. }
  6070. }
  6071. }
  6072. // Compile and execute a filtering function
  6073. // Provide `match` to avoid retokenization if we modified the selector above
  6074. compile( selector, match )(
  6075. seed,
  6076. context,
  6077. xml,
  6078. results,
  6079. rsibling.test( selector )
  6080. );
  6081. return results;
  6082. }
  6083. if ( document.querySelectorAll ) {
  6084. (function() {
  6085. var disconnectedMatch,
  6086. oldSelect = select,
  6087. rescape = /'|\\/g,
  6088. rattributeQuotes = /\=[\x20\t\r\n\f]*([^'"\]]*)[\x20\t\r\n\f]*\]/g,
  6089. // qSa(:focus) reports false when true (Chrome 21),
  6090. // A support test would require too much code (would include document ready)
  6091. rbuggyQSA = [":focus"],
  6092. // matchesSelector(:focus) reports false when true (Chrome 21),
  6093. // matchesSelector(:active) reports false when true (IE9/Opera 11.5)
  6094. // A support test would require too much code (would include document ready)
  6095. // just skip matchesSelector for :active
  6096. rbuggyMatches = [ ":active", ":focus" ],
  6097. matches = docElem.matchesSelector ||
  6098. docElem.mozMatchesSelector ||
  6099. docElem.webkitMatchesSelector ||
  6100. docElem.oMatchesSelector ||
  6101. docElem.msMatchesSelector;
  6102. // Build QSA regex
  6103. // Regex strategy adopted from Diego Perini
  6104. assert(function( div ) {
  6105. // Select is set to empty string on purpose
  6106. // This is to test IE's treatment of not explictly
  6107. // setting a boolean content attribute,
  6108. // since its presence should be enough
  6109. // http://bugs.jquery.com/ticket/12359
  6110. div.innerHTML = "<select><option selected=''></option></select>";
  6111. // IE8 - Some boolean attributes are not treated correctly
  6112. if ( !div.querySelectorAll("[selected]").length ) {
  6113. rbuggyQSA.push( "\\[" + whitespace + "*(?:checked|disabled|ismap|multiple|readonly|selected|value)" );
  6114. }
  6115. // Webkit/Opera - :checked should return selected option elements
  6116. // http://www.w3.org/TR/2011/REC-css3-selectors-20110929/#checked
  6117. // IE8 throws error here (do not put tests after this one)
  6118. if ( !div.querySelectorAll(":checked").length ) {
  6119. rbuggyQSA.push(":checked");
  6120. }
  6121. });
  6122. assert(function( div ) {
  6123. // Opera 10-12/IE9 - ^= $= *= and empty values
  6124. // Should not select anything
  6125. div.innerHTML = "<p test=''></p>";
  6126. if ( div.querySelectorAll("[test^='']").length ) {
  6127. rbuggyQSA.push( "[*^$]=" + whitespace + "*(?:\"\"|'')" );
  6128. }
  6129. // FF 3.5 - :enabled/:disabled and hidden elements (hidden elements are still enabled)
  6130. // IE8 throws error here (do not put tests after this one)
  6131. div.innerHTML = "<input type='hidden'/>";
  6132. if ( !div.querySelectorAll(":enabled").length ) {
  6133. rbuggyQSA.push(":enabled", ":disabled");
  6134. }
  6135. });
  6136. // rbuggyQSA always contains :focus, so no need for a length check
  6137. rbuggyQSA = /* rbuggyQSA.length && */ new RegExp( rbuggyQSA.join("|") );
  6138. select = function( selector, context, results, seed, xml ) {
  6139. // Only use querySelectorAll when not filtering,
  6140. // when this is not xml,
  6141. // and when no QSA bugs apply
  6142. if ( !seed && !xml && (!rbuggyQSA || !rbuggyQSA.test( selector )) ) {
  6143. var groups, i,
  6144. old = true,
  6145. nid = expando,
  6146. newContext = context,
  6147. newSelector = context.nodeType === 9 && selector;
  6148. // qSA works strangely on Element-rooted queries
  6149. // We can work around this by specifying an extra ID on the root
  6150. // and working up from there (Thanks to Andrew Dupont for the technique)
  6151. // IE 8 doesn't work on object elements
  6152. if ( context.nodeType === 1 && context.nodeName.toLowerCase() !== "object" ) {
  6153. groups = tokenize( selector );
  6154. if ( (old = context.getAttribute("id")) ) {
  6155. nid = old.replace( rescape, "\\$&" );
  6156. } else {
  6157. context.setAttribute( "id", nid );
  6158. }
  6159. nid = "[id='" + nid + "'] ";
  6160. i = groups.length;
  6161. while ( i-- ) {
  6162. groups[i] = nid + groups[i].join("");
  6163. }
  6164. newContext = rsibling.test( selector ) && context.parentNode || context;
  6165. newSelector = groups.join(",");
  6166. }
  6167. if ( newSelector ) {
  6168. try {
  6169. push.apply( results, slice.call( newContext.querySelectorAll(
  6170. newSelector
  6171. ), 0 ) );
  6172. return results;
  6173. } catch(qsaError) {
  6174. } finally {
  6175. if ( !old ) {
  6176. context.removeAttribute("id");
  6177. }
  6178. }
  6179. }
  6180. }
  6181. return oldSelect( selector, context, results, seed, xml );
  6182. };
  6183. if ( matches ) {
  6184. assert(function( div ) {
  6185. // Check to see if it's possible to do matchesSelector
  6186. // on a disconnected node (IE 9)
  6187. disconnectedMatch = matches.call( div, "div" );
  6188. // This should fail with an exception
  6189. // Gecko does not error, returns false instead
  6190. try {
  6191. matches.call( div, "[test!='']:sizzle" );
  6192. rbuggyMatches.push( "!=", pseudos );
  6193. } catch ( e ) {}
  6194. });
  6195. // rbuggyMatches always contains :active and :focus, so no need for a length check
  6196. rbuggyMatches = /* rbuggyMatches.length && */ new RegExp( rbuggyMatches.join("|") );
  6197. Sizzle.matchesSelector = function( elem, expr ) {
  6198. // Make sure that attribute selectors are quoted
  6199. expr = expr.replace( rattributeQuotes, "='$1']" );
  6200. // rbuggyMatches always contains :active, so no need for an existence check
  6201. if ( !isXML( elem ) && !rbuggyMatches.test( expr ) && (!rbuggyQSA || !rbuggyQSA.test( expr )) ) {
  6202. try {
  6203. var ret = matches.call( elem, expr );
  6204. // IE 9's matchesSelector returns false on disconnected nodes
  6205. if ( ret || disconnectedMatch ||
  6206. // As well, disconnected nodes are said to be in a document
  6207. // fragment in IE 9
  6208. elem.document && elem.document.nodeType !== 11 ) {
  6209. return ret;
  6210. }
  6211. } catch(e) {}
  6212. }
  6213. return Sizzle( expr, null, null, [ elem ] ).length > 0;
  6214. };
  6215. }
  6216. })();
  6217. }
  6218. // Deprecated
  6219. Expr.pseudos["nth"] = Expr.pseudos["eq"];
  6220. // Back-compat
  6221. function setFilters() {}
  6222. Expr.filters = setFilters.prototype = Expr.pseudos;
  6223. Expr.setFilters = new setFilters();
  6224. // Override sizzle attribute retrieval
  6225. Sizzle.attr = jQuery.attr;
  6226. jQuery.find = Sizzle;
  6227. jQuery.expr = Sizzle.selectors;
  6228. jQuery.expr[":"] = jQuery.expr.pseudos;
  6229. jQuery.unique = Sizzle.uniqueSort;
  6230. jQuery.text = Sizzle.getText;
  6231. jQuery.isXMLDoc = Sizzle.isXML;
  6232. jQuery.contains = Sizzle.contains;
  6233. })( window );
  6234. var runtil = /Until$/,
  6235. rparentsprev = /^(?:parents|prev(?:Until|All))/,
  6236. isSimple = /^.[^:#\[\.,]*$/,
  6237. rneedsContext = jQuery.expr.match.needsContext,
  6238. // methods guaranteed to produce a unique set when starting from a unique set
  6239. guaranteedUnique = {
  6240. children: true,
  6241. contents: true,
  6242. next: true,
  6243. prev: true
  6244. };
  6245. jQuery.fn.extend({
  6246. find: function( selector ) {
  6247. var i, l, length, n, r, ret,
  6248. self = this;
  6249. if ( typeof selector !== "string" ) {
  6250. return jQuery( selector ).filter(function() {
  6251. for ( i = 0, l = self.length; i < l; i++ ) {
  6252. if ( jQuery.contains( self[ i ], this ) ) {
  6253. return true;
  6254. }
  6255. }
  6256. });
  6257. }
  6258. ret = this.pushStack( "", "find", selector );
  6259. for ( i = 0, l = this.length; i < l; i++ ) {
  6260. length = ret.length;
  6261. jQuery.find( selector, this[i], ret );
  6262. if ( i > 0 ) {
  6263. // Make sure that the results are unique
  6264. for ( n = length; n < ret.length; n++ ) {
  6265. for ( r = 0; r < length; r++ ) {
  6266. if ( ret[r] === ret[n] ) {
  6267. ret.splice(n--, 1);
  6268. break;
  6269. }
  6270. }
  6271. }
  6272. }
  6273. }
  6274. return ret;
  6275. },
  6276. has: function( target ) {
  6277. var i,
  6278. targets = jQuery( target, this ),
  6279. len = targets.length;
  6280. return this.filter(function() {
  6281. for ( i = 0; i < len; i++ ) {
  6282. if ( jQuery.contains( this, targets[i] ) ) {
  6283. return true;
  6284. }
  6285. }
  6286. });
  6287. },
  6288. not: function( selector ) {
  6289. return this.pushStack( winnow(this, selector, false), "not", selector);
  6290. },
  6291. filter: function( selector ) {
  6292. return this.pushStack( winnow(this, selector, true), "filter", selector );
  6293. },
  6294. is: function( selector ) {
  6295. return !!selector && (
  6296. typeof selector === "string" ?
  6297. // If this is a positional/relative selector, check membership in the returned set
  6298. // so $("p:first").is("p:last") won't return true for a doc with two "p".
  6299. rneedsContext.test( selector ) ?
  6300. jQuery( selector, this.context ).index( this[0] ) >= 0 :
  6301. jQuery.filter( selector, this ).length > 0 :
  6302. this.filter( selector ).length > 0 );
  6303. },
  6304. closest: function( selectors, context ) {
  6305. var cur,
  6306. i = 0,
  6307. l = this.length,
  6308. ret = [],
  6309. pos = rneedsContext.test( selectors ) || typeof selectors !== "string" ?
  6310. jQuery( selectors, context || this.context ) :
  6311. 0;
  6312. for ( ; i < l; i++ ) {
  6313. cur = this[i];
  6314. while ( cur && cur.ownerDocument && cur !== context && cur.nodeType !== 11 ) {
  6315. if ( pos ? pos.index(cur) > -1 : jQuery.find.matchesSelector(cur, selectors) ) {
  6316. ret.push( cur );
  6317. break;
  6318. }
  6319. cur = cur.parentNode;
  6320. }
  6321. }
  6322. ret = ret.length > 1 ? jQuery.unique( ret ) : ret;
  6323. return this.pushStack( ret, "closest", selectors );
  6324. },
  6325. // Determine the position of an element within
  6326. // the matched set of elements
  6327. index: function( elem ) {
  6328. // No argument, return index in parent
  6329. if ( !elem ) {
  6330. return ( this[0] && this[0].parentNode ) ? this.prevAll().length : -1;
  6331. }
  6332. // index in selector
  6333. if ( typeof elem === "string" ) {
  6334. return jQuery.inArray( this[0], jQuery( elem ) );
  6335. }
  6336. // Locate the position of the desired element
  6337. return jQuery.inArray(
  6338. // If it receives a jQuery object, the first element is used
  6339. elem.jquery ? elem[0] : elem, this );
  6340. },
  6341. add: function( selector, context ) {
  6342. var set = typeof selector === "string" ?
  6343. jQuery( selector, context ) :
  6344. jQuery.makeArray( selector && selector.nodeType ? [ selector ] : selector ),
  6345. all = jQuery.merge( this.get(), set );
  6346. return this.pushStack( isDisconnected( set[0] ) || isDisconnected( all[0] ) ?
  6347. all :
  6348. jQuery.unique( all ) );
  6349. },
  6350. addBack: function( selector ) {
  6351. return this.add( selector == null ?
  6352. this.prevObject : this.prevObject.filter(selector)
  6353. );
  6354. }
  6355. });
  6356. jQuery.fn.andSelf = jQuery.fn.addBack;
  6357. // A painfully simple check to see if an element is disconnected
  6358. // from a document (should be improved, where feasible).
  6359. function isDisconnected( node ) {
  6360. return !node || !node.parentNode || node.parentNode.nodeType === 11;
  6361. }
  6362. function sibling( cur, dir ) {
  6363. do {
  6364. cur = cur[ dir ];
  6365. } while ( cur && cur.nodeType !== 1 );
  6366. return cur;
  6367. }
  6368. jQuery.each({
  6369. parent: function( elem ) {
  6370. var parent = elem.parentNode;
  6371. return parent && parent.nodeType !== 11 ? parent : null;
  6372. },
  6373. parents: function( elem ) {
  6374. return jQuery.dir( elem, "parentNode" );
  6375. },
  6376. parentsUntil: function( elem, i, until ) {
  6377. return jQuery.dir( elem, "parentNode", until );
  6378. },
  6379. next: function( elem ) {
  6380. return sibling( elem, "nextSibling" );
  6381. },
  6382. prev: function( elem ) {
  6383. return sibling( elem, "previousSibling" );
  6384. },
  6385. nextAll: function( elem ) {
  6386. return jQuery.dir( elem, "nextSibling" );
  6387. },
  6388. prevAll: function( elem ) {
  6389. return jQuery.dir( elem, "previousSibling" );
  6390. },
  6391. nextUntil: function( elem, i, until ) {
  6392. return jQuery.dir( elem, "nextSibling", until );
  6393. },
  6394. prevUntil: function( elem, i, until ) {
  6395. return jQuery.dir( elem, "previousSibling", until );
  6396. },
  6397. siblings: function( elem ) {
  6398. return jQuery.sibling( ( elem.parentNode || {} ).firstChild, elem );
  6399. },
  6400. children: function( elem ) {
  6401. return jQuery.sibling( elem.firstChild );
  6402. },
  6403. contents: function( elem ) {
  6404. return jQuery.nodeName( elem, "iframe" ) ?
  6405. elem.contentDocument || elem.contentWindow.document :
  6406. jQuery.merge( [], elem.childNodes );
  6407. }
  6408. }, function( name, fn ) {
  6409. jQuery.fn[ name ] = function( until, selector ) {
  6410. var ret = jQuery.map( this, fn, until );
  6411. if ( !runtil.test( name ) ) {
  6412. selector = until;
  6413. }
  6414. if ( selector && typeof selector === "string" ) {
  6415. ret = jQuery.filter( selector, ret );
  6416. }
  6417. ret = this.length > 1 && !guaranteedUnique[ name ] ? jQuery.unique( ret ) : ret;
  6418. if ( this.length > 1 && rparentsprev.test( name ) ) {
  6419. ret = ret.reverse();
  6420. }
  6421. return this.pushStack( ret, name, core_slice.call( arguments ).join(",") );
  6422. };
  6423. });
  6424. jQuery.extend({
  6425. filter: function( expr, elems, not ) {
  6426. if ( not ) {
  6427. expr = ":not(" + expr + ")";
  6428. }
  6429. return elems.length === 1 ?
  6430. jQuery.find.matchesSelector(elems[0], expr) ? [ elems[0] ] : [] :
  6431. jQuery.find.matches(expr, elems);
  6432. },
  6433. dir: function( elem, dir, until ) {
  6434. var matched = [],
  6435. cur = elem[ dir ];
  6436. while ( cur && cur.nodeType !== 9 && (until === undefined || cur.nodeType !== 1 || !jQuery( cur ).is( until )) ) {
  6437. if ( cur.nodeType === 1 ) {
  6438. matched.push( cur );
  6439. }
  6440. cur = cur[dir];
  6441. }
  6442. return matched;
  6443. },
  6444. sibling: function( n, elem ) {
  6445. var r = [];
  6446. for ( ; n; n = n.nextSibling ) {
  6447. if ( n.nodeType === 1 && n !== elem ) {
  6448. r.push( n );
  6449. }
  6450. }
  6451. return r;
  6452. }
  6453. });
  6454. // Implement the identical functionality for filter and not
  6455. function winnow( elements, qualifier, keep ) {
  6456. // Can't pass null or undefined to indexOf in Firefox 4
  6457. // Set to 0 to skip string check
  6458. qualifier = qualifier || 0;
  6459. if ( jQuery.isFunction( qualifier ) ) {
  6460. return jQuery.grep(elements, function( elem, i ) {
  6461. var retVal = !!qualifier.call( elem, i, elem );
  6462. return retVal === keep;
  6463. });
  6464. } else if ( qualifier.nodeType ) {
  6465. return jQuery.grep(elements, function( elem, i ) {
  6466. return ( elem === qualifier ) === keep;
  6467. });
  6468. } else if ( typeof qualifier === "string" ) {
  6469. var filtered = jQuery.grep(elements, function( elem ) {
  6470. return elem.nodeType === 1;
  6471. });
  6472. if ( isSimple.test( qualifier ) ) {
  6473. return jQuery.filter(qualifier, filtered, !keep);
  6474. } else {
  6475. qualifier = jQuery.filter( qualifier, filtered );
  6476. }
  6477. }
  6478. return jQuery.grep(elements, function( elem, i ) {
  6479. return ( jQuery.inArray( elem, qualifier ) >= 0 ) === keep;
  6480. });
  6481. }
  6482. function createSafeFragment( document ) {
  6483. var list = nodeNames.split( "|" ),
  6484. safeFrag = document.createDocumentFragment();
  6485. if ( safeFrag.createElement ) {
  6486. while ( list.length ) {
  6487. safeFrag.createElement(
  6488. list.pop()
  6489. );
  6490. }
  6491. }
  6492. return safeFrag;
  6493. }
  6494. var nodeNames = "abbr|article|aside|audio|bdi|canvas|data|datalist|details|figcaption|figure|footer|" +
  6495. "header|hgroup|mark|meter|nav|output|progress|section|summary|time|video",
  6496. rinlinejQuery = / jQuery\d+="(?:null|\d+)"/g,
  6497. rleadingWhitespace = /^\s+/,
  6498. rxhtmlTag = /<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/gi,
  6499. rtagName = /<([\w:]+)/,
  6500. rtbody = /<tbody/i,
  6501. rhtml = /<|&#?\w+;/,
  6502. rnoInnerhtml = /<(?:script|style|link)/i,
  6503. rnocache = /<(?:script|object|embed|option|style)/i,
  6504. rnoshimcache = new RegExp("<(?:" + nodeNames + ")[\\s/>]", "i"),
  6505. rcheckableType = /^(?:checkbox|radio)$/,
  6506. // checked="checked" or checked
  6507. rchecked = /checked\s*(?:[^=]|=\s*.checked.)/i,
  6508. rscriptType = /\/(java|ecma)script/i,
  6509. rcleanScript = /^\s*<!(?:\[CDATA\[|\-\-)|[\]\-]{2}>\s*$/g,
  6510. wrapMap = {
  6511. option: [ 1, "<select multiple='multiple'>", "</select>" ],
  6512. legend: [ 1, "<fieldset>", "</fieldset>" ],
  6513. thead: [ 1, "<table>", "</table>" ],
  6514. tr: [ 2, "<table><tbody>", "</tbody></table>" ],
  6515. td: [ 3, "<table><tbody><tr>", "</tr></tbody></table>" ],
  6516. col: [ 2, "<table><tbody></tbody><colgroup>", "</colgroup></table>" ],
  6517. area: [ 1, "<map>", "</map>" ],
  6518. _default: [ 0, "", "" ]
  6519. },
  6520. safeFragment = createSafeFragment( document ),
  6521. fragmentDiv = safeFragment.appendChild( document.createElement("div") );
  6522. wrapMap.optgroup = wrapMap.option;
  6523. wrapMap.tbody = wrapMap.tfoot = wrapMap.colgroup = wrapMap.caption = wrapMap.thead;
  6524. wrapMap.th = wrapMap.td;
  6525. // IE6-8 can't serialize link, script, style, or any html5 (NoScope) tags,
  6526. // unless wrapped in a div with non-breaking characters in front of it.
  6527. if ( !jQuery.support.htmlSerialize ) {
  6528. wrapMap._default = [ 1, "X<div>", "</div>" ];
  6529. }
  6530. jQuery.fn.extend({
  6531. text: function( value ) {
  6532. return jQuery.access( this, function( value ) {
  6533. return value === undefined ?
  6534. jQuery.text( this ) :
  6535. this.empty().append( ( this[0] && this[0].ownerDocument || document ).createTextNode( value ) );
  6536. }, null, value, arguments.length );
  6537. },
  6538. wrapAll: function( html ) {
  6539. if ( jQuery.isFunction( html ) ) {
  6540. return this.each(function(i) {
  6541. jQuery(this).wrapAll( html.call(this, i) );
  6542. });
  6543. }
  6544. if ( this[0] ) {
  6545. // The elements to wrap the target around
  6546. var wrap = jQuery( html, this[0].ownerDocument ).eq(0).clone(true);
  6547. if ( this[0].parentNode ) {
  6548. wrap.insertBefore( this[0] );
  6549. }
  6550. wrap.map(function() {
  6551. var elem = this;
  6552. while ( elem.firstChild && elem.firstChild.nodeType === 1 ) {
  6553. elem = elem.firstChild;
  6554. }
  6555. return elem;
  6556. }).append( this );
  6557. }
  6558. return this;
  6559. },
  6560. wrapInner: function( html ) {
  6561. if ( jQuery.isFunction( html ) ) {
  6562. return this.each(function(i) {
  6563. jQuery(this).wrapInner( html.call(this, i) );
  6564. });
  6565. }
  6566. return this.each(function() {
  6567. var self = jQuery( this ),
  6568. contents = self.contents();
  6569. if ( contents.length ) {
  6570. contents.wrapAll( html );
  6571. } else {
  6572. self.append( html );
  6573. }
  6574. });
  6575. },
  6576. wrap: function( html ) {
  6577. var isFunction = jQuery.isFunction( html );
  6578. return this.each(function(i) {
  6579. jQuery( this ).wrapAll( isFunction ? html.call(this, i) : html );
  6580. });
  6581. },
  6582. unwrap: function() {
  6583. return this.parent().each(function() {
  6584. if ( !jQuery.nodeName( this, "body" ) ) {
  6585. jQuery( this ).replaceWith( this.childNodes );
  6586. }
  6587. }).end();
  6588. },
  6589. append: function() {
  6590. return this.domManip(arguments, true, function( elem ) {
  6591. if ( this.nodeType === 1 || this.nodeType === 11 ) {
  6592. this.appendChild( elem );
  6593. }
  6594. });
  6595. },
  6596. prepend: function() {
  6597. return this.domManip(arguments, true, function( elem ) {
  6598. if ( this.nodeType === 1 || this.nodeType === 11 ) {
  6599. this.insertBefore( elem, this.firstChild );
  6600. }
  6601. });
  6602. },
  6603. before: function() {
  6604. if ( !isDisconnected( this[0] ) ) {
  6605. return this.domManip(arguments, false, function( elem ) {
  6606. this.parentNode.insertBefore( elem, this );
  6607. });
  6608. }
  6609. if ( arguments.length ) {
  6610. var set = jQuery.clean( arguments );
  6611. return this.pushStack( jQuery.merge( set, this ), "before", this.selector );
  6612. }
  6613. },
  6614. after: function() {
  6615. if ( !isDisconnected( this[0] ) ) {
  6616. return this.domManip(arguments, false, function( elem ) {
  6617. this.parentNode.insertBefore( elem, this.nextSibling );
  6618. });
  6619. }
  6620. if ( arguments.length ) {
  6621. var set = jQuery.clean( arguments );
  6622. return this.pushStack( jQuery.merge( this, set ), "after", this.selector );
  6623. }
  6624. },
  6625. // keepData is for internal use only--do not document
  6626. remove: function( selector, keepData ) {
  6627. var elem,
  6628. i = 0;
  6629. for ( ; (elem = this[i]) != null; i++ ) {
  6630. if ( !selector || jQuery.filter( selector, [ elem ] ).length ) {
  6631. if ( !keepData && elem.nodeType === 1 ) {
  6632. jQuery.cleanData( elem.getElementsByTagName("*") );
  6633. jQuery.cleanData( [ elem ] );
  6634. }
  6635. if ( elem.parentNode ) {
  6636. elem.parentNode.removeChild( elem );
  6637. }
  6638. }
  6639. }
  6640. return this;
  6641. },
  6642. empty: function() {
  6643. var elem,
  6644. i = 0;
  6645. for ( ; (elem = this[i]) != null; i++ ) {
  6646. // Remove element nodes and prevent memory leaks
  6647. if ( elem.nodeType === 1 ) {
  6648. jQuery.cleanData( elem.getElementsByTagName("*") );
  6649. }
  6650. // Remove any remaining nodes
  6651. while ( elem.firstChild ) {
  6652. elem.removeChild( elem.firstChild );
  6653. }
  6654. }
  6655. return this;
  6656. },
  6657. clone: function( dataAndEvents, deepDataAndEvents ) {
  6658. dataAndEvents = dataAndEvents == null ? false : dataAndEvents;
  6659. deepDataAndEvents = deepDataAndEvents == null ? dataAndEvents : deepDataAndEvents;
  6660. return this.map( function () {
  6661. return jQuery.clone( this, dataAndEvents, deepDataAndEvents );
  6662. });
  6663. },
  6664. html: function( value ) {
  6665. return jQuery.access( this, function( value ) {
  6666. var elem = this[0] || {},
  6667. i = 0,
  6668. l = this.length;
  6669. if ( value === undefined ) {
  6670. return elem.nodeType === 1 ?
  6671. elem.innerHTML.replace( rinlinejQuery, "" ) :
  6672. undefined;
  6673. }
  6674. // See if we can take a shortcut and just use innerHTML
  6675. if ( typeof value === "string" && !rnoInnerhtml.test( value ) &&
  6676. ( jQuery.support.htmlSerialize || !rnoshimcache.test( value ) ) &&
  6677. ( jQuery.support.leadingWhitespace || !rleadingWhitespace.test( value ) ) &&
  6678. !wrapMap[ ( rtagName.exec( value ) || ["", ""] )[1].toLowerCase() ] ) {
  6679. value = value.replace( rxhtmlTag, "<$1></$2>" );
  6680. try {
  6681. for (; i < l; i++ ) {
  6682. // Remove element nodes and prevent memory leaks
  6683. elem = this[i] || {};
  6684. if ( elem.nodeType === 1 ) {
  6685. jQuery.cleanData( elem.getElementsByTagName( "*" ) );
  6686. elem.innerHTML = value;
  6687. }
  6688. }
  6689. elem = 0;
  6690. // If using innerHTML throws an exception, use the fallback method
  6691. } catch(e) {}
  6692. }
  6693. if ( elem ) {
  6694. this.empty().append( value );
  6695. }
  6696. }, null, value, arguments.length );
  6697. },
  6698. replaceWith: function( value ) {
  6699. if ( !isDisconnected( this[0] ) ) {
  6700. // Make sure that the elements are removed from the DOM before they are inserted
  6701. // this can help fix replacing a parent with child elements
  6702. if ( jQuery.isFunction( value ) ) {
  6703. return this.each(function(i) {
  6704. var self = jQuery(this), old = self.html();
  6705. self.replaceWith( value.call( this, i, old ) );
  6706. });
  6707. }
  6708. if ( typeof value !== "string" ) {
  6709. value = jQuery( value ).detach();
  6710. }
  6711. return this.each(function() {
  6712. var next = this.nextSibling,
  6713. parent = this.parentNode;
  6714. jQuery( this ).remove();
  6715. if ( next ) {
  6716. jQuery(next).before( value );
  6717. } else {
  6718. jQuery(parent).append( value );
  6719. }
  6720. });
  6721. }
  6722. return this.length ?
  6723. this.pushStack( jQuery(jQuery.isFunction(value) ? value() : value), "replaceWith", value ) :
  6724. this;
  6725. },
  6726. detach: function( selector ) {
  6727. return this.remove( selector, true );
  6728. },
  6729. domManip: function( args, table, callback ) {
  6730. // Flatten any nested arrays
  6731. args = [].concat.apply( [], args );
  6732. var results, first, fragment, iNoClone,
  6733. i = 0,
  6734. value = args[0],
  6735. scripts = [],
  6736. l = this.length;
  6737. // We can't cloneNode fragments that contain checked, in WebKit
  6738. if ( !jQuery.support.checkClone && l > 1 && typeof value === "string" && rchecked.test( value ) ) {
  6739. return this.each(function() {
  6740. jQuery(this).domManip( args, table, callback );
  6741. });
  6742. }
  6743. if ( jQuery.isFunction(value) ) {
  6744. return this.each(function(i) {
  6745. var self = jQuery(this);
  6746. args[0] = value.call( this, i, table ? self.html() : undefined );
  6747. self.domManip( args, table, callback );
  6748. });
  6749. }
  6750. if ( this[0] ) {
  6751. results = jQuery.buildFragment( args, this, scripts );
  6752. fragment = results.fragment;
  6753. first = fragment.firstChild;
  6754. if ( fragment.childNodes.length === 1 ) {
  6755. fragment = first;
  6756. }
  6757. if ( first ) {
  6758. table = table && jQuery.nodeName( first, "tr" );
  6759. // Use the original fragment for the last item instead of the first because it can end up
  6760. // being emptied incorrectly in certain situations (#8070).
  6761. // Fragments from the fragment cache must always be cloned and never used in place.
  6762. for ( iNoClone = results.cacheable || l - 1; i < l; i++ ) {
  6763. callback.call(
  6764. table && jQuery.nodeName( this[i], "table" ) ?
  6765. findOrAppend( this[i], "tbody" ) :
  6766. this[i],
  6767. i === iNoClone ?
  6768. fragment :
  6769. jQuery.clone( fragment, true, true )
  6770. );
  6771. }
  6772. }
  6773. // Fix #11809: Avoid leaking memory
  6774. fragment = first = null;
  6775. if ( scripts.length ) {
  6776. jQuery.each( scripts, function( i, elem ) {
  6777. if ( elem.src ) {
  6778. if ( jQuery.ajax ) {
  6779. jQuery.ajax({
  6780. url: elem.src,
  6781. type: "GET",
  6782. dataType: "script",
  6783. async: false,
  6784. global: false,
  6785. "throws": true
  6786. });
  6787. } else {
  6788. jQuery.error("no ajax");
  6789. }
  6790. } else {
  6791. jQuery.globalEval( ( elem.text || elem.textContent || elem.innerHTML || "" ).replace( rcleanScript, "" ) );
  6792. }
  6793. if ( elem.parentNode ) {
  6794. elem.parentNode.removeChild( elem );
  6795. }
  6796. });
  6797. }
  6798. }
  6799. return this;
  6800. }
  6801. });
  6802. function findOrAppend( elem, tag ) {
  6803. return elem.getElementsByTagName( tag )[0] || elem.appendChild( elem.ownerDocument.createElement( tag ) );
  6804. }
  6805. function cloneCopyEvent( src, dest ) {
  6806. if ( dest.nodeType !== 1 || !jQuery.hasData( src ) ) {
  6807. return;
  6808. }
  6809. var type, i, l,
  6810. oldData = jQuery._data( src ),
  6811. curData = jQuery._data( dest, oldData ),
  6812. events = oldData.events;
  6813. if ( events ) {
  6814. delete curData.handle;
  6815. curData.events = {};
  6816. for ( type in events ) {
  6817. for ( i = 0, l = events[ type ].length; i < l; i++ ) {
  6818. jQuery.event.add( dest, type, events[ type ][ i ] );
  6819. }
  6820. }
  6821. }
  6822. // make the cloned public data object a copy from the original
  6823. if ( curData.data ) {
  6824. curData.data = jQuery.extend( {}, curData.data );
  6825. }
  6826. }
  6827. function cloneFixAttributes( src, dest ) {
  6828. var nodeName;
  6829. // We do not need to do anything for non-Elements
  6830. if ( dest.nodeType !== 1 ) {
  6831. return;
  6832. }
  6833. // clearAttributes removes the attributes, which we don't want,
  6834. // but also removes the attachEvent events, which we *do* want
  6835. if ( dest.clearAttributes ) {
  6836. dest.clearAttributes();
  6837. }
  6838. // mergeAttributes, in contrast, only merges back on the
  6839. // original attributes, not the events
  6840. if ( dest.mergeAttributes ) {
  6841. dest.mergeAttributes( src );
  6842. }
  6843. nodeName = dest.nodeName.toLowerCase();
  6844. if ( nodeName === "object" ) {
  6845. // IE6-10 improperly clones children of object elements using classid.
  6846. // IE10 throws NoModificationAllowedError if parent is null, #12132.
  6847. if ( dest.parentNode ) {
  6848. dest.outerHTML = src.outerHTML;
  6849. }
  6850. // This path appears unavoidable for IE9. When cloning an object
  6851. // element in IE9, the outerHTML strategy above is not sufficient.
  6852. // If the src has innerHTML and the destination does not,
  6853. // copy the src.innerHTML into the dest.innerHTML. #10324
  6854. if ( jQuery.support.html5Clone && (src.innerHTML && !jQuery.trim(dest.innerHTML)) ) {
  6855. dest.innerHTML = src.innerHTML;
  6856. }
  6857. } else if ( nodeName === "input" && rcheckableType.test( src.type ) ) {
  6858. // IE6-8 fails to persist the checked state of a cloned checkbox
  6859. // or radio button. Worse, IE6-7 fail to give the cloned element
  6860. // a checked appearance if the defaultChecked value isn't also set
  6861. dest.defaultChecked = dest.checked = src.checked;
  6862. // IE6-7 get confused and end up setting the value of a cloned
  6863. // checkbox/radio button to an empty string instead of "on"
  6864. if ( dest.value !== src.value ) {
  6865. dest.value = src.value;
  6866. }
  6867. // IE6-8 fails to return the selected option to the default selected
  6868. // state when cloning options
  6869. } else if ( nodeName === "option" ) {
  6870. dest.selected = src.defaultSelected;
  6871. // IE6-8 fails to set the defaultValue to the correct value when
  6872. // cloning other types of input fields
  6873. } else if ( nodeName === "input" || nodeName === "textarea" ) {
  6874. dest.defaultValue = src.defaultValue;
  6875. // IE blanks contents when cloning scripts
  6876. } else if ( nodeName === "script" && dest.text !== src.text ) {
  6877. dest.text = src.text;
  6878. }
  6879. // Event data gets referenced instead of copied if the expando
  6880. // gets copied too
  6881. dest.removeAttribute( jQuery.expando );
  6882. }
  6883. jQuery.buildFragment = function( args, context, scripts ) {
  6884. var fragment, cacheable, cachehit,
  6885. first = args[ 0 ];
  6886. // Set context from what may come in as undefined or a jQuery collection or a node
  6887. // Updated to fix #12266 where accessing context[0] could throw an exception in IE9/10 &
  6888. // also doubles as fix for #8950 where plain objects caused createDocumentFragment exception
  6889. context = context || document;
  6890. context = !context.nodeType && context[0] || context;
  6891. context = context.ownerDocument || context;
  6892. // Only cache "small" (1/2 KB) HTML strings that are associated with the main document
  6893. // Cloning options loses the selected state, so don't cache them
  6894. // IE 6 doesn't like it when you put <object> or <embed> elements in a fragment
  6895. // Also, WebKit does not clone 'checked' attributes on cloneNode, so don't cache
  6896. // Lastly, IE6,7,8 will not correctly reuse cached fragments that were created from unknown elems #10501
  6897. if ( args.length === 1 && typeof first === "string" && first.length < 512 && context === document &&
  6898. first.charAt(0) === "<" && !rnocache.test( first ) &&
  6899. (jQuery.support.checkClone || !rchecked.test( first )) &&
  6900. (jQuery.support.html5Clone || !rnoshimcache.test( first )) ) {
  6901. // Mark cacheable and look for a hit
  6902. cacheable = true;
  6903. fragment = jQuery.fragments[ first ];
  6904. cachehit = fragment !== undefined;
  6905. }
  6906. if ( !fragment ) {
  6907. fragment = context.createDocumentFragment();
  6908. jQuery.clean( args, context, fragment, scripts );
  6909. // Update the cache, but only store false
  6910. // unless this is a second parsing of the same content
  6911. if ( cacheable ) {
  6912. jQuery.fragments[ first ] = cachehit && fragment;
  6913. }
  6914. }
  6915. return { fragment: fragment, cacheable: cacheable };
  6916. };
  6917. jQuery.fragments = {};
  6918. jQuery.each({
  6919. appendTo: "append",
  6920. prependTo: "prepend",
  6921. insertBefore: "before",
  6922. insertAfter: "after",
  6923. replaceAll: "replaceWith"
  6924. }, function( name, original ) {
  6925. jQuery.fn[ name ] = function( selector ) {
  6926. var elems,
  6927. i = 0,
  6928. ret = [],
  6929. insert = jQuery( selector ),
  6930. l = insert.length,
  6931. parent = this.length === 1 && this[0].parentNode;
  6932. if ( (parent == null || parent && parent.nodeType === 11 && parent.childNodes.length === 1) && l === 1 ) {
  6933. insert[ original ]( this[0] );
  6934. return this;
  6935. } else {
  6936. for ( ; i < l; i++ ) {
  6937. elems = ( i > 0 ? this.clone(true) : this ).get();
  6938. jQuery( insert[i] )[ original ]( elems );
  6939. ret = ret.concat( elems );
  6940. }
  6941. return this.pushStack( ret, name, insert.selector );
  6942. }
  6943. };
  6944. });
  6945. function getAll( elem ) {
  6946. if ( typeof elem.getElementsByTagName !== "undefined" ) {
  6947. return elem.getElementsByTagName( "*" );
  6948. } else if ( typeof elem.querySelectorAll !== "undefined" ) {
  6949. return elem.querySelectorAll( "*" );
  6950. } else {
  6951. return [];
  6952. }
  6953. }
  6954. // Used in clean, fixes the defaultChecked property
  6955. function fixDefaultChecked( elem ) {
  6956. if ( rcheckableType.test( elem.type ) ) {
  6957. elem.defaultChecked = elem.checked;
  6958. }
  6959. }
  6960. jQuery.extend({
  6961. clone: function( elem, dataAndEvents, deepDataAndEvents ) {
  6962. var srcElements,
  6963. destElements,
  6964. i,
  6965. clone;
  6966. if ( jQuery.support.html5Clone || jQuery.isXMLDoc(elem) || !rnoshimcache.test( "<" + elem.nodeName + ">" ) ) {
  6967. clone = elem.cloneNode( true );
  6968. // IE<=8 does not properly clone detached, unknown element nodes
  6969. } else {
  6970. fragmentDiv.innerHTML = elem.outerHTML;
  6971. fragmentDiv.removeChild( clone = fragmentDiv.firstChild );
  6972. }
  6973. if ( (!jQuery.support.noCloneEvent || !jQuery.support.noCloneChecked) &&
  6974. (elem.nodeType === 1 || elem.nodeType === 11) && !jQuery.isXMLDoc(elem) ) {
  6975. // IE copies events bound via attachEvent when using cloneNode.
  6976. // Calling detachEvent on the clone will also remove the events
  6977. // from the original. In order to get around this, we use some
  6978. // proprietary methods to clear the events. Thanks to MooTools
  6979. // guys for this hotness.
  6980. cloneFixAttributes( elem, clone );
  6981. // Using Sizzle here is crazy slow, so we use getElementsByTagName instead
  6982. srcElements = getAll( elem );
  6983. destElements = getAll( clone );
  6984. // Weird iteration because IE will replace the length property
  6985. // with an element if you are cloning the body and one of the
  6986. // elements on the page has a name or id of "length"
  6987. for ( i = 0; srcElements[i]; ++i ) {
  6988. // Ensure that the destination node is not null; Fixes #9587
  6989. if ( destElements[i] ) {
  6990. cloneFixAttributes( srcElements[i], destElements[i] );
  6991. }
  6992. }
  6993. }
  6994. // Copy the events from the original to the clone
  6995. if ( dataAndEvents ) {
  6996. cloneCopyEvent( elem, clone );
  6997. if ( deepDataAndEvents ) {
  6998. srcElements = getAll( elem );
  6999. destElements = getAll( clone );
  7000. for ( i = 0; srcElements[i]; ++i ) {
  7001. cloneCopyEvent( srcElements[i], destElements[i] );
  7002. }
  7003. }
  7004. }
  7005. srcElements = destElements = null;
  7006. // Return the cloned set
  7007. return clone;
  7008. },
  7009. clean: function( elems, context, fragment, scripts ) {
  7010. var i, j, elem, tag, wrap, depth, div, hasBody, tbody, len, handleScript, jsTags,
  7011. safe = context === document && safeFragment,
  7012. ret = [];
  7013. // Ensure that context is a document
  7014. if ( !context || typeof context.createDocumentFragment === "undefined" ) {
  7015. context = document;
  7016. }
  7017. // Use the already-created safe fragment if context permits
  7018. for ( i = 0; (elem = elems[i]) != null; i++ ) {
  7019. if ( typeof elem === "number" ) {
  7020. elem += "";
  7021. }
  7022. if ( !elem ) {
  7023. continue;
  7024. }
  7025. // Convert html string into DOM nodes
  7026. if ( typeof elem === "string" ) {
  7027. if ( !rhtml.test( elem ) ) {
  7028. elem = context.createTextNode( elem );
  7029. } else {
  7030. // Ensure a safe container in which to render the html
  7031. safe = safe || createSafeFragment( context );
  7032. div = context.createElement("div");
  7033. safe.appendChild( div );
  7034. // Fix "XHTML"-style tags in all browsers
  7035. elem = elem.replace(rxhtmlTag, "<$1></$2>");
  7036. // Go to html and back, then peel off extra wrappers
  7037. tag = ( rtagName.exec( elem ) || ["", ""] )[1].toLowerCase();
  7038. wrap = wrapMap[ tag ] || wrapMap._default;
  7039. depth = wrap[0];
  7040. div.innerHTML = wrap[1] + elem + wrap[2];
  7041. // Move to the right depth
  7042. while ( depth-- ) {
  7043. div = div.lastChild;
  7044. }
  7045. // Remove IE's autoinserted <tbody> from table fragments
  7046. if ( !jQuery.support.tbody ) {
  7047. // String was a <table>, *may* have spurious <tbody>
  7048. hasBody = rtbody.test(elem);
  7049. tbody = tag === "table" && !hasBody ?
  7050. div.firstChild && div.firstChild.childNodes :
  7051. // String was a bare <thead> or <tfoot>
  7052. wrap[1] === "<table>" && !hasBody ?
  7053. div.childNodes :
  7054. [];
  7055. for ( j = tbody.length - 1; j >= 0 ; --j ) {
  7056. if ( jQuery.nodeName( tbody[ j ], "tbody" ) && !tbody[ j ].childNodes.length ) {
  7057. tbody[ j ].parentNode.removeChild( tbody[ j ] );
  7058. }
  7059. }
  7060. }
  7061. // IE completely kills leading whitespace when innerHTML is used
  7062. if ( !jQuery.support.leadingWhitespace && rleadingWhitespace.test( elem ) ) {
  7063. div.insertBefore( context.createTextNode( rleadingWhitespace.exec(elem)[0] ), div.firstChild );
  7064. }
  7065. elem = div.childNodes;
  7066. // Take out of fragment container (we need a fresh div each time)
  7067. div.parentNode.removeChild( div );
  7068. }
  7069. }
  7070. if ( elem.nodeType ) {
  7071. ret.push( elem );
  7072. } else {
  7073. jQuery.merge( ret, elem );
  7074. }
  7075. }
  7076. // Fix #11356: Clear elements from safeFragment
  7077. if ( div ) {
  7078. elem = div = safe = null;
  7079. }
  7080. // Reset defaultChecked for any radios and checkboxes
  7081. // about to be appended to the DOM in IE 6/7 (#8060)
  7082. if ( !jQuery.support.appendChecked ) {
  7083. for ( i = 0; (elem = ret[i]) != null; i++ ) {
  7084. if ( jQuery.nodeName( elem, "input" ) ) {
  7085. fixDefaultChecked( elem );
  7086. } else if ( typeof elem.getElementsByTagName !== "undefined" ) {
  7087. jQuery.grep( elem.getElementsByTagName("input"), fixDefaultChecked );
  7088. }
  7089. }
  7090. }
  7091. // Append elements to a provided document fragment
  7092. if ( fragment ) {
  7093. // Special handling of each script element
  7094. handleScript = function( elem ) {
  7095. // Check if we consider it executable
  7096. if ( !elem.type || rscriptType.test( elem.type ) ) {
  7097. // Detach the script and store it in the scripts array (if provided) or the fragment
  7098. // Return truthy to indicate that it has been handled
  7099. return scripts ?
  7100. scripts.push( elem.parentNode ? elem.parentNode.removeChild( elem ) : elem ) :
  7101. fragment.appendChild( elem );
  7102. }
  7103. };
  7104. for ( i = 0; (elem = ret[i]) != null; i++ ) {
  7105. // Check if we're done after handling an executable script
  7106. if ( !( jQuery.nodeName( elem, "script" ) && handleScript( elem ) ) ) {
  7107. // Append to fragment and handle embedded scripts
  7108. fragment.appendChild( elem );
  7109. if ( typeof elem.getElementsByTagName !== "undefined" ) {
  7110. // handleScript alters the DOM, so use jQuery.merge to ensure snapshot iteration
  7111. jsTags = jQuery.grep( jQuery.merge( [], elem.getElementsByTagName("script") ), handleScript );
  7112. // Splice the scripts into ret after their former ancestor and advance our index beyond them
  7113. ret.splice.apply( ret, [i + 1, 0].concat( jsTags ) );
  7114. i += jsTags.length;
  7115. }
  7116. }
  7117. }
  7118. }
  7119. return ret;
  7120. },
  7121. cleanData: function( elems, /* internal */ acceptData ) {
  7122. var data, id, elem, type,
  7123. i = 0,
  7124. internalKey = jQuery.expando,
  7125. cache = jQuery.cache,
  7126. deleteExpando = jQuery.support.deleteExpando,
  7127. special = jQuery.event.special;
  7128. for ( ; (elem = elems[i]) != null; i++ ) {
  7129. if ( acceptData || jQuery.acceptData( elem ) ) {
  7130. id = elem[ internalKey ];
  7131. data = id && cache[ id ];
  7132. if ( data ) {
  7133. if ( data.events ) {
  7134. for ( type in data.events ) {
  7135. if ( special[ type ] ) {
  7136. jQuery.event.remove( elem, type );
  7137. // This is a shortcut to avoid jQuery.event.remove's overhead
  7138. } else {
  7139. jQuery.removeEvent( elem, type, data.handle );
  7140. }
  7141. }
  7142. }
  7143. // Remove cache only if it was not already removed by jQuery.event.remove
  7144. if ( cache[ id ] ) {
  7145. delete cache[ id ];
  7146. // IE does not allow us to delete expando properties from nodes,
  7147. // nor does it have a removeAttribute function on Document nodes;
  7148. // we must handle all of these cases
  7149. if ( deleteExpando ) {
  7150. delete elem[ internalKey ];
  7151. } else if ( elem.removeAttribute ) {
  7152. elem.removeAttribute( internalKey );
  7153. } else {
  7154. elem[ internalKey ] = null;
  7155. }
  7156. jQuery.deletedIds.push( id );
  7157. }
  7158. }
  7159. }
  7160. }
  7161. }
  7162. });
  7163. // Limit scope pollution from any deprecated API
  7164. (function() {
  7165. var matched, browser;
  7166. // Use of jQuery.browser is frowned upon.
  7167. // More details: http://api.jquery.com/jQuery.browser
  7168. // jQuery.uaMatch maintained for back-compat
  7169. jQuery.uaMatch = function( ua ) {
  7170. ua = ua.toLowerCase();
  7171. var match = /(chrome)[ \/]([\w.]+)/.exec( ua ) ||
  7172. /(webkit)[ \/]([\w.]+)/.exec( ua ) ||
  7173. /(opera)(?:.*version|)[ \/]([\w.]+)/.exec( ua ) ||
  7174. /(msie) ([\w.]+)/.exec( ua ) ||
  7175. ua.indexOf("compatible") < 0 && /(mozilla)(?:.*? rv:([\w.]+)|)/.exec( ua ) ||
  7176. [];
  7177. return {
  7178. browser: match[ 1 ] || "",
  7179. version: match[ 2 ] || "0"
  7180. };
  7181. };
  7182. matched = jQuery.uaMatch( navigator.userAgent );
  7183. browser = {};
  7184. if ( matched.browser ) {
  7185. browser[ matched.browser ] = true;
  7186. browser.version = matched.version;
  7187. }
  7188. // Chrome is Webkit, but Webkit is also Safari.
  7189. if ( browser.chrome ) {
  7190. browser.webkit = true;
  7191. } else if ( browser.webkit ) {
  7192. browser.safari = true;
  7193. }
  7194. jQuery.browser = browser;
  7195. jQuery.sub = function() {
  7196. function jQuerySub( selector, context ) {
  7197. return new jQuerySub.fn.init( selector, context );
  7198. }
  7199. jQuery.extend( true, jQuerySub, this );
  7200. jQuerySub.superclass = this;
  7201. jQuerySub.fn = jQuerySub.prototype = this();
  7202. jQuerySub.fn.constructor = jQuerySub;
  7203. jQuerySub.sub = this.sub;
  7204. jQuerySub.fn.init = function init( selector, context ) {
  7205. if ( context && context instanceof jQuery && !(context instanceof jQuerySub) ) {
  7206. context = jQuerySub( context );
  7207. }
  7208. return jQuery.fn.init.call( this, selector, context, rootjQuerySub );
  7209. };
  7210. jQuerySub.fn.init.prototype = jQuerySub.fn;
  7211. var rootjQuerySub = jQuerySub(document);
  7212. return jQuerySub;
  7213. };
  7214. })();
  7215. var curCSS, iframe, iframeDoc,
  7216. ralpha = /alpha\([^)]*\)/i,
  7217. ropacity = /opacity=([^)]*)/,
  7218. rposition = /^(top|right|bottom|left)$/,
  7219. // swappable if display is none or starts with table except "table", "table-cell", or "table-caption"
  7220. // see here for display values: https://developer.mozilla.org/en-US/docs/CSS/display
  7221. rdisplayswap = /^(none|table(?!-c[ea]).+)/,
  7222. rmargin = /^margin/,
  7223. rnumsplit = new RegExp( "^(" + core_pnum + ")(.*)$", "i" ),
  7224. rnumnonpx = new RegExp( "^(" + core_pnum + ")(?!px)[a-z%]+$", "i" ),
  7225. rrelNum = new RegExp( "^([-+])=(" + core_pnum + ")", "i" ),
  7226. elemdisplay = {},
  7227. cssShow = { position: "absolute", visibility: "hidden", display: "block" },
  7228. cssNormalTransform = {
  7229. letterSpacing: 0,
  7230. fontWeight: 400
  7231. },
  7232. cssExpand = [ "Top", "Right", "Bottom", "Left" ],
  7233. cssPrefixes = [ "Webkit", "O", "Moz", "ms" ],
  7234. eventsToggle = jQuery.fn.toggle;
  7235. // return a css property mapped to a potentially vendor prefixed property
  7236. function vendorPropName( style, name ) {
  7237. // shortcut for names that are not vendor prefixed
  7238. if ( name in style ) {
  7239. return name;
  7240. }
  7241. // check for vendor prefixed names
  7242. var capName = name.charAt(0).toUpperCase() + name.slice(1),
  7243. origName = name,
  7244. i = cssPrefixes.length;
  7245. while ( i-- ) {
  7246. name = cssPrefixes[ i ] + capName;
  7247. if ( name in style ) {
  7248. return name;
  7249. }
  7250. }
  7251. return origName;
  7252. }
  7253. function isHidden( elem, el ) {
  7254. elem = el || elem;
  7255. return jQuery.css( elem, "display" ) === "none" || !jQuery.contains( elem.ownerDocument, elem );
  7256. }
  7257. function showHide( elements, show ) {
  7258. var elem, display,
  7259. values = [],
  7260. index = 0,
  7261. length = elements.length;
  7262. for ( ; index < length; index++ ) {
  7263. elem = elements[ index ];
  7264. if ( !elem.style ) {
  7265. continue;
  7266. }
  7267. values[ index ] = jQuery._data( elem, "olddisplay" );
  7268. if ( show ) {
  7269. // Reset the inline display of this element to learn if it is
  7270. // being hidden by cascaded rules or not
  7271. if ( !values[ index ] && elem.style.display === "none" ) {
  7272. elem.style.display = "";
  7273. }
  7274. // Set elements which have been overridden with display: none
  7275. // in a stylesheet to whatever the default browser style is
  7276. // for such an element
  7277. if ( elem.style.display === "" && isHidden( elem ) ) {
  7278. values[ index ] = jQuery._data( elem, "olddisplay", css_defaultDisplay(elem.nodeName) );
  7279. }
  7280. } else {
  7281. display = curCSS( elem, "display" );
  7282. if ( !values[ index ] && display !== "none" ) {
  7283. jQuery._data( elem, "olddisplay", display );
  7284. }
  7285. }
  7286. }
  7287. // Set the display of most of the elements in a second loop
  7288. // to avoid the constant reflow
  7289. for ( index = 0; index < length; index++ ) {
  7290. elem = elements[ index ];
  7291. if ( !elem.style ) {
  7292. continue;
  7293. }
  7294. if ( !show || elem.style.display === "none" || elem.style.display === "" ) {
  7295. elem.style.display = show ? values[ index ] || "" : "none";
  7296. }
  7297. }
  7298. return elements;
  7299. }
  7300. jQuery.fn.extend({
  7301. css: function( name, value ) {
  7302. return jQuery.access( this, function( elem, name, value ) {
  7303. return value !== undefined ?
  7304. jQuery.style( elem, name, value ) :
  7305. jQuery.css( elem, name );
  7306. }, name, value, arguments.length > 1 );
  7307. },
  7308. show: function() {
  7309. return showHide( this, true );
  7310. },
  7311. hide: function() {
  7312. return showHide( this );
  7313. },
  7314. toggle: function( state, fn2 ) {
  7315. var bool = typeof state === "boolean";
  7316. if ( jQuery.isFunction( state ) && jQuery.isFunction( fn2 ) ) {
  7317. return eventsToggle.apply( this, arguments );
  7318. }
  7319. return this.each(function() {
  7320. if ( bool ? state : isHidden( this ) ) {
  7321. jQuery( this ).show();
  7322. } else {
  7323. jQuery( this ).hide();
  7324. }
  7325. });
  7326. }
  7327. });
  7328. jQuery.extend({
  7329. // Add in style property hooks for overriding the default
  7330. // behavior of getting and setting a style property
  7331. cssHooks: {
  7332. opacity: {
  7333. get: function( elem, computed ) {
  7334. if ( computed ) {
  7335. // We should always get a number back from opacity
  7336. var ret = curCSS( elem, "opacity" );
  7337. return ret === "" ? "1" : ret;
  7338. }
  7339. }
  7340. }
  7341. },
  7342. // Exclude the following css properties to add px
  7343. cssNumber: {
  7344. "fillOpacity": true,
  7345. "fontWeight": true,
  7346. "lineHeight": true,
  7347. "opacity": true,
  7348. "orphans": true,
  7349. "widows": true,
  7350. "zIndex": true,
  7351. "zoom": true
  7352. },
  7353. // Add in properties whose names you wish to fix before
  7354. // setting or getting the value
  7355. cssProps: {
  7356. // normalize float css property
  7357. "float": jQuery.support.cssFloat ? "cssFloat" : "styleFloat"
  7358. },
  7359. // Get and set the style property on a DOM Node
  7360. style: function( elem, name, value, extra ) {
  7361. // Don't set styles on text and comment nodes
  7362. if ( !elem || elem.nodeType === 3 || elem.nodeType === 8 || !elem.style ) {
  7363. return;
  7364. }
  7365. // Make sure that we're working with the right name
  7366. var ret, type, hooks,
  7367. origName = jQuery.camelCase( name ),
  7368. style = elem.style;
  7369. name = jQuery.cssProps[ origName ] || ( jQuery.cssProps[ origName ] = vendorPropName( style, origName ) );
  7370. // gets hook for the prefixed version
  7371. // followed by the unprefixed version
  7372. hooks = jQuery.cssHooks[ name ] || jQuery.cssHooks[ origName ];
  7373. // Check if we're setting a value
  7374. if ( value !== undefined ) {
  7375. type = typeof value;
  7376. // convert relative number strings (+= or -=) to relative numbers. #7345
  7377. if ( type === "string" && (ret = rrelNum.exec( value )) ) {
  7378. value = ( ret[1] + 1 ) * ret[2] + parseFloat( jQuery.css( elem, name ) );
  7379. // Fixes bug #9237
  7380. type = "number";
  7381. }
  7382. // Make sure that NaN and null values aren't set. See: #7116
  7383. if ( value == null || type === "number" && isNaN( value ) ) {
  7384. return;
  7385. }
  7386. // If a number was passed in, add 'px' to the (except for certain CSS properties)
  7387. if ( type === "number" && !jQuery.cssNumber[ origName ] ) {
  7388. value += "px";
  7389. }
  7390. // If a hook was provided, use that value, otherwise just set the specified value
  7391. if ( !hooks || !("set" in hooks) || (value = hooks.set( elem, value, extra )) !== undefined ) {
  7392. // Wrapped to prevent IE from throwing errors when 'invalid' values are provided
  7393. // Fixes bug #5509
  7394. try {
  7395. style[ name ] = value;
  7396. } catch(e) {}
  7397. }
  7398. } else {
  7399. // If a hook was provided get the non-computed value from there
  7400. if ( hooks && "get" in hooks && (ret = hooks.get( elem, false, extra )) !== undefined ) {
  7401. return ret;
  7402. }
  7403. // Otherwise just get the value from the style object
  7404. return style[ name ];
  7405. }
  7406. },
  7407. css: function( elem, name, numeric, extra ) {
  7408. var val, num, hooks,
  7409. origName = jQuery.camelCase( name );
  7410. // Make sure that we're working with the right name
  7411. name = jQuery.cssProps[ origName ] || ( jQuery.cssProps[ origName ] = vendorPropName( elem.style, origName ) );
  7412. // gets hook for the prefixed version
  7413. // followed by the unprefixed version
  7414. hooks = jQuery.cssHooks[ name ] || jQuery.cssHooks[ origName ];
  7415. // If a hook was provided get the computed value from there
  7416. if ( hooks && "get" in hooks ) {
  7417. val = hooks.get( elem, true, extra );
  7418. }
  7419. // Otherwise, if a way to get the computed value exists, use that
  7420. if ( val === undefined ) {
  7421. val = curCSS( elem, name );
  7422. }
  7423. //convert "normal" to computed value
  7424. if ( val === "normal" && name in cssNormalTransform ) {
  7425. val = cssNormalTransform[ name ];
  7426. }
  7427. // Return, converting to number if forced or a qualifier was provided and val looks numeric
  7428. if ( numeric || extra !== undefined ) {
  7429. num = parseFloat( val );
  7430. return numeric || jQuery.isNumeric( num ) ? num || 0 : val;
  7431. }
  7432. return val;
  7433. },
  7434. // A method for quickly swapping in/out CSS properties to get correct calculations
  7435. swap: function( elem, options, callback ) {
  7436. var ret, name,
  7437. old = {};
  7438. // Remember the old values, and insert the new ones
  7439. for ( name in options ) {
  7440. old[ name ] = elem.style[ name ];
  7441. elem.style[ name ] = options[ name ];
  7442. }
  7443. ret = callback.call( elem );
  7444. // Revert the old values
  7445. for ( name in options ) {
  7446. elem.style[ name ] = old[ name ];
  7447. }
  7448. return ret;
  7449. }
  7450. });
  7451. // NOTE: To any future maintainer, we've window.getComputedStyle
  7452. // because jsdom on node.js will break without it.
  7453. if ( window.getComputedStyle ) {
  7454. curCSS = function( elem, name ) {
  7455. var ret, width, minWidth, maxWidth,
  7456. computed = window.getComputedStyle( elem, null ),
  7457. style = elem.style;
  7458. if ( computed ) {
  7459. ret = computed[ name ];
  7460. if ( ret === "" && !jQuery.contains( elem.ownerDocument, elem ) ) {
  7461. ret = jQuery.style( elem, name );
  7462. }
  7463. // A tribute to the "awesome hack by Dean Edwards"
  7464. // Chrome < 17 and Safari 5.0 uses "computed value" instead of "used value" for margin-right
  7465. // Safari 5.1.7 (at least) returns percentage for a larger set of values, but width seems to be reliably pixels
  7466. // this is against the CSSOM draft spec: http://dev.w3.org/csswg/cssom/#resolved-values
  7467. if ( rnumnonpx.test( ret ) && rmargin.test( name ) ) {
  7468. width = style.width;
  7469. minWidth = style.minWidth;
  7470. maxWidth = style.maxWidth;
  7471. style.minWidth = style.maxWidth = style.width = ret;
  7472. ret = computed.width;
  7473. style.width = width;
  7474. style.minWidth = minWidth;
  7475. style.maxWidth = maxWidth;
  7476. }
  7477. }
  7478. return ret;
  7479. };
  7480. } else if ( document.documentElement.currentStyle ) {
  7481. curCSS = function( elem, name ) {
  7482. var left, rsLeft,
  7483. ret = elem.currentStyle && elem.currentStyle[ name ],
  7484. style = elem.style;
  7485. // Avoid setting ret to empty string here
  7486. // so we don't default to auto
  7487. if ( ret == null && style && style[ name ] ) {
  7488. ret = style[ name ];
  7489. }
  7490. // From the awesome hack by Dean Edwards
  7491. // http://erik.eae.net/archives/2007/07/27/18.54.15/#comment-102291
  7492. // If we're not dealing with a regular pixel number
  7493. // but a number that has a weird ending, we need to convert it to pixels
  7494. // but not position css attributes, as those are proportional to the parent element instead
  7495. // and we can't measure the parent instead because it might trigger a "stacking dolls" problem
  7496. if ( rnumnonpx.test( ret ) && !rposition.test( name ) ) {
  7497. // Remember the original values
  7498. left = style.left;
  7499. rsLeft = elem.runtimeStyle && elem.runtimeStyle.left;
  7500. // Put in the new values to get a computed value out
  7501. if ( rsLeft ) {
  7502. elem.runtimeStyle.left = elem.currentStyle.left;
  7503. }
  7504. style.left = name === "fontSize" ? "1em" : ret;
  7505. ret = style.pixelLeft + "px";
  7506. // Revert the changed values
  7507. style.left = left;
  7508. if ( rsLeft ) {
  7509. elem.runtimeStyle.left = rsLeft;
  7510. }
  7511. }
  7512. return ret === "" ? "auto" : ret;
  7513. };
  7514. }
  7515. function setPositiveNumber( elem, value, subtract ) {
  7516. var matches = rnumsplit.exec( value );
  7517. return matches ?
  7518. Math.max( 0, matches[ 1 ] - ( subtract || 0 ) ) + ( matches[ 2 ] || "px" ) :
  7519. value;
  7520. }
  7521. function augmentWidthOrHeight( elem, name, extra, isBorderBox ) {
  7522. var i = extra === ( isBorderBox ? "border" : "content" ) ?
  7523. // If we already have the right measurement, avoid augmentation
  7524. 4 :
  7525. // Otherwise initialize for horizontal or vertical properties
  7526. name === "width" ? 1 : 0,
  7527. val = 0;
  7528. for ( ; i < 4; i += 2 ) {
  7529. // both box models exclude margin, so add it if we want it
  7530. if ( extra === "margin" ) {
  7531. // we use jQuery.css instead of curCSS here
  7532. // because of the reliableMarginRight CSS hook!
  7533. val += jQuery.css( elem, extra + cssExpand[ i ], true );
  7534. }
  7535. // From this point on we use curCSS for maximum performance (relevant in animations)
  7536. if ( isBorderBox ) {
  7537. // border-box includes padding, so remove it if we want content
  7538. if ( extra === "content" ) {
  7539. val -= parseFloat( curCSS( elem, "padding" + cssExpand[ i ] ) ) || 0;
  7540. }
  7541. // at this point, extra isn't border nor margin, so remove border
  7542. if ( extra !== "margin" ) {
  7543. val -= parseFloat( curCSS( elem, "border" + cssExpand[ i ] + "Width" ) ) || 0;
  7544. }
  7545. } else {
  7546. // at this point, extra isn't content, so add padding
  7547. val += parseFloat( curCSS( elem, "padding" + cssExpand[ i ] ) ) || 0;
  7548. // at this point, extra isn't content nor padding, so add border
  7549. if ( extra !== "padding" ) {
  7550. val += parseFloat( curCSS( elem, "border" + cssExpand[ i ] + "Width" ) ) || 0;
  7551. }
  7552. }
  7553. }
  7554. return val;
  7555. }
  7556. function getWidthOrHeight( elem, name, extra ) {
  7557. // Start with offset property, which is equivalent to the border-box value
  7558. var val = name === "width" ? elem.offsetWidth : elem.offsetHeight,
  7559. valueIsBorderBox = true,
  7560. isBorderBox = jQuery.support.boxSizing && jQuery.css( elem, "boxSizing" ) === "border-box";
  7561. // some non-html elements return undefined for offsetWidth, so check for null/undefined
  7562. // svg - https://bugzilla.mozilla.org/show_bug.cgi?id=649285
  7563. // MathML - https://bugzilla.mozilla.org/show_bug.cgi?id=491668
  7564. if ( val <= 0 || val == null ) {
  7565. // Fall back to computed then uncomputed css if necessary
  7566. val = curCSS( elem, name );
  7567. if ( val < 0 || val == null ) {
  7568. val = elem.style[ name ];
  7569. }
  7570. // Computed unit is not pixels. Stop here and return.
  7571. if ( rnumnonpx.test(val) ) {
  7572. return val;
  7573. }
  7574. // we need the check for style in case a browser which returns unreliable values
  7575. // for getComputedStyle silently falls back to the reliable elem.style
  7576. valueIsBorderBox = isBorderBox && ( jQuery.support.boxSizingReliable || val === elem.style[ name ] );
  7577. // Normalize "", auto, and prepare for extra
  7578. val = parseFloat( val ) || 0;
  7579. }
  7580. // use the active box-sizing model to add/subtract irrelevant styles
  7581. return ( val +
  7582. augmentWidthOrHeight(
  7583. elem,
  7584. name,
  7585. extra || ( isBorderBox ? "border" : "content" ),
  7586. valueIsBorderBox
  7587. )
  7588. ) + "px";
  7589. }
  7590. // Try to determine the default display value of an element
  7591. function css_defaultDisplay( nodeName ) {
  7592. if ( elemdisplay[ nodeName ] ) {
  7593. return elemdisplay[ nodeName ];
  7594. }
  7595. var elem = jQuery( "<" + nodeName + ">" ).appendTo( document.body ),
  7596. display = elem.css("display");
  7597. elem.remove();
  7598. // If the simple way fails,
  7599. // get element's real default display by attaching it to a temp iframe
  7600. if ( display === "none" || display === "" ) {
  7601. // Use the already-created iframe if possible
  7602. iframe = document.body.appendChild(
  7603. iframe || jQuery.extend( document.createElement("iframe"), {
  7604. frameBorder: 0,
  7605. width: 0,
  7606. height: 0
  7607. })
  7608. );
  7609. // Create a cacheable copy of the iframe document on first call.
  7610. // IE and Opera will allow us to reuse the iframeDoc without re-writing the fake HTML
  7611. // document to it; WebKit & Firefox won't allow reusing the iframe document.
  7612. if ( !iframeDoc || !iframe.createElement ) {
  7613. iframeDoc = ( iframe.contentWindow || iframe.contentDocument ).document;
  7614. iframeDoc.write("<!doctype html><html><body>");
  7615. iframeDoc.close();
  7616. }
  7617. elem = iframeDoc.body.appendChild( iframeDoc.createElement(nodeName) );
  7618. display = curCSS( elem, "display" );
  7619. document.body.removeChild( iframe );
  7620. }
  7621. // Store the correct default display
  7622. elemdisplay[ nodeName ] = display;
  7623. return display;
  7624. }
  7625. jQuery.each([ "height", "width" ], function( i, name ) {
  7626. jQuery.cssHooks[ name ] = {
  7627. get: function( elem, computed, extra ) {
  7628. if ( computed ) {
  7629. // certain elements can have dimension info if we invisibly show them
  7630. // however, it must have a current display style that would benefit from this
  7631. if ( elem.offsetWidth === 0 && rdisplayswap.test( curCSS( elem, "display" ) ) ) {
  7632. return jQuery.swap( elem, cssShow, function() {
  7633. return getWidthOrHeight( elem, name, extra );
  7634. });
  7635. } else {
  7636. return getWidthOrHeight( elem, name, extra );
  7637. }
  7638. }
  7639. },
  7640. set: function( elem, value, extra ) {
  7641. return setPositiveNumber( elem, value, extra ?
  7642. augmentWidthOrHeight(
  7643. elem,
  7644. name,
  7645. extra,
  7646. jQuery.support.boxSizing && jQuery.css( elem, "boxSizing" ) === "border-box"
  7647. ) : 0
  7648. );
  7649. }
  7650. };
  7651. });
  7652. if ( !jQuery.support.opacity ) {
  7653. jQuery.cssHooks.opacity = {
  7654. get: function( elem, computed ) {
  7655. // IE uses filters for opacity
  7656. return ropacity.test( (computed && elem.currentStyle ? elem.currentStyle.filter : elem.style.filter) || "" ) ?
  7657. ( 0.01 * parseFloat( RegExp.$1 ) ) + "" :
  7658. computed ? "1" : "";
  7659. },
  7660. set: function( elem, value ) {
  7661. var style = elem.style,
  7662. currentStyle = elem.currentStyle,
  7663. opacity = jQuery.isNumeric( value ) ? "alpha(opacity=" + value * 100 + ")" : "",
  7664. filter = currentStyle && currentStyle.filter || style.filter || "";
  7665. // IE has trouble with opacity if it does not have layout
  7666. // Force it by setting the zoom level
  7667. style.zoom = 1;
  7668. // if setting opacity to 1, and no other filters exist - attempt to remove filter attribute #6652
  7669. if ( value >= 1 && jQuery.trim( filter.replace( ralpha, "" ) ) === "" &&
  7670. style.removeAttribute ) {
  7671. // Setting style.filter to null, "" & " " still leave "filter:" in the cssText
  7672. // if "filter:" is present at all, clearType is disabled, we want to avoid this
  7673. // style.removeAttribute is IE Only, but so apparently is this code path...
  7674. style.removeAttribute( "filter" );
  7675. // if there there is no filter style applied in a css rule, we are done
  7676. if ( currentStyle && !currentStyle.filter ) {
  7677. return;
  7678. }
  7679. }
  7680. // otherwise, set new filter values
  7681. style.filter = ralpha.test( filter ) ?
  7682. filter.replace( ralpha, opacity ) :
  7683. filter + " " + opacity;
  7684. }
  7685. };
  7686. }
  7687. // These hooks cannot be added until DOM ready because the support test
  7688. // for it is not run until after DOM ready
  7689. jQuery(function() {
  7690. if ( !jQuery.support.reliableMarginRight ) {
  7691. jQuery.cssHooks.marginRight = {
  7692. get: function( elem, computed ) {
  7693. // WebKit Bug 13343 - getComputedStyle returns wrong value for margin-right
  7694. // Work around by temporarily setting element display to inline-block
  7695. return jQuery.swap( elem, { "display": "inline-block" }, function() {
  7696. if ( computed ) {
  7697. return curCSS( elem, "marginRight" );
  7698. }
  7699. });
  7700. }
  7701. };
  7702. }
  7703. // Webkit bug: https://bugs.webkit.org/show_bug.cgi?id=29084
  7704. // getComputedStyle returns percent when specified for top/left/bottom/right
  7705. // rather than make the css module depend on the offset module, we just check for it here
  7706. if ( !jQuery.support.pixelPosition && jQuery.fn.position ) {
  7707. jQuery.each( [ "top", "left" ], function( i, prop ) {
  7708. jQuery.cssHooks[ prop ] = {
  7709. get: function( elem, computed ) {
  7710. if ( computed ) {
  7711. var ret = curCSS( elem, prop );
  7712. // if curCSS returns percentage, fallback to offset
  7713. return rnumnonpx.test( ret ) ? jQuery( elem ).position()[ prop ] + "px" : ret;
  7714. }
  7715. }
  7716. };
  7717. });
  7718. }
  7719. });
  7720. if ( jQuery.expr && jQuery.expr.filters ) {
  7721. jQuery.expr.filters.hidden = function( elem ) {
  7722. return ( elem.offsetWidth === 0 && elem.offsetHeight === 0 ) || (!jQuery.support.reliableHiddenOffsets && ((elem.style && elem.style.display) || curCSS( elem, "display" )) === "none");
  7723. };
  7724. jQuery.expr.filters.visible = function( elem ) {
  7725. return !jQuery.expr.filters.hidden( elem );
  7726. };
  7727. }
  7728. // These hooks are used by animate to expand properties
  7729. jQuery.each({
  7730. margin: "",
  7731. padding: "",
  7732. border: "Width"
  7733. }, function( prefix, suffix ) {
  7734. jQuery.cssHooks[ prefix + suffix ] = {
  7735. expand: function( value ) {
  7736. var i,
  7737. // assumes a single number if not a string
  7738. parts = typeof value === "string" ? value.split(" ") : [ value ],
  7739. expanded = {};
  7740. for ( i = 0; i < 4; i++ ) {
  7741. expanded[ prefix + cssExpand[ i ] + suffix ] =
  7742. parts[ i ] || parts[ i - 2 ] || parts[ 0 ];
  7743. }
  7744. return expanded;
  7745. }
  7746. };
  7747. if ( !rmargin.test( prefix ) ) {
  7748. jQuery.cssHooks[ prefix + suffix ].set = setPositiveNumber;
  7749. }
  7750. });
  7751. var r20 = /%20/g,
  7752. rbracket = /\[\]$/,
  7753. rCRLF = /\r?\n/g,
  7754. rinput = /^(?:color|date|datetime|datetime-local|email|hidden|month|number|password|range|search|tel|text|time|url|week)$/i,
  7755. rselectTextarea = /^(?:select|textarea)/i;
  7756. jQuery.fn.extend({
  7757. serialize: function() {
  7758. return jQuery.param( this.serializeArray() );
  7759. },
  7760. serializeArray: function() {
  7761. return this.map(function(){
  7762. return this.elements ? jQuery.makeArray( this.elements ) : this;
  7763. })
  7764. .filter(function(){
  7765. return this.name && !this.disabled &&
  7766. ( this.checked || rselectTextarea.test( this.nodeName ) ||
  7767. rinput.test( this.type ) );
  7768. })
  7769. .map(function( i, elem ){
  7770. var val = jQuery( this ).val();
  7771. return val == null ?
  7772. null :
  7773. jQuery.isArray( val ) ?
  7774. jQuery.map( val, function( val, i ){
  7775. return { name: elem.name, value: val.replace( rCRLF, "\r\n" ) };
  7776. }) :
  7777. { name: elem.name, value: val.replace( rCRLF, "\r\n" ) };
  7778. }).get();
  7779. }
  7780. });
  7781. //Serialize an array of form elements or a set of
  7782. //key/values into a query string
  7783. jQuery.param = function( a, traditional ) {
  7784. var prefix,
  7785. s = [],
  7786. add = function( key, value ) {
  7787. // If value is a function, invoke it and return its value
  7788. value = jQuery.isFunction( value ) ? value() : ( value == null ? "" : value );
  7789. s[ s.length ] = encodeURIComponent( key ) + "=" + encodeURIComponent( value );
  7790. };
  7791. // Set traditional to true for jQuery <= 1.3.2 behavior.
  7792. if ( traditional === undefined ) {
  7793. traditional = jQuery.ajaxSettings && jQuery.ajaxSettings.traditional;
  7794. }
  7795. // If an array was passed in, assume that it is an array of form elements.
  7796. if ( jQuery.isArray( a ) || ( a.jquery && !jQuery.isPlainObject( a ) ) ) {
  7797. // Serialize the form elements
  7798. jQuery.each( a, function() {
  7799. add( this.name, this.value );
  7800. });
  7801. } else {
  7802. // If traditional, encode the "old" way (the way 1.3.2 or older
  7803. // did it), otherwise encode params recursively.
  7804. for ( prefix in a ) {
  7805. buildParams( prefix, a[ prefix ], traditional, add );
  7806. }
  7807. }
  7808. // Return the resulting serialization
  7809. return s.join( "&" ).replace( r20, "+" );
  7810. };
  7811. function buildParams( prefix, obj, traditional, add ) {
  7812. var name;
  7813. if ( jQuery.isArray( obj ) ) {
  7814. // Serialize array item.
  7815. jQuery.each( obj, function( i, v ) {
  7816. if ( traditional || rbracket.test( prefix ) ) {
  7817. // Treat each array item as a scalar.
  7818. add( prefix, v );
  7819. } else {
  7820. // If array item is non-scalar (array or object), encode its
  7821. // numeric index to resolve deserialization ambiguity issues.
  7822. // Note that rack (as of 1.0.0) can't currently deserialize
  7823. // nested arrays properly, and attempting to do so may cause
  7824. // a server error. Possible fixes are to modify rack's
  7825. // deserialization algorithm or to provide an option or flag
  7826. // to force array serialization to be shallow.
  7827. buildParams( prefix + "[" + ( typeof v === "object" ? i : "" ) + "]", v, traditional, add );
  7828. }
  7829. });
  7830. } else if ( !traditional && jQuery.type( obj ) === "object" ) {
  7831. // Serialize object item.
  7832. for ( name in obj ) {
  7833. buildParams( prefix + "[" + name + "]", obj[ name ], traditional, add );
  7834. }
  7835. } else {
  7836. // Serialize scalar item.
  7837. add( prefix, obj );
  7838. }
  7839. }
  7840. var
  7841. // Document location
  7842. ajaxLocParts,
  7843. ajaxLocation,
  7844. rhash = /#.*$/,
  7845. rheaders = /^(.*?):[ \t]*([^\r\n]*)\r?$/mg, // IE leaves an \r character at EOL
  7846. // #7653, #8125, #8152: local protocol detection
  7847. rlocalProtocol = /^(?:about|app|app\-storage|.+\-extension|file|res|widget):$/,
  7848. rnoContent = /^(?:GET|HEAD)$/,
  7849. rprotocol = /^\/\//,
  7850. rquery = /\?/,
  7851. rscript = /<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi,
  7852. rts = /([?&])_=[^&]*/,
  7853. rurl = /^([\w\+\.\-]+:)(?:\/\/([^\/?#:]*)(?::(\d+)|)|)/,
  7854. // Keep a copy of the old load method
  7855. _load = jQuery.fn.load,
  7856. /* Prefilters
  7857. * 1) They are useful to introduce custom dataTypes (see ajax/jsonp.js for an example)
  7858. * 2) These are called:
  7859. * - BEFORE asking for a transport
  7860. * - AFTER param serialization (s.data is a string if s.processData is true)
  7861. * 3) key is the dataType
  7862. * 4) the catchall symbol "*" can be used
  7863. * 5) execution will start with transport dataType and THEN continue down to "*" if needed
  7864. */
  7865. prefilters = {},
  7866. /* Transports bindings
  7867. * 1) key is the dataType
  7868. * 2) the catchall symbol "*" can be used
  7869. * 3) selection will start with transport dataType and THEN go to "*" if needed
  7870. */
  7871. transports = {},
  7872. // Avoid comment-prolog char sequence (#10098); must appease lint and evade compression
  7873. allTypes = ["*/"] + ["*"];
  7874. // #8138, IE may throw an exception when accessing
  7875. // a field from window.location if document.domain has been set
  7876. try {
  7877. ajaxLocation = location.href;
  7878. } catch( e ) {
  7879. // Use the href attribute of an A element
  7880. // since IE will modify it given document.location
  7881. ajaxLocation = document.createElement( "a" );
  7882. ajaxLocation.href = "";
  7883. ajaxLocation = ajaxLocation.href;
  7884. }
  7885. // Segment location into parts
  7886. ajaxLocParts = rurl.exec( ajaxLocation.toLowerCase() ) || [];
  7887. // Base "constructor" for jQuery.ajaxPrefilter and jQuery.ajaxTransport
  7888. function addToPrefiltersOrTransports( structure ) {
  7889. // dataTypeExpression is optional and defaults to "*"
  7890. return function( dataTypeExpression, func ) {
  7891. if ( typeof dataTypeExpression !== "string" ) {
  7892. func = dataTypeExpression;
  7893. dataTypeExpression = "*";
  7894. }
  7895. var dataType, list, placeBefore,
  7896. dataTypes = dataTypeExpression.toLowerCase().split( core_rspace ),
  7897. i = 0,
  7898. length = dataTypes.length;
  7899. if ( jQuery.isFunction( func ) ) {
  7900. // For each dataType in the dataTypeExpression
  7901. for ( ; i < length; i++ ) {
  7902. dataType = dataTypes[ i ];
  7903. // We control if we're asked to add before
  7904. // any existing element
  7905. placeBefore = /^\+/.test( dataType );
  7906. if ( placeBefore ) {
  7907. dataType = dataType.substr( 1 ) || "*";
  7908. }
  7909. list = structure[ dataType ] = structure[ dataType ] || [];
  7910. // then we add to the structure accordingly
  7911. list[ placeBefore ? "unshift" : "push" ]( func );
  7912. }
  7913. }
  7914. };
  7915. }
  7916. // Base inspection function for prefilters and transports
  7917. function inspectPrefiltersOrTransports( structure, options, originalOptions, jqXHR,
  7918. dataType /* internal */, inspected /* internal */ ) {
  7919. dataType = dataType || options.dataTypes[ 0 ];
  7920. inspected = inspected || {};
  7921. inspected[ dataType ] = true;
  7922. var selection,
  7923. list = structure[ dataType ],
  7924. i = 0,
  7925. length = list ? list.length : 0,
  7926. executeOnly = ( structure === prefilters );
  7927. for ( ; i < length && ( executeOnly || !selection ); i++ ) {
  7928. selection = list[ i ]( options, originalOptions, jqXHR );
  7929. // If we got redirected to another dataType
  7930. // we try there if executing only and not done already
  7931. if ( typeof selection === "string" ) {
  7932. if ( !executeOnly || inspected[ selection ] ) {
  7933. selection = undefined;
  7934. } else {
  7935. options.dataTypes.unshift( selection );
  7936. selection = inspectPrefiltersOrTransports(
  7937. structure, options, originalOptions, jqXHR, selection, inspected );
  7938. }
  7939. }
  7940. }
  7941. // If we're only executing or nothing was selected
  7942. // we try the catchall dataType if not done already
  7943. if ( ( executeOnly || !selection ) && !inspected[ "*" ] ) {
  7944. selection = inspectPrefiltersOrTransports(
  7945. structure, options, originalOptions, jqXHR, "*", inspected );
  7946. }
  7947. // unnecessary when only executing (prefilters)
  7948. // but it'll be ignored by the caller in that case
  7949. return selection;
  7950. }
  7951. // A special extend for ajax options
  7952. // that takes "flat" options (not to be deep extended)
  7953. // Fixes #9887
  7954. function ajaxExtend( target, src ) {
  7955. var key, deep,
  7956. flatOptions = jQuery.ajaxSettings.flatOptions || {};
  7957. for ( key in src ) {
  7958. if ( src[ key ] !== undefined ) {
  7959. ( flatOptions[ key ] ? target : ( deep || ( deep = {} ) ) )[ key ] = src[ key ];
  7960. }
  7961. }
  7962. if ( deep ) {
  7963. jQuery.extend( true, target, deep );
  7964. }
  7965. }
  7966. jQuery.fn.load = function( url, params, callback ) {
  7967. if ( typeof url !== "string" && _load ) {
  7968. return _load.apply( this, arguments );
  7969. }
  7970. // Don't do a request if no elements are being requested
  7971. if ( !this.length ) {
  7972. return this;
  7973. }
  7974. var selector, type, response,
  7975. self = this,
  7976. off = url.indexOf(" ");
  7977. if ( off >= 0 ) {
  7978. selector = url.slice( off, url.length );
  7979. url = url.slice( 0, off );
  7980. }
  7981. // If it's a function
  7982. if ( jQuery.isFunction( params ) ) {
  7983. // We assume that it's the callback
  7984. callback = params;
  7985. params = undefined;
  7986. // Otherwise, build a param string
  7987. } else if ( params && typeof params === "object" ) {
  7988. type = "POST";
  7989. }
  7990. // Request the remote document
  7991. jQuery.ajax({
  7992. url: url,
  7993. // if "type" variable is undefined, then "GET" method will be used
  7994. type: type,
  7995. dataType: "html",
  7996. data: params,
  7997. complete: function( jqXHR, status ) {
  7998. if ( callback ) {
  7999. self.each( callback, response || [ jqXHR.responseText, status, jqXHR ] );
  8000. }
  8001. }
  8002. }).done(function( responseText ) {
  8003. // Save response for use in complete callback
  8004. response = arguments;
  8005. // See if a selector was specified
  8006. self.html( selector ?
  8007. // Create a dummy div to hold the results
  8008. jQuery("<div>")
  8009. // inject the contents of the document in, removing the scripts
  8010. // to avoid any 'Permission Denied' errors in IE
  8011. .append( responseText.replace( rscript, "" ) )
  8012. // Locate the specified elements
  8013. .find( selector ) :
  8014. // If not, just inject the full result
  8015. responseText );
  8016. });
  8017. return this;
  8018. };
  8019. // Attach a bunch of functions for handling common AJAX events
  8020. jQuery.each( "ajaxStart ajaxStop ajaxComplete ajaxError ajaxSuccess ajaxSend".split( " " ), function( i, o ){
  8021. jQuery.fn[ o ] = function( f ){
  8022. return this.on( o, f );
  8023. };
  8024. });
  8025. jQuery.each( [ "get", "post" ], function( i, method ) {
  8026. jQuery[ method ] = function( url, data, callback, type ) {
  8027. // shift arguments if data argument was omitted
  8028. if ( jQuery.isFunction( data ) ) {
  8029. type = type || callback;
  8030. callback = data;
  8031. data = undefined;
  8032. }
  8033. return jQuery.ajax({
  8034. type: method,
  8035. url: url,
  8036. data: data,
  8037. success: callback,
  8038. dataType: type
  8039. });
  8040. };
  8041. });
  8042. jQuery.extend({
  8043. getScript: function( url, callback ) {
  8044. return jQuery.get( url, undefined, callback, "script" );
  8045. },
  8046. getJSON: function( url, data, callback ) {
  8047. return jQuery.get( url, data, callback, "json" );
  8048. },
  8049. // Creates a full fledged settings object into target
  8050. // with both ajaxSettings and settings fields.
  8051. // If target is omitted, writes into ajaxSettings.
  8052. ajaxSetup: function( target, settings ) {
  8053. if ( settings ) {
  8054. // Building a settings object
  8055. ajaxExtend( target, jQuery.ajaxSettings );
  8056. } else {
  8057. // Extending ajaxSettings
  8058. settings = target;
  8059. target = jQuery.ajaxSettings;
  8060. }
  8061. ajaxExtend( target, settings );
  8062. return target;
  8063. },
  8064. ajaxSettings: {
  8065. url: ajaxLocation,
  8066. isLocal: rlocalProtocol.test( ajaxLocParts[ 1 ] ),
  8067. global: true,
  8068. type: "GET",
  8069. contentType: "application/x-www-form-urlencoded; charset=UTF-8",
  8070. processData: true,
  8071. async: true,
  8072. /*
  8073. timeout: 0,
  8074. data: null,
  8075. dataType: null,
  8076. username: null,
  8077. password: null,
  8078. cache: null,
  8079. throws: false,
  8080. traditional: false,
  8081. headers: {},
  8082. */
  8083. accepts: {
  8084. xml: "application/xml, text/xml",
  8085. html: "text/html",
  8086. text: "text/plain",
  8087. json: "application/json, text/javascript",
  8088. "*": allTypes
  8089. },
  8090. contents: {
  8091. xml: /xml/,
  8092. html: /html/,
  8093. json: /json/
  8094. },
  8095. responseFields: {
  8096. xml: "responseXML",
  8097. text: "responseText"
  8098. },
  8099. // List of data converters
  8100. // 1) key format is "source_type destination_type" (a single space in-between)
  8101. // 2) the catchall symbol "*" can be used for source_type
  8102. converters: {
  8103. // Convert anything to text
  8104. "* text": window.String,
  8105. // Text to html (true = no transformation)
  8106. "text html": true,
  8107. // Evaluate text as a json expression
  8108. "text json": jQuery.parseJSON,
  8109. // Parse text as xml
  8110. "text xml": jQuery.parseXML
  8111. },
  8112. // For options that shouldn't be deep extended:
  8113. // you can add your own custom options here if
  8114. // and when you create one that shouldn't be
  8115. // deep extended (see ajaxExtend)
  8116. flatOptions: {
  8117. context: true,
  8118. url: true
  8119. }
  8120. },
  8121. ajaxPrefilter: addToPrefiltersOrTransports( prefilters ),
  8122. ajaxTransport: addToPrefiltersOrTransports( transports ),
  8123. // Main method
  8124. ajax: function( url, options ) {
  8125. // If url is an object, simulate pre-1.5 signature
  8126. if ( typeof url === "object" ) {
  8127. options = url;
  8128. url = undefined;
  8129. }
  8130. // Force options to be an object
  8131. options = options || {};
  8132. var // ifModified key
  8133. ifModifiedKey,
  8134. // Response headers
  8135. responseHeadersString,
  8136. responseHeaders,
  8137. // transport
  8138. transport,
  8139. // timeout handle
  8140. timeoutTimer,
  8141. // Cross-domain detection vars
  8142. parts,
  8143. // To know if global events are to be dispatched
  8144. fireGlobals,
  8145. // Loop variable
  8146. i,
  8147. // Create the final options object
  8148. s = jQuery.ajaxSetup( {}, options ),
  8149. // Callbacks context
  8150. callbackContext = s.context || s,
  8151. // Context for global events
  8152. // It's the callbackContext if one was provided in the options
  8153. // and if it's a DOM node or a jQuery collection
  8154. globalEventContext = callbackContext !== s &&
  8155. ( callbackContext.nodeType || callbackContext instanceof jQuery ) ?
  8156. jQuery( callbackContext ) : jQuery.event,
  8157. // Deferreds
  8158. deferred = jQuery.Deferred(),
  8159. completeDeferred = jQuery.Callbacks( "once memory" ),
  8160. // Status-dependent callbacks
  8161. statusCode = s.statusCode || {},
  8162. // Headers (they are sent all at once)
  8163. requestHeaders = {},
  8164. requestHeadersNames = {},
  8165. // The jqXHR state
  8166. state = 0,
  8167. // Default abort message
  8168. strAbort = "canceled",
  8169. // Fake xhr
  8170. jqXHR = {
  8171. readyState: 0,
  8172. // Caches the header
  8173. setRequestHeader: function( name, value ) {
  8174. if ( !state ) {
  8175. var lname = name.toLowerCase();
  8176. name = requestHeadersNames[ lname ] = requestHeadersNames[ lname ] || name;
  8177. requestHeaders[ name ] = value;
  8178. }
  8179. return this;
  8180. },
  8181. // Raw string
  8182. getAllResponseHeaders: function() {
  8183. return state === 2 ? responseHeadersString : null;
  8184. },
  8185. // Builds headers hashtable if needed
  8186. getResponseHeader: function( key ) {
  8187. var match;
  8188. if ( state === 2 ) {
  8189. if ( !responseHeaders ) {
  8190. responseHeaders = {};
  8191. while( ( match = rheaders.exec( responseHeadersString ) ) ) {
  8192. responseHeaders[ match[1].toLowerCase() ] = match[ 2 ];
  8193. }
  8194. }
  8195. match = responseHeaders[ key.toLowerCase() ];
  8196. }
  8197. return match === undefined ? null : match;
  8198. },
  8199. // Overrides response content-type header
  8200. overrideMimeType: function( type ) {
  8201. if ( !state ) {
  8202. s.mimeType = type;
  8203. }
  8204. return this;
  8205. },
  8206. // Cancel the request
  8207. abort: function( statusText ) {
  8208. statusText = statusText || strAbort;
  8209. if ( transport ) {
  8210. transport.abort( statusText );
  8211. }
  8212. done( 0, statusText );
  8213. return this;
  8214. }
  8215. };
  8216. // Callback for when everything is done
  8217. // It is defined here because jslint complains if it is declared
  8218. // at the end of the function (which would be more logical and readable)
  8219. function done( status, nativeStatusText, responses, headers ) {
  8220. var isSuccess, success, error, response, modified,
  8221. statusText = nativeStatusText;
  8222. // Called once
  8223. if ( state === 2 ) {
  8224. return;
  8225. }
  8226. // State is "done" now
  8227. state = 2;
  8228. // Clear timeout if it exists
  8229. if ( timeoutTimer ) {
  8230. clearTimeout( timeoutTimer );
  8231. }
  8232. // Dereference transport for early garbage collection
  8233. // (no matter how long the jqXHR object will be used)
  8234. transport = undefined;
  8235. // Cache response headers
  8236. responseHeadersString = headers || "";
  8237. // Set readyState
  8238. jqXHR.readyState = status > 0 ? 4 : 0;
  8239. // Get response data
  8240. if ( responses ) {
  8241. response = ajaxHandleResponses( s, jqXHR, responses );
  8242. }
  8243. // If successful, handle type chaining
  8244. if ( status >= 200 && status < 300 || status === 304 ) {
  8245. // Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode.
  8246. if ( s.ifModified ) {
  8247. modified = jqXHR.getResponseHeader("Last-Modified");
  8248. if ( modified ) {
  8249. jQuery.lastModified[ ifModifiedKey ] = modified;
  8250. }
  8251. modified = jqXHR.getResponseHeader("Etag");
  8252. if ( modified ) {
  8253. jQuery.etag[ ifModifiedKey ] = modified;
  8254. }
  8255. }
  8256. // If not modified
  8257. if ( status === 304 ) {
  8258. statusText = "notmodified";
  8259. isSuccess = true;
  8260. // If we have data
  8261. } else {
  8262. isSuccess = ajaxConvert( s, response );
  8263. statusText = isSuccess.state;
  8264. success = isSuccess.data;
  8265. error = isSuccess.error;
  8266. isSuccess = !error;
  8267. }
  8268. } else {
  8269. // We extract error from statusText
  8270. // then normalize statusText and status for non-aborts
  8271. error = statusText;
  8272. if ( !statusText || status ) {
  8273. statusText = "error";
  8274. if ( status < 0 ) {
  8275. status = 0;
  8276. }
  8277. }
  8278. }
  8279. // Set data for the fake xhr object
  8280. jqXHR.status = status;
  8281. jqXHR.statusText = ( nativeStatusText || statusText ) + "";
  8282. // Success/Error
  8283. if ( isSuccess ) {
  8284. deferred.resolveWith( callbackContext, [ success, statusText, jqXHR ] );
  8285. } else {
  8286. deferred.rejectWith( callbackContext, [ jqXHR, statusText, error ] );
  8287. }
  8288. // Status-dependent callbacks
  8289. jqXHR.statusCode( statusCode );
  8290. statusCode = undefined;
  8291. if ( fireGlobals ) {
  8292. globalEventContext.trigger( "ajax" + ( isSuccess ? "Success" : "Error" ),
  8293. [ jqXHR, s, isSuccess ? success : error ] );
  8294. }
  8295. // Complete
  8296. completeDeferred.fireWith( callbackContext, [ jqXHR, statusText ] );
  8297. if ( fireGlobals ) {
  8298. globalEventContext.trigger( "ajaxComplete", [ jqXHR, s ] );
  8299. // Handle the global AJAX counter
  8300. if ( !( --jQuery.active ) ) {
  8301. jQuery.event.trigger( "ajaxStop" );
  8302. }
  8303. }
  8304. }
  8305. // Attach deferreds
  8306. deferred.promise( jqXHR );
  8307. jqXHR.success = jqXHR.done;
  8308. jqXHR.error = jqXHR.fail;
  8309. jqXHR.complete = completeDeferred.add;
  8310. // Status-dependent callbacks
  8311. jqXHR.statusCode = function( map ) {
  8312. if ( map ) {
  8313. var tmp;
  8314. if ( state < 2 ) {
  8315. for ( tmp in map ) {
  8316. statusCode[ tmp ] = [ statusCode[tmp], map[tmp] ];
  8317. }
  8318. } else {
  8319. tmp = map[ jqXHR.status ];
  8320. jqXHR.always( tmp );
  8321. }
  8322. }
  8323. return this;
  8324. };
  8325. // Remove hash character (#7531: and string promotion)
  8326. // Add protocol if not provided (#5866: IE7 issue with protocol-less urls)
  8327. // We also use the url parameter if available
  8328. s.url = ( ( url || s.url ) + "" ).replace( rhash, "" ).replace( rprotocol, ajaxLocParts[ 1 ] + "//" );
  8329. // Extract dataTypes list
  8330. s.dataTypes = jQuery.trim( s.dataType || "*" ).toLowerCase().split( core_rspace );
  8331. // A cross-domain request is in order when we have a protocol:host:port mismatch
  8332. if ( s.crossDomain == null ) {
  8333. parts = rurl.exec( s.url.toLowerCase() ) || false;
  8334. s.crossDomain = parts && ( parts.join(":") + ( parts[ 3 ] ? "" : parts[ 1 ] === "http:" ? 80 : 443 ) ) !==
  8335. ( ajaxLocParts.join(":") + ( ajaxLocParts[ 3 ] ? "" : ajaxLocParts[ 1 ] === "http:" ? 80 : 443 ) );
  8336. }
  8337. // Convert data if not already a string
  8338. if ( s.data && s.processData && typeof s.data !== "string" ) {
  8339. s.data = jQuery.param( s.data, s.traditional );
  8340. }
  8341. // Apply prefilters
  8342. inspectPrefiltersOrTransports( prefilters, s, options, jqXHR );
  8343. // If request was aborted inside a prefilter, stop there
  8344. if ( state === 2 ) {
  8345. return jqXHR;
  8346. }
  8347. // We can fire global events as of now if asked to
  8348. fireGlobals = s.global;
  8349. // Uppercase the type
  8350. s.type = s.type.toUpperCase();
  8351. // Determine if request has content
  8352. s.hasContent = !rnoContent.test( s.type );
  8353. // Watch for a new set of requests
  8354. if ( fireGlobals && jQuery.active++ === 0 ) {
  8355. jQuery.event.trigger( "ajaxStart" );
  8356. }
  8357. // More options handling for requests with no content
  8358. if ( !s.hasContent ) {
  8359. // If data is available, append data to url
  8360. if ( s.data ) {
  8361. s.url += ( rquery.test( s.url ) ? "&" : "?" ) + s.data;
  8362. // #9682: remove data so that it's not used in an eventual retry
  8363. delete s.data;
  8364. }
  8365. // Get ifModifiedKey before adding the anti-cache parameter
  8366. ifModifiedKey = s.url;
  8367. // Add anti-cache in url if needed
  8368. if ( s.cache === false ) {
  8369. var ts = jQuery.now(),
  8370. // try replacing _= if it is there
  8371. ret = s.url.replace( rts, "$1_=" + ts );
  8372. // if nothing was replaced, add timestamp to the end
  8373. s.url = ret + ( ( ret === s.url ) ? ( rquery.test( s.url ) ? "&" : "?" ) + "_=" + ts : "" );
  8374. }
  8375. }
  8376. // Set the correct header, if data is being sent
  8377. if ( s.data && s.hasContent && s.contentType !== false || options.contentType ) {
  8378. jqXHR.setRequestHeader( "Content-Type", s.contentType );
  8379. }
  8380. // Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode.
  8381. if ( s.ifModified ) {
  8382. ifModifiedKey = ifModifiedKey || s.url;
  8383. if ( jQuery.lastModified[ ifModifiedKey ] ) {
  8384. jqXHR.setRequestHeader( "If-Modified-Since", jQuery.lastModified[ ifModifiedKey ] );
  8385. }
  8386. if ( jQuery.etag[ ifModifiedKey ] ) {
  8387. jqXHR.setRequestHeader( "If-None-Match", jQuery.etag[ ifModifiedKey ] );
  8388. }
  8389. }
  8390. // Set the Accepts header for the server, depending on the dataType
  8391. jqXHR.setRequestHeader(
  8392. "Accept",
  8393. s.dataTypes[ 0 ] && s.accepts[ s.dataTypes[0] ] ?
  8394. s.accepts[ s.dataTypes[0] ] + ( s.dataTypes[ 0 ] !== "*" ? ", " + allTypes + "; q=0.01" : "" ) :
  8395. s.accepts[ "*" ]
  8396. );
  8397. // Check for headers option
  8398. for ( i in s.headers ) {
  8399. jqXHR.setRequestHeader( i, s.headers[ i ] );
  8400. }
  8401. // Allow custom headers/mimetypes and early abort
  8402. if ( s.beforeSend && ( s.beforeSend.call( callbackContext, jqXHR, s ) === false || state === 2 ) ) {
  8403. // Abort if not done already and return
  8404. return jqXHR.abort();
  8405. }
  8406. // aborting is no longer a cancellation
  8407. strAbort = "abort";
  8408. // Install callbacks on deferreds
  8409. for ( i in { success: 1, error: 1, complete: 1 } ) {
  8410. jqXHR[ i ]( s[ i ] );
  8411. }
  8412. // Get transport
  8413. transport = inspectPrefiltersOrTransports( transports, s, options, jqXHR );
  8414. // If no transport, we auto-abort
  8415. if ( !transport ) {
  8416. done( -1, "No Transport" );
  8417. } else {
  8418. jqXHR.readyState = 1;
  8419. // Send global event
  8420. if ( fireGlobals ) {
  8421. globalEventContext.trigger( "ajaxSend", [ jqXHR, s ] );
  8422. }
  8423. // Timeout
  8424. if ( s.async && s.timeout > 0 ) {
  8425. timeoutTimer = setTimeout( function(){
  8426. jqXHR.abort( "timeout" );
  8427. }, s.timeout );
  8428. }
  8429. try {
  8430. state = 1;
  8431. transport.send( requestHeaders, done );
  8432. } catch (e) {
  8433. // Propagate exception as error if not done
  8434. if ( state < 2 ) {
  8435. done( -1, e );
  8436. // Simply rethrow otherwise
  8437. } else {
  8438. throw e;
  8439. }
  8440. }
  8441. }
  8442. return jqXHR;
  8443. },
  8444. // Counter for holding the number of active queries
  8445. active: 0,
  8446. // Last-Modified header cache for next request
  8447. lastModified: {},
  8448. etag: {}
  8449. });
  8450. /* Handles responses to an ajax request:
  8451. * - sets all responseXXX fields accordingly
  8452. * - finds the right dataType (mediates between content-type and expected dataType)
  8453. * - returns the corresponding response
  8454. */
  8455. function ajaxHandleResponses( s, jqXHR, responses ) {
  8456. var ct, type, finalDataType, firstDataType,
  8457. contents = s.contents,
  8458. dataTypes = s.dataTypes,
  8459. responseFields = s.responseFields;
  8460. // Fill responseXXX fields
  8461. for ( type in responseFields ) {
  8462. if ( type in responses ) {
  8463. jqXHR[ responseFields[type] ] = responses[ type ];
  8464. }
  8465. }
  8466. // Remove auto dataType and get content-type in the process
  8467. while( dataTypes[ 0 ] === "*" ) {
  8468. dataTypes.shift();
  8469. if ( ct === undefined ) {
  8470. ct = s.mimeType || jqXHR.getResponseHeader( "content-type" );
  8471. }
  8472. }
  8473. // Check if we're dealing with a known content-type
  8474. if ( ct ) {
  8475. for ( type in contents ) {
  8476. if ( contents[ type ] && contents[ type ].test( ct ) ) {
  8477. dataTypes.unshift( type );
  8478. break;
  8479. }
  8480. }
  8481. }
  8482. // Check to see if we have a response for the expected dataType
  8483. if ( dataTypes[ 0 ] in responses ) {
  8484. finalDataType = dataTypes[ 0 ];
  8485. } else {
  8486. // Try convertible dataTypes
  8487. for ( type in responses ) {
  8488. if ( !dataTypes[ 0 ] || s.converters[ type + " " + dataTypes[0] ] ) {
  8489. finalDataType = type;
  8490. break;
  8491. }
  8492. if ( !firstDataType ) {
  8493. firstDataType = type;
  8494. }
  8495. }
  8496. // Or just use first one
  8497. finalDataType = finalDataType || firstDataType;
  8498. }
  8499. // If we found a dataType
  8500. // We add the dataType to the list if needed
  8501. // and return the corresponding response
  8502. if ( finalDataType ) {
  8503. if ( finalDataType !== dataTypes[ 0 ] ) {
  8504. dataTypes.unshift( finalDataType );
  8505. }
  8506. return responses[ finalDataType ];
  8507. }
  8508. }
  8509. // Chain conversions given the request and the original response
  8510. function ajaxConvert( s, response ) {
  8511. var conv, conv2, current, tmp,
  8512. // Work with a copy of dataTypes in case we need to modify it for conversion
  8513. dataTypes = s.dataTypes.slice(),
  8514. prev = dataTypes[ 0 ],
  8515. converters = {},
  8516. i = 0;
  8517. // Apply the dataFilter if provided
  8518. if ( s.dataFilter ) {
  8519. response = s.dataFilter( response, s.dataType );
  8520. }
  8521. // Create converters map with lowercased keys
  8522. if ( dataTypes[ 1 ] ) {
  8523. for ( conv in s.converters ) {
  8524. converters[ conv.toLowerCase() ] = s.converters[ conv ];
  8525. }
  8526. }
  8527. // Convert to each sequential dataType, tolerating list modification
  8528. for ( ; (current = dataTypes[++i]); ) {
  8529. // There's only work to do if current dataType is non-auto
  8530. if ( current !== "*" ) {
  8531. // Convert response if prev dataType is non-auto and differs from current
  8532. if ( prev !== "*" && prev !== current ) {
  8533. // Seek a direct converter
  8534. conv = converters[ prev + " " + current ] || converters[ "* " + current ];
  8535. // If none found, seek a pair
  8536. if ( !conv ) {
  8537. for ( conv2 in converters ) {
  8538. // If conv2 outputs current
  8539. tmp = conv2.split(" ");
  8540. if ( tmp[ 1 ] === current ) {
  8541. // If prev can be converted to accepted input
  8542. conv = converters[ prev + " " + tmp[ 0 ] ] ||
  8543. converters[ "* " + tmp[ 0 ] ];
  8544. if ( conv ) {
  8545. // Condense equivalence converters
  8546. if ( conv === true ) {
  8547. conv = converters[ conv2 ];
  8548. // Otherwise, insert the intermediate dataType
  8549. } else if ( converters[ conv2 ] !== true ) {
  8550. current = tmp[ 0 ];
  8551. dataTypes.splice( i--, 0, current );
  8552. }
  8553. break;
  8554. }
  8555. }
  8556. }
  8557. }
  8558. // Apply converter (if not an equivalence)
  8559. if ( conv !== true ) {
  8560. // Unless errors are allowed to bubble, catch and return them
  8561. if ( conv && s["throws"] ) {
  8562. response = conv( response );
  8563. } else {
  8564. try {
  8565. response = conv( response );
  8566. } catch ( e ) {
  8567. return { state: "parsererror", error: conv ? e : "No conversion from " + prev + " to " + current };
  8568. }
  8569. }
  8570. }
  8571. }
  8572. // Update prev for next iteration
  8573. prev = current;
  8574. }
  8575. }
  8576. return { state: "success", data: response };
  8577. }
  8578. var oldCallbacks = [],
  8579. rquestion = /\?/,
  8580. rjsonp = /(=)\?(?=&|$)|\?\?/,
  8581. nonce = jQuery.now();
  8582. // Default jsonp settings
  8583. jQuery.ajaxSetup({
  8584. jsonp: "callback",
  8585. jsonpCallback: function() {
  8586. var callback = oldCallbacks.pop() || ( jQuery.expando + "_" + ( nonce++ ) );
  8587. this[ callback ] = true;
  8588. return callback;
  8589. }
  8590. });
  8591. // Detect, normalize options and install callbacks for jsonp requests
  8592. jQuery.ajaxPrefilter( "json jsonp", function( s, originalSettings, jqXHR ) {
  8593. var callbackName, overwritten, responseContainer,
  8594. data = s.data,
  8595. url = s.url,
  8596. hasCallback = s.jsonp !== false,
  8597. replaceInUrl = hasCallback && rjsonp.test( url ),
  8598. replaceInData = hasCallback && !replaceInUrl && typeof data === "string" &&
  8599. !( s.contentType || "" ).indexOf("application/x-www-form-urlencoded") &&
  8600. rjsonp.test( data );
  8601. // Handle iff the expected data type is "jsonp" or we have a parameter to set
  8602. if ( s.dataTypes[ 0 ] === "jsonp" || replaceInUrl || replaceInData ) {
  8603. // Get callback name, remembering preexisting value associated with it
  8604. callbackName = s.jsonpCallback = jQuery.isFunction( s.jsonpCallback ) ?
  8605. s.jsonpCallback() :
  8606. s.jsonpCallback;
  8607. overwritten = window[ callbackName ];
  8608. // Insert callback into url or form data
  8609. if ( replaceInUrl ) {
  8610. s.url = url.replace( rjsonp, "$1" + callbackName );
  8611. } else if ( replaceInData ) {
  8612. s.data = data.replace( rjsonp, "$1" + callbackName );
  8613. } else if ( hasCallback ) {
  8614. s.url += ( rquestion.test( url ) ? "&" : "?" ) + s.jsonp + "=" + callbackName;
  8615. }
  8616. // Use data converter to retrieve json after script execution
  8617. s.converters["script json"] = function() {
  8618. if ( !responseContainer ) {
  8619. jQuery.error( callbackName + " was not called" );
  8620. }
  8621. return responseContainer[ 0 ];
  8622. };
  8623. // force json dataType
  8624. s.dataTypes[ 0 ] = "json";
  8625. // Install callback
  8626. window[ callbackName ] = function() {
  8627. responseContainer = arguments;
  8628. };
  8629. // Clean-up function (fires after converters)
  8630. jqXHR.always(function() {
  8631. // Restore preexisting value
  8632. window[ callbackName ] = overwritten;
  8633. // Save back as free
  8634. if ( s[ callbackName ] ) {
  8635. // make sure that re-using the options doesn't screw things around
  8636. s.jsonpCallback = originalSettings.jsonpCallback;
  8637. // save the callback name for future use
  8638. oldCallbacks.push( callbackName );
  8639. }
  8640. // Call if it was a function and we have a response
  8641. if ( responseContainer && jQuery.isFunction( overwritten ) ) {
  8642. overwritten( responseContainer[ 0 ] );
  8643. }
  8644. responseContainer = overwritten = undefined;
  8645. });
  8646. // Delegate to script
  8647. return "script";
  8648. }
  8649. });
  8650. // Install script dataType
  8651. jQuery.ajaxSetup({
  8652. accepts: {
  8653. script: "text/javascript, application/javascript, application/ecmascript, application/x-ecmascript"
  8654. },
  8655. contents: {
  8656. script: /javascript|ecmascript/
  8657. },
  8658. converters: {
  8659. "text script": function( text ) {
  8660. jQuery.globalEval( text );
  8661. return text;
  8662. }
  8663. }
  8664. });
  8665. // Handle cache's special case and global
  8666. jQuery.ajaxPrefilter( "script", function( s ) {
  8667. if ( s.cache === undefined ) {
  8668. s.cache = false;
  8669. }
  8670. if ( s.crossDomain ) {
  8671. s.type = "GET";
  8672. s.global = false;
  8673. }
  8674. });
  8675. // Bind script tag hack transport
  8676. jQuery.ajaxTransport( "script", function(s) {
  8677. // This transport only deals with cross domain requests
  8678. if ( s.crossDomain ) {
  8679. var script,
  8680. head = document.head || document.getElementsByTagName( "head" )[0] || document.documentElement;
  8681. return {
  8682. send: function( _, callback ) {
  8683. script = document.createElement( "script" );
  8684. script.async = "async";
  8685. if ( s.scriptCharset ) {
  8686. script.charset = s.scriptCharset;
  8687. }
  8688. script.src = s.url;
  8689. // Attach handlers for all browsers
  8690. script.onload = script.onreadystatechange = function( _, isAbort ) {
  8691. if ( isAbort || !script.readyState || /loaded|complete/.test( script.readyState ) ) {
  8692. // Handle memory leak in IE
  8693. script.onload = script.onreadystatechange = null;
  8694. // Remove the script
  8695. if ( head && script.parentNode ) {
  8696. head.removeChild( script );
  8697. }
  8698. // Dereference the script
  8699. script = undefined;
  8700. // Callback if not abort
  8701. if ( !isAbort ) {
  8702. callback( 200, "success" );
  8703. }
  8704. }
  8705. };
  8706. // Use insertBefore instead of appendChild to circumvent an IE6 bug.
  8707. // This arises when a base node is used (#2709 and #4378).
  8708. head.insertBefore( script, head.firstChild );
  8709. },
  8710. abort: function() {
  8711. if ( script ) {
  8712. script.onload( 0, 1 );
  8713. }
  8714. }
  8715. };
  8716. }
  8717. });
  8718. var xhrCallbacks,
  8719. // #5280: Internet Explorer will keep connections alive if we don't abort on unload
  8720. xhrOnUnloadAbort = window.ActiveXObject ? function() {
  8721. // Abort all pending requests
  8722. for ( var key in xhrCallbacks ) {
  8723. xhrCallbacks[ key ]( 0, 1 );
  8724. }
  8725. } : false,
  8726. xhrId = 0;
  8727. // Functions to create xhrs
  8728. function createStandardXHR() {
  8729. try {
  8730. return new window.XMLHttpRequest();
  8731. } catch( e ) {}
  8732. }
  8733. function createActiveXHR() {
  8734. try {
  8735. return new window.ActiveXObject( "Microsoft.XMLHTTP" );
  8736. } catch( e ) {}
  8737. }
  8738. // Create the request object
  8739. // (This is still attached to ajaxSettings for backward compatibility)
  8740. jQuery.ajaxSettings.xhr = window.ActiveXObject ?
  8741. /* Microsoft failed to properly
  8742. * implement the XMLHttpRequest in IE7 (can't request local files),
  8743. * so we use the ActiveXObject when it is available
  8744. * Additionally XMLHttpRequest can be disabled in IE7/IE8 so
  8745. * we need a fallback.
  8746. */
  8747. function() {
  8748. return !this.isLocal && createStandardXHR() || createActiveXHR();
  8749. } :
  8750. // For all other browsers, use the standard XMLHttpRequest object
  8751. createStandardXHR;
  8752. // Determine support properties
  8753. (function( xhr ) {
  8754. jQuery.extend( jQuery.support, {
  8755. ajax: !!xhr,
  8756. cors: !!xhr && ( "withCredentials" in xhr )
  8757. });
  8758. })( jQuery.ajaxSettings.xhr() );
  8759. // Create transport if the browser can provide an xhr
  8760. if ( jQuery.support.ajax ) {
  8761. jQuery.ajaxTransport(function( s ) {
  8762. // Cross domain only allowed if supported through XMLHttpRequest
  8763. if ( !s.crossDomain || jQuery.support.cors ) {
  8764. var callback;
  8765. return {
  8766. send: function( headers, complete ) {
  8767. // Get a new xhr
  8768. var handle, i,
  8769. xhr = s.xhr();
  8770. // Open the socket
  8771. // Passing null username, generates a login popup on Opera (#2865)
  8772. if ( s.username ) {
  8773. xhr.open( s.type, s.url, s.async, s.username, s.password );
  8774. } else {
  8775. xhr.open( s.type, s.url, s.async );
  8776. }
  8777. // Apply custom fields if provided
  8778. if ( s.xhrFields ) {
  8779. for ( i in s.xhrFields ) {
  8780. xhr[ i ] = s.xhrFields[ i ];
  8781. }
  8782. }
  8783. // Override mime type if needed
  8784. if ( s.mimeType && xhr.overrideMimeType ) {
  8785. xhr.overrideMimeType( s.mimeType );
  8786. }
  8787. // X-Requested-With header
  8788. // For cross-domain requests, seeing as conditions for a preflight are
  8789. // akin to a jigsaw puzzle, we simply never set it to be sure.
  8790. // (it can always be set on a per-request basis or even using ajaxSetup)
  8791. // For same-domain requests, won't change header if already provided.
  8792. if ( !s.crossDomain && !headers["X-Requested-With"] ) {
  8793. headers[ "X-Requested-With" ] = "XMLHttpRequest";
  8794. }
  8795. // Need an extra try/catch for cross domain requests in Firefox 3
  8796. try {
  8797. for ( i in headers ) {
  8798. xhr.setRequestHeader( i, headers[ i ] );
  8799. }
  8800. } catch( _ ) {}
  8801. // Do send the request
  8802. // This may raise an exception which is actually
  8803. // handled in jQuery.ajax (so no try/catch here)
  8804. xhr.send( ( s.hasContent && s.data ) || null );
  8805. // Listener
  8806. callback = function( _, isAbort ) {
  8807. var status,
  8808. statusText,
  8809. responseHeaders,
  8810. responses,
  8811. xml;
  8812. // Firefox throws exceptions when accessing properties
  8813. // of an xhr when a network error occurred
  8814. // http://helpful.knobs-dials.com/index.php/Component_returned_failure_code:_0x80040111_(NS_ERROR_NOT_AVAILABLE)
  8815. try {
  8816. // Was never called and is aborted or complete
  8817. if ( callback && ( isAbort || xhr.readyState === 4 ) ) {
  8818. // Only called once
  8819. callback = undefined;
  8820. // Do not keep as active anymore
  8821. if ( handle ) {
  8822. xhr.onreadystatechange = jQuery.noop;
  8823. if ( xhrOnUnloadAbort ) {
  8824. delete xhrCallbacks[ handle ];
  8825. }
  8826. }
  8827. // If it's an abort
  8828. if ( isAbort ) {
  8829. // Abort it manually if needed
  8830. if ( xhr.readyState !== 4 ) {
  8831. xhr.abort();
  8832. }
  8833. } else {
  8834. status = xhr.status;
  8835. responseHeaders = xhr.getAllResponseHeaders();
  8836. responses = {};
  8837. xml = xhr.responseXML;
  8838. // Construct response list
  8839. if ( xml && xml.documentElement /* #4958 */ ) {
  8840. responses.xml = xml;
  8841. }
  8842. // When requesting binary data, IE6-9 will throw an exception
  8843. // on any attempt to access responseText (#11426)
  8844. try {
  8845. responses.text = xhr.responseText;
  8846. } catch( _ ) {
  8847. }
  8848. // Firefox throws an exception when accessing
  8849. // statusText for faulty cross-domain requests
  8850. try {
  8851. statusText = xhr.statusText;
  8852. } catch( e ) {
  8853. // We normalize with Webkit giving an empty statusText
  8854. statusText = "";
  8855. }
  8856. // Filter status for non standard behaviors
  8857. // If the request is local and we have data: assume a success
  8858. // (success with no data won't get notified, that's the best we
  8859. // can do given current implementations)
  8860. if ( !status && s.isLocal && !s.crossDomain ) {
  8861. status = responses.text ? 200 : 404;
  8862. // IE - #1450: sometimes returns 1223 when it should be 204
  8863. } else if ( status === 1223 ) {
  8864. status = 204;
  8865. }
  8866. }
  8867. }
  8868. } catch( firefoxAccessException ) {
  8869. if ( !isAbort ) {
  8870. complete( -1, firefoxAccessException );
  8871. }
  8872. }
  8873. // Call complete if needed
  8874. if ( responses ) {
  8875. complete( status, statusText, responses, responseHeaders );
  8876. }
  8877. };
  8878. if ( !s.async ) {
  8879. // if we're in sync mode we fire the callback
  8880. callback();
  8881. } else if ( xhr.readyState === 4 ) {
  8882. // (IE6 & IE7) if it's in cache and has been
  8883. // retrieved directly we need to fire the callback
  8884. setTimeout( callback, 0 );
  8885. } else {
  8886. handle = ++xhrId;
  8887. if ( xhrOnUnloadAbort ) {
  8888. // Create the active xhrs callbacks list if needed
  8889. // and attach the unload handler
  8890. if ( !xhrCallbacks ) {
  8891. xhrCallbacks = {};
  8892. jQuery( window ).unload( xhrOnUnloadAbort );
  8893. }
  8894. // Add to list of active xhrs callbacks
  8895. xhrCallbacks[ handle ] = callback;
  8896. }
  8897. xhr.onreadystatechange = callback;
  8898. }
  8899. },
  8900. abort: function() {
  8901. if ( callback ) {
  8902. callback(0,1);
  8903. }
  8904. }
  8905. };
  8906. }
  8907. });
  8908. }
  8909. var fxNow, timerId,
  8910. rfxtypes = /^(?:toggle|show|hide)$/,
  8911. rfxnum = new RegExp( "^(?:([-+])=|)(" + core_pnum + ")([a-z%]*)$", "i" ),
  8912. rrun = /queueHooks$/,
  8913. animationPrefilters = [ defaultPrefilter ],
  8914. tweeners = {
  8915. "*": [function( prop, value ) {
  8916. var end, unit,
  8917. tween = this.createTween( prop, value ),
  8918. parts = rfxnum.exec( value ),
  8919. target = tween.cur(),
  8920. start = +target || 0,
  8921. scale = 1,
  8922. maxIterations = 20;
  8923. if ( parts ) {
  8924. end = +parts[2];
  8925. unit = parts[3] || ( jQuery.cssNumber[ prop ] ? "" : "px" );
  8926. // We need to compute starting value
  8927. if ( unit !== "px" && start ) {
  8928. // Iteratively approximate from a nonzero starting point
  8929. // Prefer the current property, because this process will be trivial if it uses the same units
  8930. // Fallback to end or a simple constant
  8931. start = jQuery.css( tween.elem, prop, true ) || end || 1;
  8932. do {
  8933. // If previous iteration zeroed out, double until we get *something*
  8934. // Use a string for doubling factor so we don't accidentally see scale as unchanged below
  8935. scale = scale || ".5";
  8936. // Adjust and apply
  8937. start = start / scale;
  8938. jQuery.style( tween.elem, prop, start + unit );
  8939. // Update scale, tolerating zero or NaN from tween.cur()
  8940. // And breaking the loop if scale is unchanged or perfect, or if we've just had enough
  8941. } while ( scale !== (scale = tween.cur() / target) && scale !== 1 && --maxIterations );
  8942. }
  8943. tween.unit = unit;
  8944. tween.start = start;
  8945. // If a +=/-= token was provided, we're doing a relative animation
  8946. tween.end = parts[1] ? start + ( parts[1] + 1 ) * end : end;
  8947. }
  8948. return tween;
  8949. }]
  8950. };
  8951. // Animations created synchronously will run synchronously
  8952. function createFxNow() {
  8953. setTimeout(function() {
  8954. fxNow = undefined;
  8955. }, 0 );
  8956. return ( fxNow = jQuery.now() );
  8957. }
  8958. function createTweens( animation, props ) {
  8959. jQuery.each( props, function( prop, value ) {
  8960. var collection = ( tweeners[ prop ] || [] ).concat( tweeners[ "*" ] ),
  8961. index = 0,
  8962. length = collection.length;
  8963. for ( ; index < length; index++ ) {
  8964. if ( collection[ index ].call( animation, prop, value ) ) {
  8965. // we're done with this property
  8966. return;
  8967. }
  8968. }
  8969. });
  8970. }
  8971. function Animation( elem, properties, options ) {
  8972. var result,
  8973. index = 0,
  8974. tweenerIndex = 0,
  8975. length = animationPrefilters.length,
  8976. deferred = jQuery.Deferred().always( function() {
  8977. // don't match elem in the :animated selector
  8978. delete tick.elem;
  8979. }),
  8980. tick = function() {
  8981. var currentTime = fxNow || createFxNow(),
  8982. remaining = Math.max( 0, animation.startTime + animation.duration - currentTime ),
  8983. percent = 1 - ( remaining / animation.duration || 0 ),
  8984. index = 0,
  8985. length = animation.tweens.length;
  8986. for ( ; index < length ; index++ ) {
  8987. animation.tweens[ index ].run( percent );
  8988. }
  8989. deferred.notifyWith( elem, [ animation, percent, remaining ]);
  8990. if ( percent < 1 && length ) {
  8991. return remaining;
  8992. } else {
  8993. deferred.resolveWith( elem, [ animation ] );
  8994. return false;
  8995. }
  8996. },
  8997. animation = deferred.promise({
  8998. elem: elem,
  8999. props: jQuery.extend( {}, properties ),
  9000. opts: jQuery.extend( true, { specialEasing: {} }, options ),
  9001. originalProperties: properties,
  9002. originalOptions: options,
  9003. startTime: fxNow || createFxNow(),
  9004. duration: options.duration,
  9005. tweens: [],
  9006. createTween: function( prop, end, easing ) {
  9007. var tween = jQuery.Tween( elem, animation.opts, prop, end,
  9008. animation.opts.specialEasing[ prop ] || animation.opts.easing );
  9009. animation.tweens.push( tween );
  9010. return tween;
  9011. },
  9012. stop: function( gotoEnd ) {
  9013. var index = 0,
  9014. // if we are going to the end, we want to run all the tweens
  9015. // otherwise we skip this part
  9016. length = gotoEnd ? animation.tweens.length : 0;
  9017. for ( ; index < length ; index++ ) {
  9018. animation.tweens[ index ].run( 1 );
  9019. }
  9020. // resolve when we played the last frame
  9021. // otherwise, reject
  9022. if ( gotoEnd ) {
  9023. deferred.resolveWith( elem, [ animation, gotoEnd ] );
  9024. } else {
  9025. deferred.rejectWith( elem, [ animation, gotoEnd ] );
  9026. }
  9027. return this;
  9028. }
  9029. }),
  9030. props = animation.props;
  9031. propFilter( props, animation.opts.specialEasing );
  9032. for ( ; index < length ; index++ ) {
  9033. result = animationPrefilters[ index ].call( animation, elem, props, animation.opts );
  9034. if ( result ) {
  9035. return result;
  9036. }
  9037. }
  9038. createTweens( animation, props );
  9039. if ( jQuery.isFunction( animation.opts.start ) ) {
  9040. animation.opts.start.call( elem, animation );
  9041. }
  9042. jQuery.fx.timer(
  9043. jQuery.extend( tick, {
  9044. anim: animation,
  9045. queue: animation.opts.queue,
  9046. elem: elem
  9047. })
  9048. );
  9049. // attach callbacks from options
  9050. return animation.progress( animation.opts.progress )
  9051. .done( animation.opts.done, animation.opts.complete )
  9052. .fail( animation.opts.fail )
  9053. .always( animation.opts.always );
  9054. }
  9055. function propFilter( props, specialEasing ) {
  9056. var index, name, easing, value, hooks;
  9057. // camelCase, specialEasing and expand cssHook pass
  9058. for ( index in props ) {
  9059. name = jQuery.camelCase( index );
  9060. easing = specialEasing[ name ];
  9061. value = props[ index ];
  9062. if ( jQuery.isArray( value ) ) {
  9063. easing = value[ 1 ];
  9064. value = props[ index ] = value[ 0 ];
  9065. }
  9066. if ( index !== name ) {
  9067. props[ name ] = value;
  9068. delete props[ index ];
  9069. }
  9070. hooks = jQuery.cssHooks[ name ];
  9071. if ( hooks && "expand" in hooks ) {
  9072. value = hooks.expand( value );
  9073. delete props[ name ];
  9074. // not quite $.extend, this wont overwrite keys already present.
  9075. // also - reusing 'index' from above because we have the correct "name"
  9076. for ( index in value ) {
  9077. if ( !( index in props ) ) {
  9078. props[ index ] = value[ index ];
  9079. specialEasing[ index ] = easing;
  9080. }
  9081. }
  9082. } else {
  9083. specialEasing[ name ] = easing;
  9084. }
  9085. }
  9086. }
  9087. jQuery.Animation = jQuery.extend( Animation, {
  9088. tweener: function( props, callback ) {
  9089. if ( jQuery.isFunction( props ) ) {
  9090. callback = props;
  9091. props = [ "*" ];
  9092. } else {
  9093. props = props.split(" ");
  9094. }
  9095. var prop,
  9096. index = 0,
  9097. length = props.length;
  9098. for ( ; index < length ; index++ ) {
  9099. prop = props[ index ];
  9100. tweeners[ prop ] = tweeners[ prop ] || [];
  9101. tweeners[ prop ].unshift( callback );
  9102. }
  9103. },
  9104. prefilter: function( callback, prepend ) {
  9105. if ( prepend ) {
  9106. animationPrefilters.unshift( callback );
  9107. } else {
  9108. animationPrefilters.push( callback );
  9109. }
  9110. }
  9111. });
  9112. function defaultPrefilter( elem, props, opts ) {
  9113. var index, prop, value, length, dataShow, tween, hooks, oldfire,
  9114. anim = this,
  9115. style = elem.style,
  9116. orig = {},
  9117. handled = [],
  9118. hidden = elem.nodeType && isHidden( elem );
  9119. // handle queue: false promises
  9120. if ( !opts.queue ) {
  9121. hooks = jQuery._queueHooks( elem, "fx" );
  9122. if ( hooks.unqueued == null ) {
  9123. hooks.unqueued = 0;
  9124. oldfire = hooks.empty.fire;
  9125. hooks.empty.fire = function() {
  9126. if ( !hooks.unqueued ) {
  9127. oldfire();
  9128. }
  9129. };
  9130. }
  9131. hooks.unqueued++;
  9132. anim.always(function() {
  9133. // doing this makes sure that the complete handler will be called
  9134. // before this completes
  9135. anim.always(function() {
  9136. hooks.unqueued--;
  9137. if ( !jQuery.queue( elem, "fx" ).length ) {
  9138. hooks.empty.fire();
  9139. }
  9140. });
  9141. });
  9142. }
  9143. // height/width overflow pass
  9144. if ( elem.nodeType === 1 && ( "height" in props || "width" in props ) ) {
  9145. // Make sure that nothing sneaks out
  9146. // Record all 3 overflow attributes because IE does not
  9147. // change the overflow attribute when overflowX and
  9148. // overflowY are set to the same value
  9149. opts.overflow = [ style.overflow, style.overflowX, style.overflowY ];
  9150. // Set display property to inline-block for height/width
  9151. // animations on inline elements that are having width/height animated
  9152. if ( jQuery.css( elem, "display" ) === "inline" &&
  9153. jQuery.css( elem, "float" ) === "none" ) {
  9154. // inline-level elements accept inline-block;
  9155. // block-level elements need to be inline with layout
  9156. if ( !jQuery.support.inlineBlockNeedsLayout || css_defaultDisplay( elem.nodeName ) === "inline" ) {
  9157. style.display = "inline-block";
  9158. } else {
  9159. style.zoom = 1;
  9160. }
  9161. }
  9162. }
  9163. if ( opts.overflow ) {
  9164. style.overflow = "hidden";
  9165. if ( !jQuery.support.shrinkWrapBlocks ) {
  9166. anim.done(function() {
  9167. style.overflow = opts.overflow[ 0 ];
  9168. style.overflowX = opts.overflow[ 1 ];
  9169. style.overflowY = opts.overflow[ 2 ];
  9170. });
  9171. }
  9172. }
  9173. // show/hide pass
  9174. for ( index in props ) {
  9175. value = props[ index ];
  9176. if ( rfxtypes.exec( value ) ) {
  9177. delete props[ index ];
  9178. if ( value === ( hidden ? "hide" : "show" ) ) {
  9179. continue;
  9180. }
  9181. handled.push( index );
  9182. }
  9183. }
  9184. length = handled.length;
  9185. if ( length ) {
  9186. dataShow = jQuery._data( elem, "fxshow" ) || jQuery._data( elem, "fxshow", {} );
  9187. if ( hidden ) {
  9188. jQuery( elem ).show();
  9189. } else {
  9190. anim.done(function() {
  9191. jQuery( elem ).hide();
  9192. });
  9193. }
  9194. anim.done(function() {
  9195. var prop;
  9196. jQuery.removeData( elem, "fxshow", true );
  9197. for ( prop in orig ) {
  9198. jQuery.style( elem, prop, orig[ prop ] );
  9199. }
  9200. });
  9201. for ( index = 0 ; index < length ; index++ ) {
  9202. prop = handled[ index ];
  9203. tween = anim.createTween( prop, hidden ? dataShow[ prop ] : 0 );
  9204. orig[ prop ] = dataShow[ prop ] || jQuery.style( elem, prop );
  9205. if ( !( prop in dataShow ) ) {
  9206. dataShow[ prop ] = tween.start;
  9207. if ( hidden ) {
  9208. tween.end = tween.start;
  9209. tween.start = prop === "width" || prop === "height" ? 1 : 0;
  9210. }
  9211. }
  9212. }
  9213. }
  9214. }
  9215. function Tween( elem, options, prop, end, easing ) {
  9216. return new Tween.prototype.init( elem, options, prop, end, easing );
  9217. }
  9218. jQuery.Tween = Tween;
  9219. Tween.prototype = {
  9220. constructor: Tween,
  9221. init: function( elem, options, prop, end, easing, unit ) {
  9222. this.elem = elem;
  9223. this.prop = prop;
  9224. this.easing = easing || "swing";
  9225. this.options = options;
  9226. this.start = this.now = this.cur();
  9227. this.end = end;
  9228. this.unit = unit || ( jQuery.cssNumber[ prop ] ? "" : "px" );
  9229. },
  9230. cur: function() {
  9231. var hooks = Tween.propHooks[ this.prop ];
  9232. return hooks && hooks.get ?
  9233. hooks.get( this ) :
  9234. Tween.propHooks._default.get( this );
  9235. },
  9236. run: function( percent ) {
  9237. var eased,
  9238. hooks = Tween.propHooks[ this.prop ];
  9239. if ( this.options.duration ) {
  9240. this.pos = eased = jQuery.easing[ this.easing ](
  9241. percent, this.options.duration * percent, 0, 1, this.options.duration
  9242. );
  9243. } else {
  9244. this.pos = eased = percent;
  9245. }
  9246. this.now = ( this.end - this.start ) * eased + this.start;
  9247. if ( this.options.step ) {
  9248. this.options.step.call( this.elem, this.now, this );
  9249. }
  9250. if ( hooks && hooks.set ) {
  9251. hooks.set( this );
  9252. } else {
  9253. Tween.propHooks._default.set( this );
  9254. }
  9255. return this;
  9256. }
  9257. };
  9258. Tween.prototype.init.prototype = Tween.prototype;
  9259. Tween.propHooks = {
  9260. _default: {
  9261. get: function( tween ) {
  9262. var result;
  9263. if ( tween.elem[ tween.prop ] != null &&
  9264. (!tween.elem.style || tween.elem.style[ tween.prop ] == null) ) {
  9265. return tween.elem[ tween.prop ];
  9266. }
  9267. // passing any value as a 4th parameter to .css will automatically
  9268. // attempt a parseFloat and fallback to a string if the parse fails
  9269. // so, simple values such as "10px" are parsed to Float.
  9270. // complex values such as "rotate(1rad)" are returned as is.
  9271. result = jQuery.css( tween.elem, tween.prop, false, "" );
  9272. // Empty strings, null, undefined and "auto" are converted to 0.
  9273. return !result || result === "auto" ? 0 : result;
  9274. },
  9275. set: function( tween ) {
  9276. // use step hook for back compat - use cssHook if its there - use .style if its
  9277. // available and use plain properties where available
  9278. if ( jQuery.fx.step[ tween.prop ] ) {
  9279. jQuery.fx.step[ tween.prop ]( tween );
  9280. } else if ( tween.elem.style && ( tween.elem.style[ jQuery.cssProps[ tween.prop ] ] != null || jQuery.cssHooks[ tween.prop ] ) ) {
  9281. jQuery.style( tween.elem, tween.prop, tween.now + tween.unit );
  9282. } else {
  9283. tween.elem[ tween.prop ] = tween.now;
  9284. }
  9285. }
  9286. }
  9287. };
  9288. // Remove in 2.0 - this supports IE8's panic based approach
  9289. // to setting things on disconnected nodes
  9290. Tween.propHooks.scrollTop = Tween.propHooks.scrollLeft = {
  9291. set: function( tween ) {
  9292. if ( tween.elem.nodeType && tween.elem.parentNode ) {
  9293. tween.elem[ tween.prop ] = tween.now;
  9294. }
  9295. }
  9296. };
  9297. jQuery.each([ "toggle", "show", "hide" ], function( i, name ) {
  9298. var cssFn = jQuery.fn[ name ];
  9299. jQuery.fn[ name ] = function( speed, easing, callback ) {
  9300. return speed == null || typeof speed === "boolean" ||
  9301. // special check for .toggle( handler, handler, ... )
  9302. ( !i && jQuery.isFunction( speed ) && jQuery.isFunction( easing ) ) ?
  9303. cssFn.apply( this, arguments ) :
  9304. this.animate( genFx( name, true ), speed, easing, callback );
  9305. };
  9306. });
  9307. jQuery.fn.extend({
  9308. fadeTo: function( speed, to, easing, callback ) {
  9309. // show any hidden elements after setting opacity to 0
  9310. return this.filter( isHidden ).css( "opacity", 0 ).show()
  9311. // animate to the value specified
  9312. .end().animate({ opacity: to }, speed, easing, callback );
  9313. },
  9314. animate: function( prop, speed, easing, callback ) {
  9315. var empty = jQuery.isEmptyObject( prop ),
  9316. optall = jQuery.speed( speed, easing, callback ),
  9317. doAnimation = function() {
  9318. // Operate on a copy of prop so per-property easing won't be lost
  9319. var anim = Animation( this, jQuery.extend( {}, prop ), optall );
  9320. // Empty animations resolve immediately
  9321. if ( empty ) {
  9322. anim.stop( true );
  9323. }
  9324. };
  9325. return empty || optall.queue === false ?
  9326. this.each( doAnimation ) :
  9327. this.queue( optall.queue, doAnimation );
  9328. },
  9329. stop: function( type, clearQueue, gotoEnd ) {
  9330. var stopQueue = function( hooks ) {
  9331. var stop = hooks.stop;
  9332. delete hooks.stop;
  9333. stop( gotoEnd );
  9334. };
  9335. if ( typeof type !== "string" ) {
  9336. gotoEnd = clearQueue;
  9337. clearQueue = type;
  9338. type = undefined;
  9339. }
  9340. if ( clearQueue && type !== false ) {
  9341. this.queue( type || "fx", [] );
  9342. }
  9343. return this.each(function() {
  9344. var dequeue = true,
  9345. index = type != null && type + "queueHooks",
  9346. timers = jQuery.timers,
  9347. data = jQuery._data( this );
  9348. if ( index ) {
  9349. if ( data[ index ] && data[ index ].stop ) {
  9350. stopQueue( data[ index ] );
  9351. }
  9352. } else {
  9353. for ( index in data ) {
  9354. if ( data[ index ] && data[ index ].stop && rrun.test( index ) ) {
  9355. stopQueue( data[ index ] );
  9356. }
  9357. }
  9358. }
  9359. for ( index = timers.length; index--; ) {
  9360. if ( timers[ index ].elem === this && (type == null || timers[ index ].queue === type) ) {
  9361. timers[ index ].anim.stop( gotoEnd );
  9362. dequeue = false;
  9363. timers.splice( index, 1 );
  9364. }
  9365. }
  9366. // start the next in the queue if the last step wasn't forced
  9367. // timers currently will call their complete callbacks, which will dequeue
  9368. // but only if they were gotoEnd
  9369. if ( dequeue || !gotoEnd ) {
  9370. jQuery.dequeue( this, type );
  9371. }
  9372. });
  9373. }
  9374. });
  9375. // Generate parameters to create a standard animation
  9376. function genFx( type, includeWidth ) {
  9377. var which,
  9378. attrs = { height: type },
  9379. i = 0;
  9380. // if we include width, step value is 1 to do all cssExpand values,
  9381. // if we don't include width, step value is 2 to skip over Left and Right
  9382. includeWidth = includeWidth? 1 : 0;
  9383. for( ; i < 4 ; i += 2 - includeWidth ) {
  9384. which = cssExpand[ i ];
  9385. attrs[ "margin" + which ] = attrs[ "padding" + which ] = type;
  9386. }
  9387. if ( includeWidth ) {
  9388. attrs.opacity = attrs.width = type;
  9389. }
  9390. return attrs;
  9391. }
  9392. // Generate shortcuts for custom animations
  9393. jQuery.each({
  9394. slideDown: genFx("show"),
  9395. slideUp: genFx("hide"),
  9396. slideToggle: genFx("toggle"),
  9397. fadeIn: { opacity: "show" },
  9398. fadeOut: { opacity: "hide" },
  9399. fadeToggle: { opacity: "toggle" }
  9400. }, function( name, props ) {
  9401. jQuery.fn[ name ] = function( speed, easing, callback ) {
  9402. return this.animate( props, speed, easing, callback );
  9403. };
  9404. });
  9405. jQuery.speed = function( speed, easing, fn ) {
  9406. var opt = speed && typeof speed === "object" ? jQuery.extend( {}, speed ) : {
  9407. complete: fn || !fn && easing ||
  9408. jQuery.isFunction( speed ) && speed,
  9409. duration: speed,
  9410. easing: fn && easing || easing && !jQuery.isFunction( easing ) && easing
  9411. };
  9412. opt.duration = jQuery.fx.off ? 0 : typeof opt.duration === "number" ? opt.duration :
  9413. opt.duration in jQuery.fx.speeds ? jQuery.fx.speeds[ opt.duration ] : jQuery.fx.speeds._default;
  9414. // normalize opt.queue - true/undefined/null -> "fx"
  9415. if ( opt.queue == null || opt.queue === true ) {
  9416. opt.queue = "fx";
  9417. }
  9418. // Queueing
  9419. opt.old = opt.complete;
  9420. opt.complete = function() {
  9421. if ( jQuery.isFunction( opt.old ) ) {
  9422. opt.old.call( this );
  9423. }
  9424. if ( opt.queue ) {
  9425. jQuery.dequeue( this, opt.queue );
  9426. }
  9427. };
  9428. return opt;
  9429. };
  9430. jQuery.easing = {
  9431. linear: function( p ) {
  9432. return p;
  9433. },
  9434. swing: function( p ) {
  9435. return 0.5 - Math.cos( p*Math.PI ) / 2;
  9436. }
  9437. };
  9438. jQuery.timers = [];
  9439. jQuery.fx = Tween.prototype.init;
  9440. jQuery.fx.tick = function() {
  9441. var timer,
  9442. timers = jQuery.timers,
  9443. i = 0;
  9444. for ( ; i < timers.length; i++ ) {
  9445. timer = timers[ i ];
  9446. // Checks the timer has not already been removed
  9447. if ( !timer() && timers[ i ] === timer ) {
  9448. timers.splice( i--, 1 );
  9449. }
  9450. }
  9451. if ( !timers.length ) {
  9452. jQuery.fx.stop();
  9453. }
  9454. };
  9455. jQuery.fx.timer = function( timer ) {
  9456. if ( timer() && jQuery.timers.push( timer ) && !timerId ) {
  9457. timerId = setInterval( jQuery.fx.tick, jQuery.fx.interval );
  9458. }
  9459. };
  9460. jQuery.fx.interval = 13;
  9461. jQuery.fx.stop = function() {
  9462. clearInterval( timerId );
  9463. timerId = null;
  9464. };
  9465. jQuery.fx.speeds = {
  9466. slow: 600,
  9467. fast: 200,
  9468. // Default speed
  9469. _default: 400
  9470. };
  9471. // Back Compat <1.8 extension point
  9472. jQuery.fx.step = {};
  9473. if ( jQuery.expr && jQuery.expr.filters ) {
  9474. jQuery.expr.filters.animated = function( elem ) {
  9475. return jQuery.grep(jQuery.timers, function( fn ) {
  9476. return elem === fn.elem;
  9477. }).length;
  9478. };
  9479. }
  9480. var rroot = /^(?:body|html)$/i;
  9481. jQuery.fn.offset = function( options ) {
  9482. if ( arguments.length ) {
  9483. return options === undefined ?
  9484. this :
  9485. this.each(function( i ) {
  9486. jQuery.offset.setOffset( this, options, i );
  9487. });
  9488. }
  9489. var docElem, body, win, clientTop, clientLeft, scrollTop, scrollLeft,
  9490. box = { top: 0, left: 0 },
  9491. elem = this[ 0 ],
  9492. doc = elem && elem.ownerDocument;
  9493. if ( !doc ) {
  9494. return;
  9495. }
  9496. if ( (body = doc.body) === elem ) {
  9497. return jQuery.offset.bodyOffset( elem );
  9498. }
  9499. docElem = doc.documentElement;
  9500. // Make sure it's not a disconnected DOM node
  9501. if ( !jQuery.contains( docElem, elem ) ) {
  9502. return box;
  9503. }
  9504. // If we don't have gBCR, just use 0,0 rather than error
  9505. // BlackBerry 5, iOS 3 (original iPhone)
  9506. if ( typeof elem.getBoundingClientRect !== "undefined" ) {
  9507. box = elem.getBoundingClientRect();
  9508. }
  9509. win = getWindow( doc );
  9510. clientTop = docElem.clientTop || body.clientTop || 0;
  9511. clientLeft = docElem.clientLeft || body.clientLeft || 0;
  9512. scrollTop = win.pageYOffset || docElem.scrollTop;
  9513. scrollLeft = win.pageXOffset || docElem.scrollLeft;
  9514. return {
  9515. top: box.top + scrollTop - clientTop,
  9516. left: box.left + scrollLeft - clientLeft
  9517. };
  9518. };
  9519. jQuery.offset = {
  9520. bodyOffset: function( body ) {
  9521. var top = body.offsetTop,
  9522. left = body.offsetLeft;
  9523. if ( jQuery.support.doesNotIncludeMarginInBodyOffset ) {
  9524. top += parseFloat( jQuery.css(body, "marginTop") ) || 0;
  9525. left += parseFloat( jQuery.css(body, "marginLeft") ) || 0;
  9526. }
  9527. return { top: top, left: left };
  9528. },
  9529. setOffset: function( elem, options, i ) {
  9530. var position = jQuery.css( elem, "position" );
  9531. // set position first, in-case top/left are set even on static elem
  9532. if ( position === "static" ) {
  9533. elem.style.position = "relative";
  9534. }
  9535. var curElem = jQuery( elem ),
  9536. curOffset = curElem.offset(),
  9537. curCSSTop = jQuery.css( elem, "top" ),
  9538. curCSSLeft = jQuery.css( elem, "left" ),
  9539. calculatePosition = ( position === "absolute" || position === "fixed" ) && jQuery.inArray("auto", [curCSSTop, curCSSLeft]) > -1,
  9540. props = {}, curPosition = {}, curTop, curLeft;
  9541. // need to be able to calculate position if either top or left is auto and position is either absolute or fixed
  9542. if ( calculatePosition ) {
  9543. curPosition = curElem.position();
  9544. curTop = curPosition.top;
  9545. curLeft = curPosition.left;
  9546. } else {
  9547. curTop = parseFloat( curCSSTop ) || 0;
  9548. curLeft = parseFloat( curCSSLeft ) || 0;
  9549. }
  9550. if ( jQuery.isFunction( options ) ) {
  9551. options = options.call( elem, i, curOffset );
  9552. }
  9553. if ( options.top != null ) {
  9554. props.top = ( options.top - curOffset.top ) + curTop;
  9555. }
  9556. if ( options.left != null ) {
  9557. props.left = ( options.left - curOffset.left ) + curLeft;
  9558. }
  9559. if ( "using" in options ) {
  9560. options.using.call( elem, props );
  9561. } else {
  9562. curElem.css( props );
  9563. }
  9564. }
  9565. };
  9566. jQuery.fn.extend({
  9567. position: function() {
  9568. if ( !this[0] ) {
  9569. return;
  9570. }
  9571. var elem = this[0],
  9572. // Get *real* offsetParent
  9573. offsetParent = this.offsetParent(),
  9574. // Get correct offsets
  9575. offset = this.offset(),
  9576. parentOffset = rroot.test(offsetParent[0].nodeName) ? { top: 0, left: 0 } : offsetParent.offset();
  9577. // Subtract element margins
  9578. // note: when an element has margin: auto the offsetLeft and marginLeft
  9579. // are the same in Safari causing offset.left to incorrectly be 0
  9580. offset.top -= parseFloat( jQuery.css(elem, "marginTop") ) || 0;
  9581. offset.left -= parseFloat( jQuery.css(elem, "marginLeft") ) || 0;
  9582. // Add offsetParent borders
  9583. parentOffset.top += parseFloat( jQuery.css(offsetParent[0], "borderTopWidth") ) || 0;
  9584. parentOffset.left += parseFloat( jQuery.css(offsetParent[0], "borderLeftWidth") ) || 0;
  9585. // Subtract the two offsets
  9586. return {
  9587. top: offset.top - parentOffset.top,
  9588. left: offset.left - parentOffset.left
  9589. };
  9590. },
  9591. offsetParent: function() {
  9592. return this.map(function() {
  9593. var offsetParent = this.offsetParent || document.body;
  9594. while ( offsetParent && (!rroot.test(offsetParent.nodeName) && jQuery.css(offsetParent, "position") === "static") ) {
  9595. offsetParent = offsetParent.offsetParent;
  9596. }
  9597. return offsetParent || document.body;
  9598. });
  9599. }
  9600. });
  9601. // Create scrollLeft and scrollTop methods
  9602. jQuery.each( {scrollLeft: "pageXOffset", scrollTop: "pageYOffset"}, function( method, prop ) {
  9603. var top = /Y/.test( prop );
  9604. jQuery.fn[ method ] = function( val ) {
  9605. return jQuery.access( this, function( elem, method, val ) {
  9606. var win = getWindow( elem );
  9607. if ( val === undefined ) {
  9608. return win ? (prop in win) ? win[ prop ] :
  9609. win.document.documentElement[ method ] :
  9610. elem[ method ];
  9611. }
  9612. if ( win ) {
  9613. win.scrollTo(
  9614. !top ? val : jQuery( win ).scrollLeft(),
  9615. top ? val : jQuery( win ).scrollTop()
  9616. );
  9617. } else {
  9618. elem[ method ] = val;
  9619. }
  9620. }, method, val, arguments.length, null );
  9621. };
  9622. });
  9623. function getWindow( elem ) {
  9624. return jQuery.isWindow( elem ) ?
  9625. elem :
  9626. elem.nodeType === 9 ?
  9627. elem.defaultView || elem.parentWindow :
  9628. false;
  9629. }
  9630. // Create innerHeight, innerWidth, height, width, outerHeight and outerWidth methods
  9631. jQuery.each( { Height: "height", Width: "width" }, function( name, type ) {
  9632. jQuery.each( { padding: "inner" + name, content: type, "": "outer" + name }, function( defaultExtra, funcName ) {
  9633. // margin is only for outerHeight, outerWidth
  9634. jQuery.fn[ funcName ] = function( margin, value ) {
  9635. var chainable = arguments.length && ( defaultExtra || typeof margin !== "boolean" ),
  9636. extra = defaultExtra || ( margin === true || value === true ? "margin" : "border" );
  9637. return jQuery.access( this, function( elem, type, value ) {
  9638. var doc;
  9639. if ( jQuery.isWindow( elem ) ) {
  9640. // As of 5/8/2012 this will yield incorrect results for Mobile Safari, but there
  9641. // isn't a whole lot we can do. See pull request at this URL for discussion:
  9642. // https://github.com/jquery/jquery/pull/764
  9643. return elem.document.documentElement[ "client" + name ];
  9644. }
  9645. // Get document width or height
  9646. if ( elem.nodeType === 9 ) {
  9647. doc = elem.documentElement;
  9648. // Either scroll[Width/Height] or offset[Width/Height] or client[Width/Height], whichever is greatest
  9649. // unfortunately, this causes bug #3838 in IE6/8 only, but there is currently no good, small way to fix it.
  9650. return Math.max(
  9651. elem.body[ "scroll" + name ], doc[ "scroll" + name ],
  9652. elem.body[ "offset" + name ], doc[ "offset" + name ],
  9653. doc[ "client" + name ]
  9654. );
  9655. }
  9656. return value === undefined ?
  9657. // Get width or height on the element, requesting but not forcing parseFloat
  9658. jQuery.css( elem, type, value, extra ) :
  9659. // Set width or height on the element
  9660. jQuery.style( elem, type, value, extra );
  9661. }, type, chainable ? margin : undefined, chainable, null );
  9662. };
  9663. });
  9664. });
  9665. // Expose jQuery to the global object
  9666. window.jQuery = window.$ = jQuery;
  9667. // Expose jQuery as an AMD module, but only for AMD loaders that
  9668. // understand the issues with loading multiple versions of jQuery
  9669. // in a page that all might call define(). The loader will indicate
  9670. // they have special allowances for multiple jQuery versions by
  9671. // specifying define.amd.jQuery = true. Register as a named module,
  9672. // since jQuery can be concatenated with other files that may use define,
  9673. // but not use a proper concatenation script that understands anonymous
  9674. // AMD modules. A named AMD is safest and most robust way to register.
  9675. // Lowercase jquery is used because AMD module names are derived from
  9676. // file names, and jQuery is normally delivered in a lowercase file name.
  9677. // Do this after creating the global so that if an AMD module wants to call
  9678. // noConflict to hide this version of jQuery, it will work.
  9679. if ( typeof define === "function" && define.amd && define.amd.jQuery ) {
  9680. define( "jquery", [], function () { return jQuery; } );
  9681. }
  9682. })( window );