jquery-ui.js 508 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187161881618916190161911619216193161941619516196161971619816199162001620116202162031620416205162061620716208162091621016211162121621316214162151621616217162181621916220162211622216223162241622516226162271622816229162301623116232162331623416235162361623716238162391624016241162421624316244162451624616247162481624916250162511625216253162541625516256162571625816259162601626116262162631626416265162661626716268162691627016271162721627316274162751627616277162781627916280162811628216283162841628516286162871628816289162901629116292162931629416295162961629716298162991630016301163021630316304163051630616307163081630916310163111631216313163141631516316163171631816319163201632116322163231632416325163261632716328163291633016331163321633316334163351633616337163381633916340163411634216343163441634516346163471634816349163501635116352163531635416355163561635716358163591636016361163621636316364163651636616367163681636916370163711637216373163741637516376163771637816379163801638116382163831638416385163861638716388163891639016391163921639316394163951639616397163981639916400164011640216403164041640516406164071640816409164101641116412164131641416415164161641716418164191642016421164221642316424164251642616427164281642916430164311643216433164341643516436164371643816439164401644116442164431644416445164461644716448164491645016451164521645316454164551645616457164581645916460164611646216463164641646516466164671646816469164701647116472164731647416475164761647716478164791648016481164821648316484164851648616487164881648916490164911649216493164941649516496164971649816499165001650116502165031650416505165061650716508165091651016511165121651316514165151651616517165181651916520165211652216523165241652516526165271652816529165301653116532165331653416535165361653716538165391654016541165421654316544165451654616547165481654916550165511655216553165541655516556165571655816559165601656116562165631656416565165661656716568165691657016571165721657316574165751657616577165781657916580165811658216583165841658516586165871658816589165901659116592165931659416595165961659716598165991660016601166021660316604166051660616607166081660916610166111661216613166141661516616166171661816619166201662116622166231662416625166261662716628166291663016631166321663316634166351663616637166381663916640166411664216643166441664516646166471664816649166501665116652166531665416655166561665716658166591666016661166621666316664166651666616667166681666916670166711667216673166741667516676166771667816679166801668116682166831668416685166861668716688166891669016691166921669316694166951669616697166981669916700167011670216703167041670516706167071670816709167101671116712167131671416715167161671716718167191672016721167221672316724167251672616727167281672916730167311673216733167341673516736167371673816739167401674116742167431674416745167461674716748167491675016751167521675316754167551675616757167581675916760167611676216763167641676516766167671676816769167701677116772167731677416775167761677716778167791678016781167821678316784167851678616787167881678916790167911679216793167941679516796167971679816799168001680116802168031680416805168061680716808168091681016811168121681316814168151681616817168181681916820168211682216823168241682516826168271682816829168301683116832168331683416835168361683716838168391684016841168421684316844168451684616847168481684916850168511685216853168541685516856168571685816859168601686116862168631686416865168661686716868168691687016871168721687316874168751687616877168781687916880168811688216883168841688516886168871688816889168901689116892168931689416895168961689716898168991690016901169021690316904169051690616907169081690916910169111691216913169141691516916169171691816919169201692116922169231692416925169261692716928169291693016931169321693316934169351693616937169381693916940169411694216943169441694516946169471694816949169501695116952169531695416955169561695716958169591696016961169621696316964169651696616967169681696916970169711697216973169741697516976169771697816979169801698116982169831698416985169861698716988169891699016991169921699316994169951699616997169981699917000170011700217003170041700517006170071700817009170101701117012170131701417015170161701717018170191702017021170221702317024170251702617027170281702917030170311703217033170341703517036170371703817039170401704117042170431704417045170461704717048170491705017051170521705317054170551705617057170581705917060170611706217063170641706517066170671706817069170701707117072170731707417075170761707717078170791708017081170821708317084170851708617087170881708917090170911709217093170941709517096170971709817099171001710117102171031710417105171061710717108171091711017111171121711317114171151711617117171181711917120171211712217123171241712517126171271712817129171301713117132171331713417135171361713717138171391714017141171421714317144171451714617147171481714917150171511715217153171541715517156171571715817159171601716117162171631716417165171661716717168171691717017171171721717317174171751717617177171781717917180171811718217183171841718517186171871718817189171901719117192171931719417195171961719717198171991720017201172021720317204172051720617207172081720917210172111721217213172141721517216172171721817219172201722117222172231722417225172261722717228172291723017231172321723317234172351723617237172381723917240172411724217243172441724517246172471724817249172501725117252172531725417255172561725717258172591726017261172621726317264172651726617267172681726917270172711727217273172741727517276172771727817279172801728117282172831728417285172861728717288172891729017291172921729317294172951729617297172981729917300173011730217303173041730517306173071730817309173101731117312173131731417315173161731717318173191732017321173221732317324173251732617327173281732917330173311733217333173341733517336173371733817339173401734117342173431734417345173461734717348173491735017351173521735317354173551735617357173581735917360173611736217363173641736517366173671736817369173701737117372173731737417375173761737717378173791738017381173821738317384173851738617387173881738917390173911739217393173941739517396173971739817399174001740117402174031740417405174061740717408174091741017411174121741317414174151741617417174181741917420174211742217423174241742517426174271742817429174301743117432174331743417435174361743717438174391744017441174421744317444174451744617447174481744917450174511745217453174541745517456174571745817459174601746117462174631746417465174661746717468174691747017471174721747317474174751747617477174781747917480174811748217483174841748517486174871748817489174901749117492174931749417495174961749717498174991750017501175021750317504175051750617507175081750917510175111751217513175141751517516175171751817519175201752117522175231752417525175261752717528175291753017531175321753317534175351753617537175381753917540175411754217543175441754517546175471754817549175501755117552175531755417555175561755717558175591756017561175621756317564175651756617567175681756917570175711757217573175741757517576175771757817579175801758117582175831758417585175861758717588175891759017591175921759317594175951759617597175981759917600176011760217603176041760517606176071760817609176101761117612176131761417615176161761717618176191762017621176221762317624176251762617627176281762917630176311763217633176341763517636176371763817639176401764117642176431764417645176461764717648176491765017651176521765317654176551765617657176581765917660176611766217663176641766517666176671766817669176701767117672176731767417675176761767717678176791768017681176821768317684176851768617687176881768917690176911769217693176941769517696176971769817699177001770117702177031770417705177061770717708177091771017711177121771317714177151771617717177181771917720177211772217723177241772517726177271772817729177301773117732177331773417735177361773717738177391774017741177421774317744177451774617747177481774917750177511775217753177541775517756177571775817759177601776117762177631776417765177661776717768177691777017771177721777317774177751777617777177781777917780177811778217783177841778517786177871778817789177901779117792177931779417795177961779717798177991780017801178021780317804178051780617807178081780917810178111781217813178141781517816178171781817819178201782117822178231782417825178261782717828178291783017831178321783317834178351783617837178381783917840178411784217843178441784517846178471784817849178501785117852178531785417855178561785717858178591786017861178621786317864178651786617867178681786917870178711787217873178741787517876178771787817879178801788117882178831788417885178861788717888178891789017891178921789317894178951789617897178981789917900179011790217903179041790517906179071790817909179101791117912179131791417915179161791717918179191792017921179221792317924179251792617927179281792917930179311793217933179341793517936179371793817939179401794117942179431794417945179461794717948179491795017951179521795317954179551795617957179581795917960179611796217963179641796517966179671796817969179701797117972179731797417975179761797717978179791798017981179821798317984179851798617987179881798917990179911799217993179941799517996179971799817999180001800118002180031800418005180061800718008180091801018011180121801318014180151801618017180181801918020180211802218023180241802518026180271802818029180301803118032180331803418035180361803718038180391804018041180421804318044180451804618047180481804918050180511805218053180541805518056180571805818059180601806118062180631806418065180661806718068180691807018071180721807318074180751807618077180781807918080180811808218083180841808518086180871808818089180901809118092180931809418095180961809718098180991810018101181021810318104181051810618107181081810918110181111811218113181141811518116181171811818119181201812118122181231812418125181261812718128181291813018131181321813318134181351813618137181381813918140181411814218143181441814518146181471814818149181501815118152181531815418155181561815718158181591816018161181621816318164181651816618167181681816918170181711817218173181741817518176181771817818179181801818118182181831818418185181861818718188181891819018191181921819318194181951819618197181981819918200182011820218203182041820518206182071820818209182101821118212182131821418215182161821718218182191822018221182221822318224182251822618227182281822918230182311823218233182341823518236182371823818239182401824118242182431824418245182461824718248182491825018251182521825318254182551825618257182581825918260182611826218263182641826518266182671826818269182701827118272182731827418275182761827718278182791828018281182821828318284182851828618287182881828918290182911829218293182941829518296182971829818299183001830118302183031830418305183061830718308183091831018311183121831318314183151831618317183181831918320183211832218323183241832518326183271832818329183301833118332183331833418335183361833718338183391834018341183421834318344183451834618347183481834918350183511835218353183541835518356183571835818359183601836118362183631836418365183661836718368183691837018371183721837318374183751837618377183781837918380183811838218383183841838518386183871838818389183901839118392183931839418395183961839718398183991840018401184021840318404184051840618407184081840918410184111841218413184141841518416184171841818419184201842118422184231842418425184261842718428184291843018431184321843318434184351843618437184381843918440184411844218443184441844518446184471844818449184501845118452184531845418455184561845718458184591846018461184621846318464184651846618467184681846918470184711847218473184741847518476184771847818479184801848118482184831848418485184861848718488184891849018491184921849318494184951849618497184981849918500185011850218503185041850518506185071850818509185101851118512185131851418515185161851718518185191852018521185221852318524185251852618527185281852918530185311853218533185341853518536185371853818539185401854118542185431854418545185461854718548185491855018551185521855318554185551855618557185581855918560185611856218563185641856518566185671856818569185701857118572185731857418575185761857718578185791858018581185821858318584185851858618587185881858918590185911859218593185941859518596185971859818599186001860118602186031860418605186061860718608186091861018611186121861318614186151861618617186181861918620186211862218623186241862518626186271862818629186301863118632186331863418635186361863718638186391864018641186421864318644186451864618647186481864918650186511865218653186541865518656186571865818659186601866118662186631866418665186661866718668186691867018671186721867318674186751867618677186781867918680186811868218683186841868518686
  1. /*! jQuery UI - v1.12.0 - 2016-09-04
  2. * http://jqueryui.com
  3. * Includes: widget.js, position.js, data.js, disable-selection.js, focusable.js, form-reset-mixin.js, jquery-1-7.js, keycode.js, labels.js, scroll-parent.js, tabbable.js, unique-id.js, widgets/draggable.js, widgets/droppable.js, widgets/resizable.js, widgets/selectable.js, widgets/sortable.js, widgets/accordion.js, widgets/autocomplete.js, widgets/button.js, widgets/checkboxradio.js, widgets/controlgroup.js, widgets/datepicker.js, widgets/dialog.js, widgets/menu.js, widgets/mouse.js, widgets/progressbar.js, widgets/selectmenu.js, widgets/slider.js, widgets/spinner.js, widgets/tabs.js, widgets/tooltip.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
  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 Focusable 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: :focusable Selector
  1107. //>>group: Core
  1108. //>>description: Selects elements which can be focused.
  1109. //>>docs: http://api.jqueryui.com/focusable-selector/
  1110. // Selectors
  1111. $.ui.focusable = function( element, hasTabindex ) {
  1112. var map, mapName, img, focusableIfVisible, fieldset,
  1113. nodeName = element.nodeName.toLowerCase();
  1114. if ( "area" === nodeName ) {
  1115. map = element.parentNode;
  1116. mapName = map.name;
  1117. if ( !element.href || !mapName || map.nodeName.toLowerCase() !== "map" ) {
  1118. return false;
  1119. }
  1120. img = $( "img[usemap='#" + mapName + "']" );
  1121. return img.length > 0 && img.is( ":visible" );
  1122. }
  1123. if ( /^(input|select|textarea|button|object)$/.test( nodeName ) ) {
  1124. focusableIfVisible = !element.disabled;
  1125. if ( focusableIfVisible ) {
  1126. // Form controls within a disabled fieldset are disabled.
  1127. // However, controls within the fieldset's legend do not get disabled.
  1128. // Since controls generally aren't placed inside legends, we skip
  1129. // this portion of the check.
  1130. fieldset = $( element ).closest( "fieldset" )[ 0 ];
  1131. if ( fieldset ) {
  1132. focusableIfVisible = !fieldset.disabled;
  1133. }
  1134. }
  1135. } else if ( "a" === nodeName ) {
  1136. focusableIfVisible = element.href || hasTabindex;
  1137. } else {
  1138. focusableIfVisible = hasTabindex;
  1139. }
  1140. return focusableIfVisible && $( element ).is( ":visible" ) && visible( $( element ) );
  1141. };
  1142. // Support: IE 8 only
  1143. // IE 8 doesn't resolve inherit to visible/hidden for computed values
  1144. function visible( element ) {
  1145. var visibility = element.css( "visibility" );
  1146. while ( visibility === "inherit" ) {
  1147. element = element.parent();
  1148. visibility = element.css( "visibility" );
  1149. }
  1150. return visibility !== "hidden";
  1151. }
  1152. $.extend( $.expr[ ":" ], {
  1153. focusable: function( element ) {
  1154. return $.ui.focusable( element, $.attr( element, "tabindex" ) != null );
  1155. }
  1156. } );
  1157. var focusable = $.ui.focusable;
  1158. // Support: IE8 Only
  1159. // IE8 does not support the form attribute and when it is supplied. It overwrites the form prop
  1160. // with a string, so we need to find the proper form.
  1161. var form = $.fn.form = function() {
  1162. return typeof this[ 0 ].form === "string" ? this.closest( "form" ) : $( this[ 0 ].form );
  1163. };
  1164. /*!
  1165. * jQuery UI Form Reset Mixin 1.12.0
  1166. * http://jqueryui.com
  1167. *
  1168. * Copyright jQuery Foundation and other contributors
  1169. * Released under the MIT license.
  1170. * http://jquery.org/license
  1171. */
  1172. //>>label: Form Reset Mixin
  1173. //>>group: Core
  1174. //>>description: Refresh input widgets when their form is reset
  1175. //>>docs: http://api.jqueryui.com/form-reset-mixin/
  1176. var formResetMixin = $.ui.formResetMixin = {
  1177. _formResetHandler: function() {
  1178. var form = $( this );
  1179. // Wait for the form reset to actually happen before refreshing
  1180. setTimeout( function() {
  1181. var instances = form.data( "ui-form-reset-instances" );
  1182. $.each( instances, function() {
  1183. this.refresh();
  1184. } );
  1185. } );
  1186. },
  1187. _bindFormResetHandler: function() {
  1188. this.form = this.element.form();
  1189. if ( !this.form.length ) {
  1190. return;
  1191. }
  1192. var instances = this.form.data( "ui-form-reset-instances" ) || [];
  1193. if ( !instances.length ) {
  1194. // We don't use _on() here because we use a single event handler per form
  1195. this.form.on( "reset.ui-form-reset", this._formResetHandler );
  1196. }
  1197. instances.push( this );
  1198. this.form.data( "ui-form-reset-instances", instances );
  1199. },
  1200. _unbindFormResetHandler: function() {
  1201. if ( !this.form.length ) {
  1202. return;
  1203. }
  1204. var instances = this.form.data( "ui-form-reset-instances" );
  1205. instances.splice( $.inArray( this, instances ), 1 );
  1206. if ( instances.length ) {
  1207. this.form.data( "ui-form-reset-instances", instances );
  1208. } else {
  1209. this.form
  1210. .removeData( "ui-form-reset-instances" )
  1211. .off( "reset.ui-form-reset" );
  1212. }
  1213. }
  1214. };
  1215. /*!
  1216. * jQuery UI Support for jQuery core 1.7.x 1.12.0
  1217. * http://jqueryui.com
  1218. *
  1219. * Copyright jQuery Foundation and other contributors
  1220. * Released under the MIT license.
  1221. * http://jquery.org/license
  1222. *
  1223. */
  1224. //>>label: jQuery 1.7 Support
  1225. //>>group: Core
  1226. //>>description: Support version 1.7.x of jQuery core
  1227. // Support: jQuery 1.7 only
  1228. // Not a great way to check versions, but since we only support 1.7+ and only
  1229. // need to detect <1.8, this is a simple check that should suffice. Checking
  1230. // for "1.7." would be a bit safer, but the version string is 1.7, not 1.7.0
  1231. // and we'll never reach 1.70.0 (if we do, we certainly won't be supporting
  1232. // 1.7 anymore). See #11197 for why we're not using feature detection.
  1233. if ( $.fn.jquery.substring( 0, 3 ) === "1.7" ) {
  1234. // Setters for .innerWidth(), .innerHeight(), .outerWidth(), .outerHeight()
  1235. // Unlike jQuery Core 1.8+, these only support numeric values to set the
  1236. // dimensions in pixels
  1237. $.each( [ "Width", "Height" ], function( i, name ) {
  1238. var side = name === "Width" ? [ "Left", "Right" ] : [ "Top", "Bottom" ],
  1239. type = name.toLowerCase(),
  1240. orig = {
  1241. innerWidth: $.fn.innerWidth,
  1242. innerHeight: $.fn.innerHeight,
  1243. outerWidth: $.fn.outerWidth,
  1244. outerHeight: $.fn.outerHeight
  1245. };
  1246. function reduce( elem, size, border, margin ) {
  1247. $.each( side, function() {
  1248. size -= parseFloat( $.css( elem, "padding" + this ) ) || 0;
  1249. if ( border ) {
  1250. size -= parseFloat( $.css( elem, "border" + this + "Width" ) ) || 0;
  1251. }
  1252. if ( margin ) {
  1253. size -= parseFloat( $.css( elem, "margin" + this ) ) || 0;
  1254. }
  1255. } );
  1256. return size;
  1257. }
  1258. $.fn[ "inner" + name ] = function( size ) {
  1259. if ( size === undefined ) {
  1260. return orig[ "inner" + name ].call( this );
  1261. }
  1262. return this.each( function() {
  1263. $( this ).css( type, reduce( this, size ) + "px" );
  1264. } );
  1265. };
  1266. $.fn[ "outer" + name ] = function( size, margin ) {
  1267. if ( typeof size !== "number" ) {
  1268. return orig[ "outer" + name ].call( this, size );
  1269. }
  1270. return this.each( function() {
  1271. $( this ).css( type, reduce( this, size, true, margin ) + "px" );
  1272. } );
  1273. };
  1274. } );
  1275. $.fn.addBack = function( selector ) {
  1276. return this.add( selector == null ?
  1277. this.prevObject : this.prevObject.filter( selector )
  1278. );
  1279. };
  1280. }
  1281. ;
  1282. /*!
  1283. * jQuery UI Keycode 1.12.0
  1284. * http://jqueryui.com
  1285. *
  1286. * Copyright jQuery Foundation and other contributors
  1287. * Released under the MIT license.
  1288. * http://jquery.org/license
  1289. */
  1290. //>>label: Keycode
  1291. //>>group: Core
  1292. //>>description: Provide keycodes as keynames
  1293. //>>docs: http://api.jqueryui.com/jQuery.ui.keyCode/
  1294. var keycode = $.ui.keyCode = {
  1295. BACKSPACE: 8,
  1296. COMMA: 188,
  1297. DELETE: 46,
  1298. DOWN: 40,
  1299. END: 35,
  1300. ENTER: 13,
  1301. ESCAPE: 27,
  1302. HOME: 36,
  1303. LEFT: 37,
  1304. PAGE_DOWN: 34,
  1305. PAGE_UP: 33,
  1306. PERIOD: 190,
  1307. RIGHT: 39,
  1308. SPACE: 32,
  1309. TAB: 9,
  1310. UP: 38
  1311. };
  1312. // Internal use only
  1313. var escapeSelector = $.ui.escapeSelector = ( function() {
  1314. var selectorEscape = /([!"#$%&'()*+,./:;<=>?@[\]^`{|}~])/g;
  1315. return function( selector ) {
  1316. return selector.replace( selectorEscape, "\\$1" );
  1317. };
  1318. } )();
  1319. /*!
  1320. * jQuery UI Labels 1.12.0
  1321. * http://jqueryui.com
  1322. *
  1323. * Copyright jQuery Foundation and other contributors
  1324. * Released under the MIT license.
  1325. * http://jquery.org/license
  1326. */
  1327. //>>label: labels
  1328. //>>group: Core
  1329. //>>description: Find all the labels associated with a given input
  1330. //>>docs: http://api.jqueryui.com/labels/
  1331. var labels = $.fn.labels = function() {
  1332. var ancestor, selector, id, labels, ancestors;
  1333. // Check control.labels first
  1334. if ( this[ 0 ].labels && this[ 0 ].labels.length ) {
  1335. return this.pushStack( this[ 0 ].labels );
  1336. }
  1337. // Support: IE <= 11, FF <= 37, Android <= 2.3 only
  1338. // Above browsers do not support control.labels. Everything below is to support them
  1339. // as well as document fragments. control.labels does not work on document fragments
  1340. labels = this.eq( 0 ).parents( "label" );
  1341. // Look for the label based on the id
  1342. id = this.attr( "id" );
  1343. if ( id ) {
  1344. // We don't search against the document in case the element
  1345. // is disconnected from the DOM
  1346. ancestor = this.eq( 0 ).parents().last();
  1347. // Get a full set of top level ancestors
  1348. ancestors = ancestor.add( ancestor.length ? ancestor.siblings() : this.siblings() );
  1349. // Create a selector for the label based on the id
  1350. selector = "label[for='" + $.ui.escapeSelector( id ) + "']";
  1351. labels = labels.add( ancestors.find( selector ).addBack( selector ) );
  1352. }
  1353. // Return whatever we have found for labels
  1354. return this.pushStack( labels );
  1355. };
  1356. /*!
  1357. * jQuery UI Scroll Parent 1.12.0
  1358. * http://jqueryui.com
  1359. *
  1360. * Copyright jQuery Foundation and other contributors
  1361. * Released under the MIT license.
  1362. * http://jquery.org/license
  1363. */
  1364. //>>label: scrollParent
  1365. //>>group: Core
  1366. //>>description: Get the closest ancestor element that is scrollable.
  1367. //>>docs: http://api.jqueryui.com/scrollParent/
  1368. var scrollParent = $.fn.scrollParent = function( includeHidden ) {
  1369. var position = this.css( "position" ),
  1370. excludeStaticParent = position === "absolute",
  1371. overflowRegex = includeHidden ? /(auto|scroll|hidden)/ : /(auto|scroll)/,
  1372. scrollParent = this.parents().filter( function() {
  1373. var parent = $( this );
  1374. if ( excludeStaticParent && parent.css( "position" ) === "static" ) {
  1375. return false;
  1376. }
  1377. return overflowRegex.test( parent.css( "overflow" ) + parent.css( "overflow-y" ) +
  1378. parent.css( "overflow-x" ) );
  1379. } ).eq( 0 );
  1380. return position === "fixed" || !scrollParent.length ?
  1381. $( this[ 0 ].ownerDocument || document ) :
  1382. scrollParent;
  1383. };
  1384. /*!
  1385. * jQuery UI Tabbable 1.12.0
  1386. * http://jqueryui.com
  1387. *
  1388. * Copyright jQuery Foundation and other contributors
  1389. * Released under the MIT license.
  1390. * http://jquery.org/license
  1391. */
  1392. //>>label: :tabbable Selector
  1393. //>>group: Core
  1394. //>>description: Selects elements which can be tabbed to.
  1395. //>>docs: http://api.jqueryui.com/tabbable-selector/
  1396. var tabbable = $.extend( $.expr[ ":" ], {
  1397. tabbable: function( element ) {
  1398. var tabIndex = $.attr( element, "tabindex" ),
  1399. hasTabindex = tabIndex != null;
  1400. return ( !hasTabindex || tabIndex >= 0 ) && $.ui.focusable( element, hasTabindex );
  1401. }
  1402. } );
  1403. /*!
  1404. * jQuery UI Unique ID 1.12.0
  1405. * http://jqueryui.com
  1406. *
  1407. * Copyright jQuery Foundation and other contributors
  1408. * Released under the MIT license.
  1409. * http://jquery.org/license
  1410. */
  1411. //>>label: uniqueId
  1412. //>>group: Core
  1413. //>>description: Functions to generate and remove uniqueId's
  1414. //>>docs: http://api.jqueryui.com/uniqueId/
  1415. var uniqueId = $.fn.extend( {
  1416. uniqueId: ( function() {
  1417. var uuid = 0;
  1418. return function() {
  1419. return this.each( function() {
  1420. if ( !this.id ) {
  1421. this.id = "ui-id-" + ( ++uuid );
  1422. }
  1423. } );
  1424. };
  1425. } )(),
  1426. removeUniqueId: function() {
  1427. return this.each( function() {
  1428. if ( /^ui-id-\d+$/.test( this.id ) ) {
  1429. $( this ).removeAttr( "id" );
  1430. }
  1431. } );
  1432. }
  1433. } );
  1434. // This file is deprecated
  1435. var ie = $.ui.ie = !!/msie [\w.]+/.exec( navigator.userAgent.toLowerCase() );
  1436. /*!
  1437. * jQuery UI Mouse 1.12.0
  1438. * http://jqueryui.com
  1439. *
  1440. * Copyright jQuery Foundation and other contributors
  1441. * Released under the MIT license.
  1442. * http://jquery.org/license
  1443. */
  1444. //>>label: Mouse
  1445. //>>group: Widgets
  1446. //>>description: Abstracts mouse-based interactions to assist in creating certain widgets.
  1447. //>>docs: http://api.jqueryui.com/mouse/
  1448. var mouseHandled = false;
  1449. $( document ).on( "mouseup", function() {
  1450. mouseHandled = false;
  1451. } );
  1452. var widgetsMouse = $.widget( "ui.mouse", {
  1453. version: "1.12.0",
  1454. options: {
  1455. cancel: "input, textarea, button, select, option",
  1456. distance: 1,
  1457. delay: 0
  1458. },
  1459. _mouseInit: function() {
  1460. var that = this;
  1461. this.element
  1462. .on( "mousedown." + this.widgetName, function( event ) {
  1463. return that._mouseDown( event );
  1464. } )
  1465. .on( "click." + this.widgetName, function( event ) {
  1466. if ( true === $.data( event.target, that.widgetName + ".preventClickEvent" ) ) {
  1467. $.removeData( event.target, that.widgetName + ".preventClickEvent" );
  1468. event.stopImmediatePropagation();
  1469. return false;
  1470. }
  1471. } );
  1472. this.started = false;
  1473. },
  1474. // TODO: make sure destroying one instance of mouse doesn't mess with
  1475. // other instances of mouse
  1476. _mouseDestroy: function() {
  1477. this.element.off( "." + this.widgetName );
  1478. if ( this._mouseMoveDelegate ) {
  1479. this.document
  1480. .off( "mousemove." + this.widgetName, this._mouseMoveDelegate )
  1481. .off( "mouseup." + this.widgetName, this._mouseUpDelegate );
  1482. }
  1483. },
  1484. _mouseDown: function( event ) {
  1485. // don't let more than one widget handle mouseStart
  1486. if ( mouseHandled ) {
  1487. return;
  1488. }
  1489. this._mouseMoved = false;
  1490. // We may have missed mouseup (out of window)
  1491. ( this._mouseStarted && this._mouseUp( event ) );
  1492. this._mouseDownEvent = event;
  1493. var that = this,
  1494. btnIsLeft = ( event.which === 1 ),
  1495. // event.target.nodeName works around a bug in IE 8 with
  1496. // disabled inputs (#7620)
  1497. elIsCancel = ( typeof this.options.cancel === "string" && event.target.nodeName ?
  1498. $( event.target ).closest( this.options.cancel ).length : false );
  1499. if ( !btnIsLeft || elIsCancel || !this._mouseCapture( event ) ) {
  1500. return true;
  1501. }
  1502. this.mouseDelayMet = !this.options.delay;
  1503. if ( !this.mouseDelayMet ) {
  1504. this._mouseDelayTimer = setTimeout( function() {
  1505. that.mouseDelayMet = true;
  1506. }, this.options.delay );
  1507. }
  1508. if ( this._mouseDistanceMet( event ) && this._mouseDelayMet( event ) ) {
  1509. this._mouseStarted = ( this._mouseStart( event ) !== false );
  1510. if ( !this._mouseStarted ) {
  1511. event.preventDefault();
  1512. return true;
  1513. }
  1514. }
  1515. // Click event may never have fired (Gecko & Opera)
  1516. if ( true === $.data( event.target, this.widgetName + ".preventClickEvent" ) ) {
  1517. $.removeData( event.target, this.widgetName + ".preventClickEvent" );
  1518. }
  1519. // These delegates are required to keep context
  1520. this._mouseMoveDelegate = function( event ) {
  1521. return that._mouseMove( event );
  1522. };
  1523. this._mouseUpDelegate = function( event ) {
  1524. return that._mouseUp( event );
  1525. };
  1526. this.document
  1527. .on( "mousemove." + this.widgetName, this._mouseMoveDelegate )
  1528. .on( "mouseup." + this.widgetName, this._mouseUpDelegate );
  1529. event.preventDefault();
  1530. mouseHandled = true;
  1531. return true;
  1532. },
  1533. _mouseMove: function( event ) {
  1534. // Only check for mouseups outside the document if you've moved inside the document
  1535. // at least once. This prevents the firing of mouseup in the case of IE<9, which will
  1536. // fire a mousemove event if content is placed under the cursor. See #7778
  1537. // Support: IE <9
  1538. if ( this._mouseMoved ) {
  1539. // IE mouseup check - mouseup happened when mouse was out of window
  1540. if ( $.ui.ie && ( !document.documentMode || document.documentMode < 9 ) &&
  1541. !event.button ) {
  1542. return this._mouseUp( event );
  1543. // Iframe mouseup check - mouseup occurred in another document
  1544. } else if ( !event.which ) {
  1545. // Support: Safari <=8 - 9
  1546. // Safari sets which to 0 if you press any of the following keys
  1547. // during a drag (#14461)
  1548. if ( event.originalEvent.altKey || event.originalEvent.ctrlKey ||
  1549. event.originalEvent.metaKey || event.originalEvent.shiftKey ) {
  1550. this.ignoreMissingWhich = true;
  1551. } else if ( !this.ignoreMissingWhich ) {
  1552. return this._mouseUp( event );
  1553. }
  1554. }
  1555. }
  1556. if ( event.which || event.button ) {
  1557. this._mouseMoved = true;
  1558. }
  1559. if ( this._mouseStarted ) {
  1560. this._mouseDrag( event );
  1561. return event.preventDefault();
  1562. }
  1563. if ( this._mouseDistanceMet( event ) && this._mouseDelayMet( event ) ) {
  1564. this._mouseStarted =
  1565. ( this._mouseStart( this._mouseDownEvent, event ) !== false );
  1566. ( this._mouseStarted ? this._mouseDrag( event ) : this._mouseUp( event ) );
  1567. }
  1568. return !this._mouseStarted;
  1569. },
  1570. _mouseUp: function( event ) {
  1571. this.document
  1572. .off( "mousemove." + this.widgetName, this._mouseMoveDelegate )
  1573. .off( "mouseup." + this.widgetName, this._mouseUpDelegate );
  1574. if ( this._mouseStarted ) {
  1575. this._mouseStarted = false;
  1576. if ( event.target === this._mouseDownEvent.target ) {
  1577. $.data( event.target, this.widgetName + ".preventClickEvent", true );
  1578. }
  1579. this._mouseStop( event );
  1580. }
  1581. if ( this._mouseDelayTimer ) {
  1582. clearTimeout( this._mouseDelayTimer );
  1583. delete this._mouseDelayTimer;
  1584. }
  1585. this.ignoreMissingWhich = false;
  1586. mouseHandled = false;
  1587. event.preventDefault();
  1588. },
  1589. _mouseDistanceMet: function( event ) {
  1590. return ( Math.max(
  1591. Math.abs( this._mouseDownEvent.pageX - event.pageX ),
  1592. Math.abs( this._mouseDownEvent.pageY - event.pageY )
  1593. ) >= this.options.distance
  1594. );
  1595. },
  1596. _mouseDelayMet: function( /* event */ ) {
  1597. return this.mouseDelayMet;
  1598. },
  1599. // These are placeholder methods, to be overriden by extending plugin
  1600. _mouseStart: function( /* event */ ) {},
  1601. _mouseDrag: function( /* event */ ) {},
  1602. _mouseStop: function( /* event */ ) {},
  1603. _mouseCapture: function( /* event */ ) { return true; }
  1604. } );
  1605. // $.ui.plugin is deprecated. Use $.widget() extensions instead.
  1606. var plugin = $.ui.plugin = {
  1607. add: function( module, option, set ) {
  1608. var i,
  1609. proto = $.ui[ module ].prototype;
  1610. for ( i in set ) {
  1611. proto.plugins[ i ] = proto.plugins[ i ] || [];
  1612. proto.plugins[ i ].push( [ option, set[ i ] ] );
  1613. }
  1614. },
  1615. call: function( instance, name, args, allowDisconnected ) {
  1616. var i,
  1617. set = instance.plugins[ name ];
  1618. if ( !set ) {
  1619. return;
  1620. }
  1621. if ( !allowDisconnected && ( !instance.element[ 0 ].parentNode ||
  1622. instance.element[ 0 ].parentNode.nodeType === 11 ) ) {
  1623. return;
  1624. }
  1625. for ( i = 0; i < set.length; i++ ) {
  1626. if ( instance.options[ set[ i ][ 0 ] ] ) {
  1627. set[ i ][ 1 ].apply( instance.element, args );
  1628. }
  1629. }
  1630. }
  1631. };
  1632. var safeActiveElement = $.ui.safeActiveElement = function( document ) {
  1633. var activeElement;
  1634. // Support: IE 9 only
  1635. // IE9 throws an "Unspecified error" accessing document.activeElement from an <iframe>
  1636. try {
  1637. activeElement = document.activeElement;
  1638. } catch ( error ) {
  1639. activeElement = document.body;
  1640. }
  1641. // Support: IE 9 - 11 only
  1642. // IE may return null instead of an element
  1643. // Interestingly, this only seems to occur when NOT in an iframe
  1644. if ( !activeElement ) {
  1645. activeElement = document.body;
  1646. }
  1647. // Support: IE 11 only
  1648. // IE11 returns a seemingly empty object in some cases when accessing
  1649. // document.activeElement from an <iframe>
  1650. if ( !activeElement.nodeName ) {
  1651. activeElement = document.body;
  1652. }
  1653. return activeElement;
  1654. };
  1655. var safeBlur = $.ui.safeBlur = function( element ) {
  1656. // Support: IE9 - 10 only
  1657. // If the <body> is blurred, IE will switch windows, see #9420
  1658. if ( element && element.nodeName.toLowerCase() !== "body" ) {
  1659. $( element ).trigger( "blur" );
  1660. }
  1661. };
  1662. /*!
  1663. * jQuery UI Draggable 1.12.0
  1664. * http://jqueryui.com
  1665. *
  1666. * Copyright jQuery Foundation and other contributors
  1667. * Released under the MIT license.
  1668. * http://jquery.org/license
  1669. */
  1670. //>>label: Draggable
  1671. //>>group: Interactions
  1672. //>>description: Enables dragging functionality for any element.
  1673. //>>docs: http://api.jqueryui.com/draggable/
  1674. //>>demos: http://jqueryui.com/draggable/
  1675. //>>css.structure: ../../themes/base/draggable.css
  1676. $.widget( "ui.draggable", $.ui.mouse, {
  1677. version: "1.12.0",
  1678. widgetEventPrefix: "drag",
  1679. options: {
  1680. addClasses: true,
  1681. appendTo: "parent",
  1682. axis: false,
  1683. connectToSortable: false,
  1684. containment: false,
  1685. cursor: "auto",
  1686. cursorAt: false,
  1687. grid: false,
  1688. handle: false,
  1689. helper: "original",
  1690. iframeFix: false,
  1691. opacity: false,
  1692. refreshPositions: false,
  1693. revert: false,
  1694. revertDuration: 500,
  1695. scope: "default",
  1696. scroll: true,
  1697. scrollSensitivity: 20,
  1698. scrollSpeed: 20,
  1699. snap: false,
  1700. snapMode: "both",
  1701. snapTolerance: 20,
  1702. stack: false,
  1703. zIndex: false,
  1704. // Callbacks
  1705. drag: null,
  1706. start: null,
  1707. stop: null
  1708. },
  1709. _create: function() {
  1710. if ( this.options.helper === "original" ) {
  1711. this._setPositionRelative();
  1712. }
  1713. if ( this.options.addClasses ) {
  1714. this._addClass( "ui-draggable" );
  1715. }
  1716. this._setHandleClassName();
  1717. this._mouseInit();
  1718. },
  1719. _setOption: function( key, value ) {
  1720. this._super( key, value );
  1721. if ( key === "handle" ) {
  1722. this._removeHandleClassName();
  1723. this._setHandleClassName();
  1724. }
  1725. },
  1726. _destroy: function() {
  1727. if ( ( this.helper || this.element ).is( ".ui-draggable-dragging" ) ) {
  1728. this.destroyOnClear = true;
  1729. return;
  1730. }
  1731. this._removeHandleClassName();
  1732. this._mouseDestroy();
  1733. },
  1734. _mouseCapture: function( event ) {
  1735. var o = this.options;
  1736. this._blurActiveElement( event );
  1737. // Among others, prevent a drag on a resizable-handle
  1738. if ( this.helper || o.disabled ||
  1739. $( event.target ).closest( ".ui-resizable-handle" ).length > 0 ) {
  1740. return false;
  1741. }
  1742. //Quit if we're not on a valid handle
  1743. this.handle = this._getHandle( event );
  1744. if ( !this.handle ) {
  1745. return false;
  1746. }
  1747. this._blockFrames( o.iframeFix === true ? "iframe" : o.iframeFix );
  1748. return true;
  1749. },
  1750. _blockFrames: function( selector ) {
  1751. this.iframeBlocks = this.document.find( selector ).map( function() {
  1752. var iframe = $( this );
  1753. return $( "<div>" )
  1754. .css( "position", "absolute" )
  1755. .appendTo( iframe.parent() )
  1756. .outerWidth( iframe.outerWidth() )
  1757. .outerHeight( iframe.outerHeight() )
  1758. .offset( iframe.offset() )[ 0 ];
  1759. } );
  1760. },
  1761. _unblockFrames: function() {
  1762. if ( this.iframeBlocks ) {
  1763. this.iframeBlocks.remove();
  1764. delete this.iframeBlocks;
  1765. }
  1766. },
  1767. _blurActiveElement: function( event ) {
  1768. var activeElement = $.ui.safeActiveElement( this.document[ 0 ] ),
  1769. target = $( event.target );
  1770. // Only blur if the event occurred on an element that is:
  1771. // 1) within the draggable handle
  1772. // 2) but not within the currently focused element
  1773. // See #10527, #12472
  1774. if ( this._getHandle( event ) && target.closest( activeElement ).length ) {
  1775. return;
  1776. }
  1777. // Blur any element that currently has focus, see #4261
  1778. $.ui.safeBlur( activeElement );
  1779. },
  1780. _mouseStart: function( event ) {
  1781. var o = this.options;
  1782. //Create and append the visible helper
  1783. this.helper = this._createHelper( event );
  1784. this._addClass( this.helper, "ui-draggable-dragging" );
  1785. //Cache the helper size
  1786. this._cacheHelperProportions();
  1787. //If ddmanager is used for droppables, set the global draggable
  1788. if ( $.ui.ddmanager ) {
  1789. $.ui.ddmanager.current = this;
  1790. }
  1791. /*
  1792. * - Position generation -
  1793. * This block generates everything position related - it's the core of draggables.
  1794. */
  1795. //Cache the margins of the original element
  1796. this._cacheMargins();
  1797. //Store the helper's css position
  1798. this.cssPosition = this.helper.css( "position" );
  1799. this.scrollParent = this.helper.scrollParent( true );
  1800. this.offsetParent = this.helper.offsetParent();
  1801. this.hasFixedAncestor = this.helper.parents().filter( function() {
  1802. return $( this ).css( "position" ) === "fixed";
  1803. } ).length > 0;
  1804. //The element's absolute position on the page minus margins
  1805. this.positionAbs = this.element.offset();
  1806. this._refreshOffsets( event );
  1807. //Generate the original position
  1808. this.originalPosition = this.position = this._generatePosition( event, false );
  1809. this.originalPageX = event.pageX;
  1810. this.originalPageY = event.pageY;
  1811. //Adjust the mouse offset relative to the helper if "cursorAt" is supplied
  1812. ( o.cursorAt && this._adjustOffsetFromHelper( o.cursorAt ) );
  1813. //Set a containment if given in the options
  1814. this._setContainment();
  1815. //Trigger event + callbacks
  1816. if ( this._trigger( "start", event ) === false ) {
  1817. this._clear();
  1818. return false;
  1819. }
  1820. //Recache the helper size
  1821. this._cacheHelperProportions();
  1822. //Prepare the droppable offsets
  1823. if ( $.ui.ddmanager && !o.dropBehaviour ) {
  1824. $.ui.ddmanager.prepareOffsets( this, event );
  1825. }
  1826. // Execute the drag once - this causes the helper not to be visible before getting its
  1827. // correct position
  1828. this._mouseDrag( event, true );
  1829. // If the ddmanager is used for droppables, inform the manager that dragging has started
  1830. // (see #5003)
  1831. if ( $.ui.ddmanager ) {
  1832. $.ui.ddmanager.dragStart( this, event );
  1833. }
  1834. return true;
  1835. },
  1836. _refreshOffsets: function( event ) {
  1837. this.offset = {
  1838. top: this.positionAbs.top - this.margins.top,
  1839. left: this.positionAbs.left - this.margins.left,
  1840. scroll: false,
  1841. parent: this._getParentOffset(),
  1842. relative: this._getRelativeOffset()
  1843. };
  1844. this.offset.click = {
  1845. left: event.pageX - this.offset.left,
  1846. top: event.pageY - this.offset.top
  1847. };
  1848. },
  1849. _mouseDrag: function( event, noPropagation ) {
  1850. // reset any necessary cached properties (see #5009)
  1851. if ( this.hasFixedAncestor ) {
  1852. this.offset.parent = this._getParentOffset();
  1853. }
  1854. //Compute the helpers position
  1855. this.position = this._generatePosition( event, true );
  1856. this.positionAbs = this._convertPositionTo( "absolute" );
  1857. //Call plugins and callbacks and use the resulting position if something is returned
  1858. if ( !noPropagation ) {
  1859. var ui = this._uiHash();
  1860. if ( this._trigger( "drag", event, ui ) === false ) {
  1861. this._mouseUp( new $.Event( "mouseup", event ) );
  1862. return false;
  1863. }
  1864. this.position = ui.position;
  1865. }
  1866. this.helper[ 0 ].style.left = this.position.left + "px";
  1867. this.helper[ 0 ].style.top = this.position.top + "px";
  1868. if ( $.ui.ddmanager ) {
  1869. $.ui.ddmanager.drag( this, event );
  1870. }
  1871. return false;
  1872. },
  1873. _mouseStop: function( event ) {
  1874. //If we are using droppables, inform the manager about the drop
  1875. var that = this,
  1876. dropped = false;
  1877. if ( $.ui.ddmanager && !this.options.dropBehaviour ) {
  1878. dropped = $.ui.ddmanager.drop( this, event );
  1879. }
  1880. //if a drop comes from outside (a sortable)
  1881. if ( this.dropped ) {
  1882. dropped = this.dropped;
  1883. this.dropped = false;
  1884. }
  1885. if ( ( this.options.revert === "invalid" && !dropped ) ||
  1886. ( this.options.revert === "valid" && dropped ) ||
  1887. this.options.revert === true || ( $.isFunction( this.options.revert ) &&
  1888. this.options.revert.call( this.element, dropped ) )
  1889. ) {
  1890. $( this.helper ).animate(
  1891. this.originalPosition,
  1892. parseInt( this.options.revertDuration, 10 ),
  1893. function() {
  1894. if ( that._trigger( "stop", event ) !== false ) {
  1895. that._clear();
  1896. }
  1897. }
  1898. );
  1899. } else {
  1900. if ( this._trigger( "stop", event ) !== false ) {
  1901. this._clear();
  1902. }
  1903. }
  1904. return false;
  1905. },
  1906. _mouseUp: function( event ) {
  1907. this._unblockFrames();
  1908. // If the ddmanager is used for droppables, inform the manager that dragging has stopped
  1909. // (see #5003)
  1910. if ( $.ui.ddmanager ) {
  1911. $.ui.ddmanager.dragStop( this, event );
  1912. }
  1913. // Only need to focus if the event occurred on the draggable itself, see #10527
  1914. if ( this.handleElement.is( event.target ) ) {
  1915. // The interaction is over; whether or not the click resulted in a drag,
  1916. // focus the element
  1917. this.element.trigger( "focus" );
  1918. }
  1919. return $.ui.mouse.prototype._mouseUp.call( this, event );
  1920. },
  1921. cancel: function() {
  1922. if ( this.helper.is( ".ui-draggable-dragging" ) ) {
  1923. this._mouseUp( new $.Event( "mouseup", { target: this.element[ 0 ] } ) );
  1924. } else {
  1925. this._clear();
  1926. }
  1927. return this;
  1928. },
  1929. _getHandle: function( event ) {
  1930. return this.options.handle ?
  1931. !!$( event.target ).closest( this.element.find( this.options.handle ) ).length :
  1932. true;
  1933. },
  1934. _setHandleClassName: function() {
  1935. this.handleElement = this.options.handle ?
  1936. this.element.find( this.options.handle ) : this.element;
  1937. this._addClass( this.handleElement, "ui-draggable-handle" );
  1938. },
  1939. _removeHandleClassName: function() {
  1940. this._removeClass( this.handleElement, "ui-draggable-handle" );
  1941. },
  1942. _createHelper: function( event ) {
  1943. var o = this.options,
  1944. helperIsFunction = $.isFunction( o.helper ),
  1945. helper = helperIsFunction ?
  1946. $( o.helper.apply( this.element[ 0 ], [ event ] ) ) :
  1947. ( o.helper === "clone" ?
  1948. this.element.clone().removeAttr( "id" ) :
  1949. this.element );
  1950. if ( !helper.parents( "body" ).length ) {
  1951. helper.appendTo( ( o.appendTo === "parent" ?
  1952. this.element[ 0 ].parentNode :
  1953. o.appendTo ) );
  1954. }
  1955. // Http://bugs.jqueryui.com/ticket/9446
  1956. // a helper function can return the original element
  1957. // which wouldn't have been set to relative in _create
  1958. if ( helperIsFunction && helper[ 0 ] === this.element[ 0 ] ) {
  1959. this._setPositionRelative();
  1960. }
  1961. if ( helper[ 0 ] !== this.element[ 0 ] &&
  1962. !( /(fixed|absolute)/ ).test( helper.css( "position" ) ) ) {
  1963. helper.css( "position", "absolute" );
  1964. }
  1965. return helper;
  1966. },
  1967. _setPositionRelative: function() {
  1968. if ( !( /^(?:r|a|f)/ ).test( this.element.css( "position" ) ) ) {
  1969. this.element[ 0 ].style.position = "relative";
  1970. }
  1971. },
  1972. _adjustOffsetFromHelper: function( obj ) {
  1973. if ( typeof obj === "string" ) {
  1974. obj = obj.split( " " );
  1975. }
  1976. if ( $.isArray( obj ) ) {
  1977. obj = { left: +obj[ 0 ], top: +obj[ 1 ] || 0 };
  1978. }
  1979. if ( "left" in obj ) {
  1980. this.offset.click.left = obj.left + this.margins.left;
  1981. }
  1982. if ( "right" in obj ) {
  1983. this.offset.click.left = this.helperProportions.width - obj.right + this.margins.left;
  1984. }
  1985. if ( "top" in obj ) {
  1986. this.offset.click.top = obj.top + this.margins.top;
  1987. }
  1988. if ( "bottom" in obj ) {
  1989. this.offset.click.top = this.helperProportions.height - obj.bottom + this.margins.top;
  1990. }
  1991. },
  1992. _isRootNode: function( element ) {
  1993. return ( /(html|body)/i ).test( element.tagName ) || element === this.document[ 0 ];
  1994. },
  1995. _getParentOffset: function() {
  1996. //Get the offsetParent and cache its position
  1997. var po = this.offsetParent.offset(),
  1998. document = this.document[ 0 ];
  1999. // This is a special case where we need to modify a offset calculated on start, since the
  2000. // following happened:
  2001. // 1. The position of the helper is absolute, so it's position is calculated based on the
  2002. // next positioned parent
  2003. // 2. The actual offset parent is a child of the scroll parent, and the scroll parent isn't
  2004. // the document, which means that the scroll is included in the initial calculation of the
  2005. // offset of the parent, and never recalculated upon drag
  2006. if ( this.cssPosition === "absolute" && this.scrollParent[ 0 ] !== document &&
  2007. $.contains( this.scrollParent[ 0 ], this.offsetParent[ 0 ] ) ) {
  2008. po.left += this.scrollParent.scrollLeft();
  2009. po.top += this.scrollParent.scrollTop();
  2010. }
  2011. if ( this._isRootNode( this.offsetParent[ 0 ] ) ) {
  2012. po = { top: 0, left: 0 };
  2013. }
  2014. return {
  2015. top: po.top + ( parseInt( this.offsetParent.css( "borderTopWidth" ), 10 ) || 0 ),
  2016. left: po.left + ( parseInt( this.offsetParent.css( "borderLeftWidth" ), 10 ) || 0 )
  2017. };
  2018. },
  2019. _getRelativeOffset: function() {
  2020. if ( this.cssPosition !== "relative" ) {
  2021. return { top: 0, left: 0 };
  2022. }
  2023. var p = this.element.position(),
  2024. scrollIsRootNode = this._isRootNode( this.scrollParent[ 0 ] );
  2025. return {
  2026. top: p.top - ( parseInt( this.helper.css( "top" ), 10 ) || 0 ) +
  2027. ( !scrollIsRootNode ? this.scrollParent.scrollTop() : 0 ),
  2028. left: p.left - ( parseInt( this.helper.css( "left" ), 10 ) || 0 ) +
  2029. ( !scrollIsRootNode ? this.scrollParent.scrollLeft() : 0 )
  2030. };
  2031. },
  2032. _cacheMargins: function() {
  2033. this.margins = {
  2034. left: ( parseInt( this.element.css( "marginLeft" ), 10 ) || 0 ),
  2035. top: ( parseInt( this.element.css( "marginTop" ), 10 ) || 0 ),
  2036. right: ( parseInt( this.element.css( "marginRight" ), 10 ) || 0 ),
  2037. bottom: ( parseInt( this.element.css( "marginBottom" ), 10 ) || 0 )
  2038. };
  2039. },
  2040. _cacheHelperProportions: function() {
  2041. this.helperProportions = {
  2042. width: this.helper.outerWidth(),
  2043. height: this.helper.outerHeight()
  2044. };
  2045. },
  2046. _setContainment: function() {
  2047. var isUserScrollable, c, ce,
  2048. o = this.options,
  2049. document = this.document[ 0 ];
  2050. this.relativeContainer = null;
  2051. if ( !o.containment ) {
  2052. this.containment = null;
  2053. return;
  2054. }
  2055. if ( o.containment === "window" ) {
  2056. this.containment = [
  2057. $( window ).scrollLeft() - this.offset.relative.left - this.offset.parent.left,
  2058. $( window ).scrollTop() - this.offset.relative.top - this.offset.parent.top,
  2059. $( window ).scrollLeft() + $( window ).width() -
  2060. this.helperProportions.width - this.margins.left,
  2061. $( window ).scrollTop() +
  2062. ( $( window ).height() || document.body.parentNode.scrollHeight ) -
  2063. this.helperProportions.height - this.margins.top
  2064. ];
  2065. return;
  2066. }
  2067. if ( o.containment === "document" ) {
  2068. this.containment = [
  2069. 0,
  2070. 0,
  2071. $( document ).width() - this.helperProportions.width - this.margins.left,
  2072. ( $( document ).height() || document.body.parentNode.scrollHeight ) -
  2073. this.helperProportions.height - this.margins.top
  2074. ];
  2075. return;
  2076. }
  2077. if ( o.containment.constructor === Array ) {
  2078. this.containment = o.containment;
  2079. return;
  2080. }
  2081. if ( o.containment === "parent" ) {
  2082. o.containment = this.helper[ 0 ].parentNode;
  2083. }
  2084. c = $( o.containment );
  2085. ce = c[ 0 ];
  2086. if ( !ce ) {
  2087. return;
  2088. }
  2089. isUserScrollable = /(scroll|auto)/.test( c.css( "overflow" ) );
  2090. this.containment = [
  2091. ( parseInt( c.css( "borderLeftWidth" ), 10 ) || 0 ) +
  2092. ( parseInt( c.css( "paddingLeft" ), 10 ) || 0 ),
  2093. ( parseInt( c.css( "borderTopWidth" ), 10 ) || 0 ) +
  2094. ( parseInt( c.css( "paddingTop" ), 10 ) || 0 ),
  2095. ( isUserScrollable ? Math.max( ce.scrollWidth, ce.offsetWidth ) : ce.offsetWidth ) -
  2096. ( parseInt( c.css( "borderRightWidth" ), 10 ) || 0 ) -
  2097. ( parseInt( c.css( "paddingRight" ), 10 ) || 0 ) -
  2098. this.helperProportions.width -
  2099. this.margins.left -
  2100. this.margins.right,
  2101. ( isUserScrollable ? Math.max( ce.scrollHeight, ce.offsetHeight ) : ce.offsetHeight ) -
  2102. ( parseInt( c.css( "borderBottomWidth" ), 10 ) || 0 ) -
  2103. ( parseInt( c.css( "paddingBottom" ), 10 ) || 0 ) -
  2104. this.helperProportions.height -
  2105. this.margins.top -
  2106. this.margins.bottom
  2107. ];
  2108. this.relativeContainer = c;
  2109. },
  2110. _convertPositionTo: function( d, pos ) {
  2111. if ( !pos ) {
  2112. pos = this.position;
  2113. }
  2114. var mod = d === "absolute" ? 1 : -1,
  2115. scrollIsRootNode = this._isRootNode( this.scrollParent[ 0 ] );
  2116. return {
  2117. top: (
  2118. // The absolute mouse position
  2119. pos.top +
  2120. // Only for relative positioned nodes: Relative offset from element to offset parent
  2121. this.offset.relative.top * mod +
  2122. // The offsetParent's offset without borders (offset + border)
  2123. this.offset.parent.top * mod -
  2124. ( ( this.cssPosition === "fixed" ?
  2125. -this.offset.scroll.top :
  2126. ( scrollIsRootNode ? 0 : this.offset.scroll.top ) ) * mod )
  2127. ),
  2128. left: (
  2129. // The absolute mouse position
  2130. pos.left +
  2131. // Only for relative positioned nodes: Relative offset from element to offset parent
  2132. this.offset.relative.left * mod +
  2133. // The offsetParent's offset without borders (offset + border)
  2134. this.offset.parent.left * mod -
  2135. ( ( this.cssPosition === "fixed" ?
  2136. -this.offset.scroll.left :
  2137. ( scrollIsRootNode ? 0 : this.offset.scroll.left ) ) * mod )
  2138. )
  2139. };
  2140. },
  2141. _generatePosition: function( event, constrainPosition ) {
  2142. var containment, co, top, left,
  2143. o = this.options,
  2144. scrollIsRootNode = this._isRootNode( this.scrollParent[ 0 ] ),
  2145. pageX = event.pageX,
  2146. pageY = event.pageY;
  2147. // Cache the scroll
  2148. if ( !scrollIsRootNode || !this.offset.scroll ) {
  2149. this.offset.scroll = {
  2150. top: this.scrollParent.scrollTop(),
  2151. left: this.scrollParent.scrollLeft()
  2152. };
  2153. }
  2154. /*
  2155. * - Position constraining -
  2156. * Constrain the position to a mix of grid, containment.
  2157. */
  2158. // If we are not dragging yet, we won't check for options
  2159. if ( constrainPosition ) {
  2160. if ( this.containment ) {
  2161. if ( this.relativeContainer ) {
  2162. co = this.relativeContainer.offset();
  2163. containment = [
  2164. this.containment[ 0 ] + co.left,
  2165. this.containment[ 1 ] + co.top,
  2166. this.containment[ 2 ] + co.left,
  2167. this.containment[ 3 ] + co.top
  2168. ];
  2169. } else {
  2170. containment = this.containment;
  2171. }
  2172. if ( event.pageX - this.offset.click.left < containment[ 0 ] ) {
  2173. pageX = containment[ 0 ] + this.offset.click.left;
  2174. }
  2175. if ( event.pageY - this.offset.click.top < containment[ 1 ] ) {
  2176. pageY = containment[ 1 ] + this.offset.click.top;
  2177. }
  2178. if ( event.pageX - this.offset.click.left > containment[ 2 ] ) {
  2179. pageX = containment[ 2 ] + this.offset.click.left;
  2180. }
  2181. if ( event.pageY - this.offset.click.top > containment[ 3 ] ) {
  2182. pageY = containment[ 3 ] + this.offset.click.top;
  2183. }
  2184. }
  2185. if ( o.grid ) {
  2186. //Check for grid elements set to 0 to prevent divide by 0 error causing invalid
  2187. // argument errors in IE (see ticket #6950)
  2188. top = o.grid[ 1 ] ? this.originalPageY + Math.round( ( pageY -
  2189. this.originalPageY ) / o.grid[ 1 ] ) * o.grid[ 1 ] : this.originalPageY;
  2190. pageY = containment ? ( ( top - this.offset.click.top >= containment[ 1 ] ||
  2191. top - this.offset.click.top > containment[ 3 ] ) ?
  2192. top :
  2193. ( ( top - this.offset.click.top >= containment[ 1 ] ) ?
  2194. top - o.grid[ 1 ] : top + o.grid[ 1 ] ) ) : top;
  2195. left = o.grid[ 0 ] ? this.originalPageX +
  2196. Math.round( ( pageX - this.originalPageX ) / o.grid[ 0 ] ) * o.grid[ 0 ] :
  2197. this.originalPageX;
  2198. pageX = containment ? ( ( left - this.offset.click.left >= containment[ 0 ] ||
  2199. left - this.offset.click.left > containment[ 2 ] ) ?
  2200. left :
  2201. ( ( left - this.offset.click.left >= containment[ 0 ] ) ?
  2202. left - o.grid[ 0 ] : left + o.grid[ 0 ] ) ) : left;
  2203. }
  2204. if ( o.axis === "y" ) {
  2205. pageX = this.originalPageX;
  2206. }
  2207. if ( o.axis === "x" ) {
  2208. pageY = this.originalPageY;
  2209. }
  2210. }
  2211. return {
  2212. top: (
  2213. // The absolute mouse position
  2214. pageY -
  2215. // Click offset (relative to the element)
  2216. this.offset.click.top -
  2217. // Only for relative positioned nodes: Relative offset from element to offset parent
  2218. this.offset.relative.top -
  2219. // The offsetParent's offset without borders (offset + border)
  2220. this.offset.parent.top +
  2221. ( this.cssPosition === "fixed" ?
  2222. -this.offset.scroll.top :
  2223. ( scrollIsRootNode ? 0 : this.offset.scroll.top ) )
  2224. ),
  2225. left: (
  2226. // The absolute mouse position
  2227. pageX -
  2228. // Click offset (relative to the element)
  2229. this.offset.click.left -
  2230. // Only for relative positioned nodes: Relative offset from element to offset parent
  2231. this.offset.relative.left -
  2232. // The offsetParent's offset without borders (offset + border)
  2233. this.offset.parent.left +
  2234. ( this.cssPosition === "fixed" ?
  2235. -this.offset.scroll.left :
  2236. ( scrollIsRootNode ? 0 : this.offset.scroll.left ) )
  2237. )
  2238. };
  2239. },
  2240. _clear: function() {
  2241. this._removeClass( this.helper, "ui-draggable-dragging" );
  2242. if ( this.helper[ 0 ] !== this.element[ 0 ] && !this.cancelHelperRemoval ) {
  2243. this.helper.remove();
  2244. }
  2245. this.helper = null;
  2246. this.cancelHelperRemoval = false;
  2247. if ( this.destroyOnClear ) {
  2248. this.destroy();
  2249. }
  2250. },
  2251. // From now on bulk stuff - mainly helpers
  2252. _trigger: function( type, event, ui ) {
  2253. ui = ui || this._uiHash();
  2254. $.ui.plugin.call( this, type, [ event, ui, this ], true );
  2255. // Absolute position and offset (see #6884 ) have to be recalculated after plugins
  2256. if ( /^(drag|start|stop)/.test( type ) ) {
  2257. this.positionAbs = this._convertPositionTo( "absolute" );
  2258. ui.offset = this.positionAbs;
  2259. }
  2260. return $.Widget.prototype._trigger.call( this, type, event, ui );
  2261. },
  2262. plugins: {},
  2263. _uiHash: function() {
  2264. return {
  2265. helper: this.helper,
  2266. position: this.position,
  2267. originalPosition: this.originalPosition,
  2268. offset: this.positionAbs
  2269. };
  2270. }
  2271. } );
  2272. $.ui.plugin.add( "draggable", "connectToSortable", {
  2273. start: function( event, ui, draggable ) {
  2274. var uiSortable = $.extend( {}, ui, {
  2275. item: draggable.element
  2276. } );
  2277. draggable.sortables = [];
  2278. $( draggable.options.connectToSortable ).each( function() {
  2279. var sortable = $( this ).sortable( "instance" );
  2280. if ( sortable && !sortable.options.disabled ) {
  2281. draggable.sortables.push( sortable );
  2282. // RefreshPositions is called at drag start to refresh the containerCache
  2283. // which is used in drag. This ensures it's initialized and synchronized
  2284. // with any changes that might have happened on the page since initialization.
  2285. sortable.refreshPositions();
  2286. sortable._trigger( "activate", event, uiSortable );
  2287. }
  2288. } );
  2289. },
  2290. stop: function( event, ui, draggable ) {
  2291. var uiSortable = $.extend( {}, ui, {
  2292. item: draggable.element
  2293. } );
  2294. draggable.cancelHelperRemoval = false;
  2295. $.each( draggable.sortables, function() {
  2296. var sortable = this;
  2297. if ( sortable.isOver ) {
  2298. sortable.isOver = 0;
  2299. // Allow this sortable to handle removing the helper
  2300. draggable.cancelHelperRemoval = true;
  2301. sortable.cancelHelperRemoval = false;
  2302. // Use _storedCSS To restore properties in the sortable,
  2303. // as this also handles revert (#9675) since the draggable
  2304. // may have modified them in unexpected ways (#8809)
  2305. sortable._storedCSS = {
  2306. position: sortable.placeholder.css( "position" ),
  2307. top: sortable.placeholder.css( "top" ),
  2308. left: sortable.placeholder.css( "left" )
  2309. };
  2310. sortable._mouseStop( event );
  2311. // Once drag has ended, the sortable should return to using
  2312. // its original helper, not the shared helper from draggable
  2313. sortable.options.helper = sortable.options._helper;
  2314. } else {
  2315. // Prevent this Sortable from removing the helper.
  2316. // However, don't set the draggable to remove the helper
  2317. // either as another connected Sortable may yet handle the removal.
  2318. sortable.cancelHelperRemoval = true;
  2319. sortable._trigger( "deactivate", event, uiSortable );
  2320. }
  2321. } );
  2322. },
  2323. drag: function( event, ui, draggable ) {
  2324. $.each( draggable.sortables, function() {
  2325. var innermostIntersecting = false,
  2326. sortable = this;
  2327. // Copy over variables that sortable's _intersectsWith uses
  2328. sortable.positionAbs = draggable.positionAbs;
  2329. sortable.helperProportions = draggable.helperProportions;
  2330. sortable.offset.click = draggable.offset.click;
  2331. if ( sortable._intersectsWith( sortable.containerCache ) ) {
  2332. innermostIntersecting = true;
  2333. $.each( draggable.sortables, function() {
  2334. // Copy over variables that sortable's _intersectsWith uses
  2335. this.positionAbs = draggable.positionAbs;
  2336. this.helperProportions = draggable.helperProportions;
  2337. this.offset.click = draggable.offset.click;
  2338. if ( this !== sortable &&
  2339. this._intersectsWith( this.containerCache ) &&
  2340. $.contains( sortable.element[ 0 ], this.element[ 0 ] ) ) {
  2341. innermostIntersecting = false;
  2342. }
  2343. return innermostIntersecting;
  2344. } );
  2345. }
  2346. if ( innermostIntersecting ) {
  2347. // If it intersects, we use a little isOver variable and set it once,
  2348. // so that the move-in stuff gets fired only once.
  2349. if ( !sortable.isOver ) {
  2350. sortable.isOver = 1;
  2351. // Store draggable's parent in case we need to reappend to it later.
  2352. draggable._parent = ui.helper.parent();
  2353. sortable.currentItem = ui.helper
  2354. .appendTo( sortable.element )
  2355. .data( "ui-sortable-item", true );
  2356. // Store helper option to later restore it
  2357. sortable.options._helper = sortable.options.helper;
  2358. sortable.options.helper = function() {
  2359. return ui.helper[ 0 ];
  2360. };
  2361. // Fire the start events of the sortable with our passed browser event,
  2362. // and our own helper (so it doesn't create a new one)
  2363. event.target = sortable.currentItem[ 0 ];
  2364. sortable._mouseCapture( event, true );
  2365. sortable._mouseStart( event, true, true );
  2366. // Because the browser event is way off the new appended portlet,
  2367. // modify necessary variables to reflect the changes
  2368. sortable.offset.click.top = draggable.offset.click.top;
  2369. sortable.offset.click.left = draggable.offset.click.left;
  2370. sortable.offset.parent.left -= draggable.offset.parent.left -
  2371. sortable.offset.parent.left;
  2372. sortable.offset.parent.top -= draggable.offset.parent.top -
  2373. sortable.offset.parent.top;
  2374. draggable._trigger( "toSortable", event );
  2375. // Inform draggable that the helper is in a valid drop zone,
  2376. // used solely in the revert option to handle "valid/invalid".
  2377. draggable.dropped = sortable.element;
  2378. // Need to refreshPositions of all sortables in the case that
  2379. // adding to one sortable changes the location of the other sortables (#9675)
  2380. $.each( draggable.sortables, function() {
  2381. this.refreshPositions();
  2382. } );
  2383. // Hack so receive/update callbacks work (mostly)
  2384. draggable.currentItem = draggable.element;
  2385. sortable.fromOutside = draggable;
  2386. }
  2387. if ( sortable.currentItem ) {
  2388. sortable._mouseDrag( event );
  2389. // Copy the sortable's position because the draggable's can potentially reflect
  2390. // a relative position, while sortable is always absolute, which the dragged
  2391. // element has now become. (#8809)
  2392. ui.position = sortable.position;
  2393. }
  2394. } else {
  2395. // If it doesn't intersect with the sortable, and it intersected before,
  2396. // we fake the drag stop of the sortable, but make sure it doesn't remove
  2397. // the helper by using cancelHelperRemoval.
  2398. if ( sortable.isOver ) {
  2399. sortable.isOver = 0;
  2400. sortable.cancelHelperRemoval = true;
  2401. // Calling sortable's mouseStop would trigger a revert,
  2402. // so revert must be temporarily false until after mouseStop is called.
  2403. sortable.options._revert = sortable.options.revert;
  2404. sortable.options.revert = false;
  2405. sortable._trigger( "out", event, sortable._uiHash( sortable ) );
  2406. sortable._mouseStop( event, true );
  2407. // Restore sortable behaviors that were modfied
  2408. // when the draggable entered the sortable area (#9481)
  2409. sortable.options.revert = sortable.options._revert;
  2410. sortable.options.helper = sortable.options._helper;
  2411. if ( sortable.placeholder ) {
  2412. sortable.placeholder.remove();
  2413. }
  2414. // Restore and recalculate the draggable's offset considering the sortable
  2415. // may have modified them in unexpected ways. (#8809, #10669)
  2416. ui.helper.appendTo( draggable._parent );
  2417. draggable._refreshOffsets( event );
  2418. ui.position = draggable._generatePosition( event, true );
  2419. draggable._trigger( "fromSortable", event );
  2420. // Inform draggable that the helper is no longer in a valid drop zone
  2421. draggable.dropped = false;
  2422. // Need to refreshPositions of all sortables just in case removing
  2423. // from one sortable changes the location of other sortables (#9675)
  2424. $.each( draggable.sortables, function() {
  2425. this.refreshPositions();
  2426. } );
  2427. }
  2428. }
  2429. } );
  2430. }
  2431. } );
  2432. $.ui.plugin.add( "draggable", "cursor", {
  2433. start: function( event, ui, instance ) {
  2434. var t = $( "body" ),
  2435. o = instance.options;
  2436. if ( t.css( "cursor" ) ) {
  2437. o._cursor = t.css( "cursor" );
  2438. }
  2439. t.css( "cursor", o.cursor );
  2440. },
  2441. stop: function( event, ui, instance ) {
  2442. var o = instance.options;
  2443. if ( o._cursor ) {
  2444. $( "body" ).css( "cursor", o._cursor );
  2445. }
  2446. }
  2447. } );
  2448. $.ui.plugin.add( "draggable", "opacity", {
  2449. start: function( event, ui, instance ) {
  2450. var t = $( ui.helper ),
  2451. o = instance.options;
  2452. if ( t.css( "opacity" ) ) {
  2453. o._opacity = t.css( "opacity" );
  2454. }
  2455. t.css( "opacity", o.opacity );
  2456. },
  2457. stop: function( event, ui, instance ) {
  2458. var o = instance.options;
  2459. if ( o._opacity ) {
  2460. $( ui.helper ).css( "opacity", o._opacity );
  2461. }
  2462. }
  2463. } );
  2464. $.ui.plugin.add( "draggable", "scroll", {
  2465. start: function( event, ui, i ) {
  2466. if ( !i.scrollParentNotHidden ) {
  2467. i.scrollParentNotHidden = i.helper.scrollParent( false );
  2468. }
  2469. if ( i.scrollParentNotHidden[ 0 ] !== i.document[ 0 ] &&
  2470. i.scrollParentNotHidden[ 0 ].tagName !== "HTML" ) {
  2471. i.overflowOffset = i.scrollParentNotHidden.offset();
  2472. }
  2473. },
  2474. drag: function( event, ui, i ) {
  2475. var o = i.options,
  2476. scrolled = false,
  2477. scrollParent = i.scrollParentNotHidden[ 0 ],
  2478. document = i.document[ 0 ];
  2479. if ( scrollParent !== document && scrollParent.tagName !== "HTML" ) {
  2480. if ( !o.axis || o.axis !== "x" ) {
  2481. if ( ( i.overflowOffset.top + scrollParent.offsetHeight ) - event.pageY <
  2482. o.scrollSensitivity ) {
  2483. scrollParent.scrollTop = scrolled = scrollParent.scrollTop + o.scrollSpeed;
  2484. } else if ( event.pageY - i.overflowOffset.top < o.scrollSensitivity ) {
  2485. scrollParent.scrollTop = scrolled = scrollParent.scrollTop - o.scrollSpeed;
  2486. }
  2487. }
  2488. if ( !o.axis || o.axis !== "y" ) {
  2489. if ( ( i.overflowOffset.left + scrollParent.offsetWidth ) - event.pageX <
  2490. o.scrollSensitivity ) {
  2491. scrollParent.scrollLeft = scrolled = scrollParent.scrollLeft + o.scrollSpeed;
  2492. } else if ( event.pageX - i.overflowOffset.left < o.scrollSensitivity ) {
  2493. scrollParent.scrollLeft = scrolled = scrollParent.scrollLeft - o.scrollSpeed;
  2494. }
  2495. }
  2496. } else {
  2497. if ( !o.axis || o.axis !== "x" ) {
  2498. if ( event.pageY - $( document ).scrollTop() < o.scrollSensitivity ) {
  2499. scrolled = $( document ).scrollTop( $( document ).scrollTop() - o.scrollSpeed );
  2500. } else if ( $( window ).height() - ( event.pageY - $( document ).scrollTop() ) <
  2501. o.scrollSensitivity ) {
  2502. scrolled = $( document ).scrollTop( $( document ).scrollTop() + o.scrollSpeed );
  2503. }
  2504. }
  2505. if ( !o.axis || o.axis !== "y" ) {
  2506. if ( event.pageX - $( document ).scrollLeft() < o.scrollSensitivity ) {
  2507. scrolled = $( document ).scrollLeft(
  2508. $( document ).scrollLeft() - o.scrollSpeed
  2509. );
  2510. } else if ( $( window ).width() - ( event.pageX - $( document ).scrollLeft() ) <
  2511. o.scrollSensitivity ) {
  2512. scrolled = $( document ).scrollLeft(
  2513. $( document ).scrollLeft() + o.scrollSpeed
  2514. );
  2515. }
  2516. }
  2517. }
  2518. if ( scrolled !== false && $.ui.ddmanager && !o.dropBehaviour ) {
  2519. $.ui.ddmanager.prepareOffsets( i, event );
  2520. }
  2521. }
  2522. } );
  2523. $.ui.plugin.add( "draggable", "snap", {
  2524. start: function( event, ui, i ) {
  2525. var o = i.options;
  2526. i.snapElements = [];
  2527. $( o.snap.constructor !== String ? ( o.snap.items || ":data(ui-draggable)" ) : o.snap )
  2528. .each( function() {
  2529. var $t = $( this ),
  2530. $o = $t.offset();
  2531. if ( this !== i.element[ 0 ] ) {
  2532. i.snapElements.push( {
  2533. item: this,
  2534. width: $t.outerWidth(), height: $t.outerHeight(),
  2535. top: $o.top, left: $o.left
  2536. } );
  2537. }
  2538. } );
  2539. },
  2540. drag: function( event, ui, inst ) {
  2541. var ts, bs, ls, rs, l, r, t, b, i, first,
  2542. o = inst.options,
  2543. d = o.snapTolerance,
  2544. x1 = ui.offset.left, x2 = x1 + inst.helperProportions.width,
  2545. y1 = ui.offset.top, y2 = y1 + inst.helperProportions.height;
  2546. for ( i = inst.snapElements.length - 1; i >= 0; i-- ) {
  2547. l = inst.snapElements[ i ].left - inst.margins.left;
  2548. r = l + inst.snapElements[ i ].width;
  2549. t = inst.snapElements[ i ].top - inst.margins.top;
  2550. b = t + inst.snapElements[ i ].height;
  2551. if ( x2 < l - d || x1 > r + d || y2 < t - d || y1 > b + d ||
  2552. !$.contains( inst.snapElements[ i ].item.ownerDocument,
  2553. inst.snapElements[ i ].item ) ) {
  2554. if ( inst.snapElements[ i ].snapping ) {
  2555. ( inst.options.snap.release &&
  2556. inst.options.snap.release.call(
  2557. inst.element,
  2558. event,
  2559. $.extend( inst._uiHash(), { snapItem: inst.snapElements[ i ].item } )
  2560. ) );
  2561. }
  2562. inst.snapElements[ i ].snapping = false;
  2563. continue;
  2564. }
  2565. if ( o.snapMode !== "inner" ) {
  2566. ts = Math.abs( t - y2 ) <= d;
  2567. bs = Math.abs( b - y1 ) <= d;
  2568. ls = Math.abs( l - x2 ) <= d;
  2569. rs = Math.abs( r - x1 ) <= d;
  2570. if ( ts ) {
  2571. ui.position.top = inst._convertPositionTo( "relative", {
  2572. top: t - inst.helperProportions.height,
  2573. left: 0
  2574. } ).top;
  2575. }
  2576. if ( bs ) {
  2577. ui.position.top = inst._convertPositionTo( "relative", {
  2578. top: b,
  2579. left: 0
  2580. } ).top;
  2581. }
  2582. if ( ls ) {
  2583. ui.position.left = inst._convertPositionTo( "relative", {
  2584. top: 0,
  2585. left: l - inst.helperProportions.width
  2586. } ).left;
  2587. }
  2588. if ( rs ) {
  2589. ui.position.left = inst._convertPositionTo( "relative", {
  2590. top: 0,
  2591. left: r
  2592. } ).left;
  2593. }
  2594. }
  2595. first = ( ts || bs || ls || rs );
  2596. if ( o.snapMode !== "outer" ) {
  2597. ts = Math.abs( t - y1 ) <= d;
  2598. bs = Math.abs( b - y2 ) <= d;
  2599. ls = Math.abs( l - x1 ) <= d;
  2600. rs = Math.abs( r - x2 ) <= d;
  2601. if ( ts ) {
  2602. ui.position.top = inst._convertPositionTo( "relative", {
  2603. top: t,
  2604. left: 0
  2605. } ).top;
  2606. }
  2607. if ( bs ) {
  2608. ui.position.top = inst._convertPositionTo( "relative", {
  2609. top: b - inst.helperProportions.height,
  2610. left: 0
  2611. } ).top;
  2612. }
  2613. if ( ls ) {
  2614. ui.position.left = inst._convertPositionTo( "relative", {
  2615. top: 0,
  2616. left: l
  2617. } ).left;
  2618. }
  2619. if ( rs ) {
  2620. ui.position.left = inst._convertPositionTo( "relative", {
  2621. top: 0,
  2622. left: r - inst.helperProportions.width
  2623. } ).left;
  2624. }
  2625. }
  2626. if ( !inst.snapElements[ i ].snapping && ( ts || bs || ls || rs || first ) ) {
  2627. ( inst.options.snap.snap &&
  2628. inst.options.snap.snap.call(
  2629. inst.element,
  2630. event,
  2631. $.extend( inst._uiHash(), {
  2632. snapItem: inst.snapElements[ i ].item
  2633. } ) ) );
  2634. }
  2635. inst.snapElements[ i ].snapping = ( ts || bs || ls || rs || first );
  2636. }
  2637. }
  2638. } );
  2639. $.ui.plugin.add( "draggable", "stack", {
  2640. start: function( event, ui, instance ) {
  2641. var min,
  2642. o = instance.options,
  2643. group = $.makeArray( $( o.stack ) ).sort( function( a, b ) {
  2644. return ( parseInt( $( a ).css( "zIndex" ), 10 ) || 0 ) -
  2645. ( parseInt( $( b ).css( "zIndex" ), 10 ) || 0 );
  2646. } );
  2647. if ( !group.length ) { return; }
  2648. min = parseInt( $( group[ 0 ] ).css( "zIndex" ), 10 ) || 0;
  2649. $( group ).each( function( i ) {
  2650. $( this ).css( "zIndex", min + i );
  2651. } );
  2652. this.css( "zIndex", ( min + group.length ) );
  2653. }
  2654. } );
  2655. $.ui.plugin.add( "draggable", "zIndex", {
  2656. start: function( event, ui, instance ) {
  2657. var t = $( ui.helper ),
  2658. o = instance.options;
  2659. if ( t.css( "zIndex" ) ) {
  2660. o._zIndex = t.css( "zIndex" );
  2661. }
  2662. t.css( "zIndex", o.zIndex );
  2663. },
  2664. stop: function( event, ui, instance ) {
  2665. var o = instance.options;
  2666. if ( o._zIndex ) {
  2667. $( ui.helper ).css( "zIndex", o._zIndex );
  2668. }
  2669. }
  2670. } );
  2671. var widgetsDraggable = $.ui.draggable;
  2672. /*!
  2673. * jQuery UI Droppable 1.12.0
  2674. * http://jqueryui.com
  2675. *
  2676. * Copyright jQuery Foundation and other contributors
  2677. * Released under the MIT license.
  2678. * http://jquery.org/license
  2679. */
  2680. //>>label: Droppable
  2681. //>>group: Interactions
  2682. //>>description: Enables drop targets for draggable elements.
  2683. //>>docs: http://api.jqueryui.com/droppable/
  2684. //>>demos: http://jqueryui.com/droppable/
  2685. $.widget( "ui.droppable", {
  2686. version: "1.12.0",
  2687. widgetEventPrefix: "drop",
  2688. options: {
  2689. accept: "*",
  2690. addClasses: true,
  2691. greedy: false,
  2692. scope: "default",
  2693. tolerance: "intersect",
  2694. // Callbacks
  2695. activate: null,
  2696. deactivate: null,
  2697. drop: null,
  2698. out: null,
  2699. over: null
  2700. },
  2701. _create: function() {
  2702. var proportions,
  2703. o = this.options,
  2704. accept = o.accept;
  2705. this.isover = false;
  2706. this.isout = true;
  2707. this.accept = $.isFunction( accept ) ? accept : function( d ) {
  2708. return d.is( accept );
  2709. };
  2710. this.proportions = function( /* valueToWrite */ ) {
  2711. if ( arguments.length ) {
  2712. // Store the droppable's proportions
  2713. proportions = arguments[ 0 ];
  2714. } else {
  2715. // Retrieve or derive the droppable's proportions
  2716. return proportions ?
  2717. proportions :
  2718. proportions = {
  2719. width: this.element[ 0 ].offsetWidth,
  2720. height: this.element[ 0 ].offsetHeight
  2721. };
  2722. }
  2723. };
  2724. this._addToManager( o.scope );
  2725. o.addClasses && this._addClass( "ui-droppable" );
  2726. },
  2727. _addToManager: function( scope ) {
  2728. // Add the reference and positions to the manager
  2729. $.ui.ddmanager.droppables[ scope ] = $.ui.ddmanager.droppables[ scope ] || [];
  2730. $.ui.ddmanager.droppables[ scope ].push( this );
  2731. },
  2732. _splice: function( drop ) {
  2733. var i = 0;
  2734. for ( ; i < drop.length; i++ ) {
  2735. if ( drop[ i ] === this ) {
  2736. drop.splice( i, 1 );
  2737. }
  2738. }
  2739. },
  2740. _destroy: function() {
  2741. var drop = $.ui.ddmanager.droppables[ this.options.scope ];
  2742. this._splice( drop );
  2743. },
  2744. _setOption: function( key, value ) {
  2745. if ( key === "accept" ) {
  2746. this.accept = $.isFunction( value ) ? value : function( d ) {
  2747. return d.is( value );
  2748. };
  2749. } else if ( key === "scope" ) {
  2750. var drop = $.ui.ddmanager.droppables[ this.options.scope ];
  2751. this._splice( drop );
  2752. this._addToManager( value );
  2753. }
  2754. this._super( key, value );
  2755. },
  2756. _activate: function( event ) {
  2757. var draggable = $.ui.ddmanager.current;
  2758. this._addActiveClass();
  2759. if ( draggable ) {
  2760. this._trigger( "activate", event, this.ui( draggable ) );
  2761. }
  2762. },
  2763. _deactivate: function( event ) {
  2764. var draggable = $.ui.ddmanager.current;
  2765. this._removeActiveClass();
  2766. if ( draggable ) {
  2767. this._trigger( "deactivate", event, this.ui( draggable ) );
  2768. }
  2769. },
  2770. _over: function( event ) {
  2771. var draggable = $.ui.ddmanager.current;
  2772. // Bail if draggable and droppable are same element
  2773. if ( !draggable || ( draggable.currentItem ||
  2774. draggable.element )[ 0 ] === this.element[ 0 ] ) {
  2775. return;
  2776. }
  2777. if ( this.accept.call( this.element[ 0 ], ( draggable.currentItem ||
  2778. draggable.element ) ) ) {
  2779. this._addHoverClass();
  2780. this._trigger( "over", event, this.ui( draggable ) );
  2781. }
  2782. },
  2783. _out: function( event ) {
  2784. var draggable = $.ui.ddmanager.current;
  2785. // Bail if draggable and droppable are same element
  2786. if ( !draggable || ( draggable.currentItem ||
  2787. draggable.element )[ 0 ] === this.element[ 0 ] ) {
  2788. return;
  2789. }
  2790. if ( this.accept.call( this.element[ 0 ], ( draggable.currentItem ||
  2791. draggable.element ) ) ) {
  2792. this._removeHoverClass();
  2793. this._trigger( "out", event, this.ui( draggable ) );
  2794. }
  2795. },
  2796. _drop: function( event, custom ) {
  2797. var draggable = custom || $.ui.ddmanager.current,
  2798. childrenIntersection = false;
  2799. // Bail if draggable and droppable are same element
  2800. if ( !draggable || ( draggable.currentItem ||
  2801. draggable.element )[ 0 ] === this.element[ 0 ] ) {
  2802. return false;
  2803. }
  2804. this.element
  2805. .find( ":data(ui-droppable)" )
  2806. .not( ".ui-draggable-dragging" )
  2807. .each( function() {
  2808. var inst = $( this ).droppable( "instance" );
  2809. if (
  2810. inst.options.greedy &&
  2811. !inst.options.disabled &&
  2812. inst.options.scope === draggable.options.scope &&
  2813. inst.accept.call(
  2814. inst.element[ 0 ], ( draggable.currentItem || draggable.element )
  2815. ) &&
  2816. intersect(
  2817. draggable,
  2818. $.extend( inst, { offset: inst.element.offset() } ),
  2819. inst.options.tolerance, event
  2820. )
  2821. ) {
  2822. childrenIntersection = true;
  2823. return false; }
  2824. } );
  2825. if ( childrenIntersection ) {
  2826. return false;
  2827. }
  2828. if ( this.accept.call( this.element[ 0 ],
  2829. ( draggable.currentItem || draggable.element ) ) ) {
  2830. this._removeActiveClass();
  2831. this._removeHoverClass();
  2832. this._trigger( "drop", event, this.ui( draggable ) );
  2833. return this.element;
  2834. }
  2835. return false;
  2836. },
  2837. ui: function( c ) {
  2838. return {
  2839. draggable: ( c.currentItem || c.element ),
  2840. helper: c.helper,
  2841. position: c.position,
  2842. offset: c.positionAbs
  2843. };
  2844. },
  2845. // Extension points just to make backcompat sane and avoid duplicating logic
  2846. // TODO: Remove in 1.13 along with call to it below
  2847. _addHoverClass: function() {
  2848. this._addClass( "ui-droppable-hover" );
  2849. },
  2850. _removeHoverClass: function() {
  2851. this._removeClass( "ui-droppable-hover" );
  2852. },
  2853. _addActiveClass: function() {
  2854. this._addClass( "ui-droppable-active" );
  2855. },
  2856. _removeActiveClass: function() {
  2857. this._removeClass( "ui-droppable-active" );
  2858. }
  2859. } );
  2860. var intersect = $.ui.intersect = ( function() {
  2861. function isOverAxis( x, reference, size ) {
  2862. return ( x >= reference ) && ( x < ( reference + size ) );
  2863. }
  2864. return function( draggable, droppable, toleranceMode, event ) {
  2865. if ( !droppable.offset ) {
  2866. return false;
  2867. }
  2868. var x1 = ( draggable.positionAbs ||
  2869. draggable.position.absolute ).left + draggable.margins.left,
  2870. y1 = ( draggable.positionAbs ||
  2871. draggable.position.absolute ).top + draggable.margins.top,
  2872. x2 = x1 + draggable.helperProportions.width,
  2873. y2 = y1 + draggable.helperProportions.height,
  2874. l = droppable.offset.left,
  2875. t = droppable.offset.top,
  2876. r = l + droppable.proportions().width,
  2877. b = t + droppable.proportions().height;
  2878. switch ( toleranceMode ) {
  2879. case "fit":
  2880. return ( l <= x1 && x2 <= r && t <= y1 && y2 <= b );
  2881. case "intersect":
  2882. return ( l < x1 + ( draggable.helperProportions.width / 2 ) && // Right Half
  2883. x2 - ( draggable.helperProportions.width / 2 ) < r && // Left Half
  2884. t < y1 + ( draggable.helperProportions.height / 2 ) && // Bottom Half
  2885. y2 - ( draggable.helperProportions.height / 2 ) < b ); // Top Half
  2886. case "pointer":
  2887. return isOverAxis( event.pageY, t, droppable.proportions().height ) &&
  2888. isOverAxis( event.pageX, l, droppable.proportions().width );
  2889. case "touch":
  2890. return (
  2891. ( y1 >= t && y1 <= b ) || // Top edge touching
  2892. ( y2 >= t && y2 <= b ) || // Bottom edge touching
  2893. ( y1 < t && y2 > b ) // Surrounded vertically
  2894. ) && (
  2895. ( x1 >= l && x1 <= r ) || // Left edge touching
  2896. ( x2 >= l && x2 <= r ) || // Right edge touching
  2897. ( x1 < l && x2 > r ) // Surrounded horizontally
  2898. );
  2899. default:
  2900. return false;
  2901. }
  2902. };
  2903. } )();
  2904. /*
  2905. This manager tracks offsets of draggables and droppables
  2906. */
  2907. $.ui.ddmanager = {
  2908. current: null,
  2909. droppables: { "default": [] },
  2910. prepareOffsets: function( t, event ) {
  2911. var i, j,
  2912. m = $.ui.ddmanager.droppables[ t.options.scope ] || [],
  2913. type = event ? event.type : null, // workaround for #2317
  2914. list = ( t.currentItem || t.element ).find( ":data(ui-droppable)" ).addBack();
  2915. droppablesLoop: for ( i = 0; i < m.length; i++ ) {
  2916. // No disabled and non-accepted
  2917. if ( m[ i ].options.disabled || ( t && !m[ i ].accept.call( m[ i ].element[ 0 ],
  2918. ( t.currentItem || t.element ) ) ) ) {
  2919. continue;
  2920. }
  2921. // Filter out elements in the current dragged item
  2922. for ( j = 0; j < list.length; j++ ) {
  2923. if ( list[ j ] === m[ i ].element[ 0 ] ) {
  2924. m[ i ].proportions().height = 0;
  2925. continue droppablesLoop;
  2926. }
  2927. }
  2928. m[ i ].visible = m[ i ].element.css( "display" ) !== "none";
  2929. if ( !m[ i ].visible ) {
  2930. continue;
  2931. }
  2932. // Activate the droppable if used directly from draggables
  2933. if ( type === "mousedown" ) {
  2934. m[ i ]._activate.call( m[ i ], event );
  2935. }
  2936. m[ i ].offset = m[ i ].element.offset();
  2937. m[ i ].proportions( {
  2938. width: m[ i ].element[ 0 ].offsetWidth,
  2939. height: m[ i ].element[ 0 ].offsetHeight
  2940. } );
  2941. }
  2942. },
  2943. drop: function( draggable, event ) {
  2944. var dropped = false;
  2945. // Create a copy of the droppables in case the list changes during the drop (#9116)
  2946. $.each( ( $.ui.ddmanager.droppables[ draggable.options.scope ] || [] ).slice(), function() {
  2947. if ( !this.options ) {
  2948. return;
  2949. }
  2950. if ( !this.options.disabled && this.visible &&
  2951. intersect( draggable, this, this.options.tolerance, event ) ) {
  2952. dropped = this._drop.call( this, event ) || dropped;
  2953. }
  2954. if ( !this.options.disabled && this.visible && this.accept.call( this.element[ 0 ],
  2955. ( draggable.currentItem || draggable.element ) ) ) {
  2956. this.isout = true;
  2957. this.isover = false;
  2958. this._deactivate.call( this, event );
  2959. }
  2960. } );
  2961. return dropped;
  2962. },
  2963. dragStart: function( draggable, event ) {
  2964. // Listen for scrolling so that if the dragging causes scrolling the position of the
  2965. // droppables can be recalculated (see #5003)
  2966. draggable.element.parentsUntil( "body" ).on( "scroll.droppable", function() {
  2967. if ( !draggable.options.refreshPositions ) {
  2968. $.ui.ddmanager.prepareOffsets( draggable, event );
  2969. }
  2970. } );
  2971. },
  2972. drag: function( draggable, event ) {
  2973. // If you have a highly dynamic page, you might try this option. It renders positions
  2974. // every time you move the mouse.
  2975. if ( draggable.options.refreshPositions ) {
  2976. $.ui.ddmanager.prepareOffsets( draggable, event );
  2977. }
  2978. // Run through all droppables and check their positions based on specific tolerance options
  2979. $.each( $.ui.ddmanager.droppables[ draggable.options.scope ] || [], function() {
  2980. if ( this.options.disabled || this.greedyChild || !this.visible ) {
  2981. return;
  2982. }
  2983. var parentInstance, scope, parent,
  2984. intersects = intersect( draggable, this, this.options.tolerance, event ),
  2985. c = !intersects && this.isover ?
  2986. "isout" :
  2987. ( intersects && !this.isover ? "isover" : null );
  2988. if ( !c ) {
  2989. return;
  2990. }
  2991. if ( this.options.greedy ) {
  2992. // find droppable parents with same scope
  2993. scope = this.options.scope;
  2994. parent = this.element.parents( ":data(ui-droppable)" ).filter( function() {
  2995. return $( this ).droppable( "instance" ).options.scope === scope;
  2996. } );
  2997. if ( parent.length ) {
  2998. parentInstance = $( parent[ 0 ] ).droppable( "instance" );
  2999. parentInstance.greedyChild = ( c === "isover" );
  3000. }
  3001. }
  3002. // We just moved into a greedy child
  3003. if ( parentInstance && c === "isover" ) {
  3004. parentInstance.isover = false;
  3005. parentInstance.isout = true;
  3006. parentInstance._out.call( parentInstance, event );
  3007. }
  3008. this[ c ] = true;
  3009. this[ c === "isout" ? "isover" : "isout" ] = false;
  3010. this[ c === "isover" ? "_over" : "_out" ].call( this, event );
  3011. // We just moved out of a greedy child
  3012. if ( parentInstance && c === "isout" ) {
  3013. parentInstance.isout = false;
  3014. parentInstance.isover = true;
  3015. parentInstance._over.call( parentInstance, event );
  3016. }
  3017. } );
  3018. },
  3019. dragStop: function( draggable, event ) {
  3020. draggable.element.parentsUntil( "body" ).off( "scroll.droppable" );
  3021. // Call prepareOffsets one final time since IE does not fire return scroll events when
  3022. // overflow was caused by drag (see #5003)
  3023. if ( !draggable.options.refreshPositions ) {
  3024. $.ui.ddmanager.prepareOffsets( draggable, event );
  3025. }
  3026. }
  3027. };
  3028. // DEPRECATED
  3029. // TODO: switch return back to widget declaration at top of file when this is removed
  3030. if ( $.uiBackCompat !== false ) {
  3031. // Backcompat for activeClass and hoverClass options
  3032. $.widget( "ui.droppable", $.ui.droppable, {
  3033. options: {
  3034. hoverClass: false,
  3035. activeClass: false
  3036. },
  3037. _addActiveClass: function() {
  3038. this._super();
  3039. if ( this.options.activeClass ) {
  3040. this.element.addClass( this.options.activeClass );
  3041. }
  3042. },
  3043. _removeActiveClass: function() {
  3044. this._super();
  3045. if ( this.options.activeClass ) {
  3046. this.element.removeClass( this.options.activeClass );
  3047. }
  3048. },
  3049. _addHoverClass: function() {
  3050. this._super();
  3051. if ( this.options.hoverClass ) {
  3052. this.element.addClass( this.options.hoverClass );
  3053. }
  3054. },
  3055. _removeHoverClass: function() {
  3056. this._super();
  3057. if ( this.options.hoverClass ) {
  3058. this.element.removeClass( this.options.hoverClass );
  3059. }
  3060. }
  3061. } );
  3062. }
  3063. var widgetsDroppable = $.ui.droppable;
  3064. /*!
  3065. * jQuery UI Resizable 1.12.0
  3066. * http://jqueryui.com
  3067. *
  3068. * Copyright jQuery Foundation and other contributors
  3069. * Released under the MIT license.
  3070. * http://jquery.org/license
  3071. */
  3072. //>>label: Resizable
  3073. //>>group: Interactions
  3074. //>>description: Enables resize functionality for any element.
  3075. //>>docs: http://api.jqueryui.com/resizable/
  3076. //>>demos: http://jqueryui.com/resizable/
  3077. //>>css.structure: ../../themes/base/core.css
  3078. //>>css.structure: ../../themes/base/resizable.css
  3079. //>>css.theme: ../../themes/base/theme.css
  3080. $.widget( "ui.resizable", $.ui.mouse, {
  3081. version: "1.12.0",
  3082. widgetEventPrefix: "resize",
  3083. options: {
  3084. alsoResize: false,
  3085. animate: false,
  3086. animateDuration: "slow",
  3087. animateEasing: "swing",
  3088. aspectRatio: false,
  3089. autoHide: false,
  3090. classes: {
  3091. "ui-resizable-se": "ui-icon ui-icon-gripsmall-diagonal-se"
  3092. },
  3093. containment: false,
  3094. ghost: false,
  3095. grid: false,
  3096. handles: "e,s,se",
  3097. helper: false,
  3098. maxHeight: null,
  3099. maxWidth: null,
  3100. minHeight: 10,
  3101. minWidth: 10,
  3102. // See #7960
  3103. zIndex: 90,
  3104. // Callbacks
  3105. resize: null,
  3106. start: null,
  3107. stop: null
  3108. },
  3109. _num: function( value ) {
  3110. return parseFloat( value ) || 0;
  3111. },
  3112. _isNumber: function( value ) {
  3113. return !isNaN( parseFloat( value ) );
  3114. },
  3115. _hasScroll: function( el, a ) {
  3116. if ( $( el ).css( "overflow" ) === "hidden" ) {
  3117. return false;
  3118. }
  3119. var scroll = ( a && a === "left" ) ? "scrollLeft" : "scrollTop",
  3120. has = false;
  3121. if ( el[ scroll ] > 0 ) {
  3122. return true;
  3123. }
  3124. // TODO: determine which cases actually cause this to happen
  3125. // if the element doesn't have the scroll set, see if it's possible to
  3126. // set the scroll
  3127. el[ scroll ] = 1;
  3128. has = ( el[ scroll ] > 0 );
  3129. el[ scroll ] = 0;
  3130. return has;
  3131. },
  3132. _create: function() {
  3133. var margins,
  3134. o = this.options,
  3135. that = this;
  3136. this._addClass( "ui-resizable" );
  3137. $.extend( this, {
  3138. _aspectRatio: !!( o.aspectRatio ),
  3139. aspectRatio: o.aspectRatio,
  3140. originalElement: this.element,
  3141. _proportionallyResizeElements: [],
  3142. _helper: o.helper || o.ghost || o.animate ? o.helper || "ui-resizable-helper" : null
  3143. } );
  3144. // Wrap the element if it cannot hold child nodes
  3145. if ( this.element[ 0 ].nodeName.match( /^(canvas|textarea|input|select|button|img)$/i ) ) {
  3146. this.element.wrap(
  3147. $( "<div class='ui-wrapper' style='overflow: hidden;'></div>" ).css( {
  3148. position: this.element.css( "position" ),
  3149. width: this.element.outerWidth(),
  3150. height: this.element.outerHeight(),
  3151. top: this.element.css( "top" ),
  3152. left: this.element.css( "left" )
  3153. } )
  3154. );
  3155. this.element = this.element.parent().data(
  3156. "ui-resizable", this.element.resizable( "instance" )
  3157. );
  3158. this.elementIsWrapper = true;
  3159. margins = {
  3160. marginTop: this.originalElement.css( "marginTop" ),
  3161. marginRight: this.originalElement.css( "marginRight" ),
  3162. marginBottom: this.originalElement.css( "marginBottom" ),
  3163. marginLeft: this.originalElement.css( "marginLeft" )
  3164. };
  3165. this.element.css( margins );
  3166. this.originalElement.css( "margin", 0 );
  3167. // support: Safari
  3168. // Prevent Safari textarea resize
  3169. this.originalResizeStyle = this.originalElement.css( "resize" );
  3170. this.originalElement.css( "resize", "none" );
  3171. this._proportionallyResizeElements.push( this.originalElement.css( {
  3172. position: "static",
  3173. zoom: 1,
  3174. display: "block"
  3175. } ) );
  3176. // Support: IE9
  3177. // avoid IE jump (hard set the margin)
  3178. this.originalElement.css( margins );
  3179. this._proportionallyResize();
  3180. }
  3181. this._setupHandles();
  3182. if ( o.autoHide ) {
  3183. $( this.element )
  3184. .on( "mouseenter", function() {
  3185. if ( o.disabled ) {
  3186. return;
  3187. }
  3188. that._removeClass( "ui-resizable-autohide" );
  3189. that._handles.show();
  3190. } )
  3191. .on( "mouseleave", function() {
  3192. if ( o.disabled ) {
  3193. return;
  3194. }
  3195. if ( !that.resizing ) {
  3196. that._addClass( "ui-resizable-autohide" );
  3197. that._handles.hide();
  3198. }
  3199. } );
  3200. }
  3201. this._mouseInit();
  3202. },
  3203. _destroy: function() {
  3204. this._mouseDestroy();
  3205. var wrapper,
  3206. _destroy = function( exp ) {
  3207. $( exp )
  3208. .removeData( "resizable" )
  3209. .removeData( "ui-resizable" )
  3210. .off( ".resizable" )
  3211. .find( ".ui-resizable-handle" )
  3212. .remove();
  3213. };
  3214. // TODO: Unwrap at same DOM position
  3215. if ( this.elementIsWrapper ) {
  3216. _destroy( this.element );
  3217. wrapper = this.element;
  3218. this.originalElement.css( {
  3219. position: wrapper.css( "position" ),
  3220. width: wrapper.outerWidth(),
  3221. height: wrapper.outerHeight(),
  3222. top: wrapper.css( "top" ),
  3223. left: wrapper.css( "left" )
  3224. } ).insertAfter( wrapper );
  3225. wrapper.remove();
  3226. }
  3227. this.originalElement.css( "resize", this.originalResizeStyle );
  3228. _destroy( this.originalElement );
  3229. return this;
  3230. },
  3231. _setOption: function( key, value ) {
  3232. this._super( key, value );
  3233. switch ( key ) {
  3234. case "handles":
  3235. this._removeHandles();
  3236. this._setupHandles();
  3237. break;
  3238. default:
  3239. break;
  3240. }
  3241. },
  3242. _setupHandles: function() {
  3243. var o = this.options, handle, i, n, hname, axis, that = this;
  3244. this.handles = o.handles ||
  3245. ( !$( ".ui-resizable-handle", this.element ).length ?
  3246. "e,s,se" : {
  3247. n: ".ui-resizable-n",
  3248. e: ".ui-resizable-e",
  3249. s: ".ui-resizable-s",
  3250. w: ".ui-resizable-w",
  3251. se: ".ui-resizable-se",
  3252. sw: ".ui-resizable-sw",
  3253. ne: ".ui-resizable-ne",
  3254. nw: ".ui-resizable-nw"
  3255. } );
  3256. this._handles = $();
  3257. if ( this.handles.constructor === String ) {
  3258. if ( this.handles === "all" ) {
  3259. this.handles = "n,e,s,w,se,sw,ne,nw";
  3260. }
  3261. n = this.handles.split( "," );
  3262. this.handles = {};
  3263. for ( i = 0; i < n.length; i++ ) {
  3264. handle = $.trim( n[ i ] );
  3265. hname = "ui-resizable-" + handle;
  3266. axis = $( "<div>" );
  3267. this._addClass( axis, "ui-resizable-handle " + hname );
  3268. axis.css( { zIndex: o.zIndex } );
  3269. this.handles[ handle ] = ".ui-resizable-" + handle;
  3270. this.element.append( axis );
  3271. }
  3272. }
  3273. this._renderAxis = function( target ) {
  3274. var i, axis, padPos, padWrapper;
  3275. target = target || this.element;
  3276. for ( i in this.handles ) {
  3277. if ( this.handles[ i ].constructor === String ) {
  3278. this.handles[ i ] = this.element.children( this.handles[ i ] ).first().show();
  3279. } else if ( this.handles[ i ].jquery || this.handles[ i ].nodeType ) {
  3280. this.handles[ i ] = $( this.handles[ i ] );
  3281. this._on( this.handles[ i ], { "mousedown": that._mouseDown } );
  3282. }
  3283. if ( this.elementIsWrapper &&
  3284. this.originalElement[ 0 ]
  3285. .nodeName
  3286. .match( /^(textarea|input|select|button)$/i ) ) {
  3287. axis = $( this.handles[ i ], this.element );
  3288. padWrapper = /sw|ne|nw|se|n|s/.test( i ) ?
  3289. axis.outerHeight() :
  3290. axis.outerWidth();
  3291. padPos = [ "padding",
  3292. /ne|nw|n/.test( i ) ? "Top" :
  3293. /se|sw|s/.test( i ) ? "Bottom" :
  3294. /^e$/.test( i ) ? "Right" : "Left" ].join( "" );
  3295. target.css( padPos, padWrapper );
  3296. this._proportionallyResize();
  3297. }
  3298. this._handles = this._handles.add( this.handles[ i ] );
  3299. }
  3300. };
  3301. // TODO: make renderAxis a prototype function
  3302. this._renderAxis( this.element );
  3303. this._handles = this._handles.add( this.element.find( ".ui-resizable-handle" ) );
  3304. this._handles.disableSelection();
  3305. this._handles.on( "mouseover", function() {
  3306. if ( !that.resizing ) {
  3307. if ( this.className ) {
  3308. axis = this.className.match( /ui-resizable-(se|sw|ne|nw|n|e|s|w)/i );
  3309. }
  3310. that.axis = axis && axis[ 1 ] ? axis[ 1 ] : "se";
  3311. }
  3312. } );
  3313. if ( o.autoHide ) {
  3314. this._handles.hide();
  3315. this._addClass( "ui-resizable-autohide" );
  3316. }
  3317. },
  3318. _removeHandles: function() {
  3319. this._handles.remove();
  3320. },
  3321. _mouseCapture: function( event ) {
  3322. var i, handle,
  3323. capture = false;
  3324. for ( i in this.handles ) {
  3325. handle = $( this.handles[ i ] )[ 0 ];
  3326. if ( handle === event.target || $.contains( handle, event.target ) ) {
  3327. capture = true;
  3328. }
  3329. }
  3330. return !this.options.disabled && capture;
  3331. },
  3332. _mouseStart: function( event ) {
  3333. var curleft, curtop, cursor,
  3334. o = this.options,
  3335. el = this.element;
  3336. this.resizing = true;
  3337. this._renderProxy();
  3338. curleft = this._num( this.helper.css( "left" ) );
  3339. curtop = this._num( this.helper.css( "top" ) );
  3340. if ( o.containment ) {
  3341. curleft += $( o.containment ).scrollLeft() || 0;
  3342. curtop += $( o.containment ).scrollTop() || 0;
  3343. }
  3344. this.offset = this.helper.offset();
  3345. this.position = { left: curleft, top: curtop };
  3346. this.size = this._helper ? {
  3347. width: this.helper.width(),
  3348. height: this.helper.height()
  3349. } : {
  3350. width: el.width(),
  3351. height: el.height()
  3352. };
  3353. this.originalSize = this._helper ? {
  3354. width: el.outerWidth(),
  3355. height: el.outerHeight()
  3356. } : {
  3357. width: el.width(),
  3358. height: el.height()
  3359. };
  3360. this.sizeDiff = {
  3361. width: el.outerWidth() - el.width(),
  3362. height: el.outerHeight() - el.height()
  3363. };
  3364. this.originalPosition = { left: curleft, top: curtop };
  3365. this.originalMousePosition = { left: event.pageX, top: event.pageY };
  3366. this.aspectRatio = ( typeof o.aspectRatio === "number" ) ?
  3367. o.aspectRatio :
  3368. ( ( this.originalSize.width / this.originalSize.height ) || 1 );
  3369. cursor = $( ".ui-resizable-" + this.axis ).css( "cursor" );
  3370. $( "body" ).css( "cursor", cursor === "auto" ? this.axis + "-resize" : cursor );
  3371. this._addClass( "ui-resizable-resizing" );
  3372. this._propagate( "start", event );
  3373. return true;
  3374. },
  3375. _mouseDrag: function( event ) {
  3376. var data, props,
  3377. smp = this.originalMousePosition,
  3378. a = this.axis,
  3379. dx = ( event.pageX - smp.left ) || 0,
  3380. dy = ( event.pageY - smp.top ) || 0,
  3381. trigger = this._change[ a ];
  3382. this._updatePrevProperties();
  3383. if ( !trigger ) {
  3384. return false;
  3385. }
  3386. data = trigger.apply( this, [ event, dx, dy ] );
  3387. this._updateVirtualBoundaries( event.shiftKey );
  3388. if ( this._aspectRatio || event.shiftKey ) {
  3389. data = this._updateRatio( data, event );
  3390. }
  3391. data = this._respectSize( data, event );
  3392. this._updateCache( data );
  3393. this._propagate( "resize", event );
  3394. props = this._applyChanges();
  3395. if ( !this._helper && this._proportionallyResizeElements.length ) {
  3396. this._proportionallyResize();
  3397. }
  3398. if ( !$.isEmptyObject( props ) ) {
  3399. this._updatePrevProperties();
  3400. this._trigger( "resize", event, this.ui() );
  3401. this._applyChanges();
  3402. }
  3403. return false;
  3404. },
  3405. _mouseStop: function( event ) {
  3406. this.resizing = false;
  3407. var pr, ista, soffseth, soffsetw, s, left, top,
  3408. o = this.options, that = this;
  3409. if ( this._helper ) {
  3410. pr = this._proportionallyResizeElements;
  3411. ista = pr.length && ( /textarea/i ).test( pr[ 0 ].nodeName );
  3412. soffseth = ista && this._hasScroll( pr[ 0 ], "left" ) ? 0 : that.sizeDiff.height;
  3413. soffsetw = ista ? 0 : that.sizeDiff.width;
  3414. s = {
  3415. width: ( that.helper.width() - soffsetw ),
  3416. height: ( that.helper.height() - soffseth )
  3417. };
  3418. left = ( parseFloat( that.element.css( "left" ) ) +
  3419. ( that.position.left - that.originalPosition.left ) ) || null;
  3420. top = ( parseFloat( that.element.css( "top" ) ) +
  3421. ( that.position.top - that.originalPosition.top ) ) || null;
  3422. if ( !o.animate ) {
  3423. this.element.css( $.extend( s, { top: top, left: left } ) );
  3424. }
  3425. that.helper.height( that.size.height );
  3426. that.helper.width( that.size.width );
  3427. if ( this._helper && !o.animate ) {
  3428. this._proportionallyResize();
  3429. }
  3430. }
  3431. $( "body" ).css( "cursor", "auto" );
  3432. this._removeClass( "ui-resizable-resizing" );
  3433. this._propagate( "stop", event );
  3434. if ( this._helper ) {
  3435. this.helper.remove();
  3436. }
  3437. return false;
  3438. },
  3439. _updatePrevProperties: function() {
  3440. this.prevPosition = {
  3441. top: this.position.top,
  3442. left: this.position.left
  3443. };
  3444. this.prevSize = {
  3445. width: this.size.width,
  3446. height: this.size.height
  3447. };
  3448. },
  3449. _applyChanges: function() {
  3450. var props = {};
  3451. if ( this.position.top !== this.prevPosition.top ) {
  3452. props.top = this.position.top + "px";
  3453. }
  3454. if ( this.position.left !== this.prevPosition.left ) {
  3455. props.left = this.position.left + "px";
  3456. }
  3457. if ( this.size.width !== this.prevSize.width ) {
  3458. props.width = this.size.width + "px";
  3459. }
  3460. if ( this.size.height !== this.prevSize.height ) {
  3461. props.height = this.size.height + "px";
  3462. }
  3463. this.helper.css( props );
  3464. return props;
  3465. },
  3466. _updateVirtualBoundaries: function( forceAspectRatio ) {
  3467. var pMinWidth, pMaxWidth, pMinHeight, pMaxHeight, b,
  3468. o = this.options;
  3469. b = {
  3470. minWidth: this._isNumber( o.minWidth ) ? o.minWidth : 0,
  3471. maxWidth: this._isNumber( o.maxWidth ) ? o.maxWidth : Infinity,
  3472. minHeight: this._isNumber( o.minHeight ) ? o.minHeight : 0,
  3473. maxHeight: this._isNumber( o.maxHeight ) ? o.maxHeight : Infinity
  3474. };
  3475. if ( this._aspectRatio || forceAspectRatio ) {
  3476. pMinWidth = b.minHeight * this.aspectRatio;
  3477. pMinHeight = b.minWidth / this.aspectRatio;
  3478. pMaxWidth = b.maxHeight * this.aspectRatio;
  3479. pMaxHeight = b.maxWidth / this.aspectRatio;
  3480. if ( pMinWidth > b.minWidth ) {
  3481. b.minWidth = pMinWidth;
  3482. }
  3483. if ( pMinHeight > b.minHeight ) {
  3484. b.minHeight = pMinHeight;
  3485. }
  3486. if ( pMaxWidth < b.maxWidth ) {
  3487. b.maxWidth = pMaxWidth;
  3488. }
  3489. if ( pMaxHeight < b.maxHeight ) {
  3490. b.maxHeight = pMaxHeight;
  3491. }
  3492. }
  3493. this._vBoundaries = b;
  3494. },
  3495. _updateCache: function( data ) {
  3496. this.offset = this.helper.offset();
  3497. if ( this._isNumber( data.left ) ) {
  3498. this.position.left = data.left;
  3499. }
  3500. if ( this._isNumber( data.top ) ) {
  3501. this.position.top = data.top;
  3502. }
  3503. if ( this._isNumber( data.height ) ) {
  3504. this.size.height = data.height;
  3505. }
  3506. if ( this._isNumber( data.width ) ) {
  3507. this.size.width = data.width;
  3508. }
  3509. },
  3510. _updateRatio: function( data ) {
  3511. var cpos = this.position,
  3512. csize = this.size,
  3513. a = this.axis;
  3514. if ( this._isNumber( data.height ) ) {
  3515. data.width = ( data.height * this.aspectRatio );
  3516. } else if ( this._isNumber( data.width ) ) {
  3517. data.height = ( data.width / this.aspectRatio );
  3518. }
  3519. if ( a === "sw" ) {
  3520. data.left = cpos.left + ( csize.width - data.width );
  3521. data.top = null;
  3522. }
  3523. if ( a === "nw" ) {
  3524. data.top = cpos.top + ( csize.height - data.height );
  3525. data.left = cpos.left + ( csize.width - data.width );
  3526. }
  3527. return data;
  3528. },
  3529. _respectSize: function( data ) {
  3530. var o = this._vBoundaries,
  3531. a = this.axis,
  3532. ismaxw = this._isNumber( data.width ) && o.maxWidth && ( o.maxWidth < data.width ),
  3533. ismaxh = this._isNumber( data.height ) && o.maxHeight && ( o.maxHeight < data.height ),
  3534. isminw = this._isNumber( data.width ) && o.minWidth && ( o.minWidth > data.width ),
  3535. isminh = this._isNumber( data.height ) && o.minHeight && ( o.minHeight > data.height ),
  3536. dw = this.originalPosition.left + this.originalSize.width,
  3537. dh = this.originalPosition.top + this.originalSize.height,
  3538. cw = /sw|nw|w/.test( a ), ch = /nw|ne|n/.test( a );
  3539. if ( isminw ) {
  3540. data.width = o.minWidth;
  3541. }
  3542. if ( isminh ) {
  3543. data.height = o.minHeight;
  3544. }
  3545. if ( ismaxw ) {
  3546. data.width = o.maxWidth;
  3547. }
  3548. if ( ismaxh ) {
  3549. data.height = o.maxHeight;
  3550. }
  3551. if ( isminw && cw ) {
  3552. data.left = dw - o.minWidth;
  3553. }
  3554. if ( ismaxw && cw ) {
  3555. data.left = dw - o.maxWidth;
  3556. }
  3557. if ( isminh && ch ) {
  3558. data.top = dh - o.minHeight;
  3559. }
  3560. if ( ismaxh && ch ) {
  3561. data.top = dh - o.maxHeight;
  3562. }
  3563. // Fixing jump error on top/left - bug #2330
  3564. if ( !data.width && !data.height && !data.left && data.top ) {
  3565. data.top = null;
  3566. } else if ( !data.width && !data.height && !data.top && data.left ) {
  3567. data.left = null;
  3568. }
  3569. return data;
  3570. },
  3571. _getPaddingPlusBorderDimensions: function( element ) {
  3572. var i = 0,
  3573. widths = [],
  3574. borders = [
  3575. element.css( "borderTopWidth" ),
  3576. element.css( "borderRightWidth" ),
  3577. element.css( "borderBottomWidth" ),
  3578. element.css( "borderLeftWidth" )
  3579. ],
  3580. paddings = [
  3581. element.css( "paddingTop" ),
  3582. element.css( "paddingRight" ),
  3583. element.css( "paddingBottom" ),
  3584. element.css( "paddingLeft" )
  3585. ];
  3586. for ( ; i < 4; i++ ) {
  3587. widths[ i ] = ( parseFloat( borders[ i ] ) || 0 );
  3588. widths[ i ] += ( parseFloat( paddings[ i ] ) || 0 );
  3589. }
  3590. return {
  3591. height: widths[ 0 ] + widths[ 2 ],
  3592. width: widths[ 1 ] + widths[ 3 ]
  3593. };
  3594. },
  3595. _proportionallyResize: function() {
  3596. if ( !this._proportionallyResizeElements.length ) {
  3597. return;
  3598. }
  3599. var prel,
  3600. i = 0,
  3601. element = this.helper || this.element;
  3602. for ( ; i < this._proportionallyResizeElements.length; i++ ) {
  3603. prel = this._proportionallyResizeElements[ i ];
  3604. // TODO: Seems like a bug to cache this.outerDimensions
  3605. // considering that we are in a loop.
  3606. if ( !this.outerDimensions ) {
  3607. this.outerDimensions = this._getPaddingPlusBorderDimensions( prel );
  3608. }
  3609. prel.css( {
  3610. height: ( element.height() - this.outerDimensions.height ) || 0,
  3611. width: ( element.width() - this.outerDimensions.width ) || 0
  3612. } );
  3613. }
  3614. },
  3615. _renderProxy: function() {
  3616. var el = this.element, o = this.options;
  3617. this.elementOffset = el.offset();
  3618. if ( this._helper ) {
  3619. this.helper = this.helper || $( "<div style='overflow:hidden;'></div>" );
  3620. this._addClass( this.helper, this._helper );
  3621. this.helper.css( {
  3622. width: this.element.outerWidth(),
  3623. height: this.element.outerHeight(),
  3624. position: "absolute",
  3625. left: this.elementOffset.left + "px",
  3626. top: this.elementOffset.top + "px",
  3627. zIndex: ++o.zIndex //TODO: Don't modify option
  3628. } );
  3629. this.helper
  3630. .appendTo( "body" )
  3631. .disableSelection();
  3632. } else {
  3633. this.helper = this.element;
  3634. }
  3635. },
  3636. _change: {
  3637. e: function( event, dx ) {
  3638. return { width: this.originalSize.width + dx };
  3639. },
  3640. w: function( event, dx ) {
  3641. var cs = this.originalSize, sp = this.originalPosition;
  3642. return { left: sp.left + dx, width: cs.width - dx };
  3643. },
  3644. n: function( event, dx, dy ) {
  3645. var cs = this.originalSize, sp = this.originalPosition;
  3646. return { top: sp.top + dy, height: cs.height - dy };
  3647. },
  3648. s: function( event, dx, dy ) {
  3649. return { height: this.originalSize.height + dy };
  3650. },
  3651. se: function( event, dx, dy ) {
  3652. return $.extend( this._change.s.apply( this, arguments ),
  3653. this._change.e.apply( this, [ event, dx, dy ] ) );
  3654. },
  3655. sw: function( event, dx, dy ) {
  3656. return $.extend( this._change.s.apply( this, arguments ),
  3657. this._change.w.apply( this, [ event, dx, dy ] ) );
  3658. },
  3659. ne: function( event, dx, dy ) {
  3660. return $.extend( this._change.n.apply( this, arguments ),
  3661. this._change.e.apply( this, [ event, dx, dy ] ) );
  3662. },
  3663. nw: function( event, dx, dy ) {
  3664. return $.extend( this._change.n.apply( this, arguments ),
  3665. this._change.w.apply( this, [ event, dx, dy ] ) );
  3666. }
  3667. },
  3668. _propagate: function( n, event ) {
  3669. $.ui.plugin.call( this, n, [ event, this.ui() ] );
  3670. ( n !== "resize" && this._trigger( n, event, this.ui() ) );
  3671. },
  3672. plugins: {},
  3673. ui: function() {
  3674. return {
  3675. originalElement: this.originalElement,
  3676. element: this.element,
  3677. helper: this.helper,
  3678. position: this.position,
  3679. size: this.size,
  3680. originalSize: this.originalSize,
  3681. originalPosition: this.originalPosition
  3682. };
  3683. }
  3684. } );
  3685. /*
  3686. * Resizable Extensions
  3687. */
  3688. $.ui.plugin.add( "resizable", "animate", {
  3689. stop: function( event ) {
  3690. var that = $( this ).resizable( "instance" ),
  3691. o = that.options,
  3692. pr = that._proportionallyResizeElements,
  3693. ista = pr.length && ( /textarea/i ).test( pr[ 0 ].nodeName ),
  3694. soffseth = ista && that._hasScroll( pr[ 0 ], "left" ) ? 0 : that.sizeDiff.height,
  3695. soffsetw = ista ? 0 : that.sizeDiff.width,
  3696. style = {
  3697. width: ( that.size.width - soffsetw ),
  3698. height: ( that.size.height - soffseth )
  3699. },
  3700. left = ( parseFloat( that.element.css( "left" ) ) +
  3701. ( that.position.left - that.originalPosition.left ) ) || null,
  3702. top = ( parseFloat( that.element.css( "top" ) ) +
  3703. ( that.position.top - that.originalPosition.top ) ) || null;
  3704. that.element.animate(
  3705. $.extend( style, top && left ? { top: top, left: left } : {} ), {
  3706. duration: o.animateDuration,
  3707. easing: o.animateEasing,
  3708. step: function() {
  3709. var data = {
  3710. width: parseFloat( that.element.css( "width" ) ),
  3711. height: parseFloat( that.element.css( "height" ) ),
  3712. top: parseFloat( that.element.css( "top" ) ),
  3713. left: parseFloat( that.element.css( "left" ) )
  3714. };
  3715. if ( pr && pr.length ) {
  3716. $( pr[ 0 ] ).css( { width: data.width, height: data.height } );
  3717. }
  3718. // Propagating resize, and updating values for each animation step
  3719. that._updateCache( data );
  3720. that._propagate( "resize", event );
  3721. }
  3722. }
  3723. );
  3724. }
  3725. } );
  3726. $.ui.plugin.add( "resizable", "containment", {
  3727. start: function() {
  3728. var element, p, co, ch, cw, width, height,
  3729. that = $( this ).resizable( "instance" ),
  3730. o = that.options,
  3731. el = that.element,
  3732. oc = o.containment,
  3733. ce = ( oc instanceof $ ) ?
  3734. oc.get( 0 ) :
  3735. ( /parent/.test( oc ) ) ? el.parent().get( 0 ) : oc;
  3736. if ( !ce ) {
  3737. return;
  3738. }
  3739. that.containerElement = $( ce );
  3740. if ( /document/.test( oc ) || oc === document ) {
  3741. that.containerOffset = {
  3742. left: 0,
  3743. top: 0
  3744. };
  3745. that.containerPosition = {
  3746. left: 0,
  3747. top: 0
  3748. };
  3749. that.parentData = {
  3750. element: $( document ),
  3751. left: 0,
  3752. top: 0,
  3753. width: $( document ).width(),
  3754. height: $( document ).height() || document.body.parentNode.scrollHeight
  3755. };
  3756. } else {
  3757. element = $( ce );
  3758. p = [];
  3759. $( [ "Top", "Right", "Left", "Bottom" ] ).each( function( i, name ) {
  3760. p[ i ] = that._num( element.css( "padding" + name ) );
  3761. } );
  3762. that.containerOffset = element.offset();
  3763. that.containerPosition = element.position();
  3764. that.containerSize = {
  3765. height: ( element.innerHeight() - p[ 3 ] ),
  3766. width: ( element.innerWidth() - p[ 1 ] )
  3767. };
  3768. co = that.containerOffset;
  3769. ch = that.containerSize.height;
  3770. cw = that.containerSize.width;
  3771. width = ( that._hasScroll ( ce, "left" ) ? ce.scrollWidth : cw );
  3772. height = ( that._hasScroll ( ce ) ? ce.scrollHeight : ch ) ;
  3773. that.parentData = {
  3774. element: ce,
  3775. left: co.left,
  3776. top: co.top,
  3777. width: width,
  3778. height: height
  3779. };
  3780. }
  3781. },
  3782. resize: function( event ) {
  3783. var woset, hoset, isParent, isOffsetRelative,
  3784. that = $( this ).resizable( "instance" ),
  3785. o = that.options,
  3786. co = that.containerOffset,
  3787. cp = that.position,
  3788. pRatio = that._aspectRatio || event.shiftKey,
  3789. cop = {
  3790. top: 0,
  3791. left: 0
  3792. },
  3793. ce = that.containerElement,
  3794. continueResize = true;
  3795. if ( ce[ 0 ] !== document && ( /static/ ).test( ce.css( "position" ) ) ) {
  3796. cop = co;
  3797. }
  3798. if ( cp.left < ( that._helper ? co.left : 0 ) ) {
  3799. that.size.width = that.size.width +
  3800. ( that._helper ?
  3801. ( that.position.left - co.left ) :
  3802. ( that.position.left - cop.left ) );
  3803. if ( pRatio ) {
  3804. that.size.height = that.size.width / that.aspectRatio;
  3805. continueResize = false;
  3806. }
  3807. that.position.left = o.helper ? co.left : 0;
  3808. }
  3809. if ( cp.top < ( that._helper ? co.top : 0 ) ) {
  3810. that.size.height = that.size.height +
  3811. ( that._helper ?
  3812. ( that.position.top - co.top ) :
  3813. that.position.top );
  3814. if ( pRatio ) {
  3815. that.size.width = that.size.height * that.aspectRatio;
  3816. continueResize = false;
  3817. }
  3818. that.position.top = that._helper ? co.top : 0;
  3819. }
  3820. isParent = that.containerElement.get( 0 ) === that.element.parent().get( 0 );
  3821. isOffsetRelative = /relative|absolute/.test( that.containerElement.css( "position" ) );
  3822. if ( isParent && isOffsetRelative ) {
  3823. that.offset.left = that.parentData.left + that.position.left;
  3824. that.offset.top = that.parentData.top + that.position.top;
  3825. } else {
  3826. that.offset.left = that.element.offset().left;
  3827. that.offset.top = that.element.offset().top;
  3828. }
  3829. woset = Math.abs( that.sizeDiff.width +
  3830. ( that._helper ?
  3831. that.offset.left - cop.left :
  3832. ( that.offset.left - co.left ) ) );
  3833. hoset = Math.abs( that.sizeDiff.height +
  3834. ( that._helper ?
  3835. that.offset.top - cop.top :
  3836. ( that.offset.top - co.top ) ) );
  3837. if ( woset + that.size.width >= that.parentData.width ) {
  3838. that.size.width = that.parentData.width - woset;
  3839. if ( pRatio ) {
  3840. that.size.height = that.size.width / that.aspectRatio;
  3841. continueResize = false;
  3842. }
  3843. }
  3844. if ( hoset + that.size.height >= that.parentData.height ) {
  3845. that.size.height = that.parentData.height - hoset;
  3846. if ( pRatio ) {
  3847. that.size.width = that.size.height * that.aspectRatio;
  3848. continueResize = false;
  3849. }
  3850. }
  3851. if ( !continueResize ) {
  3852. that.position.left = that.prevPosition.left;
  3853. that.position.top = that.prevPosition.top;
  3854. that.size.width = that.prevSize.width;
  3855. that.size.height = that.prevSize.height;
  3856. }
  3857. },
  3858. stop: function() {
  3859. var that = $( this ).resizable( "instance" ),
  3860. o = that.options,
  3861. co = that.containerOffset,
  3862. cop = that.containerPosition,
  3863. ce = that.containerElement,
  3864. helper = $( that.helper ),
  3865. ho = helper.offset(),
  3866. w = helper.outerWidth() - that.sizeDiff.width,
  3867. h = helper.outerHeight() - that.sizeDiff.height;
  3868. if ( that._helper && !o.animate && ( /relative/ ).test( ce.css( "position" ) ) ) {
  3869. $( this ).css( {
  3870. left: ho.left - cop.left - co.left,
  3871. width: w,
  3872. height: h
  3873. } );
  3874. }
  3875. if ( that._helper && !o.animate && ( /static/ ).test( ce.css( "position" ) ) ) {
  3876. $( this ).css( {
  3877. left: ho.left - cop.left - co.left,
  3878. width: w,
  3879. height: h
  3880. } );
  3881. }
  3882. }
  3883. } );
  3884. $.ui.plugin.add( "resizable", "alsoResize", {
  3885. start: function() {
  3886. var that = $( this ).resizable( "instance" ),
  3887. o = that.options;
  3888. $( o.alsoResize ).each( function() {
  3889. var el = $( this );
  3890. el.data( "ui-resizable-alsoresize", {
  3891. width: parseFloat( el.width() ), height: parseFloat( el.height() ),
  3892. left: parseFloat( el.css( "left" ) ), top: parseFloat( el.css( "top" ) )
  3893. } );
  3894. } );
  3895. },
  3896. resize: function( event, ui ) {
  3897. var that = $( this ).resizable( "instance" ),
  3898. o = that.options,
  3899. os = that.originalSize,
  3900. op = that.originalPosition,
  3901. delta = {
  3902. height: ( that.size.height - os.height ) || 0,
  3903. width: ( that.size.width - os.width ) || 0,
  3904. top: ( that.position.top - op.top ) || 0,
  3905. left: ( that.position.left - op.left ) || 0
  3906. };
  3907. $( o.alsoResize ).each( function() {
  3908. var el = $( this ), start = $( this ).data( "ui-resizable-alsoresize" ), style = {},
  3909. css = el.parents( ui.originalElement[ 0 ] ).length ?
  3910. [ "width", "height" ] :
  3911. [ "width", "height", "top", "left" ];
  3912. $.each( css, function( i, prop ) {
  3913. var sum = ( start[ prop ] || 0 ) + ( delta[ prop ] || 0 );
  3914. if ( sum && sum >= 0 ) {
  3915. style[ prop ] = sum || null;
  3916. }
  3917. } );
  3918. el.css( style );
  3919. } );
  3920. },
  3921. stop: function() {
  3922. $( this ).removeData( "ui-resizable-alsoresize" );
  3923. }
  3924. } );
  3925. $.ui.plugin.add( "resizable", "ghost", {
  3926. start: function() {
  3927. var that = $( this ).resizable( "instance" ), cs = that.size;
  3928. that.ghost = that.originalElement.clone();
  3929. that.ghost.css( {
  3930. opacity: 0.25,
  3931. display: "block",
  3932. position: "relative",
  3933. height: cs.height,
  3934. width: cs.width,
  3935. margin: 0,
  3936. left: 0,
  3937. top: 0
  3938. } );
  3939. that._addClass( that.ghost, "ui-resizable-ghost" );
  3940. // DEPRECATED
  3941. // TODO: remove after 1.12
  3942. if ( $.uiBackCompat !== false && typeof that.options.ghost === "string" ) {
  3943. // Ghost option
  3944. that.ghost.addClass( this.options.ghost );
  3945. }
  3946. that.ghost.appendTo( that.helper );
  3947. },
  3948. resize: function() {
  3949. var that = $( this ).resizable( "instance" );
  3950. if ( that.ghost ) {
  3951. that.ghost.css( {
  3952. position: "relative",
  3953. height: that.size.height,
  3954. width: that.size.width
  3955. } );
  3956. }
  3957. },
  3958. stop: function() {
  3959. var that = $( this ).resizable( "instance" );
  3960. if ( that.ghost && that.helper ) {
  3961. that.helper.get( 0 ).removeChild( that.ghost.get( 0 ) );
  3962. }
  3963. }
  3964. } );
  3965. $.ui.plugin.add( "resizable", "grid", {
  3966. resize: function() {
  3967. var outerDimensions,
  3968. that = $( this ).resizable( "instance" ),
  3969. o = that.options,
  3970. cs = that.size,
  3971. os = that.originalSize,
  3972. op = that.originalPosition,
  3973. a = that.axis,
  3974. grid = typeof o.grid === "number" ? [ o.grid, o.grid ] : o.grid,
  3975. gridX = ( grid[ 0 ] || 1 ),
  3976. gridY = ( grid[ 1 ] || 1 ),
  3977. ox = Math.round( ( cs.width - os.width ) / gridX ) * gridX,
  3978. oy = Math.round( ( cs.height - os.height ) / gridY ) * gridY,
  3979. newWidth = os.width + ox,
  3980. newHeight = os.height + oy,
  3981. isMaxWidth = o.maxWidth && ( o.maxWidth < newWidth ),
  3982. isMaxHeight = o.maxHeight && ( o.maxHeight < newHeight ),
  3983. isMinWidth = o.minWidth && ( o.minWidth > newWidth ),
  3984. isMinHeight = o.minHeight && ( o.minHeight > newHeight );
  3985. o.grid = grid;
  3986. if ( isMinWidth ) {
  3987. newWidth += gridX;
  3988. }
  3989. if ( isMinHeight ) {
  3990. newHeight += gridY;
  3991. }
  3992. if ( isMaxWidth ) {
  3993. newWidth -= gridX;
  3994. }
  3995. if ( isMaxHeight ) {
  3996. newHeight -= gridY;
  3997. }
  3998. if ( /^(se|s|e)$/.test( a ) ) {
  3999. that.size.width = newWidth;
  4000. that.size.height = newHeight;
  4001. } else if ( /^(ne)$/.test( a ) ) {
  4002. that.size.width = newWidth;
  4003. that.size.height = newHeight;
  4004. that.position.top = op.top - oy;
  4005. } else if ( /^(sw)$/.test( a ) ) {
  4006. that.size.width = newWidth;
  4007. that.size.height = newHeight;
  4008. that.position.left = op.left - ox;
  4009. } else {
  4010. if ( newHeight - gridY <= 0 || newWidth - gridX <= 0 ) {
  4011. outerDimensions = that._getPaddingPlusBorderDimensions( this );
  4012. }
  4013. if ( newHeight - gridY > 0 ) {
  4014. that.size.height = newHeight;
  4015. that.position.top = op.top - oy;
  4016. } else {
  4017. newHeight = gridY - outerDimensions.height;
  4018. that.size.height = newHeight;
  4019. that.position.top = op.top + os.height - newHeight;
  4020. }
  4021. if ( newWidth - gridX > 0 ) {
  4022. that.size.width = newWidth;
  4023. that.position.left = op.left - ox;
  4024. } else {
  4025. newWidth = gridX - outerDimensions.width;
  4026. that.size.width = newWidth;
  4027. that.position.left = op.left + os.width - newWidth;
  4028. }
  4029. }
  4030. }
  4031. } );
  4032. var widgetsResizable = $.ui.resizable;
  4033. /*!
  4034. * jQuery UI Selectable 1.12.0
  4035. * http://jqueryui.com
  4036. *
  4037. * Copyright jQuery Foundation and other contributors
  4038. * Released under the MIT license.
  4039. * http://jquery.org/license
  4040. */
  4041. //>>label: Selectable
  4042. //>>group: Interactions
  4043. //>>description: Allows groups of elements to be selected with the mouse.
  4044. //>>docs: http://api.jqueryui.com/selectable/
  4045. //>>demos: http://jqueryui.com/selectable/
  4046. //>>css.structure: ../../themes/base/selectable.css
  4047. var widgetsSelectable = $.widget( "ui.selectable", $.ui.mouse, {
  4048. version: "1.12.0",
  4049. options: {
  4050. appendTo: "body",
  4051. autoRefresh: true,
  4052. distance: 0,
  4053. filter: "*",
  4054. tolerance: "touch",
  4055. // Callbacks
  4056. selected: null,
  4057. selecting: null,
  4058. start: null,
  4059. stop: null,
  4060. unselected: null,
  4061. unselecting: null
  4062. },
  4063. _create: function() {
  4064. var that = this;
  4065. this._addClass( "ui-selectable" );
  4066. this.dragged = false;
  4067. // Cache selectee children based on filter
  4068. this.refresh = function() {
  4069. that.elementPos = $( that.element[ 0 ] ).offset();
  4070. that.selectees = $( that.options.filter, that.element[ 0 ] );
  4071. that._addClass( that.selectees, "ui-selectee" );
  4072. that.selectees.each( function() {
  4073. var $this = $( this ),
  4074. selecteeOffset = $this.offset(),
  4075. pos = {
  4076. left: selecteeOffset.left - that.elementPos.left,
  4077. top: selecteeOffset.top - that.elementPos.top
  4078. };
  4079. $.data( this, "selectable-item", {
  4080. element: this,
  4081. $element: $this,
  4082. left: pos.left,
  4083. top: pos.top,
  4084. right: pos.left + $this.outerWidth(),
  4085. bottom: pos.top + $this.outerHeight(),
  4086. startselected: false,
  4087. selected: $this.hasClass( "ui-selected" ),
  4088. selecting: $this.hasClass( "ui-selecting" ),
  4089. unselecting: $this.hasClass( "ui-unselecting" )
  4090. } );
  4091. } );
  4092. };
  4093. this.refresh();
  4094. this._mouseInit();
  4095. this.helper = $( "<div>" );
  4096. this._addClass( this.helper, "ui-selectable-helper" );
  4097. },
  4098. _destroy: function() {
  4099. this.selectees.removeData( "selectable-item" );
  4100. this._mouseDestroy();
  4101. },
  4102. _mouseStart: function( event ) {
  4103. var that = this,
  4104. options = this.options;
  4105. this.opos = [ event.pageX, event.pageY ];
  4106. this.elementPos = $( this.element[ 0 ] ).offset();
  4107. if ( this.options.disabled ) {
  4108. return;
  4109. }
  4110. this.selectees = $( options.filter, this.element[ 0 ] );
  4111. this._trigger( "start", event );
  4112. $( options.appendTo ).append( this.helper );
  4113. // position helper (lasso)
  4114. this.helper.css( {
  4115. "left": event.pageX,
  4116. "top": event.pageY,
  4117. "width": 0,
  4118. "height": 0
  4119. } );
  4120. if ( options.autoRefresh ) {
  4121. this.refresh();
  4122. }
  4123. this.selectees.filter( ".ui-selected" ).each( function() {
  4124. var selectee = $.data( this, "selectable-item" );
  4125. selectee.startselected = true;
  4126. if ( !event.metaKey && !event.ctrlKey ) {
  4127. that._removeClass( selectee.$element, "ui-selected" );
  4128. selectee.selected = false;
  4129. that._addClass( selectee.$element, "ui-unselecting" );
  4130. selectee.unselecting = true;
  4131. // selectable UNSELECTING callback
  4132. that._trigger( "unselecting", event, {
  4133. unselecting: selectee.element
  4134. } );
  4135. }
  4136. } );
  4137. $( event.target ).parents().addBack().each( function() {
  4138. var doSelect,
  4139. selectee = $.data( this, "selectable-item" );
  4140. if ( selectee ) {
  4141. doSelect = ( !event.metaKey && !event.ctrlKey ) ||
  4142. !selectee.$element.hasClass( "ui-selected" );
  4143. that._removeClass( selectee.$element, doSelect ? "ui-unselecting" : "ui-selected" )
  4144. ._addClass( selectee.$element, doSelect ? "ui-selecting" : "ui-unselecting" );
  4145. selectee.unselecting = !doSelect;
  4146. selectee.selecting = doSelect;
  4147. selectee.selected = doSelect;
  4148. // selectable (UN)SELECTING callback
  4149. if ( doSelect ) {
  4150. that._trigger( "selecting", event, {
  4151. selecting: selectee.element
  4152. } );
  4153. } else {
  4154. that._trigger( "unselecting", event, {
  4155. unselecting: selectee.element
  4156. } );
  4157. }
  4158. return false;
  4159. }
  4160. } );
  4161. },
  4162. _mouseDrag: function( event ) {
  4163. this.dragged = true;
  4164. if ( this.options.disabled ) {
  4165. return;
  4166. }
  4167. var tmp,
  4168. that = this,
  4169. options = this.options,
  4170. x1 = this.opos[ 0 ],
  4171. y1 = this.opos[ 1 ],
  4172. x2 = event.pageX,
  4173. y2 = event.pageY;
  4174. if ( x1 > x2 ) { tmp = x2; x2 = x1; x1 = tmp; }
  4175. if ( y1 > y2 ) { tmp = y2; y2 = y1; y1 = tmp; }
  4176. this.helper.css( { left: x1, top: y1, width: x2 - x1, height: y2 - y1 } );
  4177. this.selectees.each( function() {
  4178. var selectee = $.data( this, "selectable-item" ),
  4179. hit = false,
  4180. offset = {};
  4181. //prevent helper from being selected if appendTo: selectable
  4182. if ( !selectee || selectee.element === that.element[ 0 ] ) {
  4183. return;
  4184. }
  4185. offset.left = selectee.left + that.elementPos.left;
  4186. offset.right = selectee.right + that.elementPos.left;
  4187. offset.top = selectee.top + that.elementPos.top;
  4188. offset.bottom = selectee.bottom + that.elementPos.top;
  4189. if ( options.tolerance === "touch" ) {
  4190. hit = ( !( offset.left > x2 || offset.right < x1 || offset.top > y2 ||
  4191. offset.bottom < y1 ) );
  4192. } else if ( options.tolerance === "fit" ) {
  4193. hit = ( offset.left > x1 && offset.right < x2 && offset.top > y1 &&
  4194. offset.bottom < y2 );
  4195. }
  4196. if ( hit ) {
  4197. // SELECT
  4198. if ( selectee.selected ) {
  4199. that._removeClass( selectee.$element, "ui-selected" );
  4200. selectee.selected = false;
  4201. }
  4202. if ( selectee.unselecting ) {
  4203. that._removeClass( selectee.$element, "ui-unselecting" );
  4204. selectee.unselecting = false;
  4205. }
  4206. if ( !selectee.selecting ) {
  4207. that._addClass( selectee.$element, "ui-selecting" );
  4208. selectee.selecting = true;
  4209. // selectable SELECTING callback
  4210. that._trigger( "selecting", event, {
  4211. selecting: selectee.element
  4212. } );
  4213. }
  4214. } else {
  4215. // UNSELECT
  4216. if ( selectee.selecting ) {
  4217. if ( ( event.metaKey || event.ctrlKey ) && selectee.startselected ) {
  4218. that._removeClass( selectee.$element, "ui-selecting" );
  4219. selectee.selecting = false;
  4220. that._addClass( selectee.$element, "ui-selected" );
  4221. selectee.selected = true;
  4222. } else {
  4223. that._removeClass( selectee.$element, "ui-selecting" );
  4224. selectee.selecting = false;
  4225. if ( selectee.startselected ) {
  4226. that._addClass( selectee.$element, "ui-unselecting" );
  4227. selectee.unselecting = true;
  4228. }
  4229. // selectable UNSELECTING callback
  4230. that._trigger( "unselecting", event, {
  4231. unselecting: selectee.element
  4232. } );
  4233. }
  4234. }
  4235. if ( selectee.selected ) {
  4236. if ( !event.metaKey && !event.ctrlKey && !selectee.startselected ) {
  4237. that._removeClass( selectee.$element, "ui-selected" );
  4238. selectee.selected = false;
  4239. that._addClass( selectee.$element, "ui-unselecting" );
  4240. selectee.unselecting = true;
  4241. // selectable UNSELECTING callback
  4242. that._trigger( "unselecting", event, {
  4243. unselecting: selectee.element
  4244. } );
  4245. }
  4246. }
  4247. }
  4248. } );
  4249. return false;
  4250. },
  4251. _mouseStop: function( event ) {
  4252. var that = this;
  4253. this.dragged = false;
  4254. $( ".ui-unselecting", this.element[ 0 ] ).each( function() {
  4255. var selectee = $.data( this, "selectable-item" );
  4256. that._removeClass( selectee.$element, "ui-unselecting" );
  4257. selectee.unselecting = false;
  4258. selectee.startselected = false;
  4259. that._trigger( "unselected", event, {
  4260. unselected: selectee.element
  4261. } );
  4262. } );
  4263. $( ".ui-selecting", this.element[ 0 ] ).each( function() {
  4264. var selectee = $.data( this, "selectable-item" );
  4265. that._removeClass( selectee.$element, "ui-selecting" )
  4266. ._addClass( selectee.$element, "ui-selected" );
  4267. selectee.selecting = false;
  4268. selectee.selected = true;
  4269. selectee.startselected = true;
  4270. that._trigger( "selected", event, {
  4271. selected: selectee.element
  4272. } );
  4273. } );
  4274. this._trigger( "stop", event );
  4275. this.helper.remove();
  4276. return false;
  4277. }
  4278. } );
  4279. /*!
  4280. * jQuery UI Sortable 1.12.0
  4281. * http://jqueryui.com
  4282. *
  4283. * Copyright jQuery Foundation and other contributors
  4284. * Released under the MIT license.
  4285. * http://jquery.org/license
  4286. */
  4287. //>>label: Sortable
  4288. //>>group: Interactions
  4289. //>>description: Enables items in a list to be sorted using the mouse.
  4290. //>>docs: http://api.jqueryui.com/sortable/
  4291. //>>demos: http://jqueryui.com/sortable/
  4292. //>>css.structure: ../../themes/base/sortable.css
  4293. var widgetsSortable = $.widget( "ui.sortable", $.ui.mouse, {
  4294. version: "1.12.0",
  4295. widgetEventPrefix: "sort",
  4296. ready: false,
  4297. options: {
  4298. appendTo: "parent",
  4299. axis: false,
  4300. connectWith: false,
  4301. containment: false,
  4302. cursor: "auto",
  4303. cursorAt: false,
  4304. dropOnEmpty: true,
  4305. forcePlaceholderSize: false,
  4306. forceHelperSize: false,
  4307. grid: false,
  4308. handle: false,
  4309. helper: "original",
  4310. items: "> *",
  4311. opacity: false,
  4312. placeholder: false,
  4313. revert: false,
  4314. scroll: true,
  4315. scrollSensitivity: 20,
  4316. scrollSpeed: 20,
  4317. scope: "default",
  4318. tolerance: "intersect",
  4319. zIndex: 1000,
  4320. // Callbacks
  4321. activate: null,
  4322. beforeStop: null,
  4323. change: null,
  4324. deactivate: null,
  4325. out: null,
  4326. over: null,
  4327. receive: null,
  4328. remove: null,
  4329. sort: null,
  4330. start: null,
  4331. stop: null,
  4332. update: null
  4333. },
  4334. _isOverAxis: function( x, reference, size ) {
  4335. return ( x >= reference ) && ( x < ( reference + size ) );
  4336. },
  4337. _isFloating: function( item ) {
  4338. return ( /left|right/ ).test( item.css( "float" ) ) ||
  4339. ( /inline|table-cell/ ).test( item.css( "display" ) );
  4340. },
  4341. _create: function() {
  4342. this.containerCache = {};
  4343. this._addClass( "ui-sortable" );
  4344. //Get the items
  4345. this.refresh();
  4346. //Let's determine the parent's offset
  4347. this.offset = this.element.offset();
  4348. //Initialize mouse events for interaction
  4349. this._mouseInit();
  4350. this._setHandleClassName();
  4351. //We're ready to go
  4352. this.ready = true;
  4353. },
  4354. _setOption: function( key, value ) {
  4355. this._super( key, value );
  4356. if ( key === "handle" ) {
  4357. this._setHandleClassName();
  4358. }
  4359. },
  4360. _setHandleClassName: function() {
  4361. var that = this;
  4362. this._removeClass( this.element.find( ".ui-sortable-handle" ), "ui-sortable-handle" );
  4363. $.each( this.items, function() {
  4364. that._addClass(
  4365. this.instance.options.handle ?
  4366. this.item.find( this.instance.options.handle ) :
  4367. this.item,
  4368. "ui-sortable-handle"
  4369. );
  4370. } );
  4371. },
  4372. _destroy: function() {
  4373. this._mouseDestroy();
  4374. for ( var i = this.items.length - 1; i >= 0; i-- ) {
  4375. this.items[ i ].item.removeData( this.widgetName + "-item" );
  4376. }
  4377. return this;
  4378. },
  4379. _mouseCapture: function( event, overrideHandle ) {
  4380. var currentItem = null,
  4381. validHandle = false,
  4382. that = this;
  4383. if ( this.reverting ) {
  4384. return false;
  4385. }
  4386. if ( this.options.disabled || this.options.type === "static" ) {
  4387. return false;
  4388. }
  4389. //We have to refresh the items data once first
  4390. this._refreshItems( event );
  4391. //Find out if the clicked node (or one of its parents) is a actual item in this.items
  4392. $( event.target ).parents().each( function() {
  4393. if ( $.data( this, that.widgetName + "-item" ) === that ) {
  4394. currentItem = $( this );
  4395. return false;
  4396. }
  4397. } );
  4398. if ( $.data( event.target, that.widgetName + "-item" ) === that ) {
  4399. currentItem = $( event.target );
  4400. }
  4401. if ( !currentItem ) {
  4402. return false;
  4403. }
  4404. if ( this.options.handle && !overrideHandle ) {
  4405. $( this.options.handle, currentItem ).find( "*" ).addBack().each( function() {
  4406. if ( this === event.target ) {
  4407. validHandle = true;
  4408. }
  4409. } );
  4410. if ( !validHandle ) {
  4411. return false;
  4412. }
  4413. }
  4414. this.currentItem = currentItem;
  4415. this._removeCurrentsFromItems();
  4416. return true;
  4417. },
  4418. _mouseStart: function( event, overrideHandle, noActivation ) {
  4419. var i, body,
  4420. o = this.options;
  4421. this.currentContainer = this;
  4422. //We only need to call refreshPositions, because the refreshItems call has been moved to
  4423. // mouseCapture
  4424. this.refreshPositions();
  4425. //Create and append the visible helper
  4426. this.helper = this._createHelper( event );
  4427. //Cache the helper size
  4428. this._cacheHelperProportions();
  4429. /*
  4430. * - Position generation -
  4431. * This block generates everything position related - it's the core of draggables.
  4432. */
  4433. //Cache the margins of the original element
  4434. this._cacheMargins();
  4435. //Get the next scrolling parent
  4436. this.scrollParent = this.helper.scrollParent();
  4437. //The element's absolute position on the page minus margins
  4438. this.offset = this.currentItem.offset();
  4439. this.offset = {
  4440. top: this.offset.top - this.margins.top,
  4441. left: this.offset.left - this.margins.left
  4442. };
  4443. $.extend( this.offset, {
  4444. click: { //Where the click happened, relative to the element
  4445. left: event.pageX - this.offset.left,
  4446. top: event.pageY - this.offset.top
  4447. },
  4448. parent: this._getParentOffset(),
  4449. // This is a relative to absolute position minus the actual position calculation -
  4450. // only used for relative positioned helper
  4451. relative: this._getRelativeOffset()
  4452. } );
  4453. // Only after we got the offset, we can change the helper's position to absolute
  4454. // TODO: Still need to figure out a way to make relative sorting possible
  4455. this.helper.css( "position", "absolute" );
  4456. this.cssPosition = this.helper.css( "position" );
  4457. //Generate the original position
  4458. this.originalPosition = this._generatePosition( event );
  4459. this.originalPageX = event.pageX;
  4460. this.originalPageY = event.pageY;
  4461. //Adjust the mouse offset relative to the helper if "cursorAt" is supplied
  4462. ( o.cursorAt && this._adjustOffsetFromHelper( o.cursorAt ) );
  4463. //Cache the former DOM position
  4464. this.domPosition = {
  4465. prev: this.currentItem.prev()[ 0 ],
  4466. parent: this.currentItem.parent()[ 0 ]
  4467. };
  4468. // If the helper is not the original, hide the original so it's not playing any role during
  4469. // the drag, won't cause anything bad this way
  4470. if ( this.helper[ 0 ] !== this.currentItem[ 0 ] ) {
  4471. this.currentItem.hide();
  4472. }
  4473. //Create the placeholder
  4474. this._createPlaceholder();
  4475. //Set a containment if given in the options
  4476. if ( o.containment ) {
  4477. this._setContainment();
  4478. }
  4479. if ( o.cursor && o.cursor !== "auto" ) { // cursor option
  4480. body = this.document.find( "body" );
  4481. // Support: IE
  4482. this.storedCursor = body.css( "cursor" );
  4483. body.css( "cursor", o.cursor );
  4484. this.storedStylesheet =
  4485. $( "<style>*{ cursor: " + o.cursor + " !important; }</style>" ).appendTo( body );
  4486. }
  4487. if ( o.opacity ) { // opacity option
  4488. if ( this.helper.css( "opacity" ) ) {
  4489. this._storedOpacity = this.helper.css( "opacity" );
  4490. }
  4491. this.helper.css( "opacity", o.opacity );
  4492. }
  4493. if ( o.zIndex ) { // zIndex option
  4494. if ( this.helper.css( "zIndex" ) ) {
  4495. this._storedZIndex = this.helper.css( "zIndex" );
  4496. }
  4497. this.helper.css( "zIndex", o.zIndex );
  4498. }
  4499. //Prepare scrolling
  4500. if ( this.scrollParent[ 0 ] !== this.document[ 0 ] &&
  4501. this.scrollParent[ 0 ].tagName !== "HTML" ) {
  4502. this.overflowOffset = this.scrollParent.offset();
  4503. }
  4504. //Call callbacks
  4505. this._trigger( "start", event, this._uiHash() );
  4506. //Recache the helper size
  4507. if ( !this._preserveHelperProportions ) {
  4508. this._cacheHelperProportions();
  4509. }
  4510. //Post "activate" events to possible containers
  4511. if ( !noActivation ) {
  4512. for ( i = this.containers.length - 1; i >= 0; i-- ) {
  4513. this.containers[ i ]._trigger( "activate", event, this._uiHash( this ) );
  4514. }
  4515. }
  4516. //Prepare possible droppables
  4517. if ( $.ui.ddmanager ) {
  4518. $.ui.ddmanager.current = this;
  4519. }
  4520. if ( $.ui.ddmanager && !o.dropBehaviour ) {
  4521. $.ui.ddmanager.prepareOffsets( this, event );
  4522. }
  4523. this.dragging = true;
  4524. this._addClass( this.helper, "ui-sortable-helper" );
  4525. // Execute the drag once - this causes the helper not to be visiblebefore getting its
  4526. // correct position
  4527. this._mouseDrag( event );
  4528. return true;
  4529. },
  4530. _mouseDrag: function( event ) {
  4531. var i, item, itemElement, intersection,
  4532. o = this.options,
  4533. scrolled = false;
  4534. //Compute the helpers position
  4535. this.position = this._generatePosition( event );
  4536. this.positionAbs = this._convertPositionTo( "absolute" );
  4537. if ( !this.lastPositionAbs ) {
  4538. this.lastPositionAbs = this.positionAbs;
  4539. }
  4540. //Do scrolling
  4541. if ( this.options.scroll ) {
  4542. if ( this.scrollParent[ 0 ] !== this.document[ 0 ] &&
  4543. this.scrollParent[ 0 ].tagName !== "HTML" ) {
  4544. if ( ( this.overflowOffset.top + this.scrollParent[ 0 ].offsetHeight ) -
  4545. event.pageY < o.scrollSensitivity ) {
  4546. this.scrollParent[ 0 ].scrollTop =
  4547. scrolled = this.scrollParent[ 0 ].scrollTop + o.scrollSpeed;
  4548. } else if ( event.pageY - this.overflowOffset.top < o.scrollSensitivity ) {
  4549. this.scrollParent[ 0 ].scrollTop =
  4550. scrolled = this.scrollParent[ 0 ].scrollTop - o.scrollSpeed;
  4551. }
  4552. if ( ( this.overflowOffset.left + this.scrollParent[ 0 ].offsetWidth ) -
  4553. event.pageX < o.scrollSensitivity ) {
  4554. this.scrollParent[ 0 ].scrollLeft = scrolled =
  4555. this.scrollParent[ 0 ].scrollLeft + o.scrollSpeed;
  4556. } else if ( event.pageX - this.overflowOffset.left < o.scrollSensitivity ) {
  4557. this.scrollParent[ 0 ].scrollLeft = scrolled =
  4558. this.scrollParent[ 0 ].scrollLeft - o.scrollSpeed;
  4559. }
  4560. } else {
  4561. if ( event.pageY - this.document.scrollTop() < o.scrollSensitivity ) {
  4562. scrolled = this.document.scrollTop( this.document.scrollTop() - o.scrollSpeed );
  4563. } else if ( this.window.height() - ( event.pageY - this.document.scrollTop() ) <
  4564. o.scrollSensitivity ) {
  4565. scrolled = this.document.scrollTop( this.document.scrollTop() + o.scrollSpeed );
  4566. }
  4567. if ( event.pageX - this.document.scrollLeft() < o.scrollSensitivity ) {
  4568. scrolled = this.document.scrollLeft(
  4569. this.document.scrollLeft() - o.scrollSpeed
  4570. );
  4571. } else if ( this.window.width() - ( event.pageX - this.document.scrollLeft() ) <
  4572. o.scrollSensitivity ) {
  4573. scrolled = this.document.scrollLeft(
  4574. this.document.scrollLeft() + o.scrollSpeed
  4575. );
  4576. }
  4577. }
  4578. if ( scrolled !== false && $.ui.ddmanager && !o.dropBehaviour ) {
  4579. $.ui.ddmanager.prepareOffsets( this, event );
  4580. }
  4581. }
  4582. //Regenerate the absolute position used for position checks
  4583. this.positionAbs = this._convertPositionTo( "absolute" );
  4584. //Set the helper position
  4585. if ( !this.options.axis || this.options.axis !== "y" ) {
  4586. this.helper[ 0 ].style.left = this.position.left + "px";
  4587. }
  4588. if ( !this.options.axis || this.options.axis !== "x" ) {
  4589. this.helper[ 0 ].style.top = this.position.top + "px";
  4590. }
  4591. //Rearrange
  4592. for ( i = this.items.length - 1; i >= 0; i-- ) {
  4593. //Cache variables and intersection, continue if no intersection
  4594. item = this.items[ i ];
  4595. itemElement = item.item[ 0 ];
  4596. intersection = this._intersectsWithPointer( item );
  4597. if ( !intersection ) {
  4598. continue;
  4599. }
  4600. // Only put the placeholder inside the current Container, skip all
  4601. // items from other containers. This works because when moving
  4602. // an item from one container to another the
  4603. // currentContainer is switched before the placeholder is moved.
  4604. //
  4605. // Without this, moving items in "sub-sortables" can cause
  4606. // the placeholder to jitter between the outer and inner container.
  4607. if ( item.instance !== this.currentContainer ) {
  4608. continue;
  4609. }
  4610. // Cannot intersect with itself
  4611. // no useless actions that have been done before
  4612. // no action if the item moved is the parent of the item checked
  4613. if ( itemElement !== this.currentItem[ 0 ] &&
  4614. this.placeholder[ intersection === 1 ? "next" : "prev" ]()[ 0 ] !== itemElement &&
  4615. !$.contains( this.placeholder[ 0 ], itemElement ) &&
  4616. ( this.options.type === "semi-dynamic" ?
  4617. !$.contains( this.element[ 0 ], itemElement ) :
  4618. true
  4619. )
  4620. ) {
  4621. this.direction = intersection === 1 ? "down" : "up";
  4622. if ( this.options.tolerance === "pointer" || this._intersectsWithSides( item ) ) {
  4623. this._rearrange( event, item );
  4624. } else {
  4625. break;
  4626. }
  4627. this._trigger( "change", event, this._uiHash() );
  4628. break;
  4629. }
  4630. }
  4631. //Post events to containers
  4632. this._contactContainers( event );
  4633. //Interconnect with droppables
  4634. if ( $.ui.ddmanager ) {
  4635. $.ui.ddmanager.drag( this, event );
  4636. }
  4637. //Call callbacks
  4638. this._trigger( "sort", event, this._uiHash() );
  4639. this.lastPositionAbs = this.positionAbs;
  4640. return false;
  4641. },
  4642. _mouseStop: function( event, noPropagation ) {
  4643. if ( !event ) {
  4644. return;
  4645. }
  4646. //If we are using droppables, inform the manager about the drop
  4647. if ( $.ui.ddmanager && !this.options.dropBehaviour ) {
  4648. $.ui.ddmanager.drop( this, event );
  4649. }
  4650. if ( this.options.revert ) {
  4651. var that = this,
  4652. cur = this.placeholder.offset(),
  4653. axis = this.options.axis,
  4654. animation = {};
  4655. if ( !axis || axis === "x" ) {
  4656. animation.left = cur.left - this.offset.parent.left - this.margins.left +
  4657. ( this.offsetParent[ 0 ] === this.document[ 0 ].body ?
  4658. 0 :
  4659. this.offsetParent[ 0 ].scrollLeft
  4660. );
  4661. }
  4662. if ( !axis || axis === "y" ) {
  4663. animation.top = cur.top - this.offset.parent.top - this.margins.top +
  4664. ( this.offsetParent[ 0 ] === this.document[ 0 ].body ?
  4665. 0 :
  4666. this.offsetParent[ 0 ].scrollTop
  4667. );
  4668. }
  4669. this.reverting = true;
  4670. $( this.helper ).animate(
  4671. animation,
  4672. parseInt( this.options.revert, 10 ) || 500,
  4673. function() {
  4674. that._clear( event );
  4675. }
  4676. );
  4677. } else {
  4678. this._clear( event, noPropagation );
  4679. }
  4680. return false;
  4681. },
  4682. cancel: function() {
  4683. if ( this.dragging ) {
  4684. this._mouseUp( { target: null } );
  4685. if ( this.options.helper === "original" ) {
  4686. this.currentItem.css( this._storedCSS );
  4687. this._removeClass( this.currentItem, "ui-sortable-helper" );
  4688. } else {
  4689. this.currentItem.show();
  4690. }
  4691. //Post deactivating events to containers
  4692. for ( var i = this.containers.length - 1; i >= 0; i-- ) {
  4693. this.containers[ i ]._trigger( "deactivate", null, this._uiHash( this ) );
  4694. if ( this.containers[ i ].containerCache.over ) {
  4695. this.containers[ i ]._trigger( "out", null, this._uiHash( this ) );
  4696. this.containers[ i ].containerCache.over = 0;
  4697. }
  4698. }
  4699. }
  4700. if ( this.placeholder ) {
  4701. //$(this.placeholder[0]).remove(); would have been the jQuery way - unfortunately,
  4702. // it unbinds ALL events from the original node!
  4703. if ( this.placeholder[ 0 ].parentNode ) {
  4704. this.placeholder[ 0 ].parentNode.removeChild( this.placeholder[ 0 ] );
  4705. }
  4706. if ( this.options.helper !== "original" && this.helper &&
  4707. this.helper[ 0 ].parentNode ) {
  4708. this.helper.remove();
  4709. }
  4710. $.extend( this, {
  4711. helper: null,
  4712. dragging: false,
  4713. reverting: false,
  4714. _noFinalSort: null
  4715. } );
  4716. if ( this.domPosition.prev ) {
  4717. $( this.domPosition.prev ).after( this.currentItem );
  4718. } else {
  4719. $( this.domPosition.parent ).prepend( this.currentItem );
  4720. }
  4721. }
  4722. return this;
  4723. },
  4724. serialize: function( o ) {
  4725. var items = this._getItemsAsjQuery( o && o.connected ),
  4726. str = [];
  4727. o = o || {};
  4728. $( items ).each( function() {
  4729. var res = ( $( o.item || this ).attr( o.attribute || "id" ) || "" )
  4730. .match( o.expression || ( /(.+)[\-=_](.+)/ ) );
  4731. if ( res ) {
  4732. str.push(
  4733. ( o.key || res[ 1 ] + "[]" ) +
  4734. "=" + ( o.key && o.expression ? res[ 1 ] : res[ 2 ] ) );
  4735. }
  4736. } );
  4737. if ( !str.length && o.key ) {
  4738. str.push( o.key + "=" );
  4739. }
  4740. return str.join( "&" );
  4741. },
  4742. toArray: function( o ) {
  4743. var items = this._getItemsAsjQuery( o && o.connected ),
  4744. ret = [];
  4745. o = o || {};
  4746. items.each( function() {
  4747. ret.push( $( o.item || this ).attr( o.attribute || "id" ) || "" );
  4748. } );
  4749. return ret;
  4750. },
  4751. /* Be careful with the following core functions */
  4752. _intersectsWith: function( item ) {
  4753. var x1 = this.positionAbs.left,
  4754. x2 = x1 + this.helperProportions.width,
  4755. y1 = this.positionAbs.top,
  4756. y2 = y1 + this.helperProportions.height,
  4757. l = item.left,
  4758. r = l + item.width,
  4759. t = item.top,
  4760. b = t + item.height,
  4761. dyClick = this.offset.click.top,
  4762. dxClick = this.offset.click.left,
  4763. isOverElementHeight = ( this.options.axis === "x" ) || ( ( y1 + dyClick ) > t &&
  4764. ( y1 + dyClick ) < b ),
  4765. isOverElementWidth = ( this.options.axis === "y" ) || ( ( x1 + dxClick ) > l &&
  4766. ( x1 + dxClick ) < r ),
  4767. isOverElement = isOverElementHeight && isOverElementWidth;
  4768. if ( this.options.tolerance === "pointer" ||
  4769. this.options.forcePointerForContainers ||
  4770. ( this.options.tolerance !== "pointer" &&
  4771. this.helperProportions[ this.floating ? "width" : "height" ] >
  4772. item[ this.floating ? "width" : "height" ] )
  4773. ) {
  4774. return isOverElement;
  4775. } else {
  4776. return ( l < x1 + ( this.helperProportions.width / 2 ) && // Right Half
  4777. x2 - ( this.helperProportions.width / 2 ) < r && // Left Half
  4778. t < y1 + ( this.helperProportions.height / 2 ) && // Bottom Half
  4779. y2 - ( this.helperProportions.height / 2 ) < b ); // Top Half
  4780. }
  4781. },
  4782. _intersectsWithPointer: function( item ) {
  4783. var verticalDirection, horizontalDirection,
  4784. isOverElementHeight = ( this.options.axis === "x" ) ||
  4785. this._isOverAxis(
  4786. this.positionAbs.top + this.offset.click.top, item.top, item.height ),
  4787. isOverElementWidth = ( this.options.axis === "y" ) ||
  4788. this._isOverAxis(
  4789. this.positionAbs.left + this.offset.click.left, item.left, item.width ),
  4790. isOverElement = isOverElementHeight && isOverElementWidth;
  4791. if ( !isOverElement ) {
  4792. return false;
  4793. }
  4794. verticalDirection = this._getDragVerticalDirection();
  4795. horizontalDirection = this._getDragHorizontalDirection();
  4796. return this.floating ?
  4797. ( ( horizontalDirection === "right" || verticalDirection === "down" ) ? 2 : 1 )
  4798. : ( verticalDirection && ( verticalDirection === "down" ? 2 : 1 ) );
  4799. },
  4800. _intersectsWithSides: function( item ) {
  4801. var isOverBottomHalf = this._isOverAxis( this.positionAbs.top +
  4802. this.offset.click.top, item.top + ( item.height / 2 ), item.height ),
  4803. isOverRightHalf = this._isOverAxis( this.positionAbs.left +
  4804. this.offset.click.left, item.left + ( item.width / 2 ), item.width ),
  4805. verticalDirection = this._getDragVerticalDirection(),
  4806. horizontalDirection = this._getDragHorizontalDirection();
  4807. if ( this.floating && horizontalDirection ) {
  4808. return ( ( horizontalDirection === "right" && isOverRightHalf ) ||
  4809. ( horizontalDirection === "left" && !isOverRightHalf ) );
  4810. } else {
  4811. return verticalDirection && ( ( verticalDirection === "down" && isOverBottomHalf ) ||
  4812. ( verticalDirection === "up" && !isOverBottomHalf ) );
  4813. }
  4814. },
  4815. _getDragVerticalDirection: function() {
  4816. var delta = this.positionAbs.top - this.lastPositionAbs.top;
  4817. return delta !== 0 && ( delta > 0 ? "down" : "up" );
  4818. },
  4819. _getDragHorizontalDirection: function() {
  4820. var delta = this.positionAbs.left - this.lastPositionAbs.left;
  4821. return delta !== 0 && ( delta > 0 ? "right" : "left" );
  4822. },
  4823. refresh: function( event ) {
  4824. this._refreshItems( event );
  4825. this._setHandleClassName();
  4826. this.refreshPositions();
  4827. return this;
  4828. },
  4829. _connectWith: function() {
  4830. var options = this.options;
  4831. return options.connectWith.constructor === String ?
  4832. [ options.connectWith ] :
  4833. options.connectWith;
  4834. },
  4835. _getItemsAsjQuery: function( connected ) {
  4836. var i, j, cur, inst,
  4837. items = [],
  4838. queries = [],
  4839. connectWith = this._connectWith();
  4840. if ( connectWith && connected ) {
  4841. for ( i = connectWith.length - 1; i >= 0; i-- ) {
  4842. cur = $( connectWith[ i ], this.document[ 0 ] );
  4843. for ( j = cur.length - 1; j >= 0; j-- ) {
  4844. inst = $.data( cur[ j ], this.widgetFullName );
  4845. if ( inst && inst !== this && !inst.options.disabled ) {
  4846. queries.push( [ $.isFunction( inst.options.items ) ?
  4847. inst.options.items.call( inst.element ) :
  4848. $( inst.options.items, inst.element )
  4849. .not( ".ui-sortable-helper" )
  4850. .not( ".ui-sortable-placeholder" ), inst ] );
  4851. }
  4852. }
  4853. }
  4854. }
  4855. queries.push( [ $.isFunction( this.options.items ) ?
  4856. this.options.items
  4857. .call( this.element, null, { options: this.options, item: this.currentItem } ) :
  4858. $( this.options.items, this.element )
  4859. .not( ".ui-sortable-helper" )
  4860. .not( ".ui-sortable-placeholder" ), this ] );
  4861. function addItems() {
  4862. items.push( this );
  4863. }
  4864. for ( i = queries.length - 1; i >= 0; i-- ) {
  4865. queries[ i ][ 0 ].each( addItems );
  4866. }
  4867. return $( items );
  4868. },
  4869. _removeCurrentsFromItems: function() {
  4870. var list = this.currentItem.find( ":data(" + this.widgetName + "-item)" );
  4871. this.items = $.grep( this.items, function( item ) {
  4872. for ( var j = 0; j < list.length; j++ ) {
  4873. if ( list[ j ] === item.item[ 0 ] ) {
  4874. return false;
  4875. }
  4876. }
  4877. return true;
  4878. } );
  4879. },
  4880. _refreshItems: function( event ) {
  4881. this.items = [];
  4882. this.containers = [ this ];
  4883. var i, j, cur, inst, targetData, _queries, item, queriesLength,
  4884. items = this.items,
  4885. queries = [ [ $.isFunction( this.options.items ) ?
  4886. this.options.items.call( this.element[ 0 ], event, { item: this.currentItem } ) :
  4887. $( this.options.items, this.element ), this ] ],
  4888. connectWith = this._connectWith();
  4889. //Shouldn't be run the first time through due to massive slow-down
  4890. if ( connectWith && this.ready ) {
  4891. for ( i = connectWith.length - 1; i >= 0; i-- ) {
  4892. cur = $( connectWith[ i ], this.document[ 0 ] );
  4893. for ( j = cur.length - 1; j >= 0; j-- ) {
  4894. inst = $.data( cur[ j ], this.widgetFullName );
  4895. if ( inst && inst !== this && !inst.options.disabled ) {
  4896. queries.push( [ $.isFunction( inst.options.items ) ?
  4897. inst.options.items
  4898. .call( inst.element[ 0 ], event, { item: this.currentItem } ) :
  4899. $( inst.options.items, inst.element ), inst ] );
  4900. this.containers.push( inst );
  4901. }
  4902. }
  4903. }
  4904. }
  4905. for ( i = queries.length - 1; i >= 0; i-- ) {
  4906. targetData = queries[ i ][ 1 ];
  4907. _queries = queries[ i ][ 0 ];
  4908. for ( j = 0, queriesLength = _queries.length; j < queriesLength; j++ ) {
  4909. item = $( _queries[ j ] );
  4910. // Data for target checking (mouse manager)
  4911. item.data( this.widgetName + "-item", targetData );
  4912. items.push( {
  4913. item: item,
  4914. instance: targetData,
  4915. width: 0, height: 0,
  4916. left: 0, top: 0
  4917. } );
  4918. }
  4919. }
  4920. },
  4921. refreshPositions: function( fast ) {
  4922. // Determine whether items are being displayed horizontally
  4923. this.floating = this.items.length ?
  4924. this.options.axis === "x" || this._isFloating( this.items[ 0 ].item ) :
  4925. false;
  4926. //This has to be redone because due to the item being moved out/into the offsetParent,
  4927. // the offsetParent's position will change
  4928. if ( this.offsetParent && this.helper ) {
  4929. this.offset.parent = this._getParentOffset();
  4930. }
  4931. var i, item, t, p;
  4932. for ( i = this.items.length - 1; i >= 0; i-- ) {
  4933. item = this.items[ i ];
  4934. //We ignore calculating positions of all connected containers when we're not over them
  4935. if ( item.instance !== this.currentContainer && this.currentContainer &&
  4936. item.item[ 0 ] !== this.currentItem[ 0 ] ) {
  4937. continue;
  4938. }
  4939. t = this.options.toleranceElement ?
  4940. $( this.options.toleranceElement, item.item ) :
  4941. item.item;
  4942. if ( !fast ) {
  4943. item.width = t.outerWidth();
  4944. item.height = t.outerHeight();
  4945. }
  4946. p = t.offset();
  4947. item.left = p.left;
  4948. item.top = p.top;
  4949. }
  4950. if ( this.options.custom && this.options.custom.refreshContainers ) {
  4951. this.options.custom.refreshContainers.call( this );
  4952. } else {
  4953. for ( i = this.containers.length - 1; i >= 0; i-- ) {
  4954. p = this.containers[ i ].element.offset();
  4955. this.containers[ i ].containerCache.left = p.left;
  4956. this.containers[ i ].containerCache.top = p.top;
  4957. this.containers[ i ].containerCache.width =
  4958. this.containers[ i ].element.outerWidth();
  4959. this.containers[ i ].containerCache.height =
  4960. this.containers[ i ].element.outerHeight();
  4961. }
  4962. }
  4963. return this;
  4964. },
  4965. _createPlaceholder: function( that ) {
  4966. that = that || this;
  4967. var className,
  4968. o = that.options;
  4969. if ( !o.placeholder || o.placeholder.constructor === String ) {
  4970. className = o.placeholder;
  4971. o.placeholder = {
  4972. element: function() {
  4973. var nodeName = that.currentItem[ 0 ].nodeName.toLowerCase(),
  4974. element = $( "<" + nodeName + ">", that.document[ 0 ] );
  4975. that._addClass( element, "ui-sortable-placeholder",
  4976. className || that.currentItem[ 0 ].className )
  4977. ._removeClass( element, "ui-sortable-helper" );
  4978. if ( nodeName === "tbody" ) {
  4979. that._createTrPlaceholder(
  4980. that.currentItem.find( "tr" ).eq( 0 ),
  4981. $( "<tr>", that.document[ 0 ] ).appendTo( element )
  4982. );
  4983. } else if ( nodeName === "tr" ) {
  4984. that._createTrPlaceholder( that.currentItem, element );
  4985. } else if ( nodeName === "img" ) {
  4986. element.attr( "src", that.currentItem.attr( "src" ) );
  4987. }
  4988. if ( !className ) {
  4989. element.css( "visibility", "hidden" );
  4990. }
  4991. return element;
  4992. },
  4993. update: function( container, p ) {
  4994. // 1. If a className is set as 'placeholder option, we don't force sizes -
  4995. // the class is responsible for that
  4996. // 2. The option 'forcePlaceholderSize can be enabled to force it even if a
  4997. // class name is specified
  4998. if ( className && !o.forcePlaceholderSize ) {
  4999. return;
  5000. }
  5001. //If the element doesn't have a actual height by itself (without styles coming
  5002. // from a stylesheet), it receives the inline height from the dragged item
  5003. if ( !p.height() ) {
  5004. p.height(
  5005. that.currentItem.innerHeight() -
  5006. parseInt( that.currentItem.css( "paddingTop" ) || 0, 10 ) -
  5007. parseInt( that.currentItem.css( "paddingBottom" ) || 0, 10 ) );
  5008. }
  5009. if ( !p.width() ) {
  5010. p.width(
  5011. that.currentItem.innerWidth() -
  5012. parseInt( that.currentItem.css( "paddingLeft" ) || 0, 10 ) -
  5013. parseInt( that.currentItem.css( "paddingRight" ) || 0, 10 ) );
  5014. }
  5015. }
  5016. };
  5017. }
  5018. //Create the placeholder
  5019. that.placeholder = $( o.placeholder.element.call( that.element, that.currentItem ) );
  5020. //Append it after the actual current item
  5021. that.currentItem.after( that.placeholder );
  5022. //Update the size of the placeholder (TODO: Logic to fuzzy, see line 316/317)
  5023. o.placeholder.update( that, that.placeholder );
  5024. },
  5025. _createTrPlaceholder: function( sourceTr, targetTr ) {
  5026. var that = this;
  5027. sourceTr.children().each( function() {
  5028. $( "<td>&#160;</td>", that.document[ 0 ] )
  5029. .attr( "colspan", $( this ).attr( "colspan" ) || 1 )
  5030. .appendTo( targetTr );
  5031. } );
  5032. },
  5033. _contactContainers: function( event ) {
  5034. var i, j, dist, itemWithLeastDistance, posProperty, sizeProperty, cur, nearBottom,
  5035. floating, axis,
  5036. innermostContainer = null,
  5037. innermostIndex = null;
  5038. // Get innermost container that intersects with item
  5039. for ( i = this.containers.length - 1; i >= 0; i-- ) {
  5040. // Never consider a container that's located within the item itself
  5041. if ( $.contains( this.currentItem[ 0 ], this.containers[ i ].element[ 0 ] ) ) {
  5042. continue;
  5043. }
  5044. if ( this._intersectsWith( this.containers[ i ].containerCache ) ) {
  5045. // If we've already found a container and it's more "inner" than this, then continue
  5046. if ( innermostContainer &&
  5047. $.contains(
  5048. this.containers[ i ].element[ 0 ],
  5049. innermostContainer.element[ 0 ] ) ) {
  5050. continue;
  5051. }
  5052. innermostContainer = this.containers[ i ];
  5053. innermostIndex = i;
  5054. } else {
  5055. // container doesn't intersect. trigger "out" event if necessary
  5056. if ( this.containers[ i ].containerCache.over ) {
  5057. this.containers[ i ]._trigger( "out", event, this._uiHash( this ) );
  5058. this.containers[ i ].containerCache.over = 0;
  5059. }
  5060. }
  5061. }
  5062. // If no intersecting containers found, return
  5063. if ( !innermostContainer ) {
  5064. return;
  5065. }
  5066. // Move the item into the container if it's not there already
  5067. if ( this.containers.length === 1 ) {
  5068. if ( !this.containers[ innermostIndex ].containerCache.over ) {
  5069. this.containers[ innermostIndex ]._trigger( "over", event, this._uiHash( this ) );
  5070. this.containers[ innermostIndex ].containerCache.over = 1;
  5071. }
  5072. } else {
  5073. // When entering a new container, we will find the item with the least distance and
  5074. // append our item near it
  5075. dist = 10000;
  5076. itemWithLeastDistance = null;
  5077. floating = innermostContainer.floating || this._isFloating( this.currentItem );
  5078. posProperty = floating ? "left" : "top";
  5079. sizeProperty = floating ? "width" : "height";
  5080. axis = floating ? "pageX" : "pageY";
  5081. for ( j = this.items.length - 1; j >= 0; j-- ) {
  5082. if ( !$.contains(
  5083. this.containers[ innermostIndex ].element[ 0 ], this.items[ j ].item[ 0 ] )
  5084. ) {
  5085. continue;
  5086. }
  5087. if ( this.items[ j ].item[ 0 ] === this.currentItem[ 0 ] ) {
  5088. continue;
  5089. }
  5090. cur = this.items[ j ].item.offset()[ posProperty ];
  5091. nearBottom = false;
  5092. if ( event[ axis ] - cur > this.items[ j ][ sizeProperty ] / 2 ) {
  5093. nearBottom = true;
  5094. }
  5095. if ( Math.abs( event[ axis ] - cur ) < dist ) {
  5096. dist = Math.abs( event[ axis ] - cur );
  5097. itemWithLeastDistance = this.items[ j ];
  5098. this.direction = nearBottom ? "up" : "down";
  5099. }
  5100. }
  5101. //Check if dropOnEmpty is enabled
  5102. if ( !itemWithLeastDistance && !this.options.dropOnEmpty ) {
  5103. return;
  5104. }
  5105. if ( this.currentContainer === this.containers[ innermostIndex ] ) {
  5106. if ( !this.currentContainer.containerCache.over ) {
  5107. this.containers[ innermostIndex ]._trigger( "over", event, this._uiHash() );
  5108. this.currentContainer.containerCache.over = 1;
  5109. }
  5110. return;
  5111. }
  5112. itemWithLeastDistance ?
  5113. this._rearrange( event, itemWithLeastDistance, null, true ) :
  5114. this._rearrange( event, null, this.containers[ innermostIndex ].element, true );
  5115. this._trigger( "change", event, this._uiHash() );
  5116. this.containers[ innermostIndex ]._trigger( "change", event, this._uiHash( this ) );
  5117. this.currentContainer = this.containers[ innermostIndex ];
  5118. //Update the placeholder
  5119. this.options.placeholder.update( this.currentContainer, this.placeholder );
  5120. this.containers[ innermostIndex ]._trigger( "over", event, this._uiHash( this ) );
  5121. this.containers[ innermostIndex ].containerCache.over = 1;
  5122. }
  5123. },
  5124. _createHelper: function( event ) {
  5125. var o = this.options,
  5126. helper = $.isFunction( o.helper ) ?
  5127. $( o.helper.apply( this.element[ 0 ], [ event, this.currentItem ] ) ) :
  5128. ( o.helper === "clone" ? this.currentItem.clone() : this.currentItem );
  5129. //Add the helper to the DOM if that didn't happen already
  5130. if ( !helper.parents( "body" ).length ) {
  5131. $( o.appendTo !== "parent" ?
  5132. o.appendTo :
  5133. this.currentItem[ 0 ].parentNode )[ 0 ].appendChild( helper[ 0 ] );
  5134. }
  5135. if ( helper[ 0 ] === this.currentItem[ 0 ] ) {
  5136. this._storedCSS = {
  5137. width: this.currentItem[ 0 ].style.width,
  5138. height: this.currentItem[ 0 ].style.height,
  5139. position: this.currentItem.css( "position" ),
  5140. top: this.currentItem.css( "top" ),
  5141. left: this.currentItem.css( "left" )
  5142. };
  5143. }
  5144. if ( !helper[ 0 ].style.width || o.forceHelperSize ) {
  5145. helper.width( this.currentItem.width() );
  5146. }
  5147. if ( !helper[ 0 ].style.height || o.forceHelperSize ) {
  5148. helper.height( this.currentItem.height() );
  5149. }
  5150. return helper;
  5151. },
  5152. _adjustOffsetFromHelper: function( obj ) {
  5153. if ( typeof obj === "string" ) {
  5154. obj = obj.split( " " );
  5155. }
  5156. if ( $.isArray( obj ) ) {
  5157. obj = { left: +obj[ 0 ], top: +obj[ 1 ] || 0 };
  5158. }
  5159. if ( "left" in obj ) {
  5160. this.offset.click.left = obj.left + this.margins.left;
  5161. }
  5162. if ( "right" in obj ) {
  5163. this.offset.click.left = this.helperProportions.width - obj.right + this.margins.left;
  5164. }
  5165. if ( "top" in obj ) {
  5166. this.offset.click.top = obj.top + this.margins.top;
  5167. }
  5168. if ( "bottom" in obj ) {
  5169. this.offset.click.top = this.helperProportions.height - obj.bottom + this.margins.top;
  5170. }
  5171. },
  5172. _getParentOffset: function() {
  5173. //Get the offsetParent and cache its position
  5174. this.offsetParent = this.helper.offsetParent();
  5175. var po = this.offsetParent.offset();
  5176. // This is a special case where we need to modify a offset calculated on start, since the
  5177. // following happened:
  5178. // 1. The position of the helper is absolute, so it's position is calculated based on the
  5179. // next positioned parent
  5180. // 2. The actual offset parent is a child of the scroll parent, and the scroll parent isn't
  5181. // the document, which means that the scroll is included in the initial calculation of the
  5182. // offset of the parent, and never recalculated upon drag
  5183. if ( this.cssPosition === "absolute" && this.scrollParent[ 0 ] !== this.document[ 0 ] &&
  5184. $.contains( this.scrollParent[ 0 ], this.offsetParent[ 0 ] ) ) {
  5185. po.left += this.scrollParent.scrollLeft();
  5186. po.top += this.scrollParent.scrollTop();
  5187. }
  5188. // This needs to be actually done for all browsers, since pageX/pageY includes this
  5189. // information with an ugly IE fix
  5190. if ( this.offsetParent[ 0 ] === this.document[ 0 ].body ||
  5191. ( this.offsetParent[ 0 ].tagName &&
  5192. this.offsetParent[ 0 ].tagName.toLowerCase() === "html" && $.ui.ie ) ) {
  5193. po = { top: 0, left: 0 };
  5194. }
  5195. return {
  5196. top: po.top + ( parseInt( this.offsetParent.css( "borderTopWidth" ), 10 ) || 0 ),
  5197. left: po.left + ( parseInt( this.offsetParent.css( "borderLeftWidth" ), 10 ) || 0 )
  5198. };
  5199. },
  5200. _getRelativeOffset: function() {
  5201. if ( this.cssPosition === "relative" ) {
  5202. var p = this.currentItem.position();
  5203. return {
  5204. top: p.top - ( parseInt( this.helper.css( "top" ), 10 ) || 0 ) +
  5205. this.scrollParent.scrollTop(),
  5206. left: p.left - ( parseInt( this.helper.css( "left" ), 10 ) || 0 ) +
  5207. this.scrollParent.scrollLeft()
  5208. };
  5209. } else {
  5210. return { top: 0, left: 0 };
  5211. }
  5212. },
  5213. _cacheMargins: function() {
  5214. this.margins = {
  5215. left: ( parseInt( this.currentItem.css( "marginLeft" ), 10 ) || 0 ),
  5216. top: ( parseInt( this.currentItem.css( "marginTop" ), 10 ) || 0 )
  5217. };
  5218. },
  5219. _cacheHelperProportions: function() {
  5220. this.helperProportions = {
  5221. width: this.helper.outerWidth(),
  5222. height: this.helper.outerHeight()
  5223. };
  5224. },
  5225. _setContainment: function() {
  5226. var ce, co, over,
  5227. o = this.options;
  5228. if ( o.containment === "parent" ) {
  5229. o.containment = this.helper[ 0 ].parentNode;
  5230. }
  5231. if ( o.containment === "document" || o.containment === "window" ) {
  5232. this.containment = [
  5233. 0 - this.offset.relative.left - this.offset.parent.left,
  5234. 0 - this.offset.relative.top - this.offset.parent.top,
  5235. o.containment === "document" ?
  5236. this.document.width() :
  5237. this.window.width() - this.helperProportions.width - this.margins.left,
  5238. ( o.containment === "document" ?
  5239. ( this.document.height() || document.body.parentNode.scrollHeight ) :
  5240. this.window.height() || this.document[ 0 ].body.parentNode.scrollHeight
  5241. ) - this.helperProportions.height - this.margins.top
  5242. ];
  5243. }
  5244. if ( !( /^(document|window|parent)$/ ).test( o.containment ) ) {
  5245. ce = $( o.containment )[ 0 ];
  5246. co = $( o.containment ).offset();
  5247. over = ( $( ce ).css( "overflow" ) !== "hidden" );
  5248. this.containment = [
  5249. co.left + ( parseInt( $( ce ).css( "borderLeftWidth" ), 10 ) || 0 ) +
  5250. ( parseInt( $( ce ).css( "paddingLeft" ), 10 ) || 0 ) - this.margins.left,
  5251. co.top + ( parseInt( $( ce ).css( "borderTopWidth" ), 10 ) || 0 ) +
  5252. ( parseInt( $( ce ).css( "paddingTop" ), 10 ) || 0 ) - this.margins.top,
  5253. co.left + ( over ? Math.max( ce.scrollWidth, ce.offsetWidth ) : ce.offsetWidth ) -
  5254. ( parseInt( $( ce ).css( "borderLeftWidth" ), 10 ) || 0 ) -
  5255. ( parseInt( $( ce ).css( "paddingRight" ), 10 ) || 0 ) -
  5256. this.helperProportions.width - this.margins.left,
  5257. co.top + ( over ? Math.max( ce.scrollHeight, ce.offsetHeight ) : ce.offsetHeight ) -
  5258. ( parseInt( $( ce ).css( "borderTopWidth" ), 10 ) || 0 ) -
  5259. ( parseInt( $( ce ).css( "paddingBottom" ), 10 ) || 0 ) -
  5260. this.helperProportions.height - this.margins.top
  5261. ];
  5262. }
  5263. },
  5264. _convertPositionTo: function( d, pos ) {
  5265. if ( !pos ) {
  5266. pos = this.position;
  5267. }
  5268. var mod = d === "absolute" ? 1 : -1,
  5269. scroll = this.cssPosition === "absolute" &&
  5270. !( this.scrollParent[ 0 ] !== this.document[ 0 ] &&
  5271. $.contains( this.scrollParent[ 0 ], this.offsetParent[ 0 ] ) ) ?
  5272. this.offsetParent :
  5273. this.scrollParent,
  5274. scrollIsRootNode = ( /(html|body)/i ).test( scroll[ 0 ].tagName );
  5275. return {
  5276. top: (
  5277. // The absolute mouse position
  5278. pos.top +
  5279. // Only for relative positioned nodes: Relative offset from element to offset parent
  5280. this.offset.relative.top * mod +
  5281. // The offsetParent's offset without borders (offset + border)
  5282. this.offset.parent.top * mod -
  5283. ( ( this.cssPosition === "fixed" ?
  5284. -this.scrollParent.scrollTop() :
  5285. ( scrollIsRootNode ? 0 : scroll.scrollTop() ) ) * mod )
  5286. ),
  5287. left: (
  5288. // The absolute mouse position
  5289. pos.left +
  5290. // Only for relative positioned nodes: Relative offset from element to offset parent
  5291. this.offset.relative.left * mod +
  5292. // The offsetParent's offset without borders (offset + border)
  5293. this.offset.parent.left * mod -
  5294. ( ( this.cssPosition === "fixed" ?
  5295. -this.scrollParent.scrollLeft() : scrollIsRootNode ? 0 :
  5296. scroll.scrollLeft() ) * mod )
  5297. )
  5298. };
  5299. },
  5300. _generatePosition: function( event ) {
  5301. var top, left,
  5302. o = this.options,
  5303. pageX = event.pageX,
  5304. pageY = event.pageY,
  5305. scroll = this.cssPosition === "absolute" &&
  5306. !( this.scrollParent[ 0 ] !== this.document[ 0 ] &&
  5307. $.contains( this.scrollParent[ 0 ], this.offsetParent[ 0 ] ) ) ?
  5308. this.offsetParent :
  5309. this.scrollParent,
  5310. scrollIsRootNode = ( /(html|body)/i ).test( scroll[ 0 ].tagName );
  5311. // This is another very weird special case that only happens for relative elements:
  5312. // 1. If the css position is relative
  5313. // 2. and the scroll parent is the document or similar to the offset parent
  5314. // we have to refresh the relative offset during the scroll so there are no jumps
  5315. if ( this.cssPosition === "relative" && !( this.scrollParent[ 0 ] !== this.document[ 0 ] &&
  5316. this.scrollParent[ 0 ] !== this.offsetParent[ 0 ] ) ) {
  5317. this.offset.relative = this._getRelativeOffset();
  5318. }
  5319. /*
  5320. * - Position constraining -
  5321. * Constrain the position to a mix of grid, containment.
  5322. */
  5323. if ( this.originalPosition ) { //If we are not dragging yet, we won't check for options
  5324. if ( this.containment ) {
  5325. if ( event.pageX - this.offset.click.left < this.containment[ 0 ] ) {
  5326. pageX = this.containment[ 0 ] + this.offset.click.left;
  5327. }
  5328. if ( event.pageY - this.offset.click.top < this.containment[ 1 ] ) {
  5329. pageY = this.containment[ 1 ] + this.offset.click.top;
  5330. }
  5331. if ( event.pageX - this.offset.click.left > this.containment[ 2 ] ) {
  5332. pageX = this.containment[ 2 ] + this.offset.click.left;
  5333. }
  5334. if ( event.pageY - this.offset.click.top > this.containment[ 3 ] ) {
  5335. pageY = this.containment[ 3 ] + this.offset.click.top;
  5336. }
  5337. }
  5338. if ( o.grid ) {
  5339. top = this.originalPageY + Math.round( ( pageY - this.originalPageY ) /
  5340. o.grid[ 1 ] ) * o.grid[ 1 ];
  5341. pageY = this.containment ?
  5342. ( ( top - this.offset.click.top >= this.containment[ 1 ] &&
  5343. top - this.offset.click.top <= this.containment[ 3 ] ) ?
  5344. top :
  5345. ( ( top - this.offset.click.top >= this.containment[ 1 ] ) ?
  5346. top - o.grid[ 1 ] : top + o.grid[ 1 ] ) ) :
  5347. top;
  5348. left = this.originalPageX + Math.round( ( pageX - this.originalPageX ) /
  5349. o.grid[ 0 ] ) * o.grid[ 0 ];
  5350. pageX = this.containment ?
  5351. ( ( left - this.offset.click.left >= this.containment[ 0 ] &&
  5352. left - this.offset.click.left <= this.containment[ 2 ] ) ?
  5353. left :
  5354. ( ( left - this.offset.click.left >= this.containment[ 0 ] ) ?
  5355. left - o.grid[ 0 ] : left + o.grid[ 0 ] ) ) :
  5356. left;
  5357. }
  5358. }
  5359. return {
  5360. top: (
  5361. // The absolute mouse position
  5362. pageY -
  5363. // Click offset (relative to the element)
  5364. this.offset.click.top -
  5365. // Only for relative positioned nodes: Relative offset from element to offset parent
  5366. this.offset.relative.top -
  5367. // The offsetParent's offset without borders (offset + border)
  5368. this.offset.parent.top +
  5369. ( ( this.cssPosition === "fixed" ?
  5370. -this.scrollParent.scrollTop() :
  5371. ( scrollIsRootNode ? 0 : scroll.scrollTop() ) ) )
  5372. ),
  5373. left: (
  5374. // The absolute mouse position
  5375. pageX -
  5376. // Click offset (relative to the element)
  5377. this.offset.click.left -
  5378. // Only for relative positioned nodes: Relative offset from element to offset parent
  5379. this.offset.relative.left -
  5380. // The offsetParent's offset without borders (offset + border)
  5381. this.offset.parent.left +
  5382. ( ( this.cssPosition === "fixed" ?
  5383. -this.scrollParent.scrollLeft() :
  5384. scrollIsRootNode ? 0 : scroll.scrollLeft() ) )
  5385. )
  5386. };
  5387. },
  5388. _rearrange: function( event, i, a, hardRefresh ) {
  5389. a ? a[ 0 ].appendChild( this.placeholder[ 0 ] ) :
  5390. i.item[ 0 ].parentNode.insertBefore( this.placeholder[ 0 ],
  5391. ( this.direction === "down" ? i.item[ 0 ] : i.item[ 0 ].nextSibling ) );
  5392. //Various things done here to improve the performance:
  5393. // 1. we create a setTimeout, that calls refreshPositions
  5394. // 2. on the instance, we have a counter variable, that get's higher after every append
  5395. // 3. on the local scope, we copy the counter variable, and check in the timeout,
  5396. // if it's still the same
  5397. // 4. this lets only the last addition to the timeout stack through
  5398. this.counter = this.counter ? ++this.counter : 1;
  5399. var counter = this.counter;
  5400. this._delay( function() {
  5401. if ( counter === this.counter ) {
  5402. //Precompute after each DOM insertion, NOT on mousemove
  5403. this.refreshPositions( !hardRefresh );
  5404. }
  5405. } );
  5406. },
  5407. _clear: function( event, noPropagation ) {
  5408. this.reverting = false;
  5409. // We delay all events that have to be triggered to after the point where the placeholder
  5410. // has been removed and everything else normalized again
  5411. var i,
  5412. delayedTriggers = [];
  5413. // We first have to update the dom position of the actual currentItem
  5414. // Note: don't do it if the current item is already removed (by a user), or it gets
  5415. // reappended (see #4088)
  5416. if ( !this._noFinalSort && this.currentItem.parent().length ) {
  5417. this.placeholder.before( this.currentItem );
  5418. }
  5419. this._noFinalSort = null;
  5420. if ( this.helper[ 0 ] === this.currentItem[ 0 ] ) {
  5421. for ( i in this._storedCSS ) {
  5422. if ( this._storedCSS[ i ] === "auto" || this._storedCSS[ i ] === "static" ) {
  5423. this._storedCSS[ i ] = "";
  5424. }
  5425. }
  5426. this.currentItem.css( this._storedCSS );
  5427. this._removeClass( this.currentItem, "ui-sortable-helper" );
  5428. } else {
  5429. this.currentItem.show();
  5430. }
  5431. if ( this.fromOutside && !noPropagation ) {
  5432. delayedTriggers.push( function( event ) {
  5433. this._trigger( "receive", event, this._uiHash( this.fromOutside ) );
  5434. } );
  5435. }
  5436. if ( ( this.fromOutside ||
  5437. this.domPosition.prev !==
  5438. this.currentItem.prev().not( ".ui-sortable-helper" )[ 0 ] ||
  5439. this.domPosition.parent !== this.currentItem.parent()[ 0 ] ) && !noPropagation ) {
  5440. // Trigger update callback if the DOM position has changed
  5441. delayedTriggers.push( function( event ) {
  5442. this._trigger( "update", event, this._uiHash() );
  5443. } );
  5444. }
  5445. // Check if the items Container has Changed and trigger appropriate
  5446. // events.
  5447. if ( this !== this.currentContainer ) {
  5448. if ( !noPropagation ) {
  5449. delayedTriggers.push( function( event ) {
  5450. this._trigger( "remove", event, this._uiHash() );
  5451. } );
  5452. delayedTriggers.push( ( function( c ) {
  5453. return function( event ) {
  5454. c._trigger( "receive", event, this._uiHash( this ) );
  5455. };
  5456. } ).call( this, this.currentContainer ) );
  5457. delayedTriggers.push( ( function( c ) {
  5458. return function( event ) {
  5459. c._trigger( "update", event, this._uiHash( this ) );
  5460. };
  5461. } ).call( this, this.currentContainer ) );
  5462. }
  5463. }
  5464. //Post events to containers
  5465. function delayEvent( type, instance, container ) {
  5466. return function( event ) {
  5467. container._trigger( type, event, instance._uiHash( instance ) );
  5468. };
  5469. }
  5470. for ( i = this.containers.length - 1; i >= 0; i-- ) {
  5471. if ( !noPropagation ) {
  5472. delayedTriggers.push( delayEvent( "deactivate", this, this.containers[ i ] ) );
  5473. }
  5474. if ( this.containers[ i ].containerCache.over ) {
  5475. delayedTriggers.push( delayEvent( "out", this, this.containers[ i ] ) );
  5476. this.containers[ i ].containerCache.over = 0;
  5477. }
  5478. }
  5479. //Do what was originally in plugins
  5480. if ( this.storedCursor ) {
  5481. this.document.find( "body" ).css( "cursor", this.storedCursor );
  5482. this.storedStylesheet.remove();
  5483. }
  5484. if ( this._storedOpacity ) {
  5485. this.helper.css( "opacity", this._storedOpacity );
  5486. }
  5487. if ( this._storedZIndex ) {
  5488. this.helper.css( "zIndex", this._storedZIndex === "auto" ? "" : this._storedZIndex );
  5489. }
  5490. this.dragging = false;
  5491. if ( !noPropagation ) {
  5492. this._trigger( "beforeStop", event, this._uiHash() );
  5493. }
  5494. //$(this.placeholder[0]).remove(); would have been the jQuery way - unfortunately,
  5495. // it unbinds ALL events from the original node!
  5496. this.placeholder[ 0 ].parentNode.removeChild( this.placeholder[ 0 ] );
  5497. if ( !this.cancelHelperRemoval ) {
  5498. if ( this.helper[ 0 ] !== this.currentItem[ 0 ] ) {
  5499. this.helper.remove();
  5500. }
  5501. this.helper = null;
  5502. }
  5503. if ( !noPropagation ) {
  5504. for ( i = 0; i < delayedTriggers.length; i++ ) {
  5505. // Trigger all delayed events
  5506. delayedTriggers[ i ].call( this, event );
  5507. }
  5508. this._trigger( "stop", event, this._uiHash() );
  5509. }
  5510. this.fromOutside = false;
  5511. return !this.cancelHelperRemoval;
  5512. },
  5513. _trigger: function() {
  5514. if ( $.Widget.prototype._trigger.apply( this, arguments ) === false ) {
  5515. this.cancel();
  5516. }
  5517. },
  5518. _uiHash: function( _inst ) {
  5519. var inst = _inst || this;
  5520. return {
  5521. helper: inst.helper,
  5522. placeholder: inst.placeholder || $( [] ),
  5523. position: inst.position,
  5524. originalPosition: inst.originalPosition,
  5525. offset: inst.positionAbs,
  5526. item: inst.currentItem,
  5527. sender: _inst ? _inst.element : null
  5528. };
  5529. }
  5530. } );
  5531. /*!
  5532. * jQuery UI Accordion 1.12.0
  5533. * http://jqueryui.com
  5534. *
  5535. * Copyright jQuery Foundation and other contributors
  5536. * Released under the MIT license.
  5537. * http://jquery.org/license
  5538. */
  5539. //>>label: Accordion
  5540. //>>group: Widgets
  5541. // jscs:disable maximumLineLength
  5542. //>>description: Displays collapsible content panels for presenting information in a limited amount of space.
  5543. // jscs:enable maximumLineLength
  5544. //>>docs: http://api.jqueryui.com/accordion/
  5545. //>>demos: http://jqueryui.com/accordion/
  5546. //>>css.structure: ../../themes/base/core.css
  5547. //>>css.structure: ../../themes/base/accordion.css
  5548. //>>css.theme: ../../themes/base/theme.css
  5549. var widgetsAccordion = $.widget( "ui.accordion", {
  5550. version: "1.12.0",
  5551. options: {
  5552. active: 0,
  5553. animate: {},
  5554. classes: {
  5555. "ui-accordion-header": "ui-corner-top",
  5556. "ui-accordion-header-collapsed": "ui-corner-all",
  5557. "ui-accordion-content": "ui-corner-bottom"
  5558. },
  5559. collapsible: false,
  5560. event: "click",
  5561. header: "> li > :first-child, > :not(li):even",
  5562. heightStyle: "auto",
  5563. icons: {
  5564. activeHeader: "ui-icon-triangle-1-s",
  5565. header: "ui-icon-triangle-1-e"
  5566. },
  5567. // Callbacks
  5568. activate: null,
  5569. beforeActivate: null
  5570. },
  5571. hideProps: {
  5572. borderTopWidth: "hide",
  5573. borderBottomWidth: "hide",
  5574. paddingTop: "hide",
  5575. paddingBottom: "hide",
  5576. height: "hide"
  5577. },
  5578. showProps: {
  5579. borderTopWidth: "show",
  5580. borderBottomWidth: "show",
  5581. paddingTop: "show",
  5582. paddingBottom: "show",
  5583. height: "show"
  5584. },
  5585. _create: function() {
  5586. var options = this.options;
  5587. this.prevShow = this.prevHide = $();
  5588. this._addClass( "ui-accordion", "ui-widget ui-helper-reset" );
  5589. this.element.attr( "role", "tablist" );
  5590. // Don't allow collapsible: false and active: false / null
  5591. if ( !options.collapsible && ( options.active === false || options.active == null ) ) {
  5592. options.active = 0;
  5593. }
  5594. this._processPanels();
  5595. // handle negative values
  5596. if ( options.active < 0 ) {
  5597. options.active += this.headers.length;
  5598. }
  5599. this._refresh();
  5600. },
  5601. _getCreateEventData: function() {
  5602. return {
  5603. header: this.active,
  5604. panel: !this.active.length ? $() : this.active.next()
  5605. };
  5606. },
  5607. _createIcons: function() {
  5608. var icon, children,
  5609. icons = this.options.icons;
  5610. if ( icons ) {
  5611. icon = $( "<span>" );
  5612. this._addClass( icon, "ui-accordion-header-icon", "ui-icon " + icons.header );
  5613. icon.prependTo( this.headers );
  5614. children = this.active.children( ".ui-accordion-header-icon" );
  5615. this._removeClass( children, icons.header )
  5616. ._addClass( children, null, icons.activeHeader )
  5617. ._addClass( this.headers, "ui-accordion-icons" );
  5618. }
  5619. },
  5620. _destroyIcons: function() {
  5621. this._removeClass( this.headers, "ui-accordion-icons" );
  5622. this.headers.children( ".ui-accordion-header-icon" ).remove();
  5623. },
  5624. _destroy: function() {
  5625. var contents;
  5626. // Clean up main element
  5627. this.element.removeAttr( "role" );
  5628. // Clean up headers
  5629. this.headers
  5630. .removeAttr( "role aria-expanded aria-selected aria-controls tabIndex" )
  5631. .removeUniqueId();
  5632. this._destroyIcons();
  5633. // Clean up content panels
  5634. contents = this.headers.next()
  5635. .css( "display", "" )
  5636. .removeAttr( "role aria-hidden aria-labelledby" )
  5637. .removeUniqueId();
  5638. if ( this.options.heightStyle !== "content" ) {
  5639. contents.css( "height", "" );
  5640. }
  5641. },
  5642. _setOption: function( key, value ) {
  5643. if ( key === "active" ) {
  5644. // _activate() will handle invalid values and update this.options
  5645. this._activate( value );
  5646. return;
  5647. }
  5648. if ( key === "event" ) {
  5649. if ( this.options.event ) {
  5650. this._off( this.headers, this.options.event );
  5651. }
  5652. this._setupEvents( value );
  5653. }
  5654. this._super( key, value );
  5655. // Setting collapsible: false while collapsed; open first panel
  5656. if ( key === "collapsible" && !value && this.options.active === false ) {
  5657. this._activate( 0 );
  5658. }
  5659. if ( key === "icons" ) {
  5660. this._destroyIcons();
  5661. if ( value ) {
  5662. this._createIcons();
  5663. }
  5664. }
  5665. },
  5666. _setOptionDisabled: function( value ) {
  5667. this._super( value );
  5668. this.element.attr( "aria-disabled", value );
  5669. // Support: IE8 Only
  5670. // #5332 / #6059 - opacity doesn't cascade to positioned elements in IE
  5671. // so we need to add the disabled class to the headers and panels
  5672. this._toggleClass( null, "ui-state-disabled", !!value );
  5673. this._toggleClass( this.headers.add( this.headers.next() ), null, "ui-state-disabled",
  5674. !!value );
  5675. },
  5676. _keydown: function( event ) {
  5677. if ( event.altKey || event.ctrlKey ) {
  5678. return;
  5679. }
  5680. var keyCode = $.ui.keyCode,
  5681. length = this.headers.length,
  5682. currentIndex = this.headers.index( event.target ),
  5683. toFocus = false;
  5684. switch ( event.keyCode ) {
  5685. case keyCode.RIGHT:
  5686. case keyCode.DOWN:
  5687. toFocus = this.headers[ ( currentIndex + 1 ) % length ];
  5688. break;
  5689. case keyCode.LEFT:
  5690. case keyCode.UP:
  5691. toFocus = this.headers[ ( currentIndex - 1 + length ) % length ];
  5692. break;
  5693. case keyCode.SPACE:
  5694. case keyCode.ENTER:
  5695. this._eventHandler( event );
  5696. break;
  5697. case keyCode.HOME:
  5698. toFocus = this.headers[ 0 ];
  5699. break;
  5700. case keyCode.END:
  5701. toFocus = this.headers[ length - 1 ];
  5702. break;
  5703. }
  5704. if ( toFocus ) {
  5705. $( event.target ).attr( "tabIndex", -1 );
  5706. $( toFocus ).attr( "tabIndex", 0 );
  5707. $( toFocus ).trigger( "focus" );
  5708. event.preventDefault();
  5709. }
  5710. },
  5711. _panelKeyDown: function( event ) {
  5712. if ( event.keyCode === $.ui.keyCode.UP && event.ctrlKey ) {
  5713. $( event.currentTarget ).prev().trigger( "focus" );
  5714. }
  5715. },
  5716. refresh: function() {
  5717. var options = this.options;
  5718. this._processPanels();
  5719. // Was collapsed or no panel
  5720. if ( ( options.active === false && options.collapsible === true ) ||
  5721. !this.headers.length ) {
  5722. options.active = false;
  5723. this.active = $();
  5724. // active false only when collapsible is true
  5725. } else if ( options.active === false ) {
  5726. this._activate( 0 );
  5727. // was active, but active panel is gone
  5728. } else if ( this.active.length && !$.contains( this.element[ 0 ], this.active[ 0 ] ) ) {
  5729. // all remaining panel are disabled
  5730. if ( this.headers.length === this.headers.find( ".ui-state-disabled" ).length ) {
  5731. options.active = false;
  5732. this.active = $();
  5733. // activate previous panel
  5734. } else {
  5735. this._activate( Math.max( 0, options.active - 1 ) );
  5736. }
  5737. // was active, active panel still exists
  5738. } else {
  5739. // make sure active index is correct
  5740. options.active = this.headers.index( this.active );
  5741. }
  5742. this._destroyIcons();
  5743. this._refresh();
  5744. },
  5745. _processPanels: function() {
  5746. var prevHeaders = this.headers,
  5747. prevPanels = this.panels;
  5748. this.headers = this.element.find( this.options.header );
  5749. this._addClass( this.headers, "ui-accordion-header ui-accordion-header-collapsed",
  5750. "ui-state-default" );
  5751. this.panels = this.headers.next().filter( ":not(.ui-accordion-content-active)" ).hide();
  5752. this._addClass( this.panels, "ui-accordion-content", "ui-helper-reset ui-widget-content" );
  5753. // Avoid memory leaks (#10056)
  5754. if ( prevPanels ) {
  5755. this._off( prevHeaders.not( this.headers ) );
  5756. this._off( prevPanels.not( this.panels ) );
  5757. }
  5758. },
  5759. _refresh: function() {
  5760. var maxHeight,
  5761. options = this.options,
  5762. heightStyle = options.heightStyle,
  5763. parent = this.element.parent();
  5764. this.active = this._findActive( options.active );
  5765. this._addClass( this.active, "ui-accordion-header-active", "ui-state-active" )
  5766. ._removeClass( this.active, "ui-accordion-header-collapsed" );
  5767. this._addClass( this.active.next(), "ui-accordion-content-active" );
  5768. this.active.next().show();
  5769. this.headers
  5770. .attr( "role", "tab" )
  5771. .each( function() {
  5772. var header = $( this ),
  5773. headerId = header.uniqueId().attr( "id" ),
  5774. panel = header.next(),
  5775. panelId = panel.uniqueId().attr( "id" );
  5776. header.attr( "aria-controls", panelId );
  5777. panel.attr( "aria-labelledby", headerId );
  5778. } )
  5779. .next()
  5780. .attr( "role", "tabpanel" );
  5781. this.headers
  5782. .not( this.active )
  5783. .attr( {
  5784. "aria-selected": "false",
  5785. "aria-expanded": "false",
  5786. tabIndex: -1
  5787. } )
  5788. .next()
  5789. .attr( {
  5790. "aria-hidden": "true"
  5791. } )
  5792. .hide();
  5793. // Make sure at least one header is in the tab order
  5794. if ( !this.active.length ) {
  5795. this.headers.eq( 0 ).attr( "tabIndex", 0 );
  5796. } else {
  5797. this.active.attr( {
  5798. "aria-selected": "true",
  5799. "aria-expanded": "true",
  5800. tabIndex: 0
  5801. } )
  5802. .next()
  5803. .attr( {
  5804. "aria-hidden": "false"
  5805. } );
  5806. }
  5807. this._createIcons();
  5808. this._setupEvents( options.event );
  5809. if ( heightStyle === "fill" ) {
  5810. maxHeight = parent.height();
  5811. this.element.siblings( ":visible" ).each( function() {
  5812. var elem = $( this ),
  5813. position = elem.css( "position" );
  5814. if ( position === "absolute" || position === "fixed" ) {
  5815. return;
  5816. }
  5817. maxHeight -= elem.outerHeight( true );
  5818. } );
  5819. this.headers.each( function() {
  5820. maxHeight -= $( this ).outerHeight( true );
  5821. } );
  5822. this.headers.next()
  5823. .each( function() {
  5824. $( this ).height( Math.max( 0, maxHeight -
  5825. $( this ).innerHeight() + $( this ).height() ) );
  5826. } )
  5827. .css( "overflow", "auto" );
  5828. } else if ( heightStyle === "auto" ) {
  5829. maxHeight = 0;
  5830. this.headers.next()
  5831. .each( function() {
  5832. var isVisible = $( this ).is( ":visible" );
  5833. if ( !isVisible ) {
  5834. $( this ).show();
  5835. }
  5836. maxHeight = Math.max( maxHeight, $( this ).css( "height", "" ).height() );
  5837. if ( !isVisible ) {
  5838. $( this ).hide();
  5839. }
  5840. } )
  5841. .height( maxHeight );
  5842. }
  5843. },
  5844. _activate: function( index ) {
  5845. var active = this._findActive( index )[ 0 ];
  5846. // Trying to activate the already active panel
  5847. if ( active === this.active[ 0 ] ) {
  5848. return;
  5849. }
  5850. // Trying to collapse, simulate a click on the currently active header
  5851. active = active || this.active[ 0 ];
  5852. this._eventHandler( {
  5853. target: active,
  5854. currentTarget: active,
  5855. preventDefault: $.noop
  5856. } );
  5857. },
  5858. _findActive: function( selector ) {
  5859. return typeof selector === "number" ? this.headers.eq( selector ) : $();
  5860. },
  5861. _setupEvents: function( event ) {
  5862. var events = {
  5863. keydown: "_keydown"
  5864. };
  5865. if ( event ) {
  5866. $.each( event.split( " " ), function( index, eventName ) {
  5867. events[ eventName ] = "_eventHandler";
  5868. } );
  5869. }
  5870. this._off( this.headers.add( this.headers.next() ) );
  5871. this._on( this.headers, events );
  5872. this._on( this.headers.next(), { keydown: "_panelKeyDown" } );
  5873. this._hoverable( this.headers );
  5874. this._focusable( this.headers );
  5875. },
  5876. _eventHandler: function( event ) {
  5877. var activeChildren, clickedChildren,
  5878. options = this.options,
  5879. active = this.active,
  5880. clicked = $( event.currentTarget ),
  5881. clickedIsActive = clicked[ 0 ] === active[ 0 ],
  5882. collapsing = clickedIsActive && options.collapsible,
  5883. toShow = collapsing ? $() : clicked.next(),
  5884. toHide = active.next(),
  5885. eventData = {
  5886. oldHeader: active,
  5887. oldPanel: toHide,
  5888. newHeader: collapsing ? $() : clicked,
  5889. newPanel: toShow
  5890. };
  5891. event.preventDefault();
  5892. if (
  5893. // click on active header, but not collapsible
  5894. ( clickedIsActive && !options.collapsible ) ||
  5895. // allow canceling activation
  5896. ( this._trigger( "beforeActivate", event, eventData ) === false ) ) {
  5897. return;
  5898. }
  5899. options.active = collapsing ? false : this.headers.index( clicked );
  5900. // When the call to ._toggle() comes after the class changes
  5901. // it causes a very odd bug in IE 8 (see #6720)
  5902. this.active = clickedIsActive ? $() : clicked;
  5903. this._toggle( eventData );
  5904. // Switch classes
  5905. // corner classes on the previously active header stay after the animation
  5906. this._removeClass( active, "ui-accordion-header-active", "ui-state-active" );
  5907. if ( options.icons ) {
  5908. activeChildren = active.children( ".ui-accordion-header-icon" );
  5909. this._removeClass( activeChildren, null, options.icons.activeHeader )
  5910. ._addClass( activeChildren, null, options.icons.header );
  5911. }
  5912. if ( !clickedIsActive ) {
  5913. this._removeClass( clicked, "ui-accordion-header-collapsed" )
  5914. ._addClass( clicked, "ui-accordion-header-active", "ui-state-active" );
  5915. if ( options.icons ) {
  5916. clickedChildren = clicked.children( ".ui-accordion-header-icon" );
  5917. this._removeClass( clickedChildren, null, options.icons.header )
  5918. ._addClass( clickedChildren, null, options.icons.activeHeader );
  5919. }
  5920. this._addClass( clicked.next(), "ui-accordion-content-active" );
  5921. }
  5922. },
  5923. _toggle: function( data ) {
  5924. var toShow = data.newPanel,
  5925. toHide = this.prevShow.length ? this.prevShow : data.oldPanel;
  5926. // Handle activating a panel during the animation for another activation
  5927. this.prevShow.add( this.prevHide ).stop( true, true );
  5928. this.prevShow = toShow;
  5929. this.prevHide = toHide;
  5930. if ( this.options.animate ) {
  5931. this._animate( toShow, toHide, data );
  5932. } else {
  5933. toHide.hide();
  5934. toShow.show();
  5935. this._toggleComplete( data );
  5936. }
  5937. toHide.attr( {
  5938. "aria-hidden": "true"
  5939. } );
  5940. toHide.prev().attr( {
  5941. "aria-selected": "false",
  5942. "aria-expanded": "false"
  5943. } );
  5944. // if we're switching panels, remove the old header from the tab order
  5945. // if we're opening from collapsed state, remove the previous header from the tab order
  5946. // if we're collapsing, then keep the collapsing header in the tab order
  5947. if ( toShow.length && toHide.length ) {
  5948. toHide.prev().attr( {
  5949. "tabIndex": -1,
  5950. "aria-expanded": "false"
  5951. } );
  5952. } else if ( toShow.length ) {
  5953. this.headers.filter( function() {
  5954. return parseInt( $( this ).attr( "tabIndex" ), 10 ) === 0;
  5955. } )
  5956. .attr( "tabIndex", -1 );
  5957. }
  5958. toShow
  5959. .attr( "aria-hidden", "false" )
  5960. .prev()
  5961. .attr( {
  5962. "aria-selected": "true",
  5963. "aria-expanded": "true",
  5964. tabIndex: 0
  5965. } );
  5966. },
  5967. _animate: function( toShow, toHide, data ) {
  5968. var total, easing, duration,
  5969. that = this,
  5970. adjust = 0,
  5971. boxSizing = toShow.css( "box-sizing" ),
  5972. down = toShow.length &&
  5973. ( !toHide.length || ( toShow.index() < toHide.index() ) ),
  5974. animate = this.options.animate || {},
  5975. options = down && animate.down || animate,
  5976. complete = function() {
  5977. that._toggleComplete( data );
  5978. };
  5979. if ( typeof options === "number" ) {
  5980. duration = options;
  5981. }
  5982. if ( typeof options === "string" ) {
  5983. easing = options;
  5984. }
  5985. // fall back from options to animation in case of partial down settings
  5986. easing = easing || options.easing || animate.easing;
  5987. duration = duration || options.duration || animate.duration;
  5988. if ( !toHide.length ) {
  5989. return toShow.animate( this.showProps, duration, easing, complete );
  5990. }
  5991. if ( !toShow.length ) {
  5992. return toHide.animate( this.hideProps, duration, easing, complete );
  5993. }
  5994. total = toShow.show().outerHeight();
  5995. toHide.animate( this.hideProps, {
  5996. duration: duration,
  5997. easing: easing,
  5998. step: function( now, fx ) {
  5999. fx.now = Math.round( now );
  6000. }
  6001. } );
  6002. toShow
  6003. .hide()
  6004. .animate( this.showProps, {
  6005. duration: duration,
  6006. easing: easing,
  6007. complete: complete,
  6008. step: function( now, fx ) {
  6009. fx.now = Math.round( now );
  6010. if ( fx.prop !== "height" ) {
  6011. if ( boxSizing === "content-box" ) {
  6012. adjust += fx.now;
  6013. }
  6014. } else if ( that.options.heightStyle !== "content" ) {
  6015. fx.now = Math.round( total - toHide.outerHeight() - adjust );
  6016. adjust = 0;
  6017. }
  6018. }
  6019. } );
  6020. },
  6021. _toggleComplete: function( data ) {
  6022. var toHide = data.oldPanel,
  6023. prev = toHide.prev();
  6024. this._removeClass( toHide, "ui-accordion-content-active" );
  6025. this._removeClass( prev, "ui-accordion-header-active" )
  6026. ._addClass( prev, "ui-accordion-header-collapsed" );
  6027. // Work around for rendering bug in IE (#5421)
  6028. if ( toHide.length ) {
  6029. toHide.parent()[ 0 ].className = toHide.parent()[ 0 ].className;
  6030. }
  6031. this._trigger( "activate", null, data );
  6032. }
  6033. } );
  6034. /*!
  6035. * jQuery UI Menu 1.12.0
  6036. * http://jqueryui.com
  6037. *
  6038. * Copyright jQuery Foundation and other contributors
  6039. * Released under the MIT license.
  6040. * http://jquery.org/license
  6041. */
  6042. //>>label: Menu
  6043. //>>group: Widgets
  6044. //>>description: Creates nestable menus.
  6045. //>>docs: http://api.jqueryui.com/menu/
  6046. //>>demos: http://jqueryui.com/menu/
  6047. //>>css.structure: ../../themes/base/core.css
  6048. //>>css.structure: ../../themes/base/menu.css
  6049. //>>css.theme: ../../themes/base/theme.css
  6050. var widgetsMenu = $.widget( "ui.menu", {
  6051. version: "1.12.0",
  6052. defaultElement: "<ul>",
  6053. delay: 300,
  6054. options: {
  6055. icons: {
  6056. submenu: "ui-icon-caret-1-e"
  6057. },
  6058. items: "> *",
  6059. menus: "ul",
  6060. position: {
  6061. my: "left top",
  6062. at: "right top"
  6063. },
  6064. role: "menu",
  6065. // Callbacks
  6066. blur: null,
  6067. focus: null,
  6068. select: null
  6069. },
  6070. _create: function() {
  6071. this.activeMenu = this.element;
  6072. // Flag used to prevent firing of the click handler
  6073. // as the event bubbles up through nested menus
  6074. this.mouseHandled = false;
  6075. this.element
  6076. .uniqueId()
  6077. .attr( {
  6078. role: this.options.role,
  6079. tabIndex: 0
  6080. } );
  6081. this._addClass( "ui-menu", "ui-widget ui-widget-content" );
  6082. this._on( {
  6083. // Prevent focus from sticking to links inside menu after clicking
  6084. // them (focus should always stay on UL during navigation).
  6085. "mousedown .ui-menu-item": function( event ) {
  6086. event.preventDefault();
  6087. },
  6088. "click .ui-menu-item": function( event ) {
  6089. var target = $( event.target );
  6090. var active = $( $.ui.safeActiveElement( this.document[ 0 ] ) );
  6091. if ( !this.mouseHandled && target.not( ".ui-state-disabled" ).length ) {
  6092. this.select( event );
  6093. // Only set the mouseHandled flag if the event will bubble, see #9469.
  6094. if ( !event.isPropagationStopped() ) {
  6095. this.mouseHandled = true;
  6096. }
  6097. // Open submenu on click
  6098. if ( target.has( ".ui-menu" ).length ) {
  6099. this.expand( event );
  6100. } else if ( !this.element.is( ":focus" ) &&
  6101. active.closest( ".ui-menu" ).length ) {
  6102. // Redirect focus to the menu
  6103. this.element.trigger( "focus", [ true ] );
  6104. // If the active item is on the top level, let it stay active.
  6105. // Otherwise, blur the active item since it is no longer visible.
  6106. if ( this.active && this.active.parents( ".ui-menu" ).length === 1 ) {
  6107. clearTimeout( this.timer );
  6108. }
  6109. }
  6110. }
  6111. },
  6112. "mouseenter .ui-menu-item": function( event ) {
  6113. // Ignore mouse events while typeahead is active, see #10458.
  6114. // Prevents focusing the wrong item when typeahead causes a scroll while the mouse
  6115. // is over an item in the menu
  6116. if ( this.previousFilter ) {
  6117. return;
  6118. }
  6119. var actualTarget = $( event.target ).closest( ".ui-menu-item" ),
  6120. target = $( event.currentTarget );
  6121. // Ignore bubbled events on parent items, see #11641
  6122. if ( actualTarget[ 0 ] !== target[ 0 ] ) {
  6123. return;
  6124. }
  6125. // Remove ui-state-active class from siblings of the newly focused menu item
  6126. // to avoid a jump caused by adjacent elements both having a class with a border
  6127. this._removeClass( target.siblings().children( ".ui-state-active" ),
  6128. null, "ui-state-active" );
  6129. this.focus( event, target );
  6130. },
  6131. mouseleave: "collapseAll",
  6132. "mouseleave .ui-menu": "collapseAll",
  6133. focus: function( event, keepActiveItem ) {
  6134. // If there's already an active item, keep it active
  6135. // If not, activate the first item
  6136. var item = this.active || this.element.find( this.options.items ).eq( 0 );
  6137. if ( !keepActiveItem ) {
  6138. this.focus( event, item );
  6139. }
  6140. },
  6141. blur: function( event ) {
  6142. this._delay( function() {
  6143. var notContained = !$.contains(
  6144. this.element[ 0 ],
  6145. $.ui.safeActiveElement( this.document[ 0 ] )
  6146. );
  6147. if ( notContained ) {
  6148. this.collapseAll( event );
  6149. }
  6150. } );
  6151. },
  6152. keydown: "_keydown"
  6153. } );
  6154. this.refresh();
  6155. // Clicks outside of a menu collapse any open menus
  6156. this._on( this.document, {
  6157. click: function( event ) {
  6158. if ( this._closeOnDocumentClick( event ) ) {
  6159. this.collapseAll( event );
  6160. }
  6161. // Reset the mouseHandled flag
  6162. this.mouseHandled = false;
  6163. }
  6164. } );
  6165. },
  6166. _destroy: function() {
  6167. var items = this.element.find( ".ui-menu-item" )
  6168. .removeAttr( "role aria-disabled" ),
  6169. submenus = items.children( ".ui-menu-item-wrapper" )
  6170. .removeUniqueId()
  6171. .removeAttr( "tabIndex role aria-haspopup" );
  6172. // Destroy (sub)menus
  6173. this.element
  6174. .removeAttr( "aria-activedescendant" )
  6175. .find( ".ui-menu" ).addBack()
  6176. .removeAttr( "role aria-labelledby aria-expanded aria-hidden aria-disabled " +
  6177. "tabIndex" )
  6178. .removeUniqueId()
  6179. .show();
  6180. submenus.children().each( function() {
  6181. var elem = $( this );
  6182. if ( elem.data( "ui-menu-submenu-caret" ) ) {
  6183. elem.remove();
  6184. }
  6185. } );
  6186. },
  6187. _keydown: function( event ) {
  6188. var match, prev, character, skip,
  6189. preventDefault = true;
  6190. switch ( event.keyCode ) {
  6191. case $.ui.keyCode.PAGE_UP:
  6192. this.previousPage( event );
  6193. break;
  6194. case $.ui.keyCode.PAGE_DOWN:
  6195. this.nextPage( event );
  6196. break;
  6197. case $.ui.keyCode.HOME:
  6198. this._move( "first", "first", event );
  6199. break;
  6200. case $.ui.keyCode.END:
  6201. this._move( "last", "last", event );
  6202. break;
  6203. case $.ui.keyCode.UP:
  6204. this.previous( event );
  6205. break;
  6206. case $.ui.keyCode.DOWN:
  6207. this.next( event );
  6208. break;
  6209. case $.ui.keyCode.LEFT:
  6210. this.collapse( event );
  6211. break;
  6212. case $.ui.keyCode.RIGHT:
  6213. if ( this.active && !this.active.is( ".ui-state-disabled" ) ) {
  6214. this.expand( event );
  6215. }
  6216. break;
  6217. case $.ui.keyCode.ENTER:
  6218. case $.ui.keyCode.SPACE:
  6219. this._activate( event );
  6220. break;
  6221. case $.ui.keyCode.ESCAPE:
  6222. this.collapse( event );
  6223. break;
  6224. default:
  6225. preventDefault = false;
  6226. prev = this.previousFilter || "";
  6227. character = String.fromCharCode( event.keyCode );
  6228. skip = false;
  6229. clearTimeout( this.filterTimer );
  6230. if ( character === prev ) {
  6231. skip = true;
  6232. } else {
  6233. character = prev + character;
  6234. }
  6235. match = this._filterMenuItems( character );
  6236. match = skip && match.index( this.active.next() ) !== -1 ?
  6237. this.active.nextAll( ".ui-menu-item" ) :
  6238. match;
  6239. // If no matches on the current filter, reset to the last character pressed
  6240. // to move down the menu to the first item that starts with that character
  6241. if ( !match.length ) {
  6242. character = String.fromCharCode( event.keyCode );
  6243. match = this._filterMenuItems( character );
  6244. }
  6245. if ( match.length ) {
  6246. this.focus( event, match );
  6247. this.previousFilter = character;
  6248. this.filterTimer = this._delay( function() {
  6249. delete this.previousFilter;
  6250. }, 1000 );
  6251. } else {
  6252. delete this.previousFilter;
  6253. }
  6254. }
  6255. if ( preventDefault ) {
  6256. event.preventDefault();
  6257. }
  6258. },
  6259. _activate: function( event ) {
  6260. if ( this.active && !this.active.is( ".ui-state-disabled" ) ) {
  6261. if ( this.active.children( "[aria-haspopup='true']" ).length ) {
  6262. this.expand( event );
  6263. } else {
  6264. this.select( event );
  6265. }
  6266. }
  6267. },
  6268. refresh: function() {
  6269. var menus, items, newSubmenus, newItems, newWrappers,
  6270. that = this,
  6271. icon = this.options.icons.submenu,
  6272. submenus = this.element.find( this.options.menus );
  6273. this._toggleClass( "ui-menu-icons", null, !!this.element.find( ".ui-icon" ).length );
  6274. // Initialize nested menus
  6275. newSubmenus = submenus.filter( ":not(.ui-menu)" )
  6276. .hide()
  6277. .attr( {
  6278. role: this.options.role,
  6279. "aria-hidden": "true",
  6280. "aria-expanded": "false"
  6281. } )
  6282. .each( function() {
  6283. var menu = $( this ),
  6284. item = menu.prev(),
  6285. submenuCaret = $( "<span>" ).data( "ui-menu-submenu-caret", true );
  6286. that._addClass( submenuCaret, "ui-menu-icon", "ui-icon " + icon );
  6287. item
  6288. .attr( "aria-haspopup", "true" )
  6289. .prepend( submenuCaret );
  6290. menu.attr( "aria-labelledby", item.attr( "id" ) );
  6291. } );
  6292. this._addClass( newSubmenus, "ui-menu", "ui-widget ui-widget-content ui-front" );
  6293. menus = submenus.add( this.element );
  6294. items = menus.find( this.options.items );
  6295. // Initialize menu-items containing spaces and/or dashes only as dividers
  6296. items.not( ".ui-menu-item" ).each( function() {
  6297. var item = $( this );
  6298. if ( that._isDivider( item ) ) {
  6299. that._addClass( item, "ui-menu-divider", "ui-widget-content" );
  6300. }
  6301. } );
  6302. // Don't refresh list items that are already adapted
  6303. newItems = items.not( ".ui-menu-item, .ui-menu-divider" );
  6304. newWrappers = newItems.children()
  6305. .not( ".ui-menu" )
  6306. .uniqueId()
  6307. .attr( {
  6308. tabIndex: -1,
  6309. role: this._itemRole()
  6310. } );
  6311. this._addClass( newItems, "ui-menu-item" )
  6312. ._addClass( newWrappers, "ui-menu-item-wrapper" );
  6313. // Add aria-disabled attribute to any disabled menu item
  6314. items.filter( ".ui-state-disabled" ).attr( "aria-disabled", "true" );
  6315. // If the active item has been removed, blur the menu
  6316. if ( this.active && !$.contains( this.element[ 0 ], this.active[ 0 ] ) ) {
  6317. this.blur();
  6318. }
  6319. },
  6320. _itemRole: function() {
  6321. return {
  6322. menu: "menuitem",
  6323. listbox: "option"
  6324. }[ this.options.role ];
  6325. },
  6326. _setOption: function( key, value ) {
  6327. if ( key === "icons" ) {
  6328. var icons = this.element.find( ".ui-menu-icon" );
  6329. this._removeClass( icons, null, this.options.icons.submenu )
  6330. ._addClass( icons, null, value.submenu );
  6331. }
  6332. this._super( key, value );
  6333. },
  6334. _setOptionDisabled: function( value ) {
  6335. this._super( value );
  6336. this.element.attr( "aria-disabled", String( value ) );
  6337. this._toggleClass( null, "ui-state-disabled", !!value );
  6338. },
  6339. focus: function( event, item ) {
  6340. var nested, focused, activeParent;
  6341. this.blur( event, event && event.type === "focus" );
  6342. this._scrollIntoView( item );
  6343. this.active = item.first();
  6344. focused = this.active.children( ".ui-menu-item-wrapper" );
  6345. this._addClass( focused, null, "ui-state-active" );
  6346. // Only update aria-activedescendant if there's a role
  6347. // otherwise we assume focus is managed elsewhere
  6348. if ( this.options.role ) {
  6349. this.element.attr( "aria-activedescendant", focused.attr( "id" ) );
  6350. }
  6351. // Highlight active parent menu item, if any
  6352. activeParent = this.active
  6353. .parent()
  6354. .closest( ".ui-menu-item" )
  6355. .children( ".ui-menu-item-wrapper" );
  6356. this._addClass( activeParent, null, "ui-state-active" );
  6357. if ( event && event.type === "keydown" ) {
  6358. this._close();
  6359. } else {
  6360. this.timer = this._delay( function() {
  6361. this._close();
  6362. }, this.delay );
  6363. }
  6364. nested = item.children( ".ui-menu" );
  6365. if ( nested.length && event && ( /^mouse/.test( event.type ) ) ) {
  6366. this._startOpening( nested );
  6367. }
  6368. this.activeMenu = item.parent();
  6369. this._trigger( "focus", event, { item: item } );
  6370. },
  6371. _scrollIntoView: function( item ) {
  6372. var borderTop, paddingTop, offset, scroll, elementHeight, itemHeight;
  6373. if ( this._hasScroll() ) {
  6374. borderTop = parseFloat( $.css( this.activeMenu[ 0 ], "borderTopWidth" ) ) || 0;
  6375. paddingTop = parseFloat( $.css( this.activeMenu[ 0 ], "paddingTop" ) ) || 0;
  6376. offset = item.offset().top - this.activeMenu.offset().top - borderTop - paddingTop;
  6377. scroll = this.activeMenu.scrollTop();
  6378. elementHeight = this.activeMenu.height();
  6379. itemHeight = item.outerHeight();
  6380. if ( offset < 0 ) {
  6381. this.activeMenu.scrollTop( scroll + offset );
  6382. } else if ( offset + itemHeight > elementHeight ) {
  6383. this.activeMenu.scrollTop( scroll + offset - elementHeight + itemHeight );
  6384. }
  6385. }
  6386. },
  6387. blur: function( event, fromFocus ) {
  6388. if ( !fromFocus ) {
  6389. clearTimeout( this.timer );
  6390. }
  6391. if ( !this.active ) {
  6392. return;
  6393. }
  6394. this._removeClass( this.active.children( ".ui-menu-item-wrapper" ),
  6395. null, "ui-state-active" );
  6396. this._trigger( "blur", event, { item: this.active } );
  6397. this.active = null;
  6398. },
  6399. _startOpening: function( submenu ) {
  6400. clearTimeout( this.timer );
  6401. // Don't open if already open fixes a Firefox bug that caused a .5 pixel
  6402. // shift in the submenu position when mousing over the caret icon
  6403. if ( submenu.attr( "aria-hidden" ) !== "true" ) {
  6404. return;
  6405. }
  6406. this.timer = this._delay( function() {
  6407. this._close();
  6408. this._open( submenu );
  6409. }, this.delay );
  6410. },
  6411. _open: function( submenu ) {
  6412. var position = $.extend( {
  6413. of: this.active
  6414. }, this.options.position );
  6415. clearTimeout( this.timer );
  6416. this.element.find( ".ui-menu" ).not( submenu.parents( ".ui-menu" ) )
  6417. .hide()
  6418. .attr( "aria-hidden", "true" );
  6419. submenu
  6420. .show()
  6421. .removeAttr( "aria-hidden" )
  6422. .attr( "aria-expanded", "true" )
  6423. .position( position );
  6424. },
  6425. collapseAll: function( event, all ) {
  6426. clearTimeout( this.timer );
  6427. this.timer = this._delay( function() {
  6428. // If we were passed an event, look for the submenu that contains the event
  6429. var currentMenu = all ? this.element :
  6430. $( event && event.target ).closest( this.element.find( ".ui-menu" ) );
  6431. // If we found no valid submenu ancestor, use the main menu to close all
  6432. // sub menus anyway
  6433. if ( !currentMenu.length ) {
  6434. currentMenu = this.element;
  6435. }
  6436. this._close( currentMenu );
  6437. this.blur( event );
  6438. // Work around active item staying active after menu is blurred
  6439. this._removeClass( currentMenu.find( ".ui-state-active" ), null, "ui-state-active" );
  6440. this.activeMenu = currentMenu;
  6441. }, this.delay );
  6442. },
  6443. // With no arguments, closes the currently active menu - if nothing is active
  6444. // it closes all menus. If passed an argument, it will search for menus BELOW
  6445. _close: function( startMenu ) {
  6446. if ( !startMenu ) {
  6447. startMenu = this.active ? this.active.parent() : this.element;
  6448. }
  6449. startMenu.find( ".ui-menu" )
  6450. .hide()
  6451. .attr( "aria-hidden", "true" )
  6452. .attr( "aria-expanded", "false" );
  6453. },
  6454. _closeOnDocumentClick: function( event ) {
  6455. return !$( event.target ).closest( ".ui-menu" ).length;
  6456. },
  6457. _isDivider: function( item ) {
  6458. // Match hyphen, em dash, en dash
  6459. return !/[^\-\u2014\u2013\s]/.test( item.text() );
  6460. },
  6461. collapse: function( event ) {
  6462. var newItem = this.active &&
  6463. this.active.parent().closest( ".ui-menu-item", this.element );
  6464. if ( newItem && newItem.length ) {
  6465. this._close();
  6466. this.focus( event, newItem );
  6467. }
  6468. },
  6469. expand: function( event ) {
  6470. var newItem = this.active &&
  6471. this.active
  6472. .children( ".ui-menu " )
  6473. .find( this.options.items )
  6474. .first();
  6475. if ( newItem && newItem.length ) {
  6476. this._open( newItem.parent() );
  6477. // Delay so Firefox will not hide activedescendant change in expanding submenu from AT
  6478. this._delay( function() {
  6479. this.focus( event, newItem );
  6480. } );
  6481. }
  6482. },
  6483. next: function( event ) {
  6484. this._move( "next", "first", event );
  6485. },
  6486. previous: function( event ) {
  6487. this._move( "prev", "last", event );
  6488. },
  6489. isFirstItem: function() {
  6490. return this.active && !this.active.prevAll( ".ui-menu-item" ).length;
  6491. },
  6492. isLastItem: function() {
  6493. return this.active && !this.active.nextAll( ".ui-menu-item" ).length;
  6494. },
  6495. _move: function( direction, filter, event ) {
  6496. var next;
  6497. if ( this.active ) {
  6498. if ( direction === "first" || direction === "last" ) {
  6499. next = this.active
  6500. [ direction === "first" ? "prevAll" : "nextAll" ]( ".ui-menu-item" )
  6501. .eq( -1 );
  6502. } else {
  6503. next = this.active
  6504. [ direction + "All" ]( ".ui-menu-item" )
  6505. .eq( 0 );
  6506. }
  6507. }
  6508. if ( !next || !next.length || !this.active ) {
  6509. next = this.activeMenu.find( this.options.items )[ filter ]();
  6510. }
  6511. this.focus( event, next );
  6512. },
  6513. nextPage: function( event ) {
  6514. var item, base, height;
  6515. if ( !this.active ) {
  6516. this.next( event );
  6517. return;
  6518. }
  6519. if ( this.isLastItem() ) {
  6520. return;
  6521. }
  6522. if ( this._hasScroll() ) {
  6523. base = this.active.offset().top;
  6524. height = this.element.height();
  6525. this.active.nextAll( ".ui-menu-item" ).each( function() {
  6526. item = $( this );
  6527. return item.offset().top - base - height < 0;
  6528. } );
  6529. this.focus( event, item );
  6530. } else {
  6531. this.focus( event, this.activeMenu.find( this.options.items )
  6532. [ !this.active ? "first" : "last" ]() );
  6533. }
  6534. },
  6535. previousPage: function( event ) {
  6536. var item, base, height;
  6537. if ( !this.active ) {
  6538. this.next( event );
  6539. return;
  6540. }
  6541. if ( this.isFirstItem() ) {
  6542. return;
  6543. }
  6544. if ( this._hasScroll() ) {
  6545. base = this.active.offset().top;
  6546. height = this.element.height();
  6547. this.active.prevAll( ".ui-menu-item" ).each( function() {
  6548. item = $( this );
  6549. return item.offset().top - base + height > 0;
  6550. } );
  6551. this.focus( event, item );
  6552. } else {
  6553. this.focus( event, this.activeMenu.find( this.options.items ).first() );
  6554. }
  6555. },
  6556. _hasScroll: function() {
  6557. return this.element.outerHeight() < this.element.prop( "scrollHeight" );
  6558. },
  6559. select: function( event ) {
  6560. // TODO: It should never be possible to not have an active item at this
  6561. // point, but the tests don't trigger mouseenter before click.
  6562. this.active = this.active || $( event.target ).closest( ".ui-menu-item" );
  6563. var ui = { item: this.active };
  6564. if ( !this.active.has( ".ui-menu" ).length ) {
  6565. this.collapseAll( event, true );
  6566. }
  6567. this._trigger( "select", event, ui );
  6568. },
  6569. _filterMenuItems: function( character ) {
  6570. var escapedCharacter = character.replace( /[\-\[\]{}()*+?.,\\\^$|#\s]/g, "\\$&" ),
  6571. regex = new RegExp( "^" + escapedCharacter, "i" );
  6572. return this.activeMenu
  6573. .find( this.options.items )
  6574. // Only match on items, not dividers or other content (#10571)
  6575. .filter( ".ui-menu-item" )
  6576. .filter( function() {
  6577. return regex.test(
  6578. $.trim( $( this ).children( ".ui-menu-item-wrapper" ).text() ) );
  6579. } );
  6580. }
  6581. } );
  6582. /*!
  6583. * jQuery UI Autocomplete 1.12.0
  6584. * http://jqueryui.com
  6585. *
  6586. * Copyright jQuery Foundation and other contributors
  6587. * Released under the MIT license.
  6588. * http://jquery.org/license
  6589. */
  6590. //>>label: Autocomplete
  6591. //>>group: Widgets
  6592. //>>description: Lists suggested words as the user is typing.
  6593. //>>docs: http://api.jqueryui.com/autocomplete/
  6594. //>>demos: http://jqueryui.com/autocomplete/
  6595. //>>css.structure: ../../themes/base/core.css
  6596. //>>css.structure: ../../themes/base/autocomplete.css
  6597. //>>css.theme: ../../themes/base/theme.css
  6598. $.widget( "ui.autocomplete", {
  6599. version: "1.12.0",
  6600. defaultElement: "<input>",
  6601. options: {
  6602. appendTo: null,
  6603. autoFocus: false,
  6604. delay: 300,
  6605. minLength: 1,
  6606. position: {
  6607. my: "left top",
  6608. at: "left bottom",
  6609. collision: "none"
  6610. },
  6611. source: null,
  6612. // Callbacks
  6613. change: null,
  6614. close: null,
  6615. focus: null,
  6616. open: null,
  6617. response: null,
  6618. search: null,
  6619. select: null
  6620. },
  6621. requestIndex: 0,
  6622. pending: 0,
  6623. _create: function() {
  6624. // Some browsers only repeat keydown events, not keypress events,
  6625. // so we use the suppressKeyPress flag to determine if we've already
  6626. // handled the keydown event. #7269
  6627. // Unfortunately the code for & in keypress is the same as the up arrow,
  6628. // so we use the suppressKeyPressRepeat flag to avoid handling keypress
  6629. // events when we know the keydown event was used to modify the
  6630. // search term. #7799
  6631. var suppressKeyPress, suppressKeyPressRepeat, suppressInput,
  6632. nodeName = this.element[ 0 ].nodeName.toLowerCase(),
  6633. isTextarea = nodeName === "textarea",
  6634. isInput = nodeName === "input";
  6635. // Textareas are always multi-line
  6636. // Inputs are always single-line, even if inside a contentEditable element
  6637. // IE also treats inputs as contentEditable
  6638. // All other element types are determined by whether or not they're contentEditable
  6639. this.isMultiLine = isTextarea || !isInput && this._isContentEditable( this.element );
  6640. this.valueMethod = this.element[ isTextarea || isInput ? "val" : "text" ];
  6641. this.isNewMenu = true;
  6642. this._addClass( "ui-autocomplete-input" );
  6643. this.element.attr( "autocomplete", "off" );
  6644. this._on( this.element, {
  6645. keydown: function( event ) {
  6646. if ( this.element.prop( "readOnly" ) ) {
  6647. suppressKeyPress = true;
  6648. suppressInput = true;
  6649. suppressKeyPressRepeat = true;
  6650. return;
  6651. }
  6652. suppressKeyPress = false;
  6653. suppressInput = false;
  6654. suppressKeyPressRepeat = false;
  6655. var keyCode = $.ui.keyCode;
  6656. switch ( event.keyCode ) {
  6657. case keyCode.PAGE_UP:
  6658. suppressKeyPress = true;
  6659. this._move( "previousPage", event );
  6660. break;
  6661. case keyCode.PAGE_DOWN:
  6662. suppressKeyPress = true;
  6663. this._move( "nextPage", event );
  6664. break;
  6665. case keyCode.UP:
  6666. suppressKeyPress = true;
  6667. this._keyEvent( "previous", event );
  6668. break;
  6669. case keyCode.DOWN:
  6670. suppressKeyPress = true;
  6671. this._keyEvent( "next", event );
  6672. break;
  6673. case keyCode.ENTER:
  6674. // when menu is open and has focus
  6675. if ( this.menu.active ) {
  6676. // #6055 - Opera still allows the keypress to occur
  6677. // which causes forms to submit
  6678. suppressKeyPress = true;
  6679. event.preventDefault();
  6680. this.menu.select( event );
  6681. }
  6682. break;
  6683. case keyCode.TAB:
  6684. if ( this.menu.active ) {
  6685. this.menu.select( event );
  6686. }
  6687. break;
  6688. case keyCode.ESCAPE:
  6689. if ( this.menu.element.is( ":visible" ) ) {
  6690. if ( !this.isMultiLine ) {
  6691. this._value( this.term );
  6692. }
  6693. this.close( event );
  6694. // Different browsers have different default behavior for escape
  6695. // Single press can mean undo or clear
  6696. // Double press in IE means clear the whole form
  6697. event.preventDefault();
  6698. }
  6699. break;
  6700. default:
  6701. suppressKeyPressRepeat = true;
  6702. // search timeout should be triggered before the input value is changed
  6703. this._searchTimeout( event );
  6704. break;
  6705. }
  6706. },
  6707. keypress: function( event ) {
  6708. if ( suppressKeyPress ) {
  6709. suppressKeyPress = false;
  6710. if ( !this.isMultiLine || this.menu.element.is( ":visible" ) ) {
  6711. event.preventDefault();
  6712. }
  6713. return;
  6714. }
  6715. if ( suppressKeyPressRepeat ) {
  6716. return;
  6717. }
  6718. // Replicate some key handlers to allow them to repeat in Firefox and Opera
  6719. var keyCode = $.ui.keyCode;
  6720. switch ( event.keyCode ) {
  6721. case keyCode.PAGE_UP:
  6722. this._move( "previousPage", event );
  6723. break;
  6724. case keyCode.PAGE_DOWN:
  6725. this._move( "nextPage", event );
  6726. break;
  6727. case keyCode.UP:
  6728. this._keyEvent( "previous", event );
  6729. break;
  6730. case keyCode.DOWN:
  6731. this._keyEvent( "next", event );
  6732. break;
  6733. }
  6734. },
  6735. input: function( event ) {
  6736. if ( suppressInput ) {
  6737. suppressInput = false;
  6738. event.preventDefault();
  6739. return;
  6740. }
  6741. this._searchTimeout( event );
  6742. },
  6743. focus: function() {
  6744. this.selectedItem = null;
  6745. this.previous = this._value();
  6746. },
  6747. blur: function( event ) {
  6748. if ( this.cancelBlur ) {
  6749. delete this.cancelBlur;
  6750. return;
  6751. }
  6752. clearTimeout( this.searching );
  6753. this.close( event );
  6754. this._change( event );
  6755. }
  6756. } );
  6757. this._initSource();
  6758. this.menu = $( "<ul>" )
  6759. .appendTo( this._appendTo() )
  6760. .menu( {
  6761. // disable ARIA support, the live region takes care of that
  6762. role: null
  6763. } )
  6764. .hide()
  6765. .menu( "instance" );
  6766. this._addClass( this.menu.element, "ui-autocomplete", "ui-front" );
  6767. this._on( this.menu.element, {
  6768. mousedown: function( event ) {
  6769. // prevent moving focus out of the text field
  6770. event.preventDefault();
  6771. // IE doesn't prevent moving focus even with event.preventDefault()
  6772. // so we set a flag to know when we should ignore the blur event
  6773. this.cancelBlur = true;
  6774. this._delay( function() {
  6775. delete this.cancelBlur;
  6776. // Support: IE 8 only
  6777. // Right clicking a menu item or selecting text from the menu items will
  6778. // result in focus moving out of the input. However, we've already received
  6779. // and ignored the blur event because of the cancelBlur flag set above. So
  6780. // we restore focus to ensure that the menu closes properly based on the user's
  6781. // next actions.
  6782. if ( this.element[ 0 ] !== $.ui.safeActiveElement( this.document[ 0 ] ) ) {
  6783. this.element.trigger( "focus" );
  6784. }
  6785. } );
  6786. },
  6787. menufocus: function( event, ui ) {
  6788. var label, item;
  6789. // support: Firefox
  6790. // Prevent accidental activation of menu items in Firefox (#7024 #9118)
  6791. if ( this.isNewMenu ) {
  6792. this.isNewMenu = false;
  6793. if ( event.originalEvent && /^mouse/.test( event.originalEvent.type ) ) {
  6794. this.menu.blur();
  6795. this.document.one( "mousemove", function() {
  6796. $( event.target ).trigger( event.originalEvent );
  6797. } );
  6798. return;
  6799. }
  6800. }
  6801. item = ui.item.data( "ui-autocomplete-item" );
  6802. if ( false !== this._trigger( "focus", event, { item: item } ) ) {
  6803. // use value to match what will end up in the input, if it was a key event
  6804. if ( event.originalEvent && /^key/.test( event.originalEvent.type ) ) {
  6805. this._value( item.value );
  6806. }
  6807. }
  6808. // Announce the value in the liveRegion
  6809. label = ui.item.attr( "aria-label" ) || item.value;
  6810. if ( label && $.trim( label ).length ) {
  6811. this.liveRegion.children().hide();
  6812. $( "<div>" ).text( label ).appendTo( this.liveRegion );
  6813. }
  6814. },
  6815. menuselect: function( event, ui ) {
  6816. var item = ui.item.data( "ui-autocomplete-item" ),
  6817. previous = this.previous;
  6818. // Only trigger when focus was lost (click on menu)
  6819. if ( this.element[ 0 ] !== $.ui.safeActiveElement( this.document[ 0 ] ) ) {
  6820. this.element.trigger( "focus" );
  6821. this.previous = previous;
  6822. // #6109 - IE triggers two focus events and the second
  6823. // is asynchronous, so we need to reset the previous
  6824. // term synchronously and asynchronously :-(
  6825. this._delay( function() {
  6826. this.previous = previous;
  6827. this.selectedItem = item;
  6828. } );
  6829. }
  6830. if ( false !== this._trigger( "select", event, { item: item } ) ) {
  6831. this._value( item.value );
  6832. }
  6833. // reset the term after the select event
  6834. // this allows custom select handling to work properly
  6835. this.term = this._value();
  6836. this.close( event );
  6837. this.selectedItem = item;
  6838. }
  6839. } );
  6840. this.liveRegion = $( "<div>", {
  6841. role: "status",
  6842. "aria-live": "assertive",
  6843. "aria-relevant": "additions"
  6844. } )
  6845. .appendTo( this.document[ 0 ].body );
  6846. this._addClass( this.liveRegion, null, "ui-helper-hidden-accessible" );
  6847. // Turning off autocomplete prevents the browser from remembering the
  6848. // value when navigating through history, so we re-enable autocomplete
  6849. // if the page is unloaded before the widget is destroyed. #7790
  6850. this._on( this.window, {
  6851. beforeunload: function() {
  6852. this.element.removeAttr( "autocomplete" );
  6853. }
  6854. } );
  6855. },
  6856. _destroy: function() {
  6857. clearTimeout( this.searching );
  6858. this.element.removeAttr( "autocomplete" );
  6859. this.menu.element.remove();
  6860. this.liveRegion.remove();
  6861. },
  6862. _setOption: function( key, value ) {
  6863. this._super( key, value );
  6864. if ( key === "source" ) {
  6865. this._initSource();
  6866. }
  6867. if ( key === "appendTo" ) {
  6868. this.menu.element.appendTo( this._appendTo() );
  6869. }
  6870. if ( key === "disabled" && value && this.xhr ) {
  6871. this.xhr.abort();
  6872. }
  6873. },
  6874. _isEventTargetInWidget: function( event ) {
  6875. var menuElement = this.menu.element[ 0 ];
  6876. return event.target === this.element[ 0 ] ||
  6877. event.target === menuElement ||
  6878. $.contains( menuElement, event.target );
  6879. },
  6880. _closeOnClickOutside: function( event ) {
  6881. if ( !this._isEventTargetInWidget( event ) ) {
  6882. this.close();
  6883. }
  6884. },
  6885. _appendTo: function() {
  6886. var element = this.options.appendTo;
  6887. if ( element ) {
  6888. element = element.jquery || element.nodeType ?
  6889. $( element ) :
  6890. this.document.find( element ).eq( 0 );
  6891. }
  6892. if ( !element || !element[ 0 ] ) {
  6893. element = this.element.closest( ".ui-front, dialog" );
  6894. }
  6895. if ( !element.length ) {
  6896. element = this.document[ 0 ].body;
  6897. }
  6898. return element;
  6899. },
  6900. _initSource: function() {
  6901. var array, url,
  6902. that = this;
  6903. if ( $.isArray( this.options.source ) ) {
  6904. array = this.options.source;
  6905. this.source = function( request, response ) {
  6906. response( $.ui.autocomplete.filter( array, request.term ) );
  6907. };
  6908. } else if ( typeof this.options.source === "string" ) {
  6909. url = this.options.source;
  6910. this.source = function( request, response ) {
  6911. if ( that.xhr ) {
  6912. that.xhr.abort();
  6913. }
  6914. that.xhr = $.ajax( {
  6915. url: url,
  6916. data: request,
  6917. dataType: "json",
  6918. success: function( data ) {
  6919. response( data );
  6920. },
  6921. error: function() {
  6922. response( [] );
  6923. }
  6924. } );
  6925. };
  6926. } else {
  6927. this.source = this.options.source;
  6928. }
  6929. },
  6930. _searchTimeout: function( event ) {
  6931. clearTimeout( this.searching );
  6932. this.searching = this._delay( function() {
  6933. // Search if the value has changed, or if the user retypes the same value (see #7434)
  6934. var equalValues = this.term === this._value(),
  6935. menuVisible = this.menu.element.is( ":visible" ),
  6936. modifierKey = event.altKey || event.ctrlKey || event.metaKey || event.shiftKey;
  6937. if ( !equalValues || ( equalValues && !menuVisible && !modifierKey ) ) {
  6938. this.selectedItem = null;
  6939. this.search( null, event );
  6940. }
  6941. }, this.options.delay );
  6942. },
  6943. search: function( value, event ) {
  6944. value = value != null ? value : this._value();
  6945. // Always save the actual value, not the one passed as an argument
  6946. this.term = this._value();
  6947. if ( value.length < this.options.minLength ) {
  6948. return this.close( event );
  6949. }
  6950. if ( this._trigger( "search", event ) === false ) {
  6951. return;
  6952. }
  6953. return this._search( value );
  6954. },
  6955. _search: function( value ) {
  6956. this.pending++;
  6957. this._addClass( "ui-autocomplete-loading" );
  6958. this.cancelSearch = false;
  6959. this.source( { term: value }, this._response() );
  6960. },
  6961. _response: function() {
  6962. var index = ++this.requestIndex;
  6963. return $.proxy( function( content ) {
  6964. if ( index === this.requestIndex ) {
  6965. this.__response( content );
  6966. }
  6967. this.pending--;
  6968. if ( !this.pending ) {
  6969. this._removeClass( "ui-autocomplete-loading" );
  6970. }
  6971. }, this );
  6972. },
  6973. __response: function( content ) {
  6974. if ( content ) {
  6975. content = this._normalize( content );
  6976. }
  6977. this._trigger( "response", null, { content: content } );
  6978. if ( !this.options.disabled && content && content.length && !this.cancelSearch ) {
  6979. this._suggest( content );
  6980. this._trigger( "open" );
  6981. } else {
  6982. // use ._close() instead of .close() so we don't cancel future searches
  6983. this._close();
  6984. }
  6985. },
  6986. close: function( event ) {
  6987. this.cancelSearch = true;
  6988. this._close( event );
  6989. },
  6990. _close: function( event ) {
  6991. // Remove the handler that closes the menu on outside clicks
  6992. this._off( this.document, "mousedown" );
  6993. if ( this.menu.element.is( ":visible" ) ) {
  6994. this.menu.element.hide();
  6995. this.menu.blur();
  6996. this.isNewMenu = true;
  6997. this._trigger( "close", event );
  6998. }
  6999. },
  7000. _change: function( event ) {
  7001. if ( this.previous !== this._value() ) {
  7002. this._trigger( "change", event, { item: this.selectedItem } );
  7003. }
  7004. },
  7005. _normalize: function( items ) {
  7006. // assume all items have the right format when the first item is complete
  7007. if ( items.length && items[ 0 ].label && items[ 0 ].value ) {
  7008. return items;
  7009. }
  7010. return $.map( items, function( item ) {
  7011. if ( typeof item === "string" ) {
  7012. return {
  7013. label: item,
  7014. value: item
  7015. };
  7016. }
  7017. return $.extend( {}, item, {
  7018. label: item.label || item.value,
  7019. value: item.value || item.label
  7020. } );
  7021. } );
  7022. },
  7023. _suggest: function( items ) {
  7024. var ul = this.menu.element.empty();
  7025. this._renderMenu( ul, items );
  7026. this.isNewMenu = true;
  7027. this.menu.refresh();
  7028. // Size and position menu
  7029. ul.show();
  7030. this._resizeMenu();
  7031. ul.position( $.extend( {
  7032. of: this.element
  7033. }, this.options.position ) );
  7034. if ( this.options.autoFocus ) {
  7035. this.menu.next();
  7036. }
  7037. // Listen for interactions outside of the widget (#6642)
  7038. this._on( this.document, {
  7039. mousedown: "_closeOnClickOutside"
  7040. } );
  7041. },
  7042. _resizeMenu: function() {
  7043. var ul = this.menu.element;
  7044. ul.outerWidth( Math.max(
  7045. // Firefox wraps long text (possibly a rounding bug)
  7046. // so we add 1px to avoid the wrapping (#7513)
  7047. ul.width( "" ).outerWidth() + 1,
  7048. this.element.outerWidth()
  7049. ) );
  7050. },
  7051. _renderMenu: function( ul, items ) {
  7052. var that = this;
  7053. $.each( items, function( index, item ) {
  7054. that._renderItemData( ul, item );
  7055. } );
  7056. },
  7057. _renderItemData: function( ul, item ) {
  7058. return this._renderItem( ul, item ).data( "ui-autocomplete-item", item );
  7059. },
  7060. _renderItem: function( ul, item ) {
  7061. return $( "<li>" )
  7062. .append( $( "<div>" ).text( item.label ) )
  7063. .appendTo( ul );
  7064. },
  7065. _move: function( direction, event ) {
  7066. if ( !this.menu.element.is( ":visible" ) ) {
  7067. this.search( null, event );
  7068. return;
  7069. }
  7070. if ( this.menu.isFirstItem() && /^previous/.test( direction ) ||
  7071. this.menu.isLastItem() && /^next/.test( direction ) ) {
  7072. if ( !this.isMultiLine ) {
  7073. this._value( this.term );
  7074. }
  7075. this.menu.blur();
  7076. return;
  7077. }
  7078. this.menu[ direction ]( event );
  7079. },
  7080. widget: function() {
  7081. return this.menu.element;
  7082. },
  7083. _value: function() {
  7084. return this.valueMethod.apply( this.element, arguments );
  7085. },
  7086. _keyEvent: function( keyEvent, event ) {
  7087. if ( !this.isMultiLine || this.menu.element.is( ":visible" ) ) {
  7088. this._move( keyEvent, event );
  7089. // Prevents moving cursor to beginning/end of the text field in some browsers
  7090. event.preventDefault();
  7091. }
  7092. },
  7093. // Support: Chrome <=50
  7094. // We should be able to just use this.element.prop( "isContentEditable" )
  7095. // but hidden elements always report false in Chrome.
  7096. // https://code.google.com/p/chromium/issues/detail?id=313082
  7097. _isContentEditable: function( element ) {
  7098. if ( !element.length ) {
  7099. return false;
  7100. }
  7101. var editable = element.prop( "contentEditable" );
  7102. if ( editable === "inherit" ) {
  7103. return this._isContentEditable( element.parent() );
  7104. }
  7105. return editable === "true";
  7106. }
  7107. } );
  7108. $.extend( $.ui.autocomplete, {
  7109. escapeRegex: function( value ) {
  7110. return value.replace( /[\-\[\]{}()*+?.,\\\^$|#\s]/g, "\\$&" );
  7111. },
  7112. filter: function( array, term ) {
  7113. var matcher = new RegExp( $.ui.autocomplete.escapeRegex( term ), "i" );
  7114. return $.grep( array, function( value ) {
  7115. return matcher.test( value.label || value.value || value );
  7116. } );
  7117. }
  7118. } );
  7119. // Live region extension, adding a `messages` option
  7120. // NOTE: This is an experimental API. We are still investigating
  7121. // a full solution for string manipulation and internationalization.
  7122. $.widget( "ui.autocomplete", $.ui.autocomplete, {
  7123. options: {
  7124. messages: {
  7125. noResults: "No search results.",
  7126. results: function( amount ) {
  7127. return amount + ( amount > 1 ? " results are" : " result is" ) +
  7128. " available, use up and down arrow keys to navigate.";
  7129. }
  7130. }
  7131. },
  7132. __response: function( content ) {
  7133. var message;
  7134. this._superApply( arguments );
  7135. if ( this.options.disabled || this.cancelSearch ) {
  7136. return;
  7137. }
  7138. if ( content && content.length ) {
  7139. message = this.options.messages.results( content.length );
  7140. } else {
  7141. message = this.options.messages.noResults;
  7142. }
  7143. this.liveRegion.children().hide();
  7144. $( "<div>" ).text( message ).appendTo( this.liveRegion );
  7145. }
  7146. } );
  7147. var widgetsAutocomplete = $.ui.autocomplete;
  7148. /*!
  7149. * jQuery UI Controlgroup 1.12.0
  7150. * http://jqueryui.com
  7151. *
  7152. * Copyright jQuery Foundation and other contributors
  7153. * Released under the MIT license.
  7154. * http://jquery.org/license
  7155. */
  7156. //>>label: Controlgroup
  7157. //>>group: Widgets
  7158. //>>description: Visually groups form control widgets
  7159. //>>docs: http://api.jqueryui.com/controlgroup/
  7160. //>>demos: http://jqueryui.com/controlgroup/
  7161. //>>css.structure: ../../themes/base/core.css
  7162. //>>css.structure: ../../themes/base/controlgroup.css
  7163. //>>css.theme: ../../themes/base/theme.css
  7164. var controlgroupCornerRegex = /ui-corner-([a-z]){2,6}/g;
  7165. var widgetsControlgroup = $.widget( "ui.controlgroup", {
  7166. version: "1.12.0",
  7167. defaultElement: "<div>",
  7168. options: {
  7169. direction: "horizontal",
  7170. disabled: null,
  7171. onlyVisible: true,
  7172. items: {
  7173. "button": "input[type=button], input[type=submit], input[type=reset], button, a",
  7174. "controlgroupLabel": ".ui-controlgroup-label",
  7175. "checkboxradio": "input[type='checkbox'], input[type='radio']",
  7176. "selectmenu": "select",
  7177. "spinner": ".ui-spinner-input"
  7178. }
  7179. },
  7180. _create: function() {
  7181. this._enhance();
  7182. },
  7183. // To support the enhanced option in jQuery Mobile, we isolate DOM manipulation
  7184. _enhance: function() {
  7185. this.element.attr( "role", "toolbar" );
  7186. this.refresh();
  7187. },
  7188. _destroy: function() {
  7189. this._callChildMethod( "destroy" );
  7190. this.childWidgets.removeData( "ui-controlgroup-data" );
  7191. this.element.removeAttr( "role" );
  7192. if ( this.options.items.controlgroupLabel ) {
  7193. this.element
  7194. .find( this.options.items.controlgroupLabel )
  7195. .find( ".ui-controlgroup-label-contents" )
  7196. .contents().unwrap();
  7197. }
  7198. },
  7199. _initWidgets: function() {
  7200. var that = this,
  7201. childWidgets = [];
  7202. // First we iterate over each of the items options
  7203. $.each( this.options.items, function( widget, selector ) {
  7204. var labels;
  7205. var options = {};
  7206. // Make sure the widget has a selector set
  7207. if ( !selector ) {
  7208. return;
  7209. }
  7210. if ( widget === "controlgroupLabel" ) {
  7211. labels = that.element.find( selector );
  7212. labels.each( function() {
  7213. var element = $( this );
  7214. if ( element.children( ".ui-controlgroup-label-contents" ).length ) {
  7215. return;
  7216. }
  7217. element.contents()
  7218. .wrapAll( "<span class='ui-controlgroup-label-contents'></span>" );
  7219. } );
  7220. that._addClass( labels, null, "ui-widget ui-widget-content ui-state-default" );
  7221. childWidgets = childWidgets.concat( labels.get() );
  7222. return;
  7223. }
  7224. // Make sure the widget actually exists
  7225. if ( !$.fn[ widget ] ) {
  7226. return;
  7227. }
  7228. // We assume everything is in the middle to start because we can't determine
  7229. // first / last elements until all enhancments are done.
  7230. if ( that[ "_" + widget + "Options" ] ) {
  7231. options = that[ "_" + widget + "Options" ]( "middle" );
  7232. }
  7233. // Find instances of this widget inside controlgroup and init them
  7234. that.element
  7235. .find( selector )
  7236. .each( function() {
  7237. var element = $( this );
  7238. var instance = element[ widget ]( "instance" );
  7239. // We need to clone the default options for this type of widget to avoid
  7240. // polluting the variable options which has a wider scope than a single widget.
  7241. var instanceOptions = $.widget.extend( {}, options );
  7242. // If the button is the child of a spinner ignore it
  7243. // TODO: Find a more generic solution
  7244. if ( widget === "button" && element.parent( ".ui-spinner" ).length ) {
  7245. return;
  7246. }
  7247. // Create the widget if it doesn't exist
  7248. if ( !instance ) {
  7249. instance = element[ widget ]()[ widget ]( "instance" );
  7250. }
  7251. if ( instance ) {
  7252. instanceOptions.classes =
  7253. that._resolveClassesValues( instanceOptions.classes, instance );
  7254. }
  7255. element[ widget ]( instanceOptions );
  7256. // Store an instance of the controlgroup to be able to reference
  7257. // from the outermost element for changing options and refresh
  7258. var widgetElement = element[ widget ]( "widget" );
  7259. $.data( widgetElement[ 0 ], "ui-controlgroup-data",
  7260. instance ? instance : element[ widget ]( "instance" ) );
  7261. childWidgets.push( widgetElement[ 0 ] );
  7262. } );
  7263. } );
  7264. this.childWidgets = $( $.unique( childWidgets ) );
  7265. this._addClass( this.childWidgets, "ui-controlgroup-item" );
  7266. },
  7267. _callChildMethod: function( method ) {
  7268. this.childWidgets.each( function() {
  7269. var element = $( this ),
  7270. data = element.data( "ui-controlgroup-data" );
  7271. if ( data && data[ method ] ) {
  7272. data[ method ]();
  7273. }
  7274. } );
  7275. },
  7276. _updateCornerClass: function( element, position ) {
  7277. var remove = "ui-corner-top ui-corner-bottom ui-corner-left ui-corner-right ui-corner-all";
  7278. var add = this._buildSimpleOptions( position, "label" ).classes.label;
  7279. this._removeClass( element, null, remove );
  7280. this._addClass( element, null, add );
  7281. },
  7282. _buildSimpleOptions: function( position, key ) {
  7283. var direction = this.options.direction === "vertical";
  7284. var result = {
  7285. classes: {}
  7286. };
  7287. result.classes[ key ] = {
  7288. "middle": "",
  7289. "first": "ui-corner-" + ( direction ? "top" : "left" ),
  7290. "last": "ui-corner-" + ( direction ? "bottom" : "right" ),
  7291. "only": "ui-corner-all"
  7292. }[ position ];
  7293. return result;
  7294. },
  7295. _spinnerOptions: function( position ) {
  7296. var options = this._buildSimpleOptions( position, "ui-spinner" );
  7297. options.classes[ "ui-spinner-up" ] = "";
  7298. options.classes[ "ui-spinner-down" ] = "";
  7299. return options;
  7300. },
  7301. _buttonOptions: function( position ) {
  7302. return this._buildSimpleOptions( position, "ui-button" );
  7303. },
  7304. _checkboxradioOptions: function( position ) {
  7305. return this._buildSimpleOptions( position, "ui-checkboxradio-label" );
  7306. },
  7307. _selectmenuOptions: function( position ) {
  7308. var direction = this.options.direction === "vertical";
  7309. return {
  7310. width: direction ? "auto" : false,
  7311. classes: {
  7312. middle: {
  7313. "ui-selectmenu-button-open": "",
  7314. "ui-selectmenu-button-closed": ""
  7315. },
  7316. first: {
  7317. "ui-selectmenu-button-open": "ui-corner-" + ( direction ? "top" : "tl" ),
  7318. "ui-selectmenu-button-closed": "ui-corner-" + ( direction ? "top" : "left" )
  7319. },
  7320. last: {
  7321. "ui-selectmenu-button-open": direction ? "" : "ui-corner-tr",
  7322. "ui-selectmenu-button-closed": "ui-corner-" + ( direction ? "bottom" : "right" )
  7323. },
  7324. only: {
  7325. "ui-selectmenu-button-open": "ui-corner-top",
  7326. "ui-selectmenu-button-closed": "ui-corner-all"
  7327. }
  7328. }[ position ]
  7329. };
  7330. },
  7331. _resolveClassesValues: function( classes, instance ) {
  7332. var result = {};
  7333. $.each( classes, function( key ) {
  7334. var current = instance.options.classes[ key ] || "";
  7335. current = current.replace( controlgroupCornerRegex, "" ).trim();
  7336. result[ key ] = ( current + " " + classes[ key ] ).replace( /\s+/g, " " );
  7337. } );
  7338. return result;
  7339. },
  7340. _setOption: function( key, value ) {
  7341. if ( key === "direction" ) {
  7342. this._removeClass( "ui-controlgroup-" + this.options.direction );
  7343. }
  7344. this._super( key, value );
  7345. if ( key === "disabled" ) {
  7346. this._callChildMethod( value ? "disable" : "enable" );
  7347. return;
  7348. }
  7349. this.refresh();
  7350. },
  7351. refresh: function() {
  7352. var children,
  7353. that = this;
  7354. this._addClass( "ui-controlgroup ui-controlgroup-" + this.options.direction );
  7355. if ( this.options.direction === "horizontal" ) {
  7356. this._addClass( null, "ui-helper-clearfix" );
  7357. }
  7358. this._initWidgets();
  7359. children = this.childWidgets;
  7360. // We filter here because we need to track all childWidgets not just the visible ones
  7361. if ( this.options.onlyVisible ) {
  7362. children = children.filter( ":visible" );
  7363. }
  7364. if ( children.length ) {
  7365. // We do this last because we need to make sure all enhancment is done
  7366. // before determining first and last
  7367. $.each( [ "first", "last" ], function( index, value ) {
  7368. var instance = children[ value ]().data( "ui-controlgroup-data" );
  7369. if ( instance && that[ "_" + instance.widgetName + "Options" ] ) {
  7370. var options = that[ "_" + instance.widgetName + "Options" ](
  7371. children.length === 1 ? "only" : value
  7372. );
  7373. options.classes = that._resolveClassesValues( options.classes, instance );
  7374. instance.element[ instance.widgetName ]( options );
  7375. } else {
  7376. that._updateCornerClass( children[ value ](), value );
  7377. }
  7378. } );
  7379. // Finally call the refresh method on each of the child widgets.
  7380. this._callChildMethod( "refresh" );
  7381. }
  7382. }
  7383. } );
  7384. /*!
  7385. * jQuery UI Checkboxradio 1.12.0
  7386. * http://jqueryui.com
  7387. *
  7388. * Copyright jQuery Foundation and other contributors
  7389. * Released under the MIT license.
  7390. * http://jquery.org/license
  7391. */
  7392. //>>label: Checkboxradio
  7393. //>>group: Widgets
  7394. //>>description: Enhances a form with multiple themeable checkboxes or radio buttons.
  7395. //>>docs: http://api.jqueryui.com/checkboxradio/
  7396. //>>demos: http://jqueryui.com/checkboxradio/
  7397. //>>css.structure: ../../themes/base/core.css
  7398. //>>css.structure: ../../themes/base/button.css
  7399. //>>css.structure: ../../themes/base/checkboxradio.css
  7400. //>>css.theme: ../../themes/base/theme.css
  7401. $.widget( "ui.checkboxradio", [ $.ui.formResetMixin, {
  7402. version: "1.12.0",
  7403. options: {
  7404. disabled: null,
  7405. label: null,
  7406. icon: true,
  7407. classes: {
  7408. "ui-checkboxradio-label": "ui-corner-all",
  7409. "ui-checkboxradio-icon": "ui-corner-all"
  7410. }
  7411. },
  7412. _getCreateOptions: function() {
  7413. var disabled, labels;
  7414. var that = this;
  7415. var options = this._super() || {};
  7416. // We read the type here, because it makes more sense to throw a element type error first,
  7417. // rather then the error for lack of a label. Often if its the wrong type, it
  7418. // won't have a label (e.g. calling on a div, btn, etc)
  7419. this._readType();
  7420. labels = this.element.labels();
  7421. // If there are multiple labels, use the last one
  7422. this.label = $( labels[ labels.length - 1 ] );
  7423. if ( !this.label.length ) {
  7424. $.error( "No label found for checkboxradio widget" );
  7425. }
  7426. this.originalLabel = "";
  7427. // We need to get the label text but this may also need to make sure it does not contain the
  7428. // input itself.
  7429. this.label.contents().not( this.element ).each( function() {
  7430. // The label contents could be text, html, or a mix. We concat each element to get a
  7431. // string representation of the label, without the input as part of it.
  7432. that.originalLabel += this.nodeType === 3 ? $( this ).text() : this.outerHTML;
  7433. } );
  7434. // Set the label option if we found label text
  7435. if ( this.originalLabel ) {
  7436. options.label = this.originalLabel;
  7437. }
  7438. disabled = this.element[ 0 ].disabled;
  7439. if ( disabled != null ) {
  7440. options.disabled = disabled;
  7441. }
  7442. return options;
  7443. },
  7444. _create: function() {
  7445. var checked = this.element[ 0 ].checked;
  7446. this._bindFormResetHandler();
  7447. if ( this.options.disabled == null ) {
  7448. this.options.disabled = this.element[ 0 ].disabled;
  7449. }
  7450. this._setOption( "disabled", this.options.disabled );
  7451. this._addClass( "ui-checkboxradio", "ui-helper-hidden-accessible" );
  7452. this._addClass( this.label, "ui-checkboxradio-label", "ui-button ui-widget" );
  7453. if ( this.type === "radio" ) {
  7454. this._addClass( this.label, "ui-checkboxradio-radio-label" );
  7455. }
  7456. if ( this.options.label && this.options.label !== this.originalLabel ) {
  7457. this._updateLabel();
  7458. } else if ( this.originalLabel ) {
  7459. this.options.label = this.originalLabel;
  7460. }
  7461. this._enhance();
  7462. if ( checked ) {
  7463. this._addClass( this.label, "ui-checkboxradio-checked", "ui-state-active" );
  7464. if ( this.icon ) {
  7465. this._addClass( this.icon, null, "ui-state-hover" );
  7466. }
  7467. }
  7468. this._on( {
  7469. change: "_toggleClasses",
  7470. focus: function() {
  7471. this._addClass( this.label, null, "ui-state-focus ui-visual-focus" );
  7472. },
  7473. blur: function() {
  7474. this._removeClass( this.label, null, "ui-state-focus ui-visual-focus" );
  7475. }
  7476. } );
  7477. },
  7478. _readType: function() {
  7479. var nodeName = this.element[ 0 ].nodeName.toLowerCase();
  7480. this.type = this.element[ 0 ].type;
  7481. if ( nodeName !== "input" || !/radio|checkbox/.test( this.type ) ) {
  7482. $.error( "Can't create checkboxradio on element.nodeName=" + nodeName +
  7483. " and element.type=" + this.type );
  7484. }
  7485. },
  7486. // Support jQuery Mobile enhanced option
  7487. _enhance: function() {
  7488. this._updateIcon( this.element[ 0 ].checked );
  7489. },
  7490. widget: function() {
  7491. return this.label;
  7492. },
  7493. _getRadioGroup: function() {
  7494. var group;
  7495. var name = this.element[ 0 ].name;
  7496. var nameSelector = "input[name='" + $.ui.escapeSelector( name ) + "']";
  7497. if ( !name ) {
  7498. return $( [] );
  7499. }
  7500. if ( this.form.length ) {
  7501. group = $( this.form[ 0 ].elements ).filter( nameSelector );
  7502. } else {
  7503. // Not inside a form, check all inputs that also are not inside a form
  7504. group = $( nameSelector ).filter( function() {
  7505. return $( this ).form().length === 0;
  7506. } );
  7507. }
  7508. return group.not( this.element );
  7509. },
  7510. _toggleClasses: function() {
  7511. var checked = this.element[ 0 ].checked;
  7512. this._toggleClass( this.label, "ui-checkboxradio-checked", "ui-state-active", checked );
  7513. if ( this.options.icon && this.type === "checkbox" ) {
  7514. this._toggleClass( this.icon, null, "ui-icon-check ui-state-checked", checked )
  7515. ._toggleClass( this.icon, null, "ui-icon-blank", !checked );
  7516. }
  7517. if ( this.type === "radio" ) {
  7518. this._getRadioGroup()
  7519. .each( function() {
  7520. var instance = $( this ).checkboxradio( "instance" );
  7521. if ( instance ) {
  7522. instance._removeClass( instance.label,
  7523. "ui-checkboxradio-checked", "ui-state-active" );
  7524. }
  7525. } );
  7526. }
  7527. },
  7528. _destroy: function() {
  7529. this._unbindFormResetHandler();
  7530. if ( this.icon ) {
  7531. this.icon.remove();
  7532. this.iconSpace.remove();
  7533. }
  7534. },
  7535. _setOption: function( key, value ) {
  7536. // We don't allow the value to be set to nothing
  7537. if ( key === "label" && !value ) {
  7538. return;
  7539. }
  7540. this._super( key, value );
  7541. if ( key === "disabled" ) {
  7542. this._toggleClass( this.label, null, "ui-state-disabled", value );
  7543. this.element[ 0 ].disabled = value;
  7544. // Don't refresh when setting disabled
  7545. return;
  7546. }
  7547. this.refresh();
  7548. },
  7549. _updateIcon: function( checked ) {
  7550. var toAdd = "ui-icon ui-icon-background ";
  7551. if ( this.options.icon ) {
  7552. if ( !this.icon ) {
  7553. this.icon = $( "<span>" );
  7554. this.iconSpace = $( "<span> </span>" );
  7555. this._addClass( this.iconSpace, "ui-checkboxradio-icon-space" );
  7556. }
  7557. if ( this.type === "checkbox" ) {
  7558. toAdd += checked ? "ui-icon-check ui-state-checked" : "ui-icon-blank";
  7559. this._removeClass( this.icon, null, checked ? "ui-icon-blank" : "ui-icon-check" );
  7560. } else {
  7561. toAdd += "ui-icon-blank";
  7562. }
  7563. this._addClass( this.icon, "ui-checkboxradio-icon", toAdd );
  7564. if ( !checked ) {
  7565. this._removeClass( this.icon, null, "ui-icon-check ui-state-checked" );
  7566. }
  7567. this.icon.prependTo( this.label ).after( this.iconSpace );
  7568. } else if ( this.icon !== undefined ) {
  7569. this.icon.remove();
  7570. this.iconSpace.remove();
  7571. delete this.icon;
  7572. }
  7573. },
  7574. _updateLabel: function() {
  7575. // Remove the contents of the label ( minus the icon, icon space, and input )
  7576. this.label.contents().not( this.element.add( this.icon ).add( this.iconSpace ) ).remove();
  7577. this.label.append( this.options.label );
  7578. },
  7579. refresh: function() {
  7580. var checked = this.element[ 0 ].checked,
  7581. isDisabled = this.element[ 0 ].disabled;
  7582. this._updateIcon( checked );
  7583. this._toggleClass( this.label, "ui-checkboxradio-checked", "ui-state-active", checked );
  7584. if ( this.options.label !== null ) {
  7585. this._updateLabel();
  7586. }
  7587. if ( isDisabled !== this.options.disabled ) {
  7588. this._setOptions( { "disabled": isDisabled } );
  7589. }
  7590. }
  7591. } ] );
  7592. var widgetsCheckboxradio = $.ui.checkboxradio;
  7593. /*!
  7594. * jQuery UI Button 1.12.0
  7595. * http://jqueryui.com
  7596. *
  7597. * Copyright jQuery Foundation and other contributors
  7598. * Released under the MIT license.
  7599. * http://jquery.org/license
  7600. */
  7601. //>>label: Button
  7602. //>>group: Widgets
  7603. //>>description: Enhances a form with themeable buttons.
  7604. //>>docs: http://api.jqueryui.com/button/
  7605. //>>demos: http://jqueryui.com/button/
  7606. //>>css.structure: ../../themes/base/core.css
  7607. //>>css.structure: ../../themes/base/button.css
  7608. //>>css.theme: ../../themes/base/theme.css
  7609. $.widget( "ui.button", {
  7610. version: "1.12.0",
  7611. defaultElement: "<button>",
  7612. options: {
  7613. classes: {
  7614. "ui-button": "ui-corner-all"
  7615. },
  7616. disabled: null,
  7617. icon: null,
  7618. iconPosition: "beginning",
  7619. label: null,
  7620. showLabel: true
  7621. },
  7622. _getCreateOptions: function() {
  7623. var disabled,
  7624. // This is to support cases like in jQuery Mobile where the base widget does have
  7625. // an implementation of _getCreateOptions
  7626. options = this._super() || {};
  7627. this.isInput = this.element.is( "input" );
  7628. disabled = this.element[ 0 ].disabled;
  7629. if ( disabled != null ) {
  7630. options.disabled = disabled;
  7631. }
  7632. this.originalLabel = this.isInput ? this.element.val() : this.element.html();
  7633. if ( this.originalLabel ) {
  7634. options.label = this.originalLabel;
  7635. }
  7636. return options;
  7637. },
  7638. _create: function() {
  7639. if ( !this.option.showLabel & !this.options.icon ) {
  7640. this.options.showLabel = true;
  7641. }
  7642. // We have to check the option again here even though we did in _getCreateOptions,
  7643. // because null may have been passed on init which would override what was set in
  7644. // _getCreateOptions
  7645. if ( this.options.disabled == null ) {
  7646. this.options.disabled = this.element[ 0 ].disabled || false;
  7647. }
  7648. this.hasTitle = !!this.element.attr( "title" );
  7649. // Check to see if the label needs to be set or if its already correct
  7650. if ( this.options.label && this.options.label !== this.originalLabel ) {
  7651. if ( this.isInput ) {
  7652. this.element.val( this.options.label );
  7653. } else {
  7654. this.element.html( this.options.label );
  7655. }
  7656. }
  7657. this._addClass( "ui-button", "ui-widget" );
  7658. this._setOption( "disabled", this.options.disabled );
  7659. this._enhance();
  7660. if ( this.element.is( "a" ) ) {
  7661. this._on( {
  7662. "keyup": function( event ) {
  7663. if ( event.keyCode === $.ui.keyCode.SPACE ) {
  7664. event.preventDefault();
  7665. // Support: PhantomJS <= 1.9, IE 8 Only
  7666. // If a native click is available use it so we actually cause navigation
  7667. // otherwise just trigger a click event
  7668. if ( this.element[ 0 ].click ) {
  7669. this.element[ 0 ].click();
  7670. } else {
  7671. this.element.trigger( "click" );
  7672. }
  7673. }
  7674. }
  7675. } );
  7676. }
  7677. },
  7678. _enhance: function() {
  7679. if ( !this.element.is( "button" ) ) {
  7680. this.element.attr( "role", "button" );
  7681. }
  7682. if ( this.options.icon ) {
  7683. this._updateIcon( "icon", this.options.icon );
  7684. this._updateTooltip();
  7685. }
  7686. },
  7687. _updateTooltip: function() {
  7688. this.title = this.element.attr( "title" );
  7689. if ( !this.options.showLabel && !this.title ) {
  7690. this.element.attr( "title", this.options.label );
  7691. }
  7692. },
  7693. _updateIcon: function( option, value ) {
  7694. var icon = option !== "iconPosition",
  7695. position = icon ? this.options.iconPosition : value,
  7696. displayBlock = position === "top" || position === "bottom";
  7697. // Create icon
  7698. if ( !this.icon ) {
  7699. this.icon = $( "<span>" );
  7700. this._addClass( this.icon, "ui-button-icon", "ui-icon" );
  7701. if ( !this.options.showLabel ) {
  7702. this._addClass( "ui-button-icon-only" );
  7703. }
  7704. } else if ( icon ) {
  7705. // If we are updating the icon remove the old icon class
  7706. this._removeClass( this.icon, null, this.options.icon );
  7707. }
  7708. // If we are updating the icon add the new icon class
  7709. if ( icon ) {
  7710. this._addClass( this.icon, null, value );
  7711. }
  7712. this._attachIcon( position );
  7713. // If the icon is on top or bottom we need to add the ui-widget-icon-block class and remove
  7714. // the iconSpace if there is one.
  7715. if ( displayBlock ) {
  7716. this._addClass( this.icon, null, "ui-widget-icon-block" );
  7717. if ( this.iconSpace ) {
  7718. this.iconSpace.remove();
  7719. }
  7720. } else {
  7721. // Position is beginning or end so remove the ui-widget-icon-block class and add the
  7722. // space if it does not exist
  7723. if ( !this.iconSpace ) {
  7724. this.iconSpace = $( "<span> </span>" );
  7725. this._addClass( this.iconSpace, "ui-button-icon-space" );
  7726. }
  7727. this._removeClass( this.icon, null, "ui-wiget-icon-block" );
  7728. this._attachIconSpace( position );
  7729. }
  7730. },
  7731. _destroy: function() {
  7732. this.element.removeAttr( "role" );
  7733. if ( this.icon ) {
  7734. this.icon.remove();
  7735. }
  7736. if ( this.iconSpace ) {
  7737. this.iconSpace.remove();
  7738. }
  7739. if ( !this.hasTitle ) {
  7740. this.element.removeAttr( "title" );
  7741. }
  7742. },
  7743. _attachIconSpace: function( iconPosition ) {
  7744. this.icon[ /^(?:end|bottom)/.test( iconPosition ) ? "before" : "after" ]( this.iconSpace );
  7745. },
  7746. _attachIcon: function( iconPosition ) {
  7747. this.element[ /^(?:end|bottom)/.test( iconPosition ) ? "append" : "prepend" ]( this.icon );
  7748. },
  7749. _setOptions: function( options ) {
  7750. var newShowLabel = options.showLabel === undefined ?
  7751. this.options.showLabel :
  7752. options.showLabel,
  7753. newIcon = options.icon === undefined ? this.options.icon : options.icon;
  7754. if ( !newShowLabel && !newIcon ) {
  7755. options.showLabel = true;
  7756. }
  7757. this._super( options );
  7758. },
  7759. _setOption: function( key, value ) {
  7760. if ( key === "icon" ) {
  7761. if ( value ) {
  7762. this._updateIcon( key, value );
  7763. } else if ( this.icon ) {
  7764. this.icon.remove();
  7765. if ( this.iconSpace ) {
  7766. this.iconSpace.remove();
  7767. }
  7768. }
  7769. }
  7770. if ( key === "iconPosition" ) {
  7771. this._updateIcon( key, value );
  7772. }
  7773. // Make sure we can't end up with a button that has neither text nor icon
  7774. if ( key === "showLabel" ) {
  7775. this._toggleClass( "ui-button-icon-only", null, !value );
  7776. this._updateTooltip();
  7777. }
  7778. if ( key === "label" ) {
  7779. if ( this.isInput ) {
  7780. this.element.val( value );
  7781. } else {
  7782. // If there is an icon, append it, else nothing then append the value
  7783. // this avoids removal of the icon when setting label text
  7784. this.element.html( value );
  7785. if ( this.icon ) {
  7786. this._attachIcon( this.options.iconPosition );
  7787. this._attachIconSpace( this.options.iconPosition );
  7788. }
  7789. }
  7790. }
  7791. this._super( key, value );
  7792. if ( key === "disabled" ) {
  7793. this._toggleClass( null, "ui-state-disabled", value );
  7794. this.element[ 0 ].disabled = value;
  7795. if ( value ) {
  7796. this.element.blur();
  7797. }
  7798. }
  7799. },
  7800. refresh: function() {
  7801. // Make sure to only check disabled if its an element that supports this otherwise
  7802. // check for the disabled class to determine state
  7803. var isDisabled = this.element.is( "input, button" ) ?
  7804. this.element[ 0 ].disabled : this.element.hasClass( "ui-button-disabled" );
  7805. if ( isDisabled !== this.options.disabled ) {
  7806. this._setOptions( { disabled: isDisabled } );
  7807. }
  7808. this._updateTooltip();
  7809. }
  7810. } );
  7811. // DEPRECATED
  7812. if ( $.uiBackCompat !== false ) {
  7813. // Text and Icons options
  7814. $.widget( "ui.button", $.ui.button, {
  7815. options: {
  7816. text: true,
  7817. icons: {
  7818. primary: null,
  7819. secondary: null
  7820. }
  7821. },
  7822. _create: function() {
  7823. if ( this.options.showLabel && !this.options.text ) {
  7824. this.options.showLabel = this.options.text;
  7825. }
  7826. if ( !this.options.showLabel && this.options.text ) {
  7827. this.options.text = this.options.showLabel;
  7828. }
  7829. if ( !this.options.icon && ( this.options.icons.primary ||
  7830. this.options.icons.secondary ) ) {
  7831. if ( this.options.icons.primary ) {
  7832. this.options.icon = this.options.icons.primary;
  7833. } else {
  7834. this.options.icon = this.options.icons.secondary;
  7835. this.options.iconPosition = "end";
  7836. }
  7837. } else if ( this.options.icon ) {
  7838. this.options.icons.primary = this.options.icon;
  7839. }
  7840. this._super();
  7841. },
  7842. _setOption: function( key, value ) {
  7843. if ( key === "text" ) {
  7844. this._super( "showLabel", value );
  7845. return;
  7846. }
  7847. if ( key === "showLabel" ) {
  7848. this.options.text = value;
  7849. }
  7850. if ( key === "icon" ) {
  7851. this.options.icons.primary = value;
  7852. }
  7853. if ( key === "icons" ) {
  7854. if ( value.primary ) {
  7855. this._super( "icon", value.primary );
  7856. this._super( "iconPosition", "beginning" );
  7857. } else if ( value.secondary ) {
  7858. this._super( "icon", value.secondary );
  7859. this._super( "iconPosition", "end" );
  7860. }
  7861. }
  7862. this._superApply( arguments );
  7863. }
  7864. } );
  7865. $.fn.button = ( function( orig ) {
  7866. return function() {
  7867. if ( !this.length || ( this.length && this[ 0 ].tagName !== "INPUT" ) ||
  7868. ( this.length && this[ 0 ].tagName === "INPUT" && (
  7869. this.attr( "type" ) !== "checkbox" && this.attr( "type" ) !== "radio"
  7870. ) ) ) {
  7871. return orig.apply( this, arguments );
  7872. }
  7873. if ( !$.ui.checkboxradio ) {
  7874. $.error( "Checkboxradio widget missing" );
  7875. }
  7876. if ( arguments.length === 0 ) {
  7877. return this.checkboxradio( {
  7878. "icon": false
  7879. } );
  7880. }
  7881. return this.checkboxradio.apply( this, arguments );
  7882. };
  7883. } )( $.fn.button );
  7884. $.fn.buttonset = function() {
  7885. if ( !$.ui.controlgroup ) {
  7886. $.error( "Controlgroup widget missing" );
  7887. }
  7888. if ( arguments[ 0 ] === "option" && arguments[ 1 ] === "items" && arguments[ 2 ] ) {
  7889. return this.controlgroup.apply( this,
  7890. [ arguments[ 0 ], "items.button", arguments[ 2 ] ] );
  7891. }
  7892. if ( arguments[ 0 ] === "option" && arguments[ 1 ] === "items" ) {
  7893. return this.controlgroup.apply( this, [ arguments[ 0 ], "items.button" ] );
  7894. }
  7895. if ( typeof arguments[ 0 ] === "object" && arguments[ 0 ].items ) {
  7896. arguments[ 0 ].items = {
  7897. button: arguments[ 0 ].items
  7898. };
  7899. }
  7900. return this.controlgroup.apply( this, arguments );
  7901. };
  7902. }
  7903. var widgetsButton = $.ui.button;
  7904. // jscs:disable maximumLineLength
  7905. /* jscs:disable requireCamelCaseOrUpperCaseIdentifiers */
  7906. /*!
  7907. * jQuery UI Datepicker 1.12.0
  7908. * http://jqueryui.com
  7909. *
  7910. * Copyright jQuery Foundation and other contributors
  7911. * Released under the MIT license.
  7912. * http://jquery.org/license
  7913. */
  7914. //>>label: Datepicker
  7915. //>>group: Widgets
  7916. //>>description: Displays a calendar from an input or inline for selecting dates.
  7917. //>>docs: http://api.jqueryui.com/datepicker/
  7918. //>>demos: http://jqueryui.com/datepicker/
  7919. //>>css.structure: ../../themes/base/core.css
  7920. //>>css.structure: ../../themes/base/datepicker.css
  7921. //>>css.theme: ../../themes/base/theme.css
  7922. $.extend( $.ui, { datepicker: { version: "1.12.0" } } );
  7923. var datepicker_instActive;
  7924. function datepicker_getZindex( elem ) {
  7925. var position, value;
  7926. while ( elem.length && elem[ 0 ] !== document ) {
  7927. // Ignore z-index if position is set to a value where z-index is ignored by the browser
  7928. // This makes behavior of this function consistent across browsers
  7929. // WebKit always returns auto if the element is positioned
  7930. position = elem.css( "position" );
  7931. if ( position === "absolute" || position === "relative" || position === "fixed" ) {
  7932. // IE returns 0 when zIndex is not specified
  7933. // other browsers return a string
  7934. // we ignore the case of nested elements with an explicit value of 0
  7935. // <div style="z-index: -10;"><div style="z-index: 0;"></div></div>
  7936. value = parseInt( elem.css( "zIndex" ), 10 );
  7937. if ( !isNaN( value ) && value !== 0 ) {
  7938. return value;
  7939. }
  7940. }
  7941. elem = elem.parent();
  7942. }
  7943. return 0;
  7944. }
  7945. /* Date picker manager.
  7946. Use the singleton instance of this class, $.datepicker, to interact with the date picker.
  7947. Settings for (groups of) date pickers are maintained in an instance object,
  7948. allowing multiple different settings on the same page. */
  7949. function Datepicker() {
  7950. this._curInst = null; // The current instance in use
  7951. this._keyEvent = false; // If the last event was a key event
  7952. this._disabledInputs = []; // List of date picker inputs that have been disabled
  7953. this._datepickerShowing = false; // True if the popup picker is showing , false if not
  7954. this._inDialog = false; // True if showing within a "dialog", false if not
  7955. this._mainDivId = "ui-datepicker-div"; // The ID of the main datepicker division
  7956. this._inlineClass = "ui-datepicker-inline"; // The name of the inline marker class
  7957. this._appendClass = "ui-datepicker-append"; // The name of the append marker class
  7958. this._triggerClass = "ui-datepicker-trigger"; // The name of the trigger marker class
  7959. this._dialogClass = "ui-datepicker-dialog"; // The name of the dialog marker class
  7960. this._disableClass = "ui-datepicker-disabled"; // The name of the disabled covering marker class
  7961. this._unselectableClass = "ui-datepicker-unselectable"; // The name of the unselectable cell marker class
  7962. this._currentClass = "ui-datepicker-current-day"; // The name of the current day marker class
  7963. this._dayOverClass = "ui-datepicker-days-cell-over"; // The name of the day hover marker class
  7964. this.regional = []; // Available regional settings, indexed by language code
  7965. this.regional[ "" ] = { // Default regional settings
  7966. closeText: "Done", // Display text for close link
  7967. prevText: "Prev", // Display text for previous month link
  7968. nextText: "Next", // Display text for next month link
  7969. currentText: "Today", // Display text for current month link
  7970. monthNames: [ "January","February","March","April","May","June",
  7971. "July","August","September","October","November","December" ], // Names of months for drop-down and formatting
  7972. monthNamesShort: [ "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" ], // For formatting
  7973. dayNames: [ "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday" ], // For formatting
  7974. dayNamesShort: [ "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" ], // For formatting
  7975. dayNamesMin: [ "Su","Mo","Tu","We","Th","Fr","Sa" ], // Column headings for days starting at Sunday
  7976. weekHeader: "Wk", // Column header for week of the year
  7977. dateFormat: "mm/dd/yy", // See format options on parseDate
  7978. firstDay: 0, // The first day of the week, Sun = 0, Mon = 1, ...
  7979. isRTL: false, // True if right-to-left language, false if left-to-right
  7980. showMonthAfterYear: false, // True if the year select precedes month, false for month then year
  7981. yearSuffix: "" // Additional text to append to the year in the month headers
  7982. };
  7983. this._defaults = { // Global defaults for all the date picker instances
  7984. showOn: "focus", // "focus" for popup on focus,
  7985. // "button" for trigger button, or "both" for either
  7986. showAnim: "fadeIn", // Name of jQuery animation for popup
  7987. showOptions: {}, // Options for enhanced animations
  7988. defaultDate: null, // Used when field is blank: actual date,
  7989. // +/-number for offset from today, null for today
  7990. appendText: "", // Display text following the input box, e.g. showing the format
  7991. buttonText: "...", // Text for trigger button
  7992. buttonImage: "", // URL for trigger button image
  7993. buttonImageOnly: false, // True if the image appears alone, false if it appears on a button
  7994. hideIfNoPrevNext: false, // True to hide next/previous month links
  7995. // if not applicable, false to just disable them
  7996. navigationAsDateFormat: false, // True if date formatting applied to prev/today/next links
  7997. gotoCurrent: false, // True if today link goes back to current selection instead
  7998. changeMonth: false, // True if month can be selected directly, false if only prev/next
  7999. changeYear: false, // True if year can be selected directly, false if only prev/next
  8000. yearRange: "c-10:c+10", // Range of years to display in drop-down,
  8001. // either relative to today's year (-nn:+nn), relative to currently displayed year
  8002. // (c-nn:c+nn), absolute (nnnn:nnnn), or a combination of the above (nnnn:-n)
  8003. showOtherMonths: false, // True to show dates in other months, false to leave blank
  8004. selectOtherMonths: false, // True to allow selection of dates in other months, false for unselectable
  8005. showWeek: false, // True to show week of the year, false to not show it
  8006. calculateWeek: this.iso8601Week, // How to calculate the week of the year,
  8007. // takes a Date and returns the number of the week for it
  8008. shortYearCutoff: "+10", // Short year values < this are in the current century,
  8009. // > this are in the previous century,
  8010. // string value starting with "+" for current year + value
  8011. minDate: null, // The earliest selectable date, or null for no limit
  8012. maxDate: null, // The latest selectable date, or null for no limit
  8013. duration: "fast", // Duration of display/closure
  8014. beforeShowDay: null, // Function that takes a date and returns an array with
  8015. // [0] = true if selectable, false if not, [1] = custom CSS class name(s) or "",
  8016. // [2] = cell title (optional), e.g. $.datepicker.noWeekends
  8017. beforeShow: null, // Function that takes an input field and
  8018. // returns a set of custom settings for the date picker
  8019. onSelect: null, // Define a callback function when a date is selected
  8020. onChangeMonthYear: null, // Define a callback function when the month or year is changed
  8021. onClose: null, // Define a callback function when the datepicker is closed
  8022. numberOfMonths: 1, // Number of months to show at a time
  8023. showCurrentAtPos: 0, // The position in multipe months at which to show the current month (starting at 0)
  8024. stepMonths: 1, // Number of months to step back/forward
  8025. stepBigMonths: 12, // Number of months to step back/forward for the big links
  8026. altField: "", // Selector for an alternate field to store selected dates into
  8027. altFormat: "", // The date format to use for the alternate field
  8028. constrainInput: true, // The input is constrained by the current date format
  8029. showButtonPanel: false, // True to show button panel, false to not show it
  8030. autoSize: false, // True to size the input for the date format, false to leave as is
  8031. disabled: false // The initial disabled state
  8032. };
  8033. $.extend( this._defaults, this.regional[ "" ] );
  8034. this.regional.en = $.extend( true, {}, this.regional[ "" ] );
  8035. this.regional[ "en-US" ] = $.extend( true, {}, this.regional.en );
  8036. this.dpDiv = datepicker_bindHover( $( "<div id='" + this._mainDivId + "' class='ui-datepicker ui-widget ui-widget-content ui-helper-clearfix ui-corner-all'></div>" ) );
  8037. }
  8038. $.extend( Datepicker.prototype, {
  8039. /* Class name added to elements to indicate already configured with a date picker. */
  8040. markerClassName: "hasDatepicker",
  8041. //Keep track of the maximum number of rows displayed (see #7043)
  8042. maxRows: 4,
  8043. // TODO rename to "widget" when switching to widget factory
  8044. _widgetDatepicker: function() {
  8045. return this.dpDiv;
  8046. },
  8047. /* Override the default settings for all instances of the date picker.
  8048. * @param settings object - the new settings to use as defaults (anonymous object)
  8049. * @return the manager object
  8050. */
  8051. setDefaults: function( settings ) {
  8052. datepicker_extendRemove( this._defaults, settings || {} );
  8053. return this;
  8054. },
  8055. /* Attach the date picker to a jQuery selection.
  8056. * @param target element - the target input field or division or span
  8057. * @param settings object - the new settings to use for this date picker instance (anonymous)
  8058. */
  8059. _attachDatepicker: function( target, settings ) {
  8060. var nodeName, inline, inst;
  8061. nodeName = target.nodeName.toLowerCase();
  8062. inline = ( nodeName === "div" || nodeName === "span" );
  8063. if ( !target.id ) {
  8064. this.uuid += 1;
  8065. target.id = "dp" + this.uuid;
  8066. }
  8067. inst = this._newInst( $( target ), inline );
  8068. inst.settings = $.extend( {}, settings || {} );
  8069. if ( nodeName === "input" ) {
  8070. this._connectDatepicker( target, inst );
  8071. } else if ( inline ) {
  8072. this._inlineDatepicker( target, inst );
  8073. }
  8074. },
  8075. /* Create a new instance object. */
  8076. _newInst: function( target, inline ) {
  8077. var id = target[ 0 ].id.replace( /([^A-Za-z0-9_\-])/g, "\\\\$1" ); // escape jQuery meta chars
  8078. return { id: id, input: target, // associated target
  8079. selectedDay: 0, selectedMonth: 0, selectedYear: 0, // current selection
  8080. drawMonth: 0, drawYear: 0, // month being drawn
  8081. inline: inline, // is datepicker inline or not
  8082. dpDiv: ( !inline ? this.dpDiv : // presentation div
  8083. datepicker_bindHover( $( "<div class='" + this._inlineClass + " ui-datepicker ui-widget ui-widget-content ui-helper-clearfix ui-corner-all'></div>" ) ) ) };
  8084. },
  8085. /* Attach the date picker to an input field. */
  8086. _connectDatepicker: function( target, inst ) {
  8087. var input = $( target );
  8088. inst.append = $( [] );
  8089. inst.trigger = $( [] );
  8090. if ( input.hasClass( this.markerClassName ) ) {
  8091. return;
  8092. }
  8093. this._attachments( input, inst );
  8094. input.addClass( this.markerClassName ).on( "keydown", this._doKeyDown ).
  8095. on( "keypress", this._doKeyPress ).on( "keyup", this._doKeyUp );
  8096. this._autoSize( inst );
  8097. $.data( target, "datepicker", inst );
  8098. //If disabled option is true, disable the datepicker once it has been attached to the input (see ticket #5665)
  8099. if ( inst.settings.disabled ) {
  8100. this._disableDatepicker( target );
  8101. }
  8102. },
  8103. /* Make attachments based on settings. */
  8104. _attachments: function( input, inst ) {
  8105. var showOn, buttonText, buttonImage,
  8106. appendText = this._get( inst, "appendText" ),
  8107. isRTL = this._get( inst, "isRTL" );
  8108. if ( inst.append ) {
  8109. inst.append.remove();
  8110. }
  8111. if ( appendText ) {
  8112. inst.append = $( "<span class='" + this._appendClass + "'>" + appendText + "</span>" );
  8113. input[ isRTL ? "before" : "after" ]( inst.append );
  8114. }
  8115. input.off( "focus", this._showDatepicker );
  8116. if ( inst.trigger ) {
  8117. inst.trigger.remove();
  8118. }
  8119. showOn = this._get( inst, "showOn" );
  8120. if ( showOn === "focus" || showOn === "both" ) { // pop-up date picker when in the marked field
  8121. input.on( "focus", this._showDatepicker );
  8122. }
  8123. if ( showOn === "button" || showOn === "both" ) { // pop-up date picker when button clicked
  8124. buttonText = this._get( inst, "buttonText" );
  8125. buttonImage = this._get( inst, "buttonImage" );
  8126. inst.trigger = $( this._get( inst, "buttonImageOnly" ) ?
  8127. $( "<img/>" ).addClass( this._triggerClass ).
  8128. attr( { src: buttonImage, alt: buttonText, title: buttonText } ) :
  8129. $( "<button type='button'></button>" ).addClass( this._triggerClass ).
  8130. html( !buttonImage ? buttonText : $( "<img/>" ).attr(
  8131. { src:buttonImage, alt:buttonText, title:buttonText } ) ) );
  8132. input[ isRTL ? "before" : "after" ]( inst.trigger );
  8133. inst.trigger.on( "click", function() {
  8134. if ( $.datepicker._datepickerShowing && $.datepicker._lastInput === input[ 0 ] ) {
  8135. $.datepicker._hideDatepicker();
  8136. } else if ( $.datepicker._datepickerShowing && $.datepicker._lastInput !== input[ 0 ] ) {
  8137. $.datepicker._hideDatepicker();
  8138. $.datepicker._showDatepicker( input[ 0 ] );
  8139. } else {
  8140. $.datepicker._showDatepicker( input[ 0 ] );
  8141. }
  8142. return false;
  8143. } );
  8144. }
  8145. },
  8146. /* Apply the maximum length for the date format. */
  8147. _autoSize: function( inst ) {
  8148. if ( this._get( inst, "autoSize" ) && !inst.inline ) {
  8149. var findMax, max, maxI, i,
  8150. date = new Date( 2009, 12 - 1, 20 ), // Ensure double digits
  8151. dateFormat = this._get( inst, "dateFormat" );
  8152. if ( dateFormat.match( /[DM]/ ) ) {
  8153. findMax = function( names ) {
  8154. max = 0;
  8155. maxI = 0;
  8156. for ( i = 0; i < names.length; i++ ) {
  8157. if ( names[ i ].length > max ) {
  8158. max = names[ i ].length;
  8159. maxI = i;
  8160. }
  8161. }
  8162. return maxI;
  8163. };
  8164. date.setMonth( findMax( this._get( inst, ( dateFormat.match( /MM/ ) ?
  8165. "monthNames" : "monthNamesShort" ) ) ) );
  8166. date.setDate( findMax( this._get( inst, ( dateFormat.match( /DD/ ) ?
  8167. "dayNames" : "dayNamesShort" ) ) ) + 20 - date.getDay() );
  8168. }
  8169. inst.input.attr( "size", this._formatDate( inst, date ).length );
  8170. }
  8171. },
  8172. /* Attach an inline date picker to a div. */
  8173. _inlineDatepicker: function( target, inst ) {
  8174. var divSpan = $( target );
  8175. if ( divSpan.hasClass( this.markerClassName ) ) {
  8176. return;
  8177. }
  8178. divSpan.addClass( this.markerClassName ).append( inst.dpDiv );
  8179. $.data( target, "datepicker", inst );
  8180. this._setDate( inst, this._getDefaultDate( inst ), true );
  8181. this._updateDatepicker( inst );
  8182. this._updateAlternate( inst );
  8183. //If disabled option is true, disable the datepicker before showing it (see ticket #5665)
  8184. if ( inst.settings.disabled ) {
  8185. this._disableDatepicker( target );
  8186. }
  8187. // Set display:block in place of inst.dpDiv.show() which won't work on disconnected elements
  8188. // http://bugs.jqueryui.com/ticket/7552 - A Datepicker created on a detached div has zero height
  8189. inst.dpDiv.css( "display", "block" );
  8190. },
  8191. /* Pop-up the date picker in a "dialog" box.
  8192. * @param input element - ignored
  8193. * @param date string or Date - the initial date to display
  8194. * @param onSelect function - the function to call when a date is selected
  8195. * @param settings object - update the dialog date picker instance's settings (anonymous object)
  8196. * @param pos int[2] - coordinates for the dialog's position within the screen or
  8197. * event - with x/y coordinates or
  8198. * leave empty for default (screen centre)
  8199. * @return the manager object
  8200. */
  8201. _dialogDatepicker: function( input, date, onSelect, settings, pos ) {
  8202. var id, browserWidth, browserHeight, scrollX, scrollY,
  8203. inst = this._dialogInst; // internal instance
  8204. if ( !inst ) {
  8205. this.uuid += 1;
  8206. id = "dp" + this.uuid;
  8207. this._dialogInput = $( "<input type='text' id='" + id +
  8208. "' style='position: absolute; top: -100px; width: 0px;'/>" );
  8209. this._dialogInput.on( "keydown", this._doKeyDown );
  8210. $( "body" ).append( this._dialogInput );
  8211. inst = this._dialogInst = this._newInst( this._dialogInput, false );
  8212. inst.settings = {};
  8213. $.data( this._dialogInput[ 0 ], "datepicker", inst );
  8214. }
  8215. datepicker_extendRemove( inst.settings, settings || {} );
  8216. date = ( date && date.constructor === Date ? this._formatDate( inst, date ) : date );
  8217. this._dialogInput.val( date );
  8218. this._pos = ( pos ? ( pos.length ? pos : [ pos.pageX, pos.pageY ] ) : null );
  8219. if ( !this._pos ) {
  8220. browserWidth = document.documentElement.clientWidth;
  8221. browserHeight = document.documentElement.clientHeight;
  8222. scrollX = document.documentElement.scrollLeft || document.body.scrollLeft;
  8223. scrollY = document.documentElement.scrollTop || document.body.scrollTop;
  8224. this._pos = // should use actual width/height below
  8225. [ ( browserWidth / 2 ) - 100 + scrollX, ( browserHeight / 2 ) - 150 + scrollY ];
  8226. }
  8227. // Move input on screen for focus, but hidden behind dialog
  8228. this._dialogInput.css( "left", ( this._pos[ 0 ] + 20 ) + "px" ).css( "top", this._pos[ 1 ] + "px" );
  8229. inst.settings.onSelect = onSelect;
  8230. this._inDialog = true;
  8231. this.dpDiv.addClass( this._dialogClass );
  8232. this._showDatepicker( this._dialogInput[ 0 ] );
  8233. if ( $.blockUI ) {
  8234. $.blockUI( this.dpDiv );
  8235. }
  8236. $.data( this._dialogInput[ 0 ], "datepicker", inst );
  8237. return this;
  8238. },
  8239. /* Detach a datepicker from its control.
  8240. * @param target element - the target input field or division or span
  8241. */
  8242. _destroyDatepicker: function( target ) {
  8243. var nodeName,
  8244. $target = $( target ),
  8245. inst = $.data( target, "datepicker" );
  8246. if ( !$target.hasClass( this.markerClassName ) ) {
  8247. return;
  8248. }
  8249. nodeName = target.nodeName.toLowerCase();
  8250. $.removeData( target, "datepicker" );
  8251. if ( nodeName === "input" ) {
  8252. inst.append.remove();
  8253. inst.trigger.remove();
  8254. $target.removeClass( this.markerClassName ).
  8255. off( "focus", this._showDatepicker ).
  8256. off( "keydown", this._doKeyDown ).
  8257. off( "keypress", this._doKeyPress ).
  8258. off( "keyup", this._doKeyUp );
  8259. } else if ( nodeName === "div" || nodeName === "span" ) {
  8260. $target.removeClass( this.markerClassName ).empty();
  8261. }
  8262. if ( datepicker_instActive === inst ) {
  8263. datepicker_instActive = null;
  8264. }
  8265. },
  8266. /* Enable the date picker to a jQuery selection.
  8267. * @param target element - the target input field or division or span
  8268. */
  8269. _enableDatepicker: function( target ) {
  8270. var nodeName, inline,
  8271. $target = $( target ),
  8272. inst = $.data( target, "datepicker" );
  8273. if ( !$target.hasClass( this.markerClassName ) ) {
  8274. return;
  8275. }
  8276. nodeName = target.nodeName.toLowerCase();
  8277. if ( nodeName === "input" ) {
  8278. target.disabled = false;
  8279. inst.trigger.filter( "button" ).
  8280. each( function() { this.disabled = false; } ).end().
  8281. filter( "img" ).css( { opacity: "1.0", cursor: "" } );
  8282. } else if ( nodeName === "div" || nodeName === "span" ) {
  8283. inline = $target.children( "." + this._inlineClass );
  8284. inline.children().removeClass( "ui-state-disabled" );
  8285. inline.find( "select.ui-datepicker-month, select.ui-datepicker-year" ).
  8286. prop( "disabled", false );
  8287. }
  8288. this._disabledInputs = $.map( this._disabledInputs,
  8289. function( value ) { return ( value === target ? null : value ); } ); // delete entry
  8290. },
  8291. /* Disable the date picker to a jQuery selection.
  8292. * @param target element - the target input field or division or span
  8293. */
  8294. _disableDatepicker: function( target ) {
  8295. var nodeName, inline,
  8296. $target = $( target ),
  8297. inst = $.data( target, "datepicker" );
  8298. if ( !$target.hasClass( this.markerClassName ) ) {
  8299. return;
  8300. }
  8301. nodeName = target.nodeName.toLowerCase();
  8302. if ( nodeName === "input" ) {
  8303. target.disabled = true;
  8304. inst.trigger.filter( "button" ).
  8305. each( function() { this.disabled = true; } ).end().
  8306. filter( "img" ).css( { opacity: "0.5", cursor: "default" } );
  8307. } else if ( nodeName === "div" || nodeName === "span" ) {
  8308. inline = $target.children( "." + this._inlineClass );
  8309. inline.children().addClass( "ui-state-disabled" );
  8310. inline.find( "select.ui-datepicker-month, select.ui-datepicker-year" ).
  8311. prop( "disabled", true );
  8312. }
  8313. this._disabledInputs = $.map( this._disabledInputs,
  8314. function( value ) { return ( value === target ? null : value ); } ); // delete entry
  8315. this._disabledInputs[ this._disabledInputs.length ] = target;
  8316. },
  8317. /* Is the first field in a jQuery collection disabled as a datepicker?
  8318. * @param target element - the target input field or division or span
  8319. * @return boolean - true if disabled, false if enabled
  8320. */
  8321. _isDisabledDatepicker: function( target ) {
  8322. if ( !target ) {
  8323. return false;
  8324. }
  8325. for ( var i = 0; i < this._disabledInputs.length; i++ ) {
  8326. if ( this._disabledInputs[ i ] === target ) {
  8327. return true;
  8328. }
  8329. }
  8330. return false;
  8331. },
  8332. /* Retrieve the instance data for the target control.
  8333. * @param target element - the target input field or division or span
  8334. * @return object - the associated instance data
  8335. * @throws error if a jQuery problem getting data
  8336. */
  8337. _getInst: function( target ) {
  8338. try {
  8339. return $.data( target, "datepicker" );
  8340. }
  8341. catch ( err ) {
  8342. throw "Missing instance data for this datepicker";
  8343. }
  8344. },
  8345. /* Update or retrieve the settings for a date picker attached to an input field or division.
  8346. * @param target element - the target input field or division or span
  8347. * @param name object - the new settings to update or
  8348. * string - the name of the setting to change or retrieve,
  8349. * when retrieving also "all" for all instance settings or
  8350. * "defaults" for all global defaults
  8351. * @param value any - the new value for the setting
  8352. * (omit if above is an object or to retrieve a value)
  8353. */
  8354. _optionDatepicker: function( target, name, value ) {
  8355. var settings, date, minDate, maxDate,
  8356. inst = this._getInst( target );
  8357. if ( arguments.length === 2 && typeof name === "string" ) {
  8358. return ( name === "defaults" ? $.extend( {}, $.datepicker._defaults ) :
  8359. ( inst ? ( name === "all" ? $.extend( {}, inst.settings ) :
  8360. this._get( inst, name ) ) : null ) );
  8361. }
  8362. settings = name || {};
  8363. if ( typeof name === "string" ) {
  8364. settings = {};
  8365. settings[ name ] = value;
  8366. }
  8367. if ( inst ) {
  8368. if ( this._curInst === inst ) {
  8369. this._hideDatepicker();
  8370. }
  8371. date = this._getDateDatepicker( target, true );
  8372. minDate = this._getMinMaxDate( inst, "min" );
  8373. maxDate = this._getMinMaxDate( inst, "max" );
  8374. datepicker_extendRemove( inst.settings, settings );
  8375. // reformat the old minDate/maxDate values if dateFormat changes and a new minDate/maxDate isn't provided
  8376. if ( minDate !== null && settings.dateFormat !== undefined && settings.minDate === undefined ) {
  8377. inst.settings.minDate = this._formatDate( inst, minDate );
  8378. }
  8379. if ( maxDate !== null && settings.dateFormat !== undefined && settings.maxDate === undefined ) {
  8380. inst.settings.maxDate = this._formatDate( inst, maxDate );
  8381. }
  8382. if ( "disabled" in settings ) {
  8383. if ( settings.disabled ) {
  8384. this._disableDatepicker( target );
  8385. } else {
  8386. this._enableDatepicker( target );
  8387. }
  8388. }
  8389. this._attachments( $( target ), inst );
  8390. this._autoSize( inst );
  8391. this._setDate( inst, date );
  8392. this._updateAlternate( inst );
  8393. this._updateDatepicker( inst );
  8394. }
  8395. },
  8396. // Change method deprecated
  8397. _changeDatepicker: function( target, name, value ) {
  8398. this._optionDatepicker( target, name, value );
  8399. },
  8400. /* Redraw the date picker attached to an input field or division.
  8401. * @param target element - the target input field or division or span
  8402. */
  8403. _refreshDatepicker: function( target ) {
  8404. var inst = this._getInst( target );
  8405. if ( inst ) {
  8406. this._updateDatepicker( inst );
  8407. }
  8408. },
  8409. /* Set the dates for a jQuery selection.
  8410. * @param target element - the target input field or division or span
  8411. * @param date Date - the new date
  8412. */
  8413. _setDateDatepicker: function( target, date ) {
  8414. var inst = this._getInst( target );
  8415. if ( inst ) {
  8416. this._setDate( inst, date );
  8417. this._updateDatepicker( inst );
  8418. this._updateAlternate( inst );
  8419. }
  8420. },
  8421. /* Get the date(s) for the first entry in a jQuery selection.
  8422. * @param target element - the target input field or division or span
  8423. * @param noDefault boolean - true if no default date is to be used
  8424. * @return Date - the current date
  8425. */
  8426. _getDateDatepicker: function( target, noDefault ) {
  8427. var inst = this._getInst( target );
  8428. if ( inst && !inst.inline ) {
  8429. this._setDateFromField( inst, noDefault );
  8430. }
  8431. return ( inst ? this._getDate( inst ) : null );
  8432. },
  8433. /* Handle keystrokes. */
  8434. _doKeyDown: function( event ) {
  8435. var onSelect, dateStr, sel,
  8436. inst = $.datepicker._getInst( event.target ),
  8437. handled = true,
  8438. isRTL = inst.dpDiv.is( ".ui-datepicker-rtl" );
  8439. inst._keyEvent = true;
  8440. if ( $.datepicker._datepickerShowing ) {
  8441. switch ( event.keyCode ) {
  8442. case 9: $.datepicker._hideDatepicker();
  8443. handled = false;
  8444. break; // hide on tab out
  8445. case 13: sel = $( "td." + $.datepicker._dayOverClass + ":not(." +
  8446. $.datepicker._currentClass + ")", inst.dpDiv );
  8447. if ( sel[ 0 ] ) {
  8448. $.datepicker._selectDay( event.target, inst.selectedMonth, inst.selectedYear, sel[ 0 ] );
  8449. }
  8450. onSelect = $.datepicker._get( inst, "onSelect" );
  8451. if ( onSelect ) {
  8452. dateStr = $.datepicker._formatDate( inst );
  8453. // Trigger custom callback
  8454. onSelect.apply( ( inst.input ? inst.input[ 0 ] : null ), [ dateStr, inst ] );
  8455. } else {
  8456. $.datepicker._hideDatepicker();
  8457. }
  8458. return false; // don't submit the form
  8459. case 27: $.datepicker._hideDatepicker();
  8460. break; // hide on escape
  8461. case 33: $.datepicker._adjustDate( event.target, ( event.ctrlKey ?
  8462. -$.datepicker._get( inst, "stepBigMonths" ) :
  8463. -$.datepicker._get( inst, "stepMonths" ) ), "M" );
  8464. break; // previous month/year on page up/+ ctrl
  8465. case 34: $.datepicker._adjustDate( event.target, ( event.ctrlKey ?
  8466. +$.datepicker._get( inst, "stepBigMonths" ) :
  8467. +$.datepicker._get( inst, "stepMonths" ) ), "M" );
  8468. break; // next month/year on page down/+ ctrl
  8469. case 35: if ( event.ctrlKey || event.metaKey ) {
  8470. $.datepicker._clearDate( event.target );
  8471. }
  8472. handled = event.ctrlKey || event.metaKey;
  8473. break; // clear on ctrl or command +end
  8474. case 36: if ( event.ctrlKey || event.metaKey ) {
  8475. $.datepicker._gotoToday( event.target );
  8476. }
  8477. handled = event.ctrlKey || event.metaKey;
  8478. break; // current on ctrl or command +home
  8479. case 37: if ( event.ctrlKey || event.metaKey ) {
  8480. $.datepicker._adjustDate( event.target, ( isRTL ? +1 : -1 ), "D" );
  8481. }
  8482. handled = event.ctrlKey || event.metaKey;
  8483. // -1 day on ctrl or command +left
  8484. if ( event.originalEvent.altKey ) {
  8485. $.datepicker._adjustDate( event.target, ( event.ctrlKey ?
  8486. -$.datepicker._get( inst, "stepBigMonths" ) :
  8487. -$.datepicker._get( inst, "stepMonths" ) ), "M" );
  8488. }
  8489. // next month/year on alt +left on Mac
  8490. break;
  8491. case 38: if ( event.ctrlKey || event.metaKey ) {
  8492. $.datepicker._adjustDate( event.target, -7, "D" );
  8493. }
  8494. handled = event.ctrlKey || event.metaKey;
  8495. break; // -1 week on ctrl or command +up
  8496. case 39: if ( event.ctrlKey || event.metaKey ) {
  8497. $.datepicker._adjustDate( event.target, ( isRTL ? -1 : +1 ), "D" );
  8498. }
  8499. handled = event.ctrlKey || event.metaKey;
  8500. // +1 day on ctrl or command +right
  8501. if ( event.originalEvent.altKey ) {
  8502. $.datepicker._adjustDate( event.target, ( event.ctrlKey ?
  8503. +$.datepicker._get( inst, "stepBigMonths" ) :
  8504. +$.datepicker._get( inst, "stepMonths" ) ), "M" );
  8505. }
  8506. // next month/year on alt +right
  8507. break;
  8508. case 40: if ( event.ctrlKey || event.metaKey ) {
  8509. $.datepicker._adjustDate( event.target, +7, "D" );
  8510. }
  8511. handled = event.ctrlKey || event.metaKey;
  8512. break; // +1 week on ctrl or command +down
  8513. default: handled = false;
  8514. }
  8515. } else if ( event.keyCode === 36 && event.ctrlKey ) { // display the date picker on ctrl+home
  8516. $.datepicker._showDatepicker( this );
  8517. } else {
  8518. handled = false;
  8519. }
  8520. if ( handled ) {
  8521. event.preventDefault();
  8522. event.stopPropagation();
  8523. }
  8524. },
  8525. /* Filter entered characters - based on date format. */
  8526. _doKeyPress: function( event ) {
  8527. var chars, chr,
  8528. inst = $.datepicker._getInst( event.target );
  8529. if ( $.datepicker._get( inst, "constrainInput" ) ) {
  8530. chars = $.datepicker._possibleChars( $.datepicker._get( inst, "dateFormat" ) );
  8531. chr = String.fromCharCode( event.charCode == null ? event.keyCode : event.charCode );
  8532. return event.ctrlKey || event.metaKey || ( chr < " " || !chars || chars.indexOf( chr ) > -1 );
  8533. }
  8534. },
  8535. /* Synchronise manual entry and field/alternate field. */
  8536. _doKeyUp: function( event ) {
  8537. var date,
  8538. inst = $.datepicker._getInst( event.target );
  8539. if ( inst.input.val() !== inst.lastVal ) {
  8540. try {
  8541. date = $.datepicker.parseDate( $.datepicker._get( inst, "dateFormat" ),
  8542. ( inst.input ? inst.input.val() : null ),
  8543. $.datepicker._getFormatConfig( inst ) );
  8544. if ( date ) { // only if valid
  8545. $.datepicker._setDateFromField( inst );
  8546. $.datepicker._updateAlternate( inst );
  8547. $.datepicker._updateDatepicker( inst );
  8548. }
  8549. }
  8550. catch ( err ) {
  8551. }
  8552. }
  8553. return true;
  8554. },
  8555. /* Pop-up the date picker for a given input field.
  8556. * If false returned from beforeShow event handler do not show.
  8557. * @param input element - the input field attached to the date picker or
  8558. * event - if triggered by focus
  8559. */
  8560. _showDatepicker: function( input ) {
  8561. input = input.target || input;
  8562. if ( input.nodeName.toLowerCase() !== "input" ) { // find from button/image trigger
  8563. input = $( "input", input.parentNode )[ 0 ];
  8564. }
  8565. if ( $.datepicker._isDisabledDatepicker( input ) || $.datepicker._lastInput === input ) { // already here
  8566. return;
  8567. }
  8568. var inst, beforeShow, beforeShowSettings, isFixed,
  8569. offset, showAnim, duration;
  8570. inst = $.datepicker._getInst( input );
  8571. if ( $.datepicker._curInst && $.datepicker._curInst !== inst ) {
  8572. $.datepicker._curInst.dpDiv.stop( true, true );
  8573. if ( inst && $.datepicker._datepickerShowing ) {
  8574. $.datepicker._hideDatepicker( $.datepicker._curInst.input[ 0 ] );
  8575. }
  8576. }
  8577. beforeShow = $.datepicker._get( inst, "beforeShow" );
  8578. beforeShowSettings = beforeShow ? beforeShow.apply( input, [ input, inst ] ) : {};
  8579. if ( beforeShowSettings === false ) {
  8580. return;
  8581. }
  8582. datepicker_extendRemove( inst.settings, beforeShowSettings );
  8583. inst.lastVal = null;
  8584. $.datepicker._lastInput = input;
  8585. $.datepicker._setDateFromField( inst );
  8586. if ( $.datepicker._inDialog ) { // hide cursor
  8587. input.value = "";
  8588. }
  8589. if ( !$.datepicker._pos ) { // position below input
  8590. $.datepicker._pos = $.datepicker._findPos( input );
  8591. $.datepicker._pos[ 1 ] += input.offsetHeight; // add the height
  8592. }
  8593. isFixed = false;
  8594. $( input ).parents().each( function() {
  8595. isFixed |= $( this ).css( "position" ) === "fixed";
  8596. return !isFixed;
  8597. } );
  8598. offset = { left: $.datepicker._pos[ 0 ], top: $.datepicker._pos[ 1 ] };
  8599. $.datepicker._pos = null;
  8600. //to avoid flashes on Firefox
  8601. inst.dpDiv.empty();
  8602. // determine sizing offscreen
  8603. inst.dpDiv.css( { position: "absolute", display: "block", top: "-1000px" } );
  8604. $.datepicker._updateDatepicker( inst );
  8605. // fix width for dynamic number of date pickers
  8606. // and adjust position before showing
  8607. offset = $.datepicker._checkOffset( inst, offset, isFixed );
  8608. inst.dpDiv.css( { position: ( $.datepicker._inDialog && $.blockUI ?
  8609. "static" : ( isFixed ? "fixed" : "absolute" ) ), display: "none",
  8610. left: offset.left + "px", top: offset.top + "px" } );
  8611. if ( !inst.inline ) {
  8612. showAnim = $.datepicker._get( inst, "showAnim" );
  8613. duration = $.datepicker._get( inst, "duration" );
  8614. inst.dpDiv.css( "z-index", datepicker_getZindex( $( input ) ) + 1 );
  8615. $.datepicker._datepickerShowing = true;
  8616. if ( $.effects && $.effects.effect[ showAnim ] ) {
  8617. inst.dpDiv.show( showAnim, $.datepicker._get( inst, "showOptions" ), duration );
  8618. } else {
  8619. inst.dpDiv[ showAnim || "show" ]( showAnim ? duration : null );
  8620. }
  8621. if ( $.datepicker._shouldFocusInput( inst ) ) {
  8622. inst.input.trigger( "focus" );
  8623. }
  8624. $.datepicker._curInst = inst;
  8625. }
  8626. },
  8627. /* Generate the date picker content. */
  8628. _updateDatepicker: function( inst ) {
  8629. this.maxRows = 4; //Reset the max number of rows being displayed (see #7043)
  8630. datepicker_instActive = inst; // for delegate hover events
  8631. inst.dpDiv.empty().append( this._generateHTML( inst ) );
  8632. this._attachHandlers( inst );
  8633. var origyearshtml,
  8634. numMonths = this._getNumberOfMonths( inst ),
  8635. cols = numMonths[ 1 ],
  8636. width = 17,
  8637. activeCell = inst.dpDiv.find( "." + this._dayOverClass + " a" );
  8638. if ( activeCell.length > 0 ) {
  8639. datepicker_handleMouseover.apply( activeCell.get( 0 ) );
  8640. }
  8641. inst.dpDiv.removeClass( "ui-datepicker-multi-2 ui-datepicker-multi-3 ui-datepicker-multi-4" ).width( "" );
  8642. if ( cols > 1 ) {
  8643. inst.dpDiv.addClass( "ui-datepicker-multi-" + cols ).css( "width", ( width * cols ) + "em" );
  8644. }
  8645. inst.dpDiv[ ( numMonths[ 0 ] !== 1 || numMonths[ 1 ] !== 1 ? "add" : "remove" ) +
  8646. "Class" ]( "ui-datepicker-multi" );
  8647. inst.dpDiv[ ( this._get( inst, "isRTL" ) ? "add" : "remove" ) +
  8648. "Class" ]( "ui-datepicker-rtl" );
  8649. if ( inst === $.datepicker._curInst && $.datepicker._datepickerShowing && $.datepicker._shouldFocusInput( inst ) ) {
  8650. inst.input.trigger( "focus" );
  8651. }
  8652. // Deffered render of the years select (to avoid flashes on Firefox)
  8653. if ( inst.yearshtml ) {
  8654. origyearshtml = inst.yearshtml;
  8655. setTimeout( function() {
  8656. //assure that inst.yearshtml didn't change.
  8657. if ( origyearshtml === inst.yearshtml && inst.yearshtml ) {
  8658. inst.dpDiv.find( "select.ui-datepicker-year:first" ).replaceWith( inst.yearshtml );
  8659. }
  8660. origyearshtml = inst.yearshtml = null;
  8661. }, 0 );
  8662. }
  8663. },
  8664. // #6694 - don't focus the input if it's already focused
  8665. // this breaks the change event in IE
  8666. // Support: IE and jQuery <1.9
  8667. _shouldFocusInput: function( inst ) {
  8668. return inst.input && inst.input.is( ":visible" ) && !inst.input.is( ":disabled" ) && !inst.input.is( ":focus" );
  8669. },
  8670. /* Check positioning to remain on screen. */
  8671. _checkOffset: function( inst, offset, isFixed ) {
  8672. var dpWidth = inst.dpDiv.outerWidth(),
  8673. dpHeight = inst.dpDiv.outerHeight(),
  8674. inputWidth = inst.input ? inst.input.outerWidth() : 0,
  8675. inputHeight = inst.input ? inst.input.outerHeight() : 0,
  8676. viewWidth = document.documentElement.clientWidth + ( isFixed ? 0 : $( document ).scrollLeft() ),
  8677. viewHeight = document.documentElement.clientHeight + ( isFixed ? 0 : $( document ).scrollTop() );
  8678. offset.left -= ( this._get( inst, "isRTL" ) ? ( dpWidth - inputWidth ) : 0 );
  8679. offset.left -= ( isFixed && offset.left === inst.input.offset().left ) ? $( document ).scrollLeft() : 0;
  8680. offset.top -= ( isFixed && offset.top === ( inst.input.offset().top + inputHeight ) ) ? $( document ).scrollTop() : 0;
  8681. // Now check if datepicker is showing outside window viewport - move to a better place if so.
  8682. offset.left -= Math.min( offset.left, ( offset.left + dpWidth > viewWidth && viewWidth > dpWidth ) ?
  8683. Math.abs( offset.left + dpWidth - viewWidth ) : 0 );
  8684. offset.top -= Math.min( offset.top, ( offset.top + dpHeight > viewHeight && viewHeight > dpHeight ) ?
  8685. Math.abs( dpHeight + inputHeight ) : 0 );
  8686. return offset;
  8687. },
  8688. /* Find an object's position on the screen. */
  8689. _findPos: function( obj ) {
  8690. var position,
  8691. inst = this._getInst( obj ),
  8692. isRTL = this._get( inst, "isRTL" );
  8693. while ( obj && ( obj.type === "hidden" || obj.nodeType !== 1 || $.expr.filters.hidden( obj ) ) ) {
  8694. obj = obj[ isRTL ? "previousSibling" : "nextSibling" ];
  8695. }
  8696. position = $( obj ).offset();
  8697. return [ position.left, position.top ];
  8698. },
  8699. /* Hide the date picker from view.
  8700. * @param input element - the input field attached to the date picker
  8701. */
  8702. _hideDatepicker: function( input ) {
  8703. var showAnim, duration, postProcess, onClose,
  8704. inst = this._curInst;
  8705. if ( !inst || ( input && inst !== $.data( input, "datepicker" ) ) ) {
  8706. return;
  8707. }
  8708. if ( this._datepickerShowing ) {
  8709. showAnim = this._get( inst, "showAnim" );
  8710. duration = this._get( inst, "duration" );
  8711. postProcess = function() {
  8712. $.datepicker._tidyDialog( inst );
  8713. };
  8714. // DEPRECATED: after BC for 1.8.x $.effects[ showAnim ] is not needed
  8715. if ( $.effects && ( $.effects.effect[ showAnim ] || $.effects[ showAnim ] ) ) {
  8716. inst.dpDiv.hide( showAnim, $.datepicker._get( inst, "showOptions" ), duration, postProcess );
  8717. } else {
  8718. inst.dpDiv[ ( showAnim === "slideDown" ? "slideUp" :
  8719. ( showAnim === "fadeIn" ? "fadeOut" : "hide" ) ) ]( ( showAnim ? duration : null ), postProcess );
  8720. }
  8721. if ( !showAnim ) {
  8722. postProcess();
  8723. }
  8724. this._datepickerShowing = false;
  8725. onClose = this._get( inst, "onClose" );
  8726. if ( onClose ) {
  8727. onClose.apply( ( inst.input ? inst.input[ 0 ] : null ), [ ( inst.input ? inst.input.val() : "" ), inst ] );
  8728. }
  8729. this._lastInput = null;
  8730. if ( this._inDialog ) {
  8731. this._dialogInput.css( { position: "absolute", left: "0", top: "-100px" } );
  8732. if ( $.blockUI ) {
  8733. $.unblockUI();
  8734. $( "body" ).append( this.dpDiv );
  8735. }
  8736. }
  8737. this._inDialog = false;
  8738. }
  8739. },
  8740. /* Tidy up after a dialog display. */
  8741. _tidyDialog: function( inst ) {
  8742. inst.dpDiv.removeClass( this._dialogClass ).off( ".ui-datepicker-calendar" );
  8743. },
  8744. /* Close date picker if clicked elsewhere. */
  8745. _checkExternalClick: function( event ) {
  8746. if ( !$.datepicker._curInst ) {
  8747. return;
  8748. }
  8749. var $target = $( event.target ),
  8750. inst = $.datepicker._getInst( $target[ 0 ] );
  8751. if ( ( ( $target[ 0 ].id !== $.datepicker._mainDivId &&
  8752. $target.parents( "#" + $.datepicker._mainDivId ).length === 0 &&
  8753. !$target.hasClass( $.datepicker.markerClassName ) &&
  8754. !$target.closest( "." + $.datepicker._triggerClass ).length &&
  8755. $.datepicker._datepickerShowing && !( $.datepicker._inDialog && $.blockUI ) ) ) ||
  8756. ( $target.hasClass( $.datepicker.markerClassName ) && $.datepicker._curInst !== inst ) ) {
  8757. $.datepicker._hideDatepicker();
  8758. }
  8759. },
  8760. /* Adjust one of the date sub-fields. */
  8761. _adjustDate: function( id, offset, period ) {
  8762. var target = $( id ),
  8763. inst = this._getInst( target[ 0 ] );
  8764. if ( this._isDisabledDatepicker( target[ 0 ] ) ) {
  8765. return;
  8766. }
  8767. this._adjustInstDate( inst, offset +
  8768. ( period === "M" ? this._get( inst, "showCurrentAtPos" ) : 0 ), // undo positioning
  8769. period );
  8770. this._updateDatepicker( inst );
  8771. },
  8772. /* Action for current link. */
  8773. _gotoToday: function( id ) {
  8774. var date,
  8775. target = $( id ),
  8776. inst = this._getInst( target[ 0 ] );
  8777. if ( this._get( inst, "gotoCurrent" ) && inst.currentDay ) {
  8778. inst.selectedDay = inst.currentDay;
  8779. inst.drawMonth = inst.selectedMonth = inst.currentMonth;
  8780. inst.drawYear = inst.selectedYear = inst.currentYear;
  8781. } else {
  8782. date = new Date();
  8783. inst.selectedDay = date.getDate();
  8784. inst.drawMonth = inst.selectedMonth = date.getMonth();
  8785. inst.drawYear = inst.selectedYear = date.getFullYear();
  8786. }
  8787. this._notifyChange( inst );
  8788. this._adjustDate( target );
  8789. },
  8790. /* Action for selecting a new month/year. */
  8791. _selectMonthYear: function( id, select, period ) {
  8792. var target = $( id ),
  8793. inst = this._getInst( target[ 0 ] );
  8794. inst[ "selected" + ( period === "M" ? "Month" : "Year" ) ] =
  8795. inst[ "draw" + ( period === "M" ? "Month" : "Year" ) ] =
  8796. parseInt( select.options[ select.selectedIndex ].value, 10 );
  8797. this._notifyChange( inst );
  8798. this._adjustDate( target );
  8799. },
  8800. /* Action for selecting a day. */
  8801. _selectDay: function( id, month, year, td ) {
  8802. var inst,
  8803. target = $( id );
  8804. if ( $( td ).hasClass( this._unselectableClass ) || this._isDisabledDatepicker( target[ 0 ] ) ) {
  8805. return;
  8806. }
  8807. inst = this._getInst( target[ 0 ] );
  8808. inst.selectedDay = inst.currentDay = $( "a", td ).html();
  8809. inst.selectedMonth = inst.currentMonth = month;
  8810. inst.selectedYear = inst.currentYear = year;
  8811. this._selectDate( id, this._formatDate( inst,
  8812. inst.currentDay, inst.currentMonth, inst.currentYear ) );
  8813. },
  8814. /* Erase the input field and hide the date picker. */
  8815. _clearDate: function( id ) {
  8816. var target = $( id );
  8817. this._selectDate( target, "" );
  8818. },
  8819. /* Update the input field with the selected date. */
  8820. _selectDate: function( id, dateStr ) {
  8821. var onSelect,
  8822. target = $( id ),
  8823. inst = this._getInst( target[ 0 ] );
  8824. dateStr = ( dateStr != null ? dateStr : this._formatDate( inst ) );
  8825. if ( inst.input ) {
  8826. inst.input.val( dateStr );
  8827. }
  8828. this._updateAlternate( inst );
  8829. onSelect = this._get( inst, "onSelect" );
  8830. if ( onSelect ) {
  8831. onSelect.apply( ( inst.input ? inst.input[ 0 ] : null ), [ dateStr, inst ] ); // trigger custom callback
  8832. } else if ( inst.input ) {
  8833. inst.input.trigger( "change" ); // fire the change event
  8834. }
  8835. if ( inst.inline ) {
  8836. this._updateDatepicker( inst );
  8837. } else {
  8838. this._hideDatepicker();
  8839. this._lastInput = inst.input[ 0 ];
  8840. if ( typeof( inst.input[ 0 ] ) !== "object" ) {
  8841. inst.input.trigger( "focus" ); // restore focus
  8842. }
  8843. this._lastInput = null;
  8844. }
  8845. },
  8846. /* Update any alternate field to synchronise with the main field. */
  8847. _updateAlternate: function( inst ) {
  8848. var altFormat, date, dateStr,
  8849. altField = this._get( inst, "altField" );
  8850. if ( altField ) { // update alternate field too
  8851. altFormat = this._get( inst, "altFormat" ) || this._get( inst, "dateFormat" );
  8852. date = this._getDate( inst );
  8853. dateStr = this.formatDate( altFormat, date, this._getFormatConfig( inst ) );
  8854. $( altField ).val( dateStr );
  8855. }
  8856. },
  8857. /* Set as beforeShowDay function to prevent selection of weekends.
  8858. * @param date Date - the date to customise
  8859. * @return [boolean, string] - is this date selectable?, what is its CSS class?
  8860. */
  8861. noWeekends: function( date ) {
  8862. var day = date.getDay();
  8863. return [ ( day > 0 && day < 6 ), "" ];
  8864. },
  8865. /* Set as calculateWeek to determine the week of the year based on the ISO 8601 definition.
  8866. * @param date Date - the date to get the week for
  8867. * @return number - the number of the week within the year that contains this date
  8868. */
  8869. iso8601Week: function( date ) {
  8870. var time,
  8871. checkDate = new Date( date.getTime() );
  8872. // Find Thursday of this week starting on Monday
  8873. checkDate.setDate( checkDate.getDate() + 4 - ( checkDate.getDay() || 7 ) );
  8874. time = checkDate.getTime();
  8875. checkDate.setMonth( 0 ); // Compare with Jan 1
  8876. checkDate.setDate( 1 );
  8877. return Math.floor( Math.round( ( time - checkDate ) / 86400000 ) / 7 ) + 1;
  8878. },
  8879. /* Parse a string value into a date object.
  8880. * See formatDate below for the possible formats.
  8881. *
  8882. * @param format string - the expected format of the date
  8883. * @param value string - the date in the above format
  8884. * @param settings Object - attributes include:
  8885. * shortYearCutoff number - the cutoff year for determining the century (optional)
  8886. * dayNamesShort string[7] - abbreviated names of the days from Sunday (optional)
  8887. * dayNames string[7] - names of the days from Sunday (optional)
  8888. * monthNamesShort string[12] - abbreviated names of the months (optional)
  8889. * monthNames string[12] - names of the months (optional)
  8890. * @return Date - the extracted date value or null if value is blank
  8891. */
  8892. parseDate: function( format, value, settings ) {
  8893. if ( format == null || value == null ) {
  8894. throw "Invalid arguments";
  8895. }
  8896. value = ( typeof value === "object" ? value.toString() : value + "" );
  8897. if ( value === "" ) {
  8898. return null;
  8899. }
  8900. var iFormat, dim, extra,
  8901. iValue = 0,
  8902. shortYearCutoffTemp = ( settings ? settings.shortYearCutoff : null ) || this._defaults.shortYearCutoff,
  8903. shortYearCutoff = ( typeof shortYearCutoffTemp !== "string" ? shortYearCutoffTemp :
  8904. new Date().getFullYear() % 100 + parseInt( shortYearCutoffTemp, 10 ) ),
  8905. dayNamesShort = ( settings ? settings.dayNamesShort : null ) || this._defaults.dayNamesShort,
  8906. dayNames = ( settings ? settings.dayNames : null ) || this._defaults.dayNames,
  8907. monthNamesShort = ( settings ? settings.monthNamesShort : null ) || this._defaults.monthNamesShort,
  8908. monthNames = ( settings ? settings.monthNames : null ) || this._defaults.monthNames,
  8909. year = -1,
  8910. month = -1,
  8911. day = -1,
  8912. doy = -1,
  8913. literal = false,
  8914. date,
  8915. // Check whether a format character is doubled
  8916. lookAhead = function( match ) {
  8917. var matches = ( iFormat + 1 < format.length && format.charAt( iFormat + 1 ) === match );
  8918. if ( matches ) {
  8919. iFormat++;
  8920. }
  8921. return matches;
  8922. },
  8923. // Extract a number from the string value
  8924. getNumber = function( match ) {
  8925. var isDoubled = lookAhead( match ),
  8926. size = ( match === "@" ? 14 : ( match === "!" ? 20 :
  8927. ( match === "y" && isDoubled ? 4 : ( match === "o" ? 3 : 2 ) ) ) ),
  8928. minSize = ( match === "y" ? size : 1 ),
  8929. digits = new RegExp( "^\\d{" + minSize + "," + size + "}" ),
  8930. num = value.substring( iValue ).match( digits );
  8931. if ( !num ) {
  8932. throw "Missing number at position " + iValue;
  8933. }
  8934. iValue += num[ 0 ].length;
  8935. return parseInt( num[ 0 ], 10 );
  8936. },
  8937. // Extract a name from the string value and convert to an index
  8938. getName = function( match, shortNames, longNames ) {
  8939. var index = -1,
  8940. names = $.map( lookAhead( match ) ? longNames : shortNames, function( v, k ) {
  8941. return [ [ k, v ] ];
  8942. } ).sort( function( a, b ) {
  8943. return -( a[ 1 ].length - b[ 1 ].length );
  8944. } );
  8945. $.each( names, function( i, pair ) {
  8946. var name = pair[ 1 ];
  8947. if ( value.substr( iValue, name.length ).toLowerCase() === name.toLowerCase() ) {
  8948. index = pair[ 0 ];
  8949. iValue += name.length;
  8950. return false;
  8951. }
  8952. } );
  8953. if ( index !== -1 ) {
  8954. return index + 1;
  8955. } else {
  8956. throw "Unknown name at position " + iValue;
  8957. }
  8958. },
  8959. // Confirm that a literal character matches the string value
  8960. checkLiteral = function() {
  8961. if ( value.charAt( iValue ) !== format.charAt( iFormat ) ) {
  8962. throw "Unexpected literal at position " + iValue;
  8963. }
  8964. iValue++;
  8965. };
  8966. for ( iFormat = 0; iFormat < format.length; iFormat++ ) {
  8967. if ( literal ) {
  8968. if ( format.charAt( iFormat ) === "'" && !lookAhead( "'" ) ) {
  8969. literal = false;
  8970. } else {
  8971. checkLiteral();
  8972. }
  8973. } else {
  8974. switch ( format.charAt( iFormat ) ) {
  8975. case "d":
  8976. day = getNumber( "d" );
  8977. break;
  8978. case "D":
  8979. getName( "D", dayNamesShort, dayNames );
  8980. break;
  8981. case "o":
  8982. doy = getNumber( "o" );
  8983. break;
  8984. case "m":
  8985. month = getNumber( "m" );
  8986. break;
  8987. case "M":
  8988. month = getName( "M", monthNamesShort, monthNames );
  8989. break;
  8990. case "y":
  8991. year = getNumber( "y" );
  8992. break;
  8993. case "@":
  8994. date = new Date( getNumber( "@" ) );
  8995. year = date.getFullYear();
  8996. month = date.getMonth() + 1;
  8997. day = date.getDate();
  8998. break;
  8999. case "!":
  9000. date = new Date( ( getNumber( "!" ) - this._ticksTo1970 ) / 10000 );
  9001. year = date.getFullYear();
  9002. month = date.getMonth() + 1;
  9003. day = date.getDate();
  9004. break;
  9005. case "'":
  9006. if ( lookAhead( "'" ) ) {
  9007. checkLiteral();
  9008. } else {
  9009. literal = true;
  9010. }
  9011. break;
  9012. default:
  9013. checkLiteral();
  9014. }
  9015. }
  9016. }
  9017. if ( iValue < value.length ) {
  9018. extra = value.substr( iValue );
  9019. if ( !/^\s+/.test( extra ) ) {
  9020. throw "Extra/unparsed characters found in date: " + extra;
  9021. }
  9022. }
  9023. if ( year === -1 ) {
  9024. year = new Date().getFullYear();
  9025. } else if ( year < 100 ) {
  9026. year += new Date().getFullYear() - new Date().getFullYear() % 100 +
  9027. ( year <= shortYearCutoff ? 0 : -100 );
  9028. }
  9029. if ( doy > -1 ) {
  9030. month = 1;
  9031. day = doy;
  9032. do {
  9033. dim = this._getDaysInMonth( year, month - 1 );
  9034. if ( day <= dim ) {
  9035. break;
  9036. }
  9037. month++;
  9038. day -= dim;
  9039. } while ( true );
  9040. }
  9041. date = this._daylightSavingAdjust( new Date( year, month - 1, day ) );
  9042. if ( date.getFullYear() !== year || date.getMonth() + 1 !== month || date.getDate() !== day ) {
  9043. throw "Invalid date"; // E.g. 31/02/00
  9044. }
  9045. return date;
  9046. },
  9047. /* Standard date formats. */
  9048. ATOM: "yy-mm-dd", // RFC 3339 (ISO 8601)
  9049. COOKIE: "D, dd M yy",
  9050. ISO_8601: "yy-mm-dd",
  9051. RFC_822: "D, d M y",
  9052. RFC_850: "DD, dd-M-y",
  9053. RFC_1036: "D, d M y",
  9054. RFC_1123: "D, d M yy",
  9055. RFC_2822: "D, d M yy",
  9056. RSS: "D, d M y", // RFC 822
  9057. TICKS: "!",
  9058. TIMESTAMP: "@",
  9059. W3C: "yy-mm-dd", // ISO 8601
  9060. _ticksTo1970: ( ( ( 1970 - 1 ) * 365 + Math.floor( 1970 / 4 ) - Math.floor( 1970 / 100 ) +
  9061. Math.floor( 1970 / 400 ) ) * 24 * 60 * 60 * 10000000 ),
  9062. /* Format a date object into a string value.
  9063. * The format can be combinations of the following:
  9064. * d - day of month (no leading zero)
  9065. * dd - day of month (two digit)
  9066. * o - day of year (no leading zeros)
  9067. * oo - day of year (three digit)
  9068. * D - day name short
  9069. * DD - day name long
  9070. * m - month of year (no leading zero)
  9071. * mm - month of year (two digit)
  9072. * M - month name short
  9073. * MM - month name long
  9074. * y - year (two digit)
  9075. * yy - year (four digit)
  9076. * @ - Unix timestamp (ms since 01/01/1970)
  9077. * ! - Windows ticks (100ns since 01/01/0001)
  9078. * "..." - literal text
  9079. * '' - single quote
  9080. *
  9081. * @param format string - the desired format of the date
  9082. * @param date Date - the date value to format
  9083. * @param settings Object - attributes include:
  9084. * dayNamesShort string[7] - abbreviated names of the days from Sunday (optional)
  9085. * dayNames string[7] - names of the days from Sunday (optional)
  9086. * monthNamesShort string[12] - abbreviated names of the months (optional)
  9087. * monthNames string[12] - names of the months (optional)
  9088. * @return string - the date in the above format
  9089. */
  9090. formatDate: function( format, date, settings ) {
  9091. if ( !date ) {
  9092. return "";
  9093. }
  9094. var iFormat,
  9095. dayNamesShort = ( settings ? settings.dayNamesShort : null ) || this._defaults.dayNamesShort,
  9096. dayNames = ( settings ? settings.dayNames : null ) || this._defaults.dayNames,
  9097. monthNamesShort = ( settings ? settings.monthNamesShort : null ) || this._defaults.monthNamesShort,
  9098. monthNames = ( settings ? settings.monthNames : null ) || this._defaults.monthNames,
  9099. // Check whether a format character is doubled
  9100. lookAhead = function( match ) {
  9101. var matches = ( iFormat + 1 < format.length && format.charAt( iFormat + 1 ) === match );
  9102. if ( matches ) {
  9103. iFormat++;
  9104. }
  9105. return matches;
  9106. },
  9107. // Format a number, with leading zero if necessary
  9108. formatNumber = function( match, value, len ) {
  9109. var num = "" + value;
  9110. if ( lookAhead( match ) ) {
  9111. while ( num.length < len ) {
  9112. num = "0" + num;
  9113. }
  9114. }
  9115. return num;
  9116. },
  9117. // Format a name, short or long as requested
  9118. formatName = function( match, value, shortNames, longNames ) {
  9119. return ( lookAhead( match ) ? longNames[ value ] : shortNames[ value ] );
  9120. },
  9121. output = "",
  9122. literal = false;
  9123. if ( date ) {
  9124. for ( iFormat = 0; iFormat < format.length; iFormat++ ) {
  9125. if ( literal ) {
  9126. if ( format.charAt( iFormat ) === "'" && !lookAhead( "'" ) ) {
  9127. literal = false;
  9128. } else {
  9129. output += format.charAt( iFormat );
  9130. }
  9131. } else {
  9132. switch ( format.charAt( iFormat ) ) {
  9133. case "d":
  9134. output += formatNumber( "d", date.getDate(), 2 );
  9135. break;
  9136. case "D":
  9137. output += formatName( "D", date.getDay(), dayNamesShort, dayNames );
  9138. break;
  9139. case "o":
  9140. output += formatNumber( "o",
  9141. Math.round( ( new Date( date.getFullYear(), date.getMonth(), date.getDate() ).getTime() - new Date( date.getFullYear(), 0, 0 ).getTime() ) / 86400000 ), 3 );
  9142. break;
  9143. case "m":
  9144. output += formatNumber( "m", date.getMonth() + 1, 2 );
  9145. break;
  9146. case "M":
  9147. output += formatName( "M", date.getMonth(), monthNamesShort, monthNames );
  9148. break;
  9149. case "y":
  9150. output += ( lookAhead( "y" ) ? date.getFullYear() :
  9151. ( date.getFullYear() % 100 < 10 ? "0" : "" ) + date.getFullYear() % 100 );
  9152. break;
  9153. case "@":
  9154. output += date.getTime();
  9155. break;
  9156. case "!":
  9157. output += date.getTime() * 10000 + this._ticksTo1970;
  9158. break;
  9159. case "'":
  9160. if ( lookAhead( "'" ) ) {
  9161. output += "'";
  9162. } else {
  9163. literal = true;
  9164. }
  9165. break;
  9166. default:
  9167. output += format.charAt( iFormat );
  9168. }
  9169. }
  9170. }
  9171. }
  9172. return output;
  9173. },
  9174. /* Extract all possible characters from the date format. */
  9175. _possibleChars: function( format ) {
  9176. var iFormat,
  9177. chars = "",
  9178. literal = false,
  9179. // Check whether a format character is doubled
  9180. lookAhead = function( match ) {
  9181. var matches = ( iFormat + 1 < format.length && format.charAt( iFormat + 1 ) === match );
  9182. if ( matches ) {
  9183. iFormat++;
  9184. }
  9185. return matches;
  9186. };
  9187. for ( iFormat = 0; iFormat < format.length; iFormat++ ) {
  9188. if ( literal ) {
  9189. if ( format.charAt( iFormat ) === "'" && !lookAhead( "'" ) ) {
  9190. literal = false;
  9191. } else {
  9192. chars += format.charAt( iFormat );
  9193. }
  9194. } else {
  9195. switch ( format.charAt( iFormat ) ) {
  9196. case "d": case "m": case "y": case "@":
  9197. chars += "0123456789";
  9198. break;
  9199. case "D": case "M":
  9200. return null; // Accept anything
  9201. case "'":
  9202. if ( lookAhead( "'" ) ) {
  9203. chars += "'";
  9204. } else {
  9205. literal = true;
  9206. }
  9207. break;
  9208. default:
  9209. chars += format.charAt( iFormat );
  9210. }
  9211. }
  9212. }
  9213. return chars;
  9214. },
  9215. /* Get a setting value, defaulting if necessary. */
  9216. _get: function( inst, name ) {
  9217. return inst.settings[ name ] !== undefined ?
  9218. inst.settings[ name ] : this._defaults[ name ];
  9219. },
  9220. /* Parse existing date and initialise date picker. */
  9221. _setDateFromField: function( inst, noDefault ) {
  9222. if ( inst.input.val() === inst.lastVal ) {
  9223. return;
  9224. }
  9225. var dateFormat = this._get( inst, "dateFormat" ),
  9226. dates = inst.lastVal = inst.input ? inst.input.val() : null,
  9227. defaultDate = this._getDefaultDate( inst ),
  9228. date = defaultDate,
  9229. settings = this._getFormatConfig( inst );
  9230. try {
  9231. date = this.parseDate( dateFormat, dates, settings ) || defaultDate;
  9232. } catch ( event ) {
  9233. dates = ( noDefault ? "" : dates );
  9234. }
  9235. inst.selectedDay = date.getDate();
  9236. inst.drawMonth = inst.selectedMonth = date.getMonth();
  9237. inst.drawYear = inst.selectedYear = date.getFullYear();
  9238. inst.currentDay = ( dates ? date.getDate() : 0 );
  9239. inst.currentMonth = ( dates ? date.getMonth() : 0 );
  9240. inst.currentYear = ( dates ? date.getFullYear() : 0 );
  9241. this._adjustInstDate( inst );
  9242. },
  9243. /* Retrieve the default date shown on opening. */
  9244. _getDefaultDate: function( inst ) {
  9245. return this._restrictMinMax( inst,
  9246. this._determineDate( inst, this._get( inst, "defaultDate" ), new Date() ) );
  9247. },
  9248. /* A date may be specified as an exact value or a relative one. */
  9249. _determineDate: function( inst, date, defaultDate ) {
  9250. var offsetNumeric = function( offset ) {
  9251. var date = new Date();
  9252. date.setDate( date.getDate() + offset );
  9253. return date;
  9254. },
  9255. offsetString = function( offset ) {
  9256. try {
  9257. return $.datepicker.parseDate( $.datepicker._get( inst, "dateFormat" ),
  9258. offset, $.datepicker._getFormatConfig( inst ) );
  9259. }
  9260. catch ( e ) {
  9261. // Ignore
  9262. }
  9263. var date = ( offset.toLowerCase().match( /^c/ ) ?
  9264. $.datepicker._getDate( inst ) : null ) || new Date(),
  9265. year = date.getFullYear(),
  9266. month = date.getMonth(),
  9267. day = date.getDate(),
  9268. pattern = /([+\-]?[0-9]+)\s*(d|D|w|W|m|M|y|Y)?/g,
  9269. matches = pattern.exec( offset );
  9270. while ( matches ) {
  9271. switch ( matches[ 2 ] || "d" ) {
  9272. case "d" : case "D" :
  9273. day += parseInt( matches[ 1 ], 10 ); break;
  9274. case "w" : case "W" :
  9275. day += parseInt( matches[ 1 ], 10 ) * 7; break;
  9276. case "m" : case "M" :
  9277. month += parseInt( matches[ 1 ], 10 );
  9278. day = Math.min( day, $.datepicker._getDaysInMonth( year, month ) );
  9279. break;
  9280. case "y": case "Y" :
  9281. year += parseInt( matches[ 1 ], 10 );
  9282. day = Math.min( day, $.datepicker._getDaysInMonth( year, month ) );
  9283. break;
  9284. }
  9285. matches = pattern.exec( offset );
  9286. }
  9287. return new Date( year, month, day );
  9288. },
  9289. newDate = ( date == null || date === "" ? defaultDate : ( typeof date === "string" ? offsetString( date ) :
  9290. ( typeof date === "number" ? ( isNaN( date ) ? defaultDate : offsetNumeric( date ) ) : new Date( date.getTime() ) ) ) );
  9291. newDate = ( newDate && newDate.toString() === "Invalid Date" ? defaultDate : newDate );
  9292. if ( newDate ) {
  9293. newDate.setHours( 0 );
  9294. newDate.setMinutes( 0 );
  9295. newDate.setSeconds( 0 );
  9296. newDate.setMilliseconds( 0 );
  9297. }
  9298. return this._daylightSavingAdjust( newDate );
  9299. },
  9300. /* Handle switch to/from daylight saving.
  9301. * Hours may be non-zero on daylight saving cut-over:
  9302. * > 12 when midnight changeover, but then cannot generate
  9303. * midnight datetime, so jump to 1AM, otherwise reset.
  9304. * @param date (Date) the date to check
  9305. * @return (Date) the corrected date
  9306. */
  9307. _daylightSavingAdjust: function( date ) {
  9308. if ( !date ) {
  9309. return null;
  9310. }
  9311. date.setHours( date.getHours() > 12 ? date.getHours() + 2 : 0 );
  9312. return date;
  9313. },
  9314. /* Set the date(s) directly. */
  9315. _setDate: function( inst, date, noChange ) {
  9316. var clear = !date,
  9317. origMonth = inst.selectedMonth,
  9318. origYear = inst.selectedYear,
  9319. newDate = this._restrictMinMax( inst, this._determineDate( inst, date, new Date() ) );
  9320. inst.selectedDay = inst.currentDay = newDate.getDate();
  9321. inst.drawMonth = inst.selectedMonth = inst.currentMonth = newDate.getMonth();
  9322. inst.drawYear = inst.selectedYear = inst.currentYear = newDate.getFullYear();
  9323. if ( ( origMonth !== inst.selectedMonth || origYear !== inst.selectedYear ) && !noChange ) {
  9324. this._notifyChange( inst );
  9325. }
  9326. this._adjustInstDate( inst );
  9327. if ( inst.input ) {
  9328. inst.input.val( clear ? "" : this._formatDate( inst ) );
  9329. }
  9330. },
  9331. /* Retrieve the date(s) directly. */
  9332. _getDate: function( inst ) {
  9333. var startDate = ( !inst.currentYear || ( inst.input && inst.input.val() === "" ) ? null :
  9334. this._daylightSavingAdjust( new Date(
  9335. inst.currentYear, inst.currentMonth, inst.currentDay ) ) );
  9336. return startDate;
  9337. },
  9338. /* Attach the onxxx handlers. These are declared statically so
  9339. * they work with static code transformers like Caja.
  9340. */
  9341. _attachHandlers: function( inst ) {
  9342. var stepMonths = this._get( inst, "stepMonths" ),
  9343. id = "#" + inst.id.replace( /\\\\/g, "\\" );
  9344. inst.dpDiv.find( "[data-handler]" ).map( function() {
  9345. var handler = {
  9346. prev: function() {
  9347. $.datepicker._adjustDate( id, -stepMonths, "M" );
  9348. },
  9349. next: function() {
  9350. $.datepicker._adjustDate( id, +stepMonths, "M" );
  9351. },
  9352. hide: function() {
  9353. $.datepicker._hideDatepicker();
  9354. },
  9355. today: function() {
  9356. $.datepicker._gotoToday( id );
  9357. },
  9358. selectDay: function() {
  9359. $.datepicker._selectDay( id, +this.getAttribute( "data-month" ), +this.getAttribute( "data-year" ), this );
  9360. return false;
  9361. },
  9362. selectMonth: function() {
  9363. $.datepicker._selectMonthYear( id, this, "M" );
  9364. return false;
  9365. },
  9366. selectYear: function() {
  9367. $.datepicker._selectMonthYear( id, this, "Y" );
  9368. return false;
  9369. }
  9370. };
  9371. $( this ).on( this.getAttribute( "data-event" ), handler[ this.getAttribute( "data-handler" ) ] );
  9372. } );
  9373. },
  9374. /* Generate the HTML for the current state of the date picker. */
  9375. _generateHTML: function( inst ) {
  9376. var maxDraw, prevText, prev, nextText, next, currentText, gotoDate,
  9377. controls, buttonPanel, firstDay, showWeek, dayNames, dayNamesMin,
  9378. monthNames, monthNamesShort, beforeShowDay, showOtherMonths,
  9379. selectOtherMonths, defaultDate, html, dow, row, group, col, selectedDate,
  9380. cornerClass, calender, thead, day, daysInMonth, leadDays, curRows, numRows,
  9381. printDate, dRow, tbody, daySettings, otherMonth, unselectable,
  9382. tempDate = new Date(),
  9383. today = this._daylightSavingAdjust(
  9384. new Date( tempDate.getFullYear(), tempDate.getMonth(), tempDate.getDate() ) ), // clear time
  9385. isRTL = this._get( inst, "isRTL" ),
  9386. showButtonPanel = this._get( inst, "showButtonPanel" ),
  9387. hideIfNoPrevNext = this._get( inst, "hideIfNoPrevNext" ),
  9388. navigationAsDateFormat = this._get( inst, "navigationAsDateFormat" ),
  9389. numMonths = this._getNumberOfMonths( inst ),
  9390. showCurrentAtPos = this._get( inst, "showCurrentAtPos" ),
  9391. stepMonths = this._get( inst, "stepMonths" ),
  9392. isMultiMonth = ( numMonths[ 0 ] !== 1 || numMonths[ 1 ] !== 1 ),
  9393. currentDate = this._daylightSavingAdjust( ( !inst.currentDay ? new Date( 9999, 9, 9 ) :
  9394. new Date( inst.currentYear, inst.currentMonth, inst.currentDay ) ) ),
  9395. minDate = this._getMinMaxDate( inst, "min" ),
  9396. maxDate = this._getMinMaxDate( inst, "max" ),
  9397. drawMonth = inst.drawMonth - showCurrentAtPos,
  9398. drawYear = inst.drawYear;
  9399. if ( drawMonth < 0 ) {
  9400. drawMonth += 12;
  9401. drawYear--;
  9402. }
  9403. if ( maxDate ) {
  9404. maxDraw = this._daylightSavingAdjust( new Date( maxDate.getFullYear(),
  9405. maxDate.getMonth() - ( numMonths[ 0 ] * numMonths[ 1 ] ) + 1, maxDate.getDate() ) );
  9406. maxDraw = ( minDate && maxDraw < minDate ? minDate : maxDraw );
  9407. while ( this._daylightSavingAdjust( new Date( drawYear, drawMonth, 1 ) ) > maxDraw ) {
  9408. drawMonth--;
  9409. if ( drawMonth < 0 ) {
  9410. drawMonth = 11;
  9411. drawYear--;
  9412. }
  9413. }
  9414. }
  9415. inst.drawMonth = drawMonth;
  9416. inst.drawYear = drawYear;
  9417. prevText = this._get( inst, "prevText" );
  9418. prevText = ( !navigationAsDateFormat ? prevText : this.formatDate( prevText,
  9419. this._daylightSavingAdjust( new Date( drawYear, drawMonth - stepMonths, 1 ) ),
  9420. this._getFormatConfig( inst ) ) );
  9421. prev = ( this._canAdjustMonth( inst, -1, drawYear, drawMonth ) ?
  9422. "<a class='ui-datepicker-prev ui-corner-all' data-handler='prev' data-event='click'" +
  9423. " title='" + prevText + "'><span class='ui-icon ui-icon-circle-triangle-" + ( isRTL ? "e" : "w" ) + "'>" + prevText + "</span></a>" :
  9424. ( 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>" ) );
  9425. nextText = this._get( inst, "nextText" );
  9426. nextText = ( !navigationAsDateFormat ? nextText : this.formatDate( nextText,
  9427. this._daylightSavingAdjust( new Date( drawYear, drawMonth + stepMonths, 1 ) ),
  9428. this._getFormatConfig( inst ) ) );
  9429. next = ( this._canAdjustMonth( inst, +1, drawYear, drawMonth ) ?
  9430. "<a class='ui-datepicker-next ui-corner-all' data-handler='next' data-event='click'" +
  9431. " title='" + nextText + "'><span class='ui-icon ui-icon-circle-triangle-" + ( isRTL ? "w" : "e" ) + "'>" + nextText + "</span></a>" :
  9432. ( 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>" ) );
  9433. currentText = this._get( inst, "currentText" );
  9434. gotoDate = ( this._get( inst, "gotoCurrent" ) && inst.currentDay ? currentDate : today );
  9435. currentText = ( !navigationAsDateFormat ? currentText :
  9436. this.formatDate( currentText, gotoDate, this._getFormatConfig( inst ) ) );
  9437. 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'>" +
  9438. this._get( inst, "closeText" ) + "</button>" : "" );
  9439. buttonPanel = ( showButtonPanel ) ? "<div class='ui-datepicker-buttonpane ui-widget-content'>" + ( isRTL ? controls : "" ) +
  9440. ( 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'" +
  9441. ">" + currentText + "</button>" : "" ) + ( isRTL ? "" : controls ) + "</div>" : "";
  9442. firstDay = parseInt( this._get( inst, "firstDay" ), 10 );
  9443. firstDay = ( isNaN( firstDay ) ? 0 : firstDay );
  9444. showWeek = this._get( inst, "showWeek" );
  9445. dayNames = this._get( inst, "dayNames" );
  9446. dayNamesMin = this._get( inst, "dayNamesMin" );
  9447. monthNames = this._get( inst, "monthNames" );
  9448. monthNamesShort = this._get( inst, "monthNamesShort" );
  9449. beforeShowDay = this._get( inst, "beforeShowDay" );
  9450. showOtherMonths = this._get( inst, "showOtherMonths" );
  9451. selectOtherMonths = this._get( inst, "selectOtherMonths" );
  9452. defaultDate = this._getDefaultDate( inst );
  9453. html = "";
  9454. for ( row = 0; row < numMonths[ 0 ]; row++ ) {
  9455. group = "";
  9456. this.maxRows = 4;
  9457. for ( col = 0; col < numMonths[ 1 ]; col++ ) {
  9458. selectedDate = this._daylightSavingAdjust( new Date( drawYear, drawMonth, inst.selectedDay ) );
  9459. cornerClass = " ui-corner-all";
  9460. calender = "";
  9461. if ( isMultiMonth ) {
  9462. calender += "<div class='ui-datepicker-group";
  9463. if ( numMonths[ 1 ] > 1 ) {
  9464. switch ( col ) {
  9465. case 0: calender += " ui-datepicker-group-first";
  9466. cornerClass = " ui-corner-" + ( isRTL ? "right" : "left" ); break;
  9467. case numMonths[ 1 ] - 1: calender += " ui-datepicker-group-last";
  9468. cornerClass = " ui-corner-" + ( isRTL ? "left" : "right" ); break;
  9469. default: calender += " ui-datepicker-group-middle"; cornerClass = ""; break;
  9470. }
  9471. }
  9472. calender += "'>";
  9473. }
  9474. calender += "<div class='ui-datepicker-header ui-widget-header ui-helper-clearfix" + cornerClass + "'>" +
  9475. ( /all|left/.test( cornerClass ) && row === 0 ? ( isRTL ? next : prev ) : "" ) +
  9476. ( /all|right/.test( cornerClass ) && row === 0 ? ( isRTL ? prev : next ) : "" ) +
  9477. this._generateMonthYearHeader( inst, drawMonth, drawYear, minDate, maxDate,
  9478. row > 0 || col > 0, monthNames, monthNamesShort ) + // draw month headers
  9479. "</div><table class='ui-datepicker-calendar'><thead>" +
  9480. "<tr>";
  9481. thead = ( showWeek ? "<th class='ui-datepicker-week-col'>" + this._get( inst, "weekHeader" ) + "</th>" : "" );
  9482. for ( dow = 0; dow < 7; dow++ ) { // days of the week
  9483. day = ( dow + firstDay ) % 7;
  9484. thead += "<th scope='col'" + ( ( dow + firstDay + 6 ) % 7 >= 5 ? " class='ui-datepicker-week-end'" : "" ) + ">" +
  9485. "<span title='" + dayNames[ day ] + "'>" + dayNamesMin[ day ] + "</span></th>";
  9486. }
  9487. calender += thead + "</tr></thead><tbody>";
  9488. daysInMonth = this._getDaysInMonth( drawYear, drawMonth );
  9489. if ( drawYear === inst.selectedYear && drawMonth === inst.selectedMonth ) {
  9490. inst.selectedDay = Math.min( inst.selectedDay, daysInMonth );
  9491. }
  9492. leadDays = ( this._getFirstDayOfMonth( drawYear, drawMonth ) - firstDay + 7 ) % 7;
  9493. curRows = Math.ceil( ( leadDays + daysInMonth ) / 7 ); // calculate the number of rows to generate
  9494. numRows = ( isMultiMonth ? this.maxRows > curRows ? this.maxRows : curRows : curRows ); //If multiple months, use the higher number of rows (see #7043)
  9495. this.maxRows = numRows;
  9496. printDate = this._daylightSavingAdjust( new Date( drawYear, drawMonth, 1 - leadDays ) );
  9497. for ( dRow = 0; dRow < numRows; dRow++ ) { // create date picker rows
  9498. calender += "<tr>";
  9499. tbody = ( !showWeek ? "" : "<td class='ui-datepicker-week-col'>" +
  9500. this._get( inst, "calculateWeek" )( printDate ) + "</td>" );
  9501. for ( dow = 0; dow < 7; dow++ ) { // create date picker days
  9502. daySettings = ( beforeShowDay ?
  9503. beforeShowDay.apply( ( inst.input ? inst.input[ 0 ] : null ), [ printDate ] ) : [ true, "" ] );
  9504. otherMonth = ( printDate.getMonth() !== drawMonth );
  9505. unselectable = ( otherMonth && !selectOtherMonths ) || !daySettings[ 0 ] ||
  9506. ( minDate && printDate < minDate ) || ( maxDate && printDate > maxDate );
  9507. tbody += "<td class='" +
  9508. ( ( dow + firstDay + 6 ) % 7 >= 5 ? " ui-datepicker-week-end" : "" ) + // highlight weekends
  9509. ( otherMonth ? " ui-datepicker-other-month" : "" ) + // highlight days from other months
  9510. ( ( printDate.getTime() === selectedDate.getTime() && drawMonth === inst.selectedMonth && inst._keyEvent ) || // user pressed key
  9511. ( defaultDate.getTime() === printDate.getTime() && defaultDate.getTime() === selectedDate.getTime() ) ?
  9512. // or defaultDate is current printedDate and defaultDate is selectedDate
  9513. " " + this._dayOverClass : "" ) + // highlight selected day
  9514. ( unselectable ? " " + this._unselectableClass + " ui-state-disabled" : "" ) + // highlight unselectable days
  9515. ( otherMonth && !showOtherMonths ? "" : " " + daySettings[ 1 ] + // highlight custom dates
  9516. ( printDate.getTime() === currentDate.getTime() ? " " + this._currentClass : "" ) + // highlight selected day
  9517. ( printDate.getTime() === today.getTime() ? " ui-datepicker-today" : "" ) ) + "'" + // highlight today (if different)
  9518. ( ( !otherMonth || showOtherMonths ) && daySettings[ 2 ] ? " title='" + daySettings[ 2 ].replace( /'/g, "&#39;" ) + "'" : "" ) + // cell title
  9519. ( unselectable ? "" : " data-handler='selectDay' data-event='click' data-month='" + printDate.getMonth() + "' data-year='" + printDate.getFullYear() + "'" ) + ">" + // actions
  9520. ( otherMonth && !showOtherMonths ? "&#xa0;" : // display for other months
  9521. ( unselectable ? "<span class='ui-state-default'>" + printDate.getDate() + "</span>" : "<a class='ui-state-default" +
  9522. ( printDate.getTime() === today.getTime() ? " ui-state-highlight" : "" ) +
  9523. ( printDate.getTime() === currentDate.getTime() ? " ui-state-active" : "" ) + // highlight selected day
  9524. ( otherMonth ? " ui-priority-secondary" : "" ) + // distinguish dates from other months
  9525. "' href='#'>" + printDate.getDate() + "</a>" ) ) + "</td>"; // display selectable date
  9526. printDate.setDate( printDate.getDate() + 1 );
  9527. printDate = this._daylightSavingAdjust( printDate );
  9528. }
  9529. calender += tbody + "</tr>";
  9530. }
  9531. drawMonth++;
  9532. if ( drawMonth > 11 ) {
  9533. drawMonth = 0;
  9534. drawYear++;
  9535. }
  9536. calender += "</tbody></table>" + ( isMultiMonth ? "</div>" +
  9537. ( ( numMonths[ 0 ] > 0 && col === numMonths[ 1 ] - 1 ) ? "<div class='ui-datepicker-row-break'></div>" : "" ) : "" );
  9538. group += calender;
  9539. }
  9540. html += group;
  9541. }
  9542. html += buttonPanel;
  9543. inst._keyEvent = false;
  9544. return html;
  9545. },
  9546. /* Generate the month and year header. */
  9547. _generateMonthYearHeader: function( inst, drawMonth, drawYear, minDate, maxDate,
  9548. secondary, monthNames, monthNamesShort ) {
  9549. var inMinYear, inMaxYear, month, years, thisYear, determineYear, year, endYear,
  9550. changeMonth = this._get( inst, "changeMonth" ),
  9551. changeYear = this._get( inst, "changeYear" ),
  9552. showMonthAfterYear = this._get( inst, "showMonthAfterYear" ),
  9553. html = "<div class='ui-datepicker-title'>",
  9554. monthHtml = "";
  9555. // Month selection
  9556. if ( secondary || !changeMonth ) {
  9557. monthHtml += "<span class='ui-datepicker-month'>" + monthNames[ drawMonth ] + "</span>";
  9558. } else {
  9559. inMinYear = ( minDate && minDate.getFullYear() === drawYear );
  9560. inMaxYear = ( maxDate && maxDate.getFullYear() === drawYear );
  9561. monthHtml += "<select class='ui-datepicker-month' data-handler='selectMonth' data-event='change'>";
  9562. for ( month = 0; month < 12; month++ ) {
  9563. if ( ( !inMinYear || month >= minDate.getMonth() ) && ( !inMaxYear || month <= maxDate.getMonth() ) ) {
  9564. monthHtml += "<option value='" + month + "'" +
  9565. ( month === drawMonth ? " selected='selected'" : "" ) +
  9566. ">" + monthNamesShort[ month ] + "</option>";
  9567. }
  9568. }
  9569. monthHtml += "</select>";
  9570. }
  9571. if ( !showMonthAfterYear ) {
  9572. html += monthHtml + ( secondary || !( changeMonth && changeYear ) ? "&#xa0;" : "" );
  9573. }
  9574. // Year selection
  9575. if ( !inst.yearshtml ) {
  9576. inst.yearshtml = "";
  9577. if ( secondary || !changeYear ) {
  9578. html += "<span class='ui-datepicker-year'>" + drawYear + "</span>";
  9579. } else {
  9580. // determine range of years to display
  9581. years = this._get( inst, "yearRange" ).split( ":" );
  9582. thisYear = new Date().getFullYear();
  9583. determineYear = function( value ) {
  9584. var year = ( value.match( /c[+\-].*/ ) ? drawYear + parseInt( value.substring( 1 ), 10 ) :
  9585. ( value.match( /[+\-].*/ ) ? thisYear + parseInt( value, 10 ) :
  9586. parseInt( value, 10 ) ) );
  9587. return ( isNaN( year ) ? thisYear : year );
  9588. };
  9589. year = determineYear( years[ 0 ] );
  9590. endYear = Math.max( year, determineYear( years[ 1 ] || "" ) );
  9591. year = ( minDate ? Math.max( year, minDate.getFullYear() ) : year );
  9592. endYear = ( maxDate ? Math.min( endYear, maxDate.getFullYear() ) : endYear );
  9593. inst.yearshtml += "<select class='ui-datepicker-year' data-handler='selectYear' data-event='change'>";
  9594. for ( ; year <= endYear; year++ ) {
  9595. inst.yearshtml += "<option value='" + year + "'" +
  9596. ( year === drawYear ? " selected='selected'" : "" ) +
  9597. ">" + year + "</option>";
  9598. }
  9599. inst.yearshtml += "</select>";
  9600. html += inst.yearshtml;
  9601. inst.yearshtml = null;
  9602. }
  9603. }
  9604. html += this._get( inst, "yearSuffix" );
  9605. if ( showMonthAfterYear ) {
  9606. html += ( secondary || !( changeMonth && changeYear ) ? "&#xa0;" : "" ) + monthHtml;
  9607. }
  9608. html += "</div>"; // Close datepicker_header
  9609. return html;
  9610. },
  9611. /* Adjust one of the date sub-fields. */
  9612. _adjustInstDate: function( inst, offset, period ) {
  9613. var year = inst.selectedYear + ( period === "Y" ? offset : 0 ),
  9614. month = inst.selectedMonth + ( period === "M" ? offset : 0 ),
  9615. day = Math.min( inst.selectedDay, this._getDaysInMonth( year, month ) ) + ( period === "D" ? offset : 0 ),
  9616. date = this._restrictMinMax( inst, this._daylightSavingAdjust( new Date( year, month, day ) ) );
  9617. inst.selectedDay = date.getDate();
  9618. inst.drawMonth = inst.selectedMonth = date.getMonth();
  9619. inst.drawYear = inst.selectedYear = date.getFullYear();
  9620. if ( period === "M" || period === "Y" ) {
  9621. this._notifyChange( inst );
  9622. }
  9623. },
  9624. /* Ensure a date is within any min/max bounds. */
  9625. _restrictMinMax: function( inst, date ) {
  9626. var minDate = this._getMinMaxDate( inst, "min" ),
  9627. maxDate = this._getMinMaxDate( inst, "max" ),
  9628. newDate = ( minDate && date < minDate ? minDate : date );
  9629. return ( maxDate && newDate > maxDate ? maxDate : newDate );
  9630. },
  9631. /* Notify change of month/year. */
  9632. _notifyChange: function( inst ) {
  9633. var onChange = this._get( inst, "onChangeMonthYear" );
  9634. if ( onChange ) {
  9635. onChange.apply( ( inst.input ? inst.input[ 0 ] : null ),
  9636. [ inst.selectedYear, inst.selectedMonth + 1, inst ] );
  9637. }
  9638. },
  9639. /* Determine the number of months to show. */
  9640. _getNumberOfMonths: function( inst ) {
  9641. var numMonths = this._get( inst, "numberOfMonths" );
  9642. return ( numMonths == null ? [ 1, 1 ] : ( typeof numMonths === "number" ? [ 1, numMonths ] : numMonths ) );
  9643. },
  9644. /* Determine the current maximum date - ensure no time components are set. */
  9645. _getMinMaxDate: function( inst, minMax ) {
  9646. return this._determineDate( inst, this._get( inst, minMax + "Date" ), null );
  9647. },
  9648. /* Find the number of days in a given month. */
  9649. _getDaysInMonth: function( year, month ) {
  9650. return 32 - this._daylightSavingAdjust( new Date( year, month, 32 ) ).getDate();
  9651. },
  9652. /* Find the day of the week of the first of a month. */
  9653. _getFirstDayOfMonth: function( year, month ) {
  9654. return new Date( year, month, 1 ).getDay();
  9655. },
  9656. /* Determines if we should allow a "next/prev" month display change. */
  9657. _canAdjustMonth: function( inst, offset, curYear, curMonth ) {
  9658. var numMonths = this._getNumberOfMonths( inst ),
  9659. date = this._daylightSavingAdjust( new Date( curYear,
  9660. curMonth + ( offset < 0 ? offset : numMonths[ 0 ] * numMonths[ 1 ] ), 1 ) );
  9661. if ( offset < 0 ) {
  9662. date.setDate( this._getDaysInMonth( date.getFullYear(), date.getMonth() ) );
  9663. }
  9664. return this._isInRange( inst, date );
  9665. },
  9666. /* Is the given date in the accepted range? */
  9667. _isInRange: function( inst, date ) {
  9668. var yearSplit, currentYear,
  9669. minDate = this._getMinMaxDate( inst, "min" ),
  9670. maxDate = this._getMinMaxDate( inst, "max" ),
  9671. minYear = null,
  9672. maxYear = null,
  9673. years = this._get( inst, "yearRange" );
  9674. if ( years ) {
  9675. yearSplit = years.split( ":" );
  9676. currentYear = new Date().getFullYear();
  9677. minYear = parseInt( yearSplit[ 0 ], 10 );
  9678. maxYear = parseInt( yearSplit[ 1 ], 10 );
  9679. if ( yearSplit[ 0 ].match( /[+\-].*/ ) ) {
  9680. minYear += currentYear;
  9681. }
  9682. if ( yearSplit[ 1 ].match( /[+\-].*/ ) ) {
  9683. maxYear += currentYear;
  9684. }
  9685. }
  9686. return ( ( !minDate || date.getTime() >= minDate.getTime() ) &&
  9687. ( !maxDate || date.getTime() <= maxDate.getTime() ) &&
  9688. ( !minYear || date.getFullYear() >= minYear ) &&
  9689. ( !maxYear || date.getFullYear() <= maxYear ) );
  9690. },
  9691. /* Provide the configuration settings for formatting/parsing. */
  9692. _getFormatConfig: function( inst ) {
  9693. var shortYearCutoff = this._get( inst, "shortYearCutoff" );
  9694. shortYearCutoff = ( typeof shortYearCutoff !== "string" ? shortYearCutoff :
  9695. new Date().getFullYear() % 100 + parseInt( shortYearCutoff, 10 ) );
  9696. return { shortYearCutoff: shortYearCutoff,
  9697. dayNamesShort: this._get( inst, "dayNamesShort" ), dayNames: this._get( inst, "dayNames" ),
  9698. monthNamesShort: this._get( inst, "monthNamesShort" ), monthNames: this._get( inst, "monthNames" ) };
  9699. },
  9700. /* Format the given date for display. */
  9701. _formatDate: function( inst, day, month, year ) {
  9702. if ( !day ) {
  9703. inst.currentDay = inst.selectedDay;
  9704. inst.currentMonth = inst.selectedMonth;
  9705. inst.currentYear = inst.selectedYear;
  9706. }
  9707. var date = ( day ? ( typeof day === "object" ? day :
  9708. this._daylightSavingAdjust( new Date( year, month, day ) ) ) :
  9709. this._daylightSavingAdjust( new Date( inst.currentYear, inst.currentMonth, inst.currentDay ) ) );
  9710. return this.formatDate( this._get( inst, "dateFormat" ), date, this._getFormatConfig( inst ) );
  9711. }
  9712. } );
  9713. /*
  9714. * Bind hover events for datepicker elements.
  9715. * Done via delegate so the binding only occurs once in the lifetime of the parent div.
  9716. * Global datepicker_instActive, set by _updateDatepicker allows the handlers to find their way back to the active picker.
  9717. */
  9718. function datepicker_bindHover( dpDiv ) {
  9719. var selector = "button, .ui-datepicker-prev, .ui-datepicker-next, .ui-datepicker-calendar td a";
  9720. return dpDiv.on( "mouseout", selector, function() {
  9721. $( this ).removeClass( "ui-state-hover" );
  9722. if ( this.className.indexOf( "ui-datepicker-prev" ) !== -1 ) {
  9723. $( this ).removeClass( "ui-datepicker-prev-hover" );
  9724. }
  9725. if ( this.className.indexOf( "ui-datepicker-next" ) !== -1 ) {
  9726. $( this ).removeClass( "ui-datepicker-next-hover" );
  9727. }
  9728. } )
  9729. .on( "mouseover", selector, datepicker_handleMouseover );
  9730. }
  9731. function datepicker_handleMouseover() {
  9732. if ( !$.datepicker._isDisabledDatepicker( datepicker_instActive.inline ? datepicker_instActive.dpDiv.parent()[ 0 ] : datepicker_instActive.input[ 0 ] ) ) {
  9733. $( this ).parents( ".ui-datepicker-calendar" ).find( "a" ).removeClass( "ui-state-hover" );
  9734. $( this ).addClass( "ui-state-hover" );
  9735. if ( this.className.indexOf( "ui-datepicker-prev" ) !== -1 ) {
  9736. $( this ).addClass( "ui-datepicker-prev-hover" );
  9737. }
  9738. if ( this.className.indexOf( "ui-datepicker-next" ) !== -1 ) {
  9739. $( this ).addClass( "ui-datepicker-next-hover" );
  9740. }
  9741. }
  9742. }
  9743. /* jQuery extend now ignores nulls! */
  9744. function datepicker_extendRemove( target, props ) {
  9745. $.extend( target, props );
  9746. for ( var name in props ) {
  9747. if ( props[ name ] == null ) {
  9748. target[ name ] = props[ name ];
  9749. }
  9750. }
  9751. return target;
  9752. }
  9753. /* Invoke the datepicker functionality.
  9754. @param options string - a command, optionally followed by additional parameters or
  9755. Object - settings for attaching new datepicker functionality
  9756. @return jQuery object */
  9757. $.fn.datepicker = function( options ) {
  9758. /* Verify an empty collection wasn't passed - Fixes #6976 */
  9759. if ( !this.length ) {
  9760. return this;
  9761. }
  9762. /* Initialise the date picker. */
  9763. if ( !$.datepicker.initialized ) {
  9764. $( document ).on( "mousedown", $.datepicker._checkExternalClick );
  9765. $.datepicker.initialized = true;
  9766. }
  9767. /* Append datepicker main container to body if not exist. */
  9768. if ( $( "#" + $.datepicker._mainDivId ).length === 0 ) {
  9769. $( "body" ).append( $.datepicker.dpDiv );
  9770. }
  9771. var otherArgs = Array.prototype.slice.call( arguments, 1 );
  9772. if ( typeof options === "string" && ( options === "isDisabled" || options === "getDate" || options === "widget" ) ) {
  9773. return $.datepicker[ "_" + options + "Datepicker" ].
  9774. apply( $.datepicker, [ this[ 0 ] ].concat( otherArgs ) );
  9775. }
  9776. if ( options === "option" && arguments.length === 2 && typeof arguments[ 1 ] === "string" ) {
  9777. return $.datepicker[ "_" + options + "Datepicker" ].
  9778. apply( $.datepicker, [ this[ 0 ] ].concat( otherArgs ) );
  9779. }
  9780. return this.each( function() {
  9781. typeof options === "string" ?
  9782. $.datepicker[ "_" + options + "Datepicker" ].
  9783. apply( $.datepicker, [ this ].concat( otherArgs ) ) :
  9784. $.datepicker._attachDatepicker( this, options );
  9785. } );
  9786. };
  9787. $.datepicker = new Datepicker(); // singleton instance
  9788. $.datepicker.initialized = false;
  9789. $.datepicker.uuid = new Date().getTime();
  9790. $.datepicker.version = "1.12.0";
  9791. var widgetsDatepicker = $.datepicker;
  9792. /*!
  9793. * jQuery UI Dialog 1.12.0
  9794. * http://jqueryui.com
  9795. *
  9796. * Copyright jQuery Foundation and other contributors
  9797. * Released under the MIT license.
  9798. * http://jquery.org/license
  9799. */
  9800. //>>label: Dialog
  9801. //>>group: Widgets
  9802. //>>description: Displays customizable dialog windows.
  9803. //>>docs: http://api.jqueryui.com/dialog/
  9804. //>>demos: http://jqueryui.com/dialog/
  9805. //>>css.structure: ../../themes/base/core.css
  9806. //>>css.structure: ../../themes/base/dialog.css
  9807. //>>css.theme: ../../themes/base/theme.css
  9808. $.widget( "ui.dialog", {
  9809. version: "1.12.0",
  9810. options: {
  9811. appendTo: "body",
  9812. autoOpen: true,
  9813. buttons: [],
  9814. classes: {
  9815. "ui-dialog": "ui-corner-all",
  9816. "ui-dialog-titlebar": "ui-corner-all"
  9817. },
  9818. closeOnEscape: true,
  9819. closeText: "Close",
  9820. draggable: true,
  9821. hide: null,
  9822. height: "auto",
  9823. maxHeight: null,
  9824. maxWidth: null,
  9825. minHeight: 150,
  9826. minWidth: 150,
  9827. modal: false,
  9828. position: {
  9829. my: "center",
  9830. at: "center",
  9831. of: window,
  9832. collision: "fit",
  9833. // Ensure the titlebar is always visible
  9834. using: function( pos ) {
  9835. var topOffset = $( this ).css( pos ).offset().top;
  9836. if ( topOffset < 0 ) {
  9837. $( this ).css( "top", pos.top - topOffset );
  9838. }
  9839. }
  9840. },
  9841. resizable: true,
  9842. show: null,
  9843. title: null,
  9844. width: 300,
  9845. // Callbacks
  9846. beforeClose: null,
  9847. close: null,
  9848. drag: null,
  9849. dragStart: null,
  9850. dragStop: null,
  9851. focus: null,
  9852. open: null,
  9853. resize: null,
  9854. resizeStart: null,
  9855. resizeStop: null
  9856. },
  9857. sizeRelatedOptions: {
  9858. buttons: true,
  9859. height: true,
  9860. maxHeight: true,
  9861. maxWidth: true,
  9862. minHeight: true,
  9863. minWidth: true,
  9864. width: true
  9865. },
  9866. resizableRelatedOptions: {
  9867. maxHeight: true,
  9868. maxWidth: true,
  9869. minHeight: true,
  9870. minWidth: true
  9871. },
  9872. _create: function() {
  9873. this.originalCss = {
  9874. display: this.element[ 0 ].style.display,
  9875. width: this.element[ 0 ].style.width,
  9876. minHeight: this.element[ 0 ].style.minHeight,
  9877. maxHeight: this.element[ 0 ].style.maxHeight,
  9878. height: this.element[ 0 ].style.height
  9879. };
  9880. this.originalPosition = {
  9881. parent: this.element.parent(),
  9882. index: this.element.parent().children().index( this.element )
  9883. };
  9884. this.originalTitle = this.element.attr( "title" );
  9885. if ( this.options.title == null && this.originalTitle != null ) {
  9886. this.options.title = this.originalTitle;
  9887. }
  9888. // Dialogs can't be disabled
  9889. if ( this.options.disabled ) {
  9890. this.options.disabled = false;
  9891. }
  9892. this._createWrapper();
  9893. this.element
  9894. .show()
  9895. .removeAttr( "title" )
  9896. .appendTo( this.uiDialog );
  9897. this._addClass( "ui-dialog-content", "ui-widget-content" );
  9898. this._createTitlebar();
  9899. this._createButtonPane();
  9900. if ( this.options.draggable && $.fn.draggable ) {
  9901. this._makeDraggable();
  9902. }
  9903. if ( this.options.resizable && $.fn.resizable ) {
  9904. this._makeResizable();
  9905. }
  9906. this._isOpen = false;
  9907. this._trackFocus();
  9908. },
  9909. _init: function() {
  9910. if ( this.options.autoOpen ) {
  9911. this.open();
  9912. }
  9913. },
  9914. _appendTo: function() {
  9915. var element = this.options.appendTo;
  9916. if ( element && ( element.jquery || element.nodeType ) ) {
  9917. return $( element );
  9918. }
  9919. return this.document.find( element || "body" ).eq( 0 );
  9920. },
  9921. _destroy: function() {
  9922. var next,
  9923. originalPosition = this.originalPosition;
  9924. this._untrackInstance();
  9925. this._destroyOverlay();
  9926. this.element
  9927. .removeUniqueId()
  9928. .css( this.originalCss )
  9929. // Without detaching first, the following becomes really slow
  9930. .detach();
  9931. this.uiDialog.remove();
  9932. if ( this.originalTitle ) {
  9933. this.element.attr( "title", this.originalTitle );
  9934. }
  9935. next = originalPosition.parent.children().eq( originalPosition.index );
  9936. // Don't try to place the dialog next to itself (#8613)
  9937. if ( next.length && next[ 0 ] !== this.element[ 0 ] ) {
  9938. next.before( this.element );
  9939. } else {
  9940. originalPosition.parent.append( this.element );
  9941. }
  9942. },
  9943. widget: function() {
  9944. return this.uiDialog;
  9945. },
  9946. disable: $.noop,
  9947. enable: $.noop,
  9948. close: function( event ) {
  9949. var that = this;
  9950. if ( !this._isOpen || this._trigger( "beforeClose", event ) === false ) {
  9951. return;
  9952. }
  9953. this._isOpen = false;
  9954. this._focusedElement = null;
  9955. this._destroyOverlay();
  9956. this._untrackInstance();
  9957. if ( !this.opener.filter( ":focusable" ).trigger( "focus" ).length ) {
  9958. // Hiding a focused element doesn't trigger blur in WebKit
  9959. // so in case we have nothing to focus on, explicitly blur the active element
  9960. // https://bugs.webkit.org/show_bug.cgi?id=47182
  9961. $.ui.safeBlur( $.ui.safeActiveElement( this.document[ 0 ] ) );
  9962. }
  9963. this._hide( this.uiDialog, this.options.hide, function() {
  9964. that._trigger( "close", event );
  9965. } );
  9966. },
  9967. isOpen: function() {
  9968. return this._isOpen;
  9969. },
  9970. moveToTop: function() {
  9971. this._moveToTop();
  9972. },
  9973. _moveToTop: function( event, silent ) {
  9974. var moved = false,
  9975. zIndices = this.uiDialog.siblings( ".ui-front:visible" ).map( function() {
  9976. return +$( this ).css( "z-index" );
  9977. } ).get(),
  9978. zIndexMax = Math.max.apply( null, zIndices );
  9979. if ( zIndexMax >= +this.uiDialog.css( "z-index" ) ) {
  9980. this.uiDialog.css( "z-index", zIndexMax + 1 );
  9981. moved = true;
  9982. }
  9983. if ( moved && !silent ) {
  9984. this._trigger( "focus", event );
  9985. }
  9986. return moved;
  9987. },
  9988. open: function() {
  9989. var that = this;
  9990. if ( this._isOpen ) {
  9991. if ( this._moveToTop() ) {
  9992. this._focusTabbable();
  9993. }
  9994. return;
  9995. }
  9996. this._isOpen = true;
  9997. this.opener = $( $.ui.safeActiveElement( this.document[ 0 ] ) );
  9998. this._size();
  9999. this._position();
  10000. this._createOverlay();
  10001. this._moveToTop( null, true );
  10002. // Ensure the overlay is moved to the top with the dialog, but only when
  10003. // opening. The overlay shouldn't move after the dialog is open so that
  10004. // modeless dialogs opened after the modal dialog stack properly.
  10005. if ( this.overlay ) {
  10006. this.overlay.css( "z-index", this.uiDialog.css( "z-index" ) - 1 );
  10007. }
  10008. this._show( this.uiDialog, this.options.show, function() {
  10009. that._focusTabbable();
  10010. that._trigger( "focus" );
  10011. } );
  10012. // Track the dialog immediately upon openening in case a focus event
  10013. // somehow occurs outside of the dialog before an element inside the
  10014. // dialog is focused (#10152)
  10015. this._makeFocusTarget();
  10016. this._trigger( "open" );
  10017. },
  10018. _focusTabbable: function() {
  10019. // Set focus to the first match:
  10020. // 1. An element that was focused previously
  10021. // 2. First element inside the dialog matching [autofocus]
  10022. // 3. Tabbable element inside the content element
  10023. // 4. Tabbable element inside the buttonpane
  10024. // 5. The close button
  10025. // 6. The dialog itself
  10026. var hasFocus = this._focusedElement;
  10027. if ( !hasFocus ) {
  10028. hasFocus = this.element.find( "[autofocus]" );
  10029. }
  10030. if ( !hasFocus.length ) {
  10031. hasFocus = this.element.find( ":tabbable" );
  10032. }
  10033. if ( !hasFocus.length ) {
  10034. hasFocus = this.uiDialogButtonPane.find( ":tabbable" );
  10035. }
  10036. if ( !hasFocus.length ) {
  10037. hasFocus = this.uiDialogTitlebarClose.filter( ":tabbable" );
  10038. }
  10039. if ( !hasFocus.length ) {
  10040. hasFocus = this.uiDialog;
  10041. }
  10042. hasFocus.eq( 0 ).trigger( "focus" );
  10043. },
  10044. _keepFocus: function( event ) {
  10045. function checkFocus() {
  10046. var activeElement = $.ui.safeActiveElement( this.document[ 0 ] ),
  10047. isActive = this.uiDialog[ 0 ] === activeElement ||
  10048. $.contains( this.uiDialog[ 0 ], activeElement );
  10049. if ( !isActive ) {
  10050. this._focusTabbable();
  10051. }
  10052. }
  10053. event.preventDefault();
  10054. checkFocus.call( this );
  10055. // support: IE
  10056. // IE <= 8 doesn't prevent moving focus even with event.preventDefault()
  10057. // so we check again later
  10058. this._delay( checkFocus );
  10059. },
  10060. _createWrapper: function() {
  10061. this.uiDialog = $( "<div>" )
  10062. .hide()
  10063. .attr( {
  10064. // Setting tabIndex makes the div focusable
  10065. tabIndex: -1,
  10066. role: "dialog"
  10067. } )
  10068. .appendTo( this._appendTo() );
  10069. this._addClass( this.uiDialog, "ui-dialog", "ui-widget ui-widget-content ui-front" );
  10070. this._on( this.uiDialog, {
  10071. keydown: function( event ) {
  10072. if ( this.options.closeOnEscape && !event.isDefaultPrevented() && event.keyCode &&
  10073. event.keyCode === $.ui.keyCode.ESCAPE ) {
  10074. event.preventDefault();
  10075. this.close( event );
  10076. return;
  10077. }
  10078. // Prevent tabbing out of dialogs
  10079. if ( event.keyCode !== $.ui.keyCode.TAB || event.isDefaultPrevented() ) {
  10080. return;
  10081. }
  10082. var tabbables = this.uiDialog.find( ":tabbable" ),
  10083. first = tabbables.filter( ":first" ),
  10084. last = tabbables.filter( ":last" );
  10085. if ( ( event.target === last[ 0 ] || event.target === this.uiDialog[ 0 ] ) &&
  10086. !event.shiftKey ) {
  10087. this._delay( function() {
  10088. first.trigger( "focus" );
  10089. } );
  10090. event.preventDefault();
  10091. } else if ( ( event.target === first[ 0 ] ||
  10092. event.target === this.uiDialog[ 0 ] ) && event.shiftKey ) {
  10093. this._delay( function() {
  10094. last.trigger( "focus" );
  10095. } );
  10096. event.preventDefault();
  10097. }
  10098. },
  10099. mousedown: function( event ) {
  10100. if ( this._moveToTop( event ) ) {
  10101. this._focusTabbable();
  10102. }
  10103. }
  10104. } );
  10105. // We assume that any existing aria-describedby attribute means
  10106. // that the dialog content is marked up properly
  10107. // otherwise we brute force the content as the description
  10108. if ( !this.element.find( "[aria-describedby]" ).length ) {
  10109. this.uiDialog.attr( {
  10110. "aria-describedby": this.element.uniqueId().attr( "id" )
  10111. } );
  10112. }
  10113. },
  10114. _createTitlebar: function() {
  10115. var uiDialogTitle;
  10116. this.uiDialogTitlebar = $( "<div>" );
  10117. this._addClass( this.uiDialogTitlebar,
  10118. "ui-dialog-titlebar", "ui-widget-header ui-helper-clearfix" );
  10119. this._on( this.uiDialogTitlebar, {
  10120. mousedown: function( event ) {
  10121. // Don't prevent click on close button (#8838)
  10122. // Focusing a dialog that is partially scrolled out of view
  10123. // causes the browser to scroll it into view, preventing the click event
  10124. if ( !$( event.target ).closest( ".ui-dialog-titlebar-close" ) ) {
  10125. // Dialog isn't getting focus when dragging (#8063)
  10126. this.uiDialog.trigger( "focus" );
  10127. }
  10128. }
  10129. } );
  10130. // Support: IE
  10131. // Use type="button" to prevent enter keypresses in textboxes from closing the
  10132. // dialog in IE (#9312)
  10133. this.uiDialogTitlebarClose = $( "<button type='button'></button>" )
  10134. .button( {
  10135. label: $( "<a>" ).text( this.options.closeText ).html(),
  10136. icon: "ui-icon-closethick",
  10137. showLabel: false
  10138. } )
  10139. .appendTo( this.uiDialogTitlebar );
  10140. this._addClass( this.uiDialogTitlebarClose, "ui-dialog-titlebar-close" );
  10141. this._on( this.uiDialogTitlebarClose, {
  10142. click: function( event ) {
  10143. event.preventDefault();
  10144. this.close( event );
  10145. }
  10146. } );
  10147. uiDialogTitle = $( "<span>" ).uniqueId().prependTo( this.uiDialogTitlebar );
  10148. this._addClass( uiDialogTitle, "ui-dialog-title" );
  10149. this._title( uiDialogTitle );
  10150. this.uiDialogTitlebar.prependTo( this.uiDialog );
  10151. this.uiDialog.attr( {
  10152. "aria-labelledby": uiDialogTitle.attr( "id" )
  10153. } );
  10154. },
  10155. _title: function( title ) {
  10156. if ( this.options.title ) {
  10157. title.text( this.options.title );
  10158. } else {
  10159. title.html( "&#160;" );
  10160. }
  10161. },
  10162. _createButtonPane: function() {
  10163. this.uiDialogButtonPane = $( "<div>" );
  10164. this._addClass( this.uiDialogButtonPane, "ui-dialog-buttonpane",
  10165. "ui-widget-content ui-helper-clearfix" );
  10166. this.uiButtonSet = $( "<div>" )
  10167. .appendTo( this.uiDialogButtonPane );
  10168. this._addClass( this.uiButtonSet, "ui-dialog-buttonset" );
  10169. this._createButtons();
  10170. },
  10171. _createButtons: function() {
  10172. var that = this,
  10173. buttons = this.options.buttons;
  10174. // If we already have a button pane, remove it
  10175. this.uiDialogButtonPane.remove();
  10176. this.uiButtonSet.empty();
  10177. if ( $.isEmptyObject( buttons ) || ( $.isArray( buttons ) && !buttons.length ) ) {
  10178. this._removeClass( this.uiDialog, "ui-dialog-buttons" );
  10179. return;
  10180. }
  10181. $.each( buttons, function( name, props ) {
  10182. var click, buttonOptions;
  10183. props = $.isFunction( props ) ?
  10184. { click: props, text: name } :
  10185. props;
  10186. // Default to a non-submitting button
  10187. props = $.extend( { type: "button" }, props );
  10188. // Change the context for the click callback to be the main element
  10189. click = props.click;
  10190. buttonOptions = {
  10191. icon: props.icon,
  10192. iconPosition: props.iconPosition,
  10193. showLabel: props.showLabel
  10194. };
  10195. delete props.click;
  10196. delete props.icon;
  10197. delete props.iconPosition;
  10198. delete props.showLabel;
  10199. $( "<button></button>", props )
  10200. .button( buttonOptions )
  10201. .appendTo( that.uiButtonSet )
  10202. .on( "click", function() {
  10203. click.apply( that.element[ 0 ], arguments );
  10204. } );
  10205. } );
  10206. this._addClass( this.uiDialog, "ui-dialog-buttons" );
  10207. this.uiDialogButtonPane.appendTo( this.uiDialog );
  10208. },
  10209. _makeDraggable: function() {
  10210. var that = this,
  10211. options = this.options;
  10212. function filteredUi( ui ) {
  10213. return {
  10214. position: ui.position,
  10215. offset: ui.offset
  10216. };
  10217. }
  10218. this.uiDialog.draggable( {
  10219. cancel: ".ui-dialog-content, .ui-dialog-titlebar-close",
  10220. handle: ".ui-dialog-titlebar",
  10221. containment: "document",
  10222. start: function( event, ui ) {
  10223. that._addClass( $( this ), "ui-dialog-dragging" );
  10224. that._blockFrames();
  10225. that._trigger( "dragStart", event, filteredUi( ui ) );
  10226. },
  10227. drag: function( event, ui ) {
  10228. that._trigger( "drag", event, filteredUi( ui ) );
  10229. },
  10230. stop: function( event, ui ) {
  10231. var left = ui.offset.left - that.document.scrollLeft(),
  10232. top = ui.offset.top - that.document.scrollTop();
  10233. options.position = {
  10234. my: "left top",
  10235. at: "left" + ( left >= 0 ? "+" : "" ) + left + " " +
  10236. "top" + ( top >= 0 ? "+" : "" ) + top,
  10237. of: that.window
  10238. };
  10239. that._removeClass( $( this ), "ui-dialog-dragging" );
  10240. that._unblockFrames();
  10241. that._trigger( "dragStop", event, filteredUi( ui ) );
  10242. }
  10243. } );
  10244. },
  10245. _makeResizable: function() {
  10246. var that = this,
  10247. options = this.options,
  10248. handles = options.resizable,
  10249. // .ui-resizable has position: relative defined in the stylesheet
  10250. // but dialogs have to use absolute or fixed positioning
  10251. position = this.uiDialog.css( "position" ),
  10252. resizeHandles = typeof handles === "string" ?
  10253. handles :
  10254. "n,e,s,w,se,sw,ne,nw";
  10255. function filteredUi( ui ) {
  10256. return {
  10257. originalPosition: ui.originalPosition,
  10258. originalSize: ui.originalSize,
  10259. position: ui.position,
  10260. size: ui.size
  10261. };
  10262. }
  10263. this.uiDialog.resizable( {
  10264. cancel: ".ui-dialog-content",
  10265. containment: "document",
  10266. alsoResize: this.element,
  10267. maxWidth: options.maxWidth,
  10268. maxHeight: options.maxHeight,
  10269. minWidth: options.minWidth,
  10270. minHeight: this._minHeight(),
  10271. handles: resizeHandles,
  10272. start: function( event, ui ) {
  10273. that._addClass( $( this ), "ui-dialog-resizing" );
  10274. that._blockFrames();
  10275. that._trigger( "resizeStart", event, filteredUi( ui ) );
  10276. },
  10277. resize: function( event, ui ) {
  10278. that._trigger( "resize", event, filteredUi( ui ) );
  10279. },
  10280. stop: function( event, ui ) {
  10281. var offset = that.uiDialog.offset(),
  10282. left = offset.left - that.document.scrollLeft(),
  10283. top = offset.top - that.document.scrollTop();
  10284. options.height = that.uiDialog.height();
  10285. options.width = that.uiDialog.width();
  10286. options.position = {
  10287. my: "left top",
  10288. at: "left" + ( left >= 0 ? "+" : "" ) + left + " " +
  10289. "top" + ( top >= 0 ? "+" : "" ) + top,
  10290. of: that.window
  10291. };
  10292. that._removeClass( $( this ), "ui-dialog-resizing" );
  10293. that._unblockFrames();
  10294. that._trigger( "resizeStop", event, filteredUi( ui ) );
  10295. }
  10296. } )
  10297. .css( "position", position );
  10298. },
  10299. _trackFocus: function() {
  10300. this._on( this.widget(), {
  10301. focusin: function( event ) {
  10302. this._makeFocusTarget();
  10303. this._focusedElement = $( event.target );
  10304. }
  10305. } );
  10306. },
  10307. _makeFocusTarget: function() {
  10308. this._untrackInstance();
  10309. this._trackingInstances().unshift( this );
  10310. },
  10311. _untrackInstance: function() {
  10312. var instances = this._trackingInstances(),
  10313. exists = $.inArray( this, instances );
  10314. if ( exists !== -1 ) {
  10315. instances.splice( exists, 1 );
  10316. }
  10317. },
  10318. _trackingInstances: function() {
  10319. var instances = this.document.data( "ui-dialog-instances" );
  10320. if ( !instances ) {
  10321. instances = [];
  10322. this.document.data( "ui-dialog-instances", instances );
  10323. }
  10324. return instances;
  10325. },
  10326. _minHeight: function() {
  10327. var options = this.options;
  10328. return options.height === "auto" ?
  10329. options.minHeight :
  10330. Math.min( options.minHeight, options.height );
  10331. },
  10332. _position: function() {
  10333. // Need to show the dialog to get the actual offset in the position plugin
  10334. var isVisible = this.uiDialog.is( ":visible" );
  10335. if ( !isVisible ) {
  10336. this.uiDialog.show();
  10337. }
  10338. this.uiDialog.position( this.options.position );
  10339. if ( !isVisible ) {
  10340. this.uiDialog.hide();
  10341. }
  10342. },
  10343. _setOptions: function( options ) {
  10344. var that = this,
  10345. resize = false,
  10346. resizableOptions = {};
  10347. $.each( options, function( key, value ) {
  10348. that._setOption( key, value );
  10349. if ( key in that.sizeRelatedOptions ) {
  10350. resize = true;
  10351. }
  10352. if ( key in that.resizableRelatedOptions ) {
  10353. resizableOptions[ key ] = value;
  10354. }
  10355. } );
  10356. if ( resize ) {
  10357. this._size();
  10358. this._position();
  10359. }
  10360. if ( this.uiDialog.is( ":data(ui-resizable)" ) ) {
  10361. this.uiDialog.resizable( "option", resizableOptions );
  10362. }
  10363. },
  10364. _setOption: function( key, value ) {
  10365. var isDraggable, isResizable,
  10366. uiDialog = this.uiDialog;
  10367. if ( key === "disabled" ) {
  10368. return;
  10369. }
  10370. this._super( key, value );
  10371. if ( key === "appendTo" ) {
  10372. this.uiDialog.appendTo( this._appendTo() );
  10373. }
  10374. if ( key === "buttons" ) {
  10375. this._createButtons();
  10376. }
  10377. if ( key === "closeText" ) {
  10378. this.uiDialogTitlebarClose.button( {
  10379. // Ensure that we always pass a string
  10380. label: $( "<a>" ).text( "" + this.options.closeText ).html()
  10381. } );
  10382. }
  10383. if ( key === "draggable" ) {
  10384. isDraggable = uiDialog.is( ":data(ui-draggable)" );
  10385. if ( isDraggable && !value ) {
  10386. uiDialog.draggable( "destroy" );
  10387. }
  10388. if ( !isDraggable && value ) {
  10389. this._makeDraggable();
  10390. }
  10391. }
  10392. if ( key === "position" ) {
  10393. this._position();
  10394. }
  10395. if ( key === "resizable" ) {
  10396. // currently resizable, becoming non-resizable
  10397. isResizable = uiDialog.is( ":data(ui-resizable)" );
  10398. if ( isResizable && !value ) {
  10399. uiDialog.resizable( "destroy" );
  10400. }
  10401. // Currently resizable, changing handles
  10402. if ( isResizable && typeof value === "string" ) {
  10403. uiDialog.resizable( "option", "handles", value );
  10404. }
  10405. // Currently non-resizable, becoming resizable
  10406. if ( !isResizable && value !== false ) {
  10407. this._makeResizable();
  10408. }
  10409. }
  10410. if ( key === "title" ) {
  10411. this._title( this.uiDialogTitlebar.find( ".ui-dialog-title" ) );
  10412. }
  10413. },
  10414. _size: function() {
  10415. // If the user has resized the dialog, the .ui-dialog and .ui-dialog-content
  10416. // divs will both have width and height set, so we need to reset them
  10417. var nonContentHeight, minContentHeight, maxContentHeight,
  10418. options = this.options;
  10419. // Reset content sizing
  10420. this.element.show().css( {
  10421. width: "auto",
  10422. minHeight: 0,
  10423. maxHeight: "none",
  10424. height: 0
  10425. } );
  10426. if ( options.minWidth > options.width ) {
  10427. options.width = options.minWidth;
  10428. }
  10429. // Reset wrapper sizing
  10430. // determine the height of all the non-content elements
  10431. nonContentHeight = this.uiDialog.css( {
  10432. height: "auto",
  10433. width: options.width
  10434. } )
  10435. .outerHeight();
  10436. minContentHeight = Math.max( 0, options.minHeight - nonContentHeight );
  10437. maxContentHeight = typeof options.maxHeight === "number" ?
  10438. Math.max( 0, options.maxHeight - nonContentHeight ) :
  10439. "none";
  10440. if ( options.height === "auto" ) {
  10441. this.element.css( {
  10442. minHeight: minContentHeight,
  10443. maxHeight: maxContentHeight,
  10444. height: "auto"
  10445. } );
  10446. } else {
  10447. this.element.height( Math.max( 0, options.height - nonContentHeight ) );
  10448. }
  10449. if ( this.uiDialog.is( ":data(ui-resizable)" ) ) {
  10450. this.uiDialog.resizable( "option", "minHeight", this._minHeight() );
  10451. }
  10452. },
  10453. _blockFrames: function() {
  10454. this.iframeBlocks = this.document.find( "iframe" ).map( function() {
  10455. var iframe = $( this );
  10456. return $( "<div>" )
  10457. .css( {
  10458. position: "absolute",
  10459. width: iframe.outerWidth(),
  10460. height: iframe.outerHeight()
  10461. } )
  10462. .appendTo( iframe.parent() )
  10463. .offset( iframe.offset() )[ 0 ];
  10464. } );
  10465. },
  10466. _unblockFrames: function() {
  10467. if ( this.iframeBlocks ) {
  10468. this.iframeBlocks.remove();
  10469. delete this.iframeBlocks;
  10470. }
  10471. },
  10472. _allowInteraction: function( event ) {
  10473. if ( $( event.target ).closest( ".ui-dialog" ).length ) {
  10474. return true;
  10475. }
  10476. // TODO: Remove hack when datepicker implements
  10477. // the .ui-front logic (#8989)
  10478. return !!$( event.target ).closest( ".ui-datepicker" ).length;
  10479. },
  10480. _createOverlay: function() {
  10481. if ( !this.options.modal ) {
  10482. return;
  10483. }
  10484. // We use a delay in case the overlay is created from an
  10485. // event that we're going to be cancelling (#2804)
  10486. var isOpening = true;
  10487. this._delay( function() {
  10488. isOpening = false;
  10489. } );
  10490. if ( !this.document.data( "ui-dialog-overlays" ) ) {
  10491. // Prevent use of anchors and inputs
  10492. // Using _on() for an event handler shared across many instances is
  10493. // safe because the dialogs stack and must be closed in reverse order
  10494. this._on( this.document, {
  10495. focusin: function( event ) {
  10496. if ( isOpening ) {
  10497. return;
  10498. }
  10499. if ( !this._allowInteraction( event ) ) {
  10500. event.preventDefault();
  10501. this._trackingInstances()[ 0 ]._focusTabbable();
  10502. }
  10503. }
  10504. } );
  10505. }
  10506. this.overlay = $( "<div>" )
  10507. .appendTo( this._appendTo() );
  10508. this._addClass( this.overlay, null, "ui-widget-overlay ui-front" );
  10509. this._on( this.overlay, {
  10510. mousedown: "_keepFocus"
  10511. } );
  10512. this.document.data( "ui-dialog-overlays",
  10513. ( this.document.data( "ui-dialog-overlays" ) || 0 ) + 1 );
  10514. },
  10515. _destroyOverlay: function() {
  10516. if ( !this.options.modal ) {
  10517. return;
  10518. }
  10519. if ( this.overlay ) {
  10520. var overlays = this.document.data( "ui-dialog-overlays" ) - 1;
  10521. if ( !overlays ) {
  10522. this._off( this.document, "focusin" );
  10523. this.document.removeData( "ui-dialog-overlays" );
  10524. } else {
  10525. this.document.data( "ui-dialog-overlays", overlays );
  10526. }
  10527. this.overlay.remove();
  10528. this.overlay = null;
  10529. }
  10530. }
  10531. } );
  10532. // DEPRECATED
  10533. // TODO: switch return back to widget declaration at top of file when this is removed
  10534. if ( $.uiBackCompat !== false ) {
  10535. // Backcompat for dialogClass option
  10536. $.widget( "ui.dialog", $.ui.dialog, {
  10537. options: {
  10538. dialogClass: ""
  10539. },
  10540. _createWrapper: function() {
  10541. this._super();
  10542. this.uiDialog.addClass( this.options.dialogClass );
  10543. },
  10544. _setOption: function( key, value ) {
  10545. if ( key === "dialogClass" ) {
  10546. this.uiDialog
  10547. .removeClass( this.options.dialogClass )
  10548. .addClass( value );
  10549. }
  10550. this._superApply( arguments );
  10551. }
  10552. } );
  10553. }
  10554. var widgetsDialog = $.ui.dialog;
  10555. /*!
  10556. * jQuery UI Progressbar 1.12.0
  10557. * http://jqueryui.com
  10558. *
  10559. * Copyright jQuery Foundation and other contributors
  10560. * Released under the MIT license.
  10561. * http://jquery.org/license
  10562. */
  10563. //>>label: Progressbar
  10564. //>>group: Widgets
  10565. // jscs:disable maximumLineLength
  10566. //>>description: Displays a status indicator for loading state, standard percentage, and other progress indicators.
  10567. // jscs:enable maximumLineLength
  10568. //>>docs: http://api.jqueryui.com/progressbar/
  10569. //>>demos: http://jqueryui.com/progressbar/
  10570. //>>css.structure: ../../themes/base/core.css
  10571. //>>css.structure: ../../themes/base/progressbar.css
  10572. //>>css.theme: ../../themes/base/theme.css
  10573. var widgetsProgressbar = $.widget( "ui.progressbar", {
  10574. version: "1.12.0",
  10575. options: {
  10576. classes: {
  10577. "ui-progressbar": "ui-corner-all",
  10578. "ui-progressbar-value": "ui-corner-left",
  10579. "ui-progressbar-complete": "ui-corner-right"
  10580. },
  10581. max: 100,
  10582. value: 0,
  10583. change: null,
  10584. complete: null
  10585. },
  10586. min: 0,
  10587. _create: function() {
  10588. // Constrain initial value
  10589. this.oldValue = this.options.value = this._constrainedValue();
  10590. this.element.attr( {
  10591. // Only set static values; aria-valuenow and aria-valuemax are
  10592. // set inside _refreshValue()
  10593. role: "progressbar",
  10594. "aria-valuemin": this.min
  10595. } );
  10596. this._addClass( "ui-progressbar", "ui-widget ui-widget-content" );
  10597. this.valueDiv = $( "<div>" ).appendTo( this.element );
  10598. this._addClass( this.valueDiv, "ui-progressbar-value", "ui-widget-header" );
  10599. this._refreshValue();
  10600. },
  10601. _destroy: function() {
  10602. this.element.removeAttr( "role aria-valuemin aria-valuemax aria-valuenow" );
  10603. this.valueDiv.remove();
  10604. },
  10605. value: function( newValue ) {
  10606. if ( newValue === undefined ) {
  10607. return this.options.value;
  10608. }
  10609. this.options.value = this._constrainedValue( newValue );
  10610. this._refreshValue();
  10611. },
  10612. _constrainedValue: function( newValue ) {
  10613. if ( newValue === undefined ) {
  10614. newValue = this.options.value;
  10615. }
  10616. this.indeterminate = newValue === false;
  10617. // Sanitize value
  10618. if ( typeof newValue !== "number" ) {
  10619. newValue = 0;
  10620. }
  10621. return this.indeterminate ? false :
  10622. Math.min( this.options.max, Math.max( this.min, newValue ) );
  10623. },
  10624. _setOptions: function( options ) {
  10625. // Ensure "value" option is set after other values (like max)
  10626. var value = options.value;
  10627. delete options.value;
  10628. this._super( options );
  10629. this.options.value = this._constrainedValue( value );
  10630. this._refreshValue();
  10631. },
  10632. _setOption: function( key, value ) {
  10633. if ( key === "max" ) {
  10634. // Don't allow a max less than min
  10635. value = Math.max( this.min, value );
  10636. }
  10637. this._super( key, value );
  10638. },
  10639. _setOptionDisabled: function( value ) {
  10640. this._super( value );
  10641. this.element.attr( "aria-disabled", value );
  10642. this._toggleClass( null, "ui-state-disabled", !!value );
  10643. },
  10644. _percentage: function() {
  10645. return this.indeterminate ?
  10646. 100 :
  10647. 100 * ( this.options.value - this.min ) / ( this.options.max - this.min );
  10648. },
  10649. _refreshValue: function() {
  10650. var value = this.options.value,
  10651. percentage = this._percentage();
  10652. this.valueDiv
  10653. .toggle( this.indeterminate || value > this.min )
  10654. .width( percentage.toFixed( 0 ) + "%" );
  10655. this
  10656. ._toggleClass( this.valueDiv, "ui-progressbar-complete", null,
  10657. value === this.options.max )
  10658. ._toggleClass( "ui-progressbar-indeterminate", null, this.indeterminate );
  10659. if ( this.indeterminate ) {
  10660. this.element.removeAttr( "aria-valuenow" );
  10661. if ( !this.overlayDiv ) {
  10662. this.overlayDiv = $( "<div>" ).appendTo( this.valueDiv );
  10663. this._addClass( this.overlayDiv, "ui-progressbar-overlay" );
  10664. }
  10665. } else {
  10666. this.element.attr( {
  10667. "aria-valuemax": this.options.max,
  10668. "aria-valuenow": value
  10669. } );
  10670. if ( this.overlayDiv ) {
  10671. this.overlayDiv.remove();
  10672. this.overlayDiv = null;
  10673. }
  10674. }
  10675. if ( this.oldValue !== value ) {
  10676. this.oldValue = value;
  10677. this._trigger( "change" );
  10678. }
  10679. if ( value === this.options.max ) {
  10680. this._trigger( "complete" );
  10681. }
  10682. }
  10683. } );
  10684. /*!
  10685. * jQuery UI Selectmenu 1.12.0
  10686. * http://jqueryui.com
  10687. *
  10688. * Copyright jQuery Foundation and other contributors
  10689. * Released under the MIT license.
  10690. * http://jquery.org/license
  10691. */
  10692. //>>label: Selectmenu
  10693. //>>group: Widgets
  10694. // jscs:disable maximumLineLength
  10695. //>>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.
  10696. // jscs:enable maximumLineLength
  10697. //>>docs: http://api.jqueryui.com/selectmenu/
  10698. //>>demos: http://jqueryui.com/selectmenu/
  10699. //>>css.structure: ../../themes/base/core.css
  10700. //>>css.structure: ../../themes/base/selectmenu.css, ../../themes/base/button.css
  10701. //>>css.theme: ../../themes/base/theme.css
  10702. var widgetsSelectmenu = $.widget( "ui.selectmenu", [ $.ui.formResetMixin, {
  10703. version: "1.12.0",
  10704. defaultElement: "<select>",
  10705. options: {
  10706. appendTo: null,
  10707. classes: {
  10708. "ui-selectmenu-button-open": "ui-corner-top",
  10709. "ui-selectmenu-button-closed": "ui-corner-all"
  10710. },
  10711. disabled: null,
  10712. icons: {
  10713. button: "ui-icon-triangle-1-s"
  10714. },
  10715. position: {
  10716. my: "left top",
  10717. at: "left bottom",
  10718. collision: "none"
  10719. },
  10720. width: false,
  10721. // Callbacks
  10722. change: null,
  10723. close: null,
  10724. focus: null,
  10725. open: null,
  10726. select: null
  10727. },
  10728. _create: function() {
  10729. var selectmenuId = this.element.uniqueId().attr( "id" );
  10730. this.ids = {
  10731. element: selectmenuId,
  10732. button: selectmenuId + "-button",
  10733. menu: selectmenuId + "-menu"
  10734. };
  10735. this._drawButton();
  10736. this._drawMenu();
  10737. this._bindFormResetHandler();
  10738. this._rendered = false;
  10739. this.menuItems = $();
  10740. },
  10741. _drawButton: function() {
  10742. var icon,
  10743. that = this,
  10744. item = this._parseOption(
  10745. this.element.find( "option:selected" ),
  10746. this.element[ 0 ].selectedIndex
  10747. );
  10748. // Associate existing label with the new button
  10749. this.labels = this.element.labels().attr( "for", this.ids.button );
  10750. this._on( this.labels, {
  10751. click: function( event ) {
  10752. this.button.focus();
  10753. event.preventDefault();
  10754. }
  10755. } );
  10756. // Hide original select element
  10757. this.element.hide();
  10758. // Create button
  10759. this.button = $( "<span>", {
  10760. tabindex: this.options.disabled ? -1 : 0,
  10761. id: this.ids.button,
  10762. role: "combobox",
  10763. "aria-expanded": "false",
  10764. "aria-autocomplete": "list",
  10765. "aria-owns": this.ids.menu,
  10766. "aria-haspopup": "true",
  10767. title: this.element.attr( "title" )
  10768. } )
  10769. .insertAfter( this.element );
  10770. this._addClass( this.button, "ui-selectmenu-button ui-selectmenu-button-closed",
  10771. "ui-button ui-widget" );
  10772. icon = $( "<span>" ).appendTo( this.button );
  10773. this._addClass( icon, "ui-selectmenu-icon", "ui-icon " + this.options.icons.button );
  10774. this.buttonItem = this._renderButtonItem( item )
  10775. .appendTo( this.button );
  10776. if ( this.options.width !== false ) {
  10777. this._resizeButton();
  10778. }
  10779. this._on( this.button, this._buttonEvents );
  10780. this.button.one( "focusin", function() {
  10781. // Delay rendering the menu items until the button receives focus.
  10782. // The menu may have already been rendered via a programmatic open.
  10783. if ( !that._rendered ) {
  10784. that._refreshMenu();
  10785. }
  10786. } );
  10787. },
  10788. _drawMenu: function() {
  10789. var that = this;
  10790. // Create menu
  10791. this.menu = $( "<ul>", {
  10792. "aria-hidden": "true",
  10793. "aria-labelledby": this.ids.button,
  10794. id: this.ids.menu
  10795. } );
  10796. // Wrap menu
  10797. this.menuWrap = $( "<div>" ).append( this.menu );
  10798. this._addClass( this.menuWrap, "ui-selectmenu-menu", "ui-front" );
  10799. this.menuWrap.appendTo( this._appendTo() );
  10800. // Initialize menu widget
  10801. this.menuInstance = this.menu
  10802. .menu( {
  10803. classes: {
  10804. "ui-menu": "ui-corner-bottom"
  10805. },
  10806. role: "listbox",
  10807. select: function( event, ui ) {
  10808. event.preventDefault();
  10809. // Support: IE8
  10810. // If the item was selected via a click, the text selection
  10811. // will be destroyed in IE
  10812. that._setSelection();
  10813. that._select( ui.item.data( "ui-selectmenu-item" ), event );
  10814. },
  10815. focus: function( event, ui ) {
  10816. var item = ui.item.data( "ui-selectmenu-item" );
  10817. // Prevent inital focus from firing and check if its a newly focused item
  10818. if ( that.focusIndex != null && item.index !== that.focusIndex ) {
  10819. that._trigger( "focus", event, { item: item } );
  10820. if ( !that.isOpen ) {
  10821. that._select( item, event );
  10822. }
  10823. }
  10824. that.focusIndex = item.index;
  10825. that.button.attr( "aria-activedescendant",
  10826. that.menuItems.eq( item.index ).attr( "id" ) );
  10827. }
  10828. } )
  10829. .menu( "instance" );
  10830. // Don't close the menu on mouseleave
  10831. this.menuInstance._off( this.menu, "mouseleave" );
  10832. // Cancel the menu's collapseAll on document click
  10833. this.menuInstance._closeOnDocumentClick = function() {
  10834. return false;
  10835. };
  10836. // Selects often contain empty items, but never contain dividers
  10837. this.menuInstance._isDivider = function() {
  10838. return false;
  10839. };
  10840. },
  10841. refresh: function() {
  10842. this._refreshMenu();
  10843. this.buttonItem.replaceWith(
  10844. this.buttonItem = this._renderButtonItem(
  10845. // Fall back to an empty object in case there are no options
  10846. this._getSelectedItem().data( "ui-selectmenu-item" ) || {}
  10847. )
  10848. );
  10849. if ( this.options.width === null ) {
  10850. this._resizeButton();
  10851. }
  10852. },
  10853. _refreshMenu: function() {
  10854. var item,
  10855. options = this.element.find( "option" );
  10856. this.menu.empty();
  10857. this._parseOptions( options );
  10858. this._renderMenu( this.menu, this.items );
  10859. this.menuInstance.refresh();
  10860. this.menuItems = this.menu.find( "li" )
  10861. .not( ".ui-selectmenu-optgroup" )
  10862. .find( ".ui-menu-item-wrapper" );
  10863. this._rendered = true;
  10864. if ( !options.length ) {
  10865. return;
  10866. }
  10867. item = this._getSelectedItem();
  10868. // Update the menu to have the correct item focused
  10869. this.menuInstance.focus( null, item );
  10870. this._setAria( item.data( "ui-selectmenu-item" ) );
  10871. // Set disabled state
  10872. this._setOption( "disabled", this.element.prop( "disabled" ) );
  10873. },
  10874. open: function( event ) {
  10875. if ( this.options.disabled ) {
  10876. return;
  10877. }
  10878. // If this is the first time the menu is being opened, render the items
  10879. if ( !this._rendered ) {
  10880. this._refreshMenu();
  10881. } else {
  10882. // Menu clears focus on close, reset focus to selected item
  10883. this._removeClass( this.menu.find( ".ui-state-active" ), null, "ui-state-active" );
  10884. this.menuInstance.focus( null, this._getSelectedItem() );
  10885. }
  10886. // If there are no options, don't open the menu
  10887. if ( !this.menuItems.length ) {
  10888. return;
  10889. }
  10890. this.isOpen = true;
  10891. this._toggleAttr();
  10892. this._resizeMenu();
  10893. this._position();
  10894. this._on( this.document, this._documentClick );
  10895. this._trigger( "open", event );
  10896. },
  10897. _position: function() {
  10898. this.menuWrap.position( $.extend( { of: this.button }, this.options.position ) );
  10899. },
  10900. close: function( event ) {
  10901. if ( !this.isOpen ) {
  10902. return;
  10903. }
  10904. this.isOpen = false;
  10905. this._toggleAttr();
  10906. this.range = null;
  10907. this._off( this.document );
  10908. this._trigger( "close", event );
  10909. },
  10910. widget: function() {
  10911. return this.button;
  10912. },
  10913. menuWidget: function() {
  10914. return this.menu;
  10915. },
  10916. _renderButtonItem: function( item ) {
  10917. var buttonItem = $( "<span>" );
  10918. this._setText( buttonItem, item.label );
  10919. this._addClass( buttonItem, "ui-selectmenu-text" );
  10920. return buttonItem;
  10921. },
  10922. _renderMenu: function( ul, items ) {
  10923. var that = this,
  10924. currentOptgroup = "";
  10925. $.each( items, function( index, item ) {
  10926. var li;
  10927. if ( item.optgroup !== currentOptgroup ) {
  10928. li = $( "<li>", {
  10929. text: item.optgroup
  10930. } );
  10931. that._addClass( li, "ui-selectmenu-optgroup", "ui-menu-divider" +
  10932. ( item.element.parent( "optgroup" ).prop( "disabled" ) ?
  10933. " ui-state-disabled" :
  10934. "" ) );
  10935. li.appendTo( ul );
  10936. currentOptgroup = item.optgroup;
  10937. }
  10938. that._renderItemData( ul, item );
  10939. } );
  10940. },
  10941. _renderItemData: function( ul, item ) {
  10942. return this._renderItem( ul, item ).data( "ui-selectmenu-item", item );
  10943. },
  10944. _renderItem: function( ul, item ) {
  10945. var li = $( "<li>" ),
  10946. wrapper = $( "<div>", {
  10947. title: item.element.attr( "title" )
  10948. } );
  10949. if ( item.disabled ) {
  10950. this._addClass( li, null, "ui-state-disabled" );
  10951. }
  10952. this._setText( wrapper, item.label );
  10953. return li.append( wrapper ).appendTo( ul );
  10954. },
  10955. _setText: function( element, value ) {
  10956. if ( value ) {
  10957. element.text( value );
  10958. } else {
  10959. element.html( "&#160;" );
  10960. }
  10961. },
  10962. _move: function( direction, event ) {
  10963. var item, next,
  10964. filter = ".ui-menu-item";
  10965. if ( this.isOpen ) {
  10966. item = this.menuItems.eq( this.focusIndex ).parent( "li" );
  10967. } else {
  10968. item = this.menuItems.eq( this.element[ 0 ].selectedIndex ).parent( "li" );
  10969. filter += ":not(.ui-state-disabled)";
  10970. }
  10971. if ( direction === "first" || direction === "last" ) {
  10972. next = item[ direction === "first" ? "prevAll" : "nextAll" ]( filter ).eq( -1 );
  10973. } else {
  10974. next = item[ direction + "All" ]( filter ).eq( 0 );
  10975. }
  10976. if ( next.length ) {
  10977. this.menuInstance.focus( event, next );
  10978. }
  10979. },
  10980. _getSelectedItem: function() {
  10981. return this.menuItems.eq( this.element[ 0 ].selectedIndex ).parent( "li" );
  10982. },
  10983. _toggle: function( event ) {
  10984. this[ this.isOpen ? "close" : "open" ]( event );
  10985. },
  10986. _setSelection: function() {
  10987. var selection;
  10988. if ( !this.range ) {
  10989. return;
  10990. }
  10991. if ( window.getSelection ) {
  10992. selection = window.getSelection();
  10993. selection.removeAllRanges();
  10994. selection.addRange( this.range );
  10995. // Support: IE8
  10996. } else {
  10997. this.range.select();
  10998. }
  10999. // Support: IE
  11000. // Setting the text selection kills the button focus in IE, but
  11001. // restoring the focus doesn't kill the selection.
  11002. this.button.focus();
  11003. },
  11004. _documentClick: {
  11005. mousedown: function( event ) {
  11006. if ( !this.isOpen ) {
  11007. return;
  11008. }
  11009. if ( !$( event.target ).closest( ".ui-selectmenu-menu, #" +
  11010. $.ui.escapeSelector( this.ids.button ) ).length ) {
  11011. this.close( event );
  11012. }
  11013. }
  11014. },
  11015. _buttonEvents: {
  11016. // Prevent text selection from being reset when interacting with the selectmenu (#10144)
  11017. mousedown: function() {
  11018. var selection;
  11019. if ( window.getSelection ) {
  11020. selection = window.getSelection();
  11021. if ( selection.rangeCount ) {
  11022. this.range = selection.getRangeAt( 0 );
  11023. }
  11024. // Support: IE8
  11025. } else {
  11026. this.range = document.selection.createRange();
  11027. }
  11028. },
  11029. click: function( event ) {
  11030. this._setSelection();
  11031. this._toggle( event );
  11032. },
  11033. keydown: function( event ) {
  11034. var preventDefault = true;
  11035. switch ( event.keyCode ) {
  11036. case $.ui.keyCode.TAB:
  11037. case $.ui.keyCode.ESCAPE:
  11038. this.close( event );
  11039. preventDefault = false;
  11040. break;
  11041. case $.ui.keyCode.ENTER:
  11042. if ( this.isOpen ) {
  11043. this._selectFocusedItem( event );
  11044. }
  11045. break;
  11046. case $.ui.keyCode.UP:
  11047. if ( event.altKey ) {
  11048. this._toggle( event );
  11049. } else {
  11050. this._move( "prev", event );
  11051. }
  11052. break;
  11053. case $.ui.keyCode.DOWN:
  11054. if ( event.altKey ) {
  11055. this._toggle( event );
  11056. } else {
  11057. this._move( "next", event );
  11058. }
  11059. break;
  11060. case $.ui.keyCode.SPACE:
  11061. if ( this.isOpen ) {
  11062. this._selectFocusedItem( event );
  11063. } else {
  11064. this._toggle( event );
  11065. }
  11066. break;
  11067. case $.ui.keyCode.LEFT:
  11068. this._move( "prev", event );
  11069. break;
  11070. case $.ui.keyCode.RIGHT:
  11071. this._move( "next", event );
  11072. break;
  11073. case $.ui.keyCode.HOME:
  11074. case $.ui.keyCode.PAGE_UP:
  11075. this._move( "first", event );
  11076. break;
  11077. case $.ui.keyCode.END:
  11078. case $.ui.keyCode.PAGE_DOWN:
  11079. this._move( "last", event );
  11080. break;
  11081. default:
  11082. this.menu.trigger( event );
  11083. preventDefault = false;
  11084. }
  11085. if ( preventDefault ) {
  11086. event.preventDefault();
  11087. }
  11088. }
  11089. },
  11090. _selectFocusedItem: function( event ) {
  11091. var item = this.menuItems.eq( this.focusIndex ).parent( "li" );
  11092. if ( !item.hasClass( "ui-state-disabled" ) ) {
  11093. this._select( item.data( "ui-selectmenu-item" ), event );
  11094. }
  11095. },
  11096. _select: function( item, event ) {
  11097. var oldIndex = this.element[ 0 ].selectedIndex;
  11098. // Change native select element
  11099. this.element[ 0 ].selectedIndex = item.index;
  11100. this.buttonItem.replaceWith( this.buttonItem = this._renderButtonItem( item ) );
  11101. this._setAria( item );
  11102. this._trigger( "select", event, { item: item } );
  11103. if ( item.index !== oldIndex ) {
  11104. this._trigger( "change", event, { item: item } );
  11105. }
  11106. this.close( event );
  11107. },
  11108. _setAria: function( item ) {
  11109. var id = this.menuItems.eq( item.index ).attr( "id" );
  11110. this.button.attr( {
  11111. "aria-labelledby": id,
  11112. "aria-activedescendant": id
  11113. } );
  11114. this.menu.attr( "aria-activedescendant", id );
  11115. },
  11116. _setOption: function( key, value ) {
  11117. if ( key === "icons" ) {
  11118. var icon = this.button.find( "span.ui-icon" );
  11119. this._removeClass( icon, null, this.options.icons.button )
  11120. ._addClass( icon, null, value.button );
  11121. }
  11122. this._super( key, value );
  11123. if ( key === "appendTo" ) {
  11124. this.menuWrap.appendTo( this._appendTo() );
  11125. }
  11126. if ( key === "width" ) {
  11127. this._resizeButton();
  11128. }
  11129. },
  11130. _setOptionDisabled: function( value ) {
  11131. this._super( value );
  11132. this.menuInstance.option( "disabled", value );
  11133. this.button.attr( "aria-disabled", value );
  11134. this._toggleClass( this.button, null, "ui-state-disabled", value );
  11135. this.element.prop( "disabled", value );
  11136. if ( value ) {
  11137. this.button.attr( "tabindex", -1 );
  11138. this.close();
  11139. } else {
  11140. this.button.attr( "tabindex", 0 );
  11141. }
  11142. },
  11143. _appendTo: function() {
  11144. var element = this.options.appendTo;
  11145. if ( element ) {
  11146. element = element.jquery || element.nodeType ?
  11147. $( element ) :
  11148. this.document.find( element ).eq( 0 );
  11149. }
  11150. if ( !element || !element[ 0 ] ) {
  11151. element = this.element.closest( ".ui-front, dialog" );
  11152. }
  11153. if ( !element.length ) {
  11154. element = this.document[ 0 ].body;
  11155. }
  11156. return element;
  11157. },
  11158. _toggleAttr: function() {
  11159. this.button.attr( "aria-expanded", this.isOpen );
  11160. // We can't use two _toggleClass() calls here, because we need to make sure
  11161. // we always remove classes first and add them second, otherwise if both classes have the
  11162. // same theme class, it will be removed after we add it.
  11163. this._removeClass( this.button, "ui-selectmenu-button-" +
  11164. ( this.isOpen ? "closed" : "open" ) )
  11165. ._addClass( this.button, "ui-selectmenu-button-" +
  11166. ( this.isOpen ? "open" : "closed" ) )
  11167. ._toggleClass( this.menuWrap, "ui-selectmenu-open", null, this.isOpen );
  11168. this.menu.attr( "aria-hidden", !this.isOpen );
  11169. },
  11170. _resizeButton: function() {
  11171. var width = this.options.width;
  11172. // For `width: false`, just remove inline style and stop
  11173. if ( width === false ) {
  11174. this.button.css( "width", "" );
  11175. return;
  11176. }
  11177. // For `width: null`, match the width of the original element
  11178. if ( width === null ) {
  11179. width = this.element.show().outerWidth();
  11180. this.element.hide();
  11181. }
  11182. this.button.outerWidth( width );
  11183. },
  11184. _resizeMenu: function() {
  11185. this.menu.outerWidth( Math.max(
  11186. this.button.outerWidth(),
  11187. // Support: IE10
  11188. // IE10 wraps long text (possibly a rounding bug)
  11189. // so we add 1px to avoid the wrapping
  11190. this.menu.width( "" ).outerWidth() + 1
  11191. ) );
  11192. },
  11193. _getCreateOptions: function() {
  11194. var options = this._super();
  11195. options.disabled = this.element.prop( "disabled" );
  11196. return options;
  11197. },
  11198. _parseOptions: function( options ) {
  11199. var that = this,
  11200. data = [];
  11201. options.each( function( index, item ) {
  11202. data.push( that._parseOption( $( item ), index ) );
  11203. } );
  11204. this.items = data;
  11205. },
  11206. _parseOption: function( option, index ) {
  11207. var optgroup = option.parent( "optgroup" );
  11208. return {
  11209. element: option,
  11210. index: index,
  11211. value: option.val(),
  11212. label: option.text(),
  11213. optgroup: optgroup.attr( "label" ) || "",
  11214. disabled: optgroup.prop( "disabled" ) || option.prop( "disabled" )
  11215. };
  11216. },
  11217. _destroy: function() {
  11218. this._unbindFormResetHandler();
  11219. this.menuWrap.remove();
  11220. this.button.remove();
  11221. this.element.show();
  11222. this.element.removeUniqueId();
  11223. this.labels.attr( "for", this.ids.element );
  11224. }
  11225. } ] );
  11226. /*!
  11227. * jQuery UI Slider 1.12.0
  11228. * http://jqueryui.com
  11229. *
  11230. * Copyright jQuery Foundation and other contributors
  11231. * Released under the MIT license.
  11232. * http://jquery.org/license
  11233. */
  11234. //>>label: Slider
  11235. //>>group: Widgets
  11236. //>>description: Displays a flexible slider with ranges and accessibility via keyboard.
  11237. //>>docs: http://api.jqueryui.com/slider/
  11238. //>>demos: http://jqueryui.com/slider/
  11239. //>>css.structure: ../../themes/base/core.css
  11240. //>>css.structure: ../../themes/base/slider.css
  11241. //>>css.theme: ../../themes/base/theme.css
  11242. var widgetsSlider = $.widget( "ui.slider", $.ui.mouse, {
  11243. version: "1.12.0",
  11244. widgetEventPrefix: "slide",
  11245. options: {
  11246. animate: false,
  11247. classes: {
  11248. "ui-slider": "ui-corner-all",
  11249. "ui-slider-handle": "ui-corner-all",
  11250. // Note: ui-widget-header isn't the most fittingly semantic framework class for this
  11251. // element, but worked best visually with a variety of themes
  11252. "ui-slider-range": "ui-corner-all ui-widget-header"
  11253. },
  11254. distance: 0,
  11255. max: 100,
  11256. min: 0,
  11257. orientation: "horizontal",
  11258. range: false,
  11259. step: 1,
  11260. value: 0,
  11261. values: null,
  11262. // Callbacks
  11263. change: null,
  11264. slide: null,
  11265. start: null,
  11266. stop: null
  11267. },
  11268. // Number of pages in a slider
  11269. // (how many times can you page up/down to go through the whole range)
  11270. numPages: 5,
  11271. _create: function() {
  11272. this._keySliding = false;
  11273. this._mouseSliding = false;
  11274. this._animateOff = true;
  11275. this._handleIndex = null;
  11276. this._detectOrientation();
  11277. this._mouseInit();
  11278. this._calculateNewMax();
  11279. this._addClass( "ui-slider ui-slider-" + this.orientation,
  11280. "ui-widget ui-widget-content" );
  11281. this._refresh();
  11282. this._animateOff = false;
  11283. },
  11284. _refresh: function() {
  11285. this._createRange();
  11286. this._createHandles();
  11287. this._setupEvents();
  11288. this._refreshValue();
  11289. },
  11290. _createHandles: function() {
  11291. var i, handleCount,
  11292. options = this.options,
  11293. existingHandles = this.element.find( ".ui-slider-handle" ),
  11294. handle = "<span tabindex='0'></span>",
  11295. handles = [];
  11296. handleCount = ( options.values && options.values.length ) || 1;
  11297. if ( existingHandles.length > handleCount ) {
  11298. existingHandles.slice( handleCount ).remove();
  11299. existingHandles = existingHandles.slice( 0, handleCount );
  11300. }
  11301. for ( i = existingHandles.length; i < handleCount; i++ ) {
  11302. handles.push( handle );
  11303. }
  11304. this.handles = existingHandles.add( $( handles.join( "" ) ).appendTo( this.element ) );
  11305. this._addClass( this.handles, "ui-slider-handle", "ui-state-default" );
  11306. this.handle = this.handles.eq( 0 );
  11307. this.handles.each( function( i ) {
  11308. $( this ).data( "ui-slider-handle-index", i );
  11309. } );
  11310. },
  11311. _createRange: function() {
  11312. var options = this.options;
  11313. if ( options.range ) {
  11314. if ( options.range === true ) {
  11315. if ( !options.values ) {
  11316. options.values = [ this._valueMin(), this._valueMin() ];
  11317. } else if ( options.values.length && options.values.length !== 2 ) {
  11318. options.values = [ options.values[ 0 ], options.values[ 0 ] ];
  11319. } else if ( $.isArray( options.values ) ) {
  11320. options.values = options.values.slice( 0 );
  11321. }
  11322. }
  11323. if ( !this.range || !this.range.length ) {
  11324. this.range = $( "<div>" )
  11325. .appendTo( this.element );
  11326. this._addClass( this.range, "ui-slider-range" );
  11327. } else {
  11328. this._removeClass( this.range, "ui-slider-range-min ui-slider-range-max" );
  11329. // Handle range switching from true to min/max
  11330. this.range.css( {
  11331. "left": "",
  11332. "bottom": ""
  11333. } );
  11334. }
  11335. if ( options.range === "min" || options.range === "max" ) {
  11336. this._addClass( this.range, "ui-slider-range-" + options.range );
  11337. }
  11338. } else {
  11339. if ( this.range ) {
  11340. this.range.remove();
  11341. }
  11342. this.range = null;
  11343. }
  11344. },
  11345. _setupEvents: function() {
  11346. this._off( this.handles );
  11347. this._on( this.handles, this._handleEvents );
  11348. this._hoverable( this.handles );
  11349. this._focusable( this.handles );
  11350. },
  11351. _destroy: function() {
  11352. this.handles.remove();
  11353. if ( this.range ) {
  11354. this.range.remove();
  11355. }
  11356. this._mouseDestroy();
  11357. },
  11358. _mouseCapture: function( event ) {
  11359. var position, normValue, distance, closestHandle, index, allowed, offset, mouseOverHandle,
  11360. that = this,
  11361. o = this.options;
  11362. if ( o.disabled ) {
  11363. return false;
  11364. }
  11365. this.elementSize = {
  11366. width: this.element.outerWidth(),
  11367. height: this.element.outerHeight()
  11368. };
  11369. this.elementOffset = this.element.offset();
  11370. position = { x: event.pageX, y: event.pageY };
  11371. normValue = this._normValueFromMouse( position );
  11372. distance = this._valueMax() - this._valueMin() + 1;
  11373. this.handles.each( function( i ) {
  11374. var thisDistance = Math.abs( normValue - that.values( i ) );
  11375. if ( ( distance > thisDistance ) ||
  11376. ( distance === thisDistance &&
  11377. ( i === that._lastChangedValue || that.values( i ) === o.min ) ) ) {
  11378. distance = thisDistance;
  11379. closestHandle = $( this );
  11380. index = i;
  11381. }
  11382. } );
  11383. allowed = this._start( event, index );
  11384. if ( allowed === false ) {
  11385. return false;
  11386. }
  11387. this._mouseSliding = true;
  11388. this._handleIndex = index;
  11389. this._addClass( closestHandle, null, "ui-state-active" );
  11390. closestHandle.trigger( "focus" );
  11391. offset = closestHandle.offset();
  11392. mouseOverHandle = !$( event.target ).parents().addBack().is( ".ui-slider-handle" );
  11393. this._clickOffset = mouseOverHandle ? { left: 0, top: 0 } : {
  11394. left: event.pageX - offset.left - ( closestHandle.width() / 2 ),
  11395. top: event.pageY - offset.top -
  11396. ( closestHandle.height() / 2 ) -
  11397. ( parseInt( closestHandle.css( "borderTopWidth" ), 10 ) || 0 ) -
  11398. ( parseInt( closestHandle.css( "borderBottomWidth" ), 10 ) || 0 ) +
  11399. ( parseInt( closestHandle.css( "marginTop" ), 10 ) || 0 )
  11400. };
  11401. if ( !this.handles.hasClass( "ui-state-hover" ) ) {
  11402. this._slide( event, index, normValue );
  11403. }
  11404. this._animateOff = true;
  11405. return true;
  11406. },
  11407. _mouseStart: function() {
  11408. return true;
  11409. },
  11410. _mouseDrag: function( event ) {
  11411. var position = { x: event.pageX, y: event.pageY },
  11412. normValue = this._normValueFromMouse( position );
  11413. this._slide( event, this._handleIndex, normValue );
  11414. return false;
  11415. },
  11416. _mouseStop: function( event ) {
  11417. this._removeClass( this.handles, null, "ui-state-active" );
  11418. this._mouseSliding = false;
  11419. this._stop( event, this._handleIndex );
  11420. this._change( event, this._handleIndex );
  11421. this._handleIndex = null;
  11422. this._clickOffset = null;
  11423. this._animateOff = false;
  11424. return false;
  11425. },
  11426. _detectOrientation: function() {
  11427. this.orientation = ( this.options.orientation === "vertical" ) ? "vertical" : "horizontal";
  11428. },
  11429. _normValueFromMouse: function( position ) {
  11430. var pixelTotal,
  11431. pixelMouse,
  11432. percentMouse,
  11433. valueTotal,
  11434. valueMouse;
  11435. if ( this.orientation === "horizontal" ) {
  11436. pixelTotal = this.elementSize.width;
  11437. pixelMouse = position.x - this.elementOffset.left -
  11438. ( this._clickOffset ? this._clickOffset.left : 0 );
  11439. } else {
  11440. pixelTotal = this.elementSize.height;
  11441. pixelMouse = position.y - this.elementOffset.top -
  11442. ( this._clickOffset ? this._clickOffset.top : 0 );
  11443. }
  11444. percentMouse = ( pixelMouse / pixelTotal );
  11445. if ( percentMouse > 1 ) {
  11446. percentMouse = 1;
  11447. }
  11448. if ( percentMouse < 0 ) {
  11449. percentMouse = 0;
  11450. }
  11451. if ( this.orientation === "vertical" ) {
  11452. percentMouse = 1 - percentMouse;
  11453. }
  11454. valueTotal = this._valueMax() - this._valueMin();
  11455. valueMouse = this._valueMin() + percentMouse * valueTotal;
  11456. return this._trimAlignValue( valueMouse );
  11457. },
  11458. _uiHash: function( index, value, values ) {
  11459. var uiHash = {
  11460. handle: this.handles[ index ],
  11461. handleIndex: index,
  11462. value: value !== undefined ? value : this.value()
  11463. };
  11464. if ( this._hasMultipleValues() ) {
  11465. uiHash.value = value !== undefined ? value : this.values( index );
  11466. uiHash.values = values || this.values();
  11467. }
  11468. return uiHash;
  11469. },
  11470. _hasMultipleValues: function() {
  11471. return this.options.values && this.options.values.length;
  11472. },
  11473. _start: function( event, index ) {
  11474. return this._trigger( "start", event, this._uiHash( index ) );
  11475. },
  11476. _slide: function( event, index, newVal ) {
  11477. var allowed, otherVal,
  11478. currentValue = this.value(),
  11479. newValues = this.values();
  11480. if ( this._hasMultipleValues() ) {
  11481. otherVal = this.values( index ? 0 : 1 );
  11482. currentValue = this.values( index );
  11483. if ( this.options.values.length === 2 && this.options.range === true ) {
  11484. newVal = index === 0 ? Math.min( otherVal, newVal ) : Math.max( otherVal, newVal );
  11485. }
  11486. newValues[ index ] = newVal;
  11487. }
  11488. if ( newVal === currentValue ) {
  11489. return;
  11490. }
  11491. allowed = this._trigger( "slide", event, this._uiHash( index, newVal, newValues ) );
  11492. // A slide can be canceled by returning false from the slide callback
  11493. if ( allowed === false ) {
  11494. return;
  11495. }
  11496. if ( this._hasMultipleValues() ) {
  11497. this.values( index, newVal );
  11498. } else {
  11499. this.value( newVal );
  11500. }
  11501. },
  11502. _stop: function( event, index ) {
  11503. this._trigger( "stop", event, this._uiHash( index ) );
  11504. },
  11505. _change: function( event, index ) {
  11506. if ( !this._keySliding && !this._mouseSliding ) {
  11507. //store the last changed value index for reference when handles overlap
  11508. this._lastChangedValue = index;
  11509. this._trigger( "change", event, this._uiHash( index ) );
  11510. }
  11511. },
  11512. value: function( newValue ) {
  11513. if ( arguments.length ) {
  11514. this.options.value = this._trimAlignValue( newValue );
  11515. this._refreshValue();
  11516. this._change( null, 0 );
  11517. return;
  11518. }
  11519. return this._value();
  11520. },
  11521. values: function( index, newValue ) {
  11522. var vals,
  11523. newValues,
  11524. i;
  11525. if ( arguments.length > 1 ) {
  11526. this.options.values[ index ] = this._trimAlignValue( newValue );
  11527. this._refreshValue();
  11528. this._change( null, index );
  11529. return;
  11530. }
  11531. if ( arguments.length ) {
  11532. if ( $.isArray( arguments[ 0 ] ) ) {
  11533. vals = this.options.values;
  11534. newValues = arguments[ 0 ];
  11535. for ( i = 0; i < vals.length; i += 1 ) {
  11536. vals[ i ] = this._trimAlignValue( newValues[ i ] );
  11537. this._change( null, i );
  11538. }
  11539. this._refreshValue();
  11540. } else {
  11541. if ( this._hasMultipleValues() ) {
  11542. return this._values( index );
  11543. } else {
  11544. return this.value();
  11545. }
  11546. }
  11547. } else {
  11548. return this._values();
  11549. }
  11550. },
  11551. _setOption: function( key, value ) {
  11552. var i,
  11553. valsLength = 0;
  11554. if ( key === "range" && this.options.range === true ) {
  11555. if ( value === "min" ) {
  11556. this.options.value = this._values( 0 );
  11557. this.options.values = null;
  11558. } else if ( value === "max" ) {
  11559. this.options.value = this._values( this.options.values.length - 1 );
  11560. this.options.values = null;
  11561. }
  11562. }
  11563. if ( $.isArray( this.options.values ) ) {
  11564. valsLength = this.options.values.length;
  11565. }
  11566. this._super( key, value );
  11567. switch ( key ) {
  11568. case "orientation":
  11569. this._detectOrientation();
  11570. this._removeClass( "ui-slider-horizontal ui-slider-vertical" )
  11571. ._addClass( "ui-slider-" + this.orientation );
  11572. this._refreshValue();
  11573. if ( this.options.range ) {
  11574. this._refreshRange( value );
  11575. }
  11576. // Reset positioning from previous orientation
  11577. this.handles.css( value === "horizontal" ? "bottom" : "left", "" );
  11578. break;
  11579. case "value":
  11580. this._animateOff = true;
  11581. this._refreshValue();
  11582. this._change( null, 0 );
  11583. this._animateOff = false;
  11584. break;
  11585. case "values":
  11586. this._animateOff = true;
  11587. this._refreshValue();
  11588. // Start from the last handle to prevent unreachable handles (#9046)
  11589. for ( i = valsLength - 1; i >= 0; i-- ) {
  11590. this._change( null, i );
  11591. }
  11592. this._animateOff = false;
  11593. break;
  11594. case "step":
  11595. case "min":
  11596. case "max":
  11597. this._animateOff = true;
  11598. this._calculateNewMax();
  11599. this._refreshValue();
  11600. this._animateOff = false;
  11601. break;
  11602. case "range":
  11603. this._animateOff = true;
  11604. this._refresh();
  11605. this._animateOff = false;
  11606. break;
  11607. }
  11608. },
  11609. _setOptionDisabled: function( value ) {
  11610. this._super( value );
  11611. this._toggleClass( null, "ui-state-disabled", !!value );
  11612. },
  11613. //internal value getter
  11614. // _value() returns value trimmed by min and max, aligned by step
  11615. _value: function() {
  11616. var val = this.options.value;
  11617. val = this._trimAlignValue( val );
  11618. return val;
  11619. },
  11620. //internal values getter
  11621. // _values() returns array of values trimmed by min and max, aligned by step
  11622. // _values( index ) returns single value trimmed by min and max, aligned by step
  11623. _values: function( index ) {
  11624. var val,
  11625. vals,
  11626. i;
  11627. if ( arguments.length ) {
  11628. val = this.options.values[ index ];
  11629. val = this._trimAlignValue( val );
  11630. return val;
  11631. } else if ( this._hasMultipleValues() ) {
  11632. // .slice() creates a copy of the array
  11633. // this copy gets trimmed by min and max and then returned
  11634. vals = this.options.values.slice();
  11635. for ( i = 0; i < vals.length; i += 1 ) {
  11636. vals[ i ] = this._trimAlignValue( vals[ i ] );
  11637. }
  11638. return vals;
  11639. } else {
  11640. return [];
  11641. }
  11642. },
  11643. // Returns the step-aligned value that val is closest to, between (inclusive) min and max
  11644. _trimAlignValue: function( val ) {
  11645. if ( val <= this._valueMin() ) {
  11646. return this._valueMin();
  11647. }
  11648. if ( val >= this._valueMax() ) {
  11649. return this._valueMax();
  11650. }
  11651. var step = ( this.options.step > 0 ) ? this.options.step : 1,
  11652. valModStep = ( val - this._valueMin() ) % step,
  11653. alignValue = val - valModStep;
  11654. if ( Math.abs( valModStep ) * 2 >= step ) {
  11655. alignValue += ( valModStep > 0 ) ? step : ( -step );
  11656. }
  11657. // Since JavaScript has problems with large floats, round
  11658. // the final value to 5 digits after the decimal point (see #4124)
  11659. return parseFloat( alignValue.toFixed( 5 ) );
  11660. },
  11661. _calculateNewMax: function() {
  11662. var max = this.options.max,
  11663. min = this._valueMin(),
  11664. step = this.options.step,
  11665. aboveMin = Math.round( ( max - min ) / step ) * step;
  11666. max = aboveMin + min;
  11667. if ( max > this.options.max ) {
  11668. //If max is not divisible by step, rounding off may increase its value
  11669. max -= step;
  11670. }
  11671. this.max = parseFloat( max.toFixed( this._precision() ) );
  11672. },
  11673. _precision: function() {
  11674. var precision = this._precisionOf( this.options.step );
  11675. if ( this.options.min !== null ) {
  11676. precision = Math.max( precision, this._precisionOf( this.options.min ) );
  11677. }
  11678. return precision;
  11679. },
  11680. _precisionOf: function( num ) {
  11681. var str = num.toString(),
  11682. decimal = str.indexOf( "." );
  11683. return decimal === -1 ? 0 : str.length - decimal - 1;
  11684. },
  11685. _valueMin: function() {
  11686. return this.options.min;
  11687. },
  11688. _valueMax: function() {
  11689. return this.max;
  11690. },
  11691. _refreshRange: function( orientation ) {
  11692. if ( orientation === "vertical" ) {
  11693. this.range.css( { "width": "", "left": "" } );
  11694. }
  11695. if ( orientation === "horizontal" ) {
  11696. this.range.css( { "height": "", "bottom": "" } );
  11697. }
  11698. },
  11699. _refreshValue: function() {
  11700. var lastValPercent, valPercent, value, valueMin, valueMax,
  11701. oRange = this.options.range,
  11702. o = this.options,
  11703. that = this,
  11704. animate = ( !this._animateOff ) ? o.animate : false,
  11705. _set = {};
  11706. if ( this._hasMultipleValues() ) {
  11707. this.handles.each( function( i ) {
  11708. valPercent = ( that.values( i ) - that._valueMin() ) / ( that._valueMax() -
  11709. that._valueMin() ) * 100;
  11710. _set[ that.orientation === "horizontal" ? "left" : "bottom" ] = valPercent + "%";
  11711. $( this ).stop( 1, 1 )[ animate ? "animate" : "css" ]( _set, o.animate );
  11712. if ( that.options.range === true ) {
  11713. if ( that.orientation === "horizontal" ) {
  11714. if ( i === 0 ) {
  11715. that.range.stop( 1, 1 )[ animate ? "animate" : "css" ]( {
  11716. left: valPercent + "%"
  11717. }, o.animate );
  11718. }
  11719. if ( i === 1 ) {
  11720. that.range[ animate ? "animate" : "css" ]( {
  11721. width: ( valPercent - lastValPercent ) + "%"
  11722. }, {
  11723. queue: false,
  11724. duration: o.animate
  11725. } );
  11726. }
  11727. } else {
  11728. if ( i === 0 ) {
  11729. that.range.stop( 1, 1 )[ animate ? "animate" : "css" ]( {
  11730. bottom: ( valPercent ) + "%"
  11731. }, o.animate );
  11732. }
  11733. if ( i === 1 ) {
  11734. that.range[ animate ? "animate" : "css" ]( {
  11735. height: ( valPercent - lastValPercent ) + "%"
  11736. }, {
  11737. queue: false,
  11738. duration: o.animate
  11739. } );
  11740. }
  11741. }
  11742. }
  11743. lastValPercent = valPercent;
  11744. } );
  11745. } else {
  11746. value = this.value();
  11747. valueMin = this._valueMin();
  11748. valueMax = this._valueMax();
  11749. valPercent = ( valueMax !== valueMin ) ?
  11750. ( value - valueMin ) / ( valueMax - valueMin ) * 100 :
  11751. 0;
  11752. _set[ this.orientation === "horizontal" ? "left" : "bottom" ] = valPercent + "%";
  11753. this.handle.stop( 1, 1 )[ animate ? "animate" : "css" ]( _set, o.animate );
  11754. if ( oRange === "min" && this.orientation === "horizontal" ) {
  11755. this.range.stop( 1, 1 )[ animate ? "animate" : "css" ]( {
  11756. width: valPercent + "%"
  11757. }, o.animate );
  11758. }
  11759. if ( oRange === "max" && this.orientation === "horizontal" ) {
  11760. this.range.stop( 1, 1 )[ animate ? "animate" : "css" ]( {
  11761. width: ( 100 - valPercent ) + "%"
  11762. }, o.animate );
  11763. }
  11764. if ( oRange === "min" && this.orientation === "vertical" ) {
  11765. this.range.stop( 1, 1 )[ animate ? "animate" : "css" ]( {
  11766. height: valPercent + "%"
  11767. }, o.animate );
  11768. }
  11769. if ( oRange === "max" && this.orientation === "vertical" ) {
  11770. this.range.stop( 1, 1 )[ animate ? "animate" : "css" ]( {
  11771. height: ( 100 - valPercent ) + "%"
  11772. }, o.animate );
  11773. }
  11774. }
  11775. },
  11776. _handleEvents: {
  11777. keydown: function( event ) {
  11778. var allowed, curVal, newVal, step,
  11779. index = $( event.target ).data( "ui-slider-handle-index" );
  11780. switch ( event.keyCode ) {
  11781. case $.ui.keyCode.HOME:
  11782. case $.ui.keyCode.END:
  11783. case $.ui.keyCode.PAGE_UP:
  11784. case $.ui.keyCode.PAGE_DOWN:
  11785. case $.ui.keyCode.UP:
  11786. case $.ui.keyCode.RIGHT:
  11787. case $.ui.keyCode.DOWN:
  11788. case $.ui.keyCode.LEFT:
  11789. event.preventDefault();
  11790. if ( !this._keySliding ) {
  11791. this._keySliding = true;
  11792. this._addClass( $( event.target ), null, "ui-state-active" );
  11793. allowed = this._start( event, index );
  11794. if ( allowed === false ) {
  11795. return;
  11796. }
  11797. }
  11798. break;
  11799. }
  11800. step = this.options.step;
  11801. if ( this._hasMultipleValues() ) {
  11802. curVal = newVal = this.values( index );
  11803. } else {
  11804. curVal = newVal = this.value();
  11805. }
  11806. switch ( event.keyCode ) {
  11807. case $.ui.keyCode.HOME:
  11808. newVal = this._valueMin();
  11809. break;
  11810. case $.ui.keyCode.END:
  11811. newVal = this._valueMax();
  11812. break;
  11813. case $.ui.keyCode.PAGE_UP:
  11814. newVal = this._trimAlignValue(
  11815. curVal + ( ( this._valueMax() - this._valueMin() ) / this.numPages )
  11816. );
  11817. break;
  11818. case $.ui.keyCode.PAGE_DOWN:
  11819. newVal = this._trimAlignValue(
  11820. curVal - ( ( this._valueMax() - this._valueMin() ) / this.numPages ) );
  11821. break;
  11822. case $.ui.keyCode.UP:
  11823. case $.ui.keyCode.RIGHT:
  11824. if ( curVal === this._valueMax() ) {
  11825. return;
  11826. }
  11827. newVal = this._trimAlignValue( curVal + step );
  11828. break;
  11829. case $.ui.keyCode.DOWN:
  11830. case $.ui.keyCode.LEFT:
  11831. if ( curVal === this._valueMin() ) {
  11832. return;
  11833. }
  11834. newVal = this._trimAlignValue( curVal - step );
  11835. break;
  11836. }
  11837. this._slide( event, index, newVal );
  11838. },
  11839. keyup: function( event ) {
  11840. var index = $( event.target ).data( "ui-slider-handle-index" );
  11841. if ( this._keySliding ) {
  11842. this._keySliding = false;
  11843. this._stop( event, index );
  11844. this._change( event, index );
  11845. this._removeClass( $( event.target ), null, "ui-state-active" );
  11846. }
  11847. }
  11848. }
  11849. } );
  11850. /*!
  11851. * jQuery UI Spinner 1.12.0
  11852. * http://jqueryui.com
  11853. *
  11854. * Copyright jQuery Foundation and other contributors
  11855. * Released under the MIT license.
  11856. * http://jquery.org/license
  11857. */
  11858. //>>label: Spinner
  11859. //>>group: Widgets
  11860. //>>description: Displays buttons to easily input numbers via the keyboard or mouse.
  11861. //>>docs: http://api.jqueryui.com/spinner/
  11862. //>>demos: http://jqueryui.com/spinner/
  11863. //>>css.structure: ../../themes/base/core.css
  11864. //>>css.structure: ../../themes/base/spinner.css
  11865. //>>css.theme: ../../themes/base/theme.css
  11866. function spinnerModifer( fn ) {
  11867. return function() {
  11868. var previous = this.element.val();
  11869. fn.apply( this, arguments );
  11870. this._refresh();
  11871. if ( previous !== this.element.val() ) {
  11872. this._trigger( "change" );
  11873. }
  11874. };
  11875. }
  11876. $.widget( "ui.spinner", {
  11877. version: "1.12.0",
  11878. defaultElement: "<input>",
  11879. widgetEventPrefix: "spin",
  11880. options: {
  11881. classes: {
  11882. "ui-spinner": "ui-corner-all",
  11883. "ui-spinner-down": "ui-corner-br",
  11884. "ui-spinner-up": "ui-corner-tr"
  11885. },
  11886. culture: null,
  11887. icons: {
  11888. down: "ui-icon-triangle-1-s",
  11889. up: "ui-icon-triangle-1-n"
  11890. },
  11891. incremental: true,
  11892. max: null,
  11893. min: null,
  11894. numberFormat: null,
  11895. page: 10,
  11896. step: 1,
  11897. change: null,
  11898. spin: null,
  11899. start: null,
  11900. stop: null
  11901. },
  11902. _create: function() {
  11903. // handle string values that need to be parsed
  11904. this._setOption( "max", this.options.max );
  11905. this._setOption( "min", this.options.min );
  11906. this._setOption( "step", this.options.step );
  11907. // Only format if there is a value, prevents the field from being marked
  11908. // as invalid in Firefox, see #9573.
  11909. if ( this.value() !== "" ) {
  11910. // Format the value, but don't constrain.
  11911. this._value( this.element.val(), true );
  11912. }
  11913. this._draw();
  11914. this._on( this._events );
  11915. this._refresh();
  11916. // Turning off autocomplete prevents the browser from remembering the
  11917. // value when navigating through history, so we re-enable autocomplete
  11918. // if the page is unloaded before the widget is destroyed. #7790
  11919. this._on( this.window, {
  11920. beforeunload: function() {
  11921. this.element.removeAttr( "autocomplete" );
  11922. }
  11923. } );
  11924. },
  11925. _getCreateOptions: function() {
  11926. var options = this._super();
  11927. var element = this.element;
  11928. $.each( [ "min", "max", "step" ], function( i, option ) {
  11929. var value = element.attr( option );
  11930. if ( value != null && value.length ) {
  11931. options[ option ] = value;
  11932. }
  11933. } );
  11934. return options;
  11935. },
  11936. _events: {
  11937. keydown: function( event ) {
  11938. if ( this._start( event ) && this._keydown( event ) ) {
  11939. event.preventDefault();
  11940. }
  11941. },
  11942. keyup: "_stop",
  11943. focus: function() {
  11944. this.previous = this.element.val();
  11945. },
  11946. blur: function( event ) {
  11947. if ( this.cancelBlur ) {
  11948. delete this.cancelBlur;
  11949. return;
  11950. }
  11951. this._stop();
  11952. this._refresh();
  11953. if ( this.previous !== this.element.val() ) {
  11954. this._trigger( "change", event );
  11955. }
  11956. },
  11957. mousewheel: function( event, delta ) {
  11958. if ( !delta ) {
  11959. return;
  11960. }
  11961. if ( !this.spinning && !this._start( event ) ) {
  11962. return false;
  11963. }
  11964. this._spin( ( delta > 0 ? 1 : -1 ) * this.options.step, event );
  11965. clearTimeout( this.mousewheelTimer );
  11966. this.mousewheelTimer = this._delay( function() {
  11967. if ( this.spinning ) {
  11968. this._stop( event );
  11969. }
  11970. }, 100 );
  11971. event.preventDefault();
  11972. },
  11973. "mousedown .ui-spinner-button": function( event ) {
  11974. var previous;
  11975. // We never want the buttons to have focus; whenever the user is
  11976. // interacting with the spinner, the focus should be on the input.
  11977. // If the input is focused then this.previous is properly set from
  11978. // when the input first received focus. If the input is not focused
  11979. // then we need to set this.previous based on the value before spinning.
  11980. previous = this.element[ 0 ] === $.ui.safeActiveElement( this.document[ 0 ] ) ?
  11981. this.previous : this.element.val();
  11982. function checkFocus() {
  11983. var isActive = this.element[ 0 ] === $.ui.safeActiveElement( this.document[ 0 ] );
  11984. if ( !isActive ) {
  11985. this.element.trigger( "focus" );
  11986. this.previous = previous;
  11987. // support: IE
  11988. // IE sets focus asynchronously, so we need to check if focus
  11989. // moved off of the input because the user clicked on the button.
  11990. this._delay( function() {
  11991. this.previous = previous;
  11992. } );
  11993. }
  11994. }
  11995. // Ensure focus is on (or stays on) the text field
  11996. event.preventDefault();
  11997. checkFocus.call( this );
  11998. // Support: IE
  11999. // IE doesn't prevent moving focus even with event.preventDefault()
  12000. // so we set a flag to know when we should ignore the blur event
  12001. // and check (again) if focus moved off of the input.
  12002. this.cancelBlur = true;
  12003. this._delay( function() {
  12004. delete this.cancelBlur;
  12005. checkFocus.call( this );
  12006. } );
  12007. if ( this._start( event ) === false ) {
  12008. return;
  12009. }
  12010. this._repeat( null, $( event.currentTarget )
  12011. .hasClass( "ui-spinner-up" ) ? 1 : -1, event );
  12012. },
  12013. "mouseup .ui-spinner-button": "_stop",
  12014. "mouseenter .ui-spinner-button": function( event ) {
  12015. // button will add ui-state-active if mouse was down while mouseleave and kept down
  12016. if ( !$( event.currentTarget ).hasClass( "ui-state-active" ) ) {
  12017. return;
  12018. }
  12019. if ( this._start( event ) === false ) {
  12020. return false;
  12021. }
  12022. this._repeat( null, $( event.currentTarget )
  12023. .hasClass( "ui-spinner-up" ) ? 1 : -1, event );
  12024. },
  12025. // TODO: do we really want to consider this a stop?
  12026. // shouldn't we just stop the repeater and wait until mouseup before
  12027. // we trigger the stop event?
  12028. "mouseleave .ui-spinner-button": "_stop"
  12029. },
  12030. // Support mobile enhanced option and make backcompat more sane
  12031. _enhance: function() {
  12032. this.uiSpinner = this.element
  12033. .attr( "autocomplete", "off" )
  12034. .wrap( "<span>" )
  12035. .parent()
  12036. // Add buttons
  12037. .append(
  12038. "<a></a><a></a>"
  12039. );
  12040. },
  12041. _draw: function() {
  12042. this._enhance();
  12043. this._addClass( this.uiSpinner, "ui-spinner", "ui-widget ui-widget-content" );
  12044. this._addClass( "ui-spinner-input" );
  12045. this.element.attr( "role", "spinbutton" );
  12046. // Button bindings
  12047. this.buttons = this.uiSpinner.children( "a" )
  12048. .attr( "tabIndex", -1 )
  12049. .attr( "aria-hidden", true )
  12050. .button( {
  12051. classes: {
  12052. "ui-button": ""
  12053. }
  12054. } );
  12055. // TODO: Right now button does not support classes this is already updated in button PR
  12056. this._removeClass( this.buttons, "ui-corner-all" );
  12057. this._addClass( this.buttons.first(), "ui-spinner-button ui-spinner-up" );
  12058. this._addClass( this.buttons.last(), "ui-spinner-button ui-spinner-down" );
  12059. this.buttons.first().button( {
  12060. "icon": this.options.icons.up,
  12061. "showLabel": false
  12062. } );
  12063. this.buttons.last().button( {
  12064. "icon": this.options.icons.down,
  12065. "showLabel": false
  12066. } );
  12067. // IE 6 doesn't understand height: 50% for the buttons
  12068. // unless the wrapper has an explicit height
  12069. if ( this.buttons.height() > Math.ceil( this.uiSpinner.height() * 0.5 ) &&
  12070. this.uiSpinner.height() > 0 ) {
  12071. this.uiSpinner.height( this.uiSpinner.height() );
  12072. }
  12073. },
  12074. _keydown: function( event ) {
  12075. var options = this.options,
  12076. keyCode = $.ui.keyCode;
  12077. switch ( event.keyCode ) {
  12078. case keyCode.UP:
  12079. this._repeat( null, 1, event );
  12080. return true;
  12081. case keyCode.DOWN:
  12082. this._repeat( null, -1, event );
  12083. return true;
  12084. case keyCode.PAGE_UP:
  12085. this._repeat( null, options.page, event );
  12086. return true;
  12087. case keyCode.PAGE_DOWN:
  12088. this._repeat( null, -options.page, event );
  12089. return true;
  12090. }
  12091. return false;
  12092. },
  12093. _start: function( event ) {
  12094. if ( !this.spinning && this._trigger( "start", event ) === false ) {
  12095. return false;
  12096. }
  12097. if ( !this.counter ) {
  12098. this.counter = 1;
  12099. }
  12100. this.spinning = true;
  12101. return true;
  12102. },
  12103. _repeat: function( i, steps, event ) {
  12104. i = i || 500;
  12105. clearTimeout( this.timer );
  12106. this.timer = this._delay( function() {
  12107. this._repeat( 40, steps, event );
  12108. }, i );
  12109. this._spin( steps * this.options.step, event );
  12110. },
  12111. _spin: function( step, event ) {
  12112. var value = this.value() || 0;
  12113. if ( !this.counter ) {
  12114. this.counter = 1;
  12115. }
  12116. value = this._adjustValue( value + step * this._increment( this.counter ) );
  12117. if ( !this.spinning || this._trigger( "spin", event, { value: value } ) !== false ) {
  12118. this._value( value );
  12119. this.counter++;
  12120. }
  12121. },
  12122. _increment: function( i ) {
  12123. var incremental = this.options.incremental;
  12124. if ( incremental ) {
  12125. return $.isFunction( incremental ) ?
  12126. incremental( i ) :
  12127. Math.floor( i * i * i / 50000 - i * i / 500 + 17 * i / 200 + 1 );
  12128. }
  12129. return 1;
  12130. },
  12131. _precision: function() {
  12132. var precision = this._precisionOf( this.options.step );
  12133. if ( this.options.min !== null ) {
  12134. precision = Math.max( precision, this._precisionOf( this.options.min ) );
  12135. }
  12136. return precision;
  12137. },
  12138. _precisionOf: function( num ) {
  12139. var str = num.toString(),
  12140. decimal = str.indexOf( "." );
  12141. return decimal === -1 ? 0 : str.length - decimal - 1;
  12142. },
  12143. _adjustValue: function( value ) {
  12144. var base, aboveMin,
  12145. options = this.options;
  12146. // Make sure we're at a valid step
  12147. // - find out where we are relative to the base (min or 0)
  12148. base = options.min !== null ? options.min : 0;
  12149. aboveMin = value - base;
  12150. // - round to the nearest step
  12151. aboveMin = Math.round( aboveMin / options.step ) * options.step;
  12152. // - rounding is based on 0, so adjust back to our base
  12153. value = base + aboveMin;
  12154. // Fix precision from bad JS floating point math
  12155. value = parseFloat( value.toFixed( this._precision() ) );
  12156. // Clamp the value
  12157. if ( options.max !== null && value > options.max ) {
  12158. return options.max;
  12159. }
  12160. if ( options.min !== null && value < options.min ) {
  12161. return options.min;
  12162. }
  12163. return value;
  12164. },
  12165. _stop: function( event ) {
  12166. if ( !this.spinning ) {
  12167. return;
  12168. }
  12169. clearTimeout( this.timer );
  12170. clearTimeout( this.mousewheelTimer );
  12171. this.counter = 0;
  12172. this.spinning = false;
  12173. this._trigger( "stop", event );
  12174. },
  12175. _setOption: function( key, value ) {
  12176. var prevValue, first, last;
  12177. if ( key === "culture" || key === "numberFormat" ) {
  12178. prevValue = this._parse( this.element.val() );
  12179. this.options[ key ] = value;
  12180. this.element.val( this._format( prevValue ) );
  12181. return;
  12182. }
  12183. if ( key === "max" || key === "min" || key === "step" ) {
  12184. if ( typeof value === "string" ) {
  12185. value = this._parse( value );
  12186. }
  12187. }
  12188. if ( key === "icons" ) {
  12189. first = this.buttons.first().find( ".ui-icon" );
  12190. this._removeClass( first, null, this.options.icons.up );
  12191. this._addClass( first, null, value.up );
  12192. last = this.buttons.last().find( ".ui-icon" );
  12193. this._removeClass( last, null, this.options.icons.down );
  12194. this._addClass( last, null, value.down );
  12195. }
  12196. this._super( key, value );
  12197. },
  12198. _setOptionDisabled: function( value ) {
  12199. this._super( value );
  12200. this._toggleClass( this.uiSpinner, null, "ui-state-disabled", !!value );
  12201. this.element.prop( "disabled", !!value );
  12202. this.buttons.button( value ? "disable" : "enable" );
  12203. },
  12204. _setOptions: spinnerModifer( function( options ) {
  12205. this._super( options );
  12206. } ),
  12207. _parse: function( val ) {
  12208. if ( typeof val === "string" && val !== "" ) {
  12209. val = window.Globalize && this.options.numberFormat ?
  12210. Globalize.parseFloat( val, 10, this.options.culture ) : +val;
  12211. }
  12212. return val === "" || isNaN( val ) ? null : val;
  12213. },
  12214. _format: function( value ) {
  12215. if ( value === "" ) {
  12216. return "";
  12217. }
  12218. return window.Globalize && this.options.numberFormat ?
  12219. Globalize.format( value, this.options.numberFormat, this.options.culture ) :
  12220. value;
  12221. },
  12222. _refresh: function() {
  12223. this.element.attr( {
  12224. "aria-valuemin": this.options.min,
  12225. "aria-valuemax": this.options.max,
  12226. // TODO: what should we do with values that can't be parsed?
  12227. "aria-valuenow": this._parse( this.element.val() )
  12228. } );
  12229. },
  12230. isValid: function() {
  12231. var value = this.value();
  12232. // Null is invalid
  12233. if ( value === null ) {
  12234. return false;
  12235. }
  12236. // If value gets adjusted, it's invalid
  12237. return value === this._adjustValue( value );
  12238. },
  12239. // Update the value without triggering change
  12240. _value: function( value, allowAny ) {
  12241. var parsed;
  12242. if ( value !== "" ) {
  12243. parsed = this._parse( value );
  12244. if ( parsed !== null ) {
  12245. if ( !allowAny ) {
  12246. parsed = this._adjustValue( parsed );
  12247. }
  12248. value = this._format( parsed );
  12249. }
  12250. }
  12251. this.element.val( value );
  12252. this._refresh();
  12253. },
  12254. _destroy: function() {
  12255. this.element
  12256. .prop( "disabled", false )
  12257. .removeAttr( "autocomplete role aria-valuemin aria-valuemax aria-valuenow" );
  12258. this.uiSpinner.replaceWith( this.element );
  12259. },
  12260. stepUp: spinnerModifer( function( steps ) {
  12261. this._stepUp( steps );
  12262. } ),
  12263. _stepUp: function( steps ) {
  12264. if ( this._start() ) {
  12265. this._spin( ( steps || 1 ) * this.options.step );
  12266. this._stop();
  12267. }
  12268. },
  12269. stepDown: spinnerModifer( function( steps ) {
  12270. this._stepDown( steps );
  12271. } ),
  12272. _stepDown: function( steps ) {
  12273. if ( this._start() ) {
  12274. this._spin( ( steps || 1 ) * -this.options.step );
  12275. this._stop();
  12276. }
  12277. },
  12278. pageUp: spinnerModifer( function( pages ) {
  12279. this._stepUp( ( pages || 1 ) * this.options.page );
  12280. } ),
  12281. pageDown: spinnerModifer( function( pages ) {
  12282. this._stepDown( ( pages || 1 ) * this.options.page );
  12283. } ),
  12284. value: function( newVal ) {
  12285. if ( !arguments.length ) {
  12286. return this._parse( this.element.val() );
  12287. }
  12288. spinnerModifer( this._value ).call( this, newVal );
  12289. },
  12290. widget: function() {
  12291. return this.uiSpinner;
  12292. }
  12293. } );
  12294. // DEPRECATED
  12295. // TODO: switch return back to widget declaration at top of file when this is removed
  12296. if ( $.uiBackCompat !== false ) {
  12297. // Backcompat for spinner html extension points
  12298. $.widget( "ui.spinner", $.ui.spinner, {
  12299. _enhance: function() {
  12300. this.uiSpinner = this.element
  12301. .attr( "autocomplete", "off" )
  12302. .wrap( this._uiSpinnerHtml() )
  12303. .parent()
  12304. // Add buttons
  12305. .append( this._buttonHtml() );
  12306. },
  12307. _uiSpinnerHtml: function() {
  12308. return "<span>";
  12309. },
  12310. _buttonHtml: function() {
  12311. return "<a></a><a></a>";
  12312. }
  12313. } );
  12314. }
  12315. var widgetsSpinner = $.ui.spinner;
  12316. /*!
  12317. * jQuery UI Tabs 1.12.0
  12318. * http://jqueryui.com
  12319. *
  12320. * Copyright jQuery Foundation and other contributors
  12321. * Released under the MIT license.
  12322. * http://jquery.org/license
  12323. */
  12324. //>>label: Tabs
  12325. //>>group: Widgets
  12326. //>>description: Transforms a set of container elements into a tab structure.
  12327. //>>docs: http://api.jqueryui.com/tabs/
  12328. //>>demos: http://jqueryui.com/tabs/
  12329. //>>css.structure: ../../themes/base/core.css
  12330. //>>css.structure: ../../themes/base/tabs.css
  12331. //>>css.theme: ../../themes/base/theme.css
  12332. $.widget( "ui.tabs", {
  12333. version: "1.12.0",
  12334. delay: 300,
  12335. options: {
  12336. active: null,
  12337. classes: {
  12338. "ui-tabs": "ui-corner-all",
  12339. "ui-tabs-nav": "ui-corner-all",
  12340. "ui-tabs-panel": "ui-corner-bottom",
  12341. "ui-tabs-tab": "ui-corner-top"
  12342. },
  12343. collapsible: false,
  12344. event: "click",
  12345. heightStyle: "content",
  12346. hide: null,
  12347. show: null,
  12348. // Callbacks
  12349. activate: null,
  12350. beforeActivate: null,
  12351. beforeLoad: null,
  12352. load: null
  12353. },
  12354. _isLocal: ( function() {
  12355. var rhash = /#.*$/;
  12356. return function( anchor ) {
  12357. var anchorUrl, locationUrl;
  12358. anchorUrl = anchor.href.replace( rhash, "" );
  12359. locationUrl = location.href.replace( rhash, "" );
  12360. // Decoding may throw an error if the URL isn't UTF-8 (#9518)
  12361. try {
  12362. anchorUrl = decodeURIComponent( anchorUrl );
  12363. } catch ( error ) {}
  12364. try {
  12365. locationUrl = decodeURIComponent( locationUrl );
  12366. } catch ( error ) {}
  12367. return anchor.hash.length > 1 && anchorUrl === locationUrl;
  12368. };
  12369. } )(),
  12370. _create: function() {
  12371. var that = this,
  12372. options = this.options;
  12373. this.running = false;
  12374. this._addClass( "ui-tabs", "ui-widget ui-widget-content" );
  12375. this._toggleClass( "ui-tabs-collapsible", null, options.collapsible );
  12376. this._processTabs();
  12377. options.active = this._initialActive();
  12378. // Take disabling tabs via class attribute from HTML
  12379. // into account and update option properly.
  12380. if ( $.isArray( options.disabled ) ) {
  12381. options.disabled = $.unique( options.disabled.concat(
  12382. $.map( this.tabs.filter( ".ui-state-disabled" ), function( li ) {
  12383. return that.tabs.index( li );
  12384. } )
  12385. ) ).sort();
  12386. }
  12387. // Check for length avoids error when initializing empty list
  12388. if ( this.options.active !== false && this.anchors.length ) {
  12389. this.active = this._findActive( options.active );
  12390. } else {
  12391. this.active = $();
  12392. }
  12393. this._refresh();
  12394. if ( this.active.length ) {
  12395. this.load( options.active );
  12396. }
  12397. },
  12398. _initialActive: function() {
  12399. var active = this.options.active,
  12400. collapsible = this.options.collapsible,
  12401. locationHash = location.hash.substring( 1 );
  12402. if ( active === null ) {
  12403. // check the fragment identifier in the URL
  12404. if ( locationHash ) {
  12405. this.tabs.each( function( i, tab ) {
  12406. if ( $( tab ).attr( "aria-controls" ) === locationHash ) {
  12407. active = i;
  12408. return false;
  12409. }
  12410. } );
  12411. }
  12412. // Check for a tab marked active via a class
  12413. if ( active === null ) {
  12414. active = this.tabs.index( this.tabs.filter( ".ui-tabs-active" ) );
  12415. }
  12416. // No active tab, set to false
  12417. if ( active === null || active === -1 ) {
  12418. active = this.tabs.length ? 0 : false;
  12419. }
  12420. }
  12421. // Handle numbers: negative, out of range
  12422. if ( active !== false ) {
  12423. active = this.tabs.index( this.tabs.eq( active ) );
  12424. if ( active === -1 ) {
  12425. active = collapsible ? false : 0;
  12426. }
  12427. }
  12428. // Don't allow collapsible: false and active: false
  12429. if ( !collapsible && active === false && this.anchors.length ) {
  12430. active = 0;
  12431. }
  12432. return active;
  12433. },
  12434. _getCreateEventData: function() {
  12435. return {
  12436. tab: this.active,
  12437. panel: !this.active.length ? $() : this._getPanelForTab( this.active )
  12438. };
  12439. },
  12440. _tabKeydown: function( event ) {
  12441. var focusedTab = $( $.ui.safeActiveElement( this.document[ 0 ] ) ).closest( "li" ),
  12442. selectedIndex = this.tabs.index( focusedTab ),
  12443. goingForward = true;
  12444. if ( this._handlePageNav( event ) ) {
  12445. return;
  12446. }
  12447. switch ( event.keyCode ) {
  12448. case $.ui.keyCode.RIGHT:
  12449. case $.ui.keyCode.DOWN:
  12450. selectedIndex++;
  12451. break;
  12452. case $.ui.keyCode.UP:
  12453. case $.ui.keyCode.LEFT:
  12454. goingForward = false;
  12455. selectedIndex--;
  12456. break;
  12457. case $.ui.keyCode.END:
  12458. selectedIndex = this.anchors.length - 1;
  12459. break;
  12460. case $.ui.keyCode.HOME:
  12461. selectedIndex = 0;
  12462. break;
  12463. case $.ui.keyCode.SPACE:
  12464. // Activate only, no collapsing
  12465. event.preventDefault();
  12466. clearTimeout( this.activating );
  12467. this._activate( selectedIndex );
  12468. return;
  12469. case $.ui.keyCode.ENTER:
  12470. // Toggle (cancel delayed activation, allow collapsing)
  12471. event.preventDefault();
  12472. clearTimeout( this.activating );
  12473. // Determine if we should collapse or activate
  12474. this._activate( selectedIndex === this.options.active ? false : selectedIndex );
  12475. return;
  12476. default:
  12477. return;
  12478. }
  12479. // Focus the appropriate tab, based on which key was pressed
  12480. event.preventDefault();
  12481. clearTimeout( this.activating );
  12482. selectedIndex = this._focusNextTab( selectedIndex, goingForward );
  12483. // Navigating with control/command key will prevent automatic activation
  12484. if ( !event.ctrlKey && !event.metaKey ) {
  12485. // Update aria-selected immediately so that AT think the tab is already selected.
  12486. // Otherwise AT may confuse the user by stating that they need to activate the tab,
  12487. // but the tab will already be activated by the time the announcement finishes.
  12488. focusedTab.attr( "aria-selected", "false" );
  12489. this.tabs.eq( selectedIndex ).attr( "aria-selected", "true" );
  12490. this.activating = this._delay( function() {
  12491. this.option( "active", selectedIndex );
  12492. }, this.delay );
  12493. }
  12494. },
  12495. _panelKeydown: function( event ) {
  12496. if ( this._handlePageNav( event ) ) {
  12497. return;
  12498. }
  12499. // Ctrl+up moves focus to the current tab
  12500. if ( event.ctrlKey && event.keyCode === $.ui.keyCode.UP ) {
  12501. event.preventDefault();
  12502. this.active.trigger( "focus" );
  12503. }
  12504. },
  12505. // Alt+page up/down moves focus to the previous/next tab (and activates)
  12506. _handlePageNav: function( event ) {
  12507. if ( event.altKey && event.keyCode === $.ui.keyCode.PAGE_UP ) {
  12508. this._activate( this._focusNextTab( this.options.active - 1, false ) );
  12509. return true;
  12510. }
  12511. if ( event.altKey && event.keyCode === $.ui.keyCode.PAGE_DOWN ) {
  12512. this._activate( this._focusNextTab( this.options.active + 1, true ) );
  12513. return true;
  12514. }
  12515. },
  12516. _findNextTab: function( index, goingForward ) {
  12517. var lastTabIndex = this.tabs.length - 1;
  12518. function constrain() {
  12519. if ( index > lastTabIndex ) {
  12520. index = 0;
  12521. }
  12522. if ( index < 0 ) {
  12523. index = lastTabIndex;
  12524. }
  12525. return index;
  12526. }
  12527. while ( $.inArray( constrain(), this.options.disabled ) !== -1 ) {
  12528. index = goingForward ? index + 1 : index - 1;
  12529. }
  12530. return index;
  12531. },
  12532. _focusNextTab: function( index, goingForward ) {
  12533. index = this._findNextTab( index, goingForward );
  12534. this.tabs.eq( index ).trigger( "focus" );
  12535. return index;
  12536. },
  12537. _setOption: function( key, value ) {
  12538. if ( key === "active" ) {
  12539. // _activate() will handle invalid values and update this.options
  12540. this._activate( value );
  12541. return;
  12542. }
  12543. this._super( key, value );
  12544. if ( key === "collapsible" ) {
  12545. this._toggleClass( "ui-tabs-collapsible", null, value );
  12546. // Setting collapsible: false while collapsed; open first panel
  12547. if ( !value && this.options.active === false ) {
  12548. this._activate( 0 );
  12549. }
  12550. }
  12551. if ( key === "event" ) {
  12552. this._setupEvents( value );
  12553. }
  12554. if ( key === "heightStyle" ) {
  12555. this._setupHeightStyle( value );
  12556. }
  12557. },
  12558. _sanitizeSelector: function( hash ) {
  12559. return hash ? hash.replace( /[!"$%&'()*+,.\/:;<=>?@\[\]\^`{|}~]/g, "\\$&" ) : "";
  12560. },
  12561. refresh: function() {
  12562. var options = this.options,
  12563. lis = this.tablist.children( ":has(a[href])" );
  12564. // Get disabled tabs from class attribute from HTML
  12565. // this will get converted to a boolean if needed in _refresh()
  12566. options.disabled = $.map( lis.filter( ".ui-state-disabled" ), function( tab ) {
  12567. return lis.index( tab );
  12568. } );
  12569. this._processTabs();
  12570. // Was collapsed or no tabs
  12571. if ( options.active === false || !this.anchors.length ) {
  12572. options.active = false;
  12573. this.active = $();
  12574. // was active, but active tab is gone
  12575. } else if ( this.active.length && !$.contains( this.tablist[ 0 ], this.active[ 0 ] ) ) {
  12576. // all remaining tabs are disabled
  12577. if ( this.tabs.length === options.disabled.length ) {
  12578. options.active = false;
  12579. this.active = $();
  12580. // activate previous tab
  12581. } else {
  12582. this._activate( this._findNextTab( Math.max( 0, options.active - 1 ), false ) );
  12583. }
  12584. // was active, active tab still exists
  12585. } else {
  12586. // make sure active index is correct
  12587. options.active = this.tabs.index( this.active );
  12588. }
  12589. this._refresh();
  12590. },
  12591. _refresh: function() {
  12592. this._setOptionDisabled( this.options.disabled );
  12593. this._setupEvents( this.options.event );
  12594. this._setupHeightStyle( this.options.heightStyle );
  12595. this.tabs.not( this.active ).attr( {
  12596. "aria-selected": "false",
  12597. "aria-expanded": "false",
  12598. tabIndex: -1
  12599. } );
  12600. this.panels.not( this._getPanelForTab( this.active ) )
  12601. .hide()
  12602. .attr( {
  12603. "aria-hidden": "true"
  12604. } );
  12605. // Make sure one tab is in the tab order
  12606. if ( !this.active.length ) {
  12607. this.tabs.eq( 0 ).attr( "tabIndex", 0 );
  12608. } else {
  12609. this.active
  12610. .attr( {
  12611. "aria-selected": "true",
  12612. "aria-expanded": "true",
  12613. tabIndex: 0
  12614. } );
  12615. this._addClass( this.active, "ui-tabs-active", "ui-state-active" );
  12616. this._getPanelForTab( this.active )
  12617. .show()
  12618. .attr( {
  12619. "aria-hidden": "false"
  12620. } );
  12621. }
  12622. },
  12623. _processTabs: function() {
  12624. var that = this,
  12625. prevTabs = this.tabs,
  12626. prevAnchors = this.anchors,
  12627. prevPanels = this.panels;
  12628. this.tablist = this._getList().attr( "role", "tablist" );
  12629. this._addClass( this.tablist, "ui-tabs-nav",
  12630. "ui-helper-reset ui-helper-clearfix ui-widget-header" );
  12631. // Prevent users from focusing disabled tabs via click
  12632. this.tablist
  12633. .on( "mousedown" + this.eventNamespace, "> li", function( event ) {
  12634. if ( $( this ).is( ".ui-state-disabled" ) ) {
  12635. event.preventDefault();
  12636. }
  12637. } )
  12638. // Support: IE <9
  12639. // Preventing the default action in mousedown doesn't prevent IE
  12640. // from focusing the element, so if the anchor gets focused, blur.
  12641. // We don't have to worry about focusing the previously focused
  12642. // element since clicking on a non-focusable element should focus
  12643. // the body anyway.
  12644. .on( "focus" + this.eventNamespace, ".ui-tabs-anchor", function() {
  12645. if ( $( this ).closest( "li" ).is( ".ui-state-disabled" ) ) {
  12646. this.blur();
  12647. }
  12648. } );
  12649. this.tabs = this.tablist.find( "> li:has(a[href])" )
  12650. .attr( {
  12651. role: "tab",
  12652. tabIndex: -1
  12653. } );
  12654. this._addClass( this.tabs, "ui-tabs-tab", "ui-state-default" );
  12655. this.anchors = this.tabs.map( function() {
  12656. return $( "a", this )[ 0 ];
  12657. } )
  12658. .attr( {
  12659. role: "presentation",
  12660. tabIndex: -1
  12661. } );
  12662. this._addClass( this.anchors, "ui-tabs-anchor" );
  12663. this.panels = $();
  12664. this.anchors.each( function( i, anchor ) {
  12665. var selector, panel, panelId,
  12666. anchorId = $( anchor ).uniqueId().attr( "id" ),
  12667. tab = $( anchor ).closest( "li" ),
  12668. originalAriaControls = tab.attr( "aria-controls" );
  12669. // Inline tab
  12670. if ( that._isLocal( anchor ) ) {
  12671. selector = anchor.hash;
  12672. panelId = selector.substring( 1 );
  12673. panel = that.element.find( that._sanitizeSelector( selector ) );
  12674. // remote tab
  12675. } else {
  12676. // If the tab doesn't already have aria-controls,
  12677. // generate an id by using a throw-away element
  12678. panelId = tab.attr( "aria-controls" ) || $( {} ).uniqueId()[ 0 ].id;
  12679. selector = "#" + panelId;
  12680. panel = that.element.find( selector );
  12681. if ( !panel.length ) {
  12682. panel = that._createPanel( panelId );
  12683. panel.insertAfter( that.panels[ i - 1 ] || that.tablist );
  12684. }
  12685. panel.attr( "aria-live", "polite" );
  12686. }
  12687. if ( panel.length ) {
  12688. that.panels = that.panels.add( panel );
  12689. }
  12690. if ( originalAriaControls ) {
  12691. tab.data( "ui-tabs-aria-controls", originalAriaControls );
  12692. }
  12693. tab.attr( {
  12694. "aria-controls": panelId,
  12695. "aria-labelledby": anchorId
  12696. } );
  12697. panel.attr( "aria-labelledby", anchorId );
  12698. } );
  12699. this.panels.attr( "role", "tabpanel" );
  12700. this._addClass( this.panels, "ui-tabs-panel", "ui-widget-content" );
  12701. // Avoid memory leaks (#10056)
  12702. if ( prevTabs ) {
  12703. this._off( prevTabs.not( this.tabs ) );
  12704. this._off( prevAnchors.not( this.anchors ) );
  12705. this._off( prevPanels.not( this.panels ) );
  12706. }
  12707. },
  12708. // Allow overriding how to find the list for rare usage scenarios (#7715)
  12709. _getList: function() {
  12710. return this.tablist || this.element.find( "ol, ul" ).eq( 0 );
  12711. },
  12712. _createPanel: function( id ) {
  12713. return $( "<div>" )
  12714. .attr( "id", id )
  12715. .data( "ui-tabs-destroy", true );
  12716. },
  12717. _setOptionDisabled: function( disabled ) {
  12718. var currentItem, li, i;
  12719. if ( $.isArray( disabled ) ) {
  12720. if ( !disabled.length ) {
  12721. disabled = false;
  12722. } else if ( disabled.length === this.anchors.length ) {
  12723. disabled = true;
  12724. }
  12725. }
  12726. // Disable tabs
  12727. for ( i = 0; ( li = this.tabs[ i ] ); i++ ) {
  12728. currentItem = $( li );
  12729. if ( disabled === true || $.inArray( i, disabled ) !== -1 ) {
  12730. currentItem.attr( "aria-disabled", "true" );
  12731. this._addClass( currentItem, null, "ui-state-disabled" );
  12732. } else {
  12733. currentItem.removeAttr( "aria-disabled" );
  12734. this._removeClass( currentItem, null, "ui-state-disabled" );
  12735. }
  12736. }
  12737. this.options.disabled = disabled;
  12738. this._toggleClass( this.widget(), this.widgetFullName + "-disabled", null,
  12739. disabled === true );
  12740. },
  12741. _setupEvents: function( event ) {
  12742. var events = {};
  12743. if ( event ) {
  12744. $.each( event.split( " " ), function( index, eventName ) {
  12745. events[ eventName ] = "_eventHandler";
  12746. } );
  12747. }
  12748. this._off( this.anchors.add( this.tabs ).add( this.panels ) );
  12749. // Always prevent the default action, even when disabled
  12750. this._on( true, this.anchors, {
  12751. click: function( event ) {
  12752. event.preventDefault();
  12753. }
  12754. } );
  12755. this._on( this.anchors, events );
  12756. this._on( this.tabs, { keydown: "_tabKeydown" } );
  12757. this._on( this.panels, { keydown: "_panelKeydown" } );
  12758. this._focusable( this.tabs );
  12759. this._hoverable( this.tabs );
  12760. },
  12761. _setupHeightStyle: function( heightStyle ) {
  12762. var maxHeight,
  12763. parent = this.element.parent();
  12764. if ( heightStyle === "fill" ) {
  12765. maxHeight = parent.height();
  12766. maxHeight -= this.element.outerHeight() - this.element.height();
  12767. this.element.siblings( ":visible" ).each( function() {
  12768. var elem = $( this ),
  12769. position = elem.css( "position" );
  12770. if ( position === "absolute" || position === "fixed" ) {
  12771. return;
  12772. }
  12773. maxHeight -= elem.outerHeight( true );
  12774. } );
  12775. this.element.children().not( this.panels ).each( function() {
  12776. maxHeight -= $( this ).outerHeight( true );
  12777. } );
  12778. this.panels.each( function() {
  12779. $( this ).height( Math.max( 0, maxHeight -
  12780. $( this ).innerHeight() + $( this ).height() ) );
  12781. } )
  12782. .css( "overflow", "auto" );
  12783. } else if ( heightStyle === "auto" ) {
  12784. maxHeight = 0;
  12785. this.panels.each( function() {
  12786. maxHeight = Math.max( maxHeight, $( this ).height( "" ).height() );
  12787. } ).height( maxHeight );
  12788. }
  12789. },
  12790. _eventHandler: function( event ) {
  12791. var options = this.options,
  12792. active = this.active,
  12793. anchor = $( event.currentTarget ),
  12794. tab = anchor.closest( "li" ),
  12795. clickedIsActive = tab[ 0 ] === active[ 0 ],
  12796. collapsing = clickedIsActive && options.collapsible,
  12797. toShow = collapsing ? $() : this._getPanelForTab( tab ),
  12798. toHide = !active.length ? $() : this._getPanelForTab( active ),
  12799. eventData = {
  12800. oldTab: active,
  12801. oldPanel: toHide,
  12802. newTab: collapsing ? $() : tab,
  12803. newPanel: toShow
  12804. };
  12805. event.preventDefault();
  12806. if ( tab.hasClass( "ui-state-disabled" ) ||
  12807. // tab is already loading
  12808. tab.hasClass( "ui-tabs-loading" ) ||
  12809. // can't switch durning an animation
  12810. this.running ||
  12811. // click on active header, but not collapsible
  12812. ( clickedIsActive && !options.collapsible ) ||
  12813. // allow canceling activation
  12814. ( this._trigger( "beforeActivate", event, eventData ) === false ) ) {
  12815. return;
  12816. }
  12817. options.active = collapsing ? false : this.tabs.index( tab );
  12818. this.active = clickedIsActive ? $() : tab;
  12819. if ( this.xhr ) {
  12820. this.xhr.abort();
  12821. }
  12822. if ( !toHide.length && !toShow.length ) {
  12823. $.error( "jQuery UI Tabs: Mismatching fragment identifier." );
  12824. }
  12825. if ( toShow.length ) {
  12826. this.load( this.tabs.index( tab ), event );
  12827. }
  12828. this._toggle( event, eventData );
  12829. },
  12830. // Handles show/hide for selecting tabs
  12831. _toggle: function( event, eventData ) {
  12832. var that = this,
  12833. toShow = eventData.newPanel,
  12834. toHide = eventData.oldPanel;
  12835. this.running = true;
  12836. function complete() {
  12837. that.running = false;
  12838. that._trigger( "activate", event, eventData );
  12839. }
  12840. function show() {
  12841. that._addClass( eventData.newTab.closest( "li" ), "ui-tabs-active", "ui-state-active" );
  12842. if ( toShow.length && that.options.show ) {
  12843. that._show( toShow, that.options.show, complete );
  12844. } else {
  12845. toShow.show();
  12846. complete();
  12847. }
  12848. }
  12849. // Start out by hiding, then showing, then completing
  12850. if ( toHide.length && this.options.hide ) {
  12851. this._hide( toHide, this.options.hide, function() {
  12852. that._removeClass( eventData.oldTab.closest( "li" ),
  12853. "ui-tabs-active", "ui-state-active" );
  12854. show();
  12855. } );
  12856. } else {
  12857. this._removeClass( eventData.oldTab.closest( "li" ),
  12858. "ui-tabs-active", "ui-state-active" );
  12859. toHide.hide();
  12860. show();
  12861. }
  12862. toHide.attr( "aria-hidden", "true" );
  12863. eventData.oldTab.attr( {
  12864. "aria-selected": "false",
  12865. "aria-expanded": "false"
  12866. } );
  12867. // If we're switching tabs, remove the old tab from the tab order.
  12868. // If we're opening from collapsed state, remove the previous tab from the tab order.
  12869. // If we're collapsing, then keep the collapsing tab in the tab order.
  12870. if ( toShow.length && toHide.length ) {
  12871. eventData.oldTab.attr( "tabIndex", -1 );
  12872. } else if ( toShow.length ) {
  12873. this.tabs.filter( function() {
  12874. return $( this ).attr( "tabIndex" ) === 0;
  12875. } )
  12876. .attr( "tabIndex", -1 );
  12877. }
  12878. toShow.attr( "aria-hidden", "false" );
  12879. eventData.newTab.attr( {
  12880. "aria-selected": "true",
  12881. "aria-expanded": "true",
  12882. tabIndex: 0
  12883. } );
  12884. },
  12885. _activate: function( index ) {
  12886. var anchor,
  12887. active = this._findActive( index );
  12888. // Trying to activate the already active panel
  12889. if ( active[ 0 ] === this.active[ 0 ] ) {
  12890. return;
  12891. }
  12892. // Trying to collapse, simulate a click on the current active header
  12893. if ( !active.length ) {
  12894. active = this.active;
  12895. }
  12896. anchor = active.find( ".ui-tabs-anchor" )[ 0 ];
  12897. this._eventHandler( {
  12898. target: anchor,
  12899. currentTarget: anchor,
  12900. preventDefault: $.noop
  12901. } );
  12902. },
  12903. _findActive: function( index ) {
  12904. return index === false ? $() : this.tabs.eq( index );
  12905. },
  12906. _getIndex: function( index ) {
  12907. // meta-function to give users option to provide a href string instead of a numerical index.
  12908. if ( typeof index === "string" ) {
  12909. index = this.anchors.index( this.anchors.filter( "[href$='" +
  12910. $.ui.escapeSelector( index ) + "']" ) );
  12911. }
  12912. return index;
  12913. },
  12914. _destroy: function() {
  12915. if ( this.xhr ) {
  12916. this.xhr.abort();
  12917. }
  12918. this.tablist
  12919. .removeAttr( "role" )
  12920. .off( this.eventNamespace );
  12921. this.anchors
  12922. .removeAttr( "role tabIndex" )
  12923. .removeUniqueId();
  12924. this.tabs.add( this.panels ).each( function() {
  12925. if ( $.data( this, "ui-tabs-destroy" ) ) {
  12926. $( this ).remove();
  12927. } else {
  12928. $( this ).removeAttr( "role tabIndex " +
  12929. "aria-live aria-busy aria-selected aria-labelledby aria-hidden aria-expanded" );
  12930. }
  12931. } );
  12932. this.tabs.each( function() {
  12933. var li = $( this ),
  12934. prev = li.data( "ui-tabs-aria-controls" );
  12935. if ( prev ) {
  12936. li
  12937. .attr( "aria-controls", prev )
  12938. .removeData( "ui-tabs-aria-controls" );
  12939. } else {
  12940. li.removeAttr( "aria-controls" );
  12941. }
  12942. } );
  12943. this.panels.show();
  12944. if ( this.options.heightStyle !== "content" ) {
  12945. this.panels.css( "height", "" );
  12946. }
  12947. },
  12948. enable: function( index ) {
  12949. var disabled = this.options.disabled;
  12950. if ( disabled === false ) {
  12951. return;
  12952. }
  12953. if ( index === undefined ) {
  12954. disabled = false;
  12955. } else {
  12956. index = this._getIndex( index );
  12957. if ( $.isArray( disabled ) ) {
  12958. disabled = $.map( disabled, function( num ) {
  12959. return num !== index ? num : null;
  12960. } );
  12961. } else {
  12962. disabled = $.map( this.tabs, function( li, num ) {
  12963. return num !== index ? num : null;
  12964. } );
  12965. }
  12966. }
  12967. this._setOptionDisabled( disabled );
  12968. },
  12969. disable: function( index ) {
  12970. var disabled = this.options.disabled;
  12971. if ( disabled === true ) {
  12972. return;
  12973. }
  12974. if ( index === undefined ) {
  12975. disabled = true;
  12976. } else {
  12977. index = this._getIndex( index );
  12978. if ( $.inArray( index, disabled ) !== -1 ) {
  12979. return;
  12980. }
  12981. if ( $.isArray( disabled ) ) {
  12982. disabled = $.merge( [ index ], disabled ).sort();
  12983. } else {
  12984. disabled = [ index ];
  12985. }
  12986. }
  12987. this._setOptionDisabled( disabled );
  12988. },
  12989. load: function( index, event ) {
  12990. index = this._getIndex( index );
  12991. var that = this,
  12992. tab = this.tabs.eq( index ),
  12993. anchor = tab.find( ".ui-tabs-anchor" ),
  12994. panel = this._getPanelForTab( tab ),
  12995. eventData = {
  12996. tab: tab,
  12997. panel: panel
  12998. },
  12999. complete = function( jqXHR, status ) {
  13000. if ( status === "abort" ) {
  13001. that.panels.stop( false, true );
  13002. }
  13003. that._removeClass( tab, "ui-tabs-loading" );
  13004. panel.removeAttr( "aria-busy" );
  13005. if ( jqXHR === that.xhr ) {
  13006. delete that.xhr;
  13007. }
  13008. };
  13009. // Not remote
  13010. if ( this._isLocal( anchor[ 0 ] ) ) {
  13011. return;
  13012. }
  13013. this.xhr = $.ajax( this._ajaxSettings( anchor, event, eventData ) );
  13014. // Support: jQuery <1.8
  13015. // jQuery <1.8 returns false if the request is canceled in beforeSend,
  13016. // but as of 1.8, $.ajax() always returns a jqXHR object.
  13017. if ( this.xhr && this.xhr.statusText !== "canceled" ) {
  13018. this._addClass( tab, "ui-tabs-loading" );
  13019. panel.attr( "aria-busy", "true" );
  13020. this.xhr
  13021. .done( function( response, status, jqXHR ) {
  13022. // support: jQuery <1.8
  13023. // http://bugs.jquery.com/ticket/11778
  13024. setTimeout( function() {
  13025. panel.html( response );
  13026. that._trigger( "load", event, eventData );
  13027. complete( jqXHR, status );
  13028. }, 1 );
  13029. } )
  13030. .fail( function( jqXHR, status ) {
  13031. // support: jQuery <1.8
  13032. // http://bugs.jquery.com/ticket/11778
  13033. setTimeout( function() {
  13034. complete( jqXHR, status );
  13035. }, 1 );
  13036. } );
  13037. }
  13038. },
  13039. _ajaxSettings: function( anchor, event, eventData ) {
  13040. var that = this;
  13041. return {
  13042. url: anchor.attr( "href" ),
  13043. beforeSend: function( jqXHR, settings ) {
  13044. return that._trigger( "beforeLoad", event,
  13045. $.extend( { jqXHR: jqXHR, ajaxSettings: settings }, eventData ) );
  13046. }
  13047. };
  13048. },
  13049. _getPanelForTab: function( tab ) {
  13050. var id = $( tab ).attr( "aria-controls" );
  13051. return this.element.find( this._sanitizeSelector( "#" + id ) );
  13052. }
  13053. } );
  13054. // DEPRECATED
  13055. // TODO: Switch return back to widget declaration at top of file when this is removed
  13056. if ( $.uiBackCompat !== false ) {
  13057. // Backcompat for ui-tab class (now ui-tabs-tab)
  13058. $.widget( "ui.tabs", $.ui.tabs, {
  13059. _processTabs: function() {
  13060. this._superApply( arguments );
  13061. this._addClass( this.tabs, "ui-tab" );
  13062. }
  13063. } );
  13064. }
  13065. var widgetsTabs = $.ui.tabs;
  13066. /*!
  13067. * jQuery UI Tooltip 1.12.0
  13068. * http://jqueryui.com
  13069. *
  13070. * Copyright jQuery Foundation and other contributors
  13071. * Released under the MIT license.
  13072. * http://jquery.org/license
  13073. */
  13074. //>>label: Tooltip
  13075. //>>group: Widgets
  13076. //>>description: Shows additional information for any element on hover or focus.
  13077. //>>docs: http://api.jqueryui.com/tooltip/
  13078. //>>demos: http://jqueryui.com/tooltip/
  13079. //>>css.structure: ../../themes/base/core.css
  13080. //>>css.structure: ../../themes/base/tooltip.css
  13081. //>>css.theme: ../../themes/base/theme.css
  13082. $.widget( "ui.tooltip", {
  13083. version: "1.12.0",
  13084. options: {
  13085. classes: {
  13086. "ui-tooltip": "ui-corner-all ui-widget-shadow"
  13087. },
  13088. content: function() {
  13089. // support: IE<9, Opera in jQuery <1.7
  13090. // .text() can't accept undefined, so coerce to a string
  13091. var title = $( this ).attr( "title" ) || "";
  13092. // Escape title, since we're going from an attribute to raw HTML
  13093. return $( "<a>" ).text( title ).html();
  13094. },
  13095. hide: true,
  13096. // Disabled elements have inconsistent behavior across browsers (#8661)
  13097. items: "[title]:not([disabled])",
  13098. position: {
  13099. my: "left top+15",
  13100. at: "left bottom",
  13101. collision: "flipfit flip"
  13102. },
  13103. show: true,
  13104. track: false,
  13105. // Callbacks
  13106. close: null,
  13107. open: null
  13108. },
  13109. _addDescribedBy: function( elem, id ) {
  13110. var describedby = ( elem.attr( "aria-describedby" ) || "" ).split( /\s+/ );
  13111. describedby.push( id );
  13112. elem
  13113. .data( "ui-tooltip-id", id )
  13114. .attr( "aria-describedby", $.trim( describedby.join( " " ) ) );
  13115. },
  13116. _removeDescribedBy: function( elem ) {
  13117. var id = elem.data( "ui-tooltip-id" ),
  13118. describedby = ( elem.attr( "aria-describedby" ) || "" ).split( /\s+/ ),
  13119. index = $.inArray( id, describedby );
  13120. if ( index !== -1 ) {
  13121. describedby.splice( index, 1 );
  13122. }
  13123. elem.removeData( "ui-tooltip-id" );
  13124. describedby = $.trim( describedby.join( " " ) );
  13125. if ( describedby ) {
  13126. elem.attr( "aria-describedby", describedby );
  13127. } else {
  13128. elem.removeAttr( "aria-describedby" );
  13129. }
  13130. },
  13131. _create: function() {
  13132. this._on( {
  13133. mouseover: "open",
  13134. focusin: "open"
  13135. } );
  13136. // IDs of generated tooltips, needed for destroy
  13137. this.tooltips = {};
  13138. // IDs of parent tooltips where we removed the title attribute
  13139. this.parents = {};
  13140. // Append the aria-live region so tooltips announce correctly
  13141. this.liveRegion = $( "<div>" )
  13142. .attr( {
  13143. role: "log",
  13144. "aria-live": "assertive",
  13145. "aria-relevant": "additions"
  13146. } )
  13147. .appendTo( this.document[ 0 ].body );
  13148. this._addClass( this.liveRegion, null, "ui-helper-hidden-accessible" );
  13149. this.disabledTitles = $( [] );
  13150. },
  13151. _setOption: function( key, value ) {
  13152. var that = this;
  13153. this._super( key, value );
  13154. if ( key === "content" ) {
  13155. $.each( this.tooltips, function( id, tooltipData ) {
  13156. that._updateContent( tooltipData.element );
  13157. } );
  13158. }
  13159. },
  13160. _setOptionDisabled: function( value ) {
  13161. this[ value ? "_disable" : "_enable" ]();
  13162. },
  13163. _disable: function() {
  13164. var that = this;
  13165. // Close open tooltips
  13166. $.each( this.tooltips, function( id, tooltipData ) {
  13167. var event = $.Event( "blur" );
  13168. event.target = event.currentTarget = tooltipData.element[ 0 ];
  13169. that.close( event, true );
  13170. } );
  13171. // Remove title attributes to prevent native tooltips
  13172. this.disabledTitles = this.disabledTitles.add(
  13173. this.element.find( this.options.items ).addBack()
  13174. .filter( function() {
  13175. var element = $( this );
  13176. if ( element.is( "[title]" ) ) {
  13177. return element
  13178. .data( "ui-tooltip-title", element.attr( "title" ) )
  13179. .removeAttr( "title" );
  13180. }
  13181. } )
  13182. );
  13183. },
  13184. _enable: function() {
  13185. // restore title attributes
  13186. this.disabledTitles.each( function() {
  13187. var element = $( this );
  13188. if ( element.data( "ui-tooltip-title" ) ) {
  13189. element.attr( "title", element.data( "ui-tooltip-title" ) );
  13190. }
  13191. } );
  13192. this.disabledTitles = $( [] );
  13193. },
  13194. open: function( event ) {
  13195. var that = this,
  13196. target = $( event ? event.target : this.element )
  13197. // we need closest here due to mouseover bubbling,
  13198. // but always pointing at the same event target
  13199. .closest( this.options.items );
  13200. // No element to show a tooltip for or the tooltip is already open
  13201. if ( !target.length || target.data( "ui-tooltip-id" ) ) {
  13202. return;
  13203. }
  13204. if ( target.attr( "title" ) ) {
  13205. target.data( "ui-tooltip-title", target.attr( "title" ) );
  13206. }
  13207. target.data( "ui-tooltip-open", true );
  13208. // Kill parent tooltips, custom or native, for hover
  13209. if ( event && event.type === "mouseover" ) {
  13210. target.parents().each( function() {
  13211. var parent = $( this ),
  13212. blurEvent;
  13213. if ( parent.data( "ui-tooltip-open" ) ) {
  13214. blurEvent = $.Event( "blur" );
  13215. blurEvent.target = blurEvent.currentTarget = this;
  13216. that.close( blurEvent, true );
  13217. }
  13218. if ( parent.attr( "title" ) ) {
  13219. parent.uniqueId();
  13220. that.parents[ this.id ] = {
  13221. element: this,
  13222. title: parent.attr( "title" )
  13223. };
  13224. parent.attr( "title", "" );
  13225. }
  13226. } );
  13227. }
  13228. this._registerCloseHandlers( event, target );
  13229. this._updateContent( target, event );
  13230. },
  13231. _updateContent: function( target, event ) {
  13232. var content,
  13233. contentOption = this.options.content,
  13234. that = this,
  13235. eventType = event ? event.type : null;
  13236. if ( typeof contentOption === "string" || contentOption.nodeType ||
  13237. contentOption.jquery ) {
  13238. return this._open( event, target, contentOption );
  13239. }
  13240. content = contentOption.call( target[ 0 ], function( response ) {
  13241. // IE may instantly serve a cached response for ajax requests
  13242. // delay this call to _open so the other call to _open runs first
  13243. that._delay( function() {
  13244. // Ignore async response if tooltip was closed already
  13245. if ( !target.data( "ui-tooltip-open" ) ) {
  13246. return;
  13247. }
  13248. // JQuery creates a special event for focusin when it doesn't
  13249. // exist natively. To improve performance, the native event
  13250. // object is reused and the type is changed. Therefore, we can't
  13251. // rely on the type being correct after the event finished
  13252. // bubbling, so we set it back to the previous value. (#8740)
  13253. if ( event ) {
  13254. event.type = eventType;
  13255. }
  13256. this._open( event, target, response );
  13257. } );
  13258. } );
  13259. if ( content ) {
  13260. this._open( event, target, content );
  13261. }
  13262. },
  13263. _open: function( event, target, content ) {
  13264. var tooltipData, tooltip, delayedShow, a11yContent,
  13265. positionOption = $.extend( {}, this.options.position );
  13266. if ( !content ) {
  13267. return;
  13268. }
  13269. // Content can be updated multiple times. If the tooltip already
  13270. // exists, then just update the content and bail.
  13271. tooltipData = this._find( target );
  13272. if ( tooltipData ) {
  13273. tooltipData.tooltip.find( ".ui-tooltip-content" ).html( content );
  13274. return;
  13275. }
  13276. // If we have a title, clear it to prevent the native tooltip
  13277. // we have to check first to avoid defining a title if none exists
  13278. // (we don't want to cause an element to start matching [title])
  13279. //
  13280. // We use removeAttr only for key events, to allow IE to export the correct
  13281. // accessible attributes. For mouse events, set to empty string to avoid
  13282. // native tooltip showing up (happens only when removing inside mouseover).
  13283. if ( target.is( "[title]" ) ) {
  13284. if ( event && event.type === "mouseover" ) {
  13285. target.attr( "title", "" );
  13286. } else {
  13287. target.removeAttr( "title" );
  13288. }
  13289. }
  13290. tooltipData = this._tooltip( target );
  13291. tooltip = tooltipData.tooltip;
  13292. this._addDescribedBy( target, tooltip.attr( "id" ) );
  13293. tooltip.find( ".ui-tooltip-content" ).html( content );
  13294. // Support: Voiceover on OS X, JAWS on IE <= 9
  13295. // JAWS announces deletions even when aria-relevant="additions"
  13296. // Voiceover will sometimes re-read the entire log region's contents from the beginning
  13297. this.liveRegion.children().hide();
  13298. a11yContent = $( "<div>" ).html( tooltip.find( ".ui-tooltip-content" ).html() );
  13299. a11yContent.removeAttr( "name" ).find( "[name]" ).removeAttr( "name" );
  13300. a11yContent.removeAttr( "id" ).find( "[id]" ).removeAttr( "id" );
  13301. a11yContent.appendTo( this.liveRegion );
  13302. function position( event ) {
  13303. positionOption.of = event;
  13304. if ( tooltip.is( ":hidden" ) ) {
  13305. return;
  13306. }
  13307. tooltip.position( positionOption );
  13308. }
  13309. if ( this.options.track && event && /^mouse/.test( event.type ) ) {
  13310. this._on( this.document, {
  13311. mousemove: position
  13312. } );
  13313. // trigger once to override element-relative positioning
  13314. position( event );
  13315. } else {
  13316. tooltip.position( $.extend( {
  13317. of: target
  13318. }, this.options.position ) );
  13319. }
  13320. tooltip.hide();
  13321. this._show( tooltip, this.options.show );
  13322. // Handle tracking tooltips that are shown with a delay (#8644). As soon
  13323. // as the tooltip is visible, position the tooltip using the most recent
  13324. // event.
  13325. // Adds the check to add the timers only when both delay and track options are set (#14682)
  13326. if ( this.options.track && this.options.show && this.options.show.delay ) {
  13327. delayedShow = this.delayedShow = setInterval( function() {
  13328. if ( tooltip.is( ":visible" ) ) {
  13329. position( positionOption.of );
  13330. clearInterval( delayedShow );
  13331. }
  13332. }, $.fx.interval );
  13333. }
  13334. this._trigger( "open", event, { tooltip: tooltip } );
  13335. },
  13336. _registerCloseHandlers: function( event, target ) {
  13337. var events = {
  13338. keyup: function( event ) {
  13339. if ( event.keyCode === $.ui.keyCode.ESCAPE ) {
  13340. var fakeEvent = $.Event( event );
  13341. fakeEvent.currentTarget = target[ 0 ];
  13342. this.close( fakeEvent, true );
  13343. }
  13344. }
  13345. };
  13346. // Only bind remove handler for delegated targets. Non-delegated
  13347. // tooltips will handle this in destroy.
  13348. if ( target[ 0 ] !== this.element[ 0 ] ) {
  13349. events.remove = function() {
  13350. this._removeTooltip( this._find( target ).tooltip );
  13351. };
  13352. }
  13353. if ( !event || event.type === "mouseover" ) {
  13354. events.mouseleave = "close";
  13355. }
  13356. if ( !event || event.type === "focusin" ) {
  13357. events.focusout = "close";
  13358. }
  13359. this._on( true, target, events );
  13360. },
  13361. close: function( event ) {
  13362. var tooltip,
  13363. that = this,
  13364. target = $( event ? event.currentTarget : this.element ),
  13365. tooltipData = this._find( target );
  13366. // The tooltip may already be closed
  13367. if ( !tooltipData ) {
  13368. // We set ui-tooltip-open immediately upon open (in open()), but only set the
  13369. // additional data once there's actually content to show (in _open()). So even if the
  13370. // tooltip doesn't have full data, we always remove ui-tooltip-open in case we're in
  13371. // the period between open() and _open().
  13372. target.removeData( "ui-tooltip-open" );
  13373. return;
  13374. }
  13375. tooltip = tooltipData.tooltip;
  13376. // Disabling closes the tooltip, so we need to track when we're closing
  13377. // to avoid an infinite loop in case the tooltip becomes disabled on close
  13378. if ( tooltipData.closing ) {
  13379. return;
  13380. }
  13381. // Clear the interval for delayed tracking tooltips
  13382. clearInterval( this.delayedShow );
  13383. // Only set title if we had one before (see comment in _open())
  13384. // If the title attribute has changed since open(), don't restore
  13385. if ( target.data( "ui-tooltip-title" ) && !target.attr( "title" ) ) {
  13386. target.attr( "title", target.data( "ui-tooltip-title" ) );
  13387. }
  13388. this._removeDescribedBy( target );
  13389. tooltipData.hiding = true;
  13390. tooltip.stop( true );
  13391. this._hide( tooltip, this.options.hide, function() {
  13392. that._removeTooltip( $( this ) );
  13393. } );
  13394. target.removeData( "ui-tooltip-open" );
  13395. this._off( target, "mouseleave focusout keyup" );
  13396. // Remove 'remove' binding only on delegated targets
  13397. if ( target[ 0 ] !== this.element[ 0 ] ) {
  13398. this._off( target, "remove" );
  13399. }
  13400. this._off( this.document, "mousemove" );
  13401. if ( event && event.type === "mouseleave" ) {
  13402. $.each( this.parents, function( id, parent ) {
  13403. $( parent.element ).attr( "title", parent.title );
  13404. delete that.parents[ id ];
  13405. } );
  13406. }
  13407. tooltipData.closing = true;
  13408. this._trigger( "close", event, { tooltip: tooltip } );
  13409. if ( !tooltipData.hiding ) {
  13410. tooltipData.closing = false;
  13411. }
  13412. },
  13413. _tooltip: function( element ) {
  13414. var tooltip = $( "<div>" ).attr( "role", "tooltip" ),
  13415. content = $( "<div>" ).appendTo( tooltip ),
  13416. id = tooltip.uniqueId().attr( "id" );
  13417. this._addClass( content, "ui-tooltip-content" );
  13418. this._addClass( tooltip, "ui-tooltip", "ui-widget ui-widget-content" );
  13419. tooltip.appendTo( this._appendTo( element ) );
  13420. return this.tooltips[ id ] = {
  13421. element: element,
  13422. tooltip: tooltip
  13423. };
  13424. },
  13425. _find: function( target ) {
  13426. var id = target.data( "ui-tooltip-id" );
  13427. return id ? this.tooltips[ id ] : null;
  13428. },
  13429. _removeTooltip: function( tooltip ) {
  13430. tooltip.remove();
  13431. delete this.tooltips[ tooltip.attr( "id" ) ];
  13432. },
  13433. _appendTo: function( target ) {
  13434. var element = target.closest( ".ui-front, dialog" );
  13435. if ( !element.length ) {
  13436. element = this.document[ 0 ].body;
  13437. }
  13438. return element;
  13439. },
  13440. _destroy: function() {
  13441. var that = this;
  13442. // Close open tooltips
  13443. $.each( this.tooltips, function( id, tooltipData ) {
  13444. // Delegate to close method to handle common cleanup
  13445. var event = $.Event( "blur" ),
  13446. element = tooltipData.element;
  13447. event.target = event.currentTarget = element[ 0 ];
  13448. that.close( event, true );
  13449. // Remove immediately; destroying an open tooltip doesn't use the
  13450. // hide animation
  13451. $( "#" + id ).remove();
  13452. // Restore the title
  13453. if ( element.data( "ui-tooltip-title" ) ) {
  13454. // If the title attribute has changed since open(), don't restore
  13455. if ( !element.attr( "title" ) ) {
  13456. element.attr( "title", element.data( "ui-tooltip-title" ) );
  13457. }
  13458. element.removeData( "ui-tooltip-title" );
  13459. }
  13460. } );
  13461. this.liveRegion.remove();
  13462. }
  13463. } );
  13464. // DEPRECATED
  13465. // TODO: Switch return back to widget declaration at top of file when this is removed
  13466. if ( $.uiBackCompat !== false ) {
  13467. // Backcompat for tooltipClass option
  13468. $.widget( "ui.tooltip", $.ui.tooltip, {
  13469. options: {
  13470. tooltipClass: null
  13471. },
  13472. _tooltip: function() {
  13473. var tooltipData = this._superApply( arguments );
  13474. if ( this.options.tooltipClass ) {
  13475. tooltipData.tooltip.addClass( this.options.tooltipClass );
  13476. }
  13477. return tooltipData;
  13478. }
  13479. } );
  13480. }
  13481. var widgetsTooltip = $.ui.tooltip;
  13482. /*!
  13483. * jQuery UI Effects 1.12.0
  13484. * http://jqueryui.com
  13485. *
  13486. * Copyright jQuery Foundation and other contributors
  13487. * Released under the MIT license.
  13488. * http://jquery.org/license
  13489. */
  13490. //>>label: Effects Core
  13491. //>>group: Effects
  13492. // jscs:disable maximumLineLength
  13493. //>>description: Extends the internal jQuery effects. Includes morphing and easing. Required by all other effects.
  13494. // jscs:enable maximumLineLength
  13495. //>>docs: http://api.jqueryui.com/category/effects-core/
  13496. //>>demos: http://jqueryui.com/effect/
  13497. var dataSpace = "ui-effects-",
  13498. dataSpaceStyle = "ui-effects-style",
  13499. dataSpaceAnimated = "ui-effects-animated",
  13500. // Create a local jQuery because jQuery Color relies on it and the
  13501. // global may not exist with AMD and a custom build (#10199)
  13502. jQuery = $;
  13503. $.effects = {
  13504. effect: {}
  13505. };
  13506. /*!
  13507. * jQuery Color Animations v2.1.2
  13508. * https://github.com/jquery/jquery-color
  13509. *
  13510. * Copyright 2014 jQuery Foundation and other contributors
  13511. * Released under the MIT license.
  13512. * http://jquery.org/license
  13513. *
  13514. * Date: Wed Jan 16 08:47:09 2013 -0600
  13515. */
  13516. ( function( jQuery, undefined ) {
  13517. var stepHooks = "backgroundColor borderBottomColor borderLeftColor borderRightColor " +
  13518. "borderTopColor color columnRuleColor outlineColor textDecorationColor textEmphasisColor",
  13519. // Plusequals test for += 100 -= 100
  13520. rplusequals = /^([\-+])=\s*(\d+\.?\d*)/,
  13521. // A set of RE's that can match strings and generate color tuples.
  13522. stringParsers = [ {
  13523. re: /rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(?:,\s*(\d?(?:\.\d+)?)\s*)?\)/,
  13524. parse: function( execResult ) {
  13525. return [
  13526. execResult[ 1 ],
  13527. execResult[ 2 ],
  13528. execResult[ 3 ],
  13529. execResult[ 4 ]
  13530. ];
  13531. }
  13532. }, {
  13533. re: /rgba?\(\s*(\d+(?:\.\d+)?)\%\s*,\s*(\d+(?:\.\d+)?)\%\s*,\s*(\d+(?:\.\d+)?)\%\s*(?:,\s*(\d?(?:\.\d+)?)\s*)?\)/,
  13534. parse: function( execResult ) {
  13535. return [
  13536. execResult[ 1 ] * 2.55,
  13537. execResult[ 2 ] * 2.55,
  13538. execResult[ 3 ] * 2.55,
  13539. execResult[ 4 ]
  13540. ];
  13541. }
  13542. }, {
  13543. // This regex ignores A-F because it's compared against an already lowercased string
  13544. re: /#([a-f0-9]{2})([a-f0-9]{2})([a-f0-9]{2})/,
  13545. parse: function( execResult ) {
  13546. return [
  13547. parseInt( execResult[ 1 ], 16 ),
  13548. parseInt( execResult[ 2 ], 16 ),
  13549. parseInt( execResult[ 3 ], 16 )
  13550. ];
  13551. }
  13552. }, {
  13553. // This regex ignores A-F because it's compared against an already lowercased string
  13554. re: /#([a-f0-9])([a-f0-9])([a-f0-9])/,
  13555. parse: function( execResult ) {
  13556. return [
  13557. parseInt( execResult[ 1 ] + execResult[ 1 ], 16 ),
  13558. parseInt( execResult[ 2 ] + execResult[ 2 ], 16 ),
  13559. parseInt( execResult[ 3 ] + execResult[ 3 ], 16 )
  13560. ];
  13561. }
  13562. }, {
  13563. re: /hsla?\(\s*(\d+(?:\.\d+)?)\s*,\s*(\d+(?:\.\d+)?)\%\s*,\s*(\d+(?:\.\d+)?)\%\s*(?:,\s*(\d?(?:\.\d+)?)\s*)?\)/,
  13564. space: "hsla",
  13565. parse: function( execResult ) {
  13566. return [
  13567. execResult[ 1 ],
  13568. execResult[ 2 ] / 100,
  13569. execResult[ 3 ] / 100,
  13570. execResult[ 4 ]
  13571. ];
  13572. }
  13573. } ],
  13574. // JQuery.Color( )
  13575. color = jQuery.Color = function( color, green, blue, alpha ) {
  13576. return new jQuery.Color.fn.parse( color, green, blue, alpha );
  13577. },
  13578. spaces = {
  13579. rgba: {
  13580. props: {
  13581. red: {
  13582. idx: 0,
  13583. type: "byte"
  13584. },
  13585. green: {
  13586. idx: 1,
  13587. type: "byte"
  13588. },
  13589. blue: {
  13590. idx: 2,
  13591. type: "byte"
  13592. }
  13593. }
  13594. },
  13595. hsla: {
  13596. props: {
  13597. hue: {
  13598. idx: 0,
  13599. type: "degrees"
  13600. },
  13601. saturation: {
  13602. idx: 1,
  13603. type: "percent"
  13604. },
  13605. lightness: {
  13606. idx: 2,
  13607. type: "percent"
  13608. }
  13609. }
  13610. }
  13611. },
  13612. propTypes = {
  13613. "byte": {
  13614. floor: true,
  13615. max: 255
  13616. },
  13617. "percent": {
  13618. max: 1
  13619. },
  13620. "degrees": {
  13621. mod: 360,
  13622. floor: true
  13623. }
  13624. },
  13625. support = color.support = {},
  13626. // Element for support tests
  13627. supportElem = jQuery( "<p>" )[ 0 ],
  13628. // Colors = jQuery.Color.names
  13629. colors,
  13630. // Local aliases of functions called often
  13631. each = jQuery.each;
  13632. // Determine rgba support immediately
  13633. supportElem.style.cssText = "background-color:rgba(1,1,1,.5)";
  13634. support.rgba = supportElem.style.backgroundColor.indexOf( "rgba" ) > -1;
  13635. // Define cache name and alpha properties
  13636. // for rgba and hsla spaces
  13637. each( spaces, function( spaceName, space ) {
  13638. space.cache = "_" + spaceName;
  13639. space.props.alpha = {
  13640. idx: 3,
  13641. type: "percent",
  13642. def: 1
  13643. };
  13644. } );
  13645. function clamp( value, prop, allowEmpty ) {
  13646. var type = propTypes[ prop.type ] || {};
  13647. if ( value == null ) {
  13648. return ( allowEmpty || !prop.def ) ? null : prop.def;
  13649. }
  13650. // ~~ is an short way of doing floor for positive numbers
  13651. value = type.floor ? ~~value : parseFloat( value );
  13652. // IE will pass in empty strings as value for alpha,
  13653. // which will hit this case
  13654. if ( isNaN( value ) ) {
  13655. return prop.def;
  13656. }
  13657. if ( type.mod ) {
  13658. // We add mod before modding to make sure that negatives values
  13659. // get converted properly: -10 -> 350
  13660. return ( value + type.mod ) % type.mod;
  13661. }
  13662. // For now all property types without mod have min and max
  13663. return 0 > value ? 0 : type.max < value ? type.max : value;
  13664. }
  13665. function stringParse( string ) {
  13666. var inst = color(),
  13667. rgba = inst._rgba = [];
  13668. string = string.toLowerCase();
  13669. each( stringParsers, function( i, parser ) {
  13670. var parsed,
  13671. match = parser.re.exec( string ),
  13672. values = match && parser.parse( match ),
  13673. spaceName = parser.space || "rgba";
  13674. if ( values ) {
  13675. parsed = inst[ spaceName ]( values );
  13676. // If this was an rgba parse the assignment might happen twice
  13677. // oh well....
  13678. inst[ spaces[ spaceName ].cache ] = parsed[ spaces[ spaceName ].cache ];
  13679. rgba = inst._rgba = parsed._rgba;
  13680. // Exit each( stringParsers ) here because we matched
  13681. return false;
  13682. }
  13683. } );
  13684. // Found a stringParser that handled it
  13685. if ( rgba.length ) {
  13686. // If this came from a parsed string, force "transparent" when alpha is 0
  13687. // chrome, (and maybe others) return "transparent" as rgba(0,0,0,0)
  13688. if ( rgba.join() === "0,0,0,0" ) {
  13689. jQuery.extend( rgba, colors.transparent );
  13690. }
  13691. return inst;
  13692. }
  13693. // Named colors
  13694. return colors[ string ];
  13695. }
  13696. color.fn = jQuery.extend( color.prototype, {
  13697. parse: function( red, green, blue, alpha ) {
  13698. if ( red === undefined ) {
  13699. this._rgba = [ null, null, null, null ];
  13700. return this;
  13701. }
  13702. if ( red.jquery || red.nodeType ) {
  13703. red = jQuery( red ).css( green );
  13704. green = undefined;
  13705. }
  13706. var inst = this,
  13707. type = jQuery.type( red ),
  13708. rgba = this._rgba = [];
  13709. // More than 1 argument specified - assume ( red, green, blue, alpha )
  13710. if ( green !== undefined ) {
  13711. red = [ red, green, blue, alpha ];
  13712. type = "array";
  13713. }
  13714. if ( type === "string" ) {
  13715. return this.parse( stringParse( red ) || colors._default );
  13716. }
  13717. if ( type === "array" ) {
  13718. each( spaces.rgba.props, function( key, prop ) {
  13719. rgba[ prop.idx ] = clamp( red[ prop.idx ], prop );
  13720. } );
  13721. return this;
  13722. }
  13723. if ( type === "object" ) {
  13724. if ( red instanceof color ) {
  13725. each( spaces, function( spaceName, space ) {
  13726. if ( red[ space.cache ] ) {
  13727. inst[ space.cache ] = red[ space.cache ].slice();
  13728. }
  13729. } );
  13730. } else {
  13731. each( spaces, function( spaceName, space ) {
  13732. var cache = space.cache;
  13733. each( space.props, function( key, prop ) {
  13734. // If the cache doesn't exist, and we know how to convert
  13735. if ( !inst[ cache ] && space.to ) {
  13736. // If the value was null, we don't need to copy it
  13737. // if the key was alpha, we don't need to copy it either
  13738. if ( key === "alpha" || red[ key ] == null ) {
  13739. return;
  13740. }
  13741. inst[ cache ] = space.to( inst._rgba );
  13742. }
  13743. // This is the only case where we allow nulls for ALL properties.
  13744. // call clamp with alwaysAllowEmpty
  13745. inst[ cache ][ prop.idx ] = clamp( red[ key ], prop, true );
  13746. } );
  13747. // Everything defined but alpha?
  13748. if ( inst[ cache ] &&
  13749. jQuery.inArray( null, inst[ cache ].slice( 0, 3 ) ) < 0 ) {
  13750. // Use the default of 1
  13751. inst[ cache ][ 3 ] = 1;
  13752. if ( space.from ) {
  13753. inst._rgba = space.from( inst[ cache ] );
  13754. }
  13755. }
  13756. } );
  13757. }
  13758. return this;
  13759. }
  13760. },
  13761. is: function( compare ) {
  13762. var is = color( compare ),
  13763. same = true,
  13764. inst = this;
  13765. each( spaces, function( _, space ) {
  13766. var localCache,
  13767. isCache = is[ space.cache ];
  13768. if ( isCache ) {
  13769. localCache = inst[ space.cache ] || space.to && space.to( inst._rgba ) || [];
  13770. each( space.props, function( _, prop ) {
  13771. if ( isCache[ prop.idx ] != null ) {
  13772. same = ( isCache[ prop.idx ] === localCache[ prop.idx ] );
  13773. return same;
  13774. }
  13775. } );
  13776. }
  13777. return same;
  13778. } );
  13779. return same;
  13780. },
  13781. _space: function() {
  13782. var used = [],
  13783. inst = this;
  13784. each( spaces, function( spaceName, space ) {
  13785. if ( inst[ space.cache ] ) {
  13786. used.push( spaceName );
  13787. }
  13788. } );
  13789. return used.pop();
  13790. },
  13791. transition: function( other, distance ) {
  13792. var end = color( other ),
  13793. spaceName = end._space(),
  13794. space = spaces[ spaceName ],
  13795. startColor = this.alpha() === 0 ? color( "transparent" ) : this,
  13796. start = startColor[ space.cache ] || space.to( startColor._rgba ),
  13797. result = start.slice();
  13798. end = end[ space.cache ];
  13799. each( space.props, function( key, prop ) {
  13800. var index = prop.idx,
  13801. startValue = start[ index ],
  13802. endValue = end[ index ],
  13803. type = propTypes[ prop.type ] || {};
  13804. // If null, don't override start value
  13805. if ( endValue === null ) {
  13806. return;
  13807. }
  13808. // If null - use end
  13809. if ( startValue === null ) {
  13810. result[ index ] = endValue;
  13811. } else {
  13812. if ( type.mod ) {
  13813. if ( endValue - startValue > type.mod / 2 ) {
  13814. startValue += type.mod;
  13815. } else if ( startValue - endValue > type.mod / 2 ) {
  13816. startValue -= type.mod;
  13817. }
  13818. }
  13819. result[ index ] = clamp( ( endValue - startValue ) * distance + startValue, prop );
  13820. }
  13821. } );
  13822. return this[ spaceName ]( result );
  13823. },
  13824. blend: function( opaque ) {
  13825. // If we are already opaque - return ourself
  13826. if ( this._rgba[ 3 ] === 1 ) {
  13827. return this;
  13828. }
  13829. var rgb = this._rgba.slice(),
  13830. a = rgb.pop(),
  13831. blend = color( opaque )._rgba;
  13832. return color( jQuery.map( rgb, function( v, i ) {
  13833. return ( 1 - a ) * blend[ i ] + a * v;
  13834. } ) );
  13835. },
  13836. toRgbaString: function() {
  13837. var prefix = "rgba(",
  13838. rgba = jQuery.map( this._rgba, function( v, i ) {
  13839. return v == null ? ( i > 2 ? 1 : 0 ) : v;
  13840. } );
  13841. if ( rgba[ 3 ] === 1 ) {
  13842. rgba.pop();
  13843. prefix = "rgb(";
  13844. }
  13845. return prefix + rgba.join() + ")";
  13846. },
  13847. toHslaString: function() {
  13848. var prefix = "hsla(",
  13849. hsla = jQuery.map( this.hsla(), function( v, i ) {
  13850. if ( v == null ) {
  13851. v = i > 2 ? 1 : 0;
  13852. }
  13853. // Catch 1 and 2
  13854. if ( i && i < 3 ) {
  13855. v = Math.round( v * 100 ) + "%";
  13856. }
  13857. return v;
  13858. } );
  13859. if ( hsla[ 3 ] === 1 ) {
  13860. hsla.pop();
  13861. prefix = "hsl(";
  13862. }
  13863. return prefix + hsla.join() + ")";
  13864. },
  13865. toHexString: function( includeAlpha ) {
  13866. var rgba = this._rgba.slice(),
  13867. alpha = rgba.pop();
  13868. if ( includeAlpha ) {
  13869. rgba.push( ~~( alpha * 255 ) );
  13870. }
  13871. return "#" + jQuery.map( rgba, function( v ) {
  13872. // Default to 0 when nulls exist
  13873. v = ( v || 0 ).toString( 16 );
  13874. return v.length === 1 ? "0" + v : v;
  13875. } ).join( "" );
  13876. },
  13877. toString: function() {
  13878. return this._rgba[ 3 ] === 0 ? "transparent" : this.toRgbaString();
  13879. }
  13880. } );
  13881. color.fn.parse.prototype = color.fn;
  13882. // Hsla conversions adapted from:
  13883. // https://code.google.com/p/maashaack/source/browse/packages/graphics/trunk/src/graphics/colors/HUE2RGB.as?r=5021
  13884. function hue2rgb( p, q, h ) {
  13885. h = ( h + 1 ) % 1;
  13886. if ( h * 6 < 1 ) {
  13887. return p + ( q - p ) * h * 6;
  13888. }
  13889. if ( h * 2 < 1 ) {
  13890. return q;
  13891. }
  13892. if ( h * 3 < 2 ) {
  13893. return p + ( q - p ) * ( ( 2 / 3 ) - h ) * 6;
  13894. }
  13895. return p;
  13896. }
  13897. spaces.hsla.to = function( rgba ) {
  13898. if ( rgba[ 0 ] == null || rgba[ 1 ] == null || rgba[ 2 ] == null ) {
  13899. return [ null, null, null, rgba[ 3 ] ];
  13900. }
  13901. var r = rgba[ 0 ] / 255,
  13902. g = rgba[ 1 ] / 255,
  13903. b = rgba[ 2 ] / 255,
  13904. a = rgba[ 3 ],
  13905. max = Math.max( r, g, b ),
  13906. min = Math.min( r, g, b ),
  13907. diff = max - min,
  13908. add = max + min,
  13909. l = add * 0.5,
  13910. h, s;
  13911. if ( min === max ) {
  13912. h = 0;
  13913. } else if ( r === max ) {
  13914. h = ( 60 * ( g - b ) / diff ) + 360;
  13915. } else if ( g === max ) {
  13916. h = ( 60 * ( b - r ) / diff ) + 120;
  13917. } else {
  13918. h = ( 60 * ( r - g ) / diff ) + 240;
  13919. }
  13920. // Chroma (diff) == 0 means greyscale which, by definition, saturation = 0%
  13921. // otherwise, saturation is based on the ratio of chroma (diff) to lightness (add)
  13922. if ( diff === 0 ) {
  13923. s = 0;
  13924. } else if ( l <= 0.5 ) {
  13925. s = diff / add;
  13926. } else {
  13927. s = diff / ( 2 - add );
  13928. }
  13929. return [ Math.round( h ) % 360, s, l, a == null ? 1 : a ];
  13930. };
  13931. spaces.hsla.from = function( hsla ) {
  13932. if ( hsla[ 0 ] == null || hsla[ 1 ] == null || hsla[ 2 ] == null ) {
  13933. return [ null, null, null, hsla[ 3 ] ];
  13934. }
  13935. var h = hsla[ 0 ] / 360,
  13936. s = hsla[ 1 ],
  13937. l = hsla[ 2 ],
  13938. a = hsla[ 3 ],
  13939. q = l <= 0.5 ? l * ( 1 + s ) : l + s - l * s,
  13940. p = 2 * l - q;
  13941. return [
  13942. Math.round( hue2rgb( p, q, h + ( 1 / 3 ) ) * 255 ),
  13943. Math.round( hue2rgb( p, q, h ) * 255 ),
  13944. Math.round( hue2rgb( p, q, h - ( 1 / 3 ) ) * 255 ),
  13945. a
  13946. ];
  13947. };
  13948. each( spaces, function( spaceName, space ) {
  13949. var props = space.props,
  13950. cache = space.cache,
  13951. to = space.to,
  13952. from = space.from;
  13953. // Makes rgba() and hsla()
  13954. color.fn[ spaceName ] = function( value ) {
  13955. // Generate a cache for this space if it doesn't exist
  13956. if ( to && !this[ cache ] ) {
  13957. this[ cache ] = to( this._rgba );
  13958. }
  13959. if ( value === undefined ) {
  13960. return this[ cache ].slice();
  13961. }
  13962. var ret,
  13963. type = jQuery.type( value ),
  13964. arr = ( type === "array" || type === "object" ) ? value : arguments,
  13965. local = this[ cache ].slice();
  13966. each( props, function( key, prop ) {
  13967. var val = arr[ type === "object" ? key : prop.idx ];
  13968. if ( val == null ) {
  13969. val = local[ prop.idx ];
  13970. }
  13971. local[ prop.idx ] = clamp( val, prop );
  13972. } );
  13973. if ( from ) {
  13974. ret = color( from( local ) );
  13975. ret[ cache ] = local;
  13976. return ret;
  13977. } else {
  13978. return color( local );
  13979. }
  13980. };
  13981. // Makes red() green() blue() alpha() hue() saturation() lightness()
  13982. each( props, function( key, prop ) {
  13983. // Alpha is included in more than one space
  13984. if ( color.fn[ key ] ) {
  13985. return;
  13986. }
  13987. color.fn[ key ] = function( value ) {
  13988. var vtype = jQuery.type( value ),
  13989. fn = ( key === "alpha" ? ( this._hsla ? "hsla" : "rgba" ) : spaceName ),
  13990. local = this[ fn ](),
  13991. cur = local[ prop.idx ],
  13992. match;
  13993. if ( vtype === "undefined" ) {
  13994. return cur;
  13995. }
  13996. if ( vtype === "function" ) {
  13997. value = value.call( this, cur );
  13998. vtype = jQuery.type( value );
  13999. }
  14000. if ( value == null && prop.empty ) {
  14001. return this;
  14002. }
  14003. if ( vtype === "string" ) {
  14004. match = rplusequals.exec( value );
  14005. if ( match ) {
  14006. value = cur + parseFloat( match[ 2 ] ) * ( match[ 1 ] === "+" ? 1 : -1 );
  14007. }
  14008. }
  14009. local[ prop.idx ] = value;
  14010. return this[ fn ]( local );
  14011. };
  14012. } );
  14013. } );
  14014. // Add cssHook and .fx.step function for each named hook.
  14015. // accept a space separated string of properties
  14016. color.hook = function( hook ) {
  14017. var hooks = hook.split( " " );
  14018. each( hooks, function( i, hook ) {
  14019. jQuery.cssHooks[ hook ] = {
  14020. set: function( elem, value ) {
  14021. var parsed, curElem,
  14022. backgroundColor = "";
  14023. if ( value !== "transparent" && ( jQuery.type( value ) !== "string" ||
  14024. ( parsed = stringParse( value ) ) ) ) {
  14025. value = color( parsed || value );
  14026. if ( !support.rgba && value._rgba[ 3 ] !== 1 ) {
  14027. curElem = hook === "backgroundColor" ? elem.parentNode : elem;
  14028. while (
  14029. ( backgroundColor === "" || backgroundColor === "transparent" ) &&
  14030. curElem && curElem.style
  14031. ) {
  14032. try {
  14033. backgroundColor = jQuery.css( curElem, "backgroundColor" );
  14034. curElem = curElem.parentNode;
  14035. } catch ( e ) {
  14036. }
  14037. }
  14038. value = value.blend( backgroundColor && backgroundColor !== "transparent" ?
  14039. backgroundColor :
  14040. "_default" );
  14041. }
  14042. value = value.toRgbaString();
  14043. }
  14044. try {
  14045. elem.style[ hook ] = value;
  14046. } catch ( e ) {
  14047. // Wrapped to prevent IE from throwing errors on "invalid" values like
  14048. // 'auto' or 'inherit'
  14049. }
  14050. }
  14051. };
  14052. jQuery.fx.step[ hook ] = function( fx ) {
  14053. if ( !fx.colorInit ) {
  14054. fx.start = color( fx.elem, hook );
  14055. fx.end = color( fx.end );
  14056. fx.colorInit = true;
  14057. }
  14058. jQuery.cssHooks[ hook ].set( fx.elem, fx.start.transition( fx.end, fx.pos ) );
  14059. };
  14060. } );
  14061. };
  14062. color.hook( stepHooks );
  14063. jQuery.cssHooks.borderColor = {
  14064. expand: function( value ) {
  14065. var expanded = {};
  14066. each( [ "Top", "Right", "Bottom", "Left" ], function( i, part ) {
  14067. expanded[ "border" + part + "Color" ] = value;
  14068. } );
  14069. return expanded;
  14070. }
  14071. };
  14072. // Basic color names only.
  14073. // Usage of any of the other color names requires adding yourself or including
  14074. // jquery.color.svg-names.js.
  14075. colors = jQuery.Color.names = {
  14076. // 4.1. Basic color keywords
  14077. aqua: "#00ffff",
  14078. black: "#000000",
  14079. blue: "#0000ff",
  14080. fuchsia: "#ff00ff",
  14081. gray: "#808080",
  14082. green: "#008000",
  14083. lime: "#00ff00",
  14084. maroon: "#800000",
  14085. navy: "#000080",
  14086. olive: "#808000",
  14087. purple: "#800080",
  14088. red: "#ff0000",
  14089. silver: "#c0c0c0",
  14090. teal: "#008080",
  14091. white: "#ffffff",
  14092. yellow: "#ffff00",
  14093. // 4.2.3. "transparent" color keyword
  14094. transparent: [ null, null, null, 0 ],
  14095. _default: "#ffffff"
  14096. };
  14097. } )( jQuery );
  14098. /******************************************************************************/
  14099. /****************************** CLASS ANIMATIONS ******************************/
  14100. /******************************************************************************/
  14101. ( function() {
  14102. var classAnimationActions = [ "add", "remove", "toggle" ],
  14103. shorthandStyles = {
  14104. border: 1,
  14105. borderBottom: 1,
  14106. borderColor: 1,
  14107. borderLeft: 1,
  14108. borderRight: 1,
  14109. borderTop: 1,
  14110. borderWidth: 1,
  14111. margin: 1,
  14112. padding: 1
  14113. };
  14114. $.each(
  14115. [ "borderLeftStyle", "borderRightStyle", "borderBottomStyle", "borderTopStyle" ],
  14116. function( _, prop ) {
  14117. $.fx.step[ prop ] = function( fx ) {
  14118. if ( fx.end !== "none" && !fx.setAttr || fx.pos === 1 && !fx.setAttr ) {
  14119. jQuery.style( fx.elem, prop, fx.end );
  14120. fx.setAttr = true;
  14121. }
  14122. };
  14123. }
  14124. );
  14125. function getElementStyles( elem ) {
  14126. var key, len,
  14127. style = elem.ownerDocument.defaultView ?
  14128. elem.ownerDocument.defaultView.getComputedStyle( elem, null ) :
  14129. elem.currentStyle,
  14130. styles = {};
  14131. if ( style && style.length && style[ 0 ] && style[ style[ 0 ] ] ) {
  14132. len = style.length;
  14133. while ( len-- ) {
  14134. key = style[ len ];
  14135. if ( typeof style[ key ] === "string" ) {
  14136. styles[ $.camelCase( key ) ] = style[ key ];
  14137. }
  14138. }
  14139. // Support: Opera, IE <9
  14140. } else {
  14141. for ( key in style ) {
  14142. if ( typeof style[ key ] === "string" ) {
  14143. styles[ key ] = style[ key ];
  14144. }
  14145. }
  14146. }
  14147. return styles;
  14148. }
  14149. function styleDifference( oldStyle, newStyle ) {
  14150. var diff = {},
  14151. name, value;
  14152. for ( name in newStyle ) {
  14153. value = newStyle[ name ];
  14154. if ( oldStyle[ name ] !== value ) {
  14155. if ( !shorthandStyles[ name ] ) {
  14156. if ( $.fx.step[ name ] || !isNaN( parseFloat( value ) ) ) {
  14157. diff[ name ] = value;
  14158. }
  14159. }
  14160. }
  14161. }
  14162. return diff;
  14163. }
  14164. // Support: jQuery <1.8
  14165. if ( !$.fn.addBack ) {
  14166. $.fn.addBack = function( selector ) {
  14167. return this.add( selector == null ?
  14168. this.prevObject : this.prevObject.filter( selector )
  14169. );
  14170. };
  14171. }
  14172. $.effects.animateClass = function( value, duration, easing, callback ) {
  14173. var o = $.speed( duration, easing, callback );
  14174. return this.queue( function() {
  14175. var animated = $( this ),
  14176. baseClass = animated.attr( "class" ) || "",
  14177. applyClassChange,
  14178. allAnimations = o.children ? animated.find( "*" ).addBack() : animated;
  14179. // Map the animated objects to store the original styles.
  14180. allAnimations = allAnimations.map( function() {
  14181. var el = $( this );
  14182. return {
  14183. el: el,
  14184. start: getElementStyles( this )
  14185. };
  14186. } );
  14187. // Apply class change
  14188. applyClassChange = function() {
  14189. $.each( classAnimationActions, function( i, action ) {
  14190. if ( value[ action ] ) {
  14191. animated[ action + "Class" ]( value[ action ] );
  14192. }
  14193. } );
  14194. };
  14195. applyClassChange();
  14196. // Map all animated objects again - calculate new styles and diff
  14197. allAnimations = allAnimations.map( function() {
  14198. this.end = getElementStyles( this.el[ 0 ] );
  14199. this.diff = styleDifference( this.start, this.end );
  14200. return this;
  14201. } );
  14202. // Apply original class
  14203. animated.attr( "class", baseClass );
  14204. // Map all animated objects again - this time collecting a promise
  14205. allAnimations = allAnimations.map( function() {
  14206. var styleInfo = this,
  14207. dfd = $.Deferred(),
  14208. opts = $.extend( {}, o, {
  14209. queue: false,
  14210. complete: function() {
  14211. dfd.resolve( styleInfo );
  14212. }
  14213. } );
  14214. this.el.animate( this.diff, opts );
  14215. return dfd.promise();
  14216. } );
  14217. // Once all animations have completed:
  14218. $.when.apply( $, allAnimations.get() ).done( function() {
  14219. // Set the final class
  14220. applyClassChange();
  14221. // For each animated element,
  14222. // clear all css properties that were animated
  14223. $.each( arguments, function() {
  14224. var el = this.el;
  14225. $.each( this.diff, function( key ) {
  14226. el.css( key, "" );
  14227. } );
  14228. } );
  14229. // This is guarnteed to be there if you use jQuery.speed()
  14230. // it also handles dequeuing the next anim...
  14231. o.complete.call( animated[ 0 ] );
  14232. } );
  14233. } );
  14234. };
  14235. $.fn.extend( {
  14236. addClass: ( function( orig ) {
  14237. return function( classNames, speed, easing, callback ) {
  14238. return speed ?
  14239. $.effects.animateClass.call( this,
  14240. { add: classNames }, speed, easing, callback ) :
  14241. orig.apply( this, arguments );
  14242. };
  14243. } )( $.fn.addClass ),
  14244. removeClass: ( function( orig ) {
  14245. return function( classNames, speed, easing, callback ) {
  14246. return arguments.length > 1 ?
  14247. $.effects.animateClass.call( this,
  14248. { remove: classNames }, speed, easing, callback ) :
  14249. orig.apply( this, arguments );
  14250. };
  14251. } )( $.fn.removeClass ),
  14252. toggleClass: ( function( orig ) {
  14253. return function( classNames, force, speed, easing, callback ) {
  14254. if ( typeof force === "boolean" || force === undefined ) {
  14255. if ( !speed ) {
  14256. // Without speed parameter
  14257. return orig.apply( this, arguments );
  14258. } else {
  14259. return $.effects.animateClass.call( this,
  14260. ( force ? { add: classNames } : { remove: classNames } ),
  14261. speed, easing, callback );
  14262. }
  14263. } else {
  14264. // Without force parameter
  14265. return $.effects.animateClass.call( this,
  14266. { toggle: classNames }, force, speed, easing );
  14267. }
  14268. };
  14269. } )( $.fn.toggleClass ),
  14270. switchClass: function( remove, add, speed, easing, callback ) {
  14271. return $.effects.animateClass.call( this, {
  14272. add: add,
  14273. remove: remove
  14274. }, speed, easing, callback );
  14275. }
  14276. } );
  14277. } )();
  14278. /******************************************************************************/
  14279. /*********************************** EFFECTS **********************************/
  14280. /******************************************************************************/
  14281. ( function() {
  14282. if ( $.expr && $.expr.filters && $.expr.filters.animated ) {
  14283. $.expr.filters.animated = ( function( orig ) {
  14284. return function( elem ) {
  14285. return !!$( elem ).data( dataSpaceAnimated ) || orig( elem );
  14286. };
  14287. } )( $.expr.filters.animated );
  14288. }
  14289. if ( $.uiBackCompat !== false ) {
  14290. $.extend( $.effects, {
  14291. // Saves a set of properties in a data storage
  14292. save: function( element, set ) {
  14293. var i = 0, length = set.length;
  14294. for ( ; i < length; i++ ) {
  14295. if ( set[ i ] !== null ) {
  14296. element.data( dataSpace + set[ i ], element[ 0 ].style[ set[ i ] ] );
  14297. }
  14298. }
  14299. },
  14300. // Restores a set of previously saved properties from a data storage
  14301. restore: function( element, set ) {
  14302. var val, i = 0, length = set.length;
  14303. for ( ; i < length; i++ ) {
  14304. if ( set[ i ] !== null ) {
  14305. val = element.data( dataSpace + set[ i ] );
  14306. element.css( set[ i ], val );
  14307. }
  14308. }
  14309. },
  14310. setMode: function( el, mode ) {
  14311. if ( mode === "toggle" ) {
  14312. mode = el.is( ":hidden" ) ? "show" : "hide";
  14313. }
  14314. return mode;
  14315. },
  14316. // Wraps the element around a wrapper that copies position properties
  14317. createWrapper: function( element ) {
  14318. // If the element is already wrapped, return it
  14319. if ( element.parent().is( ".ui-effects-wrapper" ) ) {
  14320. return element.parent();
  14321. }
  14322. // Wrap the element
  14323. var props = {
  14324. width: element.outerWidth( true ),
  14325. height: element.outerHeight( true ),
  14326. "float": element.css( "float" )
  14327. },
  14328. wrapper = $( "<div></div>" )
  14329. .addClass( "ui-effects-wrapper" )
  14330. .css( {
  14331. fontSize: "100%",
  14332. background: "transparent",
  14333. border: "none",
  14334. margin: 0,
  14335. padding: 0
  14336. } ),
  14337. // Store the size in case width/height are defined in % - Fixes #5245
  14338. size = {
  14339. width: element.width(),
  14340. height: element.height()
  14341. },
  14342. active = document.activeElement;
  14343. // Support: Firefox
  14344. // Firefox incorrectly exposes anonymous content
  14345. // https://bugzilla.mozilla.org/show_bug.cgi?id=561664
  14346. try {
  14347. active.id;
  14348. } catch ( e ) {
  14349. active = document.body;
  14350. }
  14351. element.wrap( wrapper );
  14352. // Fixes #7595 - Elements lose focus when wrapped.
  14353. if ( element[ 0 ] === active || $.contains( element[ 0 ], active ) ) {
  14354. $( active ).trigger( "focus" );
  14355. }
  14356. // Hotfix for jQuery 1.4 since some change in wrap() seems to actually
  14357. // lose the reference to the wrapped element
  14358. wrapper = element.parent();
  14359. // Transfer positioning properties to the wrapper
  14360. if ( element.css( "position" ) === "static" ) {
  14361. wrapper.css( { position: "relative" } );
  14362. element.css( { position: "relative" } );
  14363. } else {
  14364. $.extend( props, {
  14365. position: element.css( "position" ),
  14366. zIndex: element.css( "z-index" )
  14367. } );
  14368. $.each( [ "top", "left", "bottom", "right" ], function( i, pos ) {
  14369. props[ pos ] = element.css( pos );
  14370. if ( isNaN( parseInt( props[ pos ], 10 ) ) ) {
  14371. props[ pos ] = "auto";
  14372. }
  14373. } );
  14374. element.css( {
  14375. position: "relative",
  14376. top: 0,
  14377. left: 0,
  14378. right: "auto",
  14379. bottom: "auto"
  14380. } );
  14381. }
  14382. element.css( size );
  14383. return wrapper.css( props ).show();
  14384. },
  14385. removeWrapper: function( element ) {
  14386. var active = document.activeElement;
  14387. if ( element.parent().is( ".ui-effects-wrapper" ) ) {
  14388. element.parent().replaceWith( element );
  14389. // Fixes #7595 - Elements lose focus when wrapped.
  14390. if ( element[ 0 ] === active || $.contains( element[ 0 ], active ) ) {
  14391. $( active ).trigger( "focus" );
  14392. }
  14393. }
  14394. return element;
  14395. }
  14396. } );
  14397. }
  14398. $.extend( $.effects, {
  14399. version: "1.12.0",
  14400. define: function( name, mode, effect ) {
  14401. if ( !effect ) {
  14402. effect = mode;
  14403. mode = "effect";
  14404. }
  14405. $.effects.effect[ name ] = effect;
  14406. $.effects.effect[ name ].mode = mode;
  14407. return effect;
  14408. },
  14409. scaledDimensions: function( element, percent, direction ) {
  14410. if ( percent === 0 ) {
  14411. return {
  14412. height: 0,
  14413. width: 0,
  14414. outerHeight: 0,
  14415. outerWidth: 0
  14416. };
  14417. }
  14418. var x = direction !== "horizontal" ? ( ( percent || 100 ) / 100 ) : 1,
  14419. y = direction !== "vertical" ? ( ( percent || 100 ) / 100 ) : 1;
  14420. return {
  14421. height: element.height() * y,
  14422. width: element.width() * x,
  14423. outerHeight: element.outerHeight() * y,
  14424. outerWidth: element.outerWidth() * x
  14425. };
  14426. },
  14427. clipToBox: function( animation ) {
  14428. return {
  14429. width: animation.clip.right - animation.clip.left,
  14430. height: animation.clip.bottom - animation.clip.top,
  14431. left: animation.clip.left,
  14432. top: animation.clip.top
  14433. };
  14434. },
  14435. // Injects recently queued functions to be first in line (after "inprogress")
  14436. unshift: function( element, queueLength, count ) {
  14437. var queue = element.queue();
  14438. if ( queueLength > 1 ) {
  14439. queue.splice.apply( queue,
  14440. [ 1, 0 ].concat( queue.splice( queueLength, count ) ) );
  14441. }
  14442. element.dequeue();
  14443. },
  14444. saveStyle: function( element ) {
  14445. element.data( dataSpaceStyle, element[ 0 ].style.cssText );
  14446. },
  14447. restoreStyle: function( element ) {
  14448. element[ 0 ].style.cssText = element.data( dataSpaceStyle ) || "";
  14449. element.removeData( dataSpaceStyle );
  14450. },
  14451. mode: function( element, mode ) {
  14452. var hidden = element.is( ":hidden" );
  14453. if ( mode === "toggle" ) {
  14454. mode = hidden ? "show" : "hide";
  14455. }
  14456. if ( hidden ? mode === "hide" : mode === "show" ) {
  14457. mode = "none";
  14458. }
  14459. return mode;
  14460. },
  14461. // Translates a [top,left] array into a baseline value
  14462. getBaseline: function( origin, original ) {
  14463. var y, x;
  14464. switch ( origin[ 0 ] ) {
  14465. case "top":
  14466. y = 0;
  14467. break;
  14468. case "middle":
  14469. y = 0.5;
  14470. break;
  14471. case "bottom":
  14472. y = 1;
  14473. break;
  14474. default:
  14475. y = origin[ 0 ] / original.height;
  14476. }
  14477. switch ( origin[ 1 ] ) {
  14478. case "left":
  14479. x = 0;
  14480. break;
  14481. case "center":
  14482. x = 0.5;
  14483. break;
  14484. case "right":
  14485. x = 1;
  14486. break;
  14487. default:
  14488. x = origin[ 1 ] / original.width;
  14489. }
  14490. return {
  14491. x: x,
  14492. y: y
  14493. };
  14494. },
  14495. // Creates a placeholder element so that the original element can be made absolute
  14496. createPlaceholder: function( element ) {
  14497. var placeholder,
  14498. cssPosition = element.css( "position" ),
  14499. position = element.position();
  14500. // Lock in margins first to account for form elements, which
  14501. // will change margin if you explicitly set height
  14502. // see: http://jsfiddle.net/JZSMt/3/ https://bugs.webkit.org/show_bug.cgi?id=107380
  14503. // Support: Safari
  14504. element.css( {
  14505. marginTop: element.css( "marginTop" ),
  14506. marginBottom: element.css( "marginBottom" ),
  14507. marginLeft: element.css( "marginLeft" ),
  14508. marginRight: element.css( "marginRight" )
  14509. } )
  14510. .outerWidth( element.outerWidth() )
  14511. .outerHeight( element.outerHeight() );
  14512. if ( /^(static|relative)/.test( cssPosition ) ) {
  14513. cssPosition = "absolute";
  14514. placeholder = $( "<" + element[ 0 ].nodeName + ">" ).insertAfter( element ).css( {
  14515. // Convert inline to inline block to account for inline elements
  14516. // that turn to inline block based on content (like img)
  14517. display: /^(inline|ruby)/.test( element.css( "display" ) ) ?
  14518. "inline-block" :
  14519. "block",
  14520. visibility: "hidden",
  14521. // Margins need to be set to account for margin collapse
  14522. marginTop: element.css( "marginTop" ),
  14523. marginBottom: element.css( "marginBottom" ),
  14524. marginLeft: element.css( "marginLeft" ),
  14525. marginRight: element.css( "marginRight" ),
  14526. "float": element.css( "float" )
  14527. } )
  14528. .outerWidth( element.outerWidth() )
  14529. .outerHeight( element.outerHeight() )
  14530. .addClass( "ui-effects-placeholder" );
  14531. element.data( dataSpace + "placeholder", placeholder );
  14532. }
  14533. element.css( {
  14534. position: cssPosition,
  14535. left: position.left,
  14536. top: position.top
  14537. } );
  14538. return placeholder;
  14539. },
  14540. removePlaceholder: function( element ) {
  14541. var dataKey = dataSpace + "placeholder",
  14542. placeholder = element.data( dataKey );
  14543. if ( placeholder ) {
  14544. placeholder.remove();
  14545. element.removeData( dataKey );
  14546. }
  14547. },
  14548. // Removes a placeholder if it exists and restores
  14549. // properties that were modified during placeholder creation
  14550. cleanUp: function( element ) {
  14551. $.effects.restoreStyle( element );
  14552. $.effects.removePlaceholder( element );
  14553. },
  14554. setTransition: function( element, list, factor, value ) {
  14555. value = value || {};
  14556. $.each( list, function( i, x ) {
  14557. var unit = element.cssUnit( x );
  14558. if ( unit[ 0 ] > 0 ) {
  14559. value[ x ] = unit[ 0 ] * factor + unit[ 1 ];
  14560. }
  14561. } );
  14562. return value;
  14563. }
  14564. } );
  14565. // Return an effect options object for the given parameters:
  14566. function _normalizeArguments( effect, options, speed, callback ) {
  14567. // Allow passing all options as the first parameter
  14568. if ( $.isPlainObject( effect ) ) {
  14569. options = effect;
  14570. effect = effect.effect;
  14571. }
  14572. // Convert to an object
  14573. effect = { effect: effect };
  14574. // Catch (effect, null, ...)
  14575. if ( options == null ) {
  14576. options = {};
  14577. }
  14578. // Catch (effect, callback)
  14579. if ( $.isFunction( options ) ) {
  14580. callback = options;
  14581. speed = null;
  14582. options = {};
  14583. }
  14584. // Catch (effect, speed, ?)
  14585. if ( typeof options === "number" || $.fx.speeds[ options ] ) {
  14586. callback = speed;
  14587. speed = options;
  14588. options = {};
  14589. }
  14590. // Catch (effect, options, callback)
  14591. if ( $.isFunction( speed ) ) {
  14592. callback = speed;
  14593. speed = null;
  14594. }
  14595. // Add options to effect
  14596. if ( options ) {
  14597. $.extend( effect, options );
  14598. }
  14599. speed = speed || options.duration;
  14600. effect.duration = $.fx.off ? 0 :
  14601. typeof speed === "number" ? speed :
  14602. speed in $.fx.speeds ? $.fx.speeds[ speed ] :
  14603. $.fx.speeds._default;
  14604. effect.complete = callback || options.complete;
  14605. return effect;
  14606. }
  14607. function standardAnimationOption( option ) {
  14608. // Valid standard speeds (nothing, number, named speed)
  14609. if ( !option || typeof option === "number" || $.fx.speeds[ option ] ) {
  14610. return true;
  14611. }
  14612. // Invalid strings - treat as "normal" speed
  14613. if ( typeof option === "string" && !$.effects.effect[ option ] ) {
  14614. return true;
  14615. }
  14616. // Complete callback
  14617. if ( $.isFunction( option ) ) {
  14618. return true;
  14619. }
  14620. // Options hash (but not naming an effect)
  14621. if ( typeof option === "object" && !option.effect ) {
  14622. return true;
  14623. }
  14624. // Didn't match any standard API
  14625. return false;
  14626. }
  14627. $.fn.extend( {
  14628. effect: function( /* effect, options, speed, callback */ ) {
  14629. var args = _normalizeArguments.apply( this, arguments ),
  14630. effectMethod = $.effects.effect[ args.effect ],
  14631. defaultMode = effectMethod.mode,
  14632. queue = args.queue,
  14633. queueName = queue || "fx",
  14634. complete = args.complete,
  14635. mode = args.mode,
  14636. modes = [],
  14637. prefilter = function( next ) {
  14638. var el = $( this ),
  14639. normalizedMode = $.effects.mode( el, mode ) || defaultMode;
  14640. // Sentinel for duck-punching the :animated psuedo-selector
  14641. el.data( dataSpaceAnimated, true );
  14642. // Save effect mode for later use,
  14643. // we can't just call $.effects.mode again later,
  14644. // as the .show() below destroys the initial state
  14645. modes.push( normalizedMode );
  14646. // See $.uiBackCompat inside of run() for removal of defaultMode in 1.13
  14647. if ( defaultMode && ( normalizedMode === "show" ||
  14648. ( normalizedMode === defaultMode && normalizedMode === "hide" ) ) ) {
  14649. el.show();
  14650. }
  14651. if ( !defaultMode || normalizedMode !== "none" ) {
  14652. $.effects.saveStyle( el );
  14653. }
  14654. if ( $.isFunction( next ) ) {
  14655. next();
  14656. }
  14657. };
  14658. if ( $.fx.off || !effectMethod ) {
  14659. // Delegate to the original method (e.g., .show()) if possible
  14660. if ( mode ) {
  14661. return this[ mode ]( args.duration, complete );
  14662. } else {
  14663. return this.each( function() {
  14664. if ( complete ) {
  14665. complete.call( this );
  14666. }
  14667. } );
  14668. }
  14669. }
  14670. function run( next ) {
  14671. var elem = $( this );
  14672. function cleanup() {
  14673. elem.removeData( dataSpaceAnimated );
  14674. $.effects.cleanUp( elem );
  14675. if ( args.mode === "hide" ) {
  14676. elem.hide();
  14677. }
  14678. done();
  14679. }
  14680. function done() {
  14681. if ( $.isFunction( complete ) ) {
  14682. complete.call( elem[ 0 ] );
  14683. }
  14684. if ( $.isFunction( next ) ) {
  14685. next();
  14686. }
  14687. }
  14688. // Override mode option on a per element basis,
  14689. // as toggle can be either show or hide depending on element state
  14690. args.mode = modes.shift();
  14691. if ( $.uiBackCompat !== false && !defaultMode ) {
  14692. if ( elem.is( ":hidden" ) ? mode === "hide" : mode === "show" ) {
  14693. // Call the core method to track "olddisplay" properly
  14694. elem[ mode ]();
  14695. done();
  14696. } else {
  14697. effectMethod.call( elem[ 0 ], args, done );
  14698. }
  14699. } else {
  14700. if ( args.mode === "none" ) {
  14701. // Call the core method to track "olddisplay" properly
  14702. elem[ mode ]();
  14703. done();
  14704. } else {
  14705. effectMethod.call( elem[ 0 ], args, cleanup );
  14706. }
  14707. }
  14708. }
  14709. // Run prefilter on all elements first to ensure that
  14710. // any showing or hiding happens before placeholder creation,
  14711. // which ensures that any layout changes are correctly captured.
  14712. return queue === false ?
  14713. this.each( prefilter ).each( run ) :
  14714. this.queue( queueName, prefilter ).queue( queueName, run );
  14715. },
  14716. show: ( function( orig ) {
  14717. return function( option ) {
  14718. if ( standardAnimationOption( option ) ) {
  14719. return orig.apply( this, arguments );
  14720. } else {
  14721. var args = _normalizeArguments.apply( this, arguments );
  14722. args.mode = "show";
  14723. return this.effect.call( this, args );
  14724. }
  14725. };
  14726. } )( $.fn.show ),
  14727. hide: ( function( orig ) {
  14728. return function( option ) {
  14729. if ( standardAnimationOption( option ) ) {
  14730. return orig.apply( this, arguments );
  14731. } else {
  14732. var args = _normalizeArguments.apply( this, arguments );
  14733. args.mode = "hide";
  14734. return this.effect.call( this, args );
  14735. }
  14736. };
  14737. } )( $.fn.hide ),
  14738. toggle: ( function( orig ) {
  14739. return function( option ) {
  14740. if ( standardAnimationOption( option ) || typeof option === "boolean" ) {
  14741. return orig.apply( this, arguments );
  14742. } else {
  14743. var args = _normalizeArguments.apply( this, arguments );
  14744. args.mode = "toggle";
  14745. return this.effect.call( this, args );
  14746. }
  14747. };
  14748. } )( $.fn.toggle ),
  14749. cssUnit: function( key ) {
  14750. var style = this.css( key ),
  14751. val = [];
  14752. $.each( [ "em", "px", "%", "pt" ], function( i, unit ) {
  14753. if ( style.indexOf( unit ) > 0 ) {
  14754. val = [ parseFloat( style ), unit ];
  14755. }
  14756. } );
  14757. return val;
  14758. },
  14759. cssClip: function( clipObj ) {
  14760. if ( clipObj ) {
  14761. return this.css( "clip", "rect(" + clipObj.top + "px " + clipObj.right + "px " +
  14762. clipObj.bottom + "px " + clipObj.left + "px)" );
  14763. }
  14764. return parseClip( this.css( "clip" ), this );
  14765. },
  14766. transfer: function( options, done ) {
  14767. var element = $( this ),
  14768. target = $( options.to ),
  14769. targetFixed = target.css( "position" ) === "fixed",
  14770. body = $( "body" ),
  14771. fixTop = targetFixed ? body.scrollTop() : 0,
  14772. fixLeft = targetFixed ? body.scrollLeft() : 0,
  14773. endPosition = target.offset(),
  14774. animation = {
  14775. top: endPosition.top - fixTop,
  14776. left: endPosition.left - fixLeft,
  14777. height: target.innerHeight(),
  14778. width: target.innerWidth()
  14779. },
  14780. startPosition = element.offset(),
  14781. transfer = $( "<div class='ui-effects-transfer'></div>" )
  14782. .appendTo( "body" )
  14783. .addClass( options.className )
  14784. .css( {
  14785. top: startPosition.top - fixTop,
  14786. left: startPosition.left - fixLeft,
  14787. height: element.innerHeight(),
  14788. width: element.innerWidth(),
  14789. position: targetFixed ? "fixed" : "absolute"
  14790. } )
  14791. .animate( animation, options.duration, options.easing, function() {
  14792. transfer.remove();
  14793. if ( $.isFunction( done ) ) {
  14794. done();
  14795. }
  14796. } );
  14797. }
  14798. } );
  14799. function parseClip( str, element ) {
  14800. var outerWidth = element.outerWidth(),
  14801. outerHeight = element.outerHeight(),
  14802. 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)\)$/,
  14803. values = clipRegex.exec( str ) || [ "", 0, outerWidth, outerHeight, 0 ];
  14804. return {
  14805. top: parseFloat( values[ 1 ] ) || 0,
  14806. right: values[ 2 ] === "auto" ? outerWidth : parseFloat( values[ 2 ] ),
  14807. bottom: values[ 3 ] === "auto" ? outerHeight : parseFloat( values[ 3 ] ),
  14808. left: parseFloat( values[ 4 ] ) || 0
  14809. };
  14810. }
  14811. $.fx.step.clip = function( fx ) {
  14812. if ( !fx.clipInit ) {
  14813. fx.start = $( fx.elem ).cssClip();
  14814. if ( typeof fx.end === "string" ) {
  14815. fx.end = parseClip( fx.end, fx.elem );
  14816. }
  14817. fx.clipInit = true;
  14818. }
  14819. $( fx.elem ).cssClip( {
  14820. top: fx.pos * ( fx.end.top - fx.start.top ) + fx.start.top,
  14821. right: fx.pos * ( fx.end.right - fx.start.right ) + fx.start.right,
  14822. bottom: fx.pos * ( fx.end.bottom - fx.start.bottom ) + fx.start.bottom,
  14823. left: fx.pos * ( fx.end.left - fx.start.left ) + fx.start.left
  14824. } );
  14825. };
  14826. } )();
  14827. /******************************************************************************/
  14828. /*********************************** EASING ***********************************/
  14829. /******************************************************************************/
  14830. ( function() {
  14831. // Based on easing equations from Robert Penner (http://www.robertpenner.com/easing)
  14832. var baseEasings = {};
  14833. $.each( [ "Quad", "Cubic", "Quart", "Quint", "Expo" ], function( i, name ) {
  14834. baseEasings[ name ] = function( p ) {
  14835. return Math.pow( p, i + 2 );
  14836. };
  14837. } );
  14838. $.extend( baseEasings, {
  14839. Sine: function( p ) {
  14840. return 1 - Math.cos( p * Math.PI / 2 );
  14841. },
  14842. Circ: function( p ) {
  14843. return 1 - Math.sqrt( 1 - p * p );
  14844. },
  14845. Elastic: function( p ) {
  14846. return p === 0 || p === 1 ? p :
  14847. -Math.pow( 2, 8 * ( p - 1 ) ) * Math.sin( ( ( p - 1 ) * 80 - 7.5 ) * Math.PI / 15 );
  14848. },
  14849. Back: function( p ) {
  14850. return p * p * ( 3 * p - 2 );
  14851. },
  14852. Bounce: function( p ) {
  14853. var pow2,
  14854. bounce = 4;
  14855. while ( p < ( ( pow2 = Math.pow( 2, --bounce ) ) - 1 ) / 11 ) {}
  14856. return 1 / Math.pow( 4, 3 - bounce ) - 7.5625 * Math.pow( ( pow2 * 3 - 2 ) / 22 - p, 2 );
  14857. }
  14858. } );
  14859. $.each( baseEasings, function( name, easeIn ) {
  14860. $.easing[ "easeIn" + name ] = easeIn;
  14861. $.easing[ "easeOut" + name ] = function( p ) {
  14862. return 1 - easeIn( 1 - p );
  14863. };
  14864. $.easing[ "easeInOut" + name ] = function( p ) {
  14865. return p < 0.5 ?
  14866. easeIn( p * 2 ) / 2 :
  14867. 1 - easeIn( p * -2 + 2 ) / 2;
  14868. };
  14869. } );
  14870. } )();
  14871. var effect = $.effects;
  14872. /*!
  14873. * jQuery UI Effects Blind 1.12.0
  14874. * http://jqueryui.com
  14875. *
  14876. * Copyright jQuery Foundation and other contributors
  14877. * Released under the MIT license.
  14878. * http://jquery.org/license
  14879. */
  14880. //>>label: Blind Effect
  14881. //>>group: Effects
  14882. //>>description: Blinds the element.
  14883. //>>docs: http://api.jqueryui.com/blind-effect/
  14884. //>>demos: http://jqueryui.com/effect/
  14885. var effectsEffectBlind = $.effects.define( "blind", "hide", function( options, done ) {
  14886. var map = {
  14887. up: [ "bottom", "top" ],
  14888. vertical: [ "bottom", "top" ],
  14889. down: [ "top", "bottom" ],
  14890. left: [ "right", "left" ],
  14891. horizontal: [ "right", "left" ],
  14892. right: [ "left", "right" ]
  14893. },
  14894. element = $( this ),
  14895. direction = options.direction || "up",
  14896. start = element.cssClip(),
  14897. animate = { clip: $.extend( {}, start ) },
  14898. placeholder = $.effects.createPlaceholder( element );
  14899. animate.clip[ map[ direction ][ 0 ] ] = animate.clip[ map[ direction ][ 1 ] ];
  14900. if ( options.mode === "show" ) {
  14901. element.cssClip( animate.clip );
  14902. if ( placeholder ) {
  14903. placeholder.css( $.effects.clipToBox( animate ) );
  14904. }
  14905. animate.clip = start;
  14906. }
  14907. if ( placeholder ) {
  14908. placeholder.animate( $.effects.clipToBox( animate ), options.duration, options.easing );
  14909. }
  14910. element.animate( animate, {
  14911. queue: false,
  14912. duration: options.duration,
  14913. easing: options.easing,
  14914. complete: done
  14915. } );
  14916. } );
  14917. /*!
  14918. * jQuery UI Effects Bounce 1.12.0
  14919. * http://jqueryui.com
  14920. *
  14921. * Copyright jQuery Foundation and other contributors
  14922. * Released under the MIT license.
  14923. * http://jquery.org/license
  14924. */
  14925. //>>label: Bounce Effect
  14926. //>>group: Effects
  14927. //>>description: Bounces an element horizontally or vertically n times.
  14928. //>>docs: http://api.jqueryui.com/bounce-effect/
  14929. //>>demos: http://jqueryui.com/effect/
  14930. var effectsEffectBounce = $.effects.define( "bounce", function( options, done ) {
  14931. var upAnim, downAnim, refValue,
  14932. element = $( this ),
  14933. // Defaults:
  14934. mode = options.mode,
  14935. hide = mode === "hide",
  14936. show = mode === "show",
  14937. direction = options.direction || "up",
  14938. distance = options.distance,
  14939. times = options.times || 5,
  14940. // Number of internal animations
  14941. anims = times * 2 + ( show || hide ? 1 : 0 ),
  14942. speed = options.duration / anims,
  14943. easing = options.easing,
  14944. // Utility:
  14945. ref = ( direction === "up" || direction === "down" ) ? "top" : "left",
  14946. motion = ( direction === "up" || direction === "left" ),
  14947. i = 0,
  14948. queuelen = element.queue().length;
  14949. $.effects.createPlaceholder( element );
  14950. refValue = element.css( ref );
  14951. // Default distance for the BIGGEST bounce is the outer Distance / 3
  14952. if ( !distance ) {
  14953. distance = element[ ref === "top" ? "outerHeight" : "outerWidth" ]() / 3;
  14954. }
  14955. if ( show ) {
  14956. downAnim = { opacity: 1 };
  14957. downAnim[ ref ] = refValue;
  14958. // If we are showing, force opacity 0 and set the initial position
  14959. // then do the "first" animation
  14960. element
  14961. .css( "opacity", 0 )
  14962. .css( ref, motion ? -distance * 2 : distance * 2 )
  14963. .animate( downAnim, speed, easing );
  14964. }
  14965. // Start at the smallest distance if we are hiding
  14966. if ( hide ) {
  14967. distance = distance / Math.pow( 2, times - 1 );
  14968. }
  14969. downAnim = {};
  14970. downAnim[ ref ] = refValue;
  14971. // Bounces up/down/left/right then back to 0 -- times * 2 animations happen here
  14972. for ( ; i < times; i++ ) {
  14973. upAnim = {};
  14974. upAnim[ ref ] = ( motion ? "-=" : "+=" ) + distance;
  14975. element
  14976. .animate( upAnim, speed, easing )
  14977. .animate( downAnim, speed, easing );
  14978. distance = hide ? distance * 2 : distance / 2;
  14979. }
  14980. // Last Bounce when Hiding
  14981. if ( hide ) {
  14982. upAnim = { opacity: 0 };
  14983. upAnim[ ref ] = ( motion ? "-=" : "+=" ) + distance;
  14984. element.animate( upAnim, speed, easing );
  14985. }
  14986. element.queue( done );
  14987. $.effects.unshift( element, queuelen, anims + 1 );
  14988. } );
  14989. /*!
  14990. * jQuery UI Effects Clip 1.12.0
  14991. * http://jqueryui.com
  14992. *
  14993. * Copyright jQuery Foundation and other contributors
  14994. * Released under the MIT license.
  14995. * http://jquery.org/license
  14996. */
  14997. //>>label: Clip Effect
  14998. //>>group: Effects
  14999. //>>description: Clips the element on and off like an old TV.
  15000. //>>docs: http://api.jqueryui.com/clip-effect/
  15001. //>>demos: http://jqueryui.com/effect/
  15002. var effectsEffectClip = $.effects.define( "clip", "hide", function( options, done ) {
  15003. var start,
  15004. animate = {},
  15005. element = $( this ),
  15006. direction = options.direction || "vertical",
  15007. both = direction === "both",
  15008. horizontal = both || direction === "horizontal",
  15009. vertical = both || direction === "vertical";
  15010. start = element.cssClip();
  15011. animate.clip = {
  15012. top: vertical ? ( start.bottom - start.top ) / 2 : start.top,
  15013. right: horizontal ? ( start.right - start.left ) / 2 : start.right,
  15014. bottom: vertical ? ( start.bottom - start.top ) / 2 : start.bottom,
  15015. left: horizontal ? ( start.right - start.left ) / 2 : start.left
  15016. };
  15017. $.effects.createPlaceholder( element );
  15018. if ( options.mode === "show" ) {
  15019. element.cssClip( animate.clip );
  15020. animate.clip = start;
  15021. }
  15022. element.animate( animate, {
  15023. queue: false,
  15024. duration: options.duration,
  15025. easing: options.easing,
  15026. complete: done
  15027. } );
  15028. } );
  15029. /*!
  15030. * jQuery UI Effects Drop 1.12.0
  15031. * http://jqueryui.com
  15032. *
  15033. * Copyright jQuery Foundation and other contributors
  15034. * Released under the MIT license.
  15035. * http://jquery.org/license
  15036. */
  15037. //>>label: Drop Effect
  15038. //>>group: Effects
  15039. //>>description: Moves an element in one direction and hides it at the same time.
  15040. //>>docs: http://api.jqueryui.com/drop-effect/
  15041. //>>demos: http://jqueryui.com/effect/
  15042. var effectsEffectDrop = $.effects.define( "drop", "hide", function( options, done ) {
  15043. var distance,
  15044. element = $( this ),
  15045. mode = options.mode,
  15046. show = mode === "show",
  15047. direction = options.direction || "left",
  15048. ref = ( direction === "up" || direction === "down" ) ? "top" : "left",
  15049. motion = ( direction === "up" || direction === "left" ) ? "-=" : "+=",
  15050. oppositeMotion = ( motion === "+=" ) ? "-=" : "+=",
  15051. animation = {
  15052. opacity: 0
  15053. };
  15054. $.effects.createPlaceholder( element );
  15055. distance = options.distance ||
  15056. element[ ref === "top" ? "outerHeight" : "outerWidth" ]( true ) / 2;
  15057. animation[ ref ] = motion + distance;
  15058. if ( show ) {
  15059. element.css( animation );
  15060. animation[ ref ] = oppositeMotion + distance;
  15061. animation.opacity = 1;
  15062. }
  15063. // Animate
  15064. element.animate( animation, {
  15065. queue: false,
  15066. duration: options.duration,
  15067. easing: options.easing,
  15068. complete: done
  15069. } );
  15070. } );
  15071. /*!
  15072. * jQuery UI Effects Explode 1.12.0
  15073. * http://jqueryui.com
  15074. *
  15075. * Copyright jQuery Foundation and other contributors
  15076. * Released under the MIT license.
  15077. * http://jquery.org/license
  15078. */
  15079. //>>label: Explode Effect
  15080. //>>group: Effects
  15081. // jscs:disable maximumLineLength
  15082. //>>description: Explodes an element in all directions into n pieces. Implodes an element to its original wholeness.
  15083. // jscs:enable maximumLineLength
  15084. //>>docs: http://api.jqueryui.com/explode-effect/
  15085. //>>demos: http://jqueryui.com/effect/
  15086. var effectsEffectExplode = $.effects.define( "explode", "hide", function( options, done ) {
  15087. var i, j, left, top, mx, my,
  15088. rows = options.pieces ? Math.round( Math.sqrt( options.pieces ) ) : 3,
  15089. cells = rows,
  15090. element = $( this ),
  15091. mode = options.mode,
  15092. show = mode === "show",
  15093. // Show and then visibility:hidden the element before calculating offset
  15094. offset = element.show().css( "visibility", "hidden" ).offset(),
  15095. // Width and height of a piece
  15096. width = Math.ceil( element.outerWidth() / cells ),
  15097. height = Math.ceil( element.outerHeight() / rows ),
  15098. pieces = [];
  15099. // Children animate complete:
  15100. function childComplete() {
  15101. pieces.push( this );
  15102. if ( pieces.length === rows * cells ) {
  15103. animComplete();
  15104. }
  15105. }
  15106. // Clone the element for each row and cell.
  15107. for ( i = 0; i < rows; i++ ) { // ===>
  15108. top = offset.top + i * height;
  15109. my = i - ( rows - 1 ) / 2;
  15110. for ( j = 0; j < cells; j++ ) { // |||
  15111. left = offset.left + j * width;
  15112. mx = j - ( cells - 1 ) / 2;
  15113. // Create a clone of the now hidden main element that will be absolute positioned
  15114. // within a wrapper div off the -left and -top equal to size of our pieces
  15115. element
  15116. .clone()
  15117. .appendTo( "body" )
  15118. .wrap( "<div></div>" )
  15119. .css( {
  15120. position: "absolute",
  15121. visibility: "visible",
  15122. left: -j * width,
  15123. top: -i * height
  15124. } )
  15125. // Select the wrapper - make it overflow: hidden and absolute positioned based on
  15126. // where the original was located +left and +top equal to the size of pieces
  15127. .parent()
  15128. .addClass( "ui-effects-explode" )
  15129. .css( {
  15130. position: "absolute",
  15131. overflow: "hidden",
  15132. width: width,
  15133. height: height,
  15134. left: left + ( show ? mx * width : 0 ),
  15135. top: top + ( show ? my * height : 0 ),
  15136. opacity: show ? 0 : 1
  15137. } )
  15138. .animate( {
  15139. left: left + ( show ? 0 : mx * width ),
  15140. top: top + ( show ? 0 : my * height ),
  15141. opacity: show ? 1 : 0
  15142. }, options.duration || 500, options.easing, childComplete );
  15143. }
  15144. }
  15145. function animComplete() {
  15146. element.css( {
  15147. visibility: "visible"
  15148. } );
  15149. $( pieces ).remove();
  15150. done();
  15151. }
  15152. } );
  15153. /*!
  15154. * jQuery UI Effects Fade 1.12.0
  15155. * http://jqueryui.com
  15156. *
  15157. * Copyright jQuery Foundation and other contributors
  15158. * Released under the MIT license.
  15159. * http://jquery.org/license
  15160. */
  15161. //>>label: Fade Effect
  15162. //>>group: Effects
  15163. //>>description: Fades the element.
  15164. //>>docs: http://api.jqueryui.com/fade-effect/
  15165. //>>demos: http://jqueryui.com/effect/
  15166. var effectsEffectFade = $.effects.define( "fade", "toggle", function( options, done ) {
  15167. var show = options.mode === "show";
  15168. $( this )
  15169. .css( "opacity", show ? 0 : 1 )
  15170. .animate( {
  15171. opacity: show ? 1 : 0
  15172. }, {
  15173. queue: false,
  15174. duration: options.duration,
  15175. easing: options.easing,
  15176. complete: done
  15177. } );
  15178. } );
  15179. /*!
  15180. * jQuery UI Effects Fold 1.12.0
  15181. * http://jqueryui.com
  15182. *
  15183. * Copyright jQuery Foundation and other contributors
  15184. * Released under the MIT license.
  15185. * http://jquery.org/license
  15186. */
  15187. //>>label: Fold Effect
  15188. //>>group: Effects
  15189. //>>description: Folds an element first horizontally and then vertically.
  15190. //>>docs: http://api.jqueryui.com/fold-effect/
  15191. //>>demos: http://jqueryui.com/effect/
  15192. var effectsEffectFold = $.effects.define( "fold", "hide", function( options, done ) {
  15193. // Create element
  15194. var element = $( this ),
  15195. mode = options.mode,
  15196. show = mode === "show",
  15197. hide = mode === "hide",
  15198. size = options.size || 15,
  15199. percent = /([0-9]+)%/.exec( size ),
  15200. horizFirst = !!options.horizFirst,
  15201. ref = horizFirst ? [ "right", "bottom" ] : [ "bottom", "right" ],
  15202. duration = options.duration / 2,
  15203. placeholder = $.effects.createPlaceholder( element ),
  15204. start = element.cssClip(),
  15205. animation1 = { clip: $.extend( {}, start ) },
  15206. animation2 = { clip: $.extend( {}, start ) },
  15207. distance = [ start[ ref[ 0 ] ], start[ ref[ 1 ] ] ],
  15208. queuelen = element.queue().length;
  15209. if ( percent ) {
  15210. size = parseInt( percent[ 1 ], 10 ) / 100 * distance[ hide ? 0 : 1 ];
  15211. }
  15212. animation1.clip[ ref[ 0 ] ] = size;
  15213. animation2.clip[ ref[ 0 ] ] = size;
  15214. animation2.clip[ ref[ 1 ] ] = 0;
  15215. if ( show ) {
  15216. element.cssClip( animation2.clip );
  15217. if ( placeholder ) {
  15218. placeholder.css( $.effects.clipToBox( animation2 ) );
  15219. }
  15220. animation2.clip = start;
  15221. }
  15222. // Animate
  15223. element
  15224. .queue( function( next ) {
  15225. if ( placeholder ) {
  15226. placeholder
  15227. .animate( $.effects.clipToBox( animation1 ), duration, options.easing )
  15228. .animate( $.effects.clipToBox( animation2 ), duration, options.easing );
  15229. }
  15230. next();
  15231. } )
  15232. .animate( animation1, duration, options.easing )
  15233. .animate( animation2, duration, options.easing )
  15234. .queue( done );
  15235. $.effects.unshift( element, queuelen, 4 );
  15236. } );
  15237. /*!
  15238. * jQuery UI Effects Highlight 1.12.0
  15239. * http://jqueryui.com
  15240. *
  15241. * Copyright jQuery Foundation and other contributors
  15242. * Released under the MIT license.
  15243. * http://jquery.org/license
  15244. */
  15245. //>>label: Highlight Effect
  15246. //>>group: Effects
  15247. //>>description: Highlights the background of an element in a defined color for a custom duration.
  15248. //>>docs: http://api.jqueryui.com/highlight-effect/
  15249. //>>demos: http://jqueryui.com/effect/
  15250. var effectsEffectHighlight = $.effects.define( "highlight", "show", function( options, done ) {
  15251. var element = $( this ),
  15252. animation = {
  15253. backgroundColor: element.css( "backgroundColor" )
  15254. };
  15255. if ( options.mode === "hide" ) {
  15256. animation.opacity = 0;
  15257. }
  15258. $.effects.saveStyle( element );
  15259. element
  15260. .css( {
  15261. backgroundImage: "none",
  15262. backgroundColor: options.color || "#ffff99"
  15263. } )
  15264. .animate( animation, {
  15265. queue: false,
  15266. duration: options.duration,
  15267. easing: options.easing,
  15268. complete: done
  15269. } );
  15270. } );
  15271. /*!
  15272. * jQuery UI Effects Size 1.12.0
  15273. * http://jqueryui.com
  15274. *
  15275. * Copyright jQuery Foundation and other contributors
  15276. * Released under the MIT license.
  15277. * http://jquery.org/license
  15278. */
  15279. //>>label: Size Effect
  15280. //>>group: Effects
  15281. //>>description: Resize an element to a specified width and height.
  15282. //>>docs: http://api.jqueryui.com/size-effect/
  15283. //>>demos: http://jqueryui.com/effect/
  15284. var effectsEffectSize = $.effects.define( "size", function( options, done ) {
  15285. // Create element
  15286. var baseline, factor, temp,
  15287. element = $( this ),
  15288. // Copy for children
  15289. cProps = [ "fontSize" ],
  15290. vProps = [ "borderTopWidth", "borderBottomWidth", "paddingTop", "paddingBottom" ],
  15291. hProps = [ "borderLeftWidth", "borderRightWidth", "paddingLeft", "paddingRight" ],
  15292. // Set options
  15293. mode = options.mode,
  15294. restore = mode !== "effect",
  15295. scale = options.scale || "both",
  15296. origin = options.origin || [ "middle", "center" ],
  15297. position = element.css( "position" ),
  15298. pos = element.position(),
  15299. original = $.effects.scaledDimensions( element ),
  15300. from = options.from || original,
  15301. to = options.to || $.effects.scaledDimensions( element, 0 );
  15302. $.effects.createPlaceholder( element );
  15303. if ( mode === "show" ) {
  15304. temp = from;
  15305. from = to;
  15306. to = temp;
  15307. }
  15308. // Set scaling factor
  15309. factor = {
  15310. from: {
  15311. y: from.height / original.height,
  15312. x: from.width / original.width
  15313. },
  15314. to: {
  15315. y: to.height / original.height,
  15316. x: to.width / original.width
  15317. }
  15318. };
  15319. // Scale the css box
  15320. if ( scale === "box" || scale === "both" ) {
  15321. // Vertical props scaling
  15322. if ( factor.from.y !== factor.to.y ) {
  15323. from = $.effects.setTransition( element, vProps, factor.from.y, from );
  15324. to = $.effects.setTransition( element, vProps, factor.to.y, to );
  15325. }
  15326. // Horizontal props scaling
  15327. if ( factor.from.x !== factor.to.x ) {
  15328. from = $.effects.setTransition( element, hProps, factor.from.x, from );
  15329. to = $.effects.setTransition( element, hProps, factor.to.x, to );
  15330. }
  15331. }
  15332. // Scale the content
  15333. if ( scale === "content" || scale === "both" ) {
  15334. // Vertical props scaling
  15335. if ( factor.from.y !== factor.to.y ) {
  15336. from = $.effects.setTransition( element, cProps, factor.from.y, from );
  15337. to = $.effects.setTransition( element, cProps, factor.to.y, to );
  15338. }
  15339. }
  15340. // Adjust the position properties based on the provided origin points
  15341. if ( origin ) {
  15342. baseline = $.effects.getBaseline( origin, original );
  15343. from.top = ( original.outerHeight - from.outerHeight ) * baseline.y + pos.top;
  15344. from.left = ( original.outerWidth - from.outerWidth ) * baseline.x + pos.left;
  15345. to.top = ( original.outerHeight - to.outerHeight ) * baseline.y + pos.top;
  15346. to.left = ( original.outerWidth - to.outerWidth ) * baseline.x + pos.left;
  15347. }
  15348. element.css( from );
  15349. // Animate the children if desired
  15350. if ( scale === "content" || scale === "both" ) {
  15351. vProps = vProps.concat( [ "marginTop", "marginBottom" ] ).concat( cProps );
  15352. hProps = hProps.concat( [ "marginLeft", "marginRight" ] );
  15353. // Only animate children with width attributes specified
  15354. // TODO: is this right? should we include anything with css width specified as well
  15355. element.find( "*[width]" ).each( function() {
  15356. var child = $( this ),
  15357. childOriginal = $.effects.scaledDimensions( child ),
  15358. childFrom = {
  15359. height: childOriginal.height * factor.from.y,
  15360. width: childOriginal.width * factor.from.x,
  15361. outerHeight: childOriginal.outerHeight * factor.from.y,
  15362. outerWidth: childOriginal.outerWidth * factor.from.x
  15363. },
  15364. childTo = {
  15365. height: childOriginal.height * factor.to.y,
  15366. width: childOriginal.width * factor.to.x,
  15367. outerHeight: childOriginal.height * factor.to.y,
  15368. outerWidth: childOriginal.width * factor.to.x
  15369. };
  15370. // Vertical props scaling
  15371. if ( factor.from.y !== factor.to.y ) {
  15372. childFrom = $.effects.setTransition( child, vProps, factor.from.y, childFrom );
  15373. childTo = $.effects.setTransition( child, vProps, factor.to.y, childTo );
  15374. }
  15375. // Horizontal props scaling
  15376. if ( factor.from.x !== factor.to.x ) {
  15377. childFrom = $.effects.setTransition( child, hProps, factor.from.x, childFrom );
  15378. childTo = $.effects.setTransition( child, hProps, factor.to.x, childTo );
  15379. }
  15380. if ( restore ) {
  15381. $.effects.saveStyle( child );
  15382. }
  15383. // Animate children
  15384. child.css( childFrom );
  15385. child.animate( childTo, options.duration, options.easing, function() {
  15386. // Restore children
  15387. if ( restore ) {
  15388. $.effects.restoreStyle( child );
  15389. }
  15390. } );
  15391. } );
  15392. }
  15393. // Animate
  15394. element.animate( to, {
  15395. queue: false,
  15396. duration: options.duration,
  15397. easing: options.easing,
  15398. complete: function() {
  15399. var offset = element.offset();
  15400. if ( to.opacity === 0 ) {
  15401. element.css( "opacity", from.opacity );
  15402. }
  15403. if ( !restore ) {
  15404. element
  15405. .css( "position", position === "static" ? "relative" : position )
  15406. .offset( offset );
  15407. // Need to save style here so that automatic style restoration
  15408. // doesn't restore to the original styles from before the animation.
  15409. $.effects.saveStyle( element );
  15410. }
  15411. done();
  15412. }
  15413. } );
  15414. } );
  15415. /*!
  15416. * jQuery UI Effects Scale 1.12.0
  15417. * http://jqueryui.com
  15418. *
  15419. * Copyright jQuery Foundation and other contributors
  15420. * Released under the MIT license.
  15421. * http://jquery.org/license
  15422. */
  15423. //>>label: Scale Effect
  15424. //>>group: Effects
  15425. //>>description: Grows or shrinks an element and its content.
  15426. //>>docs: http://api.jqueryui.com/scale-effect/
  15427. //>>demos: http://jqueryui.com/effect/
  15428. var effectsEffectScale = $.effects.define( "scale", function( options, done ) {
  15429. // Create element
  15430. var el = $( this ),
  15431. mode = options.mode,
  15432. percent = parseInt( options.percent, 10 ) ||
  15433. ( parseInt( options.percent, 10 ) === 0 ? 0 : ( mode !== "effect" ? 0 : 100 ) ),
  15434. newOptions = $.extend( true, {
  15435. from: $.effects.scaledDimensions( el ),
  15436. to: $.effects.scaledDimensions( el, percent, options.direction || "both" ),
  15437. origin: options.origin || [ "middle", "center" ]
  15438. }, options );
  15439. // Fade option to support puff
  15440. if ( options.fade ) {
  15441. newOptions.from.opacity = 1;
  15442. newOptions.to.opacity = 0;
  15443. }
  15444. $.effects.effect.size.call( this, newOptions, done );
  15445. } );
  15446. /*!
  15447. * jQuery UI Effects Puff 1.12.0
  15448. * http://jqueryui.com
  15449. *
  15450. * Copyright jQuery Foundation and other contributors
  15451. * Released under the MIT license.
  15452. * http://jquery.org/license
  15453. */
  15454. //>>label: Puff Effect
  15455. //>>group: Effects
  15456. //>>description: Creates a puff effect by scaling the element up and hiding it at the same time.
  15457. //>>docs: http://api.jqueryui.com/puff-effect/
  15458. //>>demos: http://jqueryui.com/effect/
  15459. var effectsEffectPuff = $.effects.define( "puff", "hide", function( options, done ) {
  15460. var newOptions = $.extend( true, {}, options, {
  15461. fade: true,
  15462. percent: parseInt( options.percent, 10 ) || 150
  15463. } );
  15464. $.effects.effect.scale.call( this, newOptions, done );
  15465. } );
  15466. /*!
  15467. * jQuery UI Effects Pulsate 1.12.0
  15468. * http://jqueryui.com
  15469. *
  15470. * Copyright jQuery Foundation and other contributors
  15471. * Released under the MIT license.
  15472. * http://jquery.org/license
  15473. */
  15474. //>>label: Pulsate Effect
  15475. //>>group: Effects
  15476. //>>description: Pulsates an element n times by changing the opacity to zero and back.
  15477. //>>docs: http://api.jqueryui.com/pulsate-effect/
  15478. //>>demos: http://jqueryui.com/effect/
  15479. var effectsEffectPulsate = $.effects.define( "pulsate", "show", function( options, done ) {
  15480. var element = $( this ),
  15481. mode = options.mode,
  15482. show = mode === "show",
  15483. hide = mode === "hide",
  15484. showhide = show || hide,
  15485. // Showing or hiding leaves off the "last" animation
  15486. anims = ( ( options.times || 5 ) * 2 ) + ( showhide ? 1 : 0 ),
  15487. duration = options.duration / anims,
  15488. animateTo = 0,
  15489. i = 1,
  15490. queuelen = element.queue().length;
  15491. if ( show || !element.is( ":visible" ) ) {
  15492. element.css( "opacity", 0 ).show();
  15493. animateTo = 1;
  15494. }
  15495. // Anims - 1 opacity "toggles"
  15496. for ( ; i < anims; i++ ) {
  15497. element.animate( { opacity: animateTo }, duration, options.easing );
  15498. animateTo = 1 - animateTo;
  15499. }
  15500. element.animate( { opacity: animateTo }, duration, options.easing );
  15501. element.queue( done );
  15502. $.effects.unshift( element, queuelen, anims + 1 );
  15503. } );
  15504. /*!
  15505. * jQuery UI Effects Shake 1.12.0
  15506. * http://jqueryui.com
  15507. *
  15508. * Copyright jQuery Foundation and other contributors
  15509. * Released under the MIT license.
  15510. * http://jquery.org/license
  15511. */
  15512. //>>label: Shake Effect
  15513. //>>group: Effects
  15514. //>>description: Shakes an element horizontally or vertically n times.
  15515. //>>docs: http://api.jqueryui.com/shake-effect/
  15516. //>>demos: http://jqueryui.com/effect/
  15517. var effectsEffectShake = $.effects.define( "shake", function( options, done ) {
  15518. var i = 1,
  15519. element = $( this ),
  15520. direction = options.direction || "left",
  15521. distance = options.distance || 20,
  15522. times = options.times || 3,
  15523. anims = times * 2 + 1,
  15524. speed = Math.round( options.duration / anims ),
  15525. ref = ( direction === "up" || direction === "down" ) ? "top" : "left",
  15526. positiveMotion = ( direction === "up" || direction === "left" ),
  15527. animation = {},
  15528. animation1 = {},
  15529. animation2 = {},
  15530. queuelen = element.queue().length;
  15531. $.effects.createPlaceholder( element );
  15532. // Animation
  15533. animation[ ref ] = ( positiveMotion ? "-=" : "+=" ) + distance;
  15534. animation1[ ref ] = ( positiveMotion ? "+=" : "-=" ) + distance * 2;
  15535. animation2[ ref ] = ( positiveMotion ? "-=" : "+=" ) + distance * 2;
  15536. // Animate
  15537. element.animate( animation, speed, options.easing );
  15538. // Shakes
  15539. for ( ; i < times; i++ ) {
  15540. element
  15541. .animate( animation1, speed, options.easing )
  15542. .animate( animation2, speed, options.easing );
  15543. }
  15544. element
  15545. .animate( animation1, speed, options.easing )
  15546. .animate( animation, speed / 2, options.easing )
  15547. .queue( done );
  15548. $.effects.unshift( element, queuelen, anims + 1 );
  15549. } );
  15550. /*!
  15551. * jQuery UI Effects Slide 1.12.0
  15552. * http://jqueryui.com
  15553. *
  15554. * Copyright jQuery Foundation and other contributors
  15555. * Released under the MIT license.
  15556. * http://jquery.org/license
  15557. */
  15558. //>>label: Slide Effect
  15559. //>>group: Effects
  15560. //>>description: Slides an element in and out of the viewport.
  15561. //>>docs: http://api.jqueryui.com/slide-effect/
  15562. //>>demos: http://jqueryui.com/effect/
  15563. var effectsEffectSlide = $.effects.define( "slide", "show", function( options, done ) {
  15564. var startClip, startRef,
  15565. element = $( this ),
  15566. map = {
  15567. up: [ "bottom", "top" ],
  15568. down: [ "top", "bottom" ],
  15569. left: [ "right", "left" ],
  15570. right: [ "left", "right" ]
  15571. },
  15572. mode = options.mode,
  15573. direction = options.direction || "left",
  15574. ref = ( direction === "up" || direction === "down" ) ? "top" : "left",
  15575. positiveMotion = ( direction === "up" || direction === "left" ),
  15576. distance = options.distance ||
  15577. element[ ref === "top" ? "outerHeight" : "outerWidth" ]( true ),
  15578. animation = {};
  15579. $.effects.createPlaceholder( element );
  15580. startClip = element.cssClip();
  15581. startRef = element.position()[ ref ];
  15582. // Define hide animation
  15583. animation[ ref ] = ( positiveMotion ? -1 : 1 ) * distance + startRef;
  15584. animation.clip = element.cssClip();
  15585. animation.clip[ map[ direction ][ 1 ] ] = animation.clip[ map[ direction ][ 0 ] ];
  15586. // Reverse the animation if we're showing
  15587. if ( mode === "show" ) {
  15588. element.cssClip( animation.clip );
  15589. element.css( ref, animation[ ref ] );
  15590. animation.clip = startClip;
  15591. animation[ ref ] = startRef;
  15592. }
  15593. // Actually animate
  15594. element.animate( animation, {
  15595. queue: false,
  15596. duration: options.duration,
  15597. easing: options.easing,
  15598. complete: done
  15599. } );
  15600. } );
  15601. /*!
  15602. * jQuery UI Effects Transfer 1.12.0
  15603. * http://jqueryui.com
  15604. *
  15605. * Copyright jQuery Foundation and other contributors
  15606. * Released under the MIT license.
  15607. * http://jquery.org/license
  15608. */
  15609. //>>label: Transfer Effect
  15610. //>>group: Effects
  15611. //>>description: Displays a transfer effect from one element to another.
  15612. //>>docs: http://api.jqueryui.com/transfer-effect/
  15613. //>>demos: http://jqueryui.com/effect/
  15614. var effect;
  15615. if ( $.uiBackCompat !== false ) {
  15616. effect = $.effects.define( "transfer", function( options, done ) {
  15617. $( this ).transfer( options, done );
  15618. } );
  15619. }
  15620. var effectsEffectTransfer = effect;
  15621. }));