jquery-ui_dist_jquery-ui.js 477 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193
  1. // node_modules/jquery-ui/dist/jquery-ui.js
  2. (function(factory) {
  3. "use strict";
  4. if (typeof define === "function" && define.amd) {
  5. define(["jquery"], factory);
  6. } else {
  7. factory(jQuery);
  8. }
  9. })(function($) {
  10. "use strict";
  11. $.ui = $.ui || {};
  12. var version = $.ui.version = "1.14.1";
  13. var widgetUuid = 0;
  14. var widgetHasOwnProperty = Array.prototype.hasOwnProperty;
  15. var widgetSlice = Array.prototype.slice;
  16. $.cleanData = function(orig) {
  17. return function(elems) {
  18. var events, elem, i;
  19. for (i = 0; (elem = elems[i]) != null; i++) {
  20. events = $._data(elem, "events");
  21. if (events && events.remove) {
  22. $(elem).triggerHandler("remove");
  23. }
  24. }
  25. orig(elems);
  26. };
  27. }($.cleanData);
  28. $.widget = function(name, base, prototype) {
  29. var existingConstructor, constructor, basePrototype;
  30. var proxiedPrototype = {};
  31. var namespace = name.split(".")[0];
  32. name = name.split(".")[1];
  33. if (name === "__proto__" || name === "constructor") {
  34. return $.error("Invalid widget name: " + name);
  35. }
  36. var fullName = namespace + "-" + name;
  37. if (!prototype) {
  38. prototype = base;
  39. base = $.Widget;
  40. }
  41. if (Array.isArray(prototype)) {
  42. prototype = $.extend.apply(null, [{}].concat(prototype));
  43. }
  44. $.expr.pseudos[fullName.toLowerCase()] = function(elem) {
  45. return !!$.data(elem, fullName);
  46. };
  47. $[namespace] = $[namespace] || {};
  48. existingConstructor = $[namespace][name];
  49. constructor = $[namespace][name] = function(options, element) {
  50. if (!this || !this._createWidget) {
  51. return new constructor(options, element);
  52. }
  53. if (arguments.length) {
  54. this._createWidget(options, element);
  55. }
  56. };
  57. $.extend(constructor, existingConstructor, {
  58. version: prototype.version,
  59. // Copy the object used to create the prototype in case we need to
  60. // redefine the widget later
  61. _proto: $.extend({}, prototype),
  62. // Track widgets that inherit from this widget in case this widget is
  63. // redefined after a widget inherits from it
  64. _childConstructors: []
  65. });
  66. basePrototype = new base();
  67. basePrototype.options = $.widget.extend({}, basePrototype.options);
  68. $.each(prototype, function(prop, value) {
  69. if (typeof value !== "function") {
  70. proxiedPrototype[prop] = value;
  71. return;
  72. }
  73. proxiedPrototype[prop] = function() {
  74. function _super() {
  75. return base.prototype[prop].apply(this, arguments);
  76. }
  77. function _superApply(args) {
  78. return base.prototype[prop].apply(this, args);
  79. }
  80. return function() {
  81. var __super = this._super;
  82. var __superApply = this._superApply;
  83. var returnValue;
  84. this._super = _super;
  85. this._superApply = _superApply;
  86. returnValue = value.apply(this, arguments);
  87. this._super = __super;
  88. this._superApply = __superApply;
  89. return returnValue;
  90. };
  91. }();
  92. });
  93. constructor.prototype = $.widget.extend(basePrototype, {
  94. // TODO: remove support for widgetEventPrefix
  95. // always use the name + a colon as the prefix, e.g., draggable:start
  96. // don't prefix for widgets that aren't DOM-based
  97. widgetEventPrefix: existingConstructor ? basePrototype.widgetEventPrefix || name : name
  98. }, proxiedPrototype, {
  99. constructor,
  100. namespace,
  101. widgetName: name,
  102. widgetFullName: fullName
  103. });
  104. if (existingConstructor) {
  105. $.each(existingConstructor._childConstructors, function(i, child) {
  106. var childPrototype = child.prototype;
  107. $.widget(
  108. childPrototype.namespace + "." + childPrototype.widgetName,
  109. constructor,
  110. child._proto
  111. );
  112. });
  113. delete existingConstructor._childConstructors;
  114. } else {
  115. base._childConstructors.push(constructor);
  116. }
  117. $.widget.bridge(name, constructor);
  118. return constructor;
  119. };
  120. $.widget.extend = function(target) {
  121. var input = widgetSlice.call(arguments, 1);
  122. var inputIndex = 0;
  123. var inputLength = input.length;
  124. var key;
  125. var value;
  126. for (; inputIndex < inputLength; inputIndex++) {
  127. for (key in input[inputIndex]) {
  128. value = input[inputIndex][key];
  129. if (widgetHasOwnProperty.call(input[inputIndex], key) && value !== void 0) {
  130. if ($.isPlainObject(value)) {
  131. target[key] = $.isPlainObject(target[key]) ? $.widget.extend({}, target[key], value) : (
  132. // Don't extend strings, arrays, etc. with objects
  133. $.widget.extend({}, value)
  134. );
  135. } else {
  136. target[key] = value;
  137. }
  138. }
  139. }
  140. }
  141. return target;
  142. };
  143. $.widget.bridge = function(name, object) {
  144. var fullName = object.prototype.widgetFullName || name;
  145. $.fn[name] = function(options) {
  146. var isMethodCall = typeof options === "string";
  147. var args = widgetSlice.call(arguments, 1);
  148. var returnValue = this;
  149. if (isMethodCall) {
  150. if (!this.length && options === "instance") {
  151. returnValue = void 0;
  152. } else {
  153. this.each(function() {
  154. var methodValue;
  155. var instance = $.data(this, fullName);
  156. if (options === "instance") {
  157. returnValue = instance;
  158. return false;
  159. }
  160. if (!instance) {
  161. return $.error("cannot call methods on " + name + " prior to initialization; attempted to call method '" + options + "'");
  162. }
  163. if (typeof instance[options] !== "function" || options.charAt(0) === "_") {
  164. return $.error("no such method '" + options + "' for " + name + " widget instance");
  165. }
  166. methodValue = instance[options].apply(instance, args);
  167. if (methodValue !== instance && methodValue !== void 0) {
  168. returnValue = methodValue && methodValue.jquery ? returnValue.pushStack(methodValue.get()) : methodValue;
  169. return false;
  170. }
  171. });
  172. }
  173. } else {
  174. if (args.length) {
  175. options = $.widget.extend.apply(null, [options].concat(args));
  176. }
  177. this.each(function() {
  178. var instance = $.data(this, fullName);
  179. if (instance) {
  180. instance.option(options || {});
  181. if (instance._init) {
  182. instance._init();
  183. }
  184. } else {
  185. $.data(this, fullName, new object(options, this));
  186. }
  187. });
  188. }
  189. return returnValue;
  190. };
  191. };
  192. $.Widget = function() {
  193. };
  194. $.Widget._childConstructors = [];
  195. $.Widget.prototype = {
  196. widgetName: "widget",
  197. widgetEventPrefix: "",
  198. defaultElement: "<div>",
  199. options: {
  200. classes: {},
  201. disabled: false,
  202. // Callbacks
  203. create: null
  204. },
  205. _createWidget: function(options, element) {
  206. element = $(element || this.defaultElement || this)[0];
  207. this.element = $(element);
  208. this.uuid = widgetUuid++;
  209. this.eventNamespace = "." + this.widgetName + this.uuid;
  210. this.bindings = $();
  211. this.hoverable = $();
  212. this.focusable = $();
  213. this.classesElementLookup = {};
  214. if (element !== this) {
  215. $.data(element, this.widgetFullName, this);
  216. this._on(true, this.element, {
  217. remove: function(event) {
  218. if (event.target === element) {
  219. this.destroy();
  220. }
  221. }
  222. });
  223. this.document = $(element.style ? (
  224. // Element within the document
  225. element.ownerDocument
  226. ) : (
  227. // Element is window or document
  228. element.document || element
  229. ));
  230. this.window = $(this.document[0].defaultView || this.document[0].parentWindow);
  231. }
  232. this.options = $.widget.extend(
  233. {},
  234. this.options,
  235. this._getCreateOptions(),
  236. options
  237. );
  238. this._create();
  239. if (this.options.disabled) {
  240. this._setOptionDisabled(this.options.disabled);
  241. }
  242. this._trigger("create", null, this._getCreateEventData());
  243. this._init();
  244. },
  245. _getCreateOptions: function() {
  246. return {};
  247. },
  248. _getCreateEventData: $.noop,
  249. _create: $.noop,
  250. _init: $.noop,
  251. destroy: function() {
  252. var that = this;
  253. this._destroy();
  254. $.each(this.classesElementLookup, function(key, value) {
  255. that._removeClass(value, key);
  256. });
  257. this.element.off(this.eventNamespace).removeData(this.widgetFullName);
  258. this.widget().off(this.eventNamespace).removeAttr("aria-disabled");
  259. this.bindings.off(this.eventNamespace);
  260. },
  261. _destroy: $.noop,
  262. widget: function() {
  263. return this.element;
  264. },
  265. option: function(key, value) {
  266. var options = key;
  267. var parts;
  268. var curOption;
  269. var i;
  270. if (arguments.length === 0) {
  271. return $.widget.extend({}, this.options);
  272. }
  273. if (typeof key === "string") {
  274. options = {};
  275. parts = key.split(".");
  276. key = parts.shift();
  277. if (parts.length) {
  278. curOption = options[key] = $.widget.extend({}, this.options[key]);
  279. for (i = 0; i < parts.length - 1; i++) {
  280. curOption[parts[i]] = curOption[parts[i]] || {};
  281. curOption = curOption[parts[i]];
  282. }
  283. key = parts.pop();
  284. if (arguments.length === 1) {
  285. return curOption[key] === void 0 ? null : curOption[key];
  286. }
  287. curOption[key] = value;
  288. } else {
  289. if (arguments.length === 1) {
  290. return this.options[key] === void 0 ? null : this.options[key];
  291. }
  292. options[key] = value;
  293. }
  294. }
  295. this._setOptions(options);
  296. return this;
  297. },
  298. _setOptions: function(options) {
  299. var key;
  300. for (key in options) {
  301. this._setOption(key, options[key]);
  302. }
  303. return this;
  304. },
  305. _setOption: function(key, value) {
  306. if (key === "classes") {
  307. this._setOptionClasses(value);
  308. }
  309. this.options[key] = value;
  310. if (key === "disabled") {
  311. this._setOptionDisabled(value);
  312. }
  313. return this;
  314. },
  315. _setOptionClasses: function(value) {
  316. var classKey, elements, currentElements;
  317. for (classKey in value) {
  318. currentElements = this.classesElementLookup[classKey];
  319. if (value[classKey] === this.options.classes[classKey] || !currentElements || !currentElements.length) {
  320. continue;
  321. }
  322. elements = $(currentElements.get());
  323. this._removeClass(currentElements, classKey);
  324. elements.addClass(this._classes({
  325. element: elements,
  326. keys: classKey,
  327. classes: value,
  328. add: true
  329. }));
  330. }
  331. },
  332. _setOptionDisabled: function(value) {
  333. this._toggleClass(this.widget(), this.widgetFullName + "-disabled", null, !!value);
  334. if (value) {
  335. this._removeClass(this.hoverable, null, "ui-state-hover");
  336. this._removeClass(this.focusable, null, "ui-state-focus");
  337. }
  338. },
  339. enable: function() {
  340. return this._setOptions({ disabled: false });
  341. },
  342. disable: function() {
  343. return this._setOptions({ disabled: true });
  344. },
  345. _classes: function(options) {
  346. var full = [];
  347. var that = this;
  348. options = $.extend({
  349. element: this.element,
  350. classes: this.options.classes || {}
  351. }, options);
  352. function bindRemoveEvent() {
  353. var nodesToBind = [];
  354. options.element.each(function(_, element) {
  355. var isTracked = $.map(that.classesElementLookup, function(elements) {
  356. return elements;
  357. }).some(function(elements) {
  358. return elements.is(element);
  359. });
  360. if (!isTracked) {
  361. nodesToBind.push(element);
  362. }
  363. });
  364. that._on($(nodesToBind), {
  365. remove: "_untrackClassesElement"
  366. });
  367. }
  368. function processClassString(classes, checkOption) {
  369. var current, i;
  370. for (i = 0; i < classes.length; i++) {
  371. current = that.classesElementLookup[classes[i]] || $();
  372. if (options.add) {
  373. bindRemoveEvent();
  374. current = $($.uniqueSort(current.get().concat(options.element.get())));
  375. } else {
  376. current = $(current.not(options.element).get());
  377. }
  378. that.classesElementLookup[classes[i]] = current;
  379. full.push(classes[i]);
  380. if (checkOption && options.classes[classes[i]]) {
  381. full.push(options.classes[classes[i]]);
  382. }
  383. }
  384. }
  385. if (options.keys) {
  386. processClassString(options.keys.match(/\S+/g) || [], true);
  387. }
  388. if (options.extra) {
  389. processClassString(options.extra.match(/\S+/g) || []);
  390. }
  391. return full.join(" ");
  392. },
  393. _untrackClassesElement: function(event) {
  394. var that = this;
  395. $.each(that.classesElementLookup, function(key, value) {
  396. if ($.inArray(event.target, value) !== -1) {
  397. that.classesElementLookup[key] = $(value.not(event.target).get());
  398. }
  399. });
  400. this._off($(event.target));
  401. },
  402. _removeClass: function(element, keys, extra) {
  403. return this._toggleClass(element, keys, extra, false);
  404. },
  405. _addClass: function(element, keys, extra) {
  406. return this._toggleClass(element, keys, extra, true);
  407. },
  408. _toggleClass: function(element, keys, extra, add) {
  409. add = typeof add === "boolean" ? add : extra;
  410. var shift = typeof element === "string" || element === null, options = {
  411. extra: shift ? keys : extra,
  412. keys: shift ? element : keys,
  413. element: shift ? this.element : element,
  414. add
  415. };
  416. options.element.toggleClass(this._classes(options), add);
  417. return this;
  418. },
  419. _on: function(suppressDisabledCheck, element, handlers) {
  420. var delegateElement;
  421. var instance = this;
  422. if (typeof suppressDisabledCheck !== "boolean") {
  423. handlers = element;
  424. element = suppressDisabledCheck;
  425. suppressDisabledCheck = false;
  426. }
  427. if (!handlers) {
  428. handlers = element;
  429. element = this.element;
  430. delegateElement = this.widget();
  431. } else {
  432. element = delegateElement = $(element);
  433. this.bindings = this.bindings.add(element);
  434. }
  435. $.each(handlers, function(event, handler) {
  436. function handlerProxy() {
  437. if (!suppressDisabledCheck && (instance.options.disabled === true || $(this).hasClass("ui-state-disabled"))) {
  438. return;
  439. }
  440. return (typeof handler === "string" ? instance[handler] : handler).apply(instance, arguments);
  441. }
  442. if (typeof handler !== "string") {
  443. handlerProxy.guid = handler.guid = handler.guid || handlerProxy.guid || $.guid++;
  444. }
  445. var match = event.match(/^([\w:-]*)\s*(.*)$/);
  446. var eventName = match[1] + instance.eventNamespace;
  447. var selector = match[2];
  448. if (selector) {
  449. delegateElement.on(eventName, selector, handlerProxy);
  450. } else {
  451. element.on(eventName, handlerProxy);
  452. }
  453. });
  454. },
  455. _off: function(element, eventName) {
  456. eventName = (eventName || "").split(" ").join(this.eventNamespace + " ") + this.eventNamespace;
  457. element.off(eventName);
  458. this.bindings = $(this.bindings.not(element).get());
  459. this.focusable = $(this.focusable.not(element).get());
  460. this.hoverable = $(this.hoverable.not(element).get());
  461. },
  462. _delay: function(handler, delay) {
  463. function handlerProxy() {
  464. return (typeof handler === "string" ? instance[handler] : handler).apply(instance, arguments);
  465. }
  466. var instance = this;
  467. return setTimeout(handlerProxy, delay || 0);
  468. },
  469. _hoverable: function(element) {
  470. this.hoverable = this.hoverable.add(element);
  471. this._on(element, {
  472. mouseenter: function(event) {
  473. this._addClass($(event.currentTarget), null, "ui-state-hover");
  474. },
  475. mouseleave: function(event) {
  476. this._removeClass($(event.currentTarget), null, "ui-state-hover");
  477. }
  478. });
  479. },
  480. _focusable: function(element) {
  481. this.focusable = this.focusable.add(element);
  482. this._on(element, {
  483. focusin: function(event) {
  484. this._addClass($(event.currentTarget), null, "ui-state-focus");
  485. },
  486. focusout: function(event) {
  487. this._removeClass($(event.currentTarget), null, "ui-state-focus");
  488. }
  489. });
  490. },
  491. _trigger: function(type, event, data2) {
  492. var prop, orig;
  493. var callback = this.options[type];
  494. data2 = data2 || {};
  495. event = $.Event(event);
  496. event.type = (type === this.widgetEventPrefix ? type : this.widgetEventPrefix + type).toLowerCase();
  497. event.target = this.element[0];
  498. orig = event.originalEvent;
  499. if (orig) {
  500. for (prop in orig) {
  501. if (!(prop in event)) {
  502. event[prop] = orig[prop];
  503. }
  504. }
  505. }
  506. this.element.trigger(event, data2);
  507. return !(typeof callback === "function" && callback.apply(this.element[0], [event].concat(data2)) === false || event.isDefaultPrevented());
  508. }
  509. };
  510. $.each({ show: "fadeIn", hide: "fadeOut" }, function(method, defaultEffect) {
  511. $.Widget.prototype["_" + method] = function(element, options, callback) {
  512. if (typeof options === "string") {
  513. options = { effect: options };
  514. }
  515. var hasOptions;
  516. var effectName = !options ? method : options === true || typeof options === "number" ? defaultEffect : options.effect || defaultEffect;
  517. options = options || {};
  518. if (typeof options === "number") {
  519. options = { duration: options };
  520. } else if (options === true) {
  521. options = {};
  522. }
  523. hasOptions = !$.isEmptyObject(options);
  524. options.complete = callback;
  525. if (options.delay) {
  526. element.delay(options.delay);
  527. }
  528. if (hasOptions && $.effects && $.effects.effect[effectName]) {
  529. element[method](options);
  530. } else if (effectName !== method && element[effectName]) {
  531. element[effectName](options.duration, options.easing, callback);
  532. } else {
  533. element.queue(function(next) {
  534. $(this)[method]();
  535. if (callback) {
  536. callback.call(element[0]);
  537. }
  538. next();
  539. });
  540. }
  541. };
  542. });
  543. var widget = $.widget;
  544. (function() {
  545. var cachedScrollbarWidth, max = Math.max, abs = Math.abs, rhorizontal = /left|center|right/, rvertical = /top|center|bottom/, roffset = /[\+\-]\d+(\.[\d]+)?%?/, rposition = /^\w+/, rpercent = /%$/, _position = $.fn.position;
  546. function getOffsets(offsets, width, height) {
  547. return [
  548. parseFloat(offsets[0]) * (rpercent.test(offsets[0]) ? width / 100 : 1),
  549. parseFloat(offsets[1]) * (rpercent.test(offsets[1]) ? height / 100 : 1)
  550. ];
  551. }
  552. function parseCss(element, property) {
  553. return parseInt($.css(element, property), 10) || 0;
  554. }
  555. function isWindow(obj) {
  556. return obj != null && obj === obj.window;
  557. }
  558. function getDimensions(elem) {
  559. var raw = elem[0];
  560. if (raw.nodeType === 9) {
  561. return {
  562. width: elem.width(),
  563. height: elem.height(),
  564. offset: { top: 0, left: 0 }
  565. };
  566. }
  567. if (isWindow(raw)) {
  568. return {
  569. width: elem.width(),
  570. height: elem.height(),
  571. offset: { top: elem.scrollTop(), left: elem.scrollLeft() }
  572. };
  573. }
  574. if (raw.preventDefault) {
  575. return {
  576. width: 0,
  577. height: 0,
  578. offset: { top: raw.pageY, left: raw.pageX }
  579. };
  580. }
  581. return {
  582. width: elem.outerWidth(),
  583. height: elem.outerHeight(),
  584. offset: elem.offset()
  585. };
  586. }
  587. $.position = {
  588. scrollbarWidth: function() {
  589. if (cachedScrollbarWidth !== void 0) {
  590. return cachedScrollbarWidth;
  591. }
  592. var w1, w2, div = $("<div style='display:block;position:absolute;width:200px;height:200px;overflow:hidden;'><div style='height:300px;width:auto;'></div></div>"), innerDiv = div.children()[0];
  593. $("body").append(div);
  594. w1 = innerDiv.offsetWidth;
  595. div.css("overflow", "scroll");
  596. w2 = innerDiv.offsetWidth;
  597. if (w1 === w2) {
  598. w2 = div[0].clientWidth;
  599. }
  600. div.remove();
  601. return cachedScrollbarWidth = w1 - w2;
  602. },
  603. getScrollInfo: function(within) {
  604. var overflowX = within.isWindow || within.isDocument ? "" : within.element.css("overflow-x"), overflowY = within.isWindow || within.isDocument ? "" : within.element.css("overflow-y"), hasOverflowX = overflowX === "scroll" || overflowX === "auto" && within.width < within.element[0].scrollWidth, hasOverflowY = overflowY === "scroll" || overflowY === "auto" && within.height < within.element[0].scrollHeight;
  605. return {
  606. width: hasOverflowY ? $.position.scrollbarWidth() : 0,
  607. height: hasOverflowX ? $.position.scrollbarWidth() : 0
  608. };
  609. },
  610. getWithinInfo: function(element) {
  611. var withinElement = $(element || window), isElemWindow = isWindow(withinElement[0]), isDocument = !!withinElement[0] && withinElement[0].nodeType === 9, hasOffset = !isElemWindow && !isDocument;
  612. return {
  613. element: withinElement,
  614. isWindow: isElemWindow,
  615. isDocument,
  616. offset: hasOffset ? $(element).offset() : { left: 0, top: 0 },
  617. scrollLeft: withinElement.scrollLeft(),
  618. scrollTop: withinElement.scrollTop(),
  619. width: withinElement.outerWidth(),
  620. height: withinElement.outerHeight()
  621. };
  622. }
  623. };
  624. $.fn.position = function(options) {
  625. if (!options || !options.of) {
  626. return _position.apply(this, arguments);
  627. }
  628. options = $.extend({}, options);
  629. var atOffset, targetWidth, targetHeight, targetOffset, basePosition, dimensions, target = typeof options.of === "string" ? $(document).find(options.of) : $(options.of), within = $.position.getWithinInfo(options.within), scrollInfo = $.position.getScrollInfo(within), collision = (options.collision || "flip").split(" "), offsets = {};
  630. dimensions = getDimensions(target);
  631. if (target[0].preventDefault) {
  632. options.at = "left top";
  633. }
  634. targetWidth = dimensions.width;
  635. targetHeight = dimensions.height;
  636. targetOffset = dimensions.offset;
  637. basePosition = $.extend({}, targetOffset);
  638. $.each(["my", "at"], function() {
  639. var pos = (options[this] || "").split(" "), horizontalOffset, verticalOffset;
  640. if (pos.length === 1) {
  641. pos = rhorizontal.test(pos[0]) ? pos.concat(["center"]) : rvertical.test(pos[0]) ? ["center"].concat(pos) : ["center", "center"];
  642. }
  643. pos[0] = rhorizontal.test(pos[0]) ? pos[0] : "center";
  644. pos[1] = rvertical.test(pos[1]) ? pos[1] : "center";
  645. horizontalOffset = roffset.exec(pos[0]);
  646. verticalOffset = roffset.exec(pos[1]);
  647. offsets[this] = [
  648. horizontalOffset ? horizontalOffset[0] : 0,
  649. verticalOffset ? verticalOffset[0] : 0
  650. ];
  651. options[this] = [
  652. rposition.exec(pos[0])[0],
  653. rposition.exec(pos[1])[0]
  654. ];
  655. });
  656. if (collision.length === 1) {
  657. collision[1] = collision[0];
  658. }
  659. if (options.at[0] === "right") {
  660. basePosition.left += targetWidth;
  661. } else if (options.at[0] === "center") {
  662. basePosition.left += targetWidth / 2;
  663. }
  664. if (options.at[1] === "bottom") {
  665. basePosition.top += targetHeight;
  666. } else if (options.at[1] === "center") {
  667. basePosition.top += targetHeight / 2;
  668. }
  669. atOffset = getOffsets(offsets.at, targetWidth, targetHeight);
  670. basePosition.left += atOffset[0];
  671. basePosition.top += atOffset[1];
  672. return this.each(function() {
  673. var collisionPosition, using, elem = $(this), elemWidth = elem.outerWidth(), elemHeight = elem.outerHeight(), marginLeft = parseCss(this, "marginLeft"), marginTop = parseCss(this, "marginTop"), collisionWidth = elemWidth + marginLeft + parseCss(this, "marginRight") + scrollInfo.width, collisionHeight = elemHeight + marginTop + parseCss(this, "marginBottom") + scrollInfo.height, position2 = $.extend({}, basePosition), myOffset = getOffsets(offsets.my, elem.outerWidth(), elem.outerHeight());
  674. if (options.my[0] === "right") {
  675. position2.left -= elemWidth;
  676. } else if (options.my[0] === "center") {
  677. position2.left -= elemWidth / 2;
  678. }
  679. if (options.my[1] === "bottom") {
  680. position2.top -= elemHeight;
  681. } else if (options.my[1] === "center") {
  682. position2.top -= elemHeight / 2;
  683. }
  684. position2.left += myOffset[0];
  685. position2.top += myOffset[1];
  686. collisionPosition = {
  687. marginLeft,
  688. marginTop
  689. };
  690. $.each(["left", "top"], function(i, dir) {
  691. if ($.ui.position[collision[i]]) {
  692. $.ui.position[collision[i]][dir](position2, {
  693. targetWidth,
  694. targetHeight,
  695. elemWidth,
  696. elemHeight,
  697. collisionPosition,
  698. collisionWidth,
  699. collisionHeight,
  700. offset: [atOffset[0] + myOffset[0], atOffset[1] + myOffset[1]],
  701. my: options.my,
  702. at: options.at,
  703. within,
  704. elem
  705. });
  706. }
  707. });
  708. if (options.using) {
  709. using = function(props) {
  710. var left = targetOffset.left - position2.left, right = left + targetWidth - elemWidth, top = targetOffset.top - position2.top, bottom = top + targetHeight - elemHeight, feedback = {
  711. target: {
  712. element: target,
  713. left: targetOffset.left,
  714. top: targetOffset.top,
  715. width: targetWidth,
  716. height: targetHeight
  717. },
  718. element: {
  719. element: elem,
  720. left: position2.left,
  721. top: position2.top,
  722. width: elemWidth,
  723. height: elemHeight
  724. },
  725. horizontal: right < 0 ? "left" : left > 0 ? "right" : "center",
  726. vertical: bottom < 0 ? "top" : top > 0 ? "bottom" : "middle"
  727. };
  728. if (targetWidth < elemWidth && abs(left + right) < targetWidth) {
  729. feedback.horizontal = "center";
  730. }
  731. if (targetHeight < elemHeight && abs(top + bottom) < targetHeight) {
  732. feedback.vertical = "middle";
  733. }
  734. if (max(abs(left), abs(right)) > max(abs(top), abs(bottom))) {
  735. feedback.important = "horizontal";
  736. } else {
  737. feedback.important = "vertical";
  738. }
  739. options.using.call(this, props, feedback);
  740. };
  741. }
  742. elem.offset($.extend(position2, { using }));
  743. });
  744. };
  745. $.ui.position = {
  746. fit: {
  747. left: function(position2, data2) {
  748. var within = data2.within, withinOffset = within.isWindow ? within.scrollLeft : within.offset.left, outerWidth = within.width, collisionPosLeft = position2.left - data2.collisionPosition.marginLeft, overLeft = withinOffset - collisionPosLeft, overRight = collisionPosLeft + data2.collisionWidth - outerWidth - withinOffset, newOverRight;
  749. if (data2.collisionWidth > outerWidth) {
  750. if (overLeft > 0 && overRight <= 0) {
  751. newOverRight = position2.left + overLeft + data2.collisionWidth - outerWidth - withinOffset;
  752. position2.left += overLeft - newOverRight;
  753. } else if (overRight > 0 && overLeft <= 0) {
  754. position2.left = withinOffset;
  755. } else {
  756. if (overLeft > overRight) {
  757. position2.left = withinOffset + outerWidth - data2.collisionWidth;
  758. } else {
  759. position2.left = withinOffset;
  760. }
  761. }
  762. } else if (overLeft > 0) {
  763. position2.left += overLeft;
  764. } else if (overRight > 0) {
  765. position2.left -= overRight;
  766. } else {
  767. position2.left = max(position2.left - collisionPosLeft, position2.left);
  768. }
  769. },
  770. top: function(position2, data2) {
  771. var within = data2.within, withinOffset = within.isWindow ? within.scrollTop : within.offset.top, outerHeight = data2.within.height, collisionPosTop = position2.top - data2.collisionPosition.marginTop, overTop = withinOffset - collisionPosTop, overBottom = collisionPosTop + data2.collisionHeight - outerHeight - withinOffset, newOverBottom;
  772. if (data2.collisionHeight > outerHeight) {
  773. if (overTop > 0 && overBottom <= 0) {
  774. newOverBottom = position2.top + overTop + data2.collisionHeight - outerHeight - withinOffset;
  775. position2.top += overTop - newOverBottom;
  776. } else if (overBottom > 0 && overTop <= 0) {
  777. position2.top = withinOffset;
  778. } else {
  779. if (overTop > overBottom) {
  780. position2.top = withinOffset + outerHeight - data2.collisionHeight;
  781. } else {
  782. position2.top = withinOffset;
  783. }
  784. }
  785. } else if (overTop > 0) {
  786. position2.top += overTop;
  787. } else if (overBottom > 0) {
  788. position2.top -= overBottom;
  789. } else {
  790. position2.top = max(position2.top - collisionPosTop, position2.top);
  791. }
  792. }
  793. },
  794. flip: {
  795. left: function(position2, data2) {
  796. var within = data2.within, withinOffset = within.offset.left + within.scrollLeft, outerWidth = within.width, offsetLeft = within.isWindow ? within.scrollLeft : within.offset.left, collisionPosLeft = position2.left - data2.collisionPosition.marginLeft, overLeft = collisionPosLeft - offsetLeft, overRight = collisionPosLeft + data2.collisionWidth - outerWidth - offsetLeft, myOffset = data2.my[0] === "left" ? -data2.elemWidth : data2.my[0] === "right" ? data2.elemWidth : 0, atOffset = data2.at[0] === "left" ? data2.targetWidth : data2.at[0] === "right" ? -data2.targetWidth : 0, offset = -2 * data2.offset[0], newOverRight, newOverLeft;
  797. if (overLeft < 0) {
  798. newOverRight = position2.left + myOffset + atOffset + offset + data2.collisionWidth - outerWidth - withinOffset;
  799. if (newOverRight < 0 || newOverRight < abs(overLeft)) {
  800. position2.left += myOffset + atOffset + offset;
  801. }
  802. } else if (overRight > 0) {
  803. newOverLeft = position2.left - data2.collisionPosition.marginLeft + myOffset + atOffset + offset - offsetLeft;
  804. if (newOverLeft > 0 || abs(newOverLeft) < overRight) {
  805. position2.left += myOffset + atOffset + offset;
  806. }
  807. }
  808. },
  809. top: function(position2, data2) {
  810. var within = data2.within, withinOffset = within.offset.top + within.scrollTop, outerHeight = within.height, offsetTop = within.isWindow ? within.scrollTop : within.offset.top, collisionPosTop = position2.top - data2.collisionPosition.marginTop, overTop = collisionPosTop - offsetTop, overBottom = collisionPosTop + data2.collisionHeight - outerHeight - offsetTop, top = data2.my[1] === "top", myOffset = top ? -data2.elemHeight : data2.my[1] === "bottom" ? data2.elemHeight : 0, atOffset = data2.at[1] === "top" ? data2.targetHeight : data2.at[1] === "bottom" ? -data2.targetHeight : 0, offset = -2 * data2.offset[1], newOverTop, newOverBottom;
  811. if (overTop < 0) {
  812. newOverBottom = position2.top + myOffset + atOffset + offset + data2.collisionHeight - outerHeight - withinOffset;
  813. if (newOverBottom < 0 || newOverBottom < abs(overTop)) {
  814. position2.top += myOffset + atOffset + offset;
  815. }
  816. } else if (overBottom > 0) {
  817. newOverTop = position2.top - data2.collisionPosition.marginTop + myOffset + atOffset + offset - offsetTop;
  818. if (newOverTop > 0 || abs(newOverTop) < overBottom) {
  819. position2.top += myOffset + atOffset + offset;
  820. }
  821. }
  822. }
  823. },
  824. flipfit: {
  825. left: function() {
  826. $.ui.position.flip.left.apply(this, arguments);
  827. $.ui.position.fit.left.apply(this, arguments);
  828. },
  829. top: function() {
  830. $.ui.position.flip.top.apply(this, arguments);
  831. $.ui.position.fit.top.apply(this, arguments);
  832. }
  833. }
  834. };
  835. })();
  836. var position = $.ui.position;
  837. var data = $.extend($.expr.pseudos, {
  838. data: $.expr.createPseudo(function(dataName) {
  839. return function(elem) {
  840. return !!$.data(elem, dataName);
  841. };
  842. })
  843. });
  844. var disableSelection = $.fn.extend({
  845. disableSelection: function() {
  846. var eventType = "onselectstart" in document.createElement("div") ? "selectstart" : "mousedown";
  847. return function() {
  848. return this.on(eventType + ".ui-disableSelection", function(event) {
  849. event.preventDefault();
  850. });
  851. };
  852. }(),
  853. enableSelection: function() {
  854. return this.off(".ui-disableSelection");
  855. }
  856. });
  857. var jQuery2 = $;
  858. var stepHooks = "backgroundColor borderBottomColor borderLeftColor borderRightColor borderTopColor color columnRuleColor outlineColor textDecorationColor textEmphasisColor", class2type = {}, toString = class2type.toString, rplusequals = /^([\-+])=\s*(\d+\.?\d*)/, stringParsers = [{
  859. re: /rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(?:,\s*(\d?(?:\.\d+)?)\s*)?\)/,
  860. parse: function(execResult) {
  861. return [
  862. execResult[1],
  863. execResult[2],
  864. execResult[3],
  865. execResult[4]
  866. ];
  867. }
  868. }, {
  869. re: /rgba?\(\s*(\d+(?:\.\d+)?)\%\s*,\s*(\d+(?:\.\d+)?)\%\s*,\s*(\d+(?:\.\d+)?)\%\s*(?:,\s*(\d?(?:\.\d+)?)\s*)?\)/,
  870. parse: function(execResult) {
  871. return [
  872. execResult[1] * 2.55,
  873. execResult[2] * 2.55,
  874. execResult[3] * 2.55,
  875. execResult[4]
  876. ];
  877. }
  878. }, {
  879. // this regex ignores A-F because it's compared against an already lowercased string
  880. re: /#([a-f0-9]{2})([a-f0-9]{2})([a-f0-9]{2})([a-f0-9]{2})?/,
  881. parse: function(execResult) {
  882. return [
  883. parseInt(execResult[1], 16),
  884. parseInt(execResult[2], 16),
  885. parseInt(execResult[3], 16),
  886. execResult[4] ? (parseInt(execResult[4], 16) / 255).toFixed(2) : 1
  887. ];
  888. }
  889. }, {
  890. // this regex ignores A-F because it's compared against an already lowercased string
  891. re: /#([a-f0-9])([a-f0-9])([a-f0-9])([a-f0-9])?/,
  892. parse: function(execResult) {
  893. return [
  894. parseInt(execResult[1] + execResult[1], 16),
  895. parseInt(execResult[2] + execResult[2], 16),
  896. parseInt(execResult[3] + execResult[3], 16),
  897. execResult[4] ? (parseInt(execResult[4] + execResult[4], 16) / 255).toFixed(2) : 1
  898. ];
  899. }
  900. }, {
  901. re: /hsla?\(\s*(\d+(?:\.\d+)?)\s*,\s*(\d+(?:\.\d+)?)\%\s*,\s*(\d+(?:\.\d+)?)\%\s*(?:,\s*(\d?(?:\.\d+)?)\s*)?\)/,
  902. space: "hsla",
  903. parse: function(execResult) {
  904. return [
  905. execResult[1],
  906. execResult[2] / 100,
  907. execResult[3] / 100,
  908. execResult[4]
  909. ];
  910. }
  911. }], color = jQuery2.Color = function(color2, green, blue, alpha) {
  912. return new jQuery2.Color.fn.parse(color2, green, blue, alpha);
  913. }, spaces = {
  914. rgba: {
  915. props: {
  916. red: {
  917. idx: 0,
  918. type: "byte"
  919. },
  920. green: {
  921. idx: 1,
  922. type: "byte"
  923. },
  924. blue: {
  925. idx: 2,
  926. type: "byte"
  927. }
  928. }
  929. },
  930. hsla: {
  931. props: {
  932. hue: {
  933. idx: 0,
  934. type: "degrees"
  935. },
  936. saturation: {
  937. idx: 1,
  938. type: "percent"
  939. },
  940. lightness: {
  941. idx: 2,
  942. type: "percent"
  943. }
  944. }
  945. }
  946. }, propTypes = {
  947. "byte": {
  948. floor: true,
  949. max: 255
  950. },
  951. "percent": {
  952. max: 1
  953. },
  954. "degrees": {
  955. mod: 360,
  956. floor: true
  957. }
  958. }, colors, each = jQuery2.each;
  959. each(spaces, function(spaceName, space) {
  960. space.cache = "_" + spaceName;
  961. space.props.alpha = {
  962. idx: 3,
  963. type: "percent",
  964. def: 1
  965. };
  966. });
  967. jQuery2.each(
  968. "Boolean Number String Function Array Date RegExp Object Error Symbol".split(" "),
  969. function(_i, name) {
  970. class2type["[object " + name + "]"] = name.toLowerCase();
  971. }
  972. );
  973. function getType(obj) {
  974. if (obj == null) {
  975. return obj + "";
  976. }
  977. return typeof obj === "object" ? class2type[toString.call(obj)] || "object" : typeof obj;
  978. }
  979. function clamp(value, prop, allowEmpty) {
  980. var type = propTypes[prop.type] || {};
  981. if (value == null) {
  982. return allowEmpty || !prop.def ? null : prop.def;
  983. }
  984. value = type.floor ? ~~value : parseFloat(value);
  985. if (type.mod) {
  986. return (value + type.mod) % type.mod;
  987. }
  988. return Math.min(type.max, Math.max(0, value));
  989. }
  990. function stringParse(string) {
  991. var inst = color(), rgba = inst._rgba = [];
  992. string = string.toLowerCase();
  993. each(stringParsers, function(_i, parser) {
  994. var parsed, match = parser.re.exec(string), values = match && parser.parse(match), spaceName = parser.space || "rgba";
  995. if (values) {
  996. parsed = inst[spaceName](values);
  997. inst[spaces[spaceName].cache] = parsed[spaces[spaceName].cache];
  998. rgba = inst._rgba = parsed._rgba;
  999. return false;
  1000. }
  1001. });
  1002. if (rgba.length) {
  1003. if (rgba.join() === "0,0,0,0") {
  1004. jQuery2.extend(rgba, colors.transparent);
  1005. }
  1006. return inst;
  1007. }
  1008. return colors[string];
  1009. }
  1010. color.fn = jQuery2.extend(color.prototype, {
  1011. parse: function(red, green, blue, alpha) {
  1012. if (red === void 0) {
  1013. this._rgba = [null, null, null, null];
  1014. return this;
  1015. }
  1016. if (red.jquery || red.nodeType) {
  1017. red = jQuery2(red).css(green);
  1018. green = void 0;
  1019. }
  1020. var inst = this, type = getType(red), rgba = this._rgba = [];
  1021. if (green !== void 0) {
  1022. red = [red, green, blue, alpha];
  1023. type = "array";
  1024. }
  1025. if (type === "string") {
  1026. return this.parse(stringParse(red) || colors._default);
  1027. }
  1028. if (type === "array") {
  1029. each(spaces.rgba.props, function(_key, prop) {
  1030. rgba[prop.idx] = clamp(red[prop.idx], prop);
  1031. });
  1032. return this;
  1033. }
  1034. if (type === "object") {
  1035. if (red instanceof color) {
  1036. each(spaces, function(_spaceName, space) {
  1037. if (red[space.cache]) {
  1038. inst[space.cache] = red[space.cache].slice();
  1039. }
  1040. });
  1041. } else {
  1042. each(spaces, function(_spaceName, space) {
  1043. var cache = space.cache;
  1044. each(space.props, function(key, prop) {
  1045. if (!inst[cache] && space.to) {
  1046. if (key === "alpha" || red[key] == null) {
  1047. return;
  1048. }
  1049. inst[cache] = space.to(inst._rgba);
  1050. }
  1051. inst[cache][prop.idx] = clamp(red[key], prop, true);
  1052. });
  1053. if (inst[cache] && jQuery2.inArray(
  1054. null,
  1055. inst[cache].slice(0, 3)
  1056. ) < 0) {
  1057. if (inst[cache][3] == null) {
  1058. inst[cache][3] = 1;
  1059. }
  1060. if (space.from) {
  1061. inst._rgba = space.from(inst[cache]);
  1062. }
  1063. }
  1064. });
  1065. }
  1066. return this;
  1067. }
  1068. },
  1069. is: function(compare) {
  1070. var is = color(compare), same = true, inst = this;
  1071. each(spaces, function(_, space) {
  1072. var localCache, isCache = is[space.cache];
  1073. if (isCache) {
  1074. localCache = inst[space.cache] || space.to && space.to(inst._rgba) || [];
  1075. each(space.props, function(_2, prop) {
  1076. if (isCache[prop.idx] != null) {
  1077. same = isCache[prop.idx] === localCache[prop.idx];
  1078. return same;
  1079. }
  1080. });
  1081. }
  1082. return same;
  1083. });
  1084. return same;
  1085. },
  1086. _space: function() {
  1087. var used = [], inst = this;
  1088. each(spaces, function(spaceName, space) {
  1089. if (inst[space.cache]) {
  1090. used.push(spaceName);
  1091. }
  1092. });
  1093. return used.pop();
  1094. },
  1095. transition: function(other, distance) {
  1096. var end = color(other), spaceName = end._space(), space = spaces[spaceName], startColor = this.alpha() === 0 ? color("transparent") : this, start = startColor[space.cache] || space.to(startColor._rgba), result = start.slice();
  1097. end = end[space.cache];
  1098. each(space.props, function(_key, prop) {
  1099. var index = prop.idx, startValue = start[index], endValue = end[index], type = propTypes[prop.type] || {};
  1100. if (endValue === null) {
  1101. return;
  1102. }
  1103. if (startValue === null) {
  1104. result[index] = endValue;
  1105. } else {
  1106. if (type.mod) {
  1107. if (endValue - startValue > type.mod / 2) {
  1108. startValue += type.mod;
  1109. } else if (startValue - endValue > type.mod / 2) {
  1110. startValue -= type.mod;
  1111. }
  1112. }
  1113. result[index] = clamp((endValue - startValue) * distance + startValue, prop);
  1114. }
  1115. });
  1116. return this[spaceName](result);
  1117. },
  1118. blend: function(opaque) {
  1119. if (this._rgba[3] === 1) {
  1120. return this;
  1121. }
  1122. var rgb = this._rgba.slice(), a = rgb.pop(), blend = color(opaque)._rgba;
  1123. return color(jQuery2.map(rgb, function(v, i) {
  1124. return (1 - a) * blend[i] + a * v;
  1125. }));
  1126. },
  1127. toRgbaString: function() {
  1128. var prefix = "rgba(", rgba = jQuery2.map(this._rgba, function(v, i) {
  1129. if (v != null) {
  1130. return v;
  1131. }
  1132. return i > 2 ? 1 : 0;
  1133. });
  1134. if (rgba[3] === 1) {
  1135. rgba.pop();
  1136. prefix = "rgb(";
  1137. }
  1138. return prefix + rgba.join(", ") + ")";
  1139. },
  1140. toHslaString: function() {
  1141. var prefix = "hsla(", hsla = jQuery2.map(this.hsla(), function(v, i) {
  1142. if (v == null) {
  1143. v = i > 2 ? 1 : 0;
  1144. }
  1145. if (i && i < 3) {
  1146. v = Math.round(v * 100) + "%";
  1147. }
  1148. return v;
  1149. });
  1150. if (hsla[3] === 1) {
  1151. hsla.pop();
  1152. prefix = "hsl(";
  1153. }
  1154. return prefix + hsla.join(", ") + ")";
  1155. },
  1156. toHexString: function(includeAlpha) {
  1157. var rgba = this._rgba.slice(), alpha = rgba.pop();
  1158. if (includeAlpha) {
  1159. rgba.push(~~(alpha * 255));
  1160. }
  1161. return "#" + jQuery2.map(rgba, function(v) {
  1162. return ("0" + (v || 0).toString(16)).substr(-2);
  1163. }).join("");
  1164. },
  1165. toString: function() {
  1166. return this.toRgbaString();
  1167. }
  1168. });
  1169. color.fn.parse.prototype = color.fn;
  1170. function hue2rgb(p, q, h) {
  1171. h = (h + 1) % 1;
  1172. if (h * 6 < 1) {
  1173. return p + (q - p) * h * 6;
  1174. }
  1175. if (h * 2 < 1) {
  1176. return q;
  1177. }
  1178. if (h * 3 < 2) {
  1179. return p + (q - p) * (2 / 3 - h) * 6;
  1180. }
  1181. return p;
  1182. }
  1183. spaces.hsla.to = function(rgba) {
  1184. if (rgba[0] == null || rgba[1] == null || rgba[2] == null) {
  1185. return [null, null, null, rgba[3]];
  1186. }
  1187. var r = rgba[0] / 255, g = rgba[1] / 255, b = rgba[2] / 255, a = rgba[3], max = Math.max(r, g, b), min = Math.min(r, g, b), diff = max - min, add = max + min, l = add * 0.5, h, s;
  1188. if (min === max) {
  1189. h = 0;
  1190. } else if (r === max) {
  1191. h = 60 * (g - b) / diff + 360;
  1192. } else if (g === max) {
  1193. h = 60 * (b - r) / diff + 120;
  1194. } else {
  1195. h = 60 * (r - g) / diff + 240;
  1196. }
  1197. if (diff === 0) {
  1198. s = 0;
  1199. } else if (l <= 0.5) {
  1200. s = diff / add;
  1201. } else {
  1202. s = diff / (2 - add);
  1203. }
  1204. return [Math.round(h) % 360, s, l, a == null ? 1 : a];
  1205. };
  1206. spaces.hsla.from = function(hsla) {
  1207. if (hsla[0] == null || hsla[1] == null || hsla[2] == null) {
  1208. return [null, null, null, hsla[3]];
  1209. }
  1210. var h = hsla[0] / 360, s = hsla[1], l = hsla[2], a = hsla[3], q = l <= 0.5 ? l * (1 + s) : l + s - l * s, p = 2 * l - q;
  1211. return [
  1212. Math.round(hue2rgb(p, q, h + 1 / 3) * 255),
  1213. Math.round(hue2rgb(p, q, h) * 255),
  1214. Math.round(hue2rgb(p, q, h - 1 / 3) * 255),
  1215. a
  1216. ];
  1217. };
  1218. each(spaces, function(spaceName, space) {
  1219. var props = space.props, cache = space.cache, to = space.to, from = space.from;
  1220. color.fn[spaceName] = function(value) {
  1221. if (to && !this[cache]) {
  1222. this[cache] = to(this._rgba);
  1223. }
  1224. if (value === void 0) {
  1225. return this[cache].slice();
  1226. }
  1227. var ret, type = getType(value), arr = type === "array" || type === "object" ? value : arguments, local = this[cache].slice();
  1228. each(props, function(key, prop) {
  1229. var val = arr[type === "object" ? key : prop.idx];
  1230. if (val == null) {
  1231. val = local[prop.idx];
  1232. }
  1233. local[prop.idx] = clamp(val, prop);
  1234. });
  1235. if (from) {
  1236. ret = color(from(local));
  1237. ret[cache] = local;
  1238. return ret;
  1239. } else {
  1240. return color(local);
  1241. }
  1242. };
  1243. each(props, function(key, prop) {
  1244. if (color.fn[key]) {
  1245. return;
  1246. }
  1247. color.fn[key] = function(value) {
  1248. var local, cur, match, fn, vtype = getType(value);
  1249. if (key === "alpha") {
  1250. fn = this._hsla ? "hsla" : "rgba";
  1251. } else {
  1252. fn = spaceName;
  1253. }
  1254. local = this[fn]();
  1255. cur = local[prop.idx];
  1256. if (vtype === "undefined") {
  1257. return cur;
  1258. }
  1259. if (vtype === "function") {
  1260. value = value.call(this, cur);
  1261. vtype = getType(value);
  1262. }
  1263. if (value == null && prop.empty) {
  1264. return this;
  1265. }
  1266. if (vtype === "string") {
  1267. match = rplusequals.exec(value);
  1268. if (match) {
  1269. value = cur + parseFloat(match[2]) * (match[1] === "+" ? 1 : -1);
  1270. }
  1271. }
  1272. local[prop.idx] = value;
  1273. return this[fn](local);
  1274. };
  1275. });
  1276. });
  1277. color.hook = function(hook) {
  1278. var hooks = hook.split(" ");
  1279. each(hooks, function(_i, hook2) {
  1280. jQuery2.cssHooks[hook2] = {
  1281. set: function(elem, value) {
  1282. var parsed;
  1283. if (value !== "transparent" && (getType(value) !== "string" || (parsed = stringParse(value)))) {
  1284. value = color(parsed || value);
  1285. value = value.toRgbaString();
  1286. }
  1287. elem.style[hook2] = value;
  1288. }
  1289. };
  1290. jQuery2.fx.step[hook2] = function(fx) {
  1291. if (!fx.colorInit) {
  1292. fx.start = color(fx.elem, hook2);
  1293. fx.end = color(fx.end);
  1294. fx.colorInit = true;
  1295. }
  1296. jQuery2.cssHooks[hook2].set(fx.elem, fx.start.transition(fx.end, fx.pos));
  1297. };
  1298. });
  1299. };
  1300. color.hook(stepHooks);
  1301. jQuery2.cssHooks.borderColor = {
  1302. expand: function(value) {
  1303. var expanded = {};
  1304. each(["Top", "Right", "Bottom", "Left"], function(_i, part) {
  1305. expanded["border" + part + "Color"] = value;
  1306. });
  1307. return expanded;
  1308. }
  1309. };
  1310. colors = jQuery2.Color.names = {
  1311. // 4.1. Basic color keywords
  1312. aqua: "#00ffff",
  1313. black: "#000000",
  1314. blue: "#0000ff",
  1315. fuchsia: "#ff00ff",
  1316. gray: "#808080",
  1317. green: "#008000",
  1318. lime: "#00ff00",
  1319. maroon: "#800000",
  1320. navy: "#000080",
  1321. olive: "#808000",
  1322. purple: "#800080",
  1323. red: "#ff0000",
  1324. silver: "#c0c0c0",
  1325. teal: "#008080",
  1326. white: "#ffffff",
  1327. yellow: "#ffff00",
  1328. // 4.2.3. "transparent" color keyword
  1329. transparent: [null, null, null, 0],
  1330. _default: "#ffffff"
  1331. };
  1332. var dataSpace = "ui-effects-", dataSpaceStyle = "ui-effects-style", dataSpaceAnimated = "ui-effects-animated";
  1333. $.effects = {
  1334. effect: {}
  1335. };
  1336. (function() {
  1337. var classAnimationActions = ["add", "remove", "toggle"], shorthandStyles = {
  1338. border: 1,
  1339. borderBottom: 1,
  1340. borderColor: 1,
  1341. borderLeft: 1,
  1342. borderRight: 1,
  1343. borderTop: 1,
  1344. borderWidth: 1,
  1345. margin: 1,
  1346. padding: 1
  1347. };
  1348. $.each(
  1349. ["borderLeftStyle", "borderRightStyle", "borderBottomStyle", "borderTopStyle"],
  1350. function(_, prop) {
  1351. $.fx.step[prop] = function(fx) {
  1352. if (fx.end !== "none" && !fx.setAttr || fx.pos === 1 && !fx.setAttr) {
  1353. jQuery2.style(fx.elem, prop, fx.end);
  1354. fx.setAttr = true;
  1355. }
  1356. };
  1357. }
  1358. );
  1359. function camelCase(string) {
  1360. return string.replace(/-([\da-z])/gi, function(all, letter) {
  1361. return letter.toUpperCase();
  1362. });
  1363. }
  1364. function getElementStyles(elem) {
  1365. var key, len, style = elem.ownerDocument.defaultView.getComputedStyle(elem), styles = {};
  1366. len = style.length;
  1367. while (len--) {
  1368. key = style[len];
  1369. if (typeof style[key] === "string") {
  1370. styles[camelCase(key)] = style[key];
  1371. }
  1372. }
  1373. return styles;
  1374. }
  1375. function styleDifference(oldStyle, newStyle) {
  1376. var diff = {}, name, value;
  1377. for (name in newStyle) {
  1378. value = newStyle[name];
  1379. if (oldStyle[name] !== value) {
  1380. if (!shorthandStyles[name]) {
  1381. if ($.fx.step[name] || !isNaN(parseFloat(value))) {
  1382. diff[name] = value;
  1383. }
  1384. }
  1385. }
  1386. }
  1387. return diff;
  1388. }
  1389. $.effects.animateClass = function(value, duration, easing, callback) {
  1390. var o = $.speed(duration, easing, callback);
  1391. return this.queue(function() {
  1392. var animated = $(this), baseClass = animated.attr("class") || "", applyClassChange, allAnimations = o.children ? animated.find("*").addBack() : animated;
  1393. allAnimations = allAnimations.map(function() {
  1394. var el = $(this);
  1395. return {
  1396. el,
  1397. start: getElementStyles(this)
  1398. };
  1399. });
  1400. applyClassChange = function() {
  1401. $.each(classAnimationActions, function(i, action) {
  1402. if (value[action]) {
  1403. animated[action + "Class"](value[action]);
  1404. }
  1405. });
  1406. };
  1407. applyClassChange();
  1408. allAnimations = allAnimations.map(function() {
  1409. this.end = getElementStyles(this.el[0]);
  1410. this.diff = styleDifference(this.start, this.end);
  1411. return this;
  1412. });
  1413. animated.attr("class", baseClass);
  1414. allAnimations = allAnimations.map(function() {
  1415. var styleInfo = this, dfd = $.Deferred(), opts = $.extend({}, o, {
  1416. queue: false,
  1417. complete: function() {
  1418. dfd.resolve(styleInfo);
  1419. }
  1420. });
  1421. this.el.animate(this.diff, opts);
  1422. return dfd.promise();
  1423. });
  1424. $.when.apply($, allAnimations.get()).done(function() {
  1425. applyClassChange();
  1426. $.each(arguments, function() {
  1427. var el = this.el;
  1428. $.each(this.diff, function(key) {
  1429. el.css(key, "");
  1430. });
  1431. });
  1432. o.complete.call(animated[0]);
  1433. });
  1434. });
  1435. };
  1436. $.fn.extend({
  1437. addClass: function(orig) {
  1438. return function(classNames, speed, easing, callback) {
  1439. return speed ? $.effects.animateClass.call(
  1440. this,
  1441. { add: classNames },
  1442. speed,
  1443. easing,
  1444. callback
  1445. ) : orig.apply(this, arguments);
  1446. };
  1447. }($.fn.addClass),
  1448. removeClass: function(orig) {
  1449. return function(classNames, speed, easing, callback) {
  1450. return arguments.length > 1 ? $.effects.animateClass.call(
  1451. this,
  1452. { remove: classNames },
  1453. speed,
  1454. easing,
  1455. callback
  1456. ) : orig.apply(this, arguments);
  1457. };
  1458. }($.fn.removeClass),
  1459. toggleClass: function(orig) {
  1460. return function(classNames, force, speed, easing, callback) {
  1461. if (typeof force === "boolean" || force === void 0) {
  1462. if (!speed) {
  1463. return orig.apply(this, arguments);
  1464. } else {
  1465. return $.effects.animateClass.call(
  1466. this,
  1467. force ? { add: classNames } : { remove: classNames },
  1468. speed,
  1469. easing,
  1470. callback
  1471. );
  1472. }
  1473. } else {
  1474. return $.effects.animateClass.call(
  1475. this,
  1476. { toggle: classNames },
  1477. force,
  1478. speed,
  1479. easing
  1480. );
  1481. }
  1482. };
  1483. }($.fn.toggleClass),
  1484. switchClass: function(remove, add, speed, easing, callback) {
  1485. return $.effects.animateClass.call(this, {
  1486. add,
  1487. remove
  1488. }, speed, easing, callback);
  1489. }
  1490. });
  1491. })();
  1492. (function() {
  1493. if ($.expr && $.expr.pseudos && $.expr.pseudos.animated) {
  1494. $.expr.pseudos.animated = function(orig) {
  1495. return function(elem) {
  1496. return !!$(elem).data(dataSpaceAnimated) || orig(elem);
  1497. };
  1498. }($.expr.pseudos.animated);
  1499. }
  1500. if ($.uiBackCompat === true) {
  1501. $.extend($.effects, {
  1502. // Saves a set of properties in a data storage
  1503. save: function(element, set) {
  1504. var i = 0, length = set.length;
  1505. for (; i < length; i++) {
  1506. if (set[i] !== null) {
  1507. element.data(dataSpace + set[i], element[0].style[set[i]]);
  1508. }
  1509. }
  1510. },
  1511. // Restores a set of previously saved properties from a data storage
  1512. restore: function(element, set) {
  1513. var val, i = 0, length = set.length;
  1514. for (; i < length; i++) {
  1515. if (set[i] !== null) {
  1516. val = element.data(dataSpace + set[i]);
  1517. element.css(set[i], val);
  1518. }
  1519. }
  1520. },
  1521. setMode: function(el, mode) {
  1522. if (mode === "toggle") {
  1523. mode = el.is(":hidden") ? "show" : "hide";
  1524. }
  1525. return mode;
  1526. },
  1527. // Wraps the element around a wrapper that copies position properties
  1528. createWrapper: function(element) {
  1529. if (element.parent().is(".ui-effects-wrapper")) {
  1530. return element.parent();
  1531. }
  1532. var props = {
  1533. width: element.outerWidth(true),
  1534. height: element.outerHeight(true),
  1535. "float": element.css("float")
  1536. }, wrapper = $("<div></div>").addClass("ui-effects-wrapper").css({
  1537. fontSize: "100%",
  1538. background: "transparent",
  1539. border: "none",
  1540. margin: 0,
  1541. padding: 0
  1542. }), size = {
  1543. width: element.width(),
  1544. height: element.height()
  1545. }, active = document.activeElement;
  1546. try {
  1547. active.id;
  1548. } catch (e) {
  1549. active = document.body;
  1550. }
  1551. element.wrap(wrapper);
  1552. if (element[0] === active || $.contains(element[0], active)) {
  1553. $(active).trigger("focus");
  1554. }
  1555. wrapper = element.parent();
  1556. if (element.css("position") === "static") {
  1557. wrapper.css({ position: "relative" });
  1558. element.css({ position: "relative" });
  1559. } else {
  1560. $.extend(props, {
  1561. position: element.css("position"),
  1562. zIndex: element.css("z-index")
  1563. });
  1564. $.each(["top", "left", "bottom", "right"], function(i, pos) {
  1565. props[pos] = element.css(pos);
  1566. if (isNaN(parseInt(props[pos], 10))) {
  1567. props[pos] = "auto";
  1568. }
  1569. });
  1570. element.css({
  1571. position: "relative",
  1572. top: 0,
  1573. left: 0,
  1574. right: "auto",
  1575. bottom: "auto"
  1576. });
  1577. }
  1578. element.css(size);
  1579. return wrapper.css(props).show();
  1580. },
  1581. removeWrapper: function(element) {
  1582. var active = document.activeElement;
  1583. if (element.parent().is(".ui-effects-wrapper")) {
  1584. element.parent().replaceWith(element);
  1585. if (element[0] === active || $.contains(element[0], active)) {
  1586. $(active).trigger("focus");
  1587. }
  1588. }
  1589. return element;
  1590. }
  1591. });
  1592. }
  1593. $.extend($.effects, {
  1594. version: "1.14.1",
  1595. define: function(name, mode, effect2) {
  1596. if (!effect2) {
  1597. effect2 = mode;
  1598. mode = "effect";
  1599. }
  1600. $.effects.effect[name] = effect2;
  1601. $.effects.effect[name].mode = mode;
  1602. return effect2;
  1603. },
  1604. scaledDimensions: function(element, percent, direction) {
  1605. if (percent === 0) {
  1606. return {
  1607. height: 0,
  1608. width: 0,
  1609. outerHeight: 0,
  1610. outerWidth: 0
  1611. };
  1612. }
  1613. var x = direction !== "horizontal" ? (percent || 100) / 100 : 1, y = direction !== "vertical" ? (percent || 100) / 100 : 1;
  1614. return {
  1615. height: element.height() * y,
  1616. width: element.width() * x,
  1617. outerHeight: element.outerHeight() * y,
  1618. outerWidth: element.outerWidth() * x
  1619. };
  1620. },
  1621. clipToBox: function(animation) {
  1622. return {
  1623. width: animation.clip.right - animation.clip.left,
  1624. height: animation.clip.bottom - animation.clip.top,
  1625. left: animation.clip.left,
  1626. top: animation.clip.top
  1627. };
  1628. },
  1629. // Injects recently queued functions to be first in line (after "inprogress")
  1630. unshift: function(element, queueLength, count) {
  1631. var queue = element.queue();
  1632. if (queueLength > 1) {
  1633. queue.splice.apply(
  1634. queue,
  1635. [1, 0].concat(queue.splice(queueLength, count))
  1636. );
  1637. }
  1638. element.dequeue();
  1639. },
  1640. saveStyle: function(element) {
  1641. element.data(dataSpaceStyle, element[0].style.cssText);
  1642. },
  1643. restoreStyle: function(element) {
  1644. element[0].style.cssText = element.data(dataSpaceStyle) || "";
  1645. element.removeData(dataSpaceStyle);
  1646. },
  1647. mode: function(element, mode) {
  1648. var hidden = element.is(":hidden");
  1649. if (mode === "toggle") {
  1650. mode = hidden ? "show" : "hide";
  1651. }
  1652. if (hidden ? mode === "hide" : mode === "show") {
  1653. mode = "none";
  1654. }
  1655. return mode;
  1656. },
  1657. // Translates a [top,left] array into a baseline value
  1658. getBaseline: function(origin, original) {
  1659. var y, x;
  1660. switch (origin[0]) {
  1661. case "top":
  1662. y = 0;
  1663. break;
  1664. case "middle":
  1665. y = 0.5;
  1666. break;
  1667. case "bottom":
  1668. y = 1;
  1669. break;
  1670. default:
  1671. y = origin[0] / original.height;
  1672. }
  1673. switch (origin[1]) {
  1674. case "left":
  1675. x = 0;
  1676. break;
  1677. case "center":
  1678. x = 0.5;
  1679. break;
  1680. case "right":
  1681. x = 1;
  1682. break;
  1683. default:
  1684. x = origin[1] / original.width;
  1685. }
  1686. return {
  1687. x,
  1688. y
  1689. };
  1690. },
  1691. // Creates a placeholder element so that the original element can be made absolute
  1692. createPlaceholder: function(element) {
  1693. var placeholder, cssPosition = element.css("position"), position2 = element.position();
  1694. element.css({
  1695. marginTop: element.css("marginTop"),
  1696. marginBottom: element.css("marginBottom"),
  1697. marginLeft: element.css("marginLeft"),
  1698. marginRight: element.css("marginRight")
  1699. }).outerWidth(element.outerWidth()).outerHeight(element.outerHeight());
  1700. if (/^(static|relative)/.test(cssPosition)) {
  1701. cssPosition = "absolute";
  1702. placeholder = $("<" + element[0].nodeName + ">").insertAfter(element).css({
  1703. // Convert inline to inline block to account for inline elements
  1704. // that turn to inline block based on content (like img)
  1705. display: /^(inline|ruby)/.test(element.css("display")) ? "inline-block" : "block",
  1706. visibility: "hidden",
  1707. // Margins need to be set to account for margin collapse
  1708. marginTop: element.css("marginTop"),
  1709. marginBottom: element.css("marginBottom"),
  1710. marginLeft: element.css("marginLeft"),
  1711. marginRight: element.css("marginRight"),
  1712. "float": element.css("float")
  1713. }).outerWidth(element.outerWidth()).outerHeight(element.outerHeight()).addClass("ui-effects-placeholder");
  1714. element.data(dataSpace + "placeholder", placeholder);
  1715. }
  1716. element.css({
  1717. position: cssPosition,
  1718. left: position2.left,
  1719. top: position2.top
  1720. });
  1721. return placeholder;
  1722. },
  1723. removePlaceholder: function(element) {
  1724. var dataKey = dataSpace + "placeholder", placeholder = element.data(dataKey);
  1725. if (placeholder) {
  1726. placeholder.remove();
  1727. element.removeData(dataKey);
  1728. }
  1729. },
  1730. // Removes a placeholder if it exists and restores
  1731. // properties that were modified during placeholder creation
  1732. cleanUp: function(element) {
  1733. $.effects.restoreStyle(element);
  1734. $.effects.removePlaceholder(element);
  1735. },
  1736. setTransition: function(element, list, factor, value) {
  1737. value = value || {};
  1738. $.each(list, function(i, x) {
  1739. var unit = element.cssUnit(x);
  1740. if (unit[0] > 0) {
  1741. value[x] = unit[0] * factor + unit[1];
  1742. }
  1743. });
  1744. return value;
  1745. }
  1746. });
  1747. function _normalizeArguments(effect2, options, speed, callback) {
  1748. if ($.isPlainObject(effect2)) {
  1749. options = effect2;
  1750. effect2 = effect2.effect;
  1751. }
  1752. effect2 = { effect: effect2 };
  1753. if (options == null) {
  1754. options = {};
  1755. }
  1756. if (typeof options === "function") {
  1757. callback = options;
  1758. speed = null;
  1759. options = {};
  1760. }
  1761. if (typeof options === "number" || $.fx.speeds[options]) {
  1762. callback = speed;
  1763. speed = options;
  1764. options = {};
  1765. }
  1766. if (typeof speed === "function") {
  1767. callback = speed;
  1768. speed = null;
  1769. }
  1770. if (options) {
  1771. $.extend(effect2, options);
  1772. }
  1773. speed = speed || options.duration;
  1774. effect2.duration = $.fx.off ? 0 : typeof speed === "number" ? speed : speed in $.fx.speeds ? $.fx.speeds[speed] : $.fx.speeds._default;
  1775. effect2.complete = callback || options.complete;
  1776. return effect2;
  1777. }
  1778. function standardAnimationOption(option) {
  1779. if (!option || typeof option === "number" || $.fx.speeds[option]) {
  1780. return true;
  1781. }
  1782. if (typeof option === "string" && !$.effects.effect[option]) {
  1783. return true;
  1784. }
  1785. if (typeof option === "function") {
  1786. return true;
  1787. }
  1788. if (typeof option === "object" && !option.effect) {
  1789. return true;
  1790. }
  1791. return false;
  1792. }
  1793. $.fn.extend({
  1794. effect: function() {
  1795. var args = _normalizeArguments.apply(this, arguments), effectMethod = $.effects.effect[args.effect], defaultMode = effectMethod.mode, queue = args.queue, queueName = queue || "fx", complete = args.complete, mode = args.mode, modes = [], prefilter = function(next) {
  1796. var el = $(this), normalizedMode = $.effects.mode(el, mode) || defaultMode;
  1797. el.data(dataSpaceAnimated, true);
  1798. modes.push(normalizedMode);
  1799. if (defaultMode && (normalizedMode === "show" || normalizedMode === defaultMode && normalizedMode === "hide")) {
  1800. el.show();
  1801. }
  1802. if (!defaultMode || normalizedMode !== "none") {
  1803. $.effects.saveStyle(el);
  1804. }
  1805. if (typeof next === "function") {
  1806. next();
  1807. }
  1808. };
  1809. if ($.fx.off || !effectMethod) {
  1810. if (mode) {
  1811. return this[mode](args.duration, complete);
  1812. } else {
  1813. return this.each(function() {
  1814. if (complete) {
  1815. complete.call(this);
  1816. }
  1817. });
  1818. }
  1819. }
  1820. function run(next) {
  1821. var elem = $(this);
  1822. function cleanup() {
  1823. elem.removeData(dataSpaceAnimated);
  1824. $.effects.cleanUp(elem);
  1825. if (args.mode === "hide") {
  1826. elem.hide();
  1827. }
  1828. done();
  1829. }
  1830. function done() {
  1831. if (typeof complete === "function") {
  1832. complete.call(elem[0]);
  1833. }
  1834. if (typeof next === "function") {
  1835. next();
  1836. }
  1837. }
  1838. args.mode = modes.shift();
  1839. if ($.uiBackCompat === true && !defaultMode) {
  1840. if (elem.is(":hidden") ? mode === "hide" : mode === "show") {
  1841. elem[mode]();
  1842. done();
  1843. } else {
  1844. effectMethod.call(elem[0], args, done);
  1845. }
  1846. } else {
  1847. if (args.mode === "none") {
  1848. elem[mode]();
  1849. done();
  1850. } else {
  1851. effectMethod.call(elem[0], args, cleanup);
  1852. }
  1853. }
  1854. }
  1855. return queue === false ? this.each(prefilter).each(run) : this.queue(queueName, prefilter).queue(queueName, run);
  1856. },
  1857. show: function(orig) {
  1858. return function(option) {
  1859. if (standardAnimationOption(option)) {
  1860. return orig.apply(this, arguments);
  1861. } else {
  1862. var args = _normalizeArguments.apply(this, arguments);
  1863. args.mode = "show";
  1864. return this.effect.call(this, args);
  1865. }
  1866. };
  1867. }($.fn.show),
  1868. hide: function(orig) {
  1869. return function(option) {
  1870. if (standardAnimationOption(option)) {
  1871. return orig.apply(this, arguments);
  1872. } else {
  1873. var args = _normalizeArguments.apply(this, arguments);
  1874. args.mode = "hide";
  1875. return this.effect.call(this, args);
  1876. }
  1877. };
  1878. }($.fn.hide),
  1879. toggle: function(orig) {
  1880. return function(option) {
  1881. if (standardAnimationOption(option) || typeof option === "boolean") {
  1882. return orig.apply(this, arguments);
  1883. } else {
  1884. var args = _normalizeArguments.apply(this, arguments);
  1885. args.mode = "toggle";
  1886. return this.effect.call(this, args);
  1887. }
  1888. };
  1889. }($.fn.toggle),
  1890. cssUnit: function(key) {
  1891. var style = this.css(key), val = [];
  1892. $.each(["em", "px", "%", "pt"], function(i, unit) {
  1893. if (style.indexOf(unit) > 0) {
  1894. val = [parseFloat(style), unit];
  1895. }
  1896. });
  1897. return val;
  1898. },
  1899. cssClip: function(clipObj) {
  1900. if (clipObj) {
  1901. return this.css("clip", "rect(" + clipObj.top + "px " + clipObj.right + "px " + clipObj.bottom + "px " + clipObj.left + "px)");
  1902. }
  1903. return parseClip(this.css("clip"), this);
  1904. },
  1905. transfer: function(options, done) {
  1906. var element = $(this), target = $(options.to), targetFixed = target.css("position") === "fixed", body = $("body"), fixTop = targetFixed ? body.scrollTop() : 0, fixLeft = targetFixed ? body.scrollLeft() : 0, endPosition = target.offset(), animation = {
  1907. top: endPosition.top - fixTop,
  1908. left: endPosition.left - fixLeft,
  1909. height: target.innerHeight(),
  1910. width: target.innerWidth()
  1911. }, startPosition = element.offset(), transfer = $("<div class='ui-effects-transfer'></div>");
  1912. transfer.appendTo("body").addClass(options.className).css({
  1913. top: startPosition.top - fixTop,
  1914. left: startPosition.left - fixLeft,
  1915. height: element.innerHeight(),
  1916. width: element.innerWidth(),
  1917. position: targetFixed ? "fixed" : "absolute"
  1918. }).animate(animation, options.duration, options.easing, function() {
  1919. transfer.remove();
  1920. if (typeof done === "function") {
  1921. done();
  1922. }
  1923. });
  1924. }
  1925. });
  1926. function parseClip(str, element) {
  1927. var outerWidth = element.outerWidth(), outerHeight = element.outerHeight(), clipRegex = /^rect\((-?\d*\.?\d*px|-?\d+%|auto),?\s*(-?\d*\.?\d*px|-?\d+%|auto),?\s*(-?\d*\.?\d*px|-?\d+%|auto),?\s*(-?\d*\.?\d*px|-?\d+%|auto)\)$/, values = clipRegex.exec(str) || ["", 0, outerWidth, outerHeight, 0];
  1928. return {
  1929. top: parseFloat(values[1]) || 0,
  1930. right: values[2] === "auto" ? outerWidth : parseFloat(values[2]),
  1931. bottom: values[3] === "auto" ? outerHeight : parseFloat(values[3]),
  1932. left: parseFloat(values[4]) || 0
  1933. };
  1934. }
  1935. $.fx.step.clip = function(fx) {
  1936. if (!fx.clipInit) {
  1937. fx.start = $(fx.elem).cssClip();
  1938. if (typeof fx.end === "string") {
  1939. fx.end = parseClip(fx.end, fx.elem);
  1940. }
  1941. fx.clipInit = true;
  1942. }
  1943. $(fx.elem).cssClip({
  1944. top: fx.pos * (fx.end.top - fx.start.top) + fx.start.top,
  1945. right: fx.pos * (fx.end.right - fx.start.right) + fx.start.right,
  1946. bottom: fx.pos * (fx.end.bottom - fx.start.bottom) + fx.start.bottom,
  1947. left: fx.pos * (fx.end.left - fx.start.left) + fx.start.left
  1948. });
  1949. };
  1950. })();
  1951. (function() {
  1952. var baseEasings = {};
  1953. $.each(["Quad", "Cubic", "Quart", "Quint", "Expo"], function(i, name) {
  1954. baseEasings[name] = function(p) {
  1955. return Math.pow(p, i + 2);
  1956. };
  1957. });
  1958. $.extend(baseEasings, {
  1959. Sine: function(p) {
  1960. return 1 - Math.cos(p * Math.PI / 2);
  1961. },
  1962. Circ: function(p) {
  1963. return 1 - Math.sqrt(1 - p * p);
  1964. },
  1965. Elastic: function(p) {
  1966. return p === 0 || p === 1 ? p : -Math.pow(2, 8 * (p - 1)) * Math.sin(((p - 1) * 80 - 7.5) * Math.PI / 15);
  1967. },
  1968. Back: function(p) {
  1969. return p * p * (3 * p - 2);
  1970. },
  1971. Bounce: function(p) {
  1972. var pow2, bounce = 4;
  1973. while (p < ((pow2 = Math.pow(2, --bounce)) - 1) / 11) {
  1974. }
  1975. return 1 / Math.pow(4, 3 - bounce) - 7.5625 * Math.pow((pow2 * 3 - 2) / 22 - p, 2);
  1976. }
  1977. });
  1978. $.each(baseEasings, function(name, easeIn) {
  1979. $.easing["easeIn" + name] = easeIn;
  1980. $.easing["easeOut" + name] = function(p) {
  1981. return 1 - easeIn(1 - p);
  1982. };
  1983. $.easing["easeInOut" + name] = function(p) {
  1984. return p < 0.5 ? easeIn(p * 2) / 2 : 1 - easeIn(p * -2 + 2) / 2;
  1985. };
  1986. });
  1987. })();
  1988. var effect = $.effects;
  1989. var effectsEffectBlind = $.effects.define("blind", "hide", function(options, done) {
  1990. var map = {
  1991. up: ["bottom", "top"],
  1992. vertical: ["bottom", "top"],
  1993. down: ["top", "bottom"],
  1994. left: ["right", "left"],
  1995. horizontal: ["right", "left"],
  1996. right: ["left", "right"]
  1997. }, element = $(this), direction = options.direction || "up", start = element.cssClip(), animate = { clip: $.extend({}, start) }, placeholder = $.effects.createPlaceholder(element);
  1998. animate.clip[map[direction][0]] = animate.clip[map[direction][1]];
  1999. if (options.mode === "show") {
  2000. element.cssClip(animate.clip);
  2001. if (placeholder) {
  2002. placeholder.css($.effects.clipToBox(animate));
  2003. }
  2004. animate.clip = start;
  2005. }
  2006. if (placeholder) {
  2007. placeholder.animate($.effects.clipToBox(animate), options.duration, options.easing);
  2008. }
  2009. element.animate(animate, {
  2010. queue: false,
  2011. duration: options.duration,
  2012. easing: options.easing,
  2013. complete: done
  2014. });
  2015. });
  2016. var effectsEffectBounce = $.effects.define("bounce", function(options, done) {
  2017. var upAnim, downAnim, refValue, element = $(this), mode = options.mode, hide = mode === "hide", show = mode === "show", direction = options.direction || "up", distance = options.distance, times = options.times || 5, anims = times * 2 + (show || hide ? 1 : 0), speed = options.duration / anims, easing = options.easing, ref = direction === "up" || direction === "down" ? "top" : "left", motion = direction === "up" || direction === "left", i = 0, queuelen = element.queue().length;
  2018. $.effects.createPlaceholder(element);
  2019. refValue = element.css(ref);
  2020. if (!distance) {
  2021. distance = element[ref === "top" ? "outerHeight" : "outerWidth"]() / 3;
  2022. }
  2023. if (show) {
  2024. downAnim = { opacity: 1 };
  2025. downAnim[ref] = refValue;
  2026. element.css("opacity", 0).css(ref, motion ? -distance * 2 : distance * 2).animate(downAnim, speed, easing);
  2027. }
  2028. if (hide) {
  2029. distance = distance / Math.pow(2, times - 1);
  2030. }
  2031. downAnim = {};
  2032. downAnim[ref] = refValue;
  2033. for (; i < times; i++) {
  2034. upAnim = {};
  2035. upAnim[ref] = (motion ? "-=" : "+=") + distance;
  2036. element.animate(upAnim, speed, easing).animate(downAnim, speed, easing);
  2037. distance = hide ? distance * 2 : distance / 2;
  2038. }
  2039. if (hide) {
  2040. upAnim = { opacity: 0 };
  2041. upAnim[ref] = (motion ? "-=" : "+=") + distance;
  2042. element.animate(upAnim, speed, easing);
  2043. }
  2044. element.queue(done);
  2045. $.effects.unshift(element, queuelen, anims + 1);
  2046. });
  2047. var effectsEffectClip = $.effects.define("clip", "hide", function(options, done) {
  2048. var start, animate = {}, element = $(this), direction = options.direction || "vertical", both = direction === "both", horizontal = both || direction === "horizontal", vertical = both || direction === "vertical";
  2049. start = element.cssClip();
  2050. animate.clip = {
  2051. top: vertical ? (start.bottom - start.top) / 2 : start.top,
  2052. right: horizontal ? (start.right - start.left) / 2 : start.right,
  2053. bottom: vertical ? (start.bottom - start.top) / 2 : start.bottom,
  2054. left: horizontal ? (start.right - start.left) / 2 : start.left
  2055. };
  2056. $.effects.createPlaceholder(element);
  2057. if (options.mode === "show") {
  2058. element.cssClip(animate.clip);
  2059. animate.clip = start;
  2060. }
  2061. element.animate(animate, {
  2062. queue: false,
  2063. duration: options.duration,
  2064. easing: options.easing,
  2065. complete: done
  2066. });
  2067. });
  2068. var effectsEffectDrop = $.effects.define("drop", "hide", function(options, done) {
  2069. var distance, element = $(this), mode = options.mode, show = mode === "show", direction = options.direction || "left", ref = direction === "up" || direction === "down" ? "top" : "left", motion = direction === "up" || direction === "left" ? "-=" : "+=", oppositeMotion = motion === "+=" ? "-=" : "+=", animation = {
  2070. opacity: 0
  2071. };
  2072. $.effects.createPlaceholder(element);
  2073. distance = options.distance || element[ref === "top" ? "outerHeight" : "outerWidth"](true) / 2;
  2074. animation[ref] = motion + distance;
  2075. if (show) {
  2076. element.css(animation);
  2077. animation[ref] = oppositeMotion + distance;
  2078. animation.opacity = 1;
  2079. }
  2080. element.animate(animation, {
  2081. queue: false,
  2082. duration: options.duration,
  2083. easing: options.easing,
  2084. complete: done
  2085. });
  2086. });
  2087. var effectsEffectExplode = $.effects.define("explode", "hide", function(options, done) {
  2088. var i, j, left, top, mx, my, rows = options.pieces ? Math.round(Math.sqrt(options.pieces)) : 3, cells = rows, element = $(this), mode = options.mode, show = mode === "show", offset = element.show().css("visibility", "hidden").offset(), width = Math.ceil(element.outerWidth() / cells), height = Math.ceil(element.outerHeight() / rows), pieces = [];
  2089. function childComplete() {
  2090. pieces.push(this);
  2091. if (pieces.length === rows * cells) {
  2092. animComplete();
  2093. }
  2094. }
  2095. for (i = 0; i < rows; i++) {
  2096. top = offset.top + i * height;
  2097. my = i - (rows - 1) / 2;
  2098. for (j = 0; j < cells; j++) {
  2099. left = offset.left + j * width;
  2100. mx = j - (cells - 1) / 2;
  2101. element.clone().appendTo("body").wrap("<div></div>").css({
  2102. position: "absolute",
  2103. visibility: "visible",
  2104. left: -j * width,
  2105. top: -i * height
  2106. }).parent().addClass("ui-effects-explode").css({
  2107. position: "absolute",
  2108. overflow: "hidden",
  2109. width,
  2110. height,
  2111. left: left + (show ? mx * width : 0),
  2112. top: top + (show ? my * height : 0),
  2113. opacity: show ? 0 : 1
  2114. }).animate({
  2115. left: left + (show ? 0 : mx * width),
  2116. top: top + (show ? 0 : my * height),
  2117. opacity: show ? 1 : 0
  2118. }, options.duration || 500, options.easing, childComplete);
  2119. }
  2120. }
  2121. function animComplete() {
  2122. element.css({
  2123. visibility: "visible"
  2124. });
  2125. $(pieces).remove();
  2126. done();
  2127. }
  2128. });
  2129. var effectsEffectFade = $.effects.define("fade", "toggle", function(options, done) {
  2130. var show = options.mode === "show";
  2131. $(this).css("opacity", show ? 0 : 1).animate({
  2132. opacity: show ? 1 : 0
  2133. }, {
  2134. queue: false,
  2135. duration: options.duration,
  2136. easing: options.easing,
  2137. complete: done
  2138. });
  2139. });
  2140. var effectsEffectFold = $.effects.define("fold", "hide", function(options, done) {
  2141. var element = $(this), mode = options.mode, show = mode === "show", hide = mode === "hide", size = options.size || 15, percent = /([0-9]+)%/.exec(size), horizFirst = !!options.horizFirst, ref = horizFirst ? ["right", "bottom"] : ["bottom", "right"], duration = options.duration / 2, placeholder = $.effects.createPlaceholder(element), start = element.cssClip(), animation1 = { clip: $.extend({}, start) }, animation2 = { clip: $.extend({}, start) }, distance = [start[ref[0]], start[ref[1]]], queuelen = element.queue().length;
  2142. if (percent) {
  2143. size = parseInt(percent[1], 10) / 100 * distance[hide ? 0 : 1];
  2144. }
  2145. animation1.clip[ref[0]] = size;
  2146. animation2.clip[ref[0]] = size;
  2147. animation2.clip[ref[1]] = 0;
  2148. if (show) {
  2149. element.cssClip(animation2.clip);
  2150. if (placeholder) {
  2151. placeholder.css($.effects.clipToBox(animation2));
  2152. }
  2153. animation2.clip = start;
  2154. }
  2155. element.queue(function(next) {
  2156. if (placeholder) {
  2157. placeholder.animate($.effects.clipToBox(animation1), duration, options.easing).animate($.effects.clipToBox(animation2), duration, options.easing);
  2158. }
  2159. next();
  2160. }).animate(animation1, duration, options.easing).animate(animation2, duration, options.easing).queue(done);
  2161. $.effects.unshift(element, queuelen, 4);
  2162. });
  2163. var effectsEffectHighlight = $.effects.define("highlight", "show", function(options, done) {
  2164. var element = $(this), animation = {
  2165. backgroundColor: element.css("backgroundColor")
  2166. };
  2167. if (options.mode === "hide") {
  2168. animation.opacity = 0;
  2169. }
  2170. $.effects.saveStyle(element);
  2171. element.css({
  2172. backgroundImage: "none",
  2173. backgroundColor: options.color || "#ffff99"
  2174. }).animate(animation, {
  2175. queue: false,
  2176. duration: options.duration,
  2177. easing: options.easing,
  2178. complete: done
  2179. });
  2180. });
  2181. var effectsEffectSize = $.effects.define("size", function(options, done) {
  2182. var baseline, factor, temp, element = $(this), cProps = ["fontSize"], vProps = ["borderTopWidth", "borderBottomWidth", "paddingTop", "paddingBottom"], hProps = ["borderLeftWidth", "borderRightWidth", "paddingLeft", "paddingRight"], mode = options.mode, restore = mode !== "effect", scale = options.scale || "both", origin = options.origin || ["middle", "center"], position2 = element.css("position"), pos = element.position(), original = $.effects.scaledDimensions(element), from = options.from || original, to = options.to || $.effects.scaledDimensions(element, 0);
  2183. $.effects.createPlaceholder(element);
  2184. if (mode === "show") {
  2185. temp = from;
  2186. from = to;
  2187. to = temp;
  2188. }
  2189. factor = {
  2190. from: {
  2191. y: from.height / original.height,
  2192. x: from.width / original.width
  2193. },
  2194. to: {
  2195. y: to.height / original.height,
  2196. x: to.width / original.width
  2197. }
  2198. };
  2199. if (scale === "box" || scale === "both") {
  2200. if (factor.from.y !== factor.to.y) {
  2201. from = $.effects.setTransition(element, vProps, factor.from.y, from);
  2202. to = $.effects.setTransition(element, vProps, factor.to.y, to);
  2203. }
  2204. if (factor.from.x !== factor.to.x) {
  2205. from = $.effects.setTransition(element, hProps, factor.from.x, from);
  2206. to = $.effects.setTransition(element, hProps, factor.to.x, to);
  2207. }
  2208. }
  2209. if (scale === "content" || scale === "both") {
  2210. if (factor.from.y !== factor.to.y) {
  2211. from = $.effects.setTransition(element, cProps, factor.from.y, from);
  2212. to = $.effects.setTransition(element, cProps, factor.to.y, to);
  2213. }
  2214. }
  2215. if (origin) {
  2216. baseline = $.effects.getBaseline(origin, original);
  2217. from.top = (original.outerHeight - from.outerHeight) * baseline.y + pos.top;
  2218. from.left = (original.outerWidth - from.outerWidth) * baseline.x + pos.left;
  2219. to.top = (original.outerHeight - to.outerHeight) * baseline.y + pos.top;
  2220. to.left = (original.outerWidth - to.outerWidth) * baseline.x + pos.left;
  2221. }
  2222. delete from.outerHeight;
  2223. delete from.outerWidth;
  2224. element.css(from);
  2225. if (scale === "content" || scale === "both") {
  2226. vProps = vProps.concat(["marginTop", "marginBottom"]).concat(cProps);
  2227. hProps = hProps.concat(["marginLeft", "marginRight"]);
  2228. element.find("*[width]").each(function() {
  2229. var child = $(this), childOriginal = $.effects.scaledDimensions(child), childFrom = {
  2230. height: childOriginal.height * factor.from.y,
  2231. width: childOriginal.width * factor.from.x,
  2232. outerHeight: childOriginal.outerHeight * factor.from.y,
  2233. outerWidth: childOriginal.outerWidth * factor.from.x
  2234. }, childTo = {
  2235. height: childOriginal.height * factor.to.y,
  2236. width: childOriginal.width * factor.to.x,
  2237. outerHeight: childOriginal.height * factor.to.y,
  2238. outerWidth: childOriginal.width * factor.to.x
  2239. };
  2240. if (factor.from.y !== factor.to.y) {
  2241. childFrom = $.effects.setTransition(child, vProps, factor.from.y, childFrom);
  2242. childTo = $.effects.setTransition(child, vProps, factor.to.y, childTo);
  2243. }
  2244. if (factor.from.x !== factor.to.x) {
  2245. childFrom = $.effects.setTransition(child, hProps, factor.from.x, childFrom);
  2246. childTo = $.effects.setTransition(child, hProps, factor.to.x, childTo);
  2247. }
  2248. if (restore) {
  2249. $.effects.saveStyle(child);
  2250. }
  2251. child.css(childFrom);
  2252. child.animate(childTo, options.duration, options.easing, function() {
  2253. if (restore) {
  2254. $.effects.restoreStyle(child);
  2255. }
  2256. });
  2257. });
  2258. }
  2259. element.animate(to, {
  2260. queue: false,
  2261. duration: options.duration,
  2262. easing: options.easing,
  2263. complete: function() {
  2264. var offset = element.offset();
  2265. if (to.opacity === 0) {
  2266. element.css("opacity", from.opacity);
  2267. }
  2268. if (!restore) {
  2269. element.css("position", position2 === "static" ? "relative" : position2).offset(offset);
  2270. $.effects.saveStyle(element);
  2271. }
  2272. done();
  2273. }
  2274. });
  2275. });
  2276. var effectsEffectScale = $.effects.define("scale", function(options, done) {
  2277. var el = $(this), mode = options.mode, percent = parseInt(options.percent, 10) || (parseInt(options.percent, 10) === 0 ? 0 : mode !== "effect" ? 0 : 100), newOptions = $.extend(true, {
  2278. from: $.effects.scaledDimensions(el),
  2279. to: $.effects.scaledDimensions(el, percent, options.direction || "both"),
  2280. origin: options.origin || ["middle", "center"]
  2281. }, options);
  2282. if (options.fade) {
  2283. newOptions.from.opacity = 1;
  2284. newOptions.to.opacity = 0;
  2285. }
  2286. $.effects.effect.size.call(this, newOptions, done);
  2287. });
  2288. var effectsEffectPuff = $.effects.define("puff", "hide", function(options, done) {
  2289. var newOptions = $.extend(true, {}, options, {
  2290. fade: true,
  2291. percent: parseInt(options.percent, 10) || 150
  2292. });
  2293. $.effects.effect.scale.call(this, newOptions, done);
  2294. });
  2295. var effectsEffectPulsate = $.effects.define("pulsate", "show", function(options, done) {
  2296. var element = $(this), mode = options.mode, show = mode === "show", hide = mode === "hide", showhide = show || hide, anims = (options.times || 5) * 2 + (showhide ? 1 : 0), duration = options.duration / anims, animateTo = 0, i = 1, queuelen = element.queue().length;
  2297. if (show || !element.is(":visible")) {
  2298. element.css("opacity", 0).show();
  2299. animateTo = 1;
  2300. }
  2301. for (; i < anims; i++) {
  2302. element.animate({ opacity: animateTo }, duration, options.easing);
  2303. animateTo = 1 - animateTo;
  2304. }
  2305. element.animate({ opacity: animateTo }, duration, options.easing);
  2306. element.queue(done);
  2307. $.effects.unshift(element, queuelen, anims + 1);
  2308. });
  2309. var effectsEffectShake = $.effects.define("shake", function(options, done) {
  2310. var i = 1, element = $(this), direction = options.direction || "left", distance = options.distance || 20, times = options.times || 3, anims = times * 2 + 1, speed = Math.round(options.duration / anims), ref = direction === "up" || direction === "down" ? "top" : "left", positiveMotion = direction === "up" || direction === "left", animation = {}, animation1 = {}, animation2 = {}, queuelen = element.queue().length;
  2311. $.effects.createPlaceholder(element);
  2312. animation[ref] = (positiveMotion ? "-=" : "+=") + distance;
  2313. animation1[ref] = (positiveMotion ? "+=" : "-=") + distance * 2;
  2314. animation2[ref] = (positiveMotion ? "-=" : "+=") + distance * 2;
  2315. element.animate(animation, speed, options.easing);
  2316. for (; i < times; i++) {
  2317. element.animate(animation1, speed, options.easing).animate(animation2, speed, options.easing);
  2318. }
  2319. element.animate(animation1, speed, options.easing).animate(animation, speed / 2, options.easing).queue(done);
  2320. $.effects.unshift(element, queuelen, anims + 1);
  2321. });
  2322. var effectsEffectSlide = $.effects.define("slide", "show", function(options, done) {
  2323. var startClip, startRef, element = $(this), map = {
  2324. up: ["bottom", "top"],
  2325. down: ["top", "bottom"],
  2326. left: ["right", "left"],
  2327. right: ["left", "right"]
  2328. }, mode = options.mode, direction = options.direction || "left", ref = direction === "up" || direction === "down" ? "top" : "left", positiveMotion = direction === "up" || direction === "left", distance = options.distance || element[ref === "top" ? "outerHeight" : "outerWidth"](true), animation = {};
  2329. $.effects.createPlaceholder(element);
  2330. startClip = element.cssClip();
  2331. startRef = element.position()[ref];
  2332. animation[ref] = (positiveMotion ? -1 : 1) * distance + startRef;
  2333. animation.clip = element.cssClip();
  2334. animation.clip[map[direction][1]] = animation.clip[map[direction][0]];
  2335. if (mode === "show") {
  2336. element.cssClip(animation.clip);
  2337. element.css(ref, animation[ref]);
  2338. animation.clip = startClip;
  2339. animation[ref] = startRef;
  2340. }
  2341. element.animate(animation, {
  2342. queue: false,
  2343. duration: options.duration,
  2344. easing: options.easing,
  2345. complete: done
  2346. });
  2347. });
  2348. var effect;
  2349. if ($.uiBackCompat === true) {
  2350. effect = $.effects.define("transfer", function(options, done) {
  2351. $(this).transfer(options, done);
  2352. });
  2353. }
  2354. var effectsEffectTransfer = effect;
  2355. $.ui.focusable = function(element, hasTabindex) {
  2356. var map, mapName, img, focusableIfVisible, fieldset, nodeName = element.nodeName.toLowerCase();
  2357. if ("area" === nodeName) {
  2358. map = element.parentNode;
  2359. mapName = map.name;
  2360. if (!element.href || !mapName || map.nodeName.toLowerCase() !== "map") {
  2361. return false;
  2362. }
  2363. img = $("img[usemap='#" + mapName + "']");
  2364. return img.length > 0 && img.is(":visible");
  2365. }
  2366. if (/^(input|select|textarea|button|object)$/.test(nodeName)) {
  2367. focusableIfVisible = !element.disabled;
  2368. if (focusableIfVisible) {
  2369. fieldset = $(element).closest("fieldset")[0];
  2370. if (fieldset) {
  2371. focusableIfVisible = !fieldset.disabled;
  2372. }
  2373. }
  2374. } else if ("a" === nodeName) {
  2375. focusableIfVisible = element.href || hasTabindex;
  2376. } else {
  2377. focusableIfVisible = hasTabindex;
  2378. }
  2379. return focusableIfVisible && $(element).is(":visible") && $(element).css("visibility") === "visible";
  2380. };
  2381. $.extend($.expr.pseudos, {
  2382. focusable: function(element) {
  2383. return $.ui.focusable(element, $.attr(element, "tabindex") != null);
  2384. }
  2385. });
  2386. var focusable = $.ui.focusable;
  2387. var formResetMixin = $.ui.formResetMixin = {
  2388. _formResetHandler: function() {
  2389. var form = $(this);
  2390. setTimeout(function() {
  2391. var instances = form.data("ui-form-reset-instances");
  2392. $.each(instances, function() {
  2393. this.refresh();
  2394. });
  2395. });
  2396. },
  2397. _bindFormResetHandler: function() {
  2398. this.form = $(this.element.prop("form"));
  2399. if (!this.form.length) {
  2400. return;
  2401. }
  2402. var instances = this.form.data("ui-form-reset-instances") || [];
  2403. if (!instances.length) {
  2404. this.form.on("reset.ui-form-reset", this._formResetHandler);
  2405. }
  2406. instances.push(this);
  2407. this.form.data("ui-form-reset-instances", instances);
  2408. },
  2409. _unbindFormResetHandler: function() {
  2410. if (!this.form.length) {
  2411. return;
  2412. }
  2413. var instances = this.form.data("ui-form-reset-instances");
  2414. instances.splice($.inArray(this, instances), 1);
  2415. if (instances.length) {
  2416. this.form.data("ui-form-reset-instances", instances);
  2417. } else {
  2418. this.form.removeData("ui-form-reset-instances").off("reset.ui-form-reset");
  2419. }
  2420. }
  2421. };
  2422. if (!$.escapeSelector) {
  2423. $.escapeSelector = function(id) {
  2424. return CSS.escape(id + "");
  2425. };
  2426. }
  2427. if (!$.fn.even || !$.fn.odd) {
  2428. $.fn.extend({
  2429. even: function() {
  2430. return this.filter(function(i) {
  2431. return i % 2 === 0;
  2432. });
  2433. },
  2434. odd: function() {
  2435. return this.filter(function(i) {
  2436. return i % 2 === 1;
  2437. });
  2438. }
  2439. });
  2440. }
  2441. ;
  2442. var keycode = $.ui.keyCode = {
  2443. BACKSPACE: 8,
  2444. COMMA: 188,
  2445. DELETE: 46,
  2446. DOWN: 40,
  2447. END: 35,
  2448. ENTER: 13,
  2449. ESCAPE: 27,
  2450. HOME: 36,
  2451. LEFT: 37,
  2452. PAGE_DOWN: 34,
  2453. PAGE_UP: 33,
  2454. PERIOD: 190,
  2455. RIGHT: 39,
  2456. SPACE: 32,
  2457. TAB: 9,
  2458. UP: 38
  2459. };
  2460. var labels = $.fn.labels = function() {
  2461. var ancestor, selector, id, labels2, ancestors;
  2462. if (!this.length) {
  2463. return this.pushStack([]);
  2464. }
  2465. if (this[0].labels && this[0].labels.length) {
  2466. return this.pushStack(this[0].labels);
  2467. }
  2468. labels2 = this.eq(0).parents("label");
  2469. id = this.attr("id");
  2470. if (id) {
  2471. ancestor = this.eq(0).parents().last();
  2472. ancestors = ancestor.add(ancestor.length ? ancestor.siblings() : this.siblings());
  2473. selector = "label[for='" + CSS.escape(id) + "']";
  2474. labels2 = labels2.add(ancestors.find(selector).addBack(selector));
  2475. }
  2476. return this.pushStack(labels2);
  2477. };
  2478. var scrollParent = $.fn.scrollParent = function(includeHidden) {
  2479. var position2 = this.css("position"), excludeStaticParent = position2 === "absolute", overflowRegex = includeHidden ? /(auto|scroll|hidden)/ : /(auto|scroll)/, scrollParent2 = this.parents().filter(function() {
  2480. var parent = $(this);
  2481. if (excludeStaticParent && parent.css("position") === "static") {
  2482. return false;
  2483. }
  2484. return overflowRegex.test(parent.css("overflow") + parent.css("overflow-y") + parent.css("overflow-x"));
  2485. }).eq(0);
  2486. return position2 === "fixed" || !scrollParent2.length ? $(this[0].ownerDocument || document) : scrollParent2;
  2487. };
  2488. var tabbable = $.extend($.expr.pseudos, {
  2489. tabbable: function(element) {
  2490. var tabIndex = $.attr(element, "tabindex"), hasTabindex = tabIndex != null;
  2491. return (!hasTabindex || tabIndex >= 0) && $.ui.focusable(element, hasTabindex);
  2492. }
  2493. });
  2494. var uniqueId = $.fn.extend({
  2495. uniqueId: function() {
  2496. var uuid = 0;
  2497. return function() {
  2498. return this.each(function() {
  2499. if (!this.id) {
  2500. this.id = "ui-id-" + ++uuid;
  2501. }
  2502. });
  2503. };
  2504. }(),
  2505. removeUniqueId: function() {
  2506. return this.each(function() {
  2507. if (/^ui-id-\d+$/.test(this.id)) {
  2508. $(this).removeAttr("id");
  2509. }
  2510. });
  2511. }
  2512. });
  2513. var widgetsAccordion = $.widget("ui.accordion", {
  2514. version: "1.14.1",
  2515. options: {
  2516. active: 0,
  2517. animate: {},
  2518. classes: {
  2519. "ui-accordion-header": "ui-corner-top",
  2520. "ui-accordion-header-collapsed": "ui-corner-all",
  2521. "ui-accordion-content": "ui-corner-bottom"
  2522. },
  2523. collapsible: false,
  2524. event: "click",
  2525. header: function(elem) {
  2526. return elem.find("> li > :first-child").add(
  2527. elem.find("> :not(li)").filter(function(i) {
  2528. return i % 2 === 0;
  2529. })
  2530. );
  2531. },
  2532. heightStyle: "auto",
  2533. icons: {
  2534. activeHeader: "ui-icon-triangle-1-s",
  2535. header: "ui-icon-triangle-1-e"
  2536. },
  2537. // Callbacks
  2538. activate: null,
  2539. beforeActivate: null
  2540. },
  2541. hideProps: {
  2542. borderTopWidth: "hide",
  2543. borderBottomWidth: "hide",
  2544. paddingTop: "hide",
  2545. paddingBottom: "hide",
  2546. height: "hide"
  2547. },
  2548. showProps: {
  2549. borderTopWidth: "show",
  2550. borderBottomWidth: "show",
  2551. paddingTop: "show",
  2552. paddingBottom: "show",
  2553. height: "show"
  2554. },
  2555. _create: function() {
  2556. var options = this.options;
  2557. this.prevShow = this.prevHide = $();
  2558. this._addClass("ui-accordion", "ui-widget ui-helper-reset");
  2559. this.element.attr("role", "tablist");
  2560. if (!options.collapsible && (options.active === false || options.active == null)) {
  2561. options.active = 0;
  2562. }
  2563. this._processPanels();
  2564. if (options.active < 0) {
  2565. options.active += this.headers.length;
  2566. }
  2567. this._refresh();
  2568. },
  2569. _getCreateEventData: function() {
  2570. return {
  2571. header: this.active,
  2572. panel: !this.active.length ? $() : this.active.next()
  2573. };
  2574. },
  2575. _createIcons: function() {
  2576. var icon, children, icons = this.options.icons;
  2577. if (icons) {
  2578. icon = $("<span>");
  2579. this._addClass(icon, "ui-accordion-header-icon", "ui-icon " + icons.header);
  2580. icon.prependTo(this.headers);
  2581. children = this.active.children(".ui-accordion-header-icon");
  2582. this._removeClass(children, icons.header)._addClass(children, null, icons.activeHeader)._addClass(this.headers, "ui-accordion-icons");
  2583. }
  2584. },
  2585. _destroyIcons: function() {
  2586. this._removeClass(this.headers, "ui-accordion-icons");
  2587. this.headers.children(".ui-accordion-header-icon").remove();
  2588. },
  2589. _destroy: function() {
  2590. var contents;
  2591. this.element.removeAttr("role");
  2592. this.headers.removeAttr("role aria-expanded aria-selected aria-controls tabIndex").removeUniqueId();
  2593. this._destroyIcons();
  2594. contents = this.headers.next().css("display", "").removeAttr("role aria-hidden aria-labelledby").removeUniqueId();
  2595. if (this.options.heightStyle !== "content") {
  2596. contents.css("height", "");
  2597. }
  2598. },
  2599. _setOption: function(key, value) {
  2600. if (key === "active") {
  2601. this._activate(value);
  2602. return;
  2603. }
  2604. if (key === "event") {
  2605. if (this.options.event) {
  2606. this._off(this.headers, this.options.event);
  2607. }
  2608. this._setupEvents(value);
  2609. }
  2610. this._super(key, value);
  2611. if (key === "collapsible" && !value && this.options.active === false) {
  2612. this._activate(0);
  2613. }
  2614. if (key === "icons") {
  2615. this._destroyIcons();
  2616. if (value) {
  2617. this._createIcons();
  2618. }
  2619. }
  2620. },
  2621. _setOptionDisabled: function(value) {
  2622. this._super(value);
  2623. this.element.attr("aria-disabled", value);
  2624. this._toggleClass(null, "ui-state-disabled", !!value);
  2625. },
  2626. _keydown: function(event) {
  2627. if (event.altKey || event.ctrlKey) {
  2628. return;
  2629. }
  2630. var keyCode = $.ui.keyCode, length = this.headers.length, currentIndex = this.headers.index(event.target), toFocus = false;
  2631. switch (event.keyCode) {
  2632. case keyCode.RIGHT:
  2633. case keyCode.DOWN:
  2634. toFocus = this.headers[(currentIndex + 1) % length];
  2635. break;
  2636. case keyCode.LEFT:
  2637. case keyCode.UP:
  2638. toFocus = this.headers[(currentIndex - 1 + length) % length];
  2639. break;
  2640. case keyCode.SPACE:
  2641. case keyCode.ENTER:
  2642. this._eventHandler(event);
  2643. break;
  2644. case keyCode.HOME:
  2645. toFocus = this.headers[0];
  2646. break;
  2647. case keyCode.END:
  2648. toFocus = this.headers[length - 1];
  2649. break;
  2650. }
  2651. if (toFocus) {
  2652. $(event.target).attr("tabIndex", -1);
  2653. $(toFocus).attr("tabIndex", 0);
  2654. $(toFocus).trigger("focus");
  2655. event.preventDefault();
  2656. }
  2657. },
  2658. _panelKeyDown: function(event) {
  2659. if (event.keyCode === $.ui.keyCode.UP && event.ctrlKey) {
  2660. $(event.currentTarget).prev().trigger("focus");
  2661. }
  2662. },
  2663. refresh: function() {
  2664. var options = this.options;
  2665. this._processPanels();
  2666. if (options.active === false && options.collapsible === true || !this.headers.length) {
  2667. options.active = false;
  2668. this.active = $();
  2669. } else if (options.active === false) {
  2670. this._activate(0);
  2671. } else if (this.active.length && !$.contains(this.element[0], this.active[0])) {
  2672. if (this.headers.length === this.headers.find(".ui-state-disabled").length) {
  2673. options.active = false;
  2674. this.active = $();
  2675. } else {
  2676. this._activate(Math.max(0, options.active - 1));
  2677. }
  2678. } else {
  2679. options.active = this.headers.index(this.active);
  2680. }
  2681. this._destroyIcons();
  2682. this._refresh();
  2683. },
  2684. _processPanels: function() {
  2685. var prevHeaders = this.headers, prevPanels = this.panels;
  2686. if (typeof this.options.header === "function") {
  2687. this.headers = this.options.header(this.element);
  2688. } else {
  2689. this.headers = this.element.find(this.options.header);
  2690. }
  2691. this._addClass(
  2692. this.headers,
  2693. "ui-accordion-header ui-accordion-header-collapsed",
  2694. "ui-state-default"
  2695. );
  2696. this.panels = this.headers.next().filter(":not(.ui-accordion-content-active)").hide();
  2697. this._addClass(this.panels, "ui-accordion-content", "ui-helper-reset ui-widget-content");
  2698. if (prevPanels) {
  2699. this._off(prevHeaders.not(this.headers));
  2700. this._off(prevPanels.not(this.panels));
  2701. }
  2702. },
  2703. _refresh: function() {
  2704. var maxHeight, options = this.options, heightStyle = options.heightStyle, parent = this.element.parent();
  2705. this.active = this._findActive(options.active);
  2706. this._addClass(this.active, "ui-accordion-header-active", "ui-state-active")._removeClass(this.active, "ui-accordion-header-collapsed");
  2707. this._addClass(this.active.next(), "ui-accordion-content-active");
  2708. this.active.next().show();
  2709. this.headers.attr("role", "tab").each(function() {
  2710. var header = $(this), headerId = header.uniqueId().attr("id"), panel = header.next(), panelId = panel.uniqueId().attr("id");
  2711. header.attr("aria-controls", panelId);
  2712. panel.attr("aria-labelledby", headerId);
  2713. }).next().attr("role", "tabpanel");
  2714. this.headers.not(this.active).attr({
  2715. "aria-selected": "false",
  2716. "aria-expanded": "false",
  2717. tabIndex: -1
  2718. }).next().attr({
  2719. "aria-hidden": "true"
  2720. }).hide();
  2721. if (!this.active.length) {
  2722. this.headers.eq(0).attr("tabIndex", 0);
  2723. } else {
  2724. this.active.attr({
  2725. "aria-selected": "true",
  2726. "aria-expanded": "true",
  2727. tabIndex: 0
  2728. }).next().attr({
  2729. "aria-hidden": "false"
  2730. });
  2731. }
  2732. this._createIcons();
  2733. this._setupEvents(options.event);
  2734. if (heightStyle === "fill") {
  2735. maxHeight = parent.height();
  2736. this.element.siblings(":visible").each(function() {
  2737. var elem = $(this), position2 = elem.css("position");
  2738. if (position2 === "absolute" || position2 === "fixed") {
  2739. return;
  2740. }
  2741. maxHeight -= elem.outerHeight(true);
  2742. });
  2743. this.headers.each(function() {
  2744. maxHeight -= $(this).outerHeight(true);
  2745. });
  2746. this.headers.next().each(function() {
  2747. $(this).height(Math.max(0, maxHeight - $(this).innerHeight() + $(this).height()));
  2748. }).css("overflow", "auto");
  2749. } else if (heightStyle === "auto") {
  2750. maxHeight = 0;
  2751. this.headers.next().each(function() {
  2752. var isVisible = $(this).is(":visible");
  2753. if (!isVisible) {
  2754. $(this).show();
  2755. }
  2756. maxHeight = Math.max(maxHeight, $(this).css("height", "").height());
  2757. if (!isVisible) {
  2758. $(this).hide();
  2759. }
  2760. }).height(maxHeight);
  2761. }
  2762. },
  2763. _activate: function(index) {
  2764. var active = this._findActive(index)[0];
  2765. if (active === this.active[0]) {
  2766. return;
  2767. }
  2768. active = active || this.active[0];
  2769. this._eventHandler({
  2770. target: active,
  2771. currentTarget: active,
  2772. preventDefault: $.noop
  2773. });
  2774. },
  2775. _findActive: function(selector) {
  2776. return typeof selector === "number" ? this.headers.eq(selector) : $();
  2777. },
  2778. _setupEvents: function(event) {
  2779. var events = {
  2780. keydown: "_keydown"
  2781. };
  2782. if (event) {
  2783. $.each(event.split(" "), function(index, eventName) {
  2784. events[eventName] = "_eventHandler";
  2785. });
  2786. }
  2787. this._off(this.headers.add(this.headers.next()));
  2788. this._on(this.headers, events);
  2789. this._on(this.headers.next(), { keydown: "_panelKeyDown" });
  2790. this._hoverable(this.headers);
  2791. this._focusable(this.headers);
  2792. },
  2793. _eventHandler: function(event) {
  2794. var activeChildren, clickedChildren, options = this.options, active = this.active, clicked = $(event.currentTarget), clickedIsActive = clicked[0] === active[0], collapsing = clickedIsActive && options.collapsible, toShow = collapsing ? $() : clicked.next(), toHide = active.next(), eventData = {
  2795. oldHeader: active,
  2796. oldPanel: toHide,
  2797. newHeader: collapsing ? $() : clicked,
  2798. newPanel: toShow
  2799. };
  2800. event.preventDefault();
  2801. if (
  2802. // click on active header, but not collapsible
  2803. clickedIsActive && !options.collapsible || // allow canceling activation
  2804. this._trigger("beforeActivate", event, eventData) === false
  2805. ) {
  2806. return;
  2807. }
  2808. options.active = collapsing ? false : this.headers.index(clicked);
  2809. this.active = clickedIsActive ? $() : clicked;
  2810. this._toggle(eventData);
  2811. this._removeClass(active, "ui-accordion-header-active", "ui-state-active");
  2812. if (options.icons) {
  2813. activeChildren = active.children(".ui-accordion-header-icon");
  2814. this._removeClass(activeChildren, null, options.icons.activeHeader)._addClass(activeChildren, null, options.icons.header);
  2815. }
  2816. if (!clickedIsActive) {
  2817. this._removeClass(clicked, "ui-accordion-header-collapsed")._addClass(clicked, "ui-accordion-header-active", "ui-state-active");
  2818. if (options.icons) {
  2819. clickedChildren = clicked.children(".ui-accordion-header-icon");
  2820. this._removeClass(clickedChildren, null, options.icons.header)._addClass(clickedChildren, null, options.icons.activeHeader);
  2821. }
  2822. this._addClass(clicked.next(), "ui-accordion-content-active");
  2823. }
  2824. },
  2825. _toggle: function(data2) {
  2826. var toShow = data2.newPanel, toHide = this.prevShow.length ? this.prevShow : data2.oldPanel;
  2827. this.prevShow.add(this.prevHide).stop(true, true);
  2828. this.prevShow = toShow;
  2829. this.prevHide = toHide;
  2830. if (this.options.animate) {
  2831. this._animate(toShow, toHide, data2);
  2832. } else {
  2833. toHide.hide();
  2834. toShow.show();
  2835. this._toggleComplete(data2);
  2836. }
  2837. toHide.attr({
  2838. "aria-hidden": "true"
  2839. });
  2840. toHide.prev().attr({
  2841. "aria-selected": "false",
  2842. "aria-expanded": "false"
  2843. });
  2844. if (toShow.length && toHide.length) {
  2845. toHide.prev().attr({
  2846. "tabIndex": -1,
  2847. "aria-expanded": "false"
  2848. });
  2849. } else if (toShow.length) {
  2850. this.headers.filter(function() {
  2851. return parseInt($(this).attr("tabIndex"), 10) === 0;
  2852. }).attr("tabIndex", -1);
  2853. }
  2854. toShow.attr("aria-hidden", "false").prev().attr({
  2855. "aria-selected": "true",
  2856. "aria-expanded": "true",
  2857. tabIndex: 0
  2858. });
  2859. },
  2860. _animate: function(toShow, toHide, data2) {
  2861. var total, easing, duration, that = this, adjust = 0, boxSizing = toShow.css("box-sizing"), down = toShow.length && (!toHide.length || toShow.index() < toHide.index()), animate = this.options.animate || {}, options = down && animate.down || animate, complete = function() {
  2862. that._toggleComplete(data2);
  2863. };
  2864. if (typeof options === "number") {
  2865. duration = options;
  2866. }
  2867. if (typeof options === "string") {
  2868. easing = options;
  2869. }
  2870. easing = easing || options.easing || animate.easing;
  2871. duration = duration || options.duration || animate.duration;
  2872. if (!toHide.length) {
  2873. return toShow.animate(this.showProps, duration, easing, complete);
  2874. }
  2875. if (!toShow.length) {
  2876. return toHide.animate(this.hideProps, duration, easing, complete);
  2877. }
  2878. total = toShow.show().outerHeight();
  2879. toHide.animate(this.hideProps, {
  2880. duration,
  2881. easing,
  2882. step: function(now, fx) {
  2883. fx.now = Math.round(now);
  2884. }
  2885. });
  2886. toShow.hide().animate(this.showProps, {
  2887. duration,
  2888. easing,
  2889. complete,
  2890. step: function(now, fx) {
  2891. fx.now = Math.round(now);
  2892. if (fx.prop !== "height") {
  2893. if (boxSizing === "content-box") {
  2894. adjust += fx.now;
  2895. }
  2896. } else if (that.options.heightStyle !== "content") {
  2897. fx.now = Math.round(total - toHide.outerHeight() - adjust);
  2898. adjust = 0;
  2899. }
  2900. }
  2901. });
  2902. },
  2903. _toggleComplete: function(data2) {
  2904. var toHide = data2.oldPanel, prev = toHide.prev();
  2905. this._removeClass(toHide, "ui-accordion-content-active");
  2906. this._removeClass(prev, "ui-accordion-header-active")._addClass(prev, "ui-accordion-header-collapsed");
  2907. this._trigger("activate", null, data2);
  2908. }
  2909. });
  2910. var widgetsMenu = $.widget("ui.menu", {
  2911. version: "1.14.1",
  2912. defaultElement: "<ul>",
  2913. delay: 300,
  2914. options: {
  2915. icons: {
  2916. submenu: "ui-icon-caret-1-e"
  2917. },
  2918. items: "> *",
  2919. menus: "ul",
  2920. position: {
  2921. my: "left top",
  2922. at: "right top"
  2923. },
  2924. role: "menu",
  2925. // Callbacks
  2926. blur: null,
  2927. focus: null,
  2928. select: null
  2929. },
  2930. _create: function() {
  2931. this.activeMenu = this.element;
  2932. this.mouseHandled = false;
  2933. this.lastMousePosition = { x: null, y: null };
  2934. this.element.uniqueId().attr({
  2935. role: this.options.role,
  2936. tabIndex: 0
  2937. });
  2938. this._addClass("ui-menu", "ui-widget ui-widget-content");
  2939. this._on({
  2940. // Prevent focus from sticking to links inside menu after clicking
  2941. // them (focus should always stay on UL during navigation).
  2942. "mousedown .ui-menu-item": function(event) {
  2943. event.preventDefault();
  2944. this._activateItem(event);
  2945. },
  2946. "click .ui-menu-item": function(event) {
  2947. var target = $(event.target);
  2948. var active = $(this.document[0].activeElement);
  2949. if (!this.mouseHandled && target.not(".ui-state-disabled").length) {
  2950. this.select(event);
  2951. if (!event.isPropagationStopped()) {
  2952. this.mouseHandled = true;
  2953. }
  2954. if (target.has(".ui-menu").length) {
  2955. this.expand(event);
  2956. } else if (!this.element.is(":focus") && active.closest(".ui-menu").length) {
  2957. this.element.trigger("focus", [true]);
  2958. if (this.active && this.active.parents(".ui-menu").length === 1) {
  2959. clearTimeout(this.timer);
  2960. }
  2961. }
  2962. }
  2963. },
  2964. "mouseenter .ui-menu-item": "_activateItem",
  2965. "mousemove .ui-menu-item": "_activateItem",
  2966. mouseleave: "collapseAll",
  2967. "mouseleave .ui-menu": "collapseAll",
  2968. focus: function(event, keepActiveItem) {
  2969. var item = this.active || this._menuItems().first();
  2970. if (!keepActiveItem) {
  2971. this.focus(event, item);
  2972. }
  2973. },
  2974. blur: function(event) {
  2975. this._delay(function() {
  2976. var notContained = !$.contains(
  2977. this.element[0],
  2978. this.document[0].activeElement
  2979. );
  2980. if (notContained) {
  2981. this.collapseAll(event);
  2982. }
  2983. });
  2984. },
  2985. keydown: "_keydown"
  2986. });
  2987. this.refresh();
  2988. this._on(this.document, {
  2989. click: function(event) {
  2990. if (this._closeOnDocumentClick(event)) {
  2991. this.collapseAll(event, true);
  2992. }
  2993. this.mouseHandled = false;
  2994. }
  2995. });
  2996. },
  2997. _activateItem: function(event) {
  2998. if (this.previousFilter) {
  2999. return;
  3000. }
  3001. if (event.clientX === this.lastMousePosition.x && event.clientY === this.lastMousePosition.y) {
  3002. return;
  3003. }
  3004. this.lastMousePosition = {
  3005. x: event.clientX,
  3006. y: event.clientY
  3007. };
  3008. var actualTarget = $(event.target).closest(".ui-menu-item"), target = $(event.currentTarget);
  3009. if (actualTarget[0] !== target[0]) {
  3010. return;
  3011. }
  3012. if (target.is(".ui-state-active")) {
  3013. return;
  3014. }
  3015. this._removeClass(
  3016. target.siblings().children(".ui-state-active"),
  3017. null,
  3018. "ui-state-active"
  3019. );
  3020. this.focus(event, target);
  3021. },
  3022. _destroy: function() {
  3023. var items = this.element.find(".ui-menu-item").removeAttr("role aria-disabled"), submenus = items.children(".ui-menu-item-wrapper").removeUniqueId().removeAttr("tabIndex role aria-haspopup");
  3024. this.element.removeAttr("aria-activedescendant").find(".ui-menu").addBack().removeAttr("role aria-labelledby aria-expanded aria-hidden aria-disabled tabIndex").removeUniqueId().show();
  3025. submenus.children().each(function() {
  3026. var elem = $(this);
  3027. if (elem.data("ui-menu-submenu-caret")) {
  3028. elem.remove();
  3029. }
  3030. });
  3031. },
  3032. _keydown: function(event) {
  3033. var match, prev, character, skip, preventDefault = true;
  3034. switch (event.keyCode) {
  3035. case $.ui.keyCode.PAGE_UP:
  3036. this.previousPage(event);
  3037. break;
  3038. case $.ui.keyCode.PAGE_DOWN:
  3039. this.nextPage(event);
  3040. break;
  3041. case $.ui.keyCode.HOME:
  3042. this._move("first", "first", event);
  3043. break;
  3044. case $.ui.keyCode.END:
  3045. this._move("last", "last", event);
  3046. break;
  3047. case $.ui.keyCode.UP:
  3048. this.previous(event);
  3049. break;
  3050. case $.ui.keyCode.DOWN:
  3051. this.next(event);
  3052. break;
  3053. case $.ui.keyCode.LEFT:
  3054. this.collapse(event);
  3055. break;
  3056. case $.ui.keyCode.RIGHT:
  3057. if (this.active && !this.active.is(".ui-state-disabled")) {
  3058. this.expand(event);
  3059. }
  3060. break;
  3061. case $.ui.keyCode.ENTER:
  3062. case $.ui.keyCode.SPACE:
  3063. this._activate(event);
  3064. break;
  3065. case $.ui.keyCode.ESCAPE:
  3066. this.collapse(event);
  3067. break;
  3068. default:
  3069. preventDefault = false;
  3070. prev = this.previousFilter || "";
  3071. skip = false;
  3072. character = event.keyCode >= 96 && event.keyCode <= 105 ? (event.keyCode - 96).toString() : String.fromCharCode(event.keyCode);
  3073. clearTimeout(this.filterTimer);
  3074. if (character === prev) {
  3075. skip = true;
  3076. } else {
  3077. character = prev + character;
  3078. }
  3079. match = this._filterMenuItems(character);
  3080. match = skip && match.index(this.active.next()) !== -1 ? this.active.nextAll(".ui-menu-item") : match;
  3081. if (!match.length) {
  3082. character = String.fromCharCode(event.keyCode);
  3083. match = this._filterMenuItems(character);
  3084. }
  3085. if (match.length) {
  3086. this.focus(event, match);
  3087. this.previousFilter = character;
  3088. this.filterTimer = this._delay(function() {
  3089. delete this.previousFilter;
  3090. }, 1e3);
  3091. } else {
  3092. delete this.previousFilter;
  3093. }
  3094. }
  3095. if (preventDefault) {
  3096. event.preventDefault();
  3097. }
  3098. },
  3099. _activate: function(event) {
  3100. if (this.active && !this.active.is(".ui-state-disabled")) {
  3101. if (this.active.children("[aria-haspopup='true']").length) {
  3102. this.expand(event);
  3103. } else {
  3104. this.select(event);
  3105. }
  3106. }
  3107. },
  3108. refresh: function() {
  3109. var menus, items, newSubmenus, newItems, newWrappers, that = this, icon = this.options.icons.submenu, submenus = this.element.find(this.options.menus);
  3110. this._toggleClass("ui-menu-icons", null, !!this.element.find(".ui-icon").length);
  3111. newSubmenus = submenus.filter(":not(.ui-menu)").hide().attr({
  3112. role: this.options.role,
  3113. "aria-hidden": "true",
  3114. "aria-expanded": "false"
  3115. }).each(function() {
  3116. var menu = $(this), item = menu.prev(), submenuCaret = $("<span>").data("ui-menu-submenu-caret", true);
  3117. that._addClass(submenuCaret, "ui-menu-icon", "ui-icon " + icon);
  3118. item.attr("aria-haspopup", "true").prepend(submenuCaret);
  3119. menu.attr("aria-labelledby", item.attr("id"));
  3120. });
  3121. this._addClass(newSubmenus, "ui-menu", "ui-widget ui-widget-content ui-front");
  3122. menus = submenus.add(this.element);
  3123. items = menus.find(this.options.items);
  3124. items.not(".ui-menu-item").each(function() {
  3125. var item = $(this);
  3126. if (that._isDivider(item)) {
  3127. that._addClass(item, "ui-menu-divider", "ui-widget-content");
  3128. }
  3129. });
  3130. newItems = items.not(".ui-menu-item, .ui-menu-divider");
  3131. newWrappers = newItems.children().not(".ui-menu").uniqueId().attr({
  3132. tabIndex: -1,
  3133. role: this._itemRole()
  3134. });
  3135. this._addClass(newItems, "ui-menu-item")._addClass(newWrappers, "ui-menu-item-wrapper");
  3136. items.filter(".ui-state-disabled").attr("aria-disabled", "true");
  3137. if (this.active && !$.contains(this.element[0], this.active[0])) {
  3138. this.blur();
  3139. }
  3140. },
  3141. _itemRole: function() {
  3142. return {
  3143. menu: "menuitem",
  3144. listbox: "option"
  3145. }[this.options.role];
  3146. },
  3147. _setOption: function(key, value) {
  3148. if (key === "icons") {
  3149. var icons = this.element.find(".ui-menu-icon");
  3150. this._removeClass(icons, null, this.options.icons.submenu)._addClass(icons, null, value.submenu);
  3151. }
  3152. this._super(key, value);
  3153. },
  3154. _setOptionDisabled: function(value) {
  3155. this._super(value);
  3156. this.element.attr("aria-disabled", String(value));
  3157. this._toggleClass(null, "ui-state-disabled", !!value);
  3158. },
  3159. focus: function(event, item) {
  3160. var nested, focused, activeParent;
  3161. this.blur(event, event && event.type === "focus");
  3162. this._scrollIntoView(item);
  3163. this.active = item.first();
  3164. focused = this.active.children(".ui-menu-item-wrapper");
  3165. this._addClass(focused, null, "ui-state-active");
  3166. if (this.options.role) {
  3167. this.element.attr("aria-activedescendant", focused.attr("id"));
  3168. }
  3169. activeParent = this.active.parent().closest(".ui-menu-item").children(".ui-menu-item-wrapper");
  3170. this._addClass(activeParent, null, "ui-state-active");
  3171. if (event && event.type === "keydown") {
  3172. this._close();
  3173. } else {
  3174. this.timer = this._delay(function() {
  3175. this._close();
  3176. }, this.delay);
  3177. }
  3178. nested = item.children(".ui-menu");
  3179. if (nested.length && event && /^mouse/.test(event.type)) {
  3180. this._startOpening(nested);
  3181. }
  3182. this.activeMenu = item.parent();
  3183. this._trigger("focus", event, { item });
  3184. },
  3185. _scrollIntoView: function(item) {
  3186. var borderTop, paddingTop, offset, scroll, elementHeight, itemHeight;
  3187. if (this._hasScroll()) {
  3188. borderTop = parseFloat($.css(this.activeMenu[0], "borderTopWidth")) || 0;
  3189. paddingTop = parseFloat($.css(this.activeMenu[0], "paddingTop")) || 0;
  3190. offset = item.offset().top - this.activeMenu.offset().top - borderTop - paddingTop;
  3191. scroll = this.activeMenu.scrollTop();
  3192. elementHeight = this.activeMenu.height();
  3193. itemHeight = item.outerHeight();
  3194. if (offset < 0) {
  3195. this.activeMenu.scrollTop(scroll + offset);
  3196. } else if (offset + itemHeight > elementHeight) {
  3197. this.activeMenu.scrollTop(scroll + offset - elementHeight + itemHeight);
  3198. }
  3199. }
  3200. },
  3201. blur: function(event, fromFocus) {
  3202. if (!fromFocus) {
  3203. clearTimeout(this.timer);
  3204. }
  3205. if (!this.active) {
  3206. return;
  3207. }
  3208. this._removeClass(
  3209. this.active.children(".ui-menu-item-wrapper"),
  3210. null,
  3211. "ui-state-active"
  3212. );
  3213. this._trigger("blur", event, { item: this.active });
  3214. this.active = null;
  3215. },
  3216. _startOpening: function(submenu) {
  3217. clearTimeout(this.timer);
  3218. if (submenu.attr("aria-hidden") !== "true") {
  3219. return;
  3220. }
  3221. this.timer = this._delay(function() {
  3222. this._close();
  3223. this._open(submenu);
  3224. }, this.delay);
  3225. },
  3226. _open: function(submenu) {
  3227. var position2 = $.extend({
  3228. of: this.active
  3229. }, this.options.position);
  3230. clearTimeout(this.timer);
  3231. this.element.find(".ui-menu").not(submenu.parents(".ui-menu")).hide().attr("aria-hidden", "true");
  3232. submenu.show().removeAttr("aria-hidden").attr("aria-expanded", "true").position(position2);
  3233. },
  3234. collapseAll: function(event, all) {
  3235. clearTimeout(this.timer);
  3236. this.timer = this._delay(function() {
  3237. var currentMenu = all ? this.element : $(event && event.target).closest(this.element.find(".ui-menu"));
  3238. if (!currentMenu.length) {
  3239. currentMenu = this.element;
  3240. }
  3241. this._close(currentMenu);
  3242. this.blur(event);
  3243. this._removeClass(currentMenu.find(".ui-state-active"), null, "ui-state-active");
  3244. this.activeMenu = currentMenu;
  3245. }, all ? 0 : this.delay);
  3246. },
  3247. // With no arguments, closes the currently active menu - if nothing is active
  3248. // it closes all menus. If passed an argument, it will search for menus BELOW
  3249. _close: function(startMenu) {
  3250. if (!startMenu) {
  3251. startMenu = this.active ? this.active.parent() : this.element;
  3252. }
  3253. startMenu.find(".ui-menu").hide().attr("aria-hidden", "true").attr("aria-expanded", "false");
  3254. },
  3255. _closeOnDocumentClick: function(event) {
  3256. return !$(event.target).closest(".ui-menu").length;
  3257. },
  3258. _isDivider: function(item) {
  3259. return !/[^\-\u2014\u2013\s]/.test(item.text());
  3260. },
  3261. collapse: function(event) {
  3262. var newItem = this.active && this.active.parent().closest(".ui-menu-item", this.element);
  3263. if (newItem && newItem.length) {
  3264. this._close();
  3265. this.focus(event, newItem);
  3266. }
  3267. },
  3268. expand: function(event) {
  3269. var newItem = this.active && this._menuItems(this.active.children(".ui-menu")).first();
  3270. if (newItem && newItem.length) {
  3271. this._open(newItem.parent());
  3272. this._delay(function() {
  3273. this.focus(event, newItem);
  3274. });
  3275. }
  3276. },
  3277. next: function(event) {
  3278. this._move("next", "first", event);
  3279. },
  3280. previous: function(event) {
  3281. this._move("prev", "last", event);
  3282. },
  3283. isFirstItem: function() {
  3284. return this.active && !this.active.prevAll(".ui-menu-item").length;
  3285. },
  3286. isLastItem: function() {
  3287. return this.active && !this.active.nextAll(".ui-menu-item").length;
  3288. },
  3289. _menuItems: function(menu) {
  3290. return (menu || this.element).find(this.options.items).filter(".ui-menu-item");
  3291. },
  3292. _move: function(direction, filter, event) {
  3293. var next;
  3294. if (this.active) {
  3295. if (direction === "first" || direction === "last") {
  3296. next = this.active[direction === "first" ? "prevAll" : "nextAll"](".ui-menu-item").last();
  3297. } else {
  3298. next = this.active[direction + "All"](".ui-menu-item").first();
  3299. }
  3300. }
  3301. if (!next || !next.length || !this.active) {
  3302. next = this._menuItems(this.activeMenu)[filter]();
  3303. }
  3304. this.focus(event, next);
  3305. },
  3306. nextPage: function(event) {
  3307. var item, base, height;
  3308. if (!this.active) {
  3309. this.next(event);
  3310. return;
  3311. }
  3312. if (this.isLastItem()) {
  3313. return;
  3314. }
  3315. if (this._hasScroll()) {
  3316. base = this.active.offset().top;
  3317. height = this.element.innerHeight();
  3318. if ($.fn.jquery.indexOf("3.2.") === 0) {
  3319. height += this.element[0].offsetHeight - this.element.outerHeight();
  3320. }
  3321. this.active.nextAll(".ui-menu-item").each(function() {
  3322. item = $(this);
  3323. return item.offset().top - base - height < 0;
  3324. });
  3325. this.focus(event, item);
  3326. } else {
  3327. this.focus(event, this._menuItems(this.activeMenu)[!this.active ? "first" : "last"]());
  3328. }
  3329. },
  3330. previousPage: function(event) {
  3331. var item, base, height;
  3332. if (!this.active) {
  3333. this.next(event);
  3334. return;
  3335. }
  3336. if (this.isFirstItem()) {
  3337. return;
  3338. }
  3339. if (this._hasScroll()) {
  3340. base = this.active.offset().top;
  3341. height = this.element.innerHeight();
  3342. if ($.fn.jquery.indexOf("3.2.") === 0) {
  3343. height += this.element[0].offsetHeight - this.element.outerHeight();
  3344. }
  3345. this.active.prevAll(".ui-menu-item").each(function() {
  3346. item = $(this);
  3347. return item.offset().top - base + height > 0;
  3348. });
  3349. this.focus(event, item);
  3350. } else {
  3351. this.focus(event, this._menuItems(this.activeMenu).first());
  3352. }
  3353. },
  3354. _hasScroll: function() {
  3355. return this.element.outerHeight() < this.element.prop("scrollHeight");
  3356. },
  3357. select: function(event) {
  3358. this.active = this.active || $(event.target).closest(".ui-menu-item");
  3359. var ui = { item: this.active };
  3360. if (!this.active.has(".ui-menu").length) {
  3361. this.collapseAll(event, true);
  3362. }
  3363. this._trigger("select", event, ui);
  3364. },
  3365. _filterMenuItems: function(character) {
  3366. var escapedCharacter = character.replace(/[\-\[\]{}()*+?.,\\\^$|#\s]/g, "\\$&"), regex = new RegExp("^" + escapedCharacter, "i");
  3367. return this.activeMenu.find(this.options.items).filter(".ui-menu-item").filter(function() {
  3368. return regex.test(
  3369. String.prototype.trim.call(
  3370. $(this).children(".ui-menu-item-wrapper").text()
  3371. )
  3372. );
  3373. });
  3374. }
  3375. });
  3376. $.widget("ui.autocomplete", {
  3377. version: "1.14.1",
  3378. defaultElement: "<input>",
  3379. options: {
  3380. appendTo: null,
  3381. autoFocus: false,
  3382. delay: 300,
  3383. minLength: 1,
  3384. position: {
  3385. my: "left top",
  3386. at: "left bottom",
  3387. collision: "none"
  3388. },
  3389. source: null,
  3390. // Callbacks
  3391. change: null,
  3392. close: null,
  3393. focus: null,
  3394. open: null,
  3395. response: null,
  3396. search: null,
  3397. select: null
  3398. },
  3399. requestIndex: 0,
  3400. pending: 0,
  3401. liveRegionTimer: null,
  3402. _create: function() {
  3403. var suppressKeyPress, suppressKeyPressRepeat, suppressInput, nodeName = this.element[0].nodeName.toLowerCase(), isTextarea = nodeName === "textarea", isInput = nodeName === "input";
  3404. this.isMultiLine = isTextarea || !isInput && this.element.prop("contentEditable") === "true";
  3405. this.valueMethod = this.element[isTextarea || isInput ? "val" : "text"];
  3406. this.isNewMenu = true;
  3407. this._addClass("ui-autocomplete-input");
  3408. this.element.attr("autocomplete", "off");
  3409. this._on(this.element, {
  3410. keydown: function(event) {
  3411. if (this.element.prop("readOnly")) {
  3412. suppressKeyPress = true;
  3413. suppressInput = true;
  3414. suppressKeyPressRepeat = true;
  3415. return;
  3416. }
  3417. suppressKeyPress = false;
  3418. suppressInput = false;
  3419. suppressKeyPressRepeat = false;
  3420. var keyCode = $.ui.keyCode;
  3421. switch (event.keyCode) {
  3422. case keyCode.PAGE_UP:
  3423. suppressKeyPress = true;
  3424. this._move("previousPage", event);
  3425. break;
  3426. case keyCode.PAGE_DOWN:
  3427. suppressKeyPress = true;
  3428. this._move("nextPage", event);
  3429. break;
  3430. case keyCode.UP:
  3431. suppressKeyPress = true;
  3432. this._keyEvent("previous", event);
  3433. break;
  3434. case keyCode.DOWN:
  3435. suppressKeyPress = true;
  3436. this._keyEvent("next", event);
  3437. break;
  3438. case keyCode.ENTER:
  3439. if (this.menu.active) {
  3440. suppressKeyPress = true;
  3441. event.preventDefault();
  3442. this.menu.select(event);
  3443. }
  3444. break;
  3445. case keyCode.TAB:
  3446. if (this.menu.active) {
  3447. this.menu.select(event);
  3448. }
  3449. break;
  3450. case keyCode.ESCAPE:
  3451. if (this.menu.element.is(":visible")) {
  3452. if (!this.isMultiLine) {
  3453. this._value(this.term);
  3454. }
  3455. this.close(event);
  3456. event.preventDefault();
  3457. }
  3458. break;
  3459. default:
  3460. suppressKeyPressRepeat = true;
  3461. this._searchTimeout(event);
  3462. break;
  3463. }
  3464. },
  3465. keypress: function(event) {
  3466. if (suppressKeyPress) {
  3467. suppressKeyPress = false;
  3468. if (!this.isMultiLine || this.menu.element.is(":visible")) {
  3469. event.preventDefault();
  3470. }
  3471. return;
  3472. }
  3473. if (suppressKeyPressRepeat) {
  3474. return;
  3475. }
  3476. var keyCode = $.ui.keyCode;
  3477. switch (event.keyCode) {
  3478. case keyCode.PAGE_UP:
  3479. this._move("previousPage", event);
  3480. break;
  3481. case keyCode.PAGE_DOWN:
  3482. this._move("nextPage", event);
  3483. break;
  3484. case keyCode.UP:
  3485. this._keyEvent("previous", event);
  3486. break;
  3487. case keyCode.DOWN:
  3488. this._keyEvent("next", event);
  3489. break;
  3490. }
  3491. },
  3492. input: function(event) {
  3493. if (suppressInput) {
  3494. suppressInput = false;
  3495. event.preventDefault();
  3496. return;
  3497. }
  3498. this._searchTimeout(event);
  3499. },
  3500. focus: function() {
  3501. this.selectedItem = null;
  3502. this.previous = this._value();
  3503. },
  3504. blur: function(event) {
  3505. clearTimeout(this.searching);
  3506. this.close(event);
  3507. this._change(event);
  3508. }
  3509. });
  3510. this._initSource();
  3511. this.menu = $("<ul>").appendTo(this._appendTo()).menu({
  3512. // disable ARIA support, the live region takes care of that
  3513. role: null
  3514. }).hide().menu("instance");
  3515. this._addClass(this.menu.element, "ui-autocomplete", "ui-front");
  3516. this._on(this.menu.element, {
  3517. mousedown: function(event) {
  3518. event.preventDefault();
  3519. },
  3520. menufocus: function(event, ui) {
  3521. var label, item;
  3522. if (this.isNewMenu) {
  3523. this.isNewMenu = false;
  3524. if (event.originalEvent && /^mouse/.test(event.originalEvent.type)) {
  3525. this.menu.blur();
  3526. this.document.one("mousemove", function() {
  3527. $(event.target).trigger(event.originalEvent);
  3528. });
  3529. return;
  3530. }
  3531. }
  3532. item = ui.item.data("ui-autocomplete-item");
  3533. if (false !== this._trigger("focus", event, { item })) {
  3534. if (event.originalEvent && /^key/.test(event.originalEvent.type)) {
  3535. this._value(item.value);
  3536. }
  3537. }
  3538. label = ui.item.attr("aria-label") || item.value;
  3539. if (label && String.prototype.trim.call(label).length) {
  3540. clearTimeout(this.liveRegionTimer);
  3541. this.liveRegionTimer = this._delay(function() {
  3542. this.liveRegion.html($("<div>").text(label));
  3543. }, 100);
  3544. }
  3545. },
  3546. menuselect: function(event, ui) {
  3547. var item = ui.item.data("ui-autocomplete-item"), previous = this.previous;
  3548. if (this.element[0] !== this.document[0].activeElement) {
  3549. this.element.trigger("focus");
  3550. this.previous = previous;
  3551. }
  3552. if (false !== this._trigger("select", event, { item })) {
  3553. this._value(item.value);
  3554. }
  3555. this.term = this._value();
  3556. this.close(event);
  3557. this.selectedItem = item;
  3558. }
  3559. });
  3560. this.liveRegion = $("<div>", {
  3561. role: "status",
  3562. "aria-live": "assertive",
  3563. "aria-relevant": "additions"
  3564. }).appendTo(this.document[0].body);
  3565. this._addClass(this.liveRegion, null, "ui-helper-hidden-accessible");
  3566. this._on(this.window, {
  3567. beforeunload: function() {
  3568. this.element.removeAttr("autocomplete");
  3569. }
  3570. });
  3571. },
  3572. _destroy: function() {
  3573. clearTimeout(this.searching);
  3574. this.element.removeAttr("autocomplete");
  3575. this.menu.element.remove();
  3576. this.liveRegion.remove();
  3577. },
  3578. _setOption: function(key, value) {
  3579. this._super(key, value);
  3580. if (key === "source") {
  3581. this._initSource();
  3582. }
  3583. if (key === "appendTo") {
  3584. this.menu.element.appendTo(this._appendTo());
  3585. }
  3586. if (key === "disabled" && value && this.xhr) {
  3587. this.xhr.abort();
  3588. }
  3589. },
  3590. _isEventTargetInWidget: function(event) {
  3591. var menuElement = this.menu.element[0];
  3592. return event.target === this.element[0] || event.target === menuElement || $.contains(menuElement, event.target);
  3593. },
  3594. _closeOnClickOutside: function(event) {
  3595. if (!this._isEventTargetInWidget(event)) {
  3596. this.close();
  3597. }
  3598. },
  3599. _appendTo: function() {
  3600. var element = this.options.appendTo;
  3601. if (element) {
  3602. element = element.jquery || element.nodeType ? $(element) : this.document.find(element).eq(0);
  3603. }
  3604. if (!element || !element[0]) {
  3605. element = this.element.closest(".ui-front, dialog");
  3606. }
  3607. if (!element.length) {
  3608. element = this.document[0].body;
  3609. }
  3610. return element;
  3611. },
  3612. _initSource: function() {
  3613. var array, url, that = this;
  3614. if (Array.isArray(this.options.source)) {
  3615. array = this.options.source;
  3616. this.source = function(request, response) {
  3617. response($.ui.autocomplete.filter(array, request.term));
  3618. };
  3619. } else if (typeof this.options.source === "string") {
  3620. url = this.options.source;
  3621. this.source = function(request, response) {
  3622. if (that.xhr) {
  3623. that.xhr.abort();
  3624. }
  3625. that.xhr = $.ajax({
  3626. url,
  3627. data: request,
  3628. dataType: "json",
  3629. success: function(data2) {
  3630. response(data2);
  3631. },
  3632. error: function() {
  3633. response([]);
  3634. }
  3635. });
  3636. };
  3637. } else {
  3638. this.source = this.options.source;
  3639. }
  3640. },
  3641. _searchTimeout: function(event) {
  3642. clearTimeout(this.searching);
  3643. this.searching = this._delay(function() {
  3644. var equalValues = this.term === this._value(), menuVisible = this.menu.element.is(":visible"), modifierKey = event.altKey || event.ctrlKey || event.metaKey || event.shiftKey;
  3645. if (!equalValues || equalValues && !menuVisible && !modifierKey) {
  3646. this.selectedItem = null;
  3647. this.search(null, event);
  3648. }
  3649. }, this.options.delay);
  3650. },
  3651. search: function(value, event) {
  3652. value = value != null ? value : this._value();
  3653. this.term = this._value();
  3654. if (value.length < this.options.minLength) {
  3655. return this.close(event);
  3656. }
  3657. if (this._trigger("search", event) === false) {
  3658. return;
  3659. }
  3660. return this._search(value);
  3661. },
  3662. _search: function(value) {
  3663. this.pending++;
  3664. this._addClass("ui-autocomplete-loading");
  3665. this.cancelSearch = false;
  3666. this.source({ term: value }, this._response());
  3667. },
  3668. _response: function() {
  3669. var index = ++this.requestIndex;
  3670. return (function(content) {
  3671. if (index === this.requestIndex) {
  3672. this.__response(content);
  3673. }
  3674. this.pending--;
  3675. if (!this.pending) {
  3676. this._removeClass("ui-autocomplete-loading");
  3677. }
  3678. }).bind(this);
  3679. },
  3680. __response: function(content) {
  3681. if (content) {
  3682. content = this._normalize(content);
  3683. }
  3684. this._trigger("response", null, { content });
  3685. if (!this.options.disabled && content && content.length && !this.cancelSearch) {
  3686. this._suggest(content);
  3687. this._trigger("open");
  3688. } else {
  3689. this._close();
  3690. }
  3691. },
  3692. close: function(event) {
  3693. this.cancelSearch = true;
  3694. this._close(event);
  3695. },
  3696. _close: function(event) {
  3697. this._off(this.document, "mousedown");
  3698. if (this.menu.element.is(":visible")) {
  3699. this.menu.element.hide();
  3700. this.menu.blur();
  3701. this.isNewMenu = true;
  3702. this._trigger("close", event);
  3703. }
  3704. },
  3705. _change: function(event) {
  3706. if (this.previous !== this._value()) {
  3707. this._trigger("change", event, { item: this.selectedItem });
  3708. }
  3709. },
  3710. _normalize: function(items) {
  3711. if (items.length && items[0].label && items[0].value) {
  3712. return items;
  3713. }
  3714. return $.map(items, function(item) {
  3715. if (typeof item === "string") {
  3716. return {
  3717. label: item,
  3718. value: item
  3719. };
  3720. }
  3721. return $.extend({}, item, {
  3722. label: item.label || item.value,
  3723. value: item.value || item.label
  3724. });
  3725. });
  3726. },
  3727. _suggest: function(items) {
  3728. var ul = this.menu.element.empty();
  3729. this._renderMenu(ul, items);
  3730. this.isNewMenu = true;
  3731. this.menu.refresh();
  3732. ul.show();
  3733. this._resizeMenu();
  3734. ul.position($.extend({
  3735. of: this.element
  3736. }, this.options.position));
  3737. if (this.options.autoFocus) {
  3738. this.menu.next();
  3739. }
  3740. this._on(this.document, {
  3741. mousedown: "_closeOnClickOutside"
  3742. });
  3743. },
  3744. _resizeMenu: function() {
  3745. var ul = this.menu.element;
  3746. ul.outerWidth(Math.max(
  3747. // Firefox wraps long text (possibly a rounding bug)
  3748. // so we add 1px to avoid the wrapping (#7513)
  3749. ul.width("").outerWidth() + 1,
  3750. this.element.outerWidth()
  3751. ));
  3752. },
  3753. _renderMenu: function(ul, items) {
  3754. var that = this;
  3755. $.each(items, function(index, item) {
  3756. that._renderItemData(ul, item);
  3757. });
  3758. },
  3759. _renderItemData: function(ul, item) {
  3760. return this._renderItem(ul, item).data("ui-autocomplete-item", item);
  3761. },
  3762. _renderItem: function(ul, item) {
  3763. return $("<li>").append($("<div>").text(item.label)).appendTo(ul);
  3764. },
  3765. _move: function(direction, event) {
  3766. if (!this.menu.element.is(":visible")) {
  3767. this.search(null, event);
  3768. return;
  3769. }
  3770. if (this.menu.isFirstItem() && /^previous/.test(direction) || this.menu.isLastItem() && /^next/.test(direction)) {
  3771. if (!this.isMultiLine) {
  3772. this._value(this.term);
  3773. }
  3774. this.menu.blur();
  3775. return;
  3776. }
  3777. this.menu[direction](event);
  3778. },
  3779. widget: function() {
  3780. return this.menu.element;
  3781. },
  3782. _value: function() {
  3783. return this.valueMethod.apply(this.element, arguments);
  3784. },
  3785. _keyEvent: function(keyEvent, event) {
  3786. if (!this.isMultiLine || this.menu.element.is(":visible")) {
  3787. this._move(keyEvent, event);
  3788. event.preventDefault();
  3789. }
  3790. }
  3791. });
  3792. $.extend($.ui.autocomplete, {
  3793. escapeRegex: function(value) {
  3794. return value.replace(/[\-\[\]{}()*+?.,\\\^$|#\s]/g, "\\$&");
  3795. },
  3796. filter: function(array, term) {
  3797. var matcher = new RegExp($.ui.autocomplete.escapeRegex(term), "i");
  3798. return $.grep(array, function(value) {
  3799. return matcher.test(value.label || value.value || value);
  3800. });
  3801. }
  3802. });
  3803. $.widget("ui.autocomplete", $.ui.autocomplete, {
  3804. options: {
  3805. messages: {
  3806. noResults: "No search results.",
  3807. results: function(amount) {
  3808. return amount + (amount > 1 ? " results are" : " result is") + " available, use up and down arrow keys to navigate.";
  3809. }
  3810. }
  3811. },
  3812. __response: function(content) {
  3813. var message;
  3814. this._superApply(arguments);
  3815. if (this.options.disabled || this.cancelSearch) {
  3816. return;
  3817. }
  3818. if (content && content.length) {
  3819. message = this.options.messages.results(content.length);
  3820. } else {
  3821. message = this.options.messages.noResults;
  3822. }
  3823. clearTimeout(this.liveRegionTimer);
  3824. this.liveRegionTimer = this._delay(function() {
  3825. this.liveRegion.html($("<div>").text(message));
  3826. }, 100);
  3827. }
  3828. });
  3829. var widgetsAutocomplete = $.ui.autocomplete;
  3830. var controlgroupCornerRegex = /ui-corner-([a-z]){2,6}/g;
  3831. var widgetsControlgroup = $.widget("ui.controlgroup", {
  3832. version: "1.14.1",
  3833. defaultElement: "<div>",
  3834. options: {
  3835. direction: "horizontal",
  3836. disabled: null,
  3837. onlyVisible: true,
  3838. items: {
  3839. "button": "input[type=button], input[type=submit], input[type=reset], button, a",
  3840. "controlgroupLabel": ".ui-controlgroup-label",
  3841. "checkboxradio": "input[type='checkbox'], input[type='radio']",
  3842. "selectmenu": "select",
  3843. "spinner": ".ui-spinner-input"
  3844. }
  3845. },
  3846. _create: function() {
  3847. this._enhance();
  3848. },
  3849. // To support the enhanced option in jQuery Mobile, we isolate DOM manipulation
  3850. _enhance: function() {
  3851. this.element.attr("role", "toolbar");
  3852. this.refresh();
  3853. },
  3854. _destroy: function() {
  3855. this._callChildMethod("destroy");
  3856. this.childWidgets.removeData("ui-controlgroup-data");
  3857. this.element.removeAttr("role");
  3858. if (this.options.items.controlgroupLabel) {
  3859. this.element.find(this.options.items.controlgroupLabel).find(".ui-controlgroup-label-contents").contents().unwrap();
  3860. }
  3861. },
  3862. _initWidgets: function() {
  3863. var that = this, childWidgets = [];
  3864. $.each(this.options.items, function(widget2, selector) {
  3865. var labels2;
  3866. var options = {};
  3867. if (!selector) {
  3868. return;
  3869. }
  3870. if (widget2 === "controlgroupLabel") {
  3871. labels2 = that.element.find(selector);
  3872. labels2.each(function() {
  3873. var element = $(this);
  3874. if (element.children(".ui-controlgroup-label-contents").length) {
  3875. return;
  3876. }
  3877. element.contents().wrapAll("<span class='ui-controlgroup-label-contents'></span>");
  3878. });
  3879. that._addClass(labels2, null, "ui-widget ui-widget-content ui-state-default");
  3880. childWidgets = childWidgets.concat(labels2.get());
  3881. return;
  3882. }
  3883. if (!$.fn[widget2]) {
  3884. return;
  3885. }
  3886. if (that["_" + widget2 + "Options"]) {
  3887. options = that["_" + widget2 + "Options"]("middle");
  3888. } else {
  3889. options = { classes: {} };
  3890. }
  3891. that.element.find(selector).each(function() {
  3892. var element = $(this);
  3893. var instance = element[widget2]("instance");
  3894. var instanceOptions = $.widget.extend({}, options);
  3895. if (widget2 === "button" && element.parent(".ui-spinner").length) {
  3896. return;
  3897. }
  3898. if (!instance) {
  3899. instance = element[widget2]()[widget2]("instance");
  3900. }
  3901. if (instance) {
  3902. instanceOptions.classes = that._resolveClassesValues(instanceOptions.classes, instance);
  3903. }
  3904. element[widget2](instanceOptions);
  3905. var widgetElement = element[widget2]("widget");
  3906. $.data(
  3907. widgetElement[0],
  3908. "ui-controlgroup-data",
  3909. instance ? instance : element[widget2]("instance")
  3910. );
  3911. childWidgets.push(widgetElement[0]);
  3912. });
  3913. });
  3914. this.childWidgets = $($.uniqueSort(childWidgets));
  3915. this._addClass(this.childWidgets, "ui-controlgroup-item");
  3916. },
  3917. _callChildMethod: function(method) {
  3918. this.childWidgets.each(function() {
  3919. var element = $(this), data2 = element.data("ui-controlgroup-data");
  3920. if (data2 && data2[method]) {
  3921. data2[method]();
  3922. }
  3923. });
  3924. },
  3925. _updateCornerClass: function(element, position2) {
  3926. var remove = "ui-corner-top ui-corner-bottom ui-corner-left ui-corner-right ui-corner-all";
  3927. var add = this._buildSimpleOptions(position2, "label").classes.label;
  3928. this._removeClass(element, null, remove);
  3929. this._addClass(element, null, add);
  3930. },
  3931. _buildSimpleOptions: function(position2, key) {
  3932. var direction = this.options.direction === "vertical";
  3933. var result = {
  3934. classes: {}
  3935. };
  3936. result.classes[key] = {
  3937. "middle": "",
  3938. "first": "ui-corner-" + (direction ? "top" : "left"),
  3939. "last": "ui-corner-" + (direction ? "bottom" : "right"),
  3940. "only": "ui-corner-all"
  3941. }[position2];
  3942. return result;
  3943. },
  3944. _spinnerOptions: function(position2) {
  3945. var options = this._buildSimpleOptions(position2, "ui-spinner");
  3946. options.classes["ui-spinner-up"] = "";
  3947. options.classes["ui-spinner-down"] = "";
  3948. return options;
  3949. },
  3950. _buttonOptions: function(position2) {
  3951. return this._buildSimpleOptions(position2, "ui-button");
  3952. },
  3953. _checkboxradioOptions: function(position2) {
  3954. return this._buildSimpleOptions(position2, "ui-checkboxradio-label");
  3955. },
  3956. _selectmenuOptions: function(position2) {
  3957. var direction = this.options.direction === "vertical";
  3958. return {
  3959. width: direction ? "auto" : false,
  3960. classes: {
  3961. middle: {
  3962. "ui-selectmenu-button-open": "",
  3963. "ui-selectmenu-button-closed": ""
  3964. },
  3965. first: {
  3966. "ui-selectmenu-button-open": "ui-corner-" + (direction ? "top" : "tl"),
  3967. "ui-selectmenu-button-closed": "ui-corner-" + (direction ? "top" : "left")
  3968. },
  3969. last: {
  3970. "ui-selectmenu-button-open": direction ? "" : "ui-corner-tr",
  3971. "ui-selectmenu-button-closed": "ui-corner-" + (direction ? "bottom" : "right")
  3972. },
  3973. only: {
  3974. "ui-selectmenu-button-open": "ui-corner-top",
  3975. "ui-selectmenu-button-closed": "ui-corner-all"
  3976. }
  3977. }[position2]
  3978. };
  3979. },
  3980. _resolveClassesValues: function(classes, instance) {
  3981. var result = {};
  3982. $.each(classes, function(key) {
  3983. var current = instance.options.classes[key] || "";
  3984. current = String.prototype.trim.call(current.replace(controlgroupCornerRegex, ""));
  3985. result[key] = (current + " " + classes[key]).replace(/\s+/g, " ");
  3986. });
  3987. return result;
  3988. },
  3989. _setOption: function(key, value) {
  3990. if (key === "direction") {
  3991. this._removeClass("ui-controlgroup-" + this.options.direction);
  3992. }
  3993. this._super(key, value);
  3994. if (key === "disabled") {
  3995. this._callChildMethod(value ? "disable" : "enable");
  3996. return;
  3997. }
  3998. this.refresh();
  3999. },
  4000. refresh: function() {
  4001. var children, that = this;
  4002. this._addClass("ui-controlgroup ui-controlgroup-" + this.options.direction);
  4003. if (this.options.direction === "horizontal") {
  4004. this._addClass(null, "ui-helper-clearfix");
  4005. }
  4006. this._initWidgets();
  4007. children = this.childWidgets;
  4008. if (this.options.onlyVisible) {
  4009. children = children.filter(":visible");
  4010. }
  4011. if (children.length) {
  4012. $.each(["first", "last"], function(index, value) {
  4013. var instance = children[value]().data("ui-controlgroup-data");
  4014. if (instance && that["_" + instance.widgetName + "Options"]) {
  4015. var options = that["_" + instance.widgetName + "Options"](
  4016. children.length === 1 ? "only" : value
  4017. );
  4018. options.classes = that._resolveClassesValues(options.classes, instance);
  4019. instance.element[instance.widgetName](options);
  4020. } else {
  4021. that._updateCornerClass(children[value](), value);
  4022. }
  4023. });
  4024. this._callChildMethod("refresh");
  4025. }
  4026. }
  4027. });
  4028. $.widget("ui.checkboxradio", [$.ui.formResetMixin, {
  4029. version: "1.14.1",
  4030. options: {
  4031. disabled: null,
  4032. label: null,
  4033. icon: true,
  4034. classes: {
  4035. "ui-checkboxradio-label": "ui-corner-all",
  4036. "ui-checkboxradio-icon": "ui-corner-all"
  4037. }
  4038. },
  4039. _getCreateOptions: function() {
  4040. var disabled, labels2, labelContents;
  4041. var options = this._super() || {};
  4042. this._readType();
  4043. labels2 = this.element.labels();
  4044. this.label = $(labels2[labels2.length - 1]);
  4045. if (!this.label.length) {
  4046. $.error("No label found for checkboxradio widget");
  4047. }
  4048. this.originalLabel = "";
  4049. labelContents = this.label.contents().not(this.element[0]);
  4050. if (labelContents.length) {
  4051. this.originalLabel += labelContents.clone().wrapAll("<div></div>").parent().html();
  4052. }
  4053. if (this.originalLabel) {
  4054. options.label = this.originalLabel;
  4055. }
  4056. disabled = this.element[0].disabled;
  4057. if (disabled != null) {
  4058. options.disabled = disabled;
  4059. }
  4060. return options;
  4061. },
  4062. _create: function() {
  4063. var checked = this.element[0].checked;
  4064. this._bindFormResetHandler();
  4065. if (this.options.disabled == null) {
  4066. this.options.disabled = this.element[0].disabled;
  4067. }
  4068. this._setOption("disabled", this.options.disabled);
  4069. this._addClass("ui-checkboxradio", "ui-helper-hidden-accessible");
  4070. this._addClass(this.label, "ui-checkboxradio-label", "ui-button ui-widget");
  4071. if (this.type === "radio") {
  4072. this._addClass(this.label, "ui-checkboxradio-radio-label");
  4073. }
  4074. if (this.options.label && this.options.label !== this.originalLabel) {
  4075. this._updateLabel();
  4076. } else if (this.originalLabel) {
  4077. this.options.label = this.originalLabel;
  4078. }
  4079. this._enhance();
  4080. if (checked) {
  4081. this._addClass(this.label, "ui-checkboxradio-checked", "ui-state-active");
  4082. }
  4083. this._on({
  4084. change: "_toggleClasses",
  4085. focus: function() {
  4086. this._addClass(this.label, null, "ui-state-focus ui-visual-focus");
  4087. },
  4088. blur: function() {
  4089. this._removeClass(this.label, null, "ui-state-focus ui-visual-focus");
  4090. }
  4091. });
  4092. },
  4093. _readType: function() {
  4094. var nodeName = this.element[0].nodeName.toLowerCase();
  4095. this.type = this.element[0].type;
  4096. if (nodeName !== "input" || !/radio|checkbox/.test(this.type)) {
  4097. $.error("Can't create checkboxradio on element.nodeName=" + nodeName + " and element.type=" + this.type);
  4098. }
  4099. },
  4100. // Support jQuery Mobile enhanced option
  4101. _enhance: function() {
  4102. this._updateIcon(this.element[0].checked);
  4103. },
  4104. widget: function() {
  4105. return this.label;
  4106. },
  4107. _getRadioGroup: function() {
  4108. var group;
  4109. var name = this.element[0].name;
  4110. var nameSelector = "input[name='" + CSS.escape(name) + "']";
  4111. if (!name) {
  4112. return $([]);
  4113. }
  4114. if (this.form.length) {
  4115. group = $(this.form[0].elements).filter(nameSelector);
  4116. } else {
  4117. group = $(nameSelector).filter(function() {
  4118. return $($(this).prop("form")).length === 0;
  4119. });
  4120. }
  4121. return group.not(this.element);
  4122. },
  4123. _toggleClasses: function() {
  4124. var checked = this.element[0].checked;
  4125. this._toggleClass(this.label, "ui-checkboxradio-checked", "ui-state-active", checked);
  4126. if (this.options.icon && this.type === "checkbox") {
  4127. this._toggleClass(this.icon, null, "ui-icon-check ui-state-checked", checked)._toggleClass(this.icon, null, "ui-icon-blank", !checked);
  4128. }
  4129. if (this.type === "radio") {
  4130. this._getRadioGroup().each(function() {
  4131. var instance = $(this).checkboxradio("instance");
  4132. if (instance) {
  4133. instance._removeClass(
  4134. instance.label,
  4135. "ui-checkboxradio-checked",
  4136. "ui-state-active"
  4137. );
  4138. }
  4139. });
  4140. }
  4141. },
  4142. _destroy: function() {
  4143. this._unbindFormResetHandler();
  4144. if (this.icon) {
  4145. this.icon.remove();
  4146. this.iconSpace.remove();
  4147. }
  4148. },
  4149. _setOption: function(key, value) {
  4150. if (key === "label" && !value) {
  4151. return;
  4152. }
  4153. this._super(key, value);
  4154. if (key === "disabled") {
  4155. this._toggleClass(this.label, null, "ui-state-disabled", value);
  4156. this.element[0].disabled = value;
  4157. return;
  4158. }
  4159. this.refresh();
  4160. },
  4161. _updateIcon: function(checked) {
  4162. var toAdd = "ui-icon ui-icon-background ";
  4163. if (this.options.icon) {
  4164. if (!this.icon) {
  4165. this.icon = $("<span>");
  4166. this.iconSpace = $("<span> </span>");
  4167. this._addClass(this.iconSpace, "ui-checkboxradio-icon-space");
  4168. }
  4169. if (this.type === "checkbox") {
  4170. toAdd += checked ? "ui-icon-check ui-state-checked" : "ui-icon-blank";
  4171. this._removeClass(this.icon, null, checked ? "ui-icon-blank" : "ui-icon-check");
  4172. } else {
  4173. toAdd += "ui-icon-blank";
  4174. }
  4175. this._addClass(this.icon, "ui-checkboxradio-icon", toAdd);
  4176. if (!checked) {
  4177. this._removeClass(this.icon, null, "ui-icon-check ui-state-checked");
  4178. }
  4179. this.icon.prependTo(this.label).after(this.iconSpace);
  4180. } else if (this.icon !== void 0) {
  4181. this.icon.remove();
  4182. this.iconSpace.remove();
  4183. delete this.icon;
  4184. }
  4185. },
  4186. _updateLabel: function() {
  4187. var contents = this.label.contents().not(this.element[0]);
  4188. if (this.icon) {
  4189. contents = contents.not(this.icon[0]);
  4190. }
  4191. if (this.iconSpace) {
  4192. contents = contents.not(this.iconSpace[0]);
  4193. }
  4194. contents.remove();
  4195. this.label.append(this.options.label);
  4196. },
  4197. refresh: function() {
  4198. var checked = this.element[0].checked, isDisabled = this.element[0].disabled;
  4199. this._updateIcon(checked);
  4200. this._toggleClass(this.label, "ui-checkboxradio-checked", "ui-state-active", checked);
  4201. if (this.options.label !== null) {
  4202. this._updateLabel();
  4203. }
  4204. if (isDisabled !== this.options.disabled) {
  4205. this._setOptions({ "disabled": isDisabled });
  4206. }
  4207. }
  4208. }]);
  4209. var widgetsCheckboxradio = $.ui.checkboxradio;
  4210. $.widget("ui.button", {
  4211. version: "1.14.1",
  4212. defaultElement: "<button>",
  4213. options: {
  4214. classes: {
  4215. "ui-button": "ui-corner-all"
  4216. },
  4217. disabled: null,
  4218. icon: null,
  4219. iconPosition: "beginning",
  4220. label: null,
  4221. showLabel: true
  4222. },
  4223. _getCreateOptions: function() {
  4224. var disabled, options = this._super() || {};
  4225. this.isInput = this.element.is("input");
  4226. disabled = this.element[0].disabled;
  4227. if (disabled != null) {
  4228. options.disabled = disabled;
  4229. }
  4230. this.originalLabel = this.isInput ? this.element.val() : this.element.html();
  4231. if (this.originalLabel) {
  4232. options.label = this.originalLabel;
  4233. }
  4234. return options;
  4235. },
  4236. _create: function() {
  4237. if (!this.option.showLabel & !this.options.icon) {
  4238. this.options.showLabel = true;
  4239. }
  4240. if (this.options.disabled == null) {
  4241. this.options.disabled = this.element[0].disabled || false;
  4242. }
  4243. this.hasTitle = !!this.element.attr("title");
  4244. if (this.options.label && this.options.label !== this.originalLabel) {
  4245. if (this.isInput) {
  4246. this.element.val(this.options.label);
  4247. } else {
  4248. this.element.html(this.options.label);
  4249. }
  4250. }
  4251. this._addClass("ui-button", "ui-widget");
  4252. this._setOption("disabled", this.options.disabled);
  4253. this._enhance();
  4254. if (this.element.is("a")) {
  4255. this._on({
  4256. "keyup": function(event) {
  4257. if (event.keyCode === $.ui.keyCode.SPACE) {
  4258. event.preventDefault();
  4259. if (this.element[0].click) {
  4260. this.element[0].click();
  4261. } else {
  4262. this.element.trigger("click");
  4263. }
  4264. }
  4265. }
  4266. });
  4267. }
  4268. },
  4269. _enhance: function() {
  4270. if (!this.element.is("button")) {
  4271. this.element.attr("role", "button");
  4272. }
  4273. if (this.options.icon) {
  4274. this._updateIcon("icon", this.options.icon);
  4275. this._updateTooltip();
  4276. }
  4277. },
  4278. _updateTooltip: function() {
  4279. this.title = this.element.attr("title");
  4280. if (!this.options.showLabel && !this.title) {
  4281. this.element.attr("title", this.options.label);
  4282. }
  4283. },
  4284. _updateIcon: function(option, value) {
  4285. var icon = option !== "iconPosition", position2 = icon ? this.options.iconPosition : value, displayBlock = position2 === "top" || position2 === "bottom";
  4286. if (!this.icon) {
  4287. this.icon = $("<span>");
  4288. this._addClass(this.icon, "ui-button-icon", "ui-icon");
  4289. if (!this.options.showLabel) {
  4290. this._addClass("ui-button-icon-only");
  4291. }
  4292. } else if (icon) {
  4293. this._removeClass(this.icon, null, this.options.icon);
  4294. }
  4295. if (icon) {
  4296. this._addClass(this.icon, null, value);
  4297. }
  4298. this._attachIcon(position2);
  4299. if (displayBlock) {
  4300. this._addClass(this.icon, null, "ui-widget-icon-block");
  4301. if (this.iconSpace) {
  4302. this.iconSpace.remove();
  4303. }
  4304. } else {
  4305. if (!this.iconSpace) {
  4306. this.iconSpace = $("<span> </span>");
  4307. this._addClass(this.iconSpace, "ui-button-icon-space");
  4308. }
  4309. this._removeClass(this.icon, null, "ui-wiget-icon-block");
  4310. this._attachIconSpace(position2);
  4311. }
  4312. },
  4313. _destroy: function() {
  4314. this.element.removeAttr("role");
  4315. if (this.icon) {
  4316. this.icon.remove();
  4317. }
  4318. if (this.iconSpace) {
  4319. this.iconSpace.remove();
  4320. }
  4321. if (!this.hasTitle) {
  4322. this.element.removeAttr("title");
  4323. }
  4324. },
  4325. _attachIconSpace: function(iconPosition) {
  4326. this.icon[/^(?:end|bottom)/.test(iconPosition) ? "before" : "after"](this.iconSpace);
  4327. },
  4328. _attachIcon: function(iconPosition) {
  4329. this.element[/^(?:end|bottom)/.test(iconPosition) ? "append" : "prepend"](this.icon);
  4330. },
  4331. _setOptions: function(options) {
  4332. var newShowLabel = options.showLabel === void 0 ? this.options.showLabel : options.showLabel, newIcon = options.icon === void 0 ? this.options.icon : options.icon;
  4333. if (!newShowLabel && !newIcon) {
  4334. options.showLabel = true;
  4335. }
  4336. this._super(options);
  4337. },
  4338. _setOption: function(key, value) {
  4339. if (key === "icon") {
  4340. if (value) {
  4341. this._updateIcon(key, value);
  4342. } else if (this.icon) {
  4343. this.icon.remove();
  4344. if (this.iconSpace) {
  4345. this.iconSpace.remove();
  4346. }
  4347. }
  4348. }
  4349. if (key === "iconPosition") {
  4350. this._updateIcon(key, value);
  4351. }
  4352. if (key === "showLabel") {
  4353. this._toggleClass("ui-button-icon-only", null, !value);
  4354. this._updateTooltip();
  4355. }
  4356. if (key === "label") {
  4357. if (this.isInput) {
  4358. this.element.val(value);
  4359. } else {
  4360. this.element.html(value);
  4361. if (this.icon) {
  4362. this._attachIcon(this.options.iconPosition);
  4363. this._attachIconSpace(this.options.iconPosition);
  4364. }
  4365. }
  4366. }
  4367. this._super(key, value);
  4368. if (key === "disabled") {
  4369. this._toggleClass(null, "ui-state-disabled", value);
  4370. this.element[0].disabled = value;
  4371. if (value) {
  4372. this.element.trigger("blur");
  4373. }
  4374. }
  4375. },
  4376. refresh: function() {
  4377. var isDisabled = this.element.is("input, button") ? this.element[0].disabled : this.element.hasClass("ui-button-disabled");
  4378. if (isDisabled !== this.options.disabled) {
  4379. this._setOptions({ disabled: isDisabled });
  4380. }
  4381. this._updateTooltip();
  4382. }
  4383. });
  4384. if ($.uiBackCompat === true) {
  4385. $.widget("ui.button", $.ui.button, {
  4386. options: {
  4387. text: true,
  4388. icons: {
  4389. primary: null,
  4390. secondary: null
  4391. }
  4392. },
  4393. _create: function() {
  4394. if (this.options.showLabel && !this.options.text) {
  4395. this.options.showLabel = this.options.text;
  4396. }
  4397. if (!this.options.showLabel && this.options.text) {
  4398. this.options.text = this.options.showLabel;
  4399. }
  4400. if (!this.options.icon && (this.options.icons.primary || this.options.icons.secondary)) {
  4401. if (this.options.icons.primary) {
  4402. this.options.icon = this.options.icons.primary;
  4403. } else {
  4404. this.options.icon = this.options.icons.secondary;
  4405. this.options.iconPosition = "end";
  4406. }
  4407. } else if (this.options.icon) {
  4408. this.options.icons.primary = this.options.icon;
  4409. }
  4410. this._super();
  4411. },
  4412. _setOption: function(key, value) {
  4413. if (key === "text") {
  4414. this._super("showLabel", value);
  4415. return;
  4416. }
  4417. if (key === "showLabel") {
  4418. this.options.text = value;
  4419. }
  4420. if (key === "icon") {
  4421. this.options.icons.primary = value;
  4422. }
  4423. if (key === "icons") {
  4424. if (value.primary) {
  4425. this._super("icon", value.primary);
  4426. this._super("iconPosition", "beginning");
  4427. } else if (value.secondary) {
  4428. this._super("icon", value.secondary);
  4429. this._super("iconPosition", "end");
  4430. }
  4431. }
  4432. this._superApply(arguments);
  4433. }
  4434. });
  4435. $.fn.button = function(orig) {
  4436. return function(options) {
  4437. var isMethodCall = typeof options === "string";
  4438. var args = Array.prototype.slice.call(arguments, 1);
  4439. var returnValue = this;
  4440. if (isMethodCall) {
  4441. if (!this.length && options === "instance") {
  4442. returnValue = void 0;
  4443. } else {
  4444. this.each(function() {
  4445. var methodValue;
  4446. var type = $(this).attr("type");
  4447. var name = type !== "checkbox" && type !== "radio" ? "button" : "checkboxradio";
  4448. var instance = $.data(this, "ui-" + name);
  4449. if (options === "instance") {
  4450. returnValue = instance;
  4451. return false;
  4452. }
  4453. if (!instance) {
  4454. return $.error("cannot call methods on button prior to initialization; attempted to call method '" + options + "'");
  4455. }
  4456. if (typeof instance[options] !== "function" || options.charAt(0) === "_") {
  4457. return $.error("no such method '" + options + "' for button widget instance");
  4458. }
  4459. methodValue = instance[options].apply(instance, args);
  4460. if (methodValue !== instance && methodValue !== void 0) {
  4461. returnValue = methodValue && methodValue.jquery ? returnValue.pushStack(methodValue.get()) : methodValue;
  4462. return false;
  4463. }
  4464. });
  4465. }
  4466. } else {
  4467. if (args.length) {
  4468. options = $.widget.extend.apply(null, [options].concat(args));
  4469. }
  4470. this.each(function() {
  4471. var type = $(this).attr("type");
  4472. var name = type !== "checkbox" && type !== "radio" ? "button" : "checkboxradio";
  4473. var instance = $.data(this, "ui-" + name);
  4474. if (instance) {
  4475. instance.option(options || {});
  4476. if (instance._init) {
  4477. instance._init();
  4478. }
  4479. } else {
  4480. if (name === "button") {
  4481. orig.call($(this), options);
  4482. return;
  4483. }
  4484. $(this).checkboxradio($.extend({ icon: false }, options));
  4485. }
  4486. });
  4487. }
  4488. return returnValue;
  4489. };
  4490. }($.fn.button);
  4491. $.fn.buttonset = function() {
  4492. if (!$.ui.controlgroup) {
  4493. $.error("Controlgroup widget missing");
  4494. }
  4495. if (arguments[0] === "option" && arguments[1] === "items" && arguments[2]) {
  4496. return this.controlgroup.apply(
  4497. this,
  4498. [arguments[0], "items.button", arguments[2]]
  4499. );
  4500. }
  4501. if (arguments[0] === "option" && arguments[1] === "items") {
  4502. return this.controlgroup.apply(this, [arguments[0], "items.button"]);
  4503. }
  4504. if (typeof arguments[0] === "object" && arguments[0].items) {
  4505. arguments[0].items = {
  4506. button: arguments[0].items
  4507. };
  4508. }
  4509. return this.controlgroup.apply(this, arguments);
  4510. };
  4511. }
  4512. var widgetsButton = $.ui.button;
  4513. $.extend($.ui, { datepicker: { version: "1.14.1" } });
  4514. var datepicker_instActive;
  4515. function datepicker_getZindex(elem) {
  4516. var position2, value;
  4517. while (elem.length && elem[0] !== document) {
  4518. position2 = elem.css("position");
  4519. if (position2 === "absolute" || position2 === "relative" || position2 === "fixed") {
  4520. value = parseInt(elem.css("zIndex"), 10);
  4521. if (!isNaN(value) && value !== 0) {
  4522. return value;
  4523. }
  4524. }
  4525. elem = elem.parent();
  4526. }
  4527. return 0;
  4528. }
  4529. function Datepicker() {
  4530. this._curInst = null;
  4531. this._keyEvent = false;
  4532. this._disabledInputs = [];
  4533. this._datepickerShowing = false;
  4534. this._inDialog = false;
  4535. this._mainDivId = "ui-datepicker-div";
  4536. this._inlineClass = "ui-datepicker-inline";
  4537. this._appendClass = "ui-datepicker-append";
  4538. this._triggerClass = "ui-datepicker-trigger";
  4539. this._dialogClass = "ui-datepicker-dialog";
  4540. this._disableClass = "ui-datepicker-disabled";
  4541. this._unselectableClass = "ui-datepicker-unselectable";
  4542. this._currentClass = "ui-datepicker-current-day";
  4543. this._dayOverClass = "ui-datepicker-days-cell-over";
  4544. this.regional = [];
  4545. this.regional[""] = {
  4546. // Default regional settings
  4547. closeText: "Done",
  4548. // Display text for close link
  4549. prevText: "Prev",
  4550. // Display text for previous month link
  4551. nextText: "Next",
  4552. // Display text for next month link
  4553. currentText: "Today",
  4554. // Display text for current month link
  4555. monthNames: [
  4556. "January",
  4557. "February",
  4558. "March",
  4559. "April",
  4560. "May",
  4561. "June",
  4562. "July",
  4563. "August",
  4564. "September",
  4565. "October",
  4566. "November",
  4567. "December"
  4568. ],
  4569. // Names of months for drop-down and formatting
  4570. monthNamesShort: ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"],
  4571. // For formatting
  4572. dayNames: ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"],
  4573. // For formatting
  4574. dayNamesShort: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"],
  4575. // For formatting
  4576. dayNamesMin: ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"],
  4577. // Column headings for days starting at Sunday
  4578. weekHeader: "Wk",
  4579. // Column header for week of the year
  4580. dateFormat: "mm/dd/yy",
  4581. // See format options on parseDate
  4582. firstDay: 0,
  4583. // The first day of the week, Sun = 0, Mon = 1, ...
  4584. isRTL: false,
  4585. // True if right-to-left language, false if left-to-right
  4586. showMonthAfterYear: false,
  4587. // True if the year select precedes month, false for month then year
  4588. yearSuffix: "",
  4589. // Additional text to append to the year in the month headers,
  4590. selectMonthLabel: "Select month",
  4591. // Invisible label for month selector
  4592. selectYearLabel: "Select year"
  4593. // Invisible label for year selector
  4594. };
  4595. this._defaults = {
  4596. // Global defaults for all the date picker instances
  4597. showOn: "focus",
  4598. // "focus" for popup on focus,
  4599. // "button" for trigger button, or "both" for either
  4600. showAnim: "fadeIn",
  4601. // Name of jQuery animation for popup
  4602. showOptions: {},
  4603. // Options for enhanced animations
  4604. defaultDate: null,
  4605. // Used when field is blank: actual date,
  4606. // +/-number for offset from today, null for today
  4607. appendText: "",
  4608. // Display text following the input box, e.g. showing the format
  4609. buttonText: "...",
  4610. // Text for trigger button
  4611. buttonImage: "",
  4612. // URL for trigger button image
  4613. buttonImageOnly: false,
  4614. // True if the image appears alone, false if it appears on a button
  4615. hideIfNoPrevNext: false,
  4616. // True to hide next/previous month links
  4617. // if not applicable, false to just disable them
  4618. navigationAsDateFormat: false,
  4619. // True if date formatting applied to prev/today/next links
  4620. gotoCurrent: false,
  4621. // True if today link goes back to current selection instead
  4622. changeMonth: false,
  4623. // True if month can be selected directly, false if only prev/next
  4624. changeYear: false,
  4625. // True if year can be selected directly, false if only prev/next
  4626. yearRange: "c-10:c+10",
  4627. // Range of years to display in drop-down,
  4628. // either relative to today's year (-nn:+nn), relative to currently displayed year
  4629. // (c-nn:c+nn), absolute (nnnn:nnnn), or a combination of the above (nnnn:-n)
  4630. showOtherMonths: false,
  4631. // True to show dates in other months, false to leave blank
  4632. selectOtherMonths: false,
  4633. // True to allow selection of dates in other months, false for unselectable
  4634. showWeek: false,
  4635. // True to show week of the year, false to not show it
  4636. calculateWeek: this.iso8601Week,
  4637. // How to calculate the week of the year,
  4638. // takes a Date and returns the number of the week for it
  4639. shortYearCutoff: "+10",
  4640. // Short year values < this are in the current century,
  4641. // > this are in the previous century,
  4642. // string value starting with "+" for current year + value
  4643. minDate: null,
  4644. // The earliest selectable date, or null for no limit
  4645. maxDate: null,
  4646. // The latest selectable date, or null for no limit
  4647. duration: "fast",
  4648. // Duration of display/closure
  4649. beforeShowDay: null,
  4650. // Function that takes a date and returns an array with
  4651. // [0] = true if selectable, false if not, [1] = custom CSS class name(s) or "",
  4652. // [2] = cell title (optional), e.g. $.datepicker.noWeekends
  4653. beforeShow: null,
  4654. // Function that takes an input field and
  4655. // returns a set of custom settings for the date picker
  4656. onSelect: null,
  4657. // Define a callback function when a date is selected
  4658. onChangeMonthYear: null,
  4659. // Define a callback function when the month or year is changed
  4660. onClose: null,
  4661. // Define a callback function when the datepicker is closed
  4662. onUpdateDatepicker: null,
  4663. // Define a callback function when the datepicker is updated
  4664. numberOfMonths: 1,
  4665. // Number of months to show at a time
  4666. showCurrentAtPos: 0,
  4667. // The position in multipe months at which to show the current month (starting at 0)
  4668. stepMonths: 1,
  4669. // Number of months to step back/forward
  4670. stepBigMonths: 12,
  4671. // Number of months to step back/forward for the big links
  4672. altField: "",
  4673. // Selector for an alternate field to store selected dates into
  4674. altFormat: "",
  4675. // The date format to use for the alternate field
  4676. constrainInput: true,
  4677. // The input is constrained by the current date format
  4678. showButtonPanel: false,
  4679. // True to show button panel, false to not show it
  4680. autoSize: false,
  4681. // True to size the input for the date format, false to leave as is
  4682. disabled: false
  4683. // The initial disabled state
  4684. };
  4685. $.extend(this._defaults, this.regional[""]);
  4686. this.regional.en = $.extend(true, {}, this.regional[""]);
  4687. this.regional["en-US"] = $.extend(true, {}, this.regional.en);
  4688. this.dpDiv = datepicker_bindHover($("<div id='" + this._mainDivId + "' class='ui-datepicker ui-widget ui-widget-content ui-helper-clearfix ui-corner-all'></div>"));
  4689. }
  4690. $.extend(Datepicker.prototype, {
  4691. /* Class name added to elements to indicate already configured with a date picker. */
  4692. markerClassName: "hasDatepicker",
  4693. //Keep track of the maximum number of rows displayed (see #7043)
  4694. maxRows: 4,
  4695. // TODO rename to "widget" when switching to widget factory
  4696. _widgetDatepicker: function() {
  4697. return this.dpDiv;
  4698. },
  4699. /* Override the default settings for all instances of the date picker.
  4700. * @param settings object - the new settings to use as defaults (anonymous object)
  4701. * @return the manager object
  4702. */
  4703. setDefaults: function(settings) {
  4704. datepicker_extendRemove(this._defaults, settings || {});
  4705. return this;
  4706. },
  4707. /* Attach the date picker to a jQuery selection.
  4708. * @param target element - the target input field or division or span
  4709. * @param settings object - the new settings to use for this date picker instance (anonymous)
  4710. */
  4711. _attachDatepicker: function(target, settings) {
  4712. var nodeName, inline, inst;
  4713. nodeName = target.nodeName.toLowerCase();
  4714. inline = nodeName === "div" || nodeName === "span";
  4715. if (!target.id) {
  4716. this.uuid += 1;
  4717. target.id = "dp" + this.uuid;
  4718. }
  4719. inst = this._newInst($(target), inline);
  4720. inst.settings = $.extend({}, settings || {});
  4721. if (nodeName === "input") {
  4722. this._connectDatepicker(target, inst);
  4723. } else if (inline) {
  4724. this._inlineDatepicker(target, inst);
  4725. }
  4726. },
  4727. /* Create a new instance object. */
  4728. _newInst: function(target, inline) {
  4729. var id = target[0].id.replace(/([^A-Za-z0-9_\-])/g, "\\\\$1");
  4730. return {
  4731. id,
  4732. input: target,
  4733. // associated target
  4734. selectedDay: 0,
  4735. selectedMonth: 0,
  4736. selectedYear: 0,
  4737. // current selection
  4738. drawMonth: 0,
  4739. drawYear: 0,
  4740. // month being drawn
  4741. inline,
  4742. // is datepicker inline or not
  4743. dpDiv: !inline ? this.dpDiv : (
  4744. // presentation div
  4745. datepicker_bindHover($("<div class='" + this._inlineClass + " ui-datepicker ui-widget ui-widget-content ui-helper-clearfix ui-corner-all'></div>"))
  4746. )
  4747. };
  4748. },
  4749. /* Attach the date picker to an input field. */
  4750. _connectDatepicker: function(target, inst) {
  4751. var input = $(target);
  4752. inst.append = $([]);
  4753. inst.trigger = $([]);
  4754. if (input.hasClass(this.markerClassName)) {
  4755. return;
  4756. }
  4757. this._attachments(input, inst);
  4758. input.addClass(this.markerClassName).on("keydown", this._doKeyDown).on("keypress", this._doKeyPress).on("keyup", this._doKeyUp);
  4759. this._autoSize(inst);
  4760. $.data(target, "datepicker", inst);
  4761. if (inst.settings.disabled) {
  4762. this._disableDatepicker(target);
  4763. }
  4764. },
  4765. /* Make attachments based on settings. */
  4766. _attachments: function(input, inst) {
  4767. var showOn, buttonText, buttonImage, appendText = this._get(inst, "appendText"), isRTL = this._get(inst, "isRTL");
  4768. if (inst.append) {
  4769. inst.append.remove();
  4770. }
  4771. if (appendText) {
  4772. inst.append = $("<span>").addClass(this._appendClass).text(appendText);
  4773. input[isRTL ? "before" : "after"](inst.append);
  4774. }
  4775. input.off("focus", this._showDatepicker);
  4776. if (inst.trigger) {
  4777. inst.trigger.remove();
  4778. }
  4779. showOn = this._get(inst, "showOn");
  4780. if (showOn === "focus" || showOn === "both") {
  4781. input.on("focus", this._showDatepicker);
  4782. }
  4783. if (showOn === "button" || showOn === "both") {
  4784. buttonText = this._get(inst, "buttonText");
  4785. buttonImage = this._get(inst, "buttonImage");
  4786. if (this._get(inst, "buttonImageOnly")) {
  4787. inst.trigger = $("<img>").addClass(this._triggerClass).attr({
  4788. src: buttonImage,
  4789. alt: buttonText,
  4790. title: buttonText
  4791. });
  4792. } else {
  4793. inst.trigger = $("<button type='button'>").addClass(this._triggerClass);
  4794. if (buttonImage) {
  4795. inst.trigger.html(
  4796. $("<img>").attr({
  4797. src: buttonImage,
  4798. alt: buttonText,
  4799. title: buttonText
  4800. })
  4801. );
  4802. } else {
  4803. inst.trigger.text(buttonText);
  4804. }
  4805. }
  4806. input[isRTL ? "before" : "after"](inst.trigger);
  4807. inst.trigger.on("click", function() {
  4808. if ($.datepicker._datepickerShowing && $.datepicker._lastInput === input[0]) {
  4809. $.datepicker._hideDatepicker();
  4810. } else if ($.datepicker._datepickerShowing && $.datepicker._lastInput !== input[0]) {
  4811. $.datepicker._hideDatepicker();
  4812. $.datepicker._showDatepicker(input[0]);
  4813. } else {
  4814. $.datepicker._showDatepicker(input[0]);
  4815. }
  4816. return false;
  4817. });
  4818. }
  4819. },
  4820. /* Apply the maximum length for the date format. */
  4821. _autoSize: function(inst) {
  4822. if (this._get(inst, "autoSize") && !inst.inline) {
  4823. var findMax, max, maxI, i, date = new Date(2009, 12 - 1, 20), dateFormat = this._get(inst, "dateFormat");
  4824. if (dateFormat.match(/[DM]/)) {
  4825. findMax = function(names) {
  4826. max = 0;
  4827. maxI = 0;
  4828. for (i = 0; i < names.length; i++) {
  4829. if (names[i].length > max) {
  4830. max = names[i].length;
  4831. maxI = i;
  4832. }
  4833. }
  4834. return maxI;
  4835. };
  4836. date.setMonth(findMax(this._get(inst, dateFormat.match(/MM/) ? "monthNames" : "monthNamesShort")));
  4837. date.setDate(findMax(this._get(inst, dateFormat.match(/DD/) ? "dayNames" : "dayNamesShort")) + 20 - date.getDay());
  4838. }
  4839. inst.input.attr("size", this._formatDate(inst, date).length);
  4840. }
  4841. },
  4842. /* Attach an inline date picker to a div. */
  4843. _inlineDatepicker: function(target, inst) {
  4844. var divSpan = $(target);
  4845. if (divSpan.hasClass(this.markerClassName)) {
  4846. return;
  4847. }
  4848. divSpan.addClass(this.markerClassName).append(inst.dpDiv);
  4849. $.data(target, "datepicker", inst);
  4850. this._setDate(inst, this._getDefaultDate(inst), true);
  4851. this._updateDatepicker(inst);
  4852. this._updateAlternate(inst);
  4853. if (inst.settings.disabled) {
  4854. this._disableDatepicker(target);
  4855. }
  4856. inst.dpDiv.css("display", "block");
  4857. },
  4858. /* Pop-up the date picker in a "dialog" box.
  4859. * @param input element - ignored
  4860. * @param date string or Date - the initial date to display
  4861. * @param onSelect function - the function to call when a date is selected
  4862. * @param settings object - update the dialog date picker instance's settings (anonymous object)
  4863. * @param pos int[2] - coordinates for the dialog's position within the screen or
  4864. * event - with x/y coordinates or
  4865. * leave empty for default (screen centre)
  4866. * @return the manager object
  4867. */
  4868. _dialogDatepicker: function(input, date, onSelect, settings, pos) {
  4869. var id, browserWidth, browserHeight, scrollX, scrollY, inst = this._dialogInst;
  4870. if (!inst) {
  4871. this.uuid += 1;
  4872. id = "dp" + this.uuid;
  4873. this._dialogInput = $("<input type='text' id='" + id + "' style='position: absolute; top: -100px; width: 0px;'/>");
  4874. this._dialogInput.on("keydown", this._doKeyDown);
  4875. $("body").append(this._dialogInput);
  4876. inst = this._dialogInst = this._newInst(this._dialogInput, false);
  4877. inst.settings = {};
  4878. $.data(this._dialogInput[0], "datepicker", inst);
  4879. }
  4880. datepicker_extendRemove(inst.settings, settings || {});
  4881. date = date && date.constructor === Date ? this._formatDate(inst, date) : date;
  4882. this._dialogInput.val(date);
  4883. this._pos = pos ? pos.length ? pos : [pos.pageX, pos.pageY] : null;
  4884. if (!this._pos) {
  4885. browserWidth = document.documentElement.clientWidth;
  4886. browserHeight = document.documentElement.clientHeight;
  4887. scrollX = document.documentElement.scrollLeft || document.body.scrollLeft;
  4888. scrollY = document.documentElement.scrollTop || document.body.scrollTop;
  4889. this._pos = // should use actual width/height below
  4890. [browserWidth / 2 - 100 + scrollX, browserHeight / 2 - 150 + scrollY];
  4891. }
  4892. this._dialogInput.css("left", this._pos[0] + 20 + "px").css("top", this._pos[1] + "px");
  4893. inst.settings.onSelect = onSelect;
  4894. this._inDialog = true;
  4895. this.dpDiv.addClass(this._dialogClass);
  4896. this._showDatepicker(this._dialogInput[0]);
  4897. if ($.blockUI) {
  4898. $.blockUI(this.dpDiv);
  4899. }
  4900. $.data(this._dialogInput[0], "datepicker", inst);
  4901. return this;
  4902. },
  4903. /* Detach a datepicker from its control.
  4904. * @param target element - the target input field or division or span
  4905. */
  4906. _destroyDatepicker: function(target) {
  4907. var nodeName, $target = $(target), inst = $.data(target, "datepicker");
  4908. if (!$target.hasClass(this.markerClassName)) {
  4909. return;
  4910. }
  4911. nodeName = target.nodeName.toLowerCase();
  4912. $.removeData(target, "datepicker");
  4913. if (nodeName === "input") {
  4914. inst.append.remove();
  4915. inst.trigger.remove();
  4916. $target.removeClass(this.markerClassName).off("focus", this._showDatepicker).off("keydown", this._doKeyDown).off("keypress", this._doKeyPress).off("keyup", this._doKeyUp);
  4917. } else if (nodeName === "div" || nodeName === "span") {
  4918. $target.removeClass(this.markerClassName).empty();
  4919. }
  4920. $.datepicker._hideDatepicker();
  4921. if (datepicker_instActive === inst) {
  4922. datepicker_instActive = null;
  4923. this._curInst = null;
  4924. }
  4925. },
  4926. /* Enable the date picker to a jQuery selection.
  4927. * @param target element - the target input field or division or span
  4928. */
  4929. _enableDatepicker: function(target) {
  4930. var nodeName, inline, $target = $(target), inst = $.data(target, "datepicker");
  4931. if (!$target.hasClass(this.markerClassName)) {
  4932. return;
  4933. }
  4934. nodeName = target.nodeName.toLowerCase();
  4935. if (nodeName === "input") {
  4936. target.disabled = false;
  4937. inst.trigger.filter("button").each(function() {
  4938. this.disabled = false;
  4939. }).end().filter("img").css({ opacity: "1.0", cursor: "" });
  4940. } else if (nodeName === "div" || nodeName === "span") {
  4941. inline = $target.children("." + this._inlineClass);
  4942. inline.children().removeClass("ui-state-disabled");
  4943. inline.find("select.ui-datepicker-month, select.ui-datepicker-year").prop("disabled", false);
  4944. }
  4945. this._disabledInputs = $.map(
  4946. this._disabledInputs,
  4947. // Delete entry
  4948. function(value) {
  4949. return value === target ? null : value;
  4950. }
  4951. );
  4952. },
  4953. /* Disable the date picker to a jQuery selection.
  4954. * @param target element - the target input field or division or span
  4955. */
  4956. _disableDatepicker: function(target) {
  4957. var nodeName, inline, $target = $(target), inst = $.data(target, "datepicker");
  4958. if (!$target.hasClass(this.markerClassName)) {
  4959. return;
  4960. }
  4961. nodeName = target.nodeName.toLowerCase();
  4962. if (nodeName === "input") {
  4963. target.disabled = true;
  4964. inst.trigger.filter("button").each(function() {
  4965. this.disabled = true;
  4966. }).end().filter("img").css({ opacity: "0.5", cursor: "default" });
  4967. } else if (nodeName === "div" || nodeName === "span") {
  4968. inline = $target.children("." + this._inlineClass);
  4969. inline.children().addClass("ui-state-disabled");
  4970. inline.find("select.ui-datepicker-month, select.ui-datepicker-year").prop("disabled", true);
  4971. }
  4972. this._disabledInputs = $.map(
  4973. this._disabledInputs,
  4974. // Delete entry
  4975. function(value) {
  4976. return value === target ? null : value;
  4977. }
  4978. );
  4979. this._disabledInputs[this._disabledInputs.length] = target;
  4980. },
  4981. /* Is the first field in a jQuery collection disabled as a datepicker?
  4982. * @param target element - the target input field or division or span
  4983. * @return boolean - true if disabled, false if enabled
  4984. */
  4985. _isDisabledDatepicker: function(target) {
  4986. if (!target) {
  4987. return false;
  4988. }
  4989. for (var i = 0; i < this._disabledInputs.length; i++) {
  4990. if (this._disabledInputs[i] === target) {
  4991. return true;
  4992. }
  4993. }
  4994. return false;
  4995. },
  4996. /* Retrieve the instance data for the target control.
  4997. * @param target element - the target input field or division or span
  4998. * @return object - the associated instance data
  4999. * @throws error if a jQuery problem getting data
  5000. */
  5001. _getInst: function(target) {
  5002. try {
  5003. return $.data(target, "datepicker");
  5004. } catch (err) {
  5005. throw "Missing instance data for this datepicker";
  5006. }
  5007. },
  5008. /* Update or retrieve the settings for a date picker attached to an input field or division.
  5009. * @param target element - the target input field or division or span
  5010. * @param name object - the new settings to update or
  5011. * string - the name of the setting to change or retrieve,
  5012. * when retrieving also "all" for all instance settings or
  5013. * "defaults" for all global defaults
  5014. * @param value any - the new value for the setting
  5015. * (omit if above is an object or to retrieve a value)
  5016. */
  5017. _optionDatepicker: function(target, name, value) {
  5018. var settings, date, minDate, maxDate, inst = this._getInst(target);
  5019. if (arguments.length === 2 && typeof name === "string") {
  5020. return name === "defaults" ? $.extend({}, $.datepicker._defaults) : inst ? name === "all" ? $.extend({}, inst.settings) : this._get(inst, name) : null;
  5021. }
  5022. settings = name || {};
  5023. if (typeof name === "string") {
  5024. settings = {};
  5025. settings[name] = value;
  5026. }
  5027. if (inst) {
  5028. if (this._curInst === inst) {
  5029. this._hideDatepicker();
  5030. }
  5031. date = this._getDateDatepicker(target, true);
  5032. minDate = this._getMinMaxDate(inst, "min");
  5033. maxDate = this._getMinMaxDate(inst, "max");
  5034. datepicker_extendRemove(inst.settings, settings);
  5035. if (minDate !== null && settings.dateFormat !== void 0 && settings.minDate === void 0) {
  5036. inst.settings.minDate = this._formatDate(inst, minDate);
  5037. }
  5038. if (maxDate !== null && settings.dateFormat !== void 0 && settings.maxDate === void 0) {
  5039. inst.settings.maxDate = this._formatDate(inst, maxDate);
  5040. }
  5041. if ("disabled" in settings) {
  5042. if (settings.disabled) {
  5043. this._disableDatepicker(target);
  5044. } else {
  5045. this._enableDatepicker(target);
  5046. }
  5047. }
  5048. this._attachments($(target), inst);
  5049. this._autoSize(inst);
  5050. this._setDate(inst, date);
  5051. this._updateAlternate(inst);
  5052. this._updateDatepicker(inst);
  5053. }
  5054. },
  5055. // Change method deprecated
  5056. _changeDatepicker: function(target, name, value) {
  5057. this._optionDatepicker(target, name, value);
  5058. },
  5059. /* Redraw the date picker attached to an input field or division.
  5060. * @param target element - the target input field or division or span
  5061. */
  5062. _refreshDatepicker: function(target) {
  5063. var inst = this._getInst(target);
  5064. if (inst) {
  5065. this._updateDatepicker(inst);
  5066. }
  5067. },
  5068. /* Set the dates for a jQuery selection.
  5069. * @param target element - the target input field or division or span
  5070. * @param date Date - the new date
  5071. */
  5072. _setDateDatepicker: function(target, date) {
  5073. var inst = this._getInst(target);
  5074. if (inst) {
  5075. this._setDate(inst, date);
  5076. this._updateDatepicker(inst);
  5077. this._updateAlternate(inst);
  5078. }
  5079. },
  5080. /* Get the date(s) for the first entry in a jQuery selection.
  5081. * @param target element - the target input field or division or span
  5082. * @param noDefault boolean - true if no default date is to be used
  5083. * @return Date - the current date
  5084. */
  5085. _getDateDatepicker: function(target, noDefault) {
  5086. var inst = this._getInst(target);
  5087. if (inst && !inst.inline) {
  5088. this._setDateFromField(inst, noDefault);
  5089. }
  5090. return inst ? this._getDate(inst) : null;
  5091. },
  5092. /* Handle keystrokes. */
  5093. _doKeyDown: function(event) {
  5094. var onSelect, dateStr, sel, inst = $.datepicker._getInst(event.target), handled = true, isRTL = inst.dpDiv.is(".ui-datepicker-rtl");
  5095. inst._keyEvent = true;
  5096. if ($.datepicker._datepickerShowing) {
  5097. switch (event.keyCode) {
  5098. case 9:
  5099. $.datepicker._hideDatepicker();
  5100. handled = false;
  5101. break;
  5102. case 13:
  5103. sel = $("td." + $.datepicker._dayOverClass + ":not(." + $.datepicker._currentClass + ")", inst.dpDiv);
  5104. if (sel[0]) {
  5105. $.datepicker._selectDay(event.target, inst.selectedMonth, inst.selectedYear, sel[0]);
  5106. }
  5107. onSelect = $.datepicker._get(inst, "onSelect");
  5108. if (onSelect) {
  5109. dateStr = $.datepicker._formatDate(inst);
  5110. onSelect.apply(inst.input ? inst.input[0] : null, [dateStr, inst]);
  5111. } else {
  5112. $.datepicker._hideDatepicker();
  5113. }
  5114. return false;
  5115. case 27:
  5116. $.datepicker._hideDatepicker();
  5117. break;
  5118. case 33:
  5119. $.datepicker._adjustDate(event.target, event.ctrlKey ? -$.datepicker._get(inst, "stepBigMonths") : -$.datepicker._get(inst, "stepMonths"), "M");
  5120. break;
  5121. case 34:
  5122. $.datepicker._adjustDate(event.target, event.ctrlKey ? +$.datepicker._get(inst, "stepBigMonths") : +$.datepicker._get(inst, "stepMonths"), "M");
  5123. break;
  5124. case 35:
  5125. if (event.ctrlKey || event.metaKey) {
  5126. $.datepicker._clearDate(event.target);
  5127. }
  5128. handled = event.ctrlKey || event.metaKey;
  5129. break;
  5130. case 36:
  5131. if (event.ctrlKey || event.metaKey) {
  5132. $.datepicker._gotoToday(event.target);
  5133. }
  5134. handled = event.ctrlKey || event.metaKey;
  5135. break;
  5136. case 37:
  5137. if (event.ctrlKey || event.metaKey) {
  5138. $.datepicker._adjustDate(event.target, isRTL ? 1 : -1, "D");
  5139. }
  5140. handled = event.ctrlKey || event.metaKey;
  5141. if (event.originalEvent.altKey) {
  5142. $.datepicker._adjustDate(event.target, event.ctrlKey ? -$.datepicker._get(inst, "stepBigMonths") : -$.datepicker._get(inst, "stepMonths"), "M");
  5143. }
  5144. break;
  5145. case 38:
  5146. if (event.ctrlKey || event.metaKey) {
  5147. $.datepicker._adjustDate(event.target, -7, "D");
  5148. }
  5149. handled = event.ctrlKey || event.metaKey;
  5150. break;
  5151. case 39:
  5152. if (event.ctrlKey || event.metaKey) {
  5153. $.datepicker._adjustDate(event.target, isRTL ? -1 : 1, "D");
  5154. }
  5155. handled = event.ctrlKey || event.metaKey;
  5156. if (event.originalEvent.altKey) {
  5157. $.datepicker._adjustDate(event.target, event.ctrlKey ? +$.datepicker._get(inst, "stepBigMonths") : +$.datepicker._get(inst, "stepMonths"), "M");
  5158. }
  5159. break;
  5160. case 40:
  5161. if (event.ctrlKey || event.metaKey) {
  5162. $.datepicker._adjustDate(event.target, 7, "D");
  5163. }
  5164. handled = event.ctrlKey || event.metaKey;
  5165. break;
  5166. default:
  5167. handled = false;
  5168. }
  5169. } else if (event.keyCode === 36 && event.ctrlKey) {
  5170. $.datepicker._showDatepicker(this);
  5171. } else {
  5172. handled = false;
  5173. }
  5174. if (handled) {
  5175. event.preventDefault();
  5176. event.stopPropagation();
  5177. }
  5178. },
  5179. /* Filter entered characters - based on date format. */
  5180. _doKeyPress: function(event) {
  5181. var chars, chr, inst = $.datepicker._getInst(event.target);
  5182. if ($.datepicker._get(inst, "constrainInput")) {
  5183. chars = $.datepicker._possibleChars($.datepicker._get(inst, "dateFormat"));
  5184. chr = String.fromCharCode(event.charCode == null ? event.keyCode : event.charCode);
  5185. return event.ctrlKey || event.metaKey || (chr < " " || !chars || chars.indexOf(chr) > -1);
  5186. }
  5187. },
  5188. /* Synchronise manual entry and field/alternate field. */
  5189. _doKeyUp: function(event) {
  5190. var date, inst = $.datepicker._getInst(event.target);
  5191. if (inst.input.val() !== inst.lastVal) {
  5192. try {
  5193. date = $.datepicker.parseDate(
  5194. $.datepicker._get(inst, "dateFormat"),
  5195. inst.input ? inst.input.val() : null,
  5196. $.datepicker._getFormatConfig(inst)
  5197. );
  5198. if (date) {
  5199. $.datepicker._setDateFromField(inst);
  5200. $.datepicker._updateAlternate(inst);
  5201. $.datepicker._updateDatepicker(inst);
  5202. }
  5203. } catch (err) {
  5204. }
  5205. }
  5206. return true;
  5207. },
  5208. /* Pop-up the date picker for a given input field.
  5209. * If false returned from beforeShow event handler do not show.
  5210. * @param input element - the input field attached to the date picker or
  5211. * event - if triggered by focus
  5212. */
  5213. _showDatepicker: function(input) {
  5214. input = input.target || input;
  5215. if (input.nodeName.toLowerCase() !== "input") {
  5216. input = $("input", input.parentNode)[0];
  5217. }
  5218. if ($.datepicker._isDisabledDatepicker(input) || $.datepicker._lastInput === input) {
  5219. return;
  5220. }
  5221. var inst, beforeShow, beforeShowSettings, isFixed, offset, showAnim, duration;
  5222. inst = $.datepicker._getInst(input);
  5223. if ($.datepicker._curInst && $.datepicker._curInst !== inst) {
  5224. $.datepicker._curInst.dpDiv.stop(true, true);
  5225. if (inst && $.datepicker._datepickerShowing) {
  5226. $.datepicker._hideDatepicker($.datepicker._curInst.input[0]);
  5227. }
  5228. }
  5229. beforeShow = $.datepicker._get(inst, "beforeShow");
  5230. beforeShowSettings = beforeShow ? beforeShow.apply(input, [input, inst]) : {};
  5231. if (beforeShowSettings === false) {
  5232. return;
  5233. }
  5234. datepicker_extendRemove(inst.settings, beforeShowSettings);
  5235. inst.lastVal = null;
  5236. $.datepicker._lastInput = input;
  5237. $.datepicker._setDateFromField(inst);
  5238. if ($.datepicker._inDialog) {
  5239. input.value = "";
  5240. }
  5241. if (!$.datepicker._pos) {
  5242. $.datepicker._pos = $.datepicker._findPos(input);
  5243. $.datepicker._pos[1] += input.offsetHeight;
  5244. }
  5245. isFixed = false;
  5246. $(input).parents().each(function() {
  5247. isFixed |= $(this).css("position") === "fixed";
  5248. return !isFixed;
  5249. });
  5250. offset = { left: $.datepicker._pos[0], top: $.datepicker._pos[1] };
  5251. $.datepicker._pos = null;
  5252. inst.dpDiv.empty();
  5253. inst.dpDiv.css({ position: "absolute", display: "block", top: "-1000px" });
  5254. $.datepicker._updateDatepicker(inst);
  5255. offset = $.datepicker._checkOffset(inst, offset, isFixed);
  5256. inst.dpDiv.css({
  5257. position: $.datepicker._inDialog && $.blockUI ? "static" : isFixed ? "fixed" : "absolute",
  5258. display: "none",
  5259. left: offset.left + "px",
  5260. top: offset.top + "px"
  5261. });
  5262. if (!inst.inline) {
  5263. showAnim = $.datepicker._get(inst, "showAnim");
  5264. duration = $.datepicker._get(inst, "duration");
  5265. inst.dpDiv.css("z-index", datepicker_getZindex($(input)) + 1);
  5266. $.datepicker._datepickerShowing = true;
  5267. if ($.effects && $.effects.effect[showAnim]) {
  5268. inst.dpDiv.show(showAnim, $.datepicker._get(inst, "showOptions"), duration);
  5269. } else {
  5270. inst.dpDiv[showAnim || "show"](showAnim ? duration : null);
  5271. }
  5272. if ($.datepicker._shouldFocusInput(inst)) {
  5273. inst.input.trigger("focus");
  5274. }
  5275. $.datepicker._curInst = inst;
  5276. }
  5277. },
  5278. /* Generate the date picker content. */
  5279. _updateDatepicker: function(inst) {
  5280. this.maxRows = 4;
  5281. datepicker_instActive = inst;
  5282. inst.dpDiv.empty().append(this._generateHTML(inst));
  5283. this._attachHandlers(inst);
  5284. var origyearshtml, numMonths = this._getNumberOfMonths(inst), cols = numMonths[1], width = 17, activeCell = inst.dpDiv.find("." + this._dayOverClass + " a"), onUpdateDatepicker = $.datepicker._get(inst, "onUpdateDatepicker");
  5285. if (activeCell.length > 0) {
  5286. datepicker_handleMouseover.apply(activeCell.get(0));
  5287. }
  5288. inst.dpDiv.removeClass("ui-datepicker-multi-2 ui-datepicker-multi-3 ui-datepicker-multi-4").width("");
  5289. if (cols > 1) {
  5290. inst.dpDiv.addClass("ui-datepicker-multi-" + cols).css("width", width * cols + "em");
  5291. }
  5292. inst.dpDiv[(numMonths[0] !== 1 || numMonths[1] !== 1 ? "add" : "remove") + "Class"]("ui-datepicker-multi");
  5293. inst.dpDiv[(this._get(inst, "isRTL") ? "add" : "remove") + "Class"]("ui-datepicker-rtl");
  5294. if (inst === $.datepicker._curInst && $.datepicker._datepickerShowing && $.datepicker._shouldFocusInput(inst)) {
  5295. inst.input.trigger("focus");
  5296. }
  5297. if (inst.yearshtml) {
  5298. origyearshtml = inst.yearshtml;
  5299. setTimeout(function() {
  5300. if (origyearshtml === inst.yearshtml && inst.yearshtml) {
  5301. inst.dpDiv.find("select.ui-datepicker-year").first().replaceWith(inst.yearshtml);
  5302. }
  5303. origyearshtml = inst.yearshtml = null;
  5304. }, 0);
  5305. }
  5306. if (onUpdateDatepicker) {
  5307. onUpdateDatepicker.apply(inst.input ? inst.input[0] : null, [inst]);
  5308. }
  5309. },
  5310. _shouldFocusInput: function(inst) {
  5311. return inst.input && inst.input.is(":visible") && !inst.input.is(":disabled");
  5312. },
  5313. /* Check positioning to remain on screen. */
  5314. _checkOffset: function(inst, offset, isFixed) {
  5315. var dpWidth = inst.dpDiv.outerWidth(), dpHeight = inst.dpDiv.outerHeight(), inputWidth = inst.input ? inst.input.outerWidth() : 0, inputHeight = inst.input ? inst.input.outerHeight() : 0, viewWidth = document.documentElement.clientWidth + (isFixed ? 0 : $(document).scrollLeft()), viewHeight = document.documentElement.clientHeight + (isFixed ? 0 : $(document).scrollTop());
  5316. offset.left -= this._get(inst, "isRTL") ? dpWidth - inputWidth : 0;
  5317. offset.left -= isFixed && offset.left === inst.input.offset().left ? $(document).scrollLeft() : 0;
  5318. offset.top -= isFixed && offset.top === inst.input.offset().top + inputHeight ? $(document).scrollTop() : 0;
  5319. offset.left -= Math.min(offset.left, offset.left + dpWidth > viewWidth && viewWidth > dpWidth ? Math.abs(offset.left + dpWidth - viewWidth) : 0);
  5320. offset.top -= Math.min(offset.top, offset.top + dpHeight > viewHeight && viewHeight > dpHeight ? Math.abs(dpHeight + inputHeight) : 0);
  5321. return offset;
  5322. },
  5323. /* Find an object's position on the screen. */
  5324. _findPos: function(obj) {
  5325. var position2, inst = this._getInst(obj), isRTL = this._get(inst, "isRTL");
  5326. while (obj && (obj.type === "hidden" || obj.nodeType !== 1 || $.expr.pseudos.hidden(obj))) {
  5327. obj = obj[isRTL ? "previousSibling" : "nextSibling"];
  5328. }
  5329. position2 = $(obj).offset();
  5330. return [position2.left, position2.top];
  5331. },
  5332. /* Hide the date picker from view.
  5333. * @param input element - the input field attached to the date picker
  5334. */
  5335. _hideDatepicker: function(input) {
  5336. var showAnim, duration, postProcess, onClose, inst = this._curInst;
  5337. if (!inst || input && inst !== $.data(input, "datepicker")) {
  5338. return;
  5339. }
  5340. if (this._datepickerShowing) {
  5341. showAnim = this._get(inst, "showAnim");
  5342. duration = this._get(inst, "duration");
  5343. postProcess = function() {
  5344. $.datepicker._tidyDialog(inst);
  5345. };
  5346. if ($.effects && $.effects.effect[showAnim]) {
  5347. inst.dpDiv.hide(showAnim, $.datepicker._get(inst, "showOptions"), duration, postProcess);
  5348. } else {
  5349. inst.dpDiv[showAnim === "slideDown" ? "slideUp" : showAnim === "fadeIn" ? "fadeOut" : "hide"](showAnim ? duration : null, postProcess);
  5350. }
  5351. if (!showAnim) {
  5352. postProcess();
  5353. }
  5354. this._datepickerShowing = false;
  5355. onClose = this._get(inst, "onClose");
  5356. if (onClose) {
  5357. onClose.apply(inst.input ? inst.input[0] : null, [inst.input ? inst.input.val() : "", inst]);
  5358. }
  5359. this._lastInput = null;
  5360. if (this._inDialog) {
  5361. this._dialogInput.css({ position: "absolute", left: "0", top: "-100px" });
  5362. if ($.blockUI) {
  5363. $.unblockUI();
  5364. $("body").append(this.dpDiv);
  5365. }
  5366. }
  5367. this._inDialog = false;
  5368. }
  5369. },
  5370. /* Tidy up after a dialog display. */
  5371. _tidyDialog: function(inst) {
  5372. inst.dpDiv.removeClass(this._dialogClass).off(".ui-datepicker-calendar");
  5373. },
  5374. /* Close date picker if clicked elsewhere. */
  5375. _checkExternalClick: function(event) {
  5376. if (!$.datepicker._curInst) {
  5377. return;
  5378. }
  5379. var $target = $(event.target), inst = $.datepicker._getInst($target[0]);
  5380. if ($target[0].id !== $.datepicker._mainDivId && $target.parents("#" + $.datepicker._mainDivId).length === 0 && !$target.hasClass($.datepicker.markerClassName) && !$target.closest("." + $.datepicker._triggerClass).length && $.datepicker._datepickerShowing && !($.datepicker._inDialog && $.blockUI) || $target.hasClass($.datepicker.markerClassName) && $.datepicker._curInst !== inst) {
  5381. $.datepicker._hideDatepicker();
  5382. }
  5383. },
  5384. /* Adjust one of the date sub-fields. */
  5385. _adjustDate: function(id, offset, period) {
  5386. var target = $(id), inst = this._getInst(target[0]);
  5387. if (this._isDisabledDatepicker(target[0])) {
  5388. return;
  5389. }
  5390. this._adjustInstDate(inst, offset, period);
  5391. this._updateDatepicker(inst);
  5392. },
  5393. /* Action for current link. */
  5394. _gotoToday: function(id) {
  5395. var date, target = $(id), inst = this._getInst(target[0]);
  5396. if (this._get(inst, "gotoCurrent") && inst.currentDay) {
  5397. inst.selectedDay = inst.currentDay;
  5398. inst.drawMonth = inst.selectedMonth = inst.currentMonth;
  5399. inst.drawYear = inst.selectedYear = inst.currentYear;
  5400. } else {
  5401. date = /* @__PURE__ */ new Date();
  5402. inst.selectedDay = date.getDate();
  5403. inst.drawMonth = inst.selectedMonth = date.getMonth();
  5404. inst.drawYear = inst.selectedYear = date.getFullYear();
  5405. }
  5406. this._notifyChange(inst);
  5407. this._adjustDate(target);
  5408. },
  5409. /* Action for selecting a new month/year. */
  5410. _selectMonthYear: function(id, select, period) {
  5411. var target = $(id), inst = this._getInst(target[0]);
  5412. inst["selected" + (period === "M" ? "Month" : "Year")] = inst["draw" + (period === "M" ? "Month" : "Year")] = parseInt(select.options[select.selectedIndex].value, 10);
  5413. this._notifyChange(inst);
  5414. this._adjustDate(target);
  5415. },
  5416. /* Action for selecting a day. */
  5417. _selectDay: function(id, month, year, td) {
  5418. var inst, target = $(id);
  5419. if ($(td).hasClass(this._unselectableClass) || this._isDisabledDatepicker(target[0])) {
  5420. return;
  5421. }
  5422. inst = this._getInst(target[0]);
  5423. inst.selectedDay = inst.currentDay = parseInt($("a", td).attr("data-date"));
  5424. inst.selectedMonth = inst.currentMonth = month;
  5425. inst.selectedYear = inst.currentYear = year;
  5426. this._selectDate(id, this._formatDate(
  5427. inst,
  5428. inst.currentDay,
  5429. inst.currentMonth,
  5430. inst.currentYear
  5431. ));
  5432. },
  5433. /* Erase the input field and hide the date picker. */
  5434. _clearDate: function(id) {
  5435. var target = $(id);
  5436. this._selectDate(target, "");
  5437. },
  5438. /* Update the input field with the selected date. */
  5439. _selectDate: function(id, dateStr) {
  5440. var onSelect, target = $(id), inst = this._getInst(target[0]);
  5441. dateStr = dateStr != null ? dateStr : this._formatDate(inst);
  5442. if (inst.input) {
  5443. inst.input.val(dateStr);
  5444. }
  5445. this._updateAlternate(inst);
  5446. onSelect = this._get(inst, "onSelect");
  5447. if (onSelect) {
  5448. onSelect.apply(inst.input ? inst.input[0] : null, [dateStr, inst]);
  5449. } else if (inst.input) {
  5450. inst.input.trigger("change");
  5451. }
  5452. if (inst.inline) {
  5453. this._updateDatepicker(inst);
  5454. } else {
  5455. this._hideDatepicker();
  5456. this._lastInput = inst.input[0];
  5457. if (typeof inst.input[0] !== "object") {
  5458. inst.input.trigger("focus");
  5459. }
  5460. this._lastInput = null;
  5461. }
  5462. },
  5463. /* Update any alternate field to synchronise with the main field. */
  5464. _updateAlternate: function(inst) {
  5465. var altFormat, date, dateStr, altField = this._get(inst, "altField");
  5466. if (altField) {
  5467. altFormat = this._get(inst, "altFormat") || this._get(inst, "dateFormat");
  5468. date = this._getDate(inst);
  5469. dateStr = this.formatDate(altFormat, date, this._getFormatConfig(inst));
  5470. $(document).find(altField).val(dateStr);
  5471. }
  5472. },
  5473. /* Set as beforeShowDay function to prevent selection of weekends.
  5474. * @param date Date - the date to customise
  5475. * @return [boolean, string] - is this date selectable?, what is its CSS class?
  5476. */
  5477. noWeekends: function(date) {
  5478. var day = date.getDay();
  5479. return [day > 0 && day < 6, ""];
  5480. },
  5481. /* Set as calculateWeek to determine the week of the year based on the ISO 8601 definition.
  5482. * @param date Date - the date to get the week for
  5483. * @return number - the number of the week within the year that contains this date
  5484. */
  5485. iso8601Week: function(date) {
  5486. var time, checkDate = new Date(date.getTime());
  5487. checkDate.setDate(checkDate.getDate() + 4 - (checkDate.getDay() || 7));
  5488. time = checkDate.getTime();
  5489. checkDate.setMonth(0);
  5490. checkDate.setDate(1);
  5491. return Math.floor(Math.round((time - checkDate) / 864e5) / 7) + 1;
  5492. },
  5493. /* Parse a string value into a date object.
  5494. * See formatDate below for the possible formats.
  5495. *
  5496. * @param format string - the expected format of the date
  5497. * @param value string - the date in the above format
  5498. * @param settings Object - attributes include:
  5499. * shortYearCutoff number - the cutoff year for determining the century (optional)
  5500. * dayNamesShort string[7] - abbreviated names of the days from Sunday (optional)
  5501. * dayNames string[7] - names of the days from Sunday (optional)
  5502. * monthNamesShort string[12] - abbreviated names of the months (optional)
  5503. * monthNames string[12] - names of the months (optional)
  5504. * @return Date - the extracted date value or null if value is blank
  5505. */
  5506. parseDate: function(format, value, settings) {
  5507. if (format == null || value == null) {
  5508. throw "Invalid arguments";
  5509. }
  5510. value = typeof value === "object" ? value.toString() : value + "";
  5511. if (value === "") {
  5512. return null;
  5513. }
  5514. var iFormat, dim, extra, iValue = 0, shortYearCutoffTemp = (settings ? settings.shortYearCutoff : null) || this._defaults.shortYearCutoff, shortYearCutoff = typeof shortYearCutoffTemp !== "string" ? shortYearCutoffTemp : (/* @__PURE__ */ new Date()).getFullYear() % 100 + parseInt(shortYearCutoffTemp, 10), dayNamesShort = (settings ? settings.dayNamesShort : null) || this._defaults.dayNamesShort, dayNames = (settings ? settings.dayNames : null) || this._defaults.dayNames, monthNamesShort = (settings ? settings.monthNamesShort : null) || this._defaults.monthNamesShort, monthNames = (settings ? settings.monthNames : null) || this._defaults.monthNames, year = -1, month = -1, day = -1, doy = -1, literal = false, date, lookAhead = function(match) {
  5515. var matches = iFormat + 1 < format.length && format.charAt(iFormat + 1) === match;
  5516. if (matches) {
  5517. iFormat++;
  5518. }
  5519. return matches;
  5520. }, getNumber = function(match) {
  5521. var isDoubled = lookAhead(match), size = match === "@" ? 14 : match === "!" ? 20 : match === "y" && isDoubled ? 4 : match === "o" ? 3 : 2, minSize = match === "y" ? size : 1, digits = new RegExp("^\\d{" + minSize + "," + size + "}"), num = value.substring(iValue).match(digits);
  5522. if (!num) {
  5523. throw "Missing number at position " + iValue;
  5524. }
  5525. iValue += num[0].length;
  5526. return parseInt(num[0], 10);
  5527. }, getName = function(match, shortNames, longNames) {
  5528. var index = -1, names = $.map(lookAhead(match) ? longNames : shortNames, function(v, k) {
  5529. return [[k, v]];
  5530. }).sort(function(a, b) {
  5531. return -(a[1].length - b[1].length);
  5532. });
  5533. $.each(names, function(i, pair) {
  5534. var name = pair[1];
  5535. if (value.substr(iValue, name.length).toLowerCase() === name.toLowerCase()) {
  5536. index = pair[0];
  5537. iValue += name.length;
  5538. return false;
  5539. }
  5540. });
  5541. if (index !== -1) {
  5542. return index + 1;
  5543. } else {
  5544. throw "Unknown name at position " + iValue;
  5545. }
  5546. }, checkLiteral = function() {
  5547. if (value.charAt(iValue) !== format.charAt(iFormat)) {
  5548. throw "Unexpected literal at position " + iValue;
  5549. }
  5550. iValue++;
  5551. };
  5552. for (iFormat = 0; iFormat < format.length; iFormat++) {
  5553. if (literal) {
  5554. if (format.charAt(iFormat) === "'" && !lookAhead("'")) {
  5555. literal = false;
  5556. } else {
  5557. checkLiteral();
  5558. }
  5559. } else {
  5560. switch (format.charAt(iFormat)) {
  5561. case "d":
  5562. day = getNumber("d");
  5563. break;
  5564. case "D":
  5565. getName("D", dayNamesShort, dayNames);
  5566. break;
  5567. case "o":
  5568. doy = getNumber("o");
  5569. break;
  5570. case "m":
  5571. month = getNumber("m");
  5572. break;
  5573. case "M":
  5574. month = getName("M", monthNamesShort, monthNames);
  5575. break;
  5576. case "y":
  5577. year = getNumber("y");
  5578. break;
  5579. case "@":
  5580. date = new Date(getNumber("@"));
  5581. year = date.getFullYear();
  5582. month = date.getMonth() + 1;
  5583. day = date.getDate();
  5584. break;
  5585. case "!":
  5586. date = new Date((getNumber("!") - this._ticksTo1970) / 1e4);
  5587. year = date.getFullYear();
  5588. month = date.getMonth() + 1;
  5589. day = date.getDate();
  5590. break;
  5591. case "'":
  5592. if (lookAhead("'")) {
  5593. checkLiteral();
  5594. } else {
  5595. literal = true;
  5596. }
  5597. break;
  5598. default:
  5599. checkLiteral();
  5600. }
  5601. }
  5602. }
  5603. if (iValue < value.length) {
  5604. extra = value.substr(iValue);
  5605. if (!/^\s+/.test(extra)) {
  5606. throw "Extra/unparsed characters found in date: " + extra;
  5607. }
  5608. }
  5609. if (year === -1) {
  5610. year = (/* @__PURE__ */ new Date()).getFullYear();
  5611. } else if (year < 100) {
  5612. year += (/* @__PURE__ */ new Date()).getFullYear() - (/* @__PURE__ */ new Date()).getFullYear() % 100 + (year <= shortYearCutoff ? 0 : -100);
  5613. }
  5614. if (doy > -1) {
  5615. month = 1;
  5616. day = doy;
  5617. do {
  5618. dim = this._getDaysInMonth(year, month - 1);
  5619. if (day <= dim) {
  5620. break;
  5621. }
  5622. month++;
  5623. day -= dim;
  5624. } while (true);
  5625. }
  5626. date = this._daylightSavingAdjust(new Date(year, month - 1, day));
  5627. if (date.getFullYear() !== year || date.getMonth() + 1 !== month || date.getDate() !== day) {
  5628. throw "Invalid date";
  5629. }
  5630. return date;
  5631. },
  5632. /* Standard date formats. */
  5633. ATOM: "yy-mm-dd",
  5634. // RFC 3339 (ISO 8601)
  5635. COOKIE: "D, dd M yy",
  5636. ISO_8601: "yy-mm-dd",
  5637. RFC_822: "D, d M y",
  5638. RFC_850: "DD, dd-M-y",
  5639. RFC_1036: "D, d M y",
  5640. RFC_1123: "D, d M yy",
  5641. RFC_2822: "D, d M yy",
  5642. RSS: "D, d M y",
  5643. // RFC 822
  5644. TICKS: "!",
  5645. TIMESTAMP: "@",
  5646. W3C: "yy-mm-dd",
  5647. // ISO 8601
  5648. _ticksTo1970: ((1970 - 1) * 365 + Math.floor(1970 / 4) - Math.floor(1970 / 100) + Math.floor(1970 / 400)) * 24 * 60 * 60 * 1e7,
  5649. /* Format a date object into a string value.
  5650. * The format can be combinations of the following:
  5651. * d - day of month (no leading zero)
  5652. * dd - day of month (two digit)
  5653. * o - day of year (no leading zeros)
  5654. * oo - day of year (three digit)
  5655. * D - day name short
  5656. * DD - day name long
  5657. * m - month of year (no leading zero)
  5658. * mm - month of year (two digit)
  5659. * M - month name short
  5660. * MM - month name long
  5661. * y - year (two digit)
  5662. * yy - year (four digit)
  5663. * @ - Unix timestamp (ms since 01/01/1970)
  5664. * ! - Windows ticks (100ns since 01/01/0001)
  5665. * "..." - literal text
  5666. * '' - single quote
  5667. *
  5668. * @param format string - the desired format of the date
  5669. * @param date Date - the date value to format
  5670. * @param settings Object - attributes include:
  5671. * dayNamesShort string[7] - abbreviated names of the days from Sunday (optional)
  5672. * dayNames string[7] - names of the days from Sunday (optional)
  5673. * monthNamesShort string[12] - abbreviated names of the months (optional)
  5674. * monthNames string[12] - names of the months (optional)
  5675. * @return string - the date in the above format
  5676. */
  5677. formatDate: function(format, date, settings) {
  5678. if (!date) {
  5679. return "";
  5680. }
  5681. var iFormat, dayNamesShort = (settings ? settings.dayNamesShort : null) || this._defaults.dayNamesShort, dayNames = (settings ? settings.dayNames : null) || this._defaults.dayNames, monthNamesShort = (settings ? settings.monthNamesShort : null) || this._defaults.monthNamesShort, monthNames = (settings ? settings.monthNames : null) || this._defaults.monthNames, lookAhead = function(match) {
  5682. var matches = iFormat + 1 < format.length && format.charAt(iFormat + 1) === match;
  5683. if (matches) {
  5684. iFormat++;
  5685. }
  5686. return matches;
  5687. }, formatNumber = function(match, value, len) {
  5688. var num = "" + value;
  5689. if (lookAhead(match)) {
  5690. while (num.length < len) {
  5691. num = "0" + num;
  5692. }
  5693. }
  5694. return num;
  5695. }, formatName = function(match, value, shortNames, longNames) {
  5696. return lookAhead(match) ? longNames[value] : shortNames[value];
  5697. }, output = "", literal = false;
  5698. if (date) {
  5699. for (iFormat = 0; iFormat < format.length; iFormat++) {
  5700. if (literal) {
  5701. if (format.charAt(iFormat) === "'" && !lookAhead("'")) {
  5702. literal = false;
  5703. } else {
  5704. output += format.charAt(iFormat);
  5705. }
  5706. } else {
  5707. switch (format.charAt(iFormat)) {
  5708. case "d":
  5709. output += formatNumber("d", date.getDate(), 2);
  5710. break;
  5711. case "D":
  5712. output += formatName("D", date.getDay(), dayNamesShort, dayNames);
  5713. break;
  5714. case "o":
  5715. output += formatNumber(
  5716. "o",
  5717. Math.round((new Date(date.getFullYear(), date.getMonth(), date.getDate()).getTime() - new Date(date.getFullYear(), 0, 0).getTime()) / 864e5),
  5718. 3
  5719. );
  5720. break;
  5721. case "m":
  5722. output += formatNumber("m", date.getMonth() + 1, 2);
  5723. break;
  5724. case "M":
  5725. output += formatName("M", date.getMonth(), monthNamesShort, monthNames);
  5726. break;
  5727. case "y":
  5728. output += lookAhead("y") ? date.getFullYear() : (date.getFullYear() % 100 < 10 ? "0" : "") + date.getFullYear() % 100;
  5729. break;
  5730. case "@":
  5731. output += date.getTime();
  5732. break;
  5733. case "!":
  5734. output += date.getTime() * 1e4 + this._ticksTo1970;
  5735. break;
  5736. case "'":
  5737. if (lookAhead("'")) {
  5738. output += "'";
  5739. } else {
  5740. literal = true;
  5741. }
  5742. break;
  5743. default:
  5744. output += format.charAt(iFormat);
  5745. }
  5746. }
  5747. }
  5748. }
  5749. return output;
  5750. },
  5751. /* Extract all possible characters from the date format. */
  5752. _possibleChars: function(format) {
  5753. var iFormat, chars = "", literal = false, lookAhead = function(match) {
  5754. var matches = iFormat + 1 < format.length && format.charAt(iFormat + 1) === match;
  5755. if (matches) {
  5756. iFormat++;
  5757. }
  5758. return matches;
  5759. };
  5760. for (iFormat = 0; iFormat < format.length; iFormat++) {
  5761. if (literal) {
  5762. if (format.charAt(iFormat) === "'" && !lookAhead("'")) {
  5763. literal = false;
  5764. } else {
  5765. chars += format.charAt(iFormat);
  5766. }
  5767. } else {
  5768. switch (format.charAt(iFormat)) {
  5769. case "d":
  5770. case "m":
  5771. case "y":
  5772. case "@":
  5773. chars += "0123456789";
  5774. break;
  5775. case "D":
  5776. case "M":
  5777. return null;
  5778. case "'":
  5779. if (lookAhead("'")) {
  5780. chars += "'";
  5781. } else {
  5782. literal = true;
  5783. }
  5784. break;
  5785. default:
  5786. chars += format.charAt(iFormat);
  5787. }
  5788. }
  5789. }
  5790. return chars;
  5791. },
  5792. /* Get a setting value, defaulting if necessary. */
  5793. _get: function(inst, name) {
  5794. return inst.settings[name] !== void 0 ? inst.settings[name] : this._defaults[name];
  5795. },
  5796. /* Parse existing date and initialise date picker. */
  5797. _setDateFromField: function(inst, noDefault) {
  5798. if (inst.input.val() === inst.lastVal) {
  5799. return;
  5800. }
  5801. var dateFormat = this._get(inst, "dateFormat"), dates = inst.lastVal = inst.input ? inst.input.val() : null, defaultDate = this._getDefaultDate(inst), date = defaultDate, settings = this._getFormatConfig(inst);
  5802. try {
  5803. date = this.parseDate(dateFormat, dates, settings) || defaultDate;
  5804. } catch (event) {
  5805. dates = noDefault ? "" : dates;
  5806. }
  5807. inst.selectedDay = date.getDate();
  5808. inst.drawMonth = inst.selectedMonth = date.getMonth();
  5809. inst.drawYear = inst.selectedYear = date.getFullYear();
  5810. inst.currentDay = dates ? date.getDate() : 0;
  5811. inst.currentMonth = dates ? date.getMonth() : 0;
  5812. inst.currentYear = dates ? date.getFullYear() : 0;
  5813. this._adjustInstDate(inst);
  5814. },
  5815. /* Retrieve the default date shown on opening. */
  5816. _getDefaultDate: function(inst) {
  5817. return this._restrictMinMax(
  5818. inst,
  5819. this._determineDate(inst, this._get(inst, "defaultDate"), /* @__PURE__ */ new Date())
  5820. );
  5821. },
  5822. /* A date may be specified as an exact value or a relative one. */
  5823. _determineDate: function(inst, date, defaultDate) {
  5824. var offsetNumeric = function(offset) {
  5825. var date2 = /* @__PURE__ */ new Date();
  5826. date2.setDate(date2.getDate() + offset);
  5827. return date2;
  5828. }, offsetString = function(offset) {
  5829. try {
  5830. return $.datepicker.parseDate(
  5831. $.datepicker._get(inst, "dateFormat"),
  5832. offset,
  5833. $.datepicker._getFormatConfig(inst)
  5834. );
  5835. } catch (e) {
  5836. }
  5837. var date2 = (offset.toLowerCase().match(/^c/) ? $.datepicker._getDate(inst) : null) || /* @__PURE__ */ new Date(), year = date2.getFullYear(), month = date2.getMonth(), day = date2.getDate(), pattern = /([+\-]?[0-9]+)\s*(d|D|w|W|m|M|y|Y)?/g, matches = pattern.exec(offset);
  5838. while (matches) {
  5839. switch (matches[2] || "d") {
  5840. case "d":
  5841. case "D":
  5842. day += parseInt(matches[1], 10);
  5843. break;
  5844. case "w":
  5845. case "W":
  5846. day += parseInt(matches[1], 10) * 7;
  5847. break;
  5848. case "m":
  5849. case "M":
  5850. month += parseInt(matches[1], 10);
  5851. day = Math.min(day, $.datepicker._getDaysInMonth(year, month));
  5852. break;
  5853. case "y":
  5854. case "Y":
  5855. year += parseInt(matches[1], 10);
  5856. day = Math.min(day, $.datepicker._getDaysInMonth(year, month));
  5857. break;
  5858. }
  5859. matches = pattern.exec(offset);
  5860. }
  5861. return new Date(year, month, day);
  5862. }, newDate = date == null || date === "" ? defaultDate : typeof date === "string" ? offsetString(date) : typeof date === "number" ? isNaN(date) ? defaultDate : offsetNumeric(date) : new Date(date.getTime());
  5863. newDate = newDate && newDate.toString() === "Invalid Date" ? defaultDate : newDate;
  5864. if (newDate) {
  5865. newDate.setHours(0);
  5866. newDate.setMinutes(0);
  5867. newDate.setSeconds(0);
  5868. newDate.setMilliseconds(0);
  5869. }
  5870. return this._daylightSavingAdjust(newDate);
  5871. },
  5872. /* Handle switch to/from daylight saving.
  5873. * Hours may be non-zero on daylight saving cut-over:
  5874. * > 12 when midnight changeover, but then cannot generate
  5875. * midnight datetime, so jump to 1AM, otherwise reset.
  5876. * @param date (Date) the date to check
  5877. * @return (Date) the corrected date
  5878. */
  5879. _daylightSavingAdjust: function(date) {
  5880. if (!date) {
  5881. return null;
  5882. }
  5883. date.setHours(date.getHours() > 12 ? date.getHours() + 2 : 0);
  5884. return date;
  5885. },
  5886. /* Set the date(s) directly. */
  5887. _setDate: function(inst, date, noChange) {
  5888. var clear = !date, origMonth = inst.selectedMonth, origYear = inst.selectedYear, newDate = this._restrictMinMax(inst, this._determineDate(inst, date, /* @__PURE__ */ new Date()));
  5889. inst.selectedDay = inst.currentDay = newDate.getDate();
  5890. inst.drawMonth = inst.selectedMonth = inst.currentMonth = newDate.getMonth();
  5891. inst.drawYear = inst.selectedYear = inst.currentYear = newDate.getFullYear();
  5892. if ((origMonth !== inst.selectedMonth || origYear !== inst.selectedYear) && !noChange) {
  5893. this._notifyChange(inst);
  5894. }
  5895. this._adjustInstDate(inst);
  5896. if (inst.input) {
  5897. inst.input.val(clear ? "" : this._formatDate(inst));
  5898. }
  5899. },
  5900. /* Retrieve the date(s) directly. */
  5901. _getDate: function(inst) {
  5902. var startDate = !inst.currentYear || inst.input && inst.input.val() === "" ? null : this._daylightSavingAdjust(new Date(
  5903. inst.currentYear,
  5904. inst.currentMonth,
  5905. inst.currentDay
  5906. ));
  5907. return startDate;
  5908. },
  5909. /* Attach the onxxx handlers. These are declared statically so
  5910. * they work with static code transformers like Caja.
  5911. */
  5912. _attachHandlers: function(inst) {
  5913. var stepMonths = this._get(inst, "stepMonths"), id = "#" + inst.id.replace(/\\\\/g, "\\");
  5914. inst.dpDiv.find("[data-handler]").map(function() {
  5915. var handler = {
  5916. prev: function() {
  5917. $.datepicker._adjustDate(id, -stepMonths, "M");
  5918. },
  5919. next: function() {
  5920. $.datepicker._adjustDate(id, +stepMonths, "M");
  5921. },
  5922. hide: function() {
  5923. $.datepicker._hideDatepicker();
  5924. },
  5925. today: function() {
  5926. $.datepicker._gotoToday(id);
  5927. },
  5928. selectDay: function() {
  5929. $.datepicker._selectDay(id, +this.getAttribute("data-month"), +this.getAttribute("data-year"), this);
  5930. return false;
  5931. },
  5932. selectMonth: function() {
  5933. $.datepicker._selectMonthYear(id, this, "M");
  5934. return false;
  5935. },
  5936. selectYear: function() {
  5937. $.datepicker._selectMonthYear(id, this, "Y");
  5938. return false;
  5939. }
  5940. };
  5941. $(this).on(this.getAttribute("data-event"), handler[this.getAttribute("data-handler")]);
  5942. });
  5943. },
  5944. /* Generate the HTML for the current state of the date picker. */
  5945. _generateHTML: function(inst) {
  5946. var maxDraw, prevText, prev, nextText, next, currentText, gotoDate, controls, buttonPanel, firstDay, showWeek, dayNames, dayNamesMin, monthNames, monthNamesShort, beforeShowDay, showOtherMonths, selectOtherMonths, defaultDate, html, dow, row, group, col, selectedDate, cornerClass, calender, thead, day, daysInMonth, leadDays, curRows, numRows, printDate, dRow, tbody, daySettings, otherMonth, unselectable, tempDate = /* @__PURE__ */ new Date(), today = this._daylightSavingAdjust(
  5947. new Date(tempDate.getFullYear(), tempDate.getMonth(), tempDate.getDate())
  5948. ), isRTL = this._get(inst, "isRTL"), showButtonPanel = this._get(inst, "showButtonPanel"), hideIfNoPrevNext = this._get(inst, "hideIfNoPrevNext"), navigationAsDateFormat = this._get(inst, "navigationAsDateFormat"), numMonths = this._getNumberOfMonths(inst), showCurrentAtPos = this._get(inst, "showCurrentAtPos"), stepMonths = this._get(inst, "stepMonths"), isMultiMonth = numMonths[0] !== 1 || numMonths[1] !== 1, currentDate = this._daylightSavingAdjust(!inst.currentDay ? new Date(9999, 9, 9) : new Date(inst.currentYear, inst.currentMonth, inst.currentDay)), minDate = this._getMinMaxDate(inst, "min"), maxDate = this._getMinMaxDate(inst, "max"), drawMonth = inst.drawMonth - showCurrentAtPos, drawYear = inst.drawYear;
  5949. if (drawMonth < 0) {
  5950. drawMonth += 12;
  5951. drawYear--;
  5952. }
  5953. if (maxDate) {
  5954. maxDraw = this._daylightSavingAdjust(new Date(
  5955. maxDate.getFullYear(),
  5956. maxDate.getMonth() - numMonths[0] * numMonths[1] + 1,
  5957. maxDate.getDate()
  5958. ));
  5959. maxDraw = minDate && maxDraw < minDate ? minDate : maxDraw;
  5960. while (this._daylightSavingAdjust(new Date(drawYear, drawMonth, 1)) > maxDraw) {
  5961. drawMonth--;
  5962. if (drawMonth < 0) {
  5963. drawMonth = 11;
  5964. drawYear--;
  5965. }
  5966. }
  5967. }
  5968. inst.drawMonth = drawMonth;
  5969. inst.drawYear = drawYear;
  5970. prevText = this._get(inst, "prevText");
  5971. prevText = !navigationAsDateFormat ? prevText : this.formatDate(
  5972. prevText,
  5973. this._daylightSavingAdjust(new Date(drawYear, drawMonth - stepMonths, 1)),
  5974. this._getFormatConfig(inst)
  5975. );
  5976. if (this._canAdjustMonth(inst, -1, drawYear, drawMonth)) {
  5977. prev = $("<a>").attr({
  5978. "class": "ui-datepicker-prev ui-corner-all",
  5979. "data-handler": "prev",
  5980. "data-event": "click",
  5981. title: prevText
  5982. }).append(
  5983. $("<span>").addClass("ui-icon ui-icon-circle-triangle-" + (isRTL ? "e" : "w")).text(prevText)
  5984. )[0].outerHTML;
  5985. } else if (hideIfNoPrevNext) {
  5986. prev = "";
  5987. } else {
  5988. prev = $("<a>").attr({
  5989. "class": "ui-datepicker-prev ui-corner-all ui-state-disabled",
  5990. title: prevText
  5991. }).append(
  5992. $("<span>").addClass("ui-icon ui-icon-circle-triangle-" + (isRTL ? "e" : "w")).text(prevText)
  5993. )[0].outerHTML;
  5994. }
  5995. nextText = this._get(inst, "nextText");
  5996. nextText = !navigationAsDateFormat ? nextText : this.formatDate(
  5997. nextText,
  5998. this._daylightSavingAdjust(new Date(drawYear, drawMonth + stepMonths, 1)),
  5999. this._getFormatConfig(inst)
  6000. );
  6001. if (this._canAdjustMonth(inst, 1, drawYear, drawMonth)) {
  6002. next = $("<a>").attr({
  6003. "class": "ui-datepicker-next ui-corner-all",
  6004. "data-handler": "next",
  6005. "data-event": "click",
  6006. title: nextText
  6007. }).append(
  6008. $("<span>").addClass("ui-icon ui-icon-circle-triangle-" + (isRTL ? "w" : "e")).text(nextText)
  6009. )[0].outerHTML;
  6010. } else if (hideIfNoPrevNext) {
  6011. next = "";
  6012. } else {
  6013. next = $("<a>").attr({
  6014. "class": "ui-datepicker-next ui-corner-all ui-state-disabled",
  6015. title: nextText
  6016. }).append(
  6017. $("<span>").attr("class", "ui-icon ui-icon-circle-triangle-" + (isRTL ? "w" : "e")).text(nextText)
  6018. )[0].outerHTML;
  6019. }
  6020. currentText = this._get(inst, "currentText");
  6021. gotoDate = this._get(inst, "gotoCurrent") && inst.currentDay ? currentDate : today;
  6022. currentText = !navigationAsDateFormat ? currentText : this.formatDate(currentText, gotoDate, this._getFormatConfig(inst));
  6023. controls = "";
  6024. if (!inst.inline) {
  6025. controls = $("<button>").attr({
  6026. type: "button",
  6027. "class": "ui-datepicker-close ui-state-default ui-priority-primary ui-corner-all",
  6028. "data-handler": "hide",
  6029. "data-event": "click"
  6030. }).text(this._get(inst, "closeText"))[0].outerHTML;
  6031. }
  6032. buttonPanel = "";
  6033. if (showButtonPanel) {
  6034. buttonPanel = $("<div class='ui-datepicker-buttonpane ui-widget-content'>").append(isRTL ? controls : "").append(this._isInRange(inst, gotoDate) ? $("<button>").attr({
  6035. type: "button",
  6036. "class": "ui-datepicker-current ui-state-default ui-priority-secondary ui-corner-all",
  6037. "data-handler": "today",
  6038. "data-event": "click"
  6039. }).text(currentText) : "").append(isRTL ? "" : controls)[0].outerHTML;
  6040. }
  6041. firstDay = parseInt(this._get(inst, "firstDay"), 10);
  6042. firstDay = isNaN(firstDay) ? 0 : firstDay;
  6043. showWeek = this._get(inst, "showWeek");
  6044. dayNames = this._get(inst, "dayNames");
  6045. dayNamesMin = this._get(inst, "dayNamesMin");
  6046. monthNames = this._get(inst, "monthNames");
  6047. monthNamesShort = this._get(inst, "monthNamesShort");
  6048. beforeShowDay = this._get(inst, "beforeShowDay");
  6049. showOtherMonths = this._get(inst, "showOtherMonths");
  6050. selectOtherMonths = this._get(inst, "selectOtherMonths");
  6051. defaultDate = this._getDefaultDate(inst);
  6052. html = "";
  6053. for (row = 0; row < numMonths[0]; row++) {
  6054. group = "";
  6055. this.maxRows = 4;
  6056. for (col = 0; col < numMonths[1]; col++) {
  6057. selectedDate = this._daylightSavingAdjust(new Date(drawYear, drawMonth, inst.selectedDay));
  6058. cornerClass = " ui-corner-all";
  6059. calender = "";
  6060. if (isMultiMonth) {
  6061. calender += "<div class='ui-datepicker-group";
  6062. if (numMonths[1] > 1) {
  6063. switch (col) {
  6064. case 0:
  6065. calender += " ui-datepicker-group-first";
  6066. cornerClass = " ui-corner-" + (isRTL ? "right" : "left");
  6067. break;
  6068. case numMonths[1] - 1:
  6069. calender += " ui-datepicker-group-last";
  6070. cornerClass = " ui-corner-" + (isRTL ? "left" : "right");
  6071. break;
  6072. default:
  6073. calender += " ui-datepicker-group-middle";
  6074. cornerClass = "";
  6075. break;
  6076. }
  6077. }
  6078. calender += "'>";
  6079. }
  6080. calender += "<div class='ui-datepicker-header ui-widget-header ui-helper-clearfix" + cornerClass + "'>" + (/all|left/.test(cornerClass) && row === 0 ? isRTL ? next : prev : "") + (/all|right/.test(cornerClass) && row === 0 ? isRTL ? prev : next : "") + this._generateMonthYearHeader(
  6081. inst,
  6082. drawMonth,
  6083. drawYear,
  6084. minDate,
  6085. maxDate,
  6086. row > 0 || col > 0,
  6087. monthNames,
  6088. monthNamesShort
  6089. ) + // draw month headers
  6090. "</div><table class='ui-datepicker-calendar'><thead><tr>";
  6091. thead = showWeek ? "<th class='ui-datepicker-week-col'>" + this._get(inst, "weekHeader") + "</th>" : "";
  6092. for (dow = 0; dow < 7; dow++) {
  6093. day = (dow + firstDay) % 7;
  6094. thead += "<th scope='col'" + ((dow + firstDay + 6) % 7 >= 5 ? " class='ui-datepicker-week-end'" : "") + "><span title='" + dayNames[day] + "'>" + dayNamesMin[day] + "</span></th>";
  6095. }
  6096. calender += thead + "</tr></thead><tbody>";
  6097. daysInMonth = this._getDaysInMonth(drawYear, drawMonth);
  6098. if (drawYear === inst.selectedYear && drawMonth === inst.selectedMonth) {
  6099. inst.selectedDay = Math.min(inst.selectedDay, daysInMonth);
  6100. }
  6101. leadDays = (this._getFirstDayOfMonth(drawYear, drawMonth) - firstDay + 7) % 7;
  6102. curRows = Math.ceil((leadDays + daysInMonth) / 7);
  6103. numRows = isMultiMonth ? this.maxRows > curRows ? this.maxRows : curRows : curRows;
  6104. this.maxRows = numRows;
  6105. printDate = this._daylightSavingAdjust(new Date(drawYear, drawMonth, 1 - leadDays));
  6106. for (dRow = 0; dRow < numRows; dRow++) {
  6107. calender += "<tr>";
  6108. tbody = !showWeek ? "" : "<td class='ui-datepicker-week-col'>" + this._get(inst, "calculateWeek")(printDate) + "</td>";
  6109. for (dow = 0; dow < 7; dow++) {
  6110. daySettings = beforeShowDay ? beforeShowDay.apply(inst.input ? inst.input[0] : null, [printDate]) : [true, ""];
  6111. otherMonth = printDate.getMonth() !== drawMonth;
  6112. unselectable = otherMonth && !selectOtherMonths || !daySettings[0] || minDate && printDate < minDate || maxDate && printDate > maxDate;
  6113. tbody += "<td class='" + ((dow + firstDay + 6) % 7 >= 5 ? " ui-datepicker-week-end" : "") + // highlight weekends
  6114. (otherMonth ? " ui-datepicker-other-month" : "") + // highlight days from other months
  6115. (printDate.getTime() === selectedDate.getTime() && drawMonth === inst.selectedMonth && inst._keyEvent || // user pressed key
  6116. defaultDate.getTime() === printDate.getTime() && defaultDate.getTime() === selectedDate.getTime() ? (
  6117. // or defaultDate is current printedDate and defaultDate is selectedDate
  6118. " " + this._dayOverClass
  6119. ) : "") + // highlight selected day
  6120. (unselectable ? " " + this._unselectableClass + " ui-state-disabled" : "") + // highlight unselectable days
  6121. (otherMonth && !showOtherMonths ? "" : " " + daySettings[1] + // highlight custom dates
  6122. (printDate.getTime() === currentDate.getTime() ? " " + this._currentClass : "") + // highlight selected day
  6123. (printDate.getTime() === today.getTime() ? " ui-datepicker-today" : "")) + "'" + // highlight today (if different)
  6124. ((!otherMonth || showOtherMonths) && daySettings[2] ? " title='" + daySettings[2].replace(/'/g, "&#39;") + "'" : "") + // cell title
  6125. (unselectable ? "" : " data-handler='selectDay' data-event='click' data-month='" + printDate.getMonth() + "' data-year='" + printDate.getFullYear() + "'") + ">" + // actions
  6126. (otherMonth && !showOtherMonths ? "&#xa0;" : (
  6127. // display for other months
  6128. unselectable ? "<span class='ui-state-default'>" + printDate.getDate() + "</span>" : "<a class='ui-state-default" + (printDate.getTime() === today.getTime() ? " ui-state-highlight" : "") + (printDate.getTime() === currentDate.getTime() ? " ui-state-active" : "") + // highlight selected day
  6129. (otherMonth ? " ui-priority-secondary" : "") + // distinguish dates from other months
  6130. "' href='#' aria-current='" + (printDate.getTime() === currentDate.getTime() ? "true" : "false") + // mark date as selected for screen reader
  6131. "' data-date='" + printDate.getDate() + // store date as data
  6132. "'>" + printDate.getDate() + "</a>"
  6133. )) + "</td>";
  6134. printDate.setDate(printDate.getDate() + 1);
  6135. printDate = this._daylightSavingAdjust(printDate);
  6136. }
  6137. calender += tbody + "</tr>";
  6138. }
  6139. drawMonth++;
  6140. if (drawMonth > 11) {
  6141. drawMonth = 0;
  6142. drawYear++;
  6143. }
  6144. calender += "</tbody></table>" + (isMultiMonth ? "</div>" + (numMonths[0] > 0 && col === numMonths[1] - 1 ? "<div class='ui-datepicker-row-break'></div>" : "") : "");
  6145. group += calender;
  6146. }
  6147. html += group;
  6148. }
  6149. html += buttonPanel;
  6150. inst._keyEvent = false;
  6151. return html;
  6152. },
  6153. /* Generate the month and year header. */
  6154. _generateMonthYearHeader: function(inst, drawMonth, drawYear, minDate, maxDate, secondary, monthNames, monthNamesShort) {
  6155. var inMinYear, inMaxYear, month, years, thisYear, determineYear, year, endYear, changeMonth = this._get(inst, "changeMonth"), changeYear = this._get(inst, "changeYear"), showMonthAfterYear = this._get(inst, "showMonthAfterYear"), selectMonthLabel = this._get(inst, "selectMonthLabel"), selectYearLabel = this._get(inst, "selectYearLabel"), html = "<div class='ui-datepicker-title'>", monthHtml = "";
  6156. if (secondary || !changeMonth) {
  6157. monthHtml += "<span class='ui-datepicker-month'>" + monthNames[drawMonth] + "</span>";
  6158. } else {
  6159. inMinYear = minDate && minDate.getFullYear() === drawYear;
  6160. inMaxYear = maxDate && maxDate.getFullYear() === drawYear;
  6161. monthHtml += "<select class='ui-datepicker-month' aria-label='" + selectMonthLabel + "' data-handler='selectMonth' data-event='change'>";
  6162. for (month = 0; month < 12; month++) {
  6163. if ((!inMinYear || month >= minDate.getMonth()) && (!inMaxYear || month <= maxDate.getMonth())) {
  6164. monthHtml += "<option value='" + month + "'" + (month === drawMonth ? " selected='selected'" : "") + ">" + monthNamesShort[month] + "</option>";
  6165. }
  6166. }
  6167. monthHtml += "</select>";
  6168. }
  6169. if (!showMonthAfterYear) {
  6170. html += monthHtml + (secondary || !(changeMonth && changeYear) ? "&#xa0;" : "");
  6171. }
  6172. if (!inst.yearshtml) {
  6173. inst.yearshtml = "";
  6174. if (secondary || !changeYear) {
  6175. html += "<span class='ui-datepicker-year'>" + drawYear + "</span>";
  6176. } else {
  6177. years = this._get(inst, "yearRange").split(":");
  6178. thisYear = (/* @__PURE__ */ new Date()).getFullYear();
  6179. determineYear = function(value) {
  6180. var year2 = value.match(/c[+\-].*/) ? drawYear + parseInt(value.substring(1), 10) : value.match(/[+\-].*/) ? thisYear + parseInt(value, 10) : parseInt(value, 10);
  6181. return isNaN(year2) ? thisYear : year2;
  6182. };
  6183. year = determineYear(years[0]);
  6184. endYear = Math.max(year, determineYear(years[1] || ""));
  6185. year = minDate ? Math.max(year, minDate.getFullYear()) : year;
  6186. endYear = maxDate ? Math.min(endYear, maxDate.getFullYear()) : endYear;
  6187. inst.yearshtml += "<select class='ui-datepicker-year' aria-label='" + selectYearLabel + "' data-handler='selectYear' data-event='change'>";
  6188. for (; year <= endYear; year++) {
  6189. inst.yearshtml += "<option value='" + year + "'" + (year === drawYear ? " selected='selected'" : "") + ">" + year + "</option>";
  6190. }
  6191. inst.yearshtml += "</select>";
  6192. html += inst.yearshtml;
  6193. inst.yearshtml = null;
  6194. }
  6195. }
  6196. html += this._get(inst, "yearSuffix");
  6197. if (showMonthAfterYear) {
  6198. html += (secondary || !(changeMonth && changeYear) ? "&#xa0;" : "") + monthHtml;
  6199. }
  6200. html += "</div>";
  6201. return html;
  6202. },
  6203. /* Adjust one of the date sub-fields. */
  6204. _adjustInstDate: function(inst, offset, period) {
  6205. var year = inst.selectedYear + (period === "Y" ? offset : 0), month = inst.selectedMonth + (period === "M" ? offset : 0), day = Math.min(inst.selectedDay, this._getDaysInMonth(year, month)) + (period === "D" ? offset : 0), date = this._restrictMinMax(inst, this._daylightSavingAdjust(new Date(year, month, day)));
  6206. inst.selectedDay = date.getDate();
  6207. inst.drawMonth = inst.selectedMonth = date.getMonth();
  6208. inst.drawYear = inst.selectedYear = date.getFullYear();
  6209. if (period === "M" || period === "Y") {
  6210. this._notifyChange(inst);
  6211. }
  6212. },
  6213. /* Ensure a date is within any min/max bounds. */
  6214. _restrictMinMax: function(inst, date) {
  6215. var minDate = this._getMinMaxDate(inst, "min"), maxDate = this._getMinMaxDate(inst, "max"), newDate = minDate && date < minDate ? minDate : date;
  6216. return maxDate && newDate > maxDate ? maxDate : newDate;
  6217. },
  6218. /* Notify change of month/year. */
  6219. _notifyChange: function(inst) {
  6220. var onChange = this._get(inst, "onChangeMonthYear");
  6221. if (onChange) {
  6222. onChange.apply(
  6223. inst.input ? inst.input[0] : null,
  6224. [inst.selectedYear, inst.selectedMonth + 1, inst]
  6225. );
  6226. }
  6227. },
  6228. /* Determine the number of months to show. */
  6229. _getNumberOfMonths: function(inst) {
  6230. var numMonths = this._get(inst, "numberOfMonths");
  6231. return numMonths == null ? [1, 1] : typeof numMonths === "number" ? [1, numMonths] : numMonths;
  6232. },
  6233. /* Determine the current maximum date - ensure no time components are set. */
  6234. _getMinMaxDate: function(inst, minMax) {
  6235. return this._determineDate(inst, this._get(inst, minMax + "Date"), null);
  6236. },
  6237. /* Find the number of days in a given month. */
  6238. _getDaysInMonth: function(year, month) {
  6239. return 32 - this._daylightSavingAdjust(new Date(year, month, 32)).getDate();
  6240. },
  6241. /* Find the day of the week of the first of a month. */
  6242. _getFirstDayOfMonth: function(year, month) {
  6243. return new Date(year, month, 1).getDay();
  6244. },
  6245. /* Determines if we should allow a "next/prev" month display change. */
  6246. _canAdjustMonth: function(inst, offset, curYear, curMonth) {
  6247. var numMonths = this._getNumberOfMonths(inst), date = this._daylightSavingAdjust(new Date(
  6248. curYear,
  6249. curMonth + (offset < 0 ? offset : numMonths[0] * numMonths[1]),
  6250. 1
  6251. ));
  6252. if (offset < 0) {
  6253. date.setDate(this._getDaysInMonth(date.getFullYear(), date.getMonth()));
  6254. }
  6255. return this._isInRange(inst, date);
  6256. },
  6257. /* Is the given date in the accepted range? */
  6258. _isInRange: function(inst, date) {
  6259. var yearSplit, currentYear, minDate = this._getMinMaxDate(inst, "min"), maxDate = this._getMinMaxDate(inst, "max"), minYear = null, maxYear = null, years = this._get(inst, "yearRange");
  6260. if (years) {
  6261. yearSplit = years.split(":");
  6262. currentYear = (/* @__PURE__ */ new Date()).getFullYear();
  6263. minYear = parseInt(yearSplit[0], 10);
  6264. maxYear = parseInt(yearSplit[1], 10);
  6265. if (yearSplit[0].match(/[+\-].*/)) {
  6266. minYear += currentYear;
  6267. }
  6268. if (yearSplit[1].match(/[+\-].*/)) {
  6269. maxYear += currentYear;
  6270. }
  6271. }
  6272. return (!minDate || date.getTime() >= minDate.getTime()) && (!maxDate || date.getTime() <= maxDate.getTime()) && (!minYear || date.getFullYear() >= minYear) && (!maxYear || date.getFullYear() <= maxYear);
  6273. },
  6274. /* Provide the configuration settings for formatting/parsing. */
  6275. _getFormatConfig: function(inst) {
  6276. var shortYearCutoff = this._get(inst, "shortYearCutoff");
  6277. shortYearCutoff = typeof shortYearCutoff !== "string" ? shortYearCutoff : (/* @__PURE__ */ new Date()).getFullYear() % 100 + parseInt(shortYearCutoff, 10);
  6278. return {
  6279. shortYearCutoff,
  6280. dayNamesShort: this._get(inst, "dayNamesShort"),
  6281. dayNames: this._get(inst, "dayNames"),
  6282. monthNamesShort: this._get(inst, "monthNamesShort"),
  6283. monthNames: this._get(inst, "monthNames")
  6284. };
  6285. },
  6286. /* Format the given date for display. */
  6287. _formatDate: function(inst, day, month, year) {
  6288. if (!day) {
  6289. inst.currentDay = inst.selectedDay;
  6290. inst.currentMonth = inst.selectedMonth;
  6291. inst.currentYear = inst.selectedYear;
  6292. }
  6293. var date = day ? typeof day === "object" ? day : this._daylightSavingAdjust(new Date(year, month, day)) : this._daylightSavingAdjust(new Date(inst.currentYear, inst.currentMonth, inst.currentDay));
  6294. return this.formatDate(this._get(inst, "dateFormat"), date, this._getFormatConfig(inst));
  6295. }
  6296. });
  6297. function datepicker_bindHover(dpDiv) {
  6298. var selector = "button, .ui-datepicker-prev, .ui-datepicker-next, .ui-datepicker-calendar td a";
  6299. return dpDiv.on("mouseout", selector, function() {
  6300. $(this).removeClass("ui-state-hover");
  6301. if (this.className.indexOf("ui-datepicker-prev") !== -1) {
  6302. $(this).removeClass("ui-datepicker-prev-hover");
  6303. }
  6304. if (this.className.indexOf("ui-datepicker-next") !== -1) {
  6305. $(this).removeClass("ui-datepicker-next-hover");
  6306. }
  6307. }).on("mouseover", selector, datepicker_handleMouseover);
  6308. }
  6309. function datepicker_handleMouseover() {
  6310. if (!$.datepicker._isDisabledDatepicker(datepicker_instActive.inline ? datepicker_instActive.dpDiv.parent()[0] : datepicker_instActive.input[0])) {
  6311. $(this).parents(".ui-datepicker-calendar").find("a").removeClass("ui-state-hover");
  6312. $(this).addClass("ui-state-hover");
  6313. if (this.className.indexOf("ui-datepicker-prev") !== -1) {
  6314. $(this).addClass("ui-datepicker-prev-hover");
  6315. }
  6316. if (this.className.indexOf("ui-datepicker-next") !== -1) {
  6317. $(this).addClass("ui-datepicker-next-hover");
  6318. }
  6319. }
  6320. }
  6321. function datepicker_extendRemove(target, props) {
  6322. $.extend(target, props);
  6323. for (var name in props) {
  6324. if (props[name] == null) {
  6325. target[name] = props[name];
  6326. }
  6327. }
  6328. return target;
  6329. }
  6330. $.fn.datepicker = function(options) {
  6331. if (!this.length) {
  6332. return this;
  6333. }
  6334. if (!$.datepicker.initialized) {
  6335. $(document).on("mousedown", $.datepicker._checkExternalClick);
  6336. $.datepicker.initialized = true;
  6337. }
  6338. if ($("#" + $.datepicker._mainDivId).length === 0) {
  6339. $("body").append($.datepicker.dpDiv);
  6340. }
  6341. var otherArgs = Array.prototype.slice.call(arguments, 1);
  6342. if (typeof options === "string" && (options === "isDisabled" || options === "getDate" || options === "widget")) {
  6343. return $.datepicker["_" + options + "Datepicker"].apply($.datepicker, [this[0]].concat(otherArgs));
  6344. }
  6345. if (options === "option" && arguments.length === 2 && typeof arguments[1] === "string") {
  6346. return $.datepicker["_" + options + "Datepicker"].apply($.datepicker, [this[0]].concat(otherArgs));
  6347. }
  6348. return this.each(function() {
  6349. if (typeof options === "string") {
  6350. $.datepicker["_" + options + "Datepicker"].apply($.datepicker, [this].concat(otherArgs));
  6351. } else {
  6352. $.datepicker._attachDatepicker(this, options);
  6353. }
  6354. });
  6355. };
  6356. $.datepicker = new Datepicker();
  6357. $.datepicker.initialized = false;
  6358. $.datepicker.uuid = (/* @__PURE__ */ new Date()).getTime();
  6359. $.datepicker.version = "1.14.1";
  6360. var widgetsDatepicker = $.datepicker;
  6361. var mouseHandled = false;
  6362. $(document).on("mouseup", function() {
  6363. mouseHandled = false;
  6364. });
  6365. var widgetsMouse = $.widget("ui.mouse", {
  6366. version: "1.14.1",
  6367. options: {
  6368. cancel: "input, textarea, button, select, option",
  6369. distance: 1,
  6370. delay: 0
  6371. },
  6372. _mouseInit: function() {
  6373. var that = this;
  6374. this.element.on("mousedown." + this.widgetName, function(event) {
  6375. return that._mouseDown(event);
  6376. }).on("click." + this.widgetName, function(event) {
  6377. if (true === $.data(event.target, that.widgetName + ".preventClickEvent")) {
  6378. $.removeData(event.target, that.widgetName + ".preventClickEvent");
  6379. event.stopImmediatePropagation();
  6380. return false;
  6381. }
  6382. });
  6383. this.started = false;
  6384. },
  6385. // TODO: make sure destroying one instance of mouse doesn't mess with
  6386. // other instances of mouse
  6387. _mouseDestroy: function() {
  6388. this.element.off("." + this.widgetName);
  6389. if (this._mouseMoveDelegate) {
  6390. this.document.off("mousemove." + this.widgetName, this._mouseMoveDelegate).off("mouseup." + this.widgetName, this._mouseUpDelegate);
  6391. }
  6392. },
  6393. _mouseDown: function(event) {
  6394. if (mouseHandled) {
  6395. return;
  6396. }
  6397. this._mouseMoved = false;
  6398. if (this._mouseStarted) {
  6399. this._mouseUp(event);
  6400. }
  6401. this._mouseDownEvent = event;
  6402. var that = this, btnIsLeft = event.which === 1, elIsCancel = typeof this.options.cancel === "string" ? $(event.target).closest(this.options.cancel).length : false;
  6403. if (!btnIsLeft || elIsCancel || !this._mouseCapture(event)) {
  6404. return true;
  6405. }
  6406. this.mouseDelayMet = !this.options.delay;
  6407. if (!this.mouseDelayMet) {
  6408. this._mouseDelayTimer = setTimeout(function() {
  6409. that.mouseDelayMet = true;
  6410. }, this.options.delay);
  6411. }
  6412. if (this._mouseDistanceMet(event) && this._mouseDelayMet(event)) {
  6413. this._mouseStarted = this._mouseStart(event) !== false;
  6414. if (!this._mouseStarted) {
  6415. event.preventDefault();
  6416. return true;
  6417. }
  6418. }
  6419. if (true === $.data(event.target, this.widgetName + ".preventClickEvent")) {
  6420. $.removeData(event.target, this.widgetName + ".preventClickEvent");
  6421. }
  6422. this._mouseMoveDelegate = function(event2) {
  6423. return that._mouseMove(event2);
  6424. };
  6425. this._mouseUpDelegate = function(event2) {
  6426. return that._mouseUp(event2);
  6427. };
  6428. this.document.on("mousemove." + this.widgetName, this._mouseMoveDelegate).on("mouseup." + this.widgetName, this._mouseUpDelegate);
  6429. event.preventDefault();
  6430. mouseHandled = true;
  6431. return true;
  6432. },
  6433. _mouseMove: function(event) {
  6434. if (this._mouseMoved && !event.which) {
  6435. if (event.originalEvent.altKey || event.originalEvent.ctrlKey || event.originalEvent.metaKey || event.originalEvent.shiftKey) {
  6436. this.ignoreMissingWhich = true;
  6437. } else if (!this.ignoreMissingWhich) {
  6438. return this._mouseUp(event);
  6439. }
  6440. }
  6441. if (event.which || event.button) {
  6442. this._mouseMoved = true;
  6443. }
  6444. if (this._mouseStarted) {
  6445. this._mouseDrag(event);
  6446. return event.preventDefault();
  6447. }
  6448. if (this._mouseDistanceMet(event) && this._mouseDelayMet(event)) {
  6449. this._mouseStarted = this._mouseStart(this._mouseDownEvent, event) !== false;
  6450. if (this._mouseStarted) {
  6451. this._mouseDrag(event);
  6452. } else {
  6453. this._mouseUp(event);
  6454. }
  6455. }
  6456. return !this._mouseStarted;
  6457. },
  6458. _mouseUp: function(event) {
  6459. this.document.off("mousemove." + this.widgetName, this._mouseMoveDelegate).off("mouseup." + this.widgetName, this._mouseUpDelegate);
  6460. if (this._mouseStarted) {
  6461. this._mouseStarted = false;
  6462. if (event.target === this._mouseDownEvent.target) {
  6463. $.data(event.target, this.widgetName + ".preventClickEvent", true);
  6464. }
  6465. this._mouseStop(event);
  6466. }
  6467. if (this._mouseDelayTimer) {
  6468. clearTimeout(this._mouseDelayTimer);
  6469. delete this._mouseDelayTimer;
  6470. }
  6471. this.ignoreMissingWhich = false;
  6472. mouseHandled = false;
  6473. event.preventDefault();
  6474. },
  6475. _mouseDistanceMet: function(event) {
  6476. return Math.max(
  6477. Math.abs(this._mouseDownEvent.pageX - event.pageX),
  6478. Math.abs(this._mouseDownEvent.pageY - event.pageY)
  6479. ) >= this.options.distance;
  6480. },
  6481. _mouseDelayMet: function() {
  6482. return this.mouseDelayMet;
  6483. },
  6484. // These are placeholder methods, to be overriden by extending plugin
  6485. _mouseStart: function() {
  6486. },
  6487. _mouseDrag: function() {
  6488. },
  6489. _mouseStop: function() {
  6490. },
  6491. _mouseCapture: function() {
  6492. return true;
  6493. }
  6494. });
  6495. var plugin = $.ui.plugin = {
  6496. add: function(module, option, set) {
  6497. var i, proto = $.ui[module].prototype;
  6498. for (i in set) {
  6499. proto.plugins[i] = proto.plugins[i] || [];
  6500. proto.plugins[i].push([option, set[i]]);
  6501. }
  6502. },
  6503. call: function(instance, name, args, allowDisconnected) {
  6504. var i, set = instance.plugins[name];
  6505. if (!set) {
  6506. return;
  6507. }
  6508. if (!allowDisconnected && (!instance.element[0].parentNode || instance.element[0].parentNode.nodeType === 11)) {
  6509. return;
  6510. }
  6511. for (i = 0; i < set.length; i++) {
  6512. if (instance.options[set[i][0]]) {
  6513. set[i][1].apply(instance.element, args);
  6514. }
  6515. }
  6516. }
  6517. };
  6518. $.widget("ui.draggable", $.ui.mouse, {
  6519. version: "1.14.1",
  6520. widgetEventPrefix: "drag",
  6521. options: {
  6522. addClasses: true,
  6523. appendTo: "parent",
  6524. axis: false,
  6525. connectToSortable: false,
  6526. containment: false,
  6527. cursor: "auto",
  6528. cursorAt: false,
  6529. grid: false,
  6530. handle: false,
  6531. helper: "original",
  6532. iframeFix: false,
  6533. opacity: false,
  6534. refreshPositions: false,
  6535. revert: false,
  6536. revertDuration: 500,
  6537. scope: "default",
  6538. scroll: true,
  6539. scrollSensitivity: 20,
  6540. scrollSpeed: 20,
  6541. snap: false,
  6542. snapMode: "both",
  6543. snapTolerance: 20,
  6544. stack: false,
  6545. zIndex: false,
  6546. // Callbacks
  6547. drag: null,
  6548. start: null,
  6549. stop: null
  6550. },
  6551. _create: function() {
  6552. if (this.options.helper === "original") {
  6553. this._setPositionRelative();
  6554. }
  6555. if (this.options.addClasses) {
  6556. this._addClass("ui-draggable");
  6557. }
  6558. this._setHandleClassName();
  6559. this._mouseInit();
  6560. },
  6561. _setOption: function(key, value) {
  6562. this._super(key, value);
  6563. if (key === "handle") {
  6564. this._removeHandleClassName();
  6565. this._setHandleClassName();
  6566. }
  6567. },
  6568. _destroy: function() {
  6569. if ((this.helper || this.element).is(".ui-draggable-dragging")) {
  6570. this.destroyOnClear = true;
  6571. return;
  6572. }
  6573. this._removeHandleClassName();
  6574. this._mouseDestroy();
  6575. },
  6576. _mouseCapture: function(event) {
  6577. var o = this.options;
  6578. if (this.helper || o.disabled || $(event.target).closest(".ui-resizable-handle").length > 0) {
  6579. return false;
  6580. }
  6581. this.handle = this._getHandle(event);
  6582. if (!this.handle) {
  6583. return false;
  6584. }
  6585. this._blurActiveElement(event);
  6586. this._blockFrames(o.iframeFix === true ? "iframe" : o.iframeFix);
  6587. return true;
  6588. },
  6589. _blockFrames: function(selector) {
  6590. this.iframeBlocks = this.document.find(selector).map(function() {
  6591. var iframe = $(this);
  6592. return $("<div>").css("position", "absolute").appendTo(iframe.parent()).outerWidth(iframe.outerWidth()).outerHeight(iframe.outerHeight()).offset(iframe.offset())[0];
  6593. });
  6594. },
  6595. _unblockFrames: function() {
  6596. if (this.iframeBlocks) {
  6597. this.iframeBlocks.remove();
  6598. delete this.iframeBlocks;
  6599. }
  6600. },
  6601. _blurActiveElement: function(event) {
  6602. var activeElement = this.document[0].activeElement, target = $(event.target);
  6603. if (target.closest(activeElement).length) {
  6604. return;
  6605. }
  6606. $(activeElement).trigger("blur");
  6607. },
  6608. _mouseStart: function(event) {
  6609. var o = this.options;
  6610. this.helper = this._createHelper(event);
  6611. this._addClass(this.helper, "ui-draggable-dragging");
  6612. this._cacheHelperProportions();
  6613. if ($.ui.ddmanager) {
  6614. $.ui.ddmanager.current = this;
  6615. }
  6616. this._cacheMargins();
  6617. this.cssPosition = this.helper.css("position");
  6618. this.scrollParent = this.helper.scrollParent(true);
  6619. this.offsetParent = this.helper.offsetParent();
  6620. this.hasFixedAncestor = this.helper.parents().filter(function() {
  6621. return $(this).css("position") === "fixed";
  6622. }).length > 0;
  6623. this.positionAbs = this.element.offset();
  6624. this._refreshOffsets(event);
  6625. this.originalPosition = this.position = this._generatePosition(event, false);
  6626. this.originalPageX = event.pageX;
  6627. this.originalPageY = event.pageY;
  6628. if (o.cursorAt) {
  6629. this._adjustOffsetFromHelper(o.cursorAt);
  6630. }
  6631. this._setContainment();
  6632. if (this._trigger("start", event) === false) {
  6633. this._clear();
  6634. return false;
  6635. }
  6636. this._cacheHelperProportions();
  6637. if ($.ui.ddmanager && !o.dropBehaviour) {
  6638. $.ui.ddmanager.prepareOffsets(this, event);
  6639. }
  6640. this._mouseDrag(event, true);
  6641. if ($.ui.ddmanager) {
  6642. $.ui.ddmanager.dragStart(this, event);
  6643. }
  6644. return true;
  6645. },
  6646. _refreshOffsets: function(event) {
  6647. this.offset = {
  6648. top: this.positionAbs.top - this.margins.top,
  6649. left: this.positionAbs.left - this.margins.left,
  6650. scroll: false,
  6651. parent: this._getParentOffset(),
  6652. relative: this._getRelativeOffset()
  6653. };
  6654. this.offset.click = {
  6655. left: event.pageX - this.offset.left,
  6656. top: event.pageY - this.offset.top
  6657. };
  6658. },
  6659. _mouseDrag: function(event, noPropagation) {
  6660. if (this.hasFixedAncestor) {
  6661. this.offset.parent = this._getParentOffset();
  6662. }
  6663. this.position = this._generatePosition(event, true);
  6664. this.positionAbs = this._convertPositionTo("absolute");
  6665. if (!noPropagation) {
  6666. var ui = this._uiHash();
  6667. if (this._trigger("drag", event, ui) === false) {
  6668. this._mouseUp(new $.Event("mouseup", event));
  6669. return false;
  6670. }
  6671. this.position = ui.position;
  6672. }
  6673. this.helper[0].style.left = this.position.left + "px";
  6674. this.helper[0].style.top = this.position.top + "px";
  6675. if ($.ui.ddmanager) {
  6676. $.ui.ddmanager.drag(this, event);
  6677. }
  6678. return false;
  6679. },
  6680. _mouseStop: function(event) {
  6681. var that = this, dropped = false;
  6682. if ($.ui.ddmanager && !this.options.dropBehaviour) {
  6683. dropped = $.ui.ddmanager.drop(this, event);
  6684. }
  6685. if (this.dropped) {
  6686. dropped = this.dropped;
  6687. this.dropped = false;
  6688. }
  6689. if (this.options.revert === "invalid" && !dropped || this.options.revert === "valid" && dropped || this.options.revert === true || typeof this.options.revert === "function" && this.options.revert.call(this.element, dropped)) {
  6690. $(this.helper).animate(
  6691. this.originalPosition,
  6692. parseInt(this.options.revertDuration, 10),
  6693. function() {
  6694. if (that._trigger("stop", event) !== false) {
  6695. that._clear();
  6696. }
  6697. }
  6698. );
  6699. } else {
  6700. if (this._trigger("stop", event) !== false) {
  6701. this._clear();
  6702. }
  6703. }
  6704. return false;
  6705. },
  6706. _mouseUp: function(event) {
  6707. this._unblockFrames();
  6708. if ($.ui.ddmanager) {
  6709. $.ui.ddmanager.dragStop(this, event);
  6710. }
  6711. if (this.handleElement.is(event.target)) {
  6712. this.element.trigger("focus");
  6713. }
  6714. return $.ui.mouse.prototype._mouseUp.call(this, event);
  6715. },
  6716. cancel: function() {
  6717. if (this.helper.is(".ui-draggable-dragging")) {
  6718. this._mouseUp(new $.Event("mouseup", { target: this.element[0] }));
  6719. } else {
  6720. this._clear();
  6721. }
  6722. return this;
  6723. },
  6724. _getHandle: function(event) {
  6725. return this.options.handle ? !!$(event.target).closest(this.element.find(this.options.handle)).length : true;
  6726. },
  6727. _setHandleClassName: function() {
  6728. this.handleElement = this.options.handle ? this.element.find(this.options.handle) : this.element;
  6729. this._addClass(this.handleElement, "ui-draggable-handle");
  6730. },
  6731. _removeHandleClassName: function() {
  6732. this._removeClass(this.handleElement, "ui-draggable-handle");
  6733. },
  6734. _createHelper: function(event) {
  6735. var o = this.options, helperIsFunction = typeof o.helper === "function", helper = helperIsFunction ? $(o.helper.apply(this.element[0], [event])) : o.helper === "clone" ? this.element.clone().removeAttr("id") : this.element;
  6736. if (!helper.parents("body").length) {
  6737. helper.appendTo(o.appendTo === "parent" ? this.element[0].parentNode : o.appendTo);
  6738. }
  6739. if (helperIsFunction && helper[0] === this.element[0]) {
  6740. this._setPositionRelative();
  6741. }
  6742. if (helper[0] !== this.element[0] && !/(fixed|absolute)/.test(helper.css("position"))) {
  6743. helper.css("position", "absolute");
  6744. }
  6745. return helper;
  6746. },
  6747. _setPositionRelative: function() {
  6748. if (!/^(?:r|a|f)/.test(this.element.css("position"))) {
  6749. this.element[0].style.position = "relative";
  6750. }
  6751. },
  6752. _adjustOffsetFromHelper: function(obj) {
  6753. if (typeof obj === "string") {
  6754. obj = obj.split(" ");
  6755. }
  6756. if (Array.isArray(obj)) {
  6757. obj = { left: +obj[0], top: +obj[1] || 0 };
  6758. }
  6759. if ("left" in obj) {
  6760. this.offset.click.left = obj.left + this.margins.left;
  6761. }
  6762. if ("right" in obj) {
  6763. this.offset.click.left = this.helperProportions.width - obj.right + this.margins.left;
  6764. }
  6765. if ("top" in obj) {
  6766. this.offset.click.top = obj.top + this.margins.top;
  6767. }
  6768. if ("bottom" in obj) {
  6769. this.offset.click.top = this.helperProportions.height - obj.bottom + this.margins.top;
  6770. }
  6771. },
  6772. _isRootNode: function(element) {
  6773. return /(html|body)/i.test(element.tagName) || element === this.document[0];
  6774. },
  6775. _getParentOffset: function() {
  6776. var po = this.offsetParent.offset(), document2 = this.document[0];
  6777. if (this.cssPosition === "absolute" && this.scrollParent[0] !== document2 && $.contains(this.scrollParent[0], this.offsetParent[0])) {
  6778. po.left += this.scrollParent.scrollLeft();
  6779. po.top += this.scrollParent.scrollTop();
  6780. }
  6781. if (this._isRootNode(this.offsetParent[0])) {
  6782. po = { top: 0, left: 0 };
  6783. }
  6784. return {
  6785. top: po.top + (parseInt(this.offsetParent.css("borderTopWidth"), 10) || 0),
  6786. left: po.left + (parseInt(this.offsetParent.css("borderLeftWidth"), 10) || 0)
  6787. };
  6788. },
  6789. _getRelativeOffset: function() {
  6790. if (this.cssPosition !== "relative") {
  6791. return { top: 0, left: 0 };
  6792. }
  6793. var p = this.element.position(), scrollIsRootNode = this._isRootNode(this.scrollParent[0]);
  6794. return {
  6795. top: p.top - (parseInt(this.helper.css("top"), 10) || 0) + (!scrollIsRootNode ? this.scrollParent.scrollTop() : 0),
  6796. left: p.left - (parseInt(this.helper.css("left"), 10) || 0) + (!scrollIsRootNode ? this.scrollParent.scrollLeft() : 0)
  6797. };
  6798. },
  6799. _cacheMargins: function() {
  6800. this.margins = {
  6801. left: parseInt(this.element.css("marginLeft"), 10) || 0,
  6802. top: parseInt(this.element.css("marginTop"), 10) || 0,
  6803. right: parseInt(this.element.css("marginRight"), 10) || 0,
  6804. bottom: parseInt(this.element.css("marginBottom"), 10) || 0
  6805. };
  6806. },
  6807. _cacheHelperProportions: function() {
  6808. this.helperProportions = {
  6809. width: this.helper.outerWidth(),
  6810. height: this.helper.outerHeight()
  6811. };
  6812. },
  6813. _setContainment: function() {
  6814. var isUserScrollable, c, ce, o = this.options, document2 = this.document[0];
  6815. this.relativeContainer = null;
  6816. if (!o.containment) {
  6817. this.containment = null;
  6818. return;
  6819. }
  6820. if (o.containment === "window") {
  6821. this.containment = [
  6822. $(window).scrollLeft() - this.offset.relative.left - this.offset.parent.left,
  6823. $(window).scrollTop() - this.offset.relative.top - this.offset.parent.top,
  6824. $(window).scrollLeft() + $(window).width() - this.helperProportions.width - this.margins.left,
  6825. $(window).scrollTop() + ($(window).height() || document2.body.parentNode.scrollHeight) - this.helperProportions.height - this.margins.top
  6826. ];
  6827. return;
  6828. }
  6829. if (o.containment === "document") {
  6830. this.containment = [
  6831. 0,
  6832. 0,
  6833. $(document2).width() - this.helperProportions.width - this.margins.left,
  6834. ($(document2).height() || document2.body.parentNode.scrollHeight) - this.helperProportions.height - this.margins.top
  6835. ];
  6836. return;
  6837. }
  6838. if (o.containment.constructor === Array) {
  6839. this.containment = o.containment;
  6840. return;
  6841. }
  6842. if (o.containment === "parent") {
  6843. o.containment = this.helper[0].parentNode;
  6844. }
  6845. c = $(o.containment);
  6846. ce = c[0];
  6847. if (!ce) {
  6848. return;
  6849. }
  6850. isUserScrollable = /(scroll|auto)/.test(c.css("overflow"));
  6851. this.containment = [
  6852. (parseInt(c.css("borderLeftWidth"), 10) || 0) + (parseInt(c.css("paddingLeft"), 10) || 0),
  6853. (parseInt(c.css("borderTopWidth"), 10) || 0) + (parseInt(c.css("paddingTop"), 10) || 0),
  6854. (isUserScrollable ? Math.max(ce.scrollWidth, ce.offsetWidth) : ce.offsetWidth) - (parseInt(c.css("borderRightWidth"), 10) || 0) - (parseInt(c.css("paddingRight"), 10) || 0) - this.helperProportions.width - this.margins.left - this.margins.right,
  6855. (isUserScrollable ? Math.max(ce.scrollHeight, ce.offsetHeight) : ce.offsetHeight) - (parseInt(c.css("borderBottomWidth"), 10) || 0) - (parseInt(c.css("paddingBottom"), 10) || 0) - this.helperProportions.height - this.margins.top - this.margins.bottom
  6856. ];
  6857. this.relativeContainer = c;
  6858. },
  6859. _convertPositionTo: function(d, pos) {
  6860. if (!pos) {
  6861. pos = this.position;
  6862. }
  6863. var mod = d === "absolute" ? 1 : -1, scrollIsRootNode = this._isRootNode(this.scrollParent[0]);
  6864. return {
  6865. top: (
  6866. // The absolute mouse position
  6867. pos.top + // Only for relative positioned nodes: Relative offset from element to offset parent
  6868. this.offset.relative.top * mod + // The offsetParent's offset without borders (offset + border)
  6869. this.offset.parent.top * mod - (this.cssPosition === "fixed" ? -this.offset.scroll.top : scrollIsRootNode ? 0 : this.offset.scroll.top) * mod
  6870. ),
  6871. left: (
  6872. // The absolute mouse position
  6873. pos.left + // Only for relative positioned nodes: Relative offset from element to offset parent
  6874. this.offset.relative.left * mod + // The offsetParent's offset without borders (offset + border)
  6875. this.offset.parent.left * mod - (this.cssPosition === "fixed" ? -this.offset.scroll.left : scrollIsRootNode ? 0 : this.offset.scroll.left) * mod
  6876. )
  6877. };
  6878. },
  6879. _generatePosition: function(event, constrainPosition) {
  6880. var containment, co, top, left, o = this.options, scrollIsRootNode = this._isRootNode(this.scrollParent[0]), pageX = event.pageX, pageY = event.pageY;
  6881. if (!scrollIsRootNode || !this.offset.scroll) {
  6882. this.offset.scroll = {
  6883. top: this.scrollParent.scrollTop(),
  6884. left: this.scrollParent.scrollLeft()
  6885. };
  6886. }
  6887. if (constrainPosition) {
  6888. if (this.containment) {
  6889. if (this.relativeContainer) {
  6890. co = this.relativeContainer.offset();
  6891. containment = [
  6892. this.containment[0] + co.left,
  6893. this.containment[1] + co.top,
  6894. this.containment[2] + co.left,
  6895. this.containment[3] + co.top
  6896. ];
  6897. } else {
  6898. containment = this.containment;
  6899. }
  6900. if (event.pageX - this.offset.click.left < containment[0]) {
  6901. pageX = containment[0] + this.offset.click.left;
  6902. }
  6903. if (event.pageY - this.offset.click.top < containment[1]) {
  6904. pageY = containment[1] + this.offset.click.top;
  6905. }
  6906. if (event.pageX - this.offset.click.left > containment[2]) {
  6907. pageX = containment[2] + this.offset.click.left;
  6908. }
  6909. if (event.pageY - this.offset.click.top > containment[3]) {
  6910. pageY = containment[3] + this.offset.click.top;
  6911. }
  6912. }
  6913. if (o.grid) {
  6914. top = o.grid[1] ? this.originalPageY + Math.round((pageY - this.originalPageY) / o.grid[1]) * o.grid[1] : this.originalPageY;
  6915. 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;
  6916. left = o.grid[0] ? this.originalPageX + Math.round((pageX - this.originalPageX) / o.grid[0]) * o.grid[0] : this.originalPageX;
  6917. 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;
  6918. }
  6919. if (o.axis === "y") {
  6920. pageX = this.originalPageX;
  6921. }
  6922. if (o.axis === "x") {
  6923. pageY = this.originalPageY;
  6924. }
  6925. }
  6926. return {
  6927. top: (
  6928. // The absolute mouse position
  6929. pageY - // Click offset (relative to the element)
  6930. this.offset.click.top - // Only for relative positioned nodes: Relative offset from element to offset parent
  6931. this.offset.relative.top - // The offsetParent's offset without borders (offset + border)
  6932. this.offset.parent.top + (this.cssPosition === "fixed" ? -this.offset.scroll.top : scrollIsRootNode ? 0 : this.offset.scroll.top)
  6933. ),
  6934. left: (
  6935. // The absolute mouse position
  6936. pageX - // Click offset (relative to the element)
  6937. this.offset.click.left - // Only for relative positioned nodes: Relative offset from element to offset parent
  6938. this.offset.relative.left - // The offsetParent's offset without borders (offset + border)
  6939. this.offset.parent.left + (this.cssPosition === "fixed" ? -this.offset.scroll.left : scrollIsRootNode ? 0 : this.offset.scroll.left)
  6940. )
  6941. };
  6942. },
  6943. _clear: function() {
  6944. this._removeClass(this.helper, "ui-draggable-dragging");
  6945. if (this.helper[0] !== this.element[0] && !this.cancelHelperRemoval) {
  6946. this.helper.remove();
  6947. }
  6948. this.helper = null;
  6949. this.cancelHelperRemoval = false;
  6950. if (this.destroyOnClear) {
  6951. this.destroy();
  6952. }
  6953. },
  6954. // From now on bulk stuff - mainly helpers
  6955. _trigger: function(type, event, ui) {
  6956. ui = ui || this._uiHash();
  6957. $.ui.plugin.call(this, type, [event, ui, this], true);
  6958. if (/^(drag|start|stop)/.test(type)) {
  6959. this.positionAbs = this._convertPositionTo("absolute");
  6960. ui.offset = this.positionAbs;
  6961. }
  6962. return $.Widget.prototype._trigger.call(this, type, event, ui);
  6963. },
  6964. plugins: {},
  6965. _uiHash: function() {
  6966. return {
  6967. helper: this.helper,
  6968. position: this.position,
  6969. originalPosition: this.originalPosition,
  6970. offset: this.positionAbs
  6971. };
  6972. }
  6973. });
  6974. $.ui.plugin.add("draggable", "connectToSortable", {
  6975. start: function(event, ui, draggable) {
  6976. var uiSortable = $.extend({}, ui, {
  6977. item: draggable.element
  6978. });
  6979. draggable.sortables = [];
  6980. $(draggable.options.connectToSortable).each(function() {
  6981. var sortable = $(this).sortable("instance");
  6982. if (sortable && !sortable.options.disabled) {
  6983. draggable.sortables.push(sortable);
  6984. sortable.refreshPositions();
  6985. sortable._trigger("activate", event, uiSortable);
  6986. }
  6987. });
  6988. },
  6989. stop: function(event, ui, draggable) {
  6990. var uiSortable = $.extend({}, ui, {
  6991. item: draggable.element
  6992. });
  6993. draggable.cancelHelperRemoval = false;
  6994. $.each(draggable.sortables, function() {
  6995. var sortable = this;
  6996. if (sortable.isOver) {
  6997. sortable.isOver = 0;
  6998. draggable.cancelHelperRemoval = true;
  6999. sortable.cancelHelperRemoval = false;
  7000. sortable._storedCSS = {
  7001. position: sortable.placeholder.css("position"),
  7002. top: sortable.placeholder.css("top"),
  7003. left: sortable.placeholder.css("left")
  7004. };
  7005. sortable._mouseStop(event);
  7006. sortable.options.helper = sortable.options._helper;
  7007. } else {
  7008. sortable.cancelHelperRemoval = true;
  7009. sortable._trigger("deactivate", event, uiSortable);
  7010. }
  7011. });
  7012. },
  7013. drag: function(event, ui, draggable) {
  7014. $.each(draggable.sortables, function() {
  7015. var innermostIntersecting = false, sortable = this;
  7016. sortable.positionAbs = draggable.positionAbs;
  7017. sortable.helperProportions = draggable.helperProportions;
  7018. sortable.offset.click = draggable.offset.click;
  7019. if (sortable._intersectsWith(sortable.containerCache)) {
  7020. innermostIntersecting = true;
  7021. $.each(draggable.sortables, function() {
  7022. this.positionAbs = draggable.positionAbs;
  7023. this.helperProportions = draggable.helperProportions;
  7024. this.offset.click = draggable.offset.click;
  7025. if (this !== sortable && this._intersectsWith(this.containerCache) && $.contains(sortable.element[0], this.element[0])) {
  7026. innermostIntersecting = false;
  7027. }
  7028. return innermostIntersecting;
  7029. });
  7030. }
  7031. if (innermostIntersecting) {
  7032. if (!sortable.isOver) {
  7033. sortable.isOver = 1;
  7034. draggable._parent = ui.helper.parent();
  7035. sortable.currentItem = ui.helper.appendTo(sortable.element).data("ui-sortable-item", true);
  7036. sortable.options._helper = sortable.options.helper;
  7037. sortable.options.helper = function() {
  7038. return ui.helper[0];
  7039. };
  7040. event.target = sortable.currentItem[0];
  7041. sortable._mouseCapture(event, true);
  7042. sortable._mouseStart(event, true, true);
  7043. sortable.offset.click.top = draggable.offset.click.top;
  7044. sortable.offset.click.left = draggable.offset.click.left;
  7045. sortable.offset.parent.left -= draggable.offset.parent.left - sortable.offset.parent.left;
  7046. sortable.offset.parent.top -= draggable.offset.parent.top - sortable.offset.parent.top;
  7047. draggable._trigger("toSortable", event);
  7048. draggable.dropped = sortable.element;
  7049. $.each(draggable.sortables, function() {
  7050. this.refreshPositions();
  7051. });
  7052. draggable.currentItem = draggable.element;
  7053. sortable.fromOutside = draggable;
  7054. }
  7055. if (sortable.currentItem) {
  7056. sortable._mouseDrag(event);
  7057. ui.position = sortable.position;
  7058. }
  7059. } else {
  7060. if (sortable.isOver) {
  7061. sortable.isOver = 0;
  7062. sortable.cancelHelperRemoval = true;
  7063. sortable.options._revert = sortable.options.revert;
  7064. sortable.options.revert = false;
  7065. sortable._trigger("out", event, sortable._uiHash(sortable));
  7066. sortable._mouseStop(event, true);
  7067. sortable.options.revert = sortable.options._revert;
  7068. sortable.options.helper = sortable.options._helper;
  7069. if (sortable.placeholder) {
  7070. sortable.placeholder.remove();
  7071. }
  7072. ui.helper.appendTo(draggable._parent);
  7073. draggable._refreshOffsets(event);
  7074. ui.position = draggable._generatePosition(event, true);
  7075. draggable._trigger("fromSortable", event);
  7076. draggable.dropped = false;
  7077. $.each(draggable.sortables, function() {
  7078. this.refreshPositions();
  7079. });
  7080. }
  7081. }
  7082. });
  7083. }
  7084. });
  7085. $.ui.plugin.add("draggable", "cursor", {
  7086. start: function(event, ui, instance) {
  7087. var t = $("body"), o = instance.options;
  7088. if (t.css("cursor")) {
  7089. o._cursor = t.css("cursor");
  7090. }
  7091. t.css("cursor", o.cursor);
  7092. },
  7093. stop: function(event, ui, instance) {
  7094. var o = instance.options;
  7095. if (o._cursor) {
  7096. $("body").css("cursor", o._cursor);
  7097. }
  7098. }
  7099. });
  7100. $.ui.plugin.add("draggable", "opacity", {
  7101. start: function(event, ui, instance) {
  7102. var t = $(ui.helper), o = instance.options;
  7103. if (t.css("opacity")) {
  7104. o._opacity = t.css("opacity");
  7105. }
  7106. t.css("opacity", o.opacity);
  7107. },
  7108. stop: function(event, ui, instance) {
  7109. var o = instance.options;
  7110. if (o._opacity) {
  7111. $(ui.helper).css("opacity", o._opacity);
  7112. }
  7113. }
  7114. });
  7115. $.ui.plugin.add("draggable", "scroll", {
  7116. start: function(event, ui, i) {
  7117. if (!i.scrollParentNotHidden) {
  7118. i.scrollParentNotHidden = i.helper.scrollParent(false);
  7119. }
  7120. if (i.scrollParentNotHidden[0] !== i.document[0] && i.scrollParentNotHidden[0].tagName !== "HTML") {
  7121. i.overflowOffset = i.scrollParentNotHidden.offset();
  7122. }
  7123. },
  7124. drag: function(event, ui, i) {
  7125. var o = i.options, scrolled = false, scrollParent2 = i.scrollParentNotHidden[0], document2 = i.document[0];
  7126. if (scrollParent2 !== document2 && scrollParent2.tagName !== "HTML") {
  7127. if (!o.axis || o.axis !== "x") {
  7128. if (i.overflowOffset.top + scrollParent2.offsetHeight - event.pageY < o.scrollSensitivity) {
  7129. scrollParent2.scrollTop = scrolled = scrollParent2.scrollTop + o.scrollSpeed;
  7130. } else if (event.pageY - i.overflowOffset.top < o.scrollSensitivity) {
  7131. scrollParent2.scrollTop = scrolled = scrollParent2.scrollTop - o.scrollSpeed;
  7132. }
  7133. }
  7134. if (!o.axis || o.axis !== "y") {
  7135. if (i.overflowOffset.left + scrollParent2.offsetWidth - event.pageX < o.scrollSensitivity) {
  7136. scrollParent2.scrollLeft = scrolled = scrollParent2.scrollLeft + o.scrollSpeed;
  7137. } else if (event.pageX - i.overflowOffset.left < o.scrollSensitivity) {
  7138. scrollParent2.scrollLeft = scrolled = scrollParent2.scrollLeft - o.scrollSpeed;
  7139. }
  7140. }
  7141. } else {
  7142. if (!o.axis || o.axis !== "x") {
  7143. if (event.pageY - $(document2).scrollTop() < o.scrollSensitivity) {
  7144. scrolled = $(document2).scrollTop($(document2).scrollTop() - o.scrollSpeed);
  7145. } else if ($(window).height() - (event.pageY - $(document2).scrollTop()) < o.scrollSensitivity) {
  7146. scrolled = $(document2).scrollTop($(document2).scrollTop() + o.scrollSpeed);
  7147. }
  7148. }
  7149. if (!o.axis || o.axis !== "y") {
  7150. if (event.pageX - $(document2).scrollLeft() < o.scrollSensitivity) {
  7151. scrolled = $(document2).scrollLeft(
  7152. $(document2).scrollLeft() - o.scrollSpeed
  7153. );
  7154. } else if ($(window).width() - (event.pageX - $(document2).scrollLeft()) < o.scrollSensitivity) {
  7155. scrolled = $(document2).scrollLeft(
  7156. $(document2).scrollLeft() + o.scrollSpeed
  7157. );
  7158. }
  7159. }
  7160. }
  7161. if (scrolled !== false && $.ui.ddmanager && !o.dropBehaviour) {
  7162. $.ui.ddmanager.prepareOffsets(i, event);
  7163. }
  7164. }
  7165. });
  7166. $.ui.plugin.add("draggable", "snap", {
  7167. start: function(event, ui, i) {
  7168. var o = i.options;
  7169. i.snapElements = [];
  7170. $(o.snap.constructor !== String ? o.snap.items || ":data(ui-draggable)" : o.snap).each(function() {
  7171. var $t = $(this), $o = $t.offset();
  7172. if (this !== i.element[0]) {
  7173. i.snapElements.push({
  7174. item: this,
  7175. width: $t.outerWidth(),
  7176. height: $t.outerHeight(),
  7177. top: $o.top,
  7178. left: $o.left
  7179. });
  7180. }
  7181. });
  7182. },
  7183. drag: function(event, ui, inst) {
  7184. var ts, bs, ls, rs, l, r, t, b, i, first, o = inst.options, d = o.snapTolerance, x1 = ui.offset.left, x2 = x1 + inst.helperProportions.width, y1 = ui.offset.top, y2 = y1 + inst.helperProportions.height;
  7185. for (i = inst.snapElements.length - 1; i >= 0; i--) {
  7186. l = inst.snapElements[i].left - inst.margins.left;
  7187. r = l + inst.snapElements[i].width;
  7188. t = inst.snapElements[i].top - inst.margins.top;
  7189. b = t + inst.snapElements[i].height;
  7190. if (x2 < l - d || x1 > r + d || y2 < t - d || y1 > b + d || !$.contains(
  7191. inst.snapElements[i].item.ownerDocument,
  7192. inst.snapElements[i].item
  7193. )) {
  7194. if (inst.snapElements[i].snapping) {
  7195. if (inst.options.snap.release) {
  7196. inst.options.snap.release.call(
  7197. inst.element,
  7198. event,
  7199. $.extend(inst._uiHash(), { snapItem: inst.snapElements[i].item })
  7200. );
  7201. }
  7202. }
  7203. inst.snapElements[i].snapping = false;
  7204. continue;
  7205. }
  7206. if (o.snapMode !== "inner") {
  7207. ts = Math.abs(t - y2) <= d;
  7208. bs = Math.abs(b - y1) <= d;
  7209. ls = Math.abs(l - x2) <= d;
  7210. rs = Math.abs(r - x1) <= d;
  7211. if (ts) {
  7212. ui.position.top = inst._convertPositionTo("relative", {
  7213. top: t - inst.helperProportions.height,
  7214. left: 0
  7215. }).top;
  7216. }
  7217. if (bs) {
  7218. ui.position.top = inst._convertPositionTo("relative", {
  7219. top: b,
  7220. left: 0
  7221. }).top;
  7222. }
  7223. if (ls) {
  7224. ui.position.left = inst._convertPositionTo("relative", {
  7225. top: 0,
  7226. left: l - inst.helperProportions.width
  7227. }).left;
  7228. }
  7229. if (rs) {
  7230. ui.position.left = inst._convertPositionTo("relative", {
  7231. top: 0,
  7232. left: r
  7233. }).left;
  7234. }
  7235. }
  7236. first = ts || bs || ls || rs;
  7237. if (o.snapMode !== "outer") {
  7238. ts = Math.abs(t - y1) <= d;
  7239. bs = Math.abs(b - y2) <= d;
  7240. ls = Math.abs(l - x1) <= d;
  7241. rs = Math.abs(r - x2) <= d;
  7242. if (ts) {
  7243. ui.position.top = inst._convertPositionTo("relative", {
  7244. top: t,
  7245. left: 0
  7246. }).top;
  7247. }
  7248. if (bs) {
  7249. ui.position.top = inst._convertPositionTo("relative", {
  7250. top: b - inst.helperProportions.height,
  7251. left: 0
  7252. }).top;
  7253. }
  7254. if (ls) {
  7255. ui.position.left = inst._convertPositionTo("relative", {
  7256. top: 0,
  7257. left: l
  7258. }).left;
  7259. }
  7260. if (rs) {
  7261. ui.position.left = inst._convertPositionTo("relative", {
  7262. top: 0,
  7263. left: r - inst.helperProportions.width
  7264. }).left;
  7265. }
  7266. }
  7267. if (!inst.snapElements[i].snapping && (ts || bs || ls || rs || first)) {
  7268. if (inst.options.snap.snap) {
  7269. inst.options.snap.snap.call(
  7270. inst.element,
  7271. event,
  7272. $.extend(inst._uiHash(), {
  7273. snapItem: inst.snapElements[i].item
  7274. })
  7275. );
  7276. }
  7277. }
  7278. inst.snapElements[i].snapping = ts || bs || ls || rs || first;
  7279. }
  7280. }
  7281. });
  7282. $.ui.plugin.add("draggable", "stack", {
  7283. start: function(event, ui, instance) {
  7284. var min, o = instance.options, group = $.makeArray($(o.stack)).sort(function(a, b) {
  7285. return (parseInt($(a).css("zIndex"), 10) || 0) - (parseInt($(b).css("zIndex"), 10) || 0);
  7286. });
  7287. if (!group.length) {
  7288. return;
  7289. }
  7290. min = parseInt($(group[0]).css("zIndex"), 10) || 0;
  7291. $(group).each(function(i) {
  7292. $(this).css("zIndex", min + i);
  7293. });
  7294. this.css("zIndex", min + group.length);
  7295. }
  7296. });
  7297. $.ui.plugin.add("draggable", "zIndex", {
  7298. start: function(event, ui, instance) {
  7299. var t = $(ui.helper), o = instance.options;
  7300. if (t.css("zIndex")) {
  7301. o._zIndex = t.css("zIndex");
  7302. }
  7303. t.css("zIndex", o.zIndex);
  7304. },
  7305. stop: function(event, ui, instance) {
  7306. var o = instance.options;
  7307. if (o._zIndex) {
  7308. $(ui.helper).css("zIndex", o._zIndex);
  7309. }
  7310. }
  7311. });
  7312. var widgetsDraggable = $.ui.draggable;
  7313. $.widget("ui.resizable", $.ui.mouse, {
  7314. version: "1.14.1",
  7315. widgetEventPrefix: "resize",
  7316. options: {
  7317. alsoResize: false,
  7318. animate: false,
  7319. animateDuration: "slow",
  7320. animateEasing: "swing",
  7321. aspectRatio: false,
  7322. autoHide: false,
  7323. classes: {
  7324. "ui-resizable-se": "ui-icon ui-icon-gripsmall-diagonal-se"
  7325. },
  7326. containment: false,
  7327. ghost: false,
  7328. grid: false,
  7329. handles: "e,s,se",
  7330. helper: false,
  7331. maxHeight: null,
  7332. maxWidth: null,
  7333. minHeight: 10,
  7334. minWidth: 10,
  7335. // See #7960
  7336. zIndex: 90,
  7337. // Callbacks
  7338. resize: null,
  7339. start: null,
  7340. stop: null
  7341. },
  7342. _num: function(value) {
  7343. return parseFloat(value) || 0;
  7344. },
  7345. _isNumber: function(value) {
  7346. return !isNaN(parseFloat(value));
  7347. },
  7348. _hasScroll: function(el, a) {
  7349. var scroll, has = false, overflow = $(el).css("overflow");
  7350. if (overflow === "hidden") {
  7351. return false;
  7352. }
  7353. if (overflow === "scroll") {
  7354. return true;
  7355. }
  7356. scroll = a && a === "left" ? "scrollLeft" : "scrollTop";
  7357. if (el[scroll] > 0) {
  7358. return true;
  7359. }
  7360. try {
  7361. el[scroll] = 1;
  7362. has = el[scroll] > 0;
  7363. el[scroll] = 0;
  7364. } catch (e) {
  7365. }
  7366. return has;
  7367. },
  7368. _create: function() {
  7369. var margins, o = this.options, that = this;
  7370. this._addClass("ui-resizable");
  7371. $.extend(this, {
  7372. _aspectRatio: !!o.aspectRatio,
  7373. aspectRatio: o.aspectRatio,
  7374. originalElement: this.element,
  7375. _proportionallyResizeElements: [],
  7376. _helper: o.helper || o.ghost || o.animate ? o.helper || "ui-resizable-helper" : null
  7377. });
  7378. if (this.element[0].nodeName.match(/^(canvas|textarea|input|select|button|img)$/i)) {
  7379. this.element.wrap(
  7380. $("<div class='ui-wrapper'></div>").css({
  7381. overflow: "hidden",
  7382. position: this.element.css("position"),
  7383. width: this.element.outerWidth(),
  7384. height: this.element.outerHeight(),
  7385. top: this.element.css("top"),
  7386. left: this.element.css("left")
  7387. })
  7388. );
  7389. this.element = this.element.parent().data(
  7390. "ui-resizable",
  7391. this.element.resizable("instance")
  7392. );
  7393. this.elementIsWrapper = true;
  7394. margins = {
  7395. marginTop: this.originalElement.css("marginTop"),
  7396. marginRight: this.originalElement.css("marginRight"),
  7397. marginBottom: this.originalElement.css("marginBottom"),
  7398. marginLeft: this.originalElement.css("marginLeft")
  7399. };
  7400. this.element.css(margins);
  7401. this.originalResizeStyle = this.originalElement.css("resize");
  7402. this.originalElement.css("resize", "none");
  7403. this._proportionallyResizeElements.push(this.originalElement.css({
  7404. position: "static",
  7405. zoom: 1,
  7406. display: "block"
  7407. }));
  7408. this._proportionallyResize();
  7409. }
  7410. this._setupHandles();
  7411. if (o.autoHide) {
  7412. $(this.element).on("mouseenter", function() {
  7413. if (o.disabled) {
  7414. return;
  7415. }
  7416. that._removeClass("ui-resizable-autohide");
  7417. that._handles.show();
  7418. }).on("mouseleave", function() {
  7419. if (o.disabled) {
  7420. return;
  7421. }
  7422. if (!that.resizing) {
  7423. that._addClass("ui-resizable-autohide");
  7424. that._handles.hide();
  7425. }
  7426. });
  7427. }
  7428. this._mouseInit();
  7429. },
  7430. _destroy: function() {
  7431. this._mouseDestroy();
  7432. this._addedHandles.remove();
  7433. var wrapper, _destroy = function(exp) {
  7434. $(exp).removeData("resizable").removeData("ui-resizable").off(".resizable");
  7435. };
  7436. if (this.elementIsWrapper) {
  7437. _destroy(this.element);
  7438. wrapper = this.element;
  7439. this.originalElement.css({
  7440. position: wrapper.css("position"),
  7441. width: wrapper.outerWidth(),
  7442. height: wrapper.outerHeight(),
  7443. top: wrapper.css("top"),
  7444. left: wrapper.css("left")
  7445. }).insertAfter(wrapper);
  7446. wrapper.remove();
  7447. }
  7448. this.originalElement.css("resize", this.originalResizeStyle);
  7449. _destroy(this.originalElement);
  7450. return this;
  7451. },
  7452. _setOption: function(key, value) {
  7453. this._super(key, value);
  7454. switch (key) {
  7455. case "handles":
  7456. this._removeHandles();
  7457. this._setupHandles();
  7458. break;
  7459. case "aspectRatio":
  7460. this._aspectRatio = !!value;
  7461. break;
  7462. default:
  7463. break;
  7464. }
  7465. },
  7466. _setupHandles: function() {
  7467. var o = this.options, handle, i, n, hname, axis, that = this;
  7468. this.handles = o.handles || (!$(".ui-resizable-handle", this.element).length ? "e,s,se" : {
  7469. n: ".ui-resizable-n",
  7470. e: ".ui-resizable-e",
  7471. s: ".ui-resizable-s",
  7472. w: ".ui-resizable-w",
  7473. se: ".ui-resizable-se",
  7474. sw: ".ui-resizable-sw",
  7475. ne: ".ui-resizable-ne",
  7476. nw: ".ui-resizable-nw"
  7477. });
  7478. this._handles = $();
  7479. this._addedHandles = $();
  7480. if (this.handles.constructor === String) {
  7481. if (this.handles === "all") {
  7482. this.handles = "n,e,s,w,se,sw,ne,nw";
  7483. }
  7484. n = this.handles.split(",");
  7485. this.handles = {};
  7486. for (i = 0; i < n.length; i++) {
  7487. handle = String.prototype.trim.call(n[i]);
  7488. hname = "ui-resizable-" + handle;
  7489. axis = $("<div>");
  7490. this._addClass(axis, "ui-resizable-handle " + hname);
  7491. axis.css({ zIndex: o.zIndex });
  7492. this.handles[handle] = ".ui-resizable-" + handle;
  7493. if (!this.element.children(this.handles[handle]).length) {
  7494. this.element.append(axis);
  7495. this._addedHandles = this._addedHandles.add(axis);
  7496. }
  7497. }
  7498. }
  7499. this._renderAxis = function(target) {
  7500. var i2, axis2, padPos, padWrapper;
  7501. target = target || this.element;
  7502. for (i2 in this.handles) {
  7503. if (this.handles[i2].constructor === String) {
  7504. this.handles[i2] = this.element.children(this.handles[i2]).first().show();
  7505. } else if (this.handles[i2].jquery || this.handles[i2].nodeType) {
  7506. this.handles[i2] = $(this.handles[i2]);
  7507. this._on(this.handles[i2], { "mousedown": that._mouseDown });
  7508. }
  7509. if (this.elementIsWrapper && this.originalElement[0].nodeName.match(/^(textarea|input|select|button)$/i)) {
  7510. axis2 = $(this.handles[i2], this.element);
  7511. padWrapper = /sw|ne|nw|se|n|s/.test(i2) ? axis2.outerHeight() : axis2.outerWidth();
  7512. padPos = [
  7513. "padding",
  7514. /ne|nw|n/.test(i2) ? "Top" : /se|sw|s/.test(i2) ? "Bottom" : /^e$/.test(i2) ? "Right" : "Left"
  7515. ].join("");
  7516. target.css(padPos, padWrapper);
  7517. this._proportionallyResize();
  7518. }
  7519. this._handles = this._handles.add(this.handles[i2]);
  7520. }
  7521. };
  7522. this._renderAxis(this.element);
  7523. this._handles = this._handles.add(this.element.find(".ui-resizable-handle"));
  7524. this._handles.disableSelection();
  7525. this._handles.on("mouseover", function() {
  7526. if (!that.resizing) {
  7527. if (this.className) {
  7528. axis = this.className.match(/ui-resizable-(se|sw|ne|nw|n|e|s|w)/i);
  7529. }
  7530. that.axis = axis && axis[1] ? axis[1] : "se";
  7531. }
  7532. });
  7533. if (o.autoHide) {
  7534. this._handles.hide();
  7535. this._addClass("ui-resizable-autohide");
  7536. }
  7537. },
  7538. _removeHandles: function() {
  7539. this._addedHandles.remove();
  7540. },
  7541. _mouseCapture: function(event) {
  7542. var i, handle, capture = false;
  7543. for (i in this.handles) {
  7544. handle = $(this.handles[i])[0];
  7545. if (handle === event.target || $.contains(handle, event.target)) {
  7546. capture = true;
  7547. }
  7548. }
  7549. return !this.options.disabled && capture;
  7550. },
  7551. _mouseStart: function(event) {
  7552. var curleft, curtop, cursor, calculatedSize, o = this.options, el = this.element;
  7553. this.resizing = true;
  7554. this._renderProxy();
  7555. curleft = this._num(this.helper.css("left"));
  7556. curtop = this._num(this.helper.css("top"));
  7557. if (o.containment) {
  7558. curleft += $(o.containment).scrollLeft() || 0;
  7559. curtop += $(o.containment).scrollTop() || 0;
  7560. }
  7561. this.offset = this.helper.offset();
  7562. this.position = { left: curleft, top: curtop };
  7563. if (!this._helper) {
  7564. calculatedSize = this._calculateAdjustedElementDimensions(el);
  7565. }
  7566. this.size = this._helper ? {
  7567. width: this.helper.width(),
  7568. height: this.helper.height()
  7569. } : {
  7570. width: calculatedSize.width,
  7571. height: calculatedSize.height
  7572. };
  7573. this.originalSize = this._helper ? {
  7574. width: el.outerWidth(),
  7575. height: el.outerHeight()
  7576. } : {
  7577. width: calculatedSize.width,
  7578. height: calculatedSize.height
  7579. };
  7580. this.sizeDiff = {
  7581. width: el.outerWidth() - el.width(),
  7582. height: el.outerHeight() - el.height()
  7583. };
  7584. this.originalPosition = { left: curleft, top: curtop };
  7585. this.originalMousePosition = { left: event.pageX, top: event.pageY };
  7586. this.aspectRatio = typeof o.aspectRatio === "number" ? o.aspectRatio : this.originalSize.width / this.originalSize.height || 1;
  7587. cursor = $(".ui-resizable-" + this.axis).css("cursor");
  7588. $("body").css("cursor", cursor === "auto" ? this.axis + "-resize" : cursor);
  7589. this._addClass("ui-resizable-resizing");
  7590. this._propagate("start", event);
  7591. return true;
  7592. },
  7593. _mouseDrag: function(event) {
  7594. var data2, props, smp = this.originalMousePosition, a = this.axis, dx = event.pageX - smp.left || 0, dy = event.pageY - smp.top || 0, trigger = this._change[a];
  7595. this._updatePrevProperties();
  7596. if (!trigger) {
  7597. return false;
  7598. }
  7599. data2 = trigger.apply(this, [event, dx, dy]);
  7600. this._updateVirtualBoundaries(event.shiftKey);
  7601. if (this._aspectRatio || event.shiftKey) {
  7602. data2 = this._updateRatio(data2, event);
  7603. }
  7604. data2 = this._respectSize(data2, event);
  7605. this._updateCache(data2);
  7606. this._propagate("resize", event);
  7607. props = this._applyChanges();
  7608. if (!this._helper && this._proportionallyResizeElements.length) {
  7609. this._proportionallyResize();
  7610. }
  7611. if (!$.isEmptyObject(props)) {
  7612. this._updatePrevProperties();
  7613. this._trigger("resize", event, this.ui());
  7614. this._applyChanges();
  7615. }
  7616. return false;
  7617. },
  7618. _mouseStop: function(event) {
  7619. this.resizing = false;
  7620. var pr, ista, soffseth, soffsetw, s, left, top, o = this.options, that = this;
  7621. if (this._helper) {
  7622. pr = this._proportionallyResizeElements;
  7623. ista = pr.length && /textarea/i.test(pr[0].nodeName);
  7624. soffseth = ista && this._hasScroll(pr[0], "left") ? 0 : that.sizeDiff.height;
  7625. soffsetw = ista ? 0 : that.sizeDiff.width;
  7626. s = {
  7627. width: that.helper.width() - soffsetw,
  7628. height: that.helper.height() - soffseth
  7629. };
  7630. left = parseFloat(that.element.css("left")) + (that.position.left - that.originalPosition.left) || null;
  7631. top = parseFloat(that.element.css("top")) + (that.position.top - that.originalPosition.top) || null;
  7632. if (!o.animate) {
  7633. this.element.css($.extend(s, { top, left }));
  7634. }
  7635. that.helper.height(that.size.height);
  7636. that.helper.width(that.size.width);
  7637. if (this._helper && !o.animate) {
  7638. this._proportionallyResize();
  7639. }
  7640. }
  7641. $("body").css("cursor", "auto");
  7642. this._removeClass("ui-resizable-resizing");
  7643. this._propagate("stop", event);
  7644. if (this._helper) {
  7645. this.helper.remove();
  7646. }
  7647. return false;
  7648. },
  7649. _updatePrevProperties: function() {
  7650. this.prevPosition = {
  7651. top: this.position.top,
  7652. left: this.position.left
  7653. };
  7654. this.prevSize = {
  7655. width: this.size.width,
  7656. height: this.size.height
  7657. };
  7658. },
  7659. _applyChanges: function() {
  7660. var props = {};
  7661. if (this.position.top !== this.prevPosition.top) {
  7662. props.top = this.position.top + "px";
  7663. }
  7664. if (this.position.left !== this.prevPosition.left) {
  7665. props.left = this.position.left + "px";
  7666. }
  7667. this.helper.css(props);
  7668. if (this.size.width !== this.prevSize.width) {
  7669. props.width = this.size.width + "px";
  7670. this.helper.width(props.width);
  7671. }
  7672. if (this.size.height !== this.prevSize.height) {
  7673. props.height = this.size.height + "px";
  7674. this.helper.height(props.height);
  7675. }
  7676. return props;
  7677. },
  7678. _updateVirtualBoundaries: function(forceAspectRatio) {
  7679. var pMinWidth, pMaxWidth, pMinHeight, pMaxHeight, b, o = this.options;
  7680. b = {
  7681. minWidth: this._isNumber(o.minWidth) ? o.minWidth : 0,
  7682. maxWidth: this._isNumber(o.maxWidth) ? o.maxWidth : Infinity,
  7683. minHeight: this._isNumber(o.minHeight) ? o.minHeight : 0,
  7684. maxHeight: this._isNumber(o.maxHeight) ? o.maxHeight : Infinity
  7685. };
  7686. if (this._aspectRatio || forceAspectRatio) {
  7687. pMinWidth = b.minHeight * this.aspectRatio;
  7688. pMinHeight = b.minWidth / this.aspectRatio;
  7689. pMaxWidth = b.maxHeight * this.aspectRatio;
  7690. pMaxHeight = b.maxWidth / this.aspectRatio;
  7691. if (pMinWidth > b.minWidth) {
  7692. b.minWidth = pMinWidth;
  7693. }
  7694. if (pMinHeight > b.minHeight) {
  7695. b.minHeight = pMinHeight;
  7696. }
  7697. if (pMaxWidth < b.maxWidth) {
  7698. b.maxWidth = pMaxWidth;
  7699. }
  7700. if (pMaxHeight < b.maxHeight) {
  7701. b.maxHeight = pMaxHeight;
  7702. }
  7703. }
  7704. this._vBoundaries = b;
  7705. },
  7706. _updateCache: function(data2) {
  7707. this.offset = this.helper.offset();
  7708. if (this._isNumber(data2.left)) {
  7709. this.position.left = data2.left;
  7710. }
  7711. if (this._isNumber(data2.top)) {
  7712. this.position.top = data2.top;
  7713. }
  7714. if (this._isNumber(data2.height)) {
  7715. this.size.height = data2.height;
  7716. }
  7717. if (this._isNumber(data2.width)) {
  7718. this.size.width = data2.width;
  7719. }
  7720. },
  7721. _updateRatio: function(data2) {
  7722. var cpos = this.position, csize = this.size, a = this.axis;
  7723. if (this._isNumber(data2.height)) {
  7724. data2.width = data2.height * this.aspectRatio;
  7725. } else if (this._isNumber(data2.width)) {
  7726. data2.height = data2.width / this.aspectRatio;
  7727. }
  7728. if (a === "sw") {
  7729. data2.left = cpos.left + (csize.width - data2.width);
  7730. data2.top = null;
  7731. }
  7732. if (a === "nw") {
  7733. data2.top = cpos.top + (csize.height - data2.height);
  7734. data2.left = cpos.left + (csize.width - data2.width);
  7735. }
  7736. return data2;
  7737. },
  7738. _respectSize: function(data2) {
  7739. var o = this._vBoundaries, a = this.axis, ismaxw = this._isNumber(data2.width) && o.maxWidth && o.maxWidth < data2.width, ismaxh = this._isNumber(data2.height) && o.maxHeight && o.maxHeight < data2.height, isminw = this._isNumber(data2.width) && o.minWidth && o.minWidth > data2.width, isminh = this._isNumber(data2.height) && o.minHeight && o.minHeight > data2.height, dw = this.originalPosition.left + this.originalSize.width, dh = this.originalPosition.top + this.originalSize.height, cw = /sw|nw|w/.test(a), ch = /nw|ne|n/.test(a);
  7740. if (isminw) {
  7741. data2.width = o.minWidth;
  7742. }
  7743. if (isminh) {
  7744. data2.height = o.minHeight;
  7745. }
  7746. if (ismaxw) {
  7747. data2.width = o.maxWidth;
  7748. }
  7749. if (ismaxh) {
  7750. data2.height = o.maxHeight;
  7751. }
  7752. if (isminw && cw) {
  7753. data2.left = dw - o.minWidth;
  7754. }
  7755. if (ismaxw && cw) {
  7756. data2.left = dw - o.maxWidth;
  7757. }
  7758. if (isminh && ch) {
  7759. data2.top = dh - o.minHeight;
  7760. }
  7761. if (ismaxh && ch) {
  7762. data2.top = dh - o.maxHeight;
  7763. }
  7764. if (!data2.width && !data2.height && !data2.left && data2.top) {
  7765. data2.top = null;
  7766. } else if (!data2.width && !data2.height && !data2.top && data2.left) {
  7767. data2.left = null;
  7768. }
  7769. return data2;
  7770. },
  7771. _getPaddingPlusBorderDimensions: function(element) {
  7772. var i = 0, widths = [], borders = [
  7773. element.css("borderTopWidth"),
  7774. element.css("borderRightWidth"),
  7775. element.css("borderBottomWidth"),
  7776. element.css("borderLeftWidth")
  7777. ], paddings = [
  7778. element.css("paddingTop"),
  7779. element.css("paddingRight"),
  7780. element.css("paddingBottom"),
  7781. element.css("paddingLeft")
  7782. ];
  7783. for (; i < 4; i++) {
  7784. widths[i] = parseFloat(borders[i]) || 0;
  7785. widths[i] += parseFloat(paddings[i]) || 0;
  7786. }
  7787. return {
  7788. height: widths[0] + widths[2],
  7789. width: widths[1] + widths[3]
  7790. };
  7791. },
  7792. _calculateAdjustedElementDimensions: function(element) {
  7793. var elWidth, elHeight, paddingBorder, ce = element.get(0);
  7794. if (element.css("box-sizing") !== "content-box" || !this._hasScroll(ce) && !this._hasScroll(ce, "left")) {
  7795. return {
  7796. height: parseFloat(element.css("height")),
  7797. width: parseFloat(element.css("width"))
  7798. };
  7799. }
  7800. elWidth = parseFloat(ce.style.width);
  7801. elHeight = parseFloat(ce.style.height);
  7802. paddingBorder = this._getPaddingPlusBorderDimensions(element);
  7803. elWidth = isNaN(elWidth) ? this._getElementTheoreticalSize(element, paddingBorder, "width") : elWidth;
  7804. elHeight = isNaN(elHeight) ? this._getElementTheoreticalSize(element, paddingBorder, "height") : elHeight;
  7805. return {
  7806. height: elHeight,
  7807. width: elWidth
  7808. };
  7809. },
  7810. _getElementTheoreticalSize: function(element, extraSize, dimension) {
  7811. var size = Math.max(0, Math.ceil(
  7812. element.get(0)["offset" + dimension[0].toUpperCase() + dimension.slice(1)] - extraSize[dimension] - 0.5
  7813. // If offsetWidth/offsetHeight is unknown, then we can't determine theoretical size.
  7814. // Use an explicit zero to avoid NaN.
  7815. // See https://github.com/jquery/jquery/issues/3964
  7816. )) || 0;
  7817. return size;
  7818. },
  7819. _proportionallyResize: function() {
  7820. if (!this._proportionallyResizeElements.length) {
  7821. return;
  7822. }
  7823. var prel, i = 0, element = this.helper || this.element;
  7824. for (; i < this._proportionallyResizeElements.length; i++) {
  7825. prel = this._proportionallyResizeElements[i];
  7826. if (!this.outerDimensions) {
  7827. this.outerDimensions = this._getPaddingPlusBorderDimensions(prel);
  7828. }
  7829. prel.css({
  7830. height: element.height() - this.outerDimensions.height || 0,
  7831. width: element.width() - this.outerDimensions.width || 0
  7832. });
  7833. }
  7834. },
  7835. _renderProxy: function() {
  7836. var el = this.element, o = this.options;
  7837. this.elementOffset = el.offset();
  7838. if (this._helper) {
  7839. this.helper = this.helper || $("<div></div>").css({ overflow: "hidden" });
  7840. this._addClass(this.helper, this._helper);
  7841. this.helper.css({
  7842. width: this.element.outerWidth(),
  7843. height: this.element.outerHeight(),
  7844. position: "absolute",
  7845. left: this.elementOffset.left + "px",
  7846. top: this.elementOffset.top + "px",
  7847. zIndex: ++o.zIndex
  7848. //TODO: Don't modify option
  7849. });
  7850. this.helper.appendTo("body").disableSelection();
  7851. } else {
  7852. this.helper = this.element;
  7853. }
  7854. },
  7855. _change: {
  7856. e: function(event, dx) {
  7857. return { width: this.originalSize.width + dx };
  7858. },
  7859. w: function(event, dx) {
  7860. var cs = this.originalSize, sp = this.originalPosition;
  7861. return { left: sp.left + dx, width: cs.width - dx };
  7862. },
  7863. n: function(event, dx, dy) {
  7864. var cs = this.originalSize, sp = this.originalPosition;
  7865. return { top: sp.top + dy, height: cs.height - dy };
  7866. },
  7867. s: function(event, dx, dy) {
  7868. return { height: this.originalSize.height + dy };
  7869. },
  7870. se: function(event, dx, dy) {
  7871. return $.extend(
  7872. this._change.s.apply(this, arguments),
  7873. this._change.e.apply(this, [event, dx, dy])
  7874. );
  7875. },
  7876. sw: function(event, dx, dy) {
  7877. return $.extend(
  7878. this._change.s.apply(this, arguments),
  7879. this._change.w.apply(this, [event, dx, dy])
  7880. );
  7881. },
  7882. ne: function(event, dx, dy) {
  7883. return $.extend(
  7884. this._change.n.apply(this, arguments),
  7885. this._change.e.apply(this, [event, dx, dy])
  7886. );
  7887. },
  7888. nw: function(event, dx, dy) {
  7889. return $.extend(
  7890. this._change.n.apply(this, arguments),
  7891. this._change.w.apply(this, [event, dx, dy])
  7892. );
  7893. }
  7894. },
  7895. _propagate: function(n, event) {
  7896. $.ui.plugin.call(this, n, [event, this.ui()]);
  7897. if (n !== "resize") {
  7898. this._trigger(n, event, this.ui());
  7899. }
  7900. },
  7901. plugins: {},
  7902. ui: function() {
  7903. return {
  7904. originalElement: this.originalElement,
  7905. element: this.element,
  7906. helper: this.helper,
  7907. position: this.position,
  7908. size: this.size,
  7909. originalSize: this.originalSize,
  7910. originalPosition: this.originalPosition
  7911. };
  7912. }
  7913. });
  7914. $.ui.plugin.add("resizable", "animate", {
  7915. stop: function(event) {
  7916. var that = $(this).resizable("instance"), o = that.options, pr = that._proportionallyResizeElements, ista = pr.length && /textarea/i.test(pr[0].nodeName), soffseth = ista && that._hasScroll(pr[0], "left") ? 0 : that.sizeDiff.height, soffsetw = ista ? 0 : that.sizeDiff.width, style = {
  7917. width: that.size.width - soffsetw,
  7918. height: that.size.height - soffseth
  7919. }, left = parseFloat(that.element.css("left")) + (that.position.left - that.originalPosition.left) || null, top = parseFloat(that.element.css("top")) + (that.position.top - that.originalPosition.top) || null;
  7920. that.element.animate(
  7921. $.extend(style, top && left ? { top, left } : {}),
  7922. {
  7923. duration: o.animateDuration,
  7924. easing: o.animateEasing,
  7925. step: function() {
  7926. var data2 = {
  7927. width: parseFloat(that.element.css("width")),
  7928. height: parseFloat(that.element.css("height")),
  7929. top: parseFloat(that.element.css("top")),
  7930. left: parseFloat(that.element.css("left"))
  7931. };
  7932. if (pr && pr.length) {
  7933. $(pr[0]).css({ width: data2.width, height: data2.height });
  7934. }
  7935. that._updateCache(data2);
  7936. that._propagate("resize", event);
  7937. }
  7938. }
  7939. );
  7940. }
  7941. });
  7942. $.ui.plugin.add("resizable", "containment", {
  7943. start: function() {
  7944. var element, p, co, ch, cw, width, height, that = $(this).resizable("instance"), o = that.options, el = that.element, oc = o.containment, ce = oc instanceof $ ? oc.get(0) : /parent/.test(oc) ? el.parent().get(0) : oc;
  7945. if (!ce) {
  7946. return;
  7947. }
  7948. that.containerElement = $(ce);
  7949. if (/document/.test(oc) || oc === document) {
  7950. that.containerOffset = {
  7951. left: 0,
  7952. top: 0
  7953. };
  7954. that.containerPosition = {
  7955. left: 0,
  7956. top: 0
  7957. };
  7958. that.parentData = {
  7959. element: $(document),
  7960. left: 0,
  7961. top: 0,
  7962. width: $(document).width(),
  7963. height: $(document).height() || document.body.parentNode.scrollHeight
  7964. };
  7965. } else {
  7966. element = $(ce);
  7967. p = [];
  7968. $(["Top", "Right", "Left", "Bottom"]).each(function(i, name) {
  7969. p[i] = that._num(element.css("padding" + name));
  7970. });
  7971. that.containerOffset = element.offset();
  7972. that.containerPosition = element.position();
  7973. that.containerSize = {
  7974. height: element.innerHeight() - p[3],
  7975. width: element.innerWidth() - p[1]
  7976. };
  7977. co = that.containerOffset;
  7978. ch = that.containerSize.height;
  7979. cw = that.containerSize.width;
  7980. width = that._hasScroll(ce, "left") ? ce.scrollWidth : cw;
  7981. height = that._hasScroll(ce) ? ce.scrollHeight : ch;
  7982. that.parentData = {
  7983. element: ce,
  7984. left: co.left,
  7985. top: co.top,
  7986. width,
  7987. height
  7988. };
  7989. }
  7990. },
  7991. resize: function(event) {
  7992. var woset, hoset, isParent, isOffsetRelative, that = $(this).resizable("instance"), o = that.options, co = that.containerOffset, cp = that.position, pRatio = that._aspectRatio || event.shiftKey, cop = {
  7993. top: 0,
  7994. left: 0
  7995. }, ce = that.containerElement, continueResize = true;
  7996. if (ce[0] !== document && /static/.test(ce.css("position"))) {
  7997. cop = co;
  7998. }
  7999. if (cp.left < (that._helper ? co.left : 0)) {
  8000. that.size.width = that.size.width + (that._helper ? that.position.left - co.left : that.position.left - cop.left);
  8001. if (pRatio) {
  8002. that.size.height = that.size.width / that.aspectRatio;
  8003. continueResize = false;
  8004. }
  8005. that.position.left = o.helper ? co.left : 0;
  8006. }
  8007. if (cp.top < (that._helper ? co.top : 0)) {
  8008. that.size.height = that.size.height + (that._helper ? that.position.top - co.top : that.position.top);
  8009. if (pRatio) {
  8010. that.size.width = that.size.height * that.aspectRatio;
  8011. continueResize = false;
  8012. }
  8013. that.position.top = that._helper ? co.top : 0;
  8014. }
  8015. isParent = that.containerElement.get(0) === that.element.parent().get(0);
  8016. isOffsetRelative = /relative|absolute/.test(that.containerElement.css("position"));
  8017. if (isParent && isOffsetRelative) {
  8018. that.offset.left = that.parentData.left + that.position.left;
  8019. that.offset.top = that.parentData.top + that.position.top;
  8020. } else {
  8021. that.offset.left = that.element.offset().left;
  8022. that.offset.top = that.element.offset().top;
  8023. }
  8024. woset = Math.abs(that.sizeDiff.width + (that._helper ? that.offset.left - cop.left : that.offset.left - co.left));
  8025. hoset = Math.abs(that.sizeDiff.height + (that._helper ? that.offset.top - cop.top : that.offset.top - co.top));
  8026. if (woset + that.size.width >= that.parentData.width) {
  8027. that.size.width = that.parentData.width - woset;
  8028. if (pRatio) {
  8029. that.size.height = that.size.width / that.aspectRatio;
  8030. continueResize = false;
  8031. }
  8032. }
  8033. if (hoset + that.size.height >= that.parentData.height) {
  8034. that.size.height = that.parentData.height - hoset;
  8035. if (pRatio) {
  8036. that.size.width = that.size.height * that.aspectRatio;
  8037. continueResize = false;
  8038. }
  8039. }
  8040. if (!continueResize) {
  8041. that.position.left = that.prevPosition.left;
  8042. that.position.top = that.prevPosition.top;
  8043. that.size.width = that.prevSize.width;
  8044. that.size.height = that.prevSize.height;
  8045. }
  8046. },
  8047. stop: function() {
  8048. var that = $(this).resizable("instance"), o = that.options, co = that.containerOffset, cop = that.containerPosition, ce = that.containerElement, helper = $(that.helper), ho = helper.offset(), w = helper.outerWidth() - that.sizeDiff.width, h = helper.outerHeight() - that.sizeDiff.height;
  8049. if (that._helper && !o.animate && /relative/.test(ce.css("position"))) {
  8050. $(this).css({
  8051. left: ho.left - cop.left - co.left,
  8052. width: w,
  8053. height: h
  8054. });
  8055. }
  8056. if (that._helper && !o.animate && /static/.test(ce.css("position"))) {
  8057. $(this).css({
  8058. left: ho.left - cop.left - co.left,
  8059. width: w,
  8060. height: h
  8061. });
  8062. }
  8063. }
  8064. });
  8065. $.ui.plugin.add("resizable", "alsoResize", {
  8066. start: function() {
  8067. var that = $(this).resizable("instance"), o = that.options;
  8068. $(o.alsoResize).each(function() {
  8069. var el = $(this), elSize = that._calculateAdjustedElementDimensions(el);
  8070. el.data("ui-resizable-alsoresize", {
  8071. width: elSize.width,
  8072. height: elSize.height,
  8073. left: parseFloat(el.css("left")),
  8074. top: parseFloat(el.css("top"))
  8075. });
  8076. });
  8077. },
  8078. resize: function(event, ui) {
  8079. var that = $(this).resizable("instance"), o = that.options, os = that.originalSize, op = that.originalPosition, delta = {
  8080. height: that.size.height - os.height || 0,
  8081. width: that.size.width - os.width || 0,
  8082. top: that.position.top - op.top || 0,
  8083. left: that.position.left - op.left || 0
  8084. };
  8085. $(o.alsoResize).each(function() {
  8086. var el = $(this), start = $(this).data("ui-resizable-alsoresize"), style = {}, css = el.parents(ui.originalElement[0]).length ? ["width", "height"] : ["width", "height", "top", "left"];
  8087. $.each(css, function(i, prop) {
  8088. var sum = (start[prop] || 0) + (delta[prop] || 0);
  8089. if (sum && sum >= 0) {
  8090. style[prop] = sum || null;
  8091. }
  8092. });
  8093. el.css(style);
  8094. });
  8095. },
  8096. stop: function() {
  8097. $(this).removeData("ui-resizable-alsoresize");
  8098. }
  8099. });
  8100. $.ui.plugin.add("resizable", "ghost", {
  8101. start: function() {
  8102. var that = $(this).resizable("instance"), cs = that.size;
  8103. that.ghost = that.originalElement.clone();
  8104. that.ghost.css({
  8105. opacity: 0.25,
  8106. display: "block",
  8107. position: "relative",
  8108. height: cs.height,
  8109. width: cs.width,
  8110. margin: 0,
  8111. left: 0,
  8112. top: 0
  8113. });
  8114. that._addClass(that.ghost, "ui-resizable-ghost");
  8115. if ($.uiBackCompat === true && typeof that.options.ghost === "string") {
  8116. that.ghost.addClass(this.options.ghost);
  8117. }
  8118. that.ghost.appendTo(that.helper);
  8119. },
  8120. resize: function() {
  8121. var that = $(this).resizable("instance");
  8122. if (that.ghost) {
  8123. that.ghost.css({
  8124. position: "relative",
  8125. height: that.size.height,
  8126. width: that.size.width
  8127. });
  8128. }
  8129. },
  8130. stop: function() {
  8131. var that = $(this).resizable("instance");
  8132. if (that.ghost && that.helper) {
  8133. that.helper.get(0).removeChild(that.ghost.get(0));
  8134. }
  8135. }
  8136. });
  8137. $.ui.plugin.add("resizable", "grid", {
  8138. resize: function() {
  8139. var outerDimensions, that = $(this).resizable("instance"), o = that.options, cs = that.size, os = that.originalSize, op = that.originalPosition, a = that.axis, grid = typeof o.grid === "number" ? [o.grid, o.grid] : o.grid, gridX = grid[0] || 1, gridY = grid[1] || 1, ox = Math.round((cs.width - os.width) / gridX) * gridX, oy = Math.round((cs.height - os.height) / gridY) * gridY, newWidth = os.width + ox, newHeight = os.height + oy, isMaxWidth = o.maxWidth && o.maxWidth < newWidth, isMaxHeight = o.maxHeight && o.maxHeight < newHeight, isMinWidth = o.minWidth && o.minWidth > newWidth, isMinHeight = o.minHeight && o.minHeight > newHeight;
  8140. o.grid = grid;
  8141. if (isMinWidth) {
  8142. newWidth += gridX;
  8143. }
  8144. if (isMinHeight) {
  8145. newHeight += gridY;
  8146. }
  8147. if (isMaxWidth) {
  8148. newWidth -= gridX;
  8149. }
  8150. if (isMaxHeight) {
  8151. newHeight -= gridY;
  8152. }
  8153. if (/^(se|s|e)$/.test(a)) {
  8154. that.size.width = newWidth;
  8155. that.size.height = newHeight;
  8156. } else if (/^(ne)$/.test(a)) {
  8157. that.size.width = newWidth;
  8158. that.size.height = newHeight;
  8159. that.position.top = op.top - oy;
  8160. } else if (/^(sw)$/.test(a)) {
  8161. that.size.width = newWidth;
  8162. that.size.height = newHeight;
  8163. that.position.left = op.left - ox;
  8164. } else {
  8165. if (newHeight - gridY <= 0 || newWidth - gridX <= 0) {
  8166. outerDimensions = that._getPaddingPlusBorderDimensions(this);
  8167. }
  8168. if (newHeight - gridY > 0) {
  8169. that.size.height = newHeight;
  8170. that.position.top = op.top - oy;
  8171. } else {
  8172. newHeight = gridY - outerDimensions.height;
  8173. that.size.height = newHeight;
  8174. that.position.top = op.top + os.height - newHeight;
  8175. }
  8176. if (newWidth - gridX > 0) {
  8177. that.size.width = newWidth;
  8178. that.position.left = op.left - ox;
  8179. } else {
  8180. newWidth = gridX - outerDimensions.width;
  8181. that.size.width = newWidth;
  8182. that.position.left = op.left + os.width - newWidth;
  8183. }
  8184. }
  8185. }
  8186. });
  8187. var widgetsResizable = $.ui.resizable;
  8188. $.widget("ui.dialog", {
  8189. version: "1.14.1",
  8190. options: {
  8191. appendTo: "body",
  8192. autoOpen: true,
  8193. buttons: [],
  8194. classes: {
  8195. "ui-dialog": "ui-corner-all",
  8196. "ui-dialog-titlebar": "ui-corner-all"
  8197. },
  8198. closeOnEscape: true,
  8199. closeText: "Close",
  8200. draggable: true,
  8201. hide: null,
  8202. height: "auto",
  8203. maxHeight: null,
  8204. maxWidth: null,
  8205. minHeight: 150,
  8206. minWidth: 150,
  8207. modal: false,
  8208. position: {
  8209. my: "center",
  8210. at: "center",
  8211. of: window,
  8212. collision: "fit",
  8213. // Ensure the titlebar is always visible
  8214. using: function(pos) {
  8215. var topOffset = $(this).css(pos).offset().top;
  8216. if (topOffset < 0) {
  8217. $(this).css("top", pos.top - topOffset);
  8218. }
  8219. }
  8220. },
  8221. resizable: true,
  8222. show: null,
  8223. title: null,
  8224. uiDialogTitleHeadingLevel: 0,
  8225. width: 300,
  8226. // Callbacks
  8227. beforeClose: null,
  8228. close: null,
  8229. drag: null,
  8230. dragStart: null,
  8231. dragStop: null,
  8232. focus: null,
  8233. open: null,
  8234. resize: null,
  8235. resizeStart: null,
  8236. resizeStop: null
  8237. },
  8238. sizeRelatedOptions: {
  8239. buttons: true,
  8240. height: true,
  8241. maxHeight: true,
  8242. maxWidth: true,
  8243. minHeight: true,
  8244. minWidth: true,
  8245. width: true
  8246. },
  8247. resizableRelatedOptions: {
  8248. maxHeight: true,
  8249. maxWidth: true,
  8250. minHeight: true,
  8251. minWidth: true
  8252. },
  8253. _create: function() {
  8254. this.originalCss = {
  8255. display: this.element[0].style.display,
  8256. width: this.element[0].style.width,
  8257. minHeight: this.element[0].style.minHeight,
  8258. maxHeight: this.element[0].style.maxHeight,
  8259. height: this.element[0].style.height
  8260. };
  8261. this.originalPosition = {
  8262. parent: this.element.parent(),
  8263. index: this.element.parent().children().index(this.element)
  8264. };
  8265. this.originalTitle = this.element.attr("title");
  8266. if (this.options.title == null && this.originalTitle != null) {
  8267. this.options.title = this.originalTitle;
  8268. }
  8269. if (this.options.disabled) {
  8270. this.options.disabled = false;
  8271. }
  8272. this._createWrapper();
  8273. this.element.show().removeAttr("title").appendTo(this.uiDialog);
  8274. this._addClass("ui-dialog-content", "ui-widget-content");
  8275. this._createTitlebar();
  8276. this._createButtonPane();
  8277. if (this.options.draggable && $.fn.draggable) {
  8278. this._makeDraggable();
  8279. }
  8280. if (this.options.resizable && $.fn.resizable) {
  8281. this._makeResizable();
  8282. }
  8283. this._isOpen = false;
  8284. this._trackFocus();
  8285. },
  8286. _init: function() {
  8287. if (this.options.autoOpen) {
  8288. this.open();
  8289. }
  8290. },
  8291. _appendTo: function() {
  8292. var element = this.options.appendTo;
  8293. if (element && (element.jquery || element.nodeType)) {
  8294. return $(element);
  8295. }
  8296. return this.document.find(element || "body").eq(0);
  8297. },
  8298. _destroy: function() {
  8299. var next, originalPosition = this.originalPosition;
  8300. this._untrackInstance();
  8301. this._destroyOverlay();
  8302. this.element.removeUniqueId().css(this.originalCss).detach();
  8303. this.uiDialog.remove();
  8304. if (this.originalTitle) {
  8305. this.element.attr("title", this.originalTitle);
  8306. }
  8307. next = originalPosition.parent.children().eq(originalPosition.index);
  8308. if (next.length && next[0] !== this.element[0]) {
  8309. next.before(this.element);
  8310. } else {
  8311. originalPosition.parent.append(this.element);
  8312. }
  8313. },
  8314. widget: function() {
  8315. return this.uiDialog;
  8316. },
  8317. disable: $.noop,
  8318. enable: $.noop,
  8319. close: function(event) {
  8320. var that = this;
  8321. if (!this._isOpen || this._trigger("beforeClose", event) === false) {
  8322. return;
  8323. }
  8324. this._isOpen = false;
  8325. this._focusedElement = null;
  8326. this._destroyOverlay();
  8327. this._untrackInstance();
  8328. if (!this.opener.filter(":focusable").trigger("focus").length) {
  8329. $(this.document[0].activeElement).trigger("blur");
  8330. }
  8331. this._hide(this.uiDialog, this.options.hide, function() {
  8332. that._trigger("close", event);
  8333. });
  8334. },
  8335. isOpen: function() {
  8336. return this._isOpen;
  8337. },
  8338. moveToTop: function() {
  8339. this._moveToTop();
  8340. },
  8341. _moveToTop: function(event, silent) {
  8342. var moved = false, zIndices = this.uiDialog.siblings(".ui-front:visible").map(function() {
  8343. return +$(this).css("z-index");
  8344. }).get(), zIndexMax = Math.max.apply(null, zIndices);
  8345. if (zIndexMax >= +this.uiDialog.css("z-index")) {
  8346. this.uiDialog.css("z-index", zIndexMax + 1);
  8347. moved = true;
  8348. }
  8349. if (moved && !silent) {
  8350. this._trigger("focus", event);
  8351. }
  8352. return moved;
  8353. },
  8354. open: function() {
  8355. var that = this;
  8356. if (this._isOpen) {
  8357. if (this._moveToTop()) {
  8358. this._focusTabbable();
  8359. }
  8360. return;
  8361. }
  8362. this._isOpen = true;
  8363. this.opener = $(this.document[0].activeElement);
  8364. this._size();
  8365. this._position();
  8366. this._createOverlay();
  8367. this._moveToTop(null, true);
  8368. if (this.overlay) {
  8369. this.overlay.css("z-index", this.uiDialog.css("z-index") - 1);
  8370. }
  8371. this._show(this.uiDialog, this.options.show, function() {
  8372. that._focusTabbable();
  8373. that._trigger("focus");
  8374. });
  8375. this._makeFocusTarget();
  8376. this._trigger("open");
  8377. },
  8378. _focusTabbable: function() {
  8379. var hasFocus = this._focusedElement;
  8380. if (!hasFocus) {
  8381. hasFocus = this.element.find("[autofocus]");
  8382. }
  8383. if (!hasFocus.length) {
  8384. hasFocus = this.element.find(":tabbable");
  8385. }
  8386. if (!hasFocus.length) {
  8387. hasFocus = this.uiDialogButtonPane.find(":tabbable");
  8388. }
  8389. if (!hasFocus.length) {
  8390. hasFocus = this.uiDialogTitlebarClose.filter(":tabbable");
  8391. }
  8392. if (!hasFocus.length) {
  8393. hasFocus = this.uiDialog;
  8394. }
  8395. hasFocus.eq(0).trigger("focus");
  8396. },
  8397. _restoreTabbableFocus: function() {
  8398. var activeElement = this.document[0].activeElement, isActive = this.uiDialog[0] === activeElement || $.contains(this.uiDialog[0], activeElement);
  8399. if (!isActive) {
  8400. this._focusTabbable();
  8401. }
  8402. },
  8403. _keepFocus: function(event) {
  8404. event.preventDefault();
  8405. this._restoreTabbableFocus();
  8406. },
  8407. _createWrapper: function() {
  8408. this.uiDialog = $("<div>").hide().attr({
  8409. // Setting tabIndex makes the div focusable
  8410. tabIndex: -1,
  8411. role: "dialog",
  8412. "aria-modal": this.options.modal ? "true" : null
  8413. }).appendTo(this._appendTo());
  8414. this._addClass(this.uiDialog, "ui-dialog", "ui-widget ui-widget-content ui-front");
  8415. this._on(this.uiDialog, {
  8416. keydown: function(event) {
  8417. if (this.options.closeOnEscape && !event.isDefaultPrevented() && event.keyCode && event.keyCode === $.ui.keyCode.ESCAPE) {
  8418. event.preventDefault();
  8419. this.close(event);
  8420. return;
  8421. }
  8422. if (event.keyCode !== $.ui.keyCode.TAB || event.isDefaultPrevented()) {
  8423. return;
  8424. }
  8425. var tabbables = this.uiDialog.find(":tabbable"), first = tabbables.first(), last = tabbables.last();
  8426. if ((event.target === last[0] || event.target === this.uiDialog[0]) && !event.shiftKey) {
  8427. this._delay(function() {
  8428. first.trigger("focus");
  8429. });
  8430. event.preventDefault();
  8431. } else if ((event.target === first[0] || event.target === this.uiDialog[0]) && event.shiftKey) {
  8432. this._delay(function() {
  8433. last.trigger("focus");
  8434. });
  8435. event.preventDefault();
  8436. }
  8437. },
  8438. mousedown: function(event) {
  8439. if (this._moveToTop(event)) {
  8440. this._focusTabbable();
  8441. }
  8442. }
  8443. });
  8444. if (!this.element.find("[aria-describedby]").length) {
  8445. this.uiDialog.attr({
  8446. "aria-describedby": this.element.uniqueId().attr("id")
  8447. });
  8448. }
  8449. },
  8450. _createTitlebar: function() {
  8451. var uiDialogTitle;
  8452. this.uiDialogTitlebar = $("<div>");
  8453. this._addClass(
  8454. this.uiDialogTitlebar,
  8455. "ui-dialog-titlebar",
  8456. "ui-widget-header ui-helper-clearfix"
  8457. );
  8458. this._on(this.uiDialogTitlebar, {
  8459. mousedown: function(event) {
  8460. if (!$(event.target).closest(".ui-dialog-titlebar-close")) {
  8461. this.uiDialog.trigger("focus");
  8462. }
  8463. }
  8464. });
  8465. this.uiDialogTitlebarClose = $("<button type='button'></button>").button({
  8466. label: $("<a>").text(this.options.closeText).html(),
  8467. icon: "ui-icon-closethick",
  8468. showLabel: false
  8469. }).appendTo(this.uiDialogTitlebar);
  8470. this._addClass(this.uiDialogTitlebarClose, "ui-dialog-titlebar-close");
  8471. this._on(this.uiDialogTitlebarClose, {
  8472. click: function(event) {
  8473. event.preventDefault();
  8474. this.close(event);
  8475. }
  8476. });
  8477. var uiDialogHeadingLevel = Number.isInteger(this.options.uiDialogTitleHeadingLevel) && this.options.uiDialogTitleHeadingLevel > 0 && this.options.uiDialogTitleHeadingLevel <= 6 ? "h" + this.options.uiDialogTitleHeadingLevel : "span";
  8478. uiDialogTitle = $("<" + uiDialogHeadingLevel + ">").uniqueId().prependTo(this.uiDialogTitlebar);
  8479. this._addClass(uiDialogTitle, "ui-dialog-title");
  8480. this._title(uiDialogTitle);
  8481. this.uiDialogTitlebar.prependTo(this.uiDialog);
  8482. this.uiDialog.attr({
  8483. "aria-labelledby": uiDialogTitle.attr("id")
  8484. });
  8485. },
  8486. _title: function(title) {
  8487. if (this.options.title) {
  8488. title.text(this.options.title);
  8489. } else {
  8490. title.html("&#160;");
  8491. }
  8492. },
  8493. _createButtonPane: function() {
  8494. this.uiDialogButtonPane = $("<div>");
  8495. this._addClass(
  8496. this.uiDialogButtonPane,
  8497. "ui-dialog-buttonpane",
  8498. "ui-widget-content ui-helper-clearfix"
  8499. );
  8500. this.uiButtonSet = $("<div>").appendTo(this.uiDialogButtonPane);
  8501. this._addClass(this.uiButtonSet, "ui-dialog-buttonset");
  8502. this._createButtons();
  8503. },
  8504. _createButtons: function() {
  8505. var that = this, buttons = this.options.buttons;
  8506. this.uiDialogButtonPane.remove();
  8507. this.uiButtonSet.empty();
  8508. if ($.isEmptyObject(buttons) || Array.isArray(buttons) && !buttons.length) {
  8509. this._removeClass(this.uiDialog, "ui-dialog-buttons");
  8510. return;
  8511. }
  8512. $.each(buttons, function(name, props) {
  8513. var click, buttonOptions;
  8514. props = typeof props === "function" ? { click: props, text: name } : props;
  8515. props = $.extend({ type: "button" }, props);
  8516. click = props.click;
  8517. buttonOptions = {
  8518. icon: props.icon,
  8519. iconPosition: props.iconPosition,
  8520. showLabel: props.showLabel,
  8521. // Deprecated options
  8522. icons: props.icons,
  8523. text: props.text
  8524. };
  8525. delete props.click;
  8526. delete props.icon;
  8527. delete props.iconPosition;
  8528. delete props.showLabel;
  8529. delete props.icons;
  8530. if (typeof props.text === "boolean") {
  8531. delete props.text;
  8532. }
  8533. $("<button></button>", props).button(buttonOptions).appendTo(that.uiButtonSet).on("click", function() {
  8534. click.apply(that.element[0], arguments);
  8535. });
  8536. });
  8537. this._addClass(this.uiDialog, "ui-dialog-buttons");
  8538. this.uiDialogButtonPane.appendTo(this.uiDialog);
  8539. },
  8540. _makeDraggable: function() {
  8541. var that = this, options = this.options;
  8542. function filteredUi(ui) {
  8543. return {
  8544. position: ui.position,
  8545. offset: ui.offset
  8546. };
  8547. }
  8548. this.uiDialog.draggable({
  8549. cancel: ".ui-dialog-content, .ui-dialog-titlebar-close",
  8550. handle: ".ui-dialog-titlebar",
  8551. containment: "document",
  8552. start: function(event, ui) {
  8553. that._addClass($(this), "ui-dialog-dragging");
  8554. that._blockFrames();
  8555. that._trigger("dragStart", event, filteredUi(ui));
  8556. },
  8557. drag: function(event, ui) {
  8558. that._trigger("drag", event, filteredUi(ui));
  8559. },
  8560. stop: function(event, ui) {
  8561. var left = ui.offset.left - that.document.scrollLeft(), top = ui.offset.top - that.document.scrollTop();
  8562. options.position = {
  8563. my: "left top",
  8564. at: "left" + (left >= 0 ? "+" : "") + left + " top" + (top >= 0 ? "+" : "") + top,
  8565. of: that.window
  8566. };
  8567. that._removeClass($(this), "ui-dialog-dragging");
  8568. that._unblockFrames();
  8569. that._trigger("dragStop", event, filteredUi(ui));
  8570. }
  8571. });
  8572. },
  8573. _makeResizable: function() {
  8574. var that = this, options = this.options, handles = options.resizable, position2 = this.uiDialog.css("position"), resizeHandles = typeof handles === "string" ? handles : "n,e,s,w,se,sw,ne,nw";
  8575. function filteredUi(ui) {
  8576. return {
  8577. originalPosition: ui.originalPosition,
  8578. originalSize: ui.originalSize,
  8579. position: ui.position,
  8580. size: ui.size
  8581. };
  8582. }
  8583. this.uiDialog.resizable({
  8584. cancel: ".ui-dialog-content",
  8585. containment: "document",
  8586. alsoResize: this.element,
  8587. maxWidth: options.maxWidth,
  8588. maxHeight: options.maxHeight,
  8589. minWidth: options.minWidth,
  8590. minHeight: this._minHeight(),
  8591. handles: resizeHandles,
  8592. start: function(event, ui) {
  8593. that._addClass($(this), "ui-dialog-resizing");
  8594. that._blockFrames();
  8595. that._trigger("resizeStart", event, filteredUi(ui));
  8596. },
  8597. resize: function(event, ui) {
  8598. that._trigger("resize", event, filteredUi(ui));
  8599. },
  8600. stop: function(event, ui) {
  8601. var offset = that.uiDialog.offset(), left = offset.left - that.document.scrollLeft(), top = offset.top - that.document.scrollTop();
  8602. options.height = that.uiDialog.height();
  8603. options.width = that.uiDialog.width();
  8604. options.position = {
  8605. my: "left top",
  8606. at: "left" + (left >= 0 ? "+" : "") + left + " top" + (top >= 0 ? "+" : "") + top,
  8607. of: that.window
  8608. };
  8609. that._removeClass($(this), "ui-dialog-resizing");
  8610. that._unblockFrames();
  8611. that._trigger("resizeStop", event, filteredUi(ui));
  8612. }
  8613. }).css("position", position2);
  8614. },
  8615. _trackFocus: function() {
  8616. this._on(this.widget(), {
  8617. focusin: function(event) {
  8618. this._makeFocusTarget();
  8619. this._focusedElement = $(event.target);
  8620. }
  8621. });
  8622. },
  8623. _makeFocusTarget: function() {
  8624. this._untrackInstance();
  8625. this._trackingInstances().unshift(this);
  8626. },
  8627. _untrackInstance: function() {
  8628. var instances = this._trackingInstances(), exists = $.inArray(this, instances);
  8629. if (exists !== -1) {
  8630. instances.splice(exists, 1);
  8631. }
  8632. },
  8633. _trackingInstances: function() {
  8634. var instances = this.document.data("ui-dialog-instances");
  8635. if (!instances) {
  8636. instances = [];
  8637. this.document.data("ui-dialog-instances", instances);
  8638. }
  8639. return instances;
  8640. },
  8641. _minHeight: function() {
  8642. var options = this.options;
  8643. return options.height === "auto" ? options.minHeight : Math.min(options.minHeight, options.height);
  8644. },
  8645. _position: function() {
  8646. var isVisible = this.uiDialog.is(":visible");
  8647. if (!isVisible) {
  8648. this.uiDialog.show();
  8649. }
  8650. this.uiDialog.position(this.options.position);
  8651. if (!isVisible) {
  8652. this.uiDialog.hide();
  8653. }
  8654. },
  8655. _setOptions: function(options) {
  8656. var that = this, resize = false, resizableOptions = {};
  8657. $.each(options, function(key, value) {
  8658. that._setOption(key, value);
  8659. if (key in that.sizeRelatedOptions) {
  8660. resize = true;
  8661. }
  8662. if (key in that.resizableRelatedOptions) {
  8663. resizableOptions[key] = value;
  8664. }
  8665. });
  8666. if (resize) {
  8667. this._size();
  8668. this._position();
  8669. }
  8670. if (this.uiDialog.is(":data(ui-resizable)")) {
  8671. this.uiDialog.resizable("option", resizableOptions);
  8672. }
  8673. },
  8674. _setOption: function(key, value) {
  8675. var isDraggable, isResizable, uiDialog = this.uiDialog;
  8676. if (key === "disabled") {
  8677. return;
  8678. }
  8679. this._super(key, value);
  8680. if (key === "appendTo") {
  8681. this.uiDialog.appendTo(this._appendTo());
  8682. }
  8683. if (key === "buttons") {
  8684. this._createButtons();
  8685. }
  8686. if (key === "closeText") {
  8687. this.uiDialogTitlebarClose.button({
  8688. // Ensure that we always pass a string
  8689. label: $("<a>").text("" + this.options.closeText).html()
  8690. });
  8691. }
  8692. if (key === "draggable") {
  8693. isDraggable = uiDialog.is(":data(ui-draggable)");
  8694. if (isDraggable && !value) {
  8695. uiDialog.draggable("destroy");
  8696. }
  8697. if (!isDraggable && value) {
  8698. this._makeDraggable();
  8699. }
  8700. }
  8701. if (key === "position") {
  8702. this._position();
  8703. }
  8704. if (key === "resizable") {
  8705. isResizable = uiDialog.is(":data(ui-resizable)");
  8706. if (isResizable && !value) {
  8707. uiDialog.resizable("destroy");
  8708. }
  8709. if (isResizable && typeof value === "string") {
  8710. uiDialog.resizable("option", "handles", value);
  8711. }
  8712. if (!isResizable && value !== false) {
  8713. this._makeResizable();
  8714. }
  8715. }
  8716. if (key === "title") {
  8717. this._title(this.uiDialogTitlebar.find(".ui-dialog-title"));
  8718. }
  8719. if (key === "modal") {
  8720. uiDialog.attr("aria-modal", value ? "true" : null);
  8721. }
  8722. },
  8723. _size: function() {
  8724. var nonContentHeight, minContentHeight, maxContentHeight, options = this.options;
  8725. this.element.show().css({
  8726. width: "auto",
  8727. minHeight: 0,
  8728. maxHeight: "none",
  8729. height: 0
  8730. });
  8731. if (options.minWidth > options.width) {
  8732. options.width = options.minWidth;
  8733. }
  8734. nonContentHeight = this.uiDialog.css({
  8735. height: "auto",
  8736. width: options.width
  8737. }).outerHeight();
  8738. minContentHeight = Math.max(0, options.minHeight - nonContentHeight);
  8739. maxContentHeight = typeof options.maxHeight === "number" ? Math.max(0, options.maxHeight - nonContentHeight) : "none";
  8740. if (options.height === "auto") {
  8741. this.element.css({
  8742. minHeight: minContentHeight,
  8743. maxHeight: maxContentHeight,
  8744. height: "auto"
  8745. });
  8746. } else {
  8747. this.element.height(Math.max(0, options.height - nonContentHeight));
  8748. }
  8749. if (this.uiDialog.is(":data(ui-resizable)")) {
  8750. this.uiDialog.resizable("option", "minHeight", this._minHeight());
  8751. }
  8752. },
  8753. _blockFrames: function() {
  8754. this.iframeBlocks = this.document.find("iframe").map(function() {
  8755. var iframe = $(this);
  8756. return $("<div>").css({
  8757. position: "absolute",
  8758. width: iframe.outerWidth(),
  8759. height: iframe.outerHeight()
  8760. }).appendTo(iframe.parent()).offset(iframe.offset())[0];
  8761. });
  8762. },
  8763. _unblockFrames: function() {
  8764. if (this.iframeBlocks) {
  8765. this.iframeBlocks.remove();
  8766. delete this.iframeBlocks;
  8767. }
  8768. },
  8769. _allowInteraction: function(event) {
  8770. if ($(event.target).closest(".ui-dialog").length) {
  8771. return true;
  8772. }
  8773. return !!$(event.target).closest(".ui-datepicker").length;
  8774. },
  8775. _createOverlay: function() {
  8776. if (!this.options.modal) {
  8777. return;
  8778. }
  8779. var isOpening = true;
  8780. this._delay(function() {
  8781. isOpening = false;
  8782. });
  8783. if (!this.document.data("ui-dialog-overlays")) {
  8784. this.document.on("focusin.ui-dialog", (function(event) {
  8785. if (isOpening) {
  8786. return;
  8787. }
  8788. var instance = this._trackingInstances()[0];
  8789. if (!instance._allowInteraction(event)) {
  8790. event.preventDefault();
  8791. instance._focusTabbable();
  8792. }
  8793. }).bind(this));
  8794. }
  8795. this.overlay = $("<div>").appendTo(this._appendTo());
  8796. this._addClass(this.overlay, null, "ui-widget-overlay ui-front");
  8797. this._on(this.overlay, {
  8798. mousedown: "_keepFocus"
  8799. });
  8800. this.document.data(
  8801. "ui-dialog-overlays",
  8802. (this.document.data("ui-dialog-overlays") || 0) + 1
  8803. );
  8804. },
  8805. _destroyOverlay: function() {
  8806. if (!this.options.modal) {
  8807. return;
  8808. }
  8809. if (this.overlay) {
  8810. var overlays = this.document.data("ui-dialog-overlays") - 1;
  8811. if (!overlays) {
  8812. this.document.off("focusin.ui-dialog");
  8813. this.document.removeData("ui-dialog-overlays");
  8814. } else {
  8815. this.document.data("ui-dialog-overlays", overlays);
  8816. }
  8817. this.overlay.remove();
  8818. this.overlay = null;
  8819. }
  8820. }
  8821. });
  8822. if ($.uiBackCompat === true) {
  8823. $.widget("ui.dialog", $.ui.dialog, {
  8824. options: {
  8825. dialogClass: ""
  8826. },
  8827. _createWrapper: function() {
  8828. this._super();
  8829. this.uiDialog.addClass(this.options.dialogClass);
  8830. },
  8831. _setOption: function(key, value) {
  8832. if (key === "dialogClass") {
  8833. this.uiDialog.removeClass(this.options.dialogClass).addClass(value);
  8834. }
  8835. this._superApply(arguments);
  8836. }
  8837. });
  8838. }
  8839. var widgetsDialog = $.ui.dialog;
  8840. $.widget("ui.droppable", {
  8841. version: "1.14.1",
  8842. widgetEventPrefix: "drop",
  8843. options: {
  8844. accept: "*",
  8845. addClasses: true,
  8846. greedy: false,
  8847. scope: "default",
  8848. tolerance: "intersect",
  8849. // Callbacks
  8850. activate: null,
  8851. deactivate: null,
  8852. drop: null,
  8853. out: null,
  8854. over: null
  8855. },
  8856. _create: function() {
  8857. var proportions, o = this.options, accept = o.accept;
  8858. this.isover = false;
  8859. this.isout = true;
  8860. this.accept = typeof accept === "function" ? accept : function(d) {
  8861. return d.is(accept);
  8862. };
  8863. this.proportions = function() {
  8864. if (arguments.length) {
  8865. proportions = arguments[0];
  8866. } else {
  8867. return proportions ? proportions : proportions = {
  8868. width: this.element[0].offsetWidth,
  8869. height: this.element[0].offsetHeight
  8870. };
  8871. }
  8872. };
  8873. this._addToManager(o.scope);
  8874. if (o.addClasses) {
  8875. this._addClass("ui-droppable");
  8876. }
  8877. },
  8878. _addToManager: function(scope) {
  8879. $.ui.ddmanager.droppables[scope] = $.ui.ddmanager.droppables[scope] || [];
  8880. $.ui.ddmanager.droppables[scope].push(this);
  8881. },
  8882. _splice: function(drop) {
  8883. var i = 0;
  8884. for (; i < drop.length; i++) {
  8885. if (drop[i] === this) {
  8886. drop.splice(i, 1);
  8887. }
  8888. }
  8889. },
  8890. _destroy: function() {
  8891. var drop = $.ui.ddmanager.droppables[this.options.scope];
  8892. this._splice(drop);
  8893. },
  8894. _setOption: function(key, value) {
  8895. if (key === "accept") {
  8896. this.accept = typeof value === "function" ? value : function(d) {
  8897. return d.is(value);
  8898. };
  8899. } else if (key === "scope") {
  8900. var drop = $.ui.ddmanager.droppables[this.options.scope];
  8901. this._splice(drop);
  8902. this._addToManager(value);
  8903. }
  8904. this._super(key, value);
  8905. },
  8906. _activate: function(event) {
  8907. var draggable = $.ui.ddmanager.current;
  8908. this._addActiveClass();
  8909. if (draggable) {
  8910. this._trigger("activate", event, this.ui(draggable));
  8911. }
  8912. },
  8913. _deactivate: function(event) {
  8914. var draggable = $.ui.ddmanager.current;
  8915. this._removeActiveClass();
  8916. if (draggable) {
  8917. this._trigger("deactivate", event, this.ui(draggable));
  8918. }
  8919. },
  8920. _over: function(event) {
  8921. var draggable = $.ui.ddmanager.current;
  8922. if (!draggable || (draggable.currentItem || draggable.element)[0] === this.element[0]) {
  8923. return;
  8924. }
  8925. if (this.accept.call(this.element[0], draggable.currentItem || draggable.element)) {
  8926. this._addHoverClass();
  8927. this._trigger("over", event, this.ui(draggable));
  8928. }
  8929. },
  8930. _out: function(event) {
  8931. var draggable = $.ui.ddmanager.current;
  8932. if (!draggable || (draggable.currentItem || draggable.element)[0] === this.element[0]) {
  8933. return;
  8934. }
  8935. if (this.accept.call(this.element[0], draggable.currentItem || draggable.element)) {
  8936. this._removeHoverClass();
  8937. this._trigger("out", event, this.ui(draggable));
  8938. }
  8939. },
  8940. _drop: function(event, custom) {
  8941. var draggable = custom || $.ui.ddmanager.current, childrenIntersection = false;
  8942. if (!draggable || (draggable.currentItem || draggable.element)[0] === this.element[0]) {
  8943. return false;
  8944. }
  8945. this.element.find(":data(ui-droppable)").not(".ui-draggable-dragging").each(function() {
  8946. var inst = $(this).droppable("instance");
  8947. if (inst.options.greedy && !inst.options.disabled && inst.options.scope === draggable.options.scope && inst.accept.call(
  8948. inst.element[0],
  8949. draggable.currentItem || draggable.element
  8950. ) && $.ui.intersect(
  8951. draggable,
  8952. $.extend(inst, { offset: inst.element.offset() }),
  8953. inst.options.tolerance,
  8954. event
  8955. )) {
  8956. childrenIntersection = true;
  8957. return false;
  8958. }
  8959. });
  8960. if (childrenIntersection) {
  8961. return false;
  8962. }
  8963. if (this.accept.call(
  8964. this.element[0],
  8965. draggable.currentItem || draggable.element
  8966. )) {
  8967. this._removeActiveClass();
  8968. this._removeHoverClass();
  8969. this._trigger("drop", event, this.ui(draggable));
  8970. return this.element;
  8971. }
  8972. return false;
  8973. },
  8974. ui: function(c) {
  8975. return {
  8976. draggable: c.currentItem || c.element,
  8977. helper: c.helper,
  8978. position: c.position,
  8979. offset: c.positionAbs
  8980. };
  8981. },
  8982. // Extension points just to make backcompat sane and avoid duplicating logic
  8983. // TODO: Remove in 1.14 along with call to it below
  8984. _addHoverClass: function() {
  8985. this._addClass("ui-droppable-hover");
  8986. },
  8987. _removeHoverClass: function() {
  8988. this._removeClass("ui-droppable-hover");
  8989. },
  8990. _addActiveClass: function() {
  8991. this._addClass("ui-droppable-active");
  8992. },
  8993. _removeActiveClass: function() {
  8994. this._removeClass("ui-droppable-active");
  8995. }
  8996. });
  8997. $.ui.intersect = function() {
  8998. function isOverAxis(x, reference, size) {
  8999. return x >= reference && x < reference + size;
  9000. }
  9001. return function(draggable, droppable, toleranceMode, event) {
  9002. if (!droppable.offset) {
  9003. return false;
  9004. }
  9005. var x1 = (draggable.positionAbs || draggable.position.absolute).left + draggable.margins.left, y1 = (draggable.positionAbs || draggable.position.absolute).top + draggable.margins.top, x2 = x1 + draggable.helperProportions.width, y2 = y1 + draggable.helperProportions.height, l = droppable.offset.left, t = droppable.offset.top, r = l + droppable.proportions().width, b = t + droppable.proportions().height;
  9006. switch (toleranceMode) {
  9007. case "fit":
  9008. return l <= x1 && x2 <= r && t <= y1 && y2 <= b;
  9009. case "intersect":
  9010. return l < x1 + draggable.helperProportions.width / 2 && // Right Half
  9011. x2 - draggable.helperProportions.width / 2 < r && // Left Half
  9012. t < y1 + draggable.helperProportions.height / 2 && // Bottom Half
  9013. y2 - draggable.helperProportions.height / 2 < b;
  9014. case "pointer":
  9015. return isOverAxis(event.pageY, t, droppable.proportions().height) && isOverAxis(event.pageX, l, droppable.proportions().width);
  9016. case "touch":
  9017. return (y1 >= t && y1 <= b || // Top edge touching
  9018. y2 >= t && y2 <= b || // Bottom edge touching
  9019. y1 < t && y2 > b) && (x1 >= l && x1 <= r || // Left edge touching
  9020. x2 >= l && x2 <= r || // Right edge touching
  9021. x1 < l && x2 > r);
  9022. default:
  9023. return false;
  9024. }
  9025. };
  9026. }();
  9027. $.ui.ddmanager = {
  9028. current: null,
  9029. droppables: { "default": [] },
  9030. prepareOffsets: function(t, event) {
  9031. var i, j, m = $.ui.ddmanager.droppables[t.options.scope] || [], type = event ? event.type : null, list = (t.currentItem || t.element).find(":data(ui-droppable)").addBack();
  9032. droppablesLoop:
  9033. for (i = 0; i < m.length; i++) {
  9034. if (m[i].options.disabled || t && !m[i].accept.call(
  9035. m[i].element[0],
  9036. t.currentItem || t.element
  9037. )) {
  9038. continue;
  9039. }
  9040. for (j = 0; j < list.length; j++) {
  9041. if (list[j] === m[i].element[0]) {
  9042. m[i].proportions().height = 0;
  9043. continue droppablesLoop;
  9044. }
  9045. }
  9046. m[i].visible = m[i].element.css("display") !== "none";
  9047. if (!m[i].visible) {
  9048. continue;
  9049. }
  9050. if (type === "mousedown") {
  9051. m[i]._activate.call(m[i], event);
  9052. }
  9053. m[i].offset = m[i].element.offset();
  9054. m[i].proportions({
  9055. width: m[i].element[0].offsetWidth,
  9056. height: m[i].element[0].offsetHeight
  9057. });
  9058. }
  9059. },
  9060. drop: function(draggable, event) {
  9061. var dropped = false;
  9062. $.each(($.ui.ddmanager.droppables[draggable.options.scope] || []).slice(), function() {
  9063. if (!this.options) {
  9064. return;
  9065. }
  9066. if (!this.options.disabled && this.visible && $.ui.intersect(draggable, this, this.options.tolerance, event)) {
  9067. dropped = this._drop.call(this, event) || dropped;
  9068. }
  9069. if (!this.options.disabled && this.visible && this.accept.call(
  9070. this.element[0],
  9071. draggable.currentItem || draggable.element
  9072. )) {
  9073. this.isout = true;
  9074. this.isover = false;
  9075. this._deactivate.call(this, event);
  9076. }
  9077. });
  9078. return dropped;
  9079. },
  9080. dragStart: function(draggable, event) {
  9081. draggable.element.parentsUntil("body").on("scroll.droppable", function() {
  9082. if (!draggable.options.refreshPositions) {
  9083. $.ui.ddmanager.prepareOffsets(draggable, event);
  9084. }
  9085. });
  9086. },
  9087. drag: function(draggable, event) {
  9088. if (draggable.options.refreshPositions) {
  9089. $.ui.ddmanager.prepareOffsets(draggable, event);
  9090. }
  9091. $.each($.ui.ddmanager.droppables[draggable.options.scope] || [], function() {
  9092. if (this.options.disabled || this.greedyChild || !this.visible) {
  9093. return;
  9094. }
  9095. var parentInstance, scope, parent, intersects = $.ui.intersect(draggable, this, this.options.tolerance, event), c = !intersects && this.isover ? "isout" : intersects && !this.isover ? "isover" : null;
  9096. if (!c) {
  9097. return;
  9098. }
  9099. if (this.options.greedy) {
  9100. scope = this.options.scope;
  9101. parent = this.element.parents(":data(ui-droppable)").filter(function() {
  9102. return $(this).droppable("instance").options.scope === scope;
  9103. });
  9104. if (parent.length) {
  9105. parentInstance = $(parent[0]).droppable("instance");
  9106. parentInstance.greedyChild = c === "isover";
  9107. }
  9108. }
  9109. if (parentInstance && c === "isover") {
  9110. parentInstance.isover = false;
  9111. parentInstance.isout = true;
  9112. parentInstance._out.call(parentInstance, event);
  9113. }
  9114. this[c] = true;
  9115. this[c === "isout" ? "isover" : "isout"] = false;
  9116. this[c === "isover" ? "_over" : "_out"].call(this, event);
  9117. if (parentInstance && c === "isout") {
  9118. parentInstance.isout = false;
  9119. parentInstance.isover = true;
  9120. parentInstance._over.call(parentInstance, event);
  9121. }
  9122. });
  9123. },
  9124. dragStop: function(draggable, event) {
  9125. draggable.element.parentsUntil("body").off("scroll.droppable");
  9126. if (!draggable.options.refreshPositions) {
  9127. $.ui.ddmanager.prepareOffsets(draggable, event);
  9128. }
  9129. }
  9130. };
  9131. if ($.uiBackCompat === true) {
  9132. $.widget("ui.droppable", $.ui.droppable, {
  9133. options: {
  9134. hoverClass: false,
  9135. activeClass: false
  9136. },
  9137. _addActiveClass: function() {
  9138. this._super();
  9139. if (this.options.activeClass) {
  9140. this.element.addClass(this.options.activeClass);
  9141. }
  9142. },
  9143. _removeActiveClass: function() {
  9144. this._super();
  9145. if (this.options.activeClass) {
  9146. this.element.removeClass(this.options.activeClass);
  9147. }
  9148. },
  9149. _addHoverClass: function() {
  9150. this._super();
  9151. if (this.options.hoverClass) {
  9152. this.element.addClass(this.options.hoverClass);
  9153. }
  9154. },
  9155. _removeHoverClass: function() {
  9156. this._super();
  9157. if (this.options.hoverClass) {
  9158. this.element.removeClass(this.options.hoverClass);
  9159. }
  9160. }
  9161. });
  9162. }
  9163. var widgetsDroppable = $.ui.droppable;
  9164. var widgetsProgressbar = $.widget("ui.progressbar", {
  9165. version: "1.14.1",
  9166. options: {
  9167. classes: {
  9168. "ui-progressbar": "ui-corner-all",
  9169. "ui-progressbar-value": "ui-corner-left",
  9170. "ui-progressbar-complete": "ui-corner-right"
  9171. },
  9172. max: 100,
  9173. value: 0,
  9174. change: null,
  9175. complete: null
  9176. },
  9177. min: 0,
  9178. _create: function() {
  9179. this.oldValue = this.options.value = this._constrainedValue();
  9180. this.element.attr({
  9181. // Only set static values; aria-valuenow and aria-valuemax are
  9182. // set inside _refreshValue()
  9183. role: "progressbar",
  9184. "aria-valuemin": this.min
  9185. });
  9186. this._addClass("ui-progressbar", "ui-widget ui-widget-content");
  9187. this.valueDiv = $("<div>").appendTo(this.element);
  9188. this._addClass(this.valueDiv, "ui-progressbar-value", "ui-widget-header");
  9189. this._refreshValue();
  9190. },
  9191. _destroy: function() {
  9192. this.element.removeAttr("role aria-valuemin aria-valuemax aria-valuenow");
  9193. this.valueDiv.remove();
  9194. },
  9195. value: function(newValue) {
  9196. if (newValue === void 0) {
  9197. return this.options.value;
  9198. }
  9199. this.options.value = this._constrainedValue(newValue);
  9200. this._refreshValue();
  9201. },
  9202. _constrainedValue: function(newValue) {
  9203. if (newValue === void 0) {
  9204. newValue = this.options.value;
  9205. }
  9206. this.indeterminate = newValue === false;
  9207. if (typeof newValue !== "number") {
  9208. newValue = 0;
  9209. }
  9210. return this.indeterminate ? false : Math.min(this.options.max, Math.max(this.min, newValue));
  9211. },
  9212. _setOptions: function(options) {
  9213. var value = options.value;
  9214. delete options.value;
  9215. this._super(options);
  9216. this.options.value = this._constrainedValue(value);
  9217. this._refreshValue();
  9218. },
  9219. _setOption: function(key, value) {
  9220. if (key === "max") {
  9221. value = Math.max(this.min, value);
  9222. }
  9223. this._super(key, value);
  9224. },
  9225. _setOptionDisabled: function(value) {
  9226. this._super(value);
  9227. this.element.attr("aria-disabled", value);
  9228. this._toggleClass(null, "ui-state-disabled", !!value);
  9229. },
  9230. _percentage: function() {
  9231. return this.indeterminate ? 100 : 100 * (this.options.value - this.min) / (this.options.max - this.min);
  9232. },
  9233. _refreshValue: function() {
  9234. var value = this.options.value, percentage = this._percentage();
  9235. this.valueDiv.toggle(this.indeterminate || value > this.min).width(percentage.toFixed(0) + "%");
  9236. this._toggleClass(
  9237. this.valueDiv,
  9238. "ui-progressbar-complete",
  9239. null,
  9240. value === this.options.max
  9241. )._toggleClass("ui-progressbar-indeterminate", null, this.indeterminate);
  9242. if (this.indeterminate) {
  9243. this.element.removeAttr("aria-valuenow");
  9244. if (!this.overlayDiv) {
  9245. this.overlayDiv = $("<div>").appendTo(this.valueDiv);
  9246. this._addClass(this.overlayDiv, "ui-progressbar-overlay");
  9247. }
  9248. } else {
  9249. this.element.attr({
  9250. "aria-valuemax": this.options.max,
  9251. "aria-valuenow": value
  9252. });
  9253. if (this.overlayDiv) {
  9254. this.overlayDiv.remove();
  9255. this.overlayDiv = null;
  9256. }
  9257. }
  9258. if (this.oldValue !== value) {
  9259. this.oldValue = value;
  9260. this._trigger("change");
  9261. }
  9262. if (value === this.options.max) {
  9263. this._trigger("complete");
  9264. }
  9265. }
  9266. });
  9267. var widgetsSelectable = $.widget("ui.selectable", $.ui.mouse, {
  9268. version: "1.14.1",
  9269. options: {
  9270. appendTo: "body",
  9271. autoRefresh: true,
  9272. distance: 0,
  9273. filter: "*",
  9274. tolerance: "touch",
  9275. // Callbacks
  9276. selected: null,
  9277. selecting: null,
  9278. start: null,
  9279. stop: null,
  9280. unselected: null,
  9281. unselecting: null
  9282. },
  9283. _create: function() {
  9284. var that = this;
  9285. this._addClass("ui-selectable");
  9286. this.dragged = false;
  9287. this.refresh = function() {
  9288. that.elementPos = $(that.element[0]).offset();
  9289. that.selectees = $(that.options.filter, that.element[0]);
  9290. that._addClass(that.selectees, "ui-selectee");
  9291. that.selectees.each(function() {
  9292. var $this = $(this), selecteeOffset = $this.offset(), pos = {
  9293. left: selecteeOffset.left - that.elementPos.left,
  9294. top: selecteeOffset.top - that.elementPos.top
  9295. };
  9296. $.data(this, "selectable-item", {
  9297. element: this,
  9298. $element: $this,
  9299. left: pos.left,
  9300. top: pos.top,
  9301. right: pos.left + $this.outerWidth(),
  9302. bottom: pos.top + $this.outerHeight(),
  9303. startselected: false,
  9304. selected: $this.hasClass("ui-selected"),
  9305. selecting: $this.hasClass("ui-selecting"),
  9306. unselecting: $this.hasClass("ui-unselecting")
  9307. });
  9308. });
  9309. };
  9310. this.refresh();
  9311. this._mouseInit();
  9312. this.helper = $("<div>");
  9313. this._addClass(this.helper, "ui-selectable-helper");
  9314. },
  9315. _destroy: function() {
  9316. this.selectees.removeData("selectable-item");
  9317. this._mouseDestroy();
  9318. },
  9319. _mouseStart: function(event) {
  9320. var that = this, options = this.options;
  9321. this.opos = [event.pageX, event.pageY];
  9322. this.elementPos = $(this.element[0]).offset();
  9323. if (this.options.disabled) {
  9324. return;
  9325. }
  9326. this.selectees = $(options.filter, this.element[0]);
  9327. this._trigger("start", event);
  9328. $(options.appendTo).append(this.helper);
  9329. this.helper.css({
  9330. "left": event.pageX,
  9331. "top": event.pageY,
  9332. "width": 0,
  9333. "height": 0
  9334. });
  9335. if (options.autoRefresh) {
  9336. this.refresh();
  9337. }
  9338. this.selectees.filter(".ui-selected").each(function() {
  9339. var selectee = $.data(this, "selectable-item");
  9340. selectee.startselected = true;
  9341. if (!event.metaKey && !event.ctrlKey) {
  9342. that._removeClass(selectee.$element, "ui-selected");
  9343. selectee.selected = false;
  9344. that._addClass(selectee.$element, "ui-unselecting");
  9345. selectee.unselecting = true;
  9346. that._trigger("unselecting", event, {
  9347. unselecting: selectee.element
  9348. });
  9349. }
  9350. });
  9351. $(event.target).parents().addBack().each(function() {
  9352. var doSelect, selectee = $.data(this, "selectable-item");
  9353. if (selectee) {
  9354. doSelect = !event.metaKey && !event.ctrlKey || !selectee.$element.hasClass("ui-selected");
  9355. that._removeClass(selectee.$element, doSelect ? "ui-unselecting" : "ui-selected")._addClass(selectee.$element, doSelect ? "ui-selecting" : "ui-unselecting");
  9356. selectee.unselecting = !doSelect;
  9357. selectee.selecting = doSelect;
  9358. selectee.selected = doSelect;
  9359. if (doSelect) {
  9360. that._trigger("selecting", event, {
  9361. selecting: selectee.element
  9362. });
  9363. } else {
  9364. that._trigger("unselecting", event, {
  9365. unselecting: selectee.element
  9366. });
  9367. }
  9368. return false;
  9369. }
  9370. });
  9371. },
  9372. _mouseDrag: function(event) {
  9373. this.dragged = true;
  9374. if (this.options.disabled) {
  9375. return;
  9376. }
  9377. var tmp, that = this, options = this.options, x1 = this.opos[0], y1 = this.opos[1], x2 = event.pageX, y2 = event.pageY;
  9378. if (x1 > x2) {
  9379. tmp = x2;
  9380. x2 = x1;
  9381. x1 = tmp;
  9382. }
  9383. if (y1 > y2) {
  9384. tmp = y2;
  9385. y2 = y1;
  9386. y1 = tmp;
  9387. }
  9388. this.helper.css({ left: x1, top: y1, width: x2 - x1, height: y2 - y1 });
  9389. this.selectees.each(function() {
  9390. var selectee = $.data(this, "selectable-item"), hit = false, offset = {};
  9391. if (!selectee || selectee.element === that.element[0]) {
  9392. return;
  9393. }
  9394. offset.left = selectee.left + that.elementPos.left;
  9395. offset.right = selectee.right + that.elementPos.left;
  9396. offset.top = selectee.top + that.elementPos.top;
  9397. offset.bottom = selectee.bottom + that.elementPos.top;
  9398. if (options.tolerance === "touch") {
  9399. hit = !(offset.left > x2 || offset.right < x1 || offset.top > y2 || offset.bottom < y1);
  9400. } else if (options.tolerance === "fit") {
  9401. hit = offset.left > x1 && offset.right < x2 && offset.top > y1 && offset.bottom < y2;
  9402. }
  9403. if (hit) {
  9404. if (selectee.selected) {
  9405. that._removeClass(selectee.$element, "ui-selected");
  9406. selectee.selected = false;
  9407. }
  9408. if (selectee.unselecting) {
  9409. that._removeClass(selectee.$element, "ui-unselecting");
  9410. selectee.unselecting = false;
  9411. }
  9412. if (!selectee.selecting) {
  9413. that._addClass(selectee.$element, "ui-selecting");
  9414. selectee.selecting = true;
  9415. that._trigger("selecting", event, {
  9416. selecting: selectee.element
  9417. });
  9418. }
  9419. } else {
  9420. if (selectee.selecting) {
  9421. if ((event.metaKey || event.ctrlKey) && selectee.startselected) {
  9422. that._removeClass(selectee.$element, "ui-selecting");
  9423. selectee.selecting = false;
  9424. that._addClass(selectee.$element, "ui-selected");
  9425. selectee.selected = true;
  9426. } else {
  9427. that._removeClass(selectee.$element, "ui-selecting");
  9428. selectee.selecting = false;
  9429. if (selectee.startselected) {
  9430. that._addClass(selectee.$element, "ui-unselecting");
  9431. selectee.unselecting = true;
  9432. }
  9433. that._trigger("unselecting", event, {
  9434. unselecting: selectee.element
  9435. });
  9436. }
  9437. }
  9438. if (selectee.selected) {
  9439. if (!event.metaKey && !event.ctrlKey && !selectee.startselected) {
  9440. that._removeClass(selectee.$element, "ui-selected");
  9441. selectee.selected = false;
  9442. that._addClass(selectee.$element, "ui-unselecting");
  9443. selectee.unselecting = true;
  9444. that._trigger("unselecting", event, {
  9445. unselecting: selectee.element
  9446. });
  9447. }
  9448. }
  9449. }
  9450. });
  9451. return false;
  9452. },
  9453. _mouseStop: function(event) {
  9454. var that = this;
  9455. this.dragged = false;
  9456. $(".ui-unselecting", this.element[0]).each(function() {
  9457. var selectee = $.data(this, "selectable-item");
  9458. that._removeClass(selectee.$element, "ui-unselecting");
  9459. selectee.unselecting = false;
  9460. selectee.startselected = false;
  9461. that._trigger("unselected", event, {
  9462. unselected: selectee.element
  9463. });
  9464. });
  9465. $(".ui-selecting", this.element[0]).each(function() {
  9466. var selectee = $.data(this, "selectable-item");
  9467. that._removeClass(selectee.$element, "ui-selecting")._addClass(selectee.$element, "ui-selected");
  9468. selectee.selecting = false;
  9469. selectee.selected = true;
  9470. selectee.startselected = true;
  9471. that._trigger("selected", event, {
  9472. selected: selectee.element
  9473. });
  9474. });
  9475. this._trigger("stop", event);
  9476. this.helper.remove();
  9477. return false;
  9478. }
  9479. });
  9480. var widgetsSelectmenu = $.widget("ui.selectmenu", [$.ui.formResetMixin, {
  9481. version: "1.14.1",
  9482. defaultElement: "<select>",
  9483. options: {
  9484. appendTo: null,
  9485. classes: {
  9486. "ui-selectmenu-button-open": "ui-corner-top",
  9487. "ui-selectmenu-button-closed": "ui-corner-all"
  9488. },
  9489. disabled: null,
  9490. icons: {
  9491. button: "ui-icon-triangle-1-s"
  9492. },
  9493. position: {
  9494. my: "left top",
  9495. at: "left bottom",
  9496. collision: "none"
  9497. },
  9498. width: false,
  9499. // Callbacks
  9500. change: null,
  9501. close: null,
  9502. focus: null,
  9503. open: null,
  9504. select: null
  9505. },
  9506. _create: function() {
  9507. var selectmenuId = this.element.uniqueId().attr("id");
  9508. this.ids = {
  9509. element: selectmenuId,
  9510. button: selectmenuId + "-button",
  9511. menu: selectmenuId + "-menu"
  9512. };
  9513. this._drawButton();
  9514. this._drawMenu();
  9515. this._bindFormResetHandler();
  9516. this._rendered = false;
  9517. this.menuItems = $();
  9518. },
  9519. _drawButton: function() {
  9520. var icon, that = this, item = this._parseOption(
  9521. this.element.find("option:selected"),
  9522. this.element[0].selectedIndex
  9523. );
  9524. this.labels = this.element.labels().attr("for", this.ids.button);
  9525. this._on(this.labels, {
  9526. click: function(event) {
  9527. this.button.trigger("focus");
  9528. event.preventDefault();
  9529. }
  9530. });
  9531. this.element.hide();
  9532. this.button = $("<span>", {
  9533. tabindex: this.options.disabled ? -1 : 0,
  9534. id: this.ids.button,
  9535. role: "combobox",
  9536. "aria-expanded": "false",
  9537. "aria-autocomplete": "list",
  9538. "aria-owns": this.ids.menu,
  9539. "aria-haspopup": "true",
  9540. title: this.element.attr("title")
  9541. }).insertAfter(this.element);
  9542. this._addClass(
  9543. this.button,
  9544. "ui-selectmenu-button ui-selectmenu-button-closed",
  9545. "ui-button ui-widget"
  9546. );
  9547. icon = $("<span>").appendTo(this.button);
  9548. this._addClass(icon, "ui-selectmenu-icon", "ui-icon " + this.options.icons.button);
  9549. this.buttonItem = this._renderButtonItem(item).appendTo(this.button);
  9550. if (this.options.width !== false) {
  9551. this._resizeButton();
  9552. }
  9553. this._on(this.button, this._buttonEvents);
  9554. this.button.one("focusin", function() {
  9555. if (!that._rendered) {
  9556. that._refreshMenu();
  9557. }
  9558. });
  9559. },
  9560. _drawMenu: function() {
  9561. var that = this;
  9562. this.menu = $("<ul>", {
  9563. "aria-hidden": "true",
  9564. "aria-labelledby": this.ids.button,
  9565. id: this.ids.menu
  9566. });
  9567. this.menuWrap = $("<div>").append(this.menu);
  9568. this._addClass(this.menuWrap, "ui-selectmenu-menu", "ui-front");
  9569. this.menuWrap.appendTo(this._appendTo());
  9570. this.menuInstance = this.menu.menu({
  9571. classes: {
  9572. "ui-menu": "ui-corner-bottom"
  9573. },
  9574. role: "listbox",
  9575. select: function(event, ui) {
  9576. event.preventDefault();
  9577. that._select(ui.item.data("ui-selectmenu-item"), event);
  9578. },
  9579. focus: function(event, ui) {
  9580. var item = ui.item.data("ui-selectmenu-item");
  9581. if (that.focusIndex != null && item.index !== that.focusIndex) {
  9582. that._trigger("focus", event, { item });
  9583. if (!that.isOpen) {
  9584. that._select(item, event);
  9585. }
  9586. }
  9587. that.focusIndex = item.index;
  9588. that.button.attr(
  9589. "aria-activedescendant",
  9590. that.menuItems.eq(item.index).attr("id")
  9591. );
  9592. }
  9593. }).menu("instance");
  9594. this.menuInstance._off(this.menu, "mouseleave");
  9595. this.menuInstance._closeOnDocumentClick = function() {
  9596. return false;
  9597. };
  9598. this.menuInstance._isDivider = function() {
  9599. return false;
  9600. };
  9601. },
  9602. refresh: function() {
  9603. this._refreshMenu();
  9604. this.buttonItem.replaceWith(
  9605. this.buttonItem = this._renderButtonItem(
  9606. // Fall back to an empty object in case there are no options
  9607. this._getSelectedItem().data("ui-selectmenu-item") || {}
  9608. )
  9609. );
  9610. if (this.options.width === null) {
  9611. this._resizeButton();
  9612. }
  9613. },
  9614. _refreshMenu: function() {
  9615. var item, options = this.element.find("option");
  9616. this.menu.empty();
  9617. this._parseOptions(options);
  9618. this._renderMenu(this.menu, this.items);
  9619. this.menuInstance.refresh();
  9620. this.menuItems = this.menu.find("li").not(".ui-selectmenu-optgroup").find(".ui-menu-item-wrapper");
  9621. this._rendered = true;
  9622. if (!options.length) {
  9623. return;
  9624. }
  9625. item = this._getSelectedItem();
  9626. this.menuInstance.focus(null, item);
  9627. this._setAria(item.data("ui-selectmenu-item"));
  9628. this._setOption("disabled", this.element.prop("disabled"));
  9629. },
  9630. open: function(event) {
  9631. if (this.options.disabled) {
  9632. return;
  9633. }
  9634. if (!this._rendered) {
  9635. this._refreshMenu();
  9636. } else {
  9637. this._removeClass(this.menu.find(".ui-state-active"), null, "ui-state-active");
  9638. this.menuInstance.focus(null, this._getSelectedItem());
  9639. }
  9640. if (!this.menuItems.length) {
  9641. return;
  9642. }
  9643. this.isOpen = true;
  9644. this._toggleAttr();
  9645. this._resizeMenu();
  9646. this._position();
  9647. this._on(this.document, this._documentClick);
  9648. this._trigger("open", event);
  9649. },
  9650. _position: function() {
  9651. this.menuWrap.position($.extend({ of: this.button }, this.options.position));
  9652. },
  9653. close: function(event) {
  9654. if (!this.isOpen) {
  9655. return;
  9656. }
  9657. this.isOpen = false;
  9658. this._toggleAttr();
  9659. this.range = null;
  9660. this._off(this.document);
  9661. this._trigger("close", event);
  9662. },
  9663. widget: function() {
  9664. return this.button;
  9665. },
  9666. menuWidget: function() {
  9667. return this.menu;
  9668. },
  9669. _renderButtonItem: function(item) {
  9670. var buttonItem = $("<span>");
  9671. this._setText(buttonItem, item.label);
  9672. this._addClass(buttonItem, "ui-selectmenu-text");
  9673. return buttonItem;
  9674. },
  9675. _renderMenu: function(ul, items) {
  9676. var that = this, currentOptgroup = "";
  9677. $.each(items, function(index, item) {
  9678. var li;
  9679. if (item.optgroup !== currentOptgroup) {
  9680. li = $("<li>", {
  9681. text: item.optgroup
  9682. });
  9683. that._addClass(li, "ui-selectmenu-optgroup", "ui-menu-divider" + (item.element.parent("optgroup").prop("disabled") ? " ui-state-disabled" : ""));
  9684. li.appendTo(ul);
  9685. currentOptgroup = item.optgroup;
  9686. }
  9687. that._renderItemData(ul, item);
  9688. });
  9689. },
  9690. _renderItemData: function(ul, item) {
  9691. return this._renderItem(ul, item).data("ui-selectmenu-item", item);
  9692. },
  9693. _renderItem: function(ul, item) {
  9694. var li = $("<li>"), wrapper = $("<div>", {
  9695. title: item.element.attr("title")
  9696. });
  9697. if (item.disabled) {
  9698. this._addClass(li, null, "ui-state-disabled");
  9699. }
  9700. if (item.hidden) {
  9701. li.prop("hidden", true);
  9702. } else {
  9703. this._setText(wrapper, item.label);
  9704. }
  9705. return li.append(wrapper).appendTo(ul);
  9706. },
  9707. _setText: function(element, value) {
  9708. if (value) {
  9709. element.text(value);
  9710. } else {
  9711. element.html("&#160;");
  9712. }
  9713. },
  9714. _move: function(direction, event) {
  9715. var item, next, filter = ".ui-menu-item";
  9716. if (this.isOpen) {
  9717. item = this.menuItems.eq(this.focusIndex).parent("li");
  9718. } else {
  9719. item = this.menuItems.eq(this.element[0].selectedIndex).parent("li");
  9720. filter += ":not(.ui-state-disabled)";
  9721. }
  9722. if (direction === "first" || direction === "last") {
  9723. next = item[direction === "first" ? "prevAll" : "nextAll"](filter).eq(-1);
  9724. } else {
  9725. next = item[direction + "All"](filter).eq(0);
  9726. }
  9727. if (next.length) {
  9728. this.menuInstance.focus(event, next);
  9729. }
  9730. },
  9731. _getSelectedItem: function() {
  9732. return this.menuItems.eq(this.element[0].selectedIndex).parent("li");
  9733. },
  9734. _toggle: function(event) {
  9735. this[this.isOpen ? "close" : "open"](event);
  9736. },
  9737. _setSelection: function() {
  9738. var selection;
  9739. if (!this.range) {
  9740. return;
  9741. }
  9742. selection = window.getSelection();
  9743. selection.removeAllRanges();
  9744. selection.addRange(this.range);
  9745. },
  9746. _documentClick: {
  9747. mousedown: function(event) {
  9748. if (!this.isOpen) {
  9749. return;
  9750. }
  9751. if (!$(event.target).closest(".ui-selectmenu-menu, #" + CSS.escape(this.ids.button)).length) {
  9752. this.close(event);
  9753. }
  9754. }
  9755. },
  9756. _buttonEvents: {
  9757. // Prevent text selection from being reset when interacting with the selectmenu (#10144)
  9758. mousedown: function() {
  9759. var selection = window.getSelection();
  9760. if (selection.rangeCount) {
  9761. this.range = selection.getRangeAt(0);
  9762. }
  9763. },
  9764. click: function(event) {
  9765. this._setSelection();
  9766. this._toggle(event);
  9767. },
  9768. keydown: function(event) {
  9769. var preventDefault = true;
  9770. switch (event.keyCode) {
  9771. case $.ui.keyCode.TAB:
  9772. case $.ui.keyCode.ESCAPE:
  9773. this.close(event);
  9774. preventDefault = false;
  9775. break;
  9776. case $.ui.keyCode.ENTER:
  9777. if (this.isOpen) {
  9778. this._selectFocusedItem(event);
  9779. }
  9780. break;
  9781. case $.ui.keyCode.UP:
  9782. if (event.altKey) {
  9783. this._toggle(event);
  9784. } else {
  9785. this._move("prev", event);
  9786. }
  9787. break;
  9788. case $.ui.keyCode.DOWN:
  9789. if (event.altKey) {
  9790. this._toggle(event);
  9791. } else {
  9792. this._move("next", event);
  9793. }
  9794. break;
  9795. case $.ui.keyCode.SPACE:
  9796. if (this.isOpen) {
  9797. this._selectFocusedItem(event);
  9798. } else {
  9799. this._toggle(event);
  9800. }
  9801. break;
  9802. case $.ui.keyCode.LEFT:
  9803. this._move("prev", event);
  9804. break;
  9805. case $.ui.keyCode.RIGHT:
  9806. this._move("next", event);
  9807. break;
  9808. case $.ui.keyCode.HOME:
  9809. case $.ui.keyCode.PAGE_UP:
  9810. this._move("first", event);
  9811. break;
  9812. case $.ui.keyCode.END:
  9813. case $.ui.keyCode.PAGE_DOWN:
  9814. this._move("last", event);
  9815. break;
  9816. default:
  9817. this.menu.trigger(event);
  9818. preventDefault = false;
  9819. }
  9820. if (preventDefault) {
  9821. event.preventDefault();
  9822. }
  9823. }
  9824. },
  9825. _selectFocusedItem: function(event) {
  9826. var item = this.menuItems.eq(this.focusIndex).parent("li");
  9827. if (!item.hasClass("ui-state-disabled")) {
  9828. this._select(item.data("ui-selectmenu-item"), event);
  9829. }
  9830. },
  9831. _select: function(item, event) {
  9832. var oldIndex = this.element[0].selectedIndex;
  9833. this.element[0].selectedIndex = item.index;
  9834. this.buttonItem.replaceWith(this.buttonItem = this._renderButtonItem(item));
  9835. this._setAria(item);
  9836. this._trigger("select", event, { item });
  9837. if (item.index !== oldIndex) {
  9838. this._trigger("change", event, { item });
  9839. }
  9840. this.close(event);
  9841. },
  9842. _setAria: function(item) {
  9843. var id = this.menuItems.eq(item.index).attr("id");
  9844. this.button.attr({
  9845. "aria-labelledby": id,
  9846. "aria-activedescendant": id
  9847. });
  9848. this.menu.attr("aria-activedescendant", id);
  9849. },
  9850. _setOption: function(key, value) {
  9851. if (key === "icons") {
  9852. var icon = this.button.find("span.ui-icon");
  9853. this._removeClass(icon, null, this.options.icons.button)._addClass(icon, null, value.button);
  9854. }
  9855. this._super(key, value);
  9856. if (key === "appendTo") {
  9857. this.menuWrap.appendTo(this._appendTo());
  9858. }
  9859. if (key === "width") {
  9860. this._resizeButton();
  9861. }
  9862. },
  9863. _setOptionDisabled: function(value) {
  9864. this._super(value);
  9865. this.menuInstance.option("disabled", value);
  9866. this.button.attr("aria-disabled", value);
  9867. this._toggleClass(this.button, null, "ui-state-disabled", value);
  9868. this.element.prop("disabled", value);
  9869. if (value) {
  9870. this.button.attr("tabindex", -1);
  9871. this.close();
  9872. } else {
  9873. this.button.attr("tabindex", 0);
  9874. }
  9875. },
  9876. _appendTo: function() {
  9877. var element = this.options.appendTo;
  9878. if (element) {
  9879. element = element.jquery || element.nodeType ? $(element) : this.document.find(element).eq(0);
  9880. }
  9881. if (!element || !element[0]) {
  9882. element = this.element.closest(".ui-front, dialog");
  9883. }
  9884. if (!element.length) {
  9885. element = this.document[0].body;
  9886. }
  9887. return element;
  9888. },
  9889. _toggleAttr: function() {
  9890. this.button.attr("aria-expanded", this.isOpen);
  9891. this._removeClass(this.button, "ui-selectmenu-button-" + (this.isOpen ? "closed" : "open"))._addClass(this.button, "ui-selectmenu-button-" + (this.isOpen ? "open" : "closed"))._toggleClass(this.menuWrap, "ui-selectmenu-open", null, this.isOpen);
  9892. this.menu.attr("aria-hidden", !this.isOpen);
  9893. },
  9894. _resizeButton: function() {
  9895. var width = this.options.width;
  9896. if (width === false) {
  9897. this.button.css("width", "");
  9898. return;
  9899. }
  9900. if (width === null) {
  9901. width = this.element.show().outerWidth();
  9902. this.element.hide();
  9903. }
  9904. this.button.outerWidth(width);
  9905. },
  9906. _resizeMenu: function() {
  9907. this.menu.outerWidth(Math.max(
  9908. this.button.outerWidth(),
  9909. this.menu.width("").outerWidth()
  9910. ));
  9911. },
  9912. _getCreateOptions: function() {
  9913. var options = this._super();
  9914. options.disabled = this.element.prop("disabled");
  9915. return options;
  9916. },
  9917. _parseOptions: function(options) {
  9918. var that = this, data2 = [];
  9919. options.each(function(index, item) {
  9920. data2.push(that._parseOption($(item), index));
  9921. });
  9922. this.items = data2;
  9923. },
  9924. _parseOption: function(option, index) {
  9925. var optgroup = option.parent("optgroup");
  9926. return {
  9927. element: option,
  9928. index,
  9929. value: option.val(),
  9930. label: option.text(),
  9931. hidden: optgroup.prop("hidden") || option.prop("hidden"),
  9932. optgroup: optgroup.attr("label") || "",
  9933. disabled: optgroup.prop("disabled") || option.prop("disabled")
  9934. };
  9935. },
  9936. _destroy: function() {
  9937. this._unbindFormResetHandler();
  9938. this.menuWrap.remove();
  9939. this.button.remove();
  9940. this.element.show();
  9941. this.element.removeUniqueId();
  9942. this.labels.attr("for", this.ids.element);
  9943. }
  9944. }]);
  9945. var widgetsSlider = $.widget("ui.slider", $.ui.mouse, {
  9946. version: "1.14.1",
  9947. widgetEventPrefix: "slide",
  9948. options: {
  9949. animate: false,
  9950. classes: {
  9951. "ui-slider": "ui-corner-all",
  9952. "ui-slider-handle": "ui-corner-all",
  9953. // Note: ui-widget-header isn't the most fittingly semantic framework class for this
  9954. // element, but worked best visually with a variety of themes
  9955. "ui-slider-range": "ui-corner-all ui-widget-header"
  9956. },
  9957. distance: 0,
  9958. max: 100,
  9959. min: 0,
  9960. orientation: "horizontal",
  9961. range: false,
  9962. step: 1,
  9963. value: 0,
  9964. values: null,
  9965. // Callbacks
  9966. change: null,
  9967. slide: null,
  9968. start: null,
  9969. stop: null
  9970. },
  9971. // Number of pages in a slider
  9972. // (how many times can you page up/down to go through the whole range)
  9973. numPages: 5,
  9974. _create: function() {
  9975. this._keySliding = false;
  9976. this._mouseSliding = false;
  9977. this._animateOff = true;
  9978. this._handleIndex = null;
  9979. this._detectOrientation();
  9980. this._mouseInit();
  9981. this._calculateNewMax();
  9982. this._addClass(
  9983. "ui-slider ui-slider-" + this.orientation,
  9984. "ui-widget ui-widget-content"
  9985. );
  9986. this._refresh();
  9987. this._animateOff = false;
  9988. },
  9989. _refresh: function() {
  9990. this._createRange();
  9991. this._createHandles();
  9992. this._setupEvents();
  9993. this._refreshValue();
  9994. },
  9995. _createHandles: function() {
  9996. var i, handleCount, options = this.options, existingHandles = this.element.find(".ui-slider-handle"), handle = "<span tabindex='0'></span>", handles = [];
  9997. handleCount = options.values && options.values.length || 1;
  9998. if (existingHandles.length > handleCount) {
  9999. existingHandles.slice(handleCount).remove();
  10000. existingHandles = existingHandles.slice(0, handleCount);
  10001. }
  10002. for (i = existingHandles.length; i < handleCount; i++) {
  10003. handles.push(handle);
  10004. }
  10005. this.handles = existingHandles.add($(handles.join("")).appendTo(this.element));
  10006. this._addClass(this.handles, "ui-slider-handle", "ui-state-default");
  10007. this.handle = this.handles.eq(0);
  10008. this.handles.each(function(i2) {
  10009. $(this).data("ui-slider-handle-index", i2).attr("tabIndex", 0);
  10010. });
  10011. },
  10012. _createRange: function() {
  10013. var options = this.options;
  10014. if (options.range) {
  10015. if (options.range === true) {
  10016. if (!options.values) {
  10017. options.values = [this._valueMin(), this._valueMin()];
  10018. } else if (options.values.length && options.values.length !== 2) {
  10019. options.values = [options.values[0], options.values[0]];
  10020. } else if (Array.isArray(options.values)) {
  10021. options.values = options.values.slice(0);
  10022. }
  10023. }
  10024. if (!this.range || !this.range.length) {
  10025. this.range = $("<div>").appendTo(this.element);
  10026. this._addClass(this.range, "ui-slider-range");
  10027. } else {
  10028. this._removeClass(this.range, "ui-slider-range-min ui-slider-range-max");
  10029. this.range.css({
  10030. "left": "",
  10031. "bottom": ""
  10032. });
  10033. }
  10034. if (options.range === "min" || options.range === "max") {
  10035. this._addClass(this.range, "ui-slider-range-" + options.range);
  10036. }
  10037. } else {
  10038. if (this.range) {
  10039. this.range.remove();
  10040. }
  10041. this.range = null;
  10042. }
  10043. },
  10044. _setupEvents: function() {
  10045. this._off(this.handles);
  10046. this._on(this.handles, this._handleEvents);
  10047. this._hoverable(this.handles);
  10048. this._focusable(this.handles);
  10049. },
  10050. _destroy: function() {
  10051. this.handles.remove();
  10052. if (this.range) {
  10053. this.range.remove();
  10054. }
  10055. this._mouseDestroy();
  10056. },
  10057. _mouseCapture: function(event) {
  10058. var position2, normValue, distance, closestHandle, index, allowed, offset, mouseOverHandle, that = this, o = this.options;
  10059. if (o.disabled) {
  10060. return false;
  10061. }
  10062. this.elementSize = {
  10063. width: this.element.outerWidth(),
  10064. height: this.element.outerHeight()
  10065. };
  10066. this.elementOffset = this.element.offset();
  10067. position2 = { x: event.pageX, y: event.pageY };
  10068. normValue = this._normValueFromMouse(position2);
  10069. distance = this._valueMax() - this._valueMin() + 1;
  10070. this.handles.each(function(i) {
  10071. var thisDistance = Math.abs(normValue - that.values(i));
  10072. if (distance > thisDistance || distance === thisDistance && (i === that._lastChangedValue || that.values(i) === o.min)) {
  10073. distance = thisDistance;
  10074. closestHandle = $(this);
  10075. index = i;
  10076. }
  10077. });
  10078. allowed = this._start(event, index);
  10079. if (allowed === false) {
  10080. return false;
  10081. }
  10082. this._mouseSliding = true;
  10083. this._handleIndex = index;
  10084. this._addClass(closestHandle, null, "ui-state-active");
  10085. closestHandle.trigger("focus");
  10086. offset = closestHandle.offset();
  10087. mouseOverHandle = !$(event.target).parents().addBack().is(".ui-slider-handle");
  10088. this._clickOffset = mouseOverHandle ? { left: 0, top: 0 } : {
  10089. left: event.pageX - offset.left - closestHandle.width() / 2,
  10090. top: event.pageY - offset.top - closestHandle.height() / 2 - (parseInt(closestHandle.css("borderTopWidth"), 10) || 0) - (parseInt(closestHandle.css("borderBottomWidth"), 10) || 0) + (parseInt(closestHandle.css("marginTop"), 10) || 0)
  10091. };
  10092. if (!this.handles.hasClass("ui-state-hover")) {
  10093. this._slide(event, index, normValue);
  10094. }
  10095. this._animateOff = true;
  10096. return true;
  10097. },
  10098. _mouseStart: function() {
  10099. return true;
  10100. },
  10101. _mouseDrag: function(event) {
  10102. var position2 = { x: event.pageX, y: event.pageY }, normValue = this._normValueFromMouse(position2);
  10103. this._slide(event, this._handleIndex, normValue);
  10104. return false;
  10105. },
  10106. _mouseStop: function(event) {
  10107. this._removeClass(this.handles, null, "ui-state-active");
  10108. this._mouseSliding = false;
  10109. this._stop(event, this._handleIndex);
  10110. this._change(event, this._handleIndex);
  10111. this._handleIndex = null;
  10112. this._clickOffset = null;
  10113. this._animateOff = false;
  10114. return false;
  10115. },
  10116. _detectOrientation: function() {
  10117. this.orientation = this.options.orientation === "vertical" ? "vertical" : "horizontal";
  10118. },
  10119. _normValueFromMouse: function(position2) {
  10120. var pixelTotal, pixelMouse, percentMouse, valueTotal, valueMouse;
  10121. if (this.orientation === "horizontal") {
  10122. pixelTotal = this.elementSize.width;
  10123. pixelMouse = position2.x - this.elementOffset.left - (this._clickOffset ? this._clickOffset.left : 0);
  10124. } else {
  10125. pixelTotal = this.elementSize.height;
  10126. pixelMouse = position2.y - this.elementOffset.top - (this._clickOffset ? this._clickOffset.top : 0);
  10127. }
  10128. percentMouse = pixelMouse / pixelTotal;
  10129. if (percentMouse > 1) {
  10130. percentMouse = 1;
  10131. }
  10132. if (percentMouse < 0) {
  10133. percentMouse = 0;
  10134. }
  10135. if (this.orientation === "vertical") {
  10136. percentMouse = 1 - percentMouse;
  10137. }
  10138. valueTotal = this._valueMax() - this._valueMin();
  10139. valueMouse = this._valueMin() + percentMouse * valueTotal;
  10140. return this._trimAlignValue(valueMouse);
  10141. },
  10142. _uiHash: function(index, value, values) {
  10143. var uiHash = {
  10144. handle: this.handles[index],
  10145. handleIndex: index,
  10146. value: value !== void 0 ? value : this.value()
  10147. };
  10148. if (this._hasMultipleValues()) {
  10149. uiHash.value = value !== void 0 ? value : this.values(index);
  10150. uiHash.values = values || this.values();
  10151. }
  10152. return uiHash;
  10153. },
  10154. _hasMultipleValues: function() {
  10155. return this.options.values && this.options.values.length;
  10156. },
  10157. _start: function(event, index) {
  10158. return this._trigger("start", event, this._uiHash(index));
  10159. },
  10160. _slide: function(event, index, newVal) {
  10161. var allowed, otherVal, currentValue = this.value(), newValues = this.values();
  10162. if (this._hasMultipleValues()) {
  10163. otherVal = this.values(index ? 0 : 1);
  10164. currentValue = this.values(index);
  10165. if (this.options.values.length === 2 && this.options.range === true) {
  10166. newVal = index === 0 ? Math.min(otherVal, newVal) : Math.max(otherVal, newVal);
  10167. }
  10168. newValues[index] = newVal;
  10169. }
  10170. if (newVal === currentValue) {
  10171. return;
  10172. }
  10173. allowed = this._trigger("slide", event, this._uiHash(index, newVal, newValues));
  10174. if (allowed === false) {
  10175. return;
  10176. }
  10177. if (this._hasMultipleValues()) {
  10178. this.values(index, newVal);
  10179. } else {
  10180. this.value(newVal);
  10181. }
  10182. },
  10183. _stop: function(event, index) {
  10184. this._trigger("stop", event, this._uiHash(index));
  10185. },
  10186. _change: function(event, index) {
  10187. if (!this._keySliding && !this._mouseSliding) {
  10188. this._lastChangedValue = index;
  10189. this._trigger("change", event, this._uiHash(index));
  10190. }
  10191. },
  10192. value: function(newValue) {
  10193. if (arguments.length) {
  10194. this.options.value = this._trimAlignValue(newValue);
  10195. this._refreshValue();
  10196. this._change(null, 0);
  10197. return;
  10198. }
  10199. return this._value();
  10200. },
  10201. values: function(index, newValue) {
  10202. var vals, newValues, i;
  10203. if (arguments.length > 1) {
  10204. this.options.values[index] = this._trimAlignValue(newValue);
  10205. this._refreshValue();
  10206. this._change(null, index);
  10207. return;
  10208. }
  10209. if (arguments.length) {
  10210. if (Array.isArray(arguments[0])) {
  10211. vals = this.options.values;
  10212. newValues = arguments[0];
  10213. for (i = 0; i < vals.length; i += 1) {
  10214. vals[i] = this._trimAlignValue(newValues[i]);
  10215. this._change(null, i);
  10216. }
  10217. this._refreshValue();
  10218. } else {
  10219. if (this._hasMultipleValues()) {
  10220. return this._values(index);
  10221. } else {
  10222. return this.value();
  10223. }
  10224. }
  10225. } else {
  10226. return this._values();
  10227. }
  10228. },
  10229. _setOption: function(key, value) {
  10230. var i, valsLength = 0;
  10231. if (key === "range" && this.options.range === true) {
  10232. if (value === "min") {
  10233. this.options.value = this._values(0);
  10234. this.options.values = null;
  10235. } else if (value === "max") {
  10236. this.options.value = this._values(this.options.values.length - 1);
  10237. this.options.values = null;
  10238. }
  10239. }
  10240. if (Array.isArray(this.options.values)) {
  10241. valsLength = this.options.values.length;
  10242. }
  10243. this._super(key, value);
  10244. switch (key) {
  10245. case "orientation":
  10246. this._detectOrientation();
  10247. this._removeClass("ui-slider-horizontal ui-slider-vertical")._addClass("ui-slider-" + this.orientation);
  10248. this._refreshValue();
  10249. if (this.options.range) {
  10250. this._refreshRange(value);
  10251. }
  10252. this.handles.css(value === "horizontal" ? "bottom" : "left", "");
  10253. break;
  10254. case "value":
  10255. this._animateOff = true;
  10256. this._refreshValue();
  10257. this._change(null, 0);
  10258. this._animateOff = false;
  10259. break;
  10260. case "values":
  10261. this._animateOff = true;
  10262. this._refreshValue();
  10263. for (i = valsLength - 1; i >= 0; i--) {
  10264. this._change(null, i);
  10265. }
  10266. this._animateOff = false;
  10267. break;
  10268. case "step":
  10269. case "min":
  10270. case "max":
  10271. this._animateOff = true;
  10272. this._calculateNewMax();
  10273. this._refreshValue();
  10274. this._animateOff = false;
  10275. break;
  10276. case "range":
  10277. this._animateOff = true;
  10278. this._refresh();
  10279. this._animateOff = false;
  10280. break;
  10281. }
  10282. },
  10283. _setOptionDisabled: function(value) {
  10284. this._super(value);
  10285. this._toggleClass(null, "ui-state-disabled", !!value);
  10286. },
  10287. //internal value getter
  10288. // _value() returns value trimmed by min and max, aligned by step
  10289. _value: function() {
  10290. var val = this.options.value;
  10291. val = this._trimAlignValue(val);
  10292. return val;
  10293. },
  10294. //internal values getter
  10295. // _values() returns array of values trimmed by min and max, aligned by step
  10296. // _values( index ) returns single value trimmed by min and max, aligned by step
  10297. _values: function(index) {
  10298. var val, vals, i;
  10299. if (arguments.length) {
  10300. val = this.options.values[index];
  10301. val = this._trimAlignValue(val);
  10302. return val;
  10303. } else if (this._hasMultipleValues()) {
  10304. vals = this.options.values.slice();
  10305. for (i = 0; i < vals.length; i += 1) {
  10306. vals[i] = this._trimAlignValue(vals[i]);
  10307. }
  10308. return vals;
  10309. } else {
  10310. return [];
  10311. }
  10312. },
  10313. // Returns the step-aligned value that val is closest to, between (inclusive) min and max
  10314. _trimAlignValue: function(val) {
  10315. if (val <= this._valueMin()) {
  10316. return this._valueMin();
  10317. }
  10318. if (val >= this._valueMax()) {
  10319. return this._valueMax();
  10320. }
  10321. var step = this.options.step > 0 ? this.options.step : 1, valModStep = (val - this._valueMin()) % step, alignValue = val - valModStep;
  10322. if (Math.abs(valModStep) * 2 >= step) {
  10323. alignValue += valModStep > 0 ? step : -step;
  10324. }
  10325. return parseFloat(alignValue.toFixed(5));
  10326. },
  10327. _calculateNewMax: function() {
  10328. var max = this.options.max, min = this._valueMin(), step = this.options.step, aboveMin = Math.round((max - min) / step) * step;
  10329. max = aboveMin + min;
  10330. if (max > this.options.max) {
  10331. max -= step;
  10332. }
  10333. this.max = parseFloat(max.toFixed(this._precision()));
  10334. },
  10335. _precision: function() {
  10336. var precision = this._precisionOf(this.options.step);
  10337. if (this.options.min !== null) {
  10338. precision = Math.max(precision, this._precisionOf(this.options.min));
  10339. }
  10340. return precision;
  10341. },
  10342. _precisionOf: function(num) {
  10343. var str = num.toString(), decimal = str.indexOf(".");
  10344. return decimal === -1 ? 0 : str.length - decimal - 1;
  10345. },
  10346. _valueMin: function() {
  10347. return this.options.min;
  10348. },
  10349. _valueMax: function() {
  10350. return this.max;
  10351. },
  10352. _refreshRange: function(orientation) {
  10353. if (orientation === "vertical") {
  10354. this.range.css({ "width": "", "left": "" });
  10355. }
  10356. if (orientation === "horizontal") {
  10357. this.range.css({ "height": "", "bottom": "" });
  10358. }
  10359. },
  10360. _refreshValue: function() {
  10361. var lastValPercent, valPercent, value, valueMin, valueMax, oRange = this.options.range, o = this.options, that = this, animate = !this._animateOff ? o.animate : false, _set = {};
  10362. if (this._hasMultipleValues()) {
  10363. this.handles.each(function(i) {
  10364. valPercent = (that.values(i) - that._valueMin()) / (that._valueMax() - that._valueMin()) * 100;
  10365. _set[that.orientation === "horizontal" ? "left" : "bottom"] = valPercent + "%";
  10366. $(this).stop(1, 1)[animate ? "animate" : "css"](_set, o.animate);
  10367. if (that.options.range === true) {
  10368. if (that.orientation === "horizontal") {
  10369. if (i === 0) {
  10370. that.range.stop(1, 1)[animate ? "animate" : "css"]({
  10371. left: valPercent + "%"
  10372. }, o.animate);
  10373. }
  10374. if (i === 1) {
  10375. that.range[animate ? "animate" : "css"]({
  10376. width: valPercent - lastValPercent + "%"
  10377. }, {
  10378. queue: false,
  10379. duration: o.animate
  10380. });
  10381. }
  10382. } else {
  10383. if (i === 0) {
  10384. that.range.stop(1, 1)[animate ? "animate" : "css"]({
  10385. bottom: valPercent + "%"
  10386. }, o.animate);
  10387. }
  10388. if (i === 1) {
  10389. that.range[animate ? "animate" : "css"]({
  10390. height: valPercent - lastValPercent + "%"
  10391. }, {
  10392. queue: false,
  10393. duration: o.animate
  10394. });
  10395. }
  10396. }
  10397. }
  10398. lastValPercent = valPercent;
  10399. });
  10400. } else {
  10401. value = this.value();
  10402. valueMin = this._valueMin();
  10403. valueMax = this._valueMax();
  10404. valPercent = valueMax !== valueMin ? (value - valueMin) / (valueMax - valueMin) * 100 : 0;
  10405. _set[this.orientation === "horizontal" ? "left" : "bottom"] = valPercent + "%";
  10406. this.handle.stop(1, 1)[animate ? "animate" : "css"](_set, o.animate);
  10407. if (oRange === "min" && this.orientation === "horizontal") {
  10408. this.range.stop(1, 1)[animate ? "animate" : "css"]({
  10409. width: valPercent + "%"
  10410. }, o.animate);
  10411. }
  10412. if (oRange === "max" && this.orientation === "horizontal") {
  10413. this.range.stop(1, 1)[animate ? "animate" : "css"]({
  10414. width: 100 - valPercent + "%"
  10415. }, o.animate);
  10416. }
  10417. if (oRange === "min" && this.orientation === "vertical") {
  10418. this.range.stop(1, 1)[animate ? "animate" : "css"]({
  10419. height: valPercent + "%"
  10420. }, o.animate);
  10421. }
  10422. if (oRange === "max" && this.orientation === "vertical") {
  10423. this.range.stop(1, 1)[animate ? "animate" : "css"]({
  10424. height: 100 - valPercent + "%"
  10425. }, o.animate);
  10426. }
  10427. }
  10428. },
  10429. _handleEvents: {
  10430. keydown: function(event) {
  10431. var allowed, curVal, newVal, step, index = $(event.target).data("ui-slider-handle-index");
  10432. switch (event.keyCode) {
  10433. case $.ui.keyCode.HOME:
  10434. case $.ui.keyCode.END:
  10435. case $.ui.keyCode.PAGE_UP:
  10436. case $.ui.keyCode.PAGE_DOWN:
  10437. case $.ui.keyCode.UP:
  10438. case $.ui.keyCode.RIGHT:
  10439. case $.ui.keyCode.DOWN:
  10440. case $.ui.keyCode.LEFT:
  10441. event.preventDefault();
  10442. if (!this._keySliding) {
  10443. this._keySliding = true;
  10444. this._addClass($(event.target), null, "ui-state-active");
  10445. allowed = this._start(event, index);
  10446. if (allowed === false) {
  10447. return;
  10448. }
  10449. }
  10450. break;
  10451. }
  10452. step = this.options.step;
  10453. if (this._hasMultipleValues()) {
  10454. curVal = newVal = this.values(index);
  10455. } else {
  10456. curVal = newVal = this.value();
  10457. }
  10458. switch (event.keyCode) {
  10459. case $.ui.keyCode.HOME:
  10460. newVal = this._valueMin();
  10461. break;
  10462. case $.ui.keyCode.END:
  10463. newVal = this._valueMax();
  10464. break;
  10465. case $.ui.keyCode.PAGE_UP:
  10466. newVal = this._trimAlignValue(
  10467. curVal + (this._valueMax() - this._valueMin()) / this.numPages
  10468. );
  10469. break;
  10470. case $.ui.keyCode.PAGE_DOWN:
  10471. newVal = this._trimAlignValue(
  10472. curVal - (this._valueMax() - this._valueMin()) / this.numPages
  10473. );
  10474. break;
  10475. case $.ui.keyCode.UP:
  10476. case $.ui.keyCode.RIGHT:
  10477. if (curVal === this._valueMax()) {
  10478. return;
  10479. }
  10480. newVal = this._trimAlignValue(curVal + step);
  10481. break;
  10482. case $.ui.keyCode.DOWN:
  10483. case $.ui.keyCode.LEFT:
  10484. if (curVal === this._valueMin()) {
  10485. return;
  10486. }
  10487. newVal = this._trimAlignValue(curVal - step);
  10488. break;
  10489. }
  10490. this._slide(event, index, newVal);
  10491. },
  10492. keyup: function(event) {
  10493. var index = $(event.target).data("ui-slider-handle-index");
  10494. if (this._keySliding) {
  10495. this._keySliding = false;
  10496. this._stop(event, index);
  10497. this._change(event, index);
  10498. this._removeClass($(event.target), null, "ui-state-active");
  10499. }
  10500. }
  10501. }
  10502. });
  10503. var widgetsSortable = $.widget("ui.sortable", $.ui.mouse, {
  10504. version: "1.14.1",
  10505. widgetEventPrefix: "sort",
  10506. ready: false,
  10507. options: {
  10508. appendTo: "parent",
  10509. axis: false,
  10510. connectWith: false,
  10511. containment: false,
  10512. cursor: "auto",
  10513. cursorAt: false,
  10514. dropOnEmpty: true,
  10515. forcePlaceholderSize: false,
  10516. forceHelperSize: false,
  10517. grid: false,
  10518. handle: false,
  10519. helper: "original",
  10520. items: "> *",
  10521. opacity: false,
  10522. placeholder: false,
  10523. revert: false,
  10524. scroll: true,
  10525. scrollSensitivity: 20,
  10526. scrollSpeed: 20,
  10527. scope: "default",
  10528. tolerance: "intersect",
  10529. zIndex: 1e3,
  10530. // Callbacks
  10531. activate: null,
  10532. beforeStop: null,
  10533. change: null,
  10534. deactivate: null,
  10535. out: null,
  10536. over: null,
  10537. receive: null,
  10538. remove: null,
  10539. sort: null,
  10540. start: null,
  10541. stop: null,
  10542. update: null
  10543. },
  10544. _isOverAxis: function(x, reference, size) {
  10545. return x >= reference && x < reference + size;
  10546. },
  10547. _isFloating: function(item) {
  10548. return /left|right/.test(item.css("float")) || /inline|table-cell/.test(item.css("display"));
  10549. },
  10550. _create: function() {
  10551. this.containerCache = {};
  10552. this._addClass("ui-sortable");
  10553. this.refresh();
  10554. this.offset = this.element.offset();
  10555. this._mouseInit();
  10556. this._setHandleClassName();
  10557. this.ready = true;
  10558. },
  10559. _setOption: function(key, value) {
  10560. this._super(key, value);
  10561. if (key === "handle") {
  10562. this._setHandleClassName();
  10563. }
  10564. },
  10565. _setHandleClassName: function() {
  10566. var that = this;
  10567. this._removeClass(this.element.find(".ui-sortable-handle"), "ui-sortable-handle");
  10568. $.each(this.items, function() {
  10569. that._addClass(
  10570. this.instance.options.handle ? this.item.find(this.instance.options.handle) : this.item,
  10571. "ui-sortable-handle"
  10572. );
  10573. });
  10574. },
  10575. _destroy: function() {
  10576. this._mouseDestroy();
  10577. for (var i = this.items.length - 1; i >= 0; i--) {
  10578. this.items[i].item.removeData(this.widgetName + "-item");
  10579. }
  10580. return this;
  10581. },
  10582. _mouseCapture: function(event, overrideHandle) {
  10583. var currentItem = null, validHandle = false, that = this;
  10584. if (this.reverting) {
  10585. return false;
  10586. }
  10587. if (this.options.disabled || this.options.type === "static") {
  10588. return false;
  10589. }
  10590. this._refreshItems(event);
  10591. $(event.target).parents().each(function() {
  10592. if ($.data(this, that.widgetName + "-item") === that) {
  10593. currentItem = $(this);
  10594. return false;
  10595. }
  10596. });
  10597. if ($.data(event.target, that.widgetName + "-item") === that) {
  10598. currentItem = $(event.target);
  10599. }
  10600. if (!currentItem) {
  10601. return false;
  10602. }
  10603. if (this.options.handle && !overrideHandle) {
  10604. $(this.options.handle, currentItem).find("*").addBack().each(function() {
  10605. if (this === event.target) {
  10606. validHandle = true;
  10607. }
  10608. });
  10609. if (!validHandle) {
  10610. return false;
  10611. }
  10612. }
  10613. this.currentItem = currentItem;
  10614. this._removeCurrentsFromItems();
  10615. return true;
  10616. },
  10617. _mouseStart: function(event, overrideHandle, noActivation) {
  10618. var i, body, o = this.options;
  10619. this.currentContainer = this;
  10620. this.refreshPositions();
  10621. this.appendTo = $(o.appendTo !== "parent" ? o.appendTo : this.currentItem.parent());
  10622. this.helper = this._createHelper(event);
  10623. this._cacheHelperProportions();
  10624. this._cacheMargins();
  10625. this.offset = this.currentItem.offset();
  10626. this.offset = {
  10627. top: this.offset.top - this.margins.top,
  10628. left: this.offset.left - this.margins.left
  10629. };
  10630. $.extend(this.offset, {
  10631. click: {
  10632. //Where the click happened, relative to the element
  10633. left: event.pageX - this.offset.left,
  10634. top: event.pageY - this.offset.top
  10635. },
  10636. // This is a relative to absolute position minus the actual position calculation -
  10637. // only used for relative positioned helper
  10638. relative: this._getRelativeOffset()
  10639. });
  10640. this.helper.css("position", "absolute");
  10641. this.cssPosition = this.helper.css("position");
  10642. if (o.cursorAt) {
  10643. this._adjustOffsetFromHelper(o.cursorAt);
  10644. }
  10645. this.domPosition = {
  10646. prev: this.currentItem.prev()[0],
  10647. parent: this.currentItem.parent()[0]
  10648. };
  10649. if (this.helper[0] !== this.currentItem[0]) {
  10650. this.currentItem.hide();
  10651. }
  10652. this._createPlaceholder();
  10653. this.scrollParent = this.placeholder.scrollParent();
  10654. $.extend(this.offset, {
  10655. parent: this._getParentOffset()
  10656. });
  10657. if (o.containment) {
  10658. this._setContainment();
  10659. }
  10660. if (o.cursor && o.cursor !== "auto") {
  10661. body = this.document.find("body");
  10662. this._storedStylesheet = $("<style>*{ cursor: " + o.cursor + " !important; }</style>").appendTo(body);
  10663. }
  10664. if (o.zIndex) {
  10665. if (this.helper.css("zIndex")) {
  10666. this._storedZIndex = this.helper.css("zIndex");
  10667. }
  10668. this.helper.css("zIndex", o.zIndex);
  10669. }
  10670. if (o.opacity) {
  10671. if (this.helper.css("opacity")) {
  10672. this._storedOpacity = this.helper.css("opacity");
  10673. }
  10674. this.helper.css("opacity", o.opacity);
  10675. }
  10676. if (this.scrollParent[0] !== this.document[0] && this.scrollParent[0].tagName !== "HTML") {
  10677. this.overflowOffset = this.scrollParent.offset();
  10678. }
  10679. this._trigger("start", event, this._uiHash());
  10680. if (!this._preserveHelperProportions) {
  10681. this._cacheHelperProportions();
  10682. }
  10683. if (!noActivation) {
  10684. for (i = this.containers.length - 1; i >= 0; i--) {
  10685. this.containers[i]._trigger("activate", event, this._uiHash(this));
  10686. }
  10687. }
  10688. if ($.ui.ddmanager) {
  10689. $.ui.ddmanager.current = this;
  10690. }
  10691. if ($.ui.ddmanager && !o.dropBehaviour) {
  10692. $.ui.ddmanager.prepareOffsets(this, event);
  10693. }
  10694. this.dragging = true;
  10695. this._addClass(this.helper, "ui-sortable-helper");
  10696. if (!this.helper.parent().is(this.appendTo)) {
  10697. this.helper.detach().appendTo(this.appendTo);
  10698. this.offset.parent = this._getParentOffset();
  10699. }
  10700. this.position = this.originalPosition = this._generatePosition(event);
  10701. this.originalPageX = event.pageX;
  10702. this.originalPageY = event.pageY;
  10703. this.lastPositionAbs = this.positionAbs = this._convertPositionTo("absolute");
  10704. this._mouseDrag(event);
  10705. return true;
  10706. },
  10707. _scroll: function(event) {
  10708. var o = this.options, scrolled = false;
  10709. if (this.scrollParent[0] !== this.document[0] && this.scrollParent[0].tagName !== "HTML") {
  10710. if (this.overflowOffset.top + this.scrollParent[0].offsetHeight - event.pageY < o.scrollSensitivity) {
  10711. this.scrollParent[0].scrollTop = scrolled = this.scrollParent[0].scrollTop + o.scrollSpeed;
  10712. } else if (event.pageY - this.overflowOffset.top < o.scrollSensitivity) {
  10713. this.scrollParent[0].scrollTop = scrolled = this.scrollParent[0].scrollTop - o.scrollSpeed;
  10714. }
  10715. if (this.overflowOffset.left + this.scrollParent[0].offsetWidth - event.pageX < o.scrollSensitivity) {
  10716. this.scrollParent[0].scrollLeft = scrolled = this.scrollParent[0].scrollLeft + o.scrollSpeed;
  10717. } else if (event.pageX - this.overflowOffset.left < o.scrollSensitivity) {
  10718. this.scrollParent[0].scrollLeft = scrolled = this.scrollParent[0].scrollLeft - o.scrollSpeed;
  10719. }
  10720. } else {
  10721. if (event.pageY - this.document.scrollTop() < o.scrollSensitivity) {
  10722. scrolled = this.document.scrollTop(this.document.scrollTop() - o.scrollSpeed);
  10723. } else if (this.window.height() - (event.pageY - this.document.scrollTop()) < o.scrollSensitivity) {
  10724. scrolled = this.document.scrollTop(this.document.scrollTop() + o.scrollSpeed);
  10725. }
  10726. if (event.pageX - this.document.scrollLeft() < o.scrollSensitivity) {
  10727. scrolled = this.document.scrollLeft(
  10728. this.document.scrollLeft() - o.scrollSpeed
  10729. );
  10730. } else if (this.window.width() - (event.pageX - this.document.scrollLeft()) < o.scrollSensitivity) {
  10731. scrolled = this.document.scrollLeft(
  10732. this.document.scrollLeft() + o.scrollSpeed
  10733. );
  10734. }
  10735. }
  10736. return scrolled;
  10737. },
  10738. _mouseDrag: function(event) {
  10739. var i, item, itemElement, intersection, o = this.options;
  10740. this.position = this._generatePosition(event);
  10741. this.positionAbs = this._convertPositionTo("absolute");
  10742. if (!this.options.axis || this.options.axis !== "y") {
  10743. this.helper[0].style.left = this.position.left + "px";
  10744. }
  10745. if (!this.options.axis || this.options.axis !== "x") {
  10746. this.helper[0].style.top = this.position.top + "px";
  10747. }
  10748. if (o.scroll) {
  10749. if (this._scroll(event) !== false) {
  10750. this._refreshItemPositions(true);
  10751. if ($.ui.ddmanager && !o.dropBehaviour) {
  10752. $.ui.ddmanager.prepareOffsets(this, event);
  10753. }
  10754. }
  10755. }
  10756. this.dragDirection = {
  10757. vertical: this._getDragVerticalDirection(),
  10758. horizontal: this._getDragHorizontalDirection()
  10759. };
  10760. for (i = this.items.length - 1; i >= 0; i--) {
  10761. item = this.items[i];
  10762. itemElement = item.item[0];
  10763. intersection = this._intersectsWithPointer(item);
  10764. if (!intersection) {
  10765. continue;
  10766. }
  10767. if (item.instance !== this.currentContainer) {
  10768. continue;
  10769. }
  10770. if (itemElement !== this.currentItem[0] && this.placeholder[intersection === 1 ? "next" : "prev"]()[0] !== itemElement && !$.contains(this.placeholder[0], itemElement) && (this.options.type === "semi-dynamic" ? !$.contains(this.element[0], itemElement) : true)) {
  10771. this.direction = intersection === 1 ? "down" : "up";
  10772. if (this.options.tolerance === "pointer" || this._intersectsWithSides(item)) {
  10773. this._rearrange(event, item);
  10774. } else {
  10775. break;
  10776. }
  10777. this._trigger("change", event, this._uiHash());
  10778. break;
  10779. }
  10780. }
  10781. this._contactContainers(event);
  10782. if ($.ui.ddmanager) {
  10783. $.ui.ddmanager.drag(this, event);
  10784. }
  10785. this._trigger("sort", event, this._uiHash());
  10786. this.lastPositionAbs = this.positionAbs;
  10787. return false;
  10788. },
  10789. _mouseStop: function(event, noPropagation) {
  10790. if (!event) {
  10791. return;
  10792. }
  10793. if ($.ui.ddmanager && !this.options.dropBehaviour) {
  10794. $.ui.ddmanager.drop(this, event);
  10795. }
  10796. if (this.options.revert) {
  10797. var that = this, cur = this.placeholder.offset(), axis = this.options.axis, animation = {};
  10798. if (!axis || axis === "x") {
  10799. animation.left = cur.left - this.offset.parent.left - this.margins.left + (this.offsetParent[0] === this.document[0].body ? 0 : this.offsetParent[0].scrollLeft);
  10800. }
  10801. if (!axis || axis === "y") {
  10802. animation.top = cur.top - this.offset.parent.top - this.margins.top + (this.offsetParent[0] === this.document[0].body ? 0 : this.offsetParent[0].scrollTop);
  10803. }
  10804. this.reverting = true;
  10805. $(this.helper).animate(
  10806. animation,
  10807. parseInt(this.options.revert, 10) || 500,
  10808. function() {
  10809. that._clear(event);
  10810. }
  10811. );
  10812. } else {
  10813. this._clear(event, noPropagation);
  10814. }
  10815. return false;
  10816. },
  10817. cancel: function() {
  10818. if (this.dragging) {
  10819. this._mouseUp(new $.Event("mouseup", { target: null }));
  10820. if (this.options.helper === "original") {
  10821. this.currentItem.css(this._storedCSS);
  10822. this._removeClass(this.currentItem, "ui-sortable-helper");
  10823. } else {
  10824. this.currentItem.show();
  10825. }
  10826. for (var i = this.containers.length - 1; i >= 0; i--) {
  10827. this.containers[i]._trigger("deactivate", null, this._uiHash(this));
  10828. if (this.containers[i].containerCache.over) {
  10829. this.containers[i]._trigger("out", null, this._uiHash(this));
  10830. this.containers[i].containerCache.over = 0;
  10831. }
  10832. }
  10833. }
  10834. if (this.placeholder) {
  10835. if (this.placeholder[0].parentNode) {
  10836. this.placeholder[0].parentNode.removeChild(this.placeholder[0]);
  10837. }
  10838. if (this.options.helper !== "original" && this.helper && this.helper[0].parentNode) {
  10839. this.helper.remove();
  10840. }
  10841. $.extend(this, {
  10842. helper: null,
  10843. dragging: false,
  10844. reverting: false,
  10845. _noFinalSort: null
  10846. });
  10847. if (this.domPosition.prev) {
  10848. $(this.domPosition.prev).after(this.currentItem);
  10849. } else {
  10850. $(this.domPosition.parent).prepend(this.currentItem);
  10851. }
  10852. }
  10853. return this;
  10854. },
  10855. serialize: function(o) {
  10856. var items = this._getItemsAsjQuery(o && o.connected), str = [];
  10857. o = o || {};
  10858. $(items).each(function() {
  10859. var res = ($(o.item || this).attr(o.attribute || "id") || "").match(o.expression || /(.+)[\-=_](.+)/);
  10860. if (res) {
  10861. str.push(
  10862. (o.key || res[1] + "[]") + "=" + (o.key && o.expression ? res[1] : res[2])
  10863. );
  10864. }
  10865. });
  10866. if (!str.length && o.key) {
  10867. str.push(o.key + "=");
  10868. }
  10869. return str.join("&");
  10870. },
  10871. toArray: function(o) {
  10872. var items = this._getItemsAsjQuery(o && o.connected), ret = [];
  10873. o = o || {};
  10874. items.each(function() {
  10875. ret.push($(o.item || this).attr(o.attribute || "id") || "");
  10876. });
  10877. return ret;
  10878. },
  10879. /* Be careful with the following core functions */
  10880. _intersectsWith: function(item) {
  10881. var x1 = this.positionAbs.left, x2 = x1 + this.helperProportions.width, y1 = this.positionAbs.top, y2 = y1 + this.helperProportions.height, l = item.left, r = l + item.width, t = item.top, b = t + item.height, dyClick = this.offset.click.top, dxClick = this.offset.click.left, isOverElementHeight = this.options.axis === "x" || y1 + dyClick > t && y1 + dyClick < b, isOverElementWidth = this.options.axis === "y" || x1 + dxClick > l && x1 + dxClick < r, isOverElement = isOverElementHeight && isOverElementWidth;
  10882. if (this.options.tolerance === "pointer" || this.options.forcePointerForContainers || this.options.tolerance !== "pointer" && this.helperProportions[this.floating ? "width" : "height"] > item[this.floating ? "width" : "height"]) {
  10883. return isOverElement;
  10884. } else {
  10885. return l < x1 + this.helperProportions.width / 2 && // Right Half
  10886. x2 - this.helperProportions.width / 2 < r && // Left Half
  10887. t < y1 + this.helperProportions.height / 2 && // Bottom Half
  10888. y2 - this.helperProportions.height / 2 < b;
  10889. }
  10890. },
  10891. _intersectsWithPointer: function(item) {
  10892. var verticalDirection, horizontalDirection, isOverElementHeight = this.options.axis === "x" || this._isOverAxis(
  10893. this.positionAbs.top + this.offset.click.top,
  10894. item.top,
  10895. item.height
  10896. ), isOverElementWidth = this.options.axis === "y" || this._isOverAxis(
  10897. this.positionAbs.left + this.offset.click.left,
  10898. item.left,
  10899. item.width
  10900. ), isOverElement = isOverElementHeight && isOverElementWidth;
  10901. if (!isOverElement) {
  10902. return false;
  10903. }
  10904. verticalDirection = this.dragDirection.vertical;
  10905. horizontalDirection = this.dragDirection.horizontal;
  10906. return this.floating ? horizontalDirection === "right" || verticalDirection === "down" ? 2 : 1 : verticalDirection && (verticalDirection === "down" ? 2 : 1);
  10907. },
  10908. _intersectsWithSides: function(item) {
  10909. var isOverBottomHalf = this._isOverAxis(this.positionAbs.top + this.offset.click.top, item.top + item.height / 2, item.height), isOverRightHalf = this._isOverAxis(this.positionAbs.left + this.offset.click.left, item.left + item.width / 2, item.width), verticalDirection = this.dragDirection.vertical, horizontalDirection = this.dragDirection.horizontal;
  10910. if (this.floating && horizontalDirection) {
  10911. return horizontalDirection === "right" && isOverRightHalf || horizontalDirection === "left" && !isOverRightHalf;
  10912. } else {
  10913. return verticalDirection && (verticalDirection === "down" && isOverBottomHalf || verticalDirection === "up" && !isOverBottomHalf);
  10914. }
  10915. },
  10916. _getDragVerticalDirection: function() {
  10917. var delta = this.positionAbs.top - this.lastPositionAbs.top;
  10918. return delta !== 0 && (delta > 0 ? "down" : "up");
  10919. },
  10920. _getDragHorizontalDirection: function() {
  10921. var delta = this.positionAbs.left - this.lastPositionAbs.left;
  10922. return delta !== 0 && (delta > 0 ? "right" : "left");
  10923. },
  10924. refresh: function(event) {
  10925. this._refreshItems(event);
  10926. this._setHandleClassName();
  10927. this.refreshPositions();
  10928. return this;
  10929. },
  10930. _connectWith: function() {
  10931. var options = this.options;
  10932. return options.connectWith.constructor === String ? [options.connectWith] : options.connectWith;
  10933. },
  10934. _getItemsAsjQuery: function(connected) {
  10935. var i, j, cur, inst, items = [], queries = [], connectWith = this._connectWith();
  10936. if (connectWith && connected) {
  10937. for (i = connectWith.length - 1; i >= 0; i--) {
  10938. cur = $(connectWith[i], this.document[0]);
  10939. for (j = cur.length - 1; j >= 0; j--) {
  10940. inst = $.data(cur[j], this.widgetFullName);
  10941. if (inst && inst !== this && !inst.options.disabled) {
  10942. queries.push([typeof inst.options.items === "function" ? inst.options.items.call(inst.element) : $(inst.options.items, inst.element).not(".ui-sortable-helper").not(".ui-sortable-placeholder"), inst]);
  10943. }
  10944. }
  10945. }
  10946. }
  10947. queries.push([typeof this.options.items === "function" ? 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]);
  10948. function addItems() {
  10949. items.push(this);
  10950. }
  10951. for (i = queries.length - 1; i >= 0; i--) {
  10952. queries[i][0].each(addItems);
  10953. }
  10954. return $(items);
  10955. },
  10956. _removeCurrentsFromItems: function() {
  10957. var list = this.currentItem.find(":data(" + this.widgetName + "-item)");
  10958. this.items = $.grep(this.items, function(item) {
  10959. for (var j = 0; j < list.length; j++) {
  10960. if (list[j] === item.item[0]) {
  10961. return false;
  10962. }
  10963. }
  10964. return true;
  10965. });
  10966. },
  10967. _refreshItems: function(event) {
  10968. this.items = [];
  10969. this.containers = [this];
  10970. var i, j, cur, inst, targetData, _queries, item, queriesLength, items = this.items, queries = [[typeof this.options.items === "function" ? this.options.items.call(this.element[0], event, { item: this.currentItem }) : $(this.options.items, this.element), this]], connectWith = this._connectWith();
  10971. if (connectWith && this.ready) {
  10972. for (i = connectWith.length - 1; i >= 0; i--) {
  10973. cur = $(connectWith[i], this.document[0]);
  10974. for (j = cur.length - 1; j >= 0; j--) {
  10975. inst = $.data(cur[j], this.widgetFullName);
  10976. if (inst && inst !== this && !inst.options.disabled) {
  10977. queries.push([typeof inst.options.items === "function" ? inst.options.items.call(inst.element[0], event, { item: this.currentItem }) : $(inst.options.items, inst.element), inst]);
  10978. this.containers.push(inst);
  10979. }
  10980. }
  10981. }
  10982. }
  10983. for (i = queries.length - 1; i >= 0; i--) {
  10984. targetData = queries[i][1];
  10985. _queries = queries[i][0];
  10986. for (j = 0, queriesLength = _queries.length; j < queriesLength; j++) {
  10987. item = $(_queries[j]);
  10988. item.data(this.widgetName + "-item", targetData);
  10989. items.push({
  10990. item,
  10991. instance: targetData,
  10992. width: 0,
  10993. height: 0,
  10994. left: 0,
  10995. top: 0
  10996. });
  10997. }
  10998. }
  10999. },
  11000. _refreshItemPositions: function(fast) {
  11001. var i, item, t, p;
  11002. for (i = this.items.length - 1; i >= 0; i--) {
  11003. item = this.items[i];
  11004. if (this.currentContainer && item.instance !== this.currentContainer && item.item[0] !== this.currentItem[0]) {
  11005. continue;
  11006. }
  11007. t = this.options.toleranceElement ? $(this.options.toleranceElement, item.item) : item.item;
  11008. if (!fast) {
  11009. item.width = t.outerWidth();
  11010. item.height = t.outerHeight();
  11011. }
  11012. p = t.offset();
  11013. item.left = p.left;
  11014. item.top = p.top;
  11015. }
  11016. },
  11017. refreshPositions: function(fast) {
  11018. this.floating = this.items.length ? this.options.axis === "x" || this._isFloating(this.items[0].item) : false;
  11019. if (this.offsetParent && this.helper) {
  11020. this.offset.parent = this._getParentOffset();
  11021. }
  11022. this._refreshItemPositions(fast);
  11023. var i, p;
  11024. if (this.options.custom && this.options.custom.refreshContainers) {
  11025. this.options.custom.refreshContainers.call(this);
  11026. } else {
  11027. for (i = this.containers.length - 1; i >= 0; i--) {
  11028. p = this.containers[i].element.offset();
  11029. this.containers[i].containerCache.left = p.left;
  11030. this.containers[i].containerCache.top = p.top;
  11031. this.containers[i].containerCache.width = this.containers[i].element.outerWidth();
  11032. this.containers[i].containerCache.height = this.containers[i].element.outerHeight();
  11033. }
  11034. }
  11035. return this;
  11036. },
  11037. _createPlaceholder: function(that) {
  11038. that = that || this;
  11039. var className, nodeName, o = that.options;
  11040. if (!o.placeholder || o.placeholder.constructor === String) {
  11041. className = o.placeholder;
  11042. nodeName = that.currentItem[0].nodeName.toLowerCase();
  11043. o.placeholder = {
  11044. element: function() {
  11045. var element = $("<" + nodeName + ">", that.document[0]);
  11046. that._addClass(
  11047. element,
  11048. "ui-sortable-placeholder",
  11049. className || that.currentItem[0].className
  11050. )._removeClass(element, "ui-sortable-helper");
  11051. if (nodeName === "tbody") {
  11052. that._createTrPlaceholder(
  11053. that.currentItem.find("tr").eq(0),
  11054. $("<tr>", that.document[0]).appendTo(element)
  11055. );
  11056. } else if (nodeName === "tr") {
  11057. that._createTrPlaceholder(that.currentItem, element);
  11058. } else if (nodeName === "img") {
  11059. element.attr("src", that.currentItem.attr("src"));
  11060. }
  11061. if (!className) {
  11062. element.css("visibility", "hidden");
  11063. }
  11064. return element;
  11065. },
  11066. update: function(container, p) {
  11067. if (className && !o.forcePlaceholderSize) {
  11068. return;
  11069. }
  11070. if (!p.height() || o.forcePlaceholderSize && (nodeName === "tbody" || nodeName === "tr")) {
  11071. p.height(
  11072. that.currentItem.innerHeight() - parseInt(that.currentItem.css("paddingTop") || 0, 10) - parseInt(that.currentItem.css("paddingBottom") || 0, 10)
  11073. );
  11074. }
  11075. if (!p.width()) {
  11076. p.width(
  11077. that.currentItem.innerWidth() - parseInt(that.currentItem.css("paddingLeft") || 0, 10) - parseInt(that.currentItem.css("paddingRight") || 0, 10)
  11078. );
  11079. }
  11080. }
  11081. };
  11082. }
  11083. that.placeholder = $(o.placeholder.element.call(that.element, that.currentItem));
  11084. that.currentItem.after(that.placeholder);
  11085. o.placeholder.update(that, that.placeholder);
  11086. },
  11087. _createTrPlaceholder: function(sourceTr, targetTr) {
  11088. var that = this;
  11089. sourceTr.children().each(function() {
  11090. $("<td>&#160;</td>", that.document[0]).attr("colspan", $(this).attr("colspan") || 1).appendTo(targetTr);
  11091. });
  11092. },
  11093. _contactContainers: function(event) {
  11094. var i, j, dist, itemWithLeastDistance, posProperty, sizeProperty, cur, nearBottom, floating, axis, innermostContainer = null, innermostIndex = null;
  11095. for (i = this.containers.length - 1; i >= 0; i--) {
  11096. if ($.contains(this.currentItem[0], this.containers[i].element[0])) {
  11097. continue;
  11098. }
  11099. if (this._intersectsWith(this.containers[i].containerCache)) {
  11100. if (innermostContainer && $.contains(
  11101. this.containers[i].element[0],
  11102. innermostContainer.element[0]
  11103. )) {
  11104. continue;
  11105. }
  11106. innermostContainer = this.containers[i];
  11107. innermostIndex = i;
  11108. } else {
  11109. if (this.containers[i].containerCache.over) {
  11110. this.containers[i]._trigger("out", event, this._uiHash(this));
  11111. this.containers[i].containerCache.over = 0;
  11112. }
  11113. }
  11114. }
  11115. if (!innermostContainer) {
  11116. return;
  11117. }
  11118. if (this.containers.length === 1) {
  11119. if (!this.containers[innermostIndex].containerCache.over) {
  11120. this.containers[innermostIndex]._trigger("over", event, this._uiHash(this));
  11121. this.containers[innermostIndex].containerCache.over = 1;
  11122. }
  11123. } else {
  11124. dist = 1e4;
  11125. itemWithLeastDistance = null;
  11126. floating = innermostContainer.floating || this._isFloating(this.currentItem);
  11127. posProperty = floating ? "left" : "top";
  11128. sizeProperty = floating ? "width" : "height";
  11129. axis = floating ? "pageX" : "pageY";
  11130. for (j = this.items.length - 1; j >= 0; j--) {
  11131. if (!$.contains(
  11132. this.containers[innermostIndex].element[0],
  11133. this.items[j].item[0]
  11134. )) {
  11135. continue;
  11136. }
  11137. if (this.items[j].item[0] === this.currentItem[0]) {
  11138. continue;
  11139. }
  11140. cur = this.items[j].item.offset()[posProperty];
  11141. nearBottom = false;
  11142. if (event[axis] - cur > this.items[j][sizeProperty] / 2) {
  11143. nearBottom = true;
  11144. }
  11145. if (Math.abs(event[axis] - cur) < dist) {
  11146. dist = Math.abs(event[axis] - cur);
  11147. itemWithLeastDistance = this.items[j];
  11148. this.direction = nearBottom ? "up" : "down";
  11149. }
  11150. }
  11151. if (!itemWithLeastDistance && !this.options.dropOnEmpty) {
  11152. return;
  11153. }
  11154. if (this.currentContainer === this.containers[innermostIndex]) {
  11155. if (!this.currentContainer.containerCache.over) {
  11156. this.containers[innermostIndex]._trigger("over", event, this._uiHash());
  11157. this.currentContainer.containerCache.over = 1;
  11158. }
  11159. return;
  11160. }
  11161. if (itemWithLeastDistance) {
  11162. this._rearrange(event, itemWithLeastDistance, null, true);
  11163. } else {
  11164. this._rearrange(event, null, this.containers[innermostIndex].element, true);
  11165. }
  11166. this._trigger("change", event, this._uiHash());
  11167. this.containers[innermostIndex]._trigger("change", event, this._uiHash(this));
  11168. this.currentContainer = this.containers[innermostIndex];
  11169. this.options.placeholder.update(this.currentContainer, this.placeholder);
  11170. this.scrollParent = this.placeholder.scrollParent();
  11171. if (this.scrollParent[0] !== this.document[0] && this.scrollParent[0].tagName !== "HTML") {
  11172. this.overflowOffset = this.scrollParent.offset();
  11173. }
  11174. this.containers[innermostIndex]._trigger("over", event, this._uiHash(this));
  11175. this.containers[innermostIndex].containerCache.over = 1;
  11176. }
  11177. },
  11178. _createHelper: function(event) {
  11179. var o = this.options, helper = typeof o.helper === "function" ? $(o.helper.apply(this.element[0], [event, this.currentItem])) : o.helper === "clone" ? this.currentItem.clone() : this.currentItem;
  11180. if (!helper.parents("body").length) {
  11181. this.appendTo[0].appendChild(helper[0]);
  11182. }
  11183. if (helper[0] === this.currentItem[0]) {
  11184. this._storedCSS = {
  11185. width: this.currentItem[0].style.width,
  11186. height: this.currentItem[0].style.height,
  11187. position: this.currentItem.css("position"),
  11188. top: this.currentItem.css("top"),
  11189. left: this.currentItem.css("left")
  11190. };
  11191. }
  11192. if (!helper[0].style.width || o.forceHelperSize) {
  11193. helper.width(this.currentItem.width());
  11194. }
  11195. if (!helper[0].style.height || o.forceHelperSize) {
  11196. helper.height(this.currentItem.height());
  11197. }
  11198. return helper;
  11199. },
  11200. _adjustOffsetFromHelper: function(obj) {
  11201. if (typeof obj === "string") {
  11202. obj = obj.split(" ");
  11203. }
  11204. if (Array.isArray(obj)) {
  11205. obj = { left: +obj[0], top: +obj[1] || 0 };
  11206. }
  11207. if ("left" in obj) {
  11208. this.offset.click.left = obj.left + this.margins.left;
  11209. }
  11210. if ("right" in obj) {
  11211. this.offset.click.left = this.helperProportions.width - obj.right + this.margins.left;
  11212. }
  11213. if ("top" in obj) {
  11214. this.offset.click.top = obj.top + this.margins.top;
  11215. }
  11216. if ("bottom" in obj) {
  11217. this.offset.click.top = this.helperProportions.height - obj.bottom + this.margins.top;
  11218. }
  11219. },
  11220. _getParentOffset: function() {
  11221. this.offsetParent = this.helper.offsetParent();
  11222. var po = this.offsetParent.offset();
  11223. if (this.cssPosition === "absolute" && this.scrollParent[0] !== this.document[0] && $.contains(this.scrollParent[0], this.offsetParent[0])) {
  11224. po.left += this.scrollParent.scrollLeft();
  11225. po.top += this.scrollParent.scrollTop();
  11226. }
  11227. if (this.offsetParent[0] === this.document[0].body) {
  11228. po = { top: 0, left: 0 };
  11229. }
  11230. return {
  11231. top: po.top + (parseInt(this.offsetParent.css("borderTopWidth"), 10) || 0),
  11232. left: po.left + (parseInt(this.offsetParent.css("borderLeftWidth"), 10) || 0)
  11233. };
  11234. },
  11235. _getRelativeOffset: function() {
  11236. if (this.cssPosition === "relative") {
  11237. var p = this.currentItem.position();
  11238. return {
  11239. top: p.top - (parseInt(this.helper.css("top"), 10) || 0) + this.scrollParent.scrollTop(),
  11240. left: p.left - (parseInt(this.helper.css("left"), 10) || 0) + this.scrollParent.scrollLeft()
  11241. };
  11242. } else {
  11243. return { top: 0, left: 0 };
  11244. }
  11245. },
  11246. _cacheMargins: function() {
  11247. this.margins = {
  11248. left: parseInt(this.currentItem.css("marginLeft"), 10) || 0,
  11249. top: parseInt(this.currentItem.css("marginTop"), 10) || 0
  11250. };
  11251. },
  11252. _cacheHelperProportions: function() {
  11253. this.helperProportions = {
  11254. width: this.helper.outerWidth(),
  11255. height: this.helper.outerHeight()
  11256. };
  11257. },
  11258. _setContainment: function() {
  11259. var ce, co, over, o = this.options;
  11260. if (o.containment === "parent") {
  11261. o.containment = this.helper[0].parentNode;
  11262. }
  11263. if (o.containment === "document" || o.containment === "window") {
  11264. this.containment = [
  11265. 0 - this.offset.relative.left - this.offset.parent.left,
  11266. 0 - this.offset.relative.top - this.offset.parent.top,
  11267. o.containment === "document" ? this.document.width() : this.window.width() - this.helperProportions.width - this.margins.left,
  11268. (o.containment === "document" ? this.document.height() || document.body.parentNode.scrollHeight : this.window.height() || this.document[0].body.parentNode.scrollHeight) - this.helperProportions.height - this.margins.top
  11269. ];
  11270. }
  11271. if (!/^(document|window|parent)$/.test(o.containment)) {
  11272. ce = $(o.containment)[0];
  11273. co = $(o.containment).offset();
  11274. over = $(ce).css("overflow") !== "hidden";
  11275. this.containment = [
  11276. co.left + (parseInt($(ce).css("borderLeftWidth"), 10) || 0) + (parseInt($(ce).css("paddingLeft"), 10) || 0) - this.margins.left,
  11277. co.top + (parseInt($(ce).css("borderTopWidth"), 10) || 0) + (parseInt($(ce).css("paddingTop"), 10) || 0) - this.margins.top,
  11278. 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,
  11279. 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
  11280. ];
  11281. }
  11282. },
  11283. _convertPositionTo: function(d, pos) {
  11284. if (!pos) {
  11285. pos = this.position;
  11286. }
  11287. var mod = d === "absolute" ? 1 : -1, scroll = this.cssPosition === "absolute" && !(this.scrollParent[0] !== this.document[0] && $.contains(this.scrollParent[0], this.offsetParent[0])) ? this.offsetParent : this.scrollParent, scrollIsRootNode = /(html|body)/i.test(scroll[0].tagName);
  11288. return {
  11289. top: (
  11290. // The absolute mouse position
  11291. pos.top + // Only for relative positioned nodes: Relative offset from element to offset parent
  11292. this.offset.relative.top * mod + // The offsetParent's offset without borders (offset + border)
  11293. this.offset.parent.top * mod - (this.cssPosition === "fixed" ? -this.scrollParent.scrollTop() : scrollIsRootNode ? 0 : scroll.scrollTop()) * mod
  11294. ),
  11295. left: (
  11296. // The absolute mouse position
  11297. pos.left + // Only for relative positioned nodes: Relative offset from element to offset parent
  11298. this.offset.relative.left * mod + // The offsetParent's offset without borders (offset + border)
  11299. this.offset.parent.left * mod - (this.cssPosition === "fixed" ? -this.scrollParent.scrollLeft() : scrollIsRootNode ? 0 : scroll.scrollLeft()) * mod
  11300. )
  11301. };
  11302. },
  11303. _generatePosition: function(event) {
  11304. var top, left, o = this.options, pageX = event.pageX, pageY = event.pageY, scroll = this.cssPosition === "absolute" && !(this.scrollParent[0] !== this.document[0] && $.contains(this.scrollParent[0], this.offsetParent[0])) ? this.offsetParent : this.scrollParent, scrollIsRootNode = /(html|body)/i.test(scroll[0].tagName);
  11305. if (this.cssPosition === "relative" && !(this.scrollParent[0] !== this.document[0] && this.scrollParent[0] !== this.offsetParent[0])) {
  11306. this.offset.relative = this._getRelativeOffset();
  11307. }
  11308. if (this.originalPosition) {
  11309. if (this.containment) {
  11310. if (event.pageX - this.offset.click.left < this.containment[0]) {
  11311. pageX = this.containment[0] + this.offset.click.left;
  11312. }
  11313. if (event.pageY - this.offset.click.top < this.containment[1]) {
  11314. pageY = this.containment[1] + this.offset.click.top;
  11315. }
  11316. if (event.pageX - this.offset.click.left > this.containment[2]) {
  11317. pageX = this.containment[2] + this.offset.click.left;
  11318. }
  11319. if (event.pageY - this.offset.click.top > this.containment[3]) {
  11320. pageY = this.containment[3] + this.offset.click.top;
  11321. }
  11322. }
  11323. if (o.grid) {
  11324. top = this.originalPageY + Math.round((pageY - this.originalPageY) / o.grid[1]) * o.grid[1];
  11325. 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;
  11326. left = this.originalPageX + Math.round((pageX - this.originalPageX) / o.grid[0]) * o.grid[0];
  11327. 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;
  11328. }
  11329. }
  11330. return {
  11331. top: (
  11332. // The absolute mouse position
  11333. pageY - // Click offset (relative to the element)
  11334. this.offset.click.top - // Only for relative positioned nodes: Relative offset from element to offset parent
  11335. this.offset.relative.top - // The offsetParent's offset without borders (offset + border)
  11336. this.offset.parent.top + (this.cssPosition === "fixed" ? -this.scrollParent.scrollTop() : scrollIsRootNode ? 0 : scroll.scrollTop())
  11337. ),
  11338. left: (
  11339. // The absolute mouse position
  11340. pageX - // Click offset (relative to the element)
  11341. this.offset.click.left - // Only for relative positioned nodes: Relative offset from element to offset parent
  11342. this.offset.relative.left - // The offsetParent's offset without borders (offset + border)
  11343. this.offset.parent.left + (this.cssPosition === "fixed" ? -this.scrollParent.scrollLeft() : scrollIsRootNode ? 0 : scroll.scrollLeft())
  11344. )
  11345. };
  11346. },
  11347. _rearrange: function(event, i, a, hardRefresh) {
  11348. if (a) {
  11349. a[0].appendChild(this.placeholder[0]);
  11350. } else {
  11351. i.item[0].parentNode.insertBefore(
  11352. this.placeholder[0],
  11353. this.direction === "down" ? i.item[0] : i.item[0].nextSibling
  11354. );
  11355. }
  11356. this.counter = this.counter ? ++this.counter : 1;
  11357. var counter = this.counter;
  11358. this._delay(function() {
  11359. if (counter === this.counter) {
  11360. this.refreshPositions(!hardRefresh);
  11361. }
  11362. });
  11363. },
  11364. _clear: function(event, noPropagation) {
  11365. this.reverting = false;
  11366. var i, delayedTriggers = [];
  11367. if (!this._noFinalSort && this.currentItem.parent().length) {
  11368. this.placeholder.before(this.currentItem);
  11369. }
  11370. this._noFinalSort = null;
  11371. if (this.helper[0] === this.currentItem[0]) {
  11372. for (i in this._storedCSS) {
  11373. if (this._storedCSS[i] === "auto" || this._storedCSS[i] === "static") {
  11374. this._storedCSS[i] = "";
  11375. }
  11376. }
  11377. this.currentItem.css(this._storedCSS);
  11378. this._removeClass(this.currentItem, "ui-sortable-helper");
  11379. } else {
  11380. this.currentItem.show();
  11381. }
  11382. if (this.fromOutside && !noPropagation) {
  11383. delayedTriggers.push(function(event2) {
  11384. this._trigger("receive", event2, this._uiHash(this.fromOutside));
  11385. });
  11386. }
  11387. if ((this.fromOutside || this.domPosition.prev !== this.currentItem.prev().not(".ui-sortable-helper")[0] || this.domPosition.parent !== this.currentItem.parent()[0]) && !noPropagation) {
  11388. delayedTriggers.push(function(event2) {
  11389. this._trigger("update", event2, this._uiHash());
  11390. });
  11391. }
  11392. if (this !== this.currentContainer) {
  11393. if (!noPropagation) {
  11394. delayedTriggers.push(function(event2) {
  11395. this._trigger("remove", event2, this._uiHash());
  11396. });
  11397. delayedTriggers.push((function(c) {
  11398. return function(event2) {
  11399. c._trigger("receive", event2, this._uiHash(this));
  11400. };
  11401. }).call(this, this.currentContainer));
  11402. delayedTriggers.push((function(c) {
  11403. return function(event2) {
  11404. c._trigger("update", event2, this._uiHash(this));
  11405. };
  11406. }).call(this, this.currentContainer));
  11407. }
  11408. }
  11409. function delayEvent(type, instance, container) {
  11410. return function(event2) {
  11411. container._trigger(type, event2, instance._uiHash(instance));
  11412. };
  11413. }
  11414. for (i = this.containers.length - 1; i >= 0; i--) {
  11415. if (!noPropagation) {
  11416. delayedTriggers.push(delayEvent("deactivate", this, this.containers[i]));
  11417. }
  11418. if (this.containers[i].containerCache.over) {
  11419. delayedTriggers.push(delayEvent("out", this, this.containers[i]));
  11420. this.containers[i].containerCache.over = 0;
  11421. }
  11422. }
  11423. if (this._storedStylesheet) {
  11424. this._storedStylesheet.remove();
  11425. this._storedStylesheet = null;
  11426. }
  11427. if (this._storedOpacity) {
  11428. this.helper.css("opacity", this._storedOpacity);
  11429. }
  11430. if (this._storedZIndex) {
  11431. this.helper.css("zIndex", this._storedZIndex === "auto" ? "" : this._storedZIndex);
  11432. }
  11433. this.dragging = false;
  11434. if (!noPropagation) {
  11435. this._trigger("beforeStop", event, this._uiHash());
  11436. }
  11437. this.placeholder[0].parentNode.removeChild(this.placeholder[0]);
  11438. if (!this.cancelHelperRemoval) {
  11439. if (this.helper[0] !== this.currentItem[0]) {
  11440. this.helper.remove();
  11441. }
  11442. this.helper = null;
  11443. }
  11444. if (!noPropagation) {
  11445. for (i = 0; i < delayedTriggers.length; i++) {
  11446. delayedTriggers[i].call(this, event);
  11447. }
  11448. this._trigger("stop", event, this._uiHash());
  11449. }
  11450. this.fromOutside = false;
  11451. return !this.cancelHelperRemoval;
  11452. },
  11453. _trigger: function() {
  11454. if ($.Widget.prototype._trigger.apply(this, arguments) === false) {
  11455. this.cancel();
  11456. }
  11457. },
  11458. _uiHash: function(_inst) {
  11459. var inst = _inst || this;
  11460. return {
  11461. helper: inst.helper,
  11462. placeholder: inst.placeholder || $([]),
  11463. position: inst.position,
  11464. originalPosition: inst.originalPosition,
  11465. offset: inst.positionAbs,
  11466. item: inst.currentItem,
  11467. sender: _inst ? _inst.element : null
  11468. };
  11469. }
  11470. });
  11471. function spinnerModifier(fn) {
  11472. return function() {
  11473. var previous = this.element.val();
  11474. fn.apply(this, arguments);
  11475. this._refresh();
  11476. if (previous !== this.element.val()) {
  11477. this._trigger("change");
  11478. }
  11479. };
  11480. }
  11481. $.widget("ui.spinner", {
  11482. version: "1.14.1",
  11483. defaultElement: "<input>",
  11484. widgetEventPrefix: "spin",
  11485. options: {
  11486. classes: {
  11487. "ui-spinner": "ui-corner-all",
  11488. "ui-spinner-down": "ui-corner-br",
  11489. "ui-spinner-up": "ui-corner-tr"
  11490. },
  11491. culture: null,
  11492. icons: {
  11493. down: "ui-icon-triangle-1-s",
  11494. up: "ui-icon-triangle-1-n"
  11495. },
  11496. incremental: true,
  11497. max: null,
  11498. min: null,
  11499. numberFormat: null,
  11500. page: 10,
  11501. step: 1,
  11502. change: null,
  11503. spin: null,
  11504. start: null,
  11505. stop: null
  11506. },
  11507. _create: function() {
  11508. this._setOption("max", this.options.max);
  11509. this._setOption("min", this.options.min);
  11510. this._setOption("step", this.options.step);
  11511. if (this.value() !== "") {
  11512. this._value(this.element.val(), true);
  11513. }
  11514. this._draw();
  11515. this._on(this._events);
  11516. this._refresh();
  11517. this._on(this.window, {
  11518. beforeunload: function() {
  11519. this.element.removeAttr("autocomplete");
  11520. }
  11521. });
  11522. },
  11523. _getCreateOptions: function() {
  11524. var options = this._super();
  11525. var element = this.element;
  11526. $.each(["min", "max", "step"], function(i, option) {
  11527. var value = element.attr(option);
  11528. if (value != null && value.length) {
  11529. options[option] = value;
  11530. }
  11531. });
  11532. return options;
  11533. },
  11534. _events: {
  11535. keydown: function(event) {
  11536. if (this._start(event) && this._keydown(event)) {
  11537. event.preventDefault();
  11538. }
  11539. },
  11540. keyup: "_stop",
  11541. focus: function() {
  11542. this.previous = this.element.val();
  11543. },
  11544. blur: function(event) {
  11545. this._stop();
  11546. this._refresh();
  11547. if (this.previous !== this.element.val()) {
  11548. this._trigger("change", event);
  11549. }
  11550. },
  11551. mousewheel: function(event, delta) {
  11552. var activeElement = this.document[0].activeElement;
  11553. var isActive = this.element[0] === activeElement;
  11554. if (!isActive || !delta) {
  11555. return;
  11556. }
  11557. if (!this.spinning && !this._start(event)) {
  11558. return false;
  11559. }
  11560. this._spin((delta > 0 ? 1 : -1) * this.options.step, event);
  11561. clearTimeout(this.mousewheelTimer);
  11562. this.mousewheelTimer = this._delay(function() {
  11563. if (this.spinning) {
  11564. this._stop(event);
  11565. }
  11566. }, 100);
  11567. event.preventDefault();
  11568. },
  11569. "mousedown .ui-spinner-button": function(event) {
  11570. var previous;
  11571. previous = this.element[0] === this.document[0].activeElement ? this.previous : this.element.val();
  11572. function checkFocus() {
  11573. var isActive = this.element[0] === this.document[0].activeElement;
  11574. if (!isActive) {
  11575. this.element.trigger("focus");
  11576. this.previous = previous;
  11577. }
  11578. }
  11579. event.preventDefault();
  11580. checkFocus.call(this);
  11581. if (this._start(event) === false) {
  11582. return;
  11583. }
  11584. this._repeat(null, $(event.currentTarget).hasClass("ui-spinner-up") ? 1 : -1, event);
  11585. },
  11586. "mouseup .ui-spinner-button": "_stop",
  11587. "mouseenter .ui-spinner-button": function(event) {
  11588. if (!$(event.currentTarget).hasClass("ui-state-active")) {
  11589. return;
  11590. }
  11591. if (this._start(event) === false) {
  11592. return false;
  11593. }
  11594. this._repeat(null, $(event.currentTarget).hasClass("ui-spinner-up") ? 1 : -1, event);
  11595. },
  11596. // TODO: do we really want to consider this a stop?
  11597. // shouldn't we just stop the repeater and wait until mouseup before
  11598. // we trigger the stop event?
  11599. "mouseleave .ui-spinner-button": "_stop"
  11600. },
  11601. // Support mobile enhanced option and make backcompat more sane
  11602. _enhance: function() {
  11603. this.uiSpinner = this.element.attr("autocomplete", "off").wrap("<span>").parent().append(
  11604. "<a></a><a></a>"
  11605. );
  11606. },
  11607. _draw: function() {
  11608. this._enhance();
  11609. this._addClass(this.uiSpinner, "ui-spinner", "ui-widget ui-widget-content");
  11610. this._addClass("ui-spinner-input");
  11611. this.element.attr("role", "spinbutton");
  11612. this.buttons = this.uiSpinner.children("a").attr("tabIndex", -1).attr("aria-hidden", true).button({
  11613. classes: {
  11614. "ui-button": ""
  11615. }
  11616. });
  11617. this._removeClass(this.buttons, "ui-corner-all");
  11618. this._addClass(this.buttons.first(), "ui-spinner-button ui-spinner-up");
  11619. this._addClass(this.buttons.last(), "ui-spinner-button ui-spinner-down");
  11620. this.buttons.first().button({
  11621. "icon": this.options.icons.up,
  11622. "showLabel": false
  11623. });
  11624. this.buttons.last().button({
  11625. "icon": this.options.icons.down,
  11626. "showLabel": false
  11627. });
  11628. if (this.buttons.height() > Math.ceil(this.uiSpinner.height() * 0.5) && this.uiSpinner.height() > 0) {
  11629. this.uiSpinner.height(this.uiSpinner.height());
  11630. }
  11631. },
  11632. _keydown: function(event) {
  11633. var options = this.options, keyCode = $.ui.keyCode;
  11634. switch (event.keyCode) {
  11635. case keyCode.UP:
  11636. this._repeat(null, 1, event);
  11637. return true;
  11638. case keyCode.DOWN:
  11639. this._repeat(null, -1, event);
  11640. return true;
  11641. case keyCode.PAGE_UP:
  11642. this._repeat(null, options.page, event);
  11643. return true;
  11644. case keyCode.PAGE_DOWN:
  11645. this._repeat(null, -options.page, event);
  11646. return true;
  11647. }
  11648. return false;
  11649. },
  11650. _start: function(event) {
  11651. if (!this.spinning && this._trigger("start", event) === false) {
  11652. return false;
  11653. }
  11654. if (!this.counter) {
  11655. this.counter = 1;
  11656. }
  11657. this.spinning = true;
  11658. return true;
  11659. },
  11660. _repeat: function(i, steps, event) {
  11661. i = i || 500;
  11662. clearTimeout(this.timer);
  11663. this.timer = this._delay(function() {
  11664. this._repeat(40, steps, event);
  11665. }, i);
  11666. this._spin(steps * this.options.step, event);
  11667. },
  11668. _spin: function(step, event) {
  11669. var value = this.value() || 0;
  11670. if (!this.counter) {
  11671. this.counter = 1;
  11672. }
  11673. value = this._adjustValue(value + step * this._increment(this.counter));
  11674. if (!this.spinning || this._trigger("spin", event, { value }) !== false) {
  11675. this._value(value);
  11676. this.counter++;
  11677. }
  11678. },
  11679. _increment: function(i) {
  11680. var incremental = this.options.incremental;
  11681. if (incremental) {
  11682. return typeof incremental === "function" ? incremental(i) : Math.floor(i * i * i / 5e4 - i * i / 500 + 17 * i / 200 + 1);
  11683. }
  11684. return 1;
  11685. },
  11686. _precision: function() {
  11687. var precision = this._precisionOf(this.options.step);
  11688. if (this.options.min !== null) {
  11689. precision = Math.max(precision, this._precisionOf(this.options.min));
  11690. }
  11691. return precision;
  11692. },
  11693. _precisionOf: function(num) {
  11694. var str = num.toString(), decimal = str.indexOf(".");
  11695. return decimal === -1 ? 0 : str.length - decimal - 1;
  11696. },
  11697. _adjustValue: function(value) {
  11698. var base, aboveMin, options = this.options;
  11699. base = options.min !== null ? options.min : 0;
  11700. aboveMin = value - base;
  11701. aboveMin = Math.round(aboveMin / options.step) * options.step;
  11702. value = base + aboveMin;
  11703. value = parseFloat(value.toFixed(this._precision()));
  11704. if (options.max !== null && value > options.max) {
  11705. return options.max;
  11706. }
  11707. if (options.min !== null && value < options.min) {
  11708. return options.min;
  11709. }
  11710. return value;
  11711. },
  11712. _stop: function(event) {
  11713. if (!this.spinning) {
  11714. return;
  11715. }
  11716. clearTimeout(this.timer);
  11717. clearTimeout(this.mousewheelTimer);
  11718. this.counter = 0;
  11719. this.spinning = false;
  11720. this._trigger("stop", event);
  11721. },
  11722. _setOption: function(key, value) {
  11723. var prevValue, first, last;
  11724. if (key === "culture" || key === "numberFormat") {
  11725. prevValue = this._parse(this.element.val());
  11726. this.options[key] = value;
  11727. this.element.val(this._format(prevValue));
  11728. return;
  11729. }
  11730. if (key === "max" || key === "min" || key === "step") {
  11731. if (typeof value === "string") {
  11732. value = this._parse(value);
  11733. }
  11734. }
  11735. if (key === "icons") {
  11736. first = this.buttons.first().find(".ui-icon");
  11737. this._removeClass(first, null, this.options.icons.up);
  11738. this._addClass(first, null, value.up);
  11739. last = this.buttons.last().find(".ui-icon");
  11740. this._removeClass(last, null, this.options.icons.down);
  11741. this._addClass(last, null, value.down);
  11742. }
  11743. this._super(key, value);
  11744. },
  11745. _setOptionDisabled: function(value) {
  11746. this._super(value);
  11747. this._toggleClass(this.uiSpinner, null, "ui-state-disabled", !!value);
  11748. this.element.prop("disabled", !!value);
  11749. this.buttons.button(value ? "disable" : "enable");
  11750. },
  11751. _setOptions: spinnerModifier(function(options) {
  11752. this._super(options);
  11753. }),
  11754. _parse: function(val) {
  11755. if (typeof val === "string" && val !== "") {
  11756. val = window.Globalize && this.options.numberFormat ? Globalize.parseFloat(val, 10, this.options.culture) : +val;
  11757. }
  11758. return val === "" || isNaN(val) ? null : val;
  11759. },
  11760. _format: function(value) {
  11761. if (value === "") {
  11762. return "";
  11763. }
  11764. return window.Globalize && this.options.numberFormat ? Globalize.format(value, this.options.numberFormat, this.options.culture) : value;
  11765. },
  11766. _refresh: function() {
  11767. this.element.attr({
  11768. "aria-valuemin": this.options.min,
  11769. "aria-valuemax": this.options.max,
  11770. // TODO: what should we do with values that can't be parsed?
  11771. "aria-valuenow": this._parse(this.element.val())
  11772. });
  11773. },
  11774. isValid: function() {
  11775. var value = this.value();
  11776. if (value === null) {
  11777. return false;
  11778. }
  11779. return value === this._adjustValue(value);
  11780. },
  11781. // Update the value without triggering change
  11782. _value: function(value, allowAny) {
  11783. var parsed;
  11784. if (value !== "") {
  11785. parsed = this._parse(value);
  11786. if (parsed !== null) {
  11787. if (!allowAny) {
  11788. parsed = this._adjustValue(parsed);
  11789. }
  11790. value = this._format(parsed);
  11791. }
  11792. }
  11793. this.element.val(value);
  11794. this._refresh();
  11795. },
  11796. _destroy: function() {
  11797. this.element.prop("disabled", false).removeAttr("autocomplete role aria-valuemin aria-valuemax aria-valuenow");
  11798. this.uiSpinner.replaceWith(this.element);
  11799. },
  11800. stepUp: spinnerModifier(function(steps) {
  11801. this._stepUp(steps);
  11802. }),
  11803. _stepUp: function(steps) {
  11804. if (this._start()) {
  11805. this._spin((steps || 1) * this.options.step);
  11806. this._stop();
  11807. }
  11808. },
  11809. stepDown: spinnerModifier(function(steps) {
  11810. this._stepDown(steps);
  11811. }),
  11812. _stepDown: function(steps) {
  11813. if (this._start()) {
  11814. this._spin((steps || 1) * -this.options.step);
  11815. this._stop();
  11816. }
  11817. },
  11818. pageUp: spinnerModifier(function(pages) {
  11819. this._stepUp((pages || 1) * this.options.page);
  11820. }),
  11821. pageDown: spinnerModifier(function(pages) {
  11822. this._stepDown((pages || 1) * this.options.page);
  11823. }),
  11824. value: function(newVal) {
  11825. if (!arguments.length) {
  11826. return this._parse(this.element.val());
  11827. }
  11828. spinnerModifier(this._value).call(this, newVal);
  11829. },
  11830. widget: function() {
  11831. return this.uiSpinner;
  11832. }
  11833. });
  11834. if ($.uiBackCompat === true) {
  11835. $.widget("ui.spinner", $.ui.spinner, {
  11836. _enhance: function() {
  11837. this.uiSpinner = this.element.attr("autocomplete", "off").wrap(this._uiSpinnerHtml()).parent().append(this._buttonHtml());
  11838. },
  11839. _uiSpinnerHtml: function() {
  11840. return "<span>";
  11841. },
  11842. _buttonHtml: function() {
  11843. return "<a></a><a></a>";
  11844. }
  11845. });
  11846. }
  11847. var widgetsSpinner = $.ui.spinner;
  11848. $.widget("ui.tabs", {
  11849. version: "1.14.1",
  11850. delay: 300,
  11851. options: {
  11852. active: null,
  11853. classes: {
  11854. "ui-tabs": "ui-corner-all",
  11855. "ui-tabs-nav": "ui-corner-all",
  11856. "ui-tabs-panel": "ui-corner-bottom",
  11857. "ui-tabs-tab": "ui-corner-top"
  11858. },
  11859. collapsible: false,
  11860. event: "click",
  11861. heightStyle: "content",
  11862. hide: null,
  11863. show: null,
  11864. // Callbacks
  11865. activate: null,
  11866. beforeActivate: null,
  11867. beforeLoad: null,
  11868. load: null
  11869. },
  11870. _isLocal: function() {
  11871. var rhash = /#.*$/;
  11872. return function(anchor) {
  11873. var anchorUrl, locationUrl;
  11874. anchorUrl = anchor.href.replace(rhash, "");
  11875. locationUrl = location.href.replace(rhash, "");
  11876. try {
  11877. anchorUrl = decodeURIComponent(anchorUrl);
  11878. } catch (error) {
  11879. }
  11880. try {
  11881. locationUrl = decodeURIComponent(locationUrl);
  11882. } catch (error) {
  11883. }
  11884. return anchor.hash.length > 1 && anchorUrl === locationUrl;
  11885. };
  11886. }(),
  11887. _create: function() {
  11888. var that = this, options = this.options;
  11889. this.running = false;
  11890. this._addClass("ui-tabs", "ui-widget ui-widget-content");
  11891. this._toggleClass("ui-tabs-collapsible", null, options.collapsible);
  11892. this._processTabs();
  11893. options.active = this._initialActive();
  11894. if (Array.isArray(options.disabled)) {
  11895. options.disabled = $.uniqueSort(options.disabled.concat(
  11896. $.map(this.tabs.filter(".ui-state-disabled"), function(li) {
  11897. return that.tabs.index(li);
  11898. })
  11899. )).sort();
  11900. }
  11901. if (this.options.active !== false && this.anchors.length) {
  11902. this.active = this._findActive(options.active);
  11903. } else {
  11904. this.active = $();
  11905. }
  11906. this._refresh();
  11907. if (this.active.length) {
  11908. this.load(options.active);
  11909. }
  11910. },
  11911. _initialActive: function() {
  11912. var active = this.options.active, collapsible = this.options.collapsible, locationHashDecoded = decodeURIComponent(location.hash.substring(1));
  11913. if (active === null) {
  11914. if (locationHashDecoded) {
  11915. this.tabs.each(function(i, tab) {
  11916. if ($(tab).attr("aria-controls") === locationHashDecoded) {
  11917. active = i;
  11918. return false;
  11919. }
  11920. });
  11921. }
  11922. if (active === null) {
  11923. active = this.tabs.index(this.tabs.filter(".ui-tabs-active"));
  11924. }
  11925. if (active === null || active === -1) {
  11926. active = this.tabs.length ? 0 : false;
  11927. }
  11928. }
  11929. if (active !== false) {
  11930. active = this.tabs.index(this.tabs.eq(active));
  11931. if (active === -1) {
  11932. active = collapsible ? false : 0;
  11933. }
  11934. }
  11935. if (!collapsible && active === false && this.anchors.length) {
  11936. active = 0;
  11937. }
  11938. return active;
  11939. },
  11940. _getCreateEventData: function() {
  11941. return {
  11942. tab: this.active,
  11943. panel: !this.active.length ? $() : this._getPanelForTab(this.active)
  11944. };
  11945. },
  11946. _tabKeydown: function(event) {
  11947. var focusedTab = $(this.document[0].activeElement).closest("li"), selectedIndex = this.tabs.index(focusedTab), goingForward = true;
  11948. if (this._handlePageNav(event)) {
  11949. return;
  11950. }
  11951. switch (event.keyCode) {
  11952. case $.ui.keyCode.RIGHT:
  11953. case $.ui.keyCode.DOWN:
  11954. selectedIndex++;
  11955. break;
  11956. case $.ui.keyCode.UP:
  11957. case $.ui.keyCode.LEFT:
  11958. goingForward = false;
  11959. selectedIndex--;
  11960. break;
  11961. case $.ui.keyCode.END:
  11962. selectedIndex = this.anchors.length - 1;
  11963. break;
  11964. case $.ui.keyCode.HOME:
  11965. selectedIndex = 0;
  11966. break;
  11967. case $.ui.keyCode.SPACE:
  11968. event.preventDefault();
  11969. clearTimeout(this.activating);
  11970. this._activate(selectedIndex);
  11971. return;
  11972. case $.ui.keyCode.ENTER:
  11973. event.preventDefault();
  11974. clearTimeout(this.activating);
  11975. this._activate(selectedIndex === this.options.active ? false : selectedIndex);
  11976. return;
  11977. default:
  11978. return;
  11979. }
  11980. event.preventDefault();
  11981. clearTimeout(this.activating);
  11982. selectedIndex = this._focusNextTab(selectedIndex, goingForward);
  11983. if (!event.ctrlKey && !event.metaKey) {
  11984. focusedTab.attr("aria-selected", "false");
  11985. this.tabs.eq(selectedIndex).attr("aria-selected", "true");
  11986. this.activating = this._delay(function() {
  11987. this.option("active", selectedIndex);
  11988. }, this.delay);
  11989. }
  11990. },
  11991. _panelKeydown: function(event) {
  11992. if (this._handlePageNav(event)) {
  11993. return;
  11994. }
  11995. if (event.ctrlKey && event.keyCode === $.ui.keyCode.UP) {
  11996. event.preventDefault();
  11997. this.active.trigger("focus");
  11998. }
  11999. },
  12000. // Alt+page up/down moves focus to the previous/next tab (and activates)
  12001. _handlePageNav: function(event) {
  12002. if (event.altKey && event.keyCode === $.ui.keyCode.PAGE_UP) {
  12003. this._activate(this._focusNextTab(this.options.active - 1, false));
  12004. return true;
  12005. }
  12006. if (event.altKey && event.keyCode === $.ui.keyCode.PAGE_DOWN) {
  12007. this._activate(this._focusNextTab(this.options.active + 1, true));
  12008. return true;
  12009. }
  12010. },
  12011. _findNextTab: function(index, goingForward) {
  12012. var lastTabIndex = this.tabs.length - 1;
  12013. function constrain() {
  12014. if (index > lastTabIndex) {
  12015. index = 0;
  12016. }
  12017. if (index < 0) {
  12018. index = lastTabIndex;
  12019. }
  12020. return index;
  12021. }
  12022. while ($.inArray(constrain(), this.options.disabled) !== -1) {
  12023. index = goingForward ? index + 1 : index - 1;
  12024. }
  12025. return index;
  12026. },
  12027. _focusNextTab: function(index, goingForward) {
  12028. index = this._findNextTab(index, goingForward);
  12029. this.tabs.eq(index).trigger("focus");
  12030. return index;
  12031. },
  12032. _setOption: function(key, value) {
  12033. if (key === "active") {
  12034. this._activate(value);
  12035. return;
  12036. }
  12037. this._super(key, value);
  12038. if (key === "collapsible") {
  12039. this._toggleClass("ui-tabs-collapsible", null, value);
  12040. if (!value && this.options.active === false) {
  12041. this._activate(0);
  12042. }
  12043. }
  12044. if (key === "event") {
  12045. this._setupEvents(value);
  12046. }
  12047. if (key === "heightStyle") {
  12048. this._setupHeightStyle(value);
  12049. }
  12050. },
  12051. refresh: function() {
  12052. var options = this.options, lis = this.tablist.children(":has(a[href])");
  12053. options.disabled = $.map(lis.filter(".ui-state-disabled"), function(tab) {
  12054. return lis.index(tab);
  12055. });
  12056. this._processTabs();
  12057. if (options.active === false || !this.anchors.length) {
  12058. options.active = false;
  12059. this.active = $();
  12060. } else if (this.active.length && !$.contains(this.tablist[0], this.active[0])) {
  12061. if (this.tabs.length === options.disabled.length) {
  12062. options.active = false;
  12063. this.active = $();
  12064. } else {
  12065. this._activate(this._findNextTab(Math.max(0, options.active - 1), false));
  12066. }
  12067. } else {
  12068. options.active = this.tabs.index(this.active);
  12069. }
  12070. this._refresh();
  12071. },
  12072. _refresh: function() {
  12073. this._setOptionDisabled(this.options.disabled);
  12074. this._setupEvents(this.options.event);
  12075. this._setupHeightStyle(this.options.heightStyle);
  12076. this.tabs.not(this.active).attr({
  12077. "aria-selected": "false",
  12078. "aria-expanded": "false",
  12079. tabIndex: -1
  12080. });
  12081. this.panels.not(this._getPanelForTab(this.active)).hide().attr({
  12082. "aria-hidden": "true"
  12083. });
  12084. if (!this.active.length) {
  12085. this.tabs.eq(0).attr("tabIndex", 0);
  12086. } else {
  12087. this.active.attr({
  12088. "aria-selected": "true",
  12089. "aria-expanded": "true",
  12090. tabIndex: 0
  12091. });
  12092. this._addClass(this.active, "ui-tabs-active", "ui-state-active");
  12093. this._getPanelForTab(this.active).show().attr({
  12094. "aria-hidden": "false"
  12095. });
  12096. }
  12097. },
  12098. _processTabs: function() {
  12099. var that = this, prevTabs = this.tabs, prevAnchors = this.anchors, prevPanels = this.panels;
  12100. this.tablist = this._getList().attr("role", "tablist");
  12101. this._addClass(
  12102. this.tablist,
  12103. "ui-tabs-nav",
  12104. "ui-helper-reset ui-helper-clearfix ui-widget-header"
  12105. );
  12106. this.tablist.on("mousedown" + this.eventNamespace, "> li", function(event) {
  12107. if ($(this).is(".ui-state-disabled")) {
  12108. event.preventDefault();
  12109. }
  12110. });
  12111. this.tabs = this.tablist.find("> li:has(a[href])").attr({
  12112. role: "tab",
  12113. tabIndex: -1
  12114. });
  12115. this._addClass(this.tabs, "ui-tabs-tab", "ui-state-default");
  12116. this.anchors = this.tabs.map(function() {
  12117. return $("a", this)[0];
  12118. }).attr({
  12119. tabIndex: -1
  12120. });
  12121. this._addClass(this.anchors, "ui-tabs-anchor");
  12122. this.panels = $();
  12123. this.anchors.each(function(i, anchor) {
  12124. var selector, panel, panelId, anchorId = $(anchor).uniqueId().attr("id"), tab = $(anchor).closest("li"), originalAriaControls = tab.attr("aria-controls");
  12125. if (that._isLocal(anchor)) {
  12126. selector = decodeURIComponent(anchor.hash);
  12127. panelId = selector.substring(1);
  12128. panel = that.element.find("#" + CSS.escape(panelId));
  12129. } else {
  12130. panelId = tab.attr("aria-controls") || $({}).uniqueId()[0].id;
  12131. selector = "#" + panelId;
  12132. panel = that.element.find(selector);
  12133. if (!panel.length) {
  12134. panel = that._createPanel(panelId);
  12135. panel.insertAfter(that.panels[i - 1] || that.tablist);
  12136. }
  12137. panel.attr("aria-live", "polite");
  12138. }
  12139. if (panel.length) {
  12140. that.panels = that.panels.add(panel);
  12141. }
  12142. if (originalAriaControls) {
  12143. tab.data("ui-tabs-aria-controls", originalAriaControls);
  12144. }
  12145. tab.attr({
  12146. "aria-controls": panelId,
  12147. "aria-labelledby": anchorId
  12148. });
  12149. panel.attr("aria-labelledby", anchorId);
  12150. });
  12151. this.panels.attr("role", "tabpanel");
  12152. this._addClass(this.panels, "ui-tabs-panel", "ui-widget-content");
  12153. if (prevTabs) {
  12154. this._off(prevTabs.not(this.tabs));
  12155. this._off(prevAnchors.not(this.anchors));
  12156. this._off(prevPanels.not(this.panels));
  12157. }
  12158. },
  12159. // Allow overriding how to find the list for rare usage scenarios (#7715)
  12160. _getList: function() {
  12161. return this.tablist || this.element.find("ol, ul").eq(0);
  12162. },
  12163. _createPanel: function(id) {
  12164. return $("<div>").attr("id", id).data("ui-tabs-destroy", true);
  12165. },
  12166. _setOptionDisabled: function(disabled) {
  12167. var currentItem, li, i;
  12168. if (Array.isArray(disabled)) {
  12169. if (!disabled.length) {
  12170. disabled = false;
  12171. } else if (disabled.length === this.anchors.length) {
  12172. disabled = true;
  12173. }
  12174. }
  12175. for (i = 0; li = this.tabs[i]; i++) {
  12176. currentItem = $(li);
  12177. if (disabled === true || $.inArray(i, disabled) !== -1) {
  12178. currentItem.attr("aria-disabled", "true");
  12179. this._addClass(currentItem, null, "ui-state-disabled");
  12180. } else {
  12181. currentItem.removeAttr("aria-disabled");
  12182. this._removeClass(currentItem, null, "ui-state-disabled");
  12183. }
  12184. }
  12185. this.options.disabled = disabled;
  12186. this._toggleClass(
  12187. this.widget(),
  12188. this.widgetFullName + "-disabled",
  12189. null,
  12190. disabled === true
  12191. );
  12192. },
  12193. _setupEvents: function(event) {
  12194. var events = {};
  12195. if (event) {
  12196. $.each(event.split(" "), function(index, eventName) {
  12197. events[eventName] = "_eventHandler";
  12198. });
  12199. }
  12200. this._off(this.anchors.add(this.tabs).add(this.panels));
  12201. this._on(true, this.anchors, {
  12202. click: function(event2) {
  12203. event2.preventDefault();
  12204. }
  12205. });
  12206. this._on(this.anchors, events);
  12207. this._on(this.tabs, { keydown: "_tabKeydown" });
  12208. this._on(this.panels, { keydown: "_panelKeydown" });
  12209. this._focusable(this.tabs);
  12210. this._hoverable(this.tabs);
  12211. },
  12212. _setupHeightStyle: function(heightStyle) {
  12213. var maxHeight, parent = this.element.parent();
  12214. if (heightStyle === "fill") {
  12215. maxHeight = parent.height();
  12216. maxHeight -= this.element.outerHeight() - this.element.height();
  12217. this.element.siblings(":visible").each(function() {
  12218. var elem = $(this), position2 = elem.css("position");
  12219. if (position2 === "absolute" || position2 === "fixed") {
  12220. return;
  12221. }
  12222. maxHeight -= elem.outerHeight(true);
  12223. });
  12224. this.element.children().not(this.panels).each(function() {
  12225. maxHeight -= $(this).outerHeight(true);
  12226. });
  12227. this.panels.each(function() {
  12228. $(this).height(Math.max(0, maxHeight - $(this).innerHeight() + $(this).height()));
  12229. }).css("overflow", "auto");
  12230. } else if (heightStyle === "auto") {
  12231. maxHeight = 0;
  12232. this.panels.each(function() {
  12233. maxHeight = Math.max(maxHeight, $(this).height("").height());
  12234. }).height(maxHeight);
  12235. }
  12236. },
  12237. _eventHandler: function(event) {
  12238. var options = this.options, active = this.active, anchor = $(event.currentTarget), tab = anchor.closest("li"), clickedIsActive = tab[0] === active[0], collapsing = clickedIsActive && options.collapsible, toShow = collapsing ? $() : this._getPanelForTab(tab), toHide = !active.length ? $() : this._getPanelForTab(active), eventData = {
  12239. oldTab: active,
  12240. oldPanel: toHide,
  12241. newTab: collapsing ? $() : tab,
  12242. newPanel: toShow
  12243. };
  12244. event.preventDefault();
  12245. if (tab.hasClass("ui-state-disabled") || // tab is already loading
  12246. tab.hasClass("ui-tabs-loading") || // can't switch durning an animation
  12247. this.running || // click on active header, but not collapsible
  12248. clickedIsActive && !options.collapsible || // allow canceling activation
  12249. this._trigger("beforeActivate", event, eventData) === false) {
  12250. return;
  12251. }
  12252. options.active = collapsing ? false : this.tabs.index(tab);
  12253. this.active = clickedIsActive ? $() : tab;
  12254. if (this.xhr) {
  12255. this.xhr.abort();
  12256. }
  12257. if (!toHide.length && !toShow.length) {
  12258. $.error("jQuery UI Tabs: Mismatching fragment identifier.");
  12259. }
  12260. if (toShow.length) {
  12261. this.load(this.tabs.index(tab), event);
  12262. }
  12263. this._toggle(event, eventData);
  12264. },
  12265. // Handles show/hide for selecting tabs
  12266. _toggle: function(event, eventData) {
  12267. var that = this, toShow = eventData.newPanel, toHide = eventData.oldPanel;
  12268. this.running = true;
  12269. function complete() {
  12270. that.running = false;
  12271. that._trigger("activate", event, eventData);
  12272. }
  12273. function show() {
  12274. that._addClass(eventData.newTab.closest("li"), "ui-tabs-active", "ui-state-active");
  12275. if (toShow.length && that.options.show) {
  12276. that._show(toShow, that.options.show, complete);
  12277. } else {
  12278. toShow.show();
  12279. complete();
  12280. }
  12281. }
  12282. if (toHide.length && this.options.hide) {
  12283. this._hide(toHide, this.options.hide, function() {
  12284. that._removeClass(
  12285. eventData.oldTab.closest("li"),
  12286. "ui-tabs-active",
  12287. "ui-state-active"
  12288. );
  12289. show();
  12290. });
  12291. } else {
  12292. this._removeClass(
  12293. eventData.oldTab.closest("li"),
  12294. "ui-tabs-active",
  12295. "ui-state-active"
  12296. );
  12297. toHide.hide();
  12298. show();
  12299. }
  12300. toHide.attr("aria-hidden", "true");
  12301. eventData.oldTab.attr({
  12302. "aria-selected": "false",
  12303. "aria-expanded": "false"
  12304. });
  12305. if (toShow.length && toHide.length) {
  12306. eventData.oldTab.attr("tabIndex", -1);
  12307. } else if (toShow.length) {
  12308. this.tabs.filter(function() {
  12309. return $(this).attr("tabIndex") === 0;
  12310. }).attr("tabIndex", -1);
  12311. }
  12312. toShow.attr("aria-hidden", "false");
  12313. eventData.newTab.attr({
  12314. "aria-selected": "true",
  12315. "aria-expanded": "true",
  12316. tabIndex: 0
  12317. });
  12318. },
  12319. _activate: function(index) {
  12320. var anchor, active = this._findActive(index);
  12321. if (active[0] === this.active[0]) {
  12322. return;
  12323. }
  12324. if (!active.length) {
  12325. active = this.active;
  12326. }
  12327. anchor = active.find(".ui-tabs-anchor")[0];
  12328. this._eventHandler({
  12329. target: anchor,
  12330. currentTarget: anchor,
  12331. preventDefault: $.noop
  12332. });
  12333. },
  12334. _findActive: function(index) {
  12335. return index === false ? $() : this.tabs.eq(index);
  12336. },
  12337. _getIndex: function(index) {
  12338. if (typeof index === "string") {
  12339. index = this.anchors.index(this.anchors.filter("[href$='" + CSS.escape(index) + "']"));
  12340. }
  12341. return index;
  12342. },
  12343. _destroy: function() {
  12344. if (this.xhr) {
  12345. this.xhr.abort();
  12346. }
  12347. this.tablist.removeAttr("role").off(this.eventNamespace);
  12348. this.anchors.removeAttr("role tabIndex").removeUniqueId();
  12349. this.tabs.add(this.panels).each(function() {
  12350. if ($.data(this, "ui-tabs-destroy")) {
  12351. $(this).remove();
  12352. } else {
  12353. $(this).removeAttr("role tabIndex aria-live aria-busy aria-selected aria-labelledby aria-hidden aria-expanded");
  12354. }
  12355. });
  12356. this.tabs.each(function() {
  12357. var li = $(this), prev = li.data("ui-tabs-aria-controls");
  12358. if (prev) {
  12359. li.attr("aria-controls", prev).removeData("ui-tabs-aria-controls");
  12360. } else {
  12361. li.removeAttr("aria-controls");
  12362. }
  12363. });
  12364. this.panels.show();
  12365. if (this.options.heightStyle !== "content") {
  12366. this.panels.css("height", "");
  12367. }
  12368. },
  12369. enable: function(index) {
  12370. var disabled = this.options.disabled;
  12371. if (disabled === false) {
  12372. return;
  12373. }
  12374. if (index === void 0) {
  12375. disabled = false;
  12376. } else {
  12377. index = this._getIndex(index);
  12378. if (Array.isArray(disabled)) {
  12379. disabled = $.map(disabled, function(num) {
  12380. return num !== index ? num : null;
  12381. });
  12382. } else {
  12383. disabled = $.map(this.tabs, function(li, num) {
  12384. return num !== index ? num : null;
  12385. });
  12386. }
  12387. }
  12388. this._setOptionDisabled(disabled);
  12389. },
  12390. disable: function(index) {
  12391. var disabled = this.options.disabled;
  12392. if (disabled === true) {
  12393. return;
  12394. }
  12395. if (index === void 0) {
  12396. disabled = true;
  12397. } else {
  12398. index = this._getIndex(index);
  12399. if ($.inArray(index, disabled) !== -1) {
  12400. return;
  12401. }
  12402. if (Array.isArray(disabled)) {
  12403. disabled = $.merge([index], disabled).sort();
  12404. } else {
  12405. disabled = [index];
  12406. }
  12407. }
  12408. this._setOptionDisabled(disabled);
  12409. },
  12410. load: function(index, event) {
  12411. index = this._getIndex(index);
  12412. var that = this, tab = this.tabs.eq(index), anchor = tab.find(".ui-tabs-anchor"), panel = this._getPanelForTab(tab), eventData = {
  12413. tab,
  12414. panel
  12415. }, complete = function(jqXHR, status) {
  12416. if (status === "abort") {
  12417. that.panels.stop(false, true);
  12418. }
  12419. that._removeClass(tab, "ui-tabs-loading");
  12420. panel.removeAttr("aria-busy");
  12421. if (jqXHR === that.xhr) {
  12422. delete that.xhr;
  12423. }
  12424. };
  12425. if (this._isLocal(anchor[0])) {
  12426. return;
  12427. }
  12428. this.xhr = $.ajax(this._ajaxSettings(anchor, event, eventData));
  12429. if (this.xhr.statusText !== "canceled") {
  12430. this._addClass(tab, "ui-tabs-loading");
  12431. panel.attr("aria-busy", "true");
  12432. this.xhr.done(function(response, status, jqXHR) {
  12433. panel.html(response);
  12434. that._trigger("load", event, eventData);
  12435. complete(jqXHR, status);
  12436. }).fail(function(jqXHR, status) {
  12437. complete(jqXHR, status);
  12438. });
  12439. }
  12440. },
  12441. _ajaxSettings: function(anchor, event, eventData) {
  12442. var that = this;
  12443. return {
  12444. url: anchor.attr("href"),
  12445. beforeSend: function(jqXHR, settings) {
  12446. return that._trigger(
  12447. "beforeLoad",
  12448. event,
  12449. $.extend({ jqXHR, ajaxSettings: settings }, eventData)
  12450. );
  12451. }
  12452. };
  12453. },
  12454. _getPanelForTab: function(tab) {
  12455. var id = $(tab).attr("aria-controls");
  12456. return this.element.find("#" + CSS.escape(id));
  12457. }
  12458. });
  12459. if ($.uiBackCompat === true) {
  12460. $.widget("ui.tabs", $.ui.tabs, {
  12461. _processTabs: function() {
  12462. this._superApply(arguments);
  12463. this._addClass(this.tabs, "ui-tab");
  12464. }
  12465. });
  12466. }
  12467. var widgetsTabs = $.ui.tabs;
  12468. $.widget("ui.tooltip", {
  12469. version: "1.14.1",
  12470. options: {
  12471. classes: {
  12472. "ui-tooltip": "ui-corner-all ui-widget-shadow"
  12473. },
  12474. content: function() {
  12475. var title = $(this).attr("title");
  12476. return $("<a>").text(title).html();
  12477. },
  12478. hide: true,
  12479. // Disabled elements have inconsistent behavior across browsers (#8661)
  12480. items: "[title]:not([disabled])",
  12481. position: {
  12482. my: "left top+15",
  12483. at: "left bottom",
  12484. collision: "flipfit flip"
  12485. },
  12486. show: true,
  12487. track: false,
  12488. // Callbacks
  12489. close: null,
  12490. open: null
  12491. },
  12492. _addDescribedBy: function(elem, id) {
  12493. var describedby = (elem.attr("aria-describedby") || "").split(/\s+/);
  12494. describedby.push(id);
  12495. elem.data("ui-tooltip-id", id).attr("aria-describedby", String.prototype.trim.call(describedby.join(" ")));
  12496. },
  12497. _removeDescribedBy: function(elem) {
  12498. var id = elem.data("ui-tooltip-id"), describedby = (elem.attr("aria-describedby") || "").split(/\s+/), index = $.inArray(id, describedby);
  12499. if (index !== -1) {
  12500. describedby.splice(index, 1);
  12501. }
  12502. elem.removeData("ui-tooltip-id");
  12503. describedby = String.prototype.trim.call(describedby.join(" "));
  12504. if (describedby) {
  12505. elem.attr("aria-describedby", describedby);
  12506. } else {
  12507. elem.removeAttr("aria-describedby");
  12508. }
  12509. },
  12510. _create: function() {
  12511. this._on({
  12512. mouseover: "open",
  12513. focusin: "open"
  12514. });
  12515. this.tooltips = {};
  12516. this.parents = {};
  12517. this.liveRegion = $("<div>").attr({
  12518. role: "log",
  12519. "aria-live": "assertive",
  12520. "aria-relevant": "additions"
  12521. }).appendTo(this.document[0].body);
  12522. this._addClass(this.liveRegion, null, "ui-helper-hidden-accessible");
  12523. this.disabledTitles = $([]);
  12524. },
  12525. _setOption: function(key, value) {
  12526. var that = this;
  12527. this._super(key, value);
  12528. if (key === "content") {
  12529. $.each(this.tooltips, function(id, tooltipData) {
  12530. that._updateContent(tooltipData.element);
  12531. });
  12532. }
  12533. },
  12534. _setOptionDisabled: function(value) {
  12535. this[value ? "_disable" : "_enable"]();
  12536. },
  12537. _disable: function() {
  12538. var that = this;
  12539. $.each(this.tooltips, function(id, tooltipData) {
  12540. var event = $.Event("blur");
  12541. event.target = event.currentTarget = tooltipData.element[0];
  12542. that.close(event, true);
  12543. });
  12544. this.disabledTitles = this.disabledTitles.add(
  12545. this.element.find(this.options.items).addBack().filter(function() {
  12546. var element = $(this);
  12547. if (element.is("[title]")) {
  12548. return element.data("ui-tooltip-title", element.attr("title")).removeAttr("title");
  12549. }
  12550. })
  12551. );
  12552. },
  12553. _enable: function() {
  12554. this.disabledTitles.each(function() {
  12555. var element = $(this);
  12556. if (element.data("ui-tooltip-title")) {
  12557. element.attr("title", element.data("ui-tooltip-title"));
  12558. }
  12559. });
  12560. this.disabledTitles = $([]);
  12561. },
  12562. open: function(event) {
  12563. var that = this, target = $(event ? event.target : this.element).closest(this.options.items);
  12564. if (!target.length || target.data("ui-tooltip-id")) {
  12565. return;
  12566. }
  12567. if (target.attr("title")) {
  12568. target.data("ui-tooltip-title", target.attr("title"));
  12569. }
  12570. target.data("ui-tooltip-open", true);
  12571. if (event && event.type === "mouseover") {
  12572. target.parents().each(function() {
  12573. var parent = $(this), blurEvent;
  12574. if (parent.data("ui-tooltip-open")) {
  12575. blurEvent = $.Event("blur");
  12576. blurEvent.target = blurEvent.currentTarget = this;
  12577. that.close(blurEvent, true);
  12578. }
  12579. if (parent.attr("title")) {
  12580. parent.uniqueId();
  12581. that.parents[this.id] = {
  12582. element: this,
  12583. title: parent.attr("title")
  12584. };
  12585. parent.attr("title", "");
  12586. }
  12587. });
  12588. }
  12589. this._registerCloseHandlers(event, target);
  12590. this._updateContent(target, event);
  12591. },
  12592. _updateContent: function(target, event) {
  12593. var content, contentOption = this.options.content, that = this, eventType = event ? event.type : null;
  12594. if (typeof contentOption === "string" || contentOption.nodeType || contentOption.jquery) {
  12595. return this._open(event, target, contentOption);
  12596. }
  12597. content = contentOption.call(target[0], function(response) {
  12598. if (!target.data("ui-tooltip-open")) {
  12599. return;
  12600. }
  12601. if (event) {
  12602. event.type = eventType;
  12603. }
  12604. that._open(event, target, response);
  12605. });
  12606. if (content) {
  12607. this._open(event, target, content);
  12608. }
  12609. },
  12610. _open: function(event, target, content) {
  12611. var tooltipData, tooltip, delayedShow, a11yContent, positionOption = $.extend({}, this.options.position);
  12612. if (!content) {
  12613. return;
  12614. }
  12615. tooltipData = this._find(target);
  12616. if (tooltipData) {
  12617. tooltipData.tooltip.find(".ui-tooltip-content").html(content);
  12618. return;
  12619. }
  12620. if (target.is("[title]")) {
  12621. if (event && event.type === "mouseover") {
  12622. target.attr("title", "");
  12623. } else {
  12624. target.removeAttr("title");
  12625. }
  12626. }
  12627. tooltipData = this._tooltip(target);
  12628. tooltip = tooltipData.tooltip;
  12629. this._addDescribedBy(target, tooltip.attr("id"));
  12630. tooltip.find(".ui-tooltip-content").html(content);
  12631. this.liveRegion.children().hide();
  12632. a11yContent = $("<div>").html(tooltip.find(".ui-tooltip-content").html());
  12633. a11yContent.removeAttr("name").find("[name]").removeAttr("name");
  12634. a11yContent.removeAttr("id").find("[id]").removeAttr("id");
  12635. a11yContent.appendTo(this.liveRegion);
  12636. function position2(event2) {
  12637. positionOption.of = event2;
  12638. if (tooltip.is(":hidden")) {
  12639. return;
  12640. }
  12641. tooltip.position(positionOption);
  12642. }
  12643. if (this.options.track && event && /^mouse/.test(event.type)) {
  12644. this._on(this.document, {
  12645. mousemove: position2
  12646. });
  12647. position2(event);
  12648. } else {
  12649. tooltip.position($.extend({
  12650. of: target
  12651. }, this.options.position));
  12652. }
  12653. tooltip.hide();
  12654. this._show(tooltip, this.options.show);
  12655. if (this.options.track && this.options.show && this.options.show.delay) {
  12656. delayedShow = this.delayedShow = setInterval(function() {
  12657. if (tooltip.is(":visible")) {
  12658. position2(positionOption.of);
  12659. clearInterval(delayedShow);
  12660. }
  12661. }, 13);
  12662. }
  12663. this._trigger("open", event, { tooltip });
  12664. },
  12665. _registerCloseHandlers: function(event, target) {
  12666. var events = {
  12667. keyup: function(event2) {
  12668. if (event2.keyCode === $.ui.keyCode.ESCAPE) {
  12669. var fakeEvent = $.Event(event2);
  12670. fakeEvent.currentTarget = target[0];
  12671. this.close(fakeEvent, true);
  12672. }
  12673. }
  12674. };
  12675. if (target[0] !== this.element[0]) {
  12676. events.remove = function() {
  12677. var targetElement = this._find(target);
  12678. if (targetElement) {
  12679. this._removeTooltip(targetElement.tooltip);
  12680. }
  12681. };
  12682. }
  12683. if (!event || event.type === "mouseover") {
  12684. events.mouseleave = "close";
  12685. }
  12686. if (!event || event.type === "focusin") {
  12687. events.focusout = "close";
  12688. }
  12689. this._on(true, target, events);
  12690. },
  12691. close: function(event) {
  12692. var tooltip, that = this, target = $(event ? event.currentTarget : this.element), tooltipData = this._find(target);
  12693. if (!tooltipData) {
  12694. target.removeData("ui-tooltip-open");
  12695. return;
  12696. }
  12697. tooltip = tooltipData.tooltip;
  12698. if (tooltipData.closing) {
  12699. return;
  12700. }
  12701. clearInterval(this.delayedShow);
  12702. if (target.data("ui-tooltip-title") && !target.attr("title")) {
  12703. target.attr("title", target.data("ui-tooltip-title"));
  12704. }
  12705. this._removeDescribedBy(target);
  12706. tooltipData.hiding = true;
  12707. tooltip.stop(true);
  12708. this._hide(tooltip, this.options.hide, function() {
  12709. that._removeTooltip($(this));
  12710. });
  12711. target.removeData("ui-tooltip-open");
  12712. this._off(target, "mouseleave focusout keyup");
  12713. if (target[0] !== this.element[0]) {
  12714. this._off(target, "remove");
  12715. }
  12716. this._off(this.document, "mousemove");
  12717. if (event && event.type === "mouseleave") {
  12718. $.each(this.parents, function(id, parent) {
  12719. $(parent.element).attr("title", parent.title);
  12720. delete that.parents[id];
  12721. });
  12722. }
  12723. tooltipData.closing = true;
  12724. this._trigger("close", event, { tooltip });
  12725. if (!tooltipData.hiding) {
  12726. tooltipData.closing = false;
  12727. }
  12728. },
  12729. _tooltip: function(element) {
  12730. var tooltip = $("<div>").attr("role", "tooltip"), content = $("<div>").appendTo(tooltip), id = tooltip.uniqueId().attr("id");
  12731. this._addClass(content, "ui-tooltip-content");
  12732. this._addClass(tooltip, "ui-tooltip", "ui-widget ui-widget-content");
  12733. tooltip.appendTo(this._appendTo(element));
  12734. return this.tooltips[id] = {
  12735. element,
  12736. tooltip
  12737. };
  12738. },
  12739. _find: function(target) {
  12740. var id = target.data("ui-tooltip-id");
  12741. return id ? this.tooltips[id] : null;
  12742. },
  12743. _removeTooltip: function(tooltip) {
  12744. clearInterval(this.delayedShow);
  12745. tooltip.remove();
  12746. delete this.tooltips[tooltip.attr("id")];
  12747. },
  12748. _appendTo: function(target) {
  12749. var element = target.closest(".ui-front, dialog");
  12750. if (!element.length) {
  12751. element = this.document[0].body;
  12752. }
  12753. return element;
  12754. },
  12755. _destroy: function() {
  12756. var that = this;
  12757. $.each(this.tooltips, function(id, tooltipData) {
  12758. var event = $.Event("blur"), element = tooltipData.element;
  12759. event.target = event.currentTarget = element[0];
  12760. that.close(event, true);
  12761. $("#" + id).remove();
  12762. if (element.data("ui-tooltip-title")) {
  12763. if (!element.attr("title")) {
  12764. element.attr("title", element.data("ui-tooltip-title"));
  12765. }
  12766. element.removeData("ui-tooltip-title");
  12767. }
  12768. });
  12769. this.liveRegion.remove();
  12770. }
  12771. });
  12772. if ($.uiBackCompat === true) {
  12773. $.widget("ui.tooltip", $.ui.tooltip, {
  12774. options: {
  12775. tooltipClass: null
  12776. },
  12777. _tooltip: function() {
  12778. var tooltipData = this._superApply(arguments);
  12779. if (this.options.tooltipClass) {
  12780. tooltipData.tooltip.addClass(this.options.tooltipClass);
  12781. }
  12782. return tooltipData;
  12783. }
  12784. });
  12785. }
  12786. var widgetsTooltip = $.ui.tooltip;
  12787. });
  12788. /*! Bundled license information:
  12789. jquery-ui/dist/jquery-ui.js:
  12790. (*! jQuery UI - v1.14.1 - 2024-10-30
  12791. * https://jqueryui.com
  12792. * Includes: widget.js, position.js, data.js, disable-selection.js, effect.js, effects/effect-blind.js, effects/effect-bounce.js, effects/effect-clip.js, effects/effect-drop.js, effects/effect-explode.js, effects/effect-fade.js, effects/effect-fold.js, effects/effect-highlight.js, effects/effect-puff.js, effects/effect-pulsate.js, effects/effect-scale.js, effects/effect-shake.js, effects/effect-size.js, effects/effect-slide.js, effects/effect-transfer.js, focusable.js, form-reset-mixin.js, jquery-patch.js, keycode.js, labels.js, scroll-parent.js, tabbable.js, unique-id.js, widgets/accordion.js, widgets/autocomplete.js, widgets/button.js, widgets/checkboxradio.js, widgets/controlgroup.js, widgets/datepicker.js, widgets/dialog.js, widgets/draggable.js, widgets/droppable.js, widgets/menu.js, widgets/mouse.js, widgets/progressbar.js, widgets/resizable.js, widgets/selectable.js, widgets/selectmenu.js, widgets/slider.js, widgets/sortable.js, widgets/spinner.js, widgets/tabs.js, widgets/tooltip.js
  12793. * Copyright OpenJS Foundation and other contributors; Licensed MIT *)
  12794. (*!
  12795. * jQuery UI Widget 1.14.1
  12796. * https://jqueryui.com
  12797. *
  12798. * Copyright OpenJS Foundation and other contributors
  12799. * Released under the MIT license.
  12800. * https://jquery.org/license
  12801. *)
  12802. (*!
  12803. * jQuery UI Position 1.14.1
  12804. * https://jqueryui.com
  12805. *
  12806. * Copyright OpenJS Foundation and other contributors
  12807. * Released under the MIT license.
  12808. * https://jquery.org/license
  12809. *
  12810. * https://api.jqueryui.com/position/
  12811. *)
  12812. (*!
  12813. * jQuery UI :data 1.14.1
  12814. * https://jqueryui.com
  12815. *
  12816. * Copyright OpenJS Foundation and other contributors
  12817. * Released under the MIT license.
  12818. * https://jquery.org/license
  12819. *)
  12820. (*!
  12821. * jQuery UI Disable Selection 1.14.1
  12822. * https://jqueryui.com
  12823. *
  12824. * Copyright OpenJS Foundation and other contributors
  12825. * Released under the MIT license.
  12826. * https://jquery.org/license
  12827. *)
  12828. (*!
  12829. * jQuery Color Animations v3.0.0
  12830. * https://github.com/jquery/jquery-color
  12831. *
  12832. * Copyright OpenJS Foundation and other contributors
  12833. * Released under the MIT license.
  12834. * https://jquery.org/license
  12835. *
  12836. * Date: Wed May 15 16:49:44 2024 +0200
  12837. *)
  12838. (*!
  12839. * jQuery UI Effects 1.14.1
  12840. * https://jqueryui.com
  12841. *
  12842. * Copyright OpenJS Foundation and other contributors
  12843. * Released under the MIT license.
  12844. * https://jquery.org/license
  12845. *)
  12846. (*!
  12847. * jQuery UI Effects Blind 1.14.1
  12848. * https://jqueryui.com
  12849. *
  12850. * Copyright OpenJS Foundation and other contributors
  12851. * Released under the MIT license.
  12852. * https://jquery.org/license
  12853. *)
  12854. (*!
  12855. * jQuery UI Effects Bounce 1.14.1
  12856. * https://jqueryui.com
  12857. *
  12858. * Copyright OpenJS Foundation and other contributors
  12859. * Released under the MIT license.
  12860. * https://jquery.org/license
  12861. *)
  12862. (*!
  12863. * jQuery UI Effects Clip 1.14.1
  12864. * https://jqueryui.com
  12865. *
  12866. * Copyright OpenJS Foundation and other contributors
  12867. * Released under the MIT license.
  12868. * https://jquery.org/license
  12869. *)
  12870. (*!
  12871. * jQuery UI Effects Drop 1.14.1
  12872. * https://jqueryui.com
  12873. *
  12874. * Copyright OpenJS Foundation and other contributors
  12875. * Released under the MIT license.
  12876. * https://jquery.org/license
  12877. *)
  12878. (*!
  12879. * jQuery UI Effects Explode 1.14.1
  12880. * https://jqueryui.com
  12881. *
  12882. * Copyright OpenJS Foundation and other contributors
  12883. * Released under the MIT license.
  12884. * https://jquery.org/license
  12885. *)
  12886. (*!
  12887. * jQuery UI Effects Fade 1.14.1
  12888. * https://jqueryui.com
  12889. *
  12890. * Copyright OpenJS Foundation and other contributors
  12891. * Released under the MIT license.
  12892. * https://jquery.org/license
  12893. *)
  12894. (*!
  12895. * jQuery UI Effects Fold 1.14.1
  12896. * https://jqueryui.com
  12897. *
  12898. * Copyright OpenJS Foundation and other contributors
  12899. * Released under the MIT license.
  12900. * https://jquery.org/license
  12901. *)
  12902. (*!
  12903. * jQuery UI Effects Highlight 1.14.1
  12904. * https://jqueryui.com
  12905. *
  12906. * Copyright OpenJS Foundation and other contributors
  12907. * Released under the MIT license.
  12908. * https://jquery.org/license
  12909. *)
  12910. (*!
  12911. * jQuery UI Effects Size 1.14.1
  12912. * https://jqueryui.com
  12913. *
  12914. * Copyright OpenJS Foundation and other contributors
  12915. * Released under the MIT license.
  12916. * https://jquery.org/license
  12917. *)
  12918. (*!
  12919. * jQuery UI Effects Scale 1.14.1
  12920. * https://jqueryui.com
  12921. *
  12922. * Copyright OpenJS Foundation and other contributors
  12923. * Released under the MIT license.
  12924. * https://jquery.org/license
  12925. *)
  12926. (*!
  12927. * jQuery UI Effects Puff 1.14.1
  12928. * https://jqueryui.com
  12929. *
  12930. * Copyright OpenJS Foundation and other contributors
  12931. * Released under the MIT license.
  12932. * https://jquery.org/license
  12933. *)
  12934. (*!
  12935. * jQuery UI Effects Pulsate 1.14.1
  12936. * https://jqueryui.com
  12937. *
  12938. * Copyright OpenJS Foundation and other contributors
  12939. * Released under the MIT license.
  12940. * https://jquery.org/license
  12941. *)
  12942. (*!
  12943. * jQuery UI Effects Shake 1.14.1
  12944. * https://jqueryui.com
  12945. *
  12946. * Copyright OpenJS Foundation and other contributors
  12947. * Released under the MIT license.
  12948. * https://jquery.org/license
  12949. *)
  12950. (*!
  12951. * jQuery UI Effects Slide 1.14.1
  12952. * https://jqueryui.com
  12953. *
  12954. * Copyright OpenJS Foundation and other contributors
  12955. * Released under the MIT license.
  12956. * https://jquery.org/license
  12957. *)
  12958. (*!
  12959. * jQuery UI Effects Transfer 1.14.1
  12960. * https://jqueryui.com
  12961. *
  12962. * Copyright OpenJS Foundation and other contributors
  12963. * Released under the MIT license.
  12964. * https://jquery.org/license
  12965. *)
  12966. (*!
  12967. * jQuery UI Focusable 1.14.1
  12968. * https://jqueryui.com
  12969. *
  12970. * Copyright OpenJS Foundation and other contributors
  12971. * Released under the MIT license.
  12972. * https://jquery.org/license
  12973. *)
  12974. (*!
  12975. * jQuery UI Form Reset Mixin 1.14.1
  12976. * https://jqueryui.com
  12977. *
  12978. * Copyright OpenJS Foundation and other contributors
  12979. * Released under the MIT license.
  12980. * https://jquery.org/license
  12981. *)
  12982. (*!
  12983. * jQuery UI Legacy jQuery Core patches 1.14.1
  12984. * https://jqueryui.com
  12985. *
  12986. * Copyright OpenJS Foundation and other contributors
  12987. * Released under the MIT license.
  12988. * https://jquery.org/license
  12989. *
  12990. *)
  12991. (*!
  12992. * jQuery UI Keycode 1.14.1
  12993. * https://jqueryui.com
  12994. *
  12995. * Copyright OpenJS Foundation and other contributors
  12996. * Released under the MIT license.
  12997. * https://jquery.org/license
  12998. *)
  12999. (*!
  13000. * jQuery UI Labels 1.14.1
  13001. * https://jqueryui.com
  13002. *
  13003. * Copyright OpenJS Foundation and other contributors
  13004. * Released under the MIT license.
  13005. * https://jquery.org/license
  13006. *)
  13007. (*!
  13008. * jQuery UI Scroll Parent 1.14.1
  13009. * https://jqueryui.com
  13010. *
  13011. * Copyright OpenJS Foundation and other contributors
  13012. * Released under the MIT license.
  13013. * https://jquery.org/license
  13014. *)
  13015. (*!
  13016. * jQuery UI Tabbable 1.14.1
  13017. * https://jqueryui.com
  13018. *
  13019. * Copyright OpenJS Foundation and other contributors
  13020. * Released under the MIT license.
  13021. * https://jquery.org/license
  13022. *)
  13023. (*!
  13024. * jQuery UI Unique ID 1.14.1
  13025. * https://jqueryui.com
  13026. *
  13027. * Copyright OpenJS Foundation and other contributors
  13028. * Released under the MIT license.
  13029. * https://jquery.org/license
  13030. *)
  13031. (*!
  13032. * jQuery UI Accordion 1.14.1
  13033. * https://jqueryui.com
  13034. *
  13035. * Copyright OpenJS Foundation and other contributors
  13036. * Released under the MIT license.
  13037. * https://jquery.org/license
  13038. *)
  13039. (*!
  13040. * jQuery UI Menu 1.14.1
  13041. * https://jqueryui.com
  13042. *
  13043. * Copyright OpenJS Foundation and other contributors
  13044. * Released under the MIT license.
  13045. * https://jquery.org/license
  13046. *)
  13047. (*!
  13048. * jQuery UI Autocomplete 1.14.1
  13049. * https://jqueryui.com
  13050. *
  13051. * Copyright OpenJS Foundation and other contributors
  13052. * Released under the MIT license.
  13053. * https://jquery.org/license
  13054. *)
  13055. (*!
  13056. * jQuery UI Controlgroup 1.14.1
  13057. * https://jqueryui.com
  13058. *
  13059. * Copyright OpenJS Foundation and other contributors
  13060. * Released under the MIT license.
  13061. * https://jquery.org/license
  13062. *)
  13063. (*!
  13064. * jQuery UI Checkboxradio 1.14.1
  13065. * https://jqueryui.com
  13066. *
  13067. * Copyright OpenJS Foundation and other contributors
  13068. * Released under the MIT license.
  13069. * https://jquery.org/license
  13070. *)
  13071. (*!
  13072. * jQuery UI Button 1.14.1
  13073. * https://jqueryui.com
  13074. *
  13075. * Copyright OpenJS Foundation and other contributors
  13076. * Released under the MIT license.
  13077. * https://jquery.org/license
  13078. *)
  13079. (*!
  13080. * jQuery UI Datepicker 1.14.1
  13081. * https://jqueryui.com
  13082. *
  13083. * Copyright OpenJS Foundation and other contributors
  13084. * Released under the MIT license.
  13085. * https://jquery.org/license
  13086. *)
  13087. (*!
  13088. * jQuery UI Mouse 1.14.1
  13089. * https://jqueryui.com
  13090. *
  13091. * Copyright OpenJS Foundation and other contributors
  13092. * Released under the MIT license.
  13093. * https://jquery.org/license
  13094. *)
  13095. (*!
  13096. * jQuery UI Draggable 1.14.1
  13097. * https://jqueryui.com
  13098. *
  13099. * Copyright OpenJS Foundation and other contributors
  13100. * Released under the MIT license.
  13101. * https://jquery.org/license
  13102. *)
  13103. (*!
  13104. * jQuery UI Resizable 1.14.1
  13105. * https://jqueryui.com
  13106. *
  13107. * Copyright OpenJS Foundation and other contributors
  13108. * Released under the MIT license.
  13109. * https://jquery.org/license
  13110. *)
  13111. (*!
  13112. * jQuery UI Dialog 1.14.1
  13113. * https://jqueryui.com
  13114. *
  13115. * Copyright OpenJS Foundation and other contributors
  13116. * Released under the MIT license.
  13117. * https://jquery.org/license
  13118. *)
  13119. (*!
  13120. * jQuery UI Droppable 1.14.1
  13121. * https://jqueryui.com
  13122. *
  13123. * Copyright OpenJS Foundation and other contributors
  13124. * Released under the MIT license.
  13125. * https://jquery.org/license
  13126. *)
  13127. (*!
  13128. * jQuery UI Progressbar 1.14.1
  13129. * https://jqueryui.com
  13130. *
  13131. * Copyright OpenJS Foundation and other contributors
  13132. * Released under the MIT license.
  13133. * https://jquery.org/license
  13134. *)
  13135. (*!
  13136. * jQuery UI Selectable 1.14.1
  13137. * https://jqueryui.com
  13138. *
  13139. * Copyright OpenJS Foundation and other contributors
  13140. * Released under the MIT license.
  13141. * https://jquery.org/license
  13142. *)
  13143. (*!
  13144. * jQuery UI Selectmenu 1.14.1
  13145. * https://jqueryui.com
  13146. *
  13147. * Copyright OpenJS Foundation and other contributors
  13148. * Released under the MIT license.
  13149. * https://jquery.org/license
  13150. *)
  13151. (*!
  13152. * jQuery UI Slider 1.14.1
  13153. * https://jqueryui.com
  13154. *
  13155. * Copyright OpenJS Foundation and other contributors
  13156. * Released under the MIT license.
  13157. * https://jquery.org/license
  13158. *)
  13159. (*!
  13160. * jQuery UI Sortable 1.14.1
  13161. * https://jqueryui.com
  13162. *
  13163. * Copyright OpenJS Foundation and other contributors
  13164. * Released under the MIT license.
  13165. * https://jquery.org/license
  13166. *)
  13167. (*!
  13168. * jQuery UI Spinner 1.14.1
  13169. * https://jqueryui.com
  13170. *
  13171. * Copyright OpenJS Foundation and other contributors
  13172. * Released under the MIT license.
  13173. * https://jquery.org/license
  13174. *)
  13175. (*!
  13176. * jQuery UI Tabs 1.14.1
  13177. * https://jqueryui.com
  13178. *
  13179. * Copyright OpenJS Foundation and other contributors
  13180. * Released under the MIT license.
  13181. * https://jquery.org/license
  13182. *)
  13183. (*!
  13184. * jQuery UI Tooltip 1.14.1
  13185. * https://jqueryui.com
  13186. *
  13187. * Copyright OpenJS Foundation and other contributors
  13188. * Released under the MIT license.
  13189. * https://jquery.org/license
  13190. *)
  13191. */
  13192. //# sourceMappingURL=jquery-ui_dist_jquery-ui.js.map