A website template with lots of features, built with ruby on rails.

application-969f39ea277b027cdaaed90e710d3fe7.js 512KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589
  1. /*!
  2. * jQuery JavaScript Library v1.11.1
  3. * http://jquery.com/
  4. *
  5. * Includes Sizzle.js
  6. * http://sizzlejs.com/
  7. *
  8. * Copyright 2005, 2014 jQuery Foundation, Inc. and other contributors
  9. * Released under the MIT license
  10. * http://jquery.org/license
  11. *
  12. * Date: 2014-05-01T17:42Z
  13. */
  14. (function( global, factory ) {
  15. if ( typeof module === "object" && typeof module.exports === "object" ) {
  16. // For CommonJS and CommonJS-like environments where a proper window is present,
  17. // execute the factory and get jQuery
  18. // For environments that do not inherently posses a window with a document
  19. // (such as Node.js), expose a jQuery-making factory as module.exports
  20. // This accentuates the need for the creation of a real window
  21. // e.g. var jQuery = require("jquery")(window);
  22. // See ticket #14549 for more info
  23. module.exports = global.document ?
  24. factory( global, true ) :
  25. function( w ) {
  26. if ( !w.document ) {
  27. throw new Error( "jQuery requires a window with a document" );
  28. }
  29. return factory( w );
  30. };
  31. } else {
  32. factory( global );
  33. }
  34. // Pass this if window is not defined yet
  35. }(typeof window !== "undefined" ? window : this, function( window, noGlobal ) {
  36. // Can't do this because several apps including ASP.NET trace
  37. // the stack via arguments.caller.callee and Firefox dies if
  38. // you try to trace through "use strict" call chains. (#13335)
  39. // Support: Firefox 18+
  40. //
  41. var deletedIds = [];
  42. var slice = deletedIds.slice;
  43. var concat = deletedIds.concat;
  44. var push = deletedIds.push;
  45. var indexOf = deletedIds.indexOf;
  46. var class2type = {};
  47. var toString = class2type.toString;
  48. var hasOwn = class2type.hasOwnProperty;
  49. var support = {};
  50. var
  51. version = "1.11.1",
  52. // Define a local copy of jQuery
  53. jQuery = function( selector, context ) {
  54. // The jQuery object is actually just the init constructor 'enhanced'
  55. // Need init if jQuery is called (just allow error to be thrown if not included)
  56. return new jQuery.fn.init( selector, context );
  57. },
  58. // Support: Android<4.1, IE<9
  59. // Make sure we trim BOM and NBSP
  60. rtrim = /^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,
  61. // Matches dashed string for camelizing
  62. rmsPrefix = /^-ms-/,
  63. rdashAlpha = /-([\da-z])/gi,
  64. // Used by jQuery.camelCase as callback to replace()
  65. fcamelCase = function( all, letter ) {
  66. return letter.toUpperCase();
  67. };
  68. jQuery.fn = jQuery.prototype = {
  69. // The current version of jQuery being used
  70. jquery: version,
  71. constructor: jQuery,
  72. // Start with an empty selector
  73. selector: "",
  74. // The default length of a jQuery object is 0
  75. length: 0,
  76. toArray: function() {
  77. return slice.call( this );
  78. },
  79. // Get the Nth element in the matched element set OR
  80. // Get the whole matched element set as a clean array
  81. get: function( num ) {
  82. return num != null ?
  83. // Return just the one element from the set
  84. ( num < 0 ? this[ num + this.length ] : this[ num ] ) :
  85. // Return all the elements in a clean array
  86. slice.call( this );
  87. },
  88. // Take an array of elements and push it onto the stack
  89. // (returning the new matched element set)
  90. pushStack: function( elems ) {
  91. // Build a new jQuery matched element set
  92. var ret = jQuery.merge( this.constructor(), elems );
  93. // Add the old object onto the stack (as a reference)
  94. ret.prevObject = this;
  95. ret.context = this.context;
  96. // Return the newly-formed element set
  97. return ret;
  98. },
  99. // Execute a callback for every element in the matched set.
  100. // (You can seed the arguments with an array of args, but this is
  101. // only used internally.)
  102. each: function( callback, args ) {
  103. return jQuery.each( this, callback, args );
  104. },
  105. map: function( callback ) {
  106. return this.pushStack( jQuery.map(this, function( elem, i ) {
  107. return callback.call( elem, i, elem );
  108. }));
  109. },
  110. slice: function() {
  111. return this.pushStack( slice.apply( this, arguments ) );
  112. },
  113. first: function() {
  114. return this.eq( 0 );
  115. },
  116. last: function() {
  117. return this.eq( -1 );
  118. },
  119. eq: function( i ) {
  120. var len = this.length,
  121. j = +i + ( i < 0 ? len : 0 );
  122. return this.pushStack( j >= 0 && j < len ? [ this[j] ] : [] );
  123. },
  124. end: function() {
  125. return this.prevObject || this.constructor(null);
  126. },
  127. // For internal use only.
  128. // Behaves like an Array's method, not like a jQuery method.
  129. push: push,
  130. sort: deletedIds.sort,
  131. splice: deletedIds.splice
  132. };
  133. jQuery.extend = jQuery.fn.extend = function() {
  134. var src, copyIsArray, copy, name, options, clone,
  135. target = arguments[0] || {},
  136. i = 1,
  137. length = arguments.length,
  138. deep = false;
  139. // Handle a deep copy situation
  140. if ( typeof target === "boolean" ) {
  141. deep = target;
  142. // skip the boolean and the target
  143. target = arguments[ i ] || {};
  144. i++;
  145. }
  146. // Handle case when target is a string or something (possible in deep copy)
  147. if ( typeof target !== "object" && !jQuery.isFunction(target) ) {
  148. target = {};
  149. }
  150. // extend jQuery itself if only one argument is passed
  151. if ( i === length ) {
  152. target = this;
  153. i--;
  154. }
  155. for ( ; i < length; i++ ) {
  156. // Only deal with non-null/undefined values
  157. if ( (options = arguments[ i ]) != null ) {
  158. // Extend the base object
  159. for ( name in options ) {
  160. src = target[ name ];
  161. copy = options[ name ];
  162. // Prevent never-ending loop
  163. if ( target === copy ) {
  164. continue;
  165. }
  166. // Recurse if we're merging plain objects or arrays
  167. if ( deep && copy && ( jQuery.isPlainObject(copy) || (copyIsArray = jQuery.isArray(copy)) ) ) {
  168. if ( copyIsArray ) {
  169. copyIsArray = false;
  170. clone = src && jQuery.isArray(src) ? src : [];
  171. } else {
  172. clone = src && jQuery.isPlainObject(src) ? src : {};
  173. }
  174. // Never move original objects, clone them
  175. target[ name ] = jQuery.extend( deep, clone, copy );
  176. // Don't bring in undefined values
  177. } else if ( copy !== undefined ) {
  178. target[ name ] = copy;
  179. }
  180. }
  181. }
  182. }
  183. // Return the modified object
  184. return target;
  185. };
  186. jQuery.extend({
  187. // Unique for each copy of jQuery on the page
  188. expando: "jQuery" + ( version + Math.random() ).replace( /\D/g, "" ),
  189. // Assume jQuery is ready without the ready module
  190. isReady: true,
  191. error: function( msg ) {
  192. throw new Error( msg );
  193. },
  194. noop: function() {},
  195. // See test/unit/core.js for details concerning isFunction.
  196. // Since version 1.3, DOM methods and functions like alert
  197. // aren't supported. They return false on IE (#2968).
  198. isFunction: function( obj ) {
  199. return jQuery.type(obj) === "function";
  200. },
  201. isArray: Array.isArray || function( obj ) {
  202. return jQuery.type(obj) === "array";
  203. },
  204. isWindow: function( obj ) {
  205. /* jshint eqeqeq: false */
  206. return obj != null && obj == obj.window;
  207. },
  208. isNumeric: function( obj ) {
  209. // parseFloat NaNs numeric-cast false positives (null|true|false|"")
  210. // ...but misinterprets leading-number strings, particularly hex literals ("0x...")
  211. // subtraction forces infinities to NaN
  212. return !jQuery.isArray( obj ) && obj - parseFloat( obj ) >= 0;
  213. },
  214. isEmptyObject: function( obj ) {
  215. var name;
  216. for ( name in obj ) {
  217. return false;
  218. }
  219. return true;
  220. },
  221. isPlainObject: function( obj ) {
  222. var key;
  223. // Must be an Object.
  224. // Because of IE, we also have to check the presence of the constructor property.
  225. // Make sure that DOM nodes and window objects don't pass through, as well
  226. if ( !obj || jQuery.type(obj) !== "object" || obj.nodeType || jQuery.isWindow( obj ) ) {
  227. return false;
  228. }
  229. try {
  230. // Not own constructor property must be Object
  231. if ( obj.constructor &&
  232. !hasOwn.call(obj, "constructor") &&
  233. !hasOwn.call(obj.constructor.prototype, "isPrototypeOf") ) {
  234. return false;
  235. }
  236. } catch ( e ) {
  237. // IE8,9 Will throw exceptions on certain host objects #9897
  238. return false;
  239. }
  240. // Support: IE<9
  241. // Handle iteration over inherited properties before own properties.
  242. if ( support.ownLast ) {
  243. for ( key in obj ) {
  244. return hasOwn.call( obj, key );
  245. }
  246. }
  247. // Own properties are enumerated firstly, so to speed up,
  248. // if last one is own, then all properties are own.
  249. for ( key in obj ) {}
  250. return key === undefined || hasOwn.call( obj, key );
  251. },
  252. type: function( obj ) {
  253. if ( obj == null ) {
  254. return obj + "";
  255. }
  256. return typeof obj === "object" || typeof obj === "function" ?
  257. class2type[ toString.call(obj) ] || "object" :
  258. typeof obj;
  259. },
  260. // Evaluates a script in a global context
  261. // Workarounds based on findings by Jim Driscoll
  262. // http://weblogs.java.net/blog/driscoll/archive/2009/09/08/eval-javascript-global-context
  263. globalEval: function( data ) {
  264. if ( data && jQuery.trim( data ) ) {
  265. // We use execScript on Internet Explorer
  266. // We use an anonymous function so that context is window
  267. // rather than jQuery in Firefox
  268. ( window.execScript || function( data ) {
  269. window[ "eval" ].call( window, data );
  270. } )( data );
  271. }
  272. },
  273. // Convert dashed to camelCase; used by the css and data modules
  274. // Microsoft forgot to hump their vendor prefix (#9572)
  275. camelCase: function( string ) {
  276. return string.replace( rmsPrefix, "ms-" ).replace( rdashAlpha, fcamelCase );
  277. },
  278. nodeName: function( elem, name ) {
  279. return elem.nodeName && elem.nodeName.toLowerCase() === name.toLowerCase();
  280. },
  281. // args is for internal usage only
  282. each: function( obj, callback, args ) {
  283. var value,
  284. i = 0,
  285. length = obj.length,
  286. isArray = isArraylike( obj );
  287. if ( args ) {
  288. if ( isArray ) {
  289. for ( ; i < length; i++ ) {
  290. value = callback.apply( obj[ i ], args );
  291. if ( value === false ) {
  292. break;
  293. }
  294. }
  295. } else {
  296. for ( i in obj ) {
  297. value = callback.apply( obj[ i ], args );
  298. if ( value === false ) {
  299. break;
  300. }
  301. }
  302. }
  303. // A special, fast, case for the most common use of each
  304. } else {
  305. if ( isArray ) {
  306. for ( ; i < length; i++ ) {
  307. value = callback.call( obj[ i ], i, obj[ i ] );
  308. if ( value === false ) {
  309. break;
  310. }
  311. }
  312. } else {
  313. for ( i in obj ) {
  314. value = callback.call( obj[ i ], i, obj[ i ] );
  315. if ( value === false ) {
  316. break;
  317. }
  318. }
  319. }
  320. }
  321. return obj;
  322. },
  323. // Support: Android<4.1, IE<9
  324. trim: function( text ) {
  325. return text == null ?
  326. "" :
  327. ( text + "" ).replace( rtrim, "" );
  328. },
  329. // results is for internal usage only
  330. makeArray: function( arr, results ) {
  331. var ret = results || [];
  332. if ( arr != null ) {
  333. if ( isArraylike( Object(arr) ) ) {
  334. jQuery.merge( ret,
  335. typeof arr === "string" ?
  336. [ arr ] : arr
  337. );
  338. } else {
  339. push.call( ret, arr );
  340. }
  341. }
  342. return ret;
  343. },
  344. inArray: function( elem, arr, i ) {
  345. var len;
  346. if ( arr ) {
  347. if ( indexOf ) {
  348. return indexOf.call( arr, elem, i );
  349. }
  350. len = arr.length;
  351. i = i ? i < 0 ? Math.max( 0, len + i ) : i : 0;
  352. for ( ; i < len; i++ ) {
  353. // Skip accessing in sparse arrays
  354. if ( i in arr && arr[ i ] === elem ) {
  355. return i;
  356. }
  357. }
  358. }
  359. return -1;
  360. },
  361. merge: function( first, second ) {
  362. var len = +second.length,
  363. j = 0,
  364. i = first.length;
  365. while ( j < len ) {
  366. first[ i++ ] = second[ j++ ];
  367. }
  368. // Support: IE<9
  369. // Workaround casting of .length to NaN on otherwise arraylike objects (e.g., NodeLists)
  370. if ( len !== len ) {
  371. while ( second[j] !== undefined ) {
  372. first[ i++ ] = second[ j++ ];
  373. }
  374. }
  375. first.length = i;
  376. return first;
  377. },
  378. grep: function( elems, callback, invert ) {
  379. var callbackInverse,
  380. matches = [],
  381. i = 0,
  382. length = elems.length,
  383. callbackExpect = !invert;
  384. // Go through the array, only saving the items
  385. // that pass the validator function
  386. for ( ; i < length; i++ ) {
  387. callbackInverse = !callback( elems[ i ], i );
  388. if ( callbackInverse !== callbackExpect ) {
  389. matches.push( elems[ i ] );
  390. }
  391. }
  392. return matches;
  393. },
  394. // arg is for internal usage only
  395. map: function( elems, callback, arg ) {
  396. var value,
  397. i = 0,
  398. length = elems.length,
  399. isArray = isArraylike( elems ),
  400. ret = [];
  401. // Go through the array, translating each of the items to their new values
  402. if ( isArray ) {
  403. for ( ; i < length; i++ ) {
  404. value = callback( elems[ i ], i, arg );
  405. if ( value != null ) {
  406. ret.push( value );
  407. }
  408. }
  409. // Go through every key on the object,
  410. } else {
  411. for ( i in elems ) {
  412. value = callback( elems[ i ], i, arg );
  413. if ( value != null ) {
  414. ret.push( value );
  415. }
  416. }
  417. }
  418. // Flatten any nested arrays
  419. return concat.apply( [], ret );
  420. },
  421. // A global GUID counter for objects
  422. guid: 1,
  423. // Bind a function to a context, optionally partially applying any
  424. // arguments.
  425. proxy: function( fn, context ) {
  426. var args, proxy, tmp;
  427. if ( typeof context === "string" ) {
  428. tmp = fn[ context ];
  429. context = fn;
  430. fn = tmp;
  431. }
  432. // Quick check to determine if target is callable, in the spec
  433. // this throws a TypeError, but we will just return undefined.
  434. if ( !jQuery.isFunction( fn ) ) {
  435. return undefined;
  436. }
  437. // Simulated bind
  438. args = slice.call( arguments, 2 );
  439. proxy = function() {
  440. return fn.apply( context || this, args.concat( slice.call( arguments ) ) );
  441. };
  442. // Set the guid of unique handler to the same of original handler, so it can be removed
  443. proxy.guid = fn.guid = fn.guid || jQuery.guid++;
  444. return proxy;
  445. },
  446. now: function() {
  447. return +( new Date() );
  448. },
  449. // jQuery.support is not used in Core but other projects attach their
  450. // properties to it so it needs to exist.
  451. support: support
  452. });
  453. // Populate the class2type map
  454. jQuery.each("Boolean Number String Function Array Date RegExp Object Error".split(" "), function(i, name) {
  455. class2type[ "[object " + name + "]" ] = name.toLowerCase();
  456. });
  457. function isArraylike( obj ) {
  458. var length = obj.length,
  459. type = jQuery.type( obj );
  460. if ( type === "function" || jQuery.isWindow( obj ) ) {
  461. return false;
  462. }
  463. if ( obj.nodeType === 1 && length ) {
  464. return true;
  465. }
  466. return type === "array" || length === 0 ||
  467. typeof length === "number" && length > 0 && ( length - 1 ) in obj;
  468. }
  469. var Sizzle =
  470. /*!
  471. * Sizzle CSS Selector Engine v1.10.19
  472. * http://sizzlejs.com/
  473. *
  474. * Copyright 2013 jQuery Foundation, Inc. and other contributors
  475. * Released under the MIT license
  476. * http://jquery.org/license
  477. *
  478. * Date: 2014-04-18
  479. */
  480. (function( window ) {
  481. var i,
  482. support,
  483. Expr,
  484. getText,
  485. isXML,
  486. tokenize,
  487. compile,
  488. select,
  489. outermostContext,
  490. sortInput,
  491. hasDuplicate,
  492. // Local document vars
  493. setDocument,
  494. document,
  495. docElem,
  496. documentIsHTML,
  497. rbuggyQSA,
  498. rbuggyMatches,
  499. matches,
  500. contains,
  501. // Instance-specific data
  502. expando = "sizzle" + -(new Date()),
  503. preferredDoc = window.document,
  504. dirruns = 0,
  505. done = 0,
  506. classCache = createCache(),
  507. tokenCache = createCache(),
  508. compilerCache = createCache(),
  509. sortOrder = function( a, b ) {
  510. if ( a === b ) {
  511. hasDuplicate = true;
  512. }
  513. return 0;
  514. },
  515. // General-purpose constants
  516. strundefined = typeof undefined,
  517. MAX_NEGATIVE = 1 << 31,
  518. // Instance methods
  519. hasOwn = ({}).hasOwnProperty,
  520. arr = [],
  521. pop = arr.pop,
  522. push_native = arr.push,
  523. push = arr.push,
  524. slice = arr.slice,
  525. // Use a stripped-down indexOf if we can't use a native one
  526. indexOf = arr.indexOf || function( elem ) {
  527. var i = 0,
  528. len = this.length;
  529. for ( ; i < len; i++ ) {
  530. if ( this[i] === elem ) {
  531. return i;
  532. }
  533. }
  534. return -1;
  535. },
  536. booleans = "checked|selected|async|autofocus|autoplay|controls|defer|disabled|hidden|ismap|loop|multiple|open|readonly|required|scoped",
  537. // Regular expressions
  538. // Whitespace characters http://www.w3.org/TR/css3-selectors/#whitespace
  539. whitespace = "[\\x20\\t\\r\\n\\f]",
  540. // http://www.w3.org/TR/css3-syntax/#characters
  541. characterEncoding = "(?:\\\\.|[\\w-]|[^\\x00-\\xa0])+",
  542. // Loosely modeled on CSS identifier characters
  543. // An unquoted value should be a CSS identifier http://www.w3.org/TR/css3-selectors/#attribute-selectors
  544. // Proper syntax: http://www.w3.org/TR/CSS21/syndata.html#value-def-identifier
  545. identifier = characterEncoding.replace( "w", "w#" ),
  546. // Attribute selectors: http://www.w3.org/TR/selectors/#attribute-selectors
  547. attributes = "\\[" + whitespace + "*(" + characterEncoding + ")(?:" + whitespace +
  548. // Operator (capture 2)
  549. "*([*^$|!~]?=)" + whitespace +
  550. // "Attribute values must be CSS identifiers [capture 5] or strings [capture 3 or capture 4]"
  551. "*(?:'((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\"|(" + identifier + "))|)" + whitespace +
  552. "*\\]",
  553. pseudos = ":(" + characterEncoding + ")(?:\\((" +
  554. // To reduce the number of selectors needing tokenize in the preFilter, prefer arguments:
  555. // 1. quoted (capture 3; capture 4 or capture 5)
  556. "('((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\")|" +
  557. // 2. simple (capture 6)
  558. "((?:\\\\.|[^\\\\()[\\]]|" + attributes + ")*)|" +
  559. // 3. anything else (capture 2)
  560. ".*" +
  561. ")\\)|)",
  562. // Leading and non-escaped trailing whitespace, capturing some non-whitespace characters preceding the latter
  563. rtrim = new RegExp( "^" + whitespace + "+|((?:^|[^\\\\])(?:\\\\.)*)" + whitespace + "+$", "g" ),
  564. rcomma = new RegExp( "^" + whitespace + "*," + whitespace + "*" ),
  565. rcombinators = new RegExp( "^" + whitespace + "*([>+~]|" + whitespace + ")" + whitespace + "*" ),
  566. rattributeQuotes = new RegExp( "=" + whitespace + "*([^\\]'\"]*?)" + whitespace + "*\\]", "g" ),
  567. rpseudo = new RegExp( pseudos ),
  568. ridentifier = new RegExp( "^" + identifier + "$" ),
  569. matchExpr = {
  570. "ID": new RegExp( "^#(" + characterEncoding + ")" ),
  571. "CLASS": new RegExp( "^\\.(" + characterEncoding + ")" ),
  572. "TAG": new RegExp( "^(" + characterEncoding.replace( "w", "w*" ) + ")" ),
  573. "ATTR": new RegExp( "^" + attributes ),
  574. "PSEUDO": new RegExp( "^" + pseudos ),
  575. "CHILD": new RegExp( "^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\(" + whitespace +
  576. "*(even|odd|(([+-]|)(\\d*)n|)" + whitespace + "*(?:([+-]|)" + whitespace +
  577. "*(\\d+)|))" + whitespace + "*\\)|)", "i" ),
  578. "bool": new RegExp( "^(?:" + booleans + ")$", "i" ),
  579. // For use in libraries implementing .is()
  580. // We use this for POS matching in `select`
  581. "needsContext": new RegExp( "^" + whitespace + "*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\(" +
  582. whitespace + "*((?:-\\d)?\\d*)" + whitespace + "*\\)|)(?=[^-]|$)", "i" )
  583. },
  584. rinputs = /^(?:input|select|textarea|button)$/i,
  585. rheader = /^h\d$/i,
  586. rnative = /^[^{]+\{\s*\[native \w/,
  587. // Easily-parseable/retrievable ID or TAG or CLASS selectors
  588. rquickExpr = /^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/,
  589. rsibling = /[+~]/,
  590. rescape = /'|\\/g,
  591. // CSS escapes http://www.w3.org/TR/CSS21/syndata.html#escaped-characters
  592. runescape = new RegExp( "\\\\([\\da-f]{1,6}" + whitespace + "?|(" + whitespace + ")|.)", "ig" ),
  593. funescape = function( _, escaped, escapedWhitespace ) {
  594. var high = "0x" + escaped - 0x10000;
  595. // NaN means non-codepoint
  596. // Support: Firefox<24
  597. // Workaround erroneous numeric interpretation of +"0x"
  598. return high !== high || escapedWhitespace ?
  599. escaped :
  600. high < 0 ?
  601. // BMP codepoint
  602. String.fromCharCode( high + 0x10000 ) :
  603. // Supplemental Plane codepoint (surrogate pair)
  604. String.fromCharCode( high >> 10 | 0xD800, high & 0x3FF | 0xDC00 );
  605. };
  606. // Optimize for push.apply( _, NodeList )
  607. try {
  608. push.apply(
  609. (arr = slice.call( preferredDoc.childNodes )),
  610. preferredDoc.childNodes
  611. );
  612. // Support: Android<4.0
  613. // Detect silently failing push.apply
  614. arr[ preferredDoc.childNodes.length ].nodeType;
  615. } catch ( e ) {
  616. push = { apply: arr.length ?
  617. // Leverage slice if possible
  618. function( target, els ) {
  619. push_native.apply( target, slice.call(els) );
  620. } :
  621. // Support: IE<9
  622. // Otherwise append directly
  623. function( target, els ) {
  624. var j = target.length,
  625. i = 0;
  626. // Can't trust NodeList.length
  627. while ( (target[j++] = els[i++]) ) {}
  628. target.length = j - 1;
  629. }
  630. };
  631. }
  632. function Sizzle( selector, context, results, seed ) {
  633. var match, elem, m, nodeType,
  634. // QSA vars
  635. i, groups, old, nid, newContext, newSelector;
  636. if ( ( context ? context.ownerDocument || context : preferredDoc ) !== document ) {
  637. setDocument( context );
  638. }
  639. context = context || document;
  640. results = results || [];
  641. if ( !selector || typeof selector !== "string" ) {
  642. return results;
  643. }
  644. if ( (nodeType = context.nodeType) !== 1 && nodeType !== 9 ) {
  645. return [];
  646. }
  647. if ( documentIsHTML && !seed ) {
  648. // Shortcuts
  649. if ( (match = rquickExpr.exec( selector )) ) {
  650. // Speed-up: Sizzle("#ID")
  651. if ( (m = match[1]) ) {
  652. if ( nodeType === 9 ) {
  653. elem = context.getElementById( m );
  654. // Check parentNode to catch when Blackberry 4.6 returns
  655. // nodes that are no longer in the document (jQuery #6963)
  656. if ( elem && elem.parentNode ) {
  657. // Handle the case where IE, Opera, and Webkit return items
  658. // by name instead of ID
  659. if ( elem.id === m ) {
  660. results.push( elem );
  661. return results;
  662. }
  663. } else {
  664. return results;
  665. }
  666. } else {
  667. // Context is not a document
  668. if ( context.ownerDocument && (elem = context.ownerDocument.getElementById( m )) &&
  669. contains( context, elem ) && elem.id === m ) {
  670. results.push( elem );
  671. return results;
  672. }
  673. }
  674. // Speed-up: Sizzle("TAG")
  675. } else if ( match[2] ) {
  676. push.apply( results, context.getElementsByTagName( selector ) );
  677. return results;
  678. // Speed-up: Sizzle(".CLASS")
  679. } else if ( (m = match[3]) && support.getElementsByClassName && context.getElementsByClassName ) {
  680. push.apply( results, context.getElementsByClassName( m ) );
  681. return results;
  682. }
  683. }
  684. // QSA path
  685. if ( support.qsa && (!rbuggyQSA || !rbuggyQSA.test( selector )) ) {
  686. nid = old = expando;
  687. newContext = context;
  688. newSelector = nodeType === 9 && selector;
  689. // qSA works strangely on Element-rooted queries
  690. // We can work around this by specifying an extra ID on the root
  691. // and working up from there (Thanks to Andrew Dupont for the technique)
  692. // IE 8 doesn't work on object elements
  693. if ( nodeType === 1 && context.nodeName.toLowerCase() !== "object" ) {
  694. groups = tokenize( selector );
  695. if ( (old = context.getAttribute("id")) ) {
  696. nid = old.replace( rescape, "\\$&" );
  697. } else {
  698. context.setAttribute( "id", nid );
  699. }
  700. nid = "[id='" + nid + "'] ";
  701. i = groups.length;
  702. while ( i-- ) {
  703. groups[i] = nid + toSelector( groups[i] );
  704. }
  705. newContext = rsibling.test( selector ) && testContext( context.parentNode ) || context;
  706. newSelector = groups.join(",");
  707. }
  708. if ( newSelector ) {
  709. try {
  710. push.apply( results,
  711. newContext.querySelectorAll( newSelector )
  712. );
  713. return results;
  714. } catch(qsaError) {
  715. } finally {
  716. if ( !old ) {
  717. context.removeAttribute("id");
  718. }
  719. }
  720. }
  721. }
  722. }
  723. // All others
  724. return select( selector.replace( rtrim, "$1" ), context, results, seed );
  725. }
  726. /**
  727. * Create key-value caches of limited size
  728. * @returns {Function(string, Object)} Returns the Object data after storing it on itself with
  729. * property name the (space-suffixed) string and (if the cache is larger than Expr.cacheLength)
  730. * deleting the oldest entry
  731. */
  732. function createCache() {
  733. var keys = [];
  734. function cache( key, value ) {
  735. // Use (key + " ") to avoid collision with native prototype properties (see Issue #157)
  736. if ( keys.push( key + " " ) > Expr.cacheLength ) {
  737. // Only keep the most recent entries
  738. delete cache[ keys.shift() ];
  739. }
  740. return (cache[ key + " " ] = value);
  741. }
  742. return cache;
  743. }
  744. /**
  745. * Mark a function for special use by Sizzle
  746. * @param {Function} fn The function to mark
  747. */
  748. function markFunction( fn ) {
  749. fn[ expando ] = true;
  750. return fn;
  751. }
  752. /**
  753. * Support testing using an element
  754. * @param {Function} fn Passed the created div and expects a boolean result
  755. */
  756. function assert( fn ) {
  757. var div = document.createElement("div");
  758. try {
  759. return !!fn( div );
  760. } catch (e) {
  761. return false;
  762. } finally {
  763. // Remove from its parent by default
  764. if ( div.parentNode ) {
  765. div.parentNode.removeChild( div );
  766. }
  767. // release memory in IE
  768. div = null;
  769. }
  770. }
  771. /**
  772. * Adds the same handler for all of the specified attrs
  773. * @param {String} attrs Pipe-separated list of attributes
  774. * @param {Function} handler The method that will be applied
  775. */
  776. function addHandle( attrs, handler ) {
  777. var arr = attrs.split("|"),
  778. i = attrs.length;
  779. while ( i-- ) {
  780. Expr.attrHandle[ arr[i] ] = handler;
  781. }
  782. }
  783. /**
  784. * Checks document order of two siblings
  785. * @param {Element} a
  786. * @param {Element} b
  787. * @returns {Number} Returns less than 0 if a precedes b, greater than 0 if a follows b
  788. */
  789. function siblingCheck( a, b ) {
  790. var cur = b && a,
  791. diff = cur && a.nodeType === 1 && b.nodeType === 1 &&
  792. ( ~b.sourceIndex || MAX_NEGATIVE ) -
  793. ( ~a.sourceIndex || MAX_NEGATIVE );
  794. // Use IE sourceIndex if available on both nodes
  795. if ( diff ) {
  796. return diff;
  797. }
  798. // Check if b follows a
  799. if ( cur ) {
  800. while ( (cur = cur.nextSibling) ) {
  801. if ( cur === b ) {
  802. return -1;
  803. }
  804. }
  805. }
  806. return a ? 1 : -1;
  807. }
  808. /**
  809. * Returns a function to use in pseudos for input types
  810. * @param {String} type
  811. */
  812. function createInputPseudo( type ) {
  813. return function( elem ) {
  814. var name = elem.nodeName.toLowerCase();
  815. return name === "input" && elem.type === type;
  816. };
  817. }
  818. /**
  819. * Returns a function to use in pseudos for buttons
  820. * @param {String} type
  821. */
  822. function createButtonPseudo( type ) {
  823. return function( elem ) {
  824. var name = elem.nodeName.toLowerCase();
  825. return (name === "input" || name === "button") && elem.type === type;
  826. };
  827. }
  828. /**
  829. * Returns a function to use in pseudos for positionals
  830. * @param {Function} fn
  831. */
  832. function createPositionalPseudo( fn ) {
  833. return markFunction(function( argument ) {
  834. argument = +argument;
  835. return markFunction(function( seed, matches ) {
  836. var j,
  837. matchIndexes = fn( [], seed.length, argument ),
  838. i = matchIndexes.length;
  839. // Match elements found at the specified indexes
  840. while ( i-- ) {
  841. if ( seed[ (j = matchIndexes[i]) ] ) {
  842. seed[j] = !(matches[j] = seed[j]);
  843. }
  844. }
  845. });
  846. });
  847. }
  848. /**
  849. * Checks a node for validity as a Sizzle context
  850. * @param {Element|Object=} context
  851. * @returns {Element|Object|Boolean} The input node if acceptable, otherwise a falsy value
  852. */
  853. function testContext( context ) {
  854. return context && typeof context.getElementsByTagName !== strundefined && context;
  855. }
  856. // Expose support vars for convenience
  857. support = Sizzle.support = {};
  858. /**
  859. * Detects XML nodes
  860. * @param {Element|Object} elem An element or a document
  861. * @returns {Boolean} True iff elem is a non-HTML XML node
  862. */
  863. isXML = Sizzle.isXML = function( elem ) {
  864. // documentElement is verified for cases where it doesn't yet exist
  865. // (such as loading iframes in IE - #4833)
  866. var documentElement = elem && (elem.ownerDocument || elem).documentElement;
  867. return documentElement ? documentElement.nodeName !== "HTML" : false;
  868. };
  869. /**
  870. * Sets document-related variables once based on the current document
  871. * @param {Element|Object} [doc] An element or document object to use to set the document
  872. * @returns {Object} Returns the current document
  873. */
  874. setDocument = Sizzle.setDocument = function( node ) {
  875. var hasCompare,
  876. doc = node ? node.ownerDocument || node : preferredDoc,
  877. parent = doc.defaultView;
  878. // If no document and documentElement is available, return
  879. if ( doc === document || doc.nodeType !== 9 || !doc.documentElement ) {
  880. return document;
  881. }
  882. // Set our document
  883. document = doc;
  884. docElem = doc.documentElement;
  885. // Support tests
  886. documentIsHTML = !isXML( doc );
  887. // Support: IE>8
  888. // If iframe document is assigned to "document" variable and if iframe has been reloaded,
  889. // IE will throw "permission denied" error when accessing "document" variable, see jQuery #13936
  890. // IE6-8 do not support the defaultView property so parent will be undefined
  891. if ( parent && parent !== parent.top ) {
  892. // IE11 does not have attachEvent, so all must suffer
  893. if ( parent.addEventListener ) {
  894. parent.addEventListener( "unload", function() {
  895. setDocument();
  896. }, false );
  897. } else if ( parent.attachEvent ) {
  898. parent.attachEvent( "onunload", function() {
  899. setDocument();
  900. });
  901. }
  902. }
  903. /* Attributes
  904. ---------------------------------------------------------------------- */
  905. // Support: IE<8
  906. // Verify that getAttribute really returns attributes and not properties (excepting IE8 booleans)
  907. support.attributes = assert(function( div ) {
  908. div.className = "i";
  909. return !div.getAttribute("className");
  910. });
  911. /* getElement(s)By*
  912. ---------------------------------------------------------------------- */
  913. // Check if getElementsByTagName("*") returns only elements
  914. support.getElementsByTagName = assert(function( div ) {
  915. div.appendChild( doc.createComment("") );
  916. return !div.getElementsByTagName("*").length;
  917. });
  918. // Check if getElementsByClassName can be trusted
  919. support.getElementsByClassName = rnative.test( doc.getElementsByClassName ) && assert(function( div ) {
  920. div.innerHTML = "<div class='a'></div><div class='a i'></div>";
  921. // Support: Safari<4
  922. // Catch class over-caching
  923. div.firstChild.className = "i";
  924. // Support: Opera<10
  925. // Catch gEBCN failure to find non-leading classes
  926. return div.getElementsByClassName("i").length === 2;
  927. });
  928. // Support: IE<10
  929. // Check if getElementById returns elements by name
  930. // The broken getElementById methods don't pick up programatically-set names,
  931. // so use a roundabout getElementsByName test
  932. support.getById = assert(function( div ) {
  933. docElem.appendChild( div ).id = expando;
  934. return !doc.getElementsByName || !doc.getElementsByName( expando ).length;
  935. });
  936. // ID find and filter
  937. if ( support.getById ) {
  938. Expr.find["ID"] = function( id, context ) {
  939. if ( typeof context.getElementById !== strundefined && documentIsHTML ) {
  940. var m = context.getElementById( id );
  941. // Check parentNode to catch when Blackberry 4.6 returns
  942. // nodes that are no longer in the document #6963
  943. return m && m.parentNode ? [ m ] : [];
  944. }
  945. };
  946. Expr.filter["ID"] = function( id ) {
  947. var attrId = id.replace( runescape, funescape );
  948. return function( elem ) {
  949. return elem.getAttribute("id") === attrId;
  950. };
  951. };
  952. } else {
  953. // Support: IE6/7
  954. // getElementById is not reliable as a find shortcut
  955. delete Expr.find["ID"];
  956. Expr.filter["ID"] = function( id ) {
  957. var attrId = id.replace( runescape, funescape );
  958. return function( elem ) {
  959. var node = typeof elem.getAttributeNode !== strundefined && elem.getAttributeNode("id");
  960. return node && node.value === attrId;
  961. };
  962. };
  963. }
  964. // Tag
  965. Expr.find["TAG"] = support.getElementsByTagName ?
  966. function( tag, context ) {
  967. if ( typeof context.getElementsByTagName !== strundefined ) {
  968. return context.getElementsByTagName( tag );
  969. }
  970. } :
  971. function( tag, context ) {
  972. var elem,
  973. tmp = [],
  974. i = 0,
  975. results = context.getElementsByTagName( tag );
  976. // Filter out possible comments
  977. if ( tag === "*" ) {
  978. while ( (elem = results[i++]) ) {
  979. if ( elem.nodeType === 1 ) {
  980. tmp.push( elem );
  981. }
  982. }
  983. return tmp;
  984. }
  985. return results;
  986. };
  987. // Class
  988. Expr.find["CLASS"] = support.getElementsByClassName && function( className, context ) {
  989. if ( typeof context.getElementsByClassName !== strundefined && documentIsHTML ) {
  990. return context.getElementsByClassName( className );
  991. }
  992. };
  993. /* QSA/matchesSelector
  994. ---------------------------------------------------------------------- */
  995. // QSA and matchesSelector support
  996. // matchesSelector(:active) reports false when true (IE9/Opera 11.5)
  997. rbuggyMatches = [];
  998. // qSa(:focus) reports false when true (Chrome 21)
  999. // We allow this because of a bug in IE8/9 that throws an error
  1000. // whenever `document.activeElement` is accessed on an iframe
  1001. // So, we allow :focus to pass through QSA all the time to avoid the IE error
  1002. // See http://bugs.jquery.com/ticket/13378
  1003. rbuggyQSA = [];
  1004. if ( (support.qsa = rnative.test( doc.querySelectorAll )) ) {
  1005. // Build QSA regex
  1006. // Regex strategy adopted from Diego Perini
  1007. assert(function( div ) {
  1008. // Select is set to empty string on purpose
  1009. // This is to test IE's treatment of not explicitly
  1010. // setting a boolean content attribute,
  1011. // since its presence should be enough
  1012. // http://bugs.jquery.com/ticket/12359
  1013. div.innerHTML = "<select msallowclip=''><option selected=''></option></select>";
  1014. // Support: IE8, Opera 11-12.16
  1015. // Nothing should be selected when empty strings follow ^= or $= or *=
  1016. // The test attribute must be unknown in Opera but "safe" for WinRT
  1017. // http://msdn.microsoft.com/en-us/library/ie/hh465388.aspx#attribute_section
  1018. if ( div.querySelectorAll("[msallowclip^='']").length ) {
  1019. rbuggyQSA.push( "[*^$]=" + whitespace + "*(?:''|\"\")" );
  1020. }
  1021. // Support: IE8
  1022. // Boolean attributes and "value" are not treated correctly
  1023. if ( !div.querySelectorAll("[selected]").length ) {
  1024. rbuggyQSA.push( "\\[" + whitespace + "*(?:value|" + booleans + ")" );
  1025. }
  1026. // Webkit/Opera - :checked should return selected option elements
  1027. // http://www.w3.org/TR/2011/REC-css3-selectors-20110929/#checked
  1028. // IE8 throws error here and will not see later tests
  1029. if ( !div.querySelectorAll(":checked").length ) {
  1030. rbuggyQSA.push(":checked");
  1031. }
  1032. });
  1033. assert(function( div ) {
  1034. // Support: Windows 8 Native Apps
  1035. // The type and name attributes are restricted during .innerHTML assignment
  1036. var input = doc.createElement("input");
  1037. input.setAttribute( "type", "hidden" );
  1038. div.appendChild( input ).setAttribute( "name", "D" );
  1039. // Support: IE8
  1040. // Enforce case-sensitivity of name attribute
  1041. if ( div.querySelectorAll("[name=d]").length ) {
  1042. rbuggyQSA.push( "name" + whitespace + "*[*^$|!~]?=" );
  1043. }
  1044. // FF 3.5 - :enabled/:disabled and hidden elements (hidden elements are still enabled)
  1045. // IE8 throws error here and will not see later tests
  1046. if ( !div.querySelectorAll(":enabled").length ) {
  1047. rbuggyQSA.push( ":enabled", ":disabled" );
  1048. }
  1049. // Opera 10-11 does not throw on post-comma invalid pseudos
  1050. div.querySelectorAll("*,:x");
  1051. rbuggyQSA.push(",.*:");
  1052. });
  1053. }
  1054. if ( (support.matchesSelector = rnative.test( (matches = docElem.matches ||
  1055. docElem.webkitMatchesSelector ||
  1056. docElem.mozMatchesSelector ||
  1057. docElem.oMatchesSelector ||
  1058. docElem.msMatchesSelector) )) ) {
  1059. assert(function( div ) {
  1060. // Check to see if it's possible to do matchesSelector
  1061. // on a disconnected node (IE 9)
  1062. support.disconnectedMatch = matches.call( div, "div" );
  1063. // This should fail with an exception
  1064. // Gecko does not error, returns false instead
  1065. matches.call( div, "[s!='']:x" );
  1066. rbuggyMatches.push( "!=", pseudos );
  1067. });
  1068. }
  1069. rbuggyQSA = rbuggyQSA.length && new RegExp( rbuggyQSA.join("|") );
  1070. rbuggyMatches = rbuggyMatches.length && new RegExp( rbuggyMatches.join("|") );
  1071. /* Contains
  1072. ---------------------------------------------------------------------- */
  1073. hasCompare = rnative.test( docElem.compareDocumentPosition );
  1074. // Element contains another
  1075. // Purposefully does not implement inclusive descendent
  1076. // As in, an element does not contain itself
  1077. contains = hasCompare || rnative.test( docElem.contains ) ?
  1078. function( a, b ) {
  1079. var adown = a.nodeType === 9 ? a.documentElement : a,
  1080. bup = b && b.parentNode;
  1081. return a === bup || !!( bup && bup.nodeType === 1 && (
  1082. adown.contains ?
  1083. adown.contains( bup ) :
  1084. a.compareDocumentPosition && a.compareDocumentPosition( bup ) & 16
  1085. ));
  1086. } :
  1087. function( a, b ) {
  1088. if ( b ) {
  1089. while ( (b = b.parentNode) ) {
  1090. if ( b === a ) {
  1091. return true;
  1092. }
  1093. }
  1094. }
  1095. return false;
  1096. };
  1097. /* Sorting
  1098. ---------------------------------------------------------------------- */
  1099. // Document order sorting
  1100. sortOrder = hasCompare ?
  1101. function( a, b ) {
  1102. // Flag for duplicate removal
  1103. if ( a === b ) {
  1104. hasDuplicate = true;
  1105. return 0;
  1106. }
  1107. // Sort on method existence if only one input has compareDocumentPosition
  1108. var compare = !a.compareDocumentPosition - !b.compareDocumentPosition;
  1109. if ( compare ) {
  1110. return compare;
  1111. }
  1112. // Calculate position if both inputs belong to the same document
  1113. compare = ( a.ownerDocument || a ) === ( b.ownerDocument || b ) ?
  1114. a.compareDocumentPosition( b ) :
  1115. // Otherwise we know they are disconnected
  1116. 1;
  1117. // Disconnected nodes
  1118. if ( compare & 1 ||
  1119. (!support.sortDetached && b.compareDocumentPosition( a ) === compare) ) {
  1120. // Choose the first element that is related to our preferred document
  1121. if ( a === doc || a.ownerDocument === preferredDoc && contains(preferredDoc, a) ) {
  1122. return -1;
  1123. }
  1124. if ( b === doc || b.ownerDocument === preferredDoc && contains(preferredDoc, b) ) {
  1125. return 1;
  1126. }
  1127. // Maintain original order
  1128. return sortInput ?
  1129. ( indexOf.call( sortInput, a ) - indexOf.call( sortInput, b ) ) :
  1130. 0;
  1131. }
  1132. return compare & 4 ? -1 : 1;
  1133. } :
  1134. function( a, b ) {
  1135. // Exit early if the nodes are identical
  1136. if ( a === b ) {
  1137. hasDuplicate = true;
  1138. return 0;
  1139. }
  1140. var cur,
  1141. i = 0,
  1142. aup = a.parentNode,
  1143. bup = b.parentNode,
  1144. ap = [ a ],
  1145. bp = [ b ];
  1146. // Parentless nodes are either documents or disconnected
  1147. if ( !aup || !bup ) {
  1148. return a === doc ? -1 :
  1149. b === doc ? 1 :
  1150. aup ? -1 :
  1151. bup ? 1 :
  1152. sortInput ?
  1153. ( indexOf.call( sortInput, a ) - indexOf.call( sortInput, b ) ) :
  1154. 0;
  1155. // If the nodes are siblings, we can do a quick check
  1156. } else if ( aup === bup ) {
  1157. return siblingCheck( a, b );
  1158. }
  1159. // Otherwise we need full lists of their ancestors for comparison
  1160. cur = a;
  1161. while ( (cur = cur.parentNode) ) {
  1162. ap.unshift( cur );
  1163. }
  1164. cur = b;
  1165. while ( (cur = cur.parentNode) ) {
  1166. bp.unshift( cur );
  1167. }
  1168. // Walk down the tree looking for a discrepancy
  1169. while ( ap[i] === bp[i] ) {
  1170. i++;
  1171. }
  1172. return i ?
  1173. // Do a sibling check if the nodes have a common ancestor
  1174. siblingCheck( ap[i], bp[i] ) :
  1175. // Otherwise nodes in our document sort first
  1176. ap[i] === preferredDoc ? -1 :
  1177. bp[i] === preferredDoc ? 1 :
  1178. 0;
  1179. };
  1180. return doc;
  1181. };
  1182. Sizzle.matches = function( expr, elements ) {
  1183. return Sizzle( expr, null, null, elements );
  1184. };
  1185. Sizzle.matchesSelector = function( elem, expr ) {
  1186. // Set document vars if needed
  1187. if ( ( elem.ownerDocument || elem ) !== document ) {
  1188. setDocument( elem );
  1189. }
  1190. // Make sure that attribute selectors are quoted
  1191. expr = expr.replace( rattributeQuotes, "='$1']" );
  1192. if ( support.matchesSelector && documentIsHTML &&
  1193. ( !rbuggyMatches || !rbuggyMatches.test( expr ) ) &&
  1194. ( !rbuggyQSA || !rbuggyQSA.test( expr ) ) ) {
  1195. try {
  1196. var ret = matches.call( elem, expr );
  1197. // IE 9's matchesSelector returns false on disconnected nodes
  1198. if ( ret || support.disconnectedMatch ||
  1199. // As well, disconnected nodes are said to be in a document
  1200. // fragment in IE 9
  1201. elem.document && elem.document.nodeType !== 11 ) {
  1202. return ret;
  1203. }
  1204. } catch(e) {}
  1205. }
  1206. return Sizzle( expr, document, null, [ elem ] ).length > 0;
  1207. };
  1208. Sizzle.contains = function( context, elem ) {
  1209. // Set document vars if needed
  1210. if ( ( context.ownerDocument || context ) !== document ) {
  1211. setDocument( context );
  1212. }
  1213. return contains( context, elem );
  1214. };
  1215. Sizzle.attr = function( elem, name ) {
  1216. // Set document vars if needed
  1217. if ( ( elem.ownerDocument || elem ) !== document ) {
  1218. setDocument( elem );
  1219. }
  1220. var fn = Expr.attrHandle[ name.toLowerCase() ],
  1221. // Don't get fooled by Object.prototype properties (jQuery #13807)
  1222. val = fn && hasOwn.call( Expr.attrHandle, name.toLowerCase() ) ?
  1223. fn( elem, name, !documentIsHTML ) :
  1224. undefined;
  1225. return val !== undefined ?
  1226. val :
  1227. support.attributes || !documentIsHTML ?
  1228. elem.getAttribute( name ) :
  1229. (val = elem.getAttributeNode(name)) && val.specified ?
  1230. val.value :
  1231. null;
  1232. };
  1233. Sizzle.error = function( msg ) {
  1234. throw new Error( "Syntax error, unrecognized expression: " + msg );
  1235. };
  1236. /**
  1237. * Document sorting and removing duplicates
  1238. * @param {ArrayLike} results
  1239. */
  1240. Sizzle.uniqueSort = function( results ) {
  1241. var elem,
  1242. duplicates = [],
  1243. j = 0,
  1244. i = 0;
  1245. // Unless we *know* we can detect duplicates, assume their presence
  1246. hasDuplicate = !support.detectDuplicates;
  1247. sortInput = !support.sortStable && results.slice( 0 );
  1248. results.sort( sortOrder );
  1249. if ( hasDuplicate ) {
  1250. while ( (elem = results[i++]) ) {
  1251. if ( elem === results[ i ] ) {
  1252. j = duplicates.push( i );
  1253. }
  1254. }
  1255. while ( j-- ) {
  1256. results.splice( duplicates[ j ], 1 );
  1257. }
  1258. }
  1259. // Clear input after sorting to release objects
  1260. // See https://github.com/jquery/sizzle/pull/225
  1261. sortInput = null;
  1262. return results;
  1263. };
  1264. /**
  1265. * Utility function for retrieving the text value of an array of DOM nodes
  1266. * @param {Array|Element} elem
  1267. */
  1268. getText = Sizzle.getText = function( elem ) {
  1269. var node,
  1270. ret = "",
  1271. i = 0,
  1272. nodeType = elem.nodeType;
  1273. if ( !nodeType ) {
  1274. // If no nodeType, this is expected to be an array
  1275. while ( (node = elem[i++]) ) {
  1276. // Do not traverse comment nodes
  1277. ret += getText( node );
  1278. }
  1279. } else if ( nodeType === 1 || nodeType === 9 || nodeType === 11 ) {
  1280. // Use textContent for elements
  1281. // innerText usage removed for consistency of new lines (jQuery #11153)
  1282. if ( typeof elem.textContent === "string" ) {
  1283. return elem.textContent;
  1284. } else {
  1285. // Traverse its children
  1286. for ( elem = elem.firstChild; elem; elem = elem.nextSibling ) {
  1287. ret += getText( elem );
  1288. }
  1289. }
  1290. } else if ( nodeType === 3 || nodeType === 4 ) {
  1291. return elem.nodeValue;
  1292. }
  1293. // Do not include comment or processing instruction nodes
  1294. return ret;
  1295. };
  1296. Expr = Sizzle.selectors = {
  1297. // Can be adjusted by the user
  1298. cacheLength: 50,
  1299. createPseudo: markFunction,
  1300. match: matchExpr,
  1301. attrHandle: {},
  1302. find: {},
  1303. relative: {
  1304. ">": { dir: "parentNode", first: true },
  1305. " ": { dir: "parentNode" },
  1306. "+": { dir: "previousSibling", first: true },
  1307. "~": { dir: "previousSibling" }
  1308. },
  1309. preFilter: {
  1310. "ATTR": function( match ) {
  1311. match[1] = match[1].replace( runescape, funescape );
  1312. // Move the given value to match[3] whether quoted or unquoted
  1313. match[3] = ( match[3] || match[4] || match[5] || "" ).replace( runescape, funescape );
  1314. if ( match[2] === "~=" ) {
  1315. match[3] = " " + match[3] + " ";
  1316. }
  1317. return match.slice( 0, 4 );
  1318. },
  1319. "CHILD": function( match ) {
  1320. /* matches from matchExpr["CHILD"]
  1321. 1 type (only|nth|...)
  1322. 2 what (child|of-type)
  1323. 3 argument (even|odd|\d*|\d*n([+-]\d+)?|...)
  1324. 4 xn-component of xn+y argument ([+-]?\d*n|)
  1325. 5 sign of xn-component
  1326. 6 x of xn-component
  1327. 7 sign of y-component
  1328. 8 y of y-component
  1329. */
  1330. match[1] = match[1].toLowerCase();
  1331. if ( match[1].slice( 0, 3 ) === "nth" ) {
  1332. // nth-* requires argument
  1333. if ( !match[3] ) {
  1334. Sizzle.error( match[0] );
  1335. }
  1336. // numeric x and y parameters for Expr.filter.CHILD
  1337. // remember that false/true cast respectively to 0/1
  1338. match[4] = +( match[4] ? match[5] + (match[6] || 1) : 2 * ( match[3] === "even" || match[3] === "odd" ) );
  1339. match[5] = +( ( match[7] + match[8] ) || match[3] === "odd" );
  1340. // other types prohibit arguments
  1341. } else if ( match[3] ) {
  1342. Sizzle.error( match[0] );
  1343. }
  1344. return match;
  1345. },
  1346. "PSEUDO": function( match ) {
  1347. var excess,
  1348. unquoted = !match[6] && match[2];
  1349. if ( matchExpr["CHILD"].test( match[0] ) ) {
  1350. return null;
  1351. }
  1352. // Accept quoted arguments as-is
  1353. if ( match[3] ) {
  1354. match[2] = match[4] || match[5] || "";
  1355. // Strip excess characters from unquoted arguments
  1356. } else if ( unquoted && rpseudo.test( unquoted ) &&
  1357. // Get excess from tokenize (recursively)
  1358. (excess = tokenize( unquoted, true )) &&
  1359. // advance to the next closing parenthesis
  1360. (excess = unquoted.indexOf( ")", unquoted.length - excess ) - unquoted.length) ) {
  1361. // excess is a negative index
  1362. match[0] = match[0].slice( 0, excess );
  1363. match[2] = unquoted.slice( 0, excess );
  1364. }
  1365. // Return only captures needed by the pseudo filter method (type and argument)
  1366. return match.slice( 0, 3 );
  1367. }
  1368. },
  1369. filter: {
  1370. "TAG": function( nodeNameSelector ) {
  1371. var nodeName = nodeNameSelector.replace( runescape, funescape ).toLowerCase();
  1372. return nodeNameSelector === "*" ?
  1373. function() { return true; } :
  1374. function( elem ) {
  1375. return elem.nodeName && elem.nodeName.toLowerCase() === nodeName;
  1376. };
  1377. },
  1378. "CLASS": function( className ) {
  1379. var pattern = classCache[ className + " " ];
  1380. return pattern ||
  1381. (pattern = new RegExp( "(^|" + whitespace + ")" + className + "(" + whitespace + "|$)" )) &&
  1382. classCache( className, function( elem ) {
  1383. return pattern.test( typeof elem.className === "string" && elem.className || typeof elem.getAttribute !== strundefined && elem.getAttribute("class") || "" );
  1384. });
  1385. },
  1386. "ATTR": function( name, operator, check ) {
  1387. return function( elem ) {
  1388. var result = Sizzle.attr( elem, name );
  1389. if ( result == null ) {
  1390. return operator === "!=";
  1391. }
  1392. if ( !operator ) {
  1393. return true;
  1394. }
  1395. result += "";
  1396. return operator === "=" ? result === check :
  1397. operator === "!=" ? result !== check :
  1398. operator === "^=" ? check && result.indexOf( check ) === 0 :
  1399. operator === "*=" ? check && result.indexOf( check ) > -1 :
  1400. operator === "$=" ? check && result.slice( -check.length ) === check :
  1401. operator === "~=" ? ( " " + result + " " ).indexOf( check ) > -1 :
  1402. operator === "|=" ? result === check || result.slice( 0, check.length + 1 ) === check + "-" :
  1403. false;
  1404. };
  1405. },
  1406. "CHILD": function( type, what, argument, first, last ) {
  1407. var simple = type.slice( 0, 3 ) !== "nth",
  1408. forward = type.slice( -4 ) !== "last",
  1409. ofType = what === "of-type";
  1410. return first === 1 && last === 0 ?
  1411. // Shortcut for :nth-*(n)
  1412. function( elem ) {
  1413. return !!elem.parentNode;
  1414. } :
  1415. function( elem, context, xml ) {
  1416. var cache, outerCache, node, diff, nodeIndex, start,
  1417. dir = simple !== forward ? "nextSibling" : "previousSibling",
  1418. parent = elem.parentNode,
  1419. name = ofType && elem.nodeName.toLowerCase(),
  1420. useCache = !xml && !ofType;
  1421. if ( parent ) {
  1422. // :(first|last|only)-(child|of-type)
  1423. if ( simple ) {
  1424. while ( dir ) {
  1425. node = elem;
  1426. while ( (node = node[ dir ]) ) {
  1427. if ( ofType ? node.nodeName.toLowerCase() === name : node.nodeType === 1 ) {
  1428. return false;
  1429. }
  1430. }
  1431. // Reverse direction for :only-* (if we haven't yet done so)
  1432. start = dir = type === "only" && !start && "nextSibling";
  1433. }
  1434. return true;
  1435. }
  1436. start = [ forward ? parent.firstChild : parent.lastChild ];
  1437. // non-xml :nth-child(...) stores cache data on `parent`
  1438. if ( forward && useCache ) {
  1439. // Seek `elem` from a previously-cached index
  1440. outerCache = parent[ expando ] || (parent[ expando ] = {});
  1441. cache = outerCache[ type ] || [];
  1442. nodeIndex = cache[0] === dirruns && cache[1];
  1443. diff = cache[0] === dirruns && cache[2];
  1444. node = nodeIndex && parent.childNodes[ nodeIndex ];
  1445. while ( (node = ++nodeIndex && node && node[ dir ] ||
  1446. // Fallback to seeking `elem` from the start
  1447. (diff = nodeIndex = 0) || start.pop()) ) {
  1448. // When found, cache indexes on `parent` and break
  1449. if ( node.nodeType === 1 && ++diff && node === elem ) {
  1450. outerCache[ type ] = [ dirruns, nodeIndex, diff ];
  1451. break;
  1452. }
  1453. }
  1454. // Use previously-cached element index if available
  1455. } else if ( useCache && (cache = (elem[ expando ] || (elem[ expando ] = {}))[ type ]) && cache[0] === dirruns ) {
  1456. diff = cache[1];
  1457. // xml :nth-child(...) or :nth-last-child(...) or :nth(-last)?-of-type(...)
  1458. } else {
  1459. // Use the same loop as above to seek `elem` from the start
  1460. while ( (node = ++nodeIndex && node && node[ dir ] ||
  1461. (diff = nodeIndex = 0) || start.pop()) ) {
  1462. if ( ( ofType ? node.nodeName.toLowerCase() === name : node.nodeType === 1 ) && ++diff ) {
  1463. // Cache the index of each encountered element
  1464. if ( useCache ) {
  1465. (node[ expando ] || (node[ expando ] = {}))[ type ] = [ dirruns, diff ];
  1466. }
  1467. if ( node === elem ) {
  1468. break;
  1469. }
  1470. }
  1471. }
  1472. }
  1473. // Incorporate the offset, then check against cycle size
  1474. diff -= last;
  1475. return diff === first || ( diff % first === 0 && diff / first >= 0 );
  1476. }
  1477. };
  1478. },
  1479. "PSEUDO": function( pseudo, argument ) {
  1480. // pseudo-class names are case-insensitive
  1481. // http://www.w3.org/TR/selectors/#pseudo-classes
  1482. // Prioritize by case sensitivity in case custom pseudos are added with uppercase letters
  1483. // Remember that setFilters inherits from pseudos
  1484. var args,
  1485. fn = Expr.pseudos[ pseudo ] || Expr.setFilters[ pseudo.toLowerCase() ] ||
  1486. Sizzle.error( "unsupported pseudo: " + pseudo );
  1487. // The user may use createPseudo to indicate that
  1488. // arguments are needed to create the filter function
  1489. // just as Sizzle does
  1490. if ( fn[ expando ] ) {
  1491. return fn( argument );
  1492. }
  1493. // But maintain support for old signatures
  1494. if ( fn.length > 1 ) {
  1495. args = [ pseudo, pseudo, "", argument ];
  1496. return Expr.setFilters.hasOwnProperty( pseudo.toLowerCase() ) ?
  1497. markFunction(function( seed, matches ) {
  1498. var idx,
  1499. matched = fn( seed, argument ),
  1500. i = matched.length;
  1501. while ( i-- ) {
  1502. idx = indexOf.call( seed, matched[i] );
  1503. seed[ idx ] = !( matches[ idx ] = matched[i] );
  1504. }
  1505. }) :
  1506. function( elem ) {
  1507. return fn( elem, 0, args );
  1508. };
  1509. }
  1510. return fn;
  1511. }
  1512. },
  1513. pseudos: {
  1514. // Potentially complex pseudos
  1515. "not": markFunction(function( selector ) {
  1516. // Trim the selector passed to compile
  1517. // to avoid treating leading and trailing
  1518. // spaces as combinators
  1519. var input = [],
  1520. results = [],
  1521. matcher = compile( selector.replace( rtrim, "$1" ) );
  1522. return matcher[ expando ] ?
  1523. markFunction(function( seed, matches, context, xml ) {
  1524. var elem,
  1525. unmatched = matcher( seed, null, xml, [] ),
  1526. i = seed.length;
  1527. // Match elements unmatched by `matcher`
  1528. while ( i-- ) {
  1529. if ( (elem = unmatched[i]) ) {
  1530. seed[i] = !(matches[i] = elem);
  1531. }
  1532. }
  1533. }) :
  1534. function( elem, context, xml ) {
  1535. input[0] = elem;
  1536. matcher( input, null, xml, results );
  1537. return !results.pop();
  1538. };
  1539. }),
  1540. "has": markFunction(function( selector ) {
  1541. return function( elem ) {
  1542. return Sizzle( selector, elem ).length > 0;
  1543. };
  1544. }),
  1545. "contains": markFunction(function( text ) {
  1546. return function( elem ) {
  1547. return ( elem.textContent || elem.innerText || getText( elem ) ).indexOf( text ) > -1;
  1548. };
  1549. }),
  1550. // "Whether an element is represented by a :lang() selector
  1551. // is based solely on the element's language value
  1552. // being equal to the identifier C,
  1553. // or beginning with the identifier C immediately followed by "-".
  1554. // The matching of C against the element's language value is performed case-insensitively.
  1555. // The identifier C does not have to be a valid language name."
  1556. // http://www.w3.org/TR/selectors/#lang-pseudo
  1557. "lang": markFunction( function( lang ) {
  1558. // lang value must be a valid identifier
  1559. if ( !ridentifier.test(lang || "") ) {
  1560. Sizzle.error( "unsupported lang: " + lang );
  1561. }
  1562. lang = lang.replace( runescape, funescape ).toLowerCase();
  1563. return function( elem ) {
  1564. var elemLang;
  1565. do {
  1566. if ( (elemLang = documentIsHTML ?
  1567. elem.lang :
  1568. elem.getAttribute("xml:lang") || elem.getAttribute("lang")) ) {
  1569. elemLang = elemLang.toLowerCase();
  1570. return elemLang === lang || elemLang.indexOf( lang + "-" ) === 0;
  1571. }
  1572. } while ( (elem = elem.parentNode) && elem.nodeType === 1 );
  1573. return false;
  1574. };
  1575. }),
  1576. // Miscellaneous
  1577. "target": function( elem ) {
  1578. var hash = window.location && window.location.hash;
  1579. return hash && hash.slice( 1 ) === elem.id;
  1580. },
  1581. "root": function( elem ) {
  1582. return elem === docElem;
  1583. },
  1584. "focus": function( elem ) {
  1585. return elem === document.activeElement && (!document.hasFocus || document.hasFocus()) && !!(elem.type || elem.href || ~elem.tabIndex);
  1586. },
  1587. // Boolean properties
  1588. "enabled": function( elem ) {
  1589. return elem.disabled === false;
  1590. },
  1591. "disabled": function( elem ) {
  1592. return elem.disabled === true;
  1593. },
  1594. "checked": function( elem ) {
  1595. // In CSS3, :checked should return both checked and selected elements
  1596. // http://www.w3.org/TR/2011/REC-css3-selectors-20110929/#checked
  1597. var nodeName = elem.nodeName.toLowerCase();
  1598. return (nodeName === "input" && !!elem.checked) || (nodeName === "option" && !!elem.selected);
  1599. },
  1600. "selected": function( elem ) {
  1601. // Accessing this property makes selected-by-default
  1602. // options in Safari work properly
  1603. if ( elem.parentNode ) {
  1604. elem.parentNode.selectedIndex;
  1605. }
  1606. return elem.selected === true;
  1607. },
  1608. // Contents
  1609. "empty": function( elem ) {
  1610. // http://www.w3.org/TR/selectors/#empty-pseudo
  1611. // :empty is negated by element (1) or content nodes (text: 3; cdata: 4; entity ref: 5),
  1612. // but not by others (comment: 8; processing instruction: 7; etc.)
  1613. // nodeType < 6 works because attributes (2) do not appear as children
  1614. for ( elem = elem.firstChild; elem; elem = elem.nextSibling ) {
  1615. if ( elem.nodeType < 6 ) {
  1616. return false;
  1617. }
  1618. }
  1619. return true;
  1620. },
  1621. "parent": function( elem ) {
  1622. return !Expr.pseudos["empty"]( elem );
  1623. },
  1624. // Element/input types
  1625. "header": function( elem ) {
  1626. return rheader.test( elem.nodeName );
  1627. },
  1628. "input": function( elem ) {
  1629. return rinputs.test( elem.nodeName );
  1630. },
  1631. "button": function( elem ) {
  1632. var name = elem.nodeName.toLowerCase();
  1633. return name === "input" && elem.type === "button" || name === "button";
  1634. },
  1635. "text": function( elem ) {
  1636. var attr;
  1637. return elem.nodeName.toLowerCase() === "input" &&
  1638. elem.type === "text" &&
  1639. // Support: IE<8
  1640. // New HTML5 attribute values (e.g., "search") appear with elem.type === "text"
  1641. ( (attr = elem.getAttribute("type")) == null || attr.toLowerCase() === "text" );
  1642. },
  1643. // Position-in-collection
  1644. "first": createPositionalPseudo(function() {
  1645. return [ 0 ];
  1646. }),
  1647. "last": createPositionalPseudo(function( matchIndexes, length ) {
  1648. return [ length - 1 ];
  1649. }),
  1650. "eq": createPositionalPseudo(function( matchIndexes, length, argument ) {
  1651. return [ argument < 0 ? argument + length : argument ];
  1652. }),
  1653. "even": createPositionalPseudo(function( matchIndexes, length ) {
  1654. var i = 0;
  1655. for ( ; i < length; i += 2 ) {
  1656. matchIndexes.push( i );
  1657. }
  1658. return matchIndexes;
  1659. }),
  1660. "odd": createPositionalPseudo(function( matchIndexes, length ) {
  1661. var i = 1;
  1662. for ( ; i < length; i += 2 ) {
  1663. matchIndexes.push( i );
  1664. }
  1665. return matchIndexes;
  1666. }),
  1667. "lt": createPositionalPseudo(function( matchIndexes, length, argument ) {
  1668. var i = argument < 0 ? argument + length : argument;
  1669. for ( ; --i >= 0; ) {
  1670. matchIndexes.push( i );
  1671. }
  1672. return matchIndexes;
  1673. }),
  1674. "gt": createPositionalPseudo(function( matchIndexes, length, argument ) {
  1675. var i = argument < 0 ? argument + length : argument;
  1676. for ( ; ++i < length; ) {
  1677. matchIndexes.push( i );
  1678. }
  1679. return matchIndexes;
  1680. })
  1681. }
  1682. };
  1683. Expr.pseudos["nth"] = Expr.pseudos["eq"];
  1684. // Add button/input type pseudos
  1685. for ( i in { radio: true, checkbox: true, file: true, password: true, image: true } ) {
  1686. Expr.pseudos[ i ] = createInputPseudo( i );
  1687. }
  1688. for ( i in { submit: true, reset: true } ) {
  1689. Expr.pseudos[ i ] = createButtonPseudo( i );
  1690. }
  1691. // Easy API for creating new setFilters
  1692. function setFilters() {}
  1693. setFilters.prototype = Expr.filters = Expr.pseudos;
  1694. Expr.setFilters = new setFilters();
  1695. tokenize = Sizzle.tokenize = function( selector, parseOnly ) {
  1696. var matched, match, tokens, type,
  1697. soFar, groups, preFilters,
  1698. cached = tokenCache[ selector + " " ];
  1699. if ( cached ) {
  1700. return parseOnly ? 0 : cached.slice( 0 );
  1701. }
  1702. soFar = selector;
  1703. groups = [];
  1704. preFilters = Expr.preFilter;
  1705. while ( soFar ) {
  1706. // Comma and first run
  1707. if ( !matched || (match = rcomma.exec( soFar )) ) {
  1708. if ( match ) {
  1709. // Don't consume trailing commas as valid
  1710. soFar = soFar.slice( match[0].length ) || soFar;
  1711. }
  1712. groups.push( (tokens = []) );
  1713. }
  1714. matched = false;
  1715. // Combinators
  1716. if ( (match = rcombinators.exec( soFar )) ) {
  1717. matched = match.shift();
  1718. tokens.push({
  1719. value: matched,
  1720. // Cast descendant combinators to space
  1721. type: match[0].replace( rtrim, " " )
  1722. });
  1723. soFar = soFar.slice( matched.length );
  1724. }
  1725. // Filters
  1726. for ( type in Expr.filter ) {
  1727. if ( (match = matchExpr[ type ].exec( soFar )) && (!preFilters[ type ] ||
  1728. (match = preFilters[ type ]( match ))) ) {
  1729. matched = match.shift();
  1730. tokens.push({
  1731. value: matched,
  1732. type: type,
  1733. matches: match
  1734. });
  1735. soFar = soFar.slice( matched.length );
  1736. }
  1737. }
  1738. if ( !matched ) {
  1739. break;
  1740. }
  1741. }
  1742. // Return the length of the invalid excess
  1743. // if we're just parsing
  1744. // Otherwise, throw an error or return tokens
  1745. return parseOnly ?
  1746. soFar.length :
  1747. soFar ?
  1748. Sizzle.error( selector ) :
  1749. // Cache the tokens
  1750. tokenCache( selector, groups ).slice( 0 );
  1751. };
  1752. function toSelector( tokens ) {
  1753. var i = 0,
  1754. len = tokens.length,
  1755. selector = "";
  1756. for ( ; i < len; i++ ) {
  1757. selector += tokens[i].value;
  1758. }
  1759. return selector;
  1760. }
  1761. function addCombinator( matcher, combinator, base ) {
  1762. var dir = combinator.dir,
  1763. checkNonElements = base && dir === "parentNode",
  1764. doneName = done++;
  1765. return combinator.first ?
  1766. // Check against closest ancestor/preceding element
  1767. function( elem, context, xml ) {
  1768. while ( (elem = elem[ dir ]) ) {
  1769. if ( elem.nodeType === 1 || checkNonElements ) {
  1770. return matcher( elem, context, xml );
  1771. }
  1772. }
  1773. } :
  1774. // Check against all ancestor/preceding elements
  1775. function( elem, context, xml ) {
  1776. var oldCache, outerCache,
  1777. newCache = [ dirruns, doneName ];
  1778. // We can't set arbitrary data on XML nodes, so they don't benefit from dir caching
  1779. if ( xml ) {
  1780. while ( (elem = elem[ dir ]) ) {
  1781. if ( elem.nodeType === 1 || checkNonElements ) {
  1782. if ( matcher( elem, context, xml ) ) {
  1783. return true;
  1784. }
  1785. }
  1786. }
  1787. } else {
  1788. while ( (elem = elem[ dir ]) ) {
  1789. if ( elem.nodeType === 1 || checkNonElements ) {
  1790. outerCache = elem[ expando ] || (elem[ expando ] = {});
  1791. if ( (oldCache = outerCache[ dir ]) &&
  1792. oldCache[ 0 ] === dirruns && oldCache[ 1 ] === doneName ) {
  1793. // Assign to newCache so results back-propagate to previous elements
  1794. return (newCache[ 2 ] = oldCache[ 2 ]);
  1795. } else {
  1796. // Reuse newcache so results back-propagate to previous elements
  1797. outerCache[ dir ] = newCache;
  1798. // A match means we're done; a fail means we have to keep checking
  1799. if ( (newCache[ 2 ] = matcher( elem, context, xml )) ) {
  1800. return true;
  1801. }
  1802. }
  1803. }
  1804. }
  1805. }
  1806. };
  1807. }
  1808. function elementMatcher( matchers ) {
  1809. return matchers.length > 1 ?
  1810. function( elem, context, xml ) {
  1811. var i = matchers.length;
  1812. while ( i-- ) {
  1813. if ( !matchers[i]( elem, context, xml ) ) {
  1814. return false;
  1815. }
  1816. }
  1817. return true;
  1818. } :
  1819. matchers[0];
  1820. }
  1821. function multipleContexts( selector, contexts, results ) {
  1822. var i = 0,
  1823. len = contexts.length;
  1824. for ( ; i < len; i++ ) {
  1825. Sizzle( selector, contexts[i], results );
  1826. }
  1827. return results;
  1828. }
  1829. function condense( unmatched, map, filter, context, xml ) {
  1830. var elem,
  1831. newUnmatched = [],
  1832. i = 0,
  1833. len = unmatched.length,
  1834. mapped = map != null;
  1835. for ( ; i < len; i++ ) {
  1836. if ( (elem = unmatched[i]) ) {
  1837. if ( !filter || filter( elem, context, xml ) ) {
  1838. newUnmatched.push( elem );
  1839. if ( mapped ) {
  1840. map.push( i );
  1841. }
  1842. }
  1843. }
  1844. }
  1845. return newUnmatched;
  1846. }
  1847. function setMatcher( preFilter, selector, matcher, postFilter, postFinder, postSelector ) {
  1848. if ( postFilter && !postFilter[ expando ] ) {
  1849. postFilter = setMatcher( postFilter );
  1850. }
  1851. if ( postFinder && !postFinder[ expando ] ) {
  1852. postFinder = setMatcher( postFinder, postSelector );
  1853. }
  1854. return markFunction(function( seed, results, context, xml ) {
  1855. var temp, i, elem,
  1856. preMap = [],
  1857. postMap = [],
  1858. preexisting = results.length,
  1859. // Get initial elements from seed or context
  1860. elems = seed || multipleContexts( selector || "*", context.nodeType ? [ context ] : context, [] ),
  1861. // Prefilter to get matcher input, preserving a map for seed-results synchronization
  1862. matcherIn = preFilter && ( seed || !selector ) ?
  1863. condense( elems, preMap, preFilter, context, xml ) :
  1864. elems,
  1865. matcherOut = matcher ?
  1866. // If we have a postFinder, or filtered seed, or non-seed postFilter or preexisting results,
  1867. postFinder || ( seed ? preFilter : preexisting || postFilter ) ?
  1868. // ...intermediate processing is necessary
  1869. [] :
  1870. // ...otherwise use results directly
  1871. results :
  1872. matcherIn;
  1873. // Find primary matches
  1874. if ( matcher ) {
  1875. matcher( matcherIn, matcherOut, context, xml );
  1876. }
  1877. // Apply postFilter
  1878. if ( postFilter ) {
  1879. temp = condense( matcherOut, postMap );
  1880. postFilter( temp, [], context, xml );
  1881. // Un-match failing elements by moving them back to matcherIn
  1882. i = temp.length;
  1883. while ( i-- ) {
  1884. if ( (elem = temp[i]) ) {
  1885. matcherOut[ postMap[i] ] = !(matcherIn[ postMap[i] ] = elem);
  1886. }
  1887. }
  1888. }
  1889. if ( seed ) {
  1890. if ( postFinder || preFilter ) {
  1891. if ( postFinder ) {
  1892. // Get the final matcherOut by condensing this intermediate into postFinder contexts
  1893. temp = [];
  1894. i = matcherOut.length;
  1895. while ( i-- ) {
  1896. if ( (elem = matcherOut[i]) ) {
  1897. // Restore matcherIn since elem is not yet a final match
  1898. temp.push( (matcherIn[i] = elem) );
  1899. }
  1900. }
  1901. postFinder( null, (matcherOut = []), temp, xml );
  1902. }
  1903. // Move matched elements from seed to results to keep them synchronized
  1904. i = matcherOut.length;
  1905. while ( i-- ) {
  1906. if ( (elem = matcherOut[i]) &&
  1907. (temp = postFinder ? indexOf.call( seed, elem ) : preMap[i]) > -1 ) {
  1908. seed[temp] = !(results[temp] = elem);
  1909. }
  1910. }
  1911. }
  1912. // Add elements to results, through postFinder if defined
  1913. } else {
  1914. matcherOut = condense(
  1915. matcherOut === results ?
  1916. matcherOut.splice( preexisting, matcherOut.length ) :
  1917. matcherOut
  1918. );
  1919. if ( postFinder ) {
  1920. postFinder( null, results, matcherOut, xml );
  1921. } else {
  1922. push.apply( results, matcherOut );
  1923. }
  1924. }
  1925. });
  1926. }
  1927. function matcherFromTokens( tokens ) {
  1928. var checkContext, matcher, j,
  1929. len = tokens.length,
  1930. leadingRelative = Expr.relative[ tokens[0].type ],
  1931. implicitRelative = leadingRelative || Expr.relative[" "],
  1932. i = leadingRelative ? 1 : 0,
  1933. // The foundational matcher ensures that elements are reachable from top-level context(s)
  1934. matchContext = addCombinator( function( elem ) {
  1935. return elem === checkContext;
  1936. }, implicitRelative, true ),
  1937. matchAnyContext = addCombinator( function( elem ) {
  1938. return indexOf.call( checkContext, elem ) > -1;
  1939. }, implicitRelative, true ),
  1940. matchers = [ function( elem, context, xml ) {
  1941. return ( !leadingRelative && ( xml || context !== outermostContext ) ) || (
  1942. (checkContext = context).nodeType ?
  1943. matchContext( elem, context, xml ) :
  1944. matchAnyContext( elem, context, xml ) );
  1945. } ];
  1946. for ( ; i < len; i++ ) {
  1947. if ( (matcher = Expr.relative[ tokens[i].type ]) ) {
  1948. matchers = [ addCombinator(elementMatcher( matchers ), matcher) ];
  1949. } else {
  1950. matcher = Expr.filter[ tokens[i].type ].apply( null, tokens[i].matches );
  1951. // Return special upon seeing a positional matcher
  1952. if ( matcher[ expando ] ) {
  1953. // Find the next relative operator (if any) for proper handling
  1954. j = ++i;
  1955. for ( ; j < len; j++ ) {
  1956. if ( Expr.relative[ tokens[j].type ] ) {
  1957. break;
  1958. }
  1959. }
  1960. return setMatcher(
  1961. i > 1 && elementMatcher( matchers ),
  1962. i > 1 && toSelector(
  1963. // If the preceding token was a descendant combinator, insert an implicit any-element `*`
  1964. tokens.slice( 0, i - 1 ).concat({ value: tokens[ i - 2 ].type === " " ? "*" : "" })
  1965. ).replace( rtrim, "$1" ),
  1966. matcher,
  1967. i < j && matcherFromTokens( tokens.slice( i, j ) ),
  1968. j < len && matcherFromTokens( (tokens = tokens.slice( j )) ),
  1969. j < len && toSelector( tokens )
  1970. );
  1971. }
  1972. matchers.push( matcher );
  1973. }
  1974. }
  1975. return elementMatcher( matchers );
  1976. }
  1977. function matcherFromGroupMatchers( elementMatchers, setMatchers ) {
  1978. var bySet = setMatchers.length > 0,
  1979. byElement = elementMatchers.length > 0,
  1980. superMatcher = function( seed, context, xml, results, outermost ) {
  1981. var elem, j, matcher,
  1982. matchedCount = 0,
  1983. i = "0",
  1984. unmatched = seed && [],
  1985. setMatched = [],
  1986. contextBackup = outermostContext,
  1987. // We must always have either seed elements or outermost context
  1988. elems = seed || byElement && Expr.find["TAG"]( "*", outermost ),
  1989. // Use integer dirruns iff this is the outermost matcher
  1990. dirrunsUnique = (dirruns += contextBackup == null ? 1 : Math.random() || 0.1),
  1991. len = elems.length;
  1992. if ( outermost ) {
  1993. outermostContext = context !== document && context;
  1994. }
  1995. // Add elements passing elementMatchers directly to results
  1996. // Keep `i` a string if there are no elements so `matchedCount` will be "00" below
  1997. // Support: IE<9, Safari
  1998. // Tolerate NodeList properties (IE: "length"; Safari: <number>) matching elements by id
  1999. for ( ; i !== len && (elem = elems[i]) != null; i++ ) {
  2000. if ( byElement && elem ) {
  2001. j = 0;
  2002. while ( (matcher = elementMatchers[j++]) ) {
  2003. if ( matcher( elem, context, xml ) ) {
  2004. results.push( elem );
  2005. break;
  2006. }
  2007. }
  2008. if ( outermost ) {
  2009. dirruns = dirrunsUnique;
  2010. }
  2011. }
  2012. // Track unmatched elements for set filters
  2013. if ( bySet ) {
  2014. // They will have gone through all possible matchers
  2015. if ( (elem = !matcher && elem) ) {
  2016. matchedCount--;
  2017. }
  2018. // Lengthen the array for every element, matched or not
  2019. if ( seed ) {
  2020. unmatched.push( elem );
  2021. }
  2022. }
  2023. }
  2024. // Apply set filters to unmatched elements
  2025. matchedCount += i;
  2026. if ( bySet && i !== matchedCount ) {
  2027. j = 0;
  2028. while ( (matcher = setMatchers[j++]) ) {
  2029. matcher( unmatched, setMatched, context, xml );
  2030. }
  2031. if ( seed ) {
  2032. // Reintegrate element matches to eliminate the need for sorting
  2033. if ( matchedCount > 0 ) {
  2034. while ( i-- ) {
  2035. if ( !(unmatched[i] || setMatched[i]) ) {
  2036. setMatched[i] = pop.call( results );
  2037. }
  2038. }
  2039. }
  2040. // Discard index placeholder values to get only actual matches
  2041. setMatched = condense( setMatched );
  2042. }
  2043. // Add matches to results
  2044. push.apply( results, setMatched );
  2045. // Seedless set matches succeeding multiple successful matchers stipulate sorting
  2046. if ( outermost && !seed && setMatched.length > 0 &&
  2047. ( matchedCount + setMatchers.length ) > 1 ) {
  2048. Sizzle.uniqueSort( results );
  2049. }
  2050. }
  2051. // Override manipulation of globals by nested matchers
  2052. if ( outermost ) {
  2053. dirruns = dirrunsUnique;
  2054. outermostContext = contextBackup;
  2055. }
  2056. return unmatched;
  2057. };
  2058. return bySet ?
  2059. markFunction( superMatcher ) :
  2060. superMatcher;
  2061. }
  2062. compile = Sizzle.compile = function( selector, match /* Internal Use Only */ ) {
  2063. var i,
  2064. setMatchers = [],
  2065. elementMatchers = [],
  2066. cached = compilerCache[ selector + " " ];
  2067. if ( !cached ) {
  2068. // Generate a function of recursive functions that can be used to check each element
  2069. if ( !match ) {
  2070. match = tokenize( selector );
  2071. }
  2072. i = match.length;
  2073. while ( i-- ) {
  2074. cached = matcherFromTokens( match[i] );
  2075. if ( cached[ expando ] ) {
  2076. setMatchers.push( cached );
  2077. } else {
  2078. elementMatchers.push( cached );
  2079. }
  2080. }
  2081. // Cache the compiled function
  2082. cached = compilerCache( selector, matcherFromGroupMatchers( elementMatchers, setMatchers ) );
  2083. // Save selector and tokenization
  2084. cached.selector = selector;
  2085. }
  2086. return cached;
  2087. };
  2088. /**
  2089. * A low-level selection function that works with Sizzle's compiled
  2090. * selector functions
  2091. * @param {String|Function} selector A selector or a pre-compiled
  2092. * selector function built with Sizzle.compile
  2093. * @param {Element} context
  2094. * @param {Array} [results]
  2095. * @param {Array} [seed] A set of elements to match against
  2096. */
  2097. select = Sizzle.select = function( selector, context, results, seed ) {
  2098. var i, tokens, token, type, find,
  2099. compiled = typeof selector === "function" && selector,
  2100. match = !seed && tokenize( (selector = compiled.selector || selector) );
  2101. results = results || [];
  2102. // Try to minimize operations if there is no seed and only one group
  2103. if ( match.length === 1 ) {
  2104. // Take a shortcut and set the context if the root selector is an ID
  2105. tokens = match[0] = match[0].slice( 0 );
  2106. if ( tokens.length > 2 && (token = tokens[0]).type === "ID" &&
  2107. support.getById && context.nodeType === 9 && documentIsHTML &&
  2108. Expr.relative[ tokens[1].type ] ) {
  2109. context = ( Expr.find["ID"]( token.matches[0].replace(runescape, funescape), context ) || [] )[0];
  2110. if ( !context ) {
  2111. return results;
  2112. // Precompiled matchers will still verify ancestry, so step up a level
  2113. } else if ( compiled ) {
  2114. context = context.parentNode;
  2115. }
  2116. selector = selector.slice( tokens.shift().value.length );
  2117. }
  2118. // Fetch a seed set for right-to-left matching
  2119. i = matchExpr["needsContext"].test( selector ) ? 0 : tokens.length;
  2120. while ( i-- ) {
  2121. token = tokens[i];
  2122. // Abort if we hit a combinator
  2123. if ( Expr.relative[ (type = token.type) ] ) {
  2124. break;
  2125. }
  2126. if ( (find = Expr.find[ type ]) ) {
  2127. // Search, expanding context for leading sibling combinators
  2128. if ( (seed = find(
  2129. token.matches[0].replace( runescape, funescape ),
  2130. rsibling.test( tokens[0].type ) && testContext( context.parentNode ) || context
  2131. )) ) {
  2132. // If seed is empty or no tokens remain, we can return early
  2133. tokens.splice( i, 1 );
  2134. selector = seed.length && toSelector( tokens );
  2135. if ( !selector ) {
  2136. push.apply( results, seed );
  2137. return results;
  2138. }
  2139. break;
  2140. }
  2141. }
  2142. }
  2143. }
  2144. // Compile and execute a filtering function if one is not provided
  2145. // Provide `match` to avoid retokenization if we modified the selector above
  2146. ( compiled || compile( selector, match ) )(
  2147. seed,
  2148. context,
  2149. !documentIsHTML,
  2150. results,
  2151. rsibling.test( selector ) && testContext( context.parentNode ) || context
  2152. );
  2153. return results;
  2154. };
  2155. // One-time assignments
  2156. // Sort stability
  2157. support.sortStable = expando.split("").sort( sortOrder ).join("") === expando;
  2158. // Support: Chrome<14
  2159. // Always assume duplicates if they aren't passed to the comparison function
  2160. support.detectDuplicates = !!hasDuplicate;
  2161. // Initialize against the default document
  2162. setDocument();
  2163. // Support: Webkit<537.32 - Safari 6.0.3/Chrome 25 (fixed in Chrome 27)
  2164. // Detached nodes confoundingly follow *each other*
  2165. support.sortDetached = assert(function( div1 ) {
  2166. // Should return 1, but returns 4 (following)
  2167. return div1.compareDocumentPosition( document.createElement("div") ) & 1;
  2168. });
  2169. // Support: IE<8
  2170. // Prevent attribute/property "interpolation"
  2171. // http://msdn.microsoft.com/en-us/library/ms536429%28VS.85%29.aspx
  2172. if ( !assert(function( div ) {
  2173. div.innerHTML = "<a href='#'></a>";
  2174. return div.firstChild.getAttribute("href") === "#" ;
  2175. }) ) {
  2176. addHandle( "type|href|height|width", function( elem, name, isXML ) {
  2177. if ( !isXML ) {
  2178. return elem.getAttribute( name, name.toLowerCase() === "type" ? 1 : 2 );
  2179. }
  2180. });
  2181. }
  2182. // Support: IE<9
  2183. // Use defaultValue in place of getAttribute("value")
  2184. if ( !support.attributes || !assert(function( div ) {
  2185. div.innerHTML = "<input/>";
  2186. div.firstChild.setAttribute( "value", "" );
  2187. return div.firstChild.getAttribute( "value" ) === "";
  2188. }) ) {
  2189. addHandle( "value", function( elem, name, isXML ) {
  2190. if ( !isXML && elem.nodeName.toLowerCase() === "input" ) {
  2191. return elem.defaultValue;
  2192. }
  2193. });
  2194. }
  2195. // Support: IE<9
  2196. // Use getAttributeNode to fetch booleans when getAttribute lies
  2197. if ( !assert(function( div ) {
  2198. return div.getAttribute("disabled") == null;
  2199. }) ) {
  2200. addHandle( booleans, function( elem, name, isXML ) {
  2201. var val;
  2202. if ( !isXML ) {
  2203. return elem[ name ] === true ? name.toLowerCase() :
  2204. (val = elem.getAttributeNode( name )) && val.specified ?
  2205. val.value :
  2206. null;
  2207. }
  2208. });
  2209. }
  2210. return Sizzle;
  2211. })( window );
  2212. jQuery.find = Sizzle;
  2213. jQuery.expr = Sizzle.selectors;
  2214. jQuery.expr[":"] = jQuery.expr.pseudos;
  2215. jQuery.unique = Sizzle.uniqueSort;
  2216. jQuery.text = Sizzle.getText;
  2217. jQuery.isXMLDoc = Sizzle.isXML;
  2218. jQuery.contains = Sizzle.contains;
  2219. var rneedsContext = jQuery.expr.match.needsContext;
  2220. var rsingleTag = (/^<(\w+)\s*\/?>(?:<\/\1>|)$/);
  2221. var risSimple = /^.[^:#\[\.,]*$/;
  2222. // Implement the identical functionality for filter and not
  2223. function winnow( elements, qualifier, not ) {
  2224. if ( jQuery.isFunction( qualifier ) ) {
  2225. return jQuery.grep( elements, function( elem, i ) {
  2226. /* jshint -W018 */
  2227. return !!qualifier.call( elem, i, elem ) !== not;
  2228. });
  2229. }
  2230. if ( qualifier.nodeType ) {
  2231. return jQuery.grep( elements, function( elem ) {
  2232. return ( elem === qualifier ) !== not;
  2233. });
  2234. }
  2235. if ( typeof qualifier === "string" ) {
  2236. if ( risSimple.test( qualifier ) ) {
  2237. return jQuery.filter( qualifier, elements, not );
  2238. }
  2239. qualifier = jQuery.filter( qualifier, elements );
  2240. }
  2241. return jQuery.grep( elements, function( elem ) {
  2242. return ( jQuery.inArray( elem, qualifier ) >= 0 ) !== not;
  2243. });
  2244. }
  2245. jQuery.filter = function( expr, elems, not ) {
  2246. var elem = elems[ 0 ];
  2247. if ( not ) {
  2248. expr = ":not(" + expr + ")";
  2249. }
  2250. return elems.length === 1 && elem.nodeType === 1 ?
  2251. jQuery.find.matchesSelector( elem, expr ) ? [ elem ] : [] :
  2252. jQuery.find.matches( expr, jQuery.grep( elems, function( elem ) {
  2253. return elem.nodeType === 1;
  2254. }));
  2255. };
  2256. jQuery.fn.extend({
  2257. find: function( selector ) {
  2258. var i,
  2259. ret = [],
  2260. self = this,
  2261. len = self.length;
  2262. if ( typeof selector !== "string" ) {
  2263. return this.pushStack( jQuery( selector ).filter(function() {
  2264. for ( i = 0; i < len; i++ ) {
  2265. if ( jQuery.contains( self[ i ], this ) ) {
  2266. return true;
  2267. }
  2268. }
  2269. }) );
  2270. }
  2271. for ( i = 0; i < len; i++ ) {
  2272. jQuery.find( selector, self[ i ], ret );
  2273. }
  2274. // Needed because $( selector, context ) becomes $( context ).find( selector )
  2275. ret = this.pushStack( len > 1 ? jQuery.unique( ret ) : ret );
  2276. ret.selector = this.selector ? this.selector + " " + selector : selector;
  2277. return ret;
  2278. },
  2279. filter: function( selector ) {
  2280. return this.pushStack( winnow(this, selector || [], false) );
  2281. },
  2282. not: function( selector ) {
  2283. return this.pushStack( winnow(this, selector || [], true) );
  2284. },
  2285. is: function( selector ) {
  2286. return !!winnow(
  2287. this,
  2288. // If this is a positional/relative selector, check membership in the returned set
  2289. // so $("p:first").is("p:last") won't return true for a doc with two "p".
  2290. typeof selector === "string" && rneedsContext.test( selector ) ?
  2291. jQuery( selector ) :
  2292. selector || [],
  2293. false
  2294. ).length;
  2295. }
  2296. });
  2297. // Initialize a jQuery object
  2298. // A central reference to the root jQuery(document)
  2299. var rootjQuery,
  2300. // Use the correct document accordingly with window argument (sandbox)
  2301. document = window.document,
  2302. // A simple way to check for HTML strings
  2303. // Prioritize #id over <tag> to avoid XSS via location.hash (#9521)
  2304. // Strict HTML recognition (#11290: must start with <)
  2305. rquickExpr = /^(?:\s*(<[\w\W]+>)[^>]*|#([\w-]*))$/,
  2306. init = jQuery.fn.init = function( selector, context ) {
  2307. var match, elem;
  2308. // HANDLE: $(""), $(null), $(undefined), $(false)
  2309. if ( !selector ) {
  2310. return this;
  2311. }
  2312. // Handle HTML strings
  2313. if ( typeof selector === "string" ) {
  2314. if ( selector.charAt(0) === "<" && selector.charAt( selector.length - 1 ) === ">" && selector.length >= 3 ) {
  2315. // Assume that strings that start and end with <> are HTML and skip the regex check
  2316. match = [ null, selector, null ];
  2317. } else {
  2318. match = rquickExpr.exec( selector );
  2319. }
  2320. // Match html or make sure no context is specified for #id
  2321. if ( match && (match[1] || !context) ) {
  2322. // HANDLE: $(html) -> $(array)
  2323. if ( match[1] ) {
  2324. context = context instanceof jQuery ? context[0] : context;
  2325. // scripts is true for back-compat
  2326. // Intentionally let the error be thrown if parseHTML is not present
  2327. jQuery.merge( this, jQuery.parseHTML(
  2328. match[1],
  2329. context && context.nodeType ? context.ownerDocument || context : document,
  2330. true
  2331. ) );
  2332. // HANDLE: $(html, props)
  2333. if ( rsingleTag.test( match[1] ) && jQuery.isPlainObject( context ) ) {
  2334. for ( match in context ) {
  2335. // Properties of context are called as methods if possible
  2336. if ( jQuery.isFunction( this[ match ] ) ) {
  2337. this[ match ]( context[ match ] );
  2338. // ...and otherwise set as attributes
  2339. } else {
  2340. this.attr( match, context[ match ] );
  2341. }
  2342. }
  2343. }
  2344. return this;
  2345. // HANDLE: $(#id)
  2346. } else {
  2347. elem = document.getElementById( match[2] );
  2348. // Check parentNode to catch when Blackberry 4.6 returns
  2349. // nodes that are no longer in the document #6963
  2350. if ( elem && elem.parentNode ) {
  2351. // Handle the case where IE and Opera return items
  2352. // by name instead of ID
  2353. if ( elem.id !== match[2] ) {
  2354. return rootjQuery.find( selector );
  2355. }
  2356. // Otherwise, we inject the element directly into the jQuery object
  2357. this.length = 1;
  2358. this[0] = elem;
  2359. }
  2360. this.context = document;
  2361. this.selector = selector;
  2362. return this;
  2363. }
  2364. // HANDLE: $(expr, $(...))
  2365. } else if ( !context || context.jquery ) {
  2366. return ( context || rootjQuery ).find( selector );
  2367. // HANDLE: $(expr, context)
  2368. // (which is just equivalent to: $(context).find(expr)
  2369. } else {
  2370. return this.constructor( context ).find( selector );
  2371. }
  2372. // HANDLE: $(DOMElement)
  2373. } else if ( selector.nodeType ) {
  2374. this.context = this[0] = selector;
  2375. this.length = 1;
  2376. return this;
  2377. // HANDLE: $(function)
  2378. // Shortcut for document ready
  2379. } else if ( jQuery.isFunction( selector ) ) {
  2380. return typeof rootjQuery.ready !== "undefined" ?
  2381. rootjQuery.ready( selector ) :
  2382. // Execute immediately if ready is not present
  2383. selector( jQuery );
  2384. }
  2385. if ( selector.selector !== undefined ) {
  2386. this.selector = selector.selector;
  2387. this.context = selector.context;
  2388. }
  2389. return jQuery.makeArray( selector, this );
  2390. };
  2391. // Give the init function the jQuery prototype for later instantiation
  2392. init.prototype = jQuery.fn;
  2393. // Initialize central reference
  2394. rootjQuery = jQuery( document );
  2395. var rparentsprev = /^(?:parents|prev(?:Until|All))/,
  2396. // methods guaranteed to produce a unique set when starting from a unique set
  2397. guaranteedUnique = {
  2398. children: true,
  2399. contents: true,
  2400. next: true,
  2401. prev: true
  2402. };
  2403. jQuery.extend({
  2404. dir: function( elem, dir, until ) {
  2405. var matched = [],
  2406. cur = elem[ dir ];
  2407. while ( cur && cur.nodeType !== 9 && (until === undefined || cur.nodeType !== 1 || !jQuery( cur ).is( until )) ) {
  2408. if ( cur.nodeType === 1 ) {
  2409. matched.push( cur );
  2410. }
  2411. cur = cur[dir];
  2412. }
  2413. return matched;
  2414. },
  2415. sibling: function( n, elem ) {
  2416. var r = [];
  2417. for ( ; n; n = n.nextSibling ) {
  2418. if ( n.nodeType === 1 && n !== elem ) {
  2419. r.push( n );
  2420. }
  2421. }
  2422. return r;
  2423. }
  2424. });
  2425. jQuery.fn.extend({
  2426. has: function( target ) {
  2427. var i,
  2428. targets = jQuery( target, this ),
  2429. len = targets.length;
  2430. return this.filter(function() {
  2431. for ( i = 0; i < len; i++ ) {
  2432. if ( jQuery.contains( this, targets[i] ) ) {
  2433. return true;
  2434. }
  2435. }
  2436. });
  2437. },
  2438. closest: function( selectors, context ) {
  2439. var cur,
  2440. i = 0,
  2441. l = this.length,
  2442. matched = [],
  2443. pos = rneedsContext.test( selectors ) || typeof selectors !== "string" ?
  2444. jQuery( selectors, context || this.context ) :
  2445. 0;
  2446. for ( ; i < l; i++ ) {
  2447. for ( cur = this[i]; cur && cur !== context; cur = cur.parentNode ) {
  2448. // Always skip document fragments
  2449. if ( cur.nodeType < 11 && (pos ?
  2450. pos.index(cur) > -1 :
  2451. // Don't pass non-elements to Sizzle
  2452. cur.nodeType === 1 &&
  2453. jQuery.find.matchesSelector(cur, selectors)) ) {
  2454. matched.push( cur );
  2455. break;
  2456. }
  2457. }
  2458. }
  2459. return this.pushStack( matched.length > 1 ? jQuery.unique( matched ) : matched );
  2460. },
  2461. // Determine the position of an element within
  2462. // the matched set of elements
  2463. index: function( elem ) {
  2464. // No argument, return index in parent
  2465. if ( !elem ) {
  2466. return ( this[0] && this[0].parentNode ) ? this.first().prevAll().length : -1;
  2467. }
  2468. // index in selector
  2469. if ( typeof elem === "string" ) {
  2470. return jQuery.inArray( this[0], jQuery( elem ) );
  2471. }
  2472. // Locate the position of the desired element
  2473. return jQuery.inArray(
  2474. // If it receives a jQuery object, the first element is used
  2475. elem.jquery ? elem[0] : elem, this );
  2476. },
  2477. add: function( selector, context ) {
  2478. return this.pushStack(
  2479. jQuery.unique(
  2480. jQuery.merge( this.get(), jQuery( selector, context ) )
  2481. )
  2482. );
  2483. },
  2484. addBack: function( selector ) {
  2485. return this.add( selector == null ?
  2486. this.prevObject : this.prevObject.filter(selector)
  2487. );
  2488. }
  2489. });
  2490. function sibling( cur, dir ) {
  2491. do {
  2492. cur = cur[ dir ];
  2493. } while ( cur && cur.nodeType !== 1 );
  2494. return cur;
  2495. }
  2496. jQuery.each({
  2497. parent: function( elem ) {
  2498. var parent = elem.parentNode;
  2499. return parent && parent.nodeType !== 11 ? parent : null;
  2500. },
  2501. parents: function( elem ) {
  2502. return jQuery.dir( elem, "parentNode" );
  2503. },
  2504. parentsUntil: function( elem, i, until ) {
  2505. return jQuery.dir( elem, "parentNode", until );
  2506. },
  2507. next: function( elem ) {
  2508. return sibling( elem, "nextSibling" );
  2509. },
  2510. prev: function( elem ) {
  2511. return sibling( elem, "previousSibling" );
  2512. },
  2513. nextAll: function( elem ) {
  2514. return jQuery.dir( elem, "nextSibling" );
  2515. },
  2516. prevAll: function( elem ) {
  2517. return jQuery.dir( elem, "previousSibling" );
  2518. },
  2519. nextUntil: function( elem, i, until ) {
  2520. return jQuery.dir( elem, "nextSibling", until );
  2521. },
  2522. prevUntil: function( elem, i, until ) {
  2523. return jQuery.dir( elem, "previousSibling", until );
  2524. },
  2525. siblings: function( elem ) {
  2526. return jQuery.sibling( ( elem.parentNode || {} ).firstChild, elem );
  2527. },
  2528. children: function( elem ) {
  2529. return jQuery.sibling( elem.firstChild );
  2530. },
  2531. contents: function( elem ) {
  2532. return jQuery.nodeName( elem, "iframe" ) ?
  2533. elem.contentDocument || elem.contentWindow.document :
  2534. jQuery.merge( [], elem.childNodes );
  2535. }
  2536. }, function( name, fn ) {
  2537. jQuery.fn[ name ] = function( until, selector ) {
  2538. var ret = jQuery.map( this, fn, until );
  2539. if ( name.slice( -5 ) !== "Until" ) {
  2540. selector = until;
  2541. }
  2542. if ( selector && typeof selector === "string" ) {
  2543. ret = jQuery.filter( selector, ret );
  2544. }
  2545. if ( this.length > 1 ) {
  2546. // Remove duplicates
  2547. if ( !guaranteedUnique[ name ] ) {
  2548. ret = jQuery.unique( ret );
  2549. }
  2550. // Reverse order for parents* and prev-derivatives
  2551. if ( rparentsprev.test( name ) ) {
  2552. ret = ret.reverse();
  2553. }
  2554. }
  2555. return this.pushStack( ret );
  2556. };
  2557. });
  2558. var rnotwhite = (/\S+/g);
  2559. // String to Object options format cache
  2560. var optionsCache = {};
  2561. // Convert String-formatted options into Object-formatted ones and store in cache
  2562. function createOptions( options ) {
  2563. var object = optionsCache[ options ] = {};
  2564. jQuery.each( options.match( rnotwhite ) || [], function( _, flag ) {
  2565. object[ flag ] = true;
  2566. });
  2567. return object;
  2568. }
  2569. /*
  2570. * Create a callback list using the following parameters:
  2571. *
  2572. * options: an optional list of space-separated options that will change how
  2573. * the callback list behaves or a more traditional option object
  2574. *
  2575. * By default a callback list will act like an event callback list and can be
  2576. * "fired" multiple times.
  2577. *
  2578. * Possible options:
  2579. *
  2580. * once: will ensure the callback list can only be fired once (like a Deferred)
  2581. *
  2582. * memory: will keep track of previous values and will call any callback added
  2583. * after the list has been fired right away with the latest "memorized"
  2584. * values (like a Deferred)
  2585. *
  2586. * unique: will ensure a callback can only be added once (no duplicate in the list)
  2587. *
  2588. * stopOnFalse: interrupt callings when a callback returns false
  2589. *
  2590. */
  2591. jQuery.Callbacks = function( options ) {
  2592. // Convert options from String-formatted to Object-formatted if needed
  2593. // (we check in cache first)
  2594. options = typeof options === "string" ?
  2595. ( optionsCache[ options ] || createOptions( options ) ) :
  2596. jQuery.extend( {}, options );
  2597. var // Flag to know if list is currently firing
  2598. firing,
  2599. // Last fire value (for non-forgettable lists)
  2600. memory,
  2601. // Flag to know if list was already fired
  2602. fired,
  2603. // End of the loop when firing
  2604. firingLength,
  2605. // Index of currently firing callback (modified by remove if needed)
  2606. firingIndex,
  2607. // First callback to fire (used internally by add and fireWith)
  2608. firingStart,
  2609. // Actual callback list
  2610. list = [],
  2611. // Stack of fire calls for repeatable lists
  2612. stack = !options.once && [],
  2613. // Fire callbacks
  2614. fire = function( data ) {
  2615. memory = options.memory && data;
  2616. fired = true;
  2617. firingIndex = firingStart || 0;
  2618. firingStart = 0;
  2619. firingLength = list.length;
  2620. firing = true;
  2621. for ( ; list && firingIndex < firingLength; firingIndex++ ) {
  2622. if ( list[ firingIndex ].apply( data[ 0 ], data[ 1 ] ) === false && options.stopOnFalse ) {
  2623. memory = false; // To prevent further calls using add
  2624. break;
  2625. }
  2626. }
  2627. firing = false;
  2628. if ( list ) {
  2629. if ( stack ) {
  2630. if ( stack.length ) {
  2631. fire( stack.shift() );
  2632. }
  2633. } else if ( memory ) {
  2634. list = [];
  2635. } else {
  2636. self.disable();
  2637. }
  2638. }
  2639. },
  2640. // Actual Callbacks object
  2641. self = {
  2642. // Add a callback or a collection of callbacks to the list
  2643. add: function() {
  2644. if ( list ) {
  2645. // First, we save the current length
  2646. var start = list.length;
  2647. (function add( args ) {
  2648. jQuery.each( args, function( _, arg ) {
  2649. var type = jQuery.type( arg );
  2650. if ( type === "function" ) {
  2651. if ( !options.unique || !self.has( arg ) ) {
  2652. list.push( arg );
  2653. }
  2654. } else if ( arg && arg.length && type !== "string" ) {
  2655. // Inspect recursively
  2656. add( arg );
  2657. }
  2658. });
  2659. })( arguments );
  2660. // Do we need to add the callbacks to the
  2661. // current firing batch?
  2662. if ( firing ) {
  2663. firingLength = list.length;
  2664. // With memory, if we're not firing then
  2665. // we should call right away
  2666. } else if ( memory ) {
  2667. firingStart = start;
  2668. fire( memory );
  2669. }
  2670. }
  2671. return this;
  2672. },
  2673. // Remove a callback from the list
  2674. remove: function() {
  2675. if ( list ) {
  2676. jQuery.each( arguments, function( _, arg ) {
  2677. var index;
  2678. while ( ( index = jQuery.inArray( arg, list, index ) ) > -1 ) {
  2679. list.splice( index, 1 );
  2680. // Handle firing indexes
  2681. if ( firing ) {
  2682. if ( index <= firingLength ) {
  2683. firingLength--;
  2684. }
  2685. if ( index <= firingIndex ) {
  2686. firingIndex--;
  2687. }
  2688. }
  2689. }
  2690. });
  2691. }
  2692. return this;
  2693. },
  2694. // Check if a given callback is in the list.
  2695. // If no argument is given, return whether or not list has callbacks attached.
  2696. has: function( fn ) {
  2697. return fn ? jQuery.inArray( fn, list ) > -1 : !!( list && list.length );
  2698. },
  2699. // Remove all callbacks from the list
  2700. empty: function() {
  2701. list = [];
  2702. firingLength = 0;
  2703. return this;
  2704. },
  2705. // Have the list do nothing anymore
  2706. disable: function() {
  2707. list = stack = memory = undefined;
  2708. return this;
  2709. },
  2710. // Is it disabled?
  2711. disabled: function() {
  2712. return !list;
  2713. },
  2714. // Lock the list in its current state
  2715. lock: function() {
  2716. stack = undefined;
  2717. if ( !memory ) {
  2718. self.disable();
  2719. }
  2720. return this;
  2721. },
  2722. // Is it locked?
  2723. locked: function() {
  2724. return !stack;
  2725. },
  2726. // Call all callbacks with the given context and arguments
  2727. fireWith: function( context, args ) {
  2728. if ( list && ( !fired || stack ) ) {
  2729. args = args || [];
  2730. args = [ context, args.slice ? args.slice() : args ];
  2731. if ( firing ) {
  2732. stack.push( args );
  2733. } else {
  2734. fire( args );
  2735. }
  2736. }
  2737. return this;
  2738. },
  2739. // Call all the callbacks with the given arguments
  2740. fire: function() {
  2741. self.fireWith( this, arguments );
  2742. return this;
  2743. },
  2744. // To know if the callbacks have already been called at least once
  2745. fired: function() {
  2746. return !!fired;
  2747. }
  2748. };
  2749. return self;
  2750. };
  2751. jQuery.extend({
  2752. Deferred: function( func ) {
  2753. var tuples = [
  2754. // action, add listener, listener list, final state
  2755. [ "resolve", "done", jQuery.Callbacks("once memory"), "resolved" ],
  2756. [ "reject", "fail", jQuery.Callbacks("once memory"), "rejected" ],
  2757. [ "notify", "progress", jQuery.Callbacks("memory") ]
  2758. ],
  2759. state = "pending",
  2760. promise = {
  2761. state: function() {
  2762. return state;
  2763. },
  2764. always: function() {
  2765. deferred.done( arguments ).fail( arguments );
  2766. return this;
  2767. },
  2768. then: function( /* fnDone, fnFail, fnProgress */ ) {
  2769. var fns = arguments;
  2770. return jQuery.Deferred(function( newDefer ) {
  2771. jQuery.each( tuples, function( i, tuple ) {
  2772. var fn = jQuery.isFunction( fns[ i ] ) && fns[ i ];
  2773. // deferred[ done | fail | progress ] for forwarding actions to newDefer
  2774. deferred[ tuple[1] ](function() {
  2775. var returned = fn && fn.apply( this, arguments );
  2776. if ( returned && jQuery.isFunction( returned.promise ) ) {
  2777. returned.promise()
  2778. .done( newDefer.resolve )
  2779. .fail( newDefer.reject )
  2780. .progress( newDefer.notify );
  2781. } else {
  2782. newDefer[ tuple[ 0 ] + "With" ]( this === promise ? newDefer.promise() : this, fn ? [ returned ] : arguments );
  2783. }
  2784. });
  2785. });
  2786. fns = null;
  2787. }).promise();
  2788. },
  2789. // Get a promise for this deferred
  2790. // If obj is provided, the promise aspect is added to the object
  2791. promise: function( obj ) {
  2792. return obj != null ? jQuery.extend( obj, promise ) : promise;
  2793. }
  2794. },
  2795. deferred = {};
  2796. // Keep pipe for back-compat
  2797. promise.pipe = promise.then;
  2798. // Add list-specific methods
  2799. jQuery.each( tuples, function( i, tuple ) {
  2800. var list = tuple[ 2 ],
  2801. stateString = tuple[ 3 ];
  2802. // promise[ done | fail | progress ] = list.add
  2803. promise[ tuple[1] ] = list.add;
  2804. // Handle state
  2805. if ( stateString ) {
  2806. list.add(function() {
  2807. // state = [ resolved | rejected ]
  2808. state = stateString;
  2809. // [ reject_list | resolve_list ].disable; progress_list.lock
  2810. }, tuples[ i ^ 1 ][ 2 ].disable, tuples[ 2 ][ 2 ].lock );
  2811. }
  2812. // deferred[ resolve | reject | notify ]
  2813. deferred[ tuple[0] ] = function() {
  2814. deferred[ tuple[0] + "With" ]( this === deferred ? promise : this, arguments );
  2815. return this;
  2816. };
  2817. deferred[ tuple[0] + "With" ] = list.fireWith;
  2818. });
  2819. // Make the deferred a promise
  2820. promise.promise( deferred );
  2821. // Call given func if any
  2822. if ( func ) {
  2823. func.call( deferred, deferred );
  2824. }
  2825. // All done!
  2826. return deferred;
  2827. },
  2828. // Deferred helper
  2829. when: function( subordinate /* , ..., subordinateN */ ) {
  2830. var i = 0,
  2831. resolveValues = slice.call( arguments ),
  2832. length = resolveValues.length,
  2833. // the count of uncompleted subordinates
  2834. remaining = length !== 1 || ( subordinate && jQuery.isFunction( subordinate.promise ) ) ? length : 0,
  2835. // the master Deferred. If resolveValues consist of only a single Deferred, just use that.
  2836. deferred = remaining === 1 ? subordinate : jQuery.Deferred(),
  2837. // Update function for both resolve and progress values
  2838. updateFunc = function( i, contexts, values ) {
  2839. return function( value ) {
  2840. contexts[ i ] = this;
  2841. values[ i ] = arguments.length > 1 ? slice.call( arguments ) : value;
  2842. if ( values === progressValues ) {
  2843. deferred.notifyWith( contexts, values );
  2844. } else if ( !(--remaining) ) {
  2845. deferred.resolveWith( contexts, values );
  2846. }
  2847. };
  2848. },
  2849. progressValues, progressContexts, resolveContexts;
  2850. // add listeners to Deferred subordinates; treat others as resolved
  2851. if ( length > 1 ) {
  2852. progressValues = new Array( length );
  2853. progressContexts = new Array( length );
  2854. resolveContexts = new Array( length );
  2855. for ( ; i < length; i++ ) {
  2856. if ( resolveValues[ i ] && jQuery.isFunction( resolveValues[ i ].promise ) ) {
  2857. resolveValues[ i ].promise()
  2858. .done( updateFunc( i, resolveContexts, resolveValues ) )
  2859. .fail( deferred.reject )
  2860. .progress( updateFunc( i, progressContexts, progressValues ) );
  2861. } else {
  2862. --remaining;
  2863. }
  2864. }
  2865. }
  2866. // if we're not waiting on anything, resolve the master
  2867. if ( !remaining ) {
  2868. deferred.resolveWith( resolveContexts, resolveValues );
  2869. }
  2870. return deferred.promise();
  2871. }
  2872. });
  2873. // The deferred used on DOM ready
  2874. var readyList;
  2875. jQuery.fn.ready = function( fn ) {
  2876. // Add the callback
  2877. jQuery.ready.promise().done( fn );
  2878. return this;
  2879. };
  2880. jQuery.extend({
  2881. // Is the DOM ready to be used? Set to true once it occurs.
  2882. isReady: false,
  2883. // A counter to track how many items to wait for before
  2884. // the ready event fires. See #6781
  2885. readyWait: 1,
  2886. // Hold (or release) the ready event
  2887. holdReady: function( hold ) {
  2888. if ( hold ) {
  2889. jQuery.readyWait++;
  2890. } else {
  2891. jQuery.ready( true );
  2892. }
  2893. },
  2894. // Handle when the DOM is ready
  2895. ready: function( wait ) {
  2896. // Abort if there are pending holds or we're already ready
  2897. if ( wait === true ? --jQuery.readyWait : jQuery.isReady ) {
  2898. return;
  2899. }
  2900. // Make sure body exists, at least, in case IE gets a little overzealous (ticket #5443).
  2901. if ( !document.body ) {
  2902. return setTimeout( jQuery.ready );
  2903. }
  2904. // Remember that the DOM is ready
  2905. jQuery.isReady = true;
  2906. // If a normal DOM Ready event fired, decrement, and wait if need be
  2907. if ( wait !== true && --jQuery.readyWait > 0 ) {
  2908. return;
  2909. }
  2910. // If there are functions bound, to execute
  2911. readyList.resolveWith( document, [ jQuery ] );
  2912. // Trigger any bound ready events
  2913. if ( jQuery.fn.triggerHandler ) {
  2914. jQuery( document ).triggerHandler( "ready" );
  2915. jQuery( document ).off( "ready" );
  2916. }
  2917. }
  2918. });
  2919. /**
  2920. * Clean-up method for dom ready events
  2921. */
  2922. function detach() {
  2923. if ( document.addEventListener ) {
  2924. document.removeEventListener( "DOMContentLoaded", completed, false );
  2925. window.removeEventListener( "load", completed, false );
  2926. } else {
  2927. document.detachEvent( "onreadystatechange", completed );
  2928. window.detachEvent( "onload", completed );
  2929. }
  2930. }
  2931. /**
  2932. * The ready event handler and self cleanup method
  2933. */
  2934. function completed() {
  2935. // readyState === "complete" is good enough for us to call the dom ready in oldIE
  2936. if ( document.addEventListener || event.type === "load" || document.readyState === "complete" ) {
  2937. detach();
  2938. jQuery.ready();
  2939. }
  2940. }
  2941. jQuery.ready.promise = function( obj ) {
  2942. if ( !readyList ) {
  2943. readyList = jQuery.Deferred();
  2944. // Catch cases where $(document).ready() is called after the browser event has already occurred.
  2945. // we once tried to use readyState "interactive" here, but it caused issues like the one
  2946. // discovered by ChrisS here: http://bugs.jquery.com/ticket/12282#comment:15
  2947. if ( document.readyState === "complete" ) {
  2948. // Handle it asynchronously to allow scripts the opportunity to delay ready
  2949. setTimeout( jQuery.ready );
  2950. // Standards-based browsers support DOMContentLoaded
  2951. } else if ( document.addEventListener ) {
  2952. // Use the handy event callback
  2953. document.addEventListener( "DOMContentLoaded", completed, false );
  2954. // A fallback to window.onload, that will always work
  2955. window.addEventListener( "load", completed, false );
  2956. // If IE event model is used
  2957. } else {
  2958. // Ensure firing before onload, maybe late but safe also for iframes
  2959. document.attachEvent( "onreadystatechange", completed );
  2960. // A fallback to window.onload, that will always work
  2961. window.attachEvent( "onload", completed );
  2962. // If IE and not a frame
  2963. // continually check to see if the document is ready
  2964. var top = false;
  2965. try {
  2966. top = window.frameElement == null && document.documentElement;
  2967. } catch(e) {}
  2968. if ( top && top.doScroll ) {
  2969. (function doScrollCheck() {
  2970. if ( !jQuery.isReady ) {
  2971. try {
  2972. // Use the trick by Diego Perini
  2973. // http://javascript.nwbox.com/IEContentLoaded/
  2974. top.doScroll("left");
  2975. } catch(e) {
  2976. return setTimeout( doScrollCheck, 50 );
  2977. }
  2978. // detach all dom ready events
  2979. detach();
  2980. // and execute any waiting functions
  2981. jQuery.ready();
  2982. }
  2983. })();
  2984. }
  2985. }
  2986. }
  2987. return readyList.promise( obj );
  2988. };
  2989. var strundefined = typeof undefined;
  2990. // Support: IE<9
  2991. // Iteration over object's inherited properties before its own
  2992. var i;
  2993. for ( i in jQuery( support ) ) {
  2994. break;
  2995. }
  2996. support.ownLast = i !== "0";
  2997. // Note: most support tests are defined in their respective modules.
  2998. // false until the test is run
  2999. support.inlineBlockNeedsLayout = false;
  3000. // Execute ASAP in case we need to set body.style.zoom
  3001. jQuery(function() {
  3002. // Minified: var a,b,c,d
  3003. var val, div, body, container;
  3004. body = document.getElementsByTagName( "body" )[ 0 ];
  3005. if ( !body || !body.style ) {
  3006. // Return for frameset docs that don't have a body
  3007. return;
  3008. }
  3009. // Setup
  3010. div = document.createElement( "div" );
  3011. container = document.createElement( "div" );
  3012. container.style.cssText = "position:absolute;border:0;width:0;height:0;top:0;left:-9999px";
  3013. body.appendChild( container ).appendChild( div );
  3014. if ( typeof div.style.zoom !== strundefined ) {
  3015. // Support: IE<8
  3016. // Check if natively block-level elements act like inline-block
  3017. // elements when setting their display to 'inline' and giving
  3018. // them layout
  3019. div.style.cssText = "display:inline;margin:0;border:0;padding:1px;width:1px;zoom:1";
  3020. support.inlineBlockNeedsLayout = val = div.offsetWidth === 3;
  3021. if ( val ) {
  3022. // Prevent IE 6 from affecting layout for positioned elements #11048
  3023. // Prevent IE from shrinking the body in IE 7 mode #12869
  3024. // Support: IE<8
  3025. body.style.zoom = 1;
  3026. }
  3027. }
  3028. body.removeChild( container );
  3029. });
  3030. (function() {
  3031. var div = document.createElement( "div" );
  3032. // Execute the test only if not already executed in another module.
  3033. if (support.deleteExpando == null) {
  3034. // Support: IE<9
  3035. support.deleteExpando = true;
  3036. try {
  3037. delete div.test;
  3038. } catch( e ) {
  3039. support.deleteExpando = false;
  3040. }
  3041. }
  3042. // Null elements to avoid leaks in IE.
  3043. div = null;
  3044. })();
  3045. /**
  3046. * Determines whether an object can have data
  3047. */
  3048. jQuery.acceptData = function( elem ) {
  3049. var noData = jQuery.noData[ (elem.nodeName + " ").toLowerCase() ],
  3050. nodeType = +elem.nodeType || 1;
  3051. // Do not set data on non-element DOM nodes because it will not be cleared (#8335).
  3052. return nodeType !== 1 && nodeType !== 9 ?
  3053. false :
  3054. // Nodes accept data unless otherwise specified; rejection can be conditional
  3055. !noData || noData !== true && elem.getAttribute("classid") === noData;
  3056. };
  3057. var rbrace = /^(?:\{[\w\W]*\}|\[[\w\W]*\])$/,
  3058. rmultiDash = /([A-Z])/g;
  3059. function dataAttr( elem, key, data ) {
  3060. // If nothing was found internally, try to fetch any
  3061. // data from the HTML5 data-* attribute
  3062. if ( data === undefined && elem.nodeType === 1 ) {
  3063. var name = "data-" + key.replace( rmultiDash, "-$1" ).toLowerCase();
  3064. data = elem.getAttribute( name );
  3065. if ( typeof data === "string" ) {
  3066. try {
  3067. data = data === "true" ? true :
  3068. data === "false" ? false :
  3069. data === "null" ? null :
  3070. // Only convert to a number if it doesn't change the string
  3071. +data + "" === data ? +data :
  3072. rbrace.test( data ) ? jQuery.parseJSON( data ) :
  3073. data;
  3074. } catch( e ) {}
  3075. // Make sure we set the data so it isn't changed later
  3076. jQuery.data( elem, key, data );
  3077. } else {
  3078. data = undefined;
  3079. }
  3080. }
  3081. return data;
  3082. }
  3083. // checks a cache object for emptiness
  3084. function isEmptyDataObject( obj ) {
  3085. var name;
  3086. for ( name in obj ) {
  3087. // if the public data object is empty, the private is still empty
  3088. if ( name === "data" && jQuery.isEmptyObject( obj[name] ) ) {
  3089. continue;
  3090. }
  3091. if ( name !== "toJSON" ) {
  3092. return false;
  3093. }
  3094. }
  3095. return true;
  3096. }
  3097. function internalData( elem, name, data, pvt /* Internal Use Only */ ) {
  3098. if ( !jQuery.acceptData( elem ) ) {
  3099. return;
  3100. }
  3101. var ret, thisCache,
  3102. internalKey = jQuery.expando,
  3103. // We have to handle DOM nodes and JS objects differently because IE6-7
  3104. // can't GC object references properly across the DOM-JS boundary
  3105. isNode = elem.nodeType,
  3106. // Only DOM nodes need the global jQuery cache; JS object data is
  3107. // attached directly to the object so GC can occur automatically
  3108. cache = isNode ? jQuery.cache : elem,
  3109. // Only defining an ID for JS objects if its cache already exists allows
  3110. // the code to shortcut on the same path as a DOM node with no cache
  3111. id = isNode ? elem[ internalKey ] : elem[ internalKey ] && internalKey;
  3112. // Avoid doing any more work than we need to when trying to get data on an
  3113. // object that has no data at all
  3114. if ( (!id || !cache[id] || (!pvt && !cache[id].data)) && data === undefined && typeof name === "string" ) {
  3115. return;
  3116. }
  3117. if ( !id ) {
  3118. // Only DOM nodes need a new unique ID for each element since their data
  3119. // ends up in the global cache
  3120. if ( isNode ) {
  3121. id = elem[ internalKey ] = deletedIds.pop() || jQuery.guid++;
  3122. } else {
  3123. id = internalKey;
  3124. }
  3125. }
  3126. if ( !cache[ id ] ) {
  3127. // Avoid exposing jQuery metadata on plain JS objects when the object
  3128. // is serialized using JSON.stringify
  3129. cache[ id ] = isNode ? {} : { toJSON: jQuery.noop };
  3130. }
  3131. // An object can be passed to jQuery.data instead of a key/value pair; this gets
  3132. // shallow copied over onto the existing cache
  3133. if ( typeof name === "object" || typeof name === "function" ) {
  3134. if ( pvt ) {
  3135. cache[ id ] = jQuery.extend( cache[ id ], name );
  3136. } else {
  3137. cache[ id ].data = jQuery.extend( cache[ id ].data, name );
  3138. }
  3139. }
  3140. thisCache = cache[ id ];
  3141. // jQuery data() is stored in a separate object inside the object's internal data
  3142. // cache in order to avoid key collisions between internal data and user-defined
  3143. // data.
  3144. if ( !pvt ) {
  3145. if ( !thisCache.data ) {
  3146. thisCache.data = {};
  3147. }
  3148. thisCache = thisCache.data;
  3149. }
  3150. if ( data !== undefined ) {
  3151. thisCache[ jQuery.camelCase( name ) ] = data;
  3152. }
  3153. // Check for both converted-to-camel and non-converted data property names
  3154. // If a data property was specified
  3155. if ( typeof name === "string" ) {
  3156. // First Try to find as-is property data
  3157. ret = thisCache[ name ];
  3158. // Test for null|undefined property data
  3159. if ( ret == null ) {
  3160. // Try to find the camelCased property
  3161. ret = thisCache[ jQuery.camelCase( name ) ];
  3162. }
  3163. } else {
  3164. ret = thisCache;
  3165. }
  3166. return ret;
  3167. }
  3168. function internalRemoveData( elem, name, pvt ) {
  3169. if ( !jQuery.acceptData( elem ) ) {
  3170. return;
  3171. }
  3172. var thisCache, i,
  3173. isNode = elem.nodeType,
  3174. // See jQuery.data for more information
  3175. cache = isNode ? jQuery.cache : elem,
  3176. id = isNode ? elem[ jQuery.expando ] : jQuery.expando;
  3177. // If there is already no cache entry for this object, there is no
  3178. // purpose in continuing
  3179. if ( !cache[ id ] ) {
  3180. return;
  3181. }
  3182. if ( name ) {
  3183. thisCache = pvt ? cache[ id ] : cache[ id ].data;
  3184. if ( thisCache ) {
  3185. // Support array or space separated string names for data keys
  3186. if ( !jQuery.isArray( name ) ) {
  3187. // try the string as a key before any manipulation
  3188. if ( name in thisCache ) {
  3189. name = [ name ];
  3190. } else {
  3191. // split the camel cased version by spaces unless a key with the spaces exists
  3192. name = jQuery.camelCase( name );
  3193. if ( name in thisCache ) {
  3194. name = [ name ];
  3195. } else {
  3196. name = name.split(" ");
  3197. }
  3198. }
  3199. } else {
  3200. // If "name" is an array of keys...
  3201. // When data is initially created, via ("key", "val") signature,
  3202. // keys will be converted to camelCase.
  3203. // Since there is no way to tell _how_ a key was added, remove
  3204. // both plain key and camelCase key. #12786
  3205. // This will only penalize the array argument path.
  3206. name = name.concat( jQuery.map( name, jQuery.camelCase ) );
  3207. }
  3208. i = name.length;
  3209. while ( i-- ) {
  3210. delete thisCache[ name[i] ];
  3211. }
  3212. // If there is no data left in the cache, we want to continue
  3213. // and let the cache object itself get destroyed
  3214. if ( pvt ? !isEmptyDataObject(thisCache) : !jQuery.isEmptyObject(thisCache) ) {
  3215. return;
  3216. }
  3217. }
  3218. }
  3219. // See jQuery.data for more information
  3220. if ( !pvt ) {
  3221. delete cache[ id ].data;
  3222. // Don't destroy the parent cache unless the internal data object
  3223. // had been the only thing left in it
  3224. if ( !isEmptyDataObject( cache[ id ] ) ) {
  3225. return;
  3226. }
  3227. }
  3228. // Destroy the cache
  3229. if ( isNode ) {
  3230. jQuery.cleanData( [ elem ], true );
  3231. // Use delete when supported for expandos or `cache` is not a window per isWindow (#10080)
  3232. /* jshint eqeqeq: false */
  3233. } else if ( support.deleteExpando || cache != cache.window ) {
  3234. /* jshint eqeqeq: true */
  3235. delete cache[ id ];
  3236. // When all else fails, null
  3237. } else {
  3238. cache[ id ] = null;
  3239. }
  3240. }
  3241. jQuery.extend({
  3242. cache: {},
  3243. // The following elements (space-suffixed to avoid Object.prototype collisions)
  3244. // throw uncatchable exceptions if you attempt to set expando properties
  3245. noData: {
  3246. "applet ": true,
  3247. "embed ": true,
  3248. // ...but Flash objects (which have this classid) *can* handle expandos
  3249. "object ": "clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
  3250. },
  3251. hasData: function( elem ) {
  3252. elem = elem.nodeType ? jQuery.cache[ elem[jQuery.expando] ] : elem[ jQuery.expando ];
  3253. return !!elem && !isEmptyDataObject( elem );
  3254. },
  3255. data: function( elem, name, data ) {
  3256. return internalData( elem, name, data );
  3257. },
  3258. removeData: function( elem, name ) {
  3259. return internalRemoveData( elem, name );
  3260. },
  3261. // For internal use only.
  3262. _data: function( elem, name, data ) {
  3263. return internalData( elem, name, data, true );
  3264. },
  3265. _removeData: function( elem, name ) {
  3266. return internalRemoveData( elem, name, true );
  3267. }
  3268. });
  3269. jQuery.fn.extend({
  3270. data: function( key, value ) {
  3271. var i, name, data,
  3272. elem = this[0],
  3273. attrs = elem && elem.attributes;
  3274. // Special expections of .data basically thwart jQuery.access,
  3275. // so implement the relevant behavior ourselves
  3276. // Gets all values
  3277. if ( key === undefined ) {
  3278. if ( this.length ) {
  3279. data = jQuery.data( elem );
  3280. if ( elem.nodeType === 1 && !jQuery._data( elem, "parsedAttrs" ) ) {
  3281. i = attrs.length;
  3282. while ( i-- ) {
  3283. // Support: IE11+
  3284. // The attrs elements can be null (#14894)
  3285. if ( attrs[ i ] ) {
  3286. name = attrs[ i ].name;
  3287. if ( name.indexOf( "data-" ) === 0 ) {
  3288. name = jQuery.camelCase( name.slice(5) );
  3289. dataAttr( elem, name, data[ name ] );
  3290. }
  3291. }
  3292. }
  3293. jQuery._data( elem, "parsedAttrs", true );
  3294. }
  3295. }
  3296. return data;
  3297. }
  3298. // Sets multiple values
  3299. if ( typeof key === "object" ) {
  3300. return this.each(function() {
  3301. jQuery.data( this, key );
  3302. });
  3303. }
  3304. return arguments.length > 1 ?
  3305. // Sets one value
  3306. this.each(function() {
  3307. jQuery.data( this, key, value );
  3308. }) :
  3309. // Gets one value
  3310. // Try to fetch any internally stored data first
  3311. elem ? dataAttr( elem, key, jQuery.data( elem, key ) ) : undefined;
  3312. },
  3313. removeData: function( key ) {
  3314. return this.each(function() {
  3315. jQuery.removeData( this, key );
  3316. });
  3317. }
  3318. });
  3319. jQuery.extend({
  3320. queue: function( elem, type, data ) {
  3321. var queue;
  3322. if ( elem ) {
  3323. type = ( type || "fx" ) + "queue";
  3324. queue = jQuery._data( elem, type );
  3325. // Speed up dequeue by getting out quickly if this is just a lookup
  3326. if ( data ) {
  3327. if ( !queue || jQuery.isArray(data) ) {
  3328. queue = jQuery._data( elem, type, jQuery.makeArray(data) );
  3329. } else {
  3330. queue.push( data );
  3331. }
  3332. }
  3333. return queue || [];
  3334. }
  3335. },
  3336. dequeue: function( elem, type ) {
  3337. type = type || "fx";
  3338. var queue = jQuery.queue( elem, type ),
  3339. startLength = queue.length,
  3340. fn = queue.shift(),
  3341. hooks = jQuery._queueHooks( elem, type ),
  3342. next = function() {
  3343. jQuery.dequeue( elem, type );
  3344. };
  3345. // If the fx queue is dequeued, always remove the progress sentinel
  3346. if ( fn === "inprogress" ) {
  3347. fn = queue.shift();
  3348. startLength--;
  3349. }
  3350. if ( fn ) {
  3351. // Add a progress sentinel to prevent the fx queue from being
  3352. // automatically dequeued
  3353. if ( type === "fx" ) {
  3354. queue.unshift( "inprogress" );
  3355. }
  3356. // clear up the last queue stop function
  3357. delete hooks.stop;
  3358. fn.call( elem, next, hooks );
  3359. }
  3360. if ( !startLength && hooks ) {
  3361. hooks.empty.fire();
  3362. }
  3363. },
  3364. // not intended for public consumption - generates a queueHooks object, or returns the current one
  3365. _queueHooks: function( elem, type ) {
  3366. var key = type + "queueHooks";
  3367. return jQuery._data( elem, key ) || jQuery._data( elem, key, {
  3368. empty: jQuery.Callbacks("once memory").add(function() {
  3369. jQuery._removeData( elem, type + "queue" );
  3370. jQuery._removeData( elem, key );
  3371. })
  3372. });
  3373. }
  3374. });
  3375. jQuery.fn.extend({
  3376. queue: function( type, data ) {
  3377. var setter = 2;
  3378. if ( typeof type !== "string" ) {
  3379. data = type;
  3380. type = "fx";
  3381. setter--;
  3382. }
  3383. if ( arguments.length < setter ) {
  3384. return jQuery.queue( this[0], type );
  3385. }
  3386. return data === undefined ?
  3387. this :
  3388. this.each(function() {
  3389. var queue = jQuery.queue( this, type, data );
  3390. // ensure a hooks for this queue
  3391. jQuery._queueHooks( this, type );
  3392. if ( type === "fx" && queue[0] !== "inprogress" ) {
  3393. jQuery.dequeue( this, type );
  3394. }
  3395. });
  3396. },
  3397. dequeue: function( type ) {
  3398. return this.each(function() {
  3399. jQuery.dequeue( this, type );
  3400. });
  3401. },
  3402. clearQueue: function( type ) {
  3403. return this.queue( type || "fx", [] );
  3404. },
  3405. // Get a promise resolved when queues of a certain type
  3406. // are emptied (fx is the type by default)
  3407. promise: function( type, obj ) {
  3408. var tmp,
  3409. count = 1,
  3410. defer = jQuery.Deferred(),
  3411. elements = this,
  3412. i = this.length,
  3413. resolve = function() {
  3414. if ( !( --count ) ) {
  3415. defer.resolveWith( elements, [ elements ] );
  3416. }
  3417. };
  3418. if ( typeof type !== "string" ) {
  3419. obj = type;
  3420. type = undefined;
  3421. }
  3422. type = type || "fx";
  3423. while ( i-- ) {
  3424. tmp = jQuery._data( elements[ i ], type + "queueHooks" );
  3425. if ( tmp && tmp.empty ) {
  3426. count++;
  3427. tmp.empty.add( resolve );
  3428. }
  3429. }
  3430. resolve();
  3431. return defer.promise( obj );
  3432. }
  3433. });
  3434. var pnum = (/[+-]?(?:\d*\.|)\d+(?:[eE][+-]?\d+|)/).source;
  3435. var cssExpand = [ "Top", "Right", "Bottom", "Left" ];
  3436. var isHidden = function( elem, el ) {
  3437. // isHidden might be called from jQuery#filter function;
  3438. // in that case, element will be second argument
  3439. elem = el || elem;
  3440. return jQuery.css( elem, "display" ) === "none" || !jQuery.contains( elem.ownerDocument, elem );
  3441. };
  3442. // Multifunctional method to get and set values of a collection
  3443. // The value/s can optionally be executed if it's a function
  3444. var access = jQuery.access = function( elems, fn, key, value, chainable, emptyGet, raw ) {
  3445. var i = 0,
  3446. length = elems.length,
  3447. bulk = key == null;
  3448. // Sets many values
  3449. if ( jQuery.type( key ) === "object" ) {
  3450. chainable = true;
  3451. for ( i in key ) {
  3452. jQuery.access( elems, fn, i, key[i], true, emptyGet, raw );
  3453. }
  3454. // Sets one value
  3455. } else if ( value !== undefined ) {
  3456. chainable = true;
  3457. if ( !jQuery.isFunction( value ) ) {
  3458. raw = true;
  3459. }
  3460. if ( bulk ) {
  3461. // Bulk operations run against the entire set
  3462. if ( raw ) {
  3463. fn.call( elems, value );
  3464. fn = null;
  3465. // ...except when executing function values
  3466. } else {
  3467. bulk = fn;
  3468. fn = function( elem, key, value ) {
  3469. return bulk.call( jQuery( elem ), value );
  3470. };
  3471. }
  3472. }
  3473. if ( fn ) {
  3474. for ( ; i < length; i++ ) {
  3475. fn( elems[i], key, raw ? value : value.call( elems[i], i, fn( elems[i], key ) ) );
  3476. }
  3477. }
  3478. }
  3479. return chainable ?
  3480. elems :
  3481. // Gets
  3482. bulk ?
  3483. fn.call( elems ) :
  3484. length ? fn( elems[0], key ) : emptyGet;
  3485. };
  3486. var rcheckableType = (/^(?:checkbox|radio)$/i);
  3487. (function() {
  3488. // Minified: var a,b,c
  3489. var input = document.createElement( "input" ),
  3490. div = document.createElement( "div" ),
  3491. fragment = document.createDocumentFragment();
  3492. // Setup
  3493. div.innerHTML = " <link/><table></table><a href='/a'>a</a><input type='checkbox'/>";
  3494. // IE strips leading whitespace when .innerHTML is used
  3495. support.leadingWhitespace = div.firstChild.nodeType === 3;
  3496. // Make sure that tbody elements aren't automatically inserted
  3497. // IE will insert them into empty tables
  3498. support.tbody = !div.getElementsByTagName( "tbody" ).length;
  3499. // Make sure that link elements get serialized correctly by innerHTML
  3500. // This requires a wrapper element in IE
  3501. support.htmlSerialize = !!div.getElementsByTagName( "link" ).length;
  3502. // Makes sure cloning an html5 element does not cause problems
  3503. // Where outerHTML is undefined, this still works
  3504. support.html5Clone =
  3505. document.createElement( "nav" ).cloneNode( true ).outerHTML !== "<:nav></:nav>";
  3506. // Check if a disconnected checkbox will retain its checked
  3507. // value of true after appended to the DOM (IE6/7)
  3508. input.type = "checkbox";
  3509. input.checked = true;
  3510. fragment.appendChild( input );
  3511. support.appendChecked = input.checked;
  3512. // Make sure textarea (and checkbox) defaultValue is properly cloned
  3513. // Support: IE6-IE11+
  3514. div.innerHTML = "<textarea>x</textarea>";
  3515. support.noCloneChecked = !!div.cloneNode( true ).lastChild.defaultValue;
  3516. // #11217 - WebKit loses check when the name is after the checked attribute
  3517. fragment.appendChild( div );
  3518. div.innerHTML = "<input type='radio' checked='checked' name='t'/>";
  3519. // Support: Safari 5.1, iOS 5.1, Android 4.x, Android 2.3
  3520. // old WebKit doesn't clone checked state correctly in fragments
  3521. support.checkClone = div.cloneNode( true ).cloneNode( true ).lastChild.checked;
  3522. // Support: IE<9
  3523. // Opera does not clone events (and typeof div.attachEvent === undefined).
  3524. // IE9-10 clones events bound via attachEvent, but they don't trigger with .click()
  3525. support.noCloneEvent = true;
  3526. if ( div.attachEvent ) {
  3527. div.attachEvent( "onclick", function() {
  3528. support.noCloneEvent = false;
  3529. });
  3530. div.cloneNode( true ).click();
  3531. }
  3532. // Execute the test only if not already executed in another module.
  3533. if (support.deleteExpando == null) {
  3534. // Support: IE<9
  3535. support.deleteExpando = true;
  3536. try {
  3537. delete div.test;
  3538. } catch( e ) {
  3539. support.deleteExpando = false;
  3540. }
  3541. }
  3542. })();
  3543. (function() {
  3544. var i, eventName,
  3545. div = document.createElement( "div" );
  3546. // Support: IE<9 (lack submit/change bubble), Firefox 23+ (lack focusin event)
  3547. for ( i in { submit: true, change: true, focusin: true }) {
  3548. eventName = "on" + i;
  3549. if ( !(support[ i + "Bubbles" ] = eventName in window) ) {
  3550. // Beware of CSP restrictions (https://developer.mozilla.org/en/Security/CSP)
  3551. div.setAttribute( eventName, "t" );
  3552. support[ i + "Bubbles" ] = div.attributes[ eventName ].expando === false;
  3553. }
  3554. }
  3555. // Null elements to avoid leaks in IE.
  3556. div = null;
  3557. })();
  3558. var rformElems = /^(?:input|select|textarea)$/i,
  3559. rkeyEvent = /^key/,
  3560. rmouseEvent = /^(?:mouse|pointer|contextmenu)|click/,
  3561. rfocusMorph = /^(?:focusinfocus|focusoutblur)$/,
  3562. rtypenamespace = /^([^.]*)(?:\.(.+)|)$/;
  3563. function returnTrue() {
  3564. return true;
  3565. }
  3566. function returnFalse() {
  3567. return false;
  3568. }
  3569. function safeActiveElement() {
  3570. try {
  3571. return document.activeElement;
  3572. } catch ( err ) { }
  3573. }
  3574. /*
  3575. * Helper functions for managing events -- not part of the public interface.
  3576. * Props to Dean Edwards' addEvent library for many of the ideas.
  3577. */
  3578. jQuery.event = {
  3579. global: {},
  3580. add: function( elem, types, handler, data, selector ) {
  3581. var tmp, events, t, handleObjIn,
  3582. special, eventHandle, handleObj,
  3583. handlers, type, namespaces, origType,
  3584. elemData = jQuery._data( elem );
  3585. // Don't attach events to noData or text/comment nodes (but allow plain objects)
  3586. if ( !elemData ) {
  3587. return;
  3588. }
  3589. // Caller can pass in an object of custom data in lieu of the handler
  3590. if ( handler.handler ) {
  3591. handleObjIn = handler;
  3592. handler = handleObjIn.handler;
  3593. selector = handleObjIn.selector;
  3594. }
  3595. // Make sure that the handler has a unique ID, used to find/remove it later
  3596. if ( !handler.guid ) {
  3597. handler.guid = jQuery.guid++;
  3598. }
  3599. // Init the element's event structure and main handler, if this is the first
  3600. if ( !(events = elemData.events) ) {
  3601. events = elemData.events = {};
  3602. }
  3603. if ( !(eventHandle = elemData.handle) ) {
  3604. eventHandle = elemData.handle = function( e ) {
  3605. // Discard the second event of a jQuery.event.trigger() and
  3606. // when an event is called after a page has unloaded
  3607. return typeof jQuery !== strundefined && (!e || jQuery.event.triggered !== e.type) ?
  3608. jQuery.event.dispatch.apply( eventHandle.elem, arguments ) :
  3609. undefined;
  3610. };
  3611. // Add elem as a property of the handle fn to prevent a memory leak with IE non-native events
  3612. eventHandle.elem = elem;
  3613. }
  3614. // Handle multiple events separated by a space
  3615. types = ( types || "" ).match( rnotwhite ) || [ "" ];
  3616. t = types.length;
  3617. while ( t-- ) {
  3618. tmp = rtypenamespace.exec( types[t] ) || [];
  3619. type = origType = tmp[1];
  3620. namespaces = ( tmp[2] || "" ).split( "." ).sort();
  3621. // There *must* be a type, no attaching namespace-only handlers
  3622. if ( !type ) {
  3623. continue;
  3624. }
  3625. // If event changes its type, use the special event handlers for the changed type
  3626. special = jQuery.event.special[ type ] || {};
  3627. // If selector defined, determine special event api type, otherwise given type
  3628. type = ( selector ? special.delegateType : special.bindType ) || type;
  3629. // Update special based on newly reset type
  3630. special = jQuery.event.special[ type ] || {};
  3631. // handleObj is passed to all event handlers
  3632. handleObj = jQuery.extend({
  3633. type: type,
  3634. origType: origType,
  3635. data: data,
  3636. handler: handler,
  3637. guid: handler.guid,
  3638. selector: selector,
  3639. needsContext: selector && jQuery.expr.match.needsContext.test( selector ),
  3640. namespace: namespaces.join(".")
  3641. }, handleObjIn );
  3642. // Init the event handler queue if we're the first
  3643. if ( !(handlers = events[ type ]) ) {
  3644. handlers = events[ type ] = [];
  3645. handlers.delegateCount = 0;
  3646. // Only use addEventListener/attachEvent if the special events handler returns false
  3647. if ( !special.setup || special.setup.call( elem, data, namespaces, eventHandle ) === false ) {
  3648. // Bind the global event handler to the element
  3649. if ( elem.addEventListener ) {
  3650. elem.addEventListener( type, eventHandle, false );
  3651. } else if ( elem.attachEvent ) {
  3652. elem.attachEvent( "on" + type, eventHandle );
  3653. }
  3654. }
  3655. }
  3656. if ( special.add ) {
  3657. special.add.call( elem, handleObj );
  3658. if ( !handleObj.handler.guid ) {
  3659. handleObj.handler.guid = handler.guid;
  3660. }
  3661. }
  3662. // Add to the element's handler list, delegates in front
  3663. if ( selector ) {
  3664. handlers.splice( handlers.delegateCount++, 0, handleObj );
  3665. } else {
  3666. handlers.push( handleObj );
  3667. }
  3668. // Keep track of which events have ever been used, for event optimization
  3669. jQuery.event.global[ type ] = true;
  3670. }
  3671. // Nullify elem to prevent memory leaks in IE
  3672. elem = null;
  3673. },
  3674. // Detach an event or set of events from an element
  3675. remove: function( elem, types, handler, selector, mappedTypes ) {
  3676. var j, handleObj, tmp,
  3677. origCount, t, events,
  3678. special, handlers, type,
  3679. namespaces, origType,
  3680. elemData = jQuery.hasData( elem ) && jQuery._data( elem );
  3681. if ( !elemData || !(events = elemData.events) ) {
  3682. return;
  3683. }
  3684. // Once for each type.namespace in types; type may be omitted
  3685. types = ( types || "" ).match( rnotwhite ) || [ "" ];
  3686. t = types.length;
  3687. while ( t-- ) {
  3688. tmp = rtypenamespace.exec( types[t] ) || [];
  3689. type = origType = tmp[1];
  3690. namespaces = ( tmp[2] || "" ).split( "." ).sort();
  3691. // Unbind all events (on this namespace, if provided) for the element
  3692. if ( !type ) {
  3693. for ( type in events ) {
  3694. jQuery.event.remove( elem, type + types[ t ], handler, selector, true );
  3695. }
  3696. continue;
  3697. }
  3698. special = jQuery.event.special[ type ] || {};
  3699. type = ( selector ? special.delegateType : special.bindType ) || type;
  3700. handlers = events[ type ] || [];
  3701. tmp = tmp[2] && new RegExp( "(^|\\.)" + namespaces.join("\\.(?:.*\\.|)") + "(\\.|$)" );
  3702. // Remove matching events
  3703. origCount = j = handlers.length;
  3704. while ( j-- ) {
  3705. handleObj = handlers[ j ];
  3706. if ( ( mappedTypes || origType === handleObj.origType ) &&
  3707. ( !handler || handler.guid === handleObj.guid ) &&
  3708. ( !tmp || tmp.test( handleObj.namespace ) ) &&
  3709. ( !selector || selector === handleObj.selector || selector === "**" && handleObj.selector ) ) {
  3710. handlers.splice( j, 1 );
  3711. if ( handleObj.selector ) {
  3712. handlers.delegateCount--;
  3713. }
  3714. if ( special.remove ) {
  3715. special.remove.call( elem, handleObj );
  3716. }
  3717. }
  3718. }
  3719. // Remove generic event handler if we removed something and no more handlers exist
  3720. // (avoids potential for endless recursion during removal of special event handlers)
  3721. if ( origCount && !handlers.length ) {
  3722. if ( !special.teardown || special.teardown.call( elem, namespaces, elemData.handle ) === false ) {
  3723. jQuery.removeEvent( elem, type, elemData.handle );
  3724. }
  3725. delete events[ type ];
  3726. }
  3727. }
  3728. // Remove the expando if it's no longer used
  3729. if ( jQuery.isEmptyObject( events ) ) {
  3730. delete elemData.handle;
  3731. // removeData also checks for emptiness and clears the expando if empty
  3732. // so use it instead of delete
  3733. jQuery._removeData( elem, "events" );
  3734. }
  3735. },
  3736. trigger: function( event, data, elem, onlyHandlers ) {
  3737. var handle, ontype, cur,
  3738. bubbleType, special, tmp, i,
  3739. eventPath = [ elem || document ],
  3740. type = hasOwn.call( event, "type" ) ? event.type : event,
  3741. namespaces = hasOwn.call( event, "namespace" ) ? event.namespace.split(".") : [];
  3742. cur = tmp = elem = elem || document;
  3743. // Don't do events on text and comment nodes
  3744. if ( elem.nodeType === 3 || elem.nodeType === 8 ) {
  3745. return;
  3746. }
  3747. // focus/blur morphs to focusin/out; ensure we're not firing them right now
  3748. if ( rfocusMorph.test( type + jQuery.event.triggered ) ) {
  3749. return;
  3750. }
  3751. if ( type.indexOf(".") >= 0 ) {
  3752. // Namespaced trigger; create a regexp to match event type in handle()
  3753. namespaces = type.split(".");
  3754. type = namespaces.shift();
  3755. namespaces.sort();
  3756. }
  3757. ontype = type.indexOf(":") < 0 && "on" + type;
  3758. // Caller can pass in a jQuery.Event object, Object, or just an event type string
  3759. event = event[ jQuery.expando ] ?
  3760. event :
  3761. new jQuery.Event( type, typeof event === "object" && event );
  3762. // Trigger bitmask: & 1 for native handlers; & 2 for jQuery (always true)
  3763. event.isTrigger = onlyHandlers ? 2 : 3;
  3764. event.namespace = namespaces.join(".");
  3765. event.namespace_re = event.namespace ?
  3766. new RegExp( "(^|\\.)" + namespaces.join("\\.(?:.*\\.|)") + "(\\.|$)" ) :
  3767. null;
  3768. // Clean up the event in case it is being reused
  3769. event.result = undefined;
  3770. if ( !event.target ) {
  3771. event.target = elem;
  3772. }
  3773. // Clone any incoming data and prepend the event, creating the handler arg list
  3774. data = data == null ?
  3775. [ event ] :
  3776. jQuery.makeArray( data, [ event ] );
  3777. // Allow special events to draw outside the lines
  3778. special = jQuery.event.special[ type ] || {};
  3779. if ( !onlyHandlers && special.trigger && special.trigger.apply( elem, data ) === false ) {
  3780. return;
  3781. }
  3782. // Determine event propagation path in advance, per W3C events spec (#9951)
  3783. // Bubble up to document, then to window; watch for a global ownerDocument var (#9724)
  3784. if ( !onlyHandlers && !special.noBubble && !jQuery.isWindow( elem ) ) {
  3785. bubbleType = special.delegateType || type;
  3786. if ( !rfocusMorph.test( bubbleType + type ) ) {
  3787. cur = cur.parentNode;
  3788. }
  3789. for ( ; cur; cur = cur.parentNode ) {
  3790. eventPath.push( cur );
  3791. tmp = cur;
  3792. }
  3793. // Only add window if we got to document (e.g., not plain obj or detached DOM)
  3794. if ( tmp === (elem.ownerDocument || document) ) {
  3795. eventPath.push( tmp.defaultView || tmp.parentWindow || window );
  3796. }
  3797. }
  3798. // Fire handlers on the event path
  3799. i = 0;
  3800. while ( (cur = eventPath[i++]) && !event.isPropagationStopped() ) {
  3801. event.type = i > 1 ?
  3802. bubbleType :
  3803. special.bindType || type;
  3804. // jQuery handler
  3805. handle = ( jQuery._data( cur, "events" ) || {} )[ event.type ] && jQuery._data( cur, "handle" );
  3806. if ( handle ) {
  3807. handle.apply( cur, data );
  3808. }
  3809. // Native handler
  3810. handle = ontype && cur[ ontype ];
  3811. if ( handle && handle.apply && jQuery.acceptData( cur ) ) {
  3812. event.result = handle.apply( cur, data );
  3813. if ( event.result === false ) {
  3814. event.preventDefault();
  3815. }
  3816. }
  3817. }
  3818. event.type = type;
  3819. // If nobody prevented the default action, do it now
  3820. if ( !onlyHandlers && !event.isDefaultPrevented() ) {
  3821. if ( (!special._default || special._default.apply( eventPath.pop(), data ) === false) &&
  3822. jQuery.acceptData( elem ) ) {
  3823. // Call a native DOM method on the target with the same name name as the event.
  3824. // Can't use an .isFunction() check here because IE6/7 fails that test.
  3825. // Don't do default actions on window, that's where global variables be (#6170)
  3826. if ( ontype && elem[ type ] && !jQuery.isWindow( elem ) ) {
  3827. // Don't re-trigger an onFOO event when we call its FOO() method
  3828. tmp = elem[ ontype ];
  3829. if ( tmp ) {
  3830. elem[ ontype ] = null;
  3831. }
  3832. // Prevent re-triggering of the same event, since we already bubbled it above
  3833. jQuery.event.triggered = type;
  3834. try {
  3835. elem[ type ]();
  3836. } catch ( e ) {
  3837. // IE<9 dies on focus/blur to hidden element (#1486,#12518)
  3838. // only reproducible on winXP IE8 native, not IE9 in IE8 mode
  3839. }
  3840. jQuery.event.triggered = undefined;
  3841. if ( tmp ) {
  3842. elem[ ontype ] = tmp;
  3843. }
  3844. }
  3845. }
  3846. }
  3847. return event.result;
  3848. },
  3849. dispatch: function( event ) {
  3850. // Make a writable jQuery.Event from the native event object
  3851. event = jQuery.event.fix( event );
  3852. var i, ret, handleObj, matched, j,
  3853. handlerQueue = [],
  3854. args = slice.call( arguments ),
  3855. handlers = ( jQuery._data( this, "events" ) || {} )[ event.type ] || [],
  3856. special = jQuery.event.special[ event.type ] || {};
  3857. // Use the fix-ed jQuery.Event rather than the (read-only) native event
  3858. args[0] = event;
  3859. event.delegateTarget = this;
  3860. // Call the preDispatch hook for the mapped type, and let it bail if desired
  3861. if ( special.preDispatch && special.preDispatch.call( this, event ) === false ) {
  3862. return;
  3863. }
  3864. // Determine handlers
  3865. handlerQueue = jQuery.event.handlers.call( this, event, handlers );
  3866. // Run delegates first; they may want to stop propagation beneath us
  3867. i = 0;
  3868. while ( (matched = handlerQueue[ i++ ]) && !event.isPropagationStopped() ) {
  3869. event.currentTarget = matched.elem;
  3870. j = 0;
  3871. while ( (handleObj = matched.handlers[ j++ ]) && !event.isImmediatePropagationStopped() ) {
  3872. // Triggered event must either 1) have no namespace, or
  3873. // 2) have namespace(s) a subset or equal to those in the bound event (both can have no namespace).
  3874. if ( !event.namespace_re || event.namespace_re.test( handleObj.namespace ) ) {
  3875. event.handleObj = handleObj;
  3876. event.data = handleObj.data;
  3877. ret = ( (jQuery.event.special[ handleObj.origType ] || {}).handle || handleObj.handler )
  3878. .apply( matched.elem, args );
  3879. if ( ret !== undefined ) {
  3880. if ( (event.result = ret) === false ) {
  3881. event.preventDefault();
  3882. event.stopPropagation();
  3883. }
  3884. }
  3885. }
  3886. }
  3887. }
  3888. // Call the postDispatch hook for the mapped type
  3889. if ( special.postDispatch ) {
  3890. special.postDispatch.call( this, event );
  3891. }
  3892. return event.result;
  3893. },
  3894. handlers: function( event, handlers ) {
  3895. var sel, handleObj, matches, i,
  3896. handlerQueue = [],
  3897. delegateCount = handlers.delegateCount,
  3898. cur = event.target;
  3899. // Find delegate handlers
  3900. // Black-hole SVG <use> instance trees (#13180)
  3901. // Avoid non-left-click bubbling in Firefox (#3861)
  3902. if ( delegateCount && cur.nodeType && (!event.button || event.type !== "click") ) {
  3903. /* jshint eqeqeq: false */
  3904. for ( ; cur != this; cur = cur.parentNode || this ) {
  3905. /* jshint eqeqeq: true */
  3906. // Don't check non-elements (#13208)
  3907. // Don't process clicks on disabled elements (#6911, #8165, #11382, #11764)
  3908. if ( cur.nodeType === 1 && (cur.disabled !== true || event.type !== "click") ) {
  3909. matches = [];
  3910. for ( i = 0; i < delegateCount; i++ ) {
  3911. handleObj = handlers[ i ];
  3912. // Don't conflict with Object.prototype properties (#13203)
  3913. sel = handleObj.selector + " ";
  3914. if ( matches[ sel ] === undefined ) {
  3915. matches[ sel ] = handleObj.needsContext ?
  3916. jQuery( sel, this ).index( cur ) >= 0 :
  3917. jQuery.find( sel, this, null, [ cur ] ).length;
  3918. }
  3919. if ( matches[ sel ] ) {
  3920. matches.push( handleObj );
  3921. }
  3922. }
  3923. if ( matches.length ) {
  3924. handlerQueue.push({ elem: cur, handlers: matches });
  3925. }
  3926. }
  3927. }
  3928. }
  3929. // Add the remaining (directly-bound) handlers
  3930. if ( delegateCount < handlers.length ) {
  3931. handlerQueue.push({ elem: this, handlers: handlers.slice( delegateCount ) });
  3932. }
  3933. return handlerQueue;
  3934. },
  3935. fix: function( event ) {
  3936. if ( event[ jQuery.expando ] ) {
  3937. return event;
  3938. }
  3939. // Create a writable copy of the event object and normalize some properties
  3940. var i, prop, copy,
  3941. type = event.type,
  3942. originalEvent = event,
  3943. fixHook = this.fixHooks[ type ];
  3944. if ( !fixHook ) {
  3945. this.fixHooks[ type ] = fixHook =
  3946. rmouseEvent.test( type ) ? this.mouseHooks :
  3947. rkeyEvent.test( type ) ? this.keyHooks :
  3948. {};
  3949. }
  3950. copy = fixHook.props ? this.props.concat( fixHook.props ) : this.props;
  3951. event = new jQuery.Event( originalEvent );
  3952. i = copy.length;
  3953. while ( i-- ) {
  3954. prop = copy[ i ];
  3955. event[ prop ] = originalEvent[ prop ];
  3956. }
  3957. // Support: IE<9
  3958. // Fix target property (#1925)
  3959. if ( !event.target ) {
  3960. event.target = originalEvent.srcElement || document;
  3961. }
  3962. // Support: Chrome 23+, Safari?
  3963. // Target should not be a text node (#504, #13143)
  3964. if ( event.target.nodeType === 3 ) {
  3965. event.target = event.target.parentNode;
  3966. }
  3967. // Support: IE<9
  3968. // For mouse/key events, metaKey==false if it's undefined (#3368, #11328)
  3969. event.metaKey = !!event.metaKey;
  3970. return fixHook.filter ? fixHook.filter( event, originalEvent ) : event;
  3971. },
  3972. // Includes some event props shared by KeyEvent and MouseEvent
  3973. props: "altKey bubbles cancelable ctrlKey currentTarget eventPhase metaKey relatedTarget shiftKey target timeStamp view which".split(" "),
  3974. fixHooks: {},
  3975. keyHooks: {
  3976. props: "char charCode key keyCode".split(" "),
  3977. filter: function( event, original ) {
  3978. // Add which for key events
  3979. if ( event.which == null ) {
  3980. event.which = original.charCode != null ? original.charCode : original.keyCode;
  3981. }
  3982. return event;
  3983. }
  3984. },
  3985. mouseHooks: {
  3986. props: "button buttons clientX clientY fromElement offsetX offsetY pageX pageY screenX screenY toElement".split(" "),
  3987. filter: function( event, original ) {
  3988. var body, eventDoc, doc,
  3989. button = original.button,
  3990. fromElement = original.fromElement;
  3991. // Calculate pageX/Y if missing and clientX/Y available
  3992. if ( event.pageX == null && original.clientX != null ) {
  3993. eventDoc = event.target.ownerDocument || document;
  3994. doc = eventDoc.documentElement;
  3995. body = eventDoc.body;
  3996. event.pageX = original.clientX + ( doc && doc.scrollLeft || body && body.scrollLeft || 0 ) - ( doc && doc.clientLeft || body && body.clientLeft || 0 );
  3997. event.pageY = original.clientY + ( doc && doc.scrollTop || body && body.scrollTop || 0 ) - ( doc && doc.clientTop || body && body.clientTop || 0 );
  3998. }
  3999. // Add relatedTarget, if necessary
  4000. if ( !event.relatedTarget && fromElement ) {
  4001. event.relatedTarget = fromElement === event.target ? original.toElement : fromElement;
  4002. }
  4003. // Add which for click: 1 === left; 2 === middle; 3 === right
  4004. // Note: button is not normalized, so don't use it
  4005. if ( !event.which && button !== undefined ) {
  4006. event.which = ( button & 1 ? 1 : ( button & 2 ? 3 : ( button & 4 ? 2 : 0 ) ) );
  4007. }
  4008. return event;
  4009. }
  4010. },
  4011. special: {
  4012. load: {
  4013. // Prevent triggered image.load events from bubbling to window.load
  4014. noBubble: true
  4015. },
  4016. focus: {
  4017. // Fire native event if possible so blur/focus sequence is correct
  4018. trigger: function() {
  4019. if ( this !== safeActiveElement() && this.focus ) {
  4020. try {
  4021. this.focus();
  4022. return false;
  4023. } catch ( e ) {
  4024. // Support: IE<9
  4025. // If we error on focus to hidden element (#1486, #12518),
  4026. // let .trigger() run the handlers
  4027. }
  4028. }
  4029. },
  4030. delegateType: "focusin"
  4031. },
  4032. blur: {
  4033. trigger: function() {
  4034. if ( this === safeActiveElement() && this.blur ) {
  4035. this.blur();
  4036. return false;
  4037. }
  4038. },
  4039. delegateType: "focusout"
  4040. },
  4041. click: {
  4042. // For checkbox, fire native event so checked state will be right
  4043. trigger: function() {
  4044. if ( jQuery.nodeName( this, "input" ) && this.type === "checkbox" && this.click ) {
  4045. this.click();
  4046. return false;
  4047. }
  4048. },
  4049. // For cross-browser consistency, don't fire native .click() on links
  4050. _default: function( event ) {
  4051. return jQuery.nodeName( event.target, "a" );
  4052. }
  4053. },
  4054. beforeunload: {
  4055. postDispatch: function( event ) {
  4056. // Support: Firefox 20+
  4057. // Firefox doesn't alert if the returnValue field is not set.
  4058. if ( event.result !== undefined && event.originalEvent ) {
  4059. event.originalEvent.returnValue = event.result;
  4060. }
  4061. }
  4062. }
  4063. },
  4064. simulate: function( type, elem, event, bubble ) {
  4065. // Piggyback on a donor event to simulate a different one.
  4066. // Fake originalEvent to avoid donor's stopPropagation, but if the
  4067. // simulated event prevents default then we do the same on the donor.
  4068. var e = jQuery.extend(
  4069. new jQuery.Event(),
  4070. event,
  4071. {
  4072. type: type,
  4073. isSimulated: true,
  4074. originalEvent: {}
  4075. }
  4076. );
  4077. if ( bubble ) {
  4078. jQuery.event.trigger( e, null, elem );
  4079. } else {
  4080. jQuery.event.dispatch.call( elem, e );
  4081. }
  4082. if ( e.isDefaultPrevented() ) {
  4083. event.preventDefault();
  4084. }
  4085. }
  4086. };
  4087. jQuery.removeEvent = document.removeEventListener ?
  4088. function( elem, type, handle ) {
  4089. if ( elem.removeEventListener ) {
  4090. elem.removeEventListener( type, handle, false );
  4091. }
  4092. } :
  4093. function( elem, type, handle ) {
  4094. var name = "on" + type;
  4095. if ( elem.detachEvent ) {
  4096. // #8545, #7054, preventing memory leaks for custom events in IE6-8
  4097. // detachEvent needed property on element, by name of that event, to properly expose it to GC
  4098. if ( typeof elem[ name ] === strundefined ) {
  4099. elem[ name ] = null;
  4100. }
  4101. elem.detachEvent( name, handle );
  4102. }
  4103. };
  4104. jQuery.Event = function( src, props ) {
  4105. // Allow instantiation without the 'new' keyword
  4106. if ( !(this instanceof jQuery.Event) ) {
  4107. return new jQuery.Event( src, props );
  4108. }
  4109. // Event object
  4110. if ( src && src.type ) {
  4111. this.originalEvent = src;
  4112. this.type = src.type;
  4113. // Events bubbling up the document may have been marked as prevented
  4114. // by a handler lower down the tree; reflect the correct value.
  4115. this.isDefaultPrevented = src.defaultPrevented ||
  4116. src.defaultPrevented === undefined &&
  4117. // Support: IE < 9, Android < 4.0
  4118. src.returnValue === false ?
  4119. returnTrue :
  4120. returnFalse;
  4121. // Event type
  4122. } else {
  4123. this.type = src;
  4124. }
  4125. // Put explicitly provided properties onto the event object
  4126. if ( props ) {
  4127. jQuery.extend( this, props );
  4128. }
  4129. // Create a timestamp if incoming event doesn't have one
  4130. this.timeStamp = src && src.timeStamp || jQuery.now();
  4131. // Mark it as fixed
  4132. this[ jQuery.expando ] = true;
  4133. };
  4134. // jQuery.Event is based on DOM3 Events as specified by the ECMAScript Language Binding
  4135. // http://www.w3.org/TR/2003/WD-DOM-Level-3-Events-20030331/ecma-script-binding.html
  4136. jQuery.Event.prototype = {
  4137. isDefaultPrevented: returnFalse,
  4138. isPropagationStopped: returnFalse,
  4139. isImmediatePropagationStopped: returnFalse,
  4140. preventDefault: function() {
  4141. var e = this.originalEvent;
  4142. this.isDefaultPrevented = returnTrue;
  4143. if ( !e ) {
  4144. return;
  4145. }
  4146. // If preventDefault exists, run it on the original event
  4147. if ( e.preventDefault ) {
  4148. e.preventDefault();
  4149. // Support: IE
  4150. // Otherwise set the returnValue property of the original event to false
  4151. } else {
  4152. e.returnValue = false;
  4153. }
  4154. },
  4155. stopPropagation: function() {
  4156. var e = this.originalEvent;
  4157. this.isPropagationStopped = returnTrue;
  4158. if ( !e ) {
  4159. return;
  4160. }
  4161. // If stopPropagation exists, run it on the original event
  4162. if ( e.stopPropagation ) {
  4163. e.stopPropagation();
  4164. }
  4165. // Support: IE
  4166. // Set the cancelBubble property of the original event to true
  4167. e.cancelBubble = true;
  4168. },
  4169. stopImmediatePropagation: function() {
  4170. var e = this.originalEvent;
  4171. this.isImmediatePropagationStopped = returnTrue;
  4172. if ( e && e.stopImmediatePropagation ) {
  4173. e.stopImmediatePropagation();
  4174. }
  4175. this.stopPropagation();
  4176. }
  4177. };
  4178. // Create mouseenter/leave events using mouseover/out and event-time checks
  4179. jQuery.each({
  4180. mouseenter: "mouseover",
  4181. mouseleave: "mouseout",
  4182. pointerenter: "pointerover",
  4183. pointerleave: "pointerout"
  4184. }, function( orig, fix ) {
  4185. jQuery.event.special[ orig ] = {
  4186. delegateType: fix,
  4187. bindType: fix,
  4188. handle: function( event ) {
  4189. var ret,
  4190. target = this,
  4191. related = event.relatedTarget,
  4192. handleObj = event.handleObj;
  4193. // For mousenter/leave call the handler if related is outside the target.
  4194. // NB: No relatedTarget if the mouse left/entered the browser window
  4195. if ( !related || (related !== target && !jQuery.contains( target, related )) ) {
  4196. event.type = handleObj.origType;
  4197. ret = handleObj.handler.apply( this, arguments );
  4198. event.type = fix;
  4199. }
  4200. return ret;
  4201. }
  4202. };
  4203. });
  4204. // IE submit delegation
  4205. if ( !support.submitBubbles ) {
  4206. jQuery.event.special.submit = {
  4207. setup: function() {
  4208. // Only need this for delegated form submit events
  4209. if ( jQuery.nodeName( this, "form" ) ) {
  4210. return false;
  4211. }
  4212. // Lazy-add a submit handler when a descendant form may potentially be submitted
  4213. jQuery.event.add( this, "click._submit keypress._submit", function( e ) {
  4214. // Node name check avoids a VML-related crash in IE (#9807)
  4215. var elem = e.target,
  4216. form = jQuery.nodeName( elem, "input" ) || jQuery.nodeName( elem, "button" ) ? elem.form : undefined;
  4217. if ( form && !jQuery._data( form, "submitBubbles" ) ) {
  4218. jQuery.event.add( form, "submit._submit", function( event ) {
  4219. event._submit_bubble = true;
  4220. });
  4221. jQuery._data( form, "submitBubbles", true );
  4222. }
  4223. });
  4224. // return undefined since we don't need an event listener
  4225. },
  4226. postDispatch: function( event ) {
  4227. // If form was submitted by the user, bubble the event up the tree
  4228. if ( event._submit_bubble ) {
  4229. delete event._submit_bubble;
  4230. if ( this.parentNode && !event.isTrigger ) {
  4231. jQuery.event.simulate( "submit", this.parentNode, event, true );
  4232. }
  4233. }
  4234. },
  4235. teardown: function() {
  4236. // Only need this for delegated form submit events
  4237. if ( jQuery.nodeName( this, "form" ) ) {
  4238. return false;
  4239. }
  4240. // Remove delegated handlers; cleanData eventually reaps submit handlers attached above
  4241. jQuery.event.remove( this, "._submit" );
  4242. }
  4243. };
  4244. }
  4245. // IE change delegation and checkbox/radio fix
  4246. if ( !support.changeBubbles ) {
  4247. jQuery.event.special.change = {
  4248. setup: function() {
  4249. if ( rformElems.test( this.nodeName ) ) {
  4250. // IE doesn't fire change on a check/radio until blur; trigger it on click
  4251. // after a propertychange. Eat the blur-change in special.change.handle.
  4252. // This still fires onchange a second time for check/radio after blur.
  4253. if ( this.type === "checkbox" || this.type === "radio" ) {
  4254. jQuery.event.add( this, "propertychange._change", function( event ) {
  4255. if ( event.originalEvent.propertyName === "checked" ) {
  4256. this._just_changed = true;
  4257. }
  4258. });
  4259. jQuery.event.add( this, "click._change", function( event ) {
  4260. if ( this._just_changed && !event.isTrigger ) {
  4261. this._just_changed = false;
  4262. }
  4263. // Allow triggered, simulated change events (#11500)
  4264. jQuery.event.simulate( "change", this, event, true );
  4265. });
  4266. }
  4267. return false;
  4268. }
  4269. // Delegated event; lazy-add a change handler on descendant inputs
  4270. jQuery.event.add( this, "beforeactivate._change", function( e ) {
  4271. var elem = e.target;
  4272. if ( rformElems.test( elem.nodeName ) && !jQuery._data( elem, "changeBubbles" ) ) {
  4273. jQuery.event.add( elem, "change._change", function( event ) {
  4274. if ( this.parentNode && !event.isSimulated && !event.isTrigger ) {
  4275. jQuery.event.simulate( "change", this.parentNode, event, true );
  4276. }
  4277. });
  4278. jQuery._data( elem, "changeBubbles", true );
  4279. }
  4280. });
  4281. },
  4282. handle: function( event ) {
  4283. var elem = event.target;
  4284. // Swallow native change events from checkbox/radio, we already triggered them above
  4285. if ( this !== elem || event.isSimulated || event.isTrigger || (elem.type !== "radio" && elem.type !== "checkbox") ) {
  4286. return event.handleObj.handler.apply( this, arguments );
  4287. }
  4288. },
  4289. teardown: function() {
  4290. jQuery.event.remove( this, "._change" );
  4291. return !rformElems.test( this.nodeName );
  4292. }
  4293. };
  4294. }
  4295. // Create "bubbling" focus and blur events
  4296. if ( !support.focusinBubbles ) {
  4297. jQuery.each({ focus: "focusin", blur: "focusout" }, function( orig, fix ) {
  4298. // Attach a single capturing handler on the document while someone wants focusin/focusout
  4299. var handler = function( event ) {
  4300. jQuery.event.simulate( fix, event.target, jQuery.event.fix( event ), true );
  4301. };
  4302. jQuery.event.special[ fix ] = {
  4303. setup: function() {
  4304. var doc = this.ownerDocument || this,
  4305. attaches = jQuery._data( doc, fix );
  4306. if ( !attaches ) {
  4307. doc.addEventListener( orig, handler, true );
  4308. }
  4309. jQuery._data( doc, fix, ( attaches || 0 ) + 1 );
  4310. },
  4311. teardown: function() {
  4312. var doc = this.ownerDocument || this,
  4313. attaches = jQuery._data( doc, fix ) - 1;
  4314. if ( !attaches ) {
  4315. doc.removeEventListener( orig, handler, true );
  4316. jQuery._removeData( doc, fix );
  4317. } else {
  4318. jQuery._data( doc, fix, attaches );
  4319. }
  4320. }
  4321. };
  4322. });
  4323. }
  4324. jQuery.fn.extend({
  4325. on: function( types, selector, data, fn, /*INTERNAL*/ one ) {
  4326. var type, origFn;
  4327. // Types can be a map of types/handlers
  4328. if ( typeof types === "object" ) {
  4329. // ( types-Object, selector, data )
  4330. if ( typeof selector !== "string" ) {
  4331. // ( types-Object, data )
  4332. data = data || selector;
  4333. selector = undefined;
  4334. }
  4335. for ( type in types ) {
  4336. this.on( type, selector, data, types[ type ], one );
  4337. }
  4338. return this;
  4339. }
  4340. if ( data == null && fn == null ) {
  4341. // ( types, fn )
  4342. fn = selector;
  4343. data = selector = undefined;
  4344. } else if ( fn == null ) {
  4345. if ( typeof selector === "string" ) {
  4346. // ( types, selector, fn )
  4347. fn = data;
  4348. data = undefined;
  4349. } else {
  4350. // ( types, data, fn )
  4351. fn = data;
  4352. data = selector;
  4353. selector = undefined;
  4354. }
  4355. }
  4356. if ( fn === false ) {
  4357. fn = returnFalse;
  4358. } else if ( !fn ) {
  4359. return this;
  4360. }
  4361. if ( one === 1 ) {
  4362. origFn = fn;
  4363. fn = function( event ) {
  4364. // Can use an empty set, since event contains the info
  4365. jQuery().off( event );
  4366. return origFn.apply( this, arguments );
  4367. };
  4368. // Use same guid so caller can remove using origFn
  4369. fn.guid = origFn.guid || ( origFn.guid = jQuery.guid++ );
  4370. }
  4371. return this.each( function() {
  4372. jQuery.event.add( this, types, fn, data, selector );
  4373. });
  4374. },
  4375. one: function( types, selector, data, fn ) {
  4376. return this.on( types, selector, data, fn, 1 );
  4377. },
  4378. off: function( types, selector, fn ) {
  4379. var handleObj, type;
  4380. if ( types && types.preventDefault && types.handleObj ) {
  4381. // ( event ) dispatched jQuery.Event
  4382. handleObj = types.handleObj;
  4383. jQuery( types.delegateTarget ).off(
  4384. handleObj.namespace ? handleObj.origType + "." + handleObj.namespace : handleObj.origType,
  4385. handleObj.selector,
  4386. handleObj.handler
  4387. );
  4388. return this;
  4389. }
  4390. if ( typeof types === "object" ) {
  4391. // ( types-object [, selector] )
  4392. for ( type in types ) {
  4393. this.off( type, selector, types[ type ] );
  4394. }
  4395. return this;
  4396. }
  4397. if ( selector === false || typeof selector === "function" ) {
  4398. // ( types [, fn] )
  4399. fn = selector;
  4400. selector = undefined;
  4401. }
  4402. if ( fn === false ) {
  4403. fn = returnFalse;
  4404. }
  4405. return this.each(function() {
  4406. jQuery.event.remove( this, types, fn, selector );
  4407. });
  4408. },
  4409. trigger: function( type, data ) {
  4410. return this.each(function() {
  4411. jQuery.event.trigger( type, data, this );
  4412. });
  4413. },
  4414. triggerHandler: function( type, data ) {
  4415. var elem = this[0];
  4416. if ( elem ) {
  4417. return jQuery.event.trigger( type, data, elem, true );
  4418. }
  4419. }
  4420. });
  4421. function createSafeFragment( document ) {
  4422. var list = nodeNames.split( "|" ),
  4423. safeFrag = document.createDocumentFragment();
  4424. if ( safeFrag.createElement ) {
  4425. while ( list.length ) {
  4426. safeFrag.createElement(
  4427. list.pop()
  4428. );
  4429. }
  4430. }
  4431. return safeFrag;
  4432. }
  4433. var nodeNames = "abbr|article|aside|audio|bdi|canvas|data|datalist|details|figcaption|figure|footer|" +
  4434. "header|hgroup|mark|meter|nav|output|progress|section|summary|time|video",
  4435. rinlinejQuery = / jQuery\d+="(?:null|\d+)"/g,
  4436. rnoshimcache = new RegExp("<(?:" + nodeNames + ")[\\s/>]", "i"),
  4437. rleadingWhitespace = /^\s+/,
  4438. rxhtmlTag = /<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/gi,
  4439. rtagName = /<([\w:]+)/,
  4440. rtbody = /<tbody/i,
  4441. rhtml = /<|&#?\w+;/,
  4442. rnoInnerhtml = /<(?:script|style|link)/i,
  4443. // checked="checked" or checked
  4444. rchecked = /checked\s*(?:[^=]|=\s*.checked.)/i,
  4445. rscriptType = /^$|\/(?:java|ecma)script/i,
  4446. rscriptTypeMasked = /^true\/(.*)/,
  4447. rcleanScript = /^\s*<!(?:\[CDATA\[|--)|(?:\]\]|--)>\s*$/g,
  4448. // We have to close these tags to support XHTML (#13200)
  4449. wrapMap = {
  4450. option: [ 1, "<select multiple='multiple'>", "</select>" ],
  4451. legend: [ 1, "<fieldset>", "</fieldset>" ],
  4452. area: [ 1, "<map>", "</map>" ],
  4453. param: [ 1, "<object>", "</object>" ],
  4454. thead: [ 1, "<table>", "</table>" ],
  4455. tr: [ 2, "<table><tbody>", "</tbody></table>" ],
  4456. col: [ 2, "<table><tbody></tbody><colgroup>", "</colgroup></table>" ],
  4457. td: [ 3, "<table><tbody><tr>", "</tr></tbody></table>" ],
  4458. // IE6-8 can't serialize link, script, style, or any html5 (NoScope) tags,
  4459. // unless wrapped in a div with non-breaking characters in front of it.
  4460. _default: support.htmlSerialize ? [ 0, "", "" ] : [ 1, "X<div>", "</div>" ]
  4461. },
  4462. safeFragment = createSafeFragment( document ),
  4463. fragmentDiv = safeFragment.appendChild( document.createElement("div") );
  4464. wrapMap.optgroup = wrapMap.option;
  4465. wrapMap.tbody = wrapMap.tfoot = wrapMap.colgroup = wrapMap.caption = wrapMap.thead;
  4466. wrapMap.th = wrapMap.td;
  4467. function getAll( context, tag ) {
  4468. var elems, elem,
  4469. i = 0,
  4470. found = typeof context.getElementsByTagName !== strundefined ? context.getElementsByTagName( tag || "*" ) :
  4471. typeof context.querySelectorAll !== strundefined ? context.querySelectorAll( tag || "*" ) :
  4472. undefined;
  4473. if ( !found ) {
  4474. for ( found = [], elems = context.childNodes || context; (elem = elems[i]) != null; i++ ) {
  4475. if ( !tag || jQuery.nodeName( elem, tag ) ) {
  4476. found.push( elem );
  4477. } else {
  4478. jQuery.merge( found, getAll( elem, tag ) );
  4479. }
  4480. }
  4481. }
  4482. return tag === undefined || tag && jQuery.nodeName( context, tag ) ?
  4483. jQuery.merge( [ context ], found ) :
  4484. found;
  4485. }
  4486. // Used in buildFragment, fixes the defaultChecked property
  4487. function fixDefaultChecked( elem ) {
  4488. if ( rcheckableType.test( elem.type ) ) {
  4489. elem.defaultChecked = elem.checked;
  4490. }
  4491. }
  4492. // Support: IE<8
  4493. // Manipulating tables requires a tbody
  4494. function manipulationTarget( elem, content ) {
  4495. return jQuery.nodeName( elem, "table" ) &&
  4496. jQuery.nodeName( content.nodeType !== 11 ? content : content.firstChild, "tr" ) ?
  4497. elem.getElementsByTagName("tbody")[0] ||
  4498. elem.appendChild( elem.ownerDocument.createElement("tbody") ) :
  4499. elem;
  4500. }
  4501. // Replace/restore the type attribute of script elements for safe DOM manipulation
  4502. function disableScript( elem ) {
  4503. elem.type = (jQuery.find.attr( elem, "type" ) !== null) + "/" + elem.type;
  4504. return elem;
  4505. }
  4506. function restoreScript( elem ) {
  4507. var match = rscriptTypeMasked.exec( elem.type );
  4508. if ( match ) {
  4509. elem.type = match[1];
  4510. } else {
  4511. elem.removeAttribute("type");
  4512. }
  4513. return elem;
  4514. }
  4515. // Mark scripts as having already been evaluated
  4516. function setGlobalEval( elems, refElements ) {
  4517. var elem,
  4518. i = 0;
  4519. for ( ; (elem = elems[i]) != null; i++ ) {
  4520. jQuery._data( elem, "globalEval", !refElements || jQuery._data( refElements[i], "globalEval" ) );
  4521. }
  4522. }
  4523. function cloneCopyEvent( src, dest ) {
  4524. if ( dest.nodeType !== 1 || !jQuery.hasData( src ) ) {
  4525. return;
  4526. }
  4527. var type, i, l,
  4528. oldData = jQuery._data( src ),
  4529. curData = jQuery._data( dest, oldData ),
  4530. events = oldData.events;
  4531. if ( events ) {
  4532. delete curData.handle;
  4533. curData.events = {};
  4534. for ( type in events ) {
  4535. for ( i = 0, l = events[ type ].length; i < l; i++ ) {
  4536. jQuery.event.add( dest, type, events[ type ][ i ] );
  4537. }
  4538. }
  4539. }
  4540. // make the cloned public data object a copy from the original
  4541. if ( curData.data ) {
  4542. curData.data = jQuery.extend( {}, curData.data );
  4543. }
  4544. }
  4545. function fixCloneNodeIssues( src, dest ) {
  4546. var nodeName, e, data;
  4547. // We do not need to do anything for non-Elements
  4548. if ( dest.nodeType !== 1 ) {
  4549. return;
  4550. }
  4551. nodeName = dest.nodeName.toLowerCase();
  4552. // IE6-8 copies events bound via attachEvent when using cloneNode.
  4553. if ( !support.noCloneEvent && dest[ jQuery.expando ] ) {
  4554. data = jQuery._data( dest );
  4555. for ( e in data.events ) {
  4556. jQuery.removeEvent( dest, e, data.handle );
  4557. }
  4558. // Event data gets referenced instead of copied if the expando gets copied too
  4559. dest.removeAttribute( jQuery.expando );
  4560. }
  4561. // IE blanks contents when cloning scripts, and tries to evaluate newly-set text
  4562. if ( nodeName === "script" && dest.text !== src.text ) {
  4563. disableScript( dest ).text = src.text;
  4564. restoreScript( dest );
  4565. // IE6-10 improperly clones children of object elements using classid.
  4566. // IE10 throws NoModificationAllowedError if parent is null, #12132.
  4567. } else if ( nodeName === "object" ) {
  4568. if ( dest.parentNode ) {
  4569. dest.outerHTML = src.outerHTML;
  4570. }
  4571. // This path appears unavoidable for IE9. When cloning an object
  4572. // element in IE9, the outerHTML strategy above is not sufficient.
  4573. // If the src has innerHTML and the destination does not,
  4574. // copy the src.innerHTML into the dest.innerHTML. #10324
  4575. if ( support.html5Clone && ( src.innerHTML && !jQuery.trim(dest.innerHTML) ) ) {
  4576. dest.innerHTML = src.innerHTML;
  4577. }
  4578. } else if ( nodeName === "input" && rcheckableType.test( src.type ) ) {
  4579. // IE6-8 fails to persist the checked state of a cloned checkbox
  4580. // or radio button. Worse, IE6-7 fail to give the cloned element
  4581. // a checked appearance if the defaultChecked value isn't also set
  4582. dest.defaultChecked = dest.checked = src.checked;
  4583. // IE6-7 get confused and end up setting the value of a cloned
  4584. // checkbox/radio button to an empty string instead of "on"
  4585. if ( dest.value !== src.value ) {
  4586. dest.value = src.value;
  4587. }
  4588. // IE6-8 fails to return the selected option to the default selected
  4589. // state when cloning options
  4590. } else if ( nodeName === "option" ) {
  4591. dest.defaultSelected = dest.selected = src.defaultSelected;
  4592. // IE6-8 fails to set the defaultValue to the correct value when
  4593. // cloning other types of input fields
  4594. } else if ( nodeName === "input" || nodeName === "textarea" ) {
  4595. dest.defaultValue = src.defaultValue;
  4596. }
  4597. }
  4598. jQuery.extend({
  4599. clone: function( elem, dataAndEvents, deepDataAndEvents ) {
  4600. var destElements, node, clone, i, srcElements,
  4601. inPage = jQuery.contains( elem.ownerDocument, elem );
  4602. if ( support.html5Clone || jQuery.isXMLDoc(elem) || !rnoshimcache.test( "<" + elem.nodeName + ">" ) ) {
  4603. clone = elem.cloneNode( true );
  4604. // IE<=8 does not properly clone detached, unknown element nodes
  4605. } else {
  4606. fragmentDiv.innerHTML = elem.outerHTML;
  4607. fragmentDiv.removeChild( clone = fragmentDiv.firstChild );
  4608. }
  4609. if ( (!support.noCloneEvent || !support.noCloneChecked) &&
  4610. (elem.nodeType === 1 || elem.nodeType === 11) && !jQuery.isXMLDoc(elem) ) {
  4611. // We eschew Sizzle here for performance reasons: http://jsperf.com/getall-vs-sizzle/2
  4612. destElements = getAll( clone );
  4613. srcElements = getAll( elem );
  4614. // Fix all IE cloning issues
  4615. for ( i = 0; (node = srcElements[i]) != null; ++i ) {
  4616. // Ensure that the destination node is not null; Fixes #9587
  4617. if ( destElements[i] ) {
  4618. fixCloneNodeIssues( node, destElements[i] );
  4619. }
  4620. }
  4621. }
  4622. // Copy the events from the original to the clone
  4623. if ( dataAndEvents ) {
  4624. if ( deepDataAndEvents ) {
  4625. srcElements = srcElements || getAll( elem );
  4626. destElements = destElements || getAll( clone );
  4627. for ( i = 0; (node = srcElements[i]) != null; i++ ) {
  4628. cloneCopyEvent( node, destElements[i] );
  4629. }
  4630. } else {
  4631. cloneCopyEvent( elem, clone );
  4632. }
  4633. }
  4634. // Preserve script evaluation history
  4635. destElements = getAll( clone, "script" );
  4636. if ( destElements.length > 0 ) {
  4637. setGlobalEval( destElements, !inPage && getAll( elem, "script" ) );
  4638. }
  4639. destElements = srcElements = node = null;
  4640. // Return the cloned set
  4641. return clone;
  4642. },
  4643. buildFragment: function( elems, context, scripts, selection ) {
  4644. var j, elem, contains,
  4645. tmp, tag, tbody, wrap,
  4646. l = elems.length,
  4647. // Ensure a safe fragment
  4648. safe = createSafeFragment( context ),
  4649. nodes = [],
  4650. i = 0;
  4651. for ( ; i < l; i++ ) {
  4652. elem = elems[ i ];
  4653. if ( elem || elem === 0 ) {
  4654. // Add nodes directly
  4655. if ( jQuery.type( elem ) === "object" ) {
  4656. jQuery.merge( nodes, elem.nodeType ? [ elem ] : elem );
  4657. // Convert non-html into a text node
  4658. } else if ( !rhtml.test( elem ) ) {
  4659. nodes.push( context.createTextNode( elem ) );
  4660. // Convert html into DOM nodes
  4661. } else {
  4662. tmp = tmp || safe.appendChild( context.createElement("div") );
  4663. // Deserialize a standard representation
  4664. tag = (rtagName.exec( elem ) || [ "", "" ])[ 1 ].toLowerCase();
  4665. wrap = wrapMap[ tag ] || wrapMap._default;
  4666. tmp.innerHTML = wrap[1] + elem.replace( rxhtmlTag, "<$1></$2>" ) + wrap[2];
  4667. // Descend through wrappers to the right content
  4668. j = wrap[0];
  4669. while ( j-- ) {
  4670. tmp = tmp.lastChild;
  4671. }
  4672. // Manually add leading whitespace removed by IE
  4673. if ( !support.leadingWhitespace && rleadingWhitespace.test( elem ) ) {
  4674. nodes.push( context.createTextNode( rleadingWhitespace.exec( elem )[0] ) );
  4675. }
  4676. // Remove IE's autoinserted <tbody> from table fragments
  4677. if ( !support.tbody ) {
  4678. // String was a <table>, *may* have spurious <tbody>
  4679. elem = tag === "table" && !rtbody.test( elem ) ?
  4680. tmp.firstChild :
  4681. // String was a bare <thead> or <tfoot>
  4682. wrap[1] === "<table>" && !rtbody.test( elem ) ?
  4683. tmp :
  4684. 0;
  4685. j = elem && elem.childNodes.length;
  4686. while ( j-- ) {
  4687. if ( jQuery.nodeName( (tbody = elem.childNodes[j]), "tbody" ) && !tbody.childNodes.length ) {
  4688. elem.removeChild( tbody );
  4689. }
  4690. }
  4691. }
  4692. jQuery.merge( nodes, tmp.childNodes );
  4693. // Fix #12392 for WebKit and IE > 9
  4694. tmp.textContent = "";
  4695. // Fix #12392 for oldIE
  4696. while ( tmp.firstChild ) {
  4697. tmp.removeChild( tmp.firstChild );
  4698. }
  4699. // Remember the top-level container for proper cleanup
  4700. tmp = safe.lastChild;
  4701. }
  4702. }
  4703. }
  4704. // Fix #11356: Clear elements from fragment
  4705. if ( tmp ) {
  4706. safe.removeChild( tmp );
  4707. }
  4708. // Reset defaultChecked for any radios and checkboxes
  4709. // about to be appended to the DOM in IE 6/7 (#8060)
  4710. if ( !support.appendChecked ) {
  4711. jQuery.grep( getAll( nodes, "input" ), fixDefaultChecked );
  4712. }
  4713. i = 0;
  4714. while ( (elem = nodes[ i++ ]) ) {
  4715. // #4087 - If origin and destination elements are the same, and this is
  4716. // that element, do not do anything
  4717. if ( selection && jQuery.inArray( elem, selection ) !== -1 ) {
  4718. continue;
  4719. }
  4720. contains = jQuery.contains( elem.ownerDocument, elem );
  4721. // Append to fragment
  4722. tmp = getAll( safe.appendChild( elem ), "script" );
  4723. // Preserve script evaluation history
  4724. if ( contains ) {
  4725. setGlobalEval( tmp );
  4726. }
  4727. // Capture executables
  4728. if ( scripts ) {
  4729. j = 0;
  4730. while ( (elem = tmp[ j++ ]) ) {
  4731. if ( rscriptType.test( elem.type || "" ) ) {
  4732. scripts.push( elem );
  4733. }
  4734. }
  4735. }
  4736. }
  4737. tmp = null;
  4738. return safe;
  4739. },
  4740. cleanData: function( elems, /* internal */ acceptData ) {
  4741. var elem, type, id, data,
  4742. i = 0,
  4743. internalKey = jQuery.expando,
  4744. cache = jQuery.cache,
  4745. deleteExpando = support.deleteExpando,
  4746. special = jQuery.event.special;
  4747. for ( ; (elem = elems[i]) != null; i++ ) {
  4748. if ( acceptData || jQuery.acceptData( elem ) ) {
  4749. id = elem[ internalKey ];
  4750. data = id && cache[ id ];
  4751. if ( data ) {
  4752. if ( data.events ) {
  4753. for ( type in data.events ) {
  4754. if ( special[ type ] ) {
  4755. jQuery.event.remove( elem, type );
  4756. // This is a shortcut to avoid jQuery.event.remove's overhead
  4757. } else {
  4758. jQuery.removeEvent( elem, type, data.handle );
  4759. }
  4760. }
  4761. }
  4762. // Remove cache only if it was not already removed by jQuery.event.remove
  4763. if ( cache[ id ] ) {
  4764. delete cache[ id ];
  4765. // IE does not allow us to delete expando properties from nodes,
  4766. // nor does it have a removeAttribute function on Document nodes;
  4767. // we must handle all of these cases
  4768. if ( deleteExpando ) {
  4769. delete elem[ internalKey ];
  4770. } else if ( typeof elem.removeAttribute !== strundefined ) {
  4771. elem.removeAttribute( internalKey );
  4772. } else {
  4773. elem[ internalKey ] = null;
  4774. }
  4775. deletedIds.push( id );
  4776. }
  4777. }
  4778. }
  4779. }
  4780. }
  4781. });
  4782. jQuery.fn.extend({
  4783. text: function( value ) {
  4784. return access( this, function( value ) {
  4785. return value === undefined ?
  4786. jQuery.text( this ) :
  4787. this.empty().append( ( this[0] && this[0].ownerDocument || document ).createTextNode( value ) );
  4788. }, null, value, arguments.length );
  4789. },
  4790. append: function() {
  4791. return this.domManip( arguments, function( elem ) {
  4792. if ( this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9 ) {
  4793. var target = manipulationTarget( this, elem );
  4794. target.appendChild( elem );
  4795. }
  4796. });
  4797. },
  4798. prepend: function() {
  4799. return this.domManip( arguments, function( elem ) {
  4800. if ( this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9 ) {
  4801. var target = manipulationTarget( this, elem );
  4802. target.insertBefore( elem, target.firstChild );
  4803. }
  4804. });
  4805. },
  4806. before: function() {
  4807. return this.domManip( arguments, function( elem ) {
  4808. if ( this.parentNode ) {
  4809. this.parentNode.insertBefore( elem, this );
  4810. }
  4811. });
  4812. },
  4813. after: function() {
  4814. return this.domManip( arguments, function( elem ) {
  4815. if ( this.parentNode ) {
  4816. this.parentNode.insertBefore( elem, this.nextSibling );
  4817. }
  4818. });
  4819. },
  4820. remove: function( selector, keepData /* Internal Use Only */ ) {
  4821. var elem,
  4822. elems = selector ? jQuery.filter( selector, this ) : this,
  4823. i = 0;
  4824. for ( ; (elem = elems[i]) != null; i++ ) {
  4825. if ( !keepData && elem.nodeType === 1 ) {
  4826. jQuery.cleanData( getAll( elem ) );
  4827. }
  4828. if ( elem.parentNode ) {
  4829. if ( keepData && jQuery.contains( elem.ownerDocument, elem ) ) {
  4830. setGlobalEval( getAll( elem, "script" ) );
  4831. }
  4832. elem.parentNode.removeChild( elem );
  4833. }
  4834. }
  4835. return this;
  4836. },
  4837. empty: function() {
  4838. var elem,
  4839. i = 0;
  4840. for ( ; (elem = this[i]) != null; i++ ) {
  4841. // Remove element nodes and prevent memory leaks
  4842. if ( elem.nodeType === 1 ) {
  4843. jQuery.cleanData( getAll( elem, false ) );
  4844. }
  4845. // Remove any remaining nodes
  4846. while ( elem.firstChild ) {
  4847. elem.removeChild( elem.firstChild );
  4848. }
  4849. // If this is a select, ensure that it displays empty (#12336)
  4850. // Support: IE<9
  4851. if ( elem.options && jQuery.nodeName( elem, "select" ) ) {
  4852. elem.options.length = 0;
  4853. }
  4854. }
  4855. return this;
  4856. },
  4857. clone: function( dataAndEvents, deepDataAndEvents ) {
  4858. dataAndEvents = dataAndEvents == null ? false : dataAndEvents;
  4859. deepDataAndEvents = deepDataAndEvents == null ? dataAndEvents : deepDataAndEvents;
  4860. return this.map(function() {
  4861. return jQuery.clone( this, dataAndEvents, deepDataAndEvents );
  4862. });
  4863. },
  4864. html: function( value ) {
  4865. return access( this, function( value ) {
  4866. var elem = this[ 0 ] || {},
  4867. i = 0,
  4868. l = this.length;
  4869. if ( value === undefined ) {
  4870. return elem.nodeType === 1 ?
  4871. elem.innerHTML.replace( rinlinejQuery, "" ) :
  4872. undefined;
  4873. }
  4874. // See if we can take a shortcut and just use innerHTML
  4875. if ( typeof value === "string" && !rnoInnerhtml.test( value ) &&
  4876. ( support.htmlSerialize || !rnoshimcache.test( value ) ) &&
  4877. ( support.leadingWhitespace || !rleadingWhitespace.test( value ) ) &&
  4878. !wrapMap[ (rtagName.exec( value ) || [ "", "" ])[ 1 ].toLowerCase() ] ) {
  4879. value = value.replace( rxhtmlTag, "<$1></$2>" );
  4880. try {
  4881. for (; i < l; i++ ) {
  4882. // Remove element nodes and prevent memory leaks
  4883. elem = this[i] || {};
  4884. if ( elem.nodeType === 1 ) {
  4885. jQuery.cleanData( getAll( elem, false ) );
  4886. elem.innerHTML = value;
  4887. }
  4888. }
  4889. elem = 0;
  4890. // If using innerHTML throws an exception, use the fallback method
  4891. } catch(e) {}
  4892. }
  4893. if ( elem ) {
  4894. this.empty().append( value );
  4895. }
  4896. }, null, value, arguments.length );
  4897. },
  4898. replaceWith: function() {
  4899. var arg = arguments[ 0 ];
  4900. // Make the changes, replacing each context element with the new content
  4901. this.domManip( arguments, function( elem ) {
  4902. arg = this.parentNode;
  4903. jQuery.cleanData( getAll( this ) );
  4904. if ( arg ) {
  4905. arg.replaceChild( elem, this );
  4906. }
  4907. });
  4908. // Force removal if there was no new content (e.g., from empty arguments)
  4909. return arg && (arg.length || arg.nodeType) ? this : this.remove();
  4910. },
  4911. detach: function( selector ) {
  4912. return this.remove( selector, true );
  4913. },
  4914. domManip: function( args, callback ) {
  4915. // Flatten any nested arrays
  4916. args = concat.apply( [], args );
  4917. var first, node, hasScripts,
  4918. scripts, doc, fragment,
  4919. i = 0,
  4920. l = this.length,
  4921. set = this,
  4922. iNoClone = l - 1,
  4923. value = args[0],
  4924. isFunction = jQuery.isFunction( value );
  4925. // We can't cloneNode fragments that contain checked, in WebKit
  4926. if ( isFunction ||
  4927. ( l > 1 && typeof value === "string" &&
  4928. !support.checkClone && rchecked.test( value ) ) ) {
  4929. return this.each(function( index ) {
  4930. var self = set.eq( index );
  4931. if ( isFunction ) {
  4932. args[0] = value.call( this, index, self.html() );
  4933. }
  4934. self.domManip( args, callback );
  4935. });
  4936. }
  4937. if ( l ) {
  4938. fragment = jQuery.buildFragment( args, this[ 0 ].ownerDocument, false, this );
  4939. first = fragment.firstChild;
  4940. if ( fragment.childNodes.length === 1 ) {
  4941. fragment = first;
  4942. }
  4943. if ( first ) {
  4944. scripts = jQuery.map( getAll( fragment, "script" ), disableScript );
  4945. hasScripts = scripts.length;
  4946. // Use the original fragment for the last item instead of the first because it can end up
  4947. // being emptied incorrectly in certain situations (#8070).
  4948. for ( ; i < l; i++ ) {
  4949. node = fragment;
  4950. if ( i !== iNoClone ) {
  4951. node = jQuery.clone( node, true, true );
  4952. // Keep references to cloned scripts for later restoration
  4953. if ( hasScripts ) {
  4954. jQuery.merge( scripts, getAll( node, "script" ) );
  4955. }
  4956. }
  4957. callback.call( this[i], node, i );
  4958. }
  4959. if ( hasScripts ) {
  4960. doc = scripts[ scripts.length - 1 ].ownerDocument;
  4961. // Reenable scripts
  4962. jQuery.map( scripts, restoreScript );
  4963. // Evaluate executable scripts on first document insertion
  4964. for ( i = 0; i < hasScripts; i++ ) {
  4965. node = scripts[ i ];
  4966. if ( rscriptType.test( node.type || "" ) &&
  4967. !jQuery._data( node, "globalEval" ) && jQuery.contains( doc, node ) ) {
  4968. if ( node.src ) {
  4969. // Optional AJAX dependency, but won't run scripts if not present
  4970. if ( jQuery._evalUrl ) {
  4971. jQuery._evalUrl( node.src );
  4972. }
  4973. } else {
  4974. jQuery.globalEval( ( node.text || node.textContent || node.innerHTML || "" ).replace( rcleanScript, "" ) );
  4975. }
  4976. }
  4977. }
  4978. }
  4979. // Fix #11809: Avoid leaking memory
  4980. fragment = first = null;
  4981. }
  4982. }
  4983. return this;
  4984. }
  4985. });
  4986. jQuery.each({
  4987. appendTo: "append",
  4988. prependTo: "prepend",
  4989. insertBefore: "before",
  4990. insertAfter: "after",
  4991. replaceAll: "replaceWith"
  4992. }, function( name, original ) {
  4993. jQuery.fn[ name ] = function( selector ) {
  4994. var elems,
  4995. i = 0,
  4996. ret = [],
  4997. insert = jQuery( selector ),
  4998. last = insert.length - 1;
  4999. for ( ; i <= last; i++ ) {
  5000. elems = i === last ? this : this.clone(true);
  5001. jQuery( insert[i] )[ original ]( elems );
  5002. // Modern browsers can apply jQuery collections as arrays, but oldIE needs a .get()
  5003. push.apply( ret, elems.get() );
  5004. }
  5005. return this.pushStack( ret );
  5006. };
  5007. });
  5008. var iframe,
  5009. elemdisplay = {};
  5010. /**
  5011. * Retrieve the actual display of a element
  5012. * @param {String} name nodeName of the element
  5013. * @param {Object} doc Document object
  5014. */
  5015. // Called only from within defaultDisplay
  5016. function actualDisplay( name, doc ) {
  5017. var style,
  5018. elem = jQuery( doc.createElement( name ) ).appendTo( doc.body ),
  5019. // getDefaultComputedStyle might be reliably used only on attached element
  5020. display = window.getDefaultComputedStyle && ( style = window.getDefaultComputedStyle( elem[ 0 ] ) ) ?
  5021. // Use of this method is a temporary fix (more like optmization) until something better comes along,
  5022. // since it was removed from specification and supported only in FF
  5023. style.display : jQuery.css( elem[ 0 ], "display" );
  5024. // We don't have any data stored on the element,
  5025. // so use "detach" method as fast way to get rid of the element
  5026. elem.detach();
  5027. return display;
  5028. }
  5029. /**
  5030. * Try to determine the default display value of an element
  5031. * @param {String} nodeName
  5032. */
  5033. function defaultDisplay( nodeName ) {
  5034. var doc = document,
  5035. display = elemdisplay[ nodeName ];
  5036. if ( !display ) {
  5037. display = actualDisplay( nodeName, doc );
  5038. // If the simple way fails, read from inside an iframe
  5039. if ( display === "none" || !display ) {
  5040. // Use the already-created iframe if possible
  5041. iframe = (iframe || jQuery( "<iframe frameborder='0' width='0' height='0'/>" )).appendTo( doc.documentElement );
  5042. // Always write a new HTML skeleton so Webkit and Firefox don't choke on reuse
  5043. doc = ( iframe[ 0 ].contentWindow || iframe[ 0 ].contentDocument ).document;
  5044. // Support: IE
  5045. doc.write();
  5046. doc.close();
  5047. display = actualDisplay( nodeName, doc );
  5048. iframe.detach();
  5049. }
  5050. // Store the correct default display
  5051. elemdisplay[ nodeName ] = display;
  5052. }
  5053. return display;
  5054. }
  5055. (function() {
  5056. var shrinkWrapBlocksVal;
  5057. support.shrinkWrapBlocks = function() {
  5058. if ( shrinkWrapBlocksVal != null ) {
  5059. return shrinkWrapBlocksVal;
  5060. }
  5061. // Will be changed later if needed.
  5062. shrinkWrapBlocksVal = false;
  5063. // Minified: var b,c,d
  5064. var div, body, container;
  5065. body = document.getElementsByTagName( "body" )[ 0 ];
  5066. if ( !body || !body.style ) {
  5067. // Test fired too early or in an unsupported environment, exit.
  5068. return;
  5069. }
  5070. // Setup
  5071. div = document.createElement( "div" );
  5072. container = document.createElement( "div" );
  5073. container.style.cssText = "position:absolute;border:0;width:0;height:0;top:0;left:-9999px";
  5074. body.appendChild( container ).appendChild( div );
  5075. // Support: IE6
  5076. // Check if elements with layout shrink-wrap their children
  5077. if ( typeof div.style.zoom !== strundefined ) {
  5078. // Reset CSS: box-sizing; display; margin; border
  5079. div.style.cssText =
  5080. // Support: Firefox<29, Android 2.3
  5081. // Vendor-prefix box-sizing
  5082. "-webkit-box-sizing:content-box;-moz-box-sizing:content-box;" +
  5083. "box-sizing:content-box;display:block;margin:0;border:0;" +
  5084. "padding:1px;width:1px;zoom:1";
  5085. div.appendChild( document.createElement( "div" ) ).style.width = "5px";
  5086. shrinkWrapBlocksVal = div.offsetWidth !== 3;
  5087. }
  5088. body.removeChild( container );
  5089. return shrinkWrapBlocksVal;
  5090. };
  5091. })();
  5092. var rmargin = (/^margin/);
  5093. var rnumnonpx = new RegExp( "^(" + pnum + ")(?!px)[a-z%]+$", "i" );
  5094. var getStyles, curCSS,
  5095. rposition = /^(top|right|bottom|left)$/;
  5096. if ( window.getComputedStyle ) {
  5097. getStyles = function( elem ) {
  5098. return elem.ownerDocument.defaultView.getComputedStyle( elem, null );
  5099. };
  5100. curCSS = function( elem, name, computed ) {
  5101. var width, minWidth, maxWidth, ret,
  5102. style = elem.style;
  5103. computed = computed || getStyles( elem );
  5104. // getPropertyValue is only needed for .css('filter') in IE9, see #12537
  5105. ret = computed ? computed.getPropertyValue( name ) || computed[ name ] : undefined;
  5106. if ( computed ) {
  5107. if ( ret === "" && !jQuery.contains( elem.ownerDocument, elem ) ) {
  5108. ret = jQuery.style( elem, name );
  5109. }
  5110. // A tribute to the "awesome hack by Dean Edwards"
  5111. // Chrome < 17 and Safari 5.0 uses "computed value" instead of "used value" for margin-right
  5112. // Safari 5.1.7 (at least) returns percentage for a larger set of values, but width seems to be reliably pixels
  5113. // this is against the CSSOM draft spec: http://dev.w3.org/csswg/cssom/#resolved-values
  5114. if ( rnumnonpx.test( ret ) && rmargin.test( name ) ) {
  5115. // Remember the original values
  5116. width = style.width;
  5117. minWidth = style.minWidth;
  5118. maxWidth = style.maxWidth;
  5119. // Put in the new values to get a computed value out
  5120. style.minWidth = style.maxWidth = style.width = ret;
  5121. ret = computed.width;
  5122. // Revert the changed values
  5123. style.width = width;
  5124. style.minWidth = minWidth;
  5125. style.maxWidth = maxWidth;
  5126. }
  5127. }
  5128. // Support: IE
  5129. // IE returns zIndex value as an integer.
  5130. return ret === undefined ?
  5131. ret :
  5132. ret + "";
  5133. };
  5134. } else if ( document.documentElement.currentStyle ) {
  5135. getStyles = function( elem ) {
  5136. return elem.currentStyle;
  5137. };
  5138. curCSS = function( elem, name, computed ) {
  5139. var left, rs, rsLeft, ret,
  5140. style = elem.style;
  5141. computed = computed || getStyles( elem );
  5142. ret = computed ? computed[ name ] : undefined;
  5143. // Avoid setting ret to empty string here
  5144. // so we don't default to auto
  5145. if ( ret == null && style && style[ name ] ) {
  5146. ret = style[ name ];
  5147. }
  5148. // From the awesome hack by Dean Edwards
  5149. // http://erik.eae.net/archives/2007/07/27/18.54.15/#comment-102291
  5150. // If we're not dealing with a regular pixel number
  5151. // but a number that has a weird ending, we need to convert it to pixels
  5152. // but not position css attributes, as those are proportional to the parent element instead
  5153. // and we can't measure the parent instead because it might trigger a "stacking dolls" problem
  5154. if ( rnumnonpx.test( ret ) && !rposition.test( name ) ) {
  5155. // Remember the original values
  5156. left = style.left;
  5157. rs = elem.runtimeStyle;
  5158. rsLeft = rs && rs.left;
  5159. // Put in the new values to get a computed value out
  5160. if ( rsLeft ) {
  5161. rs.left = elem.currentStyle.left;
  5162. }
  5163. style.left = name === "fontSize" ? "1em" : ret;
  5164. ret = style.pixelLeft + "px";
  5165. // Revert the changed values
  5166. style.left = left;
  5167. if ( rsLeft ) {
  5168. rs.left = rsLeft;
  5169. }
  5170. }
  5171. // Support: IE
  5172. // IE returns zIndex value as an integer.
  5173. return ret === undefined ?
  5174. ret :
  5175. ret + "" || "auto";
  5176. };
  5177. }
  5178. function addGetHookIf( conditionFn, hookFn ) {
  5179. // Define the hook, we'll check on the first run if it's really needed.
  5180. return {
  5181. get: function() {
  5182. var condition = conditionFn();
  5183. if ( condition == null ) {
  5184. // The test was not ready at this point; screw the hook this time
  5185. // but check again when needed next time.
  5186. return;
  5187. }
  5188. if ( condition ) {
  5189. // Hook not needed (or it's not possible to use it due to missing dependency),
  5190. // remove it.
  5191. // Since there are no other hooks for marginRight, remove the whole object.
  5192. delete this.get;
  5193. return;
  5194. }
  5195. // Hook needed; redefine it so that the support test is not executed again.
  5196. return (this.get = hookFn).apply( this, arguments );
  5197. }
  5198. };
  5199. }
  5200. (function() {
  5201. // Minified: var b,c,d,e,f,g, h,i
  5202. var div, style, a, pixelPositionVal, boxSizingReliableVal,
  5203. reliableHiddenOffsetsVal, reliableMarginRightVal;
  5204. // Setup
  5205. div = document.createElement( "div" );
  5206. div.innerHTML = " <link/><table></table><a href='/a'>a</a><input type='checkbox'/>";
  5207. a = div.getElementsByTagName( "a" )[ 0 ];
  5208. style = a && a.style;
  5209. // Finish early in limited (non-browser) environments
  5210. if ( !style ) {
  5211. return;
  5212. }
  5213. style.cssText = "float:left;opacity:.5";
  5214. // Support: IE<9
  5215. // Make sure that element opacity exists (as opposed to filter)
  5216. support.opacity = style.opacity === "0.5";
  5217. // Verify style float existence
  5218. // (IE uses styleFloat instead of cssFloat)
  5219. support.cssFloat = !!style.cssFloat;
  5220. div.style.backgroundClip = "content-box";
  5221. div.cloneNode( true ).style.backgroundClip = "";
  5222. support.clearCloneStyle = div.style.backgroundClip === "content-box";
  5223. // Support: Firefox<29, Android 2.3
  5224. // Vendor-prefix box-sizing
  5225. support.boxSizing = style.boxSizing === "" || style.MozBoxSizing === "" ||
  5226. style.WebkitBoxSizing === "";
  5227. jQuery.extend(support, {
  5228. reliableHiddenOffsets: function() {
  5229. if ( reliableHiddenOffsetsVal == null ) {
  5230. computeStyleTests();
  5231. }
  5232. return reliableHiddenOffsetsVal;
  5233. },
  5234. boxSizingReliable: function() {
  5235. if ( boxSizingReliableVal == null ) {
  5236. computeStyleTests();
  5237. }
  5238. return boxSizingReliableVal;
  5239. },
  5240. pixelPosition: function() {
  5241. if ( pixelPositionVal == null ) {
  5242. computeStyleTests();
  5243. }
  5244. return pixelPositionVal;
  5245. },
  5246. // Support: Android 2.3
  5247. reliableMarginRight: function() {
  5248. if ( reliableMarginRightVal == null ) {
  5249. computeStyleTests();
  5250. }
  5251. return reliableMarginRightVal;
  5252. }
  5253. });
  5254. function computeStyleTests() {
  5255. // Minified: var b,c,d,j
  5256. var div, body, container, contents;
  5257. body = document.getElementsByTagName( "body" )[ 0 ];
  5258. if ( !body || !body.style ) {
  5259. // Test fired too early or in an unsupported environment, exit.
  5260. return;
  5261. }
  5262. // Setup
  5263. div = document.createElement( "div" );
  5264. container = document.createElement( "div" );
  5265. container.style.cssText = "position:absolute;border:0;width:0;height:0;top:0;left:-9999px";
  5266. body.appendChild( container ).appendChild( div );
  5267. div.style.cssText =
  5268. // Support: Firefox<29, Android 2.3
  5269. // Vendor-prefix box-sizing
  5270. "-webkit-box-sizing:border-box;-moz-box-sizing:border-box;" +
  5271. "box-sizing:border-box;display:block;margin-top:1%;top:1%;" +
  5272. "border:1px;padding:1px;width:4px;position:absolute";
  5273. // Support: IE<9
  5274. // Assume reasonable values in the absence of getComputedStyle
  5275. pixelPositionVal = boxSizingReliableVal = false;
  5276. reliableMarginRightVal = true;
  5277. // Check for getComputedStyle so that this code is not run in IE<9.
  5278. if ( window.getComputedStyle ) {
  5279. pixelPositionVal = ( window.getComputedStyle( div, null ) || {} ).top !== "1%";
  5280. boxSizingReliableVal =
  5281. ( window.getComputedStyle( div, null ) || { width: "4px" } ).width === "4px";
  5282. // Support: Android 2.3
  5283. // Div with explicit width and no margin-right incorrectly
  5284. // gets computed margin-right based on width of container (#3333)
  5285. // WebKit Bug 13343 - getComputedStyle returns wrong value for margin-right
  5286. contents = div.appendChild( document.createElement( "div" ) );
  5287. // Reset CSS: box-sizing; display; margin; border; padding
  5288. contents.style.cssText = div.style.cssText =
  5289. // Support: Firefox<29, Android 2.3
  5290. // Vendor-prefix box-sizing
  5291. "-webkit-box-sizing:content-box;-moz-box-sizing:content-box;" +
  5292. "box-sizing:content-box;display:block;margin:0;border:0;padding:0";
  5293. contents.style.marginRight = contents.style.width = "0";
  5294. div.style.width = "1px";
  5295. reliableMarginRightVal =
  5296. !parseFloat( ( window.getComputedStyle( contents, null ) || {} ).marginRight );
  5297. }
  5298. // Support: IE8
  5299. // Check if table cells still have offsetWidth/Height when they are set
  5300. // to display:none and there are still other visible table cells in a
  5301. // table row; if so, offsetWidth/Height are not reliable for use when
  5302. // determining if an element has been hidden directly using
  5303. // display:none (it is still safe to use offsets if a parent element is
  5304. // hidden; don safety goggles and see bug #4512 for more information).
  5305. div.innerHTML = "<table><tr><td></td><td>t</td></tr></table>";
  5306. contents = div.getElementsByTagName( "td" );
  5307. contents[ 0 ].style.cssText = "margin:0;border:0;padding:0;display:none";
  5308. reliableHiddenOffsetsVal = contents[ 0 ].offsetHeight === 0;
  5309. if ( reliableHiddenOffsetsVal ) {
  5310. contents[ 0 ].style.display = "";
  5311. contents[ 1 ].style.display = "none";
  5312. reliableHiddenOffsetsVal = contents[ 0 ].offsetHeight === 0;
  5313. }
  5314. body.removeChild( container );
  5315. }
  5316. })();
  5317. // A method for quickly swapping in/out CSS properties to get correct calculations.
  5318. jQuery.swap = function( elem, options, callback, args ) {
  5319. var ret, name,
  5320. old = {};
  5321. // Remember the old values, and insert the new ones
  5322. for ( name in options ) {
  5323. old[ name ] = elem.style[ name ];
  5324. elem.style[ name ] = options[ name ];
  5325. }
  5326. ret = callback.apply( elem, args || [] );
  5327. // Revert the old values
  5328. for ( name in options ) {
  5329. elem.style[ name ] = old[ name ];
  5330. }
  5331. return ret;
  5332. };
  5333. var
  5334. ralpha = /alpha\([^)]*\)/i,
  5335. ropacity = /opacity\s*=\s*([^)]*)/,
  5336. // swappable if display is none or starts with table except "table", "table-cell", or "table-caption"
  5337. // see here for display values: https://developer.mozilla.org/en-US/docs/CSS/display
  5338. rdisplayswap = /^(none|table(?!-c[ea]).+)/,
  5339. rnumsplit = new RegExp( "^(" + pnum + ")(.*)$", "i" ),
  5340. rrelNum = new RegExp( "^([+-])=(" + pnum + ")", "i" ),
  5341. cssShow = { position: "absolute", visibility: "hidden", display: "block" },
  5342. cssNormalTransform = {
  5343. letterSpacing: "0",
  5344. fontWeight: "400"
  5345. },
  5346. cssPrefixes = [ "Webkit", "O", "Moz", "ms" ];
  5347. // return a css property mapped to a potentially vendor prefixed property
  5348. function vendorPropName( style, name ) {
  5349. // shortcut for names that are not vendor prefixed
  5350. if ( name in style ) {
  5351. return name;
  5352. }
  5353. // check for vendor prefixed names
  5354. var capName = name.charAt(0).toUpperCase() + name.slice(1),
  5355. origName = name,
  5356. i = cssPrefixes.length;
  5357. while ( i-- ) {
  5358. name = cssPrefixes[ i ] + capName;
  5359. if ( name in style ) {
  5360. return name;
  5361. }
  5362. }
  5363. return origName;
  5364. }
  5365. function showHide( elements, show ) {
  5366. var display, elem, hidden,
  5367. values = [],
  5368. index = 0,
  5369. length = elements.length;
  5370. for ( ; index < length; index++ ) {
  5371. elem = elements[ index ];
  5372. if ( !elem.style ) {
  5373. continue;
  5374. }
  5375. values[ index ] = jQuery._data( elem, "olddisplay" );
  5376. display = elem.style.display;
  5377. if ( show ) {
  5378. // Reset the inline display of this element to learn if it is
  5379. // being hidden by cascaded rules or not
  5380. if ( !values[ index ] && display === "none" ) {
  5381. elem.style.display = "";
  5382. }
  5383. // Set elements which have been overridden with display: none
  5384. // in a stylesheet to whatever the default browser style is
  5385. // for such an element
  5386. if ( elem.style.display === "" && isHidden( elem ) ) {
  5387. values[ index ] = jQuery._data( elem, "olddisplay", defaultDisplay(elem.nodeName) );
  5388. }
  5389. } else {
  5390. hidden = isHidden( elem );
  5391. if ( display && display !== "none" || !hidden ) {
  5392. jQuery._data( elem, "olddisplay", hidden ? display : jQuery.css( elem, "display" ) );
  5393. }
  5394. }
  5395. }
  5396. // Set the display of most of the elements in a second loop
  5397. // to avoid the constant reflow
  5398. for ( index = 0; index < length; index++ ) {
  5399. elem = elements[ index ];
  5400. if ( !elem.style ) {
  5401. continue;
  5402. }
  5403. if ( !show || elem.style.display === "none" || elem.style.display === "" ) {
  5404. elem.style.display = show ? values[ index ] || "" : "none";
  5405. }
  5406. }
  5407. return elements;
  5408. }
  5409. function setPositiveNumber( elem, value, subtract ) {
  5410. var matches = rnumsplit.exec( value );
  5411. return matches ?
  5412. // Guard against undefined "subtract", e.g., when used as in cssHooks
  5413. Math.max( 0, matches[ 1 ] - ( subtract || 0 ) ) + ( matches[ 2 ] || "px" ) :
  5414. value;
  5415. }
  5416. function augmentWidthOrHeight( elem, name, extra, isBorderBox, styles ) {
  5417. var i = extra === ( isBorderBox ? "border" : "content" ) ?
  5418. // If we already have the right measurement, avoid augmentation
  5419. 4 :
  5420. // Otherwise initialize for horizontal or vertical properties
  5421. name === "width" ? 1 : 0,
  5422. val = 0;
  5423. for ( ; i < 4; i += 2 ) {
  5424. // both box models exclude margin, so add it if we want it
  5425. if ( extra === "margin" ) {
  5426. val += jQuery.css( elem, extra + cssExpand[ i ], true, styles );
  5427. }
  5428. if ( isBorderBox ) {
  5429. // border-box includes padding, so remove it if we want content
  5430. if ( extra === "content" ) {
  5431. val -= jQuery.css( elem, "padding" + cssExpand[ i ], true, styles );
  5432. }
  5433. // at this point, extra isn't border nor margin, so remove border
  5434. if ( extra !== "margin" ) {
  5435. val -= jQuery.css( elem, "border" + cssExpand[ i ] + "Width", true, styles );
  5436. }
  5437. } else {
  5438. // at this point, extra isn't content, so add padding
  5439. val += jQuery.css( elem, "padding" + cssExpand[ i ], true, styles );
  5440. // at this point, extra isn't content nor padding, so add border
  5441. if ( extra !== "padding" ) {
  5442. val += jQuery.css( elem, "border" + cssExpand[ i ] + "Width", true, styles );
  5443. }
  5444. }
  5445. }
  5446. return val;
  5447. }
  5448. function getWidthOrHeight( elem, name, extra ) {
  5449. // Start with offset property, which is equivalent to the border-box value
  5450. var valueIsBorderBox = true,
  5451. val = name === "width" ? elem.offsetWidth : elem.offsetHeight,
  5452. styles = getStyles( elem ),
  5453. isBorderBox = support.boxSizing && jQuery.css( elem, "boxSizing", false, styles ) === "border-box";
  5454. // some non-html elements return undefined for offsetWidth, so check for null/undefined
  5455. // svg - https://bugzilla.mozilla.org/show_bug.cgi?id=649285
  5456. // MathML - https://bugzilla.mozilla.org/show_bug.cgi?id=491668
  5457. if ( val <= 0 || val == null ) {
  5458. // Fall back to computed then uncomputed css if necessary
  5459. val = curCSS( elem, name, styles );
  5460. if ( val < 0 || val == null ) {
  5461. val = elem.style[ name ];
  5462. }
  5463. // Computed unit is not pixels. Stop here and return.
  5464. if ( rnumnonpx.test(val) ) {
  5465. return val;
  5466. }
  5467. // we need the check for style in case a browser which returns unreliable values
  5468. // for getComputedStyle silently falls back to the reliable elem.style
  5469. valueIsBorderBox = isBorderBox && ( support.boxSizingReliable() || val === elem.style[ name ] );
  5470. // Normalize "", auto, and prepare for extra
  5471. val = parseFloat( val ) || 0;
  5472. }
  5473. // use the active box-sizing model to add/subtract irrelevant styles
  5474. return ( val +
  5475. augmentWidthOrHeight(
  5476. elem,
  5477. name,
  5478. extra || ( isBorderBox ? "border" : "content" ),
  5479. valueIsBorderBox,
  5480. styles
  5481. )
  5482. ) + "px";
  5483. }
  5484. jQuery.extend({
  5485. // Add in style property hooks for overriding the default
  5486. // behavior of getting and setting a style property
  5487. cssHooks: {
  5488. opacity: {
  5489. get: function( elem, computed ) {
  5490. if ( computed ) {
  5491. // We should always get a number back from opacity
  5492. var ret = curCSS( elem, "opacity" );
  5493. return ret === "" ? "1" : ret;
  5494. }
  5495. }
  5496. }
  5497. },
  5498. // Don't automatically add "px" to these possibly-unitless properties
  5499. cssNumber: {
  5500. "columnCount": true,
  5501. "fillOpacity": true,
  5502. "flexGrow": true,
  5503. "flexShrink": true,
  5504. "fontWeight": true,
  5505. "lineHeight": true,
  5506. "opacity": true,
  5507. "order": true,
  5508. "orphans": true,
  5509. "widows": true,
  5510. "zIndex": true,
  5511. "zoom": true
  5512. },
  5513. // Add in properties whose names you wish to fix before
  5514. // setting or getting the value
  5515. cssProps: {
  5516. // normalize float css property
  5517. "float": support.cssFloat ? "cssFloat" : "styleFloat"
  5518. },
  5519. // Get and set the style property on a DOM Node
  5520. style: function( elem, name, value, extra ) {
  5521. // Don't set styles on text and comment nodes
  5522. if ( !elem || elem.nodeType === 3 || elem.nodeType === 8 || !elem.style ) {
  5523. return;
  5524. }
  5525. // Make sure that we're working with the right name
  5526. var ret, type, hooks,
  5527. origName = jQuery.camelCase( name ),
  5528. style = elem.style;
  5529. name = jQuery.cssProps[ origName ] || ( jQuery.cssProps[ origName ] = vendorPropName( style, origName ) );
  5530. // gets hook for the prefixed version
  5531. // followed by the unprefixed version
  5532. hooks = jQuery.cssHooks[ name ] || jQuery.cssHooks[ origName ];
  5533. // Check if we're setting a value
  5534. if ( value !== undefined ) {
  5535. type = typeof value;
  5536. // convert relative number strings (+= or -=) to relative numbers. #7345
  5537. if ( type === "string" && (ret = rrelNum.exec( value )) ) {
  5538. value = ( ret[1] + 1 ) * ret[2] + parseFloat( jQuery.css( elem, name ) );
  5539. // Fixes bug #9237
  5540. type = "number";
  5541. }
  5542. // Make sure that null and NaN values aren't set. See: #7116
  5543. if ( value == null || value !== value ) {
  5544. return;
  5545. }
  5546. // If a number was passed in, add 'px' to the (except for certain CSS properties)
  5547. if ( type === "number" && !jQuery.cssNumber[ origName ] ) {
  5548. value += "px";
  5549. }
  5550. // Fixes #8908, it can be done more correctly by specifing setters in cssHooks,
  5551. // but it would mean to define eight (for every problematic property) identical functions
  5552. if ( !support.clearCloneStyle && value === "" && name.indexOf("background") === 0 ) {
  5553. style[ name ] = "inherit";
  5554. }
  5555. // If a hook was provided, use that value, otherwise just set the specified value
  5556. if ( !hooks || !("set" in hooks) || (value = hooks.set( elem, value, extra )) !== undefined ) {
  5557. // Support: IE
  5558. // Swallow errors from 'invalid' CSS values (#5509)
  5559. try {
  5560. style[ name ] = value;
  5561. } catch(e) {}
  5562. }
  5563. } else {
  5564. // If a hook was provided get the non-computed value from there
  5565. if ( hooks && "get" in hooks && (ret = hooks.get( elem, false, extra )) !== undefined ) {
  5566. return ret;
  5567. }
  5568. // Otherwise just get the value from the style object
  5569. return style[ name ];
  5570. }
  5571. },
  5572. css: function( elem, name, extra, styles ) {
  5573. var num, val, hooks,
  5574. origName = jQuery.camelCase( name );
  5575. // Make sure that we're working with the right name
  5576. name = jQuery.cssProps[ origName ] || ( jQuery.cssProps[ origName ] = vendorPropName( elem.style, origName ) );
  5577. // gets hook for the prefixed version
  5578. // followed by the unprefixed version
  5579. hooks = jQuery.cssHooks[ name ] || jQuery.cssHooks[ origName ];
  5580. // If a hook was provided get the computed value from there
  5581. if ( hooks && "get" in hooks ) {
  5582. val = hooks.get( elem, true, extra );
  5583. }
  5584. // Otherwise, if a way to get the computed value exists, use that
  5585. if ( val === undefined ) {
  5586. val = curCSS( elem, name, styles );
  5587. }
  5588. //convert "normal" to computed value
  5589. if ( val === "normal" && name in cssNormalTransform ) {
  5590. val = cssNormalTransform[ name ];
  5591. }
  5592. // Return, converting to number if forced or a qualifier was provided and val looks numeric
  5593. if ( extra === "" || extra ) {
  5594. num = parseFloat( val );
  5595. return extra === true || jQuery.isNumeric( num ) ? num || 0 : val;
  5596. }
  5597. return val;
  5598. }
  5599. });
  5600. jQuery.each([ "height", "width" ], function( i, name ) {
  5601. jQuery.cssHooks[ name ] = {
  5602. get: function( elem, computed, extra ) {
  5603. if ( computed ) {
  5604. // certain elements can have dimension info if we invisibly show them
  5605. // however, it must have a current display style that would benefit from this
  5606. return rdisplayswap.test( jQuery.css( elem, "display" ) ) && elem.offsetWidth === 0 ?
  5607. jQuery.swap( elem, cssShow, function() {
  5608. return getWidthOrHeight( elem, name, extra );
  5609. }) :
  5610. getWidthOrHeight( elem, name, extra );
  5611. }
  5612. },
  5613. set: function( elem, value, extra ) {
  5614. var styles = extra && getStyles( elem );
  5615. return setPositiveNumber( elem, value, extra ?
  5616. augmentWidthOrHeight(
  5617. elem,
  5618. name,
  5619. extra,
  5620. support.boxSizing && jQuery.css( elem, "boxSizing", false, styles ) === "border-box",
  5621. styles
  5622. ) : 0
  5623. );
  5624. }
  5625. };
  5626. });
  5627. if ( !support.opacity ) {
  5628. jQuery.cssHooks.opacity = {
  5629. get: function( elem, computed ) {
  5630. // IE uses filters for opacity
  5631. return ropacity.test( (computed && elem.currentStyle ? elem.currentStyle.filter : elem.style.filter) || "" ) ?
  5632. ( 0.01 * parseFloat( RegExp.$1 ) ) + "" :
  5633. computed ? "1" : "";
  5634. },
  5635. set: function( elem, value ) {
  5636. var style = elem.style,
  5637. currentStyle = elem.currentStyle,
  5638. opacity = jQuery.isNumeric( value ) ? "alpha(opacity=" + value * 100 + ")" : "",
  5639. filter = currentStyle && currentStyle.filter || style.filter || "";
  5640. // IE has trouble with opacity if it does not have layout
  5641. // Force it by setting the zoom level
  5642. style.zoom = 1;
  5643. // if setting opacity to 1, and no other filters exist - attempt to remove filter attribute #6652
  5644. // if value === "", then remove inline opacity #12685
  5645. if ( ( value >= 1 || value === "" ) &&
  5646. jQuery.trim( filter.replace( ralpha, "" ) ) === "" &&
  5647. style.removeAttribute ) {
  5648. // Setting style.filter to null, "" & " " still leave "filter:" in the cssText
  5649. // if "filter:" is present at all, clearType is disabled, we want to avoid this
  5650. // style.removeAttribute is IE Only, but so apparently is this code path...
  5651. style.removeAttribute( "filter" );
  5652. // if there is no filter style applied in a css rule or unset inline opacity, we are done
  5653. if ( value === "" || currentStyle && !currentStyle.filter ) {
  5654. return;
  5655. }
  5656. }
  5657. // otherwise, set new filter values
  5658. style.filter = ralpha.test( filter ) ?
  5659. filter.replace( ralpha, opacity ) :
  5660. filter + " " + opacity;
  5661. }
  5662. };
  5663. }
  5664. jQuery.cssHooks.marginRight = addGetHookIf( support.reliableMarginRight,
  5665. function( elem, computed ) {
  5666. if ( computed ) {
  5667. // WebKit Bug 13343 - getComputedStyle returns wrong value for margin-right
  5668. // Work around by temporarily setting element display to inline-block
  5669. return jQuery.swap( elem, { "display": "inline-block" },
  5670. curCSS, [ elem, "marginRight" ] );
  5671. }
  5672. }
  5673. );
  5674. // These hooks are used by animate to expand properties
  5675. jQuery.each({
  5676. margin: "",
  5677. padding: "",
  5678. border: "Width"
  5679. }, function( prefix, suffix ) {
  5680. jQuery.cssHooks[ prefix + suffix ] = {
  5681. expand: function( value ) {
  5682. var i = 0,
  5683. expanded = {},
  5684. // assumes a single number if not a string
  5685. parts = typeof value === "string" ? value.split(" ") : [ value ];
  5686. for ( ; i < 4; i++ ) {
  5687. expanded[ prefix + cssExpand[ i ] + suffix ] =
  5688. parts[ i ] || parts[ i - 2 ] || parts[ 0 ];
  5689. }
  5690. return expanded;
  5691. }
  5692. };
  5693. if ( !rmargin.test( prefix ) ) {
  5694. jQuery.cssHooks[ prefix + suffix ].set = setPositiveNumber;
  5695. }
  5696. });
  5697. jQuery.fn.extend({
  5698. css: function( name, value ) {
  5699. return access( this, function( elem, name, value ) {
  5700. var styles, len,
  5701. map = {},
  5702. i = 0;
  5703. if ( jQuery.isArray( name ) ) {
  5704. styles = getStyles( elem );
  5705. len = name.length;
  5706. for ( ; i < len; i++ ) {
  5707. map[ name[ i ] ] = jQuery.css( elem, name[ i ], false, styles );
  5708. }
  5709. return map;
  5710. }
  5711. return value !== undefined ?
  5712. jQuery.style( elem, name, value ) :
  5713. jQuery.css( elem, name );
  5714. }, name, value, arguments.length > 1 );
  5715. },
  5716. show: function() {
  5717. return showHide( this, true );
  5718. },
  5719. hide: function() {
  5720. return showHide( this );
  5721. },
  5722. toggle: function( state ) {
  5723. if ( typeof state === "boolean" ) {
  5724. return state ? this.show() : this.hide();
  5725. }
  5726. return this.each(function() {
  5727. if ( isHidden( this ) ) {
  5728. jQuery( this ).show();
  5729. } else {
  5730. jQuery( this ).hide();
  5731. }
  5732. });
  5733. }
  5734. });
  5735. function Tween( elem, options, prop, end, easing ) {
  5736. return new Tween.prototype.init( elem, options, prop, end, easing );
  5737. }
  5738. jQuery.Tween = Tween;
  5739. Tween.prototype = {
  5740. constructor: Tween,
  5741. init: function( elem, options, prop, end, easing, unit ) {
  5742. this.elem = elem;
  5743. this.prop = prop;
  5744. this.easing = easing || "swing";
  5745. this.options = options;
  5746. this.start = this.now = this.cur();
  5747. this.end = end;
  5748. this.unit = unit || ( jQuery.cssNumber[ prop ] ? "" : "px" );
  5749. },
  5750. cur: function() {
  5751. var hooks = Tween.propHooks[ this.prop ];
  5752. return hooks && hooks.get ?
  5753. hooks.get( this ) :
  5754. Tween.propHooks._default.get( this );
  5755. },
  5756. run: function( percent ) {
  5757. var eased,
  5758. hooks = Tween.propHooks[ this.prop ];
  5759. if ( this.options.duration ) {
  5760. this.pos = eased = jQuery.easing[ this.easing ](
  5761. percent, this.options.duration * percent, 0, 1, this.options.duration
  5762. );
  5763. } else {
  5764. this.pos = eased = percent;
  5765. }
  5766. this.now = ( this.end - this.start ) * eased + this.start;
  5767. if ( this.options.step ) {
  5768. this.options.step.call( this.elem, this.now, this );
  5769. }
  5770. if ( hooks && hooks.set ) {
  5771. hooks.set( this );
  5772. } else {
  5773. Tween.propHooks._default.set( this );
  5774. }
  5775. return this;
  5776. }
  5777. };
  5778. Tween.prototype.init.prototype = Tween.prototype;
  5779. Tween.propHooks = {
  5780. _default: {
  5781. get: function( tween ) {
  5782. var result;
  5783. if ( tween.elem[ tween.prop ] != null &&
  5784. (!tween.elem.style || tween.elem.style[ tween.prop ] == null) ) {
  5785. return tween.elem[ tween.prop ];
  5786. }
  5787. // passing an empty string as a 3rd parameter to .css will automatically
  5788. // attempt a parseFloat and fallback to a string if the parse fails
  5789. // so, simple values such as "10px" are parsed to Float.
  5790. // complex values such as "rotate(1rad)" are returned as is.
  5791. result = jQuery.css( tween.elem, tween.prop, "" );
  5792. // Empty strings, null, undefined and "auto" are converted to 0.
  5793. return !result || result === "auto" ? 0 : result;
  5794. },
  5795. set: function( tween ) {
  5796. // use step hook for back compat - use cssHook if its there - use .style if its
  5797. // available and use plain properties where available
  5798. if ( jQuery.fx.step[ tween.prop ] ) {
  5799. jQuery.fx.step[ tween.prop ]( tween );
  5800. } else if ( tween.elem.style && ( tween.elem.style[ jQuery.cssProps[ tween.prop ] ] != null || jQuery.cssHooks[ tween.prop ] ) ) {
  5801. jQuery.style( tween.elem, tween.prop, tween.now + tween.unit );
  5802. } else {
  5803. tween.elem[ tween.prop ] = tween.now;
  5804. }
  5805. }
  5806. }
  5807. };
  5808. // Support: IE <=9
  5809. // Panic based approach to setting things on disconnected nodes
  5810. Tween.propHooks.scrollTop = Tween.propHooks.scrollLeft = {
  5811. set: function( tween ) {
  5812. if ( tween.elem.nodeType && tween.elem.parentNode ) {
  5813. tween.elem[ tween.prop ] = tween.now;
  5814. }
  5815. }
  5816. };
  5817. jQuery.easing = {
  5818. linear: function( p ) {
  5819. return p;
  5820. },
  5821. swing: function( p ) {
  5822. return 0.5 - Math.cos( p * Math.PI ) / 2;
  5823. }
  5824. };
  5825. jQuery.fx = Tween.prototype.init;
  5826. // Back Compat <1.8 extension point
  5827. jQuery.fx.step = {};
  5828. var
  5829. fxNow, timerId,
  5830. rfxtypes = /^(?:toggle|show|hide)$/,
  5831. rfxnum = new RegExp( "^(?:([+-])=|)(" + pnum + ")([a-z%]*)$", "i" ),
  5832. rrun = /queueHooks$/,
  5833. animationPrefilters = [ defaultPrefilter ],
  5834. tweeners = {
  5835. "*": [ function( prop, value ) {
  5836. var tween = this.createTween( prop, value ),
  5837. target = tween.cur(),
  5838. parts = rfxnum.exec( value ),
  5839. unit = parts && parts[ 3 ] || ( jQuery.cssNumber[ prop ] ? "" : "px" ),
  5840. // Starting value computation is required for potential unit mismatches
  5841. start = ( jQuery.cssNumber[ prop ] || unit !== "px" && +target ) &&
  5842. rfxnum.exec( jQuery.css( tween.elem, prop ) ),
  5843. scale = 1,
  5844. maxIterations = 20;
  5845. if ( start && start[ 3 ] !== unit ) {
  5846. // Trust units reported by jQuery.css
  5847. unit = unit || start[ 3 ];
  5848. // Make sure we update the tween properties later on
  5849. parts = parts || [];
  5850. // Iteratively approximate from a nonzero starting point
  5851. start = +target || 1;
  5852. do {
  5853. // If previous iteration zeroed out, double until we get *something*
  5854. // Use a string for doubling factor so we don't accidentally see scale as unchanged below
  5855. scale = scale || ".5";
  5856. // Adjust and apply
  5857. start = start / scale;
  5858. jQuery.style( tween.elem, prop, start + unit );
  5859. // Update scale, tolerating zero or NaN from tween.cur()
  5860. // And breaking the loop if scale is unchanged or perfect, or if we've just had enough
  5861. } while ( scale !== (scale = tween.cur() / target) && scale !== 1 && --maxIterations );
  5862. }
  5863. // Update tween properties
  5864. if ( parts ) {
  5865. start = tween.start = +start || +target || 0;
  5866. tween.unit = unit;
  5867. // If a +=/-= token was provided, we're doing a relative animation
  5868. tween.end = parts[ 1 ] ?
  5869. start + ( parts[ 1 ] + 1 ) * parts[ 2 ] :
  5870. +parts[ 2 ];
  5871. }
  5872. return tween;
  5873. } ]
  5874. };
  5875. // Animations created synchronously will run synchronously
  5876. function createFxNow() {
  5877. setTimeout(function() {
  5878. fxNow = undefined;
  5879. });
  5880. return ( fxNow = jQuery.now() );
  5881. }
  5882. // Generate parameters to create a standard animation
  5883. function genFx( type, includeWidth ) {
  5884. var which,
  5885. attrs = { height: type },
  5886. i = 0;
  5887. // if we include width, step value is 1 to do all cssExpand values,
  5888. // if we don't include width, step value is 2 to skip over Left and Right
  5889. includeWidth = includeWidth ? 1 : 0;
  5890. for ( ; i < 4 ; i += 2 - includeWidth ) {
  5891. which = cssExpand[ i ];
  5892. attrs[ "margin" + which ] = attrs[ "padding" + which ] = type;
  5893. }
  5894. if ( includeWidth ) {
  5895. attrs.opacity = attrs.width = type;
  5896. }
  5897. return attrs;
  5898. }
  5899. function createTween( value, prop, animation ) {
  5900. var tween,
  5901. collection = ( tweeners[ prop ] || [] ).concat( tweeners[ "*" ] ),
  5902. index = 0,
  5903. length = collection.length;
  5904. for ( ; index < length; index++ ) {
  5905. if ( (tween = collection[ index ].call( animation, prop, value )) ) {
  5906. // we're done with this property
  5907. return tween;
  5908. }
  5909. }
  5910. }
  5911. function defaultPrefilter( elem, props, opts ) {
  5912. /* jshint validthis: true */
  5913. var prop, value, toggle, tween, hooks, oldfire, display, checkDisplay,
  5914. anim = this,
  5915. orig = {},
  5916. style = elem.style,
  5917. hidden = elem.nodeType && isHidden( elem ),
  5918. dataShow = jQuery._data( elem, "fxshow" );
  5919. // handle queue: false promises
  5920. if ( !opts.queue ) {
  5921. hooks = jQuery._queueHooks( elem, "fx" );
  5922. if ( hooks.unqueued == null ) {
  5923. hooks.unqueued = 0;
  5924. oldfire = hooks.empty.fire;
  5925. hooks.empty.fire = function() {
  5926. if ( !hooks.unqueued ) {
  5927. oldfire();
  5928. }
  5929. };
  5930. }
  5931. hooks.unqueued++;
  5932. anim.always(function() {
  5933. // doing this makes sure that the complete handler will be called
  5934. // before this completes
  5935. anim.always(function() {
  5936. hooks.unqueued--;
  5937. if ( !jQuery.queue( elem, "fx" ).length ) {
  5938. hooks.empty.fire();
  5939. }
  5940. });
  5941. });
  5942. }
  5943. // height/width overflow pass
  5944. if ( elem.nodeType === 1 && ( "height" in props || "width" in props ) ) {
  5945. // Make sure that nothing sneaks out
  5946. // Record all 3 overflow attributes because IE does not
  5947. // change the overflow attribute when overflowX and
  5948. // overflowY are set to the same value
  5949. opts.overflow = [ style.overflow, style.overflowX, style.overflowY ];
  5950. // Set display property to inline-block for height/width
  5951. // animations on inline elements that are having width/height animated
  5952. display = jQuery.css( elem, "display" );
  5953. // Test default display if display is currently "none"
  5954. checkDisplay = display === "none" ?
  5955. jQuery._data( elem, "olddisplay" ) || defaultDisplay( elem.nodeName ) : display;
  5956. if ( checkDisplay === "inline" && jQuery.css( elem, "float" ) === "none" ) {
  5957. // inline-level elements accept inline-block;
  5958. // block-level elements need to be inline with layout
  5959. if ( !support.inlineBlockNeedsLayout || defaultDisplay( elem.nodeName ) === "inline" ) {
  5960. style.display = "inline-block";
  5961. } else {
  5962. style.zoom = 1;
  5963. }
  5964. }
  5965. }
  5966. if ( opts.overflow ) {
  5967. style.overflow = "hidden";
  5968. if ( !support.shrinkWrapBlocks() ) {
  5969. anim.always(function() {
  5970. style.overflow = opts.overflow[ 0 ];
  5971. style.overflowX = opts.overflow[ 1 ];
  5972. style.overflowY = opts.overflow[ 2 ];
  5973. });
  5974. }
  5975. }
  5976. // show/hide pass
  5977. for ( prop in props ) {
  5978. value = props[ prop ];
  5979. if ( rfxtypes.exec( value ) ) {
  5980. delete props[ prop ];
  5981. toggle = toggle || value === "toggle";
  5982. if ( value === ( hidden ? "hide" : "show" ) ) {
  5983. // 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
  5984. if ( value === "show" && dataShow && dataShow[ prop ] !== undefined ) {
  5985. hidden = true;
  5986. } else {
  5987. continue;
  5988. }
  5989. }
  5990. orig[ prop ] = dataShow && dataShow[ prop ] || jQuery.style( elem, prop );
  5991. // Any non-fx value stops us from restoring the original display value
  5992. } else {
  5993. display = undefined;
  5994. }
  5995. }
  5996. if ( !jQuery.isEmptyObject( orig ) ) {
  5997. if ( dataShow ) {
  5998. if ( "hidden" in dataShow ) {
  5999. hidden = dataShow.hidden;
  6000. }
  6001. } else {
  6002. dataShow = jQuery._data( elem, "fxshow", {} );
  6003. }
  6004. // store state if its toggle - enables .stop().toggle() to "reverse"
  6005. if ( toggle ) {
  6006. dataShow.hidden = !hidden;
  6007. }
  6008. if ( hidden ) {
  6009. jQuery( elem ).show();
  6010. } else {
  6011. anim.done(function() {
  6012. jQuery( elem ).hide();
  6013. });
  6014. }
  6015. anim.done(function() {
  6016. var prop;
  6017. jQuery._removeData( elem, "fxshow" );
  6018. for ( prop in orig ) {
  6019. jQuery.style( elem, prop, orig[ prop ] );
  6020. }
  6021. });
  6022. for ( prop in orig ) {
  6023. tween = createTween( hidden ? dataShow[ prop ] : 0, prop, anim );
  6024. if ( !( prop in dataShow ) ) {
  6025. dataShow[ prop ] = tween.start;
  6026. if ( hidden ) {
  6027. tween.end = tween.start;
  6028. tween.start = prop === "width" || prop === "height" ? 1 : 0;
  6029. }
  6030. }
  6031. }
  6032. // If this is a noop like .hide().hide(), restore an overwritten display value
  6033. } else if ( (display === "none" ? defaultDisplay( elem.nodeName ) : display) === "inline" ) {
  6034. style.display = display;
  6035. }
  6036. }
  6037. function propFilter( props, specialEasing ) {
  6038. var index, name, easing, value, hooks;
  6039. // camelCase, specialEasing and expand cssHook pass
  6040. for ( index in props ) {
  6041. name = jQuery.camelCase( index );
  6042. easing = specialEasing[ name ];
  6043. value = props[ index ];
  6044. if ( jQuery.isArray( value ) ) {
  6045. easing = value[ 1 ];
  6046. value = props[ index ] = value[ 0 ];
  6047. }
  6048. if ( index !== name ) {
  6049. props[ name ] = value;
  6050. delete props[ index ];
  6051. }
  6052. hooks = jQuery.cssHooks[ name ];
  6053. if ( hooks && "expand" in hooks ) {
  6054. value = hooks.expand( value );
  6055. delete props[ name ];
  6056. // not quite $.extend, this wont overwrite keys already present.
  6057. // also - reusing 'index' from above because we have the correct "name"
  6058. for ( index in value ) {
  6059. if ( !( index in props ) ) {
  6060. props[ index ] = value[ index ];
  6061. specialEasing[ index ] = easing;
  6062. }
  6063. }
  6064. } else {
  6065. specialEasing[ name ] = easing;
  6066. }
  6067. }
  6068. }
  6069. function Animation( elem, properties, options ) {
  6070. var result,
  6071. stopped,
  6072. index = 0,
  6073. length = animationPrefilters.length,
  6074. deferred = jQuery.Deferred().always( function() {
  6075. // don't match elem in the :animated selector
  6076. delete tick.elem;
  6077. }),
  6078. tick = function() {
  6079. if ( stopped ) {
  6080. return false;
  6081. }
  6082. var currentTime = fxNow || createFxNow(),
  6083. remaining = Math.max( 0, animation.startTime + animation.duration - currentTime ),
  6084. // archaic crash bug won't allow us to use 1 - ( 0.5 || 0 ) (#12497)
  6085. temp = remaining / animation.duration || 0,
  6086. percent = 1 - temp,
  6087. index = 0,
  6088. length = animation.tweens.length;
  6089. for ( ; index < length ; index++ ) {
  6090. animation.tweens[ index ].run( percent );
  6091. }
  6092. deferred.notifyWith( elem, [ animation, percent, remaining ]);
  6093. if ( percent < 1 && length ) {
  6094. return remaining;
  6095. } else {
  6096. deferred.resolveWith( elem, [ animation ] );
  6097. return false;
  6098. }
  6099. },
  6100. animation = deferred.promise({
  6101. elem: elem,
  6102. props: jQuery.extend( {}, properties ),
  6103. opts: jQuery.extend( true, { specialEasing: {} }, options ),
  6104. originalProperties: properties,
  6105. originalOptions: options,
  6106. startTime: fxNow || createFxNow(),
  6107. duration: options.duration,
  6108. tweens: [],
  6109. createTween: function( prop, end ) {
  6110. var tween = jQuery.Tween( elem, animation.opts, prop, end,
  6111. animation.opts.specialEasing[ prop ] || animation.opts.easing );
  6112. animation.tweens.push( tween );
  6113. return tween;
  6114. },
  6115. stop: function( gotoEnd ) {
  6116. var index = 0,
  6117. // if we are going to the end, we want to run all the tweens
  6118. // otherwise we skip this part
  6119. length = gotoEnd ? animation.tweens.length : 0;
  6120. if ( stopped ) {
  6121. return this;
  6122. }
  6123. stopped = true;
  6124. for ( ; index < length ; index++ ) {
  6125. animation.tweens[ index ].run( 1 );
  6126. }
  6127. // resolve when we played the last frame
  6128. // otherwise, reject
  6129. if ( gotoEnd ) {
  6130. deferred.resolveWith( elem, [ animation, gotoEnd ] );
  6131. } else {
  6132. deferred.rejectWith( elem, [ animation, gotoEnd ] );
  6133. }
  6134. return this;
  6135. }
  6136. }),
  6137. props = animation.props;
  6138. propFilter( props, animation.opts.specialEasing );
  6139. for ( ; index < length ; index++ ) {
  6140. result = animationPrefilters[ index ].call( animation, elem, props, animation.opts );
  6141. if ( result ) {
  6142. return result;
  6143. }
  6144. }
  6145. jQuery.map( props, createTween, animation );
  6146. if ( jQuery.isFunction( animation.opts.start ) ) {
  6147. animation.opts.start.call( elem, animation );
  6148. }
  6149. jQuery.fx.timer(
  6150. jQuery.extend( tick, {
  6151. elem: elem,
  6152. anim: animation,
  6153. queue: animation.opts.queue
  6154. })
  6155. );
  6156. // attach callbacks from options
  6157. return animation.progress( animation.opts.progress )
  6158. .done( animation.opts.done, animation.opts.complete )
  6159. .fail( animation.opts.fail )
  6160. .always( animation.opts.always );
  6161. }
  6162. jQuery.Animation = jQuery.extend( Animation, {
  6163. tweener: function( props, callback ) {
  6164. if ( jQuery.isFunction( props ) ) {
  6165. callback = props;
  6166. props = [ "*" ];
  6167. } else {
  6168. props = props.split(" ");
  6169. }
  6170. var prop,
  6171. index = 0,
  6172. length = props.length;
  6173. for ( ; index < length ; index++ ) {
  6174. prop = props[ index ];
  6175. tweeners[ prop ] = tweeners[ prop ] || [];
  6176. tweeners[ prop ].unshift( callback );
  6177. }
  6178. },
  6179. prefilter: function( callback, prepend ) {
  6180. if ( prepend ) {
  6181. animationPrefilters.unshift( callback );
  6182. } else {
  6183. animationPrefilters.push( callback );
  6184. }
  6185. }
  6186. });
  6187. jQuery.speed = function( speed, easing, fn ) {
  6188. var opt = speed && typeof speed === "object" ? jQuery.extend( {}, speed ) : {
  6189. complete: fn || !fn && easing ||
  6190. jQuery.isFunction( speed ) && speed,
  6191. duration: speed,
  6192. easing: fn && easing || easing && !jQuery.isFunction( easing ) && easing
  6193. };
  6194. opt.duration = jQuery.fx.off ? 0 : typeof opt.duration === "number" ? opt.duration :
  6195. opt.duration in jQuery.fx.speeds ? jQuery.fx.speeds[ opt.duration ] : jQuery.fx.speeds._default;
  6196. // normalize opt.queue - true/undefined/null -> "fx"
  6197. if ( opt.queue == null || opt.queue === true ) {
  6198. opt.queue = "fx";
  6199. }
  6200. // Queueing
  6201. opt.old = opt.complete;
  6202. opt.complete = function() {
  6203. if ( jQuery.isFunction( opt.old ) ) {
  6204. opt.old.call( this );
  6205. }
  6206. if ( opt.queue ) {
  6207. jQuery.dequeue( this, opt.queue );
  6208. }
  6209. };
  6210. return opt;
  6211. };
  6212. jQuery.fn.extend({
  6213. fadeTo: function( speed, to, easing, callback ) {
  6214. // show any hidden elements after setting opacity to 0
  6215. return this.filter( isHidden ).css( "opacity", 0 ).show()
  6216. // animate to the value specified
  6217. .end().animate({ opacity: to }, speed, easing, callback );
  6218. },
  6219. animate: function( prop, speed, easing, callback ) {
  6220. var empty = jQuery.isEmptyObject( prop ),
  6221. optall = jQuery.speed( speed, easing, callback ),
  6222. doAnimation = function() {
  6223. // Operate on a copy of prop so per-property easing won't be lost
  6224. var anim = Animation( this, jQuery.extend( {}, prop ), optall );
  6225. // Empty animations, or finishing resolves immediately
  6226. if ( empty || jQuery._data( this, "finish" ) ) {
  6227. anim.stop( true );
  6228. }
  6229. };
  6230. doAnimation.finish = doAnimation;
  6231. return empty || optall.queue === false ?
  6232. this.each( doAnimation ) :
  6233. this.queue( optall.queue, doAnimation );
  6234. },
  6235. stop: function( type, clearQueue, gotoEnd ) {
  6236. var stopQueue = function( hooks ) {
  6237. var stop = hooks.stop;
  6238. delete hooks.stop;
  6239. stop( gotoEnd );
  6240. };
  6241. if ( typeof type !== "string" ) {
  6242. gotoEnd = clearQueue;
  6243. clearQueue = type;
  6244. type = undefined;
  6245. }
  6246. if ( clearQueue && type !== false ) {
  6247. this.queue( type || "fx", [] );
  6248. }
  6249. return this.each(function() {
  6250. var dequeue = true,
  6251. index = type != null && type + "queueHooks",
  6252. timers = jQuery.timers,
  6253. data = jQuery._data( this );
  6254. if ( index ) {
  6255. if ( data[ index ] && data[ index ].stop ) {
  6256. stopQueue( data[ index ] );
  6257. }
  6258. } else {
  6259. for ( index in data ) {
  6260. if ( data[ index ] && data[ index ].stop && rrun.test( index ) ) {
  6261. stopQueue( data[ index ] );
  6262. }
  6263. }
  6264. }
  6265. for ( index = timers.length; index--; ) {
  6266. if ( timers[ index ].elem === this && (type == null || timers[ index ].queue === type) ) {
  6267. timers[ index ].anim.stop( gotoEnd );
  6268. dequeue = false;
  6269. timers.splice( index, 1 );
  6270. }
  6271. }
  6272. // start the next in the queue if the last step wasn't forced
  6273. // timers currently will call their complete callbacks, which will dequeue
  6274. // but only if they were gotoEnd
  6275. if ( dequeue || !gotoEnd ) {
  6276. jQuery.dequeue( this, type );
  6277. }
  6278. });
  6279. },
  6280. finish: function( type ) {
  6281. if ( type !== false ) {
  6282. type = type || "fx";
  6283. }
  6284. return this.each(function() {
  6285. var index,
  6286. data = jQuery._data( this ),
  6287. queue = data[ type + "queue" ],
  6288. hooks = data[ type + "queueHooks" ],
  6289. timers = jQuery.timers,
  6290. length = queue ? queue.length : 0;
  6291. // enable finishing flag on private data
  6292. data.finish = true;
  6293. // empty the queue first
  6294. jQuery.queue( this, type, [] );
  6295. if ( hooks && hooks.stop ) {
  6296. hooks.stop.call( this, true );
  6297. }
  6298. // look for any active animations, and finish them
  6299. for ( index = timers.length; index--; ) {
  6300. if ( timers[ index ].elem === this && timers[ index ].queue === type ) {
  6301. timers[ index ].anim.stop( true );
  6302. timers.splice( index, 1 );
  6303. }
  6304. }
  6305. // look for any animations in the old queue and finish them
  6306. for ( index = 0; index < length; index++ ) {
  6307. if ( queue[ index ] && queue[ index ].finish ) {
  6308. queue[ index ].finish.call( this );
  6309. }
  6310. }
  6311. // turn off finishing flag
  6312. delete data.finish;
  6313. });
  6314. }
  6315. });
  6316. jQuery.each([ "toggle", "show", "hide" ], function( i, name ) {
  6317. var cssFn = jQuery.fn[ name ];
  6318. jQuery.fn[ name ] = function( speed, easing, callback ) {
  6319. return speed == null || typeof speed === "boolean" ?
  6320. cssFn.apply( this, arguments ) :
  6321. this.animate( genFx( name, true ), speed, easing, callback );
  6322. };
  6323. });
  6324. // Generate shortcuts for custom animations
  6325. jQuery.each({
  6326. slideDown: genFx("show"),
  6327. slideUp: genFx("hide"),
  6328. slideToggle: genFx("toggle"),
  6329. fadeIn: { opacity: "show" },
  6330. fadeOut: { opacity: "hide" },
  6331. fadeToggle: { opacity: "toggle" }
  6332. }, function( name, props ) {
  6333. jQuery.fn[ name ] = function( speed, easing, callback ) {
  6334. return this.animate( props, speed, easing, callback );
  6335. };
  6336. });
  6337. jQuery.timers = [];
  6338. jQuery.fx.tick = function() {
  6339. var timer,
  6340. timers = jQuery.timers,
  6341. i = 0;
  6342. fxNow = jQuery.now();
  6343. for ( ; i < timers.length; i++ ) {
  6344. timer = timers[ i ];
  6345. // Checks the timer has not already been removed
  6346. if ( !timer() && timers[ i ] === timer ) {
  6347. timers.splice( i--, 1 );
  6348. }
  6349. }
  6350. if ( !timers.length ) {
  6351. jQuery.fx.stop();
  6352. }
  6353. fxNow = undefined;
  6354. };
  6355. jQuery.fx.timer = function( timer ) {
  6356. jQuery.timers.push( timer );
  6357. if ( timer() ) {
  6358. jQuery.fx.start();
  6359. } else {
  6360. jQuery.timers.pop();
  6361. }
  6362. };
  6363. jQuery.fx.interval = 13;
  6364. jQuery.fx.start = function() {
  6365. if ( !timerId ) {
  6366. timerId = setInterval( jQuery.fx.tick, jQuery.fx.interval );
  6367. }
  6368. };
  6369. jQuery.fx.stop = function() {
  6370. clearInterval( timerId );
  6371. timerId = null;
  6372. };
  6373. jQuery.fx.speeds = {
  6374. slow: 600,
  6375. fast: 200,
  6376. // Default speed
  6377. _default: 400
  6378. };
  6379. // Based off of the plugin by Clint Helfers, with permission.
  6380. // http://blindsignals.com/index.php/2009/07/jquery-delay/
  6381. jQuery.fn.delay = function( time, type ) {
  6382. time = jQuery.fx ? jQuery.fx.speeds[ time ] || time : time;
  6383. type = type || "fx";
  6384. return this.queue( type, function( next, hooks ) {
  6385. var timeout = setTimeout( next, time );
  6386. hooks.stop = function() {
  6387. clearTimeout( timeout );
  6388. };
  6389. });
  6390. };
  6391. (function() {
  6392. // Minified: var a,b,c,d,e
  6393. var input, div, select, a, opt;
  6394. // Setup
  6395. div = document.createElement( "div" );
  6396. div.setAttribute( "className", "t" );
  6397. div.innerHTML = " <link/><table></table><a href='/a'>a</a><input type='checkbox'/>";
  6398. a = div.getElementsByTagName("a")[ 0 ];
  6399. // First batch of tests.
  6400. select = document.createElement("select");
  6401. opt = select.appendChild( document.createElement("option") );
  6402. input = div.getElementsByTagName("input")[ 0 ];
  6403. a.style.cssText = "top:1px";
  6404. // Test setAttribute on camelCase class. If it works, we need attrFixes when doing get/setAttribute (ie6/7)
  6405. support.getSetAttribute = div.className !== "t";
  6406. // Get the style information from getAttribute
  6407. // (IE uses .cssText instead)
  6408. support.style = /top/.test( a.getAttribute("style") );
  6409. // Make sure that URLs aren't manipulated
  6410. // (IE normalizes it by default)
  6411. support.hrefNormalized = a.getAttribute("href") === "/a";
  6412. // Check the default checkbox/radio value ("" on WebKit; "on" elsewhere)
  6413. support.checkOn = !!input.value;
  6414. // Make sure that a selected-by-default option has a working selected property.
  6415. // (WebKit defaults to false instead of true, IE too, if it's in an optgroup)
  6416. support.optSelected = opt.selected;
  6417. // Tests for enctype support on a form (#6743)
  6418. support.enctype = !!document.createElement("form").enctype;
  6419. // Make sure that the options inside disabled selects aren't marked as disabled
  6420. // (WebKit marks them as disabled)
  6421. select.disabled = true;
  6422. support.optDisabled = !opt.disabled;
  6423. // Support: IE8 only
  6424. // Check if we can trust getAttribute("value")
  6425. input = document.createElement( "input" );
  6426. input.setAttribute( "value", "" );
  6427. support.input = input.getAttribute( "value" ) === "";
  6428. // Check if an input maintains its value after becoming a radio
  6429. input.value = "t";
  6430. input.setAttribute( "type", "radio" );
  6431. support.radioValue = input.value === "t";
  6432. })();
  6433. var rreturn = /\r/g;
  6434. jQuery.fn.extend({
  6435. val: function( value ) {
  6436. var hooks, ret, isFunction,
  6437. elem = this[0];
  6438. if ( !arguments.length ) {
  6439. if ( elem ) {
  6440. hooks = jQuery.valHooks[ elem.type ] || jQuery.valHooks[ elem.nodeName.toLowerCase() ];
  6441. if ( hooks && "get" in hooks && (ret = hooks.get( elem, "value" )) !== undefined ) {
  6442. return ret;
  6443. }
  6444. ret = elem.value;
  6445. return typeof ret === "string" ?
  6446. // handle most common string cases
  6447. ret.replace(rreturn, "") :
  6448. // handle cases where value is null/undef or number
  6449. ret == null ? "" : ret;
  6450. }
  6451. return;
  6452. }
  6453. isFunction = jQuery.isFunction( value );
  6454. return this.each(function( i ) {
  6455. var val;
  6456. if ( this.nodeType !== 1 ) {
  6457. return;
  6458. }
  6459. if ( isFunction ) {
  6460. val = value.call( this, i, jQuery( this ).val() );
  6461. } else {
  6462. val = value;
  6463. }
  6464. // Treat null/undefined as ""; convert numbers to string
  6465. if ( val == null ) {
  6466. val = "";
  6467. } else if ( typeof val === "number" ) {
  6468. val += "";
  6469. } else if ( jQuery.isArray( val ) ) {
  6470. val = jQuery.map( val, function( value ) {
  6471. return value == null ? "" : value + "";
  6472. });
  6473. }
  6474. hooks = jQuery.valHooks[ this.type ] || jQuery.valHooks[ this.nodeName.toLowerCase() ];
  6475. // If set returns undefined, fall back to normal setting
  6476. if ( !hooks || !("set" in hooks) || hooks.set( this, val, "value" ) === undefined ) {
  6477. this.value = val;
  6478. }
  6479. });
  6480. }
  6481. });
  6482. jQuery.extend({
  6483. valHooks: {
  6484. option: {
  6485. get: function( elem ) {
  6486. var val = jQuery.find.attr( elem, "value" );
  6487. return val != null ?
  6488. val :
  6489. // Support: IE10-11+
  6490. // option.text throws exceptions (#14686, #14858)
  6491. jQuery.trim( jQuery.text( elem ) );
  6492. }
  6493. },
  6494. select: {
  6495. get: function( elem ) {
  6496. var value, option,
  6497. options = elem.options,
  6498. index = elem.selectedIndex,
  6499. one = elem.type === "select-one" || index < 0,
  6500. values = one ? null : [],
  6501. max = one ? index + 1 : options.length,
  6502. i = index < 0 ?
  6503. max :
  6504. one ? index : 0;
  6505. // Loop through all the selected options
  6506. for ( ; i < max; i++ ) {
  6507. option = options[ i ];
  6508. // oldIE doesn't update selected after form reset (#2551)
  6509. if ( ( option.selected || i === index ) &&
  6510. // Don't return options that are disabled or in a disabled optgroup
  6511. ( support.optDisabled ? !option.disabled : option.getAttribute("disabled") === null ) &&
  6512. ( !option.parentNode.disabled || !jQuery.nodeName( option.parentNode, "optgroup" ) ) ) {
  6513. // Get the specific value for the option
  6514. value = jQuery( option ).val();
  6515. // We don't need an array for one selects
  6516. if ( one ) {
  6517. return value;
  6518. }
  6519. // Multi-Selects return an array
  6520. values.push( value );
  6521. }
  6522. }
  6523. return values;
  6524. },
  6525. set: function( elem, value ) {
  6526. var optionSet, option,
  6527. options = elem.options,
  6528. values = jQuery.makeArray( value ),
  6529. i = options.length;
  6530. while ( i-- ) {
  6531. option = options[ i ];
  6532. if ( jQuery.inArray( jQuery.valHooks.option.get( option ), values ) >= 0 ) {
  6533. // Support: IE6
  6534. // When new option element is added to select box we need to
  6535. // force reflow of newly added node in order to workaround delay
  6536. // of initialization properties
  6537. try {
  6538. option.selected = optionSet = true;
  6539. } catch ( _ ) {
  6540. // Will be executed only in IE6
  6541. option.scrollHeight;
  6542. }
  6543. } else {
  6544. option.selected = false;
  6545. }
  6546. }
  6547. // Force browsers to behave consistently when non-matching value is set
  6548. if ( !optionSet ) {
  6549. elem.selectedIndex = -1;
  6550. }
  6551. return options;
  6552. }
  6553. }
  6554. }
  6555. });
  6556. // Radios and checkboxes getter/setter
  6557. jQuery.each([ "radio", "checkbox" ], function() {
  6558. jQuery.valHooks[ this ] = {
  6559. set: function( elem, value ) {
  6560. if ( jQuery.isArray( value ) ) {
  6561. return ( elem.checked = jQuery.inArray( jQuery(elem).val(), value ) >= 0 );
  6562. }
  6563. }
  6564. };
  6565. if ( !support.checkOn ) {
  6566. jQuery.valHooks[ this ].get = function( elem ) {
  6567. // Support: Webkit
  6568. // "" is returned instead of "on" if a value isn't specified
  6569. return elem.getAttribute("value") === null ? "on" : elem.value;
  6570. };
  6571. }
  6572. });
  6573. var nodeHook, boolHook,
  6574. attrHandle = jQuery.expr.attrHandle,
  6575. ruseDefault = /^(?:checked|selected)$/i,
  6576. getSetAttribute = support.getSetAttribute,
  6577. getSetInput = support.input;
  6578. jQuery.fn.extend({
  6579. attr: function( name, value ) {
  6580. return access( this, jQuery.attr, name, value, arguments.length > 1 );
  6581. },
  6582. removeAttr: function( name ) {
  6583. return this.each(function() {
  6584. jQuery.removeAttr( this, name );
  6585. });
  6586. }
  6587. });
  6588. jQuery.extend({
  6589. attr: function( elem, name, value ) {
  6590. var hooks, ret,
  6591. nType = elem.nodeType;
  6592. // don't get/set attributes on text, comment and attribute nodes
  6593. if ( !elem || nType === 3 || nType === 8 || nType === 2 ) {
  6594. return;
  6595. }
  6596. // Fallback to prop when attributes are not supported
  6597. if ( typeof elem.getAttribute === strundefined ) {
  6598. return jQuery.prop( elem, name, value );
  6599. }
  6600. // All attributes are lowercase
  6601. // Grab necessary hook if one is defined
  6602. if ( nType !== 1 || !jQuery.isXMLDoc( elem ) ) {
  6603. name = name.toLowerCase();
  6604. hooks = jQuery.attrHooks[ name ] ||
  6605. ( jQuery.expr.match.bool.test( name ) ? boolHook : nodeHook );
  6606. }
  6607. if ( value !== undefined ) {
  6608. if ( value === null ) {
  6609. jQuery.removeAttr( elem, name );
  6610. } else if ( hooks && "set" in hooks && (ret = hooks.set( elem, value, name )) !== undefined ) {
  6611. return ret;
  6612. } else {
  6613. elem.setAttribute( name, value + "" );
  6614. return value;
  6615. }
  6616. } else if ( hooks && "get" in hooks && (ret = hooks.get( elem, name )) !== null ) {
  6617. return ret;
  6618. } else {
  6619. ret = jQuery.find.attr( elem, name );
  6620. // Non-existent attributes return null, we normalize to undefined
  6621. return ret == null ?
  6622. undefined :
  6623. ret;
  6624. }
  6625. },
  6626. removeAttr: function( elem, value ) {
  6627. var name, propName,
  6628. i = 0,
  6629. attrNames = value && value.match( rnotwhite );
  6630. if ( attrNames && elem.nodeType === 1 ) {
  6631. while ( (name = attrNames[i++]) ) {
  6632. propName = jQuery.propFix[ name ] || name;
  6633. // Boolean attributes get special treatment (#10870)
  6634. if ( jQuery.expr.match.bool.test( name ) ) {
  6635. // Set corresponding property to false
  6636. if ( getSetInput && getSetAttribute || !ruseDefault.test( name ) ) {
  6637. elem[ propName ] = false;
  6638. // Support: IE<9
  6639. // Also clear defaultChecked/defaultSelected (if appropriate)
  6640. } else {
  6641. elem[ jQuery.camelCase( "default-" + name ) ] =
  6642. elem[ propName ] = false;
  6643. }
  6644. // See #9699 for explanation of this approach (setting first, then removal)
  6645. } else {
  6646. jQuery.attr( elem, name, "" );
  6647. }
  6648. elem.removeAttribute( getSetAttribute ? name : propName );
  6649. }
  6650. }
  6651. },
  6652. attrHooks: {
  6653. type: {
  6654. set: function( elem, value ) {
  6655. if ( !support.radioValue && value === "radio" && jQuery.nodeName(elem, "input") ) {
  6656. // Setting the type on a radio button after the value resets the value in IE6-9
  6657. // Reset value to default in case type is set after value during creation
  6658. var val = elem.value;
  6659. elem.setAttribute( "type", value );
  6660. if ( val ) {
  6661. elem.value = val;
  6662. }
  6663. return value;
  6664. }
  6665. }
  6666. }
  6667. }
  6668. });
  6669. // Hook for boolean attributes
  6670. boolHook = {
  6671. set: function( elem, value, name ) {
  6672. if ( value === false ) {
  6673. // Remove boolean attributes when set to false
  6674. jQuery.removeAttr( elem, name );
  6675. } else if ( getSetInput && getSetAttribute || !ruseDefault.test( name ) ) {
  6676. // IE<8 needs the *property* name
  6677. elem.setAttribute( !getSetAttribute && jQuery.propFix[ name ] || name, name );
  6678. // Use defaultChecked and defaultSelected for oldIE
  6679. } else {
  6680. elem[ jQuery.camelCase( "default-" + name ) ] = elem[ name ] = true;
  6681. }
  6682. return name;
  6683. }
  6684. };
  6685. // Retrieve booleans specially
  6686. jQuery.each( jQuery.expr.match.bool.source.match( /\w+/g ), function( i, name ) {
  6687. var getter = attrHandle[ name ] || jQuery.find.attr;
  6688. attrHandle[ name ] = getSetInput && getSetAttribute || !ruseDefault.test( name ) ?
  6689. function( elem, name, isXML ) {
  6690. var ret, handle;
  6691. if ( !isXML ) {
  6692. // Avoid an infinite loop by temporarily removing this function from the getter
  6693. handle = attrHandle[ name ];
  6694. attrHandle[ name ] = ret;
  6695. ret = getter( elem, name, isXML ) != null ?
  6696. name.toLowerCase() :
  6697. null;
  6698. attrHandle[ name ] = handle;
  6699. }
  6700. return ret;
  6701. } :
  6702. function( elem, name, isXML ) {
  6703. if ( !isXML ) {
  6704. return elem[ jQuery.camelCase( "default-" + name ) ] ?
  6705. name.toLowerCase() :
  6706. null;
  6707. }
  6708. };
  6709. });
  6710. // fix oldIE attroperties
  6711. if ( !getSetInput || !getSetAttribute ) {
  6712. jQuery.attrHooks.value = {
  6713. set: function( elem, value, name ) {
  6714. if ( jQuery.nodeName( elem, "input" ) ) {
  6715. // Does not return so that setAttribute is also used
  6716. elem.defaultValue = value;
  6717. } else {
  6718. // Use nodeHook if defined (#1954); otherwise setAttribute is fine
  6719. return nodeHook && nodeHook.set( elem, value, name );
  6720. }
  6721. }
  6722. };
  6723. }
  6724. // IE6/7 do not support getting/setting some attributes with get/setAttribute
  6725. if ( !getSetAttribute ) {
  6726. // Use this for any attribute in IE6/7
  6727. // This fixes almost every IE6/7 issue
  6728. nodeHook = {
  6729. set: function( elem, value, name ) {
  6730. // Set the existing or create a new attribute node
  6731. var ret = elem.getAttributeNode( name );
  6732. if ( !ret ) {
  6733. elem.setAttributeNode(
  6734. (ret = elem.ownerDocument.createAttribute( name ))
  6735. );
  6736. }
  6737. ret.value = value += "";
  6738. // Break association with cloned elements by also using setAttribute (#9646)
  6739. if ( name === "value" || value === elem.getAttribute( name ) ) {
  6740. return value;
  6741. }
  6742. }
  6743. };
  6744. // Some attributes are constructed with empty-string values when not defined
  6745. attrHandle.id = attrHandle.name = attrHandle.coords =
  6746. function( elem, name, isXML ) {
  6747. var ret;
  6748. if ( !isXML ) {
  6749. return (ret = elem.getAttributeNode( name )) && ret.value !== "" ?
  6750. ret.value :
  6751. null;
  6752. }
  6753. };
  6754. // Fixing value retrieval on a button requires this module
  6755. jQuery.valHooks.button = {
  6756. get: function( elem, name ) {
  6757. var ret = elem.getAttributeNode( name );
  6758. if ( ret && ret.specified ) {
  6759. return ret.value;
  6760. }
  6761. },
  6762. set: nodeHook.set
  6763. };
  6764. // Set contenteditable to false on removals(#10429)
  6765. // Setting to empty string throws an error as an invalid value
  6766. jQuery.attrHooks.contenteditable = {
  6767. set: function( elem, value, name ) {
  6768. nodeHook.set( elem, value === "" ? false : value, name );
  6769. }
  6770. };
  6771. // Set width and height to auto instead of 0 on empty string( Bug #8150 )
  6772. // This is for removals
  6773. jQuery.each([ "width", "height" ], function( i, name ) {
  6774. jQuery.attrHooks[ name ] = {
  6775. set: function( elem, value ) {
  6776. if ( value === "" ) {
  6777. elem.setAttribute( name, "auto" );
  6778. return value;
  6779. }
  6780. }
  6781. };
  6782. });
  6783. }
  6784. if ( !support.style ) {
  6785. jQuery.attrHooks.style = {
  6786. get: function( elem ) {
  6787. // Return undefined in the case of empty string
  6788. // Note: IE uppercases css property names, but if we were to .toLowerCase()
  6789. // .cssText, that would destroy case senstitivity in URL's, like in "background"
  6790. return elem.style.cssText || undefined;
  6791. },
  6792. set: function( elem, value ) {
  6793. return ( elem.style.cssText = value + "" );
  6794. }
  6795. };
  6796. }
  6797. var rfocusable = /^(?:input|select|textarea|button|object)$/i,
  6798. rclickable = /^(?:a|area)$/i;
  6799. jQuery.fn.extend({
  6800. prop: function( name, value ) {
  6801. return access( this, jQuery.prop, name, value, arguments.length > 1 );
  6802. },
  6803. removeProp: function( name ) {
  6804. name = jQuery.propFix[ name ] || name;
  6805. return this.each(function() {
  6806. // try/catch handles cases where IE balks (such as removing a property on window)
  6807. try {
  6808. this[ name ] = undefined;
  6809. delete this[ name ];
  6810. } catch( e ) {}
  6811. });
  6812. }
  6813. });
  6814. jQuery.extend({
  6815. propFix: {
  6816. "for": "htmlFor",
  6817. "class": "className"
  6818. },
  6819. prop: function( elem, name, value ) {
  6820. var ret, hooks, notxml,
  6821. nType = elem.nodeType;
  6822. // don't get/set properties on text, comment and attribute nodes
  6823. if ( !elem || nType === 3 || nType === 8 || nType === 2 ) {
  6824. return;
  6825. }
  6826. notxml = nType !== 1 || !jQuery.isXMLDoc( elem );
  6827. if ( notxml ) {
  6828. // Fix name and attach hooks
  6829. name = jQuery.propFix[ name ] || name;
  6830. hooks = jQuery.propHooks[ name ];
  6831. }
  6832. if ( value !== undefined ) {
  6833. return hooks && "set" in hooks && (ret = hooks.set( elem, value, name )) !== undefined ?
  6834. ret :
  6835. ( elem[ name ] = value );
  6836. } else {
  6837. return hooks && "get" in hooks && (ret = hooks.get( elem, name )) !== null ?
  6838. ret :
  6839. elem[ name ];
  6840. }
  6841. },
  6842. propHooks: {
  6843. tabIndex: {
  6844. get: function( elem ) {
  6845. // elem.tabIndex doesn't always return the correct value when it hasn't been explicitly set
  6846. // http://fluidproject.org/blog/2008/01/09/getting-setting-and-removing-tabindex-values-with-javascript/
  6847. // Use proper attribute retrieval(#12072)
  6848. var tabindex = jQuery.find.attr( elem, "tabindex" );
  6849. return tabindex ?
  6850. parseInt( tabindex, 10 ) :
  6851. rfocusable.test( elem.nodeName ) || rclickable.test( elem.nodeName ) && elem.href ?
  6852. 0 :
  6853. -1;
  6854. }
  6855. }
  6856. }
  6857. });
  6858. // Some attributes require a special call on IE
  6859. // http://msdn.microsoft.com/en-us/library/ms536429%28VS.85%29.aspx
  6860. if ( !support.hrefNormalized ) {
  6861. // href/src property should get the full normalized URL (#10299/#12915)
  6862. jQuery.each([ "href", "src" ], function( i, name ) {
  6863. jQuery.propHooks[ name ] = {
  6864. get: function( elem ) {
  6865. return elem.getAttribute( name, 4 );
  6866. }
  6867. };
  6868. });
  6869. }
  6870. // Support: Safari, IE9+
  6871. // mis-reports the default selected property of an option
  6872. // Accessing the parent's selectedIndex property fixes it
  6873. if ( !support.optSelected ) {
  6874. jQuery.propHooks.selected = {
  6875. get: function( elem ) {
  6876. var parent = elem.parentNode;
  6877. if ( parent ) {
  6878. parent.selectedIndex;
  6879. // Make sure that it also works with optgroups, see #5701
  6880. if ( parent.parentNode ) {
  6881. parent.parentNode.selectedIndex;
  6882. }
  6883. }
  6884. return null;
  6885. }
  6886. };
  6887. }
  6888. jQuery.each([
  6889. "tabIndex",
  6890. "readOnly",
  6891. "maxLength",
  6892. "cellSpacing",
  6893. "cellPadding",
  6894. "rowSpan",
  6895. "colSpan",
  6896. "useMap",
  6897. "frameBorder",
  6898. "contentEditable"
  6899. ], function() {
  6900. jQuery.propFix[ this.toLowerCase() ] = this;
  6901. });
  6902. // IE6/7 call enctype encoding
  6903. if ( !support.enctype ) {
  6904. jQuery.propFix.enctype = "encoding";
  6905. }
  6906. var rclass = /[\t\r\n\f]/g;
  6907. jQuery.fn.extend({
  6908. addClass: function( value ) {
  6909. var classes, elem, cur, clazz, j, finalValue,
  6910. i = 0,
  6911. len = this.length,
  6912. proceed = typeof value === "string" && value;
  6913. if ( jQuery.isFunction( value ) ) {
  6914. return this.each(function( j ) {
  6915. jQuery( this ).addClass( value.call( this, j, this.className ) );
  6916. });
  6917. }
  6918. if ( proceed ) {
  6919. // The disjunction here is for better compressibility (see removeClass)
  6920. classes = ( value || "" ).match( rnotwhite ) || [];
  6921. for ( ; i < len; i++ ) {
  6922. elem = this[ i ];
  6923. cur = elem.nodeType === 1 && ( elem.className ?
  6924. ( " " + elem.className + " " ).replace( rclass, " " ) :
  6925. " "
  6926. );
  6927. if ( cur ) {
  6928. j = 0;
  6929. while ( (clazz = classes[j++]) ) {
  6930. if ( cur.indexOf( " " + clazz + " " ) < 0 ) {
  6931. cur += clazz + " ";
  6932. }
  6933. }
  6934. // only assign if different to avoid unneeded rendering.
  6935. finalValue = jQuery.trim( cur );
  6936. if ( elem.className !== finalValue ) {
  6937. elem.className = finalValue;
  6938. }
  6939. }
  6940. }
  6941. }
  6942. return this;
  6943. },
  6944. removeClass: function( value ) {
  6945. var classes, elem, cur, clazz, j, finalValue,
  6946. i = 0,
  6947. len = this.length,
  6948. proceed = arguments.length === 0 || typeof value === "string" && value;
  6949. if ( jQuery.isFunction( value ) ) {
  6950. return this.each(function( j ) {
  6951. jQuery( this ).removeClass( value.call( this, j, this.className ) );
  6952. });
  6953. }
  6954. if ( proceed ) {
  6955. classes = ( value || "" ).match( rnotwhite ) || [];
  6956. for ( ; i < len; i++ ) {
  6957. elem = this[ i ];
  6958. // This expression is here for better compressibility (see addClass)
  6959. cur = elem.nodeType === 1 && ( elem.className ?
  6960. ( " " + elem.className + " " ).replace( rclass, " " ) :
  6961. ""
  6962. );
  6963. if ( cur ) {
  6964. j = 0;
  6965. while ( (clazz = classes[j++]) ) {
  6966. // Remove *all* instances
  6967. while ( cur.indexOf( " " + clazz + " " ) >= 0 ) {
  6968. cur = cur.replace( " " + clazz + " ", " " );
  6969. }
  6970. }
  6971. // only assign if different to avoid unneeded rendering.
  6972. finalValue = value ? jQuery.trim( cur ) : "";
  6973. if ( elem.className !== finalValue ) {
  6974. elem.className = finalValue;
  6975. }
  6976. }
  6977. }
  6978. }
  6979. return this;
  6980. },
  6981. toggleClass: function( value, stateVal ) {
  6982. var type = typeof value;
  6983. if ( typeof stateVal === "boolean" && type === "string" ) {
  6984. return stateVal ? this.addClass( value ) : this.removeClass( value );
  6985. }
  6986. if ( jQuery.isFunction( value ) ) {
  6987. return this.each(function( i ) {
  6988. jQuery( this ).toggleClass( value.call(this, i, this.className, stateVal), stateVal );
  6989. });
  6990. }
  6991. return this.each(function() {
  6992. if ( type === "string" ) {
  6993. // toggle individual class names
  6994. var className,
  6995. i = 0,
  6996. self = jQuery( this ),
  6997. classNames = value.match( rnotwhite ) || [];
  6998. while ( (className = classNames[ i++ ]) ) {
  6999. // check each className given, space separated list
  7000. if ( self.hasClass( className ) ) {
  7001. self.removeClass( className );
  7002. } else {
  7003. self.addClass( className );
  7004. }
  7005. }
  7006. // Toggle whole class name
  7007. } else if ( type === strundefined || type === "boolean" ) {
  7008. if ( this.className ) {
  7009. // store className if set
  7010. jQuery._data( this, "__className__", this.className );
  7011. }
  7012. // If the element has a class name or if we're passed "false",
  7013. // then remove the whole classname (if there was one, the above saved it).
  7014. // Otherwise bring back whatever was previously saved (if anything),
  7015. // falling back to the empty string if nothing was stored.
  7016. this.className = this.className || value === false ? "" : jQuery._data( this, "__className__" ) || "";
  7017. }
  7018. });
  7019. },
  7020. hasClass: function( selector ) {
  7021. var className = " " + selector + " ",
  7022. i = 0,
  7023. l = this.length;
  7024. for ( ; i < l; i++ ) {
  7025. if ( this[i].nodeType === 1 && (" " + this[i].className + " ").replace(rclass, " ").indexOf( className ) >= 0 ) {
  7026. return true;
  7027. }
  7028. }
  7029. return false;
  7030. }
  7031. });
  7032. // Return jQuery for attributes-only inclusion
  7033. jQuery.each( ("blur focus focusin focusout load resize scroll unload click dblclick " +
  7034. "mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave " +
  7035. "change select submit keydown keypress keyup error contextmenu").split(" "), function( i, name ) {
  7036. // Handle event binding
  7037. jQuery.fn[ name ] = function( data, fn ) {
  7038. return arguments.length > 0 ?
  7039. this.on( name, null, data, fn ) :
  7040. this.trigger( name );
  7041. };
  7042. });
  7043. jQuery.fn.extend({
  7044. hover: function( fnOver, fnOut ) {
  7045. return this.mouseenter( fnOver ).mouseleave( fnOut || fnOver );
  7046. },
  7047. bind: function( types, data, fn ) {
  7048. return this.on( types, null, data, fn );
  7049. },
  7050. unbind: function( types, fn ) {
  7051. return this.off( types, null, fn );
  7052. },
  7053. delegate: function( selector, types, data, fn ) {
  7054. return this.on( types, selector, data, fn );
  7055. },
  7056. undelegate: function( selector, types, fn ) {
  7057. // ( namespace ) or ( selector, types [, fn] )
  7058. return arguments.length === 1 ? this.off( selector, "**" ) : this.off( types, selector || "**", fn );
  7059. }
  7060. });
  7061. var nonce = jQuery.now();
  7062. var rquery = (/\?/);
  7063. var rvalidtokens = /(,)|(\[|{)|(}|])|"(?:[^"\\\r\n]|\\["\\\/bfnrt]|\\u[\da-fA-F]{4})*"\s*:?|true|false|null|-?(?!0\d)\d+(?:\.\d+|)(?:[eE][+-]?\d+|)/g;
  7064. jQuery.parseJSON = function( data ) {
  7065. // Attempt to parse using the native JSON parser first
  7066. if ( window.JSON && window.JSON.parse ) {
  7067. // Support: Android 2.3
  7068. // Workaround failure to string-cast null input
  7069. return window.JSON.parse( data + "" );
  7070. }
  7071. var requireNonComma,
  7072. depth = null,
  7073. str = jQuery.trim( data + "" );
  7074. // Guard against invalid (and possibly dangerous) input by ensuring that nothing remains
  7075. // after removing valid tokens
  7076. return str && !jQuery.trim( str.replace( rvalidtokens, function( token, comma, open, close ) {
  7077. // Force termination if we see a misplaced comma
  7078. if ( requireNonComma && comma ) {
  7079. depth = 0;
  7080. }
  7081. // Perform no more replacements after returning to outermost depth
  7082. if ( depth === 0 ) {
  7083. return token;
  7084. }
  7085. // Commas must not follow "[", "{", or ","
  7086. requireNonComma = open || comma;
  7087. // Determine new depth
  7088. // array/object open ("[" or "{"): depth += true - false (increment)
  7089. // array/object close ("]" or "}"): depth += false - true (decrement)
  7090. // other cases ("," or primitive): depth += true - true (numeric cast)
  7091. depth += !close - !open;
  7092. // Remove this token
  7093. return "";
  7094. }) ) ?
  7095. ( Function( "return " + str ) )() :
  7096. jQuery.error( "Invalid JSON: " + data );
  7097. };
  7098. // Cross-browser xml parsing
  7099. jQuery.parseXML = function( data ) {
  7100. var xml, tmp;
  7101. if ( !data || typeof data !== "string" ) {
  7102. return null;
  7103. }
  7104. try {
  7105. if ( window.DOMParser ) { // Standard
  7106. tmp = new DOMParser();
  7107. xml = tmp.parseFromString( data, "text/xml" );
  7108. } else { // IE
  7109. xml = new ActiveXObject( "Microsoft.XMLDOM" );
  7110. xml.async = "false";
  7111. xml.loadXML( data );
  7112. }
  7113. } catch( e ) {
  7114. xml = undefined;
  7115. }
  7116. if ( !xml || !xml.documentElement || xml.getElementsByTagName( "parsererror" ).length ) {
  7117. jQuery.error( "Invalid XML: " + data );
  7118. }
  7119. return xml;
  7120. };
  7121. var
  7122. // Document location
  7123. ajaxLocParts,
  7124. ajaxLocation,
  7125. rhash = /#.*$/,
  7126. rts = /([?&])_=[^&]*/,
  7127. rheaders = /^(.*?):[ \t]*([^\r\n]*)\r?$/mg, // IE leaves an \r character at EOL
  7128. // #7653, #8125, #8152: local protocol detection
  7129. rlocalProtocol = /^(?:about|app|app-storage|.+-extension|file|res|widget):$/,
  7130. rnoContent = /^(?:GET|HEAD)$/,
  7131. rprotocol = /^\/\//,
  7132. rurl = /^([\w.+-]+:)(?:\/\/(?:[^\/?#]*@|)([^\/?#:]*)(?::(\d+)|)|)/,
  7133. /* Prefilters
  7134. * 1) They are useful to introduce custom dataTypes (see ajax/jsonp.js for an example)
  7135. * 2) These are called:
  7136. * - BEFORE asking for a transport
  7137. * - AFTER param serialization (s.data is a string if s.processData is true)
  7138. * 3) key is the dataType
  7139. * 4) the catchall symbol "*" can be used
  7140. * 5) execution will start with transport dataType and THEN continue down to "*" if needed
  7141. */
  7142. prefilters = {},
  7143. /* Transports bindings
  7144. * 1) key is the dataType
  7145. * 2) the catchall symbol "*" can be used
  7146. * 3) selection will start with transport dataType and THEN go to "*" if needed
  7147. */
  7148. transports = {},
  7149. // Avoid comment-prolog char sequence (#10098); must appease lint and evade compression
  7150. allTypes = "*/".concat("*");
  7151. // #8138, IE may throw an exception when accessing
  7152. // a field from window.location if document.domain has been set
  7153. try {
  7154. ajaxLocation = location.href;
  7155. } catch( e ) {
  7156. // Use the href attribute of an A element
  7157. // since IE will modify it given document.location
  7158. ajaxLocation = document.createElement( "a" );
  7159. ajaxLocation.href = "";
  7160. ajaxLocation = ajaxLocation.href;
  7161. }
  7162. // Segment location into parts
  7163. ajaxLocParts = rurl.exec( ajaxLocation.toLowerCase() ) || [];
  7164. // Base "constructor" for jQuery.ajaxPrefilter and jQuery.ajaxTransport
  7165. function addToPrefiltersOrTransports( structure ) {
  7166. // dataTypeExpression is optional and defaults to "*"
  7167. return function( dataTypeExpression, func ) {
  7168. if ( typeof dataTypeExpression !== "string" ) {
  7169. func = dataTypeExpression;
  7170. dataTypeExpression = "*";
  7171. }
  7172. var dataType,
  7173. i = 0,
  7174. dataTypes = dataTypeExpression.toLowerCase().match( rnotwhite ) || [];
  7175. if ( jQuery.isFunction( func ) ) {
  7176. // For each dataType in the dataTypeExpression
  7177. while ( (dataType = dataTypes[i++]) ) {
  7178. // Prepend if requested
  7179. if ( dataType.charAt( 0 ) === "+" ) {
  7180. dataType = dataType.slice( 1 ) || "*";
  7181. (structure[ dataType ] = structure[ dataType ] || []).unshift( func );
  7182. // Otherwise append
  7183. } else {
  7184. (structure[ dataType ] = structure[ dataType ] || []).push( func );
  7185. }
  7186. }
  7187. }
  7188. };
  7189. }
  7190. // Base inspection function for prefilters and transports
  7191. function inspectPrefiltersOrTransports( structure, options, originalOptions, jqXHR ) {
  7192. var inspected = {},
  7193. seekingTransport = ( structure === transports );
  7194. function inspect( dataType ) {
  7195. var selected;
  7196. inspected[ dataType ] = true;
  7197. jQuery.each( structure[ dataType ] || [], function( _, prefilterOrFactory ) {
  7198. var dataTypeOrTransport = prefilterOrFactory( options, originalOptions, jqXHR );
  7199. if ( typeof dataTypeOrTransport === "string" && !seekingTransport && !inspected[ dataTypeOrTransport ] ) {
  7200. options.dataTypes.unshift( dataTypeOrTransport );
  7201. inspect( dataTypeOrTransport );
  7202. return false;
  7203. } else if ( seekingTransport ) {
  7204. return !( selected = dataTypeOrTransport );
  7205. }
  7206. });
  7207. return selected;
  7208. }
  7209. return inspect( options.dataTypes[ 0 ] ) || !inspected[ "*" ] && inspect( "*" );
  7210. }
  7211. // A special extend for ajax options
  7212. // that takes "flat" options (not to be deep extended)
  7213. // Fixes #9887
  7214. function ajaxExtend( target, src ) {
  7215. var deep, key,
  7216. flatOptions = jQuery.ajaxSettings.flatOptions || {};
  7217. for ( key in src ) {
  7218. if ( src[ key ] !== undefined ) {
  7219. ( flatOptions[ key ] ? target : ( deep || (deep = {}) ) )[ key ] = src[ key ];
  7220. }
  7221. }
  7222. if ( deep ) {
  7223. jQuery.extend( true, target, deep );
  7224. }
  7225. return target;
  7226. }
  7227. /* Handles responses to an ajax request:
  7228. * - finds the right dataType (mediates between content-type and expected dataType)
  7229. * - returns the corresponding response
  7230. */
  7231. function ajaxHandleResponses( s, jqXHR, responses ) {
  7232. var firstDataType, ct, finalDataType, type,
  7233. contents = s.contents,
  7234. dataTypes = s.dataTypes;
  7235. // Remove auto dataType and get content-type in the process
  7236. while ( dataTypes[ 0 ] === "*" ) {
  7237. dataTypes.shift();
  7238. if ( ct === undefined ) {
  7239. ct = s.mimeType || jqXHR.getResponseHeader("Content-Type");
  7240. }
  7241. }
  7242. // Check if we're dealing with a known content-type
  7243. if ( ct ) {
  7244. for ( type in contents ) {
  7245. if ( contents[ type ] && contents[ type ].test( ct ) ) {
  7246. dataTypes.unshift( type );
  7247. break;
  7248. }
  7249. }
  7250. }
  7251. // Check to see if we have a response for the expected dataType
  7252. if ( dataTypes[ 0 ] in responses ) {
  7253. finalDataType = dataTypes[ 0 ];
  7254. } else {
  7255. // Try convertible dataTypes
  7256. for ( type in responses ) {
  7257. if ( !dataTypes[ 0 ] || s.converters[ type + " " + dataTypes[0] ] ) {
  7258. finalDataType = type;
  7259. break;
  7260. }
  7261. if ( !firstDataType ) {
  7262. firstDataType = type;
  7263. }
  7264. }
  7265. // Or just use first one
  7266. finalDataType = finalDataType || firstDataType;
  7267. }
  7268. // If we found a dataType
  7269. // We add the dataType to the list if needed
  7270. // and return the corresponding response
  7271. if ( finalDataType ) {
  7272. if ( finalDataType !== dataTypes[ 0 ] ) {
  7273. dataTypes.unshift( finalDataType );
  7274. }
  7275. return responses[ finalDataType ];
  7276. }
  7277. }
  7278. /* Chain conversions given the request and the original response
  7279. * Also sets the responseXXX fields on the jqXHR instance
  7280. */
  7281. function ajaxConvert( s, response, jqXHR, isSuccess ) {
  7282. var conv2, current, conv, tmp, prev,
  7283. converters = {},
  7284. // Work with a copy of dataTypes in case we need to modify it for conversion
  7285. dataTypes = s.dataTypes.slice();
  7286. // Create converters map with lowercased keys
  7287. if ( dataTypes[ 1 ] ) {
  7288. for ( conv in s.converters ) {
  7289. converters[ conv.toLowerCase() ] = s.converters[ conv ];
  7290. }
  7291. }
  7292. current = dataTypes.shift();
  7293. // Convert to each sequential dataType
  7294. while ( current ) {
  7295. if ( s.responseFields[ current ] ) {
  7296. jqXHR[ s.responseFields[ current ] ] = response;
  7297. }
  7298. // Apply the dataFilter if provided
  7299. if ( !prev && isSuccess && s.dataFilter ) {
  7300. response = s.dataFilter( response, s.dataType );
  7301. }
  7302. prev = current;
  7303. current = dataTypes.shift();
  7304. if ( current ) {
  7305. // There's only work to do if current dataType is non-auto
  7306. if ( current === "*" ) {
  7307. current = prev;
  7308. // Convert response if prev dataType is non-auto and differs from current
  7309. } else if ( prev !== "*" && prev !== current ) {
  7310. // Seek a direct converter
  7311. conv = converters[ prev + " " + current ] || converters[ "* " + current ];
  7312. // If none found, seek a pair
  7313. if ( !conv ) {
  7314. for ( conv2 in converters ) {
  7315. // If conv2 outputs current
  7316. tmp = conv2.split( " " );
  7317. if ( tmp[ 1 ] === current ) {
  7318. // If prev can be converted to accepted input
  7319. conv = converters[ prev + " " + tmp[ 0 ] ] ||
  7320. converters[ "* " + tmp[ 0 ] ];
  7321. if ( conv ) {
  7322. // Condense equivalence converters
  7323. if ( conv === true ) {
  7324. conv = converters[ conv2 ];
  7325. // Otherwise, insert the intermediate dataType
  7326. } else if ( converters[ conv2 ] !== true ) {
  7327. current = tmp[ 0 ];
  7328. dataTypes.unshift( tmp[ 1 ] );
  7329. }
  7330. break;
  7331. }
  7332. }
  7333. }
  7334. }
  7335. // Apply converter (if not an equivalence)
  7336. if ( conv !== true ) {
  7337. // Unless errors are allowed to bubble, catch and return them
  7338. if ( conv && s[ "throws" ] ) {
  7339. response = conv( response );
  7340. } else {
  7341. try {
  7342. response = conv( response );
  7343. } catch ( e ) {
  7344. return { state: "parsererror", error: conv ? e : "No conversion from " + prev + " to " + current };
  7345. }
  7346. }
  7347. }
  7348. }
  7349. }
  7350. }
  7351. return { state: "success", data: response };
  7352. }
  7353. jQuery.extend({
  7354. // Counter for holding the number of active queries
  7355. active: 0,
  7356. // Last-Modified header cache for next request
  7357. lastModified: {},
  7358. etag: {},
  7359. ajaxSettings: {
  7360. url: ajaxLocation,
  7361. type: "GET",
  7362. isLocal: rlocalProtocol.test( ajaxLocParts[ 1 ] ),
  7363. global: true,
  7364. processData: true,
  7365. async: true,
  7366. contentType: "application/x-www-form-urlencoded; charset=UTF-8",
  7367. /*
  7368. timeout: 0,
  7369. data: null,
  7370. dataType: null,
  7371. username: null,
  7372. password: null,
  7373. cache: null,
  7374. throws: false,
  7375. traditional: false,
  7376. headers: {},
  7377. */
  7378. accepts: {
  7379. "*": allTypes,
  7380. text: "text/plain",
  7381. html: "text/html",
  7382. xml: "application/xml, text/xml",
  7383. json: "application/json, text/javascript"
  7384. },
  7385. contents: {
  7386. xml: /xml/,
  7387. html: /html/,
  7388. json: /json/
  7389. },
  7390. responseFields: {
  7391. xml: "responseXML",
  7392. text: "responseText",
  7393. json: "responseJSON"
  7394. },
  7395. // Data converters
  7396. // Keys separate source (or catchall "*") and destination types with a single space
  7397. converters: {
  7398. // Convert anything to text
  7399. "* text": String,
  7400. // Text to html (true = no transformation)
  7401. "text html": true,
  7402. // Evaluate text as a json expression
  7403. "text json": jQuery.parseJSON,
  7404. // Parse text as xml
  7405. "text xml": jQuery.parseXML
  7406. },
  7407. // For options that shouldn't be deep extended:
  7408. // you can add your own custom options here if
  7409. // and when you create one that shouldn't be
  7410. // deep extended (see ajaxExtend)
  7411. flatOptions: {
  7412. url: true,
  7413. context: true
  7414. }
  7415. },
  7416. // Creates a full fledged settings object into target
  7417. // with both ajaxSettings and settings fields.
  7418. // If target is omitted, writes into ajaxSettings.
  7419. ajaxSetup: function( target, settings ) {
  7420. return settings ?
  7421. // Building a settings object
  7422. ajaxExtend( ajaxExtend( target, jQuery.ajaxSettings ), settings ) :
  7423. // Extending ajaxSettings
  7424. ajaxExtend( jQuery.ajaxSettings, target );
  7425. },
  7426. ajaxPrefilter: addToPrefiltersOrTransports( prefilters ),
  7427. ajaxTransport: addToPrefiltersOrTransports( transports ),
  7428. // Main method
  7429. ajax: function( url, options ) {
  7430. // If url is an object, simulate pre-1.5 signature
  7431. if ( typeof url === "object" ) {
  7432. options = url;
  7433. url = undefined;
  7434. }
  7435. // Force options to be an object
  7436. options = options || {};
  7437. var // Cross-domain detection vars
  7438. parts,
  7439. // Loop variable
  7440. i,
  7441. // URL without anti-cache param
  7442. cacheURL,
  7443. // Response headers as string
  7444. responseHeadersString,
  7445. // timeout handle
  7446. timeoutTimer,
  7447. // To know if global events are to be dispatched
  7448. fireGlobals,
  7449. transport,
  7450. // Response headers
  7451. responseHeaders,
  7452. // Create the final options object
  7453. s = jQuery.ajaxSetup( {}, options ),
  7454. // Callbacks context
  7455. callbackContext = s.context || s,
  7456. // Context for global events is callbackContext if it is a DOM node or jQuery collection
  7457. globalEventContext = s.context && ( callbackContext.nodeType || callbackContext.jquery ) ?
  7458. jQuery( callbackContext ) :
  7459. jQuery.event,
  7460. // Deferreds
  7461. deferred = jQuery.Deferred(),
  7462. completeDeferred = jQuery.Callbacks("once memory"),
  7463. // Status-dependent callbacks
  7464. statusCode = s.statusCode || {},
  7465. // Headers (they are sent all at once)
  7466. requestHeaders = {},
  7467. requestHeadersNames = {},
  7468. // The jqXHR state
  7469. state = 0,
  7470. // Default abort message
  7471. strAbort = "canceled",
  7472. // Fake xhr
  7473. jqXHR = {
  7474. readyState: 0,
  7475. // Builds headers hashtable if needed
  7476. getResponseHeader: function( key ) {
  7477. var match;
  7478. if ( state === 2 ) {
  7479. if ( !responseHeaders ) {
  7480. responseHeaders = {};
  7481. while ( (match = rheaders.exec( responseHeadersString )) ) {
  7482. responseHeaders[ match[1].toLowerCase() ] = match[ 2 ];
  7483. }
  7484. }
  7485. match = responseHeaders[ key.toLowerCase() ];
  7486. }
  7487. return match == null ? null : match;
  7488. },
  7489. // Raw string
  7490. getAllResponseHeaders: function() {
  7491. return state === 2 ? responseHeadersString : null;
  7492. },
  7493. // Caches the header
  7494. setRequestHeader: function( name, value ) {
  7495. var lname = name.toLowerCase();
  7496. if ( !state ) {
  7497. name = requestHeadersNames[ lname ] = requestHeadersNames[ lname ] || name;
  7498. requestHeaders[ name ] = value;
  7499. }
  7500. return this;
  7501. },
  7502. // Overrides response content-type header
  7503. overrideMimeType: function( type ) {
  7504. if ( !state ) {
  7505. s.mimeType = type;
  7506. }
  7507. return this;
  7508. },
  7509. // Status-dependent callbacks
  7510. statusCode: function( map ) {
  7511. var code;
  7512. if ( map ) {
  7513. if ( state < 2 ) {
  7514. for ( code in map ) {
  7515. // Lazy-add the new callback in a way that preserves old ones
  7516. statusCode[ code ] = [ statusCode[ code ], map[ code ] ];
  7517. }
  7518. } else {
  7519. // Execute the appropriate callbacks
  7520. jqXHR.always( map[ jqXHR.status ] );
  7521. }
  7522. }
  7523. return this;
  7524. },
  7525. // Cancel the request
  7526. abort: function( statusText ) {
  7527. var finalText = statusText || strAbort;
  7528. if ( transport ) {
  7529. transport.abort( finalText );
  7530. }
  7531. done( 0, finalText );
  7532. return this;
  7533. }
  7534. };
  7535. // Attach deferreds
  7536. deferred.promise( jqXHR ).complete = completeDeferred.add;
  7537. jqXHR.success = jqXHR.done;
  7538. jqXHR.error = jqXHR.fail;
  7539. // Remove hash character (#7531: and string promotion)
  7540. // Add protocol if not provided (#5866: IE7 issue with protocol-less urls)
  7541. // Handle falsy url in the settings object (#10093: consistency with old signature)
  7542. // We also use the url parameter if available
  7543. s.url = ( ( url || s.url || ajaxLocation ) + "" ).replace( rhash, "" ).replace( rprotocol, ajaxLocParts[ 1 ] + "//" );
  7544. // Alias method option to type as per ticket #12004
  7545. s.type = options.method || options.type || s.method || s.type;
  7546. // Extract dataTypes list
  7547. s.dataTypes = jQuery.trim( s.dataType || "*" ).toLowerCase().match( rnotwhite ) || [ "" ];
  7548. // A cross-domain request is in order when we have a protocol:host:port mismatch
  7549. if ( s.crossDomain == null ) {
  7550. parts = rurl.exec( s.url.toLowerCase() );
  7551. s.crossDomain = !!( parts &&
  7552. ( parts[ 1 ] !== ajaxLocParts[ 1 ] || parts[ 2 ] !== ajaxLocParts[ 2 ] ||
  7553. ( parts[ 3 ] || ( parts[ 1 ] === "http:" ? "80" : "443" ) ) !==
  7554. ( ajaxLocParts[ 3 ] || ( ajaxLocParts[ 1 ] === "http:" ? "80" : "443" ) ) )
  7555. );
  7556. }
  7557. // Convert data if not already a string
  7558. if ( s.data && s.processData && typeof s.data !== "string" ) {
  7559. s.data = jQuery.param( s.data, s.traditional );
  7560. }
  7561. // Apply prefilters
  7562. inspectPrefiltersOrTransports( prefilters, s, options, jqXHR );
  7563. // If request was aborted inside a prefilter, stop there
  7564. if ( state === 2 ) {
  7565. return jqXHR;
  7566. }
  7567. // We can fire global events as of now if asked to
  7568. fireGlobals = s.global;
  7569. // Watch for a new set of requests
  7570. if ( fireGlobals && jQuery.active++ === 0 ) {
  7571. jQuery.event.trigger("ajaxStart");
  7572. }
  7573. // Uppercase the type
  7574. s.type = s.type.toUpperCase();
  7575. // Determine if request has content
  7576. s.hasContent = !rnoContent.test( s.type );
  7577. // Save the URL in case we're toying with the If-Modified-Since
  7578. // and/or If-None-Match header later on
  7579. cacheURL = s.url;
  7580. // More options handling for requests with no content
  7581. if ( !s.hasContent ) {
  7582. // If data is available, append data to url
  7583. if ( s.data ) {
  7584. cacheURL = ( s.url += ( rquery.test( cacheURL ) ? "&" : "?" ) + s.data );
  7585. // #9682: remove data so that it's not used in an eventual retry
  7586. delete s.data;
  7587. }
  7588. // Add anti-cache in url if needed
  7589. if ( s.cache === false ) {
  7590. s.url = rts.test( cacheURL ) ?
  7591. // If there is already a '_' parameter, set its value
  7592. cacheURL.replace( rts, "$1_=" + nonce++ ) :
  7593. // Otherwise add one to the end
  7594. cacheURL + ( rquery.test( cacheURL ) ? "&" : "?" ) + "_=" + nonce++;
  7595. }
  7596. }
  7597. // Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode.
  7598. if ( s.ifModified ) {
  7599. if ( jQuery.lastModified[ cacheURL ] ) {
  7600. jqXHR.setRequestHeader( "If-Modified-Since", jQuery.lastModified[ cacheURL ] );
  7601. }
  7602. if ( jQuery.etag[ cacheURL ] ) {
  7603. jqXHR.setRequestHeader( "If-None-Match", jQuery.etag[ cacheURL ] );
  7604. }
  7605. }
  7606. // Set the correct header, if data is being sent
  7607. if ( s.data && s.hasContent && s.contentType !== false || options.contentType ) {
  7608. jqXHR.setRequestHeader( "Content-Type", s.contentType );
  7609. }
  7610. // Set the Accepts header for the server, depending on the dataType
  7611. jqXHR.setRequestHeader(
  7612. "Accept",
  7613. s.dataTypes[ 0 ] && s.accepts[ s.dataTypes[0] ] ?
  7614. s.accepts[ s.dataTypes[0] ] + ( s.dataTypes[ 0 ] !== "*" ? ", " + allTypes + "; q=0.01" : "" ) :
  7615. s.accepts[ "*" ]
  7616. );
  7617. // Check for headers option
  7618. for ( i in s.headers ) {
  7619. jqXHR.setRequestHeader( i, s.headers[ i ] );
  7620. }
  7621. // Allow custom headers/mimetypes and early abort
  7622. if ( s.beforeSend && ( s.beforeSend.call( callbackContext, jqXHR, s ) === false || state === 2 ) ) {
  7623. // Abort if not done already and return
  7624. return jqXHR.abort();
  7625. }
  7626. // aborting is no longer a cancellation
  7627. strAbort = "abort";
  7628. // Install callbacks on deferreds
  7629. for ( i in { success: 1, error: 1, complete: 1 } ) {
  7630. jqXHR[ i ]( s[ i ] );
  7631. }
  7632. // Get transport
  7633. transport = inspectPrefiltersOrTransports( transports, s, options, jqXHR );
  7634. // If no transport, we auto-abort
  7635. if ( !transport ) {
  7636. done( -1, "No Transport" );
  7637. } else {
  7638. jqXHR.readyState = 1;
  7639. // Send global event
  7640. if ( fireGlobals ) {
  7641. globalEventContext.trigger( "ajaxSend", [ jqXHR, s ] );
  7642. }
  7643. // Timeout
  7644. if ( s.async && s.timeout > 0 ) {
  7645. timeoutTimer = setTimeout(function() {
  7646. jqXHR.abort("timeout");
  7647. }, s.timeout );
  7648. }
  7649. try {
  7650. state = 1;
  7651. transport.send( requestHeaders, done );
  7652. } catch ( e ) {
  7653. // Propagate exception as error if not done
  7654. if ( state < 2 ) {
  7655. done( -1, e );
  7656. // Simply rethrow otherwise
  7657. } else {
  7658. throw e;
  7659. }
  7660. }
  7661. }
  7662. // Callback for when everything is done
  7663. function done( status, nativeStatusText, responses, headers ) {
  7664. var isSuccess, success, error, response, modified,
  7665. statusText = nativeStatusText;
  7666. // Called once
  7667. if ( state === 2 ) {
  7668. return;
  7669. }
  7670. // State is "done" now
  7671. state = 2;
  7672. // Clear timeout if it exists
  7673. if ( timeoutTimer ) {
  7674. clearTimeout( timeoutTimer );
  7675. }
  7676. // Dereference transport for early garbage collection
  7677. // (no matter how long the jqXHR object will be used)
  7678. transport = undefined;
  7679. // Cache response headers
  7680. responseHeadersString = headers || "";
  7681. // Set readyState
  7682. jqXHR.readyState = status > 0 ? 4 : 0;
  7683. // Determine if successful
  7684. isSuccess = status >= 200 && status < 300 || status === 304;
  7685. // Get response data
  7686. if ( responses ) {
  7687. response = ajaxHandleResponses( s, jqXHR, responses );
  7688. }
  7689. // Convert no matter what (that way responseXXX fields are always set)
  7690. response = ajaxConvert( s, response, jqXHR, isSuccess );
  7691. // If successful, handle type chaining
  7692. if ( isSuccess ) {
  7693. // Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode.
  7694. if ( s.ifModified ) {
  7695. modified = jqXHR.getResponseHeader("Last-Modified");
  7696. if ( modified ) {
  7697. jQuery.lastModified[ cacheURL ] = modified;
  7698. }
  7699. modified = jqXHR.getResponseHeader("etag");
  7700. if ( modified ) {
  7701. jQuery.etag[ cacheURL ] = modified;
  7702. }
  7703. }
  7704. // if no content
  7705. if ( status === 204 || s.type === "HEAD" ) {
  7706. statusText = "nocontent";
  7707. // if not modified
  7708. } else if ( status === 304 ) {
  7709. statusText = "notmodified";
  7710. // If we have data, let's convert it
  7711. } else {
  7712. statusText = response.state;
  7713. success = response.data;
  7714. error = response.error;
  7715. isSuccess = !error;
  7716. }
  7717. } else {
  7718. // We extract error from statusText
  7719. // then normalize statusText and status for non-aborts
  7720. error = statusText;
  7721. if ( status || !statusText ) {
  7722. statusText = "error";
  7723. if ( status < 0 ) {
  7724. status = 0;
  7725. }
  7726. }
  7727. }
  7728. // Set data for the fake xhr object
  7729. jqXHR.status = status;
  7730. jqXHR.statusText = ( nativeStatusText || statusText ) + "";
  7731. // Success/Error
  7732. if ( isSuccess ) {
  7733. deferred.resolveWith( callbackContext, [ success, statusText, jqXHR ] );
  7734. } else {
  7735. deferred.rejectWith( callbackContext, [ jqXHR, statusText, error ] );
  7736. }
  7737. // Status-dependent callbacks
  7738. jqXHR.statusCode( statusCode );
  7739. statusCode = undefined;
  7740. if ( fireGlobals ) {
  7741. globalEventContext.trigger( isSuccess ? "ajaxSuccess" : "ajaxError",
  7742. [ jqXHR, s, isSuccess ? success : error ] );
  7743. }
  7744. // Complete
  7745. completeDeferred.fireWith( callbackContext, [ jqXHR, statusText ] );
  7746. if ( fireGlobals ) {
  7747. globalEventContext.trigger( "ajaxComplete", [ jqXHR, s ] );
  7748. // Handle the global AJAX counter
  7749. if ( !( --jQuery.active ) ) {
  7750. jQuery.event.trigger("ajaxStop");
  7751. }
  7752. }
  7753. }
  7754. return jqXHR;
  7755. },
  7756. getJSON: function( url, data, callback ) {
  7757. return jQuery.get( url, data, callback, "json" );
  7758. },
  7759. getScript: function( url, callback ) {
  7760. return jQuery.get( url, undefined, callback, "script" );
  7761. }
  7762. });
  7763. jQuery.each( [ "get", "post" ], function( i, method ) {
  7764. jQuery[ method ] = function( url, data, callback, type ) {
  7765. // shift arguments if data argument was omitted
  7766. if ( jQuery.isFunction( data ) ) {
  7767. type = type || callback;
  7768. callback = data;
  7769. data = undefined;
  7770. }
  7771. return jQuery.ajax({
  7772. url: url,
  7773. type: method,
  7774. dataType: type,
  7775. data: data,
  7776. success: callback
  7777. });
  7778. };
  7779. });
  7780. // Attach a bunch of functions for handling common AJAX events
  7781. jQuery.each( [ "ajaxStart", "ajaxStop", "ajaxComplete", "ajaxError", "ajaxSuccess", "ajaxSend" ], function( i, type ) {
  7782. jQuery.fn[ type ] = function( fn ) {
  7783. return this.on( type, fn );
  7784. };
  7785. });
  7786. jQuery._evalUrl = function( url ) {
  7787. return jQuery.ajax({
  7788. url: url,
  7789. type: "GET",
  7790. dataType: "script",
  7791. async: false,
  7792. global: false,
  7793. "throws": true
  7794. });
  7795. };
  7796. jQuery.fn.extend({
  7797. wrapAll: function( html ) {
  7798. if ( jQuery.isFunction( html ) ) {
  7799. return this.each(function(i) {
  7800. jQuery(this).wrapAll( html.call(this, i) );
  7801. });
  7802. }
  7803. if ( this[0] ) {
  7804. // The elements to wrap the target around
  7805. var wrap = jQuery( html, this[0].ownerDocument ).eq(0).clone(true);
  7806. if ( this[0].parentNode ) {
  7807. wrap.insertBefore( this[0] );
  7808. }
  7809. wrap.map(function() {
  7810. var elem = this;
  7811. while ( elem.firstChild && elem.firstChild.nodeType === 1 ) {
  7812. elem = elem.firstChild;
  7813. }
  7814. return elem;
  7815. }).append( this );
  7816. }
  7817. return this;
  7818. },
  7819. wrapInner: function( html ) {
  7820. if ( jQuery.isFunction( html ) ) {
  7821. return this.each(function(i) {
  7822. jQuery(this).wrapInner( html.call(this, i) );
  7823. });
  7824. }
  7825. return this.each(function() {
  7826. var self = jQuery( this ),
  7827. contents = self.contents();
  7828. if ( contents.length ) {
  7829. contents.wrapAll( html );
  7830. } else {
  7831. self.append( html );
  7832. }
  7833. });
  7834. },
  7835. wrap: function( html ) {
  7836. var isFunction = jQuery.isFunction( html );
  7837. return this.each(function(i) {
  7838. jQuery( this ).wrapAll( isFunction ? html.call(this, i) : html );
  7839. });
  7840. },
  7841. unwrap: function() {
  7842. return this.parent().each(function() {
  7843. if ( !jQuery.nodeName( this, "body" ) ) {
  7844. jQuery( this ).replaceWith( this.childNodes );
  7845. }
  7846. }).end();
  7847. }
  7848. });
  7849. jQuery.expr.filters.hidden = function( elem ) {
  7850. // Support: Opera <= 12.12
  7851. // Opera reports offsetWidths and offsetHeights less than zero on some elements
  7852. return elem.offsetWidth <= 0 && elem.offsetHeight <= 0 ||
  7853. (!support.reliableHiddenOffsets() &&
  7854. ((elem.style && elem.style.display) || jQuery.css( elem, "display" )) === "none");
  7855. };
  7856. jQuery.expr.filters.visible = function( elem ) {
  7857. return !jQuery.expr.filters.hidden( elem );
  7858. };
  7859. var r20 = /%20/g,
  7860. rbracket = /\[\]$/,
  7861. rCRLF = /\r?\n/g,
  7862. rsubmitterTypes = /^(?:submit|button|image|reset|file)$/i,
  7863. rsubmittable = /^(?:input|select|textarea|keygen)/i;
  7864. function buildParams( prefix, obj, traditional, add ) {
  7865. var name;
  7866. if ( jQuery.isArray( obj ) ) {
  7867. // Serialize array item.
  7868. jQuery.each( obj, function( i, v ) {
  7869. if ( traditional || rbracket.test( prefix ) ) {
  7870. // Treat each array item as a scalar.
  7871. add( prefix, v );
  7872. } else {
  7873. // Item is non-scalar (array or object), encode its numeric index.
  7874. buildParams( prefix + "[" + ( typeof v === "object" ? i : "" ) + "]", v, traditional, add );
  7875. }
  7876. });
  7877. } else if ( !traditional && jQuery.type( obj ) === "object" ) {
  7878. // Serialize object item.
  7879. for ( name in obj ) {
  7880. buildParams( prefix + "[" + name + "]", obj[ name ], traditional, add );
  7881. }
  7882. } else {
  7883. // Serialize scalar item.
  7884. add( prefix, obj );
  7885. }
  7886. }
  7887. // Serialize an array of form elements or a set of
  7888. // key/values into a query string
  7889. jQuery.param = function( a, traditional ) {
  7890. var prefix,
  7891. s = [],
  7892. add = function( key, value ) {
  7893. // If value is a function, invoke it and return its value
  7894. value = jQuery.isFunction( value ) ? value() : ( value == null ? "" : value );
  7895. s[ s.length ] = encodeURIComponent( key ) + "=" + encodeURIComponent( value );
  7896. };
  7897. // Set traditional to true for jQuery <= 1.3.2 behavior.
  7898. if ( traditional === undefined ) {
  7899. traditional = jQuery.ajaxSettings && jQuery.ajaxSettings.traditional;
  7900. }
  7901. // If an array was passed in, assume that it is an array of form elements.
  7902. if ( jQuery.isArray( a ) || ( a.jquery && !jQuery.isPlainObject( a ) ) ) {
  7903. // Serialize the form elements
  7904. jQuery.each( a, function() {
  7905. add( this.name, this.value );
  7906. });
  7907. } else {
  7908. // If traditional, encode the "old" way (the way 1.3.2 or older
  7909. // did it), otherwise encode params recursively.
  7910. for ( prefix in a ) {
  7911. buildParams( prefix, a[ prefix ], traditional, add );
  7912. }
  7913. }
  7914. // Return the resulting serialization
  7915. return s.join( "&" ).replace( r20, "+" );
  7916. };
  7917. jQuery.fn.extend({
  7918. serialize: function() {
  7919. return jQuery.param( this.serializeArray() );
  7920. },
  7921. serializeArray: function() {
  7922. return this.map(function() {
  7923. // Can add propHook for "elements" to filter or add form elements
  7924. var elements = jQuery.prop( this, "elements" );
  7925. return elements ? jQuery.makeArray( elements ) : this;
  7926. })
  7927. .filter(function() {
  7928. var type = this.type;
  7929. // Use .is(":disabled") so that fieldset[disabled] works
  7930. return this.name && !jQuery( this ).is( ":disabled" ) &&
  7931. rsubmittable.test( this.nodeName ) && !rsubmitterTypes.test( type ) &&
  7932. ( this.checked || !rcheckableType.test( type ) );
  7933. })
  7934. .map(function( i, elem ) {
  7935. var val = jQuery( this ).val();
  7936. return val == null ?
  7937. null :
  7938. jQuery.isArray( val ) ?
  7939. jQuery.map( val, function( val ) {
  7940. return { name: elem.name, value: val.replace( rCRLF, "\r\n" ) };
  7941. }) :
  7942. { name: elem.name, value: val.replace( rCRLF, "\r\n" ) };
  7943. }).get();
  7944. }
  7945. });
  7946. // Create the request object
  7947. // (This is still attached to ajaxSettings for backward compatibility)
  7948. jQuery.ajaxSettings.xhr = window.ActiveXObject !== undefined ?
  7949. // Support: IE6+
  7950. function() {
  7951. // XHR cannot access local files, always use ActiveX for that case
  7952. return !this.isLocal &&
  7953. // Support: IE7-8
  7954. // oldIE XHR does not support non-RFC2616 methods (#13240)
  7955. // See http://msdn.microsoft.com/en-us/library/ie/ms536648(v=vs.85).aspx
  7956. // and http://www.w3.org/Protocols/rfc2616/rfc2616-sec9.html#sec9
  7957. // Although this check for six methods instead of eight
  7958. // since IE also does not support "trace" and "connect"
  7959. /^(get|post|head|put|delete|options)$/i.test( this.type ) &&
  7960. createStandardXHR() || createActiveXHR();
  7961. } :
  7962. // For all other browsers, use the standard XMLHttpRequest object
  7963. createStandardXHR;
  7964. var xhrId = 0,
  7965. xhrCallbacks = {},
  7966. xhrSupported = jQuery.ajaxSettings.xhr();
  7967. // Support: IE<10
  7968. // Open requests must be manually aborted on unload (#5280)
  7969. if ( window.ActiveXObject ) {
  7970. jQuery( window ).on( "unload", function() {
  7971. for ( var key in xhrCallbacks ) {
  7972. xhrCallbacks[ key ]( undefined, true );
  7973. }
  7974. });
  7975. }
  7976. // Determine support properties
  7977. support.cors = !!xhrSupported && ( "withCredentials" in xhrSupported );
  7978. xhrSupported = support.ajax = !!xhrSupported;
  7979. // Create transport if the browser can provide an xhr
  7980. if ( xhrSupported ) {
  7981. jQuery.ajaxTransport(function( options ) {
  7982. // Cross domain only allowed if supported through XMLHttpRequest
  7983. if ( !options.crossDomain || support.cors ) {
  7984. var callback;
  7985. return {
  7986. send: function( headers, complete ) {
  7987. var i,
  7988. xhr = options.xhr(),
  7989. id = ++xhrId;
  7990. // Open the socket
  7991. xhr.open( options.type, options.url, options.async, options.username, options.password );
  7992. // Apply custom fields if provided
  7993. if ( options.xhrFields ) {
  7994. for ( i in options.xhrFields ) {
  7995. xhr[ i ] = options.xhrFields[ i ];
  7996. }
  7997. }
  7998. // Override mime type if needed
  7999. if ( options.mimeType && xhr.overrideMimeType ) {
  8000. xhr.overrideMimeType( options.mimeType );
  8001. }
  8002. // X-Requested-With header
  8003. // For cross-domain requests, seeing as conditions for a preflight are
  8004. // akin to a jigsaw puzzle, we simply never set it to be sure.
  8005. // (it can always be set on a per-request basis or even using ajaxSetup)
  8006. // For same-domain requests, won't change header if already provided.
  8007. if ( !options.crossDomain && !headers["X-Requested-With"] ) {
  8008. headers["X-Requested-With"] = "XMLHttpRequest";
  8009. }
  8010. // Set headers
  8011. for ( i in headers ) {
  8012. // Support: IE<9
  8013. // IE's ActiveXObject throws a 'Type Mismatch' exception when setting
  8014. // request header to a null-value.
  8015. //
  8016. // To keep consistent with other XHR implementations, cast the value
  8017. // to string and ignore `undefined`.
  8018. if ( headers[ i ] !== undefined ) {
  8019. xhr.setRequestHeader( i, headers[ i ] + "" );
  8020. }
  8021. }
  8022. // Do send the request
  8023. // This may raise an exception which is actually
  8024. // handled in jQuery.ajax (so no try/catch here)
  8025. xhr.send( ( options.hasContent && options.data ) || null );
  8026. // Listener
  8027. callback = function( _, isAbort ) {
  8028. var status, statusText, responses;
  8029. // Was never called and is aborted or complete
  8030. if ( callback && ( isAbort || xhr.readyState === 4 ) ) {
  8031. // Clean up
  8032. delete xhrCallbacks[ id ];
  8033. callback = undefined;
  8034. xhr.onreadystatechange = jQuery.noop;
  8035. // Abort manually if needed
  8036. if ( isAbort ) {
  8037. if ( xhr.readyState !== 4 ) {
  8038. xhr.abort();
  8039. }
  8040. } else {
  8041. responses = {};
  8042. status = xhr.status;
  8043. // Support: IE<10
  8044. // Accessing binary-data responseText throws an exception
  8045. // (#11426)
  8046. if ( typeof xhr.responseText === "string" ) {
  8047. responses.text = xhr.responseText;
  8048. }
  8049. // Firefox throws an exception when accessing
  8050. // statusText for faulty cross-domain requests
  8051. try {
  8052. statusText = xhr.statusText;
  8053. } catch( e ) {
  8054. // We normalize with Webkit giving an empty statusText
  8055. statusText = "";
  8056. }
  8057. // Filter status for non standard behaviors
  8058. // If the request is local and we have data: assume a success
  8059. // (success with no data won't get notified, that's the best we
  8060. // can do given current implementations)
  8061. if ( !status && options.isLocal && !options.crossDomain ) {
  8062. status = responses.text ? 200 : 404;
  8063. // IE - #1450: sometimes returns 1223 when it should be 204
  8064. } else if ( status === 1223 ) {
  8065. status = 204;
  8066. }
  8067. }
  8068. }
  8069. // Call complete if needed
  8070. if ( responses ) {
  8071. complete( status, statusText, responses, xhr.getAllResponseHeaders() );
  8072. }
  8073. };
  8074. if ( !options.async ) {
  8075. // if we're in sync mode we fire the callback
  8076. callback();
  8077. } else if ( xhr.readyState === 4 ) {
  8078. // (IE6 & IE7) if it's in cache and has been
  8079. // retrieved directly we need to fire the callback
  8080. setTimeout( callback );
  8081. } else {
  8082. // Add to the list of active xhr callbacks
  8083. xhr.onreadystatechange = xhrCallbacks[ id ] = callback;
  8084. }
  8085. },
  8086. abort: function() {
  8087. if ( callback ) {
  8088. callback( undefined, true );
  8089. }
  8090. }
  8091. };
  8092. }
  8093. });
  8094. }
  8095. // Functions to create xhrs
  8096. function createStandardXHR() {
  8097. try {
  8098. return new window.XMLHttpRequest();
  8099. } catch( e ) {}
  8100. }
  8101. function createActiveXHR() {
  8102. try {
  8103. return new window.ActiveXObject( "Microsoft.XMLHTTP" );
  8104. } catch( e ) {}
  8105. }
  8106. // Install script dataType
  8107. jQuery.ajaxSetup({
  8108. accepts: {
  8109. script: "text/javascript, application/javascript, application/ecmascript, application/x-ecmascript"
  8110. },
  8111. contents: {
  8112. script: /(?:java|ecma)script/
  8113. },
  8114. converters: {
  8115. "text script": function( text ) {
  8116. jQuery.globalEval( text );
  8117. return text;
  8118. }
  8119. }
  8120. });
  8121. // Handle cache's special case and global
  8122. jQuery.ajaxPrefilter( "script", function( s ) {
  8123. if ( s.cache === undefined ) {
  8124. s.cache = false;
  8125. }
  8126. if ( s.crossDomain ) {
  8127. s.type = "GET";
  8128. s.global = false;
  8129. }
  8130. });
  8131. // Bind script tag hack transport
  8132. jQuery.ajaxTransport( "script", function(s) {
  8133. // This transport only deals with cross domain requests
  8134. if ( s.crossDomain ) {
  8135. var script,
  8136. head = document.head || jQuery("head")[0] || document.documentElement;
  8137. return {
  8138. send: function( _, callback ) {
  8139. script = document.createElement("script");
  8140. script.async = true;
  8141. if ( s.scriptCharset ) {
  8142. script.charset = s.scriptCharset;
  8143. }
  8144. script.src = s.url;
  8145. // Attach handlers for all browsers
  8146. script.onload = script.onreadystatechange = function( _, isAbort ) {
  8147. if ( isAbort || !script.readyState || /loaded|complete/.test( script.readyState ) ) {
  8148. // Handle memory leak in IE
  8149. script.onload = script.onreadystatechange = null;
  8150. // Remove the script
  8151. if ( script.parentNode ) {
  8152. script.parentNode.removeChild( script );
  8153. }
  8154. // Dereference the script
  8155. script = null;
  8156. // Callback if not abort
  8157. if ( !isAbort ) {
  8158. callback( 200, "success" );
  8159. }
  8160. }
  8161. };
  8162. // Circumvent IE6 bugs with base elements (#2709 and #4378) by prepending
  8163. // Use native DOM manipulation to avoid our domManip AJAX trickery
  8164. head.insertBefore( script, head.firstChild );
  8165. },
  8166. abort: function() {
  8167. if ( script ) {
  8168. script.onload( undefined, true );
  8169. }
  8170. }
  8171. };
  8172. }
  8173. });
  8174. var oldCallbacks = [],
  8175. rjsonp = /(=)\?(?=&|$)|\?\?/;
  8176. // Default jsonp settings
  8177. jQuery.ajaxSetup({
  8178. jsonp: "callback",
  8179. jsonpCallback: function() {
  8180. var callback = oldCallbacks.pop() || ( jQuery.expando + "_" + ( nonce++ ) );
  8181. this[ callback ] = true;
  8182. return callback;
  8183. }
  8184. });
  8185. // Detect, normalize options and install callbacks for jsonp requests
  8186. jQuery.ajaxPrefilter( "json jsonp", function( s, originalSettings, jqXHR ) {
  8187. var callbackName, overwritten, responseContainer,
  8188. jsonProp = s.jsonp !== false && ( rjsonp.test( s.url ) ?
  8189. "url" :
  8190. typeof s.data === "string" && !( s.contentType || "" ).indexOf("application/x-www-form-urlencoded") && rjsonp.test( s.data ) && "data"
  8191. );
  8192. // Handle iff the expected data type is "jsonp" or we have a parameter to set
  8193. if ( jsonProp || s.dataTypes[ 0 ] === "jsonp" ) {
  8194. // Get callback name, remembering preexisting value associated with it
  8195. callbackName = s.jsonpCallback = jQuery.isFunction( s.jsonpCallback ) ?
  8196. s.jsonpCallback() :
  8197. s.jsonpCallback;
  8198. // Insert callback into url or form data
  8199. if ( jsonProp ) {
  8200. s[ jsonProp ] = s[ jsonProp ].replace( rjsonp, "$1" + callbackName );
  8201. } else if ( s.jsonp !== false ) {
  8202. s.url += ( rquery.test( s.url ) ? "&" : "?" ) + s.jsonp + "=" + callbackName;
  8203. }
  8204. // Use data converter to retrieve json after script execution
  8205. s.converters["script json"] = function() {
  8206. if ( !responseContainer ) {
  8207. jQuery.error( callbackName + " was not called" );
  8208. }
  8209. return responseContainer[ 0 ];
  8210. };
  8211. // force json dataType
  8212. s.dataTypes[ 0 ] = "json";
  8213. // Install callback
  8214. overwritten = window[ callbackName ];
  8215. window[ callbackName ] = function() {
  8216. responseContainer = arguments;
  8217. };
  8218. // Clean-up function (fires after converters)
  8219. jqXHR.always(function() {
  8220. // Restore preexisting value
  8221. window[ callbackName ] = overwritten;
  8222. // Save back as free
  8223. if ( s[ callbackName ] ) {
  8224. // make sure that re-using the options doesn't screw things around
  8225. s.jsonpCallback = originalSettings.jsonpCallback;
  8226. // save the callback name for future use
  8227. oldCallbacks.push( callbackName );
  8228. }
  8229. // Call if it was a function and we have a response
  8230. if ( responseContainer && jQuery.isFunction( overwritten ) ) {
  8231. overwritten( responseContainer[ 0 ] );
  8232. }
  8233. responseContainer = overwritten = undefined;
  8234. });
  8235. // Delegate to script
  8236. return "script";
  8237. }
  8238. });
  8239. // data: string of html
  8240. // context (optional): If specified, the fragment will be created in this context, defaults to document
  8241. // keepScripts (optional): If true, will include scripts passed in the html string
  8242. jQuery.parseHTML = function( data, context, keepScripts ) {
  8243. if ( !data || typeof data !== "string" ) {
  8244. return null;
  8245. }
  8246. if ( typeof context === "boolean" ) {
  8247. keepScripts = context;
  8248. context = false;
  8249. }
  8250. context = context || document;
  8251. var parsed = rsingleTag.exec( data ),
  8252. scripts = !keepScripts && [];
  8253. // Single tag
  8254. if ( parsed ) {
  8255. return [ context.createElement( parsed[1] ) ];
  8256. }
  8257. parsed = jQuery.buildFragment( [ data ], context, scripts );
  8258. if ( scripts && scripts.length ) {
  8259. jQuery( scripts ).remove();
  8260. }
  8261. return jQuery.merge( [], parsed.childNodes );
  8262. };
  8263. // Keep a copy of the old load method
  8264. var _load = jQuery.fn.load;
  8265. /**
  8266. * Load a url into a page
  8267. */
  8268. jQuery.fn.load = function( url, params, callback ) {
  8269. if ( typeof url !== "string" && _load ) {
  8270. return _load.apply( this, arguments );
  8271. }
  8272. var selector, response, type,
  8273. self = this,
  8274. off = url.indexOf(" ");
  8275. if ( off >= 0 ) {
  8276. selector = jQuery.trim( url.slice( off, url.length ) );
  8277. url = url.slice( 0, off );
  8278. }
  8279. // If it's a function
  8280. if ( jQuery.isFunction( params ) ) {
  8281. // We assume that it's the callback
  8282. callback = params;
  8283. params = undefined;
  8284. // Otherwise, build a param string
  8285. } else if ( params && typeof params === "object" ) {
  8286. type = "POST";
  8287. }
  8288. // If we have elements to modify, make the request
  8289. if ( self.length > 0 ) {
  8290. jQuery.ajax({
  8291. url: url,
  8292. // if "type" variable is undefined, then "GET" method will be used
  8293. type: type,
  8294. dataType: "html",
  8295. data: params
  8296. }).done(function( responseText ) {
  8297. // Save response for use in complete callback
  8298. response = arguments;
  8299. self.html( selector ?
  8300. // If a selector was specified, locate the right elements in a dummy div
  8301. // Exclude scripts to avoid IE 'Permission Denied' errors
  8302. jQuery("<div>").append( jQuery.parseHTML( responseText ) ).find( selector ) :
  8303. // Otherwise use the full result
  8304. responseText );
  8305. }).complete( callback && function( jqXHR, status ) {
  8306. self.each( callback, response || [ jqXHR.responseText, status, jqXHR ] );
  8307. });
  8308. }
  8309. return this;
  8310. };
  8311. jQuery.expr.filters.animated = function( elem ) {
  8312. return jQuery.grep(jQuery.timers, function( fn ) {
  8313. return elem === fn.elem;
  8314. }).length;
  8315. };
  8316. var docElem = window.document.documentElement;
  8317. /**
  8318. * Gets a window from an element
  8319. */
  8320. function getWindow( elem ) {
  8321. return jQuery.isWindow( elem ) ?
  8322. elem :
  8323. elem.nodeType === 9 ?
  8324. elem.defaultView || elem.parentWindow :
  8325. false;
  8326. }
  8327. jQuery.offset = {
  8328. setOffset: function( elem, options, i ) {
  8329. var curPosition, curLeft, curCSSTop, curTop, curOffset, curCSSLeft, calculatePosition,
  8330. position = jQuery.css( elem, "position" ),
  8331. curElem = jQuery( elem ),
  8332. props = {};
  8333. // set position first, in-case top/left are set even on static elem
  8334. if ( position === "static" ) {
  8335. elem.style.position = "relative";
  8336. }
  8337. curOffset = curElem.offset();
  8338. curCSSTop = jQuery.css( elem, "top" );
  8339. curCSSLeft = jQuery.css( elem, "left" );
  8340. calculatePosition = ( position === "absolute" || position === "fixed" ) &&
  8341. jQuery.inArray("auto", [ curCSSTop, curCSSLeft ] ) > -1;
  8342. // need to be able to calculate position if either top or left is auto and position is either absolute or fixed
  8343. if ( calculatePosition ) {
  8344. curPosition = curElem.position();
  8345. curTop = curPosition.top;
  8346. curLeft = curPosition.left;
  8347. } else {
  8348. curTop = parseFloat( curCSSTop ) || 0;
  8349. curLeft = parseFloat( curCSSLeft ) || 0;
  8350. }
  8351. if ( jQuery.isFunction( options ) ) {
  8352. options = options.call( elem, i, curOffset );
  8353. }
  8354. if ( options.top != null ) {
  8355. props.top = ( options.top - curOffset.top ) + curTop;
  8356. }
  8357. if ( options.left != null ) {
  8358. props.left = ( options.left - curOffset.left ) + curLeft;
  8359. }
  8360. if ( "using" in options ) {
  8361. options.using.call( elem, props );
  8362. } else {
  8363. curElem.css( props );
  8364. }
  8365. }
  8366. };
  8367. jQuery.fn.extend({
  8368. offset: function( options ) {
  8369. if ( arguments.length ) {
  8370. return options === undefined ?
  8371. this :
  8372. this.each(function( i ) {
  8373. jQuery.offset.setOffset( this, options, i );
  8374. });
  8375. }
  8376. var docElem, win,
  8377. box = { top: 0, left: 0 },
  8378. elem = this[ 0 ],
  8379. doc = elem && elem.ownerDocument;
  8380. if ( !doc ) {
  8381. return;
  8382. }
  8383. docElem = doc.documentElement;
  8384. // Make sure it's not a disconnected DOM node
  8385. if ( !jQuery.contains( docElem, elem ) ) {
  8386. return box;
  8387. }
  8388. // If we don't have gBCR, just use 0,0 rather than error
  8389. // BlackBerry 5, iOS 3 (original iPhone)
  8390. if ( typeof elem.getBoundingClientRect !== strundefined ) {
  8391. box = elem.getBoundingClientRect();
  8392. }
  8393. win = getWindow( doc );
  8394. return {
  8395. top: box.top + ( win.pageYOffset || docElem.scrollTop ) - ( docElem.clientTop || 0 ),
  8396. left: box.left + ( win.pageXOffset || docElem.scrollLeft ) - ( docElem.clientLeft || 0 )
  8397. };
  8398. },
  8399. position: function() {
  8400. if ( !this[ 0 ] ) {
  8401. return;
  8402. }
  8403. var offsetParent, offset,
  8404. parentOffset = { top: 0, left: 0 },
  8405. elem = this[ 0 ];
  8406. // fixed elements are offset from window (parentOffset = {top:0, left: 0}, because it is its only offset parent
  8407. if ( jQuery.css( elem, "position" ) === "fixed" ) {
  8408. // we assume that getBoundingClientRect is available when computed position is fixed
  8409. offset = elem.getBoundingClientRect();
  8410. } else {
  8411. // Get *real* offsetParent
  8412. offsetParent = this.offsetParent();
  8413. // Get correct offsets
  8414. offset = this.offset();
  8415. if ( !jQuery.nodeName( offsetParent[ 0 ], "html" ) ) {
  8416. parentOffset = offsetParent.offset();
  8417. }
  8418. // Add offsetParent borders
  8419. parentOffset.top += jQuery.css( offsetParent[ 0 ], "borderTopWidth", true );
  8420. parentOffset.left += jQuery.css( offsetParent[ 0 ], "borderLeftWidth", true );
  8421. }
  8422. // Subtract parent offsets and element margins
  8423. // note: when an element has margin: auto the offsetLeft and marginLeft
  8424. // are the same in Safari causing offset.left to incorrectly be 0
  8425. return {
  8426. top: offset.top - parentOffset.top - jQuery.css( elem, "marginTop", true ),
  8427. left: offset.left - parentOffset.left - jQuery.css( elem, "marginLeft", true)
  8428. };
  8429. },
  8430. offsetParent: function() {
  8431. return this.map(function() {
  8432. var offsetParent = this.offsetParent || docElem;
  8433. while ( offsetParent && ( !jQuery.nodeName( offsetParent, "html" ) && jQuery.css( offsetParent, "position" ) === "static" ) ) {
  8434. offsetParent = offsetParent.offsetParent;
  8435. }
  8436. return offsetParent || docElem;
  8437. });
  8438. }
  8439. });
  8440. // Create scrollLeft and scrollTop methods
  8441. jQuery.each( { scrollLeft: "pageXOffset", scrollTop: "pageYOffset" }, function( method, prop ) {
  8442. var top = /Y/.test( prop );
  8443. jQuery.fn[ method ] = function( val ) {
  8444. return access( this, function( elem, method, val ) {
  8445. var win = getWindow( elem );
  8446. if ( val === undefined ) {
  8447. return win ? (prop in win) ? win[ prop ] :
  8448. win.document.documentElement[ method ] :
  8449. elem[ method ];
  8450. }
  8451. if ( win ) {
  8452. win.scrollTo(
  8453. !top ? val : jQuery( win ).scrollLeft(),
  8454. top ? val : jQuery( win ).scrollTop()
  8455. );
  8456. } else {
  8457. elem[ method ] = val;
  8458. }
  8459. }, method, val, arguments.length, null );
  8460. };
  8461. });
  8462. // Add the top/left cssHooks using jQuery.fn.position
  8463. // Webkit bug: https://bugs.webkit.org/show_bug.cgi?id=29084
  8464. // getComputedStyle returns percent when specified for top/left/bottom/right
  8465. // rather than make the css module depend on the offset module, we just check for it here
  8466. jQuery.each( [ "top", "left" ], function( i, prop ) {
  8467. jQuery.cssHooks[ prop ] = addGetHookIf( support.pixelPosition,
  8468. function( elem, computed ) {
  8469. if ( computed ) {
  8470. computed = curCSS( elem, prop );
  8471. // if curCSS returns percentage, fallback to offset
  8472. return rnumnonpx.test( computed ) ?
  8473. jQuery( elem ).position()[ prop ] + "px" :
  8474. computed;
  8475. }
  8476. }
  8477. );
  8478. });
  8479. // Create innerHeight, innerWidth, height, width, outerHeight and outerWidth methods
  8480. jQuery.each( { Height: "height", Width: "width" }, function( name, type ) {
  8481. jQuery.each( { padding: "inner" + name, content: type, "": "outer" + name }, function( defaultExtra, funcName ) {
  8482. // margin is only for outerHeight, outerWidth
  8483. jQuery.fn[ funcName ] = function( margin, value ) {
  8484. var chainable = arguments.length && ( defaultExtra || typeof margin !== "boolean" ),
  8485. extra = defaultExtra || ( margin === true || value === true ? "margin" : "border" );
  8486. return access( this, function( elem, type, value ) {
  8487. var doc;
  8488. if ( jQuery.isWindow( elem ) ) {
  8489. // As of 5/8/2012 this will yield incorrect results for Mobile Safari, but there
  8490. // isn't a whole lot we can do. See pull request at this URL for discussion:
  8491. // https://github.com/jquery/jquery/pull/764
  8492. return elem.document.documentElement[ "client" + name ];
  8493. }
  8494. // Get document width or height
  8495. if ( elem.nodeType === 9 ) {
  8496. doc = elem.documentElement;
  8497. // Either scroll[Width/Height] or offset[Width/Height] or client[Width/Height], whichever is greatest
  8498. // unfortunately, this causes bug #3838 in IE6/8 only, but there is currently no good, small way to fix it.
  8499. return Math.max(
  8500. elem.body[ "scroll" + name ], doc[ "scroll" + name ],
  8501. elem.body[ "offset" + name ], doc[ "offset" + name ],
  8502. doc[ "client" + name ]
  8503. );
  8504. }
  8505. return value === undefined ?
  8506. // Get width or height on the element, requesting but not forcing parseFloat
  8507. jQuery.css( elem, type, extra ) :
  8508. // Set width or height on the element
  8509. jQuery.style( elem, type, value, extra );
  8510. }, type, chainable ? margin : undefined, chainable, null );
  8511. };
  8512. });
  8513. });
  8514. // The number of elements contained in the matched element set
  8515. jQuery.fn.size = function() {
  8516. return this.length;
  8517. };
  8518. jQuery.fn.andSelf = jQuery.fn.addBack;
  8519. // Register as a named AMD module, since jQuery can be concatenated with other
  8520. // files that may use define, but not via a proper concatenation script that
  8521. // understands anonymous AMD modules. A named AMD is safest and most robust
  8522. // way to register. Lowercase jquery is used because AMD module names are
  8523. // derived from file names, and jQuery is normally delivered in a lowercase
  8524. // file name. Do this after creating the global so that if an AMD module wants
  8525. // to call noConflict to hide this version of jQuery, it will work.
  8526. // Note that for maximum portability, libraries that are not jQuery should
  8527. // declare themselves as anonymous modules, and avoid setting a global if an
  8528. // AMD loader is present. jQuery is a special case. For more information, see
  8529. // https://github.com/jrburke/requirejs/wiki/Updating-existing-libraries#wiki-anon
  8530. if ( typeof define === "function" && define.amd ) {
  8531. define( "jquery", [], function() {
  8532. return jQuery;
  8533. });
  8534. }
  8535. var
  8536. // Map over jQuery in case of overwrite
  8537. _jQuery = window.jQuery,
  8538. // Map over the $ in case of overwrite
  8539. _$ = window.$;
  8540. jQuery.noConflict = function( deep ) {
  8541. if ( window.$ === jQuery ) {
  8542. window.$ = _$;
  8543. }
  8544. if ( deep && window.jQuery === jQuery ) {
  8545. window.jQuery = _jQuery;
  8546. }
  8547. return jQuery;
  8548. };
  8549. // Expose jQuery and $ identifiers, even in
  8550. // AMD (#7102#comment:10, https://github.com/jquery/jquery/pull/557)
  8551. // and CommonJS for browser emulators (#13566)
  8552. if ( typeof noGlobal === strundefined ) {
  8553. window.jQuery = window.$ = jQuery;
  8554. }
  8555. return jQuery;
  8556. }));
  8557. (function($, undefined) {
  8558. /**
  8559. * Unobtrusive scripting adapter for jQuery
  8560. * https://github.com/rails/jquery-ujs
  8561. *
  8562. * Requires jQuery 1.8.0 or later.
  8563. *
  8564. * Released under the MIT license
  8565. *
  8566. */
  8567. // Cut down on the number of issues from people inadvertently including jquery_ujs twice
  8568. // by detecting and raising an error when it happens.
  8569. if ( $.rails !== undefined ) {
  8570. $.error('jquery-ujs has already been loaded!');
  8571. }
  8572. // Shorthand to make it a little easier to call public rails functions from within rails.js
  8573. var rails;
  8574. var $document = $(document);
  8575. $.rails = rails = {
  8576. // Link elements bound by jquery-ujs
  8577. linkClickSelector: 'a[data-confirm], a[data-method], a[data-remote], a[data-disable-with], a[data-disable]',
  8578. // Button elements bound by jquery-ujs
  8579. buttonClickSelector: 'button[data-remote]:not(form button), button[data-confirm]:not(form button)',
  8580. // Select elements bound by jquery-ujs
  8581. inputChangeSelector: 'select[data-remote], input[data-remote], textarea[data-remote]',
  8582. // Form elements bound by jquery-ujs
  8583. formSubmitSelector: 'form',
  8584. // Form input elements bound by jquery-ujs
  8585. formInputClickSelector: 'form input[type=submit], form input[type=image], form button[type=submit], form button:not([type]), input[type=submit][form], input[type=image][form], button[type=submit][form], button[form]:not([type])',
  8586. // Form input elements disabled during form submission
  8587. disableSelector: 'input[data-disable-with]:enabled, button[data-disable-with]:enabled, textarea[data-disable-with]:enabled, input[data-disable]:enabled, button[data-disable]:enabled, textarea[data-disable]:enabled',
  8588. // Form input elements re-enabled after form submission
  8589. enableSelector: 'input[data-disable-with]:disabled, button[data-disable-with]:disabled, textarea[data-disable-with]:disabled, input[data-disable]:disabled, button[data-disable]:disabled, textarea[data-disable]:disabled',
  8590. // Form required input elements
  8591. requiredInputSelector: 'input[name][required]:not([disabled]),textarea[name][required]:not([disabled])',
  8592. // Form file input elements
  8593. fileInputSelector: 'input[type=file]',
  8594. // Link onClick disable selector with possible reenable after remote submission
  8595. linkDisableSelector: 'a[data-disable-with], a[data-disable]',
  8596. // Button onClick disable selector with possible reenable after remote submission
  8597. buttonDisableSelector: 'button[data-remote][data-disable-with], button[data-remote][data-disable]',
  8598. // Make sure that every Ajax request sends the CSRF token
  8599. CSRFProtection: function(xhr) {
  8600. var token = $('meta[name="csrf-token"]').attr('content');
  8601. if (token) xhr.setRequestHeader('X-CSRF-Token', token);
  8602. },
  8603. // making sure that all forms have actual up-to-date token(cached forms contain old one)
  8604. refreshCSRFTokens: function(){
  8605. var csrfToken = $('meta[name=csrf-token]').attr('content');
  8606. var csrfParam = $('meta[name=csrf-param]').attr('content');
  8607. $('form input[name="' + csrfParam + '"]').val(csrfToken);
  8608. },
  8609. // Triggers an event on an element and returns false if the event result is false
  8610. fire: function(obj, name, data) {
  8611. var event = $.Event(name);
  8612. obj.trigger(event, data);
  8613. return event.result !== false;
  8614. },
  8615. // Default confirm dialog, may be overridden with custom confirm dialog in $.rails.confirm
  8616. confirm: function(message) {
  8617. return confirm(message);
  8618. },
  8619. // Default ajax function, may be overridden with custom function in $.rails.ajax
  8620. ajax: function(options) {
  8621. return $.ajax(options);
  8622. },
  8623. // Default way to get an element's href. May be overridden at $.rails.href.
  8624. href: function(element) {
  8625. return element.attr('href');
  8626. },
  8627. // Submits "remote" forms and links with ajax
  8628. handleRemote: function(element) {
  8629. var method, url, data, elCrossDomain, crossDomain, withCredentials, dataType, options;
  8630. if (rails.fire(element, 'ajax:before')) {
  8631. elCrossDomain = element.data('cross-domain');
  8632. crossDomain = elCrossDomain === undefined ? null : elCrossDomain;
  8633. withCredentials = element.data('with-credentials') || null;
  8634. dataType = element.data('type') || ($.ajaxSettings && $.ajaxSettings.dataType);
  8635. if (element.is('form')) {
  8636. method = element.attr('method');
  8637. url = element.attr('action');
  8638. data = element.serializeArray();
  8639. // memoized value from clicked submit button
  8640. var button = element.data('ujs:submit-button');
  8641. if (button) {
  8642. data.push(button);
  8643. element.data('ujs:submit-button', null);
  8644. }
  8645. } else if (element.is(rails.inputChangeSelector)) {
  8646. method = element.data('method');
  8647. url = element.data('url');
  8648. data = element.serialize();
  8649. if (element.data('params')) data = data + "&" + element.data('params');
  8650. } else if (element.is(rails.buttonClickSelector)) {
  8651. method = element.data('method') || 'get';
  8652. url = element.data('url');
  8653. data = element.serialize();
  8654. if (element.data('params')) data = data + "&" + element.data('params');
  8655. } else {
  8656. method = element.data('method');
  8657. url = rails.href(element);
  8658. data = element.data('params') || null;
  8659. }
  8660. options = {
  8661. type: method || 'GET', data: data, dataType: dataType,
  8662. // stopping the "ajax:beforeSend" event will cancel the ajax request
  8663. beforeSend: function(xhr, settings) {
  8664. if (settings.dataType === undefined) {
  8665. xhr.setRequestHeader('accept', '*/*;q=0.5, ' + settings.accepts.script);
  8666. }
  8667. if (rails.fire(element, 'ajax:beforeSend', [xhr, settings])) {
  8668. element.trigger('ajax:send', xhr);
  8669. } else {
  8670. return false;
  8671. }
  8672. },
  8673. success: function(data, status, xhr) {
  8674. element.trigger('ajax:success', [data, status, xhr]);
  8675. },
  8676. complete: function(xhr, status) {
  8677. element.trigger('ajax:complete', [xhr, status]);
  8678. },
  8679. error: function(xhr, status, error) {
  8680. element.trigger('ajax:error', [xhr, status, error]);
  8681. },
  8682. crossDomain: crossDomain
  8683. };
  8684. // There is no withCredentials for IE6-8 when
  8685. // "Enable native XMLHTTP support" is disabled
  8686. if (withCredentials) {
  8687. options.xhrFields = {
  8688. withCredentials: withCredentials
  8689. };
  8690. }
  8691. // Only pass url to `ajax` options if not blank
  8692. if (url) { options.url = url; }
  8693. return rails.ajax(options);
  8694. } else {
  8695. return false;
  8696. }
  8697. },
  8698. // Handles "data-method" on links such as:
  8699. // <a href="/users/5" data-method="delete" rel="nofollow" data-confirm="Are you sure?">Delete</a>
  8700. handleMethod: function(link) {
  8701. var href = rails.href(link),
  8702. method = link.data('method'),
  8703. target = link.attr('target'),
  8704. csrfToken = $('meta[name=csrf-token]').attr('content'),
  8705. csrfParam = $('meta[name=csrf-param]').attr('content'),
  8706. form = $('<form method="post" action="' + href + '"></form>'),
  8707. metadataInput = '<input name="_method" value="' + method + '" type="hidden" />';
  8708. if (csrfParam !== undefined && csrfToken !== undefined) {
  8709. metadataInput += '<input name="' + csrfParam + '" value="' + csrfToken + '" type="hidden" />';
  8710. }
  8711. if (target) { form.attr('target', target); }
  8712. form.hide().append(metadataInput).appendTo('body');
  8713. form.submit();
  8714. },
  8715. // Helper function that returns form elements that match the specified CSS selector
  8716. // If form is actually a "form" element this will return associated elements outside the from that have
  8717. // the html form attribute set
  8718. formElements: function(form, selector) {
  8719. return form.is('form') ? $(form[0].elements).filter(selector) : form.find(selector);
  8720. },
  8721. /* Disables form elements:
  8722. - Caches element value in 'ujs:enable-with' data store
  8723. - Replaces element text with value of 'data-disable-with' attribute
  8724. - Sets disabled property to true
  8725. */
  8726. disableFormElements: function(form) {
  8727. rails.formElements(form, rails.disableSelector).each(function() {
  8728. rails.disableFormElement($(this));
  8729. });
  8730. },
  8731. disableFormElement: function(element) {
  8732. var method, replacement;
  8733. method = element.is('button') ? 'html' : 'val';
  8734. replacement = element.data('disable-with');
  8735. element.data('ujs:enable-with', element[method]());
  8736. if (replacement !== undefined) {
  8737. element[method](replacement);
  8738. }
  8739. element.prop('disabled', true);
  8740. },
  8741. /* Re-enables disabled form elements:
  8742. - Replaces element text with cached value from 'ujs:enable-with' data store (created in `disableFormElements`)
  8743. - Sets disabled property to false
  8744. */
  8745. enableFormElements: function(form) {
  8746. rails.formElements(form, rails.enableSelector).each(function() {
  8747. rails.enableFormElement($(this));
  8748. });
  8749. },
  8750. enableFormElement: function(element) {
  8751. var method = element.is('button') ? 'html' : 'val';
  8752. if (element.data('ujs:enable-with')) element[method](element.data('ujs:enable-with'));
  8753. element.prop('disabled', false);
  8754. },
  8755. /* For 'data-confirm' attribute:
  8756. - Fires `confirm` event
  8757. - Shows the confirmation dialog
  8758. - Fires the `confirm:complete` event
  8759. Returns `true` if no function stops the chain and user chose yes; `false` otherwise.
  8760. Attaching a handler to the element's `confirm` event that returns a `falsy` value cancels the confirmation dialog.
  8761. Attaching a handler to the element's `confirm:complete` event that returns a `falsy` value makes this function
  8762. return false. The `confirm:complete` event is fired whether or not the user answered true or false to the dialog.
  8763. */
  8764. allowAction: function(element) {
  8765. var message = element.data('confirm'),
  8766. answer = false, callback;
  8767. if (!message) { return true; }
  8768. if (rails.fire(element, 'confirm')) {
  8769. answer = rails.confirm(message);
  8770. callback = rails.fire(element, 'confirm:complete', [answer]);
  8771. }
  8772. return answer && callback;
  8773. },
  8774. // Helper function which checks for blank inputs in a form that match the specified CSS selector
  8775. blankInputs: function(form, specifiedSelector, nonBlank) {
  8776. var inputs = $(), input, valueToCheck,
  8777. selector = specifiedSelector || 'input,textarea',
  8778. allInputs = form.find(selector);
  8779. allInputs.each(function() {
  8780. input = $(this);
  8781. valueToCheck = input.is('input[type=checkbox],input[type=radio]') ? input.is(':checked') : input.val();
  8782. // If nonBlank and valueToCheck are both truthy, or nonBlank and valueToCheck are both falsey
  8783. if (!valueToCheck === !nonBlank) {
  8784. // Don't count unchecked required radio if other radio with same name is checked
  8785. if (input.is('input[type=radio]') && allInputs.filter('input[type=radio]:checked[name="' + input.attr('name') + '"]').length) {
  8786. return true; // Skip to next input
  8787. }
  8788. inputs = inputs.add(input);
  8789. }
  8790. });
  8791. return inputs.length ? inputs : false;
  8792. },
  8793. // Helper function which checks for non-blank inputs in a form that match the specified CSS selector
  8794. nonBlankInputs: function(form, specifiedSelector) {
  8795. return rails.blankInputs(form, specifiedSelector, true); // true specifies nonBlank
  8796. },
  8797. // Helper function, needed to provide consistent behavior in IE
  8798. stopEverything: function(e) {
  8799. $(e.target).trigger('ujs:everythingStopped');
  8800. e.stopImmediatePropagation();
  8801. return false;
  8802. },
  8803. // replace element's html with the 'data-disable-with' after storing original html
  8804. // and prevent clicking on it
  8805. disableElement: function(element) {
  8806. var replacement = element.data('disable-with');
  8807. element.data('ujs:enable-with', element.html()); // store enabled state
  8808. if (replacement !== undefined) {
  8809. element.html(replacement);
  8810. }
  8811. element.bind('click.railsDisable', function(e) { // prevent further clicking
  8812. return rails.stopEverything(e);
  8813. });
  8814. },
  8815. // restore element to its original state which was disabled by 'disableElement' above
  8816. enableElement: function(element) {
  8817. if (element.data('ujs:enable-with') !== undefined) {
  8818. element.html(element.data('ujs:enable-with')); // set to old enabled state
  8819. element.removeData('ujs:enable-with'); // clean up cache
  8820. }
  8821. element.unbind('click.railsDisable'); // enable element
  8822. }
  8823. };
  8824. if (rails.fire($document, 'rails:attachBindings')) {
  8825. $.ajaxPrefilter(function(options, originalOptions, xhr){ if ( !options.crossDomain ) { rails.CSRFProtection(xhr); }});
  8826. $document.delegate(rails.linkDisableSelector, 'ajax:complete', function() {
  8827. rails.enableElement($(this));
  8828. });
  8829. $document.delegate(rails.buttonDisableSelector, 'ajax:complete', function() {
  8830. rails.enableFormElement($(this));
  8831. });
  8832. $document.delegate(rails.linkClickSelector, 'click.rails', function(e) {
  8833. var link = $(this), method = link.data('method'), data = link.data('params'), metaClick = e.metaKey || e.ctrlKey;
  8834. if (!rails.allowAction(link)) return rails.stopEverything(e);
  8835. if (!metaClick && link.is(rails.linkDisableSelector)) rails.disableElement(link);
  8836. if (link.data('remote') !== undefined) {
  8837. if (metaClick && (!method || method === 'GET') && !data) { return true; }
  8838. var handleRemote = rails.handleRemote(link);
  8839. // response from rails.handleRemote() will either be false or a deferred object promise.
  8840. if (handleRemote === false) {
  8841. rails.enableElement(link);
  8842. } else {
  8843. handleRemote.error( function() { rails.enableElement(link); } );
  8844. }
  8845. return false;
  8846. } else if (link.data('method')) {
  8847. rails.handleMethod(link);
  8848. return false;
  8849. }
  8850. });
  8851. $document.delegate(rails.buttonClickSelector, 'click.rails', function(e) {
  8852. var button = $(this);
  8853. if (!rails.allowAction(button)) return rails.stopEverything(e);
  8854. if (button.is(rails.buttonDisableSelector)) rails.disableFormElement(button);
  8855. var handleRemote = rails.handleRemote(button);
  8856. // response from rails.handleRemote() will either be false or a deferred object promise.
  8857. if (handleRemote === false) {
  8858. rails.enableFormElement(button);
  8859. } else {
  8860. handleRemote.error( function() { rails.enableFormElement(button); } );
  8861. }
  8862. return false;
  8863. });
  8864. $document.delegate(rails.inputChangeSelector, 'change.rails', function(e) {
  8865. var link = $(this);
  8866. if (!rails.allowAction(link)) return rails.stopEverything(e);
  8867. rails.handleRemote(link);
  8868. return false;
  8869. });
  8870. $document.delegate(rails.formSubmitSelector, 'submit.rails', function(e) {
  8871. var form = $(this),
  8872. remote = form.data('remote') !== undefined,
  8873. blankRequiredInputs,
  8874. nonBlankFileInputs;
  8875. if (!rails.allowAction(form)) return rails.stopEverything(e);
  8876. // skip other logic when required values are missing or file upload is present
  8877. if (form.attr('novalidate') == undefined) {
  8878. blankRequiredInputs = rails.blankInputs(form, rails.requiredInputSelector);
  8879. if (blankRequiredInputs && rails.fire(form, 'ajax:aborted:required', [blankRequiredInputs])) {
  8880. return rails.stopEverything(e);
  8881. }
  8882. }
  8883. if (remote) {
  8884. nonBlankFileInputs = rails.nonBlankInputs(form, rails.fileInputSelector);
  8885. if (nonBlankFileInputs) {
  8886. // slight timeout so that the submit button gets properly serialized
  8887. // (make it easy for event handler to serialize form without disabled values)
  8888. setTimeout(function(){ rails.disableFormElements(form); }, 13);
  8889. var aborted = rails.fire(form, 'ajax:aborted:file', [nonBlankFileInputs]);
  8890. // re-enable form elements if event bindings return false (canceling normal form submission)
  8891. if (!aborted) { setTimeout(function(){ rails.enableFormElements(form); }, 13); }
  8892. return aborted;
  8893. }
  8894. rails.handleRemote(form);
  8895. return false;
  8896. } else {
  8897. // slight timeout so that the submit button gets properly serialized
  8898. setTimeout(function(){ rails.disableFormElements(form); }, 13);
  8899. }
  8900. });
  8901. $document.delegate(rails.formInputClickSelector, 'click.rails', function(event) {
  8902. var button = $(this);
  8903. if (!rails.allowAction(button)) return rails.stopEverything(event);
  8904. // register the pressed submit button
  8905. var name = button.attr('name'),
  8906. data = name ? {name:name, value:button.val()} : null;
  8907. button.closest('form').data('ujs:submit-button', data);
  8908. });
  8909. $document.delegate(rails.formSubmitSelector, 'ajax:send.rails', function(event) {
  8910. if (this == event.target) rails.disableFormElements($(this));
  8911. });
  8912. $document.delegate(rails.formSubmitSelector, 'ajax:complete.rails', function(event) {
  8913. if (this == event.target) rails.enableFormElements($(this));
  8914. });
  8915. $(function(){
  8916. rails.refreshCSRFTokens();
  8917. });
  8918. }
  8919. })( jQuery );
  8920. /* ===================================================
  8921. * bootstrap-transition.js v2.3.2
  8922. * http://twitter.github.com/bootstrap/javascript.html#transitions
  8923. * ===================================================
  8924. * Copyright 2012 Twitter, Inc.
  8925. *
  8926. * Licensed under the Apache License, Version 2.0 (the "License");
  8927. * you may not use this file except in compliance with the License.
  8928. * You may obtain a copy of the License at
  8929. *
  8930. * http://www.apache.org/licenses/LICENSE-2.0
  8931. *
  8932. * Unless required by applicable law or agreed to in writing, software
  8933. * distributed under the License is distributed on an "AS IS" BASIS,
  8934. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  8935. * See the License for the specific language governing permissions and
  8936. * limitations under the License.
  8937. * ========================================================== */
  8938. !function ($) {
  8939. "use strict"; // jshint ;_;
  8940. /* CSS TRANSITION SUPPORT (http://www.modernizr.com/)
  8941. * ======================================================= */
  8942. $(function () {
  8943. $.support.transition = (function () {
  8944. var transitionEnd = (function () {
  8945. var el = document.createElement('bootstrap')
  8946. , transEndEventNames = {
  8947. 'WebkitTransition' : 'webkitTransitionEnd'
  8948. , 'MozTransition' : 'transitionend'
  8949. , 'OTransition' : 'oTransitionEnd otransitionend'
  8950. , 'transition' : 'transitionend'
  8951. }
  8952. , name
  8953. for (name in transEndEventNames){
  8954. if (el.style[name] !== undefined) {
  8955. return transEndEventNames[name]
  8956. }
  8957. }
  8958. }())
  8959. return transitionEnd && {
  8960. end: transitionEnd
  8961. }
  8962. })()
  8963. })
  8964. }(window.jQuery);
  8965. /* ==========================================================
  8966. * bootstrap-alert.js v2.3.2
  8967. * http://twitter.github.com/bootstrap/javascript.html#alerts
  8968. * ==========================================================
  8969. * Copyright 2012 Twitter, Inc.
  8970. *
  8971. * Licensed under the Apache License, Version 2.0 (the "License");
  8972. * you may not use this file except in compliance with the License.
  8973. * You may obtain a copy of the License at
  8974. *
  8975. * http://www.apache.org/licenses/LICENSE-2.0
  8976. *
  8977. * Unless required by applicable law or agreed to in writing, software
  8978. * distributed under the License is distributed on an "AS IS" BASIS,
  8979. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  8980. * See the License for the specific language governing permissions and
  8981. * limitations under the License.
  8982. * ========================================================== */
  8983. !function ($) {
  8984. "use strict"; // jshint ;_;
  8985. /* ALERT CLASS DEFINITION
  8986. * ====================== */
  8987. var dismiss = '[data-dismiss="alert"]'
  8988. , Alert = function (el) {
  8989. $(el).on('click', dismiss, this.close)
  8990. }
  8991. Alert.prototype.close = function (e) {
  8992. var $this = $(this)
  8993. , selector = $this.attr('data-target')
  8994. , $parent
  8995. if (!selector) {
  8996. selector = $this.attr('href')
  8997. selector = selector && selector.replace(/.*(?=#[^\s]*$)/, '') //strip for ie7
  8998. }
  8999. $parent = $(selector)
  9000. e && e.preventDefault()
  9001. $parent.length || ($parent = $this.hasClass('alert') ? $this : $this.parent())
  9002. $parent.trigger(e = $.Event('close'))
  9003. if (e.isDefaultPrevented()) return
  9004. $parent.removeClass('in')
  9005. function removeElement() {
  9006. $parent
  9007. .trigger('closed')
  9008. .remove()
  9009. }
  9010. $.support.transition && $parent.hasClass('fade') ?
  9011. $parent.on($.support.transition.end, removeElement) :
  9012. removeElement()
  9013. }
  9014. /* ALERT PLUGIN DEFINITION
  9015. * ======================= */
  9016. var old = $.fn.alert
  9017. $.fn.alert = function (option) {
  9018. return this.each(function () {
  9019. var $this = $(this)
  9020. , data = $this.data('alert')
  9021. if (!data) $this.data('alert', (data = new Alert(this)))
  9022. if (typeof option == 'string') data[option].call($this)
  9023. })
  9024. }
  9025. $.fn.alert.Constructor = Alert
  9026. /* ALERT NO CONFLICT
  9027. * ================= */
  9028. $.fn.alert.noConflict = function () {
  9029. $.fn.alert = old
  9030. return this
  9031. }
  9032. /* ALERT DATA-API
  9033. * ============== */
  9034. $(document).on('click.alert.data-api', dismiss, Alert.prototype.close)
  9035. }(window.jQuery);
  9036. /* =========================================================
  9037. * bootstrap-modal.js v2.3.2
  9038. * http://twitter.github.com/bootstrap/javascript.html#modals
  9039. * =========================================================
  9040. * Copyright 2012 Twitter, Inc.
  9041. *
  9042. * Licensed under the Apache License, Version 2.0 (the "License");
  9043. * you may not use this file except in compliance with the License.
  9044. * You may obtain a copy of the License at
  9045. *
  9046. * http://www.apache.org/licenses/LICENSE-2.0
  9047. *
  9048. * Unless required by applicable law or agreed to in writing, software
  9049. * distributed under the License is distributed on an "AS IS" BASIS,
  9050. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  9051. * See the License for the specific language governing permissions and
  9052. * limitations under the License.
  9053. * ========================================================= */
  9054. !function ($) {
  9055. "use strict"; // jshint ;_;
  9056. /* MODAL CLASS DEFINITION
  9057. * ====================== */
  9058. var Modal = function (element, options) {
  9059. this.options = options
  9060. this.$element = $(element)
  9061. .delegate('[data-dismiss="modal"]', 'click.dismiss.modal', $.proxy(this.hide, this))
  9062. this.options.remote && this.$element.find('.modal-body').load(this.options.remote)
  9063. }
  9064. Modal.prototype = {
  9065. constructor: Modal
  9066. , toggle: function () {
  9067. return this[!this.isShown ? 'show' : 'hide']()
  9068. }
  9069. , show: function () {
  9070. var that = this
  9071. , e = $.Event('show')
  9072. this.$element.trigger(e)
  9073. if (this.isShown || e.isDefaultPrevented()) return
  9074. this.isShown = true
  9075. this.escape()
  9076. this.backdrop(function () {
  9077. var transition = $.support.transition && that.$element.hasClass('fade')
  9078. if (!that.$element.parent().length) {
  9079. that.$element.appendTo(document.body) //don't move modals dom position
  9080. }
  9081. that.$element.show()
  9082. if (transition) {
  9083. that.$element[0].offsetWidth // force reflow
  9084. }
  9085. that.$element
  9086. .addClass('in')
  9087. .attr('aria-hidden', false)
  9088. that.enforceFocus()
  9089. transition ?
  9090. that.$element.one($.support.transition.end, function () { that.$element.focus().trigger('shown') }) :
  9091. that.$element.focus().trigger('shown')
  9092. })
  9093. }
  9094. , hide: function (e) {
  9095. e && e.preventDefault()
  9096. var that = this
  9097. e = $.Event('hide')
  9098. this.$element.trigger(e)
  9099. if (!this.isShown || e.isDefaultPrevented()) return
  9100. this.isShown = false
  9101. this.escape()
  9102. $(document).off('focusin.modal')
  9103. this.$element
  9104. .removeClass('in')
  9105. .attr('aria-hidden', true)
  9106. $.support.transition && this.$element.hasClass('fade') ?
  9107. this.hideWithTransition() :
  9108. this.hideModal()
  9109. }
  9110. , enforceFocus: function () {
  9111. var that = this
  9112. $(document).on('focusin.modal', function (e) {
  9113. if (that.$element[0] !== e.target && !that.$element.has(e.target).length) {
  9114. that.$element.focus()
  9115. }
  9116. })
  9117. }
  9118. , escape: function () {
  9119. var that = this
  9120. if (this.isShown && this.options.keyboard) {
  9121. this.$element.on('keyup.dismiss.modal', function ( e ) {
  9122. e.which == 27 && that.hide()
  9123. })
  9124. } else if (!this.isShown) {
  9125. this.$element.off('keyup.dismiss.modal')
  9126. }
  9127. }
  9128. , hideWithTransition: function () {
  9129. var that = this
  9130. , timeout = setTimeout(function () {
  9131. that.$element.off($.support.transition.end)
  9132. that.hideModal()
  9133. }, 500)
  9134. this.$element.one($.support.transition.end, function () {
  9135. clearTimeout(timeout)
  9136. that.hideModal()
  9137. })
  9138. }
  9139. , hideModal: function () {
  9140. var that = this
  9141. this.$element.hide()
  9142. this.backdrop(function () {
  9143. that.removeBackdrop()
  9144. that.$element.trigger('hidden')
  9145. })
  9146. }
  9147. , removeBackdrop: function () {
  9148. this.$backdrop && this.$backdrop.remove()
  9149. this.$backdrop = null
  9150. }
  9151. , backdrop: function (callback) {
  9152. var that = this
  9153. , animate = this.$element.hasClass('fade') ? 'fade' : ''
  9154. if (this.isShown && this.options.backdrop) {
  9155. var doAnimate = $.support.transition && animate
  9156. this.$backdrop = $('<div class="modal-backdrop ' + animate + '" />')
  9157. .appendTo(document.body)
  9158. this.$backdrop.click(
  9159. this.options.backdrop == 'static' ?
  9160. $.proxy(this.$element[0].focus, this.$element[0])
  9161. : $.proxy(this.hide, this)
  9162. )
  9163. if (doAnimate) this.$backdrop[0].offsetWidth // force reflow
  9164. this.$backdrop.addClass('in')
  9165. if (!callback) return
  9166. doAnimate ?
  9167. this.$backdrop.one($.support.transition.end, callback) :
  9168. callback()
  9169. } else if (!this.isShown && this.$backdrop) {
  9170. this.$backdrop.removeClass('in')
  9171. $.support.transition && this.$element.hasClass('fade')?
  9172. this.$backdrop.one($.support.transition.end, callback) :
  9173. callback()
  9174. } else if (callback) {
  9175. callback()
  9176. }
  9177. }
  9178. }
  9179. /* MODAL PLUGIN DEFINITION
  9180. * ======================= */
  9181. var old = $.fn.modal
  9182. $.fn.modal = function (option) {
  9183. return this.each(function () {
  9184. var $this = $(this)
  9185. , data = $this.data('modal')
  9186. , options = $.extend({}, $.fn.modal.defaults, $this.data(), typeof option == 'object' && option)
  9187. if (!data) $this.data('modal', (data = new Modal(this, options)))
  9188. if (typeof option == 'string') data[option]()
  9189. else if (options.show) data.show()
  9190. })
  9191. }
  9192. $.fn.modal.defaults = {
  9193. backdrop: true
  9194. , keyboard: true
  9195. , show: true
  9196. }
  9197. $.fn.modal.Constructor = Modal
  9198. /* MODAL NO CONFLICT
  9199. * ================= */
  9200. $.fn.modal.noConflict = function () {
  9201. $.fn.modal = old
  9202. return this
  9203. }
  9204. /* MODAL DATA-API
  9205. * ============== */
  9206. $(document).on('click.modal.data-api', '[data-toggle="modal"]', function (e) {
  9207. var $this = $(this)
  9208. , href = $this.attr('href')
  9209. , $target = $($this.attr('data-target') || (href && href.replace(/.*(?=#[^\s]+$)/, ''))) //strip for ie7
  9210. , option = $target.data('modal') ? 'toggle' : $.extend({ remote:!/#/.test(href) && href }, $target.data(), $this.data())
  9211. e.preventDefault()
  9212. $target
  9213. .modal(option)
  9214. .one('hide', function () {
  9215. $this.focus()
  9216. })
  9217. })
  9218. }(window.jQuery);
  9219. /* ============================================================
  9220. * bootstrap-dropdown.js v2.3.2
  9221. * http://twitter.github.com/bootstrap/javascript.html#dropdowns
  9222. * ============================================================
  9223. * Copyright 2012 Twitter, Inc.
  9224. *
  9225. * Licensed under the Apache License, Version 2.0 (the "License");
  9226. * you may not use this file except in compliance with the License.
  9227. * You may obtain a copy of the License at
  9228. *
  9229. * http://www.apache.org/licenses/LICENSE-2.0
  9230. *
  9231. * Unless required by applicable law or agreed to in writing, software
  9232. * distributed under the License is distributed on an "AS IS" BASIS,
  9233. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  9234. * See the License for the specific language governing permissions and
  9235. * limitations under the License.
  9236. * ============================================================ */
  9237. !function ($) {
  9238. "use strict"; // jshint ;_;
  9239. /* DROPDOWN CLASS DEFINITION
  9240. * ========================= */
  9241. var toggle = '[data-toggle=dropdown]'
  9242. , Dropdown = function (element) {
  9243. var $el = $(element).on('click.dropdown.data-api', this.toggle)
  9244. $('html').on('click.dropdown.data-api', function () {
  9245. $el.parent().removeClass('open')
  9246. })
  9247. }
  9248. Dropdown.prototype = {
  9249. constructor: Dropdown
  9250. , toggle: function (e) {
  9251. var $this = $(this)
  9252. , $parent
  9253. , isActive
  9254. if ($this.is('.disabled, :disabled')) return
  9255. $parent = getParent($this)
  9256. isActive = $parent.hasClass('open')
  9257. clearMenus()
  9258. if (!isActive) {
  9259. if ('ontouchstart' in document.documentElement) {
  9260. // if mobile we we use a backdrop because click events don't delegate
  9261. $('<div class="dropdown-backdrop"/>').insertBefore($(this)).on('click', clearMenus)
  9262. }
  9263. $parent.toggleClass('open')
  9264. }
  9265. $this.focus()
  9266. return false
  9267. }
  9268. , keydown: function (e) {
  9269. var $this
  9270. , $items
  9271. , $active
  9272. , $parent
  9273. , isActive
  9274. , index
  9275. if (!/(38|40|27)/.test(e.keyCode)) return
  9276. $this = $(this)
  9277. e.preventDefault()
  9278. e.stopPropagation()
  9279. if ($this.is('.disabled, :disabled')) return
  9280. $parent = getParent($this)
  9281. isActive = $parent.hasClass('open')
  9282. if (!isActive || (isActive && e.keyCode == 27)) {
  9283. if (e.which == 27) $parent.find(toggle).focus()
  9284. return $this.click()
  9285. }
  9286. $items = $('[role=menu] li:not(.divider):visible a', $parent)
  9287. if (!$items.length) return
  9288. index = $items.index($items.filter(':focus'))
  9289. if (e.keyCode == 38 && index > 0) index-- // up
  9290. if (e.keyCode == 40 && index < $items.length - 1) index++ // down
  9291. if (!~index) index = 0
  9292. $items
  9293. .eq(index)
  9294. .focus()
  9295. }
  9296. }
  9297. function clearMenus() {
  9298. $('.dropdown-backdrop').remove()
  9299. $(toggle).each(function () {
  9300. getParent($(this)).removeClass('open')
  9301. })
  9302. }
  9303. function getParent($this) {
  9304. var selector = $this.attr('data-target')
  9305. , $parent
  9306. if (!selector) {
  9307. selector = $this.attr('href')
  9308. selector = selector && /#/.test(selector) && selector.replace(/.*(?=#[^\s]*$)/, '') //strip for ie7
  9309. }
  9310. $parent = selector && $(selector)
  9311. if (!$parent || !$parent.length) $parent = $this.parent()
  9312. return $parent
  9313. }
  9314. /* DROPDOWN PLUGIN DEFINITION
  9315. * ========================== */
  9316. var old = $.fn.dropdown
  9317. $.fn.dropdown = function (option) {
  9318. return this.each(function () {
  9319. var $this = $(this)
  9320. , data = $this.data('dropdown')
  9321. if (!data) $this.data('dropdown', (data = new Dropdown(this)))
  9322. if (typeof option == 'string') data[option].call($this)
  9323. })
  9324. }
  9325. $.fn.dropdown.Constructor = Dropdown
  9326. /* DROPDOWN NO CONFLICT
  9327. * ==================== */
  9328. $.fn.dropdown.noConflict = function () {
  9329. $.fn.dropdown = old
  9330. return this
  9331. }
  9332. /* APPLY TO STANDARD DROPDOWN ELEMENTS
  9333. * =================================== */
  9334. $(document)
  9335. .on('click.dropdown.data-api', clearMenus)
  9336. .on('click.dropdown.data-api', '.dropdown form', function (e) { e.stopPropagation() })
  9337. .on('click.dropdown.data-api' , toggle, Dropdown.prototype.toggle)
  9338. .on('keydown.dropdown.data-api', toggle + ', [role=menu]' , Dropdown.prototype.keydown)
  9339. }(window.jQuery);
  9340. /* =============================================================
  9341. * bootstrap-scrollspy.js v2.3.2
  9342. * http://twitter.github.com/bootstrap/javascript.html#scrollspy
  9343. * =============================================================
  9344. * Copyright 2012 Twitter, Inc.
  9345. *
  9346. * Licensed under the Apache License, Version 2.0 (the "License");
  9347. * you may not use this file except in compliance with the License.
  9348. * You may obtain a copy of the License at
  9349. *
  9350. * http://www.apache.org/licenses/LICENSE-2.0
  9351. *
  9352. * Unless required by applicable law or agreed to in writing, software
  9353. * distributed under the License is distributed on an "AS IS" BASIS,
  9354. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  9355. * See the License for the specific language governing permissions and
  9356. * limitations under the License.
  9357. * ============================================================== */
  9358. !function ($) {
  9359. "use strict"; // jshint ;_;
  9360. /* SCROLLSPY CLASS DEFINITION
  9361. * ========================== */
  9362. function ScrollSpy(element, options) {
  9363. var process = $.proxy(this.process, this)
  9364. , $element = $(element).is('body') ? $(window) : $(element)
  9365. , href
  9366. this.options = $.extend({}, $.fn.scrollspy.defaults, options)
  9367. this.$scrollElement = $element.on('scroll.scroll-spy.data-api', process)
  9368. this.selector = (this.options.target
  9369. || ((href = $(element).attr('href')) && href.replace(/.*(?=#[^\s]+$)/, '')) //strip for ie7
  9370. || '') + ' .nav li > a'
  9371. this.$body = $('body')
  9372. this.refresh()
  9373. this.process()
  9374. }
  9375. ScrollSpy.prototype = {
  9376. constructor: ScrollSpy
  9377. , refresh: function () {
  9378. var self = this
  9379. , $targets
  9380. this.offsets = $([])
  9381. this.targets = $([])
  9382. $targets = this.$body
  9383. .find(this.selector)
  9384. .map(function () {
  9385. var $el = $(this)
  9386. , href = $el.data('target') || $el.attr('href')
  9387. , $href = /^#\w/.test(href) && $(href)
  9388. return ( $href
  9389. && $href.length
  9390. && [[ $href.position().top + (!$.isWindow(self.$scrollElement.get(0)) && self.$scrollElement.scrollTop()), href ]] ) || null
  9391. })
  9392. .sort(function (a, b) { return a[0] - b[0] })
  9393. .each(function () {
  9394. self.offsets.push(this[0])
  9395. self.targets.push(this[1])
  9396. })
  9397. }
  9398. , process: function () {
  9399. var scrollTop = this.$scrollElement.scrollTop() + this.options.offset
  9400. , scrollHeight = this.$scrollElement[0].scrollHeight || this.$body[0].scrollHeight
  9401. , maxScroll = scrollHeight - this.$scrollElement.height()
  9402. , offsets = this.offsets
  9403. , targets = this.targets
  9404. , activeTarget = this.activeTarget
  9405. , i
  9406. if (scrollTop >= maxScroll) {
  9407. return activeTarget != (i = targets.last()[0])
  9408. && this.activate ( i )
  9409. }
  9410. for (i = offsets.length; i--;) {
  9411. activeTarget != targets[i]
  9412. && scrollTop >= offsets[i]
  9413. && (!offsets[i + 1] || scrollTop <= offsets[i + 1])
  9414. && this.activate( targets[i] )
  9415. }
  9416. }
  9417. , activate: function (target) {
  9418. var active
  9419. , selector
  9420. this.activeTarget = target
  9421. $(this.selector)
  9422. .parent('.active')
  9423. .removeClass('active')
  9424. selector = this.selector
  9425. + '[data-target="' + target + '"],'
  9426. + this.selector + '[href="' + target + '"]'
  9427. active = $(selector)
  9428. .parent('li')
  9429. .addClass('active')
  9430. if (active.parent('.dropdown-menu').length) {
  9431. active = active.closest('li.dropdown').addClass('active')
  9432. }
  9433. active.trigger('activate')
  9434. }
  9435. }
  9436. /* SCROLLSPY PLUGIN DEFINITION
  9437. * =========================== */
  9438. var old = $.fn.scrollspy
  9439. $.fn.scrollspy = function (option) {
  9440. return this.each(function () {
  9441. var $this = $(this)
  9442. , data = $this.data('scrollspy')
  9443. , options = typeof option == 'object' && option
  9444. if (!data) $this.data('scrollspy', (data = new ScrollSpy(this, options)))
  9445. if (typeof option == 'string') data[option]()
  9446. })
  9447. }
  9448. $.fn.scrollspy.Constructor = ScrollSpy
  9449. $.fn.scrollspy.defaults = {
  9450. offset: 10
  9451. }
  9452. /* SCROLLSPY NO CONFLICT
  9453. * ===================== */
  9454. $.fn.scrollspy.noConflict = function () {
  9455. $.fn.scrollspy = old
  9456. return this
  9457. }
  9458. /* SCROLLSPY DATA-API
  9459. * ================== */
  9460. $(window).on('load', function () {
  9461. $('[data-spy="scroll"]').each(function () {
  9462. var $spy = $(this)
  9463. $spy.scrollspy($spy.data())
  9464. })
  9465. })
  9466. }(window.jQuery);
  9467. /* ========================================================
  9468. * bootstrap-tab.js v2.3.2
  9469. * http://twitter.github.com/bootstrap/javascript.html#tabs
  9470. * ========================================================
  9471. * Copyright 2012 Twitter, Inc.
  9472. *
  9473. * Licensed under the Apache License, Version 2.0 (the "License");
  9474. * you may not use this file except in compliance with the License.
  9475. * You may obtain a copy of the License at
  9476. *
  9477. * http://www.apache.org/licenses/LICENSE-2.0
  9478. *
  9479. * Unless required by applicable law or agreed to in writing, software
  9480. * distributed under the License is distributed on an "AS IS" BASIS,
  9481. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  9482. * See the License for the specific language governing permissions and
  9483. * limitations under the License.
  9484. * ======================================================== */
  9485. !function ($) {
  9486. "use strict"; // jshint ;_;
  9487. /* TAB CLASS DEFINITION
  9488. * ==================== */
  9489. var Tab = function (element) {
  9490. this.element = $(element)
  9491. }
  9492. Tab.prototype = {
  9493. constructor: Tab
  9494. , show: function () {
  9495. var $this = this.element
  9496. , $ul = $this.closest('ul:not(.dropdown-menu)')
  9497. , selector = $this.attr('data-target')
  9498. , previous
  9499. , $target
  9500. , e
  9501. if (!selector) {
  9502. selector = $this.attr('href')
  9503. selector = selector && selector.replace(/.*(?=#[^\s]*$)/, '') //strip for ie7
  9504. }
  9505. if ( $this.parent('li').hasClass('active') ) return
  9506. previous = $ul.find('.active:last a')[0]
  9507. e = $.Event('show', {
  9508. relatedTarget: previous
  9509. })
  9510. $this.trigger(e)
  9511. if (e.isDefaultPrevented()) return
  9512. $target = $(selector)
  9513. this.activate($this.parent('li'), $ul)
  9514. this.activate($target, $target.parent(), function () {
  9515. $this.trigger({
  9516. type: 'shown'
  9517. , relatedTarget: previous
  9518. })
  9519. })
  9520. }
  9521. , activate: function ( element, container, callback) {
  9522. var $active = container.find('> .active')
  9523. , transition = callback
  9524. && $.support.transition
  9525. && $active.hasClass('fade')
  9526. function next() {
  9527. $active
  9528. .removeClass('active')
  9529. .find('> .dropdown-menu > .active')
  9530. .removeClass('active')
  9531. element.addClass('active')
  9532. if (transition) {
  9533. element[0].offsetWidth // reflow for transition
  9534. element.addClass('in')
  9535. } else {
  9536. element.removeClass('fade')
  9537. }
  9538. if ( element.parent('.dropdown-menu') ) {
  9539. element.closest('li.dropdown').addClass('active')
  9540. }
  9541. callback && callback()
  9542. }
  9543. transition ?
  9544. $active.one($.support.transition.end, next) :
  9545. next()
  9546. $active.removeClass('in')
  9547. }
  9548. }
  9549. /* TAB PLUGIN DEFINITION
  9550. * ===================== */
  9551. var old = $.fn.tab
  9552. $.fn.tab = function ( option ) {
  9553. return this.each(function () {
  9554. var $this = $(this)
  9555. , data = $this.data('tab')
  9556. if (!data) $this.data('tab', (data = new Tab(this)))
  9557. if (typeof option == 'string') data[option]()
  9558. })
  9559. }
  9560. $.fn.tab.Constructor = Tab
  9561. /* TAB NO CONFLICT
  9562. * =============== */
  9563. $.fn.tab.noConflict = function () {
  9564. $.fn.tab = old
  9565. return this
  9566. }
  9567. /* TAB DATA-API
  9568. * ============ */
  9569. $(document).on('click.tab.data-api', '[data-toggle="tab"], [data-toggle="pill"]', function (e) {
  9570. e.preventDefault()
  9571. $(this).tab('show')
  9572. })
  9573. }(window.jQuery);
  9574. /* ===========================================================
  9575. * bootstrap-tooltip.js v2.3.2
  9576. * http://twitter.github.com/bootstrap/javascript.html#tooltips
  9577. * Inspired by the original jQuery.tipsy by Jason Frame
  9578. * ===========================================================
  9579. * Copyright 2012 Twitter, Inc.
  9580. *
  9581. * Licensed under the Apache License, Version 2.0 (the "License");
  9582. * you may not use this file except in compliance with the License.
  9583. * You may obtain a copy of the License at
  9584. *
  9585. * http://www.apache.org/licenses/LICENSE-2.0
  9586. *
  9587. * Unless required by applicable law or agreed to in writing, software
  9588. * distributed under the License is distributed on an "AS IS" BASIS,
  9589. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  9590. * See the License for the specific language governing permissions and
  9591. * limitations under the License.
  9592. * ========================================================== */
  9593. !function ($) {
  9594. "use strict"; // jshint ;_;
  9595. /* TOOLTIP PUBLIC CLASS DEFINITION
  9596. * =============================== */
  9597. var Tooltip = function (element, options) {
  9598. this.init('tooltip', element, options)
  9599. }
  9600. Tooltip.prototype = {
  9601. constructor: Tooltip
  9602. , init: function (type, element, options) {
  9603. var eventIn
  9604. , eventOut
  9605. , triggers
  9606. , trigger
  9607. , i
  9608. this.type = type
  9609. this.$element = $(element)
  9610. this.options = this.getOptions(options)
  9611. this.enabled = true
  9612. triggers = this.options.trigger.split(' ')
  9613. for (i = triggers.length; i--;) {
  9614. trigger = triggers[i]
  9615. if (trigger == 'click') {
  9616. this.$element.on('click.' + this.type, this.options.selector, $.proxy(this.toggle, this))
  9617. } else if (trigger != 'manual') {
  9618. eventIn = trigger == 'hover' ? 'mouseenter' : 'focus'
  9619. eventOut = trigger == 'hover' ? 'mouseleave' : 'blur'
  9620. this.$element.on(eventIn + '.' + this.type, this.options.selector, $.proxy(this.enter, this))
  9621. this.$element.on(eventOut + '.' + this.type, this.options.selector, $.proxy(this.leave, this))
  9622. }
  9623. }
  9624. this.options.selector ?
  9625. (this._options = $.extend({}, this.options, { trigger: 'manual', selector: '' })) :
  9626. this.fixTitle()
  9627. }
  9628. , getOptions: function (options) {
  9629. options = $.extend({}, $.fn[this.type].defaults, this.$element.data(), options)
  9630. if (options.delay && typeof options.delay == 'number') {
  9631. options.delay = {
  9632. show: options.delay
  9633. , hide: options.delay
  9634. }
  9635. }
  9636. return options
  9637. }
  9638. , enter: function (e) {
  9639. var defaults = $.fn[this.type].defaults
  9640. , options = {}
  9641. , self
  9642. this._options && $.each(this._options, function (key, value) {
  9643. if (defaults[key] != value) options[key] = value
  9644. }, this)
  9645. self = $(e.currentTarget)[this.type](options).data(this.type)
  9646. if (!self.options.delay || !self.options.delay.show) return self.show()
  9647. clearTimeout(this.timeout)
  9648. self.hoverState = 'in'
  9649. this.timeout = setTimeout(function() {
  9650. if (self.hoverState == 'in') self.show()
  9651. }, self.options.delay.show)
  9652. }
  9653. , leave: function (e) {
  9654. var self = $(e.currentTarget)[this.type](this._options).data(this.type)
  9655. if (this.timeout) clearTimeout(this.timeout)
  9656. if (!self.options.delay || !self.options.delay.hide) return self.hide()
  9657. self.hoverState = 'out'
  9658. this.timeout = setTimeout(function() {
  9659. if (self.hoverState == 'out') self.hide()
  9660. }, self.options.delay.hide)
  9661. }
  9662. , show: function () {
  9663. var $tip
  9664. , pos
  9665. , actualWidth
  9666. , actualHeight
  9667. , placement
  9668. , tp
  9669. , e = $.Event('show')
  9670. if (this.hasContent() && this.enabled) {
  9671. this.$element.trigger(e)
  9672. if (e.isDefaultPrevented()) return
  9673. $tip = this.tip()
  9674. this.setContent()
  9675. if (this.options.animation) {
  9676. $tip.addClass('fade')
  9677. }
  9678. placement = typeof this.options.placement == 'function' ?
  9679. this.options.placement.call(this, $tip[0], this.$element[0]) :
  9680. this.options.placement
  9681. $tip
  9682. .detach()
  9683. .css({ top: 0, left: 0, display: 'block' })
  9684. this.options.container ? $tip.appendTo(this.options.container) : $tip.insertAfter(this.$element)
  9685. pos = this.getPosition()
  9686. actualWidth = $tip[0].offsetWidth
  9687. actualHeight = $tip[0].offsetHeight
  9688. switch (placement) {
  9689. case 'bottom':
  9690. tp = {top: pos.top + pos.height, left: pos.left + pos.width / 2 - actualWidth / 2}
  9691. break
  9692. case 'top':
  9693. tp = {top: pos.top - actualHeight, left: pos.left + pos.width / 2 - actualWidth / 2}
  9694. break
  9695. case 'left':
  9696. tp = {top: pos.top + pos.height / 2 - actualHeight / 2, left: pos.left - actualWidth}
  9697. break
  9698. case 'right':
  9699. tp = {top: pos.top + pos.height / 2 - actualHeight / 2, left: pos.left + pos.width}
  9700. break
  9701. }
  9702. this.applyPlacement(tp, placement)
  9703. this.$element.trigger('shown')
  9704. }
  9705. }
  9706. , applyPlacement: function(offset, placement){
  9707. var $tip = this.tip()
  9708. , width = $tip[0].offsetWidth
  9709. , height = $tip[0].offsetHeight
  9710. , actualWidth
  9711. , actualHeight
  9712. , delta
  9713. , replace
  9714. $tip
  9715. .offset(offset)
  9716. .addClass(placement)
  9717. .addClass('in')
  9718. actualWidth = $tip[0].offsetWidth
  9719. actualHeight = $tip[0].offsetHeight
  9720. if (placement == 'top' && actualHeight != height) {
  9721. offset.top = offset.top + height - actualHeight
  9722. replace = true
  9723. }
  9724. if (placement == 'bottom' || placement == 'top') {
  9725. delta = 0
  9726. if (offset.left < 0){
  9727. delta = offset.left * -2
  9728. offset.left = 0
  9729. $tip.offset(offset)
  9730. actualWidth = $tip[0].offsetWidth
  9731. actualHeight = $tip[0].offsetHeight
  9732. }
  9733. this.replaceArrow(delta - width + actualWidth, actualWidth, 'left')
  9734. } else {
  9735. this.replaceArrow(actualHeight - height, actualHeight, 'top')
  9736. }
  9737. if (replace) $tip.offset(offset)
  9738. }
  9739. , replaceArrow: function(delta, dimension, position){
  9740. this
  9741. .arrow()
  9742. .css(position, delta ? (50 * (1 - delta / dimension) + "%") : '')
  9743. }
  9744. , setContent: function () {
  9745. var $tip = this.tip()
  9746. , title = this.getTitle()
  9747. $tip.find('.tooltip-inner')[this.options.html ? 'html' : 'text'](title)
  9748. $tip.removeClass('fade in top bottom left right')
  9749. }
  9750. , hide: function () {
  9751. var that = this
  9752. , $tip = this.tip()
  9753. , e = $.Event('hide')
  9754. this.$element.trigger(e)
  9755. if (e.isDefaultPrevented()) return
  9756. $tip.removeClass('in')
  9757. function removeWithAnimation() {
  9758. var timeout = setTimeout(function () {
  9759. $tip.off($.support.transition.end).detach()
  9760. }, 500)
  9761. $tip.one($.support.transition.end, function () {
  9762. clearTimeout(timeout)
  9763. $tip.detach()
  9764. })
  9765. }
  9766. $.support.transition && this.$tip.hasClass('fade') ?
  9767. removeWithAnimation() :
  9768. $tip.detach()
  9769. this.$element.trigger('hidden')
  9770. return this
  9771. }
  9772. , fixTitle: function () {
  9773. var $e = this.$element
  9774. if ($e.attr('title') || typeof($e.attr('data-original-title')) != 'string') {
  9775. $e.attr('data-original-title', $e.attr('title') || '').attr('title', '')
  9776. }
  9777. }
  9778. , hasContent: function () {
  9779. return this.getTitle()
  9780. }
  9781. , getPosition: function () {
  9782. var el = this.$element[0]
  9783. return $.extend({}, (typeof el.getBoundingClientRect == 'function') ? el.getBoundingClientRect() : {
  9784. width: el.offsetWidth
  9785. , height: el.offsetHeight
  9786. }, this.$element.offset())
  9787. }
  9788. , getTitle: function () {
  9789. var title
  9790. , $e = this.$element
  9791. , o = this.options
  9792. title = $e.attr('data-original-title')
  9793. || (typeof o.title == 'function' ? o.title.call($e[0]) : o.title)
  9794. return title
  9795. }
  9796. , tip: function () {
  9797. return this.$tip = this.$tip || $(this.options.template)
  9798. }
  9799. , arrow: function(){
  9800. return this.$arrow = this.$arrow || this.tip().find(".tooltip-arrow")
  9801. }
  9802. , validate: function () {
  9803. if (!this.$element[0].parentNode) {
  9804. this.hide()
  9805. this.$element = null
  9806. this.options = null
  9807. }
  9808. }
  9809. , enable: function () {
  9810. this.enabled = true
  9811. }
  9812. , disable: function () {
  9813. this.enabled = false
  9814. }
  9815. , toggleEnabled: function () {
  9816. this.enabled = !this.enabled
  9817. }
  9818. , toggle: function (e) {
  9819. var self = e ? $(e.currentTarget)[this.type](this._options).data(this.type) : this
  9820. self.tip().hasClass('in') ? self.hide() : self.show()
  9821. }
  9822. , destroy: function () {
  9823. this.hide().$element.off('.' + this.type).removeData(this.type)
  9824. }
  9825. }
  9826. /* TOOLTIP PLUGIN DEFINITION
  9827. * ========================= */
  9828. var old = $.fn.tooltip
  9829. $.fn.tooltip = function ( option ) {
  9830. return this.each(function () {
  9831. var $this = $(this)
  9832. , data = $this.data('tooltip')
  9833. , options = typeof option == 'object' && option
  9834. if (!data) $this.data('tooltip', (data = new Tooltip(this, options)))
  9835. if (typeof option == 'string') data[option]()
  9836. })
  9837. }
  9838. $.fn.tooltip.Constructor = Tooltip
  9839. $.fn.tooltip.defaults = {
  9840. animation: true
  9841. , placement: 'top'
  9842. , selector: false
  9843. , template: '<div class="tooltip"><div class="tooltip-arrow"></div><div class="tooltip-inner"></div></div>'
  9844. , trigger: 'hover focus'
  9845. , title: ''
  9846. , delay: 0
  9847. , html: false
  9848. , container: false
  9849. }
  9850. /* TOOLTIP NO CONFLICT
  9851. * =================== */
  9852. $.fn.tooltip.noConflict = function () {
  9853. $.fn.tooltip = old
  9854. return this
  9855. }
  9856. }(window.jQuery);
  9857. /* ===========================================================
  9858. * bootstrap-popover.js v2.3.2
  9859. * http://twitter.github.com/bootstrap/javascript.html#popovers
  9860. * ===========================================================
  9861. * Copyright 2012 Twitter, Inc.
  9862. *
  9863. * Licensed under the Apache License, Version 2.0 (the "License");
  9864. * you may not use this file except in compliance with the License.
  9865. * You may obtain a copy of the License at
  9866. *
  9867. * http://www.apache.org/licenses/LICENSE-2.0
  9868. *
  9869. * Unless required by applicable law or agreed to in writing, software
  9870. * distributed under the License is distributed on an "AS IS" BASIS,
  9871. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  9872. * See the License for the specific language governing permissions and
  9873. * limitations under the License.
  9874. * =========================================================== */
  9875. !function ($) {
  9876. "use strict"; // jshint ;_;
  9877. /* POPOVER PUBLIC CLASS DEFINITION
  9878. * =============================== */
  9879. var Popover = function (element, options) {
  9880. this.init('popover', element, options)
  9881. }
  9882. /* NOTE: POPOVER EXTENDS BOOTSTRAP-TOOLTIP.js
  9883. ========================================== */
  9884. Popover.prototype = $.extend({}, $.fn.tooltip.Constructor.prototype, {
  9885. constructor: Popover
  9886. , setContent: function () {
  9887. var $tip = this.tip()
  9888. , title = this.getTitle()
  9889. , content = this.getContent()
  9890. $tip.find('.popover-title')[this.options.html ? 'html' : 'text'](title)
  9891. $tip.find('.popover-content')[this.options.html ? 'html' : 'text'](content)
  9892. $tip.removeClass('fade top bottom left right in')
  9893. }
  9894. , hasContent: function () {
  9895. return this.getTitle() || this.getContent()
  9896. }
  9897. , getContent: function () {
  9898. var content
  9899. , $e = this.$element
  9900. , o = this.options
  9901. content = (typeof o.content == 'function' ? o.content.call($e[0]) : o.content)
  9902. || $e.attr('data-content')
  9903. return content
  9904. }
  9905. , tip: function () {
  9906. if (!this.$tip) {
  9907. this.$tip = $(this.options.template)
  9908. }
  9909. return this.$tip
  9910. }
  9911. , destroy: function () {
  9912. this.hide().$element.off('.' + this.type).removeData(this.type)
  9913. }
  9914. })
  9915. /* POPOVER PLUGIN DEFINITION
  9916. * ======================= */
  9917. var old = $.fn.popover
  9918. $.fn.popover = function (option) {
  9919. return this.each(function () {
  9920. var $this = $(this)
  9921. , data = $this.data('popover')
  9922. , options = typeof option == 'object' && option
  9923. if (!data) $this.data('popover', (data = new Popover(this, options)))
  9924. if (typeof option == 'string') data[option]()
  9925. })
  9926. }
  9927. $.fn.popover.Constructor = Popover
  9928. $.fn.popover.defaults = $.extend({} , $.fn.tooltip.defaults, {
  9929. placement: 'right'
  9930. , trigger: 'click'
  9931. , content: ''
  9932. , template: '<div class="popover"><div class="arrow"></div><h3 class="popover-title"></h3><div class="popover-content"></div></div>'
  9933. })
  9934. /* POPOVER NO CONFLICT
  9935. * =================== */
  9936. $.fn.popover.noConflict = function () {
  9937. $.fn.popover = old
  9938. return this
  9939. }
  9940. }(window.jQuery);
  9941. /* ============================================================
  9942. * bootstrap-button.js v2.3.2
  9943. * http://twitter.github.com/bootstrap/javascript.html#buttons
  9944. * ============================================================
  9945. * Copyright 2012 Twitter, Inc.
  9946. *
  9947. * Licensed under the Apache License, Version 2.0 (the "License");
  9948. * you may not use this file except in compliance with the License.
  9949. * You may obtain a copy of the License at
  9950. *
  9951. * http://www.apache.org/licenses/LICENSE-2.0
  9952. *
  9953. * Unless required by applicable law or agreed to in writing, software
  9954. * distributed under the License is distributed on an "AS IS" BASIS,
  9955. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  9956. * See the License for the specific language governing permissions and
  9957. * limitations under the License.
  9958. * ============================================================ */
  9959. !function ($) {
  9960. "use strict"; // jshint ;_;
  9961. /* BUTTON PUBLIC CLASS DEFINITION
  9962. * ============================== */
  9963. var Button = function (element, options) {
  9964. this.$element = $(element)
  9965. this.options = $.extend({}, $.fn.button.defaults, options)
  9966. }
  9967. Button.prototype.setState = function (state) {
  9968. var d = 'disabled'
  9969. , $el = this.$element
  9970. , data = $el.data()
  9971. , val = $el.is('input') ? 'val' : 'html'
  9972. state = state + 'Text'
  9973. data.resetText || $el.data('resetText', $el[val]())
  9974. $el[val](data[state] || this.options[state])
  9975. // push to event loop to allow forms to submit
  9976. setTimeout(function () {
  9977. state == 'loadingText' ?
  9978. $el.addClass(d).attr(d, d) :
  9979. $el.removeClass(d).removeAttr(d)
  9980. }, 0)
  9981. }
  9982. Button.prototype.toggle = function () {
  9983. var $parent = this.$element.closest('[data-toggle="buttons-radio"]')
  9984. $parent && $parent
  9985. .find('.active')
  9986. .removeClass('active')
  9987. this.$element.toggleClass('active')
  9988. }
  9989. /* BUTTON PLUGIN DEFINITION
  9990. * ======================== */
  9991. var old = $.fn.button
  9992. $.fn.button = function (option) {
  9993. return this.each(function () {
  9994. var $this = $(this)
  9995. , data = $this.data('button')
  9996. , options = typeof option == 'object' && option
  9997. if (!data) $this.data('button', (data = new Button(this, options)))
  9998. if (option == 'toggle') data.toggle()
  9999. else if (option) data.setState(option)
  10000. })
  10001. }
  10002. $.fn.button.defaults = {
  10003. loadingText: 'loading...'
  10004. }
  10005. $.fn.button.Constructor = Button
  10006. /* BUTTON NO CONFLICT
  10007. * ================== */
  10008. $.fn.button.noConflict = function () {
  10009. $.fn.button = old
  10010. return this
  10011. }
  10012. /* BUTTON DATA-API
  10013. * =============== */
  10014. $(document).on('click.button.data-api', '[data-toggle^=button]', function (e) {
  10015. var $btn = $(e.target)
  10016. if (!$btn.hasClass('btn')) $btn = $btn.closest('.btn')
  10017. $btn.button('toggle')
  10018. })
  10019. }(window.jQuery);
  10020. /* =============================================================
  10021. * bootstrap-collapse.js v2.3.2
  10022. * http://twitter.github.com/bootstrap/javascript.html#collapse
  10023. * =============================================================
  10024. * Copyright 2012 Twitter, Inc.
  10025. *
  10026. * Licensed under the Apache License, Version 2.0 (the "License");
  10027. * you may not use this file except in compliance with the License.
  10028. * You may obtain a copy of the License at
  10029. *
  10030. * http://www.apache.org/licenses/LICENSE-2.0
  10031. *
  10032. * Unless required by applicable law or agreed to in writing, software
  10033. * distributed under the License is distributed on an "AS IS" BASIS,
  10034. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  10035. * See the License for the specific language governing permissions and
  10036. * limitations under the License.
  10037. * ============================================================ */
  10038. !function ($) {
  10039. "use strict"; // jshint ;_;
  10040. /* COLLAPSE PUBLIC CLASS DEFINITION
  10041. * ================================ */
  10042. var Collapse = function (element, options) {
  10043. this.$element = $(element)
  10044. this.options = $.extend({}, $.fn.collapse.defaults, options)
  10045. if (this.options.parent) {
  10046. this.$parent = $(this.options.parent)
  10047. }
  10048. this.options.toggle && this.toggle()
  10049. }
  10050. Collapse.prototype = {
  10051. constructor: Collapse
  10052. , dimension: function () {
  10053. var hasWidth = this.$element.hasClass('width')
  10054. return hasWidth ? 'width' : 'height'
  10055. }
  10056. , show: function () {
  10057. var dimension
  10058. , scroll
  10059. , actives
  10060. , hasData
  10061. if (this.transitioning || this.$element.hasClass('in')) return
  10062. dimension = this.dimension()
  10063. scroll = $.camelCase(['scroll', dimension].join('-'))
  10064. actives = this.$parent && this.$parent.find('> .accordion-group > .in')
  10065. if (actives && actives.length) {
  10066. hasData = actives.data('collapse')
  10067. if (hasData && hasData.transitioning) return
  10068. actives.collapse('hide')
  10069. hasData || actives.data('collapse', null)
  10070. }
  10071. this.$element[dimension](0)
  10072. this.transition('addClass', $.Event('show'), 'shown')
  10073. $.support.transition && this.$element[dimension](this.$element[0][scroll])
  10074. }
  10075. , hide: function () {
  10076. var dimension
  10077. if (this.transitioning || !this.$element.hasClass('in')) return
  10078. dimension = this.dimension()
  10079. this.reset(this.$element[dimension]())
  10080. this.transition('removeClass', $.Event('hide'), 'hidden')
  10081. this.$element[dimension](0)
  10082. }
  10083. , reset: function (size) {
  10084. var dimension = this.dimension()
  10085. this.$element
  10086. .removeClass('collapse')
  10087. [dimension](size || 'auto')
  10088. [0].offsetWidth
  10089. this.$element[size !== null ? 'addClass' : 'removeClass']('collapse')
  10090. return this
  10091. }
  10092. , transition: function (method, startEvent, completeEvent) {
  10093. var that = this
  10094. , complete = function () {
  10095. if (startEvent.type == 'show') that.reset()
  10096. that.transitioning = 0
  10097. that.$element.trigger(completeEvent)
  10098. }
  10099. this.$element.trigger(startEvent)
  10100. if (startEvent.isDefaultPrevented()) return
  10101. this.transitioning = 1
  10102. this.$element[method]('in')
  10103. $.support.transition && this.$element.hasClass('collapse') ?
  10104. this.$element.one($.support.transition.end, complete) :
  10105. complete()
  10106. }
  10107. , toggle: function () {
  10108. this[this.$element.hasClass('in') ? 'hide' : 'show']()
  10109. }
  10110. }
  10111. /* COLLAPSE PLUGIN DEFINITION
  10112. * ========================== */
  10113. var old = $.fn.collapse
  10114. $.fn.collapse = function (option) {
  10115. return this.each(function () {
  10116. var $this = $(this)
  10117. , data = $this.data('collapse')
  10118. , options = $.extend({}, $.fn.collapse.defaults, $this.data(), typeof option == 'object' && option)
  10119. if (!data) $this.data('collapse', (data = new Collapse(this, options)))
  10120. if (typeof option == 'string') data[option]()
  10121. })
  10122. }
  10123. $.fn.collapse.defaults = {
  10124. toggle: true
  10125. }
  10126. $.fn.collapse.Constructor = Collapse
  10127. /* COLLAPSE NO CONFLICT
  10128. * ==================== */
  10129. $.fn.collapse.noConflict = function () {
  10130. $.fn.collapse = old
  10131. return this
  10132. }
  10133. /* COLLAPSE DATA-API
  10134. * ================= */
  10135. $(document).on('click.collapse.data-api', '[data-toggle=collapse]', function (e) {
  10136. var $this = $(this), href
  10137. , target = $this.attr('data-target')
  10138. || e.preventDefault()
  10139. || (href = $this.attr('href')) && href.replace(/.*(?=#[^\s]+$)/, '') //strip for ie7
  10140. , option = $(target).data('collapse') ? 'toggle' : $this.data()
  10141. $this[$(target).hasClass('in') ? 'addClass' : 'removeClass']('collapsed')
  10142. $(target).collapse(option)
  10143. })
  10144. }(window.jQuery);
  10145. /* ==========================================================
  10146. * bootstrap-carousel.js v2.3.2
  10147. * http://twitter.github.com/bootstrap/javascript.html#carousel
  10148. * ==========================================================
  10149. * Copyright 2012 Twitter, Inc.
  10150. *
  10151. * Licensed under the Apache License, Version 2.0 (the "License");
  10152. * you may not use this file except in compliance with the License.
  10153. * You may obtain a copy of the License at
  10154. *
  10155. * http://www.apache.org/licenses/LICENSE-2.0
  10156. *
  10157. * Unless required by applicable law or agreed to in writing, software
  10158. * distributed under the License is distributed on an "AS IS" BASIS,
  10159. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  10160. * See the License for the specific language governing permissions and
  10161. * limitations under the License.
  10162. * ========================================================== */
  10163. !function ($) {
  10164. "use strict"; // jshint ;_;
  10165. /* CAROUSEL CLASS DEFINITION
  10166. * ========================= */
  10167. var Carousel = function (element, options) {
  10168. this.$element = $(element)
  10169. this.$indicators = this.$element.find('.carousel-indicators')
  10170. this.options = options
  10171. this.options.pause == 'hover' && this.$element
  10172. .on('mouseenter', $.proxy(this.pause, this))
  10173. .on('mouseleave', $.proxy(this.cycle, this))
  10174. }
  10175. Carousel.prototype = {
  10176. cycle: function (e) {
  10177. if (!e) this.paused = false
  10178. if (this.interval) clearInterval(this.interval);
  10179. this.options.interval
  10180. && !this.paused
  10181. && (this.interval = setInterval($.proxy(this.next, this), this.options.interval))
  10182. return this
  10183. }
  10184. , getActiveIndex: function () {
  10185. this.$active = this.$element.find('.item.active')
  10186. this.$items = this.$active.parent().children()
  10187. return this.$items.index(this.$active)
  10188. }
  10189. , to: function (pos) {
  10190. var activeIndex = this.getActiveIndex()
  10191. , that = this
  10192. if (pos > (this.$items.length - 1) || pos < 0) return
  10193. if (this.sliding) {
  10194. return this.$element.one('slid', function () {
  10195. that.to(pos)
  10196. })
  10197. }
  10198. if (activeIndex == pos) {
  10199. return this.pause().cycle()
  10200. }
  10201. return this.slide(pos > activeIndex ? 'next' : 'prev', $(this.$items[pos]))
  10202. }
  10203. , pause: function (e) {
  10204. if (!e) this.paused = true
  10205. if (this.$element.find('.next, .prev').length && $.support.transition.end) {
  10206. this.$element.trigger($.support.transition.end)
  10207. this.cycle(true)
  10208. }
  10209. clearInterval(this.interval)
  10210. this.interval = null
  10211. return this
  10212. }
  10213. , next: function () {
  10214. if (this.sliding) return
  10215. return this.slide('next')
  10216. }
  10217. , prev: function () {
  10218. if (this.sliding) return
  10219. return this.slide('prev')
  10220. }
  10221. , slide: function (type, next) {
  10222. var $active = this.$element.find('.item.active')
  10223. , $next = next || $active[type]()
  10224. , isCycling = this.interval
  10225. , direction = type == 'next' ? 'left' : 'right'
  10226. , fallback = type == 'next' ? 'first' : 'last'
  10227. , that = this
  10228. , e
  10229. this.sliding = true
  10230. isCycling && this.pause()
  10231. $next = $next.length ? $next : this.$element.find('.item')[fallback]()
  10232. e = $.Event('slide', {
  10233. relatedTarget: $next[0]
  10234. , direction: direction
  10235. })
  10236. if ($next.hasClass('active')) return
  10237. if (this.$indicators.length) {
  10238. this.$indicators.find('.active').removeClass('active')
  10239. this.$element.one('slid', function () {
  10240. var $nextIndicator = $(that.$indicators.children()[that.getActiveIndex()])
  10241. $nextIndicator && $nextIndicator.addClass('active')
  10242. })
  10243. }
  10244. if ($.support.transition && this.$element.hasClass('slide')) {
  10245. this.$element.trigger(e)
  10246. if (e.isDefaultPrevented()) return
  10247. $next.addClass(type)
  10248. $next[0].offsetWidth // force reflow
  10249. $active.addClass(direction)
  10250. $next.addClass(direction)
  10251. this.$element.one($.support.transition.end, function () {
  10252. $next.removeClass([type, direction].join(' ')).addClass('active')
  10253. $active.removeClass(['active', direction].join(' '))
  10254. that.sliding = false
  10255. setTimeout(function () { that.$element.trigger('slid') }, 0)
  10256. })
  10257. } else {
  10258. this.$element.trigger(e)
  10259. if (e.isDefaultPrevented()) return
  10260. $active.removeClass('active')
  10261. $next.addClass('active')
  10262. this.sliding = false
  10263. this.$element.trigger('slid')
  10264. }
  10265. isCycling && this.cycle()
  10266. return this
  10267. }
  10268. }
  10269. /* CAROUSEL PLUGIN DEFINITION
  10270. * ========================== */
  10271. var old = $.fn.carousel
  10272. $.fn.carousel = function (option) {
  10273. return this.each(function () {
  10274. var $this = $(this)
  10275. , data = $this.data('carousel')
  10276. , options = $.extend({}, $.fn.carousel.defaults, typeof option == 'object' && option)
  10277. , action = typeof option == 'string' ? option : options.slide
  10278. if (!data) $this.data('carousel', (data = new Carousel(this, options)))
  10279. if (typeof option == 'number') data.to(option)
  10280. else if (action) data[action]()
  10281. else if (options.interval) data.pause().cycle()
  10282. })
  10283. }
  10284. $.fn.carousel.defaults = {
  10285. interval: 5000
  10286. , pause: 'hover'
  10287. }
  10288. $.fn.carousel.Constructor = Carousel
  10289. /* CAROUSEL NO CONFLICT
  10290. * ==================== */
  10291. $.fn.carousel.noConflict = function () {
  10292. $.fn.carousel = old
  10293. return this
  10294. }
  10295. /* CAROUSEL DATA-API
  10296. * ================= */
  10297. $(document).on('click.carousel.data-api', '[data-slide], [data-slide-to]', function (e) {
  10298. var $this = $(this), href
  10299. , $target = $($this.attr('data-target') || (href = $this.attr('href')) && href.replace(/.*(?=#[^\s]+$)/, '')) //strip for ie7
  10300. , options = $.extend({}, $target.data(), $this.data())
  10301. , slideIndex
  10302. $target.carousel(options)
  10303. if (slideIndex = $this.attr('data-slide-to')) {
  10304. $target.data('carousel').pause().to(slideIndex).cycle()
  10305. }
  10306. e.preventDefault()
  10307. })
  10308. }(window.jQuery);
  10309. /* =============================================================
  10310. * bootstrap-typeahead.js v2.3.2
  10311. * http://twitter.github.com/bootstrap/javascript.html#typeahead
  10312. * =============================================================
  10313. * Copyright 2012 Twitter, Inc.
  10314. *
  10315. * Licensed under the Apache License, Version 2.0 (the "License");
  10316. * you may not use this file except in compliance with the License.
  10317. * You may obtain a copy of the License at
  10318. *
  10319. * http://www.apache.org/licenses/LICENSE-2.0
  10320. *
  10321. * Unless required by applicable law or agreed to in writing, software
  10322. * distributed under the License is distributed on an "AS IS" BASIS,
  10323. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  10324. * See the License for the specific language governing permissions and
  10325. * limitations under the License.
  10326. * ============================================================ */
  10327. !function($){
  10328. "use strict"; // jshint ;_;
  10329. /* TYPEAHEAD PUBLIC CLASS DEFINITION
  10330. * ================================= */
  10331. var Typeahead = function (element, options) {
  10332. this.$element = $(element)
  10333. this.options = $.extend({}, $.fn.typeahead.defaults, options)
  10334. this.matcher = this.options.matcher || this.matcher
  10335. this.sorter = this.options.sorter || this.sorter
  10336. this.highlighter = this.options.highlighter || this.highlighter
  10337. this.updater = this.options.updater || this.updater
  10338. this.source = this.options.source
  10339. this.$menu = $(this.options.menu)
  10340. this.shown = false
  10341. this.listen()
  10342. }
  10343. Typeahead.prototype = {
  10344. constructor: Typeahead
  10345. , select: function () {
  10346. var val = this.$menu.find('.active').attr('data-value')
  10347. this.$element
  10348. .val(this.updater(val))
  10349. .change()
  10350. return this.hide()
  10351. }
  10352. , updater: function (item) {
  10353. return item
  10354. }
  10355. , show: function () {
  10356. var pos = $.extend({}, this.$element.position(), {
  10357. height: this.$element[0].offsetHeight
  10358. })
  10359. this.$menu
  10360. .insertAfter(this.$element)
  10361. .css({
  10362. top: pos.top + pos.height
  10363. , left: pos.left
  10364. })
  10365. .show()
  10366. this.shown = true
  10367. return this
  10368. }
  10369. , hide: function () {
  10370. this.$menu.hide()
  10371. this.shown = false
  10372. return this
  10373. }
  10374. , lookup: function (event) {
  10375. var items
  10376. this.query = this.$element.val()
  10377. if (!this.query || this.query.length < this.options.minLength) {
  10378. return this.shown ? this.hide() : this
  10379. }
  10380. items = $.isFunction(this.source) ? this.source(this.query, $.proxy(this.process, this)) : this.source
  10381. return items ? this.process(items) : this
  10382. }
  10383. , process: function (items) {
  10384. var that = this
  10385. items = $.grep(items, function (item) {
  10386. return that.matcher(item)
  10387. })
  10388. items = this.sorter(items)
  10389. if (!items.length) {
  10390. return this.shown ? this.hide() : this
  10391. }
  10392. return this.render(items.slice(0, this.options.items)).show()
  10393. }
  10394. , matcher: function (item) {
  10395. return ~item.toLowerCase().indexOf(this.query.toLowerCase())
  10396. }
  10397. , sorter: function (items) {
  10398. var beginswith = []
  10399. , caseSensitive = []
  10400. , caseInsensitive = []
  10401. , item
  10402. while (item = items.shift()) {
  10403. if (!item.toLowerCase().indexOf(this.query.toLowerCase())) beginswith.push(item)
  10404. else if (~item.indexOf(this.query)) caseSensitive.push(item)
  10405. else caseInsensitive.push(item)
  10406. }
  10407. return beginswith.concat(caseSensitive, caseInsensitive)
  10408. }
  10409. , highlighter: function (item) {
  10410. var query = this.query.replace(/[\-\[\]{}()*+?.,\\\^$|#\s]/g, '\\$&')
  10411. return item.replace(new RegExp('(' + query + ')', 'ig'), function ($1, match) {
  10412. return '<strong>' + match + '</strong>'
  10413. })
  10414. }
  10415. , render: function (items) {
  10416. var that = this
  10417. items = $(items).map(function (i, item) {
  10418. i = $(that.options.item).attr('data-value', item)
  10419. i.find('a').html(that.highlighter(item))
  10420. return i[0]
  10421. })
  10422. items.first().addClass('active')
  10423. this.$menu.html(items)
  10424. return this
  10425. }
  10426. , next: function (event) {
  10427. var active = this.$menu.find('.active').removeClass('active')
  10428. , next = active.next()
  10429. if (!next.length) {
  10430. next = $(this.$menu.find('li')[0])
  10431. }
  10432. next.addClass('active')
  10433. }
  10434. , prev: function (event) {
  10435. var active = this.$menu.find('.active').removeClass('active')
  10436. , prev = active.prev()
  10437. if (!prev.length) {
  10438. prev = this.$menu.find('li').last()
  10439. }
  10440. prev.addClass('active')
  10441. }
  10442. , listen: function () {
  10443. this.$element
  10444. .on('focus', $.proxy(this.focus, this))
  10445. .on('blur', $.proxy(this.blur, this))
  10446. .on('keypress', $.proxy(this.keypress, this))
  10447. .on('keyup', $.proxy(this.keyup, this))
  10448. if (this.eventSupported('keydown')) {
  10449. this.$element.on('keydown', $.proxy(this.keydown, this))
  10450. }
  10451. this.$menu
  10452. .on('click', $.proxy(this.click, this))
  10453. .on('mouseenter', 'li', $.proxy(this.mouseenter, this))
  10454. .on('mouseleave', 'li', $.proxy(this.mouseleave, this))
  10455. }
  10456. , eventSupported: function(eventName) {
  10457. var isSupported = eventName in this.$element
  10458. if (!isSupported) {
  10459. this.$element.setAttribute(eventName, 'return;')
  10460. isSupported = typeof this.$element[eventName] === 'function'
  10461. }
  10462. return isSupported
  10463. }
  10464. , move: function (e) {
  10465. if (!this.shown) return
  10466. switch(e.keyCode) {
  10467. case 9: // tab
  10468. case 13: // enter
  10469. case 27: // escape
  10470. e.preventDefault()
  10471. break
  10472. case 38: // up arrow
  10473. e.preventDefault()
  10474. this.prev()
  10475. break
  10476. case 40: // down arrow
  10477. e.preventDefault()
  10478. this.next()
  10479. break
  10480. }
  10481. e.stopPropagation()
  10482. }
  10483. , keydown: function (e) {
  10484. this.suppressKeyPressRepeat = ~$.inArray(e.keyCode, [40,38,9,13,27])
  10485. this.move(e)
  10486. }
  10487. , keypress: function (e) {
  10488. if (this.suppressKeyPressRepeat) return
  10489. this.move(e)
  10490. }
  10491. , keyup: function (e) {
  10492. switch(e.keyCode) {
  10493. case 40: // down arrow
  10494. case 38: // up arrow
  10495. case 16: // shift
  10496. case 17: // ctrl
  10497. case 18: // alt
  10498. break
  10499. case 9: // tab
  10500. case 13: // enter
  10501. if (!this.shown) return
  10502. this.select()
  10503. break
  10504. case 27: // escape
  10505. if (!this.shown) return
  10506. this.hide()
  10507. break
  10508. default:
  10509. this.lookup()
  10510. }
  10511. e.stopPropagation()
  10512. e.preventDefault()
  10513. }
  10514. , focus: function (e) {
  10515. this.focused = true
  10516. }
  10517. , blur: function (e) {
  10518. this.focused = false
  10519. if (!this.mousedover && this.shown) this.hide()
  10520. }
  10521. , click: function (e) {
  10522. e.stopPropagation()
  10523. e.preventDefault()
  10524. this.select()
  10525. this.$element.focus()
  10526. }
  10527. , mouseenter: function (e) {
  10528. this.mousedover = true
  10529. this.$menu.find('.active').removeClass('active')
  10530. $(e.currentTarget).addClass('active')
  10531. }
  10532. , mouseleave: function (e) {
  10533. this.mousedover = false
  10534. if (!this.focused && this.shown) this.hide()
  10535. }
  10536. }
  10537. /* TYPEAHEAD PLUGIN DEFINITION
  10538. * =========================== */
  10539. var old = $.fn.typeahead
  10540. $.fn.typeahead = function (option) {
  10541. return this.each(function () {
  10542. var $this = $(this)
  10543. , data = $this.data('typeahead')
  10544. , options = typeof option == 'object' && option
  10545. if (!data) $this.data('typeahead', (data = new Typeahead(this, options)))
  10546. if (typeof option == 'string') data[option]()
  10547. })
  10548. }
  10549. $.fn.typeahead.defaults = {
  10550. source: []
  10551. , items: 8
  10552. , menu: '<ul class="typeahead dropdown-menu"></ul>'
  10553. , item: '<li><a href="#"></a></li>'
  10554. , minLength: 1
  10555. }
  10556. $.fn.typeahead.Constructor = Typeahead
  10557. /* TYPEAHEAD NO CONFLICT
  10558. * =================== */
  10559. $.fn.typeahead.noConflict = function () {
  10560. $.fn.typeahead = old
  10561. return this
  10562. }
  10563. /* TYPEAHEAD DATA-API
  10564. * ================== */
  10565. $(document).on('focus.typeahead.data-api', '[data-provide="typeahead"]', function (e) {
  10566. var $this = $(this)
  10567. if ($this.data('typeahead')) return
  10568. $this.typeahead($this.data())
  10569. })
  10570. }(window.jQuery);
  10571. /* ==========================================================
  10572. * bootstrap-affix.js v2.3.2
  10573. * http://twitter.github.com/bootstrap/javascript.html#affix
  10574. * ==========================================================
  10575. * Copyright 2012 Twitter, Inc.
  10576. *
  10577. * Licensed under the Apache License, Version 2.0 (the "License");
  10578. * you may not use this file except in compliance with the License.
  10579. * You may obtain a copy of the License at
  10580. *
  10581. * http://www.apache.org/licenses/LICENSE-2.0
  10582. *
  10583. * Unless required by applicable law or agreed to in writing, software
  10584. * distributed under the License is distributed on an "AS IS" BASIS,
  10585. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  10586. * See the License for the specific language governing permissions and
  10587. * limitations under the License.
  10588. * ========================================================== */
  10589. !function ($) {
  10590. "use strict"; // jshint ;_;
  10591. /* AFFIX CLASS DEFINITION
  10592. * ====================== */
  10593. var Affix = function (element, options) {
  10594. this.options = $.extend({}, $.fn.affix.defaults, options)
  10595. this.$window = $(window)
  10596. .on('scroll.affix.data-api', $.proxy(this.checkPosition, this))
  10597. .on('click.affix.data-api', $.proxy(function () { setTimeout($.proxy(this.checkPosition, this), 1) }, this))
  10598. this.$element = $(element)
  10599. this.checkPosition()
  10600. }
  10601. Affix.prototype.checkPosition = function () {
  10602. if (!this.$element.is(':visible')) return
  10603. var scrollHeight = $(document).height()
  10604. , scrollTop = this.$window.scrollTop()
  10605. , position = this.$element.offset()
  10606. , offset = this.options.offset
  10607. , offsetBottom = offset.bottom
  10608. , offsetTop = offset.top
  10609. , reset = 'affix affix-top affix-bottom'
  10610. , affix
  10611. if (typeof offset != 'object') offsetBottom = offsetTop = offset
  10612. if (typeof offsetTop == 'function') offsetTop = offset.top()
  10613. if (typeof offsetBottom == 'function') offsetBottom = offset.bottom()
  10614. affix = this.unpin != null && (scrollTop + this.unpin <= position.top) ?
  10615. false : offsetBottom != null && (position.top + this.$element.height() >= scrollHeight - offsetBottom) ?
  10616. 'bottom' : offsetTop != null && scrollTop <= offsetTop ?
  10617. 'top' : false
  10618. if (this.affixed === affix) return
  10619. this.affixed = affix
  10620. this.unpin = affix == 'bottom' ? position.top - scrollTop : null
  10621. this.$element.removeClass(reset).addClass('affix' + (affix ? '-' + affix : ''))
  10622. }
  10623. /* AFFIX PLUGIN DEFINITION
  10624. * ======================= */
  10625. var old = $.fn.affix
  10626. $.fn.affix = function (option) {
  10627. return this.each(function () {
  10628. var $this = $(this)
  10629. , data = $this.data('affix')
  10630. , options = typeof option == 'object' && option
  10631. if (!data) $this.data('affix', (data = new Affix(this, options)))
  10632. if (typeof option == 'string') data[option]()
  10633. })
  10634. }
  10635. $.fn.affix.Constructor = Affix
  10636. $.fn.affix.defaults = {
  10637. offset: 0
  10638. }
  10639. /* AFFIX NO CONFLICT
  10640. * ================= */
  10641. $.fn.affix.noConflict = function () {
  10642. $.fn.affix = old
  10643. return this
  10644. }
  10645. /* AFFIX DATA-API
  10646. * ============== */
  10647. $(window).on('load', function () {
  10648. $('[data-spy="affix"]').each(function () {
  10649. var $spy = $(this)
  10650. , data = $spy.data()
  10651. data.offset = data.offset || {}
  10652. data.offsetBottom && (data.offset.bottom = data.offsetBottom)
  10653. data.offsetTop && (data.offset.top = data.offsetTop)
  10654. $spy.affix(data)
  10655. })
  10656. })
  10657. }(window.jQuery);
  10658. /* ========================================================================
  10659. * bootstrap-switch - v3.1.0
  10660. * http://www.bootstrap-switch.org
  10661. * ========================================================================
  10662. * Copyright 2012-2013 Mattia Larentis
  10663. *
  10664. * ========================================================================
  10665. * Licensed under the Apache License, Version 2.0 (the "License");
  10666. * you may not use this file except in compliance with the License.
  10667. * You may obtain a copy of the License at
  10668. *
  10669. * http://www.apache.org/licenses/LICENSE-2.0
  10670. *
  10671. * Unless required by applicable law or agreed to in writing, software
  10672. * distributed under the License is distributed on an "AS IS" BASIS,
  10673. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  10674. * See the License for the specific language governing permissions and
  10675. * limitations under the License.
  10676. * ========================================================================
  10677. */
  10678. (function() {
  10679. var __slice = [].slice;
  10680. (function($, window) {
  10681. "use strict";
  10682. var BootstrapSwitch;
  10683. BootstrapSwitch = (function() {
  10684. function BootstrapSwitch(element, options) {
  10685. if (options == null) {
  10686. options = {};
  10687. }
  10688. this.$element = $(element);
  10689. this.options = $.extend({}, $.fn.bootstrapSwitch.defaults, {
  10690. state: this.$element.is(":checked"),
  10691. size: this.$element.data("size"),
  10692. animate: this.$element.data("animate"),
  10693. disabled: this.$element.is(":disabled"),
  10694. readonly: this.$element.is("[readonly]"),
  10695. indeterminate: this.$element.data("indeterminate"),
  10696. inverse: this.$element.data("inverse"),
  10697. radioAllOff: this.$element.data("radio-all-off"),
  10698. onColor: this.$element.data("on-color"),
  10699. offColor: this.$element.data("off-color"),
  10700. onText: this.$element.data("on-text"),
  10701. offText: this.$element.data("off-text"),
  10702. labelText: this.$element.data("label-text"),
  10703. baseClass: this.$element.data("base-class"),
  10704. wrapperClass: this.$element.data("wrapper-class")
  10705. }, options);
  10706. this.$wrapper = $("<div>", {
  10707. "class": (function(_this) {
  10708. return function() {
  10709. var classes;
  10710. classes = ["" + _this.options.baseClass].concat(_this._getClasses(_this.options.wrapperClass));
  10711. classes.push(_this.options.state ? "" + _this.options.baseClass + "-on" : "" + _this.options.baseClass + "-off");
  10712. if (_this.options.size != null) {
  10713. classes.push("" + _this.options.baseClass + "-" + _this.options.size);
  10714. }
  10715. if (_this.options.animate) {
  10716. classes.push("" + _this.options.baseClass + "-animate");
  10717. }
  10718. if (_this.options.disabled) {
  10719. classes.push("" + _this.options.baseClass + "-disabled");
  10720. }
  10721. if (_this.options.readonly) {
  10722. classes.push("" + _this.options.baseClass + "-readonly");
  10723. }
  10724. if (_this.options.indeterminate) {
  10725. classes.push("" + _this.options.baseClass + "-indeterminate");
  10726. }
  10727. if (_this.options.inverse) {
  10728. classes.push("" + _this.options.baseClass + "-inverse");
  10729. }
  10730. if (_this.$element.attr("id")) {
  10731. classes.push("" + _this.options.baseClass + "-id-" + (_this.$element.attr("id")));
  10732. }
  10733. return classes.join(" ");
  10734. };
  10735. })(this)()
  10736. });
  10737. this.$container = $("<div>", {
  10738. "class": "" + this.options.baseClass + "-container"
  10739. });
  10740. this.$on = $("<span>", {
  10741. html: this.options.onText,
  10742. "class": "" + this.options.baseClass + "-handle-on " + this.options.baseClass + "-" + this.options.onColor
  10743. });
  10744. this.$off = $("<span>", {
  10745. html: this.options.offText,
  10746. "class": "" + this.options.baseClass + "-handle-off " + this.options.baseClass + "-" + this.options.offColor
  10747. });
  10748. this.$label = $("<label>", {
  10749. html: this.options.labelText,
  10750. "class": "" + this.options.baseClass + "-label"
  10751. });
  10752. if (this.options.indeterminate) {
  10753. this.$element.prop("indeterminate", true);
  10754. }
  10755. this.$element.on("init.bootstrapSwitch", (function(_this) {
  10756. return function() {
  10757. return _this.options.onInit.apply(element, arguments);
  10758. };
  10759. })(this));
  10760. this.$element.on("switchChange.bootstrapSwitch", (function(_this) {
  10761. return function() {
  10762. return _this.options.onSwitchChange.apply(element, arguments);
  10763. };
  10764. })(this));
  10765. this.$container = this.$element.wrap(this.$container).parent();
  10766. this.$wrapper = this.$container.wrap(this.$wrapper).parent();
  10767. this.$element.before(this.options.inverse ? this.$off : this.$on).before(this.$label).before(this.options.inverse ? this.$on : this.$off).trigger("init.bootstrapSwitch");
  10768. this._elementHandlers();
  10769. this._handleHandlers();
  10770. this._labelHandlers();
  10771. this._formHandler();
  10772. }
  10773. BootstrapSwitch.prototype._constructor = BootstrapSwitch;
  10774. BootstrapSwitch.prototype.state = function(value, skip) {
  10775. if (typeof value === "undefined") {
  10776. return this.options.state;
  10777. }
  10778. if (this.options.disabled || this.options.readonly) {
  10779. return this.$element;
  10780. }
  10781. if (this.options.state && !this.options.radioAllOff && this.$element.is(':radio')) {
  10782. return this.$element;
  10783. }
  10784. if (this.options.indeterminate) {
  10785. this.indeterminate(false);
  10786. value = true;
  10787. } else {
  10788. value = !!value;
  10789. }
  10790. this.$element.prop("checked", value).trigger("change.bootstrapSwitch", skip);
  10791. return this.$element;
  10792. };
  10793. BootstrapSwitch.prototype.toggleState = function(skip) {
  10794. if (this.options.disabled || this.options.readonly) {
  10795. return this.$element;
  10796. }
  10797. if (this.options.indeterminate) {
  10798. this.indeterminate(false);
  10799. return this.state(true);
  10800. } else {
  10801. return this.$element.prop("checked", !this.options.state).trigger("change.bootstrapSwitch", skip);
  10802. }
  10803. };
  10804. BootstrapSwitch.prototype.size = function(value) {
  10805. if (typeof value === "undefined") {
  10806. return this.options.size;
  10807. }
  10808. if (this.options.size != null) {
  10809. this.$wrapper.removeClass("" + this.options.baseClass + "-" + this.options.size);
  10810. }
  10811. if (value) {
  10812. this.$wrapper.addClass("" + this.options.baseClass + "-" + value);
  10813. }
  10814. this.options.size = value;
  10815. return this.$element;
  10816. };
  10817. BootstrapSwitch.prototype.animate = function(value) {
  10818. if (typeof value === "undefined") {
  10819. return this.options.animate;
  10820. }
  10821. value = !!value;
  10822. this.$wrapper[value ? "addClass" : "removeClass"]("" + this.options.baseClass + "-animate");
  10823. this.options.animate = value;
  10824. return this.$element;
  10825. };
  10826. BootstrapSwitch.prototype.toggleAnimate = function() {
  10827. this.$wrapper.toggleClass("" + this.options.baseClass + "-animate");
  10828. this.options.animate = !this.options.animate;
  10829. return this.$element;
  10830. };
  10831. BootstrapSwitch.prototype.disabled = function(value) {
  10832. if (typeof value === "undefined") {
  10833. return this.options.disabled;
  10834. }
  10835. value = !!value;
  10836. this.$wrapper[value ? "addClass" : "removeClass"]("" + this.options.baseClass + "-disabled");
  10837. this.$element.prop("disabled", value);
  10838. this.options.disabled = value;
  10839. return this.$element;
  10840. };
  10841. BootstrapSwitch.prototype.toggleDisabled = function() {
  10842. this.$element.prop("disabled", !this.options.disabled);
  10843. this.$wrapper.toggleClass("" + this.options.baseClass + "-disabled");
  10844. this.options.disabled = !this.options.disabled;
  10845. return this.$element;
  10846. };
  10847. BootstrapSwitch.prototype.readonly = function(value) {
  10848. if (typeof value === "undefined") {
  10849. return this.options.readonly;
  10850. }
  10851. value = !!value;
  10852. this.$wrapper[value ? "addClass" : "removeClass"]("" + this.options.baseClass + "-readonly");
  10853. this.$element.prop("readonly", value);
  10854. this.options.readonly = value;
  10855. return this.$element;
  10856. };
  10857. BootstrapSwitch.prototype.toggleReadonly = function() {
  10858. this.$element.prop("readonly", !this.options.readonly);
  10859. this.$wrapper.toggleClass("" + this.options.baseClass + "-readonly");
  10860. this.options.readonly = !this.options.readonly;
  10861. return this.$element;
  10862. };
  10863. BootstrapSwitch.prototype.indeterminate = function(value) {
  10864. if (typeof value === "undefined") {
  10865. return this.options.indeterminate;
  10866. }
  10867. value = !!value;
  10868. this.$wrapper[value ? "addClass" : "removeClass"]("" + this.options.baseClass + "-indeterminate");
  10869. this.$element.prop("indeterminate", value);
  10870. this.options.indeterminate = value;
  10871. return this.$element;
  10872. };
  10873. BootstrapSwitch.prototype.toggleIndeterminate = function() {
  10874. this.$element.prop("indeterminate", !this.options.indeterminate);
  10875. this.$wrapper.toggleClass("" + this.options.baseClass + "-indeterminate");
  10876. this.options.indeterminate = !this.options.indeterminate;
  10877. return this.$element;
  10878. };
  10879. BootstrapSwitch.prototype.inverse = function(value) {
  10880. var $off, $on;
  10881. if (typeof value === "undefined") {
  10882. return this.options.inverse;
  10883. }
  10884. value = !!value;
  10885. this.$wrapper[value ? "addClass" : "removeClass"]("" + this.options.baseClass + "-inverse");
  10886. $on = this.$on.clone(true);
  10887. $off = this.$off.clone(true);
  10888. this.$on.replaceWith($off);
  10889. this.$off.replaceWith($on);
  10890. this.$on = $off;
  10891. this.$off = $on;
  10892. this.options.inverse = value;
  10893. return this.$element;
  10894. };
  10895. BootstrapSwitch.prototype.toggleInverse = function() {
  10896. var $off, $on;
  10897. this.$wrapper.toggleClass("" + this.options.baseClass + "-inverse");
  10898. $on = this.$on.clone(true);
  10899. $off = this.$off.clone(true);
  10900. this.$on.replaceWith($off);
  10901. this.$off.replaceWith($on);
  10902. this.$on = $off;
  10903. this.$off = $on;
  10904. this.options.inverse = !this.options.inverse;
  10905. return this.$element;
  10906. };
  10907. BootstrapSwitch.prototype.onColor = function(value) {
  10908. var color;
  10909. color = this.options.onColor;
  10910. if (typeof value === "undefined") {
  10911. return color;
  10912. }
  10913. if (color != null) {
  10914. this.$on.removeClass("" + this.options.baseClass + "-" + color);
  10915. }
  10916. this.$on.addClass("" + this.options.baseClass + "-" + value);
  10917. this.options.onColor = value;
  10918. return this.$element;
  10919. };
  10920. BootstrapSwitch.prototype.offColor = function(value) {
  10921. var color;
  10922. color = this.options.offColor;
  10923. if (typeof value === "undefined") {
  10924. return color;
  10925. }
  10926. if (color != null) {
  10927. this.$off.removeClass("" + this.options.baseClass + "-" + color);
  10928. }
  10929. this.$off.addClass("" + this.options.baseClass + "-" + value);
  10930. this.options.offColor = value;
  10931. return this.$element;
  10932. };
  10933. BootstrapSwitch.prototype.onText = function(value) {
  10934. if (typeof value === "undefined") {
  10935. return this.options.onText;
  10936. }
  10937. this.$on.html(value);
  10938. this.options.onText = value;
  10939. return this.$element;
  10940. };
  10941. BootstrapSwitch.prototype.offText = function(value) {
  10942. if (typeof value === "undefined") {
  10943. return this.options.offText;
  10944. }
  10945. this.$off.html(value);
  10946. this.options.offText = value;
  10947. return this.$element;
  10948. };
  10949. BootstrapSwitch.prototype.labelText = function(value) {
  10950. if (typeof value === "undefined") {
  10951. return this.options.labelText;
  10952. }
  10953. this.$label.html(value);
  10954. this.options.labelText = value;
  10955. return this.$element;
  10956. };
  10957. BootstrapSwitch.prototype.baseClass = function(value) {
  10958. return this.options.baseClass;
  10959. };
  10960. BootstrapSwitch.prototype.wrapperClass = function(value) {
  10961. if (typeof value === "undefined") {
  10962. return this.options.wrapperClass;
  10963. }
  10964. if (!value) {
  10965. value = $.fn.bootstrapSwitch.defaults.wrapperClass;
  10966. }
  10967. this.$wrapper.removeClass(this._getClasses(this.options.wrapperClass).join(" "));
  10968. this.$wrapper.addClass(this._getClasses(value).join(" "));
  10969. this.options.wrapperClass = value;
  10970. return this.$element;
  10971. };
  10972. BootstrapSwitch.prototype.radioAllOff = function(value) {
  10973. if (typeof value === "undefined") {
  10974. return this.options.radioAllOff;
  10975. }
  10976. this.options.radioAllOff = value;
  10977. return this.$element;
  10978. };
  10979. BootstrapSwitch.prototype.onInit = function(value) {
  10980. if (typeof value === "undefined") {
  10981. return this.options.onInit;
  10982. }
  10983. if (!value) {
  10984. value = $.fn.bootstrapSwitch.defaults.onInit;
  10985. }
  10986. this.options.onInit = value;
  10987. return this.$element;
  10988. };
  10989. BootstrapSwitch.prototype.onSwitchChange = function(value) {
  10990. if (typeof value === "undefined") {
  10991. return this.options.onSwitchChange;
  10992. }
  10993. if (!value) {
  10994. value = $.fn.bootstrapSwitch.defaults.onSwitchChange;
  10995. }
  10996. this.options.onSwitchChange = value;
  10997. return this.$element;
  10998. };
  10999. BootstrapSwitch.prototype.destroy = function() {
  11000. var $form;
  11001. $form = this.$element.closest("form");
  11002. if ($form.length) {
  11003. $form.off("reset.bootstrapSwitch").removeData("bootstrap-switch");
  11004. }
  11005. this.$container.children().not(this.$element).remove();
  11006. this.$element.unwrap().unwrap().off(".bootstrapSwitch").removeData("bootstrap-switch");
  11007. return this.$element;
  11008. };
  11009. BootstrapSwitch.prototype._elementHandlers = function() {
  11010. return this.$element.on({
  11011. "change.bootstrapSwitch": (function(_this) {
  11012. return function(e, skip) {
  11013. var checked;
  11014. e.preventDefault();
  11015. e.stopImmediatePropagation();
  11016. checked = _this.$element.is(":checked");
  11017. if (checked === _this.options.state) {
  11018. return;
  11019. }
  11020. _this.options.state = checked;
  11021. _this.$wrapper.removeClass(checked ? "" + _this.options.baseClass + "-off" : "" + _this.options.baseClass + "-on").addClass(checked ? "" + _this.options.baseClass + "-on" : "" + _this.options.baseClass + "-off");
  11022. if (!skip) {
  11023. if (_this.$element.is(":radio")) {
  11024. $("[name='" + (_this.$element.attr('name')) + "']").not(_this.$element).prop("checked", false).trigger("change.bootstrapSwitch", true);
  11025. }
  11026. return _this.$element.trigger("switchChange.bootstrapSwitch", [checked]);
  11027. }
  11028. };
  11029. })(this),
  11030. "focus.bootstrapSwitch": (function(_this) {
  11031. return function(e) {
  11032. e.preventDefault();
  11033. return _this.$wrapper.addClass("" + _this.options.baseClass + "-focused");
  11034. };
  11035. })(this),
  11036. "blur.bootstrapSwitch": (function(_this) {
  11037. return function(e) {
  11038. e.preventDefault();
  11039. return _this.$wrapper.removeClass("" + _this.options.baseClass + "-focused");
  11040. };
  11041. })(this),
  11042. "keydown.bootstrapSwitch": (function(_this) {
  11043. return function(e) {
  11044. if (!e.which || _this.options.disabled || _this.options.readonly) {
  11045. return;
  11046. }
  11047. switch (e.which) {
  11048. case 37:
  11049. e.preventDefault();
  11050. e.stopImmediatePropagation();
  11051. return _this.state(false);
  11052. case 39:
  11053. e.preventDefault();
  11054. e.stopImmediatePropagation();
  11055. return _this.state(true);
  11056. }
  11057. };
  11058. })(this)
  11059. });
  11060. };
  11061. BootstrapSwitch.prototype._handleHandlers = function() {
  11062. this.$on.on("click.bootstrapSwitch", (function(_this) {
  11063. return function(e) {
  11064. _this.state(false);
  11065. return _this.$element.trigger("focus.bootstrapSwitch");
  11066. };
  11067. })(this));
  11068. return this.$off.on("click.bootstrapSwitch", (function(_this) {
  11069. return function(e) {
  11070. _this.state(true);
  11071. return _this.$element.trigger("focus.bootstrapSwitch");
  11072. };
  11073. })(this));
  11074. };
  11075. BootstrapSwitch.prototype._labelHandlers = function() {
  11076. return this.$label.on({
  11077. "mousemove.bootstrapSwitch touchmove.bootstrapSwitch": (function(_this) {
  11078. return function(e) {
  11079. var left, pageX, percent, right;
  11080. if (!_this.isLabelDragging) {
  11081. return;
  11082. }
  11083. e.preventDefault();
  11084. _this.isLabelDragged = true;
  11085. pageX = e.pageX || e.originalEvent.touches[0].pageX;
  11086. percent = ((pageX - _this.$wrapper.offset().left) / _this.$wrapper.width()) * 100;
  11087. left = 25;
  11088. right = 75;
  11089. if (_this.options.animate) {
  11090. _this.$wrapper.removeClass("" + _this.options.baseClass + "-animate");
  11091. }
  11092. if (percent < left) {
  11093. percent = left;
  11094. } else if (percent > right) {
  11095. percent = right;
  11096. }
  11097. _this.$container.css("margin-left", "" + (percent - right) + "%");
  11098. return _this.$element.trigger("focus.bootstrapSwitch");
  11099. };
  11100. })(this),
  11101. "mousedown.bootstrapSwitch touchstart.bootstrapSwitch": (function(_this) {
  11102. return function(e) {
  11103. if (_this.isLabelDragging || _this.options.disabled || _this.options.readonly) {
  11104. return;
  11105. }
  11106. e.preventDefault();
  11107. _this.isLabelDragging = true;
  11108. return _this.$element.trigger("focus.bootstrapSwitch");
  11109. };
  11110. })(this),
  11111. "mouseup.bootstrapSwitch touchend.bootstrapSwitch": (function(_this) {
  11112. return function(e) {
  11113. var state;
  11114. if (!_this.isLabelDragging) {
  11115. return;
  11116. }
  11117. e.preventDefault();
  11118. if (_this.isLabelDragged) {
  11119. state = parseInt(_this.$container.css("margin-left"), 10) > -(_this.$container.width() / 6);
  11120. _this.isLabelDragged = false;
  11121. _this.state(_this.options.inverse ? !state : state);
  11122. if (_this.options.animate) {
  11123. _this.$wrapper.addClass("" + _this.options.baseClass + "-animate");
  11124. }
  11125. _this.$container.css("margin-left", "");
  11126. } else {
  11127. _this.state(!_this.options.state);
  11128. }
  11129. return _this.isLabelDragging = false;
  11130. };
  11131. })(this),
  11132. "mouseleave.bootstrapSwitch": (function(_this) {
  11133. return function(e) {
  11134. return _this.$label.trigger("mouseup.bootstrapSwitch");
  11135. };
  11136. })(this)
  11137. });
  11138. };
  11139. BootstrapSwitch.prototype._formHandler = function() {
  11140. var $form;
  11141. $form = this.$element.closest("form");
  11142. if ($form.data("bootstrap-switch")) {
  11143. return;
  11144. }
  11145. return $form.on("reset.bootstrapSwitch", function() {
  11146. return window.setTimeout(function() {
  11147. return $form.find("input").filter(function() {
  11148. return $(this).data("bootstrap-switch");
  11149. }).each(function() {
  11150. return $(this).bootstrapSwitch("state", this.checked);
  11151. });
  11152. }, 1);
  11153. }).data("bootstrap-switch", true);
  11154. };
  11155. BootstrapSwitch.prototype._getClasses = function(classes) {
  11156. var c, cls, _i, _len;
  11157. if (!$.isArray(classes)) {
  11158. return ["" + this.options.baseClass + "-" + classes];
  11159. }
  11160. cls = [];
  11161. for (_i = 0, _len = classes.length; _i < _len; _i++) {
  11162. c = classes[_i];
  11163. cls.push("" + this.options.baseClass + "-" + c);
  11164. }
  11165. return cls;
  11166. };
  11167. return BootstrapSwitch;
  11168. })();
  11169. $.fn.bootstrapSwitch = function() {
  11170. var args, option, ret;
  11171. option = arguments[0], args = 2 <= arguments.length ? __slice.call(arguments, 1) : [];
  11172. ret = this;
  11173. this.each(function() {
  11174. var $this, data;
  11175. $this = $(this);
  11176. data = $this.data("bootstrap-switch");
  11177. if (!data) {
  11178. $this.data("bootstrap-switch", data = new BootstrapSwitch(this, option));
  11179. }
  11180. if (typeof option === "string") {
  11181. return ret = data[option].apply(data, args);
  11182. }
  11183. });
  11184. return ret;
  11185. };
  11186. $.fn.bootstrapSwitch.Constructor = BootstrapSwitch;
  11187. return $.fn.bootstrapSwitch.defaults = {
  11188. state: true,
  11189. size: null,
  11190. animate: true,
  11191. disabled: false,
  11192. readonly: false,
  11193. indeterminate: false,
  11194. inverse: false,
  11195. radioAllOff: false,
  11196. onColor: "primary",
  11197. offColor: "default",
  11198. onText: "ON",
  11199. offText: "OFF",
  11200. labelText: "&nbsp;",
  11201. baseClass: "bootstrap-switch",
  11202. wrapperClass: "wrapper",
  11203. onInit: function() {},
  11204. onSwitchChange: function() {}
  11205. };
  11206. })(window.jQuery, window);
  11207. }).call(this);
  11208. /* =============================================================
  11209. * bootstrap-typeahead.js v2.3.1-j6
  11210. * http://twitter.github.com/bootstrap/javascript.html#typeahead
  11211. * =============================================================
  11212. * Copyright 2012 Twitter, Inc.
  11213. *
  11214. * Licensed under the Apache License, Version 2.0 (the "License");
  11215. * you may not use this file except in compliance with the License.
  11216. * You may obtain a copy of the License at
  11217. *
  11218. * http://www.apache.org/licenses/LICENSE-2.0
  11219. *
  11220. * Unless required by applicable law or agreed to in writing, software
  11221. * distributed under the License is distributed on an "AS IS" BASIS,
  11222. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  11223. * See the License for the specific language governing permissions and
  11224. * limitations under the License.
  11225. * ============================================================ */
  11226. !function($){
  11227. "use strict"; // jshint ;_;
  11228. /* TYPEAHEAD PUBLIC CLASS DEFINITION
  11229. * ================================= */
  11230. var Typeahead = function (element, options) {
  11231. this.$element = $(element)
  11232. this.options = $.extend({}, $.fn.typeahead.defaults, options)
  11233. if (this.options.target) this.$target = $(this.options.target)
  11234. this.matcher = this.options.matcher || this.matcher
  11235. this.sorter = this.options.sorter || this.sorter
  11236. this.highlighter = this.options.highlighter || this.highlighter
  11237. this.updater = this.options.updater || this.updater
  11238. this.source = this.options.source
  11239. this.strict = this.options.strict
  11240. this.$menu = $(this.options.menu)
  11241. this.shown = false
  11242. if (typeof this.source == 'string') {
  11243. this.url = this.source
  11244. this.source = this.searchAjax
  11245. }
  11246. if (element.nodeName == 'SELECT') this.replaceSelect()
  11247. this.text = this.$element.val()
  11248. this.$element
  11249. .attr('data-text', this.value)
  11250. .attr('autocomplete', "off")
  11251. if (typeof this.$target != 'undefined') this.$element.attr('data-value', this.$target.val())
  11252. else if (typeof this.$element.attr('data-value') == 'undefined') this.$element.attr('data-value', this.strict ? '' : this.value)
  11253. this.$menu.css('min-width', this.$element.width() + 12)
  11254. this.listen()
  11255. }
  11256. Typeahead.prototype = {
  11257. constructor: Typeahead
  11258. , replaceSelect: function () {
  11259. this.$target = this.$element
  11260. this.$element = $('<input type="text" />')
  11261. this.source = {}
  11262. this.strict = true
  11263. var options = this.$target.find('option')
  11264. var $option;
  11265. for (var i=0; i<options.length; i++) {
  11266. $option = $(options[i]);
  11267. if ($option.val() === '') {
  11268. this.$element.attr('placeholder', $option.html());
  11269. continue;
  11270. }
  11271. this.source[$option.val()] = $option.html()
  11272. if (this.$target.val() == $option.val()) this.$element.val($option.html())
  11273. }
  11274. var attr = this.$target[0].attributes
  11275. for (i=0; i<attr.length; i++) {
  11276. if (attr[i].nodeName != 'type' && attr[i].nodeName != 'name' && attr[i].nodeName != 'id' && attr[i].nodeName != 'data-provide' && !attr[i].nodeName.match(/^on/)) {
  11277. this.$element.attr(attr[i].nodeName, attr[i].nodeValue)
  11278. }
  11279. }
  11280. this.$element.insertAfter(this.$target)
  11281. if (this.$target.attr('autofocus')) this.$element.trigger('focus').select()
  11282. this.$target.attr('autofocus', false)
  11283. this.$target.hide()
  11284. }
  11285. , destroyReplacement: function () {
  11286. // Detroy replacement element, so it doesn't mess up the browsers autofill on refresh
  11287. if (typeof this.$target != 'undefined' && this.$target[0].nodeName == 'SELECT') {
  11288. this.$element.replaceWith('');
  11289. }
  11290. }
  11291. , select: function () {
  11292. var li = this.$menu.find('.active')
  11293. , val = li.attr('data-value')
  11294. , text = li.find('.item-text').length > 0 ? li.find('.item-text').text() : li.text()
  11295. val = this.updater(val, 'value')
  11296. text = this.updater(text, 'text')
  11297. this.$element
  11298. .val(text)
  11299. .attr('data-value', val)
  11300. this.text = text
  11301. if (typeof this.$target != 'undefined') {
  11302. this.$target
  11303. .val(val)
  11304. .trigger('change')
  11305. }
  11306. this.$element.trigger('change')
  11307. return this.hide()
  11308. }
  11309. , updater: function (text, type) {
  11310. return text
  11311. }
  11312. , show: function () {
  11313. var pos = $.extend({}, this.$element.position(), {
  11314. height: this.$element[0].offsetHeight
  11315. })
  11316. this.$menu
  11317. .insertAfter(this.$element)
  11318. .css({
  11319. top: pos.top + pos.height
  11320. , left: pos.left
  11321. })
  11322. .show()
  11323. this.shown = true
  11324. return this
  11325. }
  11326. , hide: function () {
  11327. this.$menu.hide()
  11328. this.shown = false
  11329. return this
  11330. }
  11331. , lookup: function (event) {
  11332. var items
  11333. this.query = this.$element.val()
  11334. if (!this.query || this.query.length < this.options.minLength) {
  11335. return this.shown ? this.hide() : this
  11336. }
  11337. items = $.isFunction(this.source) ? this.source(this.query, $.proxy(this.process, this)) : this.source
  11338. return items ? this.process(items) : this
  11339. }
  11340. , process: function (items) {
  11341. return $.isArray(items) ? this.processArray(items) : this.processObject(items)
  11342. }
  11343. , processArray: function (items) {
  11344. var that = this
  11345. items = $.grep(items, function (item) {
  11346. return that.matcher(item)
  11347. })
  11348. items = this.sorter(items)
  11349. if (!items.length) {
  11350. return this.shown ? this.hide() : this
  11351. }
  11352. return this.render(items.slice(0, this.options.items)).show()
  11353. }
  11354. , processObject: function (itemsIn) {
  11355. var that = this
  11356. , items = {}
  11357. , i = 0
  11358. $.each(itemsIn, function (key, item) {
  11359. if (that.matcher(item)) items[key] = item
  11360. })
  11361. items = this.sorter(items)
  11362. if ($.isEmptyObject(items)) {
  11363. return this.shown ? this.hide() : this
  11364. }
  11365. $.each(items, function(key, item) {
  11366. if (i++ >= that.options.items) delete items[key]
  11367. })
  11368. return this.render(items).show()
  11369. }
  11370. , searchAjax: function (query, process) {
  11371. var that = this
  11372. if (this.ajaxTimeout) clearTimeout(this.ajaxTimeout)
  11373. this.ajaxTimeout = setTimeout(function () {
  11374. if (that.ajaxTimeout) clearTimeout(that.ajaxTimeout)
  11375. if (query === "") {
  11376. that.hide()
  11377. return
  11378. }
  11379. $.get(that.url, {'q': query, 'limit': that.options.items }, function (items) {
  11380. if (typeof items == 'string') items = JSON.parse(items)
  11381. process(items)
  11382. })
  11383. }, this.options.ajaxdelay)
  11384. }
  11385. , matcher: function (item) {
  11386. return ~item.toLowerCase().indexOf(this.query.toLowerCase())
  11387. }
  11388. , sorter: function (items) {
  11389. return $.isArray(items) ? this.sortArray(items) : this.sortObject(items)
  11390. }
  11391. , sortArray: function (items) {
  11392. var beginswith = []
  11393. , caseSensitive = []
  11394. , caseInsensitive = []
  11395. , item
  11396. while (item = items.shift()) {
  11397. if (!item.toLowerCase().indexOf(this.query.toLowerCase())) beginswith.push(item)
  11398. else if (~item.indexOf(this.query)) caseSensitive.push(item)
  11399. else caseInsensitive.push(item)
  11400. }
  11401. return beginswith.concat(caseSensitive, caseInsensitive)
  11402. }
  11403. , sortObject: function (items) {
  11404. var sorted = {}
  11405. , key;
  11406. for (key in items) {
  11407. if (!items[key].toLowerCase().indexOf(this.query.toLowerCase())) {
  11408. sorted[key] = items[key];
  11409. delete items[key]
  11410. }
  11411. }
  11412. for (key in items) {
  11413. if (~items[key].indexOf(this.query)) {
  11414. sorted[key] = items[key];
  11415. delete items[key]
  11416. }
  11417. }
  11418. for (key in items) {
  11419. sorted[key] = items[key]
  11420. }
  11421. return sorted
  11422. }
  11423. , highlighter: function (item) {
  11424. var query = this.query.replace(/[\-\[\]{}()*+?.,\\\^$|#\s]/g, '\\$&')
  11425. return item.replace(new RegExp('(' + query + ')', 'ig'), function ($1, match) {
  11426. return '<strong>' + match + '</strong>'
  11427. })
  11428. }
  11429. , render: function (items) {
  11430. var that = this
  11431. , list = $([])
  11432. $.map(items, function (item, value) {
  11433. if (list.length >= that.options.items) return
  11434. var li
  11435. , a
  11436. if ($.isArray(items)) value = item
  11437. li = $(that.options.item)
  11438. a = li.find('a').length ? li.find('a') : li
  11439. a.html(that.highlighter(item))
  11440. li.attr('data-value', value)
  11441. if (li.find('a').length === 0) li.addClass('dropdown-header')
  11442. list.push(li[0])
  11443. })
  11444. list.not('.dropdown-header').first().addClass('active')
  11445. this.$menu.html(list)
  11446. return this
  11447. }
  11448. , next: function (event) {
  11449. var active = this.$menu.find('.active').removeClass('active')
  11450. , next = active.nextAll('li:not(.dropdown-header)').first()
  11451. if (!next.length) {
  11452. next = $(this.$menu.find('li:not(.dropdown-header)')[0])
  11453. }
  11454. next.addClass('active')
  11455. }
  11456. , prev: function (event) {
  11457. var active = this.$menu.find('.active').removeClass('active')
  11458. , prev = active.prevAll('li:not(.dropdown-header)').first()
  11459. if (!prev.length) {
  11460. prev = this.$menu.find('li:not(.dropdown-header)').last()
  11461. }
  11462. prev.addClass('active')
  11463. }
  11464. , listen: function () {
  11465. this.$element
  11466. .on('focus', $.proxy(this.focus, this))
  11467. .on('blur', $.proxy(this.blur, this))
  11468. .on('change', $.proxy(this.change, this))
  11469. .on('keypress', $.proxy(this.keypress, this))
  11470. .on('keyup', $.proxy(this.keyup, this))
  11471. if (this.eventSupported('keydown')) {
  11472. this.$element.on('keydown', $.proxy(this.keydown, this))
  11473. }
  11474. this.$menu
  11475. .on('click', $.proxy(this.click, this))
  11476. .on('mouseenter', 'li', $.proxy(this.mouseenter, this))
  11477. .on('mouseleave', 'li', $.proxy(this.mouseleave, this))
  11478. $(window).on('unload', $.proxy(this.destroyReplacement, this))
  11479. }
  11480. , eventSupported: function(eventName) {
  11481. var isSupported = eventName in this.$element
  11482. if (!isSupported) {
  11483. this.$element.setAttribute(eventName, 'return;')
  11484. isSupported = typeof this.$element[eventName] === 'function'
  11485. }
  11486. return isSupported
  11487. }
  11488. , move: function (e) {
  11489. if (!this.shown) return
  11490. switch(e.keyCode) {
  11491. case 9: // tab
  11492. case 13: // enter
  11493. case 27: // escape
  11494. e.preventDefault()
  11495. break
  11496. case 38: // up arrow
  11497. e.preventDefault()
  11498. this.prev()
  11499. break
  11500. case 40: // down arrow
  11501. e.preventDefault()
  11502. this.next()
  11503. break
  11504. }
  11505. e.stopPropagation()
  11506. }
  11507. , keydown: function (e) {
  11508. this.suppressKeyPressRepeat = ~$.inArray(e.keyCode, [40,38,9,13,27])
  11509. this.move(e)
  11510. }
  11511. , keypress: function (e) {
  11512. if (this.suppressKeyPressRepeat) return
  11513. this.move(e)
  11514. }
  11515. , keyup: function (e) {
  11516. switch(e.keyCode) {
  11517. case 40: // down arrow
  11518. case 38: // up arrow
  11519. case 16: // shift
  11520. case 17: // ctrl
  11521. case 18: // alt
  11522. break
  11523. case 9: // tab
  11524. case 13: // enter
  11525. if (!this.shown) return
  11526. this.select()
  11527. break
  11528. case 27: // escape
  11529. if (!this.shown) return
  11530. this.hide()
  11531. break
  11532. default:
  11533. this.lookup()
  11534. }
  11535. e.stopPropagation()
  11536. e.preventDefault()
  11537. }
  11538. , change: function (e) {
  11539. var value
  11540. if (this.$element.val() != this.text) {
  11541. value = this.$element.val() === '' || this.strict ? '' : this.$element.val()
  11542. this.$element.val(value)
  11543. this.$element.attr('data-value', value)
  11544. this.text = value
  11545. if (typeof this.$target != 'undefined') this.$target.val(value)
  11546. }
  11547. }
  11548. , focus: function (e) {
  11549. this.focused = true
  11550. }
  11551. , blur: function (e) {
  11552. this.focused = false
  11553. if (!this.mousedover && this.shown) this.hide()
  11554. }
  11555. , click: function (e) {
  11556. e.stopPropagation()
  11557. e.preventDefault()
  11558. this.select()
  11559. this.$element.focus()
  11560. }
  11561. , mouseenter: function (e) {
  11562. this.mousedover = true
  11563. this.$menu.find('.active').removeClass('active')
  11564. $(e.currentTarget).addClass('active')
  11565. }
  11566. , mouseleave: function (e) {
  11567. this.mousedover = false
  11568. if (!this.focused && this.shown) this.hide()
  11569. }
  11570. }
  11571. /* TYPEAHEAD PLUGIN DEFINITION
  11572. * =========================== */
  11573. var old = $.fn.typeahead
  11574. $.fn.typeahead = function (option) {
  11575. return this.each(function () {
  11576. var $this = $(this)
  11577. , data = $this.data('typeahead')
  11578. , options = typeof option == 'object' && option
  11579. if (!data) $this.data('typeahead', (data = new Typeahead(this, options)))
  11580. if (typeof option == 'string') data[option]()
  11581. })
  11582. }
  11583. $.fn.typeahead.defaults = {
  11584. source: []
  11585. , items: 8
  11586. , menu: '<ul class="typeahead dropdown-menu"></ul>'
  11587. , item: '<li><a href="#"></a></li>'
  11588. , ajaxdelay: 400
  11589. , minLength: 1
  11590. }
  11591. $.fn.typeahead.Constructor = Typeahead
  11592. /* TYPEAHEAD NO CONFLICT
  11593. * =================== */
  11594. $.fn.typeahead.noConflict = function () {
  11595. $.fn.typeahead = old
  11596. return this
  11597. }
  11598. /* TYPEAHEAD DATA-API
  11599. * ================== */
  11600. $(document)
  11601. .off('focus.typeahead.data-api') // overwriting Twitter's typeahead
  11602. .on('focus.typeahead.data-api', '[data-provide="typeahead"]', function (e) {
  11603. var $this = $(this)
  11604. if ($this.data('typeahead')) return
  11605. if ($this.is('select')) $this.attr('autofocus', true)
  11606. e.preventDefault()
  11607. $this.typeahead($this.data())
  11608. })
  11609. }(window.jQuery);
  11610. /* ===========================================================
  11611. * bootstrap-inputmask.js j2
  11612. * http://twitter.github.com/bootstrap/javascript.html#tooltips
  11613. * Based on Masked Input plugin by Josh Bush (digitalbush.com)
  11614. * ===========================================================
  11615. * Copyright 2012 Jasny BV, Netherlands.
  11616. *
  11617. * Licensed under the Apache License, Version 2.0 (the "License")
  11618. * you may not use this file except in compliance with the License.
  11619. * You may obtain a copy of the License at
  11620. *
  11621. * http://www.apache.org/licenses/LICENSE-2.0
  11622. *
  11623. * Unless required by applicable law or agreed to in writing, software
  11624. * distributed under the License is distributed on an "AS IS" BASIS,
  11625. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  11626. * See the License for the specific language governing permissions and
  11627. * limitations under the License.
  11628. * ========================================================== */
  11629. !function ($) {
  11630. "use strict"; // jshint ;_;
  11631. var isIphone = (window.orientation !== undefined),
  11632. isAndroid = navigator.userAgent.toLowerCase().indexOf("android") > -1
  11633. /* INPUTMASK PUBLIC CLASS DEFINITION
  11634. * ================================= */
  11635. var Inputmask = function (element, options) {
  11636. if (isAndroid) return // No support because caret positioning doesn't work on Android
  11637. this.$element = $(element)
  11638. this.options = $.extend({}, $.fn.inputmask.defaults, options)
  11639. this.mask = String(options.mask)
  11640. this.init()
  11641. this.listen()
  11642. this.checkVal() //Perform initial check for existing values
  11643. }
  11644. Inputmask.prototype = {
  11645. init: function() {
  11646. var defs = this.options.definitions
  11647. var len = this.mask.length
  11648. this.tests = []
  11649. this.partialPosition = this.mask.length
  11650. this.firstNonMaskPos = null
  11651. $.each(this.mask.split(""), $.proxy(function(i, c) {
  11652. if (c == '?') {
  11653. len--
  11654. this.partialPosition = i
  11655. } else if (defs[c]) {
  11656. this.tests.push(new RegExp(defs[c]))
  11657. if(this.firstNonMaskPos === null)
  11658. this.firstNonMaskPos = this.tests.length - 1
  11659. } else {
  11660. this.tests.push(null)
  11661. }
  11662. }, this))
  11663. this.buffer = $.map(this.mask.split(""), $.proxy(function(c, i) {
  11664. if (c != '?') return defs[c] ? this.options.placeholder : c
  11665. }, this))
  11666. this.focusText = this.$element.val()
  11667. this.$element.data("rawMaskFn", $.proxy(function() {
  11668. return $.map(this.buffer, function(c, i) {
  11669. return this.tests[i] && c != this.options.placeholder ? c : null
  11670. }).join('')
  11671. }, this))
  11672. },
  11673. listen: function() {
  11674. if (this.$element.attr("readonly")) return
  11675. var pasteEventName = (navigator.userAgent.match(/msie/i) ? 'paste' : 'input') + ".mask"
  11676. this.$element
  11677. .on("unmask", $.proxy(this.unmask, this))
  11678. .on("focus.mask", $.proxy(this.focusEvent, this))
  11679. .on("blur.mask", $.proxy(this.blurEvent, this))
  11680. .on("keydown.mask", $.proxy(this.keydownEvent, this))
  11681. .on("keypress.mask", $.proxy(this.keypressEvent, this))
  11682. .on(pasteEventName, $.proxy(this.pasteEvent, this))
  11683. },
  11684. //Helper Function for Caret positioning
  11685. caret: function(begin, end) {
  11686. if (this.$element.length === 0) return
  11687. if (typeof begin == 'number') {
  11688. end = (typeof end == 'number') ? end : begin
  11689. return this.$element.each(function() {
  11690. if (this.setSelectionRange) {
  11691. this.setSelectionRange(begin, end)
  11692. } else if (this.createTextRange) {
  11693. var range = this.createTextRange()
  11694. range.collapse(true)
  11695. range.moveEnd('character', end)
  11696. range.moveStart('character', begin)
  11697. range.select()
  11698. }
  11699. })
  11700. } else {
  11701. if (this.$element[0].setSelectionRange) {
  11702. begin = this.$element[0].selectionStart
  11703. end = this.$element[0].selectionEnd
  11704. } else if (document.selection && document.selection.createRange) {
  11705. var range = document.selection.createRange()
  11706. begin = 0 - range.duplicate().moveStart('character', -100000)
  11707. end = begin + range.text.length
  11708. }
  11709. return {
  11710. begin: begin,
  11711. end: end
  11712. }
  11713. }
  11714. },
  11715. seekNext: function(pos) {
  11716. var len = this.mask.length
  11717. while (++pos <= len && !this.tests[pos]);
  11718. return pos
  11719. },
  11720. seekPrev: function(pos) {
  11721. while (--pos >= 0 && !this.tests[pos]);
  11722. return pos
  11723. },
  11724. shiftL: function(begin,end) {
  11725. var len = this.mask.length
  11726. if(begin<0) return
  11727. for (var i = begin,j = this.seekNext(end); i < len; i++) {
  11728. if (this.tests[i]) {
  11729. if (j < len && this.tests[i].test(this.buffer[j])) {
  11730. this.buffer[i] = this.buffer[j]
  11731. this.buffer[j] = this.options.placeholder
  11732. } else
  11733. break
  11734. j = this.seekNext(j)
  11735. }
  11736. }
  11737. this.writeBuffer()
  11738. this.caret(Math.max(this.firstNonMaskPos, begin))
  11739. },
  11740. shiftR: function(pos) {
  11741. var len = this.mask.length
  11742. for (var i = pos, c = this.options.placeholder; i < len; i++) {
  11743. if (this.tests[i]) {
  11744. var j = this.seekNext(i)
  11745. var t = this.buffer[i]
  11746. this.buffer[i] = c
  11747. if (j < len && this.tests[j].test(t))
  11748. c = t
  11749. else
  11750. break
  11751. }
  11752. }
  11753. },
  11754. unmask: function() {
  11755. this.$element
  11756. .unbind(".mask")
  11757. .removeData("inputmask")
  11758. },
  11759. focusEvent: function() {
  11760. this.focusText = this.$element.val()
  11761. var len = this.mask.length
  11762. var pos = this.checkVal()
  11763. this.writeBuffer()
  11764. var that = this
  11765. var moveCaret = function() {
  11766. if (pos == len)
  11767. that.caret(0, pos)
  11768. else
  11769. that.caret(pos)
  11770. }
  11771. if ($.browser.msie)
  11772. moveCaret()
  11773. else
  11774. setTimeout(moveCaret, 0)
  11775. },
  11776. blurEvent: function() {
  11777. this.checkVal()
  11778. if (this.$element.val() != this.focusText)
  11779. this.$element.trigger('change')
  11780. },
  11781. keydownEvent: function(e) {
  11782. var k=e.which
  11783. //backspace, delete, and escape get special treatment
  11784. if (k == 8 || k == 46 || (isIphone && k == 127)) {
  11785. var pos = this.caret(),
  11786. begin = pos.begin,
  11787. end = pos.end
  11788. if (end-begin === 0) {
  11789. begin = k!=46 ? this.seekPrev(begin) : (end=this.seekNext(begin-1))
  11790. end = k==46 ? this.seekNext(end) : end
  11791. }
  11792. this.clearBuffer(begin, end)
  11793. this.shiftL(begin,end-1)
  11794. return false
  11795. } else if (k == 27) {//escape
  11796. this.$element.val(this.focusText)
  11797. this.caret(0, this.checkVal())
  11798. return false
  11799. }
  11800. },
  11801. keypressEvent: function(e) {
  11802. var len = this.mask.length
  11803. var k = e.which,
  11804. pos = this.caret()
  11805. if (e.ctrlKey || e.altKey || e.metaKey || k<32) {//Ignore
  11806. return true
  11807. } else if (k) {
  11808. if (pos.end - pos.begin !== 0) {
  11809. this.clearBuffer(pos.begin, pos.end)
  11810. this.shiftL(pos.begin, pos.end-1)
  11811. }
  11812. var p = this.seekNext(pos.begin - 1)
  11813. if (p < len) {
  11814. var c = String.fromCharCode(k)
  11815. if (this.tests[p].test(c)) {
  11816. this.shiftR(p)
  11817. this.buffer[p] = c
  11818. this.writeBuffer()
  11819. var next = this.seekNext(p)
  11820. this.caret(next)
  11821. }
  11822. }
  11823. return false
  11824. }
  11825. },
  11826. pasteEvent: function() {
  11827. var that = this
  11828. setTimeout(function() {
  11829. that.caret(that.checkVal(true))
  11830. }, 0)
  11831. },
  11832. clearBuffer: function(start, end) {
  11833. var len = this.mask.length
  11834. for (var i = start; i < end && i < len; i++) {
  11835. if (this.tests[i])
  11836. this.buffer[i] = this.options.placeholder
  11837. }
  11838. },
  11839. writeBuffer: function() {
  11840. return this.$element.val(this.buffer.join('')).val()
  11841. },
  11842. checkVal: function(allow) {
  11843. var len = this.mask.length
  11844. //try to place characters where they belong
  11845. var test = this.$element.val()
  11846. var lastMatch = -1
  11847. for (var i = 0, pos = 0; i < len; i++) {
  11848. if (this.tests[i]) {
  11849. this.buffer[i] = this.options.placeholder
  11850. while (pos++ < test.length) {
  11851. var c = test.charAt(pos - 1)
  11852. if (this.tests[i].test(c)) {
  11853. this.buffer[i] = c
  11854. lastMatch = i
  11855. break
  11856. }
  11857. }
  11858. if (pos > test.length)
  11859. break
  11860. } else if (this.buffer[i] == test.charAt(pos) && i != this.partialPosition) {
  11861. pos++
  11862. lastMatch = i
  11863. }
  11864. }
  11865. if (!allow && lastMatch + 1 < this.partialPosition) {
  11866. this.$element.val("")
  11867. this.clearBuffer(0, len)
  11868. } else if (allow || lastMatch + 1 >= this.partialPosition) {
  11869. this.writeBuffer()
  11870. if (!allow) this.$element.val(this.$element.val().substring(0, lastMatch + 1))
  11871. }
  11872. return (this.partialPosition ? i : this.firstNonMaskPos)
  11873. }
  11874. }
  11875. /* INPUTMASK PLUGIN DEFINITION
  11876. * =========================== */
  11877. $.fn.inputmask = function (options) {
  11878. return this.each(function () {
  11879. var $this = $(this)
  11880. , data = $this.data('inputmask')
  11881. if (!data) $this.data('inputmask', (data = new Inputmask(this, options)))
  11882. })
  11883. }
  11884. $.fn.inputmask.defaults = {
  11885. mask: "",
  11886. placeholder: "_",
  11887. definitions: {
  11888. '9': "[0-9]",
  11889. 'a': "[A-Za-z]",
  11890. '?': "[A-Za-z0-9]",
  11891. '*': "."
  11892. }
  11893. }
  11894. $.fn.inputmask.Constructor = Inputmask
  11895. /* INPUTMASK DATA-API
  11896. * ================== */
  11897. $(document).on('focus.inputmask.data-api', '[data-mask]', function (e) {
  11898. var $this = $(this)
  11899. if ($this.data('inputmask')) return
  11900. e.preventDefault()
  11901. $this.inputmask($this.data())
  11902. })
  11903. }(window.jQuery);
  11904. /* ============================================================
  11905. * bootstrap-rowlink.js j1
  11906. * http://jasny.github.com/bootstrap/javascript.html#rowlink
  11907. * ============================================================
  11908. * Copyright 2012 Jasny BV, Netherlands.
  11909. *
  11910. * Licensed under the Apache License, Version 2.0 (the "License");
  11911. * you may not use this file except in compliance with the License.
  11912. * You may obtain a copy of the License at
  11913. *
  11914. * http://www.apache.org/licenses/LICENSE-2.0
  11915. *
  11916. * Unless required by applicable law or agreed to in writing, software
  11917. * distributed under the License is distributed on an "AS IS" BASIS,
  11918. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  11919. * See the License for the specific language governing permissions and
  11920. * limitations under the License.
  11921. * ============================================================ */
  11922. !function ($) {
  11923. "use strict"; // jshint ;_;
  11924. var Rowlink = function (element, options) {
  11925. options = $.extend({}, $.fn.rowlink.defaults, options)
  11926. var tr = element.nodeName.toLowerCase() == 'tr' ? $(element) : $(element).find('tr:has(td)')
  11927. tr.each(function() {
  11928. var link = $(this).find(options.target).first()
  11929. if (!link.length) return
  11930. var href = link.attr('href')
  11931. $(this).find('td').not('.nolink').click(function() {
  11932. window.location = href;
  11933. })
  11934. $(this).addClass('rowlink')
  11935. link.replaceWith(link.html())
  11936. })
  11937. }
  11938. /* ROWLINK PLUGIN DEFINITION
  11939. * =========================== */
  11940. $.fn.rowlink = function (options) {
  11941. return this.each(function () {
  11942. var $this = $(this)
  11943. , data = $this.data('rowlink')
  11944. if (!data) $this.data('rowlink', (data = new Rowlink(this, options)))
  11945. })
  11946. }
  11947. $.fn.rowlink.defaults = {
  11948. target: "a"
  11949. }
  11950. $.fn.rowlink.Constructor = Rowlink
  11951. /* ROWLINK DATA-API
  11952. * ================== */
  11953. $(function () {
  11954. $('[data-provide="rowlink"],[data-provides="rowlink"]').each(function () {
  11955. $(this).rowlink($(this).data())
  11956. })
  11957. })
  11958. }(window.jQuery);
  11959. /* ===========================================================
  11960. * bootstrap-fileupload.js j2
  11961. * http://jasny.github.com/bootstrap/javascript.html#fileupload
  11962. * ===========================================================
  11963. * Copyright 2012 Jasny BV, Netherlands.
  11964. *
  11965. * Licensed under the Apache License, Version 2.0 (the "License")
  11966. * you may not use this file except in compliance with the License.
  11967. * You may obtain a copy of the License at
  11968. *
  11969. * http://www.apache.org/licenses/LICENSE-2.0
  11970. *
  11971. * Unless required by applicable law or agreed to in writing, software
  11972. * distributed under the License is distributed on an "AS IS" BASIS,
  11973. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  11974. * See the License for the specific language governing permissions and
  11975. * limitations under the License.
  11976. * ========================================================== */
  11977. !function ($) {
  11978. "use strict"; // jshint ;_
  11979. /* FILEUPLOAD PUBLIC CLASS DEFINITION
  11980. * ================================= */
  11981. var Fileupload = function (element, options) {
  11982. this.$element = $(element)
  11983. this.type = this.$element.data('uploadtype') || (this.$element.find('.thumbnail').length > 0 ? "image" : "file")
  11984. this.$input = this.$element.find(':file')
  11985. if (this.$input.length === 0) return
  11986. this.name = this.$input.attr('name') || options.name
  11987. this.$hidden = this.$element.find('input[type=hidden][name="'+this.name+'"]')
  11988. if (this.$hidden.length === 0) {
  11989. this.$hidden = $('<input type="hidden" />')
  11990. this.$element.prepend(this.$hidden)
  11991. }
  11992. this.$preview = this.$element.find('.fileupload-preview')
  11993. var height = this.$preview.css('height')
  11994. if (this.$preview.css('display') != 'inline' && height != '0px' && height != 'none') this.$preview.css('line-height', height)
  11995. this.original = {
  11996. 'exists': this.$element.hasClass('fileupload-exists'),
  11997. 'preview': this.$preview.html(),
  11998. 'hiddenVal': this.$hidden.val()
  11999. }
  12000. this.$remove = this.$element.find('[data-dismiss="fileupload"]')
  12001. this.$element.find('[data-trigger="fileupload"]').on('click.fileupload', $.proxy(this.trigger, this))
  12002. this.listen()
  12003. }
  12004. Fileupload.prototype = {
  12005. listen: function() {
  12006. this.$input.on('change.fileupload', $.proxy(this.change, this))
  12007. $(this.$input[0].form).on('reset.fileupload', $.proxy(this.reset, this))
  12008. if (this.$remove) this.$remove.on('click.fileupload', $.proxy(this.clear, this))
  12009. },
  12010. change: function(e, invoked) {
  12011. if (invoked === 'clear') return
  12012. var file = e.target.files !== undefined ? e.target.files[0] : (e.target.value ? { name: e.target.value.replace(/^.+\\/, '') } : null)
  12013. if (!file) {
  12014. this.clear()
  12015. return
  12016. }
  12017. this.$hidden.val('')
  12018. this.$hidden.attr('name', '')
  12019. this.$input.attr('name', this.name)
  12020. if (this.type === "image" && this.$preview.length > 0 && (typeof file.type !== "undefined" ? file.type.match('image.*') : file.name.match(/\.(gif|png|jpe?g)$/i)) && typeof FileReader !== "undefined") {
  12021. var reader = new FileReader()
  12022. var preview = this.$preview
  12023. var element = this.$element
  12024. reader.onload = function(e) {
  12025. preview.html('<img src="' + e.target.result + '" ' + (preview.css('max-height') != 'none' ? 'style="max-height: ' + preview.css('max-height') + ';"' : '') + ' />')
  12026. element.addClass('fileupload-exists').removeClass('fileupload-new')
  12027. }
  12028. reader.readAsDataURL(file)
  12029. } else {
  12030. this.$preview.text(file.name)
  12031. this.$element.addClass('fileupload-exists').removeClass('fileupload-new')
  12032. }
  12033. },
  12034. clear: function(e) {
  12035. this.$hidden.val('')
  12036. this.$hidden.attr('name', this.name)
  12037. this.$input.attr('name', '')
  12038. //ie8+ doesn't support changing the value of input with type=file so clone instead
  12039. if (navigator.userAgent.match(/msie/i)){
  12040. var inputClone = this.$input.clone(true);
  12041. this.$input.after(inputClone);
  12042. this.$input.remove();
  12043. this.$input = inputClone;
  12044. }else{
  12045. this.$input.val('')
  12046. }
  12047. this.$preview.html('')
  12048. this.$element.addClass('fileupload-new').removeClass('fileupload-exists')
  12049. if (e) {
  12050. this.$input.trigger('change', [ 'clear' ])
  12051. e.preventDefault()
  12052. }
  12053. },
  12054. reset: function(e) {
  12055. this.clear()
  12056. this.$hidden.val(this.original.hiddenVal)
  12057. this.$preview.html(this.original.preview)
  12058. if (this.original.exists) this.$element.addClass('fileupload-exists').removeClass('fileupload-new')
  12059. else this.$element.addClass('fileupload-new').removeClass('fileupload-exists')
  12060. },
  12061. trigger: function(e) {
  12062. this.$input.trigger('click')
  12063. e.preventDefault()
  12064. }
  12065. }
  12066. /* FILEUPLOAD PLUGIN DEFINITION
  12067. * =========================== */
  12068. $.fn.fileupload = function (options) {
  12069. return this.each(function () {
  12070. var $this = $(this)
  12071. , data = $this.data('fileupload')
  12072. if (!data) $this.data('fileupload', (data = new Fileupload(this, options)))
  12073. if (typeof options == 'string') data[options]()
  12074. })
  12075. }
  12076. $.fn.fileupload.Constructor = Fileupload
  12077. /* FILEUPLOAD DATA-API
  12078. * ================== */
  12079. $(document).on('click.fileupload.data-api', '[data-provides="fileupload"]', function (e) {
  12080. var $this = $(this)
  12081. if ($this.data('fileupload')) return
  12082. $this.fileupload($this.data())
  12083. var $target = $(e.target).closest('[data-dismiss="fileupload"],[data-trigger="fileupload"]');
  12084. if ($target.length > 0) {
  12085. $target.trigger('click.fileupload')
  12086. e.preventDefault()
  12087. }
  12088. })
  12089. }(window.jQuery);
  12090. /**
  12091. * summernote.js
  12092. * (c) 2013~ Alan Hong
  12093. * summernote may be freely distributed under the MIT license./
  12094. */
  12095. (function($) { "use strict";
  12096. /**
  12097. * object which check platform/agent
  12098. */
  12099. var agent = {
  12100. bMac: navigator.appVersion.indexOf('Mac') > -1,
  12101. bMSIE: navigator.userAgent.indexOf('MSIE') > -1,
  12102. bFF: navigator.userAgent.indexOf('Firefox') > -1
  12103. };
  12104. /**
  12105. * func utils (for high-order func's arg)
  12106. */
  12107. var func = function() {
  12108. var eq = function(elA) { return function(elB) { return elA === elB; }; };
  12109. var eq2 = function(elA, elB) { return elA === elB; };
  12110. var fail = function() { return false; };
  12111. var not = function(f) { return function() { return !f.apply(f, arguments); }; };
  12112. var self = function(a) { return a; };
  12113. return { eq: eq, eq2: eq2, fail: fail, not: not, self: self };
  12114. }();
  12115. /**
  12116. * list utils
  12117. */
  12118. var list = function() {
  12119. var head = function(array) { return array[0]; };
  12120. var last = function(array) { return array[array.length - 1]; };
  12121. var initial = function(array) { return array.slice(0, array.length - 1); };
  12122. var tail = function(array) { return array.slice(1); };
  12123. /**
  12124. * get sum from a list
  12125. * @param {array} array - array
  12126. * @param {function} fn - iterator
  12127. */
  12128. var sum = function(array, fn) {
  12129. fn = fn || func.self;
  12130. return array.reduce(function(memo, v) {
  12131. return memo + fn(v);
  12132. }, 0);
  12133. };
  12134. /**
  12135. * returns a copy of the collection with array type.
  12136. * @param {collection} collection - collection eg) node.childNodes, ...
  12137. */
  12138. var from = function(collection) {
  12139. var result = [], idx = -1, length = collection.length;
  12140. while (++idx < length) {
  12141. result[idx] = collection[idx];
  12142. }
  12143. return result;
  12144. };
  12145. /**
  12146. * cluster item by second function
  12147. * @param {array} array - array
  12148. * @param {function} fn - predicate function for cluster rule
  12149. */
  12150. var clusterBy = function(array, fn) {
  12151. if (array.length === 0) { return []; }
  12152. var aTail = tail(array);
  12153. return aTail.reduce(function (memo, v) {
  12154. var aLast = last(memo);
  12155. if (fn(last(aLast), v)) {
  12156. aLast[aLast.length] = v;
  12157. } else {
  12158. memo[memo.length] = [v];
  12159. }
  12160. return memo;
  12161. }, [[head(array)]]);
  12162. };
  12163. /**
  12164. * returns a copy of the array with all falsy values removed
  12165. * @param {array} array - array
  12166. * @param {function} fn - predicate function for cluster rule
  12167. */
  12168. var compact = function(array) {
  12169. var aResult = [];
  12170. for (var idx = 0, sz = array.length; idx < sz; idx ++) {
  12171. if (array[idx]) { aResult.push(array[idx]); }
  12172. }
  12173. return aResult;
  12174. };
  12175. return { head: head, last: last, initial: initial, tail: tail,
  12176. sum: sum, from: from, compact: compact, clusterBy: clusterBy };
  12177. }();
  12178. /**
  12179. * aysnc functions which returns deferred object
  12180. */
  12181. var async = function() {
  12182. /**
  12183. * readFile
  12184. * @param {file} file - file object
  12185. */
  12186. var readFile = function(file) {
  12187. return $.Deferred(function(deferred) {
  12188. var reader = new FileReader();
  12189. reader.onload = function(e) { deferred.resolve(e.target.result); }
  12190. reader.onerror = function(e) { deferred.reject(this); }
  12191. reader.readAsDataURL(file);
  12192. }).promise();
  12193. };
  12194. /**
  12195. * loadImage
  12196. * @param {string} sUrl
  12197. */
  12198. var loadImage = function(sUrl) {
  12199. return $.Deferred(function(deferred) {
  12200.   var image = new Image();
  12201.   image.onload = loaded;
  12202.   image.onerror = errored; // URL returns 404, etc
  12203.   image.onabort = errored; // IE may call this if user clicks "Stop"
  12204.   image.src = sUrl;
  12205.    
  12206.   function loaded() {
  12207.     unbindEvents(); deferred.resolve(image);
  12208.   }
  12209.   function errored() {
  12210.     unbindEvents(); deferred.reject(image);
  12211.   }
  12212.   function unbindEvents() {
  12213.     image.onload = null;
  12214.     image.onerror = null;
  12215.     image.onabort = null;
  12216.   }
  12217. }).promise();
  12218. };
  12219. return { readFile: readFile, loadImage: loadImage };
  12220. }();
  12221. /**
  12222. * dom utils
  12223. */
  12224. var dom = function() {
  12225. /**
  12226. * returns predicate which judge whether nodeName is same
  12227. */
  12228. var makePredByNodeName = function(sNodeName) {
  12229. // nodeName of element is always uppercase.
  12230. return function(node) {
  12231. return node && node.nodeName === sNodeName;
  12232. };
  12233. };
  12234. var isPara = function(node) {
  12235. return node && /^P|^LI|^H[1-7]/.test(node.nodeName);
  12236. };
  12237. var isList = function(node) {
  12238. return node && /^UL|^OL/.test(node.nodeName);
  12239. };
  12240. var isEditable = function(node) {
  12241. return node && $(node).hasClass('note-editable');
  12242. };
  12243. var isControlSizing = function(node) {
  12244. return node && $(node).hasClass('note-control-sizing');
  12245. };
  12246. /**
  12247. * find nearest ancestor predicate hit
  12248. * @param {element} node
  12249. * @param {function} pred - predicate function
  12250. */
  12251. var ancestor = function(node, pred) {
  12252. while (node) {
  12253. if (pred(node)) { return node; }
  12254. node = node.parentNode;
  12255. }
  12256. return null;
  12257. };
  12258. /**
  12259. * returns new array of ancestor nodes (until predicate hit).
  12260. * @param {element} node
  12261. * @param {function} [optional] pred - predicate function
  12262. */
  12263. var listAncestor = function(node, pred) {
  12264. pred = pred || func.fail;
  12265. var aAncestor = [];
  12266. ancestor(node, function(el) {
  12267. aAncestor.push(el);
  12268. return pred(el);
  12269. });
  12270. return aAncestor;
  12271. };
  12272. /**
  12273. * returns common ancestor node between two nodes.
  12274. * @param {element} nodeA
  12275. * @param {element} nodeB
  12276. */
  12277. var commonAncestor = function(nodeA, nodeB) {
  12278. var aAncestor = listAncestor(nodeA);
  12279. for (var n = nodeB; n; n = n.parentNode) {
  12280. if ($.inArray(n, aAncestor) > -1) { return n; }
  12281. }
  12282. return null; // difference document area
  12283. };
  12284. /**
  12285. * listing all Nodes between two nodes.
  12286. * FIXME: nodeA and nodeB must be sorted, use comparePoints later.
  12287. * @param {element} nodeA
  12288. * @param {element} nodeB
  12289. */
  12290. var listBetween = function(nodeA, nodeB) {
  12291. var aNode = [];
  12292. var bStart = false, bEnd = false;
  12293. var fnWalk = function(node) {
  12294. if (!node) { return; } // traverse fisnish
  12295. if (node === nodeA) { bStart = true; } // start point
  12296. if (bStart && !bEnd) { aNode.push(node); } // between
  12297. if (node === nodeB) { bEnd = true; return; } // end point
  12298. for (var idx = 0, sz = node.childNodes.length; idx < sz; idx++) {
  12299. fnWalk(node.childNodes[idx]);
  12300. }
  12301. };
  12302. fnWalk(commonAncestor(nodeA, nodeB)); // DFS with commonAcestor.
  12303. return aNode;
  12304. };
  12305. /**
  12306. * listing all prevSiblings (until predicate hit).
  12307. * @param {element} node
  12308. * @param {function} [optional] pred - predicate function
  12309. */
  12310. var listPrev = function(node, pred) {
  12311. pred = pred || func.fail;
  12312. var aNext = [];
  12313. while (node) {
  12314. aNext.push(node);
  12315. if (pred(node)) { break; }
  12316. node = node.previousSibling;
  12317. }
  12318. return aNext;
  12319. };
  12320. /**
  12321. * listing nextSiblings (until predicate hit).
  12322. * @param {element} node
  12323. * @param {function} pred [optional] - predicate function
  12324. */
  12325. var listNext = function(node, pred) {
  12326. pred = pred || func.fail;
  12327. var aNext = [];
  12328. while (node) {
  12329. aNext.push(node);
  12330. if (pred(node)) { break; }
  12331. node = node.nextSibling;
  12332. }
  12333. return aNext;
  12334. };
  12335. /**
  12336. * insert node after preceding
  12337. * @param {element} node
  12338. * @param {element} preceding - predicate function
  12339. */
  12340. var insertAfter = function(node, preceding) {
  12341. var next = preceding.nextSibling, parent = preceding.parentNode;
  12342. if (next) {
  12343. parent.insertBefore(node, next);
  12344. } else {
  12345. parent.appendChild(node);
  12346. }
  12347. return node;
  12348. };
  12349. /**
  12350. * append children
  12351. * @param {element} node
  12352. * @param {collection} aChild
  12353. */
  12354. var appends = function(node, aChild) {
  12355. $.each(aChild, function(idx, child) {
  12356. node.appendChild(child);
  12357. });
  12358. return node;
  12359. };
  12360. var isText = makePredByNodeName('#text');
  12361. /**
  12362. * returns #text's text size or element's childNodes size
  12363. * @param {element} node
  12364. */
  12365. var length = function(node) {
  12366. if (isText(node)) { return node.nodeValue.length; }
  12367. return node.childNodes.length;
  12368. };
  12369. /**
  12370. * returns offset from parent.
  12371. * @param {element} node
  12372. */
  12373. var position = function(node) {
  12374. var offset = 0;
  12375. while (node = node.previousSibling) { offset += 1; }
  12376. return offset;
  12377. };
  12378. /**
  12379. * return offsetPath(array of offset) from ancestor
  12380. * @param {element} ancestor - ancestor node
  12381. * @param {element} node
  12382. */
  12383. var makeOffsetPath = function(ancestor, node) {
  12384. var aAncestor = list.initial(listAncestor(node, func.eq(ancestor)));
  12385. return $.map(aAncestor, position).reverse();
  12386. };
  12387. /**
  12388. * return element from offsetPath(array of offset)
  12389. * @param {element} ancestor - ancestor node
  12390. * @param {array} aOffset - offsetPath
  12391. */
  12392. var fromOffsetPath = function(ancestor, aOffset) {
  12393. var current = ancestor;
  12394. for (var i = 0, sz = aOffset.length; i < sz; i++) {
  12395. current = current.childNodes[aOffset[i]];
  12396. }
  12397. return current;
  12398. };
  12399. /**
  12400. * split element or #text
  12401. * @param {element} node
  12402. * @param {number} offset
  12403. */
  12404. var splitData = function(node, offset) {
  12405. if (offset === 0) { return node; }
  12406. if (offset >= length(node)) { return node.nextSibling; }
  12407. // splitText
  12408. if (isText(node)) { return node.splitText(offset); }
  12409. // splitElement
  12410. var child = node.childNodes[offset];
  12411. node = insertAfter(node.cloneNode(false), node);
  12412. return appends(node, listNext(child));
  12413. };
  12414. /**
  12415. * split dom tree by boundaryPoint(pivot and offset)
  12416. * @param {element} root
  12417. * @param {element} pivot - this will be boundaryPoint's node
  12418. * @param {number} offset - this will be boundaryPoint's offset
  12419. */
  12420. var split = function(root, pivot, offset) {
  12421. var aAncestor = listAncestor(pivot, func.eq(root));
  12422. if (aAncestor.length === 1) { return splitData(pivot, offset); }
  12423. return aAncestor.reduce(function(node, parent) {
  12424. var clone = parent.cloneNode(false);
  12425. insertAfter(clone, parent);
  12426. if (node === pivot) {
  12427. node = splitData(node, offset);
  12428. }
  12429. appends(clone, listNext(node));
  12430. return clone;
  12431. });
  12432. };
  12433. /**
  12434. * remove node, (bRemoveChild: remove child or not)
  12435. * @param {element} node
  12436. * @param {boolean} bRemoveChild
  12437. */
  12438. var remove = function(node, bRemoveChild) {
  12439. if (!node || !node.parentNode) { return; }
  12440. if (node.removeNode) { return node.removeNode(bRemoveChild); }
  12441. var elParent = node.parentNode;
  12442. if (!bRemoveChild) {
  12443. var aNode = [];
  12444. for (var i = 0, sz = node.childNodes.length; i < sz; i++) {
  12445. aNode.push(node.childNodes[i]);
  12446. }
  12447. for (var i = 0, sz = aNode.length; i < sz; i++) {
  12448. elParent.insertBefore(aNode[i], node);
  12449. }
  12450. }
  12451. elParent.removeChild(node);
  12452. };
  12453. var unescape = function(str) {
  12454. return $("<div/>").html(str).text();
  12455. };
  12456. var html = function($node) {
  12457. return dom.isTextarea($node[0]) ? unescape($node.val()) : $node.html();
  12458. };
  12459. return {
  12460. isText: isText,
  12461. isPara: isPara, isList: isList,
  12462. isEditable: isEditable, isControlSizing: isControlSizing,
  12463. isAnchor: makePredByNodeName('A'),
  12464. isDiv: makePredByNodeName('DIV'), isSpan: makePredByNodeName('SPAN'),
  12465. isB: makePredByNodeName('B'), isU: makePredByNodeName('U'),
  12466. isS: makePredByNodeName('S'), isI: makePredByNodeName('I'),
  12467. isImg: makePredByNodeName('IMG'), isTextarea: makePredByNodeName('TEXTAREA'),
  12468. ancestor: ancestor, listAncestor: listAncestor,
  12469. listNext: listNext, listPrev: listPrev,
  12470. commonAncestor: commonAncestor, listBetween: listBetween,
  12471. insertAfter: insertAfter, position: position,
  12472. makeOffsetPath: makeOffsetPath, fromOffsetPath: fromOffsetPath,
  12473. split: split, remove: remove, html: html
  12474. };
  12475. }();
  12476. /**
  12477. * range module
  12478. */
  12479. var range = function() {
  12480. var bW3CRangeSupport = !!document.createRange;
  12481. // return boundaryPoint from TextRange, inspired by Andy Na's HuskyRange.js
  12482. var textRange2bp = function(textRange, bStart) {
  12483. var elCont = textRange.parentElement(), nOffset;
  12484. var tester = document.body.createTextRange(), elPrevCont;
  12485. var aChild = list.from(elCont.childNodes);
  12486. for (nOffset = 0; nOffset < aChild.length; nOffset++) {
  12487. if (dom.isText(aChild[nOffset])) { continue; }
  12488. tester.moveToElementText(aChild[nOffset]);
  12489. if (tester.compareEndPoints('StartToStart', textRange) >= 0) { break; }
  12490. elPrevCont = aChild[nOffset];
  12491. }
  12492. if (nOffset !== 0 && dom.isText(aChild[nOffset - 1])) {
  12493. var textRangeStart = document.body.createTextRange(), elCurText = null;
  12494. textRangeStart.moveToElementText(elPrevCont || elCont);
  12495. textRangeStart.collapse(!elPrevCont);
  12496. elCurText = elPrevCont ? elPrevCont.nextSibling : elCont.firstChild;
  12497. var pointTester = textRange.duplicate();
  12498. pointTester.setEndPoint('StartToStart', textRangeStart);
  12499. var nTextCount = pointTester.text.replace(/[\r\n]/g, '').length;
  12500. while (nTextCount > elCurText.nodeValue.length && elCurText.nextSibling) {
  12501. nTextCount -= elCurText.nodeValue.length;
  12502. elCurText = elCurText.nextSibling;
  12503. }
  12504. var sDummy = elCurText.nodeValue; //enforce IE to re-reference elCurText
  12505. if (bStart && elCurText.nextSibling && dom.isText(elCurText.nextSibling) &&
  12506. nTextCount == elCurText.nodeValue.length) {
  12507. nTextCount -= elCurText.nodeValue.length;
  12508. elCurText = elCurText.nextSibling;
  12509. }
  12510. elCont = elCurText;
  12511. nOffset = nTextCount;
  12512. }
  12513. return {cont: elCont, offset: nOffset};
  12514. };
  12515. // return TextRange from boundary point (inspired by google closure-library)
  12516. var bp2textRange = function(bp) {
  12517. var textRangeInfo = function(elCont, nOffset) {
  12518. var elNode, bCollapseToStart;
  12519. if (dom.isText(elCont)) {
  12520. var aPrevText = dom.listPrev(elCont, func.not(dom.isText));
  12521. var elPrevCont = list.last(aPrevText).previousSibling;
  12522. elNode = elPrevCont || elCont.parentNode;
  12523. nOffset += list.sum(list.tail(aPrevText), dom.length);
  12524. bCollapseToStart = !elPrevCont;
  12525. } else {
  12526. elNode = elCont.childNodes[nOffset] || elCont;
  12527. if (dom.isText(elNode)) {
  12528. return textRangeInfo(elNode, nOffset);
  12529. }
  12530. nOffset = 0;
  12531. bCollapseToStart = false;
  12532. }
  12533. return {cont: elNode, collapseToStart: bCollapseToStart, offset: nOffset};
  12534. };
  12535. var textRange = document.body.createTextRange();
  12536. var info = textRangeInfo(bp.cont, bp.offset);
  12537. textRange.moveToElementText(info.cont);
  12538. textRange.collapse(info.collapseToStart);
  12539. textRange.moveStart('character', info.offset);
  12540. return textRange;
  12541. };
  12542. // {startContainer, startOffset, endContainer, endOffset}
  12543. var WrappedRange = function(sc, so, ec, eo) {
  12544. this.sc = sc; this.so = so;
  12545. this.ec = ec; this.eo = eo;
  12546. // nativeRange: get nativeRange from sc, so, ec, eo
  12547. var nativeRange = function() {
  12548. if (bW3CRangeSupport) {
  12549. var w3cRange = document.createRange();
  12550. w3cRange.setStart(sc, so);
  12551. w3cRange.setEnd(ec, eo);
  12552. return w3cRange;
  12553. } else {
  12554. var textRange = bp2textRange({cont:sc, offset:so});
  12555. textRange.setEndPoint('EndToEnd', bp2textRange({cont:ec, offset:eo}));
  12556. return textRange;
  12557. }
  12558. };
  12559. // select: update visible range
  12560. this.select = function() {
  12561. var nativeRng = nativeRange();
  12562. if (bW3CRangeSupport) {
  12563. var selection = document.getSelection();
  12564. if (selection.rangeCount > 0) { selection.removeAllRanges(); }
  12565. selection.addRange(nativeRng);
  12566. } else {
  12567. nativeRng.select();
  12568. }
  12569. };
  12570. // listPara: listing paragraphs on range
  12571. this.listPara = function() {
  12572. var aNode = dom.listBetween(sc, ec);
  12573. var aPara = list.compact($.map(aNode, function(node) {
  12574. return dom.ancestor(node, dom.isPara);
  12575. }));
  12576. return $.map(list.clusterBy(aPara, func.eq2), list.head);
  12577. };
  12578. // makeIsOn: return isOn(pred) function
  12579. var makeIsOn = function(pred) {
  12580. return function() {
  12581. var elAncestor = dom.ancestor(sc, pred);
  12582. return elAncestor && (elAncestor === dom.ancestor(ec, pred));
  12583. };
  12584. };
  12585. // isOnEditable: judge whether range is on editable or not
  12586. this.isOnEditable = makeIsOn(dom.isEditable);
  12587. // isOnList: judge whether range is on list node or not
  12588. this.isOnList = makeIsOn(dom.isList);
  12589. // isOnAnchor: judge whether range is on anchor node or not
  12590. this.isOnAnchor = makeIsOn(dom.isAnchor);
  12591. // isCollapsed: judge whether range was collapsed
  12592. this.isCollapsed = function() { return sc === ec && so === eo; };
  12593. // insertNode
  12594. this.insertNode = function(node) {
  12595. var nativeRng = nativeRange();
  12596. if (bW3CRangeSupport) {
  12597. nativeRng.insertNode(node);
  12598. } else {
  12599. nativeRng.pasteHTML(node.outerHTML); // NOTE: missing node reference.
  12600. }
  12601. };
  12602. this.toString = function() {
  12603. var nativeRng = nativeRange();
  12604. return bW3CRangeSupport ? nativeRng.toString() : nativeRng.text;
  12605. };
  12606. //bookmark: offsetPath bookmark
  12607. this.bookmark = function(elEditable) {
  12608. return {
  12609. s: { path: dom.makeOffsetPath(elEditable, sc), offset: so },
  12610. e: { path: dom.makeOffsetPath(elEditable, ec), offset: eo }
  12611. };
  12612. };
  12613. };
  12614. return { // Range Object
  12615. // create Range Object From arguments or Browser Selection
  12616. create : function(sc, so, ec, eo) {
  12617. if (arguments.length === 0) { // from Browser Selection
  12618. if (bW3CRangeSupport) { // webkit, firefox
  12619. var selection = document.getSelection();
  12620. if (selection.rangeCount === 0) { return null; }
  12621. var nativeRng = selection.getRangeAt(0);
  12622. sc = nativeRng.startContainer, so = nativeRng.startOffset,
  12623. ec = nativeRng.endContainer, eo = nativeRng.endOffset;
  12624. } else { // IE8: TextRange
  12625. var textRange = document.selection.createRange();
  12626. var textRangeEnd = textRange.duplicate(); textRangeEnd.collapse(false);
  12627. var textRangeStart = textRange; textRangeStart.collapse(true);
  12628. var bpStart = textRange2bp(textRangeStart, true),
  12629. bpEnd = textRange2bp(textRangeEnd, false);
  12630. sc = bpStart.cont, so = bpStart.offset;
  12631. ec = bpEnd.cont, eo = bpEnd.offset;
  12632. }
  12633. } else if (arguments.length === 2) { //collapsed
  12634. ec = sc; eo = so;
  12635. }
  12636. return new WrappedRange(sc, so, ec, eo);
  12637. },
  12638. // createFromBookmark
  12639. createFromBookmark : function(elEditable, bookmark) {
  12640. var sc = dom.fromOffsetPath(elEditable, bookmark.s.path);
  12641. var so = bookmark.s.offset;
  12642. var ec = dom.fromOffsetPath(elEditable, bookmark.e.path);
  12643. var eo = bookmark.e.offset;
  12644. return new WrappedRange(sc, so, ec, eo);
  12645. }
  12646. };
  12647. }();
  12648. /**
  12649. * Style
  12650. */
  12651. var Style = function() {
  12652. // para level style
  12653. this.stylePara = function(rng, oStyle) {
  12654. var aPara = rng.listPara();
  12655. $.each(aPara, function(idx, elPara) {
  12656. $.each(oStyle, function(sKey, sValue) {
  12657. elPara.style[sKey] = sValue;
  12658. });
  12659. });
  12660. };
  12661. // get current style, elTarget: target element on event.
  12662. this.current = function(rng, elTarget) {
  12663. var welCont = $(dom.isText(rng.sc) ? rng.sc.parentNode : rng.sc);
  12664. var oStyle = welCont.css(['font-size', 'text-align',
  12665. 'list-style-type', 'line-height']) || {};
  12666. oStyle['font-size'] = parseInt(oStyle['font-size']);
  12667. // document.queryCommandState for toggle state
  12668. oStyle['font-bold'] = document.queryCommandState('bold') ? 'bold' : 'normal';
  12669. oStyle['font-italic'] = document.queryCommandState('italic') ? 'italic' : 'normal';
  12670. oStyle['font-underline'] = document.queryCommandState('underline') ? 'underline' : 'normal';
  12671. // list-style-type to list-style(unordered, ordered)
  12672. if (!rng.isOnList()) {
  12673. oStyle['list-style'] = 'none';
  12674. } else {
  12675. var aOrderedType = ['circle', 'disc', 'disc-leading-zero', 'square'];
  12676. var bUnordered = $.inArray(oStyle['list-style-type'], aOrderedType) > -1;
  12677. oStyle['list-style'] = bUnordered ? 'unordered' : 'ordered';
  12678. }
  12679. var elPara = dom.ancestor(rng.sc, dom.isPara);
  12680. if (elPara && elPara.style['line-height']) {
  12681. oStyle['line-height'] = elPara.style.lineHeight;
  12682. } else {
  12683. var lineHeight = parseInt(oStyle['line-height']) / parseInt(oStyle['font-size']);
  12684. oStyle['line-height'] = lineHeight.toFixed(1);
  12685. }
  12686. oStyle.image = dom.isImg(elTarget) && elTarget;
  12687. oStyle.anchor = rng.isOnAnchor() && dom.ancestor(rng.sc, dom.isAnchor);
  12688. oStyle.aAncestor = dom.listAncestor(rng.sc, dom.isEditable);
  12689. return oStyle;
  12690. };
  12691. };
  12692. /**
  12693. * History
  12694. */
  12695. var History = function() {
  12696. var aUndo = [], aRedo = [];
  12697. var makeSnap = function(welEditable) {
  12698. var elEditable = welEditable[0], rng = range.create();
  12699. return {
  12700. contents: welEditable.html(), bookmark: rng.bookmark(elEditable),
  12701. scrollTop: welEditable.scrollTop()
  12702. };
  12703. };
  12704. var applySnap = function(welEditable, oSnap) {
  12705. welEditable.html(oSnap.contents).scrollTop(oSnap.scrollTop);
  12706. range.createFromBookmark(welEditable[0], oSnap.bookmark).select();
  12707. };
  12708. this.undo = function(welEditable) {
  12709. var oSnap = makeSnap(welEditable);
  12710. if (aUndo.length === 0) { return; }
  12711. applySnap(welEditable, aUndo.pop()), aRedo.push(oSnap);
  12712. };
  12713. this.redo = function(welEditable) {
  12714. var oSnap = makeSnap(welEditable);
  12715. if (aRedo.length === 0) { return; }
  12716. applySnap(welEditable, aRedo.pop()), aUndo.push(oSnap);
  12717. };
  12718. this.recordUndo = function(welEditable) {
  12719. aRedo = [], aUndo.push(makeSnap(welEditable));
  12720. };
  12721. };
  12722. /**
  12723. * Editor
  12724. */
  12725. var Editor = function() {
  12726. // save current range
  12727. this.saveRange = function(welEditable) {
  12728. welEditable.data('range', range.create());
  12729. }
  12730. // restore lately range
  12731. this.restoreRange = function(welEditable) {
  12732. var rng = welEditable.data('range');
  12733. if (rng) { rng.select(); }
  12734. }
  12735. //currentStyle
  12736. var style = new Style();
  12737. this.currentStyle = function(elTarget) {
  12738. var rng = range.create();
  12739. return rng.isOnEditable() && style.current(rng, elTarget);
  12740. };
  12741. this.tab = function(welEditable) {
  12742. recordUndo(welEditable);
  12743. var rng = range.create();
  12744. var sNbsp = new Array(welEditable.data('tabsize') + 1).join('&nbsp;');
  12745. rng.insertNode($('<span id="noteTab">' + sNbsp + '</span>')[0]);
  12746. var welTab = $('#noteTab').removeAttr('id');
  12747. rng = range.create(welTab[0], 1);
  12748. rng.select();
  12749. dom.remove(welTab[0]);
  12750. };
  12751. // undo
  12752. this.undo = function(welEditable) {
  12753. welEditable.data('NoteHistory').undo(welEditable);
  12754. };
  12755. // redo
  12756. this.redo = function(welEditable) {
  12757. welEditable.data('NoteHistory').redo(welEditable);
  12758. };
  12759. // recordUndo
  12760. var recordUndo = this.recordUndo = function(welEditable) {
  12761. welEditable.data('NoteHistory').recordUndo(welEditable);
  12762. };
  12763. // native commands(with execCommand)
  12764. var aCmd = ['bold', 'italic', 'underline', 'strikethrough',
  12765. 'justifyLeft', 'justifyCenter', 'justifyRight', 'justifyFull',
  12766. 'insertOrderedList', 'insertUnorderedList',
  12767. 'indent', 'outdent', 'formatBlock', 'removeFormat',
  12768. 'backColor', 'foreColor', 'insertHorizontalRule'];
  12769. for (var idx = 0, len=aCmd.length; idx < len; idx ++) {
  12770. this[aCmd[idx]] = function(sCmd) {
  12771. return function(welEditable, sValue) {
  12772. recordUndo(welEditable);
  12773. document.execCommand(sCmd, false, sValue);
  12774. };
  12775. }(aCmd[idx]);
  12776. }
  12777. this.insertImage = function(welEditable, sUrl) {
  12778. async.loadImage(sUrl).done(function(image) {
  12779. recordUndo(welEditable);
  12780. var welImage = $('<img>').attr('src', sUrl);
  12781. welImage.css('width', Math.min(welEditable.width(), image.width));
  12782. range.create().insertNode(welImage[0]);
  12783. }).fail(function(image) {
  12784. var callbacks = welEditable.data('callbacks');
  12785. if (callbacks.onImageUploadError) {
  12786. callbacks.onImageUploadError();
  12787. }
  12788. });
  12789. };
  12790. this.formatBlock = function(welEditable, sValue) {
  12791. recordUndo(welEditable);
  12792. sValue = agent.bMSIE ? '<' + sValue + '>' : sValue;
  12793. document.execCommand('FormatBlock', false, sValue);
  12794. };
  12795. this.fontSize = function(welEditable, sValue) {
  12796. recordUndo(welEditable);
  12797. document.execCommand('fontSize', false, 3);
  12798. if (agent.bFF) {
  12799. // firefox: <font size="3"> to <span style='font-size={sValue}px;'>, buggy
  12800. welEditable.find('font[size=3]').removeAttr('size').css('font-size', sValue + 'px');
  12801. } else {
  12802. // chrome: <span style="font-size: medium"> to <span style='font-size={sValue}px;'>
  12803. welEditable.find('span').filter(function() {
  12804. return this.style.fontSize == 'medium';
  12805. }).css('font-size', sValue + 'px');
  12806. }
  12807. };
  12808. this.lineHeight = function(welEditable, sValue) {
  12809. recordUndo(welEditable);
  12810. style.stylePara(range.create(), {lineHeight: sValue});
  12811. };
  12812. this.unlink = function(welEditable) {
  12813. var rng = range.create();
  12814. if (rng.isOnAnchor()) {
  12815. recordUndo(welEditable);
  12816. var elAnchor = dom.ancestor(rng.sc, dom.isAnchor);
  12817. rng = range.create(elAnchor, 0, elAnchor, 1);
  12818. rng.select();
  12819. document.execCommand('unlink');
  12820. }
  12821. };
  12822. this.setLinkDialog = function(welEditable, fnShowDialog) {
  12823. var rng = range.create();
  12824. if (rng.isOnAnchor()) {
  12825. var elAnchor = dom.ancestor(rng.sc, dom.isAnchor);
  12826. rng = range.create(elAnchor, 0, elAnchor, 1);
  12827. }
  12828. fnShowDialog({
  12829. range: rng,
  12830. text: rng.toString(),
  12831. url: rng.isOnAnchor() ? dom.ancestor(rng.sc, dom.isAnchor).href : ''
  12832. }, function(sLinkUrl) {
  12833. rng.select(); recordUndo(welEditable);
  12834. var bProtocol = sLinkUrl.toLowerCase().indexOf('://') !== -1;
  12835. var sLinkUrlWithProtocol = bProtocol ? sLinkUrl : 'http://' + sLinkUrl;
  12836. //IE: createLink when range collapsed.
  12837. if (agent.bMSIE && rng.isCollapsed()) {
  12838. rng.insertNode($('<A id="linkAnchor">' + sLinkUrl + '</A>')[0]);
  12839. var welAnchor = $('#linkAnchor').removeAttr('id')
  12840. .attr('href', sLinkUrlWithProtocol);
  12841. rng = range.create(welAnchor[0], 0, welAnchor[0], 1);
  12842. rng.select();
  12843. } else {
  12844. document.execCommand('createlink', false, sLinkUrlWithProtocol);
  12845. }
  12846. });
  12847. };
  12848. this.color = function(welEditable, sObjColor) {
  12849. var oColor = JSON.parse(sObjColor);
  12850. var foreColor = oColor.foreColor, backColor = oColor.backColor;
  12851. recordUndo(welEditable);
  12852. if (foreColor) { document.execCommand('foreColor', false, foreColor); }
  12853. if (backColor) { document.execCommand('backColor', false, backColor); }
  12854. };
  12855. this.insertTable = function(welEditable, sDim) {
  12856. recordUndo(welEditable);
  12857. var aDim = sDim.split('x');
  12858. var nCol = aDim[0], nRow = aDim[1];
  12859. var aTD = [], sTD;
  12860. var sWhitespace = agent.bMSIE ? '&nbsp;' : '<br/>';
  12861. for (var idxCol = 0; idxCol < nCol; idxCol++) {
  12862. aTD.push('<td>' + sWhitespace + '</td>');
  12863. }
  12864. sTD = aTD.join('');
  12865. var aTR = [], sTR;
  12866. for (var idxRow = 0; idxRow < nRow; idxRow++) {
  12867. aTR.push('<tr>' + sTD + '</tr>');
  12868. }
  12869. sTR = aTR.join('');
  12870. var sTable = '<table class="table table-bordered">' + sTR + '</table>';
  12871. range.create().insertNode($(sTable)[0]);
  12872. };
  12873. this.floatMe = function(welEditable, sValue, elTarget) {
  12874. recordUndo(welEditable);
  12875. elTarget.style.cssFloat = sValue;
  12876. };
  12877. this.resize = function(welEditable, sValue, elTarget) {
  12878. recordUndo(welEditable);
  12879. elTarget.style.width = welEditable.width() * sValue + 'px';
  12880. elTarget.style.height = '';
  12881. };
  12882. this.resizeTo = function(pos, welTarget) {
  12883. var newRatio = pos.y / pos.x;
  12884. var ratio = welTarget.data('ratio');
  12885. welTarget.css({
  12886. width: ratio > newRatio ? pos.x : pos.y / ratio,
  12887. height: ratio > newRatio ? pos.x * ratio : pos.y
  12888. });
  12889. };
  12890. };
  12891. /**
  12892. * Toolbar
  12893. */
  12894. var Toolbar = function() {
  12895. this.update = function(welToolbar, oStyle) {
  12896. //handle selectbox for fontsize, lineHeight
  12897. var checkDropdownMenu = function(welBtn, nValue) {
  12898. welBtn.find('.dropdown-menu li a').each(function() {
  12899. var bChecked = $(this).attr('data-value') == nValue;
  12900. this.className = bChecked ? 'checked' : '';
  12901. });
  12902. };
  12903. var welFontsize = welToolbar.find('.note-fontsize');
  12904. welFontsize.find('.note-current-fontsize').html(oStyle['font-size']);
  12905. checkDropdownMenu(welFontsize, parseFloat(oStyle['font-size']));
  12906. var welLineHeight = welToolbar.find('.note-height');
  12907. checkDropdownMenu(welLineHeight, parseFloat(oStyle['line-height']));
  12908. //check button state
  12909. var btnState = function(sSelector, pred) {
  12910. var welBtn = welToolbar.find(sSelector);
  12911. welBtn[pred() ? 'addClass' : 'removeClass']('active');
  12912. };
  12913. btnState('button[data-event="bold"]', function() {
  12914. return oStyle['font-bold'] === 'bold';
  12915. });
  12916. btnState('button[data-event="italic"]', function() {
  12917. return oStyle['font-italic'] === 'italic';
  12918. });
  12919. btnState('button[data-event="underline"]', function() {
  12920. return oStyle['font-underline'] === 'underline';
  12921. });
  12922. btnState('button[data-event="justifyLeft"]', function() {
  12923. return oStyle['text-align'] === 'left' || oStyle['text-align'] === 'start';
  12924. });
  12925. btnState('button[data-event="justifyCenter"]', function() {
  12926. return oStyle['text-align'] === 'center';
  12927. });
  12928. btnState('button[data-event="justifyRight"]', function() {
  12929. return oStyle['text-align'] === 'right';
  12930. });
  12931. btnState('button[data-event="justifyFull"]', function() {
  12932. return oStyle['text-align'] === 'justify';
  12933. });
  12934. btnState('button[data-event="insertUnorderedList"]', function() {
  12935. return oStyle['list-style'] === 'unordered';
  12936. });
  12937. btnState('button[data-event="insertOrderedList"]', function() {
  12938. return oStyle['list-style'] === 'ordered';
  12939. });
  12940. };
  12941. this.updateRecentColor = function(elBtn, sEvent, sValue) {
  12942. var welColor = $(elBtn).closest('.note-color');
  12943. var welRecentColor = welColor.find('.note-recent-color');
  12944. var oColor = JSON.parse(welRecentColor.attr('data-value'));
  12945. oColor[sEvent] = sValue;
  12946. welRecentColor.attr('data-value', JSON.stringify(oColor));
  12947. var sKey = sEvent === 'backColor' ? 'background-color' : 'color';
  12948. welRecentColor.find('i').css(sKey, sValue);
  12949. };
  12950. this.updateFullscreen = function(welToolbar, bFullscreen) {
  12951. var welBtn = welToolbar.find('button[data-event="fullscreen"]');
  12952. welBtn[bFullscreen ? 'addClass' : 'removeClass']('active');
  12953. };
  12954. this.updateCodeview = function(welToolbar, bCodeview) {
  12955. var welBtn = welToolbar.find('button[data-event="codeview"]');
  12956. welBtn[bCodeview ? 'addClass' : 'removeClass']('active');
  12957. };
  12958. this.enable = function(welToolbar) {
  12959. welToolbar.find('button').not('button[data-event="codeview"]').removeClass('disabled');
  12960. };
  12961. this.disable = function(welToolbar) {
  12962. welToolbar.find('button').not('button[data-event="codeview"]').addClass('disabled');
  12963. };
  12964. };
  12965. /**
  12966. * Popover (http://getbootstrap.com/javascript/#popovers)
  12967. */
  12968. var Popover = function() {
  12969. var showPopover = function(welPopover, elPlaceholder) {
  12970. var welPlaceHolder = $(elPlaceholder);
  12971. var pos = welPlaceHolder.position(), height = welPlaceHolder.height();
  12972. welPopover.css({
  12973. display: 'block',
  12974. left: pos.left,
  12975. top: pos.top + height
  12976. });
  12977. };
  12978. this.update = function(welPopover, oStyle) {
  12979. var welLinkPopover = welPopover.find('.note-link-popover'),
  12980. welImagePopover = welPopover.find('.note-image-popover');
  12981. if (oStyle.anchor) {
  12982. var welAnchor = welLinkPopover.find('a');
  12983. welAnchor.attr('href', oStyle.anchor.href).html(oStyle.anchor.href);
  12984. showPopover(welLinkPopover, oStyle.anchor);
  12985. } else {
  12986. welLinkPopover.hide();
  12987. }
  12988. if (oStyle.image) {
  12989. showPopover(welImagePopover, oStyle.image);
  12990. } else {
  12991. welImagePopover.hide();
  12992. }
  12993. };
  12994. this.hide = function(welPopover) {
  12995. welPopover.children().hide();
  12996. };
  12997. };
  12998. /**
  12999. * Handle
  13000. */
  13001. var Handle = function() {
  13002. this.update = function(welHandle, oStyle) {
  13003. var welSelection = welHandle.find('.note-control-selection');
  13004. if (oStyle.image) {
  13005. var welImage = $(oStyle.image);
  13006. var pos = welImage.position();
  13007. var szImage = {w: welImage.width(), h: welImage.height()};
  13008. welSelection.css({
  13009. display: 'block',
  13010. left: pos.left, top: pos.top,
  13011. width: szImage.w, height: szImage.h
  13012. }).data('target', oStyle.image); // save current image element.
  13013. var sSizing = szImage.w + 'x' + szImage.h;
  13014. welSelection.find('.note-control-selection-info').text(sSizing);
  13015. } else {
  13016. welSelection.hide();
  13017. }
  13018. };
  13019. this.hide = function(welHandle) {
  13020. welHandle.children().hide();
  13021. };
  13022. };
  13023. /**
  13024. * Dialog
  13025. */
  13026. var Dialog = function() {
  13027. this.showImageDialog = function(welDialog, hDropImage, fnInsertImages, fnInsertImage) {
  13028. var welImageDialog = welDialog.find('.note-image-dialog');
  13029. var welDropzone = welDialog.find('.note-dropzone'),
  13030. welImageInput = welDialog.find('.note-image-input'),
  13031. welImageUrl = welDialog.find('.note-image-url'),
  13032. welImageBtn = welDialog.find('.note-image-btn');
  13033. welImageDialog.on('shown.bs.modal', function(e) {
  13034. welDropzone.on('dragenter dragover dragleave', false);
  13035. welDropzone.on('drop', function(e) {
  13036. hDropImage(e); welImageDialog.modal('hide');
  13037. });
  13038. welImageInput.on('change', function(event) {
  13039. fnInsertImages(this.files); $(this).val('');
  13040. welImageDialog.modal('hide');
  13041. });
  13042. welImageUrl.val('').keyup(function(event) {
  13043. if (welImageUrl.val()) {
  13044. welImageBtn.removeClass('disabled').attr('disabled', false);
  13045. } else {
  13046. welImageBtn.addClass('disabled').attr('disabled', true);
  13047. }
  13048. }).trigger('focus');
  13049. welImageBtn.click(function(event) {
  13050. welImageDialog.modal('hide');
  13051. fnInsertImage(welImageUrl.val());
  13052. event.preventDefault();
  13053. });
  13054. }).on('hidden.bs.modal', function(e) {
  13055. welDropzone.off('dragenter dragover dragleave drop');
  13056. welImageInput.off('change');
  13057. welImageDialog.off('shown.bs.modal hidden.bs.modal');
  13058. welImageUrl.off('keyup');
  13059. welImageBtn.off('click');
  13060. }).modal('show');
  13061. };
  13062. this.showLinkDialog = function(welDialog, linkInfo, callback) {
  13063. var welLinkDialog = welDialog.find('.note-link-dialog');
  13064. var welLinkText = welLinkDialog.find('.note-link-text'),
  13065. welLinkUrl = welLinkDialog.find('.note-link-url'),
  13066. welLinkBtn = welLinkDialog.find('.note-link-btn');
  13067. welLinkDialog.on('shown.bs.modal', function(e) {
  13068. welLinkText.html(linkInfo.text);
  13069. welLinkUrl.val(linkInfo.url).keyup(function(event) {
  13070. if (welLinkUrl.val()) {
  13071. welLinkBtn.removeClass('disabled').attr('disabled', false);
  13072. } else {
  13073. welLinkBtn.addClass('disabled').attr('disabled', true);
  13074. }
  13075. if (!linkInfo.text) { welLinkText.html(welLinkUrl.val()); }
  13076. }).trigger('focus');
  13077. welLinkBtn.click(function(event) {
  13078. welLinkDialog.modal('hide'); //hide and createLink (ie9+)
  13079. callback(welLinkUrl.val());
  13080. event.preventDefault();
  13081. });
  13082. }).on('hidden.bs.modal', function(e) {
  13083. welLinkUrl.off('keyup');
  13084. welLinkBtn.off('click');
  13085. welLinkDialog.off('shown.bs.modal hidden.bs.modal');
  13086. }).modal('show');
  13087. };
  13088. this.showHelpDialog = function(welDialog) {
  13089. welDialog.find('.note-help-dialog').modal('show');
  13090. };
  13091. };
  13092. /**
  13093. * EventHandler
  13094. *
  13095. * handle mouse & key event on note
  13096. */
  13097. var EventHandler = function() {
  13098. var editor = new Editor();
  13099. var toolbar = new Toolbar(), popover = new Popover();
  13100. var handle = new Handle(), dialog = new Dialog();
  13101. var key = { BACKSPACE: 8, TAB: 9, ENTER: 13, SPACE: 32,
  13102. NUM0: 48, NUM1: 49, NUM6: 54, NUM7: 55, NUM8: 56,
  13103. B: 66, E: 69, I: 73, J: 74, K: 75, L: 76, R: 82, S: 83, U: 85,
  13104. Y: 89, Z: 90, SLASH: 191,
  13105. LEFTBRACKET: 219, BACKSLACH: 220, RIGHTBRACKET: 221 };
  13106. // makeLayoutInfo from editor's descendant node.
  13107. var makeLayoutInfo = function(descendant) {
  13108. var welEditor = $(descendant).closest('.note-editor');
  13109. return {
  13110. editor: function() { return welEditor; },
  13111. toolbar: function() { return welEditor.find('.note-toolbar'); },
  13112. editable: function() { return welEditor.find('.note-editable'); },
  13113. codable: function() { return welEditor.find('.note-codable'); },
  13114. statusbar: function() { return welEditor.find('.note-statusbar'); },
  13115. popover: function() { return welEditor.find('.note-popover'); },
  13116. handle: function() { return welEditor.find('.note-handle'); },
  13117. dialog: function() { return welEditor.find('.note-dialog'); }
  13118. };
  13119. };
  13120. var hKeydown = function(event) {
  13121. var bCmd = agent.bMac ? event.metaKey : event.ctrlKey,
  13122. bShift = event.shiftKey, keyCode = event.keyCode;
  13123. // optimize
  13124. var bExecCmd = (bCmd || bShift || keyCode === key.TAB);
  13125. var oLayoutInfo = (bExecCmd) ? makeLayoutInfo(event.target) : null;
  13126. if (keyCode === key.TAB && oLayoutInfo.editable().data('tabsize')) {
  13127. editor.tab(oLayoutInfo.editable());
  13128. } else if (bCmd && ((bShift && keyCode === key.Z) || keyCode === key.Y)) {
  13129. editor.redo(oLayoutInfo.editable());
  13130. } else if (bCmd && keyCode === key.Z) {
  13131. editor.undo(oLayoutInfo.editable());
  13132. } else if (bCmd && keyCode === key.B) {
  13133. editor.bold(oLayoutInfo.editable());
  13134. } else if (bCmd && keyCode === key.I) {
  13135. editor.italic(oLayoutInfo.editable());
  13136. } else if (bCmd && keyCode === key.U) {
  13137. editor.underline(oLayoutInfo.editable());
  13138. } else if (bCmd && bShift && keyCode === key.S) {
  13139. editor.strikethrough(oLayoutInfo.editable());
  13140. } else if (bCmd && keyCode === key.BACKSLACH) {
  13141. editor.removeFormat(oLayoutInfo.editable());
  13142. } else if (bCmd && keyCode === key.K) {
  13143. oLayoutInfo.editable();
  13144. editor.setLinkDialog(oLayoutInfo.editable(), function(linkInfo, cb) {
  13145. dialog.showLinkDialog(oLayoutInfo.dialog(), linkInfo, cb);
  13146. });
  13147. } else if (bCmd && keyCode === key.SLASH) {
  13148. dialog.showHelpDialog(oLayoutInfo.dialog());
  13149. } else if (bCmd && bShift && keyCode === key.L) {
  13150. editor.justifyLeft(oLayoutInfo.editable());
  13151. } else if (bCmd && bShift && keyCode === key.E) {
  13152. editor.justifyCenter(oLayoutInfo.editable());
  13153. } else if (bCmd && bShift && keyCode === key.R) {
  13154. editor.justifyRight(oLayoutInfo.editable());
  13155. } else if (bCmd && bShift && keyCode === key.J) {
  13156. editor.justifyFull(oLayoutInfo.editable());
  13157. } else if (bCmd && bShift && keyCode === key.NUM7) {
  13158. editor.insertUnorderedList(oLayoutInfo.editable());
  13159. } else if (bCmd && bShift && keyCode === key.NUM8) {
  13160. editor.insertOrderedList(oLayoutInfo.editable());
  13161. } else if (bCmd && keyCode === key.LEFTBRACKET) {
  13162. editor.outdent(oLayoutInfo.editable());
  13163. } else if (bCmd && keyCode === key.RIGHTBRACKET) {
  13164. editor.indent(oLayoutInfo.editable());
  13165. } else if (bCmd && keyCode === key.NUM0) { // formatBlock Paragraph
  13166. editor.formatBlock(oLayoutInfo.editable(), 'P');
  13167. } else if (bCmd && (key.NUM1 <= keyCode && keyCode <= key.NUM6)) {
  13168. var sHeading = 'H' + String.fromCharCode(keyCode); // H1~H6
  13169. editor.formatBlock(oLayoutInfo.editable(), sHeading);
  13170. } else if (bCmd && keyCode === key.ENTER) {
  13171. editor.insertHorizontalRule(oLayoutInfo.editable());
  13172. } else {
  13173. if (keyCode === key.BACKSPACE || keyCode === key.ENTER ||
  13174. keyCode === key.SPACE) {
  13175. editor.recordUndo(makeLayoutInfo(event.target).editable());
  13176. }
  13177. return; // not matched
  13178. }
  13179. event.preventDefault(); //prevent default event for FF
  13180. };
  13181. var insertImages = function(welEditable, files) {
  13182. var callbacks = welEditable.data('callbacks');
  13183. editor.restoreRange(welEditable);
  13184. if (callbacks.onImageUpload) { // call custom handler
  13185. callbacks.onImageUpload(files, editor, welEditable);
  13186. } else {
  13187. $.each(files, function(idx, file) {
  13188. async.readFile(file).done(function(sURL) {
  13189. editor.insertImage(welEditable, sURL);
  13190. }).fail(function() {
  13191. if (callbacks.onImageUploadError) {
  13192. callbacks.onImageUploadError();
  13193. }
  13194. });
  13195. });
  13196. }
  13197. };
  13198. var hDropImage = function(event) {
  13199. var dataTransfer = event.originalEvent.dataTransfer;
  13200. if (dataTransfer && dataTransfer.files) {
  13201. var oLayoutInfo = makeLayoutInfo(event.currentTarget || event.target);
  13202. insertImages(oLayoutInfo.editable(), dataTransfer.files);
  13203. }
  13204. event.stopPropagation();
  13205. event.preventDefault();
  13206. };
  13207. var hMousedown = function(event) {
  13208. //preventDefault Selection for FF, IE8+
  13209. if (dom.isImg(event.target)) { event.preventDefault(); }
  13210. };
  13211. var hToolbarAndPopoverUpdate = function(event) {
  13212. var oLayoutInfo = makeLayoutInfo(event.currentTarget || event.target);
  13213. var oStyle = editor.currentStyle(event.target);
  13214. if (!oStyle) { return; }
  13215. toolbar.update(oLayoutInfo.toolbar(), oStyle);
  13216. popover.update(oLayoutInfo.popover(), oStyle);
  13217. handle.update(oLayoutInfo.handle(), oStyle);
  13218. };
  13219. var hScroll = function(event) {
  13220. var oLayoutInfo = makeLayoutInfo(event.currentTarget || event.target);
  13221. //hide popover and handle when scrolled
  13222. popover.hide(oLayoutInfo.popover());
  13223. handle.hide(oLayoutInfo.handle());
  13224. };
  13225. var hHandleMousedown = function(event) {
  13226. if (dom.isControlSizing(event.target)) {
  13227. var oLayoutInfo = makeLayoutInfo(event.target),
  13228. welHandle = oLayoutInfo.handle(), welPopover = oLayoutInfo.popover(),
  13229. welEditable = oLayoutInfo.editable(), welEditor = oLayoutInfo.editor();
  13230. var elTarget = welHandle.find('.note-control-selection').data('target'),
  13231. welTarget = $(elTarget);
  13232. var posStart = welTarget.offset(),
  13233. scrollTop = $(document).scrollTop(), posDistance;
  13234. welEditor.on('mousemove', function(event) {
  13235. posDistance = {x: event.clientX - posStart.left,
  13236. y: event.clientY - (posStart.top - scrollTop)};
  13237. editor.resizeTo(posDistance, welTarget);
  13238. handle.update(welHandle, {image: elTarget});
  13239. popover.update(welPopover, {image: elTarget});
  13240. }).on('mouseup', function() {
  13241. welEditor.off('mousemove').off('mouseup');
  13242. });
  13243. if (!welTarget.data('ratio')) { // original ratio.
  13244. welTarget.data('ratio', welTarget.height() / welTarget.width());
  13245. }
  13246. editor.recordUndo(welEditable);
  13247. event.stopPropagation(); event.preventDefault();
  13248. }
  13249. };
  13250. var hToolbarAndPopoverMousedown = function(event) {
  13251. // prevent default event when insertTable (FF, Webkit)
  13252. var welBtn = $(event.target).closest('[data-event]');
  13253. if (welBtn.length > 0) { event.preventDefault(); }
  13254. };
  13255. var hToolbarAndPopoverClick = function(event) {
  13256. var welBtn = $(event.target).closest('[data-event]');
  13257. if (welBtn.length > 0) {
  13258. var sEvent = welBtn.attr('data-event'),
  13259. sValue = welBtn.attr('data-value');
  13260. var oLayoutInfo = makeLayoutInfo(event.target);
  13261. var welDialog = oLayoutInfo.dialog(),
  13262. welEditable = oLayoutInfo.editable(),
  13263. welCodable = oLayoutInfo.codable();
  13264. // before command
  13265. var elTarget;
  13266. if ($.inArray(sEvent, ['resize', 'floatMe']) !== -1) {
  13267. var welHandle = oLayoutInfo.handle();
  13268. var welSelection = welHandle.find('.note-control-selection');
  13269. elTarget = welSelection.data('target');
  13270. }
  13271. if (editor[sEvent]) { // on command
  13272. welEditable.trigger('focus');
  13273. editor[sEvent](welEditable, sValue, elTarget);
  13274. }
  13275. // after command
  13276. if ($.inArray(sEvent, ['backColor', 'foreColor']) !== -1) {
  13277. toolbar.updateRecentColor(welBtn[0], sEvent, sValue);
  13278. } else if (sEvent === 'showLinkDialog') { // popover to dialog
  13279. welEditable.focus();
  13280. editor.setLinkDialog(welEditable, function(linkInfo, cb) {
  13281. dialog.showLinkDialog(welDialog, linkInfo, cb);
  13282. });
  13283. } else if (sEvent === 'showImageDialog') {
  13284. welEditable.focus();
  13285. dialog.showImageDialog(welDialog, hDropImage, function(files) {
  13286. insertImages(welEditable, files);
  13287. }, function(sUrl) {
  13288. editor.restoreRange(welEditable);
  13289. editor.insertImage(welEditable, sUrl);
  13290. });
  13291. } else if (sEvent === 'showHelpDialog') {
  13292. dialog.showHelpDialog(welDialog);
  13293. } else if (sEvent === 'fullscreen') {
  13294. var welEditor = oLayoutInfo.editor();
  13295. welEditor.toggleClass('fullscreen');
  13296. var welToolbar = oLayoutInfo.toolbar();
  13297. var hResizeFullscreen = function() {
  13298. var nHeight = $(window).height() - welToolbar.outerHeight();
  13299. welEditable.css('height', nHeight);
  13300. };
  13301. var bFullscreen = welEditor.hasClass('fullscreen');
  13302. if (bFullscreen) {
  13303. welEditable.data('orgHeight', welEditable.css('height'));
  13304. $(window).resize(hResizeFullscreen).trigger('resize');
  13305. } else {
  13306. welEditable.css('height', welEditable.data('orgHeight'));
  13307. $(window).off('resize');
  13308. }
  13309. toolbar.updateFullscreen(welToolbar, bFullscreen);
  13310. } else if (sEvent === 'codeview') {
  13311. var welEditor = oLayoutInfo.editor(),
  13312. welToolbar = oLayoutInfo.toolbar();
  13313. welEditor.toggleClass('codeview');
  13314. var bCodeview = welEditor.hasClass('codeview');
  13315. if (bCodeview) {
  13316. welCodable.val(welEditable.html());
  13317. welCodable.height(welEditable.height());
  13318. toolbar.disable(welToolbar);
  13319. welCodable.focus();
  13320. } else {
  13321. welEditable.html(welCodable.val());
  13322. welEditable.height(welCodable.height());
  13323. toolbar.enable(welToolbar);
  13324. welEditable.focus();
  13325. }
  13326. toolbar.updateCodeview(oLayoutInfo.toolbar(), bCodeview);
  13327. }
  13328. hToolbarAndPopoverUpdate(event);
  13329. }
  13330. };
  13331. var EDITABLE_PADDING = 24;
  13332. var hStatusbarMousedown = function(event) {
  13333. var welDocument = $(document);
  13334. var oLayoutInfo = makeLayoutInfo(event.target);
  13335. var welEditable = oLayoutInfo.editable(),
  13336. welCodable = oLayoutInfo.codable();
  13337. var nEditableTop = welEditable.offset().top - welDocument.scrollTop();
  13338. var hMousemove = function(event) {
  13339. welEditable.height(event.clientY - (nEditableTop + EDITABLE_PADDING));
  13340. };
  13341. var hMouseup = function() {
  13342. welDocument.unbind('mousemove', hMousemove)
  13343. .unbind('mouseup', hMouseup);
  13344. };
  13345. welDocument.mousemove(hMousemove).mouseup(hMouseup);
  13346. event.stopPropagation(); event.preventDefault();
  13347. };
  13348. var PX_PER_EM = 18;
  13349. var hDimensionPickerMove = function(event) {
  13350. var welPicker = $(event.target.parentNode); // target is mousecatcher
  13351. var welDimensionDisplay = welPicker.next();
  13352. var welCatcher = welPicker.find('.note-dimension-picker-mousecatcher');
  13353. var welHighlighted = welPicker.find('.note-dimension-picker-highlighted');
  13354. var welUnhighlighted = welPicker.find('.note-dimension-picker-unhighlighted');
  13355. var posOffset;
  13356. if (event.offsetX === undefined) {
  13357. // HTML5 with jQuery - e.offsetX is undefined in Firefox
  13358. var posCatcher = $(event.target).offset();
  13359. posOffset = {x: event.pageX - posCatcher.left,
  13360. y: event.pageY - posCatcher.top};
  13361. } else {
  13362. posOffset = {x: event.offsetX, y: event.offsetY};
  13363. }
  13364. var dim = {c: Math.ceil(posOffset.x / PX_PER_EM) || 1,
  13365. r: Math.ceil(posOffset.y / PX_PER_EM) || 1};
  13366. welHighlighted.css({ width: dim.c +'em', height: dim.r + 'em' });
  13367. welCatcher.attr('data-value', dim.c + 'x' + dim.r);
  13368. if (3 < dim.c && dim.c < 10) { // 5~10
  13369. welUnhighlighted.css({ width: dim.c + 1 + 'em'});
  13370. }
  13371. if (3 < dim.r && dim.r < 10) { // 5~10
  13372. welUnhighlighted.css({ height: dim.r + 1 + 'em'});
  13373. }
  13374. welDimensionDisplay.html(dim.c + ' x ' + dim.r);
  13375. };
  13376. /**
  13377. * Attach eventhandler
  13378. * @param {object} oLayoutInfo - layout Informations
  13379. * @param {object} options - user options include custom event handlers
  13380. * @param {function} options.enter - enter key handler
  13381. */
  13382. this.attach = function(oLayoutInfo, options) {
  13383. oLayoutInfo.editable.on('keydown', hKeydown);
  13384. oLayoutInfo.editable.on('mousedown', hMousedown);
  13385. oLayoutInfo.editable.on('keyup mouseup', hToolbarAndPopoverUpdate);
  13386. oLayoutInfo.editable.on('scroll', hScroll);
  13387. //TODO: handle Drag point
  13388. oLayoutInfo.editable.on('dragenter dragover dragleave', false);
  13389. oLayoutInfo.editable.on('drop', hDropImage);
  13390. oLayoutInfo.handle.on('mousedown', hHandleMousedown);
  13391. oLayoutInfo.toolbar.on('click', hToolbarAndPopoverClick);
  13392. oLayoutInfo.popover.on('click', hToolbarAndPopoverClick);
  13393. oLayoutInfo.toolbar.on('mousedown', hToolbarAndPopoverMousedown);
  13394. oLayoutInfo.popover.on('mousedown', hToolbarAndPopoverMousedown);
  13395. oLayoutInfo.statusbar.on('mousedown', hStatusbarMousedown);
  13396. //toolbar table dimension
  13397. var welToolbar = oLayoutInfo.toolbar;
  13398. var welCatcher = welToolbar.find('.note-dimension-picker-mousecatcher');
  13399. welCatcher.on('mousemove', hDimensionPickerMove);
  13400. // save selection when focusout
  13401. oLayoutInfo.editable.on('blur', function() {
  13402. editor.saveRange(oLayoutInfo.editable);
  13403. });
  13404. // basic event callbacks (lowercase)
  13405. // enter, focus, blur, keyup, keydown
  13406. if (options.onenter) {
  13407. oLayoutInfo.editable.keypress(function(event) {
  13408. if (event.keyCode === key.ENTER) { options.onenter(event);}
  13409. });
  13410. }
  13411. if (options.onfocus) { oLayoutInfo.editable.focus(options.onfocus); }
  13412. if (options.onblur) { oLayoutInfo.editable.blur(options.onblur); }
  13413. if (options.onkeyup) { oLayoutInfo.editable.keyup(options.onkeyup); }
  13414. if (options.onkeydown) { oLayoutInfo.editable.keydown(options.onkeydown); }
  13415. // callbacks for advanced features (camel)
  13416. // All editor status will be saved on editable with jquery's data
  13417. // for support multiple editor with singleton object.
  13418. oLayoutInfo.editable.data('callbacks', {
  13419. onChange: options.onChange, onAutoSave: options.onAutoSave,
  13420. onPasteBefore: options.onPasteBefore, onPasteAfter: options.onPasteAfter,
  13421. onImageUpload: options.onImageUpload, onImageUploadError: options.onImageUpload,
  13422. onFileUpload: options.onFileUpload, onFileUploadError: options.onFileUpload
  13423. });
  13424. };
  13425. this.dettach = function(oLayoutInfo) {
  13426. oLayoutInfo.editable.off();
  13427. oLayoutInfo.toolbar.off();
  13428. oLayoutInfo.handle.off();
  13429. oLayoutInfo.popover.off();
  13430. };
  13431. };
  13432. /**
  13433. * Renderer
  13434. *
  13435. * rendering toolbar and editable
  13436. */
  13437. var Renderer = function() {
  13438. var aToolbarItem = {
  13439. picture:
  13440. '<button type="button" class="btn btn-default btn-sm btn-small" title="Picture" data-event="showImageDialog" tabindex="-1"><i class="fa fa-picture-o icon-picture"></i></button>',
  13441. link:
  13442. '<button type="button" class="btn btn-default btn-sm btn-small" title="Link" data-event="showLinkDialog" data-shortcut="Ctrl+K" data-mac-shortcut="⌘+K" tabindex="-1"><i class="fa fa-link icon-link"></i></button>',
  13443. table:
  13444. '<button type="button" class="btn btn-default btn-sm btn-small dropdown-toggle" title="Table" data-toggle="dropdown" tabindex="-1"><i class="fa fa-table icon-table"></i> <span class="caret"></span></button>' +
  13445. '<ul class="dropdown-menu">' +
  13446. '<div class="note-dimension-picker">' +
  13447. '<div class="note-dimension-picker-mousecatcher" data-event="insertTable" data-value="1x1"></div>' +
  13448. '<div class="note-dimension-picker-highlighted"></div>' +
  13449. '<div class="note-dimension-picker-unhighlighted"></div>' +
  13450. '</div>' +
  13451. '<div class="note-dimension-display"> 1 x 1 </div>' +
  13452. '</ul>',
  13453. style:
  13454. '<button type="button" class="btn btn-default btn-sm btn-small dropdown-toggle" title="Style" data-toggle="dropdown" tabindex="-1"><i class="fa fa-magic icon-magic"></i> <span class="caret"></span></button>' +
  13455. '<ul class="dropdown-menu">' +
  13456. '<li><a data-event="formatBlock" data-value="p">Normal</a></li>' +
  13457. '<li><a data-event="formatBlock" data-value="blockquote"><blockquote>Quote</blockquote></a></li>' +
  13458. '<li><a data-event="formatBlock" data-value="pre">Code</a></li>' +
  13459. '<li><a data-event="formatBlock" data-value="h1"><h1>Header 1</h1></a></li>' +
  13460. '<li><a data-event="formatBlock" data-value="h2"><h2>Header 2</h2></a></li>' +
  13461. '<li><a data-event="formatBlock" data-value="h3"><h3>Header 3</h3></a></li>' +
  13462. '<li><a data-event="formatBlock" data-value="h4"><h4>Header 4</h4></a></li>' +
  13463. '<li><a data-event="formatBlock" data-value="h5"><h5>Header 5</h5></a></li>' +
  13464. '<li><a data-event="formatBlock" data-value="h6"><h6>Header 6</h6></a></li>' +
  13465. '</ul>',
  13466. fontsize:
  13467. '<button type="button" class="btn btn-default btn-sm btn-small dropdown-toggle" data-toggle="dropdown" title="Font Size" tabindex="-1"><span class="note-current-fontsize">11</span> <b class="caret"></b></button>' +
  13468. '<ul class="dropdown-menu">' +
  13469. '<li><a data-event="fontSize" data-value="8"><i class="fa fa-check icon-ok"></i> 8</a></li>' +
  13470. '<li><a data-event="fontSize" data-value="9"><i class="fa fa-check icon-ok"></i> 9</a></li>' +
  13471. '<li><a data-event="fontSize" data-value="10"><i class="fa fa-check icon-ok"></i> 10</a></li>' +
  13472. '<li><a data-event="fontSize" data-value="11"><i class="fa fa-check icon-ok"></i> 11</a></li>' +
  13473. '<li><a data-event="fontSize" data-value="12"><i class="fa fa-check icon-ok"></i> 12</a></li>' +
  13474. '<li><a data-event="fontSize" data-value="14"><i class="fa fa-check icon-ok"></i> 14</a></li>' +
  13475. '<li><a data-event="fontSize" data-value="18"><i class="fa fa-check icon-ok"></i> 18</a></li>' +
  13476. '<li><a data-event="fontSize" data-value="24"><i class="fa fa-check icon-ok"></i> 24</a></li>' +
  13477. '<li><a data-event="fontSize" data-value="36"><i class="fa fa-check icon-ok"></i> 36</a></li>' +
  13478. '</ul>',
  13479. color:
  13480. '<button type="button" class="btn btn-default btn-sm btn-small note-recent-color" title="Recent Color" data-event="color" data-value=\'{"backColor":"yellow"}\' tabindex="-1"><i class="fa fa-font icon-font" style="color:black;background-color:yellow;"></i></button>' +
  13481. '<button type="button" class="btn btn-default btn-sm btn-small dropdown-toggle" title="More Color" data-toggle="dropdown" tabindex="-1">' +
  13482. '<span class="caret"></span>' +
  13483. '</button>' +
  13484. '<ul class="dropdown-menu">' +
  13485. '<li>' +
  13486. '<div class="btn-group">' +
  13487. '<div class="note-palette-title">BackColor</div>' +
  13488. '<div class="note-color-reset" data-event="backColor" data-value="inherit" title="Transparent">Set transparent</div>' +
  13489. '<div class="note-color-palette" data-target-event="backColor"></div>' +
  13490. '</div>' +
  13491. '<div class="btn-group">' +
  13492. '<div class="note-palette-title">FontColor</div>' +
  13493. '<div class="note-color-reset" data-event="foreColor" data-value="inherit" title="Reset">Reset to default</div>' +
  13494. '<div class="note-color-palette" data-target-event="foreColor"></div>' +
  13495. '</div>' +
  13496. '</li>' +
  13497. '</ul>',
  13498. bold:
  13499. '<button type="button" class="btn btn-default btn-sm btn-small" title="Bold" data-shortcut="Ctrl+B" data-mac-shortcut="⌘+B" data-event="bold" tabindex="-1"><i class="fa fa-bold icon-bold"></i></button>',
  13500. italic:
  13501. '<button type="button" class="btn btn-default btn-sm btn-small" title="Italic" data-shortcut="Ctrl+I" data-mac-shortcut="⌘+I" data-event="italic" tabindex="-1"><i class="fa fa-italic icon-italic"></i></button>',
  13502. underline:
  13503. '<button type="button" class="btn btn-default btn-sm btn-small" title="Underline" data-shortcut="Ctrl+U" data-mac-shortcut="⌘+U" data-event="underline" tabindex="-1"><i class="fa fa-underline icon-underline"></i></button>',
  13504. clear:
  13505. '<button type="button" class="btn btn-default btn-sm btn-small" title="Remove Font Style" data-shortcut="Ctrl+\\" data-mac-shortcut="⌘+\\" data-event="removeFormat" tabindex="-1"><i class="fa fa-eraser icon-eraser"></i></button>',
  13506. ul:
  13507. '<button type="button" class="btn btn-default btn-sm btn-small" title="Unordered list" data-shortcut="Ctrl+Shift+8" data-mac-shortcut="⌘+⇧+7" data-event="insertUnorderedList" tabindex="-1"><i class="fa fa-list-ul icon-list-ul"></i></button>',
  13508. ol:
  13509. '<button type="button" class="btn btn-default btn-sm btn-small" title="Ordered list" data-shortcut="Ctrl+Shift+7" data-mac-shortcut="⌘+⇧+8" data-event="insertOrderedList" tabindex="-1"><i class="fa fa-list-ol icon-list-ol"></i></button>',
  13510. paragraph:
  13511. '<button type="button" class="btn btn-default btn-sm btn-small dropdown-toggle" title="Paragraph" data-toggle="dropdown" tabindex="-1"><i class="fa fa-align-left icon-align-left"></i> <span class="caret"></span></button>' +
  13512. '<ul class="dropdown-menu">' +
  13513. '<li>' +
  13514. '<div class="note-align btn-group">' +
  13515. '<button type="button" class="btn btn-default btn-sm btn-small" title="Align left" data-shortcut="Ctrl+Shift+L" data-mac-shortcut="⌘+⇧+L" data-event="justifyLeft" tabindex="-1"><i class="fa fa-align-left icon-align-left"></i></button>' +
  13516. '<button type="button" class="btn btn-default btn-sm btn-small" title="Align center" data-shortcut="Ctrl+Shift+E" data-mac-shortcut="⌘+⇧+E" data-event="justifyCenter" tabindex="-1"><i class="fa fa-align-center icon-align-center"></i></button>' +
  13517. '<button type="button" class="btn btn-default btn-sm btn-small" title="Align right" data-shortcut="Ctrl+Shift+R" data-mac-shortcut="⌘+⇧+R" data-event="justifyRight" tabindex="-1"><i class="fa fa-align-right icon-align-right"></i></button>' +
  13518. '<button type="button" class="btn btn-default btn-sm btn-small" title="Justify full" data-shortcut="Ctrl+Shift+J" data-mac-shortcut="⌘+⇧+J" data-event="justifyFull" tabindex="-1"><i class="fa fa-align-justify icon-align-justify"></i></button>' +
  13519. '</div>' +
  13520. '</li>' +
  13521. '<li>' +
  13522. '<div class="note-list btn-group">' +
  13523. '<button type="button" class="btn btn-default btn-sm btn-small" title="Outdent" data-shortcut="Ctrl+[" data-mac-shortcut="⌘+[" data-event="outdent" tabindex="-1"><i class="fa fa-outdent icon-indent-left"></i></button>' +
  13524. '<button type="button" class="btn btn-default btn-sm btn-small" title="Indent" data-shortcut="Ctrl+]" data-mac-shortcut="⌘+]" data-event="indent" tabindex="-1"><i class="fa fa-indent icon-indent-right"></i></button>' +
  13525. '</li>' +
  13526. '</ul>',
  13527. height:
  13528. '<button type="button" class="btn btn-default btn-sm btn-small dropdown-toggle" data-toggle="dropdown" title="Line Height" tabindex="-1"><i class="fa fa-text-height icon-text-height"></i>&nbsp; <b class="caret"></b></button>' +
  13529. '<ul class="dropdown-menu">' +
  13530. '<li><a data-event="lineHeight" data-value="1.0"><i class="fa fa-check icon-ok"></i> 1.0</a></li>' +
  13531. '<li><a data-event="lineHeight" data-value="1.2"><i class="fa fa-check icon-ok"></i> 1.2</a></li>' +
  13532. '<li><a data-event="lineHeight" data-value="1.4"><i class="fa fa-check icon-ok"></i> 1.4</a></li>' +
  13533. '<li><a data-event="lineHeight" data-value="1.5"><i class="fa fa-check icon-ok"></i> 1.5</a></li>' +
  13534. '<li><a data-event="lineHeight" data-value="1.6"><i class="fa fa-check icon-ok"></i> 1.6</a></li>' +
  13535. '<li><a data-event="lineHeight" data-value="1.8"><i class="fa fa-check icon-ok"></i> 1.8</a></li>' +
  13536. '<li><a data-event="lineHeight" data-value="2.0"><i class="fa fa-check icon-ok"></i> 2.0</a></li>' +
  13537. '<li><a data-event="lineHeight" data-value="3.0"><i class="fa fa-check icon-ok"></i> 3.0</a></li>' +
  13538. '</ul>',
  13539. help:
  13540. '<button type="button" class="btn btn-default btn-sm btn-small" title="Help" data-shortcut="Ctrl+/" data-mac-shortcut="⌘+/" data-event="showHelpDialog" tabindex="-1"><i class="fa fa-question icon-question"></i></button>',
  13541. fullscreen:
  13542. '<button type="button" class="btn btn-default btn-sm btn-small" title="Full Screen" data-event="fullscreen" tabindex="-1"><i class="fa fa-arrows-alt icon-fullscreen"></i></button>',
  13543. codeview:
  13544. '<button type="button" class="btn btn-default btn-sm btn-small" title="Code View" data-event="codeview" tabindex="-1"><i class="fa fa-code icon-code"></i></button>'
  13545. };
  13546. var sPopover = '<div class="note-popover">' +
  13547. '<div class="note-link-popover popover bottom in" style="display: none;">' +
  13548. '<div class="arrow"></div>' +
  13549. '<div class="popover-content note-link-content">' +
  13550. '<a href="http://www.google.com" target="_blank">www.google.com</a>&nbsp;&nbsp;' +
  13551. '<div class="note-insert btn-group">' +
  13552. '<button type="button" class="btn btn-default btn-sm btn-small" title="Edit" data-event="showLinkDialog" tabindex="-1"><i class="fa fa-edit icon-edit"></i></button>' +
  13553. '<button type="button" class="btn btn-default btn-sm btn-small" title="Unlink" data-event="unlink" tabindex="-1"><i class="fa fa-unlink icon-unlink"></i></button>' +
  13554. '</div>' +
  13555. '</div>' +
  13556. '</div>' +
  13557. '<div class="note-image-popover popover bottom in" style="display: none;">' +
  13558. '<div class="arrow"></div>' +
  13559. '<div class="popover-content note-image-content">' +
  13560. '<div class="btn-group">' +
  13561. '<button type="button" class="btn btn-default btn-sm btn-small" title="Resize Full" data-event="resize" data-value="1" tabindex="-1"><span class="note-fontsize-10">100%</span> </button>' +
  13562. '<button type="button" class="btn btn-default btn-sm btn-small" title="Resize Half" data-event="resize" data-value="0.5" tabindex="-1"><span class="note-fontsize-10">50%</span> </button>' +
  13563. '<button type="button" class="btn btn-default btn-sm btn-small" title="Resize Quarter" data-event="resize" data-value="0.25" tabindex="-1"><span class="note-fontsize-10">25%</span> </button>' +
  13564. '</div>' +
  13565. '<div class="btn-group">' +
  13566. '<button type="button" class="btn btn-default btn-sm btn-small" title="Float Left" data-event="floatMe" data-value="left" tabindex="-1"><i class="fa fa-align-left icon-align-left"></i></button>' +
  13567. '<button type="button" class="btn btn-default btn-sm btn-small" title="Float Right" data-event="floatMe" data-value="right" tabindex="-1"><i class="fa fa-align-right icon-align-right"></i></button>' +
  13568. '<button type="button" class="btn btn-default btn-sm btn-small" title="Float None" data-event="floatMe" data-value="none" tabindex="-1"><i class="fa fa-align-justify icon-align-justify"></i></button>' +
  13569. '</div>' +
  13570. '</div>' +
  13571. '</div>' +
  13572. '</div>';
  13573. var sHandle = '<div class="note-handle">' +
  13574. '<div class="note-control-selection">' +
  13575. '<div class="note-control-selection-bg"></div>' +
  13576. '<div class="note-control-holder note-control-nw"></div>' +
  13577. '<div class="note-control-holder note-control-ne"></div>' +
  13578. '<div class="note-control-holder note-control-sw"></div>' +
  13579. '<div class="note-control-sizing note-control-se"></div>' +
  13580. '<div class="note-control-selection-info"></div>' +
  13581. '</div>' +
  13582. '</div>';
  13583. var sShortcutText = '<table class="note-shortcut">' +
  13584. '<thead>' +
  13585. '<tr><th></th><th>Text formatting</th></tr>' +
  13586. '</thead>' +
  13587. '<tbody>' +
  13588. '<tr><td>⌘ + B</td><td>Toggle Bold</td></tr>' +
  13589. '<tr><td>⌘ + I</td><td>Toggle Italic</td></tr>' +
  13590. '<tr><td>⌘ + U</td><td>Toggle Underline</td></tr>' +
  13591. '<tr><td>⌘ + ⇧ + S</td><td>Toggle Strike</td></tr>' +
  13592. '<tr><td>⌘ + \\</td><td>Remove Font Style</td></tr>' +
  13593. '</tr>' +
  13594. '</tbody>' +
  13595. '</table>';
  13596. var sShortcutAction = '<table class="note-shortcut">' +
  13597. '<thead>' +
  13598. '<tr><th></th><th>Action</th></tr>' +
  13599. '</thead>' +
  13600. '<tbody>' +
  13601. '<tr><td>⌘ + Z</td><td>Undo</td></tr>' +
  13602. '<tr><td>⌘ + ⇧ + Z</td><td>Redo</td></tr>' +
  13603. '<tr><td>⌘ + ]</td><td>Indent</td></tr>' +
  13604. '<tr><td>⌘ + [</td><td>Outdent</td></tr>' +
  13605. '<tr><td>⌘ + K</td><td>Insert Link</td></tr>' +
  13606. '<tr><td>⌘ + ENTER</td><td>Insert Horizontal Rule</td></tr>' +
  13607. '</tbody>' +
  13608. '</table>';
  13609. var sShortcutPara = '<table class="note-shortcut">' +
  13610. '<thead>' +
  13611. '<tr><th></th><th>Paragraph formatting</th></tr>' +
  13612. '</thead>' +
  13613. '<tbody>' +
  13614. '<tr><td>⌘ + ⇧ + L</td><td>Align Left</td></tr>' +
  13615. '<tr><td>⌘ + ⇧ + E</td><td>Align Center</td></tr>' +
  13616. '<tr><td>⌘ + ⇧ + R</td><td>Align Right</td></tr>' +
  13617. '<tr><td>⌘ + ⇧ + J</td><td>Justify Full</td></tr>' +
  13618. '<tr><td>⌘ + ⇧ + NUM7</td><td>Ordered List</td></tr>' +
  13619. '<tr><td>⌘ + ⇧ + NUM8</td><td>Unordered List</td></tr>' +
  13620. '</tbody>' +
  13621. '</table>';
  13622. var sShortcutStyle = '<table class="note-shortcut">' +
  13623. '<thead>' +
  13624. '<tr><th></th><th>Document Style</th></tr>' +
  13625. '</thead>' +
  13626. '<tbody>' +
  13627. '<tr><td>⌘ + NUM0</td><td>Normal Text</td></tr>' +
  13628. '<tr><td>⌘ + NUM1</td><td>Heading 1</td></tr>' +
  13629. '<tr><td>⌘ + NUM2</td><td>Heading 2</td></tr>' +
  13630. '<tr><td>⌘ + NUM3</td><td>Heading 3</td></tr>' +
  13631. '<tr><td>⌘ + NUM4</td><td>Heading 4</td></tr>' +
  13632. '<tr><td>⌘ + NUM5</td><td>Heading 5</td></tr>' +
  13633. '<tr><td>⌘ + NUM6</td><td>Heading 6</td></tr>' +
  13634. '</tbody>' +
  13635. '</table>';
  13636. var sShortcutTable = '<table class="note-shortcut-layout">' +
  13637. '<tbody>' +
  13638. '<tr><td>' + sShortcutAction +'</td><td>' + sShortcutText +'</td></tr>' +
  13639. '<tr><td>' + sShortcutStyle +'</td><td>' + sShortcutPara +'</td></tr>' +
  13640. '</tbody>' +
  13641. '</table>';
  13642. if (!agent.bMac) { // shortcut modifier for windows
  13643. sShortcutTable = sShortcutTable.replace(/⌘/g, 'Ctrl').replace(/⇧/g, 'Shift');
  13644. }
  13645. var sDialog = '<div class="note-dialog">' +
  13646. '<div class="note-image-dialog modal" aria-hidden="false">' +
  13647. '<div class="modal-dialog">' +
  13648. '<div class="modal-content">' +
  13649. '<div class="modal-header">' +
  13650. '<button type="button" class="close" aria-hidden="true" tabindex="-1">×</button>' +
  13651. '<h4>Insert Image</h4>' +
  13652. '</div>' +
  13653. '<div class="modal-body">' +
  13654. '<div class="row-fluid">' +
  13655. '<div class="note-dropzone span12">Drag an image here</div>' +
  13656. '<h5>Select from files</h5>' +
  13657. '<input class="note-image-input" type="file" name="files" accept="image/*" capture="camera" />' +
  13658. '<h5>Image URL</h5>' +
  13659. '<input class="note-image-url form-control span12" type="text" />' +
  13660. '</div>' +
  13661. '</div>' +
  13662. '<div class="modal-footer">' +
  13663. '<button href="#" class="btn btn-primary note-image-btn disabled" disabled="disabled">Insert</button>' +
  13664. '</div>' +
  13665. '</div>' +
  13666. '</div>' +
  13667. '</div>' +
  13668. '<div class="note-link-dialog modal" aria-hidden="false">' +
  13669. '<div class="modal-dialog">' +
  13670. '<div class="modal-content">' +
  13671. '<div class="modal-header">' +
  13672. '<button type="button" class="close" aria-hidden="true" tabindex="-1">×</button>' +
  13673. '<h4>Edit Link</h4>' +
  13674. '</div>' +
  13675. '<div class="modal-body">' +
  13676. '<div class="row-fluid">' +
  13677. '<div class="form-group">' +
  13678. '<label>Text to display</label>' +
  13679. '<span class="note-link-text form-control input-xlarge uneditable-input" />' +
  13680. '</div>' +
  13681. '<div class="form-group">' +
  13682. '<label>To what URL should this link go?</label>' +
  13683. '<input class="note-link-url form-control span12" type="text" />' +
  13684. '</div>' +
  13685. '</div>' +
  13686. '</div>' +
  13687. '<div class="modal-footer">' +
  13688. '<button href="#" class="btn btn-primary note-link-btn disabled" disabled="disabled">Link</button>' +
  13689. '</div>' +
  13690. '</div>' +
  13691. '</div>' +
  13692. '</div>' +
  13693. '<div class="note-help-dialog modal" aria-hidden="false">' +
  13694. '<div class="modal-dialog">' +
  13695. '<div class="modal-content">' +
  13696. '<div class="modal-body">' +
  13697. '<div class="modal-background">' +
  13698. '<a class="modal-close pull-right" aria-hidden="true" tabindex="-1">Close</a>' +
  13699. '<div class="title">Keyboard shortcuts</div>' +
  13700. sShortcutTable +
  13701. '<p class="text-center"><a href="//hackerwins.github.io/summernote/" target="_blank">Summernote v0.4</a> · <a href="//github.com/HackerWins/summernote" target="_blank">Project</a> · <a href="//github.com/HackerWins/summernote/issues" target="_blank">Issues</a></p>' +
  13702. '</div>' +
  13703. '</div>' +
  13704. '</div>' +
  13705. '</div>' +
  13706. '</div>';
  13707. // createTooltip
  13708. var createTooltip = function(welContainer, sPlacement) {
  13709. welContainer.find('button').each(function(i, elBtn) {
  13710. var welBtn = $(elBtn);
  13711. var sShortcut = welBtn.attr(agent.bMac ? 'data-mac-shortcut': 'data-shortcut');
  13712. if (sShortcut) { welBtn.attr('title', function(i, v) { return v + ' (' + sShortcut + ')'; }); }
  13713. //bootstrap tooltip on btn-group bug: https://github.com/twitter/bootstrap/issues/5687
  13714. }).tooltip({container: 'body', placement: sPlacement || 'top'});
  13715. };
  13716. // pallete colors
  13717. var aaColor = [
  13718. ['#000000', '#424242', '#636363', '#9C9C94', '#CEC6CE', '#EFEFEF', '#F7F7F7', '#FFFFFF'],
  13719. ['#FF0000', '#FF9C00', '#FFFF00', '#00FF00', '#00FFFF', '#0000FF', '#9C00FF', '#FF00FF'],
  13720. ['#F7C6CE', '#FFE7CE', '#FFEFC6', '#D6EFD6', '#CEDEE7', '#CEE7F7', '#D6D6E7', '#E7D6DE'],
  13721. ['#E79C9C', '#FFC69C', '#FFE79C', '#B5D6A5', '#A5C6CE', '#9CC6EF', '#B5A5D6', '#D6A5BD'],
  13722. ['#E76363', '#F7AD6B', '#FFD663', '#94BD7B', '#73A5AD', '#6BADDE', '#8C7BC6', '#C67BA5'],
  13723. ['#CE0000', '#E79439', '#EFC631', '#6BA54A', '#4A7B8C', '#3984C6', '#634AA5', '#A54A7B'],
  13724. ['#9C0000', '#B56308', '#BD9400', '#397B21', '#104A5A', '#085294', '#311873', '#731842'],
  13725. ['#630000', '#7B3900', '#846300', '#295218', '#083139', '#003163', '#21104A', '#4A1031']
  13726. ];
  13727. // createPalette
  13728. var createPalette = function(welContainer) {
  13729. welContainer.find('.note-color-palette').each(function() {
  13730. var welPalette = $(this), sEvent = welPalette.attr('data-target-event');
  13731. var sPaletteContents = '';
  13732. for (var row = 0, szRow = aaColor.length; row < szRow; row++) {
  13733. var aColor = aaColor[row];
  13734. var sLine = '<div>';
  13735. for (var col = 0, szCol = aColor.length; col < szCol; col++) {
  13736. var sColor = aColor[col];
  13737. var sButton = ['<button type="button" class="note-color-btn" style="background-color:', sColor,
  13738. ';" data-event="', sEvent,
  13739. '" data-value="', sColor,
  13740. '" title="', sColor,
  13741. '" data-toggle="button" tabindex="-1"></button>'].join('');
  13742. sLine += sButton;
  13743. }
  13744. sLine += '</div>';
  13745. sPaletteContents += sLine;
  13746. }
  13747. welPalette.html(sPaletteContents);
  13748. });
  13749. };
  13750. // createLayout
  13751. var createLayout = this.createLayout = function(welHolder, nHeight, nTabsize, aToolbarSetting) {
  13752. //already created
  13753. if (welHolder.next().hasClass('note-editor')) { return; }
  13754. //01. create Editor
  13755. var welEditor = $('<div class="note-editor"></div>');
  13756. //02. statusbar
  13757. if (nHeight > 0) {
  13758. var welStatusbar = $('<div class="note-statusbar"><div class="note-resizebar"><div class="note-icon-bar"></div><div class="note-icon-bar"></div><div class="note-icon-bar"></div></div></div>').prependTo(welEditor);
  13759. }
  13760. //03. create Editable
  13761. var welEditable = $('<div class="note-editable" contentEditable="true"></div>').prependTo(welEditor);
  13762. if (nHeight) { welEditable.height(nHeight); }
  13763. if (nTabsize) {
  13764. welEditable.data('tabsize', nTabsize);
  13765. }
  13766. welEditable.html(dom.html(welHolder));
  13767. welEditable.data('NoteHistory', new History());
  13768. //031. create codable
  13769. var welCodable = $('<textarea class="note-codable"></textarea>').prependTo(welEditor);
  13770. //032. set styleWithCSS for backColor / foreColor clearing with 'inherit'.
  13771. setTimeout(function() { // protect FF Error: NS_ERROR_FAILURE: Failure
  13772. document.execCommand('styleWithCSS', 0, true);
  13773. });
  13774. //04. create Toolbar
  13775. var sToolbar = '';
  13776. for (var idx = 0, sz = aToolbarSetting.length; idx < sz; idx ++) {
  13777. var group = aToolbarSetting[idx];
  13778. sToolbar += '<div class="note-' + group[0] + ' btn-group">';
  13779. for (var i = 0, szGroup = group[1].length; i < szGroup; i++) {
  13780. sToolbar += aToolbarItem[group[1][i]];
  13781. }
  13782. sToolbar += '</div>';
  13783. }
  13784. sToolbar = '<div class="note-toolbar btn-toolbar">' + sToolbar + '</div>';
  13785. var welToolbar = $(sToolbar).prependTo(welEditor);
  13786. createPalette(welToolbar);
  13787. createTooltip(welToolbar, 'bottom');
  13788. //05. create Popover
  13789. var welPopover = $(sPopover).prependTo(welEditor);
  13790. createTooltip(welPopover);
  13791. //06. handle(control selection, ...)
  13792. $(sHandle).prependTo(welEditor);
  13793. //07. create Dialog
  13794. var welDialog = $(sDialog).prependTo(welEditor);
  13795. welDialog.find('button.close, a.modal-close').click(function(event) {
  13796. $(this).closest('.modal').modal('hide');
  13797. });
  13798. //08. Editor/Holder switch
  13799. welEditor.insertAfter(welHolder);
  13800. welHolder.hide();
  13801. };
  13802. // layoutInfoFromHolder
  13803. var layoutInfoFromHolder = this.layoutInfoFromHolder = function(welHolder) {
  13804. var welEditor = welHolder.next();
  13805. if (!welEditor.hasClass('note-editor')) { return; }
  13806. return {
  13807. editor: welEditor,
  13808. toolbar: welEditor.find('.note-toolbar'),
  13809. editable: welEditor.find('.note-editable'),
  13810. codable: welEditor.find('.note-codable'),
  13811. statusbar: welEditor.find('.note-statusbar'),
  13812. popover: welEditor.find('.note-popover'),
  13813. handle: welEditor.find('.note-handle'),
  13814. dialog: welEditor.find('.note-dialog')
  13815. };
  13816. };
  13817. // removeLayout
  13818. var removeLayout = this.removeLayout = function(welHolder) {
  13819. var info = layoutInfoFromHolder(welHolder);
  13820. if (!info) { return; }
  13821. welHolder.html(info.editable.html());
  13822. info.editor.remove();
  13823. welHolder.show();
  13824. };
  13825. };
  13826. var renderer = new Renderer();
  13827. var eventHandler = new EventHandler();
  13828. /**
  13829. * extend jquery fn
  13830. */
  13831. $.fn.extend({
  13832. // create Editor Layout and attach Key and Mouse Event
  13833. summernote: function(options) {
  13834. options = $.extend({
  13835. toolbar: [
  13836. ['style', ['style']],
  13837. ['font', ['bold', 'italic', 'underline', 'clear']],
  13838. ['fontsize', ['fontsize']],
  13839. ['color', ['color']],
  13840. ['para', ['ul', 'ol', 'paragraph']],
  13841. ['height', ['height']],
  13842. ['table', ['table']],
  13843. ['insert', ['link', 'picture']],
  13844. ['view', ['fullscreen', 'codeview']],
  13845. ['help', ['help']]
  13846. ]
  13847. }, options );
  13848. this.each(function(idx, elHolder) {
  13849. var welHolder = $(elHolder);
  13850. // createLayout with options
  13851. renderer.createLayout(welHolder, options.height, options.tabsize, options.toolbar);
  13852. var info = renderer.layoutInfoFromHolder(welHolder);
  13853. eventHandler.attach(info, options);
  13854. });
  13855. if (this.first() && options.focus) { // focus on first editable element
  13856. var info = renderer.layoutInfoFromHolder(this.first());
  13857. info.editable.focus();
  13858. }
  13859. if (this.length > 0 && options.oninit) { // callback on init
  13860. options.oninit();
  13861. }
  13862. },
  13863. // get the HTML contents of note or set the HTML contents of note.
  13864. code: function(sHTML) {
  13865. //get the HTML contents
  13866. if (sHTML === undefined) {
  13867. var welHolder = this.first();
  13868. if (welHolder.length === 0) { return; }
  13869. var info = renderer.layoutInfoFromHolder(welHolder);
  13870. if (!!(info && info.editable)) {
  13871. var bCodeview = info.editor.hasClass('codeview');
  13872. return bCodeview ? info.codable.val() : info.editable.html();
  13873. }
  13874. return welHolder.html();
  13875. }
  13876. // set the HTML contents
  13877. this.each(function(i, elHolder) {
  13878. var info = renderer.layoutInfoFromHolder($(elHolder));
  13879. if (info && info.editable) { info.editable.html(sHTML); }
  13880. });
  13881. },
  13882. // destroy Editor Layout and dettach Key and Mouse Event
  13883. destroy: function() {
  13884. this.each(function(idx, elHolder) {
  13885. var welHolder = $(elHolder);
  13886. var info = renderer.layoutInfoFromHolder(welHolder);
  13887. if (!info || !info.editable) { return; }
  13888. eventHandler.dettach(info);
  13889. renderer.removeLayout(welHolder);
  13890. });
  13891. },
  13892. // inner object for test
  13893. summernoteInner: function() {
  13894. return { dom: dom, list: list, func: func, range: range };
  13895. }
  13896. });
  13897. })(window.jQuery); // jQuery
  13898. // Array.prototype.reduce fallback
  13899. // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/Reduce
  13900. if ('function' !== typeof Array.prototype.reduce) {
  13901. Array.prototype.reduce = function(callback, opt_initialValue) {
  13902. 'use strict';
  13903. var idx, value, length = this.length >>> 0, isValueSet = false;
  13904. if (1 < arguments.length) { value = opt_initialValue, isValueSet = true; }
  13905. for (idx = 0; length > idx; ++idx) {
  13906. if (this.hasOwnProperty(idx)) {
  13907. if (isValueSet) {
  13908. value = callback(value, this[idx], idx, this);
  13909. } else {
  13910. value = this[idx], isValueSet = true;
  13911. }
  13912. }
  13913. }
  13914. if (!isValueSet) {
  13915. throw new TypeError('Reduce of empty array with no initial value');
  13916. }
  13917. return value;
  13918. };
  13919. }
  13920. ;
  13921. (function() {
  13922. var CSRFToken, Click, ComponentUrl, Link, browserCompatibleDocumentParser, browserIsntBuggy, browserSupportsCustomEvents, browserSupportsPushState, browserSupportsTurbolinks, bypassOnLoadPopstate, cacheCurrentPage, cacheSize, changePage, constrainPageCacheTo, createDocument, currentState, enableTransitionCache, executeScriptTags, extractTitleAndBody, fetch, fetchHistory, fetchReplacement, historyStateIsDefined, initializeTurbolinks, installDocumentReadyPageEventTriggers, installHistoryChangeHandler, installJqueryAjaxSuccessPageUpdateTrigger, loadedAssets, manuallyTriggerHashChangeForFirefox, pageCache, pageChangePrevented, pagesCached, popCookie, processResponse, recallScrollPosition, referer, reflectNewUrl, reflectRedirectedUrl, rememberCurrentState, rememberCurrentUrl, rememberReferer, removeNoscriptTags, requestMethodIsSafe, resetScrollPosition, setAutofocusElement, transitionCacheEnabled, transitionCacheFor, triggerEvent, visit, xhr, _ref,
  13923. __indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; },
  13924. __hasProp = {}.hasOwnProperty,
  13925. __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
  13926. __slice = [].slice;
  13927. pageCache = {};
  13928. cacheSize = 10;
  13929. transitionCacheEnabled = false;
  13930. currentState = null;
  13931. loadedAssets = null;
  13932. referer = null;
  13933. createDocument = null;
  13934. xhr = null;
  13935. fetch = function(url) {
  13936. var cachedPage;
  13937. url = new ComponentUrl(url);
  13938. rememberReferer();
  13939. cacheCurrentPage();
  13940. if (transitionCacheEnabled && (cachedPage = transitionCacheFor(url.absolute))) {
  13941. fetchHistory(cachedPage);
  13942. return fetchReplacement(url);
  13943. } else {
  13944. return fetchReplacement(url, resetScrollPosition);
  13945. }
  13946. };
  13947. transitionCacheFor = function(url) {
  13948. var cachedPage;
  13949. cachedPage = pageCache[url];
  13950. if (cachedPage && !cachedPage.transitionCacheDisabled) {
  13951. return cachedPage;
  13952. }
  13953. };
  13954. enableTransitionCache = function(enable) {
  13955. if (enable == null) {
  13956. enable = true;
  13957. }
  13958. return transitionCacheEnabled = enable;
  13959. };
  13960. fetchReplacement = function(url, onLoadFunction) {
  13961. if (onLoadFunction == null) {
  13962. onLoadFunction = (function(_this) {
  13963. return function() {};
  13964. })(this);
  13965. }
  13966. triggerEvent('page:fetch', {
  13967. url: url.absolute
  13968. });
  13969. if (xhr != null) {
  13970. xhr.abort();
  13971. }
  13972. xhr = new XMLHttpRequest;
  13973. xhr.open('GET', url.withoutHashForIE10compatibility(), true);
  13974. xhr.setRequestHeader('Accept', 'text/html, application/xhtml+xml, application/xml');
  13975. xhr.setRequestHeader('X-XHR-Referer', referer);
  13976. xhr.onload = function() {
  13977. var doc;
  13978. triggerEvent('page:receive', {
  13979. url: url.absolute
  13980. });
  13981. if (doc = processResponse()) {
  13982. reflectNewUrl(url);
  13983. changePage.apply(null, extractTitleAndBody(doc));
  13984. manuallyTriggerHashChangeForFirefox();
  13985. reflectRedirectedUrl();
  13986. onLoadFunction();
  13987. return triggerEvent('page:load');
  13988. } else {
  13989. return document.location.href = url.absolute;
  13990. }
  13991. };
  13992. xhr.onloadend = function() {
  13993. return xhr = null;
  13994. };
  13995. xhr.onerror = function() {
  13996. return document.location.href = url.absolute;
  13997. };
  13998. return xhr.send();
  13999. };
  14000. fetchHistory = function(cachedPage) {
  14001. if (xhr != null) {
  14002. xhr.abort();
  14003. }
  14004. changePage(cachedPage.title, cachedPage.body);
  14005. recallScrollPosition(cachedPage);
  14006. return triggerEvent('page:restore');
  14007. };
  14008. cacheCurrentPage = function() {
  14009. var currentStateUrl;
  14010. currentStateUrl = new ComponentUrl(currentState.url);
  14011. pageCache[currentStateUrl.absolute] = {
  14012. url: currentStateUrl.relative,
  14013. body: document.body,
  14014. title: document.title,
  14015. positionY: window.pageYOffset,
  14016. positionX: window.pageXOffset,
  14017. cachedAt: new Date().getTime(),
  14018. transitionCacheDisabled: document.querySelector('[data-no-transition-cache]') != null
  14019. };
  14020. return constrainPageCacheTo(cacheSize);
  14021. };
  14022. pagesCached = function(size) {
  14023. if (size == null) {
  14024. size = cacheSize;
  14025. }
  14026. if (/^[\d]+$/.test(size)) {
  14027. return cacheSize = parseInt(size);
  14028. }
  14029. };
  14030. constrainPageCacheTo = function(limit) {
  14031. var cacheTimesRecentFirst, key, pageCacheKeys, _i, _len, _results;
  14032. pageCacheKeys = Object.keys(pageCache);
  14033. cacheTimesRecentFirst = pageCacheKeys.map(function(url) {
  14034. return pageCache[url].cachedAt;
  14035. }).sort(function(a, b) {
  14036. return b - a;
  14037. });
  14038. _results = [];
  14039. for (_i = 0, _len = pageCacheKeys.length; _i < _len; _i++) {
  14040. key = pageCacheKeys[_i];
  14041. if (!(pageCache[key].cachedAt <= cacheTimesRecentFirst[limit])) {
  14042. continue;
  14043. }
  14044. triggerEvent('page:expire', pageCache[key]);
  14045. _results.push(delete pageCache[key]);
  14046. }
  14047. return _results;
  14048. };
  14049. changePage = function(title, body, csrfToken, runScripts) {
  14050. document.title = title;
  14051. document.documentElement.replaceChild(body, document.body);
  14052. if (csrfToken != null) {
  14053. CSRFToken.update(csrfToken);
  14054. }
  14055. setAutofocusElement();
  14056. if (runScripts) {
  14057. executeScriptTags();
  14058. }
  14059. currentState = window.history.state;
  14060. triggerEvent('page:change');
  14061. return triggerEvent('page:update');
  14062. };
  14063. executeScriptTags = function() {
  14064. var attr, copy, nextSibling, parentNode, script, scripts, _i, _j, _len, _len1, _ref, _ref1;
  14065. scripts = Array.prototype.slice.call(document.body.querySelectorAll('script:not([data-turbolinks-eval="false"])'));
  14066. for (_i = 0, _len = scripts.length; _i < _len; _i++) {
  14067. script = scripts[_i];
  14068. if (!((_ref = script.type) === '' || _ref === 'text/javascript')) {
  14069. continue;
  14070. }
  14071. copy = document.createElement('script');
  14072. _ref1 = script.attributes;
  14073. for (_j = 0, _len1 = _ref1.length; _j < _len1; _j++) {
  14074. attr = _ref1[_j];
  14075. copy.setAttribute(attr.name, attr.value);
  14076. }
  14077. copy.appendChild(document.createTextNode(script.innerHTML));
  14078. parentNode = script.parentNode, nextSibling = script.nextSibling;
  14079. parentNode.removeChild(script);
  14080. parentNode.insertBefore(copy, nextSibling);
  14081. }
  14082. };
  14083. removeNoscriptTags = function(node) {
  14084. node.innerHTML = node.innerHTML.replace(/<noscript[\S\s]*?<\/noscript>/ig, '');
  14085. return node;
  14086. };
  14087. setAutofocusElement = function() {
  14088. var autofocusElement, list;
  14089. autofocusElement = (list = document.querySelectorAll('input[autofocus], textarea[autofocus]'))[list.length - 1];
  14090. if (autofocusElement && document.activeElement !== autofocusElement) {
  14091. return autofocusElement.focus();
  14092. }
  14093. };
  14094. reflectNewUrl = function(url) {
  14095. if ((url = new ComponentUrl(url)).absolute !== referer) {
  14096. return window.history.pushState({
  14097. turbolinks: true,
  14098. url: url.absolute
  14099. }, '', url.absolute);
  14100. }
  14101. };
  14102. reflectRedirectedUrl = function() {
  14103. var location, preservedHash;
  14104. if (location = xhr.getResponseHeader('X-XHR-Redirected-To')) {
  14105. location = new ComponentUrl(location);
  14106. preservedHash = location.hasNoHash() ? document.location.hash : '';
  14107. return window.history.replaceState(currentState, '', location.href + preservedHash);
  14108. }
  14109. };
  14110. rememberReferer = function() {
  14111. return referer = document.location.href;
  14112. };
  14113. rememberCurrentUrl = function() {
  14114. return window.history.replaceState({
  14115. turbolinks: true,
  14116. url: document.location.href
  14117. }, '', document.location.href);
  14118. };
  14119. rememberCurrentState = function() {
  14120. return currentState = window.history.state;
  14121. };
  14122. manuallyTriggerHashChangeForFirefox = function() {
  14123. var url;
  14124. if (navigator.userAgent.match(/Firefox/) && !(url = new ComponentUrl).hasNoHash()) {
  14125. window.history.replaceState(currentState, '', url.withoutHash());
  14126. return document.location.hash = url.hash;
  14127. }
  14128. };
  14129. recallScrollPosition = function(page) {
  14130. return window.scrollTo(page.positionX, page.positionY);
  14131. };
  14132. resetScrollPosition = function() {
  14133. if (document.location.hash) {
  14134. return document.location.href = document.location.href;
  14135. } else {
  14136. return window.scrollTo(0, 0);
  14137. }
  14138. };
  14139. popCookie = function(name) {
  14140. var value, _ref;
  14141. value = ((_ref = document.cookie.match(new RegExp(name + "=(\\w+)"))) != null ? _ref[1].toUpperCase() : void 0) || '';
  14142. document.cookie = name + '=; expires=Thu, 01-Jan-70 00:00:01 GMT; path=/';
  14143. return value;
  14144. };
  14145. triggerEvent = function(name, data) {
  14146. var event;
  14147. event = document.createEvent('Events');
  14148. if (data) {
  14149. event.data = data;
  14150. }
  14151. event.initEvent(name, true, true);
  14152. return document.dispatchEvent(event);
  14153. };
  14154. pageChangePrevented = function() {
  14155. return !triggerEvent('page:before-change');
  14156. };
  14157. processResponse = function() {
  14158. var assetsChanged, clientOrServerError, doc, extractTrackAssets, intersection, validContent;
  14159. clientOrServerError = function() {
  14160. var _ref;
  14161. return (400 <= (_ref = xhr.status) && _ref < 600);
  14162. };
  14163. validContent = function() {
  14164. return xhr.getResponseHeader('Content-Type').match(/^(?:text\/html|application\/xhtml\+xml|application\/xml)(?:;|$)/);
  14165. };
  14166. extractTrackAssets = function(doc) {
  14167. var node, _i, _len, _ref, _results;
  14168. _ref = doc.head.childNodes;
  14169. _results = [];
  14170. for (_i = 0, _len = _ref.length; _i < _len; _i++) {
  14171. node = _ref[_i];
  14172. if ((typeof node.getAttribute === "function" ? node.getAttribute('data-turbolinks-track') : void 0) != null) {
  14173. _results.push(node.getAttribute('src') || node.getAttribute('href'));
  14174. }
  14175. }
  14176. return _results;
  14177. };
  14178. assetsChanged = function(doc) {
  14179. var fetchedAssets;
  14180. loadedAssets || (loadedAssets = extractTrackAssets(document));
  14181. fetchedAssets = extractTrackAssets(doc);
  14182. return fetchedAssets.length !== loadedAssets.length || intersection(fetchedAssets, loadedAssets).length !== loadedAssets.length;
  14183. };
  14184. intersection = function(a, b) {
  14185. var value, _i, _len, _ref, _results;
  14186. if (a.length > b.length) {
  14187. _ref = [b, a], a = _ref[0], b = _ref[1];
  14188. }
  14189. _results = [];
  14190. for (_i = 0, _len = a.length; _i < _len; _i++) {
  14191. value = a[_i];
  14192. if (__indexOf.call(b, value) >= 0) {
  14193. _results.push(value);
  14194. }
  14195. }
  14196. return _results;
  14197. };
  14198. if (!clientOrServerError() && validContent()) {
  14199. doc = createDocument(xhr.responseText);
  14200. if (doc && !assetsChanged(doc)) {
  14201. return doc;
  14202. }
  14203. }
  14204. };
  14205. extractTitleAndBody = function(doc) {
  14206. var title;
  14207. title = doc.querySelector('title');
  14208. return [title != null ? title.textContent : void 0, removeNoscriptTags(doc.body), CSRFToken.get(doc).token, 'runScripts'];
  14209. };
  14210. CSRFToken = {
  14211. get: function(doc) {
  14212. var tag;
  14213. if (doc == null) {
  14214. doc = document;
  14215. }
  14216. return {
  14217. node: tag = doc.querySelector('meta[name="csrf-token"]'),
  14218. token: tag != null ? typeof tag.getAttribute === "function" ? tag.getAttribute('content') : void 0 : void 0
  14219. };
  14220. },
  14221. update: function(latest) {
  14222. var current;
  14223. current = this.get();
  14224. if ((current.token != null) && (latest != null) && current.token !== latest) {
  14225. return current.node.setAttribute('content', latest);
  14226. }
  14227. }
  14228. };
  14229. browserCompatibleDocumentParser = function() {
  14230. var createDocumentUsingDOM, createDocumentUsingParser, createDocumentUsingWrite, e, testDoc, _ref;
  14231. createDocumentUsingParser = function(html) {
  14232. return (new DOMParser).parseFromString(html, 'text/html');
  14233. };
  14234. createDocumentUsingDOM = function(html) {
  14235. var doc;
  14236. doc = document.implementation.createHTMLDocument('');
  14237. doc.documentElement.innerHTML = html;
  14238. return doc;
  14239. };
  14240. createDocumentUsingWrite = function(html) {
  14241. var doc;
  14242. doc = document.implementation.createHTMLDocument('');
  14243. doc.open('replace');
  14244. doc.write(html);
  14245. doc.close();
  14246. return doc;
  14247. };
  14248. try {
  14249. if (window.DOMParser) {
  14250. testDoc = createDocumentUsingParser('<html><body><p>test');
  14251. return createDocumentUsingParser;
  14252. }
  14253. } catch (_error) {
  14254. e = _error;
  14255. testDoc = createDocumentUsingDOM('<html><body><p>test');
  14256. return createDocumentUsingDOM;
  14257. } finally {
  14258. if ((testDoc != null ? (_ref = testDoc.body) != null ? _ref.childNodes.length : void 0 : void 0) !== 1) {
  14259. return createDocumentUsingWrite;
  14260. }
  14261. }
  14262. };
  14263. ComponentUrl = (function() {
  14264. function ComponentUrl(original) {
  14265. this.original = original != null ? original : document.location.href;
  14266. if (this.original.constructor === ComponentUrl) {
  14267. return this.original;
  14268. }
  14269. this._parse();
  14270. }
  14271. ComponentUrl.prototype.withoutHash = function() {
  14272. return this.href.replace(this.hash, '');
  14273. };
  14274. ComponentUrl.prototype.withoutHashForIE10compatibility = function() {
  14275. return this.withoutHash();
  14276. };
  14277. ComponentUrl.prototype.hasNoHash = function() {
  14278. return this.hash.length === 0;
  14279. };
  14280. ComponentUrl.prototype._parse = function() {
  14281. var _ref;
  14282. (this.link != null ? this.link : this.link = document.createElement('a')).href = this.original;
  14283. _ref = this.link, this.href = _ref.href, this.protocol = _ref.protocol, this.host = _ref.host, this.hostname = _ref.hostname, this.port = _ref.port, this.pathname = _ref.pathname, this.search = _ref.search, this.hash = _ref.hash;
  14284. this.origin = [this.protocol, '//', this.hostname].join('');
  14285. if (this.port.length !== 0) {
  14286. this.origin += ":" + this.port;
  14287. }
  14288. this.relative = [this.pathname, this.search, this.hash].join('');
  14289. return this.absolute = this.href;
  14290. };
  14291. return ComponentUrl;
  14292. })();
  14293. Link = (function(_super) {
  14294. __extends(Link, _super);
  14295. Link.HTML_EXTENSIONS = ['html'];
  14296. Link.allowExtensions = function() {
  14297. var extension, extensions, _i, _len;
  14298. extensions = 1 <= arguments.length ? __slice.call(arguments, 0) : [];
  14299. for (_i = 0, _len = extensions.length; _i < _len; _i++) {
  14300. extension = extensions[_i];
  14301. Link.HTML_EXTENSIONS.push(extension);
  14302. }
  14303. return Link.HTML_EXTENSIONS;
  14304. };
  14305. function Link(link) {
  14306. this.link = link;
  14307. if (this.link.constructor === Link) {
  14308. return this.link;
  14309. }
  14310. this.original = this.link.href;
  14311. Link.__super__.constructor.apply(this, arguments);
  14312. }
  14313. Link.prototype.shouldIgnore = function() {
  14314. return this._crossOrigin() || this._anchored() || this._nonHtml() || this._optOut() || this._target();
  14315. };
  14316. Link.prototype._crossOrigin = function() {
  14317. return this.origin !== (new ComponentUrl).origin;
  14318. };
  14319. Link.prototype._anchored = function() {
  14320. var current;
  14321. return ((this.hash && this.withoutHash()) === (current = new ComponentUrl).withoutHash()) || (this.href === current.href + '#');
  14322. };
  14323. Link.prototype._nonHtml = function() {
  14324. return this.pathname.match(/\.[a-z]+$/g) && !this.pathname.match(new RegExp("\\.(?:" + (Link.HTML_EXTENSIONS.join('|')) + ")?$", 'g'));
  14325. };
  14326. Link.prototype._optOut = function() {
  14327. var ignore, link;
  14328. link = this.link;
  14329. while (!(ignore || link === document)) {
  14330. ignore = link.getAttribute('data-no-turbolink') != null;
  14331. link = link.parentNode;
  14332. }
  14333. return ignore;
  14334. };
  14335. Link.prototype._target = function() {
  14336. return this.link.target.length !== 0;
  14337. };
  14338. return Link;
  14339. })(ComponentUrl);
  14340. Click = (function() {
  14341. Click.installHandlerLast = function(event) {
  14342. if (!event.defaultPrevented) {
  14343. document.removeEventListener('click', Click.handle, false);
  14344. return document.addEventListener('click', Click.handle, false);
  14345. }
  14346. };
  14347. Click.handle = function(event) {
  14348. return new Click(event);
  14349. };
  14350. function Click(event) {
  14351. this.event = event;
  14352. if (this.event.defaultPrevented) {
  14353. return;
  14354. }
  14355. this._extractLink();
  14356. if (this._validForTurbolinks()) {
  14357. if (!pageChangePrevented()) {
  14358. visit(this.link.href);
  14359. }
  14360. this.event.preventDefault();
  14361. }
  14362. }
  14363. Click.prototype._extractLink = function() {
  14364. var link;
  14365. link = this.event.target;
  14366. while (!(!link.parentNode || link.nodeName === 'A')) {
  14367. link = link.parentNode;
  14368. }
  14369. if (link.nodeName === 'A' && link.href.length !== 0) {
  14370. return this.link = new Link(link);
  14371. }
  14372. };
  14373. Click.prototype._validForTurbolinks = function() {
  14374. return (this.link != null) && !(this.link.shouldIgnore() || this._nonStandardClick());
  14375. };
  14376. Click.prototype._nonStandardClick = function() {
  14377. return this.event.which > 1 || this.event.metaKey || this.event.ctrlKey || this.event.shiftKey || this.event.altKey;
  14378. };
  14379. return Click;
  14380. })();
  14381. bypassOnLoadPopstate = function(fn) {
  14382. return setTimeout(fn, 500);
  14383. };
  14384. installDocumentReadyPageEventTriggers = function() {
  14385. return document.addEventListener('DOMContentLoaded', (function() {
  14386. triggerEvent('page:change');
  14387. return triggerEvent('page:update');
  14388. }), true);
  14389. };
  14390. installJqueryAjaxSuccessPageUpdateTrigger = function() {
  14391. if (typeof jQuery !== 'undefined') {
  14392. return jQuery(document).on('ajaxSuccess', function(event, xhr, settings) {
  14393. if (!jQuery.trim(xhr.responseText)) {
  14394. return;
  14395. }
  14396. return triggerEvent('page:update');
  14397. });
  14398. }
  14399. };
  14400. installHistoryChangeHandler = function(event) {
  14401. var cachedPage, _ref;
  14402. if ((_ref = event.state) != null ? _ref.turbolinks : void 0) {
  14403. if (cachedPage = pageCache[(new ComponentUrl(event.state.url)).absolute]) {
  14404. cacheCurrentPage();
  14405. return fetchHistory(cachedPage);
  14406. } else {
  14407. return visit(event.target.location.href);
  14408. }
  14409. }
  14410. };
  14411. initializeTurbolinks = function() {
  14412. rememberCurrentUrl();
  14413. rememberCurrentState();
  14414. createDocument = browserCompatibleDocumentParser();
  14415. document.addEventListener('click', Click.installHandlerLast, true);
  14416. window.addEventListener('hashchange', function(event) {
  14417. rememberCurrentUrl();
  14418. return rememberCurrentState();
  14419. }, false);
  14420. return bypassOnLoadPopstate(function() {
  14421. return window.addEventListener('popstate', installHistoryChangeHandler, false);
  14422. });
  14423. };
  14424. historyStateIsDefined = window.history.state !== void 0 || navigator.userAgent.match(/Firefox\/2[6|7]/);
  14425. browserSupportsPushState = window.history && window.history.pushState && window.history.replaceState && historyStateIsDefined;
  14426. browserIsntBuggy = !navigator.userAgent.match(/CriOS\//);
  14427. requestMethodIsSafe = (_ref = popCookie('request_method')) === 'GET' || _ref === '';
  14428. browserSupportsTurbolinks = browserSupportsPushState && browserIsntBuggy && requestMethodIsSafe;
  14429. browserSupportsCustomEvents = document.addEventListener && document.createEvent;
  14430. if (browserSupportsCustomEvents) {
  14431. installDocumentReadyPageEventTriggers();
  14432. installJqueryAjaxSuccessPageUpdateTrigger();
  14433. }
  14434. if (browserSupportsTurbolinks) {
  14435. visit = fetch;
  14436. initializeTurbolinks();
  14437. } else {
  14438. visit = function(url) {
  14439. return document.location.href = url;
  14440. };
  14441. }
  14442. this.Turbolinks = {
  14443. visit: visit,
  14444. pagesCached: pagesCached,
  14445. enableTransitionCache: enableTransitionCache,
  14446. allowLinkExtensions: Link.allowExtensions,
  14447. supported: browserSupportsTurbolinks
  14448. };
  14449. }).call(this);
  14450. (function() {
  14451. this.GoogleAnalytics = (function() {
  14452. function GoogleAnalytics() {}
  14453. GoogleAnalytics.load = function() {
  14454. var firstScript, ga;
  14455. window._gaq = [];
  14456. window._gaq.push(["_setAccount", GoogleAnalytics.analyticsId()]);
  14457. ga = document.createElement("script");
  14458. ga.type = "text/javascript";
  14459. ga.async = true;
  14460. ga.src = ("https:" === document.location.protocol ? "https://ssl" : "http://www") + ".google-analytics.com/ga.js";
  14461. firstScript = document.getElementsByTagName("script")[0];
  14462. firstScript.parentNode.insertBefore(ga, firstScript);
  14463. if (typeof Turbolinks !== 'undefined' && Turbolinks.supported) {
  14464. return document.addEventListener("page:change", (function() {
  14465. return GoogleAnalytics.trackPageview();
  14466. }), true);
  14467. } else {
  14468. return GoogleAnalytics.trackPageview();
  14469. }
  14470. };
  14471. GoogleAnalytics.trackPageview = function(url) {
  14472. if (!GoogleAnalytics.isLocalRequest()) {
  14473. if (url) {
  14474. window._gaq.push(["_trackPageview", url]);
  14475. } else {
  14476. window._gaq.push(["_trackPageview"]);
  14477. }
  14478. return window._gaq.push(["_trackPageLoadTime"]);
  14479. }
  14480. };
  14481. GoogleAnalytics.isLocalRequest = function() {
  14482. return GoogleAnalytics.documentDomainIncludes("local");
  14483. };
  14484. GoogleAnalytics.documentDomainIncludes = function(str) {
  14485. return document.domain.indexOf(str) !== -1;
  14486. };
  14487. GoogleAnalytics.analyticsId = function() {
  14488. return 'UA-58359004-1';
  14489. };
  14490. return GoogleAnalytics;
  14491. })();
  14492. GoogleAnalytics.load();
  14493. }).call(this);
  14494. (function() {
  14495. var attachHandler;
  14496. attachHandler = function() {
  14497. $(".bootstrap_switch").bootstrapSwitch('size', 'large');
  14498. return $('#admin_navbar').affix();
  14499. };
  14500. $(document).ready(attachHandler);
  14501. $(document).on("page:load", attachHandler);
  14502. }).call(this);
  14503. (function() {
  14504. var attachRatingHandler, sendFile;
  14505. attachRatingHandler = function() {
  14506. var summer_note;
  14507. $(".bootstrap_switch").bootstrapSwitch('size', 'large');
  14508. summer_note = $('#post_content');
  14509. summer_note.summernote({
  14510. height: 300,
  14511. onImageUpload: function(files, editor, welEditable) {
  14512. return sendFile(files[0], editor, welEditable);
  14513. }
  14514. });
  14515. summer_note.code(summer_note.val());
  14516. return summer_note.closest('form').submit(function() {
  14517. summer_note.val(summer_note.code());
  14518. return true;
  14519. });
  14520. };
  14521. sendFile = function(file, editor, welEditable) {
  14522. var data;
  14523. data = new FormData();
  14524. data.append("file", file);
  14525. return $.ajax({
  14526. url: '/upload',
  14527. data: data,
  14528. cache: false,
  14529. contentType: false,
  14530. processData: false,
  14531. type: 'POST',
  14532. success: function(data) {
  14533. return editor.insertImage(welEditable, data.url);
  14534. },
  14535. error: function(data) {
  14536. editor.insertImage(welEditable, data.url);
  14537. return alert(data.url);
  14538. }
  14539. });
  14540. };
  14541. $(document).ready(attachRatingHandler);
  14542. $(document).on("page:load", attachRatingHandler);
  14543. }).call(this);
  14544. (function() {
  14545. jQuery(function() {
  14546. $("a[rel~=popover], .has-popover").popover();
  14547. return $("a[rel~=tooltip], .has-tooltip").tooltip();
  14548. });
  14549. }).call(this);
  14550. (function() {
  14551. }).call(this);
  14552. (function() {
  14553. }).call(this);
  14554. (function() {
  14555. }).call(this);
  14556. (function() {
  14557. }).call(this);
  14558. // This is a manifest file that'll be compiled into application.js, which will include all the files
  14559. // listed below.
  14560. //
  14561. // Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
  14562. // or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path.
  14563. //
  14564. // It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
  14565. // compiled file.
  14566. //
  14567. // Read Sprockets README (https://github.com/sstephenson/sprockets#sprockets-directives) for details
  14568. // about supported directives.
  14569. //
  14570. ;