jquery-ui.js 508 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187161881618916190161911619216193161941619516196161971619816199162001620116202162031620416205162061620716208162091621016211162121621316214162151621616217162181621916220162211622216223162241622516226162271622816229162301623116232162331623416235162361623716238162391624016241162421624316244162451624616247162481624916250162511625216253162541625516256162571625816259162601626116262162631626416265162661626716268162691627016271162721627316274162751627616277162781627916280162811628216283162841628516286162871628816289162901629116292162931629416295162961629716298162991630016301163021630316304163051630616307163081630916310163111631216313163141631516316163171631816319163201632116322163231632416325163261632716328163291633016331163321633316334163351633616337163381633916340163411634216343163441634516346163471634816349163501635116352163531635416355163561635716358163591636016361163621636316364163651636616367163681636916370163711637216373163741637516376163771637816379163801638116382163831638416385163861638716388163891639016391163921639316394163951639616397163981639916400164011640216403164041640516406164071640816409164101641116412164131641416415164161641716418164191642016421164221642316424164251642616427164281642916430164311643216433164341643516436164371643816439164401644116442164431644416445164461644716448164491645016451164521645316454164551645616457164581645916460164611646216463164641646516466164671646816469164701647116472164731647416475164761647716478164791648016481164821648316484164851648616487164881648916490164911649216493164941649516496164971649816499165001650116502165031650416505165061650716508165091651016511165121651316514165151651616517165181651916520165211652216523165241652516526165271652816529165301653116532165331653416535165361653716538165391654016541165421654316544165451654616547165481654916550165511655216553165541655516556165571655816559165601656116562165631656416565165661656716568165691657016571165721657316574165751657616577165781657916580165811658216583165841658516586165871658816589165901659116592165931659416595165961659716598165991660016601166021660316604166051660616607166081660916610166111661216613166141661516616166171661816619166201662116622166231662416625166261662716628166291663016631166321663316634166351663616637166381663916640166411664216643166441664516646166471664816649166501665116652166531665416655166561665716658166591666016661166621666316664166651666616667166681666916670166711667216673166741667516676166771667816679166801668116682166831668416685166861668716688166891669016691166921669316694166951669616697166981669916700167011670216703167041670516706167071670816709167101671116712167131671416715167161671716718167191672016721167221672316724167251672616727167281672916730167311673216733167341673516736167371673816739167401674116742167431674416745167461674716748167491675016751167521675316754167551675616757167581675916760167611676216763167641676516766167671676816769167701677116772167731677416775167761677716778167791678016781167821678316784167851678616787167881678916790167911679216793167941679516796167971679816799168001680116802168031680416805168061680716808168091681016811168121681316814168151681616817168181681916820168211682216823168241682516826168271682816829168301683116832168331683416835168361683716838168391684016841168421684316844168451684616847168481684916850168511685216853168541685516856168571685816859168601686116862168631686416865168661686716868168691687016871168721687316874168751687616877168781687916880168811688216883168841688516886168871688816889168901689116892168931689416895168961689716898168991690016901169021690316904169051690616907169081690916910169111691216913169141691516916169171691816919169201692116922169231692416925169261692716928169291693016931169321693316934169351693616937169381693916940169411694216943169441694516946169471694816949169501695116952169531695416955169561695716958169591696016961169621696316964169651696616967169681696916970169711697216973169741697516976169771697816979169801698116982169831698416985169861698716988169891699016991169921699316994169951699616997169981699917000170011700217003170041700517006170071700817009170101701117012170131701417015170161701717018170191702017021170221702317024170251702617027170281702917030170311703217033170341703517036170371703817039170401704117042170431704417045170461704717048170491705017051170521705317054170551705617057170581705917060170611706217063170641706517066170671706817069170701707117072170731707417075170761707717078170791708017081170821708317084170851708617087170881708917090170911709217093170941709517096170971709817099171001710117102171031710417105171061710717108171091711017111171121711317114171151711617117171181711917120171211712217123171241712517126171271712817129171301713117132171331713417135171361713717138171391714017141171421714317144171451714617147171481714917150171511715217153171541715517156171571715817159171601716117162171631716417165171661716717168171691717017171171721717317174171751717617177171781717917180171811718217183171841718517186171871718817189171901719117192171931719417195171961719717198171991720017201172021720317204172051720617207172081720917210172111721217213172141721517216172171721817219172201722117222172231722417225172261722717228172291723017231172321723317234172351723617237172381723917240172411724217243172441724517246172471724817249172501725117252172531725417255172561725717258172591726017261172621726317264172651726617267172681726917270172711727217273172741727517276172771727817279172801728117282172831728417285172861728717288172891729017291172921729317294172951729617297172981729917300173011730217303173041730517306173071730817309173101731117312173131731417315173161731717318173191732017321173221732317324173251732617327173281732917330173311733217333173341733517336173371733817339173401734117342173431734417345173461734717348173491735017351173521735317354173551735617357173581735917360173611736217363173641736517366173671736817369173701737117372173731737417375173761737717378173791738017381173821738317384173851738617387173881738917390173911739217393173941739517396173971739817399174001740117402174031740417405174061740717408174091741017411174121741317414174151741617417174181741917420174211742217423174241742517426174271742817429174301743117432174331743417435174361743717438174391744017441174421744317444174451744617447174481744917450174511745217453174541745517456174571745817459174601746117462174631746417465174661746717468174691747017471174721747317474174751747617477174781747917480174811748217483174841748517486174871748817489174901749117492174931749417495174961749717498174991750017501175021750317504175051750617507175081750917510175111751217513175141751517516175171751817519175201752117522175231752417525175261752717528175291753017531175321753317534175351753617537175381753917540175411754217543175441754517546175471754817549175501755117552175531755417555175561755717558175591756017561175621756317564175651756617567175681756917570175711757217573175741757517576175771757817579175801758117582175831758417585175861758717588175891759017591175921759317594175951759617597175981759917600176011760217603176041760517606176071760817609176101761117612176131761417615176161761717618176191762017621176221762317624176251762617627176281762917630176311763217633176341763517636176371763817639176401764117642176431764417645176461764717648176491765017651176521765317654176551765617657176581765917660176611766217663176641766517666176671766817669176701767117672176731767417675176761767717678176791768017681176821768317684176851768617687176881768917690176911769217693176941769517696176971769817699177001770117702177031770417705177061770717708177091771017711177121771317714177151771617717177181771917720177211772217723177241772517726177271772817729177301773117732177331773417735177361773717738177391774017741177421774317744177451774617747177481774917750177511775217753177541775517756177571775817759177601776117762177631776417765177661776717768177691777017771177721777317774177751777617777177781777917780177811778217783177841778517786177871778817789177901779117792177931779417795177961779717798177991780017801178021780317804178051780617807178081780917810178111781217813178141781517816178171781817819178201782117822178231782417825178261782717828178291783017831178321783317834178351783617837178381783917840178411784217843178441784517846178471784817849178501785117852178531785417855178561785717858178591786017861178621786317864178651786617867178681786917870178711787217873178741787517876178771787817879178801788117882178831788417885178861788717888178891789017891178921789317894178951789617897178981789917900179011790217903179041790517906179071790817909179101791117912179131791417915179161791717918179191792017921179221792317924179251792617927179281792917930179311793217933179341793517936179371793817939179401794117942179431794417945179461794717948179491795017951179521795317954179551795617957179581795917960179611796217963179641796517966179671796817969179701797117972179731797417975179761797717978179791798017981179821798317984179851798617987179881798917990179911799217993179941799517996179971799817999180001800118002180031800418005180061800718008180091801018011180121801318014180151801618017180181801918020180211802218023180241802518026180271802818029180301803118032180331803418035180361803718038180391804018041180421804318044180451804618047180481804918050180511805218053180541805518056180571805818059180601806118062180631806418065180661806718068180691807018071180721807318074180751807618077180781807918080180811808218083180841808518086180871808818089180901809118092180931809418095180961809718098180991810018101181021810318104181051810618107181081810918110181111811218113181141811518116181171811818119181201812118122181231812418125181261812718128181291813018131181321813318134181351813618137181381813918140181411814218143181441814518146181471814818149181501815118152181531815418155181561815718158181591816018161181621816318164181651816618167181681816918170181711817218173181741817518176181771817818179181801818118182181831818418185181861818718188181891819018191181921819318194181951819618197181981819918200182011820218203182041820518206182071820818209182101821118212182131821418215182161821718218182191822018221182221822318224182251822618227182281822918230182311823218233182341823518236182371823818239182401824118242182431824418245182461824718248182491825018251182521825318254182551825618257182581825918260182611826218263182641826518266182671826818269182701827118272182731827418275182761827718278182791828018281182821828318284182851828618287182881828918290182911829218293182941829518296182971829818299183001830118302183031830418305183061830718308183091831018311183121831318314183151831618317183181831918320183211832218323183241832518326183271832818329183301833118332183331833418335183361833718338183391834018341183421834318344183451834618347183481834918350183511835218353183541835518356183571835818359183601836118362183631836418365183661836718368183691837018371183721837318374183751837618377183781837918380183811838218383183841838518386183871838818389183901839118392183931839418395183961839718398183991840018401184021840318404184051840618407184081840918410184111841218413184141841518416184171841818419184201842118422184231842418425184261842718428184291843018431184321843318434184351843618437184381843918440184411844218443184441844518446184471844818449184501845118452184531845418455184561845718458184591846018461184621846318464184651846618467184681846918470184711847218473184741847518476184771847818479184801848118482184831848418485184861848718488184891849018491184921849318494184951849618497184981849918500185011850218503185041850518506185071850818509185101851118512185131851418515185161851718518185191852018521185221852318524185251852618527185281852918530185311853218533185341853518536185371853818539185401854118542185431854418545185461854718548185491855018551185521855318554185551855618557185581855918560185611856218563185641856518566185671856818569185701857118572185731857418575185761857718578185791858018581185821858318584185851858618587185881858918590185911859218593185941859518596185971859818599186001860118602186031860418605186061860718608186091861018611186121861318614186151861618617186181861918620186211862218623186241862518626186271862818629186301863118632186331863418635186361863718638186391864018641186421864318644186451864618647186481864918650186511865218653186541865518656186571865818659186601866118662186631866418665186661866718668186691867018671186721867318674186751867618677186781867918680186811868218683186841868518686
  1. /*! jQuery UI - v1.12.0 - 2016-07-08
  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-1-7.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. if ( typeof define === "function" && define.amd ) {
  7. // AMD. Register as an anonymous module.
  8. define([ "jquery" ], factory );
  9. } else {
  10. // Browser globals
  11. factory( jQuery );
  12. }
  13. }(function( $ ) {
  14. $.ui = $.ui || {};
  15. var version = $.ui.version = "1.12.0";
  16. /*!
  17. * jQuery UI Widget 1.12.0
  18. * http://jqueryui.com
  19. *
  20. * Copyright jQuery Foundation and other contributors
  21. * Released under the MIT license.
  22. * http://jquery.org/license
  23. */
  24. //>>label: Widget
  25. //>>group: Core
  26. //>>description: Provides a factory for creating stateful widgets with a common API.
  27. //>>docs: http://api.jqueryui.com/jQuery.widget/
  28. //>>demos: http://jqueryui.com/widget/
  29. var widgetUuid = 0;
  30. var widgetSlice = Array.prototype.slice;
  31. $.cleanData = ( function( orig ) {
  32. return function( elems ) {
  33. var events, elem, i;
  34. for ( i = 0; ( elem = elems[ i ] ) != null; i++ ) {
  35. try {
  36. // Only trigger remove when necessary to save time
  37. events = $._data( elem, "events" );
  38. if ( events && events.remove ) {
  39. $( elem ).triggerHandler( "remove" );
  40. }
  41. // Http://bugs.jquery.com/ticket/8235
  42. } catch ( e ) {}
  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 ( $.isArray( prototype ) ) {
  60. prototype = $.extend.apply( null, [ {} ].concat( prototype ) );
  61. }
  62. // Create selector for plugin
  63. $.expr[ ":" ][ 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._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 ( !$.isFunction( value ) ) {
  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 ( input[ inputIndex ].hasOwnProperty( 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. this.each( function() {
  184. var methodValue;
  185. var instance = $.data( this, fullName );
  186. if ( options === "instance" ) {
  187. returnValue = instance;
  188. return false;
  189. }
  190. if ( !instance ) {
  191. return $.error( "cannot call methods on " + name +
  192. " prior to initialization; " +
  193. "attempted to call method '" + options + "'" );
  194. }
  195. if ( !$.isFunction( instance[ options ] ) || options.charAt( 0 ) === "_" ) {
  196. return $.error( "no such method '" + options + "' for " + name +
  197. " widget instance" );
  198. }
  199. methodValue = instance[ options ].apply( instance, args );
  200. if ( methodValue !== instance && methodValue !== undefined ) {
  201. returnValue = methodValue && methodValue.jquery ?
  202. returnValue.pushStack( methodValue.get() ) :
  203. methodValue;
  204. return false;
  205. }
  206. } );
  207. } else {
  208. // Allow multiple hashes to be passed on init
  209. if ( args.length ) {
  210. options = $.widget.extend.apply( null, [ options ].concat( args ) );
  211. }
  212. this.each( function() {
  213. var instance = $.data( this, fullName );
  214. if ( instance ) {
  215. instance.option( options || {} );
  216. if ( instance._init ) {
  217. instance._init();
  218. }
  219. } else {
  220. $.data( this, fullName, new object( options, this ) );
  221. }
  222. } );
  223. }
  224. return returnValue;
  225. };
  226. };
  227. $.Widget = function( /* options, element */ ) {};
  228. $.Widget._childConstructors = [];
  229. $.Widget.prototype = {
  230. widgetName: "widget",
  231. widgetEventPrefix: "",
  232. defaultElement: "<div>",
  233. options: {
  234. classes: {},
  235. disabled: false,
  236. // Callbacks
  237. create: null
  238. },
  239. _createWidget: function( options, element ) {
  240. element = $( element || this.defaultElement || this )[ 0 ];
  241. this.element = $( element );
  242. this.uuid = widgetUuid++;
  243. this.eventNamespace = "." + this.widgetName + this.uuid;
  244. this.bindings = $();
  245. this.hoverable = $();
  246. this.focusable = $();
  247. this.classesElementLookup = {};
  248. if ( element !== this ) {
  249. $.data( element, this.widgetFullName, this );
  250. this._on( true, this.element, {
  251. remove: function( event ) {
  252. if ( event.target === element ) {
  253. this.destroy();
  254. }
  255. }
  256. } );
  257. this.document = $( element.style ?
  258. // Element within the document
  259. element.ownerDocument :
  260. // Element is window or document
  261. element.document || element );
  262. this.window = $( this.document[ 0 ].defaultView || this.document[ 0 ].parentWindow );
  263. }
  264. this.options = $.widget.extend( {},
  265. this.options,
  266. this._getCreateOptions(),
  267. options );
  268. this._create();
  269. if ( this.options.disabled ) {
  270. this._setOptionDisabled( this.options.disabled );
  271. }
  272. this._trigger( "create", null, this._getCreateEventData() );
  273. this._init();
  274. },
  275. _getCreateOptions: function() {
  276. return {};
  277. },
  278. _getCreateEventData: $.noop,
  279. _create: $.noop,
  280. _init: $.noop,
  281. destroy: function() {
  282. var that = this;
  283. this._destroy();
  284. $.each( this.classesElementLookup, function( key, value ) {
  285. that._removeClass( value, key );
  286. } );
  287. // We can probably remove the unbind calls in 2.0
  288. // all event bindings should go through this._on()
  289. this.element
  290. .off( this.eventNamespace )
  291. .removeData( this.widgetFullName );
  292. this.widget()
  293. .off( this.eventNamespace )
  294. .removeAttr( "aria-disabled" );
  295. // Clean up events and states
  296. this.bindings.off( this.eventNamespace );
  297. },
  298. _destroy: $.noop,
  299. widget: function() {
  300. return this.element;
  301. },
  302. option: function( key, value ) {
  303. var options = key;
  304. var parts;
  305. var curOption;
  306. var i;
  307. if ( arguments.length === 0 ) {
  308. // Don't return a reference to the internal hash
  309. return $.widget.extend( {}, this.options );
  310. }
  311. if ( typeof key === "string" ) {
  312. // Handle nested keys, e.g., "foo.bar" => { foo: { bar: ___ } }
  313. options = {};
  314. parts = key.split( "." );
  315. key = parts.shift();
  316. if ( parts.length ) {
  317. curOption = options[ key ] = $.widget.extend( {}, this.options[ key ] );
  318. for ( i = 0; i < parts.length - 1; i++ ) {
  319. curOption[ parts[ i ] ] = curOption[ parts[ i ] ] || {};
  320. curOption = curOption[ parts[ i ] ];
  321. }
  322. key = parts.pop();
  323. if ( arguments.length === 1 ) {
  324. return curOption[ key ] === undefined ? null : curOption[ key ];
  325. }
  326. curOption[ key ] = value;
  327. } else {
  328. if ( arguments.length === 1 ) {
  329. return this.options[ key ] === undefined ? null : this.options[ key ];
  330. }
  331. options[ key ] = value;
  332. }
  333. }
  334. this._setOptions( options );
  335. return this;
  336. },
  337. _setOptions: function( options ) {
  338. var key;
  339. for ( key in options ) {
  340. this._setOption( key, options[ key ] );
  341. }
  342. return this;
  343. },
  344. _setOption: function( key, value ) {
  345. if ( key === "classes" ) {
  346. this._setOptionClasses( value );
  347. }
  348. this.options[ key ] = value;
  349. if ( key === "disabled" ) {
  350. this._setOptionDisabled( value );
  351. }
  352. return this;
  353. },
  354. _setOptionClasses: function( value ) {
  355. var classKey, elements, currentElements;
  356. for ( classKey in value ) {
  357. currentElements = this.classesElementLookup[ classKey ];
  358. if ( value[ classKey ] === this.options.classes[ classKey ] ||
  359. !currentElements ||
  360. !currentElements.length ) {
  361. continue;
  362. }
  363. // We are doing this to create a new jQuery object because the _removeClass() call
  364. // on the next line is going to destroy the reference to the current elements being
  365. // tracked. We need to save a copy of this collection so that we can add the new classes
  366. // below.
  367. elements = $( currentElements.get() );
  368. this._removeClass( currentElements, classKey );
  369. // We don't use _addClass() here, because that uses this.options.classes
  370. // for generating the string of classes. We want to use the value passed in from
  371. // _setOption(), this is the new value of the classes option which was passed to
  372. // _setOption(). We pass this value directly to _classes().
  373. elements.addClass( this._classes( {
  374. element: elements,
  375. keys: classKey,
  376. classes: value,
  377. add: true
  378. } ) );
  379. }
  380. },
  381. _setOptionDisabled: function( value ) {
  382. this._toggleClass( this.widget(), this.widgetFullName + "-disabled", null, !!value );
  383. // If the widget is becoming disabled, then nothing is interactive
  384. if ( value ) {
  385. this._removeClass( this.hoverable, null, "ui-state-hover" );
  386. this._removeClass( this.focusable, null, "ui-state-focus" );
  387. }
  388. },
  389. enable: function() {
  390. return this._setOptions( { disabled: false } );
  391. },
  392. disable: function() {
  393. return this._setOptions( { disabled: true } );
  394. },
  395. _classes: function( options ) {
  396. var full = [];
  397. var that = this;
  398. options = $.extend( {
  399. element: this.element,
  400. classes: this.options.classes || {}
  401. }, options );
  402. function processClassString( classes, checkOption ) {
  403. var current, i;
  404. for ( i = 0; i < classes.length; i++ ) {
  405. current = that.classesElementLookup[ classes[ i ] ] || $();
  406. if ( options.add ) {
  407. current = $( $.unique( current.get().concat( options.element.get() ) ) );
  408. } else {
  409. current = $( current.not( options.element ).get() );
  410. }
  411. that.classesElementLookup[ classes[ i ] ] = current;
  412. full.push( classes[ i ] );
  413. if ( checkOption && options.classes[ classes[ i ] ] ) {
  414. full.push( options.classes[ classes[ i ] ] );
  415. }
  416. }
  417. }
  418. if ( options.keys ) {
  419. processClassString( options.keys.match( /\S+/g ) || [], true );
  420. }
  421. if ( options.extra ) {
  422. processClassString( options.extra.match( /\S+/g ) || [] );
  423. }
  424. return full.join( " " );
  425. },
  426. _removeClass: function( element, keys, extra ) {
  427. return this._toggleClass( element, keys, extra, false );
  428. },
  429. _addClass: function( element, keys, extra ) {
  430. return this._toggleClass( element, keys, extra, true );
  431. },
  432. _toggleClass: function( element, keys, extra, add ) {
  433. add = ( typeof add === "boolean" ) ? add : extra;
  434. var shift = ( typeof element === "string" || element === null ),
  435. options = {
  436. extra: shift ? keys : extra,
  437. keys: shift ? element : keys,
  438. element: shift ? this.element : element,
  439. add: add
  440. };
  441. options.element.toggleClass( this._classes( options ), add );
  442. return this;
  443. },
  444. _on: function( suppressDisabledCheck, element, handlers ) {
  445. var delegateElement;
  446. var instance = this;
  447. // No suppressDisabledCheck flag, shuffle arguments
  448. if ( typeof suppressDisabledCheck !== "boolean" ) {
  449. handlers = element;
  450. element = suppressDisabledCheck;
  451. suppressDisabledCheck = false;
  452. }
  453. // No element argument, shuffle and use this.element
  454. if ( !handlers ) {
  455. handlers = element;
  456. element = this.element;
  457. delegateElement = this.widget();
  458. } else {
  459. element = delegateElement = $( element );
  460. this.bindings = this.bindings.add( element );
  461. }
  462. $.each( handlers, function( event, handler ) {
  463. function handlerProxy() {
  464. // Allow widgets to customize the disabled handling
  465. // - disabled as an array instead of boolean
  466. // - disabled class as method for disabling individual parts
  467. if ( !suppressDisabledCheck &&
  468. ( instance.options.disabled === true ||
  469. $( this ).hasClass( "ui-state-disabled" ) ) ) {
  470. return;
  471. }
  472. return ( typeof handler === "string" ? instance[ handler ] : handler )
  473. .apply( instance, arguments );
  474. }
  475. // Copy the guid so direct unbinding works
  476. if ( typeof handler !== "string" ) {
  477. handlerProxy.guid = handler.guid =
  478. handler.guid || handlerProxy.guid || $.guid++;
  479. }
  480. var match = event.match( /^([\w:-]*)\s*(.*)$/ );
  481. var eventName = match[ 1 ] + instance.eventNamespace;
  482. var selector = match[ 2 ];
  483. if ( selector ) {
  484. delegateElement.on( eventName, selector, handlerProxy );
  485. } else {
  486. element.on( eventName, handlerProxy );
  487. }
  488. } );
  489. },
  490. _off: function( element, eventName ) {
  491. eventName = ( eventName || "" ).split( " " ).join( this.eventNamespace + " " ) +
  492. this.eventNamespace;
  493. element.off( eventName ).off( eventName );
  494. // Clear the stack to avoid memory leaks (#10056)
  495. this.bindings = $( this.bindings.not( element ).get() );
  496. this.focusable = $( this.focusable.not( element ).get() );
  497. this.hoverable = $( this.hoverable.not( element ).get() );
  498. },
  499. _delay: function( handler, delay ) {
  500. function handlerProxy() {
  501. return ( typeof handler === "string" ? instance[ handler ] : handler )
  502. .apply( instance, arguments );
  503. }
  504. var instance = this;
  505. return setTimeout( handlerProxy, delay || 0 );
  506. },
  507. _hoverable: function( element ) {
  508. this.hoverable = this.hoverable.add( element );
  509. this._on( element, {
  510. mouseenter: function( event ) {
  511. this._addClass( $( event.currentTarget ), null, "ui-state-hover" );
  512. },
  513. mouseleave: function( event ) {
  514. this._removeClass( $( event.currentTarget ), null, "ui-state-hover" );
  515. }
  516. } );
  517. },
  518. _focusable: function( element ) {
  519. this.focusable = this.focusable.add( element );
  520. this._on( element, {
  521. focusin: function( event ) {
  522. this._addClass( $( event.currentTarget ), null, "ui-state-focus" );
  523. },
  524. focusout: function( event ) {
  525. this._removeClass( $( event.currentTarget ), null, "ui-state-focus" );
  526. }
  527. } );
  528. },
  529. _trigger: function( type, event, data ) {
  530. var prop, orig;
  531. var callback = this.options[ type ];
  532. data = data || {};
  533. event = $.Event( event );
  534. event.type = ( type === this.widgetEventPrefix ?
  535. type :
  536. this.widgetEventPrefix + type ).toLowerCase();
  537. // The original event may come from any element
  538. // so we need to reset the target on the new event
  539. event.target = this.element[ 0 ];
  540. // Copy original event properties over to the new event
  541. orig = event.originalEvent;
  542. if ( orig ) {
  543. for ( prop in orig ) {
  544. if ( !( prop in event ) ) {
  545. event[ prop ] = orig[ prop ];
  546. }
  547. }
  548. }
  549. this.element.trigger( event, data );
  550. return !( $.isFunction( callback ) &&
  551. callback.apply( this.element[ 0 ], [ event ].concat( data ) ) === false ||
  552. event.isDefaultPrevented() );
  553. }
  554. };
  555. $.each( { show: "fadeIn", hide: "fadeOut" }, function( method, defaultEffect ) {
  556. $.Widget.prototype[ "_" + method ] = function( element, options, callback ) {
  557. if ( typeof options === "string" ) {
  558. options = { effect: options };
  559. }
  560. var hasOptions;
  561. var effectName = !options ?
  562. method :
  563. options === true || typeof options === "number" ?
  564. defaultEffect :
  565. options.effect || defaultEffect;
  566. options = options || {};
  567. if ( typeof options === "number" ) {
  568. options = { duration: options };
  569. }
  570. hasOptions = !$.isEmptyObject( options );
  571. options.complete = callback;
  572. if ( options.delay ) {
  573. element.delay( options.delay );
  574. }
  575. if ( hasOptions && $.effects && $.effects.effect[ effectName ] ) {
  576. element[ method ]( options );
  577. } else if ( effectName !== method && element[ effectName ] ) {
  578. element[ effectName ]( options.duration, options.easing, callback );
  579. } else {
  580. element.queue( function( next ) {
  581. $( this )[ method ]();
  582. if ( callback ) {
  583. callback.call( element[ 0 ] );
  584. }
  585. next();
  586. } );
  587. }
  588. };
  589. } );
  590. var widget = $.widget;
  591. /*!
  592. * jQuery UI Position 1.12.0
  593. * http://jqueryui.com
  594. *
  595. * Copyright jQuery Foundation and other contributors
  596. * Released under the MIT license.
  597. * http://jquery.org/license
  598. *
  599. * http://api.jqueryui.com/position/
  600. */
  601. //>>label: Position
  602. //>>group: Core
  603. //>>description: Positions elements relative to other elements.
  604. //>>docs: http://api.jqueryui.com/position/
  605. //>>demos: http://jqueryui.com/position/
  606. ( function() {
  607. var cachedScrollbarWidth, supportsOffsetFractions,
  608. max = Math.max,
  609. abs = Math.abs,
  610. round = Math.round,
  611. rhorizontal = /left|center|right/,
  612. rvertical = /top|center|bottom/,
  613. roffset = /[\+\-]\d+(\.[\d]+)?%?/,
  614. rposition = /^\w+/,
  615. rpercent = /%$/,
  616. _position = $.fn.position;
  617. // Support: IE <=9 only
  618. supportsOffsetFractions = function() {
  619. var element = $( "<div>" )
  620. .css( "position", "absolute" )
  621. .appendTo( "body" )
  622. .offset( {
  623. top: 1.5,
  624. left: 1.5
  625. } ),
  626. support = element.offset().top === 1.5;
  627. element.remove();
  628. supportsOffsetFractions = function() {
  629. return support;
  630. };
  631. return support;
  632. };
  633. function getOffsets( offsets, width, height ) {
  634. return [
  635. parseFloat( offsets[ 0 ] ) * ( rpercent.test( offsets[ 0 ] ) ? width / 100 : 1 ),
  636. parseFloat( offsets[ 1 ] ) * ( rpercent.test( offsets[ 1 ] ) ? height / 100 : 1 )
  637. ];
  638. }
  639. function parseCss( element, property ) {
  640. return parseInt( $.css( element, property ), 10 ) || 0;
  641. }
  642. function getDimensions( elem ) {
  643. var raw = elem[ 0 ];
  644. if ( raw.nodeType === 9 ) {
  645. return {
  646. width: elem.width(),
  647. height: elem.height(),
  648. offset: { top: 0, left: 0 }
  649. };
  650. }
  651. if ( $.isWindow( raw ) ) {
  652. return {
  653. width: elem.width(),
  654. height: elem.height(),
  655. offset: { top: elem.scrollTop(), left: elem.scrollLeft() }
  656. };
  657. }
  658. if ( raw.preventDefault ) {
  659. return {
  660. width: 0,
  661. height: 0,
  662. offset: { top: raw.pageY, left: raw.pageX }
  663. };
  664. }
  665. return {
  666. width: elem.outerWidth(),
  667. height: elem.outerHeight(),
  668. offset: elem.offset()
  669. };
  670. }
  671. $.position = {
  672. scrollbarWidth: function() {
  673. if ( cachedScrollbarWidth !== undefined ) {
  674. return cachedScrollbarWidth;
  675. }
  676. var w1, w2,
  677. div = $( "<div " +
  678. "style='display:block;position:absolute;width:50px;height:50px;overflow:hidden;'>" +
  679. "<div style='height:100px;width:auto;'></div></div>" ),
  680. innerDiv = div.children()[ 0 ];
  681. $( "body" ).append( div );
  682. w1 = innerDiv.offsetWidth;
  683. div.css( "overflow", "scroll" );
  684. w2 = innerDiv.offsetWidth;
  685. if ( w1 === w2 ) {
  686. w2 = div[ 0 ].clientWidth;
  687. }
  688. div.remove();
  689. return ( cachedScrollbarWidth = w1 - w2 );
  690. },
  691. getScrollInfo: function( within ) {
  692. var overflowX = within.isWindow || within.isDocument ? "" :
  693. within.element.css( "overflow-x" ),
  694. overflowY = within.isWindow || within.isDocument ? "" :
  695. within.element.css( "overflow-y" ),
  696. hasOverflowX = overflowX === "scroll" ||
  697. ( overflowX === "auto" && within.width < within.element[ 0 ].scrollWidth ),
  698. hasOverflowY = overflowY === "scroll" ||
  699. ( overflowY === "auto" && within.height < within.element[ 0 ].scrollHeight );
  700. return {
  701. width: hasOverflowY ? $.position.scrollbarWidth() : 0,
  702. height: hasOverflowX ? $.position.scrollbarWidth() : 0
  703. };
  704. },
  705. getWithinInfo: function( element ) {
  706. var withinElement = $( element || window ),
  707. isWindow = $.isWindow( withinElement[ 0 ] ),
  708. isDocument = !!withinElement[ 0 ] && withinElement[ 0 ].nodeType === 9,
  709. hasOffset = !isWindow && !isDocument;
  710. return {
  711. element: withinElement,
  712. isWindow: isWindow,
  713. isDocument: isDocument,
  714. offset: hasOffset ? $( element ).offset() : { left: 0, top: 0 },
  715. scrollLeft: withinElement.scrollLeft(),
  716. scrollTop: withinElement.scrollTop(),
  717. width: withinElement.outerWidth(),
  718. height: withinElement.outerHeight()
  719. };
  720. }
  721. };
  722. $.fn.position = function( options ) {
  723. if ( !options || !options.of ) {
  724. return _position.apply( this, arguments );
  725. }
  726. // Make a copy, we don't want to modify arguments
  727. options = $.extend( {}, options );
  728. var atOffset, targetWidth, targetHeight, targetOffset, basePosition, dimensions,
  729. target = $( options.of ),
  730. within = $.position.getWithinInfo( options.within ),
  731. scrollInfo = $.position.getScrollInfo( within ),
  732. collision = ( options.collision || "flip" ).split( " " ),
  733. offsets = {};
  734. dimensions = getDimensions( target );
  735. if ( target[ 0 ].preventDefault ) {
  736. // Force left top to allow flipping
  737. options.at = "left top";
  738. }
  739. targetWidth = dimensions.width;
  740. targetHeight = dimensions.height;
  741. targetOffset = dimensions.offset;
  742. // Clone to reuse original targetOffset later
  743. basePosition = $.extend( {}, targetOffset );
  744. // Force my and at to have valid horizontal and vertical positions
  745. // if a value is missing or invalid, it will be converted to center
  746. $.each( [ "my", "at" ], function() {
  747. var pos = ( options[ this ] || "" ).split( " " ),
  748. horizontalOffset,
  749. verticalOffset;
  750. if ( pos.length === 1 ) {
  751. pos = rhorizontal.test( pos[ 0 ] ) ?
  752. pos.concat( [ "center" ] ) :
  753. rvertical.test( pos[ 0 ] ) ?
  754. [ "center" ].concat( pos ) :
  755. [ "center", "center" ];
  756. }
  757. pos[ 0 ] = rhorizontal.test( pos[ 0 ] ) ? pos[ 0 ] : "center";
  758. pos[ 1 ] = rvertical.test( pos[ 1 ] ) ? pos[ 1 ] : "center";
  759. // Calculate offsets
  760. horizontalOffset = roffset.exec( pos[ 0 ] );
  761. verticalOffset = roffset.exec( pos[ 1 ] );
  762. offsets[ this ] = [
  763. horizontalOffset ? horizontalOffset[ 0 ] : 0,
  764. verticalOffset ? verticalOffset[ 0 ] : 0
  765. ];
  766. // Reduce to just the positions without the offsets
  767. options[ this ] = [
  768. rposition.exec( pos[ 0 ] )[ 0 ],
  769. rposition.exec( pos[ 1 ] )[ 0 ]
  770. ];
  771. } );
  772. // Normalize collision option
  773. if ( collision.length === 1 ) {
  774. collision[ 1 ] = collision[ 0 ];
  775. }
  776. if ( options.at[ 0 ] === "right" ) {
  777. basePosition.left += targetWidth;
  778. } else if ( options.at[ 0 ] === "center" ) {
  779. basePosition.left += targetWidth / 2;
  780. }
  781. if ( options.at[ 1 ] === "bottom" ) {
  782. basePosition.top += targetHeight;
  783. } else if ( options.at[ 1 ] === "center" ) {
  784. basePosition.top += targetHeight / 2;
  785. }
  786. atOffset = getOffsets( offsets.at, targetWidth, targetHeight );
  787. basePosition.left += atOffset[ 0 ];
  788. basePosition.top += atOffset[ 1 ];
  789. return this.each( function() {
  790. var collisionPosition, using,
  791. elem = $( this ),
  792. elemWidth = elem.outerWidth(),
  793. elemHeight = elem.outerHeight(),
  794. marginLeft = parseCss( this, "marginLeft" ),
  795. marginTop = parseCss( this, "marginTop" ),
  796. collisionWidth = elemWidth + marginLeft + parseCss( this, "marginRight" ) +
  797. scrollInfo.width,
  798. collisionHeight = elemHeight + marginTop + parseCss( this, "marginBottom" ) +
  799. scrollInfo.height,
  800. position = $.extend( {}, basePosition ),
  801. myOffset = getOffsets( offsets.my, elem.outerWidth(), elem.outerHeight() );
  802. if ( options.my[ 0 ] === "right" ) {
  803. position.left -= elemWidth;
  804. } else if ( options.my[ 0 ] === "center" ) {
  805. position.left -= elemWidth / 2;
  806. }
  807. if ( options.my[ 1 ] === "bottom" ) {
  808. position.top -= elemHeight;
  809. } else if ( options.my[ 1 ] === "center" ) {
  810. position.top -= elemHeight / 2;
  811. }
  812. position.left += myOffset[ 0 ];
  813. position.top += myOffset[ 1 ];
  814. // If the browser doesn't support fractions, then round for consistent results
  815. if ( !supportsOffsetFractions() ) {
  816. position.left = round( position.left );
  817. position.top = round( position.top );
  818. }
  819. collisionPosition = {
  820. marginLeft: marginLeft,
  821. marginTop: marginTop
  822. };
  823. $.each( [ "left", "top" ], function( i, dir ) {
  824. if ( $.ui.position[ collision[ i ] ] ) {
  825. $.ui.position[ collision[ i ] ][ dir ]( position, {
  826. targetWidth: targetWidth,
  827. targetHeight: targetHeight,
  828. elemWidth: elemWidth,
  829. elemHeight: elemHeight,
  830. collisionPosition: collisionPosition,
  831. collisionWidth: collisionWidth,
  832. collisionHeight: collisionHeight,
  833. offset: [ atOffset[ 0 ] + myOffset[ 0 ], atOffset [ 1 ] + myOffset[ 1 ] ],
  834. my: options.my,
  835. at: options.at,
  836. within: within,
  837. elem: elem
  838. } );
  839. }
  840. } );
  841. if ( options.using ) {
  842. // Adds feedback as second argument to using callback, if present
  843. using = function( props ) {
  844. var left = targetOffset.left - position.left,
  845. right = left + targetWidth - elemWidth,
  846. top = targetOffset.top - position.top,
  847. bottom = top + targetHeight - elemHeight,
  848. feedback = {
  849. target: {
  850. element: target,
  851. left: targetOffset.left,
  852. top: targetOffset.top,
  853. width: targetWidth,
  854. height: targetHeight
  855. },
  856. element: {
  857. element: elem,
  858. left: position.left,
  859. top: position.top,
  860. width: elemWidth,
  861. height: elemHeight
  862. },
  863. horizontal: right < 0 ? "left" : left > 0 ? "right" : "center",
  864. vertical: bottom < 0 ? "top" : top > 0 ? "bottom" : "middle"
  865. };
  866. if ( targetWidth < elemWidth && abs( left + right ) < targetWidth ) {
  867. feedback.horizontal = "center";
  868. }
  869. if ( targetHeight < elemHeight && abs( top + bottom ) < targetHeight ) {
  870. feedback.vertical = "middle";
  871. }
  872. if ( max( abs( left ), abs( right ) ) > max( abs( top ), abs( bottom ) ) ) {
  873. feedback.important = "horizontal";
  874. } else {
  875. feedback.important = "vertical";
  876. }
  877. options.using.call( this, props, feedback );
  878. };
  879. }
  880. elem.offset( $.extend( position, { using: using } ) );
  881. } );
  882. };
  883. $.ui.position = {
  884. fit: {
  885. left: function( position, data ) {
  886. var within = data.within,
  887. withinOffset = within.isWindow ? within.scrollLeft : within.offset.left,
  888. outerWidth = within.width,
  889. collisionPosLeft = position.left - data.collisionPosition.marginLeft,
  890. overLeft = withinOffset - collisionPosLeft,
  891. overRight = collisionPosLeft + data.collisionWidth - outerWidth - withinOffset,
  892. newOverRight;
  893. // Element is wider than within
  894. if ( data.collisionWidth > outerWidth ) {
  895. // Element is initially over the left side of within
  896. if ( overLeft > 0 && overRight <= 0 ) {
  897. newOverRight = position.left + overLeft + data.collisionWidth - outerWidth -
  898. withinOffset;
  899. position.left += overLeft - newOverRight;
  900. // Element is initially over right side of within
  901. } else if ( overRight > 0 && overLeft <= 0 ) {
  902. position.left = withinOffset;
  903. // Element is initially over both left and right sides of within
  904. } else {
  905. if ( overLeft > overRight ) {
  906. position.left = withinOffset + outerWidth - data.collisionWidth;
  907. } else {
  908. position.left = withinOffset;
  909. }
  910. }
  911. // Too far left -> align with left edge
  912. } else if ( overLeft > 0 ) {
  913. position.left += overLeft;
  914. // Too far right -> align with right edge
  915. } else if ( overRight > 0 ) {
  916. position.left -= overRight;
  917. // Adjust based on position and margin
  918. } else {
  919. position.left = max( position.left - collisionPosLeft, position.left );
  920. }
  921. },
  922. top: function( position, data ) {
  923. var within = data.within,
  924. withinOffset = within.isWindow ? within.scrollTop : within.offset.top,
  925. outerHeight = data.within.height,
  926. collisionPosTop = position.top - data.collisionPosition.marginTop,
  927. overTop = withinOffset - collisionPosTop,
  928. overBottom = collisionPosTop + data.collisionHeight - outerHeight - withinOffset,
  929. newOverBottom;
  930. // Element is taller than within
  931. if ( data.collisionHeight > outerHeight ) {
  932. // Element is initially over the top of within
  933. if ( overTop > 0 && overBottom <= 0 ) {
  934. newOverBottom = position.top + overTop + data.collisionHeight - outerHeight -
  935. withinOffset;
  936. position.top += overTop - newOverBottom;
  937. // Element is initially over bottom of within
  938. } else if ( overBottom > 0 && overTop <= 0 ) {
  939. position.top = withinOffset;
  940. // Element is initially over both top and bottom of within
  941. } else {
  942. if ( overTop > overBottom ) {
  943. position.top = withinOffset + outerHeight - data.collisionHeight;
  944. } else {
  945. position.top = withinOffset;
  946. }
  947. }
  948. // Too far up -> align with top
  949. } else if ( overTop > 0 ) {
  950. position.top += overTop;
  951. // Too far down -> align with bottom edge
  952. } else if ( overBottom > 0 ) {
  953. position.top -= overBottom;
  954. // Adjust based on position and margin
  955. } else {
  956. position.top = max( position.top - collisionPosTop, position.top );
  957. }
  958. }
  959. },
  960. flip: {
  961. left: function( position, data ) {
  962. var within = data.within,
  963. withinOffset = within.offset.left + within.scrollLeft,
  964. outerWidth = within.width,
  965. offsetLeft = within.isWindow ? within.scrollLeft : within.offset.left,
  966. collisionPosLeft = position.left - data.collisionPosition.marginLeft,
  967. overLeft = collisionPosLeft - offsetLeft,
  968. overRight = collisionPosLeft + data.collisionWidth - outerWidth - offsetLeft,
  969. myOffset = data.my[ 0 ] === "left" ?
  970. -data.elemWidth :
  971. data.my[ 0 ] === "right" ?
  972. data.elemWidth :
  973. 0,
  974. atOffset = data.at[ 0 ] === "left" ?
  975. data.targetWidth :
  976. data.at[ 0 ] === "right" ?
  977. -data.targetWidth :
  978. 0,
  979. offset = -2 * data.offset[ 0 ],
  980. newOverRight,
  981. newOverLeft;
  982. if ( overLeft < 0 ) {
  983. newOverRight = position.left + myOffset + atOffset + offset + data.collisionWidth -
  984. outerWidth - withinOffset;
  985. if ( newOverRight < 0 || newOverRight < abs( overLeft ) ) {
  986. position.left += myOffset + atOffset + offset;
  987. }
  988. } else if ( overRight > 0 ) {
  989. newOverLeft = position.left - data.collisionPosition.marginLeft + myOffset +
  990. atOffset + offset - offsetLeft;
  991. if ( newOverLeft > 0 || abs( newOverLeft ) < overRight ) {
  992. position.left += myOffset + atOffset + offset;
  993. }
  994. }
  995. },
  996. top: function( position, data ) {
  997. var within = data.within,
  998. withinOffset = within.offset.top + within.scrollTop,
  999. outerHeight = within.height,
  1000. offsetTop = within.isWindow ? within.scrollTop : within.offset.top,
  1001. collisionPosTop = position.top - data.collisionPosition.marginTop,
  1002. overTop = collisionPosTop - offsetTop,
  1003. overBottom = collisionPosTop + data.collisionHeight - outerHeight - offsetTop,
  1004. top = data.my[ 1 ] === "top",
  1005. myOffset = top ?
  1006. -data.elemHeight :
  1007. data.my[ 1 ] === "bottom" ?
  1008. data.elemHeight :
  1009. 0,
  1010. atOffset = data.at[ 1 ] === "top" ?
  1011. data.targetHeight :
  1012. data.at[ 1 ] === "bottom" ?
  1013. -data.targetHeight :
  1014. 0,
  1015. offset = -2 * data.offset[ 1 ],
  1016. newOverTop,
  1017. newOverBottom;
  1018. if ( overTop < 0 ) {
  1019. newOverBottom = position.top + myOffset + atOffset + offset + data.collisionHeight -
  1020. outerHeight - withinOffset;
  1021. if ( newOverBottom < 0 || newOverBottom < abs( overTop ) ) {
  1022. position.top += myOffset + atOffset + offset;
  1023. }
  1024. } else if ( overBottom > 0 ) {
  1025. newOverTop = position.top - data.collisionPosition.marginTop + myOffset + atOffset +
  1026. offset - offsetTop;
  1027. if ( newOverTop > 0 || abs( newOverTop ) < overBottom ) {
  1028. position.top += myOffset + atOffset + offset;
  1029. }
  1030. }
  1031. }
  1032. },
  1033. flipfit: {
  1034. left: function() {
  1035. $.ui.position.flip.left.apply( this, arguments );
  1036. $.ui.position.fit.left.apply( this, arguments );
  1037. },
  1038. top: function() {
  1039. $.ui.position.flip.top.apply( this, arguments );
  1040. $.ui.position.fit.top.apply( this, arguments );
  1041. }
  1042. }
  1043. };
  1044. } )();
  1045. var position = $.ui.position;
  1046. /*!
  1047. * jQuery UI :data 1.12.0
  1048. * http://jqueryui.com
  1049. *
  1050. * Copyright jQuery Foundation and other contributors
  1051. * Released under the MIT license.
  1052. * http://jquery.org/license
  1053. */
  1054. //>>label: :data Selector
  1055. //>>group: Core
  1056. //>>description: Selects elements which have data stored under the specified key.
  1057. //>>docs: http://api.jqueryui.com/data-selector/
  1058. var data = $.extend( $.expr[ ":" ], {
  1059. data: $.expr.createPseudo ?
  1060. $.expr.createPseudo( function( dataName ) {
  1061. return function( elem ) {
  1062. return !!$.data( elem, dataName );
  1063. };
  1064. } ) :
  1065. // Support: jQuery <1.8
  1066. function( elem, i, match ) {
  1067. return !!$.data( elem, match[ 3 ] );
  1068. }
  1069. } );
  1070. /*!
  1071. * jQuery UI Disable Selection 1.12.0
  1072. * http://jqueryui.com
  1073. *
  1074. * Copyright jQuery Foundation and other contributors
  1075. * Released under the MIT license.
  1076. * http://jquery.org/license
  1077. */
  1078. //>>label: disableSelection
  1079. //>>group: Core
  1080. //>>description: Disable selection of text content within the set of matched elements.
  1081. //>>docs: http://api.jqueryui.com/disableSelection/
  1082. // This file is deprecated
  1083. var disableSelection = $.fn.extend( {
  1084. disableSelection: ( function() {
  1085. var eventType = "onselectstart" in document.createElement( "div" ) ?
  1086. "selectstart" :
  1087. "mousedown";
  1088. return function() {
  1089. return this.on( eventType + ".ui-disableSelection", function( event ) {
  1090. event.preventDefault();
  1091. } );
  1092. };
  1093. } )(),
  1094. enableSelection: function() {
  1095. return this.off( ".ui-disableSelection" );
  1096. }
  1097. } );
  1098. /*!
  1099. * jQuery UI Effects 1.12.0
  1100. * http://jqueryui.com
  1101. *
  1102. * Copyright jQuery Foundation and other contributors
  1103. * Released under the MIT license.
  1104. * http://jquery.org/license
  1105. */
  1106. //>>label: Effects Core
  1107. //>>group: Effects
  1108. // jscs:disable maximumLineLength
  1109. //>>description: Extends the internal jQuery effects. Includes morphing and easing. Required by all other effects.
  1110. // jscs:enable maximumLineLength
  1111. //>>docs: http://api.jqueryui.com/category/effects-core/
  1112. //>>demos: http://jqueryui.com/effect/
  1113. var dataSpace = "ui-effects-",
  1114. dataSpaceStyle = "ui-effects-style",
  1115. dataSpaceAnimated = "ui-effects-animated",
  1116. // Create a local jQuery because jQuery Color relies on it and the
  1117. // global may not exist with AMD and a custom build (#10199)
  1118. jQuery = $;
  1119. $.effects = {
  1120. effect: {}
  1121. };
  1122. /*!
  1123. * jQuery Color Animations v2.1.2
  1124. * https://github.com/jquery/jquery-color
  1125. *
  1126. * Copyright 2014 jQuery Foundation and other contributors
  1127. * Released under the MIT license.
  1128. * http://jquery.org/license
  1129. *
  1130. * Date: Wed Jan 16 08:47:09 2013 -0600
  1131. */
  1132. ( function( jQuery, undefined ) {
  1133. var stepHooks = "backgroundColor borderBottomColor borderLeftColor borderRightColor " +
  1134. "borderTopColor color columnRuleColor outlineColor textDecorationColor textEmphasisColor",
  1135. // Plusequals test for += 100 -= 100
  1136. rplusequals = /^([\-+])=\s*(\d+\.?\d*)/,
  1137. // A set of RE's that can match strings and generate color tuples.
  1138. stringParsers = [ {
  1139. re: /rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(?:,\s*(\d?(?:\.\d+)?)\s*)?\)/,
  1140. parse: function( execResult ) {
  1141. return [
  1142. execResult[ 1 ],
  1143. execResult[ 2 ],
  1144. execResult[ 3 ],
  1145. execResult[ 4 ]
  1146. ];
  1147. }
  1148. }, {
  1149. re: /rgba?\(\s*(\d+(?:\.\d+)?)\%\s*,\s*(\d+(?:\.\d+)?)\%\s*,\s*(\d+(?:\.\d+)?)\%\s*(?:,\s*(\d?(?:\.\d+)?)\s*)?\)/,
  1150. parse: function( execResult ) {
  1151. return [
  1152. execResult[ 1 ] * 2.55,
  1153. execResult[ 2 ] * 2.55,
  1154. execResult[ 3 ] * 2.55,
  1155. execResult[ 4 ]
  1156. ];
  1157. }
  1158. }, {
  1159. // This regex ignores A-F because it's compared against an already lowercased string
  1160. re: /#([a-f0-9]{2})([a-f0-9]{2})([a-f0-9]{2})/,
  1161. parse: function( execResult ) {
  1162. return [
  1163. parseInt( execResult[ 1 ], 16 ),
  1164. parseInt( execResult[ 2 ], 16 ),
  1165. parseInt( execResult[ 3 ], 16 )
  1166. ];
  1167. }
  1168. }, {
  1169. // This regex ignores A-F because it's compared against an already lowercased string
  1170. re: /#([a-f0-9])([a-f0-9])([a-f0-9])/,
  1171. parse: function( execResult ) {
  1172. return [
  1173. parseInt( execResult[ 1 ] + execResult[ 1 ], 16 ),
  1174. parseInt( execResult[ 2 ] + execResult[ 2 ], 16 ),
  1175. parseInt( execResult[ 3 ] + execResult[ 3 ], 16 )
  1176. ];
  1177. }
  1178. }, {
  1179. re: /hsla?\(\s*(\d+(?:\.\d+)?)\s*,\s*(\d+(?:\.\d+)?)\%\s*,\s*(\d+(?:\.\d+)?)\%\s*(?:,\s*(\d?(?:\.\d+)?)\s*)?\)/,
  1180. space: "hsla",
  1181. parse: function( execResult ) {
  1182. return [
  1183. execResult[ 1 ],
  1184. execResult[ 2 ] / 100,
  1185. execResult[ 3 ] / 100,
  1186. execResult[ 4 ]
  1187. ];
  1188. }
  1189. } ],
  1190. // JQuery.Color( )
  1191. color = jQuery.Color = function( color, green, blue, alpha ) {
  1192. return new jQuery.Color.fn.parse( color, green, blue, alpha );
  1193. },
  1194. spaces = {
  1195. rgba: {
  1196. props: {
  1197. red: {
  1198. idx: 0,
  1199. type: "byte"
  1200. },
  1201. green: {
  1202. idx: 1,
  1203. type: "byte"
  1204. },
  1205. blue: {
  1206. idx: 2,
  1207. type: "byte"
  1208. }
  1209. }
  1210. },
  1211. hsla: {
  1212. props: {
  1213. hue: {
  1214. idx: 0,
  1215. type: "degrees"
  1216. },
  1217. saturation: {
  1218. idx: 1,
  1219. type: "percent"
  1220. },
  1221. lightness: {
  1222. idx: 2,
  1223. type: "percent"
  1224. }
  1225. }
  1226. }
  1227. },
  1228. propTypes = {
  1229. "byte": {
  1230. floor: true,
  1231. max: 255
  1232. },
  1233. "percent": {
  1234. max: 1
  1235. },
  1236. "degrees": {
  1237. mod: 360,
  1238. floor: true
  1239. }
  1240. },
  1241. support = color.support = {},
  1242. // Element for support tests
  1243. supportElem = jQuery( "<p>" )[ 0 ],
  1244. // Colors = jQuery.Color.names
  1245. colors,
  1246. // Local aliases of functions called often
  1247. each = jQuery.each;
  1248. // Determine rgba support immediately
  1249. supportElem.style.cssText = "background-color:rgba(1,1,1,.5)";
  1250. support.rgba = supportElem.style.backgroundColor.indexOf( "rgba" ) > -1;
  1251. // Define cache name and alpha properties
  1252. // for rgba and hsla spaces
  1253. each( spaces, function( spaceName, space ) {
  1254. space.cache = "_" + spaceName;
  1255. space.props.alpha = {
  1256. idx: 3,
  1257. type: "percent",
  1258. def: 1
  1259. };
  1260. } );
  1261. function clamp( value, prop, allowEmpty ) {
  1262. var type = propTypes[ prop.type ] || {};
  1263. if ( value == null ) {
  1264. return ( allowEmpty || !prop.def ) ? null : prop.def;
  1265. }
  1266. // ~~ is an short way of doing floor for positive numbers
  1267. value = type.floor ? ~~value : parseFloat( value );
  1268. // IE will pass in empty strings as value for alpha,
  1269. // which will hit this case
  1270. if ( isNaN( value ) ) {
  1271. return prop.def;
  1272. }
  1273. if ( type.mod ) {
  1274. // We add mod before modding to make sure that negatives values
  1275. // get converted properly: -10 -> 350
  1276. return ( value + type.mod ) % type.mod;
  1277. }
  1278. // For now all property types without mod have min and max
  1279. return 0 > value ? 0 : type.max < value ? type.max : value;
  1280. }
  1281. function stringParse( string ) {
  1282. var inst = color(),
  1283. rgba = inst._rgba = [];
  1284. string = string.toLowerCase();
  1285. each( stringParsers, function( i, parser ) {
  1286. var parsed,
  1287. match = parser.re.exec( string ),
  1288. values = match && parser.parse( match ),
  1289. spaceName = parser.space || "rgba";
  1290. if ( values ) {
  1291. parsed = inst[ spaceName ]( values );
  1292. // If this was an rgba parse the assignment might happen twice
  1293. // oh well....
  1294. inst[ spaces[ spaceName ].cache ] = parsed[ spaces[ spaceName ].cache ];
  1295. rgba = inst._rgba = parsed._rgba;
  1296. // Exit each( stringParsers ) here because we matched
  1297. return false;
  1298. }
  1299. } );
  1300. // Found a stringParser that handled it
  1301. if ( rgba.length ) {
  1302. // If this came from a parsed string, force "transparent" when alpha is 0
  1303. // chrome, (and maybe others) return "transparent" as rgba(0,0,0,0)
  1304. if ( rgba.join() === "0,0,0,0" ) {
  1305. jQuery.extend( rgba, colors.transparent );
  1306. }
  1307. return inst;
  1308. }
  1309. // Named colors
  1310. return colors[ string ];
  1311. }
  1312. color.fn = jQuery.extend( color.prototype, {
  1313. parse: function( red, green, blue, alpha ) {
  1314. if ( red === undefined ) {
  1315. this._rgba = [ null, null, null, null ];
  1316. return this;
  1317. }
  1318. if ( red.jquery || red.nodeType ) {
  1319. red = jQuery( red ).css( green );
  1320. green = undefined;
  1321. }
  1322. var inst = this,
  1323. type = jQuery.type( red ),
  1324. rgba = this._rgba = [];
  1325. // More than 1 argument specified - assume ( red, green, blue, alpha )
  1326. if ( green !== undefined ) {
  1327. red = [ red, green, blue, alpha ];
  1328. type = "array";
  1329. }
  1330. if ( type === "string" ) {
  1331. return this.parse( stringParse( red ) || colors._default );
  1332. }
  1333. if ( type === "array" ) {
  1334. each( spaces.rgba.props, function( key, prop ) {
  1335. rgba[ prop.idx ] = clamp( red[ prop.idx ], prop );
  1336. } );
  1337. return this;
  1338. }
  1339. if ( type === "object" ) {
  1340. if ( red instanceof color ) {
  1341. each( spaces, function( spaceName, space ) {
  1342. if ( red[ space.cache ] ) {
  1343. inst[ space.cache ] = red[ space.cache ].slice();
  1344. }
  1345. } );
  1346. } else {
  1347. each( spaces, function( spaceName, space ) {
  1348. var cache = space.cache;
  1349. each( space.props, function( key, prop ) {
  1350. // If the cache doesn't exist, and we know how to convert
  1351. if ( !inst[ cache ] && space.to ) {
  1352. // If the value was null, we don't need to copy it
  1353. // if the key was alpha, we don't need to copy it either
  1354. if ( key === "alpha" || red[ key ] == null ) {
  1355. return;
  1356. }
  1357. inst[ cache ] = space.to( inst._rgba );
  1358. }
  1359. // This is the only case where we allow nulls for ALL properties.
  1360. // call clamp with alwaysAllowEmpty
  1361. inst[ cache ][ prop.idx ] = clamp( red[ key ], prop, true );
  1362. } );
  1363. // Everything defined but alpha?
  1364. if ( inst[ cache ] &&
  1365. jQuery.inArray( null, inst[ cache ].slice( 0, 3 ) ) < 0 ) {
  1366. // Use the default of 1
  1367. inst[ cache ][ 3 ] = 1;
  1368. if ( space.from ) {
  1369. inst._rgba = space.from( inst[ cache ] );
  1370. }
  1371. }
  1372. } );
  1373. }
  1374. return this;
  1375. }
  1376. },
  1377. is: function( compare ) {
  1378. var is = color( compare ),
  1379. same = true,
  1380. inst = this;
  1381. each( spaces, function( _, space ) {
  1382. var localCache,
  1383. isCache = is[ space.cache ];
  1384. if ( isCache ) {
  1385. localCache = inst[ space.cache ] || space.to && space.to( inst._rgba ) || [];
  1386. each( space.props, function( _, prop ) {
  1387. if ( isCache[ prop.idx ] != null ) {
  1388. same = ( isCache[ prop.idx ] === localCache[ prop.idx ] );
  1389. return same;
  1390. }
  1391. } );
  1392. }
  1393. return same;
  1394. } );
  1395. return same;
  1396. },
  1397. _space: function() {
  1398. var used = [],
  1399. inst = this;
  1400. each( spaces, function( spaceName, space ) {
  1401. if ( inst[ space.cache ] ) {
  1402. used.push( spaceName );
  1403. }
  1404. } );
  1405. return used.pop();
  1406. },
  1407. transition: function( other, distance ) {
  1408. var end = color( other ),
  1409. spaceName = end._space(),
  1410. space = spaces[ spaceName ],
  1411. startColor = this.alpha() === 0 ? color( "transparent" ) : this,
  1412. start = startColor[ space.cache ] || space.to( startColor._rgba ),
  1413. result = start.slice();
  1414. end = end[ space.cache ];
  1415. each( space.props, function( key, prop ) {
  1416. var index = prop.idx,
  1417. startValue = start[ index ],
  1418. endValue = end[ index ],
  1419. type = propTypes[ prop.type ] || {};
  1420. // If null, don't override start value
  1421. if ( endValue === null ) {
  1422. return;
  1423. }
  1424. // If null - use end
  1425. if ( startValue === null ) {
  1426. result[ index ] = endValue;
  1427. } else {
  1428. if ( type.mod ) {
  1429. if ( endValue - startValue > type.mod / 2 ) {
  1430. startValue += type.mod;
  1431. } else if ( startValue - endValue > type.mod / 2 ) {
  1432. startValue -= type.mod;
  1433. }
  1434. }
  1435. result[ index ] = clamp( ( endValue - startValue ) * distance + startValue, prop );
  1436. }
  1437. } );
  1438. return this[ spaceName ]( result );
  1439. },
  1440. blend: function( opaque ) {
  1441. // If we are already opaque - return ourself
  1442. if ( this._rgba[ 3 ] === 1 ) {
  1443. return this;
  1444. }
  1445. var rgb = this._rgba.slice(),
  1446. a = rgb.pop(),
  1447. blend = color( opaque )._rgba;
  1448. return color( jQuery.map( rgb, function( v, i ) {
  1449. return ( 1 - a ) * blend[ i ] + a * v;
  1450. } ) );
  1451. },
  1452. toRgbaString: function() {
  1453. var prefix = "rgba(",
  1454. rgba = jQuery.map( this._rgba, function( v, i ) {
  1455. return v == null ? ( i > 2 ? 1 : 0 ) : v;
  1456. } );
  1457. if ( rgba[ 3 ] === 1 ) {
  1458. rgba.pop();
  1459. prefix = "rgb(";
  1460. }
  1461. return prefix + rgba.join() + ")";
  1462. },
  1463. toHslaString: function() {
  1464. var prefix = "hsla(",
  1465. hsla = jQuery.map( this.hsla(), function( v, i ) {
  1466. if ( v == null ) {
  1467. v = i > 2 ? 1 : 0;
  1468. }
  1469. // Catch 1 and 2
  1470. if ( i && i < 3 ) {
  1471. v = Math.round( v * 100 ) + "%";
  1472. }
  1473. return v;
  1474. } );
  1475. if ( hsla[ 3 ] === 1 ) {
  1476. hsla.pop();
  1477. prefix = "hsl(";
  1478. }
  1479. return prefix + hsla.join() + ")";
  1480. },
  1481. toHexString: function( includeAlpha ) {
  1482. var rgba = this._rgba.slice(),
  1483. alpha = rgba.pop();
  1484. if ( includeAlpha ) {
  1485. rgba.push( ~~( alpha * 255 ) );
  1486. }
  1487. return "#" + jQuery.map( rgba, function( v ) {
  1488. // Default to 0 when nulls exist
  1489. v = ( v || 0 ).toString( 16 );
  1490. return v.length === 1 ? "0" + v : v;
  1491. } ).join( "" );
  1492. },
  1493. toString: function() {
  1494. return this._rgba[ 3 ] === 0 ? "transparent" : this.toRgbaString();
  1495. }
  1496. } );
  1497. color.fn.parse.prototype = color.fn;
  1498. // Hsla conversions adapted from:
  1499. // https://code.google.com/p/maashaack/source/browse/packages/graphics/trunk/src/graphics/colors/HUE2RGB.as?r=5021
  1500. function hue2rgb( p, q, h ) {
  1501. h = ( h + 1 ) % 1;
  1502. if ( h * 6 < 1 ) {
  1503. return p + ( q - p ) * h * 6;
  1504. }
  1505. if ( h * 2 < 1 ) {
  1506. return q;
  1507. }
  1508. if ( h * 3 < 2 ) {
  1509. return p + ( q - p ) * ( ( 2 / 3 ) - h ) * 6;
  1510. }
  1511. return p;
  1512. }
  1513. spaces.hsla.to = function( rgba ) {
  1514. if ( rgba[ 0 ] == null || rgba[ 1 ] == null || rgba[ 2 ] == null ) {
  1515. return [ null, null, null, rgba[ 3 ] ];
  1516. }
  1517. var r = rgba[ 0 ] / 255,
  1518. g = rgba[ 1 ] / 255,
  1519. b = rgba[ 2 ] / 255,
  1520. a = rgba[ 3 ],
  1521. max = Math.max( r, g, b ),
  1522. min = Math.min( r, g, b ),
  1523. diff = max - min,
  1524. add = max + min,
  1525. l = add * 0.5,
  1526. h, s;
  1527. if ( min === max ) {
  1528. h = 0;
  1529. } else if ( r === max ) {
  1530. h = ( 60 * ( g - b ) / diff ) + 360;
  1531. } else if ( g === max ) {
  1532. h = ( 60 * ( b - r ) / diff ) + 120;
  1533. } else {
  1534. h = ( 60 * ( r - g ) / diff ) + 240;
  1535. }
  1536. // Chroma (diff) == 0 means greyscale which, by definition, saturation = 0%
  1537. // otherwise, saturation is based on the ratio of chroma (diff) to lightness (add)
  1538. if ( diff === 0 ) {
  1539. s = 0;
  1540. } else if ( l <= 0.5 ) {
  1541. s = diff / add;
  1542. } else {
  1543. s = diff / ( 2 - add );
  1544. }
  1545. return [ Math.round( h ) % 360, s, l, a == null ? 1 : a ];
  1546. };
  1547. spaces.hsla.from = function( hsla ) {
  1548. if ( hsla[ 0 ] == null || hsla[ 1 ] == null || hsla[ 2 ] == null ) {
  1549. return [ null, null, null, hsla[ 3 ] ];
  1550. }
  1551. var h = hsla[ 0 ] / 360,
  1552. s = hsla[ 1 ],
  1553. l = hsla[ 2 ],
  1554. a = hsla[ 3 ],
  1555. q = l <= 0.5 ? l * ( 1 + s ) : l + s - l * s,
  1556. p = 2 * l - q;
  1557. return [
  1558. Math.round( hue2rgb( p, q, h + ( 1 / 3 ) ) * 255 ),
  1559. Math.round( hue2rgb( p, q, h ) * 255 ),
  1560. Math.round( hue2rgb( p, q, h - ( 1 / 3 ) ) * 255 ),
  1561. a
  1562. ];
  1563. };
  1564. each( spaces, function( spaceName, space ) {
  1565. var props = space.props,
  1566. cache = space.cache,
  1567. to = space.to,
  1568. from = space.from;
  1569. // Makes rgba() and hsla()
  1570. color.fn[ spaceName ] = function( value ) {
  1571. // Generate a cache for this space if it doesn't exist
  1572. if ( to && !this[ cache ] ) {
  1573. this[ cache ] = to( this._rgba );
  1574. }
  1575. if ( value === undefined ) {
  1576. return this[ cache ].slice();
  1577. }
  1578. var ret,
  1579. type = jQuery.type( value ),
  1580. arr = ( type === "array" || type === "object" ) ? value : arguments,
  1581. local = this[ cache ].slice();
  1582. each( props, function( key, prop ) {
  1583. var val = arr[ type === "object" ? key : prop.idx ];
  1584. if ( val == null ) {
  1585. val = local[ prop.idx ];
  1586. }
  1587. local[ prop.idx ] = clamp( val, prop );
  1588. } );
  1589. if ( from ) {
  1590. ret = color( from( local ) );
  1591. ret[ cache ] = local;
  1592. return ret;
  1593. } else {
  1594. return color( local );
  1595. }
  1596. };
  1597. // Makes red() green() blue() alpha() hue() saturation() lightness()
  1598. each( props, function( key, prop ) {
  1599. // Alpha is included in more than one space
  1600. if ( color.fn[ key ] ) {
  1601. return;
  1602. }
  1603. color.fn[ key ] = function( value ) {
  1604. var vtype = jQuery.type( value ),
  1605. fn = ( key === "alpha" ? ( this._hsla ? "hsla" : "rgba" ) : spaceName ),
  1606. local = this[ fn ](),
  1607. cur = local[ prop.idx ],
  1608. match;
  1609. if ( vtype === "undefined" ) {
  1610. return cur;
  1611. }
  1612. if ( vtype === "function" ) {
  1613. value = value.call( this, cur );
  1614. vtype = jQuery.type( value );
  1615. }
  1616. if ( value == null && prop.empty ) {
  1617. return this;
  1618. }
  1619. if ( vtype === "string" ) {
  1620. match = rplusequals.exec( value );
  1621. if ( match ) {
  1622. value = cur + parseFloat( match[ 2 ] ) * ( match[ 1 ] === "+" ? 1 : -1 );
  1623. }
  1624. }
  1625. local[ prop.idx ] = value;
  1626. return this[ fn ]( local );
  1627. };
  1628. } );
  1629. } );
  1630. // Add cssHook and .fx.step function for each named hook.
  1631. // accept a space separated string of properties
  1632. color.hook = function( hook ) {
  1633. var hooks = hook.split( " " );
  1634. each( hooks, function( i, hook ) {
  1635. jQuery.cssHooks[ hook ] = {
  1636. set: function( elem, value ) {
  1637. var parsed, curElem,
  1638. backgroundColor = "";
  1639. if ( value !== "transparent" && ( jQuery.type( value ) !== "string" ||
  1640. ( parsed = stringParse( value ) ) ) ) {
  1641. value = color( parsed || value );
  1642. if ( !support.rgba && value._rgba[ 3 ] !== 1 ) {
  1643. curElem = hook === "backgroundColor" ? elem.parentNode : elem;
  1644. while (
  1645. ( backgroundColor === "" || backgroundColor === "transparent" ) &&
  1646. curElem && curElem.style
  1647. ) {
  1648. try {
  1649. backgroundColor = jQuery.css( curElem, "backgroundColor" );
  1650. curElem = curElem.parentNode;
  1651. } catch ( e ) {
  1652. }
  1653. }
  1654. value = value.blend( backgroundColor && backgroundColor !== "transparent" ?
  1655. backgroundColor :
  1656. "_default" );
  1657. }
  1658. value = value.toRgbaString();
  1659. }
  1660. try {
  1661. elem.style[ hook ] = value;
  1662. } catch ( e ) {
  1663. // Wrapped to prevent IE from throwing errors on "invalid" values like
  1664. // 'auto' or 'inherit'
  1665. }
  1666. }
  1667. };
  1668. jQuery.fx.step[ hook ] = function( fx ) {
  1669. if ( !fx.colorInit ) {
  1670. fx.start = color( fx.elem, hook );
  1671. fx.end = color( fx.end );
  1672. fx.colorInit = true;
  1673. }
  1674. jQuery.cssHooks[ hook ].set( fx.elem, fx.start.transition( fx.end, fx.pos ) );
  1675. };
  1676. } );
  1677. };
  1678. color.hook( stepHooks );
  1679. jQuery.cssHooks.borderColor = {
  1680. expand: function( value ) {
  1681. var expanded = {};
  1682. each( [ "Top", "Right", "Bottom", "Left" ], function( i, part ) {
  1683. expanded[ "border" + part + "Color" ] = value;
  1684. } );
  1685. return expanded;
  1686. }
  1687. };
  1688. // Basic color names only.
  1689. // Usage of any of the other color names requires adding yourself or including
  1690. // jquery.color.svg-names.js.
  1691. colors = jQuery.Color.names = {
  1692. // 4.1. Basic color keywords
  1693. aqua: "#00ffff",
  1694. black: "#000000",
  1695. blue: "#0000ff",
  1696. fuchsia: "#ff00ff",
  1697. gray: "#808080",
  1698. green: "#008000",
  1699. lime: "#00ff00",
  1700. maroon: "#800000",
  1701. navy: "#000080",
  1702. olive: "#808000",
  1703. purple: "#800080",
  1704. red: "#ff0000",
  1705. silver: "#c0c0c0",
  1706. teal: "#008080",
  1707. white: "#ffffff",
  1708. yellow: "#ffff00",
  1709. // 4.2.3. "transparent" color keyword
  1710. transparent: [ null, null, null, 0 ],
  1711. _default: "#ffffff"
  1712. };
  1713. } )( jQuery );
  1714. /******************************************************************************/
  1715. /****************************** CLASS ANIMATIONS ******************************/
  1716. /******************************************************************************/
  1717. ( function() {
  1718. var classAnimationActions = [ "add", "remove", "toggle" ],
  1719. shorthandStyles = {
  1720. border: 1,
  1721. borderBottom: 1,
  1722. borderColor: 1,
  1723. borderLeft: 1,
  1724. borderRight: 1,
  1725. borderTop: 1,
  1726. borderWidth: 1,
  1727. margin: 1,
  1728. padding: 1
  1729. };
  1730. $.each(
  1731. [ "borderLeftStyle", "borderRightStyle", "borderBottomStyle", "borderTopStyle" ],
  1732. function( _, prop ) {
  1733. $.fx.step[ prop ] = function( fx ) {
  1734. if ( fx.end !== "none" && !fx.setAttr || fx.pos === 1 && !fx.setAttr ) {
  1735. jQuery.style( fx.elem, prop, fx.end );
  1736. fx.setAttr = true;
  1737. }
  1738. };
  1739. }
  1740. );
  1741. function getElementStyles( elem ) {
  1742. var key, len,
  1743. style = elem.ownerDocument.defaultView ?
  1744. elem.ownerDocument.defaultView.getComputedStyle( elem, null ) :
  1745. elem.currentStyle,
  1746. styles = {};
  1747. if ( style && style.length && style[ 0 ] && style[ style[ 0 ] ] ) {
  1748. len = style.length;
  1749. while ( len-- ) {
  1750. key = style[ len ];
  1751. if ( typeof style[ key ] === "string" ) {
  1752. styles[ $.camelCase( key ) ] = style[ key ];
  1753. }
  1754. }
  1755. // Support: Opera, IE <9
  1756. } else {
  1757. for ( key in style ) {
  1758. if ( typeof style[ key ] === "string" ) {
  1759. styles[ key ] = style[ key ];
  1760. }
  1761. }
  1762. }
  1763. return styles;
  1764. }
  1765. function styleDifference( oldStyle, newStyle ) {
  1766. var diff = {},
  1767. name, value;
  1768. for ( name in newStyle ) {
  1769. value = newStyle[ name ];
  1770. if ( oldStyle[ name ] !== value ) {
  1771. if ( !shorthandStyles[ name ] ) {
  1772. if ( $.fx.step[ name ] || !isNaN( parseFloat( value ) ) ) {
  1773. diff[ name ] = value;
  1774. }
  1775. }
  1776. }
  1777. }
  1778. return diff;
  1779. }
  1780. // Support: jQuery <1.8
  1781. if ( !$.fn.addBack ) {
  1782. $.fn.addBack = function( selector ) {
  1783. return this.add( selector == null ?
  1784. this.prevObject : this.prevObject.filter( selector )
  1785. );
  1786. };
  1787. }
  1788. $.effects.animateClass = function( value, duration, easing, callback ) {
  1789. var o = $.speed( duration, easing, callback );
  1790. return this.queue( function() {
  1791. var animated = $( this ),
  1792. baseClass = animated.attr( "class" ) || "",
  1793. applyClassChange,
  1794. allAnimations = o.children ? animated.find( "*" ).addBack() : animated;
  1795. // Map the animated objects to store the original styles.
  1796. allAnimations = allAnimations.map( function() {
  1797. var el = $( this );
  1798. return {
  1799. el: el,
  1800. start: getElementStyles( this )
  1801. };
  1802. } );
  1803. // Apply class change
  1804. applyClassChange = function() {
  1805. $.each( classAnimationActions, function( i, action ) {
  1806. if ( value[ action ] ) {
  1807. animated[ action + "Class" ]( value[ action ] );
  1808. }
  1809. } );
  1810. };
  1811. applyClassChange();
  1812. // Map all animated objects again - calculate new styles and diff
  1813. allAnimations = allAnimations.map( function() {
  1814. this.end = getElementStyles( this.el[ 0 ] );
  1815. this.diff = styleDifference( this.start, this.end );
  1816. return this;
  1817. } );
  1818. // Apply original class
  1819. animated.attr( "class", baseClass );
  1820. // Map all animated objects again - this time collecting a promise
  1821. allAnimations = allAnimations.map( function() {
  1822. var styleInfo = this,
  1823. dfd = $.Deferred(),
  1824. opts = $.extend( {}, o, {
  1825. queue: false,
  1826. complete: function() {
  1827. dfd.resolve( styleInfo );
  1828. }
  1829. } );
  1830. this.el.animate( this.diff, opts );
  1831. return dfd.promise();
  1832. } );
  1833. // Once all animations have completed:
  1834. $.when.apply( $, allAnimations.get() ).done( function() {
  1835. // Set the final class
  1836. applyClassChange();
  1837. // For each animated element,
  1838. // clear all css properties that were animated
  1839. $.each( arguments, function() {
  1840. var el = this.el;
  1841. $.each( this.diff, function( key ) {
  1842. el.css( key, "" );
  1843. } );
  1844. } );
  1845. // This is guarnteed to be there if you use jQuery.speed()
  1846. // it also handles dequeuing the next anim...
  1847. o.complete.call( animated[ 0 ] );
  1848. } );
  1849. } );
  1850. };
  1851. $.fn.extend( {
  1852. addClass: ( function( orig ) {
  1853. return function( classNames, speed, easing, callback ) {
  1854. return speed ?
  1855. $.effects.animateClass.call( this,
  1856. { add: classNames }, speed, easing, callback ) :
  1857. orig.apply( this, arguments );
  1858. };
  1859. } )( $.fn.addClass ),
  1860. removeClass: ( function( orig ) {
  1861. return function( classNames, speed, easing, callback ) {
  1862. return arguments.length > 1 ?
  1863. $.effects.animateClass.call( this,
  1864. { remove: classNames }, speed, easing, callback ) :
  1865. orig.apply( this, arguments );
  1866. };
  1867. } )( $.fn.removeClass ),
  1868. toggleClass: ( function( orig ) {
  1869. return function( classNames, force, speed, easing, callback ) {
  1870. if ( typeof force === "boolean" || force === undefined ) {
  1871. if ( !speed ) {
  1872. // Without speed parameter
  1873. return orig.apply( this, arguments );
  1874. } else {
  1875. return $.effects.animateClass.call( this,
  1876. ( force ? { add: classNames } : { remove: classNames } ),
  1877. speed, easing, callback );
  1878. }
  1879. } else {
  1880. // Without force parameter
  1881. return $.effects.animateClass.call( this,
  1882. { toggle: classNames }, force, speed, easing );
  1883. }
  1884. };
  1885. } )( $.fn.toggleClass ),
  1886. switchClass: function( remove, add, speed, easing, callback ) {
  1887. return $.effects.animateClass.call( this, {
  1888. add: add,
  1889. remove: remove
  1890. }, speed, easing, callback );
  1891. }
  1892. } );
  1893. } )();
  1894. /******************************************************************************/
  1895. /*********************************** EFFECTS **********************************/
  1896. /******************************************************************************/
  1897. ( function() {
  1898. if ( $.expr && $.expr.filters && $.expr.filters.animated ) {
  1899. $.expr.filters.animated = ( function( orig ) {
  1900. return function( elem ) {
  1901. return !!$( elem ).data( dataSpaceAnimated ) || orig( elem );
  1902. };
  1903. } )( $.expr.filters.animated );
  1904. }
  1905. if ( $.uiBackCompat !== false ) {
  1906. $.extend( $.effects, {
  1907. // Saves a set of properties in a data storage
  1908. save: function( element, set ) {
  1909. var i = 0, length = set.length;
  1910. for ( ; i < length; i++ ) {
  1911. if ( set[ i ] !== null ) {
  1912. element.data( dataSpace + set[ i ], element[ 0 ].style[ set[ i ] ] );
  1913. }
  1914. }
  1915. },
  1916. // Restores a set of previously saved properties from a data storage
  1917. restore: function( element, set ) {
  1918. var val, i = 0, length = set.length;
  1919. for ( ; i < length; i++ ) {
  1920. if ( set[ i ] !== null ) {
  1921. val = element.data( dataSpace + set[ i ] );
  1922. element.css( set[ i ], val );
  1923. }
  1924. }
  1925. },
  1926. setMode: function( el, mode ) {
  1927. if ( mode === "toggle" ) {
  1928. mode = el.is( ":hidden" ) ? "show" : "hide";
  1929. }
  1930. return mode;
  1931. },
  1932. // Wraps the element around a wrapper that copies position properties
  1933. createWrapper: function( element ) {
  1934. // If the element is already wrapped, return it
  1935. if ( element.parent().is( ".ui-effects-wrapper" ) ) {
  1936. return element.parent();
  1937. }
  1938. // Wrap the element
  1939. var props = {
  1940. width: element.outerWidth( true ),
  1941. height: element.outerHeight( true ),
  1942. "float": element.css( "float" )
  1943. },
  1944. wrapper = $( "<div></div>" )
  1945. .addClass( "ui-effects-wrapper" )
  1946. .css( {
  1947. fontSize: "100%",
  1948. background: "transparent",
  1949. border: "none",
  1950. margin: 0,
  1951. padding: 0
  1952. } ),
  1953. // Store the size in case width/height are defined in % - Fixes #5245
  1954. size = {
  1955. width: element.width(),
  1956. height: element.height()
  1957. },
  1958. active = document.activeElement;
  1959. // Support: Firefox
  1960. // Firefox incorrectly exposes anonymous content
  1961. // https://bugzilla.mozilla.org/show_bug.cgi?id=561664
  1962. try {
  1963. active.id;
  1964. } catch ( e ) {
  1965. active = document.body;
  1966. }
  1967. element.wrap( wrapper );
  1968. // Fixes #7595 - Elements lose focus when wrapped.
  1969. if ( element[ 0 ] === active || $.contains( element[ 0 ], active ) ) {
  1970. $( active ).trigger( "focus" );
  1971. }
  1972. // Hotfix for jQuery 1.4 since some change in wrap() seems to actually
  1973. // lose the reference to the wrapped element
  1974. wrapper = element.parent();
  1975. // Transfer positioning properties to the wrapper
  1976. if ( element.css( "position" ) === "static" ) {
  1977. wrapper.css( { position: "relative" } );
  1978. element.css( { position: "relative" } );
  1979. } else {
  1980. $.extend( props, {
  1981. position: element.css( "position" ),
  1982. zIndex: element.css( "z-index" )
  1983. } );
  1984. $.each( [ "top", "left", "bottom", "right" ], function( i, pos ) {
  1985. props[ pos ] = element.css( pos );
  1986. if ( isNaN( parseInt( props[ pos ], 10 ) ) ) {
  1987. props[ pos ] = "auto";
  1988. }
  1989. } );
  1990. element.css( {
  1991. position: "relative",
  1992. top: 0,
  1993. left: 0,
  1994. right: "auto",
  1995. bottom: "auto"
  1996. } );
  1997. }
  1998. element.css( size );
  1999. return wrapper.css( props ).show();
  2000. },
  2001. removeWrapper: function( element ) {
  2002. var active = document.activeElement;
  2003. if ( element.parent().is( ".ui-effects-wrapper" ) ) {
  2004. element.parent().replaceWith( element );
  2005. // Fixes #7595 - Elements lose focus when wrapped.
  2006. if ( element[ 0 ] === active || $.contains( element[ 0 ], active ) ) {
  2007. $( active ).trigger( "focus" );
  2008. }
  2009. }
  2010. return element;
  2011. }
  2012. } );
  2013. }
  2014. $.extend( $.effects, {
  2015. version: "1.12.0",
  2016. define: function( name, mode, effect ) {
  2017. if ( !effect ) {
  2018. effect = mode;
  2019. mode = "effect";
  2020. }
  2021. $.effects.effect[ name ] = effect;
  2022. $.effects.effect[ name ].mode = mode;
  2023. return effect;
  2024. },
  2025. scaledDimensions: function( element, percent, direction ) {
  2026. if ( percent === 0 ) {
  2027. return {
  2028. height: 0,
  2029. width: 0,
  2030. outerHeight: 0,
  2031. outerWidth: 0
  2032. };
  2033. }
  2034. var x = direction !== "horizontal" ? ( ( percent || 100 ) / 100 ) : 1,
  2035. y = direction !== "vertical" ? ( ( percent || 100 ) / 100 ) : 1;
  2036. return {
  2037. height: element.height() * y,
  2038. width: element.width() * x,
  2039. outerHeight: element.outerHeight() * y,
  2040. outerWidth: element.outerWidth() * x
  2041. };
  2042. },
  2043. clipToBox: function( animation ) {
  2044. return {
  2045. width: animation.clip.right - animation.clip.left,
  2046. height: animation.clip.bottom - animation.clip.top,
  2047. left: animation.clip.left,
  2048. top: animation.clip.top
  2049. };
  2050. },
  2051. // Injects recently queued functions to be first in line (after "inprogress")
  2052. unshift: function( element, queueLength, count ) {
  2053. var queue = element.queue();
  2054. if ( queueLength > 1 ) {
  2055. queue.splice.apply( queue,
  2056. [ 1, 0 ].concat( queue.splice( queueLength, count ) ) );
  2057. }
  2058. element.dequeue();
  2059. },
  2060. saveStyle: function( element ) {
  2061. element.data( dataSpaceStyle, element[ 0 ].style.cssText );
  2062. },
  2063. restoreStyle: function( element ) {
  2064. element[ 0 ].style.cssText = element.data( dataSpaceStyle ) || "";
  2065. element.removeData( dataSpaceStyle );
  2066. },
  2067. mode: function( element, mode ) {
  2068. var hidden = element.is( ":hidden" );
  2069. if ( mode === "toggle" ) {
  2070. mode = hidden ? "show" : "hide";
  2071. }
  2072. if ( hidden ? mode === "hide" : mode === "show" ) {
  2073. mode = "none";
  2074. }
  2075. return mode;
  2076. },
  2077. // Translates a [top,left] array into a baseline value
  2078. getBaseline: function( origin, original ) {
  2079. var y, x;
  2080. switch ( origin[ 0 ] ) {
  2081. case "top":
  2082. y = 0;
  2083. break;
  2084. case "middle":
  2085. y = 0.5;
  2086. break;
  2087. case "bottom":
  2088. y = 1;
  2089. break;
  2090. default:
  2091. y = origin[ 0 ] / original.height;
  2092. }
  2093. switch ( origin[ 1 ] ) {
  2094. case "left":
  2095. x = 0;
  2096. break;
  2097. case "center":
  2098. x = 0.5;
  2099. break;
  2100. case "right":
  2101. x = 1;
  2102. break;
  2103. default:
  2104. x = origin[ 1 ] / original.width;
  2105. }
  2106. return {
  2107. x: x,
  2108. y: y
  2109. };
  2110. },
  2111. // Creates a placeholder element so that the original element can be made absolute
  2112. createPlaceholder: function( element ) {
  2113. var placeholder,
  2114. cssPosition = element.css( "position" ),
  2115. position = element.position();
  2116. // Lock in margins first to account for form elements, which
  2117. // will change margin if you explicitly set height
  2118. // see: http://jsfiddle.net/JZSMt/3/ https://bugs.webkit.org/show_bug.cgi?id=107380
  2119. // Support: Safari
  2120. element.css( {
  2121. marginTop: element.css( "marginTop" ),
  2122. marginBottom: element.css( "marginBottom" ),
  2123. marginLeft: element.css( "marginLeft" ),
  2124. marginRight: element.css( "marginRight" )
  2125. } )
  2126. .outerWidth( element.outerWidth() )
  2127. .outerHeight( element.outerHeight() );
  2128. if ( /^(static|relative)/.test( cssPosition ) ) {
  2129. cssPosition = "absolute";
  2130. placeholder = $( "<" + element[ 0 ].nodeName + ">" ).insertAfter( element ).css( {
  2131. // Convert inline to inline block to account for inline elements
  2132. // that turn to inline block based on content (like img)
  2133. display: /^(inline|ruby)/.test( element.css( "display" ) ) ?
  2134. "inline-block" :
  2135. "block",
  2136. visibility: "hidden",
  2137. // Margins need to be set to account for margin collapse
  2138. marginTop: element.css( "marginTop" ),
  2139. marginBottom: element.css( "marginBottom" ),
  2140. marginLeft: element.css( "marginLeft" ),
  2141. marginRight: element.css( "marginRight" ),
  2142. "float": element.css( "float" )
  2143. } )
  2144. .outerWidth( element.outerWidth() )
  2145. .outerHeight( element.outerHeight() )
  2146. .addClass( "ui-effects-placeholder" );
  2147. element.data( dataSpace + "placeholder", placeholder );
  2148. }
  2149. element.css( {
  2150. position: cssPosition,
  2151. left: position.left,
  2152. top: position.top
  2153. } );
  2154. return placeholder;
  2155. },
  2156. removePlaceholder: function( element ) {
  2157. var dataKey = dataSpace + "placeholder",
  2158. placeholder = element.data( dataKey );
  2159. if ( placeholder ) {
  2160. placeholder.remove();
  2161. element.removeData( dataKey );
  2162. }
  2163. },
  2164. // Removes a placeholder if it exists and restores
  2165. // properties that were modified during placeholder creation
  2166. cleanUp: function( element ) {
  2167. $.effects.restoreStyle( element );
  2168. $.effects.removePlaceholder( element );
  2169. },
  2170. setTransition: function( element, list, factor, value ) {
  2171. value = value || {};
  2172. $.each( list, function( i, x ) {
  2173. var unit = element.cssUnit( x );
  2174. if ( unit[ 0 ] > 0 ) {
  2175. value[ x ] = unit[ 0 ] * factor + unit[ 1 ];
  2176. }
  2177. } );
  2178. return value;
  2179. }
  2180. } );
  2181. // Return an effect options object for the given parameters:
  2182. function _normalizeArguments( effect, options, speed, callback ) {
  2183. // Allow passing all options as the first parameter
  2184. if ( $.isPlainObject( effect ) ) {
  2185. options = effect;
  2186. effect = effect.effect;
  2187. }
  2188. // Convert to an object
  2189. effect = { effect: effect };
  2190. // Catch (effect, null, ...)
  2191. if ( options == null ) {
  2192. options = {};
  2193. }
  2194. // Catch (effect, callback)
  2195. if ( $.isFunction( options ) ) {
  2196. callback = options;
  2197. speed = null;
  2198. options = {};
  2199. }
  2200. // Catch (effect, speed, ?)
  2201. if ( typeof options === "number" || $.fx.speeds[ options ] ) {
  2202. callback = speed;
  2203. speed = options;
  2204. options = {};
  2205. }
  2206. // Catch (effect, options, callback)
  2207. if ( $.isFunction( speed ) ) {
  2208. callback = speed;
  2209. speed = null;
  2210. }
  2211. // Add options to effect
  2212. if ( options ) {
  2213. $.extend( effect, options );
  2214. }
  2215. speed = speed || options.duration;
  2216. effect.duration = $.fx.off ? 0 :
  2217. typeof speed === "number" ? speed :
  2218. speed in $.fx.speeds ? $.fx.speeds[ speed ] :
  2219. $.fx.speeds._default;
  2220. effect.complete = callback || options.complete;
  2221. return effect;
  2222. }
  2223. function standardAnimationOption( option ) {
  2224. // Valid standard speeds (nothing, number, named speed)
  2225. if ( !option || typeof option === "number" || $.fx.speeds[ option ] ) {
  2226. return true;
  2227. }
  2228. // Invalid strings - treat as "normal" speed
  2229. if ( typeof option === "string" && !$.effects.effect[ option ] ) {
  2230. return true;
  2231. }
  2232. // Complete callback
  2233. if ( $.isFunction( option ) ) {
  2234. return true;
  2235. }
  2236. // Options hash (but not naming an effect)
  2237. if ( typeof option === "object" && !option.effect ) {
  2238. return true;
  2239. }
  2240. // Didn't match any standard API
  2241. return false;
  2242. }
  2243. $.fn.extend( {
  2244. effect: function( /* effect, options, speed, callback */ ) {
  2245. var args = _normalizeArguments.apply( this, arguments ),
  2246. effectMethod = $.effects.effect[ args.effect ],
  2247. defaultMode = effectMethod.mode,
  2248. queue = args.queue,
  2249. queueName = queue || "fx",
  2250. complete = args.complete,
  2251. mode = args.mode,
  2252. modes = [],
  2253. prefilter = function( next ) {
  2254. var el = $( this ),
  2255. normalizedMode = $.effects.mode( el, mode ) || defaultMode;
  2256. // Sentinel for duck-punching the :animated psuedo-selector
  2257. el.data( dataSpaceAnimated, true );
  2258. // Save effect mode for later use,
  2259. // we can't just call $.effects.mode again later,
  2260. // as the .show() below destroys the initial state
  2261. modes.push( normalizedMode );
  2262. // See $.uiBackCompat inside of run() for removal of defaultMode in 1.13
  2263. if ( defaultMode && ( normalizedMode === "show" ||
  2264. ( normalizedMode === defaultMode && normalizedMode === "hide" ) ) ) {
  2265. el.show();
  2266. }
  2267. if ( !defaultMode || normalizedMode !== "none" ) {
  2268. $.effects.saveStyle( el );
  2269. }
  2270. if ( $.isFunction( next ) ) {
  2271. next();
  2272. }
  2273. };
  2274. if ( $.fx.off || !effectMethod ) {
  2275. // Delegate to the original method (e.g., .show()) if possible
  2276. if ( mode ) {
  2277. return this[ mode ]( args.duration, complete );
  2278. } else {
  2279. return this.each( function() {
  2280. if ( complete ) {
  2281. complete.call( this );
  2282. }
  2283. } );
  2284. }
  2285. }
  2286. function run( next ) {
  2287. var elem = $( this );
  2288. function cleanup() {
  2289. elem.removeData( dataSpaceAnimated );
  2290. $.effects.cleanUp( elem );
  2291. if ( args.mode === "hide" ) {
  2292. elem.hide();
  2293. }
  2294. done();
  2295. }
  2296. function done() {
  2297. if ( $.isFunction( complete ) ) {
  2298. complete.call( elem[ 0 ] );
  2299. }
  2300. if ( $.isFunction( next ) ) {
  2301. next();
  2302. }
  2303. }
  2304. // Override mode option on a per element basis,
  2305. // as toggle can be either show or hide depending on element state
  2306. args.mode = modes.shift();
  2307. if ( $.uiBackCompat !== false && !defaultMode ) {
  2308. if ( elem.is( ":hidden" ) ? mode === "hide" : mode === "show" ) {
  2309. // Call the core method to track "olddisplay" properly
  2310. elem[ mode ]();
  2311. done();
  2312. } else {
  2313. effectMethod.call( elem[ 0 ], args, done );
  2314. }
  2315. } else {
  2316. if ( args.mode === "none" ) {
  2317. // Call the core method to track "olddisplay" properly
  2318. elem[ mode ]();
  2319. done();
  2320. } else {
  2321. effectMethod.call( elem[ 0 ], args, cleanup );
  2322. }
  2323. }
  2324. }
  2325. // Run prefilter on all elements first to ensure that
  2326. // any showing or hiding happens before placeholder creation,
  2327. // which ensures that any layout changes are correctly captured.
  2328. return queue === false ?
  2329. this.each( prefilter ).each( run ) :
  2330. this.queue( queueName, prefilter ).queue( queueName, run );
  2331. },
  2332. show: ( function( orig ) {
  2333. return function( option ) {
  2334. if ( standardAnimationOption( option ) ) {
  2335. return orig.apply( this, arguments );
  2336. } else {
  2337. var args = _normalizeArguments.apply( this, arguments );
  2338. args.mode = "show";
  2339. return this.effect.call( this, args );
  2340. }
  2341. };
  2342. } )( $.fn.show ),
  2343. hide: ( function( orig ) {
  2344. return function( option ) {
  2345. if ( standardAnimationOption( option ) ) {
  2346. return orig.apply( this, arguments );
  2347. } else {
  2348. var args = _normalizeArguments.apply( this, arguments );
  2349. args.mode = "hide";
  2350. return this.effect.call( this, args );
  2351. }
  2352. };
  2353. } )( $.fn.hide ),
  2354. toggle: ( function( orig ) {
  2355. return function( option ) {
  2356. if ( standardAnimationOption( option ) || typeof option === "boolean" ) {
  2357. return orig.apply( this, arguments );
  2358. } else {
  2359. var args = _normalizeArguments.apply( this, arguments );
  2360. args.mode = "toggle";
  2361. return this.effect.call( this, args );
  2362. }
  2363. };
  2364. } )( $.fn.toggle ),
  2365. cssUnit: function( key ) {
  2366. var style = this.css( key ),
  2367. val = [];
  2368. $.each( [ "em", "px", "%", "pt" ], function( i, unit ) {
  2369. if ( style.indexOf( unit ) > 0 ) {
  2370. val = [ parseFloat( style ), unit ];
  2371. }
  2372. } );
  2373. return val;
  2374. },
  2375. cssClip: function( clipObj ) {
  2376. if ( clipObj ) {
  2377. return this.css( "clip", "rect(" + clipObj.top + "px " + clipObj.right + "px " +
  2378. clipObj.bottom + "px " + clipObj.left + "px)" );
  2379. }
  2380. return parseClip( this.css( "clip" ), this );
  2381. },
  2382. transfer: function( options, done ) {
  2383. var element = $( this ),
  2384. target = $( options.to ),
  2385. targetFixed = target.css( "position" ) === "fixed",
  2386. body = $( "body" ),
  2387. fixTop = targetFixed ? body.scrollTop() : 0,
  2388. fixLeft = targetFixed ? body.scrollLeft() : 0,
  2389. endPosition = target.offset(),
  2390. animation = {
  2391. top: endPosition.top - fixTop,
  2392. left: endPosition.left - fixLeft,
  2393. height: target.innerHeight(),
  2394. width: target.innerWidth()
  2395. },
  2396. startPosition = element.offset(),
  2397. transfer = $( "<div class='ui-effects-transfer'></div>" )
  2398. .appendTo( "body" )
  2399. .addClass( options.className )
  2400. .css( {
  2401. top: startPosition.top - fixTop,
  2402. left: startPosition.left - fixLeft,
  2403. height: element.innerHeight(),
  2404. width: element.innerWidth(),
  2405. position: targetFixed ? "fixed" : "absolute"
  2406. } )
  2407. .animate( animation, options.duration, options.easing, function() {
  2408. transfer.remove();
  2409. if ( $.isFunction( done ) ) {
  2410. done();
  2411. }
  2412. } );
  2413. }
  2414. } );
  2415. function parseClip( str, element ) {
  2416. var outerWidth = element.outerWidth(),
  2417. outerHeight = element.outerHeight(),
  2418. 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)\)$/,
  2419. values = clipRegex.exec( str ) || [ "", 0, outerWidth, outerHeight, 0 ];
  2420. return {
  2421. top: parseFloat( values[ 1 ] ) || 0,
  2422. right: values[ 2 ] === "auto" ? outerWidth : parseFloat( values[ 2 ] ),
  2423. bottom: values[ 3 ] === "auto" ? outerHeight : parseFloat( values[ 3 ] ),
  2424. left: parseFloat( values[ 4 ] ) || 0
  2425. };
  2426. }
  2427. $.fx.step.clip = function( fx ) {
  2428. if ( !fx.clipInit ) {
  2429. fx.start = $( fx.elem ).cssClip();
  2430. if ( typeof fx.end === "string" ) {
  2431. fx.end = parseClip( fx.end, fx.elem );
  2432. }
  2433. fx.clipInit = true;
  2434. }
  2435. $( fx.elem ).cssClip( {
  2436. top: fx.pos * ( fx.end.top - fx.start.top ) + fx.start.top,
  2437. right: fx.pos * ( fx.end.right - fx.start.right ) + fx.start.right,
  2438. bottom: fx.pos * ( fx.end.bottom - fx.start.bottom ) + fx.start.bottom,
  2439. left: fx.pos * ( fx.end.left - fx.start.left ) + fx.start.left
  2440. } );
  2441. };
  2442. } )();
  2443. /******************************************************************************/
  2444. /*********************************** EASING ***********************************/
  2445. /******************************************************************************/
  2446. ( function() {
  2447. // Based on easing equations from Robert Penner (http://www.robertpenner.com/easing)
  2448. var baseEasings = {};
  2449. $.each( [ "Quad", "Cubic", "Quart", "Quint", "Expo" ], function( i, name ) {
  2450. baseEasings[ name ] = function( p ) {
  2451. return Math.pow( p, i + 2 );
  2452. };
  2453. } );
  2454. $.extend( baseEasings, {
  2455. Sine: function( p ) {
  2456. return 1 - Math.cos( p * Math.PI / 2 );
  2457. },
  2458. Circ: function( p ) {
  2459. return 1 - Math.sqrt( 1 - p * p );
  2460. },
  2461. Elastic: function( p ) {
  2462. return p === 0 || p === 1 ? p :
  2463. -Math.pow( 2, 8 * ( p - 1 ) ) * Math.sin( ( ( p - 1 ) * 80 - 7.5 ) * Math.PI / 15 );
  2464. },
  2465. Back: function( p ) {
  2466. return p * p * ( 3 * p - 2 );
  2467. },
  2468. Bounce: function( p ) {
  2469. var pow2,
  2470. bounce = 4;
  2471. while ( p < ( ( pow2 = Math.pow( 2, --bounce ) ) - 1 ) / 11 ) {}
  2472. return 1 / Math.pow( 4, 3 - bounce ) - 7.5625 * Math.pow( ( pow2 * 3 - 2 ) / 22 - p, 2 );
  2473. }
  2474. } );
  2475. $.each( baseEasings, function( name, easeIn ) {
  2476. $.easing[ "easeIn" + name ] = easeIn;
  2477. $.easing[ "easeOut" + name ] = function( p ) {
  2478. return 1 - easeIn( 1 - p );
  2479. };
  2480. $.easing[ "easeInOut" + name ] = function( p ) {
  2481. return p < 0.5 ?
  2482. easeIn( p * 2 ) / 2 :
  2483. 1 - easeIn( p * -2 + 2 ) / 2;
  2484. };
  2485. } );
  2486. } )();
  2487. var effect = $.effects;
  2488. /*!
  2489. * jQuery UI Effects Blind 1.12.0
  2490. * http://jqueryui.com
  2491. *
  2492. * Copyright jQuery Foundation and other contributors
  2493. * Released under the MIT license.
  2494. * http://jquery.org/license
  2495. */
  2496. //>>label: Blind Effect
  2497. //>>group: Effects
  2498. //>>description: Blinds the element.
  2499. //>>docs: http://api.jqueryui.com/blind-effect/
  2500. //>>demos: http://jqueryui.com/effect/
  2501. var effectsEffectBlind = $.effects.define( "blind", "hide", function( options, done ) {
  2502. var map = {
  2503. up: [ "bottom", "top" ],
  2504. vertical: [ "bottom", "top" ],
  2505. down: [ "top", "bottom" ],
  2506. left: [ "right", "left" ],
  2507. horizontal: [ "right", "left" ],
  2508. right: [ "left", "right" ]
  2509. },
  2510. element = $( this ),
  2511. direction = options.direction || "up",
  2512. start = element.cssClip(),
  2513. animate = { clip: $.extend( {}, start ) },
  2514. placeholder = $.effects.createPlaceholder( element );
  2515. animate.clip[ map[ direction ][ 0 ] ] = animate.clip[ map[ direction ][ 1 ] ];
  2516. if ( options.mode === "show" ) {
  2517. element.cssClip( animate.clip );
  2518. if ( placeholder ) {
  2519. placeholder.css( $.effects.clipToBox( animate ) );
  2520. }
  2521. animate.clip = start;
  2522. }
  2523. if ( placeholder ) {
  2524. placeholder.animate( $.effects.clipToBox( animate ), options.duration, options.easing );
  2525. }
  2526. element.animate( animate, {
  2527. queue: false,
  2528. duration: options.duration,
  2529. easing: options.easing,
  2530. complete: done
  2531. } );
  2532. } );
  2533. /*!
  2534. * jQuery UI Effects Bounce 1.12.0
  2535. * http://jqueryui.com
  2536. *
  2537. * Copyright jQuery Foundation and other contributors
  2538. * Released under the MIT license.
  2539. * http://jquery.org/license
  2540. */
  2541. //>>label: Bounce Effect
  2542. //>>group: Effects
  2543. //>>description: Bounces an element horizontally or vertically n times.
  2544. //>>docs: http://api.jqueryui.com/bounce-effect/
  2545. //>>demos: http://jqueryui.com/effect/
  2546. var effectsEffectBounce = $.effects.define( "bounce", function( options, done ) {
  2547. var upAnim, downAnim, refValue,
  2548. element = $( this ),
  2549. // Defaults:
  2550. mode = options.mode,
  2551. hide = mode === "hide",
  2552. show = mode === "show",
  2553. direction = options.direction || "up",
  2554. distance = options.distance,
  2555. times = options.times || 5,
  2556. // Number of internal animations
  2557. anims = times * 2 + ( show || hide ? 1 : 0 ),
  2558. speed = options.duration / anims,
  2559. easing = options.easing,
  2560. // Utility:
  2561. ref = ( direction === "up" || direction === "down" ) ? "top" : "left",
  2562. motion = ( direction === "up" || direction === "left" ),
  2563. i = 0,
  2564. queuelen = element.queue().length;
  2565. $.effects.createPlaceholder( element );
  2566. refValue = element.css( ref );
  2567. // Default distance for the BIGGEST bounce is the outer Distance / 3
  2568. if ( !distance ) {
  2569. distance = element[ ref === "top" ? "outerHeight" : "outerWidth" ]() / 3;
  2570. }
  2571. if ( show ) {
  2572. downAnim = { opacity: 1 };
  2573. downAnim[ ref ] = refValue;
  2574. // If we are showing, force opacity 0 and set the initial position
  2575. // then do the "first" animation
  2576. element
  2577. .css( "opacity", 0 )
  2578. .css( ref, motion ? -distance * 2 : distance * 2 )
  2579. .animate( downAnim, speed, easing );
  2580. }
  2581. // Start at the smallest distance if we are hiding
  2582. if ( hide ) {
  2583. distance = distance / Math.pow( 2, times - 1 );
  2584. }
  2585. downAnim = {};
  2586. downAnim[ ref ] = refValue;
  2587. // Bounces up/down/left/right then back to 0 -- times * 2 animations happen here
  2588. for ( ; i < times; i++ ) {
  2589. upAnim = {};
  2590. upAnim[ ref ] = ( motion ? "-=" : "+=" ) + distance;
  2591. element
  2592. .animate( upAnim, speed, easing )
  2593. .animate( downAnim, speed, easing );
  2594. distance = hide ? distance * 2 : distance / 2;
  2595. }
  2596. // Last Bounce when Hiding
  2597. if ( hide ) {
  2598. upAnim = { opacity: 0 };
  2599. upAnim[ ref ] = ( motion ? "-=" : "+=" ) + distance;
  2600. element.animate( upAnim, speed, easing );
  2601. }
  2602. element.queue( done );
  2603. $.effects.unshift( element, queuelen, anims + 1 );
  2604. } );
  2605. /*!
  2606. * jQuery UI Effects Clip 1.12.0
  2607. * http://jqueryui.com
  2608. *
  2609. * Copyright jQuery Foundation and other contributors
  2610. * Released under the MIT license.
  2611. * http://jquery.org/license
  2612. */
  2613. //>>label: Clip Effect
  2614. //>>group: Effects
  2615. //>>description: Clips the element on and off like an old TV.
  2616. //>>docs: http://api.jqueryui.com/clip-effect/
  2617. //>>demos: http://jqueryui.com/effect/
  2618. var effectsEffectClip = $.effects.define( "clip", "hide", function( options, done ) {
  2619. var start,
  2620. animate = {},
  2621. element = $( this ),
  2622. direction = options.direction || "vertical",
  2623. both = direction === "both",
  2624. horizontal = both || direction === "horizontal",
  2625. vertical = both || direction === "vertical";
  2626. start = element.cssClip();
  2627. animate.clip = {
  2628. top: vertical ? ( start.bottom - start.top ) / 2 : start.top,
  2629. right: horizontal ? ( start.right - start.left ) / 2 : start.right,
  2630. bottom: vertical ? ( start.bottom - start.top ) / 2 : start.bottom,
  2631. left: horizontal ? ( start.right - start.left ) / 2 : start.left
  2632. };
  2633. $.effects.createPlaceholder( element );
  2634. if ( options.mode === "show" ) {
  2635. element.cssClip( animate.clip );
  2636. animate.clip = start;
  2637. }
  2638. element.animate( animate, {
  2639. queue: false,
  2640. duration: options.duration,
  2641. easing: options.easing,
  2642. complete: done
  2643. } );
  2644. } );
  2645. /*!
  2646. * jQuery UI Effects Drop 1.12.0
  2647. * http://jqueryui.com
  2648. *
  2649. * Copyright jQuery Foundation and other contributors
  2650. * Released under the MIT license.
  2651. * http://jquery.org/license
  2652. */
  2653. //>>label: Drop Effect
  2654. //>>group: Effects
  2655. //>>description: Moves an element in one direction and hides it at the same time.
  2656. //>>docs: http://api.jqueryui.com/drop-effect/
  2657. //>>demos: http://jqueryui.com/effect/
  2658. var effectsEffectDrop = $.effects.define( "drop", "hide", function( options, done ) {
  2659. var distance,
  2660. element = $( this ),
  2661. mode = options.mode,
  2662. show = mode === "show",
  2663. direction = options.direction || "left",
  2664. ref = ( direction === "up" || direction === "down" ) ? "top" : "left",
  2665. motion = ( direction === "up" || direction === "left" ) ? "-=" : "+=",
  2666. oppositeMotion = ( motion === "+=" ) ? "-=" : "+=",
  2667. animation = {
  2668. opacity: 0
  2669. };
  2670. $.effects.createPlaceholder( element );
  2671. distance = options.distance ||
  2672. element[ ref === "top" ? "outerHeight" : "outerWidth" ]( true ) / 2;
  2673. animation[ ref ] = motion + distance;
  2674. if ( show ) {
  2675. element.css( animation );
  2676. animation[ ref ] = oppositeMotion + distance;
  2677. animation.opacity = 1;
  2678. }
  2679. // Animate
  2680. element.animate( animation, {
  2681. queue: false,
  2682. duration: options.duration,
  2683. easing: options.easing,
  2684. complete: done
  2685. } );
  2686. } );
  2687. /*!
  2688. * jQuery UI Effects Explode 1.12.0
  2689. * http://jqueryui.com
  2690. *
  2691. * Copyright jQuery Foundation and other contributors
  2692. * Released under the MIT license.
  2693. * http://jquery.org/license
  2694. */
  2695. //>>label: Explode Effect
  2696. //>>group: Effects
  2697. // jscs:disable maximumLineLength
  2698. //>>description: Explodes an element in all directions into n pieces. Implodes an element to its original wholeness.
  2699. // jscs:enable maximumLineLength
  2700. //>>docs: http://api.jqueryui.com/explode-effect/
  2701. //>>demos: http://jqueryui.com/effect/
  2702. var effectsEffectExplode = $.effects.define( "explode", "hide", function( options, done ) {
  2703. var i, j, left, top, mx, my,
  2704. rows = options.pieces ? Math.round( Math.sqrt( options.pieces ) ) : 3,
  2705. cells = rows,
  2706. element = $( this ),
  2707. mode = options.mode,
  2708. show = mode === "show",
  2709. // Show and then visibility:hidden the element before calculating offset
  2710. offset = element.show().css( "visibility", "hidden" ).offset(),
  2711. // Width and height of a piece
  2712. width = Math.ceil( element.outerWidth() / cells ),
  2713. height = Math.ceil( element.outerHeight() / rows ),
  2714. pieces = [];
  2715. // Children animate complete:
  2716. function childComplete() {
  2717. pieces.push( this );
  2718. if ( pieces.length === rows * cells ) {
  2719. animComplete();
  2720. }
  2721. }
  2722. // Clone the element for each row and cell.
  2723. for ( i = 0; i < rows; i++ ) { // ===>
  2724. top = offset.top + i * height;
  2725. my = i - ( rows - 1 ) / 2;
  2726. for ( j = 0; j < cells; j++ ) { // |||
  2727. left = offset.left + j * width;
  2728. mx = j - ( cells - 1 ) / 2;
  2729. // Create a clone of the now hidden main element that will be absolute positioned
  2730. // within a wrapper div off the -left and -top equal to size of our pieces
  2731. element
  2732. .clone()
  2733. .appendTo( "body" )
  2734. .wrap( "<div></div>" )
  2735. .css( {
  2736. position: "absolute",
  2737. visibility: "visible",
  2738. left: -j * width,
  2739. top: -i * height
  2740. } )
  2741. // Select the wrapper - make it overflow: hidden and absolute positioned based on
  2742. // where the original was located +left and +top equal to the size of pieces
  2743. .parent()
  2744. .addClass( "ui-effects-explode" )
  2745. .css( {
  2746. position: "absolute",
  2747. overflow: "hidden",
  2748. width: width,
  2749. height: height,
  2750. left: left + ( show ? mx * width : 0 ),
  2751. top: top + ( show ? my * height : 0 ),
  2752. opacity: show ? 0 : 1
  2753. } )
  2754. .animate( {
  2755. left: left + ( show ? 0 : mx * width ),
  2756. top: top + ( show ? 0 : my * height ),
  2757. opacity: show ? 1 : 0
  2758. }, options.duration || 500, options.easing, childComplete );
  2759. }
  2760. }
  2761. function animComplete() {
  2762. element.css( {
  2763. visibility: "visible"
  2764. } );
  2765. $( pieces ).remove();
  2766. done();
  2767. }
  2768. } );
  2769. /*!
  2770. * jQuery UI Effects Fade 1.12.0
  2771. * http://jqueryui.com
  2772. *
  2773. * Copyright jQuery Foundation and other contributors
  2774. * Released under the MIT license.
  2775. * http://jquery.org/license
  2776. */
  2777. //>>label: Fade Effect
  2778. //>>group: Effects
  2779. //>>description: Fades the element.
  2780. //>>docs: http://api.jqueryui.com/fade-effect/
  2781. //>>demos: http://jqueryui.com/effect/
  2782. var effectsEffectFade = $.effects.define( "fade", "toggle", function( options, done ) {
  2783. var show = options.mode === "show";
  2784. $( this )
  2785. .css( "opacity", show ? 0 : 1 )
  2786. .animate( {
  2787. opacity: show ? 1 : 0
  2788. }, {
  2789. queue: false,
  2790. duration: options.duration,
  2791. easing: options.easing,
  2792. complete: done
  2793. } );
  2794. } );
  2795. /*!
  2796. * jQuery UI Effects Fold 1.12.0
  2797. * http://jqueryui.com
  2798. *
  2799. * Copyright jQuery Foundation and other contributors
  2800. * Released under the MIT license.
  2801. * http://jquery.org/license
  2802. */
  2803. //>>label: Fold Effect
  2804. //>>group: Effects
  2805. //>>description: Folds an element first horizontally and then vertically.
  2806. //>>docs: http://api.jqueryui.com/fold-effect/
  2807. //>>demos: http://jqueryui.com/effect/
  2808. var effectsEffectFold = $.effects.define( "fold", "hide", function( options, done ) {
  2809. // Create element
  2810. var element = $( this ),
  2811. mode = options.mode,
  2812. show = mode === "show",
  2813. hide = mode === "hide",
  2814. size = options.size || 15,
  2815. percent = /([0-9]+)%/.exec( size ),
  2816. horizFirst = !!options.horizFirst,
  2817. ref = horizFirst ? [ "right", "bottom" ] : [ "bottom", "right" ],
  2818. duration = options.duration / 2,
  2819. placeholder = $.effects.createPlaceholder( element ),
  2820. start = element.cssClip(),
  2821. animation1 = { clip: $.extend( {}, start ) },
  2822. animation2 = { clip: $.extend( {}, start ) },
  2823. distance = [ start[ ref[ 0 ] ], start[ ref[ 1 ] ] ],
  2824. queuelen = element.queue().length;
  2825. if ( percent ) {
  2826. size = parseInt( percent[ 1 ], 10 ) / 100 * distance[ hide ? 0 : 1 ];
  2827. }
  2828. animation1.clip[ ref[ 0 ] ] = size;
  2829. animation2.clip[ ref[ 0 ] ] = size;
  2830. animation2.clip[ ref[ 1 ] ] = 0;
  2831. if ( show ) {
  2832. element.cssClip( animation2.clip );
  2833. if ( placeholder ) {
  2834. placeholder.css( $.effects.clipToBox( animation2 ) );
  2835. }
  2836. animation2.clip = start;
  2837. }
  2838. // Animate
  2839. element
  2840. .queue( function( next ) {
  2841. if ( placeholder ) {
  2842. placeholder
  2843. .animate( $.effects.clipToBox( animation1 ), duration, options.easing )
  2844. .animate( $.effects.clipToBox( animation2 ), duration, options.easing );
  2845. }
  2846. next();
  2847. } )
  2848. .animate( animation1, duration, options.easing )
  2849. .animate( animation2, duration, options.easing )
  2850. .queue( done );
  2851. $.effects.unshift( element, queuelen, 4 );
  2852. } );
  2853. /*!
  2854. * jQuery UI Effects Highlight 1.12.0
  2855. * http://jqueryui.com
  2856. *
  2857. * Copyright jQuery Foundation and other contributors
  2858. * Released under the MIT license.
  2859. * http://jquery.org/license
  2860. */
  2861. //>>label: Highlight Effect
  2862. //>>group: Effects
  2863. //>>description: Highlights the background of an element in a defined color for a custom duration.
  2864. //>>docs: http://api.jqueryui.com/highlight-effect/
  2865. //>>demos: http://jqueryui.com/effect/
  2866. var effectsEffectHighlight = $.effects.define( "highlight", "show", function( options, done ) {
  2867. var element = $( this ),
  2868. animation = {
  2869. backgroundColor: element.css( "backgroundColor" )
  2870. };
  2871. if ( options.mode === "hide" ) {
  2872. animation.opacity = 0;
  2873. }
  2874. $.effects.saveStyle( element );
  2875. element
  2876. .css( {
  2877. backgroundImage: "none",
  2878. backgroundColor: options.color || "#ffff99"
  2879. } )
  2880. .animate( animation, {
  2881. queue: false,
  2882. duration: options.duration,
  2883. easing: options.easing,
  2884. complete: done
  2885. } );
  2886. } );
  2887. /*!
  2888. * jQuery UI Effects Size 1.12.0
  2889. * http://jqueryui.com
  2890. *
  2891. * Copyright jQuery Foundation and other contributors
  2892. * Released under the MIT license.
  2893. * http://jquery.org/license
  2894. */
  2895. //>>label: Size Effect
  2896. //>>group: Effects
  2897. //>>description: Resize an element to a specified width and height.
  2898. //>>docs: http://api.jqueryui.com/size-effect/
  2899. //>>demos: http://jqueryui.com/effect/
  2900. var effectsEffectSize = $.effects.define( "size", function( options, done ) {
  2901. // Create element
  2902. var baseline, factor, temp,
  2903. element = $( this ),
  2904. // Copy for children
  2905. cProps = [ "fontSize" ],
  2906. vProps = [ "borderTopWidth", "borderBottomWidth", "paddingTop", "paddingBottom" ],
  2907. hProps = [ "borderLeftWidth", "borderRightWidth", "paddingLeft", "paddingRight" ],
  2908. // Set options
  2909. mode = options.mode,
  2910. restore = mode !== "effect",
  2911. scale = options.scale || "both",
  2912. origin = options.origin || [ "middle", "center" ],
  2913. position = element.css( "position" ),
  2914. pos = element.position(),
  2915. original = $.effects.scaledDimensions( element ),
  2916. from = options.from || original,
  2917. to = options.to || $.effects.scaledDimensions( element, 0 );
  2918. $.effects.createPlaceholder( element );
  2919. if ( mode === "show" ) {
  2920. temp = from;
  2921. from = to;
  2922. to = temp;
  2923. }
  2924. // Set scaling factor
  2925. factor = {
  2926. from: {
  2927. y: from.height / original.height,
  2928. x: from.width / original.width
  2929. },
  2930. to: {
  2931. y: to.height / original.height,
  2932. x: to.width / original.width
  2933. }
  2934. };
  2935. // Scale the css box
  2936. if ( scale === "box" || scale === "both" ) {
  2937. // Vertical props scaling
  2938. if ( factor.from.y !== factor.to.y ) {
  2939. from = $.effects.setTransition( element, vProps, factor.from.y, from );
  2940. to = $.effects.setTransition( element, vProps, factor.to.y, to );
  2941. }
  2942. // Horizontal props scaling
  2943. if ( factor.from.x !== factor.to.x ) {
  2944. from = $.effects.setTransition( element, hProps, factor.from.x, from );
  2945. to = $.effects.setTransition( element, hProps, factor.to.x, to );
  2946. }
  2947. }
  2948. // Scale the content
  2949. if ( scale === "content" || scale === "both" ) {
  2950. // Vertical props scaling
  2951. if ( factor.from.y !== factor.to.y ) {
  2952. from = $.effects.setTransition( element, cProps, factor.from.y, from );
  2953. to = $.effects.setTransition( element, cProps, factor.to.y, to );
  2954. }
  2955. }
  2956. // Adjust the position properties based on the provided origin points
  2957. if ( origin ) {
  2958. baseline = $.effects.getBaseline( origin, original );
  2959. from.top = ( original.outerHeight - from.outerHeight ) * baseline.y + pos.top;
  2960. from.left = ( original.outerWidth - from.outerWidth ) * baseline.x + pos.left;
  2961. to.top = ( original.outerHeight - to.outerHeight ) * baseline.y + pos.top;
  2962. to.left = ( original.outerWidth - to.outerWidth ) * baseline.x + pos.left;
  2963. }
  2964. element.css( from );
  2965. // Animate the children if desired
  2966. if ( scale === "content" || scale === "both" ) {
  2967. vProps = vProps.concat( [ "marginTop", "marginBottom" ] ).concat( cProps );
  2968. hProps = hProps.concat( [ "marginLeft", "marginRight" ] );
  2969. // Only animate children with width attributes specified
  2970. // TODO: is this right? should we include anything with css width specified as well
  2971. element.find( "*[width]" ).each( function() {
  2972. var child = $( this ),
  2973. childOriginal = $.effects.scaledDimensions( child ),
  2974. childFrom = {
  2975. height: childOriginal.height * factor.from.y,
  2976. width: childOriginal.width * factor.from.x,
  2977. outerHeight: childOriginal.outerHeight * factor.from.y,
  2978. outerWidth: childOriginal.outerWidth * factor.from.x
  2979. },
  2980. childTo = {
  2981. height: childOriginal.height * factor.to.y,
  2982. width: childOriginal.width * factor.to.x,
  2983. outerHeight: childOriginal.height * factor.to.y,
  2984. outerWidth: childOriginal.width * factor.to.x
  2985. };
  2986. // Vertical props scaling
  2987. if ( factor.from.y !== factor.to.y ) {
  2988. childFrom = $.effects.setTransition( child, vProps, factor.from.y, childFrom );
  2989. childTo = $.effects.setTransition( child, vProps, factor.to.y, childTo );
  2990. }
  2991. // Horizontal props scaling
  2992. if ( factor.from.x !== factor.to.x ) {
  2993. childFrom = $.effects.setTransition( child, hProps, factor.from.x, childFrom );
  2994. childTo = $.effects.setTransition( child, hProps, factor.to.x, childTo );
  2995. }
  2996. if ( restore ) {
  2997. $.effects.saveStyle( child );
  2998. }
  2999. // Animate children
  3000. child.css( childFrom );
  3001. child.animate( childTo, options.duration, options.easing, function() {
  3002. // Restore children
  3003. if ( restore ) {
  3004. $.effects.restoreStyle( child );
  3005. }
  3006. } );
  3007. } );
  3008. }
  3009. // Animate
  3010. element.animate( to, {
  3011. queue: false,
  3012. duration: options.duration,
  3013. easing: options.easing,
  3014. complete: function() {
  3015. var offset = element.offset();
  3016. if ( to.opacity === 0 ) {
  3017. element.css( "opacity", from.opacity );
  3018. }
  3019. if ( !restore ) {
  3020. element
  3021. .css( "position", position === "static" ? "relative" : position )
  3022. .offset( offset );
  3023. // Need to save style here so that automatic style restoration
  3024. // doesn't restore to the original styles from before the animation.
  3025. $.effects.saveStyle( element );
  3026. }
  3027. done();
  3028. }
  3029. } );
  3030. } );
  3031. /*!
  3032. * jQuery UI Effects Scale 1.12.0
  3033. * http://jqueryui.com
  3034. *
  3035. * Copyright jQuery Foundation and other contributors
  3036. * Released under the MIT license.
  3037. * http://jquery.org/license
  3038. */
  3039. //>>label: Scale Effect
  3040. //>>group: Effects
  3041. //>>description: Grows or shrinks an element and its content.
  3042. //>>docs: http://api.jqueryui.com/scale-effect/
  3043. //>>demos: http://jqueryui.com/effect/
  3044. var effectsEffectScale = $.effects.define( "scale", function( options, done ) {
  3045. // Create element
  3046. var el = $( this ),
  3047. mode = options.mode,
  3048. percent = parseInt( options.percent, 10 ) ||
  3049. ( parseInt( options.percent, 10 ) === 0 ? 0 : ( mode !== "effect" ? 0 : 100 ) ),
  3050. newOptions = $.extend( true, {
  3051. from: $.effects.scaledDimensions( el ),
  3052. to: $.effects.scaledDimensions( el, percent, options.direction || "both" ),
  3053. origin: options.origin || [ "middle", "center" ]
  3054. }, options );
  3055. // Fade option to support puff
  3056. if ( options.fade ) {
  3057. newOptions.from.opacity = 1;
  3058. newOptions.to.opacity = 0;
  3059. }
  3060. $.effects.effect.size.call( this, newOptions, done );
  3061. } );
  3062. /*!
  3063. * jQuery UI Effects Puff 1.12.0
  3064. * http://jqueryui.com
  3065. *
  3066. * Copyright jQuery Foundation and other contributors
  3067. * Released under the MIT license.
  3068. * http://jquery.org/license
  3069. */
  3070. //>>label: Puff Effect
  3071. //>>group: Effects
  3072. //>>description: Creates a puff effect by scaling the element up and hiding it at the same time.
  3073. //>>docs: http://api.jqueryui.com/puff-effect/
  3074. //>>demos: http://jqueryui.com/effect/
  3075. var effectsEffectPuff = $.effects.define( "puff", "hide", function( options, done ) {
  3076. var newOptions = $.extend( true, {}, options, {
  3077. fade: true,
  3078. percent: parseInt( options.percent, 10 ) || 150
  3079. } );
  3080. $.effects.effect.scale.call( this, newOptions, done );
  3081. } );
  3082. /*!
  3083. * jQuery UI Effects Pulsate 1.12.0
  3084. * http://jqueryui.com
  3085. *
  3086. * Copyright jQuery Foundation and other contributors
  3087. * Released under the MIT license.
  3088. * http://jquery.org/license
  3089. */
  3090. //>>label: Pulsate Effect
  3091. //>>group: Effects
  3092. //>>description: Pulsates an element n times by changing the opacity to zero and back.
  3093. //>>docs: http://api.jqueryui.com/pulsate-effect/
  3094. //>>demos: http://jqueryui.com/effect/
  3095. var effectsEffectPulsate = $.effects.define( "pulsate", "show", function( options, done ) {
  3096. var element = $( this ),
  3097. mode = options.mode,
  3098. show = mode === "show",
  3099. hide = mode === "hide",
  3100. showhide = show || hide,
  3101. // Showing or hiding leaves off the "last" animation
  3102. anims = ( ( options.times || 5 ) * 2 ) + ( showhide ? 1 : 0 ),
  3103. duration = options.duration / anims,
  3104. animateTo = 0,
  3105. i = 1,
  3106. queuelen = element.queue().length;
  3107. if ( show || !element.is( ":visible" ) ) {
  3108. element.css( "opacity", 0 ).show();
  3109. animateTo = 1;
  3110. }
  3111. // Anims - 1 opacity "toggles"
  3112. for ( ; i < anims; i++ ) {
  3113. element.animate( { opacity: animateTo }, duration, options.easing );
  3114. animateTo = 1 - animateTo;
  3115. }
  3116. element.animate( { opacity: animateTo }, duration, options.easing );
  3117. element.queue( done );
  3118. $.effects.unshift( element, queuelen, anims + 1 );
  3119. } );
  3120. /*!
  3121. * jQuery UI Effects Shake 1.12.0
  3122. * http://jqueryui.com
  3123. *
  3124. * Copyright jQuery Foundation and other contributors
  3125. * Released under the MIT license.
  3126. * http://jquery.org/license
  3127. */
  3128. //>>label: Shake Effect
  3129. //>>group: Effects
  3130. //>>description: Shakes an element horizontally or vertically n times.
  3131. //>>docs: http://api.jqueryui.com/shake-effect/
  3132. //>>demos: http://jqueryui.com/effect/
  3133. var effectsEffectShake = $.effects.define( "shake", function( options, done ) {
  3134. var i = 1,
  3135. element = $( this ),
  3136. direction = options.direction || "left",
  3137. distance = options.distance || 20,
  3138. times = options.times || 3,
  3139. anims = times * 2 + 1,
  3140. speed = Math.round( options.duration / anims ),
  3141. ref = ( direction === "up" || direction === "down" ) ? "top" : "left",
  3142. positiveMotion = ( direction === "up" || direction === "left" ),
  3143. animation = {},
  3144. animation1 = {},
  3145. animation2 = {},
  3146. queuelen = element.queue().length;
  3147. $.effects.createPlaceholder( element );
  3148. // Animation
  3149. animation[ ref ] = ( positiveMotion ? "-=" : "+=" ) + distance;
  3150. animation1[ ref ] = ( positiveMotion ? "+=" : "-=" ) + distance * 2;
  3151. animation2[ ref ] = ( positiveMotion ? "-=" : "+=" ) + distance * 2;
  3152. // Animate
  3153. element.animate( animation, speed, options.easing );
  3154. // Shakes
  3155. for ( ; i < times; i++ ) {
  3156. element
  3157. .animate( animation1, speed, options.easing )
  3158. .animate( animation2, speed, options.easing );
  3159. }
  3160. element
  3161. .animate( animation1, speed, options.easing )
  3162. .animate( animation, speed / 2, options.easing )
  3163. .queue( done );
  3164. $.effects.unshift( element, queuelen, anims + 1 );
  3165. } );
  3166. /*!
  3167. * jQuery UI Effects Slide 1.12.0
  3168. * http://jqueryui.com
  3169. *
  3170. * Copyright jQuery Foundation and other contributors
  3171. * Released under the MIT license.
  3172. * http://jquery.org/license
  3173. */
  3174. //>>label: Slide Effect
  3175. //>>group: Effects
  3176. //>>description: Slides an element in and out of the viewport.
  3177. //>>docs: http://api.jqueryui.com/slide-effect/
  3178. //>>demos: http://jqueryui.com/effect/
  3179. var effectsEffectSlide = $.effects.define( "slide", "show", function( options, done ) {
  3180. var startClip, startRef,
  3181. element = $( this ),
  3182. map = {
  3183. up: [ "bottom", "top" ],
  3184. down: [ "top", "bottom" ],
  3185. left: [ "right", "left" ],
  3186. right: [ "left", "right" ]
  3187. },
  3188. mode = options.mode,
  3189. direction = options.direction || "left",
  3190. ref = ( direction === "up" || direction === "down" ) ? "top" : "left",
  3191. positiveMotion = ( direction === "up" || direction === "left" ),
  3192. distance = options.distance ||
  3193. element[ ref === "top" ? "outerHeight" : "outerWidth" ]( true ),
  3194. animation = {};
  3195. $.effects.createPlaceholder( element );
  3196. startClip = element.cssClip();
  3197. startRef = element.position()[ ref ];
  3198. // Define hide animation
  3199. animation[ ref ] = ( positiveMotion ? -1 : 1 ) * distance + startRef;
  3200. animation.clip = element.cssClip();
  3201. animation.clip[ map[ direction ][ 1 ] ] = animation.clip[ map[ direction ][ 0 ] ];
  3202. // Reverse the animation if we're showing
  3203. if ( mode === "show" ) {
  3204. element.cssClip( animation.clip );
  3205. element.css( ref, animation[ ref ] );
  3206. animation.clip = startClip;
  3207. animation[ ref ] = startRef;
  3208. }
  3209. // Actually animate
  3210. element.animate( animation, {
  3211. queue: false,
  3212. duration: options.duration,
  3213. easing: options.easing,
  3214. complete: done
  3215. } );
  3216. } );
  3217. /*!
  3218. * jQuery UI Effects Transfer 1.12.0
  3219. * http://jqueryui.com
  3220. *
  3221. * Copyright jQuery Foundation and other contributors
  3222. * Released under the MIT license.
  3223. * http://jquery.org/license
  3224. */
  3225. //>>label: Transfer Effect
  3226. //>>group: Effects
  3227. //>>description: Displays a transfer effect from one element to another.
  3228. //>>docs: http://api.jqueryui.com/transfer-effect/
  3229. //>>demos: http://jqueryui.com/effect/
  3230. var effect;
  3231. if ( $.uiBackCompat !== false ) {
  3232. effect = $.effects.define( "transfer", function( options, done ) {
  3233. $( this ).transfer( options, done );
  3234. } );
  3235. }
  3236. var effectsEffectTransfer = effect;
  3237. /*!
  3238. * jQuery UI Focusable 1.12.0
  3239. * http://jqueryui.com
  3240. *
  3241. * Copyright jQuery Foundation and other contributors
  3242. * Released under the MIT license.
  3243. * http://jquery.org/license
  3244. */
  3245. //>>label: :focusable Selector
  3246. //>>group: Core
  3247. //>>description: Selects elements which can be focused.
  3248. //>>docs: http://api.jqueryui.com/focusable-selector/
  3249. // Selectors
  3250. $.ui.focusable = function( element, hasTabindex ) {
  3251. var map, mapName, img, focusableIfVisible, fieldset,
  3252. nodeName = element.nodeName.toLowerCase();
  3253. if ( "area" === nodeName ) {
  3254. map = element.parentNode;
  3255. mapName = map.name;
  3256. if ( !element.href || !mapName || map.nodeName.toLowerCase() !== "map" ) {
  3257. return false;
  3258. }
  3259. img = $( "img[usemap='#" + mapName + "']" );
  3260. return img.length > 0 && img.is( ":visible" );
  3261. }
  3262. if ( /^(input|select|textarea|button|object)$/.test( nodeName ) ) {
  3263. focusableIfVisible = !element.disabled;
  3264. if ( focusableIfVisible ) {
  3265. // Form controls within a disabled fieldset are disabled.
  3266. // However, controls within the fieldset's legend do not get disabled.
  3267. // Since controls generally aren't placed inside legends, we skip
  3268. // this portion of the check.
  3269. fieldset = $( element ).closest( "fieldset" )[ 0 ];
  3270. if ( fieldset ) {
  3271. focusableIfVisible = !fieldset.disabled;
  3272. }
  3273. }
  3274. } else if ( "a" === nodeName ) {
  3275. focusableIfVisible = element.href || hasTabindex;
  3276. } else {
  3277. focusableIfVisible = hasTabindex;
  3278. }
  3279. return focusableIfVisible && $( element ).is( ":visible" ) && visible( $( element ) );
  3280. };
  3281. // Support: IE 8 only
  3282. // IE 8 doesn't resolve inherit to visible/hidden for computed values
  3283. function visible( element ) {
  3284. var visibility = element.css( "visibility" );
  3285. while ( visibility === "inherit" ) {
  3286. element = element.parent();
  3287. visibility = element.css( "visibility" );
  3288. }
  3289. return visibility !== "hidden";
  3290. }
  3291. $.extend( $.expr[ ":" ], {
  3292. focusable: function( element ) {
  3293. return $.ui.focusable( element, $.attr( element, "tabindex" ) != null );
  3294. }
  3295. } );
  3296. var focusable = $.ui.focusable;
  3297. // Support: IE8 Only
  3298. // IE8 does not support the form attribute and when it is supplied. It overwrites the form prop
  3299. // with a string, so we need to find the proper form.
  3300. var form = $.fn.form = function() {
  3301. return typeof this[ 0 ].form === "string" ? this.closest( "form" ) : $( this[ 0 ].form );
  3302. };
  3303. /*!
  3304. * jQuery UI Form Reset Mixin 1.12.0
  3305. * http://jqueryui.com
  3306. *
  3307. * Copyright jQuery Foundation and other contributors
  3308. * Released under the MIT license.
  3309. * http://jquery.org/license
  3310. */
  3311. //>>label: Form Reset Mixin
  3312. //>>group: Core
  3313. //>>description: Refresh input widgets when their form is reset
  3314. //>>docs: http://api.jqueryui.com/form-reset-mixin/
  3315. var formResetMixin = $.ui.formResetMixin = {
  3316. _formResetHandler: function() {
  3317. var form = $( this );
  3318. // Wait for the form reset to actually happen before refreshing
  3319. setTimeout( function() {
  3320. var instances = form.data( "ui-form-reset-instances" );
  3321. $.each( instances, function() {
  3322. this.refresh();
  3323. } );
  3324. } );
  3325. },
  3326. _bindFormResetHandler: function() {
  3327. this.form = this.element.form();
  3328. if ( !this.form.length ) {
  3329. return;
  3330. }
  3331. var instances = this.form.data( "ui-form-reset-instances" ) || [];
  3332. if ( !instances.length ) {
  3333. // We don't use _on() here because we use a single event handler per form
  3334. this.form.on( "reset.ui-form-reset", this._formResetHandler );
  3335. }
  3336. instances.push( this );
  3337. this.form.data( "ui-form-reset-instances", instances );
  3338. },
  3339. _unbindFormResetHandler: function() {
  3340. if ( !this.form.length ) {
  3341. return;
  3342. }
  3343. var instances = this.form.data( "ui-form-reset-instances" );
  3344. instances.splice( $.inArray( this, instances ), 1 );
  3345. if ( instances.length ) {
  3346. this.form.data( "ui-form-reset-instances", instances );
  3347. } else {
  3348. this.form
  3349. .removeData( "ui-form-reset-instances" )
  3350. .off( "reset.ui-form-reset" );
  3351. }
  3352. }
  3353. };
  3354. /*!
  3355. * jQuery UI Support for jQuery core 1.7.x 1.12.0
  3356. * http://jqueryui.com
  3357. *
  3358. * Copyright jQuery Foundation and other contributors
  3359. * Released under the MIT license.
  3360. * http://jquery.org/license
  3361. *
  3362. */
  3363. //>>label: jQuery 1.7 Support
  3364. //>>group: Core
  3365. //>>description: Support version 1.7.x of jQuery core
  3366. // Support: jQuery 1.7 only
  3367. // Not a great way to check versions, but since we only support 1.7+ and only
  3368. // need to detect <1.8, this is a simple check that should suffice. Checking
  3369. // for "1.7." would be a bit safer, but the version string is 1.7, not 1.7.0
  3370. // and we'll never reach 1.70.0 (if we do, we certainly won't be supporting
  3371. // 1.7 anymore). See #11197 for why we're not using feature detection.
  3372. if ( $.fn.jquery.substring( 0, 3 ) === "1.7" ) {
  3373. // Setters for .innerWidth(), .innerHeight(), .outerWidth(), .outerHeight()
  3374. // Unlike jQuery Core 1.8+, these only support numeric values to set the
  3375. // dimensions in pixels
  3376. $.each( [ "Width", "Height" ], function( i, name ) {
  3377. var side = name === "Width" ? [ "Left", "Right" ] : [ "Top", "Bottom" ],
  3378. type = name.toLowerCase(),
  3379. orig = {
  3380. innerWidth: $.fn.innerWidth,
  3381. innerHeight: $.fn.innerHeight,
  3382. outerWidth: $.fn.outerWidth,
  3383. outerHeight: $.fn.outerHeight
  3384. };
  3385. function reduce( elem, size, border, margin ) {
  3386. $.each( side, function() {
  3387. size -= parseFloat( $.css( elem, "padding" + this ) ) || 0;
  3388. if ( border ) {
  3389. size -= parseFloat( $.css( elem, "border" + this + "Width" ) ) || 0;
  3390. }
  3391. if ( margin ) {
  3392. size -= parseFloat( $.css( elem, "margin" + this ) ) || 0;
  3393. }
  3394. } );
  3395. return size;
  3396. }
  3397. $.fn[ "inner" + name ] = function( size ) {
  3398. if ( size === undefined ) {
  3399. return orig[ "inner" + name ].call( this );
  3400. }
  3401. return this.each( function() {
  3402. $( this ).css( type, reduce( this, size ) + "px" );
  3403. } );
  3404. };
  3405. $.fn[ "outer" + name ] = function( size, margin ) {
  3406. if ( typeof size !== "number" ) {
  3407. return orig[ "outer" + name ].call( this, size );
  3408. }
  3409. return this.each( function() {
  3410. $( this ).css( type, reduce( this, size, true, margin ) + "px" );
  3411. } );
  3412. };
  3413. } );
  3414. $.fn.addBack = function( selector ) {
  3415. return this.add( selector == null ?
  3416. this.prevObject : this.prevObject.filter( selector )
  3417. );
  3418. };
  3419. }
  3420. ;
  3421. /*!
  3422. * jQuery UI Keycode 1.12.0
  3423. * http://jqueryui.com
  3424. *
  3425. * Copyright jQuery Foundation and other contributors
  3426. * Released under the MIT license.
  3427. * http://jquery.org/license
  3428. */
  3429. //>>label: Keycode
  3430. //>>group: Core
  3431. //>>description: Provide keycodes as keynames
  3432. //>>docs: http://api.jqueryui.com/jQuery.ui.keyCode/
  3433. var keycode = $.ui.keyCode = {
  3434. BACKSPACE: 8,
  3435. COMMA: 188,
  3436. DELETE: 46,
  3437. DOWN: 40,
  3438. END: 35,
  3439. ENTER: 13,
  3440. ESCAPE: 27,
  3441. HOME: 36,
  3442. LEFT: 37,
  3443. PAGE_DOWN: 34,
  3444. PAGE_UP: 33,
  3445. PERIOD: 190,
  3446. RIGHT: 39,
  3447. SPACE: 32,
  3448. TAB: 9,
  3449. UP: 38
  3450. };
  3451. // Internal use only
  3452. var escapeSelector = $.ui.escapeSelector = ( function() {
  3453. var selectorEscape = /([!"#$%&'()*+,./:;<=>?@[\]^`{|}~])/g;
  3454. return function( selector ) {
  3455. return selector.replace( selectorEscape, "\\$1" );
  3456. };
  3457. } )();
  3458. /*!
  3459. * jQuery UI Labels 1.12.0
  3460. * http://jqueryui.com
  3461. *
  3462. * Copyright jQuery Foundation and other contributors
  3463. * Released under the MIT license.
  3464. * http://jquery.org/license
  3465. */
  3466. //>>label: labels
  3467. //>>group: Core
  3468. //>>description: Find all the labels associated with a given input
  3469. //>>docs: http://api.jqueryui.com/labels/
  3470. var labels = $.fn.labels = function() {
  3471. var ancestor, selector, id, labels, ancestors;
  3472. // Check control.labels first
  3473. if ( this[ 0 ].labels && this[ 0 ].labels.length ) {
  3474. return this.pushStack( this[ 0 ].labels );
  3475. }
  3476. // Support: IE <= 11, FF <= 37, Android <= 2.3 only
  3477. // Above browsers do not support control.labels. Everything below is to support them
  3478. // as well as document fragments. control.labels does not work on document fragments
  3479. labels = this.eq( 0 ).parents( "label" );
  3480. // Look for the label based on the id
  3481. id = this.attr( "id" );
  3482. if ( id ) {
  3483. // We don't search against the document in case the element
  3484. // is disconnected from the DOM
  3485. ancestor = this.eq( 0 ).parents().last();
  3486. // Get a full set of top level ancestors
  3487. ancestors = ancestor.add( ancestor.length ? ancestor.siblings() : this.siblings() );
  3488. // Create a selector for the label based on the id
  3489. selector = "label[for='" + $.ui.escapeSelector( id ) + "']";
  3490. labels = labels.add( ancestors.find( selector ).addBack( selector ) );
  3491. }
  3492. // Return whatever we have found for labels
  3493. return this.pushStack( labels );
  3494. };
  3495. /*!
  3496. * jQuery UI Scroll Parent 1.12.0
  3497. * http://jqueryui.com
  3498. *
  3499. * Copyright jQuery Foundation and other contributors
  3500. * Released under the MIT license.
  3501. * http://jquery.org/license
  3502. */
  3503. //>>label: scrollParent
  3504. //>>group: Core
  3505. //>>description: Get the closest ancestor element that is scrollable.
  3506. //>>docs: http://api.jqueryui.com/scrollParent/
  3507. var scrollParent = $.fn.scrollParent = function( includeHidden ) {
  3508. var position = this.css( "position" ),
  3509. excludeStaticParent = position === "absolute",
  3510. overflowRegex = includeHidden ? /(auto|scroll|hidden)/ : /(auto|scroll)/,
  3511. scrollParent = this.parents().filter( function() {
  3512. var parent = $( this );
  3513. if ( excludeStaticParent && parent.css( "position" ) === "static" ) {
  3514. return false;
  3515. }
  3516. return overflowRegex.test( parent.css( "overflow" ) + parent.css( "overflow-y" ) +
  3517. parent.css( "overflow-x" ) );
  3518. } ).eq( 0 );
  3519. return position === "fixed" || !scrollParent.length ?
  3520. $( this[ 0 ].ownerDocument || document ) :
  3521. scrollParent;
  3522. };
  3523. /*!
  3524. * jQuery UI Tabbable 1.12.0
  3525. * http://jqueryui.com
  3526. *
  3527. * Copyright jQuery Foundation and other contributors
  3528. * Released under the MIT license.
  3529. * http://jquery.org/license
  3530. */
  3531. //>>label: :tabbable Selector
  3532. //>>group: Core
  3533. //>>description: Selects elements which can be tabbed to.
  3534. //>>docs: http://api.jqueryui.com/tabbable-selector/
  3535. var tabbable = $.extend( $.expr[ ":" ], {
  3536. tabbable: function( element ) {
  3537. var tabIndex = $.attr( element, "tabindex" ),
  3538. hasTabindex = tabIndex != null;
  3539. return ( !hasTabindex || tabIndex >= 0 ) && $.ui.focusable( element, hasTabindex );
  3540. }
  3541. } );
  3542. /*!
  3543. * jQuery UI Unique ID 1.12.0
  3544. * http://jqueryui.com
  3545. *
  3546. * Copyright jQuery Foundation and other contributors
  3547. * Released under the MIT license.
  3548. * http://jquery.org/license
  3549. */
  3550. //>>label: uniqueId
  3551. //>>group: Core
  3552. //>>description: Functions to generate and remove uniqueId's
  3553. //>>docs: http://api.jqueryui.com/uniqueId/
  3554. var uniqueId = $.fn.extend( {
  3555. uniqueId: ( function() {
  3556. var uuid = 0;
  3557. return function() {
  3558. return this.each( function() {
  3559. if ( !this.id ) {
  3560. this.id = "ui-id-" + ( ++uuid );
  3561. }
  3562. } );
  3563. };
  3564. } )(),
  3565. removeUniqueId: function() {
  3566. return this.each( function() {
  3567. if ( /^ui-id-\d+$/.test( this.id ) ) {
  3568. $( this ).removeAttr( "id" );
  3569. }
  3570. } );
  3571. }
  3572. } );
  3573. /*!
  3574. * jQuery UI Accordion 1.12.0
  3575. * http://jqueryui.com
  3576. *
  3577. * Copyright jQuery Foundation and other contributors
  3578. * Released under the MIT license.
  3579. * http://jquery.org/license
  3580. */
  3581. //>>label: Accordion
  3582. //>>group: Widgets
  3583. // jscs:disable maximumLineLength
  3584. //>>description: Displays collapsible content panels for presenting information in a limited amount of space.
  3585. // jscs:enable maximumLineLength
  3586. //>>docs: http://api.jqueryui.com/accordion/
  3587. //>>demos: http://jqueryui.com/accordion/
  3588. //>>css.structure: ../../themes/base/core.css
  3589. //>>css.structure: ../../themes/base/accordion.css
  3590. //>>css.theme: ../../themes/base/theme.css
  3591. var widgetsAccordion = $.widget( "ui.accordion", {
  3592. version: "1.12.0",
  3593. options: {
  3594. active: 0,
  3595. animate: {},
  3596. classes: {
  3597. "ui-accordion-header": "ui-corner-top",
  3598. "ui-accordion-header-collapsed": "ui-corner-all",
  3599. "ui-accordion-content": "ui-corner-bottom"
  3600. },
  3601. collapsible: false,
  3602. event: "click",
  3603. header: "> li > :first-child, > :not(li):even",
  3604. heightStyle: "auto",
  3605. icons: {
  3606. activeHeader: "ui-icon-triangle-1-s",
  3607. header: "ui-icon-triangle-1-e"
  3608. },
  3609. // Callbacks
  3610. activate: null,
  3611. beforeActivate: null
  3612. },
  3613. hideProps: {
  3614. borderTopWidth: "hide",
  3615. borderBottomWidth: "hide",
  3616. paddingTop: "hide",
  3617. paddingBottom: "hide",
  3618. height: "hide"
  3619. },
  3620. showProps: {
  3621. borderTopWidth: "show",
  3622. borderBottomWidth: "show",
  3623. paddingTop: "show",
  3624. paddingBottom: "show",
  3625. height: "show"
  3626. },
  3627. _create: function() {
  3628. var options = this.options;
  3629. this.prevShow = this.prevHide = $();
  3630. this._addClass( "ui-accordion", "ui-widget ui-helper-reset" );
  3631. this.element.attr( "role", "tablist" );
  3632. // Don't allow collapsible: false and active: false / null
  3633. if ( !options.collapsible && ( options.active === false || options.active == null ) ) {
  3634. options.active = 0;
  3635. }
  3636. this._processPanels();
  3637. // handle negative values
  3638. if ( options.active < 0 ) {
  3639. options.active += this.headers.length;
  3640. }
  3641. this._refresh();
  3642. },
  3643. _getCreateEventData: function() {
  3644. return {
  3645. header: this.active,
  3646. panel: !this.active.length ? $() : this.active.next()
  3647. };
  3648. },
  3649. _createIcons: function() {
  3650. var icon, children,
  3651. icons = this.options.icons;
  3652. if ( icons ) {
  3653. icon = $( "<span>" );
  3654. this._addClass( icon, "ui-accordion-header-icon", "ui-icon " + icons.header );
  3655. icon.prependTo( this.headers );
  3656. children = this.active.children( ".ui-accordion-header-icon" );
  3657. this._removeClass( children, icons.header )
  3658. ._addClass( children, null, icons.activeHeader )
  3659. ._addClass( this.headers, "ui-accordion-icons" );
  3660. }
  3661. },
  3662. _destroyIcons: function() {
  3663. this._removeClass( this.headers, "ui-accordion-icons" );
  3664. this.headers.children( ".ui-accordion-header-icon" ).remove();
  3665. },
  3666. _destroy: function() {
  3667. var contents;
  3668. // Clean up main element
  3669. this.element.removeAttr( "role" );
  3670. // Clean up headers
  3671. this.headers
  3672. .removeAttr( "role aria-expanded aria-selected aria-controls tabIndex" )
  3673. .removeUniqueId();
  3674. this._destroyIcons();
  3675. // Clean up content panels
  3676. contents = this.headers.next()
  3677. .css( "display", "" )
  3678. .removeAttr( "role aria-hidden aria-labelledby" )
  3679. .removeUniqueId();
  3680. if ( this.options.heightStyle !== "content" ) {
  3681. contents.css( "height", "" );
  3682. }
  3683. },
  3684. _setOption: function( key, value ) {
  3685. if ( key === "active" ) {
  3686. // _activate() will handle invalid values and update this.options
  3687. this._activate( value );
  3688. return;
  3689. }
  3690. if ( key === "event" ) {
  3691. if ( this.options.event ) {
  3692. this._off( this.headers, this.options.event );
  3693. }
  3694. this._setupEvents( value );
  3695. }
  3696. this._super( key, value );
  3697. // Setting collapsible: false while collapsed; open first panel
  3698. if ( key === "collapsible" && !value && this.options.active === false ) {
  3699. this._activate( 0 );
  3700. }
  3701. if ( key === "icons" ) {
  3702. this._destroyIcons();
  3703. if ( value ) {
  3704. this._createIcons();
  3705. }
  3706. }
  3707. },
  3708. _setOptionDisabled: function( value ) {
  3709. this._super( value );
  3710. this.element.attr( "aria-disabled", value );
  3711. // Support: IE8 Only
  3712. // #5332 / #6059 - opacity doesn't cascade to positioned elements in IE
  3713. // so we need to add the disabled class to the headers and panels
  3714. this._toggleClass( null, "ui-state-disabled", !!value );
  3715. this._toggleClass( this.headers.add( this.headers.next() ), null, "ui-state-disabled",
  3716. !!value );
  3717. },
  3718. _keydown: function( event ) {
  3719. if ( event.altKey || event.ctrlKey ) {
  3720. return;
  3721. }
  3722. var keyCode = $.ui.keyCode,
  3723. length = this.headers.length,
  3724. currentIndex = this.headers.index( event.target ),
  3725. toFocus = false;
  3726. switch ( event.keyCode ) {
  3727. case keyCode.RIGHT:
  3728. case keyCode.DOWN:
  3729. toFocus = this.headers[ ( currentIndex + 1 ) % length ];
  3730. break;
  3731. case keyCode.LEFT:
  3732. case keyCode.UP:
  3733. toFocus = this.headers[ ( currentIndex - 1 + length ) % length ];
  3734. break;
  3735. case keyCode.SPACE:
  3736. case keyCode.ENTER:
  3737. this._eventHandler( event );
  3738. break;
  3739. case keyCode.HOME:
  3740. toFocus = this.headers[ 0 ];
  3741. break;
  3742. case keyCode.END:
  3743. toFocus = this.headers[ length - 1 ];
  3744. break;
  3745. }
  3746. if ( toFocus ) {
  3747. $( event.target ).attr( "tabIndex", -1 );
  3748. $( toFocus ).attr( "tabIndex", 0 );
  3749. $( toFocus ).trigger( "focus" );
  3750. event.preventDefault();
  3751. }
  3752. },
  3753. _panelKeyDown: function( event ) {
  3754. if ( event.keyCode === $.ui.keyCode.UP && event.ctrlKey ) {
  3755. $( event.currentTarget ).prev().trigger( "focus" );
  3756. }
  3757. },
  3758. refresh: function() {
  3759. var options = this.options;
  3760. this._processPanels();
  3761. // Was collapsed or no panel
  3762. if ( ( options.active === false && options.collapsible === true ) ||
  3763. !this.headers.length ) {
  3764. options.active = false;
  3765. this.active = $();
  3766. // active false only when collapsible is true
  3767. } else if ( options.active === false ) {
  3768. this._activate( 0 );
  3769. // was active, but active panel is gone
  3770. } else if ( this.active.length && !$.contains( this.element[ 0 ], this.active[ 0 ] ) ) {
  3771. // all remaining panel are disabled
  3772. if ( this.headers.length === this.headers.find( ".ui-state-disabled" ).length ) {
  3773. options.active = false;
  3774. this.active = $();
  3775. // activate previous panel
  3776. } else {
  3777. this._activate( Math.max( 0, options.active - 1 ) );
  3778. }
  3779. // was active, active panel still exists
  3780. } else {
  3781. // make sure active index is correct
  3782. options.active = this.headers.index( this.active );
  3783. }
  3784. this._destroyIcons();
  3785. this._refresh();
  3786. },
  3787. _processPanels: function() {
  3788. var prevHeaders = this.headers,
  3789. prevPanels = this.panels;
  3790. this.headers = this.element.find( this.options.header );
  3791. this._addClass( this.headers, "ui-accordion-header ui-accordion-header-collapsed",
  3792. "ui-state-default" );
  3793. this.panels = this.headers.next().filter( ":not(.ui-accordion-content-active)" ).hide();
  3794. this._addClass( this.panels, "ui-accordion-content", "ui-helper-reset ui-widget-content" );
  3795. // Avoid memory leaks (#10056)
  3796. if ( prevPanels ) {
  3797. this._off( prevHeaders.not( this.headers ) );
  3798. this._off( prevPanels.not( this.panels ) );
  3799. }
  3800. },
  3801. _refresh: function() {
  3802. var maxHeight,
  3803. options = this.options,
  3804. heightStyle = options.heightStyle,
  3805. parent = this.element.parent();
  3806. this.active = this._findActive( options.active );
  3807. this._addClass( this.active, "ui-accordion-header-active", "ui-state-active" )
  3808. ._removeClass( this.active, "ui-accordion-header-collapsed" );
  3809. this._addClass( this.active.next(), "ui-accordion-content-active" );
  3810. this.active.next().show();
  3811. this.headers
  3812. .attr( "role", "tab" )
  3813. .each( function() {
  3814. var header = $( this ),
  3815. headerId = header.uniqueId().attr( "id" ),
  3816. panel = header.next(),
  3817. panelId = panel.uniqueId().attr( "id" );
  3818. header.attr( "aria-controls", panelId );
  3819. panel.attr( "aria-labelledby", headerId );
  3820. } )
  3821. .next()
  3822. .attr( "role", "tabpanel" );
  3823. this.headers
  3824. .not( this.active )
  3825. .attr( {
  3826. "aria-selected": "false",
  3827. "aria-expanded": "false",
  3828. tabIndex: -1
  3829. } )
  3830. .next()
  3831. .attr( {
  3832. "aria-hidden": "true"
  3833. } )
  3834. .hide();
  3835. // Make sure at least one header is in the tab order
  3836. if ( !this.active.length ) {
  3837. this.headers.eq( 0 ).attr( "tabIndex", 0 );
  3838. } else {
  3839. this.active.attr( {
  3840. "aria-selected": "true",
  3841. "aria-expanded": "true",
  3842. tabIndex: 0
  3843. } )
  3844. .next()
  3845. .attr( {
  3846. "aria-hidden": "false"
  3847. } );
  3848. }
  3849. this._createIcons();
  3850. this._setupEvents( options.event );
  3851. if ( heightStyle === "fill" ) {
  3852. maxHeight = parent.height();
  3853. this.element.siblings( ":visible" ).each( function() {
  3854. var elem = $( this ),
  3855. position = elem.css( "position" );
  3856. if ( position === "absolute" || position === "fixed" ) {
  3857. return;
  3858. }
  3859. maxHeight -= elem.outerHeight( true );
  3860. } );
  3861. this.headers.each( function() {
  3862. maxHeight -= $( this ).outerHeight( true );
  3863. } );
  3864. this.headers.next()
  3865. .each( function() {
  3866. $( this ).height( Math.max( 0, maxHeight -
  3867. $( this ).innerHeight() + $( this ).height() ) );
  3868. } )
  3869. .css( "overflow", "auto" );
  3870. } else if ( heightStyle === "auto" ) {
  3871. maxHeight = 0;
  3872. this.headers.next()
  3873. .each( function() {
  3874. var isVisible = $( this ).is( ":visible" );
  3875. if ( !isVisible ) {
  3876. $( this ).show();
  3877. }
  3878. maxHeight = Math.max( maxHeight, $( this ).css( "height", "" ).height() );
  3879. if ( !isVisible ) {
  3880. $( this ).hide();
  3881. }
  3882. } )
  3883. .height( maxHeight );
  3884. }
  3885. },
  3886. _activate: function( index ) {
  3887. var active = this._findActive( index )[ 0 ];
  3888. // Trying to activate the already active panel
  3889. if ( active === this.active[ 0 ] ) {
  3890. return;
  3891. }
  3892. // Trying to collapse, simulate a click on the currently active header
  3893. active = active || this.active[ 0 ];
  3894. this._eventHandler( {
  3895. target: active,
  3896. currentTarget: active,
  3897. preventDefault: $.noop
  3898. } );
  3899. },
  3900. _findActive: function( selector ) {
  3901. return typeof selector === "number" ? this.headers.eq( selector ) : $();
  3902. },
  3903. _setupEvents: function( event ) {
  3904. var events = {
  3905. keydown: "_keydown"
  3906. };
  3907. if ( event ) {
  3908. $.each( event.split( " " ), function( index, eventName ) {
  3909. events[ eventName ] = "_eventHandler";
  3910. } );
  3911. }
  3912. this._off( this.headers.add( this.headers.next() ) );
  3913. this._on( this.headers, events );
  3914. this._on( this.headers.next(), { keydown: "_panelKeyDown" } );
  3915. this._hoverable( this.headers );
  3916. this._focusable( this.headers );
  3917. },
  3918. _eventHandler: function( event ) {
  3919. var activeChildren, clickedChildren,
  3920. options = this.options,
  3921. active = this.active,
  3922. clicked = $( event.currentTarget ),
  3923. clickedIsActive = clicked[ 0 ] === active[ 0 ],
  3924. collapsing = clickedIsActive && options.collapsible,
  3925. toShow = collapsing ? $() : clicked.next(),
  3926. toHide = active.next(),
  3927. eventData = {
  3928. oldHeader: active,
  3929. oldPanel: toHide,
  3930. newHeader: collapsing ? $() : clicked,
  3931. newPanel: toShow
  3932. };
  3933. event.preventDefault();
  3934. if (
  3935. // click on active header, but not collapsible
  3936. ( clickedIsActive && !options.collapsible ) ||
  3937. // allow canceling activation
  3938. ( this._trigger( "beforeActivate", event, eventData ) === false ) ) {
  3939. return;
  3940. }
  3941. options.active = collapsing ? false : this.headers.index( clicked );
  3942. // When the call to ._toggle() comes after the class changes
  3943. // it causes a very odd bug in IE 8 (see #6720)
  3944. this.active = clickedIsActive ? $() : clicked;
  3945. this._toggle( eventData );
  3946. // Switch classes
  3947. // corner classes on the previously active header stay after the animation
  3948. this._removeClass( active, "ui-accordion-header-active", "ui-state-active" );
  3949. if ( options.icons ) {
  3950. activeChildren = active.children( ".ui-accordion-header-icon" );
  3951. this._removeClass( activeChildren, null, options.icons.activeHeader )
  3952. ._addClass( activeChildren, null, options.icons.header );
  3953. }
  3954. if ( !clickedIsActive ) {
  3955. this._removeClass( clicked, "ui-accordion-header-collapsed" )
  3956. ._addClass( clicked, "ui-accordion-header-active", "ui-state-active" );
  3957. if ( options.icons ) {
  3958. clickedChildren = clicked.children( ".ui-accordion-header-icon" );
  3959. this._removeClass( clickedChildren, null, options.icons.header )
  3960. ._addClass( clickedChildren, null, options.icons.activeHeader );
  3961. }
  3962. this._addClass( clicked.next(), "ui-accordion-content-active" );
  3963. }
  3964. },
  3965. _toggle: function( data ) {
  3966. var toShow = data.newPanel,
  3967. toHide = this.prevShow.length ? this.prevShow : data.oldPanel;
  3968. // Handle activating a panel during the animation for another activation
  3969. this.prevShow.add( this.prevHide ).stop( true, true );
  3970. this.prevShow = toShow;
  3971. this.prevHide = toHide;
  3972. if ( this.options.animate ) {
  3973. this._animate( toShow, toHide, data );
  3974. } else {
  3975. toHide.hide();
  3976. toShow.show();
  3977. this._toggleComplete( data );
  3978. }
  3979. toHide.attr( {
  3980. "aria-hidden": "true"
  3981. } );
  3982. toHide.prev().attr( {
  3983. "aria-selected": "false",
  3984. "aria-expanded": "false"
  3985. } );
  3986. // if we're switching panels, remove the old header from the tab order
  3987. // if we're opening from collapsed state, remove the previous header from the tab order
  3988. // if we're collapsing, then keep the collapsing header in the tab order
  3989. if ( toShow.length && toHide.length ) {
  3990. toHide.prev().attr( {
  3991. "tabIndex": -1,
  3992. "aria-expanded": "false"
  3993. } );
  3994. } else if ( toShow.length ) {
  3995. this.headers.filter( function() {
  3996. return parseInt( $( this ).attr( "tabIndex" ), 10 ) === 0;
  3997. } )
  3998. .attr( "tabIndex", -1 );
  3999. }
  4000. toShow
  4001. .attr( "aria-hidden", "false" )
  4002. .prev()
  4003. .attr( {
  4004. "aria-selected": "true",
  4005. "aria-expanded": "true",
  4006. tabIndex: 0
  4007. } );
  4008. },
  4009. _animate: function( toShow, toHide, data ) {
  4010. var total, easing, duration,
  4011. that = this,
  4012. adjust = 0,
  4013. boxSizing = toShow.css( "box-sizing" ),
  4014. down = toShow.length &&
  4015. ( !toHide.length || ( toShow.index() < toHide.index() ) ),
  4016. animate = this.options.animate || {},
  4017. options = down && animate.down || animate,
  4018. complete = function() {
  4019. that._toggleComplete( data );
  4020. };
  4021. if ( typeof options === "number" ) {
  4022. duration = options;
  4023. }
  4024. if ( typeof options === "string" ) {
  4025. easing = options;
  4026. }
  4027. // fall back from options to animation in case of partial down settings
  4028. easing = easing || options.easing || animate.easing;
  4029. duration = duration || options.duration || animate.duration;
  4030. if ( !toHide.length ) {
  4031. return toShow.animate( this.showProps, duration, easing, complete );
  4032. }
  4033. if ( !toShow.length ) {
  4034. return toHide.animate( this.hideProps, duration, easing, complete );
  4035. }
  4036. total = toShow.show().outerHeight();
  4037. toHide.animate( this.hideProps, {
  4038. duration: duration,
  4039. easing: easing,
  4040. step: function( now, fx ) {
  4041. fx.now = Math.round( now );
  4042. }
  4043. } );
  4044. toShow
  4045. .hide()
  4046. .animate( this.showProps, {
  4047. duration: duration,
  4048. easing: easing,
  4049. complete: complete,
  4050. step: function( now, fx ) {
  4051. fx.now = Math.round( now );
  4052. if ( fx.prop !== "height" ) {
  4053. if ( boxSizing === "content-box" ) {
  4054. adjust += fx.now;
  4055. }
  4056. } else if ( that.options.heightStyle !== "content" ) {
  4057. fx.now = Math.round( total - toHide.outerHeight() - adjust );
  4058. adjust = 0;
  4059. }
  4060. }
  4061. } );
  4062. },
  4063. _toggleComplete: function( data ) {
  4064. var toHide = data.oldPanel,
  4065. prev = toHide.prev();
  4066. this._removeClass( toHide, "ui-accordion-content-active" );
  4067. this._removeClass( prev, "ui-accordion-header-active" )
  4068. ._addClass( prev, "ui-accordion-header-collapsed" );
  4069. // Work around for rendering bug in IE (#5421)
  4070. if ( toHide.length ) {
  4071. toHide.parent()[ 0 ].className = toHide.parent()[ 0 ].className;
  4072. }
  4073. this._trigger( "activate", null, data );
  4074. }
  4075. } );
  4076. var safeActiveElement = $.ui.safeActiveElement = function( document ) {
  4077. var activeElement;
  4078. // Support: IE 9 only
  4079. // IE9 throws an "Unspecified error" accessing document.activeElement from an <iframe>
  4080. try {
  4081. activeElement = document.activeElement;
  4082. } catch ( error ) {
  4083. activeElement = document.body;
  4084. }
  4085. // Support: IE 9 - 11 only
  4086. // IE may return null instead of an element
  4087. // Interestingly, this only seems to occur when NOT in an iframe
  4088. if ( !activeElement ) {
  4089. activeElement = document.body;
  4090. }
  4091. // Support: IE 11 only
  4092. // IE11 returns a seemingly empty object in some cases when accessing
  4093. // document.activeElement from an <iframe>
  4094. if ( !activeElement.nodeName ) {
  4095. activeElement = document.body;
  4096. }
  4097. return activeElement;
  4098. };
  4099. /*!
  4100. * jQuery UI Menu 1.12.0
  4101. * http://jqueryui.com
  4102. *
  4103. * Copyright jQuery Foundation and other contributors
  4104. * Released under the MIT license.
  4105. * http://jquery.org/license
  4106. */
  4107. //>>label: Menu
  4108. //>>group: Widgets
  4109. //>>description: Creates nestable menus.
  4110. //>>docs: http://api.jqueryui.com/menu/
  4111. //>>demos: http://jqueryui.com/menu/
  4112. //>>css.structure: ../../themes/base/core.css
  4113. //>>css.structure: ../../themes/base/menu.css
  4114. //>>css.theme: ../../themes/base/theme.css
  4115. var widgetsMenu = $.widget( "ui.menu", {
  4116. version: "1.12.0",
  4117. defaultElement: "<ul>",
  4118. delay: 300,
  4119. options: {
  4120. icons: {
  4121. submenu: "ui-icon-caret-1-e"
  4122. },
  4123. items: "> *",
  4124. menus: "ul",
  4125. position: {
  4126. my: "left top",
  4127. at: "right top"
  4128. },
  4129. role: "menu",
  4130. // Callbacks
  4131. blur: null,
  4132. focus: null,
  4133. select: null
  4134. },
  4135. _create: function() {
  4136. this.activeMenu = this.element;
  4137. // Flag used to prevent firing of the click handler
  4138. // as the event bubbles up through nested menus
  4139. this.mouseHandled = false;
  4140. this.element
  4141. .uniqueId()
  4142. .attr( {
  4143. role: this.options.role,
  4144. tabIndex: 0
  4145. } );
  4146. this._addClass( "ui-menu", "ui-widget ui-widget-content" );
  4147. this._on( {
  4148. // Prevent focus from sticking to links inside menu after clicking
  4149. // them (focus should always stay on UL during navigation).
  4150. "mousedown .ui-menu-item": function( event ) {
  4151. event.preventDefault();
  4152. },
  4153. "click .ui-menu-item": function( event ) {
  4154. var target = $( event.target );
  4155. var active = $( $.ui.safeActiveElement( this.document[ 0 ] ) );
  4156. if ( !this.mouseHandled && target.not( ".ui-state-disabled" ).length ) {
  4157. this.select( event );
  4158. // Only set the mouseHandled flag if the event will bubble, see #9469.
  4159. if ( !event.isPropagationStopped() ) {
  4160. this.mouseHandled = true;
  4161. }
  4162. // Open submenu on click
  4163. if ( target.has( ".ui-menu" ).length ) {
  4164. this.expand( event );
  4165. } else if ( !this.element.is( ":focus" ) &&
  4166. active.closest( ".ui-menu" ).length ) {
  4167. // Redirect focus to the menu
  4168. this.element.trigger( "focus", [ true ] );
  4169. // If the active item is on the top level, let it stay active.
  4170. // Otherwise, blur the active item since it is no longer visible.
  4171. if ( this.active && this.active.parents( ".ui-menu" ).length === 1 ) {
  4172. clearTimeout( this.timer );
  4173. }
  4174. }
  4175. }
  4176. },
  4177. "mouseenter .ui-menu-item": function( event ) {
  4178. // Ignore mouse events while typeahead is active, see #10458.
  4179. // Prevents focusing the wrong item when typeahead causes a scroll while the mouse
  4180. // is over an item in the menu
  4181. if ( this.previousFilter ) {
  4182. return;
  4183. }
  4184. var actualTarget = $( event.target ).closest( ".ui-menu-item" ),
  4185. target = $( event.currentTarget );
  4186. // Ignore bubbled events on parent items, see #11641
  4187. if ( actualTarget[ 0 ] !== target[ 0 ] ) {
  4188. return;
  4189. }
  4190. // Remove ui-state-active class from siblings of the newly focused menu item
  4191. // to avoid a jump caused by adjacent elements both having a class with a border
  4192. this._removeClass( target.siblings().children( ".ui-state-active" ),
  4193. null, "ui-state-active" );
  4194. this.focus( event, target );
  4195. },
  4196. mouseleave: "collapseAll",
  4197. "mouseleave .ui-menu": "collapseAll",
  4198. focus: function( event, keepActiveItem ) {
  4199. // If there's already an active item, keep it active
  4200. // If not, activate the first item
  4201. var item = this.active || this.element.find( this.options.items ).eq( 0 );
  4202. if ( !keepActiveItem ) {
  4203. this.focus( event, item );
  4204. }
  4205. },
  4206. blur: function( event ) {
  4207. this._delay( function() {
  4208. var notContained = !$.contains(
  4209. this.element[ 0 ],
  4210. $.ui.safeActiveElement( this.document[ 0 ] )
  4211. );
  4212. if ( notContained ) {
  4213. this.collapseAll( event );
  4214. }
  4215. } );
  4216. },
  4217. keydown: "_keydown"
  4218. } );
  4219. this.refresh();
  4220. // Clicks outside of a menu collapse any open menus
  4221. this._on( this.document, {
  4222. click: function( event ) {
  4223. if ( this._closeOnDocumentClick( event ) ) {
  4224. this.collapseAll( event );
  4225. }
  4226. // Reset the mouseHandled flag
  4227. this.mouseHandled = false;
  4228. }
  4229. } );
  4230. },
  4231. _destroy: function() {
  4232. var items = this.element.find( ".ui-menu-item" )
  4233. .removeAttr( "role aria-disabled" ),
  4234. submenus = items.children( ".ui-menu-item-wrapper" )
  4235. .removeUniqueId()
  4236. .removeAttr( "tabIndex role aria-haspopup" );
  4237. // Destroy (sub)menus
  4238. this.element
  4239. .removeAttr( "aria-activedescendant" )
  4240. .find( ".ui-menu" ).addBack()
  4241. .removeAttr( "role aria-labelledby aria-expanded aria-hidden aria-disabled " +
  4242. "tabIndex" )
  4243. .removeUniqueId()
  4244. .show();
  4245. submenus.children().each( function() {
  4246. var elem = $( this );
  4247. if ( elem.data( "ui-menu-submenu-caret" ) ) {
  4248. elem.remove();
  4249. }
  4250. } );
  4251. },
  4252. _keydown: function( event ) {
  4253. var match, prev, character, skip,
  4254. preventDefault = true;
  4255. switch ( event.keyCode ) {
  4256. case $.ui.keyCode.PAGE_UP:
  4257. this.previousPage( event );
  4258. break;
  4259. case $.ui.keyCode.PAGE_DOWN:
  4260. this.nextPage( event );
  4261. break;
  4262. case $.ui.keyCode.HOME:
  4263. this._move( "first", "first", event );
  4264. break;
  4265. case $.ui.keyCode.END:
  4266. this._move( "last", "last", event );
  4267. break;
  4268. case $.ui.keyCode.UP:
  4269. this.previous( event );
  4270. break;
  4271. case $.ui.keyCode.DOWN:
  4272. this.next( event );
  4273. break;
  4274. case $.ui.keyCode.LEFT:
  4275. this.collapse( event );
  4276. break;
  4277. case $.ui.keyCode.RIGHT:
  4278. if ( this.active && !this.active.is( ".ui-state-disabled" ) ) {
  4279. this.expand( event );
  4280. }
  4281. break;
  4282. case $.ui.keyCode.ENTER:
  4283. case $.ui.keyCode.SPACE:
  4284. this._activate( event );
  4285. break;
  4286. case $.ui.keyCode.ESCAPE:
  4287. this.collapse( event );
  4288. break;
  4289. default:
  4290. preventDefault = false;
  4291. prev = this.previousFilter || "";
  4292. character = String.fromCharCode( event.keyCode );
  4293. skip = false;
  4294. clearTimeout( this.filterTimer );
  4295. if ( character === prev ) {
  4296. skip = true;
  4297. } else {
  4298. character = prev + character;
  4299. }
  4300. match = this._filterMenuItems( character );
  4301. match = skip && match.index( this.active.next() ) !== -1 ?
  4302. this.active.nextAll( ".ui-menu-item" ) :
  4303. match;
  4304. // If no matches on the current filter, reset to the last character pressed
  4305. // to move down the menu to the first item that starts with that character
  4306. if ( !match.length ) {
  4307. character = String.fromCharCode( event.keyCode );
  4308. match = this._filterMenuItems( character );
  4309. }
  4310. if ( match.length ) {
  4311. this.focus( event, match );
  4312. this.previousFilter = character;
  4313. this.filterTimer = this._delay( function() {
  4314. delete this.previousFilter;
  4315. }, 1000 );
  4316. } else {
  4317. delete this.previousFilter;
  4318. }
  4319. }
  4320. if ( preventDefault ) {
  4321. event.preventDefault();
  4322. }
  4323. },
  4324. _activate: function( event ) {
  4325. if ( this.active && !this.active.is( ".ui-state-disabled" ) ) {
  4326. if ( this.active.children( "[aria-haspopup='true']" ).length ) {
  4327. this.expand( event );
  4328. } else {
  4329. this.select( event );
  4330. }
  4331. }
  4332. },
  4333. refresh: function() {
  4334. var menus, items, newSubmenus, newItems, newWrappers,
  4335. that = this,
  4336. icon = this.options.icons.submenu,
  4337. submenus = this.element.find( this.options.menus );
  4338. this._toggleClass( "ui-menu-icons", null, !!this.element.find( ".ui-icon" ).length );
  4339. // Initialize nested menus
  4340. newSubmenus = submenus.filter( ":not(.ui-menu)" )
  4341. .hide()
  4342. .attr( {
  4343. role: this.options.role,
  4344. "aria-hidden": "true",
  4345. "aria-expanded": "false"
  4346. } )
  4347. .each( function() {
  4348. var menu = $( this ),
  4349. item = menu.prev(),
  4350. submenuCaret = $( "<span>" ).data( "ui-menu-submenu-caret", true );
  4351. that._addClass( submenuCaret, "ui-menu-icon", "ui-icon " + icon );
  4352. item
  4353. .attr( "aria-haspopup", "true" )
  4354. .prepend( submenuCaret );
  4355. menu.attr( "aria-labelledby", item.attr( "id" ) );
  4356. } );
  4357. this._addClass( newSubmenus, "ui-menu", "ui-widget ui-widget-content ui-front" );
  4358. menus = submenus.add( this.element );
  4359. items = menus.find( this.options.items );
  4360. // Initialize menu-items containing spaces and/or dashes only as dividers
  4361. items.not( ".ui-menu-item" ).each( function() {
  4362. var item = $( this );
  4363. if ( that._isDivider( item ) ) {
  4364. that._addClass( item, "ui-menu-divider", "ui-widget-content" );
  4365. }
  4366. } );
  4367. // Don't refresh list items that are already adapted
  4368. newItems = items.not( ".ui-menu-item, .ui-menu-divider" );
  4369. newWrappers = newItems.children()
  4370. .not( ".ui-menu" )
  4371. .uniqueId()
  4372. .attr( {
  4373. tabIndex: -1,
  4374. role: this._itemRole()
  4375. } );
  4376. this._addClass( newItems, "ui-menu-item" )
  4377. ._addClass( newWrappers, "ui-menu-item-wrapper" );
  4378. // Add aria-disabled attribute to any disabled menu item
  4379. items.filter( ".ui-state-disabled" ).attr( "aria-disabled", "true" );
  4380. // If the active item has been removed, blur the menu
  4381. if ( this.active && !$.contains( this.element[ 0 ], this.active[ 0 ] ) ) {
  4382. this.blur();
  4383. }
  4384. },
  4385. _itemRole: function() {
  4386. return {
  4387. menu: "menuitem",
  4388. listbox: "option"
  4389. }[ this.options.role ];
  4390. },
  4391. _setOption: function( key, value ) {
  4392. if ( key === "icons" ) {
  4393. var icons = this.element.find( ".ui-menu-icon" );
  4394. this._removeClass( icons, null, this.options.icons.submenu )
  4395. ._addClass( icons, null, value.submenu );
  4396. }
  4397. this._super( key, value );
  4398. },
  4399. _setOptionDisabled: function( value ) {
  4400. this._super( value );
  4401. this.element.attr( "aria-disabled", String( value ) );
  4402. this._toggleClass( null, "ui-state-disabled", !!value );
  4403. },
  4404. focus: function( event, item ) {
  4405. var nested, focused, activeParent;
  4406. this.blur( event, event && event.type === "focus" );
  4407. this._scrollIntoView( item );
  4408. this.active = item.first();
  4409. focused = this.active.children( ".ui-menu-item-wrapper" );
  4410. this._addClass( focused, null, "ui-state-active" );
  4411. // Only update aria-activedescendant if there's a role
  4412. // otherwise we assume focus is managed elsewhere
  4413. if ( this.options.role ) {
  4414. this.element.attr( "aria-activedescendant", focused.attr( "id" ) );
  4415. }
  4416. // Highlight active parent menu item, if any
  4417. activeParent = this.active
  4418. .parent()
  4419. .closest( ".ui-menu-item" )
  4420. .children( ".ui-menu-item-wrapper" );
  4421. this._addClass( activeParent, null, "ui-state-active" );
  4422. if ( event && event.type === "keydown" ) {
  4423. this._close();
  4424. } else {
  4425. this.timer = this._delay( function() {
  4426. this._close();
  4427. }, this.delay );
  4428. }
  4429. nested = item.children( ".ui-menu" );
  4430. if ( nested.length && event && ( /^mouse/.test( event.type ) ) ) {
  4431. this._startOpening( nested );
  4432. }
  4433. this.activeMenu = item.parent();
  4434. this._trigger( "focus", event, { item: item } );
  4435. },
  4436. _scrollIntoView: function( item ) {
  4437. var borderTop, paddingTop, offset, scroll, elementHeight, itemHeight;
  4438. if ( this._hasScroll() ) {
  4439. borderTop = parseFloat( $.css( this.activeMenu[ 0 ], "borderTopWidth" ) ) || 0;
  4440. paddingTop = parseFloat( $.css( this.activeMenu[ 0 ], "paddingTop" ) ) || 0;
  4441. offset = item.offset().top - this.activeMenu.offset().top - borderTop - paddingTop;
  4442. scroll = this.activeMenu.scrollTop();
  4443. elementHeight = this.activeMenu.height();
  4444. itemHeight = item.outerHeight();
  4445. if ( offset < 0 ) {
  4446. this.activeMenu.scrollTop( scroll + offset );
  4447. } else if ( offset + itemHeight > elementHeight ) {
  4448. this.activeMenu.scrollTop( scroll + offset - elementHeight + itemHeight );
  4449. }
  4450. }
  4451. },
  4452. blur: function( event, fromFocus ) {
  4453. if ( !fromFocus ) {
  4454. clearTimeout( this.timer );
  4455. }
  4456. if ( !this.active ) {
  4457. return;
  4458. }
  4459. this._removeClass( this.active.children( ".ui-menu-item-wrapper" ),
  4460. null, "ui-state-active" );
  4461. this._trigger( "blur", event, { item: this.active } );
  4462. this.active = null;
  4463. },
  4464. _startOpening: function( submenu ) {
  4465. clearTimeout( this.timer );
  4466. // Don't open if already open fixes a Firefox bug that caused a .5 pixel
  4467. // shift in the submenu position when mousing over the caret icon
  4468. if ( submenu.attr( "aria-hidden" ) !== "true" ) {
  4469. return;
  4470. }
  4471. this.timer = this._delay( function() {
  4472. this._close();
  4473. this._open( submenu );
  4474. }, this.delay );
  4475. },
  4476. _open: function( submenu ) {
  4477. var position = $.extend( {
  4478. of: this.active
  4479. }, this.options.position );
  4480. clearTimeout( this.timer );
  4481. this.element.find( ".ui-menu" ).not( submenu.parents( ".ui-menu" ) )
  4482. .hide()
  4483. .attr( "aria-hidden", "true" );
  4484. submenu
  4485. .show()
  4486. .removeAttr( "aria-hidden" )
  4487. .attr( "aria-expanded", "true" )
  4488. .position( position );
  4489. },
  4490. collapseAll: function( event, all ) {
  4491. clearTimeout( this.timer );
  4492. this.timer = this._delay( function() {
  4493. // If we were passed an event, look for the submenu that contains the event
  4494. var currentMenu = all ? this.element :
  4495. $( event && event.target ).closest( this.element.find( ".ui-menu" ) );
  4496. // If we found no valid submenu ancestor, use the main menu to close all
  4497. // sub menus anyway
  4498. if ( !currentMenu.length ) {
  4499. currentMenu = this.element;
  4500. }
  4501. this._close( currentMenu );
  4502. this.blur( event );
  4503. // Work around active item staying active after menu is blurred
  4504. this._removeClass( currentMenu.find( ".ui-state-active" ), null, "ui-state-active" );
  4505. this.activeMenu = currentMenu;
  4506. }, this.delay );
  4507. },
  4508. // With no arguments, closes the currently active menu - if nothing is active
  4509. // it closes all menus. If passed an argument, it will search for menus BELOW
  4510. _close: function( startMenu ) {
  4511. if ( !startMenu ) {
  4512. startMenu = this.active ? this.active.parent() : this.element;
  4513. }
  4514. startMenu.find( ".ui-menu" )
  4515. .hide()
  4516. .attr( "aria-hidden", "true" )
  4517. .attr( "aria-expanded", "false" );
  4518. },
  4519. _closeOnDocumentClick: function( event ) {
  4520. return !$( event.target ).closest( ".ui-menu" ).length;
  4521. },
  4522. _isDivider: function( item ) {
  4523. // Match hyphen, em dash, en dash
  4524. return !/[^\-\u2014\u2013\s]/.test( item.text() );
  4525. },
  4526. collapse: function( event ) {
  4527. var newItem = this.active &&
  4528. this.active.parent().closest( ".ui-menu-item", this.element );
  4529. if ( newItem && newItem.length ) {
  4530. this._close();
  4531. this.focus( event, newItem );
  4532. }
  4533. },
  4534. expand: function( event ) {
  4535. var newItem = this.active &&
  4536. this.active
  4537. .children( ".ui-menu " )
  4538. .find( this.options.items )
  4539. .first();
  4540. if ( newItem && newItem.length ) {
  4541. this._open( newItem.parent() );
  4542. // Delay so Firefox will not hide activedescendant change in expanding submenu from AT
  4543. this._delay( function() {
  4544. this.focus( event, newItem );
  4545. } );
  4546. }
  4547. },
  4548. next: function( event ) {
  4549. this._move( "next", "first", event );
  4550. },
  4551. previous: function( event ) {
  4552. this._move( "prev", "last", event );
  4553. },
  4554. isFirstItem: function() {
  4555. return this.active && !this.active.prevAll( ".ui-menu-item" ).length;
  4556. },
  4557. isLastItem: function() {
  4558. return this.active && !this.active.nextAll( ".ui-menu-item" ).length;
  4559. },
  4560. _move: function( direction, filter, event ) {
  4561. var next;
  4562. if ( this.active ) {
  4563. if ( direction === "first" || direction === "last" ) {
  4564. next = this.active
  4565. [ direction === "first" ? "prevAll" : "nextAll" ]( ".ui-menu-item" )
  4566. .eq( -1 );
  4567. } else {
  4568. next = this.active
  4569. [ direction + "All" ]( ".ui-menu-item" )
  4570. .eq( 0 );
  4571. }
  4572. }
  4573. if ( !next || !next.length || !this.active ) {
  4574. next = this.activeMenu.find( this.options.items )[ filter ]();
  4575. }
  4576. this.focus( event, next );
  4577. },
  4578. nextPage: function( event ) {
  4579. var item, base, height;
  4580. if ( !this.active ) {
  4581. this.next( event );
  4582. return;
  4583. }
  4584. if ( this.isLastItem() ) {
  4585. return;
  4586. }
  4587. if ( this._hasScroll() ) {
  4588. base = this.active.offset().top;
  4589. height = this.element.height();
  4590. this.active.nextAll( ".ui-menu-item" ).each( function() {
  4591. item = $( this );
  4592. return item.offset().top - base - height < 0;
  4593. } );
  4594. this.focus( event, item );
  4595. } else {
  4596. this.focus( event, this.activeMenu.find( this.options.items )
  4597. [ !this.active ? "first" : "last" ]() );
  4598. }
  4599. },
  4600. previousPage: function( event ) {
  4601. var item, base, height;
  4602. if ( !this.active ) {
  4603. this.next( event );
  4604. return;
  4605. }
  4606. if ( this.isFirstItem() ) {
  4607. return;
  4608. }
  4609. if ( this._hasScroll() ) {
  4610. base = this.active.offset().top;
  4611. height = this.element.height();
  4612. this.active.prevAll( ".ui-menu-item" ).each( function() {
  4613. item = $( this );
  4614. return item.offset().top - base + height > 0;
  4615. } );
  4616. this.focus( event, item );
  4617. } else {
  4618. this.focus( event, this.activeMenu.find( this.options.items ).first() );
  4619. }
  4620. },
  4621. _hasScroll: function() {
  4622. return this.element.outerHeight() < this.element.prop( "scrollHeight" );
  4623. },
  4624. select: function( event ) {
  4625. // TODO: It should never be possible to not have an active item at this
  4626. // point, but the tests don't trigger mouseenter before click.
  4627. this.active = this.active || $( event.target ).closest( ".ui-menu-item" );
  4628. var ui = { item: this.active };
  4629. if ( !this.active.has( ".ui-menu" ).length ) {
  4630. this.collapseAll( event, true );
  4631. }
  4632. this._trigger( "select", event, ui );
  4633. },
  4634. _filterMenuItems: function( character ) {
  4635. var escapedCharacter = character.replace( /[\-\[\]{}()*+?.,\\\^$|#\s]/g, "\\$&" ),
  4636. regex = new RegExp( "^" + escapedCharacter, "i" );
  4637. return this.activeMenu
  4638. .find( this.options.items )
  4639. // Only match on items, not dividers or other content (#10571)
  4640. .filter( ".ui-menu-item" )
  4641. .filter( function() {
  4642. return regex.test(
  4643. $.trim( $( this ).children( ".ui-menu-item-wrapper" ).text() ) );
  4644. } );
  4645. }
  4646. } );
  4647. /*!
  4648. * jQuery UI Autocomplete 1.12.0
  4649. * http://jqueryui.com
  4650. *
  4651. * Copyright jQuery Foundation and other contributors
  4652. * Released under the MIT license.
  4653. * http://jquery.org/license
  4654. */
  4655. //>>label: Autocomplete
  4656. //>>group: Widgets
  4657. //>>description: Lists suggested words as the user is typing.
  4658. //>>docs: http://api.jqueryui.com/autocomplete/
  4659. //>>demos: http://jqueryui.com/autocomplete/
  4660. //>>css.structure: ../../themes/base/core.css
  4661. //>>css.structure: ../../themes/base/autocomplete.css
  4662. //>>css.theme: ../../themes/base/theme.css
  4663. $.widget( "ui.autocomplete", {
  4664. version: "1.12.0",
  4665. defaultElement: "<input>",
  4666. options: {
  4667. appendTo: null,
  4668. autoFocus: false,
  4669. delay: 300,
  4670. minLength: 1,
  4671. position: {
  4672. my: "left top",
  4673. at: "left bottom",
  4674. collision: "none"
  4675. },
  4676. source: null,
  4677. // Callbacks
  4678. change: null,
  4679. close: null,
  4680. focus: null,
  4681. open: null,
  4682. response: null,
  4683. search: null,
  4684. select: null
  4685. },
  4686. requestIndex: 0,
  4687. pending: 0,
  4688. _create: function() {
  4689. // Some browsers only repeat keydown events, not keypress events,
  4690. // so we use the suppressKeyPress flag to determine if we've already
  4691. // handled the keydown event. #7269
  4692. // Unfortunately the code for & in keypress is the same as the up arrow,
  4693. // so we use the suppressKeyPressRepeat flag to avoid handling keypress
  4694. // events when we know the keydown event was used to modify the
  4695. // search term. #7799
  4696. var suppressKeyPress, suppressKeyPressRepeat, suppressInput,
  4697. nodeName = this.element[ 0 ].nodeName.toLowerCase(),
  4698. isTextarea = nodeName === "textarea",
  4699. isInput = nodeName === "input";
  4700. // Textareas are always multi-line
  4701. // Inputs are always single-line, even if inside a contentEditable element
  4702. // IE also treats inputs as contentEditable
  4703. // All other element types are determined by whether or not they're contentEditable
  4704. this.isMultiLine = isTextarea || !isInput && this._isContentEditable( this.element );
  4705. this.valueMethod = this.element[ isTextarea || isInput ? "val" : "text" ];
  4706. this.isNewMenu = true;
  4707. this._addClass( "ui-autocomplete-input" );
  4708. this.element.attr( "autocomplete", "off" );
  4709. this._on( this.element, {
  4710. keydown: function( event ) {
  4711. if ( this.element.prop( "readOnly" ) ) {
  4712. suppressKeyPress = true;
  4713. suppressInput = true;
  4714. suppressKeyPressRepeat = true;
  4715. return;
  4716. }
  4717. suppressKeyPress = false;
  4718. suppressInput = false;
  4719. suppressKeyPressRepeat = false;
  4720. var keyCode = $.ui.keyCode;
  4721. switch ( event.keyCode ) {
  4722. case keyCode.PAGE_UP:
  4723. suppressKeyPress = true;
  4724. this._move( "previousPage", event );
  4725. break;
  4726. case keyCode.PAGE_DOWN:
  4727. suppressKeyPress = true;
  4728. this._move( "nextPage", event );
  4729. break;
  4730. case keyCode.UP:
  4731. suppressKeyPress = true;
  4732. this._keyEvent( "previous", event );
  4733. break;
  4734. case keyCode.DOWN:
  4735. suppressKeyPress = true;
  4736. this._keyEvent( "next", event );
  4737. break;
  4738. case keyCode.ENTER:
  4739. // when menu is open and has focus
  4740. if ( this.menu.active ) {
  4741. // #6055 - Opera still allows the keypress to occur
  4742. // which causes forms to submit
  4743. suppressKeyPress = true;
  4744. event.preventDefault();
  4745. this.menu.select( event );
  4746. }
  4747. break;
  4748. case keyCode.TAB:
  4749. if ( this.menu.active ) {
  4750. this.menu.select( event );
  4751. }
  4752. break;
  4753. case keyCode.ESCAPE:
  4754. if ( this.menu.element.is( ":visible" ) ) {
  4755. if ( !this.isMultiLine ) {
  4756. this._value( this.term );
  4757. }
  4758. this.close( event );
  4759. // Different browsers have different default behavior for escape
  4760. // Single press can mean undo or clear
  4761. // Double press in IE means clear the whole form
  4762. event.preventDefault();
  4763. }
  4764. break;
  4765. default:
  4766. suppressKeyPressRepeat = true;
  4767. // search timeout should be triggered before the input value is changed
  4768. this._searchTimeout( event );
  4769. break;
  4770. }
  4771. },
  4772. keypress: function( event ) {
  4773. if ( suppressKeyPress ) {
  4774. suppressKeyPress = false;
  4775. if ( !this.isMultiLine || this.menu.element.is( ":visible" ) ) {
  4776. event.preventDefault();
  4777. }
  4778. return;
  4779. }
  4780. if ( suppressKeyPressRepeat ) {
  4781. return;
  4782. }
  4783. // Replicate some key handlers to allow them to repeat in Firefox and Opera
  4784. var keyCode = $.ui.keyCode;
  4785. switch ( event.keyCode ) {
  4786. case keyCode.PAGE_UP:
  4787. this._move( "previousPage", event );
  4788. break;
  4789. case keyCode.PAGE_DOWN:
  4790. this._move( "nextPage", event );
  4791. break;
  4792. case keyCode.UP:
  4793. this._keyEvent( "previous", event );
  4794. break;
  4795. case keyCode.DOWN:
  4796. this._keyEvent( "next", event );
  4797. break;
  4798. }
  4799. },
  4800. input: function( event ) {
  4801. if ( suppressInput ) {
  4802. suppressInput = false;
  4803. event.preventDefault();
  4804. return;
  4805. }
  4806. this._searchTimeout( event );
  4807. },
  4808. focus: function() {
  4809. this.selectedItem = null;
  4810. this.previous = this._value();
  4811. },
  4812. blur: function( event ) {
  4813. if ( this.cancelBlur ) {
  4814. delete this.cancelBlur;
  4815. return;
  4816. }
  4817. clearTimeout( this.searching );
  4818. this.close( event );
  4819. this._change( event );
  4820. }
  4821. } );
  4822. this._initSource();
  4823. this.menu = $( "<ul>" )
  4824. .appendTo( this._appendTo() )
  4825. .menu( {
  4826. // disable ARIA support, the live region takes care of that
  4827. role: null
  4828. } )
  4829. .hide()
  4830. .menu( "instance" );
  4831. this._addClass( this.menu.element, "ui-autocomplete", "ui-front" );
  4832. this._on( this.menu.element, {
  4833. mousedown: function( event ) {
  4834. // prevent moving focus out of the text field
  4835. event.preventDefault();
  4836. // IE doesn't prevent moving focus even with event.preventDefault()
  4837. // so we set a flag to know when we should ignore the blur event
  4838. this.cancelBlur = true;
  4839. this._delay( function() {
  4840. delete this.cancelBlur;
  4841. // Support: IE 8 only
  4842. // Right clicking a menu item or selecting text from the menu items will
  4843. // result in focus moving out of the input. However, we've already received
  4844. // and ignored the blur event because of the cancelBlur flag set above. So
  4845. // we restore focus to ensure that the menu closes properly based on the user's
  4846. // next actions.
  4847. if ( this.element[ 0 ] !== $.ui.safeActiveElement( this.document[ 0 ] ) ) {
  4848. this.element.trigger( "focus" );
  4849. }
  4850. } );
  4851. },
  4852. menufocus: function( event, ui ) {
  4853. var label, item;
  4854. // support: Firefox
  4855. // Prevent accidental activation of menu items in Firefox (#7024 #9118)
  4856. if ( this.isNewMenu ) {
  4857. this.isNewMenu = false;
  4858. if ( event.originalEvent && /^mouse/.test( event.originalEvent.type ) ) {
  4859. this.menu.blur();
  4860. this.document.one( "mousemove", function() {
  4861. $( event.target ).trigger( event.originalEvent );
  4862. } );
  4863. return;
  4864. }
  4865. }
  4866. item = ui.item.data( "ui-autocomplete-item" );
  4867. if ( false !== this._trigger( "focus", event, { item: item } ) ) {
  4868. // use value to match what will end up in the input, if it was a key event
  4869. if ( event.originalEvent && /^key/.test( event.originalEvent.type ) ) {
  4870. this._value( item.value );
  4871. }
  4872. }
  4873. // Announce the value in the liveRegion
  4874. label = ui.item.attr( "aria-label" ) || item.value;
  4875. if ( label && $.trim( label ).length ) {
  4876. this.liveRegion.children().hide();
  4877. $( "<div>" ).text( label ).appendTo( this.liveRegion );
  4878. }
  4879. },
  4880. menuselect: function( event, ui ) {
  4881. var item = ui.item.data( "ui-autocomplete-item" ),
  4882. previous = this.previous;
  4883. // Only trigger when focus was lost (click on menu)
  4884. if ( this.element[ 0 ] !== $.ui.safeActiveElement( this.document[ 0 ] ) ) {
  4885. this.element.trigger( "focus" );
  4886. this.previous = previous;
  4887. // #6109 - IE triggers two focus events and the second
  4888. // is asynchronous, so we need to reset the previous
  4889. // term synchronously and asynchronously :-(
  4890. this._delay( function() {
  4891. this.previous = previous;
  4892. this.selectedItem = item;
  4893. } );
  4894. }
  4895. if ( false !== this._trigger( "select", event, { item: item } ) ) {
  4896. this._value( item.value );
  4897. }
  4898. // reset the term after the select event
  4899. // this allows custom select handling to work properly
  4900. this.term = this._value();
  4901. this.close( event );
  4902. this.selectedItem = item;
  4903. }
  4904. } );
  4905. this.liveRegion = $( "<div>", {
  4906. role: "status",
  4907. "aria-live": "assertive",
  4908. "aria-relevant": "additions"
  4909. } )
  4910. .appendTo( this.document[ 0 ].body );
  4911. this._addClass( this.liveRegion, null, "ui-helper-hidden-accessible" );
  4912. // Turning off autocomplete prevents the browser from remembering the
  4913. // value when navigating through history, so we re-enable autocomplete
  4914. // if the page is unloaded before the widget is destroyed. #7790
  4915. this._on( this.window, {
  4916. beforeunload: function() {
  4917. this.element.removeAttr( "autocomplete" );
  4918. }
  4919. } );
  4920. },
  4921. _destroy: function() {
  4922. clearTimeout( this.searching );
  4923. this.element.removeAttr( "autocomplete" );
  4924. this.menu.element.remove();
  4925. this.liveRegion.remove();
  4926. },
  4927. _setOption: function( key, value ) {
  4928. this._super( key, value );
  4929. if ( key === "source" ) {
  4930. this._initSource();
  4931. }
  4932. if ( key === "appendTo" ) {
  4933. this.menu.element.appendTo( this._appendTo() );
  4934. }
  4935. if ( key === "disabled" && value && this.xhr ) {
  4936. this.xhr.abort();
  4937. }
  4938. },
  4939. _isEventTargetInWidget: function( event ) {
  4940. var menuElement = this.menu.element[ 0 ];
  4941. return event.target === this.element[ 0 ] ||
  4942. event.target === menuElement ||
  4943. $.contains( menuElement, event.target );
  4944. },
  4945. _closeOnClickOutside: function( event ) {
  4946. if ( !this._isEventTargetInWidget( event ) ) {
  4947. this.close();
  4948. }
  4949. },
  4950. _appendTo: function() {
  4951. var element = this.options.appendTo;
  4952. if ( element ) {
  4953. element = element.jquery || element.nodeType ?
  4954. $( element ) :
  4955. this.document.find( element ).eq( 0 );
  4956. }
  4957. if ( !element || !element[ 0 ] ) {
  4958. element = this.element.closest( ".ui-front, dialog" );
  4959. }
  4960. if ( !element.length ) {
  4961. element = this.document[ 0 ].body;
  4962. }
  4963. return element;
  4964. },
  4965. _initSource: function() {
  4966. var array, url,
  4967. that = this;
  4968. if ( $.isArray( this.options.source ) ) {
  4969. array = this.options.source;
  4970. this.source = function( request, response ) {
  4971. response( $.ui.autocomplete.filter( array, request.term ) );
  4972. };
  4973. } else if ( typeof this.options.source === "string" ) {
  4974. url = this.options.source;
  4975. this.source = function( request, response ) {
  4976. if ( that.xhr ) {
  4977. that.xhr.abort();
  4978. }
  4979. that.xhr = $.ajax( {
  4980. url: url,
  4981. data: request,
  4982. dataType: "json",
  4983. success: function( data ) {
  4984. response( data );
  4985. },
  4986. error: function() {
  4987. response( [] );
  4988. }
  4989. } );
  4990. };
  4991. } else {
  4992. this.source = this.options.source;
  4993. }
  4994. },
  4995. _searchTimeout: function( event ) {
  4996. clearTimeout( this.searching );
  4997. this.searching = this._delay( function() {
  4998. // Search if the value has changed, or if the user retypes the same value (see #7434)
  4999. var equalValues = this.term === this._value(),
  5000. menuVisible = this.menu.element.is( ":visible" ),
  5001. modifierKey = event.altKey || event.ctrlKey || event.metaKey || event.shiftKey;
  5002. if ( !equalValues || ( equalValues && !menuVisible && !modifierKey ) ) {
  5003. this.selectedItem = null;
  5004. this.search( null, event );
  5005. }
  5006. }, this.options.delay );
  5007. },
  5008. search: function( value, event ) {
  5009. value = value != null ? value : this._value();
  5010. // Always save the actual value, not the one passed as an argument
  5011. this.term = this._value();
  5012. if ( value.length < this.options.minLength ) {
  5013. return this.close( event );
  5014. }
  5015. if ( this._trigger( "search", event ) === false ) {
  5016. return;
  5017. }
  5018. return this._search( value );
  5019. },
  5020. _search: function( value ) {
  5021. this.pending++;
  5022. this._addClass( "ui-autocomplete-loading" );
  5023. this.cancelSearch = false;
  5024. this.source( { term: value }, this._response() );
  5025. },
  5026. _response: function() {
  5027. var index = ++this.requestIndex;
  5028. return $.proxy( function( content ) {
  5029. if ( index === this.requestIndex ) {
  5030. this.__response( content );
  5031. }
  5032. this.pending--;
  5033. if ( !this.pending ) {
  5034. this._removeClass( "ui-autocomplete-loading" );
  5035. }
  5036. }, this );
  5037. },
  5038. __response: function( content ) {
  5039. if ( content ) {
  5040. content = this._normalize( content );
  5041. }
  5042. this._trigger( "response", null, { content: content } );
  5043. if ( !this.options.disabled && content && content.length && !this.cancelSearch ) {
  5044. this._suggest( content );
  5045. this._trigger( "open" );
  5046. } else {
  5047. // use ._close() instead of .close() so we don't cancel future searches
  5048. this._close();
  5049. }
  5050. },
  5051. close: function( event ) {
  5052. this.cancelSearch = true;
  5053. this._close( event );
  5054. },
  5055. _close: function( event ) {
  5056. // Remove the handler that closes the menu on outside clicks
  5057. this._off( this.document, "mousedown" );
  5058. if ( this.menu.element.is( ":visible" ) ) {
  5059. this.menu.element.hide();
  5060. this.menu.blur();
  5061. this.isNewMenu = true;
  5062. this._trigger( "close", event );
  5063. }
  5064. },
  5065. _change: function( event ) {
  5066. if ( this.previous !== this._value() ) {
  5067. this._trigger( "change", event, { item: this.selectedItem } );
  5068. }
  5069. },
  5070. _normalize: function( items ) {
  5071. // assume all items have the right format when the first item is complete
  5072. if ( items.length && items[ 0 ].label && items[ 0 ].value ) {
  5073. return items;
  5074. }
  5075. return $.map( items, function( item ) {
  5076. if ( typeof item === "string" ) {
  5077. return {
  5078. label: item,
  5079. value: item
  5080. };
  5081. }
  5082. return $.extend( {}, item, {
  5083. label: item.label || item.value,
  5084. value: item.value || item.label
  5085. } );
  5086. } );
  5087. },
  5088. _suggest: function( items ) {
  5089. var ul = this.menu.element.empty();
  5090. this._renderMenu( ul, items );
  5091. this.isNewMenu = true;
  5092. this.menu.refresh();
  5093. // Size and position menu
  5094. ul.show();
  5095. this._resizeMenu();
  5096. ul.position( $.extend( {
  5097. of: this.element
  5098. }, this.options.position ) );
  5099. if ( this.options.autoFocus ) {
  5100. this.menu.next();
  5101. }
  5102. // Listen for interactions outside of the widget (#6642)
  5103. this._on( this.document, {
  5104. mousedown: "_closeOnClickOutside"
  5105. } );
  5106. },
  5107. _resizeMenu: function() {
  5108. var ul = this.menu.element;
  5109. ul.outerWidth( Math.max(
  5110. // Firefox wraps long text (possibly a rounding bug)
  5111. // so we add 1px to avoid the wrapping (#7513)
  5112. ul.width( "" ).outerWidth() + 1,
  5113. this.element.outerWidth()
  5114. ) );
  5115. },
  5116. _renderMenu: function( ul, items ) {
  5117. var that = this;
  5118. $.each( items, function( index, item ) {
  5119. that._renderItemData( ul, item );
  5120. } );
  5121. },
  5122. _renderItemData: function( ul, item ) {
  5123. return this._renderItem( ul, item ).data( "ui-autocomplete-item", item );
  5124. },
  5125. _renderItem: function( ul, item ) {
  5126. return $( "<li>" )
  5127. .append( $( "<div>" ).text( item.label ) )
  5128. .appendTo( ul );
  5129. },
  5130. _move: function( direction, event ) {
  5131. if ( !this.menu.element.is( ":visible" ) ) {
  5132. this.search( null, event );
  5133. return;
  5134. }
  5135. if ( this.menu.isFirstItem() && /^previous/.test( direction ) ||
  5136. this.menu.isLastItem() && /^next/.test( direction ) ) {
  5137. if ( !this.isMultiLine ) {
  5138. this._value( this.term );
  5139. }
  5140. this.menu.blur();
  5141. return;
  5142. }
  5143. this.menu[ direction ]( event );
  5144. },
  5145. widget: function() {
  5146. return this.menu.element;
  5147. },
  5148. _value: function() {
  5149. return this.valueMethod.apply( this.element, arguments );
  5150. },
  5151. _keyEvent: function( keyEvent, event ) {
  5152. if ( !this.isMultiLine || this.menu.element.is( ":visible" ) ) {
  5153. this._move( keyEvent, event );
  5154. // Prevents moving cursor to beginning/end of the text field in some browsers
  5155. event.preventDefault();
  5156. }
  5157. },
  5158. // Support: Chrome <=50
  5159. // We should be able to just use this.element.prop( "isContentEditable" )
  5160. // but hidden elements always report false in Chrome.
  5161. // https://code.google.com/p/chromium/issues/detail?id=313082
  5162. _isContentEditable: function( element ) {
  5163. if ( !element.length ) {
  5164. return false;
  5165. }
  5166. var editable = element.prop( "contentEditable" );
  5167. if ( editable === "inherit" ) {
  5168. return this._isContentEditable( element.parent() );
  5169. }
  5170. return editable === "true";
  5171. }
  5172. } );
  5173. $.extend( $.ui.autocomplete, {
  5174. escapeRegex: function( value ) {
  5175. return value.replace( /[\-\[\]{}()*+?.,\\\^$|#\s]/g, "\\$&" );
  5176. },
  5177. filter: function( array, term ) {
  5178. var matcher = new RegExp( $.ui.autocomplete.escapeRegex( term ), "i" );
  5179. return $.grep( array, function( value ) {
  5180. return matcher.test( value.label || value.value || value );
  5181. } );
  5182. }
  5183. } );
  5184. // Live region extension, adding a `messages` option
  5185. // NOTE: This is an experimental API. We are still investigating
  5186. // a full solution for string manipulation and internationalization.
  5187. $.widget( "ui.autocomplete", $.ui.autocomplete, {
  5188. options: {
  5189. messages: {
  5190. noResults: "No search results.",
  5191. results: function( amount ) {
  5192. return amount + ( amount > 1 ? " results are" : " result is" ) +
  5193. " available, use up and down arrow keys to navigate.";
  5194. }
  5195. }
  5196. },
  5197. __response: function( content ) {
  5198. var message;
  5199. this._superApply( arguments );
  5200. if ( this.options.disabled || this.cancelSearch ) {
  5201. return;
  5202. }
  5203. if ( content && content.length ) {
  5204. message = this.options.messages.results( content.length );
  5205. } else {
  5206. message = this.options.messages.noResults;
  5207. }
  5208. this.liveRegion.children().hide();
  5209. $( "<div>" ).text( message ).appendTo( this.liveRegion );
  5210. }
  5211. } );
  5212. var widgetsAutocomplete = $.ui.autocomplete;
  5213. /*!
  5214. * jQuery UI Controlgroup 1.12.0
  5215. * http://jqueryui.com
  5216. *
  5217. * Copyright jQuery Foundation and other contributors
  5218. * Released under the MIT license.
  5219. * http://jquery.org/license
  5220. */
  5221. //>>label: Controlgroup
  5222. //>>group: Widgets
  5223. //>>description: Visually groups form control widgets
  5224. //>>docs: http://api.jqueryui.com/controlgroup/
  5225. //>>demos: http://jqueryui.com/controlgroup/
  5226. //>>css.structure: ../../themes/base/core.css
  5227. //>>css.structure: ../../themes/base/controlgroup.css
  5228. //>>css.theme: ../../themes/base/theme.css
  5229. var controlgroupCornerRegex = /ui-corner-([a-z]){2,6}/g;
  5230. var widgetsControlgroup = $.widget( "ui.controlgroup", {
  5231. version: "1.12.0",
  5232. defaultElement: "<div>",
  5233. options: {
  5234. direction: "horizontal",
  5235. disabled: null,
  5236. onlyVisible: true,
  5237. items: {
  5238. "button": "input[type=button], input[type=submit], input[type=reset], button, a",
  5239. "controlgroupLabel": ".ui-controlgroup-label",
  5240. "checkboxradio": "input[type='checkbox'], input[type='radio']",
  5241. "selectmenu": "select",
  5242. "spinner": ".ui-spinner-input"
  5243. }
  5244. },
  5245. _create: function() {
  5246. this._enhance();
  5247. },
  5248. // To support the enhanced option in jQuery Mobile, we isolate DOM manipulation
  5249. _enhance: function() {
  5250. this.element.attr( "role", "toolbar" );
  5251. this.refresh();
  5252. },
  5253. _destroy: function() {
  5254. this._callChildMethod( "destroy" );
  5255. this.childWidgets.removeData( "ui-controlgroup-data" );
  5256. this.element.removeAttr( "role" );
  5257. if ( this.options.items.controlgroupLabel ) {
  5258. this.element
  5259. .find( this.options.items.controlgroupLabel )
  5260. .find( ".ui-controlgroup-label-contents" )
  5261. .contents().unwrap();
  5262. }
  5263. },
  5264. _initWidgets: function() {
  5265. var that = this,
  5266. childWidgets = [];
  5267. // First we iterate over each of the items options
  5268. $.each( this.options.items, function( widget, selector ) {
  5269. var labels;
  5270. var options = {};
  5271. // Make sure the widget has a selector set
  5272. if ( !selector ) {
  5273. return;
  5274. }
  5275. if ( widget === "controlgroupLabel" ) {
  5276. labels = that.element.find( selector );
  5277. labels.each( function() {
  5278. var element = $( this );
  5279. if ( element.children( ".ui-controlgroup-label-contents" ).length ) {
  5280. return;
  5281. }
  5282. element.contents()
  5283. .wrapAll( "<span class='ui-controlgroup-label-contents'></span>" );
  5284. } );
  5285. that._addClass( labels, null, "ui-widget ui-widget-content ui-state-default" );
  5286. childWidgets = childWidgets.concat( labels.get() );
  5287. return;
  5288. }
  5289. // Make sure the widget actually exists
  5290. if ( !$.fn[ widget ] ) {
  5291. return;
  5292. }
  5293. // We assume everything is in the middle to start because we can't determine
  5294. // first / last elements until all enhancments are done.
  5295. if ( that[ "_" + widget + "Options" ] ) {
  5296. options = that[ "_" + widget + "Options" ]( "middle" );
  5297. }
  5298. // Find instances of this widget inside controlgroup and init them
  5299. that.element
  5300. .find( selector )
  5301. .each( function() {
  5302. var element = $( this );
  5303. var instance = element[ widget ]( "instance" );
  5304. // We need to clone the default options for this type of widget to avoid
  5305. // polluting the variable options which has a wider scope than a single widget.
  5306. var instanceOptions = $.widget.extend( {}, options );
  5307. // If the button is the child of a spinner ignore it
  5308. // TODO: Find a more generic solution
  5309. if ( widget === "button" && element.parent( ".ui-spinner" ).length ) {
  5310. return;
  5311. }
  5312. // Create the widget if it doesn't exist
  5313. if ( !instance ) {
  5314. instance = element[ widget ]()[ widget ]( "instance" );
  5315. }
  5316. if ( instance ) {
  5317. instanceOptions.classes =
  5318. that._resolveClassesValues( instanceOptions.classes, instance );
  5319. }
  5320. element[ widget ]( instanceOptions );
  5321. // Store an instance of the controlgroup to be able to reference
  5322. // from the outermost element for changing options and refresh
  5323. var widgetElement = element[ widget ]( "widget" );
  5324. $.data( widgetElement[ 0 ], "ui-controlgroup-data",
  5325. instance ? instance : element[ widget ]( "instance" ) );
  5326. childWidgets.push( widgetElement[ 0 ] );
  5327. } );
  5328. } );
  5329. this.childWidgets = $( $.unique( childWidgets ) );
  5330. this._addClass( this.childWidgets, "ui-controlgroup-item" );
  5331. },
  5332. _callChildMethod: function( method ) {
  5333. this.childWidgets.each( function() {
  5334. var element = $( this ),
  5335. data = element.data( "ui-controlgroup-data" );
  5336. if ( data && data[ method ] ) {
  5337. data[ method ]();
  5338. }
  5339. } );
  5340. },
  5341. _updateCornerClass: function( element, position ) {
  5342. var remove = "ui-corner-top ui-corner-bottom ui-corner-left ui-corner-right ui-corner-all";
  5343. var add = this._buildSimpleOptions( position, "label" ).classes.label;
  5344. this._removeClass( element, null, remove );
  5345. this._addClass( element, null, add );
  5346. },
  5347. _buildSimpleOptions: function( position, key ) {
  5348. var direction = this.options.direction === "vertical";
  5349. var result = {
  5350. classes: {}
  5351. };
  5352. result.classes[ key ] = {
  5353. "middle": "",
  5354. "first": "ui-corner-" + ( direction ? "top" : "left" ),
  5355. "last": "ui-corner-" + ( direction ? "bottom" : "right" ),
  5356. "only": "ui-corner-all"
  5357. }[ position ];
  5358. return result;
  5359. },
  5360. _spinnerOptions: function( position ) {
  5361. var options = this._buildSimpleOptions( position, "ui-spinner" );
  5362. options.classes[ "ui-spinner-up" ] = "";
  5363. options.classes[ "ui-spinner-down" ] = "";
  5364. return options;
  5365. },
  5366. _buttonOptions: function( position ) {
  5367. return this._buildSimpleOptions( position, "ui-button" );
  5368. },
  5369. _checkboxradioOptions: function( position ) {
  5370. return this._buildSimpleOptions( position, "ui-checkboxradio-label" );
  5371. },
  5372. _selectmenuOptions: function( position ) {
  5373. var direction = this.options.direction === "vertical";
  5374. return {
  5375. width: direction ? "auto" : false,
  5376. classes: {
  5377. middle: {
  5378. "ui-selectmenu-button-open": "",
  5379. "ui-selectmenu-button-closed": ""
  5380. },
  5381. first: {
  5382. "ui-selectmenu-button-open": "ui-corner-" + ( direction ? "top" : "tl" ),
  5383. "ui-selectmenu-button-closed": "ui-corner-" + ( direction ? "top" : "left" )
  5384. },
  5385. last: {
  5386. "ui-selectmenu-button-open": direction ? "" : "ui-corner-tr",
  5387. "ui-selectmenu-button-closed": "ui-corner-" + ( direction ? "bottom" : "right" )
  5388. },
  5389. only: {
  5390. "ui-selectmenu-button-open": "ui-corner-top",
  5391. "ui-selectmenu-button-closed": "ui-corner-all"
  5392. }
  5393. }[ position ]
  5394. };
  5395. },
  5396. _resolveClassesValues: function( classes, instance ) {
  5397. var result = {};
  5398. $.each( classes, function( key ) {
  5399. var current = instance.options.classes[ key ] || "";
  5400. current = current.replace( controlgroupCornerRegex, "" ).trim();
  5401. result[ key ] = ( current + " " + classes[ key ] ).replace( /\s+/g, " " );
  5402. } );
  5403. return result;
  5404. },
  5405. _setOption: function( key, value ) {
  5406. if ( key === "direction" ) {
  5407. this._removeClass( "ui-controlgroup-" + this.options.direction );
  5408. }
  5409. this._super( key, value );
  5410. if ( key === "disabled" ) {
  5411. this._callChildMethod( value ? "disable" : "enable" );
  5412. return;
  5413. }
  5414. this.refresh();
  5415. },
  5416. refresh: function() {
  5417. var children,
  5418. that = this;
  5419. this._addClass( "ui-controlgroup ui-controlgroup-" + this.options.direction );
  5420. if ( this.options.direction === "horizontal" ) {
  5421. this._addClass( null, "ui-helper-clearfix" );
  5422. }
  5423. this._initWidgets();
  5424. children = this.childWidgets;
  5425. // We filter here because we need to track all childWidgets not just the visible ones
  5426. if ( this.options.onlyVisible ) {
  5427. children = children.filter( ":visible" );
  5428. }
  5429. if ( children.length ) {
  5430. // We do this last because we need to make sure all enhancment is done
  5431. // before determining first and last
  5432. $.each( [ "first", "last" ], function( index, value ) {
  5433. var instance = children[ value ]().data( "ui-controlgroup-data" );
  5434. if ( instance && that[ "_" + instance.widgetName + "Options" ] ) {
  5435. var options = that[ "_" + instance.widgetName + "Options" ](
  5436. children.length === 1 ? "only" : value
  5437. );
  5438. options.classes = that._resolveClassesValues( options.classes, instance );
  5439. instance.element[ instance.widgetName ]( options );
  5440. } else {
  5441. that._updateCornerClass( children[ value ](), value );
  5442. }
  5443. } );
  5444. // Finally call the refresh method on each of the child widgets.
  5445. this._callChildMethod( "refresh" );
  5446. }
  5447. }
  5448. } );
  5449. /*!
  5450. * jQuery UI Checkboxradio 1.12.0
  5451. * http://jqueryui.com
  5452. *
  5453. * Copyright jQuery Foundation and other contributors
  5454. * Released under the MIT license.
  5455. * http://jquery.org/license
  5456. */
  5457. //>>label: Checkboxradio
  5458. //>>group: Widgets
  5459. //>>description: Enhances a form with multiple themeable checkboxes or radio buttons.
  5460. //>>docs: http://api.jqueryui.com/checkboxradio/
  5461. //>>demos: http://jqueryui.com/checkboxradio/
  5462. //>>css.structure: ../../themes/base/core.css
  5463. //>>css.structure: ../../themes/base/button.css
  5464. //>>css.structure: ../../themes/base/checkboxradio.css
  5465. //>>css.theme: ../../themes/base/theme.css
  5466. $.widget( "ui.checkboxradio", [ $.ui.formResetMixin, {
  5467. version: "1.12.0",
  5468. options: {
  5469. disabled: null,
  5470. label: null,
  5471. icon: true,
  5472. classes: {
  5473. "ui-checkboxradio-label": "ui-corner-all",
  5474. "ui-checkboxradio-icon": "ui-corner-all"
  5475. }
  5476. },
  5477. _getCreateOptions: function() {
  5478. var disabled, labels;
  5479. var that = this;
  5480. var options = this._super() || {};
  5481. // We read the type here, because it makes more sense to throw a element type error first,
  5482. // rather then the error for lack of a label. Often if its the wrong type, it
  5483. // won't have a label (e.g. calling on a div, btn, etc)
  5484. this._readType();
  5485. labels = this.element.labels();
  5486. // If there are multiple labels, use the last one
  5487. this.label = $( labels[ labels.length - 1 ] );
  5488. if ( !this.label.length ) {
  5489. $.error( "No label found for checkboxradio widget" );
  5490. }
  5491. this.originalLabel = "";
  5492. // We need to get the label text but this may also need to make sure it does not contain the
  5493. // input itself.
  5494. this.label.contents().not( this.element ).each( function() {
  5495. // The label contents could be text, html, or a mix. We concat each element to get a
  5496. // string representation of the label, without the input as part of it.
  5497. that.originalLabel += this.nodeType === 3 ? $( this ).text() : this.outerHTML;
  5498. } );
  5499. // Set the label option if we found label text
  5500. if ( this.originalLabel ) {
  5501. options.label = this.originalLabel;
  5502. }
  5503. disabled = this.element[ 0 ].disabled;
  5504. if ( disabled != null ) {
  5505. options.disabled = disabled;
  5506. }
  5507. return options;
  5508. },
  5509. _create: function() {
  5510. var checked = this.element[ 0 ].checked;
  5511. this._bindFormResetHandler();
  5512. if ( this.options.disabled == null ) {
  5513. this.options.disabled = this.element[ 0 ].disabled;
  5514. }
  5515. this._setOption( "disabled", this.options.disabled );
  5516. this._addClass( "ui-checkboxradio", "ui-helper-hidden-accessible" );
  5517. this._addClass( this.label, "ui-checkboxradio-label", "ui-button ui-widget" );
  5518. if ( this.type === "radio" ) {
  5519. this._addClass( this.label, "ui-checkboxradio-radio-label" );
  5520. }
  5521. if ( this.options.label && this.options.label !== this.originalLabel ) {
  5522. this._updateLabel();
  5523. } else if ( this.originalLabel ) {
  5524. this.options.label = this.originalLabel;
  5525. }
  5526. this._enhance();
  5527. if ( checked ) {
  5528. this._addClass( this.label, "ui-checkboxradio-checked", "ui-state-active" );
  5529. if ( this.icon ) {
  5530. this._addClass( this.icon, null, "ui-state-hover" );
  5531. }
  5532. }
  5533. this._on( {
  5534. change: "_toggleClasses",
  5535. focus: function() {
  5536. this._addClass( this.label, null, "ui-state-focus ui-visual-focus" );
  5537. },
  5538. blur: function() {
  5539. this._removeClass( this.label, null, "ui-state-focus ui-visual-focus" );
  5540. }
  5541. } );
  5542. },
  5543. _readType: function() {
  5544. var nodeName = this.element[ 0 ].nodeName.toLowerCase();
  5545. this.type = this.element[ 0 ].type;
  5546. if ( nodeName !== "input" || !/radio|checkbox/.test( this.type ) ) {
  5547. $.error( "Can't create checkboxradio on element.nodeName=" + nodeName +
  5548. " and element.type=" + this.type );
  5549. }
  5550. },
  5551. // Support jQuery Mobile enhanced option
  5552. _enhance: function() {
  5553. this._updateIcon( this.element[ 0 ].checked );
  5554. },
  5555. widget: function() {
  5556. return this.label;
  5557. },
  5558. _getRadioGroup: function() {
  5559. var group;
  5560. var name = this.element[ 0 ].name;
  5561. var nameSelector = "input[name='" + $.ui.escapeSelector( name ) + "']";
  5562. if ( !name ) {
  5563. return $( [] );
  5564. }
  5565. if ( this.form.length ) {
  5566. group = $( this.form[ 0 ].elements ).filter( nameSelector );
  5567. } else {
  5568. // Not inside a form, check all inputs that also are not inside a form
  5569. group = $( nameSelector ).filter( function() {
  5570. return $( this ).form().length === 0;
  5571. } );
  5572. }
  5573. return group.not( this.element );
  5574. },
  5575. _toggleClasses: function() {
  5576. var checked = this.element[ 0 ].checked;
  5577. this._toggleClass( this.label, "ui-checkboxradio-checked", "ui-state-active", checked );
  5578. if ( this.options.icon && this.type === "checkbox" ) {
  5579. this._toggleClass( this.icon, null, "ui-icon-check ui-state-checked", checked )
  5580. ._toggleClass( this.icon, null, "ui-icon-blank", !checked );
  5581. }
  5582. if ( this.type === "radio" ) {
  5583. this._getRadioGroup()
  5584. .each( function() {
  5585. var instance = $( this ).checkboxradio( "instance" );
  5586. if ( instance ) {
  5587. instance._removeClass( instance.label,
  5588. "ui-checkboxradio-checked", "ui-state-active" );
  5589. }
  5590. } );
  5591. }
  5592. },
  5593. _destroy: function() {
  5594. this._unbindFormResetHandler();
  5595. if ( this.icon ) {
  5596. this.icon.remove();
  5597. this.iconSpace.remove();
  5598. }
  5599. },
  5600. _setOption: function( key, value ) {
  5601. // We don't allow the value to be set to nothing
  5602. if ( key === "label" && !value ) {
  5603. return;
  5604. }
  5605. this._super( key, value );
  5606. if ( key === "disabled" ) {
  5607. this._toggleClass( this.label, null, "ui-state-disabled", value );
  5608. this.element[ 0 ].disabled = value;
  5609. // Don't refresh when setting disabled
  5610. return;
  5611. }
  5612. this.refresh();
  5613. },
  5614. _updateIcon: function( checked ) {
  5615. var toAdd = "ui-icon ui-icon-background ";
  5616. if ( this.options.icon ) {
  5617. if ( !this.icon ) {
  5618. this.icon = $( "<span>" );
  5619. this.iconSpace = $( "<span> </span>" );
  5620. this._addClass( this.iconSpace, "ui-checkboxradio-icon-space" );
  5621. }
  5622. if ( this.type === "checkbox" ) {
  5623. toAdd += checked ? "ui-icon-check ui-state-checked" : "ui-icon-blank";
  5624. this._removeClass( this.icon, null, checked ? "ui-icon-blank" : "ui-icon-check" );
  5625. } else {
  5626. toAdd += "ui-icon-blank";
  5627. }
  5628. this._addClass( this.icon, "ui-checkboxradio-icon", toAdd );
  5629. if ( !checked ) {
  5630. this._removeClass( this.icon, null, "ui-icon-check ui-state-checked" );
  5631. }
  5632. this.icon.prependTo( this.label ).after( this.iconSpace );
  5633. } else if ( this.icon !== undefined ) {
  5634. this.icon.remove();
  5635. this.iconSpace.remove();
  5636. delete this.icon;
  5637. }
  5638. },
  5639. _updateLabel: function() {
  5640. // Remove the contents of the label ( minus the icon, icon space, and input )
  5641. this.label.contents().not( this.element.add( this.icon ).add( this.iconSpace ) ).remove();
  5642. this.label.append( this.options.label );
  5643. },
  5644. refresh: function() {
  5645. var checked = this.element[ 0 ].checked,
  5646. isDisabled = this.element[ 0 ].disabled;
  5647. this._updateIcon( checked );
  5648. this._toggleClass( this.label, "ui-checkboxradio-checked", "ui-state-active", checked );
  5649. if ( this.options.label !== null ) {
  5650. this._updateLabel();
  5651. }
  5652. if ( isDisabled !== this.options.disabled ) {
  5653. this._setOptions( { "disabled": isDisabled } );
  5654. }
  5655. }
  5656. } ] );
  5657. var widgetsCheckboxradio = $.ui.checkboxradio;
  5658. /*!
  5659. * jQuery UI Button 1.12.0
  5660. * http://jqueryui.com
  5661. *
  5662. * Copyright jQuery Foundation and other contributors
  5663. * Released under the MIT license.
  5664. * http://jquery.org/license
  5665. */
  5666. //>>label: Button
  5667. //>>group: Widgets
  5668. //>>description: Enhances a form with themeable buttons.
  5669. //>>docs: http://api.jqueryui.com/button/
  5670. //>>demos: http://jqueryui.com/button/
  5671. //>>css.structure: ../../themes/base/core.css
  5672. //>>css.structure: ../../themes/base/button.css
  5673. //>>css.theme: ../../themes/base/theme.css
  5674. $.widget( "ui.button", {
  5675. version: "1.12.0",
  5676. defaultElement: "<button>",
  5677. options: {
  5678. classes: {
  5679. "ui-button": "ui-corner-all"
  5680. },
  5681. disabled: null,
  5682. icon: null,
  5683. iconPosition: "beginning",
  5684. label: null,
  5685. showLabel: true
  5686. },
  5687. _getCreateOptions: function() {
  5688. var disabled,
  5689. // This is to support cases like in jQuery Mobile where the base widget does have
  5690. // an implementation of _getCreateOptions
  5691. options = this._super() || {};
  5692. this.isInput = this.element.is( "input" );
  5693. disabled = this.element[ 0 ].disabled;
  5694. if ( disabled != null ) {
  5695. options.disabled = disabled;
  5696. }
  5697. this.originalLabel = this.isInput ? this.element.val() : this.element.html();
  5698. if ( this.originalLabel ) {
  5699. options.label = this.originalLabel;
  5700. }
  5701. return options;
  5702. },
  5703. _create: function() {
  5704. if ( !this.option.showLabel & !this.options.icon ) {
  5705. this.options.showLabel = true;
  5706. }
  5707. // We have to check the option again here even though we did in _getCreateOptions,
  5708. // because null may have been passed on init which would override what was set in
  5709. // _getCreateOptions
  5710. if ( this.options.disabled == null ) {
  5711. this.options.disabled = this.element[ 0 ].disabled || false;
  5712. }
  5713. this.hasTitle = !!this.element.attr( "title" );
  5714. // Check to see if the label needs to be set or if its already correct
  5715. if ( this.options.label && this.options.label !== this.originalLabel ) {
  5716. if ( this.isInput ) {
  5717. this.element.val( this.options.label );
  5718. } else {
  5719. this.element.html( this.options.label );
  5720. }
  5721. }
  5722. this._addClass( "ui-button", "ui-widget" );
  5723. this._setOption( "disabled", this.options.disabled );
  5724. this._enhance();
  5725. if ( this.element.is( "a" ) ) {
  5726. this._on( {
  5727. "keyup": function( event ) {
  5728. if ( event.keyCode === $.ui.keyCode.SPACE ) {
  5729. event.preventDefault();
  5730. // Support: PhantomJS <= 1.9, IE 8 Only
  5731. // If a native click is available use it so we actually cause navigation
  5732. // otherwise just trigger a click event
  5733. if ( this.element[ 0 ].click ) {
  5734. this.element[ 0 ].click();
  5735. } else {
  5736. this.element.trigger( "click" );
  5737. }
  5738. }
  5739. }
  5740. } );
  5741. }
  5742. },
  5743. _enhance: function() {
  5744. if ( !this.element.is( "button" ) ) {
  5745. this.element.attr( "role", "button" );
  5746. }
  5747. if ( this.options.icon ) {
  5748. this._updateIcon( "icon", this.options.icon );
  5749. this._updateTooltip();
  5750. }
  5751. },
  5752. _updateTooltip: function() {
  5753. this.title = this.element.attr( "title" );
  5754. if ( !this.options.showLabel && !this.title ) {
  5755. this.element.attr( "title", this.options.label );
  5756. }
  5757. },
  5758. _updateIcon: function( option, value ) {
  5759. var icon = option !== "iconPosition",
  5760. position = icon ? this.options.iconPosition : value,
  5761. displayBlock = position === "top" || position === "bottom";
  5762. // Create icon
  5763. if ( !this.icon ) {
  5764. this.icon = $( "<span>" );
  5765. this._addClass( this.icon, "ui-button-icon", "ui-icon" );
  5766. if ( !this.options.showLabel ) {
  5767. this._addClass( "ui-button-icon-only" );
  5768. }
  5769. } else if ( icon ) {
  5770. // If we are updating the icon remove the old icon class
  5771. this._removeClass( this.icon, null, this.options.icon );
  5772. }
  5773. // If we are updating the icon add the new icon class
  5774. if ( icon ) {
  5775. this._addClass( this.icon, null, value );
  5776. }
  5777. this._attachIcon( position );
  5778. // If the icon is on top or bottom we need to add the ui-widget-icon-block class and remove
  5779. // the iconSpace if there is one.
  5780. if ( displayBlock ) {
  5781. this._addClass( this.icon, null, "ui-widget-icon-block" );
  5782. if ( this.iconSpace ) {
  5783. this.iconSpace.remove();
  5784. }
  5785. } else {
  5786. // Position is beginning or end so remove the ui-widget-icon-block class and add the
  5787. // space if it does not exist
  5788. if ( !this.iconSpace ) {
  5789. this.iconSpace = $( "<span> </span>" );
  5790. this._addClass( this.iconSpace, "ui-button-icon-space" );
  5791. }
  5792. this._removeClass( this.icon, null, "ui-wiget-icon-block" );
  5793. this._attachIconSpace( position );
  5794. }
  5795. },
  5796. _destroy: function() {
  5797. this.element.removeAttr( "role" );
  5798. if ( this.icon ) {
  5799. this.icon.remove();
  5800. }
  5801. if ( this.iconSpace ) {
  5802. this.iconSpace.remove();
  5803. }
  5804. if ( !this.hasTitle ) {
  5805. this.element.removeAttr( "title" );
  5806. }
  5807. },
  5808. _attachIconSpace: function( iconPosition ) {
  5809. this.icon[ /^(?:end|bottom)/.test( iconPosition ) ? "before" : "after" ]( this.iconSpace );
  5810. },
  5811. _attachIcon: function( iconPosition ) {
  5812. this.element[ /^(?:end|bottom)/.test( iconPosition ) ? "append" : "prepend" ]( this.icon );
  5813. },
  5814. _setOptions: function( options ) {
  5815. var newShowLabel = options.showLabel === undefined ?
  5816. this.options.showLabel :
  5817. options.showLabel,
  5818. newIcon = options.icon === undefined ? this.options.icon : options.icon;
  5819. if ( !newShowLabel && !newIcon ) {
  5820. options.showLabel = true;
  5821. }
  5822. this._super( options );
  5823. },
  5824. _setOption: function( key, value ) {
  5825. if ( key === "icon" ) {
  5826. if ( value ) {
  5827. this._updateIcon( key, value );
  5828. } else if ( this.icon ) {
  5829. this.icon.remove();
  5830. if ( this.iconSpace ) {
  5831. this.iconSpace.remove();
  5832. }
  5833. }
  5834. }
  5835. if ( key === "iconPosition" ) {
  5836. this._updateIcon( key, value );
  5837. }
  5838. // Make sure we can't end up with a button that has neither text nor icon
  5839. if ( key === "showLabel" ) {
  5840. this._toggleClass( "ui-button-icon-only", null, !value );
  5841. this._updateTooltip();
  5842. }
  5843. if ( key === "label" ) {
  5844. if ( this.isInput ) {
  5845. this.element.val( value );
  5846. } else {
  5847. // If there is an icon, append it, else nothing then append the value
  5848. // this avoids removal of the icon when setting label text
  5849. this.element.html( value );
  5850. if ( this.icon ) {
  5851. this._attachIcon( this.options.iconPosition );
  5852. this._attachIconSpace( this.options.iconPosition );
  5853. }
  5854. }
  5855. }
  5856. this._super( key, value );
  5857. if ( key === "disabled" ) {
  5858. this._toggleClass( null, "ui-state-disabled", value );
  5859. this.element[ 0 ].disabled = value;
  5860. if ( value ) {
  5861. this.element.blur();
  5862. }
  5863. }
  5864. },
  5865. refresh: function() {
  5866. // Make sure to only check disabled if its an element that supports this otherwise
  5867. // check for the disabled class to determine state
  5868. var isDisabled = this.element.is( "input, button" ) ?
  5869. this.element[ 0 ].disabled : this.element.hasClass( "ui-button-disabled" );
  5870. if ( isDisabled !== this.options.disabled ) {
  5871. this._setOptions( { disabled: isDisabled } );
  5872. }
  5873. this._updateTooltip();
  5874. }
  5875. } );
  5876. // DEPRECATED
  5877. if ( $.uiBackCompat !== false ) {
  5878. // Text and Icons options
  5879. $.widget( "ui.button", $.ui.button, {
  5880. options: {
  5881. text: true,
  5882. icons: {
  5883. primary: null,
  5884. secondary: null
  5885. }
  5886. },
  5887. _create: function() {
  5888. if ( this.options.showLabel && !this.options.text ) {
  5889. this.options.showLabel = this.options.text;
  5890. }
  5891. if ( !this.options.showLabel && this.options.text ) {
  5892. this.options.text = this.options.showLabel;
  5893. }
  5894. if ( !this.options.icon && ( this.options.icons.primary ||
  5895. this.options.icons.secondary ) ) {
  5896. if ( this.options.icons.primary ) {
  5897. this.options.icon = this.options.icons.primary;
  5898. } else {
  5899. this.options.icon = this.options.icons.secondary;
  5900. this.options.iconPosition = "end";
  5901. }
  5902. } else if ( this.options.icon ) {
  5903. this.options.icons.primary = this.options.icon;
  5904. }
  5905. this._super();
  5906. },
  5907. _setOption: function( key, value ) {
  5908. if ( key === "text" ) {
  5909. this._super( "showLabel", value );
  5910. return;
  5911. }
  5912. if ( key === "showLabel" ) {
  5913. this.options.text = value;
  5914. }
  5915. if ( key === "icon" ) {
  5916. this.options.icons.primary = value;
  5917. }
  5918. if ( key === "icons" ) {
  5919. if ( value.primary ) {
  5920. this._super( "icon", value.primary );
  5921. this._super( "iconPosition", "beginning" );
  5922. } else if ( value.secondary ) {
  5923. this._super( "icon", value.secondary );
  5924. this._super( "iconPosition", "end" );
  5925. }
  5926. }
  5927. this._superApply( arguments );
  5928. }
  5929. } );
  5930. $.fn.button = ( function( orig ) {
  5931. return function() {
  5932. if ( !this.length || ( this.length && this[ 0 ].tagName !== "INPUT" ) ||
  5933. ( this.length && this[ 0 ].tagName === "INPUT" && (
  5934. this.attr( "type" ) !== "checkbox" && this.attr( "type" ) !== "radio"
  5935. ) ) ) {
  5936. return orig.apply( this, arguments );
  5937. }
  5938. if ( !$.ui.checkboxradio ) {
  5939. $.error( "Checkboxradio widget missing" );
  5940. }
  5941. if ( arguments.length === 0 ) {
  5942. return this.checkboxradio( {
  5943. "icon": false
  5944. } );
  5945. }
  5946. return this.checkboxradio.apply( this, arguments );
  5947. };
  5948. } )( $.fn.button );
  5949. $.fn.buttonset = function() {
  5950. if ( !$.ui.controlgroup ) {
  5951. $.error( "Controlgroup widget missing" );
  5952. }
  5953. if ( arguments[ 0 ] === "option" && arguments[ 1 ] === "items" && arguments[ 2 ] ) {
  5954. return this.controlgroup.apply( this,
  5955. [ arguments[ 0 ], "items.button", arguments[ 2 ] ] );
  5956. }
  5957. if ( arguments[ 0 ] === "option" && arguments[ 1 ] === "items" ) {
  5958. return this.controlgroup.apply( this, [ arguments[ 0 ], "items.button" ] );
  5959. }
  5960. if ( typeof arguments[ 0 ] === "object" && arguments[ 0 ].items ) {
  5961. arguments[ 0 ].items = {
  5962. button: arguments[ 0 ].items
  5963. };
  5964. }
  5965. return this.controlgroup.apply( this, arguments );
  5966. };
  5967. }
  5968. var widgetsButton = $.ui.button;
  5969. // jscs:disable maximumLineLength
  5970. /* jscs:disable requireCamelCaseOrUpperCaseIdentifiers */
  5971. /*!
  5972. * jQuery UI Datepicker 1.12.0
  5973. * http://jqueryui.com
  5974. *
  5975. * Copyright jQuery Foundation and other contributors
  5976. * Released under the MIT license.
  5977. * http://jquery.org/license
  5978. */
  5979. //>>label: Datepicker
  5980. //>>group: Widgets
  5981. //>>description: Displays a calendar from an input or inline for selecting dates.
  5982. //>>docs: http://api.jqueryui.com/datepicker/
  5983. //>>demos: http://jqueryui.com/datepicker/
  5984. //>>css.structure: ../../themes/base/core.css
  5985. //>>css.structure: ../../themes/base/datepicker.css
  5986. //>>css.theme: ../../themes/base/theme.css
  5987. $.extend( $.ui, { datepicker: { version: "1.12.0" } } );
  5988. var datepicker_instActive;
  5989. function datepicker_getZindex( elem ) {
  5990. var position, value;
  5991. while ( elem.length && elem[ 0 ] !== document ) {
  5992. // Ignore z-index if position is set to a value where z-index is ignored by the browser
  5993. // This makes behavior of this function consistent across browsers
  5994. // WebKit always returns auto if the element is positioned
  5995. position = elem.css( "position" );
  5996. if ( position === "absolute" || position === "relative" || position === "fixed" ) {
  5997. // IE returns 0 when zIndex is not specified
  5998. // other browsers return a string
  5999. // we ignore the case of nested elements with an explicit value of 0
  6000. // <div style="z-index: -10;"><div style="z-index: 0;"></div></div>
  6001. value = parseInt( elem.css( "zIndex" ), 10 );
  6002. if ( !isNaN( value ) && value !== 0 ) {
  6003. return value;
  6004. }
  6005. }
  6006. elem = elem.parent();
  6007. }
  6008. return 0;
  6009. }
  6010. /* Date picker manager.
  6011. Use the singleton instance of this class, $.datepicker, to interact with the date picker.
  6012. Settings for (groups of) date pickers are maintained in an instance object,
  6013. allowing multiple different settings on the same page. */
  6014. function Datepicker() {
  6015. this._curInst = null; // The current instance in use
  6016. this._keyEvent = false; // If the last event was a key event
  6017. this._disabledInputs = []; // List of date picker inputs that have been disabled
  6018. this._datepickerShowing = false; // True if the popup picker is showing , false if not
  6019. this._inDialog = false; // True if showing within a "dialog", false if not
  6020. this._mainDivId = "ui-datepicker-div"; // The ID of the main datepicker division
  6021. this._inlineClass = "ui-datepicker-inline"; // The name of the inline marker class
  6022. this._appendClass = "ui-datepicker-append"; // The name of the append marker class
  6023. this._triggerClass = "ui-datepicker-trigger"; // The name of the trigger marker class
  6024. this._dialogClass = "ui-datepicker-dialog"; // The name of the dialog marker class
  6025. this._disableClass = "ui-datepicker-disabled"; // The name of the disabled covering marker class
  6026. this._unselectableClass = "ui-datepicker-unselectable"; // The name of the unselectable cell marker class
  6027. this._currentClass = "ui-datepicker-current-day"; // The name of the current day marker class
  6028. this._dayOverClass = "ui-datepicker-days-cell-over"; // The name of the day hover marker class
  6029. this.regional = []; // Available regional settings, indexed by language code
  6030. this.regional[ "" ] = { // Default regional settings
  6031. closeText: "Done", // Display text for close link
  6032. prevText: "Prev", // Display text for previous month link
  6033. nextText: "Next", // Display text for next month link
  6034. currentText: "Today", // Display text for current month link
  6035. monthNames: [ "January","February","March","April","May","June",
  6036. "July","August","September","October","November","December" ], // Names of months for drop-down and formatting
  6037. monthNamesShort: [ "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" ], // For formatting
  6038. dayNames: [ "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday" ], // For formatting
  6039. dayNamesShort: [ "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" ], // For formatting
  6040. dayNamesMin: [ "Su","Mo","Tu","We","Th","Fr","Sa" ], // Column headings for days starting at Sunday
  6041. weekHeader: "Wk", // Column header for week of the year
  6042. dateFormat: "mm/dd/yy", // See format options on parseDate
  6043. firstDay: 0, // The first day of the week, Sun = 0, Mon = 1, ...
  6044. isRTL: false, // True if right-to-left language, false if left-to-right
  6045. showMonthAfterYear: false, // True if the year select precedes month, false for month then year
  6046. yearSuffix: "" // Additional text to append to the year in the month headers
  6047. };
  6048. this._defaults = { // Global defaults for all the date picker instances
  6049. showOn: "focus", // "focus" for popup on focus,
  6050. // "button" for trigger button, or "both" for either
  6051. showAnim: "fadeIn", // Name of jQuery animation for popup
  6052. showOptions: {}, // Options for enhanced animations
  6053. defaultDate: null, // Used when field is blank: actual date,
  6054. // +/-number for offset from today, null for today
  6055. appendText: "", // Display text following the input box, e.g. showing the format
  6056. buttonText: "...", // Text for trigger button
  6057. buttonImage: "", // URL for trigger button image
  6058. buttonImageOnly: false, // True if the image appears alone, false if it appears on a button
  6059. hideIfNoPrevNext: false, // True to hide next/previous month links
  6060. // if not applicable, false to just disable them
  6061. navigationAsDateFormat: false, // True if date formatting applied to prev/today/next links
  6062. gotoCurrent: false, // True if today link goes back to current selection instead
  6063. changeMonth: false, // True if month can be selected directly, false if only prev/next
  6064. changeYear: false, // True if year can be selected directly, false if only prev/next
  6065. yearRange: "c-10:c+10", // Range of years to display in drop-down,
  6066. // either relative to today's year (-nn:+nn), relative to currently displayed year
  6067. // (c-nn:c+nn), absolute (nnnn:nnnn), or a combination of the above (nnnn:-n)
  6068. showOtherMonths: false, // True to show dates in other months, false to leave blank
  6069. selectOtherMonths: false, // True to allow selection of dates in other months, false for unselectable
  6070. showWeek: false, // True to show week of the year, false to not show it
  6071. calculateWeek: this.iso8601Week, // How to calculate the week of the year,
  6072. // takes a Date and returns the number of the week for it
  6073. shortYearCutoff: "+10", // Short year values < this are in the current century,
  6074. // > this are in the previous century,
  6075. // string value starting with "+" for current year + value
  6076. minDate: null, // The earliest selectable date, or null for no limit
  6077. maxDate: null, // The latest selectable date, or null for no limit
  6078. duration: "fast", // Duration of display/closure
  6079. beforeShowDay: null, // Function that takes a date and returns an array with
  6080. // [0] = true if selectable, false if not, [1] = custom CSS class name(s) or "",
  6081. // [2] = cell title (optional), e.g. $.datepicker.noWeekends
  6082. beforeShow: null, // Function that takes an input field and
  6083. // returns a set of custom settings for the date picker
  6084. onSelect: null, // Define a callback function when a date is selected
  6085. onChangeMonthYear: null, // Define a callback function when the month or year is changed
  6086. onClose: null, // Define a callback function when the datepicker is closed
  6087. numberOfMonths: 1, // Number of months to show at a time
  6088. showCurrentAtPos: 0, // The position in multipe months at which to show the current month (starting at 0)
  6089. stepMonths: 1, // Number of months to step back/forward
  6090. stepBigMonths: 12, // Number of months to step back/forward for the big links
  6091. altField: "", // Selector for an alternate field to store selected dates into
  6092. altFormat: "", // The date format to use for the alternate field
  6093. constrainInput: true, // The input is constrained by the current date format
  6094. showButtonPanel: false, // True to show button panel, false to not show it
  6095. autoSize: false, // True to size the input for the date format, false to leave as is
  6096. disabled: false // The initial disabled state
  6097. };
  6098. $.extend( this._defaults, this.regional[ "" ] );
  6099. this.regional.en = $.extend( true, {}, this.regional[ "" ] );
  6100. this.regional[ "en-US" ] = $.extend( true, {}, this.regional.en );
  6101. this.dpDiv = datepicker_bindHover( $( "<div id='" + this._mainDivId + "' class='ui-datepicker ui-widget ui-widget-content ui-helper-clearfix ui-corner-all'></div>" ) );
  6102. }
  6103. $.extend( Datepicker.prototype, {
  6104. /* Class name added to elements to indicate already configured with a date picker. */
  6105. markerClassName: "hasDatepicker",
  6106. //Keep track of the maximum number of rows displayed (see #7043)
  6107. maxRows: 4,
  6108. // TODO rename to "widget" when switching to widget factory
  6109. _widgetDatepicker: function() {
  6110. return this.dpDiv;
  6111. },
  6112. /* Override the default settings for all instances of the date picker.
  6113. * @param settings object - the new settings to use as defaults (anonymous object)
  6114. * @return the manager object
  6115. */
  6116. setDefaults: function( settings ) {
  6117. datepicker_extendRemove( this._defaults, settings || {} );
  6118. return this;
  6119. },
  6120. /* Attach the date picker to a jQuery selection.
  6121. * @param target element - the target input field or division or span
  6122. * @param settings object - the new settings to use for this date picker instance (anonymous)
  6123. */
  6124. _attachDatepicker: function( target, settings ) {
  6125. var nodeName, inline, inst;
  6126. nodeName = target.nodeName.toLowerCase();
  6127. inline = ( nodeName === "div" || nodeName === "span" );
  6128. if ( !target.id ) {
  6129. this.uuid += 1;
  6130. target.id = "dp" + this.uuid;
  6131. }
  6132. inst = this._newInst( $( target ), inline );
  6133. inst.settings = $.extend( {}, settings || {} );
  6134. if ( nodeName === "input" ) {
  6135. this._connectDatepicker( target, inst );
  6136. } else if ( inline ) {
  6137. this._inlineDatepicker( target, inst );
  6138. }
  6139. },
  6140. /* Create a new instance object. */
  6141. _newInst: function( target, inline ) {
  6142. var id = target[ 0 ].id.replace( /([^A-Za-z0-9_\-])/g, "\\\\$1" ); // escape jQuery meta chars
  6143. return { id: id, input: target, // associated target
  6144. selectedDay: 0, selectedMonth: 0, selectedYear: 0, // current selection
  6145. drawMonth: 0, drawYear: 0, // month being drawn
  6146. inline: inline, // is datepicker inline or not
  6147. dpDiv: ( !inline ? this.dpDiv : // presentation div
  6148. datepicker_bindHover( $( "<div class='" + this._inlineClass + " ui-datepicker ui-widget ui-widget-content ui-helper-clearfix ui-corner-all'></div>" ) ) ) };
  6149. },
  6150. /* Attach the date picker to an input field. */
  6151. _connectDatepicker: function( target, inst ) {
  6152. var input = $( target );
  6153. inst.append = $( [] );
  6154. inst.trigger = $( [] );
  6155. if ( input.hasClass( this.markerClassName ) ) {
  6156. return;
  6157. }
  6158. this._attachments( input, inst );
  6159. input.addClass( this.markerClassName ).on( "keydown", this._doKeyDown ).
  6160. on( "keypress", this._doKeyPress ).on( "keyup", this._doKeyUp );
  6161. this._autoSize( inst );
  6162. $.data( target, "datepicker", inst );
  6163. //If disabled option is true, disable the datepicker once it has been attached to the input (see ticket #5665)
  6164. if ( inst.settings.disabled ) {
  6165. this._disableDatepicker( target );
  6166. }
  6167. },
  6168. /* Make attachments based on settings. */
  6169. _attachments: function( input, inst ) {
  6170. var showOn, buttonText, buttonImage,
  6171. appendText = this._get( inst, "appendText" ),
  6172. isRTL = this._get( inst, "isRTL" );
  6173. if ( inst.append ) {
  6174. inst.append.remove();
  6175. }
  6176. if ( appendText ) {
  6177. inst.append = $( "<span class='" + this._appendClass + "'>" + appendText + "</span>" );
  6178. input[ isRTL ? "before" : "after" ]( inst.append );
  6179. }
  6180. input.off( "focus", this._showDatepicker );
  6181. if ( inst.trigger ) {
  6182. inst.trigger.remove();
  6183. }
  6184. showOn = this._get( inst, "showOn" );
  6185. if ( showOn === "focus" || showOn === "both" ) { // pop-up date picker when in the marked field
  6186. input.on( "focus", this._showDatepicker );
  6187. }
  6188. if ( showOn === "button" || showOn === "both" ) { // pop-up date picker when button clicked
  6189. buttonText = this._get( inst, "buttonText" );
  6190. buttonImage = this._get( inst, "buttonImage" );
  6191. inst.trigger = $( this._get( inst, "buttonImageOnly" ) ?
  6192. $( "<img/>" ).addClass( this._triggerClass ).
  6193. attr( { src: buttonImage, alt: buttonText, title: buttonText } ) :
  6194. $( "<button type='button'></button>" ).addClass( this._triggerClass ).
  6195. html( !buttonImage ? buttonText : $( "<img/>" ).attr(
  6196. { src:buttonImage, alt:buttonText, title:buttonText } ) ) );
  6197. input[ isRTL ? "before" : "after" ]( inst.trigger );
  6198. inst.trigger.on( "click", function() {
  6199. if ( $.datepicker._datepickerShowing && $.datepicker._lastInput === input[ 0 ] ) {
  6200. $.datepicker._hideDatepicker();
  6201. } else if ( $.datepicker._datepickerShowing && $.datepicker._lastInput !== input[ 0 ] ) {
  6202. $.datepicker._hideDatepicker();
  6203. $.datepicker._showDatepicker( input[ 0 ] );
  6204. } else {
  6205. $.datepicker._showDatepicker( input[ 0 ] );
  6206. }
  6207. return false;
  6208. } );
  6209. }
  6210. },
  6211. /* Apply the maximum length for the date format. */
  6212. _autoSize: function( inst ) {
  6213. if ( this._get( inst, "autoSize" ) && !inst.inline ) {
  6214. var findMax, max, maxI, i,
  6215. date = new Date( 2009, 12 - 1, 20 ), // Ensure double digits
  6216. dateFormat = this._get( inst, "dateFormat" );
  6217. if ( dateFormat.match( /[DM]/ ) ) {
  6218. findMax = function( names ) {
  6219. max = 0;
  6220. maxI = 0;
  6221. for ( i = 0; i < names.length; i++ ) {
  6222. if ( names[ i ].length > max ) {
  6223. max = names[ i ].length;
  6224. maxI = i;
  6225. }
  6226. }
  6227. return maxI;
  6228. };
  6229. date.setMonth( findMax( this._get( inst, ( dateFormat.match( /MM/ ) ?
  6230. "monthNames" : "monthNamesShort" ) ) ) );
  6231. date.setDate( findMax( this._get( inst, ( dateFormat.match( /DD/ ) ?
  6232. "dayNames" : "dayNamesShort" ) ) ) + 20 - date.getDay() );
  6233. }
  6234. inst.input.attr( "size", this._formatDate( inst, date ).length );
  6235. }
  6236. },
  6237. /* Attach an inline date picker to a div. */
  6238. _inlineDatepicker: function( target, inst ) {
  6239. var divSpan = $( target );
  6240. if ( divSpan.hasClass( this.markerClassName ) ) {
  6241. return;
  6242. }
  6243. divSpan.addClass( this.markerClassName ).append( inst.dpDiv );
  6244. $.data( target, "datepicker", inst );
  6245. this._setDate( inst, this._getDefaultDate( inst ), true );
  6246. this._updateDatepicker( inst );
  6247. this._updateAlternate( inst );
  6248. //If disabled option is true, disable the datepicker before showing it (see ticket #5665)
  6249. if ( inst.settings.disabled ) {
  6250. this._disableDatepicker( target );
  6251. }
  6252. // Set display:block in place of inst.dpDiv.show() which won't work on disconnected elements
  6253. // http://bugs.jqueryui.com/ticket/7552 - A Datepicker created on a detached div has zero height
  6254. inst.dpDiv.css( "display", "block" );
  6255. },
  6256. /* Pop-up the date picker in a "dialog" box.
  6257. * @param input element - ignored
  6258. * @param date string or Date - the initial date to display
  6259. * @param onSelect function - the function to call when a date is selected
  6260. * @param settings object - update the dialog date picker instance's settings (anonymous object)
  6261. * @param pos int[2] - coordinates for the dialog's position within the screen or
  6262. * event - with x/y coordinates or
  6263. * leave empty for default (screen centre)
  6264. * @return the manager object
  6265. */
  6266. _dialogDatepicker: function( input, date, onSelect, settings, pos ) {
  6267. var id, browserWidth, browserHeight, scrollX, scrollY,
  6268. inst = this._dialogInst; // internal instance
  6269. if ( !inst ) {
  6270. this.uuid += 1;
  6271. id = "dp" + this.uuid;
  6272. this._dialogInput = $( "<input type='text' id='" + id +
  6273. "' style='position: absolute; top: -100px; width: 0px;'/>" );
  6274. this._dialogInput.on( "keydown", this._doKeyDown );
  6275. $( "body" ).append( this._dialogInput );
  6276. inst = this._dialogInst = this._newInst( this._dialogInput, false );
  6277. inst.settings = {};
  6278. $.data( this._dialogInput[ 0 ], "datepicker", inst );
  6279. }
  6280. datepicker_extendRemove( inst.settings, settings || {} );
  6281. date = ( date && date.constructor === Date ? this._formatDate( inst, date ) : date );
  6282. this._dialogInput.val( date );
  6283. this._pos = ( pos ? ( pos.length ? pos : [ pos.pageX, pos.pageY ] ) : null );
  6284. if ( !this._pos ) {
  6285. browserWidth = document.documentElement.clientWidth;
  6286. browserHeight = document.documentElement.clientHeight;
  6287. scrollX = document.documentElement.scrollLeft || document.body.scrollLeft;
  6288. scrollY = document.documentElement.scrollTop || document.body.scrollTop;
  6289. this._pos = // should use actual width/height below
  6290. [ ( browserWidth / 2 ) - 100 + scrollX, ( browserHeight / 2 ) - 150 + scrollY ];
  6291. }
  6292. // Move input on screen for focus, but hidden behind dialog
  6293. this._dialogInput.css( "left", ( this._pos[ 0 ] + 20 ) + "px" ).css( "top", this._pos[ 1 ] + "px" );
  6294. inst.settings.onSelect = onSelect;
  6295. this._inDialog = true;
  6296. this.dpDiv.addClass( this._dialogClass );
  6297. this._showDatepicker( this._dialogInput[ 0 ] );
  6298. if ( $.blockUI ) {
  6299. $.blockUI( this.dpDiv );
  6300. }
  6301. $.data( this._dialogInput[ 0 ], "datepicker", inst );
  6302. return this;
  6303. },
  6304. /* Detach a datepicker from its control.
  6305. * @param target element - the target input field or division or span
  6306. */
  6307. _destroyDatepicker: function( target ) {
  6308. var nodeName,
  6309. $target = $( target ),
  6310. inst = $.data( target, "datepicker" );
  6311. if ( !$target.hasClass( this.markerClassName ) ) {
  6312. return;
  6313. }
  6314. nodeName = target.nodeName.toLowerCase();
  6315. $.removeData( target, "datepicker" );
  6316. if ( nodeName === "input" ) {
  6317. inst.append.remove();
  6318. inst.trigger.remove();
  6319. $target.removeClass( this.markerClassName ).
  6320. off( "focus", this._showDatepicker ).
  6321. off( "keydown", this._doKeyDown ).
  6322. off( "keypress", this._doKeyPress ).
  6323. off( "keyup", this._doKeyUp );
  6324. } else if ( nodeName === "div" || nodeName === "span" ) {
  6325. $target.removeClass( this.markerClassName ).empty();
  6326. }
  6327. if ( datepicker_instActive === inst ) {
  6328. datepicker_instActive = null;
  6329. }
  6330. },
  6331. /* Enable the date picker to a jQuery selection.
  6332. * @param target element - the target input field or division or span
  6333. */
  6334. _enableDatepicker: function( target ) {
  6335. var nodeName, inline,
  6336. $target = $( target ),
  6337. inst = $.data( target, "datepicker" );
  6338. if ( !$target.hasClass( this.markerClassName ) ) {
  6339. return;
  6340. }
  6341. nodeName = target.nodeName.toLowerCase();
  6342. if ( nodeName === "input" ) {
  6343. target.disabled = false;
  6344. inst.trigger.filter( "button" ).
  6345. each( function() { this.disabled = false; } ).end().
  6346. filter( "img" ).css( { opacity: "1.0", cursor: "" } );
  6347. } else if ( nodeName === "div" || nodeName === "span" ) {
  6348. inline = $target.children( "." + this._inlineClass );
  6349. inline.children().removeClass( "ui-state-disabled" );
  6350. inline.find( "select.ui-datepicker-month, select.ui-datepicker-year" ).
  6351. prop( "disabled", false );
  6352. }
  6353. this._disabledInputs = $.map( this._disabledInputs,
  6354. function( value ) { return ( value === target ? null : value ); } ); // delete entry
  6355. },
  6356. /* Disable the date picker to a jQuery selection.
  6357. * @param target element - the target input field or division or span
  6358. */
  6359. _disableDatepicker: function( target ) {
  6360. var nodeName, inline,
  6361. $target = $( target ),
  6362. inst = $.data( target, "datepicker" );
  6363. if ( !$target.hasClass( this.markerClassName ) ) {
  6364. return;
  6365. }
  6366. nodeName = target.nodeName.toLowerCase();
  6367. if ( nodeName === "input" ) {
  6368. target.disabled = true;
  6369. inst.trigger.filter( "button" ).
  6370. each( function() { this.disabled = true; } ).end().
  6371. filter( "img" ).css( { opacity: "0.5", cursor: "default" } );
  6372. } else if ( nodeName === "div" || nodeName === "span" ) {
  6373. inline = $target.children( "." + this._inlineClass );
  6374. inline.children().addClass( "ui-state-disabled" );
  6375. inline.find( "select.ui-datepicker-month, select.ui-datepicker-year" ).
  6376. prop( "disabled", true );
  6377. }
  6378. this._disabledInputs = $.map( this._disabledInputs,
  6379. function( value ) { return ( value === target ? null : value ); } ); // delete entry
  6380. this._disabledInputs[ this._disabledInputs.length ] = target;
  6381. },
  6382. /* Is the first field in a jQuery collection disabled as a datepicker?
  6383. * @param target element - the target input field or division or span
  6384. * @return boolean - true if disabled, false if enabled
  6385. */
  6386. _isDisabledDatepicker: function( target ) {
  6387. if ( !target ) {
  6388. return false;
  6389. }
  6390. for ( var i = 0; i < this._disabledInputs.length; i++ ) {
  6391. if ( this._disabledInputs[ i ] === target ) {
  6392. return true;
  6393. }
  6394. }
  6395. return false;
  6396. },
  6397. /* Retrieve the instance data for the target control.
  6398. * @param target element - the target input field or division or span
  6399. * @return object - the associated instance data
  6400. * @throws error if a jQuery problem getting data
  6401. */
  6402. _getInst: function( target ) {
  6403. try {
  6404. return $.data( target, "datepicker" );
  6405. }
  6406. catch ( err ) {
  6407. throw "Missing instance data for this datepicker";
  6408. }
  6409. },
  6410. /* Update or retrieve the settings for a date picker attached to an input field or division.
  6411. * @param target element - the target input field or division or span
  6412. * @param name object - the new settings to update or
  6413. * string - the name of the setting to change or retrieve,
  6414. * when retrieving also "all" for all instance settings or
  6415. * "defaults" for all global defaults
  6416. * @param value any - the new value for the setting
  6417. * (omit if above is an object or to retrieve a value)
  6418. */
  6419. _optionDatepicker: function( target, name, value ) {
  6420. var settings, date, minDate, maxDate,
  6421. inst = this._getInst( target );
  6422. if ( arguments.length === 2 && typeof name === "string" ) {
  6423. return ( name === "defaults" ? $.extend( {}, $.datepicker._defaults ) :
  6424. ( inst ? ( name === "all" ? $.extend( {}, inst.settings ) :
  6425. this._get( inst, name ) ) : null ) );
  6426. }
  6427. settings = name || {};
  6428. if ( typeof name === "string" ) {
  6429. settings = {};
  6430. settings[ name ] = value;
  6431. }
  6432. if ( inst ) {
  6433. if ( this._curInst === inst ) {
  6434. this._hideDatepicker();
  6435. }
  6436. date = this._getDateDatepicker( target, true );
  6437. minDate = this._getMinMaxDate( inst, "min" );
  6438. maxDate = this._getMinMaxDate( inst, "max" );
  6439. datepicker_extendRemove( inst.settings, settings );
  6440. // reformat the old minDate/maxDate values if dateFormat changes and a new minDate/maxDate isn't provided
  6441. if ( minDate !== null && settings.dateFormat !== undefined && settings.minDate === undefined ) {
  6442. inst.settings.minDate = this._formatDate( inst, minDate );
  6443. }
  6444. if ( maxDate !== null && settings.dateFormat !== undefined && settings.maxDate === undefined ) {
  6445. inst.settings.maxDate = this._formatDate( inst, maxDate );
  6446. }
  6447. if ( "disabled" in settings ) {
  6448. if ( settings.disabled ) {
  6449. this._disableDatepicker( target );
  6450. } else {
  6451. this._enableDatepicker( target );
  6452. }
  6453. }
  6454. this._attachments( $( target ), inst );
  6455. this._autoSize( inst );
  6456. this._setDate( inst, date );
  6457. this._updateAlternate( inst );
  6458. this._updateDatepicker( inst );
  6459. }
  6460. },
  6461. // Change method deprecated
  6462. _changeDatepicker: function( target, name, value ) {
  6463. this._optionDatepicker( target, name, value );
  6464. },
  6465. /* Redraw the date picker attached to an input field or division.
  6466. * @param target element - the target input field or division or span
  6467. */
  6468. _refreshDatepicker: function( target ) {
  6469. var inst = this._getInst( target );
  6470. if ( inst ) {
  6471. this._updateDatepicker( inst );
  6472. }
  6473. },
  6474. /* Set the dates for a jQuery selection.
  6475. * @param target element - the target input field or division or span
  6476. * @param date Date - the new date
  6477. */
  6478. _setDateDatepicker: function( target, date ) {
  6479. var inst = this._getInst( target );
  6480. if ( inst ) {
  6481. this._setDate( inst, date );
  6482. this._updateDatepicker( inst );
  6483. this._updateAlternate( inst );
  6484. }
  6485. },
  6486. /* Get the date(s) for the first entry in a jQuery selection.
  6487. * @param target element - the target input field or division or span
  6488. * @param noDefault boolean - true if no default date is to be used
  6489. * @return Date - the current date
  6490. */
  6491. _getDateDatepicker: function( target, noDefault ) {
  6492. var inst = this._getInst( target );
  6493. if ( inst && !inst.inline ) {
  6494. this._setDateFromField( inst, noDefault );
  6495. }
  6496. return ( inst ? this._getDate( inst ) : null );
  6497. },
  6498. /* Handle keystrokes. */
  6499. _doKeyDown: function( event ) {
  6500. var onSelect, dateStr, sel,
  6501. inst = $.datepicker._getInst( event.target ),
  6502. handled = true,
  6503. isRTL = inst.dpDiv.is( ".ui-datepicker-rtl" );
  6504. inst._keyEvent = true;
  6505. if ( $.datepicker._datepickerShowing ) {
  6506. switch ( event.keyCode ) {
  6507. case 9: $.datepicker._hideDatepicker();
  6508. handled = false;
  6509. break; // hide on tab out
  6510. case 13: sel = $( "td." + $.datepicker._dayOverClass + ":not(." +
  6511. $.datepicker._currentClass + ")", inst.dpDiv );
  6512. if ( sel[ 0 ] ) {
  6513. $.datepicker._selectDay( event.target, inst.selectedMonth, inst.selectedYear, sel[ 0 ] );
  6514. }
  6515. onSelect = $.datepicker._get( inst, "onSelect" );
  6516. if ( onSelect ) {
  6517. dateStr = $.datepicker._formatDate( inst );
  6518. // Trigger custom callback
  6519. onSelect.apply( ( inst.input ? inst.input[ 0 ] : null ), [ dateStr, inst ] );
  6520. } else {
  6521. $.datepicker._hideDatepicker();
  6522. }
  6523. return false; // don't submit the form
  6524. case 27: $.datepicker._hideDatepicker();
  6525. break; // hide on escape
  6526. case 33: $.datepicker._adjustDate( event.target, ( event.ctrlKey ?
  6527. -$.datepicker._get( inst, "stepBigMonths" ) :
  6528. -$.datepicker._get( inst, "stepMonths" ) ), "M" );
  6529. break; // previous month/year on page up/+ ctrl
  6530. case 34: $.datepicker._adjustDate( event.target, ( event.ctrlKey ?
  6531. +$.datepicker._get( inst, "stepBigMonths" ) :
  6532. +$.datepicker._get( inst, "stepMonths" ) ), "M" );
  6533. break; // next month/year on page down/+ ctrl
  6534. case 35: if ( event.ctrlKey || event.metaKey ) {
  6535. $.datepicker._clearDate( event.target );
  6536. }
  6537. handled = event.ctrlKey || event.metaKey;
  6538. break; // clear on ctrl or command +end
  6539. case 36: if ( event.ctrlKey || event.metaKey ) {
  6540. $.datepicker._gotoToday( event.target );
  6541. }
  6542. handled = event.ctrlKey || event.metaKey;
  6543. break; // current on ctrl or command +home
  6544. case 37: if ( event.ctrlKey || event.metaKey ) {
  6545. $.datepicker._adjustDate( event.target, ( isRTL ? +1 : -1 ), "D" );
  6546. }
  6547. handled = event.ctrlKey || event.metaKey;
  6548. // -1 day on ctrl or command +left
  6549. if ( event.originalEvent.altKey ) {
  6550. $.datepicker._adjustDate( event.target, ( event.ctrlKey ?
  6551. -$.datepicker._get( inst, "stepBigMonths" ) :
  6552. -$.datepicker._get( inst, "stepMonths" ) ), "M" );
  6553. }
  6554. // next month/year on alt +left on Mac
  6555. break;
  6556. case 38: if ( event.ctrlKey || event.metaKey ) {
  6557. $.datepicker._adjustDate( event.target, -7, "D" );
  6558. }
  6559. handled = event.ctrlKey || event.metaKey;
  6560. break; // -1 week on ctrl or command +up
  6561. case 39: if ( event.ctrlKey || event.metaKey ) {
  6562. $.datepicker._adjustDate( event.target, ( isRTL ? -1 : +1 ), "D" );
  6563. }
  6564. handled = event.ctrlKey || event.metaKey;
  6565. // +1 day on ctrl or command +right
  6566. if ( event.originalEvent.altKey ) {
  6567. $.datepicker._adjustDate( event.target, ( event.ctrlKey ?
  6568. +$.datepicker._get( inst, "stepBigMonths" ) :
  6569. +$.datepicker._get( inst, "stepMonths" ) ), "M" );
  6570. }
  6571. // next month/year on alt +right
  6572. break;
  6573. case 40: if ( event.ctrlKey || event.metaKey ) {
  6574. $.datepicker._adjustDate( event.target, +7, "D" );
  6575. }
  6576. handled = event.ctrlKey || event.metaKey;
  6577. break; // +1 week on ctrl or command +down
  6578. default: handled = false;
  6579. }
  6580. } else if ( event.keyCode === 36 && event.ctrlKey ) { // display the date picker on ctrl+home
  6581. $.datepicker._showDatepicker( this );
  6582. } else {
  6583. handled = false;
  6584. }
  6585. if ( handled ) {
  6586. event.preventDefault();
  6587. event.stopPropagation();
  6588. }
  6589. },
  6590. /* Filter entered characters - based on date format. */
  6591. _doKeyPress: function( event ) {
  6592. var chars, chr,
  6593. inst = $.datepicker._getInst( event.target );
  6594. if ( $.datepicker._get( inst, "constrainInput" ) ) {
  6595. chars = $.datepicker._possibleChars( $.datepicker._get( inst, "dateFormat" ) );
  6596. chr = String.fromCharCode( event.charCode == null ? event.keyCode : event.charCode );
  6597. return event.ctrlKey || event.metaKey || ( chr < " " || !chars || chars.indexOf( chr ) > -1 );
  6598. }
  6599. },
  6600. /* Synchronise manual entry and field/alternate field. */
  6601. _doKeyUp: function( event ) {
  6602. var date,
  6603. inst = $.datepicker._getInst( event.target );
  6604. if ( inst.input.val() !== inst.lastVal ) {
  6605. try {
  6606. date = $.datepicker.parseDate( $.datepicker._get( inst, "dateFormat" ),
  6607. ( inst.input ? inst.input.val() : null ),
  6608. $.datepicker._getFormatConfig( inst ) );
  6609. if ( date ) { // only if valid
  6610. $.datepicker._setDateFromField( inst );
  6611. $.datepicker._updateAlternate( inst );
  6612. $.datepicker._updateDatepicker( inst );
  6613. }
  6614. }
  6615. catch ( err ) {
  6616. }
  6617. }
  6618. return true;
  6619. },
  6620. /* Pop-up the date picker for a given input field.
  6621. * If false returned from beforeShow event handler do not show.
  6622. * @param input element - the input field attached to the date picker or
  6623. * event - if triggered by focus
  6624. */
  6625. _showDatepicker: function( input ) {
  6626. input = input.target || input;
  6627. if ( input.nodeName.toLowerCase() !== "input" ) { // find from button/image trigger
  6628. input = $( "input", input.parentNode )[ 0 ];
  6629. }
  6630. if ( $.datepicker._isDisabledDatepicker( input ) || $.datepicker._lastInput === input ) { // already here
  6631. return;
  6632. }
  6633. var inst, beforeShow, beforeShowSettings, isFixed,
  6634. offset, showAnim, duration;
  6635. inst = $.datepicker._getInst( input );
  6636. if ( $.datepicker._curInst && $.datepicker._curInst !== inst ) {
  6637. $.datepicker._curInst.dpDiv.stop( true, true );
  6638. if ( inst && $.datepicker._datepickerShowing ) {
  6639. $.datepicker._hideDatepicker( $.datepicker._curInst.input[ 0 ] );
  6640. }
  6641. }
  6642. beforeShow = $.datepicker._get( inst, "beforeShow" );
  6643. beforeShowSettings = beforeShow ? beforeShow.apply( input, [ input, inst ] ) : {};
  6644. if ( beforeShowSettings === false ) {
  6645. return;
  6646. }
  6647. datepicker_extendRemove( inst.settings, beforeShowSettings );
  6648. inst.lastVal = null;
  6649. $.datepicker._lastInput = input;
  6650. $.datepicker._setDateFromField( inst );
  6651. if ( $.datepicker._inDialog ) { // hide cursor
  6652. input.value = "";
  6653. }
  6654. if ( !$.datepicker._pos ) { // position below input
  6655. $.datepicker._pos = $.datepicker._findPos( input );
  6656. $.datepicker._pos[ 1 ] += input.offsetHeight; // add the height
  6657. }
  6658. isFixed = false;
  6659. $( input ).parents().each( function() {
  6660. isFixed |= $( this ).css( "position" ) === "fixed";
  6661. return !isFixed;
  6662. } );
  6663. offset = { left: $.datepicker._pos[ 0 ], top: $.datepicker._pos[ 1 ] };
  6664. $.datepicker._pos = null;
  6665. //to avoid flashes on Firefox
  6666. inst.dpDiv.empty();
  6667. // determine sizing offscreen
  6668. inst.dpDiv.css( { position: "absolute", display: "block", top: "-1000px" } );
  6669. $.datepicker._updateDatepicker( inst );
  6670. // fix width for dynamic number of date pickers
  6671. // and adjust position before showing
  6672. offset = $.datepicker._checkOffset( inst, offset, isFixed );
  6673. inst.dpDiv.css( { position: ( $.datepicker._inDialog && $.blockUI ?
  6674. "static" : ( isFixed ? "fixed" : "absolute" ) ), display: "none",
  6675. left: offset.left + "px", top: offset.top + "px" } );
  6676. if ( !inst.inline ) {
  6677. showAnim = $.datepicker._get( inst, "showAnim" );
  6678. duration = $.datepicker._get( inst, "duration" );
  6679. inst.dpDiv.css( "z-index", datepicker_getZindex( $( input ) ) + 1 );
  6680. $.datepicker._datepickerShowing = true;
  6681. if ( $.effects && $.effects.effect[ showAnim ] ) {
  6682. inst.dpDiv.show( showAnim, $.datepicker._get( inst, "showOptions" ), duration );
  6683. } else {
  6684. inst.dpDiv[ showAnim || "show" ]( showAnim ? duration : null );
  6685. }
  6686. if ( $.datepicker._shouldFocusInput( inst ) ) {
  6687. inst.input.trigger( "focus" );
  6688. }
  6689. $.datepicker._curInst = inst;
  6690. }
  6691. },
  6692. /* Generate the date picker content. */
  6693. _updateDatepicker: function( inst ) {
  6694. this.maxRows = 4; //Reset the max number of rows being displayed (see #7043)
  6695. datepicker_instActive = inst; // for delegate hover events
  6696. inst.dpDiv.empty().append( this._generateHTML( inst ) );
  6697. this._attachHandlers( inst );
  6698. var origyearshtml,
  6699. numMonths = this._getNumberOfMonths( inst ),
  6700. cols = numMonths[ 1 ],
  6701. width = 17,
  6702. activeCell = inst.dpDiv.find( "." + this._dayOverClass + " a" );
  6703. if ( activeCell.length > 0 ) {
  6704. datepicker_handleMouseover.apply( activeCell.get( 0 ) );
  6705. }
  6706. inst.dpDiv.removeClass( "ui-datepicker-multi-2 ui-datepicker-multi-3 ui-datepicker-multi-4" ).width( "" );
  6707. if ( cols > 1 ) {
  6708. inst.dpDiv.addClass( "ui-datepicker-multi-" + cols ).css( "width", ( width * cols ) + "em" );
  6709. }
  6710. inst.dpDiv[ ( numMonths[ 0 ] !== 1 || numMonths[ 1 ] !== 1 ? "add" : "remove" ) +
  6711. "Class" ]( "ui-datepicker-multi" );
  6712. inst.dpDiv[ ( this._get( inst, "isRTL" ) ? "add" : "remove" ) +
  6713. "Class" ]( "ui-datepicker-rtl" );
  6714. if ( inst === $.datepicker._curInst && $.datepicker._datepickerShowing && $.datepicker._shouldFocusInput( inst ) ) {
  6715. inst.input.trigger( "focus" );
  6716. }
  6717. // Deffered render of the years select (to avoid flashes on Firefox)
  6718. if ( inst.yearshtml ) {
  6719. origyearshtml = inst.yearshtml;
  6720. setTimeout( function() {
  6721. //assure that inst.yearshtml didn't change.
  6722. if ( origyearshtml === inst.yearshtml && inst.yearshtml ) {
  6723. inst.dpDiv.find( "select.ui-datepicker-year:first" ).replaceWith( inst.yearshtml );
  6724. }
  6725. origyearshtml = inst.yearshtml = null;
  6726. }, 0 );
  6727. }
  6728. },
  6729. // #6694 - don't focus the input if it's already focused
  6730. // this breaks the change event in IE
  6731. // Support: IE and jQuery <1.9
  6732. _shouldFocusInput: function( inst ) {
  6733. return inst.input && inst.input.is( ":visible" ) && !inst.input.is( ":disabled" ) && !inst.input.is( ":focus" );
  6734. },
  6735. /* Check positioning to remain on screen. */
  6736. _checkOffset: function( inst, offset, isFixed ) {
  6737. var dpWidth = inst.dpDiv.outerWidth(),
  6738. dpHeight = inst.dpDiv.outerHeight(),
  6739. inputWidth = inst.input ? inst.input.outerWidth() : 0,
  6740. inputHeight = inst.input ? inst.input.outerHeight() : 0,
  6741. viewWidth = document.documentElement.clientWidth + ( isFixed ? 0 : $( document ).scrollLeft() ),
  6742. viewHeight = document.documentElement.clientHeight + ( isFixed ? 0 : $( document ).scrollTop() );
  6743. offset.left -= ( this._get( inst, "isRTL" ) ? ( dpWidth - inputWidth ) : 0 );
  6744. offset.left -= ( isFixed && offset.left === inst.input.offset().left ) ? $( document ).scrollLeft() : 0;
  6745. offset.top -= ( isFixed && offset.top === ( inst.input.offset().top + inputHeight ) ) ? $( document ).scrollTop() : 0;
  6746. // Now check if datepicker is showing outside window viewport - move to a better place if so.
  6747. offset.left -= Math.min( offset.left, ( offset.left + dpWidth > viewWidth && viewWidth > dpWidth ) ?
  6748. Math.abs( offset.left + dpWidth - viewWidth ) : 0 );
  6749. offset.top -= Math.min( offset.top, ( offset.top + dpHeight > viewHeight && viewHeight > dpHeight ) ?
  6750. Math.abs( dpHeight + inputHeight ) : 0 );
  6751. return offset;
  6752. },
  6753. /* Find an object's position on the screen. */
  6754. _findPos: function( obj ) {
  6755. var position,
  6756. inst = this._getInst( obj ),
  6757. isRTL = this._get( inst, "isRTL" );
  6758. while ( obj && ( obj.type === "hidden" || obj.nodeType !== 1 || $.expr.filters.hidden( obj ) ) ) {
  6759. obj = obj[ isRTL ? "previousSibling" : "nextSibling" ];
  6760. }
  6761. position = $( obj ).offset();
  6762. return [ position.left, position.top ];
  6763. },
  6764. /* Hide the date picker from view.
  6765. * @param input element - the input field attached to the date picker
  6766. */
  6767. _hideDatepicker: function( input ) {
  6768. var showAnim, duration, postProcess, onClose,
  6769. inst = this._curInst;
  6770. if ( !inst || ( input && inst !== $.data( input, "datepicker" ) ) ) {
  6771. return;
  6772. }
  6773. if ( this._datepickerShowing ) {
  6774. showAnim = this._get( inst, "showAnim" );
  6775. duration = this._get( inst, "duration" );
  6776. postProcess = function() {
  6777. $.datepicker._tidyDialog( inst );
  6778. };
  6779. // DEPRECATED: after BC for 1.8.x $.effects[ showAnim ] is not needed
  6780. if ( $.effects && ( $.effects.effect[ showAnim ] || $.effects[ showAnim ] ) ) {
  6781. inst.dpDiv.hide( showAnim, $.datepicker._get( inst, "showOptions" ), duration, postProcess );
  6782. } else {
  6783. inst.dpDiv[ ( showAnim === "slideDown" ? "slideUp" :
  6784. ( showAnim === "fadeIn" ? "fadeOut" : "hide" ) ) ]( ( showAnim ? duration : null ), postProcess );
  6785. }
  6786. if ( !showAnim ) {
  6787. postProcess();
  6788. }
  6789. this._datepickerShowing = false;
  6790. onClose = this._get( inst, "onClose" );
  6791. if ( onClose ) {
  6792. onClose.apply( ( inst.input ? inst.input[ 0 ] : null ), [ ( inst.input ? inst.input.val() : "" ), inst ] );
  6793. }
  6794. this._lastInput = null;
  6795. if ( this._inDialog ) {
  6796. this._dialogInput.css( { position: "absolute", left: "0", top: "-100px" } );
  6797. if ( $.blockUI ) {
  6798. $.unblockUI();
  6799. $( "body" ).append( this.dpDiv );
  6800. }
  6801. }
  6802. this._inDialog = false;
  6803. }
  6804. },
  6805. /* Tidy up after a dialog display. */
  6806. _tidyDialog: function( inst ) {
  6807. inst.dpDiv.removeClass( this._dialogClass ).off( ".ui-datepicker-calendar" );
  6808. },
  6809. /* Close date picker if clicked elsewhere. */
  6810. _checkExternalClick: function( event ) {
  6811. if ( !$.datepicker._curInst ) {
  6812. return;
  6813. }
  6814. var $target = $( event.target ),
  6815. inst = $.datepicker._getInst( $target[ 0 ] );
  6816. if ( ( ( $target[ 0 ].id !== $.datepicker._mainDivId &&
  6817. $target.parents( "#" + $.datepicker._mainDivId ).length === 0 &&
  6818. !$target.hasClass( $.datepicker.markerClassName ) &&
  6819. !$target.closest( "." + $.datepicker._triggerClass ).length &&
  6820. $.datepicker._datepickerShowing && !( $.datepicker._inDialog && $.blockUI ) ) ) ||
  6821. ( $target.hasClass( $.datepicker.markerClassName ) && $.datepicker._curInst !== inst ) ) {
  6822. $.datepicker._hideDatepicker();
  6823. }
  6824. },
  6825. /* Adjust one of the date sub-fields. */
  6826. _adjustDate: function( id, offset, period ) {
  6827. var target = $( id ),
  6828. inst = this._getInst( target[ 0 ] );
  6829. if ( this._isDisabledDatepicker( target[ 0 ] ) ) {
  6830. return;
  6831. }
  6832. this._adjustInstDate( inst, offset +
  6833. ( period === "M" ? this._get( inst, "showCurrentAtPos" ) : 0 ), // undo positioning
  6834. period );
  6835. this._updateDatepicker( inst );
  6836. },
  6837. /* Action for current link. */
  6838. _gotoToday: function( id ) {
  6839. var date,
  6840. target = $( id ),
  6841. inst = this._getInst( target[ 0 ] );
  6842. if ( this._get( inst, "gotoCurrent" ) && inst.currentDay ) {
  6843. inst.selectedDay = inst.currentDay;
  6844. inst.drawMonth = inst.selectedMonth = inst.currentMonth;
  6845. inst.drawYear = inst.selectedYear = inst.currentYear;
  6846. } else {
  6847. date = new Date();
  6848. inst.selectedDay = date.getDate();
  6849. inst.drawMonth = inst.selectedMonth = date.getMonth();
  6850. inst.drawYear = inst.selectedYear = date.getFullYear();
  6851. }
  6852. this._notifyChange( inst );
  6853. this._adjustDate( target );
  6854. },
  6855. /* Action for selecting a new month/year. */
  6856. _selectMonthYear: function( id, select, period ) {
  6857. var target = $( id ),
  6858. inst = this._getInst( target[ 0 ] );
  6859. inst[ "selected" + ( period === "M" ? "Month" : "Year" ) ] =
  6860. inst[ "draw" + ( period === "M" ? "Month" : "Year" ) ] =
  6861. parseInt( select.options[ select.selectedIndex ].value, 10 );
  6862. this._notifyChange( inst );
  6863. this._adjustDate( target );
  6864. },
  6865. /* Action for selecting a day. */
  6866. _selectDay: function( id, month, year, td ) {
  6867. var inst,
  6868. target = $( id );
  6869. if ( $( td ).hasClass( this._unselectableClass ) || this._isDisabledDatepicker( target[ 0 ] ) ) {
  6870. return;
  6871. }
  6872. inst = this._getInst( target[ 0 ] );
  6873. inst.selectedDay = inst.currentDay = $( "a", td ).html();
  6874. inst.selectedMonth = inst.currentMonth = month;
  6875. inst.selectedYear = inst.currentYear = year;
  6876. this._selectDate( id, this._formatDate( inst,
  6877. inst.currentDay, inst.currentMonth, inst.currentYear ) );
  6878. },
  6879. /* Erase the input field and hide the date picker. */
  6880. _clearDate: function( id ) {
  6881. var target = $( id );
  6882. this._selectDate( target, "" );
  6883. },
  6884. /* Update the input field with the selected date. */
  6885. _selectDate: function( id, dateStr ) {
  6886. var onSelect,
  6887. target = $( id ),
  6888. inst = this._getInst( target[ 0 ] );
  6889. dateStr = ( dateStr != null ? dateStr : this._formatDate( inst ) );
  6890. if ( inst.input ) {
  6891. inst.input.val( dateStr );
  6892. }
  6893. this._updateAlternate( inst );
  6894. onSelect = this._get( inst, "onSelect" );
  6895. if ( onSelect ) {
  6896. onSelect.apply( ( inst.input ? inst.input[ 0 ] : null ), [ dateStr, inst ] ); // trigger custom callback
  6897. } else if ( inst.input ) {
  6898. inst.input.trigger( "change" ); // fire the change event
  6899. }
  6900. if ( inst.inline ) {
  6901. this._updateDatepicker( inst );
  6902. } else {
  6903. this._hideDatepicker();
  6904. this._lastInput = inst.input[ 0 ];
  6905. if ( typeof( inst.input[ 0 ] ) !== "object" ) {
  6906. inst.input.trigger( "focus" ); // restore focus
  6907. }
  6908. this._lastInput = null;
  6909. }
  6910. },
  6911. /* Update any alternate field to synchronise with the main field. */
  6912. _updateAlternate: function( inst ) {
  6913. var altFormat, date, dateStr,
  6914. altField = this._get( inst, "altField" );
  6915. if ( altField ) { // update alternate field too
  6916. altFormat = this._get( inst, "altFormat" ) || this._get( inst, "dateFormat" );
  6917. date = this._getDate( inst );
  6918. dateStr = this.formatDate( altFormat, date, this._getFormatConfig( inst ) );
  6919. $( altField ).val( dateStr );
  6920. }
  6921. },
  6922. /* Set as beforeShowDay function to prevent selection of weekends.
  6923. * @param date Date - the date to customise
  6924. * @return [boolean, string] - is this date selectable?, what is its CSS class?
  6925. */
  6926. noWeekends: function( date ) {
  6927. var day = date.getDay();
  6928. return [ ( day > 0 && day < 6 ), "" ];
  6929. },
  6930. /* Set as calculateWeek to determine the week of the year based on the ISO 8601 definition.
  6931. * @param date Date - the date to get the week for
  6932. * @return number - the number of the week within the year that contains this date
  6933. */
  6934. iso8601Week: function( date ) {
  6935. var time,
  6936. checkDate = new Date( date.getTime() );
  6937. // Find Thursday of this week starting on Monday
  6938. checkDate.setDate( checkDate.getDate() + 4 - ( checkDate.getDay() || 7 ) );
  6939. time = checkDate.getTime();
  6940. checkDate.setMonth( 0 ); // Compare with Jan 1
  6941. checkDate.setDate( 1 );
  6942. return Math.floor( Math.round( ( time - checkDate ) / 86400000 ) / 7 ) + 1;
  6943. },
  6944. /* Parse a string value into a date object.
  6945. * See formatDate below for the possible formats.
  6946. *
  6947. * @param format string - the expected format of the date
  6948. * @param value string - the date in the above format
  6949. * @param settings Object - attributes include:
  6950. * shortYearCutoff number - the cutoff year for determining the century (optional)
  6951. * dayNamesShort string[7] - abbreviated names of the days from Sunday (optional)
  6952. * dayNames string[7] - names of the days from Sunday (optional)
  6953. * monthNamesShort string[12] - abbreviated names of the months (optional)
  6954. * monthNames string[12] - names of the months (optional)
  6955. * @return Date - the extracted date value or null if value is blank
  6956. */
  6957. parseDate: function( format, value, settings ) {
  6958. if ( format == null || value == null ) {
  6959. throw "Invalid arguments";
  6960. }
  6961. value = ( typeof value === "object" ? value.toString() : value + "" );
  6962. if ( value === "" ) {
  6963. return null;
  6964. }
  6965. var iFormat, dim, extra,
  6966. iValue = 0,
  6967. shortYearCutoffTemp = ( settings ? settings.shortYearCutoff : null ) || this._defaults.shortYearCutoff,
  6968. shortYearCutoff = ( typeof shortYearCutoffTemp !== "string" ? shortYearCutoffTemp :
  6969. new Date().getFullYear() % 100 + parseInt( shortYearCutoffTemp, 10 ) ),
  6970. dayNamesShort = ( settings ? settings.dayNamesShort : null ) || this._defaults.dayNamesShort,
  6971. dayNames = ( settings ? settings.dayNames : null ) || this._defaults.dayNames,
  6972. monthNamesShort = ( settings ? settings.monthNamesShort : null ) || this._defaults.monthNamesShort,
  6973. monthNames = ( settings ? settings.monthNames : null ) || this._defaults.monthNames,
  6974. year = -1,
  6975. month = -1,
  6976. day = -1,
  6977. doy = -1,
  6978. literal = false,
  6979. date,
  6980. // Check whether a format character is doubled
  6981. lookAhead = function( match ) {
  6982. var matches = ( iFormat + 1 < format.length && format.charAt( iFormat + 1 ) === match );
  6983. if ( matches ) {
  6984. iFormat++;
  6985. }
  6986. return matches;
  6987. },
  6988. // Extract a number from the string value
  6989. getNumber = function( match ) {
  6990. var isDoubled = lookAhead( match ),
  6991. size = ( match === "@" ? 14 : ( match === "!" ? 20 :
  6992. ( match === "y" && isDoubled ? 4 : ( match === "o" ? 3 : 2 ) ) ) ),
  6993. minSize = ( match === "y" ? size : 1 ),
  6994. digits = new RegExp( "^\\d{" + minSize + "," + size + "}" ),
  6995. num = value.substring( iValue ).match( digits );
  6996. if ( !num ) {
  6997. throw "Missing number at position " + iValue;
  6998. }
  6999. iValue += num[ 0 ].length;
  7000. return parseInt( num[ 0 ], 10 );
  7001. },
  7002. // Extract a name from the string value and convert to an index
  7003. getName = function( match, shortNames, longNames ) {
  7004. var index = -1,
  7005. names = $.map( lookAhead( match ) ? longNames : shortNames, function( v, k ) {
  7006. return [ [ k, v ] ];
  7007. } ).sort( function( a, b ) {
  7008. return -( a[ 1 ].length - b[ 1 ].length );
  7009. } );
  7010. $.each( names, function( i, pair ) {
  7011. var name = pair[ 1 ];
  7012. if ( value.substr( iValue, name.length ).toLowerCase() === name.toLowerCase() ) {
  7013. index = pair[ 0 ];
  7014. iValue += name.length;
  7015. return false;
  7016. }
  7017. } );
  7018. if ( index !== -1 ) {
  7019. return index + 1;
  7020. } else {
  7021. throw "Unknown name at position " + iValue;
  7022. }
  7023. },
  7024. // Confirm that a literal character matches the string value
  7025. checkLiteral = function() {
  7026. if ( value.charAt( iValue ) !== format.charAt( iFormat ) ) {
  7027. throw "Unexpected literal at position " + iValue;
  7028. }
  7029. iValue++;
  7030. };
  7031. for ( iFormat = 0; iFormat < format.length; iFormat++ ) {
  7032. if ( literal ) {
  7033. if ( format.charAt( iFormat ) === "'" && !lookAhead( "'" ) ) {
  7034. literal = false;
  7035. } else {
  7036. checkLiteral();
  7037. }
  7038. } else {
  7039. switch ( format.charAt( iFormat ) ) {
  7040. case "d":
  7041. day = getNumber( "d" );
  7042. break;
  7043. case "D":
  7044. getName( "D", dayNamesShort, dayNames );
  7045. break;
  7046. case "o":
  7047. doy = getNumber( "o" );
  7048. break;
  7049. case "m":
  7050. month = getNumber( "m" );
  7051. break;
  7052. case "M":
  7053. month = getName( "M", monthNamesShort, monthNames );
  7054. break;
  7055. case "y":
  7056. year = getNumber( "y" );
  7057. break;
  7058. case "@":
  7059. date = new Date( getNumber( "@" ) );
  7060. year = date.getFullYear();
  7061. month = date.getMonth() + 1;
  7062. day = date.getDate();
  7063. break;
  7064. case "!":
  7065. date = new Date( ( getNumber( "!" ) - this._ticksTo1970 ) / 10000 );
  7066. year = date.getFullYear();
  7067. month = date.getMonth() + 1;
  7068. day = date.getDate();
  7069. break;
  7070. case "'":
  7071. if ( lookAhead( "'" ) ) {
  7072. checkLiteral();
  7073. } else {
  7074. literal = true;
  7075. }
  7076. break;
  7077. default:
  7078. checkLiteral();
  7079. }
  7080. }
  7081. }
  7082. if ( iValue < value.length ) {
  7083. extra = value.substr( iValue );
  7084. if ( !/^\s+/.test( extra ) ) {
  7085. throw "Extra/unparsed characters found in date: " + extra;
  7086. }
  7087. }
  7088. if ( year === -1 ) {
  7089. year = new Date().getFullYear();
  7090. } else if ( year < 100 ) {
  7091. year += new Date().getFullYear() - new Date().getFullYear() % 100 +
  7092. ( year <= shortYearCutoff ? 0 : -100 );
  7093. }
  7094. if ( doy > -1 ) {
  7095. month = 1;
  7096. day = doy;
  7097. do {
  7098. dim = this._getDaysInMonth( year, month - 1 );
  7099. if ( day <= dim ) {
  7100. break;
  7101. }
  7102. month++;
  7103. day -= dim;
  7104. } while ( true );
  7105. }
  7106. date = this._daylightSavingAdjust( new Date( year, month - 1, day ) );
  7107. if ( date.getFullYear() !== year || date.getMonth() + 1 !== month || date.getDate() !== day ) {
  7108. throw "Invalid date"; // E.g. 31/02/00
  7109. }
  7110. return date;
  7111. },
  7112. /* Standard date formats. */
  7113. ATOM: "yy-mm-dd", // RFC 3339 (ISO 8601)
  7114. COOKIE: "D, dd M yy",
  7115. ISO_8601: "yy-mm-dd",
  7116. RFC_822: "D, d M y",
  7117. RFC_850: "DD, dd-M-y",
  7118. RFC_1036: "D, d M y",
  7119. RFC_1123: "D, d M yy",
  7120. RFC_2822: "D, d M yy",
  7121. RSS: "D, d M y", // RFC 822
  7122. TICKS: "!",
  7123. TIMESTAMP: "@",
  7124. W3C: "yy-mm-dd", // ISO 8601
  7125. _ticksTo1970: ( ( ( 1970 - 1 ) * 365 + Math.floor( 1970 / 4 ) - Math.floor( 1970 / 100 ) +
  7126. Math.floor( 1970 / 400 ) ) * 24 * 60 * 60 * 10000000 ),
  7127. /* Format a date object into a string value.
  7128. * The format can be combinations of the following:
  7129. * d - day of month (no leading zero)
  7130. * dd - day of month (two digit)
  7131. * o - day of year (no leading zeros)
  7132. * oo - day of year (three digit)
  7133. * D - day name short
  7134. * DD - day name long
  7135. * m - month of year (no leading zero)
  7136. * mm - month of year (two digit)
  7137. * M - month name short
  7138. * MM - month name long
  7139. * y - year (two digit)
  7140. * yy - year (four digit)
  7141. * @ - Unix timestamp (ms since 01/01/1970)
  7142. * ! - Windows ticks (100ns since 01/01/0001)
  7143. * "..." - literal text
  7144. * '' - single quote
  7145. *
  7146. * @param format string - the desired format of the date
  7147. * @param date Date - the date value to format
  7148. * @param settings Object - attributes include:
  7149. * dayNamesShort string[7] - abbreviated names of the days from Sunday (optional)
  7150. * dayNames string[7] - names of the days from Sunday (optional)
  7151. * monthNamesShort string[12] - abbreviated names of the months (optional)
  7152. * monthNames string[12] - names of the months (optional)
  7153. * @return string - the date in the above format
  7154. */
  7155. formatDate: function( format, date, settings ) {
  7156. if ( !date ) {
  7157. return "";
  7158. }
  7159. var iFormat,
  7160. dayNamesShort = ( settings ? settings.dayNamesShort : null ) || this._defaults.dayNamesShort,
  7161. dayNames = ( settings ? settings.dayNames : null ) || this._defaults.dayNames,
  7162. monthNamesShort = ( settings ? settings.monthNamesShort : null ) || this._defaults.monthNamesShort,
  7163. monthNames = ( settings ? settings.monthNames : null ) || this._defaults.monthNames,
  7164. // Check whether a format character is doubled
  7165. lookAhead = function( match ) {
  7166. var matches = ( iFormat + 1 < format.length && format.charAt( iFormat + 1 ) === match );
  7167. if ( matches ) {
  7168. iFormat++;
  7169. }
  7170. return matches;
  7171. },
  7172. // Format a number, with leading zero if necessary
  7173. formatNumber = function( match, value, len ) {
  7174. var num = "" + value;
  7175. if ( lookAhead( match ) ) {
  7176. while ( num.length < len ) {
  7177. num = "0" + num;
  7178. }
  7179. }
  7180. return num;
  7181. },
  7182. // Format a name, short or long as requested
  7183. formatName = function( match, value, shortNames, longNames ) {
  7184. return ( lookAhead( match ) ? longNames[ value ] : shortNames[ value ] );
  7185. },
  7186. output = "",
  7187. literal = false;
  7188. if ( date ) {
  7189. for ( iFormat = 0; iFormat < format.length; iFormat++ ) {
  7190. if ( literal ) {
  7191. if ( format.charAt( iFormat ) === "'" && !lookAhead( "'" ) ) {
  7192. literal = false;
  7193. } else {
  7194. output += format.charAt( iFormat );
  7195. }
  7196. } else {
  7197. switch ( format.charAt( iFormat ) ) {
  7198. case "d":
  7199. output += formatNumber( "d", date.getDate(), 2 );
  7200. break;
  7201. case "D":
  7202. output += formatName( "D", date.getDay(), dayNamesShort, dayNames );
  7203. break;
  7204. case "o":
  7205. output += formatNumber( "o",
  7206. Math.round( ( new Date( date.getFullYear(), date.getMonth(), date.getDate() ).getTime() - new Date( date.getFullYear(), 0, 0 ).getTime() ) / 86400000 ), 3 );
  7207. break;
  7208. case "m":
  7209. output += formatNumber( "m", date.getMonth() + 1, 2 );
  7210. break;
  7211. case "M":
  7212. output += formatName( "M", date.getMonth(), monthNamesShort, monthNames );
  7213. break;
  7214. case "y":
  7215. output += ( lookAhead( "y" ) ? date.getFullYear() :
  7216. ( date.getFullYear() % 100 < 10 ? "0" : "" ) + date.getFullYear() % 100 );
  7217. break;
  7218. case "@":
  7219. output += date.getTime();
  7220. break;
  7221. case "!":
  7222. output += date.getTime() * 10000 + this._ticksTo1970;
  7223. break;
  7224. case "'":
  7225. if ( lookAhead( "'" ) ) {
  7226. output += "'";
  7227. } else {
  7228. literal = true;
  7229. }
  7230. break;
  7231. default:
  7232. output += format.charAt( iFormat );
  7233. }
  7234. }
  7235. }
  7236. }
  7237. return output;
  7238. },
  7239. /* Extract all possible characters from the date format. */
  7240. _possibleChars: function( format ) {
  7241. var iFormat,
  7242. chars = "",
  7243. literal = false,
  7244. // Check whether a format character is doubled
  7245. lookAhead = function( match ) {
  7246. var matches = ( iFormat + 1 < format.length && format.charAt( iFormat + 1 ) === match );
  7247. if ( matches ) {
  7248. iFormat++;
  7249. }
  7250. return matches;
  7251. };
  7252. for ( iFormat = 0; iFormat < format.length; iFormat++ ) {
  7253. if ( literal ) {
  7254. if ( format.charAt( iFormat ) === "'" && !lookAhead( "'" ) ) {
  7255. literal = false;
  7256. } else {
  7257. chars += format.charAt( iFormat );
  7258. }
  7259. } else {
  7260. switch ( format.charAt( iFormat ) ) {
  7261. case "d": case "m": case "y": case "@":
  7262. chars += "0123456789";
  7263. break;
  7264. case "D": case "M":
  7265. return null; // Accept anything
  7266. case "'":
  7267. if ( lookAhead( "'" ) ) {
  7268. chars += "'";
  7269. } else {
  7270. literal = true;
  7271. }
  7272. break;
  7273. default:
  7274. chars += format.charAt( iFormat );
  7275. }
  7276. }
  7277. }
  7278. return chars;
  7279. },
  7280. /* Get a setting value, defaulting if necessary. */
  7281. _get: function( inst, name ) {
  7282. return inst.settings[ name ] !== undefined ?
  7283. inst.settings[ name ] : this._defaults[ name ];
  7284. },
  7285. /* Parse existing date and initialise date picker. */
  7286. _setDateFromField: function( inst, noDefault ) {
  7287. if ( inst.input.val() === inst.lastVal ) {
  7288. return;
  7289. }
  7290. var dateFormat = this._get( inst, "dateFormat" ),
  7291. dates = inst.lastVal = inst.input ? inst.input.val() : null,
  7292. defaultDate = this._getDefaultDate( inst ),
  7293. date = defaultDate,
  7294. settings = this._getFormatConfig( inst );
  7295. try {
  7296. date = this.parseDate( dateFormat, dates, settings ) || defaultDate;
  7297. } catch ( event ) {
  7298. dates = ( noDefault ? "" : dates );
  7299. }
  7300. inst.selectedDay = date.getDate();
  7301. inst.drawMonth = inst.selectedMonth = date.getMonth();
  7302. inst.drawYear = inst.selectedYear = date.getFullYear();
  7303. inst.currentDay = ( dates ? date.getDate() : 0 );
  7304. inst.currentMonth = ( dates ? date.getMonth() : 0 );
  7305. inst.currentYear = ( dates ? date.getFullYear() : 0 );
  7306. this._adjustInstDate( inst );
  7307. },
  7308. /* Retrieve the default date shown on opening. */
  7309. _getDefaultDate: function( inst ) {
  7310. return this._restrictMinMax( inst,
  7311. this._determineDate( inst, this._get( inst, "defaultDate" ), new Date() ) );
  7312. },
  7313. /* A date may be specified as an exact value or a relative one. */
  7314. _determineDate: function( inst, date, defaultDate ) {
  7315. var offsetNumeric = function( offset ) {
  7316. var date = new Date();
  7317. date.setDate( date.getDate() + offset );
  7318. return date;
  7319. },
  7320. offsetString = function( offset ) {
  7321. try {
  7322. return $.datepicker.parseDate( $.datepicker._get( inst, "dateFormat" ),
  7323. offset, $.datepicker._getFormatConfig( inst ) );
  7324. }
  7325. catch ( e ) {
  7326. // Ignore
  7327. }
  7328. var date = ( offset.toLowerCase().match( /^c/ ) ?
  7329. $.datepicker._getDate( inst ) : null ) || new Date(),
  7330. year = date.getFullYear(),
  7331. month = date.getMonth(),
  7332. day = date.getDate(),
  7333. pattern = /([+\-]?[0-9]+)\s*(d|D|w|W|m|M|y|Y)?/g,
  7334. matches = pattern.exec( offset );
  7335. while ( matches ) {
  7336. switch ( matches[ 2 ] || "d" ) {
  7337. case "d" : case "D" :
  7338. day += parseInt( matches[ 1 ], 10 ); break;
  7339. case "w" : case "W" :
  7340. day += parseInt( matches[ 1 ], 10 ) * 7; break;
  7341. case "m" : case "M" :
  7342. month += parseInt( matches[ 1 ], 10 );
  7343. day = Math.min( day, $.datepicker._getDaysInMonth( year, month ) );
  7344. break;
  7345. case "y": case "Y" :
  7346. year += parseInt( matches[ 1 ], 10 );
  7347. day = Math.min( day, $.datepicker._getDaysInMonth( year, month ) );
  7348. break;
  7349. }
  7350. matches = pattern.exec( offset );
  7351. }
  7352. return new Date( year, month, day );
  7353. },
  7354. newDate = ( date == null || date === "" ? defaultDate : ( typeof date === "string" ? offsetString( date ) :
  7355. ( typeof date === "number" ? ( isNaN( date ) ? defaultDate : offsetNumeric( date ) ) : new Date( date.getTime() ) ) ) );
  7356. newDate = ( newDate && newDate.toString() === "Invalid Date" ? defaultDate : newDate );
  7357. if ( newDate ) {
  7358. newDate.setHours( 0 );
  7359. newDate.setMinutes( 0 );
  7360. newDate.setSeconds( 0 );
  7361. newDate.setMilliseconds( 0 );
  7362. }
  7363. return this._daylightSavingAdjust( newDate );
  7364. },
  7365. /* Handle switch to/from daylight saving.
  7366. * Hours may be non-zero on daylight saving cut-over:
  7367. * > 12 when midnight changeover, but then cannot generate
  7368. * midnight datetime, so jump to 1AM, otherwise reset.
  7369. * @param date (Date) the date to check
  7370. * @return (Date) the corrected date
  7371. */
  7372. _daylightSavingAdjust: function( date ) {
  7373. if ( !date ) {
  7374. return null;
  7375. }
  7376. date.setHours( date.getHours() > 12 ? date.getHours() + 2 : 0 );
  7377. return date;
  7378. },
  7379. /* Set the date(s) directly. */
  7380. _setDate: function( inst, date, noChange ) {
  7381. var clear = !date,
  7382. origMonth = inst.selectedMonth,
  7383. origYear = inst.selectedYear,
  7384. newDate = this._restrictMinMax( inst, this._determineDate( inst, date, new Date() ) );
  7385. inst.selectedDay = inst.currentDay = newDate.getDate();
  7386. inst.drawMonth = inst.selectedMonth = inst.currentMonth = newDate.getMonth();
  7387. inst.drawYear = inst.selectedYear = inst.currentYear = newDate.getFullYear();
  7388. if ( ( origMonth !== inst.selectedMonth || origYear !== inst.selectedYear ) && !noChange ) {
  7389. this._notifyChange( inst );
  7390. }
  7391. this._adjustInstDate( inst );
  7392. if ( inst.input ) {
  7393. inst.input.val( clear ? "" : this._formatDate( inst ) );
  7394. }
  7395. },
  7396. /* Retrieve the date(s) directly. */
  7397. _getDate: function( inst ) {
  7398. var startDate = ( !inst.currentYear || ( inst.input && inst.input.val() === "" ) ? null :
  7399. this._daylightSavingAdjust( new Date(
  7400. inst.currentYear, inst.currentMonth, inst.currentDay ) ) );
  7401. return startDate;
  7402. },
  7403. /* Attach the onxxx handlers. These are declared statically so
  7404. * they work with static code transformers like Caja.
  7405. */
  7406. _attachHandlers: function( inst ) {
  7407. var stepMonths = this._get( inst, "stepMonths" ),
  7408. id = "#" + inst.id.replace( /\\\\/g, "\\" );
  7409. inst.dpDiv.find( "[data-handler]" ).map( function() {
  7410. var handler = {
  7411. prev: function() {
  7412. $.datepicker._adjustDate( id, -stepMonths, "M" );
  7413. },
  7414. next: function() {
  7415. $.datepicker._adjustDate( id, +stepMonths, "M" );
  7416. },
  7417. hide: function() {
  7418. $.datepicker._hideDatepicker();
  7419. },
  7420. today: function() {
  7421. $.datepicker._gotoToday( id );
  7422. },
  7423. selectDay: function() {
  7424. $.datepicker._selectDay( id, +this.getAttribute( "data-month" ), +this.getAttribute( "data-year" ), this );
  7425. return false;
  7426. },
  7427. selectMonth: function() {
  7428. $.datepicker._selectMonthYear( id, this, "M" );
  7429. return false;
  7430. },
  7431. selectYear: function() {
  7432. $.datepicker._selectMonthYear( id, this, "Y" );
  7433. return false;
  7434. }
  7435. };
  7436. $( this ).on( this.getAttribute( "data-event" ), handler[ this.getAttribute( "data-handler" ) ] );
  7437. } );
  7438. },
  7439. /* Generate the HTML for the current state of the date picker. */
  7440. _generateHTML: function( inst ) {
  7441. var maxDraw, prevText, prev, nextText, next, currentText, gotoDate,
  7442. controls, buttonPanel, firstDay, showWeek, dayNames, dayNamesMin,
  7443. monthNames, monthNamesShort, beforeShowDay, showOtherMonths,
  7444. selectOtherMonths, defaultDate, html, dow, row, group, col, selectedDate,
  7445. cornerClass, calender, thead, day, daysInMonth, leadDays, curRows, numRows,
  7446. printDate, dRow, tbody, daySettings, otherMonth, unselectable,
  7447. tempDate = new Date(),
  7448. today = this._daylightSavingAdjust(
  7449. new Date( tempDate.getFullYear(), tempDate.getMonth(), tempDate.getDate() ) ), // clear time
  7450. isRTL = this._get( inst, "isRTL" ),
  7451. showButtonPanel = this._get( inst, "showButtonPanel" ),
  7452. hideIfNoPrevNext = this._get( inst, "hideIfNoPrevNext" ),
  7453. navigationAsDateFormat = this._get( inst, "navigationAsDateFormat" ),
  7454. numMonths = this._getNumberOfMonths( inst ),
  7455. showCurrentAtPos = this._get( inst, "showCurrentAtPos" ),
  7456. stepMonths = this._get( inst, "stepMonths" ),
  7457. isMultiMonth = ( numMonths[ 0 ] !== 1 || numMonths[ 1 ] !== 1 ),
  7458. currentDate = this._daylightSavingAdjust( ( !inst.currentDay ? new Date( 9999, 9, 9 ) :
  7459. new Date( inst.currentYear, inst.currentMonth, inst.currentDay ) ) ),
  7460. minDate = this._getMinMaxDate( inst, "min" ),
  7461. maxDate = this._getMinMaxDate( inst, "max" ),
  7462. drawMonth = inst.drawMonth - showCurrentAtPos,
  7463. drawYear = inst.drawYear;
  7464. if ( drawMonth < 0 ) {
  7465. drawMonth += 12;
  7466. drawYear--;
  7467. }
  7468. if ( maxDate ) {
  7469. maxDraw = this._daylightSavingAdjust( new Date( maxDate.getFullYear(),
  7470. maxDate.getMonth() - ( numMonths[ 0 ] * numMonths[ 1 ] ) + 1, maxDate.getDate() ) );
  7471. maxDraw = ( minDate && maxDraw < minDate ? minDate : maxDraw );
  7472. while ( this._daylightSavingAdjust( new Date( drawYear, drawMonth, 1 ) ) > maxDraw ) {
  7473. drawMonth--;
  7474. if ( drawMonth < 0 ) {
  7475. drawMonth = 11;
  7476. drawYear--;
  7477. }
  7478. }
  7479. }
  7480. inst.drawMonth = drawMonth;
  7481. inst.drawYear = drawYear;
  7482. prevText = this._get( inst, "prevText" );
  7483. prevText = ( !navigationAsDateFormat ? prevText : this.formatDate( prevText,
  7484. this._daylightSavingAdjust( new Date( drawYear, drawMonth - stepMonths, 1 ) ),
  7485. this._getFormatConfig( inst ) ) );
  7486. prev = ( this._canAdjustMonth( inst, -1, drawYear, drawMonth ) ?
  7487. "<a class='ui-datepicker-prev ui-corner-all' data-handler='prev' data-event='click'" +
  7488. " title='" + prevText + "'><span class='ui-icon ui-icon-circle-triangle-" + ( isRTL ? "e" : "w" ) + "'>" + prevText + "</span></a>" :
  7489. ( hideIfNoPrevNext ? "" : "<a class='ui-datepicker-prev ui-corner-all ui-state-disabled' title='" + prevText + "'><span class='ui-icon ui-icon-circle-triangle-" + ( isRTL ? "e" : "w" ) + "'>" + prevText + "</span></a>" ) );
  7490. nextText = this._get( inst, "nextText" );
  7491. nextText = ( !navigationAsDateFormat ? nextText : this.formatDate( nextText,
  7492. this._daylightSavingAdjust( new Date( drawYear, drawMonth + stepMonths, 1 ) ),
  7493. this._getFormatConfig( inst ) ) );
  7494. next = ( this._canAdjustMonth( inst, +1, drawYear, drawMonth ) ?
  7495. "<a class='ui-datepicker-next ui-corner-all' data-handler='next' data-event='click'" +
  7496. " title='" + nextText + "'><span class='ui-icon ui-icon-circle-triangle-" + ( isRTL ? "w" : "e" ) + "'>" + nextText + "</span></a>" :
  7497. ( hideIfNoPrevNext ? "" : "<a class='ui-datepicker-next ui-corner-all ui-state-disabled' title='" + nextText + "'><span class='ui-icon ui-icon-circle-triangle-" + ( isRTL ? "w" : "e" ) + "'>" + nextText + "</span></a>" ) );
  7498. currentText = this._get( inst, "currentText" );
  7499. gotoDate = ( this._get( inst, "gotoCurrent" ) && inst.currentDay ? currentDate : today );
  7500. currentText = ( !navigationAsDateFormat ? currentText :
  7501. this.formatDate( currentText, gotoDate, this._getFormatConfig( inst ) ) );
  7502. controls = ( !inst.inline ? "<button type='button' class='ui-datepicker-close ui-state-default ui-priority-primary ui-corner-all' data-handler='hide' data-event='click'>" +
  7503. this._get( inst, "closeText" ) + "</button>" : "" );
  7504. buttonPanel = ( showButtonPanel ) ? "<div class='ui-datepicker-buttonpane ui-widget-content'>" + ( isRTL ? controls : "" ) +
  7505. ( this._isInRange( inst, gotoDate ) ? "<button type='button' class='ui-datepicker-current ui-state-default ui-priority-secondary ui-corner-all' data-handler='today' data-event='click'" +
  7506. ">" + currentText + "</button>" : "" ) + ( isRTL ? "" : controls ) + "</div>" : "";
  7507. firstDay = parseInt( this._get( inst, "firstDay" ), 10 );
  7508. firstDay = ( isNaN( firstDay ) ? 0 : firstDay );
  7509. showWeek = this._get( inst, "showWeek" );
  7510. dayNames = this._get( inst, "dayNames" );
  7511. dayNamesMin = this._get( inst, "dayNamesMin" );
  7512. monthNames = this._get( inst, "monthNames" );
  7513. monthNamesShort = this._get( inst, "monthNamesShort" );
  7514. beforeShowDay = this._get( inst, "beforeShowDay" );
  7515. showOtherMonths = this._get( inst, "showOtherMonths" );
  7516. selectOtherMonths = this._get( inst, "selectOtherMonths" );
  7517. defaultDate = this._getDefaultDate( inst );
  7518. html = "";
  7519. for ( row = 0; row < numMonths[ 0 ]; row++ ) {
  7520. group = "";
  7521. this.maxRows = 4;
  7522. for ( col = 0; col < numMonths[ 1 ]; col++ ) {
  7523. selectedDate = this._daylightSavingAdjust( new Date( drawYear, drawMonth, inst.selectedDay ) );
  7524. cornerClass = " ui-corner-all";
  7525. calender = "";
  7526. if ( isMultiMonth ) {
  7527. calender += "<div class='ui-datepicker-group";
  7528. if ( numMonths[ 1 ] > 1 ) {
  7529. switch ( col ) {
  7530. case 0: calender += " ui-datepicker-group-first";
  7531. cornerClass = " ui-corner-" + ( isRTL ? "right" : "left" ); break;
  7532. case numMonths[ 1 ] - 1: calender += " ui-datepicker-group-last";
  7533. cornerClass = " ui-corner-" + ( isRTL ? "left" : "right" ); break;
  7534. default: calender += " ui-datepicker-group-middle"; cornerClass = ""; break;
  7535. }
  7536. }
  7537. calender += "'>";
  7538. }
  7539. calender += "<div class='ui-datepicker-header ui-widget-header ui-helper-clearfix" + cornerClass + "'>" +
  7540. ( /all|left/.test( cornerClass ) && row === 0 ? ( isRTL ? next : prev ) : "" ) +
  7541. ( /all|right/.test( cornerClass ) && row === 0 ? ( isRTL ? prev : next ) : "" ) +
  7542. this._generateMonthYearHeader( inst, drawMonth, drawYear, minDate, maxDate,
  7543. row > 0 || col > 0, monthNames, monthNamesShort ) + // draw month headers
  7544. "</div><table class='ui-datepicker-calendar'><thead>" +
  7545. "<tr>";
  7546. thead = ( showWeek ? "<th class='ui-datepicker-week-col'>" + this._get( inst, "weekHeader" ) + "</th>" : "" );
  7547. for ( dow = 0; dow < 7; dow++ ) { // days of the week
  7548. day = ( dow + firstDay ) % 7;
  7549. thead += "<th scope='col'" + ( ( dow + firstDay + 6 ) % 7 >= 5 ? " class='ui-datepicker-week-end'" : "" ) + ">" +
  7550. "<span title='" + dayNames[ day ] + "'>" + dayNamesMin[ day ] + "</span></th>";
  7551. }
  7552. calender += thead + "</tr></thead><tbody>";
  7553. daysInMonth = this._getDaysInMonth( drawYear, drawMonth );
  7554. if ( drawYear === inst.selectedYear && drawMonth === inst.selectedMonth ) {
  7555. inst.selectedDay = Math.min( inst.selectedDay, daysInMonth );
  7556. }
  7557. leadDays = ( this._getFirstDayOfMonth( drawYear, drawMonth ) - firstDay + 7 ) % 7;
  7558. curRows = Math.ceil( ( leadDays + daysInMonth ) / 7 ); // calculate the number of rows to generate
  7559. numRows = ( isMultiMonth ? this.maxRows > curRows ? this.maxRows : curRows : curRows ); //If multiple months, use the higher number of rows (see #7043)
  7560. this.maxRows = numRows;
  7561. printDate = this._daylightSavingAdjust( new Date( drawYear, drawMonth, 1 - leadDays ) );
  7562. for ( dRow = 0; dRow < numRows; dRow++ ) { // create date picker rows
  7563. calender += "<tr>";
  7564. tbody = ( !showWeek ? "" : "<td class='ui-datepicker-week-col'>" +
  7565. this._get( inst, "calculateWeek" )( printDate ) + "</td>" );
  7566. for ( dow = 0; dow < 7; dow++ ) { // create date picker days
  7567. daySettings = ( beforeShowDay ?
  7568. beforeShowDay.apply( ( inst.input ? inst.input[ 0 ] : null ), [ printDate ] ) : [ true, "" ] );
  7569. otherMonth = ( printDate.getMonth() !== drawMonth );
  7570. unselectable = ( otherMonth && !selectOtherMonths ) || !daySettings[ 0 ] ||
  7571. ( minDate && printDate < minDate ) || ( maxDate && printDate > maxDate );
  7572. tbody += "<td class='" +
  7573. ( ( dow + firstDay + 6 ) % 7 >= 5 ? " ui-datepicker-week-end" : "" ) + // highlight weekends
  7574. ( otherMonth ? " ui-datepicker-other-month" : "" ) + // highlight days from other months
  7575. ( ( printDate.getTime() === selectedDate.getTime() && drawMonth === inst.selectedMonth && inst._keyEvent ) || // user pressed key
  7576. ( defaultDate.getTime() === printDate.getTime() && defaultDate.getTime() === selectedDate.getTime() ) ?
  7577. // or defaultDate is current printedDate and defaultDate is selectedDate
  7578. " " + this._dayOverClass : "" ) + // highlight selected day
  7579. ( unselectable ? " " + this._unselectableClass + " ui-state-disabled" : "" ) + // highlight unselectable days
  7580. ( otherMonth && !showOtherMonths ? "" : " " + daySettings[ 1 ] + // highlight custom dates
  7581. ( printDate.getTime() === currentDate.getTime() ? " " + this._currentClass : "" ) + // highlight selected day
  7582. ( printDate.getTime() === today.getTime() ? " ui-datepicker-today" : "" ) ) + "'" + // highlight today (if different)
  7583. ( ( !otherMonth || showOtherMonths ) && daySettings[ 2 ] ? " title='" + daySettings[ 2 ].replace( /'/g, "&#39;" ) + "'" : "" ) + // cell title
  7584. ( unselectable ? "" : " data-handler='selectDay' data-event='click' data-month='" + printDate.getMonth() + "' data-year='" + printDate.getFullYear() + "'" ) + ">" + // actions
  7585. ( otherMonth && !showOtherMonths ? "&#xa0;" : // display for other months
  7586. ( unselectable ? "<span class='ui-state-default'>" + printDate.getDate() + "</span>" : "<a class='ui-state-default" +
  7587. ( printDate.getTime() === today.getTime() ? " ui-state-highlight" : "" ) +
  7588. ( printDate.getTime() === currentDate.getTime() ? " ui-state-active" : "" ) + // highlight selected day
  7589. ( otherMonth ? " ui-priority-secondary" : "" ) + // distinguish dates from other months
  7590. "' href='#'>" + printDate.getDate() + "</a>" ) ) + "</td>"; // display selectable date
  7591. printDate.setDate( printDate.getDate() + 1 );
  7592. printDate = this._daylightSavingAdjust( printDate );
  7593. }
  7594. calender += tbody + "</tr>";
  7595. }
  7596. drawMonth++;
  7597. if ( drawMonth > 11 ) {
  7598. drawMonth = 0;
  7599. drawYear++;
  7600. }
  7601. calender += "</tbody></table>" + ( isMultiMonth ? "</div>" +
  7602. ( ( numMonths[ 0 ] > 0 && col === numMonths[ 1 ] - 1 ) ? "<div class='ui-datepicker-row-break'></div>" : "" ) : "" );
  7603. group += calender;
  7604. }
  7605. html += group;
  7606. }
  7607. html += buttonPanel;
  7608. inst._keyEvent = false;
  7609. return html;
  7610. },
  7611. /* Generate the month and year header. */
  7612. _generateMonthYearHeader: function( inst, drawMonth, drawYear, minDate, maxDate,
  7613. secondary, monthNames, monthNamesShort ) {
  7614. var inMinYear, inMaxYear, month, years, thisYear, determineYear, year, endYear,
  7615. changeMonth = this._get( inst, "changeMonth" ),
  7616. changeYear = this._get( inst, "changeYear" ),
  7617. showMonthAfterYear = this._get( inst, "showMonthAfterYear" ),
  7618. html = "<div class='ui-datepicker-title'>",
  7619. monthHtml = "";
  7620. // Month selection
  7621. if ( secondary || !changeMonth ) {
  7622. monthHtml += "<span class='ui-datepicker-month'>" + monthNames[ drawMonth ] + "</span>";
  7623. } else {
  7624. inMinYear = ( minDate && minDate.getFullYear() === drawYear );
  7625. inMaxYear = ( maxDate && maxDate.getFullYear() === drawYear );
  7626. monthHtml += "<select class='ui-datepicker-month' data-handler='selectMonth' data-event='change'>";
  7627. for ( month = 0; month < 12; month++ ) {
  7628. if ( ( !inMinYear || month >= minDate.getMonth() ) && ( !inMaxYear || month <= maxDate.getMonth() ) ) {
  7629. monthHtml += "<option value='" + month + "'" +
  7630. ( month === drawMonth ? " selected='selected'" : "" ) +
  7631. ">" + monthNamesShort[ month ] + "</option>";
  7632. }
  7633. }
  7634. monthHtml += "</select>";
  7635. }
  7636. if ( !showMonthAfterYear ) {
  7637. html += monthHtml + ( secondary || !( changeMonth && changeYear ) ? "&#xa0;" : "" );
  7638. }
  7639. // Year selection
  7640. if ( !inst.yearshtml ) {
  7641. inst.yearshtml = "";
  7642. if ( secondary || !changeYear ) {
  7643. html += "<span class='ui-datepicker-year'>" + drawYear + "</span>";
  7644. } else {
  7645. // determine range of years to display
  7646. years = this._get( inst, "yearRange" ).split( ":" );
  7647. thisYear = new Date().getFullYear();
  7648. determineYear = function( value ) {
  7649. var year = ( value.match( /c[+\-].*/ ) ? drawYear + parseInt( value.substring( 1 ), 10 ) :
  7650. ( value.match( /[+\-].*/ ) ? thisYear + parseInt( value, 10 ) :
  7651. parseInt( value, 10 ) ) );
  7652. return ( isNaN( year ) ? thisYear : year );
  7653. };
  7654. year = determineYear( years[ 0 ] );
  7655. endYear = Math.max( year, determineYear( years[ 1 ] || "" ) );
  7656. year = ( minDate ? Math.max( year, minDate.getFullYear() ) : year );
  7657. endYear = ( maxDate ? Math.min( endYear, maxDate.getFullYear() ) : endYear );
  7658. inst.yearshtml += "<select class='ui-datepicker-year' data-handler='selectYear' data-event='change'>";
  7659. for ( ; year <= endYear; year++ ) {
  7660. inst.yearshtml += "<option value='" + year + "'" +
  7661. ( year === drawYear ? " selected='selected'" : "" ) +
  7662. ">" + year + "</option>";
  7663. }
  7664. inst.yearshtml += "</select>";
  7665. html += inst.yearshtml;
  7666. inst.yearshtml = null;
  7667. }
  7668. }
  7669. html += this._get( inst, "yearSuffix" );
  7670. if ( showMonthAfterYear ) {
  7671. html += ( secondary || !( changeMonth && changeYear ) ? "&#xa0;" : "" ) + monthHtml;
  7672. }
  7673. html += "</div>"; // Close datepicker_header
  7674. return html;
  7675. },
  7676. /* Adjust one of the date sub-fields. */
  7677. _adjustInstDate: function( inst, offset, period ) {
  7678. var year = inst.selectedYear + ( period === "Y" ? offset : 0 ),
  7679. month = inst.selectedMonth + ( period === "M" ? offset : 0 ),
  7680. day = Math.min( inst.selectedDay, this._getDaysInMonth( year, month ) ) + ( period === "D" ? offset : 0 ),
  7681. date = this._restrictMinMax( inst, this._daylightSavingAdjust( new Date( year, month, day ) ) );
  7682. inst.selectedDay = date.getDate();
  7683. inst.drawMonth = inst.selectedMonth = date.getMonth();
  7684. inst.drawYear = inst.selectedYear = date.getFullYear();
  7685. if ( period === "M" || period === "Y" ) {
  7686. this._notifyChange( inst );
  7687. }
  7688. },
  7689. /* Ensure a date is within any min/max bounds. */
  7690. _restrictMinMax: function( inst, date ) {
  7691. var minDate = this._getMinMaxDate( inst, "min" ),
  7692. maxDate = this._getMinMaxDate( inst, "max" ),
  7693. newDate = ( minDate && date < minDate ? minDate : date );
  7694. return ( maxDate && newDate > maxDate ? maxDate : newDate );
  7695. },
  7696. /* Notify change of month/year. */
  7697. _notifyChange: function( inst ) {
  7698. var onChange = this._get( inst, "onChangeMonthYear" );
  7699. if ( onChange ) {
  7700. onChange.apply( ( inst.input ? inst.input[ 0 ] : null ),
  7701. [ inst.selectedYear, inst.selectedMonth + 1, inst ] );
  7702. }
  7703. },
  7704. /* Determine the number of months to show. */
  7705. _getNumberOfMonths: function( inst ) {
  7706. var numMonths = this._get( inst, "numberOfMonths" );
  7707. return ( numMonths == null ? [ 1, 1 ] : ( typeof numMonths === "number" ? [ 1, numMonths ] : numMonths ) );
  7708. },
  7709. /* Determine the current maximum date - ensure no time components are set. */
  7710. _getMinMaxDate: function( inst, minMax ) {
  7711. return this._determineDate( inst, this._get( inst, minMax + "Date" ), null );
  7712. },
  7713. /* Find the number of days in a given month. */
  7714. _getDaysInMonth: function( year, month ) {
  7715. return 32 - this._daylightSavingAdjust( new Date( year, month, 32 ) ).getDate();
  7716. },
  7717. /* Find the day of the week of the first of a month. */
  7718. _getFirstDayOfMonth: function( year, month ) {
  7719. return new Date( year, month, 1 ).getDay();
  7720. },
  7721. /* Determines if we should allow a "next/prev" month display change. */
  7722. _canAdjustMonth: function( inst, offset, curYear, curMonth ) {
  7723. var numMonths = this._getNumberOfMonths( inst ),
  7724. date = this._daylightSavingAdjust( new Date( curYear,
  7725. curMonth + ( offset < 0 ? offset : numMonths[ 0 ] * numMonths[ 1 ] ), 1 ) );
  7726. if ( offset < 0 ) {
  7727. date.setDate( this._getDaysInMonth( date.getFullYear(), date.getMonth() ) );
  7728. }
  7729. return this._isInRange( inst, date );
  7730. },
  7731. /* Is the given date in the accepted range? */
  7732. _isInRange: function( inst, date ) {
  7733. var yearSplit, currentYear,
  7734. minDate = this._getMinMaxDate( inst, "min" ),
  7735. maxDate = this._getMinMaxDate( inst, "max" ),
  7736. minYear = null,
  7737. maxYear = null,
  7738. years = this._get( inst, "yearRange" );
  7739. if ( years ) {
  7740. yearSplit = years.split( ":" );
  7741. currentYear = new Date().getFullYear();
  7742. minYear = parseInt( yearSplit[ 0 ], 10 );
  7743. maxYear = parseInt( yearSplit[ 1 ], 10 );
  7744. if ( yearSplit[ 0 ].match( /[+\-].*/ ) ) {
  7745. minYear += currentYear;
  7746. }
  7747. if ( yearSplit[ 1 ].match( /[+\-].*/ ) ) {
  7748. maxYear += currentYear;
  7749. }
  7750. }
  7751. return ( ( !minDate || date.getTime() >= minDate.getTime() ) &&
  7752. ( !maxDate || date.getTime() <= maxDate.getTime() ) &&
  7753. ( !minYear || date.getFullYear() >= minYear ) &&
  7754. ( !maxYear || date.getFullYear() <= maxYear ) );
  7755. },
  7756. /* Provide the configuration settings for formatting/parsing. */
  7757. _getFormatConfig: function( inst ) {
  7758. var shortYearCutoff = this._get( inst, "shortYearCutoff" );
  7759. shortYearCutoff = ( typeof shortYearCutoff !== "string" ? shortYearCutoff :
  7760. new Date().getFullYear() % 100 + parseInt( shortYearCutoff, 10 ) );
  7761. return { shortYearCutoff: shortYearCutoff,
  7762. dayNamesShort: this._get( inst, "dayNamesShort" ), dayNames: this._get( inst, "dayNames" ),
  7763. monthNamesShort: this._get( inst, "monthNamesShort" ), monthNames: this._get( inst, "monthNames" ) };
  7764. },
  7765. /* Format the given date for display. */
  7766. _formatDate: function( inst, day, month, year ) {
  7767. if ( !day ) {
  7768. inst.currentDay = inst.selectedDay;
  7769. inst.currentMonth = inst.selectedMonth;
  7770. inst.currentYear = inst.selectedYear;
  7771. }
  7772. var date = ( day ? ( typeof day === "object" ? day :
  7773. this._daylightSavingAdjust( new Date( year, month, day ) ) ) :
  7774. this._daylightSavingAdjust( new Date( inst.currentYear, inst.currentMonth, inst.currentDay ) ) );
  7775. return this.formatDate( this._get( inst, "dateFormat" ), date, this._getFormatConfig( inst ) );
  7776. }
  7777. } );
  7778. /*
  7779. * Bind hover events for datepicker elements.
  7780. * Done via delegate so the binding only occurs once in the lifetime of the parent div.
  7781. * Global datepicker_instActive, set by _updateDatepicker allows the handlers to find their way back to the active picker.
  7782. */
  7783. function datepicker_bindHover( dpDiv ) {
  7784. var selector = "button, .ui-datepicker-prev, .ui-datepicker-next, .ui-datepicker-calendar td a";
  7785. return dpDiv.on( "mouseout", selector, function() {
  7786. $( this ).removeClass( "ui-state-hover" );
  7787. if ( this.className.indexOf( "ui-datepicker-prev" ) !== -1 ) {
  7788. $( this ).removeClass( "ui-datepicker-prev-hover" );
  7789. }
  7790. if ( this.className.indexOf( "ui-datepicker-next" ) !== -1 ) {
  7791. $( this ).removeClass( "ui-datepicker-next-hover" );
  7792. }
  7793. } )
  7794. .on( "mouseover", selector, datepicker_handleMouseover );
  7795. }
  7796. function datepicker_handleMouseover() {
  7797. if ( !$.datepicker._isDisabledDatepicker( datepicker_instActive.inline ? datepicker_instActive.dpDiv.parent()[ 0 ] : datepicker_instActive.input[ 0 ] ) ) {
  7798. $( this ).parents( ".ui-datepicker-calendar" ).find( "a" ).removeClass( "ui-state-hover" );
  7799. $( this ).addClass( "ui-state-hover" );
  7800. if ( this.className.indexOf( "ui-datepicker-prev" ) !== -1 ) {
  7801. $( this ).addClass( "ui-datepicker-prev-hover" );
  7802. }
  7803. if ( this.className.indexOf( "ui-datepicker-next" ) !== -1 ) {
  7804. $( this ).addClass( "ui-datepicker-next-hover" );
  7805. }
  7806. }
  7807. }
  7808. /* jQuery extend now ignores nulls! */
  7809. function datepicker_extendRemove( target, props ) {
  7810. $.extend( target, props );
  7811. for ( var name in props ) {
  7812. if ( props[ name ] == null ) {
  7813. target[ name ] = props[ name ];
  7814. }
  7815. }
  7816. return target;
  7817. }
  7818. /* Invoke the datepicker functionality.
  7819. @param options string - a command, optionally followed by additional parameters or
  7820. Object - settings for attaching new datepicker functionality
  7821. @return jQuery object */
  7822. $.fn.datepicker = function( options ) {
  7823. /* Verify an empty collection wasn't passed - Fixes #6976 */
  7824. if ( !this.length ) {
  7825. return this;
  7826. }
  7827. /* Initialise the date picker. */
  7828. if ( !$.datepicker.initialized ) {
  7829. $( document ).on( "mousedown", $.datepicker._checkExternalClick );
  7830. $.datepicker.initialized = true;
  7831. }
  7832. /* Append datepicker main container to body if not exist. */
  7833. if ( $( "#" + $.datepicker._mainDivId ).length === 0 ) {
  7834. $( "body" ).append( $.datepicker.dpDiv );
  7835. }
  7836. var otherArgs = Array.prototype.slice.call( arguments, 1 );
  7837. if ( typeof options === "string" && ( options === "isDisabled" || options === "getDate" || options === "widget" ) ) {
  7838. return $.datepicker[ "_" + options + "Datepicker" ].
  7839. apply( $.datepicker, [ this[ 0 ] ].concat( otherArgs ) );
  7840. }
  7841. if ( options === "option" && arguments.length === 2 && typeof arguments[ 1 ] === "string" ) {
  7842. return $.datepicker[ "_" + options + "Datepicker" ].
  7843. apply( $.datepicker, [ this[ 0 ] ].concat( otherArgs ) );
  7844. }
  7845. return this.each( function() {
  7846. typeof options === "string" ?
  7847. $.datepicker[ "_" + options + "Datepicker" ].
  7848. apply( $.datepicker, [ this ].concat( otherArgs ) ) :
  7849. $.datepicker._attachDatepicker( this, options );
  7850. } );
  7851. };
  7852. $.datepicker = new Datepicker(); // singleton instance
  7853. $.datepicker.initialized = false;
  7854. $.datepicker.uuid = new Date().getTime();
  7855. $.datepicker.version = "1.12.0";
  7856. var widgetsDatepicker = $.datepicker;
  7857. // This file is deprecated
  7858. var ie = $.ui.ie = !!/msie [\w.]+/.exec( navigator.userAgent.toLowerCase() );
  7859. /*!
  7860. * jQuery UI Mouse 1.12.0
  7861. * http://jqueryui.com
  7862. *
  7863. * Copyright jQuery Foundation and other contributors
  7864. * Released under the MIT license.
  7865. * http://jquery.org/license
  7866. */
  7867. //>>label: Mouse
  7868. //>>group: Widgets
  7869. //>>description: Abstracts mouse-based interactions to assist in creating certain widgets.
  7870. //>>docs: http://api.jqueryui.com/mouse/
  7871. var mouseHandled = false;
  7872. $( document ).on( "mouseup", function() {
  7873. mouseHandled = false;
  7874. } );
  7875. var widgetsMouse = $.widget( "ui.mouse", {
  7876. version: "1.12.0",
  7877. options: {
  7878. cancel: "input, textarea, button, select, option",
  7879. distance: 1,
  7880. delay: 0
  7881. },
  7882. _mouseInit: function() {
  7883. var that = this;
  7884. this.element
  7885. .on( "mousedown." + this.widgetName, function( event ) {
  7886. return that._mouseDown( event );
  7887. } )
  7888. .on( "click." + this.widgetName, function( event ) {
  7889. if ( true === $.data( event.target, that.widgetName + ".preventClickEvent" ) ) {
  7890. $.removeData( event.target, that.widgetName + ".preventClickEvent" );
  7891. event.stopImmediatePropagation();
  7892. return false;
  7893. }
  7894. } );
  7895. this.started = false;
  7896. },
  7897. // TODO: make sure destroying one instance of mouse doesn't mess with
  7898. // other instances of mouse
  7899. _mouseDestroy: function() {
  7900. this.element.off( "." + this.widgetName );
  7901. if ( this._mouseMoveDelegate ) {
  7902. this.document
  7903. .off( "mousemove." + this.widgetName, this._mouseMoveDelegate )
  7904. .off( "mouseup." + this.widgetName, this._mouseUpDelegate );
  7905. }
  7906. },
  7907. _mouseDown: function( event ) {
  7908. // don't let more than one widget handle mouseStart
  7909. if ( mouseHandled ) {
  7910. return;
  7911. }
  7912. this._mouseMoved = false;
  7913. // We may have missed mouseup (out of window)
  7914. ( this._mouseStarted && this._mouseUp( event ) );
  7915. this._mouseDownEvent = event;
  7916. var that = this,
  7917. btnIsLeft = ( event.which === 1 ),
  7918. // event.target.nodeName works around a bug in IE 8 with
  7919. // disabled inputs (#7620)
  7920. elIsCancel = ( typeof this.options.cancel === "string" && event.target.nodeName ?
  7921. $( event.target ).closest( this.options.cancel ).length : false );
  7922. if ( !btnIsLeft || elIsCancel || !this._mouseCapture( event ) ) {
  7923. return true;
  7924. }
  7925. this.mouseDelayMet = !this.options.delay;
  7926. if ( !this.mouseDelayMet ) {
  7927. this._mouseDelayTimer = setTimeout( function() {
  7928. that.mouseDelayMet = true;
  7929. }, this.options.delay );
  7930. }
  7931. if ( this._mouseDistanceMet( event ) && this._mouseDelayMet( event ) ) {
  7932. this._mouseStarted = ( this._mouseStart( event ) !== false );
  7933. if ( !this._mouseStarted ) {
  7934. event.preventDefault();
  7935. return true;
  7936. }
  7937. }
  7938. // Click event may never have fired (Gecko & Opera)
  7939. if ( true === $.data( event.target, this.widgetName + ".preventClickEvent" ) ) {
  7940. $.removeData( event.target, this.widgetName + ".preventClickEvent" );
  7941. }
  7942. // These delegates are required to keep context
  7943. this._mouseMoveDelegate = function( event ) {
  7944. return that._mouseMove( event );
  7945. };
  7946. this._mouseUpDelegate = function( event ) {
  7947. return that._mouseUp( event );
  7948. };
  7949. this.document
  7950. .on( "mousemove." + this.widgetName, this._mouseMoveDelegate )
  7951. .on( "mouseup." + this.widgetName, this._mouseUpDelegate );
  7952. event.preventDefault();
  7953. mouseHandled = true;
  7954. return true;
  7955. },
  7956. _mouseMove: function( event ) {
  7957. // Only check for mouseups outside the document if you've moved inside the document
  7958. // at least once. This prevents the firing of mouseup in the case of IE<9, which will
  7959. // fire a mousemove event if content is placed under the cursor. See #7778
  7960. // Support: IE <9
  7961. if ( this._mouseMoved ) {
  7962. // IE mouseup check - mouseup happened when mouse was out of window
  7963. if ( $.ui.ie && ( !document.documentMode || document.documentMode < 9 ) &&
  7964. !event.button ) {
  7965. return this._mouseUp( event );
  7966. // Iframe mouseup check - mouseup occurred in another document
  7967. } else if ( !event.which ) {
  7968. // Support: Safari <=8 - 9
  7969. // Safari sets which to 0 if you press any of the following keys
  7970. // during a drag (#14461)
  7971. if ( event.originalEvent.altKey || event.originalEvent.ctrlKey ||
  7972. event.originalEvent.metaKey || event.originalEvent.shiftKey ) {
  7973. this.ignoreMissingWhich = true;
  7974. } else if ( !this.ignoreMissingWhich ) {
  7975. return this._mouseUp( event );
  7976. }
  7977. }
  7978. }
  7979. if ( event.which || event.button ) {
  7980. this._mouseMoved = true;
  7981. }
  7982. if ( this._mouseStarted ) {
  7983. this._mouseDrag( event );
  7984. return event.preventDefault();
  7985. }
  7986. if ( this._mouseDistanceMet( event ) && this._mouseDelayMet( event ) ) {
  7987. this._mouseStarted =
  7988. ( this._mouseStart( this._mouseDownEvent, event ) !== false );
  7989. ( this._mouseStarted ? this._mouseDrag( event ) : this._mouseUp( event ) );
  7990. }
  7991. return !this._mouseStarted;
  7992. },
  7993. _mouseUp: function( event ) {
  7994. this.document
  7995. .off( "mousemove." + this.widgetName, this._mouseMoveDelegate )
  7996. .off( "mouseup." + this.widgetName, this._mouseUpDelegate );
  7997. if ( this._mouseStarted ) {
  7998. this._mouseStarted = false;
  7999. if ( event.target === this._mouseDownEvent.target ) {
  8000. $.data( event.target, this.widgetName + ".preventClickEvent", true );
  8001. }
  8002. this._mouseStop( event );
  8003. }
  8004. if ( this._mouseDelayTimer ) {
  8005. clearTimeout( this._mouseDelayTimer );
  8006. delete this._mouseDelayTimer;
  8007. }
  8008. this.ignoreMissingWhich = false;
  8009. mouseHandled = false;
  8010. event.preventDefault();
  8011. },
  8012. _mouseDistanceMet: function( event ) {
  8013. return ( Math.max(
  8014. Math.abs( this._mouseDownEvent.pageX - event.pageX ),
  8015. Math.abs( this._mouseDownEvent.pageY - event.pageY )
  8016. ) >= this.options.distance
  8017. );
  8018. },
  8019. _mouseDelayMet: function( /* event */ ) {
  8020. return this.mouseDelayMet;
  8021. },
  8022. // These are placeholder methods, to be overriden by extending plugin
  8023. _mouseStart: function( /* event */ ) {},
  8024. _mouseDrag: function( /* event */ ) {},
  8025. _mouseStop: function( /* event */ ) {},
  8026. _mouseCapture: function( /* event */ ) { return true; }
  8027. } );
  8028. // $.ui.plugin is deprecated. Use $.widget() extensions instead.
  8029. var plugin = $.ui.plugin = {
  8030. add: function( module, option, set ) {
  8031. var i,
  8032. proto = $.ui[ module ].prototype;
  8033. for ( i in set ) {
  8034. proto.plugins[ i ] = proto.plugins[ i ] || [];
  8035. proto.plugins[ i ].push( [ option, set[ i ] ] );
  8036. }
  8037. },
  8038. call: function( instance, name, args, allowDisconnected ) {
  8039. var i,
  8040. set = instance.plugins[ name ];
  8041. if ( !set ) {
  8042. return;
  8043. }
  8044. if ( !allowDisconnected && ( !instance.element[ 0 ].parentNode ||
  8045. instance.element[ 0 ].parentNode.nodeType === 11 ) ) {
  8046. return;
  8047. }
  8048. for ( i = 0; i < set.length; i++ ) {
  8049. if ( instance.options[ set[ i ][ 0 ] ] ) {
  8050. set[ i ][ 1 ].apply( instance.element, args );
  8051. }
  8052. }
  8053. }
  8054. };
  8055. var safeBlur = $.ui.safeBlur = function( element ) {
  8056. // Support: IE9 - 10 only
  8057. // If the <body> is blurred, IE will switch windows, see #9420
  8058. if ( element && element.nodeName.toLowerCase() !== "body" ) {
  8059. $( element ).trigger( "blur" );
  8060. }
  8061. };
  8062. /*!
  8063. * jQuery UI Draggable 1.12.0
  8064. * http://jqueryui.com
  8065. *
  8066. * Copyright jQuery Foundation and other contributors
  8067. * Released under the MIT license.
  8068. * http://jquery.org/license
  8069. */
  8070. //>>label: Draggable
  8071. //>>group: Interactions
  8072. //>>description: Enables dragging functionality for any element.
  8073. //>>docs: http://api.jqueryui.com/draggable/
  8074. //>>demos: http://jqueryui.com/draggable/
  8075. //>>css.structure: ../../themes/base/draggable.css
  8076. $.widget( "ui.draggable", $.ui.mouse, {
  8077. version: "1.12.0",
  8078. widgetEventPrefix: "drag",
  8079. options: {
  8080. addClasses: true,
  8081. appendTo: "parent",
  8082. axis: false,
  8083. connectToSortable: false,
  8084. containment: false,
  8085. cursor: "auto",
  8086. cursorAt: false,
  8087. grid: false,
  8088. handle: false,
  8089. helper: "original",
  8090. iframeFix: false,
  8091. opacity: false,
  8092. refreshPositions: false,
  8093. revert: false,
  8094. revertDuration: 500,
  8095. scope: "default",
  8096. scroll: true,
  8097. scrollSensitivity: 20,
  8098. scrollSpeed: 20,
  8099. snap: false,
  8100. snapMode: "both",
  8101. snapTolerance: 20,
  8102. stack: false,
  8103. zIndex: false,
  8104. // Callbacks
  8105. drag: null,
  8106. start: null,
  8107. stop: null
  8108. },
  8109. _create: function() {
  8110. if ( this.options.helper === "original" ) {
  8111. this._setPositionRelative();
  8112. }
  8113. if ( this.options.addClasses ) {
  8114. this._addClass( "ui-draggable" );
  8115. }
  8116. this._setHandleClassName();
  8117. this._mouseInit();
  8118. },
  8119. _setOption: function( key, value ) {
  8120. this._super( key, value );
  8121. if ( key === "handle" ) {
  8122. this._removeHandleClassName();
  8123. this._setHandleClassName();
  8124. }
  8125. },
  8126. _destroy: function() {
  8127. if ( ( this.helper || this.element ).is( ".ui-draggable-dragging" ) ) {
  8128. this.destroyOnClear = true;
  8129. return;
  8130. }
  8131. this._removeHandleClassName();
  8132. this._mouseDestroy();
  8133. },
  8134. _mouseCapture: function( event ) {
  8135. var o = this.options;
  8136. this._blurActiveElement( event );
  8137. // Among others, prevent a drag on a resizable-handle
  8138. if ( this.helper || o.disabled ||
  8139. $( event.target ).closest( ".ui-resizable-handle" ).length > 0 ) {
  8140. return false;
  8141. }
  8142. //Quit if we're not on a valid handle
  8143. this.handle = this._getHandle( event );
  8144. if ( !this.handle ) {
  8145. return false;
  8146. }
  8147. this._blockFrames( o.iframeFix === true ? "iframe" : o.iframeFix );
  8148. return true;
  8149. },
  8150. _blockFrames: function( selector ) {
  8151. this.iframeBlocks = this.document.find( selector ).map( function() {
  8152. var iframe = $( this );
  8153. return $( "<div>" )
  8154. .css( "position", "absolute" )
  8155. .appendTo( iframe.parent() )
  8156. .outerWidth( iframe.outerWidth() )
  8157. .outerHeight( iframe.outerHeight() )
  8158. .offset( iframe.offset() )[ 0 ];
  8159. } );
  8160. },
  8161. _unblockFrames: function() {
  8162. if ( this.iframeBlocks ) {
  8163. this.iframeBlocks.remove();
  8164. delete this.iframeBlocks;
  8165. }
  8166. },
  8167. _blurActiveElement: function( event ) {
  8168. var activeElement = $.ui.safeActiveElement( this.document[ 0 ] ),
  8169. target = $( event.target );
  8170. // Only blur if the event occurred on an element that is:
  8171. // 1) within the draggable handle
  8172. // 2) but not within the currently focused element
  8173. // See #10527, #12472
  8174. if ( this._getHandle( event ) && target.closest( activeElement ).length ) {
  8175. return;
  8176. }
  8177. // Blur any element that currently has focus, see #4261
  8178. $.ui.safeBlur( activeElement );
  8179. },
  8180. _mouseStart: function( event ) {
  8181. var o = this.options;
  8182. //Create and append the visible helper
  8183. this.helper = this._createHelper( event );
  8184. this._addClass( this.helper, "ui-draggable-dragging" );
  8185. //Cache the helper size
  8186. this._cacheHelperProportions();
  8187. //If ddmanager is used for droppables, set the global draggable
  8188. if ( $.ui.ddmanager ) {
  8189. $.ui.ddmanager.current = this;
  8190. }
  8191. /*
  8192. * - Position generation -
  8193. * This block generates everything position related - it's the core of draggables.
  8194. */
  8195. //Cache the margins of the original element
  8196. this._cacheMargins();
  8197. //Store the helper's css position
  8198. this.cssPosition = this.helper.css( "position" );
  8199. this.scrollParent = this.helper.scrollParent( true );
  8200. this.offsetParent = this.helper.offsetParent();
  8201. this.hasFixedAncestor = this.helper.parents().filter( function() {
  8202. return $( this ).css( "position" ) === "fixed";
  8203. } ).length > 0;
  8204. //The element's absolute position on the page minus margins
  8205. this.positionAbs = this.element.offset();
  8206. this._refreshOffsets( event );
  8207. //Generate the original position
  8208. this.originalPosition = this.position = this._generatePosition( event, false );
  8209. this.originalPageX = event.pageX;
  8210. this.originalPageY = event.pageY;
  8211. //Adjust the mouse offset relative to the helper if "cursorAt" is supplied
  8212. ( o.cursorAt && this._adjustOffsetFromHelper( o.cursorAt ) );
  8213. //Set a containment if given in the options
  8214. this._setContainment();
  8215. //Trigger event + callbacks
  8216. if ( this._trigger( "start", event ) === false ) {
  8217. this._clear();
  8218. return false;
  8219. }
  8220. //Recache the helper size
  8221. this._cacheHelperProportions();
  8222. //Prepare the droppable offsets
  8223. if ( $.ui.ddmanager && !o.dropBehaviour ) {
  8224. $.ui.ddmanager.prepareOffsets( this, event );
  8225. }
  8226. // Execute the drag once - this causes the helper not to be visible before getting its
  8227. // correct position
  8228. this._mouseDrag( event, true );
  8229. // If the ddmanager is used for droppables, inform the manager that dragging has started
  8230. // (see #5003)
  8231. if ( $.ui.ddmanager ) {
  8232. $.ui.ddmanager.dragStart( this, event );
  8233. }
  8234. return true;
  8235. },
  8236. _refreshOffsets: function( event ) {
  8237. this.offset = {
  8238. top: this.positionAbs.top - this.margins.top,
  8239. left: this.positionAbs.left - this.margins.left,
  8240. scroll: false,
  8241. parent: this._getParentOffset(),
  8242. relative: this._getRelativeOffset()
  8243. };
  8244. this.offset.click = {
  8245. left: event.pageX - this.offset.left,
  8246. top: event.pageY - this.offset.top
  8247. };
  8248. },
  8249. _mouseDrag: function( event, noPropagation ) {
  8250. // reset any necessary cached properties (see #5009)
  8251. if ( this.hasFixedAncestor ) {
  8252. this.offset.parent = this._getParentOffset();
  8253. }
  8254. //Compute the helpers position
  8255. this.position = this._generatePosition( event, true );
  8256. this.positionAbs = this._convertPositionTo( "absolute" );
  8257. //Call plugins and callbacks and use the resulting position if something is returned
  8258. if ( !noPropagation ) {
  8259. var ui = this._uiHash();
  8260. if ( this._trigger( "drag", event, ui ) === false ) {
  8261. this._mouseUp( new $.Event( "mouseup", event ) );
  8262. return false;
  8263. }
  8264. this.position = ui.position;
  8265. }
  8266. this.helper[ 0 ].style.left = this.position.left + "px";
  8267. this.helper[ 0 ].style.top = this.position.top + "px";
  8268. if ( $.ui.ddmanager ) {
  8269. $.ui.ddmanager.drag( this, event );
  8270. }
  8271. return false;
  8272. },
  8273. _mouseStop: function( event ) {
  8274. //If we are using droppables, inform the manager about the drop
  8275. var that = this,
  8276. dropped = false;
  8277. if ( $.ui.ddmanager && !this.options.dropBehaviour ) {
  8278. dropped = $.ui.ddmanager.drop( this, event );
  8279. }
  8280. //if a drop comes from outside (a sortable)
  8281. if ( this.dropped ) {
  8282. dropped = this.dropped;
  8283. this.dropped = false;
  8284. }
  8285. if ( ( this.options.revert === "invalid" && !dropped ) ||
  8286. ( this.options.revert === "valid" && dropped ) ||
  8287. this.options.revert === true || ( $.isFunction( this.options.revert ) &&
  8288. this.options.revert.call( this.element, dropped ) )
  8289. ) {
  8290. $( this.helper ).animate(
  8291. this.originalPosition,
  8292. parseInt( this.options.revertDuration, 10 ),
  8293. function() {
  8294. if ( that._trigger( "stop", event ) !== false ) {
  8295. that._clear();
  8296. }
  8297. }
  8298. );
  8299. } else {
  8300. if ( this._trigger( "stop", event ) !== false ) {
  8301. this._clear();
  8302. }
  8303. }
  8304. return false;
  8305. },
  8306. _mouseUp: function( event ) {
  8307. this._unblockFrames();
  8308. // If the ddmanager is used for droppables, inform the manager that dragging has stopped
  8309. // (see #5003)
  8310. if ( $.ui.ddmanager ) {
  8311. $.ui.ddmanager.dragStop( this, event );
  8312. }
  8313. // Only need to focus if the event occurred on the draggable itself, see #10527
  8314. if ( this.handleElement.is( event.target ) ) {
  8315. // The interaction is over; whether or not the click resulted in a drag,
  8316. // focus the element
  8317. this.element.trigger( "focus" );
  8318. }
  8319. return $.ui.mouse.prototype._mouseUp.call( this, event );
  8320. },
  8321. cancel: function() {
  8322. if ( this.helper.is( ".ui-draggable-dragging" ) ) {
  8323. this._mouseUp( new $.Event( "mouseup", { target: this.element[ 0 ] } ) );
  8324. } else {
  8325. this._clear();
  8326. }
  8327. return this;
  8328. },
  8329. _getHandle: function( event ) {
  8330. return this.options.handle ?
  8331. !!$( event.target ).closest( this.element.find( this.options.handle ) ).length :
  8332. true;
  8333. },
  8334. _setHandleClassName: function() {
  8335. this.handleElement = this.options.handle ?
  8336. this.element.find( this.options.handle ) : this.element;
  8337. this._addClass( this.handleElement, "ui-draggable-handle" );
  8338. },
  8339. _removeHandleClassName: function() {
  8340. this._removeClass( this.handleElement, "ui-draggable-handle" );
  8341. },
  8342. _createHelper: function( event ) {
  8343. var o = this.options,
  8344. helperIsFunction = $.isFunction( o.helper ),
  8345. helper = helperIsFunction ?
  8346. $( o.helper.apply( this.element[ 0 ], [ event ] ) ) :
  8347. ( o.helper === "clone" ?
  8348. this.element.clone().removeAttr( "id" ) :
  8349. this.element );
  8350. if ( !helper.parents( "body" ).length ) {
  8351. helper.appendTo( ( o.appendTo === "parent" ?
  8352. this.element[ 0 ].parentNode :
  8353. o.appendTo ) );
  8354. }
  8355. // Http://bugs.jqueryui.com/ticket/9446
  8356. // a helper function can return the original element
  8357. // which wouldn't have been set to relative in _create
  8358. if ( helperIsFunction && helper[ 0 ] === this.element[ 0 ] ) {
  8359. this._setPositionRelative();
  8360. }
  8361. if ( helper[ 0 ] !== this.element[ 0 ] &&
  8362. !( /(fixed|absolute)/ ).test( helper.css( "position" ) ) ) {
  8363. helper.css( "position", "absolute" );
  8364. }
  8365. return helper;
  8366. },
  8367. _setPositionRelative: function() {
  8368. if ( !( /^(?:r|a|f)/ ).test( this.element.css( "position" ) ) ) {
  8369. this.element[ 0 ].style.position = "relative";
  8370. }
  8371. },
  8372. _adjustOffsetFromHelper: function( obj ) {
  8373. if ( typeof obj === "string" ) {
  8374. obj = obj.split( " " );
  8375. }
  8376. if ( $.isArray( obj ) ) {
  8377. obj = { left: +obj[ 0 ], top: +obj[ 1 ] || 0 };
  8378. }
  8379. if ( "left" in obj ) {
  8380. this.offset.click.left = obj.left + this.margins.left;
  8381. }
  8382. if ( "right" in obj ) {
  8383. this.offset.click.left = this.helperProportions.width - obj.right + this.margins.left;
  8384. }
  8385. if ( "top" in obj ) {
  8386. this.offset.click.top = obj.top + this.margins.top;
  8387. }
  8388. if ( "bottom" in obj ) {
  8389. this.offset.click.top = this.helperProportions.height - obj.bottom + this.margins.top;
  8390. }
  8391. },
  8392. _isRootNode: function( element ) {
  8393. return ( /(html|body)/i ).test( element.tagName ) || element === this.document[ 0 ];
  8394. },
  8395. _getParentOffset: function() {
  8396. //Get the offsetParent and cache its position
  8397. var po = this.offsetParent.offset(),
  8398. document = this.document[ 0 ];
  8399. // This is a special case where we need to modify a offset calculated on start, since the
  8400. // following happened:
  8401. // 1. The position of the helper is absolute, so it's position is calculated based on the
  8402. // next positioned parent
  8403. // 2. The actual offset parent is a child of the scroll parent, and the scroll parent isn't
  8404. // the document, which means that the scroll is included in the initial calculation of the
  8405. // offset of the parent, and never recalculated upon drag
  8406. if ( this.cssPosition === "absolute" && this.scrollParent[ 0 ] !== document &&
  8407. $.contains( this.scrollParent[ 0 ], this.offsetParent[ 0 ] ) ) {
  8408. po.left += this.scrollParent.scrollLeft();
  8409. po.top += this.scrollParent.scrollTop();
  8410. }
  8411. if ( this._isRootNode( this.offsetParent[ 0 ] ) ) {
  8412. po = { top: 0, left: 0 };
  8413. }
  8414. return {
  8415. top: po.top + ( parseInt( this.offsetParent.css( "borderTopWidth" ), 10 ) || 0 ),
  8416. left: po.left + ( parseInt( this.offsetParent.css( "borderLeftWidth" ), 10 ) || 0 )
  8417. };
  8418. },
  8419. _getRelativeOffset: function() {
  8420. if ( this.cssPosition !== "relative" ) {
  8421. return { top: 0, left: 0 };
  8422. }
  8423. var p = this.element.position(),
  8424. scrollIsRootNode = this._isRootNode( this.scrollParent[ 0 ] );
  8425. return {
  8426. top: p.top - ( parseInt( this.helper.css( "top" ), 10 ) || 0 ) +
  8427. ( !scrollIsRootNode ? this.scrollParent.scrollTop() : 0 ),
  8428. left: p.left - ( parseInt( this.helper.css( "left" ), 10 ) || 0 ) +
  8429. ( !scrollIsRootNode ? this.scrollParent.scrollLeft() : 0 )
  8430. };
  8431. },
  8432. _cacheMargins: function() {
  8433. this.margins = {
  8434. left: ( parseInt( this.element.css( "marginLeft" ), 10 ) || 0 ),
  8435. top: ( parseInt( this.element.css( "marginTop" ), 10 ) || 0 ),
  8436. right: ( parseInt( this.element.css( "marginRight" ), 10 ) || 0 ),
  8437. bottom: ( parseInt( this.element.css( "marginBottom" ), 10 ) || 0 )
  8438. };
  8439. },
  8440. _cacheHelperProportions: function() {
  8441. this.helperProportions = {
  8442. width: this.helper.outerWidth(),
  8443. height: this.helper.outerHeight()
  8444. };
  8445. },
  8446. _setContainment: function() {
  8447. var isUserScrollable, c, ce,
  8448. o = this.options,
  8449. document = this.document[ 0 ];
  8450. this.relativeContainer = null;
  8451. if ( !o.containment ) {
  8452. this.containment = null;
  8453. return;
  8454. }
  8455. if ( o.containment === "window" ) {
  8456. this.containment = [
  8457. $( window ).scrollLeft() - this.offset.relative.left - this.offset.parent.left,
  8458. $( window ).scrollTop() - this.offset.relative.top - this.offset.parent.top,
  8459. $( window ).scrollLeft() + $( window ).width() -
  8460. this.helperProportions.width - this.margins.left,
  8461. $( window ).scrollTop() +
  8462. ( $( window ).height() || document.body.parentNode.scrollHeight ) -
  8463. this.helperProportions.height - this.margins.top
  8464. ];
  8465. return;
  8466. }
  8467. if ( o.containment === "document" ) {
  8468. this.containment = [
  8469. 0,
  8470. 0,
  8471. $( document ).width() - this.helperProportions.width - this.margins.left,
  8472. ( $( document ).height() || document.body.parentNode.scrollHeight ) -
  8473. this.helperProportions.height - this.margins.top
  8474. ];
  8475. return;
  8476. }
  8477. if ( o.containment.constructor === Array ) {
  8478. this.containment = o.containment;
  8479. return;
  8480. }
  8481. if ( o.containment === "parent" ) {
  8482. o.containment = this.helper[ 0 ].parentNode;
  8483. }
  8484. c = $( o.containment );
  8485. ce = c[ 0 ];
  8486. if ( !ce ) {
  8487. return;
  8488. }
  8489. isUserScrollable = /(scroll|auto)/.test( c.css( "overflow" ) );
  8490. this.containment = [
  8491. ( parseInt( c.css( "borderLeftWidth" ), 10 ) || 0 ) +
  8492. ( parseInt( c.css( "paddingLeft" ), 10 ) || 0 ),
  8493. ( parseInt( c.css( "borderTopWidth" ), 10 ) || 0 ) +
  8494. ( parseInt( c.css( "paddingTop" ), 10 ) || 0 ),
  8495. ( isUserScrollable ? Math.max( ce.scrollWidth, ce.offsetWidth ) : ce.offsetWidth ) -
  8496. ( parseInt( c.css( "borderRightWidth" ), 10 ) || 0 ) -
  8497. ( parseInt( c.css( "paddingRight" ), 10 ) || 0 ) -
  8498. this.helperProportions.width -
  8499. this.margins.left -
  8500. this.margins.right,
  8501. ( isUserScrollable ? Math.max( ce.scrollHeight, ce.offsetHeight ) : ce.offsetHeight ) -
  8502. ( parseInt( c.css( "borderBottomWidth" ), 10 ) || 0 ) -
  8503. ( parseInt( c.css( "paddingBottom" ), 10 ) || 0 ) -
  8504. this.helperProportions.height -
  8505. this.margins.top -
  8506. this.margins.bottom
  8507. ];
  8508. this.relativeContainer = c;
  8509. },
  8510. _convertPositionTo: function( d, pos ) {
  8511. if ( !pos ) {
  8512. pos = this.position;
  8513. }
  8514. var mod = d === "absolute" ? 1 : -1,
  8515. scrollIsRootNode = this._isRootNode( this.scrollParent[ 0 ] );
  8516. return {
  8517. top: (
  8518. // The absolute mouse position
  8519. pos.top +
  8520. // Only for relative positioned nodes: Relative offset from element to offset parent
  8521. this.offset.relative.top * mod +
  8522. // The offsetParent's offset without borders (offset + border)
  8523. this.offset.parent.top * mod -
  8524. ( ( this.cssPosition === "fixed" ?
  8525. -this.offset.scroll.top :
  8526. ( scrollIsRootNode ? 0 : this.offset.scroll.top ) ) * mod )
  8527. ),
  8528. left: (
  8529. // The absolute mouse position
  8530. pos.left +
  8531. // Only for relative positioned nodes: Relative offset from element to offset parent
  8532. this.offset.relative.left * mod +
  8533. // The offsetParent's offset without borders (offset + border)
  8534. this.offset.parent.left * mod -
  8535. ( ( this.cssPosition === "fixed" ?
  8536. -this.offset.scroll.left :
  8537. ( scrollIsRootNode ? 0 : this.offset.scroll.left ) ) * mod )
  8538. )
  8539. };
  8540. },
  8541. _generatePosition: function( event, constrainPosition ) {
  8542. var containment, co, top, left,
  8543. o = this.options,
  8544. scrollIsRootNode = this._isRootNode( this.scrollParent[ 0 ] ),
  8545. pageX = event.pageX,
  8546. pageY = event.pageY;
  8547. // Cache the scroll
  8548. if ( !scrollIsRootNode || !this.offset.scroll ) {
  8549. this.offset.scroll = {
  8550. top: this.scrollParent.scrollTop(),
  8551. left: this.scrollParent.scrollLeft()
  8552. };
  8553. }
  8554. /*
  8555. * - Position constraining -
  8556. * Constrain the position to a mix of grid, containment.
  8557. */
  8558. // If we are not dragging yet, we won't check for options
  8559. if ( constrainPosition ) {
  8560. if ( this.containment ) {
  8561. if ( this.relativeContainer ) {
  8562. co = this.relativeContainer.offset();
  8563. containment = [
  8564. this.containment[ 0 ] + co.left,
  8565. this.containment[ 1 ] + co.top,
  8566. this.containment[ 2 ] + co.left,
  8567. this.containment[ 3 ] + co.top
  8568. ];
  8569. } else {
  8570. containment = this.containment;
  8571. }
  8572. if ( event.pageX - this.offset.click.left < containment[ 0 ] ) {
  8573. pageX = containment[ 0 ] + this.offset.click.left;
  8574. }
  8575. if ( event.pageY - this.offset.click.top < containment[ 1 ] ) {
  8576. pageY = containment[ 1 ] + this.offset.click.top;
  8577. }
  8578. if ( event.pageX - this.offset.click.left > containment[ 2 ] ) {
  8579. pageX = containment[ 2 ] + this.offset.click.left;
  8580. }
  8581. if ( event.pageY - this.offset.click.top > containment[ 3 ] ) {
  8582. pageY = containment[ 3 ] + this.offset.click.top;
  8583. }
  8584. }
  8585. if ( o.grid ) {
  8586. //Check for grid elements set to 0 to prevent divide by 0 error causing invalid
  8587. // argument errors in IE (see ticket #6950)
  8588. top = o.grid[ 1 ] ? this.originalPageY + Math.round( ( pageY -
  8589. this.originalPageY ) / o.grid[ 1 ] ) * o.grid[ 1 ] : this.originalPageY;
  8590. pageY = containment ? ( ( top - this.offset.click.top >= containment[ 1 ] ||
  8591. top - this.offset.click.top > containment[ 3 ] ) ?
  8592. top :
  8593. ( ( top - this.offset.click.top >= containment[ 1 ] ) ?
  8594. top - o.grid[ 1 ] : top + o.grid[ 1 ] ) ) : top;
  8595. left = o.grid[ 0 ] ? this.originalPageX +
  8596. Math.round( ( pageX - this.originalPageX ) / o.grid[ 0 ] ) * o.grid[ 0 ] :
  8597. this.originalPageX;
  8598. pageX = containment ? ( ( left - this.offset.click.left >= containment[ 0 ] ||
  8599. left - this.offset.click.left > containment[ 2 ] ) ?
  8600. left :
  8601. ( ( left - this.offset.click.left >= containment[ 0 ] ) ?
  8602. left - o.grid[ 0 ] : left + o.grid[ 0 ] ) ) : left;
  8603. }
  8604. if ( o.axis === "y" ) {
  8605. pageX = this.originalPageX;
  8606. }
  8607. if ( o.axis === "x" ) {
  8608. pageY = this.originalPageY;
  8609. }
  8610. }
  8611. return {
  8612. top: (
  8613. // The absolute mouse position
  8614. pageY -
  8615. // Click offset (relative to the element)
  8616. this.offset.click.top -
  8617. // Only for relative positioned nodes: Relative offset from element to offset parent
  8618. this.offset.relative.top -
  8619. // The offsetParent's offset without borders (offset + border)
  8620. this.offset.parent.top +
  8621. ( this.cssPosition === "fixed" ?
  8622. -this.offset.scroll.top :
  8623. ( scrollIsRootNode ? 0 : this.offset.scroll.top ) )
  8624. ),
  8625. left: (
  8626. // The absolute mouse position
  8627. pageX -
  8628. // Click offset (relative to the element)
  8629. this.offset.click.left -
  8630. // Only for relative positioned nodes: Relative offset from element to offset parent
  8631. this.offset.relative.left -
  8632. // The offsetParent's offset without borders (offset + border)
  8633. this.offset.parent.left +
  8634. ( this.cssPosition === "fixed" ?
  8635. -this.offset.scroll.left :
  8636. ( scrollIsRootNode ? 0 : this.offset.scroll.left ) )
  8637. )
  8638. };
  8639. },
  8640. _clear: function() {
  8641. this._removeClass( this.helper, "ui-draggable-dragging" );
  8642. if ( this.helper[ 0 ] !== this.element[ 0 ] && !this.cancelHelperRemoval ) {
  8643. this.helper.remove();
  8644. }
  8645. this.helper = null;
  8646. this.cancelHelperRemoval = false;
  8647. if ( this.destroyOnClear ) {
  8648. this.destroy();
  8649. }
  8650. },
  8651. // From now on bulk stuff - mainly helpers
  8652. _trigger: function( type, event, ui ) {
  8653. ui = ui || this._uiHash();
  8654. $.ui.plugin.call( this, type, [ event, ui, this ], true );
  8655. // Absolute position and offset (see #6884 ) have to be recalculated after plugins
  8656. if ( /^(drag|start|stop)/.test( type ) ) {
  8657. this.positionAbs = this._convertPositionTo( "absolute" );
  8658. ui.offset = this.positionAbs;
  8659. }
  8660. return $.Widget.prototype._trigger.call( this, type, event, ui );
  8661. },
  8662. plugins: {},
  8663. _uiHash: function() {
  8664. return {
  8665. helper: this.helper,
  8666. position: this.position,
  8667. originalPosition: this.originalPosition,
  8668. offset: this.positionAbs
  8669. };
  8670. }
  8671. } );
  8672. $.ui.plugin.add( "draggable", "connectToSortable", {
  8673. start: function( event, ui, draggable ) {
  8674. var uiSortable = $.extend( {}, ui, {
  8675. item: draggable.element
  8676. } );
  8677. draggable.sortables = [];
  8678. $( draggable.options.connectToSortable ).each( function() {
  8679. var sortable = $( this ).sortable( "instance" );
  8680. if ( sortable && !sortable.options.disabled ) {
  8681. draggable.sortables.push( sortable );
  8682. // RefreshPositions is called at drag start to refresh the containerCache
  8683. // which is used in drag. This ensures it's initialized and synchronized
  8684. // with any changes that might have happened on the page since initialization.
  8685. sortable.refreshPositions();
  8686. sortable._trigger( "activate", event, uiSortable );
  8687. }
  8688. } );
  8689. },
  8690. stop: function( event, ui, draggable ) {
  8691. var uiSortable = $.extend( {}, ui, {
  8692. item: draggable.element
  8693. } );
  8694. draggable.cancelHelperRemoval = false;
  8695. $.each( draggable.sortables, function() {
  8696. var sortable = this;
  8697. if ( sortable.isOver ) {
  8698. sortable.isOver = 0;
  8699. // Allow this sortable to handle removing the helper
  8700. draggable.cancelHelperRemoval = true;
  8701. sortable.cancelHelperRemoval = false;
  8702. // Use _storedCSS To restore properties in the sortable,
  8703. // as this also handles revert (#9675) since the draggable
  8704. // may have modified them in unexpected ways (#8809)
  8705. sortable._storedCSS = {
  8706. position: sortable.placeholder.css( "position" ),
  8707. top: sortable.placeholder.css( "top" ),
  8708. left: sortable.placeholder.css( "left" )
  8709. };
  8710. sortable._mouseStop( event );
  8711. // Once drag has ended, the sortable should return to using
  8712. // its original helper, not the shared helper from draggable
  8713. sortable.options.helper = sortable.options._helper;
  8714. } else {
  8715. // Prevent this Sortable from removing the helper.
  8716. // However, don't set the draggable to remove the helper
  8717. // either as another connected Sortable may yet handle the removal.
  8718. sortable.cancelHelperRemoval = true;
  8719. sortable._trigger( "deactivate", event, uiSortable );
  8720. }
  8721. } );
  8722. },
  8723. drag: function( event, ui, draggable ) {
  8724. $.each( draggable.sortables, function() {
  8725. var innermostIntersecting = false,
  8726. sortable = this;
  8727. // Copy over variables that sortable's _intersectsWith uses
  8728. sortable.positionAbs = draggable.positionAbs;
  8729. sortable.helperProportions = draggable.helperProportions;
  8730. sortable.offset.click = draggable.offset.click;
  8731. if ( sortable._intersectsWith( sortable.containerCache ) ) {
  8732. innermostIntersecting = true;
  8733. $.each( draggable.sortables, function() {
  8734. // Copy over variables that sortable's _intersectsWith uses
  8735. this.positionAbs = draggable.positionAbs;
  8736. this.helperProportions = draggable.helperProportions;
  8737. this.offset.click = draggable.offset.click;
  8738. if ( this !== sortable &&
  8739. this._intersectsWith( this.containerCache ) &&
  8740. $.contains( sortable.element[ 0 ], this.element[ 0 ] ) ) {
  8741. innermostIntersecting = false;
  8742. }
  8743. return innermostIntersecting;
  8744. } );
  8745. }
  8746. if ( innermostIntersecting ) {
  8747. // If it intersects, we use a little isOver variable and set it once,
  8748. // so that the move-in stuff gets fired only once.
  8749. if ( !sortable.isOver ) {
  8750. sortable.isOver = 1;
  8751. // Store draggable's parent in case we need to reappend to it later.
  8752. draggable._parent = ui.helper.parent();
  8753. sortable.currentItem = ui.helper
  8754. .appendTo( sortable.element )
  8755. .data( "ui-sortable-item", true );
  8756. // Store helper option to later restore it
  8757. sortable.options._helper = sortable.options.helper;
  8758. sortable.options.helper = function() {
  8759. return ui.helper[ 0 ];
  8760. };
  8761. // Fire the start events of the sortable with our passed browser event,
  8762. // and our own helper (so it doesn't create a new one)
  8763. event.target = sortable.currentItem[ 0 ];
  8764. sortable._mouseCapture( event, true );
  8765. sortable._mouseStart( event, true, true );
  8766. // Because the browser event is way off the new appended portlet,
  8767. // modify necessary variables to reflect the changes
  8768. sortable.offset.click.top = draggable.offset.click.top;
  8769. sortable.offset.click.left = draggable.offset.click.left;
  8770. sortable.offset.parent.left -= draggable.offset.parent.left -
  8771. sortable.offset.parent.left;
  8772. sortable.offset.parent.top -= draggable.offset.parent.top -
  8773. sortable.offset.parent.top;
  8774. draggable._trigger( "toSortable", event );
  8775. // Inform draggable that the helper is in a valid drop zone,
  8776. // used solely in the revert option to handle "valid/invalid".
  8777. draggable.dropped = sortable.element;
  8778. // Need to refreshPositions of all sortables in the case that
  8779. // adding to one sortable changes the location of the other sortables (#9675)
  8780. $.each( draggable.sortables, function() {
  8781. this.refreshPositions();
  8782. } );
  8783. // Hack so receive/update callbacks work (mostly)
  8784. draggable.currentItem = draggable.element;
  8785. sortable.fromOutside = draggable;
  8786. }
  8787. if ( sortable.currentItem ) {
  8788. sortable._mouseDrag( event );
  8789. // Copy the sortable's position because the draggable's can potentially reflect
  8790. // a relative position, while sortable is always absolute, which the dragged
  8791. // element has now become. (#8809)
  8792. ui.position = sortable.position;
  8793. }
  8794. } else {
  8795. // If it doesn't intersect with the sortable, and it intersected before,
  8796. // we fake the drag stop of the sortable, but make sure it doesn't remove
  8797. // the helper by using cancelHelperRemoval.
  8798. if ( sortable.isOver ) {
  8799. sortable.isOver = 0;
  8800. sortable.cancelHelperRemoval = true;
  8801. // Calling sortable's mouseStop would trigger a revert,
  8802. // so revert must be temporarily false until after mouseStop is called.
  8803. sortable.options._revert = sortable.options.revert;
  8804. sortable.options.revert = false;
  8805. sortable._trigger( "out", event, sortable._uiHash( sortable ) );
  8806. sortable._mouseStop( event, true );
  8807. // Restore sortable behaviors that were modfied
  8808. // when the draggable entered the sortable area (#9481)
  8809. sortable.options.revert = sortable.options._revert;
  8810. sortable.options.helper = sortable.options._helper;
  8811. if ( sortable.placeholder ) {
  8812. sortable.placeholder.remove();
  8813. }
  8814. // Restore and recalculate the draggable's offset considering the sortable
  8815. // may have modified them in unexpected ways. (#8809, #10669)
  8816. ui.helper.appendTo( draggable._parent );
  8817. draggable._refreshOffsets( event );
  8818. ui.position = draggable._generatePosition( event, true );
  8819. draggable._trigger( "fromSortable", event );
  8820. // Inform draggable that the helper is no longer in a valid drop zone
  8821. draggable.dropped = false;
  8822. // Need to refreshPositions of all sortables just in case removing
  8823. // from one sortable changes the location of other sortables (#9675)
  8824. $.each( draggable.sortables, function() {
  8825. this.refreshPositions();
  8826. } );
  8827. }
  8828. }
  8829. } );
  8830. }
  8831. } );
  8832. $.ui.plugin.add( "draggable", "cursor", {
  8833. start: function( event, ui, instance ) {
  8834. var t = $( "body" ),
  8835. o = instance.options;
  8836. if ( t.css( "cursor" ) ) {
  8837. o._cursor = t.css( "cursor" );
  8838. }
  8839. t.css( "cursor", o.cursor );
  8840. },
  8841. stop: function( event, ui, instance ) {
  8842. var o = instance.options;
  8843. if ( o._cursor ) {
  8844. $( "body" ).css( "cursor", o._cursor );
  8845. }
  8846. }
  8847. } );
  8848. $.ui.plugin.add( "draggable", "opacity", {
  8849. start: function( event, ui, instance ) {
  8850. var t = $( ui.helper ),
  8851. o = instance.options;
  8852. if ( t.css( "opacity" ) ) {
  8853. o._opacity = t.css( "opacity" );
  8854. }
  8855. t.css( "opacity", o.opacity );
  8856. },
  8857. stop: function( event, ui, instance ) {
  8858. var o = instance.options;
  8859. if ( o._opacity ) {
  8860. $( ui.helper ).css( "opacity", o._opacity );
  8861. }
  8862. }
  8863. } );
  8864. $.ui.plugin.add( "draggable", "scroll", {
  8865. start: function( event, ui, i ) {
  8866. if ( !i.scrollParentNotHidden ) {
  8867. i.scrollParentNotHidden = i.helper.scrollParent( false );
  8868. }
  8869. if ( i.scrollParentNotHidden[ 0 ] !== i.document[ 0 ] &&
  8870. i.scrollParentNotHidden[ 0 ].tagName !== "HTML" ) {
  8871. i.overflowOffset = i.scrollParentNotHidden.offset();
  8872. }
  8873. },
  8874. drag: function( event, ui, i ) {
  8875. var o = i.options,
  8876. scrolled = false,
  8877. scrollParent = i.scrollParentNotHidden[ 0 ],
  8878. document = i.document[ 0 ];
  8879. if ( scrollParent !== document && scrollParent.tagName !== "HTML" ) {
  8880. if ( !o.axis || o.axis !== "x" ) {
  8881. if ( ( i.overflowOffset.top + scrollParent.offsetHeight ) - event.pageY <
  8882. o.scrollSensitivity ) {
  8883. scrollParent.scrollTop = scrolled = scrollParent.scrollTop + o.scrollSpeed;
  8884. } else if ( event.pageY - i.overflowOffset.top < o.scrollSensitivity ) {
  8885. scrollParent.scrollTop = scrolled = scrollParent.scrollTop - o.scrollSpeed;
  8886. }
  8887. }
  8888. if ( !o.axis || o.axis !== "y" ) {
  8889. if ( ( i.overflowOffset.left + scrollParent.offsetWidth ) - event.pageX <
  8890. o.scrollSensitivity ) {
  8891. scrollParent.scrollLeft = scrolled = scrollParent.scrollLeft + o.scrollSpeed;
  8892. } else if ( event.pageX - i.overflowOffset.left < o.scrollSensitivity ) {
  8893. scrollParent.scrollLeft = scrolled = scrollParent.scrollLeft - o.scrollSpeed;
  8894. }
  8895. }
  8896. } else {
  8897. if ( !o.axis || o.axis !== "x" ) {
  8898. if ( event.pageY - $( document ).scrollTop() < o.scrollSensitivity ) {
  8899. scrolled = $( document ).scrollTop( $( document ).scrollTop() - o.scrollSpeed );
  8900. } else if ( $( window ).height() - ( event.pageY - $( document ).scrollTop() ) <
  8901. o.scrollSensitivity ) {
  8902. scrolled = $( document ).scrollTop( $( document ).scrollTop() + o.scrollSpeed );
  8903. }
  8904. }
  8905. if ( !o.axis || o.axis !== "y" ) {
  8906. if ( event.pageX - $( document ).scrollLeft() < o.scrollSensitivity ) {
  8907. scrolled = $( document ).scrollLeft(
  8908. $( document ).scrollLeft() - o.scrollSpeed
  8909. );
  8910. } else if ( $( window ).width() - ( event.pageX - $( document ).scrollLeft() ) <
  8911. o.scrollSensitivity ) {
  8912. scrolled = $( document ).scrollLeft(
  8913. $( document ).scrollLeft() + o.scrollSpeed
  8914. );
  8915. }
  8916. }
  8917. }
  8918. if ( scrolled !== false && $.ui.ddmanager && !o.dropBehaviour ) {
  8919. $.ui.ddmanager.prepareOffsets( i, event );
  8920. }
  8921. }
  8922. } );
  8923. $.ui.plugin.add( "draggable", "snap", {
  8924. start: function( event, ui, i ) {
  8925. var o = i.options;
  8926. i.snapElements = [];
  8927. $( o.snap.constructor !== String ? ( o.snap.items || ":data(ui-draggable)" ) : o.snap )
  8928. .each( function() {
  8929. var $t = $( this ),
  8930. $o = $t.offset();
  8931. if ( this !== i.element[ 0 ] ) {
  8932. i.snapElements.push( {
  8933. item: this,
  8934. width: $t.outerWidth(), height: $t.outerHeight(),
  8935. top: $o.top, left: $o.left
  8936. } );
  8937. }
  8938. } );
  8939. },
  8940. drag: function( event, ui, inst ) {
  8941. var ts, bs, ls, rs, l, r, t, b, i, first,
  8942. o = inst.options,
  8943. d = o.snapTolerance,
  8944. x1 = ui.offset.left, x2 = x1 + inst.helperProportions.width,
  8945. y1 = ui.offset.top, y2 = y1 + inst.helperProportions.height;
  8946. for ( i = inst.snapElements.length - 1; i >= 0; i-- ) {
  8947. l = inst.snapElements[ i ].left - inst.margins.left;
  8948. r = l + inst.snapElements[ i ].width;
  8949. t = inst.snapElements[ i ].top - inst.margins.top;
  8950. b = t + inst.snapElements[ i ].height;
  8951. if ( x2 < l - d || x1 > r + d || y2 < t - d || y1 > b + d ||
  8952. !$.contains( inst.snapElements[ i ].item.ownerDocument,
  8953. inst.snapElements[ i ].item ) ) {
  8954. if ( inst.snapElements[ i ].snapping ) {
  8955. ( inst.options.snap.release &&
  8956. inst.options.snap.release.call(
  8957. inst.element,
  8958. event,
  8959. $.extend( inst._uiHash(), { snapItem: inst.snapElements[ i ].item } )
  8960. ) );
  8961. }
  8962. inst.snapElements[ i ].snapping = false;
  8963. continue;
  8964. }
  8965. if ( o.snapMode !== "inner" ) {
  8966. ts = Math.abs( t - y2 ) <= d;
  8967. bs = Math.abs( b - y1 ) <= d;
  8968. ls = Math.abs( l - x2 ) <= d;
  8969. rs = Math.abs( r - x1 ) <= d;
  8970. if ( ts ) {
  8971. ui.position.top = inst._convertPositionTo( "relative", {
  8972. top: t - inst.helperProportions.height,
  8973. left: 0
  8974. } ).top;
  8975. }
  8976. if ( bs ) {
  8977. ui.position.top = inst._convertPositionTo( "relative", {
  8978. top: b,
  8979. left: 0
  8980. } ).top;
  8981. }
  8982. if ( ls ) {
  8983. ui.position.left = inst._convertPositionTo( "relative", {
  8984. top: 0,
  8985. left: l - inst.helperProportions.width
  8986. } ).left;
  8987. }
  8988. if ( rs ) {
  8989. ui.position.left = inst._convertPositionTo( "relative", {
  8990. top: 0,
  8991. left: r
  8992. } ).left;
  8993. }
  8994. }
  8995. first = ( ts || bs || ls || rs );
  8996. if ( o.snapMode !== "outer" ) {
  8997. ts = Math.abs( t - y1 ) <= d;
  8998. bs = Math.abs( b - y2 ) <= d;
  8999. ls = Math.abs( l - x1 ) <= d;
  9000. rs = Math.abs( r - x2 ) <= d;
  9001. if ( ts ) {
  9002. ui.position.top = inst._convertPositionTo( "relative", {
  9003. top: t,
  9004. left: 0
  9005. } ).top;
  9006. }
  9007. if ( bs ) {
  9008. ui.position.top = inst._convertPositionTo( "relative", {
  9009. top: b - inst.helperProportions.height,
  9010. left: 0
  9011. } ).top;
  9012. }
  9013. if ( ls ) {
  9014. ui.position.left = inst._convertPositionTo( "relative", {
  9015. top: 0,
  9016. left: l
  9017. } ).left;
  9018. }
  9019. if ( rs ) {
  9020. ui.position.left = inst._convertPositionTo( "relative", {
  9021. top: 0,
  9022. left: r - inst.helperProportions.width
  9023. } ).left;
  9024. }
  9025. }
  9026. if ( !inst.snapElements[ i ].snapping && ( ts || bs || ls || rs || first ) ) {
  9027. ( inst.options.snap.snap &&
  9028. inst.options.snap.snap.call(
  9029. inst.element,
  9030. event,
  9031. $.extend( inst._uiHash(), {
  9032. snapItem: inst.snapElements[ i ].item
  9033. } ) ) );
  9034. }
  9035. inst.snapElements[ i ].snapping = ( ts || bs || ls || rs || first );
  9036. }
  9037. }
  9038. } );
  9039. $.ui.plugin.add( "draggable", "stack", {
  9040. start: function( event, ui, instance ) {
  9041. var min,
  9042. o = instance.options,
  9043. group = $.makeArray( $( o.stack ) ).sort( function( a, b ) {
  9044. return ( parseInt( $( a ).css( "zIndex" ), 10 ) || 0 ) -
  9045. ( parseInt( $( b ).css( "zIndex" ), 10 ) || 0 );
  9046. } );
  9047. if ( !group.length ) { return; }
  9048. min = parseInt( $( group[ 0 ] ).css( "zIndex" ), 10 ) || 0;
  9049. $( group ).each( function( i ) {
  9050. $( this ).css( "zIndex", min + i );
  9051. } );
  9052. this.css( "zIndex", ( min + group.length ) );
  9053. }
  9054. } );
  9055. $.ui.plugin.add( "draggable", "zIndex", {
  9056. start: function( event, ui, instance ) {
  9057. var t = $( ui.helper ),
  9058. o = instance.options;
  9059. if ( t.css( "zIndex" ) ) {
  9060. o._zIndex = t.css( "zIndex" );
  9061. }
  9062. t.css( "zIndex", o.zIndex );
  9063. },
  9064. stop: function( event, ui, instance ) {
  9065. var o = instance.options;
  9066. if ( o._zIndex ) {
  9067. $( ui.helper ).css( "zIndex", o._zIndex );
  9068. }
  9069. }
  9070. } );
  9071. var widgetsDraggable = $.ui.draggable;
  9072. /*!
  9073. * jQuery UI Resizable 1.12.0
  9074. * http://jqueryui.com
  9075. *
  9076. * Copyright jQuery Foundation and other contributors
  9077. * Released under the MIT license.
  9078. * http://jquery.org/license
  9079. */
  9080. //>>label: Resizable
  9081. //>>group: Interactions
  9082. //>>description: Enables resize functionality for any element.
  9083. //>>docs: http://api.jqueryui.com/resizable/
  9084. //>>demos: http://jqueryui.com/resizable/
  9085. //>>css.structure: ../../themes/base/core.css
  9086. //>>css.structure: ../../themes/base/resizable.css
  9087. //>>css.theme: ../../themes/base/theme.css
  9088. $.widget( "ui.resizable", $.ui.mouse, {
  9089. version: "1.12.0",
  9090. widgetEventPrefix: "resize",
  9091. options: {
  9092. alsoResize: false,
  9093. animate: false,
  9094. animateDuration: "slow",
  9095. animateEasing: "swing",
  9096. aspectRatio: false,
  9097. autoHide: false,
  9098. classes: {
  9099. "ui-resizable-se": "ui-icon ui-icon-gripsmall-diagonal-se"
  9100. },
  9101. containment: false,
  9102. ghost: false,
  9103. grid: false,
  9104. handles: "e,s,se",
  9105. helper: false,
  9106. maxHeight: null,
  9107. maxWidth: null,
  9108. minHeight: 10,
  9109. minWidth: 10,
  9110. // See #7960
  9111. zIndex: 90,
  9112. // Callbacks
  9113. resize: null,
  9114. start: null,
  9115. stop: null
  9116. },
  9117. _num: function( value ) {
  9118. return parseFloat( value ) || 0;
  9119. },
  9120. _isNumber: function( value ) {
  9121. return !isNaN( parseFloat( value ) );
  9122. },
  9123. _hasScroll: function( el, a ) {
  9124. if ( $( el ).css( "overflow" ) === "hidden" ) {
  9125. return false;
  9126. }
  9127. var scroll = ( a && a === "left" ) ? "scrollLeft" : "scrollTop",
  9128. has = false;
  9129. if ( el[ scroll ] > 0 ) {
  9130. return true;
  9131. }
  9132. // TODO: determine which cases actually cause this to happen
  9133. // if the element doesn't have the scroll set, see if it's possible to
  9134. // set the scroll
  9135. el[ scroll ] = 1;
  9136. has = ( el[ scroll ] > 0 );
  9137. el[ scroll ] = 0;
  9138. return has;
  9139. },
  9140. _create: function() {
  9141. var margins,
  9142. o = this.options,
  9143. that = this;
  9144. this._addClass( "ui-resizable" );
  9145. $.extend( this, {
  9146. _aspectRatio: !!( o.aspectRatio ),
  9147. aspectRatio: o.aspectRatio,
  9148. originalElement: this.element,
  9149. _proportionallyResizeElements: [],
  9150. _helper: o.helper || o.ghost || o.animate ? o.helper || "ui-resizable-helper" : null
  9151. } );
  9152. // Wrap the element if it cannot hold child nodes
  9153. if ( this.element[ 0 ].nodeName.match( /^(canvas|textarea|input|select|button|img)$/i ) ) {
  9154. this.element.wrap(
  9155. $( "<div class='ui-wrapper' style='overflow: hidden;'></div>" ).css( {
  9156. position: this.element.css( "position" ),
  9157. width: this.element.outerWidth(),
  9158. height: this.element.outerHeight(),
  9159. top: this.element.css( "top" ),
  9160. left: this.element.css( "left" )
  9161. } )
  9162. );
  9163. this.element = this.element.parent().data(
  9164. "ui-resizable", this.element.resizable( "instance" )
  9165. );
  9166. this.elementIsWrapper = true;
  9167. margins = {
  9168. marginTop: this.originalElement.css( "marginTop" ),
  9169. marginRight: this.originalElement.css( "marginRight" ),
  9170. marginBottom: this.originalElement.css( "marginBottom" ),
  9171. marginLeft: this.originalElement.css( "marginLeft" )
  9172. };
  9173. this.element.css( margins );
  9174. this.originalElement.css( "margin", 0 );
  9175. // support: Safari
  9176. // Prevent Safari textarea resize
  9177. this.originalResizeStyle = this.originalElement.css( "resize" );
  9178. this.originalElement.css( "resize", "none" );
  9179. this._proportionallyResizeElements.push( this.originalElement.css( {
  9180. position: "static",
  9181. zoom: 1,
  9182. display: "block"
  9183. } ) );
  9184. // Support: IE9
  9185. // avoid IE jump (hard set the margin)
  9186. this.originalElement.css( margins );
  9187. this._proportionallyResize();
  9188. }
  9189. this._setupHandles();
  9190. if ( o.autoHide ) {
  9191. $( this.element )
  9192. .on( "mouseenter", function() {
  9193. if ( o.disabled ) {
  9194. return;
  9195. }
  9196. that._removeClass( "ui-resizable-autohide" );
  9197. that._handles.show();
  9198. } )
  9199. .on( "mouseleave", function() {
  9200. if ( o.disabled ) {
  9201. return;
  9202. }
  9203. if ( !that.resizing ) {
  9204. that._addClass( "ui-resizable-autohide" );
  9205. that._handles.hide();
  9206. }
  9207. } );
  9208. }
  9209. this._mouseInit();
  9210. },
  9211. _destroy: function() {
  9212. this._mouseDestroy();
  9213. var wrapper,
  9214. _destroy = function( exp ) {
  9215. $( exp )
  9216. .removeData( "resizable" )
  9217. .removeData( "ui-resizable" )
  9218. .off( ".resizable" )
  9219. .find( ".ui-resizable-handle" )
  9220. .remove();
  9221. };
  9222. // TODO: Unwrap at same DOM position
  9223. if ( this.elementIsWrapper ) {
  9224. _destroy( this.element );
  9225. wrapper = this.element;
  9226. this.originalElement.css( {
  9227. position: wrapper.css( "position" ),
  9228. width: wrapper.outerWidth(),
  9229. height: wrapper.outerHeight(),
  9230. top: wrapper.css( "top" ),
  9231. left: wrapper.css( "left" )
  9232. } ).insertAfter( wrapper );
  9233. wrapper.remove();
  9234. }
  9235. this.originalElement.css( "resize", this.originalResizeStyle );
  9236. _destroy( this.originalElement );
  9237. return this;
  9238. },
  9239. _setOption: function( key, value ) {
  9240. this._super( key, value );
  9241. switch ( key ) {
  9242. case "handles":
  9243. this._removeHandles();
  9244. this._setupHandles();
  9245. break;
  9246. default:
  9247. break;
  9248. }
  9249. },
  9250. _setupHandles: function() {
  9251. var o = this.options, handle, i, n, hname, axis, that = this;
  9252. this.handles = o.handles ||
  9253. ( !$( ".ui-resizable-handle", this.element ).length ?
  9254. "e,s,se" : {
  9255. n: ".ui-resizable-n",
  9256. e: ".ui-resizable-e",
  9257. s: ".ui-resizable-s",
  9258. w: ".ui-resizable-w",
  9259. se: ".ui-resizable-se",
  9260. sw: ".ui-resizable-sw",
  9261. ne: ".ui-resizable-ne",
  9262. nw: ".ui-resizable-nw"
  9263. } );
  9264. this._handles = $();
  9265. if ( this.handles.constructor === String ) {
  9266. if ( this.handles === "all" ) {
  9267. this.handles = "n,e,s,w,se,sw,ne,nw";
  9268. }
  9269. n = this.handles.split( "," );
  9270. this.handles = {};
  9271. for ( i = 0; i < n.length; i++ ) {
  9272. handle = $.trim( n[ i ] );
  9273. hname = "ui-resizable-" + handle;
  9274. axis = $( "<div>" );
  9275. this._addClass( axis, "ui-resizable-handle " + hname );
  9276. axis.css( { zIndex: o.zIndex } );
  9277. this.handles[ handle ] = ".ui-resizable-" + handle;
  9278. this.element.append( axis );
  9279. }
  9280. }
  9281. this._renderAxis = function( target ) {
  9282. var i, axis, padPos, padWrapper;
  9283. target = target || this.element;
  9284. for ( i in this.handles ) {
  9285. if ( this.handles[ i ].constructor === String ) {
  9286. this.handles[ i ] = this.element.children( this.handles[ i ] ).first().show();
  9287. } else if ( this.handles[ i ].jquery || this.handles[ i ].nodeType ) {
  9288. this.handles[ i ] = $( this.handles[ i ] );
  9289. this._on( this.handles[ i ], { "mousedown": that._mouseDown } );
  9290. }
  9291. if ( this.elementIsWrapper &&
  9292. this.originalElement[ 0 ]
  9293. .nodeName
  9294. .match( /^(textarea|input|select|button)$/i ) ) {
  9295. axis = $( this.handles[ i ], this.element );
  9296. padWrapper = /sw|ne|nw|se|n|s/.test( i ) ?
  9297. axis.outerHeight() :
  9298. axis.outerWidth();
  9299. padPos = [ "padding",
  9300. /ne|nw|n/.test( i ) ? "Top" :
  9301. /se|sw|s/.test( i ) ? "Bottom" :
  9302. /^e$/.test( i ) ? "Right" : "Left" ].join( "" );
  9303. target.css( padPos, padWrapper );
  9304. this._proportionallyResize();
  9305. }
  9306. this._handles = this._handles.add( this.handles[ i ] );
  9307. }
  9308. };
  9309. // TODO: make renderAxis a prototype function
  9310. this._renderAxis( this.element );
  9311. this._handles = this._handles.add( this.element.find( ".ui-resizable-handle" ) );
  9312. this._handles.disableSelection();
  9313. this._handles.on( "mouseover", function() {
  9314. if ( !that.resizing ) {
  9315. if ( this.className ) {
  9316. axis = this.className.match( /ui-resizable-(se|sw|ne|nw|n|e|s|w)/i );
  9317. }
  9318. that.axis = axis && axis[ 1 ] ? axis[ 1 ] : "se";
  9319. }
  9320. } );
  9321. if ( o.autoHide ) {
  9322. this._handles.hide();
  9323. this._addClass( "ui-resizable-autohide" );
  9324. }
  9325. },
  9326. _removeHandles: function() {
  9327. this._handles.remove();
  9328. },
  9329. _mouseCapture: function( event ) {
  9330. var i, handle,
  9331. capture = false;
  9332. for ( i in this.handles ) {
  9333. handle = $( this.handles[ i ] )[ 0 ];
  9334. if ( handle === event.target || $.contains( handle, event.target ) ) {
  9335. capture = true;
  9336. }
  9337. }
  9338. return !this.options.disabled && capture;
  9339. },
  9340. _mouseStart: function( event ) {
  9341. var curleft, curtop, cursor,
  9342. o = this.options,
  9343. el = this.element;
  9344. this.resizing = true;
  9345. this._renderProxy();
  9346. curleft = this._num( this.helper.css( "left" ) );
  9347. curtop = this._num( this.helper.css( "top" ) );
  9348. if ( o.containment ) {
  9349. curleft += $( o.containment ).scrollLeft() || 0;
  9350. curtop += $( o.containment ).scrollTop() || 0;
  9351. }
  9352. this.offset = this.helper.offset();
  9353. this.position = { left: curleft, top: curtop };
  9354. this.size = this._helper ? {
  9355. width: this.helper.width(),
  9356. height: this.helper.height()
  9357. } : {
  9358. width: el.width(),
  9359. height: el.height()
  9360. };
  9361. this.originalSize = this._helper ? {
  9362. width: el.outerWidth(),
  9363. height: el.outerHeight()
  9364. } : {
  9365. width: el.width(),
  9366. height: el.height()
  9367. };
  9368. this.sizeDiff = {
  9369. width: el.outerWidth() - el.width(),
  9370. height: el.outerHeight() - el.height()
  9371. };
  9372. this.originalPosition = { left: curleft, top: curtop };
  9373. this.originalMousePosition = { left: event.pageX, top: event.pageY };
  9374. this.aspectRatio = ( typeof o.aspectRatio === "number" ) ?
  9375. o.aspectRatio :
  9376. ( ( this.originalSize.width / this.originalSize.height ) || 1 );
  9377. cursor = $( ".ui-resizable-" + this.axis ).css( "cursor" );
  9378. $( "body" ).css( "cursor", cursor === "auto" ? this.axis + "-resize" : cursor );
  9379. this._addClass( "ui-resizable-resizing" );
  9380. this._propagate( "start", event );
  9381. return true;
  9382. },
  9383. _mouseDrag: function( event ) {
  9384. var data, props,
  9385. smp = this.originalMousePosition,
  9386. a = this.axis,
  9387. dx = ( event.pageX - smp.left ) || 0,
  9388. dy = ( event.pageY - smp.top ) || 0,
  9389. trigger = this._change[ a ];
  9390. this._updatePrevProperties();
  9391. if ( !trigger ) {
  9392. return false;
  9393. }
  9394. data = trigger.apply( this, [ event, dx, dy ] );
  9395. this._updateVirtualBoundaries( event.shiftKey );
  9396. if ( this._aspectRatio || event.shiftKey ) {
  9397. data = this._updateRatio( data, event );
  9398. }
  9399. data = this._respectSize( data, event );
  9400. this._updateCache( data );
  9401. this._propagate( "resize", event );
  9402. props = this._applyChanges();
  9403. if ( !this._helper && this._proportionallyResizeElements.length ) {
  9404. this._proportionallyResize();
  9405. }
  9406. if ( !$.isEmptyObject( props ) ) {
  9407. this._updatePrevProperties();
  9408. this._trigger( "resize", event, this.ui() );
  9409. this._applyChanges();
  9410. }
  9411. return false;
  9412. },
  9413. _mouseStop: function( event ) {
  9414. this.resizing = false;
  9415. var pr, ista, soffseth, soffsetw, s, left, top,
  9416. o = this.options, that = this;
  9417. if ( this._helper ) {
  9418. pr = this._proportionallyResizeElements;
  9419. ista = pr.length && ( /textarea/i ).test( pr[ 0 ].nodeName );
  9420. soffseth = ista && this._hasScroll( pr[ 0 ], "left" ) ? 0 : that.sizeDiff.height;
  9421. soffsetw = ista ? 0 : that.sizeDiff.width;
  9422. s = {
  9423. width: ( that.helper.width() - soffsetw ),
  9424. height: ( that.helper.height() - soffseth )
  9425. };
  9426. left = ( parseFloat( that.element.css( "left" ) ) +
  9427. ( that.position.left - that.originalPosition.left ) ) || null;
  9428. top = ( parseFloat( that.element.css( "top" ) ) +
  9429. ( that.position.top - that.originalPosition.top ) ) || null;
  9430. if ( !o.animate ) {
  9431. this.element.css( $.extend( s, { top: top, left: left } ) );
  9432. }
  9433. that.helper.height( that.size.height );
  9434. that.helper.width( that.size.width );
  9435. if ( this._helper && !o.animate ) {
  9436. this._proportionallyResize();
  9437. }
  9438. }
  9439. $( "body" ).css( "cursor", "auto" );
  9440. this._removeClass( "ui-resizable-resizing" );
  9441. this._propagate( "stop", event );
  9442. if ( this._helper ) {
  9443. this.helper.remove();
  9444. }
  9445. return false;
  9446. },
  9447. _updatePrevProperties: function() {
  9448. this.prevPosition = {
  9449. top: this.position.top,
  9450. left: this.position.left
  9451. };
  9452. this.prevSize = {
  9453. width: this.size.width,
  9454. height: this.size.height
  9455. };
  9456. },
  9457. _applyChanges: function() {
  9458. var props = {};
  9459. if ( this.position.top !== this.prevPosition.top ) {
  9460. props.top = this.position.top + "px";
  9461. }
  9462. if ( this.position.left !== this.prevPosition.left ) {
  9463. props.left = this.position.left + "px";
  9464. }
  9465. if ( this.size.width !== this.prevSize.width ) {
  9466. props.width = this.size.width + "px";
  9467. }
  9468. if ( this.size.height !== this.prevSize.height ) {
  9469. props.height = this.size.height + "px";
  9470. }
  9471. this.helper.css( props );
  9472. return props;
  9473. },
  9474. _updateVirtualBoundaries: function( forceAspectRatio ) {
  9475. var pMinWidth, pMaxWidth, pMinHeight, pMaxHeight, b,
  9476. o = this.options;
  9477. b = {
  9478. minWidth: this._isNumber( o.minWidth ) ? o.minWidth : 0,
  9479. maxWidth: this._isNumber( o.maxWidth ) ? o.maxWidth : Infinity,
  9480. minHeight: this._isNumber( o.minHeight ) ? o.minHeight : 0,
  9481. maxHeight: this._isNumber( o.maxHeight ) ? o.maxHeight : Infinity
  9482. };
  9483. if ( this._aspectRatio || forceAspectRatio ) {
  9484. pMinWidth = b.minHeight * this.aspectRatio;
  9485. pMinHeight = b.minWidth / this.aspectRatio;
  9486. pMaxWidth = b.maxHeight * this.aspectRatio;
  9487. pMaxHeight = b.maxWidth / this.aspectRatio;
  9488. if ( pMinWidth > b.minWidth ) {
  9489. b.minWidth = pMinWidth;
  9490. }
  9491. if ( pMinHeight > b.minHeight ) {
  9492. b.minHeight = pMinHeight;
  9493. }
  9494. if ( pMaxWidth < b.maxWidth ) {
  9495. b.maxWidth = pMaxWidth;
  9496. }
  9497. if ( pMaxHeight < b.maxHeight ) {
  9498. b.maxHeight = pMaxHeight;
  9499. }
  9500. }
  9501. this._vBoundaries = b;
  9502. },
  9503. _updateCache: function( data ) {
  9504. this.offset = this.helper.offset();
  9505. if ( this._isNumber( data.left ) ) {
  9506. this.position.left = data.left;
  9507. }
  9508. if ( this._isNumber( data.top ) ) {
  9509. this.position.top = data.top;
  9510. }
  9511. if ( this._isNumber( data.height ) ) {
  9512. this.size.height = data.height;
  9513. }
  9514. if ( this._isNumber( data.width ) ) {
  9515. this.size.width = data.width;
  9516. }
  9517. },
  9518. _updateRatio: function( data ) {
  9519. var cpos = this.position,
  9520. csize = this.size,
  9521. a = this.axis;
  9522. if ( this._isNumber( data.height ) ) {
  9523. data.width = ( data.height * this.aspectRatio );
  9524. } else if ( this._isNumber( data.width ) ) {
  9525. data.height = ( data.width / this.aspectRatio );
  9526. }
  9527. if ( a === "sw" ) {
  9528. data.left = cpos.left + ( csize.width - data.width );
  9529. data.top = null;
  9530. }
  9531. if ( a === "nw" ) {
  9532. data.top = cpos.top + ( csize.height - data.height );
  9533. data.left = cpos.left + ( csize.width - data.width );
  9534. }
  9535. return data;
  9536. },
  9537. _respectSize: function( data ) {
  9538. var o = this._vBoundaries,
  9539. a = this.axis,
  9540. ismaxw = this._isNumber( data.width ) && o.maxWidth && ( o.maxWidth < data.width ),
  9541. ismaxh = this._isNumber( data.height ) && o.maxHeight && ( o.maxHeight < data.height ),
  9542. isminw = this._isNumber( data.width ) && o.minWidth && ( o.minWidth > data.width ),
  9543. isminh = this._isNumber( data.height ) && o.minHeight && ( o.minHeight > data.height ),
  9544. dw = this.originalPosition.left + this.originalSize.width,
  9545. dh = this.originalPosition.top + this.originalSize.height,
  9546. cw = /sw|nw|w/.test( a ), ch = /nw|ne|n/.test( a );
  9547. if ( isminw ) {
  9548. data.width = o.minWidth;
  9549. }
  9550. if ( isminh ) {
  9551. data.height = o.minHeight;
  9552. }
  9553. if ( ismaxw ) {
  9554. data.width = o.maxWidth;
  9555. }
  9556. if ( ismaxh ) {
  9557. data.height = o.maxHeight;
  9558. }
  9559. if ( isminw && cw ) {
  9560. data.left = dw - o.minWidth;
  9561. }
  9562. if ( ismaxw && cw ) {
  9563. data.left = dw - o.maxWidth;
  9564. }
  9565. if ( isminh && ch ) {
  9566. data.top = dh - o.minHeight;
  9567. }
  9568. if ( ismaxh && ch ) {
  9569. data.top = dh - o.maxHeight;
  9570. }
  9571. // Fixing jump error on top/left - bug #2330
  9572. if ( !data.width && !data.height && !data.left && data.top ) {
  9573. data.top = null;
  9574. } else if ( !data.width && !data.height && !data.top && data.left ) {
  9575. data.left = null;
  9576. }
  9577. return data;
  9578. },
  9579. _getPaddingPlusBorderDimensions: function( element ) {
  9580. var i = 0,
  9581. widths = [],
  9582. borders = [
  9583. element.css( "borderTopWidth" ),
  9584. element.css( "borderRightWidth" ),
  9585. element.css( "borderBottomWidth" ),
  9586. element.css( "borderLeftWidth" )
  9587. ],
  9588. paddings = [
  9589. element.css( "paddingTop" ),
  9590. element.css( "paddingRight" ),
  9591. element.css( "paddingBottom" ),
  9592. element.css( "paddingLeft" )
  9593. ];
  9594. for ( ; i < 4; i++ ) {
  9595. widths[ i ] = ( parseFloat( borders[ i ] ) || 0 );
  9596. widths[ i ] += ( parseFloat( paddings[ i ] ) || 0 );
  9597. }
  9598. return {
  9599. height: widths[ 0 ] + widths[ 2 ],
  9600. width: widths[ 1 ] + widths[ 3 ]
  9601. };
  9602. },
  9603. _proportionallyResize: function() {
  9604. if ( !this._proportionallyResizeElements.length ) {
  9605. return;
  9606. }
  9607. var prel,
  9608. i = 0,
  9609. element = this.helper || this.element;
  9610. for ( ; i < this._proportionallyResizeElements.length; i++ ) {
  9611. prel = this._proportionallyResizeElements[ i ];
  9612. // TODO: Seems like a bug to cache this.outerDimensions
  9613. // considering that we are in a loop.
  9614. if ( !this.outerDimensions ) {
  9615. this.outerDimensions = this._getPaddingPlusBorderDimensions( prel );
  9616. }
  9617. prel.css( {
  9618. height: ( element.height() - this.outerDimensions.height ) || 0,
  9619. width: ( element.width() - this.outerDimensions.width ) || 0
  9620. } );
  9621. }
  9622. },
  9623. _renderProxy: function() {
  9624. var el = this.element, o = this.options;
  9625. this.elementOffset = el.offset();
  9626. if ( this._helper ) {
  9627. this.helper = this.helper || $( "<div style='overflow:hidden;'></div>" );
  9628. this._addClass( this.helper, this._helper );
  9629. this.helper.css( {
  9630. width: this.element.outerWidth(),
  9631. height: this.element.outerHeight(),
  9632. position: "absolute",
  9633. left: this.elementOffset.left + "px",
  9634. top: this.elementOffset.top + "px",
  9635. zIndex: ++o.zIndex //TODO: Don't modify option
  9636. } );
  9637. this.helper
  9638. .appendTo( "body" )
  9639. .disableSelection();
  9640. } else {
  9641. this.helper = this.element;
  9642. }
  9643. },
  9644. _change: {
  9645. e: function( event, dx ) {
  9646. return { width: this.originalSize.width + dx };
  9647. },
  9648. w: function( event, dx ) {
  9649. var cs = this.originalSize, sp = this.originalPosition;
  9650. return { left: sp.left + dx, width: cs.width - dx };
  9651. },
  9652. n: function( event, dx, dy ) {
  9653. var cs = this.originalSize, sp = this.originalPosition;
  9654. return { top: sp.top + dy, height: cs.height - dy };
  9655. },
  9656. s: function( event, dx, dy ) {
  9657. return { height: this.originalSize.height + dy };
  9658. },
  9659. se: function( event, dx, dy ) {
  9660. return $.extend( this._change.s.apply( this, arguments ),
  9661. this._change.e.apply( this, [ event, dx, dy ] ) );
  9662. },
  9663. sw: function( event, dx, dy ) {
  9664. return $.extend( this._change.s.apply( this, arguments ),
  9665. this._change.w.apply( this, [ event, dx, dy ] ) );
  9666. },
  9667. ne: function( event, dx, dy ) {
  9668. return $.extend( this._change.n.apply( this, arguments ),
  9669. this._change.e.apply( this, [ event, dx, dy ] ) );
  9670. },
  9671. nw: function( event, dx, dy ) {
  9672. return $.extend( this._change.n.apply( this, arguments ),
  9673. this._change.w.apply( this, [ event, dx, dy ] ) );
  9674. }
  9675. },
  9676. _propagate: function( n, event ) {
  9677. $.ui.plugin.call( this, n, [ event, this.ui() ] );
  9678. ( n !== "resize" && this._trigger( n, event, this.ui() ) );
  9679. },
  9680. plugins: {},
  9681. ui: function() {
  9682. return {
  9683. originalElement: this.originalElement,
  9684. element: this.element,
  9685. helper: this.helper,
  9686. position: this.position,
  9687. size: this.size,
  9688. originalSize: this.originalSize,
  9689. originalPosition: this.originalPosition
  9690. };
  9691. }
  9692. } );
  9693. /*
  9694. * Resizable Extensions
  9695. */
  9696. $.ui.plugin.add( "resizable", "animate", {
  9697. stop: function( event ) {
  9698. var that = $( this ).resizable( "instance" ),
  9699. o = that.options,
  9700. pr = that._proportionallyResizeElements,
  9701. ista = pr.length && ( /textarea/i ).test( pr[ 0 ].nodeName ),
  9702. soffseth = ista && that._hasScroll( pr[ 0 ], "left" ) ? 0 : that.sizeDiff.height,
  9703. soffsetw = ista ? 0 : that.sizeDiff.width,
  9704. style = {
  9705. width: ( that.size.width - soffsetw ),
  9706. height: ( that.size.height - soffseth )
  9707. },
  9708. left = ( parseFloat( that.element.css( "left" ) ) +
  9709. ( that.position.left - that.originalPosition.left ) ) || null,
  9710. top = ( parseFloat( that.element.css( "top" ) ) +
  9711. ( that.position.top - that.originalPosition.top ) ) || null;
  9712. that.element.animate(
  9713. $.extend( style, top && left ? { top: top, left: left } : {} ), {
  9714. duration: o.animateDuration,
  9715. easing: o.animateEasing,
  9716. step: function() {
  9717. var data = {
  9718. width: parseFloat( that.element.css( "width" ) ),
  9719. height: parseFloat( that.element.css( "height" ) ),
  9720. top: parseFloat( that.element.css( "top" ) ),
  9721. left: parseFloat( that.element.css( "left" ) )
  9722. };
  9723. if ( pr && pr.length ) {
  9724. $( pr[ 0 ] ).css( { width: data.width, height: data.height } );
  9725. }
  9726. // Propagating resize, and updating values for each animation step
  9727. that._updateCache( data );
  9728. that._propagate( "resize", event );
  9729. }
  9730. }
  9731. );
  9732. }
  9733. } );
  9734. $.ui.plugin.add( "resizable", "containment", {
  9735. start: function() {
  9736. var element, p, co, ch, cw, width, height,
  9737. that = $( this ).resizable( "instance" ),
  9738. o = that.options,
  9739. el = that.element,
  9740. oc = o.containment,
  9741. ce = ( oc instanceof $ ) ?
  9742. oc.get( 0 ) :
  9743. ( /parent/.test( oc ) ) ? el.parent().get( 0 ) : oc;
  9744. if ( !ce ) {
  9745. return;
  9746. }
  9747. that.containerElement = $( ce );
  9748. if ( /document/.test( oc ) || oc === document ) {
  9749. that.containerOffset = {
  9750. left: 0,
  9751. top: 0
  9752. };
  9753. that.containerPosition = {
  9754. left: 0,
  9755. top: 0
  9756. };
  9757. that.parentData = {
  9758. element: $( document ),
  9759. left: 0,
  9760. top: 0,
  9761. width: $( document ).width(),
  9762. height: $( document ).height() || document.body.parentNode.scrollHeight
  9763. };
  9764. } else {
  9765. element = $( ce );
  9766. p = [];
  9767. $( [ "Top", "Right", "Left", "Bottom" ] ).each( function( i, name ) {
  9768. p[ i ] = that._num( element.css( "padding" + name ) );
  9769. } );
  9770. that.containerOffset = element.offset();
  9771. that.containerPosition = element.position();
  9772. that.containerSize = {
  9773. height: ( element.innerHeight() - p[ 3 ] ),
  9774. width: ( element.innerWidth() - p[ 1 ] )
  9775. };
  9776. co = that.containerOffset;
  9777. ch = that.containerSize.height;
  9778. cw = that.containerSize.width;
  9779. width = ( that._hasScroll ( ce, "left" ) ? ce.scrollWidth : cw );
  9780. height = ( that._hasScroll ( ce ) ? ce.scrollHeight : ch ) ;
  9781. that.parentData = {
  9782. element: ce,
  9783. left: co.left,
  9784. top: co.top,
  9785. width: width,
  9786. height: height
  9787. };
  9788. }
  9789. },
  9790. resize: function( event ) {
  9791. var woset, hoset, isParent, isOffsetRelative,
  9792. that = $( this ).resizable( "instance" ),
  9793. o = that.options,
  9794. co = that.containerOffset,
  9795. cp = that.position,
  9796. pRatio = that._aspectRatio || event.shiftKey,
  9797. cop = {
  9798. top: 0,
  9799. left: 0
  9800. },
  9801. ce = that.containerElement,
  9802. continueResize = true;
  9803. if ( ce[ 0 ] !== document && ( /static/ ).test( ce.css( "position" ) ) ) {
  9804. cop = co;
  9805. }
  9806. if ( cp.left < ( that._helper ? co.left : 0 ) ) {
  9807. that.size.width = that.size.width +
  9808. ( that._helper ?
  9809. ( that.position.left - co.left ) :
  9810. ( that.position.left - cop.left ) );
  9811. if ( pRatio ) {
  9812. that.size.height = that.size.width / that.aspectRatio;
  9813. continueResize = false;
  9814. }
  9815. that.position.left = o.helper ? co.left : 0;
  9816. }
  9817. if ( cp.top < ( that._helper ? co.top : 0 ) ) {
  9818. that.size.height = that.size.height +
  9819. ( that._helper ?
  9820. ( that.position.top - co.top ) :
  9821. that.position.top );
  9822. if ( pRatio ) {
  9823. that.size.width = that.size.height * that.aspectRatio;
  9824. continueResize = false;
  9825. }
  9826. that.position.top = that._helper ? co.top : 0;
  9827. }
  9828. isParent = that.containerElement.get( 0 ) === that.element.parent().get( 0 );
  9829. isOffsetRelative = /relative|absolute/.test( that.containerElement.css( "position" ) );
  9830. if ( isParent && isOffsetRelative ) {
  9831. that.offset.left = that.parentData.left + that.position.left;
  9832. that.offset.top = that.parentData.top + that.position.top;
  9833. } else {
  9834. that.offset.left = that.element.offset().left;
  9835. that.offset.top = that.element.offset().top;
  9836. }
  9837. woset = Math.abs( that.sizeDiff.width +
  9838. ( that._helper ?
  9839. that.offset.left - cop.left :
  9840. ( that.offset.left - co.left ) ) );
  9841. hoset = Math.abs( that.sizeDiff.height +
  9842. ( that._helper ?
  9843. that.offset.top - cop.top :
  9844. ( that.offset.top - co.top ) ) );
  9845. if ( woset + that.size.width >= that.parentData.width ) {
  9846. that.size.width = that.parentData.width - woset;
  9847. if ( pRatio ) {
  9848. that.size.height = that.size.width / that.aspectRatio;
  9849. continueResize = false;
  9850. }
  9851. }
  9852. if ( hoset + that.size.height >= that.parentData.height ) {
  9853. that.size.height = that.parentData.height - hoset;
  9854. if ( pRatio ) {
  9855. that.size.width = that.size.height * that.aspectRatio;
  9856. continueResize = false;
  9857. }
  9858. }
  9859. if ( !continueResize ) {
  9860. that.position.left = that.prevPosition.left;
  9861. that.position.top = that.prevPosition.top;
  9862. that.size.width = that.prevSize.width;
  9863. that.size.height = that.prevSize.height;
  9864. }
  9865. },
  9866. stop: function() {
  9867. var that = $( this ).resizable( "instance" ),
  9868. o = that.options,
  9869. co = that.containerOffset,
  9870. cop = that.containerPosition,
  9871. ce = that.containerElement,
  9872. helper = $( that.helper ),
  9873. ho = helper.offset(),
  9874. w = helper.outerWidth() - that.sizeDiff.width,
  9875. h = helper.outerHeight() - that.sizeDiff.height;
  9876. if ( that._helper && !o.animate && ( /relative/ ).test( ce.css( "position" ) ) ) {
  9877. $( this ).css( {
  9878. left: ho.left - cop.left - co.left,
  9879. width: w,
  9880. height: h
  9881. } );
  9882. }
  9883. if ( that._helper && !o.animate && ( /static/ ).test( ce.css( "position" ) ) ) {
  9884. $( this ).css( {
  9885. left: ho.left - cop.left - co.left,
  9886. width: w,
  9887. height: h
  9888. } );
  9889. }
  9890. }
  9891. } );
  9892. $.ui.plugin.add( "resizable", "alsoResize", {
  9893. start: function() {
  9894. var that = $( this ).resizable( "instance" ),
  9895. o = that.options;
  9896. $( o.alsoResize ).each( function() {
  9897. var el = $( this );
  9898. el.data( "ui-resizable-alsoresize", {
  9899. width: parseFloat( el.width() ), height: parseFloat( el.height() ),
  9900. left: parseFloat( el.css( "left" ) ), top: parseFloat( el.css( "top" ) )
  9901. } );
  9902. } );
  9903. },
  9904. resize: function( event, ui ) {
  9905. var that = $( this ).resizable( "instance" ),
  9906. o = that.options,
  9907. os = that.originalSize,
  9908. op = that.originalPosition,
  9909. delta = {
  9910. height: ( that.size.height - os.height ) || 0,
  9911. width: ( that.size.width - os.width ) || 0,
  9912. top: ( that.position.top - op.top ) || 0,
  9913. left: ( that.position.left - op.left ) || 0
  9914. };
  9915. $( o.alsoResize ).each( function() {
  9916. var el = $( this ), start = $( this ).data( "ui-resizable-alsoresize" ), style = {},
  9917. css = el.parents( ui.originalElement[ 0 ] ).length ?
  9918. [ "width", "height" ] :
  9919. [ "width", "height", "top", "left" ];
  9920. $.each( css, function( i, prop ) {
  9921. var sum = ( start[ prop ] || 0 ) + ( delta[ prop ] || 0 );
  9922. if ( sum && sum >= 0 ) {
  9923. style[ prop ] = sum || null;
  9924. }
  9925. } );
  9926. el.css( style );
  9927. } );
  9928. },
  9929. stop: function() {
  9930. $( this ).removeData( "ui-resizable-alsoresize" );
  9931. }
  9932. } );
  9933. $.ui.plugin.add( "resizable", "ghost", {
  9934. start: function() {
  9935. var that = $( this ).resizable( "instance" ), cs = that.size;
  9936. that.ghost = that.originalElement.clone();
  9937. that.ghost.css( {
  9938. opacity: 0.25,
  9939. display: "block",
  9940. position: "relative",
  9941. height: cs.height,
  9942. width: cs.width,
  9943. margin: 0,
  9944. left: 0,
  9945. top: 0
  9946. } );
  9947. that._addClass( that.ghost, "ui-resizable-ghost" );
  9948. // DEPRECATED
  9949. // TODO: remove after 1.12
  9950. if ( $.uiBackCompat !== false && typeof that.options.ghost === "string" ) {
  9951. // Ghost option
  9952. that.ghost.addClass( this.options.ghost );
  9953. }
  9954. that.ghost.appendTo( that.helper );
  9955. },
  9956. resize: function() {
  9957. var that = $( this ).resizable( "instance" );
  9958. if ( that.ghost ) {
  9959. that.ghost.css( {
  9960. position: "relative",
  9961. height: that.size.height,
  9962. width: that.size.width
  9963. } );
  9964. }
  9965. },
  9966. stop: function() {
  9967. var that = $( this ).resizable( "instance" );
  9968. if ( that.ghost && that.helper ) {
  9969. that.helper.get( 0 ).removeChild( that.ghost.get( 0 ) );
  9970. }
  9971. }
  9972. } );
  9973. $.ui.plugin.add( "resizable", "grid", {
  9974. resize: function() {
  9975. var outerDimensions,
  9976. that = $( this ).resizable( "instance" ),
  9977. o = that.options,
  9978. cs = that.size,
  9979. os = that.originalSize,
  9980. op = that.originalPosition,
  9981. a = that.axis,
  9982. grid = typeof o.grid === "number" ? [ o.grid, o.grid ] : o.grid,
  9983. gridX = ( grid[ 0 ] || 1 ),
  9984. gridY = ( grid[ 1 ] || 1 ),
  9985. ox = Math.round( ( cs.width - os.width ) / gridX ) * gridX,
  9986. oy = Math.round( ( cs.height - os.height ) / gridY ) * gridY,
  9987. newWidth = os.width + ox,
  9988. newHeight = os.height + oy,
  9989. isMaxWidth = o.maxWidth && ( o.maxWidth < newWidth ),
  9990. isMaxHeight = o.maxHeight && ( o.maxHeight < newHeight ),
  9991. isMinWidth = o.minWidth && ( o.minWidth > newWidth ),
  9992. isMinHeight = o.minHeight && ( o.minHeight > newHeight );
  9993. o.grid = grid;
  9994. if ( isMinWidth ) {
  9995. newWidth += gridX;
  9996. }
  9997. if ( isMinHeight ) {
  9998. newHeight += gridY;
  9999. }
  10000. if ( isMaxWidth ) {
  10001. newWidth -= gridX;
  10002. }
  10003. if ( isMaxHeight ) {
  10004. newHeight -= gridY;
  10005. }
  10006. if ( /^(se|s|e)$/.test( a ) ) {
  10007. that.size.width = newWidth;
  10008. that.size.height = newHeight;
  10009. } else if ( /^(ne)$/.test( a ) ) {
  10010. that.size.width = newWidth;
  10011. that.size.height = newHeight;
  10012. that.position.top = op.top - oy;
  10013. } else if ( /^(sw)$/.test( a ) ) {
  10014. that.size.width = newWidth;
  10015. that.size.height = newHeight;
  10016. that.position.left = op.left - ox;
  10017. } else {
  10018. if ( newHeight - gridY <= 0 || newWidth - gridX <= 0 ) {
  10019. outerDimensions = that._getPaddingPlusBorderDimensions( this );
  10020. }
  10021. if ( newHeight - gridY > 0 ) {
  10022. that.size.height = newHeight;
  10023. that.position.top = op.top - oy;
  10024. } else {
  10025. newHeight = gridY - outerDimensions.height;
  10026. that.size.height = newHeight;
  10027. that.position.top = op.top + os.height - newHeight;
  10028. }
  10029. if ( newWidth - gridX > 0 ) {
  10030. that.size.width = newWidth;
  10031. that.position.left = op.left - ox;
  10032. } else {
  10033. newWidth = gridX - outerDimensions.width;
  10034. that.size.width = newWidth;
  10035. that.position.left = op.left + os.width - newWidth;
  10036. }
  10037. }
  10038. }
  10039. } );
  10040. var widgetsResizable = $.ui.resizable;
  10041. /*!
  10042. * jQuery UI Dialog 1.12.0
  10043. * http://jqueryui.com
  10044. *
  10045. * Copyright jQuery Foundation and other contributors
  10046. * Released under the MIT license.
  10047. * http://jquery.org/license
  10048. */
  10049. //>>label: Dialog
  10050. //>>group: Widgets
  10051. //>>description: Displays customizable dialog windows.
  10052. //>>docs: http://api.jqueryui.com/dialog/
  10053. //>>demos: http://jqueryui.com/dialog/
  10054. //>>css.structure: ../../themes/base/core.css
  10055. //>>css.structure: ../../themes/base/dialog.css
  10056. //>>css.theme: ../../themes/base/theme.css
  10057. $.widget( "ui.dialog", {
  10058. version: "1.12.0",
  10059. options: {
  10060. appendTo: "body",
  10061. autoOpen: true,
  10062. buttons: [],
  10063. classes: {
  10064. "ui-dialog": "ui-corner-all",
  10065. "ui-dialog-titlebar": "ui-corner-all"
  10066. },
  10067. closeOnEscape: true,
  10068. closeText: "Close",
  10069. draggable: true,
  10070. hide: null,
  10071. height: "auto",
  10072. maxHeight: null,
  10073. maxWidth: null,
  10074. minHeight: 150,
  10075. minWidth: 150,
  10076. modal: false,
  10077. position: {
  10078. my: "center",
  10079. at: "center",
  10080. of: window,
  10081. collision: "fit",
  10082. // Ensure the titlebar is always visible
  10083. using: function( pos ) {
  10084. var topOffset = $( this ).css( pos ).offset().top;
  10085. if ( topOffset < 0 ) {
  10086. $( this ).css( "top", pos.top - topOffset );
  10087. }
  10088. }
  10089. },
  10090. resizable: true,
  10091. show: null,
  10092. title: null,
  10093. width: 300,
  10094. // Callbacks
  10095. beforeClose: null,
  10096. close: null,
  10097. drag: null,
  10098. dragStart: null,
  10099. dragStop: null,
  10100. focus: null,
  10101. open: null,
  10102. resize: null,
  10103. resizeStart: null,
  10104. resizeStop: null
  10105. },
  10106. sizeRelatedOptions: {
  10107. buttons: true,
  10108. height: true,
  10109. maxHeight: true,
  10110. maxWidth: true,
  10111. minHeight: true,
  10112. minWidth: true,
  10113. width: true
  10114. },
  10115. resizableRelatedOptions: {
  10116. maxHeight: true,
  10117. maxWidth: true,
  10118. minHeight: true,
  10119. minWidth: true
  10120. },
  10121. _create: function() {
  10122. this.originalCss = {
  10123. display: this.element[ 0 ].style.display,
  10124. width: this.element[ 0 ].style.width,
  10125. minHeight: this.element[ 0 ].style.minHeight,
  10126. maxHeight: this.element[ 0 ].style.maxHeight,
  10127. height: this.element[ 0 ].style.height
  10128. };
  10129. this.originalPosition = {
  10130. parent: this.element.parent(),
  10131. index: this.element.parent().children().index( this.element )
  10132. };
  10133. this.originalTitle = this.element.attr( "title" );
  10134. if ( this.options.title == null && this.originalTitle != null ) {
  10135. this.options.title = this.originalTitle;
  10136. }
  10137. // Dialogs can't be disabled
  10138. if ( this.options.disabled ) {
  10139. this.options.disabled = false;
  10140. }
  10141. this._createWrapper();
  10142. this.element
  10143. .show()
  10144. .removeAttr( "title" )
  10145. .appendTo( this.uiDialog );
  10146. this._addClass( "ui-dialog-content", "ui-widget-content" );
  10147. this._createTitlebar();
  10148. this._createButtonPane();
  10149. if ( this.options.draggable && $.fn.draggable ) {
  10150. this._makeDraggable();
  10151. }
  10152. if ( this.options.resizable && $.fn.resizable ) {
  10153. this._makeResizable();
  10154. }
  10155. this._isOpen = false;
  10156. this._trackFocus();
  10157. },
  10158. _init: function() {
  10159. if ( this.options.autoOpen ) {
  10160. this.open();
  10161. }
  10162. },
  10163. _appendTo: function() {
  10164. var element = this.options.appendTo;
  10165. if ( element && ( element.jquery || element.nodeType ) ) {
  10166. return $( element );
  10167. }
  10168. return this.document.find( element || "body" ).eq( 0 );
  10169. },
  10170. _destroy: function() {
  10171. var next,
  10172. originalPosition = this.originalPosition;
  10173. this._untrackInstance();
  10174. this._destroyOverlay();
  10175. this.element
  10176. .removeUniqueId()
  10177. .css( this.originalCss )
  10178. // Without detaching first, the following becomes really slow
  10179. .detach();
  10180. this.uiDialog.remove();
  10181. if ( this.originalTitle ) {
  10182. this.element.attr( "title", this.originalTitle );
  10183. }
  10184. next = originalPosition.parent.children().eq( originalPosition.index );
  10185. // Don't try to place the dialog next to itself (#8613)
  10186. if ( next.length && next[ 0 ] !== this.element[ 0 ] ) {
  10187. next.before( this.element );
  10188. } else {
  10189. originalPosition.parent.append( this.element );
  10190. }
  10191. },
  10192. widget: function() {
  10193. return this.uiDialog;
  10194. },
  10195. disable: $.noop,
  10196. enable: $.noop,
  10197. close: function( event ) {
  10198. var that = this;
  10199. if ( !this._isOpen || this._trigger( "beforeClose", event ) === false ) {
  10200. return;
  10201. }
  10202. this._isOpen = false;
  10203. this._focusedElement = null;
  10204. this._destroyOverlay();
  10205. this._untrackInstance();
  10206. if ( !this.opener.filter( ":focusable" ).trigger( "focus" ).length ) {
  10207. // Hiding a focused element doesn't trigger blur in WebKit
  10208. // so in case we have nothing to focus on, explicitly blur the active element
  10209. // https://bugs.webkit.org/show_bug.cgi?id=47182
  10210. $.ui.safeBlur( $.ui.safeActiveElement( this.document[ 0 ] ) );
  10211. }
  10212. this._hide( this.uiDialog, this.options.hide, function() {
  10213. that._trigger( "close", event );
  10214. } );
  10215. },
  10216. isOpen: function() {
  10217. return this._isOpen;
  10218. },
  10219. moveToTop: function() {
  10220. this._moveToTop();
  10221. },
  10222. _moveToTop: function( event, silent ) {
  10223. var moved = false,
  10224. zIndices = this.uiDialog.siblings( ".ui-front:visible" ).map( function() {
  10225. return +$( this ).css( "z-index" );
  10226. } ).get(),
  10227. zIndexMax = Math.max.apply( null, zIndices );
  10228. if ( zIndexMax >= +this.uiDialog.css( "z-index" ) ) {
  10229. this.uiDialog.css( "z-index", zIndexMax + 1 );
  10230. moved = true;
  10231. }
  10232. if ( moved && !silent ) {
  10233. this._trigger( "focus", event );
  10234. }
  10235. return moved;
  10236. },
  10237. open: function() {
  10238. var that = this;
  10239. if ( this._isOpen ) {
  10240. if ( this._moveToTop() ) {
  10241. this._focusTabbable();
  10242. }
  10243. return;
  10244. }
  10245. this._isOpen = true;
  10246. this.opener = $( $.ui.safeActiveElement( this.document[ 0 ] ) );
  10247. this._size();
  10248. this._position();
  10249. this._createOverlay();
  10250. this._moveToTop( null, true );
  10251. // Ensure the overlay is moved to the top with the dialog, but only when
  10252. // opening. The overlay shouldn't move after the dialog is open so that
  10253. // modeless dialogs opened after the modal dialog stack properly.
  10254. if ( this.overlay ) {
  10255. this.overlay.css( "z-index", this.uiDialog.css( "z-index" ) - 1 );
  10256. }
  10257. this._show( this.uiDialog, this.options.show, function() {
  10258. that._focusTabbable();
  10259. that._trigger( "focus" );
  10260. } );
  10261. // Track the dialog immediately upon openening in case a focus event
  10262. // somehow occurs outside of the dialog before an element inside the
  10263. // dialog is focused (#10152)
  10264. this._makeFocusTarget();
  10265. this._trigger( "open" );
  10266. },
  10267. _focusTabbable: function() {
  10268. // Set focus to the first match:
  10269. // 1. An element that was focused previously
  10270. // 2. First element inside the dialog matching [autofocus]
  10271. // 3. Tabbable element inside the content element
  10272. // 4. Tabbable element inside the buttonpane
  10273. // 5. The close button
  10274. // 6. The dialog itself
  10275. var hasFocus = this._focusedElement;
  10276. if ( !hasFocus ) {
  10277. hasFocus = this.element.find( "[autofocus]" );
  10278. }
  10279. if ( !hasFocus.length ) {
  10280. hasFocus = this.element.find( ":tabbable" );
  10281. }
  10282. if ( !hasFocus.length ) {
  10283. hasFocus = this.uiDialogButtonPane.find( ":tabbable" );
  10284. }
  10285. if ( !hasFocus.length ) {
  10286. hasFocus = this.uiDialogTitlebarClose.filter( ":tabbable" );
  10287. }
  10288. if ( !hasFocus.length ) {
  10289. hasFocus = this.uiDialog;
  10290. }
  10291. hasFocus.eq( 0 ).trigger( "focus" );
  10292. },
  10293. _keepFocus: function( event ) {
  10294. function checkFocus() {
  10295. var activeElement = $.ui.safeActiveElement( this.document[ 0 ] ),
  10296. isActive = this.uiDialog[ 0 ] === activeElement ||
  10297. $.contains( this.uiDialog[ 0 ], activeElement );
  10298. if ( !isActive ) {
  10299. this._focusTabbable();
  10300. }
  10301. }
  10302. event.preventDefault();
  10303. checkFocus.call( this );
  10304. // support: IE
  10305. // IE <= 8 doesn't prevent moving focus even with event.preventDefault()
  10306. // so we check again later
  10307. this._delay( checkFocus );
  10308. },
  10309. _createWrapper: function() {
  10310. this.uiDialog = $( "<div>" )
  10311. .hide()
  10312. .attr( {
  10313. // Setting tabIndex makes the div focusable
  10314. tabIndex: -1,
  10315. role: "dialog"
  10316. } )
  10317. .appendTo( this._appendTo() );
  10318. this._addClass( this.uiDialog, "ui-dialog", "ui-widget ui-widget-content ui-front" );
  10319. this._on( this.uiDialog, {
  10320. keydown: function( event ) {
  10321. if ( this.options.closeOnEscape && !event.isDefaultPrevented() && event.keyCode &&
  10322. event.keyCode === $.ui.keyCode.ESCAPE ) {
  10323. event.preventDefault();
  10324. this.close( event );
  10325. return;
  10326. }
  10327. // Prevent tabbing out of dialogs
  10328. if ( event.keyCode !== $.ui.keyCode.TAB || event.isDefaultPrevented() ) {
  10329. return;
  10330. }
  10331. var tabbables = this.uiDialog.find( ":tabbable" ),
  10332. first = tabbables.filter( ":first" ),
  10333. last = tabbables.filter( ":last" );
  10334. if ( ( event.target === last[ 0 ] || event.target === this.uiDialog[ 0 ] ) &&
  10335. !event.shiftKey ) {
  10336. this._delay( function() {
  10337. first.trigger( "focus" );
  10338. } );
  10339. event.preventDefault();
  10340. } else if ( ( event.target === first[ 0 ] ||
  10341. event.target === this.uiDialog[ 0 ] ) && event.shiftKey ) {
  10342. this._delay( function() {
  10343. last.trigger( "focus" );
  10344. } );
  10345. event.preventDefault();
  10346. }
  10347. },
  10348. mousedown: function( event ) {
  10349. if ( this._moveToTop( event ) ) {
  10350. this._focusTabbable();
  10351. }
  10352. }
  10353. } );
  10354. // We assume that any existing aria-describedby attribute means
  10355. // that the dialog content is marked up properly
  10356. // otherwise we brute force the content as the description
  10357. if ( !this.element.find( "[aria-describedby]" ).length ) {
  10358. this.uiDialog.attr( {
  10359. "aria-describedby": this.element.uniqueId().attr( "id" )
  10360. } );
  10361. }
  10362. },
  10363. _createTitlebar: function() {
  10364. var uiDialogTitle;
  10365. this.uiDialogTitlebar = $( "<div>" );
  10366. this._addClass( this.uiDialogTitlebar,
  10367. "ui-dialog-titlebar", "ui-widget-header ui-helper-clearfix" );
  10368. this._on( this.uiDialogTitlebar, {
  10369. mousedown: function( event ) {
  10370. // Don't prevent click on close button (#8838)
  10371. // Focusing a dialog that is partially scrolled out of view
  10372. // causes the browser to scroll it into view, preventing the click event
  10373. if ( !$( event.target ).closest( ".ui-dialog-titlebar-close" ) ) {
  10374. // Dialog isn't getting focus when dragging (#8063)
  10375. this.uiDialog.trigger( "focus" );
  10376. }
  10377. }
  10378. } );
  10379. // Support: IE
  10380. // Use type="button" to prevent enter keypresses in textboxes from closing the
  10381. // dialog in IE (#9312)
  10382. this.uiDialogTitlebarClose = $( "<button type='button'></button>" )
  10383. .button( {
  10384. label: $( "<a>" ).text( this.options.closeText ).html(),
  10385. icon: "ui-icon-closethick",
  10386. showLabel: false
  10387. } )
  10388. .appendTo( this.uiDialogTitlebar );
  10389. this._addClass( this.uiDialogTitlebarClose, "ui-dialog-titlebar-close" );
  10390. this._on( this.uiDialogTitlebarClose, {
  10391. click: function( event ) {
  10392. event.preventDefault();
  10393. this.close( event );
  10394. }
  10395. } );
  10396. uiDialogTitle = $( "<span>" ).uniqueId().prependTo( this.uiDialogTitlebar );
  10397. this._addClass( uiDialogTitle, "ui-dialog-title" );
  10398. this._title( uiDialogTitle );
  10399. this.uiDialogTitlebar.prependTo( this.uiDialog );
  10400. this.uiDialog.attr( {
  10401. "aria-labelledby": uiDialogTitle.attr( "id" )
  10402. } );
  10403. },
  10404. _title: function( title ) {
  10405. if ( this.options.title ) {
  10406. title.text( this.options.title );
  10407. } else {
  10408. title.html( "&#160;" );
  10409. }
  10410. },
  10411. _createButtonPane: function() {
  10412. this.uiDialogButtonPane = $( "<div>" );
  10413. this._addClass( this.uiDialogButtonPane, "ui-dialog-buttonpane",
  10414. "ui-widget-content ui-helper-clearfix" );
  10415. this.uiButtonSet = $( "<div>" )
  10416. .appendTo( this.uiDialogButtonPane );
  10417. this._addClass( this.uiButtonSet, "ui-dialog-buttonset" );
  10418. this._createButtons();
  10419. },
  10420. _createButtons: function() {
  10421. var that = this,
  10422. buttons = this.options.buttons;
  10423. // If we already have a button pane, remove it
  10424. this.uiDialogButtonPane.remove();
  10425. this.uiButtonSet.empty();
  10426. if ( $.isEmptyObject( buttons ) || ( $.isArray( buttons ) && !buttons.length ) ) {
  10427. this._removeClass( this.uiDialog, "ui-dialog-buttons" );
  10428. return;
  10429. }
  10430. $.each( buttons, function( name, props ) {
  10431. var click, buttonOptions;
  10432. props = $.isFunction( props ) ?
  10433. { click: props, text: name } :
  10434. props;
  10435. // Default to a non-submitting button
  10436. props = $.extend( { type: "button" }, props );
  10437. // Change the context for the click callback to be the main element
  10438. click = props.click;
  10439. buttonOptions = {
  10440. icon: props.icon,
  10441. iconPosition: props.iconPosition,
  10442. showLabel: props.showLabel
  10443. };
  10444. delete props.click;
  10445. delete props.icon;
  10446. delete props.iconPosition;
  10447. delete props.showLabel;
  10448. $( "<button></button>", props )
  10449. .button( buttonOptions )
  10450. .appendTo( that.uiButtonSet )
  10451. .on( "click", function() {
  10452. click.apply( that.element[ 0 ], arguments );
  10453. } );
  10454. } );
  10455. this._addClass( this.uiDialog, "ui-dialog-buttons" );
  10456. this.uiDialogButtonPane.appendTo( this.uiDialog );
  10457. },
  10458. _makeDraggable: function() {
  10459. var that = this,
  10460. options = this.options;
  10461. function filteredUi( ui ) {
  10462. return {
  10463. position: ui.position,
  10464. offset: ui.offset
  10465. };
  10466. }
  10467. this.uiDialog.draggable( {
  10468. cancel: ".ui-dialog-content, .ui-dialog-titlebar-close",
  10469. handle: ".ui-dialog-titlebar",
  10470. containment: "document",
  10471. start: function( event, ui ) {
  10472. that._addClass( $( this ), "ui-dialog-dragging" );
  10473. that._blockFrames();
  10474. that._trigger( "dragStart", event, filteredUi( ui ) );
  10475. },
  10476. drag: function( event, ui ) {
  10477. that._trigger( "drag", event, filteredUi( ui ) );
  10478. },
  10479. stop: function( event, ui ) {
  10480. var left = ui.offset.left - that.document.scrollLeft(),
  10481. top = ui.offset.top - that.document.scrollTop();
  10482. options.position = {
  10483. my: "left top",
  10484. at: "left" + ( left >= 0 ? "+" : "" ) + left + " " +
  10485. "top" + ( top >= 0 ? "+" : "" ) + top,
  10486. of: that.window
  10487. };
  10488. that._removeClass( $( this ), "ui-dialog-dragging" );
  10489. that._unblockFrames();
  10490. that._trigger( "dragStop", event, filteredUi( ui ) );
  10491. }
  10492. } );
  10493. },
  10494. _makeResizable: function() {
  10495. var that = this,
  10496. options = this.options,
  10497. handles = options.resizable,
  10498. // .ui-resizable has position: relative defined in the stylesheet
  10499. // but dialogs have to use absolute or fixed positioning
  10500. position = this.uiDialog.css( "position" ),
  10501. resizeHandles = typeof handles === "string" ?
  10502. handles :
  10503. "n,e,s,w,se,sw,ne,nw";
  10504. function filteredUi( ui ) {
  10505. return {
  10506. originalPosition: ui.originalPosition,
  10507. originalSize: ui.originalSize,
  10508. position: ui.position,
  10509. size: ui.size
  10510. };
  10511. }
  10512. this.uiDialog.resizable( {
  10513. cancel: ".ui-dialog-content",
  10514. containment: "document",
  10515. alsoResize: this.element,
  10516. maxWidth: options.maxWidth,
  10517. maxHeight: options.maxHeight,
  10518. minWidth: options.minWidth,
  10519. minHeight: this._minHeight(),
  10520. handles: resizeHandles,
  10521. start: function( event, ui ) {
  10522. that._addClass( $( this ), "ui-dialog-resizing" );
  10523. that._blockFrames();
  10524. that._trigger( "resizeStart", event, filteredUi( ui ) );
  10525. },
  10526. resize: function( event, ui ) {
  10527. that._trigger( "resize", event, filteredUi( ui ) );
  10528. },
  10529. stop: function( event, ui ) {
  10530. var offset = that.uiDialog.offset(),
  10531. left = offset.left - that.document.scrollLeft(),
  10532. top = offset.top - that.document.scrollTop();
  10533. options.height = that.uiDialog.height();
  10534. options.width = that.uiDialog.width();
  10535. options.position = {
  10536. my: "left top",
  10537. at: "left" + ( left >= 0 ? "+" : "" ) + left + " " +
  10538. "top" + ( top >= 0 ? "+" : "" ) + top,
  10539. of: that.window
  10540. };
  10541. that._removeClass( $( this ), "ui-dialog-resizing" );
  10542. that._unblockFrames();
  10543. that._trigger( "resizeStop", event, filteredUi( ui ) );
  10544. }
  10545. } )
  10546. .css( "position", position );
  10547. },
  10548. _trackFocus: function() {
  10549. this._on( this.widget(), {
  10550. focusin: function( event ) {
  10551. this._makeFocusTarget();
  10552. this._focusedElement = $( event.target );
  10553. }
  10554. } );
  10555. },
  10556. _makeFocusTarget: function() {
  10557. this._untrackInstance();
  10558. this._trackingInstances().unshift( this );
  10559. },
  10560. _untrackInstance: function() {
  10561. var instances = this._trackingInstances(),
  10562. exists = $.inArray( this, instances );
  10563. if ( exists !== -1 ) {
  10564. instances.splice( exists, 1 );
  10565. }
  10566. },
  10567. _trackingInstances: function() {
  10568. var instances = this.document.data( "ui-dialog-instances" );
  10569. if ( !instances ) {
  10570. instances = [];
  10571. this.document.data( "ui-dialog-instances", instances );
  10572. }
  10573. return instances;
  10574. },
  10575. _minHeight: function() {
  10576. var options = this.options;
  10577. return options.height === "auto" ?
  10578. options.minHeight :
  10579. Math.min( options.minHeight, options.height );
  10580. },
  10581. _position: function() {
  10582. // Need to show the dialog to get the actual offset in the position plugin
  10583. var isVisible = this.uiDialog.is( ":visible" );
  10584. if ( !isVisible ) {
  10585. this.uiDialog.show();
  10586. }
  10587. this.uiDialog.position( this.options.position );
  10588. if ( !isVisible ) {
  10589. this.uiDialog.hide();
  10590. }
  10591. },
  10592. _setOptions: function( options ) {
  10593. var that = this,
  10594. resize = false,
  10595. resizableOptions = {};
  10596. $.each( options, function( key, value ) {
  10597. that._setOption( key, value );
  10598. if ( key in that.sizeRelatedOptions ) {
  10599. resize = true;
  10600. }
  10601. if ( key in that.resizableRelatedOptions ) {
  10602. resizableOptions[ key ] = value;
  10603. }
  10604. } );
  10605. if ( resize ) {
  10606. this._size();
  10607. this._position();
  10608. }
  10609. if ( this.uiDialog.is( ":data(ui-resizable)" ) ) {
  10610. this.uiDialog.resizable( "option", resizableOptions );
  10611. }
  10612. },
  10613. _setOption: function( key, value ) {
  10614. var isDraggable, isResizable,
  10615. uiDialog = this.uiDialog;
  10616. if ( key === "disabled" ) {
  10617. return;
  10618. }
  10619. this._super( key, value );
  10620. if ( key === "appendTo" ) {
  10621. this.uiDialog.appendTo( this._appendTo() );
  10622. }
  10623. if ( key === "buttons" ) {
  10624. this._createButtons();
  10625. }
  10626. if ( key === "closeText" ) {
  10627. this.uiDialogTitlebarClose.button( {
  10628. // Ensure that we always pass a string
  10629. label: $( "<a>" ).text( "" + this.options.closeText ).html()
  10630. } );
  10631. }
  10632. if ( key === "draggable" ) {
  10633. isDraggable = uiDialog.is( ":data(ui-draggable)" );
  10634. if ( isDraggable && !value ) {
  10635. uiDialog.draggable( "destroy" );
  10636. }
  10637. if ( !isDraggable && value ) {
  10638. this._makeDraggable();
  10639. }
  10640. }
  10641. if ( key === "position" ) {
  10642. this._position();
  10643. }
  10644. if ( key === "resizable" ) {
  10645. // currently resizable, becoming non-resizable
  10646. isResizable = uiDialog.is( ":data(ui-resizable)" );
  10647. if ( isResizable && !value ) {
  10648. uiDialog.resizable( "destroy" );
  10649. }
  10650. // Currently resizable, changing handles
  10651. if ( isResizable && typeof value === "string" ) {
  10652. uiDialog.resizable( "option", "handles", value );
  10653. }
  10654. // Currently non-resizable, becoming resizable
  10655. if ( !isResizable && value !== false ) {
  10656. this._makeResizable();
  10657. }
  10658. }
  10659. if ( key === "title" ) {
  10660. this._title( this.uiDialogTitlebar.find( ".ui-dialog-title" ) );
  10661. }
  10662. },
  10663. _size: function() {
  10664. // If the user has resized the dialog, the .ui-dialog and .ui-dialog-content
  10665. // divs will both have width and height set, so we need to reset them
  10666. var nonContentHeight, minContentHeight, maxContentHeight,
  10667. options = this.options;
  10668. // Reset content sizing
  10669. this.element.show().css( {
  10670. width: "auto",
  10671. minHeight: 0,
  10672. maxHeight: "none",
  10673. height: 0
  10674. } );
  10675. if ( options.minWidth > options.width ) {
  10676. options.width = options.minWidth;
  10677. }
  10678. // Reset wrapper sizing
  10679. // determine the height of all the non-content elements
  10680. nonContentHeight = this.uiDialog.css( {
  10681. height: "auto",
  10682. width: options.width
  10683. } )
  10684. .outerHeight();
  10685. minContentHeight = Math.max( 0, options.minHeight - nonContentHeight );
  10686. maxContentHeight = typeof options.maxHeight === "number" ?
  10687. Math.max( 0, options.maxHeight - nonContentHeight ) :
  10688. "none";
  10689. if ( options.height === "auto" ) {
  10690. this.element.css( {
  10691. minHeight: minContentHeight,
  10692. maxHeight: maxContentHeight,
  10693. height: "auto"
  10694. } );
  10695. } else {
  10696. this.element.height( Math.max( 0, options.height - nonContentHeight ) );
  10697. }
  10698. if ( this.uiDialog.is( ":data(ui-resizable)" ) ) {
  10699. this.uiDialog.resizable( "option", "minHeight", this._minHeight() );
  10700. }
  10701. },
  10702. _blockFrames: function() {
  10703. this.iframeBlocks = this.document.find( "iframe" ).map( function() {
  10704. var iframe = $( this );
  10705. return $( "<div>" )
  10706. .css( {
  10707. position: "absolute",
  10708. width: iframe.outerWidth(),
  10709. height: iframe.outerHeight()
  10710. } )
  10711. .appendTo( iframe.parent() )
  10712. .offset( iframe.offset() )[ 0 ];
  10713. } );
  10714. },
  10715. _unblockFrames: function() {
  10716. if ( this.iframeBlocks ) {
  10717. this.iframeBlocks.remove();
  10718. delete this.iframeBlocks;
  10719. }
  10720. },
  10721. _allowInteraction: function( event ) {
  10722. if ( $( event.target ).closest( ".ui-dialog" ).length ) {
  10723. return true;
  10724. }
  10725. // TODO: Remove hack when datepicker implements
  10726. // the .ui-front logic (#8989)
  10727. return !!$( event.target ).closest( ".ui-datepicker" ).length;
  10728. },
  10729. _createOverlay: function() {
  10730. if ( !this.options.modal ) {
  10731. return;
  10732. }
  10733. // We use a delay in case the overlay is created from an
  10734. // event that we're going to be cancelling (#2804)
  10735. var isOpening = true;
  10736. this._delay( function() {
  10737. isOpening = false;
  10738. } );
  10739. if ( !this.document.data( "ui-dialog-overlays" ) ) {
  10740. // Prevent use of anchors and inputs
  10741. // Using _on() for an event handler shared across many instances is
  10742. // safe because the dialogs stack and must be closed in reverse order
  10743. this._on( this.document, {
  10744. focusin: function( event ) {
  10745. if ( isOpening ) {
  10746. return;
  10747. }
  10748. if ( !this._allowInteraction( event ) ) {
  10749. event.preventDefault();
  10750. this._trackingInstances()[ 0 ]._focusTabbable();
  10751. }
  10752. }
  10753. } );
  10754. }
  10755. this.overlay = $( "<div>" )
  10756. .appendTo( this._appendTo() );
  10757. this._addClass( this.overlay, null, "ui-widget-overlay ui-front" );
  10758. this._on( this.overlay, {
  10759. mousedown: "_keepFocus"
  10760. } );
  10761. this.document.data( "ui-dialog-overlays",
  10762. ( this.document.data( "ui-dialog-overlays" ) || 0 ) + 1 );
  10763. },
  10764. _destroyOverlay: function() {
  10765. if ( !this.options.modal ) {
  10766. return;
  10767. }
  10768. if ( this.overlay ) {
  10769. var overlays = this.document.data( "ui-dialog-overlays" ) - 1;
  10770. if ( !overlays ) {
  10771. this._off( this.document, "focusin" );
  10772. this.document.removeData( "ui-dialog-overlays" );
  10773. } else {
  10774. this.document.data( "ui-dialog-overlays", overlays );
  10775. }
  10776. this.overlay.remove();
  10777. this.overlay = null;
  10778. }
  10779. }
  10780. } );
  10781. // DEPRECATED
  10782. // TODO: switch return back to widget declaration at top of file when this is removed
  10783. if ( $.uiBackCompat !== false ) {
  10784. // Backcompat for dialogClass option
  10785. $.widget( "ui.dialog", $.ui.dialog, {
  10786. options: {
  10787. dialogClass: ""
  10788. },
  10789. _createWrapper: function() {
  10790. this._super();
  10791. this.uiDialog.addClass( this.options.dialogClass );
  10792. },
  10793. _setOption: function( key, value ) {
  10794. if ( key === "dialogClass" ) {
  10795. this.uiDialog
  10796. .removeClass( this.options.dialogClass )
  10797. .addClass( value );
  10798. }
  10799. this._superApply( arguments );
  10800. }
  10801. } );
  10802. }
  10803. var widgetsDialog = $.ui.dialog;
  10804. /*!
  10805. * jQuery UI Droppable 1.12.0
  10806. * http://jqueryui.com
  10807. *
  10808. * Copyright jQuery Foundation and other contributors
  10809. * Released under the MIT license.
  10810. * http://jquery.org/license
  10811. */
  10812. //>>label: Droppable
  10813. //>>group: Interactions
  10814. //>>description: Enables drop targets for draggable elements.
  10815. //>>docs: http://api.jqueryui.com/droppable/
  10816. //>>demos: http://jqueryui.com/droppable/
  10817. $.widget( "ui.droppable", {
  10818. version: "1.12.0",
  10819. widgetEventPrefix: "drop",
  10820. options: {
  10821. accept: "*",
  10822. addClasses: true,
  10823. greedy: false,
  10824. scope: "default",
  10825. tolerance: "intersect",
  10826. // Callbacks
  10827. activate: null,
  10828. deactivate: null,
  10829. drop: null,
  10830. out: null,
  10831. over: null
  10832. },
  10833. _create: function() {
  10834. var proportions,
  10835. o = this.options,
  10836. accept = o.accept;
  10837. this.isover = false;
  10838. this.isout = true;
  10839. this.accept = $.isFunction( accept ) ? accept : function( d ) {
  10840. return d.is( accept );
  10841. };
  10842. this.proportions = function( /* valueToWrite */ ) {
  10843. if ( arguments.length ) {
  10844. // Store the droppable's proportions
  10845. proportions = arguments[ 0 ];
  10846. } else {
  10847. // Retrieve or derive the droppable's proportions
  10848. return proportions ?
  10849. proportions :
  10850. proportions = {
  10851. width: this.element[ 0 ].offsetWidth,
  10852. height: this.element[ 0 ].offsetHeight
  10853. };
  10854. }
  10855. };
  10856. this._addToManager( o.scope );
  10857. o.addClasses && this._addClass( "ui-droppable" );
  10858. },
  10859. _addToManager: function( scope ) {
  10860. // Add the reference and positions to the manager
  10861. $.ui.ddmanager.droppables[ scope ] = $.ui.ddmanager.droppables[ scope ] || [];
  10862. $.ui.ddmanager.droppables[ scope ].push( this );
  10863. },
  10864. _splice: function( drop ) {
  10865. var i = 0;
  10866. for ( ; i < drop.length; i++ ) {
  10867. if ( drop[ i ] === this ) {
  10868. drop.splice( i, 1 );
  10869. }
  10870. }
  10871. },
  10872. _destroy: function() {
  10873. var drop = $.ui.ddmanager.droppables[ this.options.scope ];
  10874. this._splice( drop );
  10875. },
  10876. _setOption: function( key, value ) {
  10877. if ( key === "accept" ) {
  10878. this.accept = $.isFunction( value ) ? value : function( d ) {
  10879. return d.is( value );
  10880. };
  10881. } else if ( key === "scope" ) {
  10882. var drop = $.ui.ddmanager.droppables[ this.options.scope ];
  10883. this._splice( drop );
  10884. this._addToManager( value );
  10885. }
  10886. this._super( key, value );
  10887. },
  10888. _activate: function( event ) {
  10889. var draggable = $.ui.ddmanager.current;
  10890. this._addActiveClass();
  10891. if ( draggable ) {
  10892. this._trigger( "activate", event, this.ui( draggable ) );
  10893. }
  10894. },
  10895. _deactivate: function( event ) {
  10896. var draggable = $.ui.ddmanager.current;
  10897. this._removeActiveClass();
  10898. if ( draggable ) {
  10899. this._trigger( "deactivate", event, this.ui( draggable ) );
  10900. }
  10901. },
  10902. _over: function( event ) {
  10903. var draggable = $.ui.ddmanager.current;
  10904. // Bail if draggable and droppable are same element
  10905. if ( !draggable || ( draggable.currentItem ||
  10906. draggable.element )[ 0 ] === this.element[ 0 ] ) {
  10907. return;
  10908. }
  10909. if ( this.accept.call( this.element[ 0 ], ( draggable.currentItem ||
  10910. draggable.element ) ) ) {
  10911. this._addHoverClass();
  10912. this._trigger( "over", event, this.ui( draggable ) );
  10913. }
  10914. },
  10915. _out: function( event ) {
  10916. var draggable = $.ui.ddmanager.current;
  10917. // Bail if draggable and droppable are same element
  10918. if ( !draggable || ( draggable.currentItem ||
  10919. draggable.element )[ 0 ] === this.element[ 0 ] ) {
  10920. return;
  10921. }
  10922. if ( this.accept.call( this.element[ 0 ], ( draggable.currentItem ||
  10923. draggable.element ) ) ) {
  10924. this._removeHoverClass();
  10925. this._trigger( "out", event, this.ui( draggable ) );
  10926. }
  10927. },
  10928. _drop: function( event, custom ) {
  10929. var draggable = custom || $.ui.ddmanager.current,
  10930. childrenIntersection = false;
  10931. // Bail if draggable and droppable are same element
  10932. if ( !draggable || ( draggable.currentItem ||
  10933. draggable.element )[ 0 ] === this.element[ 0 ] ) {
  10934. return false;
  10935. }
  10936. this.element
  10937. .find( ":data(ui-droppable)" )
  10938. .not( ".ui-draggable-dragging" )
  10939. .each( function() {
  10940. var inst = $( this ).droppable( "instance" );
  10941. if (
  10942. inst.options.greedy &&
  10943. !inst.options.disabled &&
  10944. inst.options.scope === draggable.options.scope &&
  10945. inst.accept.call(
  10946. inst.element[ 0 ], ( draggable.currentItem || draggable.element )
  10947. ) &&
  10948. intersect(
  10949. draggable,
  10950. $.extend( inst, { offset: inst.element.offset() } ),
  10951. inst.options.tolerance, event
  10952. )
  10953. ) {
  10954. childrenIntersection = true;
  10955. return false; }
  10956. } );
  10957. if ( childrenIntersection ) {
  10958. return false;
  10959. }
  10960. if ( this.accept.call( this.element[ 0 ],
  10961. ( draggable.currentItem || draggable.element ) ) ) {
  10962. this._removeActiveClass();
  10963. this._removeHoverClass();
  10964. this._trigger( "drop", event, this.ui( draggable ) );
  10965. return this.element;
  10966. }
  10967. return false;
  10968. },
  10969. ui: function( c ) {
  10970. return {
  10971. draggable: ( c.currentItem || c.element ),
  10972. helper: c.helper,
  10973. position: c.position,
  10974. offset: c.positionAbs
  10975. };
  10976. },
  10977. // Extension points just to make backcompat sane and avoid duplicating logic
  10978. // TODO: Remove in 1.13 along with call to it below
  10979. _addHoverClass: function() {
  10980. this._addClass( "ui-droppable-hover" );
  10981. },
  10982. _removeHoverClass: function() {
  10983. this._removeClass( "ui-droppable-hover" );
  10984. },
  10985. _addActiveClass: function() {
  10986. this._addClass( "ui-droppable-active" );
  10987. },
  10988. _removeActiveClass: function() {
  10989. this._removeClass( "ui-droppable-active" );
  10990. }
  10991. } );
  10992. var intersect = $.ui.intersect = ( function() {
  10993. function isOverAxis( x, reference, size ) {
  10994. return ( x >= reference ) && ( x < ( reference + size ) );
  10995. }
  10996. return function( draggable, droppable, toleranceMode, event ) {
  10997. if ( !droppable.offset ) {
  10998. return false;
  10999. }
  11000. var x1 = ( draggable.positionAbs ||
  11001. draggable.position.absolute ).left + draggable.margins.left,
  11002. y1 = ( draggable.positionAbs ||
  11003. draggable.position.absolute ).top + draggable.margins.top,
  11004. x2 = x1 + draggable.helperProportions.width,
  11005. y2 = y1 + draggable.helperProportions.height,
  11006. l = droppable.offset.left,
  11007. t = droppable.offset.top,
  11008. r = l + droppable.proportions().width,
  11009. b = t + droppable.proportions().height;
  11010. switch ( toleranceMode ) {
  11011. case "fit":
  11012. return ( l <= x1 && x2 <= r && t <= y1 && y2 <= b );
  11013. case "intersect":
  11014. return ( l < x1 + ( draggable.helperProportions.width / 2 ) && // Right Half
  11015. x2 - ( draggable.helperProportions.width / 2 ) < r && // Left Half
  11016. t < y1 + ( draggable.helperProportions.height / 2 ) && // Bottom Half
  11017. y2 - ( draggable.helperProportions.height / 2 ) < b ); // Top Half
  11018. case "pointer":
  11019. return isOverAxis( event.pageY, t, droppable.proportions().height ) &&
  11020. isOverAxis( event.pageX, l, droppable.proportions().width );
  11021. case "touch":
  11022. return (
  11023. ( y1 >= t && y1 <= b ) || // Top edge touching
  11024. ( y2 >= t && y2 <= b ) || // Bottom edge touching
  11025. ( y1 < t && y2 > b ) // Surrounded vertically
  11026. ) && (
  11027. ( x1 >= l && x1 <= r ) || // Left edge touching
  11028. ( x2 >= l && x2 <= r ) || // Right edge touching
  11029. ( x1 < l && x2 > r ) // Surrounded horizontally
  11030. );
  11031. default:
  11032. return false;
  11033. }
  11034. };
  11035. } )();
  11036. /*
  11037. This manager tracks offsets of draggables and droppables
  11038. */
  11039. $.ui.ddmanager = {
  11040. current: null,
  11041. droppables: { "default": [] },
  11042. prepareOffsets: function( t, event ) {
  11043. var i, j,
  11044. m = $.ui.ddmanager.droppables[ t.options.scope ] || [],
  11045. type = event ? event.type : null, // workaround for #2317
  11046. list = ( t.currentItem || t.element ).find( ":data(ui-droppable)" ).addBack();
  11047. droppablesLoop: for ( i = 0; i < m.length; i++ ) {
  11048. // No disabled and non-accepted
  11049. if ( m[ i ].options.disabled || ( t && !m[ i ].accept.call( m[ i ].element[ 0 ],
  11050. ( t.currentItem || t.element ) ) ) ) {
  11051. continue;
  11052. }
  11053. // Filter out elements in the current dragged item
  11054. for ( j = 0; j < list.length; j++ ) {
  11055. if ( list[ j ] === m[ i ].element[ 0 ] ) {
  11056. m[ i ].proportions().height = 0;
  11057. continue droppablesLoop;
  11058. }
  11059. }
  11060. m[ i ].visible = m[ i ].element.css( "display" ) !== "none";
  11061. if ( !m[ i ].visible ) {
  11062. continue;
  11063. }
  11064. // Activate the droppable if used directly from draggables
  11065. if ( type === "mousedown" ) {
  11066. m[ i ]._activate.call( m[ i ], event );
  11067. }
  11068. m[ i ].offset = m[ i ].element.offset();
  11069. m[ i ].proportions( {
  11070. width: m[ i ].element[ 0 ].offsetWidth,
  11071. height: m[ i ].element[ 0 ].offsetHeight
  11072. } );
  11073. }
  11074. },
  11075. drop: function( draggable, event ) {
  11076. var dropped = false;
  11077. // Create a copy of the droppables in case the list changes during the drop (#9116)
  11078. $.each( ( $.ui.ddmanager.droppables[ draggable.options.scope ] || [] ).slice(), function() {
  11079. if ( !this.options ) {
  11080. return;
  11081. }
  11082. if ( !this.options.disabled && this.visible &&
  11083. intersect( draggable, this, this.options.tolerance, event ) ) {
  11084. dropped = this._drop.call( this, event ) || dropped;
  11085. }
  11086. if ( !this.options.disabled && this.visible && this.accept.call( this.element[ 0 ],
  11087. ( draggable.currentItem || draggable.element ) ) ) {
  11088. this.isout = true;
  11089. this.isover = false;
  11090. this._deactivate.call( this, event );
  11091. }
  11092. } );
  11093. return dropped;
  11094. },
  11095. dragStart: function( draggable, event ) {
  11096. // Listen for scrolling so that if the dragging causes scrolling the position of the
  11097. // droppables can be recalculated (see #5003)
  11098. draggable.element.parentsUntil( "body" ).on( "scroll.droppable", function() {
  11099. if ( !draggable.options.refreshPositions ) {
  11100. $.ui.ddmanager.prepareOffsets( draggable, event );
  11101. }
  11102. } );
  11103. },
  11104. drag: function( draggable, event ) {
  11105. // If you have a highly dynamic page, you might try this option. It renders positions
  11106. // every time you move the mouse.
  11107. if ( draggable.options.refreshPositions ) {
  11108. $.ui.ddmanager.prepareOffsets( draggable, event );
  11109. }
  11110. // Run through all droppables and check their positions based on specific tolerance options
  11111. $.each( $.ui.ddmanager.droppables[ draggable.options.scope ] || [], function() {
  11112. if ( this.options.disabled || this.greedyChild || !this.visible ) {
  11113. return;
  11114. }
  11115. var parentInstance, scope, parent,
  11116. intersects = intersect( draggable, this, this.options.tolerance, event ),
  11117. c = !intersects && this.isover ?
  11118. "isout" :
  11119. ( intersects && !this.isover ? "isover" : null );
  11120. if ( !c ) {
  11121. return;
  11122. }
  11123. if ( this.options.greedy ) {
  11124. // find droppable parents with same scope
  11125. scope = this.options.scope;
  11126. parent = this.element.parents( ":data(ui-droppable)" ).filter( function() {
  11127. return $( this ).droppable( "instance" ).options.scope === scope;
  11128. } );
  11129. if ( parent.length ) {
  11130. parentInstance = $( parent[ 0 ] ).droppable( "instance" );
  11131. parentInstance.greedyChild = ( c === "isover" );
  11132. }
  11133. }
  11134. // We just moved into a greedy child
  11135. if ( parentInstance && c === "isover" ) {
  11136. parentInstance.isover = false;
  11137. parentInstance.isout = true;
  11138. parentInstance._out.call( parentInstance, event );
  11139. }
  11140. this[ c ] = true;
  11141. this[ c === "isout" ? "isover" : "isout" ] = false;
  11142. this[ c === "isover" ? "_over" : "_out" ].call( this, event );
  11143. // We just moved out of a greedy child
  11144. if ( parentInstance && c === "isout" ) {
  11145. parentInstance.isout = false;
  11146. parentInstance.isover = true;
  11147. parentInstance._over.call( parentInstance, event );
  11148. }
  11149. } );
  11150. },
  11151. dragStop: function( draggable, event ) {
  11152. draggable.element.parentsUntil( "body" ).off( "scroll.droppable" );
  11153. // Call prepareOffsets one final time since IE does not fire return scroll events when
  11154. // overflow was caused by drag (see #5003)
  11155. if ( !draggable.options.refreshPositions ) {
  11156. $.ui.ddmanager.prepareOffsets( draggable, event );
  11157. }
  11158. }
  11159. };
  11160. // DEPRECATED
  11161. // TODO: switch return back to widget declaration at top of file when this is removed
  11162. if ( $.uiBackCompat !== false ) {
  11163. // Backcompat for activeClass and hoverClass options
  11164. $.widget( "ui.droppable", $.ui.droppable, {
  11165. options: {
  11166. hoverClass: false,
  11167. activeClass: false
  11168. },
  11169. _addActiveClass: function() {
  11170. this._super();
  11171. if ( this.options.activeClass ) {
  11172. this.element.addClass( this.options.activeClass );
  11173. }
  11174. },
  11175. _removeActiveClass: function() {
  11176. this._super();
  11177. if ( this.options.activeClass ) {
  11178. this.element.removeClass( this.options.activeClass );
  11179. }
  11180. },
  11181. _addHoverClass: function() {
  11182. this._super();
  11183. if ( this.options.hoverClass ) {
  11184. this.element.addClass( this.options.hoverClass );
  11185. }
  11186. },
  11187. _removeHoverClass: function() {
  11188. this._super();
  11189. if ( this.options.hoverClass ) {
  11190. this.element.removeClass( this.options.hoverClass );
  11191. }
  11192. }
  11193. } );
  11194. }
  11195. var widgetsDroppable = $.ui.droppable;
  11196. /*!
  11197. * jQuery UI Progressbar 1.12.0
  11198. * http://jqueryui.com
  11199. *
  11200. * Copyright jQuery Foundation and other contributors
  11201. * Released under the MIT license.
  11202. * http://jquery.org/license
  11203. */
  11204. //>>label: Progressbar
  11205. //>>group: Widgets
  11206. // jscs:disable maximumLineLength
  11207. //>>description: Displays a status indicator for loading state, standard percentage, and other progress indicators.
  11208. // jscs:enable maximumLineLength
  11209. //>>docs: http://api.jqueryui.com/progressbar/
  11210. //>>demos: http://jqueryui.com/progressbar/
  11211. //>>css.structure: ../../themes/base/core.css
  11212. //>>css.structure: ../../themes/base/progressbar.css
  11213. //>>css.theme: ../../themes/base/theme.css
  11214. var widgetsProgressbar = $.widget( "ui.progressbar", {
  11215. version: "1.12.0",
  11216. options: {
  11217. classes: {
  11218. "ui-progressbar": "ui-corner-all",
  11219. "ui-progressbar-value": "ui-corner-left",
  11220. "ui-progressbar-complete": "ui-corner-right"
  11221. },
  11222. max: 100,
  11223. value: 0,
  11224. change: null,
  11225. complete: null
  11226. },
  11227. min: 0,
  11228. _create: function() {
  11229. // Constrain initial value
  11230. this.oldValue = this.options.value = this._constrainedValue();
  11231. this.element.attr( {
  11232. // Only set static values; aria-valuenow and aria-valuemax are
  11233. // set inside _refreshValue()
  11234. role: "progressbar",
  11235. "aria-valuemin": this.min
  11236. } );
  11237. this._addClass( "ui-progressbar", "ui-widget ui-widget-content" );
  11238. this.valueDiv = $( "<div>" ).appendTo( this.element );
  11239. this._addClass( this.valueDiv, "ui-progressbar-value", "ui-widget-header" );
  11240. this._refreshValue();
  11241. },
  11242. _destroy: function() {
  11243. this.element.removeAttr( "role aria-valuemin aria-valuemax aria-valuenow" );
  11244. this.valueDiv.remove();
  11245. },
  11246. value: function( newValue ) {
  11247. if ( newValue === undefined ) {
  11248. return this.options.value;
  11249. }
  11250. this.options.value = this._constrainedValue( newValue );
  11251. this._refreshValue();
  11252. },
  11253. _constrainedValue: function( newValue ) {
  11254. if ( newValue === undefined ) {
  11255. newValue = this.options.value;
  11256. }
  11257. this.indeterminate = newValue === false;
  11258. // Sanitize value
  11259. if ( typeof newValue !== "number" ) {
  11260. newValue = 0;
  11261. }
  11262. return this.indeterminate ? false :
  11263. Math.min( this.options.max, Math.max( this.min, newValue ) );
  11264. },
  11265. _setOptions: function( options ) {
  11266. // Ensure "value" option is set after other values (like max)
  11267. var value = options.value;
  11268. delete options.value;
  11269. this._super( options );
  11270. this.options.value = this._constrainedValue( value );
  11271. this._refreshValue();
  11272. },
  11273. _setOption: function( key, value ) {
  11274. if ( key === "max" ) {
  11275. // Don't allow a max less than min
  11276. value = Math.max( this.min, value );
  11277. }
  11278. this._super( key, value );
  11279. },
  11280. _setOptionDisabled: function( value ) {
  11281. this._super( value );
  11282. this.element.attr( "aria-disabled", value );
  11283. this._toggleClass( null, "ui-state-disabled", !!value );
  11284. },
  11285. _percentage: function() {
  11286. return this.indeterminate ?
  11287. 100 :
  11288. 100 * ( this.options.value - this.min ) / ( this.options.max - this.min );
  11289. },
  11290. _refreshValue: function() {
  11291. var value = this.options.value,
  11292. percentage = this._percentage();
  11293. this.valueDiv
  11294. .toggle( this.indeterminate || value > this.min )
  11295. .width( percentage.toFixed( 0 ) + "%" );
  11296. this
  11297. ._toggleClass( this.valueDiv, "ui-progressbar-complete", null,
  11298. value === this.options.max )
  11299. ._toggleClass( "ui-progressbar-indeterminate", null, this.indeterminate );
  11300. if ( this.indeterminate ) {
  11301. this.element.removeAttr( "aria-valuenow" );
  11302. if ( !this.overlayDiv ) {
  11303. this.overlayDiv = $( "<div>" ).appendTo( this.valueDiv );
  11304. this._addClass( this.overlayDiv, "ui-progressbar-overlay" );
  11305. }
  11306. } else {
  11307. this.element.attr( {
  11308. "aria-valuemax": this.options.max,
  11309. "aria-valuenow": value
  11310. } );
  11311. if ( this.overlayDiv ) {
  11312. this.overlayDiv.remove();
  11313. this.overlayDiv = null;
  11314. }
  11315. }
  11316. if ( this.oldValue !== value ) {
  11317. this.oldValue = value;
  11318. this._trigger( "change" );
  11319. }
  11320. if ( value === this.options.max ) {
  11321. this._trigger( "complete" );
  11322. }
  11323. }
  11324. } );
  11325. /*!
  11326. * jQuery UI Selectable 1.12.0
  11327. * http://jqueryui.com
  11328. *
  11329. * Copyright jQuery Foundation and other contributors
  11330. * Released under the MIT license.
  11331. * http://jquery.org/license
  11332. */
  11333. //>>label: Selectable
  11334. //>>group: Interactions
  11335. //>>description: Allows groups of elements to be selected with the mouse.
  11336. //>>docs: http://api.jqueryui.com/selectable/
  11337. //>>demos: http://jqueryui.com/selectable/
  11338. //>>css.structure: ../../themes/base/selectable.css
  11339. var widgetsSelectable = $.widget( "ui.selectable", $.ui.mouse, {
  11340. version: "1.12.0",
  11341. options: {
  11342. appendTo: "body",
  11343. autoRefresh: true,
  11344. distance: 0,
  11345. filter: "*",
  11346. tolerance: "touch",
  11347. // Callbacks
  11348. selected: null,
  11349. selecting: null,
  11350. start: null,
  11351. stop: null,
  11352. unselected: null,
  11353. unselecting: null
  11354. },
  11355. _create: function() {
  11356. var that = this;
  11357. this._addClass( "ui-selectable" );
  11358. this.dragged = false;
  11359. // Cache selectee children based on filter
  11360. this.refresh = function() {
  11361. that.elementPos = $( that.element[ 0 ] ).offset();
  11362. that.selectees = $( that.options.filter, that.element[ 0 ] );
  11363. that._addClass( that.selectees, "ui-selectee" );
  11364. that.selectees.each( function() {
  11365. var $this = $( this ),
  11366. selecteeOffset = $this.offset(),
  11367. pos = {
  11368. left: selecteeOffset.left - that.elementPos.left,
  11369. top: selecteeOffset.top - that.elementPos.top
  11370. };
  11371. $.data( this, "selectable-item", {
  11372. element: this,
  11373. $element: $this,
  11374. left: pos.left,
  11375. top: pos.top,
  11376. right: pos.left + $this.outerWidth(),
  11377. bottom: pos.top + $this.outerHeight(),
  11378. startselected: false,
  11379. selected: $this.hasClass( "ui-selected" ),
  11380. selecting: $this.hasClass( "ui-selecting" ),
  11381. unselecting: $this.hasClass( "ui-unselecting" )
  11382. } );
  11383. } );
  11384. };
  11385. this.refresh();
  11386. this._mouseInit();
  11387. this.helper = $( "<div>" );
  11388. this._addClass( this.helper, "ui-selectable-helper" );
  11389. },
  11390. _destroy: function() {
  11391. this.selectees.removeData( "selectable-item" );
  11392. this._mouseDestroy();
  11393. },
  11394. _mouseStart: function( event ) {
  11395. var that = this,
  11396. options = this.options;
  11397. this.opos = [ event.pageX, event.pageY ];
  11398. this.elementPos = $( this.element[ 0 ] ).offset();
  11399. if ( this.options.disabled ) {
  11400. return;
  11401. }
  11402. this.selectees = $( options.filter, this.element[ 0 ] );
  11403. this._trigger( "start", event );
  11404. $( options.appendTo ).append( this.helper );
  11405. // position helper (lasso)
  11406. this.helper.css( {
  11407. "left": event.pageX,
  11408. "top": event.pageY,
  11409. "width": 0,
  11410. "height": 0
  11411. } );
  11412. if ( options.autoRefresh ) {
  11413. this.refresh();
  11414. }
  11415. this.selectees.filter( ".ui-selected" ).each( function() {
  11416. var selectee = $.data( this, "selectable-item" );
  11417. selectee.startselected = true;
  11418. if ( !event.metaKey && !event.ctrlKey ) {
  11419. that._removeClass( selectee.$element, "ui-selected" );
  11420. selectee.selected = false;
  11421. that._addClass( selectee.$element, "ui-unselecting" );
  11422. selectee.unselecting = true;
  11423. // selectable UNSELECTING callback
  11424. that._trigger( "unselecting", event, {
  11425. unselecting: selectee.element
  11426. } );
  11427. }
  11428. } );
  11429. $( event.target ).parents().addBack().each( function() {
  11430. var doSelect,
  11431. selectee = $.data( this, "selectable-item" );
  11432. if ( selectee ) {
  11433. doSelect = ( !event.metaKey && !event.ctrlKey ) ||
  11434. !selectee.$element.hasClass( "ui-selected" );
  11435. that._removeClass( selectee.$element, doSelect ? "ui-unselecting" : "ui-selected" )
  11436. ._addClass( selectee.$element, doSelect ? "ui-selecting" : "ui-unselecting" );
  11437. selectee.unselecting = !doSelect;
  11438. selectee.selecting = doSelect;
  11439. selectee.selected = doSelect;
  11440. // selectable (UN)SELECTING callback
  11441. if ( doSelect ) {
  11442. that._trigger( "selecting", event, {
  11443. selecting: selectee.element
  11444. } );
  11445. } else {
  11446. that._trigger( "unselecting", event, {
  11447. unselecting: selectee.element
  11448. } );
  11449. }
  11450. return false;
  11451. }
  11452. } );
  11453. },
  11454. _mouseDrag: function( event ) {
  11455. this.dragged = true;
  11456. if ( this.options.disabled ) {
  11457. return;
  11458. }
  11459. var tmp,
  11460. that = this,
  11461. options = this.options,
  11462. x1 = this.opos[ 0 ],
  11463. y1 = this.opos[ 1 ],
  11464. x2 = event.pageX,
  11465. y2 = event.pageY;
  11466. if ( x1 > x2 ) { tmp = x2; x2 = x1; x1 = tmp; }
  11467. if ( y1 > y2 ) { tmp = y2; y2 = y1; y1 = tmp; }
  11468. this.helper.css( { left: x1, top: y1, width: x2 - x1, height: y2 - y1 } );
  11469. this.selectees.each( function() {
  11470. var selectee = $.data( this, "selectable-item" ),
  11471. hit = false,
  11472. offset = {};
  11473. //prevent helper from being selected if appendTo: selectable
  11474. if ( !selectee || selectee.element === that.element[ 0 ] ) {
  11475. return;
  11476. }
  11477. offset.left = selectee.left + that.elementPos.left;
  11478. offset.right = selectee.right + that.elementPos.left;
  11479. offset.top = selectee.top + that.elementPos.top;
  11480. offset.bottom = selectee.bottom + that.elementPos.top;
  11481. if ( options.tolerance === "touch" ) {
  11482. hit = ( !( offset.left > x2 || offset.right < x1 || offset.top > y2 ||
  11483. offset.bottom < y1 ) );
  11484. } else if ( options.tolerance === "fit" ) {
  11485. hit = ( offset.left > x1 && offset.right < x2 && offset.top > y1 &&
  11486. offset.bottom < y2 );
  11487. }
  11488. if ( hit ) {
  11489. // SELECT
  11490. if ( selectee.selected ) {
  11491. that._removeClass( selectee.$element, "ui-selected" );
  11492. selectee.selected = false;
  11493. }
  11494. if ( selectee.unselecting ) {
  11495. that._removeClass( selectee.$element, "ui-unselecting" );
  11496. selectee.unselecting = false;
  11497. }
  11498. if ( !selectee.selecting ) {
  11499. that._addClass( selectee.$element, "ui-selecting" );
  11500. selectee.selecting = true;
  11501. // selectable SELECTING callback
  11502. that._trigger( "selecting", event, {
  11503. selecting: selectee.element
  11504. } );
  11505. }
  11506. } else {
  11507. // UNSELECT
  11508. if ( selectee.selecting ) {
  11509. if ( ( event.metaKey || event.ctrlKey ) && selectee.startselected ) {
  11510. that._removeClass( selectee.$element, "ui-selecting" );
  11511. selectee.selecting = false;
  11512. that._addClass( selectee.$element, "ui-selected" );
  11513. selectee.selected = true;
  11514. } else {
  11515. that._removeClass( selectee.$element, "ui-selecting" );
  11516. selectee.selecting = false;
  11517. if ( selectee.startselected ) {
  11518. that._addClass( selectee.$element, "ui-unselecting" );
  11519. selectee.unselecting = true;
  11520. }
  11521. // selectable UNSELECTING callback
  11522. that._trigger( "unselecting", event, {
  11523. unselecting: selectee.element
  11524. } );
  11525. }
  11526. }
  11527. if ( selectee.selected ) {
  11528. if ( !event.metaKey && !event.ctrlKey && !selectee.startselected ) {
  11529. that._removeClass( selectee.$element, "ui-selected" );
  11530. selectee.selected = false;
  11531. that._addClass( selectee.$element, "ui-unselecting" );
  11532. selectee.unselecting = true;
  11533. // selectable UNSELECTING callback
  11534. that._trigger( "unselecting", event, {
  11535. unselecting: selectee.element
  11536. } );
  11537. }
  11538. }
  11539. }
  11540. } );
  11541. return false;
  11542. },
  11543. _mouseStop: function( event ) {
  11544. var that = this;
  11545. this.dragged = false;
  11546. $( ".ui-unselecting", this.element[ 0 ] ).each( function() {
  11547. var selectee = $.data( this, "selectable-item" );
  11548. that._removeClass( selectee.$element, "ui-unselecting" );
  11549. selectee.unselecting = false;
  11550. selectee.startselected = false;
  11551. that._trigger( "unselected", event, {
  11552. unselected: selectee.element
  11553. } );
  11554. } );
  11555. $( ".ui-selecting", this.element[ 0 ] ).each( function() {
  11556. var selectee = $.data( this, "selectable-item" );
  11557. that._removeClass( selectee.$element, "ui-selecting" )
  11558. ._addClass( selectee.$element, "ui-selected" );
  11559. selectee.selecting = false;
  11560. selectee.selected = true;
  11561. selectee.startselected = true;
  11562. that._trigger( "selected", event, {
  11563. selected: selectee.element
  11564. } );
  11565. } );
  11566. this._trigger( "stop", event );
  11567. this.helper.remove();
  11568. return false;
  11569. }
  11570. } );
  11571. /*!
  11572. * jQuery UI Selectmenu 1.12.0
  11573. * http://jqueryui.com
  11574. *
  11575. * Copyright jQuery Foundation and other contributors
  11576. * Released under the MIT license.
  11577. * http://jquery.org/license
  11578. */
  11579. //>>label: Selectmenu
  11580. //>>group: Widgets
  11581. // jscs:disable maximumLineLength
  11582. //>>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.
  11583. // jscs:enable maximumLineLength
  11584. //>>docs: http://api.jqueryui.com/selectmenu/
  11585. //>>demos: http://jqueryui.com/selectmenu/
  11586. //>>css.structure: ../../themes/base/core.css
  11587. //>>css.structure: ../../themes/base/selectmenu.css, ../../themes/base/button.css
  11588. //>>css.theme: ../../themes/base/theme.css
  11589. var widgetsSelectmenu = $.widget( "ui.selectmenu", [ $.ui.formResetMixin, {
  11590. version: "1.12.0",
  11591. defaultElement: "<select>",
  11592. options: {
  11593. appendTo: null,
  11594. classes: {
  11595. "ui-selectmenu-button-open": "ui-corner-top",
  11596. "ui-selectmenu-button-closed": "ui-corner-all"
  11597. },
  11598. disabled: null,
  11599. icons: {
  11600. button: "ui-icon-triangle-1-s"
  11601. },
  11602. position: {
  11603. my: "left top",
  11604. at: "left bottom",
  11605. collision: "none"
  11606. },
  11607. width: false,
  11608. // Callbacks
  11609. change: null,
  11610. close: null,
  11611. focus: null,
  11612. open: null,
  11613. select: null
  11614. },
  11615. _create: function() {
  11616. var selectmenuId = this.element.uniqueId().attr( "id" );
  11617. this.ids = {
  11618. element: selectmenuId,
  11619. button: selectmenuId + "-button",
  11620. menu: selectmenuId + "-menu"
  11621. };
  11622. this._drawButton();
  11623. this._drawMenu();
  11624. this._bindFormResetHandler();
  11625. this._rendered = false;
  11626. this.menuItems = $();
  11627. },
  11628. _drawButton: function() {
  11629. var icon,
  11630. that = this,
  11631. item = this._parseOption(
  11632. this.element.find( "option:selected" ),
  11633. this.element[ 0 ].selectedIndex
  11634. );
  11635. // Associate existing label with the new button
  11636. this.labels = this.element.labels().attr( "for", this.ids.button );
  11637. this._on( this.labels, {
  11638. click: function( event ) {
  11639. this.button.focus();
  11640. event.preventDefault();
  11641. }
  11642. } );
  11643. // Hide original select element
  11644. this.element.hide();
  11645. // Create button
  11646. this.button = $( "<span>", {
  11647. tabindex: this.options.disabled ? -1 : 0,
  11648. id: this.ids.button,
  11649. role: "combobox",
  11650. "aria-expanded": "false",
  11651. "aria-autocomplete": "list",
  11652. "aria-owns": this.ids.menu,
  11653. "aria-haspopup": "true",
  11654. title: this.element.attr( "title" )
  11655. } )
  11656. .insertAfter( this.element );
  11657. this._addClass( this.button, "ui-selectmenu-button ui-selectmenu-button-closed",
  11658. "ui-button ui-widget" );
  11659. icon = $( "<span>" ).appendTo( this.button );
  11660. this._addClass( icon, "ui-selectmenu-icon", "ui-icon " + this.options.icons.button );
  11661. this.buttonItem = this._renderButtonItem( item )
  11662. .appendTo( this.button );
  11663. if ( this.options.width !== false ) {
  11664. this._resizeButton();
  11665. }
  11666. this._on( this.button, this._buttonEvents );
  11667. this.button.one( "focusin", function() {
  11668. // Delay rendering the menu items until the button receives focus.
  11669. // The menu may have already been rendered via a programmatic open.
  11670. if ( !that._rendered ) {
  11671. that._refreshMenu();
  11672. }
  11673. } );
  11674. },
  11675. _drawMenu: function() {
  11676. var that = this;
  11677. // Create menu
  11678. this.menu = $( "<ul>", {
  11679. "aria-hidden": "true",
  11680. "aria-labelledby": this.ids.button,
  11681. id: this.ids.menu
  11682. } );
  11683. // Wrap menu
  11684. this.menuWrap = $( "<div>" ).append( this.menu );
  11685. this._addClass( this.menuWrap, "ui-selectmenu-menu", "ui-front" );
  11686. this.menuWrap.appendTo( this._appendTo() );
  11687. // Initialize menu widget
  11688. this.menuInstance = this.menu
  11689. .menu( {
  11690. classes: {
  11691. "ui-menu": "ui-corner-bottom"
  11692. },
  11693. role: "listbox",
  11694. select: function( event, ui ) {
  11695. event.preventDefault();
  11696. // Support: IE8
  11697. // If the item was selected via a click, the text selection
  11698. // will be destroyed in IE
  11699. that._setSelection();
  11700. that._select( ui.item.data( "ui-selectmenu-item" ), event );
  11701. },
  11702. focus: function( event, ui ) {
  11703. var item = ui.item.data( "ui-selectmenu-item" );
  11704. // Prevent inital focus from firing and check if its a newly focused item
  11705. if ( that.focusIndex != null && item.index !== that.focusIndex ) {
  11706. that._trigger( "focus", event, { item: item } );
  11707. if ( !that.isOpen ) {
  11708. that._select( item, event );
  11709. }
  11710. }
  11711. that.focusIndex = item.index;
  11712. that.button.attr( "aria-activedescendant",
  11713. that.menuItems.eq( item.index ).attr( "id" ) );
  11714. }
  11715. } )
  11716. .menu( "instance" );
  11717. // Don't close the menu on mouseleave
  11718. this.menuInstance._off( this.menu, "mouseleave" );
  11719. // Cancel the menu's collapseAll on document click
  11720. this.menuInstance._closeOnDocumentClick = function() {
  11721. return false;
  11722. };
  11723. // Selects often contain empty items, but never contain dividers
  11724. this.menuInstance._isDivider = function() {
  11725. return false;
  11726. };
  11727. },
  11728. refresh: function() {
  11729. this._refreshMenu();
  11730. this.buttonItem.replaceWith(
  11731. this.buttonItem = this._renderButtonItem(
  11732. // Fall back to an empty object in case there are no options
  11733. this._getSelectedItem().data( "ui-selectmenu-item" ) || {}
  11734. )
  11735. );
  11736. if ( this.options.width === null ) {
  11737. this._resizeButton();
  11738. }
  11739. },
  11740. _refreshMenu: function() {
  11741. var item,
  11742. options = this.element.find( "option" );
  11743. this.menu.empty();
  11744. this._parseOptions( options );
  11745. this._renderMenu( this.menu, this.items );
  11746. this.menuInstance.refresh();
  11747. this.menuItems = this.menu.find( "li" )
  11748. .not( ".ui-selectmenu-optgroup" )
  11749. .find( ".ui-menu-item-wrapper" );
  11750. this._rendered = true;
  11751. if ( !options.length ) {
  11752. return;
  11753. }
  11754. item = this._getSelectedItem();
  11755. // Update the menu to have the correct item focused
  11756. this.menuInstance.focus( null, item );
  11757. this._setAria( item.data( "ui-selectmenu-item" ) );
  11758. // Set disabled state
  11759. this._setOption( "disabled", this.element.prop( "disabled" ) );
  11760. },
  11761. open: function( event ) {
  11762. if ( this.options.disabled ) {
  11763. return;
  11764. }
  11765. // If this is the first time the menu is being opened, render the items
  11766. if ( !this._rendered ) {
  11767. this._refreshMenu();
  11768. } else {
  11769. // Menu clears focus on close, reset focus to selected item
  11770. this._removeClass( this.menu.find( ".ui-state-active" ), null, "ui-state-active" );
  11771. this.menuInstance.focus( null, this._getSelectedItem() );
  11772. }
  11773. // If there are no options, don't open the menu
  11774. if ( !this.menuItems.length ) {
  11775. return;
  11776. }
  11777. this.isOpen = true;
  11778. this._toggleAttr();
  11779. this._resizeMenu();
  11780. this._position();
  11781. this._on( this.document, this._documentClick );
  11782. this._trigger( "open", event );
  11783. },
  11784. _position: function() {
  11785. this.menuWrap.position( $.extend( { of: this.button }, this.options.position ) );
  11786. },
  11787. close: function( event ) {
  11788. if ( !this.isOpen ) {
  11789. return;
  11790. }
  11791. this.isOpen = false;
  11792. this._toggleAttr();
  11793. this.range = null;
  11794. this._off( this.document );
  11795. this._trigger( "close", event );
  11796. },
  11797. widget: function() {
  11798. return this.button;
  11799. },
  11800. menuWidget: function() {
  11801. return this.menu;
  11802. },
  11803. _renderButtonItem: function( item ) {
  11804. var buttonItem = $( "<span>" );
  11805. this._setText( buttonItem, item.label );
  11806. this._addClass( buttonItem, "ui-selectmenu-text" );
  11807. return buttonItem;
  11808. },
  11809. _renderMenu: function( ul, items ) {
  11810. var that = this,
  11811. currentOptgroup = "";
  11812. $.each( items, function( index, item ) {
  11813. var li;
  11814. if ( item.optgroup !== currentOptgroup ) {
  11815. li = $( "<li>", {
  11816. text: item.optgroup
  11817. } );
  11818. that._addClass( li, "ui-selectmenu-optgroup", "ui-menu-divider" +
  11819. ( item.element.parent( "optgroup" ).prop( "disabled" ) ?
  11820. " ui-state-disabled" :
  11821. "" ) );
  11822. li.appendTo( ul );
  11823. currentOptgroup = item.optgroup;
  11824. }
  11825. that._renderItemData( ul, item );
  11826. } );
  11827. },
  11828. _renderItemData: function( ul, item ) {
  11829. return this._renderItem( ul, item ).data( "ui-selectmenu-item", item );
  11830. },
  11831. _renderItem: function( ul, item ) {
  11832. var li = $( "<li>" ),
  11833. wrapper = $( "<div>", {
  11834. title: item.element.attr( "title" )
  11835. } );
  11836. if ( item.disabled ) {
  11837. this._addClass( li, null, "ui-state-disabled" );
  11838. }
  11839. this._setText( wrapper, item.label );
  11840. return li.append( wrapper ).appendTo( ul );
  11841. },
  11842. _setText: function( element, value ) {
  11843. if ( value ) {
  11844. element.text( value );
  11845. } else {
  11846. element.html( "&#160;" );
  11847. }
  11848. },
  11849. _move: function( direction, event ) {
  11850. var item, next,
  11851. filter = ".ui-menu-item";
  11852. if ( this.isOpen ) {
  11853. item = this.menuItems.eq( this.focusIndex ).parent( "li" );
  11854. } else {
  11855. item = this.menuItems.eq( this.element[ 0 ].selectedIndex ).parent( "li" );
  11856. filter += ":not(.ui-state-disabled)";
  11857. }
  11858. if ( direction === "first" || direction === "last" ) {
  11859. next = item[ direction === "first" ? "prevAll" : "nextAll" ]( filter ).eq( -1 );
  11860. } else {
  11861. next = item[ direction + "All" ]( filter ).eq( 0 );
  11862. }
  11863. if ( next.length ) {
  11864. this.menuInstance.focus( event, next );
  11865. }
  11866. },
  11867. _getSelectedItem: function() {
  11868. return this.menuItems.eq( this.element[ 0 ].selectedIndex ).parent( "li" );
  11869. },
  11870. _toggle: function( event ) {
  11871. this[ this.isOpen ? "close" : "open" ]( event );
  11872. },
  11873. _setSelection: function() {
  11874. var selection;
  11875. if ( !this.range ) {
  11876. return;
  11877. }
  11878. if ( window.getSelection ) {
  11879. selection = window.getSelection();
  11880. selection.removeAllRanges();
  11881. selection.addRange( this.range );
  11882. // Support: IE8
  11883. } else {
  11884. this.range.select();
  11885. }
  11886. // Support: IE
  11887. // Setting the text selection kills the button focus in IE, but
  11888. // restoring the focus doesn't kill the selection.
  11889. this.button.focus();
  11890. },
  11891. _documentClick: {
  11892. mousedown: function( event ) {
  11893. if ( !this.isOpen ) {
  11894. return;
  11895. }
  11896. if ( !$( event.target ).closest( ".ui-selectmenu-menu, #" +
  11897. $.ui.escapeSelector( this.ids.button ) ).length ) {
  11898. this.close( event );
  11899. }
  11900. }
  11901. },
  11902. _buttonEvents: {
  11903. // Prevent text selection from being reset when interacting with the selectmenu (#10144)
  11904. mousedown: function() {
  11905. var selection;
  11906. if ( window.getSelection ) {
  11907. selection = window.getSelection();
  11908. if ( selection.rangeCount ) {
  11909. this.range = selection.getRangeAt( 0 );
  11910. }
  11911. // Support: IE8
  11912. } else {
  11913. this.range = document.selection.createRange();
  11914. }
  11915. },
  11916. click: function( event ) {
  11917. this._setSelection();
  11918. this._toggle( event );
  11919. },
  11920. keydown: function( event ) {
  11921. var preventDefault = true;
  11922. switch ( event.keyCode ) {
  11923. case $.ui.keyCode.TAB:
  11924. case $.ui.keyCode.ESCAPE:
  11925. this.close( event );
  11926. preventDefault = false;
  11927. break;
  11928. case $.ui.keyCode.ENTER:
  11929. if ( this.isOpen ) {
  11930. this._selectFocusedItem( event );
  11931. }
  11932. break;
  11933. case $.ui.keyCode.UP:
  11934. if ( event.altKey ) {
  11935. this._toggle( event );
  11936. } else {
  11937. this._move( "prev", event );
  11938. }
  11939. break;
  11940. case $.ui.keyCode.DOWN:
  11941. if ( event.altKey ) {
  11942. this._toggle( event );
  11943. } else {
  11944. this._move( "next", event );
  11945. }
  11946. break;
  11947. case $.ui.keyCode.SPACE:
  11948. if ( this.isOpen ) {
  11949. this._selectFocusedItem( event );
  11950. } else {
  11951. this._toggle( event );
  11952. }
  11953. break;
  11954. case $.ui.keyCode.LEFT:
  11955. this._move( "prev", event );
  11956. break;
  11957. case $.ui.keyCode.RIGHT:
  11958. this._move( "next", event );
  11959. break;
  11960. case $.ui.keyCode.HOME:
  11961. case $.ui.keyCode.PAGE_UP:
  11962. this._move( "first", event );
  11963. break;
  11964. case $.ui.keyCode.END:
  11965. case $.ui.keyCode.PAGE_DOWN:
  11966. this._move( "last", event );
  11967. break;
  11968. default:
  11969. this.menu.trigger( event );
  11970. preventDefault = false;
  11971. }
  11972. if ( preventDefault ) {
  11973. event.preventDefault();
  11974. }
  11975. }
  11976. },
  11977. _selectFocusedItem: function( event ) {
  11978. var item = this.menuItems.eq( this.focusIndex ).parent( "li" );
  11979. if ( !item.hasClass( "ui-state-disabled" ) ) {
  11980. this._select( item.data( "ui-selectmenu-item" ), event );
  11981. }
  11982. },
  11983. _select: function( item, event ) {
  11984. var oldIndex = this.element[ 0 ].selectedIndex;
  11985. // Change native select element
  11986. this.element[ 0 ].selectedIndex = item.index;
  11987. this.buttonItem.replaceWith( this.buttonItem = this._renderButtonItem( item ) );
  11988. this._setAria( item );
  11989. this._trigger( "select", event, { item: item } );
  11990. if ( item.index !== oldIndex ) {
  11991. this._trigger( "change", event, { item: item } );
  11992. }
  11993. this.close( event );
  11994. },
  11995. _setAria: function( item ) {
  11996. var id = this.menuItems.eq( item.index ).attr( "id" );
  11997. this.button.attr( {
  11998. "aria-labelledby": id,
  11999. "aria-activedescendant": id
  12000. } );
  12001. this.menu.attr( "aria-activedescendant", id );
  12002. },
  12003. _setOption: function( key, value ) {
  12004. if ( key === "icons" ) {
  12005. var icon = this.button.find( "span.ui-icon" );
  12006. this._removeClass( icon, null, this.options.icons.button )
  12007. ._addClass( icon, null, value.button );
  12008. }
  12009. this._super( key, value );
  12010. if ( key === "appendTo" ) {
  12011. this.menuWrap.appendTo( this._appendTo() );
  12012. }
  12013. if ( key === "width" ) {
  12014. this._resizeButton();
  12015. }
  12016. },
  12017. _setOptionDisabled: function( value ) {
  12018. this._super( value );
  12019. this.menuInstance.option( "disabled", value );
  12020. this.button.attr( "aria-disabled", value );
  12021. this._toggleClass( this.button, null, "ui-state-disabled", value );
  12022. this.element.prop( "disabled", value );
  12023. if ( value ) {
  12024. this.button.attr( "tabindex", -1 );
  12025. this.close();
  12026. } else {
  12027. this.button.attr( "tabindex", 0 );
  12028. }
  12029. },
  12030. _appendTo: function() {
  12031. var element = this.options.appendTo;
  12032. if ( element ) {
  12033. element = element.jquery || element.nodeType ?
  12034. $( element ) :
  12035. this.document.find( element ).eq( 0 );
  12036. }
  12037. if ( !element || !element[ 0 ] ) {
  12038. element = this.element.closest( ".ui-front, dialog" );
  12039. }
  12040. if ( !element.length ) {
  12041. element = this.document[ 0 ].body;
  12042. }
  12043. return element;
  12044. },
  12045. _toggleAttr: function() {
  12046. this.button.attr( "aria-expanded", this.isOpen );
  12047. // We can't use two _toggleClass() calls here, because we need to make sure
  12048. // we always remove classes first and add them second, otherwise if both classes have the
  12049. // same theme class, it will be removed after we add it.
  12050. this._removeClass( this.button, "ui-selectmenu-button-" +
  12051. ( this.isOpen ? "closed" : "open" ) )
  12052. ._addClass( this.button, "ui-selectmenu-button-" +
  12053. ( this.isOpen ? "open" : "closed" ) )
  12054. ._toggleClass( this.menuWrap, "ui-selectmenu-open", null, this.isOpen );
  12055. this.menu.attr( "aria-hidden", !this.isOpen );
  12056. },
  12057. _resizeButton: function() {
  12058. var width = this.options.width;
  12059. // For `width: false`, just remove inline style and stop
  12060. if ( width === false ) {
  12061. this.button.css( "width", "" );
  12062. return;
  12063. }
  12064. // For `width: null`, match the width of the original element
  12065. if ( width === null ) {
  12066. width = this.element.show().outerWidth();
  12067. this.element.hide();
  12068. }
  12069. this.button.outerWidth( width );
  12070. },
  12071. _resizeMenu: function() {
  12072. this.menu.outerWidth( Math.max(
  12073. this.button.outerWidth(),
  12074. // Support: IE10
  12075. // IE10 wraps long text (possibly a rounding bug)
  12076. // so we add 1px to avoid the wrapping
  12077. this.menu.width( "" ).outerWidth() + 1
  12078. ) );
  12079. },
  12080. _getCreateOptions: function() {
  12081. var options = this._super();
  12082. options.disabled = this.element.prop( "disabled" );
  12083. return options;
  12084. },
  12085. _parseOptions: function( options ) {
  12086. var that = this,
  12087. data = [];
  12088. options.each( function( index, item ) {
  12089. data.push( that._parseOption( $( item ), index ) );
  12090. } );
  12091. this.items = data;
  12092. },
  12093. _parseOption: function( option, index ) {
  12094. var optgroup = option.parent( "optgroup" );
  12095. return {
  12096. element: option,
  12097. index: index,
  12098. value: option.val(),
  12099. label: option.text(),
  12100. optgroup: optgroup.attr( "label" ) || "",
  12101. disabled: optgroup.prop( "disabled" ) || option.prop( "disabled" )
  12102. };
  12103. },
  12104. _destroy: function() {
  12105. this._unbindFormResetHandler();
  12106. this.menuWrap.remove();
  12107. this.button.remove();
  12108. this.element.show();
  12109. this.element.removeUniqueId();
  12110. this.labels.attr( "for", this.ids.element );
  12111. }
  12112. } ] );
  12113. /*!
  12114. * jQuery UI Slider 1.12.0
  12115. * http://jqueryui.com
  12116. *
  12117. * Copyright jQuery Foundation and other contributors
  12118. * Released under the MIT license.
  12119. * http://jquery.org/license
  12120. */
  12121. //>>label: Slider
  12122. //>>group: Widgets
  12123. //>>description: Displays a flexible slider with ranges and accessibility via keyboard.
  12124. //>>docs: http://api.jqueryui.com/slider/
  12125. //>>demos: http://jqueryui.com/slider/
  12126. //>>css.structure: ../../themes/base/core.css
  12127. //>>css.structure: ../../themes/base/slider.css
  12128. //>>css.theme: ../../themes/base/theme.css
  12129. var widgetsSlider = $.widget( "ui.slider", $.ui.mouse, {
  12130. version: "1.12.0",
  12131. widgetEventPrefix: "slide",
  12132. options: {
  12133. animate: false,
  12134. classes: {
  12135. "ui-slider": "ui-corner-all",
  12136. "ui-slider-handle": "ui-corner-all",
  12137. // Note: ui-widget-header isn't the most fittingly semantic framework class for this
  12138. // element, but worked best visually with a variety of themes
  12139. "ui-slider-range": "ui-corner-all ui-widget-header"
  12140. },
  12141. distance: 0,
  12142. max: 100,
  12143. min: 0,
  12144. orientation: "horizontal",
  12145. range: false,
  12146. step: 1,
  12147. value: 0,
  12148. values: null,
  12149. // Callbacks
  12150. change: null,
  12151. slide: null,
  12152. start: null,
  12153. stop: null
  12154. },
  12155. // Number of pages in a slider
  12156. // (how many times can you page up/down to go through the whole range)
  12157. numPages: 5,
  12158. _create: function() {
  12159. this._keySliding = false;
  12160. this._mouseSliding = false;
  12161. this._animateOff = true;
  12162. this._handleIndex = null;
  12163. this._detectOrientation();
  12164. this._mouseInit();
  12165. this._calculateNewMax();
  12166. this._addClass( "ui-slider ui-slider-" + this.orientation,
  12167. "ui-widget ui-widget-content" );
  12168. this._refresh();
  12169. this._animateOff = false;
  12170. },
  12171. _refresh: function() {
  12172. this._createRange();
  12173. this._createHandles();
  12174. this._setupEvents();
  12175. this._refreshValue();
  12176. },
  12177. _createHandles: function() {
  12178. var i, handleCount,
  12179. options = this.options,
  12180. existingHandles = this.element.find( ".ui-slider-handle" ),
  12181. handle = "<span tabindex='0'></span>",
  12182. handles = [];
  12183. handleCount = ( options.values && options.values.length ) || 1;
  12184. if ( existingHandles.length > handleCount ) {
  12185. existingHandles.slice( handleCount ).remove();
  12186. existingHandles = existingHandles.slice( 0, handleCount );
  12187. }
  12188. for ( i = existingHandles.length; i < handleCount; i++ ) {
  12189. handles.push( handle );
  12190. }
  12191. this.handles = existingHandles.add( $( handles.join( "" ) ).appendTo( this.element ) );
  12192. this._addClass( this.handles, "ui-slider-handle", "ui-state-default" );
  12193. this.handle = this.handles.eq( 0 );
  12194. this.handles.each( function( i ) {
  12195. $( this ).data( "ui-slider-handle-index", i );
  12196. } );
  12197. },
  12198. _createRange: function() {
  12199. var options = this.options;
  12200. if ( options.range ) {
  12201. if ( options.range === true ) {
  12202. if ( !options.values ) {
  12203. options.values = [ this._valueMin(), this._valueMin() ];
  12204. } else if ( options.values.length && options.values.length !== 2 ) {
  12205. options.values = [ options.values[ 0 ], options.values[ 0 ] ];
  12206. } else if ( $.isArray( options.values ) ) {
  12207. options.values = options.values.slice( 0 );
  12208. }
  12209. }
  12210. if ( !this.range || !this.range.length ) {
  12211. this.range = $( "<div>" )
  12212. .appendTo( this.element );
  12213. this._addClass( this.range, "ui-slider-range" );
  12214. } else {
  12215. this._removeClass( this.range, "ui-slider-range-min ui-slider-range-max" );
  12216. // Handle range switching from true to min/max
  12217. this.range.css( {
  12218. "left": "",
  12219. "bottom": ""
  12220. } );
  12221. }
  12222. if ( options.range === "min" || options.range === "max" ) {
  12223. this._addClass( this.range, "ui-slider-range-" + options.range );
  12224. }
  12225. } else {
  12226. if ( this.range ) {
  12227. this.range.remove();
  12228. }
  12229. this.range = null;
  12230. }
  12231. },
  12232. _setupEvents: function() {
  12233. this._off( this.handles );
  12234. this._on( this.handles, this._handleEvents );
  12235. this._hoverable( this.handles );
  12236. this._focusable( this.handles );
  12237. },
  12238. _destroy: function() {
  12239. this.handles.remove();
  12240. if ( this.range ) {
  12241. this.range.remove();
  12242. }
  12243. this._mouseDestroy();
  12244. },
  12245. _mouseCapture: function( event ) {
  12246. var position, normValue, distance, closestHandle, index, allowed, offset, mouseOverHandle,
  12247. that = this,
  12248. o = this.options;
  12249. if ( o.disabled ) {
  12250. return false;
  12251. }
  12252. this.elementSize = {
  12253. width: this.element.outerWidth(),
  12254. height: this.element.outerHeight()
  12255. };
  12256. this.elementOffset = this.element.offset();
  12257. position = { x: event.pageX, y: event.pageY };
  12258. normValue = this._normValueFromMouse( position );
  12259. distance = this._valueMax() - this._valueMin() + 1;
  12260. this.handles.each( function( i ) {
  12261. var thisDistance = Math.abs( normValue - that.values( i ) );
  12262. if ( ( distance > thisDistance ) ||
  12263. ( distance === thisDistance &&
  12264. ( i === that._lastChangedValue || that.values( i ) === o.min ) ) ) {
  12265. distance = thisDistance;
  12266. closestHandle = $( this );
  12267. index = i;
  12268. }
  12269. } );
  12270. allowed = this._start( event, index );
  12271. if ( allowed === false ) {
  12272. return false;
  12273. }
  12274. this._mouseSliding = true;
  12275. this._handleIndex = index;
  12276. this._addClass( closestHandle, null, "ui-state-active" );
  12277. closestHandle.trigger( "focus" );
  12278. offset = closestHandle.offset();
  12279. mouseOverHandle = !$( event.target ).parents().addBack().is( ".ui-slider-handle" );
  12280. this._clickOffset = mouseOverHandle ? { left: 0, top: 0 } : {
  12281. left: event.pageX - offset.left - ( closestHandle.width() / 2 ),
  12282. top: event.pageY - offset.top -
  12283. ( closestHandle.height() / 2 ) -
  12284. ( parseInt( closestHandle.css( "borderTopWidth" ), 10 ) || 0 ) -
  12285. ( parseInt( closestHandle.css( "borderBottomWidth" ), 10 ) || 0 ) +
  12286. ( parseInt( closestHandle.css( "marginTop" ), 10 ) || 0 )
  12287. };
  12288. if ( !this.handles.hasClass( "ui-state-hover" ) ) {
  12289. this._slide( event, index, normValue );
  12290. }
  12291. this._animateOff = true;
  12292. return true;
  12293. },
  12294. _mouseStart: function() {
  12295. return true;
  12296. },
  12297. _mouseDrag: function( event ) {
  12298. var position = { x: event.pageX, y: event.pageY },
  12299. normValue = this._normValueFromMouse( position );
  12300. this._slide( event, this._handleIndex, normValue );
  12301. return false;
  12302. },
  12303. _mouseStop: function( event ) {
  12304. this._removeClass( this.handles, null, "ui-state-active" );
  12305. this._mouseSliding = false;
  12306. this._stop( event, this._handleIndex );
  12307. this._change( event, this._handleIndex );
  12308. this._handleIndex = null;
  12309. this._clickOffset = null;
  12310. this._animateOff = false;
  12311. return false;
  12312. },
  12313. _detectOrientation: function() {
  12314. this.orientation = ( this.options.orientation === "vertical" ) ? "vertical" : "horizontal";
  12315. },
  12316. _normValueFromMouse: function( position ) {
  12317. var pixelTotal,
  12318. pixelMouse,
  12319. percentMouse,
  12320. valueTotal,
  12321. valueMouse;
  12322. if ( this.orientation === "horizontal" ) {
  12323. pixelTotal = this.elementSize.width;
  12324. pixelMouse = position.x - this.elementOffset.left -
  12325. ( this._clickOffset ? this._clickOffset.left : 0 );
  12326. } else {
  12327. pixelTotal = this.elementSize.height;
  12328. pixelMouse = position.y - this.elementOffset.top -
  12329. ( this._clickOffset ? this._clickOffset.top : 0 );
  12330. }
  12331. percentMouse = ( pixelMouse / pixelTotal );
  12332. if ( percentMouse > 1 ) {
  12333. percentMouse = 1;
  12334. }
  12335. if ( percentMouse < 0 ) {
  12336. percentMouse = 0;
  12337. }
  12338. if ( this.orientation === "vertical" ) {
  12339. percentMouse = 1 - percentMouse;
  12340. }
  12341. valueTotal = this._valueMax() - this._valueMin();
  12342. valueMouse = this._valueMin() + percentMouse * valueTotal;
  12343. return this._trimAlignValue( valueMouse );
  12344. },
  12345. _uiHash: function( index, value, values ) {
  12346. var uiHash = {
  12347. handle: this.handles[ index ],
  12348. handleIndex: index,
  12349. value: value !== undefined ? value : this.value()
  12350. };
  12351. if ( this._hasMultipleValues() ) {
  12352. uiHash.value = value !== undefined ? value : this.values( index );
  12353. uiHash.values = values || this.values();
  12354. }
  12355. return uiHash;
  12356. },
  12357. _hasMultipleValues: function() {
  12358. return this.options.values && this.options.values.length;
  12359. },
  12360. _start: function( event, index ) {
  12361. return this._trigger( "start", event, this._uiHash( index ) );
  12362. },
  12363. _slide: function( event, index, newVal ) {
  12364. var allowed, otherVal,
  12365. currentValue = this.value(),
  12366. newValues = this.values();
  12367. if ( this._hasMultipleValues() ) {
  12368. otherVal = this.values( index ? 0 : 1 );
  12369. currentValue = this.values( index );
  12370. if ( this.options.values.length === 2 && this.options.range === true ) {
  12371. newVal = index === 0 ? Math.min( otherVal, newVal ) : Math.max( otherVal, newVal );
  12372. }
  12373. newValues[ index ] = newVal;
  12374. }
  12375. if ( newVal === currentValue ) {
  12376. return;
  12377. }
  12378. allowed = this._trigger( "slide", event, this._uiHash( index, newVal, newValues ) );
  12379. // A slide can be canceled by returning false from the slide callback
  12380. if ( allowed === false ) {
  12381. return;
  12382. }
  12383. if ( this._hasMultipleValues() ) {
  12384. this.values( index, newVal );
  12385. } else {
  12386. this.value( newVal );
  12387. }
  12388. },
  12389. _stop: function( event, index ) {
  12390. this._trigger( "stop", event, this._uiHash( index ) );
  12391. },
  12392. _change: function( event, index ) {
  12393. if ( !this._keySliding && !this._mouseSliding ) {
  12394. //store the last changed value index for reference when handles overlap
  12395. this._lastChangedValue = index;
  12396. this._trigger( "change", event, this._uiHash( index ) );
  12397. }
  12398. },
  12399. value: function( newValue ) {
  12400. if ( arguments.length ) {
  12401. this.options.value = this._trimAlignValue( newValue );
  12402. this._refreshValue();
  12403. this._change( null, 0 );
  12404. return;
  12405. }
  12406. return this._value();
  12407. },
  12408. values: function( index, newValue ) {
  12409. var vals,
  12410. newValues,
  12411. i;
  12412. if ( arguments.length > 1 ) {
  12413. this.options.values[ index ] = this._trimAlignValue( newValue );
  12414. this._refreshValue();
  12415. this._change( null, index );
  12416. return;
  12417. }
  12418. if ( arguments.length ) {
  12419. if ( $.isArray( arguments[ 0 ] ) ) {
  12420. vals = this.options.values;
  12421. newValues = arguments[ 0 ];
  12422. for ( i = 0; i < vals.length; i += 1 ) {
  12423. vals[ i ] = this._trimAlignValue( newValues[ i ] );
  12424. this._change( null, i );
  12425. }
  12426. this._refreshValue();
  12427. } else {
  12428. if ( this._hasMultipleValues() ) {
  12429. return this._values( index );
  12430. } else {
  12431. return this.value();
  12432. }
  12433. }
  12434. } else {
  12435. return this._values();
  12436. }
  12437. },
  12438. _setOption: function( key, value ) {
  12439. var i,
  12440. valsLength = 0;
  12441. if ( key === "range" && this.options.range === true ) {
  12442. if ( value === "min" ) {
  12443. this.options.value = this._values( 0 );
  12444. this.options.values = null;
  12445. } else if ( value === "max" ) {
  12446. this.options.value = this._values( this.options.values.length - 1 );
  12447. this.options.values = null;
  12448. }
  12449. }
  12450. if ( $.isArray( this.options.values ) ) {
  12451. valsLength = this.options.values.length;
  12452. }
  12453. this._super( key, value );
  12454. switch ( key ) {
  12455. case "orientation":
  12456. this._detectOrientation();
  12457. this._removeClass( "ui-slider-horizontal ui-slider-vertical" )
  12458. ._addClass( "ui-slider-" + this.orientation );
  12459. this._refreshValue();
  12460. if ( this.options.range ) {
  12461. this._refreshRange( value );
  12462. }
  12463. // Reset positioning from previous orientation
  12464. this.handles.css( value === "horizontal" ? "bottom" : "left", "" );
  12465. break;
  12466. case "value":
  12467. this._animateOff = true;
  12468. this._refreshValue();
  12469. this._change( null, 0 );
  12470. this._animateOff = false;
  12471. break;
  12472. case "values":
  12473. this._animateOff = true;
  12474. this._refreshValue();
  12475. // Start from the last handle to prevent unreachable handles (#9046)
  12476. for ( i = valsLength - 1; i >= 0; i-- ) {
  12477. this._change( null, i );
  12478. }
  12479. this._animateOff = false;
  12480. break;
  12481. case "step":
  12482. case "min":
  12483. case "max":
  12484. this._animateOff = true;
  12485. this._calculateNewMax();
  12486. this._refreshValue();
  12487. this._animateOff = false;
  12488. break;
  12489. case "range":
  12490. this._animateOff = true;
  12491. this._refresh();
  12492. this._animateOff = false;
  12493. break;
  12494. }
  12495. },
  12496. _setOptionDisabled: function( value ) {
  12497. this._super( value );
  12498. this._toggleClass( null, "ui-state-disabled", !!value );
  12499. },
  12500. //internal value getter
  12501. // _value() returns value trimmed by min and max, aligned by step
  12502. _value: function() {
  12503. var val = this.options.value;
  12504. val = this._trimAlignValue( val );
  12505. return val;
  12506. },
  12507. //internal values getter
  12508. // _values() returns array of values trimmed by min and max, aligned by step
  12509. // _values( index ) returns single value trimmed by min and max, aligned by step
  12510. _values: function( index ) {
  12511. var val,
  12512. vals,
  12513. i;
  12514. if ( arguments.length ) {
  12515. val = this.options.values[ index ];
  12516. val = this._trimAlignValue( val );
  12517. return val;
  12518. } else if ( this._hasMultipleValues() ) {
  12519. // .slice() creates a copy of the array
  12520. // this copy gets trimmed by min and max and then returned
  12521. vals = this.options.values.slice();
  12522. for ( i = 0; i < vals.length; i += 1 ) {
  12523. vals[ i ] = this._trimAlignValue( vals[ i ] );
  12524. }
  12525. return vals;
  12526. } else {
  12527. return [];
  12528. }
  12529. },
  12530. // Returns the step-aligned value that val is closest to, between (inclusive) min and max
  12531. _trimAlignValue: function( val ) {
  12532. if ( val <= this._valueMin() ) {
  12533. return this._valueMin();
  12534. }
  12535. if ( val >= this._valueMax() ) {
  12536. return this._valueMax();
  12537. }
  12538. var step = ( this.options.step > 0 ) ? this.options.step : 1,
  12539. valModStep = ( val - this._valueMin() ) % step,
  12540. alignValue = val - valModStep;
  12541. if ( Math.abs( valModStep ) * 2 >= step ) {
  12542. alignValue += ( valModStep > 0 ) ? step : ( -step );
  12543. }
  12544. // Since JavaScript has problems with large floats, round
  12545. // the final value to 5 digits after the decimal point (see #4124)
  12546. return parseFloat( alignValue.toFixed( 5 ) );
  12547. },
  12548. _calculateNewMax: function() {
  12549. var max = this.options.max,
  12550. min = this._valueMin(),
  12551. step = this.options.step,
  12552. aboveMin = Math.round( ( max - min ) / step ) * step;
  12553. max = aboveMin + min;
  12554. if ( max > this.options.max ) {
  12555. //If max is not divisible by step, rounding off may increase its value
  12556. max -= step;
  12557. }
  12558. this.max = parseFloat( max.toFixed( this._precision() ) );
  12559. },
  12560. _precision: function() {
  12561. var precision = this._precisionOf( this.options.step );
  12562. if ( this.options.min !== null ) {
  12563. precision = Math.max( precision, this._precisionOf( this.options.min ) );
  12564. }
  12565. return precision;
  12566. },
  12567. _precisionOf: function( num ) {
  12568. var str = num.toString(),
  12569. decimal = str.indexOf( "." );
  12570. return decimal === -1 ? 0 : str.length - decimal - 1;
  12571. },
  12572. _valueMin: function() {
  12573. return this.options.min;
  12574. },
  12575. _valueMax: function() {
  12576. return this.max;
  12577. },
  12578. _refreshRange: function( orientation ) {
  12579. if ( orientation === "vertical" ) {
  12580. this.range.css( { "width": "", "left": "" } );
  12581. }
  12582. if ( orientation === "horizontal" ) {
  12583. this.range.css( { "height": "", "bottom": "" } );
  12584. }
  12585. },
  12586. _refreshValue: function() {
  12587. var lastValPercent, valPercent, value, valueMin, valueMax,
  12588. oRange = this.options.range,
  12589. o = this.options,
  12590. that = this,
  12591. animate = ( !this._animateOff ) ? o.animate : false,
  12592. _set = {};
  12593. if ( this._hasMultipleValues() ) {
  12594. this.handles.each( function( i ) {
  12595. valPercent = ( that.values( i ) - that._valueMin() ) / ( that._valueMax() -
  12596. that._valueMin() ) * 100;
  12597. _set[ that.orientation === "horizontal" ? "left" : "bottom" ] = valPercent + "%";
  12598. $( this ).stop( 1, 1 )[ animate ? "animate" : "css" ]( _set, o.animate );
  12599. if ( that.options.range === true ) {
  12600. if ( that.orientation === "horizontal" ) {
  12601. if ( i === 0 ) {
  12602. that.range.stop( 1, 1 )[ animate ? "animate" : "css" ]( {
  12603. left: valPercent + "%"
  12604. }, o.animate );
  12605. }
  12606. if ( i === 1 ) {
  12607. that.range[ animate ? "animate" : "css" ]( {
  12608. width: ( valPercent - lastValPercent ) + "%"
  12609. }, {
  12610. queue: false,
  12611. duration: o.animate
  12612. } );
  12613. }
  12614. } else {
  12615. if ( i === 0 ) {
  12616. that.range.stop( 1, 1 )[ animate ? "animate" : "css" ]( {
  12617. bottom: ( valPercent ) + "%"
  12618. }, o.animate );
  12619. }
  12620. if ( i === 1 ) {
  12621. that.range[ animate ? "animate" : "css" ]( {
  12622. height: ( valPercent - lastValPercent ) + "%"
  12623. }, {
  12624. queue: false,
  12625. duration: o.animate
  12626. } );
  12627. }
  12628. }
  12629. }
  12630. lastValPercent = valPercent;
  12631. } );
  12632. } else {
  12633. value = this.value();
  12634. valueMin = this._valueMin();
  12635. valueMax = this._valueMax();
  12636. valPercent = ( valueMax !== valueMin ) ?
  12637. ( value - valueMin ) / ( valueMax - valueMin ) * 100 :
  12638. 0;
  12639. _set[ this.orientation === "horizontal" ? "left" : "bottom" ] = valPercent + "%";
  12640. this.handle.stop( 1, 1 )[ animate ? "animate" : "css" ]( _set, o.animate );
  12641. if ( oRange === "min" && this.orientation === "horizontal" ) {
  12642. this.range.stop( 1, 1 )[ animate ? "animate" : "css" ]( {
  12643. width: valPercent + "%"
  12644. }, o.animate );
  12645. }
  12646. if ( oRange === "max" && this.orientation === "horizontal" ) {
  12647. this.range.stop( 1, 1 )[ animate ? "animate" : "css" ]( {
  12648. width: ( 100 - valPercent ) + "%"
  12649. }, o.animate );
  12650. }
  12651. if ( oRange === "min" && this.orientation === "vertical" ) {
  12652. this.range.stop( 1, 1 )[ animate ? "animate" : "css" ]( {
  12653. height: valPercent + "%"
  12654. }, o.animate );
  12655. }
  12656. if ( oRange === "max" && this.orientation === "vertical" ) {
  12657. this.range.stop( 1, 1 )[ animate ? "animate" : "css" ]( {
  12658. height: ( 100 - valPercent ) + "%"
  12659. }, o.animate );
  12660. }
  12661. }
  12662. },
  12663. _handleEvents: {
  12664. keydown: function( event ) {
  12665. var allowed, curVal, newVal, step,
  12666. index = $( event.target ).data( "ui-slider-handle-index" );
  12667. switch ( event.keyCode ) {
  12668. case $.ui.keyCode.HOME:
  12669. case $.ui.keyCode.END:
  12670. case $.ui.keyCode.PAGE_UP:
  12671. case $.ui.keyCode.PAGE_DOWN:
  12672. case $.ui.keyCode.UP:
  12673. case $.ui.keyCode.RIGHT:
  12674. case $.ui.keyCode.DOWN:
  12675. case $.ui.keyCode.LEFT:
  12676. event.preventDefault();
  12677. if ( !this._keySliding ) {
  12678. this._keySliding = true;
  12679. this._addClass( $( event.target ), null, "ui-state-active" );
  12680. allowed = this._start( event, index );
  12681. if ( allowed === false ) {
  12682. return;
  12683. }
  12684. }
  12685. break;
  12686. }
  12687. step = this.options.step;
  12688. if ( this._hasMultipleValues() ) {
  12689. curVal = newVal = this.values( index );
  12690. } else {
  12691. curVal = newVal = this.value();
  12692. }
  12693. switch ( event.keyCode ) {
  12694. case $.ui.keyCode.HOME:
  12695. newVal = this._valueMin();
  12696. break;
  12697. case $.ui.keyCode.END:
  12698. newVal = this._valueMax();
  12699. break;
  12700. case $.ui.keyCode.PAGE_UP:
  12701. newVal = this._trimAlignValue(
  12702. curVal + ( ( this._valueMax() - this._valueMin() ) / this.numPages )
  12703. );
  12704. break;
  12705. case $.ui.keyCode.PAGE_DOWN:
  12706. newVal = this._trimAlignValue(
  12707. curVal - ( ( this._valueMax() - this._valueMin() ) / this.numPages ) );
  12708. break;
  12709. case $.ui.keyCode.UP:
  12710. case $.ui.keyCode.RIGHT:
  12711. if ( curVal === this._valueMax() ) {
  12712. return;
  12713. }
  12714. newVal = this._trimAlignValue( curVal + step );
  12715. break;
  12716. case $.ui.keyCode.DOWN:
  12717. case $.ui.keyCode.LEFT:
  12718. if ( curVal === this._valueMin() ) {
  12719. return;
  12720. }
  12721. newVal = this._trimAlignValue( curVal - step );
  12722. break;
  12723. }
  12724. this._slide( event, index, newVal );
  12725. },
  12726. keyup: function( event ) {
  12727. var index = $( event.target ).data( "ui-slider-handle-index" );
  12728. if ( this._keySliding ) {
  12729. this._keySliding = false;
  12730. this._stop( event, index );
  12731. this._change( event, index );
  12732. this._removeClass( $( event.target ), null, "ui-state-active" );
  12733. }
  12734. }
  12735. }
  12736. } );
  12737. /*!
  12738. * jQuery UI Sortable 1.12.0
  12739. * http://jqueryui.com
  12740. *
  12741. * Copyright jQuery Foundation and other contributors
  12742. * Released under the MIT license.
  12743. * http://jquery.org/license
  12744. */
  12745. //>>label: Sortable
  12746. //>>group: Interactions
  12747. //>>description: Enables items in a list to be sorted using the mouse.
  12748. //>>docs: http://api.jqueryui.com/sortable/
  12749. //>>demos: http://jqueryui.com/sortable/
  12750. //>>css.structure: ../../themes/base/sortable.css
  12751. var widgetsSortable = $.widget( "ui.sortable", $.ui.mouse, {
  12752. version: "1.12.0",
  12753. widgetEventPrefix: "sort",
  12754. ready: false,
  12755. options: {
  12756. appendTo: "parent",
  12757. axis: false,
  12758. connectWith: false,
  12759. containment: false,
  12760. cursor: "auto",
  12761. cursorAt: false,
  12762. dropOnEmpty: true,
  12763. forcePlaceholderSize: false,
  12764. forceHelperSize: false,
  12765. grid: false,
  12766. handle: false,
  12767. helper: "original",
  12768. items: "> *",
  12769. opacity: false,
  12770. placeholder: false,
  12771. revert: false,
  12772. scroll: true,
  12773. scrollSensitivity: 20,
  12774. scrollSpeed: 20,
  12775. scope: "default",
  12776. tolerance: "intersect",
  12777. zIndex: 1000,
  12778. // Callbacks
  12779. activate: null,
  12780. beforeStop: null,
  12781. change: null,
  12782. deactivate: null,
  12783. out: null,
  12784. over: null,
  12785. receive: null,
  12786. remove: null,
  12787. sort: null,
  12788. start: null,
  12789. stop: null,
  12790. update: null
  12791. },
  12792. _isOverAxis: function( x, reference, size ) {
  12793. return ( x >= reference ) && ( x < ( reference + size ) );
  12794. },
  12795. _isFloating: function( item ) {
  12796. return ( /left|right/ ).test( item.css( "float" ) ) ||
  12797. ( /inline|table-cell/ ).test( item.css( "display" ) );
  12798. },
  12799. _create: function() {
  12800. this.containerCache = {};
  12801. this._addClass( "ui-sortable" );
  12802. //Get the items
  12803. this.refresh();
  12804. //Let's determine the parent's offset
  12805. this.offset = this.element.offset();
  12806. //Initialize mouse events for interaction
  12807. this._mouseInit();
  12808. this._setHandleClassName();
  12809. //We're ready to go
  12810. this.ready = true;
  12811. },
  12812. _setOption: function( key, value ) {
  12813. this._super( key, value );
  12814. if ( key === "handle" ) {
  12815. this._setHandleClassName();
  12816. }
  12817. },
  12818. _setHandleClassName: function() {
  12819. var that = this;
  12820. this._removeClass( this.element.find( ".ui-sortable-handle" ), "ui-sortable-handle" );
  12821. $.each( this.items, function() {
  12822. that._addClass(
  12823. this.instance.options.handle ?
  12824. this.item.find( this.instance.options.handle ) :
  12825. this.item,
  12826. "ui-sortable-handle"
  12827. );
  12828. } );
  12829. },
  12830. _destroy: function() {
  12831. this._mouseDestroy();
  12832. for ( var i = this.items.length - 1; i >= 0; i-- ) {
  12833. this.items[ i ].item.removeData( this.widgetName + "-item" );
  12834. }
  12835. return this;
  12836. },
  12837. _mouseCapture: function( event, overrideHandle ) {
  12838. var currentItem = null,
  12839. validHandle = false,
  12840. that = this;
  12841. if ( this.reverting ) {
  12842. return false;
  12843. }
  12844. if ( this.options.disabled || this.options.type === "static" ) {
  12845. return false;
  12846. }
  12847. //We have to refresh the items data once first
  12848. this._refreshItems( event );
  12849. //Find out if the clicked node (or one of its parents) is a actual item in this.items
  12850. $( event.target ).parents().each( function() {
  12851. if ( $.data( this, that.widgetName + "-item" ) === that ) {
  12852. currentItem = $( this );
  12853. return false;
  12854. }
  12855. } );
  12856. if ( $.data( event.target, that.widgetName + "-item" ) === that ) {
  12857. currentItem = $( event.target );
  12858. }
  12859. if ( !currentItem ) {
  12860. return false;
  12861. }
  12862. if ( this.options.handle && !overrideHandle ) {
  12863. $( this.options.handle, currentItem ).find( "*" ).addBack().each( function() {
  12864. if ( this === event.target ) {
  12865. validHandle = true;
  12866. }
  12867. } );
  12868. if ( !validHandle ) {
  12869. return false;
  12870. }
  12871. }
  12872. this.currentItem = currentItem;
  12873. this._removeCurrentsFromItems();
  12874. return true;
  12875. },
  12876. _mouseStart: function( event, overrideHandle, noActivation ) {
  12877. var i, body,
  12878. o = this.options;
  12879. this.currentContainer = this;
  12880. //We only need to call refreshPositions, because the refreshItems call has been moved to
  12881. // mouseCapture
  12882. this.refreshPositions();
  12883. //Create and append the visible helper
  12884. this.helper = this._createHelper( event );
  12885. //Cache the helper size
  12886. this._cacheHelperProportions();
  12887. /*
  12888. * - Position generation -
  12889. * This block generates everything position related - it's the core of draggables.
  12890. */
  12891. //Cache the margins of the original element
  12892. this._cacheMargins();
  12893. //Get the next scrolling parent
  12894. this.scrollParent = this.helper.scrollParent();
  12895. //The element's absolute position on the page minus margins
  12896. this.offset = this.currentItem.offset();
  12897. this.offset = {
  12898. top: this.offset.top - this.margins.top,
  12899. left: this.offset.left - this.margins.left
  12900. };
  12901. $.extend( this.offset, {
  12902. click: { //Where the click happened, relative to the element
  12903. left: event.pageX - this.offset.left,
  12904. top: event.pageY - this.offset.top
  12905. },
  12906. parent: this._getParentOffset(),
  12907. // This is a relative to absolute position minus the actual position calculation -
  12908. // only used for relative positioned helper
  12909. relative: this._getRelativeOffset()
  12910. } );
  12911. // Only after we got the offset, we can change the helper's position to absolute
  12912. // TODO: Still need to figure out a way to make relative sorting possible
  12913. this.helper.css( "position", "absolute" );
  12914. this.cssPosition = this.helper.css( "position" );
  12915. //Generate the original position
  12916. this.originalPosition = this._generatePosition( event );
  12917. this.originalPageX = event.pageX;
  12918. this.originalPageY = event.pageY;
  12919. //Adjust the mouse offset relative to the helper if "cursorAt" is supplied
  12920. ( o.cursorAt && this._adjustOffsetFromHelper( o.cursorAt ) );
  12921. //Cache the former DOM position
  12922. this.domPosition = {
  12923. prev: this.currentItem.prev()[ 0 ],
  12924. parent: this.currentItem.parent()[ 0 ]
  12925. };
  12926. // If the helper is not the original, hide the original so it's not playing any role during
  12927. // the drag, won't cause anything bad this way
  12928. if ( this.helper[ 0 ] !== this.currentItem[ 0 ] ) {
  12929. this.currentItem.hide();
  12930. }
  12931. //Create the placeholder
  12932. this._createPlaceholder();
  12933. //Set a containment if given in the options
  12934. if ( o.containment ) {
  12935. this._setContainment();
  12936. }
  12937. if ( o.cursor && o.cursor !== "auto" ) { // cursor option
  12938. body = this.document.find( "body" );
  12939. // Support: IE
  12940. this.storedCursor = body.css( "cursor" );
  12941. body.css( "cursor", o.cursor );
  12942. this.storedStylesheet =
  12943. $( "<style>*{ cursor: " + o.cursor + " !important; }</style>" ).appendTo( body );
  12944. }
  12945. if ( o.opacity ) { // opacity option
  12946. if ( this.helper.css( "opacity" ) ) {
  12947. this._storedOpacity = this.helper.css( "opacity" );
  12948. }
  12949. this.helper.css( "opacity", o.opacity );
  12950. }
  12951. if ( o.zIndex ) { // zIndex option
  12952. if ( this.helper.css( "zIndex" ) ) {
  12953. this._storedZIndex = this.helper.css( "zIndex" );
  12954. }
  12955. this.helper.css( "zIndex", o.zIndex );
  12956. }
  12957. //Prepare scrolling
  12958. if ( this.scrollParent[ 0 ] !== this.document[ 0 ] &&
  12959. this.scrollParent[ 0 ].tagName !== "HTML" ) {
  12960. this.overflowOffset = this.scrollParent.offset();
  12961. }
  12962. //Call callbacks
  12963. this._trigger( "start", event, this._uiHash() );
  12964. //Recache the helper size
  12965. if ( !this._preserveHelperProportions ) {
  12966. this._cacheHelperProportions();
  12967. }
  12968. //Post "activate" events to possible containers
  12969. if ( !noActivation ) {
  12970. for ( i = this.containers.length - 1; i >= 0; i-- ) {
  12971. this.containers[ i ]._trigger( "activate", event, this._uiHash( this ) );
  12972. }
  12973. }
  12974. //Prepare possible droppables
  12975. if ( $.ui.ddmanager ) {
  12976. $.ui.ddmanager.current = this;
  12977. }
  12978. if ( $.ui.ddmanager && !o.dropBehaviour ) {
  12979. $.ui.ddmanager.prepareOffsets( this, event );
  12980. }
  12981. this.dragging = true;
  12982. this._addClass( this.helper, "ui-sortable-helper" );
  12983. // Execute the drag once - this causes the helper not to be visiblebefore getting its
  12984. // correct position
  12985. this._mouseDrag( event );
  12986. return true;
  12987. },
  12988. _mouseDrag: function( event ) {
  12989. var i, item, itemElement, intersection,
  12990. o = this.options,
  12991. scrolled = false;
  12992. //Compute the helpers position
  12993. this.position = this._generatePosition( event );
  12994. this.positionAbs = this._convertPositionTo( "absolute" );
  12995. if ( !this.lastPositionAbs ) {
  12996. this.lastPositionAbs = this.positionAbs;
  12997. }
  12998. //Do scrolling
  12999. if ( this.options.scroll ) {
  13000. if ( this.scrollParent[ 0 ] !== this.document[ 0 ] &&
  13001. this.scrollParent[ 0 ].tagName !== "HTML" ) {
  13002. if ( ( this.overflowOffset.top + this.scrollParent[ 0 ].offsetHeight ) -
  13003. event.pageY < o.scrollSensitivity ) {
  13004. this.scrollParent[ 0 ].scrollTop =
  13005. scrolled = this.scrollParent[ 0 ].scrollTop + o.scrollSpeed;
  13006. } else if ( event.pageY - this.overflowOffset.top < o.scrollSensitivity ) {
  13007. this.scrollParent[ 0 ].scrollTop =
  13008. scrolled = this.scrollParent[ 0 ].scrollTop - o.scrollSpeed;
  13009. }
  13010. if ( ( this.overflowOffset.left + this.scrollParent[ 0 ].offsetWidth ) -
  13011. event.pageX < o.scrollSensitivity ) {
  13012. this.scrollParent[ 0 ].scrollLeft = scrolled =
  13013. this.scrollParent[ 0 ].scrollLeft + o.scrollSpeed;
  13014. } else if ( event.pageX - this.overflowOffset.left < o.scrollSensitivity ) {
  13015. this.scrollParent[ 0 ].scrollLeft = scrolled =
  13016. this.scrollParent[ 0 ].scrollLeft - o.scrollSpeed;
  13017. }
  13018. } else {
  13019. if ( event.pageY - this.document.scrollTop() < o.scrollSensitivity ) {
  13020. scrolled = this.document.scrollTop( this.document.scrollTop() - o.scrollSpeed );
  13021. } else if ( this.window.height() - ( event.pageY - this.document.scrollTop() ) <
  13022. o.scrollSensitivity ) {
  13023. scrolled = this.document.scrollTop( this.document.scrollTop() + o.scrollSpeed );
  13024. }
  13025. if ( event.pageX - this.document.scrollLeft() < o.scrollSensitivity ) {
  13026. scrolled = this.document.scrollLeft(
  13027. this.document.scrollLeft() - o.scrollSpeed
  13028. );
  13029. } else if ( this.window.width() - ( event.pageX - this.document.scrollLeft() ) <
  13030. o.scrollSensitivity ) {
  13031. scrolled = this.document.scrollLeft(
  13032. this.document.scrollLeft() + o.scrollSpeed
  13033. );
  13034. }
  13035. }
  13036. if ( scrolled !== false && $.ui.ddmanager && !o.dropBehaviour ) {
  13037. $.ui.ddmanager.prepareOffsets( this, event );
  13038. }
  13039. }
  13040. //Regenerate the absolute position used for position checks
  13041. this.positionAbs = this._convertPositionTo( "absolute" );
  13042. //Set the helper position
  13043. if ( !this.options.axis || this.options.axis !== "y" ) {
  13044. this.helper[ 0 ].style.left = this.position.left + "px";
  13045. }
  13046. if ( !this.options.axis || this.options.axis !== "x" ) {
  13047. this.helper[ 0 ].style.top = this.position.top + "px";
  13048. }
  13049. //Rearrange
  13050. for ( i = this.items.length - 1; i >= 0; i-- ) {
  13051. //Cache variables and intersection, continue if no intersection
  13052. item = this.items[ i ];
  13053. itemElement = item.item[ 0 ];
  13054. intersection = this._intersectsWithPointer( item );
  13055. if ( !intersection ) {
  13056. continue;
  13057. }
  13058. // Only put the placeholder inside the current Container, skip all
  13059. // items from other containers. This works because when moving
  13060. // an item from one container to another the
  13061. // currentContainer is switched before the placeholder is moved.
  13062. //
  13063. // Without this, moving items in "sub-sortables" can cause
  13064. // the placeholder to jitter between the outer and inner container.
  13065. if ( item.instance !== this.currentContainer ) {
  13066. continue;
  13067. }
  13068. // Cannot intersect with itself
  13069. // no useless actions that have been done before
  13070. // no action if the item moved is the parent of the item checked
  13071. if ( itemElement !== this.currentItem[ 0 ] &&
  13072. this.placeholder[ intersection === 1 ? "next" : "prev" ]()[ 0 ] !== itemElement &&
  13073. !$.contains( this.placeholder[ 0 ], itemElement ) &&
  13074. ( this.options.type === "semi-dynamic" ?
  13075. !$.contains( this.element[ 0 ], itemElement ) :
  13076. true
  13077. )
  13078. ) {
  13079. this.direction = intersection === 1 ? "down" : "up";
  13080. if ( this.options.tolerance === "pointer" || this._intersectsWithSides( item ) ) {
  13081. this._rearrange( event, item );
  13082. } else {
  13083. break;
  13084. }
  13085. this._trigger( "change", event, this._uiHash() );
  13086. break;
  13087. }
  13088. }
  13089. //Post events to containers
  13090. this._contactContainers( event );
  13091. //Interconnect with droppables
  13092. if ( $.ui.ddmanager ) {
  13093. $.ui.ddmanager.drag( this, event );
  13094. }
  13095. //Call callbacks
  13096. this._trigger( "sort", event, this._uiHash() );
  13097. this.lastPositionAbs = this.positionAbs;
  13098. return false;
  13099. },
  13100. _mouseStop: function( event, noPropagation ) {
  13101. if ( !event ) {
  13102. return;
  13103. }
  13104. //If we are using droppables, inform the manager about the drop
  13105. if ( $.ui.ddmanager && !this.options.dropBehaviour ) {
  13106. $.ui.ddmanager.drop( this, event );
  13107. }
  13108. if ( this.options.revert ) {
  13109. var that = this,
  13110. cur = this.placeholder.offset(),
  13111. axis = this.options.axis,
  13112. animation = {};
  13113. if ( !axis || axis === "x" ) {
  13114. animation.left = cur.left - this.offset.parent.left - this.margins.left +
  13115. ( this.offsetParent[ 0 ] === this.document[ 0 ].body ?
  13116. 0 :
  13117. this.offsetParent[ 0 ].scrollLeft
  13118. );
  13119. }
  13120. if ( !axis || axis === "y" ) {
  13121. animation.top = cur.top - this.offset.parent.top - this.margins.top +
  13122. ( this.offsetParent[ 0 ] === this.document[ 0 ].body ?
  13123. 0 :
  13124. this.offsetParent[ 0 ].scrollTop
  13125. );
  13126. }
  13127. this.reverting = true;
  13128. $( this.helper ).animate(
  13129. animation,
  13130. parseInt( this.options.revert, 10 ) || 500,
  13131. function() {
  13132. that._clear( event );
  13133. }
  13134. );
  13135. } else {
  13136. this._clear( event, noPropagation );
  13137. }
  13138. return false;
  13139. },
  13140. cancel: function() {
  13141. if ( this.dragging ) {
  13142. this._mouseUp( { target: null } );
  13143. if ( this.options.helper === "original" ) {
  13144. this.currentItem.css( this._storedCSS );
  13145. this._removeClass( this.currentItem, "ui-sortable-helper" );
  13146. } else {
  13147. this.currentItem.show();
  13148. }
  13149. //Post deactivating events to containers
  13150. for ( var i = this.containers.length - 1; i >= 0; i-- ) {
  13151. this.containers[ i ]._trigger( "deactivate", null, this._uiHash( this ) );
  13152. if ( this.containers[ i ].containerCache.over ) {
  13153. this.containers[ i ]._trigger( "out", null, this._uiHash( this ) );
  13154. this.containers[ i ].containerCache.over = 0;
  13155. }
  13156. }
  13157. }
  13158. if ( this.placeholder ) {
  13159. //$(this.placeholder[0]).remove(); would have been the jQuery way - unfortunately,
  13160. // it unbinds ALL events from the original node!
  13161. if ( this.placeholder[ 0 ].parentNode ) {
  13162. this.placeholder[ 0 ].parentNode.removeChild( this.placeholder[ 0 ] );
  13163. }
  13164. if ( this.options.helper !== "original" && this.helper &&
  13165. this.helper[ 0 ].parentNode ) {
  13166. this.helper.remove();
  13167. }
  13168. $.extend( this, {
  13169. helper: null,
  13170. dragging: false,
  13171. reverting: false,
  13172. _noFinalSort: null
  13173. } );
  13174. if ( this.domPosition.prev ) {
  13175. $( this.domPosition.prev ).after( this.currentItem );
  13176. } else {
  13177. $( this.domPosition.parent ).prepend( this.currentItem );
  13178. }
  13179. }
  13180. return this;
  13181. },
  13182. serialize: function( o ) {
  13183. var items = this._getItemsAsjQuery( o && o.connected ),
  13184. str = [];
  13185. o = o || {};
  13186. $( items ).each( function() {
  13187. var res = ( $( o.item || this ).attr( o.attribute || "id" ) || "" )
  13188. .match( o.expression || ( /(.+)[\-=_](.+)/ ) );
  13189. if ( res ) {
  13190. str.push(
  13191. ( o.key || res[ 1 ] + "[]" ) +
  13192. "=" + ( o.key && o.expression ? res[ 1 ] : res[ 2 ] ) );
  13193. }
  13194. } );
  13195. if ( !str.length && o.key ) {
  13196. str.push( o.key + "=" );
  13197. }
  13198. return str.join( "&" );
  13199. },
  13200. toArray: function( o ) {
  13201. var items = this._getItemsAsjQuery( o && o.connected ),
  13202. ret = [];
  13203. o = o || {};
  13204. items.each( function() {
  13205. ret.push( $( o.item || this ).attr( o.attribute || "id" ) || "" );
  13206. } );
  13207. return ret;
  13208. },
  13209. /* Be careful with the following core functions */
  13210. _intersectsWith: function( item ) {
  13211. var x1 = this.positionAbs.left,
  13212. x2 = x1 + this.helperProportions.width,
  13213. y1 = this.positionAbs.top,
  13214. y2 = y1 + this.helperProportions.height,
  13215. l = item.left,
  13216. r = l + item.width,
  13217. t = item.top,
  13218. b = t + item.height,
  13219. dyClick = this.offset.click.top,
  13220. dxClick = this.offset.click.left,
  13221. isOverElementHeight = ( this.options.axis === "x" ) || ( ( y1 + dyClick ) > t &&
  13222. ( y1 + dyClick ) < b ),
  13223. isOverElementWidth = ( this.options.axis === "y" ) || ( ( x1 + dxClick ) > l &&
  13224. ( x1 + dxClick ) < r ),
  13225. isOverElement = isOverElementHeight && isOverElementWidth;
  13226. if ( this.options.tolerance === "pointer" ||
  13227. this.options.forcePointerForContainers ||
  13228. ( this.options.tolerance !== "pointer" &&
  13229. this.helperProportions[ this.floating ? "width" : "height" ] >
  13230. item[ this.floating ? "width" : "height" ] )
  13231. ) {
  13232. return isOverElement;
  13233. } else {
  13234. return ( l < x1 + ( this.helperProportions.width / 2 ) && // Right Half
  13235. x2 - ( this.helperProportions.width / 2 ) < r && // Left Half
  13236. t < y1 + ( this.helperProportions.height / 2 ) && // Bottom Half
  13237. y2 - ( this.helperProportions.height / 2 ) < b ); // Top Half
  13238. }
  13239. },
  13240. _intersectsWithPointer: function( item ) {
  13241. var verticalDirection, horizontalDirection,
  13242. isOverElementHeight = ( this.options.axis === "x" ) ||
  13243. this._isOverAxis(
  13244. this.positionAbs.top + this.offset.click.top, item.top, item.height ),
  13245. isOverElementWidth = ( this.options.axis === "y" ) ||
  13246. this._isOverAxis(
  13247. this.positionAbs.left + this.offset.click.left, item.left, item.width ),
  13248. isOverElement = isOverElementHeight && isOverElementWidth;
  13249. if ( !isOverElement ) {
  13250. return false;
  13251. }
  13252. verticalDirection = this._getDragVerticalDirection();
  13253. horizontalDirection = this._getDragHorizontalDirection();
  13254. return this.floating ?
  13255. ( ( horizontalDirection === "right" || verticalDirection === "down" ) ? 2 : 1 )
  13256. : ( verticalDirection && ( verticalDirection === "down" ? 2 : 1 ) );
  13257. },
  13258. _intersectsWithSides: function( item ) {
  13259. var isOverBottomHalf = this._isOverAxis( this.positionAbs.top +
  13260. this.offset.click.top, item.top + ( item.height / 2 ), item.height ),
  13261. isOverRightHalf = this._isOverAxis( this.positionAbs.left +
  13262. this.offset.click.left, item.left + ( item.width / 2 ), item.width ),
  13263. verticalDirection = this._getDragVerticalDirection(),
  13264. horizontalDirection = this._getDragHorizontalDirection();
  13265. if ( this.floating && horizontalDirection ) {
  13266. return ( ( horizontalDirection === "right" && isOverRightHalf ) ||
  13267. ( horizontalDirection === "left" && !isOverRightHalf ) );
  13268. } else {
  13269. return verticalDirection && ( ( verticalDirection === "down" && isOverBottomHalf ) ||
  13270. ( verticalDirection === "up" && !isOverBottomHalf ) );
  13271. }
  13272. },
  13273. _getDragVerticalDirection: function() {
  13274. var delta = this.positionAbs.top - this.lastPositionAbs.top;
  13275. return delta !== 0 && ( delta > 0 ? "down" : "up" );
  13276. },
  13277. _getDragHorizontalDirection: function() {
  13278. var delta = this.positionAbs.left - this.lastPositionAbs.left;
  13279. return delta !== 0 && ( delta > 0 ? "right" : "left" );
  13280. },
  13281. refresh: function( event ) {
  13282. this._refreshItems( event );
  13283. this._setHandleClassName();
  13284. this.refreshPositions();
  13285. return this;
  13286. },
  13287. _connectWith: function() {
  13288. var options = this.options;
  13289. return options.connectWith.constructor === String ?
  13290. [ options.connectWith ] :
  13291. options.connectWith;
  13292. },
  13293. _getItemsAsjQuery: function( connected ) {
  13294. var i, j, cur, inst,
  13295. items = [],
  13296. queries = [],
  13297. connectWith = this._connectWith();
  13298. if ( connectWith && connected ) {
  13299. for ( i = connectWith.length - 1; i >= 0; i-- ) {
  13300. cur = $( connectWith[ i ], this.document[ 0 ] );
  13301. for ( j = cur.length - 1; j >= 0; j-- ) {
  13302. inst = $.data( cur[ j ], this.widgetFullName );
  13303. if ( inst && inst !== this && !inst.options.disabled ) {
  13304. queries.push( [ $.isFunction( inst.options.items ) ?
  13305. inst.options.items.call( inst.element ) :
  13306. $( inst.options.items, inst.element )
  13307. .not( ".ui-sortable-helper" )
  13308. .not( ".ui-sortable-placeholder" ), inst ] );
  13309. }
  13310. }
  13311. }
  13312. }
  13313. queries.push( [ $.isFunction( this.options.items ) ?
  13314. this.options.items
  13315. .call( this.element, null, { options: this.options, item: this.currentItem } ) :
  13316. $( this.options.items, this.element )
  13317. .not( ".ui-sortable-helper" )
  13318. .not( ".ui-sortable-placeholder" ), this ] );
  13319. function addItems() {
  13320. items.push( this );
  13321. }
  13322. for ( i = queries.length - 1; i >= 0; i-- ) {
  13323. queries[ i ][ 0 ].each( addItems );
  13324. }
  13325. return $( items );
  13326. },
  13327. _removeCurrentsFromItems: function() {
  13328. var list = this.currentItem.find( ":data(" + this.widgetName + "-item)" );
  13329. this.items = $.grep( this.items, function( item ) {
  13330. for ( var j = 0; j < list.length; j++ ) {
  13331. if ( list[ j ] === item.item[ 0 ] ) {
  13332. return false;
  13333. }
  13334. }
  13335. return true;
  13336. } );
  13337. },
  13338. _refreshItems: function( event ) {
  13339. this.items = [];
  13340. this.containers = [ this ];
  13341. var i, j, cur, inst, targetData, _queries, item, queriesLength,
  13342. items = this.items,
  13343. queries = [ [ $.isFunction( this.options.items ) ?
  13344. this.options.items.call( this.element[ 0 ], event, { item: this.currentItem } ) :
  13345. $( this.options.items, this.element ), this ] ],
  13346. connectWith = this._connectWith();
  13347. //Shouldn't be run the first time through due to massive slow-down
  13348. if ( connectWith && this.ready ) {
  13349. for ( i = connectWith.length - 1; i >= 0; i-- ) {
  13350. cur = $( connectWith[ i ], this.document[ 0 ] );
  13351. for ( j = cur.length - 1; j >= 0; j-- ) {
  13352. inst = $.data( cur[ j ], this.widgetFullName );
  13353. if ( inst && inst !== this && !inst.options.disabled ) {
  13354. queries.push( [ $.isFunction( inst.options.items ) ?
  13355. inst.options.items
  13356. .call( inst.element[ 0 ], event, { item: this.currentItem } ) :
  13357. $( inst.options.items, inst.element ), inst ] );
  13358. this.containers.push( inst );
  13359. }
  13360. }
  13361. }
  13362. }
  13363. for ( i = queries.length - 1; i >= 0; i-- ) {
  13364. targetData = queries[ i ][ 1 ];
  13365. _queries = queries[ i ][ 0 ];
  13366. for ( j = 0, queriesLength = _queries.length; j < queriesLength; j++ ) {
  13367. item = $( _queries[ j ] );
  13368. // Data for target checking (mouse manager)
  13369. item.data( this.widgetName + "-item", targetData );
  13370. items.push( {
  13371. item: item,
  13372. instance: targetData,
  13373. width: 0, height: 0,
  13374. left: 0, top: 0
  13375. } );
  13376. }
  13377. }
  13378. },
  13379. refreshPositions: function( fast ) {
  13380. // Determine whether items are being displayed horizontally
  13381. this.floating = this.items.length ?
  13382. this.options.axis === "x" || this._isFloating( this.items[ 0 ].item ) :
  13383. false;
  13384. //This has to be redone because due to the item being moved out/into the offsetParent,
  13385. // the offsetParent's position will change
  13386. if ( this.offsetParent && this.helper ) {
  13387. this.offset.parent = this._getParentOffset();
  13388. }
  13389. var i, item, t, p;
  13390. for ( i = this.items.length - 1; i >= 0; i-- ) {
  13391. item = this.items[ i ];
  13392. //We ignore calculating positions of all connected containers when we're not over them
  13393. if ( item.instance !== this.currentContainer && this.currentContainer &&
  13394. item.item[ 0 ] !== this.currentItem[ 0 ] ) {
  13395. continue;
  13396. }
  13397. t = this.options.toleranceElement ?
  13398. $( this.options.toleranceElement, item.item ) :
  13399. item.item;
  13400. if ( !fast ) {
  13401. item.width = t.outerWidth();
  13402. item.height = t.outerHeight();
  13403. }
  13404. p = t.offset();
  13405. item.left = p.left;
  13406. item.top = p.top;
  13407. }
  13408. if ( this.options.custom && this.options.custom.refreshContainers ) {
  13409. this.options.custom.refreshContainers.call( this );
  13410. } else {
  13411. for ( i = this.containers.length - 1; i >= 0; i-- ) {
  13412. p = this.containers[ i ].element.offset();
  13413. this.containers[ i ].containerCache.left = p.left;
  13414. this.containers[ i ].containerCache.top = p.top;
  13415. this.containers[ i ].containerCache.width =
  13416. this.containers[ i ].element.outerWidth();
  13417. this.containers[ i ].containerCache.height =
  13418. this.containers[ i ].element.outerHeight();
  13419. }
  13420. }
  13421. return this;
  13422. },
  13423. _createPlaceholder: function( that ) {
  13424. that = that || this;
  13425. var className,
  13426. o = that.options;
  13427. if ( !o.placeholder || o.placeholder.constructor === String ) {
  13428. className = o.placeholder;
  13429. o.placeholder = {
  13430. element: function() {
  13431. var nodeName = that.currentItem[ 0 ].nodeName.toLowerCase(),
  13432. element = $( "<" + nodeName + ">", that.document[ 0 ] );
  13433. that._addClass( element, "ui-sortable-placeholder",
  13434. className || that.currentItem[ 0 ].className )
  13435. ._removeClass( element, "ui-sortable-helper" );
  13436. if ( nodeName === "tbody" ) {
  13437. that._createTrPlaceholder(
  13438. that.currentItem.find( "tr" ).eq( 0 ),
  13439. $( "<tr>", that.document[ 0 ] ).appendTo( element )
  13440. );
  13441. } else if ( nodeName === "tr" ) {
  13442. that._createTrPlaceholder( that.currentItem, element );
  13443. } else if ( nodeName === "img" ) {
  13444. element.attr( "src", that.currentItem.attr( "src" ) );
  13445. }
  13446. if ( !className ) {
  13447. element.css( "visibility", "hidden" );
  13448. }
  13449. return element;
  13450. },
  13451. update: function( container, p ) {
  13452. // 1. If a className is set as 'placeholder option, we don't force sizes -
  13453. // the class is responsible for that
  13454. // 2. The option 'forcePlaceholderSize can be enabled to force it even if a
  13455. // class name is specified
  13456. if ( className && !o.forcePlaceholderSize ) {
  13457. return;
  13458. }
  13459. //If the element doesn't have a actual height by itself (without styles coming
  13460. // from a stylesheet), it receives the inline height from the dragged item
  13461. if ( !p.height() ) {
  13462. p.height(
  13463. that.currentItem.innerHeight() -
  13464. parseInt( that.currentItem.css( "paddingTop" ) || 0, 10 ) -
  13465. parseInt( that.currentItem.css( "paddingBottom" ) || 0, 10 ) );
  13466. }
  13467. if ( !p.width() ) {
  13468. p.width(
  13469. that.currentItem.innerWidth() -
  13470. parseInt( that.currentItem.css( "paddingLeft" ) || 0, 10 ) -
  13471. parseInt( that.currentItem.css( "paddingRight" ) || 0, 10 ) );
  13472. }
  13473. }
  13474. };
  13475. }
  13476. //Create the placeholder
  13477. that.placeholder = $( o.placeholder.element.call( that.element, that.currentItem ) );
  13478. //Append it after the actual current item
  13479. that.currentItem.after( that.placeholder );
  13480. //Update the size of the placeholder (TODO: Logic to fuzzy, see line 316/317)
  13481. o.placeholder.update( that, that.placeholder );
  13482. },
  13483. _createTrPlaceholder: function( sourceTr, targetTr ) {
  13484. var that = this;
  13485. sourceTr.children().each( function() {
  13486. $( "<td>&#160;</td>", that.document[ 0 ] )
  13487. .attr( "colspan", $( this ).attr( "colspan" ) || 1 )
  13488. .appendTo( targetTr );
  13489. } );
  13490. },
  13491. _contactContainers: function( event ) {
  13492. var i, j, dist, itemWithLeastDistance, posProperty, sizeProperty, cur, nearBottom,
  13493. floating, axis,
  13494. innermostContainer = null,
  13495. innermostIndex = null;
  13496. // Get innermost container that intersects with item
  13497. for ( i = this.containers.length - 1; i >= 0; i-- ) {
  13498. // Never consider a container that's located within the item itself
  13499. if ( $.contains( this.currentItem[ 0 ], this.containers[ i ].element[ 0 ] ) ) {
  13500. continue;
  13501. }
  13502. if ( this._intersectsWith( this.containers[ i ].containerCache ) ) {
  13503. // If we've already found a container and it's more "inner" than this, then continue
  13504. if ( innermostContainer &&
  13505. $.contains(
  13506. this.containers[ i ].element[ 0 ],
  13507. innermostContainer.element[ 0 ] ) ) {
  13508. continue;
  13509. }
  13510. innermostContainer = this.containers[ i ];
  13511. innermostIndex = i;
  13512. } else {
  13513. // container doesn't intersect. trigger "out" event if necessary
  13514. if ( this.containers[ i ].containerCache.over ) {
  13515. this.containers[ i ]._trigger( "out", event, this._uiHash( this ) );
  13516. this.containers[ i ].containerCache.over = 0;
  13517. }
  13518. }
  13519. }
  13520. // If no intersecting containers found, return
  13521. if ( !innermostContainer ) {
  13522. return;
  13523. }
  13524. // Move the item into the container if it's not there already
  13525. if ( this.containers.length === 1 ) {
  13526. if ( !this.containers[ innermostIndex ].containerCache.over ) {
  13527. this.containers[ innermostIndex ]._trigger( "over", event, this._uiHash( this ) );
  13528. this.containers[ innermostIndex ].containerCache.over = 1;
  13529. }
  13530. } else {
  13531. // When entering a new container, we will find the item with the least distance and
  13532. // append our item near it
  13533. dist = 10000;
  13534. itemWithLeastDistance = null;
  13535. floating = innermostContainer.floating || this._isFloating( this.currentItem );
  13536. posProperty = floating ? "left" : "top";
  13537. sizeProperty = floating ? "width" : "height";
  13538. axis = floating ? "pageX" : "pageY";
  13539. for ( j = this.items.length - 1; j >= 0; j-- ) {
  13540. if ( !$.contains(
  13541. this.containers[ innermostIndex ].element[ 0 ], this.items[ j ].item[ 0 ] )
  13542. ) {
  13543. continue;
  13544. }
  13545. if ( this.items[ j ].item[ 0 ] === this.currentItem[ 0 ] ) {
  13546. continue;
  13547. }
  13548. cur = this.items[ j ].item.offset()[ posProperty ];
  13549. nearBottom = false;
  13550. if ( event[ axis ] - cur > this.items[ j ][ sizeProperty ] / 2 ) {
  13551. nearBottom = true;
  13552. }
  13553. if ( Math.abs( event[ axis ] - cur ) < dist ) {
  13554. dist = Math.abs( event[ axis ] - cur );
  13555. itemWithLeastDistance = this.items[ j ];
  13556. this.direction = nearBottom ? "up" : "down";
  13557. }
  13558. }
  13559. //Check if dropOnEmpty is enabled
  13560. if ( !itemWithLeastDistance && !this.options.dropOnEmpty ) {
  13561. return;
  13562. }
  13563. if ( this.currentContainer === this.containers[ innermostIndex ] ) {
  13564. if ( !this.currentContainer.containerCache.over ) {
  13565. this.containers[ innermostIndex ]._trigger( "over", event, this._uiHash() );
  13566. this.currentContainer.containerCache.over = 1;
  13567. }
  13568. return;
  13569. }
  13570. itemWithLeastDistance ?
  13571. this._rearrange( event, itemWithLeastDistance, null, true ) :
  13572. this._rearrange( event, null, this.containers[ innermostIndex ].element, true );
  13573. this._trigger( "change", event, this._uiHash() );
  13574. this.containers[ innermostIndex ]._trigger( "change", event, this._uiHash( this ) );
  13575. this.currentContainer = this.containers[ innermostIndex ];
  13576. //Update the placeholder
  13577. this.options.placeholder.update( this.currentContainer, this.placeholder );
  13578. this.containers[ innermostIndex ]._trigger( "over", event, this._uiHash( this ) );
  13579. this.containers[ innermostIndex ].containerCache.over = 1;
  13580. }
  13581. },
  13582. _createHelper: function( event ) {
  13583. var o = this.options,
  13584. helper = $.isFunction( o.helper ) ?
  13585. $( o.helper.apply( this.element[ 0 ], [ event, this.currentItem ] ) ) :
  13586. ( o.helper === "clone" ? this.currentItem.clone() : this.currentItem );
  13587. //Add the helper to the DOM if that didn't happen already
  13588. if ( !helper.parents( "body" ).length ) {
  13589. $( o.appendTo !== "parent" ?
  13590. o.appendTo :
  13591. this.currentItem[ 0 ].parentNode )[ 0 ].appendChild( helper[ 0 ] );
  13592. }
  13593. if ( helper[ 0 ] === this.currentItem[ 0 ] ) {
  13594. this._storedCSS = {
  13595. width: this.currentItem[ 0 ].style.width,
  13596. height: this.currentItem[ 0 ].style.height,
  13597. position: this.currentItem.css( "position" ),
  13598. top: this.currentItem.css( "top" ),
  13599. left: this.currentItem.css( "left" )
  13600. };
  13601. }
  13602. if ( !helper[ 0 ].style.width || o.forceHelperSize ) {
  13603. helper.width( this.currentItem.width() );
  13604. }
  13605. if ( !helper[ 0 ].style.height || o.forceHelperSize ) {
  13606. helper.height( this.currentItem.height() );
  13607. }
  13608. return helper;
  13609. },
  13610. _adjustOffsetFromHelper: function( obj ) {
  13611. if ( typeof obj === "string" ) {
  13612. obj = obj.split( " " );
  13613. }
  13614. if ( $.isArray( obj ) ) {
  13615. obj = { left: +obj[ 0 ], top: +obj[ 1 ] || 0 };
  13616. }
  13617. if ( "left" in obj ) {
  13618. this.offset.click.left = obj.left + this.margins.left;
  13619. }
  13620. if ( "right" in obj ) {
  13621. this.offset.click.left = this.helperProportions.width - obj.right + this.margins.left;
  13622. }
  13623. if ( "top" in obj ) {
  13624. this.offset.click.top = obj.top + this.margins.top;
  13625. }
  13626. if ( "bottom" in obj ) {
  13627. this.offset.click.top = this.helperProportions.height - obj.bottom + this.margins.top;
  13628. }
  13629. },
  13630. _getParentOffset: function() {
  13631. //Get the offsetParent and cache its position
  13632. this.offsetParent = this.helper.offsetParent();
  13633. var po = this.offsetParent.offset();
  13634. // This is a special case where we need to modify a offset calculated on start, since the
  13635. // following happened:
  13636. // 1. The position of the helper is absolute, so it's position is calculated based on the
  13637. // next positioned parent
  13638. // 2. The actual offset parent is a child of the scroll parent, and the scroll parent isn't
  13639. // the document, which means that the scroll is included in the initial calculation of the
  13640. // offset of the parent, and never recalculated upon drag
  13641. if ( this.cssPosition === "absolute" && this.scrollParent[ 0 ] !== this.document[ 0 ] &&
  13642. $.contains( this.scrollParent[ 0 ], this.offsetParent[ 0 ] ) ) {
  13643. po.left += this.scrollParent.scrollLeft();
  13644. po.top += this.scrollParent.scrollTop();
  13645. }
  13646. // This needs to be actually done for all browsers, since pageX/pageY includes this
  13647. // information with an ugly IE fix
  13648. if ( this.offsetParent[ 0 ] === this.document[ 0 ].body ||
  13649. ( this.offsetParent[ 0 ].tagName &&
  13650. this.offsetParent[ 0 ].tagName.toLowerCase() === "html" && $.ui.ie ) ) {
  13651. po = { top: 0, left: 0 };
  13652. }
  13653. return {
  13654. top: po.top + ( parseInt( this.offsetParent.css( "borderTopWidth" ), 10 ) || 0 ),
  13655. left: po.left + ( parseInt( this.offsetParent.css( "borderLeftWidth" ), 10 ) || 0 )
  13656. };
  13657. },
  13658. _getRelativeOffset: function() {
  13659. if ( this.cssPosition === "relative" ) {
  13660. var p = this.currentItem.position();
  13661. return {
  13662. top: p.top - ( parseInt( this.helper.css( "top" ), 10 ) || 0 ) +
  13663. this.scrollParent.scrollTop(),
  13664. left: p.left - ( parseInt( this.helper.css( "left" ), 10 ) || 0 ) +
  13665. this.scrollParent.scrollLeft()
  13666. };
  13667. } else {
  13668. return { top: 0, left: 0 };
  13669. }
  13670. },
  13671. _cacheMargins: function() {
  13672. this.margins = {
  13673. left: ( parseInt( this.currentItem.css( "marginLeft" ), 10 ) || 0 ),
  13674. top: ( parseInt( this.currentItem.css( "marginTop" ), 10 ) || 0 )
  13675. };
  13676. },
  13677. _cacheHelperProportions: function() {
  13678. this.helperProportions = {
  13679. width: this.helper.outerWidth(),
  13680. height: this.helper.outerHeight()
  13681. };
  13682. },
  13683. _setContainment: function() {
  13684. var ce, co, over,
  13685. o = this.options;
  13686. if ( o.containment === "parent" ) {
  13687. o.containment = this.helper[ 0 ].parentNode;
  13688. }
  13689. if ( o.containment === "document" || o.containment === "window" ) {
  13690. this.containment = [
  13691. 0 - this.offset.relative.left - this.offset.parent.left,
  13692. 0 - this.offset.relative.top - this.offset.parent.top,
  13693. o.containment === "document" ?
  13694. this.document.width() :
  13695. this.window.width() - this.helperProportions.width - this.margins.left,
  13696. ( o.containment === "document" ?
  13697. ( this.document.height() || document.body.parentNode.scrollHeight ) :
  13698. this.window.height() || this.document[ 0 ].body.parentNode.scrollHeight
  13699. ) - this.helperProportions.height - this.margins.top
  13700. ];
  13701. }
  13702. if ( !( /^(document|window|parent)$/ ).test( o.containment ) ) {
  13703. ce = $( o.containment )[ 0 ];
  13704. co = $( o.containment ).offset();
  13705. over = ( $( ce ).css( "overflow" ) !== "hidden" );
  13706. this.containment = [
  13707. co.left + ( parseInt( $( ce ).css( "borderLeftWidth" ), 10 ) || 0 ) +
  13708. ( parseInt( $( ce ).css( "paddingLeft" ), 10 ) || 0 ) - this.margins.left,
  13709. co.top + ( parseInt( $( ce ).css( "borderTopWidth" ), 10 ) || 0 ) +
  13710. ( parseInt( $( ce ).css( "paddingTop" ), 10 ) || 0 ) - this.margins.top,
  13711. co.left + ( over ? Math.max( ce.scrollWidth, ce.offsetWidth ) : ce.offsetWidth ) -
  13712. ( parseInt( $( ce ).css( "borderLeftWidth" ), 10 ) || 0 ) -
  13713. ( parseInt( $( ce ).css( "paddingRight" ), 10 ) || 0 ) -
  13714. this.helperProportions.width - this.margins.left,
  13715. co.top + ( over ? Math.max( ce.scrollHeight, ce.offsetHeight ) : ce.offsetHeight ) -
  13716. ( parseInt( $( ce ).css( "borderTopWidth" ), 10 ) || 0 ) -
  13717. ( parseInt( $( ce ).css( "paddingBottom" ), 10 ) || 0 ) -
  13718. this.helperProportions.height - this.margins.top
  13719. ];
  13720. }
  13721. },
  13722. _convertPositionTo: function( d, pos ) {
  13723. if ( !pos ) {
  13724. pos = this.position;
  13725. }
  13726. var mod = d === "absolute" ? 1 : -1,
  13727. scroll = this.cssPosition === "absolute" &&
  13728. !( this.scrollParent[ 0 ] !== this.document[ 0 ] &&
  13729. $.contains( this.scrollParent[ 0 ], this.offsetParent[ 0 ] ) ) ?
  13730. this.offsetParent :
  13731. this.scrollParent,
  13732. scrollIsRootNode = ( /(html|body)/i ).test( scroll[ 0 ].tagName );
  13733. return {
  13734. top: (
  13735. // The absolute mouse position
  13736. pos.top +
  13737. // Only for relative positioned nodes: Relative offset from element to offset parent
  13738. this.offset.relative.top * mod +
  13739. // The offsetParent's offset without borders (offset + border)
  13740. this.offset.parent.top * mod -
  13741. ( ( this.cssPosition === "fixed" ?
  13742. -this.scrollParent.scrollTop() :
  13743. ( scrollIsRootNode ? 0 : scroll.scrollTop() ) ) * mod )
  13744. ),
  13745. left: (
  13746. // The absolute mouse position
  13747. pos.left +
  13748. // Only for relative positioned nodes: Relative offset from element to offset parent
  13749. this.offset.relative.left * mod +
  13750. // The offsetParent's offset without borders (offset + border)
  13751. this.offset.parent.left * mod -
  13752. ( ( this.cssPosition === "fixed" ?
  13753. -this.scrollParent.scrollLeft() : scrollIsRootNode ? 0 :
  13754. scroll.scrollLeft() ) * mod )
  13755. )
  13756. };
  13757. },
  13758. _generatePosition: function( event ) {
  13759. var top, left,
  13760. o = this.options,
  13761. pageX = event.pageX,
  13762. pageY = event.pageY,
  13763. scroll = this.cssPosition === "absolute" &&
  13764. !( this.scrollParent[ 0 ] !== this.document[ 0 ] &&
  13765. $.contains( this.scrollParent[ 0 ], this.offsetParent[ 0 ] ) ) ?
  13766. this.offsetParent :
  13767. this.scrollParent,
  13768. scrollIsRootNode = ( /(html|body)/i ).test( scroll[ 0 ].tagName );
  13769. // This is another very weird special case that only happens for relative elements:
  13770. // 1. If the css position is relative
  13771. // 2. and the scroll parent is the document or similar to the offset parent
  13772. // we have to refresh the relative offset during the scroll so there are no jumps
  13773. if ( this.cssPosition === "relative" && !( this.scrollParent[ 0 ] !== this.document[ 0 ] &&
  13774. this.scrollParent[ 0 ] !== this.offsetParent[ 0 ] ) ) {
  13775. this.offset.relative = this._getRelativeOffset();
  13776. }
  13777. /*
  13778. * - Position constraining -
  13779. * Constrain the position to a mix of grid, containment.
  13780. */
  13781. if ( this.originalPosition ) { //If we are not dragging yet, we won't check for options
  13782. if ( this.containment ) {
  13783. if ( event.pageX - this.offset.click.left < this.containment[ 0 ] ) {
  13784. pageX = this.containment[ 0 ] + this.offset.click.left;
  13785. }
  13786. if ( event.pageY - this.offset.click.top < this.containment[ 1 ] ) {
  13787. pageY = this.containment[ 1 ] + this.offset.click.top;
  13788. }
  13789. if ( event.pageX - this.offset.click.left > this.containment[ 2 ] ) {
  13790. pageX = this.containment[ 2 ] + this.offset.click.left;
  13791. }
  13792. if ( event.pageY - this.offset.click.top > this.containment[ 3 ] ) {
  13793. pageY = this.containment[ 3 ] + this.offset.click.top;
  13794. }
  13795. }
  13796. if ( o.grid ) {
  13797. top = this.originalPageY + Math.round( ( pageY - this.originalPageY ) /
  13798. o.grid[ 1 ] ) * o.grid[ 1 ];
  13799. pageY = this.containment ?
  13800. ( ( top - this.offset.click.top >= this.containment[ 1 ] &&
  13801. top - this.offset.click.top <= this.containment[ 3 ] ) ?
  13802. top :
  13803. ( ( top - this.offset.click.top >= this.containment[ 1 ] ) ?
  13804. top - o.grid[ 1 ] : top + o.grid[ 1 ] ) ) :
  13805. top;
  13806. left = this.originalPageX + Math.round( ( pageX - this.originalPageX ) /
  13807. o.grid[ 0 ] ) * o.grid[ 0 ];
  13808. pageX = this.containment ?
  13809. ( ( left - this.offset.click.left >= this.containment[ 0 ] &&
  13810. left - this.offset.click.left <= this.containment[ 2 ] ) ?
  13811. left :
  13812. ( ( left - this.offset.click.left >= this.containment[ 0 ] ) ?
  13813. left - o.grid[ 0 ] : left + o.grid[ 0 ] ) ) :
  13814. left;
  13815. }
  13816. }
  13817. return {
  13818. top: (
  13819. // The absolute mouse position
  13820. pageY -
  13821. // Click offset (relative to the element)
  13822. this.offset.click.top -
  13823. // Only for relative positioned nodes: Relative offset from element to offset parent
  13824. this.offset.relative.top -
  13825. // The offsetParent's offset without borders (offset + border)
  13826. this.offset.parent.top +
  13827. ( ( this.cssPosition === "fixed" ?
  13828. -this.scrollParent.scrollTop() :
  13829. ( scrollIsRootNode ? 0 : scroll.scrollTop() ) ) )
  13830. ),
  13831. left: (
  13832. // The absolute mouse position
  13833. pageX -
  13834. // Click offset (relative to the element)
  13835. this.offset.click.left -
  13836. // Only for relative positioned nodes: Relative offset from element to offset parent
  13837. this.offset.relative.left -
  13838. // The offsetParent's offset without borders (offset + border)
  13839. this.offset.parent.left +
  13840. ( ( this.cssPosition === "fixed" ?
  13841. -this.scrollParent.scrollLeft() :
  13842. scrollIsRootNode ? 0 : scroll.scrollLeft() ) )
  13843. )
  13844. };
  13845. },
  13846. _rearrange: function( event, i, a, hardRefresh ) {
  13847. a ? a[ 0 ].appendChild( this.placeholder[ 0 ] ) :
  13848. i.item[ 0 ].parentNode.insertBefore( this.placeholder[ 0 ],
  13849. ( this.direction === "down" ? i.item[ 0 ] : i.item[ 0 ].nextSibling ) );
  13850. //Various things done here to improve the performance:
  13851. // 1. we create a setTimeout, that calls refreshPositions
  13852. // 2. on the instance, we have a counter variable, that get's higher after every append
  13853. // 3. on the local scope, we copy the counter variable, and check in the timeout,
  13854. // if it's still the same
  13855. // 4. this lets only the last addition to the timeout stack through
  13856. this.counter = this.counter ? ++this.counter : 1;
  13857. var counter = this.counter;
  13858. this._delay( function() {
  13859. if ( counter === this.counter ) {
  13860. //Precompute after each DOM insertion, NOT on mousemove
  13861. this.refreshPositions( !hardRefresh );
  13862. }
  13863. } );
  13864. },
  13865. _clear: function( event, noPropagation ) {
  13866. this.reverting = false;
  13867. // We delay all events that have to be triggered to after the point where the placeholder
  13868. // has been removed and everything else normalized again
  13869. var i,
  13870. delayedTriggers = [];
  13871. // We first have to update the dom position of the actual currentItem
  13872. // Note: don't do it if the current item is already removed (by a user), or it gets
  13873. // reappended (see #4088)
  13874. if ( !this._noFinalSort && this.currentItem.parent().length ) {
  13875. this.placeholder.before( this.currentItem );
  13876. }
  13877. this._noFinalSort = null;
  13878. if ( this.helper[ 0 ] === this.currentItem[ 0 ] ) {
  13879. for ( i in this._storedCSS ) {
  13880. if ( this._storedCSS[ i ] === "auto" || this._storedCSS[ i ] === "static" ) {
  13881. this._storedCSS[ i ] = "";
  13882. }
  13883. }
  13884. this.currentItem.css( this._storedCSS );
  13885. this._removeClass( this.currentItem, "ui-sortable-helper" );
  13886. } else {
  13887. this.currentItem.show();
  13888. }
  13889. if ( this.fromOutside && !noPropagation ) {
  13890. delayedTriggers.push( function( event ) {
  13891. this._trigger( "receive", event, this._uiHash( this.fromOutside ) );
  13892. } );
  13893. }
  13894. if ( ( this.fromOutside ||
  13895. this.domPosition.prev !==
  13896. this.currentItem.prev().not( ".ui-sortable-helper" )[ 0 ] ||
  13897. this.domPosition.parent !== this.currentItem.parent()[ 0 ] ) && !noPropagation ) {
  13898. // Trigger update callback if the DOM position has changed
  13899. delayedTriggers.push( function( event ) {
  13900. this._trigger( "update", event, this._uiHash() );
  13901. } );
  13902. }
  13903. // Check if the items Container has Changed and trigger appropriate
  13904. // events.
  13905. if ( this !== this.currentContainer ) {
  13906. if ( !noPropagation ) {
  13907. delayedTriggers.push( function( event ) {
  13908. this._trigger( "remove", event, this._uiHash() );
  13909. } );
  13910. delayedTriggers.push( ( function( c ) {
  13911. return function( event ) {
  13912. c._trigger( "receive", event, this._uiHash( this ) );
  13913. };
  13914. } ).call( this, this.currentContainer ) );
  13915. delayedTriggers.push( ( function( c ) {
  13916. return function( event ) {
  13917. c._trigger( "update", event, this._uiHash( this ) );
  13918. };
  13919. } ).call( this, this.currentContainer ) );
  13920. }
  13921. }
  13922. //Post events to containers
  13923. function delayEvent( type, instance, container ) {
  13924. return function( event ) {
  13925. container._trigger( type, event, instance._uiHash( instance ) );
  13926. };
  13927. }
  13928. for ( i = this.containers.length - 1; i >= 0; i-- ) {
  13929. if ( !noPropagation ) {
  13930. delayedTriggers.push( delayEvent( "deactivate", this, this.containers[ i ] ) );
  13931. }
  13932. if ( this.containers[ i ].containerCache.over ) {
  13933. delayedTriggers.push( delayEvent( "out", this, this.containers[ i ] ) );
  13934. this.containers[ i ].containerCache.over = 0;
  13935. }
  13936. }
  13937. //Do what was originally in plugins
  13938. if ( this.storedCursor ) {
  13939. this.document.find( "body" ).css( "cursor", this.storedCursor );
  13940. this.storedStylesheet.remove();
  13941. }
  13942. if ( this._storedOpacity ) {
  13943. this.helper.css( "opacity", this._storedOpacity );
  13944. }
  13945. if ( this._storedZIndex ) {
  13946. this.helper.css( "zIndex", this._storedZIndex === "auto" ? "" : this._storedZIndex );
  13947. }
  13948. this.dragging = false;
  13949. if ( !noPropagation ) {
  13950. this._trigger( "beforeStop", event, this._uiHash() );
  13951. }
  13952. //$(this.placeholder[0]).remove(); would have been the jQuery way - unfortunately,
  13953. // it unbinds ALL events from the original node!
  13954. this.placeholder[ 0 ].parentNode.removeChild( this.placeholder[ 0 ] );
  13955. if ( !this.cancelHelperRemoval ) {
  13956. if ( this.helper[ 0 ] !== this.currentItem[ 0 ] ) {
  13957. this.helper.remove();
  13958. }
  13959. this.helper = null;
  13960. }
  13961. if ( !noPropagation ) {
  13962. for ( i = 0; i < delayedTriggers.length; i++ ) {
  13963. // Trigger all delayed events
  13964. delayedTriggers[ i ].call( this, event );
  13965. }
  13966. this._trigger( "stop", event, this._uiHash() );
  13967. }
  13968. this.fromOutside = false;
  13969. return !this.cancelHelperRemoval;
  13970. },
  13971. _trigger: function() {
  13972. if ( $.Widget.prototype._trigger.apply( this, arguments ) === false ) {
  13973. this.cancel();
  13974. }
  13975. },
  13976. _uiHash: function( _inst ) {
  13977. var inst = _inst || this;
  13978. return {
  13979. helper: inst.helper,
  13980. placeholder: inst.placeholder || $( [] ),
  13981. position: inst.position,
  13982. originalPosition: inst.originalPosition,
  13983. offset: inst.positionAbs,
  13984. item: inst.currentItem,
  13985. sender: _inst ? _inst.element : null
  13986. };
  13987. }
  13988. } );
  13989. /*!
  13990. * jQuery UI Spinner 1.12.0
  13991. * http://jqueryui.com
  13992. *
  13993. * Copyright jQuery Foundation and other contributors
  13994. * Released under the MIT license.
  13995. * http://jquery.org/license
  13996. */
  13997. //>>label: Spinner
  13998. //>>group: Widgets
  13999. //>>description: Displays buttons to easily input numbers via the keyboard or mouse.
  14000. //>>docs: http://api.jqueryui.com/spinner/
  14001. //>>demos: http://jqueryui.com/spinner/
  14002. //>>css.structure: ../../themes/base/core.css
  14003. //>>css.structure: ../../themes/base/spinner.css
  14004. //>>css.theme: ../../themes/base/theme.css
  14005. function spinnerModifer( fn ) {
  14006. return function() {
  14007. var previous = this.element.val();
  14008. fn.apply( this, arguments );
  14009. this._refresh();
  14010. if ( previous !== this.element.val() ) {
  14011. this._trigger( "change" );
  14012. }
  14013. };
  14014. }
  14015. $.widget( "ui.spinner", {
  14016. version: "1.12.0",
  14017. defaultElement: "<input>",
  14018. widgetEventPrefix: "spin",
  14019. options: {
  14020. classes: {
  14021. "ui-spinner": "ui-corner-all",
  14022. "ui-spinner-down": "ui-corner-br",
  14023. "ui-spinner-up": "ui-corner-tr"
  14024. },
  14025. culture: null,
  14026. icons: {
  14027. down: "ui-icon-triangle-1-s",
  14028. up: "ui-icon-triangle-1-n"
  14029. },
  14030. incremental: true,
  14031. max: null,
  14032. min: null,
  14033. numberFormat: null,
  14034. page: 10,
  14035. step: 1,
  14036. change: null,
  14037. spin: null,
  14038. start: null,
  14039. stop: null
  14040. },
  14041. _create: function() {
  14042. // handle string values that need to be parsed
  14043. this._setOption( "max", this.options.max );
  14044. this._setOption( "min", this.options.min );
  14045. this._setOption( "step", this.options.step );
  14046. // Only format if there is a value, prevents the field from being marked
  14047. // as invalid in Firefox, see #9573.
  14048. if ( this.value() !== "" ) {
  14049. // Format the value, but don't constrain.
  14050. this._value( this.element.val(), true );
  14051. }
  14052. this._draw();
  14053. this._on( this._events );
  14054. this._refresh();
  14055. // Turning off autocomplete prevents the browser from remembering the
  14056. // value when navigating through history, so we re-enable autocomplete
  14057. // if the page is unloaded before the widget is destroyed. #7790
  14058. this._on( this.window, {
  14059. beforeunload: function() {
  14060. this.element.removeAttr( "autocomplete" );
  14061. }
  14062. } );
  14063. },
  14064. _getCreateOptions: function() {
  14065. var options = this._super();
  14066. var element = this.element;
  14067. $.each( [ "min", "max", "step" ], function( i, option ) {
  14068. var value = element.attr( option );
  14069. if ( value != null && value.length ) {
  14070. options[ option ] = value;
  14071. }
  14072. } );
  14073. return options;
  14074. },
  14075. _events: {
  14076. keydown: function( event ) {
  14077. if ( this._start( event ) && this._keydown( event ) ) {
  14078. event.preventDefault();
  14079. }
  14080. },
  14081. keyup: "_stop",
  14082. focus: function() {
  14083. this.previous = this.element.val();
  14084. },
  14085. blur: function( event ) {
  14086. if ( this.cancelBlur ) {
  14087. delete this.cancelBlur;
  14088. return;
  14089. }
  14090. this._stop();
  14091. this._refresh();
  14092. if ( this.previous !== this.element.val() ) {
  14093. this._trigger( "change", event );
  14094. }
  14095. },
  14096. mousewheel: function( event, delta ) {
  14097. if ( !delta ) {
  14098. return;
  14099. }
  14100. if ( !this.spinning && !this._start( event ) ) {
  14101. return false;
  14102. }
  14103. this._spin( ( delta > 0 ? 1 : -1 ) * this.options.step, event );
  14104. clearTimeout( this.mousewheelTimer );
  14105. this.mousewheelTimer = this._delay( function() {
  14106. if ( this.spinning ) {
  14107. this._stop( event );
  14108. }
  14109. }, 100 );
  14110. event.preventDefault();
  14111. },
  14112. "mousedown .ui-spinner-button": function( event ) {
  14113. var previous;
  14114. // We never want the buttons to have focus; whenever the user is
  14115. // interacting with the spinner, the focus should be on the input.
  14116. // If the input is focused then this.previous is properly set from
  14117. // when the input first received focus. If the input is not focused
  14118. // then we need to set this.previous based on the value before spinning.
  14119. previous = this.element[ 0 ] === $.ui.safeActiveElement( this.document[ 0 ] ) ?
  14120. this.previous : this.element.val();
  14121. function checkFocus() {
  14122. var isActive = this.element[ 0 ] === $.ui.safeActiveElement( this.document[ 0 ] );
  14123. if ( !isActive ) {
  14124. this.element.trigger( "focus" );
  14125. this.previous = previous;
  14126. // support: IE
  14127. // IE sets focus asynchronously, so we need to check if focus
  14128. // moved off of the input because the user clicked on the button.
  14129. this._delay( function() {
  14130. this.previous = previous;
  14131. } );
  14132. }
  14133. }
  14134. // Ensure focus is on (or stays on) the text field
  14135. event.preventDefault();
  14136. checkFocus.call( this );
  14137. // Support: IE
  14138. // IE doesn't prevent moving focus even with event.preventDefault()
  14139. // so we set a flag to know when we should ignore the blur event
  14140. // and check (again) if focus moved off of the input.
  14141. this.cancelBlur = true;
  14142. this._delay( function() {
  14143. delete this.cancelBlur;
  14144. checkFocus.call( this );
  14145. } );
  14146. if ( this._start( event ) === false ) {
  14147. return;
  14148. }
  14149. this._repeat( null, $( event.currentTarget )
  14150. .hasClass( "ui-spinner-up" ) ? 1 : -1, event );
  14151. },
  14152. "mouseup .ui-spinner-button": "_stop",
  14153. "mouseenter .ui-spinner-button": function( event ) {
  14154. // button will add ui-state-active if mouse was down while mouseleave and kept down
  14155. if ( !$( event.currentTarget ).hasClass( "ui-state-active" ) ) {
  14156. return;
  14157. }
  14158. if ( this._start( event ) === false ) {
  14159. return false;
  14160. }
  14161. this._repeat( null, $( event.currentTarget )
  14162. .hasClass( "ui-spinner-up" ) ? 1 : -1, event );
  14163. },
  14164. // TODO: do we really want to consider this a stop?
  14165. // shouldn't we just stop the repeater and wait until mouseup before
  14166. // we trigger the stop event?
  14167. "mouseleave .ui-spinner-button": "_stop"
  14168. },
  14169. // Support mobile enhanced option and make backcompat more sane
  14170. _enhance: function() {
  14171. this.uiSpinner = this.element
  14172. .attr( "autocomplete", "off" )
  14173. .wrap( "<span>" )
  14174. .parent()
  14175. // Add buttons
  14176. .append(
  14177. "<a></a><a></a>"
  14178. );
  14179. },
  14180. _draw: function() {
  14181. this._enhance();
  14182. this._addClass( this.uiSpinner, "ui-spinner", "ui-widget ui-widget-content" );
  14183. this._addClass( "ui-spinner-input" );
  14184. this.element.attr( "role", "spinbutton" );
  14185. // Button bindings
  14186. this.buttons = this.uiSpinner.children( "a" )
  14187. .attr( "tabIndex", -1 )
  14188. .attr( "aria-hidden", true )
  14189. .button( {
  14190. classes: {
  14191. "ui-button": ""
  14192. }
  14193. } );
  14194. // TODO: Right now button does not support classes this is already updated in button PR
  14195. this._removeClass( this.buttons, "ui-corner-all" );
  14196. this._addClass( this.buttons.first(), "ui-spinner-button ui-spinner-up" );
  14197. this._addClass( this.buttons.last(), "ui-spinner-button ui-spinner-down" );
  14198. this.buttons.first().button( {
  14199. "icon": this.options.icons.up,
  14200. "showLabel": false
  14201. } );
  14202. this.buttons.last().button( {
  14203. "icon": this.options.icons.down,
  14204. "showLabel": false
  14205. } );
  14206. // IE 6 doesn't understand height: 50% for the buttons
  14207. // unless the wrapper has an explicit height
  14208. if ( this.buttons.height() > Math.ceil( this.uiSpinner.height() * 0.5 ) &&
  14209. this.uiSpinner.height() > 0 ) {
  14210. this.uiSpinner.height( this.uiSpinner.height() );
  14211. }
  14212. },
  14213. _keydown: function( event ) {
  14214. var options = this.options,
  14215. keyCode = $.ui.keyCode;
  14216. switch ( event.keyCode ) {
  14217. case keyCode.UP:
  14218. this._repeat( null, 1, event );
  14219. return true;
  14220. case keyCode.DOWN:
  14221. this._repeat( null, -1, event );
  14222. return true;
  14223. case keyCode.PAGE_UP:
  14224. this._repeat( null, options.page, event );
  14225. return true;
  14226. case keyCode.PAGE_DOWN:
  14227. this._repeat( null, -options.page, event );
  14228. return true;
  14229. }
  14230. return false;
  14231. },
  14232. _start: function( event ) {
  14233. if ( !this.spinning && this._trigger( "start", event ) === false ) {
  14234. return false;
  14235. }
  14236. if ( !this.counter ) {
  14237. this.counter = 1;
  14238. }
  14239. this.spinning = true;
  14240. return true;
  14241. },
  14242. _repeat: function( i, steps, event ) {
  14243. i = i || 500;
  14244. clearTimeout( this.timer );
  14245. this.timer = this._delay( function() {
  14246. this._repeat( 40, steps, event );
  14247. }, i );
  14248. this._spin( steps * this.options.step, event );
  14249. },
  14250. _spin: function( step, event ) {
  14251. var value = this.value() || 0;
  14252. if ( !this.counter ) {
  14253. this.counter = 1;
  14254. }
  14255. value = this._adjustValue( value + step * this._increment( this.counter ) );
  14256. if ( !this.spinning || this._trigger( "spin", event, { value: value } ) !== false ) {
  14257. this._value( value );
  14258. this.counter++;
  14259. }
  14260. },
  14261. _increment: function( i ) {
  14262. var incremental = this.options.incremental;
  14263. if ( incremental ) {
  14264. return $.isFunction( incremental ) ?
  14265. incremental( i ) :
  14266. Math.floor( i * i * i / 50000 - i * i / 500 + 17 * i / 200 + 1 );
  14267. }
  14268. return 1;
  14269. },
  14270. _precision: function() {
  14271. var precision = this._precisionOf( this.options.step );
  14272. if ( this.options.min !== null ) {
  14273. precision = Math.max( precision, this._precisionOf( this.options.min ) );
  14274. }
  14275. return precision;
  14276. },
  14277. _precisionOf: function( num ) {
  14278. var str = num.toString(),
  14279. decimal = str.indexOf( "." );
  14280. return decimal === -1 ? 0 : str.length - decimal - 1;
  14281. },
  14282. _adjustValue: function( value ) {
  14283. var base, aboveMin,
  14284. options = this.options;
  14285. // Make sure we're at a valid step
  14286. // - find out where we are relative to the base (min or 0)
  14287. base = options.min !== null ? options.min : 0;
  14288. aboveMin = value - base;
  14289. // - round to the nearest step
  14290. aboveMin = Math.round( aboveMin / options.step ) * options.step;
  14291. // - rounding is based on 0, so adjust back to our base
  14292. value = base + aboveMin;
  14293. // Fix precision from bad JS floating point math
  14294. value = parseFloat( value.toFixed( this._precision() ) );
  14295. // Clamp the value
  14296. if ( options.max !== null && value > options.max ) {
  14297. return options.max;
  14298. }
  14299. if ( options.min !== null && value < options.min ) {
  14300. return options.min;
  14301. }
  14302. return value;
  14303. },
  14304. _stop: function( event ) {
  14305. if ( !this.spinning ) {
  14306. return;
  14307. }
  14308. clearTimeout( this.timer );
  14309. clearTimeout( this.mousewheelTimer );
  14310. this.counter = 0;
  14311. this.spinning = false;
  14312. this._trigger( "stop", event );
  14313. },
  14314. _setOption: function( key, value ) {
  14315. var prevValue, first, last;
  14316. if ( key === "culture" || key === "numberFormat" ) {
  14317. prevValue = this._parse( this.element.val() );
  14318. this.options[ key ] = value;
  14319. this.element.val( this._format( prevValue ) );
  14320. return;
  14321. }
  14322. if ( key === "max" || key === "min" || key === "step" ) {
  14323. if ( typeof value === "string" ) {
  14324. value = this._parse( value );
  14325. }
  14326. }
  14327. if ( key === "icons" ) {
  14328. first = this.buttons.first().find( ".ui-icon" );
  14329. this._removeClass( first, null, this.options.icons.up );
  14330. this._addClass( first, null, value.up );
  14331. last = this.buttons.last().find( ".ui-icon" );
  14332. this._removeClass( last, null, this.options.icons.down );
  14333. this._addClass( last, null, value.down );
  14334. }
  14335. this._super( key, value );
  14336. },
  14337. _setOptionDisabled: function( value ) {
  14338. this._super( value );
  14339. this._toggleClass( this.uiSpinner, null, "ui-state-disabled", !!value );
  14340. this.element.prop( "disabled", !!value );
  14341. this.buttons.button( value ? "disable" : "enable" );
  14342. },
  14343. _setOptions: spinnerModifer( function( options ) {
  14344. this._super( options );
  14345. } ),
  14346. _parse: function( val ) {
  14347. if ( typeof val === "string" && val !== "" ) {
  14348. val = window.Globalize && this.options.numberFormat ?
  14349. Globalize.parseFloat( val, 10, this.options.culture ) : +val;
  14350. }
  14351. return val === "" || isNaN( val ) ? null : val;
  14352. },
  14353. _format: function( value ) {
  14354. if ( value === "" ) {
  14355. return "";
  14356. }
  14357. return window.Globalize && this.options.numberFormat ?
  14358. Globalize.format( value, this.options.numberFormat, this.options.culture ) :
  14359. value;
  14360. },
  14361. _refresh: function() {
  14362. this.element.attr( {
  14363. "aria-valuemin": this.options.min,
  14364. "aria-valuemax": this.options.max,
  14365. // TODO: what should we do with values that can't be parsed?
  14366. "aria-valuenow": this._parse( this.element.val() )
  14367. } );
  14368. },
  14369. isValid: function() {
  14370. var value = this.value();
  14371. // Null is invalid
  14372. if ( value === null ) {
  14373. return false;
  14374. }
  14375. // If value gets adjusted, it's invalid
  14376. return value === this._adjustValue( value );
  14377. },
  14378. // Update the value without triggering change
  14379. _value: function( value, allowAny ) {
  14380. var parsed;
  14381. if ( value !== "" ) {
  14382. parsed = this._parse( value );
  14383. if ( parsed !== null ) {
  14384. if ( !allowAny ) {
  14385. parsed = this._adjustValue( parsed );
  14386. }
  14387. value = this._format( parsed );
  14388. }
  14389. }
  14390. this.element.val( value );
  14391. this._refresh();
  14392. },
  14393. _destroy: function() {
  14394. this.element
  14395. .prop( "disabled", false )
  14396. .removeAttr( "autocomplete role aria-valuemin aria-valuemax aria-valuenow" );
  14397. this.uiSpinner.replaceWith( this.element );
  14398. },
  14399. stepUp: spinnerModifer( function( steps ) {
  14400. this._stepUp( steps );
  14401. } ),
  14402. _stepUp: function( steps ) {
  14403. if ( this._start() ) {
  14404. this._spin( ( steps || 1 ) * this.options.step );
  14405. this._stop();
  14406. }
  14407. },
  14408. stepDown: spinnerModifer( function( steps ) {
  14409. this._stepDown( steps );
  14410. } ),
  14411. _stepDown: function( steps ) {
  14412. if ( this._start() ) {
  14413. this._spin( ( steps || 1 ) * -this.options.step );
  14414. this._stop();
  14415. }
  14416. },
  14417. pageUp: spinnerModifer( function( pages ) {
  14418. this._stepUp( ( pages || 1 ) * this.options.page );
  14419. } ),
  14420. pageDown: spinnerModifer( function( pages ) {
  14421. this._stepDown( ( pages || 1 ) * this.options.page );
  14422. } ),
  14423. value: function( newVal ) {
  14424. if ( !arguments.length ) {
  14425. return this._parse( this.element.val() );
  14426. }
  14427. spinnerModifer( this._value ).call( this, newVal );
  14428. },
  14429. widget: function() {
  14430. return this.uiSpinner;
  14431. }
  14432. } );
  14433. // DEPRECATED
  14434. // TODO: switch return back to widget declaration at top of file when this is removed
  14435. if ( $.uiBackCompat !== false ) {
  14436. // Backcompat for spinner html extension points
  14437. $.widget( "ui.spinner", $.ui.spinner, {
  14438. _enhance: function() {
  14439. this.uiSpinner = this.element
  14440. .attr( "autocomplete", "off" )
  14441. .wrap( this._uiSpinnerHtml() )
  14442. .parent()
  14443. // Add buttons
  14444. .append( this._buttonHtml() );
  14445. },
  14446. _uiSpinnerHtml: function() {
  14447. return "<span>";
  14448. },
  14449. _buttonHtml: function() {
  14450. return "<a></a><a></a>";
  14451. }
  14452. } );
  14453. }
  14454. var widgetsSpinner = $.ui.spinner;
  14455. /*!
  14456. * jQuery UI Tabs 1.12.0
  14457. * http://jqueryui.com
  14458. *
  14459. * Copyright jQuery Foundation and other contributors
  14460. * Released under the MIT license.
  14461. * http://jquery.org/license
  14462. */
  14463. //>>label: Tabs
  14464. //>>group: Widgets
  14465. //>>description: Transforms a set of container elements into a tab structure.
  14466. //>>docs: http://api.jqueryui.com/tabs/
  14467. //>>demos: http://jqueryui.com/tabs/
  14468. //>>css.structure: ../../themes/base/core.css
  14469. //>>css.structure: ../../themes/base/tabs.css
  14470. //>>css.theme: ../../themes/base/theme.css
  14471. $.widget( "ui.tabs", {
  14472. version: "1.12.0",
  14473. delay: 300,
  14474. options: {
  14475. active: null,
  14476. classes: {
  14477. "ui-tabs": "ui-corner-all",
  14478. "ui-tabs-nav": "ui-corner-all",
  14479. "ui-tabs-panel": "ui-corner-bottom",
  14480. "ui-tabs-tab": "ui-corner-top"
  14481. },
  14482. collapsible: false,
  14483. event: "click",
  14484. heightStyle: "content",
  14485. hide: null,
  14486. show: null,
  14487. // Callbacks
  14488. activate: null,
  14489. beforeActivate: null,
  14490. beforeLoad: null,
  14491. load: null
  14492. },
  14493. _isLocal: ( function() {
  14494. var rhash = /#.*$/;
  14495. return function( anchor ) {
  14496. var anchorUrl, locationUrl;
  14497. anchorUrl = anchor.href.replace( rhash, "" );
  14498. locationUrl = location.href.replace( rhash, "" );
  14499. // Decoding may throw an error if the URL isn't UTF-8 (#9518)
  14500. try {
  14501. anchorUrl = decodeURIComponent( anchorUrl );
  14502. } catch ( error ) {}
  14503. try {
  14504. locationUrl = decodeURIComponent( locationUrl );
  14505. } catch ( error ) {}
  14506. return anchor.hash.length > 1 && anchorUrl === locationUrl;
  14507. };
  14508. } )(),
  14509. _create: function() {
  14510. var that = this,
  14511. options = this.options;
  14512. this.running = false;
  14513. this._addClass( "ui-tabs", "ui-widget ui-widget-content" );
  14514. this._toggleClass( "ui-tabs-collapsible", null, options.collapsible );
  14515. this._processTabs();
  14516. options.active = this._initialActive();
  14517. // Take disabling tabs via class attribute from HTML
  14518. // into account and update option properly.
  14519. if ( $.isArray( options.disabled ) ) {
  14520. options.disabled = $.unique( options.disabled.concat(
  14521. $.map( this.tabs.filter( ".ui-state-disabled" ), function( li ) {
  14522. return that.tabs.index( li );
  14523. } )
  14524. ) ).sort();
  14525. }
  14526. // Check for length avoids error when initializing empty list
  14527. if ( this.options.active !== false && this.anchors.length ) {
  14528. this.active = this._findActive( options.active );
  14529. } else {
  14530. this.active = $();
  14531. }
  14532. this._refresh();
  14533. if ( this.active.length ) {
  14534. this.load( options.active );
  14535. }
  14536. },
  14537. _initialActive: function() {
  14538. var active = this.options.active,
  14539. collapsible = this.options.collapsible,
  14540. locationHash = location.hash.substring( 1 );
  14541. if ( active === null ) {
  14542. // check the fragment identifier in the URL
  14543. if ( locationHash ) {
  14544. this.tabs.each( function( i, tab ) {
  14545. if ( $( tab ).attr( "aria-controls" ) === locationHash ) {
  14546. active = i;
  14547. return false;
  14548. }
  14549. } );
  14550. }
  14551. // Check for a tab marked active via a class
  14552. if ( active === null ) {
  14553. active = this.tabs.index( this.tabs.filter( ".ui-tabs-active" ) );
  14554. }
  14555. // No active tab, set to false
  14556. if ( active === null || active === -1 ) {
  14557. active = this.tabs.length ? 0 : false;
  14558. }
  14559. }
  14560. // Handle numbers: negative, out of range
  14561. if ( active !== false ) {
  14562. active = this.tabs.index( this.tabs.eq( active ) );
  14563. if ( active === -1 ) {
  14564. active = collapsible ? false : 0;
  14565. }
  14566. }
  14567. // Don't allow collapsible: false and active: false
  14568. if ( !collapsible && active === false && this.anchors.length ) {
  14569. active = 0;
  14570. }
  14571. return active;
  14572. },
  14573. _getCreateEventData: function() {
  14574. return {
  14575. tab: this.active,
  14576. panel: !this.active.length ? $() : this._getPanelForTab( this.active )
  14577. };
  14578. },
  14579. _tabKeydown: function( event ) {
  14580. var focusedTab = $( $.ui.safeActiveElement( this.document[ 0 ] ) ).closest( "li" ),
  14581. selectedIndex = this.tabs.index( focusedTab ),
  14582. goingForward = true;
  14583. if ( this._handlePageNav( event ) ) {
  14584. return;
  14585. }
  14586. switch ( event.keyCode ) {
  14587. case $.ui.keyCode.RIGHT:
  14588. case $.ui.keyCode.DOWN:
  14589. selectedIndex++;
  14590. break;
  14591. case $.ui.keyCode.UP:
  14592. case $.ui.keyCode.LEFT:
  14593. goingForward = false;
  14594. selectedIndex--;
  14595. break;
  14596. case $.ui.keyCode.END:
  14597. selectedIndex = this.anchors.length - 1;
  14598. break;
  14599. case $.ui.keyCode.HOME:
  14600. selectedIndex = 0;
  14601. break;
  14602. case $.ui.keyCode.SPACE:
  14603. // Activate only, no collapsing
  14604. event.preventDefault();
  14605. clearTimeout( this.activating );
  14606. this._activate( selectedIndex );
  14607. return;
  14608. case $.ui.keyCode.ENTER:
  14609. // Toggle (cancel delayed activation, allow collapsing)
  14610. event.preventDefault();
  14611. clearTimeout( this.activating );
  14612. // Determine if we should collapse or activate
  14613. this._activate( selectedIndex === this.options.active ? false : selectedIndex );
  14614. return;
  14615. default:
  14616. return;
  14617. }
  14618. // Focus the appropriate tab, based on which key was pressed
  14619. event.preventDefault();
  14620. clearTimeout( this.activating );
  14621. selectedIndex = this._focusNextTab( selectedIndex, goingForward );
  14622. // Navigating with control/command key will prevent automatic activation
  14623. if ( !event.ctrlKey && !event.metaKey ) {
  14624. // Update aria-selected immediately so that AT think the tab is already selected.
  14625. // Otherwise AT may confuse the user by stating that they need to activate the tab,
  14626. // but the tab will already be activated by the time the announcement finishes.
  14627. focusedTab.attr( "aria-selected", "false" );
  14628. this.tabs.eq( selectedIndex ).attr( "aria-selected", "true" );
  14629. this.activating = this._delay( function() {
  14630. this.option( "active", selectedIndex );
  14631. }, this.delay );
  14632. }
  14633. },
  14634. _panelKeydown: function( event ) {
  14635. if ( this._handlePageNav( event ) ) {
  14636. return;
  14637. }
  14638. // Ctrl+up moves focus to the current tab
  14639. if ( event.ctrlKey && event.keyCode === $.ui.keyCode.UP ) {
  14640. event.preventDefault();
  14641. this.active.trigger( "focus" );
  14642. }
  14643. },
  14644. // Alt+page up/down moves focus to the previous/next tab (and activates)
  14645. _handlePageNav: function( event ) {
  14646. if ( event.altKey && event.keyCode === $.ui.keyCode.PAGE_UP ) {
  14647. this._activate( this._focusNextTab( this.options.active - 1, false ) );
  14648. return true;
  14649. }
  14650. if ( event.altKey && event.keyCode === $.ui.keyCode.PAGE_DOWN ) {
  14651. this._activate( this._focusNextTab( this.options.active + 1, true ) );
  14652. return true;
  14653. }
  14654. },
  14655. _findNextTab: function( index, goingForward ) {
  14656. var lastTabIndex = this.tabs.length - 1;
  14657. function constrain() {
  14658. if ( index > lastTabIndex ) {
  14659. index = 0;
  14660. }
  14661. if ( index < 0 ) {
  14662. index = lastTabIndex;
  14663. }
  14664. return index;
  14665. }
  14666. while ( $.inArray( constrain(), this.options.disabled ) !== -1 ) {
  14667. index = goingForward ? index + 1 : index - 1;
  14668. }
  14669. return index;
  14670. },
  14671. _focusNextTab: function( index, goingForward ) {
  14672. index = this._findNextTab( index, goingForward );
  14673. this.tabs.eq( index ).trigger( "focus" );
  14674. return index;
  14675. },
  14676. _setOption: function( key, value ) {
  14677. if ( key === "active" ) {
  14678. // _activate() will handle invalid values and update this.options
  14679. this._activate( value );
  14680. return;
  14681. }
  14682. this._super( key, value );
  14683. if ( key === "collapsible" ) {
  14684. this._toggleClass( "ui-tabs-collapsible", null, value );
  14685. // Setting collapsible: false while collapsed; open first panel
  14686. if ( !value && this.options.active === false ) {
  14687. this._activate( 0 );
  14688. }
  14689. }
  14690. if ( key === "event" ) {
  14691. this._setupEvents( value );
  14692. }
  14693. if ( key === "heightStyle" ) {
  14694. this._setupHeightStyle( value );
  14695. }
  14696. },
  14697. _sanitizeSelector: function( hash ) {
  14698. return hash ? hash.replace( /[!"$%&'()*+,.\/:;<=>?@\[\]\^`{|}~]/g, "\\$&" ) : "";
  14699. },
  14700. refresh: function() {
  14701. var options = this.options,
  14702. lis = this.tablist.children( ":has(a[href])" );
  14703. // Get disabled tabs from class attribute from HTML
  14704. // this will get converted to a boolean if needed in _refresh()
  14705. options.disabled = $.map( lis.filter( ".ui-state-disabled" ), function( tab ) {
  14706. return lis.index( tab );
  14707. } );
  14708. this._processTabs();
  14709. // Was collapsed or no tabs
  14710. if ( options.active === false || !this.anchors.length ) {
  14711. options.active = false;
  14712. this.active = $();
  14713. // was active, but active tab is gone
  14714. } else if ( this.active.length && !$.contains( this.tablist[ 0 ], this.active[ 0 ] ) ) {
  14715. // all remaining tabs are disabled
  14716. if ( this.tabs.length === options.disabled.length ) {
  14717. options.active = false;
  14718. this.active = $();
  14719. // activate previous tab
  14720. } else {
  14721. this._activate( this._findNextTab( Math.max( 0, options.active - 1 ), false ) );
  14722. }
  14723. // was active, active tab still exists
  14724. } else {
  14725. // make sure active index is correct
  14726. options.active = this.tabs.index( this.active );
  14727. }
  14728. this._refresh();
  14729. },
  14730. _refresh: function() {
  14731. this._setOptionDisabled( this.options.disabled );
  14732. this._setupEvents( this.options.event );
  14733. this._setupHeightStyle( this.options.heightStyle );
  14734. this.tabs.not( this.active ).attr( {
  14735. "aria-selected": "false",
  14736. "aria-expanded": "false",
  14737. tabIndex: -1
  14738. } );
  14739. this.panels.not( this._getPanelForTab( this.active ) )
  14740. .hide()
  14741. .attr( {
  14742. "aria-hidden": "true"
  14743. } );
  14744. // Make sure one tab is in the tab order
  14745. if ( !this.active.length ) {
  14746. this.tabs.eq( 0 ).attr( "tabIndex", 0 );
  14747. } else {
  14748. this.active
  14749. .attr( {
  14750. "aria-selected": "true",
  14751. "aria-expanded": "true",
  14752. tabIndex: 0
  14753. } );
  14754. this._addClass( this.active, "ui-tabs-active", "ui-state-active" );
  14755. this._getPanelForTab( this.active )
  14756. .show()
  14757. .attr( {
  14758. "aria-hidden": "false"
  14759. } );
  14760. }
  14761. },
  14762. _processTabs: function() {
  14763. var that = this,
  14764. prevTabs = this.tabs,
  14765. prevAnchors = this.anchors,
  14766. prevPanels = this.panels;
  14767. this.tablist = this._getList().attr( "role", "tablist" );
  14768. this._addClass( this.tablist, "ui-tabs-nav",
  14769. "ui-helper-reset ui-helper-clearfix ui-widget-header" );
  14770. // Prevent users from focusing disabled tabs via click
  14771. this.tablist
  14772. .on( "mousedown" + this.eventNamespace, "> li", function( event ) {
  14773. if ( $( this ).is( ".ui-state-disabled" ) ) {
  14774. event.preventDefault();
  14775. }
  14776. } )
  14777. // Support: IE <9
  14778. // Preventing the default action in mousedown doesn't prevent IE
  14779. // from focusing the element, so if the anchor gets focused, blur.
  14780. // We don't have to worry about focusing the previously focused
  14781. // element since clicking on a non-focusable element should focus
  14782. // the body anyway.
  14783. .on( "focus" + this.eventNamespace, ".ui-tabs-anchor", function() {
  14784. if ( $( this ).closest( "li" ).is( ".ui-state-disabled" ) ) {
  14785. this.blur();
  14786. }
  14787. } );
  14788. this.tabs = this.tablist.find( "> li:has(a[href])" )
  14789. .attr( {
  14790. role: "tab",
  14791. tabIndex: -1
  14792. } );
  14793. this._addClass( this.tabs, "ui-tabs-tab", "ui-state-default" );
  14794. this.anchors = this.tabs.map( function() {
  14795. return $( "a", this )[ 0 ];
  14796. } )
  14797. .attr( {
  14798. role: "presentation",
  14799. tabIndex: -1
  14800. } );
  14801. this._addClass( this.anchors, "ui-tabs-anchor" );
  14802. this.panels = $();
  14803. this.anchors.each( function( i, anchor ) {
  14804. var selector, panel, panelId,
  14805. anchorId = $( anchor ).uniqueId().attr( "id" ),
  14806. tab = $( anchor ).closest( "li" ),
  14807. originalAriaControls = tab.attr( "aria-controls" );
  14808. // Inline tab
  14809. if ( that._isLocal( anchor ) ) {
  14810. selector = anchor.hash;
  14811. panelId = selector.substring( 1 );
  14812. panel = that.element.find( that._sanitizeSelector( selector ) );
  14813. // remote tab
  14814. } else {
  14815. // If the tab doesn't already have aria-controls,
  14816. // generate an id by using a throw-away element
  14817. panelId = tab.attr( "aria-controls" ) || $( {} ).uniqueId()[ 0 ].id;
  14818. selector = "#" + panelId;
  14819. panel = that.element.find( selector );
  14820. if ( !panel.length ) {
  14821. panel = that._createPanel( panelId );
  14822. panel.insertAfter( that.panels[ i - 1 ] || that.tablist );
  14823. }
  14824. panel.attr( "aria-live", "polite" );
  14825. }
  14826. if ( panel.length ) {
  14827. that.panels = that.panels.add( panel );
  14828. }
  14829. if ( originalAriaControls ) {
  14830. tab.data( "ui-tabs-aria-controls", originalAriaControls );
  14831. }
  14832. tab.attr( {
  14833. "aria-controls": panelId,
  14834. "aria-labelledby": anchorId
  14835. } );
  14836. panel.attr( "aria-labelledby", anchorId );
  14837. } );
  14838. this.panels.attr( "role", "tabpanel" );
  14839. this._addClass( this.panels, "ui-tabs-panel", "ui-widget-content" );
  14840. // Avoid memory leaks (#10056)
  14841. if ( prevTabs ) {
  14842. this._off( prevTabs.not( this.tabs ) );
  14843. this._off( prevAnchors.not( this.anchors ) );
  14844. this._off( prevPanels.not( this.panels ) );
  14845. }
  14846. },
  14847. // Allow overriding how to find the list for rare usage scenarios (#7715)
  14848. _getList: function() {
  14849. return this.tablist || this.element.find( "ol, ul" ).eq( 0 );
  14850. },
  14851. _createPanel: function( id ) {
  14852. return $( "<div>" )
  14853. .attr( "id", id )
  14854. .data( "ui-tabs-destroy", true );
  14855. },
  14856. _setOptionDisabled: function( disabled ) {
  14857. var currentItem, li, i;
  14858. if ( $.isArray( disabled ) ) {
  14859. if ( !disabled.length ) {
  14860. disabled = false;
  14861. } else if ( disabled.length === this.anchors.length ) {
  14862. disabled = true;
  14863. }
  14864. }
  14865. // Disable tabs
  14866. for ( i = 0; ( li = this.tabs[ i ] ); i++ ) {
  14867. currentItem = $( li );
  14868. if ( disabled === true || $.inArray( i, disabled ) !== -1 ) {
  14869. currentItem.attr( "aria-disabled", "true" );
  14870. this._addClass( currentItem, null, "ui-state-disabled" );
  14871. } else {
  14872. currentItem.removeAttr( "aria-disabled" );
  14873. this._removeClass( currentItem, null, "ui-state-disabled" );
  14874. }
  14875. }
  14876. this.options.disabled = disabled;
  14877. this._toggleClass( this.widget(), this.widgetFullName + "-disabled", null,
  14878. disabled === true );
  14879. },
  14880. _setupEvents: function( event ) {
  14881. var events = {};
  14882. if ( event ) {
  14883. $.each( event.split( " " ), function( index, eventName ) {
  14884. events[ eventName ] = "_eventHandler";
  14885. } );
  14886. }
  14887. this._off( this.anchors.add( this.tabs ).add( this.panels ) );
  14888. // Always prevent the default action, even when disabled
  14889. this._on( true, this.anchors, {
  14890. click: function( event ) {
  14891. event.preventDefault();
  14892. }
  14893. } );
  14894. this._on( this.anchors, events );
  14895. this._on( this.tabs, { keydown: "_tabKeydown" } );
  14896. this._on( this.panels, { keydown: "_panelKeydown" } );
  14897. this._focusable( this.tabs );
  14898. this._hoverable( this.tabs );
  14899. },
  14900. _setupHeightStyle: function( heightStyle ) {
  14901. var maxHeight,
  14902. parent = this.element.parent();
  14903. if ( heightStyle === "fill" ) {
  14904. maxHeight = parent.height();
  14905. maxHeight -= this.element.outerHeight() - this.element.height();
  14906. this.element.siblings( ":visible" ).each( function() {
  14907. var elem = $( this ),
  14908. position = elem.css( "position" );
  14909. if ( position === "absolute" || position === "fixed" ) {
  14910. return;
  14911. }
  14912. maxHeight -= elem.outerHeight( true );
  14913. } );
  14914. this.element.children().not( this.panels ).each( function() {
  14915. maxHeight -= $( this ).outerHeight( true );
  14916. } );
  14917. this.panels.each( function() {
  14918. $( this ).height( Math.max( 0, maxHeight -
  14919. $( this ).innerHeight() + $( this ).height() ) );
  14920. } )
  14921. .css( "overflow", "auto" );
  14922. } else if ( heightStyle === "auto" ) {
  14923. maxHeight = 0;
  14924. this.panels.each( function() {
  14925. maxHeight = Math.max( maxHeight, $( this ).height( "" ).height() );
  14926. } ).height( maxHeight );
  14927. }
  14928. },
  14929. _eventHandler: function( event ) {
  14930. var options = this.options,
  14931. active = this.active,
  14932. anchor = $( event.currentTarget ),
  14933. tab = anchor.closest( "li" ),
  14934. clickedIsActive = tab[ 0 ] === active[ 0 ],
  14935. collapsing = clickedIsActive && options.collapsible,
  14936. toShow = collapsing ? $() : this._getPanelForTab( tab ),
  14937. toHide = !active.length ? $() : this._getPanelForTab( active ),
  14938. eventData = {
  14939. oldTab: active,
  14940. oldPanel: toHide,
  14941. newTab: collapsing ? $() : tab,
  14942. newPanel: toShow
  14943. };
  14944. event.preventDefault();
  14945. if ( tab.hasClass( "ui-state-disabled" ) ||
  14946. // tab is already loading
  14947. tab.hasClass( "ui-tabs-loading" ) ||
  14948. // can't switch durning an animation
  14949. this.running ||
  14950. // click on active header, but not collapsible
  14951. ( clickedIsActive && !options.collapsible ) ||
  14952. // allow canceling activation
  14953. ( this._trigger( "beforeActivate", event, eventData ) === false ) ) {
  14954. return;
  14955. }
  14956. options.active = collapsing ? false : this.tabs.index( tab );
  14957. this.active = clickedIsActive ? $() : tab;
  14958. if ( this.xhr ) {
  14959. this.xhr.abort();
  14960. }
  14961. if ( !toHide.length && !toShow.length ) {
  14962. $.error( "jQuery UI Tabs: Mismatching fragment identifier." );
  14963. }
  14964. if ( toShow.length ) {
  14965. this.load( this.tabs.index( tab ), event );
  14966. }
  14967. this._toggle( event, eventData );
  14968. },
  14969. // Handles show/hide for selecting tabs
  14970. _toggle: function( event, eventData ) {
  14971. var that = this,
  14972. toShow = eventData.newPanel,
  14973. toHide = eventData.oldPanel;
  14974. this.running = true;
  14975. function complete() {
  14976. that.running = false;
  14977. that._trigger( "activate", event, eventData );
  14978. }
  14979. function show() {
  14980. that._addClass( eventData.newTab.closest( "li" ), "ui-tabs-active", "ui-state-active" );
  14981. if ( toShow.length && that.options.show ) {
  14982. that._show( toShow, that.options.show, complete );
  14983. } else {
  14984. toShow.show();
  14985. complete();
  14986. }
  14987. }
  14988. // Start out by hiding, then showing, then completing
  14989. if ( toHide.length && this.options.hide ) {
  14990. this._hide( toHide, this.options.hide, function() {
  14991. that._removeClass( eventData.oldTab.closest( "li" ),
  14992. "ui-tabs-active", "ui-state-active" );
  14993. show();
  14994. } );
  14995. } else {
  14996. this._removeClass( eventData.oldTab.closest( "li" ),
  14997. "ui-tabs-active", "ui-state-active" );
  14998. toHide.hide();
  14999. show();
  15000. }
  15001. toHide.attr( "aria-hidden", "true" );
  15002. eventData.oldTab.attr( {
  15003. "aria-selected": "false",
  15004. "aria-expanded": "false"
  15005. } );
  15006. // If we're switching tabs, remove the old tab from the tab order.
  15007. // If we're opening from collapsed state, remove the previous tab from the tab order.
  15008. // If we're collapsing, then keep the collapsing tab in the tab order.
  15009. if ( toShow.length && toHide.length ) {
  15010. eventData.oldTab.attr( "tabIndex", -1 );
  15011. } else if ( toShow.length ) {
  15012. this.tabs.filter( function() {
  15013. return $( this ).attr( "tabIndex" ) === 0;
  15014. } )
  15015. .attr( "tabIndex", -1 );
  15016. }
  15017. toShow.attr( "aria-hidden", "false" );
  15018. eventData.newTab.attr( {
  15019. "aria-selected": "true",
  15020. "aria-expanded": "true",
  15021. tabIndex: 0
  15022. } );
  15023. },
  15024. _activate: function( index ) {
  15025. var anchor,
  15026. active = this._findActive( index );
  15027. // Trying to activate the already active panel
  15028. if ( active[ 0 ] === this.active[ 0 ] ) {
  15029. return;
  15030. }
  15031. // Trying to collapse, simulate a click on the current active header
  15032. if ( !active.length ) {
  15033. active = this.active;
  15034. }
  15035. anchor = active.find( ".ui-tabs-anchor" )[ 0 ];
  15036. this._eventHandler( {
  15037. target: anchor,
  15038. currentTarget: anchor,
  15039. preventDefault: $.noop
  15040. } );
  15041. },
  15042. _findActive: function( index ) {
  15043. return index === false ? $() : this.tabs.eq( index );
  15044. },
  15045. _getIndex: function( index ) {
  15046. // meta-function to give users option to provide a href string instead of a numerical index.
  15047. if ( typeof index === "string" ) {
  15048. index = this.anchors.index( this.anchors.filter( "[href$='" +
  15049. $.ui.escapeSelector( index ) + "']" ) );
  15050. }
  15051. return index;
  15052. },
  15053. _destroy: function() {
  15054. if ( this.xhr ) {
  15055. this.xhr.abort();
  15056. }
  15057. this.tablist
  15058. .removeAttr( "role" )
  15059. .off( this.eventNamespace );
  15060. this.anchors
  15061. .removeAttr( "role tabIndex" )
  15062. .removeUniqueId();
  15063. this.tabs.add( this.panels ).each( function() {
  15064. if ( $.data( this, "ui-tabs-destroy" ) ) {
  15065. $( this ).remove();
  15066. } else {
  15067. $( this ).removeAttr( "role tabIndex " +
  15068. "aria-live aria-busy aria-selected aria-labelledby aria-hidden aria-expanded" );
  15069. }
  15070. } );
  15071. this.tabs.each( function() {
  15072. var li = $( this ),
  15073. prev = li.data( "ui-tabs-aria-controls" );
  15074. if ( prev ) {
  15075. li
  15076. .attr( "aria-controls", prev )
  15077. .removeData( "ui-tabs-aria-controls" );
  15078. } else {
  15079. li.removeAttr( "aria-controls" );
  15080. }
  15081. } );
  15082. this.panels.show();
  15083. if ( this.options.heightStyle !== "content" ) {
  15084. this.panels.css( "height", "" );
  15085. }
  15086. },
  15087. enable: function( index ) {
  15088. var disabled = this.options.disabled;
  15089. if ( disabled === false ) {
  15090. return;
  15091. }
  15092. if ( index === undefined ) {
  15093. disabled = false;
  15094. } else {
  15095. index = this._getIndex( index );
  15096. if ( $.isArray( disabled ) ) {
  15097. disabled = $.map( disabled, function( num ) {
  15098. return num !== index ? num : null;
  15099. } );
  15100. } else {
  15101. disabled = $.map( this.tabs, function( li, num ) {
  15102. return num !== index ? num : null;
  15103. } );
  15104. }
  15105. }
  15106. this._setOptionDisabled( disabled );
  15107. },
  15108. disable: function( index ) {
  15109. var disabled = this.options.disabled;
  15110. if ( disabled === true ) {
  15111. return;
  15112. }
  15113. if ( index === undefined ) {
  15114. disabled = true;
  15115. } else {
  15116. index = this._getIndex( index );
  15117. if ( $.inArray( index, disabled ) !== -1 ) {
  15118. return;
  15119. }
  15120. if ( $.isArray( disabled ) ) {
  15121. disabled = $.merge( [ index ], disabled ).sort();
  15122. } else {
  15123. disabled = [ index ];
  15124. }
  15125. }
  15126. this._setOptionDisabled( disabled );
  15127. },
  15128. load: function( index, event ) {
  15129. index = this._getIndex( index );
  15130. var that = this,
  15131. tab = this.tabs.eq( index ),
  15132. anchor = tab.find( ".ui-tabs-anchor" ),
  15133. panel = this._getPanelForTab( tab ),
  15134. eventData = {
  15135. tab: tab,
  15136. panel: panel
  15137. },
  15138. complete = function( jqXHR, status ) {
  15139. if ( status === "abort" ) {
  15140. that.panels.stop( false, true );
  15141. }
  15142. that._removeClass( tab, "ui-tabs-loading" );
  15143. panel.removeAttr( "aria-busy" );
  15144. if ( jqXHR === that.xhr ) {
  15145. delete that.xhr;
  15146. }
  15147. };
  15148. // Not remote
  15149. if ( this._isLocal( anchor[ 0 ] ) ) {
  15150. return;
  15151. }
  15152. this.xhr = $.ajax( this._ajaxSettings( anchor, event, eventData ) );
  15153. // Support: jQuery <1.8
  15154. // jQuery <1.8 returns false if the request is canceled in beforeSend,
  15155. // but as of 1.8, $.ajax() always returns a jqXHR object.
  15156. if ( this.xhr && this.xhr.statusText !== "canceled" ) {
  15157. this._addClass( tab, "ui-tabs-loading" );
  15158. panel.attr( "aria-busy", "true" );
  15159. this.xhr
  15160. .done( function( response, status, jqXHR ) {
  15161. // support: jQuery <1.8
  15162. // http://bugs.jquery.com/ticket/11778
  15163. setTimeout( function() {
  15164. panel.html( response );
  15165. that._trigger( "load", event, eventData );
  15166. complete( jqXHR, status );
  15167. }, 1 );
  15168. } )
  15169. .fail( function( jqXHR, status ) {
  15170. // support: jQuery <1.8
  15171. // http://bugs.jquery.com/ticket/11778
  15172. setTimeout( function() {
  15173. complete( jqXHR, status );
  15174. }, 1 );
  15175. } );
  15176. }
  15177. },
  15178. _ajaxSettings: function( anchor, event, eventData ) {
  15179. var that = this;
  15180. return {
  15181. url: anchor.attr( "href" ),
  15182. beforeSend: function( jqXHR, settings ) {
  15183. return that._trigger( "beforeLoad", event,
  15184. $.extend( { jqXHR: jqXHR, ajaxSettings: settings }, eventData ) );
  15185. }
  15186. };
  15187. },
  15188. _getPanelForTab: function( tab ) {
  15189. var id = $( tab ).attr( "aria-controls" );
  15190. return this.element.find( this._sanitizeSelector( "#" + id ) );
  15191. }
  15192. } );
  15193. // DEPRECATED
  15194. // TODO: Switch return back to widget declaration at top of file when this is removed
  15195. if ( $.uiBackCompat !== false ) {
  15196. // Backcompat for ui-tab class (now ui-tabs-tab)
  15197. $.widget( "ui.tabs", $.ui.tabs, {
  15198. _processTabs: function() {
  15199. this._superApply( arguments );
  15200. this._addClass( this.tabs, "ui-tab" );
  15201. }
  15202. } );
  15203. }
  15204. var widgetsTabs = $.ui.tabs;
  15205. /*!
  15206. * jQuery UI Tooltip 1.12.0
  15207. * http://jqueryui.com
  15208. *
  15209. * Copyright jQuery Foundation and other contributors
  15210. * Released under the MIT license.
  15211. * http://jquery.org/license
  15212. */
  15213. //>>label: Tooltip
  15214. //>>group: Widgets
  15215. //>>description: Shows additional information for any element on hover or focus.
  15216. //>>docs: http://api.jqueryui.com/tooltip/
  15217. //>>demos: http://jqueryui.com/tooltip/
  15218. //>>css.structure: ../../themes/base/core.css
  15219. //>>css.structure: ../../themes/base/tooltip.css
  15220. //>>css.theme: ../../themes/base/theme.css
  15221. $.widget( "ui.tooltip", {
  15222. version: "1.12.0",
  15223. options: {
  15224. classes: {
  15225. "ui-tooltip": "ui-corner-all ui-widget-shadow"
  15226. },
  15227. content: function() {
  15228. // support: IE<9, Opera in jQuery <1.7
  15229. // .text() can't accept undefined, so coerce to a string
  15230. var title = $( this ).attr( "title" ) || "";
  15231. // Escape title, since we're going from an attribute to raw HTML
  15232. return $( "<a>" ).text( title ).html();
  15233. },
  15234. hide: true,
  15235. // Disabled elements have inconsistent behavior across browsers (#8661)
  15236. items: "[title]:not([disabled])",
  15237. position: {
  15238. my: "left top+15",
  15239. at: "left bottom",
  15240. collision: "flipfit flip"
  15241. },
  15242. show: true,
  15243. track: false,
  15244. // Callbacks
  15245. close: null,
  15246. open: null
  15247. },
  15248. _addDescribedBy: function( elem, id ) {
  15249. var describedby = ( elem.attr( "aria-describedby" ) || "" ).split( /\s+/ );
  15250. describedby.push( id );
  15251. elem
  15252. .data( "ui-tooltip-id", id )
  15253. .attr( "aria-describedby", $.trim( describedby.join( " " ) ) );
  15254. },
  15255. _removeDescribedBy: function( elem ) {
  15256. var id = elem.data( "ui-tooltip-id" ),
  15257. describedby = ( elem.attr( "aria-describedby" ) || "" ).split( /\s+/ ),
  15258. index = $.inArray( id, describedby );
  15259. if ( index !== -1 ) {
  15260. describedby.splice( index, 1 );
  15261. }
  15262. elem.removeData( "ui-tooltip-id" );
  15263. describedby = $.trim( describedby.join( " " ) );
  15264. if ( describedby ) {
  15265. elem.attr( "aria-describedby", describedby );
  15266. } else {
  15267. elem.removeAttr( "aria-describedby" );
  15268. }
  15269. },
  15270. _create: function() {
  15271. this._on( {
  15272. mouseover: "open",
  15273. focusin: "open"
  15274. } );
  15275. // IDs of generated tooltips, needed for destroy
  15276. this.tooltips = {};
  15277. // IDs of parent tooltips where we removed the title attribute
  15278. this.parents = {};
  15279. // Append the aria-live region so tooltips announce correctly
  15280. this.liveRegion = $( "<div>" )
  15281. .attr( {
  15282. role: "log",
  15283. "aria-live": "assertive",
  15284. "aria-relevant": "additions"
  15285. } )
  15286. .appendTo( this.document[ 0 ].body );
  15287. this._addClass( this.liveRegion, null, "ui-helper-hidden-accessible" );
  15288. this.disabledTitles = $( [] );
  15289. },
  15290. _setOption: function( key, value ) {
  15291. var that = this;
  15292. this._super( key, value );
  15293. if ( key === "content" ) {
  15294. $.each( this.tooltips, function( id, tooltipData ) {
  15295. that._updateContent( tooltipData.element );
  15296. } );
  15297. }
  15298. },
  15299. _setOptionDisabled: function( value ) {
  15300. this[ value ? "_disable" : "_enable" ]();
  15301. },
  15302. _disable: function() {
  15303. var that = this;
  15304. // Close open tooltips
  15305. $.each( this.tooltips, function( id, tooltipData ) {
  15306. var event = $.Event( "blur" );
  15307. event.target = event.currentTarget = tooltipData.element[ 0 ];
  15308. that.close( event, true );
  15309. } );
  15310. // Remove title attributes to prevent native tooltips
  15311. this.disabledTitles = this.disabledTitles.add(
  15312. this.element.find( this.options.items ).addBack()
  15313. .filter( function() {
  15314. var element = $( this );
  15315. if ( element.is( "[title]" ) ) {
  15316. return element
  15317. .data( "ui-tooltip-title", element.attr( "title" ) )
  15318. .removeAttr( "title" );
  15319. }
  15320. } )
  15321. );
  15322. },
  15323. _enable: function() {
  15324. // restore title attributes
  15325. this.disabledTitles.each( function() {
  15326. var element = $( this );
  15327. if ( element.data( "ui-tooltip-title" ) ) {
  15328. element.attr( "title", element.data( "ui-tooltip-title" ) );
  15329. }
  15330. } );
  15331. this.disabledTitles = $( [] );
  15332. },
  15333. open: function( event ) {
  15334. var that = this,
  15335. target = $( event ? event.target : this.element )
  15336. // we need closest here due to mouseover bubbling,
  15337. // but always pointing at the same event target
  15338. .closest( this.options.items );
  15339. // No element to show a tooltip for or the tooltip is already open
  15340. if ( !target.length || target.data( "ui-tooltip-id" ) ) {
  15341. return;
  15342. }
  15343. if ( target.attr( "title" ) ) {
  15344. target.data( "ui-tooltip-title", target.attr( "title" ) );
  15345. }
  15346. target.data( "ui-tooltip-open", true );
  15347. // Kill parent tooltips, custom or native, for hover
  15348. if ( event && event.type === "mouseover" ) {
  15349. target.parents().each( function() {
  15350. var parent = $( this ),
  15351. blurEvent;
  15352. if ( parent.data( "ui-tooltip-open" ) ) {
  15353. blurEvent = $.Event( "blur" );
  15354. blurEvent.target = blurEvent.currentTarget = this;
  15355. that.close( blurEvent, true );
  15356. }
  15357. if ( parent.attr( "title" ) ) {
  15358. parent.uniqueId();
  15359. that.parents[ this.id ] = {
  15360. element: this,
  15361. title: parent.attr( "title" )
  15362. };
  15363. parent.attr( "title", "" );
  15364. }
  15365. } );
  15366. }
  15367. this._registerCloseHandlers( event, target );
  15368. this._updateContent( target, event );
  15369. },
  15370. _updateContent: function( target, event ) {
  15371. var content,
  15372. contentOption = this.options.content,
  15373. that = this,
  15374. eventType = event ? event.type : null;
  15375. if ( typeof contentOption === "string" || contentOption.nodeType ||
  15376. contentOption.jquery ) {
  15377. return this._open( event, target, contentOption );
  15378. }
  15379. content = contentOption.call( target[ 0 ], function( response ) {
  15380. // IE may instantly serve a cached response for ajax requests
  15381. // delay this call to _open so the other call to _open runs first
  15382. that._delay( function() {
  15383. // Ignore async response if tooltip was closed already
  15384. if ( !target.data( "ui-tooltip-open" ) ) {
  15385. return;
  15386. }
  15387. // JQuery creates a special event for focusin when it doesn't
  15388. // exist natively. To improve performance, the native event
  15389. // object is reused and the type is changed. Therefore, we can't
  15390. // rely on the type being correct after the event finished
  15391. // bubbling, so we set it back to the previous value. (#8740)
  15392. if ( event ) {
  15393. event.type = eventType;
  15394. }
  15395. this._open( event, target, response );
  15396. } );
  15397. } );
  15398. if ( content ) {
  15399. this._open( event, target, content );
  15400. }
  15401. },
  15402. _open: function( event, target, content ) {
  15403. var tooltipData, tooltip, delayedShow, a11yContent,
  15404. positionOption = $.extend( {}, this.options.position );
  15405. if ( !content ) {
  15406. return;
  15407. }
  15408. // Content can be updated multiple times. If the tooltip already
  15409. // exists, then just update the content and bail.
  15410. tooltipData = this._find( target );
  15411. if ( tooltipData ) {
  15412. tooltipData.tooltip.find( ".ui-tooltip-content" ).html( content );
  15413. return;
  15414. }
  15415. // If we have a title, clear it to prevent the native tooltip
  15416. // we have to check first to avoid defining a title if none exists
  15417. // (we don't want to cause an element to start matching [title])
  15418. //
  15419. // We use removeAttr only for key events, to allow IE to export the correct
  15420. // accessible attributes. For mouse events, set to empty string to avoid
  15421. // native tooltip showing up (happens only when removing inside mouseover).
  15422. if ( target.is( "[title]" ) ) {
  15423. if ( event && event.type === "mouseover" ) {
  15424. target.attr( "title", "" );
  15425. } else {
  15426. target.removeAttr( "title" );
  15427. }
  15428. }
  15429. tooltipData = this._tooltip( target );
  15430. tooltip = tooltipData.tooltip;
  15431. this._addDescribedBy( target, tooltip.attr( "id" ) );
  15432. tooltip.find( ".ui-tooltip-content" ).html( content );
  15433. // Support: Voiceover on OS X, JAWS on IE <= 9
  15434. // JAWS announces deletions even when aria-relevant="additions"
  15435. // Voiceover will sometimes re-read the entire log region's contents from the beginning
  15436. this.liveRegion.children().hide();
  15437. a11yContent = $( "<div>" ).html( tooltip.find( ".ui-tooltip-content" ).html() );
  15438. a11yContent.removeAttr( "name" ).find( "[name]" ).removeAttr( "name" );
  15439. a11yContent.removeAttr( "id" ).find( "[id]" ).removeAttr( "id" );
  15440. a11yContent.appendTo( this.liveRegion );
  15441. function position( event ) {
  15442. positionOption.of = event;
  15443. if ( tooltip.is( ":hidden" ) ) {
  15444. return;
  15445. }
  15446. tooltip.position( positionOption );
  15447. }
  15448. if ( this.options.track && event && /^mouse/.test( event.type ) ) {
  15449. this._on( this.document, {
  15450. mousemove: position
  15451. } );
  15452. // trigger once to override element-relative positioning
  15453. position( event );
  15454. } else {
  15455. tooltip.position( $.extend( {
  15456. of: target
  15457. }, this.options.position ) );
  15458. }
  15459. tooltip.hide();
  15460. this._show( tooltip, this.options.show );
  15461. // Handle tracking tooltips that are shown with a delay (#8644). As soon
  15462. // as the tooltip is visible, position the tooltip using the most recent
  15463. // event.
  15464. // Adds the check to add the timers only when both delay and track options are set (#14682)
  15465. if ( this.options.track && this.options.show && this.options.show.delay ) {
  15466. delayedShow = this.delayedShow = setInterval( function() {
  15467. if ( tooltip.is( ":visible" ) ) {
  15468. position( positionOption.of );
  15469. clearInterval( delayedShow );
  15470. }
  15471. }, $.fx.interval );
  15472. }
  15473. this._trigger( "open", event, { tooltip: tooltip } );
  15474. },
  15475. _registerCloseHandlers: function( event, target ) {
  15476. var events = {
  15477. keyup: function( event ) {
  15478. if ( event.keyCode === $.ui.keyCode.ESCAPE ) {
  15479. var fakeEvent = $.Event( event );
  15480. fakeEvent.currentTarget = target[ 0 ];
  15481. this.close( fakeEvent, true );
  15482. }
  15483. }
  15484. };
  15485. // Only bind remove handler for delegated targets. Non-delegated
  15486. // tooltips will handle this in destroy.
  15487. if ( target[ 0 ] !== this.element[ 0 ] ) {
  15488. events.remove = function() {
  15489. this._removeTooltip( this._find( target ).tooltip );
  15490. };
  15491. }
  15492. if ( !event || event.type === "mouseover" ) {
  15493. events.mouseleave = "close";
  15494. }
  15495. if ( !event || event.type === "focusin" ) {
  15496. events.focusout = "close";
  15497. }
  15498. this._on( true, target, events );
  15499. },
  15500. close: function( event ) {
  15501. var tooltip,
  15502. that = this,
  15503. target = $( event ? event.currentTarget : this.element ),
  15504. tooltipData = this._find( target );
  15505. // The tooltip may already be closed
  15506. if ( !tooltipData ) {
  15507. // We set ui-tooltip-open immediately upon open (in open()), but only set the
  15508. // additional data once there's actually content to show (in _open()). So even if the
  15509. // tooltip doesn't have full data, we always remove ui-tooltip-open in case we're in
  15510. // the period between open() and _open().
  15511. target.removeData( "ui-tooltip-open" );
  15512. return;
  15513. }
  15514. tooltip = tooltipData.tooltip;
  15515. // Disabling closes the tooltip, so we need to track when we're closing
  15516. // to avoid an infinite loop in case the tooltip becomes disabled on close
  15517. if ( tooltipData.closing ) {
  15518. return;
  15519. }
  15520. // Clear the interval for delayed tracking tooltips
  15521. clearInterval( this.delayedShow );
  15522. // Only set title if we had one before (see comment in _open())
  15523. // If the title attribute has changed since open(), don't restore
  15524. if ( target.data( "ui-tooltip-title" ) && !target.attr( "title" ) ) {
  15525. target.attr( "title", target.data( "ui-tooltip-title" ) );
  15526. }
  15527. this._removeDescribedBy( target );
  15528. tooltipData.hiding = true;
  15529. tooltip.stop( true );
  15530. this._hide( tooltip, this.options.hide, function() {
  15531. that._removeTooltip( $( this ) );
  15532. } );
  15533. target.removeData( "ui-tooltip-open" );
  15534. this._off( target, "mouseleave focusout keyup" );
  15535. // Remove 'remove' binding only on delegated targets
  15536. if ( target[ 0 ] !== this.element[ 0 ] ) {
  15537. this._off( target, "remove" );
  15538. }
  15539. this._off( this.document, "mousemove" );
  15540. if ( event && event.type === "mouseleave" ) {
  15541. $.each( this.parents, function( id, parent ) {
  15542. $( parent.element ).attr( "title", parent.title );
  15543. delete that.parents[ id ];
  15544. } );
  15545. }
  15546. tooltipData.closing = true;
  15547. this._trigger( "close", event, { tooltip: tooltip } );
  15548. if ( !tooltipData.hiding ) {
  15549. tooltipData.closing = false;
  15550. }
  15551. },
  15552. _tooltip: function( element ) {
  15553. var tooltip = $( "<div>" ).attr( "role", "tooltip" ),
  15554. content = $( "<div>" ).appendTo( tooltip ),
  15555. id = tooltip.uniqueId().attr( "id" );
  15556. this._addClass( content, "ui-tooltip-content" );
  15557. this._addClass( tooltip, "ui-tooltip", "ui-widget ui-widget-content" );
  15558. tooltip.appendTo( this._appendTo( element ) );
  15559. return this.tooltips[ id ] = {
  15560. element: element,
  15561. tooltip: tooltip
  15562. };
  15563. },
  15564. _find: function( target ) {
  15565. var id = target.data( "ui-tooltip-id" );
  15566. return id ? this.tooltips[ id ] : null;
  15567. },
  15568. _removeTooltip: function( tooltip ) {
  15569. tooltip.remove();
  15570. delete this.tooltips[ tooltip.attr( "id" ) ];
  15571. },
  15572. _appendTo: function( target ) {
  15573. var element = target.closest( ".ui-front, dialog" );
  15574. if ( !element.length ) {
  15575. element = this.document[ 0 ].body;
  15576. }
  15577. return element;
  15578. },
  15579. _destroy: function() {
  15580. var that = this;
  15581. // Close open tooltips
  15582. $.each( this.tooltips, function( id, tooltipData ) {
  15583. // Delegate to close method to handle common cleanup
  15584. var event = $.Event( "blur" ),
  15585. element = tooltipData.element;
  15586. event.target = event.currentTarget = element[ 0 ];
  15587. that.close( event, true );
  15588. // Remove immediately; destroying an open tooltip doesn't use the
  15589. // hide animation
  15590. $( "#" + id ).remove();
  15591. // Restore the title
  15592. if ( element.data( "ui-tooltip-title" ) ) {
  15593. // If the title attribute has changed since open(), don't restore
  15594. if ( !element.attr( "title" ) ) {
  15595. element.attr( "title", element.data( "ui-tooltip-title" ) );
  15596. }
  15597. element.removeData( "ui-tooltip-title" );
  15598. }
  15599. } );
  15600. this.liveRegion.remove();
  15601. }
  15602. } );
  15603. // DEPRECATED
  15604. // TODO: Switch return back to widget declaration at top of file when this is removed
  15605. if ( $.uiBackCompat !== false ) {
  15606. // Backcompat for tooltipClass option
  15607. $.widget( "ui.tooltip", $.ui.tooltip, {
  15608. options: {
  15609. tooltipClass: null
  15610. },
  15611. _tooltip: function() {
  15612. var tooltipData = this._superApply( arguments );
  15613. if ( this.options.tooltipClass ) {
  15614. tooltipData.tooltip.addClass( this.options.tooltipClass );
  15615. }
  15616. return tooltipData;
  15617. }
  15618. } );
  15619. }
  15620. var widgetsTooltip = $.ui.tooltip;
  15621. }));