jquery-ui.custom.js 183 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471
  1. /*! jQuery UI - v1.11.2 - 2014-10-28
  2. * http://jqueryui.com
  3. * Includes: core.js, widget.js, mouse.js, position.js, draggable.js, droppable.js, resizable.js, selectable.js, sortable.js, slider.js
  4. * Copyright 2014 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.2
  16. * http://jqueryui.com
  17. *
  18. * Copyright 2014 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.2",
  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.2
  274. * http://jqueryui.com
  275. *
  276. * Copyright 2014 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. // allow multiple hashes to be passed on init
  432. options = !isMethodCall && args.length ?
  433. $.widget.extend.apply( null, [ options ].concat(args) ) :
  434. options;
  435. if ( isMethodCall ) {
  436. this.each(function() {
  437. var methodValue,
  438. instance = $.data( this, fullName );
  439. if ( options === "instance" ) {
  440. returnValue = instance;
  441. return false;
  442. }
  443. if ( !instance ) {
  444. return $.error( "cannot call methods on " + name + " prior to initialization; " +
  445. "attempted to call method '" + options + "'" );
  446. }
  447. if ( !$.isFunction( instance[options] ) || options.charAt( 0 ) === "_" ) {
  448. return $.error( "no such method '" + options + "' for " + name + " widget instance" );
  449. }
  450. methodValue = instance[ options ].apply( instance, args );
  451. if ( methodValue !== instance && methodValue !== undefined ) {
  452. returnValue = methodValue && methodValue.jquery ?
  453. returnValue.pushStack( methodValue.get() ) :
  454. methodValue;
  455. return false;
  456. }
  457. });
  458. } else {
  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.2
  756. * http://jqueryui.com
  757. *
  758. * Copyright 2014 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.2",
  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.2
  908. * http://jqueryui.com
  909. *
  910. * Copyright 2014 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 ( ( position.top + myOffset + atOffset + offset) > overTop && ( 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 ( ( position.top + myOffset + atOffset + offset) > overBottom && ( 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.2
  1368. * http://jqueryui.com
  1369. *
  1370. * Copyright 2014 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.2",
  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. sortable.currentItem = ui.helper
  2010. .appendTo( sortable.element )
  2011. .data( "ui-sortable-item", true );
  2012. // Store helper option to later restore it
  2013. sortable.options._helper = sortable.options.helper;
  2014. sortable.options.helper = function() {
  2015. return ui.helper[ 0 ];
  2016. };
  2017. // Fire the start events of the sortable with our passed browser event,
  2018. // and our own helper (so it doesn't create a new one)
  2019. event.target = sortable.currentItem[ 0 ];
  2020. sortable._mouseCapture( event, true );
  2021. sortable._mouseStart( event, true, true );
  2022. // Because the browser event is way off the new appended portlet,
  2023. // modify necessary variables to reflect the changes
  2024. sortable.offset.click.top = draggable.offset.click.top;
  2025. sortable.offset.click.left = draggable.offset.click.left;
  2026. sortable.offset.parent.left -= draggable.offset.parent.left -
  2027. sortable.offset.parent.left;
  2028. sortable.offset.parent.top -= draggable.offset.parent.top -
  2029. sortable.offset.parent.top;
  2030. draggable._trigger( "toSortable", event );
  2031. // Inform draggable that the helper is in a valid drop zone,
  2032. // used solely in the revert option to handle "valid/invalid".
  2033. draggable.dropped = sortable.element;
  2034. // Need to refreshPositions of all sortables in the case that
  2035. // adding to one sortable changes the location of the other sortables (#9675)
  2036. $.each( draggable.sortables, function() {
  2037. this.refreshPositions();
  2038. });
  2039. // hack so receive/update callbacks work (mostly)
  2040. draggable.currentItem = draggable.element;
  2041. sortable.fromOutside = draggable;
  2042. }
  2043. if ( sortable.currentItem ) {
  2044. sortable._mouseDrag( event );
  2045. // Copy the sortable's position because the draggable's can potentially reflect
  2046. // a relative position, while sortable is always absolute, which the dragged
  2047. // element has now become. (#8809)
  2048. ui.position = sortable.position;
  2049. }
  2050. } else {
  2051. // If it doesn't intersect with the sortable, and it intersected before,
  2052. // we fake the drag stop of the sortable, but make sure it doesn't remove
  2053. // the helper by using cancelHelperRemoval.
  2054. if ( sortable.isOver ) {
  2055. sortable.isOver = 0;
  2056. sortable.cancelHelperRemoval = true;
  2057. // Calling sortable's mouseStop would trigger a revert,
  2058. // so revert must be temporarily false until after mouseStop is called.
  2059. sortable.options._revert = sortable.options.revert;
  2060. sortable.options.revert = false;
  2061. sortable._trigger( "out", event, sortable._uiHash( sortable ) );
  2062. sortable._mouseStop( event, true );
  2063. // restore sortable behaviors that were modfied
  2064. // when the draggable entered the sortable area (#9481)
  2065. sortable.options.revert = sortable.options._revert;
  2066. sortable.options.helper = sortable.options._helper;
  2067. if ( sortable.placeholder ) {
  2068. sortable.placeholder.remove();
  2069. }
  2070. // Recalculate the draggable's offset considering the sortable
  2071. // may have modified them in unexpected ways (#8809)
  2072. draggable._refreshOffsets( event );
  2073. ui.position = draggable._generatePosition( event, true );
  2074. draggable._trigger( "fromSortable", event );
  2075. // Inform draggable that the helper is no longer in a valid drop zone
  2076. draggable.dropped = false;
  2077. // Need to refreshPositions of all sortables just in case removing
  2078. // from one sortable changes the location of other sortables (#9675)
  2079. $.each( draggable.sortables, function() {
  2080. this.refreshPositions();
  2081. });
  2082. }
  2083. }
  2084. });
  2085. }
  2086. });
  2087. $.ui.plugin.add("draggable", "cursor", {
  2088. start: function( event, ui, instance ) {
  2089. var t = $( "body" ),
  2090. o = instance.options;
  2091. if (t.css("cursor")) {
  2092. o._cursor = t.css("cursor");
  2093. }
  2094. t.css("cursor", o.cursor);
  2095. },
  2096. stop: function( event, ui, instance ) {
  2097. var o = instance.options;
  2098. if (o._cursor) {
  2099. $("body").css("cursor", o._cursor);
  2100. }
  2101. }
  2102. });
  2103. $.ui.plugin.add("draggable", "opacity", {
  2104. start: function( event, ui, instance ) {
  2105. var t = $( ui.helper ),
  2106. o = instance.options;
  2107. if (t.css("opacity")) {
  2108. o._opacity = t.css("opacity");
  2109. }
  2110. t.css("opacity", o.opacity);
  2111. },
  2112. stop: function( event, ui, instance ) {
  2113. var o = instance.options;
  2114. if (o._opacity) {
  2115. $(ui.helper).css("opacity", o._opacity);
  2116. }
  2117. }
  2118. });
  2119. $.ui.plugin.add("draggable", "scroll", {
  2120. start: function( event, ui, i ) {
  2121. if ( !i.scrollParentNotHidden ) {
  2122. i.scrollParentNotHidden = i.helper.scrollParent( false );
  2123. }
  2124. if ( i.scrollParentNotHidden[ 0 ] !== i.document[ 0 ] && i.scrollParentNotHidden[ 0 ].tagName !== "HTML" ) {
  2125. i.overflowOffset = i.scrollParentNotHidden.offset();
  2126. }
  2127. },
  2128. drag: function( event, ui, i ) {
  2129. var o = i.options,
  2130. scrolled = false,
  2131. scrollParent = i.scrollParentNotHidden[ 0 ],
  2132. document = i.document[ 0 ];
  2133. if ( scrollParent !== document && scrollParent.tagName !== "HTML" ) {
  2134. if ( !o.axis || o.axis !== "x" ) {
  2135. if ( ( i.overflowOffset.top + scrollParent.offsetHeight ) - event.pageY < o.scrollSensitivity ) {
  2136. scrollParent.scrollTop = scrolled = scrollParent.scrollTop + o.scrollSpeed;
  2137. } else if ( event.pageY - i.overflowOffset.top < o.scrollSensitivity ) {
  2138. scrollParent.scrollTop = scrolled = scrollParent.scrollTop - o.scrollSpeed;
  2139. }
  2140. }
  2141. if ( !o.axis || o.axis !== "y" ) {
  2142. if ( ( i.overflowOffset.left + scrollParent.offsetWidth ) - event.pageX < o.scrollSensitivity ) {
  2143. scrollParent.scrollLeft = scrolled = scrollParent.scrollLeft + o.scrollSpeed;
  2144. } else if ( event.pageX - i.overflowOffset.left < o.scrollSensitivity ) {
  2145. scrollParent.scrollLeft = scrolled = scrollParent.scrollLeft - o.scrollSpeed;
  2146. }
  2147. }
  2148. } else {
  2149. if (!o.axis || o.axis !== "x") {
  2150. if (event.pageY - $(document).scrollTop() < o.scrollSensitivity) {
  2151. scrolled = $(document).scrollTop($(document).scrollTop() - o.scrollSpeed);
  2152. } else if ($(window).height() - (event.pageY - $(document).scrollTop()) < o.scrollSensitivity) {
  2153. scrolled = $(document).scrollTop($(document).scrollTop() + o.scrollSpeed);
  2154. }
  2155. }
  2156. if (!o.axis || o.axis !== "y") {
  2157. if (event.pageX - $(document).scrollLeft() < o.scrollSensitivity) {
  2158. scrolled = $(document).scrollLeft($(document).scrollLeft() - o.scrollSpeed);
  2159. } else if ($(window).width() - (event.pageX - $(document).scrollLeft()) < o.scrollSensitivity) {
  2160. scrolled = $(document).scrollLeft($(document).scrollLeft() + o.scrollSpeed);
  2161. }
  2162. }
  2163. }
  2164. if (scrolled !== false && $.ui.ddmanager && !o.dropBehaviour) {
  2165. $.ui.ddmanager.prepareOffsets(i, event);
  2166. }
  2167. }
  2168. });
  2169. $.ui.plugin.add("draggable", "snap", {
  2170. start: function( event, ui, i ) {
  2171. var o = i.options;
  2172. i.snapElements = [];
  2173. $(o.snap.constructor !== String ? ( o.snap.items || ":data(ui-draggable)" ) : o.snap).each(function() {
  2174. var $t = $(this),
  2175. $o = $t.offset();
  2176. if (this !== i.element[0]) {
  2177. i.snapElements.push({
  2178. item: this,
  2179. width: $t.outerWidth(), height: $t.outerHeight(),
  2180. top: $o.top, left: $o.left
  2181. });
  2182. }
  2183. });
  2184. },
  2185. drag: function( event, ui, inst ) {
  2186. var ts, bs, ls, rs, l, r, t, b, i, first,
  2187. o = inst.options,
  2188. d = o.snapTolerance,
  2189. x1 = ui.offset.left, x2 = x1 + inst.helperProportions.width,
  2190. y1 = ui.offset.top, y2 = y1 + inst.helperProportions.height;
  2191. for (i = inst.snapElements.length - 1; i >= 0; i--){
  2192. l = inst.snapElements[i].left - inst.margins.left;
  2193. r = l + inst.snapElements[i].width;
  2194. t = inst.snapElements[i].top - inst.margins.top;
  2195. b = t + inst.snapElements[i].height;
  2196. if ( x2 < l - d || x1 > r + d || y2 < t - d || y1 > b + d || !$.contains( inst.snapElements[ i ].item.ownerDocument, inst.snapElements[ i ].item ) ) {
  2197. if (inst.snapElements[i].snapping) {
  2198. (inst.options.snap.release && inst.options.snap.release.call(inst.element, event, $.extend(inst._uiHash(), { snapItem: inst.snapElements[i].item })));
  2199. }
  2200. inst.snapElements[i].snapping = false;
  2201. continue;
  2202. }
  2203. if (o.snapMode !== "inner") {
  2204. ts = Math.abs(t - y2) <= d;
  2205. bs = Math.abs(b - y1) <= d;
  2206. ls = Math.abs(l - x2) <= d;
  2207. rs = Math.abs(r - x1) <= d;
  2208. if (ts) {
  2209. ui.position.top = inst._convertPositionTo("relative", { top: t - inst.helperProportions.height, left: 0 }).top;
  2210. }
  2211. if (bs) {
  2212. ui.position.top = inst._convertPositionTo("relative", { top: b, left: 0 }).top;
  2213. }
  2214. if (ls) {
  2215. ui.position.left = inst._convertPositionTo("relative", { top: 0, left: l - inst.helperProportions.width }).left;
  2216. }
  2217. if (rs) {
  2218. ui.position.left = inst._convertPositionTo("relative", { top: 0, left: r }).left;
  2219. }
  2220. }
  2221. first = (ts || bs || ls || rs);
  2222. if (o.snapMode !== "outer") {
  2223. ts = Math.abs(t - y1) <= d;
  2224. bs = Math.abs(b - y2) <= d;
  2225. ls = Math.abs(l - x1) <= d;
  2226. rs = Math.abs(r - x2) <= d;
  2227. if (ts) {
  2228. ui.position.top = inst._convertPositionTo("relative", { top: t, left: 0 }).top;
  2229. }
  2230. if (bs) {
  2231. ui.position.top = inst._convertPositionTo("relative", { top: b - inst.helperProportions.height, left: 0 }).top;
  2232. }
  2233. if (ls) {
  2234. ui.position.left = inst._convertPositionTo("relative", { top: 0, left: l }).left;
  2235. }
  2236. if (rs) {
  2237. ui.position.left = inst._convertPositionTo("relative", { top: 0, left: r - inst.helperProportions.width }).left;
  2238. }
  2239. }
  2240. if (!inst.snapElements[i].snapping && (ts || bs || ls || rs || first)) {
  2241. (inst.options.snap.snap && inst.options.snap.snap.call(inst.element, event, $.extend(inst._uiHash(), { snapItem: inst.snapElements[i].item })));
  2242. }
  2243. inst.snapElements[i].snapping = (ts || bs || ls || rs || first);
  2244. }
  2245. }
  2246. });
  2247. $.ui.plugin.add("draggable", "stack", {
  2248. start: function( event, ui, instance ) {
  2249. var min,
  2250. o = instance.options,
  2251. group = $.makeArray($(o.stack)).sort(function(a, b) {
  2252. return (parseInt($(a).css("zIndex"), 10) || 0) - (parseInt($(b).css("zIndex"), 10) || 0);
  2253. });
  2254. if (!group.length) { return; }
  2255. min = parseInt($(group[0]).css("zIndex"), 10) || 0;
  2256. $(group).each(function(i) {
  2257. $(this).css("zIndex", min + i);
  2258. });
  2259. this.css("zIndex", (min + group.length));
  2260. }
  2261. });
  2262. $.ui.plugin.add("draggable", "zIndex", {
  2263. start: function( event, ui, instance ) {
  2264. var t = $( ui.helper ),
  2265. o = instance.options;
  2266. if (t.css("zIndex")) {
  2267. o._zIndex = t.css("zIndex");
  2268. }
  2269. t.css("zIndex", o.zIndex);
  2270. },
  2271. stop: function( event, ui, instance ) {
  2272. var o = instance.options;
  2273. if (o._zIndex) {
  2274. $(ui.helper).css("zIndex", o._zIndex);
  2275. }
  2276. }
  2277. });
  2278. var draggable = $.ui.draggable;
  2279. /*!
  2280. * jQuery UI Droppable 1.11.2
  2281. * http://jqueryui.com
  2282. *
  2283. * Copyright 2014 jQuery Foundation and other contributors
  2284. * Released under the MIT license.
  2285. * http://jquery.org/license
  2286. *
  2287. * http://api.jqueryui.com/droppable/
  2288. */
  2289. $.widget( "ui.droppable", {
  2290. version: "1.11.2",
  2291. widgetEventPrefix: "drop",
  2292. options: {
  2293. accept: "*",
  2294. activeClass: false,
  2295. addClasses: true,
  2296. greedy: false,
  2297. hoverClass: false,
  2298. scope: "default",
  2299. tolerance: "intersect",
  2300. // callbacks
  2301. activate: null,
  2302. deactivate: null,
  2303. drop: null,
  2304. out: null,
  2305. over: null
  2306. },
  2307. _create: function() {
  2308. var proportions,
  2309. o = this.options,
  2310. accept = o.accept;
  2311. this.isover = false;
  2312. this.isout = true;
  2313. this.accept = $.isFunction( accept ) ? accept : function( d ) {
  2314. return d.is( accept );
  2315. };
  2316. this.proportions = function( /* valueToWrite */ ) {
  2317. if ( arguments.length ) {
  2318. // Store the droppable's proportions
  2319. proportions = arguments[ 0 ];
  2320. } else {
  2321. // Retrieve or derive the droppable's proportions
  2322. return proportions ?
  2323. proportions :
  2324. proportions = {
  2325. width: this.element[ 0 ].offsetWidth,
  2326. height: this.element[ 0 ].offsetHeight
  2327. };
  2328. }
  2329. };
  2330. this._addToManager( o.scope );
  2331. o.addClasses && this.element.addClass( "ui-droppable" );
  2332. },
  2333. _addToManager: function( scope ) {
  2334. // Add the reference and positions to the manager
  2335. $.ui.ddmanager.droppables[ scope ] = $.ui.ddmanager.droppables[ scope ] || [];
  2336. $.ui.ddmanager.droppables[ scope ].push( this );
  2337. },
  2338. _splice: function( drop ) {
  2339. var i = 0;
  2340. for ( ; i < drop.length; i++ ) {
  2341. if ( drop[ i ] === this ) {
  2342. drop.splice( i, 1 );
  2343. }
  2344. }
  2345. },
  2346. _destroy: function() {
  2347. var drop = $.ui.ddmanager.droppables[ this.options.scope ];
  2348. this._splice( drop );
  2349. this.element.removeClass( "ui-droppable ui-droppable-disabled" );
  2350. },
  2351. _setOption: function( key, value ) {
  2352. if ( key === "accept" ) {
  2353. this.accept = $.isFunction( value ) ? value : function( d ) {
  2354. return d.is( value );
  2355. };
  2356. } else if ( key === "scope" ) {
  2357. var drop = $.ui.ddmanager.droppables[ this.options.scope ];
  2358. this._splice( drop );
  2359. this._addToManager( value );
  2360. }
  2361. this._super( key, value );
  2362. },
  2363. _activate: function( event ) {
  2364. var draggable = $.ui.ddmanager.current;
  2365. if ( this.options.activeClass ) {
  2366. this.element.addClass( this.options.activeClass );
  2367. }
  2368. if ( draggable ){
  2369. this._trigger( "activate", event, this.ui( draggable ) );
  2370. }
  2371. },
  2372. _deactivate: function( event ) {
  2373. var draggable = $.ui.ddmanager.current;
  2374. if ( this.options.activeClass ) {
  2375. this.element.removeClass( this.options.activeClass );
  2376. }
  2377. if ( draggable ){
  2378. this._trigger( "deactivate", event, this.ui( draggable ) );
  2379. }
  2380. },
  2381. _over: function( event ) {
  2382. var draggable = $.ui.ddmanager.current;
  2383. // Bail if draggable and droppable are same element
  2384. if ( !draggable || ( draggable.currentItem || draggable.element )[ 0 ] === this.element[ 0 ] ) {
  2385. return;
  2386. }
  2387. if ( this.accept.call( this.element[ 0 ], ( draggable.currentItem || draggable.element ) ) ) {
  2388. if ( this.options.hoverClass ) {
  2389. this.element.addClass( this.options.hoverClass );
  2390. }
  2391. this._trigger( "over", event, this.ui( draggable ) );
  2392. }
  2393. },
  2394. _out: function( event ) {
  2395. var draggable = $.ui.ddmanager.current;
  2396. // Bail if draggable and droppable are same element
  2397. if ( !draggable || ( draggable.currentItem || draggable.element )[ 0 ] === this.element[ 0 ] ) {
  2398. return;
  2399. }
  2400. if ( this.accept.call( this.element[ 0 ], ( draggable.currentItem || draggable.element ) ) ) {
  2401. if ( this.options.hoverClass ) {
  2402. this.element.removeClass( this.options.hoverClass );
  2403. }
  2404. this._trigger( "out", event, this.ui( draggable ) );
  2405. }
  2406. },
  2407. _drop: function( event, custom ) {
  2408. var draggable = custom || $.ui.ddmanager.current,
  2409. childrenIntersection = false;
  2410. // Bail if draggable and droppable are same element
  2411. if ( !draggable || ( draggable.currentItem || draggable.element )[ 0 ] === this.element[ 0 ] ) {
  2412. return false;
  2413. }
  2414. this.element.find( ":data(ui-droppable)" ).not( ".ui-draggable-dragging" ).each(function() {
  2415. var inst = $( this ).droppable( "instance" );
  2416. if (
  2417. inst.options.greedy &&
  2418. !inst.options.disabled &&
  2419. inst.options.scope === draggable.options.scope &&
  2420. inst.accept.call( inst.element[ 0 ], ( draggable.currentItem || draggable.element ) ) &&
  2421. $.ui.intersect( draggable, $.extend( inst, { offset: inst.element.offset() } ), inst.options.tolerance, event )
  2422. ) { childrenIntersection = true; return false; }
  2423. });
  2424. if ( childrenIntersection ) {
  2425. return false;
  2426. }
  2427. if ( this.accept.call( this.element[ 0 ], ( draggable.currentItem || draggable.element ) ) ) {
  2428. if ( this.options.activeClass ) {
  2429. this.element.removeClass( this.options.activeClass );
  2430. }
  2431. if ( this.options.hoverClass ) {
  2432. this.element.removeClass( this.options.hoverClass );
  2433. }
  2434. this._trigger( "drop", event, this.ui( draggable ) );
  2435. return this.element;
  2436. }
  2437. return false;
  2438. },
  2439. ui: function( c ) {
  2440. return {
  2441. draggable: ( c.currentItem || c.element ),
  2442. helper: c.helper,
  2443. position: c.position,
  2444. offset: c.positionAbs
  2445. };
  2446. }
  2447. });
  2448. $.ui.intersect = (function() {
  2449. function isOverAxis( x, reference, size ) {
  2450. return ( x >= reference ) && ( x < ( reference + size ) );
  2451. }
  2452. return function( draggable, droppable, toleranceMode, event ) {
  2453. if ( !droppable.offset ) {
  2454. return false;
  2455. }
  2456. var x1 = ( draggable.positionAbs || draggable.position.absolute ).left + draggable.margins.left,
  2457. y1 = ( draggable.positionAbs || draggable.position.absolute ).top + draggable.margins.top,
  2458. x2 = x1 + draggable.helperProportions.width,
  2459. y2 = y1 + draggable.helperProportions.height,
  2460. l = droppable.offset.left,
  2461. t = droppable.offset.top,
  2462. r = l + droppable.proportions().width,
  2463. b = t + droppable.proportions().height;
  2464. switch ( toleranceMode ) {
  2465. case "fit":
  2466. return ( l <= x1 && x2 <= r && t <= y1 && y2 <= b );
  2467. case "intersect":
  2468. return ( l < x1 + ( draggable.helperProportions.width / 2 ) && // Right Half
  2469. x2 - ( draggable.helperProportions.width / 2 ) < r && // Left Half
  2470. t < y1 + ( draggable.helperProportions.height / 2 ) && // Bottom Half
  2471. y2 - ( draggable.helperProportions.height / 2 ) < b ); // Top Half
  2472. case "pointer":
  2473. return isOverAxis( event.pageY, t, droppable.proportions().height ) && isOverAxis( event.pageX, l, droppable.proportions().width );
  2474. case "touch":
  2475. return (
  2476. ( y1 >= t && y1 <= b ) || // Top edge touching
  2477. ( y2 >= t && y2 <= b ) || // Bottom edge touching
  2478. ( y1 < t && y2 > b ) // Surrounded vertically
  2479. ) && (
  2480. ( x1 >= l && x1 <= r ) || // Left edge touching
  2481. ( x2 >= l && x2 <= r ) || // Right edge touching
  2482. ( x1 < l && x2 > r ) // Surrounded horizontally
  2483. );
  2484. default:
  2485. return false;
  2486. }
  2487. };
  2488. })();
  2489. /*
  2490. This manager tracks offsets of draggables and droppables
  2491. */
  2492. $.ui.ddmanager = {
  2493. current: null,
  2494. droppables: { "default": [] },
  2495. prepareOffsets: function( t, event ) {
  2496. var i, j,
  2497. m = $.ui.ddmanager.droppables[ t.options.scope ] || [],
  2498. type = event ? event.type : null, // workaround for #2317
  2499. list = ( t.currentItem || t.element ).find( ":data(ui-droppable)" ).addBack();
  2500. droppablesLoop: for ( i = 0; i < m.length; i++ ) {
  2501. // No disabled and non-accepted
  2502. if ( m[ i ].options.disabled || ( t && !m[ i ].accept.call( m[ i ].element[ 0 ], ( t.currentItem || t.element ) ) ) ) {
  2503. continue;
  2504. }
  2505. // Filter out elements in the current dragged item
  2506. for ( j = 0; j < list.length; j++ ) {
  2507. if ( list[ j ] === m[ i ].element[ 0 ] ) {
  2508. m[ i ].proportions().height = 0;
  2509. continue droppablesLoop;
  2510. }
  2511. }
  2512. m[ i ].visible = m[ i ].element.css( "display" ) !== "none";
  2513. if ( !m[ i ].visible ) {
  2514. continue;
  2515. }
  2516. // Activate the droppable if used directly from draggables
  2517. if ( type === "mousedown" ) {
  2518. m[ i ]._activate.call( m[ i ], event );
  2519. }
  2520. m[ i ].offset = m[ i ].element.offset();
  2521. m[ i ].proportions({ width: m[ i ].element[ 0 ].offsetWidth, height: m[ i ].element[ 0 ].offsetHeight });
  2522. }
  2523. },
  2524. drop: function( draggable, event ) {
  2525. var dropped = false;
  2526. // Create a copy of the droppables in case the list changes during the drop (#9116)
  2527. $.each( ( $.ui.ddmanager.droppables[ draggable.options.scope ] || [] ).slice(), function() {
  2528. if ( !this.options ) {
  2529. return;
  2530. }
  2531. if ( !this.options.disabled && this.visible && $.ui.intersect( draggable, this, this.options.tolerance, event ) ) {
  2532. dropped = this._drop.call( this, event ) || dropped;
  2533. }
  2534. if ( !this.options.disabled && this.visible && this.accept.call( this.element[ 0 ], ( draggable.currentItem || draggable.element ) ) ) {
  2535. this.isout = true;
  2536. this.isover = false;
  2537. this._deactivate.call( this, event );
  2538. }
  2539. });
  2540. return dropped;
  2541. },
  2542. dragStart: function( draggable, event ) {
  2543. // Listen for scrolling so that if the dragging causes scrolling the position of the droppables can be recalculated (see #5003)
  2544. draggable.element.parentsUntil( "body" ).bind( "scroll.droppable", function() {
  2545. if ( !draggable.options.refreshPositions ) {
  2546. $.ui.ddmanager.prepareOffsets( draggable, event );
  2547. }
  2548. });
  2549. },
  2550. drag: function( draggable, event ) {
  2551. // If you have a highly dynamic page, you might try this option. It renders positions every time you move the mouse.
  2552. if ( draggable.options.refreshPositions ) {
  2553. $.ui.ddmanager.prepareOffsets( draggable, event );
  2554. }
  2555. // Run through all droppables and check their positions based on specific tolerance options
  2556. $.each( $.ui.ddmanager.droppables[ draggable.options.scope ] || [], function() {
  2557. if ( this.options.disabled || this.greedyChild || !this.visible ) {
  2558. return;
  2559. }
  2560. var parentInstance, scope, parent,
  2561. intersects = $.ui.intersect( draggable, this, this.options.tolerance, event ),
  2562. c = !intersects && this.isover ? "isout" : ( intersects && !this.isover ? "isover" : null );
  2563. if ( !c ) {
  2564. return;
  2565. }
  2566. if ( this.options.greedy ) {
  2567. // find droppable parents with same scope
  2568. scope = this.options.scope;
  2569. parent = this.element.parents( ":data(ui-droppable)" ).filter(function() {
  2570. return $( this ).droppable( "instance" ).options.scope === scope;
  2571. });
  2572. if ( parent.length ) {
  2573. parentInstance = $( parent[ 0 ] ).droppable( "instance" );
  2574. parentInstance.greedyChild = ( c === "isover" );
  2575. }
  2576. }
  2577. // we just moved into a greedy child
  2578. if ( parentInstance && c === "isover" ) {
  2579. parentInstance.isover = false;
  2580. parentInstance.isout = true;
  2581. parentInstance._out.call( parentInstance, event );
  2582. }
  2583. this[ c ] = true;
  2584. this[c === "isout" ? "isover" : "isout"] = false;
  2585. this[c === "isover" ? "_over" : "_out"].call( this, event );
  2586. // we just moved out of a greedy child
  2587. if ( parentInstance && c === "isout" ) {
  2588. parentInstance.isout = false;
  2589. parentInstance.isover = true;
  2590. parentInstance._over.call( parentInstance, event );
  2591. }
  2592. });
  2593. },
  2594. dragStop: function( draggable, event ) {
  2595. draggable.element.parentsUntil( "body" ).unbind( "scroll.droppable" );
  2596. // Call prepareOffsets one final time since IE does not fire return scroll events when overflow was caused by drag (see #5003)
  2597. if ( !draggable.options.refreshPositions ) {
  2598. $.ui.ddmanager.prepareOffsets( draggable, event );
  2599. }
  2600. }
  2601. };
  2602. var droppable = $.ui.droppable;
  2603. /*!
  2604. * jQuery UI Resizable 1.11.2
  2605. * http://jqueryui.com
  2606. *
  2607. * Copyright 2014 jQuery Foundation and other contributors
  2608. * Released under the MIT license.
  2609. * http://jquery.org/license
  2610. *
  2611. * http://api.jqueryui.com/resizable/
  2612. */
  2613. $.widget("ui.resizable", $.ui.mouse, {
  2614. version: "1.11.2",
  2615. widgetEventPrefix: "resize",
  2616. options: {
  2617. alsoResize: false,
  2618. animate: false,
  2619. animateDuration: "slow",
  2620. animateEasing: "swing",
  2621. aspectRatio: false,
  2622. autoHide: false,
  2623. containment: false,
  2624. ghost: false,
  2625. grid: false,
  2626. handles: "e,s,se",
  2627. helper: false,
  2628. maxHeight: null,
  2629. maxWidth: null,
  2630. minHeight: 10,
  2631. minWidth: 10,
  2632. // See #7960
  2633. zIndex: 90,
  2634. // callbacks
  2635. resize: null,
  2636. start: null,
  2637. stop: null
  2638. },
  2639. _num: function( value ) {
  2640. return parseInt( value, 10 ) || 0;
  2641. },
  2642. _isNumber: function( value ) {
  2643. return !isNaN( parseInt( value, 10 ) );
  2644. },
  2645. _hasScroll: function( el, a ) {
  2646. if ( $( el ).css( "overflow" ) === "hidden") {
  2647. return false;
  2648. }
  2649. var scroll = ( a && a === "left" ) ? "scrollLeft" : "scrollTop",
  2650. has = false;
  2651. if ( el[ scroll ] > 0 ) {
  2652. return true;
  2653. }
  2654. // TODO: determine which cases actually cause this to happen
  2655. // if the element doesn't have the scroll set, see if it's possible to
  2656. // set the scroll
  2657. el[ scroll ] = 1;
  2658. has = ( el[ scroll ] > 0 );
  2659. el[ scroll ] = 0;
  2660. return has;
  2661. },
  2662. _create: function() {
  2663. var n, i, handle, axis, hname,
  2664. that = this,
  2665. o = this.options;
  2666. this.element.addClass("ui-resizable");
  2667. $.extend(this, {
  2668. _aspectRatio: !!(o.aspectRatio),
  2669. aspectRatio: o.aspectRatio,
  2670. originalElement: this.element,
  2671. _proportionallyResizeElements: [],
  2672. _helper: o.helper || o.ghost || o.animate ? o.helper || "ui-resizable-helper" : null
  2673. });
  2674. // Wrap the element if it cannot hold child nodes
  2675. if (this.element[0].nodeName.match(/canvas|textarea|input|select|button|img/i)) {
  2676. this.element.wrap(
  2677. $("<div class='ui-wrapper' style='overflow: hidden;'></div>").css({
  2678. position: this.element.css("position"),
  2679. width: this.element.outerWidth(),
  2680. height: this.element.outerHeight(),
  2681. top: this.element.css("top"),
  2682. left: this.element.css("left")
  2683. })
  2684. );
  2685. this.element = this.element.parent().data(
  2686. "ui-resizable", this.element.resizable( "instance" )
  2687. );
  2688. this.elementIsWrapper = true;
  2689. this.element.css({
  2690. marginLeft: this.originalElement.css("marginLeft"),
  2691. marginTop: this.originalElement.css("marginTop"),
  2692. marginRight: this.originalElement.css("marginRight"),
  2693. marginBottom: this.originalElement.css("marginBottom")
  2694. });
  2695. this.originalElement.css({
  2696. marginLeft: 0,
  2697. marginTop: 0,
  2698. marginRight: 0,
  2699. marginBottom: 0
  2700. });
  2701. // support: Safari
  2702. // Prevent Safari textarea resize
  2703. this.originalResizeStyle = this.originalElement.css("resize");
  2704. this.originalElement.css("resize", "none");
  2705. this._proportionallyResizeElements.push( this.originalElement.css({
  2706. position: "static",
  2707. zoom: 1,
  2708. display: "block"
  2709. }) );
  2710. // support: IE9
  2711. // avoid IE jump (hard set the margin)
  2712. this.originalElement.css({ margin: this.originalElement.css("margin") });
  2713. this._proportionallyResize();
  2714. }
  2715. this.handles = o.handles ||
  2716. ( !$(".ui-resizable-handle", this.element).length ?
  2717. "e,s,se" : {
  2718. n: ".ui-resizable-n",
  2719. e: ".ui-resizable-e",
  2720. s: ".ui-resizable-s",
  2721. w: ".ui-resizable-w",
  2722. se: ".ui-resizable-se",
  2723. sw: ".ui-resizable-sw",
  2724. ne: ".ui-resizable-ne",
  2725. nw: ".ui-resizable-nw"
  2726. } );
  2727. if (this.handles.constructor === String) {
  2728. if ( this.handles === "all") {
  2729. this.handles = "n,e,s,w,se,sw,ne,nw";
  2730. }
  2731. n = this.handles.split(",");
  2732. this.handles = {};
  2733. for (i = 0; i < n.length; i++) {
  2734. handle = $.trim(n[i]);
  2735. hname = "ui-resizable-" + handle;
  2736. axis = $("<div class='ui-resizable-handle " + hname + "'></div>");
  2737. axis.css({ zIndex: o.zIndex });
  2738. // TODO : What's going on here?
  2739. if ("se" === handle) {
  2740. axis.addClass("ui-icon ui-icon-gripsmall-diagonal-se");
  2741. }
  2742. this.handles[handle] = ".ui-resizable-" + handle;
  2743. this.element.append(axis);
  2744. }
  2745. }
  2746. this._renderAxis = function(target) {
  2747. var i, axis, padPos, padWrapper;
  2748. target = target || this.element;
  2749. for (i in this.handles) {
  2750. if (this.handles[i].constructor === String) {
  2751. this.handles[i] = this.element.children( this.handles[ i ] ).first().show();
  2752. }
  2753. if (this.elementIsWrapper && this.originalElement[0].nodeName.match(/textarea|input|select|button/i)) {
  2754. axis = $(this.handles[i], this.element);
  2755. padWrapper = /sw|ne|nw|se|n|s/.test(i) ? axis.outerHeight() : axis.outerWidth();
  2756. padPos = [ "padding",
  2757. /ne|nw|n/.test(i) ? "Top" :
  2758. /se|sw|s/.test(i) ? "Bottom" :
  2759. /^e$/.test(i) ? "Right" : "Left" ].join("");
  2760. target.css(padPos, padWrapper);
  2761. this._proportionallyResize();
  2762. }
  2763. // TODO: What's that good for? There's not anything to be executed left
  2764. if (!$(this.handles[i]).length) {
  2765. continue;
  2766. }
  2767. }
  2768. };
  2769. // TODO: make renderAxis a prototype function
  2770. this._renderAxis(this.element);
  2771. this._handles = $(".ui-resizable-handle", this.element)
  2772. .disableSelection();
  2773. this._handles.mouseover(function() {
  2774. if (!that.resizing) {
  2775. if (this.className) {
  2776. axis = this.className.match(/ui-resizable-(se|sw|ne|nw|n|e|s|w)/i);
  2777. }
  2778. that.axis = axis && axis[1] ? axis[1] : "se";
  2779. }
  2780. });
  2781. if (o.autoHide) {
  2782. this._handles.hide();
  2783. $(this.element)
  2784. .addClass("ui-resizable-autohide")
  2785. .mouseenter(function() {
  2786. if (o.disabled) {
  2787. return;
  2788. }
  2789. $(this).removeClass("ui-resizable-autohide");
  2790. that._handles.show();
  2791. })
  2792. .mouseleave(function() {
  2793. if (o.disabled) {
  2794. return;
  2795. }
  2796. if (!that.resizing) {
  2797. $(this).addClass("ui-resizable-autohide");
  2798. that._handles.hide();
  2799. }
  2800. });
  2801. }
  2802. this._mouseInit();
  2803. },
  2804. _destroy: function() {
  2805. this._mouseDestroy();
  2806. var wrapper,
  2807. _destroy = function(exp) {
  2808. $(exp)
  2809. .removeClass("ui-resizable ui-resizable-disabled ui-resizable-resizing")
  2810. .removeData("resizable")
  2811. .removeData("ui-resizable")
  2812. .unbind(".resizable")
  2813. .find(".ui-resizable-handle")
  2814. .remove();
  2815. };
  2816. // TODO: Unwrap at same DOM position
  2817. if (this.elementIsWrapper) {
  2818. _destroy(this.element);
  2819. wrapper = this.element;
  2820. this.originalElement.css({
  2821. position: wrapper.css("position"),
  2822. width: wrapper.outerWidth(),
  2823. height: wrapper.outerHeight(),
  2824. top: wrapper.css("top"),
  2825. left: wrapper.css("left")
  2826. }).insertAfter( wrapper );
  2827. wrapper.remove();
  2828. }
  2829. this.originalElement.css("resize", this.originalResizeStyle);
  2830. _destroy(this.originalElement);
  2831. return this;
  2832. },
  2833. _mouseCapture: function(event) {
  2834. var i, handle,
  2835. capture = false;
  2836. for (i in this.handles) {
  2837. handle = $(this.handles[i])[0];
  2838. if (handle === event.target || $.contains(handle, event.target)) {
  2839. capture = true;
  2840. }
  2841. }
  2842. return !this.options.disabled && capture;
  2843. },
  2844. _mouseStart: function(event) {
  2845. var curleft, curtop, cursor,
  2846. o = this.options,
  2847. el = this.element;
  2848. this.resizing = true;
  2849. this._renderProxy();
  2850. curleft = this._num(this.helper.css("left"));
  2851. curtop = this._num(this.helper.css("top"));
  2852. if (o.containment) {
  2853. curleft += $(o.containment).scrollLeft() || 0;
  2854. curtop += $(o.containment).scrollTop() || 0;
  2855. }
  2856. this.offset = this.helper.offset();
  2857. this.position = { left: curleft, top: curtop };
  2858. this.size = this._helper ? {
  2859. width: this.helper.width(),
  2860. height: this.helper.height()
  2861. } : {
  2862. width: el.width(),
  2863. height: el.height()
  2864. };
  2865. this.originalSize = this._helper ? {
  2866. width: el.outerWidth(),
  2867. height: el.outerHeight()
  2868. } : {
  2869. width: el.width(),
  2870. height: el.height()
  2871. };
  2872. this.sizeDiff = {
  2873. width: el.outerWidth() - el.width(),
  2874. height: el.outerHeight() - el.height()
  2875. };
  2876. this.originalPosition = { left: curleft, top: curtop };
  2877. this.originalMousePosition = { left: event.pageX, top: event.pageY };
  2878. this.aspectRatio = (typeof o.aspectRatio === "number") ?
  2879. o.aspectRatio :
  2880. ((this.originalSize.width / this.originalSize.height) || 1);
  2881. cursor = $(".ui-resizable-" + this.axis).css("cursor");
  2882. $("body").css("cursor", cursor === "auto" ? this.axis + "-resize" : cursor);
  2883. el.addClass("ui-resizable-resizing");
  2884. this._propagate("start", event);
  2885. return true;
  2886. },
  2887. _mouseDrag: function(event) {
  2888. var data, props,
  2889. smp = this.originalMousePosition,
  2890. a = this.axis,
  2891. dx = (event.pageX - smp.left) || 0,
  2892. dy = (event.pageY - smp.top) || 0,
  2893. trigger = this._change[a];
  2894. this._updatePrevProperties();
  2895. if (!trigger) {
  2896. return false;
  2897. }
  2898. data = trigger.apply(this, [ event, dx, dy ]);
  2899. this._updateVirtualBoundaries(event.shiftKey);
  2900. if (this._aspectRatio || event.shiftKey) {
  2901. data = this._updateRatio(data, event);
  2902. }
  2903. data = this._respectSize(data, event);
  2904. this._updateCache(data);
  2905. this._propagate("resize", event);
  2906. props = this._applyChanges();
  2907. if ( !this._helper && this._proportionallyResizeElements.length ) {
  2908. this._proportionallyResize();
  2909. }
  2910. if ( !$.isEmptyObject( props ) ) {
  2911. this._updatePrevProperties();
  2912. this._trigger( "resize", event, this.ui() );
  2913. this._applyChanges();
  2914. }
  2915. return false;
  2916. },
  2917. _mouseStop: function(event) {
  2918. this.resizing = false;
  2919. var pr, ista, soffseth, soffsetw, s, left, top,
  2920. o = this.options, that = this;
  2921. if (this._helper) {
  2922. pr = this._proportionallyResizeElements;
  2923. ista = pr.length && (/textarea/i).test(pr[0].nodeName);
  2924. soffseth = ista && this._hasScroll(pr[0], "left") ? 0 : that.sizeDiff.height;
  2925. soffsetw = ista ? 0 : that.sizeDiff.width;
  2926. s = {
  2927. width: (that.helper.width() - soffsetw),
  2928. height: (that.helper.height() - soffseth)
  2929. };
  2930. left = (parseInt(that.element.css("left"), 10) +
  2931. (that.position.left - that.originalPosition.left)) || null;
  2932. top = (parseInt(that.element.css("top"), 10) +
  2933. (that.position.top - that.originalPosition.top)) || null;
  2934. if (!o.animate) {
  2935. this.element.css($.extend(s, { top: top, left: left }));
  2936. }
  2937. that.helper.height(that.size.height);
  2938. that.helper.width(that.size.width);
  2939. if (this._helper && !o.animate) {
  2940. this._proportionallyResize();
  2941. }
  2942. }
  2943. $("body").css("cursor", "auto");
  2944. this.element.removeClass("ui-resizable-resizing");
  2945. this._propagate("stop", event);
  2946. if (this._helper) {
  2947. this.helper.remove();
  2948. }
  2949. return false;
  2950. },
  2951. _updatePrevProperties: function() {
  2952. this.prevPosition = {
  2953. top: this.position.top,
  2954. left: this.position.left
  2955. };
  2956. this.prevSize = {
  2957. width: this.size.width,
  2958. height: this.size.height
  2959. };
  2960. },
  2961. _applyChanges: function() {
  2962. var props = {};
  2963. if ( this.position.top !== this.prevPosition.top ) {
  2964. props.top = this.position.top + "px";
  2965. }
  2966. if ( this.position.left !== this.prevPosition.left ) {
  2967. props.left = this.position.left + "px";
  2968. }
  2969. if ( this.size.width !== this.prevSize.width ) {
  2970. props.width = this.size.width + "px";
  2971. }
  2972. if ( this.size.height !== this.prevSize.height ) {
  2973. props.height = this.size.height + "px";
  2974. }
  2975. this.helper.css( props );
  2976. return props;
  2977. },
  2978. _updateVirtualBoundaries: function(forceAspectRatio) {
  2979. var pMinWidth, pMaxWidth, pMinHeight, pMaxHeight, b,
  2980. o = this.options;
  2981. b = {
  2982. minWidth: this._isNumber(o.minWidth) ? o.minWidth : 0,
  2983. maxWidth: this._isNumber(o.maxWidth) ? o.maxWidth : Infinity,
  2984. minHeight: this._isNumber(o.minHeight) ? o.minHeight : 0,
  2985. maxHeight: this._isNumber(o.maxHeight) ? o.maxHeight : Infinity
  2986. };
  2987. if (this._aspectRatio || forceAspectRatio) {
  2988. pMinWidth = b.minHeight * this.aspectRatio;
  2989. pMinHeight = b.minWidth / this.aspectRatio;
  2990. pMaxWidth = b.maxHeight * this.aspectRatio;
  2991. pMaxHeight = b.maxWidth / this.aspectRatio;
  2992. if (pMinWidth > b.minWidth) {
  2993. b.minWidth = pMinWidth;
  2994. }
  2995. if (pMinHeight > b.minHeight) {
  2996. b.minHeight = pMinHeight;
  2997. }
  2998. if (pMaxWidth < b.maxWidth) {
  2999. b.maxWidth = pMaxWidth;
  3000. }
  3001. if (pMaxHeight < b.maxHeight) {
  3002. b.maxHeight = pMaxHeight;
  3003. }
  3004. }
  3005. this._vBoundaries = b;
  3006. },
  3007. _updateCache: function(data) {
  3008. this.offset = this.helper.offset();
  3009. if (this._isNumber(data.left)) {
  3010. this.position.left = data.left;
  3011. }
  3012. if (this._isNumber(data.top)) {
  3013. this.position.top = data.top;
  3014. }
  3015. if (this._isNumber(data.height)) {
  3016. this.size.height = data.height;
  3017. }
  3018. if (this._isNumber(data.width)) {
  3019. this.size.width = data.width;
  3020. }
  3021. },
  3022. _updateRatio: function( data ) {
  3023. var cpos = this.position,
  3024. csize = this.size,
  3025. a = this.axis;
  3026. if (this._isNumber(data.height)) {
  3027. data.width = (data.height * this.aspectRatio);
  3028. } else if (this._isNumber(data.width)) {
  3029. data.height = (data.width / this.aspectRatio);
  3030. }
  3031. if (a === "sw") {
  3032. data.left = cpos.left + (csize.width - data.width);
  3033. data.top = null;
  3034. }
  3035. if (a === "nw") {
  3036. data.top = cpos.top + (csize.height - data.height);
  3037. data.left = cpos.left + (csize.width - data.width);
  3038. }
  3039. return data;
  3040. },
  3041. _respectSize: function( data ) {
  3042. var o = this._vBoundaries,
  3043. a = this.axis,
  3044. ismaxw = this._isNumber(data.width) && o.maxWidth && (o.maxWidth < data.width),
  3045. ismaxh = this._isNumber(data.height) && o.maxHeight && (o.maxHeight < data.height),
  3046. isminw = this._isNumber(data.width) && o.minWidth && (o.minWidth > data.width),
  3047. isminh = this._isNumber(data.height) && o.minHeight && (o.minHeight > data.height),
  3048. dw = this.originalPosition.left + this.originalSize.width,
  3049. dh = this.position.top + this.size.height,
  3050. cw = /sw|nw|w/.test(a), ch = /nw|ne|n/.test(a);
  3051. if (isminw) {
  3052. data.width = o.minWidth;
  3053. }
  3054. if (isminh) {
  3055. data.height = o.minHeight;
  3056. }
  3057. if (ismaxw) {
  3058. data.width = o.maxWidth;
  3059. }
  3060. if (ismaxh) {
  3061. data.height = o.maxHeight;
  3062. }
  3063. if (isminw && cw) {
  3064. data.left = dw - o.minWidth;
  3065. }
  3066. if (ismaxw && cw) {
  3067. data.left = dw - o.maxWidth;
  3068. }
  3069. if (isminh && ch) {
  3070. data.top = dh - o.minHeight;
  3071. }
  3072. if (ismaxh && ch) {
  3073. data.top = dh - o.maxHeight;
  3074. }
  3075. // Fixing jump error on top/left - bug #2330
  3076. if (!data.width && !data.height && !data.left && data.top) {
  3077. data.top = null;
  3078. } else if (!data.width && !data.height && !data.top && data.left) {
  3079. data.left = null;
  3080. }
  3081. return data;
  3082. },
  3083. _getPaddingPlusBorderDimensions: function( element ) {
  3084. var i = 0,
  3085. widths = [],
  3086. borders = [
  3087. element.css( "borderTopWidth" ),
  3088. element.css( "borderRightWidth" ),
  3089. element.css( "borderBottomWidth" ),
  3090. element.css( "borderLeftWidth" )
  3091. ],
  3092. paddings = [
  3093. element.css( "paddingTop" ),
  3094. element.css( "paddingRight" ),
  3095. element.css( "paddingBottom" ),
  3096. element.css( "paddingLeft" )
  3097. ];
  3098. for ( ; i < 4; i++ ) {
  3099. widths[ i ] = ( parseInt( borders[ i ], 10 ) || 0 );
  3100. widths[ i ] += ( parseInt( paddings[ i ], 10 ) || 0 );
  3101. }
  3102. return {
  3103. height: widths[ 0 ] + widths[ 2 ],
  3104. width: widths[ 1 ] + widths[ 3 ]
  3105. };
  3106. },
  3107. _proportionallyResize: function() {
  3108. if (!this._proportionallyResizeElements.length) {
  3109. return;
  3110. }
  3111. var prel,
  3112. i = 0,
  3113. element = this.helper || this.element;
  3114. for ( ; i < this._proportionallyResizeElements.length; i++) {
  3115. prel = this._proportionallyResizeElements[i];
  3116. // TODO: Seems like a bug to cache this.outerDimensions
  3117. // considering that we are in a loop.
  3118. if (!this.outerDimensions) {
  3119. this.outerDimensions = this._getPaddingPlusBorderDimensions( prel );
  3120. }
  3121. prel.css({
  3122. height: (element.height() - this.outerDimensions.height) || 0,
  3123. width: (element.width() - this.outerDimensions.width) || 0
  3124. });
  3125. }
  3126. },
  3127. _renderProxy: function() {
  3128. var el = this.element, o = this.options;
  3129. this.elementOffset = el.offset();
  3130. if (this._helper) {
  3131. this.helper = this.helper || $("<div style='overflow:hidden;'></div>");
  3132. this.helper.addClass(this._helper).css({
  3133. width: this.element.outerWidth() - 1,
  3134. height: this.element.outerHeight() - 1,
  3135. position: "absolute",
  3136. left: this.elementOffset.left + "px",
  3137. top: this.elementOffset.top + "px",
  3138. zIndex: ++o.zIndex //TODO: Don't modify option
  3139. });
  3140. this.helper
  3141. .appendTo("body")
  3142. .disableSelection();
  3143. } else {
  3144. this.helper = this.element;
  3145. }
  3146. },
  3147. _change: {
  3148. e: function(event, dx) {
  3149. return { width: this.originalSize.width + dx };
  3150. },
  3151. w: function(event, dx) {
  3152. var cs = this.originalSize, sp = this.originalPosition;
  3153. return { left: sp.left + dx, width: cs.width - dx };
  3154. },
  3155. n: function(event, dx, dy) {
  3156. var cs = this.originalSize, sp = this.originalPosition;
  3157. return { top: sp.top + dy, height: cs.height - dy };
  3158. },
  3159. s: function(event, dx, dy) {
  3160. return { height: this.originalSize.height + dy };
  3161. },
  3162. se: function(event, dx, dy) {
  3163. return $.extend(this._change.s.apply(this, arguments),
  3164. this._change.e.apply(this, [ event, dx, dy ]));
  3165. },
  3166. sw: function(event, dx, dy) {
  3167. return $.extend(this._change.s.apply(this, arguments),
  3168. this._change.w.apply(this, [ event, dx, dy ]));
  3169. },
  3170. ne: function(event, dx, dy) {
  3171. return $.extend(this._change.n.apply(this, arguments),
  3172. this._change.e.apply(this, [ event, dx, dy ]));
  3173. },
  3174. nw: function(event, dx, dy) {
  3175. return $.extend(this._change.n.apply(this, arguments),
  3176. this._change.w.apply(this, [ event, dx, dy ]));
  3177. }
  3178. },
  3179. _propagate: function(n, event) {
  3180. $.ui.plugin.call(this, n, [ event, this.ui() ]);
  3181. (n !== "resize" && this._trigger(n, event, this.ui()));
  3182. },
  3183. plugins: {},
  3184. ui: function() {
  3185. return {
  3186. originalElement: this.originalElement,
  3187. element: this.element,
  3188. helper: this.helper,
  3189. position: this.position,
  3190. size: this.size,
  3191. originalSize: this.originalSize,
  3192. originalPosition: this.originalPosition
  3193. };
  3194. }
  3195. });
  3196. /*
  3197. * Resizable Extensions
  3198. */
  3199. $.ui.plugin.add("resizable", "animate", {
  3200. stop: function( event ) {
  3201. var that = $(this).resizable( "instance" ),
  3202. o = that.options,
  3203. pr = that._proportionallyResizeElements,
  3204. ista = pr.length && (/textarea/i).test(pr[0].nodeName),
  3205. soffseth = ista && that._hasScroll(pr[0], "left") ? 0 : that.sizeDiff.height,
  3206. soffsetw = ista ? 0 : that.sizeDiff.width,
  3207. style = { width: (that.size.width - soffsetw), height: (that.size.height - soffseth) },
  3208. left = (parseInt(that.element.css("left"), 10) +
  3209. (that.position.left - that.originalPosition.left)) || null,
  3210. top = (parseInt(that.element.css("top"), 10) +
  3211. (that.position.top - that.originalPosition.top)) || null;
  3212. that.element.animate(
  3213. $.extend(style, top && left ? { top: top, left: left } : {}), {
  3214. duration: o.animateDuration,
  3215. easing: o.animateEasing,
  3216. step: function() {
  3217. var data = {
  3218. width: parseInt(that.element.css("width"), 10),
  3219. height: parseInt(that.element.css("height"), 10),
  3220. top: parseInt(that.element.css("top"), 10),
  3221. left: parseInt(that.element.css("left"), 10)
  3222. };
  3223. if (pr && pr.length) {
  3224. $(pr[0]).css({ width: data.width, height: data.height });
  3225. }
  3226. // propagating resize, and updating values for each animation step
  3227. that._updateCache(data);
  3228. that._propagate("resize", event);
  3229. }
  3230. }
  3231. );
  3232. }
  3233. });
  3234. $.ui.plugin.add( "resizable", "containment", {
  3235. start: function() {
  3236. var element, p, co, ch, cw, width, height,
  3237. that = $( this ).resizable( "instance" ),
  3238. o = that.options,
  3239. el = that.element,
  3240. oc = o.containment,
  3241. ce = ( oc instanceof $ ) ? oc.get( 0 ) : ( /parent/.test( oc ) ) ? el.parent().get( 0 ) : oc;
  3242. if ( !ce ) {
  3243. return;
  3244. }
  3245. that.containerElement = $( ce );
  3246. if ( /document/.test( oc ) || oc === document ) {
  3247. that.containerOffset = {
  3248. left: 0,
  3249. top: 0
  3250. };
  3251. that.containerPosition = {
  3252. left: 0,
  3253. top: 0
  3254. };
  3255. that.parentData = {
  3256. element: $( document ),
  3257. left: 0,
  3258. top: 0,
  3259. width: $( document ).width(),
  3260. height: $( document ).height() || document.body.parentNode.scrollHeight
  3261. };
  3262. } else {
  3263. element = $( ce );
  3264. p = [];
  3265. $([ "Top", "Right", "Left", "Bottom" ]).each(function( i, name ) {
  3266. p[ i ] = that._num( element.css( "padding" + name ) );
  3267. });
  3268. that.containerOffset = element.offset();
  3269. that.containerPosition = element.position();
  3270. that.containerSize = {
  3271. height: ( element.innerHeight() - p[ 3 ] ),
  3272. width: ( element.innerWidth() - p[ 1 ] )
  3273. };
  3274. co = that.containerOffset;
  3275. ch = that.containerSize.height;
  3276. cw = that.containerSize.width;
  3277. width = ( that._hasScroll ( ce, "left" ) ? ce.scrollWidth : cw );
  3278. height = ( that._hasScroll ( ce ) ? ce.scrollHeight : ch ) ;
  3279. that.parentData = {
  3280. element: ce,
  3281. left: co.left,
  3282. top: co.top,
  3283. width: width,
  3284. height: height
  3285. };
  3286. }
  3287. },
  3288. resize: function( event ) {
  3289. var woset, hoset, isParent, isOffsetRelative,
  3290. that = $( this ).resizable( "instance" ),
  3291. o = that.options,
  3292. co = that.containerOffset,
  3293. cp = that.position,
  3294. pRatio = that._aspectRatio || event.shiftKey,
  3295. cop = {
  3296. top: 0,
  3297. left: 0
  3298. },
  3299. ce = that.containerElement,
  3300. continueResize = true;
  3301. if ( ce[ 0 ] !== document && ( /static/ ).test( ce.css( "position" ) ) ) {
  3302. cop = co;
  3303. }
  3304. if ( cp.left < ( that._helper ? co.left : 0 ) ) {
  3305. that.size.width = that.size.width +
  3306. ( that._helper ?
  3307. ( that.position.left - co.left ) :
  3308. ( that.position.left - cop.left ) );
  3309. if ( pRatio ) {
  3310. that.size.height = that.size.width / that.aspectRatio;
  3311. continueResize = false;
  3312. }
  3313. that.position.left = o.helper ? co.left : 0;
  3314. }
  3315. if ( cp.top < ( that._helper ? co.top : 0 ) ) {
  3316. that.size.height = that.size.height +
  3317. ( that._helper ?
  3318. ( that.position.top - co.top ) :
  3319. that.position.top );
  3320. if ( pRatio ) {
  3321. that.size.width = that.size.height * that.aspectRatio;
  3322. continueResize = false;
  3323. }
  3324. that.position.top = that._helper ? co.top : 0;
  3325. }
  3326. isParent = that.containerElement.get( 0 ) === that.element.parent().get( 0 );
  3327. isOffsetRelative = /relative|absolute/.test( that.containerElement.css( "position" ) );
  3328. if ( isParent && isOffsetRelative ) {
  3329. that.offset.left = that.parentData.left + that.position.left;
  3330. that.offset.top = that.parentData.top + that.position.top;
  3331. } else {
  3332. that.offset.left = that.element.offset().left;
  3333. that.offset.top = that.element.offset().top;
  3334. }
  3335. woset = Math.abs( that.sizeDiff.width +
  3336. (that._helper ?
  3337. that.offset.left - cop.left :
  3338. (that.offset.left - co.left)) );
  3339. hoset = Math.abs( that.sizeDiff.height +
  3340. (that._helper ?
  3341. that.offset.top - cop.top :
  3342. (that.offset.top - co.top)) );
  3343. if ( woset + that.size.width >= that.parentData.width ) {
  3344. that.size.width = that.parentData.width - woset;
  3345. if ( pRatio ) {
  3346. that.size.height = that.size.width / that.aspectRatio;
  3347. continueResize = false;
  3348. }
  3349. }
  3350. if ( hoset + that.size.height >= that.parentData.height ) {
  3351. that.size.height = that.parentData.height - hoset;
  3352. if ( pRatio ) {
  3353. that.size.width = that.size.height * that.aspectRatio;
  3354. continueResize = false;
  3355. }
  3356. }
  3357. if ( !continueResize ){
  3358. that.position.left = that.prevPosition.left;
  3359. that.position.top = that.prevPosition.top;
  3360. that.size.width = that.prevSize.width;
  3361. that.size.height = that.prevSize.height;
  3362. }
  3363. },
  3364. stop: function() {
  3365. var that = $( this ).resizable( "instance" ),
  3366. o = that.options,
  3367. co = that.containerOffset,
  3368. cop = that.containerPosition,
  3369. ce = that.containerElement,
  3370. helper = $( that.helper ),
  3371. ho = helper.offset(),
  3372. w = helper.outerWidth() - that.sizeDiff.width,
  3373. h = helper.outerHeight() - that.sizeDiff.height;
  3374. if ( that._helper && !o.animate && ( /relative/ ).test( ce.css( "position" ) ) ) {
  3375. $( this ).css({
  3376. left: ho.left - cop.left - co.left,
  3377. width: w,
  3378. height: h
  3379. });
  3380. }
  3381. if ( that._helper && !o.animate && ( /static/ ).test( ce.css( "position" ) ) ) {
  3382. $( this ).css({
  3383. left: ho.left - cop.left - co.left,
  3384. width: w,
  3385. height: h
  3386. });
  3387. }
  3388. }
  3389. });
  3390. $.ui.plugin.add("resizable", "alsoResize", {
  3391. start: function() {
  3392. var that = $(this).resizable( "instance" ),
  3393. o = that.options,
  3394. _store = function(exp) {
  3395. $(exp).each(function() {
  3396. var el = $(this);
  3397. el.data("ui-resizable-alsoresize", {
  3398. width: parseInt(el.width(), 10), height: parseInt(el.height(), 10),
  3399. left: parseInt(el.css("left"), 10), top: parseInt(el.css("top"), 10)
  3400. });
  3401. });
  3402. };
  3403. if (typeof(o.alsoResize) === "object" && !o.alsoResize.parentNode) {
  3404. if (o.alsoResize.length) {
  3405. o.alsoResize = o.alsoResize[0];
  3406. _store(o.alsoResize);
  3407. } else {
  3408. $.each(o.alsoResize, function(exp) {
  3409. _store(exp);
  3410. });
  3411. }
  3412. } else {
  3413. _store(o.alsoResize);
  3414. }
  3415. },
  3416. resize: function(event, ui) {
  3417. var that = $(this).resizable( "instance" ),
  3418. o = that.options,
  3419. os = that.originalSize,
  3420. op = that.originalPosition,
  3421. delta = {
  3422. height: (that.size.height - os.height) || 0,
  3423. width: (that.size.width - os.width) || 0,
  3424. top: (that.position.top - op.top) || 0,
  3425. left: (that.position.left - op.left) || 0
  3426. },
  3427. _alsoResize = function(exp, c) {
  3428. $(exp).each(function() {
  3429. var el = $(this), start = $(this).data("ui-resizable-alsoresize"), style = {},
  3430. css = c && c.length ?
  3431. c :
  3432. el.parents(ui.originalElement[0]).length ?
  3433. [ "width", "height" ] :
  3434. [ "width", "height", "top", "left" ];
  3435. $.each(css, function(i, prop) {
  3436. var sum = (start[prop] || 0) + (delta[prop] || 0);
  3437. if (sum && sum >= 0) {
  3438. style[prop] = sum || null;
  3439. }
  3440. });
  3441. el.css(style);
  3442. });
  3443. };
  3444. if (typeof(o.alsoResize) === "object" && !o.alsoResize.nodeType) {
  3445. $.each(o.alsoResize, function(exp, c) {
  3446. _alsoResize(exp, c);
  3447. });
  3448. } else {
  3449. _alsoResize(o.alsoResize);
  3450. }
  3451. },
  3452. stop: function() {
  3453. $(this).removeData("resizable-alsoresize");
  3454. }
  3455. });
  3456. $.ui.plugin.add("resizable", "ghost", {
  3457. start: function() {
  3458. var that = $(this).resizable( "instance" ), o = that.options, cs = that.size;
  3459. that.ghost = that.originalElement.clone();
  3460. that.ghost
  3461. .css({
  3462. opacity: 0.25,
  3463. display: "block",
  3464. position: "relative",
  3465. height: cs.height,
  3466. width: cs.width,
  3467. margin: 0,
  3468. left: 0,
  3469. top: 0
  3470. })
  3471. .addClass("ui-resizable-ghost")
  3472. .addClass(typeof o.ghost === "string" ? o.ghost : "");
  3473. that.ghost.appendTo(that.helper);
  3474. },
  3475. resize: function() {
  3476. var that = $(this).resizable( "instance" );
  3477. if (that.ghost) {
  3478. that.ghost.css({
  3479. position: "relative",
  3480. height: that.size.height,
  3481. width: that.size.width
  3482. });
  3483. }
  3484. },
  3485. stop: function() {
  3486. var that = $(this).resizable( "instance" );
  3487. if (that.ghost && that.helper) {
  3488. that.helper.get(0).removeChild(that.ghost.get(0));
  3489. }
  3490. }
  3491. });
  3492. $.ui.plugin.add("resizable", "grid", {
  3493. resize: function() {
  3494. var outerDimensions,
  3495. that = $(this).resizable( "instance" ),
  3496. o = that.options,
  3497. cs = that.size,
  3498. os = that.originalSize,
  3499. op = that.originalPosition,
  3500. a = that.axis,
  3501. grid = typeof o.grid === "number" ? [ o.grid, o.grid ] : o.grid,
  3502. gridX = (grid[0] || 1),
  3503. gridY = (grid[1] || 1),
  3504. ox = Math.round((cs.width - os.width) / gridX) * gridX,
  3505. oy = Math.round((cs.height - os.height) / gridY) * gridY,
  3506. newWidth = os.width + ox,
  3507. newHeight = os.height + oy,
  3508. isMaxWidth = o.maxWidth && (o.maxWidth < newWidth),
  3509. isMaxHeight = o.maxHeight && (o.maxHeight < newHeight),
  3510. isMinWidth = o.minWidth && (o.minWidth > newWidth),
  3511. isMinHeight = o.minHeight && (o.minHeight > newHeight);
  3512. o.grid = grid;
  3513. if (isMinWidth) {
  3514. newWidth += gridX;
  3515. }
  3516. if (isMinHeight) {
  3517. newHeight += gridY;
  3518. }
  3519. if (isMaxWidth) {
  3520. newWidth -= gridX;
  3521. }
  3522. if (isMaxHeight) {
  3523. newHeight -= gridY;
  3524. }
  3525. if (/^(se|s|e)$/.test(a)) {
  3526. that.size.width = newWidth;
  3527. that.size.height = newHeight;
  3528. } else if (/^(ne)$/.test(a)) {
  3529. that.size.width = newWidth;
  3530. that.size.height = newHeight;
  3531. that.position.top = op.top - oy;
  3532. } else if (/^(sw)$/.test(a)) {
  3533. that.size.width = newWidth;
  3534. that.size.height = newHeight;
  3535. that.position.left = op.left - ox;
  3536. } else {
  3537. if ( newHeight - gridY <= 0 || newWidth - gridX <= 0) {
  3538. outerDimensions = that._getPaddingPlusBorderDimensions( this );
  3539. }
  3540. if ( newHeight - gridY > 0 ) {
  3541. that.size.height = newHeight;
  3542. that.position.top = op.top - oy;
  3543. } else {
  3544. newHeight = gridY - outerDimensions.height;
  3545. that.size.height = newHeight;
  3546. that.position.top = op.top + os.height - newHeight;
  3547. }
  3548. if ( newWidth - gridX > 0 ) {
  3549. that.size.width = newWidth;
  3550. that.position.left = op.left - ox;
  3551. } else {
  3552. newWidth = gridY - outerDimensions.height;
  3553. that.size.width = newWidth;
  3554. that.position.left = op.left + os.width - newWidth;
  3555. }
  3556. }
  3557. }
  3558. });
  3559. var resizable = $.ui.resizable;
  3560. /*!
  3561. * jQuery UI Selectable 1.11.2
  3562. * http://jqueryui.com
  3563. *
  3564. * Copyright 2014 jQuery Foundation and other contributors
  3565. * Released under the MIT license.
  3566. * http://jquery.org/license
  3567. *
  3568. * http://api.jqueryui.com/selectable/
  3569. */
  3570. var selectable = $.widget("ui.selectable", $.ui.mouse, {
  3571. version: "1.11.2",
  3572. options: {
  3573. appendTo: "body",
  3574. autoRefresh: true,
  3575. distance: 0,
  3576. filter: "*",
  3577. tolerance: "touch",
  3578. // callbacks
  3579. selected: null,
  3580. selecting: null,
  3581. start: null,
  3582. stop: null,
  3583. unselected: null,
  3584. unselecting: null
  3585. },
  3586. _create: function() {
  3587. var selectees,
  3588. that = this;
  3589. this.element.addClass("ui-selectable");
  3590. this.dragged = false;
  3591. // cache selectee children based on filter
  3592. this.refresh = function() {
  3593. selectees = $(that.options.filter, that.element[0]);
  3594. selectees.addClass("ui-selectee");
  3595. selectees.each(function() {
  3596. var $this = $(this),
  3597. pos = $this.offset();
  3598. $.data(this, "selectable-item", {
  3599. element: this,
  3600. $element: $this,
  3601. left: pos.left,
  3602. top: pos.top,
  3603. right: pos.left + $this.outerWidth(),
  3604. bottom: pos.top + $this.outerHeight(),
  3605. startselected: false,
  3606. selected: $this.hasClass("ui-selected"),
  3607. selecting: $this.hasClass("ui-selecting"),
  3608. unselecting: $this.hasClass("ui-unselecting")
  3609. });
  3610. });
  3611. };
  3612. this.refresh();
  3613. this.selectees = selectees.addClass("ui-selectee");
  3614. this._mouseInit();
  3615. this.helper = $("<div class='ui-selectable-helper'></div>");
  3616. },
  3617. _destroy: function() {
  3618. this.selectees
  3619. .removeClass("ui-selectee")
  3620. .removeData("selectable-item");
  3621. this.element
  3622. .removeClass("ui-selectable ui-selectable-disabled");
  3623. this._mouseDestroy();
  3624. },
  3625. _mouseStart: function(event) {
  3626. var that = this,
  3627. options = this.options;
  3628. this.opos = [ event.pageX, event.pageY ];
  3629. if (this.options.disabled) {
  3630. return;
  3631. }
  3632. this.selectees = $(options.filter, this.element[0]);
  3633. this._trigger("start", event);
  3634. $(options.appendTo).append(this.helper);
  3635. // position helper (lasso)
  3636. this.helper.css({
  3637. "left": event.pageX,
  3638. "top": event.pageY,
  3639. "width": 0,
  3640. "height": 0
  3641. });
  3642. if (options.autoRefresh) {
  3643. this.refresh();
  3644. }
  3645. this.selectees.filter(".ui-selected").each(function() {
  3646. var selectee = $.data(this, "selectable-item");
  3647. selectee.startselected = true;
  3648. if (!event.metaKey && !event.ctrlKey) {
  3649. selectee.$element.removeClass("ui-selected");
  3650. selectee.selected = false;
  3651. selectee.$element.addClass("ui-unselecting");
  3652. selectee.unselecting = true;
  3653. // selectable UNSELECTING callback
  3654. that._trigger("unselecting", event, {
  3655. unselecting: selectee.element
  3656. });
  3657. }
  3658. });
  3659. $(event.target).parents().addBack().each(function() {
  3660. var doSelect,
  3661. selectee = $.data(this, "selectable-item");
  3662. if (selectee) {
  3663. doSelect = (!event.metaKey && !event.ctrlKey) || !selectee.$element.hasClass("ui-selected");
  3664. selectee.$element
  3665. .removeClass(doSelect ? "ui-unselecting" : "ui-selected")
  3666. .addClass(doSelect ? "ui-selecting" : "ui-unselecting");
  3667. selectee.unselecting = !doSelect;
  3668. selectee.selecting = doSelect;
  3669. selectee.selected = doSelect;
  3670. // selectable (UN)SELECTING callback
  3671. if (doSelect) {
  3672. that._trigger("selecting", event, {
  3673. selecting: selectee.element
  3674. });
  3675. } else {
  3676. that._trigger("unselecting", event, {
  3677. unselecting: selectee.element
  3678. });
  3679. }
  3680. return false;
  3681. }
  3682. });
  3683. },
  3684. _mouseDrag: function(event) {
  3685. this.dragged = true;
  3686. if (this.options.disabled) {
  3687. return;
  3688. }
  3689. var tmp,
  3690. that = this,
  3691. options = this.options,
  3692. x1 = this.opos[0],
  3693. y1 = this.opos[1],
  3694. x2 = event.pageX,
  3695. y2 = event.pageY;
  3696. if (x1 > x2) { tmp = x2; x2 = x1; x1 = tmp; }
  3697. if (y1 > y2) { tmp = y2; y2 = y1; y1 = tmp; }
  3698. this.helper.css({ left: x1, top: y1, width: x2 - x1, height: y2 - y1 });
  3699. this.selectees.each(function() {
  3700. var selectee = $.data(this, "selectable-item"),
  3701. hit = false;
  3702. //prevent helper from being selected if appendTo: selectable
  3703. if (!selectee || selectee.element === that.element[0]) {
  3704. return;
  3705. }
  3706. if (options.tolerance === "touch") {
  3707. hit = ( !(selectee.left > x2 || selectee.right < x1 || selectee.top > y2 || selectee.bottom < y1) );
  3708. } else if (options.tolerance === "fit") {
  3709. hit = (selectee.left > x1 && selectee.right < x2 && selectee.top > y1 && selectee.bottom < y2);
  3710. }
  3711. if (hit) {
  3712. // SELECT
  3713. if (selectee.selected) {
  3714. selectee.$element.removeClass("ui-selected");
  3715. selectee.selected = false;
  3716. }
  3717. if (selectee.unselecting) {
  3718. selectee.$element.removeClass("ui-unselecting");
  3719. selectee.unselecting = false;
  3720. }
  3721. if (!selectee.selecting) {
  3722. selectee.$element.addClass("ui-selecting");
  3723. selectee.selecting = true;
  3724. // selectable SELECTING callback
  3725. that._trigger("selecting", event, {
  3726. selecting: selectee.element
  3727. });
  3728. }
  3729. } else {
  3730. // UNSELECT
  3731. if (selectee.selecting) {
  3732. if ((event.metaKey || event.ctrlKey) && selectee.startselected) {
  3733. selectee.$element.removeClass("ui-selecting");
  3734. selectee.selecting = false;
  3735. selectee.$element.addClass("ui-selected");
  3736. selectee.selected = true;
  3737. } else {
  3738. selectee.$element.removeClass("ui-selecting");
  3739. selectee.selecting = false;
  3740. if (selectee.startselected) {
  3741. selectee.$element.addClass("ui-unselecting");
  3742. selectee.unselecting = true;
  3743. }
  3744. // selectable UNSELECTING callback
  3745. that._trigger("unselecting", event, {
  3746. unselecting: selectee.element
  3747. });
  3748. }
  3749. }
  3750. if (selectee.selected) {
  3751. if (!event.metaKey && !event.ctrlKey && !selectee.startselected) {
  3752. selectee.$element.removeClass("ui-selected");
  3753. selectee.selected = false;
  3754. selectee.$element.addClass("ui-unselecting");
  3755. selectee.unselecting = true;
  3756. // selectable UNSELECTING callback
  3757. that._trigger("unselecting", event, {
  3758. unselecting: selectee.element
  3759. });
  3760. }
  3761. }
  3762. }
  3763. });
  3764. return false;
  3765. },
  3766. _mouseStop: function(event) {
  3767. var that = this;
  3768. this.dragged = false;
  3769. $(".ui-unselecting", this.element[0]).each(function() {
  3770. var selectee = $.data(this, "selectable-item");
  3771. selectee.$element.removeClass("ui-unselecting");
  3772. selectee.unselecting = false;
  3773. selectee.startselected = false;
  3774. that._trigger("unselected", event, {
  3775. unselected: selectee.element
  3776. });
  3777. });
  3778. $(".ui-selecting", this.element[0]).each(function() {
  3779. var selectee = $.data(this, "selectable-item");
  3780. selectee.$element.removeClass("ui-selecting").addClass("ui-selected");
  3781. selectee.selecting = false;
  3782. selectee.selected = true;
  3783. selectee.startselected = true;
  3784. that._trigger("selected", event, {
  3785. selected: selectee.element
  3786. });
  3787. });
  3788. this._trigger("stop", event);
  3789. this.helper.remove();
  3790. return false;
  3791. }
  3792. });
  3793. /*!
  3794. * jQuery UI Sortable 1.11.2
  3795. * http://jqueryui.com
  3796. *
  3797. * Copyright 2014 jQuery Foundation and other contributors
  3798. * Released under the MIT license.
  3799. * http://jquery.org/license
  3800. *
  3801. * http://api.jqueryui.com/sortable/
  3802. */
  3803. var sortable = $.widget("ui.sortable", $.ui.mouse, {
  3804. version: "1.11.2",
  3805. widgetEventPrefix: "sort",
  3806. ready: false,
  3807. options: {
  3808. appendTo: "parent",
  3809. axis: false,
  3810. connectWith: false,
  3811. containment: false,
  3812. cursor: "auto",
  3813. cursorAt: false,
  3814. dropOnEmpty: true,
  3815. forcePlaceholderSize: false,
  3816. forceHelperSize: false,
  3817. grid: false,
  3818. handle: false,
  3819. helper: "original",
  3820. items: "> *",
  3821. opacity: false,
  3822. placeholder: false,
  3823. revert: false,
  3824. scroll: true,
  3825. scrollSensitivity: 20,
  3826. scrollSpeed: 20,
  3827. scope: "default",
  3828. tolerance: "intersect",
  3829. zIndex: 1000,
  3830. // callbacks
  3831. activate: null,
  3832. beforeStop: null,
  3833. change: null,
  3834. deactivate: null,
  3835. out: null,
  3836. over: null,
  3837. receive: null,
  3838. remove: null,
  3839. sort: null,
  3840. start: null,
  3841. stop: null,
  3842. update: null
  3843. },
  3844. _isOverAxis: function( x, reference, size ) {
  3845. return ( x >= reference ) && ( x < ( reference + size ) );
  3846. },
  3847. _isFloating: function( item ) {
  3848. return (/left|right/).test(item.css("float")) || (/inline|table-cell/).test(item.css("display"));
  3849. },
  3850. _create: function() {
  3851. var o = this.options;
  3852. this.containerCache = {};
  3853. this.element.addClass("ui-sortable");
  3854. //Get the items
  3855. this.refresh();
  3856. //Let's determine if the items are being displayed horizontally
  3857. this.floating = this.items.length ? o.axis === "x" || this._isFloating(this.items[0].item) : false;
  3858. //Let's determine the parent's offset
  3859. this.offset = this.element.offset();
  3860. //Initialize mouse events for interaction
  3861. this._mouseInit();
  3862. this._setHandleClassName();
  3863. //We're ready to go
  3864. this.ready = true;
  3865. },
  3866. _setOption: function( key, value ) {
  3867. this._super( key, value );
  3868. if ( key === "handle" ) {
  3869. this._setHandleClassName();
  3870. }
  3871. },
  3872. _setHandleClassName: function() {
  3873. this.element.find( ".ui-sortable-handle" ).removeClass( "ui-sortable-handle" );
  3874. $.each( this.items, function() {
  3875. ( this.instance.options.handle ?
  3876. this.item.find( this.instance.options.handle ) : this.item )
  3877. .addClass( "ui-sortable-handle" );
  3878. });
  3879. },
  3880. _destroy: function() {
  3881. this.element
  3882. .removeClass( "ui-sortable ui-sortable-disabled" )
  3883. .find( ".ui-sortable-handle" )
  3884. .removeClass( "ui-sortable-handle" );
  3885. this._mouseDestroy();
  3886. for ( var i = this.items.length - 1; i >= 0; i-- ) {
  3887. this.items[i].item.removeData(this.widgetName + "-item");
  3888. }
  3889. return this;
  3890. },
  3891. _mouseCapture: function(event, overrideHandle) {
  3892. var currentItem = null,
  3893. validHandle = false,
  3894. that = this;
  3895. if (this.reverting) {
  3896. return false;
  3897. }
  3898. if(this.options.disabled || this.options.type === "static") {
  3899. return false;
  3900. }
  3901. //We have to refresh the items data once first
  3902. this._refreshItems(event);
  3903. //Find out if the clicked node (or one of its parents) is a actual item in this.items
  3904. $(event.target).parents().each(function() {
  3905. if($.data(this, that.widgetName + "-item") === that) {
  3906. currentItem = $(this);
  3907. return false;
  3908. }
  3909. });
  3910. if($.data(event.target, that.widgetName + "-item") === that) {
  3911. currentItem = $(event.target);
  3912. }
  3913. if(!currentItem) {
  3914. return false;
  3915. }
  3916. if(this.options.handle && !overrideHandle) {
  3917. $(this.options.handle, currentItem).find("*").addBack().each(function() {
  3918. if(this === event.target) {
  3919. validHandle = true;
  3920. }
  3921. });
  3922. if(!validHandle) {
  3923. return false;
  3924. }
  3925. }
  3926. this.currentItem = currentItem;
  3927. this._removeCurrentsFromItems();
  3928. return true;
  3929. },
  3930. _mouseStart: function(event, overrideHandle, noActivation) {
  3931. var i, body,
  3932. o = this.options;
  3933. this.currentContainer = this;
  3934. //We only need to call refreshPositions, because the refreshItems call has been moved to mouseCapture
  3935. this.refreshPositions();
  3936. //Create and append the visible helper
  3937. this.helper = this._createHelper(event);
  3938. //Cache the helper size
  3939. this._cacheHelperProportions();
  3940. /*
  3941. * - Position generation -
  3942. * This block generates everything position related - it's the core of draggables.
  3943. */
  3944. //Cache the margins of the original element
  3945. this._cacheMargins();
  3946. //Get the next scrolling parent
  3947. this.scrollParent = this.helper.scrollParent();
  3948. //The element's absolute position on the page minus margins
  3949. this.offset = this.currentItem.offset();
  3950. this.offset = {
  3951. top: this.offset.top - this.margins.top,
  3952. left: this.offset.left - this.margins.left
  3953. };
  3954. $.extend(this.offset, {
  3955. click: { //Where the click happened, relative to the element
  3956. left: event.pageX - this.offset.left,
  3957. top: event.pageY - this.offset.top
  3958. },
  3959. parent: this._getParentOffset(),
  3960. relative: this._getRelativeOffset() //This is a relative to absolute position minus the actual position calculation - only used for relative positioned helper
  3961. });
  3962. // Only after we got the offset, we can change the helper's position to absolute
  3963. // TODO: Still need to figure out a way to make relative sorting possible
  3964. this.helper.css("position", "absolute");
  3965. this.cssPosition = this.helper.css("position");
  3966. //Generate the original position
  3967. this.originalPosition = this._generatePosition(event);
  3968. this.originalPageX = event.pageX;
  3969. this.originalPageY = event.pageY;
  3970. //Adjust the mouse offset relative to the helper if "cursorAt" is supplied
  3971. (o.cursorAt && this._adjustOffsetFromHelper(o.cursorAt));
  3972. //Cache the former DOM position
  3973. this.domPosition = { prev: this.currentItem.prev()[0], parent: this.currentItem.parent()[0] };
  3974. //If the helper is not the original, hide the original so it's not playing any role during the drag, won't cause anything bad this way
  3975. if(this.helper[0] !== this.currentItem[0]) {
  3976. this.currentItem.hide();
  3977. }
  3978. //Create the placeholder
  3979. this._createPlaceholder();
  3980. //Set a containment if given in the options
  3981. if(o.containment) {
  3982. this._setContainment();
  3983. }
  3984. if( o.cursor && o.cursor !== "auto" ) { // cursor option
  3985. body = this.document.find( "body" );
  3986. // support: IE
  3987. this.storedCursor = body.css( "cursor" );
  3988. body.css( "cursor", o.cursor );
  3989. this.storedStylesheet = $( "<style>*{ cursor: "+o.cursor+" !important; }</style>" ).appendTo( body );
  3990. }
  3991. if(o.opacity) { // opacity option
  3992. if (this.helper.css("opacity")) {
  3993. this._storedOpacity = this.helper.css("opacity");
  3994. }
  3995. this.helper.css("opacity", o.opacity);
  3996. }
  3997. if(o.zIndex) { // zIndex option
  3998. if (this.helper.css("zIndex")) {
  3999. this._storedZIndex = this.helper.css("zIndex");
  4000. }
  4001. this.helper.css("zIndex", o.zIndex);
  4002. }
  4003. //Prepare scrolling
  4004. if(this.scrollParent[0] !== document && this.scrollParent[0].tagName !== "HTML") {
  4005. this.overflowOffset = this.scrollParent.offset();
  4006. }
  4007. //Call callbacks
  4008. this._trigger("start", event, this._uiHash());
  4009. //Recache the helper size
  4010. if(!this._preserveHelperProportions) {
  4011. this._cacheHelperProportions();
  4012. }
  4013. //Post "activate" events to possible containers
  4014. if( !noActivation ) {
  4015. for ( i = this.containers.length - 1; i >= 0; i-- ) {
  4016. this.containers[ i ]._trigger( "activate", event, this._uiHash( this ) );
  4017. }
  4018. }
  4019. //Prepare possible droppables
  4020. if($.ui.ddmanager) {
  4021. $.ui.ddmanager.current = this;
  4022. }
  4023. if ($.ui.ddmanager && !o.dropBehaviour) {
  4024. $.ui.ddmanager.prepareOffsets(this, event);
  4025. }
  4026. this.dragging = true;
  4027. this.helper.addClass("ui-sortable-helper");
  4028. this._mouseDrag(event); //Execute the drag once - this causes the helper not to be visible before getting its correct position
  4029. return true;
  4030. },
  4031. _mouseDrag: function(event) {
  4032. var i, item, itemElement, intersection,
  4033. o = this.options,
  4034. scrolled = false;
  4035. //Compute the helpers position
  4036. this.position = this._generatePosition(event);
  4037. this.positionAbs = this._convertPositionTo("absolute");
  4038. if (!this.lastPositionAbs) {
  4039. this.lastPositionAbs = this.positionAbs;
  4040. }
  4041. //Do scrolling
  4042. if(this.options.scroll) {
  4043. if(this.scrollParent[0] !== document && this.scrollParent[0].tagName !== "HTML") {
  4044. if((this.overflowOffset.top + this.scrollParent[0].offsetHeight) - event.pageY < o.scrollSensitivity) {
  4045. this.scrollParent[0].scrollTop = scrolled = this.scrollParent[0].scrollTop + o.scrollSpeed;
  4046. } else if(event.pageY - this.overflowOffset.top < o.scrollSensitivity) {
  4047. this.scrollParent[0].scrollTop = scrolled = this.scrollParent[0].scrollTop - o.scrollSpeed;
  4048. }
  4049. if((this.overflowOffset.left + this.scrollParent[0].offsetWidth) - event.pageX < o.scrollSensitivity) {
  4050. this.scrollParent[0].scrollLeft = scrolled = this.scrollParent[0].scrollLeft + o.scrollSpeed;
  4051. } else if(event.pageX - this.overflowOffset.left < o.scrollSensitivity) {
  4052. this.scrollParent[0].scrollLeft = scrolled = this.scrollParent[0].scrollLeft - o.scrollSpeed;
  4053. }
  4054. } else {
  4055. if(event.pageY - $(document).scrollTop() < o.scrollSensitivity) {
  4056. scrolled = $(document).scrollTop($(document).scrollTop() - o.scrollSpeed);
  4057. } else if($(window).height() - (event.pageY - $(document).scrollTop()) < o.scrollSensitivity) {
  4058. scrolled = $(document).scrollTop($(document).scrollTop() + o.scrollSpeed);
  4059. }
  4060. if(event.pageX - $(document).scrollLeft() < o.scrollSensitivity) {
  4061. scrolled = $(document).scrollLeft($(document).scrollLeft() - o.scrollSpeed);
  4062. } else if($(window).width() - (event.pageX - $(document).scrollLeft()) < o.scrollSensitivity) {
  4063. scrolled = $(document).scrollLeft($(document).scrollLeft() + o.scrollSpeed);
  4064. }
  4065. }
  4066. if(scrolled !== false && $.ui.ddmanager && !o.dropBehaviour) {
  4067. $.ui.ddmanager.prepareOffsets(this, event);
  4068. }
  4069. }
  4070. //Regenerate the absolute position used for position checks
  4071. this.positionAbs = this._convertPositionTo("absolute");
  4072. //Set the helper position
  4073. if(!this.options.axis || this.options.axis !== "y") {
  4074. this.helper[0].style.left = this.position.left+"px";
  4075. }
  4076. if(!this.options.axis || this.options.axis !== "x") {
  4077. this.helper[0].style.top = this.position.top+"px";
  4078. }
  4079. //Rearrange
  4080. for (i = this.items.length - 1; i >= 0; i--) {
  4081. //Cache variables and intersection, continue if no intersection
  4082. item = this.items[i];
  4083. itemElement = item.item[0];
  4084. intersection = this._intersectsWithPointer(item);
  4085. if (!intersection) {
  4086. continue;
  4087. }
  4088. // Only put the placeholder inside the current Container, skip all
  4089. // items from other containers. This works because when moving
  4090. // an item from one container to another the
  4091. // currentContainer is switched before the placeholder is moved.
  4092. //
  4093. // Without this, moving items in "sub-sortables" can cause
  4094. // the placeholder to jitter between the outer and inner container.
  4095. if (item.instance !== this.currentContainer) {
  4096. continue;
  4097. }
  4098. // cannot intersect with itself
  4099. // no useless actions that have been done before
  4100. // no action if the item moved is the parent of the item checked
  4101. if (itemElement !== this.currentItem[0] &&
  4102. this.placeholder[intersection === 1 ? "next" : "prev"]()[0] !== itemElement &&
  4103. !$.contains(this.placeholder[0], itemElement) &&
  4104. (this.options.type === "semi-dynamic" ? !$.contains(this.element[0], itemElement) : true)
  4105. ) {
  4106. this.direction = intersection === 1 ? "down" : "up";
  4107. if (this.options.tolerance === "pointer" || this._intersectsWithSides(item)) {
  4108. this._rearrange(event, item);
  4109. } else {
  4110. break;
  4111. }
  4112. this._trigger("change", event, this._uiHash());
  4113. break;
  4114. }
  4115. }
  4116. //Post events to containers
  4117. this._contactContainers(event);
  4118. //Interconnect with droppables
  4119. if($.ui.ddmanager) {
  4120. $.ui.ddmanager.drag(this, event);
  4121. }
  4122. //Call callbacks
  4123. this._trigger("sort", event, this._uiHash());
  4124. this.lastPositionAbs = this.positionAbs;
  4125. return false;
  4126. },
  4127. _mouseStop: function(event, noPropagation) {
  4128. if(!event) {
  4129. return;
  4130. }
  4131. //If we are using droppables, inform the manager about the drop
  4132. if ($.ui.ddmanager && !this.options.dropBehaviour) {
  4133. $.ui.ddmanager.drop(this, event);
  4134. }
  4135. if(this.options.revert) {
  4136. var that = this,
  4137. cur = this.placeholder.offset(),
  4138. axis = this.options.axis,
  4139. animation = {};
  4140. if ( !axis || axis === "x" ) {
  4141. animation.left = cur.left - this.offset.parent.left - this.margins.left + (this.offsetParent[0] === document.body ? 0 : this.offsetParent[0].scrollLeft);
  4142. }
  4143. if ( !axis || axis === "y" ) {
  4144. animation.top = cur.top - this.offset.parent.top - this.margins.top + (this.offsetParent[0] === document.body ? 0 : this.offsetParent[0].scrollTop);
  4145. }
  4146. this.reverting = true;
  4147. $(this.helper).animate( animation, parseInt(this.options.revert, 10) || 500, function() {
  4148. that._clear(event);
  4149. });
  4150. } else {
  4151. this._clear(event, noPropagation);
  4152. }
  4153. return false;
  4154. },
  4155. cancel: function() {
  4156. if(this.dragging) {
  4157. this._mouseUp({ target: null });
  4158. if(this.options.helper === "original") {
  4159. this.currentItem.css(this._storedCSS).removeClass("ui-sortable-helper");
  4160. } else {
  4161. this.currentItem.show();
  4162. }
  4163. //Post deactivating events to containers
  4164. for (var i = this.containers.length - 1; i >= 0; i--){
  4165. this.containers[i]._trigger("deactivate", null, this._uiHash(this));
  4166. if(this.containers[i].containerCache.over) {
  4167. this.containers[i]._trigger("out", null, this._uiHash(this));
  4168. this.containers[i].containerCache.over = 0;
  4169. }
  4170. }
  4171. }
  4172. if (this.placeholder) {
  4173. //$(this.placeholder[0]).remove(); would have been the jQuery way - unfortunately, it unbinds ALL events from the original node!
  4174. if(this.placeholder[0].parentNode) {
  4175. this.placeholder[0].parentNode.removeChild(this.placeholder[0]);
  4176. }
  4177. if(this.options.helper !== "original" && this.helper && this.helper[0].parentNode) {
  4178. this.helper.remove();
  4179. }
  4180. $.extend(this, {
  4181. helper: null,
  4182. dragging: false,
  4183. reverting: false,
  4184. _noFinalSort: null
  4185. });
  4186. if(this.domPosition.prev) {
  4187. $(this.domPosition.prev).after(this.currentItem);
  4188. } else {
  4189. $(this.domPosition.parent).prepend(this.currentItem);
  4190. }
  4191. }
  4192. return this;
  4193. },
  4194. serialize: function(o) {
  4195. var items = this._getItemsAsjQuery(o && o.connected),
  4196. str = [];
  4197. o = o || {};
  4198. $(items).each(function() {
  4199. var res = ($(o.item || this).attr(o.attribute || "id") || "").match(o.expression || (/(.+)[\-=_](.+)/));
  4200. if (res) {
  4201. str.push((o.key || res[1]+"[]")+"="+(o.key && o.expression ? res[1] : res[2]));
  4202. }
  4203. });
  4204. if(!str.length && o.key) {
  4205. str.push(o.key + "=");
  4206. }
  4207. return str.join("&");
  4208. },
  4209. toArray: function(o) {
  4210. var items = this._getItemsAsjQuery(o && o.connected),
  4211. ret = [];
  4212. o = o || {};
  4213. items.each(function() { ret.push($(o.item || this).attr(o.attribute || "id") || ""); });
  4214. return ret;
  4215. },
  4216. /* Be careful with the following core functions */
  4217. _intersectsWith: function(item) {
  4218. var x1 = this.positionAbs.left,
  4219. x2 = x1 + this.helperProportions.width,
  4220. y1 = this.positionAbs.top,
  4221. y2 = y1 + this.helperProportions.height,
  4222. l = item.left,
  4223. r = l + item.width,
  4224. t = item.top,
  4225. b = t + item.height,
  4226. dyClick = this.offset.click.top,
  4227. dxClick = this.offset.click.left,
  4228. isOverElementHeight = ( this.options.axis === "x" ) || ( ( y1 + dyClick ) > t && ( y1 + dyClick ) < b ),
  4229. isOverElementWidth = ( this.options.axis === "y" ) || ( ( x1 + dxClick ) > l && ( x1 + dxClick ) < r ),
  4230. isOverElement = isOverElementHeight && isOverElementWidth;
  4231. if ( this.options.tolerance === "pointer" ||
  4232. this.options.forcePointerForContainers ||
  4233. (this.options.tolerance !== "pointer" && this.helperProportions[this.floating ? "width" : "height"] > item[this.floating ? "width" : "height"])
  4234. ) {
  4235. return isOverElement;
  4236. } else {
  4237. return (l < x1 + (this.helperProportions.width / 2) && // Right Half
  4238. x2 - (this.helperProportions.width / 2) < r && // Left Half
  4239. t < y1 + (this.helperProportions.height / 2) && // Bottom Half
  4240. y2 - (this.helperProportions.height / 2) < b ); // Top Half
  4241. }
  4242. },
  4243. _intersectsWithPointer: function(item) {
  4244. var isOverElementHeight = (this.options.axis === "x") || this._isOverAxis(this.positionAbs.top + this.offset.click.top, item.top, item.height),
  4245. isOverElementWidth = (this.options.axis === "y") || this._isOverAxis(this.positionAbs.left + this.offset.click.left, item.left, item.width),
  4246. isOverElement = isOverElementHeight && isOverElementWidth,
  4247. verticalDirection = this._getDragVerticalDirection(),
  4248. horizontalDirection = this._getDragHorizontalDirection();
  4249. if (!isOverElement) {
  4250. return false;
  4251. }
  4252. return this.floating ?
  4253. ( ((horizontalDirection && horizontalDirection === "right") || verticalDirection === "down") ? 2 : 1 )
  4254. : ( verticalDirection && (verticalDirection === "down" ? 2 : 1) );
  4255. },
  4256. _intersectsWithSides: function(item) {
  4257. var isOverBottomHalf = this._isOverAxis(this.positionAbs.top + this.offset.click.top, item.top + (item.height/2), item.height),
  4258. isOverRightHalf = this._isOverAxis(this.positionAbs.left + this.offset.click.left, item.left + (item.width/2), item.width),
  4259. verticalDirection = this._getDragVerticalDirection(),
  4260. horizontalDirection = this._getDragHorizontalDirection();
  4261. if (this.floating && horizontalDirection) {
  4262. return ((horizontalDirection === "right" && isOverRightHalf) || (horizontalDirection === "left" && !isOverRightHalf));
  4263. } else {
  4264. return verticalDirection && ((verticalDirection === "down" && isOverBottomHalf) || (verticalDirection === "up" && !isOverBottomHalf));
  4265. }
  4266. },
  4267. _getDragVerticalDirection: function() {
  4268. var delta = this.positionAbs.top - this.lastPositionAbs.top;
  4269. return delta !== 0 && (delta > 0 ? "down" : "up");
  4270. },
  4271. _getDragHorizontalDirection: function() {
  4272. var delta = this.positionAbs.left - this.lastPositionAbs.left;
  4273. return delta !== 0 && (delta > 0 ? "right" : "left");
  4274. },
  4275. refresh: function(event) {
  4276. this._refreshItems(event);
  4277. this._setHandleClassName();
  4278. this.refreshPositions();
  4279. return this;
  4280. },
  4281. _connectWith: function() {
  4282. var options = this.options;
  4283. return options.connectWith.constructor === String ? [options.connectWith] : options.connectWith;
  4284. },
  4285. _getItemsAsjQuery: function(connected) {
  4286. var i, j, cur, inst,
  4287. items = [],
  4288. queries = [],
  4289. connectWith = this._connectWith();
  4290. if(connectWith && connected) {
  4291. for (i = connectWith.length - 1; i >= 0; i--){
  4292. cur = $(connectWith[i]);
  4293. for ( j = cur.length - 1; j >= 0; j--){
  4294. inst = $.data(cur[j], this.widgetFullName);
  4295. if(inst && inst !== this && !inst.options.disabled) {
  4296. queries.push([$.isFunction(inst.options.items) ? inst.options.items.call(inst.element) : $(inst.options.items, inst.element).not(".ui-sortable-helper").not(".ui-sortable-placeholder"), inst]);
  4297. }
  4298. }
  4299. }
  4300. }
  4301. queries.push([$.isFunction(this.options.items) ? this.options.items.call(this.element, null, { options: this.options, item: this.currentItem }) : $(this.options.items, this.element).not(".ui-sortable-helper").not(".ui-sortable-placeholder"), this]);
  4302. function addItems() {
  4303. items.push( this );
  4304. }
  4305. for (i = queries.length - 1; i >= 0; i--){
  4306. queries[i][0].each( addItems );
  4307. }
  4308. return $(items);
  4309. },
  4310. _removeCurrentsFromItems: function() {
  4311. var list = this.currentItem.find(":data(" + this.widgetName + "-item)");
  4312. this.items = $.grep(this.items, function (item) {
  4313. for (var j=0; j < list.length; j++) {
  4314. if(list[j] === item.item[0]) {
  4315. return false;
  4316. }
  4317. }
  4318. return true;
  4319. });
  4320. },
  4321. _refreshItems: function(event) {
  4322. this.items = [];
  4323. this.containers = [this];
  4324. var i, j, cur, inst, targetData, _queries, item, queriesLength,
  4325. items = this.items,
  4326. queries = [[$.isFunction(this.options.items) ? this.options.items.call(this.element[0], event, { item: this.currentItem }) : $(this.options.items, this.element), this]],
  4327. connectWith = this._connectWith();
  4328. if(connectWith && this.ready) { //Shouldn't be run the first time through due to massive slow-down
  4329. for (i = connectWith.length - 1; i >= 0; i--){
  4330. cur = $(connectWith[i]);
  4331. for (j = cur.length - 1; j >= 0; j--){
  4332. inst = $.data(cur[j], this.widgetFullName);
  4333. if(inst && inst !== this && !inst.options.disabled) {
  4334. queries.push([$.isFunction(inst.options.items) ? inst.options.items.call(inst.element[0], event, { item: this.currentItem }) : $(inst.options.items, inst.element), inst]);
  4335. this.containers.push(inst);
  4336. }
  4337. }
  4338. }
  4339. }
  4340. for (i = queries.length - 1; i >= 0; i--) {
  4341. targetData = queries[i][1];
  4342. _queries = queries[i][0];
  4343. for (j=0, queriesLength = _queries.length; j < queriesLength; j++) {
  4344. item = $(_queries[j]);
  4345. item.data(this.widgetName + "-item", targetData); // Data for target checking (mouse manager)
  4346. items.push({
  4347. item: item,
  4348. instance: targetData,
  4349. width: 0, height: 0,
  4350. left: 0, top: 0
  4351. });
  4352. }
  4353. }
  4354. },
  4355. refreshPositions: function(fast) {
  4356. //This has to be redone because due to the item being moved out/into the offsetParent, the offsetParent's position will change
  4357. if(this.offsetParent && this.helper) {
  4358. this.offset.parent = this._getParentOffset();
  4359. }
  4360. var i, item, t, p;
  4361. for (i = this.items.length - 1; i >= 0; i--){
  4362. item = this.items[i];
  4363. //We ignore calculating positions of all connected containers when we're not over them
  4364. if(item.instance !== this.currentContainer && this.currentContainer && item.item[0] !== this.currentItem[0]) {
  4365. continue;
  4366. }
  4367. t = this.options.toleranceElement ? $(this.options.toleranceElement, item.item) : item.item;
  4368. if (!fast) {
  4369. item.width = t.outerWidth();
  4370. item.height = t.outerHeight();
  4371. }
  4372. p = t.offset();
  4373. item.left = p.left;
  4374. item.top = p.top;
  4375. }
  4376. if(this.options.custom && this.options.custom.refreshContainers) {
  4377. this.options.custom.refreshContainers.call(this);
  4378. } else {
  4379. for (i = this.containers.length - 1; i >= 0; i--){
  4380. p = this.containers[i].element.offset();
  4381. this.containers[i].containerCache.left = p.left;
  4382. this.containers[i].containerCache.top = p.top;
  4383. this.containers[i].containerCache.width = this.containers[i].element.outerWidth();
  4384. this.containers[i].containerCache.height = this.containers[i].element.outerHeight();
  4385. }
  4386. }
  4387. return this;
  4388. },
  4389. _createPlaceholder: function(that) {
  4390. that = that || this;
  4391. var className,
  4392. o = that.options;
  4393. if(!o.placeholder || o.placeholder.constructor === String) {
  4394. className = o.placeholder;
  4395. o.placeholder = {
  4396. element: function() {
  4397. var nodeName = that.currentItem[0].nodeName.toLowerCase(),
  4398. element = $( "<" + nodeName + ">", that.document[0] )
  4399. .addClass(className || that.currentItem[0].className+" ui-sortable-placeholder")
  4400. .removeClass("ui-sortable-helper");
  4401. if ( nodeName === "tr" ) {
  4402. that.currentItem.children().each(function() {
  4403. $( "<td>&#160;</td>", that.document[0] )
  4404. .attr( "colspan", $( this ).attr( "colspan" ) || 1 )
  4405. .appendTo( element );
  4406. });
  4407. } else if ( nodeName === "img" ) {
  4408. element.attr( "src", that.currentItem.attr( "src" ) );
  4409. }
  4410. if ( !className ) {
  4411. element.css( "visibility", "hidden" );
  4412. }
  4413. return element;
  4414. },
  4415. update: function(container, p) {
  4416. // 1. If a className is set as 'placeholder option, we don't force sizes - the class is responsible for that
  4417. // 2. The option 'forcePlaceholderSize can be enabled to force it even if a class name is specified
  4418. if(className && !o.forcePlaceholderSize) {
  4419. return;
  4420. }
  4421. //If the element doesn't have a actual height by itself (without styles coming from a stylesheet), it receives the inline height from the dragged item
  4422. if(!p.height()) { p.height(that.currentItem.innerHeight() - parseInt(that.currentItem.css("paddingTop")||0, 10) - parseInt(that.currentItem.css("paddingBottom")||0, 10)); }
  4423. if(!p.width()) { p.width(that.currentItem.innerWidth() - parseInt(that.currentItem.css("paddingLeft")||0, 10) - parseInt(that.currentItem.css("paddingRight")||0, 10)); }
  4424. }
  4425. };
  4426. }
  4427. //Create the placeholder
  4428. that.placeholder = $(o.placeholder.element.call(that.element, that.currentItem));
  4429. //Append it after the actual current item
  4430. that.currentItem.after(that.placeholder);
  4431. //Update the size of the placeholder (TODO: Logic to fuzzy, see line 316/317)
  4432. o.placeholder.update(that, that.placeholder);
  4433. },
  4434. _contactContainers: function(event) {
  4435. var i, j, dist, itemWithLeastDistance, posProperty, sizeProperty, cur, nearBottom, floating, axis,
  4436. innermostContainer = null,
  4437. innermostIndex = null;
  4438. // get innermost container that intersects with item
  4439. for (i = this.containers.length - 1; i >= 0; i--) {
  4440. // never consider a container that's located within the item itself
  4441. if($.contains(this.currentItem[0], this.containers[i].element[0])) {
  4442. continue;
  4443. }
  4444. if(this._intersectsWith(this.containers[i].containerCache)) {
  4445. // if we've already found a container and it's more "inner" than this, then continue
  4446. if(innermostContainer && $.contains(this.containers[i].element[0], innermostContainer.element[0])) {
  4447. continue;
  4448. }
  4449. innermostContainer = this.containers[i];
  4450. innermostIndex = i;
  4451. } else {
  4452. // container doesn't intersect. trigger "out" event if necessary
  4453. if(this.containers[i].containerCache.over) {
  4454. this.containers[i]._trigger("out", event, this._uiHash(this));
  4455. this.containers[i].containerCache.over = 0;
  4456. }
  4457. }
  4458. }
  4459. // if no intersecting containers found, return
  4460. if(!innermostContainer) {
  4461. return;
  4462. }
  4463. // move the item into the container if it's not there already
  4464. if(this.containers.length === 1) {
  4465. if (!this.containers[innermostIndex].containerCache.over) {
  4466. this.containers[innermostIndex]._trigger("over", event, this._uiHash(this));
  4467. this.containers[innermostIndex].containerCache.over = 1;
  4468. }
  4469. } else {
  4470. //When entering a new container, we will find the item with the least distance and append our item near it
  4471. dist = 10000;
  4472. itemWithLeastDistance = null;
  4473. floating = innermostContainer.floating || this._isFloating(this.currentItem);
  4474. posProperty = floating ? "left" : "top";
  4475. sizeProperty = floating ? "width" : "height";
  4476. axis = floating ? "clientX" : "clientY";
  4477. for (j = this.items.length - 1; j >= 0; j--) {
  4478. if(!$.contains(this.containers[innermostIndex].element[0], this.items[j].item[0])) {
  4479. continue;
  4480. }
  4481. if(this.items[j].item[0] === this.currentItem[0]) {
  4482. continue;
  4483. }
  4484. cur = this.items[j].item.offset()[posProperty];
  4485. nearBottom = false;
  4486. if ( event[ axis ] - cur > this.items[ j ][ sizeProperty ] / 2 ) {
  4487. nearBottom = true;
  4488. }
  4489. if ( Math.abs( event[ axis ] - cur ) < dist ) {
  4490. dist = Math.abs( event[ axis ] - cur );
  4491. itemWithLeastDistance = this.items[ j ];
  4492. this.direction = nearBottom ? "up": "down";
  4493. }
  4494. }
  4495. //Check if dropOnEmpty is enabled
  4496. if(!itemWithLeastDistance && !this.options.dropOnEmpty) {
  4497. return;
  4498. }
  4499. if(this.currentContainer === this.containers[innermostIndex]) {
  4500. if ( !this.currentContainer.containerCache.over ) {
  4501. this.containers[ innermostIndex ]._trigger( "over", event, this._uiHash() );
  4502. this.currentContainer.containerCache.over = 1;
  4503. }
  4504. return;
  4505. }
  4506. itemWithLeastDistance ? this._rearrange(event, itemWithLeastDistance, null, true) : this._rearrange(event, null, this.containers[innermostIndex].element, true);
  4507. this._trigger("change", event, this._uiHash());
  4508. this.containers[innermostIndex]._trigger("change", event, this._uiHash(this));
  4509. this.currentContainer = this.containers[innermostIndex];
  4510. //Update the placeholder
  4511. this.options.placeholder.update(this.currentContainer, this.placeholder);
  4512. this.containers[innermostIndex]._trigger("over", event, this._uiHash(this));
  4513. this.containers[innermostIndex].containerCache.over = 1;
  4514. }
  4515. },
  4516. _createHelper: function(event) {
  4517. var o = this.options,
  4518. helper = $.isFunction(o.helper) ? $(o.helper.apply(this.element[0], [event, this.currentItem])) : (o.helper === "clone" ? this.currentItem.clone() : this.currentItem);
  4519. //Add the helper to the DOM if that didn't happen already
  4520. if(!helper.parents("body").length) {
  4521. $(o.appendTo !== "parent" ? o.appendTo : this.currentItem[0].parentNode)[0].appendChild(helper[0]);
  4522. }
  4523. if(helper[0] === this.currentItem[0]) {
  4524. this._storedCSS = { width: this.currentItem[0].style.width, height: this.currentItem[0].style.height, position: this.currentItem.css("position"), top: this.currentItem.css("top"), left: this.currentItem.css("left") };
  4525. }
  4526. if(!helper[0].style.width || o.forceHelperSize) {
  4527. helper.width(this.currentItem.width());
  4528. }
  4529. if(!helper[0].style.height || o.forceHelperSize) {
  4530. helper.height(this.currentItem.height());
  4531. }
  4532. return helper;
  4533. },
  4534. _adjustOffsetFromHelper: function(obj) {
  4535. if (typeof obj === "string") {
  4536. obj = obj.split(" ");
  4537. }
  4538. if ($.isArray(obj)) {
  4539. obj = {left: +obj[0], top: +obj[1] || 0};
  4540. }
  4541. if ("left" in obj) {
  4542. this.offset.click.left = obj.left + this.margins.left;
  4543. }
  4544. if ("right" in obj) {
  4545. this.offset.click.left = this.helperProportions.width - obj.right + this.margins.left;
  4546. }
  4547. if ("top" in obj) {
  4548. this.offset.click.top = obj.top + this.margins.top;
  4549. }
  4550. if ("bottom" in obj) {
  4551. this.offset.click.top = this.helperProportions.height - obj.bottom + this.margins.top;
  4552. }
  4553. },
  4554. _getParentOffset: function() {
  4555. //Get the offsetParent and cache its position
  4556. this.offsetParent = this.helper.offsetParent();
  4557. var po = this.offsetParent.offset();
  4558. // This is a special case where we need to modify a offset calculated on start, since the following happened:
  4559. // 1. The position of the helper is absolute, so it's position is calculated based on the next positioned parent
  4560. // 2. The actual offset parent is a child of the scroll parent, and the scroll parent isn't the document, which means that
  4561. // the scroll is included in the initial calculation of the offset of the parent, and never recalculated upon drag
  4562. if(this.cssPosition === "absolute" && this.scrollParent[0] !== document && $.contains(this.scrollParent[0], this.offsetParent[0])) {
  4563. po.left += this.scrollParent.scrollLeft();
  4564. po.top += this.scrollParent.scrollTop();
  4565. }
  4566. // This needs to be actually done for all browsers, since pageX/pageY includes this information
  4567. // with an ugly IE fix
  4568. if( this.offsetParent[0] === document.body || (this.offsetParent[0].tagName && this.offsetParent[0].tagName.toLowerCase() === "html" && $.ui.ie)) {
  4569. po = { top: 0, left: 0 };
  4570. }
  4571. return {
  4572. top: po.top + (parseInt(this.offsetParent.css("borderTopWidth"),10) || 0),
  4573. left: po.left + (parseInt(this.offsetParent.css("borderLeftWidth"),10) || 0)
  4574. };
  4575. },
  4576. _getRelativeOffset: function() {
  4577. if(this.cssPosition === "relative") {
  4578. var p = this.currentItem.position();
  4579. return {
  4580. top: p.top - (parseInt(this.helper.css("top"),10) || 0) + this.scrollParent.scrollTop(),
  4581. left: p.left - (parseInt(this.helper.css("left"),10) || 0) + this.scrollParent.scrollLeft()
  4582. };
  4583. } else {
  4584. return { top: 0, left: 0 };
  4585. }
  4586. },
  4587. _cacheMargins: function() {
  4588. this.margins = {
  4589. left: (parseInt(this.currentItem.css("marginLeft"),10) || 0),
  4590. top: (parseInt(this.currentItem.css("marginTop"),10) || 0)
  4591. };
  4592. },
  4593. _cacheHelperProportions: function() {
  4594. this.helperProportions = {
  4595. width: this.helper.outerWidth(),
  4596. height: this.helper.outerHeight()
  4597. };
  4598. },
  4599. _setContainment: function() {
  4600. var ce, co, over,
  4601. o = this.options;
  4602. if(o.containment === "parent") {
  4603. o.containment = this.helper[0].parentNode;
  4604. }
  4605. if(o.containment === "document" || o.containment === "window") {
  4606. this.containment = [
  4607. 0 - this.offset.relative.left - this.offset.parent.left,
  4608. 0 - this.offset.relative.top - this.offset.parent.top,
  4609. $(o.containment === "document" ? document : window).width() - this.helperProportions.width - this.margins.left,
  4610. ($(o.containment === "document" ? document : window).height() || document.body.parentNode.scrollHeight) - this.helperProportions.height - this.margins.top
  4611. ];
  4612. }
  4613. if(!(/^(document|window|parent)$/).test(o.containment)) {
  4614. ce = $(o.containment)[0];
  4615. co = $(o.containment).offset();
  4616. over = ($(ce).css("overflow") !== "hidden");
  4617. this.containment = [
  4618. co.left + (parseInt($(ce).css("borderLeftWidth"),10) || 0) + (parseInt($(ce).css("paddingLeft"),10) || 0) - this.margins.left,
  4619. co.top + (parseInt($(ce).css("borderTopWidth"),10) || 0) + (parseInt($(ce).css("paddingTop"),10) || 0) - this.margins.top,
  4620. co.left+(over ? Math.max(ce.scrollWidth,ce.offsetWidth) : ce.offsetWidth) - (parseInt($(ce).css("borderLeftWidth"),10) || 0) - (parseInt($(ce).css("paddingRight"),10) || 0) - this.helperProportions.width - this.margins.left,
  4621. co.top+(over ? Math.max(ce.scrollHeight,ce.offsetHeight) : ce.offsetHeight) - (parseInt($(ce).css("borderTopWidth"),10) || 0) - (parseInt($(ce).css("paddingBottom"),10) || 0) - this.helperProportions.height - this.margins.top
  4622. ];
  4623. }
  4624. },
  4625. _convertPositionTo: function(d, pos) {
  4626. if(!pos) {
  4627. pos = this.position;
  4628. }
  4629. var mod = d === "absolute" ? 1 : -1,
  4630. scroll = this.cssPosition === "absolute" && !(this.scrollParent[0] !== document && $.contains(this.scrollParent[0], this.offsetParent[0])) ? this.offsetParent : this.scrollParent,
  4631. scrollIsRootNode = (/(html|body)/i).test(scroll[0].tagName);
  4632. return {
  4633. top: (
  4634. pos.top + // The absolute mouse position
  4635. this.offset.relative.top * mod + // Only for relative positioned nodes: Relative offset from element to offset parent
  4636. this.offset.parent.top * mod - // The offsetParent's offset without borders (offset + border)
  4637. ( ( this.cssPosition === "fixed" ? -this.scrollParent.scrollTop() : ( scrollIsRootNode ? 0 : scroll.scrollTop() ) ) * mod)
  4638. ),
  4639. left: (
  4640. pos.left + // The absolute mouse position
  4641. this.offset.relative.left * mod + // Only for relative positioned nodes: Relative offset from element to offset parent
  4642. this.offset.parent.left * mod - // The offsetParent's offset without borders (offset + border)
  4643. ( ( this.cssPosition === "fixed" ? -this.scrollParent.scrollLeft() : scrollIsRootNode ? 0 : scroll.scrollLeft() ) * mod)
  4644. )
  4645. };
  4646. },
  4647. _generatePosition: function(event) {
  4648. var top, left,
  4649. o = this.options,
  4650. pageX = event.pageX,
  4651. pageY = event.pageY,
  4652. scroll = this.cssPosition === "absolute" && !(this.scrollParent[0] !== document && $.contains(this.scrollParent[0], this.offsetParent[0])) ? this.offsetParent : this.scrollParent, scrollIsRootNode = (/(html|body)/i).test(scroll[0].tagName);
  4653. // This is another very weird special case that only happens for relative elements:
  4654. // 1. If the css position is relative
  4655. // 2. and the scroll parent is the document or similar to the offset parent
  4656. // we have to refresh the relative offset during the scroll so there are no jumps
  4657. if(this.cssPosition === "relative" && !(this.scrollParent[0] !== document && this.scrollParent[0] !== this.offsetParent[0])) {
  4658. this.offset.relative = this._getRelativeOffset();
  4659. }
  4660. /*
  4661. * - Position constraining -
  4662. * Constrain the position to a mix of grid, containment.
  4663. */
  4664. if(this.originalPosition) { //If we are not dragging yet, we won't check for options
  4665. if(this.containment) {
  4666. if(event.pageX - this.offset.click.left < this.containment[0]) {
  4667. pageX = this.containment[0] + this.offset.click.left;
  4668. }
  4669. if(event.pageY - this.offset.click.top < this.containment[1]) {
  4670. pageY = this.containment[1] + this.offset.click.top;
  4671. }
  4672. if(event.pageX - this.offset.click.left > this.containment[2]) {
  4673. pageX = this.containment[2] + this.offset.click.left;
  4674. }
  4675. if(event.pageY - this.offset.click.top > this.containment[3]) {
  4676. pageY = this.containment[3] + this.offset.click.top;
  4677. }
  4678. }
  4679. if(o.grid) {
  4680. top = this.originalPageY + Math.round((pageY - this.originalPageY) / o.grid[1]) * o.grid[1];
  4681. pageY = this.containment ? ( (top - this.offset.click.top >= this.containment[1] && top - this.offset.click.top <= this.containment[3]) ? top : ((top - this.offset.click.top >= this.containment[1]) ? top - o.grid[1] : top + o.grid[1])) : top;
  4682. left = this.originalPageX + Math.round((pageX - this.originalPageX) / o.grid[0]) * o.grid[0];
  4683. pageX = this.containment ? ( (left - this.offset.click.left >= this.containment[0] && left - this.offset.click.left <= this.containment[2]) ? left : ((left - this.offset.click.left >= this.containment[0]) ? left - o.grid[0] : left + o.grid[0])) : left;
  4684. }
  4685. }
  4686. return {
  4687. top: (
  4688. pageY - // The absolute mouse position
  4689. this.offset.click.top - // Click offset (relative to the element)
  4690. this.offset.relative.top - // Only for relative positioned nodes: Relative offset from element to offset parent
  4691. this.offset.parent.top + // The offsetParent's offset without borders (offset + border)
  4692. ( ( this.cssPosition === "fixed" ? -this.scrollParent.scrollTop() : ( scrollIsRootNode ? 0 : scroll.scrollTop() ) ))
  4693. ),
  4694. left: (
  4695. pageX - // The absolute mouse position
  4696. this.offset.click.left - // Click offset (relative to the element)
  4697. this.offset.relative.left - // Only for relative positioned nodes: Relative offset from element to offset parent
  4698. this.offset.parent.left + // The offsetParent's offset without borders (offset + border)
  4699. ( ( this.cssPosition === "fixed" ? -this.scrollParent.scrollLeft() : scrollIsRootNode ? 0 : scroll.scrollLeft() ))
  4700. )
  4701. };
  4702. },
  4703. _rearrange: function(event, i, a, hardRefresh) {
  4704. a ? a[0].appendChild(this.placeholder[0]) : i.item[0].parentNode.insertBefore(this.placeholder[0], (this.direction === "down" ? i.item[0] : i.item[0].nextSibling));
  4705. //Various things done here to improve the performance:
  4706. // 1. we create a setTimeout, that calls refreshPositions
  4707. // 2. on the instance, we have a counter variable, that get's higher after every append
  4708. // 3. on the local scope, we copy the counter variable, and check in the timeout, if it's still the same
  4709. // 4. this lets only the last addition to the timeout stack through
  4710. this.counter = this.counter ? ++this.counter : 1;
  4711. var counter = this.counter;
  4712. this._delay(function() {
  4713. if(counter === this.counter) {
  4714. this.refreshPositions(!hardRefresh); //Precompute after each DOM insertion, NOT on mousemove
  4715. }
  4716. });
  4717. },
  4718. _clear: function(event, noPropagation) {
  4719. this.reverting = false;
  4720. // We delay all events that have to be triggered to after the point where the placeholder has been removed and
  4721. // everything else normalized again
  4722. var i,
  4723. delayedTriggers = [];
  4724. // We first have to update the dom position of the actual currentItem
  4725. // Note: don't do it if the current item is already removed (by a user), or it gets reappended (see #4088)
  4726. if(!this._noFinalSort && this.currentItem.parent().length) {
  4727. this.placeholder.before(this.currentItem);
  4728. }
  4729. this._noFinalSort = null;
  4730. if(this.helper[0] === this.currentItem[0]) {
  4731. for(i in this._storedCSS) {
  4732. if(this._storedCSS[i] === "auto" || this._storedCSS[i] === "static") {
  4733. this._storedCSS[i] = "";
  4734. }
  4735. }
  4736. this.currentItem.css(this._storedCSS).removeClass("ui-sortable-helper");
  4737. } else {
  4738. this.currentItem.show();
  4739. }
  4740. if(this.fromOutside && !noPropagation) {
  4741. delayedTriggers.push(function(event) { this._trigger("receive", event, this._uiHash(this.fromOutside)); });
  4742. }
  4743. if((this.fromOutside || this.domPosition.prev !== this.currentItem.prev().not(".ui-sortable-helper")[0] || this.domPosition.parent !== this.currentItem.parent()[0]) && !noPropagation) {
  4744. delayedTriggers.push(function(event) { this._trigger("update", event, this._uiHash()); }); //Trigger update callback if the DOM position has changed
  4745. }
  4746. // Check if the items Container has Changed and trigger appropriate
  4747. // events.
  4748. if (this !== this.currentContainer) {
  4749. if(!noPropagation) {
  4750. delayedTriggers.push(function(event) { this._trigger("remove", event, this._uiHash()); });
  4751. delayedTriggers.push((function(c) { return function(event) { c._trigger("receive", event, this._uiHash(this)); }; }).call(this, this.currentContainer));
  4752. delayedTriggers.push((function(c) { return function(event) { c._trigger("update", event, this._uiHash(this)); }; }).call(this, this.currentContainer));
  4753. }
  4754. }
  4755. //Post events to containers
  4756. function delayEvent( type, instance, container ) {
  4757. return function( event ) {
  4758. container._trigger( type, event, instance._uiHash( instance ) );
  4759. };
  4760. }
  4761. for (i = this.containers.length - 1; i >= 0; i--){
  4762. if (!noPropagation) {
  4763. delayedTriggers.push( delayEvent( "deactivate", this, this.containers[ i ] ) );
  4764. }
  4765. if(this.containers[i].containerCache.over) {
  4766. delayedTriggers.push( delayEvent( "out", this, this.containers[ i ] ) );
  4767. this.containers[i].containerCache.over = 0;
  4768. }
  4769. }
  4770. //Do what was originally in plugins
  4771. if ( this.storedCursor ) {
  4772. this.document.find( "body" ).css( "cursor", this.storedCursor );
  4773. this.storedStylesheet.remove();
  4774. }
  4775. if(this._storedOpacity) {
  4776. this.helper.css("opacity", this._storedOpacity);
  4777. }
  4778. if(this._storedZIndex) {
  4779. this.helper.css("zIndex", this._storedZIndex === "auto" ? "" : this._storedZIndex);
  4780. }
  4781. this.dragging = false;
  4782. if(!noPropagation) {
  4783. this._trigger("beforeStop", event, this._uiHash());
  4784. }
  4785. //$(this.placeholder[0]).remove(); would have been the jQuery way - unfortunately, it unbinds ALL events from the original node!
  4786. this.placeholder[0].parentNode.removeChild(this.placeholder[0]);
  4787. if ( !this.cancelHelperRemoval ) {
  4788. if ( this.helper[ 0 ] !== this.currentItem[ 0 ] ) {
  4789. this.helper.remove();
  4790. }
  4791. this.helper = null;
  4792. }
  4793. if(!noPropagation) {
  4794. for (i=0; i < delayedTriggers.length; i++) {
  4795. delayedTriggers[i].call(this, event);
  4796. } //Trigger all delayed events
  4797. this._trigger("stop", event, this._uiHash());
  4798. }
  4799. this.fromOutside = false;
  4800. return !this.cancelHelperRemoval;
  4801. },
  4802. _trigger: function() {
  4803. if ($.Widget.prototype._trigger.apply(this, arguments) === false) {
  4804. this.cancel();
  4805. }
  4806. },
  4807. _uiHash: function(_inst) {
  4808. var inst = _inst || this;
  4809. return {
  4810. helper: inst.helper,
  4811. placeholder: inst.placeholder || $([]),
  4812. position: inst.position,
  4813. originalPosition: inst.originalPosition,
  4814. offset: inst.positionAbs,
  4815. item: inst.currentItem,
  4816. sender: _inst ? _inst.element : null
  4817. };
  4818. }
  4819. });
  4820. /*!
  4821. * jQuery UI Slider 1.11.2
  4822. * http://jqueryui.com
  4823. *
  4824. * Copyright 2014 jQuery Foundation and other contributors
  4825. * Released under the MIT license.
  4826. * http://jquery.org/license
  4827. *
  4828. * http://api.jqueryui.com/slider/
  4829. */
  4830. var slider = $.widget( "ui.slider", $.ui.mouse, {
  4831. version: "1.11.2",
  4832. widgetEventPrefix: "slide",
  4833. options: {
  4834. animate: false,
  4835. distance: 0,
  4836. max: 100,
  4837. min: 0,
  4838. orientation: "horizontal",
  4839. range: false,
  4840. step: 1,
  4841. value: 0,
  4842. values: null,
  4843. // callbacks
  4844. change: null,
  4845. slide: null,
  4846. start: null,
  4847. stop: null
  4848. },
  4849. // number of pages in a slider
  4850. // (how many times can you page up/down to go through the whole range)
  4851. numPages: 5,
  4852. _create: function() {
  4853. this._keySliding = false;
  4854. this._mouseSliding = false;
  4855. this._animateOff = true;
  4856. this._handleIndex = null;
  4857. this._detectOrientation();
  4858. this._mouseInit();
  4859. this._calculateNewMax();
  4860. this.element
  4861. .addClass( "ui-slider" +
  4862. " ui-slider-" + this.orientation +
  4863. " ui-widget" +
  4864. " ui-widget-content" +
  4865. " ui-corner-all");
  4866. this._refresh();
  4867. this._setOption( "disabled", this.options.disabled );
  4868. this._animateOff = false;
  4869. },
  4870. _refresh: function() {
  4871. this._createRange();
  4872. this._createHandles();
  4873. this._setupEvents();
  4874. this._refreshValue();
  4875. },
  4876. _createHandles: function() {
  4877. var i, handleCount,
  4878. options = this.options,
  4879. existingHandles = this.element.find( ".ui-slider-handle" ).addClass( "ui-state-default ui-corner-all" ),
  4880. handle = "<span class='ui-slider-handle ui-state-default ui-corner-all' tabindex='0'></span>",
  4881. handles = [];
  4882. handleCount = ( options.values && options.values.length ) || 1;
  4883. if ( existingHandles.length > handleCount ) {
  4884. existingHandles.slice( handleCount ).remove();
  4885. existingHandles = existingHandles.slice( 0, handleCount );
  4886. }
  4887. for ( i = existingHandles.length; i < handleCount; i++ ) {
  4888. handles.push( handle );
  4889. }
  4890. this.handles = existingHandles.add( $( handles.join( "" ) ).appendTo( this.element ) );
  4891. this.handle = this.handles.eq( 0 );
  4892. this.handles.each(function( i ) {
  4893. $( this ).data( "ui-slider-handle-index", i );
  4894. });
  4895. },
  4896. _createRange: function() {
  4897. var options = this.options,
  4898. classes = "";
  4899. if ( options.range ) {
  4900. if ( options.range === true ) {
  4901. if ( !options.values ) {
  4902. options.values = [ this._valueMin(), this._valueMin() ];
  4903. } else if ( options.values.length && options.values.length !== 2 ) {
  4904. options.values = [ options.values[0], options.values[0] ];
  4905. } else if ( $.isArray( options.values ) ) {
  4906. options.values = options.values.slice(0);
  4907. }
  4908. }
  4909. if ( !this.range || !this.range.length ) {
  4910. this.range = $( "<div></div>" )
  4911. .appendTo( this.element );
  4912. classes = "ui-slider-range" +
  4913. // note: this isn't the most fittingly semantic framework class for this element,
  4914. // but worked best visually with a variety of themes
  4915. " ui-widget-header ui-corner-all";
  4916. } else {
  4917. this.range.removeClass( "ui-slider-range-min ui-slider-range-max" )
  4918. // Handle range switching from true to min/max
  4919. .css({
  4920. "left": "",
  4921. "bottom": ""
  4922. });
  4923. }
  4924. this.range.addClass( classes +
  4925. ( ( options.range === "min" || options.range === "max" ) ? " ui-slider-range-" + options.range : "" ) );
  4926. } else {
  4927. if ( this.range ) {
  4928. this.range.remove();
  4929. }
  4930. this.range = null;
  4931. }
  4932. },
  4933. _setupEvents: function() {
  4934. this._off( this.handles );
  4935. this._on( this.handles, this._handleEvents );
  4936. this._hoverable( this.handles );
  4937. this._focusable( this.handles );
  4938. },
  4939. _destroy: function() {
  4940. this.handles.remove();
  4941. if ( this.range ) {
  4942. this.range.remove();
  4943. }
  4944. this.element
  4945. .removeClass( "ui-slider" +
  4946. " ui-slider-horizontal" +
  4947. " ui-slider-vertical" +
  4948. " ui-widget" +
  4949. " ui-widget-content" +
  4950. " ui-corner-all" );
  4951. this._mouseDestroy();
  4952. },
  4953. _mouseCapture: function( event ) {
  4954. var position, normValue, distance, closestHandle, index, allowed, offset, mouseOverHandle,
  4955. that = this,
  4956. o = this.options;
  4957. if ( o.disabled ) {
  4958. return false;
  4959. }
  4960. this.elementSize = {
  4961. width: this.element.outerWidth(),
  4962. height: this.element.outerHeight()
  4963. };
  4964. this.elementOffset = this.element.offset();
  4965. position = { x: event.pageX, y: event.pageY };
  4966. normValue = this._normValueFromMouse( position );
  4967. distance = this._valueMax() - this._valueMin() + 1;
  4968. this.handles.each(function( i ) {
  4969. var thisDistance = Math.abs( normValue - that.values(i) );
  4970. if (( distance > thisDistance ) ||
  4971. ( distance === thisDistance &&
  4972. (i === that._lastChangedValue || that.values(i) === o.min ))) {
  4973. distance = thisDistance;
  4974. closestHandle = $( this );
  4975. index = i;
  4976. }
  4977. });
  4978. allowed = this._start( event, index );
  4979. if ( allowed === false ) {
  4980. return false;
  4981. }
  4982. this._mouseSliding = true;
  4983. this._handleIndex = index;
  4984. closestHandle
  4985. .addClass( "ui-state-active" )
  4986. .focus();
  4987. offset = closestHandle.offset();
  4988. mouseOverHandle = !$( event.target ).parents().addBack().is( ".ui-slider-handle" );
  4989. this._clickOffset = mouseOverHandle ? { left: 0, top: 0 } : {
  4990. left: event.pageX - offset.left - ( closestHandle.width() / 2 ),
  4991. top: event.pageY - offset.top -
  4992. ( closestHandle.height() / 2 ) -
  4993. ( parseInt( closestHandle.css("borderTopWidth"), 10 ) || 0 ) -
  4994. ( parseInt( closestHandle.css("borderBottomWidth"), 10 ) || 0) +
  4995. ( parseInt( closestHandle.css("marginTop"), 10 ) || 0)
  4996. };
  4997. if ( !this.handles.hasClass( "ui-state-hover" ) ) {
  4998. this._slide( event, index, normValue );
  4999. }
  5000. this._animateOff = true;
  5001. return true;
  5002. },
  5003. _mouseStart: function() {
  5004. return true;
  5005. },
  5006. _mouseDrag: function( event ) {
  5007. var position = { x: event.pageX, y: event.pageY },
  5008. normValue = this._normValueFromMouse( position );
  5009. this._slide( event, this._handleIndex, normValue );
  5010. return false;
  5011. },
  5012. _mouseStop: function( event ) {
  5013. this.handles.removeClass( "ui-state-active" );
  5014. this._mouseSliding = false;
  5015. this._stop( event, this._handleIndex );
  5016. this._change( event, this._handleIndex );
  5017. this._handleIndex = null;
  5018. this._clickOffset = null;
  5019. this._animateOff = false;
  5020. return false;
  5021. },
  5022. _detectOrientation: function() {
  5023. this.orientation = ( this.options.orientation === "vertical" ) ? "vertical" : "horizontal";
  5024. },
  5025. _normValueFromMouse: function( position ) {
  5026. var pixelTotal,
  5027. pixelMouse,
  5028. percentMouse,
  5029. valueTotal,
  5030. valueMouse;
  5031. if ( this.orientation === "horizontal" ) {
  5032. pixelTotal = this.elementSize.width;
  5033. pixelMouse = position.x - this.elementOffset.left - ( this._clickOffset ? this._clickOffset.left : 0 );
  5034. } else {
  5035. pixelTotal = this.elementSize.height;
  5036. pixelMouse = position.y - this.elementOffset.top - ( this._clickOffset ? this._clickOffset.top : 0 );
  5037. }
  5038. percentMouse = ( pixelMouse / pixelTotal );
  5039. if ( percentMouse > 1 ) {
  5040. percentMouse = 1;
  5041. }
  5042. if ( percentMouse < 0 ) {
  5043. percentMouse = 0;
  5044. }
  5045. if ( this.orientation === "vertical" ) {
  5046. percentMouse = 1 - percentMouse;
  5047. }
  5048. valueTotal = this._valueMax() - this._valueMin();
  5049. valueMouse = this._valueMin() + percentMouse * valueTotal;
  5050. return this._trimAlignValue( valueMouse );
  5051. },
  5052. _start: function( event, index ) {
  5053. var uiHash = {
  5054. handle: this.handles[ index ],
  5055. value: this.value()
  5056. };
  5057. if ( this.options.values && this.options.values.length ) {
  5058. uiHash.value = this.values( index );
  5059. uiHash.values = this.values();
  5060. }
  5061. return this._trigger( "start", event, uiHash );
  5062. },
  5063. _slide: function( event, index, newVal ) {
  5064. var otherVal,
  5065. newValues,
  5066. allowed;
  5067. if ( this.options.values && this.options.values.length ) {
  5068. otherVal = this.values( index ? 0 : 1 );
  5069. if ( ( this.options.values.length === 2 && this.options.range === true ) &&
  5070. ( ( index === 0 && newVal > otherVal) || ( index === 1 && newVal < otherVal ) )
  5071. ) {
  5072. newVal = otherVal;
  5073. }
  5074. if ( newVal !== this.values( index ) ) {
  5075. newValues = this.values();
  5076. newValues[ index ] = newVal;
  5077. // A slide can be canceled by returning false from the slide callback
  5078. allowed = this._trigger( "slide", event, {
  5079. handle: this.handles[ index ],
  5080. value: newVal,
  5081. values: newValues
  5082. } );
  5083. otherVal = this.values( index ? 0 : 1 );
  5084. if ( allowed !== false ) {
  5085. this.values( index, newVal );
  5086. }
  5087. }
  5088. } else {
  5089. if ( newVal !== this.value() ) {
  5090. // A slide can be canceled by returning false from the slide callback
  5091. allowed = this._trigger( "slide", event, {
  5092. handle: this.handles[ index ],
  5093. value: newVal
  5094. } );
  5095. if ( allowed !== false ) {
  5096. this.value( newVal );
  5097. }
  5098. }
  5099. }
  5100. },
  5101. _stop: function( event, index ) {
  5102. var uiHash = {
  5103. handle: this.handles[ index ],
  5104. value: this.value()
  5105. };
  5106. if ( this.options.values && this.options.values.length ) {
  5107. uiHash.value = this.values( index );
  5108. uiHash.values = this.values();
  5109. }
  5110. this._trigger( "stop", event, uiHash );
  5111. },
  5112. _change: function( event, index ) {
  5113. if ( !this._keySliding && !this._mouseSliding ) {
  5114. var uiHash = {
  5115. handle: this.handles[ index ],
  5116. value: this.value()
  5117. };
  5118. if ( this.options.values && this.options.values.length ) {
  5119. uiHash.value = this.values( index );
  5120. uiHash.values = this.values();
  5121. }
  5122. //store the last changed value index for reference when handles overlap
  5123. this._lastChangedValue = index;
  5124. this._trigger( "change", event, uiHash );
  5125. }
  5126. },
  5127. value: function( newValue ) {
  5128. if ( arguments.length ) {
  5129. this.options.value = this._trimAlignValue( newValue );
  5130. this._refreshValue();
  5131. this._change( null, 0 );
  5132. return;
  5133. }
  5134. return this._value();
  5135. },
  5136. values: function( index, newValue ) {
  5137. var vals,
  5138. newValues,
  5139. i;
  5140. if ( arguments.length > 1 ) {
  5141. this.options.values[ index ] = this._trimAlignValue( newValue );
  5142. this._refreshValue();
  5143. this._change( null, index );
  5144. return;
  5145. }
  5146. if ( arguments.length ) {
  5147. if ( $.isArray( arguments[ 0 ] ) ) {
  5148. vals = this.options.values;
  5149. newValues = arguments[ 0 ];
  5150. for ( i = 0; i < vals.length; i += 1 ) {
  5151. vals[ i ] = this._trimAlignValue( newValues[ i ] );
  5152. this._change( null, i );
  5153. }
  5154. this._refreshValue();
  5155. } else {
  5156. if ( this.options.values && this.options.values.length ) {
  5157. return this._values( index );
  5158. } else {
  5159. return this.value();
  5160. }
  5161. }
  5162. } else {
  5163. return this._values();
  5164. }
  5165. },
  5166. _setOption: function( key, value ) {
  5167. var i,
  5168. valsLength = 0;
  5169. if ( key === "range" && this.options.range === true ) {
  5170. if ( value === "min" ) {
  5171. this.options.value = this._values( 0 );
  5172. this.options.values = null;
  5173. } else if ( value === "max" ) {
  5174. this.options.value = this._values( this.options.values.length - 1 );
  5175. this.options.values = null;
  5176. }
  5177. }
  5178. if ( $.isArray( this.options.values ) ) {
  5179. valsLength = this.options.values.length;
  5180. }
  5181. if ( key === "disabled" ) {
  5182. this.element.toggleClass( "ui-state-disabled", !!value );
  5183. }
  5184. this._super( key, value );
  5185. switch ( key ) {
  5186. case "orientation":
  5187. this._detectOrientation();
  5188. this.element
  5189. .removeClass( "ui-slider-horizontal ui-slider-vertical" )
  5190. .addClass( "ui-slider-" + this.orientation );
  5191. this._refreshValue();
  5192. // Reset positioning from previous orientation
  5193. this.handles.css( value === "horizontal" ? "bottom" : "left", "" );
  5194. break;
  5195. case "value":
  5196. this._animateOff = true;
  5197. this._refreshValue();
  5198. this._change( null, 0 );
  5199. this._animateOff = false;
  5200. break;
  5201. case "values":
  5202. this._animateOff = true;
  5203. this._refreshValue();
  5204. for ( i = 0; i < valsLength; i += 1 ) {
  5205. this._change( null, i );
  5206. }
  5207. this._animateOff = false;
  5208. break;
  5209. case "step":
  5210. case "min":
  5211. case "max":
  5212. this._animateOff = true;
  5213. this._calculateNewMax();
  5214. this._refreshValue();
  5215. this._animateOff = false;
  5216. break;
  5217. case "range":
  5218. this._animateOff = true;
  5219. this._refresh();
  5220. this._animateOff = false;
  5221. break;
  5222. }
  5223. },
  5224. //internal value getter
  5225. // _value() returns value trimmed by min and max, aligned by step
  5226. _value: function() {
  5227. var val = this.options.value;
  5228. val = this._trimAlignValue( val );
  5229. return val;
  5230. },
  5231. //internal values getter
  5232. // _values() returns array of values trimmed by min and max, aligned by step
  5233. // _values( index ) returns single value trimmed by min and max, aligned by step
  5234. _values: function( index ) {
  5235. var val,
  5236. vals,
  5237. i;
  5238. if ( arguments.length ) {
  5239. val = this.options.values[ index ];
  5240. val = this._trimAlignValue( val );
  5241. return val;
  5242. } else if ( this.options.values && this.options.values.length ) {
  5243. // .slice() creates a copy of the array
  5244. // this copy gets trimmed by min and max and then returned
  5245. vals = this.options.values.slice();
  5246. for ( i = 0; i < vals.length; i += 1) {
  5247. vals[ i ] = this._trimAlignValue( vals[ i ] );
  5248. }
  5249. return vals;
  5250. } else {
  5251. return [];
  5252. }
  5253. },
  5254. // returns the step-aligned value that val is closest to, between (inclusive) min and max
  5255. _trimAlignValue: function( val ) {
  5256. if ( val <= this._valueMin() ) {
  5257. return this._valueMin();
  5258. }
  5259. if ( val >= this._valueMax() ) {
  5260. return this._valueMax();
  5261. }
  5262. var step = ( this.options.step > 0 ) ? this.options.step : 1,
  5263. valModStep = (val - this._valueMin()) % step,
  5264. alignValue = val - valModStep;
  5265. if ( Math.abs(valModStep) * 2 >= step ) {
  5266. alignValue += ( valModStep > 0 ) ? step : ( -step );
  5267. }
  5268. // Since JavaScript has problems with large floats, round
  5269. // the final value to 5 digits after the decimal point (see #4124)
  5270. return parseFloat( alignValue.toFixed(5) );
  5271. },
  5272. _calculateNewMax: function() {
  5273. var remainder = ( this.options.max - this._valueMin() ) % this.options.step;
  5274. this.max = this.options.max - remainder;
  5275. },
  5276. _valueMin: function() {
  5277. return this.options.min;
  5278. },
  5279. _valueMax: function() {
  5280. return this.max;
  5281. },
  5282. _refreshValue: function() {
  5283. var lastValPercent, valPercent, value, valueMin, valueMax,
  5284. oRange = this.options.range,
  5285. o = this.options,
  5286. that = this,
  5287. animate = ( !this._animateOff ) ? o.animate : false,
  5288. _set = {};
  5289. if ( this.options.values && this.options.values.length ) {
  5290. this.handles.each(function( i ) {
  5291. valPercent = ( that.values(i) - that._valueMin() ) / ( that._valueMax() - that._valueMin() ) * 100;
  5292. _set[ that.orientation === "horizontal" ? "left" : "bottom" ] = valPercent + "%";
  5293. $( this ).stop( 1, 1 )[ animate ? "animate" : "css" ]( _set, o.animate );
  5294. if ( that.options.range === true ) {
  5295. if ( that.orientation === "horizontal" ) {
  5296. if ( i === 0 ) {
  5297. that.range.stop( 1, 1 )[ animate ? "animate" : "css" ]( { left: valPercent + "%" }, o.animate );
  5298. }
  5299. if ( i === 1 ) {
  5300. that.range[ animate ? "animate" : "css" ]( { width: ( valPercent - lastValPercent ) + "%" }, { queue: false, duration: o.animate } );
  5301. }
  5302. } else {
  5303. if ( i === 0 ) {
  5304. that.range.stop( 1, 1 )[ animate ? "animate" : "css" ]( { bottom: ( valPercent ) + "%" }, o.animate );
  5305. }
  5306. if ( i === 1 ) {
  5307. that.range[ animate ? "animate" : "css" ]( { height: ( valPercent - lastValPercent ) + "%" }, { queue: false, duration: o.animate } );
  5308. }
  5309. }
  5310. }
  5311. lastValPercent = valPercent;
  5312. });
  5313. } else {
  5314. value = this.value();
  5315. valueMin = this._valueMin();
  5316. valueMax = this._valueMax();
  5317. valPercent = ( valueMax !== valueMin ) ?
  5318. ( value - valueMin ) / ( valueMax - valueMin ) * 100 :
  5319. 0;
  5320. _set[ this.orientation === "horizontal" ? "left" : "bottom" ] = valPercent + "%";
  5321. this.handle.stop( 1, 1 )[ animate ? "animate" : "css" ]( _set, o.animate );
  5322. if ( oRange === "min" && this.orientation === "horizontal" ) {
  5323. this.range.stop( 1, 1 )[ animate ? "animate" : "css" ]( { width: valPercent + "%" }, o.animate );
  5324. }
  5325. if ( oRange === "max" && this.orientation === "horizontal" ) {
  5326. this.range[ animate ? "animate" : "css" ]( { width: ( 100 - valPercent ) + "%" }, { queue: false, duration: o.animate } );
  5327. }
  5328. if ( oRange === "min" && this.orientation === "vertical" ) {
  5329. this.range.stop( 1, 1 )[ animate ? "animate" : "css" ]( { height: valPercent + "%" }, o.animate );
  5330. }
  5331. if ( oRange === "max" && this.orientation === "vertical" ) {
  5332. this.range[ animate ? "animate" : "css" ]( { height: ( 100 - valPercent ) + "%" }, { queue: false, duration: o.animate } );
  5333. }
  5334. }
  5335. },
  5336. _handleEvents: {
  5337. keydown: function( event ) {
  5338. var allowed, curVal, newVal, step,
  5339. index = $( event.target ).data( "ui-slider-handle-index" );
  5340. switch ( event.keyCode ) {
  5341. case $.ui.keyCode.HOME:
  5342. case $.ui.keyCode.END:
  5343. case $.ui.keyCode.PAGE_UP:
  5344. case $.ui.keyCode.PAGE_DOWN:
  5345. case $.ui.keyCode.UP:
  5346. case $.ui.keyCode.RIGHT:
  5347. case $.ui.keyCode.DOWN:
  5348. case $.ui.keyCode.LEFT:
  5349. event.preventDefault();
  5350. if ( !this._keySliding ) {
  5351. this._keySliding = true;
  5352. $( event.target ).addClass( "ui-state-active" );
  5353. allowed = this._start( event, index );
  5354. if ( allowed === false ) {
  5355. return;
  5356. }
  5357. }
  5358. break;
  5359. }
  5360. step = this.options.step;
  5361. if ( this.options.values && this.options.values.length ) {
  5362. curVal = newVal = this.values( index );
  5363. } else {
  5364. curVal = newVal = this.value();
  5365. }
  5366. switch ( event.keyCode ) {
  5367. case $.ui.keyCode.HOME:
  5368. newVal = this._valueMin();
  5369. break;
  5370. case $.ui.keyCode.END:
  5371. newVal = this._valueMax();
  5372. break;
  5373. case $.ui.keyCode.PAGE_UP:
  5374. newVal = this._trimAlignValue(
  5375. curVal + ( ( this._valueMax() - this._valueMin() ) / this.numPages )
  5376. );
  5377. break;
  5378. case $.ui.keyCode.PAGE_DOWN:
  5379. newVal = this._trimAlignValue(
  5380. curVal - ( (this._valueMax() - this._valueMin()) / this.numPages ) );
  5381. break;
  5382. case $.ui.keyCode.UP:
  5383. case $.ui.keyCode.RIGHT:
  5384. if ( curVal === this._valueMax() ) {
  5385. return;
  5386. }
  5387. newVal = this._trimAlignValue( curVal + step );
  5388. break;
  5389. case $.ui.keyCode.DOWN:
  5390. case $.ui.keyCode.LEFT:
  5391. if ( curVal === this._valueMin() ) {
  5392. return;
  5393. }
  5394. newVal = this._trimAlignValue( curVal - step );
  5395. break;
  5396. }
  5397. this._slide( event, index, newVal );
  5398. },
  5399. keyup: function( event ) {
  5400. var index = $( event.target ).data( "ui-slider-handle-index" );
  5401. if ( this._keySliding ) {
  5402. this._keySliding = false;
  5403. this._stop( event, index );
  5404. this._change( event, index );
  5405. $( event.target ).removeClass( "ui-state-active" );
  5406. }
  5407. }
  5408. }
  5409. });
  5410. }));