select2.full.js 457 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010
  1. window.$ = window.$ || {};(function() { if ($ && $.fn && $.fn.select2 && $.fn.select2.amd) { define = $.fn.select2.amd.define; require = $.fn.select2.amd.require; }/**
  2. * @license almond 0.2.9 Copyright (c) 2011-2014, The Dojo Foundation All Rights Reserved.
  3. * Available via the MIT or new BSD license.
  4. * see: http://github.com/jrburke/almond for details
  5. */
  6. //Going sloppy to avoid 'use strict' string cost, but strict practices should
  7. //be followed.
  8. /*jslint sloppy: true */
  9. /*global setTimeout: false */
  10. var requirejs, require, define;
  11. (function (undef) {
  12. var main, req, makeMap, handlers,
  13. defined = {},
  14. waiting = {},
  15. config = {},
  16. defining = {},
  17. hasOwn = Object.prototype.hasOwnProperty,
  18. aps = [].slice,
  19. jsSuffixRegExp = /\.js$/;
  20. function hasProp(obj, prop) {
  21. return hasOwn.call(obj, prop);
  22. }
  23. /**
  24. * Given a relative module name, like ./something, normalize it to
  25. * a real name that can be mapped to a path.
  26. * @param {String} name the relative name
  27. * @param {String} baseName a real name that the name arg is relative
  28. * to.
  29. * @returns {String} normalized name
  30. */
  31. function normalize(name, baseName) {
  32. var nameParts, nameSegment, mapValue, foundMap, lastIndex,
  33. foundI, foundStarMap, starI, i, j, part,
  34. baseParts = baseName && baseName.split("/"),
  35. map = config.map,
  36. starMap = (map && map['*']) || {};
  37. //Adjust any relative paths.
  38. if (name && name.charAt(0) === ".") {
  39. //If have a base name, try to normalize against it,
  40. //otherwise, assume it is a top-level require that will
  41. //be relative to baseUrl in the end.
  42. if (baseName) {
  43. //Convert baseName to array, and lop off the last part,
  44. //so that . matches that "directory" and not name of the baseName's
  45. //module. For instance, baseName of "one/two/three", maps to
  46. //"one/two/three.js", but we want the directory, "one/two" for
  47. //this normalization.
  48. baseParts = baseParts.slice(0, baseParts.length - 1);
  49. name = name.split('/');
  50. lastIndex = name.length - 1;
  51. // Node .js allowance:
  52. if (config.nodeIdCompat && jsSuffixRegExp.test(name[lastIndex])) {
  53. name[lastIndex] = name[lastIndex].replace(jsSuffixRegExp, '');
  54. }
  55. name = baseParts.concat(name);
  56. //start trimDots
  57. for (i = 0; i < name.length; i += 1) {
  58. part = name[i];
  59. if (part === ".") {
  60. name.splice(i, 1);
  61. i -= 1;
  62. } else if (part === "..") {
  63. if (i === 1 && (name[2] === '..' || name[0] === '..')) {
  64. //End of the line. Keep at least one non-dot
  65. //path segment at the front so it can be mapped
  66. //correctly to disk. Otherwise, there is likely
  67. //no path mapping for a path starting with '..'.
  68. //This can still fail, but catches the most reasonable
  69. //uses of ..
  70. break;
  71. } else if (i > 0) {
  72. name.splice(i - 1, 2);
  73. i -= 2;
  74. }
  75. }
  76. }
  77. //end trimDots
  78. name = name.join("/");
  79. } else if (name.indexOf('./') === 0) {
  80. // No baseName, so this is ID is resolved relative
  81. // to baseUrl, pull off the leading dot.
  82. name = name.substring(2);
  83. }
  84. }
  85. //Apply map config if available.
  86. if ((baseParts || starMap) && map) {
  87. nameParts = name.split('/');
  88. for (i = nameParts.length; i > 0; i -= 1) {
  89. nameSegment = nameParts.slice(0, i).join("/");
  90. if (baseParts) {
  91. //Find the longest baseName segment match in the config.
  92. //So, do joins on the biggest to smallest lengths of baseParts.
  93. for (j = baseParts.length; j > 0; j -= 1) {
  94. mapValue = map[baseParts.slice(0, j).join('/')];
  95. //baseName segment has config, find if it has one for
  96. //this name.
  97. if (mapValue) {
  98. mapValue = mapValue[nameSegment];
  99. if (mapValue) {
  100. //Match, update name to the new value.
  101. foundMap = mapValue;
  102. foundI = i;
  103. break;
  104. }
  105. }
  106. }
  107. }
  108. if (foundMap) {
  109. break;
  110. }
  111. //Check for a star map match, but just hold on to it,
  112. //if there is a shorter segment match later in a matching
  113. //config, then favor over this star map.
  114. if (!foundStarMap && starMap && starMap[nameSegment]) {
  115. foundStarMap = starMap[nameSegment];
  116. starI = i;
  117. }
  118. }
  119. if (!foundMap && foundStarMap) {
  120. foundMap = foundStarMap;
  121. foundI = starI;
  122. }
  123. if (foundMap) {
  124. nameParts.splice(0, foundI, foundMap);
  125. name = nameParts.join('/');
  126. }
  127. }
  128. return name;
  129. }
  130. function makeRequire(relName, forceSync) {
  131. return function () {
  132. //A version of a require function that passes a moduleName
  133. //value for items that may need to
  134. //look up paths relative to the moduleName
  135. return req.apply(undef, aps.call(arguments, 0).concat([relName, forceSync]));
  136. };
  137. }
  138. function makeNormalize(relName) {
  139. return function (name) {
  140. return normalize(name, relName);
  141. };
  142. }
  143. function makeLoad(depName) {
  144. return function (value) {
  145. defined[depName] = value;
  146. };
  147. }
  148. function callDep(name) {
  149. if (hasProp(waiting, name)) {
  150. var args = waiting[name];
  151. delete waiting[name];
  152. defining[name] = true;
  153. main.apply(undef, args);
  154. }
  155. if (!hasProp(defined, name) && !hasProp(defining, name)) {
  156. throw new Error('No ' + name);
  157. }
  158. return defined[name];
  159. }
  160. //Turns a plugin!resource to [plugin, resource]
  161. //with the plugin being undefined if the name
  162. //did not have a plugin prefix.
  163. function splitPrefix(name) {
  164. var prefix,
  165. index = name ? name.indexOf('!') : -1;
  166. if (index > -1) {
  167. prefix = name.substring(0, index);
  168. name = name.substring(index + 1, name.length);
  169. }
  170. return [prefix, name];
  171. }
  172. /**
  173. * Makes a name map, normalizing the name, and using a plugin
  174. * for normalization if necessary. Grabs a ref to plugin
  175. * too, as an optimization.
  176. */
  177. makeMap = function (name, relName) {
  178. var plugin,
  179. parts = splitPrefix(name),
  180. prefix = parts[0];
  181. name = parts[1];
  182. if (prefix) {
  183. prefix = normalize(prefix, relName);
  184. plugin = callDep(prefix);
  185. }
  186. //Normalize according
  187. if (prefix) {
  188. if (plugin && plugin.normalize) {
  189. name = plugin.normalize(name, makeNormalize(relName));
  190. } else {
  191. name = normalize(name, relName);
  192. }
  193. } else {
  194. name = normalize(name, relName);
  195. parts = splitPrefix(name);
  196. prefix = parts[0];
  197. name = parts[1];
  198. if (prefix) {
  199. plugin = callDep(prefix);
  200. }
  201. }
  202. //Using ridiculous property names for space reasons
  203. return {
  204. f: prefix ? prefix + '!' + name : name, //fullName
  205. n: name,
  206. pr: prefix,
  207. p: plugin
  208. };
  209. };
  210. function makeConfig(name) {
  211. return function () {
  212. return (config && config.config && config.config[name]) || {};
  213. };
  214. }
  215. handlers = {
  216. require: function (name) {
  217. return makeRequire(name);
  218. },
  219. exports: function (name) {
  220. var e = defined[name];
  221. if (typeof e !== 'undefined') {
  222. return e;
  223. } else {
  224. return (defined[name] = {});
  225. }
  226. },
  227. module: function (name) {
  228. return {
  229. id: name,
  230. uri: '',
  231. exports: defined[name],
  232. config: makeConfig(name)
  233. };
  234. }
  235. };
  236. main = function (name, deps, callback, relName) {
  237. var cjsModule, depName, ret, map, i,
  238. args = [],
  239. callbackType = typeof callback,
  240. usingExports;
  241. //Use name if no relName
  242. relName = relName || name;
  243. //Call the callback to define the module, if necessary.
  244. if (callbackType === 'undefined' || callbackType === 'function') {
  245. //Pull out the defined dependencies and pass the ordered
  246. //values to the callback.
  247. //Default to [require, exports, module] if no deps
  248. deps = !deps.length && callback.length ? ['require', 'exports', 'module'] : deps;
  249. for (i = 0; i < deps.length; i += 1) {
  250. map = makeMap(deps[i], relName);
  251. depName = map.f;
  252. //Fast path CommonJS standard dependencies.
  253. if (depName === "require") {
  254. args[i] = handlers.require(name);
  255. } else if (depName === "exports") {
  256. //CommonJS module spec 1.1
  257. args[i] = handlers.exports(name);
  258. usingExports = true;
  259. } else if (depName === "module") {
  260. //CommonJS module spec 1.1
  261. cjsModule = args[i] = handlers.module(name);
  262. } else if (hasProp(defined, depName) ||
  263. hasProp(waiting, depName) ||
  264. hasProp(defining, depName)) {
  265. args[i] = callDep(depName);
  266. } else if (map.p) {
  267. map.p.load(map.n, makeRequire(relName, true), makeLoad(depName), {});
  268. args[i] = defined[depName];
  269. } else {
  270. throw new Error(name + ' missing ' + depName);
  271. }
  272. }
  273. ret = callback ? callback.apply(defined[name], args) : undefined;
  274. if (name) {
  275. //If setting exports via "module" is in play,
  276. //favor that over return value and exports. After that,
  277. //favor a non-undefined return value over exports use.
  278. if (cjsModule && cjsModule.exports !== undef &&
  279. cjsModule.exports !== defined[name]) {
  280. defined[name] = cjsModule.exports;
  281. } else if (ret !== undef || !usingExports) {
  282. //Use the return value from the function.
  283. defined[name] = ret;
  284. }
  285. }
  286. } else if (name) {
  287. //May just be an object definition for the module. Only
  288. //worry about defining if have a module name.
  289. defined[name] = callback;
  290. }
  291. };
  292. requirejs = require = req = function (deps, callback, relName, forceSync, alt) {
  293. if (typeof deps === "string") {
  294. if (handlers[deps]) {
  295. //callback in this case is really relName
  296. return handlers[deps](callback);
  297. }
  298. //Just return the module wanted. In this scenario, the
  299. //deps arg is the module name, and second arg (if passed)
  300. //is just the relName.
  301. //Normalize module name, if it contains . or ..
  302. return callDep(makeMap(deps, callback).f);
  303. } else if (!deps.splice) {
  304. //deps is a config object, not an array.
  305. config = deps;
  306. if (config.deps) {
  307. req(config.deps, config.callback);
  308. }
  309. if (!callback) {
  310. return;
  311. }
  312. if (callback.splice) {
  313. //callback is an array, which means it is a dependency list.
  314. //Adjust args if there are dependencies
  315. deps = callback;
  316. callback = relName;
  317. relName = null;
  318. } else {
  319. deps = undef;
  320. }
  321. }
  322. //Support require(['a'])
  323. callback = callback || function () {};
  324. //If relName is a function, it is an errback handler,
  325. //so remove it.
  326. if (typeof relName === 'function') {
  327. relName = forceSync;
  328. forceSync = alt;
  329. }
  330. //Simulate async callback;
  331. if (forceSync) {
  332. main(undef, deps, callback, relName);
  333. } else {
  334. //Using a non-zero value because of concern for what old browsers
  335. //do, and latest browsers "upgrade" to 4 if lower value is used:
  336. //http://www.whatwg.org/specs/web-apps/current-work/multipage/timers.html#dom-windowtimers-settimeout:
  337. //If want a value immediately, use require('id') instead -- something
  338. //that works in almond on the global level, but not guaranteed and
  339. //unlikely to work in other AMD implementations.
  340. setTimeout(function () {
  341. main(undef, deps, callback, relName);
  342. }, 4);
  343. }
  344. return req;
  345. };
  346. /**
  347. * Just drops the config on the floor, but returns req in case
  348. * the config return value is used.
  349. */
  350. req.config = function (cfg) {
  351. return req(cfg);
  352. };
  353. /**
  354. * Expose module registry for debugging and tooling
  355. */
  356. requirejs._defined = defined;
  357. define = function (name, deps, callback) {
  358. //This module may not have dependencies
  359. if (!deps.splice) {
  360. //deps is not an array, so probably means
  361. //an object literal or factory function for
  362. //the value. Adjust args.
  363. callback = deps;
  364. deps = [];
  365. }
  366. if (!hasProp(defined, name) && !hasProp(waiting, name)) {
  367. waiting[name] = [name, deps, callback];
  368. }
  369. };
  370. define.amd = {
  371. jQuery: true
  372. };
  373. }());
  374. define("almond", function(){});
  375. /*!
  376. * jQuery JavaScript Library v2.1.0
  377. * http://jquery.com/
  378. *
  379. * Includes Sizzle.js
  380. * http://sizzlejs.com/
  381. *
  382. * Copyright 2005, 2014 jQuery Foundation, Inc. and other contributors
  383. * Released under the MIT license
  384. * http://jquery.org/license
  385. *
  386. * Date: 2014-01-23T21:10Z
  387. */
  388. (function( global, factory ) {
  389. if ( typeof module === "object" && typeof module.exports === "object" ) {
  390. // For CommonJS and CommonJS-like environments where a proper window is present,
  391. // execute the factory and get jQuery
  392. // For environments that do not inherently posses a window with a document
  393. // (such as Node.js), expose a jQuery-making factory as module.exports
  394. // This accentuates the need for the creation of a real window
  395. // e.g. var jQuery = require("jquery")(window);
  396. // See ticket #14549 for more info
  397. module.exports = global.document ?
  398. factory( global, true ) :
  399. function( w ) {
  400. if ( !w.document ) {
  401. throw new Error( "jQuery requires a window with a document" );
  402. }
  403. return factory( w );
  404. };
  405. } else {
  406. factory( global );
  407. }
  408. // Pass this if window is not defined yet
  409. }(typeof window !== "undefined" ? window : this, function( window, noGlobal ) {
  410. // Can't do this because several apps including ASP.NET trace
  411. // the stack via arguments.caller.callee and Firefox dies if
  412. // you try to trace through "use strict" call chains. (#13335)
  413. // Support: Firefox 18+
  414. //
  415. var arr = [];
  416. var slice = arr.slice;
  417. var concat = arr.concat;
  418. var push = arr.push;
  419. var indexOf = arr.indexOf;
  420. var class2type = {};
  421. var toString = class2type.toString;
  422. var hasOwn = class2type.hasOwnProperty;
  423. var trim = "".trim;
  424. var support = {};
  425. var
  426. // Use the correct document accordingly with window argument (sandbox)
  427. document = window.document,
  428. version = "2.1.0",
  429. // Define a local copy of jQuery
  430. jQuery = function( selector, context ) {
  431. // The jQuery object is actually just the init constructor 'enhanced'
  432. // Need init if jQuery is called (just allow error to be thrown if not included)
  433. return new jQuery.fn.init( selector, context );
  434. },
  435. // Matches dashed string for camelizing
  436. rmsPrefix = /^-ms-/,
  437. rdashAlpha = /-([\da-z])/gi,
  438. // Used by jQuery.camelCase as callback to replace()
  439. fcamelCase = function( all, letter ) {
  440. return letter.toUpperCase();
  441. };
  442. jQuery.fn = jQuery.prototype = {
  443. // The current version of jQuery being used
  444. jquery: version,
  445. constructor: jQuery,
  446. // Start with an empty selector
  447. selector: "",
  448. // The default length of a jQuery object is 0
  449. length: 0,
  450. toArray: function() {
  451. return slice.call( this );
  452. },
  453. // Get the Nth element in the matched element set OR
  454. // Get the whole matched element set as a clean array
  455. get: function( num ) {
  456. return num != null ?
  457. // Return a 'clean' array
  458. ( num < 0 ? this[ num + this.length ] : this[ num ] ) :
  459. // Return just the object
  460. slice.call( this );
  461. },
  462. // Take an array of elements and push it onto the stack
  463. // (returning the new matched element set)
  464. pushStack: function( elems ) {
  465. // Build a new jQuery matched element set
  466. var ret = jQuery.merge( this.constructor(), elems );
  467. // Add the old object onto the stack (as a reference)
  468. ret.prevObject = this;
  469. ret.context = this.context;
  470. // Return the newly-formed element set
  471. return ret;
  472. },
  473. // Execute a callback for every element in the matched set.
  474. // (You can seed the arguments with an array of args, but this is
  475. // only used internally.)
  476. each: function( callback, args ) {
  477. return jQuery.each( this, callback, args );
  478. },
  479. map: function( callback ) {
  480. return this.pushStack( jQuery.map(this, function( elem, i ) {
  481. return callback.call( elem, i, elem );
  482. }));
  483. },
  484. slice: function() {
  485. return this.pushStack( slice.apply( this, arguments ) );
  486. },
  487. first: function() {
  488. return this.eq( 0 );
  489. },
  490. last: function() {
  491. return this.eq( -1 );
  492. },
  493. eq: function( i ) {
  494. var len = this.length,
  495. j = +i + ( i < 0 ? len : 0 );
  496. return this.pushStack( j >= 0 && j < len ? [ this[j] ] : [] );
  497. },
  498. end: function() {
  499. return this.prevObject || this.constructor(null);
  500. },
  501. // For internal use only.
  502. // Behaves like an Array's method, not like a jQuery method.
  503. push: push,
  504. sort: arr.sort,
  505. splice: arr.splice
  506. };
  507. jQuery.extend = jQuery.fn.extend = function() {
  508. var options, name, src, copy, copyIsArray, clone,
  509. target = arguments[0] || {},
  510. i = 1,
  511. length = arguments.length,
  512. deep = false;
  513. // Handle a deep copy situation
  514. if ( typeof target === "boolean" ) {
  515. deep = target;
  516. // skip the boolean and the target
  517. target = arguments[ i ] || {};
  518. i++;
  519. }
  520. // Handle case when target is a string or something (possible in deep copy)
  521. if ( typeof target !== "object" && !jQuery.isFunction(target) ) {
  522. target = {};
  523. }
  524. // extend jQuery itself if only one argument is passed
  525. if ( i === length ) {
  526. target = this;
  527. i--;
  528. }
  529. for ( ; i < length; i++ ) {
  530. // Only deal with non-null/undefined values
  531. if ( (options = arguments[ i ]) != null ) {
  532. // Extend the base object
  533. for ( name in options ) {
  534. src = target[ name ];
  535. copy = options[ name ];
  536. // Prevent never-ending loop
  537. if ( target === copy ) {
  538. continue;
  539. }
  540. // Recurse if we're merging plain objects or arrays
  541. if ( deep && copy && ( jQuery.isPlainObject(copy) || (copyIsArray = jQuery.isArray(copy)) ) ) {
  542. if ( copyIsArray ) {
  543. copyIsArray = false;
  544. clone = src && jQuery.isArray(src) ? src : [];
  545. } else {
  546. clone = src && jQuery.isPlainObject(src) ? src : {};
  547. }
  548. // Never move original objects, clone them
  549. target[ name ] = jQuery.extend( deep, clone, copy );
  550. // Don't bring in undefined values
  551. } else if ( copy !== undefined ) {
  552. target[ name ] = copy;
  553. }
  554. }
  555. }
  556. }
  557. // Return the modified object
  558. return target;
  559. };
  560. jQuery.extend({
  561. // Unique for each copy of jQuery on the page
  562. expando: "jQuery" + ( version + Math.random() ).replace( /\D/g, "" ),
  563. // Assume jQuery is ready without the ready module
  564. isReady: true,
  565. error: function( msg ) {
  566. throw new Error( msg );
  567. },
  568. noop: function() {},
  569. // See test/unit/core.js for details concerning isFunction.
  570. // Since version 1.3, DOM methods and functions like alert
  571. // aren't supported. They return false on IE (#2968).
  572. isFunction: function( obj ) {
  573. return jQuery.type(obj) === "function";
  574. },
  575. isArray: Array.isArray,
  576. isWindow: function( obj ) {
  577. return obj != null && obj === obj.window;
  578. },
  579. isNumeric: function( obj ) {
  580. // parseFloat NaNs numeric-cast false positives (null|true|false|"")
  581. // ...but misinterprets leading-number strings, particularly hex literals ("0x...")
  582. // subtraction forces infinities to NaN
  583. return obj - parseFloat( obj ) >= 0;
  584. },
  585. isPlainObject: function( obj ) {
  586. // Not plain objects:
  587. // - Any object or value whose internal [[Class]] property is not "[object Object]"
  588. // - DOM nodes
  589. // - window
  590. if ( jQuery.type( obj ) !== "object" || obj.nodeType || jQuery.isWindow( obj ) ) {
  591. return false;
  592. }
  593. // Support: Firefox <20
  594. // The try/catch suppresses exceptions thrown when attempting to access
  595. // the "constructor" property of certain host objects, ie. |window.location|
  596. // https://bugzilla.mozilla.org/show_bug.cgi?id=814622
  597. try {
  598. if ( obj.constructor &&
  599. !hasOwn.call( obj.constructor.prototype, "isPrototypeOf" ) ) {
  600. return false;
  601. }
  602. } catch ( e ) {
  603. return false;
  604. }
  605. // If the function hasn't returned already, we're confident that
  606. // |obj| is a plain object, created by {} or constructed with new Object
  607. return true;
  608. },
  609. isEmptyObject: function( obj ) {
  610. var name;
  611. for ( name in obj ) {
  612. return false;
  613. }
  614. return true;
  615. },
  616. type: function( obj ) {
  617. if ( obj == null ) {
  618. return obj + "";
  619. }
  620. // Support: Android < 4.0, iOS < 6 (functionish RegExp)
  621. return typeof obj === "object" || typeof obj === "function" ?
  622. class2type[ toString.call(obj) ] || "object" :
  623. typeof obj;
  624. },
  625. // Evaluates a script in a global context
  626. globalEval: function( code ) {
  627. var script,
  628. indirect = eval;
  629. code = jQuery.trim( code );
  630. if ( code ) {
  631. // If the code includes a valid, prologue position
  632. // strict mode pragma, execute code by injecting a
  633. // script tag into the document.
  634. if ( code.indexOf("use strict") === 1 ) {
  635. script = document.createElement("script");
  636. script.text = code;
  637. document.head.appendChild( script ).parentNode.removeChild( script );
  638. } else {
  639. // Otherwise, avoid the DOM node creation, insertion
  640. // and removal by using an indirect global eval
  641. indirect( code );
  642. }
  643. }
  644. },
  645. // Convert dashed to camelCase; used by the css and data modules
  646. // Microsoft forgot to hump their vendor prefix (#9572)
  647. camelCase: function( string ) {
  648. return string.replace( rmsPrefix, "ms-" ).replace( rdashAlpha, fcamelCase );
  649. },
  650. nodeName: function( elem, name ) {
  651. return elem.nodeName && elem.nodeName.toLowerCase() === name.toLowerCase();
  652. },
  653. // args is for internal usage only
  654. each: function( obj, callback, args ) {
  655. var value,
  656. i = 0,
  657. length = obj.length,
  658. isArray = isArraylike( obj );
  659. if ( args ) {
  660. if ( isArray ) {
  661. for ( ; i < length; i++ ) {
  662. value = callback.apply( obj[ i ], args );
  663. if ( value === false ) {
  664. break;
  665. }
  666. }
  667. } else {
  668. for ( i in obj ) {
  669. value = callback.apply( obj[ i ], args );
  670. if ( value === false ) {
  671. break;
  672. }
  673. }
  674. }
  675. // A special, fast, case for the most common use of each
  676. } else {
  677. if ( isArray ) {
  678. for ( ; i < length; i++ ) {
  679. value = callback.call( obj[ i ], i, obj[ i ] );
  680. if ( value === false ) {
  681. break;
  682. }
  683. }
  684. } else {
  685. for ( i in obj ) {
  686. value = callback.call( obj[ i ], i, obj[ i ] );
  687. if ( value === false ) {
  688. break;
  689. }
  690. }
  691. }
  692. }
  693. return obj;
  694. },
  695. trim: function( text ) {
  696. return text == null ? "" : trim.call( text );
  697. },
  698. // results is for internal usage only
  699. makeArray: function( arr, results ) {
  700. var ret = results || [];
  701. if ( arr != null ) {
  702. if ( isArraylike( Object(arr) ) ) {
  703. jQuery.merge( ret,
  704. typeof arr === "string" ?
  705. [ arr ] : arr
  706. );
  707. } else {
  708. push.call( ret, arr );
  709. }
  710. }
  711. return ret;
  712. },
  713. inArray: function( elem, arr, i ) {
  714. return arr == null ? -1 : indexOf.call( arr, elem, i );
  715. },
  716. merge: function( first, second ) {
  717. var len = +second.length,
  718. j = 0,
  719. i = first.length;
  720. for ( ; j < len; j++ ) {
  721. first[ i++ ] = second[ j ];
  722. }
  723. first.length = i;
  724. return first;
  725. },
  726. grep: function( elems, callback, invert ) {
  727. var callbackInverse,
  728. matches = [],
  729. i = 0,
  730. length = elems.length,
  731. callbackExpect = !invert;
  732. // Go through the array, only saving the items
  733. // that pass the validator function
  734. for ( ; i < length; i++ ) {
  735. callbackInverse = !callback( elems[ i ], i );
  736. if ( callbackInverse !== callbackExpect ) {
  737. matches.push( elems[ i ] );
  738. }
  739. }
  740. return matches;
  741. },
  742. // arg is for internal usage only
  743. map: function( elems, callback, arg ) {
  744. var value,
  745. i = 0,
  746. length = elems.length,
  747. isArray = isArraylike( elems ),
  748. ret = [];
  749. // Go through the array, translating each of the items to their new values
  750. if ( isArray ) {
  751. for ( ; i < length; i++ ) {
  752. value = callback( elems[ i ], i, arg );
  753. if ( value != null ) {
  754. ret.push( value );
  755. }
  756. }
  757. // Go through every key on the object,
  758. } else {
  759. for ( i in elems ) {
  760. value = callback( elems[ i ], i, arg );
  761. if ( value != null ) {
  762. ret.push( value );
  763. }
  764. }
  765. }
  766. // Flatten any nested arrays
  767. return concat.apply( [], ret );
  768. },
  769. // A global GUID counter for objects
  770. guid: 1,
  771. // Bind a function to a context, optionally partially applying any
  772. // arguments.
  773. proxy: function( fn, context ) {
  774. var tmp, args, proxy;
  775. if ( typeof context === "string" ) {
  776. tmp = fn[ context ];
  777. context = fn;
  778. fn = tmp;
  779. }
  780. // Quick check to determine if target is callable, in the spec
  781. // this throws a TypeError, but we will just return undefined.
  782. if ( !jQuery.isFunction( fn ) ) {
  783. return undefined;
  784. }
  785. // Simulated bind
  786. args = slice.call( arguments, 2 );
  787. proxy = function() {
  788. return fn.apply( context || this, args.concat( slice.call( arguments ) ) );
  789. };
  790. // Set the guid of unique handler to the same of original handler, so it can be removed
  791. proxy.guid = fn.guid = fn.guid || jQuery.guid++;
  792. return proxy;
  793. },
  794. now: Date.now,
  795. // jQuery.support is not used in Core but other projects attach their
  796. // properties to it so it needs to exist.
  797. support: support
  798. });
  799. // Populate the class2type map
  800. jQuery.each("Boolean Number String Function Array Date RegExp Object Error".split(" "), function(i, name) {
  801. class2type[ "[object " + name + "]" ] = name.toLowerCase();
  802. });
  803. function isArraylike( obj ) {
  804. var length = obj.length,
  805. type = jQuery.type( obj );
  806. if ( type === "function" || jQuery.isWindow( obj ) ) {
  807. return false;
  808. }
  809. if ( obj.nodeType === 1 && length ) {
  810. return true;
  811. }
  812. return type === "array" || length === 0 ||
  813. typeof length === "number" && length > 0 && ( length - 1 ) in obj;
  814. }
  815. var Sizzle =
  816. /*!
  817. * Sizzle CSS Selector Engine v1.10.16
  818. * http://sizzlejs.com/
  819. *
  820. * Copyright 2013 jQuery Foundation, Inc. and other contributors
  821. * Released under the MIT license
  822. * http://jquery.org/license
  823. *
  824. * Date: 2014-01-13
  825. */
  826. (function( window ) {
  827. var i,
  828. support,
  829. Expr,
  830. getText,
  831. isXML,
  832. compile,
  833. outermostContext,
  834. sortInput,
  835. hasDuplicate,
  836. // Local document vars
  837. setDocument,
  838. document,
  839. docElem,
  840. documentIsHTML,
  841. rbuggyQSA,
  842. rbuggyMatches,
  843. matches,
  844. contains,
  845. // Instance-specific data
  846. expando = "sizzle" + -(new Date()),
  847. preferredDoc = window.document,
  848. dirruns = 0,
  849. done = 0,
  850. classCache = createCache(),
  851. tokenCache = createCache(),
  852. compilerCache = createCache(),
  853. sortOrder = function( a, b ) {
  854. if ( a === b ) {
  855. hasDuplicate = true;
  856. }
  857. return 0;
  858. },
  859. // General-purpose constants
  860. strundefined = typeof undefined,
  861. MAX_NEGATIVE = 1 << 31,
  862. // Instance methods
  863. hasOwn = ({}).hasOwnProperty,
  864. arr = [],
  865. pop = arr.pop,
  866. push_native = arr.push,
  867. push = arr.push,
  868. slice = arr.slice,
  869. // Use a stripped-down indexOf if we can't use a native one
  870. indexOf = arr.indexOf || function( elem ) {
  871. var i = 0,
  872. len = this.length;
  873. for ( ; i < len; i++ ) {
  874. if ( this[i] === elem ) {
  875. return i;
  876. }
  877. }
  878. return -1;
  879. },
  880. booleans = "checked|selected|async|autofocus|autoplay|controls|defer|disabled|hidden|ismap|loop|multiple|open|readonly|required|scoped",
  881. // Regular expressions
  882. // Whitespace characters http://www.w3.org/TR/css3-selectors/#whitespace
  883. whitespace = "[\\x20\\t\\r\\n\\f]",
  884. // http://www.w3.org/TR/css3-syntax/#characters
  885. characterEncoding = "(?:\\\\.|[\\w-]|[^\\x00-\\xa0])+",
  886. // Loosely modeled on CSS identifier characters
  887. // An unquoted value should be a CSS identifier http://www.w3.org/TR/css3-selectors/#attribute-selectors
  888. // Proper syntax: http://www.w3.org/TR/CSS21/syndata.html#value-def-identifier
  889. identifier = characterEncoding.replace( "w", "w#" ),
  890. // Acceptable operators http://www.w3.org/TR/selectors/#attribute-selectors
  891. attributes = "\\[" + whitespace + "*(" + characterEncoding + ")" + whitespace +
  892. "*(?:([*^$|!~]?=)" + whitespace + "*(?:(['\"])((?:\\\\.|[^\\\\])*?)\\3|(" + identifier + ")|)|)" + whitespace + "*\\]",
  893. // Prefer arguments quoted,
  894. // then not containing pseudos/brackets,
  895. // then attribute selectors/non-parenthetical expressions,
  896. // then anything else
  897. // These preferences are here to reduce the number of selectors
  898. // needing tokenize in the PSEUDO preFilter
  899. pseudos = ":(" + characterEncoding + ")(?:\\(((['\"])((?:\\\\.|[^\\\\])*?)\\3|((?:\\\\.|[^\\\\()[\\]]|" + attributes.replace( 3, 8 ) + ")*)|.*)\\)|)",
  900. // Leading and non-escaped trailing whitespace, capturing some non-whitespace characters preceding the latter
  901. rtrim = new RegExp( "^" + whitespace + "+|((?:^|[^\\\\])(?:\\\\.)*)" + whitespace + "+$", "g" ),
  902. rcomma = new RegExp( "^" + whitespace + "*," + whitespace + "*" ),
  903. rcombinators = new RegExp( "^" + whitespace + "*([>+~]|" + whitespace + ")" + whitespace + "*" ),
  904. rattributeQuotes = new RegExp( "=" + whitespace + "*([^\\]'\"]*?)" + whitespace + "*\\]", "g" ),
  905. rpseudo = new RegExp( pseudos ),
  906. ridentifier = new RegExp( "^" + identifier + "$" ),
  907. matchExpr = {
  908. "ID": new RegExp( "^#(" + characterEncoding + ")" ),
  909. "CLASS": new RegExp( "^\\.(" + characterEncoding + ")" ),
  910. "TAG": new RegExp( "^(" + characterEncoding.replace( "w", "w*" ) + ")" ),
  911. "ATTR": new RegExp( "^" + attributes ),
  912. "PSEUDO": new RegExp( "^" + pseudos ),
  913. "CHILD": new RegExp( "^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\(" + whitespace +
  914. "*(even|odd|(([+-]|)(\\d*)n|)" + whitespace + "*(?:([+-]|)" + whitespace +
  915. "*(\\d+)|))" + whitespace + "*\\)|)", "i" ),
  916. "bool": new RegExp( "^(?:" + booleans + ")$", "i" ),
  917. // For use in libraries implementing .is()
  918. // We use this for POS matching in `select`
  919. "needsContext": new RegExp( "^" + whitespace + "*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\(" +
  920. whitespace + "*((?:-\\d)?\\d*)" + whitespace + "*\\)|)(?=[^-]|$)", "i" )
  921. },
  922. rinputs = /^(?:input|select|textarea|button)$/i,
  923. rheader = /^h\d$/i,
  924. rnative = /^[^{]+\{\s*\[native \w/,
  925. // Easily-parseable/retrievable ID or TAG or CLASS selectors
  926. rquickExpr = /^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/,
  927. rsibling = /[+~]/,
  928. rescape = /'|\\/g,
  929. // CSS escapes http://www.w3.org/TR/CSS21/syndata.html#escaped-characters
  930. runescape = new RegExp( "\\\\([\\da-f]{1,6}" + whitespace + "?|(" + whitespace + ")|.)", "ig" ),
  931. funescape = function( _, escaped, escapedWhitespace ) {
  932. var high = "0x" + escaped - 0x10000;
  933. // NaN means non-codepoint
  934. // Support: Firefox
  935. // Workaround erroneous numeric interpretation of +"0x"
  936. return high !== high || escapedWhitespace ?
  937. escaped :
  938. high < 0 ?
  939. // BMP codepoint
  940. String.fromCharCode( high + 0x10000 ) :
  941. // Supplemental Plane codepoint (surrogate pair)
  942. String.fromCharCode( high >> 10 | 0xD800, high & 0x3FF | 0xDC00 );
  943. };
  944. // Optimize for push.apply( _, NodeList )
  945. try {
  946. push.apply(
  947. (arr = slice.call( preferredDoc.childNodes )),
  948. preferredDoc.childNodes
  949. );
  950. // Support: Android<4.0
  951. // Detect silently failing push.apply
  952. arr[ preferredDoc.childNodes.length ].nodeType;
  953. } catch ( e ) {
  954. push = { apply: arr.length ?
  955. // Leverage slice if possible
  956. function( target, els ) {
  957. push_native.apply( target, slice.call(els) );
  958. } :
  959. // Support: IE<9
  960. // Otherwise append directly
  961. function( target, els ) {
  962. var j = target.length,
  963. i = 0;
  964. // Can't trust NodeList.length
  965. while ( (target[j++] = els[i++]) ) {}
  966. target.length = j - 1;
  967. }
  968. };
  969. }
  970. function Sizzle( selector, context, results, seed ) {
  971. var match, elem, m, nodeType,
  972. // QSA vars
  973. i, groups, old, nid, newContext, newSelector;
  974. if ( ( context ? context.ownerDocument || context : preferredDoc ) !== document ) {
  975. setDocument( context );
  976. }
  977. context = context || document;
  978. results = results || [];
  979. if ( !selector || typeof selector !== "string" ) {
  980. return results;
  981. }
  982. if ( (nodeType = context.nodeType) !== 1 && nodeType !== 9 ) {
  983. return [];
  984. }
  985. if ( documentIsHTML && !seed ) {
  986. // Shortcuts
  987. if ( (match = rquickExpr.exec( selector )) ) {
  988. // Speed-up: Sizzle("#ID")
  989. if ( (m = match[1]) ) {
  990. if ( nodeType === 9 ) {
  991. elem = context.getElementById( m );
  992. // Check parentNode to catch when Blackberry 4.6 returns
  993. // nodes that are no longer in the document (jQuery #6963)
  994. if ( elem && elem.parentNode ) {
  995. // Handle the case where IE, Opera, and Webkit return items
  996. // by name instead of ID
  997. if ( elem.id === m ) {
  998. results.push( elem );
  999. return results;
  1000. }
  1001. } else {
  1002. return results;
  1003. }
  1004. } else {
  1005. // Context is not a document
  1006. if ( context.ownerDocument && (elem = context.ownerDocument.getElementById( m )) &&
  1007. contains( context, elem ) && elem.id === m ) {
  1008. results.push( elem );
  1009. return results;
  1010. }
  1011. }
  1012. // Speed-up: Sizzle("TAG")
  1013. } else if ( match[2] ) {
  1014. push.apply( results, context.getElementsByTagName( selector ) );
  1015. return results;
  1016. // Speed-up: Sizzle(".CLASS")
  1017. } else if ( (m = match[3]) && support.getElementsByClassName && context.getElementsByClassName ) {
  1018. push.apply( results, context.getElementsByClassName( m ) );
  1019. return results;
  1020. }
  1021. }
  1022. // QSA path
  1023. if ( support.qsa && (!rbuggyQSA || !rbuggyQSA.test( selector )) ) {
  1024. nid = old = expando;
  1025. newContext = context;
  1026. newSelector = nodeType === 9 && selector;
  1027. // qSA works strangely on Element-rooted queries
  1028. // We can work around this by specifying an extra ID on the root
  1029. // and working up from there (Thanks to Andrew Dupont for the technique)
  1030. // IE 8 doesn't work on object elements
  1031. if ( nodeType === 1 && context.nodeName.toLowerCase() !== "object" ) {
  1032. groups = tokenize( selector );
  1033. if ( (old = context.getAttribute("id")) ) {
  1034. nid = old.replace( rescape, "\\$&" );
  1035. } else {
  1036. context.setAttribute( "id", nid );
  1037. }
  1038. nid = "[id='" + nid + "'] ";
  1039. i = groups.length;
  1040. while ( i-- ) {
  1041. groups[i] = nid + toSelector( groups[i] );
  1042. }
  1043. newContext = rsibling.test( selector ) && testContext( context.parentNode ) || context;
  1044. newSelector = groups.join(",");
  1045. }
  1046. if ( newSelector ) {
  1047. try {
  1048. push.apply( results,
  1049. newContext.querySelectorAll( newSelector )
  1050. );
  1051. return results;
  1052. } catch(qsaError) {
  1053. } finally {
  1054. if ( !old ) {
  1055. context.removeAttribute("id");
  1056. }
  1057. }
  1058. }
  1059. }
  1060. }
  1061. // All others
  1062. return select( selector.replace( rtrim, "$1" ), context, results, seed );
  1063. }
  1064. /**
  1065. * Create key-value caches of limited size
  1066. * @returns {Function(string, Object)} Returns the Object data after storing it on itself with
  1067. * property name the (space-suffixed) string and (if the cache is larger than Expr.cacheLength)
  1068. * deleting the oldest entry
  1069. */
  1070. function createCache() {
  1071. var keys = [];
  1072. function cache( key, value ) {
  1073. // Use (key + " ") to avoid collision with native prototype properties (see Issue #157)
  1074. if ( keys.push( key + " " ) > Expr.cacheLength ) {
  1075. // Only keep the most recent entries
  1076. delete cache[ keys.shift() ];
  1077. }
  1078. return (cache[ key + " " ] = value);
  1079. }
  1080. return cache;
  1081. }
  1082. /**
  1083. * Mark a function for special use by Sizzle
  1084. * @param {Function} fn The function to mark
  1085. */
  1086. function markFunction( fn ) {
  1087. fn[ expando ] = true;
  1088. return fn;
  1089. }
  1090. /**
  1091. * Support testing using an element
  1092. * @param {Function} fn Passed the created div and expects a boolean result
  1093. */
  1094. function assert( fn ) {
  1095. var div = document.createElement("div");
  1096. try {
  1097. return !!fn( div );
  1098. } catch (e) {
  1099. return false;
  1100. } finally {
  1101. // Remove from its parent by default
  1102. if ( div.parentNode ) {
  1103. div.parentNode.removeChild( div );
  1104. }
  1105. // release memory in IE
  1106. div = null;
  1107. }
  1108. }
  1109. /**
  1110. * Adds the same handler for all of the specified attrs
  1111. * @param {String} attrs Pipe-separated list of attributes
  1112. * @param {Function} handler The method that will be applied
  1113. */
  1114. function addHandle( attrs, handler ) {
  1115. var arr = attrs.split("|"),
  1116. i = attrs.length;
  1117. while ( i-- ) {
  1118. Expr.attrHandle[ arr[i] ] = handler;
  1119. }
  1120. }
  1121. /**
  1122. * Checks document order of two siblings
  1123. * @param {Element} a
  1124. * @param {Element} b
  1125. * @returns {Number} Returns less than 0 if a precedes b, greater than 0 if a follows b
  1126. */
  1127. function siblingCheck( a, b ) {
  1128. var cur = b && a,
  1129. diff = cur && a.nodeType === 1 && b.nodeType === 1 &&
  1130. ( ~b.sourceIndex || MAX_NEGATIVE ) -
  1131. ( ~a.sourceIndex || MAX_NEGATIVE );
  1132. // Use IE sourceIndex if available on both nodes
  1133. if ( diff ) {
  1134. return diff;
  1135. }
  1136. // Check if b follows a
  1137. if ( cur ) {
  1138. while ( (cur = cur.nextSibling) ) {
  1139. if ( cur === b ) {
  1140. return -1;
  1141. }
  1142. }
  1143. }
  1144. return a ? 1 : -1;
  1145. }
  1146. /**
  1147. * Returns a function to use in pseudos for input types
  1148. * @param {String} type
  1149. */
  1150. function createInputPseudo( type ) {
  1151. return function( elem ) {
  1152. var name = elem.nodeName.toLowerCase();
  1153. return name === "input" && elem.type === type;
  1154. };
  1155. }
  1156. /**
  1157. * Returns a function to use in pseudos for buttons
  1158. * @param {String} type
  1159. */
  1160. function createButtonPseudo( type ) {
  1161. return function( elem ) {
  1162. var name = elem.nodeName.toLowerCase();
  1163. return (name === "input" || name === "button") && elem.type === type;
  1164. };
  1165. }
  1166. /**
  1167. * Returns a function to use in pseudos for positionals
  1168. * @param {Function} fn
  1169. */
  1170. function createPositionalPseudo( fn ) {
  1171. return markFunction(function( argument ) {
  1172. argument = +argument;
  1173. return markFunction(function( seed, matches ) {
  1174. var j,
  1175. matchIndexes = fn( [], seed.length, argument ),
  1176. i = matchIndexes.length;
  1177. // Match elements found at the specified indexes
  1178. while ( i-- ) {
  1179. if ( seed[ (j = matchIndexes[i]) ] ) {
  1180. seed[j] = !(matches[j] = seed[j]);
  1181. }
  1182. }
  1183. });
  1184. });
  1185. }
  1186. /**
  1187. * Checks a node for validity as a Sizzle context
  1188. * @param {Element|Object=} context
  1189. * @returns {Element|Object|Boolean} The input node if acceptable, otherwise a falsy value
  1190. */
  1191. function testContext( context ) {
  1192. return context && typeof context.getElementsByTagName !== strundefined && context;
  1193. }
  1194. // Expose support vars for convenience
  1195. support = Sizzle.support = {};
  1196. /**
  1197. * Detects XML nodes
  1198. * @param {Element|Object} elem An element or a document
  1199. * @returns {Boolean} True iff elem is a non-HTML XML node
  1200. */
  1201. isXML = Sizzle.isXML = function( elem ) {
  1202. // documentElement is verified for cases where it doesn't yet exist
  1203. // (such as loading iframes in IE - #4833)
  1204. var documentElement = elem && (elem.ownerDocument || elem).documentElement;
  1205. return documentElement ? documentElement.nodeName !== "HTML" : false;
  1206. };
  1207. /**
  1208. * Sets document-related variables once based on the current document
  1209. * @param {Element|Object} [doc] An element or document object to use to set the document
  1210. * @returns {Object} Returns the current document
  1211. */
  1212. setDocument = Sizzle.setDocument = function( node ) {
  1213. var hasCompare,
  1214. doc = node ? node.ownerDocument || node : preferredDoc,
  1215. parent = doc.defaultView;
  1216. // If no document and documentElement is available, return
  1217. if ( doc === document || doc.nodeType !== 9 || !doc.documentElement ) {
  1218. return document;
  1219. }
  1220. // Set our document
  1221. document = doc;
  1222. docElem = doc.documentElement;
  1223. // Support tests
  1224. documentIsHTML = !isXML( doc );
  1225. // Support: IE>8
  1226. // If iframe document is assigned to "document" variable and if iframe has been reloaded,
  1227. // IE will throw "permission denied" error when accessing "document" variable, see jQuery #13936
  1228. // IE6-8 do not support the defaultView property so parent will be undefined
  1229. if ( parent && parent !== parent.top ) {
  1230. // IE11 does not have attachEvent, so all must suffer
  1231. if ( parent.addEventListener ) {
  1232. parent.addEventListener( "unload", function() {
  1233. setDocument();
  1234. }, false );
  1235. } else if ( parent.attachEvent ) {
  1236. parent.attachEvent( "onunload", function() {
  1237. setDocument();
  1238. });
  1239. }
  1240. }
  1241. /* Attributes
  1242. ---------------------------------------------------------------------- */
  1243. // Support: IE<8
  1244. // Verify that getAttribute really returns attributes and not properties (excepting IE8 booleans)
  1245. support.attributes = assert(function( div ) {
  1246. div.className = "i";
  1247. return !div.getAttribute("className");
  1248. });
  1249. /* getElement(s)By*
  1250. ---------------------------------------------------------------------- */
  1251. // Check if getElementsByTagName("*") returns only elements
  1252. support.getElementsByTagName = assert(function( div ) {
  1253. div.appendChild( doc.createComment("") );
  1254. return !div.getElementsByTagName("*").length;
  1255. });
  1256. // Check if getElementsByClassName can be trusted
  1257. support.getElementsByClassName = rnative.test( doc.getElementsByClassName ) && assert(function( div ) {
  1258. div.innerHTML = "<div class='a'></div><div class='a i'></div>";
  1259. // Support: Safari<4
  1260. // Catch class over-caching
  1261. div.firstChild.className = "i";
  1262. // Support: Opera<10
  1263. // Catch gEBCN failure to find non-leading classes
  1264. return div.getElementsByClassName("i").length === 2;
  1265. });
  1266. // Support: IE<10
  1267. // Check if getElementById returns elements by name
  1268. // The broken getElementById methods don't pick up programatically-set names,
  1269. // so use a roundabout getElementsByName test
  1270. support.getById = assert(function( div ) {
  1271. docElem.appendChild( div ).id = expando;
  1272. return !doc.getElementsByName || !doc.getElementsByName( expando ).length;
  1273. });
  1274. // ID find and filter
  1275. if ( support.getById ) {
  1276. Expr.find["ID"] = function( id, context ) {
  1277. if ( typeof context.getElementById !== strundefined && documentIsHTML ) {
  1278. var m = context.getElementById( id );
  1279. // Check parentNode to catch when Blackberry 4.6 returns
  1280. // nodes that are no longer in the document #6963
  1281. return m && m.parentNode ? [m] : [];
  1282. }
  1283. };
  1284. Expr.filter["ID"] = function( id ) {
  1285. var attrId = id.replace( runescape, funescape );
  1286. return function( elem ) {
  1287. return elem.getAttribute("id") === attrId;
  1288. };
  1289. };
  1290. } else {
  1291. // Support: IE6/7
  1292. // getElementById is not reliable as a find shortcut
  1293. delete Expr.find["ID"];
  1294. Expr.filter["ID"] = function( id ) {
  1295. var attrId = id.replace( runescape, funescape );
  1296. return function( elem ) {
  1297. var node = typeof elem.getAttributeNode !== strundefined && elem.getAttributeNode("id");
  1298. return node && node.value === attrId;
  1299. };
  1300. };
  1301. }
  1302. // Tag
  1303. Expr.find["TAG"] = support.getElementsByTagName ?
  1304. function( tag, context ) {
  1305. if ( typeof context.getElementsByTagName !== strundefined ) {
  1306. return context.getElementsByTagName( tag );
  1307. }
  1308. } :
  1309. function( tag, context ) {
  1310. var elem,
  1311. tmp = [],
  1312. i = 0,
  1313. results = context.getElementsByTagName( tag );
  1314. // Filter out possible comments
  1315. if ( tag === "*" ) {
  1316. while ( (elem = results[i++]) ) {
  1317. if ( elem.nodeType === 1 ) {
  1318. tmp.push( elem );
  1319. }
  1320. }
  1321. return tmp;
  1322. }
  1323. return results;
  1324. };
  1325. // Class
  1326. Expr.find["CLASS"] = support.getElementsByClassName && function( className, context ) {
  1327. if ( typeof context.getElementsByClassName !== strundefined && documentIsHTML ) {
  1328. return context.getElementsByClassName( className );
  1329. }
  1330. };
  1331. /* QSA/matchesSelector
  1332. ---------------------------------------------------------------------- */
  1333. // QSA and matchesSelector support
  1334. // matchesSelector(:active) reports false when true (IE9/Opera 11.5)
  1335. rbuggyMatches = [];
  1336. // qSa(:focus) reports false when true (Chrome 21)
  1337. // We allow this because of a bug in IE8/9 that throws an error
  1338. // whenever `document.activeElement` is accessed on an iframe
  1339. // So, we allow :focus to pass through QSA all the time to avoid the IE error
  1340. // See http://bugs.jquery.com/ticket/13378
  1341. rbuggyQSA = [];
  1342. if ( (support.qsa = rnative.test( doc.querySelectorAll )) ) {
  1343. // Build QSA regex
  1344. // Regex strategy adopted from Diego Perini
  1345. assert(function( div ) {
  1346. // Select is set to empty string on purpose
  1347. // This is to test IE's treatment of not explicitly
  1348. // setting a boolean content attribute,
  1349. // since its presence should be enough
  1350. // http://bugs.jquery.com/ticket/12359
  1351. div.innerHTML = "<select t=''><option selected=''></option></select>";
  1352. // Support: IE8, Opera 10-12
  1353. // Nothing should be selected when empty strings follow ^= or $= or *=
  1354. if ( div.querySelectorAll("[t^='']").length ) {
  1355. rbuggyQSA.push( "[*^$]=" + whitespace + "*(?:''|\"\")" );
  1356. }
  1357. // Support: IE8
  1358. // Boolean attributes and "value" are not treated correctly
  1359. if ( !div.querySelectorAll("[selected]").length ) {
  1360. rbuggyQSA.push( "\\[" + whitespace + "*(?:value|" + booleans + ")" );
  1361. }
  1362. // Webkit/Opera - :checked should return selected option elements
  1363. // http://www.w3.org/TR/2011/REC-css3-selectors-20110929/#checked
  1364. // IE8 throws error here and will not see later tests
  1365. if ( !div.querySelectorAll(":checked").length ) {
  1366. rbuggyQSA.push(":checked");
  1367. }
  1368. });
  1369. assert(function( div ) {
  1370. // Support: Windows 8 Native Apps
  1371. // The type and name attributes are restricted during .innerHTML assignment
  1372. var input = doc.createElement("input");
  1373. input.setAttribute( "type", "hidden" );
  1374. div.appendChild( input ).setAttribute( "name", "D" );
  1375. // Support: IE8
  1376. // Enforce case-sensitivity of name attribute
  1377. if ( div.querySelectorAll("[name=d]").length ) {
  1378. rbuggyQSA.push( "name" + whitespace + "*[*^$|!~]?=" );
  1379. }
  1380. // FF 3.5 - :enabled/:disabled and hidden elements (hidden elements are still enabled)
  1381. // IE8 throws error here and will not see later tests
  1382. if ( !div.querySelectorAll(":enabled").length ) {
  1383. rbuggyQSA.push( ":enabled", ":disabled" );
  1384. }
  1385. // Opera 10-11 does not throw on post-comma invalid pseudos
  1386. div.querySelectorAll("*,:x");
  1387. rbuggyQSA.push(",.*:");
  1388. });
  1389. }
  1390. if ( (support.matchesSelector = rnative.test( (matches = docElem.webkitMatchesSelector ||
  1391. docElem.mozMatchesSelector ||
  1392. docElem.oMatchesSelector ||
  1393. docElem.msMatchesSelector) )) ) {
  1394. assert(function( div ) {
  1395. // Check to see if it's possible to do matchesSelector
  1396. // on a disconnected node (IE 9)
  1397. support.disconnectedMatch = matches.call( div, "div" );
  1398. // This should fail with an exception
  1399. // Gecko does not error, returns false instead
  1400. matches.call( div, "[s!='']:x" );
  1401. rbuggyMatches.push( "!=", pseudos );
  1402. });
  1403. }
  1404. rbuggyQSA = rbuggyQSA.length && new RegExp( rbuggyQSA.join("|") );
  1405. rbuggyMatches = rbuggyMatches.length && new RegExp( rbuggyMatches.join("|") );
  1406. /* Contains
  1407. ---------------------------------------------------------------------- */
  1408. hasCompare = rnative.test( docElem.compareDocumentPosition );
  1409. // Element contains another
  1410. // Purposefully does not implement inclusive descendent
  1411. // As in, an element does not contain itself
  1412. contains = hasCompare || rnative.test( docElem.contains ) ?
  1413. function( a, b ) {
  1414. var adown = a.nodeType === 9 ? a.documentElement : a,
  1415. bup = b && b.parentNode;
  1416. return a === bup || !!( bup && bup.nodeType === 1 && (
  1417. adown.contains ?
  1418. adown.contains( bup ) :
  1419. a.compareDocumentPosition && a.compareDocumentPosition( bup ) & 16
  1420. ));
  1421. } :
  1422. function( a, b ) {
  1423. if ( b ) {
  1424. while ( (b = b.parentNode) ) {
  1425. if ( b === a ) {
  1426. return true;
  1427. }
  1428. }
  1429. }
  1430. return false;
  1431. };
  1432. /* Sorting
  1433. ---------------------------------------------------------------------- */
  1434. // Document order sorting
  1435. sortOrder = hasCompare ?
  1436. function( a, b ) {
  1437. // Flag for duplicate removal
  1438. if ( a === b ) {
  1439. hasDuplicate = true;
  1440. return 0;
  1441. }
  1442. // Sort on method existence if only one input has compareDocumentPosition
  1443. var compare = !a.compareDocumentPosition - !b.compareDocumentPosition;
  1444. if ( compare ) {
  1445. return compare;
  1446. }
  1447. // Calculate position if both inputs belong to the same document
  1448. compare = ( a.ownerDocument || a ) === ( b.ownerDocument || b ) ?
  1449. a.compareDocumentPosition( b ) :
  1450. // Otherwise we know they are disconnected
  1451. 1;
  1452. // Disconnected nodes
  1453. if ( compare & 1 ||
  1454. (!support.sortDetached && b.compareDocumentPosition( a ) === compare) ) {
  1455. // Choose the first element that is related to our preferred document
  1456. if ( a === doc || a.ownerDocument === preferredDoc && contains(preferredDoc, a) ) {
  1457. return -1;
  1458. }
  1459. if ( b === doc || b.ownerDocument === preferredDoc && contains(preferredDoc, b) ) {
  1460. return 1;
  1461. }
  1462. // Maintain original order
  1463. return sortInput ?
  1464. ( indexOf.call( sortInput, a ) - indexOf.call( sortInput, b ) ) :
  1465. 0;
  1466. }
  1467. return compare & 4 ? -1 : 1;
  1468. } :
  1469. function( a, b ) {
  1470. // Exit early if the nodes are identical
  1471. if ( a === b ) {
  1472. hasDuplicate = true;
  1473. return 0;
  1474. }
  1475. var cur,
  1476. i = 0,
  1477. aup = a.parentNode,
  1478. bup = b.parentNode,
  1479. ap = [ a ],
  1480. bp = [ b ];
  1481. // Parentless nodes are either documents or disconnected
  1482. if ( !aup || !bup ) {
  1483. return a === doc ? -1 :
  1484. b === doc ? 1 :
  1485. aup ? -1 :
  1486. bup ? 1 :
  1487. sortInput ?
  1488. ( indexOf.call( sortInput, a ) - indexOf.call( sortInput, b ) ) :
  1489. 0;
  1490. // If the nodes are siblings, we can do a quick check
  1491. } else if ( aup === bup ) {
  1492. return siblingCheck( a, b );
  1493. }
  1494. // Otherwise we need full lists of their ancestors for comparison
  1495. cur = a;
  1496. while ( (cur = cur.parentNode) ) {
  1497. ap.unshift( cur );
  1498. }
  1499. cur = b;
  1500. while ( (cur = cur.parentNode) ) {
  1501. bp.unshift( cur );
  1502. }
  1503. // Walk down the tree looking for a discrepancy
  1504. while ( ap[i] === bp[i] ) {
  1505. i++;
  1506. }
  1507. return i ?
  1508. // Do a sibling check if the nodes have a common ancestor
  1509. siblingCheck( ap[i], bp[i] ) :
  1510. // Otherwise nodes in our document sort first
  1511. ap[i] === preferredDoc ? -1 :
  1512. bp[i] === preferredDoc ? 1 :
  1513. 0;
  1514. };
  1515. return doc;
  1516. };
  1517. Sizzle.matches = function( expr, elements ) {
  1518. return Sizzle( expr, null, null, elements );
  1519. };
  1520. Sizzle.matchesSelector = function( elem, expr ) {
  1521. // Set document vars if needed
  1522. if ( ( elem.ownerDocument || elem ) !== document ) {
  1523. setDocument( elem );
  1524. }
  1525. // Make sure that attribute selectors are quoted
  1526. expr = expr.replace( rattributeQuotes, "='$1']" );
  1527. if ( support.matchesSelector && documentIsHTML &&
  1528. ( !rbuggyMatches || !rbuggyMatches.test( expr ) ) &&
  1529. ( !rbuggyQSA || !rbuggyQSA.test( expr ) ) ) {
  1530. try {
  1531. var ret = matches.call( elem, expr );
  1532. // IE 9's matchesSelector returns false on disconnected nodes
  1533. if ( ret || support.disconnectedMatch ||
  1534. // As well, disconnected nodes are said to be in a document
  1535. // fragment in IE 9
  1536. elem.document && elem.document.nodeType !== 11 ) {
  1537. return ret;
  1538. }
  1539. } catch(e) {}
  1540. }
  1541. return Sizzle( expr, document, null, [elem] ).length > 0;
  1542. };
  1543. Sizzle.contains = function( context, elem ) {
  1544. // Set document vars if needed
  1545. if ( ( context.ownerDocument || context ) !== document ) {
  1546. setDocument( context );
  1547. }
  1548. return contains( context, elem );
  1549. };
  1550. Sizzle.attr = function( elem, name ) {
  1551. // Set document vars if needed
  1552. if ( ( elem.ownerDocument || elem ) !== document ) {
  1553. setDocument( elem );
  1554. }
  1555. var fn = Expr.attrHandle[ name.toLowerCase() ],
  1556. // Don't get fooled by Object.prototype properties (jQuery #13807)
  1557. val = fn && hasOwn.call( Expr.attrHandle, name.toLowerCase() ) ?
  1558. fn( elem, name, !documentIsHTML ) :
  1559. undefined;
  1560. return val !== undefined ?
  1561. val :
  1562. support.attributes || !documentIsHTML ?
  1563. elem.getAttribute( name ) :
  1564. (val = elem.getAttributeNode(name)) && val.specified ?
  1565. val.value :
  1566. null;
  1567. };
  1568. Sizzle.error = function( msg ) {
  1569. throw new Error( "Syntax error, unrecognized expression: " + msg );
  1570. };
  1571. /**
  1572. * Document sorting and removing duplicates
  1573. * @param {ArrayLike} results
  1574. */
  1575. Sizzle.uniqueSort = function( results ) {
  1576. var elem,
  1577. duplicates = [],
  1578. j = 0,
  1579. i = 0;
  1580. // Unless we *know* we can detect duplicates, assume their presence
  1581. hasDuplicate = !support.detectDuplicates;
  1582. sortInput = !support.sortStable && results.slice( 0 );
  1583. results.sort( sortOrder );
  1584. if ( hasDuplicate ) {
  1585. while ( (elem = results[i++]) ) {
  1586. if ( elem === results[ i ] ) {
  1587. j = duplicates.push( i );
  1588. }
  1589. }
  1590. while ( j-- ) {
  1591. results.splice( duplicates[ j ], 1 );
  1592. }
  1593. }
  1594. // Clear input after sorting to release objects
  1595. // See https://github.com/jquery/sizzle/pull/225
  1596. sortInput = null;
  1597. return results;
  1598. };
  1599. /**
  1600. * Utility function for retrieving the text value of an array of DOM nodes
  1601. * @param {Array|Element} elem
  1602. */
  1603. getText = Sizzle.getText = function( elem ) {
  1604. var node,
  1605. ret = "",
  1606. i = 0,
  1607. nodeType = elem.nodeType;
  1608. if ( !nodeType ) {
  1609. // If no nodeType, this is expected to be an array
  1610. while ( (node = elem[i++]) ) {
  1611. // Do not traverse comment nodes
  1612. ret += getText( node );
  1613. }
  1614. } else if ( nodeType === 1 || nodeType === 9 || nodeType === 11 ) {
  1615. // Use textContent for elements
  1616. // innerText usage removed for consistency of new lines (jQuery #11153)
  1617. if ( typeof elem.textContent === "string" ) {
  1618. return elem.textContent;
  1619. } else {
  1620. // Traverse its children
  1621. for ( elem = elem.firstChild; elem; elem = elem.nextSibling ) {
  1622. ret += getText( elem );
  1623. }
  1624. }
  1625. } else if ( nodeType === 3 || nodeType === 4 ) {
  1626. return elem.nodeValue;
  1627. }
  1628. // Do not include comment or processing instruction nodes
  1629. return ret;
  1630. };
  1631. Expr = Sizzle.selectors = {
  1632. // Can be adjusted by the user
  1633. cacheLength: 50,
  1634. createPseudo: markFunction,
  1635. match: matchExpr,
  1636. attrHandle: {},
  1637. find: {},
  1638. relative: {
  1639. ">": { dir: "parentNode", first: true },
  1640. " ": { dir: "parentNode" },
  1641. "+": { dir: "previousSibling", first: true },
  1642. "~": { dir: "previousSibling" }
  1643. },
  1644. preFilter: {
  1645. "ATTR": function( match ) {
  1646. match[1] = match[1].replace( runescape, funescape );
  1647. // Move the given value to match[3] whether quoted or unquoted
  1648. match[3] = ( match[4] || match[5] || "" ).replace( runescape, funescape );
  1649. if ( match[2] === "~=" ) {
  1650. match[3] = " " + match[3] + " ";
  1651. }
  1652. return match.slice( 0, 4 );
  1653. },
  1654. "CHILD": function( match ) {
  1655. /* matches from matchExpr["CHILD"]
  1656. 1 type (only|nth|...)
  1657. 2 what (child|of-type)
  1658. 3 argument (even|odd|\d*|\d*n([+-]\d+)?|...)
  1659. 4 xn-component of xn+y argument ([+-]?\d*n|)
  1660. 5 sign of xn-component
  1661. 6 x of xn-component
  1662. 7 sign of y-component
  1663. 8 y of y-component
  1664. */
  1665. match[1] = match[1].toLowerCase();
  1666. if ( match[1].slice( 0, 3 ) === "nth" ) {
  1667. // nth-* requires argument
  1668. if ( !match[3] ) {
  1669. Sizzle.error( match[0] );
  1670. }
  1671. // numeric x and y parameters for Expr.filter.CHILD
  1672. // remember that false/true cast respectively to 0/1
  1673. match[4] = +( match[4] ? match[5] + (match[6] || 1) : 2 * ( match[3] === "even" || match[3] === "odd" ) );
  1674. match[5] = +( ( match[7] + match[8] ) || match[3] === "odd" );
  1675. // other types prohibit arguments
  1676. } else if ( match[3] ) {
  1677. Sizzle.error( match[0] );
  1678. }
  1679. return match;
  1680. },
  1681. "PSEUDO": function( match ) {
  1682. var excess,
  1683. unquoted = !match[5] && match[2];
  1684. if ( matchExpr["CHILD"].test( match[0] ) ) {
  1685. return null;
  1686. }
  1687. // Accept quoted arguments as-is
  1688. if ( match[3] && match[4] !== undefined ) {
  1689. match[2] = match[4];
  1690. // Strip excess characters from unquoted arguments
  1691. } else if ( unquoted && rpseudo.test( unquoted ) &&
  1692. // Get excess from tokenize (recursively)
  1693. (excess = tokenize( unquoted, true )) &&
  1694. // advance to the next closing parenthesis
  1695. (excess = unquoted.indexOf( ")", unquoted.length - excess ) - unquoted.length) ) {
  1696. // excess is a negative index
  1697. match[0] = match[0].slice( 0, excess );
  1698. match[2] = unquoted.slice( 0, excess );
  1699. }
  1700. // Return only captures needed by the pseudo filter method (type and argument)
  1701. return match.slice( 0, 3 );
  1702. }
  1703. },
  1704. filter: {
  1705. "TAG": function( nodeNameSelector ) {
  1706. var nodeName = nodeNameSelector.replace( runescape, funescape ).toLowerCase();
  1707. return nodeNameSelector === "*" ?
  1708. function() { return true; } :
  1709. function( elem ) {
  1710. return elem.nodeName && elem.nodeName.toLowerCase() === nodeName;
  1711. };
  1712. },
  1713. "CLASS": function( className ) {
  1714. var pattern = classCache[ className + " " ];
  1715. return pattern ||
  1716. (pattern = new RegExp( "(^|" + whitespace + ")" + className + "(" + whitespace + "|$)" )) &&
  1717. classCache( className, function( elem ) {
  1718. return pattern.test( typeof elem.className === "string" && elem.className || typeof elem.getAttribute !== strundefined && elem.getAttribute("class") || "" );
  1719. });
  1720. },
  1721. "ATTR": function( name, operator, check ) {
  1722. return function( elem ) {
  1723. var result = Sizzle.attr( elem, name );
  1724. if ( result == null ) {
  1725. return operator === "!=";
  1726. }
  1727. if ( !operator ) {
  1728. return true;
  1729. }
  1730. result += "";
  1731. return operator === "=" ? result === check :
  1732. operator === "!=" ? result !== check :
  1733. operator === "^=" ? check && result.indexOf( check ) === 0 :
  1734. operator === "*=" ? check && result.indexOf( check ) > -1 :
  1735. operator === "$=" ? check && result.slice( -check.length ) === check :
  1736. operator === "~=" ? ( " " + result + " " ).indexOf( check ) > -1 :
  1737. operator === "|=" ? result === check || result.slice( 0, check.length + 1 ) === check + "-" :
  1738. false;
  1739. };
  1740. },
  1741. "CHILD": function( type, what, argument, first, last ) {
  1742. var simple = type.slice( 0, 3 ) !== "nth",
  1743. forward = type.slice( -4 ) !== "last",
  1744. ofType = what === "of-type";
  1745. return first === 1 && last === 0 ?
  1746. // Shortcut for :nth-*(n)
  1747. function( elem ) {
  1748. return !!elem.parentNode;
  1749. } :
  1750. function( elem, context, xml ) {
  1751. var cache, outerCache, node, diff, nodeIndex, start,
  1752. dir = simple !== forward ? "nextSibling" : "previousSibling",
  1753. parent = elem.parentNode,
  1754. name = ofType && elem.nodeName.toLowerCase(),
  1755. useCache = !xml && !ofType;
  1756. if ( parent ) {
  1757. // :(first|last|only)-(child|of-type)
  1758. if ( simple ) {
  1759. while ( dir ) {
  1760. node = elem;
  1761. while ( (node = node[ dir ]) ) {
  1762. if ( ofType ? node.nodeName.toLowerCase() === name : node.nodeType === 1 ) {
  1763. return false;
  1764. }
  1765. }
  1766. // Reverse direction for :only-* (if we haven't yet done so)
  1767. start = dir = type === "only" && !start && "nextSibling";
  1768. }
  1769. return true;
  1770. }
  1771. start = [ forward ? parent.firstChild : parent.lastChild ];
  1772. // non-xml :nth-child(...) stores cache data on `parent`
  1773. if ( forward && useCache ) {
  1774. // Seek `elem` from a previously-cached index
  1775. outerCache = parent[ expando ] || (parent[ expando ] = {});
  1776. cache = outerCache[ type ] || [];
  1777. nodeIndex = cache[0] === dirruns && cache[1];
  1778. diff = cache[0] === dirruns && cache[2];
  1779. node = nodeIndex && parent.childNodes[ nodeIndex ];
  1780. while ( (node = ++nodeIndex && node && node[ dir ] ||
  1781. // Fallback to seeking `elem` from the start
  1782. (diff = nodeIndex = 0) || start.pop()) ) {
  1783. // When found, cache indexes on `parent` and break
  1784. if ( node.nodeType === 1 && ++diff && node === elem ) {
  1785. outerCache[ type ] = [ dirruns, nodeIndex, diff ];
  1786. break;
  1787. }
  1788. }
  1789. // Use previously-cached element index if available
  1790. } else if ( useCache && (cache = (elem[ expando ] || (elem[ expando ] = {}))[ type ]) && cache[0] === dirruns ) {
  1791. diff = cache[1];
  1792. // xml :nth-child(...) or :nth-last-child(...) or :nth(-last)?-of-type(...)
  1793. } else {
  1794. // Use the same loop as above to seek `elem` from the start
  1795. while ( (node = ++nodeIndex && node && node[ dir ] ||
  1796. (diff = nodeIndex = 0) || start.pop()) ) {
  1797. if ( ( ofType ? node.nodeName.toLowerCase() === name : node.nodeType === 1 ) && ++diff ) {
  1798. // Cache the index of each encountered element
  1799. if ( useCache ) {
  1800. (node[ expando ] || (node[ expando ] = {}))[ type ] = [ dirruns, diff ];
  1801. }
  1802. if ( node === elem ) {
  1803. break;
  1804. }
  1805. }
  1806. }
  1807. }
  1808. // Incorporate the offset, then check against cycle size
  1809. diff -= last;
  1810. return diff === first || ( diff % first === 0 && diff / first >= 0 );
  1811. }
  1812. };
  1813. },
  1814. "PSEUDO": function( pseudo, argument ) {
  1815. // pseudo-class names are case-insensitive
  1816. // http://www.w3.org/TR/selectors/#pseudo-classes
  1817. // Prioritize by case sensitivity in case custom pseudos are added with uppercase letters
  1818. // Remember that setFilters inherits from pseudos
  1819. var args,
  1820. fn = Expr.pseudos[ pseudo ] || Expr.setFilters[ pseudo.toLowerCase() ] ||
  1821. Sizzle.error( "unsupported pseudo: " + pseudo );
  1822. // The user may use createPseudo to indicate that
  1823. // arguments are needed to create the filter function
  1824. // just as Sizzle does
  1825. if ( fn[ expando ] ) {
  1826. return fn( argument );
  1827. }
  1828. // But maintain support for old signatures
  1829. if ( fn.length > 1 ) {
  1830. args = [ pseudo, pseudo, "", argument ];
  1831. return Expr.setFilters.hasOwnProperty( pseudo.toLowerCase() ) ?
  1832. markFunction(function( seed, matches ) {
  1833. var idx,
  1834. matched = fn( seed, argument ),
  1835. i = matched.length;
  1836. while ( i-- ) {
  1837. idx = indexOf.call( seed, matched[i] );
  1838. seed[ idx ] = !( matches[ idx ] = matched[i] );
  1839. }
  1840. }) :
  1841. function( elem ) {
  1842. return fn( elem, 0, args );
  1843. };
  1844. }
  1845. return fn;
  1846. }
  1847. },
  1848. pseudos: {
  1849. // Potentially complex pseudos
  1850. "not": markFunction(function( selector ) {
  1851. // Trim the selector passed to compile
  1852. // to avoid treating leading and trailing
  1853. // spaces as combinators
  1854. var input = [],
  1855. results = [],
  1856. matcher = compile( selector.replace( rtrim, "$1" ) );
  1857. return matcher[ expando ] ?
  1858. markFunction(function( seed, matches, context, xml ) {
  1859. var elem,
  1860. unmatched = matcher( seed, null, xml, [] ),
  1861. i = seed.length;
  1862. // Match elements unmatched by `matcher`
  1863. while ( i-- ) {
  1864. if ( (elem = unmatched[i]) ) {
  1865. seed[i] = !(matches[i] = elem);
  1866. }
  1867. }
  1868. }) :
  1869. function( elem, context, xml ) {
  1870. input[0] = elem;
  1871. matcher( input, null, xml, results );
  1872. return !results.pop();
  1873. };
  1874. }),
  1875. "has": markFunction(function( selector ) {
  1876. return function( elem ) {
  1877. return Sizzle( selector, elem ).length > 0;
  1878. };
  1879. }),
  1880. "contains": markFunction(function( text ) {
  1881. return function( elem ) {
  1882. return ( elem.textContent || elem.innerText || getText( elem ) ).indexOf( text ) > -1;
  1883. };
  1884. }),
  1885. // "Whether an element is represented by a :lang() selector
  1886. // is based solely on the element's language value
  1887. // being equal to the identifier C,
  1888. // or beginning with the identifier C immediately followed by "-".
  1889. // The matching of C against the element's language value is performed case-insensitively.
  1890. // The identifier C does not have to be a valid language name."
  1891. // http://www.w3.org/TR/selectors/#lang-pseudo
  1892. "lang": markFunction( function( lang ) {
  1893. // lang value must be a valid identifier
  1894. if ( !ridentifier.test(lang || "") ) {
  1895. Sizzle.error( "unsupported lang: " + lang );
  1896. }
  1897. lang = lang.replace( runescape, funescape ).toLowerCase();
  1898. return function( elem ) {
  1899. var elemLang;
  1900. do {
  1901. if ( (elemLang = documentIsHTML ?
  1902. elem.lang :
  1903. elem.getAttribute("xml:lang") || elem.getAttribute("lang")) ) {
  1904. elemLang = elemLang.toLowerCase();
  1905. return elemLang === lang || elemLang.indexOf( lang + "-" ) === 0;
  1906. }
  1907. } while ( (elem = elem.parentNode) && elem.nodeType === 1 );
  1908. return false;
  1909. };
  1910. }),
  1911. // Miscellaneous
  1912. "target": function( elem ) {
  1913. var hash = window.location && window.location.hash;
  1914. return hash && hash.slice( 1 ) === elem.id;
  1915. },
  1916. "root": function( elem ) {
  1917. return elem === docElem;
  1918. },
  1919. "focus": function( elem ) {
  1920. return elem === document.activeElement && (!document.hasFocus || document.hasFocus()) && !!(elem.type || elem.href || ~elem.tabIndex);
  1921. },
  1922. // Boolean properties
  1923. "enabled": function( elem ) {
  1924. return elem.disabled === false;
  1925. },
  1926. "disabled": function( elem ) {
  1927. return elem.disabled === true;
  1928. },
  1929. "checked": function( elem ) {
  1930. // In CSS3, :checked should return both checked and selected elements
  1931. // http://www.w3.org/TR/2011/REC-css3-selectors-20110929/#checked
  1932. var nodeName = elem.nodeName.toLowerCase();
  1933. return (nodeName === "input" && !!elem.checked) || (nodeName === "option" && !!elem.selected);
  1934. },
  1935. "selected": function( elem ) {
  1936. // Accessing this property makes selected-by-default
  1937. // options in Safari work properly
  1938. if ( elem.parentNode ) {
  1939. elem.parentNode.selectedIndex;
  1940. }
  1941. return elem.selected === true;
  1942. },
  1943. // Contents
  1944. "empty": function( elem ) {
  1945. // http://www.w3.org/TR/selectors/#empty-pseudo
  1946. // :empty is negated by element (1) or content nodes (text: 3; cdata: 4; entity ref: 5),
  1947. // but not by others (comment: 8; processing instruction: 7; etc.)
  1948. // nodeType < 6 works because attributes (2) do not appear as children
  1949. for ( elem = elem.firstChild; elem; elem = elem.nextSibling ) {
  1950. if ( elem.nodeType < 6 ) {
  1951. return false;
  1952. }
  1953. }
  1954. return true;
  1955. },
  1956. "parent": function( elem ) {
  1957. return !Expr.pseudos["empty"]( elem );
  1958. },
  1959. // Element/input types
  1960. "header": function( elem ) {
  1961. return rheader.test( elem.nodeName );
  1962. },
  1963. "input": function( elem ) {
  1964. return rinputs.test( elem.nodeName );
  1965. },
  1966. "button": function( elem ) {
  1967. var name = elem.nodeName.toLowerCase();
  1968. return name === "input" && elem.type === "button" || name === "button";
  1969. },
  1970. "text": function( elem ) {
  1971. var attr;
  1972. return elem.nodeName.toLowerCase() === "input" &&
  1973. elem.type === "text" &&
  1974. // Support: IE<8
  1975. // New HTML5 attribute values (e.g., "search") appear with elem.type === "text"
  1976. ( (attr = elem.getAttribute("type")) == null || attr.toLowerCase() === "text" );
  1977. },
  1978. // Position-in-collection
  1979. "first": createPositionalPseudo(function() {
  1980. return [ 0 ];
  1981. }),
  1982. "last": createPositionalPseudo(function( matchIndexes, length ) {
  1983. return [ length - 1 ];
  1984. }),
  1985. "eq": createPositionalPseudo(function( matchIndexes, length, argument ) {
  1986. return [ argument < 0 ? argument + length : argument ];
  1987. }),
  1988. "even": createPositionalPseudo(function( matchIndexes, length ) {
  1989. var i = 0;
  1990. for ( ; i < length; i += 2 ) {
  1991. matchIndexes.push( i );
  1992. }
  1993. return matchIndexes;
  1994. }),
  1995. "odd": createPositionalPseudo(function( matchIndexes, length ) {
  1996. var i = 1;
  1997. for ( ; i < length; i += 2 ) {
  1998. matchIndexes.push( i );
  1999. }
  2000. return matchIndexes;
  2001. }),
  2002. "lt": createPositionalPseudo(function( matchIndexes, length, argument ) {
  2003. var i = argument < 0 ? argument + length : argument;
  2004. for ( ; --i >= 0; ) {
  2005. matchIndexes.push( i );
  2006. }
  2007. return matchIndexes;
  2008. }),
  2009. "gt": createPositionalPseudo(function( matchIndexes, length, argument ) {
  2010. var i = argument < 0 ? argument + length : argument;
  2011. for ( ; ++i < length; ) {
  2012. matchIndexes.push( i );
  2013. }
  2014. return matchIndexes;
  2015. })
  2016. }
  2017. };
  2018. Expr.pseudos["nth"] = Expr.pseudos["eq"];
  2019. // Add button/input type pseudos
  2020. for ( i in { radio: true, checkbox: true, file: true, password: true, image: true } ) {
  2021. Expr.pseudos[ i ] = createInputPseudo( i );
  2022. }
  2023. for ( i in { submit: true, reset: true } ) {
  2024. Expr.pseudos[ i ] = createButtonPseudo( i );
  2025. }
  2026. // Easy API for creating new setFilters
  2027. function setFilters() {}
  2028. setFilters.prototype = Expr.filters = Expr.pseudos;
  2029. Expr.setFilters = new setFilters();
  2030. function tokenize( selector, parseOnly ) {
  2031. var matched, match, tokens, type,
  2032. soFar, groups, preFilters,
  2033. cached = tokenCache[ selector + " " ];
  2034. if ( cached ) {
  2035. return parseOnly ? 0 : cached.slice( 0 );
  2036. }
  2037. soFar = selector;
  2038. groups = [];
  2039. preFilters = Expr.preFilter;
  2040. while ( soFar ) {
  2041. // Comma and first run
  2042. if ( !matched || (match = rcomma.exec( soFar )) ) {
  2043. if ( match ) {
  2044. // Don't consume trailing commas as valid
  2045. soFar = soFar.slice( match[0].length ) || soFar;
  2046. }
  2047. groups.push( (tokens = []) );
  2048. }
  2049. matched = false;
  2050. // Combinators
  2051. if ( (match = rcombinators.exec( soFar )) ) {
  2052. matched = match.shift();
  2053. tokens.push({
  2054. value: matched,
  2055. // Cast descendant combinators to space
  2056. type: match[0].replace( rtrim, " " )
  2057. });
  2058. soFar = soFar.slice( matched.length );
  2059. }
  2060. // Filters
  2061. for ( type in Expr.filter ) {
  2062. if ( (match = matchExpr[ type ].exec( soFar )) && (!preFilters[ type ] ||
  2063. (match = preFilters[ type ]( match ))) ) {
  2064. matched = match.shift();
  2065. tokens.push({
  2066. value: matched,
  2067. type: type,
  2068. matches: match
  2069. });
  2070. soFar = soFar.slice( matched.length );
  2071. }
  2072. }
  2073. if ( !matched ) {
  2074. break;
  2075. }
  2076. }
  2077. // Return the length of the invalid excess
  2078. // if we're just parsing
  2079. // Otherwise, throw an error or return tokens
  2080. return parseOnly ?
  2081. soFar.length :
  2082. soFar ?
  2083. Sizzle.error( selector ) :
  2084. // Cache the tokens
  2085. tokenCache( selector, groups ).slice( 0 );
  2086. }
  2087. function toSelector( tokens ) {
  2088. var i = 0,
  2089. len = tokens.length,
  2090. selector = "";
  2091. for ( ; i < len; i++ ) {
  2092. selector += tokens[i].value;
  2093. }
  2094. return selector;
  2095. }
  2096. function addCombinator( matcher, combinator, base ) {
  2097. var dir = combinator.dir,
  2098. checkNonElements = base && dir === "parentNode",
  2099. doneName = done++;
  2100. return combinator.first ?
  2101. // Check against closest ancestor/preceding element
  2102. function( elem, context, xml ) {
  2103. while ( (elem = elem[ dir ]) ) {
  2104. if ( elem.nodeType === 1 || checkNonElements ) {
  2105. return matcher( elem, context, xml );
  2106. }
  2107. }
  2108. } :
  2109. // Check against all ancestor/preceding elements
  2110. function( elem, context, xml ) {
  2111. var oldCache, outerCache,
  2112. newCache = [ dirruns, doneName ];
  2113. // We can't set arbitrary data on XML nodes, so they don't benefit from dir caching
  2114. if ( xml ) {
  2115. while ( (elem = elem[ dir ]) ) {
  2116. if ( elem.nodeType === 1 || checkNonElements ) {
  2117. if ( matcher( elem, context, xml ) ) {
  2118. return true;
  2119. }
  2120. }
  2121. }
  2122. } else {
  2123. while ( (elem = elem[ dir ]) ) {
  2124. if ( elem.nodeType === 1 || checkNonElements ) {
  2125. outerCache = elem[ expando ] || (elem[ expando ] = {});
  2126. if ( (oldCache = outerCache[ dir ]) &&
  2127. oldCache[ 0 ] === dirruns && oldCache[ 1 ] === doneName ) {
  2128. // Assign to newCache so results back-propagate to previous elements
  2129. return (newCache[ 2 ] = oldCache[ 2 ]);
  2130. } else {
  2131. // Reuse newcache so results back-propagate to previous elements
  2132. outerCache[ dir ] = newCache;
  2133. // A match means we're done; a fail means we have to keep checking
  2134. if ( (newCache[ 2 ] = matcher( elem, context, xml )) ) {
  2135. return true;
  2136. }
  2137. }
  2138. }
  2139. }
  2140. }
  2141. };
  2142. }
  2143. function elementMatcher( matchers ) {
  2144. return matchers.length > 1 ?
  2145. function( elem, context, xml ) {
  2146. var i = matchers.length;
  2147. while ( i-- ) {
  2148. if ( !matchers[i]( elem, context, xml ) ) {
  2149. return false;
  2150. }
  2151. }
  2152. return true;
  2153. } :
  2154. matchers[0];
  2155. }
  2156. function condense( unmatched, map, filter, context, xml ) {
  2157. var elem,
  2158. newUnmatched = [],
  2159. i = 0,
  2160. len = unmatched.length,
  2161. mapped = map != null;
  2162. for ( ; i < len; i++ ) {
  2163. if ( (elem = unmatched[i]) ) {
  2164. if ( !filter || filter( elem, context, xml ) ) {
  2165. newUnmatched.push( elem );
  2166. if ( mapped ) {
  2167. map.push( i );
  2168. }
  2169. }
  2170. }
  2171. }
  2172. return newUnmatched;
  2173. }
  2174. function setMatcher( preFilter, selector, matcher, postFilter, postFinder, postSelector ) {
  2175. if ( postFilter && !postFilter[ expando ] ) {
  2176. postFilter = setMatcher( postFilter );
  2177. }
  2178. if ( postFinder && !postFinder[ expando ] ) {
  2179. postFinder = setMatcher( postFinder, postSelector );
  2180. }
  2181. return markFunction(function( seed, results, context, xml ) {
  2182. var temp, i, elem,
  2183. preMap = [],
  2184. postMap = [],
  2185. preexisting = results.length,
  2186. // Get initial elements from seed or context
  2187. elems = seed || multipleContexts( selector || "*", context.nodeType ? [ context ] : context, [] ),
  2188. // Prefilter to get matcher input, preserving a map for seed-results synchronization
  2189. matcherIn = preFilter && ( seed || !selector ) ?
  2190. condense( elems, preMap, preFilter, context, xml ) :
  2191. elems,
  2192. matcherOut = matcher ?
  2193. // If we have a postFinder, or filtered seed, or non-seed postFilter or preexisting results,
  2194. postFinder || ( seed ? preFilter : preexisting || postFilter ) ?
  2195. // ...intermediate processing is necessary
  2196. [] :
  2197. // ...otherwise use results directly
  2198. results :
  2199. matcherIn;
  2200. // Find primary matches
  2201. if ( matcher ) {
  2202. matcher( matcherIn, matcherOut, context, xml );
  2203. }
  2204. // Apply postFilter
  2205. if ( postFilter ) {
  2206. temp = condense( matcherOut, postMap );
  2207. postFilter( temp, [], context, xml );
  2208. // Un-match failing elements by moving them back to matcherIn
  2209. i = temp.length;
  2210. while ( i-- ) {
  2211. if ( (elem = temp[i]) ) {
  2212. matcherOut[ postMap[i] ] = !(matcherIn[ postMap[i] ] = elem);
  2213. }
  2214. }
  2215. }
  2216. if ( seed ) {
  2217. if ( postFinder || preFilter ) {
  2218. if ( postFinder ) {
  2219. // Get the final matcherOut by condensing this intermediate into postFinder contexts
  2220. temp = [];
  2221. i = matcherOut.length;
  2222. while ( i-- ) {
  2223. if ( (elem = matcherOut[i]) ) {
  2224. // Restore matcherIn since elem is not yet a final match
  2225. temp.push( (matcherIn[i] = elem) );
  2226. }
  2227. }
  2228. postFinder( null, (matcherOut = []), temp, xml );
  2229. }
  2230. // Move matched elements from seed to results to keep them synchronized
  2231. i = matcherOut.length;
  2232. while ( i-- ) {
  2233. if ( (elem = matcherOut[i]) &&
  2234. (temp = postFinder ? indexOf.call( seed, elem ) : preMap[i]) > -1 ) {
  2235. seed[temp] = !(results[temp] = elem);
  2236. }
  2237. }
  2238. }
  2239. // Add elements to results, through postFinder if defined
  2240. } else {
  2241. matcherOut = condense(
  2242. matcherOut === results ?
  2243. matcherOut.splice( preexisting, matcherOut.length ) :
  2244. matcherOut
  2245. );
  2246. if ( postFinder ) {
  2247. postFinder( null, results, matcherOut, xml );
  2248. } else {
  2249. push.apply( results, matcherOut );
  2250. }
  2251. }
  2252. });
  2253. }
  2254. function matcherFromTokens( tokens ) {
  2255. var checkContext, matcher, j,
  2256. len = tokens.length,
  2257. leadingRelative = Expr.relative[ tokens[0].type ],
  2258. implicitRelative = leadingRelative || Expr.relative[" "],
  2259. i = leadingRelative ? 1 : 0,
  2260. // The foundational matcher ensures that elements are reachable from top-level context(s)
  2261. matchContext = addCombinator( function( elem ) {
  2262. return elem === checkContext;
  2263. }, implicitRelative, true ),
  2264. matchAnyContext = addCombinator( function( elem ) {
  2265. return indexOf.call( checkContext, elem ) > -1;
  2266. }, implicitRelative, true ),
  2267. matchers = [ function( elem, context, xml ) {
  2268. return ( !leadingRelative && ( xml || context !== outermostContext ) ) || (
  2269. (checkContext = context).nodeType ?
  2270. matchContext( elem, context, xml ) :
  2271. matchAnyContext( elem, context, xml ) );
  2272. } ];
  2273. for ( ; i < len; i++ ) {
  2274. if ( (matcher = Expr.relative[ tokens[i].type ]) ) {
  2275. matchers = [ addCombinator(elementMatcher( matchers ), matcher) ];
  2276. } else {
  2277. matcher = Expr.filter[ tokens[i].type ].apply( null, tokens[i].matches );
  2278. // Return special upon seeing a positional matcher
  2279. if ( matcher[ expando ] ) {
  2280. // Find the next relative operator (if any) for proper handling
  2281. j = ++i;
  2282. for ( ; j < len; j++ ) {
  2283. if ( Expr.relative[ tokens[j].type ] ) {
  2284. break;
  2285. }
  2286. }
  2287. return setMatcher(
  2288. i > 1 && elementMatcher( matchers ),
  2289. i > 1 && toSelector(
  2290. // If the preceding token was a descendant combinator, insert an implicit any-element `*`
  2291. tokens.slice( 0, i - 1 ).concat({ value: tokens[ i - 2 ].type === " " ? "*" : "" })
  2292. ).replace( rtrim, "$1" ),
  2293. matcher,
  2294. i < j && matcherFromTokens( tokens.slice( i, j ) ),
  2295. j < len && matcherFromTokens( (tokens = tokens.slice( j )) ),
  2296. j < len && toSelector( tokens )
  2297. );
  2298. }
  2299. matchers.push( matcher );
  2300. }
  2301. }
  2302. return elementMatcher( matchers );
  2303. }
  2304. function matcherFromGroupMatchers( elementMatchers, setMatchers ) {
  2305. var bySet = setMatchers.length > 0,
  2306. byElement = elementMatchers.length > 0,
  2307. superMatcher = function( seed, context, xml, results, outermost ) {
  2308. var elem, j, matcher,
  2309. matchedCount = 0,
  2310. i = "0",
  2311. unmatched = seed && [],
  2312. setMatched = [],
  2313. contextBackup = outermostContext,
  2314. // We must always have either seed elements or outermost context
  2315. elems = seed || byElement && Expr.find["TAG"]( "*", outermost ),
  2316. // Use integer dirruns iff this is the outermost matcher
  2317. dirrunsUnique = (dirruns += contextBackup == null ? 1 : Math.random() || 0.1),
  2318. len = elems.length;
  2319. if ( outermost ) {
  2320. outermostContext = context !== document && context;
  2321. }
  2322. // Add elements passing elementMatchers directly to results
  2323. // Keep `i` a string if there are no elements so `matchedCount` will be "00" below
  2324. // Support: IE<9, Safari
  2325. // Tolerate NodeList properties (IE: "length"; Safari: <number>) matching elements by id
  2326. for ( ; i !== len && (elem = elems[i]) != null; i++ ) {
  2327. if ( byElement && elem ) {
  2328. j = 0;
  2329. while ( (matcher = elementMatchers[j++]) ) {
  2330. if ( matcher( elem, context, xml ) ) {
  2331. results.push( elem );
  2332. break;
  2333. }
  2334. }
  2335. if ( outermost ) {
  2336. dirruns = dirrunsUnique;
  2337. }
  2338. }
  2339. // Track unmatched elements for set filters
  2340. if ( bySet ) {
  2341. // They will have gone through all possible matchers
  2342. if ( (elem = !matcher && elem) ) {
  2343. matchedCount--;
  2344. }
  2345. // Lengthen the array for every element, matched or not
  2346. if ( seed ) {
  2347. unmatched.push( elem );
  2348. }
  2349. }
  2350. }
  2351. // Apply set filters to unmatched elements
  2352. matchedCount += i;
  2353. if ( bySet && i !== matchedCount ) {
  2354. j = 0;
  2355. while ( (matcher = setMatchers[j++]) ) {
  2356. matcher( unmatched, setMatched, context, xml );
  2357. }
  2358. if ( seed ) {
  2359. // Reintegrate element matches to eliminate the need for sorting
  2360. if ( matchedCount > 0 ) {
  2361. while ( i-- ) {
  2362. if ( !(unmatched[i] || setMatched[i]) ) {
  2363. setMatched[i] = pop.call( results );
  2364. }
  2365. }
  2366. }
  2367. // Discard index placeholder values to get only actual matches
  2368. setMatched = condense( setMatched );
  2369. }
  2370. // Add matches to results
  2371. push.apply( results, setMatched );
  2372. // Seedless set matches succeeding multiple successful matchers stipulate sorting
  2373. if ( outermost && !seed && setMatched.length > 0 &&
  2374. ( matchedCount + setMatchers.length ) > 1 ) {
  2375. Sizzle.uniqueSort( results );
  2376. }
  2377. }
  2378. // Override manipulation of globals by nested matchers
  2379. if ( outermost ) {
  2380. dirruns = dirrunsUnique;
  2381. outermostContext = contextBackup;
  2382. }
  2383. return unmatched;
  2384. };
  2385. return bySet ?
  2386. markFunction( superMatcher ) :
  2387. superMatcher;
  2388. }
  2389. compile = Sizzle.compile = function( selector, group /* Internal Use Only */ ) {
  2390. var i,
  2391. setMatchers = [],
  2392. elementMatchers = [],
  2393. cached = compilerCache[ selector + " " ];
  2394. if ( !cached ) {
  2395. // Generate a function of recursive functions that can be used to check each element
  2396. if ( !group ) {
  2397. group = tokenize( selector );
  2398. }
  2399. i = group.length;
  2400. while ( i-- ) {
  2401. cached = matcherFromTokens( group[i] );
  2402. if ( cached[ expando ] ) {
  2403. setMatchers.push( cached );
  2404. } else {
  2405. elementMatchers.push( cached );
  2406. }
  2407. }
  2408. // Cache the compiled function
  2409. cached = compilerCache( selector, matcherFromGroupMatchers( elementMatchers, setMatchers ) );
  2410. }
  2411. return cached;
  2412. };
  2413. function multipleContexts( selector, contexts, results ) {
  2414. var i = 0,
  2415. len = contexts.length;
  2416. for ( ; i < len; i++ ) {
  2417. Sizzle( selector, contexts[i], results );
  2418. }
  2419. return results;
  2420. }
  2421. function select( selector, context, results, seed ) {
  2422. var i, tokens, token, type, find,
  2423. match = tokenize( selector );
  2424. if ( !seed ) {
  2425. // Try to minimize operations if there is only one group
  2426. if ( match.length === 1 ) {
  2427. // Take a shortcut and set the context if the root selector is an ID
  2428. tokens = match[0] = match[0].slice( 0 );
  2429. if ( tokens.length > 2 && (token = tokens[0]).type === "ID" &&
  2430. support.getById && context.nodeType === 9 && documentIsHTML &&
  2431. Expr.relative[ tokens[1].type ] ) {
  2432. context = ( Expr.find["ID"]( token.matches[0].replace(runescape, funescape), context ) || [] )[0];
  2433. if ( !context ) {
  2434. return results;
  2435. }
  2436. selector = selector.slice( tokens.shift().value.length );
  2437. }
  2438. // Fetch a seed set for right-to-left matching
  2439. i = matchExpr["needsContext"].test( selector ) ? 0 : tokens.length;
  2440. while ( i-- ) {
  2441. token = tokens[i];
  2442. // Abort if we hit a combinator
  2443. if ( Expr.relative[ (type = token.type) ] ) {
  2444. break;
  2445. }
  2446. if ( (find = Expr.find[ type ]) ) {
  2447. // Search, expanding context for leading sibling combinators
  2448. if ( (seed = find(
  2449. token.matches[0].replace( runescape, funescape ),
  2450. rsibling.test( tokens[0].type ) && testContext( context.parentNode ) || context
  2451. )) ) {
  2452. // If seed is empty or no tokens remain, we can return early
  2453. tokens.splice( i, 1 );
  2454. selector = seed.length && toSelector( tokens );
  2455. if ( !selector ) {
  2456. push.apply( results, seed );
  2457. return results;
  2458. }
  2459. break;
  2460. }
  2461. }
  2462. }
  2463. }
  2464. }
  2465. // Compile and execute a filtering function
  2466. // Provide `match` to avoid retokenization if we modified the selector above
  2467. compile( selector, match )(
  2468. seed,
  2469. context,
  2470. !documentIsHTML,
  2471. results,
  2472. rsibling.test( selector ) && testContext( context.parentNode ) || context
  2473. );
  2474. return results;
  2475. }
  2476. // One-time assignments
  2477. // Sort stability
  2478. support.sortStable = expando.split("").sort( sortOrder ).join("") === expando;
  2479. // Support: Chrome<14
  2480. // Always assume duplicates if they aren't passed to the comparison function
  2481. support.detectDuplicates = !!hasDuplicate;
  2482. // Initialize against the default document
  2483. setDocument();
  2484. // Support: Webkit<537.32 - Safari 6.0.3/Chrome 25 (fixed in Chrome 27)
  2485. // Detached nodes confoundingly follow *each other*
  2486. support.sortDetached = assert(function( div1 ) {
  2487. // Should return 1, but returns 4 (following)
  2488. return div1.compareDocumentPosition( document.createElement("div") ) & 1;
  2489. });
  2490. // Support: IE<8
  2491. // Prevent attribute/property "interpolation"
  2492. // http://msdn.microsoft.com/en-us/library/ms536429%28VS.85%29.aspx
  2493. if ( !assert(function( div ) {
  2494. div.innerHTML = "<a href='#'></a>";
  2495. return div.firstChild.getAttribute("href") === "#" ;
  2496. }) ) {
  2497. addHandle( "type|href|height|width", function( elem, name, isXML ) {
  2498. if ( !isXML ) {
  2499. return elem.getAttribute( name, name.toLowerCase() === "type" ? 1 : 2 );
  2500. }
  2501. });
  2502. }
  2503. // Support: IE<9
  2504. // Use defaultValue in place of getAttribute("value")
  2505. if ( !support.attributes || !assert(function( div ) {
  2506. div.innerHTML = "<input/>";
  2507. div.firstChild.setAttribute( "value", "" );
  2508. return div.firstChild.getAttribute( "value" ) === "";
  2509. }) ) {
  2510. addHandle( "value", function( elem, name, isXML ) {
  2511. if ( !isXML && elem.nodeName.toLowerCase() === "input" ) {
  2512. return elem.defaultValue;
  2513. }
  2514. });
  2515. }
  2516. // Support: IE<9
  2517. // Use getAttributeNode to fetch booleans when getAttribute lies
  2518. if ( !assert(function( div ) {
  2519. return div.getAttribute("disabled") == null;
  2520. }) ) {
  2521. addHandle( booleans, function( elem, name, isXML ) {
  2522. var val;
  2523. if ( !isXML ) {
  2524. return elem[ name ] === true ? name.toLowerCase() :
  2525. (val = elem.getAttributeNode( name )) && val.specified ?
  2526. val.value :
  2527. null;
  2528. }
  2529. });
  2530. }
  2531. return Sizzle;
  2532. })( window );
  2533. jQuery.find = Sizzle;
  2534. jQuery.expr = Sizzle.selectors;
  2535. jQuery.expr[":"] = jQuery.expr.pseudos;
  2536. jQuery.unique = Sizzle.uniqueSort;
  2537. jQuery.text = Sizzle.getText;
  2538. jQuery.isXMLDoc = Sizzle.isXML;
  2539. jQuery.contains = Sizzle.contains;
  2540. var rneedsContext = jQuery.expr.match.needsContext;
  2541. var rsingleTag = (/^<(\w+)\s*\/?>(?:<\/\1>|)$/);
  2542. var risSimple = /^.[^:#\[\.,]*$/;
  2543. // Implement the identical functionality for filter and not
  2544. function winnow( elements, qualifier, not ) {
  2545. if ( jQuery.isFunction( qualifier ) ) {
  2546. return jQuery.grep( elements, function( elem, i ) {
  2547. /* jshint -W018 */
  2548. return !!qualifier.call( elem, i, elem ) !== not;
  2549. });
  2550. }
  2551. if ( qualifier.nodeType ) {
  2552. return jQuery.grep( elements, function( elem ) {
  2553. return ( elem === qualifier ) !== not;
  2554. });
  2555. }
  2556. if ( typeof qualifier === "string" ) {
  2557. if ( risSimple.test( qualifier ) ) {
  2558. return jQuery.filter( qualifier, elements, not );
  2559. }
  2560. qualifier = jQuery.filter( qualifier, elements );
  2561. }
  2562. return jQuery.grep( elements, function( elem ) {
  2563. return ( indexOf.call( qualifier, elem ) >= 0 ) !== not;
  2564. });
  2565. }
  2566. jQuery.filter = function( expr, elems, not ) {
  2567. var elem = elems[ 0 ];
  2568. if ( not ) {
  2569. expr = ":not(" + expr + ")";
  2570. }
  2571. return elems.length === 1 && elem.nodeType === 1 ?
  2572. jQuery.find.matchesSelector( elem, expr ) ? [ elem ] : [] :
  2573. jQuery.find.matches( expr, jQuery.grep( elems, function( elem ) {
  2574. return elem.nodeType === 1;
  2575. }));
  2576. };
  2577. jQuery.fn.extend({
  2578. find: function( selector ) {
  2579. var i,
  2580. len = this.length,
  2581. ret = [],
  2582. self = this;
  2583. if ( typeof selector !== "string" ) {
  2584. return this.pushStack( jQuery( selector ).filter(function() {
  2585. for ( i = 0; i < len; i++ ) {
  2586. if ( jQuery.contains( self[ i ], this ) ) {
  2587. return true;
  2588. }
  2589. }
  2590. }) );
  2591. }
  2592. for ( i = 0; i < len; i++ ) {
  2593. jQuery.find( selector, self[ i ], ret );
  2594. }
  2595. // Needed because $( selector, context ) becomes $( context ).find( selector )
  2596. ret = this.pushStack( len > 1 ? jQuery.unique( ret ) : ret );
  2597. ret.selector = this.selector ? this.selector + " " + selector : selector;
  2598. return ret;
  2599. },
  2600. filter: function( selector ) {
  2601. return this.pushStack( winnow(this, selector || [], false) );
  2602. },
  2603. not: function( selector ) {
  2604. return this.pushStack( winnow(this, selector || [], true) );
  2605. },
  2606. is: function( selector ) {
  2607. return !!winnow(
  2608. this,
  2609. // If this is a positional/relative selector, check membership in the returned set
  2610. // so $("p:first").is("p:last") won't return true for a doc with two "p".
  2611. typeof selector === "string" && rneedsContext.test( selector ) ?
  2612. jQuery( selector ) :
  2613. selector || [],
  2614. false
  2615. ).length;
  2616. }
  2617. });
  2618. // Initialize a jQuery object
  2619. // A central reference to the root jQuery(document)
  2620. var rootjQuery,
  2621. // A simple way to check for HTML strings
  2622. // Prioritize #id over <tag> to avoid XSS via location.hash (#9521)
  2623. // Strict HTML recognition (#11290: must start with <)
  2624. rquickExpr = /^(?:\s*(<[\w\W]+>)[^>]*|#([\w-]*))$/,
  2625. init = jQuery.fn.init = function( selector, context ) {
  2626. var match, elem;
  2627. // HANDLE: $(""), $(null), $(undefined), $(false)
  2628. if ( !selector ) {
  2629. return this;
  2630. }
  2631. // Handle HTML strings
  2632. if ( typeof selector === "string" ) {
  2633. if ( selector[0] === "<" && selector[ selector.length - 1 ] === ">" && selector.length >= 3 ) {
  2634. // Assume that strings that start and end with <> are HTML and skip the regex check
  2635. match = [ null, selector, null ];
  2636. } else {
  2637. match = rquickExpr.exec( selector );
  2638. }
  2639. // Match html or make sure no context is specified for #id
  2640. if ( match && (match[1] || !context) ) {
  2641. // HANDLE: $(html) -> $(array)
  2642. if ( match[1] ) {
  2643. context = context instanceof jQuery ? context[0] : context;
  2644. // scripts is true for back-compat
  2645. // Intentionally let the error be thrown if parseHTML is not present
  2646. jQuery.merge( this, jQuery.parseHTML(
  2647. match[1],
  2648. context && context.nodeType ? context.ownerDocument || context : document,
  2649. true
  2650. ) );
  2651. // HANDLE: $(html, props)
  2652. if ( rsingleTag.test( match[1] ) && jQuery.isPlainObject( context ) ) {
  2653. for ( match in context ) {
  2654. // Properties of context are called as methods if possible
  2655. if ( jQuery.isFunction( this[ match ] ) ) {
  2656. this[ match ]( context[ match ] );
  2657. // ...and otherwise set as attributes
  2658. } else {
  2659. this.attr( match, context[ match ] );
  2660. }
  2661. }
  2662. }
  2663. return this;
  2664. // HANDLE: $(#id)
  2665. } else {
  2666. elem = document.getElementById( match[2] );
  2667. // Check parentNode to catch when Blackberry 4.6 returns
  2668. // nodes that are no longer in the document #6963
  2669. if ( elem && elem.parentNode ) {
  2670. // Inject the element directly into the jQuery object
  2671. this.length = 1;
  2672. this[0] = elem;
  2673. }
  2674. this.context = document;
  2675. this.selector = selector;
  2676. return this;
  2677. }
  2678. // HANDLE: $(expr, $(...))
  2679. } else if ( !context || context.jquery ) {
  2680. return ( context || rootjQuery ).find( selector );
  2681. // HANDLE: $(expr, context)
  2682. // (which is just equivalent to: $(context).find(expr)
  2683. } else {
  2684. return this.constructor( context ).find( selector );
  2685. }
  2686. // HANDLE: $(DOMElement)
  2687. } else if ( selector.nodeType ) {
  2688. this.context = this[0] = selector;
  2689. this.length = 1;
  2690. return this;
  2691. // HANDLE: $(function)
  2692. // Shortcut for document ready
  2693. } else if ( jQuery.isFunction( selector ) ) {
  2694. return typeof rootjQuery.ready !== "undefined" ?
  2695. rootjQuery.ready( selector ) :
  2696. // Execute immediately if ready is not present
  2697. selector( jQuery );
  2698. }
  2699. if ( selector.selector !== undefined ) {
  2700. this.selector = selector.selector;
  2701. this.context = selector.context;
  2702. }
  2703. return jQuery.makeArray( selector, this );
  2704. };
  2705. // Give the init function the jQuery prototype for later instantiation
  2706. init.prototype = jQuery.fn;
  2707. // Initialize central reference
  2708. rootjQuery = jQuery( document );
  2709. var rparentsprev = /^(?:parents|prev(?:Until|All))/,
  2710. // methods guaranteed to produce a unique set when starting from a unique set
  2711. guaranteedUnique = {
  2712. children: true,
  2713. contents: true,
  2714. next: true,
  2715. prev: true
  2716. };
  2717. jQuery.extend({
  2718. dir: function( elem, dir, until ) {
  2719. var matched = [],
  2720. truncate = until !== undefined;
  2721. while ( (elem = elem[ dir ]) && elem.nodeType !== 9 ) {
  2722. if ( elem.nodeType === 1 ) {
  2723. if ( truncate && jQuery( elem ).is( until ) ) {
  2724. break;
  2725. }
  2726. matched.push( elem );
  2727. }
  2728. }
  2729. return matched;
  2730. },
  2731. sibling: function( n, elem ) {
  2732. var matched = [];
  2733. for ( ; n; n = n.nextSibling ) {
  2734. if ( n.nodeType === 1 && n !== elem ) {
  2735. matched.push( n );
  2736. }
  2737. }
  2738. return matched;
  2739. }
  2740. });
  2741. jQuery.fn.extend({
  2742. has: function( target ) {
  2743. var targets = jQuery( target, this ),
  2744. l = targets.length;
  2745. return this.filter(function() {
  2746. var i = 0;
  2747. for ( ; i < l; i++ ) {
  2748. if ( jQuery.contains( this, targets[i] ) ) {
  2749. return true;
  2750. }
  2751. }
  2752. });
  2753. },
  2754. closest: function( selectors, context ) {
  2755. var cur,
  2756. i = 0,
  2757. l = this.length,
  2758. matched = [],
  2759. pos = rneedsContext.test( selectors ) || typeof selectors !== "string" ?
  2760. jQuery( selectors, context || this.context ) :
  2761. 0;
  2762. for ( ; i < l; i++ ) {
  2763. for ( cur = this[i]; cur && cur !== context; cur = cur.parentNode ) {
  2764. // Always skip document fragments
  2765. if ( cur.nodeType < 11 && (pos ?
  2766. pos.index(cur) > -1 :
  2767. // Don't pass non-elements to Sizzle
  2768. cur.nodeType === 1 &&
  2769. jQuery.find.matchesSelector(cur, selectors)) ) {
  2770. matched.push( cur );
  2771. break;
  2772. }
  2773. }
  2774. }
  2775. return this.pushStack( matched.length > 1 ? jQuery.unique( matched ) : matched );
  2776. },
  2777. // Determine the position of an element within
  2778. // the matched set of elements
  2779. index: function( elem ) {
  2780. // No argument, return index in parent
  2781. if ( !elem ) {
  2782. return ( this[ 0 ] && this[ 0 ].parentNode ) ? this.first().prevAll().length : -1;
  2783. }
  2784. // index in selector
  2785. if ( typeof elem === "string" ) {
  2786. return indexOf.call( jQuery( elem ), this[ 0 ] );
  2787. }
  2788. // Locate the position of the desired element
  2789. return indexOf.call( this,
  2790. // If it receives a jQuery object, the first element is used
  2791. elem.jquery ? elem[ 0 ] : elem
  2792. );
  2793. },
  2794. add: function( selector, context ) {
  2795. return this.pushStack(
  2796. jQuery.unique(
  2797. jQuery.merge( this.get(), jQuery( selector, context ) )
  2798. )
  2799. );
  2800. },
  2801. addBack: function( selector ) {
  2802. return this.add( selector == null ?
  2803. this.prevObject : this.prevObject.filter(selector)
  2804. );
  2805. }
  2806. });
  2807. function sibling( cur, dir ) {
  2808. while ( (cur = cur[dir]) && cur.nodeType !== 1 ) {}
  2809. return cur;
  2810. }
  2811. jQuery.each({
  2812. parent: function( elem ) {
  2813. var parent = elem.parentNode;
  2814. return parent && parent.nodeType !== 11 ? parent : null;
  2815. },
  2816. parents: function( elem ) {
  2817. return jQuery.dir( elem, "parentNode" );
  2818. },
  2819. parentsUntil: function( elem, i, until ) {
  2820. return jQuery.dir( elem, "parentNode", until );
  2821. },
  2822. next: function( elem ) {
  2823. return sibling( elem, "nextSibling" );
  2824. },
  2825. prev: function( elem ) {
  2826. return sibling( elem, "previousSibling" );
  2827. },
  2828. nextAll: function( elem ) {
  2829. return jQuery.dir( elem, "nextSibling" );
  2830. },
  2831. prevAll: function( elem ) {
  2832. return jQuery.dir( elem, "previousSibling" );
  2833. },
  2834. nextUntil: function( elem, i, until ) {
  2835. return jQuery.dir( elem, "nextSibling", until );
  2836. },
  2837. prevUntil: function( elem, i, until ) {
  2838. return jQuery.dir( elem, "previousSibling", until );
  2839. },
  2840. siblings: function( elem ) {
  2841. return jQuery.sibling( ( elem.parentNode || {} ).firstChild, elem );
  2842. },
  2843. children: function( elem ) {
  2844. return jQuery.sibling( elem.firstChild );
  2845. },
  2846. contents: function( elem ) {
  2847. return elem.contentDocument || jQuery.merge( [], elem.childNodes );
  2848. }
  2849. }, function( name, fn ) {
  2850. jQuery.fn[ name ] = function( until, selector ) {
  2851. var matched = jQuery.map( this, fn, until );
  2852. if ( name.slice( -5 ) !== "Until" ) {
  2853. selector = until;
  2854. }
  2855. if ( selector && typeof selector === "string" ) {
  2856. matched = jQuery.filter( selector, matched );
  2857. }
  2858. if ( this.length > 1 ) {
  2859. // Remove duplicates
  2860. if ( !guaranteedUnique[ name ] ) {
  2861. jQuery.unique( matched );
  2862. }
  2863. // Reverse order for parents* and prev-derivatives
  2864. if ( rparentsprev.test( name ) ) {
  2865. matched.reverse();
  2866. }
  2867. }
  2868. return this.pushStack( matched );
  2869. };
  2870. });
  2871. var rnotwhite = (/\S+/g);
  2872. // String to Object options format cache
  2873. var optionsCache = {};
  2874. // Convert String-formatted options into Object-formatted ones and store in cache
  2875. function createOptions( options ) {
  2876. var object = optionsCache[ options ] = {};
  2877. jQuery.each( options.match( rnotwhite ) || [], function( _, flag ) {
  2878. object[ flag ] = true;
  2879. });
  2880. return object;
  2881. }
  2882. /*
  2883. * Create a callback list using the following parameters:
  2884. *
  2885. * options: an optional list of space-separated options that will change how
  2886. * the callback list behaves or a more traditional option object
  2887. *
  2888. * By default a callback list will act like an event callback list and can be
  2889. * "fired" multiple times.
  2890. *
  2891. * Possible options:
  2892. *
  2893. * once: will ensure the callback list can only be fired once (like a Deferred)
  2894. *
  2895. * memory: will keep track of previous values and will call any callback added
  2896. * after the list has been fired right away with the latest "memorized"
  2897. * values (like a Deferred)
  2898. *
  2899. * unique: will ensure a callback can only be added once (no duplicate in the list)
  2900. *
  2901. * stopOnFalse: interrupt callings when a callback returns false
  2902. *
  2903. */
  2904. jQuery.Callbacks = function( options ) {
  2905. // Convert options from String-formatted to Object-formatted if needed
  2906. // (we check in cache first)
  2907. options = typeof options === "string" ?
  2908. ( optionsCache[ options ] || createOptions( options ) ) :
  2909. jQuery.extend( {}, options );
  2910. var // Last fire value (for non-forgettable lists)
  2911. memory,
  2912. // Flag to know if list was already fired
  2913. fired,
  2914. // Flag to know if list is currently firing
  2915. firing,
  2916. // First callback to fire (used internally by add and fireWith)
  2917. firingStart,
  2918. // End of the loop when firing
  2919. firingLength,
  2920. // Index of currently firing callback (modified by remove if needed)
  2921. firingIndex,
  2922. // Actual callback list
  2923. list = [],
  2924. // Stack of fire calls for repeatable lists
  2925. stack = !options.once && [],
  2926. // Fire callbacks
  2927. fire = function( data ) {
  2928. memory = options.memory && data;
  2929. fired = true;
  2930. firingIndex = firingStart || 0;
  2931. firingStart = 0;
  2932. firingLength = list.length;
  2933. firing = true;
  2934. for ( ; list && firingIndex < firingLength; firingIndex++ ) {
  2935. if ( list[ firingIndex ].apply( data[ 0 ], data[ 1 ] ) === false && options.stopOnFalse ) {
  2936. memory = false; // To prevent further calls using add
  2937. break;
  2938. }
  2939. }
  2940. firing = false;
  2941. if ( list ) {
  2942. if ( stack ) {
  2943. if ( stack.length ) {
  2944. fire( stack.shift() );
  2945. }
  2946. } else if ( memory ) {
  2947. list = [];
  2948. } else {
  2949. self.disable();
  2950. }
  2951. }
  2952. },
  2953. // Actual Callbacks object
  2954. self = {
  2955. // Add a callback or a collection of callbacks to the list
  2956. add: function() {
  2957. if ( list ) {
  2958. // First, we save the current length
  2959. var start = list.length;
  2960. (function add( args ) {
  2961. jQuery.each( args, function( _, arg ) {
  2962. var type = jQuery.type( arg );
  2963. if ( type === "function" ) {
  2964. if ( !options.unique || !self.has( arg ) ) {
  2965. list.push( arg );
  2966. }
  2967. } else if ( arg && arg.length && type !== "string" ) {
  2968. // Inspect recursively
  2969. add( arg );
  2970. }
  2971. });
  2972. })( arguments );
  2973. // Do we need to add the callbacks to the
  2974. // current firing batch?
  2975. if ( firing ) {
  2976. firingLength = list.length;
  2977. // With memory, if we're not firing then
  2978. // we should call right away
  2979. } else if ( memory ) {
  2980. firingStart = start;
  2981. fire( memory );
  2982. }
  2983. }
  2984. return this;
  2985. },
  2986. // Remove a callback from the list
  2987. remove: function() {
  2988. if ( list ) {
  2989. jQuery.each( arguments, function( _, arg ) {
  2990. var index;
  2991. while ( ( index = jQuery.inArray( arg, list, index ) ) > -1 ) {
  2992. list.splice( index, 1 );
  2993. // Handle firing indexes
  2994. if ( firing ) {
  2995. if ( index <= firingLength ) {
  2996. firingLength--;
  2997. }
  2998. if ( index <= firingIndex ) {
  2999. firingIndex--;
  3000. }
  3001. }
  3002. }
  3003. });
  3004. }
  3005. return this;
  3006. },
  3007. // Check if a given callback is in the list.
  3008. // If no argument is given, return whether or not list has callbacks attached.
  3009. has: function( fn ) {
  3010. return fn ? jQuery.inArray( fn, list ) > -1 : !!( list && list.length );
  3011. },
  3012. // Remove all callbacks from the list
  3013. empty: function() {
  3014. list = [];
  3015. firingLength = 0;
  3016. return this;
  3017. },
  3018. // Have the list do nothing anymore
  3019. disable: function() {
  3020. list = stack = memory = undefined;
  3021. return this;
  3022. },
  3023. // Is it disabled?
  3024. disabled: function() {
  3025. return !list;
  3026. },
  3027. // Lock the list in its current state
  3028. lock: function() {
  3029. stack = undefined;
  3030. if ( !memory ) {
  3031. self.disable();
  3032. }
  3033. return this;
  3034. },
  3035. // Is it locked?
  3036. locked: function() {
  3037. return !stack;
  3038. },
  3039. // Call all callbacks with the given context and arguments
  3040. fireWith: function( context, args ) {
  3041. if ( list && ( !fired || stack ) ) {
  3042. args = args || [];
  3043. args = [ context, args.slice ? args.slice() : args ];
  3044. if ( firing ) {
  3045. stack.push( args );
  3046. } else {
  3047. fire( args );
  3048. }
  3049. }
  3050. return this;
  3051. },
  3052. // Call all the callbacks with the given arguments
  3053. fire: function() {
  3054. self.fireWith( this, arguments );
  3055. return this;
  3056. },
  3057. // To know if the callbacks have already been called at least once
  3058. fired: function() {
  3059. return !!fired;
  3060. }
  3061. };
  3062. return self;
  3063. };
  3064. jQuery.extend({
  3065. Deferred: function( func ) {
  3066. var tuples = [
  3067. // action, add listener, listener list, final state
  3068. [ "resolve", "done", jQuery.Callbacks("once memory"), "resolved" ],
  3069. [ "reject", "fail", jQuery.Callbacks("once memory"), "rejected" ],
  3070. [ "notify", "progress", jQuery.Callbacks("memory") ]
  3071. ],
  3072. state = "pending",
  3073. promise = {
  3074. state: function() {
  3075. return state;
  3076. },
  3077. always: function() {
  3078. deferred.done( arguments ).fail( arguments );
  3079. return this;
  3080. },
  3081. then: function( /* fnDone, fnFail, fnProgress */ ) {
  3082. var fns = arguments;
  3083. return jQuery.Deferred(function( newDefer ) {
  3084. jQuery.each( tuples, function( i, tuple ) {
  3085. var fn = jQuery.isFunction( fns[ i ] ) && fns[ i ];
  3086. // deferred[ done | fail | progress ] for forwarding actions to newDefer
  3087. deferred[ tuple[1] ](function() {
  3088. var returned = fn && fn.apply( this, arguments );
  3089. if ( returned && jQuery.isFunction( returned.promise ) ) {
  3090. returned.promise()
  3091. .done( newDefer.resolve )
  3092. .fail( newDefer.reject )
  3093. .progress( newDefer.notify );
  3094. } else {
  3095. newDefer[ tuple[ 0 ] + "With" ]( this === promise ? newDefer.promise() : this, fn ? [ returned ] : arguments );
  3096. }
  3097. });
  3098. });
  3099. fns = null;
  3100. }).promise();
  3101. },
  3102. // Get a promise for this deferred
  3103. // If obj is provided, the promise aspect is added to the object
  3104. promise: function( obj ) {
  3105. return obj != null ? jQuery.extend( obj, promise ) : promise;
  3106. }
  3107. },
  3108. deferred = {};
  3109. // Keep pipe for back-compat
  3110. promise.pipe = promise.then;
  3111. // Add list-specific methods
  3112. jQuery.each( tuples, function( i, tuple ) {
  3113. var list = tuple[ 2 ],
  3114. stateString = tuple[ 3 ];
  3115. // promise[ done | fail | progress ] = list.add
  3116. promise[ tuple[1] ] = list.add;
  3117. // Handle state
  3118. if ( stateString ) {
  3119. list.add(function() {
  3120. // state = [ resolved | rejected ]
  3121. state = stateString;
  3122. // [ reject_list | resolve_list ].disable; progress_list.lock
  3123. }, tuples[ i ^ 1 ][ 2 ].disable, tuples[ 2 ][ 2 ].lock );
  3124. }
  3125. // deferred[ resolve | reject | notify ]
  3126. deferred[ tuple[0] ] = function() {
  3127. deferred[ tuple[0] + "With" ]( this === deferred ? promise : this, arguments );
  3128. return this;
  3129. };
  3130. deferred[ tuple[0] + "With" ] = list.fireWith;
  3131. });
  3132. // Make the deferred a promise
  3133. promise.promise( deferred );
  3134. // Call given func if any
  3135. if ( func ) {
  3136. func.call( deferred, deferred );
  3137. }
  3138. // All done!
  3139. return deferred;
  3140. },
  3141. // Deferred helper
  3142. when: function( subordinate /* , ..., subordinateN */ ) {
  3143. var i = 0,
  3144. resolveValues = slice.call( arguments ),
  3145. length = resolveValues.length,
  3146. // the count of uncompleted subordinates
  3147. remaining = length !== 1 || ( subordinate && jQuery.isFunction( subordinate.promise ) ) ? length : 0,
  3148. // the master Deferred. If resolveValues consist of only a single Deferred, just use that.
  3149. deferred = remaining === 1 ? subordinate : jQuery.Deferred(),
  3150. // Update function for both resolve and progress values
  3151. updateFunc = function( i, contexts, values ) {
  3152. return function( value ) {
  3153. contexts[ i ] = this;
  3154. values[ i ] = arguments.length > 1 ? slice.call( arguments ) : value;
  3155. if ( values === progressValues ) {
  3156. deferred.notifyWith( contexts, values );
  3157. } else if ( !( --remaining ) ) {
  3158. deferred.resolveWith( contexts, values );
  3159. }
  3160. };
  3161. },
  3162. progressValues, progressContexts, resolveContexts;
  3163. // add listeners to Deferred subordinates; treat others as resolved
  3164. if ( length > 1 ) {
  3165. progressValues = new Array( length );
  3166. progressContexts = new Array( length );
  3167. resolveContexts = new Array( length );
  3168. for ( ; i < length; i++ ) {
  3169. if ( resolveValues[ i ] && jQuery.isFunction( resolveValues[ i ].promise ) ) {
  3170. resolveValues[ i ].promise()
  3171. .done( updateFunc( i, resolveContexts, resolveValues ) )
  3172. .fail( deferred.reject )
  3173. .progress( updateFunc( i, progressContexts, progressValues ) );
  3174. } else {
  3175. --remaining;
  3176. }
  3177. }
  3178. }
  3179. // if we're not waiting on anything, resolve the master
  3180. if ( !remaining ) {
  3181. deferred.resolveWith( resolveContexts, resolveValues );
  3182. }
  3183. return deferred.promise();
  3184. }
  3185. });
  3186. // The deferred used on DOM ready
  3187. var readyList;
  3188. jQuery.fn.ready = function( fn ) {
  3189. // Add the callback
  3190. jQuery.ready.promise().done( fn );
  3191. return this;
  3192. };
  3193. jQuery.extend({
  3194. // Is the DOM ready to be used? Set to true once it occurs.
  3195. isReady: false,
  3196. // A counter to track how many items to wait for before
  3197. // the ready event fires. See #6781
  3198. readyWait: 1,
  3199. // Hold (or release) the ready event
  3200. holdReady: function( hold ) {
  3201. if ( hold ) {
  3202. jQuery.readyWait++;
  3203. } else {
  3204. jQuery.ready( true );
  3205. }
  3206. },
  3207. // Handle when the DOM is ready
  3208. ready: function( wait ) {
  3209. // Abort if there are pending holds or we're already ready
  3210. if ( wait === true ? --jQuery.readyWait : jQuery.isReady ) {
  3211. return;
  3212. }
  3213. // Remember that the DOM is ready
  3214. jQuery.isReady = true;
  3215. // If a normal DOM Ready event fired, decrement, and wait if need be
  3216. if ( wait !== true && --jQuery.readyWait > 0 ) {
  3217. return;
  3218. }
  3219. // If there are functions bound, to execute
  3220. readyList.resolveWith( document, [ jQuery ] );
  3221. // Trigger any bound ready events
  3222. if ( jQuery.fn.trigger ) {
  3223. jQuery( document ).trigger("ready").off("ready");
  3224. }
  3225. }
  3226. });
  3227. /**
  3228. * The ready event handler and self cleanup method
  3229. */
  3230. function completed() {
  3231. document.removeEventListener( "DOMContentLoaded", completed, false );
  3232. window.removeEventListener( "load", completed, false );
  3233. jQuery.ready();
  3234. }
  3235. jQuery.ready.promise = function( obj ) {
  3236. if ( !readyList ) {
  3237. readyList = jQuery.Deferred();
  3238. // Catch cases where $(document).ready() is called after the browser event has already occurred.
  3239. // we once tried to use readyState "interactive" here, but it caused issues like the one
  3240. // discovered by ChrisS here: http://bugs.jquery.com/ticket/12282#comment:15
  3241. if ( document.readyState === "complete" ) {
  3242. // Handle it asynchronously to allow scripts the opportunity to delay ready
  3243. setTimeout( jQuery.ready );
  3244. } else {
  3245. // Use the handy event callback
  3246. document.addEventListener( "DOMContentLoaded", completed, false );
  3247. // A fallback to window.onload, that will always work
  3248. window.addEventListener( "load", completed, false );
  3249. }
  3250. }
  3251. return readyList.promise( obj );
  3252. };
  3253. // Kick off the DOM ready check even if the user does not
  3254. jQuery.ready.promise();
  3255. // Multifunctional method to get and set values of a collection
  3256. // The value/s can optionally be executed if it's a function
  3257. var access = jQuery.access = function( elems, fn, key, value, chainable, emptyGet, raw ) {
  3258. var i = 0,
  3259. len = elems.length,
  3260. bulk = key == null;
  3261. // Sets many values
  3262. if ( jQuery.type( key ) === "object" ) {
  3263. chainable = true;
  3264. for ( i in key ) {
  3265. jQuery.access( elems, fn, i, key[i], true, emptyGet, raw );
  3266. }
  3267. // Sets one value
  3268. } else if ( value !== undefined ) {
  3269. chainable = true;
  3270. if ( !jQuery.isFunction( value ) ) {
  3271. raw = true;
  3272. }
  3273. if ( bulk ) {
  3274. // Bulk operations run against the entire set
  3275. if ( raw ) {
  3276. fn.call( elems, value );
  3277. fn = null;
  3278. // ...except when executing function values
  3279. } else {
  3280. bulk = fn;
  3281. fn = function( elem, key, value ) {
  3282. return bulk.call( jQuery( elem ), value );
  3283. };
  3284. }
  3285. }
  3286. if ( fn ) {
  3287. for ( ; i < len; i++ ) {
  3288. fn( elems[i], key, raw ? value : value.call( elems[i], i, fn( elems[i], key ) ) );
  3289. }
  3290. }
  3291. }
  3292. return chainable ?
  3293. elems :
  3294. // Gets
  3295. bulk ?
  3296. fn.call( elems ) :
  3297. len ? fn( elems[0], key ) : emptyGet;
  3298. };
  3299. /**
  3300. * Determines whether an object can have data
  3301. */
  3302. jQuery.acceptData = function( owner ) {
  3303. // Accepts only:
  3304. // - Node
  3305. // - Node.ELEMENT_NODE
  3306. // - Node.DOCUMENT_NODE
  3307. // - Object
  3308. // - Any
  3309. /* jshint -W018 */
  3310. return owner.nodeType === 1 || owner.nodeType === 9 || !( +owner.nodeType );
  3311. };
  3312. function Data() {
  3313. // Support: Android < 4,
  3314. // Old WebKit does not have Object.preventExtensions/freeze method,
  3315. // return new empty object instead with no [[set]] accessor
  3316. Object.defineProperty( this.cache = {}, 0, {
  3317. get: function() {
  3318. return {};
  3319. }
  3320. });
  3321. this.expando = jQuery.expando + Math.random();
  3322. }
  3323. Data.uid = 1;
  3324. Data.accepts = jQuery.acceptData;
  3325. Data.prototype = {
  3326. key: function( owner ) {
  3327. // We can accept data for non-element nodes in modern browsers,
  3328. // but we should not, see #8335.
  3329. // Always return the key for a frozen object.
  3330. if ( !Data.accepts( owner ) ) {
  3331. return 0;
  3332. }
  3333. var descriptor = {},
  3334. // Check if the owner object already has a cache key
  3335. unlock = owner[ this.expando ];
  3336. // If not, create one
  3337. if ( !unlock ) {
  3338. unlock = Data.uid++;
  3339. // Secure it in a non-enumerable, non-writable property
  3340. try {
  3341. descriptor[ this.expando ] = { value: unlock };
  3342. Object.defineProperties( owner, descriptor );
  3343. // Support: Android < 4
  3344. // Fallback to a less secure definition
  3345. } catch ( e ) {
  3346. descriptor[ this.expando ] = unlock;
  3347. jQuery.extend( owner, descriptor );
  3348. }
  3349. }
  3350. // Ensure the cache object
  3351. if ( !this.cache[ unlock ] ) {
  3352. this.cache[ unlock ] = {};
  3353. }
  3354. return unlock;
  3355. },
  3356. set: function( owner, data, value ) {
  3357. var prop,
  3358. // There may be an unlock assigned to this node,
  3359. // if there is no entry for this "owner", create one inline
  3360. // and set the unlock as though an owner entry had always existed
  3361. unlock = this.key( owner ),
  3362. cache = this.cache[ unlock ];
  3363. // Handle: [ owner, key, value ] args
  3364. if ( typeof data === "string" ) {
  3365. cache[ data ] = value;
  3366. // Handle: [ owner, { properties } ] args
  3367. } else {
  3368. // Fresh assignments by object are shallow copied
  3369. if ( jQuery.isEmptyObject( cache ) ) {
  3370. jQuery.extend( this.cache[ unlock ], data );
  3371. // Otherwise, copy the properties one-by-one to the cache object
  3372. } else {
  3373. for ( prop in data ) {
  3374. cache[ prop ] = data[ prop ];
  3375. }
  3376. }
  3377. }
  3378. return cache;
  3379. },
  3380. get: function( owner, key ) {
  3381. // Either a valid cache is found, or will be created.
  3382. // New caches will be created and the unlock returned,
  3383. // allowing direct access to the newly created
  3384. // empty data object. A valid owner object must be provided.
  3385. var cache = this.cache[ this.key( owner ) ];
  3386. return key === undefined ?
  3387. cache : cache[ key ];
  3388. },
  3389. access: function( owner, key, value ) {
  3390. var stored;
  3391. // In cases where either:
  3392. //
  3393. // 1. No key was specified
  3394. // 2. A string key was specified, but no value provided
  3395. //
  3396. // Take the "read" path and allow the get method to determine
  3397. // which value to return, respectively either:
  3398. //
  3399. // 1. The entire cache object
  3400. // 2. The data stored at the key
  3401. //
  3402. if ( key === undefined ||
  3403. ((key && typeof key === "string") && value === undefined) ) {
  3404. stored = this.get( owner, key );
  3405. return stored !== undefined ?
  3406. stored : this.get( owner, jQuery.camelCase(key) );
  3407. }
  3408. // [*]When the key is not a string, or both a key and value
  3409. // are specified, set or extend (existing objects) with either:
  3410. //
  3411. // 1. An object of properties
  3412. // 2. A key and value
  3413. //
  3414. this.set( owner, key, value );
  3415. // Since the "set" path can have two possible entry points
  3416. // return the expected data based on which path was taken[*]
  3417. return value !== undefined ? value : key;
  3418. },
  3419. remove: function( owner, key ) {
  3420. var i, name, camel,
  3421. unlock = this.key( owner ),
  3422. cache = this.cache[ unlock ];
  3423. if ( key === undefined ) {
  3424. this.cache[ unlock ] = {};
  3425. } else {
  3426. // Support array or space separated string of keys
  3427. if ( jQuery.isArray( key ) ) {
  3428. // If "name" is an array of keys...
  3429. // When data is initially created, via ("key", "val") signature,
  3430. // keys will be converted to camelCase.
  3431. // Since there is no way to tell _how_ a key was added, remove
  3432. // both plain key and camelCase key. #12786
  3433. // This will only penalize the array argument path.
  3434. name = key.concat( key.map( jQuery.camelCase ) );
  3435. } else {
  3436. camel = jQuery.camelCase( key );
  3437. // Try the string as a key before any manipulation
  3438. if ( key in cache ) {
  3439. name = [ key, camel ];
  3440. } else {
  3441. // If a key with the spaces exists, use it.
  3442. // Otherwise, create an array by matching non-whitespace
  3443. name = camel;
  3444. name = name in cache ?
  3445. [ name ] : ( name.match( rnotwhite ) || [] );
  3446. }
  3447. }
  3448. i = name.length;
  3449. while ( i-- ) {
  3450. delete cache[ name[ i ] ];
  3451. }
  3452. }
  3453. },
  3454. hasData: function( owner ) {
  3455. return !jQuery.isEmptyObject(
  3456. this.cache[ owner[ this.expando ] ] || {}
  3457. );
  3458. },
  3459. discard: function( owner ) {
  3460. if ( owner[ this.expando ] ) {
  3461. delete this.cache[ owner[ this.expando ] ];
  3462. }
  3463. }
  3464. };
  3465. var data_priv = new Data();
  3466. var data_user = new Data();
  3467. /*
  3468. Implementation Summary
  3469. 1. Enforce API surface and semantic compatibility with 1.9.x branch
  3470. 2. Improve the module's maintainability by reducing the storage
  3471. paths to a single mechanism.
  3472. 3. Use the same single mechanism to support "private" and "user" data.
  3473. 4. _Never_ expose "private" data to user code (TODO: Drop _data, _removeData)
  3474. 5. Avoid exposing implementation details on user objects (eg. expando properties)
  3475. 6. Provide a clear path for implementation upgrade to WeakMap in 2014
  3476. */
  3477. var rbrace = /^(?:\{[\w\W]*\}|\[[\w\W]*\])$/,
  3478. rmultiDash = /([A-Z])/g;
  3479. function dataAttr( elem, key, data ) {
  3480. var name;
  3481. // If nothing was found internally, try to fetch any
  3482. // data from the HTML5 data-* attribute
  3483. if ( data === undefined && elem.nodeType === 1 ) {
  3484. name = "data-" + key.replace( rmultiDash, "-$1" ).toLowerCase();
  3485. data = elem.getAttribute( name );
  3486. if ( typeof data === "string" ) {
  3487. try {
  3488. data = data === "true" ? true :
  3489. data === "false" ? false :
  3490. data === "null" ? null :
  3491. // Only convert to a number if it doesn't change the string
  3492. +data + "" === data ? +data :
  3493. rbrace.test( data ) ? jQuery.parseJSON( data ) :
  3494. data;
  3495. } catch( e ) {}
  3496. // Make sure we set the data so it isn't changed later
  3497. data_user.set( elem, key, data );
  3498. } else {
  3499. data = undefined;
  3500. }
  3501. }
  3502. return data;
  3503. }
  3504. jQuery.extend({
  3505. hasData: function( elem ) {
  3506. return data_user.hasData( elem ) || data_priv.hasData( elem );
  3507. },
  3508. data: function( elem, name, data ) {
  3509. return data_user.access( elem, name, data );
  3510. },
  3511. removeData: function( elem, name ) {
  3512. data_user.remove( elem, name );
  3513. },
  3514. // TODO: Now that all calls to _data and _removeData have been replaced
  3515. // with direct calls to data_priv methods, these can be deprecated.
  3516. _data: function( elem, name, data ) {
  3517. return data_priv.access( elem, name, data );
  3518. },
  3519. _removeData: function( elem, name ) {
  3520. data_priv.remove( elem, name );
  3521. }
  3522. });
  3523. jQuery.fn.extend({
  3524. data: function( key, value ) {
  3525. var i, name, data,
  3526. elem = this[ 0 ],
  3527. attrs = elem && elem.attributes;
  3528. // Gets all values
  3529. if ( key === undefined ) {
  3530. if ( this.length ) {
  3531. data = data_user.get( elem );
  3532. if ( elem.nodeType === 1 && !data_priv.get( elem, "hasDataAttrs" ) ) {
  3533. i = attrs.length;
  3534. while ( i-- ) {
  3535. name = attrs[ i ].name;
  3536. if ( name.indexOf( "data-" ) === 0 ) {
  3537. name = jQuery.camelCase( name.slice(5) );
  3538. dataAttr( elem, name, data[ name ] );
  3539. }
  3540. }
  3541. data_priv.set( elem, "hasDataAttrs", true );
  3542. }
  3543. }
  3544. return data;
  3545. }
  3546. // Sets multiple values
  3547. if ( typeof key === "object" ) {
  3548. return this.each(function() {
  3549. data_user.set( this, key );
  3550. });
  3551. }
  3552. return access( this, function( value ) {
  3553. var data,
  3554. camelKey = jQuery.camelCase( key );
  3555. // The calling jQuery object (element matches) is not empty
  3556. // (and therefore has an element appears at this[ 0 ]) and the
  3557. // `value` parameter was not undefined. An empty jQuery object
  3558. // will result in `undefined` for elem = this[ 0 ] which will
  3559. // throw an exception if an attempt to read a data cache is made.
  3560. if ( elem && value === undefined ) {
  3561. // Attempt to get data from the cache
  3562. // with the key as-is
  3563. data = data_user.get( elem, key );
  3564. if ( data !== undefined ) {
  3565. return data;
  3566. }
  3567. // Attempt to get data from the cache
  3568. // with the key camelized
  3569. data = data_user.get( elem, camelKey );
  3570. if ( data !== undefined ) {
  3571. return data;
  3572. }
  3573. // Attempt to "discover" the data in
  3574. // HTML5 custom data-* attrs
  3575. data = dataAttr( elem, camelKey, undefined );
  3576. if ( data !== undefined ) {
  3577. return data;
  3578. }
  3579. // We tried really hard, but the data doesn't exist.
  3580. return;
  3581. }
  3582. // Set the data...
  3583. this.each(function() {
  3584. // First, attempt to store a copy or reference of any
  3585. // data that might've been store with a camelCased key.
  3586. var data = data_user.get( this, camelKey );
  3587. // For HTML5 data-* attribute interop, we have to
  3588. // store property names with dashes in a camelCase form.
  3589. // This might not apply to all properties...*
  3590. data_user.set( this, camelKey, value );
  3591. // *... In the case of properties that might _actually_
  3592. // have dashes, we need to also store a copy of that
  3593. // unchanged property.
  3594. if ( key.indexOf("-") !== -1 && data !== undefined ) {
  3595. data_user.set( this, key, value );
  3596. }
  3597. });
  3598. }, null, value, arguments.length > 1, null, true );
  3599. },
  3600. removeData: function( key ) {
  3601. return this.each(function() {
  3602. data_user.remove( this, key );
  3603. });
  3604. }
  3605. });
  3606. jQuery.extend({
  3607. queue: function( elem, type, data ) {
  3608. var queue;
  3609. if ( elem ) {
  3610. type = ( type || "fx" ) + "queue";
  3611. queue = data_priv.get( elem, type );
  3612. // Speed up dequeue by getting out quickly if this is just a lookup
  3613. if ( data ) {
  3614. if ( !queue || jQuery.isArray( data ) ) {
  3615. queue = data_priv.access( elem, type, jQuery.makeArray(data) );
  3616. } else {
  3617. queue.push( data );
  3618. }
  3619. }
  3620. return queue || [];
  3621. }
  3622. },
  3623. dequeue: function( elem, type ) {
  3624. type = type || "fx";
  3625. var queue = jQuery.queue( elem, type ),
  3626. startLength = queue.length,
  3627. fn = queue.shift(),
  3628. hooks = jQuery._queueHooks( elem, type ),
  3629. next = function() {
  3630. jQuery.dequeue( elem, type );
  3631. };
  3632. // If the fx queue is dequeued, always remove the progress sentinel
  3633. if ( fn === "inprogress" ) {
  3634. fn = queue.shift();
  3635. startLength--;
  3636. }
  3637. if ( fn ) {
  3638. // Add a progress sentinel to prevent the fx queue from being
  3639. // automatically dequeued
  3640. if ( type === "fx" ) {
  3641. queue.unshift( "inprogress" );
  3642. }
  3643. // clear up the last queue stop function
  3644. delete hooks.stop;
  3645. fn.call( elem, next, hooks );
  3646. }
  3647. if ( !startLength && hooks ) {
  3648. hooks.empty.fire();
  3649. }
  3650. },
  3651. // not intended for public consumption - generates a queueHooks object, or returns the current one
  3652. _queueHooks: function( elem, type ) {
  3653. var key = type + "queueHooks";
  3654. return data_priv.get( elem, key ) || data_priv.access( elem, key, {
  3655. empty: jQuery.Callbacks("once memory").add(function() {
  3656. data_priv.remove( elem, [ type + "queue", key ] );
  3657. })
  3658. });
  3659. }
  3660. });
  3661. jQuery.fn.extend({
  3662. queue: function( type, data ) {
  3663. var setter = 2;
  3664. if ( typeof type !== "string" ) {
  3665. data = type;
  3666. type = "fx";
  3667. setter--;
  3668. }
  3669. if ( arguments.length < setter ) {
  3670. return jQuery.queue( this[0], type );
  3671. }
  3672. return data === undefined ?
  3673. this :
  3674. this.each(function() {
  3675. var queue = jQuery.queue( this, type, data );
  3676. // ensure a hooks for this queue
  3677. jQuery._queueHooks( this, type );
  3678. if ( type === "fx" && queue[0] !== "inprogress" ) {
  3679. jQuery.dequeue( this, type );
  3680. }
  3681. });
  3682. },
  3683. dequeue: function( type ) {
  3684. return this.each(function() {
  3685. jQuery.dequeue( this, type );
  3686. });
  3687. },
  3688. clearQueue: function( type ) {
  3689. return this.queue( type || "fx", [] );
  3690. },
  3691. // Get a promise resolved when queues of a certain type
  3692. // are emptied (fx is the type by default)
  3693. promise: function( type, obj ) {
  3694. var tmp,
  3695. count = 1,
  3696. defer = jQuery.Deferred(),
  3697. elements = this,
  3698. i = this.length,
  3699. resolve = function() {
  3700. if ( !( --count ) ) {
  3701. defer.resolveWith( elements, [ elements ] );
  3702. }
  3703. };
  3704. if ( typeof type !== "string" ) {
  3705. obj = type;
  3706. type = undefined;
  3707. }
  3708. type = type || "fx";
  3709. while ( i-- ) {
  3710. tmp = data_priv.get( elements[ i ], type + "queueHooks" );
  3711. if ( tmp && tmp.empty ) {
  3712. count++;
  3713. tmp.empty.add( resolve );
  3714. }
  3715. }
  3716. resolve();
  3717. return defer.promise( obj );
  3718. }
  3719. });
  3720. var pnum = (/[+-]?(?:\d*\.|)\d+(?:[eE][+-]?\d+|)/).source;
  3721. var cssExpand = [ "Top", "Right", "Bottom", "Left" ];
  3722. var isHidden = function( elem, el ) {
  3723. // isHidden might be called from jQuery#filter function;
  3724. // in that case, element will be second argument
  3725. elem = el || elem;
  3726. return jQuery.css( elem, "display" ) === "none" || !jQuery.contains( elem.ownerDocument, elem );
  3727. };
  3728. var rcheckableType = (/^(?:checkbox|radio)$/i);
  3729. (function() {
  3730. var fragment = document.createDocumentFragment(),
  3731. div = fragment.appendChild( document.createElement( "div" ) );
  3732. // #11217 - WebKit loses check when the name is after the checked attribute
  3733. div.innerHTML = "<input type='radio' checked='checked' name='t'/>";
  3734. // Support: Safari 5.1, iOS 5.1, Android 4.x, Android 2.3
  3735. // old WebKit doesn't clone checked state correctly in fragments
  3736. support.checkClone = div.cloneNode( true ).cloneNode( true ).lastChild.checked;
  3737. // Make sure textarea (and checkbox) defaultValue is properly cloned
  3738. // Support: IE9-IE11+
  3739. div.innerHTML = "<textarea>x</textarea>";
  3740. support.noCloneChecked = !!div.cloneNode( true ).lastChild.defaultValue;
  3741. })();
  3742. var strundefined = typeof undefined;
  3743. support.focusinBubbles = "onfocusin" in window;
  3744. var
  3745. rkeyEvent = /^key/,
  3746. rmouseEvent = /^(?:mouse|contextmenu)|click/,
  3747. rfocusMorph = /^(?:focusinfocus|focusoutblur)$/,
  3748. rtypenamespace = /^([^.]*)(?:\.(.+)|)$/;
  3749. function returnTrue() {
  3750. return true;
  3751. }
  3752. function returnFalse() {
  3753. return false;
  3754. }
  3755. function safeActiveElement() {
  3756. try {
  3757. return document.activeElement;
  3758. } catch ( err ) { }
  3759. }
  3760. /*
  3761. * Helper functions for managing events -- not part of the public interface.
  3762. * Props to Dean Edwards' addEvent library for many of the ideas.
  3763. */
  3764. jQuery.event = {
  3765. global: {},
  3766. add: function( elem, types, handler, data, selector ) {
  3767. var handleObjIn, eventHandle, tmp,
  3768. events, t, handleObj,
  3769. special, handlers, type, namespaces, origType,
  3770. elemData = data_priv.get( elem );
  3771. // Don't attach events to noData or text/comment nodes (but allow plain objects)
  3772. if ( !elemData ) {
  3773. return;
  3774. }
  3775. // Caller can pass in an object of custom data in lieu of the handler
  3776. if ( handler.handler ) {
  3777. handleObjIn = handler;
  3778. handler = handleObjIn.handler;
  3779. selector = handleObjIn.selector;
  3780. }
  3781. // Make sure that the handler has a unique ID, used to find/remove it later
  3782. if ( !handler.guid ) {
  3783. handler.guid = jQuery.guid++;
  3784. }
  3785. // Init the element's event structure and main handler, if this is the first
  3786. if ( !(events = elemData.events) ) {
  3787. events = elemData.events = {};
  3788. }
  3789. if ( !(eventHandle = elemData.handle) ) {
  3790. eventHandle = elemData.handle = function( e ) {
  3791. // Discard the second event of a jQuery.event.trigger() and
  3792. // when an event is called after a page has unloaded
  3793. return typeof jQuery !== strundefined && jQuery.event.triggered !== e.type ?
  3794. jQuery.event.dispatch.apply( elem, arguments ) : undefined;
  3795. };
  3796. }
  3797. // Handle multiple events separated by a space
  3798. types = ( types || "" ).match( rnotwhite ) || [ "" ];
  3799. t = types.length;
  3800. while ( t-- ) {
  3801. tmp = rtypenamespace.exec( types[t] ) || [];
  3802. type = origType = tmp[1];
  3803. namespaces = ( tmp[2] || "" ).split( "." ).sort();
  3804. // There *must* be a type, no attaching namespace-only handlers
  3805. if ( !type ) {
  3806. continue;
  3807. }
  3808. // If event changes its type, use the special event handlers for the changed type
  3809. special = jQuery.event.special[ type ] || {};
  3810. // If selector defined, determine special event api type, otherwise given type
  3811. type = ( selector ? special.delegateType : special.bindType ) || type;
  3812. // Update special based on newly reset type
  3813. special = jQuery.event.special[ type ] || {};
  3814. // handleObj is passed to all event handlers
  3815. handleObj = jQuery.extend({
  3816. type: type,
  3817. origType: origType,
  3818. data: data,
  3819. handler: handler,
  3820. guid: handler.guid,
  3821. selector: selector,
  3822. needsContext: selector && jQuery.expr.match.needsContext.test( selector ),
  3823. namespace: namespaces.join(".")
  3824. }, handleObjIn );
  3825. // Init the event handler queue if we're the first
  3826. if ( !(handlers = events[ type ]) ) {
  3827. handlers = events[ type ] = [];
  3828. handlers.delegateCount = 0;
  3829. // Only use addEventListener if the special events handler returns false
  3830. if ( !special.setup || special.setup.call( elem, data, namespaces, eventHandle ) === false ) {
  3831. if ( elem.addEventListener ) {
  3832. elem.addEventListener( type, eventHandle, false );
  3833. }
  3834. }
  3835. }
  3836. if ( special.add ) {
  3837. special.add.call( elem, handleObj );
  3838. if ( !handleObj.handler.guid ) {
  3839. handleObj.handler.guid = handler.guid;
  3840. }
  3841. }
  3842. // Add to the element's handler list, delegates in front
  3843. if ( selector ) {
  3844. handlers.splice( handlers.delegateCount++, 0, handleObj );
  3845. } else {
  3846. handlers.push( handleObj );
  3847. }
  3848. // Keep track of which events have ever been used, for event optimization
  3849. jQuery.event.global[ type ] = true;
  3850. }
  3851. },
  3852. // Detach an event or set of events from an element
  3853. remove: function( elem, types, handler, selector, mappedTypes ) {
  3854. var j, origCount, tmp,
  3855. events, t, handleObj,
  3856. special, handlers, type, namespaces, origType,
  3857. elemData = data_priv.hasData( elem ) && data_priv.get( elem );
  3858. if ( !elemData || !(events = elemData.events) ) {
  3859. return;
  3860. }
  3861. // Once for each type.namespace in types; type may be omitted
  3862. types = ( types || "" ).match( rnotwhite ) || [ "" ];
  3863. t = types.length;
  3864. while ( t-- ) {
  3865. tmp = rtypenamespace.exec( types[t] ) || [];
  3866. type = origType = tmp[1];
  3867. namespaces = ( tmp[2] || "" ).split( "." ).sort();
  3868. // Unbind all events (on this namespace, if provided) for the element
  3869. if ( !type ) {
  3870. for ( type in events ) {
  3871. jQuery.event.remove( elem, type + types[ t ], handler, selector, true );
  3872. }
  3873. continue;
  3874. }
  3875. special = jQuery.event.special[ type ] || {};
  3876. type = ( selector ? special.delegateType : special.bindType ) || type;
  3877. handlers = events[ type ] || [];
  3878. tmp = tmp[2] && new RegExp( "(^|\\.)" + namespaces.join("\\.(?:.*\\.|)") + "(\\.|$)" );
  3879. // Remove matching events
  3880. origCount = j = handlers.length;
  3881. while ( j-- ) {
  3882. handleObj = handlers[ j ];
  3883. if ( ( mappedTypes || origType === handleObj.origType ) &&
  3884. ( !handler || handler.guid === handleObj.guid ) &&
  3885. ( !tmp || tmp.test( handleObj.namespace ) ) &&
  3886. ( !selector || selector === handleObj.selector || selector === "**" && handleObj.selector ) ) {
  3887. handlers.splice( j, 1 );
  3888. if ( handleObj.selector ) {
  3889. handlers.delegateCount--;
  3890. }
  3891. if ( special.remove ) {
  3892. special.remove.call( elem, handleObj );
  3893. }
  3894. }
  3895. }
  3896. // Remove generic event handler if we removed something and no more handlers exist
  3897. // (avoids potential for endless recursion during removal of special event handlers)
  3898. if ( origCount && !handlers.length ) {
  3899. if ( !special.teardown || special.teardown.call( elem, namespaces, elemData.handle ) === false ) {
  3900. jQuery.removeEvent( elem, type, elemData.handle );
  3901. }
  3902. delete events[ type ];
  3903. }
  3904. }
  3905. // Remove the expando if it's no longer used
  3906. if ( jQuery.isEmptyObject( events ) ) {
  3907. delete elemData.handle;
  3908. data_priv.remove( elem, "events" );
  3909. }
  3910. },
  3911. trigger: function( event, data, elem, onlyHandlers ) {
  3912. var i, cur, tmp, bubbleType, ontype, handle, special,
  3913. eventPath = [ elem || document ],
  3914. type = hasOwn.call( event, "type" ) ? event.type : event,
  3915. namespaces = hasOwn.call( event, "namespace" ) ? event.namespace.split(".") : [];
  3916. cur = tmp = elem = elem || document;
  3917. // Don't do events on text and comment nodes
  3918. if ( elem.nodeType === 3 || elem.nodeType === 8 ) {
  3919. return;
  3920. }
  3921. // focus/blur morphs to focusin/out; ensure we're not firing them right now
  3922. if ( rfocusMorph.test( type + jQuery.event.triggered ) ) {
  3923. return;
  3924. }
  3925. if ( type.indexOf(".") >= 0 ) {
  3926. // Namespaced trigger; create a regexp to match event type in handle()
  3927. namespaces = type.split(".");
  3928. type = namespaces.shift();
  3929. namespaces.sort();
  3930. }
  3931. ontype = type.indexOf(":") < 0 && "on" + type;
  3932. // Caller can pass in a jQuery.Event object, Object, or just an event type string
  3933. event = event[ jQuery.expando ] ?
  3934. event :
  3935. new jQuery.Event( type, typeof event === "object" && event );
  3936. // Trigger bitmask: & 1 for native handlers; & 2 for jQuery (always true)
  3937. event.isTrigger = onlyHandlers ? 2 : 3;
  3938. event.namespace = namespaces.join(".");
  3939. event.namespace_re = event.namespace ?
  3940. new RegExp( "(^|\\.)" + namespaces.join("\\.(?:.*\\.|)") + "(\\.|$)" ) :
  3941. null;
  3942. // Clean up the event in case it is being reused
  3943. event.result = undefined;
  3944. if ( !event.target ) {
  3945. event.target = elem;
  3946. }
  3947. // Clone any incoming data and prepend the event, creating the handler arg list
  3948. data = data == null ?
  3949. [ event ] :
  3950. jQuery.makeArray( data, [ event ] );
  3951. // Allow special events to draw outside the lines
  3952. special = jQuery.event.special[ type ] || {};
  3953. if ( !onlyHandlers && special.trigger && special.trigger.apply( elem, data ) === false ) {
  3954. return;
  3955. }
  3956. // Determine event propagation path in advance, per W3C events spec (#9951)
  3957. // Bubble up to document, then to window; watch for a global ownerDocument var (#9724)
  3958. if ( !onlyHandlers && !special.noBubble && !jQuery.isWindow( elem ) ) {
  3959. bubbleType = special.delegateType || type;
  3960. if ( !rfocusMorph.test( bubbleType + type ) ) {
  3961. cur = cur.parentNode;
  3962. }
  3963. for ( ; cur; cur = cur.parentNode ) {
  3964. eventPath.push( cur );
  3965. tmp = cur;
  3966. }
  3967. // Only add window if we got to document (e.g., not plain obj or detached DOM)
  3968. if ( tmp === (elem.ownerDocument || document) ) {
  3969. eventPath.push( tmp.defaultView || tmp.parentWindow || window );
  3970. }
  3971. }
  3972. // Fire handlers on the event path
  3973. i = 0;
  3974. while ( (cur = eventPath[i++]) && !event.isPropagationStopped() ) {
  3975. event.type = i > 1 ?
  3976. bubbleType :
  3977. special.bindType || type;
  3978. // jQuery handler
  3979. handle = ( data_priv.get( cur, "events" ) || {} )[ event.type ] && data_priv.get( cur, "handle" );
  3980. if ( handle ) {
  3981. handle.apply( cur, data );
  3982. }
  3983. // Native handler
  3984. handle = ontype && cur[ ontype ];
  3985. if ( handle && handle.apply && jQuery.acceptData( cur ) ) {
  3986. event.result = handle.apply( cur, data );
  3987. if ( event.result === false ) {
  3988. event.preventDefault();
  3989. }
  3990. }
  3991. }
  3992. event.type = type;
  3993. // If nobody prevented the default action, do it now
  3994. if ( !onlyHandlers && !event.isDefaultPrevented() ) {
  3995. if ( (!special._default || special._default.apply( eventPath.pop(), data ) === false) &&
  3996. jQuery.acceptData( elem ) ) {
  3997. // Call a native DOM method on the target with the same name name as the event.
  3998. // Don't do default actions on window, that's where global variables be (#6170)
  3999. if ( ontype && jQuery.isFunction( elem[ type ] ) && !jQuery.isWindow( elem ) ) {
  4000. // Don't re-trigger an onFOO event when we call its FOO() method
  4001. tmp = elem[ ontype ];
  4002. if ( tmp ) {
  4003. elem[ ontype ] = null;
  4004. }
  4005. // Prevent re-triggering of the same event, since we already bubbled it above
  4006. jQuery.event.triggered = type;
  4007. elem[ type ]();
  4008. jQuery.event.triggered = undefined;
  4009. if ( tmp ) {
  4010. elem[ ontype ] = tmp;
  4011. }
  4012. }
  4013. }
  4014. }
  4015. return event.result;
  4016. },
  4017. dispatch: function( event ) {
  4018. // Make a writable jQuery.Event from the native event object
  4019. event = jQuery.event.fix( event );
  4020. var i, j, ret, matched, handleObj,
  4021. handlerQueue = [],
  4022. args = slice.call( arguments ),
  4023. handlers = ( data_priv.get( this, "events" ) || {} )[ event.type ] || [],
  4024. special = jQuery.event.special[ event.type ] || {};
  4025. // Use the fix-ed jQuery.Event rather than the (read-only) native event
  4026. args[0] = event;
  4027. event.delegateTarget = this;
  4028. // Call the preDispatch hook for the mapped type, and let it bail if desired
  4029. if ( special.preDispatch && special.preDispatch.call( this, event ) === false ) {
  4030. return;
  4031. }
  4032. // Determine handlers
  4033. handlerQueue = jQuery.event.handlers.call( this, event, handlers );
  4034. // Run delegates first; they may want to stop propagation beneath us
  4035. i = 0;
  4036. while ( (matched = handlerQueue[ i++ ]) && !event.isPropagationStopped() ) {
  4037. event.currentTarget = matched.elem;
  4038. j = 0;
  4039. while ( (handleObj = matched.handlers[ j++ ]) && !event.isImmediatePropagationStopped() ) {
  4040. // Triggered event must either 1) have no namespace, or
  4041. // 2) have namespace(s) a subset or equal to those in the bound event (both can have no namespace).
  4042. if ( !event.namespace_re || event.namespace_re.test( handleObj.namespace ) ) {
  4043. event.handleObj = handleObj;
  4044. event.data = handleObj.data;
  4045. ret = ( (jQuery.event.special[ handleObj.origType ] || {}).handle || handleObj.handler )
  4046. .apply( matched.elem, args );
  4047. if ( ret !== undefined ) {
  4048. if ( (event.result = ret) === false ) {
  4049. event.preventDefault();
  4050. event.stopPropagation();
  4051. }
  4052. }
  4053. }
  4054. }
  4055. }
  4056. // Call the postDispatch hook for the mapped type
  4057. if ( special.postDispatch ) {
  4058. special.postDispatch.call( this, event );
  4059. }
  4060. return event.result;
  4061. },
  4062. handlers: function( event, handlers ) {
  4063. var i, matches, sel, handleObj,
  4064. handlerQueue = [],
  4065. delegateCount = handlers.delegateCount,
  4066. cur = event.target;
  4067. // Find delegate handlers
  4068. // Black-hole SVG <use> instance trees (#13180)
  4069. // Avoid non-left-click bubbling in Firefox (#3861)
  4070. if ( delegateCount && cur.nodeType && (!event.button || event.type !== "click") ) {
  4071. for ( ; cur !== this; cur = cur.parentNode || this ) {
  4072. // Don't process clicks on disabled elements (#6911, #8165, #11382, #11764)
  4073. if ( cur.disabled !== true || event.type !== "click" ) {
  4074. matches = [];
  4075. for ( i = 0; i < delegateCount; i++ ) {
  4076. handleObj = handlers[ i ];
  4077. // Don't conflict with Object.prototype properties (#13203)
  4078. sel = handleObj.selector + " ";
  4079. if ( matches[ sel ] === undefined ) {
  4080. matches[ sel ] = handleObj.needsContext ?
  4081. jQuery( sel, this ).index( cur ) >= 0 :
  4082. jQuery.find( sel, this, null, [ cur ] ).length;
  4083. }
  4084. if ( matches[ sel ] ) {
  4085. matches.push( handleObj );
  4086. }
  4087. }
  4088. if ( matches.length ) {
  4089. handlerQueue.push({ elem: cur, handlers: matches });
  4090. }
  4091. }
  4092. }
  4093. }
  4094. // Add the remaining (directly-bound) handlers
  4095. if ( delegateCount < handlers.length ) {
  4096. handlerQueue.push({ elem: this, handlers: handlers.slice( delegateCount ) });
  4097. }
  4098. return handlerQueue;
  4099. },
  4100. // Includes some event props shared by KeyEvent and MouseEvent
  4101. props: "altKey bubbles cancelable ctrlKey currentTarget eventPhase metaKey relatedTarget shiftKey target timeStamp view which".split(" "),
  4102. fixHooks: {},
  4103. keyHooks: {
  4104. props: "char charCode key keyCode".split(" "),
  4105. filter: function( event, original ) {
  4106. // Add which for key events
  4107. if ( event.which == null ) {
  4108. event.which = original.charCode != null ? original.charCode : original.keyCode;
  4109. }
  4110. return event;
  4111. }
  4112. },
  4113. mouseHooks: {
  4114. props: "button buttons clientX clientY offsetX offsetY pageX pageY screenX screenY toElement".split(" "),
  4115. filter: function( event, original ) {
  4116. var eventDoc, doc, body,
  4117. button = original.button;
  4118. // Calculate pageX/Y if missing and clientX/Y available
  4119. if ( event.pageX == null && original.clientX != null ) {
  4120. eventDoc = event.target.ownerDocument || document;
  4121. doc = eventDoc.documentElement;
  4122. body = eventDoc.body;
  4123. event.pageX = original.clientX + ( doc && doc.scrollLeft || body && body.scrollLeft || 0 ) - ( doc && doc.clientLeft || body && body.clientLeft || 0 );
  4124. event.pageY = original.clientY + ( doc && doc.scrollTop || body && body.scrollTop || 0 ) - ( doc && doc.clientTop || body && body.clientTop || 0 );
  4125. }
  4126. // Add which for click: 1 === left; 2 === middle; 3 === right
  4127. // Note: button is not normalized, so don't use it
  4128. if ( !event.which && button !== undefined ) {
  4129. event.which = ( button & 1 ? 1 : ( button & 2 ? 3 : ( button & 4 ? 2 : 0 ) ) );
  4130. }
  4131. return event;
  4132. }
  4133. },
  4134. fix: function( event ) {
  4135. if ( event[ jQuery.expando ] ) {
  4136. return event;
  4137. }
  4138. // Create a writable copy of the event object and normalize some properties
  4139. var i, prop, copy,
  4140. type = event.type,
  4141. originalEvent = event,
  4142. fixHook = this.fixHooks[ type ];
  4143. if ( !fixHook ) {
  4144. this.fixHooks[ type ] = fixHook =
  4145. rmouseEvent.test( type ) ? this.mouseHooks :
  4146. rkeyEvent.test( type ) ? this.keyHooks :
  4147. {};
  4148. }
  4149. copy = fixHook.props ? this.props.concat( fixHook.props ) : this.props;
  4150. event = new jQuery.Event( originalEvent );
  4151. i = copy.length;
  4152. while ( i-- ) {
  4153. prop = copy[ i ];
  4154. event[ prop ] = originalEvent[ prop ];
  4155. }
  4156. // Support: Cordova 2.5 (WebKit) (#13255)
  4157. // All events should have a target; Cordova deviceready doesn't
  4158. if ( !event.target ) {
  4159. event.target = document;
  4160. }
  4161. // Support: Safari 6.0+, Chrome < 28
  4162. // Target should not be a text node (#504, #13143)
  4163. if ( event.target.nodeType === 3 ) {
  4164. event.target = event.target.parentNode;
  4165. }
  4166. return fixHook.filter ? fixHook.filter( event, originalEvent ) : event;
  4167. },
  4168. special: {
  4169. load: {
  4170. // Prevent triggered image.load events from bubbling to window.load
  4171. noBubble: true
  4172. },
  4173. focus: {
  4174. // Fire native event if possible so blur/focus sequence is correct
  4175. trigger: function() {
  4176. if ( this !== safeActiveElement() && this.focus ) {
  4177. this.focus();
  4178. return false;
  4179. }
  4180. },
  4181. delegateType: "focusin"
  4182. },
  4183. blur: {
  4184. trigger: function() {
  4185. if ( this === safeActiveElement() && this.blur ) {
  4186. this.blur();
  4187. return false;
  4188. }
  4189. },
  4190. delegateType: "focusout"
  4191. },
  4192. click: {
  4193. // For checkbox, fire native event so checked state will be right
  4194. trigger: function() {
  4195. if ( this.type === "checkbox" && this.click && jQuery.nodeName( this, "input" ) ) {
  4196. this.click();
  4197. return false;
  4198. }
  4199. },
  4200. // For cross-browser consistency, don't fire native .click() on links
  4201. _default: function( event ) {
  4202. return jQuery.nodeName( event.target, "a" );
  4203. }
  4204. },
  4205. beforeunload: {
  4206. postDispatch: function( event ) {
  4207. // Support: Firefox 20+
  4208. // Firefox doesn't alert if the returnValue field is not set.
  4209. if ( event.result !== undefined ) {
  4210. event.originalEvent.returnValue = event.result;
  4211. }
  4212. }
  4213. }
  4214. },
  4215. simulate: function( type, elem, event, bubble ) {
  4216. // Piggyback on a donor event to simulate a different one.
  4217. // Fake originalEvent to avoid donor's stopPropagation, but if the
  4218. // simulated event prevents default then we do the same on the donor.
  4219. var e = jQuery.extend(
  4220. new jQuery.Event(),
  4221. event,
  4222. {
  4223. type: type,
  4224. isSimulated: true,
  4225. originalEvent: {}
  4226. }
  4227. );
  4228. if ( bubble ) {
  4229. jQuery.event.trigger( e, null, elem );
  4230. } else {
  4231. jQuery.event.dispatch.call( elem, e );
  4232. }
  4233. if ( e.isDefaultPrevented() ) {
  4234. event.preventDefault();
  4235. }
  4236. }
  4237. };
  4238. jQuery.removeEvent = function( elem, type, handle ) {
  4239. if ( elem.removeEventListener ) {
  4240. elem.removeEventListener( type, handle, false );
  4241. }
  4242. };
  4243. jQuery.Event = function( src, props ) {
  4244. // Allow instantiation without the 'new' keyword
  4245. if ( !(this instanceof jQuery.Event) ) {
  4246. return new jQuery.Event( src, props );
  4247. }
  4248. // Event object
  4249. if ( src && src.type ) {
  4250. this.originalEvent = src;
  4251. this.type = src.type;
  4252. // Events bubbling up the document may have been marked as prevented
  4253. // by a handler lower down the tree; reflect the correct value.
  4254. this.isDefaultPrevented = src.defaultPrevented ||
  4255. // Support: Android < 4.0
  4256. src.defaultPrevented === undefined &&
  4257. src.getPreventDefault && src.getPreventDefault() ?
  4258. returnTrue :
  4259. returnFalse;
  4260. // Event type
  4261. } else {
  4262. this.type = src;
  4263. }
  4264. // Put explicitly provided properties onto the event object
  4265. if ( props ) {
  4266. jQuery.extend( this, props );
  4267. }
  4268. // Create a timestamp if incoming event doesn't have one
  4269. this.timeStamp = src && src.timeStamp || jQuery.now();
  4270. // Mark it as fixed
  4271. this[ jQuery.expando ] = true;
  4272. };
  4273. // jQuery.Event is based on DOM3 Events as specified by the ECMAScript Language Binding
  4274. // http://www.w3.org/TR/2003/WD-DOM-Level-3-Events-20030331/ecma-script-binding.html
  4275. jQuery.Event.prototype = {
  4276. isDefaultPrevented: returnFalse,
  4277. isPropagationStopped: returnFalse,
  4278. isImmediatePropagationStopped: returnFalse,
  4279. preventDefault: function() {
  4280. var e = this.originalEvent;
  4281. this.isDefaultPrevented = returnTrue;
  4282. if ( e && e.preventDefault ) {
  4283. e.preventDefault();
  4284. }
  4285. },
  4286. stopPropagation: function() {
  4287. var e = this.originalEvent;
  4288. this.isPropagationStopped = returnTrue;
  4289. if ( e && e.stopPropagation ) {
  4290. e.stopPropagation();
  4291. }
  4292. },
  4293. stopImmediatePropagation: function() {
  4294. this.isImmediatePropagationStopped = returnTrue;
  4295. this.stopPropagation();
  4296. }
  4297. };
  4298. // Create mouseenter/leave events using mouseover/out and event-time checks
  4299. // Support: Chrome 15+
  4300. jQuery.each({
  4301. mouseenter: "mouseover",
  4302. mouseleave: "mouseout"
  4303. }, function( orig, fix ) {
  4304. jQuery.event.special[ orig ] = {
  4305. delegateType: fix,
  4306. bindType: fix,
  4307. handle: function( event ) {
  4308. var ret,
  4309. target = this,
  4310. related = event.relatedTarget,
  4311. handleObj = event.handleObj;
  4312. // For mousenter/leave call the handler if related is outside the target.
  4313. // NB: No relatedTarget if the mouse left/entered the browser window
  4314. if ( !related || (related !== target && !jQuery.contains( target, related )) ) {
  4315. event.type = handleObj.origType;
  4316. ret = handleObj.handler.apply( this, arguments );
  4317. event.type = fix;
  4318. }
  4319. return ret;
  4320. }
  4321. };
  4322. });
  4323. // Create "bubbling" focus and blur events
  4324. // Support: Firefox, Chrome, Safari
  4325. if ( !support.focusinBubbles ) {
  4326. jQuery.each({ focus: "focusin", blur: "focusout" }, function( orig, fix ) {
  4327. // Attach a single capturing handler on the document while someone wants focusin/focusout
  4328. var handler = function( event ) {
  4329. jQuery.event.simulate( fix, event.target, jQuery.event.fix( event ), true );
  4330. };
  4331. jQuery.event.special[ fix ] = {
  4332. setup: function() {
  4333. var doc = this.ownerDocument || this,
  4334. attaches = data_priv.access( doc, fix );
  4335. if ( !attaches ) {
  4336. doc.addEventListener( orig, handler, true );
  4337. }
  4338. data_priv.access( doc, fix, ( attaches || 0 ) + 1 );
  4339. },
  4340. teardown: function() {
  4341. var doc = this.ownerDocument || this,
  4342. attaches = data_priv.access( doc, fix ) - 1;
  4343. if ( !attaches ) {
  4344. doc.removeEventListener( orig, handler, true );
  4345. data_priv.remove( doc, fix );
  4346. } else {
  4347. data_priv.access( doc, fix, attaches );
  4348. }
  4349. }
  4350. };
  4351. });
  4352. }
  4353. jQuery.fn.extend({
  4354. on: function( types, selector, data, fn, /*INTERNAL*/ one ) {
  4355. var origFn, type;
  4356. // Types can be a map of types/handlers
  4357. if ( typeof types === "object" ) {
  4358. // ( types-Object, selector, data )
  4359. if ( typeof selector !== "string" ) {
  4360. // ( types-Object, data )
  4361. data = data || selector;
  4362. selector = undefined;
  4363. }
  4364. for ( type in types ) {
  4365. this.on( type, selector, data, types[ type ], one );
  4366. }
  4367. return this;
  4368. }
  4369. if ( data == null && fn == null ) {
  4370. // ( types, fn )
  4371. fn = selector;
  4372. data = selector = undefined;
  4373. } else if ( fn == null ) {
  4374. if ( typeof selector === "string" ) {
  4375. // ( types, selector, fn )
  4376. fn = data;
  4377. data = undefined;
  4378. } else {
  4379. // ( types, data, fn )
  4380. fn = data;
  4381. data = selector;
  4382. selector = undefined;
  4383. }
  4384. }
  4385. if ( fn === false ) {
  4386. fn = returnFalse;
  4387. } else if ( !fn ) {
  4388. return this;
  4389. }
  4390. if ( one === 1 ) {
  4391. origFn = fn;
  4392. fn = function( event ) {
  4393. // Can use an empty set, since event contains the info
  4394. jQuery().off( event );
  4395. return origFn.apply( this, arguments );
  4396. };
  4397. // Use same guid so caller can remove using origFn
  4398. fn.guid = origFn.guid || ( origFn.guid = jQuery.guid++ );
  4399. }
  4400. return this.each( function() {
  4401. jQuery.event.add( this, types, fn, data, selector );
  4402. });
  4403. },
  4404. one: function( types, selector, data, fn ) {
  4405. return this.on( types, selector, data, fn, 1 );
  4406. },
  4407. off: function( types, selector, fn ) {
  4408. var handleObj, type;
  4409. if ( types && types.preventDefault && types.handleObj ) {
  4410. // ( event ) dispatched jQuery.Event
  4411. handleObj = types.handleObj;
  4412. jQuery( types.delegateTarget ).off(
  4413. handleObj.namespace ? handleObj.origType + "." + handleObj.namespace : handleObj.origType,
  4414. handleObj.selector,
  4415. handleObj.handler
  4416. );
  4417. return this;
  4418. }
  4419. if ( typeof types === "object" ) {
  4420. // ( types-object [, selector] )
  4421. for ( type in types ) {
  4422. this.off( type, selector, types[ type ] );
  4423. }
  4424. return this;
  4425. }
  4426. if ( selector === false || typeof selector === "function" ) {
  4427. // ( types [, fn] )
  4428. fn = selector;
  4429. selector = undefined;
  4430. }
  4431. if ( fn === false ) {
  4432. fn = returnFalse;
  4433. }
  4434. return this.each(function() {
  4435. jQuery.event.remove( this, types, fn, selector );
  4436. });
  4437. },
  4438. trigger: function( type, data ) {
  4439. return this.each(function() {
  4440. jQuery.event.trigger( type, data, this );
  4441. });
  4442. },
  4443. triggerHandler: function( type, data ) {
  4444. var elem = this[0];
  4445. if ( elem ) {
  4446. return jQuery.event.trigger( type, data, elem, true );
  4447. }
  4448. }
  4449. });
  4450. var
  4451. rxhtmlTag = /<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/gi,
  4452. rtagName = /<([\w:]+)/,
  4453. rhtml = /<|&#?\w+;/,
  4454. rnoInnerhtml = /<(?:script|style|link)/i,
  4455. // checked="checked" or checked
  4456. rchecked = /checked\s*(?:[^=]|=\s*.checked.)/i,
  4457. rscriptType = /^$|\/(?:java|ecma)script/i,
  4458. rscriptTypeMasked = /^true\/(.*)/,
  4459. rcleanScript = /^\s*<!(?:\[CDATA\[|--)|(?:\]\]|--)>\s*$/g,
  4460. // We have to close these tags to support XHTML (#13200)
  4461. wrapMap = {
  4462. // Support: IE 9
  4463. option: [ 1, "<select multiple='multiple'>", "</select>" ],
  4464. thead: [ 1, "<table>", "</table>" ],
  4465. col: [ 2, "<table><colgroup>", "</colgroup></table>" ],
  4466. tr: [ 2, "<table><tbody>", "</tbody></table>" ],
  4467. td: [ 3, "<table><tbody><tr>", "</tr></tbody></table>" ],
  4468. _default: [ 0, "", "" ]
  4469. };
  4470. // Support: IE 9
  4471. wrapMap.optgroup = wrapMap.option;
  4472. wrapMap.tbody = wrapMap.tfoot = wrapMap.colgroup = wrapMap.caption = wrapMap.thead;
  4473. wrapMap.th = wrapMap.td;
  4474. // Support: 1.x compatibility
  4475. // Manipulating tables requires a tbody
  4476. function manipulationTarget( elem, content ) {
  4477. return jQuery.nodeName( elem, "table" ) &&
  4478. jQuery.nodeName( content.nodeType !== 11 ? content : content.firstChild, "tr" ) ?
  4479. elem.getElementsByTagName("tbody")[0] ||
  4480. elem.appendChild( elem.ownerDocument.createElement("tbody") ) :
  4481. elem;
  4482. }
  4483. // Replace/restore the type attribute of script elements for safe DOM manipulation
  4484. function disableScript( elem ) {
  4485. elem.type = (elem.getAttribute("type") !== null) + "/" + elem.type;
  4486. return elem;
  4487. }
  4488. function restoreScript( elem ) {
  4489. var match = rscriptTypeMasked.exec( elem.type );
  4490. if ( match ) {
  4491. elem.type = match[ 1 ];
  4492. } else {
  4493. elem.removeAttribute("type");
  4494. }
  4495. return elem;
  4496. }
  4497. // Mark scripts as having already been evaluated
  4498. function setGlobalEval( elems, refElements ) {
  4499. var i = 0,
  4500. l = elems.length;
  4501. for ( ; i < l; i++ ) {
  4502. data_priv.set(
  4503. elems[ i ], "globalEval", !refElements || data_priv.get( refElements[ i ], "globalEval" )
  4504. );
  4505. }
  4506. }
  4507. function cloneCopyEvent( src, dest ) {
  4508. var i, l, type, pdataOld, pdataCur, udataOld, udataCur, events;
  4509. if ( dest.nodeType !== 1 ) {
  4510. return;
  4511. }
  4512. // 1. Copy private data: events, handlers, etc.
  4513. if ( data_priv.hasData( src ) ) {
  4514. pdataOld = data_priv.access( src );
  4515. pdataCur = data_priv.set( dest, pdataOld );
  4516. events = pdataOld.events;
  4517. if ( events ) {
  4518. delete pdataCur.handle;
  4519. pdataCur.events = {};
  4520. for ( type in events ) {
  4521. for ( i = 0, l = events[ type ].length; i < l; i++ ) {
  4522. jQuery.event.add( dest, type, events[ type ][ i ] );
  4523. }
  4524. }
  4525. }
  4526. }
  4527. // 2. Copy user data
  4528. if ( data_user.hasData( src ) ) {
  4529. udataOld = data_user.access( src );
  4530. udataCur = jQuery.extend( {}, udataOld );
  4531. data_user.set( dest, udataCur );
  4532. }
  4533. }
  4534. function getAll( context, tag ) {
  4535. var ret = context.getElementsByTagName ? context.getElementsByTagName( tag || "*" ) :
  4536. context.querySelectorAll ? context.querySelectorAll( tag || "*" ) :
  4537. [];
  4538. return tag === undefined || tag && jQuery.nodeName( context, tag ) ?
  4539. jQuery.merge( [ context ], ret ) :
  4540. ret;
  4541. }
  4542. // Support: IE >= 9
  4543. function fixInput( src, dest ) {
  4544. var nodeName = dest.nodeName.toLowerCase();
  4545. // Fails to persist the checked state of a cloned checkbox or radio button.
  4546. if ( nodeName === "input" && rcheckableType.test( src.type ) ) {
  4547. dest.checked = src.checked;
  4548. // Fails to return the selected option to the default selected state when cloning options
  4549. } else if ( nodeName === "input" || nodeName === "textarea" ) {
  4550. dest.defaultValue = src.defaultValue;
  4551. }
  4552. }
  4553. jQuery.extend({
  4554. clone: function( elem, dataAndEvents, deepDataAndEvents ) {
  4555. var i, l, srcElements, destElements,
  4556. clone = elem.cloneNode( true ),
  4557. inPage = jQuery.contains( elem.ownerDocument, elem );
  4558. // Support: IE >= 9
  4559. // Fix Cloning issues
  4560. if ( !support.noCloneChecked && ( elem.nodeType === 1 || elem.nodeType === 11 ) &&
  4561. !jQuery.isXMLDoc( elem ) ) {
  4562. // We eschew Sizzle here for performance reasons: http://jsperf.com/getall-vs-sizzle/2
  4563. destElements = getAll( clone );
  4564. srcElements = getAll( elem );
  4565. for ( i = 0, l = srcElements.length; i < l; i++ ) {
  4566. fixInput( srcElements[ i ], destElements[ i ] );
  4567. }
  4568. }
  4569. // Copy the events from the original to the clone
  4570. if ( dataAndEvents ) {
  4571. if ( deepDataAndEvents ) {
  4572. srcElements = srcElements || getAll( elem );
  4573. destElements = destElements || getAll( clone );
  4574. for ( i = 0, l = srcElements.length; i < l; i++ ) {
  4575. cloneCopyEvent( srcElements[ i ], destElements[ i ] );
  4576. }
  4577. } else {
  4578. cloneCopyEvent( elem, clone );
  4579. }
  4580. }
  4581. // Preserve script evaluation history
  4582. destElements = getAll( clone, "script" );
  4583. if ( destElements.length > 0 ) {
  4584. setGlobalEval( destElements, !inPage && getAll( elem, "script" ) );
  4585. }
  4586. // Return the cloned set
  4587. return clone;
  4588. },
  4589. buildFragment: function( elems, context, scripts, selection ) {
  4590. var elem, tmp, tag, wrap, contains, j,
  4591. fragment = context.createDocumentFragment(),
  4592. nodes = [],
  4593. i = 0,
  4594. l = elems.length;
  4595. for ( ; i < l; i++ ) {
  4596. elem = elems[ i ];
  4597. if ( elem || elem === 0 ) {
  4598. // Add nodes directly
  4599. if ( jQuery.type( elem ) === "object" ) {
  4600. // Support: QtWebKit
  4601. // jQuery.merge because push.apply(_, arraylike) throws
  4602. jQuery.merge( nodes, elem.nodeType ? [ elem ] : elem );
  4603. // Convert non-html into a text node
  4604. } else if ( !rhtml.test( elem ) ) {
  4605. nodes.push( context.createTextNode( elem ) );
  4606. // Convert html into DOM nodes
  4607. } else {
  4608. tmp = tmp || fragment.appendChild( context.createElement("div") );
  4609. // Deserialize a standard representation
  4610. tag = ( rtagName.exec( elem ) || [ "", "" ] )[ 1 ].toLowerCase();
  4611. wrap = wrapMap[ tag ] || wrapMap._default;
  4612. tmp.innerHTML = wrap[ 1 ] + elem.replace( rxhtmlTag, "<$1></$2>" ) + wrap[ 2 ];
  4613. // Descend through wrappers to the right content
  4614. j = wrap[ 0 ];
  4615. while ( j-- ) {
  4616. tmp = tmp.lastChild;
  4617. }
  4618. // Support: QtWebKit
  4619. // jQuery.merge because push.apply(_, arraylike) throws
  4620. jQuery.merge( nodes, tmp.childNodes );
  4621. // Remember the top-level container
  4622. tmp = fragment.firstChild;
  4623. // Fixes #12346
  4624. // Support: Webkit, IE
  4625. tmp.textContent = "";
  4626. }
  4627. }
  4628. }
  4629. // Remove wrapper from fragment
  4630. fragment.textContent = "";
  4631. i = 0;
  4632. while ( (elem = nodes[ i++ ]) ) {
  4633. // #4087 - If origin and destination elements are the same, and this is
  4634. // that element, do not do anything
  4635. if ( selection && jQuery.inArray( elem, selection ) !== -1 ) {
  4636. continue;
  4637. }
  4638. contains = jQuery.contains( elem.ownerDocument, elem );
  4639. // Append to fragment
  4640. tmp = getAll( fragment.appendChild( elem ), "script" );
  4641. // Preserve script evaluation history
  4642. if ( contains ) {
  4643. setGlobalEval( tmp );
  4644. }
  4645. // Capture executables
  4646. if ( scripts ) {
  4647. j = 0;
  4648. while ( (elem = tmp[ j++ ]) ) {
  4649. if ( rscriptType.test( elem.type || "" ) ) {
  4650. scripts.push( elem );
  4651. }
  4652. }
  4653. }
  4654. }
  4655. return fragment;
  4656. },
  4657. cleanData: function( elems ) {
  4658. var data, elem, events, type, key, j,
  4659. special = jQuery.event.special,
  4660. i = 0;
  4661. for ( ; (elem = elems[ i ]) !== undefined; i++ ) {
  4662. if ( jQuery.acceptData( elem ) ) {
  4663. key = elem[ data_priv.expando ];
  4664. if ( key && (data = data_priv.cache[ key ]) ) {
  4665. events = Object.keys( data.events || {} );
  4666. if ( events.length ) {
  4667. for ( j = 0; (type = events[j]) !== undefined; j++ ) {
  4668. if ( special[ type ] ) {
  4669. jQuery.event.remove( elem, type );
  4670. // This is a shortcut to avoid jQuery.event.remove's overhead
  4671. } else {
  4672. jQuery.removeEvent( elem, type, data.handle );
  4673. }
  4674. }
  4675. }
  4676. if ( data_priv.cache[ key ] ) {
  4677. // Discard any remaining `private` data
  4678. delete data_priv.cache[ key ];
  4679. }
  4680. }
  4681. }
  4682. // Discard any remaining `user` data
  4683. delete data_user.cache[ elem[ data_user.expando ] ];
  4684. }
  4685. }
  4686. });
  4687. jQuery.fn.extend({
  4688. text: function( value ) {
  4689. return access( this, function( value ) {
  4690. return value === undefined ?
  4691. jQuery.text( this ) :
  4692. this.empty().each(function() {
  4693. if ( this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9 ) {
  4694. this.textContent = value;
  4695. }
  4696. });
  4697. }, null, value, arguments.length );
  4698. },
  4699. append: function() {
  4700. return this.domManip( arguments, function( elem ) {
  4701. if ( this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9 ) {
  4702. var target = manipulationTarget( this, elem );
  4703. target.appendChild( elem );
  4704. }
  4705. });
  4706. },
  4707. prepend: function() {
  4708. return this.domManip( arguments, function( elem ) {
  4709. if ( this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9 ) {
  4710. var target = manipulationTarget( this, elem );
  4711. target.insertBefore( elem, target.firstChild );
  4712. }
  4713. });
  4714. },
  4715. before: function() {
  4716. return this.domManip( arguments, function( elem ) {
  4717. if ( this.parentNode ) {
  4718. this.parentNode.insertBefore( elem, this );
  4719. }
  4720. });
  4721. },
  4722. after: function() {
  4723. return this.domManip( arguments, function( elem ) {
  4724. if ( this.parentNode ) {
  4725. this.parentNode.insertBefore( elem, this.nextSibling );
  4726. }
  4727. });
  4728. },
  4729. remove: function( selector, keepData /* Internal Use Only */ ) {
  4730. var elem,
  4731. elems = selector ? jQuery.filter( selector, this ) : this,
  4732. i = 0;
  4733. for ( ; (elem = elems[i]) != null; i++ ) {
  4734. if ( !keepData && elem.nodeType === 1 ) {
  4735. jQuery.cleanData( getAll( elem ) );
  4736. }
  4737. if ( elem.parentNode ) {
  4738. if ( keepData && jQuery.contains( elem.ownerDocument, elem ) ) {
  4739. setGlobalEval( getAll( elem, "script" ) );
  4740. }
  4741. elem.parentNode.removeChild( elem );
  4742. }
  4743. }
  4744. return this;
  4745. },
  4746. empty: function() {
  4747. var elem,
  4748. i = 0;
  4749. for ( ; (elem = this[i]) != null; i++ ) {
  4750. if ( elem.nodeType === 1 ) {
  4751. // Prevent memory leaks
  4752. jQuery.cleanData( getAll( elem, false ) );
  4753. // Remove any remaining nodes
  4754. elem.textContent = "";
  4755. }
  4756. }
  4757. return this;
  4758. },
  4759. clone: function( dataAndEvents, deepDataAndEvents ) {
  4760. dataAndEvents = dataAndEvents == null ? false : dataAndEvents;
  4761. deepDataAndEvents = deepDataAndEvents == null ? dataAndEvents : deepDataAndEvents;
  4762. return this.map(function() {
  4763. return jQuery.clone( this, dataAndEvents, deepDataAndEvents );
  4764. });
  4765. },
  4766. html: function( value ) {
  4767. return access( this, function( value ) {
  4768. var elem = this[ 0 ] || {},
  4769. i = 0,
  4770. l = this.length;
  4771. if ( value === undefined && elem.nodeType === 1 ) {
  4772. return elem.innerHTML;
  4773. }
  4774. // See if we can take a shortcut and just use innerHTML
  4775. if ( typeof value === "string" && !rnoInnerhtml.test( value ) &&
  4776. !wrapMap[ ( rtagName.exec( value ) || [ "", "" ] )[ 1 ].toLowerCase() ] ) {
  4777. value = value.replace( rxhtmlTag, "<$1></$2>" );
  4778. try {
  4779. for ( ; i < l; i++ ) {
  4780. elem = this[ i ] || {};
  4781. // Remove element nodes and prevent memory leaks
  4782. if ( elem.nodeType === 1 ) {
  4783. jQuery.cleanData( getAll( elem, false ) );
  4784. elem.innerHTML = value;
  4785. }
  4786. }
  4787. elem = 0;
  4788. // If using innerHTML throws an exception, use the fallback method
  4789. } catch( e ) {}
  4790. }
  4791. if ( elem ) {
  4792. this.empty().append( value );
  4793. }
  4794. }, null, value, arguments.length );
  4795. },
  4796. replaceWith: function() {
  4797. var arg = arguments[ 0 ];
  4798. // Make the changes, replacing each context element with the new content
  4799. this.domManip( arguments, function( elem ) {
  4800. arg = this.parentNode;
  4801. jQuery.cleanData( getAll( this ) );
  4802. if ( arg ) {
  4803. arg.replaceChild( elem, this );
  4804. }
  4805. });
  4806. // Force removal if there was no new content (e.g., from empty arguments)
  4807. return arg && (arg.length || arg.nodeType) ? this : this.remove();
  4808. },
  4809. detach: function( selector ) {
  4810. return this.remove( selector, true );
  4811. },
  4812. domManip: function( args, callback ) {
  4813. // Flatten any nested arrays
  4814. args = concat.apply( [], args );
  4815. var fragment, first, scripts, hasScripts, node, doc,
  4816. i = 0,
  4817. l = this.length,
  4818. set = this,
  4819. iNoClone = l - 1,
  4820. value = args[ 0 ],
  4821. isFunction = jQuery.isFunction( value );
  4822. // We can't cloneNode fragments that contain checked, in WebKit
  4823. if ( isFunction ||
  4824. ( l > 1 && typeof value === "string" &&
  4825. !support.checkClone && rchecked.test( value ) ) ) {
  4826. return this.each(function( index ) {
  4827. var self = set.eq( index );
  4828. if ( isFunction ) {
  4829. args[ 0 ] = value.call( this, index, self.html() );
  4830. }
  4831. self.domManip( args, callback );
  4832. });
  4833. }
  4834. if ( l ) {
  4835. fragment = jQuery.buildFragment( args, this[ 0 ].ownerDocument, false, this );
  4836. first = fragment.firstChild;
  4837. if ( fragment.childNodes.length === 1 ) {
  4838. fragment = first;
  4839. }
  4840. if ( first ) {
  4841. scripts = jQuery.map( getAll( fragment, "script" ), disableScript );
  4842. hasScripts = scripts.length;
  4843. // Use the original fragment for the last item instead of the first because it can end up
  4844. // being emptied incorrectly in certain situations (#8070).
  4845. for ( ; i < l; i++ ) {
  4846. node = fragment;
  4847. if ( i !== iNoClone ) {
  4848. node = jQuery.clone( node, true, true );
  4849. // Keep references to cloned scripts for later restoration
  4850. if ( hasScripts ) {
  4851. // Support: QtWebKit
  4852. // jQuery.merge because push.apply(_, arraylike) throws
  4853. jQuery.merge( scripts, getAll( node, "script" ) );
  4854. }
  4855. }
  4856. callback.call( this[ i ], node, i );
  4857. }
  4858. if ( hasScripts ) {
  4859. doc = scripts[ scripts.length - 1 ].ownerDocument;
  4860. // Reenable scripts
  4861. jQuery.map( scripts, restoreScript );
  4862. // Evaluate executable scripts on first document insertion
  4863. for ( i = 0; i < hasScripts; i++ ) {
  4864. node = scripts[ i ];
  4865. if ( rscriptType.test( node.type || "" ) &&
  4866. !data_priv.access( node, "globalEval" ) && jQuery.contains( doc, node ) ) {
  4867. if ( node.src ) {
  4868. // Optional AJAX dependency, but won't run scripts if not present
  4869. if ( jQuery._evalUrl ) {
  4870. jQuery._evalUrl( node.src );
  4871. }
  4872. } else {
  4873. jQuery.globalEval( node.textContent.replace( rcleanScript, "" ) );
  4874. }
  4875. }
  4876. }
  4877. }
  4878. }
  4879. }
  4880. return this;
  4881. }
  4882. });
  4883. jQuery.each({
  4884. appendTo: "append",
  4885. prependTo: "prepend",
  4886. insertBefore: "before",
  4887. insertAfter: "after",
  4888. replaceAll: "replaceWith"
  4889. }, function( name, original ) {
  4890. jQuery.fn[ name ] = function( selector ) {
  4891. var elems,
  4892. ret = [],
  4893. insert = jQuery( selector ),
  4894. last = insert.length - 1,
  4895. i = 0;
  4896. for ( ; i <= last; i++ ) {
  4897. elems = i === last ? this : this.clone( true );
  4898. jQuery( insert[ i ] )[ original ]( elems );
  4899. // Support: QtWebKit
  4900. // .get() because push.apply(_, arraylike) throws
  4901. push.apply( ret, elems.get() );
  4902. }
  4903. return this.pushStack( ret );
  4904. };
  4905. });
  4906. var iframe,
  4907. elemdisplay = {};
  4908. /**
  4909. * Retrieve the actual display of a element
  4910. * @param {String} name nodeName of the element
  4911. * @param {Object} doc Document object
  4912. */
  4913. // Called only from within defaultDisplay
  4914. function actualDisplay( name, doc ) {
  4915. var elem = jQuery( doc.createElement( name ) ).appendTo( doc.body ),
  4916. // getDefaultComputedStyle might be reliably used only on attached element
  4917. display = window.getDefaultComputedStyle ?
  4918. // Use of this method is a temporary fix (more like optmization) until something better comes along,
  4919. // since it was removed from specification and supported only in FF
  4920. window.getDefaultComputedStyle( elem[ 0 ] ).display : jQuery.css( elem[ 0 ], "display" );
  4921. // We don't have any data stored on the element,
  4922. // so use "detach" method as fast way to get rid of the element
  4923. elem.detach();
  4924. return display;
  4925. }
  4926. /**
  4927. * Try to determine the default display value of an element
  4928. * @param {String} nodeName
  4929. */
  4930. function defaultDisplay( nodeName ) {
  4931. var doc = document,
  4932. display = elemdisplay[ nodeName ];
  4933. if ( !display ) {
  4934. display = actualDisplay( nodeName, doc );
  4935. // If the simple way fails, read from inside an iframe
  4936. if ( display === "none" || !display ) {
  4937. // Use the already-created iframe if possible
  4938. iframe = (iframe || jQuery( "<iframe frameborder='0' width='0' height='0'/>" )).appendTo( doc.documentElement );
  4939. // Always write a new HTML skeleton so Webkit and Firefox don't choke on reuse
  4940. doc = iframe[ 0 ].contentDocument;
  4941. // Support: IE
  4942. doc.write();
  4943. doc.close();
  4944. display = actualDisplay( nodeName, doc );
  4945. iframe.detach();
  4946. }
  4947. // Store the correct default display
  4948. elemdisplay[ nodeName ] = display;
  4949. }
  4950. return display;
  4951. }
  4952. var rmargin = (/^margin/);
  4953. var rnumnonpx = new RegExp( "^(" + pnum + ")(?!px)[a-z%]+$", "i" );
  4954. var getStyles = function( elem ) {
  4955. return elem.ownerDocument.defaultView.getComputedStyle( elem, null );
  4956. };
  4957. function curCSS( elem, name, computed ) {
  4958. var width, minWidth, maxWidth, ret,
  4959. style = elem.style;
  4960. computed = computed || getStyles( elem );
  4961. // Support: IE9
  4962. // getPropertyValue is only needed for .css('filter') in IE9, see #12537
  4963. if ( computed ) {
  4964. ret = computed.getPropertyValue( name ) || computed[ name ];
  4965. }
  4966. if ( computed ) {
  4967. if ( ret === "" && !jQuery.contains( elem.ownerDocument, elem ) ) {
  4968. ret = jQuery.style( elem, name );
  4969. }
  4970. // Support: iOS < 6
  4971. // A tribute to the "awesome hack by Dean Edwards"
  4972. // iOS < 6 (at least) returns percentage for a larger set of values, but width seems to be reliably pixels
  4973. // this is against the CSSOM draft spec: http://dev.w3.org/csswg/cssom/#resolved-values
  4974. if ( rnumnonpx.test( ret ) && rmargin.test( name ) ) {
  4975. // Remember the original values
  4976. width = style.width;
  4977. minWidth = style.minWidth;
  4978. maxWidth = style.maxWidth;
  4979. // Put in the new values to get a computed value out
  4980. style.minWidth = style.maxWidth = style.width = ret;
  4981. ret = computed.width;
  4982. // Revert the changed values
  4983. style.width = width;
  4984. style.minWidth = minWidth;
  4985. style.maxWidth = maxWidth;
  4986. }
  4987. }
  4988. return ret !== undefined ?
  4989. // Support: IE
  4990. // IE returns zIndex value as an integer.
  4991. ret + "" :
  4992. ret;
  4993. }
  4994. function addGetHookIf( conditionFn, hookFn ) {
  4995. // Define the hook, we'll check on the first run if it's really needed.
  4996. return {
  4997. get: function() {
  4998. if ( conditionFn() ) {
  4999. // Hook not needed (or it's not possible to use it due to missing dependency),
  5000. // remove it.
  5001. // Since there are no other hooks for marginRight, remove the whole object.
  5002. delete this.get;
  5003. return;
  5004. }
  5005. // Hook needed; redefine it so that the support test is not executed again.
  5006. return (this.get = hookFn).apply( this, arguments );
  5007. }
  5008. };
  5009. }
  5010. (function() {
  5011. var pixelPositionVal, boxSizingReliableVal,
  5012. // Support: Firefox, Android 2.3 (Prefixed box-sizing versions).
  5013. divReset = "padding:0;margin:0;border:0;display:block;-webkit-box-sizing:content-box;" +
  5014. "-moz-box-sizing:content-box;box-sizing:content-box",
  5015. docElem = document.documentElement,
  5016. container = document.createElement( "div" ),
  5017. div = document.createElement( "div" );
  5018. div.style.backgroundClip = "content-box";
  5019. div.cloneNode( true ).style.backgroundClip = "";
  5020. support.clearCloneStyle = div.style.backgroundClip === "content-box";
  5021. container.style.cssText = "border:0;width:0;height:0;position:absolute;top:0;left:-9999px;" +
  5022. "margin-top:1px";
  5023. container.appendChild( div );
  5024. // Executing both pixelPosition & boxSizingReliable tests require only one layout
  5025. // so they're executed at the same time to save the second computation.
  5026. function computePixelPositionAndBoxSizingReliable() {
  5027. // Support: Firefox, Android 2.3 (Prefixed box-sizing versions).
  5028. div.style.cssText = "-webkit-box-sizing:border-box;-moz-box-sizing:border-box;" +
  5029. "box-sizing:border-box;padding:1px;border:1px;display:block;width:4px;margin-top:1%;" +
  5030. "position:absolute;top:1%";
  5031. docElem.appendChild( container );
  5032. var divStyle = window.getComputedStyle( div, null );
  5033. pixelPositionVal = divStyle.top !== "1%";
  5034. boxSizingReliableVal = divStyle.width === "4px";
  5035. docElem.removeChild( container );
  5036. }
  5037. // Use window.getComputedStyle because jsdom on node.js will break without it.
  5038. if ( window.getComputedStyle ) {
  5039. jQuery.extend(support, {
  5040. pixelPosition: function() {
  5041. // This test is executed only once but we still do memoizing
  5042. // since we can use the boxSizingReliable pre-computing.
  5043. // No need to check if the test was already performed, though.
  5044. computePixelPositionAndBoxSizingReliable();
  5045. return pixelPositionVal;
  5046. },
  5047. boxSizingReliable: function() {
  5048. if ( boxSizingReliableVal == null ) {
  5049. computePixelPositionAndBoxSizingReliable();
  5050. }
  5051. return boxSizingReliableVal;
  5052. },
  5053. reliableMarginRight: function() {
  5054. // Support: Android 2.3
  5055. // Check if div with explicit width and no margin-right incorrectly
  5056. // gets computed margin-right based on width of container. (#3333)
  5057. // WebKit Bug 13343 - getComputedStyle returns wrong value for margin-right
  5058. // This support function is only executed once so no memoizing is needed.
  5059. var ret,
  5060. marginDiv = div.appendChild( document.createElement( "div" ) );
  5061. marginDiv.style.cssText = div.style.cssText = divReset;
  5062. marginDiv.style.marginRight = marginDiv.style.width = "0";
  5063. div.style.width = "1px";
  5064. docElem.appendChild( container );
  5065. ret = !parseFloat( window.getComputedStyle( marginDiv, null ).marginRight );
  5066. docElem.removeChild( container );
  5067. // Clean up the div for other support tests.
  5068. div.innerHTML = "";
  5069. return ret;
  5070. }
  5071. });
  5072. }
  5073. })();
  5074. // A method for quickly swapping in/out CSS properties to get correct calculations.
  5075. jQuery.swap = function( elem, options, callback, args ) {
  5076. var ret, name,
  5077. old = {};
  5078. // Remember the old values, and insert the new ones
  5079. for ( name in options ) {
  5080. old[ name ] = elem.style[ name ];
  5081. elem.style[ name ] = options[ name ];
  5082. }
  5083. ret = callback.apply( elem, args || [] );
  5084. // Revert the old values
  5085. for ( name in options ) {
  5086. elem.style[ name ] = old[ name ];
  5087. }
  5088. return ret;
  5089. };
  5090. var
  5091. // swappable if display is none or starts with table except "table", "table-cell", or "table-caption"
  5092. // see here for display values: https://developer.mozilla.org/en-US/docs/CSS/display
  5093. rdisplayswap = /^(none|table(?!-c[ea]).+)/,
  5094. rnumsplit = new RegExp( "^(" + pnum + ")(.*)$", "i" ),
  5095. rrelNum = new RegExp( "^([+-])=(" + pnum + ")", "i" ),
  5096. cssShow = { position: "absolute", visibility: "hidden", display: "block" },
  5097. cssNormalTransform = {
  5098. letterSpacing: 0,
  5099. fontWeight: 400
  5100. },
  5101. cssPrefixes = [ "Webkit", "O", "Moz", "ms" ];
  5102. // return a css property mapped to a potentially vendor prefixed property
  5103. function vendorPropName( style, name ) {
  5104. // shortcut for names that are not vendor prefixed
  5105. if ( name in style ) {
  5106. return name;
  5107. }
  5108. // check for vendor prefixed names
  5109. var capName = name[0].toUpperCase() + name.slice(1),
  5110. origName = name,
  5111. i = cssPrefixes.length;
  5112. while ( i-- ) {
  5113. name = cssPrefixes[ i ] + capName;
  5114. if ( name in style ) {
  5115. return name;
  5116. }
  5117. }
  5118. return origName;
  5119. }
  5120. function setPositiveNumber( elem, value, subtract ) {
  5121. var matches = rnumsplit.exec( value );
  5122. return matches ?
  5123. // Guard against undefined "subtract", e.g., when used as in cssHooks
  5124. Math.max( 0, matches[ 1 ] - ( subtract || 0 ) ) + ( matches[ 2 ] || "px" ) :
  5125. value;
  5126. }
  5127. function augmentWidthOrHeight( elem, name, extra, isBorderBox, styles ) {
  5128. var i = extra === ( isBorderBox ? "border" : "content" ) ?
  5129. // If we already have the right measurement, avoid augmentation
  5130. 4 :
  5131. // Otherwise initialize for horizontal or vertical properties
  5132. name === "width" ? 1 : 0,
  5133. val = 0;
  5134. for ( ; i < 4; i += 2 ) {
  5135. // both box models exclude margin, so add it if we want it
  5136. if ( extra === "margin" ) {
  5137. val += jQuery.css( elem, extra + cssExpand[ i ], true, styles );
  5138. }
  5139. if ( isBorderBox ) {
  5140. // border-box includes padding, so remove it if we want content
  5141. if ( extra === "content" ) {
  5142. val -= jQuery.css( elem, "padding" + cssExpand[ i ], true, styles );
  5143. }
  5144. // at this point, extra isn't border nor margin, so remove border
  5145. if ( extra !== "margin" ) {
  5146. val -= jQuery.css( elem, "border" + cssExpand[ i ] + "Width", true, styles );
  5147. }
  5148. } else {
  5149. // at this point, extra isn't content, so add padding
  5150. val += jQuery.css( elem, "padding" + cssExpand[ i ], true, styles );
  5151. // at this point, extra isn't content nor padding, so add border
  5152. if ( extra !== "padding" ) {
  5153. val += jQuery.css( elem, "border" + cssExpand[ i ] + "Width", true, styles );
  5154. }
  5155. }
  5156. }
  5157. return val;
  5158. }
  5159. function getWidthOrHeight( elem, name, extra ) {
  5160. // Start with offset property, which is equivalent to the border-box value
  5161. var valueIsBorderBox = true,
  5162. val = name === "width" ? elem.offsetWidth : elem.offsetHeight,
  5163. styles = getStyles( elem ),
  5164. isBorderBox = jQuery.css( elem, "boxSizing", false, styles ) === "border-box";
  5165. // some non-html elements return undefined for offsetWidth, so check for null/undefined
  5166. // svg - https://bugzilla.mozilla.org/show_bug.cgi?id=649285
  5167. // MathML - https://bugzilla.mozilla.org/show_bug.cgi?id=491668
  5168. if ( val <= 0 || val == null ) {
  5169. // Fall back to computed then uncomputed css if necessary
  5170. val = curCSS( elem, name, styles );
  5171. if ( val < 0 || val == null ) {
  5172. val = elem.style[ name ];
  5173. }
  5174. // Computed unit is not pixels. Stop here and return.
  5175. if ( rnumnonpx.test(val) ) {
  5176. return val;
  5177. }
  5178. // we need the check for style in case a browser which returns unreliable values
  5179. // for getComputedStyle silently falls back to the reliable elem.style
  5180. valueIsBorderBox = isBorderBox &&
  5181. ( support.boxSizingReliable() || val === elem.style[ name ] );
  5182. // Normalize "", auto, and prepare for extra
  5183. val = parseFloat( val ) || 0;
  5184. }
  5185. // use the active box-sizing model to add/subtract irrelevant styles
  5186. return ( val +
  5187. augmentWidthOrHeight(
  5188. elem,
  5189. name,
  5190. extra || ( isBorderBox ? "border" : "content" ),
  5191. valueIsBorderBox,
  5192. styles
  5193. )
  5194. ) + "px";
  5195. }
  5196. function showHide( elements, show ) {
  5197. var display, elem, hidden,
  5198. values = [],
  5199. index = 0,
  5200. length = elements.length;
  5201. for ( ; index < length; index++ ) {
  5202. elem = elements[ index ];
  5203. if ( !elem.style ) {
  5204. continue;
  5205. }
  5206. values[ index ] = data_priv.get( elem, "olddisplay" );
  5207. display = elem.style.display;
  5208. if ( show ) {
  5209. // Reset the inline display of this element to learn if it is
  5210. // being hidden by cascaded rules or not
  5211. if ( !values[ index ] && display === "none" ) {
  5212. elem.style.display = "";
  5213. }
  5214. // Set elements which have been overridden with display: none
  5215. // in a stylesheet to whatever the default browser style is
  5216. // for such an element
  5217. if ( elem.style.display === "" && isHidden( elem ) ) {
  5218. values[ index ] = data_priv.access( elem, "olddisplay", defaultDisplay(elem.nodeName) );
  5219. }
  5220. } else {
  5221. if ( !values[ index ] ) {
  5222. hidden = isHidden( elem );
  5223. if ( display && display !== "none" || !hidden ) {
  5224. data_priv.set( elem, "olddisplay", hidden ? display : jQuery.css(elem, "display") );
  5225. }
  5226. }
  5227. }
  5228. }
  5229. // Set the display of most of the elements in a second loop
  5230. // to avoid the constant reflow
  5231. for ( index = 0; index < length; index++ ) {
  5232. elem = elements[ index ];
  5233. if ( !elem.style ) {
  5234. continue;
  5235. }
  5236. if ( !show || elem.style.display === "none" || elem.style.display === "" ) {
  5237. elem.style.display = show ? values[ index ] || "" : "none";
  5238. }
  5239. }
  5240. return elements;
  5241. }
  5242. jQuery.extend({
  5243. // Add in style property hooks for overriding the default
  5244. // behavior of getting and setting a style property
  5245. cssHooks: {
  5246. opacity: {
  5247. get: function( elem, computed ) {
  5248. if ( computed ) {
  5249. // We should always get a number back from opacity
  5250. var ret = curCSS( elem, "opacity" );
  5251. return ret === "" ? "1" : ret;
  5252. }
  5253. }
  5254. }
  5255. },
  5256. // Don't automatically add "px" to these possibly-unitless properties
  5257. cssNumber: {
  5258. "columnCount": true,
  5259. "fillOpacity": true,
  5260. "fontWeight": true,
  5261. "lineHeight": true,
  5262. "opacity": true,
  5263. "order": true,
  5264. "orphans": true,
  5265. "widows": true,
  5266. "zIndex": true,
  5267. "zoom": true
  5268. },
  5269. // Add in properties whose names you wish to fix before
  5270. // setting or getting the value
  5271. cssProps: {
  5272. // normalize float css property
  5273. "float": "cssFloat"
  5274. },
  5275. // Get and set the style property on a DOM Node
  5276. style: function( elem, name, value, extra ) {
  5277. // Don't set styles on text and comment nodes
  5278. if ( !elem || elem.nodeType === 3 || elem.nodeType === 8 || !elem.style ) {
  5279. return;
  5280. }
  5281. // Make sure that we're working with the right name
  5282. var ret, type, hooks,
  5283. origName = jQuery.camelCase( name ),
  5284. style = elem.style;
  5285. name = jQuery.cssProps[ origName ] || ( jQuery.cssProps[ origName ] = vendorPropName( style, origName ) );
  5286. // gets hook for the prefixed version
  5287. // followed by the unprefixed version
  5288. hooks = jQuery.cssHooks[ name ] || jQuery.cssHooks[ origName ];
  5289. // Check if we're setting a value
  5290. if ( value !== undefined ) {
  5291. type = typeof value;
  5292. // convert relative number strings (+= or -=) to relative numbers. #7345
  5293. if ( type === "string" && (ret = rrelNum.exec( value )) ) {
  5294. value = ( ret[1] + 1 ) * ret[2] + parseFloat( jQuery.css( elem, name ) );
  5295. // Fixes bug #9237
  5296. type = "number";
  5297. }
  5298. // Make sure that null and NaN values aren't set. See: #7116
  5299. if ( value == null || value !== value ) {
  5300. return;
  5301. }
  5302. // If a number was passed in, add 'px' to the (except for certain CSS properties)
  5303. if ( type === "number" && !jQuery.cssNumber[ origName ] ) {
  5304. value += "px";
  5305. }
  5306. // Fixes #8908, it can be done more correctly by specifying setters in cssHooks,
  5307. // but it would mean to define eight (for every problematic property) identical functions
  5308. if ( !support.clearCloneStyle && value === "" && name.indexOf( "background" ) === 0 ) {
  5309. style[ name ] = "inherit";
  5310. }
  5311. // If a hook was provided, use that value, otherwise just set the specified value
  5312. if ( !hooks || !("set" in hooks) || (value = hooks.set( elem, value, extra )) !== undefined ) {
  5313. // Support: Chrome, Safari
  5314. // Setting style to blank string required to delete "style: x !important;"
  5315. style[ name ] = "";
  5316. style[ name ] = value;
  5317. }
  5318. } else {
  5319. // If a hook was provided get the non-computed value from there
  5320. if ( hooks && "get" in hooks && (ret = hooks.get( elem, false, extra )) !== undefined ) {
  5321. return ret;
  5322. }
  5323. // Otherwise just get the value from the style object
  5324. return style[ name ];
  5325. }
  5326. },
  5327. css: function( elem, name, extra, styles ) {
  5328. var val, num, hooks,
  5329. origName = jQuery.camelCase( name );
  5330. // Make sure that we're working with the right name
  5331. name = jQuery.cssProps[ origName ] || ( jQuery.cssProps[ origName ] = vendorPropName( elem.style, origName ) );
  5332. // gets hook for the prefixed version
  5333. // followed by the unprefixed version
  5334. hooks = jQuery.cssHooks[ name ] || jQuery.cssHooks[ origName ];
  5335. // If a hook was provided get the computed value from there
  5336. if ( hooks && "get" in hooks ) {
  5337. val = hooks.get( elem, true, extra );
  5338. }
  5339. // Otherwise, if a way to get the computed value exists, use that
  5340. if ( val === undefined ) {
  5341. val = curCSS( elem, name, styles );
  5342. }
  5343. //convert "normal" to computed value
  5344. if ( val === "normal" && name in cssNormalTransform ) {
  5345. val = cssNormalTransform[ name ];
  5346. }
  5347. // Return, converting to number if forced or a qualifier was provided and val looks numeric
  5348. if ( extra === "" || extra ) {
  5349. num = parseFloat( val );
  5350. return extra === true || jQuery.isNumeric( num ) ? num || 0 : val;
  5351. }
  5352. return val;
  5353. }
  5354. });
  5355. jQuery.each([ "height", "width" ], function( i, name ) {
  5356. jQuery.cssHooks[ name ] = {
  5357. get: function( elem, computed, extra ) {
  5358. if ( computed ) {
  5359. // certain elements can have dimension info if we invisibly show them
  5360. // however, it must have a current display style that would benefit from this
  5361. return elem.offsetWidth === 0 && rdisplayswap.test( jQuery.css( elem, "display" ) ) ?
  5362. jQuery.swap( elem, cssShow, function() {
  5363. return getWidthOrHeight( elem, name, extra );
  5364. }) :
  5365. getWidthOrHeight( elem, name, extra );
  5366. }
  5367. },
  5368. set: function( elem, value, extra ) {
  5369. var styles = extra && getStyles( elem );
  5370. return setPositiveNumber( elem, value, extra ?
  5371. augmentWidthOrHeight(
  5372. elem,
  5373. name,
  5374. extra,
  5375. jQuery.css( elem, "boxSizing", false, styles ) === "border-box",
  5376. styles
  5377. ) : 0
  5378. );
  5379. }
  5380. };
  5381. });
  5382. // Support: Android 2.3
  5383. jQuery.cssHooks.marginRight = addGetHookIf( support.reliableMarginRight,
  5384. function( elem, computed ) {
  5385. if ( computed ) {
  5386. // WebKit Bug 13343 - getComputedStyle returns wrong value for margin-right
  5387. // Work around by temporarily setting element display to inline-block
  5388. return jQuery.swap( elem, { "display": "inline-block" },
  5389. curCSS, [ elem, "marginRight" ] );
  5390. }
  5391. }
  5392. );
  5393. // These hooks are used by animate to expand properties
  5394. jQuery.each({
  5395. margin: "",
  5396. padding: "",
  5397. border: "Width"
  5398. }, function( prefix, suffix ) {
  5399. jQuery.cssHooks[ prefix + suffix ] = {
  5400. expand: function( value ) {
  5401. var i = 0,
  5402. expanded = {},
  5403. // assumes a single number if not a string
  5404. parts = typeof value === "string" ? value.split(" ") : [ value ];
  5405. for ( ; i < 4; i++ ) {
  5406. expanded[ prefix + cssExpand[ i ] + suffix ] =
  5407. parts[ i ] || parts[ i - 2 ] || parts[ 0 ];
  5408. }
  5409. return expanded;
  5410. }
  5411. };
  5412. if ( !rmargin.test( prefix ) ) {
  5413. jQuery.cssHooks[ prefix + suffix ].set = setPositiveNumber;
  5414. }
  5415. });
  5416. jQuery.fn.extend({
  5417. css: function( name, value ) {
  5418. return access( this, function( elem, name, value ) {
  5419. var styles, len,
  5420. map = {},
  5421. i = 0;
  5422. if ( jQuery.isArray( name ) ) {
  5423. styles = getStyles( elem );
  5424. len = name.length;
  5425. for ( ; i < len; i++ ) {
  5426. map[ name[ i ] ] = jQuery.css( elem, name[ i ], false, styles );
  5427. }
  5428. return map;
  5429. }
  5430. return value !== undefined ?
  5431. jQuery.style( elem, name, value ) :
  5432. jQuery.css( elem, name );
  5433. }, name, value, arguments.length > 1 );
  5434. },
  5435. show: function() {
  5436. return showHide( this, true );
  5437. },
  5438. hide: function() {
  5439. return showHide( this );
  5440. },
  5441. toggle: function( state ) {
  5442. if ( typeof state === "boolean" ) {
  5443. return state ? this.show() : this.hide();
  5444. }
  5445. return this.each(function() {
  5446. if ( isHidden( this ) ) {
  5447. jQuery( this ).show();
  5448. } else {
  5449. jQuery( this ).hide();
  5450. }
  5451. });
  5452. }
  5453. });
  5454. function Tween( elem, options, prop, end, easing ) {
  5455. return new Tween.prototype.init( elem, options, prop, end, easing );
  5456. }
  5457. jQuery.Tween = Tween;
  5458. Tween.prototype = {
  5459. constructor: Tween,
  5460. init: function( elem, options, prop, end, easing, unit ) {
  5461. this.elem = elem;
  5462. this.prop = prop;
  5463. this.easing = easing || "swing";
  5464. this.options = options;
  5465. this.start = this.now = this.cur();
  5466. this.end = end;
  5467. this.unit = unit || ( jQuery.cssNumber[ prop ] ? "" : "px" );
  5468. },
  5469. cur: function() {
  5470. var hooks = Tween.propHooks[ this.prop ];
  5471. return hooks && hooks.get ?
  5472. hooks.get( this ) :
  5473. Tween.propHooks._default.get( this );
  5474. },
  5475. run: function( percent ) {
  5476. var eased,
  5477. hooks = Tween.propHooks[ this.prop ];
  5478. if ( this.options.duration ) {
  5479. this.pos = eased = jQuery.easing[ this.easing ](
  5480. percent, this.options.duration * percent, 0, 1, this.options.duration
  5481. );
  5482. } else {
  5483. this.pos = eased = percent;
  5484. }
  5485. this.now = ( this.end - this.start ) * eased + this.start;
  5486. if ( this.options.step ) {
  5487. this.options.step.call( this.elem, this.now, this );
  5488. }
  5489. if ( hooks && hooks.set ) {
  5490. hooks.set( this );
  5491. } else {
  5492. Tween.propHooks._default.set( this );
  5493. }
  5494. return this;
  5495. }
  5496. };
  5497. Tween.prototype.init.prototype = Tween.prototype;
  5498. Tween.propHooks = {
  5499. _default: {
  5500. get: function( tween ) {
  5501. var result;
  5502. if ( tween.elem[ tween.prop ] != null &&
  5503. (!tween.elem.style || tween.elem.style[ tween.prop ] == null) ) {
  5504. return tween.elem[ tween.prop ];
  5505. }
  5506. // passing an empty string as a 3rd parameter to .css will automatically
  5507. // attempt a parseFloat and fallback to a string if the parse fails
  5508. // so, simple values such as "10px" are parsed to Float.
  5509. // complex values such as "rotate(1rad)" are returned as is.
  5510. result = jQuery.css( tween.elem, tween.prop, "" );
  5511. // Empty strings, null, undefined and "auto" are converted to 0.
  5512. return !result || result === "auto" ? 0 : result;
  5513. },
  5514. set: function( tween ) {
  5515. // use step hook for back compat - use cssHook if its there - use .style if its
  5516. // available and use plain properties where available
  5517. if ( jQuery.fx.step[ tween.prop ] ) {
  5518. jQuery.fx.step[ tween.prop ]( tween );
  5519. } else if ( tween.elem.style && ( tween.elem.style[ jQuery.cssProps[ tween.prop ] ] != null || jQuery.cssHooks[ tween.prop ] ) ) {
  5520. jQuery.style( tween.elem, tween.prop, tween.now + tween.unit );
  5521. } else {
  5522. tween.elem[ tween.prop ] = tween.now;
  5523. }
  5524. }
  5525. }
  5526. };
  5527. // Support: IE9
  5528. // Panic based approach to setting things on disconnected nodes
  5529. Tween.propHooks.scrollTop = Tween.propHooks.scrollLeft = {
  5530. set: function( tween ) {
  5531. if ( tween.elem.nodeType && tween.elem.parentNode ) {
  5532. tween.elem[ tween.prop ] = tween.now;
  5533. }
  5534. }
  5535. };
  5536. jQuery.easing = {
  5537. linear: function( p ) {
  5538. return p;
  5539. },
  5540. swing: function( p ) {
  5541. return 0.5 - Math.cos( p * Math.PI ) / 2;
  5542. }
  5543. };
  5544. jQuery.fx = Tween.prototype.init;
  5545. // Back Compat <1.8 extension point
  5546. jQuery.fx.step = {};
  5547. var
  5548. fxNow, timerId,
  5549. rfxtypes = /^(?:toggle|show|hide)$/,
  5550. rfxnum = new RegExp( "^(?:([+-])=|)(" + pnum + ")([a-z%]*)$", "i" ),
  5551. rrun = /queueHooks$/,
  5552. animationPrefilters = [ defaultPrefilter ],
  5553. tweeners = {
  5554. "*": [ function( prop, value ) {
  5555. var tween = this.createTween( prop, value ),
  5556. target = tween.cur(),
  5557. parts = rfxnum.exec( value ),
  5558. unit = parts && parts[ 3 ] || ( jQuery.cssNumber[ prop ] ? "" : "px" ),
  5559. // Starting value computation is required for potential unit mismatches
  5560. start = ( jQuery.cssNumber[ prop ] || unit !== "px" && +target ) &&
  5561. rfxnum.exec( jQuery.css( tween.elem, prop ) ),
  5562. scale = 1,
  5563. maxIterations = 20;
  5564. if ( start && start[ 3 ] !== unit ) {
  5565. // Trust units reported by jQuery.css
  5566. unit = unit || start[ 3 ];
  5567. // Make sure we update the tween properties later on
  5568. parts = parts || [];
  5569. // Iteratively approximate from a nonzero starting point
  5570. start = +target || 1;
  5571. do {
  5572. // If previous iteration zeroed out, double until we get *something*
  5573. // Use a string for doubling factor so we don't accidentally see scale as unchanged below
  5574. scale = scale || ".5";
  5575. // Adjust and apply
  5576. start = start / scale;
  5577. jQuery.style( tween.elem, prop, start + unit );
  5578. // Update scale, tolerating zero or NaN from tween.cur()
  5579. // And breaking the loop if scale is unchanged or perfect, or if we've just had enough
  5580. } while ( scale !== (scale = tween.cur() / target) && scale !== 1 && --maxIterations );
  5581. }
  5582. // Update tween properties
  5583. if ( parts ) {
  5584. start = tween.start = +start || +target || 0;
  5585. tween.unit = unit;
  5586. // If a +=/-= token was provided, we're doing a relative animation
  5587. tween.end = parts[ 1 ] ?
  5588. start + ( parts[ 1 ] + 1 ) * parts[ 2 ] :
  5589. +parts[ 2 ];
  5590. }
  5591. return tween;
  5592. } ]
  5593. };
  5594. // Animations created synchronously will run synchronously
  5595. function createFxNow() {
  5596. setTimeout(function() {
  5597. fxNow = undefined;
  5598. });
  5599. return ( fxNow = jQuery.now() );
  5600. }
  5601. // Generate parameters to create a standard animation
  5602. function genFx( type, includeWidth ) {
  5603. var which,
  5604. i = 0,
  5605. attrs = { height: type };
  5606. // if we include width, step value is 1 to do all cssExpand values,
  5607. // if we don't include width, step value is 2 to skip over Left and Right
  5608. includeWidth = includeWidth ? 1 : 0;
  5609. for ( ; i < 4 ; i += 2 - includeWidth ) {
  5610. which = cssExpand[ i ];
  5611. attrs[ "margin" + which ] = attrs[ "padding" + which ] = type;
  5612. }
  5613. if ( includeWidth ) {
  5614. attrs.opacity = attrs.width = type;
  5615. }
  5616. return attrs;
  5617. }
  5618. function createTween( value, prop, animation ) {
  5619. var tween,
  5620. collection = ( tweeners[ prop ] || [] ).concat( tweeners[ "*" ] ),
  5621. index = 0,
  5622. length = collection.length;
  5623. for ( ; index < length; index++ ) {
  5624. if ( (tween = collection[ index ].call( animation, prop, value )) ) {
  5625. // we're done with this property
  5626. return tween;
  5627. }
  5628. }
  5629. }
  5630. function defaultPrefilter( elem, props, opts ) {
  5631. /* jshint validthis: true */
  5632. var prop, value, toggle, tween, hooks, oldfire, display,
  5633. anim = this,
  5634. orig = {},
  5635. style = elem.style,
  5636. hidden = elem.nodeType && isHidden( elem ),
  5637. dataShow = data_priv.get( elem, "fxshow" );
  5638. // handle queue: false promises
  5639. if ( !opts.queue ) {
  5640. hooks = jQuery._queueHooks( elem, "fx" );
  5641. if ( hooks.unqueued == null ) {
  5642. hooks.unqueued = 0;
  5643. oldfire = hooks.empty.fire;
  5644. hooks.empty.fire = function() {
  5645. if ( !hooks.unqueued ) {
  5646. oldfire();
  5647. }
  5648. };
  5649. }
  5650. hooks.unqueued++;
  5651. anim.always(function() {
  5652. // doing this makes sure that the complete handler will be called
  5653. // before this completes
  5654. anim.always(function() {
  5655. hooks.unqueued--;
  5656. if ( !jQuery.queue( elem, "fx" ).length ) {
  5657. hooks.empty.fire();
  5658. }
  5659. });
  5660. });
  5661. }
  5662. // height/width overflow pass
  5663. if ( elem.nodeType === 1 && ( "height" in props || "width" in props ) ) {
  5664. // Make sure that nothing sneaks out
  5665. // Record all 3 overflow attributes because IE9-10 do not
  5666. // change the overflow attribute when overflowX and
  5667. // overflowY are set to the same value
  5668. opts.overflow = [ style.overflow, style.overflowX, style.overflowY ];
  5669. // Set display property to inline-block for height/width
  5670. // animations on inline elements that are having width/height animated
  5671. display = jQuery.css( elem, "display" );
  5672. // Get default display if display is currently "none"
  5673. if ( display === "none" ) {
  5674. display = defaultDisplay( elem.nodeName );
  5675. }
  5676. if ( display === "inline" &&
  5677. jQuery.css( elem, "float" ) === "none" ) {
  5678. style.display = "inline-block";
  5679. }
  5680. }
  5681. if ( opts.overflow ) {
  5682. style.overflow = "hidden";
  5683. anim.always(function() {
  5684. style.overflow = opts.overflow[ 0 ];
  5685. style.overflowX = opts.overflow[ 1 ];
  5686. style.overflowY = opts.overflow[ 2 ];
  5687. });
  5688. }
  5689. // show/hide pass
  5690. for ( prop in props ) {
  5691. value = props[ prop ];
  5692. if ( rfxtypes.exec( value ) ) {
  5693. delete props[ prop ];
  5694. toggle = toggle || value === "toggle";
  5695. if ( value === ( hidden ? "hide" : "show" ) ) {
  5696. // If there is dataShow left over from a stopped hide or show and we are going to proceed with show, we should pretend to be hidden
  5697. if ( value === "show" && dataShow && dataShow[ prop ] !== undefined ) {
  5698. hidden = true;
  5699. } else {
  5700. continue;
  5701. }
  5702. }
  5703. orig[ prop ] = dataShow && dataShow[ prop ] || jQuery.style( elem, prop );
  5704. }
  5705. }
  5706. if ( !jQuery.isEmptyObject( orig ) ) {
  5707. if ( dataShow ) {
  5708. if ( "hidden" in dataShow ) {
  5709. hidden = dataShow.hidden;
  5710. }
  5711. } else {
  5712. dataShow = data_priv.access( elem, "fxshow", {} );
  5713. }
  5714. // store state if its toggle - enables .stop().toggle() to "reverse"
  5715. if ( toggle ) {
  5716. dataShow.hidden = !hidden;
  5717. }
  5718. if ( hidden ) {
  5719. jQuery( elem ).show();
  5720. } else {
  5721. anim.done(function() {
  5722. jQuery( elem ).hide();
  5723. });
  5724. }
  5725. anim.done(function() {
  5726. var prop;
  5727. data_priv.remove( elem, "fxshow" );
  5728. for ( prop in orig ) {
  5729. jQuery.style( elem, prop, orig[ prop ] );
  5730. }
  5731. });
  5732. for ( prop in orig ) {
  5733. tween = createTween( hidden ? dataShow[ prop ] : 0, prop, anim );
  5734. if ( !( prop in dataShow ) ) {
  5735. dataShow[ prop ] = tween.start;
  5736. if ( hidden ) {
  5737. tween.end = tween.start;
  5738. tween.start = prop === "width" || prop === "height" ? 1 : 0;
  5739. }
  5740. }
  5741. }
  5742. }
  5743. }
  5744. function propFilter( props, specialEasing ) {
  5745. var index, name, easing, value, hooks;
  5746. // camelCase, specialEasing and expand cssHook pass
  5747. for ( index in props ) {
  5748. name = jQuery.camelCase( index );
  5749. easing = specialEasing[ name ];
  5750. value = props[ index ];
  5751. if ( jQuery.isArray( value ) ) {
  5752. easing = value[ 1 ];
  5753. value = props[ index ] = value[ 0 ];
  5754. }
  5755. if ( index !== name ) {
  5756. props[ name ] = value;
  5757. delete props[ index ];
  5758. }
  5759. hooks = jQuery.cssHooks[ name ];
  5760. if ( hooks && "expand" in hooks ) {
  5761. value = hooks.expand( value );
  5762. delete props[ name ];
  5763. // not quite $.extend, this wont overwrite keys already present.
  5764. // also - reusing 'index' from above because we have the correct "name"
  5765. for ( index in value ) {
  5766. if ( !( index in props ) ) {
  5767. props[ index ] = value[ index ];
  5768. specialEasing[ index ] = easing;
  5769. }
  5770. }
  5771. } else {
  5772. specialEasing[ name ] = easing;
  5773. }
  5774. }
  5775. }
  5776. function Animation( elem, properties, options ) {
  5777. var result,
  5778. stopped,
  5779. index = 0,
  5780. length = animationPrefilters.length,
  5781. deferred = jQuery.Deferred().always( function() {
  5782. // don't match elem in the :animated selector
  5783. delete tick.elem;
  5784. }),
  5785. tick = function() {
  5786. if ( stopped ) {
  5787. return false;
  5788. }
  5789. var currentTime = fxNow || createFxNow(),
  5790. remaining = Math.max( 0, animation.startTime + animation.duration - currentTime ),
  5791. // archaic crash bug won't allow us to use 1 - ( 0.5 || 0 ) (#12497)
  5792. temp = remaining / animation.duration || 0,
  5793. percent = 1 - temp,
  5794. index = 0,
  5795. length = animation.tweens.length;
  5796. for ( ; index < length ; index++ ) {
  5797. animation.tweens[ index ].run( percent );
  5798. }
  5799. deferred.notifyWith( elem, [ animation, percent, remaining ]);
  5800. if ( percent < 1 && length ) {
  5801. return remaining;
  5802. } else {
  5803. deferred.resolveWith( elem, [ animation ] );
  5804. return false;
  5805. }
  5806. },
  5807. animation = deferred.promise({
  5808. elem: elem,
  5809. props: jQuery.extend( {}, properties ),
  5810. opts: jQuery.extend( true, { specialEasing: {} }, options ),
  5811. originalProperties: properties,
  5812. originalOptions: options,
  5813. startTime: fxNow || createFxNow(),
  5814. duration: options.duration,
  5815. tweens: [],
  5816. createTween: function( prop, end ) {
  5817. var tween = jQuery.Tween( elem, animation.opts, prop, end,
  5818. animation.opts.specialEasing[ prop ] || animation.opts.easing );
  5819. animation.tweens.push( tween );
  5820. return tween;
  5821. },
  5822. stop: function( gotoEnd ) {
  5823. var index = 0,
  5824. // if we are going to the end, we want to run all the tweens
  5825. // otherwise we skip this part
  5826. length = gotoEnd ? animation.tweens.length : 0;
  5827. if ( stopped ) {
  5828. return this;
  5829. }
  5830. stopped = true;
  5831. for ( ; index < length ; index++ ) {
  5832. animation.tweens[ index ].run( 1 );
  5833. }
  5834. // resolve when we played the last frame
  5835. // otherwise, reject
  5836. if ( gotoEnd ) {
  5837. deferred.resolveWith( elem, [ animation, gotoEnd ] );
  5838. } else {
  5839. deferred.rejectWith( elem, [ animation, gotoEnd ] );
  5840. }
  5841. return this;
  5842. }
  5843. }),
  5844. props = animation.props;
  5845. propFilter( props, animation.opts.specialEasing );
  5846. for ( ; index < length ; index++ ) {
  5847. result = animationPrefilters[ index ].call( animation, elem, props, animation.opts );
  5848. if ( result ) {
  5849. return result;
  5850. }
  5851. }
  5852. jQuery.map( props, createTween, animation );
  5853. if ( jQuery.isFunction( animation.opts.start ) ) {
  5854. animation.opts.start.call( elem, animation );
  5855. }
  5856. jQuery.fx.timer(
  5857. jQuery.extend( tick, {
  5858. elem: elem,
  5859. anim: animation,
  5860. queue: animation.opts.queue
  5861. })
  5862. );
  5863. // attach callbacks from options
  5864. return animation.progress( animation.opts.progress )
  5865. .done( animation.opts.done, animation.opts.complete )
  5866. .fail( animation.opts.fail )
  5867. .always( animation.opts.always );
  5868. }
  5869. jQuery.Animation = jQuery.extend( Animation, {
  5870. tweener: function( props, callback ) {
  5871. if ( jQuery.isFunction( props ) ) {
  5872. callback = props;
  5873. props = [ "*" ];
  5874. } else {
  5875. props = props.split(" ");
  5876. }
  5877. var prop,
  5878. index = 0,
  5879. length = props.length;
  5880. for ( ; index < length ; index++ ) {
  5881. prop = props[ index ];
  5882. tweeners[ prop ] = tweeners[ prop ] || [];
  5883. tweeners[ prop ].unshift( callback );
  5884. }
  5885. },
  5886. prefilter: function( callback, prepend ) {
  5887. if ( prepend ) {
  5888. animationPrefilters.unshift( callback );
  5889. } else {
  5890. animationPrefilters.push( callback );
  5891. }
  5892. }
  5893. });
  5894. jQuery.speed = function( speed, easing, fn ) {
  5895. var opt = speed && typeof speed === "object" ? jQuery.extend( {}, speed ) : {
  5896. complete: fn || !fn && easing ||
  5897. jQuery.isFunction( speed ) && speed,
  5898. duration: speed,
  5899. easing: fn && easing || easing && !jQuery.isFunction( easing ) && easing
  5900. };
  5901. opt.duration = jQuery.fx.off ? 0 : typeof opt.duration === "number" ? opt.duration :
  5902. opt.duration in jQuery.fx.speeds ? jQuery.fx.speeds[ opt.duration ] : jQuery.fx.speeds._default;
  5903. // normalize opt.queue - true/undefined/null -> "fx"
  5904. if ( opt.queue == null || opt.queue === true ) {
  5905. opt.queue = "fx";
  5906. }
  5907. // Queueing
  5908. opt.old = opt.complete;
  5909. opt.complete = function() {
  5910. if ( jQuery.isFunction( opt.old ) ) {
  5911. opt.old.call( this );
  5912. }
  5913. if ( opt.queue ) {
  5914. jQuery.dequeue( this, opt.queue );
  5915. }
  5916. };
  5917. return opt;
  5918. };
  5919. jQuery.fn.extend({
  5920. fadeTo: function( speed, to, easing, callback ) {
  5921. // show any hidden elements after setting opacity to 0
  5922. return this.filter( isHidden ).css( "opacity", 0 ).show()
  5923. // animate to the value specified
  5924. .end().animate({ opacity: to }, speed, easing, callback );
  5925. },
  5926. animate: function( prop, speed, easing, callback ) {
  5927. var empty = jQuery.isEmptyObject( prop ),
  5928. optall = jQuery.speed( speed, easing, callback ),
  5929. doAnimation = function() {
  5930. // Operate on a copy of prop so per-property easing won't be lost
  5931. var anim = Animation( this, jQuery.extend( {}, prop ), optall );
  5932. // Empty animations, or finishing resolves immediately
  5933. if ( empty || data_priv.get( this, "finish" ) ) {
  5934. anim.stop( true );
  5935. }
  5936. };
  5937. doAnimation.finish = doAnimation;
  5938. return empty || optall.queue === false ?
  5939. this.each( doAnimation ) :
  5940. this.queue( optall.queue, doAnimation );
  5941. },
  5942. stop: function( type, clearQueue, gotoEnd ) {
  5943. var stopQueue = function( hooks ) {
  5944. var stop = hooks.stop;
  5945. delete hooks.stop;
  5946. stop( gotoEnd );
  5947. };
  5948. if ( typeof type !== "string" ) {
  5949. gotoEnd = clearQueue;
  5950. clearQueue = type;
  5951. type = undefined;
  5952. }
  5953. if ( clearQueue && type !== false ) {
  5954. this.queue( type || "fx", [] );
  5955. }
  5956. return this.each(function() {
  5957. var dequeue = true,
  5958. index = type != null && type + "queueHooks",
  5959. timers = jQuery.timers,
  5960. data = data_priv.get( this );
  5961. if ( index ) {
  5962. if ( data[ index ] && data[ index ].stop ) {
  5963. stopQueue( data[ index ] );
  5964. }
  5965. } else {
  5966. for ( index in data ) {
  5967. if ( data[ index ] && data[ index ].stop && rrun.test( index ) ) {
  5968. stopQueue( data[ index ] );
  5969. }
  5970. }
  5971. }
  5972. for ( index = timers.length; index--; ) {
  5973. if ( timers[ index ].elem === this && (type == null || timers[ index ].queue === type) ) {
  5974. timers[ index ].anim.stop( gotoEnd );
  5975. dequeue = false;
  5976. timers.splice( index, 1 );
  5977. }
  5978. }
  5979. // start the next in the queue if the last step wasn't forced
  5980. // timers currently will call their complete callbacks, which will dequeue
  5981. // but only if they were gotoEnd
  5982. if ( dequeue || !gotoEnd ) {
  5983. jQuery.dequeue( this, type );
  5984. }
  5985. });
  5986. },
  5987. finish: function( type ) {
  5988. if ( type !== false ) {
  5989. type = type || "fx";
  5990. }
  5991. return this.each(function() {
  5992. var index,
  5993. data = data_priv.get( this ),
  5994. queue = data[ type + "queue" ],
  5995. hooks = data[ type + "queueHooks" ],
  5996. timers = jQuery.timers,
  5997. length = queue ? queue.length : 0;
  5998. // enable finishing flag on private data
  5999. data.finish = true;
  6000. // empty the queue first
  6001. jQuery.queue( this, type, [] );
  6002. if ( hooks && hooks.stop ) {
  6003. hooks.stop.call( this, true );
  6004. }
  6005. // look for any active animations, and finish them
  6006. for ( index = timers.length; index--; ) {
  6007. if ( timers[ index ].elem === this && timers[ index ].queue === type ) {
  6008. timers[ index ].anim.stop( true );
  6009. timers.splice( index, 1 );
  6010. }
  6011. }
  6012. // look for any animations in the old queue and finish them
  6013. for ( index = 0; index < length; index++ ) {
  6014. if ( queue[ index ] && queue[ index ].finish ) {
  6015. queue[ index ].finish.call( this );
  6016. }
  6017. }
  6018. // turn off finishing flag
  6019. delete data.finish;
  6020. });
  6021. }
  6022. });
  6023. jQuery.each([ "toggle", "show", "hide" ], function( i, name ) {
  6024. var cssFn = jQuery.fn[ name ];
  6025. jQuery.fn[ name ] = function( speed, easing, callback ) {
  6026. return speed == null || typeof speed === "boolean" ?
  6027. cssFn.apply( this, arguments ) :
  6028. this.animate( genFx( name, true ), speed, easing, callback );
  6029. };
  6030. });
  6031. // Generate shortcuts for custom animations
  6032. jQuery.each({
  6033. slideDown: genFx("show"),
  6034. slideUp: genFx("hide"),
  6035. slideToggle: genFx("toggle"),
  6036. fadeIn: { opacity: "show" },
  6037. fadeOut: { opacity: "hide" },
  6038. fadeToggle: { opacity: "toggle" }
  6039. }, function( name, props ) {
  6040. jQuery.fn[ name ] = function( speed, easing, callback ) {
  6041. return this.animate( props, speed, easing, callback );
  6042. };
  6043. });
  6044. jQuery.timers = [];
  6045. jQuery.fx.tick = function() {
  6046. var timer,
  6047. i = 0,
  6048. timers = jQuery.timers;
  6049. fxNow = jQuery.now();
  6050. for ( ; i < timers.length; i++ ) {
  6051. timer = timers[ i ];
  6052. // Checks the timer has not already been removed
  6053. if ( !timer() && timers[ i ] === timer ) {
  6054. timers.splice( i--, 1 );
  6055. }
  6056. }
  6057. if ( !timers.length ) {
  6058. jQuery.fx.stop();
  6059. }
  6060. fxNow = undefined;
  6061. };
  6062. jQuery.fx.timer = function( timer ) {
  6063. jQuery.timers.push( timer );
  6064. if ( timer() ) {
  6065. jQuery.fx.start();
  6066. } else {
  6067. jQuery.timers.pop();
  6068. }
  6069. };
  6070. jQuery.fx.interval = 13;
  6071. jQuery.fx.start = function() {
  6072. if ( !timerId ) {
  6073. timerId = setInterval( jQuery.fx.tick, jQuery.fx.interval );
  6074. }
  6075. };
  6076. jQuery.fx.stop = function() {
  6077. clearInterval( timerId );
  6078. timerId = null;
  6079. };
  6080. jQuery.fx.speeds = {
  6081. slow: 600,
  6082. fast: 200,
  6083. // Default speed
  6084. _default: 400
  6085. };
  6086. // Based off of the plugin by Clint Helfers, with permission.
  6087. // http://blindsignals.com/index.php/2009/07/jquery-delay/
  6088. jQuery.fn.delay = function( time, type ) {
  6089. time = jQuery.fx ? jQuery.fx.speeds[ time ] || time : time;
  6090. type = type || "fx";
  6091. return this.queue( type, function( next, hooks ) {
  6092. var timeout = setTimeout( next, time );
  6093. hooks.stop = function() {
  6094. clearTimeout( timeout );
  6095. };
  6096. });
  6097. };
  6098. (function() {
  6099. var input = document.createElement( "input" ),
  6100. select = document.createElement( "select" ),
  6101. opt = select.appendChild( document.createElement( "option" ) );
  6102. input.type = "checkbox";
  6103. // Support: iOS 5.1, Android 4.x, Android 2.3
  6104. // Check the default checkbox/radio value ("" on old WebKit; "on" elsewhere)
  6105. support.checkOn = input.value !== "";
  6106. // Must access the parent to make an option select properly
  6107. // Support: IE9, IE10
  6108. support.optSelected = opt.selected;
  6109. // Make sure that the options inside disabled selects aren't marked as disabled
  6110. // (WebKit marks them as disabled)
  6111. select.disabled = true;
  6112. support.optDisabled = !opt.disabled;
  6113. // Check if an input maintains its value after becoming a radio
  6114. // Support: IE9, IE10
  6115. input = document.createElement( "input" );
  6116. input.value = "t";
  6117. input.type = "radio";
  6118. support.radioValue = input.value === "t";
  6119. })();
  6120. var nodeHook, boolHook,
  6121. attrHandle = jQuery.expr.attrHandle;
  6122. jQuery.fn.extend({
  6123. attr: function( name, value ) {
  6124. return access( this, jQuery.attr, name, value, arguments.length > 1 );
  6125. },
  6126. removeAttr: function( name ) {
  6127. return this.each(function() {
  6128. jQuery.removeAttr( this, name );
  6129. });
  6130. }
  6131. });
  6132. jQuery.extend({
  6133. attr: function( elem, name, value ) {
  6134. var hooks, ret,
  6135. nType = elem.nodeType;
  6136. // don't get/set attributes on text, comment and attribute nodes
  6137. if ( !elem || nType === 3 || nType === 8 || nType === 2 ) {
  6138. return;
  6139. }
  6140. // Fallback to prop when attributes are not supported
  6141. if ( typeof elem.getAttribute === strundefined ) {
  6142. return jQuery.prop( elem, name, value );
  6143. }
  6144. // All attributes are lowercase
  6145. // Grab necessary hook if one is defined
  6146. if ( nType !== 1 || !jQuery.isXMLDoc( elem ) ) {
  6147. name = name.toLowerCase();
  6148. hooks = jQuery.attrHooks[ name ] ||
  6149. ( jQuery.expr.match.bool.test( name ) ? boolHook : nodeHook );
  6150. }
  6151. if ( value !== undefined ) {
  6152. if ( value === null ) {
  6153. jQuery.removeAttr( elem, name );
  6154. } else if ( hooks && "set" in hooks && (ret = hooks.set( elem, value, name )) !== undefined ) {
  6155. return ret;
  6156. } else {
  6157. elem.setAttribute( name, value + "" );
  6158. return value;
  6159. }
  6160. } else if ( hooks && "get" in hooks && (ret = hooks.get( elem, name )) !== null ) {
  6161. return ret;
  6162. } else {
  6163. ret = jQuery.find.attr( elem, name );
  6164. // Non-existent attributes return null, we normalize to undefined
  6165. return ret == null ?
  6166. undefined :
  6167. ret;
  6168. }
  6169. },
  6170. removeAttr: function( elem, value ) {
  6171. var name, propName,
  6172. i = 0,
  6173. attrNames = value && value.match( rnotwhite );
  6174. if ( attrNames && elem.nodeType === 1 ) {
  6175. while ( (name = attrNames[i++]) ) {
  6176. propName = jQuery.propFix[ name ] || name;
  6177. // Boolean attributes get special treatment (#10870)
  6178. if ( jQuery.expr.match.bool.test( name ) ) {
  6179. // Set corresponding property to false
  6180. elem[ propName ] = false;
  6181. }
  6182. elem.removeAttribute( name );
  6183. }
  6184. }
  6185. },
  6186. attrHooks: {
  6187. type: {
  6188. set: function( elem, value ) {
  6189. if ( !support.radioValue && value === "radio" &&
  6190. jQuery.nodeName( elem, "input" ) ) {
  6191. // Setting the type on a radio button after the value resets the value in IE6-9
  6192. // Reset value to default in case type is set after value during creation
  6193. var val = elem.value;
  6194. elem.setAttribute( "type", value );
  6195. if ( val ) {
  6196. elem.value = val;
  6197. }
  6198. return value;
  6199. }
  6200. }
  6201. }
  6202. }
  6203. });
  6204. // Hooks for boolean attributes
  6205. boolHook = {
  6206. set: function( elem, value, name ) {
  6207. if ( value === false ) {
  6208. // Remove boolean attributes when set to false
  6209. jQuery.removeAttr( elem, name );
  6210. } else {
  6211. elem.setAttribute( name, name );
  6212. }
  6213. return name;
  6214. }
  6215. };
  6216. jQuery.each( jQuery.expr.match.bool.source.match( /\w+/g ), function( i, name ) {
  6217. var getter = attrHandle[ name ] || jQuery.find.attr;
  6218. attrHandle[ name ] = function( elem, name, isXML ) {
  6219. var ret, handle;
  6220. if ( !isXML ) {
  6221. // Avoid an infinite loop by temporarily removing this function from the getter
  6222. handle = attrHandle[ name ];
  6223. attrHandle[ name ] = ret;
  6224. ret = getter( elem, name, isXML ) != null ?
  6225. name.toLowerCase() :
  6226. null;
  6227. attrHandle[ name ] = handle;
  6228. }
  6229. return ret;
  6230. };
  6231. });
  6232. var rfocusable = /^(?:input|select|textarea|button)$/i;
  6233. jQuery.fn.extend({
  6234. prop: function( name, value ) {
  6235. return access( this, jQuery.prop, name, value, arguments.length > 1 );
  6236. },
  6237. removeProp: function( name ) {
  6238. return this.each(function() {
  6239. delete this[ jQuery.propFix[ name ] || name ];
  6240. });
  6241. }
  6242. });
  6243. jQuery.extend({
  6244. propFix: {
  6245. "for": "htmlFor",
  6246. "class": "className"
  6247. },
  6248. prop: function( elem, name, value ) {
  6249. var ret, hooks, notxml,
  6250. nType = elem.nodeType;
  6251. // don't get/set properties on text, comment and attribute nodes
  6252. if ( !elem || nType === 3 || nType === 8 || nType === 2 ) {
  6253. return;
  6254. }
  6255. notxml = nType !== 1 || !jQuery.isXMLDoc( elem );
  6256. if ( notxml ) {
  6257. // Fix name and attach hooks
  6258. name = jQuery.propFix[ name ] || name;
  6259. hooks = jQuery.propHooks[ name ];
  6260. }
  6261. if ( value !== undefined ) {
  6262. return hooks && "set" in hooks && (ret = hooks.set( elem, value, name )) !== undefined ?
  6263. ret :
  6264. ( elem[ name ] = value );
  6265. } else {
  6266. return hooks && "get" in hooks && (ret = hooks.get( elem, name )) !== null ?
  6267. ret :
  6268. elem[ name ];
  6269. }
  6270. },
  6271. propHooks: {
  6272. tabIndex: {
  6273. get: function( elem ) {
  6274. return elem.hasAttribute( "tabindex" ) || rfocusable.test( elem.nodeName ) || elem.href ?
  6275. elem.tabIndex :
  6276. -1;
  6277. }
  6278. }
  6279. }
  6280. });
  6281. // Support: IE9+
  6282. // Selectedness for an option in an optgroup can be inaccurate
  6283. if ( !support.optSelected ) {
  6284. jQuery.propHooks.selected = {
  6285. get: function( elem ) {
  6286. var parent = elem.parentNode;
  6287. if ( parent && parent.parentNode ) {
  6288. parent.parentNode.selectedIndex;
  6289. }
  6290. return null;
  6291. }
  6292. };
  6293. }
  6294. jQuery.each([
  6295. "tabIndex",
  6296. "readOnly",
  6297. "maxLength",
  6298. "cellSpacing",
  6299. "cellPadding",
  6300. "rowSpan",
  6301. "colSpan",
  6302. "useMap",
  6303. "frameBorder",
  6304. "contentEditable"
  6305. ], function() {
  6306. jQuery.propFix[ this.toLowerCase() ] = this;
  6307. });
  6308. var rclass = /[\t\r\n\f]/g;
  6309. jQuery.fn.extend({
  6310. addClass: function( value ) {
  6311. var classes, elem, cur, clazz, j, finalValue,
  6312. proceed = typeof value === "string" && value,
  6313. i = 0,
  6314. len = this.length;
  6315. if ( jQuery.isFunction( value ) ) {
  6316. return this.each(function( j ) {
  6317. jQuery( this ).addClass( value.call( this, j, this.className ) );
  6318. });
  6319. }
  6320. if ( proceed ) {
  6321. // The disjunction here is for better compressibility (see removeClass)
  6322. classes = ( value || "" ).match( rnotwhite ) || [];
  6323. for ( ; i < len; i++ ) {
  6324. elem = this[ i ];
  6325. cur = elem.nodeType === 1 && ( elem.className ?
  6326. ( " " + elem.className + " " ).replace( rclass, " " ) :
  6327. " "
  6328. );
  6329. if ( cur ) {
  6330. j = 0;
  6331. while ( (clazz = classes[j++]) ) {
  6332. if ( cur.indexOf( " " + clazz + " " ) < 0 ) {
  6333. cur += clazz + " ";
  6334. }
  6335. }
  6336. // only assign if different to avoid unneeded rendering.
  6337. finalValue = jQuery.trim( cur );
  6338. if ( elem.className !== finalValue ) {
  6339. elem.className = finalValue;
  6340. }
  6341. }
  6342. }
  6343. }
  6344. return this;
  6345. },
  6346. removeClass: function( value ) {
  6347. var classes, elem, cur, clazz, j, finalValue,
  6348. proceed = arguments.length === 0 || typeof value === "string" && value,
  6349. i = 0,
  6350. len = this.length;
  6351. if ( jQuery.isFunction( value ) ) {
  6352. return this.each(function( j ) {
  6353. jQuery( this ).removeClass( value.call( this, j, this.className ) );
  6354. });
  6355. }
  6356. if ( proceed ) {
  6357. classes = ( value || "" ).match( rnotwhite ) || [];
  6358. for ( ; i < len; i++ ) {
  6359. elem = this[ i ];
  6360. // This expression is here for better compressibility (see addClass)
  6361. cur = elem.nodeType === 1 && ( elem.className ?
  6362. ( " " + elem.className + " " ).replace( rclass, " " ) :
  6363. ""
  6364. );
  6365. if ( cur ) {
  6366. j = 0;
  6367. while ( (clazz = classes[j++]) ) {
  6368. // Remove *all* instances
  6369. while ( cur.indexOf( " " + clazz + " " ) >= 0 ) {
  6370. cur = cur.replace( " " + clazz + " ", " " );
  6371. }
  6372. }
  6373. // only assign if different to avoid unneeded rendering.
  6374. finalValue = value ? jQuery.trim( cur ) : "";
  6375. if ( elem.className !== finalValue ) {
  6376. elem.className = finalValue;
  6377. }
  6378. }
  6379. }
  6380. }
  6381. return this;
  6382. },
  6383. toggleClass: function( value, stateVal ) {
  6384. var type = typeof value;
  6385. if ( typeof stateVal === "boolean" && type === "string" ) {
  6386. return stateVal ? this.addClass( value ) : this.removeClass( value );
  6387. }
  6388. if ( jQuery.isFunction( value ) ) {
  6389. return this.each(function( i ) {
  6390. jQuery( this ).toggleClass( value.call(this, i, this.className, stateVal), stateVal );
  6391. });
  6392. }
  6393. return this.each(function() {
  6394. if ( type === "string" ) {
  6395. // toggle individual class names
  6396. var className,
  6397. i = 0,
  6398. self = jQuery( this ),
  6399. classNames = value.match( rnotwhite ) || [];
  6400. while ( (className = classNames[ i++ ]) ) {
  6401. // check each className given, space separated list
  6402. if ( self.hasClass( className ) ) {
  6403. self.removeClass( className );
  6404. } else {
  6405. self.addClass( className );
  6406. }
  6407. }
  6408. // Toggle whole class name
  6409. } else if ( type === strundefined || type === "boolean" ) {
  6410. if ( this.className ) {
  6411. // store className if set
  6412. data_priv.set( this, "__className__", this.className );
  6413. }
  6414. // If the element has a class name or if we're passed "false",
  6415. // then remove the whole classname (if there was one, the above saved it).
  6416. // Otherwise bring back whatever was previously saved (if anything),
  6417. // falling back to the empty string if nothing was stored.
  6418. this.className = this.className || value === false ? "" : data_priv.get( this, "__className__" ) || "";
  6419. }
  6420. });
  6421. },
  6422. hasClass: function( selector ) {
  6423. var className = " " + selector + " ",
  6424. i = 0,
  6425. l = this.length;
  6426. for ( ; i < l; i++ ) {
  6427. if ( this[i].nodeType === 1 && (" " + this[i].className + " ").replace(rclass, " ").indexOf( className ) >= 0 ) {
  6428. return true;
  6429. }
  6430. }
  6431. return false;
  6432. }
  6433. });
  6434. var rreturn = /\r/g;
  6435. jQuery.fn.extend({
  6436. val: function( value ) {
  6437. var hooks, ret, isFunction,
  6438. elem = this[0];
  6439. if ( !arguments.length ) {
  6440. if ( elem ) {
  6441. hooks = jQuery.valHooks[ elem.type ] || jQuery.valHooks[ elem.nodeName.toLowerCase() ];
  6442. if ( hooks && "get" in hooks && (ret = hooks.get( elem, "value" )) !== undefined ) {
  6443. return ret;
  6444. }
  6445. ret = elem.value;
  6446. return typeof ret === "string" ?
  6447. // handle most common string cases
  6448. ret.replace(rreturn, "") :
  6449. // handle cases where value is null/undef or number
  6450. ret == null ? "" : ret;
  6451. }
  6452. return;
  6453. }
  6454. isFunction = jQuery.isFunction( value );
  6455. return this.each(function( i ) {
  6456. var val;
  6457. if ( this.nodeType !== 1 ) {
  6458. return;
  6459. }
  6460. if ( isFunction ) {
  6461. val = value.call( this, i, jQuery( this ).val() );
  6462. } else {
  6463. val = value;
  6464. }
  6465. // Treat null/undefined as ""; convert numbers to string
  6466. if ( val == null ) {
  6467. val = "";
  6468. } else if ( typeof val === "number" ) {
  6469. val += "";
  6470. } else if ( jQuery.isArray( val ) ) {
  6471. val = jQuery.map( val, function( value ) {
  6472. return value == null ? "" : value + "";
  6473. });
  6474. }
  6475. hooks = jQuery.valHooks[ this.type ] || jQuery.valHooks[ this.nodeName.toLowerCase() ];
  6476. // If set returns undefined, fall back to normal setting
  6477. if ( !hooks || !("set" in hooks) || hooks.set( this, val, "value" ) === undefined ) {
  6478. this.value = val;
  6479. }
  6480. });
  6481. }
  6482. });
  6483. jQuery.extend({
  6484. valHooks: {
  6485. select: {
  6486. get: function( elem ) {
  6487. var value, option,
  6488. options = elem.options,
  6489. index = elem.selectedIndex,
  6490. one = elem.type === "select-one" || index < 0,
  6491. values = one ? null : [],
  6492. max = one ? index + 1 : options.length,
  6493. i = index < 0 ?
  6494. max :
  6495. one ? index : 0;
  6496. // Loop through all the selected options
  6497. for ( ; i < max; i++ ) {
  6498. option = options[ i ];
  6499. // IE6-9 doesn't update selected after form reset (#2551)
  6500. if ( ( option.selected || i === index ) &&
  6501. // Don't return options that are disabled or in a disabled optgroup
  6502. ( support.optDisabled ? !option.disabled : option.getAttribute( "disabled" ) === null ) &&
  6503. ( !option.parentNode.disabled || !jQuery.nodeName( option.parentNode, "optgroup" ) ) ) {
  6504. // Get the specific value for the option
  6505. value = jQuery( option ).val();
  6506. // We don't need an array for one selects
  6507. if ( one ) {
  6508. return value;
  6509. }
  6510. // Multi-Selects return an array
  6511. values.push( value );
  6512. }
  6513. }
  6514. return values;
  6515. },
  6516. set: function( elem, value ) {
  6517. var optionSet, option,
  6518. options = elem.options,
  6519. values = jQuery.makeArray( value ),
  6520. i = options.length;
  6521. while ( i-- ) {
  6522. option = options[ i ];
  6523. if ( (option.selected = jQuery.inArray( jQuery(option).val(), values ) >= 0) ) {
  6524. optionSet = true;
  6525. }
  6526. }
  6527. // force browsers to behave consistently when non-matching value is set
  6528. if ( !optionSet ) {
  6529. elem.selectedIndex = -1;
  6530. }
  6531. return values;
  6532. }
  6533. }
  6534. }
  6535. });
  6536. // Radios and checkboxes getter/setter
  6537. jQuery.each([ "radio", "checkbox" ], function() {
  6538. jQuery.valHooks[ this ] = {
  6539. set: function( elem, value ) {
  6540. if ( jQuery.isArray( value ) ) {
  6541. return ( elem.checked = jQuery.inArray( jQuery(elem).val(), value ) >= 0 );
  6542. }
  6543. }
  6544. };
  6545. if ( !support.checkOn ) {
  6546. jQuery.valHooks[ this ].get = function( elem ) {
  6547. // Support: Webkit
  6548. // "" is returned instead of "on" if a value isn't specified
  6549. return elem.getAttribute("value") === null ? "on" : elem.value;
  6550. };
  6551. }
  6552. });
  6553. // Return jQuery for attributes-only inclusion
  6554. jQuery.each( ("blur focus focusin focusout load resize scroll unload click dblclick " +
  6555. "mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave " +
  6556. "change select submit keydown keypress keyup error contextmenu").split(" "), function( i, name ) {
  6557. // Handle event binding
  6558. jQuery.fn[ name ] = function( data, fn ) {
  6559. return arguments.length > 0 ?
  6560. this.on( name, null, data, fn ) :
  6561. this.trigger( name );
  6562. };
  6563. });
  6564. jQuery.fn.extend({
  6565. hover: function( fnOver, fnOut ) {
  6566. return this.mouseenter( fnOver ).mouseleave( fnOut || fnOver );
  6567. },
  6568. bind: function( types, data, fn ) {
  6569. return this.on( types, null, data, fn );
  6570. },
  6571. unbind: function( types, fn ) {
  6572. return this.off( types, null, fn );
  6573. },
  6574. delegate: function( selector, types, data, fn ) {
  6575. return this.on( types, selector, data, fn );
  6576. },
  6577. undelegate: function( selector, types, fn ) {
  6578. // ( namespace ) or ( selector, types [, fn] )
  6579. return arguments.length === 1 ? this.off( selector, "**" ) : this.off( types, selector || "**", fn );
  6580. }
  6581. });
  6582. var nonce = jQuery.now();
  6583. var rquery = (/\?/);
  6584. // Support: Android 2.3
  6585. // Workaround failure to string-cast null input
  6586. jQuery.parseJSON = function( data ) {
  6587. return JSON.parse( data + "" );
  6588. };
  6589. // Cross-browser xml parsing
  6590. jQuery.parseXML = function( data ) {
  6591. var xml, tmp;
  6592. if ( !data || typeof data !== "string" ) {
  6593. return null;
  6594. }
  6595. // Support: IE9
  6596. try {
  6597. tmp = new DOMParser();
  6598. xml = tmp.parseFromString( data, "text/xml" );
  6599. } catch ( e ) {
  6600. xml = undefined;
  6601. }
  6602. if ( !xml || xml.getElementsByTagName( "parsererror" ).length ) {
  6603. jQuery.error( "Invalid XML: " + data );
  6604. }
  6605. return xml;
  6606. };
  6607. var
  6608. // Document location
  6609. ajaxLocParts,
  6610. ajaxLocation,
  6611. rhash = /#.*$/,
  6612. rts = /([?&])_=[^&]*/,
  6613. rheaders = /^(.*?):[ \t]*([^\r\n]*)$/mg,
  6614. // #7653, #8125, #8152: local protocol detection
  6615. rlocalProtocol = /^(?:about|app|app-storage|.+-extension|file|res|widget):$/,
  6616. rnoContent = /^(?:GET|HEAD)$/,
  6617. rprotocol = /^\/\//,
  6618. rurl = /^([\w.+-]+:)(?:\/\/(?:[^\/?#]*@|)([^\/?#:]*)(?::(\d+)|)|)/,
  6619. /* Prefilters
  6620. * 1) They are useful to introduce custom dataTypes (see ajax/jsonp.js for an example)
  6621. * 2) These are called:
  6622. * - BEFORE asking for a transport
  6623. * - AFTER param serialization (s.data is a string if s.processData is true)
  6624. * 3) key is the dataType
  6625. * 4) the catchall symbol "*" can be used
  6626. * 5) execution will start with transport dataType and THEN continue down to "*" if needed
  6627. */
  6628. prefilters = {},
  6629. /* Transports bindings
  6630. * 1) key is the dataType
  6631. * 2) the catchall symbol "*" can be used
  6632. * 3) selection will start with transport dataType and THEN go to "*" if needed
  6633. */
  6634. transports = {},
  6635. // Avoid comment-prolog char sequence (#10098); must appease lint and evade compression
  6636. allTypes = "*/".concat("*");
  6637. // #8138, IE may throw an exception when accessing
  6638. // a field from window.location if document.domain has been set
  6639. try {
  6640. ajaxLocation = location.href;
  6641. } catch( e ) {
  6642. // Use the href attribute of an A element
  6643. // since IE will modify it given document.location
  6644. ajaxLocation = document.createElement( "a" );
  6645. ajaxLocation.href = "";
  6646. ajaxLocation = ajaxLocation.href;
  6647. }
  6648. // Segment location into parts
  6649. ajaxLocParts = rurl.exec( ajaxLocation.toLowerCase() ) || [];
  6650. // Base "constructor" for jQuery.ajaxPrefilter and jQuery.ajaxTransport
  6651. function addToPrefiltersOrTransports( structure ) {
  6652. // dataTypeExpression is optional and defaults to "*"
  6653. return function( dataTypeExpression, func ) {
  6654. if ( typeof dataTypeExpression !== "string" ) {
  6655. func = dataTypeExpression;
  6656. dataTypeExpression = "*";
  6657. }
  6658. var dataType,
  6659. i = 0,
  6660. dataTypes = dataTypeExpression.toLowerCase().match( rnotwhite ) || [];
  6661. if ( jQuery.isFunction( func ) ) {
  6662. // For each dataType in the dataTypeExpression
  6663. while ( (dataType = dataTypes[i++]) ) {
  6664. // Prepend if requested
  6665. if ( dataType[0] === "+" ) {
  6666. dataType = dataType.slice( 1 ) || "*";
  6667. (structure[ dataType ] = structure[ dataType ] || []).unshift( func );
  6668. // Otherwise append
  6669. } else {
  6670. (structure[ dataType ] = structure[ dataType ] || []).push( func );
  6671. }
  6672. }
  6673. }
  6674. };
  6675. }
  6676. // Base inspection function for prefilters and transports
  6677. function inspectPrefiltersOrTransports( structure, options, originalOptions, jqXHR ) {
  6678. var inspected = {},
  6679. seekingTransport = ( structure === transports );
  6680. function inspect( dataType ) {
  6681. var selected;
  6682. inspected[ dataType ] = true;
  6683. jQuery.each( structure[ dataType ] || [], function( _, prefilterOrFactory ) {
  6684. var dataTypeOrTransport = prefilterOrFactory( options, originalOptions, jqXHR );
  6685. if ( typeof dataTypeOrTransport === "string" && !seekingTransport && !inspected[ dataTypeOrTransport ] ) {
  6686. options.dataTypes.unshift( dataTypeOrTransport );
  6687. inspect( dataTypeOrTransport );
  6688. return false;
  6689. } else if ( seekingTransport ) {
  6690. return !( selected = dataTypeOrTransport );
  6691. }
  6692. });
  6693. return selected;
  6694. }
  6695. return inspect( options.dataTypes[ 0 ] ) || !inspected[ "*" ] && inspect( "*" );
  6696. }
  6697. // A special extend for ajax options
  6698. // that takes "flat" options (not to be deep extended)
  6699. // Fixes #9887
  6700. function ajaxExtend( target, src ) {
  6701. var key, deep,
  6702. flatOptions = jQuery.ajaxSettings.flatOptions || {};
  6703. for ( key in src ) {
  6704. if ( src[ key ] !== undefined ) {
  6705. ( flatOptions[ key ] ? target : ( deep || (deep = {}) ) )[ key ] = src[ key ];
  6706. }
  6707. }
  6708. if ( deep ) {
  6709. jQuery.extend( true, target, deep );
  6710. }
  6711. return target;
  6712. }
  6713. /* Handles responses to an ajax request:
  6714. * - finds the right dataType (mediates between content-type and expected dataType)
  6715. * - returns the corresponding response
  6716. */
  6717. function ajaxHandleResponses( s, jqXHR, responses ) {
  6718. var ct, type, finalDataType, firstDataType,
  6719. contents = s.contents,
  6720. dataTypes = s.dataTypes;
  6721. // Remove auto dataType and get content-type in the process
  6722. while ( dataTypes[ 0 ] === "*" ) {
  6723. dataTypes.shift();
  6724. if ( ct === undefined ) {
  6725. ct = s.mimeType || jqXHR.getResponseHeader("Content-Type");
  6726. }
  6727. }
  6728. // Check if we're dealing with a known content-type
  6729. if ( ct ) {
  6730. for ( type in contents ) {
  6731. if ( contents[ type ] && contents[ type ].test( ct ) ) {
  6732. dataTypes.unshift( type );
  6733. break;
  6734. }
  6735. }
  6736. }
  6737. // Check to see if we have a response for the expected dataType
  6738. if ( dataTypes[ 0 ] in responses ) {
  6739. finalDataType = dataTypes[ 0 ];
  6740. } else {
  6741. // Try convertible dataTypes
  6742. for ( type in responses ) {
  6743. if ( !dataTypes[ 0 ] || s.converters[ type + " " + dataTypes[0] ] ) {
  6744. finalDataType = type;
  6745. break;
  6746. }
  6747. if ( !firstDataType ) {
  6748. firstDataType = type;
  6749. }
  6750. }
  6751. // Or just use first one
  6752. finalDataType = finalDataType || firstDataType;
  6753. }
  6754. // If we found a dataType
  6755. // We add the dataType to the list if needed
  6756. // and return the corresponding response
  6757. if ( finalDataType ) {
  6758. if ( finalDataType !== dataTypes[ 0 ] ) {
  6759. dataTypes.unshift( finalDataType );
  6760. }
  6761. return responses[ finalDataType ];
  6762. }
  6763. }
  6764. /* Chain conversions given the request and the original response
  6765. * Also sets the responseXXX fields on the jqXHR instance
  6766. */
  6767. function ajaxConvert( s, response, jqXHR, isSuccess ) {
  6768. var conv2, current, conv, tmp, prev,
  6769. converters = {},
  6770. // Work with a copy of dataTypes in case we need to modify it for conversion
  6771. dataTypes = s.dataTypes.slice();
  6772. // Create converters map with lowercased keys
  6773. if ( dataTypes[ 1 ] ) {
  6774. for ( conv in s.converters ) {
  6775. converters[ conv.toLowerCase() ] = s.converters[ conv ];
  6776. }
  6777. }
  6778. current = dataTypes.shift();
  6779. // Convert to each sequential dataType
  6780. while ( current ) {
  6781. if ( s.responseFields[ current ] ) {
  6782. jqXHR[ s.responseFields[ current ] ] = response;
  6783. }
  6784. // Apply the dataFilter if provided
  6785. if ( !prev && isSuccess && s.dataFilter ) {
  6786. response = s.dataFilter( response, s.dataType );
  6787. }
  6788. prev = current;
  6789. current = dataTypes.shift();
  6790. if ( current ) {
  6791. // There's only work to do if current dataType is non-auto
  6792. if ( current === "*" ) {
  6793. current = prev;
  6794. // Convert response if prev dataType is non-auto and differs from current
  6795. } else if ( prev !== "*" && prev !== current ) {
  6796. // Seek a direct converter
  6797. conv = converters[ prev + " " + current ] || converters[ "* " + current ];
  6798. // If none found, seek a pair
  6799. if ( !conv ) {
  6800. for ( conv2 in converters ) {
  6801. // If conv2 outputs current
  6802. tmp = conv2.split( " " );
  6803. if ( tmp[ 1 ] === current ) {
  6804. // If prev can be converted to accepted input
  6805. conv = converters[ prev + " " + tmp[ 0 ] ] ||
  6806. converters[ "* " + tmp[ 0 ] ];
  6807. if ( conv ) {
  6808. // Condense equivalence converters
  6809. if ( conv === true ) {
  6810. conv = converters[ conv2 ];
  6811. // Otherwise, insert the intermediate dataType
  6812. } else if ( converters[ conv2 ] !== true ) {
  6813. current = tmp[ 0 ];
  6814. dataTypes.unshift( tmp[ 1 ] );
  6815. }
  6816. break;
  6817. }
  6818. }
  6819. }
  6820. }
  6821. // Apply converter (if not an equivalence)
  6822. if ( conv !== true ) {
  6823. // Unless errors are allowed to bubble, catch and return them
  6824. if ( conv && s[ "throws" ] ) {
  6825. response = conv( response );
  6826. } else {
  6827. try {
  6828. response = conv( response );
  6829. } catch ( e ) {
  6830. return { state: "parsererror", error: conv ? e : "No conversion from " + prev + " to " + current };
  6831. }
  6832. }
  6833. }
  6834. }
  6835. }
  6836. }
  6837. return { state: "success", data: response };
  6838. }
  6839. jQuery.extend({
  6840. // Counter for holding the number of active queries
  6841. active: 0,
  6842. // Last-Modified header cache for next request
  6843. lastModified: {},
  6844. etag: {},
  6845. ajaxSettings: {
  6846. url: ajaxLocation,
  6847. type: "GET",
  6848. isLocal: rlocalProtocol.test( ajaxLocParts[ 1 ] ),
  6849. global: true,
  6850. processData: true,
  6851. async: true,
  6852. contentType: "application/x-www-form-urlencoded; charset=UTF-8",
  6853. /*
  6854. timeout: 0,
  6855. data: null,
  6856. dataType: null,
  6857. username: null,
  6858. password: null,
  6859. cache: null,
  6860. throws: false,
  6861. traditional: false,
  6862. headers: {},
  6863. */
  6864. accepts: {
  6865. "*": allTypes,
  6866. text: "text/plain",
  6867. html: "text/html",
  6868. xml: "application/xml, text/xml",
  6869. json: "application/json, text/javascript"
  6870. },
  6871. contents: {
  6872. xml: /xml/,
  6873. html: /html/,
  6874. json: /json/
  6875. },
  6876. responseFields: {
  6877. xml: "responseXML",
  6878. text: "responseText",
  6879. json: "responseJSON"
  6880. },
  6881. // Data converters
  6882. // Keys separate source (or catchall "*") and destination types with a single space
  6883. converters: {
  6884. // Convert anything to text
  6885. "* text": String,
  6886. // Text to html (true = no transformation)
  6887. "text html": true,
  6888. // Evaluate text as a json expression
  6889. "text json": jQuery.parseJSON,
  6890. // Parse text as xml
  6891. "text xml": jQuery.parseXML
  6892. },
  6893. // For options that shouldn't be deep extended:
  6894. // you can add your own custom options here if
  6895. // and when you create one that shouldn't be
  6896. // deep extended (see ajaxExtend)
  6897. flatOptions: {
  6898. url: true,
  6899. context: true
  6900. }
  6901. },
  6902. // Creates a full fledged settings object into target
  6903. // with both ajaxSettings and settings fields.
  6904. // If target is omitted, writes into ajaxSettings.
  6905. ajaxSetup: function( target, settings ) {
  6906. return settings ?
  6907. // Building a settings object
  6908. ajaxExtend( ajaxExtend( target, jQuery.ajaxSettings ), settings ) :
  6909. // Extending ajaxSettings
  6910. ajaxExtend( jQuery.ajaxSettings, target );
  6911. },
  6912. ajaxPrefilter: addToPrefiltersOrTransports( prefilters ),
  6913. ajaxTransport: addToPrefiltersOrTransports( transports ),
  6914. // Main method
  6915. ajax: function( url, options ) {
  6916. // If url is an object, simulate pre-1.5 signature
  6917. if ( typeof url === "object" ) {
  6918. options = url;
  6919. url = undefined;
  6920. }
  6921. // Force options to be an object
  6922. options = options || {};
  6923. var transport,
  6924. // URL without anti-cache param
  6925. cacheURL,
  6926. // Response headers
  6927. responseHeadersString,
  6928. responseHeaders,
  6929. // timeout handle
  6930. timeoutTimer,
  6931. // Cross-domain detection vars
  6932. parts,
  6933. // To know if global events are to be dispatched
  6934. fireGlobals,
  6935. // Loop variable
  6936. i,
  6937. // Create the final options object
  6938. s = jQuery.ajaxSetup( {}, options ),
  6939. // Callbacks context
  6940. callbackContext = s.context || s,
  6941. // Context for global events is callbackContext if it is a DOM node or jQuery collection
  6942. globalEventContext = s.context && ( callbackContext.nodeType || callbackContext.jquery ) ?
  6943. jQuery( callbackContext ) :
  6944. jQuery.event,
  6945. // Deferreds
  6946. deferred = jQuery.Deferred(),
  6947. completeDeferred = jQuery.Callbacks("once memory"),
  6948. // Status-dependent callbacks
  6949. statusCode = s.statusCode || {},
  6950. // Headers (they are sent all at once)
  6951. requestHeaders = {},
  6952. requestHeadersNames = {},
  6953. // The jqXHR state
  6954. state = 0,
  6955. // Default abort message
  6956. strAbort = "canceled",
  6957. // Fake xhr
  6958. jqXHR = {
  6959. readyState: 0,
  6960. // Builds headers hashtable if needed
  6961. getResponseHeader: function( key ) {
  6962. var match;
  6963. if ( state === 2 ) {
  6964. if ( !responseHeaders ) {
  6965. responseHeaders = {};
  6966. while ( (match = rheaders.exec( responseHeadersString )) ) {
  6967. responseHeaders[ match[1].toLowerCase() ] = match[ 2 ];
  6968. }
  6969. }
  6970. match = responseHeaders[ key.toLowerCase() ];
  6971. }
  6972. return match == null ? null : match;
  6973. },
  6974. // Raw string
  6975. getAllResponseHeaders: function() {
  6976. return state === 2 ? responseHeadersString : null;
  6977. },
  6978. // Caches the header
  6979. setRequestHeader: function( name, value ) {
  6980. var lname = name.toLowerCase();
  6981. if ( !state ) {
  6982. name = requestHeadersNames[ lname ] = requestHeadersNames[ lname ] || name;
  6983. requestHeaders[ name ] = value;
  6984. }
  6985. return this;
  6986. },
  6987. // Overrides response content-type header
  6988. overrideMimeType: function( type ) {
  6989. if ( !state ) {
  6990. s.mimeType = type;
  6991. }
  6992. return this;
  6993. },
  6994. // Status-dependent callbacks
  6995. statusCode: function( map ) {
  6996. var code;
  6997. if ( map ) {
  6998. if ( state < 2 ) {
  6999. for ( code in map ) {
  7000. // Lazy-add the new callback in a way that preserves old ones
  7001. statusCode[ code ] = [ statusCode[ code ], map[ code ] ];
  7002. }
  7003. } else {
  7004. // Execute the appropriate callbacks
  7005. jqXHR.always( map[ jqXHR.status ] );
  7006. }
  7007. }
  7008. return this;
  7009. },
  7010. // Cancel the request
  7011. abort: function( statusText ) {
  7012. var finalText = statusText || strAbort;
  7013. if ( transport ) {
  7014. transport.abort( finalText );
  7015. }
  7016. done( 0, finalText );
  7017. return this;
  7018. }
  7019. };
  7020. // Attach deferreds
  7021. deferred.promise( jqXHR ).complete = completeDeferred.add;
  7022. jqXHR.success = jqXHR.done;
  7023. jqXHR.error = jqXHR.fail;
  7024. // Remove hash character (#7531: and string promotion)
  7025. // Add protocol if not provided (prefilters might expect it)
  7026. // Handle falsy url in the settings object (#10093: consistency with old signature)
  7027. // We also use the url parameter if available
  7028. s.url = ( ( url || s.url || ajaxLocation ) + "" ).replace( rhash, "" )
  7029. .replace( rprotocol, ajaxLocParts[ 1 ] + "//" );
  7030. // Alias method option to type as per ticket #12004
  7031. s.type = options.method || options.type || s.method || s.type;
  7032. // Extract dataTypes list
  7033. s.dataTypes = jQuery.trim( s.dataType || "*" ).toLowerCase().match( rnotwhite ) || [ "" ];
  7034. // A cross-domain request is in order when we have a protocol:host:port mismatch
  7035. if ( s.crossDomain == null ) {
  7036. parts = rurl.exec( s.url.toLowerCase() );
  7037. s.crossDomain = !!( parts &&
  7038. ( parts[ 1 ] !== ajaxLocParts[ 1 ] || parts[ 2 ] !== ajaxLocParts[ 2 ] ||
  7039. ( parts[ 3 ] || ( parts[ 1 ] === "http:" ? "80" : "443" ) ) !==
  7040. ( ajaxLocParts[ 3 ] || ( ajaxLocParts[ 1 ] === "http:" ? "80" : "443" ) ) )
  7041. );
  7042. }
  7043. // Convert data if not already a string
  7044. if ( s.data && s.processData && typeof s.data !== "string" ) {
  7045. s.data = jQuery.param( s.data, s.traditional );
  7046. }
  7047. // Apply prefilters
  7048. inspectPrefiltersOrTransports( prefilters, s, options, jqXHR );
  7049. // If request was aborted inside a prefilter, stop there
  7050. if ( state === 2 ) {
  7051. return jqXHR;
  7052. }
  7053. // We can fire global events as of now if asked to
  7054. fireGlobals = s.global;
  7055. // Watch for a new set of requests
  7056. if ( fireGlobals && jQuery.active++ === 0 ) {
  7057. jQuery.event.trigger("ajaxStart");
  7058. }
  7059. // Uppercase the type
  7060. s.type = s.type.toUpperCase();
  7061. // Determine if request has content
  7062. s.hasContent = !rnoContent.test( s.type );
  7063. // Save the URL in case we're toying with the If-Modified-Since
  7064. // and/or If-None-Match header later on
  7065. cacheURL = s.url;
  7066. // More options handling for requests with no content
  7067. if ( !s.hasContent ) {
  7068. // If data is available, append data to url
  7069. if ( s.data ) {
  7070. cacheURL = ( s.url += ( rquery.test( cacheURL ) ? "&" : "?" ) + s.data );
  7071. // #9682: remove data so that it's not used in an eventual retry
  7072. delete s.data;
  7073. }
  7074. // Add anti-cache in url if needed
  7075. if ( s.cache === false ) {
  7076. s.url = rts.test( cacheURL ) ?
  7077. // If there is already a '_' parameter, set its value
  7078. cacheURL.replace( rts, "$1_=" + nonce++ ) :
  7079. // Otherwise add one to the end
  7080. cacheURL + ( rquery.test( cacheURL ) ? "&" : "?" ) + "_=" + nonce++;
  7081. }
  7082. }
  7083. // Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode.
  7084. if ( s.ifModified ) {
  7085. if ( jQuery.lastModified[ cacheURL ] ) {
  7086. jqXHR.setRequestHeader( "If-Modified-Since", jQuery.lastModified[ cacheURL ] );
  7087. }
  7088. if ( jQuery.etag[ cacheURL ] ) {
  7089. jqXHR.setRequestHeader( "If-None-Match", jQuery.etag[ cacheURL ] );
  7090. }
  7091. }
  7092. // Set the correct header, if data is being sent
  7093. if ( s.data && s.hasContent && s.contentType !== false || options.contentType ) {
  7094. jqXHR.setRequestHeader( "Content-Type", s.contentType );
  7095. }
  7096. // Set the Accepts header for the server, depending on the dataType
  7097. jqXHR.setRequestHeader(
  7098. "Accept",
  7099. s.dataTypes[ 0 ] && s.accepts[ s.dataTypes[0] ] ?
  7100. s.accepts[ s.dataTypes[0] ] + ( s.dataTypes[ 0 ] !== "*" ? ", " + allTypes + "; q=0.01" : "" ) :
  7101. s.accepts[ "*" ]
  7102. );
  7103. // Check for headers option
  7104. for ( i in s.headers ) {
  7105. jqXHR.setRequestHeader( i, s.headers[ i ] );
  7106. }
  7107. // Allow custom headers/mimetypes and early abort
  7108. if ( s.beforeSend && ( s.beforeSend.call( callbackContext, jqXHR, s ) === false || state === 2 ) ) {
  7109. // Abort if not done already and return
  7110. return jqXHR.abort();
  7111. }
  7112. // aborting is no longer a cancellation
  7113. strAbort = "abort";
  7114. // Install callbacks on deferreds
  7115. for ( i in { success: 1, error: 1, complete: 1 } ) {
  7116. jqXHR[ i ]( s[ i ] );
  7117. }
  7118. // Get transport
  7119. transport = inspectPrefiltersOrTransports( transports, s, options, jqXHR );
  7120. // If no transport, we auto-abort
  7121. if ( !transport ) {
  7122. done( -1, "No Transport" );
  7123. } else {
  7124. jqXHR.readyState = 1;
  7125. // Send global event
  7126. if ( fireGlobals ) {
  7127. globalEventContext.trigger( "ajaxSend", [ jqXHR, s ] );
  7128. }
  7129. // Timeout
  7130. if ( s.async && s.timeout > 0 ) {
  7131. timeoutTimer = setTimeout(function() {
  7132. jqXHR.abort("timeout");
  7133. }, s.timeout );
  7134. }
  7135. try {
  7136. state = 1;
  7137. transport.send( requestHeaders, done );
  7138. } catch ( e ) {
  7139. // Propagate exception as error if not done
  7140. if ( state < 2 ) {
  7141. done( -1, e );
  7142. // Simply rethrow otherwise
  7143. } else {
  7144. throw e;
  7145. }
  7146. }
  7147. }
  7148. // Callback for when everything is done
  7149. function done( status, nativeStatusText, responses, headers ) {
  7150. var isSuccess, success, error, response, modified,
  7151. statusText = nativeStatusText;
  7152. // Called once
  7153. if ( state === 2 ) {
  7154. return;
  7155. }
  7156. // State is "done" now
  7157. state = 2;
  7158. // Clear timeout if it exists
  7159. if ( timeoutTimer ) {
  7160. clearTimeout( timeoutTimer );
  7161. }
  7162. // Dereference transport for early garbage collection
  7163. // (no matter how long the jqXHR object will be used)
  7164. transport = undefined;
  7165. // Cache response headers
  7166. responseHeadersString = headers || "";
  7167. // Set readyState
  7168. jqXHR.readyState = status > 0 ? 4 : 0;
  7169. // Determine if successful
  7170. isSuccess = status >= 200 && status < 300 || status === 304;
  7171. // Get response data
  7172. if ( responses ) {
  7173. response = ajaxHandleResponses( s, jqXHR, responses );
  7174. }
  7175. // Convert no matter what (that way responseXXX fields are always set)
  7176. response = ajaxConvert( s, response, jqXHR, isSuccess );
  7177. // If successful, handle type chaining
  7178. if ( isSuccess ) {
  7179. // Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode.
  7180. if ( s.ifModified ) {
  7181. modified = jqXHR.getResponseHeader("Last-Modified");
  7182. if ( modified ) {
  7183. jQuery.lastModified[ cacheURL ] = modified;
  7184. }
  7185. modified = jqXHR.getResponseHeader("etag");
  7186. if ( modified ) {
  7187. jQuery.etag[ cacheURL ] = modified;
  7188. }
  7189. }
  7190. // if no content
  7191. if ( status === 204 || s.type === "HEAD" ) {
  7192. statusText = "nocontent";
  7193. // if not modified
  7194. } else if ( status === 304 ) {
  7195. statusText = "notmodified";
  7196. // If we have data, let's convert it
  7197. } else {
  7198. statusText = response.state;
  7199. success = response.data;
  7200. error = response.error;
  7201. isSuccess = !error;
  7202. }
  7203. } else {
  7204. // We extract error from statusText
  7205. // then normalize statusText and status for non-aborts
  7206. error = statusText;
  7207. if ( status || !statusText ) {
  7208. statusText = "error";
  7209. if ( status < 0 ) {
  7210. status = 0;
  7211. }
  7212. }
  7213. }
  7214. // Set data for the fake xhr object
  7215. jqXHR.status = status;
  7216. jqXHR.statusText = ( nativeStatusText || statusText ) + "";
  7217. // Success/Error
  7218. if ( isSuccess ) {
  7219. deferred.resolveWith( callbackContext, [ success, statusText, jqXHR ] );
  7220. } else {
  7221. deferred.rejectWith( callbackContext, [ jqXHR, statusText, error ] );
  7222. }
  7223. // Status-dependent callbacks
  7224. jqXHR.statusCode( statusCode );
  7225. statusCode = undefined;
  7226. if ( fireGlobals ) {
  7227. globalEventContext.trigger( isSuccess ? "ajaxSuccess" : "ajaxError",
  7228. [ jqXHR, s, isSuccess ? success : error ] );
  7229. }
  7230. // Complete
  7231. completeDeferred.fireWith( callbackContext, [ jqXHR, statusText ] );
  7232. if ( fireGlobals ) {
  7233. globalEventContext.trigger( "ajaxComplete", [ jqXHR, s ] );
  7234. // Handle the global AJAX counter
  7235. if ( !( --jQuery.active ) ) {
  7236. jQuery.event.trigger("ajaxStop");
  7237. }
  7238. }
  7239. }
  7240. return jqXHR;
  7241. },
  7242. getJSON: function( url, data, callback ) {
  7243. return jQuery.get( url, data, callback, "json" );
  7244. },
  7245. getScript: function( url, callback ) {
  7246. return jQuery.get( url, undefined, callback, "script" );
  7247. }
  7248. });
  7249. jQuery.each( [ "get", "post" ], function( i, method ) {
  7250. jQuery[ method ] = function( url, data, callback, type ) {
  7251. // shift arguments if data argument was omitted
  7252. if ( jQuery.isFunction( data ) ) {
  7253. type = type || callback;
  7254. callback = data;
  7255. data = undefined;
  7256. }
  7257. return jQuery.ajax({
  7258. url: url,
  7259. type: method,
  7260. dataType: type,
  7261. data: data,
  7262. success: callback
  7263. });
  7264. };
  7265. });
  7266. // Attach a bunch of functions for handling common AJAX events
  7267. jQuery.each( [ "ajaxStart", "ajaxStop", "ajaxComplete", "ajaxError", "ajaxSuccess", "ajaxSend" ], function( i, type ) {
  7268. jQuery.fn[ type ] = function( fn ) {
  7269. return this.on( type, fn );
  7270. };
  7271. });
  7272. jQuery._evalUrl = function( url ) {
  7273. return jQuery.ajax({
  7274. url: url,
  7275. type: "GET",
  7276. dataType: "script",
  7277. async: false,
  7278. global: false,
  7279. "throws": true
  7280. });
  7281. };
  7282. jQuery.fn.extend({
  7283. wrapAll: function( html ) {
  7284. var wrap;
  7285. if ( jQuery.isFunction( html ) ) {
  7286. return this.each(function( i ) {
  7287. jQuery( this ).wrapAll( html.call(this, i) );
  7288. });
  7289. }
  7290. if ( this[ 0 ] ) {
  7291. // The elements to wrap the target around
  7292. wrap = jQuery( html, this[ 0 ].ownerDocument ).eq( 0 ).clone( true );
  7293. if ( this[ 0 ].parentNode ) {
  7294. wrap.insertBefore( this[ 0 ] );
  7295. }
  7296. wrap.map(function() {
  7297. var elem = this;
  7298. while ( elem.firstElementChild ) {
  7299. elem = elem.firstElementChild;
  7300. }
  7301. return elem;
  7302. }).append( this );
  7303. }
  7304. return this;
  7305. },
  7306. wrapInner: function( html ) {
  7307. if ( jQuery.isFunction( html ) ) {
  7308. return this.each(function( i ) {
  7309. jQuery( this ).wrapInner( html.call(this, i) );
  7310. });
  7311. }
  7312. return this.each(function() {
  7313. var self = jQuery( this ),
  7314. contents = self.contents();
  7315. if ( contents.length ) {
  7316. contents.wrapAll( html );
  7317. } else {
  7318. self.append( html );
  7319. }
  7320. });
  7321. },
  7322. wrap: function( html ) {
  7323. var isFunction = jQuery.isFunction( html );
  7324. return this.each(function( i ) {
  7325. jQuery( this ).wrapAll( isFunction ? html.call(this, i) : html );
  7326. });
  7327. },
  7328. unwrap: function() {
  7329. return this.parent().each(function() {
  7330. if ( !jQuery.nodeName( this, "body" ) ) {
  7331. jQuery( this ).replaceWith( this.childNodes );
  7332. }
  7333. }).end();
  7334. }
  7335. });
  7336. jQuery.expr.filters.hidden = function( elem ) {
  7337. // Support: Opera <= 12.12
  7338. // Opera reports offsetWidths and offsetHeights less than zero on some elements
  7339. return elem.offsetWidth <= 0 && elem.offsetHeight <= 0;
  7340. };
  7341. jQuery.expr.filters.visible = function( elem ) {
  7342. return !jQuery.expr.filters.hidden( elem );
  7343. };
  7344. var r20 = /%20/g,
  7345. rbracket = /\[\]$/,
  7346. rCRLF = /\r?\n/g,
  7347. rsubmitterTypes = /^(?:submit|button|image|reset|file)$/i,
  7348. rsubmittable = /^(?:input|select|textarea|keygen)/i;
  7349. function buildParams( prefix, obj, traditional, add ) {
  7350. var name;
  7351. if ( jQuery.isArray( obj ) ) {
  7352. // Serialize array item.
  7353. jQuery.each( obj, function( i, v ) {
  7354. if ( traditional || rbracket.test( prefix ) ) {
  7355. // Treat each array item as a scalar.
  7356. add( prefix, v );
  7357. } else {
  7358. // Item is non-scalar (array or object), encode its numeric index.
  7359. buildParams( prefix + "[" + ( typeof v === "object" ? i : "" ) + "]", v, traditional, add );
  7360. }
  7361. });
  7362. } else if ( !traditional && jQuery.type( obj ) === "object" ) {
  7363. // Serialize object item.
  7364. for ( name in obj ) {
  7365. buildParams( prefix + "[" + name + "]", obj[ name ], traditional, add );
  7366. }
  7367. } else {
  7368. // Serialize scalar item.
  7369. add( prefix, obj );
  7370. }
  7371. }
  7372. // Serialize an array of form elements or a set of
  7373. // key/values into a query string
  7374. jQuery.param = function( a, traditional ) {
  7375. var prefix,
  7376. s = [],
  7377. add = function( key, value ) {
  7378. // If value is a function, invoke it and return its value
  7379. value = jQuery.isFunction( value ) ? value() : ( value == null ? "" : value );
  7380. s[ s.length ] = encodeURIComponent( key ) + "=" + encodeURIComponent( value );
  7381. };
  7382. // Set traditional to true for jQuery <= 1.3.2 behavior.
  7383. if ( traditional === undefined ) {
  7384. traditional = jQuery.ajaxSettings && jQuery.ajaxSettings.traditional;
  7385. }
  7386. // If an array was passed in, assume that it is an array of form elements.
  7387. if ( jQuery.isArray( a ) || ( a.jquery && !jQuery.isPlainObject( a ) ) ) {
  7388. // Serialize the form elements
  7389. jQuery.each( a, function() {
  7390. add( this.name, this.value );
  7391. });
  7392. } else {
  7393. // If traditional, encode the "old" way (the way 1.3.2 or older
  7394. // did it), otherwise encode params recursively.
  7395. for ( prefix in a ) {
  7396. buildParams( prefix, a[ prefix ], traditional, add );
  7397. }
  7398. }
  7399. // Return the resulting serialization
  7400. return s.join( "&" ).replace( r20, "+" );
  7401. };
  7402. jQuery.fn.extend({
  7403. serialize: function() {
  7404. return jQuery.param( this.serializeArray() );
  7405. },
  7406. serializeArray: function() {
  7407. return this.map(function() {
  7408. // Can add propHook for "elements" to filter or add form elements
  7409. var elements = jQuery.prop( this, "elements" );
  7410. return elements ? jQuery.makeArray( elements ) : this;
  7411. })
  7412. .filter(function() {
  7413. var type = this.type;
  7414. // Use .is( ":disabled" ) so that fieldset[disabled] works
  7415. return this.name && !jQuery( this ).is( ":disabled" ) &&
  7416. rsubmittable.test( this.nodeName ) && !rsubmitterTypes.test( type ) &&
  7417. ( this.checked || !rcheckableType.test( type ) );
  7418. })
  7419. .map(function( i, elem ) {
  7420. var val = jQuery( this ).val();
  7421. return val == null ?
  7422. null :
  7423. jQuery.isArray( val ) ?
  7424. jQuery.map( val, function( val ) {
  7425. return { name: elem.name, value: val.replace( rCRLF, "\r\n" ) };
  7426. }) :
  7427. { name: elem.name, value: val.replace( rCRLF, "\r\n" ) };
  7428. }).get();
  7429. }
  7430. });
  7431. jQuery.ajaxSettings.xhr = function() {
  7432. try {
  7433. return new XMLHttpRequest();
  7434. } catch( e ) {}
  7435. };
  7436. var xhrId = 0,
  7437. xhrCallbacks = {},
  7438. xhrSuccessStatus = {
  7439. // file protocol always yields status code 0, assume 200
  7440. 0: 200,
  7441. // Support: IE9
  7442. // #1450: sometimes IE returns 1223 when it should be 204
  7443. 1223: 204
  7444. },
  7445. xhrSupported = jQuery.ajaxSettings.xhr();
  7446. // Support: IE9
  7447. // Open requests must be manually aborted on unload (#5280)
  7448. if ( window.ActiveXObject ) {
  7449. jQuery( window ).on( "unload", function() {
  7450. for ( var key in xhrCallbacks ) {
  7451. xhrCallbacks[ key ]();
  7452. }
  7453. });
  7454. }
  7455. support.cors = !!xhrSupported && ( "withCredentials" in xhrSupported );
  7456. support.ajax = xhrSupported = !!xhrSupported;
  7457. jQuery.ajaxTransport(function( options ) {
  7458. var callback;
  7459. // Cross domain only allowed if supported through XMLHttpRequest
  7460. if ( support.cors || xhrSupported && !options.crossDomain ) {
  7461. return {
  7462. send: function( headers, complete ) {
  7463. var i,
  7464. xhr = options.xhr(),
  7465. id = ++xhrId;
  7466. xhr.open( options.type, options.url, options.async, options.username, options.password );
  7467. // Apply custom fields if provided
  7468. if ( options.xhrFields ) {
  7469. for ( i in options.xhrFields ) {
  7470. xhr[ i ] = options.xhrFields[ i ];
  7471. }
  7472. }
  7473. // Override mime type if needed
  7474. if ( options.mimeType && xhr.overrideMimeType ) {
  7475. xhr.overrideMimeType( options.mimeType );
  7476. }
  7477. // X-Requested-With header
  7478. // For cross-domain requests, seeing as conditions for a preflight are
  7479. // akin to a jigsaw puzzle, we simply never set it to be sure.
  7480. // (it can always be set on a per-request basis or even using ajaxSetup)
  7481. // For same-domain requests, won't change header if already provided.
  7482. if ( !options.crossDomain && !headers["X-Requested-With"] ) {
  7483. headers["X-Requested-With"] = "XMLHttpRequest";
  7484. }
  7485. // Set headers
  7486. for ( i in headers ) {
  7487. xhr.setRequestHeader( i, headers[ i ] );
  7488. }
  7489. // Callback
  7490. callback = function( type ) {
  7491. return function() {
  7492. if ( callback ) {
  7493. delete xhrCallbacks[ id ];
  7494. callback = xhr.onload = xhr.onerror = null;
  7495. if ( type === "abort" ) {
  7496. xhr.abort();
  7497. } else if ( type === "error" ) {
  7498. complete(
  7499. // file: protocol always yields status 0; see #8605, #14207
  7500. xhr.status,
  7501. xhr.statusText
  7502. );
  7503. } else {
  7504. complete(
  7505. xhrSuccessStatus[ xhr.status ] || xhr.status,
  7506. xhr.statusText,
  7507. // Support: IE9
  7508. // Accessing binary-data responseText throws an exception
  7509. // (#11426)
  7510. typeof xhr.responseText === "string" ? {
  7511. text: xhr.responseText
  7512. } : undefined,
  7513. xhr.getAllResponseHeaders()
  7514. );
  7515. }
  7516. }
  7517. };
  7518. };
  7519. // Listen to events
  7520. xhr.onload = callback();
  7521. xhr.onerror = callback("error");
  7522. // Create the abort callback
  7523. callback = xhrCallbacks[ id ] = callback("abort");
  7524. // Do send the request
  7525. // This may raise an exception which is actually
  7526. // handled in jQuery.ajax (so no try/catch here)
  7527. xhr.send( options.hasContent && options.data || null );
  7528. },
  7529. abort: function() {
  7530. if ( callback ) {
  7531. callback();
  7532. }
  7533. }
  7534. };
  7535. }
  7536. });
  7537. // Install script dataType
  7538. jQuery.ajaxSetup({
  7539. accepts: {
  7540. script: "text/javascript, application/javascript, application/ecmascript, application/x-ecmascript"
  7541. },
  7542. contents: {
  7543. script: /(?:java|ecma)script/
  7544. },
  7545. converters: {
  7546. "text script": function( text ) {
  7547. jQuery.globalEval( text );
  7548. return text;
  7549. }
  7550. }
  7551. });
  7552. // Handle cache's special case and crossDomain
  7553. jQuery.ajaxPrefilter( "script", function( s ) {
  7554. if ( s.cache === undefined ) {
  7555. s.cache = false;
  7556. }
  7557. if ( s.crossDomain ) {
  7558. s.type = "GET";
  7559. }
  7560. });
  7561. // Bind script tag hack transport
  7562. jQuery.ajaxTransport( "script", function( s ) {
  7563. // This transport only deals with cross domain requests
  7564. if ( s.crossDomain ) {
  7565. var script, callback;
  7566. return {
  7567. send: function( _, complete ) {
  7568. script = jQuery("<script>").prop({
  7569. async: true,
  7570. charset: s.scriptCharset,
  7571. src: s.url
  7572. }).on(
  7573. "load error",
  7574. callback = function( evt ) {
  7575. script.remove();
  7576. callback = null;
  7577. if ( evt ) {
  7578. complete( evt.type === "error" ? 404 : 200, evt.type );
  7579. }
  7580. }
  7581. );
  7582. document.head.appendChild( script[ 0 ] );
  7583. },
  7584. abort: function() {
  7585. if ( callback ) {
  7586. callback();
  7587. }
  7588. }
  7589. };
  7590. }
  7591. });
  7592. var oldCallbacks = [],
  7593. rjsonp = /(=)\?(?=&|$)|\?\?/;
  7594. // Default jsonp settings
  7595. jQuery.ajaxSetup({
  7596. jsonp: "callback",
  7597. jsonpCallback: function() {
  7598. var callback = oldCallbacks.pop() || ( jQuery.expando + "_" + ( nonce++ ) );
  7599. this[ callback ] = true;
  7600. return callback;
  7601. }
  7602. });
  7603. // Detect, normalize options and install callbacks for jsonp requests
  7604. jQuery.ajaxPrefilter( "json jsonp", function( s, originalSettings, jqXHR ) {
  7605. var callbackName, overwritten, responseContainer,
  7606. jsonProp = s.jsonp !== false && ( rjsonp.test( s.url ) ?
  7607. "url" :
  7608. typeof s.data === "string" && !( s.contentType || "" ).indexOf("application/x-www-form-urlencoded") && rjsonp.test( s.data ) && "data"
  7609. );
  7610. // Handle iff the expected data type is "jsonp" or we have a parameter to set
  7611. if ( jsonProp || s.dataTypes[ 0 ] === "jsonp" ) {
  7612. // Get callback name, remembering preexisting value associated with it
  7613. callbackName = s.jsonpCallback = jQuery.isFunction( s.jsonpCallback ) ?
  7614. s.jsonpCallback() :
  7615. s.jsonpCallback;
  7616. // Insert callback into url or form data
  7617. if ( jsonProp ) {
  7618. s[ jsonProp ] = s[ jsonProp ].replace( rjsonp, "$1" + callbackName );
  7619. } else if ( s.jsonp !== false ) {
  7620. s.url += ( rquery.test( s.url ) ? "&" : "?" ) + s.jsonp + "=" + callbackName;
  7621. }
  7622. // Use data converter to retrieve json after script execution
  7623. s.converters["script json"] = function() {
  7624. if ( !responseContainer ) {
  7625. jQuery.error( callbackName + " was not called" );
  7626. }
  7627. return responseContainer[ 0 ];
  7628. };
  7629. // force json dataType
  7630. s.dataTypes[ 0 ] = "json";
  7631. // Install callback
  7632. overwritten = window[ callbackName ];
  7633. window[ callbackName ] = function() {
  7634. responseContainer = arguments;
  7635. };
  7636. // Clean-up function (fires after converters)
  7637. jqXHR.always(function() {
  7638. // Restore preexisting value
  7639. window[ callbackName ] = overwritten;
  7640. // Save back as free
  7641. if ( s[ callbackName ] ) {
  7642. // make sure that re-using the options doesn't screw things around
  7643. s.jsonpCallback = originalSettings.jsonpCallback;
  7644. // save the callback name for future use
  7645. oldCallbacks.push( callbackName );
  7646. }
  7647. // Call if it was a function and we have a response
  7648. if ( responseContainer && jQuery.isFunction( overwritten ) ) {
  7649. overwritten( responseContainer[ 0 ] );
  7650. }
  7651. responseContainer = overwritten = undefined;
  7652. });
  7653. // Delegate to script
  7654. return "script";
  7655. }
  7656. });
  7657. // data: string of html
  7658. // context (optional): If specified, the fragment will be created in this context, defaults to document
  7659. // keepScripts (optional): If true, will include scripts passed in the html string
  7660. jQuery.parseHTML = function( data, context, keepScripts ) {
  7661. if ( !data || typeof data !== "string" ) {
  7662. return null;
  7663. }
  7664. if ( typeof context === "boolean" ) {
  7665. keepScripts = context;
  7666. context = false;
  7667. }
  7668. context = context || document;
  7669. var parsed = rsingleTag.exec( data ),
  7670. scripts = !keepScripts && [];
  7671. // Single tag
  7672. if ( parsed ) {
  7673. return [ context.createElement( parsed[1] ) ];
  7674. }
  7675. parsed = jQuery.buildFragment( [ data ], context, scripts );
  7676. if ( scripts && scripts.length ) {
  7677. jQuery( scripts ).remove();
  7678. }
  7679. return jQuery.merge( [], parsed.childNodes );
  7680. };
  7681. // Keep a copy of the old load method
  7682. var _load = jQuery.fn.load;
  7683. /**
  7684. * Load a url into a page
  7685. */
  7686. jQuery.fn.load = function( url, params, callback ) {
  7687. if ( typeof url !== "string" && _load ) {
  7688. return _load.apply( this, arguments );
  7689. }
  7690. var selector, type, response,
  7691. self = this,
  7692. off = url.indexOf(" ");
  7693. if ( off >= 0 ) {
  7694. selector = url.slice( off );
  7695. url = url.slice( 0, off );
  7696. }
  7697. // If it's a function
  7698. if ( jQuery.isFunction( params ) ) {
  7699. // We assume that it's the callback
  7700. callback = params;
  7701. params = undefined;
  7702. // Otherwise, build a param string
  7703. } else if ( params && typeof params === "object" ) {
  7704. type = "POST";
  7705. }
  7706. // If we have elements to modify, make the request
  7707. if ( self.length > 0 ) {
  7708. jQuery.ajax({
  7709. url: url,
  7710. // if "type" variable is undefined, then "GET" method will be used
  7711. type: type,
  7712. dataType: "html",
  7713. data: params
  7714. }).done(function( responseText ) {
  7715. // Save response for use in complete callback
  7716. response = arguments;
  7717. self.html( selector ?
  7718. // If a selector was specified, locate the right elements in a dummy div
  7719. // Exclude scripts to avoid IE 'Permission Denied' errors
  7720. jQuery("<div>").append( jQuery.parseHTML( responseText ) ).find( selector ) :
  7721. // Otherwise use the full result
  7722. responseText );
  7723. }).complete( callback && function( jqXHR, status ) {
  7724. self.each( callback, response || [ jqXHR.responseText, status, jqXHR ] );
  7725. });
  7726. }
  7727. return this;
  7728. };
  7729. jQuery.expr.filters.animated = function( elem ) {
  7730. return jQuery.grep(jQuery.timers, function( fn ) {
  7731. return elem === fn.elem;
  7732. }).length;
  7733. };
  7734. var docElem = window.document.documentElement;
  7735. /**
  7736. * Gets a window from an element
  7737. */
  7738. function getWindow( elem ) {
  7739. return jQuery.isWindow( elem ) ? elem : elem.nodeType === 9 && elem.defaultView;
  7740. }
  7741. jQuery.offset = {
  7742. setOffset: function( elem, options, i ) {
  7743. var curPosition, curLeft, curCSSTop, curTop, curOffset, curCSSLeft, calculatePosition,
  7744. position = jQuery.css( elem, "position" ),
  7745. curElem = jQuery( elem ),
  7746. props = {};
  7747. // Set position first, in-case top/left are set even on static elem
  7748. if ( position === "static" ) {
  7749. elem.style.position = "relative";
  7750. }
  7751. curOffset = curElem.offset();
  7752. curCSSTop = jQuery.css( elem, "top" );
  7753. curCSSLeft = jQuery.css( elem, "left" );
  7754. calculatePosition = ( position === "absolute" || position === "fixed" ) &&
  7755. ( curCSSTop + curCSSLeft ).indexOf("auto") > -1;
  7756. // Need to be able to calculate position if either top or left is auto and position is either absolute or fixed
  7757. if ( calculatePosition ) {
  7758. curPosition = curElem.position();
  7759. curTop = curPosition.top;
  7760. curLeft = curPosition.left;
  7761. } else {
  7762. curTop = parseFloat( curCSSTop ) || 0;
  7763. curLeft = parseFloat( curCSSLeft ) || 0;
  7764. }
  7765. if ( jQuery.isFunction( options ) ) {
  7766. options = options.call( elem, i, curOffset );
  7767. }
  7768. if ( options.top != null ) {
  7769. props.top = ( options.top - curOffset.top ) + curTop;
  7770. }
  7771. if ( options.left != null ) {
  7772. props.left = ( options.left - curOffset.left ) + curLeft;
  7773. }
  7774. if ( "using" in options ) {
  7775. options.using.call( elem, props );
  7776. } else {
  7777. curElem.css( props );
  7778. }
  7779. }
  7780. };
  7781. jQuery.fn.extend({
  7782. offset: function( options ) {
  7783. if ( arguments.length ) {
  7784. return options === undefined ?
  7785. this :
  7786. this.each(function( i ) {
  7787. jQuery.offset.setOffset( this, options, i );
  7788. });
  7789. }
  7790. var docElem, win,
  7791. elem = this[ 0 ],
  7792. box = { top: 0, left: 0 },
  7793. doc = elem && elem.ownerDocument;
  7794. if ( !doc ) {
  7795. return;
  7796. }
  7797. docElem = doc.documentElement;
  7798. // Make sure it's not a disconnected DOM node
  7799. if ( !jQuery.contains( docElem, elem ) ) {
  7800. return box;
  7801. }
  7802. // If we don't have gBCR, just use 0,0 rather than error
  7803. // BlackBerry 5, iOS 3 (original iPhone)
  7804. if ( typeof elem.getBoundingClientRect !== strundefined ) {
  7805. box = elem.getBoundingClientRect();
  7806. }
  7807. win = getWindow( doc );
  7808. return {
  7809. top: box.top + win.pageYOffset - docElem.clientTop,
  7810. left: box.left + win.pageXOffset - docElem.clientLeft
  7811. };
  7812. },
  7813. position: function() {
  7814. if ( !this[ 0 ] ) {
  7815. return;
  7816. }
  7817. var offsetParent, offset,
  7818. elem = this[ 0 ],
  7819. parentOffset = { top: 0, left: 0 };
  7820. // Fixed elements are offset from window (parentOffset = {top:0, left: 0}, because it is its only offset parent
  7821. if ( jQuery.css( elem, "position" ) === "fixed" ) {
  7822. // We assume that getBoundingClientRect is available when computed position is fixed
  7823. offset = elem.getBoundingClientRect();
  7824. } else {
  7825. // Get *real* offsetParent
  7826. offsetParent = this.offsetParent();
  7827. // Get correct offsets
  7828. offset = this.offset();
  7829. if ( !jQuery.nodeName( offsetParent[ 0 ], "html" ) ) {
  7830. parentOffset = offsetParent.offset();
  7831. }
  7832. // Add offsetParent borders
  7833. parentOffset.top += jQuery.css( offsetParent[ 0 ], "borderTopWidth", true );
  7834. parentOffset.left += jQuery.css( offsetParent[ 0 ], "borderLeftWidth", true );
  7835. }
  7836. // Subtract parent offsets and element margins
  7837. return {
  7838. top: offset.top - parentOffset.top - jQuery.css( elem, "marginTop", true ),
  7839. left: offset.left - parentOffset.left - jQuery.css( elem, "marginLeft", true )
  7840. };
  7841. },
  7842. offsetParent: function() {
  7843. return this.map(function() {
  7844. var offsetParent = this.offsetParent || docElem;
  7845. while ( offsetParent && ( !jQuery.nodeName( offsetParent, "html" ) && jQuery.css( offsetParent, "position" ) === "static" ) ) {
  7846. offsetParent = offsetParent.offsetParent;
  7847. }
  7848. return offsetParent || docElem;
  7849. });
  7850. }
  7851. });
  7852. // Create scrollLeft and scrollTop methods
  7853. jQuery.each( { scrollLeft: "pageXOffset", scrollTop: "pageYOffset" }, function( method, prop ) {
  7854. var top = "pageYOffset" === prop;
  7855. jQuery.fn[ method ] = function( val ) {
  7856. return access( this, function( elem, method, val ) {
  7857. var win = getWindow( elem );
  7858. if ( val === undefined ) {
  7859. return win ? win[ prop ] : elem[ method ];
  7860. }
  7861. if ( win ) {
  7862. win.scrollTo(
  7863. !top ? val : window.pageXOffset,
  7864. top ? val : window.pageYOffset
  7865. );
  7866. } else {
  7867. elem[ method ] = val;
  7868. }
  7869. }, method, val, arguments.length, null );
  7870. };
  7871. });
  7872. // Add the top/left cssHooks using jQuery.fn.position
  7873. // Webkit bug: https://bugs.webkit.org/show_bug.cgi?id=29084
  7874. // getComputedStyle returns percent when specified for top/left/bottom/right
  7875. // rather than make the css module depend on the offset module, we just check for it here
  7876. jQuery.each( [ "top", "left" ], function( i, prop ) {
  7877. jQuery.cssHooks[ prop ] = addGetHookIf( support.pixelPosition,
  7878. function( elem, computed ) {
  7879. if ( computed ) {
  7880. computed = curCSS( elem, prop );
  7881. // if curCSS returns percentage, fallback to offset
  7882. return rnumnonpx.test( computed ) ?
  7883. jQuery( elem ).position()[ prop ] + "px" :
  7884. computed;
  7885. }
  7886. }
  7887. );
  7888. });
  7889. // Create innerHeight, innerWidth, height, width, outerHeight and outerWidth methods
  7890. jQuery.each( { Height: "height", Width: "width" }, function( name, type ) {
  7891. jQuery.each( { padding: "inner" + name, content: type, "": "outer" + name }, function( defaultExtra, funcName ) {
  7892. // margin is only for outerHeight, outerWidth
  7893. jQuery.fn[ funcName ] = function( margin, value ) {
  7894. var chainable = arguments.length && ( defaultExtra || typeof margin !== "boolean" ),
  7895. extra = defaultExtra || ( margin === true || value === true ? "margin" : "border" );
  7896. return access( this, function( elem, type, value ) {
  7897. var doc;
  7898. if ( jQuery.isWindow( elem ) ) {
  7899. // As of 5/8/2012 this will yield incorrect results for Mobile Safari, but there
  7900. // isn't a whole lot we can do. See pull request at this URL for discussion:
  7901. // https://github.com/jquery/jquery/pull/764
  7902. return elem.document.documentElement[ "client" + name ];
  7903. }
  7904. // Get document width or height
  7905. if ( elem.nodeType === 9 ) {
  7906. doc = elem.documentElement;
  7907. // Either scroll[Width/Height] or offset[Width/Height] or client[Width/Height],
  7908. // whichever is greatest
  7909. return Math.max(
  7910. elem.body[ "scroll" + name ], doc[ "scroll" + name ],
  7911. elem.body[ "offset" + name ], doc[ "offset" + name ],
  7912. doc[ "client" + name ]
  7913. );
  7914. }
  7915. return value === undefined ?
  7916. // Get width or height on the element, requesting but not forcing parseFloat
  7917. jQuery.css( elem, type, extra ) :
  7918. // Set width or height on the element
  7919. jQuery.style( elem, type, value, extra );
  7920. }, type, chainable ? margin : undefined, chainable, null );
  7921. };
  7922. });
  7923. });
  7924. // The number of elements contained in the matched element set
  7925. jQuery.fn.size = function() {
  7926. return this.length;
  7927. };
  7928. jQuery.fn.andSelf = jQuery.fn.addBack;
  7929. // Register as a named AMD module, since jQuery can be concatenated with other
  7930. // files that may use define, but not via a proper concatenation script that
  7931. // understands anonymous AMD modules. A named AMD is safest and most robust
  7932. // way to register. Lowercase jquery is used because AMD module names are
  7933. // derived from file names, and jQuery is normally delivered in a lowercase
  7934. // file name. Do this after creating the global so that if an AMD module wants
  7935. // to call noConflict to hide this version of jQuery, it will work.
  7936. if ( typeof define === "function" && define.amd ) {
  7937. define( "jquery", [], function() {
  7938. return jQuery;
  7939. });
  7940. }
  7941. var
  7942. // Map over jQuery in case of overwrite
  7943. _jQuery = window.jQuery,
  7944. // Map over the $ in case of overwrite
  7945. _$ = window.$;
  7946. jQuery.noConflict = function( deep ) {
  7947. if ( window.$ === jQuery ) {
  7948. window.$ = _$;
  7949. }
  7950. if ( deep && window.jQuery === jQuery ) {
  7951. window.jQuery = _jQuery;
  7952. }
  7953. return jQuery;
  7954. };
  7955. // Expose jQuery and $ identifiers, even in
  7956. // AMD (#7102#comment:10, https://github.com/jquery/jquery/pull/557)
  7957. // and CommonJS for browser emulators (#13566)
  7958. if ( typeof noGlobal === strundefined ) {
  7959. window.jQuery = window.$ = jQuery;
  7960. }
  7961. return jQuery;
  7962. }));
  7963. define('select2/utils',[], function () {
  7964. var Utils = {};
  7965. Utils.Extend = function (ChildClass, SuperClass) {
  7966. var __hasProp = {}.hasOwnProperty;
  7967. function BaseConstructor () {
  7968. this.constructor = ChildClass;
  7969. }
  7970. for (var key in SuperClass) {
  7971. if (__hasProp.call(SuperClass, key)) {
  7972. ChildClass[key] = SuperClass[key];
  7973. }
  7974. }
  7975. BaseConstructor.prototype = SuperClass.prototype;
  7976. ChildClass.prototype = new BaseConstructor();
  7977. ChildClass.__super__ = SuperClass.prototype;
  7978. return ChildClass;
  7979. };
  7980. function getMethods (theClass) {
  7981. var proto = theClass.prototype;
  7982. var methods = [];
  7983. for (var methodName in proto) {
  7984. var m = proto[methodName];
  7985. if (typeof m !== 'function') {
  7986. continue;
  7987. }
  7988. if (methodName === 'constructor') {
  7989. continue;
  7990. }
  7991. methods.push(methodName);
  7992. }
  7993. return methods;
  7994. }
  7995. Utils.Decorate = function (SuperClass, DecoratorClass) {
  7996. var decoratedMethods = getMethods(DecoratorClass);
  7997. var superMethods = getMethods(SuperClass);
  7998. function DecoratedClass () {
  7999. var unshift = Array.prototype.unshift;
  8000. var argCount = DecoratorClass.prototype.constructor.length;
  8001. var calledConstructor = SuperClass.prototype.constructor;
  8002. if (argCount > 0) {
  8003. unshift.call(arguments, SuperClass.prototype.constructor);
  8004. calledConstructor = DecoratorClass.prototype.constructor;
  8005. }
  8006. calledConstructor.apply(this, arguments);
  8007. }
  8008. DecoratorClass.displayName = SuperClass.displayName;
  8009. function ctr () {
  8010. this.constructor = DecoratedClass;
  8011. }
  8012. DecoratedClass.prototype = new ctr();
  8013. for (var m = 0; m < superMethods.length; m++) {
  8014. var superMethod = superMethods[m];
  8015. DecoratedClass.prototype[superMethod] =
  8016. SuperClass.prototype[superMethod];
  8017. }
  8018. var calledMethod = function (methodName) {
  8019. // Stub out the original method if it's not decorating an actual method
  8020. var originalMethod = function () {};
  8021. if (methodName in DecoratedClass.prototype) {
  8022. originalMethod = DecoratedClass.prototype[methodName];
  8023. }
  8024. var decoratedMethod = DecoratorClass.prototype[methodName];
  8025. return function () {
  8026. var unshift = Array.prototype.unshift;
  8027. unshift.call(arguments, originalMethod);
  8028. return decoratedMethod.apply(this, arguments);
  8029. };
  8030. };
  8031. for (var d = 0; d < decoratedMethods.length; d++) {
  8032. var decoratedMethod = decoratedMethods[d];
  8033. DecoratedClass.prototype[decoratedMethod] = calledMethod(decoratedMethod);
  8034. }
  8035. return DecoratedClass;
  8036. };
  8037. var Observable = function () {
  8038. this.listeners = {};
  8039. };
  8040. Observable.prototype.on = function (event, callback) {
  8041. this.listeners = this.listeners || {};
  8042. if (event in this.listeners) {
  8043. this.listeners[event].push(callback);
  8044. } else {
  8045. this.listeners[event] = [callback];
  8046. }
  8047. };
  8048. Observable.prototype.trigger = function (event) {
  8049. var slice = Array.prototype.slice;
  8050. this.listeners = this.listeners || {};
  8051. if (event in this.listeners) {
  8052. this.invoke(this.listeners[event], slice.call(arguments, 1));
  8053. }
  8054. if ('*' in this.listeners) {
  8055. this.invoke(this.listeners['*'], arguments);
  8056. }
  8057. };
  8058. Observable.prototype.invoke = function (listeners, params) {
  8059. for (var i = 0, len = listeners.length; i < len; i++) {
  8060. listeners[i].apply(this, params);
  8061. }
  8062. };
  8063. Utils.Observable = Observable;
  8064. Utils.generateChars = function (length) {
  8065. var chars = '';
  8066. for (var i = 0; i < length; i++) {
  8067. var randomChar = Math.floor(Math.random() * 36);
  8068. chars += randomChar.toString(36);
  8069. }
  8070. return chars;
  8071. };
  8072. Utils.bind = function (func, context) {
  8073. return function () {
  8074. func.apply(context, arguments);
  8075. };
  8076. };
  8077. return Utils;
  8078. });
  8079. define('select2/results',[
  8080. 'jquery',
  8081. './utils'
  8082. ], function ($, Utils) {
  8083. function Results ($element, options, dataAdapter) {
  8084. this.$element = $element;
  8085. this.data = dataAdapter;
  8086. this.options = options;
  8087. Results.__super__.constructor.call(this);
  8088. }
  8089. Utils.Extend(Results, Utils.Observable);
  8090. Results.prototype.render = function () {
  8091. var $results = $(
  8092. '<ul class="select2-results__options" role="tree"></ul>'
  8093. );
  8094. if (this.options.get('multiple')) {
  8095. $results.attr('aria-multiselectable', 'true');
  8096. }
  8097. this.$results = $results;
  8098. return $results;
  8099. };
  8100. Results.prototype.clear = function () {
  8101. this.$results.empty();
  8102. };
  8103. Results.prototype.displayMessage = function (params) {
  8104. this.clear();
  8105. this.hideLoading();
  8106. var $message = $(
  8107. '<li role="treeitem" class="select2-results__option"></li>'
  8108. );
  8109. var message = this.options.get('translations').get(params.message);
  8110. $message.text(message(params.args));
  8111. this.$results.append($message);
  8112. };
  8113. Results.prototype.append = function (data) {
  8114. this.hideLoading();
  8115. var $options = [];
  8116. if (data.results == null || data.results.length === 0) {
  8117. if (this.$results.children().length === 0) {
  8118. this.trigger('results:message', {
  8119. message: 'noResults'
  8120. });
  8121. }
  8122. return;
  8123. }
  8124. data.results = this.sort(data.results);
  8125. for (var d = 0; d < data.results.length; d++) {
  8126. var item = data.results[d];
  8127. var $option = this.option(item);
  8128. $options.push($option);
  8129. }
  8130. this.$results.append($options);
  8131. };
  8132. Results.prototype.position = function ($results, $dropdown) {
  8133. var $resultsContainer = $dropdown.find('.select2-results');
  8134. $resultsContainer.append($results);
  8135. };
  8136. Results.prototype.sort = function (data) {
  8137. var sorter = this.options.get('sorter');
  8138. return sorter(data);
  8139. };
  8140. Results.prototype.setClasses = function () {
  8141. var self = this;
  8142. this.data.current(function (selected) {
  8143. var selectedIds = $.map(selected, function (s) {
  8144. return s.id.toString();
  8145. });
  8146. var $options = self.$results
  8147. .find('.select2-results__option[aria-selected]');
  8148. $options.each(function () {
  8149. var $option = $(this);
  8150. var item = $.data(this, 'data');
  8151. if (item.id != null && selectedIds.indexOf(item.id.toString()) > -1) {
  8152. $option.attr('aria-selected', 'true');
  8153. } else {
  8154. $option.attr('aria-selected', 'false');
  8155. }
  8156. });
  8157. var $selected = $options.filter('[aria-selected=true]');
  8158. // Check if there are any selected options
  8159. if ($selected.length > 0) {
  8160. // If there are selected options, highlight the first
  8161. $selected.first().trigger('mouseenter');
  8162. } else {
  8163. // If there are no selected options, highlight the first option
  8164. // in the dropdown
  8165. $options.first().trigger('mouseenter');
  8166. }
  8167. });
  8168. };
  8169. Results.prototype.showLoading = function (params) {
  8170. this.hideLoading();
  8171. var loadingMore = this.options.get('translations').get('searching');
  8172. var loading = {
  8173. disabled: true,
  8174. loading: true,
  8175. text: loadingMore(params)
  8176. };
  8177. var $loading = this.option(loading);
  8178. $loading.className += ' loading-results';
  8179. this.$results.prepend($loading);
  8180. };
  8181. Results.prototype.hideLoading = function () {
  8182. this.$results.find('.loading-results').remove();
  8183. };
  8184. Results.prototype.option = function (data) {
  8185. var option = document.createElement('li');
  8186. option.className = 'select2-results__option';
  8187. var attrs = {
  8188. 'role': 'treeitem',
  8189. 'aria-selected': 'false'
  8190. };
  8191. if (data.disabled) {
  8192. delete attrs['aria-selected'];
  8193. attrs['aria-disabled'] = 'true';
  8194. }
  8195. if (data.id == null) {
  8196. delete attrs['aria-selected'];
  8197. }
  8198. if (data._resultId != null) {
  8199. option.id = data._resultId;
  8200. }
  8201. if (data.children) {
  8202. attrs.role = 'group';
  8203. attrs['aria-label'] = data.text;
  8204. delete attrs['aria-selected'];
  8205. }
  8206. for (var attr in attrs) {
  8207. var val = attrs[attr];
  8208. option.setAttribute(attr, val);
  8209. }
  8210. if (data.children) {
  8211. var $option = $(option);
  8212. var label = document.createElement('strong');
  8213. label.className = 'select2-results__group';
  8214. var $label = $(label);
  8215. this.template(data, label);
  8216. var $children = [];
  8217. for (var c = 0; c < data.children.length; c++) {
  8218. var child = data.children[c];
  8219. var $child = this.option(child);
  8220. $children.push($child);
  8221. }
  8222. var $childrenContainer = $('<ul></ul>', {
  8223. 'class': 'select2-results__options select2-results__options--nested'
  8224. });
  8225. $childrenContainer.append($children);
  8226. $option.append(label);
  8227. $option.append($childrenContainer);
  8228. } else {
  8229. this.template(data, option);
  8230. }
  8231. $.data(option, 'data', data);
  8232. return option;
  8233. };
  8234. Results.prototype.bind = function (container, $container) {
  8235. var self = this;
  8236. var id = container.id + '-results';
  8237. this.$results.attr('id', id);
  8238. container.on('results:all', function (params) {
  8239. self.clear();
  8240. self.append(params.data);
  8241. if (container.isOpen()) {
  8242. self.setClasses();
  8243. }
  8244. });
  8245. container.on('results:append', function (params) {
  8246. self.append(params.data);
  8247. if (container.isOpen()) {
  8248. self.setClasses();
  8249. }
  8250. });
  8251. container.on('query', function (params) {
  8252. self.showLoading(params);
  8253. });
  8254. container.on('select', function () {
  8255. if (!container.isOpen()) {
  8256. return;
  8257. }
  8258. self.setClasses();
  8259. });
  8260. container.on('unselect', function () {
  8261. if (!container.isOpen()) {
  8262. return;
  8263. }
  8264. self.setClasses();
  8265. });
  8266. container.on('open', function () {
  8267. // When the dropdown is open, aria-expended="true"
  8268. self.$results.attr('aria-expanded', 'true');
  8269. self.$results.attr('aria-hidden', 'false');
  8270. self.setClasses();
  8271. self.ensureHighlightVisible();
  8272. });
  8273. container.on('close', function () {
  8274. // When the dropdown is closed, aria-expended="false"
  8275. self.$results.attr('aria-expanded', 'false');
  8276. self.$results.attr('aria-hidden', 'true');
  8277. self.$results.removeAttr('aria-activedescendant');
  8278. });
  8279. container.on('results:select', function () {
  8280. var $highlighted = self.getHighlightedResults();
  8281. if ($highlighted.length === 0) {
  8282. return;
  8283. }
  8284. var data = $highlighted.data('data');
  8285. if ($highlighted.attr('aria-selected') == 'true') {
  8286. self.trigger('unselect', {
  8287. data: data
  8288. });
  8289. } else {
  8290. self.trigger('select', {
  8291. data: data
  8292. });
  8293. }
  8294. });
  8295. container.on('results:previous', function () {
  8296. var $highlighted = self.getHighlightedResults();
  8297. var $options = self.$results.find('[aria-selected]');
  8298. var currentIndex = $options.index($highlighted);
  8299. // If we are already at te top, don't move further
  8300. if (currentIndex === 0) {
  8301. return;
  8302. }
  8303. var nextIndex = currentIndex - 1;
  8304. // If none are highlighted, highlight the first
  8305. if ($highlighted.length === 0) {
  8306. nextIndex = 0;
  8307. }
  8308. var $next = $options.eq(nextIndex);
  8309. $next.trigger('mouseenter');
  8310. var currentOffset = self.$results.offset().top;
  8311. var nextTop = $next.offset().top;
  8312. var nextOffset = self.$results.scrollTop() + (nextTop - currentOffset);
  8313. if (nextIndex === 0) {
  8314. self.$results.scrollTop(0);
  8315. } else if (nextTop - currentOffset < 0) {
  8316. self.$results.scrollTop(nextOffset);
  8317. }
  8318. });
  8319. container.on('results:next', function () {
  8320. var $highlighted = self.getHighlightedResults();
  8321. var $options = self.$results.find('[aria-selected]');
  8322. var currentIndex = $options.index($highlighted);
  8323. var nextIndex = currentIndex + 1;
  8324. // If we are at the last option, stay there
  8325. if (nextIndex >= $options.length) {
  8326. return;
  8327. }
  8328. var $next = $options.eq(nextIndex);
  8329. $next.trigger('mouseenter');
  8330. var currentOffset = self.$results.offset().top +
  8331. self.$results.outerHeight(false);
  8332. var nextBottom = $next.offset().top + $next.outerHeight(false);
  8333. var nextOffset = self.$results.scrollTop() + nextBottom - currentOffset;
  8334. if (nextIndex === 0) {
  8335. self.$results.scrollTop(0);
  8336. } else if (nextBottom > currentOffset) {
  8337. self.$results.scrollTop(nextOffset);
  8338. }
  8339. });
  8340. container.on('results:focus', function (params) {
  8341. params.element.addClass('select2-results__option--highlighted');
  8342. });
  8343. container.on('results:message', function (params) {
  8344. self.trigger('results:message', params);
  8345. });
  8346. this.on('results:message', function (params) {
  8347. self.displayMessage(params);
  8348. });
  8349. if ($.fn.mousewheel) {
  8350. this.$results.on('mousewheel', function (e) {
  8351. var top = self.$results.scrollTop();
  8352. var bottom = (
  8353. self.$results.get(0).scrollHeight -
  8354. self.$results.scrollTop() +
  8355. e.deltaY
  8356. );
  8357. var isAtTop = e.deltaY > 0 && top - e.deltaY <= 0;
  8358. var isAtBottom = e.deltaY < 0 && bottom <= self.$results.height();
  8359. if (isAtTop) {
  8360. self.$results.scrollTop(0);
  8361. e.preventDefault();
  8362. e.stopPropagation();
  8363. } else if (isAtBottom) {
  8364. self.$results.scrollTop(
  8365. self.$results.get(0).scrollHeight - self.$results.height()
  8366. );
  8367. e.preventDefault();
  8368. e.stopPropagation();
  8369. }
  8370. });
  8371. }
  8372. this.$results.on('mouseup', '.select2-results__option[aria-selected]',
  8373. function (evt) {
  8374. var $this = $(this);
  8375. var data = $this.data('data');
  8376. if ($this.attr('aria-selected') === 'true') {
  8377. self.trigger('unselect', {
  8378. originalEvent: evt,
  8379. data: data
  8380. });
  8381. return;
  8382. }
  8383. self.trigger('select', {
  8384. originalEvent: evt,
  8385. data: data
  8386. });
  8387. });
  8388. this.$results.on('mouseenter', '.select2-results__option[aria-selected]',
  8389. function (evt) {
  8390. var data = $(this).data('data');
  8391. self.getHighlightedResults()
  8392. .removeClass('select2-results__option--highlighted');
  8393. self.trigger('results:focus', {
  8394. data: data,
  8395. element: $(this)
  8396. });
  8397. });
  8398. };
  8399. Results.prototype.getHighlightedResults = function () {
  8400. var $highlighted = this.$results
  8401. .find('.select2-results__option--highlighted');
  8402. return $highlighted;
  8403. };
  8404. Results.prototype.destroy = function () {
  8405. this.$results.remove();
  8406. };
  8407. Results.prototype.ensureHighlightVisible = function () {
  8408. var $highlighted = this.getHighlightedResults();
  8409. if ($highlighted.length === 0) {
  8410. return;
  8411. }
  8412. var $options = this.$results.find('[aria-selected]');
  8413. var currentIndex = $options.index($highlighted);
  8414. var currentOffset = this.$results.offset().top;
  8415. var nextTop = $highlighted.offset().top;
  8416. var nextOffset = this.$results.scrollTop() + (nextTop - currentOffset);
  8417. var offsetDelta = nextTop - currentOffset;
  8418. nextOffset -= $highlighted.outerHeight(false) * 2;
  8419. if (currentIndex <= 2) {
  8420. this.$results.scrollTop(0);
  8421. } else if (offsetDelta > this.$results.outerHeight() || offsetDelta < 0) {
  8422. this.$results.scrollTop(nextOffset);
  8423. }
  8424. };
  8425. Results.prototype.template = function (result, container) {
  8426. var template = this.options.get('templateResult');
  8427. container.innerHTML = template(result);
  8428. };
  8429. return Results;
  8430. });
  8431. define('select2/keys',[
  8432. ], function () {
  8433. var KEYS = {
  8434. BACKSPACE: 8,
  8435. TAB: 9,
  8436. ENTER: 13,
  8437. SHIFT: 16,
  8438. CTRL: 17,
  8439. ALT: 18,
  8440. ESC: 27,
  8441. SPACE: 32,
  8442. PAGE_UP: 33,
  8443. PAGE_DOWN: 34,
  8444. END: 35,
  8445. HOME: 36,
  8446. LEFT: 37,
  8447. UP: 38,
  8448. RIGHT: 39,
  8449. DOWN: 40,
  8450. DELETE: 46,
  8451. isArrow: function (k) {
  8452. k = k.which ? k.which : k;
  8453. switch (k) {
  8454. case KEY.LEFT:
  8455. case KEY.RIGHT:
  8456. case KEY.UP:
  8457. case KEY.DOWN:
  8458. return true;
  8459. }
  8460. return false;
  8461. }
  8462. };
  8463. return KEYS;
  8464. });
  8465. define('select2/selection/base',[
  8466. '../utils',
  8467. '../keys'
  8468. ], function (Utils, KEYS) {
  8469. function BaseSelection ($element, options) {
  8470. this.$element = $element;
  8471. this.options = options;
  8472. BaseSelection.__super__.constructor.call(this);
  8473. }
  8474. Utils.Extend(BaseSelection, Utils.Observable);
  8475. BaseSelection.prototype.render = function () {
  8476. throw new Error('The `render` method must be defined in child classes.');
  8477. };
  8478. BaseSelection.prototype.bind = function (container, $container) {
  8479. var self = this;
  8480. var id = container.id + '-container';
  8481. var resultsId = container.id + '-results';
  8482. this.container = container;
  8483. this.$selection.attr('aria-owns', resultsId);
  8484. this.$selection.on('keydown', function (evt) {
  8485. self.trigger('keypress', evt);
  8486. if (evt.which === KEYS.SPACE) {
  8487. evt.preventDefault();
  8488. }
  8489. });
  8490. container.on('results:focus', function (params) {
  8491. self.$selection.attr('aria-activedescendant', params.data._resultId);
  8492. });
  8493. container.on('selection:update', function (params) {
  8494. self.update(params.data);
  8495. });
  8496. container.on('open', function () {
  8497. // When the dropdown is open, aria-expanded="true"
  8498. self.$selection.attr('aria-expanded', 'true');
  8499. self._attachCloseHandler(container);
  8500. });
  8501. container.on('close', function () {
  8502. // When the dropdown is closed, aria-expanded="false"
  8503. self.$selection.attr('aria-expanded', 'false');
  8504. self.$selection.removeAttr('aria-activedescendant');
  8505. self.$selection.focus();
  8506. self._detachCloseHandler(container);
  8507. });
  8508. };
  8509. BaseSelection.prototype._attachCloseHandler = function (container) {
  8510. var self = this;
  8511. $(document.body).on('mousedown.select2.' + container.id, function (e) {
  8512. var $target = $(e.target);
  8513. var $select = $target.closest('.select2');
  8514. var $all = $('.select2.select2-container--open');
  8515. $all.each(function () {
  8516. var $this = $(this);
  8517. if (this == $select[0]) {
  8518. return;
  8519. }
  8520. var $element = $this.data('element');
  8521. $element.select2('close');
  8522. });
  8523. });
  8524. $(window).on('scroll.select2.' + container.id, function (e) {
  8525. self.trigger('close');
  8526. });
  8527. };
  8528. BaseSelection.prototype._detachCloseHandler = function (container) {
  8529. $(document.body).off('mousedown.select2.' + container.id);
  8530. $(window).off('scroll.select2.' + container.id);
  8531. };
  8532. BaseSelection.prototype.position = function ($selection, $container) {
  8533. var $selectionContainer = $container.find('.selection');
  8534. $selectionContainer.append($selection);
  8535. };
  8536. BaseSelection.prototype.destroy = function () {
  8537. this._detachCloseHandler(this.container);
  8538. };
  8539. BaseSelection.prototype.update = function (data) {
  8540. throw new Error('The `update` method must be defined in child classes.');
  8541. };
  8542. return BaseSelection;
  8543. });
  8544. define('select2/selection/single',[
  8545. './base',
  8546. '../utils',
  8547. '../keys'
  8548. ], function (BaseSelection, Utils, KEYS) {
  8549. function SingleSelection () {
  8550. SingleSelection.__super__.constructor.apply(this, arguments);
  8551. }
  8552. Utils.Extend(SingleSelection, BaseSelection);
  8553. SingleSelection.prototype.render = function () {
  8554. var $selection = $(
  8555. '<span class="select2-selection select2-selection--single" tabindex="0"' +
  8556. ' role="combobox" aria-autocomplete="list" aria-haspopup="true"' +
  8557. ' aria-expanded="false">' +
  8558. '<span class="select2-selection__rendered"></span>' +
  8559. '<span class="select2-selection__arrow" role="presentation">' +
  8560. '<b role="presentation"></b>' +
  8561. '</span>' +
  8562. '</span>'
  8563. );
  8564. $selection.attr('title', this.$element.attr('title'));
  8565. this.$selection = $selection;
  8566. return $selection;
  8567. };
  8568. SingleSelection.prototype.bind = function (container, $container) {
  8569. var self = this;
  8570. SingleSelection.__super__.bind.apply(this, arguments);
  8571. var id = container.id + '-container';
  8572. this.$selection.find('.select2-selection__rendered').attr('id', id);
  8573. this.$selection.attr('aria-labelledby', id);
  8574. this.$selection.on('mousedown', function (evt) {
  8575. // Only respond to left clicks
  8576. if (evt.which !== 1) {
  8577. return;
  8578. }
  8579. self.trigger('toggle', {
  8580. originalEvent: evt
  8581. });
  8582. });
  8583. this.$selection.on('focus', function (evt) {
  8584. // User focuses on the container
  8585. });
  8586. this.$selection.on('blur', function (evt) {
  8587. // User exits the container
  8588. });
  8589. container.on('enable', function () {
  8590. self.$selection.attr('tabindex', '0');
  8591. });
  8592. container.on('disable', function () {
  8593. self.$selection.attr('tabindex', '-1');
  8594. });
  8595. container.on('selection:update', function (params) {
  8596. self.update(params.data);
  8597. });
  8598. };
  8599. SingleSelection.prototype.clear = function () {
  8600. this.$selection.find('.select2-selection__rendered').empty();
  8601. };
  8602. SingleSelection.prototype.display = function (data) {
  8603. var template = this.options.get('templateSelection');
  8604. return template(data);
  8605. };
  8606. SingleSelection.prototype.selectionContainer = function () {
  8607. return $('<span></span>');
  8608. };
  8609. SingleSelection.prototype.update = function (data) {
  8610. if (data.length === 0) {
  8611. this.clear();
  8612. return;
  8613. }
  8614. var selection = data[0];
  8615. var formatted = this.display(selection);
  8616. this.$selection.find('.select2-selection__rendered').html(formatted);
  8617. };
  8618. return SingleSelection;
  8619. });
  8620. define('select2/selection/multiple',[
  8621. './base',
  8622. '../utils'
  8623. ], function (BaseSelection, Utils) {
  8624. function MultipleSelection ($element, options) {
  8625. MultipleSelection.__super__.constructor.apply(this, arguments);
  8626. }
  8627. Utils.Extend(MultipleSelection, BaseSelection);
  8628. MultipleSelection.prototype.render = function () {
  8629. var $selection = $(
  8630. '<span class="select2-selection select2-selection--multiple"' +
  8631. ' tabindex="0" role="combobox" aria-autocomplete="list"' +
  8632. ' aria-haspopup="true" aria-expanded="false">' +
  8633. '<ul class="select2-selection__rendered"></ul>' +
  8634. '</span>'
  8635. );
  8636. $selection.attr('title', this.$element.attr('title'));
  8637. this.$selection = $selection;
  8638. return $selection;
  8639. };
  8640. MultipleSelection.prototype.bind = function (container, $container) {
  8641. var self = this;
  8642. MultipleSelection.__super__.bind.apply(this, arguments);
  8643. this.$selection.on('click', function (evt) {
  8644. self.trigger('toggle', {
  8645. originalEvent: evt
  8646. });
  8647. });
  8648. this.$selection.on('click', '.select2-selection__choice__remove',
  8649. function (evt) {
  8650. var $remove = $(this);
  8651. var $selection = $remove.parent();
  8652. var data = $selection.data('data');
  8653. self.trigger('unselect', {
  8654. originalEvent: evt,
  8655. data: data
  8656. });
  8657. });
  8658. container.on('enable', function () {
  8659. self.$selection.attr('tabindex', '0');
  8660. });
  8661. container.on('disable', function () {
  8662. self.$selection.attr('tabindex', '-1');
  8663. });
  8664. };
  8665. MultipleSelection.prototype.clear = function () {
  8666. this.$selection.find('.select2-selection__rendered').empty();
  8667. };
  8668. MultipleSelection.prototype.display = function (data) {
  8669. var template = this.options.get('templateSelection');
  8670. return template(data);
  8671. };
  8672. MultipleSelection.prototype.selectionContainer = function () {
  8673. var $container = $(
  8674. '<li class="select2-selection__choice">' +
  8675. '<span class="select2-selection__choice__remove" role="presentation">' +
  8676. '&times;' +
  8677. '</span>' +
  8678. '</li>'
  8679. );
  8680. return $container;
  8681. };
  8682. MultipleSelection.prototype.update = function (data) {
  8683. this.clear();
  8684. if (data.length === 0) {
  8685. return;
  8686. }
  8687. var $selections = [];
  8688. for (var d = 0; d < data.length; d++) {
  8689. var selection = data[d];
  8690. var formatted = this.display(selection);
  8691. var $selection = this.selectionContainer();
  8692. $selection.append(formatted);
  8693. $selection.data('data', selection);
  8694. $selections.push($selection);
  8695. }
  8696. this.$selection.find('.select2-selection__rendered').append($selections);
  8697. };
  8698. return MultipleSelection;
  8699. });
  8700. define('select2/selection/placeholder',[
  8701. '../utils'
  8702. ], function (Utils) {
  8703. function Placeholder (decorated, $element, options) {
  8704. this.placeholder = this.normalizePlaceholder(options.get('placeholder'));
  8705. decorated.call(this, $element, options);
  8706. }
  8707. Placeholder.prototype.normalizePlaceholder = function (_, placeholder) {
  8708. if (typeof placeholder === 'string') {
  8709. placeholder = {
  8710. id: '',
  8711. text: placeholder
  8712. };
  8713. }
  8714. return placeholder;
  8715. };
  8716. Placeholder.prototype.createPlaceholder = function (decorated, placeholder) {
  8717. var $placeholder = this.selectionContainer();
  8718. $placeholder.html(this.display(placeholder));
  8719. $placeholder.addClass('select2-selection__placeholder')
  8720. .removeClass('select2-selection__choice');
  8721. return $placeholder;
  8722. };
  8723. Placeholder.prototype.update = function (decorated, data) {
  8724. var singlePlaceholder = (
  8725. data.length == 1 && data[0].id != this.placeholder.id
  8726. );
  8727. var multipleSelections = data.length > 1;
  8728. if (multipleSelections || singlePlaceholder) {
  8729. return decorated.call(this, data);
  8730. }
  8731. this.clear();
  8732. var $placeholder = this.createPlaceholder(this.placeholder);
  8733. this.$selection.find('.select2-selection__rendered').append($placeholder);
  8734. };
  8735. return Placeholder;
  8736. });
  8737. define('select2/selection/allowClear',[
  8738. ], function () {
  8739. function AllowClear () { }
  8740. AllowClear.prototype.bind = function (decorated, container, $container) {
  8741. var self = this;
  8742. decorated.call(this, container, $container);
  8743. this.$selection.on('mousedown', '.select2-selection__clear',
  8744. function (evt) {
  8745. // Ignore the event if it is disabled
  8746. if (self.options.get('disabled')) {
  8747. return;
  8748. }
  8749. evt.stopPropagation();
  8750. self.$element.val(self.placeholder.id).trigger('change');
  8751. self.trigger('toggle');
  8752. });
  8753. };
  8754. AllowClear.prototype.update = function (decorated, data) {
  8755. decorated.call(this, data);
  8756. if (this.$selection.find('.select2-selection__placeholder').length > 0) {
  8757. return;
  8758. }
  8759. var $remove = $(
  8760. '<span class="select2-selection__clear">' +
  8761. '&times;' +
  8762. '</span>'
  8763. );
  8764. this.$selection.find('.select2-selection__rendered').append($remove);
  8765. };
  8766. return AllowClear;
  8767. });
  8768. define('select2/selection/search',[
  8769. '../utils',
  8770. '../keys'
  8771. ], function (Utils, KEYS) {
  8772. function Search (decorated, $element, options) {
  8773. decorated.call(this, $element, options);
  8774. }
  8775. Search.prototype.render = function (decorated) {
  8776. var $search = $(
  8777. '<li class="select2-search select2-search--inline">' +
  8778. '<input class="select2-search__field" type="search" tabindex="-1"' +
  8779. ' role="textbox" />' +
  8780. '</li>'
  8781. );
  8782. this.$searchContainer = $search;
  8783. this.$search = $search.find('input');
  8784. var $rendered = decorated.call(this);
  8785. return $rendered;
  8786. };
  8787. Search.prototype.bind = function (decorated, container, $container) {
  8788. var self = this;
  8789. decorated.call(this, container, $container);
  8790. container.on('open', function () {
  8791. self.$search.attr('tabindex', 0);
  8792. self.$search.focus();
  8793. });
  8794. container.on('close', function () {
  8795. self.$search.attr('tabindex', -1);
  8796. self.$search.val('');
  8797. });
  8798. container.on('enable', function () {
  8799. self.$search.prop('disabled', false);
  8800. });
  8801. container.on('disable', function () {
  8802. self.$search.prop('disabled', true);
  8803. });
  8804. this.$selection.on('keydown', '.select2-search--inline', function (evt) {
  8805. evt.stopPropagation();
  8806. self.trigger('keypress', evt);
  8807. self._keyUpPrevented = evt.isDefaultPrevented();
  8808. var key = evt.which;
  8809. if (key === KEYS.BACKSPACE && self.$search.val() === '') {
  8810. var $previousChoice = self.$searchContainer
  8811. .prev('.select2-selection__choice');
  8812. if ($previousChoice.length > 0) {
  8813. var item = $previousChoice.data('data');
  8814. self.searchRemoveChoice(item);
  8815. }
  8816. }
  8817. });
  8818. this.$selection.on('keyup', '.select2-search--inline', function (evt) {
  8819. self.handleSearch(evt);
  8820. });
  8821. };
  8822. Search.prototype.createPlaceholder = function (decorated, placeholder) {
  8823. this.$search.attr('placeholder', placeholder.text);
  8824. };
  8825. Search.prototype.update = function (decorated, data) {
  8826. this.$search.attr('placeholder', '');
  8827. decorated.call(this, data);
  8828. this.$selection.find('.select2-selection__rendered')
  8829. .append(this.$searchContainer);
  8830. this.resizeSearch();
  8831. };
  8832. Search.prototype.handleSearch = function () {
  8833. this.resizeSearch();
  8834. if (!this._keyUpPrevented) {
  8835. var input = this.$search.val();
  8836. this.trigger('query', {
  8837. term: input
  8838. });
  8839. }
  8840. this._keyUpPrevented = false;
  8841. };
  8842. Search.prototype.searchRemoveChoice = function (decorated, item) {
  8843. this.trigger('unselect', {
  8844. data: item
  8845. });
  8846. this.trigger('open');
  8847. this.$search.val(item.text + ' ');
  8848. };
  8849. Search.prototype.resizeSearch = function () {
  8850. this.$search.css('width', '25px');
  8851. var width = '';
  8852. if (this.$search.attr('placeholder') !== '') {
  8853. width = this.$selection.innerWidth();
  8854. width -= this.$selection.find('.select2-selection__rendered')
  8855. .innerWidth();
  8856. width = width + 'px';
  8857. } else {
  8858. var minimumWidth = this.$search.val().length + 1;
  8859. width = (minimumWidth * 0.75) + 'em';
  8860. }
  8861. this.$search.css('width', width);
  8862. };
  8863. return Search;
  8864. });
  8865. define('select2/selection/eventRelay',[
  8866. 'jquery'
  8867. ], function ($) {
  8868. function EventRelay () { }
  8869. EventRelay.prototype.bind = function (decorated, container, $container) {
  8870. var self = this;
  8871. var relayEvents = ['open', 'close'];
  8872. decorated.call(this, container, $container);
  8873. container.on('*', function (name, params) {
  8874. if (relayEvents.indexOf(name) === -1) {
  8875. return;
  8876. }
  8877. var evt = $.Event('select2:' + name, params);
  8878. self.$element.trigger(evt);
  8879. });
  8880. };
  8881. return EventRelay;
  8882. });
  8883. define('select2/translation',[
  8884. ], function () {
  8885. function Translation (dict) {
  8886. this.dict = dict || {};
  8887. }
  8888. Translation.prototype.all = function () {
  8889. return this.dict;
  8890. };
  8891. Translation.prototype.get = function (key) {
  8892. return this.dict[key];
  8893. };
  8894. Translation.prototype.extend = function (translation) {
  8895. this.dict = $.extend({}, translation.all(), this.dict);
  8896. };
  8897. // Static functions
  8898. Translation._cache = {};
  8899. Translation.loadPath = function (path) {
  8900. if (!(path in Translation._cache)) {
  8901. var translations = require(path);
  8902. Translation._cache[path] = translations;
  8903. }
  8904. return new Translation(Translation._cache[path]);
  8905. };
  8906. return Translation;
  8907. });
  8908. define('select2/diacritics',[
  8909. ], function () {
  8910. var diacritics = {
  8911. '\u24B6': 'A',
  8912. '\uFF21': 'A',
  8913. '\u00C0': 'A',
  8914. '\u00C1': 'A',
  8915. '\u00C2': 'A',
  8916. '\u1EA6': 'A',
  8917. '\u1EA4': 'A',
  8918. '\u1EAA': 'A',
  8919. '\u1EA8': 'A',
  8920. '\u00C3': 'A',
  8921. '\u0100': 'A',
  8922. '\u0102': 'A',
  8923. '\u1EB0': 'A',
  8924. '\u1EAE': 'A',
  8925. '\u1EB4': 'A',
  8926. '\u1EB2': 'A',
  8927. '\u0226': 'A',
  8928. '\u01E0': 'A',
  8929. '\u00C4': 'A',
  8930. '\u01DE': 'A',
  8931. '\u1EA2': 'A',
  8932. '\u00C5': 'A',
  8933. '\u01FA': 'A',
  8934. '\u01CD': 'A',
  8935. '\u0200': 'A',
  8936. '\u0202': 'A',
  8937. '\u1EA0': 'A',
  8938. '\u1EAC': 'A',
  8939. '\u1EB6': 'A',
  8940. '\u1E00': 'A',
  8941. '\u0104': 'A',
  8942. '\u023A': 'A',
  8943. '\u2C6F': 'A',
  8944. '\uA732': 'AA',
  8945. '\u00C6': 'AE',
  8946. '\u01FC': 'AE',
  8947. '\u01E2': 'AE',
  8948. '\uA734': 'AO',
  8949. '\uA736': 'AU',
  8950. '\uA738': 'AV',
  8951. '\uA73A': 'AV',
  8952. '\uA73C': 'AY',
  8953. '\u24B7': 'B',
  8954. '\uFF22': 'B',
  8955. '\u1E02': 'B',
  8956. '\u1E04': 'B',
  8957. '\u1E06': 'B',
  8958. '\u0243': 'B',
  8959. '\u0182': 'B',
  8960. '\u0181': 'B',
  8961. '\u24B8': 'C',
  8962. '\uFF23': 'C',
  8963. '\u0106': 'C',
  8964. '\u0108': 'C',
  8965. '\u010A': 'C',
  8966. '\u010C': 'C',
  8967. '\u00C7': 'C',
  8968. '\u1E08': 'C',
  8969. '\u0187': 'C',
  8970. '\u023B': 'C',
  8971. '\uA73E': 'C',
  8972. '\u24B9': 'D',
  8973. '\uFF24': 'D',
  8974. '\u1E0A': 'D',
  8975. '\u010E': 'D',
  8976. '\u1E0C': 'D',
  8977. '\u1E10': 'D',
  8978. '\u1E12': 'D',
  8979. '\u1E0E': 'D',
  8980. '\u0110': 'D',
  8981. '\u018B': 'D',
  8982. '\u018A': 'D',
  8983. '\u0189': 'D',
  8984. '\uA779': 'D',
  8985. '\u01F1': 'DZ',
  8986. '\u01C4': 'DZ',
  8987. '\u01F2': 'Dz',
  8988. '\u01C5': 'Dz',
  8989. '\u24BA': 'E',
  8990. '\uFF25': 'E',
  8991. '\u00C8': 'E',
  8992. '\u00C9': 'E',
  8993. '\u00CA': 'E',
  8994. '\u1EC0': 'E',
  8995. '\u1EBE': 'E',
  8996. '\u1EC4': 'E',
  8997. '\u1EC2': 'E',
  8998. '\u1EBC': 'E',
  8999. '\u0112': 'E',
  9000. '\u1E14': 'E',
  9001. '\u1E16': 'E',
  9002. '\u0114': 'E',
  9003. '\u0116': 'E',
  9004. '\u00CB': 'E',
  9005. '\u1EBA': 'E',
  9006. '\u011A': 'E',
  9007. '\u0204': 'E',
  9008. '\u0206': 'E',
  9009. '\u1EB8': 'E',
  9010. '\u1EC6': 'E',
  9011. '\u0228': 'E',
  9012. '\u1E1C': 'E',
  9013. '\u0118': 'E',
  9014. '\u1E18': 'E',
  9015. '\u1E1A': 'E',
  9016. '\u0190': 'E',
  9017. '\u018E': 'E',
  9018. '\u24BB': 'F',
  9019. '\uFF26': 'F',
  9020. '\u1E1E': 'F',
  9021. '\u0191': 'F',
  9022. '\uA77B': 'F',
  9023. '\u24BC': 'G',
  9024. '\uFF27': 'G',
  9025. '\u01F4': 'G',
  9026. '\u011C': 'G',
  9027. '\u1E20': 'G',
  9028. '\u011E': 'G',
  9029. '\u0120': 'G',
  9030. '\u01E6': 'G',
  9031. '\u0122': 'G',
  9032. '\u01E4': 'G',
  9033. '\u0193': 'G',
  9034. '\uA7A0': 'G',
  9035. '\uA77D': 'G',
  9036. '\uA77E': 'G',
  9037. '\u24BD': 'H',
  9038. '\uFF28': 'H',
  9039. '\u0124': 'H',
  9040. '\u1E22': 'H',
  9041. '\u1E26': 'H',
  9042. '\u021E': 'H',
  9043. '\u1E24': 'H',
  9044. '\u1E28': 'H',
  9045. '\u1E2A': 'H',
  9046. '\u0126': 'H',
  9047. '\u2C67': 'H',
  9048. '\u2C75': 'H',
  9049. '\uA78D': 'H',
  9050. '\u24BE': 'I',
  9051. '\uFF29': 'I',
  9052. '\u00CC': 'I',
  9053. '\u00CD': 'I',
  9054. '\u00CE': 'I',
  9055. '\u0128': 'I',
  9056. '\u012A': 'I',
  9057. '\u012C': 'I',
  9058. '\u0130': 'I',
  9059. '\u00CF': 'I',
  9060. '\u1E2E': 'I',
  9061. '\u1EC8': 'I',
  9062. '\u01CF': 'I',
  9063. '\u0208': 'I',
  9064. '\u020A': 'I',
  9065. '\u1ECA': 'I',
  9066. '\u012E': 'I',
  9067. '\u1E2C': 'I',
  9068. '\u0197': 'I',
  9069. '\u24BF': 'J',
  9070. '\uFF2A': 'J',
  9071. '\u0134': 'J',
  9072. '\u0248': 'J',
  9073. '\u24C0': 'K',
  9074. '\uFF2B': 'K',
  9075. '\u1E30': 'K',
  9076. '\u01E8': 'K',
  9077. '\u1E32': 'K',
  9078. '\u0136': 'K',
  9079. '\u1E34': 'K',
  9080. '\u0198': 'K',
  9081. '\u2C69': 'K',
  9082. '\uA740': 'K',
  9083. '\uA742': 'K',
  9084. '\uA744': 'K',
  9085. '\uA7A2': 'K',
  9086. '\u24C1': 'L',
  9087. '\uFF2C': 'L',
  9088. '\u013F': 'L',
  9089. '\u0139': 'L',
  9090. '\u013D': 'L',
  9091. '\u1E36': 'L',
  9092. '\u1E38': 'L',
  9093. '\u013B': 'L',
  9094. '\u1E3C': 'L',
  9095. '\u1E3A': 'L',
  9096. '\u0141': 'L',
  9097. '\u023D': 'L',
  9098. '\u2C62': 'L',
  9099. '\u2C60': 'L',
  9100. '\uA748': 'L',
  9101. '\uA746': 'L',
  9102. '\uA780': 'L',
  9103. '\u01C7': 'LJ',
  9104. '\u01C8': 'Lj',
  9105. '\u24C2': 'M',
  9106. '\uFF2D': 'M',
  9107. '\u1E3E': 'M',
  9108. '\u1E40': 'M',
  9109. '\u1E42': 'M',
  9110. '\u2C6E': 'M',
  9111. '\u019C': 'M',
  9112. '\u24C3': 'N',
  9113. '\uFF2E': 'N',
  9114. '\u01F8': 'N',
  9115. '\u0143': 'N',
  9116. '\u00D1': 'N',
  9117. '\u1E44': 'N',
  9118. '\u0147': 'N',
  9119. '\u1E46': 'N',
  9120. '\u0145': 'N',
  9121. '\u1E4A': 'N',
  9122. '\u1E48': 'N',
  9123. '\u0220': 'N',
  9124. '\u019D': 'N',
  9125. '\uA790': 'N',
  9126. '\uA7A4': 'N',
  9127. '\u01CA': 'NJ',
  9128. '\u01CB': 'Nj',
  9129. '\u24C4': 'O',
  9130. '\uFF2F': 'O',
  9131. '\u00D2': 'O',
  9132. '\u00D3': 'O',
  9133. '\u00D4': 'O',
  9134. '\u1ED2': 'O',
  9135. '\u1ED0': 'O',
  9136. '\u1ED6': 'O',
  9137. '\u1ED4': 'O',
  9138. '\u00D5': 'O',
  9139. '\u1E4C': 'O',
  9140. '\u022C': 'O',
  9141. '\u1E4E': 'O',
  9142. '\u014C': 'O',
  9143. '\u1E50': 'O',
  9144. '\u1E52': 'O',
  9145. '\u014E': 'O',
  9146. '\u022E': 'O',
  9147. '\u0230': 'O',
  9148. '\u00D6': 'O',
  9149. '\u022A': 'O',
  9150. '\u1ECE': 'O',
  9151. '\u0150': 'O',
  9152. '\u01D1': 'O',
  9153. '\u020C': 'O',
  9154. '\u020E': 'O',
  9155. '\u01A0': 'O',
  9156. '\u1EDC': 'O',
  9157. '\u1EDA': 'O',
  9158. '\u1EE0': 'O',
  9159. '\u1EDE': 'O',
  9160. '\u1EE2': 'O',
  9161. '\u1ECC': 'O',
  9162. '\u1ED8': 'O',
  9163. '\u01EA': 'O',
  9164. '\u01EC': 'O',
  9165. '\u00D8': 'O',
  9166. '\u01FE': 'O',
  9167. '\u0186': 'O',
  9168. '\u019F': 'O',
  9169. '\uA74A': 'O',
  9170. '\uA74C': 'O',
  9171. '\u01A2': 'OI',
  9172. '\uA74E': 'OO',
  9173. '\u0222': 'OU',
  9174. '\u24C5': 'P',
  9175. '\uFF30': 'P',
  9176. '\u1E54': 'P',
  9177. '\u1E56': 'P',
  9178. '\u01A4': 'P',
  9179. '\u2C63': 'P',
  9180. '\uA750': 'P',
  9181. '\uA752': 'P',
  9182. '\uA754': 'P',
  9183. '\u24C6': 'Q',
  9184. '\uFF31': 'Q',
  9185. '\uA756': 'Q',
  9186. '\uA758': 'Q',
  9187. '\u024A': 'Q',
  9188. '\u24C7': 'R',
  9189. '\uFF32': 'R',
  9190. '\u0154': 'R',
  9191. '\u1E58': 'R',
  9192. '\u0158': 'R',
  9193. '\u0210': 'R',
  9194. '\u0212': 'R',
  9195. '\u1E5A': 'R',
  9196. '\u1E5C': 'R',
  9197. '\u0156': 'R',
  9198. '\u1E5E': 'R',
  9199. '\u024C': 'R',
  9200. '\u2C64': 'R',
  9201. '\uA75A': 'R',
  9202. '\uA7A6': 'R',
  9203. '\uA782': 'R',
  9204. '\u24C8': 'S',
  9205. '\uFF33': 'S',
  9206. '\u1E9E': 'S',
  9207. '\u015A': 'S',
  9208. '\u1E64': 'S',
  9209. '\u015C': 'S',
  9210. '\u1E60': 'S',
  9211. '\u0160': 'S',
  9212. '\u1E66': 'S',
  9213. '\u1E62': 'S',
  9214. '\u1E68': 'S',
  9215. '\u0218': 'S',
  9216. '\u015E': 'S',
  9217. '\u2C7E': 'S',
  9218. '\uA7A8': 'S',
  9219. '\uA784': 'S',
  9220. '\u24C9': 'T',
  9221. '\uFF34': 'T',
  9222. '\u1E6A': 'T',
  9223. '\u0164': 'T',
  9224. '\u1E6C': 'T',
  9225. '\u021A': 'T',
  9226. '\u0162': 'T',
  9227. '\u1E70': 'T',
  9228. '\u1E6E': 'T',
  9229. '\u0166': 'T',
  9230. '\u01AC': 'T',
  9231. '\u01AE': 'T',
  9232. '\u023E': 'T',
  9233. '\uA786': 'T',
  9234. '\uA728': 'TZ',
  9235. '\u24CA': 'U',
  9236. '\uFF35': 'U',
  9237. '\u00D9': 'U',
  9238. '\u00DA': 'U',
  9239. '\u00DB': 'U',
  9240. '\u0168': 'U',
  9241. '\u1E78': 'U',
  9242. '\u016A': 'U',
  9243. '\u1E7A': 'U',
  9244. '\u016C': 'U',
  9245. '\u00DC': 'U',
  9246. '\u01DB': 'U',
  9247. '\u01D7': 'U',
  9248. '\u01D5': 'U',
  9249. '\u01D9': 'U',
  9250. '\u1EE6': 'U',
  9251. '\u016E': 'U',
  9252. '\u0170': 'U',
  9253. '\u01D3': 'U',
  9254. '\u0214': 'U',
  9255. '\u0216': 'U',
  9256. '\u01AF': 'U',
  9257. '\u1EEA': 'U',
  9258. '\u1EE8': 'U',
  9259. '\u1EEE': 'U',
  9260. '\u1EEC': 'U',
  9261. '\u1EF0': 'U',
  9262. '\u1EE4': 'U',
  9263. '\u1E72': 'U',
  9264. '\u0172': 'U',
  9265. '\u1E76': 'U',
  9266. '\u1E74': 'U',
  9267. '\u0244': 'U',
  9268. '\u24CB': 'V',
  9269. '\uFF36': 'V',
  9270. '\u1E7C': 'V',
  9271. '\u1E7E': 'V',
  9272. '\u01B2': 'V',
  9273. '\uA75E': 'V',
  9274. '\u0245': 'V',
  9275. '\uA760': 'VY',
  9276. '\u24CC': 'W',
  9277. '\uFF37': 'W',
  9278. '\u1E80': 'W',
  9279. '\u1E82': 'W',
  9280. '\u0174': 'W',
  9281. '\u1E86': 'W',
  9282. '\u1E84': 'W',
  9283. '\u1E88': 'W',
  9284. '\u2C72': 'W',
  9285. '\u24CD': 'X',
  9286. '\uFF38': 'X',
  9287. '\u1E8A': 'X',
  9288. '\u1E8C': 'X',
  9289. '\u24CE': 'Y',
  9290. '\uFF39': 'Y',
  9291. '\u1EF2': 'Y',
  9292. '\u00DD': 'Y',
  9293. '\u0176': 'Y',
  9294. '\u1EF8': 'Y',
  9295. '\u0232': 'Y',
  9296. '\u1E8E': 'Y',
  9297. '\u0178': 'Y',
  9298. '\u1EF6': 'Y',
  9299. '\u1EF4': 'Y',
  9300. '\u01B3': 'Y',
  9301. '\u024E': 'Y',
  9302. '\u1EFE': 'Y',
  9303. '\u24CF': 'Z',
  9304. '\uFF3A': 'Z',
  9305. '\u0179': 'Z',
  9306. '\u1E90': 'Z',
  9307. '\u017B': 'Z',
  9308. '\u017D': 'Z',
  9309. '\u1E92': 'Z',
  9310. '\u1E94': 'Z',
  9311. '\u01B5': 'Z',
  9312. '\u0224': 'Z',
  9313. '\u2C7F': 'Z',
  9314. '\u2C6B': 'Z',
  9315. '\uA762': 'Z',
  9316. '\u24D0': 'a',
  9317. '\uFF41': 'a',
  9318. '\u1E9A': 'a',
  9319. '\u00E0': 'a',
  9320. '\u00E1': 'a',
  9321. '\u00E2': 'a',
  9322. '\u1EA7': 'a',
  9323. '\u1EA5': 'a',
  9324. '\u1EAB': 'a',
  9325. '\u1EA9': 'a',
  9326. '\u00E3': 'a',
  9327. '\u0101': 'a',
  9328. '\u0103': 'a',
  9329. '\u1EB1': 'a',
  9330. '\u1EAF': 'a',
  9331. '\u1EB5': 'a',
  9332. '\u1EB3': 'a',
  9333. '\u0227': 'a',
  9334. '\u01E1': 'a',
  9335. '\u00E4': 'a',
  9336. '\u01DF': 'a',
  9337. '\u1EA3': 'a',
  9338. '\u00E5': 'a',
  9339. '\u01FB': 'a',
  9340. '\u01CE': 'a',
  9341. '\u0201': 'a',
  9342. '\u0203': 'a',
  9343. '\u1EA1': 'a',
  9344. '\u1EAD': 'a',
  9345. '\u1EB7': 'a',
  9346. '\u1E01': 'a',
  9347. '\u0105': 'a',
  9348. '\u2C65': 'a',
  9349. '\u0250': 'a',
  9350. '\uA733': 'aa',
  9351. '\u00E6': 'ae',
  9352. '\u01FD': 'ae',
  9353. '\u01E3': 'ae',
  9354. '\uA735': 'ao',
  9355. '\uA737': 'au',
  9356. '\uA739': 'av',
  9357. '\uA73B': 'av',
  9358. '\uA73D': 'ay',
  9359. '\u24D1': 'b',
  9360. '\uFF42': 'b',
  9361. '\u1E03': 'b',
  9362. '\u1E05': 'b',
  9363. '\u1E07': 'b',
  9364. '\u0180': 'b',
  9365. '\u0183': 'b',
  9366. '\u0253': 'b',
  9367. '\u24D2': 'c',
  9368. '\uFF43': 'c',
  9369. '\u0107': 'c',
  9370. '\u0109': 'c',
  9371. '\u010B': 'c',
  9372. '\u010D': 'c',
  9373. '\u00E7': 'c',
  9374. '\u1E09': 'c',
  9375. '\u0188': 'c',
  9376. '\u023C': 'c',
  9377. '\uA73F': 'c',
  9378. '\u2184': 'c',
  9379. '\u24D3': 'd',
  9380. '\uFF44': 'd',
  9381. '\u1E0B': 'd',
  9382. '\u010F': 'd',
  9383. '\u1E0D': 'd',
  9384. '\u1E11': 'd',
  9385. '\u1E13': 'd',
  9386. '\u1E0F': 'd',
  9387. '\u0111': 'd',
  9388. '\u018C': 'd',
  9389. '\u0256': 'd',
  9390. '\u0257': 'd',
  9391. '\uA77A': 'd',
  9392. '\u01F3': 'dz',
  9393. '\u01C6': 'dz',
  9394. '\u24D4': 'e',
  9395. '\uFF45': 'e',
  9396. '\u00E8': 'e',
  9397. '\u00E9': 'e',
  9398. '\u00EA': 'e',
  9399. '\u1EC1': 'e',
  9400. '\u1EBF': 'e',
  9401. '\u1EC5': 'e',
  9402. '\u1EC3': 'e',
  9403. '\u1EBD': 'e',
  9404. '\u0113': 'e',
  9405. '\u1E15': 'e',
  9406. '\u1E17': 'e',
  9407. '\u0115': 'e',
  9408. '\u0117': 'e',
  9409. '\u00EB': 'e',
  9410. '\u1EBB': 'e',
  9411. '\u011B': 'e',
  9412. '\u0205': 'e',
  9413. '\u0207': 'e',
  9414. '\u1EB9': 'e',
  9415. '\u1EC7': 'e',
  9416. '\u0229': 'e',
  9417. '\u1E1D': 'e',
  9418. '\u0119': 'e',
  9419. '\u1E19': 'e',
  9420. '\u1E1B': 'e',
  9421. '\u0247': 'e',
  9422. '\u025B': 'e',
  9423. '\u01DD': 'e',
  9424. '\u24D5': 'f',
  9425. '\uFF46': 'f',
  9426. '\u1E1F': 'f',
  9427. '\u0192': 'f',
  9428. '\uA77C': 'f',
  9429. '\u24D6': 'g',
  9430. '\uFF47': 'g',
  9431. '\u01F5': 'g',
  9432. '\u011D': 'g',
  9433. '\u1E21': 'g',
  9434. '\u011F': 'g',
  9435. '\u0121': 'g',
  9436. '\u01E7': 'g',
  9437. '\u0123': 'g',
  9438. '\u01E5': 'g',
  9439. '\u0260': 'g',
  9440. '\uA7A1': 'g',
  9441. '\u1D79': 'g',
  9442. '\uA77F': 'g',
  9443. '\u24D7': 'h',
  9444. '\uFF48': 'h',
  9445. '\u0125': 'h',
  9446. '\u1E23': 'h',
  9447. '\u1E27': 'h',
  9448. '\u021F': 'h',
  9449. '\u1E25': 'h',
  9450. '\u1E29': 'h',
  9451. '\u1E2B': 'h',
  9452. '\u1E96': 'h',
  9453. '\u0127': 'h',
  9454. '\u2C68': 'h',
  9455. '\u2C76': 'h',
  9456. '\u0265': 'h',
  9457. '\u0195': 'hv',
  9458. '\u24D8': 'i',
  9459. '\uFF49': 'i',
  9460. '\u00EC': 'i',
  9461. '\u00ED': 'i',
  9462. '\u00EE': 'i',
  9463. '\u0129': 'i',
  9464. '\u012B': 'i',
  9465. '\u012D': 'i',
  9466. '\u00EF': 'i',
  9467. '\u1E2F': 'i',
  9468. '\u1EC9': 'i',
  9469. '\u01D0': 'i',
  9470. '\u0209': 'i',
  9471. '\u020B': 'i',
  9472. '\u1ECB': 'i',
  9473. '\u012F': 'i',
  9474. '\u1E2D': 'i',
  9475. '\u0268': 'i',
  9476. '\u0131': 'i',
  9477. '\u24D9': 'j',
  9478. '\uFF4A': 'j',
  9479. '\u0135': 'j',
  9480. '\u01F0': 'j',
  9481. '\u0249': 'j',
  9482. '\u24DA': 'k',
  9483. '\uFF4B': 'k',
  9484. '\u1E31': 'k',
  9485. '\u01E9': 'k',
  9486. '\u1E33': 'k',
  9487. '\u0137': 'k',
  9488. '\u1E35': 'k',
  9489. '\u0199': 'k',
  9490. '\u2C6A': 'k',
  9491. '\uA741': 'k',
  9492. '\uA743': 'k',
  9493. '\uA745': 'k',
  9494. '\uA7A3': 'k',
  9495. '\u24DB': 'l',
  9496. '\uFF4C': 'l',
  9497. '\u0140': 'l',
  9498. '\u013A': 'l',
  9499. '\u013E': 'l',
  9500. '\u1E37': 'l',
  9501. '\u1E39': 'l',
  9502. '\u013C': 'l',
  9503. '\u1E3D': 'l',
  9504. '\u1E3B': 'l',
  9505. '\u017F': 'l',
  9506. '\u0142': 'l',
  9507. '\u019A': 'l',
  9508. '\u026B': 'l',
  9509. '\u2C61': 'l',
  9510. '\uA749': 'l',
  9511. '\uA781': 'l',
  9512. '\uA747': 'l',
  9513. '\u01C9': 'lj',
  9514. '\u24DC': 'm',
  9515. '\uFF4D': 'm',
  9516. '\u1E3F': 'm',
  9517. '\u1E41': 'm',
  9518. '\u1E43': 'm',
  9519. '\u0271': 'm',
  9520. '\u026F': 'm',
  9521. '\u24DD': 'n',
  9522. '\uFF4E': 'n',
  9523. '\u01F9': 'n',
  9524. '\u0144': 'n',
  9525. '\u00F1': 'n',
  9526. '\u1E45': 'n',
  9527. '\u0148': 'n',
  9528. '\u1E47': 'n',
  9529. '\u0146': 'n',
  9530. '\u1E4B': 'n',
  9531. '\u1E49': 'n',
  9532. '\u019E': 'n',
  9533. '\u0272': 'n',
  9534. '\u0149': 'n',
  9535. '\uA791': 'n',
  9536. '\uA7A5': 'n',
  9537. '\u01CC': 'nj',
  9538. '\u24DE': 'o',
  9539. '\uFF4F': 'o',
  9540. '\u00F2': 'o',
  9541. '\u00F3': 'o',
  9542. '\u00F4': 'o',
  9543. '\u1ED3': 'o',
  9544. '\u1ED1': 'o',
  9545. '\u1ED7': 'o',
  9546. '\u1ED5': 'o',
  9547. '\u00F5': 'o',
  9548. '\u1E4D': 'o',
  9549. '\u022D': 'o',
  9550. '\u1E4F': 'o',
  9551. '\u014D': 'o',
  9552. '\u1E51': 'o',
  9553. '\u1E53': 'o',
  9554. '\u014F': 'o',
  9555. '\u022F': 'o',
  9556. '\u0231': 'o',
  9557. '\u00F6': 'o',
  9558. '\u022B': 'o',
  9559. '\u1ECF': 'o',
  9560. '\u0151': 'o',
  9561. '\u01D2': 'o',
  9562. '\u020D': 'o',
  9563. '\u020F': 'o',
  9564. '\u01A1': 'o',
  9565. '\u1EDD': 'o',
  9566. '\u1EDB': 'o',
  9567. '\u1EE1': 'o',
  9568. '\u1EDF': 'o',
  9569. '\u1EE3': 'o',
  9570. '\u1ECD': 'o',
  9571. '\u1ED9': 'o',
  9572. '\u01EB': 'o',
  9573. '\u01ED': 'o',
  9574. '\u00F8': 'o',
  9575. '\u01FF': 'o',
  9576. '\u0254': 'o',
  9577. '\uA74B': 'o',
  9578. '\uA74D': 'o',
  9579. '\u0275': 'o',
  9580. '\u01A3': 'oi',
  9581. '\u0223': 'ou',
  9582. '\uA74F': 'oo',
  9583. '\u24DF': 'p',
  9584. '\uFF50': 'p',
  9585. '\u1E55': 'p',
  9586. '\u1E57': 'p',
  9587. '\u01A5': 'p',
  9588. '\u1D7D': 'p',
  9589. '\uA751': 'p',
  9590. '\uA753': 'p',
  9591. '\uA755': 'p',
  9592. '\u24E0': 'q',
  9593. '\uFF51': 'q',
  9594. '\u024B': 'q',
  9595. '\uA757': 'q',
  9596. '\uA759': 'q',
  9597. '\u24E1': 'r',
  9598. '\uFF52': 'r',
  9599. '\u0155': 'r',
  9600. '\u1E59': 'r',
  9601. '\u0159': 'r',
  9602. '\u0211': 'r',
  9603. '\u0213': 'r',
  9604. '\u1E5B': 'r',
  9605. '\u1E5D': 'r',
  9606. '\u0157': 'r',
  9607. '\u1E5F': 'r',
  9608. '\u024D': 'r',
  9609. '\u027D': 'r',
  9610. '\uA75B': 'r',
  9611. '\uA7A7': 'r',
  9612. '\uA783': 'r',
  9613. '\u24E2': 's',
  9614. '\uFF53': 's',
  9615. '\u00DF': 's',
  9616. '\u015B': 's',
  9617. '\u1E65': 's',
  9618. '\u015D': 's',
  9619. '\u1E61': 's',
  9620. '\u0161': 's',
  9621. '\u1E67': 's',
  9622. '\u1E63': 's',
  9623. '\u1E69': 's',
  9624. '\u0219': 's',
  9625. '\u015F': 's',
  9626. '\u023F': 's',
  9627. '\uA7A9': 's',
  9628. '\uA785': 's',
  9629. '\u1E9B': 's',
  9630. '\u24E3': 't',
  9631. '\uFF54': 't',
  9632. '\u1E6B': 't',
  9633. '\u1E97': 't',
  9634. '\u0165': 't',
  9635. '\u1E6D': 't',
  9636. '\u021B': 't',
  9637. '\u0163': 't',
  9638. '\u1E71': 't',
  9639. '\u1E6F': 't',
  9640. '\u0167': 't',
  9641. '\u01AD': 't',
  9642. '\u0288': 't',
  9643. '\u2C66': 't',
  9644. '\uA787': 't',
  9645. '\uA729': 'tz',
  9646. '\u24E4': 'u',
  9647. '\uFF55': 'u',
  9648. '\u00F9': 'u',
  9649. '\u00FA': 'u',
  9650. '\u00FB': 'u',
  9651. '\u0169': 'u',
  9652. '\u1E79': 'u',
  9653. '\u016B': 'u',
  9654. '\u1E7B': 'u',
  9655. '\u016D': 'u',
  9656. '\u00FC': 'u',
  9657. '\u01DC': 'u',
  9658. '\u01D8': 'u',
  9659. '\u01D6': 'u',
  9660. '\u01DA': 'u',
  9661. '\u1EE7': 'u',
  9662. '\u016F': 'u',
  9663. '\u0171': 'u',
  9664. '\u01D4': 'u',
  9665. '\u0215': 'u',
  9666. '\u0217': 'u',
  9667. '\u01B0': 'u',
  9668. '\u1EEB': 'u',
  9669. '\u1EE9': 'u',
  9670. '\u1EEF': 'u',
  9671. '\u1EED': 'u',
  9672. '\u1EF1': 'u',
  9673. '\u1EE5': 'u',
  9674. '\u1E73': 'u',
  9675. '\u0173': 'u',
  9676. '\u1E77': 'u',
  9677. '\u1E75': 'u',
  9678. '\u0289': 'u',
  9679. '\u24E5': 'v',
  9680. '\uFF56': 'v',
  9681. '\u1E7D': 'v',
  9682. '\u1E7F': 'v',
  9683. '\u028B': 'v',
  9684. '\uA75F': 'v',
  9685. '\u028C': 'v',
  9686. '\uA761': 'vy',
  9687. '\u24E6': 'w',
  9688. '\uFF57': 'w',
  9689. '\u1E81': 'w',
  9690. '\u1E83': 'w',
  9691. '\u0175': 'w',
  9692. '\u1E87': 'w',
  9693. '\u1E85': 'w',
  9694. '\u1E98': 'w',
  9695. '\u1E89': 'w',
  9696. '\u2C73': 'w',
  9697. '\u24E7': 'x',
  9698. '\uFF58': 'x',
  9699. '\u1E8B': 'x',
  9700. '\u1E8D': 'x',
  9701. '\u24E8': 'y',
  9702. '\uFF59': 'y',
  9703. '\u1EF3': 'y',
  9704. '\u00FD': 'y',
  9705. '\u0177': 'y',
  9706. '\u1EF9': 'y',
  9707. '\u0233': 'y',
  9708. '\u1E8F': 'y',
  9709. '\u00FF': 'y',
  9710. '\u1EF7': 'y',
  9711. '\u1E99': 'y',
  9712. '\u1EF5': 'y',
  9713. '\u01B4': 'y',
  9714. '\u024F': 'y',
  9715. '\u1EFF': 'y',
  9716. '\u24E9': 'z',
  9717. '\uFF5A': 'z',
  9718. '\u017A': 'z',
  9719. '\u1E91': 'z',
  9720. '\u017C': 'z',
  9721. '\u017E': 'z',
  9722. '\u1E93': 'z',
  9723. '\u1E95': 'z',
  9724. '\u01B6': 'z',
  9725. '\u0225': 'z',
  9726. '\u0240': 'z',
  9727. '\u2C6C': 'z',
  9728. '\uA763': 'z',
  9729. '\u0386': '\u0391',
  9730. '\u0388': '\u0395',
  9731. '\u0389': '\u0397',
  9732. '\u038A': '\u0399',
  9733. '\u03AA': '\u0399',
  9734. '\u038C': '\u039F',
  9735. '\u038E': '\u03A5',
  9736. '\u03AB': '\u03A5',
  9737. '\u038F': '\u03A9',
  9738. '\u03AC': '\u03B1',
  9739. '\u03AD': '\u03B5',
  9740. '\u03AE': '\u03B7',
  9741. '\u03AF': '\u03B9',
  9742. '\u03CA': '\u03B9',
  9743. '\u0390': '\u03B9',
  9744. '\u03CC': '\u03BF',
  9745. '\u03CD': '\u03C5',
  9746. '\u03CB': '\u03C5',
  9747. '\u03B0': '\u03C5',
  9748. '\u03C9': '\u03C9',
  9749. '\u03C2': '\u03C3'
  9750. };
  9751. return diacritics;
  9752. });
  9753. define('select2/data/base',[
  9754. '../utils'
  9755. ], function (Utils) {
  9756. function BaseAdapter ($element, options) {
  9757. BaseAdapter.__super__.constructor.call(this);
  9758. }
  9759. Utils.Extend(BaseAdapter, Utils.Observable);
  9760. BaseAdapter.prototype.current = function (callback) {
  9761. throw new Error('The `current` method must be defined in child classes.');
  9762. };
  9763. BaseAdapter.prototype.query = function (params, callback) {
  9764. throw new Error('The `query` method must be defined in child classes.');
  9765. };
  9766. BaseAdapter.prototype.bind = function (container, $container) {
  9767. // Can be implemented in subclasses
  9768. };
  9769. BaseAdapter.prototype.destroy = function () {
  9770. // Can be implemented in subclasses
  9771. };
  9772. BaseAdapter.prototype.generateResultId = function (container, data) {
  9773. var id = container.id + '-result-';
  9774. id += Utils.generateChars(4);
  9775. if (data.id != null) {
  9776. id += '-' + data.id.toString();
  9777. } else {
  9778. id += '-' + Utils.generateChars(4);
  9779. }
  9780. return id;
  9781. };
  9782. return BaseAdapter;
  9783. });
  9784. define('select2/data/select',[
  9785. './base',
  9786. '../utils',
  9787. 'jquery'
  9788. ], function (BaseAdapter, Utils, $) {
  9789. function SelectAdapter ($element, options) {
  9790. this.$element = $element;
  9791. this.options = options;
  9792. SelectAdapter.__super__.constructor.call(this);
  9793. }
  9794. Utils.Extend(SelectAdapter, BaseAdapter);
  9795. SelectAdapter.prototype.current = function (callback) {
  9796. var data = [];
  9797. var self = this;
  9798. this.$element.find(':selected').each(function () {
  9799. var $option = $(this);
  9800. var option = self.item($option);
  9801. data.push(option);
  9802. });
  9803. callback(data);
  9804. };
  9805. SelectAdapter.prototype.select = function (data) {
  9806. var self = this;
  9807. // If data.element is a DOM nose, use it instead
  9808. if ($(data.element).is('option')) {
  9809. data.element.selected = true;
  9810. this.$element.trigger('change');
  9811. return;
  9812. }
  9813. if (this.$element.prop('multiple')) {
  9814. this.current(function (currentData) {
  9815. var val = [];
  9816. data = [data];
  9817. data.push.apply(data, currentData);
  9818. for (var d = 0; d < data.length; d++) {
  9819. id = data[d].id;
  9820. if (val.indexOf(id) === -1) {
  9821. val.push(id);
  9822. }
  9823. }
  9824. self.$element.val(val);
  9825. self.$element.trigger('change');
  9826. });
  9827. } else {
  9828. var val = data.id;
  9829. this.$element.val(val);
  9830. this.$element.trigger('change');
  9831. }
  9832. };
  9833. SelectAdapter.prototype.unselect = function (data) {
  9834. var self = this;
  9835. if (!this.$element.prop('multiple')) {
  9836. return;
  9837. }
  9838. if ($(data.element).is('option')) {
  9839. data.element.selected = false;
  9840. this.$element.trigger('change');
  9841. return;
  9842. }
  9843. this.current(function (currentData) {
  9844. var val = [];
  9845. for (var d = 0; d < currentData.length; d++) {
  9846. id = currentData[d].id;
  9847. if (id !== data.id && val.indexOf(id) === -1) {
  9848. val.push(id);
  9849. }
  9850. }
  9851. self.$element.val(val);
  9852. self.$element.trigger('change');
  9853. });
  9854. };
  9855. SelectAdapter.prototype.bind = function (container, $container) {
  9856. var self = this;
  9857. this.container = container;
  9858. container.on('select', function (params) {
  9859. self.select(params.data);
  9860. });
  9861. container.on('unselect', function (params) {
  9862. self.unselect(params.data);
  9863. });
  9864. };
  9865. SelectAdapter.prototype.destroy = function () {
  9866. // Remove anything added to child elements
  9867. this.$element.find('*').each(function () {
  9868. // Remove any custom data set by Select2
  9869. $.removeData(this, 'data');
  9870. });
  9871. };
  9872. SelectAdapter.prototype.query = function (params, callback) {
  9873. var data = [];
  9874. var self = this;
  9875. var $options = this.$element.children();
  9876. $options.each(function () {
  9877. var $option = $(this);
  9878. if (!$option.is('option') && !$option.is('optgroup')) {
  9879. return;
  9880. }
  9881. var option = self.item($option);
  9882. var matches = self.matches(params, option);
  9883. if (matches !== null) {
  9884. data.push(matches);
  9885. }
  9886. });
  9887. callback({
  9888. results: data
  9889. });
  9890. };
  9891. SelectAdapter.prototype.option = function (data) {
  9892. var option = document.createElement('option');
  9893. option.value = data.id;
  9894. if (data.disabled) {
  9895. option.disabled = true;
  9896. }
  9897. if (data.selected) {
  9898. option.selected = true;
  9899. }
  9900. option.innerText = data.text;
  9901. var $option = $(option);
  9902. var normalizedData = this._normalizeItem(data);
  9903. normalizedData.element = option;
  9904. // Override the option's data with the combined data
  9905. $.data(option, 'data', normalizedData);
  9906. return $option;
  9907. };
  9908. SelectAdapter.prototype.item = function ($option) {
  9909. var data = {};
  9910. data = $.data($option[0], 'data');
  9911. if (data != null) {
  9912. return data;
  9913. }
  9914. if ($option.is('option')) {
  9915. data = {
  9916. id: $option.val(),
  9917. text: $option.html(),
  9918. disabled: $option.prop('disabled'),
  9919. selected: $option.prop('selected')
  9920. };
  9921. } else if ($option.is('optgroup')) {
  9922. data = {
  9923. text: $option.attr('label'),
  9924. children: []
  9925. };
  9926. var $children = $option.children('option');
  9927. var children = [];
  9928. for (var c = 0; c < $children.length; c++) {
  9929. var $child = $($children[c]);
  9930. var child = this.item($child);
  9931. children.push(child);
  9932. }
  9933. data.children = children;
  9934. }
  9935. data = this._normalizeItem(data);
  9936. data.element = $option[0];
  9937. $.data($option[0], 'data', data);
  9938. return data;
  9939. };
  9940. SelectAdapter.prototype._normalizeItem = function (item) {
  9941. if (!$.isPlainObject(item)) {
  9942. item = {
  9943. id: item,
  9944. text: item
  9945. };
  9946. }
  9947. item = $.extend({}, {
  9948. text: ''
  9949. }, item);
  9950. var defaults = {
  9951. selected: false,
  9952. disabled: false
  9953. };
  9954. if (item.id != null) {
  9955. item.id = item.id.toString();
  9956. }
  9957. if (item.text != null) {
  9958. item.text = item.text.toString();
  9959. }
  9960. if (item._resultId == null && item.id && this.container != null) {
  9961. item._resultId = this.generateResultId(this.container, item);
  9962. }
  9963. return $.extend({}, defaults, item);
  9964. };
  9965. SelectAdapter.prototype.matches = function (params, data) {
  9966. var matcher = this.options.get('matcher');
  9967. return matcher(params, data);
  9968. };
  9969. return SelectAdapter;
  9970. });
  9971. define('select2/data/array',[
  9972. './select',
  9973. '../utils',
  9974. 'jquery'
  9975. ], function (SelectAdapter, Utils, $) {
  9976. function ArrayAdapter ($element, options) {
  9977. var data = options.get('data');
  9978. ArrayAdapter.__super__.constructor.call(this, $element, options);
  9979. this.convertToOptions(data);
  9980. }
  9981. Utils.Extend(ArrayAdapter, SelectAdapter);
  9982. ArrayAdapter.prototype.select = function (data) {
  9983. var $option = this.$element.find('option[value="' + data.id + '"]');
  9984. if ($option.length === 0) {
  9985. $option = this.option(data);
  9986. this.$element.append($option);
  9987. }
  9988. ArrayAdapter.__super__.select.call(this, data);
  9989. };
  9990. ArrayAdapter.prototype.convertToOptions = function (data) {
  9991. var self = this;
  9992. var $existing = this.$element.find('option');
  9993. var existingIds = $existing.map(function () {
  9994. return self.item($(this)).id;
  9995. }).get();
  9996. // Filter out all items except for the one passed in the argument
  9997. function onlyItem (item) {
  9998. return function () {
  9999. return $(this).val() == item.id;
  10000. };
  10001. }
  10002. for (var d = 0; d < data.length; d++) {
  10003. var item = data[d];
  10004. item.id = item.id.toString();
  10005. // Skip items which were pre-loaded, only merge the data
  10006. if (existingIds.indexOf(item.id) >= 0) {
  10007. var $existingOption = $existing.filter(onlyItem(item));
  10008. var existingData = this.item($existingOption);
  10009. var newData = $.extend(true, {}, existingData, item);
  10010. var $newOption = this.option(existingData);
  10011. $existingOption.replaceWith($newOption);
  10012. continue;
  10013. }
  10014. var $option = this.option(item);
  10015. this.$element.append($option);
  10016. }
  10017. };
  10018. return ArrayAdapter;
  10019. });
  10020. define('select2/data/ajax',[
  10021. './array',
  10022. '../utils',
  10023. 'jquery'
  10024. ], function (ArrayAdapter, Utils, $) {
  10025. function AjaxAdapter ($element, options) {
  10026. this.ajaxOptions = options.get('ajax');
  10027. if (this.ajaxOptions.processResults != null) {
  10028. this.processResults = this.ajaxOptions.processResults;
  10029. }
  10030. ArrayAdapter.__super__.constructor.call(this, $element, options);
  10031. }
  10032. Utils.Extend(AjaxAdapter, ArrayAdapter);
  10033. AjaxAdapter.prototype.processResults = function (results) {
  10034. return results;
  10035. };
  10036. AjaxAdapter.prototype.query = function (params, callback) {
  10037. var matches = [];
  10038. var self = this;
  10039. if (this._request) {
  10040. this._request.abort();
  10041. this._request = null;
  10042. }
  10043. var options = $.extend({
  10044. type: 'GET'
  10045. }, this.ajaxOptions);
  10046. if (typeof options.url === 'function') {
  10047. options.url = options.url(params);
  10048. }
  10049. if (typeof options.data === 'function') {
  10050. options.data = options.data(params);
  10051. }
  10052. function request () {
  10053. var $request = $.ajax(options);
  10054. $request.success(function (data) {
  10055. var results = self.processResults(data, params);
  10056. callback(results);
  10057. });
  10058. self._request = $request;
  10059. }
  10060. if (this.ajaxOptions.delay && params.term !== '') {
  10061. if (this._queryTimeout) {
  10062. window.clearTimeout(this._queryTimeout);
  10063. }
  10064. this._queryTimeout = window.setTimeout(request, this.ajaxOptions.delay);
  10065. } else {
  10066. request();
  10067. }
  10068. };
  10069. return AjaxAdapter;
  10070. });
  10071. define('select2/data/tags',[
  10072. ], function () {
  10073. function Tags (decorated, $element, options) {
  10074. var tags = options.get('tags');
  10075. var createTag = options.get('createTag');
  10076. if (createTag !== undefined) {
  10077. this.createTag = createTag;
  10078. }
  10079. decorated.call(this, $element, options);
  10080. if ($.isArray(tags)) {
  10081. for (var t = 0; t < tags.length; t++) {
  10082. var tag = tags[t];
  10083. var item = this._normalizeItem(tag);
  10084. var $option = this.option(item);
  10085. this.$element.append($option);
  10086. }
  10087. }
  10088. }
  10089. Tags.prototype.query = function (decorated, params, callback) {
  10090. var self = this;
  10091. this._removeOldTags();
  10092. if (params.term == null || params.term === '' || params.page != null) {
  10093. decorated.call(this, params, callback);
  10094. return;
  10095. }
  10096. function wrapper (obj, child) {
  10097. var data = obj.results;
  10098. for (var i = 0; i < data.length; i++) {
  10099. var option = data[i];
  10100. var checkChildren = (
  10101. option.children != null &&
  10102. !wrapper({
  10103. results: option.children
  10104. }, true)
  10105. );
  10106. var checkText = option.text === params.term;
  10107. if (checkText || checkChildren) {
  10108. if (child) {
  10109. return false;
  10110. }
  10111. obj.data = data;
  10112. callback(obj);
  10113. return;
  10114. }
  10115. }
  10116. if (child) {
  10117. return true;
  10118. }
  10119. var tag = self.createTag(params);
  10120. if (tag != null) {
  10121. var $option = self.option(tag);
  10122. $option.attr('data-select2-tag', true);
  10123. self.$element.append($option);
  10124. self.insertTag(data, tag);
  10125. }
  10126. obj.results = data;
  10127. callback(obj);
  10128. }
  10129. decorated.call(this, params, wrapper);
  10130. };
  10131. Tags.prototype.createTag = function (decorated, params) {
  10132. return {
  10133. id: params.term,
  10134. text: params.term
  10135. };
  10136. };
  10137. Tags.prototype.insertTag = function (_, data, tag) {
  10138. data.unshift(tag);
  10139. };
  10140. Tags.prototype._removeOldTags = function (_) {
  10141. var tag = this._lastTag;
  10142. var $options = this.$element.find('option[data-select2-tag]');
  10143. $options.each(function () {
  10144. if (this.selected) {
  10145. return;
  10146. }
  10147. $(this).remove();
  10148. });
  10149. };
  10150. return Tags;
  10151. });
  10152. define('select2/data/tokenizer',[
  10153. ], function () {
  10154. function Tokenizer (decorated, $element, options) {
  10155. var tokenizer = options.get('tokenizer');
  10156. if (tokenizer !== undefined) {
  10157. this.tokenizer = tokenizer;
  10158. }
  10159. decorated.call(this, $element, options);
  10160. }
  10161. Tokenizer.prototype.bind = function (decorated, container, $container) {
  10162. decorated.call(this, container, $container);
  10163. this.$search = container.dropdown.$search || container.selection.$search ||
  10164. $container.find('.select2-search__field');
  10165. };
  10166. Tokenizer.prototype.query = function (decorated, params, callback) {
  10167. var self = this;
  10168. function select (data) {
  10169. self.select(data);
  10170. }
  10171. params.term = params.term || '';
  10172. var tokenData = this.tokenizer(params, this.options, select);
  10173. if (tokenData.term !== params.term) {
  10174. // Replace the search term if we have the search box
  10175. if (this.$search.length) {
  10176. this.$search.val(tokenData.term);
  10177. this.$search.focus();
  10178. }
  10179. params.term = tokenData.term;
  10180. }
  10181. decorated.call(this, params, callback);
  10182. };
  10183. Tokenizer.prototype.tokenizer = function (_, params, options, callback) {
  10184. var separators = options.get('tokenSeparators') || [];
  10185. var term = params.term;
  10186. var i = 0;
  10187. var createTag = this.createTag || function (params) {
  10188. return {
  10189. id: params.term,
  10190. text: params.term
  10191. };
  10192. };
  10193. while (i < term.length) {
  10194. var termChar = term[i];
  10195. if (separators.indexOf(termChar) === -1) {
  10196. i++;
  10197. continue;
  10198. }
  10199. var part = term.substr(0, i);
  10200. var partParams = $.extend({}, params, {
  10201. term: part
  10202. });
  10203. var data = createTag(partParams);
  10204. callback(data);
  10205. // Reset the term to not include the tokenized portion
  10206. term = term.substr(i + 1) || '';
  10207. i = 0;
  10208. }
  10209. return {
  10210. term: term
  10211. };
  10212. };
  10213. return Tokenizer;
  10214. });
  10215. define('select2/data/minimumInputLength',[
  10216. ], function () {
  10217. function MinimumInputLength (decorated, $e, options) {
  10218. this.minimumInputLength = options.get('minimumInputLength');
  10219. decorated.call(this, $e, options);
  10220. }
  10221. MinimumInputLength.prototype.query = function (decorated, params, callback) {
  10222. params.term = params.term || '';
  10223. if (params.term.length < this.minimumInputLength) {
  10224. this.trigger('results:message', {
  10225. message: 'inputTooShort',
  10226. args: {
  10227. minimum: this.minimumInputLength,
  10228. input: params.term,
  10229. params: params
  10230. }
  10231. });
  10232. return;
  10233. }
  10234. decorated.call(this, params, callback);
  10235. };
  10236. return MinimumInputLength;
  10237. });
  10238. define('select2/data/maximumInputLength',[
  10239. ], function () {
  10240. function MaximumInputLength (decorated, $e, options) {
  10241. this.maximumInputLength = options.get('maximumInputLength');
  10242. decorated.call(this, $e, options);
  10243. }
  10244. MaximumInputLength.prototype.query = function (decorated, params, callback) {
  10245. params.term = params.term || '';
  10246. if (this.maximumInputLength > 0 &&
  10247. params.term.length > this.maximumInputLength) {
  10248. this.trigger('results:message', {
  10249. message: 'inputTooLong',
  10250. args: {
  10251. minimum: this.maximumInputLength,
  10252. input: params.term,
  10253. params: params
  10254. }
  10255. });
  10256. return;
  10257. }
  10258. decorated.call(this, params, callback);
  10259. };
  10260. return MaximumInputLength;
  10261. });
  10262. define('select2/dropdown',[
  10263. './utils'
  10264. ], function (Utils) {
  10265. function Dropdown ($element, options) {
  10266. this.$element = $element;
  10267. this.options = options;
  10268. Dropdown.__super__.constructor.call(this);
  10269. }
  10270. Utils.Extend(Dropdown, Utils.Observable);
  10271. Dropdown.prototype.render = function () {
  10272. var $dropdown = $(
  10273. '<span class="select2-dropdown">' +
  10274. '<span class="select2-results"></span>' +
  10275. '</span>'
  10276. );
  10277. $dropdown.attr('dir', this.options.get('dir'));
  10278. this.$dropdown = $dropdown;
  10279. return $dropdown;
  10280. };
  10281. Dropdown.prototype.position = function ($dropdown, $container) {
  10282. // Should be implmented in subclasses
  10283. };
  10284. Dropdown.prototype.destroy = function () {
  10285. // Remove the dropdown from the DOM
  10286. this.$dropdown.remove();
  10287. };
  10288. Dropdown.prototype.bind = function (container, $container) {
  10289. var self = this;
  10290. container.on('select', function (params) {
  10291. self._onSelect(params);
  10292. });
  10293. container.on('unselect', function (params) {
  10294. self._onUnSelect(params);
  10295. });
  10296. };
  10297. Dropdown.prototype._onSelect = function () {
  10298. this.trigger('close');
  10299. };
  10300. Dropdown.prototype._onUnSelect = function () {
  10301. this.trigger('close');
  10302. };
  10303. return Dropdown;
  10304. });
  10305. define('select2/dropdown/search',[
  10306. '../utils'
  10307. ], function (Utils) {
  10308. function Search () { }
  10309. Search.prototype.render = function (decorated) {
  10310. var $rendered = decorated.call(this);
  10311. var $search = $(
  10312. '<span class="select2-search select2-search--dropdown">' +
  10313. '<input class="select2-search__field" type="search" tabindex="-1"' +
  10314. ' role="textbox" />' +
  10315. '</span>'
  10316. );
  10317. this.$searchContainer = $search;
  10318. this.$search = $search.find('input');
  10319. $rendered.prepend($search);
  10320. return $rendered;
  10321. };
  10322. Search.prototype.bind = function (decorated, container, $container) {
  10323. var self = this;
  10324. decorated.call(this, container, $container);
  10325. this.$search.on('keydown', function (evt) {
  10326. self.trigger('keypress', evt);
  10327. self._keyUpPrevented = evt.isDefaultPrevented();
  10328. });
  10329. this.$search.on('keyup', function (evt) {
  10330. self.handleSearch(evt);
  10331. });
  10332. container.on('open', function () {
  10333. self.$search.attr('tabindex', 0);
  10334. self.$search.focus();
  10335. window.setTimeout(function () {
  10336. self.$search.focus();
  10337. }, 0);
  10338. });
  10339. container.on('close', function () {
  10340. self.$search.attr('tabindex', -1);
  10341. self.$search.val('');
  10342. });
  10343. container.on('results:all', function (params) {
  10344. if (params.query.term == null || params.query.term === '') {
  10345. var showSearch = self.showSearch(params);
  10346. if (showSearch) {
  10347. self.$searchContainer.removeClass('select2-search--hide');
  10348. } else {
  10349. self.$searchContainer.addClass('select2-search--hide');
  10350. }
  10351. }
  10352. });
  10353. };
  10354. Search.prototype.handleSearch = function (evt) {
  10355. if (!this._keyUpPrevented) {
  10356. var input = this.$search.val();
  10357. this.trigger('query', {
  10358. term: input
  10359. });
  10360. }
  10361. this._keyUpPrevented = false;
  10362. };
  10363. Search.prototype.showSearch = function (_, params) {
  10364. return true;
  10365. };
  10366. return Search;
  10367. });
  10368. define('select2/dropdown/hidePlaceholder',[
  10369. ], function () {
  10370. function HidePlaceholder (decorated, $element, options, dataAdapter) {
  10371. this.placeholder = this.normalizePlaceholder(options.get('placeholder'));
  10372. decorated.call(this, $element, options, dataAdapter);
  10373. }
  10374. HidePlaceholder.prototype.append = function (decorated, data) {
  10375. data.results = this.removePlaceholder(data.results);
  10376. decorated.call(this, data);
  10377. };
  10378. HidePlaceholder.prototype.normalizePlaceholder = function (_, placeholder) {
  10379. if (typeof placeholder === 'string') {
  10380. placeholder = {
  10381. id: '',
  10382. text: placeholder
  10383. };
  10384. }
  10385. return placeholder;
  10386. };
  10387. HidePlaceholder.prototype.removePlaceholder = function (_, data) {
  10388. var modifiedData = data.slice(0);
  10389. for (var d = data.length - 1; d >= 0; d--) {
  10390. var item = data[d];
  10391. if (this.placeholder.id === item.id) {
  10392. modifiedData.splice(d, 1);
  10393. }
  10394. }
  10395. return modifiedData;
  10396. };
  10397. return HidePlaceholder;
  10398. });
  10399. define('select2/dropdown/infiniteScroll',[
  10400. 'jquery'
  10401. ], function ($) {
  10402. function InfiniteScroll (decorated, $element, options, dataAdapter) {
  10403. this.lastParams = {};
  10404. decorated.call(this, $element, options, dataAdapter);
  10405. this.$loadingMore = this.createLoadingMore();
  10406. this.loading = false;
  10407. }
  10408. InfiniteScroll.prototype.append = function (decorated, data) {
  10409. this.$loadingMore.remove();
  10410. this.loading = false;
  10411. decorated.call(this, data);
  10412. if (this.showLoadingMore(data)) {
  10413. this.$results.append(this.$loadingMore);
  10414. }
  10415. };
  10416. InfiniteScroll.prototype.bind = function (decorated, container, $container) {
  10417. var self = this;
  10418. decorated.call(this, container, $container);
  10419. container.on('query', function (params) {
  10420. self.lastParams = params;
  10421. self.loading = true;
  10422. });
  10423. container.on('query:append', function (params) {
  10424. self.lastParams = params;
  10425. self.loading = true;
  10426. });
  10427. this.$results.on('scroll', function () {
  10428. var isLoadMoreVisible = $.contains(
  10429. document.documentElement,
  10430. self.$loadingMore[0]
  10431. );
  10432. if (self.loading || !isLoadMoreVisible) {
  10433. return;
  10434. }
  10435. var currentOffset = self.$results.offset().top +
  10436. self.$results.outerHeight(false);
  10437. var loadingMoreOffset = self.$loadingMore.offset().top +
  10438. self.$loadingMore.outerHeight(false);
  10439. if (currentOffset + 50 >= loadingMoreOffset) {
  10440. self.loadMore();
  10441. }
  10442. });
  10443. };
  10444. InfiniteScroll.prototype.loadMore = function () {
  10445. this.loading = true;
  10446. var params = $.extend({}, {page: 1}, this.lastParams);
  10447. params.page++;
  10448. this.trigger('query:append', params);
  10449. };
  10450. InfiniteScroll.prototype.showLoadingMore = function (_, data) {
  10451. return data.pagination && data.pagination.more;
  10452. };
  10453. InfiniteScroll.prototype.createLoadingMore = function () {
  10454. var $option = $(
  10455. '<li class="option load-more" role="treeitem"></li>'
  10456. );
  10457. var message = this.options.get('translations').get('loadingMore');
  10458. $option.html(message(this.lastParams));
  10459. return $option;
  10460. };
  10461. return InfiniteScroll;
  10462. });
  10463. define('select2/dropdown/attachBody',[
  10464. ], function () {
  10465. function AttachBody (decorated, $element, options) {
  10466. this.$dropdownParent = options.get('dropdownParent') || document.body;
  10467. decorated.call(this, $element, options);
  10468. }
  10469. AttachBody.prototype.bind = function (decorated, container, $container) {
  10470. var self = this;
  10471. var setupResultsEvents = false;
  10472. decorated.call(this, container, $container);
  10473. container.on('open', function () {
  10474. self._showDropdown();
  10475. if (!setupResultsEvents) {
  10476. setupResultsEvents = true;
  10477. container.on('results:all', function () {
  10478. self._positionDropdown();
  10479. });
  10480. container.on('results:append', function () {
  10481. self._positionDropdown();
  10482. });
  10483. }
  10484. });
  10485. container.on('close', function () {
  10486. self._hideDropdown();
  10487. });
  10488. this.$dropdownContainer.on('mousedown', function (evt) {
  10489. evt.stopPropagation();
  10490. });
  10491. };
  10492. AttachBody.prototype.position = function (decorated, $dropdown, $container) {
  10493. // Clone all of the container classes
  10494. $dropdown.attr('class', $container.attr('class'));
  10495. $dropdown.removeClass('select2');
  10496. $dropdown.addClass('select2-container--open');
  10497. $dropdown.css({
  10498. position: 'absolute'
  10499. });
  10500. $dropdown.width($container.outerWidth(false));
  10501. this.$container = $container;
  10502. };
  10503. AttachBody.prototype.render = function (decorated) {
  10504. var $container = $('<span></span>');
  10505. var $dropdown = decorated.call(this);
  10506. $container.append($dropdown);
  10507. this.$dropdownContainer = $container;
  10508. return $container;
  10509. };
  10510. AttachBody.prototype._hideDropdown = function (decorated) {
  10511. this.$dropdownContainer.detach();
  10512. };
  10513. AttachBody.prototype._positionDropdown = function () {
  10514. var $window = $(window);
  10515. var isCurrentlyAbove = this.$dropdown.hasClass('select2-dropdown--above');
  10516. var isCurrentlyBelow = this.$dropdown.hasClass('select2-dropdown--below');
  10517. var newDirection = null;
  10518. var position = this.$container.position();
  10519. var offset = this.$container.offset();
  10520. offset.bottom = offset.top + this.$container.outerHeight(false);
  10521. var container = {
  10522. height: this.$container.outerHeight(false)
  10523. };
  10524. container.top = offset.top;
  10525. container.bottom = offset.top + container.height;
  10526. var dropdown = {
  10527. height: this.$dropdown.outerHeight(false)
  10528. };
  10529. var viewport = {
  10530. top: $window.scrollTop(),
  10531. bottom: $window.scrollTop() + $window.height()
  10532. };
  10533. var enoughRoomAbove = viewport.top < (offset.top - dropdown.height);
  10534. var enoughRoomBelow = viewport.bottom > (offset.bottom + dropdown.height);
  10535. var css = {
  10536. left: offset.left,
  10537. top: container.bottom
  10538. };
  10539. if (!isCurrentlyAbove && !isCurrentlyBelow) {
  10540. newDirection = 'below';
  10541. }
  10542. if (!enoughRoomBelow && enoughRoomAbove && !isCurrentlyAbove) {
  10543. newDirection = 'above';
  10544. } else if (!enoughRoomAbove && enoughRoomBelow && isCurrentlyAbove) {
  10545. newDirection = 'below';
  10546. }
  10547. if (newDirection == 'above' || isCurrentlyAbove) {
  10548. css.top = container.top - dropdown.height;
  10549. }
  10550. if (newDirection != null) {
  10551. this.$dropdown
  10552. .removeClass('select2-dropdown--below select2-dropdown--above')
  10553. .addClass('select2-dropdown--' + newDirection);
  10554. this.$container
  10555. .removeClass('select2-container--below select2-container--above')
  10556. .addClass('select2-container--' + newDirection);
  10557. }
  10558. this.$dropdownContainer.css(css);
  10559. };
  10560. AttachBody.prototype._showDropdown = function (decorated) {
  10561. this.$dropdownContainer.appendTo(this.$dropdownParent);
  10562. this._positionDropdown();
  10563. };
  10564. return AttachBody;
  10565. });
  10566. define('select2/dropdown/minimumResultsForSearch',[
  10567. ], function () {
  10568. function countResults (data) {
  10569. count = 0;
  10570. for (var d = 0; d < data.length; d++) {
  10571. var item = data[d];
  10572. if (item.children) {
  10573. count += countResults(item.children);
  10574. } else {
  10575. count++;
  10576. }
  10577. }
  10578. return count;
  10579. }
  10580. function MinimumResultsForSearch (decorated, $element, options, dataAdapter) {
  10581. this.minimumResultsForSearch = options.get('minimumResultsForSearch');
  10582. decorated.call(this, $element, options, dataAdapter);
  10583. }
  10584. MinimumResultsForSearch.prototype.showSearch = function (decorated, params) {
  10585. if (countResults(params.data.results) < this.minimumResultsForSearch) {
  10586. return false;
  10587. }
  10588. return decorated.call(this, params);
  10589. };
  10590. return MinimumResultsForSearch;
  10591. });
  10592. define('select2/i18n/en',[],function () {
  10593. // English
  10594. return {
  10595. errorLoading: function () {
  10596. return 'The results could not be loaded.';
  10597. },
  10598. inputTooLong: function (args) {
  10599. var overChars = args.input.length - args.maximum;
  10600. var message = 'Please delete ' + overChars + ' character';
  10601. if (overChars != 1) {
  10602. message += 's';
  10603. }
  10604. return message;
  10605. },
  10606. inputTooShort: function (args) {
  10607. var remainingChars = args.minimum - args.input.length;
  10608. var message = 'Please enter ' + remainingChars + ' or more characters';
  10609. return message;
  10610. },
  10611. loadingMore: function () {
  10612. return 'Loading more results…';
  10613. },
  10614. maximumSelected: function (args) {
  10615. var message = 'You can only select ' + args.maximum + ' item';
  10616. if (args.maximum != 1) {
  10617. message += 's';
  10618. }
  10619. return message;
  10620. },
  10621. noResults: function () {
  10622. return 'No results found';
  10623. },
  10624. searching: function () {
  10625. return 'Searching…';
  10626. }
  10627. };
  10628. });
  10629. define('select2/defaults',[
  10630. 'jquery',
  10631. './results',
  10632. './selection/single',
  10633. './selection/multiple',
  10634. './selection/placeholder',
  10635. './selection/allowClear',
  10636. './selection/search',
  10637. './selection/eventRelay',
  10638. './utils',
  10639. './translation',
  10640. './diacritics',
  10641. './data/select',
  10642. './data/array',
  10643. './data/ajax',
  10644. './data/tags',
  10645. './data/tokenizer',
  10646. './data/minimumInputLength',
  10647. './data/maximumInputLength',
  10648. './dropdown',
  10649. './dropdown/search',
  10650. './dropdown/hidePlaceholder',
  10651. './dropdown/infiniteScroll',
  10652. './dropdown/attachBody',
  10653. './dropdown/minimumResultsForSearch',
  10654. './i18n/en'
  10655. ], function ($, ResultsList,
  10656. SingleSelection, MultipleSelection, Placeholder, AllowClear,
  10657. SelectionSearch, EventRelay,
  10658. Utils, Translation, DIACRITICS,
  10659. SelectData, ArrayData, AjaxData, Tags, Tokenizer,
  10660. MinimumInputLength, MaximumInputLength,
  10661. Dropdown, DropdownSearch, HidePlaceholder, InfiniteScroll,
  10662. AttachBody, MinimumResultsForSearch,
  10663. EnglishTranslation) {
  10664. function Defaults () {
  10665. this.reset();
  10666. }
  10667. Defaults.prototype.apply = function (options) {
  10668. options = $.extend({}, this.defaults, options);
  10669. if (options.dataAdapter == null) {
  10670. if (options.ajax != null) {
  10671. options.dataAdapter = AjaxData;
  10672. } else if (options.data != null) {
  10673. options.dataAdapter = ArrayData;
  10674. } else {
  10675. options.dataAdapter = SelectData;
  10676. }
  10677. if (options.minimumInputLength > 0) {
  10678. options.dataAdapter = Utils.Decorate(
  10679. options.dataAdapter,
  10680. MinimumInputLength
  10681. );
  10682. }
  10683. if (options.maximumInputLength > 0) {
  10684. options.dataAdapter = Utils.Decorate(
  10685. options.dataAdapter,
  10686. MaximumInputLength
  10687. );
  10688. }
  10689. if (options.tags != null) {
  10690. options.dataAdapter = Utils.Decorate(options.dataAdapter, Tags);
  10691. }
  10692. if (options.tokenSeparators != null || options.tokenizer != null) {
  10693. options.dataAdapter = Utils.Decorate(
  10694. options.dataAdapter,
  10695. Tokenizer
  10696. );
  10697. }
  10698. }
  10699. if (options.resultsAdapter == null) {
  10700. options.resultsAdapter = ResultsList;
  10701. if (options.ajax != null) {
  10702. options.resultsAdapter = Utils.Decorate(
  10703. options.resultsAdapter,
  10704. InfiniteScroll
  10705. );
  10706. }
  10707. if (options.placeholder != null) {
  10708. options.resultsAdapter = Utils.Decorate(
  10709. options.resultsAdapter,
  10710. HidePlaceholder
  10711. );
  10712. }
  10713. }
  10714. if (options.dropdownAdapter == null) {
  10715. if (options.multiple) {
  10716. options.dropdownAdapter = Dropdown;
  10717. } else {
  10718. var SearchableDropdown = Utils.Decorate(Dropdown, DropdownSearch);
  10719. options.dropdownAdapter = SearchableDropdown;
  10720. }
  10721. if (options.minimumResultsForSearch > 0) {
  10722. options.dropdownAdapter = Utils.Decorate(
  10723. options.dropdownAdapter,
  10724. MinimumResultsForSearch
  10725. );
  10726. }
  10727. options.dropdownAdapter = Utils.Decorate(
  10728. options.dropdownAdapter,
  10729. AttachBody
  10730. );
  10731. }
  10732. if (options.selectionAdapter == null) {
  10733. if (options.multiple) {
  10734. options.selectionAdapter = MultipleSelection;
  10735. } else {
  10736. options.selectionAdapter = SingleSelection;
  10737. }
  10738. // Add the placeholder mixin if a placeholder was specified
  10739. if (options.placeholder != null) {
  10740. options.selectionAdapter = Utils.Decorate(
  10741. options.selectionAdapter,
  10742. Placeholder
  10743. );
  10744. if (options.allowClear) {
  10745. options.selectionAdapter = Utils.Decorate(
  10746. options.selectionAdapter,
  10747. AllowClear
  10748. );
  10749. }
  10750. }
  10751. if (options.multiple) {
  10752. options.selectionAdapter = Utils.Decorate(
  10753. options.selectionAdapter,
  10754. SelectionSearch
  10755. );
  10756. }
  10757. options.selectionAdapter = Utils.Decorate(
  10758. options.selectionAdapter,
  10759. EventRelay
  10760. );
  10761. }
  10762. if (typeof options.language === 'string') {
  10763. options.language = [options.language];
  10764. }
  10765. if ($.isArray(options.language)) {
  10766. var languages = new Translation();
  10767. options.language.push('en');
  10768. var languageNames = options.language;
  10769. for (var l = 0; l < languageNames.length; l++) {
  10770. var name = languageNames[l];
  10771. var language = {};
  10772. try {
  10773. // Try to load it with the original name
  10774. language = Translation.loadPath(name);
  10775. } catch (e) {
  10776. // If we couldn't load it, check if it wasn't the full path
  10777. name = 'select2/i18n/' + name;
  10778. language = Translation.loadPath(name);
  10779. }
  10780. languages.extend(language);
  10781. }
  10782. options.translations = languages;
  10783. } else {
  10784. options.translations = new Translation(options.language);
  10785. }
  10786. return options;
  10787. };
  10788. Defaults.prototype.reset = function () {
  10789. function stripDiacritics (text) {
  10790. // Used 'uni range + named function' from http://jsperf.com/diacritics/18
  10791. function match(a) {
  10792. return DIACRITICS[a] || a;
  10793. }
  10794. return text.replace(/[^\u0000-\u007E]/g, match);
  10795. }
  10796. function matcher (params, data) {
  10797. // Always return the object if there is nothing to compare
  10798. if ($.trim(params.term) === '') {
  10799. return data;
  10800. }
  10801. // Do a recursive check for options with children
  10802. if (data.children && data.children.length > 0) {
  10803. // Clone the data object if there are children
  10804. // This is required as we modify the object to remove any non-matches
  10805. var match = $.extend(true, {}, data);
  10806. // Check each child of the option
  10807. for (var c = data.children.length - 1; c >= 0; c--) {
  10808. var child = data.children[c];
  10809. var matches = matcher(params, child);
  10810. // If there wasn't a match, remove the object in the array
  10811. if (matches == null) {
  10812. match.children.splice(c, 1);
  10813. }
  10814. }
  10815. // If any children matched, return the new object
  10816. if (match.children.length > 0) {
  10817. return match;
  10818. }
  10819. // If there were no matching children, check just the plain object
  10820. return matcher(params, match);
  10821. }
  10822. var original = stripDiacritics(data.text).toUpperCase();
  10823. var term = stripDiacritics(params.term).toUpperCase();
  10824. // Check if the text contains the term
  10825. if (original.indexOf(term) > -1) {
  10826. return data;
  10827. }
  10828. // If it doesn't contain the term, don't return anything
  10829. return null;
  10830. }
  10831. this.defaults = {
  10832. language: EnglishTranslation,
  10833. matcher: matcher,
  10834. sorter: function (data) {
  10835. return data;
  10836. },
  10837. minimumInputLength: 0,
  10838. maximumInputLength: 0,
  10839. minimumResultsForSearch: 0,
  10840. templateResult: function (result) {
  10841. return result.text;
  10842. },
  10843. templateSelection: function (selection) {
  10844. return selection.text;
  10845. },
  10846. theme: 'default'
  10847. };
  10848. };
  10849. var defaults = new Defaults();
  10850. return defaults;
  10851. });
  10852. define('select2/options',[
  10853. 'jquery',
  10854. './defaults'
  10855. ], function ($, Defaults) {
  10856. function Options (options, $element) {
  10857. this.options = options;
  10858. if ($element != null) {
  10859. this.fromElement($element);
  10860. }
  10861. this.options = Defaults.apply(this.options);
  10862. }
  10863. Options.prototype.fromElement = function ($e) {
  10864. var excludedData = ['select2'];
  10865. if (this.options.multiple == null) {
  10866. this.options.multiple = $e.prop('multiple');
  10867. }
  10868. if (this.options.disabled == null) {
  10869. this.options.disabled = $e.prop('disabled');
  10870. }
  10871. if (this.options.language == null) {
  10872. if ($e.prop('lang')) {
  10873. this.options.language = $e.prop('lang').toLowerCase();
  10874. } else if ($e.closest('[lang]').prop('lang')) {
  10875. this.options.language = $e.closest('[lang]').prop('lang');
  10876. }
  10877. }
  10878. if (this.options.dir == null) {
  10879. if ($e.prop('dir')) {
  10880. this.options.dir = $e.prop('dir');
  10881. } else if ($e.closest('[dir]').prop('dir')) {
  10882. this.options.dir = $e.closest('[dir]').prop('dir');
  10883. } else {
  10884. this.options.dir = 'ltr';
  10885. }
  10886. }
  10887. $e.prop('disabled', this.options.disabled);
  10888. $e.prop('multiple', this.options.multiple);
  10889. if ($e.data('select2-tags')) {
  10890. if (console && console.warn) {
  10891. console.warn(
  10892. 'Select2: The `data-select2-tags` attribute has been changed to ' +
  10893. 'use the `data-data` and `data-tags="true"` attributes and will be ' +
  10894. 'removed in future versions of Select2.'
  10895. );
  10896. }
  10897. $e.data('data', $e.data('select2-tags'));
  10898. $e.data('tags', true);
  10899. }
  10900. if ($e.data('ajax-url')) {
  10901. if (console && console.warn) {
  10902. console.warn(
  10903. 'Select2: The `data-ajax-attribute` has been changed to ' +
  10904. '`data-ajax--url` and support for the old attribute will be removed' +
  10905. ' in future versions of Select2.'
  10906. );
  10907. }
  10908. $e.data('ajax--url', $e.data('ajax-url'));
  10909. }
  10910. var data = $e.data();
  10911. function convertData (data) {
  10912. for (var originalKey in data) {
  10913. var keys = originalKey.split('-');
  10914. var dataLevel = data;
  10915. if (keys.length === 1) {
  10916. continue;
  10917. }
  10918. for (var k = 0; k < keys.length; k++) {
  10919. var key = keys[k];
  10920. // Lowercase the first letter
  10921. // By default, dash-separated becomes camelCase
  10922. key = key.substring(0, 1).toLowerCase() + key.substring(1);
  10923. if (!(key in dataLevel)) {
  10924. dataLevel[key] = {};
  10925. }
  10926. if (k == keys.length - 1) {
  10927. dataLevel[key] = data[originalKey];
  10928. }
  10929. dataLevel = dataLevel[key];
  10930. }
  10931. delete data[originalKey];
  10932. }
  10933. return data;
  10934. }
  10935. data = convertData(data);
  10936. for (var key in data) {
  10937. if (excludedData.indexOf(key) > -1) {
  10938. continue;
  10939. }
  10940. if ($.isPlainObject(this.options[key])) {
  10941. $.extend(this.options[key], data[key]);
  10942. } else {
  10943. this.options[key] = data[key];
  10944. }
  10945. }
  10946. return this;
  10947. };
  10948. Options.prototype.get = function (key) {
  10949. return this.options[key];
  10950. };
  10951. Options.prototype.set = function (key, val) {
  10952. this.options[key] = val;
  10953. };
  10954. return Options;
  10955. });
  10956. define('select2/core',[
  10957. 'jquery',
  10958. './options',
  10959. './utils',
  10960. './keys'
  10961. ], function ($, Options, Utils, KEYS) {
  10962. var Select2 = function ($element, options) {
  10963. if ($element.data('select2') != null) {
  10964. $element.data('select2').destroy();
  10965. }
  10966. this.$element = $element;
  10967. this.id = this._generateId($element);
  10968. options = options || {};
  10969. this.options = new Options(options, $element);
  10970. Select2.__super__.constructor.call(this);
  10971. // Set up containers and adapters
  10972. var DataAdapter = this.options.get('dataAdapter');
  10973. this.data = new DataAdapter($element, this.options);
  10974. var $container = this.render();
  10975. this._placeContainer($container);
  10976. var SelectionAdapter = this.options.get('selectionAdapter');
  10977. this.selection = new SelectionAdapter($element, this.options);
  10978. this.$selection = this.selection.render();
  10979. this.selection.position(this.$selection, $container);
  10980. var DropdownAdapter = this.options.get('dropdownAdapter');
  10981. this.dropdown = new DropdownAdapter($element, this.options);
  10982. this.$dropdown = this.dropdown.render();
  10983. this.dropdown.position(this.$dropdown, $container);
  10984. var ResultsAdapter = this.options.get('resultsAdapter');
  10985. this.results = new ResultsAdapter($element, this.options, this.data);
  10986. this.$results = this.results.render();
  10987. this.results.position(this.$results, this.$dropdown);
  10988. // Bind events
  10989. var self = this;
  10990. // Bind the container to all of the adapters
  10991. this._bindAdapters();
  10992. // Register any DOM event handlers
  10993. this._registerDomEvents();
  10994. // Register any internal event handlers
  10995. this._registerDataEvents();
  10996. this._registerSelectionEvents();
  10997. this._registerDropdownEvents();
  10998. this._registerResultsEvents();
  10999. this._registerEvents();
  11000. // Set the initial state
  11001. this.data.current(function (initialData) {
  11002. self.trigger('selection:update', {
  11003. data: initialData
  11004. });
  11005. });
  11006. // Hide the original select
  11007. $element.hide();
  11008. // Synchronize any monitored attributes
  11009. this._syncAttributes();
  11010. this._tabindex = $element.attr('tabindex') || 0;
  11011. $element.attr('tabindex', '-1');
  11012. $element.data('select2', this);
  11013. };
  11014. Utils.Extend(Select2, Utils.Observable);
  11015. Select2.prototype._generateId = function ($element) {
  11016. var id = '';
  11017. if ($element.attr('id') != null) {
  11018. id = $element.attr('id');
  11019. } else if ($element.attr('name') != null) {
  11020. id = $element.attr('name') + '-' + Utils.generateChars(2);
  11021. } else {
  11022. id = Utils.generateChars(4);
  11023. }
  11024. id = 'select2-' + id;
  11025. return id;
  11026. };
  11027. Select2.prototype._placeContainer = function ($container) {
  11028. $container.insertAfter(this.$element);
  11029. $container.width(this.$element.outerWidth(false));
  11030. };
  11031. Select2.prototype._bindAdapters = function () {
  11032. this.data.bind(this, this.$container);
  11033. this.selection.bind(this, this.$container);
  11034. this.dropdown.bind(this, this.$container);
  11035. this.results.bind(this, this.$container);
  11036. };
  11037. Select2.prototype._registerDomEvents = function () {
  11038. var self = this;
  11039. this.$element.on('change.select2', function () {
  11040. self.data.current(function (data) {
  11041. self.trigger('selection:update', {
  11042. data: data
  11043. });
  11044. });
  11045. });
  11046. this._sync = Utils.bind(this._syncAttributes, this);
  11047. if (this.$element[0].attachEvent) {
  11048. this.$element[0].attachEvent('onpropertychange', this._sync);
  11049. }
  11050. var observer = window.MutationObserver ||
  11051. window.WebKitMutationObserver ||
  11052. window.MozMutationObserver
  11053. ;
  11054. if (observer != null) {
  11055. this._observer = new observer(function (mutations) {
  11056. $.each(mutations, self._sync);
  11057. });
  11058. this._observer.observe(this.$element[0], {
  11059. attributes: true,
  11060. subtree: false
  11061. });
  11062. }
  11063. };
  11064. Select2.prototype._registerDataEvents = function () {
  11065. var self = this;
  11066. this.data.on('*', function (name, params) {
  11067. self.trigger(name, params);
  11068. });
  11069. };
  11070. Select2.prototype._registerSelectionEvents = function () {
  11071. var self = this;
  11072. var nonRelayEvents = ['toggle'];
  11073. this.selection.on('toggle', function () {
  11074. self.toggleDropdown();
  11075. });
  11076. this.selection.on('*', function (name, params) {
  11077. if (nonRelayEvents.indexOf(name) !== -1) {
  11078. return;
  11079. }
  11080. self.trigger(name, params);
  11081. });
  11082. };
  11083. Select2.prototype._registerDropdownEvents = function () {
  11084. var self = this;
  11085. this.dropdown.on('*', function (name, params) {
  11086. self.trigger(name, params);
  11087. });
  11088. };
  11089. Select2.prototype._registerResultsEvents = function () {
  11090. var self = this;
  11091. this.results.on('*', function (name, params) {
  11092. self.trigger(name, params);
  11093. });
  11094. };
  11095. Select2.prototype._registerEvents = function () {
  11096. var self = this;
  11097. this.on('open', function () {
  11098. self.$container.addClass('select2-container--open');
  11099. });
  11100. this.on('close', function () {
  11101. self.$container.removeClass('select2-container--open');
  11102. });
  11103. this.on('enable', function () {
  11104. self.$container.removeClass('select2-container--disabled');
  11105. });
  11106. this.on('disable', function () {
  11107. self.$container.addClass('select2-container--disabled');
  11108. });
  11109. this.on('query', function (params) {
  11110. this.data.query(params, function (data) {
  11111. self.trigger('results:all', {
  11112. data: data,
  11113. query: params
  11114. });
  11115. });
  11116. });
  11117. this.on('query:append', function (params) {
  11118. this.data.query(params, function (data) {
  11119. self.trigger('results:append', {
  11120. data: data,
  11121. query: params
  11122. });
  11123. });
  11124. });
  11125. this.on('keypress', function (evt) {
  11126. var key = evt.which;
  11127. if (self.isOpen()) {
  11128. if (key === KEYS.ENTER) {
  11129. self.trigger('results:select');
  11130. evt.preventDefault();
  11131. } else if (key === KEYS.UP) {
  11132. self.trigger('results:previous');
  11133. evt.preventDefault();
  11134. } else if (key === KEYS.DOWN) {
  11135. self.trigger('results:next');
  11136. evt.preventDefault();
  11137. } else if (key === KEYS.ESC || key === KEYS.TAB) {
  11138. self.close();
  11139. evt.preventDefault();
  11140. }
  11141. } else {
  11142. if (key === KEYS.ENTER || key === KEYS.SPACE ||
  11143. ((key === KEYS.DOWN || key === KEYS.UP) && evt.altKey)) {
  11144. self.open();
  11145. evt.preventDefault();
  11146. }
  11147. }
  11148. });
  11149. };
  11150. Select2.prototype._syncAttributes = function () {
  11151. this.options.set('disabled', this.$element.prop('disabled'));
  11152. if (this.options.get('disabled')) {
  11153. if (this.isOpen()) {
  11154. this.trigger('close');
  11155. }
  11156. this.trigger('disable');
  11157. } else {
  11158. this.trigger('enable');
  11159. }
  11160. };
  11161. Select2.prototype.toggleDropdown = function () {
  11162. if (this.options.get('disabled')) {
  11163. return;
  11164. }
  11165. if (this.isOpen()) {
  11166. this.close();
  11167. } else {
  11168. this.open();
  11169. }
  11170. };
  11171. Select2.prototype.open = function () {
  11172. if (this.isOpen()) {
  11173. return;
  11174. }
  11175. this.trigger('query', {});
  11176. this.trigger('open');
  11177. };
  11178. Select2.prototype.close = function () {
  11179. if (!this.isOpen()) {
  11180. return;
  11181. }
  11182. this.trigger('close');
  11183. };
  11184. Select2.prototype.isOpen = function () {
  11185. return this.$container.hasClass('select2-container--open');
  11186. };
  11187. Select2.prototype.enable = function (args) {
  11188. if (console && console.warn) {
  11189. console.warn(
  11190. 'Select2: The `select2("enable")` method has been deprecated and will' +
  11191. ' be removed in later Select2 versions. Use $element.prop("disabled")' +
  11192. ' instead.'
  11193. );
  11194. }
  11195. if (args.length === 0) {
  11196. args = [true];
  11197. }
  11198. var disabled = !args[0];
  11199. this.$element.prop('disabled', disabled);
  11200. };
  11201. Select2.prototype.val = function (args) {
  11202. if (console && console.warn) {
  11203. console.warn(
  11204. 'Select2: The `select2("val")` method has been deprecated and will be' +
  11205. ' removed in later Select2 versions. Use $element.val() instead.'
  11206. );
  11207. }
  11208. if (args.length === 0) {
  11209. return this.$element.val();
  11210. }
  11211. var newVal = args[0];
  11212. if ($.isArray(newVal)) {
  11213. newVal = $.map(newVal, function (obj) {
  11214. return obj.toString();
  11215. });
  11216. }
  11217. this.$element.val(newVal).trigger('change');
  11218. };
  11219. Select2.prototype.destroy = function () {
  11220. this.$container.remove();
  11221. if (this.$element[0].detachEvent) {
  11222. this.$element[0].detachEvent('onpropertychange', this._sync);
  11223. }
  11224. if (this._observer != null) {
  11225. this._observer.disconnect();
  11226. this._observer = null;
  11227. }
  11228. this._sync = null;
  11229. this.$element.off('.select2');
  11230. this.$element.attr('tabindex', this._tabindex);
  11231. this.$element.show();
  11232. this.$element.removeData('select2');
  11233. this.data.destroy();
  11234. this.selection.destroy();
  11235. this.dropdown.destroy();
  11236. this.results.destroy();
  11237. this.data = null;
  11238. this.selection = null;
  11239. this.dropdown = null;
  11240. this.results = null;
  11241. };
  11242. Select2.prototype.render = function () {
  11243. var $container = $(
  11244. '<span class="select2 select2-container">' +
  11245. '<span class="selection"></span>' +
  11246. '<span class="dropdown-wrapper" aria-hidden="true"></span>' +
  11247. '</span>'
  11248. );
  11249. $container.attr('dir', this.options.get('dir'));
  11250. this.$container = $container;
  11251. this.$container.addClass('select2-container--' + this.options.get('theme'));
  11252. $container.data('element', this.$element);
  11253. return $container;
  11254. };
  11255. return Select2;
  11256. });
  11257. /*!
  11258. * jQuery Mousewheel 3.1.12
  11259. *
  11260. * Copyright 2014 jQuery Foundation and other contributors
  11261. * Released under the MIT license.
  11262. * http://jquery.org/license
  11263. */
  11264. (function (factory) {
  11265. if ( typeof define === 'function' && define.amd ) {
  11266. // AMD. Register as an anonymous module.
  11267. define('jquery.mousewheel',['jquery'], factory);
  11268. } else if (typeof exports === 'object') {
  11269. // Node/CommonJS style for Browserify
  11270. module.exports = factory;
  11271. } else {
  11272. // Browser globals
  11273. factory(jQuery);
  11274. }
  11275. }(function ($) {
  11276. var toFix = ['wheel', 'mousewheel', 'DOMMouseScroll', 'MozMousePixelScroll'],
  11277. toBind = ( 'onwheel' in document || document.documentMode >= 9 ) ?
  11278. ['wheel'] : ['mousewheel', 'DomMouseScroll', 'MozMousePixelScroll'],
  11279. slice = Array.prototype.slice,
  11280. nullLowestDeltaTimeout, lowestDelta;
  11281. if ( $.event.fixHooks ) {
  11282. for ( var i = toFix.length; i; ) {
  11283. $.event.fixHooks[ toFix[--i] ] = $.event.mouseHooks;
  11284. }
  11285. }
  11286. var special = $.event.special.mousewheel = {
  11287. version: '3.1.12',
  11288. setup: function() {
  11289. if ( this.addEventListener ) {
  11290. for ( var i = toBind.length; i; ) {
  11291. this.addEventListener( toBind[--i], handler, false );
  11292. }
  11293. } else {
  11294. this.onmousewheel = handler;
  11295. }
  11296. // Store the line height and page height for this particular element
  11297. $.data(this, 'mousewheel-line-height', special.getLineHeight(this));
  11298. $.data(this, 'mousewheel-page-height', special.getPageHeight(this));
  11299. },
  11300. teardown: function() {
  11301. if ( this.removeEventListener ) {
  11302. for ( var i = toBind.length; i; ) {
  11303. this.removeEventListener( toBind[--i], handler, false );
  11304. }
  11305. } else {
  11306. this.onmousewheel = null;
  11307. }
  11308. // Clean up the data we added to the element
  11309. $.removeData(this, 'mousewheel-line-height');
  11310. $.removeData(this, 'mousewheel-page-height');
  11311. },
  11312. getLineHeight: function(elem) {
  11313. var $elem = $(elem),
  11314. $parent = $elem['offsetParent' in $.fn ? 'offsetParent' : 'parent']();
  11315. if (!$parent.length) {
  11316. $parent = $('body');
  11317. }
  11318. return parseInt($parent.css('fontSize'), 10) || parseInt($elem.css('fontSize'), 10) || 16;
  11319. },
  11320. getPageHeight: function(elem) {
  11321. return $(elem).height();
  11322. },
  11323. settings: {
  11324. adjustOldDeltas: true, // see shouldAdjustOldDeltas() below
  11325. normalizeOffset: true // calls getBoundingClientRect for each event
  11326. }
  11327. };
  11328. $.fn.extend({
  11329. mousewheel: function(fn) {
  11330. return fn ? this.bind('mousewheel', fn) : this.trigger('mousewheel');
  11331. },
  11332. unmousewheel: function(fn) {
  11333. return this.unbind('mousewheel', fn);
  11334. }
  11335. });
  11336. function handler(event) {
  11337. var orgEvent = event || window.event,
  11338. args = slice.call(arguments, 1),
  11339. delta = 0,
  11340. deltaX = 0,
  11341. deltaY = 0,
  11342. absDelta = 0,
  11343. offsetX = 0,
  11344. offsetY = 0;
  11345. event = $.event.fix(orgEvent);
  11346. event.type = 'mousewheel';
  11347. // Old school scrollwheel delta
  11348. if ( 'detail' in orgEvent ) { deltaY = orgEvent.detail * -1; }
  11349. if ( 'wheelDelta' in orgEvent ) { deltaY = orgEvent.wheelDelta; }
  11350. if ( 'wheelDeltaY' in orgEvent ) { deltaY = orgEvent.wheelDeltaY; }
  11351. if ( 'wheelDeltaX' in orgEvent ) { deltaX = orgEvent.wheelDeltaX * -1; }
  11352. // Firefox < 17 horizontal scrolling related to DOMMouseScroll event
  11353. if ( 'axis' in orgEvent && orgEvent.axis === orgEvent.HORIZONTAL_AXIS ) {
  11354. deltaX = deltaY * -1;
  11355. deltaY = 0;
  11356. }
  11357. // Set delta to be deltaY or deltaX if deltaY is 0 for backwards compatabilitiy
  11358. delta = deltaY === 0 ? deltaX : deltaY;
  11359. // New school wheel delta (wheel event)
  11360. if ( 'deltaY' in orgEvent ) {
  11361. deltaY = orgEvent.deltaY * -1;
  11362. delta = deltaY;
  11363. }
  11364. if ( 'deltaX' in orgEvent ) {
  11365. deltaX = orgEvent.deltaX;
  11366. if ( deltaY === 0 ) { delta = deltaX * -1; }
  11367. }
  11368. // No change actually happened, no reason to go any further
  11369. if ( deltaY === 0 && deltaX === 0 ) { return; }
  11370. // Need to convert lines and pages to pixels if we aren't already in pixels
  11371. // There are three delta modes:
  11372. // * deltaMode 0 is by pixels, nothing to do
  11373. // * deltaMode 1 is by lines
  11374. // * deltaMode 2 is by pages
  11375. if ( orgEvent.deltaMode === 1 ) {
  11376. var lineHeight = $.data(this, 'mousewheel-line-height');
  11377. delta *= lineHeight;
  11378. deltaY *= lineHeight;
  11379. deltaX *= lineHeight;
  11380. } else if ( orgEvent.deltaMode === 2 ) {
  11381. var pageHeight = $.data(this, 'mousewheel-page-height');
  11382. delta *= pageHeight;
  11383. deltaY *= pageHeight;
  11384. deltaX *= pageHeight;
  11385. }
  11386. // Store lowest absolute delta to normalize the delta values
  11387. absDelta = Math.max( Math.abs(deltaY), Math.abs(deltaX) );
  11388. if ( !lowestDelta || absDelta < lowestDelta ) {
  11389. lowestDelta = absDelta;
  11390. // Adjust older deltas if necessary
  11391. if ( shouldAdjustOldDeltas(orgEvent, absDelta) ) {
  11392. lowestDelta /= 40;
  11393. }
  11394. }
  11395. // Adjust older deltas if necessary
  11396. if ( shouldAdjustOldDeltas(orgEvent, absDelta) ) {
  11397. // Divide all the things by 40!
  11398. delta /= 40;
  11399. deltaX /= 40;
  11400. deltaY /= 40;
  11401. }
  11402. // Get a whole, normalized value for the deltas
  11403. delta = Math[ delta >= 1 ? 'floor' : 'ceil' ](delta / lowestDelta);
  11404. deltaX = Math[ deltaX >= 1 ? 'floor' : 'ceil' ](deltaX / lowestDelta);
  11405. deltaY = Math[ deltaY >= 1 ? 'floor' : 'ceil' ](deltaY / lowestDelta);
  11406. // Normalise offsetX and offsetY properties
  11407. if ( special.settings.normalizeOffset && this.getBoundingClientRect ) {
  11408. var boundingRect = this.getBoundingClientRect();
  11409. offsetX = event.clientX - boundingRect.left;
  11410. offsetY = event.clientY - boundingRect.top;
  11411. }
  11412. // Add information to the event object
  11413. event.deltaX = deltaX;
  11414. event.deltaY = deltaY;
  11415. event.deltaFactor = lowestDelta;
  11416. event.offsetX = offsetX;
  11417. event.offsetY = offsetY;
  11418. // Go ahead and set deltaMode to 0 since we converted to pixels
  11419. // Although this is a little odd since we overwrite the deltaX/Y
  11420. // properties with normalized deltas.
  11421. event.deltaMode = 0;
  11422. // Add event and delta to the front of the arguments
  11423. args.unshift(event, delta, deltaX, deltaY);
  11424. // Clearout lowestDelta after sometime to better
  11425. // handle multiple device types that give different
  11426. // a different lowestDelta
  11427. // Ex: trackpad = 3 and mouse wheel = 120
  11428. if (nullLowestDeltaTimeout) { clearTimeout(nullLowestDeltaTimeout); }
  11429. nullLowestDeltaTimeout = setTimeout(nullLowestDelta, 200);
  11430. return ($.event.dispatch || $.event.handle).apply(this, args);
  11431. }
  11432. function nullLowestDelta() {
  11433. lowestDelta = null;
  11434. }
  11435. function shouldAdjustOldDeltas(orgEvent, absDelta) {
  11436. // If this is an older event and the delta is divisable by 120,
  11437. // then we are assuming that the browser is treating this as an
  11438. // older mouse wheel event and that we should divide the deltas
  11439. // by 40 to try and get a more usable deltaFactor.
  11440. // Side note, this actually impacts the reported scroll distance
  11441. // in older browsers and can cause scrolling to be slower than native.
  11442. // Turn this off by setting $.event.special.mousewheel.settings.adjustOldDeltas to false.
  11443. return special.settings.adjustOldDeltas && orgEvent.type === 'mousewheel' && absDelta % 120 === 0;
  11444. }
  11445. }));
  11446. define('select2/compat/matcher',[
  11447. ], function () {
  11448. function oldMatcher (matcher) {
  11449. function wrappedMatcher (params, data) {
  11450. var match = $.extend(true, {}, data);
  11451. if (params.term == null || $.trim(params.term) === '') {
  11452. return match;
  11453. }
  11454. if (data.children) {
  11455. for (var c = data.children.length - 1; c >= 0; c--) {
  11456. var child = data.children[c];
  11457. // Check if the child object matches
  11458. // The old matcher returned a boolean true or false
  11459. var doesMatch = matcher(params.term, child.text, child);
  11460. // If the child didn't match, pop it off
  11461. if (!doesMatch) {
  11462. match.children.splice(c, 1);
  11463. }
  11464. }
  11465. if (match.children.length > 0) {
  11466. return match;
  11467. }
  11468. }
  11469. if (matcher(params.term, data.text, data)) {
  11470. return match;
  11471. }
  11472. return null;
  11473. }
  11474. return wrappedMatcher;
  11475. }
  11476. return oldMatcher;
  11477. });
  11478. define('select2/dropdown/attachContainer',[
  11479. ], function () {
  11480. function AttachContainer (decorated, $element, options) {
  11481. decorated.call(this, $element, options);
  11482. }
  11483. AttachContainer.prototype.position =
  11484. function (decorated, $dropdown, $container) {
  11485. var $dropdownContainer = $container.find('.dropdown-wrapper');
  11486. $dropdownContainer.append($dropdown);
  11487. $dropdown.addClass('select2-dropdown--below');
  11488. $container.addClass('select2-container--below');
  11489. };
  11490. return AttachContainer;
  11491. });
  11492. define('jquery.select2',[
  11493. 'jquery',
  11494. 'select2/core'
  11495. ], function ($, Select2) {
  11496. // Force jQuery.mousewheel to be loaded if it hasn't already
  11497. try {
  11498. require('jquery.mousewheel');
  11499. } catch (Exception) { }
  11500. if ($.fn.select2 == null) {
  11501. $.fn.select2 = function (options) {
  11502. options = options || {};
  11503. if (typeof options === 'object') {
  11504. this.each(function () {
  11505. var instanceOptions = $.extend({}, options, true);
  11506. var instance = new Select2($(this), instanceOptions);
  11507. });
  11508. return this;
  11509. } else if (typeof options === 'string') {
  11510. var instance = this.data('select2');
  11511. var args = Array.prototype.slice.call(arguments, 1);
  11512. return instance[options](args);
  11513. } else {
  11514. throw new Error('Invalid arguments for Select2: ' + options);
  11515. }
  11516. };
  11517. }
  11518. return Select2;
  11519. });
  11520. require('jquery.select2'); $.fn.select2.amd = { define: define, require: require };}());