jquery-ui.js 517 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062
  1. /*! jQuery UI - v1.13.2 - 2022-07-14
  2. * http://jqueryui.com
  3. * 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
  4. * Copyright jQuery Foundation and other contributors; Licensed MIT */
  5. ( function( factory ) {
  6. "use strict";
  7. if ( typeof define === "function" && define.amd ) {
  8. // AMD. Register as an anonymous module.
  9. define( [ "jquery" ], factory );
  10. } else {
  11. // Browser globals
  12. factory( jQuery );
  13. }
  14. } )( function( $ ) {
  15. "use strict";
  16. $.ui = $.ui || {};
  17. var version = $.ui.version = "1.13.2";
  18. /*!
  19. * jQuery UI Widget 1.13.2
  20. * http://jqueryui.com
  21. *
  22. * Copyright jQuery Foundation and other contributors
  23. * Released under the MIT license.
  24. * http://jquery.org/license
  25. */
  26. //>>label: Widget
  27. //>>group: Core
  28. //>>description: Provides a factory for creating stateful widgets with a common API.
  29. //>>docs: http://api.jqueryui.com/jQuery.widget/
  30. //>>demos: http://jqueryui.com/widget/
  31. var widgetUuid = 0;
  32. var widgetHasOwnProperty = Array.prototype.hasOwnProperty;
  33. var widgetSlice = Array.prototype.slice;
  34. $.cleanData = ( function( orig ) {
  35. return function( elems ) {
  36. var events, elem, i;
  37. for ( i = 0; ( elem = elems[ i ] ) != null; i++ ) {
  38. // Only trigger remove when necessary to save time
  39. events = $._data( elem, "events" );
  40. if ( events && events.remove ) {
  41. $( elem ).triggerHandler( "remove" );
  42. }
  43. }
  44. orig( elems );
  45. };
  46. } )( $.cleanData );
  47. $.widget = function( name, base, prototype ) {
  48. var existingConstructor, constructor, basePrototype;
  49. // ProxiedPrototype allows the provided prototype to remain unmodified
  50. // so that it can be used as a mixin for multiple widgets (#8876)
  51. var proxiedPrototype = {};
  52. var namespace = name.split( "." )[ 0 ];
  53. name = name.split( "." )[ 1 ];
  54. var fullName = namespace + "-" + name;
  55. if ( !prototype ) {
  56. prototype = base;
  57. base = $.Widget;
  58. }
  59. if ( Array.isArray( prototype ) ) {
  60. prototype = $.extend.apply( null, [ {} ].concat( prototype ) );
  61. }
  62. // Create selector for plugin
  63. $.expr.pseudos[ fullName.toLowerCase() ] = function( elem ) {
  64. return !!$.data( elem, fullName );
  65. };
  66. $[ namespace ] = $[ namespace ] || {};
  67. existingConstructor = $[ namespace ][ name ];
  68. constructor = $[ namespace ][ name ] = function( options, element ) {
  69. // Allow instantiation without "new" keyword
  70. if ( !this || !this._createWidget ) {
  71. return new constructor( options, element );
  72. }
  73. // Allow instantiation without initializing for simple inheritance
  74. // must use "new" keyword (the code above always passes args)
  75. if ( arguments.length ) {
  76. this._createWidget( options, element );
  77. }
  78. };
  79. // Extend with the existing constructor to carry over any static properties
  80. $.extend( constructor, existingConstructor, {
  81. version: prototype.version,
  82. // Copy the object used to create the prototype in case we need to
  83. // redefine the widget later
  84. _proto: $.extend( {}, prototype ),
  85. // Track widgets that inherit from this widget in case this widget is
  86. // redefined after a widget inherits from it
  87. _childConstructors: []
  88. } );
  89. basePrototype = new base();
  90. // We need to make the options hash a property directly on the new instance
  91. // otherwise we'll modify the options hash on the prototype that we're
  92. // inheriting from
  93. basePrototype.options = $.widget.extend( {}, basePrototype.options );
  94. $.each( prototype, function( prop, value ) {
  95. if ( typeof value !== "function" ) {
  96. proxiedPrototype[ prop ] = value;
  97. return;
  98. }
  99. proxiedPrototype[ prop ] = ( function() {
  100. function _super() {
  101. return base.prototype[ prop ].apply( this, arguments );
  102. }
  103. function _superApply( args ) {
  104. return base.prototype[ prop ].apply( this, args );
  105. }
  106. return function() {
  107. var __super = this._super;
  108. var __superApply = this._superApply;
  109. var returnValue;
  110. this._super = _super;
  111. this._superApply = _superApply;
  112. returnValue = value.apply( this, arguments );
  113. this._super = __super;
  114. this._superApply = __superApply;
  115. return returnValue;
  116. };
  117. } )();
  118. } );
  119. constructor.prototype = $.widget.extend( basePrototype, {
  120. // TODO: remove support for widgetEventPrefix
  121. // always use the name + a colon as the prefix, e.g., draggable:start
  122. // don't prefix for widgets that aren't DOM-based
  123. widgetEventPrefix: existingConstructor ? ( basePrototype.widgetEventPrefix || name ) : name
  124. }, proxiedPrototype, {
  125. constructor: constructor,
  126. namespace: namespace,
  127. widgetName: name,
  128. widgetFullName: fullName
  129. } );
  130. // If this widget is being redefined then we need to find all widgets that
  131. // are inheriting from it and redefine all of them so that they inherit from
  132. // the new version of this widget. We're essentially trying to replace one
  133. // level in the prototype chain.
  134. if ( existingConstructor ) {
  135. $.each( existingConstructor._childConstructors, function( i, child ) {
  136. var childPrototype = child.prototype;
  137. // Redefine the child widget using the same prototype that was
  138. // originally used, but inherit from the new version of the base
  139. $.widget( childPrototype.namespace + "." + childPrototype.widgetName, constructor,
  140. child._proto );
  141. } );
  142. // Remove the list of existing child constructors from the old constructor
  143. // so the old child constructors can be garbage collected
  144. delete existingConstructor._childConstructors;
  145. } else {
  146. base._childConstructors.push( constructor );
  147. }
  148. $.widget.bridge( name, constructor );
  149. return constructor;
  150. };
  151. $.widget.extend = function( target ) {
  152. var input = widgetSlice.call( arguments, 1 );
  153. var inputIndex = 0;
  154. var inputLength = input.length;
  155. var key;
  156. var value;
  157. for ( ; inputIndex < inputLength; inputIndex++ ) {
  158. for ( key in input[ inputIndex ] ) {
  159. value = input[ inputIndex ][ key ];
  160. if ( widgetHasOwnProperty.call( input[ inputIndex ], key ) && value !== undefined ) {
  161. // Clone objects
  162. if ( $.isPlainObject( value ) ) {
  163. target[ key ] = $.isPlainObject( target[ key ] ) ?
  164. $.widget.extend( {}, target[ key ], value ) :
  165. // Don't extend strings, arrays, etc. with objects
  166. $.widget.extend( {}, value );
  167. // Copy everything else by reference
  168. } else {
  169. target[ key ] = value;
  170. }
  171. }
  172. }
  173. }
  174. return target;
  175. };
  176. $.widget.bridge = function( name, object ) {
  177. var fullName = object.prototype.widgetFullName || name;
  178. $.fn[ name ] = function( options ) {
  179. var isMethodCall = typeof options === "string";
  180. var args = widgetSlice.call( arguments, 1 );
  181. var returnValue = this;
  182. if ( isMethodCall ) {
  183. // If this is an empty collection, we need to have the instance method
  184. // return undefined instead of the jQuery instance
  185. if ( !this.length && options === "instance" ) {
  186. returnValue = undefined;
  187. } else {
  188. this.each( function() {
  189. var methodValue;
  190. var instance = $.data( this, fullName );
  191. if ( options === "instance" ) {
  192. returnValue = instance;
  193. return false;
  194. }
  195. if ( !instance ) {
  196. return $.error( "cannot call methods on " + name +
  197. " prior to initialization; " +
  198. "attempted to call method '" + options + "'" );
  199. }
  200. if ( typeof instance[ options ] !== "function" ||
  201. options.charAt( 0 ) === "_" ) {
  202. return $.error( "no such method '" + options + "' for " + name +
  203. " widget instance" );
  204. }
  205. methodValue = instance[ options ].apply( instance, args );
  206. if ( methodValue !== instance && methodValue !== undefined ) {
  207. returnValue = methodValue && methodValue.jquery ?
  208. returnValue.pushStack( methodValue.get() ) :
  209. methodValue;
  210. return false;
  211. }
  212. } );
  213. }
  214. } else {
  215. // Allow multiple hashes to be passed on init
  216. if ( args.length ) {
  217. options = $.widget.extend.apply( null, [ options ].concat( args ) );
  218. }
  219. this.each( function() {
  220. var instance = $.data( this, fullName );
  221. if ( instance ) {
  222. instance.option( options || {} );
  223. if ( instance._init ) {
  224. instance._init();
  225. }
  226. } else {
  227. $.data( this, fullName, new object( options, this ) );
  228. }
  229. } );
  230. }
  231. return returnValue;
  232. };
  233. };
  234. $.Widget = function( /* options, element */ ) {};
  235. $.Widget._childConstructors = [];
  236. $.Widget.prototype = {
  237. widgetName: "widget",
  238. widgetEventPrefix: "",
  239. defaultElement: "<div>",
  240. options: {
  241. classes: {},
  242. disabled: false,
  243. // Callbacks
  244. create: null
  245. },
  246. _createWidget: function( options, element ) {
  247. element = $( element || this.defaultElement || this )[ 0 ];
  248. this.element = $( element );
  249. this.uuid = widgetUuid++;
  250. this.eventNamespace = "." + this.widgetName + this.uuid;
  251. this.bindings = $();
  252. this.hoverable = $();
  253. this.focusable = $();
  254. this.classesElementLookup = {};
  255. if ( element !== this ) {
  256. $.data( element, this.widgetFullName, this );
  257. this._on( true, this.element, {
  258. remove: function( event ) {
  259. if ( event.target === element ) {
  260. this.destroy();
  261. }
  262. }
  263. } );
  264. this.document = $( element.style ?
  265. // Element within the document
  266. element.ownerDocument :
  267. // Element is window or document
  268. element.document || element );
  269. this.window = $( this.document[ 0 ].defaultView || this.document[ 0 ].parentWindow );
  270. }
  271. this.options = $.widget.extend( {},
  272. this.options,
  273. this._getCreateOptions(),
  274. options );
  275. this._create();
  276. if ( this.options.disabled ) {
  277. this._setOptionDisabled( this.options.disabled );
  278. }
  279. this._trigger( "create", null, this._getCreateEventData() );
  280. this._init();
  281. },
  282. _getCreateOptions: function() {
  283. return {};
  284. },
  285. _getCreateEventData: $.noop,
  286. _create: $.noop,
  287. _init: $.noop,
  288. destroy: function() {
  289. var that = this;
  290. this._destroy();
  291. $.each( this.classesElementLookup, function( key, value ) {
  292. that._removeClass( value, key );
  293. } );
  294. // We can probably remove the unbind calls in 2.0
  295. // all event bindings should go through this._on()
  296. this.element
  297. .off( this.eventNamespace )
  298. .removeData( this.widgetFullName );
  299. this.widget()
  300. .off( this.eventNamespace )
  301. .removeAttr( "aria-disabled" );
  302. // Clean up events and states
  303. this.bindings.off( this.eventNamespace );
  304. },
  305. _destroy: $.noop,
  306. widget: function() {
  307. return this.element;
  308. },
  309. option: function( key, value ) {
  310. var options = key;
  311. var parts;
  312. var curOption;
  313. var i;
  314. if ( arguments.length === 0 ) {
  315. // Don't return a reference to the internal hash
  316. return $.widget.extend( {}, this.options );
  317. }
  318. if ( typeof key === "string" ) {
  319. // Handle nested keys, e.g., "foo.bar" => { foo: { bar: ___ } }
  320. options = {};
  321. parts = key.split( "." );
  322. key = parts.shift();
  323. if ( parts.length ) {
  324. curOption = options[ key ] = $.widget.extend( {}, this.options[ key ] );
  325. for ( i = 0; i < parts.length - 1; i++ ) {
  326. curOption[ parts[ i ] ] = curOption[ parts[ i ] ] || {};
  327. curOption = curOption[ parts[ i ] ];
  328. }
  329. key = parts.pop();
  330. if ( arguments.length === 1 ) {
  331. return curOption[ key ] === undefined ? null : curOption[ key ];
  332. }
  333. curOption[ key ] = value;
  334. } else {
  335. if ( arguments.length === 1 ) {
  336. return this.options[ key ] === undefined ? null : this.options[ key ];
  337. }
  338. options[ key ] = value;
  339. }
  340. }
  341. this._setOptions( options );
  342. return this;
  343. },
  344. _setOptions: function( options ) {
  345. var key;
  346. for ( key in options ) {
  347. this._setOption( key, options[ key ] );
  348. }
  349. return this;
  350. },
  351. _setOption: function( key, value ) {
  352. if ( key === "classes" ) {
  353. this._setOptionClasses( value );
  354. }
  355. this.options[ key ] = value;
  356. if ( key === "disabled" ) {
  357. this._setOptionDisabled( value );
  358. }
  359. return this;
  360. },
  361. _setOptionClasses: function( value ) {
  362. var classKey, elements, currentElements;
  363. for ( classKey in value ) {
  364. currentElements = this.classesElementLookup[ classKey ];
  365. if ( value[ classKey ] === this.options.classes[ classKey ] ||
  366. !currentElements ||
  367. !currentElements.length ) {
  368. continue;
  369. }
  370. // We are doing this to create a new jQuery object because the _removeClass() call
  371. // on the next line is going to destroy the reference to the current elements being
  372. // tracked. We need to save a copy of this collection so that we can add the new classes
  373. // below.
  374. elements = $( currentElements.get() );
  375. this._removeClass( currentElements, classKey );
  376. // We don't use _addClass() here, because that uses this.options.classes
  377. // for generating the string of classes. We want to use the value passed in from
  378. // _setOption(), this is the new value of the classes option which was passed to
  379. // _setOption(). We pass this value directly to _classes().
  380. elements.addClass( this._classes( {
  381. element: elements,
  382. keys: classKey,
  383. classes: value,
  384. add: true
  385. } ) );
  386. }
  387. },
  388. _setOptionDisabled: function( value ) {
  389. this._toggleClass( this.widget(), this.widgetFullName + "-disabled", null, !!value );
  390. // If the widget is becoming disabled, then nothing is interactive
  391. if ( value ) {
  392. this._removeClass( this.hoverable, null, "ui-state-hover" );
  393. this._removeClass( this.focusable, null, "ui-state-focus" );
  394. }
  395. },
  396. enable: function() {
  397. return this._setOptions( { disabled: false } );
  398. },
  399. disable: function() {
  400. return this._setOptions( { disabled: true } );
  401. },
  402. _classes: function( options ) {
  403. var full = [];
  404. var that = this;
  405. options = $.extend( {
  406. element: this.element,
  407. classes: this.options.classes || {}
  408. }, options );
  409. function bindRemoveEvent() {
  410. var nodesToBind = [];
  411. options.element.each( function( _, element ) {
  412. var isTracked = $.map( that.classesElementLookup, function( elements ) {
  413. return elements;
  414. } )
  415. .some( function( elements ) {
  416. return elements.is( element );
  417. } );
  418. if ( !isTracked ) {
  419. nodesToBind.push( element );
  420. }
  421. } );
  422. that._on( $( nodesToBind ), {
  423. remove: "_untrackClassesElement"
  424. } );
  425. }
  426. function processClassString( classes, checkOption ) {
  427. var current, i;
  428. for ( i = 0; i < classes.length; i++ ) {
  429. current = that.classesElementLookup[ classes[ i ] ] || $();
  430. if ( options.add ) {
  431. bindRemoveEvent();
  432. current = $( $.uniqueSort( current.get().concat( options.element.get() ) ) );
  433. } else {
  434. current = $( current.not( options.element ).get() );
  435. }
  436. that.classesElementLookup[ classes[ i ] ] = current;
  437. full.push( classes[ i ] );
  438. if ( checkOption && options.classes[ classes[ i ] ] ) {
  439. full.push( options.classes[ classes[ i ] ] );
  440. }
  441. }
  442. }
  443. if ( options.keys ) {
  444. processClassString( options.keys.match( /\S+/g ) || [], true );
  445. }
  446. if ( options.extra ) {
  447. processClassString( options.extra.match( /\S+/g ) || [] );
  448. }
  449. return full.join( " " );
  450. },
  451. _untrackClassesElement: function( event ) {
  452. var that = this;
  453. $.each( that.classesElementLookup, function( key, value ) {
  454. if ( $.inArray( event.target, value ) !== -1 ) {
  455. that.classesElementLookup[ key ] = $( value.not( event.target ).get() );
  456. }
  457. } );
  458. this._off( $( event.target ) );
  459. },
  460. _removeClass: function( element, keys, extra ) {
  461. return this._toggleClass( element, keys, extra, false );
  462. },
  463. _addClass: function( element, keys, extra ) {
  464. return this._toggleClass( element, keys, extra, true );
  465. },
  466. _toggleClass: function( element, keys, extra, add ) {
  467. add = ( typeof add === "boolean" ) ? add : extra;
  468. var shift = ( typeof element === "string" || element === null ),
  469. options = {
  470. extra: shift ? keys : extra,
  471. keys: shift ? element : keys,
  472. element: shift ? this.element : element,
  473. add: add
  474. };
  475. options.element.toggleClass( this._classes( options ), add );
  476. return this;
  477. },
  478. _on: function( suppressDisabledCheck, element, handlers ) {
  479. var delegateElement;
  480. var instance = this;
  481. // No suppressDisabledCheck flag, shuffle arguments
  482. if ( typeof suppressDisabledCheck !== "boolean" ) {
  483. handlers = element;
  484. element = suppressDisabledCheck;
  485. suppressDisabledCheck = false;
  486. }
  487. // No element argument, shuffle and use this.element
  488. if ( !handlers ) {
  489. handlers = element;
  490. element = this.element;
  491. delegateElement = this.widget();
  492. } else {
  493. element = delegateElement = $( element );
  494. this.bindings = this.bindings.add( element );
  495. }
  496. $.each( handlers, function( event, handler ) {
  497. function handlerProxy() {
  498. // Allow widgets to customize the disabled handling
  499. // - disabled as an array instead of boolean
  500. // - disabled class as method for disabling individual parts
  501. if ( !suppressDisabledCheck &&
  502. ( instance.options.disabled === true ||
  503. $( this ).hasClass( "ui-state-disabled" ) ) ) {
  504. return;
  505. }
  506. return ( typeof handler === "string" ? instance[ handler ] : handler )
  507. .apply( instance, arguments );
  508. }
  509. // Copy the guid so direct unbinding works
  510. if ( typeof handler !== "string" ) {
  511. handlerProxy.guid = handler.guid =
  512. handler.guid || handlerProxy.guid || $.guid++;
  513. }
  514. var match = event.match( /^([\w:-]*)\s*(.*)$/ );
  515. var eventName = match[ 1 ] + instance.eventNamespace;
  516. var selector = match[ 2 ];
  517. if ( selector ) {
  518. delegateElement.on( eventName, selector, handlerProxy );
  519. } else {
  520. element.on( eventName, handlerProxy );
  521. }
  522. } );
  523. },
  524. _off: function( element, eventName ) {
  525. eventName = ( eventName || "" ).split( " " ).join( this.eventNamespace + " " ) +
  526. this.eventNamespace;
  527. element.off( eventName );
  528. // Clear the stack to avoid memory leaks (#10056)
  529. this.bindings = $( this.bindings.not( element ).get() );
  530. this.focusable = $( this.focusable.not( element ).get() );
  531. this.hoverable = $( this.hoverable.not( element ).get() );
  532. },
  533. _delay: function( handler, delay ) {
  534. function handlerProxy() {
  535. return ( typeof handler === "string" ? instance[ handler ] : handler )
  536. .apply( instance, arguments );
  537. }
  538. var instance = this;
  539. return setTimeout( handlerProxy, delay || 0 );
  540. },
  541. _hoverable: function( element ) {
  542. this.hoverable = this.hoverable.add( element );
  543. this._on( element, {
  544. mouseenter: function( event ) {
  545. this._addClass( $( event.currentTarget ), null, "ui-state-hover" );
  546. },
  547. mouseleave: function( event ) {
  548. this._removeClass( $( event.currentTarget ), null, "ui-state-hover" );
  549. }
  550. } );
  551. },
  552. _focusable: function( element ) {
  553. this.focusable = this.focusable.add( element );
  554. this._on( element, {
  555. focusin: function( event ) {
  556. this._addClass( $( event.currentTarget ), null, "ui-state-focus" );
  557. },
  558. focusout: function( event ) {
  559. this._removeClass( $( event.currentTarget ), null, "ui-state-focus" );
  560. }
  561. } );
  562. },
  563. _trigger: function( type, event, data ) {
  564. var prop, orig;
  565. var callback = this.options[ type ];
  566. data = data || {};
  567. event = $.Event( event );
  568. event.type = ( type === this.widgetEventPrefix ?
  569. type :
  570. this.widgetEventPrefix + type ).toLowerCase();
  571. // The original event may come from any element
  572. // so we need to reset the target on the new event
  573. event.target = this.element[ 0 ];
  574. // Copy original event properties over to the new event
  575. orig = event.originalEvent;
  576. if ( orig ) {
  577. for ( prop in orig ) {
  578. if ( !( prop in event ) ) {
  579. event[ prop ] = orig[ prop ];
  580. }
  581. }
  582. }
  583. this.element.trigger( event, data );
  584. return !( typeof callback === "function" &&
  585. callback.apply( this.element[ 0 ], [ event ].concat( data ) ) === false ||
  586. event.isDefaultPrevented() );
  587. }
  588. };
  589. $.each( { show: "fadeIn", hide: "fadeOut" }, function( method, defaultEffect ) {
  590. $.Widget.prototype[ "_" + method ] = function( element, options, callback ) {
  591. if ( typeof options === "string" ) {
  592. options = { effect: options };
  593. }
  594. var hasOptions;
  595. var effectName = !options ?
  596. method :
  597. options === true || typeof options === "number" ?
  598. defaultEffect :
  599. options.effect || defaultEffect;
  600. options = options || {};
  601. if ( typeof options === "number" ) {
  602. options = { duration: options };
  603. } else if ( options === true ) {
  604. options = {};
  605. }
  606. hasOptions = !$.isEmptyObject( options );
  607. options.complete = callback;
  608. if ( options.delay ) {
  609. element.delay( options.delay );
  610. }
  611. if ( hasOptions && $.effects && $.effects.effect[ effectName ] ) {
  612. element[ method ]( options );
  613. } else if ( effectName !== method && element[ effectName ] ) {
  614. element[ effectName ]( options.duration, options.easing, callback );
  615. } else {
  616. element.queue( function( next ) {
  617. $( this )[ method ]();
  618. if ( callback ) {
  619. callback.call( element[ 0 ] );
  620. }
  621. next();
  622. } );
  623. }
  624. };
  625. } );
  626. var widget = $.widget;
  627. /*!
  628. * jQuery UI Position 1.13.2
  629. * http://jqueryui.com
  630. *
  631. * Copyright jQuery Foundation and other contributors
  632. * Released under the MIT license.
  633. * http://jquery.org/license
  634. *
  635. * http://api.jqueryui.com/position/
  636. */
  637. //>>label: Position
  638. //>>group: Core
  639. //>>description: Positions elements relative to other elements.
  640. //>>docs: http://api.jqueryui.com/position/
  641. //>>demos: http://jqueryui.com/position/
  642. ( function() {
  643. var cachedScrollbarWidth,
  644. max = Math.max,
  645. abs = Math.abs,
  646. rhorizontal = /left|center|right/,
  647. rvertical = /top|center|bottom/,
  648. roffset = /[\+\-]\d+(\.[\d]+)?%?/,
  649. rposition = /^\w+/,
  650. rpercent = /%$/,
  651. _position = $.fn.position;
  652. function getOffsets( offsets, width, height ) {
  653. return [
  654. parseFloat( offsets[ 0 ] ) * ( rpercent.test( offsets[ 0 ] ) ? width / 100 : 1 ),
  655. parseFloat( offsets[ 1 ] ) * ( rpercent.test( offsets[ 1 ] ) ? height / 100 : 1 )
  656. ];
  657. }
  658. function parseCss( element, property ) {
  659. return parseInt( $.css( element, property ), 10 ) || 0;
  660. }
  661. function isWindow( obj ) {
  662. return obj != null && obj === obj.window;
  663. }
  664. function getDimensions( elem ) {
  665. var raw = elem[ 0 ];
  666. if ( raw.nodeType === 9 ) {
  667. return {
  668. width: elem.width(),
  669. height: elem.height(),
  670. offset: { top: 0, left: 0 }
  671. };
  672. }
  673. if ( isWindow( raw ) ) {
  674. return {
  675. width: elem.width(),
  676. height: elem.height(),
  677. offset: { top: elem.scrollTop(), left: elem.scrollLeft() }
  678. };
  679. }
  680. if ( raw.preventDefault ) {
  681. return {
  682. width: 0,
  683. height: 0,
  684. offset: { top: raw.pageY, left: raw.pageX }
  685. };
  686. }
  687. return {
  688. width: elem.outerWidth(),
  689. height: elem.outerHeight(),
  690. offset: elem.offset()
  691. };
  692. }
  693. $.position = {
  694. scrollbarWidth: function() {
  695. if ( cachedScrollbarWidth !== undefined ) {
  696. return cachedScrollbarWidth;
  697. }
  698. var w1, w2,
  699. div = $( "<div style=" +
  700. "'display:block;position:absolute;width:200px;height:200px;overflow:hidden;'>" +
  701. "<div style='height:300px;width:auto;'></div></div>" ),
  702. innerDiv = div.children()[ 0 ];
  703. $( "body" ).append( div );
  704. w1 = innerDiv.offsetWidth;
  705. div.css( "overflow", "scroll" );
  706. w2 = innerDiv.offsetWidth;
  707. if ( w1 === w2 ) {
  708. w2 = div[ 0 ].clientWidth;
  709. }
  710. div.remove();
  711. return ( cachedScrollbarWidth = w1 - w2 );
  712. },
  713. getScrollInfo: function( within ) {
  714. var overflowX = within.isWindow || within.isDocument ? "" :
  715. within.element.css( "overflow-x" ),
  716. overflowY = within.isWindow || within.isDocument ? "" :
  717. within.element.css( "overflow-y" ),
  718. hasOverflowX = overflowX === "scroll" ||
  719. ( overflowX === "auto" && within.width < within.element[ 0 ].scrollWidth ),
  720. hasOverflowY = overflowY === "scroll" ||
  721. ( overflowY === "auto" && within.height < within.element[ 0 ].scrollHeight );
  722. return {
  723. width: hasOverflowY ? $.position.scrollbarWidth() : 0,
  724. height: hasOverflowX ? $.position.scrollbarWidth() : 0
  725. };
  726. },
  727. getWithinInfo: function( element ) {
  728. var withinElement = $( element || window ),
  729. isElemWindow = isWindow( withinElement[ 0 ] ),
  730. isDocument = !!withinElement[ 0 ] && withinElement[ 0 ].nodeType === 9,
  731. hasOffset = !isElemWindow && !isDocument;
  732. return {
  733. element: withinElement,
  734. isWindow: isElemWindow,
  735. isDocument: isDocument,
  736. offset: hasOffset ? $( element ).offset() : { left: 0, top: 0 },
  737. scrollLeft: withinElement.scrollLeft(),
  738. scrollTop: withinElement.scrollTop(),
  739. width: withinElement.outerWidth(),
  740. height: withinElement.outerHeight()
  741. };
  742. }
  743. };
  744. $.fn.position = function( options ) {
  745. if ( !options || !options.of ) {
  746. return _position.apply( this, arguments );
  747. }
  748. // Make a copy, we don't want to modify arguments
  749. options = $.extend( {}, options );
  750. var atOffset, targetWidth, targetHeight, targetOffset, basePosition, dimensions,
  751. // Make sure string options are treated as CSS selectors
  752. target = typeof options.of === "string" ?
  753. $( document ).find( options.of ) :
  754. $( options.of ),
  755. within = $.position.getWithinInfo( options.within ),
  756. scrollInfo = $.position.getScrollInfo( within ),
  757. collision = ( options.collision || "flip" ).split( " " ),
  758. offsets = {};
  759. dimensions = getDimensions( target );
  760. if ( target[ 0 ].preventDefault ) {
  761. // Force left top to allow flipping
  762. options.at = "left top";
  763. }
  764. targetWidth = dimensions.width;
  765. targetHeight = dimensions.height;
  766. targetOffset = dimensions.offset;
  767. // Clone to reuse original targetOffset later
  768. basePosition = $.extend( {}, targetOffset );
  769. // Force my and at to have valid horizontal and vertical positions
  770. // if a value is missing or invalid, it will be converted to center
  771. $.each( [ "my", "at" ], function() {
  772. var pos = ( options[ this ] || "" ).split( " " ),
  773. horizontalOffset,
  774. verticalOffset;
  775. if ( pos.length === 1 ) {
  776. pos = rhorizontal.test( pos[ 0 ] ) ?
  777. pos.concat( [ "center" ] ) :
  778. rvertical.test( pos[ 0 ] ) ?
  779. [ "center" ].concat( pos ) :
  780. [ "center", "center" ];
  781. }
  782. pos[ 0 ] = rhorizontal.test( pos[ 0 ] ) ? pos[ 0 ] : "center";
  783. pos[ 1 ] = rvertical.test( pos[ 1 ] ) ? pos[ 1 ] : "center";
  784. // Calculate offsets
  785. horizontalOffset = roffset.exec( pos[ 0 ] );
  786. verticalOffset = roffset.exec( pos[ 1 ] );
  787. offsets[ this ] = [
  788. horizontalOffset ? horizontalOffset[ 0 ] : 0,
  789. verticalOffset ? verticalOffset[ 0 ] : 0
  790. ];
  791. // Reduce to just the positions without the offsets
  792. options[ this ] = [
  793. rposition.exec( pos[ 0 ] )[ 0 ],
  794. rposition.exec( pos[ 1 ] )[ 0 ]
  795. ];
  796. } );
  797. // Normalize collision option
  798. if ( collision.length === 1 ) {
  799. collision[ 1 ] = collision[ 0 ];
  800. }
  801. if ( options.at[ 0 ] === "right" ) {
  802. basePosition.left += targetWidth;
  803. } else if ( options.at[ 0 ] === "center" ) {
  804. basePosition.left += targetWidth / 2;
  805. }
  806. if ( options.at[ 1 ] === "bottom" ) {
  807. basePosition.top += targetHeight;
  808. } else if ( options.at[ 1 ] === "center" ) {
  809. basePosition.top += targetHeight / 2;
  810. }
  811. atOffset = getOffsets( offsets.at, targetWidth, targetHeight );
  812. basePosition.left += atOffset[ 0 ];
  813. basePosition.top += atOffset[ 1 ];
  814. return this.each( function() {
  815. var collisionPosition, using,
  816. elem = $( this ),
  817. elemWidth = elem.outerWidth(),
  818. elemHeight = elem.outerHeight(),
  819. marginLeft = parseCss( this, "marginLeft" ),
  820. marginTop = parseCss( this, "marginTop" ),
  821. collisionWidth = elemWidth + marginLeft + parseCss( this, "marginRight" ) +
  822. scrollInfo.width,
  823. collisionHeight = elemHeight + marginTop + parseCss( this, "marginBottom" ) +
  824. scrollInfo.height,
  825. position = $.extend( {}, basePosition ),
  826. myOffset = getOffsets( offsets.my, elem.outerWidth(), elem.outerHeight() );
  827. if ( options.my[ 0 ] === "right" ) {
  828. position.left -= elemWidth;
  829. } else if ( options.my[ 0 ] === "center" ) {
  830. position.left -= elemWidth / 2;
  831. }
  832. if ( options.my[ 1 ] === "bottom" ) {
  833. position.top -= elemHeight;
  834. } else if ( options.my[ 1 ] === "center" ) {
  835. position.top -= elemHeight / 2;
  836. }
  837. position.left += myOffset[ 0 ];
  838. position.top += myOffset[ 1 ];
  839. collisionPosition = {
  840. marginLeft: marginLeft,
  841. marginTop: marginTop
  842. };
  843. $.each( [ "left", "top" ], function( i, dir ) {
  844. if ( $.ui.position[ collision[ i ] ] ) {
  845. $.ui.position[ collision[ i ] ][ dir ]( position, {
  846. targetWidth: targetWidth,
  847. targetHeight: targetHeight,
  848. elemWidth: elemWidth,
  849. elemHeight: elemHeight,
  850. collisionPosition: collisionPosition,
  851. collisionWidth: collisionWidth,
  852. collisionHeight: collisionHeight,
  853. offset: [ atOffset[ 0 ] + myOffset[ 0 ], atOffset [ 1 ] + myOffset[ 1 ] ],
  854. my: options.my,
  855. at: options.at,
  856. within: within,
  857. elem: elem
  858. } );
  859. }
  860. } );
  861. if ( options.using ) {
  862. // Adds feedback as second argument to using callback, if present
  863. using = function( props ) {
  864. var left = targetOffset.left - position.left,
  865. right = left + targetWidth - elemWidth,
  866. top = targetOffset.top - position.top,
  867. bottom = top + targetHeight - elemHeight,
  868. feedback = {
  869. target: {
  870. element: target,
  871. left: targetOffset.left,
  872. top: targetOffset.top,
  873. width: targetWidth,
  874. height: targetHeight
  875. },
  876. element: {
  877. element: elem,
  878. left: position.left,
  879. top: position.top,
  880. width: elemWidth,
  881. height: elemHeight
  882. },
  883. horizontal: right < 0 ? "left" : left > 0 ? "right" : "center",
  884. vertical: bottom < 0 ? "top" : top > 0 ? "bottom" : "middle"
  885. };
  886. if ( targetWidth < elemWidth && abs( left + right ) < targetWidth ) {
  887. feedback.horizontal = "center";
  888. }
  889. if ( targetHeight < elemHeight && abs( top + bottom ) < targetHeight ) {
  890. feedback.vertical = "middle";
  891. }
  892. if ( max( abs( left ), abs( right ) ) > max( abs( top ), abs( bottom ) ) ) {
  893. feedback.important = "horizontal";
  894. } else {
  895. feedback.important = "vertical";
  896. }
  897. options.using.call( this, props, feedback );
  898. };
  899. }
  900. elem.offset( $.extend( position, { using: using } ) );
  901. } );
  902. };
  903. $.ui.position = {
  904. fit: {
  905. left: function( position, data ) {
  906. var within = data.within,
  907. withinOffset = within.isWindow ? within.scrollLeft : within.offset.left,
  908. outerWidth = within.width,
  909. collisionPosLeft = position.left - data.collisionPosition.marginLeft,
  910. overLeft = withinOffset - collisionPosLeft,
  911. overRight = collisionPosLeft + data.collisionWidth - outerWidth - withinOffset,
  912. newOverRight;
  913. // Element is wider than within
  914. if ( data.collisionWidth > outerWidth ) {
  915. // Element is initially over the left side of within
  916. if ( overLeft > 0 && overRight <= 0 ) {
  917. newOverRight = position.left + overLeft + data.collisionWidth - outerWidth -
  918. withinOffset;
  919. position.left += overLeft - newOverRight;
  920. // Element is initially over right side of within
  921. } else if ( overRight > 0 && overLeft <= 0 ) {
  922. position.left = withinOffset;
  923. // Element is initially over both left and right sides of within
  924. } else {
  925. if ( overLeft > overRight ) {
  926. position.left = withinOffset + outerWidth - data.collisionWidth;
  927. } else {
  928. position.left = withinOffset;
  929. }
  930. }
  931. // Too far left -> align with left edge
  932. } else if ( overLeft > 0 ) {
  933. position.left += overLeft;
  934. // Too far right -> align with right edge
  935. } else if ( overRight > 0 ) {
  936. position.left -= overRight;
  937. // Adjust based on position and margin
  938. } else {
  939. position.left = max( position.left - collisionPosLeft, position.left );
  940. }
  941. },
  942. top: function( position, data ) {
  943. var within = data.within,
  944. withinOffset = within.isWindow ? within.scrollTop : within.offset.top,
  945. outerHeight = data.within.height,
  946. collisionPosTop = position.top - data.collisionPosition.marginTop,
  947. overTop = withinOffset - collisionPosTop,
  948. overBottom = collisionPosTop + data.collisionHeight - outerHeight - withinOffset,
  949. newOverBottom;
  950. // Element is taller than within
  951. if ( data.collisionHeight > outerHeight ) {
  952. // Element is initially over the top of within
  953. if ( overTop > 0 && overBottom <= 0 ) {
  954. newOverBottom = position.top + overTop + data.collisionHeight - outerHeight -
  955. withinOffset;
  956. position.top += overTop - newOverBottom;
  957. // Element is initially over bottom of within
  958. } else if ( overBottom > 0 && overTop <= 0 ) {
  959. position.top = withinOffset;
  960. // Element is initially over both top and bottom of within
  961. } else {
  962. if ( overTop > overBottom ) {
  963. position.top = withinOffset + outerHeight - data.collisionHeight;
  964. } else {
  965. position.top = withinOffset;
  966. }
  967. }
  968. // Too far up -> align with top
  969. } else if ( overTop > 0 ) {
  970. position.top += overTop;
  971. // Too far down -> align with bottom edge
  972. } else if ( overBottom > 0 ) {
  973. position.top -= overBottom;
  974. // Adjust based on position and margin
  975. } else {
  976. position.top = max( position.top - collisionPosTop, position.top );
  977. }
  978. }
  979. },
  980. flip: {
  981. left: function( position, data ) {
  982. var within = data.within,
  983. withinOffset = within.offset.left + within.scrollLeft,
  984. outerWidth = within.width,
  985. offsetLeft = within.isWindow ? within.scrollLeft : within.offset.left,
  986. collisionPosLeft = position.left - data.collisionPosition.marginLeft,
  987. overLeft = collisionPosLeft - offsetLeft,
  988. overRight = collisionPosLeft + data.collisionWidth - outerWidth - offsetLeft,
  989. myOffset = data.my[ 0 ] === "left" ?
  990. -data.elemWidth :
  991. data.my[ 0 ] === "right" ?
  992. data.elemWidth :
  993. 0,
  994. atOffset = data.at[ 0 ] === "left" ?
  995. data.targetWidth :
  996. data.at[ 0 ] === "right" ?
  997. -data.targetWidth :
  998. 0,
  999. offset = -2 * data.offset[ 0 ],
  1000. newOverRight,
  1001. newOverLeft;
  1002. if ( overLeft < 0 ) {
  1003. newOverRight = position.left + myOffset + atOffset + offset + data.collisionWidth -
  1004. outerWidth - withinOffset;
  1005. if ( newOverRight < 0 || newOverRight < abs( overLeft ) ) {
  1006. position.left += myOffset + atOffset + offset;
  1007. }
  1008. } else if ( overRight > 0 ) {
  1009. newOverLeft = position.left - data.collisionPosition.marginLeft + myOffset +
  1010. atOffset + offset - offsetLeft;
  1011. if ( newOverLeft > 0 || abs( newOverLeft ) < overRight ) {
  1012. position.left += myOffset + atOffset + offset;
  1013. }
  1014. }
  1015. },
  1016. top: function( position, data ) {
  1017. var within = data.within,
  1018. withinOffset = within.offset.top + within.scrollTop,
  1019. outerHeight = within.height,
  1020. offsetTop = within.isWindow ? within.scrollTop : within.offset.top,
  1021. collisionPosTop = position.top - data.collisionPosition.marginTop,
  1022. overTop = collisionPosTop - offsetTop,
  1023. overBottom = collisionPosTop + data.collisionHeight - outerHeight - offsetTop,
  1024. top = data.my[ 1 ] === "top",
  1025. myOffset = top ?
  1026. -data.elemHeight :
  1027. data.my[ 1 ] === "bottom" ?
  1028. data.elemHeight :
  1029. 0,
  1030. atOffset = data.at[ 1 ] === "top" ?
  1031. data.targetHeight :
  1032. data.at[ 1 ] === "bottom" ?
  1033. -data.targetHeight :
  1034. 0,
  1035. offset = -2 * data.offset[ 1 ],
  1036. newOverTop,
  1037. newOverBottom;
  1038. if ( overTop < 0 ) {
  1039. newOverBottom = position.top + myOffset + atOffset + offset + data.collisionHeight -
  1040. outerHeight - withinOffset;
  1041. if ( newOverBottom < 0 || newOverBottom < abs( overTop ) ) {
  1042. position.top += myOffset + atOffset + offset;
  1043. }
  1044. } else if ( overBottom > 0 ) {
  1045. newOverTop = position.top - data.collisionPosition.marginTop + myOffset + atOffset +
  1046. offset - offsetTop;
  1047. if ( newOverTop > 0 || abs( newOverTop ) < overBottom ) {
  1048. position.top += myOffset + atOffset + offset;
  1049. }
  1050. }
  1051. }
  1052. },
  1053. flipfit: {
  1054. left: function() {
  1055. $.ui.position.flip.left.apply( this, arguments );
  1056. $.ui.position.fit.left.apply( this, arguments );
  1057. },
  1058. top: function() {
  1059. $.ui.position.flip.top.apply( this, arguments );
  1060. $.ui.position.fit.top.apply( this, arguments );
  1061. }
  1062. }
  1063. };
  1064. } )();
  1065. var position = $.ui.position;
  1066. /*!
  1067. * jQuery UI :data 1.13.2
  1068. * http://jqueryui.com
  1069. *
  1070. * Copyright jQuery Foundation and other contributors
  1071. * Released under the MIT license.
  1072. * http://jquery.org/license
  1073. */
  1074. //>>label: :data Selector
  1075. //>>group: Core
  1076. //>>description: Selects elements which have data stored under the specified key.
  1077. //>>docs: http://api.jqueryui.com/data-selector/
  1078. var data = $.extend( $.expr.pseudos, {
  1079. data: $.expr.createPseudo ?
  1080. $.expr.createPseudo( function( dataName ) {
  1081. return function( elem ) {
  1082. return !!$.data( elem, dataName );
  1083. };
  1084. } ) :
  1085. // Support: jQuery <1.8
  1086. function( elem, i, match ) {
  1087. return !!$.data( elem, match[ 3 ] );
  1088. }
  1089. } );
  1090. /*!
  1091. * jQuery UI Disable Selection 1.13.2
  1092. * http://jqueryui.com
  1093. *
  1094. * Copyright jQuery Foundation and other contributors
  1095. * Released under the MIT license.
  1096. * http://jquery.org/license
  1097. */
  1098. //>>label: disableSelection
  1099. //>>group: Core
  1100. //>>description: Disable selection of text content within the set of matched elements.
  1101. //>>docs: http://api.jqueryui.com/disableSelection/
  1102. // This file is deprecated
  1103. var disableSelection = $.fn.extend( {
  1104. disableSelection: ( function() {
  1105. var eventType = "onselectstart" in document.createElement( "div" ) ?
  1106. "selectstart" :
  1107. "mousedown";
  1108. return function() {
  1109. return this.on( eventType + ".ui-disableSelection", function( event ) {
  1110. event.preventDefault();
  1111. } );
  1112. };
  1113. } )(),
  1114. enableSelection: function() {
  1115. return this.off( ".ui-disableSelection" );
  1116. }
  1117. } );
  1118. // Create a local jQuery because jQuery Color relies on it and the
  1119. // global may not exist with AMD and a custom build (#10199).
  1120. // This module is a noop if used as a regular AMD module.
  1121. // eslint-disable-next-line no-unused-vars
  1122. var jQuery = $;
  1123. /*!
  1124. * jQuery Color Animations v2.2.0
  1125. * https://github.com/jquery/jquery-color
  1126. *
  1127. * Copyright OpenJS Foundation and other contributors
  1128. * Released under the MIT license.
  1129. * http://jquery.org/license
  1130. *
  1131. * Date: Sun May 10 09:02:36 2020 +0200
  1132. */
  1133. var stepHooks = "backgroundColor borderBottomColor borderLeftColor borderRightColor " +
  1134. "borderTopColor color columnRuleColor outlineColor textDecorationColor textEmphasisColor",
  1135. class2type = {},
  1136. toString = class2type.toString,
  1137. // plusequals test for += 100 -= 100
  1138. rplusequals = /^([\-+])=\s*(\d+\.?\d*)/,
  1139. // a set of RE's that can match strings and generate color tuples.
  1140. stringParsers = [ {
  1141. re: /rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(?:,\s*(\d?(?:\.\d+)?)\s*)?\)/,
  1142. parse: function( execResult ) {
  1143. return [
  1144. execResult[ 1 ],
  1145. execResult[ 2 ],
  1146. execResult[ 3 ],
  1147. execResult[ 4 ]
  1148. ];
  1149. }
  1150. }, {
  1151. re: /rgba?\(\s*(\d+(?:\.\d+)?)\%\s*,\s*(\d+(?:\.\d+)?)\%\s*,\s*(\d+(?:\.\d+)?)\%\s*(?:,\s*(\d?(?:\.\d+)?)\s*)?\)/,
  1152. parse: function( execResult ) {
  1153. return [
  1154. execResult[ 1 ] * 2.55,
  1155. execResult[ 2 ] * 2.55,
  1156. execResult[ 3 ] * 2.55,
  1157. execResult[ 4 ]
  1158. ];
  1159. }
  1160. }, {
  1161. // this regex ignores A-F because it's compared against an already lowercased string
  1162. re: /#([a-f0-9]{2})([a-f0-9]{2})([a-f0-9]{2})([a-f0-9]{2})?/,
  1163. parse: function( execResult ) {
  1164. return [
  1165. parseInt( execResult[ 1 ], 16 ),
  1166. parseInt( execResult[ 2 ], 16 ),
  1167. parseInt( execResult[ 3 ], 16 ),
  1168. execResult[ 4 ] ?
  1169. ( parseInt( execResult[ 4 ], 16 ) / 255 ).toFixed( 2 ) :
  1170. 1
  1171. ];
  1172. }
  1173. }, {
  1174. // this regex ignores A-F because it's compared against an already lowercased string
  1175. re: /#([a-f0-9])([a-f0-9])([a-f0-9])([a-f0-9])?/,
  1176. parse: function( execResult ) {
  1177. return [
  1178. parseInt( execResult[ 1 ] + execResult[ 1 ], 16 ),
  1179. parseInt( execResult[ 2 ] + execResult[ 2 ], 16 ),
  1180. parseInt( execResult[ 3 ] + execResult[ 3 ], 16 ),
  1181. execResult[ 4 ] ?
  1182. ( parseInt( execResult[ 4 ] + execResult[ 4 ], 16 ) / 255 )
  1183. .toFixed( 2 ) :
  1184. 1
  1185. ];
  1186. }
  1187. }, {
  1188. re: /hsla?\(\s*(\d+(?:\.\d+)?)\s*,\s*(\d+(?:\.\d+)?)\%\s*,\s*(\d+(?:\.\d+)?)\%\s*(?:,\s*(\d?(?:\.\d+)?)\s*)?\)/,
  1189. space: "hsla",
  1190. parse: function( execResult ) {
  1191. return [
  1192. execResult[ 1 ],
  1193. execResult[ 2 ] / 100,
  1194. execResult[ 3 ] / 100,
  1195. execResult[ 4 ]
  1196. ];
  1197. }
  1198. } ],
  1199. // jQuery.Color( )
  1200. color = jQuery.Color = function( color, green, blue, alpha ) {
  1201. return new jQuery.Color.fn.parse( color, green, blue, alpha );
  1202. },
  1203. spaces = {
  1204. rgba: {
  1205. props: {
  1206. red: {
  1207. idx: 0,
  1208. type: "byte"
  1209. },
  1210. green: {
  1211. idx: 1,
  1212. type: "byte"
  1213. },
  1214. blue: {
  1215. idx: 2,
  1216. type: "byte"
  1217. }
  1218. }
  1219. },
  1220. hsla: {
  1221. props: {
  1222. hue: {
  1223. idx: 0,
  1224. type: "degrees"
  1225. },
  1226. saturation: {
  1227. idx: 1,
  1228. type: "percent"
  1229. },
  1230. lightness: {
  1231. idx: 2,
  1232. type: "percent"
  1233. }
  1234. }
  1235. }
  1236. },
  1237. propTypes = {
  1238. "byte": {
  1239. floor: true,
  1240. max: 255
  1241. },
  1242. "percent": {
  1243. max: 1
  1244. },
  1245. "degrees": {
  1246. mod: 360,
  1247. floor: true
  1248. }
  1249. },
  1250. support = color.support = {},
  1251. // element for support tests
  1252. supportElem = jQuery( "<p>" )[ 0 ],
  1253. // colors = jQuery.Color.names
  1254. colors,
  1255. // local aliases of functions called often
  1256. each = jQuery.each;
  1257. // determine rgba support immediately
  1258. supportElem.style.cssText = "background-color:rgba(1,1,1,.5)";
  1259. support.rgba = supportElem.style.backgroundColor.indexOf( "rgba" ) > -1;
  1260. // define cache name and alpha properties
  1261. // for rgba and hsla spaces
  1262. each( spaces, function( spaceName, space ) {
  1263. space.cache = "_" + spaceName;
  1264. space.props.alpha = {
  1265. idx: 3,
  1266. type: "percent",
  1267. def: 1
  1268. };
  1269. } );
  1270. // Populate the class2type map
  1271. jQuery.each( "Boolean Number String Function Array Date RegExp Object Error Symbol".split( " " ),
  1272. function( _i, name ) {
  1273. class2type[ "[object " + name + "]" ] = name.toLowerCase();
  1274. } );
  1275. function getType( obj ) {
  1276. if ( obj == null ) {
  1277. return obj + "";
  1278. }
  1279. return typeof obj === "object" ?
  1280. class2type[ toString.call( obj ) ] || "object" :
  1281. typeof obj;
  1282. }
  1283. function clamp( value, prop, allowEmpty ) {
  1284. var type = propTypes[ prop.type ] || {};
  1285. if ( value == null ) {
  1286. return ( allowEmpty || !prop.def ) ? null : prop.def;
  1287. }
  1288. // ~~ is an short way of doing floor for positive numbers
  1289. value = type.floor ? ~~value : parseFloat( value );
  1290. // IE will pass in empty strings as value for alpha,
  1291. // which will hit this case
  1292. if ( isNaN( value ) ) {
  1293. return prop.def;
  1294. }
  1295. if ( type.mod ) {
  1296. // we add mod before modding to make sure that negatives values
  1297. // get converted properly: -10 -> 350
  1298. return ( value + type.mod ) % type.mod;
  1299. }
  1300. // for now all property types without mod have min and max
  1301. return Math.min( type.max, Math.max( 0, value ) );
  1302. }
  1303. function stringParse( string ) {
  1304. var inst = color(),
  1305. rgba = inst._rgba = [];
  1306. string = string.toLowerCase();
  1307. each( stringParsers, function( _i, parser ) {
  1308. var parsed,
  1309. match = parser.re.exec( string ),
  1310. values = match && parser.parse( match ),
  1311. spaceName = parser.space || "rgba";
  1312. if ( values ) {
  1313. parsed = inst[ spaceName ]( values );
  1314. // if this was an rgba parse the assignment might happen twice
  1315. // oh well....
  1316. inst[ spaces[ spaceName ].cache ] = parsed[ spaces[ spaceName ].cache ];
  1317. rgba = inst._rgba = parsed._rgba;
  1318. // exit each( stringParsers ) here because we matched
  1319. return false;
  1320. }
  1321. } );
  1322. // Found a stringParser that handled it
  1323. if ( rgba.length ) {
  1324. // if this came from a parsed string, force "transparent" when alpha is 0
  1325. // chrome, (and maybe others) return "transparent" as rgba(0,0,0,0)
  1326. if ( rgba.join() === "0,0,0,0" ) {
  1327. jQuery.extend( rgba, colors.transparent );
  1328. }
  1329. return inst;
  1330. }
  1331. // named colors
  1332. return colors[ string ];
  1333. }
  1334. color.fn = jQuery.extend( color.prototype, {
  1335. parse: function( red, green, blue, alpha ) {
  1336. if ( red === undefined ) {
  1337. this._rgba = [ null, null, null, null ];
  1338. return this;
  1339. }
  1340. if ( red.jquery || red.nodeType ) {
  1341. red = jQuery( red ).css( green );
  1342. green = undefined;
  1343. }
  1344. var inst = this,
  1345. type = getType( red ),
  1346. rgba = this._rgba = [];
  1347. // more than 1 argument specified - assume ( red, green, blue, alpha )
  1348. if ( green !== undefined ) {
  1349. red = [ red, green, blue, alpha ];
  1350. type = "array";
  1351. }
  1352. if ( type === "string" ) {
  1353. return this.parse( stringParse( red ) || colors._default );
  1354. }
  1355. if ( type === "array" ) {
  1356. each( spaces.rgba.props, function( _key, prop ) {
  1357. rgba[ prop.idx ] = clamp( red[ prop.idx ], prop );
  1358. } );
  1359. return this;
  1360. }
  1361. if ( type === "object" ) {
  1362. if ( red instanceof color ) {
  1363. each( spaces, function( _spaceName, space ) {
  1364. if ( red[ space.cache ] ) {
  1365. inst[ space.cache ] = red[ space.cache ].slice();
  1366. }
  1367. } );
  1368. } else {
  1369. each( spaces, function( _spaceName, space ) {
  1370. var cache = space.cache;
  1371. each( space.props, function( key, prop ) {
  1372. // if the cache doesn't exist, and we know how to convert
  1373. if ( !inst[ cache ] && space.to ) {
  1374. // if the value was null, we don't need to copy it
  1375. // if the key was alpha, we don't need to copy it either
  1376. if ( key === "alpha" || red[ key ] == null ) {
  1377. return;
  1378. }
  1379. inst[ cache ] = space.to( inst._rgba );
  1380. }
  1381. // this is the only case where we allow nulls for ALL properties.
  1382. // call clamp with alwaysAllowEmpty
  1383. inst[ cache ][ prop.idx ] = clamp( red[ key ], prop, true );
  1384. } );
  1385. // everything defined but alpha?
  1386. if ( inst[ cache ] && jQuery.inArray( null, inst[ cache ].slice( 0, 3 ) ) < 0 ) {
  1387. // use the default of 1
  1388. if ( inst[ cache ][ 3 ] == null ) {
  1389. inst[ cache ][ 3 ] = 1;
  1390. }
  1391. if ( space.from ) {
  1392. inst._rgba = space.from( inst[ cache ] );
  1393. }
  1394. }
  1395. } );
  1396. }
  1397. return this;
  1398. }
  1399. },
  1400. is: function( compare ) {
  1401. var is = color( compare ),
  1402. same = true,
  1403. inst = this;
  1404. each( spaces, function( _, space ) {
  1405. var localCache,
  1406. isCache = is[ space.cache ];
  1407. if ( isCache ) {
  1408. localCache = inst[ space.cache ] || space.to && space.to( inst._rgba ) || [];
  1409. each( space.props, function( _, prop ) {
  1410. if ( isCache[ prop.idx ] != null ) {
  1411. same = ( isCache[ prop.idx ] === localCache[ prop.idx ] );
  1412. return same;
  1413. }
  1414. } );
  1415. }
  1416. return same;
  1417. } );
  1418. return same;
  1419. },
  1420. _space: function() {
  1421. var used = [],
  1422. inst = this;
  1423. each( spaces, function( spaceName, space ) {
  1424. if ( inst[ space.cache ] ) {
  1425. used.push( spaceName );
  1426. }
  1427. } );
  1428. return used.pop();
  1429. },
  1430. transition: function( other, distance ) {
  1431. var end = color( other ),
  1432. spaceName = end._space(),
  1433. space = spaces[ spaceName ],
  1434. startColor = this.alpha() === 0 ? color( "transparent" ) : this,
  1435. start = startColor[ space.cache ] || space.to( startColor._rgba ),
  1436. result = start.slice();
  1437. end = end[ space.cache ];
  1438. each( space.props, function( _key, prop ) {
  1439. var index = prop.idx,
  1440. startValue = start[ index ],
  1441. endValue = end[ index ],
  1442. type = propTypes[ prop.type ] || {};
  1443. // if null, don't override start value
  1444. if ( endValue === null ) {
  1445. return;
  1446. }
  1447. // if null - use end
  1448. if ( startValue === null ) {
  1449. result[ index ] = endValue;
  1450. } else {
  1451. if ( type.mod ) {
  1452. if ( endValue - startValue > type.mod / 2 ) {
  1453. startValue += type.mod;
  1454. } else if ( startValue - endValue > type.mod / 2 ) {
  1455. startValue -= type.mod;
  1456. }
  1457. }
  1458. result[ index ] = clamp( ( endValue - startValue ) * distance + startValue, prop );
  1459. }
  1460. } );
  1461. return this[ spaceName ]( result );
  1462. },
  1463. blend: function( opaque ) {
  1464. // if we are already opaque - return ourself
  1465. if ( this._rgba[ 3 ] === 1 ) {
  1466. return this;
  1467. }
  1468. var rgb = this._rgba.slice(),
  1469. a = rgb.pop(),
  1470. blend = color( opaque )._rgba;
  1471. return color( jQuery.map( rgb, function( v, i ) {
  1472. return ( 1 - a ) * blend[ i ] + a * v;
  1473. } ) );
  1474. },
  1475. toRgbaString: function() {
  1476. var prefix = "rgba(",
  1477. rgba = jQuery.map( this._rgba, function( v, i ) {
  1478. if ( v != null ) {
  1479. return v;
  1480. }
  1481. return i > 2 ? 1 : 0;
  1482. } );
  1483. if ( rgba[ 3 ] === 1 ) {
  1484. rgba.pop();
  1485. prefix = "rgb(";
  1486. }
  1487. return prefix + rgba.join() + ")";
  1488. },
  1489. toHslaString: function() {
  1490. var prefix = "hsla(",
  1491. hsla = jQuery.map( this.hsla(), function( v, i ) {
  1492. if ( v == null ) {
  1493. v = i > 2 ? 1 : 0;
  1494. }
  1495. // catch 1 and 2
  1496. if ( i && i < 3 ) {
  1497. v = Math.round( v * 100 ) + "%";
  1498. }
  1499. return v;
  1500. } );
  1501. if ( hsla[ 3 ] === 1 ) {
  1502. hsla.pop();
  1503. prefix = "hsl(";
  1504. }
  1505. return prefix + hsla.join() + ")";
  1506. },
  1507. toHexString: function( includeAlpha ) {
  1508. var rgba = this._rgba.slice(),
  1509. alpha = rgba.pop();
  1510. if ( includeAlpha ) {
  1511. rgba.push( ~~( alpha * 255 ) );
  1512. }
  1513. return "#" + jQuery.map( rgba, function( v ) {
  1514. // default to 0 when nulls exist
  1515. v = ( v || 0 ).toString( 16 );
  1516. return v.length === 1 ? "0" + v : v;
  1517. } ).join( "" );
  1518. },
  1519. toString: function() {
  1520. return this._rgba[ 3 ] === 0 ? "transparent" : this.toRgbaString();
  1521. }
  1522. } );
  1523. color.fn.parse.prototype = color.fn;
  1524. // hsla conversions adapted from:
  1525. // https://code.google.com/p/maashaack/source/browse/packages/graphics/trunk/src/graphics/colors/HUE2RGB.as?r=5021
  1526. function hue2rgb( p, q, h ) {
  1527. h = ( h + 1 ) % 1;
  1528. if ( h * 6 < 1 ) {
  1529. return p + ( q - p ) * h * 6;
  1530. }
  1531. if ( h * 2 < 1 ) {
  1532. return q;
  1533. }
  1534. if ( h * 3 < 2 ) {
  1535. return p + ( q - p ) * ( ( 2 / 3 ) - h ) * 6;
  1536. }
  1537. return p;
  1538. }
  1539. spaces.hsla.to = function( rgba ) {
  1540. if ( rgba[ 0 ] == null || rgba[ 1 ] == null || rgba[ 2 ] == null ) {
  1541. return [ null, null, null, rgba[ 3 ] ];
  1542. }
  1543. var r = rgba[ 0 ] / 255,
  1544. g = rgba[ 1 ] / 255,
  1545. b = rgba[ 2 ] / 255,
  1546. a = rgba[ 3 ],
  1547. max = Math.max( r, g, b ),
  1548. min = Math.min( r, g, b ),
  1549. diff = max - min,
  1550. add = max + min,
  1551. l = add * 0.5,
  1552. h, s;
  1553. if ( min === max ) {
  1554. h = 0;
  1555. } else if ( r === max ) {
  1556. h = ( 60 * ( g - b ) / diff ) + 360;
  1557. } else if ( g === max ) {
  1558. h = ( 60 * ( b - r ) / diff ) + 120;
  1559. } else {
  1560. h = ( 60 * ( r - g ) / diff ) + 240;
  1561. }
  1562. // chroma (diff) == 0 means greyscale which, by definition, saturation = 0%
  1563. // otherwise, saturation is based on the ratio of chroma (diff) to lightness (add)
  1564. if ( diff === 0 ) {
  1565. s = 0;
  1566. } else if ( l <= 0.5 ) {
  1567. s = diff / add;
  1568. } else {
  1569. s = diff / ( 2 - add );
  1570. }
  1571. return [ Math.round( h ) % 360, s, l, a == null ? 1 : a ];
  1572. };
  1573. spaces.hsla.from = function( hsla ) {
  1574. if ( hsla[ 0 ] == null || hsla[ 1 ] == null || hsla[ 2 ] == null ) {
  1575. return [ null, null, null, hsla[ 3 ] ];
  1576. }
  1577. var h = hsla[ 0 ] / 360,
  1578. s = hsla[ 1 ],
  1579. l = hsla[ 2 ],
  1580. a = hsla[ 3 ],
  1581. q = l <= 0.5 ? l * ( 1 + s ) : l + s - l * s,
  1582. p = 2 * l - q;
  1583. return [
  1584. Math.round( hue2rgb( p, q, h + ( 1 / 3 ) ) * 255 ),
  1585. Math.round( hue2rgb( p, q, h ) * 255 ),
  1586. Math.round( hue2rgb( p, q, h - ( 1 / 3 ) ) * 255 ),
  1587. a
  1588. ];
  1589. };
  1590. each( spaces, function( spaceName, space ) {
  1591. var props = space.props,
  1592. cache = space.cache,
  1593. to = space.to,
  1594. from = space.from;
  1595. // makes rgba() and hsla()
  1596. color.fn[ spaceName ] = function( value ) {
  1597. // generate a cache for this space if it doesn't exist
  1598. if ( to && !this[ cache ] ) {
  1599. this[ cache ] = to( this._rgba );
  1600. }
  1601. if ( value === undefined ) {
  1602. return this[ cache ].slice();
  1603. }
  1604. var ret,
  1605. type = getType( value ),
  1606. arr = ( type === "array" || type === "object" ) ? value : arguments,
  1607. local = this[ cache ].slice();
  1608. each( props, function( key, prop ) {
  1609. var val = arr[ type === "object" ? key : prop.idx ];
  1610. if ( val == null ) {
  1611. val = local[ prop.idx ];
  1612. }
  1613. local[ prop.idx ] = clamp( val, prop );
  1614. } );
  1615. if ( from ) {
  1616. ret = color( from( local ) );
  1617. ret[ cache ] = local;
  1618. return ret;
  1619. } else {
  1620. return color( local );
  1621. }
  1622. };
  1623. // makes red() green() blue() alpha() hue() saturation() lightness()
  1624. each( props, function( key, prop ) {
  1625. // alpha is included in more than one space
  1626. if ( color.fn[ key ] ) {
  1627. return;
  1628. }
  1629. color.fn[ key ] = function( value ) {
  1630. var local, cur, match, fn,
  1631. vtype = getType( value );
  1632. if ( key === "alpha" ) {
  1633. fn = this._hsla ? "hsla" : "rgba";
  1634. } else {
  1635. fn = spaceName;
  1636. }
  1637. local = this[ fn ]();
  1638. cur = local[ prop.idx ];
  1639. if ( vtype === "undefined" ) {
  1640. return cur;
  1641. }
  1642. if ( vtype === "function" ) {
  1643. value = value.call( this, cur );
  1644. vtype = getType( value );
  1645. }
  1646. if ( value == null && prop.empty ) {
  1647. return this;
  1648. }
  1649. if ( vtype === "string" ) {
  1650. match = rplusequals.exec( value );
  1651. if ( match ) {
  1652. value = cur + parseFloat( match[ 2 ] ) * ( match[ 1 ] === "+" ? 1 : -1 );
  1653. }
  1654. }
  1655. local[ prop.idx ] = value;
  1656. return this[ fn ]( local );
  1657. };
  1658. } );
  1659. } );
  1660. // add cssHook and .fx.step function for each named hook.
  1661. // accept a space separated string of properties
  1662. color.hook = function( hook ) {
  1663. var hooks = hook.split( " " );
  1664. each( hooks, function( _i, hook ) {
  1665. jQuery.cssHooks[ hook ] = {
  1666. set: function( elem, value ) {
  1667. var parsed, curElem,
  1668. backgroundColor = "";
  1669. if ( value !== "transparent" && ( getType( value ) !== "string" || ( parsed = stringParse( value ) ) ) ) {
  1670. value = color( parsed || value );
  1671. if ( !support.rgba && value._rgba[ 3 ] !== 1 ) {
  1672. curElem = hook === "backgroundColor" ? elem.parentNode : elem;
  1673. while (
  1674. ( backgroundColor === "" || backgroundColor === "transparent" ) &&
  1675. curElem && curElem.style
  1676. ) {
  1677. try {
  1678. backgroundColor = jQuery.css( curElem, "backgroundColor" );
  1679. curElem = curElem.parentNode;
  1680. } catch ( e ) {
  1681. }
  1682. }
  1683. value = value.blend( backgroundColor && backgroundColor !== "transparent" ?
  1684. backgroundColor :
  1685. "_default" );
  1686. }
  1687. value = value.toRgbaString();
  1688. }
  1689. try {
  1690. elem.style[ hook ] = value;
  1691. } catch ( e ) {
  1692. // wrapped to prevent IE from throwing errors on "invalid" values like 'auto' or 'inherit'
  1693. }
  1694. }
  1695. };
  1696. jQuery.fx.step[ hook ] = function( fx ) {
  1697. if ( !fx.colorInit ) {
  1698. fx.start = color( fx.elem, hook );
  1699. fx.end = color( fx.end );
  1700. fx.colorInit = true;
  1701. }
  1702. jQuery.cssHooks[ hook ].set( fx.elem, fx.start.transition( fx.end, fx.pos ) );
  1703. };
  1704. } );
  1705. };
  1706. color.hook( stepHooks );
  1707. jQuery.cssHooks.borderColor = {
  1708. expand: function( value ) {
  1709. var expanded = {};
  1710. each( [ "Top", "Right", "Bottom", "Left" ], function( _i, part ) {
  1711. expanded[ "border" + part + "Color" ] = value;
  1712. } );
  1713. return expanded;
  1714. }
  1715. };
  1716. // Basic color names only.
  1717. // Usage of any of the other color names requires adding yourself or including
  1718. // jquery.color.svg-names.js.
  1719. colors = jQuery.Color.names = {
  1720. // 4.1. Basic color keywords
  1721. aqua: "#00ffff",
  1722. black: "#000000",
  1723. blue: "#0000ff",
  1724. fuchsia: "#ff00ff",
  1725. gray: "#808080",
  1726. green: "#008000",
  1727. lime: "#00ff00",
  1728. maroon: "#800000",
  1729. navy: "#000080",
  1730. olive: "#808000",
  1731. purple: "#800080",
  1732. red: "#ff0000",
  1733. silver: "#c0c0c0",
  1734. teal: "#008080",
  1735. white: "#ffffff",
  1736. yellow: "#ffff00",
  1737. // 4.2.3. "transparent" color keyword
  1738. transparent: [ null, null, null, 0 ],
  1739. _default: "#ffffff"
  1740. };
  1741. /*!
  1742. * jQuery UI Effects 1.13.2
  1743. * http://jqueryui.com
  1744. *
  1745. * Copyright jQuery Foundation and other contributors
  1746. * Released under the MIT license.
  1747. * http://jquery.org/license
  1748. */
  1749. //>>label: Effects Core
  1750. //>>group: Effects
  1751. /* eslint-disable max-len */
  1752. //>>description: Extends the internal jQuery effects. Includes morphing and easing. Required by all other effects.
  1753. /* eslint-enable max-len */
  1754. //>>docs: http://api.jqueryui.com/category/effects-core/
  1755. //>>demos: http://jqueryui.com/effect/
  1756. var dataSpace = "ui-effects-",
  1757. dataSpaceStyle = "ui-effects-style",
  1758. dataSpaceAnimated = "ui-effects-animated";
  1759. $.effects = {
  1760. effect: {}
  1761. };
  1762. /******************************************************************************/
  1763. /****************************** CLASS ANIMATIONS ******************************/
  1764. /******************************************************************************/
  1765. ( function() {
  1766. var classAnimationActions = [ "add", "remove", "toggle" ],
  1767. shorthandStyles = {
  1768. border: 1,
  1769. borderBottom: 1,
  1770. borderColor: 1,
  1771. borderLeft: 1,
  1772. borderRight: 1,
  1773. borderTop: 1,
  1774. borderWidth: 1,
  1775. margin: 1,
  1776. padding: 1
  1777. };
  1778. $.each(
  1779. [ "borderLeftStyle", "borderRightStyle", "borderBottomStyle", "borderTopStyle" ],
  1780. function( _, prop ) {
  1781. $.fx.step[ prop ] = function( fx ) {
  1782. if ( fx.end !== "none" && !fx.setAttr || fx.pos === 1 && !fx.setAttr ) {
  1783. jQuery.style( fx.elem, prop, fx.end );
  1784. fx.setAttr = true;
  1785. }
  1786. };
  1787. }
  1788. );
  1789. function camelCase( string ) {
  1790. return string.replace( /-([\da-z])/gi, function( all, letter ) {
  1791. return letter.toUpperCase();
  1792. } );
  1793. }
  1794. function getElementStyles( elem ) {
  1795. var key, len,
  1796. style = elem.ownerDocument.defaultView ?
  1797. elem.ownerDocument.defaultView.getComputedStyle( elem, null ) :
  1798. elem.currentStyle,
  1799. styles = {};
  1800. if ( style && style.length && style[ 0 ] && style[ style[ 0 ] ] ) {
  1801. len = style.length;
  1802. while ( len-- ) {
  1803. key = style[ len ];
  1804. if ( typeof style[ key ] === "string" ) {
  1805. styles[ camelCase( key ) ] = style[ key ];
  1806. }
  1807. }
  1808. // Support: Opera, IE <9
  1809. } else {
  1810. for ( key in style ) {
  1811. if ( typeof style[ key ] === "string" ) {
  1812. styles[ key ] = style[ key ];
  1813. }
  1814. }
  1815. }
  1816. return styles;
  1817. }
  1818. function styleDifference( oldStyle, newStyle ) {
  1819. var diff = {},
  1820. name, value;
  1821. for ( name in newStyle ) {
  1822. value = newStyle[ name ];
  1823. if ( oldStyle[ name ] !== value ) {
  1824. if ( !shorthandStyles[ name ] ) {
  1825. if ( $.fx.step[ name ] || !isNaN( parseFloat( value ) ) ) {
  1826. diff[ name ] = value;
  1827. }
  1828. }
  1829. }
  1830. }
  1831. return diff;
  1832. }
  1833. // Support: jQuery <1.8
  1834. if ( !$.fn.addBack ) {
  1835. $.fn.addBack = function( selector ) {
  1836. return this.add( selector == null ?
  1837. this.prevObject : this.prevObject.filter( selector )
  1838. );
  1839. };
  1840. }
  1841. $.effects.animateClass = function( value, duration, easing, callback ) {
  1842. var o = $.speed( duration, easing, callback );
  1843. return this.queue( function() {
  1844. var animated = $( this ),
  1845. baseClass = animated.attr( "class" ) || "",
  1846. applyClassChange,
  1847. allAnimations = o.children ? animated.find( "*" ).addBack() : animated;
  1848. // Map the animated objects to store the original styles.
  1849. allAnimations = allAnimations.map( function() {
  1850. var el = $( this );
  1851. return {
  1852. el: el,
  1853. start: getElementStyles( this )
  1854. };
  1855. } );
  1856. // Apply class change
  1857. applyClassChange = function() {
  1858. $.each( classAnimationActions, function( i, action ) {
  1859. if ( value[ action ] ) {
  1860. animated[ action + "Class" ]( value[ action ] );
  1861. }
  1862. } );
  1863. };
  1864. applyClassChange();
  1865. // Map all animated objects again - calculate new styles and diff
  1866. allAnimations = allAnimations.map( function() {
  1867. this.end = getElementStyles( this.el[ 0 ] );
  1868. this.diff = styleDifference( this.start, this.end );
  1869. return this;
  1870. } );
  1871. // Apply original class
  1872. animated.attr( "class", baseClass );
  1873. // Map all animated objects again - this time collecting a promise
  1874. allAnimations = allAnimations.map( function() {
  1875. var styleInfo = this,
  1876. dfd = $.Deferred(),
  1877. opts = $.extend( {}, o, {
  1878. queue: false,
  1879. complete: function() {
  1880. dfd.resolve( styleInfo );
  1881. }
  1882. } );
  1883. this.el.animate( this.diff, opts );
  1884. return dfd.promise();
  1885. } );
  1886. // Once all animations have completed:
  1887. $.when.apply( $, allAnimations.get() ).done( function() {
  1888. // Set the final class
  1889. applyClassChange();
  1890. // For each animated element,
  1891. // clear all css properties that were animated
  1892. $.each( arguments, function() {
  1893. var el = this.el;
  1894. $.each( this.diff, function( key ) {
  1895. el.css( key, "" );
  1896. } );
  1897. } );
  1898. // This is guarnteed to be there if you use jQuery.speed()
  1899. // it also handles dequeuing the next anim...
  1900. o.complete.call( animated[ 0 ] );
  1901. } );
  1902. } );
  1903. };
  1904. $.fn.extend( {
  1905. addClass: ( function( orig ) {
  1906. return function( classNames, speed, easing, callback ) {
  1907. return speed ?
  1908. $.effects.animateClass.call( this,
  1909. { add: classNames }, speed, easing, callback ) :
  1910. orig.apply( this, arguments );
  1911. };
  1912. } )( $.fn.addClass ),
  1913. removeClass: ( function( orig ) {
  1914. return function( classNames, speed, easing, callback ) {
  1915. return arguments.length > 1 ?
  1916. $.effects.animateClass.call( this,
  1917. { remove: classNames }, speed, easing, callback ) :
  1918. orig.apply( this, arguments );
  1919. };
  1920. } )( $.fn.removeClass ),
  1921. toggleClass: ( function( orig ) {
  1922. return function( classNames, force, speed, easing, callback ) {
  1923. if ( typeof force === "boolean" || force === undefined ) {
  1924. if ( !speed ) {
  1925. // Without speed parameter
  1926. return orig.apply( this, arguments );
  1927. } else {
  1928. return $.effects.animateClass.call( this,
  1929. ( force ? { add: classNames } : { remove: classNames } ),
  1930. speed, easing, callback );
  1931. }
  1932. } else {
  1933. // Without force parameter
  1934. return $.effects.animateClass.call( this,
  1935. { toggle: classNames }, force, speed, easing );
  1936. }
  1937. };
  1938. } )( $.fn.toggleClass ),
  1939. switchClass: function( remove, add, speed, easing, callback ) {
  1940. return $.effects.animateClass.call( this, {
  1941. add: add,
  1942. remove: remove
  1943. }, speed, easing, callback );
  1944. }
  1945. } );
  1946. } )();
  1947. /******************************************************************************/
  1948. /*********************************** EFFECTS **********************************/
  1949. /******************************************************************************/
  1950. ( function() {
  1951. if ( $.expr && $.expr.pseudos && $.expr.pseudos.animated ) {
  1952. $.expr.pseudos.animated = ( function( orig ) {
  1953. return function( elem ) {
  1954. return !!$( elem ).data( dataSpaceAnimated ) || orig( elem );
  1955. };
  1956. } )( $.expr.pseudos.animated );
  1957. }
  1958. if ( $.uiBackCompat !== false ) {
  1959. $.extend( $.effects, {
  1960. // Saves a set of properties in a data storage
  1961. save: function( element, set ) {
  1962. var i = 0, length = set.length;
  1963. for ( ; i < length; i++ ) {
  1964. if ( set[ i ] !== null ) {
  1965. element.data( dataSpace + set[ i ], element[ 0 ].style[ set[ i ] ] );
  1966. }
  1967. }
  1968. },
  1969. // Restores a set of previously saved properties from a data storage
  1970. restore: function( element, set ) {
  1971. var val, i = 0, length = set.length;
  1972. for ( ; i < length; i++ ) {
  1973. if ( set[ i ] !== null ) {
  1974. val = element.data( dataSpace + set[ i ] );
  1975. element.css( set[ i ], val );
  1976. }
  1977. }
  1978. },
  1979. setMode: function( el, mode ) {
  1980. if ( mode === "toggle" ) {
  1981. mode = el.is( ":hidden" ) ? "show" : "hide";
  1982. }
  1983. return mode;
  1984. },
  1985. // Wraps the element around a wrapper that copies position properties
  1986. createWrapper: function( element ) {
  1987. // If the element is already wrapped, return it
  1988. if ( element.parent().is( ".ui-effects-wrapper" ) ) {
  1989. return element.parent();
  1990. }
  1991. // Wrap the element
  1992. var props = {
  1993. width: element.outerWidth( true ),
  1994. height: element.outerHeight( true ),
  1995. "float": element.css( "float" )
  1996. },
  1997. wrapper = $( "<div></div>" )
  1998. .addClass( "ui-effects-wrapper" )
  1999. .css( {
  2000. fontSize: "100%",
  2001. background: "transparent",
  2002. border: "none",
  2003. margin: 0,
  2004. padding: 0
  2005. } ),
  2006. // Store the size in case width/height are defined in % - Fixes #5245
  2007. size = {
  2008. width: element.width(),
  2009. height: element.height()
  2010. },
  2011. active = document.activeElement;
  2012. // Support: Firefox
  2013. // Firefox incorrectly exposes anonymous content
  2014. // https://bugzilla.mozilla.org/show_bug.cgi?id=561664
  2015. try {
  2016. // eslint-disable-next-line no-unused-expressions
  2017. active.id;
  2018. } catch ( e ) {
  2019. active = document.body;
  2020. }
  2021. element.wrap( wrapper );
  2022. // Fixes #7595 - Elements lose focus when wrapped.
  2023. if ( element[ 0 ] === active || $.contains( element[ 0 ], active ) ) {
  2024. $( active ).trigger( "focus" );
  2025. }
  2026. // Hotfix for jQuery 1.4 since some change in wrap() seems to actually
  2027. // lose the reference to the wrapped element
  2028. wrapper = element.parent();
  2029. // Transfer positioning properties to the wrapper
  2030. if ( element.css( "position" ) === "static" ) {
  2031. wrapper.css( { position: "relative" } );
  2032. element.css( { position: "relative" } );
  2033. } else {
  2034. $.extend( props, {
  2035. position: element.css( "position" ),
  2036. zIndex: element.css( "z-index" )
  2037. } );
  2038. $.each( [ "top", "left", "bottom", "right" ], function( i, pos ) {
  2039. props[ pos ] = element.css( pos );
  2040. if ( isNaN( parseInt( props[ pos ], 10 ) ) ) {
  2041. props[ pos ] = "auto";
  2042. }
  2043. } );
  2044. element.css( {
  2045. position: "relative",
  2046. top: 0,
  2047. left: 0,
  2048. right: "auto",
  2049. bottom: "auto"
  2050. } );
  2051. }
  2052. element.css( size );
  2053. return wrapper.css( props ).show();
  2054. },
  2055. removeWrapper: function( element ) {
  2056. var active = document.activeElement;
  2057. if ( element.parent().is( ".ui-effects-wrapper" ) ) {
  2058. element.parent().replaceWith( element );
  2059. // Fixes #7595 - Elements lose focus when wrapped.
  2060. if ( element[ 0 ] === active || $.contains( element[ 0 ], active ) ) {
  2061. $( active ).trigger( "focus" );
  2062. }
  2063. }
  2064. return element;
  2065. }
  2066. } );
  2067. }
  2068. $.extend( $.effects, {
  2069. version: "1.13.2",
  2070. define: function( name, mode, effect ) {
  2071. if ( !effect ) {
  2072. effect = mode;
  2073. mode = "effect";
  2074. }
  2075. $.effects.effect[ name ] = effect;
  2076. $.effects.effect[ name ].mode = mode;
  2077. return effect;
  2078. },
  2079. scaledDimensions: function( element, percent, direction ) {
  2080. if ( percent === 0 ) {
  2081. return {
  2082. height: 0,
  2083. width: 0,
  2084. outerHeight: 0,
  2085. outerWidth: 0
  2086. };
  2087. }
  2088. var x = direction !== "horizontal" ? ( ( percent || 100 ) / 100 ) : 1,
  2089. y = direction !== "vertical" ? ( ( percent || 100 ) / 100 ) : 1;
  2090. return {
  2091. height: element.height() * y,
  2092. width: element.width() * x,
  2093. outerHeight: element.outerHeight() * y,
  2094. outerWidth: element.outerWidth() * x
  2095. };
  2096. },
  2097. clipToBox: function( animation ) {
  2098. return {
  2099. width: animation.clip.right - animation.clip.left,
  2100. height: animation.clip.bottom - animation.clip.top,
  2101. left: animation.clip.left,
  2102. top: animation.clip.top
  2103. };
  2104. },
  2105. // Injects recently queued functions to be first in line (after "inprogress")
  2106. unshift: function( element, queueLength, count ) {
  2107. var queue = element.queue();
  2108. if ( queueLength > 1 ) {
  2109. queue.splice.apply( queue,
  2110. [ 1, 0 ].concat( queue.splice( queueLength, count ) ) );
  2111. }
  2112. element.dequeue();
  2113. },
  2114. saveStyle: function( element ) {
  2115. element.data( dataSpaceStyle, element[ 0 ].style.cssText );
  2116. },
  2117. restoreStyle: function( element ) {
  2118. element[ 0 ].style.cssText = element.data( dataSpaceStyle ) || "";
  2119. element.removeData( dataSpaceStyle );
  2120. },
  2121. mode: function( element, mode ) {
  2122. var hidden = element.is( ":hidden" );
  2123. if ( mode === "toggle" ) {
  2124. mode = hidden ? "show" : "hide";
  2125. }
  2126. if ( hidden ? mode === "hide" : mode === "show" ) {
  2127. mode = "none";
  2128. }
  2129. return mode;
  2130. },
  2131. // Translates a [top,left] array into a baseline value
  2132. getBaseline: function( origin, original ) {
  2133. var y, x;
  2134. switch ( origin[ 0 ] ) {
  2135. case "top":
  2136. y = 0;
  2137. break;
  2138. case "middle":
  2139. y = 0.5;
  2140. break;
  2141. case "bottom":
  2142. y = 1;
  2143. break;
  2144. default:
  2145. y = origin[ 0 ] / original.height;
  2146. }
  2147. switch ( origin[ 1 ] ) {
  2148. case "left":
  2149. x = 0;
  2150. break;
  2151. case "center":
  2152. x = 0.5;
  2153. break;
  2154. case "right":
  2155. x = 1;
  2156. break;
  2157. default:
  2158. x = origin[ 1 ] / original.width;
  2159. }
  2160. return {
  2161. x: x,
  2162. y: y
  2163. };
  2164. },
  2165. // Creates a placeholder element so that the original element can be made absolute
  2166. createPlaceholder: function( element ) {
  2167. var placeholder,
  2168. cssPosition = element.css( "position" ),
  2169. position = element.position();
  2170. // Lock in margins first to account for form elements, which
  2171. // will change margin if you explicitly set height
  2172. // see: http://jsfiddle.net/JZSMt/3/ https://bugs.webkit.org/show_bug.cgi?id=107380
  2173. // Support: Safari
  2174. element.css( {
  2175. marginTop: element.css( "marginTop" ),
  2176. marginBottom: element.css( "marginBottom" ),
  2177. marginLeft: element.css( "marginLeft" ),
  2178. marginRight: element.css( "marginRight" )
  2179. } )
  2180. .outerWidth( element.outerWidth() )
  2181. .outerHeight( element.outerHeight() );
  2182. if ( /^(static|relative)/.test( cssPosition ) ) {
  2183. cssPosition = "absolute";
  2184. placeholder = $( "<" + element[ 0 ].nodeName + ">" ).insertAfter( element ).css( {
  2185. // Convert inline to inline block to account for inline elements
  2186. // that turn to inline block based on content (like img)
  2187. display: /^(inline|ruby)/.test( element.css( "display" ) ) ?
  2188. "inline-block" :
  2189. "block",
  2190. visibility: "hidden",
  2191. // Margins need to be set to account for margin collapse
  2192. marginTop: element.css( "marginTop" ),
  2193. marginBottom: element.css( "marginBottom" ),
  2194. marginLeft: element.css( "marginLeft" ),
  2195. marginRight: element.css( "marginRight" ),
  2196. "float": element.css( "float" )
  2197. } )
  2198. .outerWidth( element.outerWidth() )
  2199. .outerHeight( element.outerHeight() )
  2200. .addClass( "ui-effects-placeholder" );
  2201. element.data( dataSpace + "placeholder", placeholder );
  2202. }
  2203. element.css( {
  2204. position: cssPosition,
  2205. left: position.left,
  2206. top: position.top
  2207. } );
  2208. return placeholder;
  2209. },
  2210. removePlaceholder: function( element ) {
  2211. var dataKey = dataSpace + "placeholder",
  2212. placeholder = element.data( dataKey );
  2213. if ( placeholder ) {
  2214. placeholder.remove();
  2215. element.removeData( dataKey );
  2216. }
  2217. },
  2218. // Removes a placeholder if it exists and restores
  2219. // properties that were modified during placeholder creation
  2220. cleanUp: function( element ) {
  2221. $.effects.restoreStyle( element );
  2222. $.effects.removePlaceholder( element );
  2223. },
  2224. setTransition: function( element, list, factor, value ) {
  2225. value = value || {};
  2226. $.each( list, function( i, x ) {
  2227. var unit = element.cssUnit( x );
  2228. if ( unit[ 0 ] > 0 ) {
  2229. value[ x ] = unit[ 0 ] * factor + unit[ 1 ];
  2230. }
  2231. } );
  2232. return value;
  2233. }
  2234. } );
  2235. // Return an effect options object for the given parameters:
  2236. function _normalizeArguments( effect, options, speed, callback ) {
  2237. // Allow passing all options as the first parameter
  2238. if ( $.isPlainObject( effect ) ) {
  2239. options = effect;
  2240. effect = effect.effect;
  2241. }
  2242. // Convert to an object
  2243. effect = { effect: effect };
  2244. // Catch (effect, null, ...)
  2245. if ( options == null ) {
  2246. options = {};
  2247. }
  2248. // Catch (effect, callback)
  2249. if ( typeof options === "function" ) {
  2250. callback = options;
  2251. speed = null;
  2252. options = {};
  2253. }
  2254. // Catch (effect, speed, ?)
  2255. if ( typeof options === "number" || $.fx.speeds[ options ] ) {
  2256. callback = speed;
  2257. speed = options;
  2258. options = {};
  2259. }
  2260. // Catch (effect, options, callback)
  2261. if ( typeof speed === "function" ) {
  2262. callback = speed;
  2263. speed = null;
  2264. }
  2265. // Add options to effect
  2266. if ( options ) {
  2267. $.extend( effect, options );
  2268. }
  2269. speed = speed || options.duration;
  2270. effect.duration = $.fx.off ? 0 :
  2271. typeof speed === "number" ? speed :
  2272. speed in $.fx.speeds ? $.fx.speeds[ speed ] :
  2273. $.fx.speeds._default;
  2274. effect.complete = callback || options.complete;
  2275. return effect;
  2276. }
  2277. function standardAnimationOption( option ) {
  2278. // Valid standard speeds (nothing, number, named speed)
  2279. if ( !option || typeof option === "number" || $.fx.speeds[ option ] ) {
  2280. return true;
  2281. }
  2282. // Invalid strings - treat as "normal" speed
  2283. if ( typeof option === "string" && !$.effects.effect[ option ] ) {
  2284. return true;
  2285. }
  2286. // Complete callback
  2287. if ( typeof option === "function" ) {
  2288. return true;
  2289. }
  2290. // Options hash (but not naming an effect)
  2291. if ( typeof option === "object" && !option.effect ) {
  2292. return true;
  2293. }
  2294. // Didn't match any standard API
  2295. return false;
  2296. }
  2297. $.fn.extend( {
  2298. effect: function( /* effect, options, speed, callback */ ) {
  2299. var args = _normalizeArguments.apply( this, arguments ),
  2300. effectMethod = $.effects.effect[ args.effect ],
  2301. defaultMode = effectMethod.mode,
  2302. queue = args.queue,
  2303. queueName = queue || "fx",
  2304. complete = args.complete,
  2305. mode = args.mode,
  2306. modes = [],
  2307. prefilter = function( next ) {
  2308. var el = $( this ),
  2309. normalizedMode = $.effects.mode( el, mode ) || defaultMode;
  2310. // Sentinel for duck-punching the :animated pseudo-selector
  2311. el.data( dataSpaceAnimated, true );
  2312. // Save effect mode for later use,
  2313. // we can't just call $.effects.mode again later,
  2314. // as the .show() below destroys the initial state
  2315. modes.push( normalizedMode );
  2316. // See $.uiBackCompat inside of run() for removal of defaultMode in 1.14
  2317. if ( defaultMode && ( normalizedMode === "show" ||
  2318. ( normalizedMode === defaultMode && normalizedMode === "hide" ) ) ) {
  2319. el.show();
  2320. }
  2321. if ( !defaultMode || normalizedMode !== "none" ) {
  2322. $.effects.saveStyle( el );
  2323. }
  2324. if ( typeof next === "function" ) {
  2325. next();
  2326. }
  2327. };
  2328. if ( $.fx.off || !effectMethod ) {
  2329. // Delegate to the original method (e.g., .show()) if possible
  2330. if ( mode ) {
  2331. return this[ mode ]( args.duration, complete );
  2332. } else {
  2333. return this.each( function() {
  2334. if ( complete ) {
  2335. complete.call( this );
  2336. }
  2337. } );
  2338. }
  2339. }
  2340. function run( next ) {
  2341. var elem = $( this );
  2342. function cleanup() {
  2343. elem.removeData( dataSpaceAnimated );
  2344. $.effects.cleanUp( elem );
  2345. if ( args.mode === "hide" ) {
  2346. elem.hide();
  2347. }
  2348. done();
  2349. }
  2350. function done() {
  2351. if ( typeof complete === "function" ) {
  2352. complete.call( elem[ 0 ] );
  2353. }
  2354. if ( typeof next === "function" ) {
  2355. next();
  2356. }
  2357. }
  2358. // Override mode option on a per element basis,
  2359. // as toggle can be either show or hide depending on element state
  2360. args.mode = modes.shift();
  2361. if ( $.uiBackCompat !== false && !defaultMode ) {
  2362. if ( elem.is( ":hidden" ) ? mode === "hide" : mode === "show" ) {
  2363. // Call the core method to track "olddisplay" properly
  2364. elem[ mode ]();
  2365. done();
  2366. } else {
  2367. effectMethod.call( elem[ 0 ], args, done );
  2368. }
  2369. } else {
  2370. if ( args.mode === "none" ) {
  2371. // Call the core method to track "olddisplay" properly
  2372. elem[ mode ]();
  2373. done();
  2374. } else {
  2375. effectMethod.call( elem[ 0 ], args, cleanup );
  2376. }
  2377. }
  2378. }
  2379. // Run prefilter on all elements first to ensure that
  2380. // any showing or hiding happens before placeholder creation,
  2381. // which ensures that any layout changes are correctly captured.
  2382. return queue === false ?
  2383. this.each( prefilter ).each( run ) :
  2384. this.queue( queueName, prefilter ).queue( queueName, run );
  2385. },
  2386. show: ( function( orig ) {
  2387. return function( option ) {
  2388. if ( standardAnimationOption( option ) ) {
  2389. return orig.apply( this, arguments );
  2390. } else {
  2391. var args = _normalizeArguments.apply( this, arguments );
  2392. args.mode = "show";
  2393. return this.effect.call( this, args );
  2394. }
  2395. };
  2396. } )( $.fn.show ),
  2397. hide: ( function( orig ) {
  2398. return function( option ) {
  2399. if ( standardAnimationOption( option ) ) {
  2400. return orig.apply( this, arguments );
  2401. } else {
  2402. var args = _normalizeArguments.apply( this, arguments );
  2403. args.mode = "hide";
  2404. return this.effect.call( this, args );
  2405. }
  2406. };
  2407. } )( $.fn.hide ),
  2408. toggle: ( function( orig ) {
  2409. return function( option ) {
  2410. if ( standardAnimationOption( option ) || typeof option === "boolean" ) {
  2411. return orig.apply( this, arguments );
  2412. } else {
  2413. var args = _normalizeArguments.apply( this, arguments );
  2414. args.mode = "toggle";
  2415. return this.effect.call( this, args );
  2416. }
  2417. };
  2418. } )( $.fn.toggle ),
  2419. cssUnit: function( key ) {
  2420. var style = this.css( key ),
  2421. val = [];
  2422. $.each( [ "em", "px", "%", "pt" ], function( i, unit ) {
  2423. if ( style.indexOf( unit ) > 0 ) {
  2424. val = [ parseFloat( style ), unit ];
  2425. }
  2426. } );
  2427. return val;
  2428. },
  2429. cssClip: function( clipObj ) {
  2430. if ( clipObj ) {
  2431. return this.css( "clip", "rect(" + clipObj.top + "px " + clipObj.right + "px " +
  2432. clipObj.bottom + "px " + clipObj.left + "px)" );
  2433. }
  2434. return parseClip( this.css( "clip" ), this );
  2435. },
  2436. transfer: function( options, done ) {
  2437. var element = $( this ),
  2438. target = $( options.to ),
  2439. targetFixed = target.css( "position" ) === "fixed",
  2440. body = $( "body" ),
  2441. fixTop = targetFixed ? body.scrollTop() : 0,
  2442. fixLeft = targetFixed ? body.scrollLeft() : 0,
  2443. endPosition = target.offset(),
  2444. animation = {
  2445. top: endPosition.top - fixTop,
  2446. left: endPosition.left - fixLeft,
  2447. height: target.innerHeight(),
  2448. width: target.innerWidth()
  2449. },
  2450. startPosition = element.offset(),
  2451. transfer = $( "<div class='ui-effects-transfer'></div>" );
  2452. transfer
  2453. .appendTo( "body" )
  2454. .addClass( options.className )
  2455. .css( {
  2456. top: startPosition.top - fixTop,
  2457. left: startPosition.left - fixLeft,
  2458. height: element.innerHeight(),
  2459. width: element.innerWidth(),
  2460. position: targetFixed ? "fixed" : "absolute"
  2461. } )
  2462. .animate( animation, options.duration, options.easing, function() {
  2463. transfer.remove();
  2464. if ( typeof done === "function" ) {
  2465. done();
  2466. }
  2467. } );
  2468. }
  2469. } );
  2470. function parseClip( str, element ) {
  2471. var outerWidth = element.outerWidth(),
  2472. outerHeight = element.outerHeight(),
  2473. 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)\)$/,
  2474. values = clipRegex.exec( str ) || [ "", 0, outerWidth, outerHeight, 0 ];
  2475. return {
  2476. top: parseFloat( values[ 1 ] ) || 0,
  2477. right: values[ 2 ] === "auto" ? outerWidth : parseFloat( values[ 2 ] ),
  2478. bottom: values[ 3 ] === "auto" ? outerHeight : parseFloat( values[ 3 ] ),
  2479. left: parseFloat( values[ 4 ] ) || 0
  2480. };
  2481. }
  2482. $.fx.step.clip = function( fx ) {
  2483. if ( !fx.clipInit ) {
  2484. fx.start = $( fx.elem ).cssClip();
  2485. if ( typeof fx.end === "string" ) {
  2486. fx.end = parseClip( fx.end, fx.elem );
  2487. }
  2488. fx.clipInit = true;
  2489. }
  2490. $( fx.elem ).cssClip( {
  2491. top: fx.pos * ( fx.end.top - fx.start.top ) + fx.start.top,
  2492. right: fx.pos * ( fx.end.right - fx.start.right ) + fx.start.right,
  2493. bottom: fx.pos * ( fx.end.bottom - fx.start.bottom ) + fx.start.bottom,
  2494. left: fx.pos * ( fx.end.left - fx.start.left ) + fx.start.left
  2495. } );
  2496. };
  2497. } )();
  2498. /******************************************************************************/
  2499. /*********************************** EASING ***********************************/
  2500. /******************************************************************************/
  2501. ( function() {
  2502. // Based on easing equations from Robert Penner (http://www.robertpenner.com/easing)
  2503. var baseEasings = {};
  2504. $.each( [ "Quad", "Cubic", "Quart", "Quint", "Expo" ], function( i, name ) {
  2505. baseEasings[ name ] = function( p ) {
  2506. return Math.pow( p, i + 2 );
  2507. };
  2508. } );
  2509. $.extend( baseEasings, {
  2510. Sine: function( p ) {
  2511. return 1 - Math.cos( p * Math.PI / 2 );
  2512. },
  2513. Circ: function( p ) {
  2514. return 1 - Math.sqrt( 1 - p * p );
  2515. },
  2516. Elastic: function( p ) {
  2517. return p === 0 || p === 1 ? p :
  2518. -Math.pow( 2, 8 * ( p - 1 ) ) * Math.sin( ( ( p - 1 ) * 80 - 7.5 ) * Math.PI / 15 );
  2519. },
  2520. Back: function( p ) {
  2521. return p * p * ( 3 * p - 2 );
  2522. },
  2523. Bounce: function( p ) {
  2524. var pow2,
  2525. bounce = 4;
  2526. while ( p < ( ( pow2 = Math.pow( 2, --bounce ) ) - 1 ) / 11 ) {}
  2527. return 1 / Math.pow( 4, 3 - bounce ) - 7.5625 * Math.pow( ( pow2 * 3 - 2 ) / 22 - p, 2 );
  2528. }
  2529. } );
  2530. $.each( baseEasings, function( name, easeIn ) {
  2531. $.easing[ "easeIn" + name ] = easeIn;
  2532. $.easing[ "easeOut" + name ] = function( p ) {
  2533. return 1 - easeIn( 1 - p );
  2534. };
  2535. $.easing[ "easeInOut" + name ] = function( p ) {
  2536. return p < 0.5 ?
  2537. easeIn( p * 2 ) / 2 :
  2538. 1 - easeIn( p * -2 + 2 ) / 2;
  2539. };
  2540. } );
  2541. } )();
  2542. var effect = $.effects;
  2543. /*!
  2544. * jQuery UI Effects Blind 1.13.2
  2545. * http://jqueryui.com
  2546. *
  2547. * Copyright jQuery Foundation and other contributors
  2548. * Released under the MIT license.
  2549. * http://jquery.org/license
  2550. */
  2551. //>>label: Blind Effect
  2552. //>>group: Effects
  2553. //>>description: Blinds the element.
  2554. //>>docs: http://api.jqueryui.com/blind-effect/
  2555. //>>demos: http://jqueryui.com/effect/
  2556. var effectsEffectBlind = $.effects.define( "blind", "hide", function( options, done ) {
  2557. var map = {
  2558. up: [ "bottom", "top" ],
  2559. vertical: [ "bottom", "top" ],
  2560. down: [ "top", "bottom" ],
  2561. left: [ "right", "left" ],
  2562. horizontal: [ "right", "left" ],
  2563. right: [ "left", "right" ]
  2564. },
  2565. element = $( this ),
  2566. direction = options.direction || "up",
  2567. start = element.cssClip(),
  2568. animate = { clip: $.extend( {}, start ) },
  2569. placeholder = $.effects.createPlaceholder( element );
  2570. animate.clip[ map[ direction ][ 0 ] ] = animate.clip[ map[ direction ][ 1 ] ];
  2571. if ( options.mode === "show" ) {
  2572. element.cssClip( animate.clip );
  2573. if ( placeholder ) {
  2574. placeholder.css( $.effects.clipToBox( animate ) );
  2575. }
  2576. animate.clip = start;
  2577. }
  2578. if ( placeholder ) {
  2579. placeholder.animate( $.effects.clipToBox( animate ), options.duration, options.easing );
  2580. }
  2581. element.animate( animate, {
  2582. queue: false,
  2583. duration: options.duration,
  2584. easing: options.easing,
  2585. complete: done
  2586. } );
  2587. } );
  2588. /*!
  2589. * jQuery UI Effects Bounce 1.13.2
  2590. * http://jqueryui.com
  2591. *
  2592. * Copyright jQuery Foundation and other contributors
  2593. * Released under the MIT license.
  2594. * http://jquery.org/license
  2595. */
  2596. //>>label: Bounce Effect
  2597. //>>group: Effects
  2598. //>>description: Bounces an element horizontally or vertically n times.
  2599. //>>docs: http://api.jqueryui.com/bounce-effect/
  2600. //>>demos: http://jqueryui.com/effect/
  2601. var effectsEffectBounce = $.effects.define( "bounce", function( options, done ) {
  2602. var upAnim, downAnim, refValue,
  2603. element = $( this ),
  2604. // Defaults:
  2605. mode = options.mode,
  2606. hide = mode === "hide",
  2607. show = mode === "show",
  2608. direction = options.direction || "up",
  2609. distance = options.distance,
  2610. times = options.times || 5,
  2611. // Number of internal animations
  2612. anims = times * 2 + ( show || hide ? 1 : 0 ),
  2613. speed = options.duration / anims,
  2614. easing = options.easing,
  2615. // Utility:
  2616. ref = ( direction === "up" || direction === "down" ) ? "top" : "left",
  2617. motion = ( direction === "up" || direction === "left" ),
  2618. i = 0,
  2619. queuelen = element.queue().length;
  2620. $.effects.createPlaceholder( element );
  2621. refValue = element.css( ref );
  2622. // Default distance for the BIGGEST bounce is the outer Distance / 3
  2623. if ( !distance ) {
  2624. distance = element[ ref === "top" ? "outerHeight" : "outerWidth" ]() / 3;
  2625. }
  2626. if ( show ) {
  2627. downAnim = { opacity: 1 };
  2628. downAnim[ ref ] = refValue;
  2629. // If we are showing, force opacity 0 and set the initial position
  2630. // then do the "first" animation
  2631. element
  2632. .css( "opacity", 0 )
  2633. .css( ref, motion ? -distance * 2 : distance * 2 )
  2634. .animate( downAnim, speed, easing );
  2635. }
  2636. // Start at the smallest distance if we are hiding
  2637. if ( hide ) {
  2638. distance = distance / Math.pow( 2, times - 1 );
  2639. }
  2640. downAnim = {};
  2641. downAnim[ ref ] = refValue;
  2642. // Bounces up/down/left/right then back to 0 -- times * 2 animations happen here
  2643. for ( ; i < times; i++ ) {
  2644. upAnim = {};
  2645. upAnim[ ref ] = ( motion ? "-=" : "+=" ) + distance;
  2646. element
  2647. .animate( upAnim, speed, easing )
  2648. .animate( downAnim, speed, easing );
  2649. distance = hide ? distance * 2 : distance / 2;
  2650. }
  2651. // Last Bounce when Hiding
  2652. if ( hide ) {
  2653. upAnim = { opacity: 0 };
  2654. upAnim[ ref ] = ( motion ? "-=" : "+=" ) + distance;
  2655. element.animate( upAnim, speed, easing );
  2656. }
  2657. element.queue( done );
  2658. $.effects.unshift( element, queuelen, anims + 1 );
  2659. } );
  2660. /*!
  2661. * jQuery UI Effects Clip 1.13.2
  2662. * http://jqueryui.com
  2663. *
  2664. * Copyright jQuery Foundation and other contributors
  2665. * Released under the MIT license.
  2666. * http://jquery.org/license
  2667. */
  2668. //>>label: Clip Effect
  2669. //>>group: Effects
  2670. //>>description: Clips the element on and off like an old TV.
  2671. //>>docs: http://api.jqueryui.com/clip-effect/
  2672. //>>demos: http://jqueryui.com/effect/
  2673. var effectsEffectClip = $.effects.define( "clip", "hide", function( options, done ) {
  2674. var start,
  2675. animate = {},
  2676. element = $( this ),
  2677. direction = options.direction || "vertical",
  2678. both = direction === "both",
  2679. horizontal = both || direction === "horizontal",
  2680. vertical = both || direction === "vertical";
  2681. start = element.cssClip();
  2682. animate.clip = {
  2683. top: vertical ? ( start.bottom - start.top ) / 2 : start.top,
  2684. right: horizontal ? ( start.right - start.left ) / 2 : start.right,
  2685. bottom: vertical ? ( start.bottom - start.top ) / 2 : start.bottom,
  2686. left: horizontal ? ( start.right - start.left ) / 2 : start.left
  2687. };
  2688. $.effects.createPlaceholder( element );
  2689. if ( options.mode === "show" ) {
  2690. element.cssClip( animate.clip );
  2691. animate.clip = start;
  2692. }
  2693. element.animate( animate, {
  2694. queue: false,
  2695. duration: options.duration,
  2696. easing: options.easing,
  2697. complete: done
  2698. } );
  2699. } );
  2700. /*!
  2701. * jQuery UI Effects Drop 1.13.2
  2702. * http://jqueryui.com
  2703. *
  2704. * Copyright jQuery Foundation and other contributors
  2705. * Released under the MIT license.
  2706. * http://jquery.org/license
  2707. */
  2708. //>>label: Drop Effect
  2709. //>>group: Effects
  2710. //>>description: Moves an element in one direction and hides it at the same time.
  2711. //>>docs: http://api.jqueryui.com/drop-effect/
  2712. //>>demos: http://jqueryui.com/effect/
  2713. var effectsEffectDrop = $.effects.define( "drop", "hide", function( options, done ) {
  2714. var distance,
  2715. element = $( this ),
  2716. mode = options.mode,
  2717. show = mode === "show",
  2718. direction = options.direction || "left",
  2719. ref = ( direction === "up" || direction === "down" ) ? "top" : "left",
  2720. motion = ( direction === "up" || direction === "left" ) ? "-=" : "+=",
  2721. oppositeMotion = ( motion === "+=" ) ? "-=" : "+=",
  2722. animation = {
  2723. opacity: 0
  2724. };
  2725. $.effects.createPlaceholder( element );
  2726. distance = options.distance ||
  2727. element[ ref === "top" ? "outerHeight" : "outerWidth" ]( true ) / 2;
  2728. animation[ ref ] = motion + distance;
  2729. if ( show ) {
  2730. element.css( animation );
  2731. animation[ ref ] = oppositeMotion + distance;
  2732. animation.opacity = 1;
  2733. }
  2734. // Animate
  2735. element.animate( animation, {
  2736. queue: false,
  2737. duration: options.duration,
  2738. easing: options.easing,
  2739. complete: done
  2740. } );
  2741. } );
  2742. /*!
  2743. * jQuery UI Effects Explode 1.13.2
  2744. * http://jqueryui.com
  2745. *
  2746. * Copyright jQuery Foundation and other contributors
  2747. * Released under the MIT license.
  2748. * http://jquery.org/license
  2749. */
  2750. //>>label: Explode Effect
  2751. //>>group: Effects
  2752. /* eslint-disable max-len */
  2753. //>>description: Explodes an element in all directions into n pieces. Implodes an element to its original wholeness.
  2754. /* eslint-enable max-len */
  2755. //>>docs: http://api.jqueryui.com/explode-effect/
  2756. //>>demos: http://jqueryui.com/effect/
  2757. var effectsEffectExplode = $.effects.define( "explode", "hide", function( options, done ) {
  2758. var i, j, left, top, mx, my,
  2759. rows = options.pieces ? Math.round( Math.sqrt( options.pieces ) ) : 3,
  2760. cells = rows,
  2761. element = $( this ),
  2762. mode = options.mode,
  2763. show = mode === "show",
  2764. // Show and then visibility:hidden the element before calculating offset
  2765. offset = element.show().css( "visibility", "hidden" ).offset(),
  2766. // Width and height of a piece
  2767. width = Math.ceil( element.outerWidth() / cells ),
  2768. height = Math.ceil( element.outerHeight() / rows ),
  2769. pieces = [];
  2770. // Children animate complete:
  2771. function childComplete() {
  2772. pieces.push( this );
  2773. if ( pieces.length === rows * cells ) {
  2774. animComplete();
  2775. }
  2776. }
  2777. // Clone the element for each row and cell.
  2778. for ( i = 0; i < rows; i++ ) { // ===>
  2779. top = offset.top + i * height;
  2780. my = i - ( rows - 1 ) / 2;
  2781. for ( j = 0; j < cells; j++ ) { // |||
  2782. left = offset.left + j * width;
  2783. mx = j - ( cells - 1 ) / 2;
  2784. // Create a clone of the now hidden main element that will be absolute positioned
  2785. // within a wrapper div off the -left and -top equal to size of our pieces
  2786. element
  2787. .clone()
  2788. .appendTo( "body" )
  2789. .wrap( "<div></div>" )
  2790. .css( {
  2791. position: "absolute",
  2792. visibility: "visible",
  2793. left: -j * width,
  2794. top: -i * height
  2795. } )
  2796. // Select the wrapper - make it overflow: hidden and absolute positioned based on
  2797. // where the original was located +left and +top equal to the size of pieces
  2798. .parent()
  2799. .addClass( "ui-effects-explode" )
  2800. .css( {
  2801. position: "absolute",
  2802. overflow: "hidden",
  2803. width: width,
  2804. height: height,
  2805. left: left + ( show ? mx * width : 0 ),
  2806. top: top + ( show ? my * height : 0 ),
  2807. opacity: show ? 0 : 1
  2808. } )
  2809. .animate( {
  2810. left: left + ( show ? 0 : mx * width ),
  2811. top: top + ( show ? 0 : my * height ),
  2812. opacity: show ? 1 : 0
  2813. }, options.duration || 500, options.easing, childComplete );
  2814. }
  2815. }
  2816. function animComplete() {
  2817. element.css( {
  2818. visibility: "visible"
  2819. } );
  2820. $( pieces ).remove();
  2821. done();
  2822. }
  2823. } );
  2824. /*!
  2825. * jQuery UI Effects Fade 1.13.2
  2826. * http://jqueryui.com
  2827. *
  2828. * Copyright jQuery Foundation and other contributors
  2829. * Released under the MIT license.
  2830. * http://jquery.org/license
  2831. */
  2832. //>>label: Fade Effect
  2833. //>>group: Effects
  2834. //>>description: Fades the element.
  2835. //>>docs: http://api.jqueryui.com/fade-effect/
  2836. //>>demos: http://jqueryui.com/effect/
  2837. var effectsEffectFade = $.effects.define( "fade", "toggle", function( options, done ) {
  2838. var show = options.mode === "show";
  2839. $( this )
  2840. .css( "opacity", show ? 0 : 1 )
  2841. .animate( {
  2842. opacity: show ? 1 : 0
  2843. }, {
  2844. queue: false,
  2845. duration: options.duration,
  2846. easing: options.easing,
  2847. complete: done
  2848. } );
  2849. } );
  2850. /*!
  2851. * jQuery UI Effects Fold 1.13.2
  2852. * http://jqueryui.com
  2853. *
  2854. * Copyright jQuery Foundation and other contributors
  2855. * Released under the MIT license.
  2856. * http://jquery.org/license
  2857. */
  2858. //>>label: Fold Effect
  2859. //>>group: Effects
  2860. //>>description: Folds an element first horizontally and then vertically.
  2861. //>>docs: http://api.jqueryui.com/fold-effect/
  2862. //>>demos: http://jqueryui.com/effect/
  2863. var effectsEffectFold = $.effects.define( "fold", "hide", function( options, done ) {
  2864. // Create element
  2865. var element = $( this ),
  2866. mode = options.mode,
  2867. show = mode === "show",
  2868. hide = mode === "hide",
  2869. size = options.size || 15,
  2870. percent = /([0-9]+)%/.exec( size ),
  2871. horizFirst = !!options.horizFirst,
  2872. ref = horizFirst ? [ "right", "bottom" ] : [ "bottom", "right" ],
  2873. duration = options.duration / 2,
  2874. placeholder = $.effects.createPlaceholder( element ),
  2875. start = element.cssClip(),
  2876. animation1 = { clip: $.extend( {}, start ) },
  2877. animation2 = { clip: $.extend( {}, start ) },
  2878. distance = [ start[ ref[ 0 ] ], start[ ref[ 1 ] ] ],
  2879. queuelen = element.queue().length;
  2880. if ( percent ) {
  2881. size = parseInt( percent[ 1 ], 10 ) / 100 * distance[ hide ? 0 : 1 ];
  2882. }
  2883. animation1.clip[ ref[ 0 ] ] = size;
  2884. animation2.clip[ ref[ 0 ] ] = size;
  2885. animation2.clip[ ref[ 1 ] ] = 0;
  2886. if ( show ) {
  2887. element.cssClip( animation2.clip );
  2888. if ( placeholder ) {
  2889. placeholder.css( $.effects.clipToBox( animation2 ) );
  2890. }
  2891. animation2.clip = start;
  2892. }
  2893. // Animate
  2894. element
  2895. .queue( function( next ) {
  2896. if ( placeholder ) {
  2897. placeholder
  2898. .animate( $.effects.clipToBox( animation1 ), duration, options.easing )
  2899. .animate( $.effects.clipToBox( animation2 ), duration, options.easing );
  2900. }
  2901. next();
  2902. } )
  2903. .animate( animation1, duration, options.easing )
  2904. .animate( animation2, duration, options.easing )
  2905. .queue( done );
  2906. $.effects.unshift( element, queuelen, 4 );
  2907. } );
  2908. /*!
  2909. * jQuery UI Effects Highlight 1.13.2
  2910. * http://jqueryui.com
  2911. *
  2912. * Copyright jQuery Foundation and other contributors
  2913. * Released under the MIT license.
  2914. * http://jquery.org/license
  2915. */
  2916. //>>label: Highlight Effect
  2917. //>>group: Effects
  2918. //>>description: Highlights the background of an element in a defined color for a custom duration.
  2919. //>>docs: http://api.jqueryui.com/highlight-effect/
  2920. //>>demos: http://jqueryui.com/effect/
  2921. var effectsEffectHighlight = $.effects.define( "highlight", "show", function( options, done ) {
  2922. var element = $( this ),
  2923. animation = {
  2924. backgroundColor: element.css( "backgroundColor" )
  2925. };
  2926. if ( options.mode === "hide" ) {
  2927. animation.opacity = 0;
  2928. }
  2929. $.effects.saveStyle( element );
  2930. element
  2931. .css( {
  2932. backgroundImage: "none",
  2933. backgroundColor: options.color || "#ffff99"
  2934. } )
  2935. .animate( animation, {
  2936. queue: false,
  2937. duration: options.duration,
  2938. easing: options.easing,
  2939. complete: done
  2940. } );
  2941. } );
  2942. /*!
  2943. * jQuery UI Effects Size 1.13.2
  2944. * http://jqueryui.com
  2945. *
  2946. * Copyright jQuery Foundation and other contributors
  2947. * Released under the MIT license.
  2948. * http://jquery.org/license
  2949. */
  2950. //>>label: Size Effect
  2951. //>>group: Effects
  2952. //>>description: Resize an element to a specified width and height.
  2953. //>>docs: http://api.jqueryui.com/size-effect/
  2954. //>>demos: http://jqueryui.com/effect/
  2955. var effectsEffectSize = $.effects.define( "size", function( options, done ) {
  2956. // Create element
  2957. var baseline, factor, temp,
  2958. element = $( this ),
  2959. // Copy for children
  2960. cProps = [ "fontSize" ],
  2961. vProps = [ "borderTopWidth", "borderBottomWidth", "paddingTop", "paddingBottom" ],
  2962. hProps = [ "borderLeftWidth", "borderRightWidth", "paddingLeft", "paddingRight" ],
  2963. // Set options
  2964. mode = options.mode,
  2965. restore = mode !== "effect",
  2966. scale = options.scale || "both",
  2967. origin = options.origin || [ "middle", "center" ],
  2968. position = element.css( "position" ),
  2969. pos = element.position(),
  2970. original = $.effects.scaledDimensions( element ),
  2971. from = options.from || original,
  2972. to = options.to || $.effects.scaledDimensions( element, 0 );
  2973. $.effects.createPlaceholder( element );
  2974. if ( mode === "show" ) {
  2975. temp = from;
  2976. from = to;
  2977. to = temp;
  2978. }
  2979. // Set scaling factor
  2980. factor = {
  2981. from: {
  2982. y: from.height / original.height,
  2983. x: from.width / original.width
  2984. },
  2985. to: {
  2986. y: to.height / original.height,
  2987. x: to.width / original.width
  2988. }
  2989. };
  2990. // Scale the css box
  2991. if ( scale === "box" || scale === "both" ) {
  2992. // Vertical props scaling
  2993. if ( factor.from.y !== factor.to.y ) {
  2994. from = $.effects.setTransition( element, vProps, factor.from.y, from );
  2995. to = $.effects.setTransition( element, vProps, factor.to.y, to );
  2996. }
  2997. // Horizontal props scaling
  2998. if ( factor.from.x !== factor.to.x ) {
  2999. from = $.effects.setTransition( element, hProps, factor.from.x, from );
  3000. to = $.effects.setTransition( element, hProps, factor.to.x, to );
  3001. }
  3002. }
  3003. // Scale the content
  3004. if ( scale === "content" || scale === "both" ) {
  3005. // Vertical props scaling
  3006. if ( factor.from.y !== factor.to.y ) {
  3007. from = $.effects.setTransition( element, cProps, factor.from.y, from );
  3008. to = $.effects.setTransition( element, cProps, factor.to.y, to );
  3009. }
  3010. }
  3011. // Adjust the position properties based on the provided origin points
  3012. if ( origin ) {
  3013. baseline = $.effects.getBaseline( origin, original );
  3014. from.top = ( original.outerHeight - from.outerHeight ) * baseline.y + pos.top;
  3015. from.left = ( original.outerWidth - from.outerWidth ) * baseline.x + pos.left;
  3016. to.top = ( original.outerHeight - to.outerHeight ) * baseline.y + pos.top;
  3017. to.left = ( original.outerWidth - to.outerWidth ) * baseline.x + pos.left;
  3018. }
  3019. delete from.outerHeight;
  3020. delete from.outerWidth;
  3021. element.css( from );
  3022. // Animate the children if desired
  3023. if ( scale === "content" || scale === "both" ) {
  3024. vProps = vProps.concat( [ "marginTop", "marginBottom" ] ).concat( cProps );
  3025. hProps = hProps.concat( [ "marginLeft", "marginRight" ] );
  3026. // Only animate children with width attributes specified
  3027. // TODO: is this right? should we include anything with css width specified as well
  3028. element.find( "*[width]" ).each( function() {
  3029. var child = $( this ),
  3030. childOriginal = $.effects.scaledDimensions( child ),
  3031. childFrom = {
  3032. height: childOriginal.height * factor.from.y,
  3033. width: childOriginal.width * factor.from.x,
  3034. outerHeight: childOriginal.outerHeight * factor.from.y,
  3035. outerWidth: childOriginal.outerWidth * factor.from.x
  3036. },
  3037. childTo = {
  3038. height: childOriginal.height * factor.to.y,
  3039. width: childOriginal.width * factor.to.x,
  3040. outerHeight: childOriginal.height * factor.to.y,
  3041. outerWidth: childOriginal.width * factor.to.x
  3042. };
  3043. // Vertical props scaling
  3044. if ( factor.from.y !== factor.to.y ) {
  3045. childFrom = $.effects.setTransition( child, vProps, factor.from.y, childFrom );
  3046. childTo = $.effects.setTransition( child, vProps, factor.to.y, childTo );
  3047. }
  3048. // Horizontal props scaling
  3049. if ( factor.from.x !== factor.to.x ) {
  3050. childFrom = $.effects.setTransition( child, hProps, factor.from.x, childFrom );
  3051. childTo = $.effects.setTransition( child, hProps, factor.to.x, childTo );
  3052. }
  3053. if ( restore ) {
  3054. $.effects.saveStyle( child );
  3055. }
  3056. // Animate children
  3057. child.css( childFrom );
  3058. child.animate( childTo, options.duration, options.easing, function() {
  3059. // Restore children
  3060. if ( restore ) {
  3061. $.effects.restoreStyle( child );
  3062. }
  3063. } );
  3064. } );
  3065. }
  3066. // Animate
  3067. element.animate( to, {
  3068. queue: false,
  3069. duration: options.duration,
  3070. easing: options.easing,
  3071. complete: function() {
  3072. var offset = element.offset();
  3073. if ( to.opacity === 0 ) {
  3074. element.css( "opacity", from.opacity );
  3075. }
  3076. if ( !restore ) {
  3077. element
  3078. .css( "position", position === "static" ? "relative" : position )
  3079. .offset( offset );
  3080. // Need to save style here so that automatic style restoration
  3081. // doesn't restore to the original styles from before the animation.
  3082. $.effects.saveStyle( element );
  3083. }
  3084. done();
  3085. }
  3086. } );
  3087. } );
  3088. /*!
  3089. * jQuery UI Effects Scale 1.13.2
  3090. * http://jqueryui.com
  3091. *
  3092. * Copyright jQuery Foundation and other contributors
  3093. * Released under the MIT license.
  3094. * http://jquery.org/license
  3095. */
  3096. //>>label: Scale Effect
  3097. //>>group: Effects
  3098. //>>description: Grows or shrinks an element and its content.
  3099. //>>docs: http://api.jqueryui.com/scale-effect/
  3100. //>>demos: http://jqueryui.com/effect/
  3101. var effectsEffectScale = $.effects.define( "scale", function( options, done ) {
  3102. // Create element
  3103. var el = $( this ),
  3104. mode = options.mode,
  3105. percent = parseInt( options.percent, 10 ) ||
  3106. ( parseInt( options.percent, 10 ) === 0 ? 0 : ( mode !== "effect" ? 0 : 100 ) ),
  3107. newOptions = $.extend( true, {
  3108. from: $.effects.scaledDimensions( el ),
  3109. to: $.effects.scaledDimensions( el, percent, options.direction || "both" ),
  3110. origin: options.origin || [ "middle", "center" ]
  3111. }, options );
  3112. // Fade option to support puff
  3113. if ( options.fade ) {
  3114. newOptions.from.opacity = 1;
  3115. newOptions.to.opacity = 0;
  3116. }
  3117. $.effects.effect.size.call( this, newOptions, done );
  3118. } );
  3119. /*!
  3120. * jQuery UI Effects Puff 1.13.2
  3121. * http://jqueryui.com
  3122. *
  3123. * Copyright jQuery Foundation and other contributors
  3124. * Released under the MIT license.
  3125. * http://jquery.org/license
  3126. */
  3127. //>>label: Puff Effect
  3128. //>>group: Effects
  3129. //>>description: Creates a puff effect by scaling the element up and hiding it at the same time.
  3130. //>>docs: http://api.jqueryui.com/puff-effect/
  3131. //>>demos: http://jqueryui.com/effect/
  3132. var effectsEffectPuff = $.effects.define( "puff", "hide", function( options, done ) {
  3133. var newOptions = $.extend( true, {}, options, {
  3134. fade: true,
  3135. percent: parseInt( options.percent, 10 ) || 150
  3136. } );
  3137. $.effects.effect.scale.call( this, newOptions, done );
  3138. } );
  3139. /*!
  3140. * jQuery UI Effects Pulsate 1.13.2
  3141. * http://jqueryui.com
  3142. *
  3143. * Copyright jQuery Foundation and other contributors
  3144. * Released under the MIT license.
  3145. * http://jquery.org/license
  3146. */
  3147. //>>label: Pulsate Effect
  3148. //>>group: Effects
  3149. //>>description: Pulsates an element n times by changing the opacity to zero and back.
  3150. //>>docs: http://api.jqueryui.com/pulsate-effect/
  3151. //>>demos: http://jqueryui.com/effect/
  3152. var effectsEffectPulsate = $.effects.define( "pulsate", "show", function( options, done ) {
  3153. var element = $( this ),
  3154. mode = options.mode,
  3155. show = mode === "show",
  3156. hide = mode === "hide",
  3157. showhide = show || hide,
  3158. // Showing or hiding leaves off the "last" animation
  3159. anims = ( ( options.times || 5 ) * 2 ) + ( showhide ? 1 : 0 ),
  3160. duration = options.duration / anims,
  3161. animateTo = 0,
  3162. i = 1,
  3163. queuelen = element.queue().length;
  3164. if ( show || !element.is( ":visible" ) ) {
  3165. element.css( "opacity", 0 ).show();
  3166. animateTo = 1;
  3167. }
  3168. // Anims - 1 opacity "toggles"
  3169. for ( ; i < anims; i++ ) {
  3170. element.animate( { opacity: animateTo }, duration, options.easing );
  3171. animateTo = 1 - animateTo;
  3172. }
  3173. element.animate( { opacity: animateTo }, duration, options.easing );
  3174. element.queue( done );
  3175. $.effects.unshift( element, queuelen, anims + 1 );
  3176. } );
  3177. /*!
  3178. * jQuery UI Effects Shake 1.13.2
  3179. * http://jqueryui.com
  3180. *
  3181. * Copyright jQuery Foundation and other contributors
  3182. * Released under the MIT license.
  3183. * http://jquery.org/license
  3184. */
  3185. //>>label: Shake Effect
  3186. //>>group: Effects
  3187. //>>description: Shakes an element horizontally or vertically n times.
  3188. //>>docs: http://api.jqueryui.com/shake-effect/
  3189. //>>demos: http://jqueryui.com/effect/
  3190. var effectsEffectShake = $.effects.define( "shake", function( options, done ) {
  3191. var i = 1,
  3192. element = $( this ),
  3193. direction = options.direction || "left",
  3194. distance = options.distance || 20,
  3195. times = options.times || 3,
  3196. anims = times * 2 + 1,
  3197. speed = Math.round( options.duration / anims ),
  3198. ref = ( direction === "up" || direction === "down" ) ? "top" : "left",
  3199. positiveMotion = ( direction === "up" || direction === "left" ),
  3200. animation = {},
  3201. animation1 = {},
  3202. animation2 = {},
  3203. queuelen = element.queue().length;
  3204. $.effects.createPlaceholder( element );
  3205. // Animation
  3206. animation[ ref ] = ( positiveMotion ? "-=" : "+=" ) + distance;
  3207. animation1[ ref ] = ( positiveMotion ? "+=" : "-=" ) + distance * 2;
  3208. animation2[ ref ] = ( positiveMotion ? "-=" : "+=" ) + distance * 2;
  3209. // Animate
  3210. element.animate( animation, speed, options.easing );
  3211. // Shakes
  3212. for ( ; i < times; i++ ) {
  3213. element
  3214. .animate( animation1, speed, options.easing )
  3215. .animate( animation2, speed, options.easing );
  3216. }
  3217. element
  3218. .animate( animation1, speed, options.easing )
  3219. .animate( animation, speed / 2, options.easing )
  3220. .queue( done );
  3221. $.effects.unshift( element, queuelen, anims + 1 );
  3222. } );
  3223. /*!
  3224. * jQuery UI Effects Slide 1.13.2
  3225. * http://jqueryui.com
  3226. *
  3227. * Copyright jQuery Foundation and other contributors
  3228. * Released under the MIT license.
  3229. * http://jquery.org/license
  3230. */
  3231. //>>label: Slide Effect
  3232. //>>group: Effects
  3233. //>>description: Slides an element in and out of the viewport.
  3234. //>>docs: http://api.jqueryui.com/slide-effect/
  3235. //>>demos: http://jqueryui.com/effect/
  3236. var effectsEffectSlide = $.effects.define( "slide", "show", function( options, done ) {
  3237. var startClip, startRef,
  3238. element = $( this ),
  3239. map = {
  3240. up: [ "bottom", "top" ],
  3241. down: [ "top", "bottom" ],
  3242. left: [ "right", "left" ],
  3243. right: [ "left", "right" ]
  3244. },
  3245. mode = options.mode,
  3246. direction = options.direction || "left",
  3247. ref = ( direction === "up" || direction === "down" ) ? "top" : "left",
  3248. positiveMotion = ( direction === "up" || direction === "left" ),
  3249. distance = options.distance ||
  3250. element[ ref === "top" ? "outerHeight" : "outerWidth" ]( true ),
  3251. animation = {};
  3252. $.effects.createPlaceholder( element );
  3253. startClip = element.cssClip();
  3254. startRef = element.position()[ ref ];
  3255. // Define hide animation
  3256. animation[ ref ] = ( positiveMotion ? -1 : 1 ) * distance + startRef;
  3257. animation.clip = element.cssClip();
  3258. animation.clip[ map[ direction ][ 1 ] ] = animation.clip[ map[ direction ][ 0 ] ];
  3259. // Reverse the animation if we're showing
  3260. if ( mode === "show" ) {
  3261. element.cssClip( animation.clip );
  3262. element.css( ref, animation[ ref ] );
  3263. animation.clip = startClip;
  3264. animation[ ref ] = startRef;
  3265. }
  3266. // Actually animate
  3267. element.animate( animation, {
  3268. queue: false,
  3269. duration: options.duration,
  3270. easing: options.easing,
  3271. complete: done
  3272. } );
  3273. } );
  3274. /*!
  3275. * jQuery UI Effects Transfer 1.13.2
  3276. * http://jqueryui.com
  3277. *
  3278. * Copyright jQuery Foundation and other contributors
  3279. * Released under the MIT license.
  3280. * http://jquery.org/license
  3281. */
  3282. //>>label: Transfer Effect
  3283. //>>group: Effects
  3284. //>>description: Displays a transfer effect from one element to another.
  3285. //>>docs: http://api.jqueryui.com/transfer-effect/
  3286. //>>demos: http://jqueryui.com/effect/
  3287. var effect;
  3288. if ( $.uiBackCompat !== false ) {
  3289. effect = $.effects.define( "transfer", function( options, done ) {
  3290. $( this ).transfer( options, done );
  3291. } );
  3292. }
  3293. var effectsEffectTransfer = effect;
  3294. /*!
  3295. * jQuery UI Focusable 1.13.2
  3296. * http://jqueryui.com
  3297. *
  3298. * Copyright jQuery Foundation and other contributors
  3299. * Released under the MIT license.
  3300. * http://jquery.org/license
  3301. */
  3302. //>>label: :focusable Selector
  3303. //>>group: Core
  3304. //>>description: Selects elements which can be focused.
  3305. //>>docs: http://api.jqueryui.com/focusable-selector/
  3306. // Selectors
  3307. $.ui.focusable = function( element, hasTabindex ) {
  3308. var map, mapName, img, focusableIfVisible, fieldset,
  3309. nodeName = element.nodeName.toLowerCase();
  3310. if ( "area" === nodeName ) {
  3311. map = element.parentNode;
  3312. mapName = map.name;
  3313. if ( !element.href || !mapName || map.nodeName.toLowerCase() !== "map" ) {
  3314. return false;
  3315. }
  3316. img = $( "img[usemap='#" + mapName + "']" );
  3317. return img.length > 0 && img.is( ":visible" );
  3318. }
  3319. if ( /^(input|select|textarea|button|object)$/.test( nodeName ) ) {
  3320. focusableIfVisible = !element.disabled;
  3321. if ( focusableIfVisible ) {
  3322. // Form controls within a disabled fieldset are disabled.
  3323. // However, controls within the fieldset's legend do not get disabled.
  3324. // Since controls generally aren't placed inside legends, we skip
  3325. // this portion of the check.
  3326. fieldset = $( element ).closest( "fieldset" )[ 0 ];
  3327. if ( fieldset ) {
  3328. focusableIfVisible = !fieldset.disabled;
  3329. }
  3330. }
  3331. } else if ( "a" === nodeName ) {
  3332. focusableIfVisible = element.href || hasTabindex;
  3333. } else {
  3334. focusableIfVisible = hasTabindex;
  3335. }
  3336. return focusableIfVisible && $( element ).is( ":visible" ) && visible( $( element ) );
  3337. };
  3338. // Support: IE 8 only
  3339. // IE 8 doesn't resolve inherit to visible/hidden for computed values
  3340. function visible( element ) {
  3341. var visibility = element.css( "visibility" );
  3342. while ( visibility === "inherit" ) {
  3343. element = element.parent();
  3344. visibility = element.css( "visibility" );
  3345. }
  3346. return visibility === "visible";
  3347. }
  3348. $.extend( $.expr.pseudos, {
  3349. focusable: function( element ) {
  3350. return $.ui.focusable( element, $.attr( element, "tabindex" ) != null );
  3351. }
  3352. } );
  3353. var focusable = $.ui.focusable;
  3354. // Support: IE8 Only
  3355. // IE8 does not support the form attribute and when it is supplied. It overwrites the form prop
  3356. // with a string, so we need to find the proper form.
  3357. var form = $.fn._form = function() {
  3358. return typeof this[ 0 ].form === "string" ? this.closest( "form" ) : $( this[ 0 ].form );
  3359. };
  3360. /*!
  3361. * jQuery UI Form Reset Mixin 1.13.2
  3362. * http://jqueryui.com
  3363. *
  3364. * Copyright jQuery Foundation and other contributors
  3365. * Released under the MIT license.
  3366. * http://jquery.org/license
  3367. */
  3368. //>>label: Form Reset Mixin
  3369. //>>group: Core
  3370. //>>description: Refresh input widgets when their form is reset
  3371. //>>docs: http://api.jqueryui.com/form-reset-mixin/
  3372. var formResetMixin = $.ui.formResetMixin = {
  3373. _formResetHandler: function() {
  3374. var form = $( this );
  3375. // Wait for the form reset to actually happen before refreshing
  3376. setTimeout( function() {
  3377. var instances = form.data( "ui-form-reset-instances" );
  3378. $.each( instances, function() {
  3379. this.refresh();
  3380. } );
  3381. } );
  3382. },
  3383. _bindFormResetHandler: function() {
  3384. this.form = this.element._form();
  3385. if ( !this.form.length ) {
  3386. return;
  3387. }
  3388. var instances = this.form.data( "ui-form-reset-instances" ) || [];
  3389. if ( !instances.length ) {
  3390. // We don't use _on() here because we use a single event handler per form
  3391. this.form.on( "reset.ui-form-reset", this._formResetHandler );
  3392. }
  3393. instances.push( this );
  3394. this.form.data( "ui-form-reset-instances", instances );
  3395. },
  3396. _unbindFormResetHandler: function() {
  3397. if ( !this.form.length ) {
  3398. return;
  3399. }
  3400. var instances = this.form.data( "ui-form-reset-instances" );
  3401. instances.splice( $.inArray( this, instances ), 1 );
  3402. if ( instances.length ) {
  3403. this.form.data( "ui-form-reset-instances", instances );
  3404. } else {
  3405. this.form
  3406. .removeData( "ui-form-reset-instances" )
  3407. .off( "reset.ui-form-reset" );
  3408. }
  3409. }
  3410. };
  3411. /*!
  3412. * jQuery UI Support for jQuery core 1.8.x and newer 1.13.2
  3413. * http://jqueryui.com
  3414. *
  3415. * Copyright jQuery Foundation and other contributors
  3416. * Released under the MIT license.
  3417. * http://jquery.org/license
  3418. *
  3419. */
  3420. //>>label: jQuery 1.8+ Support
  3421. //>>group: Core
  3422. //>>description: Support version 1.8.x and newer of jQuery core
  3423. // Support: jQuery 1.9.x or older
  3424. // $.expr[ ":" ] is deprecated.
  3425. if ( !$.expr.pseudos ) {
  3426. $.expr.pseudos = $.expr[ ":" ];
  3427. }
  3428. // Support: jQuery 1.11.x or older
  3429. // $.unique has been renamed to $.uniqueSort
  3430. if ( !$.uniqueSort ) {
  3431. $.uniqueSort = $.unique;
  3432. }
  3433. // Support: jQuery 2.2.x or older.
  3434. // This method has been defined in jQuery 3.0.0.
  3435. // Code from https://github.com/jquery/jquery/blob/e539bac79e666bba95bba86d690b4e609dca2286/src/selector/escapeSelector.js
  3436. if ( !$.escapeSelector ) {
  3437. // CSS string/identifier serialization
  3438. // https://drafts.csswg.org/cssom/#common-serializing-idioms
  3439. var rcssescape = /([\0-\x1f\x7f]|^-?\d)|^-$|[^\x80-\uFFFF\w-]/g;
  3440. var fcssescape = function( ch, asCodePoint ) {
  3441. if ( asCodePoint ) {
  3442. // U+0000 NULL becomes U+FFFD REPLACEMENT CHARACTER
  3443. if ( ch === "\0" ) {
  3444. return "\uFFFD";
  3445. }
  3446. // Control characters and (dependent upon position) numbers get escaped as code points
  3447. return ch.slice( 0, -1 ) + "\\" + ch.charCodeAt( ch.length - 1 ).toString( 16 ) + " ";
  3448. }
  3449. // Other potentially-special ASCII characters get backslash-escaped
  3450. return "\\" + ch;
  3451. };
  3452. $.escapeSelector = function( sel ) {
  3453. return ( sel + "" ).replace( rcssescape, fcssescape );
  3454. };
  3455. }
  3456. // Support: jQuery 3.4.x or older
  3457. // These methods have been defined in jQuery 3.5.0.
  3458. if ( !$.fn.even || !$.fn.odd ) {
  3459. $.fn.extend( {
  3460. even: function() {
  3461. return this.filter( function( i ) {
  3462. return i % 2 === 0;
  3463. } );
  3464. },
  3465. odd: function() {
  3466. return this.filter( function( i ) {
  3467. return i % 2 === 1;
  3468. } );
  3469. }
  3470. } );
  3471. }
  3472. ;
  3473. /*!
  3474. * jQuery UI Keycode 1.13.2
  3475. * http://jqueryui.com
  3476. *
  3477. * Copyright jQuery Foundation and other contributors
  3478. * Released under the MIT license.
  3479. * http://jquery.org/license
  3480. */
  3481. //>>label: Keycode
  3482. //>>group: Core
  3483. //>>description: Provide keycodes as keynames
  3484. //>>docs: http://api.jqueryui.com/jQuery.ui.keyCode/
  3485. var keycode = $.ui.keyCode = {
  3486. BACKSPACE: 8,
  3487. COMMA: 188,
  3488. DELETE: 46,
  3489. DOWN: 40,
  3490. END: 35,
  3491. ENTER: 13,
  3492. ESCAPE: 27,
  3493. HOME: 36,
  3494. LEFT: 37,
  3495. PAGE_DOWN: 34,
  3496. PAGE_UP: 33,
  3497. PERIOD: 190,
  3498. RIGHT: 39,
  3499. SPACE: 32,
  3500. TAB: 9,
  3501. UP: 38
  3502. };
  3503. /*!
  3504. * jQuery UI Labels 1.13.2
  3505. * http://jqueryui.com
  3506. *
  3507. * Copyright jQuery Foundation and other contributors
  3508. * Released under the MIT license.
  3509. * http://jquery.org/license
  3510. */
  3511. //>>label: labels
  3512. //>>group: Core
  3513. //>>description: Find all the labels associated with a given input
  3514. //>>docs: http://api.jqueryui.com/labels/
  3515. var labels = $.fn.labels = function() {
  3516. var ancestor, selector, id, labels, ancestors;
  3517. if ( !this.length ) {
  3518. return this.pushStack( [] );
  3519. }
  3520. // Check control.labels first
  3521. if ( this[ 0 ].labels && this[ 0 ].labels.length ) {
  3522. return this.pushStack( this[ 0 ].labels );
  3523. }
  3524. // Support: IE <= 11, FF <= 37, Android <= 2.3 only
  3525. // Above browsers do not support control.labels. Everything below is to support them
  3526. // as well as document fragments. control.labels does not work on document fragments
  3527. labels = this.eq( 0 ).parents( "label" );
  3528. // Look for the label based on the id
  3529. id = this.attr( "id" );
  3530. if ( id ) {
  3531. // We don't search against the document in case the element
  3532. // is disconnected from the DOM
  3533. ancestor = this.eq( 0 ).parents().last();
  3534. // Get a full set of top level ancestors
  3535. ancestors = ancestor.add( ancestor.length ? ancestor.siblings() : this.siblings() );
  3536. // Create a selector for the label based on the id
  3537. selector = "label[for='" + $.escapeSelector( id ) + "']";
  3538. labels = labels.add( ancestors.find( selector ).addBack( selector ) );
  3539. }
  3540. // Return whatever we have found for labels
  3541. return this.pushStack( labels );
  3542. };
  3543. /*!
  3544. * jQuery UI Scroll Parent 1.13.2
  3545. * http://jqueryui.com
  3546. *
  3547. * Copyright jQuery Foundation and other contributors
  3548. * Released under the MIT license.
  3549. * http://jquery.org/license
  3550. */
  3551. //>>label: scrollParent
  3552. //>>group: Core
  3553. //>>description: Get the closest ancestor element that is scrollable.
  3554. //>>docs: http://api.jqueryui.com/scrollParent/
  3555. var scrollParent = $.fn.scrollParent = function( includeHidden ) {
  3556. var position = this.css( "position" ),
  3557. excludeStaticParent = position === "absolute",
  3558. overflowRegex = includeHidden ? /(auto|scroll|hidden)/ : /(auto|scroll)/,
  3559. scrollParent = this.parents().filter( function() {
  3560. var parent = $( this );
  3561. if ( excludeStaticParent && parent.css( "position" ) === "static" ) {
  3562. return false;
  3563. }
  3564. return overflowRegex.test( parent.css( "overflow" ) + parent.css( "overflow-y" ) +
  3565. parent.css( "overflow-x" ) );
  3566. } ).eq( 0 );
  3567. return position === "fixed" || !scrollParent.length ?
  3568. $( this[ 0 ].ownerDocument || document ) :
  3569. scrollParent;
  3570. };
  3571. /*!
  3572. * jQuery UI Tabbable 1.13.2
  3573. * http://jqueryui.com
  3574. *
  3575. * Copyright jQuery Foundation and other contributors
  3576. * Released under the MIT license.
  3577. * http://jquery.org/license
  3578. */
  3579. //>>label: :tabbable Selector
  3580. //>>group: Core
  3581. //>>description: Selects elements which can be tabbed to.
  3582. //>>docs: http://api.jqueryui.com/tabbable-selector/
  3583. var tabbable = $.extend( $.expr.pseudos, {
  3584. tabbable: function( element ) {
  3585. var tabIndex = $.attr( element, "tabindex" ),
  3586. hasTabindex = tabIndex != null;
  3587. return ( !hasTabindex || tabIndex >= 0 ) && $.ui.focusable( element, hasTabindex );
  3588. }
  3589. } );
  3590. /*!
  3591. * jQuery UI Unique ID 1.13.2
  3592. * http://jqueryui.com
  3593. *
  3594. * Copyright jQuery Foundation and other contributors
  3595. * Released under the MIT license.
  3596. * http://jquery.org/license
  3597. */
  3598. //>>label: uniqueId
  3599. //>>group: Core
  3600. //>>description: Functions to generate and remove uniqueId's
  3601. //>>docs: http://api.jqueryui.com/uniqueId/
  3602. var uniqueId = $.fn.extend( {
  3603. uniqueId: ( function() {
  3604. var uuid = 0;
  3605. return function() {
  3606. return this.each( function() {
  3607. if ( !this.id ) {
  3608. this.id = "ui-id-" + ( ++uuid );
  3609. }
  3610. } );
  3611. };
  3612. } )(),
  3613. removeUniqueId: function() {
  3614. return this.each( function() {
  3615. if ( /^ui-id-\d+$/.test( this.id ) ) {
  3616. $( this ).removeAttr( "id" );
  3617. }
  3618. } );
  3619. }
  3620. } );
  3621. /*!
  3622. * jQuery UI Accordion 1.13.2
  3623. * http://jqueryui.com
  3624. *
  3625. * Copyright jQuery Foundation and other contributors
  3626. * Released under the MIT license.
  3627. * http://jquery.org/license
  3628. */
  3629. //>>label: Accordion
  3630. //>>group: Widgets
  3631. /* eslint-disable max-len */
  3632. //>>description: Displays collapsible content panels for presenting information in a limited amount of space.
  3633. /* eslint-enable max-len */
  3634. //>>docs: http://api.jqueryui.com/accordion/
  3635. //>>demos: http://jqueryui.com/accordion/
  3636. //>>css.structure: ../../themes/base/core.css
  3637. //>>css.structure: ../../themes/base/accordion.css
  3638. //>>css.theme: ../../themes/base/theme.css
  3639. var widgetsAccordion = $.widget( "ui.accordion", {
  3640. version: "1.13.2",
  3641. options: {
  3642. active: 0,
  3643. animate: {},
  3644. classes: {
  3645. "ui-accordion-header": "ui-corner-top",
  3646. "ui-accordion-header-collapsed": "ui-corner-all",
  3647. "ui-accordion-content": "ui-corner-bottom"
  3648. },
  3649. collapsible: false,
  3650. event: "click",
  3651. header: function( elem ) {
  3652. return elem.find( "> li > :first-child" ).add( elem.find( "> :not(li)" ).even() );
  3653. },
  3654. heightStyle: "auto",
  3655. icons: {
  3656. activeHeader: "ui-icon-triangle-1-s",
  3657. header: "ui-icon-triangle-1-e"
  3658. },
  3659. // Callbacks
  3660. activate: null,
  3661. beforeActivate: null
  3662. },
  3663. hideProps: {
  3664. borderTopWidth: "hide",
  3665. borderBottomWidth: "hide",
  3666. paddingTop: "hide",
  3667. paddingBottom: "hide",
  3668. height: "hide"
  3669. },
  3670. showProps: {
  3671. borderTopWidth: "show",
  3672. borderBottomWidth: "show",
  3673. paddingTop: "show",
  3674. paddingBottom: "show",
  3675. height: "show"
  3676. },
  3677. _create: function() {
  3678. var options = this.options;
  3679. this.prevShow = this.prevHide = $();
  3680. this._addClass( "ui-accordion", "ui-widget ui-helper-reset" );
  3681. this.element.attr( "role", "tablist" );
  3682. // Don't allow collapsible: false and active: false / null
  3683. if ( !options.collapsible && ( options.active === false || options.active == null ) ) {
  3684. options.active = 0;
  3685. }
  3686. this._processPanels();
  3687. // handle negative values
  3688. if ( options.active < 0 ) {
  3689. options.active += this.headers.length;
  3690. }
  3691. this._refresh();
  3692. },
  3693. _getCreateEventData: function() {
  3694. return {
  3695. header: this.active,
  3696. panel: !this.active.length ? $() : this.active.next()
  3697. };
  3698. },
  3699. _createIcons: function() {
  3700. var icon, children,
  3701. icons = this.options.icons;
  3702. if ( icons ) {
  3703. icon = $( "<span>" );
  3704. this._addClass( icon, "ui-accordion-header-icon", "ui-icon " + icons.header );
  3705. icon.prependTo( this.headers );
  3706. children = this.active.children( ".ui-accordion-header-icon" );
  3707. this._removeClass( children, icons.header )
  3708. ._addClass( children, null, icons.activeHeader )
  3709. ._addClass( this.headers, "ui-accordion-icons" );
  3710. }
  3711. },
  3712. _destroyIcons: function() {
  3713. this._removeClass( this.headers, "ui-accordion-icons" );
  3714. this.headers.children( ".ui-accordion-header-icon" ).remove();
  3715. },
  3716. _destroy: function() {
  3717. var contents;
  3718. // Clean up main element
  3719. this.element.removeAttr( "role" );
  3720. // Clean up headers
  3721. this.headers
  3722. .removeAttr( "role aria-expanded aria-selected aria-controls tabIndex" )
  3723. .removeUniqueId();
  3724. this._destroyIcons();
  3725. // Clean up content panels
  3726. contents = this.headers.next()
  3727. .css( "display", "" )
  3728. .removeAttr( "role aria-hidden aria-labelledby" )
  3729. .removeUniqueId();
  3730. if ( this.options.heightStyle !== "content" ) {
  3731. contents.css( "height", "" );
  3732. }
  3733. },
  3734. _setOption: function( key, value ) {
  3735. if ( key === "active" ) {
  3736. // _activate() will handle invalid values and update this.options
  3737. this._activate( value );
  3738. return;
  3739. }
  3740. if ( key === "event" ) {
  3741. if ( this.options.event ) {
  3742. this._off( this.headers, this.options.event );
  3743. }
  3744. this._setupEvents( value );
  3745. }
  3746. this._super( key, value );
  3747. // Setting collapsible: false while collapsed; open first panel
  3748. if ( key === "collapsible" && !value && this.options.active === false ) {
  3749. this._activate( 0 );
  3750. }
  3751. if ( key === "icons" ) {
  3752. this._destroyIcons();
  3753. if ( value ) {
  3754. this._createIcons();
  3755. }
  3756. }
  3757. },
  3758. _setOptionDisabled: function( value ) {
  3759. this._super( value );
  3760. this.element.attr( "aria-disabled", value );
  3761. // Support: IE8 Only
  3762. // #5332 / #6059 - opacity doesn't cascade to positioned elements in IE
  3763. // so we need to add the disabled class to the headers and panels
  3764. this._toggleClass( null, "ui-state-disabled", !!value );
  3765. this._toggleClass( this.headers.add( this.headers.next() ), null, "ui-state-disabled",
  3766. !!value );
  3767. },
  3768. _keydown: function( event ) {
  3769. if ( event.altKey || event.ctrlKey ) {
  3770. return;
  3771. }
  3772. var keyCode = $.ui.keyCode,
  3773. length = this.headers.length,
  3774. currentIndex = this.headers.index( event.target ),
  3775. toFocus = false;
  3776. switch ( event.keyCode ) {
  3777. case keyCode.RIGHT:
  3778. case keyCode.DOWN:
  3779. toFocus = this.headers[ ( currentIndex + 1 ) % length ];
  3780. break;
  3781. case keyCode.LEFT:
  3782. case keyCode.UP:
  3783. toFocus = this.headers[ ( currentIndex - 1 + length ) % length ];
  3784. break;
  3785. case keyCode.SPACE:
  3786. case keyCode.ENTER:
  3787. this._eventHandler( event );
  3788. break;
  3789. case keyCode.HOME:
  3790. toFocus = this.headers[ 0 ];
  3791. break;
  3792. case keyCode.END:
  3793. toFocus = this.headers[ length - 1 ];
  3794. break;
  3795. }
  3796. if ( toFocus ) {
  3797. $( event.target ).attr( "tabIndex", -1 );
  3798. $( toFocus ).attr( "tabIndex", 0 );
  3799. $( toFocus ).trigger( "focus" );
  3800. event.preventDefault();
  3801. }
  3802. },
  3803. _panelKeyDown: function( event ) {
  3804. if ( event.keyCode === $.ui.keyCode.UP && event.ctrlKey ) {
  3805. $( event.currentTarget ).prev().trigger( "focus" );
  3806. }
  3807. },
  3808. refresh: function() {
  3809. var options = this.options;
  3810. this._processPanels();
  3811. // Was collapsed or no panel
  3812. if ( ( options.active === false && options.collapsible === true ) ||
  3813. !this.headers.length ) {
  3814. options.active = false;
  3815. this.active = $();
  3816. // active false only when collapsible is true
  3817. } else if ( options.active === false ) {
  3818. this._activate( 0 );
  3819. // was active, but active panel is gone
  3820. } else if ( this.active.length && !$.contains( this.element[ 0 ], this.active[ 0 ] ) ) {
  3821. // all remaining panel are disabled
  3822. if ( this.headers.length === this.headers.find( ".ui-state-disabled" ).length ) {
  3823. options.active = false;
  3824. this.active = $();
  3825. // activate previous panel
  3826. } else {
  3827. this._activate( Math.max( 0, options.active - 1 ) );
  3828. }
  3829. // was active, active panel still exists
  3830. } else {
  3831. // make sure active index is correct
  3832. options.active = this.headers.index( this.active );
  3833. }
  3834. this._destroyIcons();
  3835. this._refresh();
  3836. },
  3837. _processPanels: function() {
  3838. var prevHeaders = this.headers,
  3839. prevPanels = this.panels;
  3840. if ( typeof this.options.header === "function" ) {
  3841. this.headers = this.options.header( this.element );
  3842. } else {
  3843. this.headers = this.element.find( this.options.header );
  3844. }
  3845. this._addClass( this.headers, "ui-accordion-header ui-accordion-header-collapsed",
  3846. "ui-state-default" );
  3847. this.panels = this.headers.next().filter( ":not(.ui-accordion-content-active)" ).hide();
  3848. this._addClass( this.panels, "ui-accordion-content", "ui-helper-reset ui-widget-content" );
  3849. // Avoid memory leaks (#10056)
  3850. if ( prevPanels ) {
  3851. this._off( prevHeaders.not( this.headers ) );
  3852. this._off( prevPanels.not( this.panels ) );
  3853. }
  3854. },
  3855. _refresh: function() {
  3856. var maxHeight,
  3857. options = this.options,
  3858. heightStyle = options.heightStyle,
  3859. parent = this.element.parent();
  3860. this.active = this._findActive( options.active );
  3861. this._addClass( this.active, "ui-accordion-header-active", "ui-state-active" )
  3862. ._removeClass( this.active, "ui-accordion-header-collapsed" );
  3863. this._addClass( this.active.next(), "ui-accordion-content-active" );
  3864. this.active.next().show();
  3865. this.headers
  3866. .attr( "role", "tab" )
  3867. .each( function() {
  3868. var header = $( this ),
  3869. headerId = header.uniqueId().attr( "id" ),
  3870. panel = header.next(),
  3871. panelId = panel.uniqueId().attr( "id" );
  3872. header.attr( "aria-controls", panelId );
  3873. panel.attr( "aria-labelledby", headerId );
  3874. } )
  3875. .next()
  3876. .attr( "role", "tabpanel" );
  3877. this.headers
  3878. .not( this.active )
  3879. .attr( {
  3880. "aria-selected": "false",
  3881. "aria-expanded": "false",
  3882. tabIndex: -1
  3883. } )
  3884. .next()
  3885. .attr( {
  3886. "aria-hidden": "true"
  3887. } )
  3888. .hide();
  3889. // Make sure at least one header is in the tab order
  3890. if ( !this.active.length ) {
  3891. this.headers.eq( 0 ).attr( "tabIndex", 0 );
  3892. } else {
  3893. this.active.attr( {
  3894. "aria-selected": "true",
  3895. "aria-expanded": "true",
  3896. tabIndex: 0
  3897. } )
  3898. .next()
  3899. .attr( {
  3900. "aria-hidden": "false"
  3901. } );
  3902. }
  3903. this._createIcons();
  3904. this._setupEvents( options.event );
  3905. if ( heightStyle === "fill" ) {
  3906. maxHeight = parent.height();
  3907. this.element.siblings( ":visible" ).each( function() {
  3908. var elem = $( this ),
  3909. position = elem.css( "position" );
  3910. if ( position === "absolute" || position === "fixed" ) {
  3911. return;
  3912. }
  3913. maxHeight -= elem.outerHeight( true );
  3914. } );
  3915. this.headers.each( function() {
  3916. maxHeight -= $( this ).outerHeight( true );
  3917. } );
  3918. this.headers.next()
  3919. .each( function() {
  3920. $( this ).height( Math.max( 0, maxHeight -
  3921. $( this ).innerHeight() + $( this ).height() ) );
  3922. } )
  3923. .css( "overflow", "auto" );
  3924. } else if ( heightStyle === "auto" ) {
  3925. maxHeight = 0;
  3926. this.headers.next()
  3927. .each( function() {
  3928. var isVisible = $( this ).is( ":visible" );
  3929. if ( !isVisible ) {
  3930. $( this ).show();
  3931. }
  3932. maxHeight = Math.max( maxHeight, $( this ).css( "height", "" ).height() );
  3933. if ( !isVisible ) {
  3934. $( this ).hide();
  3935. }
  3936. } )
  3937. .height( maxHeight );
  3938. }
  3939. },
  3940. _activate: function( index ) {
  3941. var active = this._findActive( index )[ 0 ];
  3942. // Trying to activate the already active panel
  3943. if ( active === this.active[ 0 ] ) {
  3944. return;
  3945. }
  3946. // Trying to collapse, simulate a click on the currently active header
  3947. active = active || this.active[ 0 ];
  3948. this._eventHandler( {
  3949. target: active,
  3950. currentTarget: active,
  3951. preventDefault: $.noop
  3952. } );
  3953. },
  3954. _findActive: function( selector ) {
  3955. return typeof selector === "number" ? this.headers.eq( selector ) : $();
  3956. },
  3957. _setupEvents: function( event ) {
  3958. var events = {
  3959. keydown: "_keydown"
  3960. };
  3961. if ( event ) {
  3962. $.each( event.split( " " ), function( index, eventName ) {
  3963. events[ eventName ] = "_eventHandler";
  3964. } );
  3965. }
  3966. this._off( this.headers.add( this.headers.next() ) );
  3967. this._on( this.headers, events );
  3968. this._on( this.headers.next(), { keydown: "_panelKeyDown" } );
  3969. this._hoverable( this.headers );
  3970. this._focusable( this.headers );
  3971. },
  3972. _eventHandler: function( event ) {
  3973. var activeChildren, clickedChildren,
  3974. options = this.options,
  3975. active = this.active,
  3976. clicked = $( event.currentTarget ),
  3977. clickedIsActive = clicked[ 0 ] === active[ 0 ],
  3978. collapsing = clickedIsActive && options.collapsible,
  3979. toShow = collapsing ? $() : clicked.next(),
  3980. toHide = active.next(),
  3981. eventData = {
  3982. oldHeader: active,
  3983. oldPanel: toHide,
  3984. newHeader: collapsing ? $() : clicked,
  3985. newPanel: toShow
  3986. };
  3987. event.preventDefault();
  3988. if (
  3989. // click on active header, but not collapsible
  3990. ( clickedIsActive && !options.collapsible ) ||
  3991. // allow canceling activation
  3992. ( this._trigger( "beforeActivate", event, eventData ) === false ) ) {
  3993. return;
  3994. }
  3995. options.active = collapsing ? false : this.headers.index( clicked );
  3996. // When the call to ._toggle() comes after the class changes
  3997. // it causes a very odd bug in IE 8 (see #6720)
  3998. this.active = clickedIsActive ? $() : clicked;
  3999. this._toggle( eventData );
  4000. // Switch classes
  4001. // corner classes on the previously active header stay after the animation
  4002. this._removeClass( active, "ui-accordion-header-active", "ui-state-active" );
  4003. if ( options.icons ) {
  4004. activeChildren = active.children( ".ui-accordion-header-icon" );
  4005. this._removeClass( activeChildren, null, options.icons.activeHeader )
  4006. ._addClass( activeChildren, null, options.icons.header );
  4007. }
  4008. if ( !clickedIsActive ) {
  4009. this._removeClass( clicked, "ui-accordion-header-collapsed" )
  4010. ._addClass( clicked, "ui-accordion-header-active", "ui-state-active" );
  4011. if ( options.icons ) {
  4012. clickedChildren = clicked.children( ".ui-accordion-header-icon" );
  4013. this._removeClass( clickedChildren, null, options.icons.header )
  4014. ._addClass( clickedChildren, null, options.icons.activeHeader );
  4015. }
  4016. this._addClass( clicked.next(), "ui-accordion-content-active" );
  4017. }
  4018. },
  4019. _toggle: function( data ) {
  4020. var toShow = data.newPanel,
  4021. toHide = this.prevShow.length ? this.prevShow : data.oldPanel;
  4022. // Handle activating a panel during the animation for another activation
  4023. this.prevShow.add( this.prevHide ).stop( true, true );
  4024. this.prevShow = toShow;
  4025. this.prevHide = toHide;
  4026. if ( this.options.animate ) {
  4027. this._animate( toShow, toHide, data );
  4028. } else {
  4029. toHide.hide();
  4030. toShow.show();
  4031. this._toggleComplete( data );
  4032. }
  4033. toHide.attr( {
  4034. "aria-hidden": "true"
  4035. } );
  4036. toHide.prev().attr( {
  4037. "aria-selected": "false",
  4038. "aria-expanded": "false"
  4039. } );
  4040. // if we're switching panels, remove the old header from the tab order
  4041. // if we're opening from collapsed state, remove the previous header from the tab order
  4042. // if we're collapsing, then keep the collapsing header in the tab order
  4043. if ( toShow.length && toHide.length ) {
  4044. toHide.prev().attr( {
  4045. "tabIndex": -1,
  4046. "aria-expanded": "false"
  4047. } );
  4048. } else if ( toShow.length ) {
  4049. this.headers.filter( function() {
  4050. return parseInt( $( this ).attr( "tabIndex" ), 10 ) === 0;
  4051. } )
  4052. .attr( "tabIndex", -1 );
  4053. }
  4054. toShow
  4055. .attr( "aria-hidden", "false" )
  4056. .prev()
  4057. .attr( {
  4058. "aria-selected": "true",
  4059. "aria-expanded": "true",
  4060. tabIndex: 0
  4061. } );
  4062. },
  4063. _animate: function( toShow, toHide, data ) {
  4064. var total, easing, duration,
  4065. that = this,
  4066. adjust = 0,
  4067. boxSizing = toShow.css( "box-sizing" ),
  4068. down = toShow.length &&
  4069. ( !toHide.length || ( toShow.index() < toHide.index() ) ),
  4070. animate = this.options.animate || {},
  4071. options = down && animate.down || animate,
  4072. complete = function() {
  4073. that._toggleComplete( data );
  4074. };
  4075. if ( typeof options === "number" ) {
  4076. duration = options;
  4077. }
  4078. if ( typeof options === "string" ) {
  4079. easing = options;
  4080. }
  4081. // fall back from options to animation in case of partial down settings
  4082. easing = easing || options.easing || animate.easing;
  4083. duration = duration || options.duration || animate.duration;
  4084. if ( !toHide.length ) {
  4085. return toShow.animate( this.showProps, duration, easing, complete );
  4086. }
  4087. if ( !toShow.length ) {
  4088. return toHide.animate( this.hideProps, duration, easing, complete );
  4089. }
  4090. total = toShow.show().outerHeight();
  4091. toHide.animate( this.hideProps, {
  4092. duration: duration,
  4093. easing: easing,
  4094. step: function( now, fx ) {
  4095. fx.now = Math.round( now );
  4096. }
  4097. } );
  4098. toShow
  4099. .hide()
  4100. .animate( this.showProps, {
  4101. duration: duration,
  4102. easing: easing,
  4103. complete: complete,
  4104. step: function( now, fx ) {
  4105. fx.now = Math.round( now );
  4106. if ( fx.prop !== "height" ) {
  4107. if ( boxSizing === "content-box" ) {
  4108. adjust += fx.now;
  4109. }
  4110. } else if ( that.options.heightStyle !== "content" ) {
  4111. fx.now = Math.round( total - toHide.outerHeight() - adjust );
  4112. adjust = 0;
  4113. }
  4114. }
  4115. } );
  4116. },
  4117. _toggleComplete: function( data ) {
  4118. var toHide = data.oldPanel,
  4119. prev = toHide.prev();
  4120. this._removeClass( toHide, "ui-accordion-content-active" );
  4121. this._removeClass( prev, "ui-accordion-header-active" )
  4122. ._addClass( prev, "ui-accordion-header-collapsed" );
  4123. // Work around for rendering bug in IE (#5421)
  4124. if ( toHide.length ) {
  4125. toHide.parent()[ 0 ].className = toHide.parent()[ 0 ].className;
  4126. }
  4127. this._trigger( "activate", null, data );
  4128. }
  4129. } );
  4130. var safeActiveElement = $.ui.safeActiveElement = function( document ) {
  4131. var activeElement;
  4132. // Support: IE 9 only
  4133. // IE9 throws an "Unspecified error" accessing document.activeElement from an <iframe>
  4134. try {
  4135. activeElement = document.activeElement;
  4136. } catch ( error ) {
  4137. activeElement = document.body;
  4138. }
  4139. // Support: IE 9 - 11 only
  4140. // IE may return null instead of an element
  4141. // Interestingly, this only seems to occur when NOT in an iframe
  4142. if ( !activeElement ) {
  4143. activeElement = document.body;
  4144. }
  4145. // Support: IE 11 only
  4146. // IE11 returns a seemingly empty object in some cases when accessing
  4147. // document.activeElement from an <iframe>
  4148. if ( !activeElement.nodeName ) {
  4149. activeElement = document.body;
  4150. }
  4151. return activeElement;
  4152. };
  4153. /*!
  4154. * jQuery UI Menu 1.13.2
  4155. * http://jqueryui.com
  4156. *
  4157. * Copyright jQuery Foundation and other contributors
  4158. * Released under the MIT license.
  4159. * http://jquery.org/license
  4160. */
  4161. //>>label: Menu
  4162. //>>group: Widgets
  4163. //>>description: Creates nestable menus.
  4164. //>>docs: http://api.jqueryui.com/menu/
  4165. //>>demos: http://jqueryui.com/menu/
  4166. //>>css.structure: ../../themes/base/core.css
  4167. //>>css.structure: ../../themes/base/menu.css
  4168. //>>css.theme: ../../themes/base/theme.css
  4169. var widgetsMenu = $.widget( "ui.menu", {
  4170. version: "1.13.2",
  4171. defaultElement: "<ul>",
  4172. delay: 300,
  4173. options: {
  4174. icons: {
  4175. submenu: "ui-icon-caret-1-e"
  4176. },
  4177. items: "> *",
  4178. menus: "ul",
  4179. position: {
  4180. my: "left top",
  4181. at: "right top"
  4182. },
  4183. role: "menu",
  4184. // Callbacks
  4185. blur: null,
  4186. focus: null,
  4187. select: null
  4188. },
  4189. _create: function() {
  4190. this.activeMenu = this.element;
  4191. // Flag used to prevent firing of the click handler
  4192. // as the event bubbles up through nested menus
  4193. this.mouseHandled = false;
  4194. this.lastMousePosition = { x: null, y: null };
  4195. this.element
  4196. .uniqueId()
  4197. .attr( {
  4198. role: this.options.role,
  4199. tabIndex: 0
  4200. } );
  4201. this._addClass( "ui-menu", "ui-widget ui-widget-content" );
  4202. this._on( {
  4203. // Prevent focus from sticking to links inside menu after clicking
  4204. // them (focus should always stay on UL during navigation).
  4205. "mousedown .ui-menu-item": function( event ) {
  4206. event.preventDefault();
  4207. this._activateItem( event );
  4208. },
  4209. "click .ui-menu-item": function( event ) {
  4210. var target = $( event.target );
  4211. var active = $( $.ui.safeActiveElement( this.document[ 0 ] ) );
  4212. if ( !this.mouseHandled && target.not( ".ui-state-disabled" ).length ) {
  4213. this.select( event );
  4214. // Only set the mouseHandled flag if the event will bubble, see #9469.
  4215. if ( !event.isPropagationStopped() ) {
  4216. this.mouseHandled = true;
  4217. }
  4218. // Open submenu on click
  4219. if ( target.has( ".ui-menu" ).length ) {
  4220. this.expand( event );
  4221. } else if ( !this.element.is( ":focus" ) &&
  4222. active.closest( ".ui-menu" ).length ) {
  4223. // Redirect focus to the menu
  4224. this.element.trigger( "focus", [ true ] );
  4225. // If the active item is on the top level, let it stay active.
  4226. // Otherwise, blur the active item since it is no longer visible.
  4227. if ( this.active && this.active.parents( ".ui-menu" ).length === 1 ) {
  4228. clearTimeout( this.timer );
  4229. }
  4230. }
  4231. }
  4232. },
  4233. "mouseenter .ui-menu-item": "_activateItem",
  4234. "mousemove .ui-menu-item": "_activateItem",
  4235. mouseleave: "collapseAll",
  4236. "mouseleave .ui-menu": "collapseAll",
  4237. focus: function( event, keepActiveItem ) {
  4238. // If there's already an active item, keep it active
  4239. // If not, activate the first item
  4240. var item = this.active || this._menuItems().first();
  4241. if ( !keepActiveItem ) {
  4242. this.focus( event, item );
  4243. }
  4244. },
  4245. blur: function( event ) {
  4246. this._delay( function() {
  4247. var notContained = !$.contains(
  4248. this.element[ 0 ],
  4249. $.ui.safeActiveElement( this.document[ 0 ] )
  4250. );
  4251. if ( notContained ) {
  4252. this.collapseAll( event );
  4253. }
  4254. } );
  4255. },
  4256. keydown: "_keydown"
  4257. } );
  4258. this.refresh();
  4259. // Clicks outside of a menu collapse any open menus
  4260. this._on( this.document, {
  4261. click: function( event ) {
  4262. if ( this._closeOnDocumentClick( event ) ) {
  4263. this.collapseAll( event, true );
  4264. }
  4265. // Reset the mouseHandled flag
  4266. this.mouseHandled = false;
  4267. }
  4268. } );
  4269. },
  4270. _activateItem: function( event ) {
  4271. // Ignore mouse events while typeahead is active, see #10458.
  4272. // Prevents focusing the wrong item when typeahead causes a scroll while the mouse
  4273. // is over an item in the menu
  4274. if ( this.previousFilter ) {
  4275. return;
  4276. }
  4277. // If the mouse didn't actually move, but the page was scrolled, ignore the event (#9356)
  4278. if ( event.clientX === this.lastMousePosition.x &&
  4279. event.clientY === this.lastMousePosition.y ) {
  4280. return;
  4281. }
  4282. this.lastMousePosition = {
  4283. x: event.clientX,
  4284. y: event.clientY
  4285. };
  4286. var actualTarget = $( event.target ).closest( ".ui-menu-item" ),
  4287. target = $( event.currentTarget );
  4288. // Ignore bubbled events on parent items, see #11641
  4289. if ( actualTarget[ 0 ] !== target[ 0 ] ) {
  4290. return;
  4291. }
  4292. // If the item is already active, there's nothing to do
  4293. if ( target.is( ".ui-state-active" ) ) {
  4294. return;
  4295. }
  4296. // Remove ui-state-active class from siblings of the newly focused menu item
  4297. // to avoid a jump caused by adjacent elements both having a class with a border
  4298. this._removeClass( target.siblings().children( ".ui-state-active" ),
  4299. null, "ui-state-active" );
  4300. this.focus( event, target );
  4301. },
  4302. _destroy: function() {
  4303. var items = this.element.find( ".ui-menu-item" )
  4304. .removeAttr( "role aria-disabled" ),
  4305. submenus = items.children( ".ui-menu-item-wrapper" )
  4306. .removeUniqueId()
  4307. .removeAttr( "tabIndex role aria-haspopup" );
  4308. // Destroy (sub)menus
  4309. this.element
  4310. .removeAttr( "aria-activedescendant" )
  4311. .find( ".ui-menu" ).addBack()
  4312. .removeAttr( "role aria-labelledby aria-expanded aria-hidden aria-disabled " +
  4313. "tabIndex" )
  4314. .removeUniqueId()
  4315. .show();
  4316. submenus.children().each( function() {
  4317. var elem = $( this );
  4318. if ( elem.data( "ui-menu-submenu-caret" ) ) {
  4319. elem.remove();
  4320. }
  4321. } );
  4322. },
  4323. _keydown: function( event ) {
  4324. var match, prev, character, skip,
  4325. preventDefault = true;
  4326. switch ( event.keyCode ) {
  4327. case $.ui.keyCode.PAGE_UP:
  4328. this.previousPage( event );
  4329. break;
  4330. case $.ui.keyCode.PAGE_DOWN:
  4331. this.nextPage( event );
  4332. break;
  4333. case $.ui.keyCode.HOME:
  4334. this._move( "first", "first", event );
  4335. break;
  4336. case $.ui.keyCode.END:
  4337. this._move( "last", "last", event );
  4338. break;
  4339. case $.ui.keyCode.UP:
  4340. this.previous( event );
  4341. break;
  4342. case $.ui.keyCode.DOWN:
  4343. this.next( event );
  4344. break;
  4345. case $.ui.keyCode.LEFT:
  4346. this.collapse( event );
  4347. break;
  4348. case $.ui.keyCode.RIGHT:
  4349. if ( this.active && !this.active.is( ".ui-state-disabled" ) ) {
  4350. this.expand( event );
  4351. }
  4352. break;
  4353. case $.ui.keyCode.ENTER:
  4354. case $.ui.keyCode.SPACE:
  4355. this._activate( event );
  4356. break;
  4357. case $.ui.keyCode.ESCAPE:
  4358. this.collapse( event );
  4359. break;
  4360. default:
  4361. preventDefault = false;
  4362. prev = this.previousFilter || "";
  4363. skip = false;
  4364. // Support number pad values
  4365. character = event.keyCode >= 96 && event.keyCode <= 105 ?
  4366. ( event.keyCode - 96 ).toString() : String.fromCharCode( event.keyCode );
  4367. clearTimeout( this.filterTimer );
  4368. if ( character === prev ) {
  4369. skip = true;
  4370. } else {
  4371. character = prev + character;
  4372. }
  4373. match = this._filterMenuItems( character );
  4374. match = skip && match.index( this.active.next() ) !== -1 ?
  4375. this.active.nextAll( ".ui-menu-item" ) :
  4376. match;
  4377. // If no matches on the current filter, reset to the last character pressed
  4378. // to move down the menu to the first item that starts with that character
  4379. if ( !match.length ) {
  4380. character = String.fromCharCode( event.keyCode );
  4381. match = this._filterMenuItems( character );
  4382. }
  4383. if ( match.length ) {
  4384. this.focus( event, match );
  4385. this.previousFilter = character;
  4386. this.filterTimer = this._delay( function() {
  4387. delete this.previousFilter;
  4388. }, 1000 );
  4389. } else {
  4390. delete this.previousFilter;
  4391. }
  4392. }
  4393. if ( preventDefault ) {
  4394. event.preventDefault();
  4395. }
  4396. },
  4397. _activate: function( event ) {
  4398. if ( this.active && !this.active.is( ".ui-state-disabled" ) ) {
  4399. if ( this.active.children( "[aria-haspopup='true']" ).length ) {
  4400. this.expand( event );
  4401. } else {
  4402. this.select( event );
  4403. }
  4404. }
  4405. },
  4406. refresh: function() {
  4407. var menus, items, newSubmenus, newItems, newWrappers,
  4408. that = this,
  4409. icon = this.options.icons.submenu,
  4410. submenus = this.element.find( this.options.menus );
  4411. this._toggleClass( "ui-menu-icons", null, !!this.element.find( ".ui-icon" ).length );
  4412. // Initialize nested menus
  4413. newSubmenus = submenus.filter( ":not(.ui-menu)" )
  4414. .hide()
  4415. .attr( {
  4416. role: this.options.role,
  4417. "aria-hidden": "true",
  4418. "aria-expanded": "false"
  4419. } )
  4420. .each( function() {
  4421. var menu = $( this ),
  4422. item = menu.prev(),
  4423. submenuCaret = $( "<span>" ).data( "ui-menu-submenu-caret", true );
  4424. that._addClass( submenuCaret, "ui-menu-icon", "ui-icon " + icon );
  4425. item
  4426. .attr( "aria-haspopup", "true" )
  4427. .prepend( submenuCaret );
  4428. menu.attr( "aria-labelledby", item.attr( "id" ) );
  4429. } );
  4430. this._addClass( newSubmenus, "ui-menu", "ui-widget ui-widget-content ui-front" );
  4431. menus = submenus.add( this.element );
  4432. items = menus.find( this.options.items );
  4433. // Initialize menu-items containing spaces and/or dashes only as dividers
  4434. items.not( ".ui-menu-item" ).each( function() {
  4435. var item = $( this );
  4436. if ( that._isDivider( item ) ) {
  4437. that._addClass( item, "ui-menu-divider", "ui-widget-content" );
  4438. }
  4439. } );
  4440. // Don't refresh list items that are already adapted
  4441. newItems = items.not( ".ui-menu-item, .ui-menu-divider" );
  4442. newWrappers = newItems.children()
  4443. .not( ".ui-menu" )
  4444. .uniqueId()
  4445. .attr( {
  4446. tabIndex: -1,
  4447. role: this._itemRole()
  4448. } );
  4449. this._addClass( newItems, "ui-menu-item" )
  4450. ._addClass( newWrappers, "ui-menu-item-wrapper" );
  4451. // Add aria-disabled attribute to any disabled menu item
  4452. items.filter( ".ui-state-disabled" ).attr( "aria-disabled", "true" );
  4453. // If the active item has been removed, blur the menu
  4454. if ( this.active && !$.contains( this.element[ 0 ], this.active[ 0 ] ) ) {
  4455. this.blur();
  4456. }
  4457. },
  4458. _itemRole: function() {
  4459. return {
  4460. menu: "menuitem",
  4461. listbox: "option"
  4462. }[ this.options.role ];
  4463. },
  4464. _setOption: function( key, value ) {
  4465. if ( key === "icons" ) {
  4466. var icons = this.element.find( ".ui-menu-icon" );
  4467. this._removeClass( icons, null, this.options.icons.submenu )
  4468. ._addClass( icons, null, value.submenu );
  4469. }
  4470. this._super( key, value );
  4471. },
  4472. _setOptionDisabled: function( value ) {
  4473. this._super( value );
  4474. this.element.attr( "aria-disabled", String( value ) );
  4475. this._toggleClass( null, "ui-state-disabled", !!value );
  4476. },
  4477. focus: function( event, item ) {
  4478. var nested, focused, activeParent;
  4479. this.blur( event, event && event.type === "focus" );
  4480. this._scrollIntoView( item );
  4481. this.active = item.first();
  4482. focused = this.active.children( ".ui-menu-item-wrapper" );
  4483. this._addClass( focused, null, "ui-state-active" );
  4484. // Only update aria-activedescendant if there's a role
  4485. // otherwise we assume focus is managed elsewhere
  4486. if ( this.options.role ) {
  4487. this.element.attr( "aria-activedescendant", focused.attr( "id" ) );
  4488. }
  4489. // Highlight active parent menu item, if any
  4490. activeParent = this.active
  4491. .parent()
  4492. .closest( ".ui-menu-item" )
  4493. .children( ".ui-menu-item-wrapper" );
  4494. this._addClass( activeParent, null, "ui-state-active" );
  4495. if ( event && event.type === "keydown" ) {
  4496. this._close();
  4497. } else {
  4498. this.timer = this._delay( function() {
  4499. this._close();
  4500. }, this.delay );
  4501. }
  4502. nested = item.children( ".ui-menu" );
  4503. if ( nested.length && event && ( /^mouse/.test( event.type ) ) ) {
  4504. this._startOpening( nested );
  4505. }
  4506. this.activeMenu = item.parent();
  4507. this._trigger( "focus", event, { item: item } );
  4508. },
  4509. _scrollIntoView: function( item ) {
  4510. var borderTop, paddingTop, offset, scroll, elementHeight, itemHeight;
  4511. if ( this._hasScroll() ) {
  4512. borderTop = parseFloat( $.css( this.activeMenu[ 0 ], "borderTopWidth" ) ) || 0;
  4513. paddingTop = parseFloat( $.css( this.activeMenu[ 0 ], "paddingTop" ) ) || 0;
  4514. offset = item.offset().top - this.activeMenu.offset().top - borderTop - paddingTop;
  4515. scroll = this.activeMenu.scrollTop();
  4516. elementHeight = this.activeMenu.height();
  4517. itemHeight = item.outerHeight();
  4518. if ( offset < 0 ) {
  4519. this.activeMenu.scrollTop( scroll + offset );
  4520. } else if ( offset + itemHeight > elementHeight ) {
  4521. this.activeMenu.scrollTop( scroll + offset - elementHeight + itemHeight );
  4522. }
  4523. }
  4524. },
  4525. blur: function( event, fromFocus ) {
  4526. if ( !fromFocus ) {
  4527. clearTimeout( this.timer );
  4528. }
  4529. if ( !this.active ) {
  4530. return;
  4531. }
  4532. this._removeClass( this.active.children( ".ui-menu-item-wrapper" ),
  4533. null, "ui-state-active" );
  4534. this._trigger( "blur", event, { item: this.active } );
  4535. this.active = null;
  4536. },
  4537. _startOpening: function( submenu ) {
  4538. clearTimeout( this.timer );
  4539. // Don't open if already open fixes a Firefox bug that caused a .5 pixel
  4540. // shift in the submenu position when mousing over the caret icon
  4541. if ( submenu.attr( "aria-hidden" ) !== "true" ) {
  4542. return;
  4543. }
  4544. this.timer = this._delay( function() {
  4545. this._close();
  4546. this._open( submenu );
  4547. }, this.delay );
  4548. },
  4549. _open: function( submenu ) {
  4550. var position = $.extend( {
  4551. of: this.active
  4552. }, this.options.position );
  4553. clearTimeout( this.timer );
  4554. this.element.find( ".ui-menu" ).not( submenu.parents( ".ui-menu" ) )
  4555. .hide()
  4556. .attr( "aria-hidden", "true" );
  4557. submenu
  4558. .show()
  4559. .removeAttr( "aria-hidden" )
  4560. .attr( "aria-expanded", "true" )
  4561. .position( position );
  4562. },
  4563. collapseAll: function( event, all ) {
  4564. clearTimeout( this.timer );
  4565. this.timer = this._delay( function() {
  4566. // If we were passed an event, look for the submenu that contains the event
  4567. var currentMenu = all ? this.element :
  4568. $( event && event.target ).closest( this.element.find( ".ui-menu" ) );
  4569. // If we found no valid submenu ancestor, use the main menu to close all
  4570. // sub menus anyway
  4571. if ( !currentMenu.length ) {
  4572. currentMenu = this.element;
  4573. }
  4574. this._close( currentMenu );
  4575. this.blur( event );
  4576. // Work around active item staying active after menu is blurred
  4577. this._removeClass( currentMenu.find( ".ui-state-active" ), null, "ui-state-active" );
  4578. this.activeMenu = currentMenu;
  4579. }, all ? 0 : this.delay );
  4580. },
  4581. // With no arguments, closes the currently active menu - if nothing is active
  4582. // it closes all menus. If passed an argument, it will search for menus BELOW
  4583. _close: function( startMenu ) {
  4584. if ( !startMenu ) {
  4585. startMenu = this.active ? this.active.parent() : this.element;
  4586. }
  4587. startMenu.find( ".ui-menu" )
  4588. .hide()
  4589. .attr( "aria-hidden", "true" )
  4590. .attr( "aria-expanded", "false" );
  4591. },
  4592. _closeOnDocumentClick: function( event ) {
  4593. return !$( event.target ).closest( ".ui-menu" ).length;
  4594. },
  4595. _isDivider: function( item ) {
  4596. // Match hyphen, em dash, en dash
  4597. return !/[^\-\u2014\u2013\s]/.test( item.text() );
  4598. },
  4599. collapse: function( event ) {
  4600. var newItem = this.active &&
  4601. this.active.parent().closest( ".ui-menu-item", this.element );
  4602. if ( newItem && newItem.length ) {
  4603. this._close();
  4604. this.focus( event, newItem );
  4605. }
  4606. },
  4607. expand: function( event ) {
  4608. var newItem = this.active && this._menuItems( this.active.children( ".ui-menu" ) ).first();
  4609. if ( newItem && newItem.length ) {
  4610. this._open( newItem.parent() );
  4611. // Delay so Firefox will not hide activedescendant change in expanding submenu from AT
  4612. this._delay( function() {
  4613. this.focus( event, newItem );
  4614. } );
  4615. }
  4616. },
  4617. next: function( event ) {
  4618. this._move( "next", "first", event );
  4619. },
  4620. previous: function( event ) {
  4621. this._move( "prev", "last", event );
  4622. },
  4623. isFirstItem: function() {
  4624. return this.active && !this.active.prevAll( ".ui-menu-item" ).length;
  4625. },
  4626. isLastItem: function() {
  4627. return this.active && !this.active.nextAll( ".ui-menu-item" ).length;
  4628. },
  4629. _menuItems: function( menu ) {
  4630. return ( menu || this.element )
  4631. .find( this.options.items )
  4632. .filter( ".ui-menu-item" );
  4633. },
  4634. _move: function( direction, filter, event ) {
  4635. var next;
  4636. if ( this.active ) {
  4637. if ( direction === "first" || direction === "last" ) {
  4638. next = this.active
  4639. [ direction === "first" ? "prevAll" : "nextAll" ]( ".ui-menu-item" )
  4640. .last();
  4641. } else {
  4642. next = this.active
  4643. [ direction + "All" ]( ".ui-menu-item" )
  4644. .first();
  4645. }
  4646. }
  4647. if ( !next || !next.length || !this.active ) {
  4648. next = this._menuItems( this.activeMenu )[ filter ]();
  4649. }
  4650. this.focus( event, next );
  4651. },
  4652. nextPage: function( event ) {
  4653. var item, base, height;
  4654. if ( !this.active ) {
  4655. this.next( event );
  4656. return;
  4657. }
  4658. if ( this.isLastItem() ) {
  4659. return;
  4660. }
  4661. if ( this._hasScroll() ) {
  4662. base = this.active.offset().top;
  4663. height = this.element.innerHeight();
  4664. // jQuery 3.2 doesn't include scrollbars in innerHeight, add it back.
  4665. if ( $.fn.jquery.indexOf( "3.2." ) === 0 ) {
  4666. height += this.element[ 0 ].offsetHeight - this.element.outerHeight();
  4667. }
  4668. this.active.nextAll( ".ui-menu-item" ).each( function() {
  4669. item = $( this );
  4670. return item.offset().top - base - height < 0;
  4671. } );
  4672. this.focus( event, item );
  4673. } else {
  4674. this.focus( event, this._menuItems( this.activeMenu )
  4675. [ !this.active ? "first" : "last" ]() );
  4676. }
  4677. },
  4678. previousPage: function( event ) {
  4679. var item, base, height;
  4680. if ( !this.active ) {
  4681. this.next( event );
  4682. return;
  4683. }
  4684. if ( this.isFirstItem() ) {
  4685. return;
  4686. }
  4687. if ( this._hasScroll() ) {
  4688. base = this.active.offset().top;
  4689. height = this.element.innerHeight();
  4690. // jQuery 3.2 doesn't include scrollbars in innerHeight, add it back.
  4691. if ( $.fn.jquery.indexOf( "3.2." ) === 0 ) {
  4692. height += this.element[ 0 ].offsetHeight - this.element.outerHeight();
  4693. }
  4694. this.active.prevAll( ".ui-menu-item" ).each( function() {
  4695. item = $( this );
  4696. return item.offset().top - base + height > 0;
  4697. } );
  4698. this.focus( event, item );
  4699. } else {
  4700. this.focus( event, this._menuItems( this.activeMenu ).first() );
  4701. }
  4702. },
  4703. _hasScroll: function() {
  4704. return this.element.outerHeight() < this.element.prop( "scrollHeight" );
  4705. },
  4706. select: function( event ) {
  4707. // TODO: It should never be possible to not have an active item at this
  4708. // point, but the tests don't trigger mouseenter before click.
  4709. this.active = this.active || $( event.target ).closest( ".ui-menu-item" );
  4710. var ui = { item: this.active };
  4711. if ( !this.active.has( ".ui-menu" ).length ) {
  4712. this.collapseAll( event, true );
  4713. }
  4714. this._trigger( "select", event, ui );
  4715. },
  4716. _filterMenuItems: function( character ) {
  4717. var escapedCharacter = character.replace( /[\-\[\]{}()*+?.,\\\^$|#\s]/g, "\\$&" ),
  4718. regex = new RegExp( "^" + escapedCharacter, "i" );
  4719. return this.activeMenu
  4720. .find( this.options.items )
  4721. // Only match on items, not dividers or other content (#10571)
  4722. .filter( ".ui-menu-item" )
  4723. .filter( function() {
  4724. return regex.test(
  4725. String.prototype.trim.call(
  4726. $( this ).children( ".ui-menu-item-wrapper" ).text() ) );
  4727. } );
  4728. }
  4729. } );
  4730. /*!
  4731. * jQuery UI Autocomplete 1.13.2
  4732. * http://jqueryui.com
  4733. *
  4734. * Copyright jQuery Foundation and other contributors
  4735. * Released under the MIT license.
  4736. * http://jquery.org/license
  4737. */
  4738. //>>label: Autocomplete
  4739. //>>group: Widgets
  4740. //>>description: Lists suggested words as the user is typing.
  4741. //>>docs: http://api.jqueryui.com/autocomplete/
  4742. //>>demos: http://jqueryui.com/autocomplete/
  4743. //>>css.structure: ../../themes/base/core.css
  4744. //>>css.structure: ../../themes/base/autocomplete.css
  4745. //>>css.theme: ../../themes/base/theme.css
  4746. $.widget( "ui.autocomplete", {
  4747. version: "1.13.2",
  4748. defaultElement: "<input>",
  4749. options: {
  4750. appendTo: null,
  4751. autoFocus: false,
  4752. delay: 300,
  4753. minLength: 1,
  4754. position: {
  4755. my: "left top",
  4756. at: "left bottom",
  4757. collision: "none"
  4758. },
  4759. source: null,
  4760. // Callbacks
  4761. change: null,
  4762. close: null,
  4763. focus: null,
  4764. open: null,
  4765. response: null,
  4766. search: null,
  4767. select: null
  4768. },
  4769. requestIndex: 0,
  4770. pending: 0,
  4771. liveRegionTimer: null,
  4772. _create: function() {
  4773. // Some browsers only repeat keydown events, not keypress events,
  4774. // so we use the suppressKeyPress flag to determine if we've already
  4775. // handled the keydown event. #7269
  4776. // Unfortunately the code for & in keypress is the same as the up arrow,
  4777. // so we use the suppressKeyPressRepeat flag to avoid handling keypress
  4778. // events when we know the keydown event was used to modify the
  4779. // search term. #7799
  4780. var suppressKeyPress, suppressKeyPressRepeat, suppressInput,
  4781. nodeName = this.element[ 0 ].nodeName.toLowerCase(),
  4782. isTextarea = nodeName === "textarea",
  4783. isInput = nodeName === "input";
  4784. // Textareas are always multi-line
  4785. // Inputs are always single-line, even if inside a contentEditable element
  4786. // IE also treats inputs as contentEditable
  4787. // All other element types are determined by whether or not they're contentEditable
  4788. this.isMultiLine = isTextarea || !isInput && this._isContentEditable( this.element );
  4789. this.valueMethod = this.element[ isTextarea || isInput ? "val" : "text" ];
  4790. this.isNewMenu = true;
  4791. this._addClass( "ui-autocomplete-input" );
  4792. this.element.attr( "autocomplete", "off" );
  4793. this._on( this.element, {
  4794. keydown: function( event ) {
  4795. if ( this.element.prop( "readOnly" ) ) {
  4796. suppressKeyPress = true;
  4797. suppressInput = true;
  4798. suppressKeyPressRepeat = true;
  4799. return;
  4800. }
  4801. suppressKeyPress = false;
  4802. suppressInput = false;
  4803. suppressKeyPressRepeat = false;
  4804. var keyCode = $.ui.keyCode;
  4805. switch ( event.keyCode ) {
  4806. case keyCode.PAGE_UP:
  4807. suppressKeyPress = true;
  4808. this._move( "previousPage", event );
  4809. break;
  4810. case keyCode.PAGE_DOWN:
  4811. suppressKeyPress = true;
  4812. this._move( "nextPage", event );
  4813. break;
  4814. case keyCode.UP:
  4815. suppressKeyPress = true;
  4816. this._keyEvent( "previous", event );
  4817. break;
  4818. case keyCode.DOWN:
  4819. suppressKeyPress = true;
  4820. this._keyEvent( "next", event );
  4821. break;
  4822. case keyCode.ENTER:
  4823. // when menu is open and has focus
  4824. if ( this.menu.active ) {
  4825. // #6055 - Opera still allows the keypress to occur
  4826. // which causes forms to submit
  4827. suppressKeyPress = true;
  4828. event.preventDefault();
  4829. this.menu.select( event );
  4830. }
  4831. break;
  4832. case keyCode.TAB:
  4833. if ( this.menu.active ) {
  4834. this.menu.select( event );
  4835. }
  4836. break;
  4837. case keyCode.ESCAPE:
  4838. if ( this.menu.element.is( ":visible" ) ) {
  4839. if ( !this.isMultiLine ) {
  4840. this._value( this.term );
  4841. }
  4842. this.close( event );
  4843. // Different browsers have different default behavior for escape
  4844. // Single press can mean undo or clear
  4845. // Double press in IE means clear the whole form
  4846. event.preventDefault();
  4847. }
  4848. break;
  4849. default:
  4850. suppressKeyPressRepeat = true;
  4851. // search timeout should be triggered before the input value is changed
  4852. this._searchTimeout( event );
  4853. break;
  4854. }
  4855. },
  4856. keypress: function( event ) {
  4857. if ( suppressKeyPress ) {
  4858. suppressKeyPress = false;
  4859. if ( !this.isMultiLine || this.menu.element.is( ":visible" ) ) {
  4860. event.preventDefault();
  4861. }
  4862. return;
  4863. }
  4864. if ( suppressKeyPressRepeat ) {
  4865. return;
  4866. }
  4867. // Replicate some key handlers to allow them to repeat in Firefox and Opera
  4868. var keyCode = $.ui.keyCode;
  4869. switch ( event.keyCode ) {
  4870. case keyCode.PAGE_UP:
  4871. this._move( "previousPage", event );
  4872. break;
  4873. case keyCode.PAGE_DOWN:
  4874. this._move( "nextPage", event );
  4875. break;
  4876. case keyCode.UP:
  4877. this._keyEvent( "previous", event );
  4878. break;
  4879. case keyCode.DOWN:
  4880. this._keyEvent( "next", event );
  4881. break;
  4882. }
  4883. },
  4884. input: function( event ) {
  4885. if ( suppressInput ) {
  4886. suppressInput = false;
  4887. event.preventDefault();
  4888. return;
  4889. }
  4890. this._searchTimeout( event );
  4891. },
  4892. focus: function() {
  4893. this.selectedItem = null;
  4894. this.previous = this._value();
  4895. },
  4896. blur: function( event ) {
  4897. clearTimeout( this.searching );
  4898. this.close( event );
  4899. this._change( event );
  4900. }
  4901. } );
  4902. this._initSource();
  4903. this.menu = $( "<ul>" )
  4904. .appendTo( this._appendTo() )
  4905. .menu( {
  4906. // disable ARIA support, the live region takes care of that
  4907. role: null
  4908. } )
  4909. .hide()
  4910. // Support: IE 11 only, Edge <= 14
  4911. // For other browsers, we preventDefault() on the mousedown event
  4912. // to keep the dropdown from taking focus from the input. This doesn't
  4913. // work for IE/Edge, causing problems with selection and scrolling (#9638)
  4914. // Happily, IE and Edge support an "unselectable" attribute that
  4915. // prevents an element from receiving focus, exactly what we want here.
  4916. .attr( {
  4917. "unselectable": "on"
  4918. } )
  4919. .menu( "instance" );
  4920. this._addClass( this.menu.element, "ui-autocomplete", "ui-front" );
  4921. this._on( this.menu.element, {
  4922. mousedown: function( event ) {
  4923. // Prevent moving focus out of the text field
  4924. event.preventDefault();
  4925. },
  4926. menufocus: function( event, ui ) {
  4927. var label, item;
  4928. // support: Firefox
  4929. // Prevent accidental activation of menu items in Firefox (#7024 #9118)
  4930. if ( this.isNewMenu ) {
  4931. this.isNewMenu = false;
  4932. if ( event.originalEvent && /^mouse/.test( event.originalEvent.type ) ) {
  4933. this.menu.blur();
  4934. this.document.one( "mousemove", function() {
  4935. $( event.target ).trigger( event.originalEvent );
  4936. } );
  4937. return;
  4938. }
  4939. }
  4940. item = ui.item.data( "ui-autocomplete-item" );
  4941. if ( false !== this._trigger( "focus", event, { item: item } ) ) {
  4942. // use value to match what will end up in the input, if it was a key event
  4943. if ( event.originalEvent && /^key/.test( event.originalEvent.type ) ) {
  4944. this._value( item.value );
  4945. }
  4946. }
  4947. // Announce the value in the liveRegion
  4948. label = ui.item.attr( "aria-label" ) || item.value;
  4949. if ( label && String.prototype.trim.call( label ).length ) {
  4950. clearTimeout( this.liveRegionTimer );
  4951. this.liveRegionTimer = this._delay( function() {
  4952. this.liveRegion.html( $( "<div>" ).text( label ) );
  4953. }, 100 );
  4954. }
  4955. },
  4956. menuselect: function( event, ui ) {
  4957. var item = ui.item.data( "ui-autocomplete-item" ),
  4958. previous = this.previous;
  4959. // Only trigger when focus was lost (click on menu)
  4960. if ( this.element[ 0 ] !== $.ui.safeActiveElement( this.document[ 0 ] ) ) {
  4961. this.element.trigger( "focus" );
  4962. this.previous = previous;
  4963. // #6109 - IE triggers two focus events and the second
  4964. // is asynchronous, so we need to reset the previous
  4965. // term synchronously and asynchronously :-(
  4966. this._delay( function() {
  4967. this.previous = previous;
  4968. this.selectedItem = item;
  4969. } );
  4970. }
  4971. if ( false !== this._trigger( "select", event, { item: item } ) ) {
  4972. this._value( item.value );
  4973. }
  4974. // reset the term after the select event
  4975. // this allows custom select handling to work properly
  4976. this.term = this._value();
  4977. this.close( event );
  4978. this.selectedItem = item;
  4979. }
  4980. } );
  4981. this.liveRegion = $( "<div>", {
  4982. role: "status",
  4983. "aria-live": "assertive",
  4984. "aria-relevant": "additions"
  4985. } )
  4986. .appendTo( this.document[ 0 ].body );
  4987. this._addClass( this.liveRegion, null, "ui-helper-hidden-accessible" );
  4988. // Turning off autocomplete prevents the browser from remembering the
  4989. // value when navigating through history, so we re-enable autocomplete
  4990. // if the page is unloaded before the widget is destroyed. #7790
  4991. this._on( this.window, {
  4992. beforeunload: function() {
  4993. this.element.removeAttr( "autocomplete" );
  4994. }
  4995. } );
  4996. },
  4997. _destroy: function() {
  4998. clearTimeout( this.searching );
  4999. this.element.removeAttr( "autocomplete" );
  5000. this.menu.element.remove();
  5001. this.liveRegion.remove();
  5002. },
  5003. _setOption: function( key, value ) {
  5004. this._super( key, value );
  5005. if ( key === "source" ) {
  5006. this._initSource();
  5007. }
  5008. if ( key === "appendTo" ) {
  5009. this.menu.element.appendTo( this._appendTo() );
  5010. }
  5011. if ( key === "disabled" && value && this.xhr ) {
  5012. this.xhr.abort();
  5013. }
  5014. },
  5015. _isEventTargetInWidget: function( event ) {
  5016. var menuElement = this.menu.element[ 0 ];
  5017. return event.target === this.element[ 0 ] ||
  5018. event.target === menuElement ||
  5019. $.contains( menuElement, event.target );
  5020. },
  5021. _closeOnClickOutside: function( event ) {
  5022. if ( !this._isEventTargetInWidget( event ) ) {
  5023. this.close();
  5024. }
  5025. },
  5026. _appendTo: function() {
  5027. var element = this.options.appendTo;
  5028. if ( element ) {
  5029. element = element.jquery || element.nodeType ?
  5030. $( element ) :
  5031. this.document.find( element ).eq( 0 );
  5032. }
  5033. if ( !element || !element[ 0 ] ) {
  5034. element = this.element.closest( ".ui-front, dialog" );
  5035. }
  5036. if ( !element.length ) {
  5037. element = this.document[ 0 ].body;
  5038. }
  5039. return element;
  5040. },
  5041. _initSource: function() {
  5042. var array, url,
  5043. that = this;
  5044. if ( Array.isArray( this.options.source ) ) {
  5045. array = this.options.source;
  5046. this.source = function( request, response ) {
  5047. response( $.ui.autocomplete.filter( array, request.term ) );
  5048. };
  5049. } else if ( typeof this.options.source === "string" ) {
  5050. url = this.options.source;
  5051. this.source = function( request, response ) {
  5052. if ( that.xhr ) {
  5053. that.xhr.abort();
  5054. }
  5055. that.xhr = $.ajax( {
  5056. url: url,
  5057. data: request,
  5058. dataType: "json",
  5059. success: function( data ) {
  5060. response( data );
  5061. },
  5062. error: function() {
  5063. response( [] );
  5064. }
  5065. } );
  5066. };
  5067. } else {
  5068. this.source = this.options.source;
  5069. }
  5070. },
  5071. _searchTimeout: function( event ) {
  5072. clearTimeout( this.searching );
  5073. this.searching = this._delay( function() {
  5074. // Search if the value has changed, or if the user retypes the same value (see #7434)
  5075. var equalValues = this.term === this._value(),
  5076. menuVisible = this.menu.element.is( ":visible" ),
  5077. modifierKey = event.altKey || event.ctrlKey || event.metaKey || event.shiftKey;
  5078. if ( !equalValues || ( equalValues && !menuVisible && !modifierKey ) ) {
  5079. this.selectedItem = null;
  5080. this.search( null, event );
  5081. }
  5082. }, this.options.delay );
  5083. },
  5084. search: function( value, event ) {
  5085. value = value != null ? value : this._value();
  5086. // Always save the actual value, not the one passed as an argument
  5087. this.term = this._value();
  5088. if ( value.length < this.options.minLength ) {
  5089. return this.close( event );
  5090. }
  5091. if ( this._trigger( "search", event ) === false ) {
  5092. return;
  5093. }
  5094. return this._search( value );
  5095. },
  5096. _search: function( value ) {
  5097. this.pending++;
  5098. this._addClass( "ui-autocomplete-loading" );
  5099. this.cancelSearch = false;
  5100. this.source( { term: value }, this._response() );
  5101. },
  5102. _response: function() {
  5103. var index = ++this.requestIndex;
  5104. return function( content ) {
  5105. if ( index === this.requestIndex ) {
  5106. this.__response( content );
  5107. }
  5108. this.pending--;
  5109. if ( !this.pending ) {
  5110. this._removeClass( "ui-autocomplete-loading" );
  5111. }
  5112. }.bind( this );
  5113. },
  5114. __response: function( content ) {
  5115. if ( content ) {
  5116. content = this._normalize( content );
  5117. }
  5118. this._trigger( "response", null, { content: content } );
  5119. if ( !this.options.disabled && content && content.length && !this.cancelSearch ) {
  5120. this._suggest( content );
  5121. this._trigger( "open" );
  5122. } else {
  5123. // use ._close() instead of .close() so we don't cancel future searches
  5124. this._close();
  5125. }
  5126. },
  5127. close: function( event ) {
  5128. this.cancelSearch = true;
  5129. this._close( event );
  5130. },
  5131. _close: function( event ) {
  5132. // Remove the handler that closes the menu on outside clicks
  5133. this._off( this.document, "mousedown" );
  5134. if ( this.menu.element.is( ":visible" ) ) {
  5135. this.menu.element.hide();
  5136. this.menu.blur();
  5137. this.isNewMenu = true;
  5138. this._trigger( "close", event );
  5139. }
  5140. },
  5141. _change: function( event ) {
  5142. if ( this.previous !== this._value() ) {
  5143. this._trigger( "change", event, { item: this.selectedItem } );
  5144. }
  5145. },
  5146. _normalize: function( items ) {
  5147. // assume all items have the right format when the first item is complete
  5148. if ( items.length && items[ 0 ].label && items[ 0 ].value ) {
  5149. return items;
  5150. }
  5151. return $.map( items, function( item ) {
  5152. if ( typeof item === "string" ) {
  5153. return {
  5154. label: item,
  5155. value: item
  5156. };
  5157. }
  5158. return $.extend( {}, item, {
  5159. label: item.label || item.value,
  5160. value: item.value || item.label
  5161. } );
  5162. } );
  5163. },
  5164. _suggest: function( items ) {
  5165. var ul = this.menu.element.empty();
  5166. this._renderMenu( ul, items );
  5167. this.isNewMenu = true;
  5168. this.menu.refresh();
  5169. // Size and position menu
  5170. ul.show();
  5171. this._resizeMenu();
  5172. ul.position( $.extend( {
  5173. of: this.element
  5174. }, this.options.position ) );
  5175. if ( this.options.autoFocus ) {
  5176. this.menu.next();
  5177. }
  5178. // Listen for interactions outside of the widget (#6642)
  5179. this._on( this.document, {
  5180. mousedown: "_closeOnClickOutside"
  5181. } );
  5182. },
  5183. _resizeMenu: function() {
  5184. var ul = this.menu.element;
  5185. ul.outerWidth( Math.max(
  5186. // Firefox wraps long text (possibly a rounding bug)
  5187. // so we add 1px to avoid the wrapping (#7513)
  5188. ul.width( "" ).outerWidth() + 1,
  5189. this.element.outerWidth()
  5190. ) );
  5191. },
  5192. _renderMenu: function( ul, items ) {
  5193. var that = this;
  5194. $.each( items, function( index, item ) {
  5195. that._renderItemData( ul, item );
  5196. } );
  5197. },
  5198. _renderItemData: function( ul, item ) {
  5199. return this._renderItem( ul, item ).data( "ui-autocomplete-item", item );
  5200. },
  5201. _renderItem: function( ul, item ) {
  5202. return $( "<li>" )
  5203. .append( $( "<div>" ).text( item.label ) )
  5204. .appendTo( ul );
  5205. },
  5206. _move: function( direction, event ) {
  5207. if ( !this.menu.element.is( ":visible" ) ) {
  5208. this.search( null, event );
  5209. return;
  5210. }
  5211. if ( this.menu.isFirstItem() && /^previous/.test( direction ) ||
  5212. this.menu.isLastItem() && /^next/.test( direction ) ) {
  5213. if ( !this.isMultiLine ) {
  5214. this._value( this.term );
  5215. }
  5216. this.menu.blur();
  5217. return;
  5218. }
  5219. this.menu[ direction ]( event );
  5220. },
  5221. widget: function() {
  5222. return this.menu.element;
  5223. },
  5224. _value: function() {
  5225. return this.valueMethod.apply( this.element, arguments );
  5226. },
  5227. _keyEvent: function( keyEvent, event ) {
  5228. if ( !this.isMultiLine || this.menu.element.is( ":visible" ) ) {
  5229. this._move( keyEvent, event );
  5230. // Prevents moving cursor to beginning/end of the text field in some browsers
  5231. event.preventDefault();
  5232. }
  5233. },
  5234. // Support: Chrome <=50
  5235. // We should be able to just use this.element.prop( "isContentEditable" )
  5236. // but hidden elements always report false in Chrome.
  5237. // https://code.google.com/p/chromium/issues/detail?id=313082
  5238. _isContentEditable: function( element ) {
  5239. if ( !element.length ) {
  5240. return false;
  5241. }
  5242. var editable = element.prop( "contentEditable" );
  5243. if ( editable === "inherit" ) {
  5244. return this._isContentEditable( element.parent() );
  5245. }
  5246. return editable === "true";
  5247. }
  5248. } );
  5249. $.extend( $.ui.autocomplete, {
  5250. escapeRegex: function( value ) {
  5251. return value.replace( /[\-\[\]{}()*+?.,\\\^$|#\s]/g, "\\$&" );
  5252. },
  5253. filter: function( array, term ) {
  5254. var matcher = new RegExp( $.ui.autocomplete.escapeRegex( term ), "i" );
  5255. return $.grep( array, function( value ) {
  5256. return matcher.test( value.label || value.value || value );
  5257. } );
  5258. }
  5259. } );
  5260. // Live region extension, adding a `messages` option
  5261. // NOTE: This is an experimental API. We are still investigating
  5262. // a full solution for string manipulation and internationalization.
  5263. $.widget( "ui.autocomplete", $.ui.autocomplete, {
  5264. options: {
  5265. messages: {
  5266. noResults: "No search results.",
  5267. results: function( amount ) {
  5268. return amount + ( amount > 1 ? " results are" : " result is" ) +
  5269. " available, use up and down arrow keys to navigate.";
  5270. }
  5271. }
  5272. },
  5273. __response: function( content ) {
  5274. var message;
  5275. this._superApply( arguments );
  5276. if ( this.options.disabled || this.cancelSearch ) {
  5277. return;
  5278. }
  5279. if ( content && content.length ) {
  5280. message = this.options.messages.results( content.length );
  5281. } else {
  5282. message = this.options.messages.noResults;
  5283. }
  5284. clearTimeout( this.liveRegionTimer );
  5285. this.liveRegionTimer = this._delay( function() {
  5286. this.liveRegion.html( $( "<div>" ).text( message ) );
  5287. }, 100 );
  5288. }
  5289. } );
  5290. var widgetsAutocomplete = $.ui.autocomplete;
  5291. /*!
  5292. * jQuery UI Controlgroup 1.13.2
  5293. * http://jqueryui.com
  5294. *
  5295. * Copyright jQuery Foundation and other contributors
  5296. * Released under the MIT license.
  5297. * http://jquery.org/license
  5298. */
  5299. //>>label: Controlgroup
  5300. //>>group: Widgets
  5301. //>>description: Visually groups form control widgets
  5302. //>>docs: http://api.jqueryui.com/controlgroup/
  5303. //>>demos: http://jqueryui.com/controlgroup/
  5304. //>>css.structure: ../../themes/base/core.css
  5305. //>>css.structure: ../../themes/base/controlgroup.css
  5306. //>>css.theme: ../../themes/base/theme.css
  5307. var controlgroupCornerRegex = /ui-corner-([a-z]){2,6}/g;
  5308. var widgetsControlgroup = $.widget( "ui.controlgroup", {
  5309. version: "1.13.2",
  5310. defaultElement: "<div>",
  5311. options: {
  5312. direction: "horizontal",
  5313. disabled: null,
  5314. onlyVisible: true,
  5315. items: {
  5316. "button": "input[type=button], input[type=submit], input[type=reset], button, a",
  5317. "controlgroupLabel": ".ui-controlgroup-label",
  5318. "checkboxradio": "input[type='checkbox'], input[type='radio']",
  5319. "selectmenu": "select",
  5320. "spinner": ".ui-spinner-input"
  5321. }
  5322. },
  5323. _create: function() {
  5324. this._enhance();
  5325. },
  5326. // To support the enhanced option in jQuery Mobile, we isolate DOM manipulation
  5327. _enhance: function() {
  5328. this.element.attr( "role", "toolbar" );
  5329. this.refresh();
  5330. },
  5331. _destroy: function() {
  5332. this._callChildMethod( "destroy" );
  5333. this.childWidgets.removeData( "ui-controlgroup-data" );
  5334. this.element.removeAttr( "role" );
  5335. if ( this.options.items.controlgroupLabel ) {
  5336. this.element
  5337. .find( this.options.items.controlgroupLabel )
  5338. .find( ".ui-controlgroup-label-contents" )
  5339. .contents().unwrap();
  5340. }
  5341. },
  5342. _initWidgets: function() {
  5343. var that = this,
  5344. childWidgets = [];
  5345. // First we iterate over each of the items options
  5346. $.each( this.options.items, function( widget, selector ) {
  5347. var labels;
  5348. var options = {};
  5349. // Make sure the widget has a selector set
  5350. if ( !selector ) {
  5351. return;
  5352. }
  5353. if ( widget === "controlgroupLabel" ) {
  5354. labels = that.element.find( selector );
  5355. labels.each( function() {
  5356. var element = $( this );
  5357. if ( element.children( ".ui-controlgroup-label-contents" ).length ) {
  5358. return;
  5359. }
  5360. element.contents()
  5361. .wrapAll( "<span class='ui-controlgroup-label-contents'></span>" );
  5362. } );
  5363. that._addClass( labels, null, "ui-widget ui-widget-content ui-state-default" );
  5364. childWidgets = childWidgets.concat( labels.get() );
  5365. return;
  5366. }
  5367. // Make sure the widget actually exists
  5368. if ( !$.fn[ widget ] ) {
  5369. return;
  5370. }
  5371. // We assume everything is in the middle to start because we can't determine
  5372. // first / last elements until all enhancments are done.
  5373. if ( that[ "_" + widget + "Options" ] ) {
  5374. options = that[ "_" + widget + "Options" ]( "middle" );
  5375. } else {
  5376. options = { classes: {} };
  5377. }
  5378. // Find instances of this widget inside controlgroup and init them
  5379. that.element
  5380. .find( selector )
  5381. .each( function() {
  5382. var element = $( this );
  5383. var instance = element[ widget ]( "instance" );
  5384. // We need to clone the default options for this type of widget to avoid
  5385. // polluting the variable options which has a wider scope than a single widget.
  5386. var instanceOptions = $.widget.extend( {}, options );
  5387. // If the button is the child of a spinner ignore it
  5388. // TODO: Find a more generic solution
  5389. if ( widget === "button" && element.parent( ".ui-spinner" ).length ) {
  5390. return;
  5391. }
  5392. // Create the widget if it doesn't exist
  5393. if ( !instance ) {
  5394. instance = element[ widget ]()[ widget ]( "instance" );
  5395. }
  5396. if ( instance ) {
  5397. instanceOptions.classes =
  5398. that._resolveClassesValues( instanceOptions.classes, instance );
  5399. }
  5400. element[ widget ]( instanceOptions );
  5401. // Store an instance of the controlgroup to be able to reference
  5402. // from the outermost element for changing options and refresh
  5403. var widgetElement = element[ widget ]( "widget" );
  5404. $.data( widgetElement[ 0 ], "ui-controlgroup-data",
  5405. instance ? instance : element[ widget ]( "instance" ) );
  5406. childWidgets.push( widgetElement[ 0 ] );
  5407. } );
  5408. } );
  5409. this.childWidgets = $( $.uniqueSort( childWidgets ) );
  5410. this._addClass( this.childWidgets, "ui-controlgroup-item" );
  5411. },
  5412. _callChildMethod: function( method ) {
  5413. this.childWidgets.each( function() {
  5414. var element = $( this ),
  5415. data = element.data( "ui-controlgroup-data" );
  5416. if ( data && data[ method ] ) {
  5417. data[ method ]();
  5418. }
  5419. } );
  5420. },
  5421. _updateCornerClass: function( element, position ) {
  5422. var remove = "ui-corner-top ui-corner-bottom ui-corner-left ui-corner-right ui-corner-all";
  5423. var add = this._buildSimpleOptions( position, "label" ).classes.label;
  5424. this._removeClass( element, null, remove );
  5425. this._addClass( element, null, add );
  5426. },
  5427. _buildSimpleOptions: function( position, key ) {
  5428. var direction = this.options.direction === "vertical";
  5429. var result = {
  5430. classes: {}
  5431. };
  5432. result.classes[ key ] = {
  5433. "middle": "",
  5434. "first": "ui-corner-" + ( direction ? "top" : "left" ),
  5435. "last": "ui-corner-" + ( direction ? "bottom" : "right" ),
  5436. "only": "ui-corner-all"
  5437. }[ position ];
  5438. return result;
  5439. },
  5440. _spinnerOptions: function( position ) {
  5441. var options = this._buildSimpleOptions( position, "ui-spinner" );
  5442. options.classes[ "ui-spinner-up" ] = "";
  5443. options.classes[ "ui-spinner-down" ] = "";
  5444. return options;
  5445. },
  5446. _buttonOptions: function( position ) {
  5447. return this._buildSimpleOptions( position, "ui-button" );
  5448. },
  5449. _checkboxradioOptions: function( position ) {
  5450. return this._buildSimpleOptions( position, "ui-checkboxradio-label" );
  5451. },
  5452. _selectmenuOptions: function( position ) {
  5453. var direction = this.options.direction === "vertical";
  5454. return {
  5455. width: direction ? "auto" : false,
  5456. classes: {
  5457. middle: {
  5458. "ui-selectmenu-button-open": "",
  5459. "ui-selectmenu-button-closed": ""
  5460. },
  5461. first: {
  5462. "ui-selectmenu-button-open": "ui-corner-" + ( direction ? "top" : "tl" ),
  5463. "ui-selectmenu-button-closed": "ui-corner-" + ( direction ? "top" : "left" )
  5464. },
  5465. last: {
  5466. "ui-selectmenu-button-open": direction ? "" : "ui-corner-tr",
  5467. "ui-selectmenu-button-closed": "ui-corner-" + ( direction ? "bottom" : "right" )
  5468. },
  5469. only: {
  5470. "ui-selectmenu-button-open": "ui-corner-top",
  5471. "ui-selectmenu-button-closed": "ui-corner-all"
  5472. }
  5473. }[ position ]
  5474. };
  5475. },
  5476. _resolveClassesValues: function( classes, instance ) {
  5477. var result = {};
  5478. $.each( classes, function( key ) {
  5479. var current = instance.options.classes[ key ] || "";
  5480. current = String.prototype.trim.call( current.replace( controlgroupCornerRegex, "" ) );
  5481. result[ key ] = ( current + " " + classes[ key ] ).replace( /\s+/g, " " );
  5482. } );
  5483. return result;
  5484. },
  5485. _setOption: function( key, value ) {
  5486. if ( key === "direction" ) {
  5487. this._removeClass( "ui-controlgroup-" + this.options.direction );
  5488. }
  5489. this._super( key, value );
  5490. if ( key === "disabled" ) {
  5491. this._callChildMethod( value ? "disable" : "enable" );
  5492. return;
  5493. }
  5494. this.refresh();
  5495. },
  5496. refresh: function() {
  5497. var children,
  5498. that = this;
  5499. this._addClass( "ui-controlgroup ui-controlgroup-" + this.options.direction );
  5500. if ( this.options.direction === "horizontal" ) {
  5501. this._addClass( null, "ui-helper-clearfix" );
  5502. }
  5503. this._initWidgets();
  5504. children = this.childWidgets;
  5505. // We filter here because we need to track all childWidgets not just the visible ones
  5506. if ( this.options.onlyVisible ) {
  5507. children = children.filter( ":visible" );
  5508. }
  5509. if ( children.length ) {
  5510. // We do this last because we need to make sure all enhancment is done
  5511. // before determining first and last
  5512. $.each( [ "first", "last" ], function( index, value ) {
  5513. var instance = children[ value ]().data( "ui-controlgroup-data" );
  5514. if ( instance && that[ "_" + instance.widgetName + "Options" ] ) {
  5515. var options = that[ "_" + instance.widgetName + "Options" ](
  5516. children.length === 1 ? "only" : value
  5517. );
  5518. options.classes = that._resolveClassesValues( options.classes, instance );
  5519. instance.element[ instance.widgetName ]( options );
  5520. } else {
  5521. that._updateCornerClass( children[ value ](), value );
  5522. }
  5523. } );
  5524. // Finally call the refresh method on each of the child widgets.
  5525. this._callChildMethod( "refresh" );
  5526. }
  5527. }
  5528. } );
  5529. /*!
  5530. * jQuery UI Checkboxradio 1.13.2
  5531. * http://jqueryui.com
  5532. *
  5533. * Copyright jQuery Foundation and other contributors
  5534. * Released under the MIT license.
  5535. * http://jquery.org/license
  5536. */
  5537. //>>label: Checkboxradio
  5538. //>>group: Widgets
  5539. //>>description: Enhances a form with multiple themeable checkboxes or radio buttons.
  5540. //>>docs: http://api.jqueryui.com/checkboxradio/
  5541. //>>demos: http://jqueryui.com/checkboxradio/
  5542. //>>css.structure: ../../themes/base/core.css
  5543. //>>css.structure: ../../themes/base/button.css
  5544. //>>css.structure: ../../themes/base/checkboxradio.css
  5545. //>>css.theme: ../../themes/base/theme.css
  5546. $.widget( "ui.checkboxradio", [ $.ui.formResetMixin, {
  5547. version: "1.13.2",
  5548. options: {
  5549. disabled: null,
  5550. label: null,
  5551. icon: true,
  5552. classes: {
  5553. "ui-checkboxradio-label": "ui-corner-all",
  5554. "ui-checkboxradio-icon": "ui-corner-all"
  5555. }
  5556. },
  5557. _getCreateOptions: function() {
  5558. var disabled, labels, labelContents;
  5559. var options = this._super() || {};
  5560. // We read the type here, because it makes more sense to throw a element type error first,
  5561. // rather then the error for lack of a label. Often if its the wrong type, it
  5562. // won't have a label (e.g. calling on a div, btn, etc)
  5563. this._readType();
  5564. labels = this.element.labels();
  5565. // If there are multiple labels, use the last one
  5566. this.label = $( labels[ labels.length - 1 ] );
  5567. if ( !this.label.length ) {
  5568. $.error( "No label found for checkboxradio widget" );
  5569. }
  5570. this.originalLabel = "";
  5571. // We need to get the label text but this may also need to make sure it does not contain the
  5572. // input itself.
  5573. // The label contents could be text, html, or a mix. We wrap all elements
  5574. // and read the wrapper's `innerHTML` to get a string representation of
  5575. // the label, without the input as part of it.
  5576. labelContents = this.label.contents().not( this.element[ 0 ] );
  5577. if ( labelContents.length ) {
  5578. this.originalLabel += labelContents
  5579. .clone()
  5580. .wrapAll( "<div></div>" )
  5581. .parent()
  5582. .html();
  5583. }
  5584. // Set the label option if we found label text
  5585. if ( this.originalLabel ) {
  5586. options.label = this.originalLabel;
  5587. }
  5588. disabled = this.element[ 0 ].disabled;
  5589. if ( disabled != null ) {
  5590. options.disabled = disabled;
  5591. }
  5592. return options;
  5593. },
  5594. _create: function() {
  5595. var checked = this.element[ 0 ].checked;
  5596. this._bindFormResetHandler();
  5597. if ( this.options.disabled == null ) {
  5598. this.options.disabled = this.element[ 0 ].disabled;
  5599. }
  5600. this._setOption( "disabled", this.options.disabled );
  5601. this._addClass( "ui-checkboxradio", "ui-helper-hidden-accessible" );
  5602. this._addClass( this.label, "ui-checkboxradio-label", "ui-button ui-widget" );
  5603. if ( this.type === "radio" ) {
  5604. this._addClass( this.label, "ui-checkboxradio-radio-label" );
  5605. }
  5606. if ( this.options.label && this.options.label !== this.originalLabel ) {
  5607. this._updateLabel();
  5608. } else if ( this.originalLabel ) {
  5609. this.options.label = this.originalLabel;
  5610. }
  5611. this._enhance();
  5612. if ( checked ) {
  5613. this._addClass( this.label, "ui-checkboxradio-checked", "ui-state-active" );
  5614. }
  5615. this._on( {
  5616. change: "_toggleClasses",
  5617. focus: function() {
  5618. this._addClass( this.label, null, "ui-state-focus ui-visual-focus" );
  5619. },
  5620. blur: function() {
  5621. this._removeClass( this.label, null, "ui-state-focus ui-visual-focus" );
  5622. }
  5623. } );
  5624. },
  5625. _readType: function() {
  5626. var nodeName = this.element[ 0 ].nodeName.toLowerCase();
  5627. this.type = this.element[ 0 ].type;
  5628. if ( nodeName !== "input" || !/radio|checkbox/.test( this.type ) ) {
  5629. $.error( "Can't create checkboxradio on element.nodeName=" + nodeName +
  5630. " and element.type=" + this.type );
  5631. }
  5632. },
  5633. // Support jQuery Mobile enhanced option
  5634. _enhance: function() {
  5635. this._updateIcon( this.element[ 0 ].checked );
  5636. },
  5637. widget: function() {
  5638. return this.label;
  5639. },
  5640. _getRadioGroup: function() {
  5641. var group;
  5642. var name = this.element[ 0 ].name;
  5643. var nameSelector = "input[name='" + $.escapeSelector( name ) + "']";
  5644. if ( !name ) {
  5645. return $( [] );
  5646. }
  5647. if ( this.form.length ) {
  5648. group = $( this.form[ 0 ].elements ).filter( nameSelector );
  5649. } else {
  5650. // Not inside a form, check all inputs that also are not inside a form
  5651. group = $( nameSelector ).filter( function() {
  5652. return $( this )._form().length === 0;
  5653. } );
  5654. }
  5655. return group.not( this.element );
  5656. },
  5657. _toggleClasses: function() {
  5658. var checked = this.element[ 0 ].checked;
  5659. this._toggleClass( this.label, "ui-checkboxradio-checked", "ui-state-active", checked );
  5660. if ( this.options.icon && this.type === "checkbox" ) {
  5661. this._toggleClass( this.icon, null, "ui-icon-check ui-state-checked", checked )
  5662. ._toggleClass( this.icon, null, "ui-icon-blank", !checked );
  5663. }
  5664. if ( this.type === "radio" ) {
  5665. this._getRadioGroup()
  5666. .each( function() {
  5667. var instance = $( this ).checkboxradio( "instance" );
  5668. if ( instance ) {
  5669. instance._removeClass( instance.label,
  5670. "ui-checkboxradio-checked", "ui-state-active" );
  5671. }
  5672. } );
  5673. }
  5674. },
  5675. _destroy: function() {
  5676. this._unbindFormResetHandler();
  5677. if ( this.icon ) {
  5678. this.icon.remove();
  5679. this.iconSpace.remove();
  5680. }
  5681. },
  5682. _setOption: function( key, value ) {
  5683. // We don't allow the value to be set to nothing
  5684. if ( key === "label" && !value ) {
  5685. return;
  5686. }
  5687. this._super( key, value );
  5688. if ( key === "disabled" ) {
  5689. this._toggleClass( this.label, null, "ui-state-disabled", value );
  5690. this.element[ 0 ].disabled = value;
  5691. // Don't refresh when setting disabled
  5692. return;
  5693. }
  5694. this.refresh();
  5695. },
  5696. _updateIcon: function( checked ) {
  5697. var toAdd = "ui-icon ui-icon-background ";
  5698. if ( this.options.icon ) {
  5699. if ( !this.icon ) {
  5700. this.icon = $( "<span>" );
  5701. this.iconSpace = $( "<span> </span>" );
  5702. this._addClass( this.iconSpace, "ui-checkboxradio-icon-space" );
  5703. }
  5704. if ( this.type === "checkbox" ) {
  5705. toAdd += checked ? "ui-icon-check ui-state-checked" : "ui-icon-blank";
  5706. this._removeClass( this.icon, null, checked ? "ui-icon-blank" : "ui-icon-check" );
  5707. } else {
  5708. toAdd += "ui-icon-blank";
  5709. }
  5710. this._addClass( this.icon, "ui-checkboxradio-icon", toAdd );
  5711. if ( !checked ) {
  5712. this._removeClass( this.icon, null, "ui-icon-check ui-state-checked" );
  5713. }
  5714. this.icon.prependTo( this.label ).after( this.iconSpace );
  5715. } else if ( this.icon !== undefined ) {
  5716. this.icon.remove();
  5717. this.iconSpace.remove();
  5718. delete this.icon;
  5719. }
  5720. },
  5721. _updateLabel: function() {
  5722. // Remove the contents of the label ( minus the icon, icon space, and input )
  5723. var contents = this.label.contents().not( this.element[ 0 ] );
  5724. if ( this.icon ) {
  5725. contents = contents.not( this.icon[ 0 ] );
  5726. }
  5727. if ( this.iconSpace ) {
  5728. contents = contents.not( this.iconSpace[ 0 ] );
  5729. }
  5730. contents.remove();
  5731. this.label.append( this.options.label );
  5732. },
  5733. refresh: function() {
  5734. var checked = this.element[ 0 ].checked,
  5735. isDisabled = this.element[ 0 ].disabled;
  5736. this._updateIcon( checked );
  5737. this._toggleClass( this.label, "ui-checkboxradio-checked", "ui-state-active", checked );
  5738. if ( this.options.label !== null ) {
  5739. this._updateLabel();
  5740. }
  5741. if ( isDisabled !== this.options.disabled ) {
  5742. this._setOptions( { "disabled": isDisabled } );
  5743. }
  5744. }
  5745. } ] );
  5746. var widgetsCheckboxradio = $.ui.checkboxradio;
  5747. /*!
  5748. * jQuery UI Button 1.13.2
  5749. * http://jqueryui.com
  5750. *
  5751. * Copyright jQuery Foundation and other contributors
  5752. * Released under the MIT license.
  5753. * http://jquery.org/license
  5754. */
  5755. //>>label: Button
  5756. //>>group: Widgets
  5757. //>>description: Enhances a form with themeable buttons.
  5758. //>>docs: http://api.jqueryui.com/button/
  5759. //>>demos: http://jqueryui.com/button/
  5760. //>>css.structure: ../../themes/base/core.css
  5761. //>>css.structure: ../../themes/base/button.css
  5762. //>>css.theme: ../../themes/base/theme.css
  5763. $.widget( "ui.button", {
  5764. version: "1.13.2",
  5765. defaultElement: "<button>",
  5766. options: {
  5767. classes: {
  5768. "ui-button": "ui-corner-all"
  5769. },
  5770. disabled: null,
  5771. icon: null,
  5772. iconPosition: "beginning",
  5773. label: null,
  5774. showLabel: true
  5775. },
  5776. _getCreateOptions: function() {
  5777. var disabled,
  5778. // This is to support cases like in jQuery Mobile where the base widget does have
  5779. // an implementation of _getCreateOptions
  5780. options = this._super() || {};
  5781. this.isInput = this.element.is( "input" );
  5782. disabled = this.element[ 0 ].disabled;
  5783. if ( disabled != null ) {
  5784. options.disabled = disabled;
  5785. }
  5786. this.originalLabel = this.isInput ? this.element.val() : this.element.html();
  5787. if ( this.originalLabel ) {
  5788. options.label = this.originalLabel;
  5789. }
  5790. return options;
  5791. },
  5792. _create: function() {
  5793. if ( !this.option.showLabel & !this.options.icon ) {
  5794. this.options.showLabel = true;
  5795. }
  5796. // We have to check the option again here even though we did in _getCreateOptions,
  5797. // because null may have been passed on init which would override what was set in
  5798. // _getCreateOptions
  5799. if ( this.options.disabled == null ) {
  5800. this.options.disabled = this.element[ 0 ].disabled || false;
  5801. }
  5802. this.hasTitle = !!this.element.attr( "title" );
  5803. // Check to see if the label needs to be set or if its already correct
  5804. if ( this.options.label && this.options.label !== this.originalLabel ) {
  5805. if ( this.isInput ) {
  5806. this.element.val( this.options.label );
  5807. } else {
  5808. this.element.html( this.options.label );
  5809. }
  5810. }
  5811. this._addClass( "ui-button", "ui-widget" );
  5812. this._setOption( "disabled", this.options.disabled );
  5813. this._enhance();
  5814. if ( this.element.is( "a" ) ) {
  5815. this._on( {
  5816. "keyup": function( event ) {
  5817. if ( event.keyCode === $.ui.keyCode.SPACE ) {
  5818. event.preventDefault();
  5819. // Support: PhantomJS <= 1.9, IE 8 Only
  5820. // If a native click is available use it so we actually cause navigation
  5821. // otherwise just trigger a click event
  5822. if ( this.element[ 0 ].click ) {
  5823. this.element[ 0 ].click();
  5824. } else {
  5825. this.element.trigger( "click" );
  5826. }
  5827. }
  5828. }
  5829. } );
  5830. }
  5831. },
  5832. _enhance: function() {
  5833. if ( !this.element.is( "button" ) ) {
  5834. this.element.attr( "role", "button" );
  5835. }
  5836. if ( this.options.icon ) {
  5837. this._updateIcon( "icon", this.options.icon );
  5838. this._updateTooltip();
  5839. }
  5840. },
  5841. _updateTooltip: function() {
  5842. this.title = this.element.attr( "title" );
  5843. if ( !this.options.showLabel && !this.title ) {
  5844. this.element.attr( "title", this.options.label );
  5845. }
  5846. },
  5847. _updateIcon: function( option, value ) {
  5848. var icon = option !== "iconPosition",
  5849. position = icon ? this.options.iconPosition : value,
  5850. displayBlock = position === "top" || position === "bottom";
  5851. // Create icon
  5852. if ( !this.icon ) {
  5853. this.icon = $( "<span>" );
  5854. this._addClass( this.icon, "ui-button-icon", "ui-icon" );
  5855. if ( !this.options.showLabel ) {
  5856. this._addClass( "ui-button-icon-only" );
  5857. }
  5858. } else if ( icon ) {
  5859. // If we are updating the icon remove the old icon class
  5860. this._removeClass( this.icon, null, this.options.icon );
  5861. }
  5862. // If we are updating the icon add the new icon class
  5863. if ( icon ) {
  5864. this._addClass( this.icon, null, value );
  5865. }
  5866. this._attachIcon( position );
  5867. // If the icon is on top or bottom we need to add the ui-widget-icon-block class and remove
  5868. // the iconSpace if there is one.
  5869. if ( displayBlock ) {
  5870. this._addClass( this.icon, null, "ui-widget-icon-block" );
  5871. if ( this.iconSpace ) {
  5872. this.iconSpace.remove();
  5873. }
  5874. } else {
  5875. // Position is beginning or end so remove the ui-widget-icon-block class and add the
  5876. // space if it does not exist
  5877. if ( !this.iconSpace ) {
  5878. this.iconSpace = $( "<span> </span>" );
  5879. this._addClass( this.iconSpace, "ui-button-icon-space" );
  5880. }
  5881. this._removeClass( this.icon, null, "ui-wiget-icon-block" );
  5882. this._attachIconSpace( position );
  5883. }
  5884. },
  5885. _destroy: function() {
  5886. this.element.removeAttr( "role" );
  5887. if ( this.icon ) {
  5888. this.icon.remove();
  5889. }
  5890. if ( this.iconSpace ) {
  5891. this.iconSpace.remove();
  5892. }
  5893. if ( !this.hasTitle ) {
  5894. this.element.removeAttr( "title" );
  5895. }
  5896. },
  5897. _attachIconSpace: function( iconPosition ) {
  5898. this.icon[ /^(?:end|bottom)/.test( iconPosition ) ? "before" : "after" ]( this.iconSpace );
  5899. },
  5900. _attachIcon: function( iconPosition ) {
  5901. this.element[ /^(?:end|bottom)/.test( iconPosition ) ? "append" : "prepend" ]( this.icon );
  5902. },
  5903. _setOptions: function( options ) {
  5904. var newShowLabel = options.showLabel === undefined ?
  5905. this.options.showLabel :
  5906. options.showLabel,
  5907. newIcon = options.icon === undefined ? this.options.icon : options.icon;
  5908. if ( !newShowLabel && !newIcon ) {
  5909. options.showLabel = true;
  5910. }
  5911. this._super( options );
  5912. },
  5913. _setOption: function( key, value ) {
  5914. if ( key === "icon" ) {
  5915. if ( value ) {
  5916. this._updateIcon( key, value );
  5917. } else if ( this.icon ) {
  5918. this.icon.remove();
  5919. if ( this.iconSpace ) {
  5920. this.iconSpace.remove();
  5921. }
  5922. }
  5923. }
  5924. if ( key === "iconPosition" ) {
  5925. this._updateIcon( key, value );
  5926. }
  5927. // Make sure we can't end up with a button that has neither text nor icon
  5928. if ( key === "showLabel" ) {
  5929. this._toggleClass( "ui-button-icon-only", null, !value );
  5930. this._updateTooltip();
  5931. }
  5932. if ( key === "label" ) {
  5933. if ( this.isInput ) {
  5934. this.element.val( value );
  5935. } else {
  5936. // If there is an icon, append it, else nothing then append the value
  5937. // this avoids removal of the icon when setting label text
  5938. this.element.html( value );
  5939. if ( this.icon ) {
  5940. this._attachIcon( this.options.iconPosition );
  5941. this._attachIconSpace( this.options.iconPosition );
  5942. }
  5943. }
  5944. }
  5945. this._super( key, value );
  5946. if ( key === "disabled" ) {
  5947. this._toggleClass( null, "ui-state-disabled", value );
  5948. this.element[ 0 ].disabled = value;
  5949. if ( value ) {
  5950. this.element.trigger( "blur" );
  5951. }
  5952. }
  5953. },
  5954. refresh: function() {
  5955. // Make sure to only check disabled if its an element that supports this otherwise
  5956. // check for the disabled class to determine state
  5957. var isDisabled = this.element.is( "input, button" ) ?
  5958. this.element[ 0 ].disabled : this.element.hasClass( "ui-button-disabled" );
  5959. if ( isDisabled !== this.options.disabled ) {
  5960. this._setOptions( { disabled: isDisabled } );
  5961. }
  5962. this._updateTooltip();
  5963. }
  5964. } );
  5965. // DEPRECATED
  5966. if ( $.uiBackCompat !== false ) {
  5967. // Text and Icons options
  5968. $.widget( "ui.button", $.ui.button, {
  5969. options: {
  5970. text: true,
  5971. icons: {
  5972. primary: null,
  5973. secondary: null
  5974. }
  5975. },
  5976. _create: function() {
  5977. if ( this.options.showLabel && !this.options.text ) {
  5978. this.options.showLabel = this.options.text;
  5979. }
  5980. if ( !this.options.showLabel && this.options.text ) {
  5981. this.options.text = this.options.showLabel;
  5982. }
  5983. if ( !this.options.icon && ( this.options.icons.primary ||
  5984. this.options.icons.secondary ) ) {
  5985. if ( this.options.icons.primary ) {
  5986. this.options.icon = this.options.icons.primary;
  5987. } else {
  5988. this.options.icon = this.options.icons.secondary;
  5989. this.options.iconPosition = "end";
  5990. }
  5991. } else if ( this.options.icon ) {
  5992. this.options.icons.primary = this.options.icon;
  5993. }
  5994. this._super();
  5995. },
  5996. _setOption: function( key, value ) {
  5997. if ( key === "text" ) {
  5998. this._super( "showLabel", value );
  5999. return;
  6000. }
  6001. if ( key === "showLabel" ) {
  6002. this.options.text = value;
  6003. }
  6004. if ( key === "icon" ) {
  6005. this.options.icons.primary = value;
  6006. }
  6007. if ( key === "icons" ) {
  6008. if ( value.primary ) {
  6009. this._super( "icon", value.primary );
  6010. this._super( "iconPosition", "beginning" );
  6011. } else if ( value.secondary ) {
  6012. this._super( "icon", value.secondary );
  6013. this._super( "iconPosition", "end" );
  6014. }
  6015. }
  6016. this._superApply( arguments );
  6017. }
  6018. } );
  6019. $.fn.button = ( function( orig ) {
  6020. return function( options ) {
  6021. var isMethodCall = typeof options === "string";
  6022. var args = Array.prototype.slice.call( arguments, 1 );
  6023. var returnValue = this;
  6024. if ( isMethodCall ) {
  6025. // If this is an empty collection, we need to have the instance method
  6026. // return undefined instead of the jQuery instance
  6027. if ( !this.length && options === "instance" ) {
  6028. returnValue = undefined;
  6029. } else {
  6030. this.each( function() {
  6031. var methodValue;
  6032. var type = $( this ).attr( "type" );
  6033. var name = type !== "checkbox" && type !== "radio" ?
  6034. "button" :
  6035. "checkboxradio";
  6036. var instance = $.data( this, "ui-" + name );
  6037. if ( options === "instance" ) {
  6038. returnValue = instance;
  6039. return false;
  6040. }
  6041. if ( !instance ) {
  6042. return $.error( "cannot call methods on button" +
  6043. " prior to initialization; " +
  6044. "attempted to call method '" + options + "'" );
  6045. }
  6046. if ( typeof instance[ options ] !== "function" ||
  6047. options.charAt( 0 ) === "_" ) {
  6048. return $.error( "no such method '" + options + "' for button" +
  6049. " widget instance" );
  6050. }
  6051. methodValue = instance[ options ].apply( instance, args );
  6052. if ( methodValue !== instance && methodValue !== undefined ) {
  6053. returnValue = methodValue && methodValue.jquery ?
  6054. returnValue.pushStack( methodValue.get() ) :
  6055. methodValue;
  6056. return false;
  6057. }
  6058. } );
  6059. }
  6060. } else {
  6061. // Allow multiple hashes to be passed on init
  6062. if ( args.length ) {
  6063. options = $.widget.extend.apply( null, [ options ].concat( args ) );
  6064. }
  6065. this.each( function() {
  6066. var type = $( this ).attr( "type" );
  6067. var name = type !== "checkbox" && type !== "radio" ? "button" : "checkboxradio";
  6068. var instance = $.data( this, "ui-" + name );
  6069. if ( instance ) {
  6070. instance.option( options || {} );
  6071. if ( instance._init ) {
  6072. instance._init();
  6073. }
  6074. } else {
  6075. if ( name === "button" ) {
  6076. orig.call( $( this ), options );
  6077. return;
  6078. }
  6079. $( this ).checkboxradio( $.extend( { icon: false }, options ) );
  6080. }
  6081. } );
  6082. }
  6083. return returnValue;
  6084. };
  6085. } )( $.fn.button );
  6086. $.fn.buttonset = function() {
  6087. if ( !$.ui.controlgroup ) {
  6088. $.error( "Controlgroup widget missing" );
  6089. }
  6090. if ( arguments[ 0 ] === "option" && arguments[ 1 ] === "items" && arguments[ 2 ] ) {
  6091. return this.controlgroup.apply( this,
  6092. [ arguments[ 0 ], "items.button", arguments[ 2 ] ] );
  6093. }
  6094. if ( arguments[ 0 ] === "option" && arguments[ 1 ] === "items" ) {
  6095. return this.controlgroup.apply( this, [ arguments[ 0 ], "items.button" ] );
  6096. }
  6097. if ( typeof arguments[ 0 ] === "object" && arguments[ 0 ].items ) {
  6098. arguments[ 0 ].items = {
  6099. button: arguments[ 0 ].items
  6100. };
  6101. }
  6102. return this.controlgroup.apply( this, arguments );
  6103. };
  6104. }
  6105. var widgetsButton = $.ui.button;
  6106. /* eslint-disable max-len, camelcase */
  6107. /*!
  6108. * jQuery UI Datepicker 1.13.2
  6109. * http://jqueryui.com
  6110. *
  6111. * Copyright jQuery Foundation and other contributors
  6112. * Released under the MIT license.
  6113. * http://jquery.org/license
  6114. */
  6115. //>>label: Datepicker
  6116. //>>group: Widgets
  6117. //>>description: Displays a calendar from an input or inline for selecting dates.
  6118. //>>docs: http://api.jqueryui.com/datepicker/
  6119. //>>demos: http://jqueryui.com/datepicker/
  6120. //>>css.structure: ../../themes/base/core.css
  6121. //>>css.structure: ../../themes/base/datepicker.css
  6122. //>>css.theme: ../../themes/base/theme.css
  6123. $.extend( $.ui, { datepicker: { version: "1.13.2" } } );
  6124. var datepicker_instActive;
  6125. function datepicker_getZindex( elem ) {
  6126. var position, value;
  6127. while ( elem.length && elem[ 0 ] !== document ) {
  6128. // Ignore z-index if position is set to a value where z-index is ignored by the browser
  6129. // This makes behavior of this function consistent across browsers
  6130. // WebKit always returns auto if the element is positioned
  6131. position = elem.css( "position" );
  6132. if ( position === "absolute" || position === "relative" || position === "fixed" ) {
  6133. // IE returns 0 when zIndex is not specified
  6134. // other browsers return a string
  6135. // we ignore the case of nested elements with an explicit value of 0
  6136. // <div style="z-index: -10;"><div style="z-index: 0;"></div></div>
  6137. value = parseInt( elem.css( "zIndex" ), 10 );
  6138. if ( !isNaN( value ) && value !== 0 ) {
  6139. return value;
  6140. }
  6141. }
  6142. elem = elem.parent();
  6143. }
  6144. return 0;
  6145. }
  6146. /* Date picker manager.
  6147. Use the singleton instance of this class, $.datepicker, to interact with the date picker.
  6148. Settings for (groups of) date pickers are maintained in an instance object,
  6149. allowing multiple different settings on the same page. */
  6150. function Datepicker() {
  6151. this._curInst = null; // The current instance in use
  6152. this._keyEvent = false; // If the last event was a key event
  6153. this._disabledInputs = []; // List of date picker inputs that have been disabled
  6154. this._datepickerShowing = false; // True if the popup picker is showing , false if not
  6155. this._inDialog = false; // True if showing within a "dialog", false if not
  6156. this._mainDivId = "ui-datepicker-div"; // The ID of the main datepicker division
  6157. this._inlineClass = "ui-datepicker-inline"; // The name of the inline marker class
  6158. this._appendClass = "ui-datepicker-append"; // The name of the append marker class
  6159. this._triggerClass = "ui-datepicker-trigger"; // The name of the trigger marker class
  6160. this._dialogClass = "ui-datepicker-dialog"; // The name of the dialog marker class
  6161. this._disableClass = "ui-datepicker-disabled"; // The name of the disabled covering marker class
  6162. this._unselectableClass = "ui-datepicker-unselectable"; // The name of the unselectable cell marker class
  6163. this._currentClass = "ui-datepicker-current-day"; // The name of the current day marker class
  6164. this._dayOverClass = "ui-datepicker-days-cell-over"; // The name of the day hover marker class
  6165. this.regional = []; // Available regional settings, indexed by language code
  6166. this.regional[ "" ] = { // Default regional settings
  6167. closeText: "Done", // Display text for close link
  6168. prevText: "Prev", // Display text for previous month link
  6169. nextText: "Next", // Display text for next month link
  6170. currentText: "Today", // Display text for current month link
  6171. monthNames: [ "January", "February", "March", "April", "May", "June",
  6172. "July", "August", "September", "October", "November", "December" ], // Names of months for drop-down and formatting
  6173. monthNamesShort: [ "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" ], // For formatting
  6174. dayNames: [ "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday" ], // For formatting
  6175. dayNamesShort: [ "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" ], // For formatting
  6176. dayNamesMin: [ "Su", "Mo", "Tu", "We", "Th", "Fr", "Sa" ], // Column headings for days starting at Sunday
  6177. weekHeader: "Wk", // Column header for week of the year
  6178. dateFormat: "mm/dd/yy", // See format options on parseDate
  6179. firstDay: 0, // The first day of the week, Sun = 0, Mon = 1, ...
  6180. isRTL: false, // True if right-to-left language, false if left-to-right
  6181. showMonthAfterYear: false, // True if the year select precedes month, false for month then year
  6182. yearSuffix: "", // Additional text to append to the year in the month headers,
  6183. selectMonthLabel: "Select month", // Invisible label for month selector
  6184. selectYearLabel: "Select year" // Invisible label for year selector
  6185. };
  6186. this._defaults = { // Global defaults for all the date picker instances
  6187. showOn: "focus", // "focus" for popup on focus,
  6188. // "button" for trigger button, or "both" for either
  6189. showAnim: "fadeIn", // Name of jQuery animation for popup
  6190. showOptions: {}, // Options for enhanced animations
  6191. defaultDate: null, // Used when field is blank: actual date,
  6192. // +/-number for offset from today, null for today
  6193. appendText: "", // Display text following the input box, e.g. showing the format
  6194. buttonText: "...", // Text for trigger button
  6195. buttonImage: "", // URL for trigger button image
  6196. buttonImageOnly: false, // True if the image appears alone, false if it appears on a button
  6197. hideIfNoPrevNext: false, // True to hide next/previous month links
  6198. // if not applicable, false to just disable them
  6199. navigationAsDateFormat: false, // True if date formatting applied to prev/today/next links
  6200. gotoCurrent: false, // True if today link goes back to current selection instead
  6201. changeMonth: false, // True if month can be selected directly, false if only prev/next
  6202. changeYear: false, // True if year can be selected directly, false if only prev/next
  6203. yearRange: "c-10:c+10", // Range of years to display in drop-down,
  6204. // either relative to today's year (-nn:+nn), relative to currently displayed year
  6205. // (c-nn:c+nn), absolute (nnnn:nnnn), or a combination of the above (nnnn:-n)
  6206. showOtherMonths: false, // True to show dates in other months, false to leave blank
  6207. selectOtherMonths: false, // True to allow selection of dates in other months, false for unselectable
  6208. showWeek: false, // True to show week of the year, false to not show it
  6209. calculateWeek: this.iso8601Week, // How to calculate the week of the year,
  6210. // takes a Date and returns the number of the week for it
  6211. shortYearCutoff: "+10", // Short year values < this are in the current century,
  6212. // > this are in the previous century,
  6213. // string value starting with "+" for current year + value
  6214. minDate: null, // The earliest selectable date, or null for no limit
  6215. maxDate: null, // The latest selectable date, or null for no limit
  6216. duration: "fast", // Duration of display/closure
  6217. beforeShowDay: null, // Function that takes a date and returns an array with
  6218. // [0] = true if selectable, false if not, [1] = custom CSS class name(s) or "",
  6219. // [2] = cell title (optional), e.g. $.datepicker.noWeekends
  6220. beforeShow: null, // Function that takes an input field and
  6221. // returns a set of custom settings for the date picker
  6222. onSelect: null, // Define a callback function when a date is selected
  6223. onChangeMonthYear: null, // Define a callback function when the month or year is changed
  6224. onClose: null, // Define a callback function when the datepicker is closed
  6225. onUpdateDatepicker: null, // Define a callback function when the datepicker is updated
  6226. numberOfMonths: 1, // Number of months to show at a time
  6227. showCurrentAtPos: 0, // The position in multipe months at which to show the current month (starting at 0)
  6228. stepMonths: 1, // Number of months to step back/forward
  6229. stepBigMonths: 12, // Number of months to step back/forward for the big links
  6230. altField: "", // Selector for an alternate field to store selected dates into
  6231. altFormat: "", // The date format to use for the alternate field
  6232. constrainInput: true, // The input is constrained by the current date format
  6233. showButtonPanel: false, // True to show button panel, false to not show it
  6234. autoSize: false, // True to size the input for the date format, false to leave as is
  6235. disabled: false // The initial disabled state
  6236. };
  6237. $.extend( this._defaults, this.regional[ "" ] );
  6238. this.regional.en = $.extend( true, {}, this.regional[ "" ] );
  6239. this.regional[ "en-US" ] = $.extend( true, {}, this.regional.en );
  6240. this.dpDiv = datepicker_bindHover( $( "<div id='" + this._mainDivId + "' class='ui-datepicker ui-widget ui-widget-content ui-helper-clearfix ui-corner-all'></div>" ) );
  6241. }
  6242. $.extend( Datepicker.prototype, {
  6243. /* Class name added to elements to indicate already configured with a date picker. */
  6244. markerClassName: "hasDatepicker",
  6245. //Keep track of the maximum number of rows displayed (see #7043)
  6246. maxRows: 4,
  6247. // TODO rename to "widget" when switching to widget factory
  6248. _widgetDatepicker: function() {
  6249. return this.dpDiv;
  6250. },
  6251. /* Override the default settings for all instances of the date picker.
  6252. * @param settings object - the new settings to use as defaults (anonymous object)
  6253. * @return the manager object
  6254. */
  6255. setDefaults: function( settings ) {
  6256. datepicker_extendRemove( this._defaults, settings || {} );
  6257. return this;
  6258. },
  6259. /* Attach the date picker to a jQuery selection.
  6260. * @param target element - the target input field or division or span
  6261. * @param settings object - the new settings to use for this date picker instance (anonymous)
  6262. */
  6263. _attachDatepicker: function( target, settings ) {
  6264. var nodeName, inline, inst;
  6265. nodeName = target.nodeName.toLowerCase();
  6266. inline = ( nodeName === "div" || nodeName === "span" );
  6267. if ( !target.id ) {
  6268. this.uuid += 1;
  6269. target.id = "dp" + this.uuid;
  6270. }
  6271. inst = this._newInst( $( target ), inline );
  6272. inst.settings = $.extend( {}, settings || {} );
  6273. if ( nodeName === "input" ) {
  6274. this._connectDatepicker( target, inst );
  6275. } else if ( inline ) {
  6276. this._inlineDatepicker( target, inst );
  6277. }
  6278. },
  6279. /* Create a new instance object. */
  6280. _newInst: function( target, inline ) {
  6281. var id = target[ 0 ].id.replace( /([^A-Za-z0-9_\-])/g, "\\\\$1" ); // escape jQuery meta chars
  6282. return { id: id, input: target, // associated target
  6283. selectedDay: 0, selectedMonth: 0, selectedYear: 0, // current selection
  6284. drawMonth: 0, drawYear: 0, // month being drawn
  6285. inline: inline, // is datepicker inline or not
  6286. dpDiv: ( !inline ? this.dpDiv : // presentation div
  6287. datepicker_bindHover( $( "<div class='" + this._inlineClass + " ui-datepicker ui-widget ui-widget-content ui-helper-clearfix ui-corner-all'></div>" ) ) ) };
  6288. },
  6289. /* Attach the date picker to an input field. */
  6290. _connectDatepicker: function( target, inst ) {
  6291. var input = $( target );
  6292. inst.append = $( [] );
  6293. inst.trigger = $( [] );
  6294. if ( input.hasClass( this.markerClassName ) ) {
  6295. return;
  6296. }
  6297. this._attachments( input, inst );
  6298. input.addClass( this.markerClassName ).on( "keydown", this._doKeyDown ).
  6299. on( "keypress", this._doKeyPress ).on( "keyup", this._doKeyUp );
  6300. this._autoSize( inst );
  6301. $.data( target, "datepicker", inst );
  6302. //If disabled option is true, disable the datepicker once it has been attached to the input (see ticket #5665)
  6303. if ( inst.settings.disabled ) {
  6304. this._disableDatepicker( target );
  6305. }
  6306. },
  6307. /* Make attachments based on settings. */
  6308. _attachments: function( input, inst ) {
  6309. var showOn, buttonText, buttonImage,
  6310. appendText = this._get( inst, "appendText" ),
  6311. isRTL = this._get( inst, "isRTL" );
  6312. if ( inst.append ) {
  6313. inst.append.remove();
  6314. }
  6315. if ( appendText ) {
  6316. inst.append = $( "<span>" )
  6317. .addClass( this._appendClass )
  6318. .text( appendText );
  6319. input[ isRTL ? "before" : "after" ]( inst.append );
  6320. }
  6321. input.off( "focus", this._showDatepicker );
  6322. if ( inst.trigger ) {
  6323. inst.trigger.remove();
  6324. }
  6325. showOn = this._get( inst, "showOn" );
  6326. if ( showOn === "focus" || showOn === "both" ) { // pop-up date picker when in the marked field
  6327. input.on( "focus", this._showDatepicker );
  6328. }
  6329. if ( showOn === "button" || showOn === "both" ) { // pop-up date picker when button clicked
  6330. buttonText = this._get( inst, "buttonText" );
  6331. buttonImage = this._get( inst, "buttonImage" );
  6332. if ( this._get( inst, "buttonImageOnly" ) ) {
  6333. inst.trigger = $( "<img>" )
  6334. .addClass( this._triggerClass )
  6335. .attr( {
  6336. src: buttonImage,
  6337. alt: buttonText,
  6338. title: buttonText
  6339. } );
  6340. } else {
  6341. inst.trigger = $( "<button type='button'>" )
  6342. .addClass( this._triggerClass );
  6343. if ( buttonImage ) {
  6344. inst.trigger.html(
  6345. $( "<img>" )
  6346. .attr( {
  6347. src: buttonImage,
  6348. alt: buttonText,
  6349. title: buttonText
  6350. } )
  6351. );
  6352. } else {
  6353. inst.trigger.text( buttonText );
  6354. }
  6355. }
  6356. input[ isRTL ? "before" : "after" ]( inst.trigger );
  6357. inst.trigger.on( "click", function() {
  6358. if ( $.datepicker._datepickerShowing && $.datepicker._lastInput === input[ 0 ] ) {
  6359. $.datepicker._hideDatepicker();
  6360. } else if ( $.datepicker._datepickerShowing && $.datepicker._lastInput !== input[ 0 ] ) {
  6361. $.datepicker._hideDatepicker();
  6362. $.datepicker._showDatepicker( input[ 0 ] );
  6363. } else {
  6364. $.datepicker._showDatepicker( input[ 0 ] );
  6365. }
  6366. return false;
  6367. } );
  6368. }
  6369. },
  6370. /* Apply the maximum length for the date format. */
  6371. _autoSize: function( inst ) {
  6372. if ( this._get( inst, "autoSize" ) && !inst.inline ) {
  6373. var findMax, max, maxI, i,
  6374. date = new Date( 2009, 12 - 1, 20 ), // Ensure double digits
  6375. dateFormat = this._get( inst, "dateFormat" );
  6376. if ( dateFormat.match( /[DM]/ ) ) {
  6377. findMax = function( names ) {
  6378. max = 0;
  6379. maxI = 0;
  6380. for ( i = 0; i < names.length; i++ ) {
  6381. if ( names[ i ].length > max ) {
  6382. max = names[ i ].length;
  6383. maxI = i;
  6384. }
  6385. }
  6386. return maxI;
  6387. };
  6388. date.setMonth( findMax( this._get( inst, ( dateFormat.match( /MM/ ) ?
  6389. "monthNames" : "monthNamesShort" ) ) ) );
  6390. date.setDate( findMax( this._get( inst, ( dateFormat.match( /DD/ ) ?
  6391. "dayNames" : "dayNamesShort" ) ) ) + 20 - date.getDay() );
  6392. }
  6393. inst.input.attr( "size", this._formatDate( inst, date ).length );
  6394. }
  6395. },
  6396. /* Attach an inline date picker to a div. */
  6397. _inlineDatepicker: function( target, inst ) {
  6398. var divSpan = $( target );
  6399. if ( divSpan.hasClass( this.markerClassName ) ) {
  6400. return;
  6401. }
  6402. divSpan.addClass( this.markerClassName ).append( inst.dpDiv );
  6403. $.data( target, "datepicker", inst );
  6404. this._setDate( inst, this._getDefaultDate( inst ), true );
  6405. this._updateDatepicker( inst );
  6406. this._updateAlternate( inst );
  6407. //If disabled option is true, disable the datepicker before showing it (see ticket #5665)
  6408. if ( inst.settings.disabled ) {
  6409. this._disableDatepicker( target );
  6410. }
  6411. // Set display:block in place of inst.dpDiv.show() which won't work on disconnected elements
  6412. // http://bugs.jqueryui.com/ticket/7552 - A Datepicker created on a detached div has zero height
  6413. inst.dpDiv.css( "display", "block" );
  6414. },
  6415. /* Pop-up the date picker in a "dialog" box.
  6416. * @param input element - ignored
  6417. * @param date string or Date - the initial date to display
  6418. * @param onSelect function - the function to call when a date is selected
  6419. * @param settings object - update the dialog date picker instance's settings (anonymous object)
  6420. * @param pos int[2] - coordinates for the dialog's position within the screen or
  6421. * event - with x/y coordinates or
  6422. * leave empty for default (screen centre)
  6423. * @return the manager object
  6424. */
  6425. _dialogDatepicker: function( input, date, onSelect, settings, pos ) {
  6426. var id, browserWidth, browserHeight, scrollX, scrollY,
  6427. inst = this._dialogInst; // internal instance
  6428. if ( !inst ) {
  6429. this.uuid += 1;
  6430. id = "dp" + this.uuid;
  6431. this._dialogInput = $( "<input type='text' id='" + id +
  6432. "' style='position: absolute; top: -100px; width: 0px;'/>" );
  6433. this._dialogInput.on( "keydown", this._doKeyDown );
  6434. $( "body" ).append( this._dialogInput );
  6435. inst = this._dialogInst = this._newInst( this._dialogInput, false );
  6436. inst.settings = {};
  6437. $.data( this._dialogInput[ 0 ], "datepicker", inst );
  6438. }
  6439. datepicker_extendRemove( inst.settings, settings || {} );
  6440. date = ( date && date.constructor === Date ? this._formatDate( inst, date ) : date );
  6441. this._dialogInput.val( date );
  6442. this._pos = ( pos ? ( pos.length ? pos : [ pos.pageX, pos.pageY ] ) : null );
  6443. if ( !this._pos ) {
  6444. browserWidth = document.documentElement.clientWidth;
  6445. browserHeight = document.documentElement.clientHeight;
  6446. scrollX = document.documentElement.scrollLeft || document.body.scrollLeft;
  6447. scrollY = document.documentElement.scrollTop || document.body.scrollTop;
  6448. this._pos = // should use actual width/height below
  6449. [ ( browserWidth / 2 ) - 100 + scrollX, ( browserHeight / 2 ) - 150 + scrollY ];
  6450. }
  6451. // Move input on screen for focus, but hidden behind dialog
  6452. this._dialogInput.css( "left", ( this._pos[ 0 ] + 20 ) + "px" ).css( "top", this._pos[ 1 ] + "px" );
  6453. inst.settings.onSelect = onSelect;
  6454. this._inDialog = true;
  6455. this.dpDiv.addClass( this._dialogClass );
  6456. this._showDatepicker( this._dialogInput[ 0 ] );
  6457. if ( $.blockUI ) {
  6458. $.blockUI( this.dpDiv );
  6459. }
  6460. $.data( this._dialogInput[ 0 ], "datepicker", inst );
  6461. return this;
  6462. },
  6463. /* Detach a datepicker from its control.
  6464. * @param target element - the target input field or division or span
  6465. */
  6466. _destroyDatepicker: function( target ) {
  6467. var nodeName,
  6468. $target = $( target ),
  6469. inst = $.data( target, "datepicker" );
  6470. if ( !$target.hasClass( this.markerClassName ) ) {
  6471. return;
  6472. }
  6473. nodeName = target.nodeName.toLowerCase();
  6474. $.removeData( target, "datepicker" );
  6475. if ( nodeName === "input" ) {
  6476. inst.append.remove();
  6477. inst.trigger.remove();
  6478. $target.removeClass( this.markerClassName ).
  6479. off( "focus", this._showDatepicker ).
  6480. off( "keydown", this._doKeyDown ).
  6481. off( "keypress", this._doKeyPress ).
  6482. off( "keyup", this._doKeyUp );
  6483. } else if ( nodeName === "div" || nodeName === "span" ) {
  6484. $target.removeClass( this.markerClassName ).empty();
  6485. }
  6486. if ( datepicker_instActive === inst ) {
  6487. datepicker_instActive = null;
  6488. this._curInst = null;
  6489. }
  6490. },
  6491. /* Enable the date picker to a jQuery selection.
  6492. * @param target element - the target input field or division or span
  6493. */
  6494. _enableDatepicker: function( target ) {
  6495. var nodeName, inline,
  6496. $target = $( target ),
  6497. inst = $.data( target, "datepicker" );
  6498. if ( !$target.hasClass( this.markerClassName ) ) {
  6499. return;
  6500. }
  6501. nodeName = target.nodeName.toLowerCase();
  6502. if ( nodeName === "input" ) {
  6503. target.disabled = false;
  6504. inst.trigger.filter( "button" ).
  6505. each( function() {
  6506. this.disabled = false;
  6507. } ).end().
  6508. filter( "img" ).css( { opacity: "1.0", cursor: "" } );
  6509. } else if ( nodeName === "div" || nodeName === "span" ) {
  6510. inline = $target.children( "." + this._inlineClass );
  6511. inline.children().removeClass( "ui-state-disabled" );
  6512. inline.find( "select.ui-datepicker-month, select.ui-datepicker-year" ).
  6513. prop( "disabled", false );
  6514. }
  6515. this._disabledInputs = $.map( this._disabledInputs,
  6516. // Delete entry
  6517. function( value ) {
  6518. return ( value === target ? null : value );
  6519. } );
  6520. },
  6521. /* Disable the date picker to a jQuery selection.
  6522. * @param target element - the target input field or division or span
  6523. */
  6524. _disableDatepicker: function( target ) {
  6525. var nodeName, inline,
  6526. $target = $( target ),
  6527. inst = $.data( target, "datepicker" );
  6528. if ( !$target.hasClass( this.markerClassName ) ) {
  6529. return;
  6530. }
  6531. nodeName = target.nodeName.toLowerCase();
  6532. if ( nodeName === "input" ) {
  6533. target.disabled = true;
  6534. inst.trigger.filter( "button" ).
  6535. each( function() {
  6536. this.disabled = true;
  6537. } ).end().
  6538. filter( "img" ).css( { opacity: "0.5", cursor: "default" } );
  6539. } else if ( nodeName === "div" || nodeName === "span" ) {
  6540. inline = $target.children( "." + this._inlineClass );
  6541. inline.children().addClass( "ui-state-disabled" );
  6542. inline.find( "select.ui-datepicker-month, select.ui-datepicker-year" ).
  6543. prop( "disabled", true );
  6544. }
  6545. this._disabledInputs = $.map( this._disabledInputs,
  6546. // Delete entry
  6547. function( value ) {
  6548. return ( value === target ? null : value );
  6549. } );
  6550. this._disabledInputs[ this._disabledInputs.length ] = target;
  6551. },
  6552. /* Is the first field in a jQuery collection disabled as a datepicker?
  6553. * @param target element - the target input field or division or span
  6554. * @return boolean - true if disabled, false if enabled
  6555. */
  6556. _isDisabledDatepicker: function( target ) {
  6557. if ( !target ) {
  6558. return false;
  6559. }
  6560. for ( var i = 0; i < this._disabledInputs.length; i++ ) {
  6561. if ( this._disabledInputs[ i ] === target ) {
  6562. return true;
  6563. }
  6564. }
  6565. return false;
  6566. },
  6567. /* Retrieve the instance data for the target control.
  6568. * @param target element - the target input field or division or span
  6569. * @return object - the associated instance data
  6570. * @throws error if a jQuery problem getting data
  6571. */
  6572. _getInst: function( target ) {
  6573. try {
  6574. return $.data( target, "datepicker" );
  6575. } catch ( err ) {
  6576. throw "Missing instance data for this datepicker";
  6577. }
  6578. },
  6579. /* Update or retrieve the settings for a date picker attached to an input field or division.
  6580. * @param target element - the target input field or division or span
  6581. * @param name object - the new settings to update or
  6582. * string - the name of the setting to change or retrieve,
  6583. * when retrieving also "all" for all instance settings or
  6584. * "defaults" for all global defaults
  6585. * @param value any - the new value for the setting
  6586. * (omit if above is an object or to retrieve a value)
  6587. */
  6588. _optionDatepicker: function( target, name, value ) {
  6589. var settings, date, minDate, maxDate,
  6590. inst = this._getInst( target );
  6591. if ( arguments.length === 2 && typeof name === "string" ) {
  6592. return ( name === "defaults" ? $.extend( {}, $.datepicker._defaults ) :
  6593. ( inst ? ( name === "all" ? $.extend( {}, inst.settings ) :
  6594. this._get( inst, name ) ) : null ) );
  6595. }
  6596. settings = name || {};
  6597. if ( typeof name === "string" ) {
  6598. settings = {};
  6599. settings[ name ] = value;
  6600. }
  6601. if ( inst ) {
  6602. if ( this._curInst === inst ) {
  6603. this._hideDatepicker();
  6604. }
  6605. date = this._getDateDatepicker( target, true );
  6606. minDate = this._getMinMaxDate( inst, "min" );
  6607. maxDate = this._getMinMaxDate( inst, "max" );
  6608. datepicker_extendRemove( inst.settings, settings );
  6609. // reformat the old minDate/maxDate values if dateFormat changes and a new minDate/maxDate isn't provided
  6610. if ( minDate !== null && settings.dateFormat !== undefined && settings.minDate === undefined ) {
  6611. inst.settings.minDate = this._formatDate( inst, minDate );
  6612. }
  6613. if ( maxDate !== null && settings.dateFormat !== undefined && settings.maxDate === undefined ) {
  6614. inst.settings.maxDate = this._formatDate( inst, maxDate );
  6615. }
  6616. if ( "disabled" in settings ) {
  6617. if ( settings.disabled ) {
  6618. this._disableDatepicker( target );
  6619. } else {
  6620. this._enableDatepicker( target );
  6621. }
  6622. }
  6623. this._attachments( $( target ), inst );
  6624. this._autoSize( inst );
  6625. this._setDate( inst, date );
  6626. this._updateAlternate( inst );
  6627. this._updateDatepicker( inst );
  6628. }
  6629. },
  6630. // Change method deprecated
  6631. _changeDatepicker: function( target, name, value ) {
  6632. this._optionDatepicker( target, name, value );
  6633. },
  6634. /* Redraw the date picker attached to an input field or division.
  6635. * @param target element - the target input field or division or span
  6636. */
  6637. _refreshDatepicker: function( target ) {
  6638. var inst = this._getInst( target );
  6639. if ( inst ) {
  6640. this._updateDatepicker( inst );
  6641. }
  6642. },
  6643. /* Set the dates for a jQuery selection.
  6644. * @param target element - the target input field or division or span
  6645. * @param date Date - the new date
  6646. */
  6647. _setDateDatepicker: function( target, date ) {
  6648. var inst = this._getInst( target );
  6649. if ( inst ) {
  6650. this._setDate( inst, date );
  6651. this._updateDatepicker( inst );
  6652. this._updateAlternate( inst );
  6653. }
  6654. },
  6655. /* Get the date(s) for the first entry in a jQuery selection.
  6656. * @param target element - the target input field or division or span
  6657. * @param noDefault boolean - true if no default date is to be used
  6658. * @return Date - the current date
  6659. */
  6660. _getDateDatepicker: function( target, noDefault ) {
  6661. var inst = this._getInst( target );
  6662. if ( inst && !inst.inline ) {
  6663. this._setDateFromField( inst, noDefault );
  6664. }
  6665. return ( inst ? this._getDate( inst ) : null );
  6666. },
  6667. /* Handle keystrokes. */
  6668. _doKeyDown: function( event ) {
  6669. var onSelect, dateStr, sel,
  6670. inst = $.datepicker._getInst( event.target ),
  6671. handled = true,
  6672. isRTL = inst.dpDiv.is( ".ui-datepicker-rtl" );
  6673. inst._keyEvent = true;
  6674. if ( $.datepicker._datepickerShowing ) {
  6675. switch ( event.keyCode ) {
  6676. case 9: $.datepicker._hideDatepicker();
  6677. handled = false;
  6678. break; // hide on tab out
  6679. case 13: sel = $( "td." + $.datepicker._dayOverClass + ":not(." +
  6680. $.datepicker._currentClass + ")", inst.dpDiv );
  6681. if ( sel[ 0 ] ) {
  6682. $.datepicker._selectDay( event.target, inst.selectedMonth, inst.selectedYear, sel[ 0 ] );
  6683. }
  6684. onSelect = $.datepicker._get( inst, "onSelect" );
  6685. if ( onSelect ) {
  6686. dateStr = $.datepicker._formatDate( inst );
  6687. // Trigger custom callback
  6688. onSelect.apply( ( inst.input ? inst.input[ 0 ] : null ), [ dateStr, inst ] );
  6689. } else {
  6690. $.datepicker._hideDatepicker();
  6691. }
  6692. return false; // don't submit the form
  6693. case 27: $.datepicker._hideDatepicker();
  6694. break; // hide on escape
  6695. case 33: $.datepicker._adjustDate( event.target, ( event.ctrlKey ?
  6696. -$.datepicker._get( inst, "stepBigMonths" ) :
  6697. -$.datepicker._get( inst, "stepMonths" ) ), "M" );
  6698. break; // previous month/year on page up/+ ctrl
  6699. case 34: $.datepicker._adjustDate( event.target, ( event.ctrlKey ?
  6700. +$.datepicker._get( inst, "stepBigMonths" ) :
  6701. +$.datepicker._get( inst, "stepMonths" ) ), "M" );
  6702. break; // next month/year on page down/+ ctrl
  6703. case 35: if ( event.ctrlKey || event.metaKey ) {
  6704. $.datepicker._clearDate( event.target );
  6705. }
  6706. handled = event.ctrlKey || event.metaKey;
  6707. break; // clear on ctrl or command +end
  6708. case 36: if ( event.ctrlKey || event.metaKey ) {
  6709. $.datepicker._gotoToday( event.target );
  6710. }
  6711. handled = event.ctrlKey || event.metaKey;
  6712. break; // current on ctrl or command +home
  6713. case 37: if ( event.ctrlKey || event.metaKey ) {
  6714. $.datepicker._adjustDate( event.target, ( isRTL ? +1 : -1 ), "D" );
  6715. }
  6716. handled = event.ctrlKey || event.metaKey;
  6717. // -1 day on ctrl or command +left
  6718. if ( event.originalEvent.altKey ) {
  6719. $.datepicker._adjustDate( event.target, ( event.ctrlKey ?
  6720. -$.datepicker._get( inst, "stepBigMonths" ) :
  6721. -$.datepicker._get( inst, "stepMonths" ) ), "M" );
  6722. }
  6723. // next month/year on alt +left on Mac
  6724. break;
  6725. case 38: if ( event.ctrlKey || event.metaKey ) {
  6726. $.datepicker._adjustDate( event.target, -7, "D" );
  6727. }
  6728. handled = event.ctrlKey || event.metaKey;
  6729. break; // -1 week on ctrl or command +up
  6730. case 39: if ( event.ctrlKey || event.metaKey ) {
  6731. $.datepicker._adjustDate( event.target, ( isRTL ? -1 : +1 ), "D" );
  6732. }
  6733. handled = event.ctrlKey || event.metaKey;
  6734. // +1 day on ctrl or command +right
  6735. if ( event.originalEvent.altKey ) {
  6736. $.datepicker._adjustDate( event.target, ( event.ctrlKey ?
  6737. +$.datepicker._get( inst, "stepBigMonths" ) :
  6738. +$.datepicker._get( inst, "stepMonths" ) ), "M" );
  6739. }
  6740. // next month/year on alt +right
  6741. break;
  6742. case 40: if ( event.ctrlKey || event.metaKey ) {
  6743. $.datepicker._adjustDate( event.target, +7, "D" );
  6744. }
  6745. handled = event.ctrlKey || event.metaKey;
  6746. break; // +1 week on ctrl or command +down
  6747. default: handled = false;
  6748. }
  6749. } else if ( event.keyCode === 36 && event.ctrlKey ) { // display the date picker on ctrl+home
  6750. $.datepicker._showDatepicker( this );
  6751. } else {
  6752. handled = false;
  6753. }
  6754. if ( handled ) {
  6755. event.preventDefault();
  6756. event.stopPropagation();
  6757. }
  6758. },
  6759. /* Filter entered characters - based on date format. */
  6760. _doKeyPress: function( event ) {
  6761. var chars, chr,
  6762. inst = $.datepicker._getInst( event.target );
  6763. if ( $.datepicker._get( inst, "constrainInput" ) ) {
  6764. chars = $.datepicker._possibleChars( $.datepicker._get( inst, "dateFormat" ) );
  6765. chr = String.fromCharCode( event.charCode == null ? event.keyCode : event.charCode );
  6766. return event.ctrlKey || event.metaKey || ( chr < " " || !chars || chars.indexOf( chr ) > -1 );
  6767. }
  6768. },
  6769. /* Synchronise manual entry and field/alternate field. */
  6770. _doKeyUp: function( event ) {
  6771. var date,
  6772. inst = $.datepicker._getInst( event.target );
  6773. if ( inst.input.val() !== inst.lastVal ) {
  6774. try {
  6775. date = $.datepicker.parseDate( $.datepicker._get( inst, "dateFormat" ),
  6776. ( inst.input ? inst.input.val() : null ),
  6777. $.datepicker._getFormatConfig( inst ) );
  6778. if ( date ) { // only if valid
  6779. $.datepicker._setDateFromField( inst );
  6780. $.datepicker._updateAlternate( inst );
  6781. $.datepicker._updateDatepicker( inst );
  6782. }
  6783. } catch ( err ) {
  6784. }
  6785. }
  6786. return true;
  6787. },
  6788. /* Pop-up the date picker for a given input field.
  6789. * If false returned from beforeShow event handler do not show.
  6790. * @param input element - the input field attached to the date picker or
  6791. * event - if triggered by focus
  6792. */
  6793. _showDatepicker: function( input ) {
  6794. input = input.target || input;
  6795. if ( input.nodeName.toLowerCase() !== "input" ) { // find from button/image trigger
  6796. input = $( "input", input.parentNode )[ 0 ];
  6797. }
  6798. if ( $.datepicker._isDisabledDatepicker( input ) || $.datepicker._lastInput === input ) { // already here
  6799. return;
  6800. }
  6801. var inst, beforeShow, beforeShowSettings, isFixed,
  6802. offset, showAnim, duration;
  6803. inst = $.datepicker._getInst( input );
  6804. if ( $.datepicker._curInst && $.datepicker._curInst !== inst ) {
  6805. $.datepicker._curInst.dpDiv.stop( true, true );
  6806. if ( inst && $.datepicker._datepickerShowing ) {
  6807. $.datepicker._hideDatepicker( $.datepicker._curInst.input[ 0 ] );
  6808. }
  6809. }
  6810. beforeShow = $.datepicker._get( inst, "beforeShow" );
  6811. beforeShowSettings = beforeShow ? beforeShow.apply( input, [ input, inst ] ) : {};
  6812. if ( beforeShowSettings === false ) {
  6813. return;
  6814. }
  6815. datepicker_extendRemove( inst.settings, beforeShowSettings );
  6816. inst.lastVal = null;
  6817. $.datepicker._lastInput = input;
  6818. $.datepicker._setDateFromField( inst );
  6819. if ( $.datepicker._inDialog ) { // hide cursor
  6820. input.value = "";
  6821. }
  6822. if ( !$.datepicker._pos ) { // position below input
  6823. $.datepicker._pos = $.datepicker._findPos( input );
  6824. $.datepicker._pos[ 1 ] += input.offsetHeight; // add the height
  6825. }
  6826. isFixed = false;
  6827. $( input ).parents().each( function() {
  6828. isFixed |= $( this ).css( "position" ) === "fixed";
  6829. return !isFixed;
  6830. } );
  6831. offset = { left: $.datepicker._pos[ 0 ], top: $.datepicker._pos[ 1 ] };
  6832. $.datepicker._pos = null;
  6833. //to avoid flashes on Firefox
  6834. inst.dpDiv.empty();
  6835. // determine sizing offscreen
  6836. inst.dpDiv.css( { position: "absolute", display: "block", top: "-1000px" } );
  6837. $.datepicker._updateDatepicker( inst );
  6838. // fix width for dynamic number of date pickers
  6839. // and adjust position before showing
  6840. offset = $.datepicker._checkOffset( inst, offset, isFixed );
  6841. inst.dpDiv.css( { position: ( $.datepicker._inDialog && $.blockUI ?
  6842. "static" : ( isFixed ? "fixed" : "absolute" ) ), display: "none",
  6843. left: offset.left + "px", top: offset.top + "px" } );
  6844. if ( !inst.inline ) {
  6845. showAnim = $.datepicker._get( inst, "showAnim" );
  6846. duration = $.datepicker._get( inst, "duration" );
  6847. inst.dpDiv.css( "z-index", datepicker_getZindex( $( input ) ) + 1 );
  6848. $.datepicker._datepickerShowing = true;
  6849. if ( $.effects && $.effects.effect[ showAnim ] ) {
  6850. inst.dpDiv.show( showAnim, $.datepicker._get( inst, "showOptions" ), duration );
  6851. } else {
  6852. inst.dpDiv[ showAnim || "show" ]( showAnim ? duration : null );
  6853. }
  6854. if ( $.datepicker._shouldFocusInput( inst ) ) {
  6855. inst.input.trigger( "focus" );
  6856. }
  6857. $.datepicker._curInst = inst;
  6858. }
  6859. },
  6860. /* Generate the date picker content. */
  6861. _updateDatepicker: function( inst ) {
  6862. this.maxRows = 4; //Reset the max number of rows being displayed (see #7043)
  6863. datepicker_instActive = inst; // for delegate hover events
  6864. inst.dpDiv.empty().append( this._generateHTML( inst ) );
  6865. this._attachHandlers( inst );
  6866. var origyearshtml,
  6867. numMonths = this._getNumberOfMonths( inst ),
  6868. cols = numMonths[ 1 ],
  6869. width = 17,
  6870. activeCell = inst.dpDiv.find( "." + this._dayOverClass + " a" ),
  6871. onUpdateDatepicker = $.datepicker._get( inst, "onUpdateDatepicker" );
  6872. if ( activeCell.length > 0 ) {
  6873. datepicker_handleMouseover.apply( activeCell.get( 0 ) );
  6874. }
  6875. inst.dpDiv.removeClass( "ui-datepicker-multi-2 ui-datepicker-multi-3 ui-datepicker-multi-4" ).width( "" );
  6876. if ( cols > 1 ) {
  6877. inst.dpDiv.addClass( "ui-datepicker-multi-" + cols ).css( "width", ( width * cols ) + "em" );
  6878. }
  6879. inst.dpDiv[ ( numMonths[ 0 ] !== 1 || numMonths[ 1 ] !== 1 ? "add" : "remove" ) +
  6880. "Class" ]( "ui-datepicker-multi" );
  6881. inst.dpDiv[ ( this._get( inst, "isRTL" ) ? "add" : "remove" ) +
  6882. "Class" ]( "ui-datepicker-rtl" );
  6883. if ( inst === $.datepicker._curInst && $.datepicker._datepickerShowing && $.datepicker._shouldFocusInput( inst ) ) {
  6884. inst.input.trigger( "focus" );
  6885. }
  6886. // Deffered render of the years select (to avoid flashes on Firefox)
  6887. if ( inst.yearshtml ) {
  6888. origyearshtml = inst.yearshtml;
  6889. setTimeout( function() {
  6890. //assure that inst.yearshtml didn't change.
  6891. if ( origyearshtml === inst.yearshtml && inst.yearshtml ) {
  6892. inst.dpDiv.find( "select.ui-datepicker-year" ).first().replaceWith( inst.yearshtml );
  6893. }
  6894. origyearshtml = inst.yearshtml = null;
  6895. }, 0 );
  6896. }
  6897. if ( onUpdateDatepicker ) {
  6898. onUpdateDatepicker.apply( ( inst.input ? inst.input[ 0 ] : null ), [ inst ] );
  6899. }
  6900. },
  6901. // #6694 - don't focus the input if it's already focused
  6902. // this breaks the change event in IE
  6903. // Support: IE and jQuery <1.9
  6904. _shouldFocusInput: function( inst ) {
  6905. return inst.input && inst.input.is( ":visible" ) && !inst.input.is( ":disabled" ) && !inst.input.is( ":focus" );
  6906. },
  6907. /* Check positioning to remain on screen. */
  6908. _checkOffset: function( inst, offset, isFixed ) {
  6909. var dpWidth = inst.dpDiv.outerWidth(),
  6910. dpHeight = inst.dpDiv.outerHeight(),
  6911. inputWidth = inst.input ? inst.input.outerWidth() : 0,
  6912. inputHeight = inst.input ? inst.input.outerHeight() : 0,
  6913. viewWidth = document.documentElement.clientWidth + ( isFixed ? 0 : $( document ).scrollLeft() ),
  6914. viewHeight = document.documentElement.clientHeight + ( isFixed ? 0 : $( document ).scrollTop() );
  6915. offset.left -= ( this._get( inst, "isRTL" ) ? ( dpWidth - inputWidth ) : 0 );
  6916. offset.left -= ( isFixed && offset.left === inst.input.offset().left ) ? $( document ).scrollLeft() : 0;
  6917. offset.top -= ( isFixed && offset.top === ( inst.input.offset().top + inputHeight ) ) ? $( document ).scrollTop() : 0;
  6918. // Now check if datepicker is showing outside window viewport - move to a better place if so.
  6919. offset.left -= Math.min( offset.left, ( offset.left + dpWidth > viewWidth && viewWidth > dpWidth ) ?
  6920. Math.abs( offset.left + dpWidth - viewWidth ) : 0 );
  6921. offset.top -= Math.min( offset.top, ( offset.top + dpHeight > viewHeight && viewHeight > dpHeight ) ?
  6922. Math.abs( dpHeight + inputHeight ) : 0 );
  6923. return offset;
  6924. },
  6925. /* Find an object's position on the screen. */
  6926. _findPos: function( obj ) {
  6927. var position,
  6928. inst = this._getInst( obj ),
  6929. isRTL = this._get( inst, "isRTL" );
  6930. while ( obj && ( obj.type === "hidden" || obj.nodeType !== 1 || $.expr.pseudos.hidden( obj ) ) ) {
  6931. obj = obj[ isRTL ? "previousSibling" : "nextSibling" ];
  6932. }
  6933. position = $( obj ).offset();
  6934. return [ position.left, position.top ];
  6935. },
  6936. /* Hide the date picker from view.
  6937. * @param input element - the input field attached to the date picker
  6938. */
  6939. _hideDatepicker: function( input ) {
  6940. var showAnim, duration, postProcess, onClose,
  6941. inst = this._curInst;
  6942. if ( !inst || ( input && inst !== $.data( input, "datepicker" ) ) ) {
  6943. return;
  6944. }
  6945. if ( this._datepickerShowing ) {
  6946. showAnim = this._get( inst, "showAnim" );
  6947. duration = this._get( inst, "duration" );
  6948. postProcess = function() {
  6949. $.datepicker._tidyDialog( inst );
  6950. };
  6951. // DEPRECATED: after BC for 1.8.x $.effects[ showAnim ] is not needed
  6952. if ( $.effects && ( $.effects.effect[ showAnim ] || $.effects[ showAnim ] ) ) {
  6953. inst.dpDiv.hide( showAnim, $.datepicker._get( inst, "showOptions" ), duration, postProcess );
  6954. } else {
  6955. inst.dpDiv[ ( showAnim === "slideDown" ? "slideUp" :
  6956. ( showAnim === "fadeIn" ? "fadeOut" : "hide" ) ) ]( ( showAnim ? duration : null ), postProcess );
  6957. }
  6958. if ( !showAnim ) {
  6959. postProcess();
  6960. }
  6961. this._datepickerShowing = false;
  6962. onClose = this._get( inst, "onClose" );
  6963. if ( onClose ) {
  6964. onClose.apply( ( inst.input ? inst.input[ 0 ] : null ), [ ( inst.input ? inst.input.val() : "" ), inst ] );
  6965. }
  6966. this._lastInput = null;
  6967. if ( this._inDialog ) {
  6968. this._dialogInput.css( { position: "absolute", left: "0", top: "-100px" } );
  6969. if ( $.blockUI ) {
  6970. $.unblockUI();
  6971. $( "body" ).append( this.dpDiv );
  6972. }
  6973. }
  6974. this._inDialog = false;
  6975. }
  6976. },
  6977. /* Tidy up after a dialog display. */
  6978. _tidyDialog: function( inst ) {
  6979. inst.dpDiv.removeClass( this._dialogClass ).off( ".ui-datepicker-calendar" );
  6980. },
  6981. /* Close date picker if clicked elsewhere. */
  6982. _checkExternalClick: function( event ) {
  6983. if ( !$.datepicker._curInst ) {
  6984. return;
  6985. }
  6986. var $target = $( event.target ),
  6987. inst = $.datepicker._getInst( $target[ 0 ] );
  6988. if ( ( ( $target[ 0 ].id !== $.datepicker._mainDivId &&
  6989. $target.parents( "#" + $.datepicker._mainDivId ).length === 0 &&
  6990. !$target.hasClass( $.datepicker.markerClassName ) &&
  6991. !$target.closest( "." + $.datepicker._triggerClass ).length &&
  6992. $.datepicker._datepickerShowing && !( $.datepicker._inDialog && $.blockUI ) ) ) ||
  6993. ( $target.hasClass( $.datepicker.markerClassName ) && $.datepicker._curInst !== inst ) ) {
  6994. $.datepicker._hideDatepicker();
  6995. }
  6996. },
  6997. /* Adjust one of the date sub-fields. */
  6998. _adjustDate: function( id, offset, period ) {
  6999. var target = $( id ),
  7000. inst = this._getInst( target[ 0 ] );
  7001. if ( this._isDisabledDatepicker( target[ 0 ] ) ) {
  7002. return;
  7003. }
  7004. this._adjustInstDate( inst, offset, period );
  7005. this._updateDatepicker( inst );
  7006. },
  7007. /* Action for current link. */
  7008. _gotoToday: function( id ) {
  7009. var date,
  7010. target = $( id ),
  7011. inst = this._getInst( target[ 0 ] );
  7012. if ( this._get( inst, "gotoCurrent" ) && inst.currentDay ) {
  7013. inst.selectedDay = inst.currentDay;
  7014. inst.drawMonth = inst.selectedMonth = inst.currentMonth;
  7015. inst.drawYear = inst.selectedYear = inst.currentYear;
  7016. } else {
  7017. date = new Date();
  7018. inst.selectedDay = date.getDate();
  7019. inst.drawMonth = inst.selectedMonth = date.getMonth();
  7020. inst.drawYear = inst.selectedYear = date.getFullYear();
  7021. }
  7022. this._notifyChange( inst );
  7023. this._adjustDate( target );
  7024. },
  7025. /* Action for selecting a new month/year. */
  7026. _selectMonthYear: function( id, select, period ) {
  7027. var target = $( id ),
  7028. inst = this._getInst( target[ 0 ] );
  7029. inst[ "selected" + ( period === "M" ? "Month" : "Year" ) ] =
  7030. inst[ "draw" + ( period === "M" ? "Month" : "Year" ) ] =
  7031. parseInt( select.options[ select.selectedIndex ].value, 10 );
  7032. this._notifyChange( inst );
  7033. this._adjustDate( target );
  7034. },
  7035. /* Action for selecting a day. */
  7036. _selectDay: function( id, month, year, td ) {
  7037. var inst,
  7038. target = $( id );
  7039. if ( $( td ).hasClass( this._unselectableClass ) || this._isDisabledDatepicker( target[ 0 ] ) ) {
  7040. return;
  7041. }
  7042. inst = this._getInst( target[ 0 ] );
  7043. inst.selectedDay = inst.currentDay = parseInt( $( "a", td ).attr( "data-date" ) );
  7044. inst.selectedMonth = inst.currentMonth = month;
  7045. inst.selectedYear = inst.currentYear = year;
  7046. this._selectDate( id, this._formatDate( inst,
  7047. inst.currentDay, inst.currentMonth, inst.currentYear ) );
  7048. },
  7049. /* Erase the input field and hide the date picker. */
  7050. _clearDate: function( id ) {
  7051. var target = $( id );
  7052. this._selectDate( target, "" );
  7053. },
  7054. /* Update the input field with the selected date. */
  7055. _selectDate: function( id, dateStr ) {
  7056. var onSelect,
  7057. target = $( id ),
  7058. inst = this._getInst( target[ 0 ] );
  7059. dateStr = ( dateStr != null ? dateStr : this._formatDate( inst ) );
  7060. if ( inst.input ) {
  7061. inst.input.val( dateStr );
  7062. }
  7063. this._updateAlternate( inst );
  7064. onSelect = this._get( inst, "onSelect" );
  7065. if ( onSelect ) {
  7066. onSelect.apply( ( inst.input ? inst.input[ 0 ] : null ), [ dateStr, inst ] ); // trigger custom callback
  7067. } else if ( inst.input ) {
  7068. inst.input.trigger( "change" ); // fire the change event
  7069. }
  7070. if ( inst.inline ) {
  7071. this._updateDatepicker( inst );
  7072. } else {
  7073. this._hideDatepicker();
  7074. this._lastInput = inst.input[ 0 ];
  7075. if ( typeof( inst.input[ 0 ] ) !== "object" ) {
  7076. inst.input.trigger( "focus" ); // restore focus
  7077. }
  7078. this._lastInput = null;
  7079. }
  7080. },
  7081. /* Update any alternate field to synchronise with the main field. */
  7082. _updateAlternate: function( inst ) {
  7083. var altFormat, date, dateStr,
  7084. altField = this._get( inst, "altField" );
  7085. if ( altField ) { // update alternate field too
  7086. altFormat = this._get( inst, "altFormat" ) || this._get( inst, "dateFormat" );
  7087. date = this._getDate( inst );
  7088. dateStr = this.formatDate( altFormat, date, this._getFormatConfig( inst ) );
  7089. $( document ).find( altField ).val( dateStr );
  7090. }
  7091. },
  7092. /* Set as beforeShowDay function to prevent selection of weekends.
  7093. * @param date Date - the date to customise
  7094. * @return [boolean, string] - is this date selectable?, what is its CSS class?
  7095. */
  7096. noWeekends: function( date ) {
  7097. var day = date.getDay();
  7098. return [ ( day > 0 && day < 6 ), "" ];
  7099. },
  7100. /* Set as calculateWeek to determine the week of the year based on the ISO 8601 definition.
  7101. * @param date Date - the date to get the week for
  7102. * @return number - the number of the week within the year that contains this date
  7103. */
  7104. iso8601Week: function( date ) {
  7105. var time,
  7106. checkDate = new Date( date.getTime() );
  7107. // Find Thursday of this week starting on Monday
  7108. checkDate.setDate( checkDate.getDate() + 4 - ( checkDate.getDay() || 7 ) );
  7109. time = checkDate.getTime();
  7110. checkDate.setMonth( 0 ); // Compare with Jan 1
  7111. checkDate.setDate( 1 );
  7112. return Math.floor( Math.round( ( time - checkDate ) / 86400000 ) / 7 ) + 1;
  7113. },
  7114. /* Parse a string value into a date object.
  7115. * See formatDate below for the possible formats.
  7116. *
  7117. * @param format string - the expected format of the date
  7118. * @param value string - the date in the above format
  7119. * @param settings Object - attributes include:
  7120. * shortYearCutoff number - the cutoff year for determining the century (optional)
  7121. * dayNamesShort string[7] - abbreviated names of the days from Sunday (optional)
  7122. * dayNames string[7] - names of the days from Sunday (optional)
  7123. * monthNamesShort string[12] - abbreviated names of the months (optional)
  7124. * monthNames string[12] - names of the months (optional)
  7125. * @return Date - the extracted date value or null if value is blank
  7126. */
  7127. parseDate: function( format, value, settings ) {
  7128. if ( format == null || value == null ) {
  7129. throw "Invalid arguments";
  7130. }
  7131. value = ( typeof value === "object" ? value.toString() : value + "" );
  7132. if ( value === "" ) {
  7133. return null;
  7134. }
  7135. var iFormat, dim, extra,
  7136. iValue = 0,
  7137. shortYearCutoffTemp = ( settings ? settings.shortYearCutoff : null ) || this._defaults.shortYearCutoff,
  7138. shortYearCutoff = ( typeof shortYearCutoffTemp !== "string" ? shortYearCutoffTemp :
  7139. new Date().getFullYear() % 100 + parseInt( shortYearCutoffTemp, 10 ) ),
  7140. dayNamesShort = ( settings ? settings.dayNamesShort : null ) || this._defaults.dayNamesShort,
  7141. dayNames = ( settings ? settings.dayNames : null ) || this._defaults.dayNames,
  7142. monthNamesShort = ( settings ? settings.monthNamesShort : null ) || this._defaults.monthNamesShort,
  7143. monthNames = ( settings ? settings.monthNames : null ) || this._defaults.monthNames,
  7144. year = -1,
  7145. month = -1,
  7146. day = -1,
  7147. doy = -1,
  7148. literal = false,
  7149. date,
  7150. // Check whether a format character is doubled
  7151. lookAhead = function( match ) {
  7152. var matches = ( iFormat + 1 < format.length && format.charAt( iFormat + 1 ) === match );
  7153. if ( matches ) {
  7154. iFormat++;
  7155. }
  7156. return matches;
  7157. },
  7158. // Extract a number from the string value
  7159. getNumber = function( match ) {
  7160. var isDoubled = lookAhead( match ),
  7161. size = ( match === "@" ? 14 : ( match === "!" ? 20 :
  7162. ( match === "y" && isDoubled ? 4 : ( match === "o" ? 3 : 2 ) ) ) ),
  7163. minSize = ( match === "y" ? size : 1 ),
  7164. digits = new RegExp( "^\\d{" + minSize + "," + size + "}" ),
  7165. num = value.substring( iValue ).match( digits );
  7166. if ( !num ) {
  7167. throw "Missing number at position " + iValue;
  7168. }
  7169. iValue += num[ 0 ].length;
  7170. return parseInt( num[ 0 ], 10 );
  7171. },
  7172. // Extract a name from the string value and convert to an index
  7173. getName = function( match, shortNames, longNames ) {
  7174. var index = -1,
  7175. names = $.map( lookAhead( match ) ? longNames : shortNames, function( v, k ) {
  7176. return [ [ k, v ] ];
  7177. } ).sort( function( a, b ) {
  7178. return -( a[ 1 ].length - b[ 1 ].length );
  7179. } );
  7180. $.each( names, function( i, pair ) {
  7181. var name = pair[ 1 ];
  7182. if ( value.substr( iValue, name.length ).toLowerCase() === name.toLowerCase() ) {
  7183. index = pair[ 0 ];
  7184. iValue += name.length;
  7185. return false;
  7186. }
  7187. } );
  7188. if ( index !== -1 ) {
  7189. return index + 1;
  7190. } else {
  7191. throw "Unknown name at position " + iValue;
  7192. }
  7193. },
  7194. // Confirm that a literal character matches the string value
  7195. checkLiteral = function() {
  7196. if ( value.charAt( iValue ) !== format.charAt( iFormat ) ) {
  7197. throw "Unexpected literal at position " + iValue;
  7198. }
  7199. iValue++;
  7200. };
  7201. for ( iFormat = 0; iFormat < format.length; iFormat++ ) {
  7202. if ( literal ) {
  7203. if ( format.charAt( iFormat ) === "'" && !lookAhead( "'" ) ) {
  7204. literal = false;
  7205. } else {
  7206. checkLiteral();
  7207. }
  7208. } else {
  7209. switch ( format.charAt( iFormat ) ) {
  7210. case "d":
  7211. day = getNumber( "d" );
  7212. break;
  7213. case "D":
  7214. getName( "D", dayNamesShort, dayNames );
  7215. break;
  7216. case "o":
  7217. doy = getNumber( "o" );
  7218. break;
  7219. case "m":
  7220. month = getNumber( "m" );
  7221. break;
  7222. case "M":
  7223. month = getName( "M", monthNamesShort, monthNames );
  7224. break;
  7225. case "y":
  7226. year = getNumber( "y" );
  7227. break;
  7228. case "@":
  7229. date = new Date( getNumber( "@" ) );
  7230. year = date.getFullYear();
  7231. month = date.getMonth() + 1;
  7232. day = date.getDate();
  7233. break;
  7234. case "!":
  7235. date = new Date( ( getNumber( "!" ) - this._ticksTo1970 ) / 10000 );
  7236. year = date.getFullYear();
  7237. month = date.getMonth() + 1;
  7238. day = date.getDate();
  7239. break;
  7240. case "'":
  7241. if ( lookAhead( "'" ) ) {
  7242. checkLiteral();
  7243. } else {
  7244. literal = true;
  7245. }
  7246. break;
  7247. default:
  7248. checkLiteral();
  7249. }
  7250. }
  7251. }
  7252. if ( iValue < value.length ) {
  7253. extra = value.substr( iValue );
  7254. if ( !/^\s+/.test( extra ) ) {
  7255. throw "Extra/unparsed characters found in date: " + extra;
  7256. }
  7257. }
  7258. if ( year === -1 ) {
  7259. year = new Date().getFullYear();
  7260. } else if ( year < 100 ) {
  7261. year += new Date().getFullYear() - new Date().getFullYear() % 100 +
  7262. ( year <= shortYearCutoff ? 0 : -100 );
  7263. }
  7264. if ( doy > -1 ) {
  7265. month = 1;
  7266. day = doy;
  7267. do {
  7268. dim = this._getDaysInMonth( year, month - 1 );
  7269. if ( day <= dim ) {
  7270. break;
  7271. }
  7272. month++;
  7273. day -= dim;
  7274. } while ( true );
  7275. }
  7276. date = this._daylightSavingAdjust( new Date( year, month - 1, day ) );
  7277. if ( date.getFullYear() !== year || date.getMonth() + 1 !== month || date.getDate() !== day ) {
  7278. throw "Invalid date"; // E.g. 31/02/00
  7279. }
  7280. return date;
  7281. },
  7282. /* Standard date formats. */
  7283. ATOM: "yy-mm-dd", // RFC 3339 (ISO 8601)
  7284. COOKIE: "D, dd M yy",
  7285. ISO_8601: "yy-mm-dd",
  7286. RFC_822: "D, d M y",
  7287. RFC_850: "DD, dd-M-y",
  7288. RFC_1036: "D, d M y",
  7289. RFC_1123: "D, d M yy",
  7290. RFC_2822: "D, d M yy",
  7291. RSS: "D, d M y", // RFC 822
  7292. TICKS: "!",
  7293. TIMESTAMP: "@",
  7294. W3C: "yy-mm-dd", // ISO 8601
  7295. _ticksTo1970: ( ( ( 1970 - 1 ) * 365 + Math.floor( 1970 / 4 ) - Math.floor( 1970 / 100 ) +
  7296. Math.floor( 1970 / 400 ) ) * 24 * 60 * 60 * 10000000 ),
  7297. /* Format a date object into a string value.
  7298. * The format can be combinations of the following:
  7299. * d - day of month (no leading zero)
  7300. * dd - day of month (two digit)
  7301. * o - day of year (no leading zeros)
  7302. * oo - day of year (three digit)
  7303. * D - day name short
  7304. * DD - day name long
  7305. * m - month of year (no leading zero)
  7306. * mm - month of year (two digit)
  7307. * M - month name short
  7308. * MM - month name long
  7309. * y - year (two digit)
  7310. * yy - year (four digit)
  7311. * @ - Unix timestamp (ms since 01/01/1970)
  7312. * ! - Windows ticks (100ns since 01/01/0001)
  7313. * "..." - literal text
  7314. * '' - single quote
  7315. *
  7316. * @param format string - the desired format of the date
  7317. * @param date Date - the date value to format
  7318. * @param settings Object - attributes include:
  7319. * dayNamesShort string[7] - abbreviated names of the days from Sunday (optional)
  7320. * dayNames string[7] - names of the days from Sunday (optional)
  7321. * monthNamesShort string[12] - abbreviated names of the months (optional)
  7322. * monthNames string[12] - names of the months (optional)
  7323. * @return string - the date in the above format
  7324. */
  7325. formatDate: function( format, date, settings ) {
  7326. if ( !date ) {
  7327. return "";
  7328. }
  7329. var iFormat,
  7330. dayNamesShort = ( settings ? settings.dayNamesShort : null ) || this._defaults.dayNamesShort,
  7331. dayNames = ( settings ? settings.dayNames : null ) || this._defaults.dayNames,
  7332. monthNamesShort = ( settings ? settings.monthNamesShort : null ) || this._defaults.monthNamesShort,
  7333. monthNames = ( settings ? settings.monthNames : null ) || this._defaults.monthNames,
  7334. // Check whether a format character is doubled
  7335. lookAhead = function( match ) {
  7336. var matches = ( iFormat + 1 < format.length && format.charAt( iFormat + 1 ) === match );
  7337. if ( matches ) {
  7338. iFormat++;
  7339. }
  7340. return matches;
  7341. },
  7342. // Format a number, with leading zero if necessary
  7343. formatNumber = function( match, value, len ) {
  7344. var num = "" + value;
  7345. if ( lookAhead( match ) ) {
  7346. while ( num.length < len ) {
  7347. num = "0" + num;
  7348. }
  7349. }
  7350. return num;
  7351. },
  7352. // Format a name, short or long as requested
  7353. formatName = function( match, value, shortNames, longNames ) {
  7354. return ( lookAhead( match ) ? longNames[ value ] : shortNames[ value ] );
  7355. },
  7356. output = "",
  7357. literal = false;
  7358. if ( date ) {
  7359. for ( iFormat = 0; iFormat < format.length; iFormat++ ) {
  7360. if ( literal ) {
  7361. if ( format.charAt( iFormat ) === "'" && !lookAhead( "'" ) ) {
  7362. literal = false;
  7363. } else {
  7364. output += format.charAt( iFormat );
  7365. }
  7366. } else {
  7367. switch ( format.charAt( iFormat ) ) {
  7368. case "d":
  7369. output += formatNumber( "d", date.getDate(), 2 );
  7370. break;
  7371. case "D":
  7372. output += formatName( "D", date.getDay(), dayNamesShort, dayNames );
  7373. break;
  7374. case "o":
  7375. output += formatNumber( "o",
  7376. Math.round( ( new Date( date.getFullYear(), date.getMonth(), date.getDate() ).getTime() - new Date( date.getFullYear(), 0, 0 ).getTime() ) / 86400000 ), 3 );
  7377. break;
  7378. case "m":
  7379. output += formatNumber( "m", date.getMonth() + 1, 2 );
  7380. break;
  7381. case "M":
  7382. output += formatName( "M", date.getMonth(), monthNamesShort, monthNames );
  7383. break;
  7384. case "y":
  7385. output += ( lookAhead( "y" ) ? date.getFullYear() :
  7386. ( date.getFullYear() % 100 < 10 ? "0" : "" ) + date.getFullYear() % 100 );
  7387. break;
  7388. case "@":
  7389. output += date.getTime();
  7390. break;
  7391. case "!":
  7392. output += date.getTime() * 10000 + this._ticksTo1970;
  7393. break;
  7394. case "'":
  7395. if ( lookAhead( "'" ) ) {
  7396. output += "'";
  7397. } else {
  7398. literal = true;
  7399. }
  7400. break;
  7401. default:
  7402. output += format.charAt( iFormat );
  7403. }
  7404. }
  7405. }
  7406. }
  7407. return output;
  7408. },
  7409. /* Extract all possible characters from the date format. */
  7410. _possibleChars: function( format ) {
  7411. var iFormat,
  7412. chars = "",
  7413. literal = false,
  7414. // Check whether a format character is doubled
  7415. lookAhead = function( match ) {
  7416. var matches = ( iFormat + 1 < format.length && format.charAt( iFormat + 1 ) === match );
  7417. if ( matches ) {
  7418. iFormat++;
  7419. }
  7420. return matches;
  7421. };
  7422. for ( iFormat = 0; iFormat < format.length; iFormat++ ) {
  7423. if ( literal ) {
  7424. if ( format.charAt( iFormat ) === "'" && !lookAhead( "'" ) ) {
  7425. literal = false;
  7426. } else {
  7427. chars += format.charAt( iFormat );
  7428. }
  7429. } else {
  7430. switch ( format.charAt( iFormat ) ) {
  7431. case "d": case "m": case "y": case "@":
  7432. chars += "0123456789";
  7433. break;
  7434. case "D": case "M":
  7435. return null; // Accept anything
  7436. case "'":
  7437. if ( lookAhead( "'" ) ) {
  7438. chars += "'";
  7439. } else {
  7440. literal = true;
  7441. }
  7442. break;
  7443. default:
  7444. chars += format.charAt( iFormat );
  7445. }
  7446. }
  7447. }
  7448. return chars;
  7449. },
  7450. /* Get a setting value, defaulting if necessary. */
  7451. _get: function( inst, name ) {
  7452. return inst.settings[ name ] !== undefined ?
  7453. inst.settings[ name ] : this._defaults[ name ];
  7454. },
  7455. /* Parse existing date and initialise date picker. */
  7456. _setDateFromField: function( inst, noDefault ) {
  7457. if ( inst.input.val() === inst.lastVal ) {
  7458. return;
  7459. }
  7460. var dateFormat = this._get( inst, "dateFormat" ),
  7461. dates = inst.lastVal = inst.input ? inst.input.val() : null,
  7462. defaultDate = this._getDefaultDate( inst ),
  7463. date = defaultDate,
  7464. settings = this._getFormatConfig( inst );
  7465. try {
  7466. date = this.parseDate( dateFormat, dates, settings ) || defaultDate;
  7467. } catch ( event ) {
  7468. dates = ( noDefault ? "" : dates );
  7469. }
  7470. inst.selectedDay = date.getDate();
  7471. inst.drawMonth = inst.selectedMonth = date.getMonth();
  7472. inst.drawYear = inst.selectedYear = date.getFullYear();
  7473. inst.currentDay = ( dates ? date.getDate() : 0 );
  7474. inst.currentMonth = ( dates ? date.getMonth() : 0 );
  7475. inst.currentYear = ( dates ? date.getFullYear() : 0 );
  7476. this._adjustInstDate( inst );
  7477. },
  7478. /* Retrieve the default date shown on opening. */
  7479. _getDefaultDate: function( inst ) {
  7480. return this._restrictMinMax( inst,
  7481. this._determineDate( inst, this._get( inst, "defaultDate" ), new Date() ) );
  7482. },
  7483. /* A date may be specified as an exact value or a relative one. */
  7484. _determineDate: function( inst, date, defaultDate ) {
  7485. var offsetNumeric = function( offset ) {
  7486. var date = new Date();
  7487. date.setDate( date.getDate() + offset );
  7488. return date;
  7489. },
  7490. offsetString = function( offset ) {
  7491. try {
  7492. return $.datepicker.parseDate( $.datepicker._get( inst, "dateFormat" ),
  7493. offset, $.datepicker._getFormatConfig( inst ) );
  7494. } catch ( e ) {
  7495. // Ignore
  7496. }
  7497. var date = ( offset.toLowerCase().match( /^c/ ) ?
  7498. $.datepicker._getDate( inst ) : null ) || new Date(),
  7499. year = date.getFullYear(),
  7500. month = date.getMonth(),
  7501. day = date.getDate(),
  7502. pattern = /([+\-]?[0-9]+)\s*(d|D|w|W|m|M|y|Y)?/g,
  7503. matches = pattern.exec( offset );
  7504. while ( matches ) {
  7505. switch ( matches[ 2 ] || "d" ) {
  7506. case "d" : case "D" :
  7507. day += parseInt( matches[ 1 ], 10 ); break;
  7508. case "w" : case "W" :
  7509. day += parseInt( matches[ 1 ], 10 ) * 7; break;
  7510. case "m" : case "M" :
  7511. month += parseInt( matches[ 1 ], 10 );
  7512. day = Math.min( day, $.datepicker._getDaysInMonth( year, month ) );
  7513. break;
  7514. case "y": case "Y" :
  7515. year += parseInt( matches[ 1 ], 10 );
  7516. day = Math.min( day, $.datepicker._getDaysInMonth( year, month ) );
  7517. break;
  7518. }
  7519. matches = pattern.exec( offset );
  7520. }
  7521. return new Date( year, month, day );
  7522. },
  7523. newDate = ( date == null || date === "" ? defaultDate : ( typeof date === "string" ? offsetString( date ) :
  7524. ( typeof date === "number" ? ( isNaN( date ) ? defaultDate : offsetNumeric( date ) ) : new Date( date.getTime() ) ) ) );
  7525. newDate = ( newDate && newDate.toString() === "Invalid Date" ? defaultDate : newDate );
  7526. if ( newDate ) {
  7527. newDate.setHours( 0 );
  7528. newDate.setMinutes( 0 );
  7529. newDate.setSeconds( 0 );
  7530. newDate.setMilliseconds( 0 );
  7531. }
  7532. return this._daylightSavingAdjust( newDate );
  7533. },
  7534. /* Handle switch to/from daylight saving.
  7535. * Hours may be non-zero on daylight saving cut-over:
  7536. * > 12 when midnight changeover, but then cannot generate
  7537. * midnight datetime, so jump to 1AM, otherwise reset.
  7538. * @param date (Date) the date to check
  7539. * @return (Date) the corrected date
  7540. */
  7541. _daylightSavingAdjust: function( date ) {
  7542. if ( !date ) {
  7543. return null;
  7544. }
  7545. date.setHours( date.getHours() > 12 ? date.getHours() + 2 : 0 );
  7546. return date;
  7547. },
  7548. /* Set the date(s) directly. */
  7549. _setDate: function( inst, date, noChange ) {
  7550. var clear = !date,
  7551. origMonth = inst.selectedMonth,
  7552. origYear = inst.selectedYear,
  7553. newDate = this._restrictMinMax( inst, this._determineDate( inst, date, new Date() ) );
  7554. inst.selectedDay = inst.currentDay = newDate.getDate();
  7555. inst.drawMonth = inst.selectedMonth = inst.currentMonth = newDate.getMonth();
  7556. inst.drawYear = inst.selectedYear = inst.currentYear = newDate.getFullYear();
  7557. if ( ( origMonth !== inst.selectedMonth || origYear !== inst.selectedYear ) && !noChange ) {
  7558. this._notifyChange( inst );
  7559. }
  7560. this._adjustInstDate( inst );
  7561. if ( inst.input ) {
  7562. inst.input.val( clear ? "" : this._formatDate( inst ) );
  7563. }
  7564. },
  7565. /* Retrieve the date(s) directly. */
  7566. _getDate: function( inst ) {
  7567. var startDate = ( !inst.currentYear || ( inst.input && inst.input.val() === "" ) ? null :
  7568. this._daylightSavingAdjust( new Date(
  7569. inst.currentYear, inst.currentMonth, inst.currentDay ) ) );
  7570. return startDate;
  7571. },
  7572. /* Attach the onxxx handlers. These are declared statically so
  7573. * they work with static code transformers like Caja.
  7574. */
  7575. _attachHandlers: function( inst ) {
  7576. var stepMonths = this._get( inst, "stepMonths" ),
  7577. id = "#" + inst.id.replace( /\\\\/g, "\\" );
  7578. inst.dpDiv.find( "[data-handler]" ).map( function() {
  7579. var handler = {
  7580. prev: function() {
  7581. $.datepicker._adjustDate( id, -stepMonths, "M" );
  7582. },
  7583. next: function() {
  7584. $.datepicker._adjustDate( id, +stepMonths, "M" );
  7585. },
  7586. hide: function() {
  7587. $.datepicker._hideDatepicker();
  7588. },
  7589. today: function() {
  7590. $.datepicker._gotoToday( id );
  7591. },
  7592. selectDay: function() {
  7593. $.datepicker._selectDay( id, +this.getAttribute( "data-month" ), +this.getAttribute( "data-year" ), this );
  7594. return false;
  7595. },
  7596. selectMonth: function() {
  7597. $.datepicker._selectMonthYear( id, this, "M" );
  7598. return false;
  7599. },
  7600. selectYear: function() {
  7601. $.datepicker._selectMonthYear( id, this, "Y" );
  7602. return false;
  7603. }
  7604. };
  7605. $( this ).on( this.getAttribute( "data-event" ), handler[ this.getAttribute( "data-handler" ) ] );
  7606. } );
  7607. },
  7608. /* Generate the HTML for the current state of the date picker. */
  7609. _generateHTML: function( inst ) {
  7610. var maxDraw, prevText, prev, nextText, next, currentText, gotoDate,
  7611. controls, buttonPanel, firstDay, showWeek, dayNames, dayNamesMin,
  7612. monthNames, monthNamesShort, beforeShowDay, showOtherMonths,
  7613. selectOtherMonths, defaultDate, html, dow, row, group, col, selectedDate,
  7614. cornerClass, calender, thead, day, daysInMonth, leadDays, curRows, numRows,
  7615. printDate, dRow, tbody, daySettings, otherMonth, unselectable,
  7616. tempDate = new Date(),
  7617. today = this._daylightSavingAdjust(
  7618. new Date( tempDate.getFullYear(), tempDate.getMonth(), tempDate.getDate() ) ), // clear time
  7619. isRTL = this._get( inst, "isRTL" ),
  7620. showButtonPanel = this._get( inst, "showButtonPanel" ),
  7621. hideIfNoPrevNext = this._get( inst, "hideIfNoPrevNext" ),
  7622. navigationAsDateFormat = this._get( inst, "navigationAsDateFormat" ),
  7623. numMonths = this._getNumberOfMonths( inst ),
  7624. showCurrentAtPos = this._get( inst, "showCurrentAtPos" ),
  7625. stepMonths = this._get( inst, "stepMonths" ),
  7626. isMultiMonth = ( numMonths[ 0 ] !== 1 || numMonths[ 1 ] !== 1 ),
  7627. currentDate = this._daylightSavingAdjust( ( !inst.currentDay ? new Date( 9999, 9, 9 ) :
  7628. new Date( inst.currentYear, inst.currentMonth, inst.currentDay ) ) ),
  7629. minDate = this._getMinMaxDate( inst, "min" ),
  7630. maxDate = this._getMinMaxDate( inst, "max" ),
  7631. drawMonth = inst.drawMonth - showCurrentAtPos,
  7632. drawYear = inst.drawYear;
  7633. if ( drawMonth < 0 ) {
  7634. drawMonth += 12;
  7635. drawYear--;
  7636. }
  7637. if ( maxDate ) {
  7638. maxDraw = this._daylightSavingAdjust( new Date( maxDate.getFullYear(),
  7639. maxDate.getMonth() - ( numMonths[ 0 ] * numMonths[ 1 ] ) + 1, maxDate.getDate() ) );
  7640. maxDraw = ( minDate && maxDraw < minDate ? minDate : maxDraw );
  7641. while ( this._daylightSavingAdjust( new Date( drawYear, drawMonth, 1 ) ) > maxDraw ) {
  7642. drawMonth--;
  7643. if ( drawMonth < 0 ) {
  7644. drawMonth = 11;
  7645. drawYear--;
  7646. }
  7647. }
  7648. }
  7649. inst.drawMonth = drawMonth;
  7650. inst.drawYear = drawYear;
  7651. prevText = this._get( inst, "prevText" );
  7652. prevText = ( !navigationAsDateFormat ? prevText : this.formatDate( prevText,
  7653. this._daylightSavingAdjust( new Date( drawYear, drawMonth - stepMonths, 1 ) ),
  7654. this._getFormatConfig( inst ) ) );
  7655. if ( this._canAdjustMonth( inst, -1, drawYear, drawMonth ) ) {
  7656. prev = $( "<a>" )
  7657. .attr( {
  7658. "class": "ui-datepicker-prev ui-corner-all",
  7659. "data-handler": "prev",
  7660. "data-event": "click",
  7661. title: prevText
  7662. } )
  7663. .append(
  7664. $( "<span>" )
  7665. .addClass( "ui-icon ui-icon-circle-triangle-" +
  7666. ( isRTL ? "e" : "w" ) )
  7667. .text( prevText )
  7668. )[ 0 ].outerHTML;
  7669. } else if ( hideIfNoPrevNext ) {
  7670. prev = "";
  7671. } else {
  7672. prev = $( "<a>" )
  7673. .attr( {
  7674. "class": "ui-datepicker-prev ui-corner-all ui-state-disabled",
  7675. title: prevText
  7676. } )
  7677. .append(
  7678. $( "<span>" )
  7679. .addClass( "ui-icon ui-icon-circle-triangle-" +
  7680. ( isRTL ? "e" : "w" ) )
  7681. .text( prevText )
  7682. )[ 0 ].outerHTML;
  7683. }
  7684. nextText = this._get( inst, "nextText" );
  7685. nextText = ( !navigationAsDateFormat ? nextText : this.formatDate( nextText,
  7686. this._daylightSavingAdjust( new Date( drawYear, drawMonth + stepMonths, 1 ) ),
  7687. this._getFormatConfig( inst ) ) );
  7688. if ( this._canAdjustMonth( inst, +1, drawYear, drawMonth ) ) {
  7689. next = $( "<a>" )
  7690. .attr( {
  7691. "class": "ui-datepicker-next ui-corner-all",
  7692. "data-handler": "next",
  7693. "data-event": "click",
  7694. title: nextText
  7695. } )
  7696. .append(
  7697. $( "<span>" )
  7698. .addClass( "ui-icon ui-icon-circle-triangle-" +
  7699. ( isRTL ? "w" : "e" ) )
  7700. .text( nextText )
  7701. )[ 0 ].outerHTML;
  7702. } else if ( hideIfNoPrevNext ) {
  7703. next = "";
  7704. } else {
  7705. next = $( "<a>" )
  7706. .attr( {
  7707. "class": "ui-datepicker-next ui-corner-all ui-state-disabled",
  7708. title: nextText
  7709. } )
  7710. .append(
  7711. $( "<span>" )
  7712. .attr( "class", "ui-icon ui-icon-circle-triangle-" +
  7713. ( isRTL ? "w" : "e" ) )
  7714. .text( nextText )
  7715. )[ 0 ].outerHTML;
  7716. }
  7717. currentText = this._get( inst, "currentText" );
  7718. gotoDate = ( this._get( inst, "gotoCurrent" ) && inst.currentDay ? currentDate : today );
  7719. currentText = ( !navigationAsDateFormat ? currentText :
  7720. this.formatDate( currentText, gotoDate, this._getFormatConfig( inst ) ) );
  7721. controls = "";
  7722. if ( !inst.inline ) {
  7723. controls = $( "<button>" )
  7724. .attr( {
  7725. type: "button",
  7726. "class": "ui-datepicker-close ui-state-default ui-priority-primary ui-corner-all",
  7727. "data-handler": "hide",
  7728. "data-event": "click"
  7729. } )
  7730. .text( this._get( inst, "closeText" ) )[ 0 ].outerHTML;
  7731. }
  7732. buttonPanel = "";
  7733. if ( showButtonPanel ) {
  7734. buttonPanel = $( "<div class='ui-datepicker-buttonpane ui-widget-content'>" )
  7735. .append( isRTL ? controls : "" )
  7736. .append( this._isInRange( inst, gotoDate ) ?
  7737. $( "<button>" )
  7738. .attr( {
  7739. type: "button",
  7740. "class": "ui-datepicker-current ui-state-default ui-priority-secondary ui-corner-all",
  7741. "data-handler": "today",
  7742. "data-event": "click"
  7743. } )
  7744. .text( currentText ) :
  7745. "" )
  7746. .append( isRTL ? "" : controls )[ 0 ].outerHTML;
  7747. }
  7748. firstDay = parseInt( this._get( inst, "firstDay" ), 10 );
  7749. firstDay = ( isNaN( firstDay ) ? 0 : firstDay );
  7750. showWeek = this._get( inst, "showWeek" );
  7751. dayNames = this._get( inst, "dayNames" );
  7752. dayNamesMin = this._get( inst, "dayNamesMin" );
  7753. monthNames = this._get( inst, "monthNames" );
  7754. monthNamesShort = this._get( inst, "monthNamesShort" );
  7755. beforeShowDay = this._get( inst, "beforeShowDay" );
  7756. showOtherMonths = this._get( inst, "showOtherMonths" );
  7757. selectOtherMonths = this._get( inst, "selectOtherMonths" );
  7758. defaultDate = this._getDefaultDate( inst );
  7759. html = "";
  7760. for ( row = 0; row < numMonths[ 0 ]; row++ ) {
  7761. group = "";
  7762. this.maxRows = 4;
  7763. for ( col = 0; col < numMonths[ 1 ]; col++ ) {
  7764. selectedDate = this._daylightSavingAdjust( new Date( drawYear, drawMonth, inst.selectedDay ) );
  7765. cornerClass = " ui-corner-all";
  7766. calender = "";
  7767. if ( isMultiMonth ) {
  7768. calender += "<div class='ui-datepicker-group";
  7769. if ( numMonths[ 1 ] > 1 ) {
  7770. switch ( col ) {
  7771. case 0: calender += " ui-datepicker-group-first";
  7772. cornerClass = " ui-corner-" + ( isRTL ? "right" : "left" ); break;
  7773. case numMonths[ 1 ] - 1: calender += " ui-datepicker-group-last";
  7774. cornerClass = " ui-corner-" + ( isRTL ? "left" : "right" ); break;
  7775. default: calender += " ui-datepicker-group-middle"; cornerClass = ""; break;
  7776. }
  7777. }
  7778. calender += "'>";
  7779. }
  7780. calender += "<div class='ui-datepicker-header ui-widget-header ui-helper-clearfix" + cornerClass + "'>" +
  7781. ( /all|left/.test( cornerClass ) && row === 0 ? ( isRTL ? next : prev ) : "" ) +
  7782. ( /all|right/.test( cornerClass ) && row === 0 ? ( isRTL ? prev : next ) : "" ) +
  7783. this._generateMonthYearHeader( inst, drawMonth, drawYear, minDate, maxDate,
  7784. row > 0 || col > 0, monthNames, monthNamesShort ) + // draw month headers
  7785. "</div><table class='ui-datepicker-calendar'><thead>" +
  7786. "<tr>";
  7787. thead = ( showWeek ? "<th class='ui-datepicker-week-col'>" + this._get( inst, "weekHeader" ) + "</th>" : "" );
  7788. for ( dow = 0; dow < 7; dow++ ) { // days of the week
  7789. day = ( dow + firstDay ) % 7;
  7790. thead += "<th scope='col'" + ( ( dow + firstDay + 6 ) % 7 >= 5 ? " class='ui-datepicker-week-end'" : "" ) + ">" +
  7791. "<span title='" + dayNames[ day ] + "'>" + dayNamesMin[ day ] + "</span></th>";
  7792. }
  7793. calender += thead + "</tr></thead><tbody>";
  7794. daysInMonth = this._getDaysInMonth( drawYear, drawMonth );
  7795. if ( drawYear === inst.selectedYear && drawMonth === inst.selectedMonth ) {
  7796. inst.selectedDay = Math.min( inst.selectedDay, daysInMonth );
  7797. }
  7798. leadDays = ( this._getFirstDayOfMonth( drawYear, drawMonth ) - firstDay + 7 ) % 7;
  7799. curRows = Math.ceil( ( leadDays + daysInMonth ) / 7 ); // calculate the number of rows to generate
  7800. numRows = ( isMultiMonth ? this.maxRows > curRows ? this.maxRows : curRows : curRows ); //If multiple months, use the higher number of rows (see #7043)
  7801. this.maxRows = numRows;
  7802. printDate = this._daylightSavingAdjust( new Date( drawYear, drawMonth, 1 - leadDays ) );
  7803. for ( dRow = 0; dRow < numRows; dRow++ ) { // create date picker rows
  7804. calender += "<tr>";
  7805. tbody = ( !showWeek ? "" : "<td class='ui-datepicker-week-col'>" +
  7806. this._get( inst, "calculateWeek" )( printDate ) + "</td>" );
  7807. for ( dow = 0; dow < 7; dow++ ) { // create date picker days
  7808. daySettings = ( beforeShowDay ?
  7809. beforeShowDay.apply( ( inst.input ? inst.input[ 0 ] : null ), [ printDate ] ) : [ true, "" ] );
  7810. otherMonth = ( printDate.getMonth() !== drawMonth );
  7811. unselectable = ( otherMonth && !selectOtherMonths ) || !daySettings[ 0 ] ||
  7812. ( minDate && printDate < minDate ) || ( maxDate && printDate > maxDate );
  7813. tbody += "<td class='" +
  7814. ( ( dow + firstDay + 6 ) % 7 >= 5 ? " ui-datepicker-week-end" : "" ) + // highlight weekends
  7815. ( otherMonth ? " ui-datepicker-other-month" : "" ) + // highlight days from other months
  7816. ( ( printDate.getTime() === selectedDate.getTime() && drawMonth === inst.selectedMonth && inst._keyEvent ) || // user pressed key
  7817. ( defaultDate.getTime() === printDate.getTime() && defaultDate.getTime() === selectedDate.getTime() ) ?
  7818. // or defaultDate is current printedDate and defaultDate is selectedDate
  7819. " " + this._dayOverClass : "" ) + // highlight selected day
  7820. ( unselectable ? " " + this._unselectableClass + " ui-state-disabled" : "" ) + // highlight unselectable days
  7821. ( otherMonth && !showOtherMonths ? "" : " " + daySettings[ 1 ] + // highlight custom dates
  7822. ( printDate.getTime() === currentDate.getTime() ? " " + this._currentClass : "" ) + // highlight selected day
  7823. ( printDate.getTime() === today.getTime() ? " ui-datepicker-today" : "" ) ) + "'" + // highlight today (if different)
  7824. ( ( !otherMonth || showOtherMonths ) && daySettings[ 2 ] ? " title='" + daySettings[ 2 ].replace( /'/g, "&#39;" ) + "'" : "" ) + // cell title
  7825. ( unselectable ? "" : " data-handler='selectDay' data-event='click' data-month='" + printDate.getMonth() + "' data-year='" + printDate.getFullYear() + "'" ) + ">" + // actions
  7826. ( otherMonth && !showOtherMonths ? "&#xa0;" : // display for other months
  7827. ( unselectable ? "<span class='ui-state-default'>" + printDate.getDate() + "</span>" : "<a class='ui-state-default" +
  7828. ( printDate.getTime() === today.getTime() ? " ui-state-highlight" : "" ) +
  7829. ( printDate.getTime() === currentDate.getTime() ? " ui-state-active" : "" ) + // highlight selected day
  7830. ( otherMonth ? " ui-priority-secondary" : "" ) + // distinguish dates from other months
  7831. "' href='#' aria-current='" + ( printDate.getTime() === currentDate.getTime() ? "true" : "false" ) + // mark date as selected for screen reader
  7832. "' data-date='" + printDate.getDate() + // store date as data
  7833. "'>" + printDate.getDate() + "</a>" ) ) + "</td>"; // display selectable date
  7834. printDate.setDate( printDate.getDate() + 1 );
  7835. printDate = this._daylightSavingAdjust( printDate );
  7836. }
  7837. calender += tbody + "</tr>";
  7838. }
  7839. drawMonth++;
  7840. if ( drawMonth > 11 ) {
  7841. drawMonth = 0;
  7842. drawYear++;
  7843. }
  7844. calender += "</tbody></table>" + ( isMultiMonth ? "</div>" +
  7845. ( ( numMonths[ 0 ] > 0 && col === numMonths[ 1 ] - 1 ) ? "<div class='ui-datepicker-row-break'></div>" : "" ) : "" );
  7846. group += calender;
  7847. }
  7848. html += group;
  7849. }
  7850. html += buttonPanel;
  7851. inst._keyEvent = false;
  7852. return html;
  7853. },
  7854. /* Generate the month and year header. */
  7855. _generateMonthYearHeader: function( inst, drawMonth, drawYear, minDate, maxDate,
  7856. secondary, monthNames, monthNamesShort ) {
  7857. var inMinYear, inMaxYear, month, years, thisYear, determineYear, year, endYear,
  7858. changeMonth = this._get( inst, "changeMonth" ),
  7859. changeYear = this._get( inst, "changeYear" ),
  7860. showMonthAfterYear = this._get( inst, "showMonthAfterYear" ),
  7861. selectMonthLabel = this._get( inst, "selectMonthLabel" ),
  7862. selectYearLabel = this._get( inst, "selectYearLabel" ),
  7863. html = "<div class='ui-datepicker-title'>",
  7864. monthHtml = "";
  7865. // Month selection
  7866. if ( secondary || !changeMonth ) {
  7867. monthHtml += "<span class='ui-datepicker-month'>" + monthNames[ drawMonth ] + "</span>";
  7868. } else {
  7869. inMinYear = ( minDate && minDate.getFullYear() === drawYear );
  7870. inMaxYear = ( maxDate && maxDate.getFullYear() === drawYear );
  7871. monthHtml += "<select class='ui-datepicker-month' aria-label='" + selectMonthLabel + "' data-handler='selectMonth' data-event='change'>";
  7872. for ( month = 0; month < 12; month++ ) {
  7873. if ( ( !inMinYear || month >= minDate.getMonth() ) && ( !inMaxYear || month <= maxDate.getMonth() ) ) {
  7874. monthHtml += "<option value='" + month + "'" +
  7875. ( month === drawMonth ? " selected='selected'" : "" ) +
  7876. ">" + monthNamesShort[ month ] + "</option>";
  7877. }
  7878. }
  7879. monthHtml += "</select>";
  7880. }
  7881. if ( !showMonthAfterYear ) {
  7882. html += monthHtml + ( secondary || !( changeMonth && changeYear ) ? "&#xa0;" : "" );
  7883. }
  7884. // Year selection
  7885. if ( !inst.yearshtml ) {
  7886. inst.yearshtml = "";
  7887. if ( secondary || !changeYear ) {
  7888. html += "<span class='ui-datepicker-year'>" + drawYear + "</span>";
  7889. } else {
  7890. // determine range of years to display
  7891. years = this._get( inst, "yearRange" ).split( ":" );
  7892. thisYear = new Date().getFullYear();
  7893. determineYear = function( value ) {
  7894. var year = ( value.match( /c[+\-].*/ ) ? drawYear + parseInt( value.substring( 1 ), 10 ) :
  7895. ( value.match( /[+\-].*/ ) ? thisYear + parseInt( value, 10 ) :
  7896. parseInt( value, 10 ) ) );
  7897. return ( isNaN( year ) ? thisYear : year );
  7898. };
  7899. year = determineYear( years[ 0 ] );
  7900. endYear = Math.max( year, determineYear( years[ 1 ] || "" ) );
  7901. year = ( minDate ? Math.max( year, minDate.getFullYear() ) : year );
  7902. endYear = ( maxDate ? Math.min( endYear, maxDate.getFullYear() ) : endYear );
  7903. inst.yearshtml += "<select class='ui-datepicker-year' aria-label='" + selectYearLabel + "' data-handler='selectYear' data-event='change'>";
  7904. for ( ; year <= endYear; year++ ) {
  7905. inst.yearshtml += "<option value='" + year + "'" +
  7906. ( year === drawYear ? " selected='selected'" : "" ) +
  7907. ">" + year + "</option>";
  7908. }
  7909. inst.yearshtml += "</select>";
  7910. html += inst.yearshtml;
  7911. inst.yearshtml = null;
  7912. }
  7913. }
  7914. html += this._get( inst, "yearSuffix" );
  7915. if ( showMonthAfterYear ) {
  7916. html += ( secondary || !( changeMonth && changeYear ) ? "&#xa0;" : "" ) + monthHtml;
  7917. }
  7918. html += "</div>"; // Close datepicker_header
  7919. return html;
  7920. },
  7921. /* Adjust one of the date sub-fields. */
  7922. _adjustInstDate: function( inst, offset, period ) {
  7923. var year = inst.selectedYear + ( period === "Y" ? offset : 0 ),
  7924. month = inst.selectedMonth + ( period === "M" ? offset : 0 ),
  7925. day = Math.min( inst.selectedDay, this._getDaysInMonth( year, month ) ) + ( period === "D" ? offset : 0 ),
  7926. date = this._restrictMinMax( inst, this._daylightSavingAdjust( new Date( year, month, day ) ) );
  7927. inst.selectedDay = date.getDate();
  7928. inst.drawMonth = inst.selectedMonth = date.getMonth();
  7929. inst.drawYear = inst.selectedYear = date.getFullYear();
  7930. if ( period === "M" || period === "Y" ) {
  7931. this._notifyChange( inst );
  7932. }
  7933. },
  7934. /* Ensure a date is within any min/max bounds. */
  7935. _restrictMinMax: function( inst, date ) {
  7936. var minDate = this._getMinMaxDate( inst, "min" ),
  7937. maxDate = this._getMinMaxDate( inst, "max" ),
  7938. newDate = ( minDate && date < minDate ? minDate : date );
  7939. return ( maxDate && newDate > maxDate ? maxDate : newDate );
  7940. },
  7941. /* Notify change of month/year. */
  7942. _notifyChange: function( inst ) {
  7943. var onChange = this._get( inst, "onChangeMonthYear" );
  7944. if ( onChange ) {
  7945. onChange.apply( ( inst.input ? inst.input[ 0 ] : null ),
  7946. [ inst.selectedYear, inst.selectedMonth + 1, inst ] );
  7947. }
  7948. },
  7949. /* Determine the number of months to show. */
  7950. _getNumberOfMonths: function( inst ) {
  7951. var numMonths = this._get( inst, "numberOfMonths" );
  7952. return ( numMonths == null ? [ 1, 1 ] : ( typeof numMonths === "number" ? [ 1, numMonths ] : numMonths ) );
  7953. },
  7954. /* Determine the current maximum date - ensure no time components are set. */
  7955. _getMinMaxDate: function( inst, minMax ) {
  7956. return this._determineDate( inst, this._get( inst, minMax + "Date" ), null );
  7957. },
  7958. /* Find the number of days in a given month. */
  7959. _getDaysInMonth: function( year, month ) {
  7960. return 32 - this._daylightSavingAdjust( new Date( year, month, 32 ) ).getDate();
  7961. },
  7962. /* Find the day of the week of the first of a month. */
  7963. _getFirstDayOfMonth: function( year, month ) {
  7964. return new Date( year, month, 1 ).getDay();
  7965. },
  7966. /* Determines if we should allow a "next/prev" month display change. */
  7967. _canAdjustMonth: function( inst, offset, curYear, curMonth ) {
  7968. var numMonths = this._getNumberOfMonths( inst ),
  7969. date = this._daylightSavingAdjust( new Date( curYear,
  7970. curMonth + ( offset < 0 ? offset : numMonths[ 0 ] * numMonths[ 1 ] ), 1 ) );
  7971. if ( offset < 0 ) {
  7972. date.setDate( this._getDaysInMonth( date.getFullYear(), date.getMonth() ) );
  7973. }
  7974. return this._isInRange( inst, date );
  7975. },
  7976. /* Is the given date in the accepted range? */
  7977. _isInRange: function( inst, date ) {
  7978. var yearSplit, currentYear,
  7979. minDate = this._getMinMaxDate( inst, "min" ),
  7980. maxDate = this._getMinMaxDate( inst, "max" ),
  7981. minYear = null,
  7982. maxYear = null,
  7983. years = this._get( inst, "yearRange" );
  7984. if ( years ) {
  7985. yearSplit = years.split( ":" );
  7986. currentYear = new Date().getFullYear();
  7987. minYear = parseInt( yearSplit[ 0 ], 10 );
  7988. maxYear = parseInt( yearSplit[ 1 ], 10 );
  7989. if ( yearSplit[ 0 ].match( /[+\-].*/ ) ) {
  7990. minYear += currentYear;
  7991. }
  7992. if ( yearSplit[ 1 ].match( /[+\-].*/ ) ) {
  7993. maxYear += currentYear;
  7994. }
  7995. }
  7996. return ( ( !minDate || date.getTime() >= minDate.getTime() ) &&
  7997. ( !maxDate || date.getTime() <= maxDate.getTime() ) &&
  7998. ( !minYear || date.getFullYear() >= minYear ) &&
  7999. ( !maxYear || date.getFullYear() <= maxYear ) );
  8000. },
  8001. /* Provide the configuration settings for formatting/parsing. */
  8002. _getFormatConfig: function( inst ) {
  8003. var shortYearCutoff = this._get( inst, "shortYearCutoff" );
  8004. shortYearCutoff = ( typeof shortYearCutoff !== "string" ? shortYearCutoff :
  8005. new Date().getFullYear() % 100 + parseInt( shortYearCutoff, 10 ) );
  8006. return { shortYearCutoff: shortYearCutoff,
  8007. dayNamesShort: this._get( inst, "dayNamesShort" ), dayNames: this._get( inst, "dayNames" ),
  8008. monthNamesShort: this._get( inst, "monthNamesShort" ), monthNames: this._get( inst, "monthNames" ) };
  8009. },
  8010. /* Format the given date for display. */
  8011. _formatDate: function( inst, day, month, year ) {
  8012. if ( !day ) {
  8013. inst.currentDay = inst.selectedDay;
  8014. inst.currentMonth = inst.selectedMonth;
  8015. inst.currentYear = inst.selectedYear;
  8016. }
  8017. var date = ( day ? ( typeof day === "object" ? day :
  8018. this._daylightSavingAdjust( new Date( year, month, day ) ) ) :
  8019. this._daylightSavingAdjust( new Date( inst.currentYear, inst.currentMonth, inst.currentDay ) ) );
  8020. return this.formatDate( this._get( inst, "dateFormat" ), date, this._getFormatConfig( inst ) );
  8021. }
  8022. } );
  8023. /*
  8024. * Bind hover events for datepicker elements.
  8025. * Done via delegate so the binding only occurs once in the lifetime of the parent div.
  8026. * Global datepicker_instActive, set by _updateDatepicker allows the handlers to find their way back to the active picker.
  8027. */
  8028. function datepicker_bindHover( dpDiv ) {
  8029. var selector = "button, .ui-datepicker-prev, .ui-datepicker-next, .ui-datepicker-calendar td a";
  8030. return dpDiv.on( "mouseout", selector, function() {
  8031. $( this ).removeClass( "ui-state-hover" );
  8032. if ( this.className.indexOf( "ui-datepicker-prev" ) !== -1 ) {
  8033. $( this ).removeClass( "ui-datepicker-prev-hover" );
  8034. }
  8035. if ( this.className.indexOf( "ui-datepicker-next" ) !== -1 ) {
  8036. $( this ).removeClass( "ui-datepicker-next-hover" );
  8037. }
  8038. } )
  8039. .on( "mouseover", selector, datepicker_handleMouseover );
  8040. }
  8041. function datepicker_handleMouseover() {
  8042. if ( !$.datepicker._isDisabledDatepicker( datepicker_instActive.inline ? datepicker_instActive.dpDiv.parent()[ 0 ] : datepicker_instActive.input[ 0 ] ) ) {
  8043. $( this ).parents( ".ui-datepicker-calendar" ).find( "a" ).removeClass( "ui-state-hover" );
  8044. $( this ).addClass( "ui-state-hover" );
  8045. if ( this.className.indexOf( "ui-datepicker-prev" ) !== -1 ) {
  8046. $( this ).addClass( "ui-datepicker-prev-hover" );
  8047. }
  8048. if ( this.className.indexOf( "ui-datepicker-next" ) !== -1 ) {
  8049. $( this ).addClass( "ui-datepicker-next-hover" );
  8050. }
  8051. }
  8052. }
  8053. /* jQuery extend now ignores nulls! */
  8054. function datepicker_extendRemove( target, props ) {
  8055. $.extend( target, props );
  8056. for ( var name in props ) {
  8057. if ( props[ name ] == null ) {
  8058. target[ name ] = props[ name ];
  8059. }
  8060. }
  8061. return target;
  8062. }
  8063. /* Invoke the datepicker functionality.
  8064. @param options string - a command, optionally followed by additional parameters or
  8065. Object - settings for attaching new datepicker functionality
  8066. @return jQuery object */
  8067. $.fn.datepicker = function( options ) {
  8068. /* Verify an empty collection wasn't passed - Fixes #6976 */
  8069. if ( !this.length ) {
  8070. return this;
  8071. }
  8072. /* Initialise the date picker. */
  8073. if ( !$.datepicker.initialized ) {
  8074. $( document ).on( "mousedown", $.datepicker._checkExternalClick );
  8075. $.datepicker.initialized = true;
  8076. }
  8077. /* Append datepicker main container to body if not exist. */
  8078. if ( $( "#" + $.datepicker._mainDivId ).length === 0 ) {
  8079. $( "body" ).append( $.datepicker.dpDiv );
  8080. }
  8081. var otherArgs = Array.prototype.slice.call( arguments, 1 );
  8082. if ( typeof options === "string" && ( options === "isDisabled" || options === "getDate" || options === "widget" ) ) {
  8083. return $.datepicker[ "_" + options + "Datepicker" ].
  8084. apply( $.datepicker, [ this[ 0 ] ].concat( otherArgs ) );
  8085. }
  8086. if ( options === "option" && arguments.length === 2 && typeof arguments[ 1 ] === "string" ) {
  8087. return $.datepicker[ "_" + options + "Datepicker" ].
  8088. apply( $.datepicker, [ this[ 0 ] ].concat( otherArgs ) );
  8089. }
  8090. return this.each( function() {
  8091. if ( typeof options === "string" ) {
  8092. $.datepicker[ "_" + options + "Datepicker" ]
  8093. .apply( $.datepicker, [ this ].concat( otherArgs ) );
  8094. } else {
  8095. $.datepicker._attachDatepicker( this, options );
  8096. }
  8097. } );
  8098. };
  8099. $.datepicker = new Datepicker(); // singleton instance
  8100. $.datepicker.initialized = false;
  8101. $.datepicker.uuid = new Date().getTime();
  8102. $.datepicker.version = "1.13.2";
  8103. var widgetsDatepicker = $.datepicker;
  8104. // This file is deprecated
  8105. var ie = $.ui.ie = !!/msie [\w.]+/.exec( navigator.userAgent.toLowerCase() );
  8106. /*!
  8107. * jQuery UI Mouse 1.13.2
  8108. * http://jqueryui.com
  8109. *
  8110. * Copyright jQuery Foundation and other contributors
  8111. * Released under the MIT license.
  8112. * http://jquery.org/license
  8113. */
  8114. //>>label: Mouse
  8115. //>>group: Widgets
  8116. //>>description: Abstracts mouse-based interactions to assist in creating certain widgets.
  8117. //>>docs: http://api.jqueryui.com/mouse/
  8118. var mouseHandled = false;
  8119. $( document ).on( "mouseup", function() {
  8120. mouseHandled = false;
  8121. } );
  8122. var widgetsMouse = $.widget( "ui.mouse", {
  8123. version: "1.13.2",
  8124. options: {
  8125. cancel: "input, textarea, button, select, option",
  8126. distance: 1,
  8127. delay: 0
  8128. },
  8129. _mouseInit: function() {
  8130. var that = this;
  8131. this.element
  8132. .on( "mousedown." + this.widgetName, function( event ) {
  8133. return that._mouseDown( event );
  8134. } )
  8135. .on( "click." + this.widgetName, function( event ) {
  8136. if ( true === $.data( event.target, that.widgetName + ".preventClickEvent" ) ) {
  8137. $.removeData( event.target, that.widgetName + ".preventClickEvent" );
  8138. event.stopImmediatePropagation();
  8139. return false;
  8140. }
  8141. } );
  8142. this.started = false;
  8143. },
  8144. // TODO: make sure destroying one instance of mouse doesn't mess with
  8145. // other instances of mouse
  8146. _mouseDestroy: function() {
  8147. this.element.off( "." + this.widgetName );
  8148. if ( this._mouseMoveDelegate ) {
  8149. this.document
  8150. .off( "mousemove." + this.widgetName, this._mouseMoveDelegate )
  8151. .off( "mouseup." + this.widgetName, this._mouseUpDelegate );
  8152. }
  8153. },
  8154. _mouseDown: function( event ) {
  8155. // don't let more than one widget handle mouseStart
  8156. if ( mouseHandled ) {
  8157. return;
  8158. }
  8159. this._mouseMoved = false;
  8160. // We may have missed mouseup (out of window)
  8161. if ( this._mouseStarted ) {
  8162. this._mouseUp( event );
  8163. }
  8164. this._mouseDownEvent = event;
  8165. var that = this,
  8166. btnIsLeft = ( event.which === 1 ),
  8167. // event.target.nodeName works around a bug in IE 8 with
  8168. // disabled inputs (#7620)
  8169. elIsCancel = ( typeof this.options.cancel === "string" && event.target.nodeName ?
  8170. $( event.target ).closest( this.options.cancel ).length : false );
  8171. if ( !btnIsLeft || elIsCancel || !this._mouseCapture( event ) ) {
  8172. return true;
  8173. }
  8174. this.mouseDelayMet = !this.options.delay;
  8175. if ( !this.mouseDelayMet ) {
  8176. this._mouseDelayTimer = setTimeout( function() {
  8177. that.mouseDelayMet = true;
  8178. }, this.options.delay );
  8179. }
  8180. if ( this._mouseDistanceMet( event ) && this._mouseDelayMet( event ) ) {
  8181. this._mouseStarted = ( this._mouseStart( event ) !== false );
  8182. if ( !this._mouseStarted ) {
  8183. event.preventDefault();
  8184. return true;
  8185. }
  8186. }
  8187. // Click event may never have fired (Gecko & Opera)
  8188. if ( true === $.data( event.target, this.widgetName + ".preventClickEvent" ) ) {
  8189. $.removeData( event.target, this.widgetName + ".preventClickEvent" );
  8190. }
  8191. // These delegates are required to keep context
  8192. this._mouseMoveDelegate = function( event ) {
  8193. return that._mouseMove( event );
  8194. };
  8195. this._mouseUpDelegate = function( event ) {
  8196. return that._mouseUp( event );
  8197. };
  8198. this.document
  8199. .on( "mousemove." + this.widgetName, this._mouseMoveDelegate )
  8200. .on( "mouseup." + this.widgetName, this._mouseUpDelegate );
  8201. event.preventDefault();
  8202. mouseHandled = true;
  8203. return true;
  8204. },
  8205. _mouseMove: function( event ) {
  8206. // Only check for mouseups outside the document if you've moved inside the document
  8207. // at least once. This prevents the firing of mouseup in the case of IE<9, which will
  8208. // fire a mousemove event if content is placed under the cursor. See #7778
  8209. // Support: IE <9
  8210. if ( this._mouseMoved ) {
  8211. // IE mouseup check - mouseup happened when mouse was out of window
  8212. if ( $.ui.ie && ( !document.documentMode || document.documentMode < 9 ) &&
  8213. !event.button ) {
  8214. return this._mouseUp( event );
  8215. // Iframe mouseup check - mouseup occurred in another document
  8216. } else if ( !event.which ) {
  8217. // Support: Safari <=8 - 9
  8218. // Safari sets which to 0 if you press any of the following keys
  8219. // during a drag (#14461)
  8220. if ( event.originalEvent.altKey || event.originalEvent.ctrlKey ||
  8221. event.originalEvent.metaKey || event.originalEvent.shiftKey ) {
  8222. this.ignoreMissingWhich = true;
  8223. } else if ( !this.ignoreMissingWhich ) {
  8224. return this._mouseUp( event );
  8225. }
  8226. }
  8227. }
  8228. if ( event.which || event.button ) {
  8229. this._mouseMoved = true;
  8230. }
  8231. if ( this._mouseStarted ) {
  8232. this._mouseDrag( event );
  8233. return event.preventDefault();
  8234. }
  8235. if ( this._mouseDistanceMet( event ) && this._mouseDelayMet( event ) ) {
  8236. this._mouseStarted =
  8237. ( this._mouseStart( this._mouseDownEvent, event ) !== false );
  8238. if ( this._mouseStarted ) {
  8239. this._mouseDrag( event );
  8240. } else {
  8241. this._mouseUp( event );
  8242. }
  8243. }
  8244. return !this._mouseStarted;
  8245. },
  8246. _mouseUp: function( event ) {
  8247. this.document
  8248. .off( "mousemove." + this.widgetName, this._mouseMoveDelegate )
  8249. .off( "mouseup." + this.widgetName, this._mouseUpDelegate );
  8250. if ( this._mouseStarted ) {
  8251. this._mouseStarted = false;
  8252. if ( event.target === this._mouseDownEvent.target ) {
  8253. $.data( event.target, this.widgetName + ".preventClickEvent", true );
  8254. }
  8255. this._mouseStop( event );
  8256. }
  8257. if ( this._mouseDelayTimer ) {
  8258. clearTimeout( this._mouseDelayTimer );
  8259. delete this._mouseDelayTimer;
  8260. }
  8261. this.ignoreMissingWhich = false;
  8262. mouseHandled = false;
  8263. event.preventDefault();
  8264. },
  8265. _mouseDistanceMet: function( event ) {
  8266. return ( Math.max(
  8267. Math.abs( this._mouseDownEvent.pageX - event.pageX ),
  8268. Math.abs( this._mouseDownEvent.pageY - event.pageY )
  8269. ) >= this.options.distance
  8270. );
  8271. },
  8272. _mouseDelayMet: function( /* event */ ) {
  8273. return this.mouseDelayMet;
  8274. },
  8275. // These are placeholder methods, to be overriden by extending plugin
  8276. _mouseStart: function( /* event */ ) {},
  8277. _mouseDrag: function( /* event */ ) {},
  8278. _mouseStop: function( /* event */ ) {},
  8279. _mouseCapture: function( /* event */ ) {
  8280. return true;
  8281. }
  8282. } );
  8283. // $.ui.plugin is deprecated. Use $.widget() extensions instead.
  8284. var plugin = $.ui.plugin = {
  8285. add: function( module, option, set ) {
  8286. var i,
  8287. proto = $.ui[ module ].prototype;
  8288. for ( i in set ) {
  8289. proto.plugins[ i ] = proto.plugins[ i ] || [];
  8290. proto.plugins[ i ].push( [ option, set[ i ] ] );
  8291. }
  8292. },
  8293. call: function( instance, name, args, allowDisconnected ) {
  8294. var i,
  8295. set = instance.plugins[ name ];
  8296. if ( !set ) {
  8297. return;
  8298. }
  8299. if ( !allowDisconnected && ( !instance.element[ 0 ].parentNode ||
  8300. instance.element[ 0 ].parentNode.nodeType === 11 ) ) {
  8301. return;
  8302. }
  8303. for ( i = 0; i < set.length; i++ ) {
  8304. if ( instance.options[ set[ i ][ 0 ] ] ) {
  8305. set[ i ][ 1 ].apply( instance.element, args );
  8306. }
  8307. }
  8308. }
  8309. };
  8310. var safeBlur = $.ui.safeBlur = function( element ) {
  8311. // Support: IE9 - 10 only
  8312. // If the <body> is blurred, IE will switch windows, see #9420
  8313. if ( element && element.nodeName.toLowerCase() !== "body" ) {
  8314. $( element ).trigger( "blur" );
  8315. }
  8316. };
  8317. /*!
  8318. * jQuery UI Draggable 1.13.2
  8319. * http://jqueryui.com
  8320. *
  8321. * Copyright jQuery Foundation and other contributors
  8322. * Released under the MIT license.
  8323. * http://jquery.org/license
  8324. */
  8325. //>>label: Draggable
  8326. //>>group: Interactions
  8327. //>>description: Enables dragging functionality for any element.
  8328. //>>docs: http://api.jqueryui.com/draggable/
  8329. //>>demos: http://jqueryui.com/draggable/
  8330. //>>css.structure: ../../themes/base/draggable.css
  8331. $.widget( "ui.draggable", $.ui.mouse, {
  8332. version: "1.13.2",
  8333. widgetEventPrefix: "drag",
  8334. options: {
  8335. addClasses: true,
  8336. appendTo: "parent",
  8337. axis: false,
  8338. connectToSortable: false,
  8339. containment: false,
  8340. cursor: "auto",
  8341. cursorAt: false,
  8342. grid: false,
  8343. handle: false,
  8344. helper: "original",
  8345. iframeFix: false,
  8346. opacity: false,
  8347. refreshPositions: false,
  8348. revert: false,
  8349. revertDuration: 500,
  8350. scope: "default",
  8351. scroll: true,
  8352. scrollSensitivity: 20,
  8353. scrollSpeed: 20,
  8354. snap: false,
  8355. snapMode: "both",
  8356. snapTolerance: 20,
  8357. stack: false,
  8358. zIndex: false,
  8359. // Callbacks
  8360. drag: null,
  8361. start: null,
  8362. stop: null
  8363. },
  8364. _create: function() {
  8365. if ( this.options.helper === "original" ) {
  8366. this._setPositionRelative();
  8367. }
  8368. if ( this.options.addClasses ) {
  8369. this._addClass( "ui-draggable" );
  8370. }
  8371. this._setHandleClassName();
  8372. this._mouseInit();
  8373. },
  8374. _setOption: function( key, value ) {
  8375. this._super( key, value );
  8376. if ( key === "handle" ) {
  8377. this._removeHandleClassName();
  8378. this._setHandleClassName();
  8379. }
  8380. },
  8381. _destroy: function() {
  8382. if ( ( this.helper || this.element ).is( ".ui-draggable-dragging" ) ) {
  8383. this.destroyOnClear = true;
  8384. return;
  8385. }
  8386. this._removeHandleClassName();
  8387. this._mouseDestroy();
  8388. },
  8389. _mouseCapture: function( event ) {
  8390. var o = this.options;
  8391. // Among others, prevent a drag on a resizable-handle
  8392. if ( this.helper || o.disabled ||
  8393. $( event.target ).closest( ".ui-resizable-handle" ).length > 0 ) {
  8394. return false;
  8395. }
  8396. //Quit if we're not on a valid handle
  8397. this.handle = this._getHandle( event );
  8398. if ( !this.handle ) {
  8399. return false;
  8400. }
  8401. this._blurActiveElement( event );
  8402. this._blockFrames( o.iframeFix === true ? "iframe" : o.iframeFix );
  8403. return true;
  8404. },
  8405. _blockFrames: function( selector ) {
  8406. this.iframeBlocks = this.document.find( selector ).map( function() {
  8407. var iframe = $( this );
  8408. return $( "<div>" )
  8409. .css( "position", "absolute" )
  8410. .appendTo( iframe.parent() )
  8411. .outerWidth( iframe.outerWidth() )
  8412. .outerHeight( iframe.outerHeight() )
  8413. .offset( iframe.offset() )[ 0 ];
  8414. } );
  8415. },
  8416. _unblockFrames: function() {
  8417. if ( this.iframeBlocks ) {
  8418. this.iframeBlocks.remove();
  8419. delete this.iframeBlocks;
  8420. }
  8421. },
  8422. _blurActiveElement: function( event ) {
  8423. var activeElement = $.ui.safeActiveElement( this.document[ 0 ] ),
  8424. target = $( event.target );
  8425. // Don't blur if the event occurred on an element that is within
  8426. // the currently focused element
  8427. // See #10527, #12472
  8428. if ( target.closest( activeElement ).length ) {
  8429. return;
  8430. }
  8431. // Blur any element that currently has focus, see #4261
  8432. $.ui.safeBlur( activeElement );
  8433. },
  8434. _mouseStart: function( event ) {
  8435. var o = this.options;
  8436. //Create and append the visible helper
  8437. this.helper = this._createHelper( event );
  8438. this._addClass( this.helper, "ui-draggable-dragging" );
  8439. //Cache the helper size
  8440. this._cacheHelperProportions();
  8441. //If ddmanager is used for droppables, set the global draggable
  8442. if ( $.ui.ddmanager ) {
  8443. $.ui.ddmanager.current = this;
  8444. }
  8445. /*
  8446. * - Position generation -
  8447. * This block generates everything position related - it's the core of draggables.
  8448. */
  8449. //Cache the margins of the original element
  8450. this._cacheMargins();
  8451. //Store the helper's css position
  8452. this.cssPosition = this.helper.css( "position" );
  8453. this.scrollParent = this.helper.scrollParent( true );
  8454. this.offsetParent = this.helper.offsetParent();
  8455. this.hasFixedAncestor = this.helper.parents().filter( function() {
  8456. return $( this ).css( "position" ) === "fixed";
  8457. } ).length > 0;
  8458. //The element's absolute position on the page minus margins
  8459. this.positionAbs = this.element.offset();
  8460. this._refreshOffsets( event );
  8461. //Generate the original position
  8462. this.originalPosition = this.position = this._generatePosition( event, false );
  8463. this.originalPageX = event.pageX;
  8464. this.originalPageY = event.pageY;
  8465. //Adjust the mouse offset relative to the helper if "cursorAt" is supplied
  8466. if ( o.cursorAt ) {
  8467. this._adjustOffsetFromHelper( o.cursorAt );
  8468. }
  8469. //Set a containment if given in the options
  8470. this._setContainment();
  8471. //Trigger event + callbacks
  8472. if ( this._trigger( "start", event ) === false ) {
  8473. this._clear();
  8474. return false;
  8475. }
  8476. //Recache the helper size
  8477. this._cacheHelperProportions();
  8478. //Prepare the droppable offsets
  8479. if ( $.ui.ddmanager && !o.dropBehaviour ) {
  8480. $.ui.ddmanager.prepareOffsets( this, event );
  8481. }
  8482. // Execute the drag once - this causes the helper not to be visible before getting its
  8483. // correct position
  8484. this._mouseDrag( event, true );
  8485. // If the ddmanager is used for droppables, inform the manager that dragging has started
  8486. // (see #5003)
  8487. if ( $.ui.ddmanager ) {
  8488. $.ui.ddmanager.dragStart( this, event );
  8489. }
  8490. return true;
  8491. },
  8492. _refreshOffsets: function( event ) {
  8493. this.offset = {
  8494. top: this.positionAbs.top - this.margins.top,
  8495. left: this.positionAbs.left - this.margins.left,
  8496. scroll: false,
  8497. parent: this._getParentOffset(),
  8498. relative: this._getRelativeOffset()
  8499. };
  8500. this.offset.click = {
  8501. left: event.pageX - this.offset.left,
  8502. top: event.pageY - this.offset.top
  8503. };
  8504. },
  8505. _mouseDrag: function( event, noPropagation ) {
  8506. // reset any necessary cached properties (see #5009)
  8507. if ( this.hasFixedAncestor ) {
  8508. this.offset.parent = this._getParentOffset();
  8509. }
  8510. //Compute the helpers position
  8511. this.position = this._generatePosition( event, true );
  8512. this.positionAbs = this._convertPositionTo( "absolute" );
  8513. //Call plugins and callbacks and use the resulting position if something is returned
  8514. if ( !noPropagation ) {
  8515. var ui = this._uiHash();
  8516. if ( this._trigger( "drag", event, ui ) === false ) {
  8517. this._mouseUp( new $.Event( "mouseup", event ) );
  8518. return false;
  8519. }
  8520. this.position = ui.position;
  8521. }
  8522. this.helper[ 0 ].style.left = this.position.left + "px";
  8523. this.helper[ 0 ].style.top = this.position.top + "px";
  8524. if ( $.ui.ddmanager ) {
  8525. $.ui.ddmanager.drag( this, event );
  8526. }
  8527. return false;
  8528. },
  8529. _mouseStop: function( event ) {
  8530. //If we are using droppables, inform the manager about the drop
  8531. var that = this,
  8532. dropped = false;
  8533. if ( $.ui.ddmanager && !this.options.dropBehaviour ) {
  8534. dropped = $.ui.ddmanager.drop( this, event );
  8535. }
  8536. //if a drop comes from outside (a sortable)
  8537. if ( this.dropped ) {
  8538. dropped = this.dropped;
  8539. this.dropped = false;
  8540. }
  8541. if ( ( this.options.revert === "invalid" && !dropped ) ||
  8542. ( this.options.revert === "valid" && dropped ) ||
  8543. this.options.revert === true || ( typeof this.options.revert === "function" &&
  8544. this.options.revert.call( this.element, dropped ) )
  8545. ) {
  8546. $( this.helper ).animate(
  8547. this.originalPosition,
  8548. parseInt( this.options.revertDuration, 10 ),
  8549. function() {
  8550. if ( that._trigger( "stop", event ) !== false ) {
  8551. that._clear();
  8552. }
  8553. }
  8554. );
  8555. } else {
  8556. if ( this._trigger( "stop", event ) !== false ) {
  8557. this._clear();
  8558. }
  8559. }
  8560. return false;
  8561. },
  8562. _mouseUp: function( event ) {
  8563. this._unblockFrames();
  8564. // If the ddmanager is used for droppables, inform the manager that dragging has stopped
  8565. // (see #5003)
  8566. if ( $.ui.ddmanager ) {
  8567. $.ui.ddmanager.dragStop( this, event );
  8568. }
  8569. // Only need to focus if the event occurred on the draggable itself, see #10527
  8570. if ( this.handleElement.is( event.target ) ) {
  8571. // The interaction is over; whether or not the click resulted in a drag,
  8572. // focus the element
  8573. this.element.trigger( "focus" );
  8574. }
  8575. return $.ui.mouse.prototype._mouseUp.call( this, event );
  8576. },
  8577. cancel: function() {
  8578. if ( this.helper.is( ".ui-draggable-dragging" ) ) {
  8579. this._mouseUp( new $.Event( "mouseup", { target: this.element[ 0 ] } ) );
  8580. } else {
  8581. this._clear();
  8582. }
  8583. return this;
  8584. },
  8585. _getHandle: function( event ) {
  8586. return this.options.handle ?
  8587. !!$( event.target ).closest( this.element.find( this.options.handle ) ).length :
  8588. true;
  8589. },
  8590. _setHandleClassName: function() {
  8591. this.handleElement = this.options.handle ?
  8592. this.element.find( this.options.handle ) : this.element;
  8593. this._addClass( this.handleElement, "ui-draggable-handle" );
  8594. },
  8595. _removeHandleClassName: function() {
  8596. this._removeClass( this.handleElement, "ui-draggable-handle" );
  8597. },
  8598. _createHelper: function( event ) {
  8599. var o = this.options,
  8600. helperIsFunction = typeof o.helper === "function",
  8601. helper = helperIsFunction ?
  8602. $( o.helper.apply( this.element[ 0 ], [ event ] ) ) :
  8603. ( o.helper === "clone" ?
  8604. this.element.clone().removeAttr( "id" ) :
  8605. this.element );
  8606. if ( !helper.parents( "body" ).length ) {
  8607. helper.appendTo( ( o.appendTo === "parent" ?
  8608. this.element[ 0 ].parentNode :
  8609. o.appendTo ) );
  8610. }
  8611. // Http://bugs.jqueryui.com/ticket/9446
  8612. // a helper function can return the original element
  8613. // which wouldn't have been set to relative in _create
  8614. if ( helperIsFunction && helper[ 0 ] === this.element[ 0 ] ) {
  8615. this._setPositionRelative();
  8616. }
  8617. if ( helper[ 0 ] !== this.element[ 0 ] &&
  8618. !( /(fixed|absolute)/ ).test( helper.css( "position" ) ) ) {
  8619. helper.css( "position", "absolute" );
  8620. }
  8621. return helper;
  8622. },
  8623. _setPositionRelative: function() {
  8624. if ( !( /^(?:r|a|f)/ ).test( this.element.css( "position" ) ) ) {
  8625. this.element[ 0 ].style.position = "relative";
  8626. }
  8627. },
  8628. _adjustOffsetFromHelper: function( obj ) {
  8629. if ( typeof obj === "string" ) {
  8630. obj = obj.split( " " );
  8631. }
  8632. if ( Array.isArray( obj ) ) {
  8633. obj = { left: +obj[ 0 ], top: +obj[ 1 ] || 0 };
  8634. }
  8635. if ( "left" in obj ) {
  8636. this.offset.click.left = obj.left + this.margins.left;
  8637. }
  8638. if ( "right" in obj ) {
  8639. this.offset.click.left = this.helperProportions.width - obj.right + this.margins.left;
  8640. }
  8641. if ( "top" in obj ) {
  8642. this.offset.click.top = obj.top + this.margins.top;
  8643. }
  8644. if ( "bottom" in obj ) {
  8645. this.offset.click.top = this.helperProportions.height - obj.bottom + this.margins.top;
  8646. }
  8647. },
  8648. _isRootNode: function( element ) {
  8649. return ( /(html|body)/i ).test( element.tagName ) || element === this.document[ 0 ];
  8650. },
  8651. _getParentOffset: function() {
  8652. //Get the offsetParent and cache its position
  8653. var po = this.offsetParent.offset(),
  8654. document = this.document[ 0 ];
  8655. // This is a special case where we need to modify a offset calculated on start, since the
  8656. // following happened:
  8657. // 1. The position of the helper is absolute, so it's position is calculated based on the
  8658. // next positioned parent
  8659. // 2. The actual offset parent is a child of the scroll parent, and the scroll parent isn't
  8660. // the document, which means that the scroll is included in the initial calculation of the
  8661. // offset of the parent, and never recalculated upon drag
  8662. if ( this.cssPosition === "absolute" && this.scrollParent[ 0 ] !== document &&
  8663. $.contains( this.scrollParent[ 0 ], this.offsetParent[ 0 ] ) ) {
  8664. po.left += this.scrollParent.scrollLeft();
  8665. po.top += this.scrollParent.scrollTop();
  8666. }
  8667. if ( this._isRootNode( this.offsetParent[ 0 ] ) ) {
  8668. po = { top: 0, left: 0 };
  8669. }
  8670. return {
  8671. top: po.top + ( parseInt( this.offsetParent.css( "borderTopWidth" ), 10 ) || 0 ),
  8672. left: po.left + ( parseInt( this.offsetParent.css( "borderLeftWidth" ), 10 ) || 0 )
  8673. };
  8674. },
  8675. _getRelativeOffset: function() {
  8676. if ( this.cssPosition !== "relative" ) {
  8677. return { top: 0, left: 0 };
  8678. }
  8679. var p = this.element.position(),
  8680. scrollIsRootNode = this._isRootNode( this.scrollParent[ 0 ] );
  8681. return {
  8682. top: p.top - ( parseInt( this.helper.css( "top" ), 10 ) || 0 ) +
  8683. ( !scrollIsRootNode ? this.scrollParent.scrollTop() : 0 ),
  8684. left: p.left - ( parseInt( this.helper.css( "left" ), 10 ) || 0 ) +
  8685. ( !scrollIsRootNode ? this.scrollParent.scrollLeft() : 0 )
  8686. };
  8687. },
  8688. _cacheMargins: function() {
  8689. this.margins = {
  8690. left: ( parseInt( this.element.css( "marginLeft" ), 10 ) || 0 ),
  8691. top: ( parseInt( this.element.css( "marginTop" ), 10 ) || 0 ),
  8692. right: ( parseInt( this.element.css( "marginRight" ), 10 ) || 0 ),
  8693. bottom: ( parseInt( this.element.css( "marginBottom" ), 10 ) || 0 )
  8694. };
  8695. },
  8696. _cacheHelperProportions: function() {
  8697. this.helperProportions = {
  8698. width: this.helper.outerWidth(),
  8699. height: this.helper.outerHeight()
  8700. };
  8701. },
  8702. _setContainment: function() {
  8703. var isUserScrollable, c, ce,
  8704. o = this.options,
  8705. document = this.document[ 0 ];
  8706. this.relativeContainer = null;
  8707. if ( !o.containment ) {
  8708. this.containment = null;
  8709. return;
  8710. }
  8711. if ( o.containment === "window" ) {
  8712. this.containment = [
  8713. $( window ).scrollLeft() - this.offset.relative.left - this.offset.parent.left,
  8714. $( window ).scrollTop() - this.offset.relative.top - this.offset.parent.top,
  8715. $( window ).scrollLeft() + $( window ).width() -
  8716. this.helperProportions.width - this.margins.left,
  8717. $( window ).scrollTop() +
  8718. ( $( window ).height() || document.body.parentNode.scrollHeight ) -
  8719. this.helperProportions.height - this.margins.top
  8720. ];
  8721. return;
  8722. }
  8723. if ( o.containment === "document" ) {
  8724. this.containment = [
  8725. 0,
  8726. 0,
  8727. $( document ).width() - this.helperProportions.width - this.margins.left,
  8728. ( $( document ).height() || document.body.parentNode.scrollHeight ) -
  8729. this.helperProportions.height - this.margins.top
  8730. ];
  8731. return;
  8732. }
  8733. if ( o.containment.constructor === Array ) {
  8734. this.containment = o.containment;
  8735. return;
  8736. }
  8737. if ( o.containment === "parent" ) {
  8738. o.containment = this.helper[ 0 ].parentNode;
  8739. }
  8740. c = $( o.containment );
  8741. ce = c[ 0 ];
  8742. if ( !ce ) {
  8743. return;
  8744. }
  8745. isUserScrollable = /(scroll|auto)/.test( c.css( "overflow" ) );
  8746. this.containment = [
  8747. ( parseInt( c.css( "borderLeftWidth" ), 10 ) || 0 ) +
  8748. ( parseInt( c.css( "paddingLeft" ), 10 ) || 0 ),
  8749. ( parseInt( c.css( "borderTopWidth" ), 10 ) || 0 ) +
  8750. ( parseInt( c.css( "paddingTop" ), 10 ) || 0 ),
  8751. ( isUserScrollable ? Math.max( ce.scrollWidth, ce.offsetWidth ) : ce.offsetWidth ) -
  8752. ( parseInt( c.css( "borderRightWidth" ), 10 ) || 0 ) -
  8753. ( parseInt( c.css( "paddingRight" ), 10 ) || 0 ) -
  8754. this.helperProportions.width -
  8755. this.margins.left -
  8756. this.margins.right,
  8757. ( isUserScrollable ? Math.max( ce.scrollHeight, ce.offsetHeight ) : ce.offsetHeight ) -
  8758. ( parseInt( c.css( "borderBottomWidth" ), 10 ) || 0 ) -
  8759. ( parseInt( c.css( "paddingBottom" ), 10 ) || 0 ) -
  8760. this.helperProportions.height -
  8761. this.margins.top -
  8762. this.margins.bottom
  8763. ];
  8764. this.relativeContainer = c;
  8765. },
  8766. _convertPositionTo: function( d, pos ) {
  8767. if ( !pos ) {
  8768. pos = this.position;
  8769. }
  8770. var mod = d === "absolute" ? 1 : -1,
  8771. scrollIsRootNode = this._isRootNode( this.scrollParent[ 0 ] );
  8772. return {
  8773. top: (
  8774. // The absolute mouse position
  8775. pos.top +
  8776. // Only for relative positioned nodes: Relative offset from element to offset parent
  8777. this.offset.relative.top * mod +
  8778. // The offsetParent's offset without borders (offset + border)
  8779. this.offset.parent.top * mod -
  8780. ( ( this.cssPosition === "fixed" ?
  8781. -this.offset.scroll.top :
  8782. ( scrollIsRootNode ? 0 : this.offset.scroll.top ) ) * mod )
  8783. ),
  8784. left: (
  8785. // The absolute mouse position
  8786. pos.left +
  8787. // Only for relative positioned nodes: Relative offset from element to offset parent
  8788. this.offset.relative.left * mod +
  8789. // The offsetParent's offset without borders (offset + border)
  8790. this.offset.parent.left * mod -
  8791. ( ( this.cssPosition === "fixed" ?
  8792. -this.offset.scroll.left :
  8793. ( scrollIsRootNode ? 0 : this.offset.scroll.left ) ) * mod )
  8794. )
  8795. };
  8796. },
  8797. _generatePosition: function( event, constrainPosition ) {
  8798. var containment, co, top, left,
  8799. o = this.options,
  8800. scrollIsRootNode = this._isRootNode( this.scrollParent[ 0 ] ),
  8801. pageX = event.pageX,
  8802. pageY = event.pageY;
  8803. // Cache the scroll
  8804. if ( !scrollIsRootNode || !this.offset.scroll ) {
  8805. this.offset.scroll = {
  8806. top: this.scrollParent.scrollTop(),
  8807. left: this.scrollParent.scrollLeft()
  8808. };
  8809. }
  8810. /*
  8811. * - Position constraining -
  8812. * Constrain the position to a mix of grid, containment.
  8813. */
  8814. // If we are not dragging yet, we won't check for options
  8815. if ( constrainPosition ) {
  8816. if ( this.containment ) {
  8817. if ( this.relativeContainer ) {
  8818. co = this.relativeContainer.offset();
  8819. containment = [
  8820. this.containment[ 0 ] + co.left,
  8821. this.containment[ 1 ] + co.top,
  8822. this.containment[ 2 ] + co.left,
  8823. this.containment[ 3 ] + co.top
  8824. ];
  8825. } else {
  8826. containment = this.containment;
  8827. }
  8828. if ( event.pageX - this.offset.click.left < containment[ 0 ] ) {
  8829. pageX = containment[ 0 ] + this.offset.click.left;
  8830. }
  8831. if ( event.pageY - this.offset.click.top < containment[ 1 ] ) {
  8832. pageY = containment[ 1 ] + this.offset.click.top;
  8833. }
  8834. if ( event.pageX - this.offset.click.left > containment[ 2 ] ) {
  8835. pageX = containment[ 2 ] + this.offset.click.left;
  8836. }
  8837. if ( event.pageY - this.offset.click.top > containment[ 3 ] ) {
  8838. pageY = containment[ 3 ] + this.offset.click.top;
  8839. }
  8840. }
  8841. if ( o.grid ) {
  8842. //Check for grid elements set to 0 to prevent divide by 0 error causing invalid
  8843. // argument errors in IE (see ticket #6950)
  8844. top = o.grid[ 1 ] ? this.originalPageY + Math.round( ( pageY -
  8845. this.originalPageY ) / o.grid[ 1 ] ) * o.grid[ 1 ] : this.originalPageY;
  8846. pageY = containment ? ( ( top - this.offset.click.top >= containment[ 1 ] ||
  8847. top - this.offset.click.top > containment[ 3 ] ) ?
  8848. top :
  8849. ( ( top - this.offset.click.top >= containment[ 1 ] ) ?
  8850. top - o.grid[ 1 ] : top + o.grid[ 1 ] ) ) : top;
  8851. left = o.grid[ 0 ] ? this.originalPageX +
  8852. Math.round( ( pageX - this.originalPageX ) / o.grid[ 0 ] ) * o.grid[ 0 ] :
  8853. this.originalPageX;
  8854. pageX = containment ? ( ( left - this.offset.click.left >= containment[ 0 ] ||
  8855. left - this.offset.click.left > containment[ 2 ] ) ?
  8856. left :
  8857. ( ( left - this.offset.click.left >= containment[ 0 ] ) ?
  8858. left - o.grid[ 0 ] : left + o.grid[ 0 ] ) ) : left;
  8859. }
  8860. if ( o.axis === "y" ) {
  8861. pageX = this.originalPageX;
  8862. }
  8863. if ( o.axis === "x" ) {
  8864. pageY = this.originalPageY;
  8865. }
  8866. }
  8867. return {
  8868. top: (
  8869. // The absolute mouse position
  8870. pageY -
  8871. // Click offset (relative to the element)
  8872. this.offset.click.top -
  8873. // Only for relative positioned nodes: Relative offset from element to offset parent
  8874. this.offset.relative.top -
  8875. // The offsetParent's offset without borders (offset + border)
  8876. this.offset.parent.top +
  8877. ( this.cssPosition === "fixed" ?
  8878. -this.offset.scroll.top :
  8879. ( scrollIsRootNode ? 0 : this.offset.scroll.top ) )
  8880. ),
  8881. left: (
  8882. // The absolute mouse position
  8883. pageX -
  8884. // Click offset (relative to the element)
  8885. this.offset.click.left -
  8886. // Only for relative positioned nodes: Relative offset from element to offset parent
  8887. this.offset.relative.left -
  8888. // The offsetParent's offset without borders (offset + border)
  8889. this.offset.parent.left +
  8890. ( this.cssPosition === "fixed" ?
  8891. -this.offset.scroll.left :
  8892. ( scrollIsRootNode ? 0 : this.offset.scroll.left ) )
  8893. )
  8894. };
  8895. },
  8896. _clear: function() {
  8897. this._removeClass( this.helper, "ui-draggable-dragging" );
  8898. if ( this.helper[ 0 ] !== this.element[ 0 ] && !this.cancelHelperRemoval ) {
  8899. this.helper.remove();
  8900. }
  8901. this.helper = null;
  8902. this.cancelHelperRemoval = false;
  8903. if ( this.destroyOnClear ) {
  8904. this.destroy();
  8905. }
  8906. },
  8907. // From now on bulk stuff - mainly helpers
  8908. _trigger: function( type, event, ui ) {
  8909. ui = ui || this._uiHash();
  8910. $.ui.plugin.call( this, type, [ event, ui, this ], true );
  8911. // Absolute position and offset (see #6884 ) have to be recalculated after plugins
  8912. if ( /^(drag|start|stop)/.test( type ) ) {
  8913. this.positionAbs = this._convertPositionTo( "absolute" );
  8914. ui.offset = this.positionAbs;
  8915. }
  8916. return $.Widget.prototype._trigger.call( this, type, event, ui );
  8917. },
  8918. plugins: {},
  8919. _uiHash: function() {
  8920. return {
  8921. helper: this.helper,
  8922. position: this.position,
  8923. originalPosition: this.originalPosition,
  8924. offset: this.positionAbs
  8925. };
  8926. }
  8927. } );
  8928. $.ui.plugin.add( "draggable", "connectToSortable", {
  8929. start: function( event, ui, draggable ) {
  8930. var uiSortable = $.extend( {}, ui, {
  8931. item: draggable.element
  8932. } );
  8933. draggable.sortables = [];
  8934. $( draggable.options.connectToSortable ).each( function() {
  8935. var sortable = $( this ).sortable( "instance" );
  8936. if ( sortable && !sortable.options.disabled ) {
  8937. draggable.sortables.push( sortable );
  8938. // RefreshPositions is called at drag start to refresh the containerCache
  8939. // which is used in drag. This ensures it's initialized and synchronized
  8940. // with any changes that might have happened on the page since initialization.
  8941. sortable.refreshPositions();
  8942. sortable._trigger( "activate", event, uiSortable );
  8943. }
  8944. } );
  8945. },
  8946. stop: function( event, ui, draggable ) {
  8947. var uiSortable = $.extend( {}, ui, {
  8948. item: draggable.element
  8949. } );
  8950. draggable.cancelHelperRemoval = false;
  8951. $.each( draggable.sortables, function() {
  8952. var sortable = this;
  8953. if ( sortable.isOver ) {
  8954. sortable.isOver = 0;
  8955. // Allow this sortable to handle removing the helper
  8956. draggable.cancelHelperRemoval = true;
  8957. sortable.cancelHelperRemoval = false;
  8958. // Use _storedCSS To restore properties in the sortable,
  8959. // as this also handles revert (#9675) since the draggable
  8960. // may have modified them in unexpected ways (#8809)
  8961. sortable._storedCSS = {
  8962. position: sortable.placeholder.css( "position" ),
  8963. top: sortable.placeholder.css( "top" ),
  8964. left: sortable.placeholder.css( "left" )
  8965. };
  8966. sortable._mouseStop( event );
  8967. // Once drag has ended, the sortable should return to using
  8968. // its original helper, not the shared helper from draggable
  8969. sortable.options.helper = sortable.options._helper;
  8970. } else {
  8971. // Prevent this Sortable from removing the helper.
  8972. // However, don't set the draggable to remove the helper
  8973. // either as another connected Sortable may yet handle the removal.
  8974. sortable.cancelHelperRemoval = true;
  8975. sortable._trigger( "deactivate", event, uiSortable );
  8976. }
  8977. } );
  8978. },
  8979. drag: function( event, ui, draggable ) {
  8980. $.each( draggable.sortables, function() {
  8981. var innermostIntersecting = false,
  8982. sortable = this;
  8983. // Copy over variables that sortable's _intersectsWith uses
  8984. sortable.positionAbs = draggable.positionAbs;
  8985. sortable.helperProportions = draggable.helperProportions;
  8986. sortable.offset.click = draggable.offset.click;
  8987. if ( sortable._intersectsWith( sortable.containerCache ) ) {
  8988. innermostIntersecting = true;
  8989. $.each( draggable.sortables, function() {
  8990. // Copy over variables that sortable's _intersectsWith uses
  8991. this.positionAbs = draggable.positionAbs;
  8992. this.helperProportions = draggable.helperProportions;
  8993. this.offset.click = draggable.offset.click;
  8994. if ( this !== sortable &&
  8995. this._intersectsWith( this.containerCache ) &&
  8996. $.contains( sortable.element[ 0 ], this.element[ 0 ] ) ) {
  8997. innermostIntersecting = false;
  8998. }
  8999. return innermostIntersecting;
  9000. } );
  9001. }
  9002. if ( innermostIntersecting ) {
  9003. // If it intersects, we use a little isOver variable and set it once,
  9004. // so that the move-in stuff gets fired only once.
  9005. if ( !sortable.isOver ) {
  9006. sortable.isOver = 1;
  9007. // Store draggable's parent in case we need to reappend to it later.
  9008. draggable._parent = ui.helper.parent();
  9009. sortable.currentItem = ui.helper
  9010. .appendTo( sortable.element )
  9011. .data( "ui-sortable-item", true );
  9012. // Store helper option to later restore it
  9013. sortable.options._helper = sortable.options.helper;
  9014. sortable.options.helper = function() {
  9015. return ui.helper[ 0 ];
  9016. };
  9017. // Fire the start events of the sortable with our passed browser event,
  9018. // and our own helper (so it doesn't create a new one)
  9019. event.target = sortable.currentItem[ 0 ];
  9020. sortable._mouseCapture( event, true );
  9021. sortable._mouseStart( event, true, true );
  9022. // Because the browser event is way off the new appended portlet,
  9023. // modify necessary variables to reflect the changes
  9024. sortable.offset.click.top = draggable.offset.click.top;
  9025. sortable.offset.click.left = draggable.offset.click.left;
  9026. sortable.offset.parent.left -= draggable.offset.parent.left -
  9027. sortable.offset.parent.left;
  9028. sortable.offset.parent.top -= draggable.offset.parent.top -
  9029. sortable.offset.parent.top;
  9030. draggable._trigger( "toSortable", event );
  9031. // Inform draggable that the helper is in a valid drop zone,
  9032. // used solely in the revert option to handle "valid/invalid".
  9033. draggable.dropped = sortable.element;
  9034. // Need to refreshPositions of all sortables in the case that
  9035. // adding to one sortable changes the location of the other sortables (#9675)
  9036. $.each( draggable.sortables, function() {
  9037. this.refreshPositions();
  9038. } );
  9039. // Hack so receive/update callbacks work (mostly)
  9040. draggable.currentItem = draggable.element;
  9041. sortable.fromOutside = draggable;
  9042. }
  9043. if ( sortable.currentItem ) {
  9044. sortable._mouseDrag( event );
  9045. // Copy the sortable's position because the draggable's can potentially reflect
  9046. // a relative position, while sortable is always absolute, which the dragged
  9047. // element has now become. (#8809)
  9048. ui.position = sortable.position;
  9049. }
  9050. } else {
  9051. // If it doesn't intersect with the sortable, and it intersected before,
  9052. // we fake the drag stop of the sortable, but make sure it doesn't remove
  9053. // the helper by using cancelHelperRemoval.
  9054. if ( sortable.isOver ) {
  9055. sortable.isOver = 0;
  9056. sortable.cancelHelperRemoval = true;
  9057. // Calling sortable's mouseStop would trigger a revert,
  9058. // so revert must be temporarily false until after mouseStop is called.
  9059. sortable.options._revert = sortable.options.revert;
  9060. sortable.options.revert = false;
  9061. sortable._trigger( "out", event, sortable._uiHash( sortable ) );
  9062. sortable._mouseStop( event, true );
  9063. // Restore sortable behaviors that were modfied
  9064. // when the draggable entered the sortable area (#9481)
  9065. sortable.options.revert = sortable.options._revert;
  9066. sortable.options.helper = sortable.options._helper;
  9067. if ( sortable.placeholder ) {
  9068. sortable.placeholder.remove();
  9069. }
  9070. // Restore and recalculate the draggable's offset considering the sortable
  9071. // may have modified them in unexpected ways. (#8809, #10669)
  9072. ui.helper.appendTo( draggable._parent );
  9073. draggable._refreshOffsets( event );
  9074. ui.position = draggable._generatePosition( event, true );
  9075. draggable._trigger( "fromSortable", event );
  9076. // Inform draggable that the helper is no longer in a valid drop zone
  9077. draggable.dropped = false;
  9078. // Need to refreshPositions of all sortables just in case removing
  9079. // from one sortable changes the location of other sortables (#9675)
  9080. $.each( draggable.sortables, function() {
  9081. this.refreshPositions();
  9082. } );
  9083. }
  9084. }
  9085. } );
  9086. }
  9087. } );
  9088. $.ui.plugin.add( "draggable", "cursor", {
  9089. start: function( event, ui, instance ) {
  9090. var t = $( "body" ),
  9091. o = instance.options;
  9092. if ( t.css( "cursor" ) ) {
  9093. o._cursor = t.css( "cursor" );
  9094. }
  9095. t.css( "cursor", o.cursor );
  9096. },
  9097. stop: function( event, ui, instance ) {
  9098. var o = instance.options;
  9099. if ( o._cursor ) {
  9100. $( "body" ).css( "cursor", o._cursor );
  9101. }
  9102. }
  9103. } );
  9104. $.ui.plugin.add( "draggable", "opacity", {
  9105. start: function( event, ui, instance ) {
  9106. var t = $( ui.helper ),
  9107. o = instance.options;
  9108. if ( t.css( "opacity" ) ) {
  9109. o._opacity = t.css( "opacity" );
  9110. }
  9111. t.css( "opacity", o.opacity );
  9112. },
  9113. stop: function( event, ui, instance ) {
  9114. var o = instance.options;
  9115. if ( o._opacity ) {
  9116. $( ui.helper ).css( "opacity", o._opacity );
  9117. }
  9118. }
  9119. } );
  9120. $.ui.plugin.add( "draggable", "scroll", {
  9121. start: function( event, ui, i ) {
  9122. if ( !i.scrollParentNotHidden ) {
  9123. i.scrollParentNotHidden = i.helper.scrollParent( false );
  9124. }
  9125. if ( i.scrollParentNotHidden[ 0 ] !== i.document[ 0 ] &&
  9126. i.scrollParentNotHidden[ 0 ].tagName !== "HTML" ) {
  9127. i.overflowOffset = i.scrollParentNotHidden.offset();
  9128. }
  9129. },
  9130. drag: function( event, ui, i ) {
  9131. var o = i.options,
  9132. scrolled = false,
  9133. scrollParent = i.scrollParentNotHidden[ 0 ],
  9134. document = i.document[ 0 ];
  9135. if ( scrollParent !== document && scrollParent.tagName !== "HTML" ) {
  9136. if ( !o.axis || o.axis !== "x" ) {
  9137. if ( ( i.overflowOffset.top + scrollParent.offsetHeight ) - event.pageY <
  9138. o.scrollSensitivity ) {
  9139. scrollParent.scrollTop = scrolled = scrollParent.scrollTop + o.scrollSpeed;
  9140. } else if ( event.pageY - i.overflowOffset.top < o.scrollSensitivity ) {
  9141. scrollParent.scrollTop = scrolled = scrollParent.scrollTop - o.scrollSpeed;
  9142. }
  9143. }
  9144. if ( !o.axis || o.axis !== "y" ) {
  9145. if ( ( i.overflowOffset.left + scrollParent.offsetWidth ) - event.pageX <
  9146. o.scrollSensitivity ) {
  9147. scrollParent.scrollLeft = scrolled = scrollParent.scrollLeft + o.scrollSpeed;
  9148. } else if ( event.pageX - i.overflowOffset.left < o.scrollSensitivity ) {
  9149. scrollParent.scrollLeft = scrolled = scrollParent.scrollLeft - o.scrollSpeed;
  9150. }
  9151. }
  9152. } else {
  9153. if ( !o.axis || o.axis !== "x" ) {
  9154. if ( event.pageY - $( document ).scrollTop() < o.scrollSensitivity ) {
  9155. scrolled = $( document ).scrollTop( $( document ).scrollTop() - o.scrollSpeed );
  9156. } else if ( $( window ).height() - ( event.pageY - $( document ).scrollTop() ) <
  9157. o.scrollSensitivity ) {
  9158. scrolled = $( document ).scrollTop( $( document ).scrollTop() + o.scrollSpeed );
  9159. }
  9160. }
  9161. if ( !o.axis || o.axis !== "y" ) {
  9162. if ( event.pageX - $( document ).scrollLeft() < o.scrollSensitivity ) {
  9163. scrolled = $( document ).scrollLeft(
  9164. $( document ).scrollLeft() - o.scrollSpeed
  9165. );
  9166. } else if ( $( window ).width() - ( event.pageX - $( document ).scrollLeft() ) <
  9167. o.scrollSensitivity ) {
  9168. scrolled = $( document ).scrollLeft(
  9169. $( document ).scrollLeft() + o.scrollSpeed
  9170. );
  9171. }
  9172. }
  9173. }
  9174. if ( scrolled !== false && $.ui.ddmanager && !o.dropBehaviour ) {
  9175. $.ui.ddmanager.prepareOffsets( i, event );
  9176. }
  9177. }
  9178. } );
  9179. $.ui.plugin.add( "draggable", "snap", {
  9180. start: function( event, ui, i ) {
  9181. var o = i.options;
  9182. i.snapElements = [];
  9183. $( o.snap.constructor !== String ? ( o.snap.items || ":data(ui-draggable)" ) : o.snap )
  9184. .each( function() {
  9185. var $t = $( this ),
  9186. $o = $t.offset();
  9187. if ( this !== i.element[ 0 ] ) {
  9188. i.snapElements.push( {
  9189. item: this,
  9190. width: $t.outerWidth(), height: $t.outerHeight(),
  9191. top: $o.top, left: $o.left
  9192. } );
  9193. }
  9194. } );
  9195. },
  9196. drag: function( event, ui, inst ) {
  9197. var ts, bs, ls, rs, l, r, t, b, i, first,
  9198. o = inst.options,
  9199. d = o.snapTolerance,
  9200. x1 = ui.offset.left, x2 = x1 + inst.helperProportions.width,
  9201. y1 = ui.offset.top, y2 = y1 + inst.helperProportions.height;
  9202. for ( i = inst.snapElements.length - 1; i >= 0; i-- ) {
  9203. l = inst.snapElements[ i ].left - inst.margins.left;
  9204. r = l + inst.snapElements[ i ].width;
  9205. t = inst.snapElements[ i ].top - inst.margins.top;
  9206. b = t + inst.snapElements[ i ].height;
  9207. if ( x2 < l - d || x1 > r + d || y2 < t - d || y1 > b + d ||
  9208. !$.contains( inst.snapElements[ i ].item.ownerDocument,
  9209. inst.snapElements[ i ].item ) ) {
  9210. if ( inst.snapElements[ i ].snapping ) {
  9211. if ( inst.options.snap.release ) {
  9212. inst.options.snap.release.call(
  9213. inst.element,
  9214. event,
  9215. $.extend( inst._uiHash(), { snapItem: inst.snapElements[ i ].item } )
  9216. );
  9217. }
  9218. }
  9219. inst.snapElements[ i ].snapping = false;
  9220. continue;
  9221. }
  9222. if ( o.snapMode !== "inner" ) {
  9223. ts = Math.abs( t - y2 ) <= d;
  9224. bs = Math.abs( b - y1 ) <= d;
  9225. ls = Math.abs( l - x2 ) <= d;
  9226. rs = Math.abs( r - x1 ) <= d;
  9227. if ( ts ) {
  9228. ui.position.top = inst._convertPositionTo( "relative", {
  9229. top: t - inst.helperProportions.height,
  9230. left: 0
  9231. } ).top;
  9232. }
  9233. if ( bs ) {
  9234. ui.position.top = inst._convertPositionTo( "relative", {
  9235. top: b,
  9236. left: 0
  9237. } ).top;
  9238. }
  9239. if ( ls ) {
  9240. ui.position.left = inst._convertPositionTo( "relative", {
  9241. top: 0,
  9242. left: l - inst.helperProportions.width
  9243. } ).left;
  9244. }
  9245. if ( rs ) {
  9246. ui.position.left = inst._convertPositionTo( "relative", {
  9247. top: 0,
  9248. left: r
  9249. } ).left;
  9250. }
  9251. }
  9252. first = ( ts || bs || ls || rs );
  9253. if ( o.snapMode !== "outer" ) {
  9254. ts = Math.abs( t - y1 ) <= d;
  9255. bs = Math.abs( b - y2 ) <= d;
  9256. ls = Math.abs( l - x1 ) <= d;
  9257. rs = Math.abs( r - x2 ) <= d;
  9258. if ( ts ) {
  9259. ui.position.top = inst._convertPositionTo( "relative", {
  9260. top: t,
  9261. left: 0
  9262. } ).top;
  9263. }
  9264. if ( bs ) {
  9265. ui.position.top = inst._convertPositionTo( "relative", {
  9266. top: b - inst.helperProportions.height,
  9267. left: 0
  9268. } ).top;
  9269. }
  9270. if ( ls ) {
  9271. ui.position.left = inst._convertPositionTo( "relative", {
  9272. top: 0,
  9273. left: l
  9274. } ).left;
  9275. }
  9276. if ( rs ) {
  9277. ui.position.left = inst._convertPositionTo( "relative", {
  9278. top: 0,
  9279. left: r - inst.helperProportions.width
  9280. } ).left;
  9281. }
  9282. }
  9283. if ( !inst.snapElements[ i ].snapping && ( ts || bs || ls || rs || first ) ) {
  9284. if ( inst.options.snap.snap ) {
  9285. inst.options.snap.snap.call(
  9286. inst.element,
  9287. event,
  9288. $.extend( inst._uiHash(), {
  9289. snapItem: inst.snapElements[ i ].item
  9290. } ) );
  9291. }
  9292. }
  9293. inst.snapElements[ i ].snapping = ( ts || bs || ls || rs || first );
  9294. }
  9295. }
  9296. } );
  9297. $.ui.plugin.add( "draggable", "stack", {
  9298. start: function( event, ui, instance ) {
  9299. var min,
  9300. o = instance.options,
  9301. group = $.makeArray( $( o.stack ) ).sort( function( a, b ) {
  9302. return ( parseInt( $( a ).css( "zIndex" ), 10 ) || 0 ) -
  9303. ( parseInt( $( b ).css( "zIndex" ), 10 ) || 0 );
  9304. } );
  9305. if ( !group.length ) {
  9306. return;
  9307. }
  9308. min = parseInt( $( group[ 0 ] ).css( "zIndex" ), 10 ) || 0;
  9309. $( group ).each( function( i ) {
  9310. $( this ).css( "zIndex", min + i );
  9311. } );
  9312. this.css( "zIndex", ( min + group.length ) );
  9313. }
  9314. } );
  9315. $.ui.plugin.add( "draggable", "zIndex", {
  9316. start: function( event, ui, instance ) {
  9317. var t = $( ui.helper ),
  9318. o = instance.options;
  9319. if ( t.css( "zIndex" ) ) {
  9320. o._zIndex = t.css( "zIndex" );
  9321. }
  9322. t.css( "zIndex", o.zIndex );
  9323. },
  9324. stop: function( event, ui, instance ) {
  9325. var o = instance.options;
  9326. if ( o._zIndex ) {
  9327. $( ui.helper ).css( "zIndex", o._zIndex );
  9328. }
  9329. }
  9330. } );
  9331. var widgetsDraggable = $.ui.draggable;
  9332. /*!
  9333. * jQuery UI Resizable 1.13.2
  9334. * http://jqueryui.com
  9335. *
  9336. * Copyright jQuery Foundation and other contributors
  9337. * Released under the MIT license.
  9338. * http://jquery.org/license
  9339. */
  9340. //>>label: Resizable
  9341. //>>group: Interactions
  9342. //>>description: Enables resize functionality for any element.
  9343. //>>docs: http://api.jqueryui.com/resizable/
  9344. //>>demos: http://jqueryui.com/resizable/
  9345. //>>css.structure: ../../themes/base/core.css
  9346. //>>css.structure: ../../themes/base/resizable.css
  9347. //>>css.theme: ../../themes/base/theme.css
  9348. $.widget( "ui.resizable", $.ui.mouse, {
  9349. version: "1.13.2",
  9350. widgetEventPrefix: "resize",
  9351. options: {
  9352. alsoResize: false,
  9353. animate: false,
  9354. animateDuration: "slow",
  9355. animateEasing: "swing",
  9356. aspectRatio: false,
  9357. autoHide: false,
  9358. classes: {
  9359. "ui-resizable-se": "ui-icon ui-icon-gripsmall-diagonal-se"
  9360. },
  9361. containment: false,
  9362. ghost: false,
  9363. grid: false,
  9364. handles: "e,s,se",
  9365. helper: false,
  9366. maxHeight: null,
  9367. maxWidth: null,
  9368. minHeight: 10,
  9369. minWidth: 10,
  9370. // See #7960
  9371. zIndex: 90,
  9372. // Callbacks
  9373. resize: null,
  9374. start: null,
  9375. stop: null
  9376. },
  9377. _num: function( value ) {
  9378. return parseFloat( value ) || 0;
  9379. },
  9380. _isNumber: function( value ) {
  9381. return !isNaN( parseFloat( value ) );
  9382. },
  9383. _hasScroll: function( el, a ) {
  9384. if ( $( el ).css( "overflow" ) === "hidden" ) {
  9385. return false;
  9386. }
  9387. var scroll = ( a && a === "left" ) ? "scrollLeft" : "scrollTop",
  9388. has = false;
  9389. if ( el[ scroll ] > 0 ) {
  9390. return true;
  9391. }
  9392. // TODO: determine which cases actually cause this to happen
  9393. // if the element doesn't have the scroll set, see if it's possible to
  9394. // set the scroll
  9395. try {
  9396. el[ scroll ] = 1;
  9397. has = ( el[ scroll ] > 0 );
  9398. el[ scroll ] = 0;
  9399. } catch ( e ) {
  9400. // `el` might be a string, then setting `scroll` will throw
  9401. // an error in strict mode; ignore it.
  9402. }
  9403. return has;
  9404. },
  9405. _create: function() {
  9406. var margins,
  9407. o = this.options,
  9408. that = this;
  9409. this._addClass( "ui-resizable" );
  9410. $.extend( this, {
  9411. _aspectRatio: !!( o.aspectRatio ),
  9412. aspectRatio: o.aspectRatio,
  9413. originalElement: this.element,
  9414. _proportionallyResizeElements: [],
  9415. _helper: o.helper || o.ghost || o.animate ? o.helper || "ui-resizable-helper" : null
  9416. } );
  9417. // Wrap the element if it cannot hold child nodes
  9418. if ( this.element[ 0 ].nodeName.match( /^(canvas|textarea|input|select|button|img)$/i ) ) {
  9419. this.element.wrap(
  9420. $( "<div class='ui-wrapper'></div>" ).css( {
  9421. overflow: "hidden",
  9422. position: this.element.css( "position" ),
  9423. width: this.element.outerWidth(),
  9424. height: this.element.outerHeight(),
  9425. top: this.element.css( "top" ),
  9426. left: this.element.css( "left" )
  9427. } )
  9428. );
  9429. this.element = this.element.parent().data(
  9430. "ui-resizable", this.element.resizable( "instance" )
  9431. );
  9432. this.elementIsWrapper = true;
  9433. margins = {
  9434. marginTop: this.originalElement.css( "marginTop" ),
  9435. marginRight: this.originalElement.css( "marginRight" ),
  9436. marginBottom: this.originalElement.css( "marginBottom" ),
  9437. marginLeft: this.originalElement.css( "marginLeft" )
  9438. };
  9439. this.element.css( margins );
  9440. this.originalElement.css( "margin", 0 );
  9441. // support: Safari
  9442. // Prevent Safari textarea resize
  9443. this.originalResizeStyle = this.originalElement.css( "resize" );
  9444. this.originalElement.css( "resize", "none" );
  9445. this._proportionallyResizeElements.push( this.originalElement.css( {
  9446. position: "static",
  9447. zoom: 1,
  9448. display: "block"
  9449. } ) );
  9450. // Support: IE9
  9451. // avoid IE jump (hard set the margin)
  9452. this.originalElement.css( margins );
  9453. this._proportionallyResize();
  9454. }
  9455. this._setupHandles();
  9456. if ( o.autoHide ) {
  9457. $( this.element )
  9458. .on( "mouseenter", function() {
  9459. if ( o.disabled ) {
  9460. return;
  9461. }
  9462. that._removeClass( "ui-resizable-autohide" );
  9463. that._handles.show();
  9464. } )
  9465. .on( "mouseleave", function() {
  9466. if ( o.disabled ) {
  9467. return;
  9468. }
  9469. if ( !that.resizing ) {
  9470. that._addClass( "ui-resizable-autohide" );
  9471. that._handles.hide();
  9472. }
  9473. } );
  9474. }
  9475. this._mouseInit();
  9476. },
  9477. _destroy: function() {
  9478. this._mouseDestroy();
  9479. this._addedHandles.remove();
  9480. var wrapper,
  9481. _destroy = function( exp ) {
  9482. $( exp )
  9483. .removeData( "resizable" )
  9484. .removeData( "ui-resizable" )
  9485. .off( ".resizable" );
  9486. };
  9487. // TODO: Unwrap at same DOM position
  9488. if ( this.elementIsWrapper ) {
  9489. _destroy( this.element );
  9490. wrapper = this.element;
  9491. this.originalElement.css( {
  9492. position: wrapper.css( "position" ),
  9493. width: wrapper.outerWidth(),
  9494. height: wrapper.outerHeight(),
  9495. top: wrapper.css( "top" ),
  9496. left: wrapper.css( "left" )
  9497. } ).insertAfter( wrapper );
  9498. wrapper.remove();
  9499. }
  9500. this.originalElement.css( "resize", this.originalResizeStyle );
  9501. _destroy( this.originalElement );
  9502. return this;
  9503. },
  9504. _setOption: function( key, value ) {
  9505. this._super( key, value );
  9506. switch ( key ) {
  9507. case "handles":
  9508. this._removeHandles();
  9509. this._setupHandles();
  9510. break;
  9511. case "aspectRatio":
  9512. this._aspectRatio = !!value;
  9513. break;
  9514. default:
  9515. break;
  9516. }
  9517. },
  9518. _setupHandles: function() {
  9519. var o = this.options, handle, i, n, hname, axis, that = this;
  9520. this.handles = o.handles ||
  9521. ( !$( ".ui-resizable-handle", this.element ).length ?
  9522. "e,s,se" : {
  9523. n: ".ui-resizable-n",
  9524. e: ".ui-resizable-e",
  9525. s: ".ui-resizable-s",
  9526. w: ".ui-resizable-w",
  9527. se: ".ui-resizable-se",
  9528. sw: ".ui-resizable-sw",
  9529. ne: ".ui-resizable-ne",
  9530. nw: ".ui-resizable-nw"
  9531. } );
  9532. this._handles = $();
  9533. this._addedHandles = $();
  9534. if ( this.handles.constructor === String ) {
  9535. if ( this.handles === "all" ) {
  9536. this.handles = "n,e,s,w,se,sw,ne,nw";
  9537. }
  9538. n = this.handles.split( "," );
  9539. this.handles = {};
  9540. for ( i = 0; i < n.length; i++ ) {
  9541. handle = String.prototype.trim.call( n[ i ] );
  9542. hname = "ui-resizable-" + handle;
  9543. axis = $( "<div>" );
  9544. this._addClass( axis, "ui-resizable-handle " + hname );
  9545. axis.css( { zIndex: o.zIndex } );
  9546. this.handles[ handle ] = ".ui-resizable-" + handle;
  9547. if ( !this.element.children( this.handles[ handle ] ).length ) {
  9548. this.element.append( axis );
  9549. this._addedHandles = this._addedHandles.add( axis );
  9550. }
  9551. }
  9552. }
  9553. this._renderAxis = function( target ) {
  9554. var i, axis, padPos, padWrapper;
  9555. target = target || this.element;
  9556. for ( i in this.handles ) {
  9557. if ( this.handles[ i ].constructor === String ) {
  9558. this.handles[ i ] = this.element.children( this.handles[ i ] ).first().show();
  9559. } else if ( this.handles[ i ].jquery || this.handles[ i ].nodeType ) {
  9560. this.handles[ i ] = $( this.handles[ i ] );
  9561. this._on( this.handles[ i ], { "mousedown": that._mouseDown } );
  9562. }
  9563. if ( this.elementIsWrapper &&
  9564. this.originalElement[ 0 ]
  9565. .nodeName
  9566. .match( /^(textarea|input|select|button)$/i ) ) {
  9567. axis = $( this.handles[ i ], this.element );
  9568. padWrapper = /sw|ne|nw|se|n|s/.test( i ) ?
  9569. axis.outerHeight() :
  9570. axis.outerWidth();
  9571. padPos = [ "padding",
  9572. /ne|nw|n/.test( i ) ? "Top" :
  9573. /se|sw|s/.test( i ) ? "Bottom" :
  9574. /^e$/.test( i ) ? "Right" : "Left" ].join( "" );
  9575. target.css( padPos, padWrapper );
  9576. this._proportionallyResize();
  9577. }
  9578. this._handles = this._handles.add( this.handles[ i ] );
  9579. }
  9580. };
  9581. // TODO: make renderAxis a prototype function
  9582. this._renderAxis( this.element );
  9583. this._handles = this._handles.add( this.element.find( ".ui-resizable-handle" ) );
  9584. this._handles.disableSelection();
  9585. this._handles.on( "mouseover", function() {
  9586. if ( !that.resizing ) {
  9587. if ( this.className ) {
  9588. axis = this.className.match( /ui-resizable-(se|sw|ne|nw|n|e|s|w)/i );
  9589. }
  9590. that.axis = axis && axis[ 1 ] ? axis[ 1 ] : "se";
  9591. }
  9592. } );
  9593. if ( o.autoHide ) {
  9594. this._handles.hide();
  9595. this._addClass( "ui-resizable-autohide" );
  9596. }
  9597. },
  9598. _removeHandles: function() {
  9599. this._addedHandles.remove();
  9600. },
  9601. _mouseCapture: function( event ) {
  9602. var i, handle,
  9603. capture = false;
  9604. for ( i in this.handles ) {
  9605. handle = $( this.handles[ i ] )[ 0 ];
  9606. if ( handle === event.target || $.contains( handle, event.target ) ) {
  9607. capture = true;
  9608. }
  9609. }
  9610. return !this.options.disabled && capture;
  9611. },
  9612. _mouseStart: function( event ) {
  9613. var curleft, curtop, cursor,
  9614. o = this.options,
  9615. el = this.element;
  9616. this.resizing = true;
  9617. this._renderProxy();
  9618. curleft = this._num( this.helper.css( "left" ) );
  9619. curtop = this._num( this.helper.css( "top" ) );
  9620. if ( o.containment ) {
  9621. curleft += $( o.containment ).scrollLeft() || 0;
  9622. curtop += $( o.containment ).scrollTop() || 0;
  9623. }
  9624. this.offset = this.helper.offset();
  9625. this.position = { left: curleft, top: curtop };
  9626. this.size = this._helper ? {
  9627. width: this.helper.width(),
  9628. height: this.helper.height()
  9629. } : {
  9630. width: el.width(),
  9631. height: el.height()
  9632. };
  9633. this.originalSize = this._helper ? {
  9634. width: el.outerWidth(),
  9635. height: el.outerHeight()
  9636. } : {
  9637. width: el.width(),
  9638. height: el.height()
  9639. };
  9640. this.sizeDiff = {
  9641. width: el.outerWidth() - el.width(),
  9642. height: el.outerHeight() - el.height()
  9643. };
  9644. this.originalPosition = { left: curleft, top: curtop };
  9645. this.originalMousePosition = { left: event.pageX, top: event.pageY };
  9646. this.aspectRatio = ( typeof o.aspectRatio === "number" ) ?
  9647. o.aspectRatio :
  9648. ( ( this.originalSize.width / this.originalSize.height ) || 1 );
  9649. cursor = $( ".ui-resizable-" + this.axis ).css( "cursor" );
  9650. $( "body" ).css( "cursor", cursor === "auto" ? this.axis + "-resize" : cursor );
  9651. this._addClass( "ui-resizable-resizing" );
  9652. this._propagate( "start", event );
  9653. return true;
  9654. },
  9655. _mouseDrag: function( event ) {
  9656. var data, props,
  9657. smp = this.originalMousePosition,
  9658. a = this.axis,
  9659. dx = ( event.pageX - smp.left ) || 0,
  9660. dy = ( event.pageY - smp.top ) || 0,
  9661. trigger = this._change[ a ];
  9662. this._updatePrevProperties();
  9663. if ( !trigger ) {
  9664. return false;
  9665. }
  9666. data = trigger.apply( this, [ event, dx, dy ] );
  9667. this._updateVirtualBoundaries( event.shiftKey );
  9668. if ( this._aspectRatio || event.shiftKey ) {
  9669. data = this._updateRatio( data, event );
  9670. }
  9671. data = this._respectSize( data, event );
  9672. this._updateCache( data );
  9673. this._propagate( "resize", event );
  9674. props = this._applyChanges();
  9675. if ( !this._helper && this._proportionallyResizeElements.length ) {
  9676. this._proportionallyResize();
  9677. }
  9678. if ( !$.isEmptyObject( props ) ) {
  9679. this._updatePrevProperties();
  9680. this._trigger( "resize", event, this.ui() );
  9681. this._applyChanges();
  9682. }
  9683. return false;
  9684. },
  9685. _mouseStop: function( event ) {
  9686. this.resizing = false;
  9687. var pr, ista, soffseth, soffsetw, s, left, top,
  9688. o = this.options, that = this;
  9689. if ( this._helper ) {
  9690. pr = this._proportionallyResizeElements;
  9691. ista = pr.length && ( /textarea/i ).test( pr[ 0 ].nodeName );
  9692. soffseth = ista && this._hasScroll( pr[ 0 ], "left" ) ? 0 : that.sizeDiff.height;
  9693. soffsetw = ista ? 0 : that.sizeDiff.width;
  9694. s = {
  9695. width: ( that.helper.width() - soffsetw ),
  9696. height: ( that.helper.height() - soffseth )
  9697. };
  9698. left = ( parseFloat( that.element.css( "left" ) ) +
  9699. ( that.position.left - that.originalPosition.left ) ) || null;
  9700. top = ( parseFloat( that.element.css( "top" ) ) +
  9701. ( that.position.top - that.originalPosition.top ) ) || null;
  9702. if ( !o.animate ) {
  9703. this.element.css( $.extend( s, { top: top, left: left } ) );
  9704. }
  9705. that.helper.height( that.size.height );
  9706. that.helper.width( that.size.width );
  9707. if ( this._helper && !o.animate ) {
  9708. this._proportionallyResize();
  9709. }
  9710. }
  9711. $( "body" ).css( "cursor", "auto" );
  9712. this._removeClass( "ui-resizable-resizing" );
  9713. this._propagate( "stop", event );
  9714. if ( this._helper ) {
  9715. this.helper.remove();
  9716. }
  9717. return false;
  9718. },
  9719. _updatePrevProperties: function() {
  9720. this.prevPosition = {
  9721. top: this.position.top,
  9722. left: this.position.left
  9723. };
  9724. this.prevSize = {
  9725. width: this.size.width,
  9726. height: this.size.height
  9727. };
  9728. },
  9729. _applyChanges: function() {
  9730. var props = {};
  9731. if ( this.position.top !== this.prevPosition.top ) {
  9732. props.top = this.position.top + "px";
  9733. }
  9734. if ( this.position.left !== this.prevPosition.left ) {
  9735. props.left = this.position.left + "px";
  9736. }
  9737. if ( this.size.width !== this.prevSize.width ) {
  9738. props.width = this.size.width + "px";
  9739. }
  9740. if ( this.size.height !== this.prevSize.height ) {
  9741. props.height = this.size.height + "px";
  9742. }
  9743. this.helper.css( props );
  9744. return props;
  9745. },
  9746. _updateVirtualBoundaries: function( forceAspectRatio ) {
  9747. var pMinWidth, pMaxWidth, pMinHeight, pMaxHeight, b,
  9748. o = this.options;
  9749. b = {
  9750. minWidth: this._isNumber( o.minWidth ) ? o.minWidth : 0,
  9751. maxWidth: this._isNumber( o.maxWidth ) ? o.maxWidth : Infinity,
  9752. minHeight: this._isNumber( o.minHeight ) ? o.minHeight : 0,
  9753. maxHeight: this._isNumber( o.maxHeight ) ? o.maxHeight : Infinity
  9754. };
  9755. if ( this._aspectRatio || forceAspectRatio ) {
  9756. pMinWidth = b.minHeight * this.aspectRatio;
  9757. pMinHeight = b.minWidth / this.aspectRatio;
  9758. pMaxWidth = b.maxHeight * this.aspectRatio;
  9759. pMaxHeight = b.maxWidth / this.aspectRatio;
  9760. if ( pMinWidth > b.minWidth ) {
  9761. b.minWidth = pMinWidth;
  9762. }
  9763. if ( pMinHeight > b.minHeight ) {
  9764. b.minHeight = pMinHeight;
  9765. }
  9766. if ( pMaxWidth < b.maxWidth ) {
  9767. b.maxWidth = pMaxWidth;
  9768. }
  9769. if ( pMaxHeight < b.maxHeight ) {
  9770. b.maxHeight = pMaxHeight;
  9771. }
  9772. }
  9773. this._vBoundaries = b;
  9774. },
  9775. _updateCache: function( data ) {
  9776. this.offset = this.helper.offset();
  9777. if ( this._isNumber( data.left ) ) {
  9778. this.position.left = data.left;
  9779. }
  9780. if ( this._isNumber( data.top ) ) {
  9781. this.position.top = data.top;
  9782. }
  9783. if ( this._isNumber( data.height ) ) {
  9784. this.size.height = data.height;
  9785. }
  9786. if ( this._isNumber( data.width ) ) {
  9787. this.size.width = data.width;
  9788. }
  9789. },
  9790. _updateRatio: function( data ) {
  9791. var cpos = this.position,
  9792. csize = this.size,
  9793. a = this.axis;
  9794. if ( this._isNumber( data.height ) ) {
  9795. data.width = ( data.height * this.aspectRatio );
  9796. } else if ( this._isNumber( data.width ) ) {
  9797. data.height = ( data.width / this.aspectRatio );
  9798. }
  9799. if ( a === "sw" ) {
  9800. data.left = cpos.left + ( csize.width - data.width );
  9801. data.top = null;
  9802. }
  9803. if ( a === "nw" ) {
  9804. data.top = cpos.top + ( csize.height - data.height );
  9805. data.left = cpos.left + ( csize.width - data.width );
  9806. }
  9807. return data;
  9808. },
  9809. _respectSize: function( data ) {
  9810. var o = this._vBoundaries,
  9811. a = this.axis,
  9812. ismaxw = this._isNumber( data.width ) && o.maxWidth && ( o.maxWidth < data.width ),
  9813. ismaxh = this._isNumber( data.height ) && o.maxHeight && ( o.maxHeight < data.height ),
  9814. isminw = this._isNumber( data.width ) && o.minWidth && ( o.minWidth > data.width ),
  9815. isminh = this._isNumber( data.height ) && o.minHeight && ( o.minHeight > data.height ),
  9816. dw = this.originalPosition.left + this.originalSize.width,
  9817. dh = this.originalPosition.top + this.originalSize.height,
  9818. cw = /sw|nw|w/.test( a ), ch = /nw|ne|n/.test( a );
  9819. if ( isminw ) {
  9820. data.width = o.minWidth;
  9821. }
  9822. if ( isminh ) {
  9823. data.height = o.minHeight;
  9824. }
  9825. if ( ismaxw ) {
  9826. data.width = o.maxWidth;
  9827. }
  9828. if ( ismaxh ) {
  9829. data.height = o.maxHeight;
  9830. }
  9831. if ( isminw && cw ) {
  9832. data.left = dw - o.minWidth;
  9833. }
  9834. if ( ismaxw && cw ) {
  9835. data.left = dw - o.maxWidth;
  9836. }
  9837. if ( isminh && ch ) {
  9838. data.top = dh - o.minHeight;
  9839. }
  9840. if ( ismaxh && ch ) {
  9841. data.top = dh - o.maxHeight;
  9842. }
  9843. // Fixing jump error on top/left - bug #2330
  9844. if ( !data.width && !data.height && !data.left && data.top ) {
  9845. data.top = null;
  9846. } else if ( !data.width && !data.height && !data.top && data.left ) {
  9847. data.left = null;
  9848. }
  9849. return data;
  9850. },
  9851. _getPaddingPlusBorderDimensions: function( element ) {
  9852. var i = 0,
  9853. widths = [],
  9854. borders = [
  9855. element.css( "borderTopWidth" ),
  9856. element.css( "borderRightWidth" ),
  9857. element.css( "borderBottomWidth" ),
  9858. element.css( "borderLeftWidth" )
  9859. ],
  9860. paddings = [
  9861. element.css( "paddingTop" ),
  9862. element.css( "paddingRight" ),
  9863. element.css( "paddingBottom" ),
  9864. element.css( "paddingLeft" )
  9865. ];
  9866. for ( ; i < 4; i++ ) {
  9867. widths[ i ] = ( parseFloat( borders[ i ] ) || 0 );
  9868. widths[ i ] += ( parseFloat( paddings[ i ] ) || 0 );
  9869. }
  9870. return {
  9871. height: widths[ 0 ] + widths[ 2 ],
  9872. width: widths[ 1 ] + widths[ 3 ]
  9873. };
  9874. },
  9875. _proportionallyResize: function() {
  9876. if ( !this._proportionallyResizeElements.length ) {
  9877. return;
  9878. }
  9879. var prel,
  9880. i = 0,
  9881. element = this.helper || this.element;
  9882. for ( ; i < this._proportionallyResizeElements.length; i++ ) {
  9883. prel = this._proportionallyResizeElements[ i ];
  9884. // TODO: Seems like a bug to cache this.outerDimensions
  9885. // considering that we are in a loop.
  9886. if ( !this.outerDimensions ) {
  9887. this.outerDimensions = this._getPaddingPlusBorderDimensions( prel );
  9888. }
  9889. prel.css( {
  9890. height: ( element.height() - this.outerDimensions.height ) || 0,
  9891. width: ( element.width() - this.outerDimensions.width ) || 0
  9892. } );
  9893. }
  9894. },
  9895. _renderProxy: function() {
  9896. var el = this.element, o = this.options;
  9897. this.elementOffset = el.offset();
  9898. if ( this._helper ) {
  9899. this.helper = this.helper || $( "<div></div>" ).css( { overflow: "hidden" } );
  9900. this._addClass( this.helper, this._helper );
  9901. this.helper.css( {
  9902. width: this.element.outerWidth(),
  9903. height: this.element.outerHeight(),
  9904. position: "absolute",
  9905. left: this.elementOffset.left + "px",
  9906. top: this.elementOffset.top + "px",
  9907. zIndex: ++o.zIndex //TODO: Don't modify option
  9908. } );
  9909. this.helper
  9910. .appendTo( "body" )
  9911. .disableSelection();
  9912. } else {
  9913. this.helper = this.element;
  9914. }
  9915. },
  9916. _change: {
  9917. e: function( event, dx ) {
  9918. return { width: this.originalSize.width + dx };
  9919. },
  9920. w: function( event, dx ) {
  9921. var cs = this.originalSize, sp = this.originalPosition;
  9922. return { left: sp.left + dx, width: cs.width - dx };
  9923. },
  9924. n: function( event, dx, dy ) {
  9925. var cs = this.originalSize, sp = this.originalPosition;
  9926. return { top: sp.top + dy, height: cs.height - dy };
  9927. },
  9928. s: function( event, dx, dy ) {
  9929. return { height: this.originalSize.height + dy };
  9930. },
  9931. se: function( event, dx, dy ) {
  9932. return $.extend( this._change.s.apply( this, arguments ),
  9933. this._change.e.apply( this, [ event, dx, dy ] ) );
  9934. },
  9935. sw: function( event, dx, dy ) {
  9936. return $.extend( this._change.s.apply( this, arguments ),
  9937. this._change.w.apply( this, [ event, dx, dy ] ) );
  9938. },
  9939. ne: function( event, dx, dy ) {
  9940. return $.extend( this._change.n.apply( this, arguments ),
  9941. this._change.e.apply( this, [ event, dx, dy ] ) );
  9942. },
  9943. nw: function( event, dx, dy ) {
  9944. return $.extend( this._change.n.apply( this, arguments ),
  9945. this._change.w.apply( this, [ event, dx, dy ] ) );
  9946. }
  9947. },
  9948. _propagate: function( n, event ) {
  9949. $.ui.plugin.call( this, n, [ event, this.ui() ] );
  9950. if ( n !== "resize" ) {
  9951. this._trigger( n, event, this.ui() );
  9952. }
  9953. },
  9954. plugins: {},
  9955. ui: function() {
  9956. return {
  9957. originalElement: this.originalElement,
  9958. element: this.element,
  9959. helper: this.helper,
  9960. position: this.position,
  9961. size: this.size,
  9962. originalSize: this.originalSize,
  9963. originalPosition: this.originalPosition
  9964. };
  9965. }
  9966. } );
  9967. /*
  9968. * Resizable Extensions
  9969. */
  9970. $.ui.plugin.add( "resizable", "animate", {
  9971. stop: function( event ) {
  9972. var that = $( this ).resizable( "instance" ),
  9973. o = that.options,
  9974. pr = that._proportionallyResizeElements,
  9975. ista = pr.length && ( /textarea/i ).test( pr[ 0 ].nodeName ),
  9976. soffseth = ista && that._hasScroll( pr[ 0 ], "left" ) ? 0 : that.sizeDiff.height,
  9977. soffsetw = ista ? 0 : that.sizeDiff.width,
  9978. style = {
  9979. width: ( that.size.width - soffsetw ),
  9980. height: ( that.size.height - soffseth )
  9981. },
  9982. left = ( parseFloat( that.element.css( "left" ) ) +
  9983. ( that.position.left - that.originalPosition.left ) ) || null,
  9984. top = ( parseFloat( that.element.css( "top" ) ) +
  9985. ( that.position.top - that.originalPosition.top ) ) || null;
  9986. that.element.animate(
  9987. $.extend( style, top && left ? { top: top, left: left } : {} ), {
  9988. duration: o.animateDuration,
  9989. easing: o.animateEasing,
  9990. step: function() {
  9991. var data = {
  9992. width: parseFloat( that.element.css( "width" ) ),
  9993. height: parseFloat( that.element.css( "height" ) ),
  9994. top: parseFloat( that.element.css( "top" ) ),
  9995. left: parseFloat( that.element.css( "left" ) )
  9996. };
  9997. if ( pr && pr.length ) {
  9998. $( pr[ 0 ] ).css( { width: data.width, height: data.height } );
  9999. }
  10000. // Propagating resize, and updating values for each animation step
  10001. that._updateCache( data );
  10002. that._propagate( "resize", event );
  10003. }
  10004. }
  10005. );
  10006. }
  10007. } );
  10008. $.ui.plugin.add( "resizable", "containment", {
  10009. start: function() {
  10010. var element, p, co, ch, cw, width, height,
  10011. that = $( this ).resizable( "instance" ),
  10012. o = that.options,
  10013. el = that.element,
  10014. oc = o.containment,
  10015. ce = ( oc instanceof $ ) ?
  10016. oc.get( 0 ) :
  10017. ( /parent/.test( oc ) ) ? el.parent().get( 0 ) : oc;
  10018. if ( !ce ) {
  10019. return;
  10020. }
  10021. that.containerElement = $( ce );
  10022. if ( /document/.test( oc ) || oc === document ) {
  10023. that.containerOffset = {
  10024. left: 0,
  10025. top: 0
  10026. };
  10027. that.containerPosition = {
  10028. left: 0,
  10029. top: 0
  10030. };
  10031. that.parentData = {
  10032. element: $( document ),
  10033. left: 0,
  10034. top: 0,
  10035. width: $( document ).width(),
  10036. height: $( document ).height() || document.body.parentNode.scrollHeight
  10037. };
  10038. } else {
  10039. element = $( ce );
  10040. p = [];
  10041. $( [ "Top", "Right", "Left", "Bottom" ] ).each( function( i, name ) {
  10042. p[ i ] = that._num( element.css( "padding" + name ) );
  10043. } );
  10044. that.containerOffset = element.offset();
  10045. that.containerPosition = element.position();
  10046. that.containerSize = {
  10047. height: ( element.innerHeight() - p[ 3 ] ),
  10048. width: ( element.innerWidth() - p[ 1 ] )
  10049. };
  10050. co = that.containerOffset;
  10051. ch = that.containerSize.height;
  10052. cw = that.containerSize.width;
  10053. width = ( that._hasScroll( ce, "left" ) ? ce.scrollWidth : cw );
  10054. height = ( that._hasScroll( ce ) ? ce.scrollHeight : ch );
  10055. that.parentData = {
  10056. element: ce,
  10057. left: co.left,
  10058. top: co.top,
  10059. width: width,
  10060. height: height
  10061. };
  10062. }
  10063. },
  10064. resize: function( event ) {
  10065. var woset, hoset, isParent, isOffsetRelative,
  10066. that = $( this ).resizable( "instance" ),
  10067. o = that.options,
  10068. co = that.containerOffset,
  10069. cp = that.position,
  10070. pRatio = that._aspectRatio || event.shiftKey,
  10071. cop = {
  10072. top: 0,
  10073. left: 0
  10074. },
  10075. ce = that.containerElement,
  10076. continueResize = true;
  10077. if ( ce[ 0 ] !== document && ( /static/ ).test( ce.css( "position" ) ) ) {
  10078. cop = co;
  10079. }
  10080. if ( cp.left < ( that._helper ? co.left : 0 ) ) {
  10081. that.size.width = that.size.width +
  10082. ( that._helper ?
  10083. ( that.position.left - co.left ) :
  10084. ( that.position.left - cop.left ) );
  10085. if ( pRatio ) {
  10086. that.size.height = that.size.width / that.aspectRatio;
  10087. continueResize = false;
  10088. }
  10089. that.position.left = o.helper ? co.left : 0;
  10090. }
  10091. if ( cp.top < ( that._helper ? co.top : 0 ) ) {
  10092. that.size.height = that.size.height +
  10093. ( that._helper ?
  10094. ( that.position.top - co.top ) :
  10095. that.position.top );
  10096. if ( pRatio ) {
  10097. that.size.width = that.size.height * that.aspectRatio;
  10098. continueResize = false;
  10099. }
  10100. that.position.top = that._helper ? co.top : 0;
  10101. }
  10102. isParent = that.containerElement.get( 0 ) === that.element.parent().get( 0 );
  10103. isOffsetRelative = /relative|absolute/.test( that.containerElement.css( "position" ) );
  10104. if ( isParent && isOffsetRelative ) {
  10105. that.offset.left = that.parentData.left + that.position.left;
  10106. that.offset.top = that.parentData.top + that.position.top;
  10107. } else {
  10108. that.offset.left = that.element.offset().left;
  10109. that.offset.top = that.element.offset().top;
  10110. }
  10111. woset = Math.abs( that.sizeDiff.width +
  10112. ( that._helper ?
  10113. that.offset.left - cop.left :
  10114. ( that.offset.left - co.left ) ) );
  10115. hoset = Math.abs( that.sizeDiff.height +
  10116. ( that._helper ?
  10117. that.offset.top - cop.top :
  10118. ( that.offset.top - co.top ) ) );
  10119. if ( woset + that.size.width >= that.parentData.width ) {
  10120. that.size.width = that.parentData.width - woset;
  10121. if ( pRatio ) {
  10122. that.size.height = that.size.width / that.aspectRatio;
  10123. continueResize = false;
  10124. }
  10125. }
  10126. if ( hoset + that.size.height >= that.parentData.height ) {
  10127. that.size.height = that.parentData.height - hoset;
  10128. if ( pRatio ) {
  10129. that.size.width = that.size.height * that.aspectRatio;
  10130. continueResize = false;
  10131. }
  10132. }
  10133. if ( !continueResize ) {
  10134. that.position.left = that.prevPosition.left;
  10135. that.position.top = that.prevPosition.top;
  10136. that.size.width = that.prevSize.width;
  10137. that.size.height = that.prevSize.height;
  10138. }
  10139. },
  10140. stop: function() {
  10141. var that = $( this ).resizable( "instance" ),
  10142. o = that.options,
  10143. co = that.containerOffset,
  10144. cop = that.containerPosition,
  10145. ce = that.containerElement,
  10146. helper = $( that.helper ),
  10147. ho = helper.offset(),
  10148. w = helper.outerWidth() - that.sizeDiff.width,
  10149. h = helper.outerHeight() - that.sizeDiff.height;
  10150. if ( that._helper && !o.animate && ( /relative/ ).test( ce.css( "position" ) ) ) {
  10151. $( this ).css( {
  10152. left: ho.left - cop.left - co.left,
  10153. width: w,
  10154. height: h
  10155. } );
  10156. }
  10157. if ( that._helper && !o.animate && ( /static/ ).test( ce.css( "position" ) ) ) {
  10158. $( this ).css( {
  10159. left: ho.left - cop.left - co.left,
  10160. width: w,
  10161. height: h
  10162. } );
  10163. }
  10164. }
  10165. } );
  10166. $.ui.plugin.add( "resizable", "alsoResize", {
  10167. start: function() {
  10168. var that = $( this ).resizable( "instance" ),
  10169. o = that.options;
  10170. $( o.alsoResize ).each( function() {
  10171. var el = $( this );
  10172. el.data( "ui-resizable-alsoresize", {
  10173. width: parseFloat( el.width() ), height: parseFloat( el.height() ),
  10174. left: parseFloat( el.css( "left" ) ), top: parseFloat( el.css( "top" ) )
  10175. } );
  10176. } );
  10177. },
  10178. resize: function( event, ui ) {
  10179. var that = $( this ).resizable( "instance" ),
  10180. o = that.options,
  10181. os = that.originalSize,
  10182. op = that.originalPosition,
  10183. delta = {
  10184. height: ( that.size.height - os.height ) || 0,
  10185. width: ( that.size.width - os.width ) || 0,
  10186. top: ( that.position.top - op.top ) || 0,
  10187. left: ( that.position.left - op.left ) || 0
  10188. };
  10189. $( o.alsoResize ).each( function() {
  10190. var el = $( this ), start = $( this ).data( "ui-resizable-alsoresize" ), style = {},
  10191. css = el.parents( ui.originalElement[ 0 ] ).length ?
  10192. [ "width", "height" ] :
  10193. [ "width", "height", "top", "left" ];
  10194. $.each( css, function( i, prop ) {
  10195. var sum = ( start[ prop ] || 0 ) + ( delta[ prop ] || 0 );
  10196. if ( sum && sum >= 0 ) {
  10197. style[ prop ] = sum || null;
  10198. }
  10199. } );
  10200. el.css( style );
  10201. } );
  10202. },
  10203. stop: function() {
  10204. $( this ).removeData( "ui-resizable-alsoresize" );
  10205. }
  10206. } );
  10207. $.ui.plugin.add( "resizable", "ghost", {
  10208. start: function() {
  10209. var that = $( this ).resizable( "instance" ), cs = that.size;
  10210. that.ghost = that.originalElement.clone();
  10211. that.ghost.css( {
  10212. opacity: 0.25,
  10213. display: "block",
  10214. position: "relative",
  10215. height: cs.height,
  10216. width: cs.width,
  10217. margin: 0,
  10218. left: 0,
  10219. top: 0
  10220. } );
  10221. that._addClass( that.ghost, "ui-resizable-ghost" );
  10222. // DEPRECATED
  10223. // TODO: remove after 1.12
  10224. if ( $.uiBackCompat !== false && typeof that.options.ghost === "string" ) {
  10225. // Ghost option
  10226. that.ghost.addClass( this.options.ghost );
  10227. }
  10228. that.ghost.appendTo( that.helper );
  10229. },
  10230. resize: function() {
  10231. var that = $( this ).resizable( "instance" );
  10232. if ( that.ghost ) {
  10233. that.ghost.css( {
  10234. position: "relative",
  10235. height: that.size.height,
  10236. width: that.size.width
  10237. } );
  10238. }
  10239. },
  10240. stop: function() {
  10241. var that = $( this ).resizable( "instance" );
  10242. if ( that.ghost && that.helper ) {
  10243. that.helper.get( 0 ).removeChild( that.ghost.get( 0 ) );
  10244. }
  10245. }
  10246. } );
  10247. $.ui.plugin.add( "resizable", "grid", {
  10248. resize: function() {
  10249. var outerDimensions,
  10250. that = $( this ).resizable( "instance" ),
  10251. o = that.options,
  10252. cs = that.size,
  10253. os = that.originalSize,
  10254. op = that.originalPosition,
  10255. a = that.axis,
  10256. grid = typeof o.grid === "number" ? [ o.grid, o.grid ] : o.grid,
  10257. gridX = ( grid[ 0 ] || 1 ),
  10258. gridY = ( grid[ 1 ] || 1 ),
  10259. ox = Math.round( ( cs.width - os.width ) / gridX ) * gridX,
  10260. oy = Math.round( ( cs.height - os.height ) / gridY ) * gridY,
  10261. newWidth = os.width + ox,
  10262. newHeight = os.height + oy,
  10263. isMaxWidth = o.maxWidth && ( o.maxWidth < newWidth ),
  10264. isMaxHeight = o.maxHeight && ( o.maxHeight < newHeight ),
  10265. isMinWidth = o.minWidth && ( o.minWidth > newWidth ),
  10266. isMinHeight = o.minHeight && ( o.minHeight > newHeight );
  10267. o.grid = grid;
  10268. if ( isMinWidth ) {
  10269. newWidth += gridX;
  10270. }
  10271. if ( isMinHeight ) {
  10272. newHeight += gridY;
  10273. }
  10274. if ( isMaxWidth ) {
  10275. newWidth -= gridX;
  10276. }
  10277. if ( isMaxHeight ) {
  10278. newHeight -= gridY;
  10279. }
  10280. if ( /^(se|s|e)$/.test( a ) ) {
  10281. that.size.width = newWidth;
  10282. that.size.height = newHeight;
  10283. } else if ( /^(ne)$/.test( a ) ) {
  10284. that.size.width = newWidth;
  10285. that.size.height = newHeight;
  10286. that.position.top = op.top - oy;
  10287. } else if ( /^(sw)$/.test( a ) ) {
  10288. that.size.width = newWidth;
  10289. that.size.height = newHeight;
  10290. that.position.left = op.left - ox;
  10291. } else {
  10292. if ( newHeight - gridY <= 0 || newWidth - gridX <= 0 ) {
  10293. outerDimensions = that._getPaddingPlusBorderDimensions( this );
  10294. }
  10295. if ( newHeight - gridY > 0 ) {
  10296. that.size.height = newHeight;
  10297. that.position.top = op.top - oy;
  10298. } else {
  10299. newHeight = gridY - outerDimensions.height;
  10300. that.size.height = newHeight;
  10301. that.position.top = op.top + os.height - newHeight;
  10302. }
  10303. if ( newWidth - gridX > 0 ) {
  10304. that.size.width = newWidth;
  10305. that.position.left = op.left - ox;
  10306. } else {
  10307. newWidth = gridX - outerDimensions.width;
  10308. that.size.width = newWidth;
  10309. that.position.left = op.left + os.width - newWidth;
  10310. }
  10311. }
  10312. }
  10313. } );
  10314. var widgetsResizable = $.ui.resizable;
  10315. /*!
  10316. * jQuery UI Dialog 1.13.2
  10317. * http://jqueryui.com
  10318. *
  10319. * Copyright jQuery Foundation and other contributors
  10320. * Released under the MIT license.
  10321. * http://jquery.org/license
  10322. */
  10323. //>>label: Dialog
  10324. //>>group: Widgets
  10325. //>>description: Displays customizable dialog windows.
  10326. //>>docs: http://api.jqueryui.com/dialog/
  10327. //>>demos: http://jqueryui.com/dialog/
  10328. //>>css.structure: ../../themes/base/core.css
  10329. //>>css.structure: ../../themes/base/dialog.css
  10330. //>>css.theme: ../../themes/base/theme.css
  10331. $.widget( "ui.dialog", {
  10332. version: "1.13.2",
  10333. options: {
  10334. appendTo: "body",
  10335. autoOpen: true,
  10336. buttons: [],
  10337. classes: {
  10338. "ui-dialog": "ui-corner-all",
  10339. "ui-dialog-titlebar": "ui-corner-all"
  10340. },
  10341. closeOnEscape: true,
  10342. closeText: "Close",
  10343. draggable: true,
  10344. hide: null,
  10345. height: "auto",
  10346. maxHeight: null,
  10347. maxWidth: null,
  10348. minHeight: 150,
  10349. minWidth: 150,
  10350. modal: false,
  10351. position: {
  10352. my: "center",
  10353. at: "center",
  10354. of: window,
  10355. collision: "fit",
  10356. // Ensure the titlebar is always visible
  10357. using: function( pos ) {
  10358. var topOffset = $( this ).css( pos ).offset().top;
  10359. if ( topOffset < 0 ) {
  10360. $( this ).css( "top", pos.top - topOffset );
  10361. }
  10362. }
  10363. },
  10364. resizable: true,
  10365. show: null,
  10366. title: null,
  10367. width: 300,
  10368. // Callbacks
  10369. beforeClose: null,
  10370. close: null,
  10371. drag: null,
  10372. dragStart: null,
  10373. dragStop: null,
  10374. focus: null,
  10375. open: null,
  10376. resize: null,
  10377. resizeStart: null,
  10378. resizeStop: null
  10379. },
  10380. sizeRelatedOptions: {
  10381. buttons: true,
  10382. height: true,
  10383. maxHeight: true,
  10384. maxWidth: true,
  10385. minHeight: true,
  10386. minWidth: true,
  10387. width: true
  10388. },
  10389. resizableRelatedOptions: {
  10390. maxHeight: true,
  10391. maxWidth: true,
  10392. minHeight: true,
  10393. minWidth: true
  10394. },
  10395. _create: function() {
  10396. this.originalCss = {
  10397. display: this.element[ 0 ].style.display,
  10398. width: this.element[ 0 ].style.width,
  10399. minHeight: this.element[ 0 ].style.minHeight,
  10400. maxHeight: this.element[ 0 ].style.maxHeight,
  10401. height: this.element[ 0 ].style.height
  10402. };
  10403. this.originalPosition = {
  10404. parent: this.element.parent(),
  10405. index: this.element.parent().children().index( this.element )
  10406. };
  10407. this.originalTitle = this.element.attr( "title" );
  10408. if ( this.options.title == null && this.originalTitle != null ) {
  10409. this.options.title = this.originalTitle;
  10410. }
  10411. // Dialogs can't be disabled
  10412. if ( this.options.disabled ) {
  10413. this.options.disabled = false;
  10414. }
  10415. this._createWrapper();
  10416. this.element
  10417. .show()
  10418. .removeAttr( "title" )
  10419. .appendTo( this.uiDialog );
  10420. this._addClass( "ui-dialog-content", "ui-widget-content" );
  10421. this._createTitlebar();
  10422. this._createButtonPane();
  10423. if ( this.options.draggable && $.fn.draggable ) {
  10424. this._makeDraggable();
  10425. }
  10426. if ( this.options.resizable && $.fn.resizable ) {
  10427. this._makeResizable();
  10428. }
  10429. this._isOpen = false;
  10430. this._trackFocus();
  10431. },
  10432. _init: function() {
  10433. if ( this.options.autoOpen ) {
  10434. this.open();
  10435. }
  10436. },
  10437. _appendTo: function() {
  10438. var element = this.options.appendTo;
  10439. if ( element && ( element.jquery || element.nodeType ) ) {
  10440. return $( element );
  10441. }
  10442. return this.document.find( element || "body" ).eq( 0 );
  10443. },
  10444. _destroy: function() {
  10445. var next,
  10446. originalPosition = this.originalPosition;
  10447. this._untrackInstance();
  10448. this._destroyOverlay();
  10449. this.element
  10450. .removeUniqueId()
  10451. .css( this.originalCss )
  10452. // Without detaching first, the following becomes really slow
  10453. .detach();
  10454. this.uiDialog.remove();
  10455. if ( this.originalTitle ) {
  10456. this.element.attr( "title", this.originalTitle );
  10457. }
  10458. next = originalPosition.parent.children().eq( originalPosition.index );
  10459. // Don't try to place the dialog next to itself (#8613)
  10460. if ( next.length && next[ 0 ] !== this.element[ 0 ] ) {
  10461. next.before( this.element );
  10462. } else {
  10463. originalPosition.parent.append( this.element );
  10464. }
  10465. },
  10466. widget: function() {
  10467. return this.uiDialog;
  10468. },
  10469. disable: $.noop,
  10470. enable: $.noop,
  10471. close: function( event ) {
  10472. var that = this;
  10473. if ( !this._isOpen || this._trigger( "beforeClose", event ) === false ) {
  10474. return;
  10475. }
  10476. this._isOpen = false;
  10477. this._focusedElement = null;
  10478. this._destroyOverlay();
  10479. this._untrackInstance();
  10480. if ( !this.opener.filter( ":focusable" ).trigger( "focus" ).length ) {
  10481. // Hiding a focused element doesn't trigger blur in WebKit
  10482. // so in case we have nothing to focus on, explicitly blur the active element
  10483. // https://bugs.webkit.org/show_bug.cgi?id=47182
  10484. $.ui.safeBlur( $.ui.safeActiveElement( this.document[ 0 ] ) );
  10485. }
  10486. this._hide( this.uiDialog, this.options.hide, function() {
  10487. that._trigger( "close", event );
  10488. } );
  10489. },
  10490. isOpen: function() {
  10491. return this._isOpen;
  10492. },
  10493. moveToTop: function() {
  10494. this._moveToTop();
  10495. },
  10496. _moveToTop: function( event, silent ) {
  10497. var moved = false,
  10498. zIndices = this.uiDialog.siblings( ".ui-front:visible" ).map( function() {
  10499. return +$( this ).css( "z-index" );
  10500. } ).get(),
  10501. zIndexMax = Math.max.apply( null, zIndices );
  10502. if ( zIndexMax >= +this.uiDialog.css( "z-index" ) ) {
  10503. this.uiDialog.css( "z-index", zIndexMax + 1 );
  10504. moved = true;
  10505. }
  10506. if ( moved && !silent ) {
  10507. this._trigger( "focus", event );
  10508. }
  10509. return moved;
  10510. },
  10511. open: function() {
  10512. var that = this;
  10513. if ( this._isOpen ) {
  10514. if ( this._moveToTop() ) {
  10515. this._focusTabbable();
  10516. }
  10517. return;
  10518. }
  10519. this._isOpen = true;
  10520. this.opener = $( $.ui.safeActiveElement( this.document[ 0 ] ) );
  10521. this._size();
  10522. this._position();
  10523. this._createOverlay();
  10524. this._moveToTop( null, true );
  10525. // Ensure the overlay is moved to the top with the dialog, but only when
  10526. // opening. The overlay shouldn't move after the dialog is open so that
  10527. // modeless dialogs opened after the modal dialog stack properly.
  10528. if ( this.overlay ) {
  10529. this.overlay.css( "z-index", this.uiDialog.css( "z-index" ) - 1 );
  10530. }
  10531. this._show( this.uiDialog, this.options.show, function() {
  10532. that._focusTabbable();
  10533. that._trigger( "focus" );
  10534. } );
  10535. // Track the dialog immediately upon opening in case a focus event
  10536. // somehow occurs outside of the dialog before an element inside the
  10537. // dialog is focused (#10152)
  10538. this._makeFocusTarget();
  10539. this._trigger( "open" );
  10540. },
  10541. _focusTabbable: function() {
  10542. // Set focus to the first match:
  10543. // 1. An element that was focused previously
  10544. // 2. First element inside the dialog matching [autofocus]
  10545. // 3. Tabbable element inside the content element
  10546. // 4. Tabbable element inside the buttonpane
  10547. // 5. The close button
  10548. // 6. The dialog itself
  10549. var hasFocus = this._focusedElement;
  10550. if ( !hasFocus ) {
  10551. hasFocus = this.element.find( "[autofocus]" );
  10552. }
  10553. if ( !hasFocus.length ) {
  10554. hasFocus = this.element.find( ":tabbable" );
  10555. }
  10556. if ( !hasFocus.length ) {
  10557. hasFocus = this.uiDialogButtonPane.find( ":tabbable" );
  10558. }
  10559. if ( !hasFocus.length ) {
  10560. hasFocus = this.uiDialogTitlebarClose.filter( ":tabbable" );
  10561. }
  10562. if ( !hasFocus.length ) {
  10563. hasFocus = this.uiDialog;
  10564. }
  10565. hasFocus.eq( 0 ).trigger( "focus" );
  10566. },
  10567. _restoreTabbableFocus: function() {
  10568. var activeElement = $.ui.safeActiveElement( this.document[ 0 ] ),
  10569. isActive = this.uiDialog[ 0 ] === activeElement ||
  10570. $.contains( this.uiDialog[ 0 ], activeElement );
  10571. if ( !isActive ) {
  10572. this._focusTabbable();
  10573. }
  10574. },
  10575. _keepFocus: function( event ) {
  10576. event.preventDefault();
  10577. this._restoreTabbableFocus();
  10578. // support: IE
  10579. // IE <= 8 doesn't prevent moving focus even with event.preventDefault()
  10580. // so we check again later
  10581. this._delay( this._restoreTabbableFocus );
  10582. },
  10583. _createWrapper: function() {
  10584. this.uiDialog = $( "<div>" )
  10585. .hide()
  10586. .attr( {
  10587. // Setting tabIndex makes the div focusable
  10588. tabIndex: -1,
  10589. role: "dialog"
  10590. } )
  10591. .appendTo( this._appendTo() );
  10592. this._addClass( this.uiDialog, "ui-dialog", "ui-widget ui-widget-content ui-front" );
  10593. this._on( this.uiDialog, {
  10594. keydown: function( event ) {
  10595. if ( this.options.closeOnEscape && !event.isDefaultPrevented() && event.keyCode &&
  10596. event.keyCode === $.ui.keyCode.ESCAPE ) {
  10597. event.preventDefault();
  10598. this.close( event );
  10599. return;
  10600. }
  10601. // Prevent tabbing out of dialogs
  10602. if ( event.keyCode !== $.ui.keyCode.TAB || event.isDefaultPrevented() ) {
  10603. return;
  10604. }
  10605. var tabbables = this.uiDialog.find( ":tabbable" ),
  10606. first = tabbables.first(),
  10607. last = tabbables.last();
  10608. if ( ( event.target === last[ 0 ] || event.target === this.uiDialog[ 0 ] ) &&
  10609. !event.shiftKey ) {
  10610. this._delay( function() {
  10611. first.trigger( "focus" );
  10612. } );
  10613. event.preventDefault();
  10614. } else if ( ( event.target === first[ 0 ] ||
  10615. event.target === this.uiDialog[ 0 ] ) && event.shiftKey ) {
  10616. this._delay( function() {
  10617. last.trigger( "focus" );
  10618. } );
  10619. event.preventDefault();
  10620. }
  10621. },
  10622. mousedown: function( event ) {
  10623. if ( this._moveToTop( event ) ) {
  10624. this._focusTabbable();
  10625. }
  10626. }
  10627. } );
  10628. // We assume that any existing aria-describedby attribute means
  10629. // that the dialog content is marked up properly
  10630. // otherwise we brute force the content as the description
  10631. if ( !this.element.find( "[aria-describedby]" ).length ) {
  10632. this.uiDialog.attr( {
  10633. "aria-describedby": this.element.uniqueId().attr( "id" )
  10634. } );
  10635. }
  10636. },
  10637. _createTitlebar: function() {
  10638. var uiDialogTitle;
  10639. this.uiDialogTitlebar = $( "<div>" );
  10640. this._addClass( this.uiDialogTitlebar,
  10641. "ui-dialog-titlebar", "ui-widget-header ui-helper-clearfix" );
  10642. this._on( this.uiDialogTitlebar, {
  10643. mousedown: function( event ) {
  10644. // Don't prevent click on close button (#8838)
  10645. // Focusing a dialog that is partially scrolled out of view
  10646. // causes the browser to scroll it into view, preventing the click event
  10647. if ( !$( event.target ).closest( ".ui-dialog-titlebar-close" ) ) {
  10648. // Dialog isn't getting focus when dragging (#8063)
  10649. this.uiDialog.trigger( "focus" );
  10650. }
  10651. }
  10652. } );
  10653. // Support: IE
  10654. // Use type="button" to prevent enter keypresses in textboxes from closing the
  10655. // dialog in IE (#9312)
  10656. this.uiDialogTitlebarClose = $( "<button type='button'></button>" )
  10657. .button( {
  10658. label: $( "<a>" ).text( this.options.closeText ).html(),
  10659. icon: "ui-icon-closethick",
  10660. showLabel: false
  10661. } )
  10662. .appendTo( this.uiDialogTitlebar );
  10663. this._addClass( this.uiDialogTitlebarClose, "ui-dialog-titlebar-close" );
  10664. this._on( this.uiDialogTitlebarClose, {
  10665. click: function( event ) {
  10666. event.preventDefault();
  10667. this.close( event );
  10668. }
  10669. } );
  10670. uiDialogTitle = $( "<span>" ).uniqueId().prependTo( this.uiDialogTitlebar );
  10671. this._addClass( uiDialogTitle, "ui-dialog-title" );
  10672. this._title( uiDialogTitle );
  10673. this.uiDialogTitlebar.prependTo( this.uiDialog );
  10674. this.uiDialog.attr( {
  10675. "aria-labelledby": uiDialogTitle.attr( "id" )
  10676. } );
  10677. },
  10678. _title: function( title ) {
  10679. if ( this.options.title ) {
  10680. title.text( this.options.title );
  10681. } else {
  10682. title.html( "&#160;" );
  10683. }
  10684. },
  10685. _createButtonPane: function() {
  10686. this.uiDialogButtonPane = $( "<div>" );
  10687. this._addClass( this.uiDialogButtonPane, "ui-dialog-buttonpane",
  10688. "ui-widget-content ui-helper-clearfix" );
  10689. this.uiButtonSet = $( "<div>" )
  10690. .appendTo( this.uiDialogButtonPane );
  10691. this._addClass( this.uiButtonSet, "ui-dialog-buttonset" );
  10692. this._createButtons();
  10693. },
  10694. _createButtons: function() {
  10695. var that = this,
  10696. buttons = this.options.buttons;
  10697. // If we already have a button pane, remove it
  10698. this.uiDialogButtonPane.remove();
  10699. this.uiButtonSet.empty();
  10700. if ( $.isEmptyObject( buttons ) || ( Array.isArray( buttons ) && !buttons.length ) ) {
  10701. this._removeClass( this.uiDialog, "ui-dialog-buttons" );
  10702. return;
  10703. }
  10704. $.each( buttons, function( name, props ) {
  10705. var click, buttonOptions;
  10706. props = typeof props === "function" ?
  10707. { click: props, text: name } :
  10708. props;
  10709. // Default to a non-submitting button
  10710. props = $.extend( { type: "button" }, props );
  10711. // Change the context for the click callback to be the main element
  10712. click = props.click;
  10713. buttonOptions = {
  10714. icon: props.icon,
  10715. iconPosition: props.iconPosition,
  10716. showLabel: props.showLabel,
  10717. // Deprecated options
  10718. icons: props.icons,
  10719. text: props.text
  10720. };
  10721. delete props.click;
  10722. delete props.icon;
  10723. delete props.iconPosition;
  10724. delete props.showLabel;
  10725. // Deprecated options
  10726. delete props.icons;
  10727. if ( typeof props.text === "boolean" ) {
  10728. delete props.text;
  10729. }
  10730. $( "<button></button>", props )
  10731. .button( buttonOptions )
  10732. .appendTo( that.uiButtonSet )
  10733. .on( "click", function() {
  10734. click.apply( that.element[ 0 ], arguments );
  10735. } );
  10736. } );
  10737. this._addClass( this.uiDialog, "ui-dialog-buttons" );
  10738. this.uiDialogButtonPane.appendTo( this.uiDialog );
  10739. },
  10740. _makeDraggable: function() {
  10741. var that = this,
  10742. options = this.options;
  10743. function filteredUi( ui ) {
  10744. return {
  10745. position: ui.position,
  10746. offset: ui.offset
  10747. };
  10748. }
  10749. this.uiDialog.draggable( {
  10750. cancel: ".ui-dialog-content, .ui-dialog-titlebar-close",
  10751. handle: ".ui-dialog-titlebar",
  10752. containment: "document",
  10753. start: function( event, ui ) {
  10754. that._addClass( $( this ), "ui-dialog-dragging" );
  10755. that._blockFrames();
  10756. that._trigger( "dragStart", event, filteredUi( ui ) );
  10757. },
  10758. drag: function( event, ui ) {
  10759. that._trigger( "drag", event, filteredUi( ui ) );
  10760. },
  10761. stop: function( event, ui ) {
  10762. var left = ui.offset.left - that.document.scrollLeft(),
  10763. top = ui.offset.top - that.document.scrollTop();
  10764. options.position = {
  10765. my: "left top",
  10766. at: "left" + ( left >= 0 ? "+" : "" ) + left + " " +
  10767. "top" + ( top >= 0 ? "+" : "" ) + top,
  10768. of: that.window
  10769. };
  10770. that._removeClass( $( this ), "ui-dialog-dragging" );
  10771. that._unblockFrames();
  10772. that._trigger( "dragStop", event, filteredUi( ui ) );
  10773. }
  10774. } );
  10775. },
  10776. _makeResizable: function() {
  10777. var that = this,
  10778. options = this.options,
  10779. handles = options.resizable,
  10780. // .ui-resizable has position: relative defined in the stylesheet
  10781. // but dialogs have to use absolute or fixed positioning
  10782. position = this.uiDialog.css( "position" ),
  10783. resizeHandles = typeof handles === "string" ?
  10784. handles :
  10785. "n,e,s,w,se,sw,ne,nw";
  10786. function filteredUi( ui ) {
  10787. return {
  10788. originalPosition: ui.originalPosition,
  10789. originalSize: ui.originalSize,
  10790. position: ui.position,
  10791. size: ui.size
  10792. };
  10793. }
  10794. this.uiDialog.resizable( {
  10795. cancel: ".ui-dialog-content",
  10796. containment: "document",
  10797. alsoResize: this.element,
  10798. maxWidth: options.maxWidth,
  10799. maxHeight: options.maxHeight,
  10800. minWidth: options.minWidth,
  10801. minHeight: this._minHeight(),
  10802. handles: resizeHandles,
  10803. start: function( event, ui ) {
  10804. that._addClass( $( this ), "ui-dialog-resizing" );
  10805. that._blockFrames();
  10806. that._trigger( "resizeStart", event, filteredUi( ui ) );
  10807. },
  10808. resize: function( event, ui ) {
  10809. that._trigger( "resize", event, filteredUi( ui ) );
  10810. },
  10811. stop: function( event, ui ) {
  10812. var offset = that.uiDialog.offset(),
  10813. left = offset.left - that.document.scrollLeft(),
  10814. top = offset.top - that.document.scrollTop();
  10815. options.height = that.uiDialog.height();
  10816. options.width = that.uiDialog.width();
  10817. options.position = {
  10818. my: "left top",
  10819. at: "left" + ( left >= 0 ? "+" : "" ) + left + " " +
  10820. "top" + ( top >= 0 ? "+" : "" ) + top,
  10821. of: that.window
  10822. };
  10823. that._removeClass( $( this ), "ui-dialog-resizing" );
  10824. that._unblockFrames();
  10825. that._trigger( "resizeStop", event, filteredUi( ui ) );
  10826. }
  10827. } )
  10828. .css( "position", position );
  10829. },
  10830. _trackFocus: function() {
  10831. this._on( this.widget(), {
  10832. focusin: function( event ) {
  10833. this._makeFocusTarget();
  10834. this._focusedElement = $( event.target );
  10835. }
  10836. } );
  10837. },
  10838. _makeFocusTarget: function() {
  10839. this._untrackInstance();
  10840. this._trackingInstances().unshift( this );
  10841. },
  10842. _untrackInstance: function() {
  10843. var instances = this._trackingInstances(),
  10844. exists = $.inArray( this, instances );
  10845. if ( exists !== -1 ) {
  10846. instances.splice( exists, 1 );
  10847. }
  10848. },
  10849. _trackingInstances: function() {
  10850. var instances = this.document.data( "ui-dialog-instances" );
  10851. if ( !instances ) {
  10852. instances = [];
  10853. this.document.data( "ui-dialog-instances", instances );
  10854. }
  10855. return instances;
  10856. },
  10857. _minHeight: function() {
  10858. var options = this.options;
  10859. return options.height === "auto" ?
  10860. options.minHeight :
  10861. Math.min( options.minHeight, options.height );
  10862. },
  10863. _position: function() {
  10864. // Need to show the dialog to get the actual offset in the position plugin
  10865. var isVisible = this.uiDialog.is( ":visible" );
  10866. if ( !isVisible ) {
  10867. this.uiDialog.show();
  10868. }
  10869. this.uiDialog.position( this.options.position );
  10870. if ( !isVisible ) {
  10871. this.uiDialog.hide();
  10872. }
  10873. },
  10874. _setOptions: function( options ) {
  10875. var that = this,
  10876. resize = false,
  10877. resizableOptions = {};
  10878. $.each( options, function( key, value ) {
  10879. that._setOption( key, value );
  10880. if ( key in that.sizeRelatedOptions ) {
  10881. resize = true;
  10882. }
  10883. if ( key in that.resizableRelatedOptions ) {
  10884. resizableOptions[ key ] = value;
  10885. }
  10886. } );
  10887. if ( resize ) {
  10888. this._size();
  10889. this._position();
  10890. }
  10891. if ( this.uiDialog.is( ":data(ui-resizable)" ) ) {
  10892. this.uiDialog.resizable( "option", resizableOptions );
  10893. }
  10894. },
  10895. _setOption: function( key, value ) {
  10896. var isDraggable, isResizable,
  10897. uiDialog = this.uiDialog;
  10898. if ( key === "disabled" ) {
  10899. return;
  10900. }
  10901. this._super( key, value );
  10902. if ( key === "appendTo" ) {
  10903. this.uiDialog.appendTo( this._appendTo() );
  10904. }
  10905. if ( key === "buttons" ) {
  10906. this._createButtons();
  10907. }
  10908. if ( key === "closeText" ) {
  10909. this.uiDialogTitlebarClose.button( {
  10910. // Ensure that we always pass a string
  10911. label: $( "<a>" ).text( "" + this.options.closeText ).html()
  10912. } );
  10913. }
  10914. if ( key === "draggable" ) {
  10915. isDraggable = uiDialog.is( ":data(ui-draggable)" );
  10916. if ( isDraggable && !value ) {
  10917. uiDialog.draggable( "destroy" );
  10918. }
  10919. if ( !isDraggable && value ) {
  10920. this._makeDraggable();
  10921. }
  10922. }
  10923. if ( key === "position" ) {
  10924. this._position();
  10925. }
  10926. if ( key === "resizable" ) {
  10927. // currently resizable, becoming non-resizable
  10928. isResizable = uiDialog.is( ":data(ui-resizable)" );
  10929. if ( isResizable && !value ) {
  10930. uiDialog.resizable( "destroy" );
  10931. }
  10932. // Currently resizable, changing handles
  10933. if ( isResizable && typeof value === "string" ) {
  10934. uiDialog.resizable( "option", "handles", value );
  10935. }
  10936. // Currently non-resizable, becoming resizable
  10937. if ( !isResizable && value !== false ) {
  10938. this._makeResizable();
  10939. }
  10940. }
  10941. if ( key === "title" ) {
  10942. this._title( this.uiDialogTitlebar.find( ".ui-dialog-title" ) );
  10943. }
  10944. },
  10945. _size: function() {
  10946. // If the user has resized the dialog, the .ui-dialog and .ui-dialog-content
  10947. // divs will both have width and height set, so we need to reset them
  10948. var nonContentHeight, minContentHeight, maxContentHeight,
  10949. options = this.options;
  10950. // Reset content sizing
  10951. this.element.show().css( {
  10952. width: "auto",
  10953. minHeight: 0,
  10954. maxHeight: "none",
  10955. height: 0
  10956. } );
  10957. if ( options.minWidth > options.width ) {
  10958. options.width = options.minWidth;
  10959. }
  10960. // Reset wrapper sizing
  10961. // determine the height of all the non-content elements
  10962. nonContentHeight = this.uiDialog.css( {
  10963. height: "auto",
  10964. width: options.width
  10965. } )
  10966. .outerHeight();
  10967. minContentHeight = Math.max( 0, options.minHeight - nonContentHeight );
  10968. maxContentHeight = typeof options.maxHeight === "number" ?
  10969. Math.max( 0, options.maxHeight - nonContentHeight ) :
  10970. "none";
  10971. if ( options.height === "auto" ) {
  10972. this.element.css( {
  10973. minHeight: minContentHeight,
  10974. maxHeight: maxContentHeight,
  10975. height: "auto"
  10976. } );
  10977. } else {
  10978. this.element.height( Math.max( 0, options.height - nonContentHeight ) );
  10979. }
  10980. if ( this.uiDialog.is( ":data(ui-resizable)" ) ) {
  10981. this.uiDialog.resizable( "option", "minHeight", this._minHeight() );
  10982. }
  10983. },
  10984. _blockFrames: function() {
  10985. this.iframeBlocks = this.document.find( "iframe" ).map( function() {
  10986. var iframe = $( this );
  10987. return $( "<div>" )
  10988. .css( {
  10989. position: "absolute",
  10990. width: iframe.outerWidth(),
  10991. height: iframe.outerHeight()
  10992. } )
  10993. .appendTo( iframe.parent() )
  10994. .offset( iframe.offset() )[ 0 ];
  10995. } );
  10996. },
  10997. _unblockFrames: function() {
  10998. if ( this.iframeBlocks ) {
  10999. this.iframeBlocks.remove();
  11000. delete this.iframeBlocks;
  11001. }
  11002. },
  11003. _allowInteraction: function( event ) {
  11004. if ( $( event.target ).closest( ".ui-dialog" ).length ) {
  11005. return true;
  11006. }
  11007. // TODO: Remove hack when datepicker implements
  11008. // the .ui-front logic (#8989)
  11009. return !!$( event.target ).closest( ".ui-datepicker" ).length;
  11010. },
  11011. _createOverlay: function() {
  11012. if ( !this.options.modal ) {
  11013. return;
  11014. }
  11015. var jqMinor = $.fn.jquery.substring( 0, 4 );
  11016. // We use a delay in case the overlay is created from an
  11017. // event that we're going to be cancelling (#2804)
  11018. var isOpening = true;
  11019. this._delay( function() {
  11020. isOpening = false;
  11021. } );
  11022. if ( !this.document.data( "ui-dialog-overlays" ) ) {
  11023. // Prevent use of anchors and inputs
  11024. // This doesn't use `_on()` because it is a shared event handler
  11025. // across all open modal dialogs.
  11026. this.document.on( "focusin.ui-dialog", function( event ) {
  11027. if ( isOpening ) {
  11028. return;
  11029. }
  11030. var instance = this._trackingInstances()[ 0 ];
  11031. if ( !instance._allowInteraction( event ) ) {
  11032. event.preventDefault();
  11033. instance._focusTabbable();
  11034. // Support: jQuery >=3.4 <3.6 only
  11035. // Focus re-triggering in jQuery 3.4/3.5 makes the original element
  11036. // have its focus event propagated last, breaking the re-targeting.
  11037. // Trigger focus in a delay in addition if needed to avoid the issue
  11038. // See https://github.com/jquery/jquery/issues/4382
  11039. if ( jqMinor === "3.4." || jqMinor === "3.5." ) {
  11040. instance._delay( instance._restoreTabbableFocus );
  11041. }
  11042. }
  11043. }.bind( this ) );
  11044. }
  11045. this.overlay = $( "<div>" )
  11046. .appendTo( this._appendTo() );
  11047. this._addClass( this.overlay, null, "ui-widget-overlay ui-front" );
  11048. this._on( this.overlay, {
  11049. mousedown: "_keepFocus"
  11050. } );
  11051. this.document.data( "ui-dialog-overlays",
  11052. ( this.document.data( "ui-dialog-overlays" ) || 0 ) + 1 );
  11053. },
  11054. _destroyOverlay: function() {
  11055. if ( !this.options.modal ) {
  11056. return;
  11057. }
  11058. if ( this.overlay ) {
  11059. var overlays = this.document.data( "ui-dialog-overlays" ) - 1;
  11060. if ( !overlays ) {
  11061. this.document.off( "focusin.ui-dialog" );
  11062. this.document.removeData( "ui-dialog-overlays" );
  11063. } else {
  11064. this.document.data( "ui-dialog-overlays", overlays );
  11065. }
  11066. this.overlay.remove();
  11067. this.overlay = null;
  11068. }
  11069. }
  11070. } );
  11071. // DEPRECATED
  11072. // TODO: switch return back to widget declaration at top of file when this is removed
  11073. if ( $.uiBackCompat !== false ) {
  11074. // Backcompat for dialogClass option
  11075. $.widget( "ui.dialog", $.ui.dialog, {
  11076. options: {
  11077. dialogClass: ""
  11078. },
  11079. _createWrapper: function() {
  11080. this._super();
  11081. this.uiDialog.addClass( this.options.dialogClass );
  11082. },
  11083. _setOption: function( key, value ) {
  11084. if ( key === "dialogClass" ) {
  11085. this.uiDialog
  11086. .removeClass( this.options.dialogClass )
  11087. .addClass( value );
  11088. }
  11089. this._superApply( arguments );
  11090. }
  11091. } );
  11092. }
  11093. var widgetsDialog = $.ui.dialog;
  11094. /*!
  11095. * jQuery UI Droppable 1.13.2
  11096. * http://jqueryui.com
  11097. *
  11098. * Copyright jQuery Foundation and other contributors
  11099. * Released under the MIT license.
  11100. * http://jquery.org/license
  11101. */
  11102. //>>label: Droppable
  11103. //>>group: Interactions
  11104. //>>description: Enables drop targets for draggable elements.
  11105. //>>docs: http://api.jqueryui.com/droppable/
  11106. //>>demos: http://jqueryui.com/droppable/
  11107. $.widget( "ui.droppable", {
  11108. version: "1.13.2",
  11109. widgetEventPrefix: "drop",
  11110. options: {
  11111. accept: "*",
  11112. addClasses: true,
  11113. greedy: false,
  11114. scope: "default",
  11115. tolerance: "intersect",
  11116. // Callbacks
  11117. activate: null,
  11118. deactivate: null,
  11119. drop: null,
  11120. out: null,
  11121. over: null
  11122. },
  11123. _create: function() {
  11124. var proportions,
  11125. o = this.options,
  11126. accept = o.accept;
  11127. this.isover = false;
  11128. this.isout = true;
  11129. this.accept = typeof accept === "function" ? accept : function( d ) {
  11130. return d.is( accept );
  11131. };
  11132. this.proportions = function( /* valueToWrite */ ) {
  11133. if ( arguments.length ) {
  11134. // Store the droppable's proportions
  11135. proportions = arguments[ 0 ];
  11136. } else {
  11137. // Retrieve or derive the droppable's proportions
  11138. return proportions ?
  11139. proportions :
  11140. proportions = {
  11141. width: this.element[ 0 ].offsetWidth,
  11142. height: this.element[ 0 ].offsetHeight
  11143. };
  11144. }
  11145. };
  11146. this._addToManager( o.scope );
  11147. if ( o.addClasses ) {
  11148. this._addClass( "ui-droppable" );
  11149. }
  11150. },
  11151. _addToManager: function( scope ) {
  11152. // Add the reference and positions to the manager
  11153. $.ui.ddmanager.droppables[ scope ] = $.ui.ddmanager.droppables[ scope ] || [];
  11154. $.ui.ddmanager.droppables[ scope ].push( this );
  11155. },
  11156. _splice: function( drop ) {
  11157. var i = 0;
  11158. for ( ; i < drop.length; i++ ) {
  11159. if ( drop[ i ] === this ) {
  11160. drop.splice( i, 1 );
  11161. }
  11162. }
  11163. },
  11164. _destroy: function() {
  11165. var drop = $.ui.ddmanager.droppables[ this.options.scope ];
  11166. this._splice( drop );
  11167. },
  11168. _setOption: function( key, value ) {
  11169. if ( key === "accept" ) {
  11170. this.accept = typeof value === "function" ? value : function( d ) {
  11171. return d.is( value );
  11172. };
  11173. } else if ( key === "scope" ) {
  11174. var drop = $.ui.ddmanager.droppables[ this.options.scope ];
  11175. this._splice( drop );
  11176. this._addToManager( value );
  11177. }
  11178. this._super( key, value );
  11179. },
  11180. _activate: function( event ) {
  11181. var draggable = $.ui.ddmanager.current;
  11182. this._addActiveClass();
  11183. if ( draggable ) {
  11184. this._trigger( "activate", event, this.ui( draggable ) );
  11185. }
  11186. },
  11187. _deactivate: function( event ) {
  11188. var draggable = $.ui.ddmanager.current;
  11189. this._removeActiveClass();
  11190. if ( draggable ) {
  11191. this._trigger( "deactivate", event, this.ui( draggable ) );
  11192. }
  11193. },
  11194. _over: function( event ) {
  11195. var draggable = $.ui.ddmanager.current;
  11196. // Bail if draggable and droppable are same element
  11197. if ( !draggable || ( draggable.currentItem ||
  11198. draggable.element )[ 0 ] === this.element[ 0 ] ) {
  11199. return;
  11200. }
  11201. if ( this.accept.call( this.element[ 0 ], ( draggable.currentItem ||
  11202. draggable.element ) ) ) {
  11203. this._addHoverClass();
  11204. this._trigger( "over", event, this.ui( draggable ) );
  11205. }
  11206. },
  11207. _out: function( event ) {
  11208. var draggable = $.ui.ddmanager.current;
  11209. // Bail if draggable and droppable are same element
  11210. if ( !draggable || ( draggable.currentItem ||
  11211. draggable.element )[ 0 ] === this.element[ 0 ] ) {
  11212. return;
  11213. }
  11214. if ( this.accept.call( this.element[ 0 ], ( draggable.currentItem ||
  11215. draggable.element ) ) ) {
  11216. this._removeHoverClass();
  11217. this._trigger( "out", event, this.ui( draggable ) );
  11218. }
  11219. },
  11220. _drop: function( event, custom ) {
  11221. var draggable = custom || $.ui.ddmanager.current,
  11222. childrenIntersection = false;
  11223. // Bail if draggable and droppable are same element
  11224. if ( !draggable || ( draggable.currentItem ||
  11225. draggable.element )[ 0 ] === this.element[ 0 ] ) {
  11226. return false;
  11227. }
  11228. this.element
  11229. .find( ":data(ui-droppable)" )
  11230. .not( ".ui-draggable-dragging" )
  11231. .each( function() {
  11232. var inst = $( this ).droppable( "instance" );
  11233. if (
  11234. inst.options.greedy &&
  11235. !inst.options.disabled &&
  11236. inst.options.scope === draggable.options.scope &&
  11237. inst.accept.call(
  11238. inst.element[ 0 ], ( draggable.currentItem || draggable.element )
  11239. ) &&
  11240. $.ui.intersect(
  11241. draggable,
  11242. $.extend( inst, { offset: inst.element.offset() } ),
  11243. inst.options.tolerance, event
  11244. )
  11245. ) {
  11246. childrenIntersection = true;
  11247. return false;
  11248. }
  11249. } );
  11250. if ( childrenIntersection ) {
  11251. return false;
  11252. }
  11253. if ( this.accept.call( this.element[ 0 ],
  11254. ( draggable.currentItem || draggable.element ) ) ) {
  11255. this._removeActiveClass();
  11256. this._removeHoverClass();
  11257. this._trigger( "drop", event, this.ui( draggable ) );
  11258. return this.element;
  11259. }
  11260. return false;
  11261. },
  11262. ui: function( c ) {
  11263. return {
  11264. draggable: ( c.currentItem || c.element ),
  11265. helper: c.helper,
  11266. position: c.position,
  11267. offset: c.positionAbs
  11268. };
  11269. },
  11270. // Extension points just to make backcompat sane and avoid duplicating logic
  11271. // TODO: Remove in 1.14 along with call to it below
  11272. _addHoverClass: function() {
  11273. this._addClass( "ui-droppable-hover" );
  11274. },
  11275. _removeHoverClass: function() {
  11276. this._removeClass( "ui-droppable-hover" );
  11277. },
  11278. _addActiveClass: function() {
  11279. this._addClass( "ui-droppable-active" );
  11280. },
  11281. _removeActiveClass: function() {
  11282. this._removeClass( "ui-droppable-active" );
  11283. }
  11284. } );
  11285. $.ui.intersect = ( function() {
  11286. function isOverAxis( x, reference, size ) {
  11287. return ( x >= reference ) && ( x < ( reference + size ) );
  11288. }
  11289. return function( draggable, droppable, toleranceMode, event ) {
  11290. if ( !droppable.offset ) {
  11291. return false;
  11292. }
  11293. var x1 = ( draggable.positionAbs ||
  11294. draggable.position.absolute ).left + draggable.margins.left,
  11295. y1 = ( draggable.positionAbs ||
  11296. draggable.position.absolute ).top + draggable.margins.top,
  11297. x2 = x1 + draggable.helperProportions.width,
  11298. y2 = y1 + draggable.helperProportions.height,
  11299. l = droppable.offset.left,
  11300. t = droppable.offset.top,
  11301. r = l + droppable.proportions().width,
  11302. b = t + droppable.proportions().height;
  11303. switch ( toleranceMode ) {
  11304. case "fit":
  11305. return ( l <= x1 && x2 <= r && t <= y1 && y2 <= b );
  11306. case "intersect":
  11307. return ( l < x1 + ( draggable.helperProportions.width / 2 ) && // Right Half
  11308. x2 - ( draggable.helperProportions.width / 2 ) < r && // Left Half
  11309. t < y1 + ( draggable.helperProportions.height / 2 ) && // Bottom Half
  11310. y2 - ( draggable.helperProportions.height / 2 ) < b ); // Top Half
  11311. case "pointer":
  11312. return isOverAxis( event.pageY, t, droppable.proportions().height ) &&
  11313. isOverAxis( event.pageX, l, droppable.proportions().width );
  11314. case "touch":
  11315. return (
  11316. ( y1 >= t && y1 <= b ) || // Top edge touching
  11317. ( y2 >= t && y2 <= b ) || // Bottom edge touching
  11318. ( y1 < t && y2 > b ) // Surrounded vertically
  11319. ) && (
  11320. ( x1 >= l && x1 <= r ) || // Left edge touching
  11321. ( x2 >= l && x2 <= r ) || // Right edge touching
  11322. ( x1 < l && x2 > r ) // Surrounded horizontally
  11323. );
  11324. default:
  11325. return false;
  11326. }
  11327. };
  11328. } )();
  11329. /*
  11330. This manager tracks offsets of draggables and droppables
  11331. */
  11332. $.ui.ddmanager = {
  11333. current: null,
  11334. droppables: { "default": [] },
  11335. prepareOffsets: function( t, event ) {
  11336. var i, j,
  11337. m = $.ui.ddmanager.droppables[ t.options.scope ] || [],
  11338. type = event ? event.type : null, // workaround for #2317
  11339. list = ( t.currentItem || t.element ).find( ":data(ui-droppable)" ).addBack();
  11340. droppablesLoop: for ( i = 0; i < m.length; i++ ) {
  11341. // No disabled and non-accepted
  11342. if ( m[ i ].options.disabled || ( t && !m[ i ].accept.call( m[ i ].element[ 0 ],
  11343. ( t.currentItem || t.element ) ) ) ) {
  11344. continue;
  11345. }
  11346. // Filter out elements in the current dragged item
  11347. for ( j = 0; j < list.length; j++ ) {
  11348. if ( list[ j ] === m[ i ].element[ 0 ] ) {
  11349. m[ i ].proportions().height = 0;
  11350. continue droppablesLoop;
  11351. }
  11352. }
  11353. m[ i ].visible = m[ i ].element.css( "display" ) !== "none";
  11354. if ( !m[ i ].visible ) {
  11355. continue;
  11356. }
  11357. // Activate the droppable if used directly from draggables
  11358. if ( type === "mousedown" ) {
  11359. m[ i ]._activate.call( m[ i ], event );
  11360. }
  11361. m[ i ].offset = m[ i ].element.offset();
  11362. m[ i ].proportions( {
  11363. width: m[ i ].element[ 0 ].offsetWidth,
  11364. height: m[ i ].element[ 0 ].offsetHeight
  11365. } );
  11366. }
  11367. },
  11368. drop: function( draggable, event ) {
  11369. var dropped = false;
  11370. // Create a copy of the droppables in case the list changes during the drop (#9116)
  11371. $.each( ( $.ui.ddmanager.droppables[ draggable.options.scope ] || [] ).slice(), function() {
  11372. if ( !this.options ) {
  11373. return;
  11374. }
  11375. if ( !this.options.disabled && this.visible &&
  11376. $.ui.intersect( draggable, this, this.options.tolerance, event ) ) {
  11377. dropped = this._drop.call( this, event ) || dropped;
  11378. }
  11379. if ( !this.options.disabled && this.visible && this.accept.call( this.element[ 0 ],
  11380. ( draggable.currentItem || draggable.element ) ) ) {
  11381. this.isout = true;
  11382. this.isover = false;
  11383. this._deactivate.call( this, event );
  11384. }
  11385. } );
  11386. return dropped;
  11387. },
  11388. dragStart: function( draggable, event ) {
  11389. // Listen for scrolling so that if the dragging causes scrolling the position of the
  11390. // droppables can be recalculated (see #5003)
  11391. draggable.element.parentsUntil( "body" ).on( "scroll.droppable", function() {
  11392. if ( !draggable.options.refreshPositions ) {
  11393. $.ui.ddmanager.prepareOffsets( draggable, event );
  11394. }
  11395. } );
  11396. },
  11397. drag: function( draggable, event ) {
  11398. // If you have a highly dynamic page, you might try this option. It renders positions
  11399. // every time you move the mouse.
  11400. if ( draggable.options.refreshPositions ) {
  11401. $.ui.ddmanager.prepareOffsets( draggable, event );
  11402. }
  11403. // Run through all droppables and check their positions based on specific tolerance options
  11404. $.each( $.ui.ddmanager.droppables[ draggable.options.scope ] || [], function() {
  11405. if ( this.options.disabled || this.greedyChild || !this.visible ) {
  11406. return;
  11407. }
  11408. var parentInstance, scope, parent,
  11409. intersects = $.ui.intersect( draggable, this, this.options.tolerance, event ),
  11410. c = !intersects && this.isover ?
  11411. "isout" :
  11412. ( intersects && !this.isover ? "isover" : null );
  11413. if ( !c ) {
  11414. return;
  11415. }
  11416. if ( this.options.greedy ) {
  11417. // find droppable parents with same scope
  11418. scope = this.options.scope;
  11419. parent = this.element.parents( ":data(ui-droppable)" ).filter( function() {
  11420. return $( this ).droppable( "instance" ).options.scope === scope;
  11421. } );
  11422. if ( parent.length ) {
  11423. parentInstance = $( parent[ 0 ] ).droppable( "instance" );
  11424. parentInstance.greedyChild = ( c === "isover" );
  11425. }
  11426. }
  11427. // We just moved into a greedy child
  11428. if ( parentInstance && c === "isover" ) {
  11429. parentInstance.isover = false;
  11430. parentInstance.isout = true;
  11431. parentInstance._out.call( parentInstance, event );
  11432. }
  11433. this[ c ] = true;
  11434. this[ c === "isout" ? "isover" : "isout" ] = false;
  11435. this[ c === "isover" ? "_over" : "_out" ].call( this, event );
  11436. // We just moved out of a greedy child
  11437. if ( parentInstance && c === "isout" ) {
  11438. parentInstance.isout = false;
  11439. parentInstance.isover = true;
  11440. parentInstance._over.call( parentInstance, event );
  11441. }
  11442. } );
  11443. },
  11444. dragStop: function( draggable, event ) {
  11445. draggable.element.parentsUntil( "body" ).off( "scroll.droppable" );
  11446. // Call prepareOffsets one final time since IE does not fire return scroll events when
  11447. // overflow was caused by drag (see #5003)
  11448. if ( !draggable.options.refreshPositions ) {
  11449. $.ui.ddmanager.prepareOffsets( draggable, event );
  11450. }
  11451. }
  11452. };
  11453. // DEPRECATED
  11454. // TODO: switch return back to widget declaration at top of file when this is removed
  11455. if ( $.uiBackCompat !== false ) {
  11456. // Backcompat for activeClass and hoverClass options
  11457. $.widget( "ui.droppable", $.ui.droppable, {
  11458. options: {
  11459. hoverClass: false,
  11460. activeClass: false
  11461. },
  11462. _addActiveClass: function() {
  11463. this._super();
  11464. if ( this.options.activeClass ) {
  11465. this.element.addClass( this.options.activeClass );
  11466. }
  11467. },
  11468. _removeActiveClass: function() {
  11469. this._super();
  11470. if ( this.options.activeClass ) {
  11471. this.element.removeClass( this.options.activeClass );
  11472. }
  11473. },
  11474. _addHoverClass: function() {
  11475. this._super();
  11476. if ( this.options.hoverClass ) {
  11477. this.element.addClass( this.options.hoverClass );
  11478. }
  11479. },
  11480. _removeHoverClass: function() {
  11481. this._super();
  11482. if ( this.options.hoverClass ) {
  11483. this.element.removeClass( this.options.hoverClass );
  11484. }
  11485. }
  11486. } );
  11487. }
  11488. var widgetsDroppable = $.ui.droppable;
  11489. /*!
  11490. * jQuery UI Progressbar 1.13.2
  11491. * http://jqueryui.com
  11492. *
  11493. * Copyright jQuery Foundation and other contributors
  11494. * Released under the MIT license.
  11495. * http://jquery.org/license
  11496. */
  11497. //>>label: Progressbar
  11498. //>>group: Widgets
  11499. /* eslint-disable max-len */
  11500. //>>description: Displays a status indicator for loading state, standard percentage, and other progress indicators.
  11501. /* eslint-enable max-len */
  11502. //>>docs: http://api.jqueryui.com/progressbar/
  11503. //>>demos: http://jqueryui.com/progressbar/
  11504. //>>css.structure: ../../themes/base/core.css
  11505. //>>css.structure: ../../themes/base/progressbar.css
  11506. //>>css.theme: ../../themes/base/theme.css
  11507. var widgetsProgressbar = $.widget( "ui.progressbar", {
  11508. version: "1.13.2",
  11509. options: {
  11510. classes: {
  11511. "ui-progressbar": "ui-corner-all",
  11512. "ui-progressbar-value": "ui-corner-left",
  11513. "ui-progressbar-complete": "ui-corner-right"
  11514. },
  11515. max: 100,
  11516. value: 0,
  11517. change: null,
  11518. complete: null
  11519. },
  11520. min: 0,
  11521. _create: function() {
  11522. // Constrain initial value
  11523. this.oldValue = this.options.value = this._constrainedValue();
  11524. this.element.attr( {
  11525. // Only set static values; aria-valuenow and aria-valuemax are
  11526. // set inside _refreshValue()
  11527. role: "progressbar",
  11528. "aria-valuemin": this.min
  11529. } );
  11530. this._addClass( "ui-progressbar", "ui-widget ui-widget-content" );
  11531. this.valueDiv = $( "<div>" ).appendTo( this.element );
  11532. this._addClass( this.valueDiv, "ui-progressbar-value", "ui-widget-header" );
  11533. this._refreshValue();
  11534. },
  11535. _destroy: function() {
  11536. this.element.removeAttr( "role aria-valuemin aria-valuemax aria-valuenow" );
  11537. this.valueDiv.remove();
  11538. },
  11539. value: function( newValue ) {
  11540. if ( newValue === undefined ) {
  11541. return this.options.value;
  11542. }
  11543. this.options.value = this._constrainedValue( newValue );
  11544. this._refreshValue();
  11545. },
  11546. _constrainedValue: function( newValue ) {
  11547. if ( newValue === undefined ) {
  11548. newValue = this.options.value;
  11549. }
  11550. this.indeterminate = newValue === false;
  11551. // Sanitize value
  11552. if ( typeof newValue !== "number" ) {
  11553. newValue = 0;
  11554. }
  11555. return this.indeterminate ? false :
  11556. Math.min( this.options.max, Math.max( this.min, newValue ) );
  11557. },
  11558. _setOptions: function( options ) {
  11559. // Ensure "value" option is set after other values (like max)
  11560. var value = options.value;
  11561. delete options.value;
  11562. this._super( options );
  11563. this.options.value = this._constrainedValue( value );
  11564. this._refreshValue();
  11565. },
  11566. _setOption: function( key, value ) {
  11567. if ( key === "max" ) {
  11568. // Don't allow a max less than min
  11569. value = Math.max( this.min, value );
  11570. }
  11571. this._super( key, value );
  11572. },
  11573. _setOptionDisabled: function( value ) {
  11574. this._super( value );
  11575. this.element.attr( "aria-disabled", value );
  11576. this._toggleClass( null, "ui-state-disabled", !!value );
  11577. },
  11578. _percentage: function() {
  11579. return this.indeterminate ?
  11580. 100 :
  11581. 100 * ( this.options.value - this.min ) / ( this.options.max - this.min );
  11582. },
  11583. _refreshValue: function() {
  11584. var value = this.options.value,
  11585. percentage = this._percentage();
  11586. this.valueDiv
  11587. .toggle( this.indeterminate || value > this.min )
  11588. .width( percentage.toFixed( 0 ) + "%" );
  11589. this
  11590. ._toggleClass( this.valueDiv, "ui-progressbar-complete", null,
  11591. value === this.options.max )
  11592. ._toggleClass( "ui-progressbar-indeterminate", null, this.indeterminate );
  11593. if ( this.indeterminate ) {
  11594. this.element.removeAttr( "aria-valuenow" );
  11595. if ( !this.overlayDiv ) {
  11596. this.overlayDiv = $( "<div>" ).appendTo( this.valueDiv );
  11597. this._addClass( this.overlayDiv, "ui-progressbar-overlay" );
  11598. }
  11599. } else {
  11600. this.element.attr( {
  11601. "aria-valuemax": this.options.max,
  11602. "aria-valuenow": value
  11603. } );
  11604. if ( this.overlayDiv ) {
  11605. this.overlayDiv.remove();
  11606. this.overlayDiv = null;
  11607. }
  11608. }
  11609. if ( this.oldValue !== value ) {
  11610. this.oldValue = value;
  11611. this._trigger( "change" );
  11612. }
  11613. if ( value === this.options.max ) {
  11614. this._trigger( "complete" );
  11615. }
  11616. }
  11617. } );
  11618. /*!
  11619. * jQuery UI Selectable 1.13.2
  11620. * http://jqueryui.com
  11621. *
  11622. * Copyright jQuery Foundation and other contributors
  11623. * Released under the MIT license.
  11624. * http://jquery.org/license
  11625. */
  11626. //>>label: Selectable
  11627. //>>group: Interactions
  11628. //>>description: Allows groups of elements to be selected with the mouse.
  11629. //>>docs: http://api.jqueryui.com/selectable/
  11630. //>>demos: http://jqueryui.com/selectable/
  11631. //>>css.structure: ../../themes/base/selectable.css
  11632. var widgetsSelectable = $.widget( "ui.selectable", $.ui.mouse, {
  11633. version: "1.13.2",
  11634. options: {
  11635. appendTo: "body",
  11636. autoRefresh: true,
  11637. distance: 0,
  11638. filter: "*",
  11639. tolerance: "touch",
  11640. // Callbacks
  11641. selected: null,
  11642. selecting: null,
  11643. start: null,
  11644. stop: null,
  11645. unselected: null,
  11646. unselecting: null
  11647. },
  11648. _create: function() {
  11649. var that = this;
  11650. this._addClass( "ui-selectable" );
  11651. this.dragged = false;
  11652. // Cache selectee children based on filter
  11653. this.refresh = function() {
  11654. that.elementPos = $( that.element[ 0 ] ).offset();
  11655. that.selectees = $( that.options.filter, that.element[ 0 ] );
  11656. that._addClass( that.selectees, "ui-selectee" );
  11657. that.selectees.each( function() {
  11658. var $this = $( this ),
  11659. selecteeOffset = $this.offset(),
  11660. pos = {
  11661. left: selecteeOffset.left - that.elementPos.left,
  11662. top: selecteeOffset.top - that.elementPos.top
  11663. };
  11664. $.data( this, "selectable-item", {
  11665. element: this,
  11666. $element: $this,
  11667. left: pos.left,
  11668. top: pos.top,
  11669. right: pos.left + $this.outerWidth(),
  11670. bottom: pos.top + $this.outerHeight(),
  11671. startselected: false,
  11672. selected: $this.hasClass( "ui-selected" ),
  11673. selecting: $this.hasClass( "ui-selecting" ),
  11674. unselecting: $this.hasClass( "ui-unselecting" )
  11675. } );
  11676. } );
  11677. };
  11678. this.refresh();
  11679. this._mouseInit();
  11680. this.helper = $( "<div>" );
  11681. this._addClass( this.helper, "ui-selectable-helper" );
  11682. },
  11683. _destroy: function() {
  11684. this.selectees.removeData( "selectable-item" );
  11685. this._mouseDestroy();
  11686. },
  11687. _mouseStart: function( event ) {
  11688. var that = this,
  11689. options = this.options;
  11690. this.opos = [ event.pageX, event.pageY ];
  11691. this.elementPos = $( this.element[ 0 ] ).offset();
  11692. if ( this.options.disabled ) {
  11693. return;
  11694. }
  11695. this.selectees = $( options.filter, this.element[ 0 ] );
  11696. this._trigger( "start", event );
  11697. $( options.appendTo ).append( this.helper );
  11698. // position helper (lasso)
  11699. this.helper.css( {
  11700. "left": event.pageX,
  11701. "top": event.pageY,
  11702. "width": 0,
  11703. "height": 0
  11704. } );
  11705. if ( options.autoRefresh ) {
  11706. this.refresh();
  11707. }
  11708. this.selectees.filter( ".ui-selected" ).each( function() {
  11709. var selectee = $.data( this, "selectable-item" );
  11710. selectee.startselected = true;
  11711. if ( !event.metaKey && !event.ctrlKey ) {
  11712. that._removeClass( selectee.$element, "ui-selected" );
  11713. selectee.selected = false;
  11714. that._addClass( selectee.$element, "ui-unselecting" );
  11715. selectee.unselecting = true;
  11716. // selectable UNSELECTING callback
  11717. that._trigger( "unselecting", event, {
  11718. unselecting: selectee.element
  11719. } );
  11720. }
  11721. } );
  11722. $( event.target ).parents().addBack().each( function() {
  11723. var doSelect,
  11724. selectee = $.data( this, "selectable-item" );
  11725. if ( selectee ) {
  11726. doSelect = ( !event.metaKey && !event.ctrlKey ) ||
  11727. !selectee.$element.hasClass( "ui-selected" );
  11728. that._removeClass( selectee.$element, doSelect ? "ui-unselecting" : "ui-selected" )
  11729. ._addClass( selectee.$element, doSelect ? "ui-selecting" : "ui-unselecting" );
  11730. selectee.unselecting = !doSelect;
  11731. selectee.selecting = doSelect;
  11732. selectee.selected = doSelect;
  11733. // selectable (UN)SELECTING callback
  11734. if ( doSelect ) {
  11735. that._trigger( "selecting", event, {
  11736. selecting: selectee.element
  11737. } );
  11738. } else {
  11739. that._trigger( "unselecting", event, {
  11740. unselecting: selectee.element
  11741. } );
  11742. }
  11743. return false;
  11744. }
  11745. } );
  11746. },
  11747. _mouseDrag: function( event ) {
  11748. this.dragged = true;
  11749. if ( this.options.disabled ) {
  11750. return;
  11751. }
  11752. var tmp,
  11753. that = this,
  11754. options = this.options,
  11755. x1 = this.opos[ 0 ],
  11756. y1 = this.opos[ 1 ],
  11757. x2 = event.pageX,
  11758. y2 = event.pageY;
  11759. if ( x1 > x2 ) {
  11760. tmp = x2; x2 = x1; x1 = tmp;
  11761. }
  11762. if ( y1 > y2 ) {
  11763. tmp = y2; y2 = y1; y1 = tmp;
  11764. }
  11765. this.helper.css( { left: x1, top: y1, width: x2 - x1, height: y2 - y1 } );
  11766. this.selectees.each( function() {
  11767. var selectee = $.data( this, "selectable-item" ),
  11768. hit = false,
  11769. offset = {};
  11770. //prevent helper from being selected if appendTo: selectable
  11771. if ( !selectee || selectee.element === that.element[ 0 ] ) {
  11772. return;
  11773. }
  11774. offset.left = selectee.left + that.elementPos.left;
  11775. offset.right = selectee.right + that.elementPos.left;
  11776. offset.top = selectee.top + that.elementPos.top;
  11777. offset.bottom = selectee.bottom + that.elementPos.top;
  11778. if ( options.tolerance === "touch" ) {
  11779. hit = ( !( offset.left > x2 || offset.right < x1 || offset.top > y2 ||
  11780. offset.bottom < y1 ) );
  11781. } else if ( options.tolerance === "fit" ) {
  11782. hit = ( offset.left > x1 && offset.right < x2 && offset.top > y1 &&
  11783. offset.bottom < y2 );
  11784. }
  11785. if ( hit ) {
  11786. // SELECT
  11787. if ( selectee.selected ) {
  11788. that._removeClass( selectee.$element, "ui-selected" );
  11789. selectee.selected = false;
  11790. }
  11791. if ( selectee.unselecting ) {
  11792. that._removeClass( selectee.$element, "ui-unselecting" );
  11793. selectee.unselecting = false;
  11794. }
  11795. if ( !selectee.selecting ) {
  11796. that._addClass( selectee.$element, "ui-selecting" );
  11797. selectee.selecting = true;
  11798. // selectable SELECTING callback
  11799. that._trigger( "selecting", event, {
  11800. selecting: selectee.element
  11801. } );
  11802. }
  11803. } else {
  11804. // UNSELECT
  11805. if ( selectee.selecting ) {
  11806. if ( ( event.metaKey || event.ctrlKey ) && selectee.startselected ) {
  11807. that._removeClass( selectee.$element, "ui-selecting" );
  11808. selectee.selecting = false;
  11809. that._addClass( selectee.$element, "ui-selected" );
  11810. selectee.selected = true;
  11811. } else {
  11812. that._removeClass( selectee.$element, "ui-selecting" );
  11813. selectee.selecting = false;
  11814. if ( selectee.startselected ) {
  11815. that._addClass( selectee.$element, "ui-unselecting" );
  11816. selectee.unselecting = true;
  11817. }
  11818. // selectable UNSELECTING callback
  11819. that._trigger( "unselecting", event, {
  11820. unselecting: selectee.element
  11821. } );
  11822. }
  11823. }
  11824. if ( selectee.selected ) {
  11825. if ( !event.metaKey && !event.ctrlKey && !selectee.startselected ) {
  11826. that._removeClass( selectee.$element, "ui-selected" );
  11827. selectee.selected = false;
  11828. that._addClass( selectee.$element, "ui-unselecting" );
  11829. selectee.unselecting = true;
  11830. // selectable UNSELECTING callback
  11831. that._trigger( "unselecting", event, {
  11832. unselecting: selectee.element
  11833. } );
  11834. }
  11835. }
  11836. }
  11837. } );
  11838. return false;
  11839. },
  11840. _mouseStop: function( event ) {
  11841. var that = this;
  11842. this.dragged = false;
  11843. $( ".ui-unselecting", this.element[ 0 ] ).each( function() {
  11844. var selectee = $.data( this, "selectable-item" );
  11845. that._removeClass( selectee.$element, "ui-unselecting" );
  11846. selectee.unselecting = false;
  11847. selectee.startselected = false;
  11848. that._trigger( "unselected", event, {
  11849. unselected: selectee.element
  11850. } );
  11851. } );
  11852. $( ".ui-selecting", this.element[ 0 ] ).each( function() {
  11853. var selectee = $.data( this, "selectable-item" );
  11854. that._removeClass( selectee.$element, "ui-selecting" )
  11855. ._addClass( selectee.$element, "ui-selected" );
  11856. selectee.selecting = false;
  11857. selectee.selected = true;
  11858. selectee.startselected = true;
  11859. that._trigger( "selected", event, {
  11860. selected: selectee.element
  11861. } );
  11862. } );
  11863. this._trigger( "stop", event );
  11864. this.helper.remove();
  11865. return false;
  11866. }
  11867. } );
  11868. /*!
  11869. * jQuery UI Selectmenu 1.13.2
  11870. * http://jqueryui.com
  11871. *
  11872. * Copyright jQuery Foundation and other contributors
  11873. * Released under the MIT license.
  11874. * http://jquery.org/license
  11875. */
  11876. //>>label: Selectmenu
  11877. //>>group: Widgets
  11878. /* eslint-disable max-len */
  11879. //>>description: Duplicates and extends the functionality of a native HTML select element, allowing it to be customizable in behavior and appearance far beyond the limitations of a native select.
  11880. /* eslint-enable max-len */
  11881. //>>docs: http://api.jqueryui.com/selectmenu/
  11882. //>>demos: http://jqueryui.com/selectmenu/
  11883. //>>css.structure: ../../themes/base/core.css
  11884. //>>css.structure: ../../themes/base/selectmenu.css, ../../themes/base/button.css
  11885. //>>css.theme: ../../themes/base/theme.css
  11886. var widgetsSelectmenu = $.widget( "ui.selectmenu", [ $.ui.formResetMixin, {
  11887. version: "1.13.2",
  11888. defaultElement: "<select>",
  11889. options: {
  11890. appendTo: null,
  11891. classes: {
  11892. "ui-selectmenu-button-open": "ui-corner-top",
  11893. "ui-selectmenu-button-closed": "ui-corner-all"
  11894. },
  11895. disabled: null,
  11896. icons: {
  11897. button: "ui-icon-triangle-1-s"
  11898. },
  11899. position: {
  11900. my: "left top",
  11901. at: "left bottom",
  11902. collision: "none"
  11903. },
  11904. width: false,
  11905. // Callbacks
  11906. change: null,
  11907. close: null,
  11908. focus: null,
  11909. open: null,
  11910. select: null
  11911. },
  11912. _create: function() {
  11913. var selectmenuId = this.element.uniqueId().attr( "id" );
  11914. this.ids = {
  11915. element: selectmenuId,
  11916. button: selectmenuId + "-button",
  11917. menu: selectmenuId + "-menu"
  11918. };
  11919. this._drawButton();
  11920. this._drawMenu();
  11921. this._bindFormResetHandler();
  11922. this._rendered = false;
  11923. this.menuItems = $();
  11924. },
  11925. _drawButton: function() {
  11926. var icon,
  11927. that = this,
  11928. item = this._parseOption(
  11929. this.element.find( "option:selected" ),
  11930. this.element[ 0 ].selectedIndex
  11931. );
  11932. // Associate existing label with the new button
  11933. this.labels = this.element.labels().attr( "for", this.ids.button );
  11934. this._on( this.labels, {
  11935. click: function( event ) {
  11936. this.button.trigger( "focus" );
  11937. event.preventDefault();
  11938. }
  11939. } );
  11940. // Hide original select element
  11941. this.element.hide();
  11942. // Create button
  11943. this.button = $( "<span>", {
  11944. tabindex: this.options.disabled ? -1 : 0,
  11945. id: this.ids.button,
  11946. role: "combobox",
  11947. "aria-expanded": "false",
  11948. "aria-autocomplete": "list",
  11949. "aria-owns": this.ids.menu,
  11950. "aria-haspopup": "true",
  11951. title: this.element.attr( "title" )
  11952. } )
  11953. .insertAfter( this.element );
  11954. this._addClass( this.button, "ui-selectmenu-button ui-selectmenu-button-closed",
  11955. "ui-button ui-widget" );
  11956. icon = $( "<span>" ).appendTo( this.button );
  11957. this._addClass( icon, "ui-selectmenu-icon", "ui-icon " + this.options.icons.button );
  11958. this.buttonItem = this._renderButtonItem( item )
  11959. .appendTo( this.button );
  11960. if ( this.options.width !== false ) {
  11961. this._resizeButton();
  11962. }
  11963. this._on( this.button, this._buttonEvents );
  11964. this.button.one( "focusin", function() {
  11965. // Delay rendering the menu items until the button receives focus.
  11966. // The menu may have already been rendered via a programmatic open.
  11967. if ( !that._rendered ) {
  11968. that._refreshMenu();
  11969. }
  11970. } );
  11971. },
  11972. _drawMenu: function() {
  11973. var that = this;
  11974. // Create menu
  11975. this.menu = $( "<ul>", {
  11976. "aria-hidden": "true",
  11977. "aria-labelledby": this.ids.button,
  11978. id: this.ids.menu
  11979. } );
  11980. // Wrap menu
  11981. this.menuWrap = $( "<div>" ).append( this.menu );
  11982. this._addClass( this.menuWrap, "ui-selectmenu-menu", "ui-front" );
  11983. this.menuWrap.appendTo( this._appendTo() );
  11984. // Initialize menu widget
  11985. this.menuInstance = this.menu
  11986. .menu( {
  11987. classes: {
  11988. "ui-menu": "ui-corner-bottom"
  11989. },
  11990. role: "listbox",
  11991. select: function( event, ui ) {
  11992. event.preventDefault();
  11993. // Support: IE8
  11994. // If the item was selected via a click, the text selection
  11995. // will be destroyed in IE
  11996. that._setSelection();
  11997. that._select( ui.item.data( "ui-selectmenu-item" ), event );
  11998. },
  11999. focus: function( event, ui ) {
  12000. var item = ui.item.data( "ui-selectmenu-item" );
  12001. // Prevent inital focus from firing and check if its a newly focused item
  12002. if ( that.focusIndex != null && item.index !== that.focusIndex ) {
  12003. that._trigger( "focus", event, { item: item } );
  12004. if ( !that.isOpen ) {
  12005. that._select( item, event );
  12006. }
  12007. }
  12008. that.focusIndex = item.index;
  12009. that.button.attr( "aria-activedescendant",
  12010. that.menuItems.eq( item.index ).attr( "id" ) );
  12011. }
  12012. } )
  12013. .menu( "instance" );
  12014. // Don't close the menu on mouseleave
  12015. this.menuInstance._off( this.menu, "mouseleave" );
  12016. // Cancel the menu's collapseAll on document click
  12017. this.menuInstance._closeOnDocumentClick = function() {
  12018. return false;
  12019. };
  12020. // Selects often contain empty items, but never contain dividers
  12021. this.menuInstance._isDivider = function() {
  12022. return false;
  12023. };
  12024. },
  12025. refresh: function() {
  12026. this._refreshMenu();
  12027. this.buttonItem.replaceWith(
  12028. this.buttonItem = this._renderButtonItem(
  12029. // Fall back to an empty object in case there are no options
  12030. this._getSelectedItem().data( "ui-selectmenu-item" ) || {}
  12031. )
  12032. );
  12033. if ( this.options.width === null ) {
  12034. this._resizeButton();
  12035. }
  12036. },
  12037. _refreshMenu: function() {
  12038. var item,
  12039. options = this.element.find( "option" );
  12040. this.menu.empty();
  12041. this._parseOptions( options );
  12042. this._renderMenu( this.menu, this.items );
  12043. this.menuInstance.refresh();
  12044. this.menuItems = this.menu.find( "li" )
  12045. .not( ".ui-selectmenu-optgroup" )
  12046. .find( ".ui-menu-item-wrapper" );
  12047. this._rendered = true;
  12048. if ( !options.length ) {
  12049. return;
  12050. }
  12051. item = this._getSelectedItem();
  12052. // Update the menu to have the correct item focused
  12053. this.menuInstance.focus( null, item );
  12054. this._setAria( item.data( "ui-selectmenu-item" ) );
  12055. // Set disabled state
  12056. this._setOption( "disabled", this.element.prop( "disabled" ) );
  12057. },
  12058. open: function( event ) {
  12059. if ( this.options.disabled ) {
  12060. return;
  12061. }
  12062. // If this is the first time the menu is being opened, render the items
  12063. if ( !this._rendered ) {
  12064. this._refreshMenu();
  12065. } else {
  12066. // Menu clears focus on close, reset focus to selected item
  12067. this._removeClass( this.menu.find( ".ui-state-active" ), null, "ui-state-active" );
  12068. this.menuInstance.focus( null, this._getSelectedItem() );
  12069. }
  12070. // If there are no options, don't open the menu
  12071. if ( !this.menuItems.length ) {
  12072. return;
  12073. }
  12074. this.isOpen = true;
  12075. this._toggleAttr();
  12076. this._resizeMenu();
  12077. this._position();
  12078. this._on( this.document, this._documentClick );
  12079. this._trigger( "open", event );
  12080. },
  12081. _position: function() {
  12082. this.menuWrap.position( $.extend( { of: this.button }, this.options.position ) );
  12083. },
  12084. close: function( event ) {
  12085. if ( !this.isOpen ) {
  12086. return;
  12087. }
  12088. this.isOpen = false;
  12089. this._toggleAttr();
  12090. this.range = null;
  12091. this._off( this.document );
  12092. this._trigger( "close", event );
  12093. },
  12094. widget: function() {
  12095. return this.button;
  12096. },
  12097. menuWidget: function() {
  12098. return this.menu;
  12099. },
  12100. _renderButtonItem: function( item ) {
  12101. var buttonItem = $( "<span>" );
  12102. this._setText( buttonItem, item.label );
  12103. this._addClass( buttonItem, "ui-selectmenu-text" );
  12104. return buttonItem;
  12105. },
  12106. _renderMenu: function( ul, items ) {
  12107. var that = this,
  12108. currentOptgroup = "";
  12109. $.each( items, function( index, item ) {
  12110. var li;
  12111. if ( item.optgroup !== currentOptgroup ) {
  12112. li = $( "<li>", {
  12113. text: item.optgroup
  12114. } );
  12115. that._addClass( li, "ui-selectmenu-optgroup", "ui-menu-divider" +
  12116. ( item.element.parent( "optgroup" ).prop( "disabled" ) ?
  12117. " ui-state-disabled" :
  12118. "" ) );
  12119. li.appendTo( ul );
  12120. currentOptgroup = item.optgroup;
  12121. }
  12122. that._renderItemData( ul, item );
  12123. } );
  12124. },
  12125. _renderItemData: function( ul, item ) {
  12126. return this._renderItem( ul, item ).data( "ui-selectmenu-item", item );
  12127. },
  12128. _renderItem: function( ul, item ) {
  12129. var li = $( "<li>" ),
  12130. wrapper = $( "<div>", {
  12131. title: item.element.attr( "title" )
  12132. } );
  12133. if ( item.disabled ) {
  12134. this._addClass( li, null, "ui-state-disabled" );
  12135. }
  12136. this._setText( wrapper, item.label );
  12137. return li.append( wrapper ).appendTo( ul );
  12138. },
  12139. _setText: function( element, value ) {
  12140. if ( value ) {
  12141. element.text( value );
  12142. } else {
  12143. element.html( "&#160;" );
  12144. }
  12145. },
  12146. _move: function( direction, event ) {
  12147. var item, next,
  12148. filter = ".ui-menu-item";
  12149. if ( this.isOpen ) {
  12150. item = this.menuItems.eq( this.focusIndex ).parent( "li" );
  12151. } else {
  12152. item = this.menuItems.eq( this.element[ 0 ].selectedIndex ).parent( "li" );
  12153. filter += ":not(.ui-state-disabled)";
  12154. }
  12155. if ( direction === "first" || direction === "last" ) {
  12156. next = item[ direction === "first" ? "prevAll" : "nextAll" ]( filter ).eq( -1 );
  12157. } else {
  12158. next = item[ direction + "All" ]( filter ).eq( 0 );
  12159. }
  12160. if ( next.length ) {
  12161. this.menuInstance.focus( event, next );
  12162. }
  12163. },
  12164. _getSelectedItem: function() {
  12165. return this.menuItems.eq( this.element[ 0 ].selectedIndex ).parent( "li" );
  12166. },
  12167. _toggle: function( event ) {
  12168. this[ this.isOpen ? "close" : "open" ]( event );
  12169. },
  12170. _setSelection: function() {
  12171. var selection;
  12172. if ( !this.range ) {
  12173. return;
  12174. }
  12175. if ( window.getSelection ) {
  12176. selection = window.getSelection();
  12177. selection.removeAllRanges();
  12178. selection.addRange( this.range );
  12179. // Support: IE8
  12180. } else {
  12181. this.range.select();
  12182. }
  12183. // Support: IE
  12184. // Setting the text selection kills the button focus in IE, but
  12185. // restoring the focus doesn't kill the selection.
  12186. this.button.trigger( "focus" );
  12187. },
  12188. _documentClick: {
  12189. mousedown: function( event ) {
  12190. if ( !this.isOpen ) {
  12191. return;
  12192. }
  12193. if ( !$( event.target ).closest( ".ui-selectmenu-menu, #" +
  12194. $.escapeSelector( this.ids.button ) ).length ) {
  12195. this.close( event );
  12196. }
  12197. }
  12198. },
  12199. _buttonEvents: {
  12200. // Prevent text selection from being reset when interacting with the selectmenu (#10144)
  12201. mousedown: function() {
  12202. var selection;
  12203. if ( window.getSelection ) {
  12204. selection = window.getSelection();
  12205. if ( selection.rangeCount ) {
  12206. this.range = selection.getRangeAt( 0 );
  12207. }
  12208. // Support: IE8
  12209. } else {
  12210. this.range = document.selection.createRange();
  12211. }
  12212. },
  12213. click: function( event ) {
  12214. this._setSelection();
  12215. this._toggle( event );
  12216. },
  12217. keydown: function( event ) {
  12218. var preventDefault = true;
  12219. switch ( event.keyCode ) {
  12220. case $.ui.keyCode.TAB:
  12221. case $.ui.keyCode.ESCAPE:
  12222. this.close( event );
  12223. preventDefault = false;
  12224. break;
  12225. case $.ui.keyCode.ENTER:
  12226. if ( this.isOpen ) {
  12227. this._selectFocusedItem( event );
  12228. }
  12229. break;
  12230. case $.ui.keyCode.UP:
  12231. if ( event.altKey ) {
  12232. this._toggle( event );
  12233. } else {
  12234. this._move( "prev", event );
  12235. }
  12236. break;
  12237. case $.ui.keyCode.DOWN:
  12238. if ( event.altKey ) {
  12239. this._toggle( event );
  12240. } else {
  12241. this._move( "next", event );
  12242. }
  12243. break;
  12244. case $.ui.keyCode.SPACE:
  12245. if ( this.isOpen ) {
  12246. this._selectFocusedItem( event );
  12247. } else {
  12248. this._toggle( event );
  12249. }
  12250. break;
  12251. case $.ui.keyCode.LEFT:
  12252. this._move( "prev", event );
  12253. break;
  12254. case $.ui.keyCode.RIGHT:
  12255. this._move( "next", event );
  12256. break;
  12257. case $.ui.keyCode.HOME:
  12258. case $.ui.keyCode.PAGE_UP:
  12259. this._move( "first", event );
  12260. break;
  12261. case $.ui.keyCode.END:
  12262. case $.ui.keyCode.PAGE_DOWN:
  12263. this._move( "last", event );
  12264. break;
  12265. default:
  12266. this.menu.trigger( event );
  12267. preventDefault = false;
  12268. }
  12269. if ( preventDefault ) {
  12270. event.preventDefault();
  12271. }
  12272. }
  12273. },
  12274. _selectFocusedItem: function( event ) {
  12275. var item = this.menuItems.eq( this.focusIndex ).parent( "li" );
  12276. if ( !item.hasClass( "ui-state-disabled" ) ) {
  12277. this._select( item.data( "ui-selectmenu-item" ), event );
  12278. }
  12279. },
  12280. _select: function( item, event ) {
  12281. var oldIndex = this.element[ 0 ].selectedIndex;
  12282. // Change native select element
  12283. this.element[ 0 ].selectedIndex = item.index;
  12284. this.buttonItem.replaceWith( this.buttonItem = this._renderButtonItem( item ) );
  12285. this._setAria( item );
  12286. this._trigger( "select", event, { item: item } );
  12287. if ( item.index !== oldIndex ) {
  12288. this._trigger( "change", event, { item: item } );
  12289. }
  12290. this.close( event );
  12291. },
  12292. _setAria: function( item ) {
  12293. var id = this.menuItems.eq( item.index ).attr( "id" );
  12294. this.button.attr( {
  12295. "aria-labelledby": id,
  12296. "aria-activedescendant": id
  12297. } );
  12298. this.menu.attr( "aria-activedescendant", id );
  12299. },
  12300. _setOption: function( key, value ) {
  12301. if ( key === "icons" ) {
  12302. var icon = this.button.find( "span.ui-icon" );
  12303. this._removeClass( icon, null, this.options.icons.button )
  12304. ._addClass( icon, null, value.button );
  12305. }
  12306. this._super( key, value );
  12307. if ( key === "appendTo" ) {
  12308. this.menuWrap.appendTo( this._appendTo() );
  12309. }
  12310. if ( key === "width" ) {
  12311. this._resizeButton();
  12312. }
  12313. },
  12314. _setOptionDisabled: function( value ) {
  12315. this._super( value );
  12316. this.menuInstance.option( "disabled", value );
  12317. this.button.attr( "aria-disabled", value );
  12318. this._toggleClass( this.button, null, "ui-state-disabled", value );
  12319. this.element.prop( "disabled", value );
  12320. if ( value ) {
  12321. this.button.attr( "tabindex", -1 );
  12322. this.close();
  12323. } else {
  12324. this.button.attr( "tabindex", 0 );
  12325. }
  12326. },
  12327. _appendTo: function() {
  12328. var element = this.options.appendTo;
  12329. if ( element ) {
  12330. element = element.jquery || element.nodeType ?
  12331. $( element ) :
  12332. this.document.find( element ).eq( 0 );
  12333. }
  12334. if ( !element || !element[ 0 ] ) {
  12335. element = this.element.closest( ".ui-front, dialog" );
  12336. }
  12337. if ( !element.length ) {
  12338. element = this.document[ 0 ].body;
  12339. }
  12340. return element;
  12341. },
  12342. _toggleAttr: function() {
  12343. this.button.attr( "aria-expanded", this.isOpen );
  12344. // We can't use two _toggleClass() calls here, because we need to make sure
  12345. // we always remove classes first and add them second, otherwise if both classes have the
  12346. // same theme class, it will be removed after we add it.
  12347. this._removeClass( this.button, "ui-selectmenu-button-" +
  12348. ( this.isOpen ? "closed" : "open" ) )
  12349. ._addClass( this.button, "ui-selectmenu-button-" +
  12350. ( this.isOpen ? "open" : "closed" ) )
  12351. ._toggleClass( this.menuWrap, "ui-selectmenu-open", null, this.isOpen );
  12352. this.menu.attr( "aria-hidden", !this.isOpen );
  12353. },
  12354. _resizeButton: function() {
  12355. var width = this.options.width;
  12356. // For `width: false`, just remove inline style and stop
  12357. if ( width === false ) {
  12358. this.button.css( "width", "" );
  12359. return;
  12360. }
  12361. // For `width: null`, match the width of the original element
  12362. if ( width === null ) {
  12363. width = this.element.show().outerWidth();
  12364. this.element.hide();
  12365. }
  12366. this.button.outerWidth( width );
  12367. },
  12368. _resizeMenu: function() {
  12369. this.menu.outerWidth( Math.max(
  12370. this.button.outerWidth(),
  12371. // Support: IE10
  12372. // IE10 wraps long text (possibly a rounding bug)
  12373. // so we add 1px to avoid the wrapping
  12374. this.menu.width( "" ).outerWidth() + 1
  12375. ) );
  12376. },
  12377. _getCreateOptions: function() {
  12378. var options = this._super();
  12379. options.disabled = this.element.prop( "disabled" );
  12380. return options;
  12381. },
  12382. _parseOptions: function( options ) {
  12383. var that = this,
  12384. data = [];
  12385. options.each( function( index, item ) {
  12386. if ( item.hidden ) {
  12387. return;
  12388. }
  12389. data.push( that._parseOption( $( item ), index ) );
  12390. } );
  12391. this.items = data;
  12392. },
  12393. _parseOption: function( option, index ) {
  12394. var optgroup = option.parent( "optgroup" );
  12395. return {
  12396. element: option,
  12397. index: index,
  12398. value: option.val(),
  12399. label: option.text(),
  12400. optgroup: optgroup.attr( "label" ) || "",
  12401. disabled: optgroup.prop( "disabled" ) || option.prop( "disabled" )
  12402. };
  12403. },
  12404. _destroy: function() {
  12405. this._unbindFormResetHandler();
  12406. this.menuWrap.remove();
  12407. this.button.remove();
  12408. this.element.show();
  12409. this.element.removeUniqueId();
  12410. this.labels.attr( "for", this.ids.element );
  12411. }
  12412. } ] );
  12413. /*!
  12414. * jQuery UI Slider 1.13.2
  12415. * http://jqueryui.com
  12416. *
  12417. * Copyright jQuery Foundation and other contributors
  12418. * Released under the MIT license.
  12419. * http://jquery.org/license
  12420. */
  12421. //>>label: Slider
  12422. //>>group: Widgets
  12423. //>>description: Displays a flexible slider with ranges and accessibility via keyboard.
  12424. //>>docs: http://api.jqueryui.com/slider/
  12425. //>>demos: http://jqueryui.com/slider/
  12426. //>>css.structure: ../../themes/base/core.css
  12427. //>>css.structure: ../../themes/base/slider.css
  12428. //>>css.theme: ../../themes/base/theme.css
  12429. var widgetsSlider = $.widget( "ui.slider", $.ui.mouse, {
  12430. version: "1.13.2",
  12431. widgetEventPrefix: "slide",
  12432. options: {
  12433. animate: false,
  12434. classes: {
  12435. "ui-slider": "ui-corner-all",
  12436. "ui-slider-handle": "ui-corner-all",
  12437. // Note: ui-widget-header isn't the most fittingly semantic framework class for this
  12438. // element, but worked best visually with a variety of themes
  12439. "ui-slider-range": "ui-corner-all ui-widget-header"
  12440. },
  12441. distance: 0,
  12442. max: 100,
  12443. min: 0,
  12444. orientation: "horizontal",
  12445. range: false,
  12446. step: 1,
  12447. value: 0,
  12448. values: null,
  12449. // Callbacks
  12450. change: null,
  12451. slide: null,
  12452. start: null,
  12453. stop: null
  12454. },
  12455. // Number of pages in a slider
  12456. // (how many times can you page up/down to go through the whole range)
  12457. numPages: 5,
  12458. _create: function() {
  12459. this._keySliding = false;
  12460. this._mouseSliding = false;
  12461. this._animateOff = true;
  12462. this._handleIndex = null;
  12463. this._detectOrientation();
  12464. this._mouseInit();
  12465. this._calculateNewMax();
  12466. this._addClass( "ui-slider ui-slider-" + this.orientation,
  12467. "ui-widget ui-widget-content" );
  12468. this._refresh();
  12469. this._animateOff = false;
  12470. },
  12471. _refresh: function() {
  12472. this._createRange();
  12473. this._createHandles();
  12474. this._setupEvents();
  12475. this._refreshValue();
  12476. },
  12477. _createHandles: function() {
  12478. var i, handleCount,
  12479. options = this.options,
  12480. existingHandles = this.element.find( ".ui-slider-handle" ),
  12481. handle = "<span tabindex='0'></span>",
  12482. handles = [];
  12483. handleCount = ( options.values && options.values.length ) || 1;
  12484. if ( existingHandles.length > handleCount ) {
  12485. existingHandles.slice( handleCount ).remove();
  12486. existingHandles = existingHandles.slice( 0, handleCount );
  12487. }
  12488. for ( i = existingHandles.length; i < handleCount; i++ ) {
  12489. handles.push( handle );
  12490. }
  12491. this.handles = existingHandles.add( $( handles.join( "" ) ).appendTo( this.element ) );
  12492. this._addClass( this.handles, "ui-slider-handle", "ui-state-default" );
  12493. this.handle = this.handles.eq( 0 );
  12494. this.handles.each( function( i ) {
  12495. $( this )
  12496. .data( "ui-slider-handle-index", i )
  12497. .attr( "tabIndex", 0 );
  12498. } );
  12499. },
  12500. _createRange: function() {
  12501. var options = this.options;
  12502. if ( options.range ) {
  12503. if ( options.range === true ) {
  12504. if ( !options.values ) {
  12505. options.values = [ this._valueMin(), this._valueMin() ];
  12506. } else if ( options.values.length && options.values.length !== 2 ) {
  12507. options.values = [ options.values[ 0 ], options.values[ 0 ] ];
  12508. } else if ( Array.isArray( options.values ) ) {
  12509. options.values = options.values.slice( 0 );
  12510. }
  12511. }
  12512. if ( !this.range || !this.range.length ) {
  12513. this.range = $( "<div>" )
  12514. .appendTo( this.element );
  12515. this._addClass( this.range, "ui-slider-range" );
  12516. } else {
  12517. this._removeClass( this.range, "ui-slider-range-min ui-slider-range-max" );
  12518. // Handle range switching from true to min/max
  12519. this.range.css( {
  12520. "left": "",
  12521. "bottom": ""
  12522. } );
  12523. }
  12524. if ( options.range === "min" || options.range === "max" ) {
  12525. this._addClass( this.range, "ui-slider-range-" + options.range );
  12526. }
  12527. } else {
  12528. if ( this.range ) {
  12529. this.range.remove();
  12530. }
  12531. this.range = null;
  12532. }
  12533. },
  12534. _setupEvents: function() {
  12535. this._off( this.handles );
  12536. this._on( this.handles, this._handleEvents );
  12537. this._hoverable( this.handles );
  12538. this._focusable( this.handles );
  12539. },
  12540. _destroy: function() {
  12541. this.handles.remove();
  12542. if ( this.range ) {
  12543. this.range.remove();
  12544. }
  12545. this._mouseDestroy();
  12546. },
  12547. _mouseCapture: function( event ) {
  12548. var position, normValue, distance, closestHandle, index, allowed, offset, mouseOverHandle,
  12549. that = this,
  12550. o = this.options;
  12551. if ( o.disabled ) {
  12552. return false;
  12553. }
  12554. this.elementSize = {
  12555. width: this.element.outerWidth(),
  12556. height: this.element.outerHeight()
  12557. };
  12558. this.elementOffset = this.element.offset();
  12559. position = { x: event.pageX, y: event.pageY };
  12560. normValue = this._normValueFromMouse( position );
  12561. distance = this._valueMax() - this._valueMin() + 1;
  12562. this.handles.each( function( i ) {
  12563. var thisDistance = Math.abs( normValue - that.values( i ) );
  12564. if ( ( distance > thisDistance ) ||
  12565. ( distance === thisDistance &&
  12566. ( i === that._lastChangedValue || that.values( i ) === o.min ) ) ) {
  12567. distance = thisDistance;
  12568. closestHandle = $( this );
  12569. index = i;
  12570. }
  12571. } );
  12572. allowed = this._start( event, index );
  12573. if ( allowed === false ) {
  12574. return false;
  12575. }
  12576. this._mouseSliding = true;
  12577. this._handleIndex = index;
  12578. this._addClass( closestHandle, null, "ui-state-active" );
  12579. closestHandle.trigger( "focus" );
  12580. offset = closestHandle.offset();
  12581. mouseOverHandle = !$( event.target ).parents().addBack().is( ".ui-slider-handle" );
  12582. this._clickOffset = mouseOverHandle ? { left: 0, top: 0 } : {
  12583. left: event.pageX - offset.left - ( closestHandle.width() / 2 ),
  12584. top: event.pageY - offset.top -
  12585. ( closestHandle.height() / 2 ) -
  12586. ( parseInt( closestHandle.css( "borderTopWidth" ), 10 ) || 0 ) -
  12587. ( parseInt( closestHandle.css( "borderBottomWidth" ), 10 ) || 0 ) +
  12588. ( parseInt( closestHandle.css( "marginTop" ), 10 ) || 0 )
  12589. };
  12590. if ( !this.handles.hasClass( "ui-state-hover" ) ) {
  12591. this._slide( event, index, normValue );
  12592. }
  12593. this._animateOff = true;
  12594. return true;
  12595. },
  12596. _mouseStart: function() {
  12597. return true;
  12598. },
  12599. _mouseDrag: function( event ) {
  12600. var position = { x: event.pageX, y: event.pageY },
  12601. normValue = this._normValueFromMouse( position );
  12602. this._slide( event, this._handleIndex, normValue );
  12603. return false;
  12604. },
  12605. _mouseStop: function( event ) {
  12606. this._removeClass( this.handles, null, "ui-state-active" );
  12607. this._mouseSliding = false;
  12608. this._stop( event, this._handleIndex );
  12609. this._change( event, this._handleIndex );
  12610. this._handleIndex = null;
  12611. this._clickOffset = null;
  12612. this._animateOff = false;
  12613. return false;
  12614. },
  12615. _detectOrientation: function() {
  12616. this.orientation = ( this.options.orientation === "vertical" ) ? "vertical" : "horizontal";
  12617. },
  12618. _normValueFromMouse: function( position ) {
  12619. var pixelTotal,
  12620. pixelMouse,
  12621. percentMouse,
  12622. valueTotal,
  12623. valueMouse;
  12624. if ( this.orientation === "horizontal" ) {
  12625. pixelTotal = this.elementSize.width;
  12626. pixelMouse = position.x - this.elementOffset.left -
  12627. ( this._clickOffset ? this._clickOffset.left : 0 );
  12628. } else {
  12629. pixelTotal = this.elementSize.height;
  12630. pixelMouse = position.y - this.elementOffset.top -
  12631. ( this._clickOffset ? this._clickOffset.top : 0 );
  12632. }
  12633. percentMouse = ( pixelMouse / pixelTotal );
  12634. if ( percentMouse > 1 ) {
  12635. percentMouse = 1;
  12636. }
  12637. if ( percentMouse < 0 ) {
  12638. percentMouse = 0;
  12639. }
  12640. if ( this.orientation === "vertical" ) {
  12641. percentMouse = 1 - percentMouse;
  12642. }
  12643. valueTotal = this._valueMax() - this._valueMin();
  12644. valueMouse = this._valueMin() + percentMouse * valueTotal;
  12645. return this._trimAlignValue( valueMouse );
  12646. },
  12647. _uiHash: function( index, value, values ) {
  12648. var uiHash = {
  12649. handle: this.handles[ index ],
  12650. handleIndex: index,
  12651. value: value !== undefined ? value : this.value()
  12652. };
  12653. if ( this._hasMultipleValues() ) {
  12654. uiHash.value = value !== undefined ? value : this.values( index );
  12655. uiHash.values = values || this.values();
  12656. }
  12657. return uiHash;
  12658. },
  12659. _hasMultipleValues: function() {
  12660. return this.options.values && this.options.values.length;
  12661. },
  12662. _start: function( event, index ) {
  12663. return this._trigger( "start", event, this._uiHash( index ) );
  12664. },
  12665. _slide: function( event, index, newVal ) {
  12666. var allowed, otherVal,
  12667. currentValue = this.value(),
  12668. newValues = this.values();
  12669. if ( this._hasMultipleValues() ) {
  12670. otherVal = this.values( index ? 0 : 1 );
  12671. currentValue = this.values( index );
  12672. if ( this.options.values.length === 2 && this.options.range === true ) {
  12673. newVal = index === 0 ? Math.min( otherVal, newVal ) : Math.max( otherVal, newVal );
  12674. }
  12675. newValues[ index ] = newVal;
  12676. }
  12677. if ( newVal === currentValue ) {
  12678. return;
  12679. }
  12680. allowed = this._trigger( "slide", event, this._uiHash( index, newVal, newValues ) );
  12681. // A slide can be canceled by returning false from the slide callback
  12682. if ( allowed === false ) {
  12683. return;
  12684. }
  12685. if ( this._hasMultipleValues() ) {
  12686. this.values( index, newVal );
  12687. } else {
  12688. this.value( newVal );
  12689. }
  12690. },
  12691. _stop: function( event, index ) {
  12692. this._trigger( "stop", event, this._uiHash( index ) );
  12693. },
  12694. _change: function( event, index ) {
  12695. if ( !this._keySliding && !this._mouseSliding ) {
  12696. //store the last changed value index for reference when handles overlap
  12697. this._lastChangedValue = index;
  12698. this._trigger( "change", event, this._uiHash( index ) );
  12699. }
  12700. },
  12701. value: function( newValue ) {
  12702. if ( arguments.length ) {
  12703. this.options.value = this._trimAlignValue( newValue );
  12704. this._refreshValue();
  12705. this._change( null, 0 );
  12706. return;
  12707. }
  12708. return this._value();
  12709. },
  12710. values: function( index, newValue ) {
  12711. var vals,
  12712. newValues,
  12713. i;
  12714. if ( arguments.length > 1 ) {
  12715. this.options.values[ index ] = this._trimAlignValue( newValue );
  12716. this._refreshValue();
  12717. this._change( null, index );
  12718. return;
  12719. }
  12720. if ( arguments.length ) {
  12721. if ( Array.isArray( arguments[ 0 ] ) ) {
  12722. vals = this.options.values;
  12723. newValues = arguments[ 0 ];
  12724. for ( i = 0; i < vals.length; i += 1 ) {
  12725. vals[ i ] = this._trimAlignValue( newValues[ i ] );
  12726. this._change( null, i );
  12727. }
  12728. this._refreshValue();
  12729. } else {
  12730. if ( this._hasMultipleValues() ) {
  12731. return this._values( index );
  12732. } else {
  12733. return this.value();
  12734. }
  12735. }
  12736. } else {
  12737. return this._values();
  12738. }
  12739. },
  12740. _setOption: function( key, value ) {
  12741. var i,
  12742. valsLength = 0;
  12743. if ( key === "range" && this.options.range === true ) {
  12744. if ( value === "min" ) {
  12745. this.options.value = this._values( 0 );
  12746. this.options.values = null;
  12747. } else if ( value === "max" ) {
  12748. this.options.value = this._values( this.options.values.length - 1 );
  12749. this.options.values = null;
  12750. }
  12751. }
  12752. if ( Array.isArray( this.options.values ) ) {
  12753. valsLength = this.options.values.length;
  12754. }
  12755. this._super( key, value );
  12756. switch ( key ) {
  12757. case "orientation":
  12758. this._detectOrientation();
  12759. this._removeClass( "ui-slider-horizontal ui-slider-vertical" )
  12760. ._addClass( "ui-slider-" + this.orientation );
  12761. this._refreshValue();
  12762. if ( this.options.range ) {
  12763. this._refreshRange( value );
  12764. }
  12765. // Reset positioning from previous orientation
  12766. this.handles.css( value === "horizontal" ? "bottom" : "left", "" );
  12767. break;
  12768. case "value":
  12769. this._animateOff = true;
  12770. this._refreshValue();
  12771. this._change( null, 0 );
  12772. this._animateOff = false;
  12773. break;
  12774. case "values":
  12775. this._animateOff = true;
  12776. this._refreshValue();
  12777. // Start from the last handle to prevent unreachable handles (#9046)
  12778. for ( i = valsLength - 1; i >= 0; i-- ) {
  12779. this._change( null, i );
  12780. }
  12781. this._animateOff = false;
  12782. break;
  12783. case "step":
  12784. case "min":
  12785. case "max":
  12786. this._animateOff = true;
  12787. this._calculateNewMax();
  12788. this._refreshValue();
  12789. this._animateOff = false;
  12790. break;
  12791. case "range":
  12792. this._animateOff = true;
  12793. this._refresh();
  12794. this._animateOff = false;
  12795. break;
  12796. }
  12797. },
  12798. _setOptionDisabled: function( value ) {
  12799. this._super( value );
  12800. this._toggleClass( null, "ui-state-disabled", !!value );
  12801. },
  12802. //internal value getter
  12803. // _value() returns value trimmed by min and max, aligned by step
  12804. _value: function() {
  12805. var val = this.options.value;
  12806. val = this._trimAlignValue( val );
  12807. return val;
  12808. },
  12809. //internal values getter
  12810. // _values() returns array of values trimmed by min and max, aligned by step
  12811. // _values( index ) returns single value trimmed by min and max, aligned by step
  12812. _values: function( index ) {
  12813. var val,
  12814. vals,
  12815. i;
  12816. if ( arguments.length ) {
  12817. val = this.options.values[ index ];
  12818. val = this._trimAlignValue( val );
  12819. return val;
  12820. } else if ( this._hasMultipleValues() ) {
  12821. // .slice() creates a copy of the array
  12822. // this copy gets trimmed by min and max and then returned
  12823. vals = this.options.values.slice();
  12824. for ( i = 0; i < vals.length; i += 1 ) {
  12825. vals[ i ] = this._trimAlignValue( vals[ i ] );
  12826. }
  12827. return vals;
  12828. } else {
  12829. return [];
  12830. }
  12831. },
  12832. // Returns the step-aligned value that val is closest to, between (inclusive) min and max
  12833. _trimAlignValue: function( val ) {
  12834. if ( val <= this._valueMin() ) {
  12835. return this._valueMin();
  12836. }
  12837. if ( val >= this._valueMax() ) {
  12838. return this._valueMax();
  12839. }
  12840. var step = ( this.options.step > 0 ) ? this.options.step : 1,
  12841. valModStep = ( val - this._valueMin() ) % step,
  12842. alignValue = val - valModStep;
  12843. if ( Math.abs( valModStep ) * 2 >= step ) {
  12844. alignValue += ( valModStep > 0 ) ? step : ( -step );
  12845. }
  12846. // Since JavaScript has problems with large floats, round
  12847. // the final value to 5 digits after the decimal point (see #4124)
  12848. return parseFloat( alignValue.toFixed( 5 ) );
  12849. },
  12850. _calculateNewMax: function() {
  12851. var max = this.options.max,
  12852. min = this._valueMin(),
  12853. step = this.options.step,
  12854. aboveMin = Math.round( ( max - min ) / step ) * step;
  12855. max = aboveMin + min;
  12856. if ( max > this.options.max ) {
  12857. //If max is not divisible by step, rounding off may increase its value
  12858. max -= step;
  12859. }
  12860. this.max = parseFloat( max.toFixed( this._precision() ) );
  12861. },
  12862. _precision: function() {
  12863. var precision = this._precisionOf( this.options.step );
  12864. if ( this.options.min !== null ) {
  12865. precision = Math.max( precision, this._precisionOf( this.options.min ) );
  12866. }
  12867. return precision;
  12868. },
  12869. _precisionOf: function( num ) {
  12870. var str = num.toString(),
  12871. decimal = str.indexOf( "." );
  12872. return decimal === -1 ? 0 : str.length - decimal - 1;
  12873. },
  12874. _valueMin: function() {
  12875. return this.options.min;
  12876. },
  12877. _valueMax: function() {
  12878. return this.max;
  12879. },
  12880. _refreshRange: function( orientation ) {
  12881. if ( orientation === "vertical" ) {
  12882. this.range.css( { "width": "", "left": "" } );
  12883. }
  12884. if ( orientation === "horizontal" ) {
  12885. this.range.css( { "height": "", "bottom": "" } );
  12886. }
  12887. },
  12888. _refreshValue: function() {
  12889. var lastValPercent, valPercent, value, valueMin, valueMax,
  12890. oRange = this.options.range,
  12891. o = this.options,
  12892. that = this,
  12893. animate = ( !this._animateOff ) ? o.animate : false,
  12894. _set = {};
  12895. if ( this._hasMultipleValues() ) {
  12896. this.handles.each( function( i ) {
  12897. valPercent = ( that.values( i ) - that._valueMin() ) / ( that._valueMax() -
  12898. that._valueMin() ) * 100;
  12899. _set[ that.orientation === "horizontal" ? "left" : "bottom" ] = valPercent + "%";
  12900. $( this ).stop( 1, 1 )[ animate ? "animate" : "css" ]( _set, o.animate );
  12901. if ( that.options.range === true ) {
  12902. if ( that.orientation === "horizontal" ) {
  12903. if ( i === 0 ) {
  12904. that.range.stop( 1, 1 )[ animate ? "animate" : "css" ]( {
  12905. left: valPercent + "%"
  12906. }, o.animate );
  12907. }
  12908. if ( i === 1 ) {
  12909. that.range[ animate ? "animate" : "css" ]( {
  12910. width: ( valPercent - lastValPercent ) + "%"
  12911. }, {
  12912. queue: false,
  12913. duration: o.animate
  12914. } );
  12915. }
  12916. } else {
  12917. if ( i === 0 ) {
  12918. that.range.stop( 1, 1 )[ animate ? "animate" : "css" ]( {
  12919. bottom: ( valPercent ) + "%"
  12920. }, o.animate );
  12921. }
  12922. if ( i === 1 ) {
  12923. that.range[ animate ? "animate" : "css" ]( {
  12924. height: ( valPercent - lastValPercent ) + "%"
  12925. }, {
  12926. queue: false,
  12927. duration: o.animate
  12928. } );
  12929. }
  12930. }
  12931. }
  12932. lastValPercent = valPercent;
  12933. } );
  12934. } else {
  12935. value = this.value();
  12936. valueMin = this._valueMin();
  12937. valueMax = this._valueMax();
  12938. valPercent = ( valueMax !== valueMin ) ?
  12939. ( value - valueMin ) / ( valueMax - valueMin ) * 100 :
  12940. 0;
  12941. _set[ this.orientation === "horizontal" ? "left" : "bottom" ] = valPercent + "%";
  12942. this.handle.stop( 1, 1 )[ animate ? "animate" : "css" ]( _set, o.animate );
  12943. if ( oRange === "min" && this.orientation === "horizontal" ) {
  12944. this.range.stop( 1, 1 )[ animate ? "animate" : "css" ]( {
  12945. width: valPercent + "%"
  12946. }, o.animate );
  12947. }
  12948. if ( oRange === "max" && this.orientation === "horizontal" ) {
  12949. this.range.stop( 1, 1 )[ animate ? "animate" : "css" ]( {
  12950. width: ( 100 - valPercent ) + "%"
  12951. }, o.animate );
  12952. }
  12953. if ( oRange === "min" && this.orientation === "vertical" ) {
  12954. this.range.stop( 1, 1 )[ animate ? "animate" : "css" ]( {
  12955. height: valPercent + "%"
  12956. }, o.animate );
  12957. }
  12958. if ( oRange === "max" && this.orientation === "vertical" ) {
  12959. this.range.stop( 1, 1 )[ animate ? "animate" : "css" ]( {
  12960. height: ( 100 - valPercent ) + "%"
  12961. }, o.animate );
  12962. }
  12963. }
  12964. },
  12965. _handleEvents: {
  12966. keydown: function( event ) {
  12967. var allowed, curVal, newVal, step,
  12968. index = $( event.target ).data( "ui-slider-handle-index" );
  12969. switch ( event.keyCode ) {
  12970. case $.ui.keyCode.HOME:
  12971. case $.ui.keyCode.END:
  12972. case $.ui.keyCode.PAGE_UP:
  12973. case $.ui.keyCode.PAGE_DOWN:
  12974. case $.ui.keyCode.UP:
  12975. case $.ui.keyCode.RIGHT:
  12976. case $.ui.keyCode.DOWN:
  12977. case $.ui.keyCode.LEFT:
  12978. event.preventDefault();
  12979. if ( !this._keySliding ) {
  12980. this._keySliding = true;
  12981. this._addClass( $( event.target ), null, "ui-state-active" );
  12982. allowed = this._start( event, index );
  12983. if ( allowed === false ) {
  12984. return;
  12985. }
  12986. }
  12987. break;
  12988. }
  12989. step = this.options.step;
  12990. if ( this._hasMultipleValues() ) {
  12991. curVal = newVal = this.values( index );
  12992. } else {
  12993. curVal = newVal = this.value();
  12994. }
  12995. switch ( event.keyCode ) {
  12996. case $.ui.keyCode.HOME:
  12997. newVal = this._valueMin();
  12998. break;
  12999. case $.ui.keyCode.END:
  13000. newVal = this._valueMax();
  13001. break;
  13002. case $.ui.keyCode.PAGE_UP:
  13003. newVal = this._trimAlignValue(
  13004. curVal + ( ( this._valueMax() - this._valueMin() ) / this.numPages )
  13005. );
  13006. break;
  13007. case $.ui.keyCode.PAGE_DOWN:
  13008. newVal = this._trimAlignValue(
  13009. curVal - ( ( this._valueMax() - this._valueMin() ) / this.numPages ) );
  13010. break;
  13011. case $.ui.keyCode.UP:
  13012. case $.ui.keyCode.RIGHT:
  13013. if ( curVal === this._valueMax() ) {
  13014. return;
  13015. }
  13016. newVal = this._trimAlignValue( curVal + step );
  13017. break;
  13018. case $.ui.keyCode.DOWN:
  13019. case $.ui.keyCode.LEFT:
  13020. if ( curVal === this._valueMin() ) {
  13021. return;
  13022. }
  13023. newVal = this._trimAlignValue( curVal - step );
  13024. break;
  13025. }
  13026. this._slide( event, index, newVal );
  13027. },
  13028. keyup: function( event ) {
  13029. var index = $( event.target ).data( "ui-slider-handle-index" );
  13030. if ( this._keySliding ) {
  13031. this._keySliding = false;
  13032. this._stop( event, index );
  13033. this._change( event, index );
  13034. this._removeClass( $( event.target ), null, "ui-state-active" );
  13035. }
  13036. }
  13037. }
  13038. } );
  13039. /*!
  13040. * jQuery UI Sortable 1.13.2
  13041. * http://jqueryui.com
  13042. *
  13043. * Copyright jQuery Foundation and other contributors
  13044. * Released under the MIT license.
  13045. * http://jquery.org/license
  13046. */
  13047. //>>label: Sortable
  13048. //>>group: Interactions
  13049. //>>description: Enables items in a list to be sorted using the mouse.
  13050. //>>docs: http://api.jqueryui.com/sortable/
  13051. //>>demos: http://jqueryui.com/sortable/
  13052. //>>css.structure: ../../themes/base/sortable.css
  13053. var widgetsSortable = $.widget( "ui.sortable", $.ui.mouse, {
  13054. version: "1.13.2",
  13055. widgetEventPrefix: "sort",
  13056. ready: false,
  13057. options: {
  13058. appendTo: "parent",
  13059. axis: false,
  13060. connectWith: false,
  13061. containment: false,
  13062. cursor: "auto",
  13063. cursorAt: false,
  13064. dropOnEmpty: true,
  13065. forcePlaceholderSize: false,
  13066. forceHelperSize: false,
  13067. grid: false,
  13068. handle: false,
  13069. helper: "original",
  13070. items: "> *",
  13071. opacity: false,
  13072. placeholder: false,
  13073. revert: false,
  13074. scroll: true,
  13075. scrollSensitivity: 20,
  13076. scrollSpeed: 20,
  13077. scope: "default",
  13078. tolerance: "intersect",
  13079. zIndex: 1000,
  13080. // Callbacks
  13081. activate: null,
  13082. beforeStop: null,
  13083. change: null,
  13084. deactivate: null,
  13085. out: null,
  13086. over: null,
  13087. receive: null,
  13088. remove: null,
  13089. sort: null,
  13090. start: null,
  13091. stop: null,
  13092. update: null
  13093. },
  13094. _isOverAxis: function( x, reference, size ) {
  13095. return ( x >= reference ) && ( x < ( reference + size ) );
  13096. },
  13097. _isFloating: function( item ) {
  13098. return ( /left|right/ ).test( item.css( "float" ) ) ||
  13099. ( /inline|table-cell/ ).test( item.css( "display" ) );
  13100. },
  13101. _create: function() {
  13102. this.containerCache = {};
  13103. this._addClass( "ui-sortable" );
  13104. //Get the items
  13105. this.refresh();
  13106. //Let's determine the parent's offset
  13107. this.offset = this.element.offset();
  13108. //Initialize mouse events for interaction
  13109. this._mouseInit();
  13110. this._setHandleClassName();
  13111. //We're ready to go
  13112. this.ready = true;
  13113. },
  13114. _setOption: function( key, value ) {
  13115. this._super( key, value );
  13116. if ( key === "handle" ) {
  13117. this._setHandleClassName();
  13118. }
  13119. },
  13120. _setHandleClassName: function() {
  13121. var that = this;
  13122. this._removeClass( this.element.find( ".ui-sortable-handle" ), "ui-sortable-handle" );
  13123. $.each( this.items, function() {
  13124. that._addClass(
  13125. this.instance.options.handle ?
  13126. this.item.find( this.instance.options.handle ) :
  13127. this.item,
  13128. "ui-sortable-handle"
  13129. );
  13130. } );
  13131. },
  13132. _destroy: function() {
  13133. this._mouseDestroy();
  13134. for ( var i = this.items.length - 1; i >= 0; i-- ) {
  13135. this.items[ i ].item.removeData( this.widgetName + "-item" );
  13136. }
  13137. return this;
  13138. },
  13139. _mouseCapture: function( event, overrideHandle ) {
  13140. var currentItem = null,
  13141. validHandle = false,
  13142. that = this;
  13143. if ( this.reverting ) {
  13144. return false;
  13145. }
  13146. if ( this.options.disabled || this.options.type === "static" ) {
  13147. return false;
  13148. }
  13149. //We have to refresh the items data once first
  13150. this._refreshItems( event );
  13151. //Find out if the clicked node (or one of its parents) is a actual item in this.items
  13152. $( event.target ).parents().each( function() {
  13153. if ( $.data( this, that.widgetName + "-item" ) === that ) {
  13154. currentItem = $( this );
  13155. return false;
  13156. }
  13157. } );
  13158. if ( $.data( event.target, that.widgetName + "-item" ) === that ) {
  13159. currentItem = $( event.target );
  13160. }
  13161. if ( !currentItem ) {
  13162. return false;
  13163. }
  13164. if ( this.options.handle && !overrideHandle ) {
  13165. $( this.options.handle, currentItem ).find( "*" ).addBack().each( function() {
  13166. if ( this === event.target ) {
  13167. validHandle = true;
  13168. }
  13169. } );
  13170. if ( !validHandle ) {
  13171. return false;
  13172. }
  13173. }
  13174. this.currentItem = currentItem;
  13175. this._removeCurrentsFromItems();
  13176. return true;
  13177. },
  13178. _mouseStart: function( event, overrideHandle, noActivation ) {
  13179. var i, body,
  13180. o = this.options;
  13181. this.currentContainer = this;
  13182. //We only need to call refreshPositions, because the refreshItems call has been moved to
  13183. // mouseCapture
  13184. this.refreshPositions();
  13185. //Prepare the dragged items parent
  13186. this.appendTo = $( o.appendTo !== "parent" ?
  13187. o.appendTo :
  13188. this.currentItem.parent() );
  13189. //Create and append the visible helper
  13190. this.helper = this._createHelper( event );
  13191. //Cache the helper size
  13192. this._cacheHelperProportions();
  13193. /*
  13194. * - Position generation -
  13195. * This block generates everything position related - it's the core of draggables.
  13196. */
  13197. //Cache the margins of the original element
  13198. this._cacheMargins();
  13199. //The element's absolute position on the page minus margins
  13200. this.offset = this.currentItem.offset();
  13201. this.offset = {
  13202. top: this.offset.top - this.margins.top,
  13203. left: this.offset.left - this.margins.left
  13204. };
  13205. $.extend( this.offset, {
  13206. click: { //Where the click happened, relative to the element
  13207. left: event.pageX - this.offset.left,
  13208. top: event.pageY - this.offset.top
  13209. },
  13210. // This is a relative to absolute position minus the actual position calculation -
  13211. // only used for relative positioned helper
  13212. relative: this._getRelativeOffset()
  13213. } );
  13214. // After we get the helper offset, but before we get the parent offset we can
  13215. // change the helper's position to absolute
  13216. // TODO: Still need to figure out a way to make relative sorting possible
  13217. this.helper.css( "position", "absolute" );
  13218. this.cssPosition = this.helper.css( "position" );
  13219. //Adjust the mouse offset relative to the helper if "cursorAt" is supplied
  13220. if ( o.cursorAt ) {
  13221. this._adjustOffsetFromHelper( o.cursorAt );
  13222. }
  13223. //Cache the former DOM position
  13224. this.domPosition = {
  13225. prev: this.currentItem.prev()[ 0 ],
  13226. parent: this.currentItem.parent()[ 0 ]
  13227. };
  13228. // If the helper is not the original, hide the original so it's not playing any role during
  13229. // the drag, won't cause anything bad this way
  13230. if ( this.helper[ 0 ] !== this.currentItem[ 0 ] ) {
  13231. this.currentItem.hide();
  13232. }
  13233. //Create the placeholder
  13234. this._createPlaceholder();
  13235. //Get the next scrolling parent
  13236. this.scrollParent = this.placeholder.scrollParent();
  13237. $.extend( this.offset, {
  13238. parent: this._getParentOffset()
  13239. } );
  13240. //Set a containment if given in the options
  13241. if ( o.containment ) {
  13242. this._setContainment();
  13243. }
  13244. if ( o.cursor && o.cursor !== "auto" ) { // cursor option
  13245. body = this.document.find( "body" );
  13246. // Support: IE
  13247. this.storedCursor = body.css( "cursor" );
  13248. body.css( "cursor", o.cursor );
  13249. this.storedStylesheet =
  13250. $( "<style>*{ cursor: " + o.cursor + " !important; }</style>" ).appendTo( body );
  13251. }
  13252. // We need to make sure to grab the zIndex before setting the
  13253. // opacity, because setting the opacity to anything lower than 1
  13254. // causes the zIndex to change from "auto" to 0.
  13255. if ( o.zIndex ) { // zIndex option
  13256. if ( this.helper.css( "zIndex" ) ) {
  13257. this._storedZIndex = this.helper.css( "zIndex" );
  13258. }
  13259. this.helper.css( "zIndex", o.zIndex );
  13260. }
  13261. if ( o.opacity ) { // opacity option
  13262. if ( this.helper.css( "opacity" ) ) {
  13263. this._storedOpacity = this.helper.css( "opacity" );
  13264. }
  13265. this.helper.css( "opacity", o.opacity );
  13266. }
  13267. //Prepare scrolling
  13268. if ( this.scrollParent[ 0 ] !== this.document[ 0 ] &&
  13269. this.scrollParent[ 0 ].tagName !== "HTML" ) {
  13270. this.overflowOffset = this.scrollParent.offset();
  13271. }
  13272. //Call callbacks
  13273. this._trigger( "start", event, this._uiHash() );
  13274. //Recache the helper size
  13275. if ( !this._preserveHelperProportions ) {
  13276. this._cacheHelperProportions();
  13277. }
  13278. //Post "activate" events to possible containers
  13279. if ( !noActivation ) {
  13280. for ( i = this.containers.length - 1; i >= 0; i-- ) {
  13281. this.containers[ i ]._trigger( "activate", event, this._uiHash( this ) );
  13282. }
  13283. }
  13284. //Prepare possible droppables
  13285. if ( $.ui.ddmanager ) {
  13286. $.ui.ddmanager.current = this;
  13287. }
  13288. if ( $.ui.ddmanager && !o.dropBehaviour ) {
  13289. $.ui.ddmanager.prepareOffsets( this, event );
  13290. }
  13291. this.dragging = true;
  13292. this._addClass( this.helper, "ui-sortable-helper" );
  13293. //Move the helper, if needed
  13294. if ( !this.helper.parent().is( this.appendTo ) ) {
  13295. this.helper.detach().appendTo( this.appendTo );
  13296. //Update position
  13297. this.offset.parent = this._getParentOffset();
  13298. }
  13299. //Generate the original position
  13300. this.position = this.originalPosition = this._generatePosition( event );
  13301. this.originalPageX = event.pageX;
  13302. this.originalPageY = event.pageY;
  13303. this.lastPositionAbs = this.positionAbs = this._convertPositionTo( "absolute" );
  13304. this._mouseDrag( event );
  13305. return true;
  13306. },
  13307. _scroll: function( event ) {
  13308. var o = this.options,
  13309. scrolled = false;
  13310. if ( this.scrollParent[ 0 ] !== this.document[ 0 ] &&
  13311. this.scrollParent[ 0 ].tagName !== "HTML" ) {
  13312. if ( ( this.overflowOffset.top + this.scrollParent[ 0 ].offsetHeight ) -
  13313. event.pageY < o.scrollSensitivity ) {
  13314. this.scrollParent[ 0 ].scrollTop =
  13315. scrolled = this.scrollParent[ 0 ].scrollTop + o.scrollSpeed;
  13316. } else if ( event.pageY - this.overflowOffset.top < o.scrollSensitivity ) {
  13317. this.scrollParent[ 0 ].scrollTop =
  13318. scrolled = this.scrollParent[ 0 ].scrollTop - o.scrollSpeed;
  13319. }
  13320. if ( ( this.overflowOffset.left + this.scrollParent[ 0 ].offsetWidth ) -
  13321. event.pageX < o.scrollSensitivity ) {
  13322. this.scrollParent[ 0 ].scrollLeft = scrolled =
  13323. this.scrollParent[ 0 ].scrollLeft + o.scrollSpeed;
  13324. } else if ( event.pageX - this.overflowOffset.left < o.scrollSensitivity ) {
  13325. this.scrollParent[ 0 ].scrollLeft = scrolled =
  13326. this.scrollParent[ 0 ].scrollLeft - o.scrollSpeed;
  13327. }
  13328. } else {
  13329. if ( event.pageY - this.document.scrollTop() < o.scrollSensitivity ) {
  13330. scrolled = this.document.scrollTop( this.document.scrollTop() - o.scrollSpeed );
  13331. } else if ( this.window.height() - ( event.pageY - this.document.scrollTop() ) <
  13332. o.scrollSensitivity ) {
  13333. scrolled = this.document.scrollTop( this.document.scrollTop() + o.scrollSpeed );
  13334. }
  13335. if ( event.pageX - this.document.scrollLeft() < o.scrollSensitivity ) {
  13336. scrolled = this.document.scrollLeft(
  13337. this.document.scrollLeft() - o.scrollSpeed
  13338. );
  13339. } else if ( this.window.width() - ( event.pageX - this.document.scrollLeft() ) <
  13340. o.scrollSensitivity ) {
  13341. scrolled = this.document.scrollLeft(
  13342. this.document.scrollLeft() + o.scrollSpeed
  13343. );
  13344. }
  13345. }
  13346. return scrolled;
  13347. },
  13348. _mouseDrag: function( event ) {
  13349. var i, item, itemElement, intersection,
  13350. o = this.options;
  13351. //Compute the helpers position
  13352. this.position = this._generatePosition( event );
  13353. this.positionAbs = this._convertPositionTo( "absolute" );
  13354. //Set the helper position
  13355. if ( !this.options.axis || this.options.axis !== "y" ) {
  13356. this.helper[ 0 ].style.left = this.position.left + "px";
  13357. }
  13358. if ( !this.options.axis || this.options.axis !== "x" ) {
  13359. this.helper[ 0 ].style.top = this.position.top + "px";
  13360. }
  13361. //Do scrolling
  13362. if ( o.scroll ) {
  13363. if ( this._scroll( event ) !== false ) {
  13364. //Update item positions used in position checks
  13365. this._refreshItemPositions( true );
  13366. if ( $.ui.ddmanager && !o.dropBehaviour ) {
  13367. $.ui.ddmanager.prepareOffsets( this, event );
  13368. }
  13369. }
  13370. }
  13371. this.dragDirection = {
  13372. vertical: this._getDragVerticalDirection(),
  13373. horizontal: this._getDragHorizontalDirection()
  13374. };
  13375. //Rearrange
  13376. for ( i = this.items.length - 1; i >= 0; i-- ) {
  13377. //Cache variables and intersection, continue if no intersection
  13378. item = this.items[ i ];
  13379. itemElement = item.item[ 0 ];
  13380. intersection = this._intersectsWithPointer( item );
  13381. if ( !intersection ) {
  13382. continue;
  13383. }
  13384. // Only put the placeholder inside the current Container, skip all
  13385. // items from other containers. This works because when moving
  13386. // an item from one container to another the
  13387. // currentContainer is switched before the placeholder is moved.
  13388. //
  13389. // Without this, moving items in "sub-sortables" can cause
  13390. // the placeholder to jitter between the outer and inner container.
  13391. if ( item.instance !== this.currentContainer ) {
  13392. continue;
  13393. }
  13394. // Cannot intersect with itself
  13395. // no useless actions that have been done before
  13396. // no action if the item moved is the parent of the item checked
  13397. if ( itemElement !== this.currentItem[ 0 ] &&
  13398. this.placeholder[ intersection === 1 ?
  13399. "next" : "prev" ]()[ 0 ] !== itemElement &&
  13400. !$.contains( this.placeholder[ 0 ], itemElement ) &&
  13401. ( this.options.type === "semi-dynamic" ?
  13402. !$.contains( this.element[ 0 ], itemElement ) :
  13403. true
  13404. )
  13405. ) {
  13406. this.direction = intersection === 1 ? "down" : "up";
  13407. if ( this.options.tolerance === "pointer" ||
  13408. this._intersectsWithSides( item ) ) {
  13409. this._rearrange( event, item );
  13410. } else {
  13411. break;
  13412. }
  13413. this._trigger( "change", event, this._uiHash() );
  13414. break;
  13415. }
  13416. }
  13417. //Post events to containers
  13418. this._contactContainers( event );
  13419. //Interconnect with droppables
  13420. if ( $.ui.ddmanager ) {
  13421. $.ui.ddmanager.drag( this, event );
  13422. }
  13423. //Call callbacks
  13424. this._trigger( "sort", event, this._uiHash() );
  13425. this.lastPositionAbs = this.positionAbs;
  13426. return false;
  13427. },
  13428. _mouseStop: function( event, noPropagation ) {
  13429. if ( !event ) {
  13430. return;
  13431. }
  13432. //If we are using droppables, inform the manager about the drop
  13433. if ( $.ui.ddmanager && !this.options.dropBehaviour ) {
  13434. $.ui.ddmanager.drop( this, event );
  13435. }
  13436. if ( this.options.revert ) {
  13437. var that = this,
  13438. cur = this.placeholder.offset(),
  13439. axis = this.options.axis,
  13440. animation = {};
  13441. if ( !axis || axis === "x" ) {
  13442. animation.left = cur.left - this.offset.parent.left - this.margins.left +
  13443. ( this.offsetParent[ 0 ] === this.document[ 0 ].body ?
  13444. 0 :
  13445. this.offsetParent[ 0 ].scrollLeft
  13446. );
  13447. }
  13448. if ( !axis || axis === "y" ) {
  13449. animation.top = cur.top - this.offset.parent.top - this.margins.top +
  13450. ( this.offsetParent[ 0 ] === this.document[ 0 ].body ?
  13451. 0 :
  13452. this.offsetParent[ 0 ].scrollTop
  13453. );
  13454. }
  13455. this.reverting = true;
  13456. $( this.helper ).animate(
  13457. animation,
  13458. parseInt( this.options.revert, 10 ) || 500,
  13459. function() {
  13460. that._clear( event );
  13461. }
  13462. );
  13463. } else {
  13464. this._clear( event, noPropagation );
  13465. }
  13466. return false;
  13467. },
  13468. cancel: function() {
  13469. if ( this.dragging ) {
  13470. this._mouseUp( new $.Event( "mouseup", { target: null } ) );
  13471. if ( this.options.helper === "original" ) {
  13472. this.currentItem.css( this._storedCSS );
  13473. this._removeClass( this.currentItem, "ui-sortable-helper" );
  13474. } else {
  13475. this.currentItem.show();
  13476. }
  13477. //Post deactivating events to containers
  13478. for ( var i = this.containers.length - 1; i >= 0; i-- ) {
  13479. this.containers[ i ]._trigger( "deactivate", null, this._uiHash( this ) );
  13480. if ( this.containers[ i ].containerCache.over ) {
  13481. this.containers[ i ]._trigger( "out", null, this._uiHash( this ) );
  13482. this.containers[ i ].containerCache.over = 0;
  13483. }
  13484. }
  13485. }
  13486. if ( this.placeholder ) {
  13487. //$(this.placeholder[0]).remove(); would have been the jQuery way - unfortunately,
  13488. // it unbinds ALL events from the original node!
  13489. if ( this.placeholder[ 0 ].parentNode ) {
  13490. this.placeholder[ 0 ].parentNode.removeChild( this.placeholder[ 0 ] );
  13491. }
  13492. if ( this.options.helper !== "original" && this.helper &&
  13493. this.helper[ 0 ].parentNode ) {
  13494. this.helper.remove();
  13495. }
  13496. $.extend( this, {
  13497. helper: null,
  13498. dragging: false,
  13499. reverting: false,
  13500. _noFinalSort: null
  13501. } );
  13502. if ( this.domPosition.prev ) {
  13503. $( this.domPosition.prev ).after( this.currentItem );
  13504. } else {
  13505. $( this.domPosition.parent ).prepend( this.currentItem );
  13506. }
  13507. }
  13508. return this;
  13509. },
  13510. serialize: function( o ) {
  13511. var items = this._getItemsAsjQuery( o && o.connected ),
  13512. str = [];
  13513. o = o || {};
  13514. $( items ).each( function() {
  13515. var res = ( $( o.item || this ).attr( o.attribute || "id" ) || "" )
  13516. .match( o.expression || ( /(.+)[\-=_](.+)/ ) );
  13517. if ( res ) {
  13518. str.push(
  13519. ( o.key || res[ 1 ] + "[]" ) +
  13520. "=" + ( o.key && o.expression ? res[ 1 ] : res[ 2 ] ) );
  13521. }
  13522. } );
  13523. if ( !str.length && o.key ) {
  13524. str.push( o.key + "=" );
  13525. }
  13526. return str.join( "&" );
  13527. },
  13528. toArray: function( o ) {
  13529. var items = this._getItemsAsjQuery( o && o.connected ),
  13530. ret = [];
  13531. o = o || {};
  13532. items.each( function() {
  13533. ret.push( $( o.item || this ).attr( o.attribute || "id" ) || "" );
  13534. } );
  13535. return ret;
  13536. },
  13537. /* Be careful with the following core functions */
  13538. _intersectsWith: function( item ) {
  13539. var x1 = this.positionAbs.left,
  13540. x2 = x1 + this.helperProportions.width,
  13541. y1 = this.positionAbs.top,
  13542. y2 = y1 + this.helperProportions.height,
  13543. l = item.left,
  13544. r = l + item.width,
  13545. t = item.top,
  13546. b = t + item.height,
  13547. dyClick = this.offset.click.top,
  13548. dxClick = this.offset.click.left,
  13549. isOverElementHeight = ( this.options.axis === "x" ) || ( ( y1 + dyClick ) > t &&
  13550. ( y1 + dyClick ) < b ),
  13551. isOverElementWidth = ( this.options.axis === "y" ) || ( ( x1 + dxClick ) > l &&
  13552. ( x1 + dxClick ) < r ),
  13553. isOverElement = isOverElementHeight && isOverElementWidth;
  13554. if ( this.options.tolerance === "pointer" ||
  13555. this.options.forcePointerForContainers ||
  13556. ( this.options.tolerance !== "pointer" &&
  13557. this.helperProportions[ this.floating ? "width" : "height" ] >
  13558. item[ this.floating ? "width" : "height" ] )
  13559. ) {
  13560. return isOverElement;
  13561. } else {
  13562. return ( l < x1 + ( this.helperProportions.width / 2 ) && // Right Half
  13563. x2 - ( this.helperProportions.width / 2 ) < r && // Left Half
  13564. t < y1 + ( this.helperProportions.height / 2 ) && // Bottom Half
  13565. y2 - ( this.helperProportions.height / 2 ) < b ); // Top Half
  13566. }
  13567. },
  13568. _intersectsWithPointer: function( item ) {
  13569. var verticalDirection, horizontalDirection,
  13570. isOverElementHeight = ( this.options.axis === "x" ) ||
  13571. this._isOverAxis(
  13572. this.positionAbs.top + this.offset.click.top, item.top, item.height ),
  13573. isOverElementWidth = ( this.options.axis === "y" ) ||
  13574. this._isOverAxis(
  13575. this.positionAbs.left + this.offset.click.left, item.left, item.width ),
  13576. isOverElement = isOverElementHeight && isOverElementWidth;
  13577. if ( !isOverElement ) {
  13578. return false;
  13579. }
  13580. verticalDirection = this.dragDirection.vertical;
  13581. horizontalDirection = this.dragDirection.horizontal;
  13582. return this.floating ?
  13583. ( ( horizontalDirection === "right" || verticalDirection === "down" ) ? 2 : 1 ) :
  13584. ( verticalDirection && ( verticalDirection === "down" ? 2 : 1 ) );
  13585. },
  13586. _intersectsWithSides: function( item ) {
  13587. var isOverBottomHalf = this._isOverAxis( this.positionAbs.top +
  13588. this.offset.click.top, item.top + ( item.height / 2 ), item.height ),
  13589. isOverRightHalf = this._isOverAxis( this.positionAbs.left +
  13590. this.offset.click.left, item.left + ( item.width / 2 ), item.width ),
  13591. verticalDirection = this.dragDirection.vertical,
  13592. horizontalDirection = this.dragDirection.horizontal;
  13593. if ( this.floating && horizontalDirection ) {
  13594. return ( ( horizontalDirection === "right" && isOverRightHalf ) ||
  13595. ( horizontalDirection === "left" && !isOverRightHalf ) );
  13596. } else {
  13597. return verticalDirection && ( ( verticalDirection === "down" && isOverBottomHalf ) ||
  13598. ( verticalDirection === "up" && !isOverBottomHalf ) );
  13599. }
  13600. },
  13601. _getDragVerticalDirection: function() {
  13602. var delta = this.positionAbs.top - this.lastPositionAbs.top;
  13603. return delta !== 0 && ( delta > 0 ? "down" : "up" );
  13604. },
  13605. _getDragHorizontalDirection: function() {
  13606. var delta = this.positionAbs.left - this.lastPositionAbs.left;
  13607. return delta !== 0 && ( delta > 0 ? "right" : "left" );
  13608. },
  13609. refresh: function( event ) {
  13610. this._refreshItems( event );
  13611. this._setHandleClassName();
  13612. this.refreshPositions();
  13613. return this;
  13614. },
  13615. _connectWith: function() {
  13616. var options = this.options;
  13617. return options.connectWith.constructor === String ?
  13618. [ options.connectWith ] :
  13619. options.connectWith;
  13620. },
  13621. _getItemsAsjQuery: function( connected ) {
  13622. var i, j, cur, inst,
  13623. items = [],
  13624. queries = [],
  13625. connectWith = this._connectWith();
  13626. if ( connectWith && connected ) {
  13627. for ( i = connectWith.length - 1; i >= 0; i-- ) {
  13628. cur = $( connectWith[ i ], this.document[ 0 ] );
  13629. for ( j = cur.length - 1; j >= 0; j-- ) {
  13630. inst = $.data( cur[ j ], this.widgetFullName );
  13631. if ( inst && inst !== this && !inst.options.disabled ) {
  13632. queries.push( [ typeof inst.options.items === "function" ?
  13633. inst.options.items.call( inst.element ) :
  13634. $( inst.options.items, inst.element )
  13635. .not( ".ui-sortable-helper" )
  13636. .not( ".ui-sortable-placeholder" ), inst ] );
  13637. }
  13638. }
  13639. }
  13640. }
  13641. queries.push( [ typeof this.options.items === "function" ?
  13642. this.options.items
  13643. .call( this.element, null, { options: this.options, item: this.currentItem } ) :
  13644. $( this.options.items, this.element )
  13645. .not( ".ui-sortable-helper" )
  13646. .not( ".ui-sortable-placeholder" ), this ] );
  13647. function addItems() {
  13648. items.push( this );
  13649. }
  13650. for ( i = queries.length - 1; i >= 0; i-- ) {
  13651. queries[ i ][ 0 ].each( addItems );
  13652. }
  13653. return $( items );
  13654. },
  13655. _removeCurrentsFromItems: function() {
  13656. var list = this.currentItem.find( ":data(" + this.widgetName + "-item)" );
  13657. this.items = $.grep( this.items, function( item ) {
  13658. for ( var j = 0; j < list.length; j++ ) {
  13659. if ( list[ j ] === item.item[ 0 ] ) {
  13660. return false;
  13661. }
  13662. }
  13663. return true;
  13664. } );
  13665. },
  13666. _refreshItems: function( event ) {
  13667. this.items = [];
  13668. this.containers = [ this ];
  13669. var i, j, cur, inst, targetData, _queries, item, queriesLength,
  13670. items = this.items,
  13671. queries = [ [ typeof this.options.items === "function" ?
  13672. this.options.items.call( this.element[ 0 ], event, { item: this.currentItem } ) :
  13673. $( this.options.items, this.element ), this ] ],
  13674. connectWith = this._connectWith();
  13675. //Shouldn't be run the first time through due to massive slow-down
  13676. if ( connectWith && this.ready ) {
  13677. for ( i = connectWith.length - 1; i >= 0; i-- ) {
  13678. cur = $( connectWith[ i ], this.document[ 0 ] );
  13679. for ( j = cur.length - 1; j >= 0; j-- ) {
  13680. inst = $.data( cur[ j ], this.widgetFullName );
  13681. if ( inst && inst !== this && !inst.options.disabled ) {
  13682. queries.push( [ typeof inst.options.items === "function" ?
  13683. inst.options.items
  13684. .call( inst.element[ 0 ], event, { item: this.currentItem } ) :
  13685. $( inst.options.items, inst.element ), inst ] );
  13686. this.containers.push( inst );
  13687. }
  13688. }
  13689. }
  13690. }
  13691. for ( i = queries.length - 1; i >= 0; i-- ) {
  13692. targetData = queries[ i ][ 1 ];
  13693. _queries = queries[ i ][ 0 ];
  13694. for ( j = 0, queriesLength = _queries.length; j < queriesLength; j++ ) {
  13695. item = $( _queries[ j ] );
  13696. // Data for target checking (mouse manager)
  13697. item.data( this.widgetName + "-item", targetData );
  13698. items.push( {
  13699. item: item,
  13700. instance: targetData,
  13701. width: 0, height: 0,
  13702. left: 0, top: 0
  13703. } );
  13704. }
  13705. }
  13706. },
  13707. _refreshItemPositions: function( fast ) {
  13708. var i, item, t, p;
  13709. for ( i = this.items.length - 1; i >= 0; i-- ) {
  13710. item = this.items[ i ];
  13711. //We ignore calculating positions of all connected containers when we're not over them
  13712. if ( this.currentContainer && item.instance !== this.currentContainer &&
  13713. item.item[ 0 ] !== this.currentItem[ 0 ] ) {
  13714. continue;
  13715. }
  13716. t = this.options.toleranceElement ?
  13717. $( this.options.toleranceElement, item.item ) :
  13718. item.item;
  13719. if ( !fast ) {
  13720. item.width = t.outerWidth();
  13721. item.height = t.outerHeight();
  13722. }
  13723. p = t.offset();
  13724. item.left = p.left;
  13725. item.top = p.top;
  13726. }
  13727. },
  13728. refreshPositions: function( fast ) {
  13729. // Determine whether items are being displayed horizontally
  13730. this.floating = this.items.length ?
  13731. this.options.axis === "x" || this._isFloating( this.items[ 0 ].item ) :
  13732. false;
  13733. // This has to be redone because due to the item being moved out/into the offsetParent,
  13734. // the offsetParent's position will change
  13735. if ( this.offsetParent && this.helper ) {
  13736. this.offset.parent = this._getParentOffset();
  13737. }
  13738. this._refreshItemPositions( fast );
  13739. var i, p;
  13740. if ( this.options.custom && this.options.custom.refreshContainers ) {
  13741. this.options.custom.refreshContainers.call( this );
  13742. } else {
  13743. for ( i = this.containers.length - 1; i >= 0; i-- ) {
  13744. p = this.containers[ i ].element.offset();
  13745. this.containers[ i ].containerCache.left = p.left;
  13746. this.containers[ i ].containerCache.top = p.top;
  13747. this.containers[ i ].containerCache.width =
  13748. this.containers[ i ].element.outerWidth();
  13749. this.containers[ i ].containerCache.height =
  13750. this.containers[ i ].element.outerHeight();
  13751. }
  13752. }
  13753. return this;
  13754. },
  13755. _createPlaceholder: function( that ) {
  13756. that = that || this;
  13757. var className, nodeName,
  13758. o = that.options;
  13759. if ( !o.placeholder || o.placeholder.constructor === String ) {
  13760. className = o.placeholder;
  13761. nodeName = that.currentItem[ 0 ].nodeName.toLowerCase();
  13762. o.placeholder = {
  13763. element: function() {
  13764. var element = $( "<" + nodeName + ">", that.document[ 0 ] );
  13765. that._addClass( element, "ui-sortable-placeholder",
  13766. className || that.currentItem[ 0 ].className )
  13767. ._removeClass( element, "ui-sortable-helper" );
  13768. if ( nodeName === "tbody" ) {
  13769. that._createTrPlaceholder(
  13770. that.currentItem.find( "tr" ).eq( 0 ),
  13771. $( "<tr>", that.document[ 0 ] ).appendTo( element )
  13772. );
  13773. } else if ( nodeName === "tr" ) {
  13774. that._createTrPlaceholder( that.currentItem, element );
  13775. } else if ( nodeName === "img" ) {
  13776. element.attr( "src", that.currentItem.attr( "src" ) );
  13777. }
  13778. if ( !className ) {
  13779. element.css( "visibility", "hidden" );
  13780. }
  13781. return element;
  13782. },
  13783. update: function( container, p ) {
  13784. // 1. If a className is set as 'placeholder option, we don't force sizes -
  13785. // the class is responsible for that
  13786. // 2. The option 'forcePlaceholderSize can be enabled to force it even if a
  13787. // class name is specified
  13788. if ( className && !o.forcePlaceholderSize ) {
  13789. return;
  13790. }
  13791. // If the element doesn't have a actual height or width by itself (without
  13792. // styles coming from a stylesheet), it receives the inline height and width
  13793. // from the dragged item. Or, if it's a tbody or tr, it's going to have a height
  13794. // anyway since we're populating them with <td>s above, but they're unlikely to
  13795. // be the correct height on their own if the row heights are dynamic, so we'll
  13796. // always assign the height of the dragged item given forcePlaceholderSize
  13797. // is true.
  13798. if ( !p.height() || ( o.forcePlaceholderSize &&
  13799. ( nodeName === "tbody" || nodeName === "tr" ) ) ) {
  13800. p.height(
  13801. that.currentItem.innerHeight() -
  13802. parseInt( that.currentItem.css( "paddingTop" ) || 0, 10 ) -
  13803. parseInt( that.currentItem.css( "paddingBottom" ) || 0, 10 ) );
  13804. }
  13805. if ( !p.width() ) {
  13806. p.width(
  13807. that.currentItem.innerWidth() -
  13808. parseInt( that.currentItem.css( "paddingLeft" ) || 0, 10 ) -
  13809. parseInt( that.currentItem.css( "paddingRight" ) || 0, 10 ) );
  13810. }
  13811. }
  13812. };
  13813. }
  13814. //Create the placeholder
  13815. that.placeholder = $( o.placeholder.element.call( that.element, that.currentItem ) );
  13816. //Append it after the actual current item
  13817. that.currentItem.after( that.placeholder );
  13818. //Update the size of the placeholder (TODO: Logic to fuzzy, see line 316/317)
  13819. o.placeholder.update( that, that.placeholder );
  13820. },
  13821. _createTrPlaceholder: function( sourceTr, targetTr ) {
  13822. var that = this;
  13823. sourceTr.children().each( function() {
  13824. $( "<td>&#160;</td>", that.document[ 0 ] )
  13825. .attr( "colspan", $( this ).attr( "colspan" ) || 1 )
  13826. .appendTo( targetTr );
  13827. } );
  13828. },
  13829. _contactContainers: function( event ) {
  13830. var i, j, dist, itemWithLeastDistance, posProperty, sizeProperty, cur, nearBottom,
  13831. floating, axis,
  13832. innermostContainer = null,
  13833. innermostIndex = null;
  13834. // Get innermost container that intersects with item
  13835. for ( i = this.containers.length - 1; i >= 0; i-- ) {
  13836. // Never consider a container that's located within the item itself
  13837. if ( $.contains( this.currentItem[ 0 ], this.containers[ i ].element[ 0 ] ) ) {
  13838. continue;
  13839. }
  13840. if ( this._intersectsWith( this.containers[ i ].containerCache ) ) {
  13841. // If we've already found a container and it's more "inner" than this, then continue
  13842. if ( innermostContainer &&
  13843. $.contains(
  13844. this.containers[ i ].element[ 0 ],
  13845. innermostContainer.element[ 0 ] ) ) {
  13846. continue;
  13847. }
  13848. innermostContainer = this.containers[ i ];
  13849. innermostIndex = i;
  13850. } else {
  13851. // container doesn't intersect. trigger "out" event if necessary
  13852. if ( this.containers[ i ].containerCache.over ) {
  13853. this.containers[ i ]._trigger( "out", event, this._uiHash( this ) );
  13854. this.containers[ i ].containerCache.over = 0;
  13855. }
  13856. }
  13857. }
  13858. // If no intersecting containers found, return
  13859. if ( !innermostContainer ) {
  13860. return;
  13861. }
  13862. // Move the item into the container if it's not there already
  13863. if ( this.containers.length === 1 ) {
  13864. if ( !this.containers[ innermostIndex ].containerCache.over ) {
  13865. this.containers[ innermostIndex ]._trigger( "over", event, this._uiHash( this ) );
  13866. this.containers[ innermostIndex ].containerCache.over = 1;
  13867. }
  13868. } else {
  13869. // When entering a new container, we will find the item with the least distance and
  13870. // append our item near it
  13871. dist = 10000;
  13872. itemWithLeastDistance = null;
  13873. floating = innermostContainer.floating || this._isFloating( this.currentItem );
  13874. posProperty = floating ? "left" : "top";
  13875. sizeProperty = floating ? "width" : "height";
  13876. axis = floating ? "pageX" : "pageY";
  13877. for ( j = this.items.length - 1; j >= 0; j-- ) {
  13878. if ( !$.contains(
  13879. this.containers[ innermostIndex ].element[ 0 ], this.items[ j ].item[ 0 ] )
  13880. ) {
  13881. continue;
  13882. }
  13883. if ( this.items[ j ].item[ 0 ] === this.currentItem[ 0 ] ) {
  13884. continue;
  13885. }
  13886. cur = this.items[ j ].item.offset()[ posProperty ];
  13887. nearBottom = false;
  13888. if ( event[ axis ] - cur > this.items[ j ][ sizeProperty ] / 2 ) {
  13889. nearBottom = true;
  13890. }
  13891. if ( Math.abs( event[ axis ] - cur ) < dist ) {
  13892. dist = Math.abs( event[ axis ] - cur );
  13893. itemWithLeastDistance = this.items[ j ];
  13894. this.direction = nearBottom ? "up" : "down";
  13895. }
  13896. }
  13897. //Check if dropOnEmpty is enabled
  13898. if ( !itemWithLeastDistance && !this.options.dropOnEmpty ) {
  13899. return;
  13900. }
  13901. if ( this.currentContainer === this.containers[ innermostIndex ] ) {
  13902. if ( !this.currentContainer.containerCache.over ) {
  13903. this.containers[ innermostIndex ]._trigger( "over", event, this._uiHash() );
  13904. this.currentContainer.containerCache.over = 1;
  13905. }
  13906. return;
  13907. }
  13908. if ( itemWithLeastDistance ) {
  13909. this._rearrange( event, itemWithLeastDistance, null, true );
  13910. } else {
  13911. this._rearrange( event, null, this.containers[ innermostIndex ].element, true );
  13912. }
  13913. this._trigger( "change", event, this._uiHash() );
  13914. this.containers[ innermostIndex ]._trigger( "change", event, this._uiHash( this ) );
  13915. this.currentContainer = this.containers[ innermostIndex ];
  13916. //Update the placeholder
  13917. this.options.placeholder.update( this.currentContainer, this.placeholder );
  13918. //Update scrollParent
  13919. this.scrollParent = this.placeholder.scrollParent();
  13920. //Update overflowOffset
  13921. if ( this.scrollParent[ 0 ] !== this.document[ 0 ] &&
  13922. this.scrollParent[ 0 ].tagName !== "HTML" ) {
  13923. this.overflowOffset = this.scrollParent.offset();
  13924. }
  13925. this.containers[ innermostIndex ]._trigger( "over", event, this._uiHash( this ) );
  13926. this.containers[ innermostIndex ].containerCache.over = 1;
  13927. }
  13928. },
  13929. _createHelper: function( event ) {
  13930. var o = this.options,
  13931. helper = typeof o.helper === "function" ?
  13932. $( o.helper.apply( this.element[ 0 ], [ event, this.currentItem ] ) ) :
  13933. ( o.helper === "clone" ? this.currentItem.clone() : this.currentItem );
  13934. //Add the helper to the DOM if that didn't happen already
  13935. if ( !helper.parents( "body" ).length ) {
  13936. this.appendTo[ 0 ].appendChild( helper[ 0 ] );
  13937. }
  13938. if ( helper[ 0 ] === this.currentItem[ 0 ] ) {
  13939. this._storedCSS = {
  13940. width: this.currentItem[ 0 ].style.width,
  13941. height: this.currentItem[ 0 ].style.height,
  13942. position: this.currentItem.css( "position" ),
  13943. top: this.currentItem.css( "top" ),
  13944. left: this.currentItem.css( "left" )
  13945. };
  13946. }
  13947. if ( !helper[ 0 ].style.width || o.forceHelperSize ) {
  13948. helper.width( this.currentItem.width() );
  13949. }
  13950. if ( !helper[ 0 ].style.height || o.forceHelperSize ) {
  13951. helper.height( this.currentItem.height() );
  13952. }
  13953. return helper;
  13954. },
  13955. _adjustOffsetFromHelper: function( obj ) {
  13956. if ( typeof obj === "string" ) {
  13957. obj = obj.split( " " );
  13958. }
  13959. if ( Array.isArray( obj ) ) {
  13960. obj = { left: +obj[ 0 ], top: +obj[ 1 ] || 0 };
  13961. }
  13962. if ( "left" in obj ) {
  13963. this.offset.click.left = obj.left + this.margins.left;
  13964. }
  13965. if ( "right" in obj ) {
  13966. this.offset.click.left = this.helperProportions.width - obj.right + this.margins.left;
  13967. }
  13968. if ( "top" in obj ) {
  13969. this.offset.click.top = obj.top + this.margins.top;
  13970. }
  13971. if ( "bottom" in obj ) {
  13972. this.offset.click.top = this.helperProportions.height - obj.bottom + this.margins.top;
  13973. }
  13974. },
  13975. _getParentOffset: function() {
  13976. //Get the offsetParent and cache its position
  13977. this.offsetParent = this.helper.offsetParent();
  13978. var po = this.offsetParent.offset();
  13979. // This is a special case where we need to modify a offset calculated on start, since the
  13980. // following happened:
  13981. // 1. The position of the helper is absolute, so it's position is calculated based on the
  13982. // next positioned parent
  13983. // 2. The actual offset parent is a child of the scroll parent, and the scroll parent isn't
  13984. // the document, which means that the scroll is included in the initial calculation of the
  13985. // offset of the parent, and never recalculated upon drag
  13986. if ( this.cssPosition === "absolute" && this.scrollParent[ 0 ] !== this.document[ 0 ] &&
  13987. $.contains( this.scrollParent[ 0 ], this.offsetParent[ 0 ] ) ) {
  13988. po.left += this.scrollParent.scrollLeft();
  13989. po.top += this.scrollParent.scrollTop();
  13990. }
  13991. // This needs to be actually done for all browsers, since pageX/pageY includes this
  13992. // information with an ugly IE fix
  13993. if ( this.offsetParent[ 0 ] === this.document[ 0 ].body ||
  13994. ( this.offsetParent[ 0 ].tagName &&
  13995. this.offsetParent[ 0 ].tagName.toLowerCase() === "html" && $.ui.ie ) ) {
  13996. po = { top: 0, left: 0 };
  13997. }
  13998. return {
  13999. top: po.top + ( parseInt( this.offsetParent.css( "borderTopWidth" ), 10 ) || 0 ),
  14000. left: po.left + ( parseInt( this.offsetParent.css( "borderLeftWidth" ), 10 ) || 0 )
  14001. };
  14002. },
  14003. _getRelativeOffset: function() {
  14004. if ( this.cssPosition === "relative" ) {
  14005. var p = this.currentItem.position();
  14006. return {
  14007. top: p.top - ( parseInt( this.helper.css( "top" ), 10 ) || 0 ) +
  14008. this.scrollParent.scrollTop(),
  14009. left: p.left - ( parseInt( this.helper.css( "left" ), 10 ) || 0 ) +
  14010. this.scrollParent.scrollLeft()
  14011. };
  14012. } else {
  14013. return { top: 0, left: 0 };
  14014. }
  14015. },
  14016. _cacheMargins: function() {
  14017. this.margins = {
  14018. left: ( parseInt( this.currentItem.css( "marginLeft" ), 10 ) || 0 ),
  14019. top: ( parseInt( this.currentItem.css( "marginTop" ), 10 ) || 0 )
  14020. };
  14021. },
  14022. _cacheHelperProportions: function() {
  14023. this.helperProportions = {
  14024. width: this.helper.outerWidth(),
  14025. height: this.helper.outerHeight()
  14026. };
  14027. },
  14028. _setContainment: function() {
  14029. var ce, co, over,
  14030. o = this.options;
  14031. if ( o.containment === "parent" ) {
  14032. o.containment = this.helper[ 0 ].parentNode;
  14033. }
  14034. if ( o.containment === "document" || o.containment === "window" ) {
  14035. this.containment = [
  14036. 0 - this.offset.relative.left - this.offset.parent.left,
  14037. 0 - this.offset.relative.top - this.offset.parent.top,
  14038. o.containment === "document" ?
  14039. this.document.width() :
  14040. this.window.width() - this.helperProportions.width - this.margins.left,
  14041. ( o.containment === "document" ?
  14042. ( this.document.height() || document.body.parentNode.scrollHeight ) :
  14043. this.window.height() || this.document[ 0 ].body.parentNode.scrollHeight
  14044. ) - this.helperProportions.height - this.margins.top
  14045. ];
  14046. }
  14047. if ( !( /^(document|window|parent)$/ ).test( o.containment ) ) {
  14048. ce = $( o.containment )[ 0 ];
  14049. co = $( o.containment ).offset();
  14050. over = ( $( ce ).css( "overflow" ) !== "hidden" );
  14051. this.containment = [
  14052. co.left + ( parseInt( $( ce ).css( "borderLeftWidth" ), 10 ) || 0 ) +
  14053. ( parseInt( $( ce ).css( "paddingLeft" ), 10 ) || 0 ) - this.margins.left,
  14054. co.top + ( parseInt( $( ce ).css( "borderTopWidth" ), 10 ) || 0 ) +
  14055. ( parseInt( $( ce ).css( "paddingTop" ), 10 ) || 0 ) - this.margins.top,
  14056. co.left + ( over ? Math.max( ce.scrollWidth, ce.offsetWidth ) : ce.offsetWidth ) -
  14057. ( parseInt( $( ce ).css( "borderLeftWidth" ), 10 ) || 0 ) -
  14058. ( parseInt( $( ce ).css( "paddingRight" ), 10 ) || 0 ) -
  14059. this.helperProportions.width - this.margins.left,
  14060. co.top + ( over ? Math.max( ce.scrollHeight, ce.offsetHeight ) : ce.offsetHeight ) -
  14061. ( parseInt( $( ce ).css( "borderTopWidth" ), 10 ) || 0 ) -
  14062. ( parseInt( $( ce ).css( "paddingBottom" ), 10 ) || 0 ) -
  14063. this.helperProportions.height - this.margins.top
  14064. ];
  14065. }
  14066. },
  14067. _convertPositionTo: function( d, pos ) {
  14068. if ( !pos ) {
  14069. pos = this.position;
  14070. }
  14071. var mod = d === "absolute" ? 1 : -1,
  14072. scroll = this.cssPosition === "absolute" &&
  14073. !( this.scrollParent[ 0 ] !== this.document[ 0 ] &&
  14074. $.contains( this.scrollParent[ 0 ], this.offsetParent[ 0 ] ) ) ?
  14075. this.offsetParent :
  14076. this.scrollParent,
  14077. scrollIsRootNode = ( /(html|body)/i ).test( scroll[ 0 ].tagName );
  14078. return {
  14079. top: (
  14080. // The absolute mouse position
  14081. pos.top +
  14082. // Only for relative positioned nodes: Relative offset from element to offset parent
  14083. this.offset.relative.top * mod +
  14084. // The offsetParent's offset without borders (offset + border)
  14085. this.offset.parent.top * mod -
  14086. ( ( this.cssPosition === "fixed" ?
  14087. -this.scrollParent.scrollTop() :
  14088. ( scrollIsRootNode ? 0 : scroll.scrollTop() ) ) * mod )
  14089. ),
  14090. left: (
  14091. // The absolute mouse position
  14092. pos.left +
  14093. // Only for relative positioned nodes: Relative offset from element to offset parent
  14094. this.offset.relative.left * mod +
  14095. // The offsetParent's offset without borders (offset + border)
  14096. this.offset.parent.left * mod -
  14097. ( ( this.cssPosition === "fixed" ?
  14098. -this.scrollParent.scrollLeft() : scrollIsRootNode ? 0 :
  14099. scroll.scrollLeft() ) * mod )
  14100. )
  14101. };
  14102. },
  14103. _generatePosition: function( event ) {
  14104. var top, left,
  14105. o = this.options,
  14106. pageX = event.pageX,
  14107. pageY = event.pageY,
  14108. scroll = this.cssPosition === "absolute" &&
  14109. !( this.scrollParent[ 0 ] !== this.document[ 0 ] &&
  14110. $.contains( this.scrollParent[ 0 ], this.offsetParent[ 0 ] ) ) ?
  14111. this.offsetParent :
  14112. this.scrollParent,
  14113. scrollIsRootNode = ( /(html|body)/i ).test( scroll[ 0 ].tagName );
  14114. // This is another very weird special case that only happens for relative elements:
  14115. // 1. If the css position is relative
  14116. // 2. and the scroll parent is the document or similar to the offset parent
  14117. // we have to refresh the relative offset during the scroll so there are no jumps
  14118. if ( this.cssPosition === "relative" && !( this.scrollParent[ 0 ] !== this.document[ 0 ] &&
  14119. this.scrollParent[ 0 ] !== this.offsetParent[ 0 ] ) ) {
  14120. this.offset.relative = this._getRelativeOffset();
  14121. }
  14122. /*
  14123. * - Position constraining -
  14124. * Constrain the position to a mix of grid, containment.
  14125. */
  14126. if ( this.originalPosition ) { //If we are not dragging yet, we won't check for options
  14127. if ( this.containment ) {
  14128. if ( event.pageX - this.offset.click.left < this.containment[ 0 ] ) {
  14129. pageX = this.containment[ 0 ] + this.offset.click.left;
  14130. }
  14131. if ( event.pageY - this.offset.click.top < this.containment[ 1 ] ) {
  14132. pageY = this.containment[ 1 ] + this.offset.click.top;
  14133. }
  14134. if ( event.pageX - this.offset.click.left > this.containment[ 2 ] ) {
  14135. pageX = this.containment[ 2 ] + this.offset.click.left;
  14136. }
  14137. if ( event.pageY - this.offset.click.top > this.containment[ 3 ] ) {
  14138. pageY = this.containment[ 3 ] + this.offset.click.top;
  14139. }
  14140. }
  14141. if ( o.grid ) {
  14142. top = this.originalPageY + Math.round( ( pageY - this.originalPageY ) /
  14143. o.grid[ 1 ] ) * o.grid[ 1 ];
  14144. pageY = this.containment ?
  14145. ( ( top - this.offset.click.top >= this.containment[ 1 ] &&
  14146. top - this.offset.click.top <= this.containment[ 3 ] ) ?
  14147. top :
  14148. ( ( top - this.offset.click.top >= this.containment[ 1 ] ) ?
  14149. top - o.grid[ 1 ] : top + o.grid[ 1 ] ) ) :
  14150. top;
  14151. left = this.originalPageX + Math.round( ( pageX - this.originalPageX ) /
  14152. o.grid[ 0 ] ) * o.grid[ 0 ];
  14153. pageX = this.containment ?
  14154. ( ( left - this.offset.click.left >= this.containment[ 0 ] &&
  14155. left - this.offset.click.left <= this.containment[ 2 ] ) ?
  14156. left :
  14157. ( ( left - this.offset.click.left >= this.containment[ 0 ] ) ?
  14158. left - o.grid[ 0 ] : left + o.grid[ 0 ] ) ) :
  14159. left;
  14160. }
  14161. }
  14162. return {
  14163. top: (
  14164. // The absolute mouse position
  14165. pageY -
  14166. // Click offset (relative to the element)
  14167. this.offset.click.top -
  14168. // Only for relative positioned nodes: Relative offset from element to offset parent
  14169. this.offset.relative.top -
  14170. // The offsetParent's offset without borders (offset + border)
  14171. this.offset.parent.top +
  14172. ( ( this.cssPosition === "fixed" ?
  14173. -this.scrollParent.scrollTop() :
  14174. ( scrollIsRootNode ? 0 : scroll.scrollTop() ) ) )
  14175. ),
  14176. left: (
  14177. // The absolute mouse position
  14178. pageX -
  14179. // Click offset (relative to the element)
  14180. this.offset.click.left -
  14181. // Only for relative positioned nodes: Relative offset from element to offset parent
  14182. this.offset.relative.left -
  14183. // The offsetParent's offset without borders (offset + border)
  14184. this.offset.parent.left +
  14185. ( ( this.cssPosition === "fixed" ?
  14186. -this.scrollParent.scrollLeft() :
  14187. scrollIsRootNode ? 0 : scroll.scrollLeft() ) )
  14188. )
  14189. };
  14190. },
  14191. _rearrange: function( event, i, a, hardRefresh ) {
  14192. if ( a ) {
  14193. a[ 0 ].appendChild( this.placeholder[ 0 ] );
  14194. } else {
  14195. i.item[ 0 ].parentNode.insertBefore( this.placeholder[ 0 ],
  14196. ( this.direction === "down" ? i.item[ 0 ] : i.item[ 0 ].nextSibling ) );
  14197. }
  14198. //Various things done here to improve the performance:
  14199. // 1. we create a setTimeout, that calls refreshPositions
  14200. // 2. on the instance, we have a counter variable, that get's higher after every append
  14201. // 3. on the local scope, we copy the counter variable, and check in the timeout,
  14202. // if it's still the same
  14203. // 4. this lets only the last addition to the timeout stack through
  14204. this.counter = this.counter ? ++this.counter : 1;
  14205. var counter = this.counter;
  14206. this._delay( function() {
  14207. if ( counter === this.counter ) {
  14208. //Precompute after each DOM insertion, NOT on mousemove
  14209. this.refreshPositions( !hardRefresh );
  14210. }
  14211. } );
  14212. },
  14213. _clear: function( event, noPropagation ) {
  14214. this.reverting = false;
  14215. // We delay all events that have to be triggered to after the point where the placeholder
  14216. // has been removed and everything else normalized again
  14217. var i,
  14218. delayedTriggers = [];
  14219. // We first have to update the dom position of the actual currentItem
  14220. // Note: don't do it if the current item is already removed (by a user), or it gets
  14221. // reappended (see #4088)
  14222. if ( !this._noFinalSort && this.currentItem.parent().length ) {
  14223. this.placeholder.before( this.currentItem );
  14224. }
  14225. this._noFinalSort = null;
  14226. if ( this.helper[ 0 ] === this.currentItem[ 0 ] ) {
  14227. for ( i in this._storedCSS ) {
  14228. if ( this._storedCSS[ i ] === "auto" || this._storedCSS[ i ] === "static" ) {
  14229. this._storedCSS[ i ] = "";
  14230. }
  14231. }
  14232. this.currentItem.css( this._storedCSS );
  14233. this._removeClass( this.currentItem, "ui-sortable-helper" );
  14234. } else {
  14235. this.currentItem.show();
  14236. }
  14237. if ( this.fromOutside && !noPropagation ) {
  14238. delayedTriggers.push( function( event ) {
  14239. this._trigger( "receive", event, this._uiHash( this.fromOutside ) );
  14240. } );
  14241. }
  14242. if ( ( this.fromOutside ||
  14243. this.domPosition.prev !==
  14244. this.currentItem.prev().not( ".ui-sortable-helper" )[ 0 ] ||
  14245. this.domPosition.parent !== this.currentItem.parent()[ 0 ] ) && !noPropagation ) {
  14246. // Trigger update callback if the DOM position has changed
  14247. delayedTriggers.push( function( event ) {
  14248. this._trigger( "update", event, this._uiHash() );
  14249. } );
  14250. }
  14251. // Check if the items Container has Changed and trigger appropriate
  14252. // events.
  14253. if ( this !== this.currentContainer ) {
  14254. if ( !noPropagation ) {
  14255. delayedTriggers.push( function( event ) {
  14256. this._trigger( "remove", event, this._uiHash() );
  14257. } );
  14258. delayedTriggers.push( ( function( c ) {
  14259. return function( event ) {
  14260. c._trigger( "receive", event, this._uiHash( this ) );
  14261. };
  14262. } ).call( this, this.currentContainer ) );
  14263. delayedTriggers.push( ( function( c ) {
  14264. return function( event ) {
  14265. c._trigger( "update", event, this._uiHash( this ) );
  14266. };
  14267. } ).call( this, this.currentContainer ) );
  14268. }
  14269. }
  14270. //Post events to containers
  14271. function delayEvent( type, instance, container ) {
  14272. return function( event ) {
  14273. container._trigger( type, event, instance._uiHash( instance ) );
  14274. };
  14275. }
  14276. for ( i = this.containers.length - 1; i >= 0; i-- ) {
  14277. if ( !noPropagation ) {
  14278. delayedTriggers.push( delayEvent( "deactivate", this, this.containers[ i ] ) );
  14279. }
  14280. if ( this.containers[ i ].containerCache.over ) {
  14281. delayedTriggers.push( delayEvent( "out", this, this.containers[ i ] ) );
  14282. this.containers[ i ].containerCache.over = 0;
  14283. }
  14284. }
  14285. //Do what was originally in plugins
  14286. if ( this.storedCursor ) {
  14287. this.document.find( "body" ).css( "cursor", this.storedCursor );
  14288. this.storedStylesheet.remove();
  14289. }
  14290. if ( this._storedOpacity ) {
  14291. this.helper.css( "opacity", this._storedOpacity );
  14292. }
  14293. if ( this._storedZIndex ) {
  14294. this.helper.css( "zIndex", this._storedZIndex === "auto" ? "" : this._storedZIndex );
  14295. }
  14296. this.dragging = false;
  14297. if ( !noPropagation ) {
  14298. this._trigger( "beforeStop", event, this._uiHash() );
  14299. }
  14300. //$(this.placeholder[0]).remove(); would have been the jQuery way - unfortunately,
  14301. // it unbinds ALL events from the original node!
  14302. this.placeholder[ 0 ].parentNode.removeChild( this.placeholder[ 0 ] );
  14303. if ( !this.cancelHelperRemoval ) {
  14304. if ( this.helper[ 0 ] !== this.currentItem[ 0 ] ) {
  14305. this.helper.remove();
  14306. }
  14307. this.helper = null;
  14308. }
  14309. if ( !noPropagation ) {
  14310. for ( i = 0; i < delayedTriggers.length; i++ ) {
  14311. // Trigger all delayed events
  14312. delayedTriggers[ i ].call( this, event );
  14313. }
  14314. this._trigger( "stop", event, this._uiHash() );
  14315. }
  14316. this.fromOutside = false;
  14317. return !this.cancelHelperRemoval;
  14318. },
  14319. _trigger: function() {
  14320. if ( $.Widget.prototype._trigger.apply( this, arguments ) === false ) {
  14321. this.cancel();
  14322. }
  14323. },
  14324. _uiHash: function( _inst ) {
  14325. var inst = _inst || this;
  14326. return {
  14327. helper: inst.helper,
  14328. placeholder: inst.placeholder || $( [] ),
  14329. position: inst.position,
  14330. originalPosition: inst.originalPosition,
  14331. offset: inst.positionAbs,
  14332. item: inst.currentItem,
  14333. sender: _inst ? _inst.element : null
  14334. };
  14335. }
  14336. } );
  14337. /*!
  14338. * jQuery UI Spinner 1.13.2
  14339. * http://jqueryui.com
  14340. *
  14341. * Copyright jQuery Foundation and other contributors
  14342. * Released under the MIT license.
  14343. * http://jquery.org/license
  14344. */
  14345. //>>label: Spinner
  14346. //>>group: Widgets
  14347. //>>description: Displays buttons to easily input numbers via the keyboard or mouse.
  14348. //>>docs: http://api.jqueryui.com/spinner/
  14349. //>>demos: http://jqueryui.com/spinner/
  14350. //>>css.structure: ../../themes/base/core.css
  14351. //>>css.structure: ../../themes/base/spinner.css
  14352. //>>css.theme: ../../themes/base/theme.css
  14353. function spinnerModifier( fn ) {
  14354. return function() {
  14355. var previous = this.element.val();
  14356. fn.apply( this, arguments );
  14357. this._refresh();
  14358. if ( previous !== this.element.val() ) {
  14359. this._trigger( "change" );
  14360. }
  14361. };
  14362. }
  14363. $.widget( "ui.spinner", {
  14364. version: "1.13.2",
  14365. defaultElement: "<input>",
  14366. widgetEventPrefix: "spin",
  14367. options: {
  14368. classes: {
  14369. "ui-spinner": "ui-corner-all",
  14370. "ui-spinner-down": "ui-corner-br",
  14371. "ui-spinner-up": "ui-corner-tr"
  14372. },
  14373. culture: null,
  14374. icons: {
  14375. down: "ui-icon-triangle-1-s",
  14376. up: "ui-icon-triangle-1-n"
  14377. },
  14378. incremental: true,
  14379. max: null,
  14380. min: null,
  14381. numberFormat: null,
  14382. page: 10,
  14383. step: 1,
  14384. change: null,
  14385. spin: null,
  14386. start: null,
  14387. stop: null
  14388. },
  14389. _create: function() {
  14390. // handle string values that need to be parsed
  14391. this._setOption( "max", this.options.max );
  14392. this._setOption( "min", this.options.min );
  14393. this._setOption( "step", this.options.step );
  14394. // Only format if there is a value, prevents the field from being marked
  14395. // as invalid in Firefox, see #9573.
  14396. if ( this.value() !== "" ) {
  14397. // Format the value, but don't constrain.
  14398. this._value( this.element.val(), true );
  14399. }
  14400. this._draw();
  14401. this._on( this._events );
  14402. this._refresh();
  14403. // Turning off autocomplete prevents the browser from remembering the
  14404. // value when navigating through history, so we re-enable autocomplete
  14405. // if the page is unloaded before the widget is destroyed. #7790
  14406. this._on( this.window, {
  14407. beforeunload: function() {
  14408. this.element.removeAttr( "autocomplete" );
  14409. }
  14410. } );
  14411. },
  14412. _getCreateOptions: function() {
  14413. var options = this._super();
  14414. var element = this.element;
  14415. $.each( [ "min", "max", "step" ], function( i, option ) {
  14416. var value = element.attr( option );
  14417. if ( value != null && value.length ) {
  14418. options[ option ] = value;
  14419. }
  14420. } );
  14421. return options;
  14422. },
  14423. _events: {
  14424. keydown: function( event ) {
  14425. if ( this._start( event ) && this._keydown( event ) ) {
  14426. event.preventDefault();
  14427. }
  14428. },
  14429. keyup: "_stop",
  14430. focus: function() {
  14431. this.previous = this.element.val();
  14432. },
  14433. blur: function( event ) {
  14434. if ( this.cancelBlur ) {
  14435. delete this.cancelBlur;
  14436. return;
  14437. }
  14438. this._stop();
  14439. this._refresh();
  14440. if ( this.previous !== this.element.val() ) {
  14441. this._trigger( "change", event );
  14442. }
  14443. },
  14444. mousewheel: function( event, delta ) {
  14445. var activeElement = $.ui.safeActiveElement( this.document[ 0 ] );
  14446. var isActive = this.element[ 0 ] === activeElement;
  14447. if ( !isActive || !delta ) {
  14448. return;
  14449. }
  14450. if ( !this.spinning && !this._start( event ) ) {
  14451. return false;
  14452. }
  14453. this._spin( ( delta > 0 ? 1 : -1 ) * this.options.step, event );
  14454. clearTimeout( this.mousewheelTimer );
  14455. this.mousewheelTimer = this._delay( function() {
  14456. if ( this.spinning ) {
  14457. this._stop( event );
  14458. }
  14459. }, 100 );
  14460. event.preventDefault();
  14461. },
  14462. "mousedown .ui-spinner-button": function( event ) {
  14463. var previous;
  14464. // We never want the buttons to have focus; whenever the user is
  14465. // interacting with the spinner, the focus should be on the input.
  14466. // If the input is focused then this.previous is properly set from
  14467. // when the input first received focus. If the input is not focused
  14468. // then we need to set this.previous based on the value before spinning.
  14469. previous = this.element[ 0 ] === $.ui.safeActiveElement( this.document[ 0 ] ) ?
  14470. this.previous : this.element.val();
  14471. function checkFocus() {
  14472. var isActive = this.element[ 0 ] === $.ui.safeActiveElement( this.document[ 0 ] );
  14473. if ( !isActive ) {
  14474. this.element.trigger( "focus" );
  14475. this.previous = previous;
  14476. // support: IE
  14477. // IE sets focus asynchronously, so we need to check if focus
  14478. // moved off of the input because the user clicked on the button.
  14479. this._delay( function() {
  14480. this.previous = previous;
  14481. } );
  14482. }
  14483. }
  14484. // Ensure focus is on (or stays on) the text field
  14485. event.preventDefault();
  14486. checkFocus.call( this );
  14487. // Support: IE
  14488. // IE doesn't prevent moving focus even with event.preventDefault()
  14489. // so we set a flag to know when we should ignore the blur event
  14490. // and check (again) if focus moved off of the input.
  14491. this.cancelBlur = true;
  14492. this._delay( function() {
  14493. delete this.cancelBlur;
  14494. checkFocus.call( this );
  14495. } );
  14496. if ( this._start( event ) === false ) {
  14497. return;
  14498. }
  14499. this._repeat( null, $( event.currentTarget )
  14500. .hasClass( "ui-spinner-up" ) ? 1 : -1, event );
  14501. },
  14502. "mouseup .ui-spinner-button": "_stop",
  14503. "mouseenter .ui-spinner-button": function( event ) {
  14504. // button will add ui-state-active if mouse was down while mouseleave and kept down
  14505. if ( !$( event.currentTarget ).hasClass( "ui-state-active" ) ) {
  14506. return;
  14507. }
  14508. if ( this._start( event ) === false ) {
  14509. return false;
  14510. }
  14511. this._repeat( null, $( event.currentTarget )
  14512. .hasClass( "ui-spinner-up" ) ? 1 : -1, event );
  14513. },
  14514. // TODO: do we really want to consider this a stop?
  14515. // shouldn't we just stop the repeater and wait until mouseup before
  14516. // we trigger the stop event?
  14517. "mouseleave .ui-spinner-button": "_stop"
  14518. },
  14519. // Support mobile enhanced option and make backcompat more sane
  14520. _enhance: function() {
  14521. this.uiSpinner = this.element
  14522. .attr( "autocomplete", "off" )
  14523. .wrap( "<span>" )
  14524. .parent()
  14525. // Add buttons
  14526. .append(
  14527. "<a></a><a></a>"
  14528. );
  14529. },
  14530. _draw: function() {
  14531. this._enhance();
  14532. this._addClass( this.uiSpinner, "ui-spinner", "ui-widget ui-widget-content" );
  14533. this._addClass( "ui-spinner-input" );
  14534. this.element.attr( "role", "spinbutton" );
  14535. // Button bindings
  14536. this.buttons = this.uiSpinner.children( "a" )
  14537. .attr( "tabIndex", -1 )
  14538. .attr( "aria-hidden", true )
  14539. .button( {
  14540. classes: {
  14541. "ui-button": ""
  14542. }
  14543. } );
  14544. // TODO: Right now button does not support classes this is already updated in button PR
  14545. this._removeClass( this.buttons, "ui-corner-all" );
  14546. this._addClass( this.buttons.first(), "ui-spinner-button ui-spinner-up" );
  14547. this._addClass( this.buttons.last(), "ui-spinner-button ui-spinner-down" );
  14548. this.buttons.first().button( {
  14549. "icon": this.options.icons.up,
  14550. "showLabel": false
  14551. } );
  14552. this.buttons.last().button( {
  14553. "icon": this.options.icons.down,
  14554. "showLabel": false
  14555. } );
  14556. // IE 6 doesn't understand height: 50% for the buttons
  14557. // unless the wrapper has an explicit height
  14558. if ( this.buttons.height() > Math.ceil( this.uiSpinner.height() * 0.5 ) &&
  14559. this.uiSpinner.height() > 0 ) {
  14560. this.uiSpinner.height( this.uiSpinner.height() );
  14561. }
  14562. },
  14563. _keydown: function( event ) {
  14564. var options = this.options,
  14565. keyCode = $.ui.keyCode;
  14566. switch ( event.keyCode ) {
  14567. case keyCode.UP:
  14568. this._repeat( null, 1, event );
  14569. return true;
  14570. case keyCode.DOWN:
  14571. this._repeat( null, -1, event );
  14572. return true;
  14573. case keyCode.PAGE_UP:
  14574. this._repeat( null, options.page, event );
  14575. return true;
  14576. case keyCode.PAGE_DOWN:
  14577. this._repeat( null, -options.page, event );
  14578. return true;
  14579. }
  14580. return false;
  14581. },
  14582. _start: function( event ) {
  14583. if ( !this.spinning && this._trigger( "start", event ) === false ) {
  14584. return false;
  14585. }
  14586. if ( !this.counter ) {
  14587. this.counter = 1;
  14588. }
  14589. this.spinning = true;
  14590. return true;
  14591. },
  14592. _repeat: function( i, steps, event ) {
  14593. i = i || 500;
  14594. clearTimeout( this.timer );
  14595. this.timer = this._delay( function() {
  14596. this._repeat( 40, steps, event );
  14597. }, i );
  14598. this._spin( steps * this.options.step, event );
  14599. },
  14600. _spin: function( step, event ) {
  14601. var value = this.value() || 0;
  14602. if ( !this.counter ) {
  14603. this.counter = 1;
  14604. }
  14605. value = this._adjustValue( value + step * this._increment( this.counter ) );
  14606. if ( !this.spinning || this._trigger( "spin", event, { value: value } ) !== false ) {
  14607. this._value( value );
  14608. this.counter++;
  14609. }
  14610. },
  14611. _increment: function( i ) {
  14612. var incremental = this.options.incremental;
  14613. if ( incremental ) {
  14614. return typeof incremental === "function" ?
  14615. incremental( i ) :
  14616. Math.floor( i * i * i / 50000 - i * i / 500 + 17 * i / 200 + 1 );
  14617. }
  14618. return 1;
  14619. },
  14620. _precision: function() {
  14621. var precision = this._precisionOf( this.options.step );
  14622. if ( this.options.min !== null ) {
  14623. precision = Math.max( precision, this._precisionOf( this.options.min ) );
  14624. }
  14625. return precision;
  14626. },
  14627. _precisionOf: function( num ) {
  14628. var str = num.toString(),
  14629. decimal = str.indexOf( "." );
  14630. return decimal === -1 ? 0 : str.length - decimal - 1;
  14631. },
  14632. _adjustValue: function( value ) {
  14633. var base, aboveMin,
  14634. options = this.options;
  14635. // Make sure we're at a valid step
  14636. // - find out where we are relative to the base (min or 0)
  14637. base = options.min !== null ? options.min : 0;
  14638. aboveMin = value - base;
  14639. // - round to the nearest step
  14640. aboveMin = Math.round( aboveMin / options.step ) * options.step;
  14641. // - rounding is based on 0, so adjust back to our base
  14642. value = base + aboveMin;
  14643. // Fix precision from bad JS floating point math
  14644. value = parseFloat( value.toFixed( this._precision() ) );
  14645. // Clamp the value
  14646. if ( options.max !== null && value > options.max ) {
  14647. return options.max;
  14648. }
  14649. if ( options.min !== null && value < options.min ) {
  14650. return options.min;
  14651. }
  14652. return value;
  14653. },
  14654. _stop: function( event ) {
  14655. if ( !this.spinning ) {
  14656. return;
  14657. }
  14658. clearTimeout( this.timer );
  14659. clearTimeout( this.mousewheelTimer );
  14660. this.counter = 0;
  14661. this.spinning = false;
  14662. this._trigger( "stop", event );
  14663. },
  14664. _setOption: function( key, value ) {
  14665. var prevValue, first, last;
  14666. if ( key === "culture" || key === "numberFormat" ) {
  14667. prevValue = this._parse( this.element.val() );
  14668. this.options[ key ] = value;
  14669. this.element.val( this._format( prevValue ) );
  14670. return;
  14671. }
  14672. if ( key === "max" || key === "min" || key === "step" ) {
  14673. if ( typeof value === "string" ) {
  14674. value = this._parse( value );
  14675. }
  14676. }
  14677. if ( key === "icons" ) {
  14678. first = this.buttons.first().find( ".ui-icon" );
  14679. this._removeClass( first, null, this.options.icons.up );
  14680. this._addClass( first, null, value.up );
  14681. last = this.buttons.last().find( ".ui-icon" );
  14682. this._removeClass( last, null, this.options.icons.down );
  14683. this._addClass( last, null, value.down );
  14684. }
  14685. this._super( key, value );
  14686. },
  14687. _setOptionDisabled: function( value ) {
  14688. this._super( value );
  14689. this._toggleClass( this.uiSpinner, null, "ui-state-disabled", !!value );
  14690. this.element.prop( "disabled", !!value );
  14691. this.buttons.button( value ? "disable" : "enable" );
  14692. },
  14693. _setOptions: spinnerModifier( function( options ) {
  14694. this._super( options );
  14695. } ),
  14696. _parse: function( val ) {
  14697. if ( typeof val === "string" && val !== "" ) {
  14698. val = window.Globalize && this.options.numberFormat ?
  14699. Globalize.parseFloat( val, 10, this.options.culture ) : +val;
  14700. }
  14701. return val === "" || isNaN( val ) ? null : val;
  14702. },
  14703. _format: function( value ) {
  14704. if ( value === "" ) {
  14705. return "";
  14706. }
  14707. return window.Globalize && this.options.numberFormat ?
  14708. Globalize.format( value, this.options.numberFormat, this.options.culture ) :
  14709. value;
  14710. },
  14711. _refresh: function() {
  14712. this.element.attr( {
  14713. "aria-valuemin": this.options.min,
  14714. "aria-valuemax": this.options.max,
  14715. // TODO: what should we do with values that can't be parsed?
  14716. "aria-valuenow": this._parse( this.element.val() )
  14717. } );
  14718. },
  14719. isValid: function() {
  14720. var value = this.value();
  14721. // Null is invalid
  14722. if ( value === null ) {
  14723. return false;
  14724. }
  14725. // If value gets adjusted, it's invalid
  14726. return value === this._adjustValue( value );
  14727. },
  14728. // Update the value without triggering change
  14729. _value: function( value, allowAny ) {
  14730. var parsed;
  14731. if ( value !== "" ) {
  14732. parsed = this._parse( value );
  14733. if ( parsed !== null ) {
  14734. if ( !allowAny ) {
  14735. parsed = this._adjustValue( parsed );
  14736. }
  14737. value = this._format( parsed );
  14738. }
  14739. }
  14740. this.element.val( value );
  14741. this._refresh();
  14742. },
  14743. _destroy: function() {
  14744. this.element
  14745. .prop( "disabled", false )
  14746. .removeAttr( "autocomplete role aria-valuemin aria-valuemax aria-valuenow" );
  14747. this.uiSpinner.replaceWith( this.element );
  14748. },
  14749. stepUp: spinnerModifier( function( steps ) {
  14750. this._stepUp( steps );
  14751. } ),
  14752. _stepUp: function( steps ) {
  14753. if ( this._start() ) {
  14754. this._spin( ( steps || 1 ) * this.options.step );
  14755. this._stop();
  14756. }
  14757. },
  14758. stepDown: spinnerModifier( function( steps ) {
  14759. this._stepDown( steps );
  14760. } ),
  14761. _stepDown: function( steps ) {
  14762. if ( this._start() ) {
  14763. this._spin( ( steps || 1 ) * -this.options.step );
  14764. this._stop();
  14765. }
  14766. },
  14767. pageUp: spinnerModifier( function( pages ) {
  14768. this._stepUp( ( pages || 1 ) * this.options.page );
  14769. } ),
  14770. pageDown: spinnerModifier( function( pages ) {
  14771. this._stepDown( ( pages || 1 ) * this.options.page );
  14772. } ),
  14773. value: function( newVal ) {
  14774. if ( !arguments.length ) {
  14775. return this._parse( this.element.val() );
  14776. }
  14777. spinnerModifier( this._value ).call( this, newVal );
  14778. },
  14779. widget: function() {
  14780. return this.uiSpinner;
  14781. }
  14782. } );
  14783. // DEPRECATED
  14784. // TODO: switch return back to widget declaration at top of file when this is removed
  14785. if ( $.uiBackCompat !== false ) {
  14786. // Backcompat for spinner html extension points
  14787. $.widget( "ui.spinner", $.ui.spinner, {
  14788. _enhance: function() {
  14789. this.uiSpinner = this.element
  14790. .attr( "autocomplete", "off" )
  14791. .wrap( this._uiSpinnerHtml() )
  14792. .parent()
  14793. // Add buttons
  14794. .append( this._buttonHtml() );
  14795. },
  14796. _uiSpinnerHtml: function() {
  14797. return "<span>";
  14798. },
  14799. _buttonHtml: function() {
  14800. return "<a></a><a></a>";
  14801. }
  14802. } );
  14803. }
  14804. var widgetsSpinner = $.ui.spinner;
  14805. /*!
  14806. * jQuery UI Tabs 1.13.2
  14807. * http://jqueryui.com
  14808. *
  14809. * Copyright jQuery Foundation and other contributors
  14810. * Released under the MIT license.
  14811. * http://jquery.org/license
  14812. */
  14813. //>>label: Tabs
  14814. //>>group: Widgets
  14815. //>>description: Transforms a set of container elements into a tab structure.
  14816. //>>docs: http://api.jqueryui.com/tabs/
  14817. //>>demos: http://jqueryui.com/tabs/
  14818. //>>css.structure: ../../themes/base/core.css
  14819. //>>css.structure: ../../themes/base/tabs.css
  14820. //>>css.theme: ../../themes/base/theme.css
  14821. $.widget( "ui.tabs", {
  14822. version: "1.13.2",
  14823. delay: 300,
  14824. options: {
  14825. active: null,
  14826. classes: {
  14827. "ui-tabs": "ui-corner-all",
  14828. "ui-tabs-nav": "ui-corner-all",
  14829. "ui-tabs-panel": "ui-corner-bottom",
  14830. "ui-tabs-tab": "ui-corner-top"
  14831. },
  14832. collapsible: false,
  14833. event: "click",
  14834. heightStyle: "content",
  14835. hide: null,
  14836. show: null,
  14837. // Callbacks
  14838. activate: null,
  14839. beforeActivate: null,
  14840. beforeLoad: null,
  14841. load: null
  14842. },
  14843. _isLocal: ( function() {
  14844. var rhash = /#.*$/;
  14845. return function( anchor ) {
  14846. var anchorUrl, locationUrl;
  14847. anchorUrl = anchor.href.replace( rhash, "" );
  14848. locationUrl = location.href.replace( rhash, "" );
  14849. // Decoding may throw an error if the URL isn't UTF-8 (#9518)
  14850. try {
  14851. anchorUrl = decodeURIComponent( anchorUrl );
  14852. } catch ( error ) {}
  14853. try {
  14854. locationUrl = decodeURIComponent( locationUrl );
  14855. } catch ( error ) {}
  14856. return anchor.hash.length > 1 && anchorUrl === locationUrl;
  14857. };
  14858. } )(),
  14859. _create: function() {
  14860. var that = this,
  14861. options = this.options;
  14862. this.running = false;
  14863. this._addClass( "ui-tabs", "ui-widget ui-widget-content" );
  14864. this._toggleClass( "ui-tabs-collapsible", null, options.collapsible );
  14865. this._processTabs();
  14866. options.active = this._initialActive();
  14867. // Take disabling tabs via class attribute from HTML
  14868. // into account and update option properly.
  14869. if ( Array.isArray( options.disabled ) ) {
  14870. options.disabled = $.uniqueSort( options.disabled.concat(
  14871. $.map( this.tabs.filter( ".ui-state-disabled" ), function( li ) {
  14872. return that.tabs.index( li );
  14873. } )
  14874. ) ).sort();
  14875. }
  14876. // Check for length avoids error when initializing empty list
  14877. if ( this.options.active !== false && this.anchors.length ) {
  14878. this.active = this._findActive( options.active );
  14879. } else {
  14880. this.active = $();
  14881. }
  14882. this._refresh();
  14883. if ( this.active.length ) {
  14884. this.load( options.active );
  14885. }
  14886. },
  14887. _initialActive: function() {
  14888. var active = this.options.active,
  14889. collapsible = this.options.collapsible,
  14890. locationHash = location.hash.substring( 1 );
  14891. if ( active === null ) {
  14892. // check the fragment identifier in the URL
  14893. if ( locationHash ) {
  14894. this.tabs.each( function( i, tab ) {
  14895. if ( $( tab ).attr( "aria-controls" ) === locationHash ) {
  14896. active = i;
  14897. return false;
  14898. }
  14899. } );
  14900. }
  14901. // Check for a tab marked active via a class
  14902. if ( active === null ) {
  14903. active = this.tabs.index( this.tabs.filter( ".ui-tabs-active" ) );
  14904. }
  14905. // No active tab, set to false
  14906. if ( active === null || active === -1 ) {
  14907. active = this.tabs.length ? 0 : false;
  14908. }
  14909. }
  14910. // Handle numbers: negative, out of range
  14911. if ( active !== false ) {
  14912. active = this.tabs.index( this.tabs.eq( active ) );
  14913. if ( active === -1 ) {
  14914. active = collapsible ? false : 0;
  14915. }
  14916. }
  14917. // Don't allow collapsible: false and active: false
  14918. if ( !collapsible && active === false && this.anchors.length ) {
  14919. active = 0;
  14920. }
  14921. return active;
  14922. },
  14923. _getCreateEventData: function() {
  14924. return {
  14925. tab: this.active,
  14926. panel: !this.active.length ? $() : this._getPanelForTab( this.active )
  14927. };
  14928. },
  14929. _tabKeydown: function( event ) {
  14930. var focusedTab = $( $.ui.safeActiveElement( this.document[ 0 ] ) ).closest( "li" ),
  14931. selectedIndex = this.tabs.index( focusedTab ),
  14932. goingForward = true;
  14933. if ( this._handlePageNav( event ) ) {
  14934. return;
  14935. }
  14936. switch ( event.keyCode ) {
  14937. case $.ui.keyCode.RIGHT:
  14938. case $.ui.keyCode.DOWN:
  14939. selectedIndex++;
  14940. break;
  14941. case $.ui.keyCode.UP:
  14942. case $.ui.keyCode.LEFT:
  14943. goingForward = false;
  14944. selectedIndex--;
  14945. break;
  14946. case $.ui.keyCode.END:
  14947. selectedIndex = this.anchors.length - 1;
  14948. break;
  14949. case $.ui.keyCode.HOME:
  14950. selectedIndex = 0;
  14951. break;
  14952. case $.ui.keyCode.SPACE:
  14953. // Activate only, no collapsing
  14954. event.preventDefault();
  14955. clearTimeout( this.activating );
  14956. this._activate( selectedIndex );
  14957. return;
  14958. case $.ui.keyCode.ENTER:
  14959. // Toggle (cancel delayed activation, allow collapsing)
  14960. event.preventDefault();
  14961. clearTimeout( this.activating );
  14962. // Determine if we should collapse or activate
  14963. this._activate( selectedIndex === this.options.active ? false : selectedIndex );
  14964. return;
  14965. default:
  14966. return;
  14967. }
  14968. // Focus the appropriate tab, based on which key was pressed
  14969. event.preventDefault();
  14970. clearTimeout( this.activating );
  14971. selectedIndex = this._focusNextTab( selectedIndex, goingForward );
  14972. // Navigating with control/command key will prevent automatic activation
  14973. if ( !event.ctrlKey && !event.metaKey ) {
  14974. // Update aria-selected immediately so that AT think the tab is already selected.
  14975. // Otherwise AT may confuse the user by stating that they need to activate the tab,
  14976. // but the tab will already be activated by the time the announcement finishes.
  14977. focusedTab.attr( "aria-selected", "false" );
  14978. this.tabs.eq( selectedIndex ).attr( "aria-selected", "true" );
  14979. this.activating = this._delay( function() {
  14980. this.option( "active", selectedIndex );
  14981. }, this.delay );
  14982. }
  14983. },
  14984. _panelKeydown: function( event ) {
  14985. if ( this._handlePageNav( event ) ) {
  14986. return;
  14987. }
  14988. // Ctrl+up moves focus to the current tab
  14989. if ( event.ctrlKey && event.keyCode === $.ui.keyCode.UP ) {
  14990. event.preventDefault();
  14991. this.active.trigger( "focus" );
  14992. }
  14993. },
  14994. // Alt+page up/down moves focus to the previous/next tab (and activates)
  14995. _handlePageNav: function( event ) {
  14996. if ( event.altKey && event.keyCode === $.ui.keyCode.PAGE_UP ) {
  14997. this._activate( this._focusNextTab( this.options.active - 1, false ) );
  14998. return true;
  14999. }
  15000. if ( event.altKey && event.keyCode === $.ui.keyCode.PAGE_DOWN ) {
  15001. this._activate( this._focusNextTab( this.options.active + 1, true ) );
  15002. return true;
  15003. }
  15004. },
  15005. _findNextTab: function( index, goingForward ) {
  15006. var lastTabIndex = this.tabs.length - 1;
  15007. function constrain() {
  15008. if ( index > lastTabIndex ) {
  15009. index = 0;
  15010. }
  15011. if ( index < 0 ) {
  15012. index = lastTabIndex;
  15013. }
  15014. return index;
  15015. }
  15016. while ( $.inArray( constrain(), this.options.disabled ) !== -1 ) {
  15017. index = goingForward ? index + 1 : index - 1;
  15018. }
  15019. return index;
  15020. },
  15021. _focusNextTab: function( index, goingForward ) {
  15022. index = this._findNextTab( index, goingForward );
  15023. this.tabs.eq( index ).trigger( "focus" );
  15024. return index;
  15025. },
  15026. _setOption: function( key, value ) {
  15027. if ( key === "active" ) {
  15028. // _activate() will handle invalid values and update this.options
  15029. this._activate( value );
  15030. return;
  15031. }
  15032. this._super( key, value );
  15033. if ( key === "collapsible" ) {
  15034. this._toggleClass( "ui-tabs-collapsible", null, value );
  15035. // Setting collapsible: false while collapsed; open first panel
  15036. if ( !value && this.options.active === false ) {
  15037. this._activate( 0 );
  15038. }
  15039. }
  15040. if ( key === "event" ) {
  15041. this._setupEvents( value );
  15042. }
  15043. if ( key === "heightStyle" ) {
  15044. this._setupHeightStyle( value );
  15045. }
  15046. },
  15047. _sanitizeSelector: function( hash ) {
  15048. return hash ? hash.replace( /[!"$%&'()*+,.\/:;<=>?@\[\]\^`{|}~]/g, "\\$&" ) : "";
  15049. },
  15050. refresh: function() {
  15051. var options = this.options,
  15052. lis = this.tablist.children( ":has(a[href])" );
  15053. // Get disabled tabs from class attribute from HTML
  15054. // this will get converted to a boolean if needed in _refresh()
  15055. options.disabled = $.map( lis.filter( ".ui-state-disabled" ), function( tab ) {
  15056. return lis.index( tab );
  15057. } );
  15058. this._processTabs();
  15059. // Was collapsed or no tabs
  15060. if ( options.active === false || !this.anchors.length ) {
  15061. options.active = false;
  15062. this.active = $();
  15063. // was active, but active tab is gone
  15064. } else if ( this.active.length && !$.contains( this.tablist[ 0 ], this.active[ 0 ] ) ) {
  15065. // all remaining tabs are disabled
  15066. if ( this.tabs.length === options.disabled.length ) {
  15067. options.active = false;
  15068. this.active = $();
  15069. // activate previous tab
  15070. } else {
  15071. this._activate( this._findNextTab( Math.max( 0, options.active - 1 ), false ) );
  15072. }
  15073. // was active, active tab still exists
  15074. } else {
  15075. // make sure active index is correct
  15076. options.active = this.tabs.index( this.active );
  15077. }
  15078. this._refresh();
  15079. },
  15080. _refresh: function() {
  15081. this._setOptionDisabled( this.options.disabled );
  15082. this._setupEvents( this.options.event );
  15083. this._setupHeightStyle( this.options.heightStyle );
  15084. this.tabs.not( this.active ).attr( {
  15085. "aria-selected": "false",
  15086. "aria-expanded": "false",
  15087. tabIndex: -1
  15088. } );
  15089. this.panels.not( this._getPanelForTab( this.active ) )
  15090. .hide()
  15091. .attr( {
  15092. "aria-hidden": "true"
  15093. } );
  15094. // Make sure one tab is in the tab order
  15095. if ( !this.active.length ) {
  15096. this.tabs.eq( 0 ).attr( "tabIndex", 0 );
  15097. } else {
  15098. this.active
  15099. .attr( {
  15100. "aria-selected": "true",
  15101. "aria-expanded": "true",
  15102. tabIndex: 0
  15103. } );
  15104. this._addClass( this.active, "ui-tabs-active", "ui-state-active" );
  15105. this._getPanelForTab( this.active )
  15106. .show()
  15107. .attr( {
  15108. "aria-hidden": "false"
  15109. } );
  15110. }
  15111. },
  15112. _processTabs: function() {
  15113. var that = this,
  15114. prevTabs = this.tabs,
  15115. prevAnchors = this.anchors,
  15116. prevPanels = this.panels;
  15117. this.tablist = this._getList().attr( "role", "tablist" );
  15118. this._addClass( this.tablist, "ui-tabs-nav",
  15119. "ui-helper-reset ui-helper-clearfix ui-widget-header" );
  15120. // Prevent users from focusing disabled tabs via click
  15121. this.tablist
  15122. .on( "mousedown" + this.eventNamespace, "> li", function( event ) {
  15123. if ( $( this ).is( ".ui-state-disabled" ) ) {
  15124. event.preventDefault();
  15125. }
  15126. } )
  15127. // Support: IE <9
  15128. // Preventing the default action in mousedown doesn't prevent IE
  15129. // from focusing the element, so if the anchor gets focused, blur.
  15130. // We don't have to worry about focusing the previously focused
  15131. // element since clicking on a non-focusable element should focus
  15132. // the body anyway.
  15133. .on( "focus" + this.eventNamespace, ".ui-tabs-anchor", function() {
  15134. if ( $( this ).closest( "li" ).is( ".ui-state-disabled" ) ) {
  15135. this.blur();
  15136. }
  15137. } );
  15138. this.tabs = this.tablist.find( "> li:has(a[href])" )
  15139. .attr( {
  15140. role: "tab",
  15141. tabIndex: -1
  15142. } );
  15143. this._addClass( this.tabs, "ui-tabs-tab", "ui-state-default" );
  15144. this.anchors = this.tabs.map( function() {
  15145. return $( "a", this )[ 0 ];
  15146. } )
  15147. .attr( {
  15148. tabIndex: -1
  15149. } );
  15150. this._addClass( this.anchors, "ui-tabs-anchor" );
  15151. this.panels = $();
  15152. this.anchors.each( function( i, anchor ) {
  15153. var selector, panel, panelId,
  15154. anchorId = $( anchor ).uniqueId().attr( "id" ),
  15155. tab = $( anchor ).closest( "li" ),
  15156. originalAriaControls = tab.attr( "aria-controls" );
  15157. // Inline tab
  15158. if ( that._isLocal( anchor ) ) {
  15159. selector = anchor.hash;
  15160. panelId = selector.substring( 1 );
  15161. panel = that.element.find( that._sanitizeSelector( selector ) );
  15162. // remote tab
  15163. } else {
  15164. // If the tab doesn't already have aria-controls,
  15165. // generate an id by using a throw-away element
  15166. panelId = tab.attr( "aria-controls" ) || $( {} ).uniqueId()[ 0 ].id;
  15167. selector = "#" + panelId;
  15168. panel = that.element.find( selector );
  15169. if ( !panel.length ) {
  15170. panel = that._createPanel( panelId );
  15171. panel.insertAfter( that.panels[ i - 1 ] || that.tablist );
  15172. }
  15173. panel.attr( "aria-live", "polite" );
  15174. }
  15175. if ( panel.length ) {
  15176. that.panels = that.panels.add( panel );
  15177. }
  15178. if ( originalAriaControls ) {
  15179. tab.data( "ui-tabs-aria-controls", originalAriaControls );
  15180. }
  15181. tab.attr( {
  15182. "aria-controls": panelId,
  15183. "aria-labelledby": anchorId
  15184. } );
  15185. panel.attr( "aria-labelledby", anchorId );
  15186. } );
  15187. this.panels.attr( "role", "tabpanel" );
  15188. this._addClass( this.panels, "ui-tabs-panel", "ui-widget-content" );
  15189. // Avoid memory leaks (#10056)
  15190. if ( prevTabs ) {
  15191. this._off( prevTabs.not( this.tabs ) );
  15192. this._off( prevAnchors.not( this.anchors ) );
  15193. this._off( prevPanels.not( this.panels ) );
  15194. }
  15195. },
  15196. // Allow overriding how to find the list for rare usage scenarios (#7715)
  15197. _getList: function() {
  15198. return this.tablist || this.element.find( "ol, ul" ).eq( 0 );
  15199. },
  15200. _createPanel: function( id ) {
  15201. return $( "<div>" )
  15202. .attr( "id", id )
  15203. .data( "ui-tabs-destroy", true );
  15204. },
  15205. _setOptionDisabled: function( disabled ) {
  15206. var currentItem, li, i;
  15207. if ( Array.isArray( disabled ) ) {
  15208. if ( !disabled.length ) {
  15209. disabled = false;
  15210. } else if ( disabled.length === this.anchors.length ) {
  15211. disabled = true;
  15212. }
  15213. }
  15214. // Disable tabs
  15215. for ( i = 0; ( li = this.tabs[ i ] ); i++ ) {
  15216. currentItem = $( li );
  15217. if ( disabled === true || $.inArray( i, disabled ) !== -1 ) {
  15218. currentItem.attr( "aria-disabled", "true" );
  15219. this._addClass( currentItem, null, "ui-state-disabled" );
  15220. } else {
  15221. currentItem.removeAttr( "aria-disabled" );
  15222. this._removeClass( currentItem, null, "ui-state-disabled" );
  15223. }
  15224. }
  15225. this.options.disabled = disabled;
  15226. this._toggleClass( this.widget(), this.widgetFullName + "-disabled", null,
  15227. disabled === true );
  15228. },
  15229. _setupEvents: function( event ) {
  15230. var events = {};
  15231. if ( event ) {
  15232. $.each( event.split( " " ), function( index, eventName ) {
  15233. events[ eventName ] = "_eventHandler";
  15234. } );
  15235. }
  15236. this._off( this.anchors.add( this.tabs ).add( this.panels ) );
  15237. // Always prevent the default action, even when disabled
  15238. this._on( true, this.anchors, {
  15239. click: function( event ) {
  15240. event.preventDefault();
  15241. }
  15242. } );
  15243. this._on( this.anchors, events );
  15244. this._on( this.tabs, { keydown: "_tabKeydown" } );
  15245. this._on( this.panels, { keydown: "_panelKeydown" } );
  15246. this._focusable( this.tabs );
  15247. this._hoverable( this.tabs );
  15248. },
  15249. _setupHeightStyle: function( heightStyle ) {
  15250. var maxHeight,
  15251. parent = this.element.parent();
  15252. if ( heightStyle === "fill" ) {
  15253. maxHeight = parent.height();
  15254. maxHeight -= this.element.outerHeight() - this.element.height();
  15255. this.element.siblings( ":visible" ).each( function() {
  15256. var elem = $( this ),
  15257. position = elem.css( "position" );
  15258. if ( position === "absolute" || position === "fixed" ) {
  15259. return;
  15260. }
  15261. maxHeight -= elem.outerHeight( true );
  15262. } );
  15263. this.element.children().not( this.panels ).each( function() {
  15264. maxHeight -= $( this ).outerHeight( true );
  15265. } );
  15266. this.panels.each( function() {
  15267. $( this ).height( Math.max( 0, maxHeight -
  15268. $( this ).innerHeight() + $( this ).height() ) );
  15269. } )
  15270. .css( "overflow", "auto" );
  15271. } else if ( heightStyle === "auto" ) {
  15272. maxHeight = 0;
  15273. this.panels.each( function() {
  15274. maxHeight = Math.max( maxHeight, $( this ).height( "" ).height() );
  15275. } ).height( maxHeight );
  15276. }
  15277. },
  15278. _eventHandler: function( event ) {
  15279. var options = this.options,
  15280. active = this.active,
  15281. anchor = $( event.currentTarget ),
  15282. tab = anchor.closest( "li" ),
  15283. clickedIsActive = tab[ 0 ] === active[ 0 ],
  15284. collapsing = clickedIsActive && options.collapsible,
  15285. toShow = collapsing ? $() : this._getPanelForTab( tab ),
  15286. toHide = !active.length ? $() : this._getPanelForTab( active ),
  15287. eventData = {
  15288. oldTab: active,
  15289. oldPanel: toHide,
  15290. newTab: collapsing ? $() : tab,
  15291. newPanel: toShow
  15292. };
  15293. event.preventDefault();
  15294. if ( tab.hasClass( "ui-state-disabled" ) ||
  15295. // tab is already loading
  15296. tab.hasClass( "ui-tabs-loading" ) ||
  15297. // can't switch durning an animation
  15298. this.running ||
  15299. // click on active header, but not collapsible
  15300. ( clickedIsActive && !options.collapsible ) ||
  15301. // allow canceling activation
  15302. ( this._trigger( "beforeActivate", event, eventData ) === false ) ) {
  15303. return;
  15304. }
  15305. options.active = collapsing ? false : this.tabs.index( tab );
  15306. this.active = clickedIsActive ? $() : tab;
  15307. if ( this.xhr ) {
  15308. this.xhr.abort();
  15309. }
  15310. if ( !toHide.length && !toShow.length ) {
  15311. $.error( "jQuery UI Tabs: Mismatching fragment identifier." );
  15312. }
  15313. if ( toShow.length ) {
  15314. this.load( this.tabs.index( tab ), event );
  15315. }
  15316. this._toggle( event, eventData );
  15317. },
  15318. // Handles show/hide for selecting tabs
  15319. _toggle: function( event, eventData ) {
  15320. var that = this,
  15321. toShow = eventData.newPanel,
  15322. toHide = eventData.oldPanel;
  15323. this.running = true;
  15324. function complete() {
  15325. that.running = false;
  15326. that._trigger( "activate", event, eventData );
  15327. }
  15328. function show() {
  15329. that._addClass( eventData.newTab.closest( "li" ), "ui-tabs-active", "ui-state-active" );
  15330. if ( toShow.length && that.options.show ) {
  15331. that._show( toShow, that.options.show, complete );
  15332. } else {
  15333. toShow.show();
  15334. complete();
  15335. }
  15336. }
  15337. // Start out by hiding, then showing, then completing
  15338. if ( toHide.length && this.options.hide ) {
  15339. this._hide( toHide, this.options.hide, function() {
  15340. that._removeClass( eventData.oldTab.closest( "li" ),
  15341. "ui-tabs-active", "ui-state-active" );
  15342. show();
  15343. } );
  15344. } else {
  15345. this._removeClass( eventData.oldTab.closest( "li" ),
  15346. "ui-tabs-active", "ui-state-active" );
  15347. toHide.hide();
  15348. show();
  15349. }
  15350. toHide.attr( "aria-hidden", "true" );
  15351. eventData.oldTab.attr( {
  15352. "aria-selected": "false",
  15353. "aria-expanded": "false"
  15354. } );
  15355. // If we're switching tabs, remove the old tab from the tab order.
  15356. // If we're opening from collapsed state, remove the previous tab from the tab order.
  15357. // If we're collapsing, then keep the collapsing tab in the tab order.
  15358. if ( toShow.length && toHide.length ) {
  15359. eventData.oldTab.attr( "tabIndex", -1 );
  15360. } else if ( toShow.length ) {
  15361. this.tabs.filter( function() {
  15362. return $( this ).attr( "tabIndex" ) === 0;
  15363. } )
  15364. .attr( "tabIndex", -1 );
  15365. }
  15366. toShow.attr( "aria-hidden", "false" );
  15367. eventData.newTab.attr( {
  15368. "aria-selected": "true",
  15369. "aria-expanded": "true",
  15370. tabIndex: 0
  15371. } );
  15372. },
  15373. _activate: function( index ) {
  15374. var anchor,
  15375. active = this._findActive( index );
  15376. // Trying to activate the already active panel
  15377. if ( active[ 0 ] === this.active[ 0 ] ) {
  15378. return;
  15379. }
  15380. // Trying to collapse, simulate a click on the current active header
  15381. if ( !active.length ) {
  15382. active = this.active;
  15383. }
  15384. anchor = active.find( ".ui-tabs-anchor" )[ 0 ];
  15385. this._eventHandler( {
  15386. target: anchor,
  15387. currentTarget: anchor,
  15388. preventDefault: $.noop
  15389. } );
  15390. },
  15391. _findActive: function( index ) {
  15392. return index === false ? $() : this.tabs.eq( index );
  15393. },
  15394. _getIndex: function( index ) {
  15395. // meta-function to give users option to provide a href string instead of a numerical index.
  15396. if ( typeof index === "string" ) {
  15397. index = this.anchors.index( this.anchors.filter( "[href$='" +
  15398. $.escapeSelector( index ) + "']" ) );
  15399. }
  15400. return index;
  15401. },
  15402. _destroy: function() {
  15403. if ( this.xhr ) {
  15404. this.xhr.abort();
  15405. }
  15406. this.tablist
  15407. .removeAttr( "role" )
  15408. .off( this.eventNamespace );
  15409. this.anchors
  15410. .removeAttr( "role tabIndex" )
  15411. .removeUniqueId();
  15412. this.tabs.add( this.panels ).each( function() {
  15413. if ( $.data( this, "ui-tabs-destroy" ) ) {
  15414. $( this ).remove();
  15415. } else {
  15416. $( this ).removeAttr( "role tabIndex " +
  15417. "aria-live aria-busy aria-selected aria-labelledby aria-hidden aria-expanded" );
  15418. }
  15419. } );
  15420. this.tabs.each( function() {
  15421. var li = $( this ),
  15422. prev = li.data( "ui-tabs-aria-controls" );
  15423. if ( prev ) {
  15424. li
  15425. .attr( "aria-controls", prev )
  15426. .removeData( "ui-tabs-aria-controls" );
  15427. } else {
  15428. li.removeAttr( "aria-controls" );
  15429. }
  15430. } );
  15431. this.panels.show();
  15432. if ( this.options.heightStyle !== "content" ) {
  15433. this.panels.css( "height", "" );
  15434. }
  15435. },
  15436. enable: function( index ) {
  15437. var disabled = this.options.disabled;
  15438. if ( disabled === false ) {
  15439. return;
  15440. }
  15441. if ( index === undefined ) {
  15442. disabled = false;
  15443. } else {
  15444. index = this._getIndex( index );
  15445. if ( Array.isArray( disabled ) ) {
  15446. disabled = $.map( disabled, function( num ) {
  15447. return num !== index ? num : null;
  15448. } );
  15449. } else {
  15450. disabled = $.map( this.tabs, function( li, num ) {
  15451. return num !== index ? num : null;
  15452. } );
  15453. }
  15454. }
  15455. this._setOptionDisabled( disabled );
  15456. },
  15457. disable: function( index ) {
  15458. var disabled = this.options.disabled;
  15459. if ( disabled === true ) {
  15460. return;
  15461. }
  15462. if ( index === undefined ) {
  15463. disabled = true;
  15464. } else {
  15465. index = this._getIndex( index );
  15466. if ( $.inArray( index, disabled ) !== -1 ) {
  15467. return;
  15468. }
  15469. if ( Array.isArray( disabled ) ) {
  15470. disabled = $.merge( [ index ], disabled ).sort();
  15471. } else {
  15472. disabled = [ index ];
  15473. }
  15474. }
  15475. this._setOptionDisabled( disabled );
  15476. },
  15477. load: function( index, event ) {
  15478. index = this._getIndex( index );
  15479. var that = this,
  15480. tab = this.tabs.eq( index ),
  15481. anchor = tab.find( ".ui-tabs-anchor" ),
  15482. panel = this._getPanelForTab( tab ),
  15483. eventData = {
  15484. tab: tab,
  15485. panel: panel
  15486. },
  15487. complete = function( jqXHR, status ) {
  15488. if ( status === "abort" ) {
  15489. that.panels.stop( false, true );
  15490. }
  15491. that._removeClass( tab, "ui-tabs-loading" );
  15492. panel.removeAttr( "aria-busy" );
  15493. if ( jqXHR === that.xhr ) {
  15494. delete that.xhr;
  15495. }
  15496. };
  15497. // Not remote
  15498. if ( this._isLocal( anchor[ 0 ] ) ) {
  15499. return;
  15500. }
  15501. this.xhr = $.ajax( this._ajaxSettings( anchor, event, eventData ) );
  15502. // Support: jQuery <1.8
  15503. // jQuery <1.8 returns false if the request is canceled in beforeSend,
  15504. // but as of 1.8, $.ajax() always returns a jqXHR object.
  15505. if ( this.xhr && this.xhr.statusText !== "canceled" ) {
  15506. this._addClass( tab, "ui-tabs-loading" );
  15507. panel.attr( "aria-busy", "true" );
  15508. this.xhr
  15509. .done( function( response, status, jqXHR ) {
  15510. // support: jQuery <1.8
  15511. // http://bugs.jquery.com/ticket/11778
  15512. setTimeout( function() {
  15513. panel.html( response );
  15514. that._trigger( "load", event, eventData );
  15515. complete( jqXHR, status );
  15516. }, 1 );
  15517. } )
  15518. .fail( function( jqXHR, status ) {
  15519. // support: jQuery <1.8
  15520. // http://bugs.jquery.com/ticket/11778
  15521. setTimeout( function() {
  15522. complete( jqXHR, status );
  15523. }, 1 );
  15524. } );
  15525. }
  15526. },
  15527. _ajaxSettings: function( anchor, event, eventData ) {
  15528. var that = this;
  15529. return {
  15530. // Support: IE <11 only
  15531. // Strip any hash that exists to prevent errors with the Ajax request
  15532. url: anchor.attr( "href" ).replace( /#.*$/, "" ),
  15533. beforeSend: function( jqXHR, settings ) {
  15534. return that._trigger( "beforeLoad", event,
  15535. $.extend( { jqXHR: jqXHR, ajaxSettings: settings }, eventData ) );
  15536. }
  15537. };
  15538. },
  15539. _getPanelForTab: function( tab ) {
  15540. var id = $( tab ).attr( "aria-controls" );
  15541. return this.element.find( this._sanitizeSelector( "#" + id ) );
  15542. }
  15543. } );
  15544. // DEPRECATED
  15545. // TODO: Switch return back to widget declaration at top of file when this is removed
  15546. if ( $.uiBackCompat !== false ) {
  15547. // Backcompat for ui-tab class (now ui-tabs-tab)
  15548. $.widget( "ui.tabs", $.ui.tabs, {
  15549. _processTabs: function() {
  15550. this._superApply( arguments );
  15551. this._addClass( this.tabs, "ui-tab" );
  15552. }
  15553. } );
  15554. }
  15555. var widgetsTabs = $.ui.tabs;
  15556. /*!
  15557. * jQuery UI Tooltip 1.13.2
  15558. * http://jqueryui.com
  15559. *
  15560. * Copyright jQuery Foundation and other contributors
  15561. * Released under the MIT license.
  15562. * http://jquery.org/license
  15563. */
  15564. //>>label: Tooltip
  15565. //>>group: Widgets
  15566. //>>description: Shows additional information for any element on hover or focus.
  15567. //>>docs: http://api.jqueryui.com/tooltip/
  15568. //>>demos: http://jqueryui.com/tooltip/
  15569. //>>css.structure: ../../themes/base/core.css
  15570. //>>css.structure: ../../themes/base/tooltip.css
  15571. //>>css.theme: ../../themes/base/theme.css
  15572. $.widget( "ui.tooltip", {
  15573. version: "1.13.2",
  15574. options: {
  15575. classes: {
  15576. "ui-tooltip": "ui-corner-all ui-widget-shadow"
  15577. },
  15578. content: function() {
  15579. var title = $( this ).attr( "title" );
  15580. // Escape title, since we're going from an attribute to raw HTML
  15581. return $( "<a>" ).text( title ).html();
  15582. },
  15583. hide: true,
  15584. // Disabled elements have inconsistent behavior across browsers (#8661)
  15585. items: "[title]:not([disabled])",
  15586. position: {
  15587. my: "left top+15",
  15588. at: "left bottom",
  15589. collision: "flipfit flip"
  15590. },
  15591. show: true,
  15592. track: false,
  15593. // Callbacks
  15594. close: null,
  15595. open: null
  15596. },
  15597. _addDescribedBy: function( elem, id ) {
  15598. var describedby = ( elem.attr( "aria-describedby" ) || "" ).split( /\s+/ );
  15599. describedby.push( id );
  15600. elem
  15601. .data( "ui-tooltip-id", id )
  15602. .attr( "aria-describedby", String.prototype.trim.call( describedby.join( " " ) ) );
  15603. },
  15604. _removeDescribedBy: function( elem ) {
  15605. var id = elem.data( "ui-tooltip-id" ),
  15606. describedby = ( elem.attr( "aria-describedby" ) || "" ).split( /\s+/ ),
  15607. index = $.inArray( id, describedby );
  15608. if ( index !== -1 ) {
  15609. describedby.splice( index, 1 );
  15610. }
  15611. elem.removeData( "ui-tooltip-id" );
  15612. describedby = String.prototype.trim.call( describedby.join( " " ) );
  15613. if ( describedby ) {
  15614. elem.attr( "aria-describedby", describedby );
  15615. } else {
  15616. elem.removeAttr( "aria-describedby" );
  15617. }
  15618. },
  15619. _create: function() {
  15620. this._on( {
  15621. mouseover: "open",
  15622. focusin: "open"
  15623. } );
  15624. // IDs of generated tooltips, needed for destroy
  15625. this.tooltips = {};
  15626. // IDs of parent tooltips where we removed the title attribute
  15627. this.parents = {};
  15628. // Append the aria-live region so tooltips announce correctly
  15629. this.liveRegion = $( "<div>" )
  15630. .attr( {
  15631. role: "log",
  15632. "aria-live": "assertive",
  15633. "aria-relevant": "additions"
  15634. } )
  15635. .appendTo( this.document[ 0 ].body );
  15636. this._addClass( this.liveRegion, null, "ui-helper-hidden-accessible" );
  15637. this.disabledTitles = $( [] );
  15638. },
  15639. _setOption: function( key, value ) {
  15640. var that = this;
  15641. this._super( key, value );
  15642. if ( key === "content" ) {
  15643. $.each( this.tooltips, function( id, tooltipData ) {
  15644. that._updateContent( tooltipData.element );
  15645. } );
  15646. }
  15647. },
  15648. _setOptionDisabled: function( value ) {
  15649. this[ value ? "_disable" : "_enable" ]();
  15650. },
  15651. _disable: function() {
  15652. var that = this;
  15653. // Close open tooltips
  15654. $.each( this.tooltips, function( id, tooltipData ) {
  15655. var event = $.Event( "blur" );
  15656. event.target = event.currentTarget = tooltipData.element[ 0 ];
  15657. that.close( event, true );
  15658. } );
  15659. // Remove title attributes to prevent native tooltips
  15660. this.disabledTitles = this.disabledTitles.add(
  15661. this.element.find( this.options.items ).addBack()
  15662. .filter( function() {
  15663. var element = $( this );
  15664. if ( element.is( "[title]" ) ) {
  15665. return element
  15666. .data( "ui-tooltip-title", element.attr( "title" ) )
  15667. .removeAttr( "title" );
  15668. }
  15669. } )
  15670. );
  15671. },
  15672. _enable: function() {
  15673. // restore title attributes
  15674. this.disabledTitles.each( function() {
  15675. var element = $( this );
  15676. if ( element.data( "ui-tooltip-title" ) ) {
  15677. element.attr( "title", element.data( "ui-tooltip-title" ) );
  15678. }
  15679. } );
  15680. this.disabledTitles = $( [] );
  15681. },
  15682. open: function( event ) {
  15683. var that = this,
  15684. target = $( event ? event.target : this.element )
  15685. // we need closest here due to mouseover bubbling,
  15686. // but always pointing at the same event target
  15687. .closest( this.options.items );
  15688. // No element to show a tooltip for or the tooltip is already open
  15689. if ( !target.length || target.data( "ui-tooltip-id" ) ) {
  15690. return;
  15691. }
  15692. if ( target.attr( "title" ) ) {
  15693. target.data( "ui-tooltip-title", target.attr( "title" ) );
  15694. }
  15695. target.data( "ui-tooltip-open", true );
  15696. // Kill parent tooltips, custom or native, for hover
  15697. if ( event && event.type === "mouseover" ) {
  15698. target.parents().each( function() {
  15699. var parent = $( this ),
  15700. blurEvent;
  15701. if ( parent.data( "ui-tooltip-open" ) ) {
  15702. blurEvent = $.Event( "blur" );
  15703. blurEvent.target = blurEvent.currentTarget = this;
  15704. that.close( blurEvent, true );
  15705. }
  15706. if ( parent.attr( "title" ) ) {
  15707. parent.uniqueId();
  15708. that.parents[ this.id ] = {
  15709. element: this,
  15710. title: parent.attr( "title" )
  15711. };
  15712. parent.attr( "title", "" );
  15713. }
  15714. } );
  15715. }
  15716. this._registerCloseHandlers( event, target );
  15717. this._updateContent( target, event );
  15718. },
  15719. _updateContent: function( target, event ) {
  15720. var content,
  15721. contentOption = this.options.content,
  15722. that = this,
  15723. eventType = event ? event.type : null;
  15724. if ( typeof contentOption === "string" || contentOption.nodeType ||
  15725. contentOption.jquery ) {
  15726. return this._open( event, target, contentOption );
  15727. }
  15728. content = contentOption.call( target[ 0 ], function( response ) {
  15729. // IE may instantly serve a cached response for ajax requests
  15730. // delay this call to _open so the other call to _open runs first
  15731. that._delay( function() {
  15732. // Ignore async response if tooltip was closed already
  15733. if ( !target.data( "ui-tooltip-open" ) ) {
  15734. return;
  15735. }
  15736. // JQuery creates a special event for focusin when it doesn't
  15737. // exist natively. To improve performance, the native event
  15738. // object is reused and the type is changed. Therefore, we can't
  15739. // rely on the type being correct after the event finished
  15740. // bubbling, so we set it back to the previous value. (#8740)
  15741. if ( event ) {
  15742. event.type = eventType;
  15743. }
  15744. this._open( event, target, response );
  15745. } );
  15746. } );
  15747. if ( content ) {
  15748. this._open( event, target, content );
  15749. }
  15750. },
  15751. _open: function( event, target, content ) {
  15752. var tooltipData, tooltip, delayedShow, a11yContent,
  15753. positionOption = $.extend( {}, this.options.position );
  15754. if ( !content ) {
  15755. return;
  15756. }
  15757. // Content can be updated multiple times. If the tooltip already
  15758. // exists, then just update the content and bail.
  15759. tooltipData = this._find( target );
  15760. if ( tooltipData ) {
  15761. tooltipData.tooltip.find( ".ui-tooltip-content" ).html( content );
  15762. return;
  15763. }
  15764. // If we have a title, clear it to prevent the native tooltip
  15765. // we have to check first to avoid defining a title if none exists
  15766. // (we don't want to cause an element to start matching [title])
  15767. //
  15768. // We use removeAttr only for key events, to allow IE to export the correct
  15769. // accessible attributes. For mouse events, set to empty string to avoid
  15770. // native tooltip showing up (happens only when removing inside mouseover).
  15771. if ( target.is( "[title]" ) ) {
  15772. if ( event && event.type === "mouseover" ) {
  15773. target.attr( "title", "" );
  15774. } else {
  15775. target.removeAttr( "title" );
  15776. }
  15777. }
  15778. tooltipData = this._tooltip( target );
  15779. tooltip = tooltipData.tooltip;
  15780. this._addDescribedBy( target, tooltip.attr( "id" ) );
  15781. tooltip.find( ".ui-tooltip-content" ).html( content );
  15782. // Support: Voiceover on OS X, JAWS on IE <= 9
  15783. // JAWS announces deletions even when aria-relevant="additions"
  15784. // Voiceover will sometimes re-read the entire log region's contents from the beginning
  15785. this.liveRegion.children().hide();
  15786. a11yContent = $( "<div>" ).html( tooltip.find( ".ui-tooltip-content" ).html() );
  15787. a11yContent.removeAttr( "name" ).find( "[name]" ).removeAttr( "name" );
  15788. a11yContent.removeAttr( "id" ).find( "[id]" ).removeAttr( "id" );
  15789. a11yContent.appendTo( this.liveRegion );
  15790. function position( event ) {
  15791. positionOption.of = event;
  15792. if ( tooltip.is( ":hidden" ) ) {
  15793. return;
  15794. }
  15795. tooltip.position( positionOption );
  15796. }
  15797. if ( this.options.track && event && /^mouse/.test( event.type ) ) {
  15798. this._on( this.document, {
  15799. mousemove: position
  15800. } );
  15801. // trigger once to override element-relative positioning
  15802. position( event );
  15803. } else {
  15804. tooltip.position( $.extend( {
  15805. of: target
  15806. }, this.options.position ) );
  15807. }
  15808. tooltip.hide();
  15809. this._show( tooltip, this.options.show );
  15810. // Handle tracking tooltips that are shown with a delay (#8644). As soon
  15811. // as the tooltip is visible, position the tooltip using the most recent
  15812. // event.
  15813. // Adds the check to add the timers only when both delay and track options are set (#14682)
  15814. if ( this.options.track && this.options.show && this.options.show.delay ) {
  15815. delayedShow = this.delayedShow = setInterval( function() {
  15816. if ( tooltip.is( ":visible" ) ) {
  15817. position( positionOption.of );
  15818. clearInterval( delayedShow );
  15819. }
  15820. }, 13 );
  15821. }
  15822. this._trigger( "open", event, { tooltip: tooltip } );
  15823. },
  15824. _registerCloseHandlers: function( event, target ) {
  15825. var events = {
  15826. keyup: function( event ) {
  15827. if ( event.keyCode === $.ui.keyCode.ESCAPE ) {
  15828. var fakeEvent = $.Event( event );
  15829. fakeEvent.currentTarget = target[ 0 ];
  15830. this.close( fakeEvent, true );
  15831. }
  15832. }
  15833. };
  15834. // Only bind remove handler for delegated targets. Non-delegated
  15835. // tooltips will handle this in destroy.
  15836. if ( target[ 0 ] !== this.element[ 0 ] ) {
  15837. events.remove = function() {
  15838. var targetElement = this._find( target );
  15839. if ( targetElement ) {
  15840. this._removeTooltip( targetElement.tooltip );
  15841. }
  15842. };
  15843. }
  15844. if ( !event || event.type === "mouseover" ) {
  15845. events.mouseleave = "close";
  15846. }
  15847. if ( !event || event.type === "focusin" ) {
  15848. events.focusout = "close";
  15849. }
  15850. this._on( true, target, events );
  15851. },
  15852. close: function( event ) {
  15853. var tooltip,
  15854. that = this,
  15855. target = $( event ? event.currentTarget : this.element ),
  15856. tooltipData = this._find( target );
  15857. // The tooltip may already be closed
  15858. if ( !tooltipData ) {
  15859. // We set ui-tooltip-open immediately upon open (in open()), but only set the
  15860. // additional data once there's actually content to show (in _open()). So even if the
  15861. // tooltip doesn't have full data, we always remove ui-tooltip-open in case we're in
  15862. // the period between open() and _open().
  15863. target.removeData( "ui-tooltip-open" );
  15864. return;
  15865. }
  15866. tooltip = tooltipData.tooltip;
  15867. // Disabling closes the tooltip, so we need to track when we're closing
  15868. // to avoid an infinite loop in case the tooltip becomes disabled on close
  15869. if ( tooltipData.closing ) {
  15870. return;
  15871. }
  15872. // Clear the interval for delayed tracking tooltips
  15873. clearInterval( this.delayedShow );
  15874. // Only set title if we had one before (see comment in _open())
  15875. // If the title attribute has changed since open(), don't restore
  15876. if ( target.data( "ui-tooltip-title" ) && !target.attr( "title" ) ) {
  15877. target.attr( "title", target.data( "ui-tooltip-title" ) );
  15878. }
  15879. this._removeDescribedBy( target );
  15880. tooltipData.hiding = true;
  15881. tooltip.stop( true );
  15882. this._hide( tooltip, this.options.hide, function() {
  15883. that._removeTooltip( $( this ) );
  15884. } );
  15885. target.removeData( "ui-tooltip-open" );
  15886. this._off( target, "mouseleave focusout keyup" );
  15887. // Remove 'remove' binding only on delegated targets
  15888. if ( target[ 0 ] !== this.element[ 0 ] ) {
  15889. this._off( target, "remove" );
  15890. }
  15891. this._off( this.document, "mousemove" );
  15892. if ( event && event.type === "mouseleave" ) {
  15893. $.each( this.parents, function( id, parent ) {
  15894. $( parent.element ).attr( "title", parent.title );
  15895. delete that.parents[ id ];
  15896. } );
  15897. }
  15898. tooltipData.closing = true;
  15899. this._trigger( "close", event, { tooltip: tooltip } );
  15900. if ( !tooltipData.hiding ) {
  15901. tooltipData.closing = false;
  15902. }
  15903. },
  15904. _tooltip: function( element ) {
  15905. var tooltip = $( "<div>" ).attr( "role", "tooltip" ),
  15906. content = $( "<div>" ).appendTo( tooltip ),
  15907. id = tooltip.uniqueId().attr( "id" );
  15908. this._addClass( content, "ui-tooltip-content" );
  15909. this._addClass( tooltip, "ui-tooltip", "ui-widget ui-widget-content" );
  15910. tooltip.appendTo( this._appendTo( element ) );
  15911. return this.tooltips[ id ] = {
  15912. element: element,
  15913. tooltip: tooltip
  15914. };
  15915. },
  15916. _find: function( target ) {
  15917. var id = target.data( "ui-tooltip-id" );
  15918. return id ? this.tooltips[ id ] : null;
  15919. },
  15920. _removeTooltip: function( tooltip ) {
  15921. // Clear the interval for delayed tracking tooltips
  15922. clearInterval( this.delayedShow );
  15923. tooltip.remove();
  15924. delete this.tooltips[ tooltip.attr( "id" ) ];
  15925. },
  15926. _appendTo: function( target ) {
  15927. var element = target.closest( ".ui-front, dialog" );
  15928. if ( !element.length ) {
  15929. element = this.document[ 0 ].body;
  15930. }
  15931. return element;
  15932. },
  15933. _destroy: function() {
  15934. var that = this;
  15935. // Close open tooltips
  15936. $.each( this.tooltips, function( id, tooltipData ) {
  15937. // Delegate to close method to handle common cleanup
  15938. var event = $.Event( "blur" ),
  15939. element = tooltipData.element;
  15940. event.target = event.currentTarget = element[ 0 ];
  15941. that.close( event, true );
  15942. // Remove immediately; destroying an open tooltip doesn't use the
  15943. // hide animation
  15944. $( "#" + id ).remove();
  15945. // Restore the title
  15946. if ( element.data( "ui-tooltip-title" ) ) {
  15947. // If the title attribute has changed since open(), don't restore
  15948. if ( !element.attr( "title" ) ) {
  15949. element.attr( "title", element.data( "ui-tooltip-title" ) );
  15950. }
  15951. element.removeData( "ui-tooltip-title" );
  15952. }
  15953. } );
  15954. this.liveRegion.remove();
  15955. }
  15956. } );
  15957. // DEPRECATED
  15958. // TODO: Switch return back to widget declaration at top of file when this is removed
  15959. if ( $.uiBackCompat !== false ) {
  15960. // Backcompat for tooltipClass option
  15961. $.widget( "ui.tooltip", $.ui.tooltip, {
  15962. options: {
  15963. tooltipClass: null
  15964. },
  15965. _tooltip: function() {
  15966. var tooltipData = this._superApply( arguments );
  15967. if ( this.options.tooltipClass ) {
  15968. tooltipData.tooltip.addClass( this.options.tooltipClass );
  15969. }
  15970. return tooltipData;
  15971. }
  15972. } );
  15973. }
  15974. var widgetsTooltip = $.ui.tooltip;
  15975. } );