Brak opisu

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168
  1. /*! jQuery UI - v1.11.4 - 2016-01-27
  2. * http://jqueryui.com
  3. * Includes: core.js, widget.js, mouse.js, position.js, autocomplete.js, datepicker.js, menu.js, selectmenu.js, slider.js
  4. * Copyright jQuery Foundation and other contributors; Licensed MIT */
  5. (function( factory ) {
  6. if ( typeof define === "function" && define.amd ) {
  7. // AMD. Register as an anonymous module.
  8. define([ "jquery" ], factory );
  9. } else {
  10. // Browser globals
  11. factory( jQuery );
  12. }
  13. }(function( $ ) {
  14. /*!
  15. * jQuery UI Core 1.11.4
  16. * http://jqueryui.com
  17. *
  18. * Copyright jQuery Foundation and other contributors
  19. * Released under the MIT license.
  20. * http://jquery.org/license
  21. *
  22. * http://api.jqueryui.com/category/ui-core/
  23. */
  24. // $.ui might exist from components with no dependencies, e.g., $.ui.position
  25. $.ui = $.ui || {};
  26. $.extend( $.ui, {
  27. version: "1.11.4",
  28. keyCode: {
  29. BACKSPACE: 8,
  30. COMMA: 188,
  31. DELETE: 46,
  32. DOWN: 40,
  33. END: 35,
  34. ENTER: 13,
  35. ESCAPE: 27,
  36. HOME: 36,
  37. LEFT: 37,
  38. PAGE_DOWN: 34,
  39. PAGE_UP: 33,
  40. PERIOD: 190,
  41. RIGHT: 39,
  42. SPACE: 32,
  43. TAB: 9,
  44. UP: 38
  45. }
  46. });
  47. // plugins
  48. $.fn.extend({
  49. scrollParent: function( includeHidden ) {
  50. var position = this.css( "position" ),
  51. excludeStaticParent = position === "absolute",
  52. overflowRegex = includeHidden ? /(auto|scroll|hidden)/ : /(auto|scroll)/,
  53. scrollParent = this.parents().filter( function() {
  54. var parent = $( this );
  55. if ( excludeStaticParent && parent.css( "position" ) === "static" ) {
  56. return false;
  57. }
  58. return overflowRegex.test( parent.css( "overflow" ) + parent.css( "overflow-y" ) + parent.css( "overflow-x" ) );
  59. }).eq( 0 );
  60. return position === "fixed" || !scrollParent.length ? $( this[ 0 ].ownerDocument || document ) : scrollParent;
  61. },
  62. uniqueId: (function() {
  63. var uuid = 0;
  64. return function() {
  65. return this.each(function() {
  66. if ( !this.id ) {
  67. this.id = "ui-id-" + ( ++uuid );
  68. }
  69. });
  70. };
  71. })(),
  72. removeUniqueId: function() {
  73. return this.each(function() {
  74. if ( /^ui-id-\d+$/.test( this.id ) ) {
  75. $( this ).removeAttr( "id" );
  76. }
  77. });
  78. }
  79. });
  80. // selectors
  81. function focusable( element, isTabIndexNotNaN ) {
  82. var map, mapName, img,
  83. nodeName = element.nodeName.toLowerCase();
  84. if ( "area" === nodeName ) {
  85. map = element.parentNode;
  86. mapName = map.name;
  87. if ( !element.href || !mapName || map.nodeName.toLowerCase() !== "map" ) {
  88. return false;
  89. }
  90. img = $( "img[usemap='#" + mapName + "']" )[ 0 ];
  91. return !!img && visible( img );
  92. }
  93. return ( /^(input|select|textarea|button|object)$/.test( nodeName ) ?
  94. !element.disabled :
  95. "a" === nodeName ?
  96. element.href || isTabIndexNotNaN :
  97. isTabIndexNotNaN) &&
  98. // the element and all of its ancestors must be visible
  99. visible( element );
  100. }
  101. function visible( element ) {
  102. return $.expr.filters.visible( element ) &&
  103. !$( element ).parents().addBack().filter(function() {
  104. return $.css( this, "visibility" ) === "hidden";
  105. }).length;
  106. }
  107. $.extend( $.expr[ ":" ], {
  108. data: $.expr.createPseudo ?
  109. $.expr.createPseudo(function( dataName ) {
  110. return function( elem ) {
  111. return !!$.data( elem, dataName );
  112. };
  113. }) :
  114. // support: jQuery <1.8
  115. function( elem, i, match ) {
  116. return !!$.data( elem, match[ 3 ] );
  117. },
  118. focusable: function( element ) {
  119. return focusable( element, !isNaN( $.attr( element, "tabindex" ) ) );
  120. },
  121. tabbable: function( element ) {
  122. var tabIndex = $.attr( element, "tabindex" ),
  123. isTabIndexNaN = isNaN( tabIndex );
  124. return ( isTabIndexNaN || tabIndex >= 0 ) && focusable( element, !isTabIndexNaN );
  125. }
  126. });
  127. // support: jQuery <1.8
  128. if ( !$( "<a>" ).outerWidth( 1 ).jquery ) {
  129. $.each( [ "Width", "Height" ], function( i, name ) {
  130. var side = name === "Width" ? [ "Left", "Right" ] : [ "Top", "Bottom" ],
  131. type = name.toLowerCase(),
  132. orig = {
  133. innerWidth: $.fn.innerWidth,
  134. innerHeight: $.fn.innerHeight,
  135. outerWidth: $.fn.outerWidth,
  136. outerHeight: $.fn.outerHeight
  137. };
  138. function reduce( elem, size, border, margin ) {
  139. $.each( side, function() {
  140. size -= parseFloat( $.css( elem, "padding" + this ) ) || 0;
  141. if ( border ) {
  142. size -= parseFloat( $.css( elem, "border" + this + "Width" ) ) || 0;
  143. }
  144. if ( margin ) {
  145. size -= parseFloat( $.css( elem, "margin" + this ) ) || 0;
  146. }
  147. });
  148. return size;
  149. }
  150. $.fn[ "inner" + name ] = function( size ) {
  151. if ( size === undefined ) {
  152. return orig[ "inner" + name ].call( this );
  153. }
  154. return this.each(function() {
  155. $( this ).css( type, reduce( this, size ) + "px" );
  156. });
  157. };
  158. $.fn[ "outer" + name] = function( size, margin ) {
  159. if ( typeof size !== "number" ) {
  160. return orig[ "outer" + name ].call( this, size );
  161. }
  162. return this.each(function() {
  163. $( this).css( type, reduce( this, size, true, margin ) + "px" );
  164. });
  165. };
  166. });
  167. }
  168. // support: jQuery <1.8
  169. if ( !$.fn.addBack ) {
  170. $.fn.addBack = function( selector ) {
  171. return this.add( selector == null ?
  172. this.prevObject : this.prevObject.filter( selector )
  173. );
  174. };
  175. }
  176. // support: jQuery 1.6.1, 1.6.2 (http://bugs.jquery.com/ticket/9413)
  177. if ( $( "<a>" ).data( "a-b", "a" ).removeData( "a-b" ).data( "a-b" ) ) {
  178. $.fn.removeData = (function( removeData ) {
  179. return function( key ) {
  180. if ( arguments.length ) {
  181. return removeData.call( this, $.camelCase( key ) );
  182. } else {
  183. return removeData.call( this );
  184. }
  185. };
  186. })( $.fn.removeData );
  187. }
  188. // deprecated
  189. $.ui.ie = !!/msie [\w.]+/.exec( navigator.userAgent.toLowerCase() );
  190. $.fn.extend({
  191. focus: (function( orig ) {
  192. return function( delay, fn ) {
  193. return typeof delay === "number" ?
  194. this.each(function() {
  195. var elem = this;
  196. setTimeout(function() {
  197. $( elem ).focus();
  198. if ( fn ) {
  199. fn.call( elem );
  200. }
  201. }, delay );
  202. }) :
  203. orig.apply( this, arguments );
  204. };
  205. })( $.fn.focus ),
  206. disableSelection: (function() {
  207. var eventType = "onselectstart" in document.createElement( "div" ) ?
  208. "selectstart" :
  209. "mousedown";
  210. return function() {
  211. return this.bind( eventType + ".ui-disableSelection", function( event ) {
  212. event.preventDefault();
  213. });
  214. };
  215. })(),
  216. enableSelection: function() {
  217. return this.unbind( ".ui-disableSelection" );
  218. },
  219. zIndex: function( zIndex ) {
  220. if ( zIndex !== undefined ) {
  221. return this.css( "zIndex", zIndex );
  222. }
  223. if ( this.length ) {
  224. var elem = $( this[ 0 ] ), position, value;
  225. while ( elem.length && elem[ 0 ] !== document ) {
  226. // Ignore z-index if position is set to a value where z-index is ignored by the browser
  227. // This makes behavior of this function consistent across browsers
  228. // WebKit always returns auto if the element is positioned
  229. position = elem.css( "position" );
  230. if ( position === "absolute" || position === "relative" || position === "fixed" ) {
  231. // IE returns 0 when zIndex is not specified
  232. // other browsers return a string
  233. // we ignore the case of nested elements with an explicit value of 0
  234. // <div style="z-index: -10;"><div style="z-index: 0;"></div></div>
  235. value = parseInt( elem.css( "zIndex" ), 10 );
  236. if ( !isNaN( value ) && value !== 0 ) {
  237. return value;
  238. }
  239. }
  240. elem = elem.parent();
  241. }
  242. }
  243. return 0;
  244. }
  245. });
  246. // $.ui.plugin is deprecated. Use $.widget() extensions instead.
  247. $.ui.plugin = {
  248. add: function( module, option, set ) {
  249. var i,
  250. proto = $.ui[ module ].prototype;
  251. for ( i in set ) {
  252. proto.plugins[ i ] = proto.plugins[ i ] || [];
  253. proto.plugins[ i ].push( [ option, set[ i ] ] );
  254. }
  255. },
  256. call: function( instance, name, args, allowDisconnected ) {
  257. var i,
  258. set = instance.plugins[ name ];
  259. if ( !set ) {
  260. return;
  261. }
  262. if ( !allowDisconnected && ( !instance.element[ 0 ].parentNode || instance.element[ 0 ].parentNode.nodeType === 11 ) ) {
  263. return;
  264. }
  265. for ( i = 0; i < set.length; i++ ) {
  266. if ( instance.options[ set[ i ][ 0 ] ] ) {
  267. set[ i ][ 1 ].apply( instance.element, args );
  268. }
  269. }
  270. }
  271. };
  272. /*!
  273. * jQuery UI Widget 1.11.4
  274. * http://jqueryui.com
  275. *
  276. * Copyright jQuery Foundation and other contributors
  277. * Released under the MIT license.
  278. * http://jquery.org/license
  279. *
  280. * http://api.jqueryui.com/jQuery.widget/
  281. */
  282. var widget_uuid = 0,
  283. widget_slice = Array.prototype.slice;
  284. $.cleanData = (function( orig ) {
  285. return function( elems ) {
  286. var events, elem, i;
  287. for ( i = 0; (elem = elems[i]) != null; i++ ) {
  288. try {
  289. // Only trigger remove when necessary to save time
  290. events = $._data( elem, "events" );
  291. if ( events && events.remove ) {
  292. $( elem ).triggerHandler( "remove" );
  293. }
  294. // http://bugs.jquery.com/ticket/8235
  295. } catch ( e ) {}
  296. }
  297. orig( elems );
  298. };
  299. })( $.cleanData );
  300. $.widget = function( name, base, prototype ) {
  301. var fullName, existingConstructor, constructor, basePrototype,
  302. // proxiedPrototype allows the provided prototype to remain unmodified
  303. // so that it can be used as a mixin for multiple widgets (#8876)
  304. proxiedPrototype = {},
  305. namespace = name.split( "." )[ 0 ];
  306. name = name.split( "." )[ 1 ];
  307. fullName = namespace + "-" + name;
  308. if ( !prototype ) {
  309. prototype = base;
  310. base = $.Widget;
  311. }
  312. // create selector for plugin
  313. $.expr[ ":" ][ fullName.toLowerCase() ] = function( elem ) {
  314. return !!$.data( elem, fullName );
  315. };
  316. $[ namespace ] = $[ namespace ] || {};
  317. existingConstructor = $[ namespace ][ name ];
  318. constructor = $[ namespace ][ name ] = function( options, element ) {
  319. // allow instantiation without "new" keyword
  320. if ( !this._createWidget ) {
  321. return new constructor( options, element );
  322. }
  323. // allow instantiation without initializing for simple inheritance
  324. // must use "new" keyword (the code above always passes args)
  325. if ( arguments.length ) {
  326. this._createWidget( options, element );
  327. }
  328. };
  329. // extend with the existing constructor to carry over any static properties
  330. $.extend( constructor, existingConstructor, {
  331. version: prototype.version,
  332. // copy the object used to create the prototype in case we need to
  333. // redefine the widget later
  334. _proto: $.extend( {}, prototype ),
  335. // track widgets that inherit from this widget in case this widget is
  336. // redefined after a widget inherits from it
  337. _childConstructors: []
  338. });
  339. basePrototype = new base();
  340. // we need to make the options hash a property directly on the new instance
  341. // otherwise we'll modify the options hash on the prototype that we're
  342. // inheriting from
  343. basePrototype.options = $.widget.extend( {}, basePrototype.options );
  344. $.each( prototype, function( prop, value ) {
  345. if ( !$.isFunction( value ) ) {
  346. proxiedPrototype[ prop ] = value;
  347. return;
  348. }
  349. proxiedPrototype[ prop ] = (function() {
  350. var _super = function() {
  351. return base.prototype[ prop ].apply( this, arguments );
  352. },
  353. _superApply = function( args ) {
  354. return base.prototype[ prop ].apply( this, args );
  355. };
  356. return function() {
  357. var __super = this._super,
  358. __superApply = this._superApply,
  359. returnValue;
  360. this._super = _super;
  361. this._superApply = _superApply;
  362. returnValue = value.apply( this, arguments );
  363. this._super = __super;
  364. this._superApply = __superApply;
  365. return returnValue;
  366. };
  367. })();
  368. });
  369. constructor.prototype = $.widget.extend( basePrototype, {
  370. // TODO: remove support for widgetEventPrefix
  371. // always use the name + a colon as the prefix, e.g., draggable:start
  372. // don't prefix for widgets that aren't DOM-based
  373. widgetEventPrefix: existingConstructor ? (basePrototype.widgetEventPrefix || name) : name
  374. }, proxiedPrototype, {
  375. constructor: constructor,
  376. namespace: namespace,
  377. widgetName: name,
  378. widgetFullName: fullName
  379. });
  380. // If this widget is being redefined then we need to find all widgets that
  381. // are inheriting from it and redefine all of them so that they inherit from
  382. // the new version of this widget. We're essentially trying to replace one
  383. // level in the prototype chain.
  384. if ( existingConstructor ) {
  385. $.each( existingConstructor._childConstructors, function( i, child ) {
  386. var childPrototype = child.prototype;
  387. // redefine the child widget using the same prototype that was
  388. // originally used, but inherit from the new version of the base
  389. $.widget( childPrototype.namespace + "." + childPrototype.widgetName, constructor, child._proto );
  390. });
  391. // remove the list of existing child constructors from the old constructor
  392. // so the old child constructors can be garbage collected
  393. delete existingConstructor._childConstructors;
  394. } else {
  395. base._childConstructors.push( constructor );
  396. }
  397. $.widget.bridge( name, constructor );
  398. return constructor;
  399. };
  400. $.widget.extend = function( target ) {
  401. var input = widget_slice.call( arguments, 1 ),
  402. inputIndex = 0,
  403. inputLength = input.length,
  404. key,
  405. value;
  406. for ( ; inputIndex < inputLength; inputIndex++ ) {
  407. for ( key in input[ inputIndex ] ) {
  408. value = input[ inputIndex ][ key ];
  409. if ( input[ inputIndex ].hasOwnProperty( key ) && value !== undefined ) {
  410. // Clone objects
  411. if ( $.isPlainObject( value ) ) {
  412. target[ key ] = $.isPlainObject( target[ key ] ) ?
  413. $.widget.extend( {}, target[ key ], value ) :
  414. // Don't extend strings, arrays, etc. with objects
  415. $.widget.extend( {}, value );
  416. // Copy everything else by reference
  417. } else {
  418. target[ key ] = value;
  419. }
  420. }
  421. }
  422. }
  423. return target;
  424. };
  425. $.widget.bridge = function( name, object ) {
  426. var fullName = object.prototype.widgetFullName || name;
  427. $.fn[ name ] = function( options ) {
  428. var isMethodCall = typeof options === "string",
  429. args = widget_slice.call( arguments, 1 ),
  430. returnValue = this;
  431. if ( isMethodCall ) {
  432. this.each(function() {
  433. var methodValue,
  434. instance = $.data( this, fullName );
  435. if ( options === "instance" ) {
  436. returnValue = instance;
  437. return false;
  438. }
  439. if ( !instance ) {
  440. return $.error( "cannot call methods on " + name + " prior to initialization; " +
  441. "attempted to call method '" + options + "'" );
  442. }
  443. if ( !$.isFunction( instance[options] ) || options.charAt( 0 ) === "_" ) {
  444. return $.error( "no such method '" + options + "' for " + name + " widget instance" );
  445. }
  446. methodValue = instance[ options ].apply( instance, args );
  447. if ( methodValue !== instance && methodValue !== undefined ) {
  448. returnValue = methodValue && methodValue.jquery ?
  449. returnValue.pushStack( methodValue.get() ) :
  450. methodValue;
  451. return false;
  452. }
  453. });
  454. } else {
  455. // Allow multiple hashes to be passed on init
  456. if ( args.length ) {
  457. options = $.widget.extend.apply( null, [ options ].concat(args) );
  458. }
  459. this.each(function() {
  460. var instance = $.data( this, fullName );
  461. if ( instance ) {
  462. instance.option( options || {} );
  463. if ( instance._init ) {
  464. instance._init();
  465. }
  466. } else {
  467. $.data( this, fullName, new object( options, this ) );
  468. }
  469. });
  470. }
  471. return returnValue;
  472. };
  473. };
  474. $.Widget = function( /* options, element */ ) {};
  475. $.Widget._childConstructors = [];
  476. $.Widget.prototype = {
  477. widgetName: "widget",
  478. widgetEventPrefix: "",
  479. defaultElement: "<div>",
  480. options: {
  481. disabled: false,
  482. // callbacks
  483. create: null
  484. },
  485. _createWidget: function( options, element ) {
  486. element = $( element || this.defaultElement || this )[ 0 ];
  487. this.element = $( element );
  488. this.uuid = widget_uuid++;
  489. this.eventNamespace = "." + this.widgetName + this.uuid;
  490. this.bindings = $();
  491. this.hoverable = $();
  492. this.focusable = $();
  493. if ( element !== this ) {
  494. $.data( element, this.widgetFullName, this );
  495. this._on( true, this.element, {
  496. remove: function( event ) {
  497. if ( event.target === element ) {
  498. this.destroy();
  499. }
  500. }
  501. });
  502. this.document = $( element.style ?
  503. // element within the document
  504. element.ownerDocument :
  505. // element is window or document
  506. element.document || element );
  507. this.window = $( this.document[0].defaultView || this.document[0].parentWindow );
  508. }
  509. this.options = $.widget.extend( {},
  510. this.options,
  511. this._getCreateOptions(),
  512. options );
  513. this._create();
  514. this._trigger( "create", null, this._getCreateEventData() );
  515. this._init();
  516. },
  517. _getCreateOptions: $.noop,
  518. _getCreateEventData: $.noop,
  519. _create: $.noop,
  520. _init: $.noop,
  521. destroy: function() {
  522. this._destroy();
  523. // we can probably remove the unbind calls in 2.0
  524. // all event bindings should go through this._on()
  525. this.element
  526. .unbind( this.eventNamespace )
  527. .removeData( this.widgetFullName )
  528. // support: jquery <1.6.3
  529. // http://bugs.jquery.com/ticket/9413
  530. .removeData( $.camelCase( this.widgetFullName ) );
  531. this.widget()
  532. .unbind( this.eventNamespace )
  533. .removeAttr( "aria-disabled" )
  534. .removeClass(
  535. this.widgetFullName + "-disabled " +
  536. "ui-state-disabled" );
  537. // clean up events and states
  538. this.bindings.unbind( this.eventNamespace );
  539. this.hoverable.removeClass( "ui-state-hover" );
  540. this.focusable.removeClass( "ui-state-focus" );
  541. },
  542. _destroy: $.noop,
  543. widget: function() {
  544. return this.element;
  545. },
  546. option: function( key, value ) {
  547. var options = key,
  548. parts,
  549. curOption,
  550. i;
  551. if ( arguments.length === 0 ) {
  552. // don't return a reference to the internal hash
  553. return $.widget.extend( {}, this.options );
  554. }
  555. if ( typeof key === "string" ) {
  556. // handle nested keys, e.g., "foo.bar" => { foo: { bar: ___ } }
  557. options = {};
  558. parts = key.split( "." );
  559. key = parts.shift();
  560. if ( parts.length ) {
  561. curOption = options[ key ] = $.widget.extend( {}, this.options[ key ] );
  562. for ( i = 0; i < parts.length - 1; i++ ) {
  563. curOption[ parts[ i ] ] = curOption[ parts[ i ] ] || {};
  564. curOption = curOption[ parts[ i ] ];
  565. }
  566. key = parts.pop();
  567. if ( arguments.length === 1 ) {
  568. return curOption[ key ] === undefined ? null : curOption[ key ];
  569. }
  570. curOption[ key ] = value;
  571. } else {
  572. if ( arguments.length === 1 ) {
  573. return this.options[ key ] === undefined ? null : this.options[ key ];
  574. }
  575. options[ key ] = value;
  576. }
  577. }
  578. this._setOptions( options );
  579. return this;
  580. },
  581. _setOptions: function( options ) {
  582. var key;
  583. for ( key in options ) {
  584. this._setOption( key, options[ key ] );
  585. }
  586. return this;
  587. },
  588. _setOption: function( key, value ) {
  589. this.options[ key ] = value;
  590. if ( key === "disabled" ) {
  591. this.widget()
  592. .toggleClass( this.widgetFullName + "-disabled", !!value );
  593. // If the widget is becoming disabled, then nothing is interactive
  594. if ( value ) {
  595. this.hoverable.removeClass( "ui-state-hover" );
  596. this.focusable.removeClass( "ui-state-focus" );
  597. }
  598. }
  599. return this;
  600. },
  601. enable: function() {
  602. return this._setOptions({ disabled: false });
  603. },
  604. disable: function() {
  605. return this._setOptions({ disabled: true });
  606. },
  607. _on: function( suppressDisabledCheck, element, handlers ) {
  608. var delegateElement,
  609. instance = this;
  610. // no suppressDisabledCheck flag, shuffle arguments
  611. if ( typeof suppressDisabledCheck !== "boolean" ) {
  612. handlers = element;
  613. element = suppressDisabledCheck;
  614. suppressDisabledCheck = false;
  615. }
  616. // no element argument, shuffle and use this.element
  617. if ( !handlers ) {
  618. handlers = element;
  619. element = this.element;
  620. delegateElement = this.widget();
  621. } else {
  622. element = delegateElement = $( element );
  623. this.bindings = this.bindings.add( element );
  624. }
  625. $.each( handlers, function( event, handler ) {
  626. function handlerProxy() {
  627. // allow widgets to customize the disabled handling
  628. // - disabled as an array instead of boolean
  629. // - disabled class as method for disabling individual parts
  630. if ( !suppressDisabledCheck &&
  631. ( instance.options.disabled === true ||
  632. $( this ).hasClass( "ui-state-disabled" ) ) ) {
  633. return;
  634. }
  635. return ( typeof handler === "string" ? instance[ handler ] : handler )
  636. .apply( instance, arguments );
  637. }
  638. // copy the guid so direct unbinding works
  639. if ( typeof handler !== "string" ) {
  640. handlerProxy.guid = handler.guid =
  641. handler.guid || handlerProxy.guid || $.guid++;
  642. }
  643. var match = event.match( /^([\w:-]*)\s*(.*)$/ ),
  644. eventName = match[1] + instance.eventNamespace,
  645. selector = match[2];
  646. if ( selector ) {
  647. delegateElement.delegate( selector, eventName, handlerProxy );
  648. } else {
  649. element.bind( eventName, handlerProxy );
  650. }
  651. });
  652. },
  653. _off: function( element, eventName ) {
  654. eventName = (eventName || "").split( " " ).join( this.eventNamespace + " " ) +
  655. this.eventNamespace;
  656. element.unbind( eventName ).undelegate( eventName );
  657. // Clear the stack to avoid memory leaks (#10056)
  658. this.bindings = $( this.bindings.not( element ).get() );
  659. this.focusable = $( this.focusable.not( element ).get() );
  660. this.hoverable = $( this.hoverable.not( element ).get() );
  661. },
  662. _delay: function( handler, delay ) {
  663. function handlerProxy() {
  664. return ( typeof handler === "string" ? instance[ handler ] : handler )
  665. .apply( instance, arguments );
  666. }
  667. var instance = this;
  668. return setTimeout( handlerProxy, delay || 0 );
  669. },
  670. _hoverable: function( element ) {
  671. this.hoverable = this.hoverable.add( element );
  672. this._on( element, {
  673. mouseenter: function( event ) {
  674. $( event.currentTarget ).addClass( "ui-state-hover" );
  675. },
  676. mouseleave: function( event ) {
  677. $( event.currentTarget ).removeClass( "ui-state-hover" );
  678. }
  679. });
  680. },
  681. _focusable: function( element ) {
  682. this.focusable = this.focusable.add( element );
  683. this._on( element, {
  684. focusin: function( event ) {
  685. $( event.currentTarget ).addClass( "ui-state-focus" );
  686. },
  687. focusout: function( event ) {
  688. $( event.currentTarget ).removeClass( "ui-state-focus" );
  689. }
  690. });
  691. },
  692. _trigger: function( type, event, data ) {
  693. var prop, orig,
  694. callback = this.options[ type ];
  695. data = data || {};
  696. event = $.Event( event );
  697. event.type = ( type === this.widgetEventPrefix ?
  698. type :
  699. this.widgetEventPrefix + type ).toLowerCase();
  700. // the original event may come from any element
  701. // so we need to reset the target on the new event
  702. event.target = this.element[ 0 ];
  703. // copy original event properties over to the new event
  704. orig = event.originalEvent;
  705. if ( orig ) {
  706. for ( prop in orig ) {
  707. if ( !( prop in event ) ) {
  708. event[ prop ] = orig[ prop ];
  709. }
  710. }
  711. }
  712. this.element.trigger( event, data );
  713. return !( $.isFunction( callback ) &&
  714. callback.apply( this.element[0], [ event ].concat( data ) ) === false ||
  715. event.isDefaultPrevented() );
  716. }
  717. };
  718. $.each( { show: "fadeIn", hide: "fadeOut" }, function( method, defaultEffect ) {
  719. $.Widget.prototype[ "_" + method ] = function( element, options, callback ) {
  720. if ( typeof options === "string" ) {
  721. options = { effect: options };
  722. }
  723. var hasOptions,
  724. effectName = !options ?
  725. method :
  726. options === true || typeof options === "number" ?
  727. defaultEffect :
  728. options.effect || defaultEffect;
  729. options = options || {};
  730. if ( typeof options === "number" ) {
  731. options = { duration: options };
  732. }
  733. hasOptions = !$.isEmptyObject( options );
  734. options.complete = callback;
  735. if ( options.delay ) {
  736. element.delay( options.delay );
  737. }
  738. if ( hasOptions && $.effects && $.effects.effect[ effectName ] ) {
  739. element[ method ]( options );
  740. } else if ( effectName !== method && element[ effectName ] ) {
  741. element[ effectName ]( options.duration, options.easing, callback );
  742. } else {
  743. element.queue(function( next ) {
  744. $( this )[ method ]();
  745. if ( callback ) {
  746. callback.call( element[ 0 ] );
  747. }
  748. next();
  749. });
  750. }
  751. };
  752. });
  753. var widget = $.widget;
  754. /*!
  755. * jQuery UI Mouse 1.11.4
  756. * http://jqueryui.com
  757. *
  758. * Copyright jQuery Foundation and other contributors
  759. * Released under the MIT license.
  760. * http://jquery.org/license
  761. *
  762. * http://api.jqueryui.com/mouse/
  763. */
  764. var mouseHandled = false;
  765. $( document ).mouseup( function() {
  766. mouseHandled = false;
  767. });
  768. var mouse = $.widget("ui.mouse", {
  769. version: "1.11.4",
  770. options: {
  771. cancel: "input,textarea,button,select,option",
  772. distance: 1,
  773. delay: 0
  774. },
  775. _mouseInit: function() {
  776. var that = this;
  777. this.element
  778. .bind("mousedown." + this.widgetName, function(event) {
  779. return that._mouseDown(event);
  780. })
  781. .bind("click." + this.widgetName, function(event) {
  782. if (true === $.data(event.target, that.widgetName + ".preventClickEvent")) {
  783. $.removeData(event.target, that.widgetName + ".preventClickEvent");
  784. event.stopImmediatePropagation();
  785. return false;
  786. }
  787. });
  788. this.started = false;
  789. },
  790. // TODO: make sure destroying one instance of mouse doesn't mess with
  791. // other instances of mouse
  792. _mouseDestroy: function() {
  793. this.element.unbind("." + this.widgetName);
  794. if ( this._mouseMoveDelegate ) {
  795. this.document
  796. .unbind("mousemove." + this.widgetName, this._mouseMoveDelegate)
  797. .unbind("mouseup." + this.widgetName, this._mouseUpDelegate);
  798. }
  799. },
  800. _mouseDown: function(event) {
  801. // don't let more than one widget handle mouseStart
  802. if ( mouseHandled ) {
  803. return;
  804. }
  805. this._mouseMoved = false;
  806. // we may have missed mouseup (out of window)
  807. (this._mouseStarted && this._mouseUp(event));
  808. this._mouseDownEvent = event;
  809. var that = this,
  810. btnIsLeft = (event.which === 1),
  811. // event.target.nodeName works around a bug in IE 8 with
  812. // disabled inputs (#7620)
  813. elIsCancel = (typeof this.options.cancel === "string" && event.target.nodeName ? $(event.target).closest(this.options.cancel).length : false);
  814. if (!btnIsLeft || elIsCancel || !this._mouseCapture(event)) {
  815. return true;
  816. }
  817. this.mouseDelayMet = !this.options.delay;
  818. if (!this.mouseDelayMet) {
  819. this._mouseDelayTimer = setTimeout(function() {
  820. that.mouseDelayMet = true;
  821. }, this.options.delay);
  822. }
  823. if (this._mouseDistanceMet(event) && this._mouseDelayMet(event)) {
  824. this._mouseStarted = (this._mouseStart(event) !== false);
  825. if (!this._mouseStarted) {
  826. event.preventDefault();
  827. return true;
  828. }
  829. }
  830. // Click event may never have fired (Gecko & Opera)
  831. if (true === $.data(event.target, this.widgetName + ".preventClickEvent")) {
  832. $.removeData(event.target, this.widgetName + ".preventClickEvent");
  833. }
  834. // these delegates are required to keep context
  835. this._mouseMoveDelegate = function(event) {
  836. return that._mouseMove(event);
  837. };
  838. this._mouseUpDelegate = function(event) {
  839. return that._mouseUp(event);
  840. };
  841. this.document
  842. .bind( "mousemove." + this.widgetName, this._mouseMoveDelegate )
  843. .bind( "mouseup." + this.widgetName, this._mouseUpDelegate );
  844. event.preventDefault();
  845. mouseHandled = true;
  846. return true;
  847. },
  848. _mouseMove: function(event) {
  849. // Only check for mouseups outside the document if you've moved inside the document
  850. // at least once. This prevents the firing of mouseup in the case of IE<9, which will
  851. // fire a mousemove event if content is placed under the cursor. See #7778
  852. // Support: IE <9
  853. if ( this._mouseMoved ) {
  854. // IE mouseup check - mouseup happened when mouse was out of window
  855. if ($.ui.ie && ( !document.documentMode || document.documentMode < 9 ) && !event.button) {
  856. return this._mouseUp(event);
  857. // Iframe mouseup check - mouseup occurred in another document
  858. } else if ( !event.which ) {
  859. return this._mouseUp( event );
  860. }
  861. }
  862. if ( event.which || event.button ) {
  863. this._mouseMoved = true;
  864. }
  865. if (this._mouseStarted) {
  866. this._mouseDrag(event);
  867. return event.preventDefault();
  868. }
  869. if (this._mouseDistanceMet(event) && this._mouseDelayMet(event)) {
  870. this._mouseStarted =
  871. (this._mouseStart(this._mouseDownEvent, event) !== false);
  872. (this._mouseStarted ? this._mouseDrag(event) : this._mouseUp(event));
  873. }
  874. return !this._mouseStarted;
  875. },
  876. _mouseUp: function(event) {
  877. this.document
  878. .unbind( "mousemove." + this.widgetName, this._mouseMoveDelegate )
  879. .unbind( "mouseup." + this.widgetName, this._mouseUpDelegate );
  880. if (this._mouseStarted) {
  881. this._mouseStarted = false;
  882. if (event.target === this._mouseDownEvent.target) {
  883. $.data(event.target, this.widgetName + ".preventClickEvent", true);
  884. }
  885. this._mouseStop(event);
  886. }
  887. mouseHandled = false;
  888. return false;
  889. },
  890. _mouseDistanceMet: function(event) {
  891. return (Math.max(
  892. Math.abs(this._mouseDownEvent.pageX - event.pageX),
  893. Math.abs(this._mouseDownEvent.pageY - event.pageY)
  894. ) >= this.options.distance
  895. );
  896. },
  897. _mouseDelayMet: function(/* event */) {
  898. return this.mouseDelayMet;
  899. },
  900. // These are placeholder methods, to be overriden by extending plugin
  901. _mouseStart: function(/* event */) {},
  902. _mouseDrag: function(/* event */) {},
  903. _mouseStop: function(/* event */) {},
  904. _mouseCapture: function(/* event */) { return true; }
  905. });
  906. /*!
  907. * jQuery UI Position 1.11.4
  908. * http://jqueryui.com
  909. *
  910. * Copyright jQuery Foundation and other contributors
  911. * Released under the MIT license.
  912. * http://jquery.org/license
  913. *
  914. * http://api.jqueryui.com/position/
  915. */
  916. (function() {
  917. $.ui = $.ui || {};
  918. var cachedScrollbarWidth, supportsOffsetFractions,
  919. max = Math.max,
  920. abs = Math.abs,
  921. round = Math.round,
  922. rhorizontal = /left|center|right/,
  923. rvertical = /top|center|bottom/,
  924. roffset = /[\+\-]\d+(\.[\d]+)?%?/,
  925. rposition = /^\w+/,
  926. rpercent = /%$/,
  927. _position = $.fn.position;
  928. function getOffsets( offsets, width, height ) {
  929. return [
  930. parseFloat( offsets[ 0 ] ) * ( rpercent.test( offsets[ 0 ] ) ? width / 100 : 1 ),
  931. parseFloat( offsets[ 1 ] ) * ( rpercent.test( offsets[ 1 ] ) ? height / 100 : 1 )
  932. ];
  933. }
  934. function parseCss( element, property ) {
  935. return parseInt( $.css( element, property ), 10 ) || 0;
  936. }
  937. function getDimensions( elem ) {
  938. var raw = elem[0];
  939. if ( raw.nodeType === 9 ) {
  940. return {
  941. width: elem.width(),
  942. height: elem.height(),
  943. offset: { top: 0, left: 0 }
  944. };
  945. }
  946. if ( $.isWindow( raw ) ) {
  947. return {
  948. width: elem.width(),
  949. height: elem.height(),
  950. offset: { top: elem.scrollTop(), left: elem.scrollLeft() }
  951. };
  952. }
  953. if ( raw.preventDefault ) {
  954. return {
  955. width: 0,
  956. height: 0,
  957. offset: { top: raw.pageY, left: raw.pageX }
  958. };
  959. }
  960. return {
  961. width: elem.outerWidth(),
  962. height: elem.outerHeight(),
  963. offset: elem.offset()
  964. };
  965. }
  966. $.position = {
  967. scrollbarWidth: function() {
  968. if ( cachedScrollbarWidth !== undefined ) {
  969. return cachedScrollbarWidth;
  970. }
  971. var w1, w2,
  972. div = $( "<div style='display:block;position:absolute;width:50px;height:50px;overflow:hidden;'><div style='height:100px;width:auto;'></div></div>" ),
  973. innerDiv = div.children()[0];
  974. $( "body" ).append( div );
  975. w1 = innerDiv.offsetWidth;
  976. div.css( "overflow", "scroll" );
  977. w2 = innerDiv.offsetWidth;
  978. if ( w1 === w2 ) {
  979. w2 = div[0].clientWidth;
  980. }
  981. div.remove();
  982. return (cachedScrollbarWidth = w1 - w2);
  983. },
  984. getScrollInfo: function( within ) {
  985. var overflowX = within.isWindow || within.isDocument ? "" :
  986. within.element.css( "overflow-x" ),
  987. overflowY = within.isWindow || within.isDocument ? "" :
  988. within.element.css( "overflow-y" ),
  989. hasOverflowX = overflowX === "scroll" ||
  990. ( overflowX === "auto" && within.width < within.element[0].scrollWidth ),
  991. hasOverflowY = overflowY === "scroll" ||
  992. ( overflowY === "auto" && within.height < within.element[0].scrollHeight );
  993. return {
  994. width: hasOverflowY ? $.position.scrollbarWidth() : 0,
  995. height: hasOverflowX ? $.position.scrollbarWidth() : 0
  996. };
  997. },
  998. getWithinInfo: function( element ) {
  999. var withinElement = $( element || window ),
  1000. isWindow = $.isWindow( withinElement[0] ),
  1001. isDocument = !!withinElement[ 0 ] && withinElement[ 0 ].nodeType === 9;
  1002. return {
  1003. element: withinElement,
  1004. isWindow: isWindow,
  1005. isDocument: isDocument,
  1006. offset: withinElement.offset() || { left: 0, top: 0 },
  1007. scrollLeft: withinElement.scrollLeft(),
  1008. scrollTop: withinElement.scrollTop(),
  1009. // support: jQuery 1.6.x
  1010. // jQuery 1.6 doesn't support .outerWidth/Height() on documents or windows
  1011. width: isWindow || isDocument ? withinElement.width() : withinElement.outerWidth(),
  1012. height: isWindow || isDocument ? withinElement.height() : withinElement.outerHeight()
  1013. };
  1014. }
  1015. };
  1016. $.fn.position = function( options ) {
  1017. if ( !options || !options.of ) {
  1018. return _position.apply( this, arguments );
  1019. }
  1020. // make a copy, we don't want to modify arguments
  1021. options = $.extend( {}, options );
  1022. var atOffset, targetWidth, targetHeight, targetOffset, basePosition, dimensions,
  1023. target = $( options.of ),
  1024. within = $.position.getWithinInfo( options.within ),
  1025. scrollInfo = $.position.getScrollInfo( within ),
  1026. collision = ( options.collision || "flip" ).split( " " ),
  1027. offsets = {};
  1028. dimensions = getDimensions( target );
  1029. if ( target[0].preventDefault ) {
  1030. // force left top to allow flipping
  1031. options.at = "left top";
  1032. }
  1033. targetWidth = dimensions.width;
  1034. targetHeight = dimensions.height;
  1035. targetOffset = dimensions.offset;
  1036. // clone to reuse original targetOffset later
  1037. basePosition = $.extend( {}, targetOffset );
  1038. // force my and at to have valid horizontal and vertical positions
  1039. // if a value is missing or invalid, it will be converted to center
  1040. $.each( [ "my", "at" ], function() {
  1041. var pos = ( options[ this ] || "" ).split( " " ),
  1042. horizontalOffset,
  1043. verticalOffset;
  1044. if ( pos.length === 1) {
  1045. pos = rhorizontal.test( pos[ 0 ] ) ?
  1046. pos.concat( [ "center" ] ) :
  1047. rvertical.test( pos[ 0 ] ) ?
  1048. [ "center" ].concat( pos ) :
  1049. [ "center", "center" ];
  1050. }
  1051. pos[ 0 ] = rhorizontal.test( pos[ 0 ] ) ? pos[ 0 ] : "center";
  1052. pos[ 1 ] = rvertical.test( pos[ 1 ] ) ? pos[ 1 ] : "center";
  1053. // calculate offsets
  1054. horizontalOffset = roffset.exec( pos[ 0 ] );
  1055. verticalOffset = roffset.exec( pos[ 1 ] );
  1056. offsets[ this ] = [
  1057. horizontalOffset ? horizontalOffset[ 0 ] : 0,
  1058. verticalOffset ? verticalOffset[ 0 ] : 0
  1059. ];
  1060. // reduce to just the positions without the offsets
  1061. options[ this ] = [
  1062. rposition.exec( pos[ 0 ] )[ 0 ],
  1063. rposition.exec( pos[ 1 ] )[ 0 ]
  1064. ];
  1065. });
  1066. // normalize collision option
  1067. if ( collision.length === 1 ) {
  1068. collision[ 1 ] = collision[ 0 ];
  1069. }
  1070. if ( options.at[ 0 ] === "right" ) {
  1071. basePosition.left += targetWidth;
  1072. } else if ( options.at[ 0 ] === "center" ) {
  1073. basePosition.left += targetWidth / 2;
  1074. }
  1075. if ( options.at[ 1 ] === "bottom" ) {
  1076. basePosition.top += targetHeight;
  1077. } else if ( options.at[ 1 ] === "center" ) {
  1078. basePosition.top += targetHeight / 2;
  1079. }
  1080. atOffset = getOffsets( offsets.at, targetWidth, targetHeight );
  1081. basePosition.left += atOffset[ 0 ];
  1082. basePosition.top += atOffset[ 1 ];
  1083. return this.each(function() {
  1084. var collisionPosition, using,
  1085. elem = $( this ),
  1086. elemWidth = elem.outerWidth(),
  1087. elemHeight = elem.outerHeight(),
  1088. marginLeft = parseCss( this, "marginLeft" ),
  1089. marginTop = parseCss( this, "marginTop" ),
  1090. collisionWidth = elemWidth + marginLeft + parseCss( this, "marginRight" ) + scrollInfo.width,
  1091. collisionHeight = elemHeight + marginTop + parseCss( this, "marginBottom" ) + scrollInfo.height,
  1092. position = $.extend( {}, basePosition ),
  1093. myOffset = getOffsets( offsets.my, elem.outerWidth(), elem.outerHeight() );
  1094. if ( options.my[ 0 ] === "right" ) {
  1095. position.left -= elemWidth;
  1096. } else if ( options.my[ 0 ] === "center" ) {
  1097. position.left -= elemWidth / 2;
  1098. }
  1099. if ( options.my[ 1 ] === "bottom" ) {
  1100. position.top -= elemHeight;
  1101. } else if ( options.my[ 1 ] === "center" ) {
  1102. position.top -= elemHeight / 2;
  1103. }
  1104. position.left += myOffset[ 0 ];
  1105. position.top += myOffset[ 1 ];
  1106. // if the browser doesn't support fractions, then round for consistent results
  1107. if ( !supportsOffsetFractions ) {
  1108. position.left = round( position.left );
  1109. position.top = round( position.top );
  1110. }
  1111. collisionPosition = {
  1112. marginLeft: marginLeft,
  1113. marginTop: marginTop
  1114. };
  1115. $.each( [ "left", "top" ], function( i, dir ) {
  1116. if ( $.ui.position[ collision[ i ] ] ) {
  1117. $.ui.position[ collision[ i ] ][ dir ]( position, {
  1118. targetWidth: targetWidth,
  1119. targetHeight: targetHeight,
  1120. elemWidth: elemWidth,
  1121. elemHeight: elemHeight,
  1122. collisionPosition: collisionPosition,
  1123. collisionWidth: collisionWidth,
  1124. collisionHeight: collisionHeight,
  1125. offset: [ atOffset[ 0 ] + myOffset[ 0 ], atOffset [ 1 ] + myOffset[ 1 ] ],
  1126. my: options.my,
  1127. at: options.at,
  1128. within: within,
  1129. elem: elem
  1130. });
  1131. }
  1132. });
  1133. if ( options.using ) {
  1134. // adds feedback as second argument to using callback, if present
  1135. using = function( props ) {
  1136. var left = targetOffset.left - position.left,
  1137. right = left + targetWidth - elemWidth,
  1138. top = targetOffset.top - position.top,
  1139. bottom = top + targetHeight - elemHeight,
  1140. feedback = {
  1141. target: {
  1142. element: target,
  1143. left: targetOffset.left,
  1144. top: targetOffset.top,
  1145. width: targetWidth,
  1146. height: targetHeight
  1147. },
  1148. element: {
  1149. element: elem,
  1150. left: position.left,
  1151. top: position.top,
  1152. width: elemWidth,
  1153. height: elemHeight
  1154. },
  1155. horizontal: right < 0 ? "left" : left > 0 ? "right" : "center",
  1156. vertical: bottom < 0 ? "top" : top > 0 ? "bottom" : "middle"
  1157. };
  1158. if ( targetWidth < elemWidth && abs( left + right ) < targetWidth ) {
  1159. feedback.horizontal = "center";
  1160. }
  1161. if ( targetHeight < elemHeight && abs( top + bottom ) < targetHeight ) {
  1162. feedback.vertical = "middle";
  1163. }
  1164. if ( max( abs( left ), abs( right ) ) > max( abs( top ), abs( bottom ) ) ) {
  1165. feedback.important = "horizontal";
  1166. } else {
  1167. feedback.important = "vertical";
  1168. }
  1169. options.using.call( this, props, feedback );
  1170. };
  1171. }
  1172. elem.offset( $.extend( position, { using: using } ) );
  1173. });
  1174. };
  1175. $.ui.position = {
  1176. fit: {
  1177. left: function( position, data ) {
  1178. var within = data.within,
  1179. withinOffset = within.isWindow ? within.scrollLeft : within.offset.left,
  1180. outerWidth = within.width,
  1181. collisionPosLeft = position.left - data.collisionPosition.marginLeft,
  1182. overLeft = withinOffset - collisionPosLeft,
  1183. overRight = collisionPosLeft + data.collisionWidth - outerWidth - withinOffset,
  1184. newOverRight;
  1185. // element is wider than within
  1186. if ( data.collisionWidth > outerWidth ) {
  1187. // element is initially over the left side of within
  1188. if ( overLeft > 0 && overRight <= 0 ) {
  1189. newOverRight = position.left + overLeft + data.collisionWidth - outerWidth - withinOffset;
  1190. position.left += overLeft - newOverRight;
  1191. // element is initially over right side of within
  1192. } else if ( overRight > 0 && overLeft <= 0 ) {
  1193. position.left = withinOffset;
  1194. // element is initially over both left and right sides of within
  1195. } else {
  1196. if ( overLeft > overRight ) {
  1197. position.left = withinOffset + outerWidth - data.collisionWidth;
  1198. } else {
  1199. position.left = withinOffset;
  1200. }
  1201. }
  1202. // too far left -> align with left edge
  1203. } else if ( overLeft > 0 ) {
  1204. position.left += overLeft;
  1205. // too far right -> align with right edge
  1206. } else if ( overRight > 0 ) {
  1207. position.left -= overRight;
  1208. // adjust based on position and margin
  1209. } else {
  1210. position.left = max( position.left - collisionPosLeft, position.left );
  1211. }
  1212. },
  1213. top: function( position, data ) {
  1214. var within = data.within,
  1215. withinOffset = within.isWindow ? within.scrollTop : within.offset.top,
  1216. outerHeight = data.within.height,
  1217. collisionPosTop = position.top - data.collisionPosition.marginTop,
  1218. overTop = withinOffset - collisionPosTop,
  1219. overBottom = collisionPosTop + data.collisionHeight - outerHeight - withinOffset,
  1220. newOverBottom;
  1221. // element is taller than within
  1222. if ( data.collisionHeight > outerHeight ) {
  1223. // element is initially over the top of within
  1224. if ( overTop > 0 && overBottom <= 0 ) {
  1225. newOverBottom = position.top + overTop + data.collisionHeight - outerHeight - withinOffset;
  1226. position.top += overTop - newOverBottom;
  1227. // element is initially over bottom of within
  1228. } else if ( overBottom > 0 && overTop <= 0 ) {
  1229. position.top = withinOffset;
  1230. // element is initially over both top and bottom of within
  1231. } else {
  1232. if ( overTop > overBottom ) {
  1233. position.top = withinOffset + outerHeight - data.collisionHeight;
  1234. } else {
  1235. position.top = withinOffset;
  1236. }
  1237. }
  1238. // too far up -> align with top
  1239. } else if ( overTop > 0 ) {
  1240. position.top += overTop;
  1241. // too far down -> align with bottom edge
  1242. } else if ( overBottom > 0 ) {
  1243. position.top -= overBottom;
  1244. // adjust based on position and margin
  1245. } else {
  1246. position.top = max( position.top - collisionPosTop, position.top );
  1247. }
  1248. }
  1249. },
  1250. flip: {
  1251. left: function( position, data ) {
  1252. var within = data.within,
  1253. withinOffset = within.offset.left + within.scrollLeft,
  1254. outerWidth = within.width,
  1255. offsetLeft = within.isWindow ? within.scrollLeft : within.offset.left,
  1256. collisionPosLeft = position.left - data.collisionPosition.marginLeft,
  1257. overLeft = collisionPosLeft - offsetLeft,
  1258. overRight = collisionPosLeft + data.collisionWidth - outerWidth - offsetLeft,
  1259. myOffset = data.my[ 0 ] === "left" ?
  1260. -data.elemWidth :
  1261. data.my[ 0 ] === "right" ?
  1262. data.elemWidth :
  1263. 0,
  1264. atOffset = data.at[ 0 ] === "left" ?
  1265. data.targetWidth :
  1266. data.at[ 0 ] === "right" ?
  1267. -data.targetWidth :
  1268. 0,
  1269. offset = -2 * data.offset[ 0 ],
  1270. newOverRight,
  1271. newOverLeft;
  1272. if ( overLeft < 0 ) {
  1273. newOverRight = position.left + myOffset + atOffset + offset + data.collisionWidth - outerWidth - withinOffset;
  1274. if ( newOverRight < 0 || newOverRight < abs( overLeft ) ) {
  1275. position.left += myOffset + atOffset + offset;
  1276. }
  1277. } else if ( overRight > 0 ) {
  1278. newOverLeft = position.left - data.collisionPosition.marginLeft + myOffset + atOffset + offset - offsetLeft;
  1279. if ( newOverLeft > 0 || abs( newOverLeft ) < overRight ) {
  1280. position.left += myOffset + atOffset + offset;
  1281. }
  1282. }
  1283. },
  1284. top: function( position, data ) {
  1285. var within = data.within,
  1286. withinOffset = within.offset.top + within.scrollTop,
  1287. outerHeight = within.height,
  1288. offsetTop = within.isWindow ? within.scrollTop : within.offset.top,
  1289. collisionPosTop = position.top - data.collisionPosition.marginTop,
  1290. overTop = collisionPosTop - offsetTop,
  1291. overBottom = collisionPosTop + data.collisionHeight - outerHeight - offsetTop,
  1292. top = data.my[ 1 ] === "top",
  1293. myOffset = top ?
  1294. -data.elemHeight :
  1295. data.my[ 1 ] === "bottom" ?
  1296. data.elemHeight :
  1297. 0,
  1298. atOffset = data.at[ 1 ] === "top" ?
  1299. data.targetHeight :
  1300. data.at[ 1 ] === "bottom" ?
  1301. -data.targetHeight :
  1302. 0,
  1303. offset = -2 * data.offset[ 1 ],
  1304. newOverTop,
  1305. newOverBottom;
  1306. if ( overTop < 0 ) {
  1307. newOverBottom = position.top + myOffset + atOffset + offset + data.collisionHeight - outerHeight - withinOffset;
  1308. if ( newOverBottom < 0 || newOverBottom < abs( overTop ) ) {
  1309. position.top += myOffset + atOffset + offset;
  1310. }
  1311. } else if ( overBottom > 0 ) {
  1312. newOverTop = position.top - data.collisionPosition.marginTop + myOffset + atOffset + offset - offsetTop;
  1313. if ( newOverTop > 0 || abs( newOverTop ) < overBottom ) {
  1314. position.top += myOffset + atOffset + offset;
  1315. }
  1316. }
  1317. }
  1318. },
  1319. flipfit: {
  1320. left: function() {
  1321. $.ui.position.flip.left.apply( this, arguments );
  1322. $.ui.position.fit.left.apply( this, arguments );
  1323. },
  1324. top: function() {
  1325. $.ui.position.flip.top.apply( this, arguments );
  1326. $.ui.position.fit.top.apply( this, arguments );
  1327. }
  1328. }
  1329. };
  1330. // fraction support test
  1331. (function() {
  1332. var testElement, testElementParent, testElementStyle, offsetLeft, i,
  1333. body = document.getElementsByTagName( "body" )[ 0 ],
  1334. div = document.createElement( "div" );
  1335. //Create a "fake body" for testing based on method used in jQuery.support
  1336. testElement = document.createElement( body ? "div" : "body" );
  1337. testElementStyle = {
  1338. visibility: "hidden",
  1339. width: 0,
  1340. height: 0,
  1341. border: 0,
  1342. margin: 0,
  1343. background: "none"
  1344. };
  1345. if ( body ) {
  1346. $.extend( testElementStyle, {
  1347. position: "absolute",
  1348. left: "-1000px",
  1349. top: "-1000px"
  1350. });
  1351. }
  1352. for ( i in testElementStyle ) {
  1353. testElement.style[ i ] = testElementStyle[ i ];
  1354. }
  1355. testElement.appendChild( div );
  1356. testElementParent = body || document.documentElement;
  1357. testElementParent.insertBefore( testElement, testElementParent.firstChild );
  1358. div.style.cssText = "position: absolute; left: 10.7432222px;";
  1359. offsetLeft = $( div ).offset().left;
  1360. supportsOffsetFractions = offsetLeft > 10 && offsetLeft < 11;
  1361. testElement.innerHTML = "";
  1362. testElementParent.removeChild( testElement );
  1363. })();
  1364. })();
  1365. var position = $.ui.position;
  1366. /*!
  1367. * jQuery UI Menu 1.11.4
  1368. * http://jqueryui.com
  1369. *
  1370. * Copyright jQuery Foundation and other contributors
  1371. * Released under the MIT license.
  1372. * http://jquery.org/license
  1373. *
  1374. * http://api.jqueryui.com/menu/
  1375. */
  1376. var menu = $.widget( "ui.menu", {
  1377. version: "1.11.4",
  1378. defaultElement: "<ul>",
  1379. delay: 300,
  1380. options: {
  1381. icons: {
  1382. submenu: "ui-icon-carat-1-e"
  1383. },
  1384. items: "> *",
  1385. menus: "ul",
  1386. position: {
  1387. my: "left-1 top",
  1388. at: "right top"
  1389. },
  1390. role: "menu",
  1391. // callbacks
  1392. blur: null,
  1393. focus: null,
  1394. select: null
  1395. },
  1396. _create: function() {
  1397. this.activeMenu = this.element;
  1398. // Flag used to prevent firing of the click handler
  1399. // as the event bubbles up through nested menus
  1400. this.mouseHandled = false;
  1401. this.element
  1402. .uniqueId()
  1403. .addClass( "ui-menu ui-widget ui-widget-content" )
  1404. .toggleClass( "ui-menu-icons", !!this.element.find( ".ui-icon" ).length )
  1405. .attr({
  1406. role: this.options.role,
  1407. tabIndex: 0
  1408. });
  1409. if ( this.options.disabled ) {
  1410. this.element
  1411. .addClass( "ui-state-disabled" )
  1412. .attr( "aria-disabled", "true" );
  1413. }
  1414. this._on({
  1415. // Prevent focus from sticking to links inside menu after clicking
  1416. // them (focus should always stay on UL during navigation).
  1417. "mousedown .ui-menu-item": function( event ) {
  1418. event.preventDefault();
  1419. },
  1420. "click .ui-menu-item": function( event ) {
  1421. var target = $( event.target );
  1422. if ( !this.mouseHandled && target.not( ".ui-state-disabled" ).length ) {
  1423. this.select( event );
  1424. // Only set the mouseHandled flag if the event will bubble, see #9469.
  1425. if ( !event.isPropagationStopped() ) {
  1426. this.mouseHandled = true;
  1427. }
  1428. // Open submenu on click
  1429. if ( target.has( ".ui-menu" ).length ) {
  1430. this.expand( event );
  1431. } else if ( !this.element.is( ":focus" ) && $( this.document[ 0 ].activeElement ).closest( ".ui-menu" ).length ) {
  1432. // Redirect focus to the menu
  1433. this.element.trigger( "focus", [ true ] );
  1434. // If the active item is on the top level, let it stay active.
  1435. // Otherwise, blur the active item since it is no longer visible.
  1436. if ( this.active && this.active.parents( ".ui-menu" ).length === 1 ) {
  1437. clearTimeout( this.timer );
  1438. }
  1439. }
  1440. }
  1441. },
  1442. "mouseenter .ui-menu-item": function( event ) {
  1443. // Ignore mouse events while typeahead is active, see #10458.
  1444. // Prevents focusing the wrong item when typeahead causes a scroll while the mouse
  1445. // is over an item in the menu
  1446. if ( this.previousFilter ) {
  1447. return;
  1448. }
  1449. var target = $( event.currentTarget );
  1450. // Remove ui-state-active class from siblings of the newly focused menu item
  1451. // to avoid a jump caused by adjacent elements both having a class with a border
  1452. target.siblings( ".ui-state-active" ).removeClass( "ui-state-active" );
  1453. this.focus( event, target );
  1454. },
  1455. mouseleave: "collapseAll",
  1456. "mouseleave .ui-menu": "collapseAll",
  1457. focus: function( event, keepActiveItem ) {
  1458. // If there's already an active item, keep it active
  1459. // If not, activate the first item
  1460. var item = this.active || this.element.find( this.options.items ).eq( 0 );
  1461. if ( !keepActiveItem ) {
  1462. this.focus( event, item );
  1463. }
  1464. },
  1465. blur: function( event ) {
  1466. this._delay(function() {
  1467. if ( !$.contains( this.element[0], this.document[0].activeElement ) ) {
  1468. this.collapseAll( event );
  1469. }
  1470. });
  1471. },
  1472. keydown: "_keydown"
  1473. });
  1474. this.refresh();
  1475. // Clicks outside of a menu collapse any open menus
  1476. this._on( this.document, {
  1477. click: function( event ) {
  1478. if ( this._closeOnDocumentClick( event ) ) {
  1479. this.collapseAll( event );
  1480. }
  1481. // Reset the mouseHandled flag
  1482. this.mouseHandled = false;
  1483. }
  1484. });
  1485. },
  1486. _destroy: function() {
  1487. // Destroy (sub)menus
  1488. this.element
  1489. .removeAttr( "aria-activedescendant" )
  1490. .find( ".ui-menu" ).addBack()
  1491. .removeClass( "ui-menu ui-widget ui-widget-content ui-menu-icons ui-front" )
  1492. .removeAttr( "role" )
  1493. .removeAttr( "tabIndex" )
  1494. .removeAttr( "aria-labelledby" )
  1495. .removeAttr( "aria-expanded" )
  1496. .removeAttr( "aria-hidden" )
  1497. .removeAttr( "aria-disabled" )
  1498. .removeUniqueId()
  1499. .show();
  1500. // Destroy menu items
  1501. this.element.find( ".ui-menu-item" )
  1502. .removeClass( "ui-menu-item" )
  1503. .removeAttr( "role" )
  1504. .removeAttr( "aria-disabled" )
  1505. .removeUniqueId()
  1506. .removeClass( "ui-state-hover" )
  1507. .removeAttr( "tabIndex" )
  1508. .removeAttr( "role" )
  1509. .removeAttr( "aria-haspopup" )
  1510. .children().each( function() {
  1511. var elem = $( this );
  1512. if ( elem.data( "ui-menu-submenu-carat" ) ) {
  1513. elem.remove();
  1514. }
  1515. });
  1516. // Destroy menu dividers
  1517. this.element.find( ".ui-menu-divider" ).removeClass( "ui-menu-divider ui-widget-content" );
  1518. },
  1519. _keydown: function( event ) {
  1520. var match, prev, character, skip,
  1521. preventDefault = true;
  1522. switch ( event.keyCode ) {
  1523. case $.ui.keyCode.PAGE_UP:
  1524. this.previousPage( event );
  1525. break;
  1526. case $.ui.keyCode.PAGE_DOWN:
  1527. this.nextPage( event );
  1528. break;
  1529. case $.ui.keyCode.HOME:
  1530. this._move( "first", "first", event );
  1531. break;
  1532. case $.ui.keyCode.END:
  1533. this._move( "last", "last", event );
  1534. break;
  1535. case $.ui.keyCode.UP:
  1536. this.previous( event );
  1537. break;
  1538. case $.ui.keyCode.DOWN:
  1539. this.next( event );
  1540. break;
  1541. case $.ui.keyCode.LEFT:
  1542. this.collapse( event );
  1543. break;
  1544. case $.ui.keyCode.RIGHT:
  1545. if ( this.active && !this.active.is( ".ui-state-disabled" ) ) {
  1546. this.expand( event );
  1547. }
  1548. break;
  1549. case $.ui.keyCode.ENTER:
  1550. case $.ui.keyCode.SPACE:
  1551. this._activate( event );
  1552. break;
  1553. case $.ui.keyCode.ESCAPE:
  1554. this.collapse( event );
  1555. break;
  1556. default:
  1557. preventDefault = false;
  1558. prev = this.previousFilter || "";
  1559. character = String.fromCharCode( event.keyCode );
  1560. skip = false;
  1561. clearTimeout( this.filterTimer );
  1562. if ( character === prev ) {
  1563. skip = true;
  1564. } else {
  1565. character = prev + character;
  1566. }
  1567. match = this._filterMenuItems( character );
  1568. match = skip && match.index( this.active.next() ) !== -1 ?
  1569. this.active.nextAll( ".ui-menu-item" ) :
  1570. match;
  1571. // If no matches on the current filter, reset to the last character pressed
  1572. // to move down the menu to the first item that starts with that character
  1573. if ( !match.length ) {
  1574. character = String.fromCharCode( event.keyCode );
  1575. match = this._filterMenuItems( character );
  1576. }
  1577. if ( match.length ) {
  1578. this.focus( event, match );
  1579. this.previousFilter = character;
  1580. this.filterTimer = this._delay(function() {
  1581. delete this.previousFilter;
  1582. }, 1000 );
  1583. } else {
  1584. delete this.previousFilter;
  1585. }
  1586. }
  1587. if ( preventDefault ) {
  1588. event.preventDefault();
  1589. }
  1590. },
  1591. _activate: function( event ) {
  1592. if ( !this.active.is( ".ui-state-disabled" ) ) {
  1593. if ( this.active.is( "[aria-haspopup='true']" ) ) {
  1594. this.expand( event );
  1595. } else {
  1596. this.select( event );
  1597. }
  1598. }
  1599. },
  1600. refresh: function() {
  1601. var menus, items,
  1602. that = this,
  1603. icon = this.options.icons.submenu,
  1604. submenus = this.element.find( this.options.menus );
  1605. this.element.toggleClass( "ui-menu-icons", !!this.element.find( ".ui-icon" ).length );
  1606. // Initialize nested menus
  1607. submenus.filter( ":not(.ui-menu)" )
  1608. .addClass( "ui-menu ui-widget ui-widget-content ui-front" )
  1609. .hide()
  1610. .attr({
  1611. role: this.options.role,
  1612. "aria-hidden": "true",
  1613. "aria-expanded": "false"
  1614. })
  1615. .each(function() {
  1616. var menu = $( this ),
  1617. item = menu.parent(),
  1618. submenuCarat = $( "<span>" )
  1619. .addClass( "ui-menu-icon ui-icon " + icon )
  1620. .data( "ui-menu-submenu-carat", true );
  1621. item
  1622. .attr( "aria-haspopup", "true" )
  1623. .prepend( submenuCarat );
  1624. menu.attr( "aria-labelledby", item.attr( "id" ) );
  1625. });
  1626. menus = submenus.add( this.element );
  1627. items = menus.find( this.options.items );
  1628. // Initialize menu-items containing spaces and/or dashes only as dividers
  1629. items.not( ".ui-menu-item" ).each(function() {
  1630. var item = $( this );
  1631. if ( that._isDivider( item ) ) {
  1632. item.addClass( "ui-widget-content ui-menu-divider" );
  1633. }
  1634. });
  1635. // Don't refresh list items that are already adapted
  1636. items.not( ".ui-menu-item, .ui-menu-divider" )
  1637. .addClass( "ui-menu-item" )
  1638. .uniqueId()
  1639. .attr({
  1640. tabIndex: -1,
  1641. role: this._itemRole()
  1642. });
  1643. // Add aria-disabled attribute to any disabled menu item
  1644. items.filter( ".ui-state-disabled" ).attr( "aria-disabled", "true" );
  1645. // If the active item has been removed, blur the menu
  1646. if ( this.active && !$.contains( this.element[ 0 ], this.active[ 0 ] ) ) {
  1647. this.blur();
  1648. }
  1649. },
  1650. _itemRole: function() {
  1651. return {
  1652. menu: "menuitem",
  1653. listbox: "option"
  1654. }[ this.options.role ];
  1655. },
  1656. _setOption: function( key, value ) {
  1657. if ( key === "icons" ) {
  1658. this.element.find( ".ui-menu-icon" )
  1659. .removeClass( this.options.icons.submenu )
  1660. .addClass( value.submenu );
  1661. }
  1662. if ( key === "disabled" ) {
  1663. this.element
  1664. .toggleClass( "ui-state-disabled", !!value )
  1665. .attr( "aria-disabled", value );
  1666. }
  1667. this._super( key, value );
  1668. },
  1669. focus: function( event, item ) {
  1670. var nested, focused;
  1671. this.blur( event, event && event.type === "focus" );
  1672. this._scrollIntoView( item );
  1673. this.active = item.first();
  1674. focused = this.active.addClass( "ui-state-focus" ).removeClass( "ui-state-active" );
  1675. // Only update aria-activedescendant if there's a role
  1676. // otherwise we assume focus is managed elsewhere
  1677. if ( this.options.role ) {
  1678. this.element.attr( "aria-activedescendant", focused.attr( "id" ) );
  1679. }
  1680. // Highlight active parent menu item, if any
  1681. this.active
  1682. .parent()
  1683. .closest( ".ui-menu-item" )
  1684. .addClass( "ui-state-active" );
  1685. if ( event && event.type === "keydown" ) {
  1686. this._close();
  1687. } else {
  1688. this.timer = this._delay(function() {
  1689. this._close();
  1690. }, this.delay );
  1691. }
  1692. nested = item.children( ".ui-menu" );
  1693. if ( nested.length && event && ( /^mouse/.test( event.type ) ) ) {
  1694. this._startOpening(nested);
  1695. }
  1696. this.activeMenu = item.parent();
  1697. this._trigger( "focus", event, { item: item } );
  1698. },
  1699. _scrollIntoView: function( item ) {
  1700. var borderTop, paddingTop, offset, scroll, elementHeight, itemHeight;
  1701. if ( this._hasScroll() ) {
  1702. borderTop = parseFloat( $.css( this.activeMenu[0], "borderTopWidth" ) ) || 0;
  1703. paddingTop = parseFloat( $.css( this.activeMenu[0], "paddingTop" ) ) || 0;
  1704. offset = item.offset().top - this.activeMenu.offset().top - borderTop - paddingTop;
  1705. scroll = this.activeMenu.scrollTop();
  1706. elementHeight = this.activeMenu.height();
  1707. itemHeight = item.outerHeight();
  1708. if ( offset < 0 ) {
  1709. this.activeMenu.scrollTop( scroll + offset );
  1710. } else if ( offset + itemHeight > elementHeight ) {
  1711. this.activeMenu.scrollTop( scroll + offset - elementHeight + itemHeight );
  1712. }
  1713. }
  1714. },
  1715. blur: function( event, fromFocus ) {
  1716. if ( !fromFocus ) {
  1717. clearTimeout( this.timer );
  1718. }
  1719. if ( !this.active ) {
  1720. return;
  1721. }
  1722. this.active.removeClass( "ui-state-focus" );
  1723. this.active = null;
  1724. this._trigger( "blur", event, { item: this.active } );
  1725. },
  1726. _startOpening: function( submenu ) {
  1727. clearTimeout( this.timer );
  1728. // Don't open if already open fixes a Firefox bug that caused a .5 pixel
  1729. // shift in the submenu position when mousing over the carat icon
  1730. if ( submenu.attr( "aria-hidden" ) !== "true" ) {
  1731. return;
  1732. }
  1733. this.timer = this._delay(function() {
  1734. this._close();
  1735. this._open( submenu );
  1736. }, this.delay );
  1737. },
  1738. _open: function( submenu ) {
  1739. var position = $.extend({
  1740. of: this.active
  1741. }, this.options.position );
  1742. clearTimeout( this.timer );
  1743. this.element.find( ".ui-menu" ).not( submenu.parents( ".ui-menu" ) )
  1744. .hide()
  1745. .attr( "aria-hidden", "true" );
  1746. submenu
  1747. .show()
  1748. .removeAttr( "aria-hidden" )
  1749. .attr( "aria-expanded", "true" )
  1750. .position( position );
  1751. },
  1752. collapseAll: function( event, all ) {
  1753. clearTimeout( this.timer );
  1754. this.timer = this._delay(function() {
  1755. // If we were passed an event, look for the submenu that contains the event
  1756. var currentMenu = all ? this.element :
  1757. $( event && event.target ).closest( this.element.find( ".ui-menu" ) );
  1758. // If we found no valid submenu ancestor, use the main menu to close all sub menus anyway
  1759. if ( !currentMenu.length ) {
  1760. currentMenu = this.element;
  1761. }
  1762. this._close( currentMenu );
  1763. this.blur( event );
  1764. this.activeMenu = currentMenu;
  1765. }, this.delay );
  1766. },
  1767. // With no arguments, closes the currently active menu - if nothing is active
  1768. // it closes all menus. If passed an argument, it will search for menus BELOW
  1769. _close: function( startMenu ) {
  1770. if ( !startMenu ) {
  1771. startMenu = this.active ? this.active.parent() : this.element;
  1772. }
  1773. startMenu
  1774. .find( ".ui-menu" )
  1775. .hide()
  1776. .attr( "aria-hidden", "true" )
  1777. .attr( "aria-expanded", "false" )
  1778. .end()
  1779. .find( ".ui-state-active" ).not( ".ui-state-focus" )
  1780. .removeClass( "ui-state-active" );
  1781. },
  1782. _closeOnDocumentClick: function( event ) {
  1783. return !$( event.target ).closest( ".ui-menu" ).length;
  1784. },
  1785. _isDivider: function( item ) {
  1786. // Match hyphen, em dash, en dash
  1787. return !/[^\-\u2014\u2013\s]/.test( item.text() );
  1788. },
  1789. collapse: function( event ) {
  1790. var newItem = this.active &&
  1791. this.active.parent().closest( ".ui-menu-item", this.element );
  1792. if ( newItem && newItem.length ) {
  1793. this._close();
  1794. this.focus( event, newItem );
  1795. }
  1796. },
  1797. expand: function( event ) {
  1798. var newItem = this.active &&
  1799. this.active
  1800. .children( ".ui-menu " )
  1801. .find( this.options.items )
  1802. .first();
  1803. if ( newItem && newItem.length ) {
  1804. this._open( newItem.parent() );
  1805. // Delay so Firefox will not hide activedescendant change in expanding submenu from AT
  1806. this._delay(function() {
  1807. this.focus( event, newItem );
  1808. });
  1809. }
  1810. },
  1811. next: function( event ) {
  1812. this._move( "next", "first", event );
  1813. },
  1814. previous: function( event ) {
  1815. this._move( "prev", "last", event );
  1816. },
  1817. isFirstItem: function() {
  1818. return this.active && !this.active.prevAll( ".ui-menu-item" ).length;
  1819. },
  1820. isLastItem: function() {
  1821. return this.active && !this.active.nextAll( ".ui-menu-item" ).length;
  1822. },
  1823. _move: function( direction, filter, event ) {
  1824. var next;
  1825. if ( this.active ) {
  1826. if ( direction === "first" || direction === "last" ) {
  1827. next = this.active
  1828. [ direction === "first" ? "prevAll" : "nextAll" ]( ".ui-menu-item" )
  1829. .eq( -1 );
  1830. } else {
  1831. next = this.active
  1832. [ direction + "All" ]( ".ui-menu-item" )
  1833. .eq( 0 );
  1834. }
  1835. }
  1836. if ( !next || !next.length || !this.active ) {
  1837. next = this.activeMenu.find( this.options.items )[ filter ]();
  1838. }
  1839. this.focus( event, next );
  1840. },
  1841. nextPage: function( event ) {
  1842. var item, base, height;
  1843. if ( !this.active ) {
  1844. this.next( event );
  1845. return;
  1846. }
  1847. if ( this.isLastItem() ) {
  1848. return;
  1849. }
  1850. if ( this._hasScroll() ) {
  1851. base = this.active.offset().top;
  1852. height = this.element.height();
  1853. this.active.nextAll( ".ui-menu-item" ).each(function() {
  1854. item = $( this );
  1855. return item.offset().top - base - height < 0;
  1856. });
  1857. this.focus( event, item );
  1858. } else {
  1859. this.focus( event, this.activeMenu.find( this.options.items )
  1860. [ !this.active ? "first" : "last" ]() );
  1861. }
  1862. },
  1863. previousPage: function( event ) {
  1864. var item, base, height;
  1865. if ( !this.active ) {
  1866. this.next( event );
  1867. return;
  1868. }
  1869. if ( this.isFirstItem() ) {
  1870. return;
  1871. }
  1872. if ( this._hasScroll() ) {
  1873. base = this.active.offset().top;
  1874. height = this.element.height();
  1875. this.active.prevAll( ".ui-menu-item" ).each(function() {
  1876. item = $( this );
  1877. return item.offset().top - base + height > 0;
  1878. });
  1879. this.focus( event, item );
  1880. } else {
  1881. this.focus( event, this.activeMenu.find( this.options.items ).first() );
  1882. }
  1883. },
  1884. _hasScroll: function() {
  1885. return this.element.outerHeight() < this.element.prop( "scrollHeight" );
  1886. },
  1887. select: function( event ) {
  1888. // TODO: It should never be possible to not have an active item at this
  1889. // point, but the tests don't trigger mouseenter before click.
  1890. this.active = this.active || $( event.target ).closest( ".ui-menu-item" );
  1891. var ui = { item: this.active };
  1892. if ( !this.active.has( ".ui-menu" ).length ) {
  1893. this.collapseAll( event, true );
  1894. }
  1895. this._trigger( "select", event, ui );
  1896. },
  1897. _filterMenuItems: function(character) {
  1898. var escapedCharacter = character.replace( /[\-\[\]{}()*+?.,\\\^$|#\s]/g, "\\$&" ),
  1899. regex = new RegExp( "^" + escapedCharacter, "i" );
  1900. return this.activeMenu
  1901. .find( this.options.items )
  1902. // Only match on items, not dividers or other content (#10571)
  1903. .filter( ".ui-menu-item" )
  1904. .filter(function() {
  1905. return regex.test( $.trim( $( this ).text() ) );
  1906. });
  1907. }
  1908. });
  1909. /*!
  1910. * jQuery UI Autocomplete 1.11.4
  1911. * http://jqueryui.com
  1912. *
  1913. * Copyright jQuery Foundation and other contributors
  1914. * Released under the MIT license.
  1915. * http://jquery.org/license
  1916. *
  1917. * http://api.jqueryui.com/autocomplete/
  1918. */
  1919. $.widget( "ui.autocomplete", {
  1920. version: "1.11.4",
  1921. defaultElement: "<input>",
  1922. options: {
  1923. appendTo: null,
  1924. autoFocus: false,
  1925. delay: 300,
  1926. minLength: 1,
  1927. position: {
  1928. my: "left top",
  1929. at: "left bottom",
  1930. collision: "none"
  1931. },
  1932. source: null,
  1933. // callbacks
  1934. change: null,
  1935. close: null,
  1936. focus: null,
  1937. open: null,
  1938. response: null,
  1939. search: null,
  1940. select: null
  1941. },
  1942. requestIndex: 0,
  1943. pending: 0,
  1944. _create: function() {
  1945. // Some browsers only repeat keydown events, not keypress events,
  1946. // so we use the suppressKeyPress flag to determine if we've already
  1947. // handled the keydown event. #7269
  1948. // Unfortunately the code for & in keypress is the same as the up arrow,
  1949. // so we use the suppressKeyPressRepeat flag to avoid handling keypress
  1950. // events when we know the keydown event was used to modify the
  1951. // search term. #7799
  1952. var suppressKeyPress, suppressKeyPressRepeat, suppressInput,
  1953. nodeName = this.element[ 0 ].nodeName.toLowerCase(),
  1954. isTextarea = nodeName === "textarea",
  1955. isInput = nodeName === "input";
  1956. this.isMultiLine =
  1957. // Textareas are always multi-line
  1958. isTextarea ? true :
  1959. // Inputs are always single-line, even if inside a contentEditable element
  1960. // IE also treats inputs as contentEditable
  1961. isInput ? false :
  1962. // All other element types are determined by whether or not they're contentEditable
  1963. this.element.prop( "isContentEditable" );
  1964. this.valueMethod = this.element[ isTextarea || isInput ? "val" : "text" ];
  1965. this.isNewMenu = true;
  1966. this.element
  1967. .addClass( "ui-autocomplete-input" )
  1968. .attr( "autocomplete", "off" );
  1969. this._on( this.element, {
  1970. keydown: function( event ) {
  1971. if ( this.element.prop( "readOnly" ) ) {
  1972. suppressKeyPress = true;
  1973. suppressInput = true;
  1974. suppressKeyPressRepeat = true;
  1975. return;
  1976. }
  1977. suppressKeyPress = false;
  1978. suppressInput = false;
  1979. suppressKeyPressRepeat = false;
  1980. var keyCode = $.ui.keyCode;
  1981. switch ( event.keyCode ) {
  1982. case keyCode.PAGE_UP:
  1983. suppressKeyPress = true;
  1984. this._move( "previousPage", event );
  1985. break;
  1986. case keyCode.PAGE_DOWN:
  1987. suppressKeyPress = true;
  1988. this._move( "nextPage", event );
  1989. break;
  1990. case keyCode.UP:
  1991. suppressKeyPress = true;
  1992. this._keyEvent( "previous", event );
  1993. break;
  1994. case keyCode.DOWN:
  1995. suppressKeyPress = true;
  1996. this._keyEvent( "next", event );
  1997. break;
  1998. case keyCode.ENTER:
  1999. // when menu is open and has focus
  2000. if ( this.menu.active ) {
  2001. // #6055 - Opera still allows the keypress to occur
  2002. // which causes forms to submit
  2003. suppressKeyPress = true;
  2004. event.preventDefault();
  2005. this.menu.select( event );
  2006. }
  2007. break;
  2008. case keyCode.TAB:
  2009. if ( this.menu.active ) {
  2010. this.menu.select( event );
  2011. }
  2012. break;
  2013. case keyCode.ESCAPE:
  2014. if ( this.menu.element.is( ":visible" ) ) {
  2015. if ( !this.isMultiLine ) {
  2016. this._value( this.term );
  2017. }
  2018. this.close( event );
  2019. // Different browsers have different default behavior for escape
  2020. // Single press can mean undo or clear
  2021. // Double press in IE means clear the whole form
  2022. event.preventDefault();
  2023. }
  2024. break;
  2025. default:
  2026. suppressKeyPressRepeat = true;
  2027. // search timeout should be triggered before the input value is changed
  2028. this._searchTimeout( event );
  2029. break;
  2030. }
  2031. },
  2032. keypress: function( event ) {
  2033. if ( suppressKeyPress ) {
  2034. suppressKeyPress = false;
  2035. if ( !this.isMultiLine || this.menu.element.is( ":visible" ) ) {
  2036. event.preventDefault();
  2037. }
  2038. return;
  2039. }
  2040. if ( suppressKeyPressRepeat ) {
  2041. return;
  2042. }
  2043. // replicate some key handlers to allow them to repeat in Firefox and Opera
  2044. var keyCode = $.ui.keyCode;
  2045. switch ( event.keyCode ) {
  2046. case keyCode.PAGE_UP:
  2047. this._move( "previousPage", event );
  2048. break;
  2049. case keyCode.PAGE_DOWN:
  2050. this._move( "nextPage", event );
  2051. break;
  2052. case keyCode.UP:
  2053. this._keyEvent( "previous", event );
  2054. break;
  2055. case keyCode.DOWN:
  2056. this._keyEvent( "next", event );
  2057. break;
  2058. }
  2059. },
  2060. input: function( event ) {
  2061. if ( suppressInput ) {
  2062. suppressInput = false;
  2063. event.preventDefault();
  2064. return;
  2065. }
  2066. this._searchTimeout( event );
  2067. },
  2068. focus: function() {
  2069. this.selectedItem = null;
  2070. this.previous = this._value();
  2071. },
  2072. blur: function( event ) {
  2073. if ( this.cancelBlur ) {
  2074. delete this.cancelBlur;
  2075. return;
  2076. }
  2077. clearTimeout( this.searching );
  2078. this.close( event );
  2079. this._change( event );
  2080. }
  2081. });
  2082. this._initSource();
  2083. this.menu = $( "<ul>" )
  2084. .addClass( "ui-autocomplete ui-front" )
  2085. .appendTo( this._appendTo() )
  2086. .menu({
  2087. // disable ARIA support, the live region takes care of that
  2088. role: null
  2089. })
  2090. .hide()
  2091. .menu( "instance" );
  2092. this._on( this.menu.element, {
  2093. mousedown: function( event ) {
  2094. // prevent moving focus out of the text field
  2095. event.preventDefault();
  2096. // IE doesn't prevent moving focus even with event.preventDefault()
  2097. // so we set a flag to know when we should ignore the blur event
  2098. this.cancelBlur = true;
  2099. this._delay(function() {
  2100. delete this.cancelBlur;
  2101. });
  2102. // clicking on the scrollbar causes focus to shift to the body
  2103. // but we can't detect a mouseup or a click immediately afterward
  2104. // so we have to track the next mousedown and close the menu if
  2105. // the user clicks somewhere outside of the autocomplete
  2106. var menuElement = this.menu.element[ 0 ];
  2107. if ( !$( event.target ).closest( ".ui-menu-item" ).length ) {
  2108. this._delay(function() {
  2109. var that = this;
  2110. this.document.one( "mousedown", function( event ) {
  2111. if ( event.target !== that.element[ 0 ] &&
  2112. event.target !== menuElement &&
  2113. !$.contains( menuElement, event.target ) ) {
  2114. that.close();
  2115. }
  2116. });
  2117. });
  2118. }
  2119. },
  2120. menufocus: function( event, ui ) {
  2121. var label, item;
  2122. // support: Firefox
  2123. // Prevent accidental activation of menu items in Firefox (#7024 #9118)
  2124. if ( this.isNewMenu ) {
  2125. this.isNewMenu = false;
  2126. if ( event.originalEvent && /^mouse/.test( event.originalEvent.type ) ) {
  2127. this.menu.blur();
  2128. this.document.one( "mousemove", function() {
  2129. $( event.target ).trigger( event.originalEvent );
  2130. });
  2131. return;
  2132. }
  2133. }
  2134. item = ui.item.data( "ui-autocomplete-item" );
  2135. if ( false !== this._trigger( "focus", event, { item: item } ) ) {
  2136. // use value to match what will end up in the input, if it was a key event
  2137. if ( event.originalEvent && /^key/.test( event.originalEvent.type ) ) {
  2138. this._value( item.value );
  2139. }
  2140. }
  2141. // Announce the value in the liveRegion
  2142. label = ui.item.attr( "aria-label" ) || item.value;
  2143. if ( label && $.trim( label ).length ) {
  2144. this.liveRegion.children().hide();
  2145. $( "<div>" ).text( label ).appendTo( this.liveRegion );
  2146. }
  2147. },
  2148. menuselect: function( event, ui ) {
  2149. var item = ui.item.data( "ui-autocomplete-item" ),
  2150. previous = this.previous;
  2151. // only trigger when focus was lost (click on menu)
  2152. if ( this.element[ 0 ] !== this.document[ 0 ].activeElement ) {
  2153. this.element.focus();
  2154. this.previous = previous;
  2155. // #6109 - IE triggers two focus events and the second
  2156. // is asynchronous, so we need to reset the previous
  2157. // term synchronously and asynchronously :-(
  2158. this._delay(function() {
  2159. this.previous = previous;
  2160. this.selectedItem = item;
  2161. });
  2162. }
  2163. if ( false !== this._trigger( "select", event, { item: item } ) ) {
  2164. this._value( item.value );
  2165. }
  2166. // reset the term after the select event
  2167. // this allows custom select handling to work properly
  2168. this.term = this._value();
  2169. this.close( event );
  2170. this.selectedItem = item;
  2171. }
  2172. });
  2173. this.liveRegion = $( "<span>", {
  2174. role: "status",
  2175. "aria-live": "assertive",
  2176. "aria-relevant": "additions"
  2177. })
  2178. .addClass( "ui-helper-hidden-accessible" )
  2179. .appendTo( this.document[ 0 ].body );
  2180. // turning off autocomplete prevents the browser from remembering the
  2181. // value when navigating through history, so we re-enable autocomplete
  2182. // if the page is unloaded before the widget is destroyed. #7790
  2183. this._on( this.window, {
  2184. beforeunload: function() {
  2185. this.element.removeAttr( "autocomplete" );
  2186. }
  2187. });
  2188. },
  2189. _destroy: function() {
  2190. clearTimeout( this.searching );
  2191. this.element
  2192. .removeClass( "ui-autocomplete-input" )
  2193. .removeAttr( "autocomplete" );
  2194. this.menu.element.remove();
  2195. this.liveRegion.remove();
  2196. },
  2197. _setOption: function( key, value ) {
  2198. this._super( key, value );
  2199. if ( key === "source" ) {
  2200. this._initSource();
  2201. }
  2202. if ( key === "appendTo" ) {
  2203. this.menu.element.appendTo( this._appendTo() );
  2204. }
  2205. if ( key === "disabled" && value && this.xhr ) {
  2206. this.xhr.abort();
  2207. }
  2208. },
  2209. _appendTo: function() {
  2210. var element = this.options.appendTo;
  2211. if ( element ) {
  2212. element = element.jquery || element.nodeType ?
  2213. $( element ) :
  2214. this.document.find( element ).eq( 0 );
  2215. }
  2216. if ( !element || !element[ 0 ] ) {
  2217. element = this.element.closest( ".ui-front" );
  2218. }
  2219. if ( !element.length ) {
  2220. element = this.document[ 0 ].body;
  2221. }
  2222. return element;
  2223. },
  2224. _initSource: function() {
  2225. var array, url,
  2226. that = this;
  2227. if ( $.isArray( this.options.source ) ) {
  2228. array = this.options.source;
  2229. this.source = function( request, response ) {
  2230. response( $.ui.autocomplete.filter( array, request.term ) );
  2231. };
  2232. } else if ( typeof this.options.source === "string" ) {
  2233. url = this.options.source;
  2234. this.source = function( request, response ) {
  2235. if ( that.xhr ) {
  2236. that.xhr.abort();
  2237. }
  2238. that.xhr = $.ajax({
  2239. url: url,
  2240. data: request,
  2241. dataType: "json",
  2242. success: function( data ) {
  2243. response( data );
  2244. },
  2245. error: function() {
  2246. response([]);
  2247. }
  2248. });
  2249. };
  2250. } else {
  2251. this.source = this.options.source;
  2252. }
  2253. },
  2254. _searchTimeout: function( event ) {
  2255. clearTimeout( this.searching );
  2256. this.searching = this._delay(function() {
  2257. // Search if the value has changed, or if the user retypes the same value (see #7434)
  2258. var equalValues = this.term === this._value(),
  2259. menuVisible = this.menu.element.is( ":visible" ),
  2260. modifierKey = event.altKey || event.ctrlKey || event.metaKey || event.shiftKey;
  2261. if ( !equalValues || ( equalValues && !menuVisible && !modifierKey ) ) {
  2262. this.selectedItem = null;
  2263. this.search( null, event );
  2264. }
  2265. }, this.options.delay );
  2266. },
  2267. search: function( value, event ) {
  2268. value = value != null ? value : this._value();
  2269. // always save the actual value, not the one passed as an argument
  2270. this.term = this._value();
  2271. if ( value.length < this.options.minLength ) {
  2272. return this.close( event );
  2273. }
  2274. if ( this._trigger( "search", event ) === false ) {
  2275. return;
  2276. }
  2277. return this._search( value );
  2278. },
  2279. _search: function( value ) {
  2280. this.pending++;
  2281. this.element.addClass( "ui-autocomplete-loading" );
  2282. this.cancelSearch = false;
  2283. this.source( { term: value }, this._response() );
  2284. },
  2285. _response: function() {
  2286. var index = ++this.requestIndex;
  2287. return $.proxy(function( content ) {
  2288. if ( index === this.requestIndex ) {
  2289. this.__response( content );
  2290. }
  2291. this.pending--;
  2292. if ( !this.pending ) {
  2293. this.element.removeClass( "ui-autocomplete-loading" );
  2294. }
  2295. }, this );
  2296. },
  2297. __response: function( content ) {
  2298. if ( content ) {
  2299. content = this._normalize( content );
  2300. }
  2301. this._trigger( "response", null, { content: content } );
  2302. if ( !this.options.disabled && content && content.length && !this.cancelSearch ) {
  2303. this._suggest( content );
  2304. this._trigger( "open" );
  2305. } else {
  2306. // use ._close() instead of .close() so we don't cancel future searches
  2307. this._close();
  2308. }
  2309. },
  2310. close: function( event ) {
  2311. this.cancelSearch = true;
  2312. this._close( event );
  2313. },
  2314. _close: function( event ) {
  2315. if ( this.menu.element.is( ":visible" ) ) {
  2316. this.menu.element.hide();
  2317. this.menu.blur();
  2318. this.isNewMenu = true;
  2319. this._trigger( "close", event );
  2320. }
  2321. },
  2322. _change: function( event ) {
  2323. if ( this.previous !== this._value() ) {
  2324. this._trigger( "change", event, { item: this.selectedItem } );
  2325. }
  2326. },
  2327. _normalize: function( items ) {
  2328. // assume all items have the right format when the first item is complete
  2329. if ( items.length && items[ 0 ].label && items[ 0 ].value ) {
  2330. return items;
  2331. }
  2332. return $.map( items, function( item ) {
  2333. if ( typeof item === "string" ) {
  2334. return {
  2335. label: item,
  2336. value: item
  2337. };
  2338. }
  2339. return $.extend( {}, item, {
  2340. label: item.label || item.value,
  2341. value: item.value || item.label
  2342. });
  2343. });
  2344. },
  2345. _suggest: function( items ) {
  2346. var ul = this.menu.element.empty();
  2347. this._renderMenu( ul, items );
  2348. this.isNewMenu = true;
  2349. this.menu.refresh();
  2350. // size and position menu
  2351. ul.show();
  2352. this._resizeMenu();
  2353. ul.position( $.extend({
  2354. of: this.element
  2355. }, this.options.position ) );
  2356. if ( this.options.autoFocus ) {
  2357. this.menu.next();
  2358. }
  2359. },
  2360. _resizeMenu: function() {
  2361. var ul = this.menu.element;
  2362. ul.outerWidth( Math.max(
  2363. // Firefox wraps long text (possibly a rounding bug)
  2364. // so we add 1px to avoid the wrapping (#7513)
  2365. ul.width( "" ).outerWidth() + 1,
  2366. this.element.outerWidth()
  2367. ) );
  2368. },
  2369. _renderMenu: function( ul, items ) {
  2370. var that = this;
  2371. $.each( items, function( index, item ) {
  2372. that._renderItemData( ul, item );
  2373. });
  2374. },
  2375. _renderItemData: function( ul, item ) {
  2376. return this._renderItem( ul, item ).data( "ui-autocomplete-item", item );
  2377. },
  2378. _renderItem: function( ul, item ) {
  2379. return $( "<li>" ).text( item.label ).appendTo( ul );
  2380. },
  2381. _move: function( direction, event ) {
  2382. if ( !this.menu.element.is( ":visible" ) ) {
  2383. this.search( null, event );
  2384. return;
  2385. }
  2386. if ( this.menu.isFirstItem() && /^previous/.test( direction ) ||
  2387. this.menu.isLastItem() && /^next/.test( direction ) ) {
  2388. if ( !this.isMultiLine ) {
  2389. this._value( this.term );
  2390. }
  2391. this.menu.blur();
  2392. return;
  2393. }
  2394. this.menu[ direction ]( event );
  2395. },
  2396. widget: function() {
  2397. return this.menu.element;
  2398. },
  2399. _value: function() {
  2400. return this.valueMethod.apply( this.element, arguments );
  2401. },
  2402. _keyEvent: function( keyEvent, event ) {
  2403. if ( !this.isMultiLine || this.menu.element.is( ":visible" ) ) {
  2404. this._move( keyEvent, event );
  2405. // prevents moving cursor to beginning/end of the text field in some browsers
  2406. event.preventDefault();
  2407. }
  2408. }
  2409. });
  2410. $.extend( $.ui.autocomplete, {
  2411. escapeRegex: function( value ) {
  2412. return value.replace( /[\-\[\]{}()*+?.,\\\^$|#\s]/g, "\\$&" );
  2413. },
  2414. filter: function( array, term ) {
  2415. var matcher = new RegExp( $.ui.autocomplete.escapeRegex( term ), "i" );
  2416. return $.grep( array, function( value ) {
  2417. return matcher.test( value.label || value.value || value );
  2418. });
  2419. }
  2420. });
  2421. // live region extension, adding a `messages` option
  2422. // NOTE: This is an experimental API. We are still investigating
  2423. // a full solution for string manipulation and internationalization.
  2424. $.widget( "ui.autocomplete", $.ui.autocomplete, {
  2425. options: {
  2426. messages: {
  2427. noResults: "No search results.",
  2428. results: function( amount ) {
  2429. return amount + ( amount > 1 ? " results are" : " result is" ) +
  2430. " available, use up and down arrow keys to navigate.";
  2431. }
  2432. }
  2433. },
  2434. __response: function( content ) {
  2435. var message;
  2436. this._superApply( arguments );
  2437. if ( this.options.disabled || this.cancelSearch ) {
  2438. return;
  2439. }
  2440. if ( content && content.length ) {
  2441. message = this.options.messages.results( content.length );
  2442. } else {
  2443. message = this.options.messages.noResults;
  2444. }
  2445. this.liveRegion.children().hide();
  2446. $( "<div>" ).text( message ).appendTo( this.liveRegion );
  2447. }
  2448. });
  2449. var autocomplete = $.ui.autocomplete;
  2450. /*!
  2451. * jQuery UI Datepicker 1.11.4
  2452. * http://jqueryui.com
  2453. *
  2454. * Copyright jQuery Foundation and other contributors
  2455. * Released under the MIT license.
  2456. * http://jquery.org/license
  2457. *
  2458. * http://api.jqueryui.com/datepicker/
  2459. */
  2460. $.extend($.ui, { datepicker: { version: "1.11.4" } });
  2461. var datepicker_instActive;
  2462. function datepicker_getZindex( elem ) {
  2463. var position, value;
  2464. while ( elem.length && elem[ 0 ] !== document ) {
  2465. // Ignore z-index if position is set to a value where z-index is ignored by the browser
  2466. // This makes behavior of this function consistent across browsers
  2467. // WebKit always returns auto if the element is positioned
  2468. position = elem.css( "position" );
  2469. if ( position === "absolute" || position === "relative" || position === "fixed" ) {
  2470. // IE returns 0 when zIndex is not specified
  2471. // other browsers return a string
  2472. // we ignore the case of nested elements with an explicit value of 0
  2473. // <div style="z-index: -10;"><div style="z-index: 0;"></div></div>
  2474. value = parseInt( elem.css( "zIndex" ), 10 );
  2475. if ( !isNaN( value ) && value !== 0 ) {
  2476. return value;
  2477. }
  2478. }
  2479. elem = elem.parent();
  2480. }
  2481. return 0;
  2482. }
  2483. /* Date picker manager.
  2484. Use the singleton instance of this class, $.datepicker, to interact with the date picker.
  2485. Settings for (groups of) date pickers are maintained in an instance object,
  2486. allowing multiple different settings on the same page. */
  2487. function Datepicker() {
  2488. this._curInst = null; // The current instance in use
  2489. this._keyEvent = false; // If the last event was a key event
  2490. this._disabledInputs = []; // List of date picker inputs that have been disabled
  2491. this._datepickerShowing = false; // True if the popup picker is showing , false if not
  2492. this._inDialog = false; // True if showing within a "dialog", false if not
  2493. this._mainDivId = "ui-datepicker-div"; // The ID of the main datepicker division
  2494. this._inlineClass = "ui-datepicker-inline"; // The name of the inline marker class
  2495. this._appendClass = "ui-datepicker-append"; // The name of the append marker class
  2496. this._triggerClass = "ui-datepicker-trigger"; // The name of the trigger marker class
  2497. this._dialogClass = "ui-datepicker-dialog"; // The name of the dialog marker class
  2498. this._disableClass = "ui-datepicker-disabled"; // The name of the disabled covering marker class
  2499. this._unselectableClass = "ui-datepicker-unselectable"; // The name of the unselectable cell marker class
  2500. this._currentClass = "ui-datepicker-current-day"; // The name of the current day marker class
  2501. this._dayOverClass = "ui-datepicker-days-cell-over"; // The name of the day hover marker class
  2502. this.regional = []; // Available regional settings, indexed by language code
  2503. this.regional[""] = { // Default regional settings
  2504. closeText: "Done", // Display text for close link
  2505. prevText: "Prev", // Display text for previous month link
  2506. nextText: "Next", // Display text for next month link
  2507. currentText: "Today", // Display text for current month link
  2508. monthNames: ["January","February","March","April","May","June",
  2509. "July","August","September","October","November","December"], // Names of months for drop-down and formatting
  2510. monthNamesShort: ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"], // For formatting
  2511. dayNames: ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"], // For formatting
  2512. dayNamesShort: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"], // For formatting
  2513. dayNamesMin: ["Su","Mo","Tu","We","Th","Fr","Sa"], // Column headings for days starting at Sunday
  2514. weekHeader: "Wk", // Column header for week of the year
  2515. dateFormat: "mm/dd/yy", // See format options on parseDate
  2516. firstDay: 0, // The first day of the week, Sun = 0, Mon = 1, ...
  2517. isRTL: false, // True if right-to-left language, false if left-to-right
  2518. showMonthAfterYear: false, // True if the year select precedes month, false for month then year
  2519. yearSuffix: "" // Additional text to append to the year in the month headers
  2520. };
  2521. this._defaults = { // Global defaults for all the date picker instances
  2522. showOn: "focus", // "focus" for popup on focus,
  2523. // "button" for trigger button, or "both" for either
  2524. showAnim: "fadeIn", // Name of jQuery animation for popup
  2525. showOptions: {}, // Options for enhanced animations
  2526. defaultDate: null, // Used when field is blank: actual date,
  2527. // +/-number for offset from today, null for today
  2528. appendText: "", // Display text following the input box, e.g. showing the format
  2529. buttonText: "...", // Text for trigger button
  2530. buttonImage: "", // URL for trigger button image
  2531. buttonImageOnly: false, // True if the image appears alone, false if it appears on a button
  2532. hideIfNoPrevNext: false, // True to hide next/previous month links
  2533. // if not applicable, false to just disable them
  2534. navigationAsDateFormat: false, // True if date formatting applied to prev/today/next links
  2535. gotoCurrent: false, // True if today link goes back to current selection instead
  2536. changeMonth: false, // True if month can be selected directly, false if only prev/next
  2537. changeYear: false, // True if year can be selected directly, false if only prev/next
  2538. yearRange: "c-10:c+10", // Range of years to display in drop-down,
  2539. // either relative to today's year (-nn:+nn), relative to currently displayed year
  2540. // (c-nn:c+nn), absolute (nnnn:nnnn), or a combination of the above (nnnn:-n)
  2541. showOtherMonths: false, // True to show dates in other months, false to leave blank
  2542. selectOtherMonths: false, // True to allow selection of dates in other months, false for unselectable
  2543. showWeek: false, // True to show week of the year, false to not show it
  2544. calculateWeek: this.iso8601Week, // How to calculate the week of the year,
  2545. // takes a Date and returns the number of the week for it
  2546. shortYearCutoff: "+10", // Short year values < this are in the current century,
  2547. // > this are in the previous century,
  2548. // string value starting with "+" for current year + value
  2549. minDate: null, // The earliest selectable date, or null for no limit
  2550. maxDate: null, // The latest selectable date, or null for no limit
  2551. duration: "fast", // Duration of display/closure
  2552. beforeShowDay: null, // Function that takes a date and returns an array with
  2553. // [0] = true if selectable, false if not, [1] = custom CSS class name(s) or "",
  2554. // [2] = cell title (optional), e.g. $.datepicker.noWeekends
  2555. beforeShow: null, // Function that takes an input field and
  2556. // returns a set of custom settings for the date picker
  2557. onSelect: null, // Define a callback function when a date is selected
  2558. onChangeMonthYear: null, // Define a callback function when the month or year is changed
  2559. onClose: null, // Define a callback function when the datepicker is closed
  2560. numberOfMonths: 1, // Number of months to show at a time
  2561. showCurrentAtPos: 0, // The position in multipe months at which to show the current month (starting at 0)
  2562. stepMonths: 1, // Number of months to step back/forward
  2563. stepBigMonths: 12, // Number of months to step back/forward for the big links
  2564. altField: "", // Selector for an alternate field to store selected dates into
  2565. altFormat: "", // The date format to use for the alternate field
  2566. constrainInput: true, // The input is constrained by the current date format
  2567. showButtonPanel: false, // True to show button panel, false to not show it
  2568. autoSize: false, // True to size the input for the date format, false to leave as is
  2569. disabled: false // The initial disabled state
  2570. };
  2571. $.extend(this._defaults, this.regional[""]);
  2572. this.regional.en = $.extend( true, {}, this.regional[ "" ]);
  2573. this.regional[ "en-US" ] = $.extend( true, {}, this.regional.en );
  2574. this.dpDiv = datepicker_bindHover($("<div id='" + this._mainDivId + "' class='ui-datepicker ui-widget ui-widget-content ui-helper-clearfix ui-corner-all'></div>"));
  2575. }
  2576. $.extend(Datepicker.prototype, {
  2577. /* Class name added to elements to indicate already configured with a date picker. */
  2578. markerClassName: "hasDatepicker",
  2579. //Keep track of the maximum number of rows displayed (see #7043)
  2580. maxRows: 4,
  2581. // TODO rename to "widget" when switching to widget factory
  2582. _widgetDatepicker: function() {
  2583. return this.dpDiv;
  2584. },
  2585. /* Override the default settings for all instances of the date picker.
  2586. * @param settings object - the new settings to use as defaults (anonymous object)
  2587. * @return the manager object
  2588. */
  2589. setDefaults: function(settings) {
  2590. datepicker_extendRemove(this._defaults, settings || {});
  2591. return this;
  2592. },
  2593. /* Attach the date picker to a jQuery selection.
  2594. * @param target element - the target input field or division or span
  2595. * @param settings object - the new settings to use for this date picker instance (anonymous)
  2596. */
  2597. _attachDatepicker: function(target, settings) {
  2598. var nodeName, inline, inst;
  2599. nodeName = target.nodeName.toLowerCase();
  2600. inline = (nodeName === "div" || nodeName === "span");
  2601. if (!target.id) {
  2602. this.uuid += 1;
  2603. target.id = "dp" + this.uuid;
  2604. }
  2605. inst = this._newInst($(target), inline);
  2606. inst.settings = $.extend({}, settings || {});
  2607. if (nodeName === "input") {
  2608. this._connectDatepicker(target, inst);
  2609. } else if (inline) {
  2610. this._inlineDatepicker(target, inst);
  2611. }
  2612. },
  2613. /* Create a new instance object. */
  2614. _newInst: function(target, inline) {
  2615. var id = target[0].id.replace(/([^A-Za-z0-9_\-])/g, "\\\\$1"); // escape jQuery meta chars
  2616. return {id: id, input: target, // associated target
  2617. selectedDay: 0, selectedMonth: 0, selectedYear: 0, // current selection
  2618. drawMonth: 0, drawYear: 0, // month being drawn
  2619. inline: inline, // is datepicker inline or not
  2620. dpDiv: (!inline ? this.dpDiv : // presentation div
  2621. datepicker_bindHover($("<div class='" + this._inlineClass + " ui-datepicker ui-widget ui-widget-content ui-helper-clearfix ui-corner-all'></div>")))};
  2622. },
  2623. /* Attach the date picker to an input field. */
  2624. _connectDatepicker: function(target, inst) {
  2625. var input = $(target);
  2626. inst.append = $([]);
  2627. inst.trigger = $([]);
  2628. if (input.hasClass(this.markerClassName)) {
  2629. return;
  2630. }
  2631. this._attachments(input, inst);
  2632. input.addClass(this.markerClassName).keydown(this._doKeyDown).
  2633. keypress(this._doKeyPress).keyup(this._doKeyUp);
  2634. this._autoSize(inst);
  2635. $.data(target, "datepicker", inst);
  2636. //If disabled option is true, disable the datepicker once it has been attached to the input (see ticket #5665)
  2637. if( inst.settings.disabled ) {
  2638. this._disableDatepicker( target );
  2639. }
  2640. },
  2641. /* Make attachments based on settings. */
  2642. _attachments: function(input, inst) {
  2643. var showOn, buttonText, buttonImage,
  2644. appendText = this._get(inst, "appendText"),
  2645. isRTL = this._get(inst, "isRTL");
  2646. if (inst.append) {
  2647. inst.append.remove();
  2648. }
  2649. if (appendText) {
  2650. inst.append = $("<span class='" + this._appendClass + "'>" + appendText + "</span>");
  2651. input[isRTL ? "before" : "after"](inst.append);
  2652. }
  2653. input.unbind("focus", this._showDatepicker);
  2654. if (inst.trigger) {
  2655. inst.trigger.remove();
  2656. }
  2657. showOn = this._get(inst, "showOn");
  2658. if (showOn === "focus" || showOn === "both") { // pop-up date picker when in the marked field
  2659. input.focus(this._showDatepicker);
  2660. }
  2661. if (showOn === "button" || showOn === "both") { // pop-up date picker when button clicked
  2662. buttonText = this._get(inst, "buttonText");
  2663. buttonImage = this._get(inst, "buttonImage");
  2664. inst.trigger = $(this._get(inst, "buttonImageOnly") ?
  2665. $("<img/>").addClass(this._triggerClass).
  2666. attr({ src: buttonImage, alt: buttonText, title: buttonText }) :
  2667. $("<button type='button'></button>").addClass(this._triggerClass).
  2668. html(!buttonImage ? buttonText : $("<img/>").attr(
  2669. { src:buttonImage, alt:buttonText, title:buttonText })));
  2670. input[isRTL ? "before" : "after"](inst.trigger);
  2671. inst.trigger.click(function() {
  2672. if ($.datepicker._datepickerShowing && $.datepicker._lastInput === input[0]) {
  2673. $.datepicker._hideDatepicker();
  2674. } else if ($.datepicker._datepickerShowing && $.datepicker._lastInput !== input[0]) {
  2675. $.datepicker._hideDatepicker();
  2676. $.datepicker._showDatepicker(input[0]);
  2677. } else {
  2678. $.datepicker._showDatepicker(input[0]);
  2679. }
  2680. return false;
  2681. });
  2682. }
  2683. },
  2684. /* Apply the maximum length for the date format. */
  2685. _autoSize: function(inst) {
  2686. if (this._get(inst, "autoSize") && !inst.inline) {
  2687. var findMax, max, maxI, i,
  2688. date = new Date(2009, 12 - 1, 20), // Ensure double digits
  2689. dateFormat = this._get(inst, "dateFormat");
  2690. if (dateFormat.match(/[DM]/)) {
  2691. findMax = function(names) {
  2692. max = 0;
  2693. maxI = 0;
  2694. for (i = 0; i < names.length; i++) {
  2695. if (names[i].length > max) {
  2696. max = names[i].length;
  2697. maxI = i;
  2698. }
  2699. }
  2700. return maxI;
  2701. };
  2702. date.setMonth(findMax(this._get(inst, (dateFormat.match(/MM/) ?
  2703. "monthNames" : "monthNamesShort"))));
  2704. date.setDate(findMax(this._get(inst, (dateFormat.match(/DD/) ?
  2705. "dayNames" : "dayNamesShort"))) + 20 - date.getDay());
  2706. }
  2707. inst.input.attr("size", this._formatDate(inst, date).length);
  2708. }
  2709. },
  2710. /* Attach an inline date picker to a div. */
  2711. _inlineDatepicker: function(target, inst) {
  2712. var divSpan = $(target);
  2713. if (divSpan.hasClass(this.markerClassName)) {
  2714. return;
  2715. }
  2716. divSpan.addClass(this.markerClassName).append(inst.dpDiv);
  2717. $.data(target, "datepicker", inst);
  2718. this._setDate(inst, this._getDefaultDate(inst), true);
  2719. this._updateDatepicker(inst);
  2720. this._updateAlternate(inst);
  2721. //If disabled option is true, disable the datepicker before showing it (see ticket #5665)
  2722. if( inst.settings.disabled ) {
  2723. this._disableDatepicker( target );
  2724. }
  2725. // Set display:block in place of inst.dpDiv.show() which won't work on disconnected elements
  2726. // http://bugs.jqueryui.com/ticket/7552 - A Datepicker created on a detached div has zero height
  2727. inst.dpDiv.css( "display", "block" );
  2728. },
  2729. /* Pop-up the date picker in a "dialog" box.
  2730. * @param input element - ignored
  2731. * @param date string or Date - the initial date to display
  2732. * @param onSelect function - the function to call when a date is selected
  2733. * @param settings object - update the dialog date picker instance's settings (anonymous object)
  2734. * @param pos int[2] - coordinates for the dialog's position within the screen or
  2735. * event - with x/y coordinates or
  2736. * leave empty for default (screen centre)
  2737. * @return the manager object
  2738. */
  2739. _dialogDatepicker: function(input, date, onSelect, settings, pos) {
  2740. var id, browserWidth, browserHeight, scrollX, scrollY,
  2741. inst = this._dialogInst; // internal instance
  2742. if (!inst) {
  2743. this.uuid += 1;
  2744. id = "dp" + this.uuid;
  2745. this._dialogInput = $("<input type='text' id='" + id +
  2746. "' style='position: absolute; top: -100px; width: 0px;'/>");
  2747. this._dialogInput.keydown(this._doKeyDown);
  2748. $("body").append(this._dialogInput);
  2749. inst = this._dialogInst = this._newInst(this._dialogInput, false);
  2750. inst.settings = {};
  2751. $.data(this._dialogInput[0], "datepicker", inst);
  2752. }
  2753. datepicker_extendRemove(inst.settings, settings || {});
  2754. date = (date && date.constructor === Date ? this._formatDate(inst, date) : date);
  2755. this._dialogInput.val(date);
  2756. this._pos = (pos ? (pos.length ? pos : [pos.pageX, pos.pageY]) : null);
  2757. if (!this._pos) {
  2758. browserWidth = document.documentElement.clientWidth;
  2759. browserHeight = document.documentElement.clientHeight;
  2760. scrollX = document.documentElement.scrollLeft || document.body.scrollLeft;
  2761. scrollY = document.documentElement.scrollTop || document.body.scrollTop;
  2762. this._pos = // should use actual width/height below
  2763. [(browserWidth / 2) - 100 + scrollX, (browserHeight / 2) - 150 + scrollY];
  2764. }
  2765. // move input on screen for focus, but hidden behind dialog
  2766. this._dialogInput.css("left", (this._pos[0] + 20) + "px").css("top", this._pos[1] + "px");
  2767. inst.settings.onSelect = onSelect;
  2768. this._inDialog = true;
  2769. this.dpDiv.addClass(this._dialogClass);
  2770. this._showDatepicker(this._dialogInput[0]);
  2771. if ($.blockUI) {
  2772. $.blockUI(this.dpDiv);
  2773. }
  2774. $.data(this._dialogInput[0], "datepicker", inst);
  2775. return this;
  2776. },
  2777. /* Detach a datepicker from its control.
  2778. * @param target element - the target input field or division or span
  2779. */
  2780. _destroyDatepicker: function(target) {
  2781. var nodeName,
  2782. $target = $(target),
  2783. inst = $.data(target, "datepicker");
  2784. if (!$target.hasClass(this.markerClassName)) {
  2785. return;
  2786. }
  2787. nodeName = target.nodeName.toLowerCase();
  2788. $.removeData(target, "datepicker");
  2789. if (nodeName === "input") {
  2790. inst.append.remove();
  2791. inst.trigger.remove();
  2792. $target.removeClass(this.markerClassName).
  2793. unbind("focus", this._showDatepicker).
  2794. unbind("keydown", this._doKeyDown).
  2795. unbind("keypress", this._doKeyPress).
  2796. unbind("keyup", this._doKeyUp);
  2797. } else if (nodeName === "div" || nodeName === "span") {
  2798. $target.removeClass(this.markerClassName).empty();
  2799. }
  2800. if ( datepicker_instActive === inst ) {
  2801. datepicker_instActive = null;
  2802. }
  2803. },
  2804. /* Enable the date picker to a jQuery selection.
  2805. * @param target element - the target input field or division or span
  2806. */
  2807. _enableDatepicker: function(target) {
  2808. var nodeName, inline,
  2809. $target = $(target),
  2810. inst = $.data(target, "datepicker");
  2811. if (!$target.hasClass(this.markerClassName)) {
  2812. return;
  2813. }
  2814. nodeName = target.nodeName.toLowerCase();
  2815. if (nodeName === "input") {
  2816. target.disabled = false;
  2817. inst.trigger.filter("button").
  2818. each(function() { this.disabled = false; }).end().
  2819. filter("img").css({opacity: "1.0", cursor: ""});
  2820. } else if (nodeName === "div" || nodeName === "span") {
  2821. inline = $target.children("." + this._inlineClass);
  2822. inline.children().removeClass("ui-state-disabled");
  2823. inline.find("select.ui-datepicker-month, select.ui-datepicker-year").
  2824. prop("disabled", false);
  2825. }
  2826. this._disabledInputs = $.map(this._disabledInputs,
  2827. function(value) { return (value === target ? null : value); }); // delete entry
  2828. },
  2829. /* Disable the date picker to a jQuery selection.
  2830. * @param target element - the target input field or division or span
  2831. */
  2832. _disableDatepicker: function(target) {
  2833. var nodeName, inline,
  2834. $target = $(target),
  2835. inst = $.data(target, "datepicker");
  2836. if (!$target.hasClass(this.markerClassName)) {
  2837. return;
  2838. }
  2839. nodeName = target.nodeName.toLowerCase();
  2840. if (nodeName === "input") {
  2841. target.disabled = true;
  2842. inst.trigger.filter("button").
  2843. each(function() { this.disabled = true; }).end().
  2844. filter("img").css({opacity: "0.5", cursor: "default"});
  2845. } else if (nodeName === "div" || nodeName === "span") {
  2846. inline = $target.children("." + this._inlineClass);
  2847. inline.children().addClass("ui-state-disabled");
  2848. inline.find("select.ui-datepicker-month, select.ui-datepicker-year").
  2849. prop("disabled", true);
  2850. }
  2851. this._disabledInputs = $.map(this._disabledInputs,
  2852. function(value) { return (value === target ? null : value); }); // delete entry
  2853. this._disabledInputs[this._disabledInputs.length] = target;
  2854. },
  2855. /* Is the first field in a jQuery collection disabled as a datepicker?
  2856. * @param target element - the target input field or division or span
  2857. * @return boolean - true if disabled, false if enabled
  2858. */
  2859. _isDisabledDatepicker: function(target) {
  2860. if (!target) {
  2861. return false;
  2862. }
  2863. for (var i = 0; i < this._disabledInputs.length; i++) {
  2864. if (this._disabledInputs[i] === target) {
  2865. return true;
  2866. }
  2867. }
  2868. return false;
  2869. },
  2870. /* Retrieve the instance data for the target control.
  2871. * @param target element - the target input field or division or span
  2872. * @return object - the associated instance data
  2873. * @throws error if a jQuery problem getting data
  2874. */
  2875. _getInst: function(target) {
  2876. try {
  2877. return $.data(target, "datepicker");
  2878. }
  2879. catch (err) {
  2880. throw "Missing instance data for this datepicker";
  2881. }
  2882. },
  2883. /* Update or retrieve the settings for a date picker attached to an input field or division.
  2884. * @param target element - the target input field or division or span
  2885. * @param name object - the new settings to update or
  2886. * string - the name of the setting to change or retrieve,
  2887. * when retrieving also "all" for all instance settings or
  2888. * "defaults" for all global defaults
  2889. * @param value any - the new value for the setting
  2890. * (omit if above is an object or to retrieve a value)
  2891. */
  2892. _optionDatepicker: function(target, name, value) {
  2893. var settings, date, minDate, maxDate,
  2894. inst = this._getInst(target);
  2895. if (arguments.length === 2 && typeof name === "string") {
  2896. return (name === "defaults" ? $.extend({}, $.datepicker._defaults) :
  2897. (inst ? (name === "all" ? $.extend({}, inst.settings) :
  2898. this._get(inst, name)) : null));
  2899. }
  2900. settings = name || {};
  2901. if (typeof name === "string") {
  2902. settings = {};
  2903. settings[name] = value;
  2904. }
  2905. if (inst) {
  2906. if (this._curInst === inst) {
  2907. this._hideDatepicker();
  2908. }
  2909. date = this._getDateDatepicker(target, true);
  2910. minDate = this._getMinMaxDate(inst, "min");
  2911. maxDate = this._getMinMaxDate(inst, "max");
  2912. datepicker_extendRemove(inst.settings, settings);
  2913. // reformat the old minDate/maxDate values if dateFormat changes and a new minDate/maxDate isn't provided
  2914. if (minDate !== null && settings.dateFormat !== undefined && settings.minDate === undefined) {
  2915. inst.settings.minDate = this._formatDate(inst, minDate);
  2916. }
  2917. if (maxDate !== null && settings.dateFormat !== undefined && settings.maxDate === undefined) {
  2918. inst.settings.maxDate = this._formatDate(inst, maxDate);
  2919. }
  2920. if ( "disabled" in settings ) {
  2921. if ( settings.disabled ) {
  2922. this._disableDatepicker(target);
  2923. } else {
  2924. this._enableDatepicker(target);
  2925. }
  2926. }
  2927. this._attachments($(target), inst);
  2928. this._autoSize(inst);
  2929. this._setDate(inst, date);
  2930. this._updateAlternate(inst);
  2931. this._updateDatepicker(inst);
  2932. }
  2933. },
  2934. // change method deprecated
  2935. _changeDatepicker: function(target, name, value) {
  2936. this._optionDatepicker(target, name, value);
  2937. },
  2938. /* Redraw the date picker attached to an input field or division.
  2939. * @param target element - the target input field or division or span
  2940. */
  2941. _refreshDatepicker: function(target) {
  2942. var inst = this._getInst(target);
  2943. if (inst) {
  2944. this._updateDatepicker(inst);
  2945. }
  2946. },
  2947. /* Set the dates for a jQuery selection.
  2948. * @param target element - the target input field or division or span
  2949. * @param date Date - the new date
  2950. */
  2951. _setDateDatepicker: function(target, date) {
  2952. var inst = this._getInst(target);
  2953. if (inst) {
  2954. this._setDate(inst, date);
  2955. this._updateDatepicker(inst);
  2956. this._updateAlternate(inst);
  2957. }
  2958. },
  2959. /* Get the date(s) for the first entry in a jQuery selection.
  2960. * @param target element - the target input field or division or span
  2961. * @param noDefault boolean - true if no default date is to be used
  2962. * @return Date - the current date
  2963. */
  2964. _getDateDatepicker: function(target, noDefault) {
  2965. var inst = this._getInst(target);
  2966. if (inst && !inst.inline) {
  2967. this._setDateFromField(inst, noDefault);
  2968. }
  2969. return (inst ? this._getDate(inst) : null);
  2970. },
  2971. /* Handle keystrokes. */
  2972. _doKeyDown: function(event) {
  2973. var onSelect, dateStr, sel,
  2974. inst = $.datepicker._getInst(event.target),
  2975. handled = true,
  2976. isRTL = inst.dpDiv.is(".ui-datepicker-rtl");
  2977. inst._keyEvent = true;
  2978. if ($.datepicker._datepickerShowing) {
  2979. switch (event.keyCode) {
  2980. case 9: $.datepicker._hideDatepicker();
  2981. handled = false;
  2982. break; // hide on tab out
  2983. case 13: sel = $("td." + $.datepicker._dayOverClass + ":not(." +
  2984. $.datepicker._currentClass + ")", inst.dpDiv);
  2985. if (sel[0]) {
  2986. $.datepicker._selectDay(event.target, inst.selectedMonth, inst.selectedYear, sel[0]);
  2987. }
  2988. onSelect = $.datepicker._get(inst, "onSelect");
  2989. if (onSelect) {
  2990. dateStr = $.datepicker._formatDate(inst);
  2991. // trigger custom callback
  2992. onSelect.apply((inst.input ? inst.input[0] : null), [dateStr, inst]);
  2993. } else {
  2994. $.datepicker._hideDatepicker();
  2995. }
  2996. return false; // don't submit the form
  2997. case 27: $.datepicker._hideDatepicker();
  2998. break; // hide on escape
  2999. case 33: $.datepicker._adjustDate(event.target, (event.ctrlKey ?
  3000. -$.datepicker._get(inst, "stepBigMonths") :
  3001. -$.datepicker._get(inst, "stepMonths")), "M");
  3002. break; // previous month/year on page up/+ ctrl
  3003. case 34: $.datepicker._adjustDate(event.target, (event.ctrlKey ?
  3004. +$.datepicker._get(inst, "stepBigMonths") :
  3005. +$.datepicker._get(inst, "stepMonths")), "M");
  3006. break; // next month/year on page down/+ ctrl
  3007. case 35: if (event.ctrlKey || event.metaKey) {
  3008. $.datepicker._clearDate(event.target);
  3009. }
  3010. handled = event.ctrlKey || event.metaKey;
  3011. break; // clear on ctrl or command +end
  3012. case 36: if (event.ctrlKey || event.metaKey) {
  3013. $.datepicker._gotoToday(event.target);
  3014. }
  3015. handled = event.ctrlKey || event.metaKey;
  3016. break; // current on ctrl or command +home
  3017. case 37: if (event.ctrlKey || event.metaKey) {
  3018. $.datepicker._adjustDate(event.target, (isRTL ? +1 : -1), "D");
  3019. }
  3020. handled = event.ctrlKey || event.metaKey;
  3021. // -1 day on ctrl or command +left
  3022. if (event.originalEvent.altKey) {
  3023. $.datepicker._adjustDate(event.target, (event.ctrlKey ?
  3024. -$.datepicker._get(inst, "stepBigMonths") :
  3025. -$.datepicker._get(inst, "stepMonths")), "M");
  3026. }
  3027. // next month/year on alt +left on Mac
  3028. break;
  3029. case 38: if (event.ctrlKey || event.metaKey) {
  3030. $.datepicker._adjustDate(event.target, -7, "D");
  3031. }
  3032. handled = event.ctrlKey || event.metaKey;
  3033. break; // -1 week on ctrl or command +up
  3034. case 39: if (event.ctrlKey || event.metaKey) {
  3035. $.datepicker._adjustDate(event.target, (isRTL ? -1 : +1), "D");
  3036. }
  3037. handled = event.ctrlKey || event.metaKey;
  3038. // +1 day on ctrl or command +right
  3039. if (event.originalEvent.altKey) {
  3040. $.datepicker._adjustDate(event.target, (event.ctrlKey ?
  3041. +$.datepicker._get(inst, "stepBigMonths") :
  3042. +$.datepicker._get(inst, "stepMonths")), "M");
  3043. }
  3044. // next month/year on alt +right
  3045. break;
  3046. case 40: if (event.ctrlKey || event.metaKey) {
  3047. $.datepicker._adjustDate(event.target, +7, "D");
  3048. }
  3049. handled = event.ctrlKey || event.metaKey;
  3050. break; // +1 week on ctrl or command +down
  3051. default: handled = false;
  3052. }
  3053. } else if (event.keyCode === 36 && event.ctrlKey) { // display the date picker on ctrl+home
  3054. $.datepicker._showDatepicker(this);
  3055. } else {
  3056. handled = false;
  3057. }
  3058. if (handled) {
  3059. event.preventDefault();
  3060. event.stopPropagation();
  3061. }
  3062. },
  3063. /* Filter entered characters - based on date format. */
  3064. _doKeyPress: function(event) {
  3065. var chars, chr,
  3066. inst = $.datepicker._getInst(event.target);
  3067. if ($.datepicker._get(inst, "constrainInput")) {
  3068. chars = $.datepicker._possibleChars($.datepicker._get(inst, "dateFormat"));
  3069. chr = String.fromCharCode(event.charCode == null ? event.keyCode : event.charCode);
  3070. return event.ctrlKey || event.metaKey || (chr < " " || !chars || chars.indexOf(chr) > -1);
  3071. }
  3072. },
  3073. /* Synchronise manual entry and field/alternate field. */
  3074. _doKeyUp: function(event) {
  3075. var date,
  3076. inst = $.datepicker._getInst(event.target);
  3077. if (inst.input.val() !== inst.lastVal) {
  3078. try {
  3079. date = $.datepicker.parseDate($.datepicker._get(inst, "dateFormat"),
  3080. (inst.input ? inst.input.val() : null),
  3081. $.datepicker._getFormatConfig(inst));
  3082. if (date) { // only if valid
  3083. $.datepicker._setDateFromField(inst);
  3084. $.datepicker._updateAlternate(inst);
  3085. $.datepicker._updateDatepicker(inst);
  3086. }
  3087. }
  3088. catch (err) {
  3089. }
  3090. }
  3091. return true;
  3092. },
  3093. /* Pop-up the date picker for a given input field.
  3094. * If false returned from beforeShow event handler do not show.
  3095. * @param input element - the input field attached to the date picker or
  3096. * event - if triggered by focus
  3097. */
  3098. _showDatepicker: function(input) {
  3099. input = input.target || input;
  3100. if (input.nodeName.toLowerCase() !== "input") { // find from button/image trigger
  3101. input = $("input", input.parentNode)[0];
  3102. }
  3103. if ($.datepicker._isDisabledDatepicker(input) || $.datepicker._lastInput === input) { // already here
  3104. return;
  3105. }
  3106. var inst, beforeShow, beforeShowSettings, isFixed,
  3107. offset, showAnim, duration;
  3108. inst = $.datepicker._getInst(input);
  3109. if ($.datepicker._curInst && $.datepicker._curInst !== inst) {
  3110. $.datepicker._curInst.dpDiv.stop(true, true);
  3111. if ( inst && $.datepicker._datepickerShowing ) {
  3112. $.datepicker._hideDatepicker( $.datepicker._curInst.input[0] );
  3113. }
  3114. }
  3115. beforeShow = $.datepicker._get(inst, "beforeShow");
  3116. beforeShowSettings = beforeShow ? beforeShow.apply(input, [input, inst]) : {};
  3117. if(beforeShowSettings === false){
  3118. return;
  3119. }
  3120. datepicker_extendRemove(inst.settings, beforeShowSettings);
  3121. inst.lastVal = null;
  3122. $.datepicker._lastInput = input;
  3123. $.datepicker._setDateFromField(inst);
  3124. if ($.datepicker._inDialog) { // hide cursor
  3125. input.value = "";
  3126. }
  3127. if (!$.datepicker._pos) { // position below input
  3128. $.datepicker._pos = $.datepicker._findPos(input);
  3129. $.datepicker._pos[1] += input.offsetHeight; // add the height
  3130. }
  3131. isFixed = false;
  3132. $(input).parents().each(function() {
  3133. isFixed |= $(this).css("position") === "fixed";
  3134. return !isFixed;
  3135. });
  3136. offset = {left: $.datepicker._pos[0], top: $.datepicker._pos[1]};
  3137. $.datepicker._pos = null;
  3138. //to avoid flashes on Firefox
  3139. inst.dpDiv.empty();
  3140. // determine sizing offscreen
  3141. inst.dpDiv.css({position: "absolute", display: "block", top: "-1000px"});
  3142. $.datepicker._updateDatepicker(inst);
  3143. // fix width for dynamic number of date pickers
  3144. // and adjust position before showing
  3145. offset = $.datepicker._checkOffset(inst, offset, isFixed);
  3146. inst.dpDiv.css({position: ($.datepicker._inDialog && $.blockUI ?
  3147. "static" : (isFixed ? "fixed" : "absolute")), display: "none",
  3148. left: offset.left + "px", top: offset.top + "px"});
  3149. if (!inst.inline) {
  3150. showAnim = $.datepicker._get(inst, "showAnim");
  3151. duration = $.datepicker._get(inst, "duration");
  3152. inst.dpDiv.css( "z-index", datepicker_getZindex( $( input ) ) + 1 );
  3153. $.datepicker._datepickerShowing = true;
  3154. if ( $.effects && $.effects.effect[ showAnim ] ) {
  3155. inst.dpDiv.show(showAnim, $.datepicker._get(inst, "showOptions"), duration);
  3156. } else {
  3157. inst.dpDiv[showAnim || "show"](showAnim ? duration : null);
  3158. }
  3159. if ( $.datepicker._shouldFocusInput( inst ) ) {
  3160. inst.input.focus();
  3161. }
  3162. $.datepicker._curInst = inst;
  3163. }
  3164. },
  3165. /* Generate the date picker content. */
  3166. _updateDatepicker: function(inst) {
  3167. this.maxRows = 4; //Reset the max number of rows being displayed (see #7043)
  3168. datepicker_instActive = inst; // for delegate hover events
  3169. inst.dpDiv.empty().append(this._generateHTML(inst));
  3170. this._attachHandlers(inst);
  3171. var origyearshtml,
  3172. numMonths = this._getNumberOfMonths(inst),
  3173. cols = numMonths[1],
  3174. width = 17,
  3175. activeCell = inst.dpDiv.find( "." + this._dayOverClass + " a" );
  3176. if ( activeCell.length > 0 ) {
  3177. datepicker_handleMouseover.apply( activeCell.get( 0 ) );
  3178. }
  3179. inst.dpDiv.removeClass("ui-datepicker-multi-2 ui-datepicker-multi-3 ui-datepicker-multi-4").width("");
  3180. if (cols > 1) {
  3181. inst.dpDiv.addClass("ui-datepicker-multi-" + cols).css("width", (width * cols) + "em");
  3182. }
  3183. inst.dpDiv[(numMonths[0] !== 1 || numMonths[1] !== 1 ? "add" : "remove") +
  3184. "Class"]("ui-datepicker-multi");
  3185. inst.dpDiv[(this._get(inst, "isRTL") ? "add" : "remove") +
  3186. "Class"]("ui-datepicker-rtl");
  3187. if (inst === $.datepicker._curInst && $.datepicker._datepickerShowing && $.datepicker._shouldFocusInput( inst ) ) {
  3188. inst.input.focus();
  3189. }
  3190. // deffered render of the years select (to avoid flashes on Firefox)
  3191. if( inst.yearshtml ){
  3192. origyearshtml = inst.yearshtml;
  3193. setTimeout(function(){
  3194. //assure that inst.yearshtml didn't change.
  3195. if( origyearshtml === inst.yearshtml && inst.yearshtml ){
  3196. inst.dpDiv.find("select.ui-datepicker-year:first").replaceWith(inst.yearshtml);
  3197. }
  3198. origyearshtml = inst.yearshtml = null;
  3199. }, 0);
  3200. }
  3201. },
  3202. // #6694 - don't focus the input if it's already focused
  3203. // this breaks the change event in IE
  3204. // Support: IE and jQuery <1.9
  3205. _shouldFocusInput: function( inst ) {
  3206. return inst.input && inst.input.is( ":visible" ) && !inst.input.is( ":disabled" ) && !inst.input.is( ":focus" );
  3207. },
  3208. /* Check positioning to remain on screen. */
  3209. _checkOffset: function(inst, offset, isFixed) {
  3210. var dpWidth = inst.dpDiv.outerWidth(),
  3211. dpHeight = inst.dpDiv.outerHeight(),
  3212. inputWidth = inst.input ? inst.input.outerWidth() : 0,
  3213. inputHeight = inst.input ? inst.input.outerHeight() : 0,
  3214. viewWidth = document.documentElement.clientWidth + (isFixed ? 0 : $(document).scrollLeft()),
  3215. viewHeight = document.documentElement.clientHeight + (isFixed ? 0 : $(document).scrollTop());
  3216. offset.left -= (this._get(inst, "isRTL") ? (dpWidth - inputWidth) : 0);
  3217. offset.left -= (isFixed && offset.left === inst.input.offset().left) ? $(document).scrollLeft() : 0;
  3218. offset.top -= (isFixed && offset.top === (inst.input.offset().top + inputHeight)) ? $(document).scrollTop() : 0;
  3219. // now check if datepicker is showing outside window viewport - move to a better place if so.
  3220. offset.left -= Math.min(offset.left, (offset.left + dpWidth > viewWidth && viewWidth > dpWidth) ?
  3221. Math.abs(offset.left + dpWidth - viewWidth) : 0);
  3222. offset.top -= Math.min(offset.top, (offset.top + dpHeight > viewHeight && viewHeight > dpHeight) ?
  3223. Math.abs(dpHeight + inputHeight) : 0);
  3224. return offset;
  3225. },
  3226. /* Find an object's position on the screen. */
  3227. _findPos: function(obj) {
  3228. var position,
  3229. inst = this._getInst(obj),
  3230. isRTL = this._get(inst, "isRTL");
  3231. while (obj && (obj.type === "hidden" || obj.nodeType !== 1 || $.expr.filters.hidden(obj))) {
  3232. obj = obj[isRTL ? "previousSibling" : "nextSibling"];
  3233. }
  3234. position = $(obj).offset();
  3235. return [position.left, position.top];
  3236. },
  3237. /* Hide the date picker from view.
  3238. * @param input element - the input field attached to the date picker
  3239. */
  3240. _hideDatepicker: function(input) {
  3241. var showAnim, duration, postProcess, onClose,
  3242. inst = this._curInst;
  3243. if (!inst || (input && inst !== $.data(input, "datepicker"))) {
  3244. return;
  3245. }
  3246. if (this._datepickerShowing) {
  3247. showAnim = this._get(inst, "showAnim");
  3248. duration = this._get(inst, "duration");
  3249. postProcess = function() {
  3250. $.datepicker._tidyDialog(inst);
  3251. };
  3252. // DEPRECATED: after BC for 1.8.x $.effects[ showAnim ] is not needed
  3253. if ( $.effects && ( $.effects.effect[ showAnim ] || $.effects[ showAnim ] ) ) {
  3254. inst.dpDiv.hide(showAnim, $.datepicker._get(inst, "showOptions"), duration, postProcess);
  3255. } else {
  3256. inst.dpDiv[(showAnim === "slideDown" ? "slideUp" :
  3257. (showAnim === "fadeIn" ? "fadeOut" : "hide"))]((showAnim ? duration : null), postProcess);
  3258. }
  3259. if (!showAnim) {
  3260. postProcess();
  3261. }
  3262. this._datepickerShowing = false;
  3263. onClose = this._get(inst, "onClose");
  3264. if (onClose) {
  3265. onClose.apply((inst.input ? inst.input[0] : null), [(inst.input ? inst.input.val() : ""), inst]);
  3266. }
  3267. this._lastInput = null;
  3268. if (this._inDialog) {
  3269. this._dialogInput.css({ position: "absolute", left: "0", top: "-100px" });
  3270. if ($.blockUI) {
  3271. $.unblockUI();
  3272. $("body").append(this.dpDiv);
  3273. }
  3274. }
  3275. this._inDialog = false;
  3276. }
  3277. },
  3278. /* Tidy up after a dialog display. */
  3279. _tidyDialog: function(inst) {
  3280. inst.dpDiv.removeClass(this._dialogClass).unbind(".ui-datepicker-calendar");
  3281. },
  3282. /* Close date picker if clicked elsewhere. */
  3283. _checkExternalClick: function(event) {
  3284. if (!$.datepicker._curInst) {
  3285. return;
  3286. }
  3287. var $target = $(event.target),
  3288. inst = $.datepicker._getInst($target[0]);
  3289. if ( ( ( $target[0].id !== $.datepicker._mainDivId &&
  3290. $target.parents("#" + $.datepicker._mainDivId).length === 0 &&
  3291. !$target.hasClass($.datepicker.markerClassName) &&
  3292. !$target.closest("." + $.datepicker._triggerClass).length &&
  3293. $.datepicker._datepickerShowing && !($.datepicker._inDialog && $.blockUI) ) ) ||
  3294. ( $target.hasClass($.datepicker.markerClassName) && $.datepicker._curInst !== inst ) ) {
  3295. $.datepicker._hideDatepicker();
  3296. }
  3297. },
  3298. /* Adjust one of the date sub-fields. */
  3299. _adjustDate: function(id, offset, period) {
  3300. var target = $(id),
  3301. inst = this._getInst(target[0]);
  3302. if (this._isDisabledDatepicker(target[0])) {
  3303. return;
  3304. }
  3305. this._adjustInstDate(inst, offset +
  3306. (period === "M" ? this._get(inst, "showCurrentAtPos") : 0), // undo positioning
  3307. period);
  3308. this._updateDatepicker(inst);
  3309. },
  3310. /* Action for current link. */
  3311. _gotoToday: function(id) {
  3312. var date,
  3313. target = $(id),
  3314. inst = this._getInst(target[0]);
  3315. if (this._get(inst, "gotoCurrent") && inst.currentDay) {
  3316. inst.selectedDay = inst.currentDay;
  3317. inst.drawMonth = inst.selectedMonth = inst.currentMonth;
  3318. inst.drawYear = inst.selectedYear = inst.currentYear;
  3319. } else {
  3320. date = new Date();
  3321. inst.selectedDay = date.getDate();
  3322. inst.drawMonth = inst.selectedMonth = date.getMonth();
  3323. inst.drawYear = inst.selectedYear = date.getFullYear();
  3324. }
  3325. this._notifyChange(inst);
  3326. this._adjustDate(target);
  3327. },
  3328. /* Action for selecting a new month/year. */
  3329. _selectMonthYear: function(id, select, period) {
  3330. var target = $(id),
  3331. inst = this._getInst(target[0]);
  3332. inst["selected" + (period === "M" ? "Month" : "Year")] =
  3333. inst["draw" + (period === "M" ? "Month" : "Year")] =
  3334. parseInt(select.options[select.selectedIndex].value,10);
  3335. this._notifyChange(inst);
  3336. this._adjustDate(target);
  3337. },
  3338. /* Action for selecting a day. */
  3339. _selectDay: function(id, month, year, td) {
  3340. var inst,
  3341. target = $(id);
  3342. if ($(td).hasClass(this._unselectableClass) || this._isDisabledDatepicker(target[0])) {
  3343. return;
  3344. }
  3345. inst = this._getInst(target[0]);
  3346. inst.selectedDay = inst.currentDay = $("a", td).html();
  3347. inst.selectedMonth = inst.currentMonth = month;
  3348. inst.selectedYear = inst.currentYear = year;
  3349. this._selectDate(id, this._formatDate(inst,
  3350. inst.currentDay, inst.currentMonth, inst.currentYear));
  3351. },
  3352. /* Erase the input field and hide the date picker. */
  3353. _clearDate: function(id) {
  3354. var target = $(id);
  3355. this._selectDate(target, "");
  3356. },
  3357. /* Update the input field with the selected date. */
  3358. _selectDate: function(id, dateStr) {
  3359. var onSelect,
  3360. target = $(id),
  3361. inst = this._getInst(target[0]);
  3362. dateStr = (dateStr != null ? dateStr : this._formatDate(inst));
  3363. if (inst.input) {
  3364. inst.input.val(dateStr);
  3365. }
  3366. this._updateAlternate(inst);
  3367. onSelect = this._get(inst, "onSelect");
  3368. if (onSelect) {
  3369. onSelect.apply((inst.input ? inst.input[0] : null), [dateStr, inst]); // trigger custom callback
  3370. } else if (inst.input) {
  3371. inst.input.trigger("change"); // fire the change event
  3372. }
  3373. if (inst.inline){
  3374. this._updateDatepicker(inst);
  3375. } else {
  3376. this._hideDatepicker();
  3377. this._lastInput = inst.input[0];
  3378. if (typeof(inst.input[0]) !== "object") {
  3379. inst.input.focus(); // restore focus
  3380. }
  3381. this._lastInput = null;
  3382. }
  3383. },
  3384. /* Update any alternate field to synchronise with the main field. */
  3385. _updateAlternate: function(inst) {
  3386. var altFormat, date, dateStr,
  3387. altField = this._get(inst, "altField");
  3388. if (altField) { // update alternate field too
  3389. altFormat = this._get(inst, "altFormat") || this._get(inst, "dateFormat");
  3390. date = this._getDate(inst);
  3391. dateStr = this.formatDate(altFormat, date, this._getFormatConfig(inst));
  3392. $(altField).each(function() { $(this).val(dateStr); });
  3393. }
  3394. },
  3395. /* Set as beforeShowDay function to prevent selection of weekends.
  3396. * @param date Date - the date to customise
  3397. * @return [boolean, string] - is this date selectable?, what is its CSS class?
  3398. */
  3399. noWeekends: function(date) {
  3400. var day = date.getDay();
  3401. return [(day > 0 && day < 6), ""];
  3402. },
  3403. /* Set as calculateWeek to determine the week of the year based on the ISO 8601 definition.
  3404. * @param date Date - the date to get the week for
  3405. * @return number - the number of the week within the year that contains this date
  3406. */
  3407. iso8601Week: function(date) {
  3408. var time,
  3409. checkDate = new Date(date.getTime());
  3410. // Find Thursday of this week starting on Monday
  3411. checkDate.setDate(checkDate.getDate() + 4 - (checkDate.getDay() || 7));
  3412. time = checkDate.getTime();
  3413. checkDate.setMonth(0); // Compare with Jan 1
  3414. checkDate.setDate(1);
  3415. return Math.floor(Math.round((time - checkDate) / 86400000) / 7) + 1;
  3416. },
  3417. /* Parse a string value into a date object.
  3418. * See formatDate below for the possible formats.
  3419. *
  3420. * @param format string - the expected format of the date
  3421. * @param value string - the date in the above format
  3422. * @param settings Object - attributes include:
  3423. * shortYearCutoff number - the cutoff year for determining the century (optional)
  3424. * dayNamesShort string[7] - abbreviated names of the days from Sunday (optional)
  3425. * dayNames string[7] - names of the days from Sunday (optional)
  3426. * monthNamesShort string[12] - abbreviated names of the months (optional)
  3427. * monthNames string[12] - names of the months (optional)
  3428. * @return Date - the extracted date value or null if value is blank
  3429. */
  3430. parseDate: function (format, value, settings) {
  3431. if (format == null || value == null) {
  3432. throw "Invalid arguments";
  3433. }
  3434. value = (typeof value === "object" ? value.toString() : value + "");
  3435. if (value === "") {
  3436. return null;
  3437. }
  3438. var iFormat, dim, extra,
  3439. iValue = 0,
  3440. shortYearCutoffTemp = (settings ? settings.shortYearCutoff : null) || this._defaults.shortYearCutoff,
  3441. shortYearCutoff = (typeof shortYearCutoffTemp !== "string" ? shortYearCutoffTemp :
  3442. new Date().getFullYear() % 100 + parseInt(shortYearCutoffTemp, 10)),
  3443. dayNamesShort = (settings ? settings.dayNamesShort : null) || this._defaults.dayNamesShort,
  3444. dayNames = (settings ? settings.dayNames : null) || this._defaults.dayNames,
  3445. monthNamesShort = (settings ? settings.monthNamesShort : null) || this._defaults.monthNamesShort,
  3446. monthNames = (settings ? settings.monthNames : null) || this._defaults.monthNames,
  3447. year = -1,
  3448. month = -1,
  3449. day = -1,
  3450. doy = -1,
  3451. literal = false,
  3452. date,
  3453. // Check whether a format character is doubled
  3454. lookAhead = function(match) {
  3455. var matches = (iFormat + 1 < format.length && format.charAt(iFormat + 1) === match);
  3456. if (matches) {
  3457. iFormat++;
  3458. }
  3459. return matches;
  3460. },
  3461. // Extract a number from the string value
  3462. getNumber = function(match) {
  3463. var isDoubled = lookAhead(match),
  3464. size = (match === "@" ? 14 : (match === "!" ? 20 :
  3465. (match === "y" && isDoubled ? 4 : (match === "o" ? 3 : 2)))),
  3466. minSize = (match === "y" ? size : 1),
  3467. digits = new RegExp("^\\d{" + minSize + "," + size + "}"),
  3468. num = value.substring(iValue).match(digits);
  3469. if (!num) {
  3470. throw "Missing number at position " + iValue;
  3471. }
  3472. iValue += num[0].length;
  3473. return parseInt(num[0], 10);
  3474. },
  3475. // Extract a name from the string value and convert to an index
  3476. getName = function(match, shortNames, longNames) {
  3477. var index = -1,
  3478. names = $.map(lookAhead(match) ? longNames : shortNames, function (v, k) {
  3479. return [ [k, v] ];
  3480. }).sort(function (a, b) {
  3481. return -(a[1].length - b[1].length);
  3482. });
  3483. $.each(names, function (i, pair) {
  3484. var name = pair[1];
  3485. if (value.substr(iValue, name.length).toLowerCase() === name.toLowerCase()) {
  3486. index = pair[0];
  3487. iValue += name.length;
  3488. return false;
  3489. }
  3490. });
  3491. if (index !== -1) {
  3492. return index + 1;
  3493. } else {
  3494. throw "Unknown name at position " + iValue;
  3495. }
  3496. },
  3497. // Confirm that a literal character matches the string value
  3498. checkLiteral = function() {
  3499. if (value.charAt(iValue) !== format.charAt(iFormat)) {
  3500. throw "Unexpected literal at position " + iValue;
  3501. }
  3502. iValue++;
  3503. };
  3504. for (iFormat = 0; iFormat < format.length; iFormat++) {
  3505. if (literal) {
  3506. if (format.charAt(iFormat) === "'" && !lookAhead("'")) {
  3507. literal = false;
  3508. } else {
  3509. checkLiteral();
  3510. }
  3511. } else {
  3512. switch (format.charAt(iFormat)) {
  3513. case "d":
  3514. day = getNumber("d");
  3515. break;
  3516. case "D":
  3517. getName("D", dayNamesShort, dayNames);
  3518. break;
  3519. case "o":
  3520. doy = getNumber("o");
  3521. break;
  3522. case "m":
  3523. month = getNumber("m");
  3524. break;
  3525. case "M":
  3526. month = getName("M", monthNamesShort, monthNames);
  3527. break;
  3528. case "y":
  3529. year = getNumber("y");
  3530. break;
  3531. case "@":
  3532. date = new Date(getNumber("@"));
  3533. year = date.getFullYear();
  3534. month = date.getMonth() + 1;
  3535. day = date.getDate();
  3536. break;
  3537. case "!":
  3538. date = new Date((getNumber("!") - this._ticksTo1970) / 10000);
  3539. year = date.getFullYear();
  3540. month = date.getMonth() + 1;
  3541. day = date.getDate();
  3542. break;
  3543. case "'":
  3544. if (lookAhead("'")){
  3545. checkLiteral();
  3546. } else {
  3547. literal = true;
  3548. }
  3549. break;
  3550. default:
  3551. checkLiteral();
  3552. }
  3553. }
  3554. }
  3555. if (iValue < value.length){
  3556. extra = value.substr(iValue);
  3557. if (!/^\s+/.test(extra)) {
  3558. throw "Extra/unparsed characters found in date: " + extra;
  3559. }
  3560. }
  3561. if (year === -1) {
  3562. year = new Date().getFullYear();
  3563. } else if (year < 100) {
  3564. year += new Date().getFullYear() - new Date().getFullYear() % 100 +
  3565. (year <= shortYearCutoff ? 0 : -100);
  3566. }
  3567. if (doy > -1) {
  3568. month = 1;
  3569. day = doy;
  3570. do {
  3571. dim = this._getDaysInMonth(year, month - 1);
  3572. if (day <= dim) {
  3573. break;
  3574. }
  3575. month++;
  3576. day -= dim;
  3577. } while (true);
  3578. }
  3579. date = this._daylightSavingAdjust(new Date(year, month - 1, day));
  3580. if (date.getFullYear() !== year || date.getMonth() + 1 !== month || date.getDate() !== day) {
  3581. throw "Invalid date"; // E.g. 31/02/00
  3582. }
  3583. return date;
  3584. },
  3585. /* Standard date formats. */
  3586. ATOM: "yy-mm-dd", // RFC 3339 (ISO 8601)
  3587. COOKIE: "D, dd M yy",
  3588. ISO_8601: "yy-mm-dd",
  3589. RFC_822: "D, d M y",
  3590. RFC_850: "DD, dd-M-y",
  3591. RFC_1036: "D, d M y",
  3592. RFC_1123: "D, d M yy",
  3593. RFC_2822: "D, d M yy",
  3594. RSS: "D, d M y", // RFC 822
  3595. TICKS: "!",
  3596. TIMESTAMP: "@",
  3597. W3C: "yy-mm-dd", // ISO 8601
  3598. _ticksTo1970: (((1970 - 1) * 365 + Math.floor(1970 / 4) - Math.floor(1970 / 100) +
  3599. Math.floor(1970 / 400)) * 24 * 60 * 60 * 10000000),
  3600. /* Format a date object into a string value.
  3601. * The format can be combinations of the following:
  3602. * d - day of month (no leading zero)
  3603. * dd - day of month (two digit)
  3604. * o - day of year (no leading zeros)
  3605. * oo - day of year (three digit)
  3606. * D - day name short
  3607. * DD - day name long
  3608. * m - month of year (no leading zero)
  3609. * mm - month of year (two digit)
  3610. * M - month name short
  3611. * MM - month name long
  3612. * y - year (two digit)
  3613. * yy - year (four digit)
  3614. * @ - Unix timestamp (ms since 01/01/1970)
  3615. * ! - Windows ticks (100ns since 01/01/0001)
  3616. * "..." - literal text
  3617. * '' - single quote
  3618. *
  3619. * @param format string - the desired format of the date
  3620. * @param date Date - the date value to format
  3621. * @param settings Object - attributes include:
  3622. * dayNamesShort string[7] - abbreviated names of the days from Sunday (optional)
  3623. * dayNames string[7] - names of the days from Sunday (optional)
  3624. * monthNamesShort string[12] - abbreviated names of the months (optional)
  3625. * monthNames string[12] - names of the months (optional)
  3626. * @return string - the date in the above format
  3627. */
  3628. formatDate: function (format, date, settings) {
  3629. if (!date) {
  3630. return "";
  3631. }
  3632. var iFormat,
  3633. dayNamesShort = (settings ? settings.dayNamesShort : null) || this._defaults.dayNamesShort,
  3634. dayNames = (settings ? settings.dayNames : null) || this._defaults.dayNames,
  3635. monthNamesShort = (settings ? settings.monthNamesShort : null) || this._defaults.monthNamesShort,
  3636. monthNames = (settings ? settings.monthNames : null) || this._defaults.monthNames,
  3637. // Check whether a format character is doubled
  3638. lookAhead = function(match) {
  3639. var matches = (iFormat + 1 < format.length && format.charAt(iFormat + 1) === match);
  3640. if (matches) {
  3641. iFormat++;
  3642. }
  3643. return matches;
  3644. },
  3645. // Format a number, with leading zero if necessary
  3646. formatNumber = function(match, value, len) {
  3647. var num = "" + value;
  3648. if (lookAhead(match)) {
  3649. while (num.length < len) {
  3650. num = "0" + num;
  3651. }
  3652. }
  3653. return num;
  3654. },
  3655. // Format a name, short or long as requested
  3656. formatName = function(match, value, shortNames, longNames) {
  3657. return (lookAhead(match) ? longNames[value] : shortNames[value]);
  3658. },
  3659. output = "",
  3660. literal = false;
  3661. if (date) {
  3662. for (iFormat = 0; iFormat < format.length; iFormat++) {
  3663. if (literal) {
  3664. if (format.charAt(iFormat) === "'" && !lookAhead("'")) {
  3665. literal = false;
  3666. } else {
  3667. output += format.charAt(iFormat);
  3668. }
  3669. } else {
  3670. switch (format.charAt(iFormat)) {
  3671. case "d":
  3672. output += formatNumber("d", date.getDate(), 2);
  3673. break;
  3674. case "D":
  3675. output += formatName("D", date.getDay(), dayNamesShort, dayNames);
  3676. break;
  3677. case "o":
  3678. output += formatNumber("o",
  3679. Math.round((new Date(date.getFullYear(), date.getMonth(), date.getDate()).getTime() - new Date(date.getFullYear(), 0, 0).getTime()) / 86400000), 3);
  3680. break;
  3681. case "m":
  3682. output += formatNumber("m", date.getMonth() + 1, 2);
  3683. break;
  3684. case "M":
  3685. output += formatName("M", date.getMonth(), monthNamesShort, monthNames);
  3686. break;
  3687. case "y":
  3688. output += (lookAhead("y") ? date.getFullYear() :
  3689. (date.getYear() % 100 < 10 ? "0" : "") + date.getYear() % 100);
  3690. break;
  3691. case "@":
  3692. output += date.getTime();
  3693. break;
  3694. case "!":
  3695. output += date.getTime() * 10000 + this._ticksTo1970;
  3696. break;
  3697. case "'":
  3698. if (lookAhead("'")) {
  3699. output += "'";
  3700. } else {
  3701. literal = true;
  3702. }
  3703. break;
  3704. default:
  3705. output += format.charAt(iFormat);
  3706. }
  3707. }
  3708. }
  3709. }
  3710. return output;
  3711. },
  3712. /* Extract all possible characters from the date format. */
  3713. _possibleChars: function (format) {
  3714. var iFormat,
  3715. chars = "",
  3716. literal = false,
  3717. // Check whether a format character is doubled
  3718. lookAhead = function(match) {
  3719. var matches = (iFormat + 1 < format.length && format.charAt(iFormat + 1) === match);
  3720. if (matches) {
  3721. iFormat++;
  3722. }
  3723. return matches;
  3724. };
  3725. for (iFormat = 0; iFormat < format.length; iFormat++) {
  3726. if (literal) {
  3727. if (format.charAt(iFormat) === "'" && !lookAhead("'")) {
  3728. literal = false;
  3729. } else {
  3730. chars += format.charAt(iFormat);
  3731. }
  3732. } else {
  3733. switch (format.charAt(iFormat)) {
  3734. case "d": case "m": case "y": case "@":
  3735. chars += "0123456789";
  3736. break;
  3737. case "D": case "M":
  3738. return null; // Accept anything
  3739. case "'":
  3740. if (lookAhead("'")) {
  3741. chars += "'";
  3742. } else {
  3743. literal = true;
  3744. }
  3745. break;
  3746. default:
  3747. chars += format.charAt(iFormat);
  3748. }
  3749. }
  3750. }
  3751. return chars;
  3752. },
  3753. /* Get a setting value, defaulting if necessary. */
  3754. _get: function(inst, name) {
  3755. return inst.settings[name] !== undefined ?
  3756. inst.settings[name] : this._defaults[name];
  3757. },
  3758. /* Parse existing date and initialise date picker. */
  3759. _setDateFromField: function(inst, noDefault) {
  3760. if (inst.input.val() === inst.lastVal) {
  3761. return;
  3762. }
  3763. var dateFormat = this._get(inst, "dateFormat"),
  3764. dates = inst.lastVal = inst.input ? inst.input.val() : null,
  3765. defaultDate = this._getDefaultDate(inst),
  3766. date = defaultDate,
  3767. settings = this._getFormatConfig(inst);
  3768. try {
  3769. date = this.parseDate(dateFormat, dates, settings) || defaultDate;
  3770. } catch (event) {
  3771. dates = (noDefault ? "" : dates);
  3772. }
  3773. inst.selectedDay = date.getDate();
  3774. inst.drawMonth = inst.selectedMonth = date.getMonth();
  3775. inst.drawYear = inst.selectedYear = date.getFullYear();
  3776. inst.currentDay = (dates ? date.getDate() : 0);
  3777. inst.currentMonth = (dates ? date.getMonth() : 0);
  3778. inst.currentYear = (dates ? date.getFullYear() : 0);
  3779. this._adjustInstDate(inst);
  3780. },
  3781. /* Retrieve the default date shown on opening. */
  3782. _getDefaultDate: function(inst) {
  3783. return this._restrictMinMax(inst,
  3784. this._determineDate(inst, this._get(inst, "defaultDate"), new Date()));
  3785. },
  3786. /* A date may be specified as an exact value or a relative one. */
  3787. _determineDate: function(inst, date, defaultDate) {
  3788. var offsetNumeric = function(offset) {
  3789. var date = new Date();
  3790. date.setDate(date.getDate() + offset);
  3791. return date;
  3792. },
  3793. offsetString = function(offset) {
  3794. try {
  3795. return $.datepicker.parseDate($.datepicker._get(inst, "dateFormat"),
  3796. offset, $.datepicker._getFormatConfig(inst));
  3797. }
  3798. catch (e) {
  3799. // Ignore
  3800. }
  3801. var date = (offset.toLowerCase().match(/^c/) ?
  3802. $.datepicker._getDate(inst) : null) || new Date(),
  3803. year = date.getFullYear(),
  3804. month = date.getMonth(),
  3805. day = date.getDate(),
  3806. pattern = /([+\-]?[0-9]+)\s*(d|D|w|W|m|M|y|Y)?/g,
  3807. matches = pattern.exec(offset);
  3808. while (matches) {
  3809. switch (matches[2] || "d") {
  3810. case "d" : case "D" :
  3811. day += parseInt(matches[1],10); break;
  3812. case "w" : case "W" :
  3813. day += parseInt(matches[1],10) * 7; break;
  3814. case "m" : case "M" :
  3815. month += parseInt(matches[1],10);
  3816. day = Math.min(day, $.datepicker._getDaysInMonth(year, month));
  3817. break;
  3818. case "y": case "Y" :
  3819. year += parseInt(matches[1],10);
  3820. day = Math.min(day, $.datepicker._getDaysInMonth(year, month));
  3821. break;
  3822. }
  3823. matches = pattern.exec(offset);
  3824. }
  3825. return new Date(year, month, day);
  3826. },
  3827. newDate = (date == null || date === "" ? defaultDate : (typeof date === "string" ? offsetString(date) :
  3828. (typeof date === "number" ? (isNaN(date) ? defaultDate : offsetNumeric(date)) : new Date(date.getTime()))));
  3829. newDate = (newDate && newDate.toString() === "Invalid Date" ? defaultDate : newDate);
  3830. if (newDate) {
  3831. newDate.setHours(0);
  3832. newDate.setMinutes(0);
  3833. newDate.setSeconds(0);
  3834. newDate.setMilliseconds(0);
  3835. }
  3836. return this._daylightSavingAdjust(newDate);
  3837. },
  3838. /* Handle switch to/from daylight saving.
  3839. * Hours may be non-zero on daylight saving cut-over:
  3840. * > 12 when midnight changeover, but then cannot generate
  3841. * midnight datetime, so jump to 1AM, otherwise reset.
  3842. * @param date (Date) the date to check
  3843. * @return (Date) the corrected date
  3844. */
  3845. _daylightSavingAdjust: function(date) {
  3846. if (!date) {
  3847. return null;
  3848. }
  3849. date.setHours(date.getHours() > 12 ? date.getHours() + 2 : 0);
  3850. return date;
  3851. },
  3852. /* Set the date(s) directly. */
  3853. _setDate: function(inst, date, noChange) {
  3854. var clear = !date,
  3855. origMonth = inst.selectedMonth,
  3856. origYear = inst.selectedYear,
  3857. newDate = this._restrictMinMax(inst, this._determineDate(inst, date, new Date()));
  3858. inst.selectedDay = inst.currentDay = newDate.getDate();
  3859. inst.drawMonth = inst.selectedMonth = inst.currentMonth = newDate.getMonth();
  3860. inst.drawYear = inst.selectedYear = inst.currentYear = newDate.getFullYear();
  3861. if ((origMonth !== inst.selectedMonth || origYear !== inst.selectedYear) && !noChange) {
  3862. this._notifyChange(inst);
  3863. }
  3864. this._adjustInstDate(inst);
  3865. if (inst.input) {
  3866. inst.input.val(clear ? "" : this._formatDate(inst));
  3867. }
  3868. },
  3869. /* Retrieve the date(s) directly. */
  3870. _getDate: function(inst) {
  3871. var startDate = (!inst.currentYear || (inst.input && inst.input.val() === "") ? null :
  3872. this._daylightSavingAdjust(new Date(
  3873. inst.currentYear, inst.currentMonth, inst.currentDay)));
  3874. return startDate;
  3875. },
  3876. /* Attach the onxxx handlers. These are declared statically so
  3877. * they work with static code transformers like Caja.
  3878. */
  3879. _attachHandlers: function(inst) {
  3880. var stepMonths = this._get(inst, "stepMonths"),
  3881. id = "#" + inst.id.replace( /\\\\/g, "\\" );
  3882. inst.dpDiv.find("[data-handler]").map(function () {
  3883. var handler = {
  3884. prev: function () {
  3885. $.datepicker._adjustDate(id, -stepMonths, "M");
  3886. },
  3887. next: function () {
  3888. $.datepicker._adjustDate(id, +stepMonths, "M");
  3889. },
  3890. hide: function () {
  3891. $.datepicker._hideDatepicker();
  3892. },
  3893. today: function () {
  3894. $.datepicker._gotoToday(id);
  3895. },
  3896. selectDay: function () {
  3897. $.datepicker._selectDay(id, +this.getAttribute("data-month"), +this.getAttribute("data-year"), this);
  3898. return false;
  3899. },
  3900. selectMonth: function () {
  3901. $.datepicker._selectMonthYear(id, this, "M");
  3902. return false;
  3903. },
  3904. selectYear: function () {
  3905. $.datepicker._selectMonthYear(id, this, "Y");
  3906. return false;
  3907. }
  3908. };
  3909. $(this).bind(this.getAttribute("data-event"), handler[this.getAttribute("data-handler")]);
  3910. });
  3911. },
  3912. /* Generate the HTML for the current state of the date picker. */
  3913. _generateHTML: function(inst) {
  3914. var maxDraw, prevText, prev, nextText, next, currentText, gotoDate,
  3915. controls, buttonPanel, firstDay, showWeek, dayNames, dayNamesMin,
  3916. monthNames, monthNamesShort, beforeShowDay, showOtherMonths,
  3917. selectOtherMonths, defaultDate, html, dow, row, group, col, selectedDate,
  3918. cornerClass, calender, thead, day, daysInMonth, leadDays, curRows, numRows,
  3919. printDate, dRow, tbody, daySettings, otherMonth, unselectable,
  3920. tempDate = new Date(),
  3921. today = this._daylightSavingAdjust(
  3922. new Date(tempDate.getFullYear(), tempDate.getMonth(), tempDate.getDate())), // clear time
  3923. isRTL = this._get(inst, "isRTL"),
  3924. showButtonPanel = this._get(inst, "showButtonPanel"),
  3925. hideIfNoPrevNext = this._get(inst, "hideIfNoPrevNext"),
  3926. navigationAsDateFormat = this._get(inst, "navigationAsDateFormat"),
  3927. numMonths = this._getNumberOfMonths(inst),
  3928. showCurrentAtPos = this._get(inst, "showCurrentAtPos"),
  3929. stepMonths = this._get(inst, "stepMonths"),
  3930. isMultiMonth = (numMonths[0] !== 1 || numMonths[1] !== 1),
  3931. currentDate = this._daylightSavingAdjust((!inst.currentDay ? new Date(9999, 9, 9) :
  3932. new Date(inst.currentYear, inst.currentMonth, inst.currentDay))),
  3933. minDate = this._getMinMaxDate(inst, "min"),
  3934. maxDate = this._getMinMaxDate(inst, "max"),
  3935. drawMonth = inst.drawMonth - showCurrentAtPos,
  3936. drawYear = inst.drawYear;
  3937. if (drawMonth < 0) {
  3938. drawMonth += 12;
  3939. drawYear--;
  3940. }
  3941. if (maxDate) {
  3942. maxDraw = this._daylightSavingAdjust(new Date(maxDate.getFullYear(),
  3943. maxDate.getMonth() - (numMonths[0] * numMonths[1]) + 1, maxDate.getDate()));
  3944. maxDraw = (minDate && maxDraw < minDate ? minDate : maxDraw);
  3945. while (this._daylightSavingAdjust(new Date(drawYear, drawMonth, 1)) > maxDraw) {
  3946. drawMonth--;
  3947. if (drawMonth < 0) {
  3948. drawMonth = 11;
  3949. drawYear--;
  3950. }
  3951. }
  3952. }
  3953. inst.drawMonth = drawMonth;
  3954. inst.drawYear = drawYear;
  3955. prevText = this._get(inst, "prevText");
  3956. prevText = (!navigationAsDateFormat ? prevText : this.formatDate(prevText,
  3957. this._daylightSavingAdjust(new Date(drawYear, drawMonth - stepMonths, 1)),
  3958. this._getFormatConfig(inst)));
  3959. prev = (this._canAdjustMonth(inst, -1, drawYear, drawMonth) ?
  3960. "<a class='ui-datepicker-prev ui-corner-all' data-handler='prev' data-event='click'" +
  3961. " title='" + prevText + "'><span class='ui-icon ui-icon-circle-triangle-" + ( isRTL ? "e" : "w") + "'>" + prevText + "</span></a>" :
  3962. (hideIfNoPrevNext ? "" : "<a class='ui-datepicker-prev ui-corner-all ui-state-disabled' title='"+ prevText +"'><span class='ui-icon ui-icon-circle-triangle-" + ( isRTL ? "e" : "w") + "'>" + prevText + "</span></a>"));
  3963. nextText = this._get(inst, "nextText");
  3964. nextText = (!navigationAsDateFormat ? nextText : this.formatDate(nextText,
  3965. this._daylightSavingAdjust(new Date(drawYear, drawMonth + stepMonths, 1)),
  3966. this._getFormatConfig(inst)));
  3967. next = (this._canAdjustMonth(inst, +1, drawYear, drawMonth) ?
  3968. "<a class='ui-datepicker-next ui-corner-all' data-handler='next' data-event='click'" +
  3969. " title='" + nextText + "'><span class='ui-icon ui-icon-circle-triangle-" + ( isRTL ? "w" : "e") + "'>" + nextText + "</span></a>" :
  3970. (hideIfNoPrevNext ? "" : "<a class='ui-datepicker-next ui-corner-all ui-state-disabled' title='"+ nextText + "'><span class='ui-icon ui-icon-circle-triangle-" + ( isRTL ? "w" : "e") + "'>" + nextText + "</span></a>"));
  3971. currentText = this._get(inst, "currentText");
  3972. gotoDate = (this._get(inst, "gotoCurrent") && inst.currentDay ? currentDate : today);
  3973. currentText = (!navigationAsDateFormat ? currentText :
  3974. this.formatDate(currentText, gotoDate, this._getFormatConfig(inst)));
  3975. controls = (!inst.inline ? "<button type='button' class='ui-datepicker-close ui-state-default ui-priority-primary ui-corner-all' data-handler='hide' data-event='click'>" +
  3976. this._get(inst, "closeText") + "</button>" : "");
  3977. buttonPanel = (showButtonPanel) ? "<div class='ui-datepicker-buttonpane ui-widget-content'>" + (isRTL ? controls : "") +
  3978. (this._isInRange(inst, gotoDate) ? "<button type='button' class='ui-datepicker-current ui-state-default ui-priority-secondary ui-corner-all' data-handler='today' data-event='click'" +
  3979. ">" + currentText + "</button>" : "") + (isRTL ? "" : controls) + "</div>" : "";
  3980. firstDay = parseInt(this._get(inst, "firstDay"),10);
  3981. firstDay = (isNaN(firstDay) ? 0 : firstDay);
  3982. showWeek = this._get(inst, "showWeek");
  3983. dayNames = this._get(inst, "dayNames");
  3984. dayNamesMin = this._get(inst, "dayNamesMin");
  3985. monthNames = this._get(inst, "monthNames");
  3986. monthNamesShort = this._get(inst, "monthNamesShort");
  3987. beforeShowDay = this._get(inst, "beforeShowDay");
  3988. showOtherMonths = this._get(inst, "showOtherMonths");
  3989. selectOtherMonths = this._get(inst, "selectOtherMonths");
  3990. defaultDate = this._getDefaultDate(inst);
  3991. html = "";
  3992. dow;
  3993. for (row = 0; row < numMonths[0]; row++) {
  3994. group = "";
  3995. this.maxRows = 4;
  3996. for (col = 0; col < numMonths[1]; col++) {
  3997. selectedDate = this._daylightSavingAdjust(new Date(drawYear, drawMonth, inst.selectedDay));
  3998. cornerClass = " ui-corner-all";
  3999. calender = "";
  4000. if (isMultiMonth) {
  4001. calender += "<div class='ui-datepicker-group";
  4002. if (numMonths[1] > 1) {
  4003. switch (col) {
  4004. case 0: calender += " ui-datepicker-group-first";
  4005. cornerClass = " ui-corner-" + (isRTL ? "right" : "left"); break;
  4006. case numMonths[1]-1: calender += " ui-datepicker-group-last";
  4007. cornerClass = " ui-corner-" + (isRTL ? "left" : "right"); break;
  4008. default: calender += " ui-datepicker-group-middle"; cornerClass = ""; break;
  4009. }
  4010. }
  4011. calender += "'>";
  4012. }
  4013. calender += "<div class='ui-datepicker-header ui-widget-header ui-helper-clearfix" + cornerClass + "'>" +
  4014. (/all|left/.test(cornerClass) && row === 0 ? (isRTL ? next : prev) : "") +
  4015. (/all|right/.test(cornerClass) && row === 0 ? (isRTL ? prev : next) : "") +
  4016. this._generateMonthYearHeader(inst, drawMonth, drawYear, minDate, maxDate,
  4017. row > 0 || col > 0, monthNames, monthNamesShort) + // draw month headers
  4018. "</div><table class='ui-datepicker-calendar'><thead>" +
  4019. "<tr>";
  4020. thead = (showWeek ? "<th class='ui-datepicker-week-col'>" + this._get(inst, "weekHeader") + "</th>" : "");
  4021. for (dow = 0; dow < 7; dow++) { // days of the week
  4022. day = (dow + firstDay) % 7;
  4023. thead += "<th scope='col'" + ((dow + firstDay + 6) % 7 >= 5 ? " class='ui-datepicker-week-end'" : "") + ">" +
  4024. "<span title='" + dayNames[day] + "'>" + dayNamesMin[day] + "</span></th>";
  4025. }
  4026. calender += thead + "</tr></thead><tbody>";
  4027. daysInMonth = this._getDaysInMonth(drawYear, drawMonth);
  4028. if (drawYear === inst.selectedYear && drawMonth === inst.selectedMonth) {
  4029. inst.selectedDay = Math.min(inst.selectedDay, daysInMonth);
  4030. }
  4031. leadDays = (this._getFirstDayOfMonth(drawYear, drawMonth) - firstDay + 7) % 7;
  4032. curRows = Math.ceil((leadDays + daysInMonth) / 7); // calculate the number of rows to generate
  4033. numRows = (isMultiMonth ? this.maxRows > curRows ? this.maxRows : curRows : curRows); //If multiple months, use the higher number of rows (see #7043)
  4034. this.maxRows = numRows;
  4035. printDate = this._daylightSavingAdjust(new Date(drawYear, drawMonth, 1 - leadDays));
  4036. for (dRow = 0; dRow < numRows; dRow++) { // create date picker rows
  4037. calender += "<tr>";
  4038. tbody = (!showWeek ? "" : "<td class='ui-datepicker-week-col'>" +
  4039. this._get(inst, "calculateWeek")(printDate) + "</td>");
  4040. for (dow = 0; dow < 7; dow++) { // create date picker days
  4041. daySettings = (beforeShowDay ?
  4042. beforeShowDay.apply((inst.input ? inst.input[0] : null), [printDate]) : [true, ""]);
  4043. otherMonth = (printDate.getMonth() !== drawMonth);
  4044. unselectable = (otherMonth && !selectOtherMonths) || !daySettings[0] ||
  4045. (minDate && printDate < minDate) || (maxDate && printDate > maxDate);
  4046. tbody += "<td class='" +
  4047. ((dow + firstDay + 6) % 7 >= 5 ? " ui-datepicker-week-end" : "") + // highlight weekends
  4048. (otherMonth ? " ui-datepicker-other-month" : "") + // highlight days from other months
  4049. ((printDate.getTime() === selectedDate.getTime() && drawMonth === inst.selectedMonth && inst._keyEvent) || // user pressed key
  4050. (defaultDate.getTime() === printDate.getTime() && defaultDate.getTime() === selectedDate.getTime()) ?
  4051. // or defaultDate is current printedDate and defaultDate is selectedDate
  4052. " " + this._dayOverClass : "") + // highlight selected day
  4053. (unselectable ? " " + this._unselectableClass + " ui-state-disabled": "") + // highlight unselectable days
  4054. (otherMonth && !showOtherMonths ? "" : " " + daySettings[1] + // highlight custom dates
  4055. (printDate.getTime() === currentDate.getTime() ? " " + this._currentClass : "") + // highlight selected day
  4056. (printDate.getTime() === today.getTime() ? " ui-datepicker-today" : "")) + "'" + // highlight today (if different)
  4057. ((!otherMonth || showOtherMonths) && daySettings[2] ? " title='" + daySettings[2].replace(/'/g, "&#39;") + "'" : "") + // cell title
  4058. (unselectable ? "" : " data-handler='selectDay' data-event='click' data-month='" + printDate.getMonth() + "' data-year='" + printDate.getFullYear() + "'") + ">" + // actions
  4059. (otherMonth && !showOtherMonths ? "&#xa0;" : // display for other months
  4060. (unselectable ? "<span class='ui-state-default'>" + printDate.getDate() + "</span>" : "<a class='ui-state-default" +
  4061. (printDate.getTime() === today.getTime() ? " ui-state-highlight" : "") +
  4062. (printDate.getTime() === currentDate.getTime() ? " ui-state-active" : "") + // highlight selected day
  4063. (otherMonth ? " ui-priority-secondary" : "") + // distinguish dates from other months
  4064. "' href='#'>" + printDate.getDate() + "</a>")) + "</td>"; // display selectable date
  4065. printDate.setDate(printDate.getDate() + 1);
  4066. printDate = this._daylightSavingAdjust(printDate);
  4067. }
  4068. calender += tbody + "</tr>";
  4069. }
  4070. drawMonth++;
  4071. if (drawMonth > 11) {
  4072. drawMonth = 0;
  4073. drawYear++;
  4074. }
  4075. calender += "</tbody></table>" + (isMultiMonth ? "</div>" +
  4076. ((numMonths[0] > 0 && col === numMonths[1]-1) ? "<div class='ui-datepicker-row-break'></div>" : "") : "");
  4077. group += calender;
  4078. }
  4079. html += group;
  4080. }
  4081. html += buttonPanel;
  4082. inst._keyEvent = false;
  4083. return html;
  4084. },
  4085. /* Generate the month and year header. */
  4086. _generateMonthYearHeader: function(inst, drawMonth, drawYear, minDate, maxDate,
  4087. secondary, monthNames, monthNamesShort) {
  4088. var inMinYear, inMaxYear, month, years, thisYear, determineYear, year, endYear,
  4089. changeMonth = this._get(inst, "changeMonth"),
  4090. changeYear = this._get(inst, "changeYear"),
  4091. showMonthAfterYear = this._get(inst, "showMonthAfterYear"),
  4092. html = "<div class='ui-datepicker-title'>",
  4093. monthHtml = "";
  4094. // month selection
  4095. if (secondary || !changeMonth) {
  4096. monthHtml += "<span class='ui-datepicker-month'>" + monthNames[drawMonth] + "</span>";
  4097. } else {
  4098. inMinYear = (minDate && minDate.getFullYear() === drawYear);
  4099. inMaxYear = (maxDate && maxDate.getFullYear() === drawYear);
  4100. monthHtml += "<select class='ui-datepicker-month' data-handler='selectMonth' data-event='change'>";
  4101. for ( month = 0; month < 12; month++) {
  4102. if ((!inMinYear || month >= minDate.getMonth()) && (!inMaxYear || month <= maxDate.getMonth())) {
  4103. monthHtml += "<option value='" + month + "'" +
  4104. (month === drawMonth ? " selected='selected'" : "") +
  4105. ">" + monthNamesShort[month] + "</option>";
  4106. }
  4107. }
  4108. monthHtml += "</select>";
  4109. }
  4110. if (!showMonthAfterYear) {
  4111. html += monthHtml + (secondary || !(changeMonth && changeYear) ? "&#xa0;" : "");
  4112. }
  4113. // year selection
  4114. if ( !inst.yearshtml ) {
  4115. inst.yearshtml = "";
  4116. if (secondary || !changeYear) {
  4117. html += "<span class='ui-datepicker-year'>" + drawYear + "</span>";
  4118. } else {
  4119. // determine range of years to display
  4120. years = this._get(inst, "yearRange").split(":");
  4121. thisYear = new Date().getFullYear();
  4122. determineYear = function(value) {
  4123. var year = (value.match(/c[+\-].*/) ? drawYear + parseInt(value.substring(1), 10) :
  4124. (value.match(/[+\-].*/) ? thisYear + parseInt(value, 10) :
  4125. parseInt(value, 10)));
  4126. return (isNaN(year) ? thisYear : year);
  4127. };
  4128. year = determineYear(years[0]);
  4129. endYear = Math.max(year, determineYear(years[1] || ""));
  4130. year = (minDate ? Math.max(year, minDate.getFullYear()) : year);
  4131. endYear = (maxDate ? Math.min(endYear, maxDate.getFullYear()) : endYear);
  4132. inst.yearshtml += "<select class='ui-datepicker-year' data-handler='selectYear' data-event='change'>";
  4133. for (; year <= endYear; year++) {
  4134. inst.yearshtml += "<option value='" + year + "'" +
  4135. (year === drawYear ? " selected='selected'" : "") +
  4136. ">" + year + "</option>";
  4137. }
  4138. inst.yearshtml += "</select>";
  4139. html += inst.yearshtml;
  4140. inst.yearshtml = null;
  4141. }
  4142. }
  4143. html += this._get(inst, "yearSuffix");
  4144. if (showMonthAfterYear) {
  4145. html += (secondary || !(changeMonth && changeYear) ? "&#xa0;" : "") + monthHtml;
  4146. }
  4147. html += "</div>"; // Close datepicker_header
  4148. return html;
  4149. },
  4150. /* Adjust one of the date sub-fields. */
  4151. _adjustInstDate: function(inst, offset, period) {
  4152. var year = inst.drawYear + (period === "Y" ? offset : 0),
  4153. month = inst.drawMonth + (period === "M" ? offset : 0),
  4154. day = Math.min(inst.selectedDay, this._getDaysInMonth(year, month)) + (period === "D" ? offset : 0),
  4155. date = this._restrictMinMax(inst, this._daylightSavingAdjust(new Date(year, month, day)));
  4156. inst.selectedDay = date.getDate();
  4157. inst.drawMonth = inst.selectedMonth = date.getMonth();
  4158. inst.drawYear = inst.selectedYear = date.getFullYear();
  4159. if (period === "M" || period === "Y") {
  4160. this._notifyChange(inst);
  4161. }
  4162. },
  4163. /* Ensure a date is within any min/max bounds. */
  4164. _restrictMinMax: function(inst, date) {
  4165. var minDate = this._getMinMaxDate(inst, "min"),
  4166. maxDate = this._getMinMaxDate(inst, "max"),
  4167. newDate = (minDate && date < minDate ? minDate : date);
  4168. return (maxDate && newDate > maxDate ? maxDate : newDate);
  4169. },
  4170. /* Notify change of month/year. */
  4171. _notifyChange: function(inst) {
  4172. var onChange = this._get(inst, "onChangeMonthYear");
  4173. if (onChange) {
  4174. onChange.apply((inst.input ? inst.input[0] : null),
  4175. [inst.selectedYear, inst.selectedMonth + 1, inst]);
  4176. }
  4177. },
  4178. /* Determine the number of months to show. */
  4179. _getNumberOfMonths: function(inst) {
  4180. var numMonths = this._get(inst, "numberOfMonths");
  4181. return (numMonths == null ? [1, 1] : (typeof numMonths === "number" ? [1, numMonths] : numMonths));
  4182. },
  4183. /* Determine the current maximum date - ensure no time components are set. */
  4184. _getMinMaxDate: function(inst, minMax) {
  4185. return this._determineDate(inst, this._get(inst, minMax + "Date"), null);
  4186. },
  4187. /* Find the number of days in a given month. */
  4188. _getDaysInMonth: function(year, month) {
  4189. return 32 - this._daylightSavingAdjust(new Date(year, month, 32)).getDate();
  4190. },
  4191. /* Find the day of the week of the first of a month. */
  4192. _getFirstDayOfMonth: function(year, month) {
  4193. return new Date(year, month, 1).getDay();
  4194. },
  4195. /* Determines if we should allow a "next/prev" month display change. */
  4196. _canAdjustMonth: function(inst, offset, curYear, curMonth) {
  4197. var numMonths = this._getNumberOfMonths(inst),
  4198. date = this._daylightSavingAdjust(new Date(curYear,
  4199. curMonth + (offset < 0 ? offset : numMonths[0] * numMonths[1]), 1));
  4200. if (offset < 0) {
  4201. date.setDate(this._getDaysInMonth(date.getFullYear(), date.getMonth()));
  4202. }
  4203. return this._isInRange(inst, date);
  4204. },
  4205. /* Is the given date in the accepted range? */
  4206. _isInRange: function(inst, date) {
  4207. var yearSplit, currentYear,
  4208. minDate = this._getMinMaxDate(inst, "min"),
  4209. maxDate = this._getMinMaxDate(inst, "max"),
  4210. minYear = null,
  4211. maxYear = null,
  4212. years = this._get(inst, "yearRange");
  4213. if (years){
  4214. yearSplit = years.split(":");
  4215. currentYear = new Date().getFullYear();
  4216. minYear = parseInt(yearSplit[0], 10);
  4217. maxYear = parseInt(yearSplit[1], 10);
  4218. if ( yearSplit[0].match(/[+\-].*/) ) {
  4219. minYear += currentYear;
  4220. }
  4221. if ( yearSplit[1].match(/[+\-].*/) ) {
  4222. maxYear += currentYear;
  4223. }
  4224. }
  4225. return ((!minDate || date.getTime() >= minDate.getTime()) &&
  4226. (!maxDate || date.getTime() <= maxDate.getTime()) &&
  4227. (!minYear || date.getFullYear() >= minYear) &&
  4228. (!maxYear || date.getFullYear() <= maxYear));
  4229. },
  4230. /* Provide the configuration settings for formatting/parsing. */
  4231. _getFormatConfig: function(inst) {
  4232. var shortYearCutoff = this._get(inst, "shortYearCutoff");
  4233. shortYearCutoff = (typeof shortYearCutoff !== "string" ? shortYearCutoff :
  4234. new Date().getFullYear() % 100 + parseInt(shortYearCutoff, 10));
  4235. return {shortYearCutoff: shortYearCutoff,
  4236. dayNamesShort: this._get(inst, "dayNamesShort"), dayNames: this._get(inst, "dayNames"),
  4237. monthNamesShort: this._get(inst, "monthNamesShort"), monthNames: this._get(inst, "monthNames")};
  4238. },
  4239. /* Format the given date for display. */
  4240. _formatDate: function(inst, day, month, year) {
  4241. if (!day) {
  4242. inst.currentDay = inst.selectedDay;
  4243. inst.currentMonth = inst.selectedMonth;
  4244. inst.currentYear = inst.selectedYear;
  4245. }
  4246. var date = (day ? (typeof day === "object" ? day :
  4247. this._daylightSavingAdjust(new Date(year, month, day))) :
  4248. this._daylightSavingAdjust(new Date(inst.currentYear, inst.currentMonth, inst.currentDay)));
  4249. return this.formatDate(this._get(inst, "dateFormat"), date, this._getFormatConfig(inst));
  4250. }
  4251. });
  4252. /*
  4253. * Bind hover events for datepicker elements.
  4254. * Done via delegate so the binding only occurs once in the lifetime of the parent div.
  4255. * Global datepicker_instActive, set by _updateDatepicker allows the handlers to find their way back to the active picker.
  4256. */
  4257. function datepicker_bindHover(dpDiv) {
  4258. var selector = "button, .ui-datepicker-prev, .ui-datepicker-next, .ui-datepicker-calendar td a";
  4259. return dpDiv.delegate(selector, "mouseout", function() {
  4260. $(this).removeClass("ui-state-hover");
  4261. if (this.className.indexOf("ui-datepicker-prev") !== -1) {
  4262. $(this).removeClass("ui-datepicker-prev-hover");
  4263. }
  4264. if (this.className.indexOf("ui-datepicker-next") !== -1) {
  4265. $(this).removeClass("ui-datepicker-next-hover");
  4266. }
  4267. })
  4268. .delegate( selector, "mouseover", datepicker_handleMouseover );
  4269. }
  4270. function datepicker_handleMouseover() {
  4271. if (!$.datepicker._isDisabledDatepicker( datepicker_instActive.inline? datepicker_instActive.dpDiv.parent()[0] : datepicker_instActive.input[0])) {
  4272. $(this).parents(".ui-datepicker-calendar").find("a").removeClass("ui-state-hover");
  4273. $(this).addClass("ui-state-hover");
  4274. if (this.className.indexOf("ui-datepicker-prev") !== -1) {
  4275. $(this).addClass("ui-datepicker-prev-hover");
  4276. }
  4277. if (this.className.indexOf("ui-datepicker-next") !== -1) {
  4278. $(this).addClass("ui-datepicker-next-hover");
  4279. }
  4280. }
  4281. }
  4282. /* jQuery extend now ignores nulls! */
  4283. function datepicker_extendRemove(target, props) {
  4284. $.extend(target, props);
  4285. for (var name in props) {
  4286. if (props[name] == null) {
  4287. target[name] = props[name];
  4288. }
  4289. }
  4290. return target;
  4291. }
  4292. /* Invoke the datepicker functionality.
  4293. @param options string - a command, optionally followed by additional parameters or
  4294. Object - settings for attaching new datepicker functionality
  4295. @return jQuery object */
  4296. $.fn.datepicker = function(options){
  4297. /* Verify an empty collection wasn't passed - Fixes #6976 */
  4298. if ( !this.length ) {
  4299. return this;
  4300. }
  4301. /* Initialise the date picker. */
  4302. if (!$.datepicker.initialized) {
  4303. $(document).mousedown($.datepicker._checkExternalClick);
  4304. $.datepicker.initialized = true;
  4305. }
  4306. /* Append datepicker main container to body if not exist. */
  4307. if ($("#"+$.datepicker._mainDivId).length === 0) {
  4308. $("body").append($.datepicker.dpDiv);
  4309. }
  4310. var otherArgs = Array.prototype.slice.call(arguments, 1);
  4311. if (typeof options === "string" && (options === "isDisabled" || options === "getDate" || options === "widget")) {
  4312. return $.datepicker["_" + options + "Datepicker"].
  4313. apply($.datepicker, [this[0]].concat(otherArgs));
  4314. }
  4315. if (options === "option" && arguments.length === 2 && typeof arguments[1] === "string") {
  4316. return $.datepicker["_" + options + "Datepicker"].
  4317. apply($.datepicker, [this[0]].concat(otherArgs));
  4318. }
  4319. return this.each(function() {
  4320. typeof options === "string" ?
  4321. $.datepicker["_" + options + "Datepicker"].
  4322. apply($.datepicker, [this].concat(otherArgs)) :
  4323. $.datepicker._attachDatepicker(this, options);
  4324. });
  4325. };
  4326. $.datepicker = new Datepicker(); // singleton instance
  4327. $.datepicker.initialized = false;
  4328. $.datepicker.uuid = new Date().getTime();
  4329. $.datepicker.version = "1.11.4";
  4330. var datepicker = $.datepicker;
  4331. /*!
  4332. * jQuery UI Selectmenu 1.11.4
  4333. * http://jqueryui.com
  4334. *
  4335. * Copyright jQuery Foundation and other contributors
  4336. * Released under the MIT license.
  4337. * http://jquery.org/license
  4338. *
  4339. * http://api.jqueryui.com/selectmenu
  4340. */
  4341. var selectmenu = $.widget( "ui.selectmenu", {
  4342. version: "1.11.4",
  4343. defaultElement: "<select>",
  4344. options: {
  4345. appendTo: null,
  4346. disabled: null,
  4347. icons: {
  4348. button: "ui-icon-triangle-1-s"
  4349. },
  4350. position: {
  4351. my: "left top",
  4352. at: "left bottom",
  4353. collision: "none"
  4354. },
  4355. width: null,
  4356. // callbacks
  4357. change: null,
  4358. close: null,
  4359. focus: null,
  4360. open: null,
  4361. select: null
  4362. },
  4363. _create: function() {
  4364. var selectmenuId = this.element.uniqueId().attr( "id" );
  4365. this.ids = {
  4366. element: selectmenuId,
  4367. button: selectmenuId + "-button",
  4368. menu: selectmenuId + "-menu"
  4369. };
  4370. this._drawButton();
  4371. this._drawMenu();
  4372. if ( this.options.disabled ) {
  4373. this.disable();
  4374. }
  4375. },
  4376. _drawButton: function() {
  4377. var that = this;
  4378. // Associate existing label with the new button
  4379. this.label = $( "label[for='" + this.ids.element + "']" ).attr( "for", this.ids.button );
  4380. this._on( this.label, {
  4381. click: function( event ) {
  4382. this.button.focus();
  4383. event.preventDefault();
  4384. }
  4385. });
  4386. // Hide original select element
  4387. this.element.hide();
  4388. // Create button
  4389. this.button = $( "<span>", {
  4390. "class": "ui-selectmenu-button ui-widget ui-state-default ui-corner-all",
  4391. tabindex: this.options.disabled ? -1 : 0,
  4392. id: this.ids.button,
  4393. role: "combobox",
  4394. "aria-expanded": "false",
  4395. "aria-autocomplete": "list",
  4396. "aria-owns": this.ids.menu,
  4397. "aria-haspopup": "true"
  4398. })
  4399. .insertAfter( this.element );
  4400. $( "<span>", {
  4401. "class": "ui-icon " + this.options.icons.button
  4402. })
  4403. .prependTo( this.button );
  4404. this.buttonText = $( "<span>", {
  4405. "class": "ui-selectmenu-text"
  4406. })
  4407. .appendTo( this.button );
  4408. this._setText( this.buttonText, this.element.find( "option:selected" ).text() );
  4409. this._resizeButton();
  4410. this._on( this.button, this._buttonEvents );
  4411. this.button.one( "focusin", function() {
  4412. // Delay rendering the menu items until the button receives focus.
  4413. // The menu may have already been rendered via a programmatic open.
  4414. if ( !that.menuItems ) {
  4415. that._refreshMenu();
  4416. }
  4417. });
  4418. this._hoverable( this.button );
  4419. this._focusable( this.button );
  4420. },
  4421. _drawMenu: function() {
  4422. var that = this;
  4423. // Create menu
  4424. this.menu = $( "<ul>", {
  4425. "aria-hidden": "true",
  4426. "aria-labelledby": this.ids.button,
  4427. id: this.ids.menu
  4428. });
  4429. // Wrap menu
  4430. this.menuWrap = $( "<div>", {
  4431. "class": "ui-selectmenu-menu ui-front"
  4432. })
  4433. .append( this.menu )
  4434. .appendTo( this._appendTo() );
  4435. // Initialize menu widget
  4436. this.menuInstance = this.menu
  4437. .menu({
  4438. role: "listbox",
  4439. select: function( event, ui ) {
  4440. event.preventDefault();
  4441. // support: IE8
  4442. // If the item was selected via a click, the text selection
  4443. // will be destroyed in IE
  4444. that._setSelection();
  4445. that._select( ui.item.data( "ui-selectmenu-item" ), event );
  4446. },
  4447. focus: function( event, ui ) {
  4448. var item = ui.item.data( "ui-selectmenu-item" );
  4449. // Prevent inital focus from firing and check if its a newly focused item
  4450. if ( that.focusIndex != null && item.index !== that.focusIndex ) {
  4451. that._trigger( "focus", event, { item: item } );
  4452. if ( !that.isOpen ) {
  4453. that._select( item, event );
  4454. }
  4455. }
  4456. that.focusIndex = item.index;
  4457. that.button.attr( "aria-activedescendant",
  4458. that.menuItems.eq( item.index ).attr( "id" ) );
  4459. }
  4460. })
  4461. .menu( "instance" );
  4462. // Adjust menu styles to dropdown
  4463. this.menu
  4464. .addClass( "ui-corner-bottom" )
  4465. .removeClass( "ui-corner-all" );
  4466. // Don't close the menu on mouseleave
  4467. this.menuInstance._off( this.menu, "mouseleave" );
  4468. // Cancel the menu's collapseAll on document click
  4469. this.menuInstance._closeOnDocumentClick = function() {
  4470. return false;
  4471. };
  4472. // Selects often contain empty items, but never contain dividers
  4473. this.menuInstance._isDivider = function() {
  4474. return false;
  4475. };
  4476. },
  4477. refresh: function() {
  4478. this._refreshMenu();
  4479. this._setText( this.buttonText, this._getSelectedItem().text() );
  4480. if ( !this.options.width ) {
  4481. this._resizeButton();
  4482. }
  4483. },
  4484. _refreshMenu: function() {
  4485. this.menu.empty();
  4486. var item,
  4487. options = this.element.find( "option" );
  4488. if ( !options.length ) {
  4489. return;
  4490. }
  4491. this._parseOptions( options );
  4492. this._renderMenu( this.menu, this.items );
  4493. this.menuInstance.refresh();
  4494. this.menuItems = this.menu.find( "li" ).not( ".ui-selectmenu-optgroup" );
  4495. item = this._getSelectedItem();
  4496. // Update the menu to have the correct item focused
  4497. this.menuInstance.focus( null, item );
  4498. this._setAria( item.data( "ui-selectmenu-item" ) );
  4499. // Set disabled state
  4500. this._setOption( "disabled", this.element.prop( "disabled" ) );
  4501. },
  4502. open: function( event ) {
  4503. if ( this.options.disabled ) {
  4504. return;
  4505. }
  4506. // If this is the first time the menu is being opened, render the items
  4507. if ( !this.menuItems ) {
  4508. this._refreshMenu();
  4509. } else {
  4510. // Menu clears focus on close, reset focus to selected item
  4511. this.menu.find( ".ui-state-focus" ).removeClass( "ui-state-focus" );
  4512. this.menuInstance.focus( null, this._getSelectedItem() );
  4513. }
  4514. this.isOpen = true;
  4515. this._toggleAttr();
  4516. this._resizeMenu();
  4517. this._position();
  4518. this._on( this.document, this._documentClick );
  4519. this._trigger( "open", event );
  4520. },
  4521. _position: function() {
  4522. this.menuWrap.position( $.extend( { of: this.button }, this.options.position ) );
  4523. },
  4524. close: function( event ) {
  4525. if ( !this.isOpen ) {
  4526. return;
  4527. }
  4528. this.isOpen = false;
  4529. this._toggleAttr();
  4530. this.range = null;
  4531. this._off( this.document );
  4532. this._trigger( "close", event );
  4533. },
  4534. widget: function() {
  4535. return this.button;
  4536. },
  4537. menuWidget: function() {
  4538. return this.menu;
  4539. },
  4540. _renderMenu: function( ul, items ) {
  4541. var that = this,
  4542. currentOptgroup = "";
  4543. $.each( items, function( index, item ) {
  4544. if ( item.optgroup !== currentOptgroup ) {
  4545. $( "<li>", {
  4546. "class": "ui-selectmenu-optgroup ui-menu-divider" +
  4547. ( item.element.parent( "optgroup" ).prop( "disabled" ) ?
  4548. " ui-state-disabled" :
  4549. "" ),
  4550. text: item.optgroup
  4551. })
  4552. .appendTo( ul );
  4553. currentOptgroup = item.optgroup;
  4554. }
  4555. that._renderItemData( ul, item );
  4556. });
  4557. },
  4558. _renderItemData: function( ul, item ) {
  4559. return this._renderItem( ul, item ).data( "ui-selectmenu-item", item );
  4560. },
  4561. _renderItem: function( ul, item ) {
  4562. var li = $( "<li>" );
  4563. if ( item.disabled ) {
  4564. li.addClass( "ui-state-disabled" );
  4565. }
  4566. this._setText( li, item.label );
  4567. return li.appendTo( ul );
  4568. },
  4569. _setText: function( element, value ) {
  4570. if ( value ) {
  4571. element.text( value );
  4572. } else {
  4573. element.html( "&#160;" );
  4574. }
  4575. },
  4576. _move: function( direction, event ) {
  4577. var item, next,
  4578. filter = ".ui-menu-item";
  4579. if ( this.isOpen ) {
  4580. item = this.menuItems.eq( this.focusIndex );
  4581. } else {
  4582. item = this.menuItems.eq( this.element[ 0 ].selectedIndex );
  4583. filter += ":not(.ui-state-disabled)";
  4584. }
  4585. if ( direction === "first" || direction === "last" ) {
  4586. next = item[ direction === "first" ? "prevAll" : "nextAll" ]( filter ).eq( -1 );
  4587. } else {
  4588. next = item[ direction + "All" ]( filter ).eq( 0 );
  4589. }
  4590. if ( next.length ) {
  4591. this.menuInstance.focus( event, next );
  4592. }
  4593. },
  4594. _getSelectedItem: function() {
  4595. return this.menuItems.eq( this.element[ 0 ].selectedIndex );
  4596. },
  4597. _toggle: function( event ) {
  4598. this[ this.isOpen ? "close" : "open" ]( event );
  4599. },
  4600. _setSelection: function() {
  4601. var selection;
  4602. if ( !this.range ) {
  4603. return;
  4604. }
  4605. if ( window.getSelection ) {
  4606. selection = window.getSelection();
  4607. selection.removeAllRanges();
  4608. selection.addRange( this.range );
  4609. // support: IE8
  4610. } else {
  4611. this.range.select();
  4612. }
  4613. // support: IE
  4614. // Setting the text selection kills the button focus in IE, but
  4615. // restoring the focus doesn't kill the selection.
  4616. this.button.focus();
  4617. },
  4618. _documentClick: {
  4619. mousedown: function( event ) {
  4620. if ( !this.isOpen ) {
  4621. return;
  4622. }
  4623. if ( !$( event.target ).closest( ".ui-selectmenu-menu, #" + this.ids.button ).length ) {
  4624. this.close( event );
  4625. }
  4626. }
  4627. },
  4628. _buttonEvents: {
  4629. // Prevent text selection from being reset when interacting with the selectmenu (#10144)
  4630. mousedown: function() {
  4631. var selection;
  4632. if ( window.getSelection ) {
  4633. selection = window.getSelection();
  4634. if ( selection.rangeCount ) {
  4635. this.range = selection.getRangeAt( 0 );
  4636. }
  4637. // support: IE8
  4638. } else {
  4639. this.range = document.selection.createRange();
  4640. }
  4641. },
  4642. click: function( event ) {
  4643. this._setSelection();
  4644. this._toggle( event );
  4645. },
  4646. keydown: function( event ) {
  4647. var preventDefault = true;
  4648. switch ( event.keyCode ) {
  4649. case $.ui.keyCode.TAB:
  4650. case $.ui.keyCode.ESCAPE:
  4651. this.close( event );
  4652. preventDefault = false;
  4653. break;
  4654. case $.ui.keyCode.ENTER:
  4655. if ( this.isOpen ) {
  4656. this._selectFocusedItem( event );
  4657. }
  4658. break;
  4659. case $.ui.keyCode.UP:
  4660. if ( event.altKey ) {
  4661. this._toggle( event );
  4662. } else {
  4663. this._move( "prev", event );
  4664. }
  4665. break;
  4666. case $.ui.keyCode.DOWN:
  4667. if ( event.altKey ) {
  4668. this._toggle( event );
  4669. } else {
  4670. this._move( "next", event );
  4671. }
  4672. break;
  4673. case $.ui.keyCode.SPACE:
  4674. if ( this.isOpen ) {
  4675. this._selectFocusedItem( event );
  4676. } else {
  4677. this._toggle( event );
  4678. }
  4679. break;
  4680. case $.ui.keyCode.LEFT:
  4681. this._move( "prev", event );
  4682. break;
  4683. case $.ui.keyCode.RIGHT:
  4684. this._move( "next", event );
  4685. break;
  4686. case $.ui.keyCode.HOME:
  4687. case $.ui.keyCode.PAGE_UP:
  4688. this._move( "first", event );
  4689. break;
  4690. case $.ui.keyCode.END:
  4691. case $.ui.keyCode.PAGE_DOWN:
  4692. this._move( "last", event );
  4693. break;
  4694. default:
  4695. this.menu.trigger( event );
  4696. preventDefault = false;
  4697. }
  4698. if ( preventDefault ) {
  4699. event.preventDefault();
  4700. }
  4701. }
  4702. },
  4703. _selectFocusedItem: function( event ) {
  4704. var item = this.menuItems.eq( this.focusIndex );
  4705. if ( !item.hasClass( "ui-state-disabled" ) ) {
  4706. this._select( item.data( "ui-selectmenu-item" ), event );
  4707. }
  4708. },
  4709. _select: function( item, event ) {
  4710. var oldIndex = this.element[ 0 ].selectedIndex;
  4711. // Change native select element
  4712. this.element[ 0 ].selectedIndex = item.index;
  4713. this._setText( this.buttonText, item.label );
  4714. this._setAria( item );
  4715. this._trigger( "select", event, { item: item } );
  4716. if ( item.index !== oldIndex ) {
  4717. this._trigger( "change", event, { item: item } );
  4718. }
  4719. this.close( event );
  4720. },
  4721. _setAria: function( item ) {
  4722. var id = this.menuItems.eq( item.index ).attr( "id" );
  4723. this.button.attr({
  4724. "aria-labelledby": id,
  4725. "aria-activedescendant": id
  4726. });
  4727. this.menu.attr( "aria-activedescendant", id );
  4728. },
  4729. _setOption: function( key, value ) {
  4730. if ( key === "icons" ) {
  4731. this.button.find( "span.ui-icon" )
  4732. .removeClass( this.options.icons.button )
  4733. .addClass( value.button );
  4734. }
  4735. this._super( key, value );
  4736. if ( key === "appendTo" ) {
  4737. this.menuWrap.appendTo( this._appendTo() );
  4738. }
  4739. if ( key === "disabled" ) {
  4740. this.menuInstance.option( "disabled", value );
  4741. this.button
  4742. .toggleClass( "ui-state-disabled", value )
  4743. .attr( "aria-disabled", value );
  4744. this.element.prop( "disabled", value );
  4745. if ( value ) {
  4746. this.button.attr( "tabindex", -1 );
  4747. this.close();
  4748. } else {
  4749. this.button.attr( "tabindex", 0 );
  4750. }
  4751. }
  4752. if ( key === "width" ) {
  4753. this._resizeButton();
  4754. }
  4755. },
  4756. _appendTo: function() {
  4757. var element = this.options.appendTo;
  4758. if ( element ) {
  4759. element = element.jquery || element.nodeType ?
  4760. $( element ) :
  4761. this.document.find( element ).eq( 0 );
  4762. }
  4763. if ( !element || !element[ 0 ] ) {
  4764. element = this.element.closest( ".ui-front" );
  4765. }
  4766. if ( !element.length ) {
  4767. element = this.document[ 0 ].body;
  4768. }
  4769. return element;
  4770. },
  4771. _toggleAttr: function() {
  4772. this.button
  4773. .toggleClass( "ui-corner-top", this.isOpen )
  4774. .toggleClass( "ui-corner-all", !this.isOpen )
  4775. .attr( "aria-expanded", this.isOpen );
  4776. this.menuWrap.toggleClass( "ui-selectmenu-open", this.isOpen );
  4777. this.menu.attr( "aria-hidden", !this.isOpen );
  4778. },
  4779. _resizeButton: function() {
  4780. var width = this.options.width;
  4781. if ( !width ) {
  4782. width = this.element.show().outerWidth();
  4783. this.element.hide();
  4784. }
  4785. this.button.outerWidth( width );
  4786. },
  4787. _resizeMenu: function() {
  4788. this.menu.outerWidth( Math.max(
  4789. this.button.outerWidth(),
  4790. // support: IE10
  4791. // IE10 wraps long text (possibly a rounding bug)
  4792. // so we add 1px to avoid the wrapping
  4793. this.menu.width( "" ).outerWidth() + 1
  4794. ) );
  4795. },
  4796. _getCreateOptions: function() {
  4797. return { disabled: this.element.prop( "disabled" ) };
  4798. },
  4799. _parseOptions: function( options ) {
  4800. var data = [];
  4801. options.each(function( index, item ) {
  4802. var option = $( item ),
  4803. optgroup = option.parent( "optgroup" );
  4804. data.push({
  4805. element: option,
  4806. index: index,
  4807. value: option.val(),
  4808. label: option.text(),
  4809. optgroup: optgroup.attr( "label" ) || "",
  4810. disabled: optgroup.prop( "disabled" ) || option.prop( "disabled" )
  4811. });
  4812. });
  4813. this.items = data;
  4814. },
  4815. _destroy: function() {
  4816. this.menuWrap.remove();
  4817. this.button.remove();
  4818. this.element.show();
  4819. this.element.removeUniqueId();
  4820. this.label.attr( "for", this.ids.element );
  4821. }
  4822. });
  4823. /*!
  4824. * jQuery UI Slider 1.11.4
  4825. * http://jqueryui.com
  4826. *
  4827. * Copyright jQuery Foundation and other contributors
  4828. * Released under the MIT license.
  4829. * http://jquery.org/license
  4830. *
  4831. * http://api.jqueryui.com/slider/
  4832. */
  4833. var slider = $.widget( "ui.slider", $.ui.mouse, {
  4834. version: "1.11.4",
  4835. widgetEventPrefix: "slide",
  4836. options: {
  4837. animate: false,
  4838. distance: 0,
  4839. max: 100,
  4840. min: 0,
  4841. orientation: "horizontal",
  4842. range: false,
  4843. step: 1,
  4844. value: 0,
  4845. values: null,
  4846. // callbacks
  4847. change: null,
  4848. slide: null,
  4849. start: null,
  4850. stop: null
  4851. },
  4852. // number of pages in a slider
  4853. // (how many times can you page up/down to go through the whole range)
  4854. numPages: 5,
  4855. _create: function() {
  4856. this._keySliding = false;
  4857. this._mouseSliding = false;
  4858. this._animateOff = true;
  4859. this._handleIndex = null;
  4860. this._detectOrientation();
  4861. this._mouseInit();
  4862. this._calculateNewMax();
  4863. this.element
  4864. .addClass( "ui-slider" +
  4865. " ui-slider-" + this.orientation +
  4866. " ui-widget" +
  4867. " ui-widget-content" +
  4868. " ui-corner-all");
  4869. this._refresh();
  4870. this._setOption( "disabled", this.options.disabled );
  4871. this._animateOff = false;
  4872. },
  4873. _refresh: function() {
  4874. this._createRange();
  4875. this._createHandles();
  4876. this._setupEvents();
  4877. this._refreshValue();
  4878. },
  4879. _createHandles: function() {
  4880. var i, handleCount,
  4881. options = this.options,
  4882. existingHandles = this.element.find( ".ui-slider-handle" ).addClass( "ui-state-default ui-corner-all" ),
  4883. handle = "<span class='ui-slider-handle ui-state-default ui-corner-all' tabindex='0'></span>",
  4884. handles = [];
  4885. handleCount = ( options.values && options.values.length ) || 1;
  4886. if ( existingHandles.length > handleCount ) {
  4887. existingHandles.slice( handleCount ).remove();
  4888. existingHandles = existingHandles.slice( 0, handleCount );
  4889. }
  4890. for ( i = existingHandles.length; i < handleCount; i++ ) {
  4891. handles.push( handle );
  4892. }
  4893. this.handles = existingHandles.add( $( handles.join( "" ) ).appendTo( this.element ) );
  4894. this.handle = this.handles.eq( 0 );
  4895. this.handles.each(function( i ) {
  4896. $( this ).data( "ui-slider-handle-index", i );
  4897. });
  4898. },
  4899. _createRange: function() {
  4900. var options = this.options,
  4901. classes = "";
  4902. if ( options.range ) {
  4903. if ( options.range === true ) {
  4904. if ( !options.values ) {
  4905. options.values = [ this._valueMin(), this._valueMin() ];
  4906. } else if ( options.values.length && options.values.length !== 2 ) {
  4907. options.values = [ options.values[0], options.values[0] ];
  4908. } else if ( $.isArray( options.values ) ) {
  4909. options.values = options.values.slice(0);
  4910. }
  4911. }
  4912. if ( !this.range || !this.range.length ) {
  4913. this.range = $( "<div></div>" )
  4914. .appendTo( this.element );
  4915. classes = "ui-slider-range" +
  4916. // note: this isn't the most fittingly semantic framework class for this element,
  4917. // but worked best visually with a variety of themes
  4918. " ui-widget-header ui-corner-all";
  4919. } else {
  4920. this.range.removeClass( "ui-slider-range-min ui-slider-range-max" )
  4921. // Handle range switching from true to min/max
  4922. .css({
  4923. "left": "",
  4924. "bottom": ""
  4925. });
  4926. }
  4927. this.range.addClass( classes +
  4928. ( ( options.range === "min" || options.range === "max" ) ? " ui-slider-range-" + options.range : "" ) );
  4929. } else {
  4930. if ( this.range ) {
  4931. this.range.remove();
  4932. }
  4933. this.range = null;
  4934. }
  4935. },
  4936. _setupEvents: function() {
  4937. this._off( this.handles );
  4938. this._on( this.handles, this._handleEvents );
  4939. this._hoverable( this.handles );
  4940. this._focusable( this.handles );
  4941. },
  4942. _destroy: function() {
  4943. this.handles.remove();
  4944. if ( this.range ) {
  4945. this.range.remove();
  4946. }
  4947. this.element
  4948. .removeClass( "ui-slider" +
  4949. " ui-slider-horizontal" +
  4950. " ui-slider-vertical" +
  4951. " ui-widget" +
  4952. " ui-widget-content" +
  4953. " ui-corner-all" );
  4954. this._mouseDestroy();
  4955. },
  4956. _mouseCapture: function( event ) {
  4957. var position, normValue, distance, closestHandle, index, allowed, offset, mouseOverHandle,
  4958. that = this,
  4959. o = this.options;
  4960. if ( o.disabled ) {
  4961. return false;
  4962. }
  4963. this.elementSize = {
  4964. width: this.element.outerWidth(),
  4965. height: this.element.outerHeight()
  4966. };
  4967. this.elementOffset = this.element.offset();
  4968. position = { x: event.pageX, y: event.pageY };
  4969. normValue = this._normValueFromMouse( position );
  4970. distance = this._valueMax() - this._valueMin() + 1;
  4971. this.handles.each(function( i ) {
  4972. var thisDistance = Math.abs( normValue - that.values(i) );
  4973. if (( distance > thisDistance ) ||
  4974. ( distance === thisDistance &&
  4975. (i === that._lastChangedValue || that.values(i) === o.min ))) {
  4976. distance = thisDistance;
  4977. closestHandle = $( this );
  4978. index = i;
  4979. }
  4980. });
  4981. allowed = this._start( event, index );
  4982. if ( allowed === false ) {
  4983. return false;
  4984. }
  4985. this._mouseSliding = true;
  4986. this._handleIndex = index;
  4987. closestHandle
  4988. .addClass( "ui-state-active" )
  4989. .focus();
  4990. offset = closestHandle.offset();
  4991. mouseOverHandle = !$( event.target ).parents().addBack().is( ".ui-slider-handle" );
  4992. this._clickOffset = mouseOverHandle ? { left: 0, top: 0 } : {
  4993. left: event.pageX - offset.left - ( closestHandle.width() / 2 ),
  4994. top: event.pageY - offset.top -
  4995. ( closestHandle.height() / 2 ) -
  4996. ( parseInt( closestHandle.css("borderTopWidth"), 10 ) || 0 ) -
  4997. ( parseInt( closestHandle.css("borderBottomWidth"), 10 ) || 0) +
  4998. ( parseInt( closestHandle.css("marginTop"), 10 ) || 0)
  4999. };
  5000. if ( !this.handles.hasClass( "ui-state-hover" ) ) {
  5001. this._slide( event, index, normValue );
  5002. }
  5003. this._animateOff = true;
  5004. return true;
  5005. },
  5006. _mouseStart: function() {
  5007. return true;
  5008. },
  5009. _mouseDrag: function( event ) {
  5010. var position = { x: event.pageX, y: event.pageY },
  5011. normValue = this._normValueFromMouse( position );
  5012. this._slide( event, this._handleIndex, normValue );
  5013. return false;
  5014. },
  5015. _mouseStop: function( event ) {
  5016. this.handles.removeClass( "ui-state-active" );
  5017. this._mouseSliding = false;
  5018. this._stop( event, this._handleIndex );
  5019. this._change( event, this._handleIndex );
  5020. this._handleIndex = null;
  5021. this._clickOffset = null;
  5022. this._animateOff = false;
  5023. return false;
  5024. },
  5025. _detectOrientation: function() {
  5026. this.orientation = ( this.options.orientation === "vertical" ) ? "vertical" : "horizontal";
  5027. },
  5028. _normValueFromMouse: function( position ) {
  5029. var pixelTotal,
  5030. pixelMouse,
  5031. percentMouse,
  5032. valueTotal,
  5033. valueMouse;
  5034. if ( this.orientation === "horizontal" ) {
  5035. pixelTotal = this.elementSize.width;
  5036. pixelMouse = position.x - this.elementOffset.left - ( this._clickOffset ? this._clickOffset.left : 0 );
  5037. } else {
  5038. pixelTotal = this.elementSize.height;
  5039. pixelMouse = position.y - this.elementOffset.top - ( this._clickOffset ? this._clickOffset.top : 0 );
  5040. }
  5041. percentMouse = ( pixelMouse / pixelTotal );
  5042. if ( percentMouse > 1 ) {
  5043. percentMouse = 1;
  5044. }
  5045. if ( percentMouse < 0 ) {
  5046. percentMouse = 0;
  5047. }
  5048. if ( this.orientation === "vertical" ) {
  5049. percentMouse = 1 - percentMouse;
  5050. }
  5051. valueTotal = this._valueMax() - this._valueMin();
  5052. valueMouse = this._valueMin() + percentMouse * valueTotal;
  5053. return this._trimAlignValue( valueMouse );
  5054. },
  5055. _start: function( event, index ) {
  5056. var uiHash = {
  5057. handle: this.handles[ index ],
  5058. value: this.value()
  5059. };
  5060. if ( this.options.values && this.options.values.length ) {
  5061. uiHash.value = this.values( index );
  5062. uiHash.values = this.values();
  5063. }
  5064. return this._trigger( "start", event, uiHash );
  5065. },
  5066. _slide: function( event, index, newVal ) {
  5067. var otherVal,
  5068. newValues,
  5069. allowed;
  5070. if ( this.options.values && this.options.values.length ) {
  5071. otherVal = this.values( index ? 0 : 1 );
  5072. if ( ( this.options.values.length === 2 && this.options.range === true ) &&
  5073. ( ( index === 0 && newVal > otherVal) || ( index === 1 && newVal < otherVal ) )
  5074. ) {
  5075. newVal = otherVal;
  5076. }
  5077. if ( newVal !== this.values( index ) ) {
  5078. newValues = this.values();
  5079. newValues[ index ] = newVal;
  5080. // A slide can be canceled by returning false from the slide callback
  5081. allowed = this._trigger( "slide", event, {
  5082. handle: this.handles[ index ],
  5083. value: newVal,
  5084. values: newValues
  5085. } );
  5086. otherVal = this.values( index ? 0 : 1 );
  5087. if ( allowed !== false ) {
  5088. this.values( index, newVal );
  5089. }
  5090. }
  5091. } else {
  5092. if ( newVal !== this.value() ) {
  5093. // A slide can be canceled by returning false from the slide callback
  5094. allowed = this._trigger( "slide", event, {
  5095. handle: this.handles[ index ],
  5096. value: newVal
  5097. } );
  5098. if ( allowed !== false ) {
  5099. this.value( newVal );
  5100. }
  5101. }
  5102. }
  5103. },
  5104. _stop: function( event, index ) {
  5105. var uiHash = {
  5106. handle: this.handles[ index ],
  5107. value: this.value()
  5108. };
  5109. if ( this.options.values && this.options.values.length ) {
  5110. uiHash.value = this.values( index );
  5111. uiHash.values = this.values();
  5112. }
  5113. this._trigger( "stop", event, uiHash );
  5114. },
  5115. _change: function( event, index ) {
  5116. if ( !this._keySliding && !this._mouseSliding ) {
  5117. var uiHash = {
  5118. handle: this.handles[ index ],
  5119. value: this.value()
  5120. };
  5121. if ( this.options.values && this.options.values.length ) {
  5122. uiHash.value = this.values( index );
  5123. uiHash.values = this.values();
  5124. }
  5125. //store the last changed value index for reference when handles overlap
  5126. this._lastChangedValue = index;
  5127. this._trigger( "change", event, uiHash );
  5128. }
  5129. },
  5130. value: function( newValue ) {
  5131. if ( arguments.length ) {
  5132. this.options.value = this._trimAlignValue( newValue );
  5133. this._refreshValue();
  5134. this._change( null, 0 );
  5135. return;
  5136. }
  5137. return this._value();
  5138. },
  5139. values: function( index, newValue ) {
  5140. var vals,
  5141. newValues,
  5142. i;
  5143. if ( arguments.length > 1 ) {
  5144. this.options.values[ index ] = this._trimAlignValue( newValue );
  5145. this._refreshValue();
  5146. this._change( null, index );
  5147. return;
  5148. }
  5149. if ( arguments.length ) {
  5150. if ( $.isArray( arguments[ 0 ] ) ) {
  5151. vals = this.options.values;
  5152. newValues = arguments[ 0 ];
  5153. for ( i = 0; i < vals.length; i += 1 ) {
  5154. vals[ i ] = this._trimAlignValue( newValues[ i ] );
  5155. this._change( null, i );
  5156. }
  5157. this._refreshValue();
  5158. } else {
  5159. if ( this.options.values && this.options.values.length ) {
  5160. return this._values( index );
  5161. } else {
  5162. return this.value();
  5163. }
  5164. }
  5165. } else {
  5166. return this._values();
  5167. }
  5168. },
  5169. _setOption: function( key, value ) {
  5170. var i,
  5171. valsLength = 0;
  5172. if ( key === "range" && this.options.range === true ) {
  5173. if ( value === "min" ) {
  5174. this.options.value = this._values( 0 );
  5175. this.options.values = null;
  5176. } else if ( value === "max" ) {
  5177. this.options.value = this._values( this.options.values.length - 1 );
  5178. this.options.values = null;
  5179. }
  5180. }
  5181. if ( $.isArray( this.options.values ) ) {
  5182. valsLength = this.options.values.length;
  5183. }
  5184. if ( key === "disabled" ) {
  5185. this.element.toggleClass( "ui-state-disabled", !!value );
  5186. }
  5187. this._super( key, value );
  5188. switch ( key ) {
  5189. case "orientation":
  5190. this._detectOrientation();
  5191. this.element
  5192. .removeClass( "ui-slider-horizontal ui-slider-vertical" )
  5193. .addClass( "ui-slider-" + this.orientation );
  5194. this._refreshValue();
  5195. // Reset positioning from previous orientation
  5196. this.handles.css( value === "horizontal" ? "bottom" : "left", "" );
  5197. break;
  5198. case "value":
  5199. this._animateOff = true;
  5200. this._refreshValue();
  5201. this._change( null, 0 );
  5202. this._animateOff = false;
  5203. break;
  5204. case "values":
  5205. this._animateOff = true;
  5206. this._refreshValue();
  5207. for ( i = 0; i < valsLength; i += 1 ) {
  5208. this._change( null, i );
  5209. }
  5210. this._animateOff = false;
  5211. break;
  5212. case "step":
  5213. case "min":
  5214. case "max":
  5215. this._animateOff = true;
  5216. this._calculateNewMax();
  5217. this._refreshValue();
  5218. this._animateOff = false;
  5219. break;
  5220. case "range":
  5221. this._animateOff = true;
  5222. this._refresh();
  5223. this._animateOff = false;
  5224. break;
  5225. }
  5226. },
  5227. //internal value getter
  5228. // _value() returns value trimmed by min and max, aligned by step
  5229. _value: function() {
  5230. var val = this.options.value;
  5231. val = this._trimAlignValue( val );
  5232. return val;
  5233. },
  5234. //internal values getter
  5235. // _values() returns array of values trimmed by min and max, aligned by step
  5236. // _values( index ) returns single value trimmed by min and max, aligned by step
  5237. _values: function( index ) {
  5238. var val,
  5239. vals,
  5240. i;
  5241. if ( arguments.length ) {
  5242. val = this.options.values[ index ];
  5243. val = this._trimAlignValue( val );
  5244. return val;
  5245. } else if ( this.options.values && this.options.values.length ) {
  5246. // .slice() creates a copy of the array
  5247. // this copy gets trimmed by min and max and then returned
  5248. vals = this.options.values.slice();
  5249. for ( i = 0; i < vals.length; i += 1) {
  5250. vals[ i ] = this._trimAlignValue( vals[ i ] );
  5251. }
  5252. return vals;
  5253. } else {
  5254. return [];
  5255. }
  5256. },
  5257. // returns the step-aligned value that val is closest to, between (inclusive) min and max
  5258. _trimAlignValue: function( val ) {
  5259. if ( val <= this._valueMin() ) {
  5260. return this._valueMin();
  5261. }
  5262. if ( val >= this._valueMax() ) {
  5263. return this._valueMax();
  5264. }
  5265. var step = ( this.options.step > 0 ) ? this.options.step : 1,
  5266. valModStep = (val - this._valueMin()) % step,
  5267. alignValue = val - valModStep;
  5268. if ( Math.abs(valModStep) * 2 >= step ) {
  5269. alignValue += ( valModStep > 0 ) ? step : ( -step );
  5270. }
  5271. // Since JavaScript has problems with large floats, round
  5272. // the final value to 5 digits after the decimal point (see #4124)
  5273. return parseFloat( alignValue.toFixed(5) );
  5274. },
  5275. _calculateNewMax: function() {
  5276. var max = this.options.max,
  5277. min = this._valueMin(),
  5278. step = this.options.step,
  5279. aboveMin = Math.floor( ( +( max - min ).toFixed( this._precision() ) ) / step ) * step;
  5280. max = aboveMin + min;
  5281. this.max = parseFloat( max.toFixed( this._precision() ) );
  5282. },
  5283. _precision: function() {
  5284. var precision = this._precisionOf( this.options.step );
  5285. if ( this.options.min !== null ) {
  5286. precision = Math.max( precision, this._precisionOf( this.options.min ) );
  5287. }
  5288. return precision;
  5289. },
  5290. _precisionOf: function( num ) {
  5291. var str = num.toString(),
  5292. decimal = str.indexOf( "." );
  5293. return decimal === -1 ? 0 : str.length - decimal - 1;
  5294. },
  5295. _valueMin: function() {
  5296. return this.options.min;
  5297. },
  5298. _valueMax: function() {
  5299. return this.max;
  5300. },
  5301. _refreshValue: function() {
  5302. var lastValPercent, valPercent, value, valueMin, valueMax,
  5303. oRange = this.options.range,
  5304. o = this.options,
  5305. that = this,
  5306. animate = ( !this._animateOff ) ? o.animate : false,
  5307. _set = {};
  5308. if ( this.options.values && this.options.values.length ) {
  5309. this.handles.each(function( i ) {
  5310. valPercent = ( that.values(i) - that._valueMin() ) / ( that._valueMax() - that._valueMin() ) * 100;
  5311. _set[ that.orientation === "horizontal" ? "left" : "bottom" ] = valPercent + "%";
  5312. $( this ).stop( 1, 1 )[ animate ? "animate" : "css" ]( _set, o.animate );
  5313. if ( that.options.range === true ) {
  5314. if ( that.orientation === "horizontal" ) {
  5315. if ( i === 0 ) {
  5316. that.range.stop( 1, 1 )[ animate ? "animate" : "css" ]( { left: valPercent + "%" }, o.animate );
  5317. }
  5318. if ( i === 1 ) {
  5319. that.range[ animate ? "animate" : "css" ]( { width: ( valPercent - lastValPercent ) + "%" }, { queue: false, duration: o.animate } );
  5320. }
  5321. } else {
  5322. if ( i === 0 ) {
  5323. that.range.stop( 1, 1 )[ animate ? "animate" : "css" ]( { bottom: ( valPercent ) + "%" }, o.animate );
  5324. }
  5325. if ( i === 1 ) {
  5326. that.range[ animate ? "animate" : "css" ]( { height: ( valPercent - lastValPercent ) + "%" }, { queue: false, duration: o.animate } );
  5327. }
  5328. }
  5329. }
  5330. lastValPercent = valPercent;
  5331. });
  5332. } else {
  5333. value = this.value();
  5334. valueMin = this._valueMin();
  5335. valueMax = this._valueMax();
  5336. valPercent = ( valueMax !== valueMin ) ?
  5337. ( value - valueMin ) / ( valueMax - valueMin ) * 100 :
  5338. 0;
  5339. _set[ this.orientation === "horizontal" ? "left" : "bottom" ] = valPercent + "%";
  5340. this.handle.stop( 1, 1 )[ animate ? "animate" : "css" ]( _set, o.animate );
  5341. if ( oRange === "min" && this.orientation === "horizontal" ) {
  5342. this.range.stop( 1, 1 )[ animate ? "animate" : "css" ]( { width: valPercent + "%" }, o.animate );
  5343. }
  5344. if ( oRange === "max" && this.orientation === "horizontal" ) {
  5345. this.range[ animate ? "animate" : "css" ]( { width: ( 100 - valPercent ) + "%" }, { queue: false, duration: o.animate } );
  5346. }
  5347. if ( oRange === "min" && this.orientation === "vertical" ) {
  5348. this.range.stop( 1, 1 )[ animate ? "animate" : "css" ]( { height: valPercent + "%" }, o.animate );
  5349. }
  5350. if ( oRange === "max" && this.orientation === "vertical" ) {
  5351. this.range[ animate ? "animate" : "css" ]( { height: ( 100 - valPercent ) + "%" }, { queue: false, duration: o.animate } );
  5352. }
  5353. }
  5354. },
  5355. _handleEvents: {
  5356. keydown: function( event ) {
  5357. var allowed, curVal, newVal, step,
  5358. index = $( event.target ).data( "ui-slider-handle-index" );
  5359. switch ( event.keyCode ) {
  5360. case $.ui.keyCode.HOME:
  5361. case $.ui.keyCode.END:
  5362. case $.ui.keyCode.PAGE_UP:
  5363. case $.ui.keyCode.PAGE_DOWN:
  5364. case $.ui.keyCode.UP:
  5365. case $.ui.keyCode.RIGHT:
  5366. case $.ui.keyCode.DOWN:
  5367. case $.ui.keyCode.LEFT:
  5368. event.preventDefault();
  5369. if ( !this._keySliding ) {
  5370. this._keySliding = true;
  5371. $( event.target ).addClass( "ui-state-active" );
  5372. allowed = this._start( event, index );
  5373. if ( allowed === false ) {
  5374. return;
  5375. }
  5376. }
  5377. break;
  5378. }
  5379. step = this.options.step;
  5380. if ( this.options.values && this.options.values.length ) {
  5381. curVal = newVal = this.values( index );
  5382. } else {
  5383. curVal = newVal = this.value();
  5384. }
  5385. switch ( event.keyCode ) {
  5386. case $.ui.keyCode.HOME:
  5387. newVal = this._valueMin();
  5388. break;
  5389. case $.ui.keyCode.END:
  5390. newVal = this._valueMax();
  5391. break;
  5392. case $.ui.keyCode.PAGE_UP:
  5393. newVal = this._trimAlignValue(
  5394. curVal + ( ( this._valueMax() - this._valueMin() ) / this.numPages )
  5395. );
  5396. break;
  5397. case $.ui.keyCode.PAGE_DOWN:
  5398. newVal = this._trimAlignValue(
  5399. curVal - ( (this._valueMax() - this._valueMin()) / this.numPages ) );
  5400. break;
  5401. case $.ui.keyCode.UP:
  5402. case $.ui.keyCode.RIGHT:
  5403. if ( curVal === this._valueMax() ) {
  5404. return;
  5405. }
  5406. newVal = this._trimAlignValue( curVal + step );
  5407. break;
  5408. case $.ui.keyCode.DOWN:
  5409. case $.ui.keyCode.LEFT:
  5410. if ( curVal === this._valueMin() ) {
  5411. return;
  5412. }
  5413. newVal = this._trimAlignValue( curVal - step );
  5414. break;
  5415. }
  5416. this._slide( event, index, newVal );
  5417. },
  5418. keyup: function( event ) {
  5419. var index = $( event.target ).data( "ui-slider-handle-index" );
  5420. if ( this._keySliding ) {
  5421. this._keySliding = false;
  5422. this._stop( event, index );
  5423. this._change( event, index );
  5424. $( event.target ).removeClass( "ui-state-active" );
  5425. }
  5426. }
  5427. }
  5428. });
  5429. }));