jquery-ui-1.11.4.custom.js 243 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226
  1. /*! jQuery UI - v1.11.4 - 2015-03-15
  2. * http://jqueryui.com
  3. * Includes: core.js, widget.js, mouse.js, position.js, draggable.js, droppable.js, resizable.js, autocomplete.js, datepicker.js, menu.js, slider.js
  4. * Copyright 2015 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 Draggable 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/draggable/
  1375. */
  1376. $.widget("ui.draggable", $.ui.mouse, {
  1377. version: "1.11.4",
  1378. widgetEventPrefix: "drag",
  1379. options: {
  1380. addClasses: true,
  1381. appendTo: "parent",
  1382. axis: false,
  1383. connectToSortable: false,
  1384. containment: false,
  1385. cursor: "auto",
  1386. cursorAt: false,
  1387. grid: false,
  1388. handle: false,
  1389. helper: "original",
  1390. iframeFix: false,
  1391. opacity: false,
  1392. refreshPositions: false,
  1393. revert: false,
  1394. revertDuration: 500,
  1395. scope: "default",
  1396. scroll: true,
  1397. scrollSensitivity: 20,
  1398. scrollSpeed: 20,
  1399. snap: false,
  1400. snapMode: "both",
  1401. snapTolerance: 20,
  1402. stack: false,
  1403. zIndex: false,
  1404. // callbacks
  1405. drag: null,
  1406. start: null,
  1407. stop: null
  1408. },
  1409. _create: function() {
  1410. if ( this.options.helper === "original" ) {
  1411. this._setPositionRelative();
  1412. }
  1413. if (this.options.addClasses){
  1414. this.element.addClass("ui-draggable");
  1415. }
  1416. if (this.options.disabled){
  1417. this.element.addClass("ui-draggable-disabled");
  1418. }
  1419. this._setHandleClassName();
  1420. this._mouseInit();
  1421. },
  1422. _setOption: function( key, value ) {
  1423. this._super( key, value );
  1424. if ( key === "handle" ) {
  1425. this._removeHandleClassName();
  1426. this._setHandleClassName();
  1427. }
  1428. },
  1429. _destroy: function() {
  1430. if ( ( this.helper || this.element ).is( ".ui-draggable-dragging" ) ) {
  1431. this.destroyOnClear = true;
  1432. return;
  1433. }
  1434. this.element.removeClass( "ui-draggable ui-draggable-dragging ui-draggable-disabled" );
  1435. this._removeHandleClassName();
  1436. this._mouseDestroy();
  1437. },
  1438. _mouseCapture: function(event) {
  1439. var o = this.options;
  1440. this._blurActiveElement( event );
  1441. // among others, prevent a drag on a resizable-handle
  1442. if (this.helper || o.disabled || $(event.target).closest(".ui-resizable-handle").length > 0) {
  1443. return false;
  1444. }
  1445. //Quit if we're not on a valid handle
  1446. this.handle = this._getHandle(event);
  1447. if (!this.handle) {
  1448. return false;
  1449. }
  1450. this._blockFrames( o.iframeFix === true ? "iframe" : o.iframeFix );
  1451. return true;
  1452. },
  1453. _blockFrames: function( selector ) {
  1454. this.iframeBlocks = this.document.find( selector ).map(function() {
  1455. var iframe = $( this );
  1456. return $( "<div>" )
  1457. .css( "position", "absolute" )
  1458. .appendTo( iframe.parent() )
  1459. .outerWidth( iframe.outerWidth() )
  1460. .outerHeight( iframe.outerHeight() )
  1461. .offset( iframe.offset() )[ 0 ];
  1462. });
  1463. },
  1464. _unblockFrames: function() {
  1465. if ( this.iframeBlocks ) {
  1466. this.iframeBlocks.remove();
  1467. delete this.iframeBlocks;
  1468. }
  1469. },
  1470. _blurActiveElement: function( event ) {
  1471. var document = this.document[ 0 ];
  1472. // Only need to blur if the event occurred on the draggable itself, see #10527
  1473. if ( !this.handleElement.is( event.target ) ) {
  1474. return;
  1475. }
  1476. // support: IE9
  1477. // IE9 throws an "Unspecified error" accessing document.activeElement from an <iframe>
  1478. try {
  1479. // Support: IE9, IE10
  1480. // If the <body> is blurred, IE will switch windows, see #9520
  1481. if ( document.activeElement && document.activeElement.nodeName.toLowerCase() !== "body" ) {
  1482. // Blur any element that currently has focus, see #4261
  1483. $( document.activeElement ).blur();
  1484. }
  1485. } catch ( error ) {}
  1486. },
  1487. _mouseStart: function(event) {
  1488. var o = this.options;
  1489. //Create and append the visible helper
  1490. this.helper = this._createHelper(event);
  1491. this.helper.addClass("ui-draggable-dragging");
  1492. //Cache the helper size
  1493. this._cacheHelperProportions();
  1494. //If ddmanager is used for droppables, set the global draggable
  1495. if ($.ui.ddmanager) {
  1496. $.ui.ddmanager.current = this;
  1497. }
  1498. /*
  1499. * - Position generation -
  1500. * This block generates everything position related - it's the core of draggables.
  1501. */
  1502. //Cache the margins of the original element
  1503. this._cacheMargins();
  1504. //Store the helper's css position
  1505. this.cssPosition = this.helper.css( "position" );
  1506. this.scrollParent = this.helper.scrollParent( true );
  1507. this.offsetParent = this.helper.offsetParent();
  1508. this.hasFixedAncestor = this.helper.parents().filter(function() {
  1509. return $( this ).css( "position" ) === "fixed";
  1510. }).length > 0;
  1511. //The element's absolute position on the page minus margins
  1512. this.positionAbs = this.element.offset();
  1513. this._refreshOffsets( event );
  1514. //Generate the original position
  1515. this.originalPosition = this.position = this._generatePosition( event, false );
  1516. this.originalPageX = event.pageX;
  1517. this.originalPageY = event.pageY;
  1518. //Adjust the mouse offset relative to the helper if "cursorAt" is supplied
  1519. (o.cursorAt && this._adjustOffsetFromHelper(o.cursorAt));
  1520. //Set a containment if given in the options
  1521. this._setContainment();
  1522. //Trigger event + callbacks
  1523. if (this._trigger("start", event) === false) {
  1524. this._clear();
  1525. return false;
  1526. }
  1527. //Recache the helper size
  1528. this._cacheHelperProportions();
  1529. //Prepare the droppable offsets
  1530. if ($.ui.ddmanager && !o.dropBehaviour) {
  1531. $.ui.ddmanager.prepareOffsets(this, event);
  1532. }
  1533. // Reset helper's right/bottom css if they're set and set explicit width/height instead
  1534. // as this prevents resizing of elements with right/bottom set (see #7772)
  1535. this._normalizeRightBottom();
  1536. this._mouseDrag(event, true); //Execute the drag once - this causes the helper not to be visible before getting its correct position
  1537. //If the ddmanager is used for droppables, inform the manager that dragging has started (see #5003)
  1538. if ( $.ui.ddmanager ) {
  1539. $.ui.ddmanager.dragStart(this, event);
  1540. }
  1541. return true;
  1542. },
  1543. _refreshOffsets: function( event ) {
  1544. this.offset = {
  1545. top: this.positionAbs.top - this.margins.top,
  1546. left: this.positionAbs.left - this.margins.left,
  1547. scroll: false,
  1548. parent: this._getParentOffset(),
  1549. relative: this._getRelativeOffset()
  1550. };
  1551. this.offset.click = {
  1552. left: event.pageX - this.offset.left,
  1553. top: event.pageY - this.offset.top
  1554. };
  1555. },
  1556. _mouseDrag: function(event, noPropagation) {
  1557. // reset any necessary cached properties (see #5009)
  1558. if ( this.hasFixedAncestor ) {
  1559. this.offset.parent = this._getParentOffset();
  1560. }
  1561. //Compute the helpers position
  1562. this.position = this._generatePosition( event, true );
  1563. this.positionAbs = this._convertPositionTo("absolute");
  1564. //Call plugins and callbacks and use the resulting position if something is returned
  1565. if (!noPropagation) {
  1566. var ui = this._uiHash();
  1567. if (this._trigger("drag", event, ui) === false) {
  1568. this._mouseUp({});
  1569. return false;
  1570. }
  1571. this.position = ui.position;
  1572. }
  1573. this.helper[ 0 ].style.left = this.position.left + "px";
  1574. this.helper[ 0 ].style.top = this.position.top + "px";
  1575. if ($.ui.ddmanager) {
  1576. $.ui.ddmanager.drag(this, event);
  1577. }
  1578. return false;
  1579. },
  1580. _mouseStop: function(event) {
  1581. //If we are using droppables, inform the manager about the drop
  1582. var that = this,
  1583. dropped = false;
  1584. if ($.ui.ddmanager && !this.options.dropBehaviour) {
  1585. dropped = $.ui.ddmanager.drop(this, event);
  1586. }
  1587. //if a drop comes from outside (a sortable)
  1588. if (this.dropped) {
  1589. dropped = this.dropped;
  1590. this.dropped = false;
  1591. }
  1592. if ((this.options.revert === "invalid" && !dropped) || (this.options.revert === "valid" && dropped) || this.options.revert === true || ($.isFunction(this.options.revert) && this.options.revert.call(this.element, dropped))) {
  1593. $(this.helper).animate(this.originalPosition, parseInt(this.options.revertDuration, 10), function() {
  1594. if (that._trigger("stop", event) !== false) {
  1595. that._clear();
  1596. }
  1597. });
  1598. } else {
  1599. if (this._trigger("stop", event) !== false) {
  1600. this._clear();
  1601. }
  1602. }
  1603. return false;
  1604. },
  1605. _mouseUp: function( event ) {
  1606. this._unblockFrames();
  1607. //If the ddmanager is used for droppables, inform the manager that dragging has stopped (see #5003)
  1608. if ( $.ui.ddmanager ) {
  1609. $.ui.ddmanager.dragStop(this, event);
  1610. }
  1611. // Only need to focus if the event occurred on the draggable itself, see #10527
  1612. if ( this.handleElement.is( event.target ) ) {
  1613. // The interaction is over; whether or not the click resulted in a drag, focus the element
  1614. this.element.focus();
  1615. }
  1616. return $.ui.mouse.prototype._mouseUp.call(this, event);
  1617. },
  1618. cancel: function() {
  1619. if (this.helper.is(".ui-draggable-dragging")) {
  1620. this._mouseUp({});
  1621. } else {
  1622. this._clear();
  1623. }
  1624. return this;
  1625. },
  1626. _getHandle: function(event) {
  1627. return this.options.handle ?
  1628. !!$( event.target ).closest( this.element.find( this.options.handle ) ).length :
  1629. true;
  1630. },
  1631. _setHandleClassName: function() {
  1632. this.handleElement = this.options.handle ?
  1633. this.element.find( this.options.handle ) : this.element;
  1634. this.handleElement.addClass( "ui-draggable-handle" );
  1635. },
  1636. _removeHandleClassName: function() {
  1637. this.handleElement.removeClass( "ui-draggable-handle" );
  1638. },
  1639. _createHelper: function(event) {
  1640. var o = this.options,
  1641. helperIsFunction = $.isFunction( o.helper ),
  1642. helper = helperIsFunction ?
  1643. $( o.helper.apply( this.element[ 0 ], [ event ] ) ) :
  1644. ( o.helper === "clone" ?
  1645. this.element.clone().removeAttr( "id" ) :
  1646. this.element );
  1647. if (!helper.parents("body").length) {
  1648. helper.appendTo((o.appendTo === "parent" ? this.element[0].parentNode : o.appendTo));
  1649. }
  1650. // http://bugs.jqueryui.com/ticket/9446
  1651. // a helper function can return the original element
  1652. // which wouldn't have been set to relative in _create
  1653. if ( helperIsFunction && helper[ 0 ] === this.element[ 0 ] ) {
  1654. this._setPositionRelative();
  1655. }
  1656. if (helper[0] !== this.element[0] && !(/(fixed|absolute)/).test(helper.css("position"))) {
  1657. helper.css("position", "absolute");
  1658. }
  1659. return helper;
  1660. },
  1661. _setPositionRelative: function() {
  1662. if ( !( /^(?:r|a|f)/ ).test( this.element.css( "position" ) ) ) {
  1663. this.element[ 0 ].style.position = "relative";
  1664. }
  1665. },
  1666. _adjustOffsetFromHelper: function(obj) {
  1667. if (typeof obj === "string") {
  1668. obj = obj.split(" ");
  1669. }
  1670. if ($.isArray(obj)) {
  1671. obj = { left: +obj[0], top: +obj[1] || 0 };
  1672. }
  1673. if ("left" in obj) {
  1674. this.offset.click.left = obj.left + this.margins.left;
  1675. }
  1676. if ("right" in obj) {
  1677. this.offset.click.left = this.helperProportions.width - obj.right + this.margins.left;
  1678. }
  1679. if ("top" in obj) {
  1680. this.offset.click.top = obj.top + this.margins.top;
  1681. }
  1682. if ("bottom" in obj) {
  1683. this.offset.click.top = this.helperProportions.height - obj.bottom + this.margins.top;
  1684. }
  1685. },
  1686. _isRootNode: function( element ) {
  1687. return ( /(html|body)/i ).test( element.tagName ) || element === this.document[ 0 ];
  1688. },
  1689. _getParentOffset: function() {
  1690. //Get the offsetParent and cache its position
  1691. var po = this.offsetParent.offset(),
  1692. document = this.document[ 0 ];
  1693. // This is a special case where we need to modify a offset calculated on start, since the following happened:
  1694. // 1. The position of the helper is absolute, so it's position is calculated based on the next positioned parent
  1695. // 2. The actual offset parent is a child of the scroll parent, and the scroll parent isn't the document, which means that
  1696. // the scroll is included in the initial calculation of the offset of the parent, and never recalculated upon drag
  1697. if (this.cssPosition === "absolute" && this.scrollParent[0] !== document && $.contains(this.scrollParent[0], this.offsetParent[0])) {
  1698. po.left += this.scrollParent.scrollLeft();
  1699. po.top += this.scrollParent.scrollTop();
  1700. }
  1701. if ( this._isRootNode( this.offsetParent[ 0 ] ) ) {
  1702. po = { top: 0, left: 0 };
  1703. }
  1704. return {
  1705. top: po.top + (parseInt(this.offsetParent.css("borderTopWidth"), 10) || 0),
  1706. left: po.left + (parseInt(this.offsetParent.css("borderLeftWidth"), 10) || 0)
  1707. };
  1708. },
  1709. _getRelativeOffset: function() {
  1710. if ( this.cssPosition !== "relative" ) {
  1711. return { top: 0, left: 0 };
  1712. }
  1713. var p = this.element.position(),
  1714. scrollIsRootNode = this._isRootNode( this.scrollParent[ 0 ] );
  1715. return {
  1716. top: p.top - ( parseInt(this.helper.css( "top" ), 10) || 0 ) + ( !scrollIsRootNode ? this.scrollParent.scrollTop() : 0 ),
  1717. left: p.left - ( parseInt(this.helper.css( "left" ), 10) || 0 ) + ( !scrollIsRootNode ? this.scrollParent.scrollLeft() : 0 )
  1718. };
  1719. },
  1720. _cacheMargins: function() {
  1721. this.margins = {
  1722. left: (parseInt(this.element.css("marginLeft"), 10) || 0),
  1723. top: (parseInt(this.element.css("marginTop"), 10) || 0),
  1724. right: (parseInt(this.element.css("marginRight"), 10) || 0),
  1725. bottom: (parseInt(this.element.css("marginBottom"), 10) || 0)
  1726. };
  1727. },
  1728. _cacheHelperProportions: function() {
  1729. this.helperProportions = {
  1730. width: this.helper.outerWidth(),
  1731. height: this.helper.outerHeight()
  1732. };
  1733. },
  1734. _setContainment: function() {
  1735. var isUserScrollable, c, ce,
  1736. o = this.options,
  1737. document = this.document[ 0 ];
  1738. this.relativeContainer = null;
  1739. if ( !o.containment ) {
  1740. this.containment = null;
  1741. return;
  1742. }
  1743. if ( o.containment === "window" ) {
  1744. this.containment = [
  1745. $( window ).scrollLeft() - this.offset.relative.left - this.offset.parent.left,
  1746. $( window ).scrollTop() - this.offset.relative.top - this.offset.parent.top,
  1747. $( window ).scrollLeft() + $( window ).width() - this.helperProportions.width - this.margins.left,
  1748. $( window ).scrollTop() + ( $( window ).height() || document.body.parentNode.scrollHeight ) - this.helperProportions.height - this.margins.top
  1749. ];
  1750. return;
  1751. }
  1752. if ( o.containment === "document") {
  1753. this.containment = [
  1754. 0,
  1755. 0,
  1756. $( document ).width() - this.helperProportions.width - this.margins.left,
  1757. ( $( document ).height() || document.body.parentNode.scrollHeight ) - this.helperProportions.height - this.margins.top
  1758. ];
  1759. return;
  1760. }
  1761. if ( o.containment.constructor === Array ) {
  1762. this.containment = o.containment;
  1763. return;
  1764. }
  1765. if ( o.containment === "parent" ) {
  1766. o.containment = this.helper[ 0 ].parentNode;
  1767. }
  1768. c = $( o.containment );
  1769. ce = c[ 0 ];
  1770. if ( !ce ) {
  1771. return;
  1772. }
  1773. isUserScrollable = /(scroll|auto)/.test( c.css( "overflow" ) );
  1774. this.containment = [
  1775. ( parseInt( c.css( "borderLeftWidth" ), 10 ) || 0 ) + ( parseInt( c.css( "paddingLeft" ), 10 ) || 0 ),
  1776. ( parseInt( c.css( "borderTopWidth" ), 10 ) || 0 ) + ( parseInt( c.css( "paddingTop" ), 10 ) || 0 ),
  1777. ( isUserScrollable ? Math.max( ce.scrollWidth, ce.offsetWidth ) : ce.offsetWidth ) -
  1778. ( parseInt( c.css( "borderRightWidth" ), 10 ) || 0 ) -
  1779. ( parseInt( c.css( "paddingRight" ), 10 ) || 0 ) -
  1780. this.helperProportions.width -
  1781. this.margins.left -
  1782. this.margins.right,
  1783. ( isUserScrollable ? Math.max( ce.scrollHeight, ce.offsetHeight ) : ce.offsetHeight ) -
  1784. ( parseInt( c.css( "borderBottomWidth" ), 10 ) || 0 ) -
  1785. ( parseInt( c.css( "paddingBottom" ), 10 ) || 0 ) -
  1786. this.helperProportions.height -
  1787. this.margins.top -
  1788. this.margins.bottom
  1789. ];
  1790. this.relativeContainer = c;
  1791. },
  1792. _convertPositionTo: function(d, pos) {
  1793. if (!pos) {
  1794. pos = this.position;
  1795. }
  1796. var mod = d === "absolute" ? 1 : -1,
  1797. scrollIsRootNode = this._isRootNode( this.scrollParent[ 0 ] );
  1798. return {
  1799. top: (
  1800. pos.top + // The absolute mouse position
  1801. this.offset.relative.top * mod + // Only for relative positioned nodes: Relative offset from element to offset parent
  1802. this.offset.parent.top * mod - // The offsetParent's offset without borders (offset + border)
  1803. ( ( this.cssPosition === "fixed" ? -this.offset.scroll.top : ( scrollIsRootNode ? 0 : this.offset.scroll.top ) ) * mod)
  1804. ),
  1805. left: (
  1806. pos.left + // The absolute mouse position
  1807. this.offset.relative.left * mod + // Only for relative positioned nodes: Relative offset from element to offset parent
  1808. this.offset.parent.left * mod - // The offsetParent's offset without borders (offset + border)
  1809. ( ( this.cssPosition === "fixed" ? -this.offset.scroll.left : ( scrollIsRootNode ? 0 : this.offset.scroll.left ) ) * mod)
  1810. )
  1811. };
  1812. },
  1813. _generatePosition: function( event, constrainPosition ) {
  1814. var containment, co, top, left,
  1815. o = this.options,
  1816. scrollIsRootNode = this._isRootNode( this.scrollParent[ 0 ] ),
  1817. pageX = event.pageX,
  1818. pageY = event.pageY;
  1819. // Cache the scroll
  1820. if ( !scrollIsRootNode || !this.offset.scroll ) {
  1821. this.offset.scroll = {
  1822. top: this.scrollParent.scrollTop(),
  1823. left: this.scrollParent.scrollLeft()
  1824. };
  1825. }
  1826. /*
  1827. * - Position constraining -
  1828. * Constrain the position to a mix of grid, containment.
  1829. */
  1830. // If we are not dragging yet, we won't check for options
  1831. if ( constrainPosition ) {
  1832. if ( this.containment ) {
  1833. if ( this.relativeContainer ){
  1834. co = this.relativeContainer.offset();
  1835. containment = [
  1836. this.containment[ 0 ] + co.left,
  1837. this.containment[ 1 ] + co.top,
  1838. this.containment[ 2 ] + co.left,
  1839. this.containment[ 3 ] + co.top
  1840. ];
  1841. } else {
  1842. containment = this.containment;
  1843. }
  1844. if (event.pageX - this.offset.click.left < containment[0]) {
  1845. pageX = containment[0] + this.offset.click.left;
  1846. }
  1847. if (event.pageY - this.offset.click.top < containment[1]) {
  1848. pageY = containment[1] + this.offset.click.top;
  1849. }
  1850. if (event.pageX - this.offset.click.left > containment[2]) {
  1851. pageX = containment[2] + this.offset.click.left;
  1852. }
  1853. if (event.pageY - this.offset.click.top > containment[3]) {
  1854. pageY = containment[3] + this.offset.click.top;
  1855. }
  1856. }
  1857. if (o.grid) {
  1858. //Check for grid elements set to 0 to prevent divide by 0 error causing invalid argument errors in IE (see ticket #6950)
  1859. top = o.grid[1] ? this.originalPageY + Math.round((pageY - this.originalPageY) / o.grid[1]) * o.grid[1] : this.originalPageY;
  1860. pageY = containment ? ((top - this.offset.click.top >= containment[1] || top - this.offset.click.top > containment[3]) ? top : ((top - this.offset.click.top >= containment[1]) ? top - o.grid[1] : top + o.grid[1])) : top;
  1861. left = o.grid[0] ? this.originalPageX + Math.round((pageX - this.originalPageX) / o.grid[0]) * o.grid[0] : this.originalPageX;
  1862. pageX = containment ? ((left - this.offset.click.left >= containment[0] || left - this.offset.click.left > containment[2]) ? left : ((left - this.offset.click.left >= containment[0]) ? left - o.grid[0] : left + o.grid[0])) : left;
  1863. }
  1864. if ( o.axis === "y" ) {
  1865. pageX = this.originalPageX;
  1866. }
  1867. if ( o.axis === "x" ) {
  1868. pageY = this.originalPageY;
  1869. }
  1870. }
  1871. return {
  1872. top: (
  1873. pageY - // The absolute mouse position
  1874. this.offset.click.top - // Click offset (relative to the element)
  1875. this.offset.relative.top - // Only for relative positioned nodes: Relative offset from element to offset parent
  1876. this.offset.parent.top + // The offsetParent's offset without borders (offset + border)
  1877. ( this.cssPosition === "fixed" ? -this.offset.scroll.top : ( scrollIsRootNode ? 0 : this.offset.scroll.top ) )
  1878. ),
  1879. left: (
  1880. pageX - // The absolute mouse position
  1881. this.offset.click.left - // Click offset (relative to the element)
  1882. this.offset.relative.left - // Only for relative positioned nodes: Relative offset from element to offset parent
  1883. this.offset.parent.left + // The offsetParent's offset without borders (offset + border)
  1884. ( this.cssPosition === "fixed" ? -this.offset.scroll.left : ( scrollIsRootNode ? 0 : this.offset.scroll.left ) )
  1885. )
  1886. };
  1887. },
  1888. _clear: function() {
  1889. this.helper.removeClass("ui-draggable-dragging");
  1890. if (this.helper[0] !== this.element[0] && !this.cancelHelperRemoval) {
  1891. this.helper.remove();
  1892. }
  1893. this.helper = null;
  1894. this.cancelHelperRemoval = false;
  1895. if ( this.destroyOnClear ) {
  1896. this.destroy();
  1897. }
  1898. },
  1899. _normalizeRightBottom: function() {
  1900. if ( this.options.axis !== "y" && this.helper.css( "right" ) !== "auto" ) {
  1901. this.helper.width( this.helper.width() );
  1902. this.helper.css( "right", "auto" );
  1903. }
  1904. if ( this.options.axis !== "x" && this.helper.css( "bottom" ) !== "auto" ) {
  1905. this.helper.height( this.helper.height() );
  1906. this.helper.css( "bottom", "auto" );
  1907. }
  1908. },
  1909. // From now on bulk stuff - mainly helpers
  1910. _trigger: function( type, event, ui ) {
  1911. ui = ui || this._uiHash();
  1912. $.ui.plugin.call( this, type, [ event, ui, this ], true );
  1913. // Absolute position and offset (see #6884 ) have to be recalculated after plugins
  1914. if ( /^(drag|start|stop)/.test( type ) ) {
  1915. this.positionAbs = this._convertPositionTo( "absolute" );
  1916. ui.offset = this.positionAbs;
  1917. }
  1918. return $.Widget.prototype._trigger.call( this, type, event, ui );
  1919. },
  1920. plugins: {},
  1921. _uiHash: function() {
  1922. return {
  1923. helper: this.helper,
  1924. position: this.position,
  1925. originalPosition: this.originalPosition,
  1926. offset: this.positionAbs
  1927. };
  1928. }
  1929. });
  1930. $.ui.plugin.add( "draggable", "connectToSortable", {
  1931. start: function( event, ui, draggable ) {
  1932. var uiSortable = $.extend( {}, ui, {
  1933. item: draggable.element
  1934. });
  1935. draggable.sortables = [];
  1936. $( draggable.options.connectToSortable ).each(function() {
  1937. var sortable = $( this ).sortable( "instance" );
  1938. if ( sortable && !sortable.options.disabled ) {
  1939. draggable.sortables.push( sortable );
  1940. // refreshPositions is called at drag start to refresh the containerCache
  1941. // which is used in drag. This ensures it's initialized and synchronized
  1942. // with any changes that might have happened on the page since initialization.
  1943. sortable.refreshPositions();
  1944. sortable._trigger("activate", event, uiSortable);
  1945. }
  1946. });
  1947. },
  1948. stop: function( event, ui, draggable ) {
  1949. var uiSortable = $.extend( {}, ui, {
  1950. item: draggable.element
  1951. });
  1952. draggable.cancelHelperRemoval = false;
  1953. $.each( draggable.sortables, function() {
  1954. var sortable = this;
  1955. if ( sortable.isOver ) {
  1956. sortable.isOver = 0;
  1957. // Allow this sortable to handle removing the helper
  1958. draggable.cancelHelperRemoval = true;
  1959. sortable.cancelHelperRemoval = false;
  1960. // Use _storedCSS To restore properties in the sortable,
  1961. // as this also handles revert (#9675) since the draggable
  1962. // may have modified them in unexpected ways (#8809)
  1963. sortable._storedCSS = {
  1964. position: sortable.placeholder.css( "position" ),
  1965. top: sortable.placeholder.css( "top" ),
  1966. left: sortable.placeholder.css( "left" )
  1967. };
  1968. sortable._mouseStop(event);
  1969. // Once drag has ended, the sortable should return to using
  1970. // its original helper, not the shared helper from draggable
  1971. sortable.options.helper = sortable.options._helper;
  1972. } else {
  1973. // Prevent this Sortable from removing the helper.
  1974. // However, don't set the draggable to remove the helper
  1975. // either as another connected Sortable may yet handle the removal.
  1976. sortable.cancelHelperRemoval = true;
  1977. sortable._trigger( "deactivate", event, uiSortable );
  1978. }
  1979. });
  1980. },
  1981. drag: function( event, ui, draggable ) {
  1982. $.each( draggable.sortables, function() {
  1983. var innermostIntersecting = false,
  1984. sortable = this;
  1985. // Copy over variables that sortable's _intersectsWith uses
  1986. sortable.positionAbs = draggable.positionAbs;
  1987. sortable.helperProportions = draggable.helperProportions;
  1988. sortable.offset.click = draggable.offset.click;
  1989. if ( sortable._intersectsWith( sortable.containerCache ) ) {
  1990. innermostIntersecting = true;
  1991. $.each( draggable.sortables, function() {
  1992. // Copy over variables that sortable's _intersectsWith uses
  1993. this.positionAbs = draggable.positionAbs;
  1994. this.helperProportions = draggable.helperProportions;
  1995. this.offset.click = draggable.offset.click;
  1996. if ( this !== sortable &&
  1997. this._intersectsWith( this.containerCache ) &&
  1998. $.contains( sortable.element[ 0 ], this.element[ 0 ] ) ) {
  1999. innermostIntersecting = false;
  2000. }
  2001. return innermostIntersecting;
  2002. });
  2003. }
  2004. if ( innermostIntersecting ) {
  2005. // If it intersects, we use a little isOver variable and set it once,
  2006. // so that the move-in stuff gets fired only once.
  2007. if ( !sortable.isOver ) {
  2008. sortable.isOver = 1;
  2009. // Store draggable's parent in case we need to reappend to it later.
  2010. draggable._parent = ui.helper.parent();
  2011. sortable.currentItem = ui.helper
  2012. .appendTo( sortable.element )
  2013. .data( "ui-sortable-item", true );
  2014. // Store helper option to later restore it
  2015. sortable.options._helper = sortable.options.helper;
  2016. sortable.options.helper = function() {
  2017. return ui.helper[ 0 ];
  2018. };
  2019. // Fire the start events of the sortable with our passed browser event,
  2020. // and our own helper (so it doesn't create a new one)
  2021. event.target = sortable.currentItem[ 0 ];
  2022. sortable._mouseCapture( event, true );
  2023. sortable._mouseStart( event, true, true );
  2024. // Because the browser event is way off the new appended portlet,
  2025. // modify necessary variables to reflect the changes
  2026. sortable.offset.click.top = draggable.offset.click.top;
  2027. sortable.offset.click.left = draggable.offset.click.left;
  2028. sortable.offset.parent.left -= draggable.offset.parent.left -
  2029. sortable.offset.parent.left;
  2030. sortable.offset.parent.top -= draggable.offset.parent.top -
  2031. sortable.offset.parent.top;
  2032. draggable._trigger( "toSortable", event );
  2033. // Inform draggable that the helper is in a valid drop zone,
  2034. // used solely in the revert option to handle "valid/invalid".
  2035. draggable.dropped = sortable.element;
  2036. // Need to refreshPositions of all sortables in the case that
  2037. // adding to one sortable changes the location of the other sortables (#9675)
  2038. $.each( draggable.sortables, function() {
  2039. this.refreshPositions();
  2040. });
  2041. // hack so receive/update callbacks work (mostly)
  2042. draggable.currentItem = draggable.element;
  2043. sortable.fromOutside = draggable;
  2044. }
  2045. if ( sortable.currentItem ) {
  2046. sortable._mouseDrag( event );
  2047. // Copy the sortable's position because the draggable's can potentially reflect
  2048. // a relative position, while sortable is always absolute, which the dragged
  2049. // element has now become. (#8809)
  2050. ui.position = sortable.position;
  2051. }
  2052. } else {
  2053. // If it doesn't intersect with the sortable, and it intersected before,
  2054. // we fake the drag stop of the sortable, but make sure it doesn't remove
  2055. // the helper by using cancelHelperRemoval.
  2056. if ( sortable.isOver ) {
  2057. sortable.isOver = 0;
  2058. sortable.cancelHelperRemoval = true;
  2059. // Calling sortable's mouseStop would trigger a revert,
  2060. // so revert must be temporarily false until after mouseStop is called.
  2061. sortable.options._revert = sortable.options.revert;
  2062. sortable.options.revert = false;
  2063. sortable._trigger( "out", event, sortable._uiHash( sortable ) );
  2064. sortable._mouseStop( event, true );
  2065. // restore sortable behaviors that were modfied
  2066. // when the draggable entered the sortable area (#9481)
  2067. sortable.options.revert = sortable.options._revert;
  2068. sortable.options.helper = sortable.options._helper;
  2069. if ( sortable.placeholder ) {
  2070. sortable.placeholder.remove();
  2071. }
  2072. // Restore and recalculate the draggable's offset considering the sortable
  2073. // may have modified them in unexpected ways. (#8809, #10669)
  2074. ui.helper.appendTo( draggable._parent );
  2075. draggable._refreshOffsets( event );
  2076. ui.position = draggable._generatePosition( event, true );
  2077. draggable._trigger( "fromSortable", event );
  2078. // Inform draggable that the helper is no longer in a valid drop zone
  2079. draggable.dropped = false;
  2080. // Need to refreshPositions of all sortables just in case removing
  2081. // from one sortable changes the location of other sortables (#9675)
  2082. $.each( draggable.sortables, function() {
  2083. this.refreshPositions();
  2084. });
  2085. }
  2086. }
  2087. });
  2088. }
  2089. });
  2090. $.ui.plugin.add("draggable", "cursor", {
  2091. start: function( event, ui, instance ) {
  2092. var t = $( "body" ),
  2093. o = instance.options;
  2094. if (t.css("cursor")) {
  2095. o._cursor = t.css("cursor");
  2096. }
  2097. t.css("cursor", o.cursor);
  2098. },
  2099. stop: function( event, ui, instance ) {
  2100. var o = instance.options;
  2101. if (o._cursor) {
  2102. $("body").css("cursor", o._cursor);
  2103. }
  2104. }
  2105. });
  2106. $.ui.plugin.add("draggable", "opacity", {
  2107. start: function( event, ui, instance ) {
  2108. var t = $( ui.helper ),
  2109. o = instance.options;
  2110. if (t.css("opacity")) {
  2111. o._opacity = t.css("opacity");
  2112. }
  2113. t.css("opacity", o.opacity);
  2114. },
  2115. stop: function( event, ui, instance ) {
  2116. var o = instance.options;
  2117. if (o._opacity) {
  2118. $(ui.helper).css("opacity", o._opacity);
  2119. }
  2120. }
  2121. });
  2122. $.ui.plugin.add("draggable", "scroll", {
  2123. start: function( event, ui, i ) {
  2124. if ( !i.scrollParentNotHidden ) {
  2125. i.scrollParentNotHidden = i.helper.scrollParent( false );
  2126. }
  2127. if ( i.scrollParentNotHidden[ 0 ] !== i.document[ 0 ] && i.scrollParentNotHidden[ 0 ].tagName !== "HTML" ) {
  2128. i.overflowOffset = i.scrollParentNotHidden.offset();
  2129. }
  2130. },
  2131. drag: function( event, ui, i ) {
  2132. var o = i.options,
  2133. scrolled = false,
  2134. scrollParent = i.scrollParentNotHidden[ 0 ],
  2135. document = i.document[ 0 ];
  2136. if ( scrollParent !== document && scrollParent.tagName !== "HTML" ) {
  2137. if ( !o.axis || o.axis !== "x" ) {
  2138. if ( ( i.overflowOffset.top + scrollParent.offsetHeight ) - event.pageY < o.scrollSensitivity ) {
  2139. scrollParent.scrollTop = scrolled = scrollParent.scrollTop + o.scrollSpeed;
  2140. } else if ( event.pageY - i.overflowOffset.top < o.scrollSensitivity ) {
  2141. scrollParent.scrollTop = scrolled = scrollParent.scrollTop - o.scrollSpeed;
  2142. }
  2143. }
  2144. if ( !o.axis || o.axis !== "y" ) {
  2145. if ( ( i.overflowOffset.left + scrollParent.offsetWidth ) - event.pageX < o.scrollSensitivity ) {
  2146. scrollParent.scrollLeft = scrolled = scrollParent.scrollLeft + o.scrollSpeed;
  2147. } else if ( event.pageX - i.overflowOffset.left < o.scrollSensitivity ) {
  2148. scrollParent.scrollLeft = scrolled = scrollParent.scrollLeft - o.scrollSpeed;
  2149. }
  2150. }
  2151. } else {
  2152. if (!o.axis || o.axis !== "x") {
  2153. if (event.pageY - $(document).scrollTop() < o.scrollSensitivity) {
  2154. scrolled = $(document).scrollTop($(document).scrollTop() - o.scrollSpeed);
  2155. } else if ($(window).height() - (event.pageY - $(document).scrollTop()) < o.scrollSensitivity) {
  2156. scrolled = $(document).scrollTop($(document).scrollTop() + o.scrollSpeed);
  2157. }
  2158. }
  2159. if (!o.axis || o.axis !== "y") {
  2160. if (event.pageX - $(document).scrollLeft() < o.scrollSensitivity) {
  2161. scrolled = $(document).scrollLeft($(document).scrollLeft() - o.scrollSpeed);
  2162. } else if ($(window).width() - (event.pageX - $(document).scrollLeft()) < o.scrollSensitivity) {
  2163. scrolled = $(document).scrollLeft($(document).scrollLeft() + o.scrollSpeed);
  2164. }
  2165. }
  2166. }
  2167. if (scrolled !== false && $.ui.ddmanager && !o.dropBehaviour) {
  2168. $.ui.ddmanager.prepareOffsets(i, event);
  2169. }
  2170. }
  2171. });
  2172. $.ui.plugin.add("draggable", "snap", {
  2173. start: function( event, ui, i ) {
  2174. var o = i.options;
  2175. i.snapElements = [];
  2176. $(o.snap.constructor !== String ? ( o.snap.items || ":data(ui-draggable)" ) : o.snap).each(function() {
  2177. var $t = $(this),
  2178. $o = $t.offset();
  2179. if (this !== i.element[0]) {
  2180. i.snapElements.push({
  2181. item: this,
  2182. width: $t.outerWidth(), height: $t.outerHeight(),
  2183. top: $o.top, left: $o.left
  2184. });
  2185. }
  2186. });
  2187. },
  2188. drag: function( event, ui, inst ) {
  2189. var ts, bs, ls, rs, l, r, t, b, i, first,
  2190. o = inst.options,
  2191. d = o.snapTolerance,
  2192. x1 = ui.offset.left, x2 = x1 + inst.helperProportions.width,
  2193. y1 = ui.offset.top, y2 = y1 + inst.helperProportions.height;
  2194. for (i = inst.snapElements.length - 1; i >= 0; i--){
  2195. l = inst.snapElements[i].left - inst.margins.left;
  2196. r = l + inst.snapElements[i].width;
  2197. t = inst.snapElements[i].top - inst.margins.top;
  2198. b = t + inst.snapElements[i].height;
  2199. if ( x2 < l - d || x1 > r + d || y2 < t - d || y1 > b + d || !$.contains( inst.snapElements[ i ].item.ownerDocument, inst.snapElements[ i ].item ) ) {
  2200. if (inst.snapElements[i].snapping) {
  2201. (inst.options.snap.release && inst.options.snap.release.call(inst.element, event, $.extend(inst._uiHash(), { snapItem: inst.snapElements[i].item })));
  2202. }
  2203. inst.snapElements[i].snapping = false;
  2204. continue;
  2205. }
  2206. if (o.snapMode !== "inner") {
  2207. ts = Math.abs(t - y2) <= d;
  2208. bs = Math.abs(b - y1) <= d;
  2209. ls = Math.abs(l - x2) <= d;
  2210. rs = Math.abs(r - x1) <= d;
  2211. if (ts) {
  2212. ui.position.top = inst._convertPositionTo("relative", { top: t - inst.helperProportions.height, left: 0 }).top;
  2213. }
  2214. if (bs) {
  2215. ui.position.top = inst._convertPositionTo("relative", { top: b, left: 0 }).top;
  2216. }
  2217. if (ls) {
  2218. ui.position.left = inst._convertPositionTo("relative", { top: 0, left: l - inst.helperProportions.width }).left;
  2219. }
  2220. if (rs) {
  2221. ui.position.left = inst._convertPositionTo("relative", { top: 0, left: r }).left;
  2222. }
  2223. }
  2224. first = (ts || bs || ls || rs);
  2225. if (o.snapMode !== "outer") {
  2226. ts = Math.abs(t - y1) <= d;
  2227. bs = Math.abs(b - y2) <= d;
  2228. ls = Math.abs(l - x1) <= d;
  2229. rs = Math.abs(r - x2) <= d;
  2230. if (ts) {
  2231. ui.position.top = inst._convertPositionTo("relative", { top: t, left: 0 }).top;
  2232. }
  2233. if (bs) {
  2234. ui.position.top = inst._convertPositionTo("relative", { top: b - inst.helperProportions.height, left: 0 }).top;
  2235. }
  2236. if (ls) {
  2237. ui.position.left = inst._convertPositionTo("relative", { top: 0, left: l }).left;
  2238. }
  2239. if (rs) {
  2240. ui.position.left = inst._convertPositionTo("relative", { top: 0, left: r - inst.helperProportions.width }).left;
  2241. }
  2242. }
  2243. if (!inst.snapElements[i].snapping && (ts || bs || ls || rs || first)) {
  2244. (inst.options.snap.snap && inst.options.snap.snap.call(inst.element, event, $.extend(inst._uiHash(), { snapItem: inst.snapElements[i].item })));
  2245. }
  2246. inst.snapElements[i].snapping = (ts || bs || ls || rs || first);
  2247. }
  2248. }
  2249. });
  2250. $.ui.plugin.add("draggable", "stack", {
  2251. start: function( event, ui, instance ) {
  2252. var min,
  2253. o = instance.options,
  2254. group = $.makeArray($(o.stack)).sort(function(a, b) {
  2255. return (parseInt($(a).css("zIndex"), 10) || 0) - (parseInt($(b).css("zIndex"), 10) || 0);
  2256. });
  2257. if (!group.length) { return; }
  2258. min = parseInt($(group[0]).css("zIndex"), 10) || 0;
  2259. $(group).each(function(i) {
  2260. $(this).css("zIndex", min + i);
  2261. });
  2262. this.css("zIndex", (min + group.length));
  2263. }
  2264. });
  2265. $.ui.plugin.add("draggable", "zIndex", {
  2266. start: function( event, ui, instance ) {
  2267. var t = $( ui.helper ),
  2268. o = instance.options;
  2269. if (t.css("zIndex")) {
  2270. o._zIndex = t.css("zIndex");
  2271. }
  2272. t.css("zIndex", o.zIndex);
  2273. },
  2274. stop: function( event, ui, instance ) {
  2275. var o = instance.options;
  2276. if (o._zIndex) {
  2277. $(ui.helper).css("zIndex", o._zIndex);
  2278. }
  2279. }
  2280. });
  2281. var draggable = $.ui.draggable;
  2282. /*!
  2283. * jQuery UI Droppable 1.11.4
  2284. * http://jqueryui.com
  2285. *
  2286. * Copyright jQuery Foundation and other contributors
  2287. * Released under the MIT license.
  2288. * http://jquery.org/license
  2289. *
  2290. * http://api.jqueryui.com/droppable/
  2291. */
  2292. $.widget( "ui.droppable", {
  2293. version: "1.11.4",
  2294. widgetEventPrefix: "drop",
  2295. options: {
  2296. accept: "*",
  2297. activeClass: false,
  2298. addClasses: true,
  2299. greedy: false,
  2300. hoverClass: false,
  2301. scope: "default",
  2302. tolerance: "intersect",
  2303. // callbacks
  2304. activate: null,
  2305. deactivate: null,
  2306. drop: null,
  2307. out: null,
  2308. over: null
  2309. },
  2310. _create: function() {
  2311. var proportions,
  2312. o = this.options,
  2313. accept = o.accept;
  2314. this.isover = false;
  2315. this.isout = true;
  2316. this.accept = $.isFunction( accept ) ? accept : function( d ) {
  2317. return d.is( accept );
  2318. };
  2319. this.proportions = function( /* valueToWrite */ ) {
  2320. if ( arguments.length ) {
  2321. // Store the droppable's proportions
  2322. proportions = arguments[ 0 ];
  2323. } else {
  2324. // Retrieve or derive the droppable's proportions
  2325. return proportions ?
  2326. proportions :
  2327. proportions = {
  2328. width: this.element[ 0 ].offsetWidth,
  2329. height: this.element[ 0 ].offsetHeight
  2330. };
  2331. }
  2332. };
  2333. this._addToManager( o.scope );
  2334. o.addClasses && this.element.addClass( "ui-droppable" );
  2335. },
  2336. _addToManager: function( scope ) {
  2337. // Add the reference and positions to the manager
  2338. $.ui.ddmanager.droppables[ scope ] = $.ui.ddmanager.droppables[ scope ] || [];
  2339. $.ui.ddmanager.droppables[ scope ].push( this );
  2340. },
  2341. _splice: function( drop ) {
  2342. var i = 0;
  2343. for ( ; i < drop.length; i++ ) {
  2344. if ( drop[ i ] === this ) {
  2345. drop.splice( i, 1 );
  2346. }
  2347. }
  2348. },
  2349. _destroy: function() {
  2350. var drop = $.ui.ddmanager.droppables[ this.options.scope ];
  2351. this._splice( drop );
  2352. this.element.removeClass( "ui-droppable ui-droppable-disabled" );
  2353. },
  2354. _setOption: function( key, value ) {
  2355. if ( key === "accept" ) {
  2356. this.accept = $.isFunction( value ) ? value : function( d ) {
  2357. return d.is( value );
  2358. };
  2359. } else if ( key === "scope" ) {
  2360. var drop = $.ui.ddmanager.droppables[ this.options.scope ];
  2361. this._splice( drop );
  2362. this._addToManager( value );
  2363. }
  2364. this._super( key, value );
  2365. },
  2366. _activate: function( event ) {
  2367. var draggable = $.ui.ddmanager.current;
  2368. if ( this.options.activeClass ) {
  2369. this.element.addClass( this.options.activeClass );
  2370. }
  2371. if ( draggable ){
  2372. this._trigger( "activate", event, this.ui( draggable ) );
  2373. }
  2374. },
  2375. _deactivate: function( event ) {
  2376. var draggable = $.ui.ddmanager.current;
  2377. if ( this.options.activeClass ) {
  2378. this.element.removeClass( this.options.activeClass );
  2379. }
  2380. if ( draggable ){
  2381. this._trigger( "deactivate", event, this.ui( draggable ) );
  2382. }
  2383. },
  2384. _over: function( event ) {
  2385. var draggable = $.ui.ddmanager.current;
  2386. // Bail if draggable and droppable are same element
  2387. if ( !draggable || ( draggable.currentItem || draggable.element )[ 0 ] === this.element[ 0 ] ) {
  2388. return;
  2389. }
  2390. if ( this.accept.call( this.element[ 0 ], ( draggable.currentItem || draggable.element ) ) ) {
  2391. if ( this.options.hoverClass ) {
  2392. this.element.addClass( this.options.hoverClass );
  2393. }
  2394. this._trigger( "over", event, this.ui( draggable ) );
  2395. }
  2396. },
  2397. _out: function( event ) {
  2398. var draggable = $.ui.ddmanager.current;
  2399. // Bail if draggable and droppable are same element
  2400. if ( !draggable || ( draggable.currentItem || draggable.element )[ 0 ] === this.element[ 0 ] ) {
  2401. return;
  2402. }
  2403. if ( this.accept.call( this.element[ 0 ], ( draggable.currentItem || draggable.element ) ) ) {
  2404. if ( this.options.hoverClass ) {
  2405. this.element.removeClass( this.options.hoverClass );
  2406. }
  2407. this._trigger( "out", event, this.ui( draggable ) );
  2408. }
  2409. },
  2410. _drop: function( event, custom ) {
  2411. var draggable = custom || $.ui.ddmanager.current,
  2412. childrenIntersection = false;
  2413. // Bail if draggable and droppable are same element
  2414. if ( !draggable || ( draggable.currentItem || draggable.element )[ 0 ] === this.element[ 0 ] ) {
  2415. return false;
  2416. }
  2417. this.element.find( ":data(ui-droppable)" ).not( ".ui-draggable-dragging" ).each(function() {
  2418. var inst = $( this ).droppable( "instance" );
  2419. if (
  2420. inst.options.greedy &&
  2421. !inst.options.disabled &&
  2422. inst.options.scope === draggable.options.scope &&
  2423. inst.accept.call( inst.element[ 0 ], ( draggable.currentItem || draggable.element ) ) &&
  2424. $.ui.intersect( draggable, $.extend( inst, { offset: inst.element.offset() } ), inst.options.tolerance, event )
  2425. ) { childrenIntersection = true; return false; }
  2426. });
  2427. if ( childrenIntersection ) {
  2428. return false;
  2429. }
  2430. if ( this.accept.call( this.element[ 0 ], ( draggable.currentItem || draggable.element ) ) ) {
  2431. if ( this.options.activeClass ) {
  2432. this.element.removeClass( this.options.activeClass );
  2433. }
  2434. if ( this.options.hoverClass ) {
  2435. this.element.removeClass( this.options.hoverClass );
  2436. }
  2437. this._trigger( "drop", event, this.ui( draggable ) );
  2438. return this.element;
  2439. }
  2440. return false;
  2441. },
  2442. ui: function( c ) {
  2443. return {
  2444. draggable: ( c.currentItem || c.element ),
  2445. helper: c.helper,
  2446. position: c.position,
  2447. offset: c.positionAbs
  2448. };
  2449. }
  2450. });
  2451. $.ui.intersect = (function() {
  2452. function isOverAxis( x, reference, size ) {
  2453. return ( x >= reference ) && ( x < ( reference + size ) );
  2454. }
  2455. return function( draggable, droppable, toleranceMode, event ) {
  2456. if ( !droppable.offset ) {
  2457. return false;
  2458. }
  2459. var x1 = ( draggable.positionAbs || draggable.position.absolute ).left + draggable.margins.left,
  2460. y1 = ( draggable.positionAbs || draggable.position.absolute ).top + draggable.margins.top,
  2461. x2 = x1 + draggable.helperProportions.width,
  2462. y2 = y1 + draggable.helperProportions.height,
  2463. l = droppable.offset.left,
  2464. t = droppable.offset.top,
  2465. r = l + droppable.proportions().width,
  2466. b = t + droppable.proportions().height;
  2467. switch ( toleranceMode ) {
  2468. case "fit":
  2469. return ( l <= x1 && x2 <= r && t <= y1 && y2 <= b );
  2470. case "intersect":
  2471. return ( l < x1 + ( draggable.helperProportions.width / 2 ) && // Right Half
  2472. x2 - ( draggable.helperProportions.width / 2 ) < r && // Left Half
  2473. t < y1 + ( draggable.helperProportions.height / 2 ) && // Bottom Half
  2474. y2 - ( draggable.helperProportions.height / 2 ) < b ); // Top Half
  2475. case "pointer":
  2476. return isOverAxis( event.pageY, t, droppable.proportions().height ) && isOverAxis( event.pageX, l, droppable.proportions().width );
  2477. case "touch":
  2478. return (
  2479. ( y1 >= t && y1 <= b ) || // Top edge touching
  2480. ( y2 >= t && y2 <= b ) || // Bottom edge touching
  2481. ( y1 < t && y2 > b ) // Surrounded vertically
  2482. ) && (
  2483. ( x1 >= l && x1 <= r ) || // Left edge touching
  2484. ( x2 >= l && x2 <= r ) || // Right edge touching
  2485. ( x1 < l && x2 > r ) // Surrounded horizontally
  2486. );
  2487. default:
  2488. return false;
  2489. }
  2490. };
  2491. })();
  2492. /*
  2493. This manager tracks offsets of draggables and droppables
  2494. */
  2495. $.ui.ddmanager = {
  2496. current: null,
  2497. droppables: { "default": [] },
  2498. prepareOffsets: function( t, event ) {
  2499. var i, j,
  2500. m = $.ui.ddmanager.droppables[ t.options.scope ] || [],
  2501. type = event ? event.type : null, // workaround for #2317
  2502. list = ( t.currentItem || t.element ).find( ":data(ui-droppable)" ).addBack();
  2503. droppablesLoop: for ( i = 0; i < m.length; i++ ) {
  2504. // No disabled and non-accepted
  2505. if ( m[ i ].options.disabled || ( t && !m[ i ].accept.call( m[ i ].element[ 0 ], ( t.currentItem || t.element ) ) ) ) {
  2506. continue;
  2507. }
  2508. // Filter out elements in the current dragged item
  2509. for ( j = 0; j < list.length; j++ ) {
  2510. if ( list[ j ] === m[ i ].element[ 0 ] ) {
  2511. m[ i ].proportions().height = 0;
  2512. continue droppablesLoop;
  2513. }
  2514. }
  2515. m[ i ].visible = m[ i ].element.css( "display" ) !== "none";
  2516. if ( !m[ i ].visible ) {
  2517. continue;
  2518. }
  2519. // Activate the droppable if used directly from draggables
  2520. if ( type === "mousedown" ) {
  2521. m[ i ]._activate.call( m[ i ], event );
  2522. }
  2523. m[ i ].offset = m[ i ].element.offset();
  2524. m[ i ].proportions({ width: m[ i ].element[ 0 ].offsetWidth, height: m[ i ].element[ 0 ].offsetHeight });
  2525. }
  2526. },
  2527. drop: function( draggable, event ) {
  2528. var dropped = false;
  2529. // Create a copy of the droppables in case the list changes during the drop (#9116)
  2530. $.each( ( $.ui.ddmanager.droppables[ draggable.options.scope ] || [] ).slice(), function() {
  2531. if ( !this.options ) {
  2532. return;
  2533. }
  2534. if ( !this.options.disabled && this.visible && $.ui.intersect( draggable, this, this.options.tolerance, event ) ) {
  2535. dropped = this._drop.call( this, event ) || dropped;
  2536. }
  2537. if ( !this.options.disabled && this.visible && this.accept.call( this.element[ 0 ], ( draggable.currentItem || draggable.element ) ) ) {
  2538. this.isout = true;
  2539. this.isover = false;
  2540. this._deactivate.call( this, event );
  2541. }
  2542. });
  2543. return dropped;
  2544. },
  2545. dragStart: function( draggable, event ) {
  2546. // Listen for scrolling so that if the dragging causes scrolling the position of the droppables can be recalculated (see #5003)
  2547. draggable.element.parentsUntil( "body" ).bind( "scroll.droppable", function() {
  2548. if ( !draggable.options.refreshPositions ) {
  2549. $.ui.ddmanager.prepareOffsets( draggable, event );
  2550. }
  2551. });
  2552. },
  2553. drag: function( draggable, event ) {
  2554. // If you have a highly dynamic page, you might try this option. It renders positions every time you move the mouse.
  2555. if ( draggable.options.refreshPositions ) {
  2556. $.ui.ddmanager.prepareOffsets( draggable, event );
  2557. }
  2558. // Run through all droppables and check their positions based on specific tolerance options
  2559. $.each( $.ui.ddmanager.droppables[ draggable.options.scope ] || [], function() {
  2560. if ( this.options.disabled || this.greedyChild || !this.visible ) {
  2561. return;
  2562. }
  2563. var parentInstance, scope, parent,
  2564. intersects = $.ui.intersect( draggable, this, this.options.tolerance, event ),
  2565. c = !intersects && this.isover ? "isout" : ( intersects && !this.isover ? "isover" : null );
  2566. if ( !c ) {
  2567. return;
  2568. }
  2569. if ( this.options.greedy ) {
  2570. // find droppable parents with same scope
  2571. scope = this.options.scope;
  2572. parent = this.element.parents( ":data(ui-droppable)" ).filter(function() {
  2573. return $( this ).droppable( "instance" ).options.scope === scope;
  2574. });
  2575. if ( parent.length ) {
  2576. parentInstance = $( parent[ 0 ] ).droppable( "instance" );
  2577. parentInstance.greedyChild = ( c === "isover" );
  2578. }
  2579. }
  2580. // we just moved into a greedy child
  2581. if ( parentInstance && c === "isover" ) {
  2582. parentInstance.isover = false;
  2583. parentInstance.isout = true;
  2584. parentInstance._out.call( parentInstance, event );
  2585. }
  2586. this[ c ] = true;
  2587. this[c === "isout" ? "isover" : "isout"] = false;
  2588. this[c === "isover" ? "_over" : "_out"].call( this, event );
  2589. // we just moved out of a greedy child
  2590. if ( parentInstance && c === "isout" ) {
  2591. parentInstance.isout = false;
  2592. parentInstance.isover = true;
  2593. parentInstance._over.call( parentInstance, event );
  2594. }
  2595. });
  2596. },
  2597. dragStop: function( draggable, event ) {
  2598. draggable.element.parentsUntil( "body" ).unbind( "scroll.droppable" );
  2599. // Call prepareOffsets one final time since IE does not fire return scroll events when overflow was caused by drag (see #5003)
  2600. if ( !draggable.options.refreshPositions ) {
  2601. $.ui.ddmanager.prepareOffsets( draggable, event );
  2602. }
  2603. }
  2604. };
  2605. var droppable = $.ui.droppable;
  2606. /*!
  2607. * jQuery UI Resizable 1.11.4
  2608. * http://jqueryui.com
  2609. *
  2610. * Copyright jQuery Foundation and other contributors
  2611. * Released under the MIT license.
  2612. * http://jquery.org/license
  2613. *
  2614. * http://api.jqueryui.com/resizable/
  2615. */
  2616. $.widget("ui.resizable", $.ui.mouse, {
  2617. version: "1.11.4",
  2618. widgetEventPrefix: "resize",
  2619. options: {
  2620. alsoResize: false,
  2621. animate: false,
  2622. animateDuration: "slow",
  2623. animateEasing: "swing",
  2624. aspectRatio: false,
  2625. autoHide: false,
  2626. containment: false,
  2627. ghost: false,
  2628. grid: false,
  2629. handles: "e,s,se",
  2630. helper: false,
  2631. maxHeight: null,
  2632. maxWidth: null,
  2633. minHeight: 10,
  2634. minWidth: 10,
  2635. // See #7960
  2636. zIndex: 90,
  2637. // callbacks
  2638. resize: null,
  2639. start: null,
  2640. stop: null
  2641. },
  2642. _num: function( value ) {
  2643. return parseInt( value, 10 ) || 0;
  2644. },
  2645. _isNumber: function( value ) {
  2646. return !isNaN( parseInt( value, 10 ) );
  2647. },
  2648. _hasScroll: function( el, a ) {
  2649. if ( $( el ).css( "overflow" ) === "hidden") {
  2650. return false;
  2651. }
  2652. var scroll = ( a && a === "left" ) ? "scrollLeft" : "scrollTop",
  2653. has = false;
  2654. if ( el[ scroll ] > 0 ) {
  2655. return true;
  2656. }
  2657. // TODO: determine which cases actually cause this to happen
  2658. // if the element doesn't have the scroll set, see if it's possible to
  2659. // set the scroll
  2660. el[ scroll ] = 1;
  2661. has = ( el[ scroll ] > 0 );
  2662. el[ scroll ] = 0;
  2663. return has;
  2664. },
  2665. _create: function() {
  2666. var n, i, handle, axis, hname,
  2667. that = this,
  2668. o = this.options;
  2669. this.element.addClass("ui-resizable");
  2670. $.extend(this, {
  2671. _aspectRatio: !!(o.aspectRatio),
  2672. aspectRatio: o.aspectRatio,
  2673. originalElement: this.element,
  2674. _proportionallyResizeElements: [],
  2675. _helper: o.helper || o.ghost || o.animate ? o.helper || "ui-resizable-helper" : null
  2676. });
  2677. // Wrap the element if it cannot hold child nodes
  2678. if (this.element[0].nodeName.match(/^(canvas|textarea|input|select|button|img)$/i)) {
  2679. this.element.wrap(
  2680. $("<div class='ui-wrapper' style='overflow: hidden;'></div>").css({
  2681. position: this.element.css("position"),
  2682. width: this.element.outerWidth(),
  2683. height: this.element.outerHeight(),
  2684. top: this.element.css("top"),
  2685. left: this.element.css("left")
  2686. })
  2687. );
  2688. this.element = this.element.parent().data(
  2689. "ui-resizable", this.element.resizable( "instance" )
  2690. );
  2691. this.elementIsWrapper = true;
  2692. this.element.css({
  2693. marginLeft: this.originalElement.css("marginLeft"),
  2694. marginTop: this.originalElement.css("marginTop"),
  2695. marginRight: this.originalElement.css("marginRight"),
  2696. marginBottom: this.originalElement.css("marginBottom")
  2697. });
  2698. this.originalElement.css({
  2699. marginLeft: 0,
  2700. marginTop: 0,
  2701. marginRight: 0,
  2702. marginBottom: 0
  2703. });
  2704. // support: Safari
  2705. // Prevent Safari textarea resize
  2706. this.originalResizeStyle = this.originalElement.css("resize");
  2707. this.originalElement.css("resize", "none");
  2708. this._proportionallyResizeElements.push( this.originalElement.css({
  2709. position: "static",
  2710. zoom: 1,
  2711. display: "block"
  2712. }) );
  2713. // support: IE9
  2714. // avoid IE jump (hard set the margin)
  2715. this.originalElement.css({ margin: this.originalElement.css("margin") });
  2716. this._proportionallyResize();
  2717. }
  2718. this.handles = o.handles ||
  2719. ( !$(".ui-resizable-handle", this.element).length ?
  2720. "e,s,se" : {
  2721. n: ".ui-resizable-n",
  2722. e: ".ui-resizable-e",
  2723. s: ".ui-resizable-s",
  2724. w: ".ui-resizable-w",
  2725. se: ".ui-resizable-se",
  2726. sw: ".ui-resizable-sw",
  2727. ne: ".ui-resizable-ne",
  2728. nw: ".ui-resizable-nw"
  2729. } );
  2730. this._handles = $();
  2731. if ( this.handles.constructor === String ) {
  2732. if ( this.handles === "all") {
  2733. this.handles = "n,e,s,w,se,sw,ne,nw";
  2734. }
  2735. n = this.handles.split(",");
  2736. this.handles = {};
  2737. for (i = 0; i < n.length; i++) {
  2738. handle = $.trim(n[i]);
  2739. hname = "ui-resizable-" + handle;
  2740. axis = $("<div class='ui-resizable-handle " + hname + "'></div>");
  2741. axis.css({ zIndex: o.zIndex });
  2742. // TODO : What's going on here?
  2743. if ("se" === handle) {
  2744. axis.addClass("ui-icon ui-icon-gripsmall-diagonal-se");
  2745. }
  2746. this.handles[handle] = ".ui-resizable-" + handle;
  2747. this.element.append(axis);
  2748. }
  2749. }
  2750. this._renderAxis = function(target) {
  2751. var i, axis, padPos, padWrapper;
  2752. target = target || this.element;
  2753. for (i in this.handles) {
  2754. if (this.handles[i].constructor === String) {
  2755. this.handles[i] = this.element.children( this.handles[ i ] ).first().show();
  2756. } else if ( this.handles[ i ].jquery || this.handles[ i ].nodeType ) {
  2757. this.handles[ i ] = $( this.handles[ i ] );
  2758. this._on( this.handles[ i ], { "mousedown": that._mouseDown });
  2759. }
  2760. if (this.elementIsWrapper && this.originalElement[0].nodeName.match(/^(textarea|input|select|button)$/i)) {
  2761. axis = $(this.handles[i], this.element);
  2762. padWrapper = /sw|ne|nw|se|n|s/.test(i) ? axis.outerHeight() : axis.outerWidth();
  2763. padPos = [ "padding",
  2764. /ne|nw|n/.test(i) ? "Top" :
  2765. /se|sw|s/.test(i) ? "Bottom" :
  2766. /^e$/.test(i) ? "Right" : "Left" ].join("");
  2767. target.css(padPos, padWrapper);
  2768. this._proportionallyResize();
  2769. }
  2770. this._handles = this._handles.add( this.handles[ i ] );
  2771. }
  2772. };
  2773. // TODO: make renderAxis a prototype function
  2774. this._renderAxis(this.element);
  2775. this._handles = this._handles.add( this.element.find( ".ui-resizable-handle" ) );
  2776. this._handles.disableSelection();
  2777. this._handles.mouseover(function() {
  2778. if (!that.resizing) {
  2779. if (this.className) {
  2780. axis = this.className.match(/ui-resizable-(se|sw|ne|nw|n|e|s|w)/i);
  2781. }
  2782. that.axis = axis && axis[1] ? axis[1] : "se";
  2783. }
  2784. });
  2785. if (o.autoHide) {
  2786. this._handles.hide();
  2787. $(this.element)
  2788. .addClass("ui-resizable-autohide")
  2789. .mouseenter(function() {
  2790. if (o.disabled) {
  2791. return;
  2792. }
  2793. $(this).removeClass("ui-resizable-autohide");
  2794. that._handles.show();
  2795. })
  2796. .mouseleave(function() {
  2797. if (o.disabled) {
  2798. return;
  2799. }
  2800. if (!that.resizing) {
  2801. $(this).addClass("ui-resizable-autohide");
  2802. that._handles.hide();
  2803. }
  2804. });
  2805. }
  2806. this._mouseInit();
  2807. },
  2808. _destroy: function() {
  2809. this._mouseDestroy();
  2810. var wrapper,
  2811. _destroy = function(exp) {
  2812. $(exp)
  2813. .removeClass("ui-resizable ui-resizable-disabled ui-resizable-resizing")
  2814. .removeData("resizable")
  2815. .removeData("ui-resizable")
  2816. .unbind(".resizable")
  2817. .find(".ui-resizable-handle")
  2818. .remove();
  2819. };
  2820. // TODO: Unwrap at same DOM position
  2821. if (this.elementIsWrapper) {
  2822. _destroy(this.element);
  2823. wrapper = this.element;
  2824. this.originalElement.css({
  2825. position: wrapper.css("position"),
  2826. width: wrapper.outerWidth(),
  2827. height: wrapper.outerHeight(),
  2828. top: wrapper.css("top"),
  2829. left: wrapper.css("left")
  2830. }).insertAfter( wrapper );
  2831. wrapper.remove();
  2832. }
  2833. this.originalElement.css("resize", this.originalResizeStyle);
  2834. _destroy(this.originalElement);
  2835. return this;
  2836. },
  2837. _mouseCapture: function(event) {
  2838. var i, handle,
  2839. capture = false;
  2840. for (i in this.handles) {
  2841. handle = $(this.handles[i])[0];
  2842. if (handle === event.target || $.contains(handle, event.target)) {
  2843. capture = true;
  2844. }
  2845. }
  2846. return !this.options.disabled && capture;
  2847. },
  2848. _mouseStart: function(event) {
  2849. var curleft, curtop, cursor,
  2850. o = this.options,
  2851. el = this.element;
  2852. this.resizing = true;
  2853. this._renderProxy();
  2854. curleft = this._num(this.helper.css("left"));
  2855. curtop = this._num(this.helper.css("top"));
  2856. if (o.containment) {
  2857. curleft += $(o.containment).scrollLeft() || 0;
  2858. curtop += $(o.containment).scrollTop() || 0;
  2859. }
  2860. this.offset = this.helper.offset();
  2861. this.position = { left: curleft, top: curtop };
  2862. this.size = this._helper ? {
  2863. width: this.helper.width(),
  2864. height: this.helper.height()
  2865. } : {
  2866. width: el.width(),
  2867. height: el.height()
  2868. };
  2869. this.originalSize = this._helper ? {
  2870. width: el.outerWidth(),
  2871. height: el.outerHeight()
  2872. } : {
  2873. width: el.width(),
  2874. height: el.height()
  2875. };
  2876. this.sizeDiff = {
  2877. width: el.outerWidth() - el.width(),
  2878. height: el.outerHeight() - el.height()
  2879. };
  2880. this.originalPosition = { left: curleft, top: curtop };
  2881. this.originalMousePosition = { left: event.pageX, top: event.pageY };
  2882. this.aspectRatio = (typeof o.aspectRatio === "number") ?
  2883. o.aspectRatio :
  2884. ((this.originalSize.width / this.originalSize.height) || 1);
  2885. cursor = $(".ui-resizable-" + this.axis).css("cursor");
  2886. $("body").css("cursor", cursor === "auto" ? this.axis + "-resize" : cursor);
  2887. el.addClass("ui-resizable-resizing");
  2888. this._propagate("start", event);
  2889. return true;
  2890. },
  2891. _mouseDrag: function(event) {
  2892. var data, props,
  2893. smp = this.originalMousePosition,
  2894. a = this.axis,
  2895. dx = (event.pageX - smp.left) || 0,
  2896. dy = (event.pageY - smp.top) || 0,
  2897. trigger = this._change[a];
  2898. this._updatePrevProperties();
  2899. if (!trigger) {
  2900. return false;
  2901. }
  2902. data = trigger.apply(this, [ event, dx, dy ]);
  2903. this._updateVirtualBoundaries(event.shiftKey);
  2904. if (this._aspectRatio || event.shiftKey) {
  2905. data = this._updateRatio(data, event);
  2906. }
  2907. data = this._respectSize(data, event);
  2908. this._updateCache(data);
  2909. this._propagate("resize", event);
  2910. props = this._applyChanges();
  2911. if ( !this._helper && this._proportionallyResizeElements.length ) {
  2912. this._proportionallyResize();
  2913. }
  2914. if ( !$.isEmptyObject( props ) ) {
  2915. this._updatePrevProperties();
  2916. this._trigger( "resize", event, this.ui() );
  2917. this._applyChanges();
  2918. }
  2919. return false;
  2920. },
  2921. _mouseStop: function(event) {
  2922. this.resizing = false;
  2923. var pr, ista, soffseth, soffsetw, s, left, top,
  2924. o = this.options, that = this;
  2925. if (this._helper) {
  2926. pr = this._proportionallyResizeElements;
  2927. ista = pr.length && (/textarea/i).test(pr[0].nodeName);
  2928. soffseth = ista && this._hasScroll(pr[0], "left") ? 0 : that.sizeDiff.height;
  2929. soffsetw = ista ? 0 : that.sizeDiff.width;
  2930. s = {
  2931. width: (that.helper.width() - soffsetw),
  2932. height: (that.helper.height() - soffseth)
  2933. };
  2934. left = (parseInt(that.element.css("left"), 10) +
  2935. (that.position.left - that.originalPosition.left)) || null;
  2936. top = (parseInt(that.element.css("top"), 10) +
  2937. (that.position.top - that.originalPosition.top)) || null;
  2938. if (!o.animate) {
  2939. this.element.css($.extend(s, { top: top, left: left }));
  2940. }
  2941. that.helper.height(that.size.height);
  2942. that.helper.width(that.size.width);
  2943. if (this._helper && !o.animate) {
  2944. this._proportionallyResize();
  2945. }
  2946. }
  2947. $("body").css("cursor", "auto");
  2948. this.element.removeClass("ui-resizable-resizing");
  2949. this._propagate("stop", event);
  2950. if (this._helper) {
  2951. this.helper.remove();
  2952. }
  2953. return false;
  2954. },
  2955. _updatePrevProperties: function() {
  2956. this.prevPosition = {
  2957. top: this.position.top,
  2958. left: this.position.left
  2959. };
  2960. this.prevSize = {
  2961. width: this.size.width,
  2962. height: this.size.height
  2963. };
  2964. },
  2965. _applyChanges: function() {
  2966. var props = {};
  2967. if ( this.position.top !== this.prevPosition.top ) {
  2968. props.top = this.position.top + "px";
  2969. }
  2970. if ( this.position.left !== this.prevPosition.left ) {
  2971. props.left = this.position.left + "px";
  2972. }
  2973. if ( this.size.width !== this.prevSize.width ) {
  2974. props.width = this.size.width + "px";
  2975. }
  2976. if ( this.size.height !== this.prevSize.height ) {
  2977. props.height = this.size.height + "px";
  2978. }
  2979. this.helper.css( props );
  2980. return props;
  2981. },
  2982. _updateVirtualBoundaries: function(forceAspectRatio) {
  2983. var pMinWidth, pMaxWidth, pMinHeight, pMaxHeight, b,
  2984. o = this.options;
  2985. b = {
  2986. minWidth: this._isNumber(o.minWidth) ? o.minWidth : 0,
  2987. maxWidth: this._isNumber(o.maxWidth) ? o.maxWidth : Infinity,
  2988. minHeight: this._isNumber(o.minHeight) ? o.minHeight : 0,
  2989. maxHeight: this._isNumber(o.maxHeight) ? o.maxHeight : Infinity
  2990. };
  2991. if (this._aspectRatio || forceAspectRatio) {
  2992. pMinWidth = b.minHeight * this.aspectRatio;
  2993. pMinHeight = b.minWidth / this.aspectRatio;
  2994. pMaxWidth = b.maxHeight * this.aspectRatio;
  2995. pMaxHeight = b.maxWidth / this.aspectRatio;
  2996. if (pMinWidth > b.minWidth) {
  2997. b.minWidth = pMinWidth;
  2998. }
  2999. if (pMinHeight > b.minHeight) {
  3000. b.minHeight = pMinHeight;
  3001. }
  3002. if (pMaxWidth < b.maxWidth) {
  3003. b.maxWidth = pMaxWidth;
  3004. }
  3005. if (pMaxHeight < b.maxHeight) {
  3006. b.maxHeight = pMaxHeight;
  3007. }
  3008. }
  3009. this._vBoundaries = b;
  3010. },
  3011. _updateCache: function(data) {
  3012. this.offset = this.helper.offset();
  3013. if (this._isNumber(data.left)) {
  3014. this.position.left = data.left;
  3015. }
  3016. if (this._isNumber(data.top)) {
  3017. this.position.top = data.top;
  3018. }
  3019. if (this._isNumber(data.height)) {
  3020. this.size.height = data.height;
  3021. }
  3022. if (this._isNumber(data.width)) {
  3023. this.size.width = data.width;
  3024. }
  3025. },
  3026. _updateRatio: function( data ) {
  3027. var cpos = this.position,
  3028. csize = this.size,
  3029. a = this.axis;
  3030. if (this._isNumber(data.height)) {
  3031. data.width = (data.height * this.aspectRatio);
  3032. } else if (this._isNumber(data.width)) {
  3033. data.height = (data.width / this.aspectRatio);
  3034. }
  3035. if (a === "sw") {
  3036. data.left = cpos.left + (csize.width - data.width);
  3037. data.top = null;
  3038. }
  3039. if (a === "nw") {
  3040. data.top = cpos.top + (csize.height - data.height);
  3041. data.left = cpos.left + (csize.width - data.width);
  3042. }
  3043. return data;
  3044. },
  3045. _respectSize: function( data ) {
  3046. var o = this._vBoundaries,
  3047. a = this.axis,
  3048. ismaxw = this._isNumber(data.width) && o.maxWidth && (o.maxWidth < data.width),
  3049. ismaxh = this._isNumber(data.height) && o.maxHeight && (o.maxHeight < data.height),
  3050. isminw = this._isNumber(data.width) && o.minWidth && (o.minWidth > data.width),
  3051. isminh = this._isNumber(data.height) && o.minHeight && (o.minHeight > data.height),
  3052. dw = this.originalPosition.left + this.originalSize.width,
  3053. dh = this.position.top + this.size.height,
  3054. cw = /sw|nw|w/.test(a), ch = /nw|ne|n/.test(a);
  3055. if (isminw) {
  3056. data.width = o.minWidth;
  3057. }
  3058. if (isminh) {
  3059. data.height = o.minHeight;
  3060. }
  3061. if (ismaxw) {
  3062. data.width = o.maxWidth;
  3063. }
  3064. if (ismaxh) {
  3065. data.height = o.maxHeight;
  3066. }
  3067. if (isminw && cw) {
  3068. data.left = dw - o.minWidth;
  3069. }
  3070. if (ismaxw && cw) {
  3071. data.left = dw - o.maxWidth;
  3072. }
  3073. if (isminh && ch) {
  3074. data.top = dh - o.minHeight;
  3075. }
  3076. if (ismaxh && ch) {
  3077. data.top = dh - o.maxHeight;
  3078. }
  3079. // Fixing jump error on top/left - bug #2330
  3080. if (!data.width && !data.height && !data.left && data.top) {
  3081. data.top = null;
  3082. } else if (!data.width && !data.height && !data.top && data.left) {
  3083. data.left = null;
  3084. }
  3085. return data;
  3086. },
  3087. _getPaddingPlusBorderDimensions: function( element ) {
  3088. var i = 0,
  3089. widths = [],
  3090. borders = [
  3091. element.css( "borderTopWidth" ),
  3092. element.css( "borderRightWidth" ),
  3093. element.css( "borderBottomWidth" ),
  3094. element.css( "borderLeftWidth" )
  3095. ],
  3096. paddings = [
  3097. element.css( "paddingTop" ),
  3098. element.css( "paddingRight" ),
  3099. element.css( "paddingBottom" ),
  3100. element.css( "paddingLeft" )
  3101. ];
  3102. for ( ; i < 4; i++ ) {
  3103. widths[ i ] = ( parseInt( borders[ i ], 10 ) || 0 );
  3104. widths[ i ] += ( parseInt( paddings[ i ], 10 ) || 0 );
  3105. }
  3106. return {
  3107. height: widths[ 0 ] + widths[ 2 ],
  3108. width: widths[ 1 ] + widths[ 3 ]
  3109. };
  3110. },
  3111. _proportionallyResize: function() {
  3112. if (!this._proportionallyResizeElements.length) {
  3113. return;
  3114. }
  3115. var prel,
  3116. i = 0,
  3117. element = this.helper || this.element;
  3118. for ( ; i < this._proportionallyResizeElements.length; i++) {
  3119. prel = this._proportionallyResizeElements[i];
  3120. // TODO: Seems like a bug to cache this.outerDimensions
  3121. // considering that we are in a loop.
  3122. if (!this.outerDimensions) {
  3123. this.outerDimensions = this._getPaddingPlusBorderDimensions( prel );
  3124. }
  3125. prel.css({
  3126. height: (element.height() - this.outerDimensions.height) || 0,
  3127. width: (element.width() - this.outerDimensions.width) || 0
  3128. });
  3129. }
  3130. },
  3131. _renderProxy: function() {
  3132. var el = this.element, o = this.options;
  3133. this.elementOffset = el.offset();
  3134. if (this._helper) {
  3135. this.helper = this.helper || $("<div style='overflow:hidden;'></div>");
  3136. this.helper.addClass(this._helper).css({
  3137. width: this.element.outerWidth() - 1,
  3138. height: this.element.outerHeight() - 1,
  3139. position: "absolute",
  3140. left: this.elementOffset.left + "px",
  3141. top: this.elementOffset.top + "px",
  3142. zIndex: ++o.zIndex //TODO: Don't modify option
  3143. });
  3144. this.helper
  3145. .appendTo("body")
  3146. .disableSelection();
  3147. } else {
  3148. this.helper = this.element;
  3149. }
  3150. },
  3151. _change: {
  3152. e: function(event, dx) {
  3153. return { width: this.originalSize.width + dx };
  3154. },
  3155. w: function(event, dx) {
  3156. var cs = this.originalSize, sp = this.originalPosition;
  3157. return { left: sp.left + dx, width: cs.width - dx };
  3158. },
  3159. n: function(event, dx, dy) {
  3160. var cs = this.originalSize, sp = this.originalPosition;
  3161. return { top: sp.top + dy, height: cs.height - dy };
  3162. },
  3163. s: function(event, dx, dy) {
  3164. return { height: this.originalSize.height + dy };
  3165. },
  3166. se: function(event, dx, dy) {
  3167. return $.extend(this._change.s.apply(this, arguments),
  3168. this._change.e.apply(this, [ event, dx, dy ]));
  3169. },
  3170. sw: function(event, dx, dy) {
  3171. return $.extend(this._change.s.apply(this, arguments),
  3172. this._change.w.apply(this, [ event, dx, dy ]));
  3173. },
  3174. ne: function(event, dx, dy) {
  3175. return $.extend(this._change.n.apply(this, arguments),
  3176. this._change.e.apply(this, [ event, dx, dy ]));
  3177. },
  3178. nw: function(event, dx, dy) {
  3179. return $.extend(this._change.n.apply(this, arguments),
  3180. this._change.w.apply(this, [ event, dx, dy ]));
  3181. }
  3182. },
  3183. _propagate: function(n, event) {
  3184. $.ui.plugin.call(this, n, [ event, this.ui() ]);
  3185. (n !== "resize" && this._trigger(n, event, this.ui()));
  3186. },
  3187. plugins: {},
  3188. ui: function() {
  3189. return {
  3190. originalElement: this.originalElement,
  3191. element: this.element,
  3192. helper: this.helper,
  3193. position: this.position,
  3194. size: this.size,
  3195. originalSize: this.originalSize,
  3196. originalPosition: this.originalPosition
  3197. };
  3198. }
  3199. });
  3200. /*
  3201. * Resizable Extensions
  3202. */
  3203. $.ui.plugin.add("resizable", "animate", {
  3204. stop: function( event ) {
  3205. var that = $(this).resizable( "instance" ),
  3206. o = that.options,
  3207. pr = that._proportionallyResizeElements,
  3208. ista = pr.length && (/textarea/i).test(pr[0].nodeName),
  3209. soffseth = ista && that._hasScroll(pr[0], "left") ? 0 : that.sizeDiff.height,
  3210. soffsetw = ista ? 0 : that.sizeDiff.width,
  3211. style = { width: (that.size.width - soffsetw), height: (that.size.height - soffseth) },
  3212. left = (parseInt(that.element.css("left"), 10) +
  3213. (that.position.left - that.originalPosition.left)) || null,
  3214. top = (parseInt(that.element.css("top"), 10) +
  3215. (that.position.top - that.originalPosition.top)) || null;
  3216. that.element.animate(
  3217. $.extend(style, top && left ? { top: top, left: left } : {}), {
  3218. duration: o.animateDuration,
  3219. easing: o.animateEasing,
  3220. step: function() {
  3221. var data = {
  3222. width: parseInt(that.element.css("width"), 10),
  3223. height: parseInt(that.element.css("height"), 10),
  3224. top: parseInt(that.element.css("top"), 10),
  3225. left: parseInt(that.element.css("left"), 10)
  3226. };
  3227. if (pr && pr.length) {
  3228. $(pr[0]).css({ width: data.width, height: data.height });
  3229. }
  3230. // propagating resize, and updating values for each animation step
  3231. that._updateCache(data);
  3232. that._propagate("resize", event);
  3233. }
  3234. }
  3235. );
  3236. }
  3237. });
  3238. $.ui.plugin.add( "resizable", "containment", {
  3239. start: function() {
  3240. var element, p, co, ch, cw, width, height,
  3241. that = $( this ).resizable( "instance" ),
  3242. o = that.options,
  3243. el = that.element,
  3244. oc = o.containment,
  3245. ce = ( oc instanceof $ ) ? oc.get( 0 ) : ( /parent/.test( oc ) ) ? el.parent().get( 0 ) : oc;
  3246. if ( !ce ) {
  3247. return;
  3248. }
  3249. that.containerElement = $( ce );
  3250. if ( /document/.test( oc ) || oc === document ) {
  3251. that.containerOffset = {
  3252. left: 0,
  3253. top: 0
  3254. };
  3255. that.containerPosition = {
  3256. left: 0,
  3257. top: 0
  3258. };
  3259. that.parentData = {
  3260. element: $( document ),
  3261. left: 0,
  3262. top: 0,
  3263. width: $( document ).width(),
  3264. height: $( document ).height() || document.body.parentNode.scrollHeight
  3265. };
  3266. } else {
  3267. element = $( ce );
  3268. p = [];
  3269. $([ "Top", "Right", "Left", "Bottom" ]).each(function( i, name ) {
  3270. p[ i ] = that._num( element.css( "padding" + name ) );
  3271. });
  3272. that.containerOffset = element.offset();
  3273. that.containerPosition = element.position();
  3274. that.containerSize = {
  3275. height: ( element.innerHeight() - p[ 3 ] ),
  3276. width: ( element.innerWidth() - p[ 1 ] )
  3277. };
  3278. co = that.containerOffset;
  3279. ch = that.containerSize.height;
  3280. cw = that.containerSize.width;
  3281. width = ( that._hasScroll ( ce, "left" ) ? ce.scrollWidth : cw );
  3282. height = ( that._hasScroll ( ce ) ? ce.scrollHeight : ch ) ;
  3283. that.parentData = {
  3284. element: ce,
  3285. left: co.left,
  3286. top: co.top,
  3287. width: width,
  3288. height: height
  3289. };
  3290. }
  3291. },
  3292. resize: function( event ) {
  3293. var woset, hoset, isParent, isOffsetRelative,
  3294. that = $( this ).resizable( "instance" ),
  3295. o = that.options,
  3296. co = that.containerOffset,
  3297. cp = that.position,
  3298. pRatio = that._aspectRatio || event.shiftKey,
  3299. cop = {
  3300. top: 0,
  3301. left: 0
  3302. },
  3303. ce = that.containerElement,
  3304. continueResize = true;
  3305. if ( ce[ 0 ] !== document && ( /static/ ).test( ce.css( "position" ) ) ) {
  3306. cop = co;
  3307. }
  3308. if ( cp.left < ( that._helper ? co.left : 0 ) ) {
  3309. that.size.width = that.size.width +
  3310. ( that._helper ?
  3311. ( that.position.left - co.left ) :
  3312. ( that.position.left - cop.left ) );
  3313. if ( pRatio ) {
  3314. that.size.height = that.size.width / that.aspectRatio;
  3315. continueResize = false;
  3316. }
  3317. that.position.left = o.helper ? co.left : 0;
  3318. }
  3319. if ( cp.top < ( that._helper ? co.top : 0 ) ) {
  3320. that.size.height = that.size.height +
  3321. ( that._helper ?
  3322. ( that.position.top - co.top ) :
  3323. that.position.top );
  3324. if ( pRatio ) {
  3325. that.size.width = that.size.height * that.aspectRatio;
  3326. continueResize = false;
  3327. }
  3328. that.position.top = that._helper ? co.top : 0;
  3329. }
  3330. isParent = that.containerElement.get( 0 ) === that.element.parent().get( 0 );
  3331. isOffsetRelative = /relative|absolute/.test( that.containerElement.css( "position" ) );
  3332. if ( isParent && isOffsetRelative ) {
  3333. that.offset.left = that.parentData.left + that.position.left;
  3334. that.offset.top = that.parentData.top + that.position.top;
  3335. } else {
  3336. that.offset.left = that.element.offset().left;
  3337. that.offset.top = that.element.offset().top;
  3338. }
  3339. woset = Math.abs( that.sizeDiff.width +
  3340. (that._helper ?
  3341. that.offset.left - cop.left :
  3342. (that.offset.left - co.left)) );
  3343. hoset = Math.abs( that.sizeDiff.height +
  3344. (that._helper ?
  3345. that.offset.top - cop.top :
  3346. (that.offset.top - co.top)) );
  3347. if ( woset + that.size.width >= that.parentData.width ) {
  3348. that.size.width = that.parentData.width - woset;
  3349. if ( pRatio ) {
  3350. that.size.height = that.size.width / that.aspectRatio;
  3351. continueResize = false;
  3352. }
  3353. }
  3354. if ( hoset + that.size.height >= that.parentData.height ) {
  3355. that.size.height = that.parentData.height - hoset;
  3356. if ( pRatio ) {
  3357. that.size.width = that.size.height * that.aspectRatio;
  3358. continueResize = false;
  3359. }
  3360. }
  3361. if ( !continueResize ) {
  3362. that.position.left = that.prevPosition.left;
  3363. that.position.top = that.prevPosition.top;
  3364. that.size.width = that.prevSize.width;
  3365. that.size.height = that.prevSize.height;
  3366. }
  3367. },
  3368. stop: function() {
  3369. var that = $( this ).resizable( "instance" ),
  3370. o = that.options,
  3371. co = that.containerOffset,
  3372. cop = that.containerPosition,
  3373. ce = that.containerElement,
  3374. helper = $( that.helper ),
  3375. ho = helper.offset(),
  3376. w = helper.outerWidth() - that.sizeDiff.width,
  3377. h = helper.outerHeight() - that.sizeDiff.height;
  3378. if ( that._helper && !o.animate && ( /relative/ ).test( ce.css( "position" ) ) ) {
  3379. $( this ).css({
  3380. left: ho.left - cop.left - co.left,
  3381. width: w,
  3382. height: h
  3383. });
  3384. }
  3385. if ( that._helper && !o.animate && ( /static/ ).test( ce.css( "position" ) ) ) {
  3386. $( this ).css({
  3387. left: ho.left - cop.left - co.left,
  3388. width: w,
  3389. height: h
  3390. });
  3391. }
  3392. }
  3393. });
  3394. $.ui.plugin.add("resizable", "alsoResize", {
  3395. start: function() {
  3396. var that = $(this).resizable( "instance" ),
  3397. o = that.options;
  3398. $(o.alsoResize).each(function() {
  3399. var el = $(this);
  3400. el.data("ui-resizable-alsoresize", {
  3401. width: parseInt(el.width(), 10), height: parseInt(el.height(), 10),
  3402. left: parseInt(el.css("left"), 10), top: parseInt(el.css("top"), 10)
  3403. });
  3404. });
  3405. },
  3406. resize: function(event, ui) {
  3407. var that = $(this).resizable( "instance" ),
  3408. o = that.options,
  3409. os = that.originalSize,
  3410. op = that.originalPosition,
  3411. delta = {
  3412. height: (that.size.height - os.height) || 0,
  3413. width: (that.size.width - os.width) || 0,
  3414. top: (that.position.top - op.top) || 0,
  3415. left: (that.position.left - op.left) || 0
  3416. };
  3417. $(o.alsoResize).each(function() {
  3418. var el = $(this), start = $(this).data("ui-resizable-alsoresize"), style = {},
  3419. css = el.parents(ui.originalElement[0]).length ?
  3420. [ "width", "height" ] :
  3421. [ "width", "height", "top", "left" ];
  3422. $.each(css, function(i, prop) {
  3423. var sum = (start[prop] || 0) + (delta[prop] || 0);
  3424. if (sum && sum >= 0) {
  3425. style[prop] = sum || null;
  3426. }
  3427. });
  3428. el.css(style);
  3429. });
  3430. },
  3431. stop: function() {
  3432. $(this).removeData("resizable-alsoresize");
  3433. }
  3434. });
  3435. $.ui.plugin.add("resizable", "ghost", {
  3436. start: function() {
  3437. var that = $(this).resizable( "instance" ), o = that.options, cs = that.size;
  3438. that.ghost = that.originalElement.clone();
  3439. that.ghost
  3440. .css({
  3441. opacity: 0.25,
  3442. display: "block",
  3443. position: "relative",
  3444. height: cs.height,
  3445. width: cs.width,
  3446. margin: 0,
  3447. left: 0,
  3448. top: 0
  3449. })
  3450. .addClass("ui-resizable-ghost")
  3451. .addClass(typeof o.ghost === "string" ? o.ghost : "");
  3452. that.ghost.appendTo(that.helper);
  3453. },
  3454. resize: function() {
  3455. var that = $(this).resizable( "instance" );
  3456. if (that.ghost) {
  3457. that.ghost.css({
  3458. position: "relative",
  3459. height: that.size.height,
  3460. width: that.size.width
  3461. });
  3462. }
  3463. },
  3464. stop: function() {
  3465. var that = $(this).resizable( "instance" );
  3466. if (that.ghost && that.helper) {
  3467. that.helper.get(0).removeChild(that.ghost.get(0));
  3468. }
  3469. }
  3470. });
  3471. $.ui.plugin.add("resizable", "grid", {
  3472. resize: function() {
  3473. var outerDimensions,
  3474. that = $(this).resizable( "instance" ),
  3475. o = that.options,
  3476. cs = that.size,
  3477. os = that.originalSize,
  3478. op = that.originalPosition,
  3479. a = that.axis,
  3480. grid = typeof o.grid === "number" ? [ o.grid, o.grid ] : o.grid,
  3481. gridX = (grid[0] || 1),
  3482. gridY = (grid[1] || 1),
  3483. ox = Math.round((cs.width - os.width) / gridX) * gridX,
  3484. oy = Math.round((cs.height - os.height) / gridY) * gridY,
  3485. newWidth = os.width + ox,
  3486. newHeight = os.height + oy,
  3487. isMaxWidth = o.maxWidth && (o.maxWidth < newWidth),
  3488. isMaxHeight = o.maxHeight && (o.maxHeight < newHeight),
  3489. isMinWidth = o.minWidth && (o.minWidth > newWidth),
  3490. isMinHeight = o.minHeight && (o.minHeight > newHeight);
  3491. o.grid = grid;
  3492. if (isMinWidth) {
  3493. newWidth += gridX;
  3494. }
  3495. if (isMinHeight) {
  3496. newHeight += gridY;
  3497. }
  3498. if (isMaxWidth) {
  3499. newWidth -= gridX;
  3500. }
  3501. if (isMaxHeight) {
  3502. newHeight -= gridY;
  3503. }
  3504. if (/^(se|s|e)$/.test(a)) {
  3505. that.size.width = newWidth;
  3506. that.size.height = newHeight;
  3507. } else if (/^(ne)$/.test(a)) {
  3508. that.size.width = newWidth;
  3509. that.size.height = newHeight;
  3510. that.position.top = op.top - oy;
  3511. } else if (/^(sw)$/.test(a)) {
  3512. that.size.width = newWidth;
  3513. that.size.height = newHeight;
  3514. that.position.left = op.left - ox;
  3515. } else {
  3516. if ( newHeight - gridY <= 0 || newWidth - gridX <= 0) {
  3517. outerDimensions = that._getPaddingPlusBorderDimensions( this );
  3518. }
  3519. if ( newHeight - gridY > 0 ) {
  3520. that.size.height = newHeight;
  3521. that.position.top = op.top - oy;
  3522. } else {
  3523. newHeight = gridY - outerDimensions.height;
  3524. that.size.height = newHeight;
  3525. that.position.top = op.top + os.height - newHeight;
  3526. }
  3527. if ( newWidth - gridX > 0 ) {
  3528. that.size.width = newWidth;
  3529. that.position.left = op.left - ox;
  3530. } else {
  3531. newWidth = gridX - outerDimensions.width;
  3532. that.size.width = newWidth;
  3533. that.position.left = op.left + os.width - newWidth;
  3534. }
  3535. }
  3536. }
  3537. });
  3538. var resizable = $.ui.resizable;
  3539. /*!
  3540. * jQuery UI Menu 1.11.4
  3541. * http://jqueryui.com
  3542. *
  3543. * Copyright jQuery Foundation and other contributors
  3544. * Released under the MIT license.
  3545. * http://jquery.org/license
  3546. *
  3547. * http://api.jqueryui.com/menu/
  3548. */
  3549. var menu = $.widget( "ui.menu", {
  3550. version: "1.11.4",
  3551. defaultElement: "<ul>",
  3552. delay: 300,
  3553. options: {
  3554. icons: {
  3555. submenu: "ui-icon-carat-1-e"
  3556. },
  3557. items: "> *",
  3558. menus: "ul",
  3559. position: {
  3560. my: "left-1 top",
  3561. at: "right top"
  3562. },
  3563. role: "menu",
  3564. // callbacks
  3565. blur: null,
  3566. focus: null,
  3567. select: null
  3568. },
  3569. _create: function() {
  3570. this.activeMenu = this.element;
  3571. // Flag used to prevent firing of the click handler
  3572. // as the event bubbles up through nested menus
  3573. this.mouseHandled = false;
  3574. this.element
  3575. .uniqueId()
  3576. .addClass( "ui-menu ui-widget ui-widget-content" )
  3577. .toggleClass( "ui-menu-icons", !!this.element.find( ".ui-icon" ).length )
  3578. .attr({
  3579. role: this.options.role,
  3580. tabIndex: 0
  3581. });
  3582. if ( this.options.disabled ) {
  3583. this.element
  3584. .addClass( "ui-state-disabled" )
  3585. .attr( "aria-disabled", "true" );
  3586. }
  3587. this._on({
  3588. // Prevent focus from sticking to links inside menu after clicking
  3589. // them (focus should always stay on UL during navigation).
  3590. "mousedown .ui-menu-item": function( event ) {
  3591. event.preventDefault();
  3592. },
  3593. "click .ui-menu-item": function( event ) {
  3594. var target = $( event.target );
  3595. if ( !this.mouseHandled && target.not( ".ui-state-disabled" ).length ) {
  3596. this.select( event );
  3597. // Only set the mouseHandled flag if the event will bubble, see #9469.
  3598. if ( !event.isPropagationStopped() ) {
  3599. this.mouseHandled = true;
  3600. }
  3601. // Open submenu on click
  3602. if ( target.has( ".ui-menu" ).length ) {
  3603. this.expand( event );
  3604. } else if ( !this.element.is( ":focus" ) && $( this.document[ 0 ].activeElement ).closest( ".ui-menu" ).length ) {
  3605. // Redirect focus to the menu
  3606. this.element.trigger( "focus", [ true ] );
  3607. // If the active item is on the top level, let it stay active.
  3608. // Otherwise, blur the active item since it is no longer visible.
  3609. if ( this.active && this.active.parents( ".ui-menu" ).length === 1 ) {
  3610. clearTimeout( this.timer );
  3611. }
  3612. }
  3613. }
  3614. },
  3615. "mouseenter .ui-menu-item": function( event ) {
  3616. // Ignore mouse events while typeahead is active, see #10458.
  3617. // Prevents focusing the wrong item when typeahead causes a scroll while the mouse
  3618. // is over an item in the menu
  3619. if ( this.previousFilter ) {
  3620. return;
  3621. }
  3622. var target = $( event.currentTarget );
  3623. // Remove ui-state-active class from siblings of the newly focused menu item
  3624. // to avoid a jump caused by adjacent elements both having a class with a border
  3625. target.siblings( ".ui-state-active" ).removeClass( "ui-state-active" );
  3626. this.focus( event, target );
  3627. },
  3628. mouseleave: "collapseAll",
  3629. "mouseleave .ui-menu": "collapseAll",
  3630. focus: function( event, keepActiveItem ) {
  3631. // If there's already an active item, keep it active
  3632. // If not, activate the first item
  3633. var item = this.active || this.element.find( this.options.items ).eq( 0 );
  3634. if ( !keepActiveItem ) {
  3635. this.focus( event, item );
  3636. }
  3637. },
  3638. blur: function( event ) {
  3639. this._delay(function() {
  3640. if ( !$.contains( this.element[0], this.document[0].activeElement ) ) {
  3641. this.collapseAll( event );
  3642. }
  3643. });
  3644. },
  3645. keydown: "_keydown"
  3646. });
  3647. this.refresh();
  3648. // Clicks outside of a menu collapse any open menus
  3649. this._on( this.document, {
  3650. click: function( event ) {
  3651. if ( this._closeOnDocumentClick( event ) ) {
  3652. this.collapseAll( event );
  3653. }
  3654. // Reset the mouseHandled flag
  3655. this.mouseHandled = false;
  3656. }
  3657. });
  3658. },
  3659. _destroy: function() {
  3660. // Destroy (sub)menus
  3661. this.element
  3662. .removeAttr( "aria-activedescendant" )
  3663. .find( ".ui-menu" ).addBack()
  3664. .removeClass( "ui-menu ui-widget ui-widget-content ui-menu-icons ui-front" )
  3665. .removeAttr( "role" )
  3666. .removeAttr( "tabIndex" )
  3667. .removeAttr( "aria-labelledby" )
  3668. .removeAttr( "aria-expanded" )
  3669. .removeAttr( "aria-hidden" )
  3670. .removeAttr( "aria-disabled" )
  3671. .removeUniqueId()
  3672. .show();
  3673. // Destroy menu items
  3674. this.element.find( ".ui-menu-item" )
  3675. .removeClass( "ui-menu-item" )
  3676. .removeAttr( "role" )
  3677. .removeAttr( "aria-disabled" )
  3678. .removeUniqueId()
  3679. .removeClass( "ui-state-hover" )
  3680. .removeAttr( "tabIndex" )
  3681. .removeAttr( "role" )
  3682. .removeAttr( "aria-haspopup" )
  3683. .children().each( function() {
  3684. var elem = $( this );
  3685. if ( elem.data( "ui-menu-submenu-carat" ) ) {
  3686. elem.remove();
  3687. }
  3688. });
  3689. // Destroy menu dividers
  3690. this.element.find( ".ui-menu-divider" ).removeClass( "ui-menu-divider ui-widget-content" );
  3691. },
  3692. _keydown: function( event ) {
  3693. var match, prev, character, skip,
  3694. preventDefault = true;
  3695. switch ( event.keyCode ) {
  3696. case $.ui.keyCode.PAGE_UP:
  3697. this.previousPage( event );
  3698. break;
  3699. case $.ui.keyCode.PAGE_DOWN:
  3700. this.nextPage( event );
  3701. break;
  3702. case $.ui.keyCode.HOME:
  3703. this._move( "first", "first", event );
  3704. break;
  3705. case $.ui.keyCode.END:
  3706. this._move( "last", "last", event );
  3707. break;
  3708. case $.ui.keyCode.UP:
  3709. this.previous( event );
  3710. break;
  3711. case $.ui.keyCode.DOWN:
  3712. this.next( event );
  3713. break;
  3714. case $.ui.keyCode.LEFT:
  3715. this.collapse( event );
  3716. break;
  3717. case $.ui.keyCode.RIGHT:
  3718. if ( this.active && !this.active.is( ".ui-state-disabled" ) ) {
  3719. this.expand( event );
  3720. }
  3721. break;
  3722. case $.ui.keyCode.ENTER:
  3723. case $.ui.keyCode.SPACE:
  3724. this._activate( event );
  3725. break;
  3726. case $.ui.keyCode.ESCAPE:
  3727. this.collapse( event );
  3728. break;
  3729. default:
  3730. preventDefault = false;
  3731. prev = this.previousFilter || "";
  3732. character = String.fromCharCode( event.keyCode );
  3733. skip = false;
  3734. clearTimeout( this.filterTimer );
  3735. if ( character === prev ) {
  3736. skip = true;
  3737. } else {
  3738. character = prev + character;
  3739. }
  3740. match = this._filterMenuItems( character );
  3741. match = skip && match.index( this.active.next() ) !== -1 ?
  3742. this.active.nextAll( ".ui-menu-item" ) :
  3743. match;
  3744. // If no matches on the current filter, reset to the last character pressed
  3745. // to move down the menu to the first item that starts with that character
  3746. if ( !match.length ) {
  3747. character = String.fromCharCode( event.keyCode );
  3748. match = this._filterMenuItems( character );
  3749. }
  3750. if ( match.length ) {
  3751. this.focus( event, match );
  3752. this.previousFilter = character;
  3753. this.filterTimer = this._delay(function() {
  3754. delete this.previousFilter;
  3755. }, 1000 );
  3756. } else {
  3757. delete this.previousFilter;
  3758. }
  3759. }
  3760. if ( preventDefault ) {
  3761. event.preventDefault();
  3762. }
  3763. },
  3764. _activate: function( event ) {
  3765. if ( !this.active.is( ".ui-state-disabled" ) ) {
  3766. if ( this.active.is( "[aria-haspopup='true']" ) ) {
  3767. this.expand( event );
  3768. } else {
  3769. this.select( event );
  3770. }
  3771. }
  3772. },
  3773. refresh: function() {
  3774. var menus, items,
  3775. that = this,
  3776. icon = this.options.icons.submenu,
  3777. submenus = this.element.find( this.options.menus );
  3778. this.element.toggleClass( "ui-menu-icons", !!this.element.find( ".ui-icon" ).length );
  3779. // Initialize nested menus
  3780. submenus.filter( ":not(.ui-menu)" )
  3781. .addClass( "ui-menu ui-widget ui-widget-content ui-front" )
  3782. .hide()
  3783. .attr({
  3784. role: this.options.role,
  3785. "aria-hidden": "true",
  3786. "aria-expanded": "false"
  3787. })
  3788. .each(function() {
  3789. var menu = $( this ),
  3790. item = menu.parent(),
  3791. submenuCarat = $( "<span>" )
  3792. .addClass( "ui-menu-icon ui-icon " + icon )
  3793. .data( "ui-menu-submenu-carat", true );
  3794. item
  3795. .attr( "aria-haspopup", "true" )
  3796. .prepend( submenuCarat );
  3797. menu.attr( "aria-labelledby", item.attr( "id" ) );
  3798. });
  3799. menus = submenus.add( this.element );
  3800. items = menus.find( this.options.items );
  3801. // Initialize menu-items containing spaces and/or dashes only as dividers
  3802. items.not( ".ui-menu-item" ).each(function() {
  3803. var item = $( this );
  3804. if ( that._isDivider( item ) ) {
  3805. item.addClass( "ui-widget-content ui-menu-divider" );
  3806. }
  3807. });
  3808. // Don't refresh list items that are already adapted
  3809. items.not( ".ui-menu-item, .ui-menu-divider" )
  3810. .addClass( "ui-menu-item" )
  3811. .uniqueId()
  3812. .attr({
  3813. tabIndex: -1,
  3814. role: this._itemRole()
  3815. });
  3816. // Add aria-disabled attribute to any disabled menu item
  3817. items.filter( ".ui-state-disabled" ).attr( "aria-disabled", "true" );
  3818. // If the active item has been removed, blur the menu
  3819. if ( this.active && !$.contains( this.element[ 0 ], this.active[ 0 ] ) ) {
  3820. this.blur();
  3821. }
  3822. },
  3823. _itemRole: function() {
  3824. return {
  3825. menu: "menuitem",
  3826. listbox: "option"
  3827. }[ this.options.role ];
  3828. },
  3829. _setOption: function( key, value ) {
  3830. if ( key === "icons" ) {
  3831. this.element.find( ".ui-menu-icon" )
  3832. .removeClass( this.options.icons.submenu )
  3833. .addClass( value.submenu );
  3834. }
  3835. if ( key === "disabled" ) {
  3836. this.element
  3837. .toggleClass( "ui-state-disabled", !!value )
  3838. .attr( "aria-disabled", value );
  3839. }
  3840. this._super( key, value );
  3841. },
  3842. focus: function( event, item ) {
  3843. var nested, focused;
  3844. this.blur( event, event && event.type === "focus" );
  3845. this._scrollIntoView( item );
  3846. this.active = item.first();
  3847. focused = this.active.addClass( "ui-state-focus" ).removeClass( "ui-state-active" );
  3848. // Only update aria-activedescendant if there's a role
  3849. // otherwise we assume focus is managed elsewhere
  3850. if ( this.options.role ) {
  3851. this.element.attr( "aria-activedescendant", focused.attr( "id" ) );
  3852. }
  3853. // Highlight active parent menu item, if any
  3854. this.active
  3855. .parent()
  3856. .closest( ".ui-menu-item" )
  3857. .addClass( "ui-state-active" );
  3858. if ( event && event.type === "keydown" ) {
  3859. this._close();
  3860. } else {
  3861. this.timer = this._delay(function() {
  3862. this._close();
  3863. }, this.delay );
  3864. }
  3865. nested = item.children( ".ui-menu" );
  3866. if ( nested.length && event && ( /^mouse/.test( event.type ) ) ) {
  3867. this._startOpening(nested);
  3868. }
  3869. this.activeMenu = item.parent();
  3870. this._trigger( "focus", event, { item: item } );
  3871. },
  3872. _scrollIntoView: function( item ) {
  3873. var borderTop, paddingTop, offset, scroll, elementHeight, itemHeight;
  3874. if ( this._hasScroll() ) {
  3875. borderTop = parseFloat( $.css( this.activeMenu[0], "borderTopWidth" ) ) || 0;
  3876. paddingTop = parseFloat( $.css( this.activeMenu[0], "paddingTop" ) ) || 0;
  3877. offset = item.offset().top - this.activeMenu.offset().top - borderTop - paddingTop;
  3878. scroll = this.activeMenu.scrollTop();
  3879. elementHeight = this.activeMenu.height();
  3880. itemHeight = item.outerHeight();
  3881. if ( offset < 0 ) {
  3882. this.activeMenu.scrollTop( scroll + offset );
  3883. } else if ( offset + itemHeight > elementHeight ) {
  3884. this.activeMenu.scrollTop( scroll + offset - elementHeight + itemHeight );
  3885. }
  3886. }
  3887. },
  3888. blur: function( event, fromFocus ) {
  3889. if ( !fromFocus ) {
  3890. clearTimeout( this.timer );
  3891. }
  3892. if ( !this.active ) {
  3893. return;
  3894. }
  3895. this.active.removeClass( "ui-state-focus" );
  3896. this.active = null;
  3897. this._trigger( "blur", event, { item: this.active } );
  3898. },
  3899. _startOpening: function( submenu ) {
  3900. clearTimeout( this.timer );
  3901. // Don't open if already open fixes a Firefox bug that caused a .5 pixel
  3902. // shift in the submenu position when mousing over the carat icon
  3903. if ( submenu.attr( "aria-hidden" ) !== "true" ) {
  3904. return;
  3905. }
  3906. this.timer = this._delay(function() {
  3907. this._close();
  3908. this._open( submenu );
  3909. }, this.delay );
  3910. },
  3911. _open: function( submenu ) {
  3912. var position = $.extend({
  3913. of: this.active
  3914. }, this.options.position );
  3915. clearTimeout( this.timer );
  3916. this.element.find( ".ui-menu" ).not( submenu.parents( ".ui-menu" ) )
  3917. .hide()
  3918. .attr( "aria-hidden", "true" );
  3919. submenu
  3920. .show()
  3921. .removeAttr( "aria-hidden" )
  3922. .attr( "aria-expanded", "true" )
  3923. .position( position );
  3924. },
  3925. collapseAll: function( event, all ) {
  3926. clearTimeout( this.timer );
  3927. this.timer = this._delay(function() {
  3928. // If we were passed an event, look for the submenu that contains the event
  3929. var currentMenu = all ? this.element :
  3930. $( event && event.target ).closest( this.element.find( ".ui-menu" ) );
  3931. // If we found no valid submenu ancestor, use the main menu to close all sub menus anyway
  3932. if ( !currentMenu.length ) {
  3933. currentMenu = this.element;
  3934. }
  3935. this._close( currentMenu );
  3936. this.blur( event );
  3937. this.activeMenu = currentMenu;
  3938. }, this.delay );
  3939. },
  3940. // With no arguments, closes the currently active menu - if nothing is active
  3941. // it closes all menus. If passed an argument, it will search for menus BELOW
  3942. _close: function( startMenu ) {
  3943. if ( !startMenu ) {
  3944. startMenu = this.active ? this.active.parent() : this.element;
  3945. }
  3946. startMenu
  3947. .find( ".ui-menu" )
  3948. .hide()
  3949. .attr( "aria-hidden", "true" )
  3950. .attr( "aria-expanded", "false" )
  3951. .end()
  3952. .find( ".ui-state-active" ).not( ".ui-state-focus" )
  3953. .removeClass( "ui-state-active" );
  3954. },
  3955. _closeOnDocumentClick: function( event ) {
  3956. return !$( event.target ).closest( ".ui-menu" ).length;
  3957. },
  3958. _isDivider: function( item ) {
  3959. // Match hyphen, em dash, en dash
  3960. return !/[^\-\u2014\u2013\s]/.test( item.text() );
  3961. },
  3962. collapse: function( event ) {
  3963. var newItem = this.active &&
  3964. this.active.parent().closest( ".ui-menu-item", this.element );
  3965. if ( newItem && newItem.length ) {
  3966. this._close();
  3967. this.focus( event, newItem );
  3968. }
  3969. },
  3970. expand: function( event ) {
  3971. var newItem = this.active &&
  3972. this.active
  3973. .children( ".ui-menu " )
  3974. .find( this.options.items )
  3975. .first();
  3976. if ( newItem && newItem.length ) {
  3977. this._open( newItem.parent() );
  3978. // Delay so Firefox will not hide activedescendant change in expanding submenu from AT
  3979. this._delay(function() {
  3980. this.focus( event, newItem );
  3981. });
  3982. }
  3983. },
  3984. next: function( event ) {
  3985. this._move( "next", "first", event );
  3986. },
  3987. previous: function( event ) {
  3988. this._move( "prev", "last", event );
  3989. },
  3990. isFirstItem: function() {
  3991. return this.active && !this.active.prevAll( ".ui-menu-item" ).length;
  3992. },
  3993. isLastItem: function() {
  3994. return this.active && !this.active.nextAll( ".ui-menu-item" ).length;
  3995. },
  3996. _move: function( direction, filter, event ) {
  3997. var next;
  3998. if ( this.active ) {
  3999. if ( direction === "first" || direction === "last" ) {
  4000. next = this.active
  4001. [ direction === "first" ? "prevAll" : "nextAll" ]( ".ui-menu-item" )
  4002. .eq( -1 );
  4003. } else {
  4004. next = this.active
  4005. [ direction + "All" ]( ".ui-menu-item" )
  4006. .eq( 0 );
  4007. }
  4008. }
  4009. if ( !next || !next.length || !this.active ) {
  4010. next = this.activeMenu.find( this.options.items )[ filter ]();
  4011. }
  4012. this.focus( event, next );
  4013. },
  4014. nextPage: function( event ) {
  4015. var item, base, height;
  4016. if ( !this.active ) {
  4017. this.next( event );
  4018. return;
  4019. }
  4020. if ( this.isLastItem() ) {
  4021. return;
  4022. }
  4023. if ( this._hasScroll() ) {
  4024. base = this.active.offset().top;
  4025. height = this.element.height();
  4026. this.active.nextAll( ".ui-menu-item" ).each(function() {
  4027. item = $( this );
  4028. return item.offset().top - base - height < 0;
  4029. });
  4030. this.focus( event, item );
  4031. } else {
  4032. this.focus( event, this.activeMenu.find( this.options.items )
  4033. [ !this.active ? "first" : "last" ]() );
  4034. }
  4035. },
  4036. previousPage: function( event ) {
  4037. var item, base, height;
  4038. if ( !this.active ) {
  4039. this.next( event );
  4040. return;
  4041. }
  4042. if ( this.isFirstItem() ) {
  4043. return;
  4044. }
  4045. if ( this._hasScroll() ) {
  4046. base = this.active.offset().top;
  4047. height = this.element.height();
  4048. this.active.prevAll( ".ui-menu-item" ).each(function() {
  4049. item = $( this );
  4050. return item.offset().top - base + height > 0;
  4051. });
  4052. this.focus( event, item );
  4053. } else {
  4054. this.focus( event, this.activeMenu.find( this.options.items ).first() );
  4055. }
  4056. },
  4057. _hasScroll: function() {
  4058. return this.element.outerHeight() < this.element.prop( "scrollHeight" );
  4059. },
  4060. select: function( event ) {
  4061. // TODO: It should never be possible to not have an active item at this
  4062. // point, but the tests don't trigger mouseenter before click.
  4063. this.active = this.active || $( event.target ).closest( ".ui-menu-item" );
  4064. var ui = { item: this.active };
  4065. if ( !this.active.has( ".ui-menu" ).length ) {
  4066. this.collapseAll( event, true );
  4067. }
  4068. this._trigger( "select", event, ui );
  4069. },
  4070. _filterMenuItems: function(character) {
  4071. var escapedCharacter = character.replace( /[\-\[\]{}()*+?.,\\\^$|#\s]/g, "\\$&" ),
  4072. regex = new RegExp( "^" + escapedCharacter, "i" );
  4073. return this.activeMenu
  4074. .find( this.options.items )
  4075. // Only match on items, not dividers or other content (#10571)
  4076. .filter( ".ui-menu-item" )
  4077. .filter(function() {
  4078. return regex.test( $.trim( $( this ).text() ) );
  4079. });
  4080. }
  4081. });
  4082. /*!
  4083. * jQuery UI Autocomplete 1.11.4
  4084. * http://jqueryui.com
  4085. *
  4086. * Copyright jQuery Foundation and other contributors
  4087. * Released under the MIT license.
  4088. * http://jquery.org/license
  4089. *
  4090. * http://api.jqueryui.com/autocomplete/
  4091. */
  4092. $.widget( "ui.autocomplete", {
  4093. version: "1.11.4",
  4094. defaultElement: "<input>",
  4095. options: {
  4096. appendTo: null,
  4097. autoFocus: false,
  4098. delay: 300,
  4099. minLength: 1,
  4100. position: {
  4101. my: "left top",
  4102. at: "left bottom",
  4103. collision: "none"
  4104. },
  4105. source: null,
  4106. // callbacks
  4107. change: null,
  4108. close: null,
  4109. focus: null,
  4110. open: null,
  4111. response: null,
  4112. search: null,
  4113. select: null
  4114. },
  4115. requestIndex: 0,
  4116. pending: 0,
  4117. _create: function() {
  4118. // Some browsers only repeat keydown events, not keypress events,
  4119. // so we use the suppressKeyPress flag to determine if we've already
  4120. // handled the keydown event. #7269
  4121. // Unfortunately the code for & in keypress is the same as the up arrow,
  4122. // so we use the suppressKeyPressRepeat flag to avoid handling keypress
  4123. // events when we know the keydown event was used to modify the
  4124. // search term. #7799
  4125. var suppressKeyPress, suppressKeyPressRepeat, suppressInput,
  4126. nodeName = this.element[ 0 ].nodeName.toLowerCase(),
  4127. isTextarea = nodeName === "textarea",
  4128. isInput = nodeName === "input";
  4129. this.isMultiLine =
  4130. // Textareas are always multi-line
  4131. isTextarea ? true :
  4132. // Inputs are always single-line, even if inside a contentEditable element
  4133. // IE also treats inputs as contentEditable
  4134. isInput ? false :
  4135. // All other element types are determined by whether or not they're contentEditable
  4136. this.element.prop( "isContentEditable" );
  4137. this.valueMethod = this.element[ isTextarea || isInput ? "val" : "text" ];
  4138. this.isNewMenu = true;
  4139. this.element
  4140. .addClass( "ui-autocomplete-input" )
  4141. .attr( "autocomplete", "off" );
  4142. this._on( this.element, {
  4143. keydown: function( event ) {
  4144. if ( this.element.prop( "readOnly" ) ) {
  4145. suppressKeyPress = true;
  4146. suppressInput = true;
  4147. suppressKeyPressRepeat = true;
  4148. return;
  4149. }
  4150. suppressKeyPress = false;
  4151. suppressInput = false;
  4152. suppressKeyPressRepeat = false;
  4153. var keyCode = $.ui.keyCode;
  4154. switch ( event.keyCode ) {
  4155. case keyCode.PAGE_UP:
  4156. suppressKeyPress = true;
  4157. this._move( "previousPage", event );
  4158. break;
  4159. case keyCode.PAGE_DOWN:
  4160. suppressKeyPress = true;
  4161. this._move( "nextPage", event );
  4162. break;
  4163. case keyCode.UP:
  4164. suppressKeyPress = true;
  4165. this._keyEvent( "previous", event );
  4166. break;
  4167. case keyCode.DOWN:
  4168. suppressKeyPress = true;
  4169. this._keyEvent( "next", event );
  4170. break;
  4171. case keyCode.ENTER:
  4172. // when menu is open and has focus
  4173. if ( this.menu.active ) {
  4174. // #6055 - Opera still allows the keypress to occur
  4175. // which causes forms to submit
  4176. suppressKeyPress = true;
  4177. event.preventDefault();
  4178. this.menu.select( event );
  4179. }
  4180. break;
  4181. case keyCode.TAB:
  4182. if ( this.menu.active ) {
  4183. this.menu.select( event );
  4184. }
  4185. break;
  4186. case keyCode.ESCAPE:
  4187. if ( this.menu.element.is( ":visible" ) ) {
  4188. if ( !this.isMultiLine ) {
  4189. this._value( this.term );
  4190. }
  4191. this.close( event );
  4192. // Different browsers have different default behavior for escape
  4193. // Single press can mean undo or clear
  4194. // Double press in IE means clear the whole form
  4195. event.preventDefault();
  4196. }
  4197. break;
  4198. default:
  4199. suppressKeyPressRepeat = true;
  4200. // search timeout should be triggered before the input value is changed
  4201. this._searchTimeout( event );
  4202. break;
  4203. }
  4204. },
  4205. keypress: function( event ) {
  4206. if ( suppressKeyPress ) {
  4207. suppressKeyPress = false;
  4208. if ( !this.isMultiLine || this.menu.element.is( ":visible" ) ) {
  4209. event.preventDefault();
  4210. }
  4211. return;
  4212. }
  4213. if ( suppressKeyPressRepeat ) {
  4214. return;
  4215. }
  4216. // replicate some key handlers to allow them to repeat in Firefox and Opera
  4217. var keyCode = $.ui.keyCode;
  4218. switch ( event.keyCode ) {
  4219. case keyCode.PAGE_UP:
  4220. this._move( "previousPage", event );
  4221. break;
  4222. case keyCode.PAGE_DOWN:
  4223. this._move( "nextPage", event );
  4224. break;
  4225. case keyCode.UP:
  4226. this._keyEvent( "previous", event );
  4227. break;
  4228. case keyCode.DOWN:
  4229. this._keyEvent( "next", event );
  4230. break;
  4231. }
  4232. },
  4233. input: function( event ) {
  4234. if ( suppressInput ) {
  4235. suppressInput = false;
  4236. event.preventDefault();
  4237. return;
  4238. }
  4239. this._searchTimeout( event );
  4240. },
  4241. focus: function() {
  4242. this.selectedItem = null;
  4243. this.previous = this._value();
  4244. },
  4245. blur: function( event ) {
  4246. if ( this.cancelBlur ) {
  4247. delete this.cancelBlur;
  4248. return;
  4249. }
  4250. clearTimeout( this.searching );
  4251. this.close( event );
  4252. this._change( event );
  4253. }
  4254. });
  4255. this._initSource();
  4256. this.menu = $( "<ul>" )
  4257. .addClass( "ui-autocomplete ui-front" )
  4258. .appendTo( this._appendTo() )
  4259. .menu({
  4260. // disable ARIA support, the live region takes care of that
  4261. role: null
  4262. })
  4263. .hide()
  4264. .menu( "instance" );
  4265. this._on( this.menu.element, {
  4266. mousedown: function( event ) {
  4267. // prevent moving focus out of the text field
  4268. event.preventDefault();
  4269. // IE doesn't prevent moving focus even with event.preventDefault()
  4270. // so we set a flag to know when we should ignore the blur event
  4271. this.cancelBlur = true;
  4272. this._delay(function() {
  4273. delete this.cancelBlur;
  4274. });
  4275. // clicking on the scrollbar causes focus to shift to the body
  4276. // but we can't detect a mouseup or a click immediately afterward
  4277. // so we have to track the next mousedown and close the menu if
  4278. // the user clicks somewhere outside of the autocomplete
  4279. var menuElement = this.menu.element[ 0 ];
  4280. if ( !$( event.target ).closest( ".ui-menu-item" ).length ) {
  4281. this._delay(function() {
  4282. var that = this;
  4283. this.document.one( "mousedown", function( event ) {
  4284. if ( event.target !== that.element[ 0 ] &&
  4285. event.target !== menuElement &&
  4286. !$.contains( menuElement, event.target ) ) {
  4287. that.close();
  4288. }
  4289. });
  4290. });
  4291. }
  4292. },
  4293. menufocus: function( event, ui ) {
  4294. var label, item;
  4295. // support: Firefox
  4296. // Prevent accidental activation of menu items in Firefox (#7024 #9118)
  4297. if ( this.isNewMenu ) {
  4298. this.isNewMenu = false;
  4299. if ( event.originalEvent && /^mouse/.test( event.originalEvent.type ) ) {
  4300. this.menu.blur();
  4301. this.document.one( "mousemove", function() {
  4302. $( event.target ).trigger( event.originalEvent );
  4303. });
  4304. return;
  4305. }
  4306. }
  4307. item = ui.item.data( "ui-autocomplete-item" );
  4308. if ( false !== this._trigger( "focus", event, { item: item } ) ) {
  4309. // use value to match what will end up in the input, if it was a key event
  4310. if ( event.originalEvent && /^key/.test( event.originalEvent.type ) ) {
  4311. this._value( item.value );
  4312. }
  4313. }
  4314. // Announce the value in the liveRegion
  4315. label = ui.item.attr( "aria-label" ) || item.value;
  4316. if ( label && $.trim( label ).length ) {
  4317. this.liveRegion.children().hide();
  4318. $( "<div>" ).text( label ).appendTo( this.liveRegion );
  4319. }
  4320. },
  4321. menuselect: function( event, ui ) {
  4322. var item = ui.item.data( "ui-autocomplete-item" ),
  4323. previous = this.previous;
  4324. // only trigger when focus was lost (click on menu)
  4325. if ( this.element[ 0 ] !== this.document[ 0 ].activeElement ) {
  4326. this.element.focus();
  4327. this.previous = previous;
  4328. // #6109 - IE triggers two focus events and the second
  4329. // is asynchronous, so we need to reset the previous
  4330. // term synchronously and asynchronously :-(
  4331. this._delay(function() {
  4332. this.previous = previous;
  4333. this.selectedItem = item;
  4334. });
  4335. }
  4336. if ( false !== this._trigger( "select", event, { item: item } ) ) {
  4337. this._value( item.value );
  4338. }
  4339. // reset the term after the select event
  4340. // this allows custom select handling to work properly
  4341. this.term = this._value();
  4342. this.close( event );
  4343. this.selectedItem = item;
  4344. }
  4345. });
  4346. this.liveRegion = $( "<span>", {
  4347. role: "status",
  4348. "aria-live": "assertive",
  4349. "aria-relevant": "additions"
  4350. })
  4351. .addClass( "ui-helper-hidden-accessible" )
  4352. .appendTo( this.document[ 0 ].body );
  4353. // turning off autocomplete prevents the browser from remembering the
  4354. // value when navigating through history, so we re-enable autocomplete
  4355. // if the page is unloaded before the widget is destroyed. #7790
  4356. this._on( this.window, {
  4357. beforeunload: function() {
  4358. this.element.removeAttr( "autocomplete" );
  4359. }
  4360. });
  4361. },
  4362. _destroy: function() {
  4363. clearTimeout( this.searching );
  4364. this.element
  4365. .removeClass( "ui-autocomplete-input" )
  4366. .removeAttr( "autocomplete" );
  4367. this.menu.element.remove();
  4368. this.liveRegion.remove();
  4369. },
  4370. _setOption: function( key, value ) {
  4371. this._super( key, value );
  4372. if ( key === "source" ) {
  4373. this._initSource();
  4374. }
  4375. if ( key === "appendTo" ) {
  4376. this.menu.element.appendTo( this._appendTo() );
  4377. }
  4378. if ( key === "disabled" && value && this.xhr ) {
  4379. this.xhr.abort();
  4380. }
  4381. },
  4382. _appendTo: function() {
  4383. var element = this.options.appendTo;
  4384. if ( element ) {
  4385. element = element.jquery || element.nodeType ?
  4386. $( element ) :
  4387. this.document.find( element ).eq( 0 );
  4388. }
  4389. if ( !element || !element[ 0 ] ) {
  4390. element = this.element.closest( ".ui-front" );
  4391. }
  4392. if ( !element.length ) {
  4393. element = this.document[ 0 ].body;
  4394. }
  4395. return element;
  4396. },
  4397. _initSource: function() {
  4398. var array, url,
  4399. that = this;
  4400. if ( $.isArray( this.options.source ) ) {
  4401. array = this.options.source;
  4402. this.source = function( request, response ) {
  4403. response( $.ui.autocomplete.filter( array, request.term ) );
  4404. };
  4405. } else if ( typeof this.options.source === "string" ) {
  4406. url = this.options.source;
  4407. this.source = function( request, response ) {
  4408. if ( that.xhr ) {
  4409. that.xhr.abort();
  4410. }
  4411. that.xhr = $.ajax({
  4412. url: url,
  4413. data: request,
  4414. dataType: "json",
  4415. success: function( data ) {
  4416. response( data );
  4417. },
  4418. error: function() {
  4419. response([]);
  4420. }
  4421. });
  4422. };
  4423. } else {
  4424. this.source = this.options.source;
  4425. }
  4426. },
  4427. _searchTimeout: function( event ) {
  4428. clearTimeout( this.searching );
  4429. this.searching = this._delay(function() {
  4430. // Search if the value has changed, or if the user retypes the same value (see #7434)
  4431. var equalValues = this.term === this._value(),
  4432. menuVisible = this.menu.element.is( ":visible" ),
  4433. modifierKey = event.altKey || event.ctrlKey || event.metaKey || event.shiftKey;
  4434. if ( !equalValues || ( equalValues && !menuVisible && !modifierKey ) ) {
  4435. this.selectedItem = null;
  4436. this.search( null, event );
  4437. }
  4438. }, this.options.delay );
  4439. },
  4440. search: function( value, event ) {
  4441. value = value != null ? value : this._value();
  4442. // always save the actual value, not the one passed as an argument
  4443. this.term = this._value();
  4444. if ( value.length < this.options.minLength ) {
  4445. return this.close( event );
  4446. }
  4447. if ( this._trigger( "search", event ) === false ) {
  4448. return;
  4449. }
  4450. return this._search( value );
  4451. },
  4452. _search: function( value ) {
  4453. this.pending++;
  4454. this.element.addClass( "ui-autocomplete-loading" );
  4455. this.cancelSearch = false;
  4456. this.source( { term: value }, this._response() );
  4457. },
  4458. _response: function() {
  4459. var index = ++this.requestIndex;
  4460. return $.proxy(function( content ) {
  4461. if ( index === this.requestIndex ) {
  4462. this.__response( content );
  4463. }
  4464. this.pending--;
  4465. if ( !this.pending ) {
  4466. this.element.removeClass( "ui-autocomplete-loading" );
  4467. }
  4468. }, this );
  4469. },
  4470. __response: function( content ) {
  4471. if ( content ) {
  4472. content = this._normalize( content );
  4473. }
  4474. this._trigger( "response", null, { content: content } );
  4475. if ( !this.options.disabled && content && content.length && !this.cancelSearch ) {
  4476. this._suggest( content );
  4477. this._trigger( "open" );
  4478. } else {
  4479. // use ._close() instead of .close() so we don't cancel future searches
  4480. this._close();
  4481. }
  4482. },
  4483. close: function( event ) {
  4484. this.cancelSearch = true;
  4485. this._close( event );
  4486. },
  4487. _close: function( event ) {
  4488. if ( this.menu.element.is( ":visible" ) ) {
  4489. this.menu.element.hide();
  4490. this.menu.blur();
  4491. this.isNewMenu = true;
  4492. this._trigger( "close", event );
  4493. }
  4494. },
  4495. _change: function( event ) {
  4496. if ( this.previous !== this._value() ) {
  4497. this._trigger( "change", event, { item: this.selectedItem } );
  4498. }
  4499. },
  4500. _normalize: function( items ) {
  4501. // assume all items have the right format when the first item is complete
  4502. if ( items.length && items[ 0 ].label && items[ 0 ].value ) {
  4503. return items;
  4504. }
  4505. return $.map( items, function( item ) {
  4506. if ( typeof item === "string" ) {
  4507. return {
  4508. label: item,
  4509. value: item
  4510. };
  4511. }
  4512. return $.extend( {}, item, {
  4513. label: item.label || item.value,
  4514. value: item.value || item.label
  4515. });
  4516. });
  4517. },
  4518. _suggest: function( items ) {
  4519. var ul = this.menu.element.empty();
  4520. this._renderMenu( ul, items );
  4521. this.isNewMenu = true;
  4522. this.menu.refresh();
  4523. // size and position menu
  4524. ul.show();
  4525. this._resizeMenu();
  4526. ul.position( $.extend({
  4527. of: this.element
  4528. }, this.options.position ) );
  4529. if ( this.options.autoFocus ) {
  4530. this.menu.next();
  4531. }
  4532. },
  4533. _resizeMenu: function() {
  4534. var ul = this.menu.element;
  4535. ul.outerWidth( Math.max(
  4536. // Firefox wraps long text (possibly a rounding bug)
  4537. // so we add 1px to avoid the wrapping (#7513)
  4538. ul.width( "" ).outerWidth() + 1,
  4539. this.element.outerWidth()
  4540. ) );
  4541. },
  4542. _renderMenu: function( ul, items ) {
  4543. var that = this;
  4544. $.each( items, function( index, item ) {
  4545. that._renderItemData( ul, item );
  4546. });
  4547. },
  4548. _renderItemData: function( ul, item ) {
  4549. return this._renderItem( ul, item ).data( "ui-autocomplete-item", item );
  4550. },
  4551. _renderItem: function( ul, item ) {
  4552. return $( "<li>" ).text( item.label ).appendTo( ul );
  4553. },
  4554. _move: function( direction, event ) {
  4555. if ( !this.menu.element.is( ":visible" ) ) {
  4556. this.search( null, event );
  4557. return;
  4558. }
  4559. if ( this.menu.isFirstItem() && /^previous/.test( direction ) ||
  4560. this.menu.isLastItem() && /^next/.test( direction ) ) {
  4561. if ( !this.isMultiLine ) {
  4562. this._value( this.term );
  4563. }
  4564. this.menu.blur();
  4565. return;
  4566. }
  4567. this.menu[ direction ]( event );
  4568. },
  4569. widget: function() {
  4570. return this.menu.element;
  4571. },
  4572. _value: function() {
  4573. return this.valueMethod.apply( this.element, arguments );
  4574. },
  4575. _keyEvent: function( keyEvent, event ) {
  4576. if ( !this.isMultiLine || this.menu.element.is( ":visible" ) ) {
  4577. this._move( keyEvent, event );
  4578. // prevents moving cursor to beginning/end of the text field in some browsers
  4579. event.preventDefault();
  4580. }
  4581. }
  4582. });
  4583. $.extend( $.ui.autocomplete, {
  4584. escapeRegex: function( value ) {
  4585. return value.replace( /[\-\[\]{}()*+?.,\\\^$|#\s]/g, "\\$&" );
  4586. },
  4587. filter: function( array, term ) {
  4588. var matcher = new RegExp( $.ui.autocomplete.escapeRegex( term ), "i" );
  4589. return $.grep( array, function( value ) {
  4590. return matcher.test( value.label || value.value || value );
  4591. });
  4592. }
  4593. });
  4594. // live region extension, adding a `messages` option
  4595. // NOTE: This is an experimental API. We are still investigating
  4596. // a full solution for string manipulation and internationalization.
  4597. $.widget( "ui.autocomplete", $.ui.autocomplete, {
  4598. options: {
  4599. messages: {
  4600. noResults: "No search results.",
  4601. results: function( amount ) {
  4602. return amount + ( amount > 1 ? " results are" : " result is" ) +
  4603. " available, use up and down arrow keys to navigate.";
  4604. }
  4605. }
  4606. },
  4607. __response: function( content ) {
  4608. var message;
  4609. this._superApply( arguments );
  4610. if ( this.options.disabled || this.cancelSearch ) {
  4611. return;
  4612. }
  4613. if ( content && content.length ) {
  4614. message = this.options.messages.results( content.length );
  4615. } else {
  4616. message = this.options.messages.noResults;
  4617. }
  4618. this.liveRegion.children().hide();
  4619. $( "<div>" ).text( message ).appendTo( this.liveRegion );
  4620. }
  4621. });
  4622. var autocomplete = $.ui.autocomplete;
  4623. /*!
  4624. * jQuery UI Datepicker 1.11.4
  4625. * http://jqueryui.com
  4626. *
  4627. * Copyright jQuery Foundation and other contributors
  4628. * Released under the MIT license.
  4629. * http://jquery.org/license
  4630. *
  4631. * http://api.jqueryui.com/datepicker/
  4632. */
  4633. $.extend($.ui, { datepicker: { version: "1.11.4" } });
  4634. var datepicker_instActive;
  4635. function datepicker_getZindex( elem ) {
  4636. var position, value;
  4637. while ( elem.length && elem[ 0 ] !== document ) {
  4638. // Ignore z-index if position is set to a value where z-index is ignored by the browser
  4639. // This makes behavior of this function consistent across browsers
  4640. // WebKit always returns auto if the element is positioned
  4641. position = elem.css( "position" );
  4642. if ( position === "absolute" || position === "relative" || position === "fixed" ) {
  4643. // IE returns 0 when zIndex is not specified
  4644. // other browsers return a string
  4645. // we ignore the case of nested elements with an explicit value of 0
  4646. // <div style="z-index: -10;"><div style="z-index: 0;"></div></div>
  4647. value = parseInt( elem.css( "zIndex" ), 10 );
  4648. if ( !isNaN( value ) && value !== 0 ) {
  4649. return value;
  4650. }
  4651. }
  4652. elem = elem.parent();
  4653. }
  4654. return 0;
  4655. }
  4656. /* Date picker manager.
  4657. Use the singleton instance of this class, $.datepicker, to interact with the date picker.
  4658. Settings for (groups of) date pickers are maintained in an instance object,
  4659. allowing multiple different settings on the same page. */
  4660. function Datepicker() {
  4661. this._curInst = null; // The current instance in use
  4662. this._keyEvent = false; // If the last event was a key event
  4663. this._disabledInputs = []; // List of date picker inputs that have been disabled
  4664. this._datepickerShowing = false; // True if the popup picker is showing , false if not
  4665. this._inDialog = false; // True if showing within a "dialog", false if not
  4666. this._mainDivId = "ui-datepicker-div"; // The ID of the main datepicker division
  4667. this._inlineClass = "ui-datepicker-inline"; // The name of the inline marker class
  4668. this._appendClass = "ui-datepicker-append"; // The name of the append marker class
  4669. this._triggerClass = "ui-datepicker-trigger"; // The name of the trigger marker class
  4670. this._dialogClass = "ui-datepicker-dialog"; // The name of the dialog marker class
  4671. this._disableClass = "ui-datepicker-disabled"; // The name of the disabled covering marker class
  4672. this._unselectableClass = "ui-datepicker-unselectable"; // The name of the unselectable cell marker class
  4673. this._currentClass = "ui-datepicker-current-day"; // The name of the current day marker class
  4674. this._dayOverClass = "ui-datepicker-days-cell-over"; // The name of the day hover marker class
  4675. this.regional = []; // Available regional settings, indexed by language code
  4676. this.regional[""] = { // Default regional settings
  4677. closeText: "Done", // Display text for close link
  4678. prevText: "Prev", // Display text for previous month link
  4679. nextText: "Next", // Display text for next month link
  4680. currentText: "Today", // Display text for current month link
  4681. monthNames: ["January","February","March","April","May","June",
  4682. "July","August","September","October","November","December"], // Names of months for drop-down and formatting
  4683. monthNamesShort: ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"], // For formatting
  4684. dayNames: ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"], // For formatting
  4685. dayNamesShort: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"], // For formatting
  4686. dayNamesMin: ["Su","Mo","Tu","We","Th","Fr","Sa"], // Column headings for days starting at Sunday
  4687. weekHeader: "Wk", // Column header for week of the year
  4688. dateFormat: "mm/dd/yy", // See format options on parseDate
  4689. firstDay: 0, // The first day of the week, Sun = 0, Mon = 1, ...
  4690. weekendDays: [0, 6], //List of days considered as weekend, Sun = 0, Mon = 1, ...
  4691. isRTL: false, // True if right-to-left language, false if left-to-right
  4692. showMonthAfterYear: false, // True if the year select precedes month, false for month then year
  4693. yearSuffix: "" // Additional text to append to the year in the month headers
  4694. };
  4695. this._defaults = { // Global defaults for all the date picker instances
  4696. showOn: "focus", // "focus" for popup on focus,
  4697. // "button" for trigger button, or "both" for either
  4698. showAnim: "fadeIn", // Name of jQuery animation for popup
  4699. showOptions: {}, // Options for enhanced animations
  4700. defaultDate: null, // Used when field is blank: actual date,
  4701. // +/-number for offset from today, null for today
  4702. appendText: "", // Display text following the input box, e.g. showing the format
  4703. buttonText: "...", // Text for trigger button
  4704. buttonImage: "", // URL for trigger button image
  4705. buttonImageOnly: false, // True if the image appears alone, false if it appears on a button
  4706. hideIfNoPrevNext: false, // True to hide next/previous month links
  4707. // if not applicable, false to just disable them
  4708. navigationAsDateFormat: false, // True if date formatting applied to prev/today/next links
  4709. gotoCurrent: false, // True if today link goes back to current selection instead
  4710. changeMonth: false, // True if month can be selected directly, false if only prev/next
  4711. changeYear: false, // True if year can be selected directly, false if only prev/next
  4712. yearRange: "c-10:c+10", // Range of years to display in drop-down,
  4713. // either relative to today's year (-nn:+nn), relative to currently displayed year
  4714. // (c-nn:c+nn), absolute (nnnn:nnnn), or a combination of the above (nnnn:-n)
  4715. showOtherMonths: false, // True to show dates in other months, false to leave blank
  4716. selectOtherMonths: false, // True to allow selection of dates in other months, false for unselectable
  4717. showWeek: false, // True to show week of the year, false to not show it
  4718. calculateWeek: this.iso8601Week, // How to calculate the week of the year,
  4719. // takes a Date and returns the number of the week for it
  4720. shortYearCutoff: "+10", // Short year values < this are in the current century,
  4721. // > this are in the previous century,
  4722. // string value starting with "+" for current year + value
  4723. minDate: null, // The earliest selectable date, or null for no limit
  4724. maxDate: null, // The latest selectable date, or null for no limit
  4725. duration: "fast", // Duration of display/closure
  4726. beforeShowDay: null, // Function that takes a date and returns an array with
  4727. // [0] = true if selectable, false if not, [1] = custom CSS class name(s) or "",
  4728. // [2] = cell title (optional), e.g. $.datepicker.noWeekends
  4729. beforeShow: null, // Function that takes an input field and
  4730. // returns a set of custom settings for the date picker
  4731. onSelect: null, // Define a callback function when a date is selected
  4732. onChangeMonthYear: null, // Define a callback function when the month or year is changed
  4733. onClose: null, // Define a callback function when the datepicker is closed
  4734. numberOfMonths: 1, // Number of months to show at a time
  4735. showCurrentAtPos: 0, // The position in multipe months at which to show the current month (starting at 0)
  4736. stepMonths: 1, // Number of months to step back/forward
  4737. stepBigMonths: 12, // Number of months to step back/forward for the big links
  4738. altField: "", // Selector for an alternate field to store selected dates into
  4739. altFormat: "", // The date format to use for the alternate field
  4740. constrainInput: true, // The input is constrained by the current date format
  4741. showButtonPanel: false, // True to show button panel, false to not show it
  4742. autoSize: false, // True to size the input for the date format, false to leave as is
  4743. disabled: false // The initial disabled state
  4744. };
  4745. $.extend(this._defaults, this.regional[""]);
  4746. this.regional.en = $.extend( true, {}, this.regional[ "" ]);
  4747. this.regional[ "en-US" ] = $.extend( true, {}, this.regional.en );
  4748. this.dpDiv = datepicker_bindHover($("<div id='" + this._mainDivId + "' class='ui-datepicker ui-widget ui-widget-content ui-helper-clearfix ui-corner-all'></div>"));
  4749. }
  4750. $.extend(Datepicker.prototype, {
  4751. /* Class name added to elements to indicate already configured with a date picker. */
  4752. markerClassName: "hasDatepicker",
  4753. //Keep track of the maximum number of rows displayed (see #7043)
  4754. maxRows: 4,
  4755. // TODO rename to "widget" when switching to widget factory
  4756. _widgetDatepicker: function() {
  4757. return this.dpDiv;
  4758. },
  4759. /* Override the default settings for all instances of the date picker.
  4760. * @param settings object - the new settings to use as defaults (anonymous object)
  4761. * @return the manager object
  4762. */
  4763. setDefaults: function(settings) {
  4764. datepicker_extendRemove(this._defaults, settings || {});
  4765. return this;
  4766. },
  4767. /* Attach the date picker to a jQuery selection.
  4768. * @param target element - the target input field or division or span
  4769. * @param settings object - the new settings to use for this date picker instance (anonymous)
  4770. */
  4771. _attachDatepicker: function(target, settings) {
  4772. var nodeName, inline, inst;
  4773. nodeName = target.nodeName.toLowerCase();
  4774. inline = (nodeName === "div" || nodeName === "span");
  4775. if (!target.id) {
  4776. this.uuid += 1;
  4777. target.id = "dp" + this.uuid;
  4778. }
  4779. inst = this._newInst($(target), inline);
  4780. inst.settings = $.extend({}, settings || {});
  4781. if (nodeName === "input") {
  4782. this._connectDatepicker(target, inst);
  4783. } else if (inline) {
  4784. this._inlineDatepicker(target, inst);
  4785. }
  4786. },
  4787. /* Create a new instance object. */
  4788. _newInst: function(target, inline) {
  4789. var id = target[0].id.replace(/([^A-Za-z0-9_\-])/g, "\\\\$1"); // escape jQuery meta chars
  4790. return {id: id, input: target, // associated target
  4791. selectedDay: 0, selectedMonth: 0, selectedYear: 0, // current selection
  4792. drawMonth: 0, drawYear: 0, // month being drawn
  4793. inline: inline, // is datepicker inline or not
  4794. dpDiv: (!inline ? this.dpDiv : // presentation div
  4795. datepicker_bindHover($("<div class='" + this._inlineClass + " ui-datepicker ui-widget ui-widget-content ui-helper-clearfix ui-corner-all'></div>")))};
  4796. },
  4797. /* Attach the date picker to an input field. */
  4798. _connectDatepicker: function(target, inst) {
  4799. var input = $(target);
  4800. inst.append = $([]);
  4801. inst.trigger = $([]);
  4802. if (input.hasClass(this.markerClassName)) {
  4803. return;
  4804. }
  4805. this._attachments(input, inst);
  4806. input.addClass(this.markerClassName).keydown(this._doKeyDown).
  4807. keypress(this._doKeyPress).keyup(this._doKeyUp);
  4808. this._autoSize(inst);
  4809. $.data(target, "datepicker", inst);
  4810. //If disabled option is true, disable the datepicker once it has been attached to the input (see ticket #5665)
  4811. if( inst.settings.disabled ) {
  4812. this._disableDatepicker( target );
  4813. }
  4814. },
  4815. /* Make attachments based on settings. */
  4816. _attachments: function(input, inst) {
  4817. var showOn, buttonText, buttonImage,
  4818. appendText = this._get(inst, "appendText"),
  4819. isRTL = this._get(inst, "isRTL");
  4820. if (inst.append) {
  4821. inst.append.remove();
  4822. }
  4823. if (appendText) {
  4824. inst.append = $("<span class='" + this._appendClass + "'>" + appendText + "</span>");
  4825. input[isRTL ? "before" : "after"](inst.append);
  4826. }
  4827. input.unbind("focus", this._showDatepicker);
  4828. if (inst.trigger) {
  4829. inst.trigger.remove();
  4830. }
  4831. showOn = this._get(inst, "showOn");
  4832. if (showOn === "focus" || showOn === "both") { // pop-up date picker when in the marked field
  4833. input.focus(this._showDatepicker);
  4834. }
  4835. if (showOn === "button" || showOn === "both") { // pop-up date picker when button clicked
  4836. buttonText = this._get(inst, "buttonText");
  4837. buttonImage = this._get(inst, "buttonImage");
  4838. inst.trigger = $(this._get(inst, "buttonImageOnly") ?
  4839. $("<img/>").addClass(this._triggerClass).
  4840. attr({ src: buttonImage, alt: buttonText, title: buttonText }) :
  4841. $("<button type='button'></button>").addClass(this._triggerClass).
  4842. html(!buttonImage ? buttonText : $("<img/>").attr(
  4843. { src:buttonImage, alt:buttonText, title:buttonText })));
  4844. input[isRTL ? "before" : "after"](inst.trigger);
  4845. inst.trigger.click(function() {
  4846. if ($.datepicker._datepickerShowing && $.datepicker._lastInput === input[0]) {
  4847. $.datepicker._hideDatepicker();
  4848. } else if ($.datepicker._datepickerShowing && $.datepicker._lastInput !== input[0]) {
  4849. $.datepicker._hideDatepicker();
  4850. $.datepicker._showDatepicker(input[0]);
  4851. } else {
  4852. $.datepicker._showDatepicker(input[0]);
  4853. }
  4854. return false;
  4855. });
  4856. }
  4857. },
  4858. /* Apply the maximum length for the date format. */
  4859. _autoSize: function(inst) {
  4860. if (this._get(inst, "autoSize") && !inst.inline) {
  4861. var findMax, max, maxI, i,
  4862. date = new Date(2009, 12 - 1, 20), // Ensure double digits
  4863. dateFormat = this._get(inst, "dateFormat");
  4864. if (dateFormat.match(/[DM]/)) {
  4865. findMax = function(names) {
  4866. max = 0;
  4867. maxI = 0;
  4868. for (i = 0; i < names.length; i++) {
  4869. if (names[i].length > max) {
  4870. max = names[i].length;
  4871. maxI = i;
  4872. }
  4873. }
  4874. return maxI;
  4875. };
  4876. date.setMonth(findMax(this._get(inst, (dateFormat.match(/MM/) ?
  4877. "monthNames" : "monthNamesShort"))));
  4878. date.setDate(findMax(this._get(inst, (dateFormat.match(/DD/) ?
  4879. "dayNames" : "dayNamesShort"))) + 20 - date.getDay());
  4880. }
  4881. inst.input.attr("size", this._formatDate(inst, date).length);
  4882. }
  4883. },
  4884. /* Attach an inline date picker to a div. */
  4885. _inlineDatepicker: function(target, inst) {
  4886. var divSpan = $(target);
  4887. if (divSpan.hasClass(this.markerClassName)) {
  4888. return;
  4889. }
  4890. divSpan.addClass(this.markerClassName).append(inst.dpDiv);
  4891. $.data(target, "datepicker", inst);
  4892. this._setDate(inst, this._getDefaultDate(inst), true);
  4893. this._updateDatepicker(inst);
  4894. this._updateAlternate(inst);
  4895. //If disabled option is true, disable the datepicker before showing it (see ticket #5665)
  4896. if( inst.settings.disabled ) {
  4897. this._disableDatepicker( target );
  4898. }
  4899. // Set display:block in place of inst.dpDiv.show() which won't work on disconnected elements
  4900. // http://bugs.jqueryui.com/ticket/7552 - A Datepicker created on a detached div has zero height
  4901. inst.dpDiv.css( "display", "block" );
  4902. },
  4903. /* Pop-up the date picker in a "dialog" box.
  4904. * @param input element - ignored
  4905. * @param date string or Date - the initial date to display
  4906. * @param onSelect function - the function to call when a date is selected
  4907. * @param settings object - update the dialog date picker instance's settings (anonymous object)
  4908. * @param pos int[2] - coordinates for the dialog's position within the screen or
  4909. * event - with x/y coordinates or
  4910. * leave empty for default (screen centre)
  4911. * @return the manager object
  4912. */
  4913. _dialogDatepicker: function(input, date, onSelect, settings, pos) {
  4914. var id, browserWidth, browserHeight, scrollX, scrollY,
  4915. inst = this._dialogInst; // internal instance
  4916. if (!inst) {
  4917. this.uuid += 1;
  4918. id = "dp" + this.uuid;
  4919. this._dialogInput = $("<input type='text' id='" + id +
  4920. "' style='position: absolute; top: -100px; width: 0px;'/>");
  4921. this._dialogInput.keydown(this._doKeyDown);
  4922. $("body").append(this._dialogInput);
  4923. inst = this._dialogInst = this._newInst(this._dialogInput, false);
  4924. inst.settings = {};
  4925. $.data(this._dialogInput[0], "datepicker", inst);
  4926. }
  4927. datepicker_extendRemove(inst.settings, settings || {});
  4928. date = (date && date.constructor === Date ? this._formatDate(inst, date) : date);
  4929. this._dialogInput.val(date);
  4930. this._pos = (pos ? (pos.length ? pos : [pos.pageX, pos.pageY]) : null);
  4931. if (!this._pos) {
  4932. browserWidth = document.documentElement.clientWidth;
  4933. browserHeight = document.documentElement.clientHeight;
  4934. scrollX = document.documentElement.scrollLeft || document.body.scrollLeft;
  4935. scrollY = document.documentElement.scrollTop || document.body.scrollTop;
  4936. this._pos = // should use actual width/height below
  4937. [(browserWidth / 2) - 100 + scrollX, (browserHeight / 2) - 150 + scrollY];
  4938. }
  4939. // move input on screen for focus, but hidden behind dialog
  4940. this._dialogInput.css("left", (this._pos[0] + 20) + "px").css("top", this._pos[1] + "px");
  4941. inst.settings.onSelect = onSelect;
  4942. this._inDialog = true;
  4943. this.dpDiv.addClass(this._dialogClass);
  4944. this._showDatepicker(this._dialogInput[0]);
  4945. if ($.blockUI) {
  4946. $.blockUI(this.dpDiv);
  4947. }
  4948. $.data(this._dialogInput[0], "datepicker", inst);
  4949. return this;
  4950. },
  4951. /* Detach a datepicker from its control.
  4952. * @param target element - the target input field or division or span
  4953. */
  4954. _destroyDatepicker: function(target) {
  4955. var nodeName,
  4956. $target = $(target),
  4957. inst = $.data(target, "datepicker");
  4958. if (!$target.hasClass(this.markerClassName)) {
  4959. return;
  4960. }
  4961. nodeName = target.nodeName.toLowerCase();
  4962. $.removeData(target, "datepicker");
  4963. if (nodeName === "input") {
  4964. inst.append.remove();
  4965. inst.trigger.remove();
  4966. $target.removeClass(this.markerClassName).
  4967. unbind("focus", this._showDatepicker).
  4968. unbind("keydown", this._doKeyDown).
  4969. unbind("keypress", this._doKeyPress).
  4970. unbind("keyup", this._doKeyUp);
  4971. } else if (nodeName === "div" || nodeName === "span") {
  4972. $target.removeClass(this.markerClassName).empty();
  4973. }
  4974. if ( datepicker_instActive === inst ) {
  4975. datepicker_instActive = null;
  4976. }
  4977. },
  4978. /* Enable the date picker to a jQuery selection.
  4979. * @param target element - the target input field or division or span
  4980. */
  4981. _enableDatepicker: function(target) {
  4982. var nodeName, inline,
  4983. $target = $(target),
  4984. inst = $.data(target, "datepicker");
  4985. if (!$target.hasClass(this.markerClassName)) {
  4986. return;
  4987. }
  4988. nodeName = target.nodeName.toLowerCase();
  4989. if (nodeName === "input") {
  4990. target.disabled = false;
  4991. inst.trigger.filter("button").
  4992. each(function() { this.disabled = false; }).end().
  4993. filter("img").css({opacity: "1.0", cursor: ""});
  4994. } else if (nodeName === "div" || nodeName === "span") {
  4995. inline = $target.children("." + this._inlineClass);
  4996. inline.children().removeClass("ui-state-disabled");
  4997. inline.find("select.ui-datepicker-month, select.ui-datepicker-year").
  4998. prop("disabled", false);
  4999. }
  5000. this._disabledInputs = $.map(this._disabledInputs,
  5001. function(value) { return (value === target ? null : value); }); // delete entry
  5002. },
  5003. /* Disable the date picker to a jQuery selection.
  5004. * @param target element - the target input field or division or span
  5005. */
  5006. _disableDatepicker: function(target) {
  5007. var nodeName, inline,
  5008. $target = $(target),
  5009. inst = $.data(target, "datepicker");
  5010. if (!$target.hasClass(this.markerClassName)) {
  5011. return;
  5012. }
  5013. nodeName = target.nodeName.toLowerCase();
  5014. if (nodeName === "input") {
  5015. target.disabled = true;
  5016. inst.trigger.filter("button").
  5017. each(function() { this.disabled = true; }).end().
  5018. filter("img").css({opacity: "0.5", cursor: "default"});
  5019. } else if (nodeName === "div" || nodeName === "span") {
  5020. inline = $target.children("." + this._inlineClass);
  5021. inline.children().addClass("ui-state-disabled");
  5022. inline.find("select.ui-datepicker-month, select.ui-datepicker-year").
  5023. prop("disabled", true);
  5024. }
  5025. this._disabledInputs = $.map(this._disabledInputs,
  5026. function(value) { return (value === target ? null : value); }); // delete entry
  5027. this._disabledInputs[this._disabledInputs.length] = target;
  5028. },
  5029. /* Is the first field in a jQuery collection disabled as a datepicker?
  5030. * @param target element - the target input field or division or span
  5031. * @return boolean - true if disabled, false if enabled
  5032. */
  5033. _isDisabledDatepicker: function(target) {
  5034. if (!target) {
  5035. return false;
  5036. }
  5037. for (var i = 0; i < this._disabledInputs.length; i++) {
  5038. if (this._disabledInputs[i] === target) {
  5039. return true;
  5040. }
  5041. }
  5042. return false;
  5043. },
  5044. /* Retrieve the instance data for the target control.
  5045. * @param target element - the target input field or division or span
  5046. * @return object - the associated instance data
  5047. * @throws error if a jQuery problem getting data
  5048. */
  5049. _getInst: function(target) {
  5050. try {
  5051. return $.data(target, "datepicker");
  5052. }
  5053. catch (err) {
  5054. throw "Missing instance data for this datepicker";
  5055. }
  5056. },
  5057. /* Update or retrieve the settings for a date picker attached to an input field or division.
  5058. * @param target element - the target input field or division or span
  5059. * @param name object - the new settings to update or
  5060. * string - the name of the setting to change or retrieve,
  5061. * when retrieving also "all" for all instance settings or
  5062. * "defaults" for all global defaults
  5063. * @param value any - the new value for the setting
  5064. * (omit if above is an object or to retrieve a value)
  5065. */
  5066. _optionDatepicker: function(target, name, value) {
  5067. var settings, date, minDate, maxDate,
  5068. inst = this._getInst(target);
  5069. if (arguments.length === 2 && typeof name === "string") {
  5070. return (name === "defaults" ? $.extend({}, $.datepicker._defaults) :
  5071. (inst ? (name === "all" ? $.extend({}, inst.settings) :
  5072. this._get(inst, name)) : null));
  5073. }
  5074. settings = name || {};
  5075. if (typeof name === "string") {
  5076. settings = {};
  5077. settings[name] = value;
  5078. }
  5079. if (inst) {
  5080. if (this._curInst === inst) {
  5081. this._hideDatepicker();
  5082. }
  5083. date = this._getDateDatepicker(target, true);
  5084. minDate = this._getMinMaxDate(inst, "min");
  5085. maxDate = this._getMinMaxDate(inst, "max");
  5086. datepicker_extendRemove(inst.settings, settings);
  5087. // reformat the old minDate/maxDate values if dateFormat changes and a new minDate/maxDate isn't provided
  5088. if (minDate !== null && settings.dateFormat !== undefined && settings.minDate === undefined) {
  5089. inst.settings.minDate = this._formatDate(inst, minDate);
  5090. }
  5091. if (maxDate !== null && settings.dateFormat !== undefined && settings.maxDate === undefined) {
  5092. inst.settings.maxDate = this._formatDate(inst, maxDate);
  5093. }
  5094. if ( "disabled" in settings ) {
  5095. if ( settings.disabled ) {
  5096. this._disableDatepicker(target);
  5097. } else {
  5098. this._enableDatepicker(target);
  5099. }
  5100. }
  5101. this._attachments($(target), inst);
  5102. this._autoSize(inst);
  5103. this._setDate(inst, date);
  5104. this._updateAlternate(inst);
  5105. this._updateDatepicker(inst);
  5106. }
  5107. },
  5108. // change method deprecated
  5109. _changeDatepicker: function(target, name, value) {
  5110. this._optionDatepicker(target, name, value);
  5111. },
  5112. /* Redraw the date picker attached to an input field or division.
  5113. * @param target element - the target input field or division or span
  5114. */
  5115. _refreshDatepicker: function(target) {
  5116. var inst = this._getInst(target);
  5117. if (inst) {
  5118. this._updateDatepicker(inst);
  5119. }
  5120. },
  5121. /* Set the dates for a jQuery selection.
  5122. * @param target element - the target input field or division or span
  5123. * @param date Date - the new date
  5124. */
  5125. _setDateDatepicker: function(target, date) {
  5126. var inst = this._getInst(target);
  5127. if (inst) {
  5128. this._setDate(inst, date);
  5129. this._updateDatepicker(inst);
  5130. this._updateAlternate(inst);
  5131. }
  5132. },
  5133. /* Get the date(s) for the first entry in a jQuery selection.
  5134. * @param target element - the target input field or division or span
  5135. * @param noDefault boolean - true if no default date is to be used
  5136. * @return Date - the current date
  5137. */
  5138. _getDateDatepicker: function(target, noDefault) {
  5139. var inst = this._getInst(target);
  5140. if (inst && !inst.inline) {
  5141. this._setDateFromField(inst, noDefault);
  5142. }
  5143. return (inst ? this._getDate(inst) : null);
  5144. },
  5145. /* Handle keystrokes. */
  5146. _doKeyDown: function(event) {
  5147. var onSelect, dateStr, sel,
  5148. inst = $.datepicker._getInst(event.target),
  5149. handled = true,
  5150. isRTL = inst.dpDiv.is(".ui-datepicker-rtl");
  5151. inst._keyEvent = true;
  5152. if ($.datepicker._datepickerShowing) {
  5153. switch (event.keyCode) {
  5154. case 9: $.datepicker._hideDatepicker();
  5155. handled = false;
  5156. break; // hide on tab out
  5157. case 13: sel = $("td." + $.datepicker._dayOverClass + ":not(." +
  5158. $.datepicker._currentClass + ")", inst.dpDiv);
  5159. if (sel[0]) {
  5160. $.datepicker._selectDay(event.target, inst.selectedMonth, inst.selectedYear, sel[0]);
  5161. }
  5162. onSelect = $.datepicker._get(inst, "onSelect");
  5163. if (onSelect) {
  5164. dateStr = $.datepicker._formatDate(inst);
  5165. // trigger custom callback
  5166. onSelect.apply((inst.input ? inst.input[0] : null), [dateStr, inst]);
  5167. } else {
  5168. $.datepicker._hideDatepicker();
  5169. }
  5170. return false; // don't submit the form
  5171. case 27: $.datepicker._hideDatepicker();
  5172. break; // hide on escape
  5173. case 33: $.datepicker._adjustDate(event.target, (event.ctrlKey ?
  5174. -$.datepicker._get(inst, "stepBigMonths") :
  5175. -$.datepicker._get(inst, "stepMonths")), "M");
  5176. break; // previous month/year on page up/+ ctrl
  5177. case 34: $.datepicker._adjustDate(event.target, (event.ctrlKey ?
  5178. +$.datepicker._get(inst, "stepBigMonths") :
  5179. +$.datepicker._get(inst, "stepMonths")), "M");
  5180. break; // next month/year on page down/+ ctrl
  5181. case 35: if (event.ctrlKey || event.metaKey) {
  5182. $.datepicker._clearDate(event.target);
  5183. }
  5184. handled = event.ctrlKey || event.metaKey;
  5185. break; // clear on ctrl or command +end
  5186. case 36: if (event.ctrlKey || event.metaKey) {
  5187. $.datepicker._gotoToday(event.target);
  5188. }
  5189. handled = event.ctrlKey || event.metaKey;
  5190. break; // current on ctrl or command +home
  5191. case 37: if (event.ctrlKey || event.metaKey) {
  5192. $.datepicker._adjustDate(event.target, (isRTL ? +1 : -1), "D");
  5193. }
  5194. handled = event.ctrlKey || event.metaKey;
  5195. // -1 day on ctrl or command +left
  5196. if (event.originalEvent.altKey) {
  5197. $.datepicker._adjustDate(event.target, (event.ctrlKey ?
  5198. -$.datepicker._get(inst, "stepBigMonths") :
  5199. -$.datepicker._get(inst, "stepMonths")), "M");
  5200. }
  5201. // next month/year on alt +left on Mac
  5202. break;
  5203. case 38: if (event.ctrlKey || event.metaKey) {
  5204. $.datepicker._adjustDate(event.target, -7, "D");
  5205. }
  5206. handled = event.ctrlKey || event.metaKey;
  5207. break; // -1 week on ctrl or command +up
  5208. case 39: if (event.ctrlKey || event.metaKey) {
  5209. $.datepicker._adjustDate(event.target, (isRTL ? -1 : +1), "D");
  5210. }
  5211. handled = event.ctrlKey || event.metaKey;
  5212. // +1 day on ctrl or command +right
  5213. if (event.originalEvent.altKey) {
  5214. $.datepicker._adjustDate(event.target, (event.ctrlKey ?
  5215. +$.datepicker._get(inst, "stepBigMonths") :
  5216. +$.datepicker._get(inst, "stepMonths")), "M");
  5217. }
  5218. // next month/year on alt +right
  5219. break;
  5220. case 40: if (event.ctrlKey || event.metaKey) {
  5221. $.datepicker._adjustDate(event.target, +7, "D");
  5222. }
  5223. handled = event.ctrlKey || event.metaKey;
  5224. break; // +1 week on ctrl or command +down
  5225. default: handled = false;
  5226. }
  5227. } else if (event.keyCode === 36 && event.ctrlKey) { // display the date picker on ctrl+home
  5228. $.datepicker._showDatepicker(this);
  5229. } else {
  5230. handled = false;
  5231. }
  5232. if (handled) {
  5233. event.preventDefault();
  5234. event.stopPropagation();
  5235. }
  5236. },
  5237. /* Filter entered characters - based on date format. */
  5238. _doKeyPress: function(event) {
  5239. var chars, chr,
  5240. inst = $.datepicker._getInst(event.target);
  5241. if ($.datepicker._get(inst, "constrainInput")) {
  5242. chars = $.datepicker._possibleChars($.datepicker._get(inst, "dateFormat"));
  5243. chr = String.fromCharCode(event.charCode == null ? event.keyCode : event.charCode);
  5244. return event.ctrlKey || event.metaKey || (chr < " " || !chars || chars.indexOf(chr) > -1);
  5245. }
  5246. },
  5247. /* Synchronise manual entry and field/alternate field. */
  5248. _doKeyUp: function(event) {
  5249. var date,
  5250. inst = $.datepicker._getInst(event.target);
  5251. if (inst.input.val() !== inst.lastVal) {
  5252. try {
  5253. date = $.datepicker.parseDate($.datepicker._get(inst, "dateFormat"),
  5254. (inst.input ? inst.input.val() : null),
  5255. $.datepicker._getFormatConfig(inst));
  5256. if (date) { // only if valid
  5257. $.datepicker._setDateFromField(inst);
  5258. $.datepicker._updateAlternate(inst);
  5259. $.datepicker._updateDatepicker(inst);
  5260. }
  5261. }
  5262. catch (err) {
  5263. }
  5264. }
  5265. return true;
  5266. },
  5267. /* Pop-up the date picker for a given input field.
  5268. * If false returned from beforeShow event handler do not show.
  5269. * @param input element - the input field attached to the date picker or
  5270. * event - if triggered by focus
  5271. */
  5272. _showDatepicker: function(input) {
  5273. input = input.target || input;
  5274. if (input.nodeName.toLowerCase() !== "input") { // find from button/image trigger
  5275. input = $("input", input.parentNode)[0];
  5276. }
  5277. if ($.datepicker._isDisabledDatepicker(input) || $.datepicker._lastInput === input) { // already here
  5278. return;
  5279. }
  5280. var inst, beforeShow, beforeShowSettings, isFixed,
  5281. offset, showAnim, duration;
  5282. inst = $.datepicker._getInst(input);
  5283. if ($.datepicker._curInst && $.datepicker._curInst !== inst) {
  5284. $.datepicker._curInst.dpDiv.stop(true, true);
  5285. if ( inst && $.datepicker._datepickerShowing ) {
  5286. $.datepicker._hideDatepicker( $.datepicker._curInst.input[0] );
  5287. }
  5288. }
  5289. beforeShow = $.datepicker._get(inst, "beforeShow");
  5290. beforeShowSettings = beforeShow ? beforeShow.apply(input, [input, inst]) : {};
  5291. if(beforeShowSettings === false){
  5292. return;
  5293. }
  5294. datepicker_extendRemove(inst.settings, beforeShowSettings);
  5295. inst.lastVal = null;
  5296. $.datepicker._lastInput = input;
  5297. $.datepicker._setDateFromField(inst);
  5298. if ($.datepicker._inDialog) { // hide cursor
  5299. input.value = "";
  5300. }
  5301. if (!$.datepicker._pos) { // position below input
  5302. $.datepicker._pos = $.datepicker._findPos(input);
  5303. $.datepicker._pos[1] += input.offsetHeight; // add the height
  5304. }
  5305. isFixed = false;
  5306. $(input).parents().each(function() {
  5307. isFixed |= $(this).css("position") === "fixed";
  5308. return !isFixed;
  5309. });
  5310. offset = {left: $.datepicker._pos[0], top: $.datepicker._pos[1]};
  5311. $.datepicker._pos = null;
  5312. //to avoid flashes on Firefox
  5313. inst.dpDiv.empty();
  5314. // determine sizing offscreen
  5315. inst.dpDiv.css({position: "absolute", display: "block", top: "-1000px"});
  5316. $.datepicker._updateDatepicker(inst);
  5317. // fix width for dynamic number of date pickers
  5318. // and adjust position before showing
  5319. offset = $.datepicker._checkOffset(inst, offset, isFixed);
  5320. inst.dpDiv.css({position: ($.datepicker._inDialog && $.blockUI ?
  5321. "static" : (isFixed ? "fixed" : "absolute")), display: "none",
  5322. left: offset.left + "px", top: offset.top + "px"});
  5323. if (!inst.inline) {
  5324. showAnim = $.datepicker._get(inst, "showAnim");
  5325. duration = $.datepicker._get(inst, "duration");
  5326. inst.dpDiv.css( "z-index", datepicker_getZindex( $( input ) ) + 1 );
  5327. $.datepicker._datepickerShowing = true;
  5328. if ( $.effects && $.effects.effect[ showAnim ] ) {
  5329. inst.dpDiv.show(showAnim, $.datepicker._get(inst, "showOptions"), duration);
  5330. } else {
  5331. inst.dpDiv[showAnim || "show"](showAnim ? duration : null);
  5332. }
  5333. if ( $.datepicker._shouldFocusInput( inst ) ) {
  5334. inst.input.focus();
  5335. }
  5336. $.datepicker._curInst = inst;
  5337. }
  5338. },
  5339. /* Generate the date picker content. */
  5340. _updateDatepicker: function(inst) {
  5341. this.maxRows = 4; //Reset the max number of rows being displayed (see #7043)
  5342. datepicker_instActive = inst; // for delegate hover events
  5343. inst.dpDiv.empty().append(this._generateHTML(inst));
  5344. this._attachHandlers(inst);
  5345. var origyearshtml,
  5346. numMonths = this._getNumberOfMonths(inst),
  5347. cols = numMonths[1],
  5348. width = 17,
  5349. activeCell = inst.dpDiv.find( "." + this._dayOverClass + " a" );
  5350. if ( activeCell.length > 0 ) {
  5351. datepicker_handleMouseover.apply( activeCell.get( 0 ) );
  5352. }
  5353. inst.dpDiv.removeClass("ui-datepicker-multi-2 ui-datepicker-multi-3 ui-datepicker-multi-4").width("");
  5354. if (cols > 1) {
  5355. inst.dpDiv.addClass("ui-datepicker-multi-" + cols).css("width", (width * cols) + "em");
  5356. }
  5357. inst.dpDiv[(numMonths[0] !== 1 || numMonths[1] !== 1 ? "add" : "remove") +
  5358. "Class"]("ui-datepicker-multi");
  5359. inst.dpDiv[(this._get(inst, "isRTL") ? "add" : "remove") +
  5360. "Class"]("ui-datepicker-rtl");
  5361. if (inst === $.datepicker._curInst && $.datepicker._datepickerShowing && $.datepicker._shouldFocusInput( inst ) ) {
  5362. inst.input.focus();
  5363. }
  5364. // deffered render of the years select (to avoid flashes on Firefox)
  5365. if( inst.yearshtml ){
  5366. origyearshtml = inst.yearshtml;
  5367. setTimeout(function(){
  5368. //assure that inst.yearshtml didn't change.
  5369. if( origyearshtml === inst.yearshtml && inst.yearshtml ){
  5370. inst.dpDiv.find("select.ui-datepicker-year:first").replaceWith(inst.yearshtml);
  5371. }
  5372. origyearshtml = inst.yearshtml = null;
  5373. }, 0);
  5374. }
  5375. var afterUpdate = this._get(inst, "afterUpdate");
  5376. if(afterUpdate)
  5377. afterUpdate.apply((inst.input ? inst.input[0] : null), [inst]);
  5378. },
  5379. // #6694 - don't focus the input if it's already focused
  5380. // this breaks the change event in IE
  5381. // Support: IE and jQuery <1.9
  5382. _shouldFocusInput: function( inst ) {
  5383. return inst.input && inst.input.is( ":visible" ) && !inst.input.is( ":disabled" ) && !inst.input.is( ":focus" );
  5384. },
  5385. /* Check positioning to remain on screen. */
  5386. _checkOffset: function(inst, offset, isFixed) {
  5387. var dpWidth = inst.dpDiv.outerWidth(),
  5388. dpHeight = inst.dpDiv.outerHeight(),
  5389. inputWidth = inst.input ? inst.input.outerWidth() : 0,
  5390. inputHeight = inst.input ? inst.input.outerHeight() : 0,
  5391. viewWidth = document.documentElement.clientWidth + (isFixed ? 0 : $(document).scrollLeft()),
  5392. viewHeight = document.documentElement.clientHeight + (isFixed ? 0 : $(document).scrollTop());
  5393. offset.left -= (this._get(inst, "isRTL") ? (dpWidth - inputWidth) : 0);
  5394. offset.left -= (isFixed && offset.left === inst.input.offset().left) ? $(document).scrollLeft() : 0;
  5395. offset.top -= (isFixed && offset.top === (inst.input.offset().top + inputHeight)) ? $(document).scrollTop() : 0;
  5396. // now check if datepicker is showing outside window viewport - move to a better place if so.
  5397. offset.left -= Math.min(offset.left, (offset.left + dpWidth > viewWidth && viewWidth > dpWidth) ?
  5398. Math.abs(offset.left + dpWidth - viewWidth) : 0);
  5399. offset.top -= Math.min(offset.top, (offset.top + dpHeight > viewHeight && viewHeight > dpHeight) ?
  5400. Math.abs(dpHeight + inputHeight) : 0);
  5401. return offset;
  5402. },
  5403. /* Find an object's position on the screen. */
  5404. _findPos: function(obj) {
  5405. var position,
  5406. inst = this._getInst(obj),
  5407. isRTL = this._get(inst, "isRTL");
  5408. while (obj && (obj.type === "hidden" || obj.nodeType !== 1 || $.expr.filters.hidden(obj))) {
  5409. obj = obj[isRTL ? "previousSibling" : "nextSibling"];
  5410. }
  5411. position = $(obj).offset();
  5412. return [position.left, position.top];
  5413. },
  5414. /* Hide the date picker from view.
  5415. * @param input element - the input field attached to the date picker
  5416. */
  5417. _hideDatepicker: function(input) {
  5418. var showAnim, duration, postProcess, onClose,
  5419. inst = this._curInst;
  5420. if (!inst || (input && inst !== $.data(input, "datepicker"))) {
  5421. return;
  5422. }
  5423. if (this._datepickerShowing) {
  5424. showAnim = this._get(inst, "showAnim");
  5425. duration = this._get(inst, "duration");
  5426. postProcess = function() {
  5427. $.datepicker._tidyDialog(inst);
  5428. };
  5429. // DEPRECATED: after BC for 1.8.x $.effects[ showAnim ] is not needed
  5430. if ( $.effects && ( $.effects.effect[ showAnim ] || $.effects[ showAnim ] ) ) {
  5431. inst.dpDiv.hide(showAnim, $.datepicker._get(inst, "showOptions"), duration, postProcess);
  5432. } else {
  5433. inst.dpDiv[(showAnim === "slideDown" ? "slideUp" :
  5434. (showAnim === "fadeIn" ? "fadeOut" : "hide"))]((showAnim ? duration : null), postProcess);
  5435. }
  5436. if (!showAnim) {
  5437. postProcess();
  5438. }
  5439. this._datepickerShowing = false;
  5440. onClose = this._get(inst, "onClose");
  5441. if (onClose) {
  5442. onClose.apply((inst.input ? inst.input[0] : null), [(inst.input ? inst.input.val() : ""), inst]);
  5443. }
  5444. this._lastInput = null;
  5445. if (this._inDialog) {
  5446. this._dialogInput.css({ position: "absolute", left: "0", top: "-100px" });
  5447. if ($.blockUI) {
  5448. $.unblockUI();
  5449. $("body").append(this.dpDiv);
  5450. }
  5451. }
  5452. this._inDialog = false;
  5453. }
  5454. },
  5455. /* Tidy up after a dialog display. */
  5456. _tidyDialog: function(inst) {
  5457. inst.dpDiv.removeClass(this._dialogClass).unbind(".ui-datepicker-calendar");
  5458. },
  5459. /* Close date picker if clicked elsewhere. */
  5460. _checkExternalClick: function(event) {
  5461. if (!$.datepicker._curInst) {
  5462. return;
  5463. }
  5464. var $target = $(event.target),
  5465. inst = $.datepicker._getInst($target[0]);
  5466. if ( ( ( $target[0].id !== $.datepicker._mainDivId &&
  5467. $target.parents("#" + $.datepicker._mainDivId).length === 0 &&
  5468. !$target.hasClass($.datepicker.markerClassName) &&
  5469. !$target.closest("." + $.datepicker._triggerClass).length &&
  5470. $.datepicker._datepickerShowing && !($.datepicker._inDialog && $.blockUI) ) ) ||
  5471. ( $target.hasClass($.datepicker.markerClassName) && $.datepicker._curInst !== inst ) ) {
  5472. $.datepicker._hideDatepicker();
  5473. }
  5474. },
  5475. /* Adjust one of the date sub-fields. */
  5476. _adjustDate: function(id, offset, period) {
  5477. var target = $(id),
  5478. inst = this._getInst(target[0]);
  5479. if (this._isDisabledDatepicker(target[0])) {
  5480. return;
  5481. }
  5482. this._adjustInstDate(inst, offset +
  5483. (period === "M" ? this._get(inst, "showCurrentAtPos") : 0), // undo positioning
  5484. period);
  5485. this._updateDatepicker(inst);
  5486. },
  5487. /* Action for current link. */
  5488. _gotoToday: function(id) {
  5489. var date,
  5490. target = $(id),
  5491. inst = this._getInst(target[0]);
  5492. if (this._get(inst, "gotoCurrent") && inst.currentDay) {
  5493. inst.selectedDay = inst.currentDay;
  5494. inst.drawMonth = inst.selectedMonth = inst.currentMonth;
  5495. inst.drawYear = inst.selectedYear = inst.currentYear;
  5496. } else {
  5497. date = new Date();
  5498. inst.selectedDay = date.getDate();
  5499. inst.drawMonth = inst.selectedMonth = date.getMonth();
  5500. inst.drawYear = inst.selectedYear = date.getFullYear();
  5501. }
  5502. this._notifyChange(inst);
  5503. this._adjustDate(target);
  5504. },
  5505. /* Action for selecting a new month/year. */
  5506. _selectMonthYear: function(id, select, period) {
  5507. var target = $(id),
  5508. inst = this._getInst(target[0]);
  5509. inst["selected" + (period === "M" ? "Month" : "Year")] =
  5510. inst["draw" + (period === "M" ? "Month" : "Year")] =
  5511. parseInt(select.options[select.selectedIndex].value,10);
  5512. this._notifyChange(inst);
  5513. this._adjustDate(target);
  5514. },
  5515. /* Action for selecting a day. */
  5516. _selectDay: function(id, month, year, td) {
  5517. var inst,
  5518. target = $(id);
  5519. if ($(td).hasClass(this._unselectableClass) || this._isDisabledDatepicker(target[0])) {
  5520. return;
  5521. }
  5522. inst = this._getInst(target[0]);
  5523. inst.selectedDay = inst.currentDay = $("a", td).html();
  5524. inst.selectedMonth = inst.currentMonth = month;
  5525. inst.selectedYear = inst.currentYear = year;
  5526. this._selectDate(id, this._formatDate(inst,
  5527. inst.currentDay, inst.currentMonth, inst.currentYear));
  5528. },
  5529. /* Erase the input field and hide the date picker. */
  5530. _clearDate: function(id) {
  5531. var target = $(id);
  5532. this._selectDate(target, "");
  5533. },
  5534. /* Update the input field with the selected date. */
  5535. _selectDate: function(id, dateStr) {
  5536. var onSelect,
  5537. target = $(id),
  5538. inst = this._getInst(target[0]);
  5539. dateStr = (dateStr != null ? dateStr : this._formatDate(inst));
  5540. if (inst.input) {
  5541. inst.input.val(dateStr);
  5542. }
  5543. this._updateAlternate(inst);
  5544. onSelect = this._get(inst, "onSelect");
  5545. if (onSelect) {
  5546. onSelect.apply((inst.input ? inst.input[0] : null), [dateStr, inst]); // trigger custom callback
  5547. } else if (inst.input) {
  5548. inst.input.trigger("change"); // fire the change event
  5549. }
  5550. if (inst.inline){
  5551. this._updateDatepicker(inst);
  5552. } else {
  5553. this._hideDatepicker();
  5554. this._lastInput = inst.input[0];
  5555. if (typeof(inst.input[0]) !== "object") {
  5556. inst.input.focus(); // restore focus
  5557. }
  5558. this._lastInput = null;
  5559. }
  5560. },
  5561. /* Update any alternate field to synchronise with the main field. */
  5562. _updateAlternate: function(inst) {
  5563. var altFormat, date, dateStr,
  5564. altField = this._get(inst, "altField");
  5565. if (altField) { // update alternate field too
  5566. altFormat = this._get(inst, "altFormat") || this._get(inst, "dateFormat");
  5567. date = this._getDate(inst);
  5568. dateStr = this.formatDate(altFormat, date, this._getFormatConfig(inst));
  5569. $(altField).each(function() { $(this).val(dateStr); });
  5570. }
  5571. },
  5572. /* Set as beforeShowDay function to prevent selection of weekends.
  5573. * @param date Date - the date to customise
  5574. * @return [boolean, string] - is this date selectable?, what is its CSS class?
  5575. */
  5576. noWeekends: function(date) {
  5577. var day = date.getDay();
  5578. return [(day > 0 && day < 6), ""];
  5579. },
  5580. /* Set as calculateWeek to determine the week of the year based on the ISO 8601 definition.
  5581. * @param date Date - the date to get the week for
  5582. * @return number - the number of the week within the year that contains this date
  5583. */
  5584. iso8601Week: function(date) {
  5585. var time,
  5586. checkDate = new Date(date.getTime());
  5587. // Find Thursday of this week starting on Monday
  5588. checkDate.setDate(checkDate.getDate() + 4 - (checkDate.getDay() || 7));
  5589. time = checkDate.getTime();
  5590. checkDate.setMonth(0); // Compare with Jan 1
  5591. checkDate.setDate(1);
  5592. return Math.floor(Math.round((time - checkDate) / 86400000) / 7) + 1;
  5593. },
  5594. /* Parse a string value into a date object.
  5595. * See formatDate below for the possible formats.
  5596. *
  5597. * @param format string - the expected format of the date
  5598. * @param value string - the date in the above format
  5599. * @param settings Object - attributes include:
  5600. * shortYearCutoff number - the cutoff year for determining the century (optional)
  5601. * dayNamesShort string[7] - abbreviated names of the days from Sunday (optional)
  5602. * dayNames string[7] - names of the days from Sunday (optional)
  5603. * monthNamesShort string[12] - abbreviated names of the months (optional)
  5604. * monthNames string[12] - names of the months (optional)
  5605. * @return Date - the extracted date value or null if value is blank
  5606. */
  5607. parseDate: function (format, value, settings) {
  5608. if (format == null || value == null) {
  5609. throw "Invalid arguments";
  5610. }
  5611. value = (typeof value === "object" ? value.toString() : value + "");
  5612. if (value === "") {
  5613. return null;
  5614. }
  5615. var iFormat, dim, extra,
  5616. iValue = 0,
  5617. shortYearCutoffTemp = (settings ? settings.shortYearCutoff : null) || this._defaults.shortYearCutoff,
  5618. shortYearCutoff = (typeof shortYearCutoffTemp !== "string" ? shortYearCutoffTemp :
  5619. new Date().getFullYear() % 100 + parseInt(shortYearCutoffTemp, 10)),
  5620. dayNamesShort = (settings ? settings.dayNamesShort : null) || this._defaults.dayNamesShort,
  5621. dayNames = (settings ? settings.dayNames : null) || this._defaults.dayNames,
  5622. monthNamesShort = (settings ? settings.monthNamesShort : null) || this._defaults.monthNamesShort,
  5623. monthNames = (settings ? settings.monthNames : null) || this._defaults.monthNames,
  5624. year = -1,
  5625. month = -1,
  5626. day = -1,
  5627. doy = -1,
  5628. literal = false,
  5629. date,
  5630. // Check whether a format character is doubled
  5631. lookAhead = function(match) {
  5632. var matches = (iFormat + 1 < format.length && format.charAt(iFormat + 1) === match);
  5633. if (matches) {
  5634. iFormat++;
  5635. }
  5636. return matches;
  5637. },
  5638. // Extract a number from the string value
  5639. getNumber = function(match) {
  5640. var isDoubled = lookAhead(match),
  5641. size = (match === "@" ? 14 : (match === "!" ? 20 :
  5642. (match === "y" && isDoubled ? 4 : (match === "o" ? 3 : 2)))),
  5643. minSize = (match === "y" ? size : 1),
  5644. digits = new RegExp("^\\d{" + minSize + "," + size + "}"),
  5645. num = value.substring(iValue).match(digits);
  5646. if (!num) {
  5647. throw "Missing number at position " + iValue;
  5648. }
  5649. iValue += num[0].length;
  5650. return parseInt(num[0], 10);
  5651. },
  5652. // Extract a name from the string value and convert to an index
  5653. getName = function(match, shortNames, longNames) {
  5654. var index = -1,
  5655. names = $.map(lookAhead(match) ? longNames : shortNames, function (v, k) {
  5656. return [ [k, v] ];
  5657. }).sort(function (a, b) {
  5658. return -(a[1].length - b[1].length);
  5659. });
  5660. $.each(names, function (i, pair) {
  5661. var name = pair[1];
  5662. if (value.substr(iValue, name.length).toLowerCase() === name.toLowerCase()) {
  5663. index = pair[0];
  5664. iValue += name.length;
  5665. return false;
  5666. }
  5667. });
  5668. if (index !== -1) {
  5669. return index + 1;
  5670. } else {
  5671. throw "Unknown name at position " + iValue;
  5672. }
  5673. },
  5674. // Confirm that a literal character matches the string value
  5675. checkLiteral = function() {
  5676. if (value.charAt(iValue) !== format.charAt(iFormat)) {
  5677. throw "Unexpected literal at position " + iValue;
  5678. }
  5679. iValue++;
  5680. };
  5681. for (iFormat = 0; iFormat < format.length; iFormat++) {
  5682. if (literal) {
  5683. if (format.charAt(iFormat) === "'" && !lookAhead("'")) {
  5684. literal = false;
  5685. } else {
  5686. checkLiteral();
  5687. }
  5688. } else {
  5689. switch (format.charAt(iFormat)) {
  5690. case "d":
  5691. day = getNumber("d");
  5692. break;
  5693. case "D":
  5694. getName("D", dayNamesShort, dayNames);
  5695. break;
  5696. case "o":
  5697. doy = getNumber("o");
  5698. break;
  5699. case "m":
  5700. month = getNumber("m");
  5701. break;
  5702. case "M":
  5703. month = getName("M", monthNamesShort, monthNames);
  5704. break;
  5705. case "y":
  5706. year = getNumber("y");
  5707. break;
  5708. case "@":
  5709. date = new Date(getNumber("@"));
  5710. year = date.getFullYear();
  5711. month = date.getMonth() + 1;
  5712. day = date.getDate();
  5713. break;
  5714. case "!":
  5715. date = new Date((getNumber("!") - this._ticksTo1970) / 10000);
  5716. year = date.getFullYear();
  5717. month = date.getMonth() + 1;
  5718. day = date.getDate();
  5719. break;
  5720. case "'":
  5721. if (lookAhead("'")){
  5722. checkLiteral();
  5723. } else {
  5724. literal = true;
  5725. }
  5726. break;
  5727. default:
  5728. checkLiteral();
  5729. }
  5730. }
  5731. }
  5732. if (iValue < value.length){
  5733. extra = value.substr(iValue);
  5734. if (!/^\s+/.test(extra)) {
  5735. throw "Extra/unparsed characters found in date: " + extra;
  5736. }
  5737. }
  5738. if (year === -1) {
  5739. year = new Date().getFullYear();
  5740. } else if (year < 100) {
  5741. year += new Date().getFullYear() - new Date().getFullYear() % 100 +
  5742. (year <= shortYearCutoff ? 0 : -100);
  5743. }
  5744. if (doy > -1) {
  5745. month = 1;
  5746. day = doy;
  5747. do {
  5748. dim = this._getDaysInMonth(year, month - 1);
  5749. if (day <= dim) {
  5750. break;
  5751. }
  5752. month++;
  5753. day -= dim;
  5754. } while (true);
  5755. }
  5756. date = this._daylightSavingAdjust(new Date(year, month - 1, day));
  5757. if (date.getFullYear() !== year || date.getMonth() + 1 !== month || date.getDate() !== day) {
  5758. throw "Invalid date"; // E.g. 31/02/00
  5759. }
  5760. return date;
  5761. },
  5762. /* Standard date formats. */
  5763. ATOM: "yy-mm-dd", // RFC 3339 (ISO 8601)
  5764. COOKIE: "D, dd M yy",
  5765. ISO_8601: "yy-mm-dd",
  5766. RFC_822: "D, d M y",
  5767. RFC_850: "DD, dd-M-y",
  5768. RFC_1036: "D, d M y",
  5769. RFC_1123: "D, d M yy",
  5770. RFC_2822: "D, d M yy",
  5771. RSS: "D, d M y", // RFC 822
  5772. TICKS: "!",
  5773. TIMESTAMP: "@",
  5774. W3C: "yy-mm-dd", // ISO 8601
  5775. _ticksTo1970: (((1970 - 1) * 365 + Math.floor(1970 / 4) - Math.floor(1970 / 100) +
  5776. Math.floor(1970 / 400)) * 24 * 60 * 60 * 10000000),
  5777. /* Format a date object into a string value.
  5778. * The format can be combinations of the following:
  5779. * d - day of month (no leading zero)
  5780. * dd - day of month (two digit)
  5781. * o - day of year (no leading zeros)
  5782. * oo - day of year (three digit)
  5783. * D - day name short
  5784. * DD - day name long
  5785. * m - month of year (no leading zero)
  5786. * mm - month of year (two digit)
  5787. * M - month name short
  5788. * MM - month name long
  5789. * y - year (two digit)
  5790. * yy - year (four digit)
  5791. * @ - Unix timestamp (ms since 01/01/1970)
  5792. * ! - Windows ticks (100ns since 01/01/0001)
  5793. * "..." - literal text
  5794. * '' - single quote
  5795. *
  5796. * @param format string - the desired format of the date
  5797. * @param date Date - the date value to format
  5798. * @param settings Object - attributes include:
  5799. * dayNamesShort string[7] - abbreviated names of the days from Sunday (optional)
  5800. * dayNames string[7] - names of the days from Sunday (optional)
  5801. * monthNamesShort string[12] - abbreviated names of the months (optional)
  5802. * monthNames string[12] - names of the months (optional)
  5803. * @return string - the date in the above format
  5804. */
  5805. formatDate: function (format, date, settings) {
  5806. if (!date) {
  5807. return "";
  5808. }
  5809. var iFormat,
  5810. dayNamesShort = (settings ? settings.dayNamesShort : null) || this._defaults.dayNamesShort,
  5811. dayNames = (settings ? settings.dayNames : null) || this._defaults.dayNames,
  5812. monthNamesShort = (settings ? settings.monthNamesShort : null) || this._defaults.monthNamesShort,
  5813. monthNames = (settings ? settings.monthNames : null) || this._defaults.monthNames,
  5814. // Check whether a format character is doubled
  5815. lookAhead = function(match) {
  5816. var matches = (iFormat + 1 < format.length && format.charAt(iFormat + 1) === match);
  5817. if (matches) {
  5818. iFormat++;
  5819. }
  5820. return matches;
  5821. },
  5822. // Format a number, with leading zero if necessary
  5823. formatNumber = function(match, value, len) {
  5824. var num = "" + value;
  5825. if (lookAhead(match)) {
  5826. while (num.length < len) {
  5827. num = "0" + num;
  5828. }
  5829. }
  5830. return num;
  5831. },
  5832. // Format a name, short or long as requested
  5833. formatName = function(match, value, shortNames, longNames) {
  5834. return (lookAhead(match) ? longNames[value] : shortNames[value]);
  5835. },
  5836. output = "",
  5837. literal = false;
  5838. if (date) {
  5839. for (iFormat = 0; iFormat < format.length; iFormat++) {
  5840. if (literal) {
  5841. if (format.charAt(iFormat) === "'" && !lookAhead("'")) {
  5842. literal = false;
  5843. } else {
  5844. output += format.charAt(iFormat);
  5845. }
  5846. } else {
  5847. switch (format.charAt(iFormat)) {
  5848. case "d":
  5849. output += formatNumber("d", date.getDate(), 2);
  5850. break;
  5851. case "D":
  5852. output += formatName("D", date.getDay(), dayNamesShort, dayNames);
  5853. break;
  5854. case "o":
  5855. output += formatNumber("o",
  5856. Math.round((new Date(date.getFullYear(), date.getMonth(), date.getDate()).getTime() - new Date(date.getFullYear(), 0, 0).getTime()) / 86400000), 3);
  5857. break;
  5858. case "m":
  5859. output += formatNumber("m", date.getMonth() + 1, 2);
  5860. break;
  5861. case "M":
  5862. output += formatName("M", date.getMonth(), monthNamesShort, monthNames);
  5863. break;
  5864. case "y":
  5865. output += (lookAhead("y") ? date.getFullYear() :
  5866. (date.getYear() % 100 < 10 ? "0" : "") + date.getYear() % 100);
  5867. break;
  5868. case "@":
  5869. output += date.getTime();
  5870. break;
  5871. case "!":
  5872. output += date.getTime() * 10000 + this._ticksTo1970;
  5873. break;
  5874. case "'":
  5875. if (lookAhead("'")) {
  5876. output += "'";
  5877. } else {
  5878. literal = true;
  5879. }
  5880. break;
  5881. default:
  5882. output += format.charAt(iFormat);
  5883. }
  5884. }
  5885. }
  5886. }
  5887. return output;
  5888. },
  5889. /* Extract all possible characters from the date format. */
  5890. _possibleChars: function (format) {
  5891. var iFormat,
  5892. chars = "",
  5893. literal = false,
  5894. // Check whether a format character is doubled
  5895. lookAhead = function(match) {
  5896. var matches = (iFormat + 1 < format.length && format.charAt(iFormat + 1) === match);
  5897. if (matches) {
  5898. iFormat++;
  5899. }
  5900. return matches;
  5901. };
  5902. for (iFormat = 0; iFormat < format.length; iFormat++) {
  5903. if (literal) {
  5904. if (format.charAt(iFormat) === "'" && !lookAhead("'")) {
  5905. literal = false;
  5906. } else {
  5907. chars += format.charAt(iFormat);
  5908. }
  5909. } else {
  5910. switch (format.charAt(iFormat)) {
  5911. case "d": case "m": case "y": case "@":
  5912. chars += "0123456789";
  5913. break;
  5914. case "D": case "M":
  5915. return null; // Accept anything
  5916. case "'":
  5917. if (lookAhead("'")) {
  5918. chars += "'";
  5919. } else {
  5920. literal = true;
  5921. }
  5922. break;
  5923. default:
  5924. chars += format.charAt(iFormat);
  5925. }
  5926. }
  5927. }
  5928. return chars;
  5929. },
  5930. /* Get a setting value, defaulting if necessary. */
  5931. _get: function(inst, name) {
  5932. return inst.settings[name] !== undefined ?
  5933. inst.settings[name] : this._defaults[name];
  5934. },
  5935. /* Parse existing date and initialise date picker. */
  5936. _setDateFromField: function(inst, noDefault) {
  5937. if (inst.input.val() === inst.lastVal) {
  5938. return;
  5939. }
  5940. var dateFormat = this._get(inst, "dateFormat"),
  5941. dates = inst.lastVal = inst.input ? inst.input.val() : null,
  5942. defaultDate = this._getDefaultDate(inst),
  5943. date = defaultDate,
  5944. settings = this._getFormatConfig(inst);
  5945. try {
  5946. date = this.parseDate(dateFormat, dates, settings) || defaultDate;
  5947. } catch (event) {
  5948. dates = (noDefault ? "" : dates);
  5949. }
  5950. inst.selectedDay = date.getDate();
  5951. inst.drawMonth = inst.selectedMonth = date.getMonth();
  5952. inst.drawYear = inst.selectedYear = date.getFullYear();
  5953. inst.currentDay = (dates ? date.getDate() : 0);
  5954. inst.currentMonth = (dates ? date.getMonth() : 0);
  5955. inst.currentYear = (dates ? date.getFullYear() : 0);
  5956. this._adjustInstDate(inst);
  5957. },
  5958. /* Retrieve the default date shown on opening. */
  5959. _getDefaultDate: function(inst) {
  5960. return this._restrictMinMax(inst,
  5961. this._determineDate(inst, this._get(inst, "defaultDate"), new Date()));
  5962. },
  5963. /* A date may be specified as an exact value or a relative one. */
  5964. _determineDate: function(inst, date, defaultDate) {
  5965. var offsetNumeric = function(offset) {
  5966. var date = new Date();
  5967. date.setDate(date.getDate() + offset);
  5968. return date;
  5969. },
  5970. offsetString = function(offset) {
  5971. try {
  5972. return $.datepicker.parseDate($.datepicker._get(inst, "dateFormat"),
  5973. offset, $.datepicker._getFormatConfig(inst));
  5974. }
  5975. catch (e) {
  5976. // Ignore
  5977. }
  5978. var date = (offset.toLowerCase().match(/^c/) ?
  5979. $.datepicker._getDate(inst) : null) || new Date(),
  5980. year = date.getFullYear(),
  5981. month = date.getMonth(),
  5982. day = date.getDate(),
  5983. pattern = /([+\-]?[0-9]+)\s*(d|D|w|W|m|M|y|Y)?/g,
  5984. matches = pattern.exec(offset);
  5985. while (matches) {
  5986. switch (matches[2] || "d") {
  5987. case "d" : case "D" :
  5988. day += parseInt(matches[1],10); break;
  5989. case "w" : case "W" :
  5990. day += parseInt(matches[1],10) * 7; break;
  5991. case "m" : case "M" :
  5992. month += parseInt(matches[1],10);
  5993. day = Math.min(day, $.datepicker._getDaysInMonth(year, month));
  5994. break;
  5995. case "y": case "Y" :
  5996. year += parseInt(matches[1],10);
  5997. day = Math.min(day, $.datepicker._getDaysInMonth(year, month));
  5998. break;
  5999. }
  6000. matches = pattern.exec(offset);
  6001. }
  6002. return new Date(year, month, day);
  6003. },
  6004. newDate = (date == null || date === "" ? defaultDate : (typeof date === "string" ? offsetString(date) :
  6005. (typeof date === "number" ? (isNaN(date) ? defaultDate : offsetNumeric(date)) : new Date(date.getTime()))));
  6006. newDate = (newDate && newDate.toString() === "Invalid Date" ? defaultDate : newDate);
  6007. if (newDate) {
  6008. newDate.setHours(0);
  6009. newDate.setMinutes(0);
  6010. newDate.setSeconds(0);
  6011. newDate.setMilliseconds(0);
  6012. }
  6013. return this._daylightSavingAdjust(newDate);
  6014. },
  6015. /* Handle switch to/from daylight saving.
  6016. * Hours may be non-zero on daylight saving cut-over:
  6017. * > 12 when midnight changeover, but then cannot generate
  6018. * midnight datetime, so jump to 1AM, otherwise reset.
  6019. * @param date (Date) the date to check
  6020. * @return (Date) the corrected date
  6021. */
  6022. _daylightSavingAdjust: function(date) {
  6023. if (!date) {
  6024. return null;
  6025. }
  6026. date.setHours(date.getHours() > 12 ? date.getHours() + 2 : 0);
  6027. return date;
  6028. },
  6029. /* Set the date(s) directly. */
  6030. _setDate: function(inst, date, noChange) {
  6031. var clear = !date,
  6032. origMonth = inst.selectedMonth,
  6033. origYear = inst.selectedYear,
  6034. newDate = this._restrictMinMax(inst, this._determineDate(inst, date, new Date()));
  6035. inst.selectedDay = inst.currentDay = newDate.getDate();
  6036. inst.drawMonth = inst.selectedMonth = inst.currentMonth = newDate.getMonth();
  6037. inst.drawYear = inst.selectedYear = inst.currentYear = newDate.getFullYear();
  6038. if ((origMonth !== inst.selectedMonth || origYear !== inst.selectedYear) && !noChange) {
  6039. this._notifyChange(inst);
  6040. }
  6041. this._adjustInstDate(inst);
  6042. if (inst.input) {
  6043. inst.input.val(clear ? "" : this._formatDate(inst));
  6044. }
  6045. },
  6046. /* Retrieve the date(s) directly. */
  6047. _getDate: function(inst) {
  6048. var startDate = (!inst.currentYear || (inst.input && inst.input.val() === "") ? null :
  6049. this._daylightSavingAdjust(new Date(
  6050. inst.currentYear, inst.currentMonth, inst.currentDay)));
  6051. return startDate;
  6052. },
  6053. /* Attach the onxxx handlers. These are declared statically so
  6054. * they work with static code transformers like Caja.
  6055. */
  6056. _attachHandlers: function(inst) {
  6057. var stepMonths = this._get(inst, "stepMonths"),
  6058. id = "#" + inst.id.replace( /\\\\/g, "\\" );
  6059. inst.dpDiv.find("[data-handler]").map(function () {
  6060. var handler = {
  6061. prev: function () {
  6062. $.datepicker._adjustDate(id, -stepMonths, "M");
  6063. },
  6064. next: function () {
  6065. $.datepicker._adjustDate(id, +stepMonths, "M");
  6066. },
  6067. hide: function () {
  6068. $.datepicker._hideDatepicker();
  6069. },
  6070. today: function () {
  6071. $.datepicker._gotoToday(id);
  6072. },
  6073. selectDay: function () {
  6074. $.datepicker._selectDay(id, +this.getAttribute("data-month"), +this.getAttribute("data-year"), this);
  6075. return false;
  6076. },
  6077. selectMonth: function () {
  6078. $.datepicker._selectMonthYear(id, this, "M");
  6079. return false;
  6080. },
  6081. selectYear: function () {
  6082. $.datepicker._selectMonthYear(id, this, "Y");
  6083. return false;
  6084. }
  6085. };
  6086. $(this).bind(this.getAttribute("data-event"), handler[this.getAttribute("data-handler")]);
  6087. });
  6088. },
  6089. /* Generate the HTML for the current state of the date picker. */
  6090. _generateHTML: function(inst) {
  6091. var maxDraw, prevText, prev, nextText, next, currentText, gotoDate,
  6092. controls, buttonPanel, firstDay, weekendDays, showWeek, dayNames, dayNamesMin,
  6093. monthNames, monthNamesShort, beforeShowDay, showOtherMonths,
  6094. selectOtherMonths, defaultDate, html, dow, row, group, col, selectedDate,
  6095. cornerClass, calender, thead, day, daysInMonth, leadDays, curRows, numRows,
  6096. printDate, dRow, tbody, daySettings, otherMonth, unselectable,
  6097. tempDate = new Date(),
  6098. today = this._daylightSavingAdjust(
  6099. new Date(tempDate.getFullYear(), tempDate.getMonth(), tempDate.getDate())), // clear time
  6100. isRTL = this._get(inst, "isRTL"),
  6101. showButtonPanel = this._get(inst, "showButtonPanel"),
  6102. hideIfNoPrevNext = this._get(inst, "hideIfNoPrevNext"),
  6103. navigationAsDateFormat = this._get(inst, "navigationAsDateFormat"),
  6104. numMonths = this._getNumberOfMonths(inst),
  6105. showCurrentAtPos = this._get(inst, "showCurrentAtPos"),
  6106. stepMonths = this._get(inst, "stepMonths"),
  6107. isMultiMonth = (numMonths[0] !== 1 || numMonths[1] !== 1),
  6108. currentDate = this._daylightSavingAdjust((!inst.currentDay ? new Date(9999, 9, 9) :
  6109. new Date(inst.currentYear, inst.currentMonth, inst.currentDay))),
  6110. minDate = this._getMinMaxDate(inst, "min"),
  6111. maxDate = this._getMinMaxDate(inst, "max"),
  6112. drawMonth = inst.drawMonth - showCurrentAtPos,
  6113. drawYear = inst.drawYear;
  6114. if (drawMonth < 0) {
  6115. drawMonth += 12;
  6116. drawYear--;
  6117. }
  6118. if (maxDate) {
  6119. maxDraw = this._daylightSavingAdjust(new Date(maxDate.getFullYear(),
  6120. maxDate.getMonth() - (numMonths[0] * numMonths[1]) + 1, maxDate.getDate()));
  6121. maxDraw = (minDate && maxDraw < minDate ? minDate : maxDraw);
  6122. while (this._daylightSavingAdjust(new Date(drawYear, drawMonth, 1)) > maxDraw) {
  6123. drawMonth--;
  6124. if (drawMonth < 0) {
  6125. drawMonth = 11;
  6126. drawYear--;
  6127. }
  6128. }
  6129. }
  6130. inst.drawMonth = drawMonth;
  6131. inst.drawYear = drawYear;
  6132. prevText = this._get(inst, "prevText");
  6133. prevText = (!navigationAsDateFormat ? prevText : this.formatDate(prevText,
  6134. this._daylightSavingAdjust(new Date(drawYear, drawMonth - stepMonths, 1)),
  6135. this._getFormatConfig(inst)));
  6136. prev = (this._canAdjustMonth(inst, -1, drawYear, drawMonth) ?
  6137. "<a class='ui-datepicker-prev ui-corner-all' data-handler='prev' data-event='click'" +
  6138. " title='" + prevText + "'><span class='ui-icon ui-icon-circle-triangle-" + ( isRTL ? "e" : "w") + "'>" + prevText + "</span></a>" :
  6139. (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>"));
  6140. nextText = this._get(inst, "nextText");
  6141. nextText = (!navigationAsDateFormat ? nextText : this.formatDate(nextText,
  6142. this._daylightSavingAdjust(new Date(drawYear, drawMonth + stepMonths, 1)),
  6143. this._getFormatConfig(inst)));
  6144. next = (this._canAdjustMonth(inst, +1, drawYear, drawMonth) ?
  6145. "<a class='ui-datepicker-next ui-corner-all' data-handler='next' data-event='click'" +
  6146. " title='" + nextText + "'><span class='ui-icon ui-icon-circle-triangle-" + ( isRTL ? "w" : "e") + "'>" + nextText + "</span></a>" :
  6147. (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>"));
  6148. currentText = this._get(inst, "currentText");
  6149. gotoDate = (this._get(inst, "gotoCurrent") && inst.currentDay ? currentDate : today);
  6150. currentText = (!navigationAsDateFormat ? currentText :
  6151. this.formatDate(currentText, gotoDate, this._getFormatConfig(inst)));
  6152. 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'>" +
  6153. this._get(inst, "closeText") + "</button>" : "");
  6154. buttonPanel = (showButtonPanel) ? "<div class='ui-datepicker-buttonpane ui-widget-content'>" + (isRTL ? controls : "") +
  6155. (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'" +
  6156. ">" + currentText + "</button>" : "") + (isRTL ? "" : controls) + "</div>" : "";
  6157. firstDay = parseInt(this._get(inst, "firstDay"),10);
  6158. firstDay = (isNaN(firstDay) ? 0 : firstDay);
  6159. weekendDays = this._get(inst, "weekendDays");
  6160. showWeek = this._get(inst, "showWeek");
  6161. dayNames = this._get(inst, "dayNames");
  6162. dayNamesMin = this._get(inst, "dayNamesMin");
  6163. monthNames = this._get(inst, "monthNames");
  6164. monthNamesShort = this._get(inst, "monthNamesShort");
  6165. beforeShowDay = this._get(inst, "beforeShowDay");
  6166. showOtherMonths = this._get(inst, "showOtherMonths");
  6167. selectOtherMonths = this._get(inst, "selectOtherMonths");
  6168. defaultDate = this._getDefaultDate(inst);
  6169. html = "";
  6170. dow;
  6171. for (row = 0; row < numMonths[0]; row++) {
  6172. group = "";
  6173. this.maxRows = 4;
  6174. for (col = 0; col < numMonths[1]; col++) {
  6175. selectedDate = this._daylightSavingAdjust(new Date(drawYear, drawMonth, inst.selectedDay));
  6176. cornerClass = " ui-corner-all";
  6177. calender = "";
  6178. if (isMultiMonth) {
  6179. calender += "<div class='ui-datepicker-group";
  6180. if (numMonths[1] > 1) {
  6181. switch (col) {
  6182. case 0: calender += " ui-datepicker-group-first";
  6183. cornerClass = " ui-corner-" + (isRTL ? "right" : "left"); break;
  6184. case numMonths[1]-1: calender += " ui-datepicker-group-last";
  6185. cornerClass = " ui-corner-" + (isRTL ? "left" : "right"); break;
  6186. default: calender += " ui-datepicker-group-middle"; cornerClass = ""; break;
  6187. }
  6188. }
  6189. calender += "'>";
  6190. }
  6191. calender += "<div class='ui-datepicker-header ui-widget-header ui-helper-clearfix" + cornerClass + "'>" +
  6192. (/all|left/.test(cornerClass) && row === 0 ? (isRTL ? next : prev) : "") +
  6193. (/all|right/.test(cornerClass) && row === 0 ? (isRTL ? prev : next) : "") +
  6194. this._generateMonthYearHeader(inst, drawMonth, drawYear, minDate, maxDate,
  6195. row > 0 || col > 0, monthNames, monthNamesShort) + // draw month headers
  6196. "</div><table class='ui-datepicker-calendar'><thead>" +
  6197. "<tr>";
  6198. thead = (showWeek ? "<th class='ui-datepicker-week-col'>" + this._get(inst, "weekHeader") + "</th>" : "");
  6199. for (dow = 0; dow < 7; dow++) { // days of the week
  6200. day = (dow + firstDay) % 7;
  6201. thead += "<th scope='col'" + (weekendDays.indexOf(day)!=-1 ? " class='ui-datepicker-week-end'" : "") + ">" +
  6202. "<span title='" + dayNames[day] + "'>" + dayNamesMin[day] + "</span></th>";
  6203. }
  6204. calender += thead + "</tr></thead><tbody>";
  6205. daysInMonth = this._getDaysInMonth(drawYear, drawMonth);
  6206. if (drawYear === inst.selectedYear && drawMonth === inst.selectedMonth) {
  6207. inst.selectedDay = Math.min(inst.selectedDay, daysInMonth);
  6208. }
  6209. leadDays = (this._getFirstDayOfMonth(drawYear, drawMonth) - firstDay + 7) % 7;
  6210. curRows = Math.ceil((leadDays + daysInMonth) / 7); // calculate the number of rows to generate
  6211. numRows = (isMultiMonth ? this.maxRows > curRows ? this.maxRows : curRows : curRows); //If multiple months, use the higher number of rows (see #7043)
  6212. this.maxRows = numRows;
  6213. printDate = this._daylightSavingAdjust(new Date(drawYear, drawMonth, 1 - leadDays));
  6214. for (dRow = 0; dRow < numRows; dRow++) { // create date picker rows
  6215. calender += "<tr>";
  6216. tbody = (!showWeek ? "" : "<td class='ui-datepicker-week-col'>" +
  6217. this._get(inst, "calculateWeek")(printDate) + "</td>");
  6218. for (dow = 0; dow < 7; dow++) { // create date picker days
  6219. daySettings = (beforeShowDay ?
  6220. beforeShowDay.apply((inst.input ? inst.input[0] : null), [printDate]) : [true, ""]);
  6221. otherMonth = (printDate.getMonth() !== drawMonth);
  6222. unselectable = (otherMonth && !selectOtherMonths) || !daySettings[0] ||
  6223. (minDate && printDate < minDate) || (maxDate && printDate > maxDate);
  6224. tbody += "<td class='" +
  6225. (weekendDays.indexOf((dow + firstDay) % 7)!=-1 ? " ui-datepicker-week-end" : "") + // highlight weekends
  6226. (otherMonth ? " ui-datepicker-other-month" : "") + // highlight days from other months
  6227. ((printDate.getTime() === selectedDate.getTime() && drawMonth === inst.selectedMonth && inst._keyEvent) || // user pressed key
  6228. (defaultDate.getTime() === printDate.getTime() && defaultDate.getTime() === selectedDate.getTime()) ?
  6229. // or defaultDate is current printedDate and defaultDate is selectedDate
  6230. " " + this._dayOverClass : "") + // highlight selected day
  6231. (unselectable ? " " + this._unselectableClass + " ui-state-disabled": "") + // highlight unselectable days
  6232. (otherMonth && !showOtherMonths ? "" : " " + daySettings[1] + // highlight custom dates
  6233. (printDate.getTime() === currentDate.getTime() ? " " + this._currentClass : "") + // highlight selected day
  6234. (printDate.getTime() === today.getTime() ? " ui-datepicker-today" : "")) + "'" + // highlight today (if different)
  6235. ((!otherMonth || showOtherMonths) && daySettings[2] ? " title='" + daySettings[2].replace(/'/g, "&#39;") + "'" : "") + // cell title
  6236. (unselectable ? "" : " data-handler='selectDay' data-event='click' data-month='" + printDate.getMonth() + "' data-year='" + printDate.getFullYear() + "'") + ">" + // actions
  6237. (otherMonth && !showOtherMonths ? "&#xa0;" : // display for other months
  6238. (unselectable ? "<span class='ui-state-default'>" + printDate.getDate() + "</span>" : "<a class='ui-state-default" +
  6239. (printDate.getTime() === today.getTime() ? " ui-state-highlight" : "") +
  6240. (printDate.getTime() === currentDate.getTime() ? " ui-state-active" : "") + // highlight selected day
  6241. (otherMonth ? " ui-priority-secondary" : "") + // distinguish dates from other months
  6242. "' href='#'>" + printDate.getDate() + "</a>")) + "</td>"; // display selectable date
  6243. printDate.setDate(printDate.getDate() + 1);
  6244. printDate = this._daylightSavingAdjust(printDate);
  6245. }
  6246. calender += tbody + "</tr>";
  6247. }
  6248. drawMonth++;
  6249. if (drawMonth > 11) {
  6250. drawMonth = 0;
  6251. drawYear++;
  6252. }
  6253. calender += "</tbody></table>" + (isMultiMonth ? "</div>" +
  6254. ((numMonths[0] > 0 && col === numMonths[1]-1) ? "<div class='ui-datepicker-row-break'></div>" : "") : "");
  6255. group += calender;
  6256. }
  6257. html += group;
  6258. }
  6259. html += buttonPanel;
  6260. inst._keyEvent = false;
  6261. return html;
  6262. },
  6263. /* Generate the month and year header. */
  6264. _generateMonthYearHeader: function(inst, drawMonth, drawYear, minDate, maxDate,
  6265. secondary, monthNames, monthNamesShort) {
  6266. var inMinYear, inMaxYear, month, years, thisYear, determineYear, year, endYear,
  6267. changeMonth = this._get(inst, "changeMonth"),
  6268. changeYear = this._get(inst, "changeYear"),
  6269. showMonthAfterYear = this._get(inst, "showMonthAfterYear"),
  6270. html = "<div class='ui-datepicker-title'>",
  6271. monthHtml = "";
  6272. // month selection
  6273. if (secondary || !changeMonth) {
  6274. monthHtml += "<span class='ui-datepicker-month'>" + monthNames[drawMonth] + "</span>";
  6275. } else {
  6276. inMinYear = (minDate && minDate.getFullYear() === drawYear);
  6277. inMaxYear = (maxDate && maxDate.getFullYear() === drawYear);
  6278. monthHtml += "<select class='ui-datepicker-month' data-handler='selectMonth' data-event='change'>";
  6279. for ( month = 0; month < 12; month++) {
  6280. if ((!inMinYear || month >= minDate.getMonth()) && (!inMaxYear || month <= maxDate.getMonth())) {
  6281. monthHtml += "<option value='" + month + "'" +
  6282. (month === drawMonth ? " selected='selected'" : "") +
  6283. ">" + monthNamesShort[month] + "</option>";
  6284. }
  6285. }
  6286. monthHtml += "</select>";
  6287. }
  6288. if (!showMonthAfterYear) {
  6289. html += monthHtml + (secondary || !(changeMonth && changeYear) ? "&#xa0;" : "");
  6290. }
  6291. // year selection
  6292. if ( !inst.yearshtml ) {
  6293. inst.yearshtml = "";
  6294. if (secondary || !changeYear) {
  6295. html += "<span class='ui-datepicker-year'>" + drawYear + "</span>";
  6296. } else {
  6297. // determine range of years to display
  6298. years = this._get(inst, "yearRange").split(":");
  6299. thisYear = new Date().getFullYear();
  6300. determineYear = function(value) {
  6301. var year = (value.match(/c[+\-].*/) ? drawYear + parseInt(value.substring(1), 10) :
  6302. (value.match(/[+\-].*/) ? thisYear + parseInt(value, 10) :
  6303. parseInt(value, 10)));
  6304. return (isNaN(year) ? thisYear : year);
  6305. };
  6306. year = determineYear(years[0]);
  6307. endYear = Math.max(year, determineYear(years[1] || ""));
  6308. year = (minDate ? Math.max(year, minDate.getFullYear()) : year);
  6309. endYear = (maxDate ? Math.min(endYear, maxDate.getFullYear()) : endYear);
  6310. inst.yearshtml += "<select class='ui-datepicker-year' data-handler='selectYear' data-event='change'>";
  6311. for (; year <= endYear; year++) {
  6312. inst.yearshtml += "<option value='" + year + "'" +
  6313. (year === drawYear ? " selected='selected'" : "") +
  6314. ">" + year + "</option>";
  6315. }
  6316. inst.yearshtml += "</select>";
  6317. html += inst.yearshtml;
  6318. inst.yearshtml = null;
  6319. }
  6320. }
  6321. html += this._get(inst, "yearSuffix");
  6322. if (showMonthAfterYear) {
  6323. html += (secondary || !(changeMonth && changeYear) ? "&#xa0;" : "") + monthHtml;
  6324. }
  6325. html += "</div>"; // Close datepicker_header
  6326. return html;
  6327. },
  6328. /* Adjust one of the date sub-fields. */
  6329. _adjustInstDate: function(inst, offset, period) {
  6330. var year = inst.drawYear + (period === "Y" ? offset : 0),
  6331. month = inst.drawMonth + (period === "M" ? offset : 0),
  6332. day = Math.min(inst.selectedDay, this._getDaysInMonth(year, month)) + (period === "D" ? offset : 0),
  6333. date = this._restrictMinMax(inst, this._daylightSavingAdjust(new Date(year, month, day)));
  6334. inst.selectedDay = date.getDate();
  6335. inst.drawMonth = inst.selectedMonth = date.getMonth();
  6336. inst.drawYear = inst.selectedYear = date.getFullYear();
  6337. if (period === "M" || period === "Y") {
  6338. this._notifyChange(inst);
  6339. }
  6340. },
  6341. /* Ensure a date is within any min/max bounds. */
  6342. _restrictMinMax: function(inst, date) {
  6343. var minDate = this._getMinMaxDate(inst, "min"),
  6344. maxDate = this._getMinMaxDate(inst, "max"),
  6345. newDate = (minDate && date < minDate ? minDate : date);
  6346. return (maxDate && newDate > maxDate ? maxDate : newDate);
  6347. },
  6348. /* Notify change of month/year. */
  6349. _notifyChange: function(inst) {
  6350. var onChange = this._get(inst, "onChangeMonthYear");
  6351. if (onChange) {
  6352. onChange.apply((inst.input ? inst.input[0] : null),
  6353. [inst.selectedYear, inst.selectedMonth + 1, inst]);
  6354. }
  6355. },
  6356. /* Determine the number of months to show. */
  6357. _getNumberOfMonths: function(inst) {
  6358. var numMonths = this._get(inst, "numberOfMonths");
  6359. return (numMonths == null ? [1, 1] : (typeof numMonths === "number" ? [1, numMonths] : numMonths));
  6360. },
  6361. /* Determine the current maximum date - ensure no time components are set. */
  6362. _getMinMaxDate: function(inst, minMax) {
  6363. return this._determineDate(inst, this._get(inst, minMax + "Date"), null);
  6364. },
  6365. /* Find the number of days in a given month. */
  6366. _getDaysInMonth: function(year, month) {
  6367. return 32 - this._daylightSavingAdjust(new Date(year, month, 32)).getDate();
  6368. },
  6369. /* Find the day of the week of the first of a month. */
  6370. _getFirstDayOfMonth: function(year, month) {
  6371. return new Date(year, month, 1).getDay();
  6372. },
  6373. /* Determines if we should allow a "next/prev" month display change. */
  6374. _canAdjustMonth: function(inst, offset, curYear, curMonth) {
  6375. var numMonths = this._getNumberOfMonths(inst),
  6376. date = this._daylightSavingAdjust(new Date(curYear,
  6377. curMonth + (offset < 0 ? offset : numMonths[0] * numMonths[1]), 1));
  6378. if (offset < 0) {
  6379. date.setDate(this._getDaysInMonth(date.getFullYear(), date.getMonth()));
  6380. }
  6381. return this._isInRange(inst, date);
  6382. },
  6383. /* Is the given date in the accepted range? */
  6384. _isInRange: function(inst, date) {
  6385. var yearSplit, currentYear,
  6386. minDate = this._getMinMaxDate(inst, "min"),
  6387. maxDate = this._getMinMaxDate(inst, "max"),
  6388. minYear = null,
  6389. maxYear = null,
  6390. years = this._get(inst, "yearRange");
  6391. if (years){
  6392. yearSplit = years.split(":");
  6393. currentYear = new Date().getFullYear();
  6394. minYear = parseInt(yearSplit[0], 10);
  6395. maxYear = parseInt(yearSplit[1], 10);
  6396. if ( yearSplit[0].match(/[+\-].*/) ) {
  6397. minYear += currentYear;
  6398. }
  6399. if ( yearSplit[1].match(/[+\-].*/) ) {
  6400. maxYear += currentYear;
  6401. }
  6402. }
  6403. return ((!minDate || date.getTime() >= minDate.getTime()) &&
  6404. (!maxDate || date.getTime() <= maxDate.getTime()) &&
  6405. (!minYear || date.getFullYear() >= minYear) &&
  6406. (!maxYear || date.getFullYear() <= maxYear));
  6407. },
  6408. /* Provide the configuration settings for formatting/parsing. */
  6409. _getFormatConfig: function(inst) {
  6410. var shortYearCutoff = this._get(inst, "shortYearCutoff");
  6411. shortYearCutoff = (typeof shortYearCutoff !== "string" ? shortYearCutoff :
  6412. new Date().getFullYear() % 100 + parseInt(shortYearCutoff, 10));
  6413. return {shortYearCutoff: shortYearCutoff,
  6414. dayNamesShort: this._get(inst, "dayNamesShort"), dayNames: this._get(inst, "dayNames"),
  6415. monthNamesShort: this._get(inst, "monthNamesShort"), monthNames: this._get(inst, "monthNames")};
  6416. },
  6417. /* Format the given date for display. */
  6418. _formatDate: function(inst, day, month, year) {
  6419. if (!day) {
  6420. inst.currentDay = inst.selectedDay;
  6421. inst.currentMonth = inst.selectedMonth;
  6422. inst.currentYear = inst.selectedYear;
  6423. }
  6424. var date = (day ? (typeof day === "object" ? day :
  6425. this._daylightSavingAdjust(new Date(year, month, day))) :
  6426. this._daylightSavingAdjust(new Date(inst.currentYear, inst.currentMonth, inst.currentDay)));
  6427. return this.formatDate(this._get(inst, "dateFormat"), date, this._getFormatConfig(inst));
  6428. }
  6429. });
  6430. /*
  6431. * Bind hover events for datepicker elements.
  6432. * Done via delegate so the binding only occurs once in the lifetime of the parent div.
  6433. * Global datepicker_instActive, set by _updateDatepicker allows the handlers to find their way back to the active picker.
  6434. */
  6435. function datepicker_bindHover(dpDiv) {
  6436. var selector = "button, .ui-datepicker-prev, .ui-datepicker-next, .ui-datepicker-calendar td a";
  6437. return dpDiv.delegate(selector, "mouseout", function() {
  6438. $(this).removeClass("ui-state-hover");
  6439. if (this.className.indexOf("ui-datepicker-prev") !== -1) {
  6440. $(this).removeClass("ui-datepicker-prev-hover");
  6441. }
  6442. if (this.className.indexOf("ui-datepicker-next") !== -1) {
  6443. $(this).removeClass("ui-datepicker-next-hover");
  6444. }
  6445. })
  6446. .delegate( selector, "mouseover", datepicker_handleMouseover );
  6447. }
  6448. function datepicker_handleMouseover() {
  6449. if (!$.datepicker._isDisabledDatepicker( datepicker_instActive.inline? datepicker_instActive.dpDiv.parent()[0] : datepicker_instActive.input[0])) {
  6450. $(this).parents(".ui-datepicker-calendar").find("a").removeClass("ui-state-hover");
  6451. $(this).addClass("ui-state-hover");
  6452. if (this.className.indexOf("ui-datepicker-prev") !== -1) {
  6453. $(this).addClass("ui-datepicker-prev-hover");
  6454. }
  6455. if (this.className.indexOf("ui-datepicker-next") !== -1) {
  6456. $(this).addClass("ui-datepicker-next-hover");
  6457. }
  6458. }
  6459. }
  6460. /* jQuery extend now ignores nulls! */
  6461. function datepicker_extendRemove(target, props) {
  6462. $.extend(target, props);
  6463. for (var name in props) {
  6464. if (props[name] == null) {
  6465. target[name] = props[name];
  6466. }
  6467. }
  6468. return target;
  6469. }
  6470. /* Invoke the datepicker functionality.
  6471. @param options string - a command, optionally followed by additional parameters or
  6472. Object - settings for attaching new datepicker functionality
  6473. @return jQuery object */
  6474. $.fn.datepicker = function(options){
  6475. /* Verify an empty collection wasn't passed - Fixes #6976 */
  6476. if ( !this.length ) {
  6477. return this;
  6478. }
  6479. /* Initialise the date picker. */
  6480. if (!$.datepicker.initialized) {
  6481. $(document).mousedown($.datepicker._checkExternalClick);
  6482. $.datepicker.initialized = true;
  6483. }
  6484. /* Append datepicker main container to body if not exist. */
  6485. if ($("#"+$.datepicker._mainDivId).length === 0) {
  6486. $("body").append($.datepicker.dpDiv);
  6487. }
  6488. var otherArgs = Array.prototype.slice.call(arguments, 1);
  6489. if (typeof options === "string" && (options === "isDisabled" || options === "getDate" || options === "widget")) {
  6490. return $.datepicker["_" + options + "Datepicker"].
  6491. apply($.datepicker, [this[0]].concat(otherArgs));
  6492. }
  6493. if (options === "option" && arguments.length === 2 && typeof arguments[1] === "string") {
  6494. return $.datepicker["_" + options + "Datepicker"].
  6495. apply($.datepicker, [this[0]].concat(otherArgs));
  6496. }
  6497. return this.each(function() {
  6498. typeof options === "string" ?
  6499. $.datepicker["_" + options + "Datepicker"].
  6500. apply($.datepicker, [this].concat(otherArgs)) :
  6501. $.datepicker._attachDatepicker(this, options);
  6502. });
  6503. };
  6504. $.datepicker = new Datepicker(); // singleton instance
  6505. $.datepicker.initialized = false;
  6506. $.datepicker.uuid = new Date().getTime();
  6507. $.datepicker.version = "1.11.4";
  6508. var datepicker = $.datepicker;
  6509. /*!
  6510. * jQuery UI Slider 1.11.4
  6511. * http://jqueryui.com
  6512. *
  6513. * Copyright jQuery Foundation and other contributors
  6514. * Released under the MIT license.
  6515. * http://jquery.org/license
  6516. *
  6517. * http://api.jqueryui.com/slider/
  6518. */
  6519. var slider = $.widget( "ui.slider", $.ui.mouse, {
  6520. version: "1.11.4",
  6521. widgetEventPrefix: "slide",
  6522. options: {
  6523. animate: false,
  6524. distance: 0,
  6525. max: 100,
  6526. min: 0,
  6527. orientation: "horizontal",
  6528. range: false,
  6529. step: 1,
  6530. value: 0,
  6531. values: null,
  6532. // callbacks
  6533. change: null,
  6534. slide: null,
  6535. start: null,
  6536. stop: null
  6537. },
  6538. // number of pages in a slider
  6539. // (how many times can you page up/down to go through the whole range)
  6540. numPages: 5,
  6541. _create: function() {
  6542. this._keySliding = false;
  6543. this._mouseSliding = false;
  6544. this._animateOff = true;
  6545. this._handleIndex = null;
  6546. this._detectOrientation();
  6547. this._mouseInit();
  6548. this._calculateNewMax();
  6549. this.element
  6550. .addClass( "ui-slider" +
  6551. " ui-slider-" + this.orientation +
  6552. " ui-widget" +
  6553. " ui-widget-content" +
  6554. " ui-corner-all");
  6555. this._refresh();
  6556. this._setOption( "disabled", this.options.disabled );
  6557. this._animateOff = false;
  6558. },
  6559. _refresh: function() {
  6560. this._createRange();
  6561. this._createHandles();
  6562. this._setupEvents();
  6563. this._refreshValue();
  6564. },
  6565. _createHandles: function() {
  6566. var i, handleCount,
  6567. options = this.options,
  6568. existingHandles = this.element.find( ".ui-slider-handle" ).addClass( "ui-state-default ui-corner-all" ),
  6569. handle = "<span class='ui-slider-handle ui-state-default ui-corner-all' tabindex='0'></span>",
  6570. handles = [];
  6571. handleCount = ( options.values && options.values.length ) || 1;
  6572. if ( existingHandles.length > handleCount ) {
  6573. existingHandles.slice( handleCount ).remove();
  6574. existingHandles = existingHandles.slice( 0, handleCount );
  6575. }
  6576. for ( i = existingHandles.length; i < handleCount; i++ ) {
  6577. handles.push( handle );
  6578. }
  6579. this.handles = existingHandles.add( $( handles.join( "" ) ).appendTo( this.element ) );
  6580. this.handle = this.handles.eq( 0 );
  6581. this.handles.each(function( i ) {
  6582. $( this ).data( "ui-slider-handle-index", i );
  6583. });
  6584. },
  6585. _createRange: function() {
  6586. var options = this.options,
  6587. classes = "";
  6588. if ( options.range ) {
  6589. if ( options.range === true ) {
  6590. if ( !options.values ) {
  6591. options.values = [ this._valueMin(), this._valueMin() ];
  6592. } else if ( options.values.length && options.values.length !== 2 ) {
  6593. options.values = [ options.values[0], options.values[0] ];
  6594. } else if ( $.isArray( options.values ) ) {
  6595. options.values = options.values.slice(0);
  6596. }
  6597. }
  6598. if ( !this.range || !this.range.length ) {
  6599. this.range = $( "<div></div>" )
  6600. .appendTo( this.element );
  6601. classes = "ui-slider-range" +
  6602. // note: this isn't the most fittingly semantic framework class for this element,
  6603. // but worked best visually with a variety of themes
  6604. " ui-widget-header ui-corner-all";
  6605. } else {
  6606. this.range.removeClass( "ui-slider-range-min ui-slider-range-max" )
  6607. // Handle range switching from true to min/max
  6608. .css({
  6609. "left": "",
  6610. "bottom": ""
  6611. });
  6612. }
  6613. this.range.addClass( classes +
  6614. ( ( options.range === "min" || options.range === "max" ) ? " ui-slider-range-" + options.range : "" ) );
  6615. } else {
  6616. if ( this.range ) {
  6617. this.range.remove();
  6618. }
  6619. this.range = null;
  6620. }
  6621. },
  6622. _setupEvents: function() {
  6623. this._off( this.handles );
  6624. this._on( this.handles, this._handleEvents );
  6625. this._hoverable( this.handles );
  6626. this._focusable( this.handles );
  6627. },
  6628. _destroy: function() {
  6629. this.handles.remove();
  6630. if ( this.range ) {
  6631. this.range.remove();
  6632. }
  6633. this.element
  6634. .removeClass( "ui-slider" +
  6635. " ui-slider-horizontal" +
  6636. " ui-slider-vertical" +
  6637. " ui-widget" +
  6638. " ui-widget-content" +
  6639. " ui-corner-all" );
  6640. this._mouseDestroy();
  6641. },
  6642. _mouseCapture: function( event ) {
  6643. var position, normValue, distance, closestHandle, index, allowed, offset, mouseOverHandle,
  6644. that = this,
  6645. o = this.options;
  6646. if ( o.disabled ) {
  6647. return false;
  6648. }
  6649. this.elementSize = {
  6650. width: this.element.outerWidth(),
  6651. height: this.element.outerHeight()
  6652. };
  6653. this.elementOffset = this.element.offset();
  6654. position = { x: event.pageX, y: event.pageY };
  6655. normValue = this._normValueFromMouse( position );
  6656. distance = this._valueMax() - this._valueMin() + 1;
  6657. this.handles.each(function( i ) {
  6658. var thisDistance = Math.abs( normValue - that.values(i) );
  6659. if (( distance > thisDistance ) ||
  6660. ( distance === thisDistance &&
  6661. (i === that._lastChangedValue || that.values(i) === o.min ))) {
  6662. distance = thisDistance;
  6663. closestHandle = $( this );
  6664. index = i;
  6665. }
  6666. });
  6667. allowed = this._start( event, index );
  6668. if ( allowed === false ) {
  6669. return false;
  6670. }
  6671. this._mouseSliding = true;
  6672. this._handleIndex = index;
  6673. closestHandle
  6674. .addClass( "ui-state-active" )
  6675. .focus();
  6676. offset = closestHandle.offset();
  6677. mouseOverHandle = !$( event.target ).parents().addBack().is( ".ui-slider-handle" );
  6678. this._clickOffset = mouseOverHandle ? { left: 0, top: 0 } : {
  6679. left: event.pageX - offset.left - ( closestHandle.width() / 2 ),
  6680. top: event.pageY - offset.top -
  6681. ( closestHandle.height() / 2 ) -
  6682. ( parseInt( closestHandle.css("borderTopWidth"), 10 ) || 0 ) -
  6683. ( parseInt( closestHandle.css("borderBottomWidth"), 10 ) || 0) +
  6684. ( parseInt( closestHandle.css("marginTop"), 10 ) || 0)
  6685. };
  6686. if ( !this.handles.hasClass( "ui-state-hover" ) ) {
  6687. this._slide( event, index, normValue );
  6688. }
  6689. this._animateOff = true;
  6690. return true;
  6691. },
  6692. _mouseStart: function() {
  6693. return true;
  6694. },
  6695. _mouseDrag: function( event ) {
  6696. var position = { x: event.pageX, y: event.pageY },
  6697. normValue = this._normValueFromMouse( position );
  6698. this._slide( event, this._handleIndex, normValue );
  6699. return false;
  6700. },
  6701. _mouseStop: function( event ) {
  6702. this.handles.removeClass( "ui-state-active" );
  6703. this._mouseSliding = false;
  6704. this._stop( event, this._handleIndex );
  6705. this._change( event, this._handleIndex );
  6706. this._handleIndex = null;
  6707. this._clickOffset = null;
  6708. this._animateOff = false;
  6709. return false;
  6710. },
  6711. _detectOrientation: function() {
  6712. this.orientation = ( this.options.orientation === "vertical" ) ? "vertical" : "horizontal";
  6713. },
  6714. _normValueFromMouse: function( position ) {
  6715. var pixelTotal,
  6716. pixelMouse,
  6717. percentMouse,
  6718. valueTotal,
  6719. valueMouse;
  6720. if ( this.orientation === "horizontal" ) {
  6721. pixelTotal = this.elementSize.width;
  6722. pixelMouse = position.x - this.elementOffset.left - ( this._clickOffset ? this._clickOffset.left : 0 );
  6723. } else {
  6724. pixelTotal = this.elementSize.height;
  6725. pixelMouse = position.y - this.elementOffset.top - ( this._clickOffset ? this._clickOffset.top : 0 );
  6726. }
  6727. percentMouse = ( pixelMouse / pixelTotal );
  6728. if ( percentMouse > 1 ) {
  6729. percentMouse = 1;
  6730. }
  6731. if ( percentMouse < 0 ) {
  6732. percentMouse = 0;
  6733. }
  6734. if ( this.orientation === "vertical" ) {
  6735. percentMouse = 1 - percentMouse;
  6736. }
  6737. valueTotal = this._valueMax() - this._valueMin();
  6738. valueMouse = this._valueMin() + percentMouse * valueTotal;
  6739. return this._trimAlignValue( valueMouse );
  6740. },
  6741. _start: function( event, index ) {
  6742. var uiHash = {
  6743. handle: this.handles[ index ],
  6744. value: this.value()
  6745. };
  6746. if ( this.options.values && this.options.values.length ) {
  6747. uiHash.value = this.values( index );
  6748. uiHash.values = this.values();
  6749. }
  6750. return this._trigger( "start", event, uiHash );
  6751. },
  6752. _slide: function( event, index, newVal ) {
  6753. var otherVal,
  6754. newValues,
  6755. allowed;
  6756. if ( this.options.values && this.options.values.length ) {
  6757. otherVal = this.values( index ? 0 : 1 );
  6758. if ( ( this.options.values.length === 2 && this.options.range === true ) &&
  6759. ( ( index === 0 && newVal > otherVal) || ( index === 1 && newVal < otherVal ) )
  6760. ) {
  6761. newVal = otherVal;
  6762. }
  6763. if ( newVal !== this.values( index ) ) {
  6764. newValues = this.values();
  6765. newValues[ index ] = newVal;
  6766. // A slide can be canceled by returning false from the slide callback
  6767. allowed = this._trigger( "slide", event, {
  6768. handle: this.handles[ index ],
  6769. value: newVal,
  6770. values: newValues
  6771. } );
  6772. otherVal = this.values( index ? 0 : 1 );
  6773. if ( allowed !== false ) {
  6774. this.values( index, newVal );
  6775. }
  6776. }
  6777. } else {
  6778. if ( newVal !== this.value() ) {
  6779. // A slide can be canceled by returning false from the slide callback
  6780. allowed = this._trigger( "slide", event, {
  6781. handle: this.handles[ index ],
  6782. value: newVal
  6783. } );
  6784. if ( allowed !== false ) {
  6785. this.value( newVal );
  6786. }
  6787. }
  6788. }
  6789. },
  6790. _stop: function( event, index ) {
  6791. var uiHash = {
  6792. handle: this.handles[ index ],
  6793. value: this.value()
  6794. };
  6795. if ( this.options.values && this.options.values.length ) {
  6796. uiHash.value = this.values( index );
  6797. uiHash.values = this.values();
  6798. }
  6799. this._trigger( "stop", event, uiHash );
  6800. },
  6801. _change: function( event, index ) {
  6802. if ( !this._keySliding && !this._mouseSliding ) {
  6803. var uiHash = {
  6804. handle: this.handles[ index ],
  6805. value: this.value()
  6806. };
  6807. if ( this.options.values && this.options.values.length ) {
  6808. uiHash.value = this.values( index );
  6809. uiHash.values = this.values();
  6810. }
  6811. //store the last changed value index for reference when handles overlap
  6812. this._lastChangedValue = index;
  6813. this._trigger( "change", event, uiHash );
  6814. }
  6815. },
  6816. value: function( newValue ) {
  6817. if ( arguments.length ) {
  6818. this.options.value = this._trimAlignValue( newValue );
  6819. this._refreshValue();
  6820. this._change( null, 0 );
  6821. return;
  6822. }
  6823. return this._value();
  6824. },
  6825. values: function( index, newValue ) {
  6826. var vals,
  6827. newValues,
  6828. i;
  6829. if ( arguments.length > 1 ) {
  6830. this.options.values[ index ] = this._trimAlignValue( newValue );
  6831. this._refreshValue();
  6832. this._change( null, index );
  6833. return;
  6834. }
  6835. if ( arguments.length ) {
  6836. if ( $.isArray( arguments[ 0 ] ) ) {
  6837. vals = this.options.values;
  6838. newValues = arguments[ 0 ];
  6839. for ( i = 0; i < vals.length; i += 1 ) {
  6840. vals[ i ] = this._trimAlignValue( newValues[ i ] );
  6841. this._change( null, i );
  6842. }
  6843. this._refreshValue();
  6844. } else {
  6845. if ( this.options.values && this.options.values.length ) {
  6846. return this._values( index );
  6847. } else {
  6848. return this.value();
  6849. }
  6850. }
  6851. } else {
  6852. return this._values();
  6853. }
  6854. },
  6855. _setOption: function( key, value ) {
  6856. var i,
  6857. valsLength = 0;
  6858. if ( key === "range" && this.options.range === true ) {
  6859. if ( value === "min" ) {
  6860. this.options.value = this._values( 0 );
  6861. this.options.values = null;
  6862. } else if ( value === "max" ) {
  6863. this.options.value = this._values( this.options.values.length - 1 );
  6864. this.options.values = null;
  6865. }
  6866. }
  6867. if ( $.isArray( this.options.values ) ) {
  6868. valsLength = this.options.values.length;
  6869. }
  6870. if ( key === "disabled" ) {
  6871. this.element.toggleClass( "ui-state-disabled", !!value );
  6872. }
  6873. this._super( key, value );
  6874. switch ( key ) {
  6875. case "orientation":
  6876. this._detectOrientation();
  6877. this.element
  6878. .removeClass( "ui-slider-horizontal ui-slider-vertical" )
  6879. .addClass( "ui-slider-" + this.orientation );
  6880. this._refreshValue();
  6881. // Reset positioning from previous orientation
  6882. this.handles.css( value === "horizontal" ? "bottom" : "left", "" );
  6883. break;
  6884. case "value":
  6885. this._animateOff = true;
  6886. this._refreshValue();
  6887. this._change( null, 0 );
  6888. this._animateOff = false;
  6889. break;
  6890. case "values":
  6891. this._animateOff = true;
  6892. this._refreshValue();
  6893. for ( i = 0; i < valsLength; i += 1 ) {
  6894. this._change( null, i );
  6895. }
  6896. this._animateOff = false;
  6897. break;
  6898. case "step":
  6899. case "min":
  6900. case "max":
  6901. this._animateOff = true;
  6902. this._calculateNewMax();
  6903. this._refreshValue();
  6904. this._animateOff = false;
  6905. break;
  6906. case "range":
  6907. this._animateOff = true;
  6908. this._refresh();
  6909. this._animateOff = false;
  6910. break;
  6911. }
  6912. },
  6913. //internal value getter
  6914. // _value() returns value trimmed by min and max, aligned by step
  6915. _value: function() {
  6916. var val = this.options.value;
  6917. val = this._trimAlignValue( val );
  6918. return val;
  6919. },
  6920. //internal values getter
  6921. // _values() returns array of values trimmed by min and max, aligned by step
  6922. // _values( index ) returns single value trimmed by min and max, aligned by step
  6923. _values: function( index ) {
  6924. var val,
  6925. vals,
  6926. i;
  6927. if ( arguments.length ) {
  6928. val = this.options.values[ index ];
  6929. val = this._trimAlignValue( val );
  6930. return val;
  6931. } else if ( this.options.values && this.options.values.length ) {
  6932. // .slice() creates a copy of the array
  6933. // this copy gets trimmed by min and max and then returned
  6934. vals = this.options.values.slice();
  6935. for ( i = 0; i < vals.length; i += 1) {
  6936. vals[ i ] = this._trimAlignValue( vals[ i ] );
  6937. }
  6938. return vals;
  6939. } else {
  6940. return [];
  6941. }
  6942. },
  6943. // returns the step-aligned value that val is closest to, between (inclusive) min and max
  6944. _trimAlignValue: function( val ) {
  6945. if ( val <= this._valueMin() ) {
  6946. return this._valueMin();
  6947. }
  6948. if ( val >= this._valueMax() ) {
  6949. return this._valueMax();
  6950. }
  6951. var step = ( this.options.step > 0 ) ? this.options.step : 1,
  6952. valModStep = (val - this._valueMin()) % step,
  6953. alignValue = val - valModStep;
  6954. if ( Math.abs(valModStep) * 2 >= step ) {
  6955. alignValue += ( valModStep > 0 ) ? step : ( -step );
  6956. }
  6957. // Since JavaScript has problems with large floats, round
  6958. // the final value to 5 digits after the decimal point (see #4124)
  6959. return parseFloat( alignValue.toFixed(5) );
  6960. },
  6961. _calculateNewMax: function() {
  6962. var max = this.options.max,
  6963. min = this._valueMin(),
  6964. step = this.options.step,
  6965. aboveMin = Math.floor( ( +( max - min ).toFixed( this._precision() ) ) / step ) * step;
  6966. max = aboveMin + min;
  6967. this.max = parseFloat( max.toFixed( this._precision() ) );
  6968. },
  6969. _precision: function() {
  6970. var precision = this._precisionOf( this.options.step );
  6971. if ( this.options.min !== null ) {
  6972. precision = Math.max( precision, this._precisionOf( this.options.min ) );
  6973. }
  6974. return precision;
  6975. },
  6976. _precisionOf: function( num ) {
  6977. var str = num.toString(),
  6978. decimal = str.indexOf( "." );
  6979. return decimal === -1 ? 0 : str.length - decimal - 1;
  6980. },
  6981. _valueMin: function() {
  6982. return this.options.min;
  6983. },
  6984. _valueMax: function() {
  6985. return this.max;
  6986. },
  6987. _refreshValue: function() {
  6988. var lastValPercent, valPercent, value, valueMin, valueMax,
  6989. oRange = this.options.range,
  6990. o = this.options,
  6991. that = this,
  6992. animate = ( !this._animateOff ) ? o.animate : false,
  6993. _set = {};
  6994. if ( this.options.values && this.options.values.length ) {
  6995. this.handles.each(function( i ) {
  6996. valPercent = ( that.values(i) - that._valueMin() ) / ( that._valueMax() - that._valueMin() ) * 100;
  6997. _set[ that.orientation === "horizontal" ? "left" : "bottom" ] = valPercent + "%";
  6998. $( this ).stop( 1, 1 )[ animate ? "animate" : "css" ]( _set, o.animate );
  6999. if ( that.options.range === true ) {
  7000. if ( that.orientation === "horizontal" ) {
  7001. if ( i === 0 ) {
  7002. that.range.stop( 1, 1 )[ animate ? "animate" : "css" ]( { left: valPercent + "%" }, o.animate );
  7003. }
  7004. if ( i === 1 ) {
  7005. that.range[ animate ? "animate" : "css" ]( { width: ( valPercent - lastValPercent ) + "%" }, { queue: false, duration: o.animate } );
  7006. }
  7007. } else {
  7008. if ( i === 0 ) {
  7009. that.range.stop( 1, 1 )[ animate ? "animate" : "css" ]( { bottom: ( valPercent ) + "%" }, o.animate );
  7010. }
  7011. if ( i === 1 ) {
  7012. that.range[ animate ? "animate" : "css" ]( { height: ( valPercent - lastValPercent ) + "%" }, { queue: false, duration: o.animate } );
  7013. }
  7014. }
  7015. }
  7016. lastValPercent = valPercent;
  7017. });
  7018. } else {
  7019. value = this.value();
  7020. valueMin = this._valueMin();
  7021. valueMax = this._valueMax();
  7022. valPercent = ( valueMax !== valueMin ) ?
  7023. ( value - valueMin ) / ( valueMax - valueMin ) * 100 :
  7024. 0;
  7025. _set[ this.orientation === "horizontal" ? "left" : "bottom" ] = valPercent + "%";
  7026. this.handle.stop( 1, 1 )[ animate ? "animate" : "css" ]( _set, o.animate );
  7027. if ( oRange === "min" && this.orientation === "horizontal" ) {
  7028. this.range.stop( 1, 1 )[ animate ? "animate" : "css" ]( { width: valPercent + "%" }, o.animate );
  7029. }
  7030. if ( oRange === "max" && this.orientation === "horizontal" ) {
  7031. this.range[ animate ? "animate" : "css" ]( { width: ( 100 - valPercent ) + "%" }, { queue: false, duration: o.animate } );
  7032. }
  7033. if ( oRange === "min" && this.orientation === "vertical" ) {
  7034. this.range.stop( 1, 1 )[ animate ? "animate" : "css" ]( { height: valPercent + "%" }, o.animate );
  7035. }
  7036. if ( oRange === "max" && this.orientation === "vertical" ) {
  7037. this.range[ animate ? "animate" : "css" ]( { height: ( 100 - valPercent ) + "%" }, { queue: false, duration: o.animate } );
  7038. }
  7039. }
  7040. },
  7041. _handleEvents: {
  7042. keydown: function( event ) {
  7043. var allowed, curVal, newVal, step,
  7044. index = $( event.target ).data( "ui-slider-handle-index" );
  7045. switch ( event.keyCode ) {
  7046. case $.ui.keyCode.HOME:
  7047. case $.ui.keyCode.END:
  7048. case $.ui.keyCode.PAGE_UP:
  7049. case $.ui.keyCode.PAGE_DOWN:
  7050. case $.ui.keyCode.UP:
  7051. case $.ui.keyCode.RIGHT:
  7052. case $.ui.keyCode.DOWN:
  7053. case $.ui.keyCode.LEFT:
  7054. event.preventDefault();
  7055. if ( !this._keySliding ) {
  7056. this._keySliding = true;
  7057. $( event.target ).addClass( "ui-state-active" );
  7058. allowed = this._start( event, index );
  7059. if ( allowed === false ) {
  7060. return;
  7061. }
  7062. }
  7063. break;
  7064. }
  7065. step = this.options.step;
  7066. if ( this.options.values && this.options.values.length ) {
  7067. curVal = newVal = this.values( index );
  7068. } else {
  7069. curVal = newVal = this.value();
  7070. }
  7071. switch ( event.keyCode ) {
  7072. case $.ui.keyCode.HOME:
  7073. newVal = this._valueMin();
  7074. break;
  7075. case $.ui.keyCode.END:
  7076. newVal = this._valueMax();
  7077. break;
  7078. case $.ui.keyCode.PAGE_UP:
  7079. newVal = this._trimAlignValue(
  7080. curVal + ( ( this._valueMax() - this._valueMin() ) / this.numPages )
  7081. );
  7082. break;
  7083. case $.ui.keyCode.PAGE_DOWN:
  7084. newVal = this._trimAlignValue(
  7085. curVal - ( (this._valueMax() - this._valueMin()) / this.numPages ) );
  7086. break;
  7087. case $.ui.keyCode.UP:
  7088. case $.ui.keyCode.RIGHT:
  7089. if ( curVal === this._valueMax() ) {
  7090. return;
  7091. }
  7092. newVal = this._trimAlignValue( curVal + step );
  7093. break;
  7094. case $.ui.keyCode.DOWN:
  7095. case $.ui.keyCode.LEFT:
  7096. if ( curVal === this._valueMin() ) {
  7097. return;
  7098. }
  7099. newVal = this._trimAlignValue( curVal - step );
  7100. break;
  7101. }
  7102. this._slide( event, index, newVal );
  7103. },
  7104. keyup: function( event ) {
  7105. var index = $( event.target ).data( "ui-slider-handle-index" );
  7106. if ( this._keySliding ) {
  7107. this._keySliding = false;
  7108. this._stop( event, index );
  7109. this._change( event, index );
  7110. $( event.target ).removeClass( "ui-state-active" );
  7111. }
  7112. }
  7113. }
  7114. });
  7115. }));