jquery-ui_new.js 349 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341
  1. /*! jQuery UI - v1.12.1 - 2020-04-06
  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/button.js, widgets/checkboxradio.js, widgets/controlgroup.js, widgets/datepicker.js, widgets/mouse.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.1";
  16. /*!
  17. * jQuery UI Widget 1.12.1
  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. // If this is an empty collection, we need to have the instance method
  184. // return undefined instead of the jQuery instance
  185. if ( !this.length && options === "instance" ) {
  186. returnValue = undefined;
  187. } else {
  188. this.each( function() {
  189. var methodValue;
  190. var instance = $.data( this, fullName );
  191. if ( options === "instance" ) {
  192. returnValue = instance;
  193. return false;
  194. }
  195. if ( !instance ) {
  196. return $.error( "cannot call methods on " + name +
  197. " prior to initialization; " +
  198. "attempted to call method '" + options + "'" );
  199. }
  200. if ( !$.isFunction( instance[ options ] ) || options.charAt( 0 ) === "_" ) {
  201. return $.error( "no such method '" + options + "' for " + name +
  202. " widget instance" );
  203. }
  204. methodValue = instance[ options ].apply( instance, args );
  205. if ( methodValue !== instance && methodValue !== undefined ) {
  206. returnValue = methodValue && methodValue.jquery ?
  207. returnValue.pushStack( methodValue.get() ) :
  208. methodValue;
  209. return false;
  210. }
  211. } );
  212. }
  213. } else {
  214. // Allow multiple hashes to be passed on init
  215. if ( args.length ) {
  216. options = $.widget.extend.apply( null, [ options ].concat( args ) );
  217. }
  218. this.each( function() {
  219. var instance = $.data( this, fullName );
  220. if ( instance ) {
  221. instance.option( options || {} );
  222. if ( instance._init ) {
  223. instance._init();
  224. }
  225. } else {
  226. $.data( this, fullName, new object( options, this ) );
  227. }
  228. } );
  229. }
  230. return returnValue;
  231. };
  232. };
  233. $.Widget = function( /* options, element */ ) {};
  234. $.Widget._childConstructors = [];
  235. $.Widget.prototype = {
  236. widgetName: "widget",
  237. widgetEventPrefix: "",
  238. defaultElement: "<div>",
  239. options: {
  240. classes: {},
  241. disabled: false,
  242. // Callbacks
  243. create: null
  244. },
  245. _createWidget: function( options, element ) {
  246. element = $( element || this.defaultElement || this )[ 0 ];
  247. this.element = $( element );
  248. this.uuid = widgetUuid++;
  249. this.eventNamespace = "." + this.widgetName + this.uuid;
  250. this.bindings = $();
  251. this.hoverable = $();
  252. this.focusable = $();
  253. this.classesElementLookup = {};
  254. if ( element !== this ) {
  255. $.data( element, this.widgetFullName, this );
  256. this._on( true, this.element, {
  257. remove: function( event ) {
  258. if ( event.target === element ) {
  259. this.destroy();
  260. }
  261. }
  262. } );
  263. this.document = $( element.style ?
  264. // Element within the document
  265. element.ownerDocument :
  266. // Element is window or document
  267. element.document || element );
  268. this.window = $( this.document[ 0 ].defaultView || this.document[ 0 ].parentWindow );
  269. }
  270. this.options = $.widget.extend( {},
  271. this.options,
  272. this._getCreateOptions(),
  273. options );
  274. this._create();
  275. if ( this.options.disabled ) {
  276. this._setOptionDisabled( this.options.disabled );
  277. }
  278. this._trigger( "create", null, this._getCreateEventData() );
  279. this._init();
  280. },
  281. _getCreateOptions: function() {
  282. return {};
  283. },
  284. _getCreateEventData: $.noop,
  285. _create: $.noop,
  286. _init: $.noop,
  287. destroy: function() {
  288. var that = this;
  289. this._destroy();
  290. $.each( this.classesElementLookup, function( key, value ) {
  291. that._removeClass( value, key );
  292. } );
  293. // We can probably remove the unbind calls in 2.0
  294. // all event bindings should go through this._on()
  295. this.element
  296. .off( this.eventNamespace )
  297. .removeData( this.widgetFullName );
  298. this.widget()
  299. .off( this.eventNamespace )
  300. .removeAttr( "aria-disabled" );
  301. // Clean up events and states
  302. this.bindings.off( this.eventNamespace );
  303. },
  304. _destroy: $.noop,
  305. widget: function() {
  306. return this.element;
  307. },
  308. option: function( key, value ) {
  309. var options = key;
  310. var parts;
  311. var curOption;
  312. var i;
  313. if ( arguments.length === 0 ) {
  314. // Don't return a reference to the internal hash
  315. return $.widget.extend( {}, this.options );
  316. }
  317. if ( typeof key === "string" ) {
  318. // Handle nested keys, e.g., "foo.bar" => { foo: { bar: ___ } }
  319. options = {};
  320. parts = key.split( "." );
  321. key = parts.shift();
  322. if ( parts.length ) {
  323. curOption = options[ key ] = $.widget.extend( {}, this.options[ key ] );
  324. for ( i = 0; i < parts.length - 1; i++ ) {
  325. curOption[ parts[ i ] ] = curOption[ parts[ i ] ] || {};
  326. curOption = curOption[ parts[ i ] ];
  327. }
  328. key = parts.pop();
  329. if ( arguments.length === 1 ) {
  330. return curOption[ key ] === undefined ? null : curOption[ key ];
  331. }
  332. curOption[ key ] = value;
  333. } else {
  334. if ( arguments.length === 1 ) {
  335. return this.options[ key ] === undefined ? null : this.options[ key ];
  336. }
  337. options[ key ] = value;
  338. }
  339. }
  340. this._setOptions( options );
  341. return this;
  342. },
  343. _setOptions: function( options ) {
  344. var key;
  345. for ( key in options ) {
  346. this._setOption( key, options[ key ] );
  347. }
  348. return this;
  349. },
  350. _setOption: function( key, value ) {
  351. if ( key === "classes" ) {
  352. this._setOptionClasses( value );
  353. }
  354. this.options[ key ] = value;
  355. if ( key === "disabled" ) {
  356. this._setOptionDisabled( value );
  357. }
  358. return this;
  359. },
  360. _setOptionClasses: function( value ) {
  361. var classKey, elements, currentElements;
  362. for ( classKey in value ) {
  363. currentElements = this.classesElementLookup[ classKey ];
  364. if ( value[ classKey ] === this.options.classes[ classKey ] ||
  365. !currentElements ||
  366. !currentElements.length ) {
  367. continue;
  368. }
  369. // We are doing this to create a new jQuery object because the _removeClass() call
  370. // on the next line is going to destroy the reference to the current elements being
  371. // tracked. We need to save a copy of this collection so that we can add the new classes
  372. // below.
  373. elements = $( currentElements.get() );
  374. this._removeClass( currentElements, classKey );
  375. // We don't use _addClass() here, because that uses this.options.classes
  376. // for generating the string of classes. We want to use the value passed in from
  377. // _setOption(), this is the new value of the classes option which was passed to
  378. // _setOption(). We pass this value directly to _classes().
  379. elements.addClass( this._classes( {
  380. element: elements,
  381. keys: classKey,
  382. classes: value,
  383. add: true
  384. } ) );
  385. }
  386. },
  387. _setOptionDisabled: function( value ) {
  388. this._toggleClass( this.widget(), this.widgetFullName + "-disabled", null, !!value );
  389. // If the widget is becoming disabled, then nothing is interactive
  390. if ( value ) {
  391. this._removeClass( this.hoverable, null, "ui-state-hover" );
  392. this._removeClass( this.focusable, null, "ui-state-focus" );
  393. }
  394. },
  395. enable: function() {
  396. return this._setOptions( { disabled: false } );
  397. },
  398. disable: function() {
  399. return this._setOptions( { disabled: true } );
  400. },
  401. _classes: function( options ) {
  402. var full = [];
  403. var that = this;
  404. options = $.extend( {
  405. element: this.element,
  406. classes: this.options.classes || {}
  407. }, options );
  408. function processClassString( classes, checkOption ) {
  409. var current, i;
  410. for ( i = 0; i < classes.length; i++ ) {
  411. current = that.classesElementLookup[ classes[ i ] ] || $();
  412. if ( options.add ) {
  413. current = $( $.unique( current.get().concat( options.element.get() ) ) );
  414. } else {
  415. current = $( current.not( options.element ).get() );
  416. }
  417. that.classesElementLookup[ classes[ i ] ] = current;
  418. full.push( classes[ i ] );
  419. if ( checkOption && options.classes[ classes[ i ] ] ) {
  420. full.push( options.classes[ classes[ i ] ] );
  421. }
  422. }
  423. }
  424. this._on( options.element, {
  425. "remove": "_untrackClassesElement"
  426. } );
  427. if ( options.keys ) {
  428. processClassString( options.keys.match( /\S+/g ) || [], true );
  429. }
  430. if ( options.extra ) {
  431. processClassString( options.extra.match( /\S+/g ) || [] );
  432. }
  433. return full.join( " " );
  434. },
  435. _untrackClassesElement: function( event ) {
  436. var that = this;
  437. $.each( that.classesElementLookup, function( key, value ) {
  438. if ( $.inArray( event.target, value ) !== -1 ) {
  439. that.classesElementLookup[ key ] = $( value.not( event.target ).get() );
  440. }
  441. } );
  442. },
  443. _removeClass: function( element, keys, extra ) {
  444. return this._toggleClass( element, keys, extra, false );
  445. },
  446. _addClass: function( element, keys, extra ) {
  447. return this._toggleClass( element, keys, extra, true );
  448. },
  449. _toggleClass: function( element, keys, extra, add ) {
  450. add = ( typeof add === "boolean" ) ? add : extra;
  451. var shift = ( typeof element === "string" || element === null ),
  452. options = {
  453. extra: shift ? keys : extra,
  454. keys: shift ? element : keys,
  455. element: shift ? this.element : element,
  456. add: add
  457. };
  458. options.element.toggleClass( this._classes( options ), add );
  459. return this;
  460. },
  461. _on: function( suppressDisabledCheck, element, handlers ) {
  462. var delegateElement;
  463. var instance = this;
  464. // No suppressDisabledCheck flag, shuffle arguments
  465. if ( typeof suppressDisabledCheck !== "boolean" ) {
  466. handlers = element;
  467. element = suppressDisabledCheck;
  468. suppressDisabledCheck = false;
  469. }
  470. // No element argument, shuffle and use this.element
  471. if ( !handlers ) {
  472. handlers = element;
  473. element = this.element;
  474. delegateElement = this.widget();
  475. } else {
  476. element = delegateElement = $( element );
  477. this.bindings = this.bindings.add( element );
  478. }
  479. $.each( handlers, function( event, handler ) {
  480. function handlerProxy() {
  481. // Allow widgets to customize the disabled handling
  482. // - disabled as an array instead of boolean
  483. // - disabled class as method for disabling individual parts
  484. if ( !suppressDisabledCheck &&
  485. ( instance.options.disabled === true ||
  486. $( this ).hasClass( "ui-state-disabled" ) ) ) {
  487. return;
  488. }
  489. return ( typeof handler === "string" ? instance[ handler ] : handler )
  490. .apply( instance, arguments );
  491. }
  492. // Copy the guid so direct unbinding works
  493. if ( typeof handler !== "string" ) {
  494. handlerProxy.guid = handler.guid =
  495. handler.guid || handlerProxy.guid || $.guid++;
  496. }
  497. var match = event.match( /^([\w:-]*)\s*(.*)$/ );
  498. var eventName = match[ 1 ] + instance.eventNamespace;
  499. var selector = match[ 2 ];
  500. if ( selector ) {
  501. delegateElement.on( eventName, selector, handlerProxy );
  502. } else {
  503. element.on( eventName, handlerProxy );
  504. }
  505. } );
  506. },
  507. _off: function( element, eventName ) {
  508. eventName = ( eventName || "" ).split( " " ).join( this.eventNamespace + " " ) +
  509. this.eventNamespace;
  510. element.off( eventName ).off( eventName );
  511. // Clear the stack to avoid memory leaks (#10056)
  512. this.bindings = $( this.bindings.not( element ).get() );
  513. this.focusable = $( this.focusable.not( element ).get() );
  514. this.hoverable = $( this.hoverable.not( element ).get() );
  515. },
  516. _delay: function( handler, delay ) {
  517. function handlerProxy() {
  518. return ( typeof handler === "string" ? instance[ handler ] : handler )
  519. .apply( instance, arguments );
  520. }
  521. var instance = this;
  522. return setTimeout( handlerProxy, delay || 0 );
  523. },
  524. _hoverable: function( element ) {
  525. this.hoverable = this.hoverable.add( element );
  526. this._on( element, {
  527. mouseenter: function( event ) {
  528. this._addClass( $( event.currentTarget ), null, "ui-state-hover" );
  529. },
  530. mouseleave: function( event ) {
  531. this._removeClass( $( event.currentTarget ), null, "ui-state-hover" );
  532. }
  533. } );
  534. },
  535. _focusable: function( element ) {
  536. this.focusable = this.focusable.add( element );
  537. this._on( element, {
  538. focusin: function( event ) {
  539. this._addClass( $( event.currentTarget ), null, "ui-state-focus" );
  540. },
  541. focusout: function( event ) {
  542. this._removeClass( $( event.currentTarget ), null, "ui-state-focus" );
  543. }
  544. } );
  545. },
  546. _trigger: function( type, event, data ) {
  547. var prop, orig;
  548. var callback = this.options[ type ];
  549. data = data || {};
  550. event = $.Event( event );
  551. event.type = ( type === this.widgetEventPrefix ?
  552. type :
  553. this.widgetEventPrefix + type ).toLowerCase();
  554. // The original event may come from any element
  555. // so we need to reset the target on the new event
  556. event.target = this.element[ 0 ];
  557. // Copy original event properties over to the new event
  558. orig = event.originalEvent;
  559. if ( orig ) {
  560. for ( prop in orig ) {
  561. if ( !( prop in event ) ) {
  562. event[ prop ] = orig[ prop ];
  563. }
  564. }
  565. }
  566. this.element.trigger( event, data );
  567. return !( $.isFunction( callback ) &&
  568. callback.apply( this.element[ 0 ], [ event ].concat( data ) ) === false ||
  569. event.isDefaultPrevented() );
  570. }
  571. };
  572. $.each( { show: "fadeIn", hide: "fadeOut" }, function( method, defaultEffect ) {
  573. $.Widget.prototype[ "_" + method ] = function( element, options, callback ) {
  574. if ( typeof options === "string" ) {
  575. options = { effect: options };
  576. }
  577. var hasOptions;
  578. var effectName = !options ?
  579. method :
  580. options === true || typeof options === "number" ?
  581. defaultEffect :
  582. options.effect || defaultEffect;
  583. options = options || {};
  584. if ( typeof options === "number" ) {
  585. options = { duration: options };
  586. }
  587. hasOptions = !$.isEmptyObject( options );
  588. options.complete = callback;
  589. if ( options.delay ) {
  590. element.delay( options.delay );
  591. }
  592. if ( hasOptions && $.effects && $.effects.effect[ effectName ] ) {
  593. element[ method ]( options );
  594. } else if ( effectName !== method && element[ effectName ] ) {
  595. element[ effectName ]( options.duration, options.easing, callback );
  596. } else {
  597. element.queue( function( next ) {
  598. $( this )[ method ]();
  599. if ( callback ) {
  600. callback.call( element[ 0 ] );
  601. }
  602. next();
  603. } );
  604. }
  605. };
  606. } );
  607. var widget = $.widget;
  608. /*!
  609. * jQuery UI Position 1.12.1
  610. * http://jqueryui.com
  611. *
  612. * Copyright jQuery Foundation and other contributors
  613. * Released under the MIT license.
  614. * http://jquery.org/license
  615. *
  616. * http://api.jqueryui.com/position/
  617. */
  618. //>>label: Position
  619. //>>group: Core
  620. //>>description: Positions elements relative to other elements.
  621. //>>docs: http://api.jqueryui.com/position/
  622. //>>demos: http://jqueryui.com/position/
  623. ( function() {
  624. var cachedScrollbarWidth,
  625. max = Math.max,
  626. abs = Math.abs,
  627. rhorizontal = /left|center|right/,
  628. rvertical = /top|center|bottom/,
  629. roffset = /[\+\-]\d+(\.[\d]+)?%?/,
  630. rposition = /^\w+/,
  631. rpercent = /%$/,
  632. _position = $.fn.position;
  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. collisionPosition = {
  815. marginLeft: marginLeft,
  816. marginTop: marginTop
  817. };
  818. $.each( [ "left", "top" ], function( i, dir ) {
  819. if ( $.ui.position[ collision[ i ] ] ) {
  820. $.ui.position[ collision[ i ] ][ dir ]( position, {
  821. targetWidth: targetWidth,
  822. targetHeight: targetHeight,
  823. elemWidth: elemWidth,
  824. elemHeight: elemHeight,
  825. collisionPosition: collisionPosition,
  826. collisionWidth: collisionWidth,
  827. collisionHeight: collisionHeight,
  828. offset: [ atOffset[ 0 ] + myOffset[ 0 ], atOffset [ 1 ] + myOffset[ 1 ] ],
  829. my: options.my,
  830. at: options.at,
  831. within: within,
  832. elem: elem
  833. } );
  834. }
  835. } );
  836. if ( options.using ) {
  837. // Adds feedback as second argument to using callback, if present
  838. using = function( props ) {
  839. var left = targetOffset.left - position.left,
  840. right = left + targetWidth - elemWidth,
  841. top = targetOffset.top - position.top,
  842. bottom = top + targetHeight - elemHeight,
  843. feedback = {
  844. target: {
  845. element: target,
  846. left: targetOffset.left,
  847. top: targetOffset.top,
  848. width: targetWidth,
  849. height: targetHeight
  850. },
  851. element: {
  852. element: elem,
  853. left: position.left,
  854. top: position.top,
  855. width: elemWidth,
  856. height: elemHeight
  857. },
  858. horizontal: right < 0 ? "left" : left > 0 ? "right" : "center",
  859. vertical: bottom < 0 ? "top" : top > 0 ? "bottom" : "middle"
  860. };
  861. if ( targetWidth < elemWidth && abs( left + right ) < targetWidth ) {
  862. feedback.horizontal = "center";
  863. }
  864. if ( targetHeight < elemHeight && abs( top + bottom ) < targetHeight ) {
  865. feedback.vertical = "middle";
  866. }
  867. if ( max( abs( left ), abs( right ) ) > max( abs( top ), abs( bottom ) ) ) {
  868. feedback.important = "horizontal";
  869. } else {
  870. feedback.important = "vertical";
  871. }
  872. options.using.call( this, props, feedback );
  873. };
  874. }
  875. elem.offset( $.extend( position, { using: using } ) );
  876. } );
  877. };
  878. $.ui.position = {
  879. fit: {
  880. left: function( position, data ) {
  881. var within = data.within,
  882. withinOffset = within.isWindow ? within.scrollLeft : within.offset.left,
  883. outerWidth = within.width,
  884. collisionPosLeft = position.left - data.collisionPosition.marginLeft,
  885. overLeft = withinOffset - collisionPosLeft,
  886. overRight = collisionPosLeft + data.collisionWidth - outerWidth - withinOffset,
  887. newOverRight;
  888. // Element is wider than within
  889. if ( data.collisionWidth > outerWidth ) {
  890. // Element is initially over the left side of within
  891. if ( overLeft > 0 && overRight <= 0 ) {
  892. newOverRight = position.left + overLeft + data.collisionWidth - outerWidth -
  893. withinOffset;
  894. position.left += overLeft - newOverRight;
  895. // Element is initially over right side of within
  896. } else if ( overRight > 0 && overLeft <= 0 ) {
  897. position.left = withinOffset;
  898. // Element is initially over both left and right sides of within
  899. } else {
  900. if ( overLeft > overRight ) {
  901. position.left = withinOffset + outerWidth - data.collisionWidth;
  902. } else {
  903. position.left = withinOffset;
  904. }
  905. }
  906. // Too far left -> align with left edge
  907. } else if ( overLeft > 0 ) {
  908. position.left += overLeft;
  909. // Too far right -> align with right edge
  910. } else if ( overRight > 0 ) {
  911. position.left -= overRight;
  912. // Adjust based on position and margin
  913. } else {
  914. position.left = max( position.left - collisionPosLeft, position.left );
  915. }
  916. },
  917. top: function( position, data ) {
  918. var within = data.within,
  919. withinOffset = within.isWindow ? within.scrollTop : within.offset.top,
  920. outerHeight = data.within.height,
  921. collisionPosTop = position.top - data.collisionPosition.marginTop,
  922. overTop = withinOffset - collisionPosTop,
  923. overBottom = collisionPosTop + data.collisionHeight - outerHeight - withinOffset,
  924. newOverBottom;
  925. // Element is taller than within
  926. if ( data.collisionHeight > outerHeight ) {
  927. // Element is initially over the top of within
  928. if ( overTop > 0 && overBottom <= 0 ) {
  929. newOverBottom = position.top + overTop + data.collisionHeight - outerHeight -
  930. withinOffset;
  931. position.top += overTop - newOverBottom;
  932. // Element is initially over bottom of within
  933. } else if ( overBottom > 0 && overTop <= 0 ) {
  934. position.top = withinOffset;
  935. // Element is initially over both top and bottom of within
  936. } else {
  937. if ( overTop > overBottom ) {
  938. position.top = withinOffset + outerHeight - data.collisionHeight;
  939. } else {
  940. position.top = withinOffset;
  941. }
  942. }
  943. // Too far up -> align with top
  944. } else if ( overTop > 0 ) {
  945. position.top += overTop;
  946. // Too far down -> align with bottom edge
  947. } else if ( overBottom > 0 ) {
  948. position.top -= overBottom;
  949. // Adjust based on position and margin
  950. } else {
  951. position.top = max( position.top - collisionPosTop, position.top );
  952. }
  953. }
  954. },
  955. flip: {
  956. left: function( position, data ) {
  957. var within = data.within,
  958. withinOffset = within.offset.left + within.scrollLeft,
  959. outerWidth = within.width,
  960. offsetLeft = within.isWindow ? within.scrollLeft : within.offset.left,
  961. collisionPosLeft = position.left - data.collisionPosition.marginLeft,
  962. overLeft = collisionPosLeft - offsetLeft,
  963. overRight = collisionPosLeft + data.collisionWidth - outerWidth - offsetLeft,
  964. myOffset = data.my[ 0 ] === "left" ?
  965. -data.elemWidth :
  966. data.my[ 0 ] === "right" ?
  967. data.elemWidth :
  968. 0,
  969. atOffset = data.at[ 0 ] === "left" ?
  970. data.targetWidth :
  971. data.at[ 0 ] === "right" ?
  972. -data.targetWidth :
  973. 0,
  974. offset = -2 * data.offset[ 0 ],
  975. newOverRight,
  976. newOverLeft;
  977. if ( overLeft < 0 ) {
  978. newOverRight = position.left + myOffset + atOffset + offset + data.collisionWidth -
  979. outerWidth - withinOffset;
  980. if ( newOverRight < 0 || newOverRight < abs( overLeft ) ) {
  981. position.left += myOffset + atOffset + offset;
  982. }
  983. } else if ( overRight > 0 ) {
  984. newOverLeft = position.left - data.collisionPosition.marginLeft + myOffset +
  985. atOffset + offset - offsetLeft;
  986. if ( newOverLeft > 0 || abs( newOverLeft ) < overRight ) {
  987. position.left += myOffset + atOffset + offset;
  988. }
  989. }
  990. },
  991. top: function( position, data ) {
  992. var within = data.within,
  993. withinOffset = within.offset.top + within.scrollTop,
  994. outerHeight = within.height,
  995. offsetTop = within.isWindow ? within.scrollTop : within.offset.top,
  996. collisionPosTop = position.top - data.collisionPosition.marginTop,
  997. overTop = collisionPosTop - offsetTop,
  998. overBottom = collisionPosTop + data.collisionHeight - outerHeight - offsetTop,
  999. top = data.my[ 1 ] === "top",
  1000. myOffset = top ?
  1001. -data.elemHeight :
  1002. data.my[ 1 ] === "bottom" ?
  1003. data.elemHeight :
  1004. 0,
  1005. atOffset = data.at[ 1 ] === "top" ?
  1006. data.targetHeight :
  1007. data.at[ 1 ] === "bottom" ?
  1008. -data.targetHeight :
  1009. 0,
  1010. offset = -2 * data.offset[ 1 ],
  1011. newOverTop,
  1012. newOverBottom;
  1013. if ( overTop < 0 ) {
  1014. newOverBottom = position.top + myOffset + atOffset + offset + data.collisionHeight -
  1015. outerHeight - withinOffset;
  1016. if ( newOverBottom < 0 || newOverBottom < abs( overTop ) ) {
  1017. position.top += myOffset + atOffset + offset;
  1018. }
  1019. } else if ( overBottom > 0 ) {
  1020. newOverTop = position.top - data.collisionPosition.marginTop + myOffset + atOffset +
  1021. offset - offsetTop;
  1022. if ( newOverTop > 0 || abs( newOverTop ) < overBottom ) {
  1023. position.top += myOffset + atOffset + offset;
  1024. }
  1025. }
  1026. }
  1027. },
  1028. flipfit: {
  1029. left: function() {
  1030. $.ui.position.flip.left.apply( this, arguments );
  1031. $.ui.position.fit.left.apply( this, arguments );
  1032. },
  1033. top: function() {
  1034. $.ui.position.flip.top.apply( this, arguments );
  1035. $.ui.position.fit.top.apply( this, arguments );
  1036. }
  1037. }
  1038. };
  1039. } )();
  1040. var position = $.ui.position;
  1041. /*!
  1042. * jQuery UI :data 1.12.1
  1043. * http://jqueryui.com
  1044. *
  1045. * Copyright jQuery Foundation and other contributors
  1046. * Released under the MIT license.
  1047. * http://jquery.org/license
  1048. */
  1049. //>>label: :data Selector
  1050. //>>group: Core
  1051. //>>description: Selects elements which have data stored under the specified key.
  1052. //>>docs: http://api.jqueryui.com/data-selector/
  1053. var data = $.extend( $.expr[ ":" ], {
  1054. data: $.expr.createPseudo ?
  1055. $.expr.createPseudo( function( dataName ) {
  1056. return function( elem ) {
  1057. return !!$.data( elem, dataName );
  1058. };
  1059. } ) :
  1060. // Support: jQuery <1.8
  1061. function( elem, i, match ) {
  1062. return !!$.data( elem, match[ 3 ] );
  1063. }
  1064. } );
  1065. /*!
  1066. * jQuery UI Disable Selection 1.12.1
  1067. * http://jqueryui.com
  1068. *
  1069. * Copyright jQuery Foundation and other contributors
  1070. * Released under the MIT license.
  1071. * http://jquery.org/license
  1072. */
  1073. //>>label: disableSelection
  1074. //>>group: Core
  1075. //>>description: Disable selection of text content within the set of matched elements.
  1076. //>>docs: http://api.jqueryui.com/disableSelection/
  1077. // This file is deprecated
  1078. var disableSelection = $.fn.extend( {
  1079. disableSelection: ( function() {
  1080. var eventType = "onselectstart" in document.createElement( "div" ) ?
  1081. "selectstart" :
  1082. "mousedown";
  1083. return function() {
  1084. return this.on( eventType + ".ui-disableSelection", function( event ) {
  1085. event.preventDefault();
  1086. } );
  1087. };
  1088. } )(),
  1089. enableSelection: function() {
  1090. return this.off( ".ui-disableSelection" );
  1091. }
  1092. } );
  1093. /*!
  1094. * jQuery UI Focusable 1.12.1
  1095. * http://jqueryui.com
  1096. *
  1097. * Copyright jQuery Foundation and other contributors
  1098. * Released under the MIT license.
  1099. * http://jquery.org/license
  1100. */
  1101. //>>label: :focusable Selector
  1102. //>>group: Core
  1103. //>>description: Selects elements which can be focused.
  1104. //>>docs: http://api.jqueryui.com/focusable-selector/
  1105. // Selectors
  1106. $.ui.focusable = function( element, hasTabindex ) {
  1107. var map, mapName, img, focusableIfVisible, fieldset,
  1108. nodeName = element.nodeName.toLowerCase();
  1109. if ( "area" === nodeName ) {
  1110. map = element.parentNode;
  1111. mapName = map.name;
  1112. if ( !element.href || !mapName || map.nodeName.toLowerCase() !== "map" ) {
  1113. return false;
  1114. }
  1115. img = $( "img[usemap='#" + mapName + "']" );
  1116. return img.length > 0 && img.is( ":visible" );
  1117. }
  1118. if ( /^(input|select|textarea|button|object)$/.test( nodeName ) ) {
  1119. focusableIfVisible = !element.disabled;
  1120. if ( focusableIfVisible ) {
  1121. // Form controls within a disabled fieldset are disabled.
  1122. // However, controls within the fieldset's legend do not get disabled.
  1123. // Since controls generally aren't placed inside legends, we skip
  1124. // this portion of the check.
  1125. fieldset = $( element ).closest( "fieldset" )[ 0 ];
  1126. if ( fieldset ) {
  1127. focusableIfVisible = !fieldset.disabled;
  1128. }
  1129. }
  1130. } else if ( "a" === nodeName ) {
  1131. focusableIfVisible = element.href || hasTabindex;
  1132. } else {
  1133. focusableIfVisible = hasTabindex;
  1134. }
  1135. return focusableIfVisible && $( element ).is( ":visible" ) && visible( $( element ) );
  1136. };
  1137. // Support: IE 8 only
  1138. // IE 8 doesn't resolve inherit to visible/hidden for computed values
  1139. function visible( element ) {
  1140. var visibility = element.css( "visibility" );
  1141. while ( visibility === "inherit" ) {
  1142. element = element.parent();
  1143. visibility = element.css( "visibility" );
  1144. }
  1145. return visibility !== "hidden";
  1146. }
  1147. $.extend( $.expr[ ":" ], {
  1148. focusable: function( element ) {
  1149. return $.ui.focusable( element, $.attr( element, "tabindex" ) != null );
  1150. }
  1151. } );
  1152. var focusable = $.ui.focusable;
  1153. // Support: IE8 Only
  1154. // IE8 does not support the form attribute and when it is supplied. It overwrites the form prop
  1155. // with a string, so we need to find the proper form.
  1156. var form = $.fn.form = function() {
  1157. return typeof this[ 0 ].form === "string" ? this.closest( "form" ) : $( this[ 0 ].form );
  1158. };
  1159. /*!
  1160. * jQuery UI Form Reset Mixin 1.12.1
  1161. * http://jqueryui.com
  1162. *
  1163. * Copyright jQuery Foundation and other contributors
  1164. * Released under the MIT license.
  1165. * http://jquery.org/license
  1166. */
  1167. //>>label: Form Reset Mixin
  1168. //>>group: Core
  1169. //>>description: Refresh input widgets when their form is reset
  1170. //>>docs: http://api.jqueryui.com/form-reset-mixin/
  1171. var formResetMixin = $.ui.formResetMixin = {
  1172. _formResetHandler: function() {
  1173. var form = $( this );
  1174. // Wait for the form reset to actually happen before refreshing
  1175. setTimeout( function() {
  1176. var instances = form.data( "ui-form-reset-instances" );
  1177. $.each( instances, function() {
  1178. this.refresh();
  1179. } );
  1180. } );
  1181. },
  1182. _bindFormResetHandler: function() {
  1183. this.form = this.element.form();
  1184. if ( !this.form.length ) {
  1185. return;
  1186. }
  1187. var instances = this.form.data( "ui-form-reset-instances" ) || [];
  1188. if ( !instances.length ) {
  1189. // We don't use _on() here because we use a single event handler per form
  1190. this.form.on( "reset.ui-form-reset", this._formResetHandler );
  1191. }
  1192. instances.push( this );
  1193. this.form.data( "ui-form-reset-instances", instances );
  1194. },
  1195. _unbindFormResetHandler: function() {
  1196. if ( !this.form.length ) {
  1197. return;
  1198. }
  1199. var instances = this.form.data( "ui-form-reset-instances" );
  1200. instances.splice( $.inArray( this, instances ), 1 );
  1201. if ( instances.length ) {
  1202. this.form.data( "ui-form-reset-instances", instances );
  1203. } else {
  1204. this.form
  1205. .removeData( "ui-form-reset-instances" )
  1206. .off( "reset.ui-form-reset" );
  1207. }
  1208. }
  1209. };
  1210. /*!
  1211. * jQuery UI Support for jQuery core 1.7.x 1.12.1
  1212. * http://jqueryui.com
  1213. *
  1214. * Copyright jQuery Foundation and other contributors
  1215. * Released under the MIT license.
  1216. * http://jquery.org/license
  1217. *
  1218. */
  1219. //>>label: jQuery 1.7 Support
  1220. //>>group: Core
  1221. //>>description: Support version 1.7.x of jQuery core
  1222. // Support: jQuery 1.7 only
  1223. // Not a great way to check versions, but since we only support 1.7+ and only
  1224. // need to detect <1.8, this is a simple check that should suffice. Checking
  1225. // for "1.7." would be a bit safer, but the version string is 1.7, not 1.7.0
  1226. // and we'll never reach 1.70.0 (if we do, we certainly won't be supporting
  1227. // 1.7 anymore). See #11197 for why we're not using feature detection.
  1228. if ( $.fn.jquery.substring( 0, 3 ) === "1.7" ) {
  1229. // Setters for .innerWidth(), .innerHeight(), .outerWidth(), .outerHeight()
  1230. // Unlike jQuery Core 1.8+, these only support numeric values to set the
  1231. // dimensions in pixels
  1232. $.each( [ "Width", "Height" ], function( i, name ) {
  1233. var side = name === "Width" ? [ "Left", "Right" ] : [ "Top", "Bottom" ],
  1234. type = name.toLowerCase(),
  1235. orig = {
  1236. innerWidth: $.fn.innerWidth,
  1237. innerHeight: $.fn.innerHeight,
  1238. outerWidth: $.fn.outerWidth,
  1239. outerHeight: $.fn.outerHeight
  1240. };
  1241. function reduce( elem, size, border, margin ) {
  1242. $.each( side, function() {
  1243. size -= parseFloat( $.css( elem, "padding" + this ) ) || 0;
  1244. if ( border ) {
  1245. size -= parseFloat( $.css( elem, "border" + this + "Width" ) ) || 0;
  1246. }
  1247. if ( margin ) {
  1248. size -= parseFloat( $.css( elem, "margin" + this ) ) || 0;
  1249. }
  1250. } );
  1251. return size;
  1252. }
  1253. $.fn[ "inner" + name ] = function( size ) {
  1254. if ( size === undefined ) {
  1255. return orig[ "inner" + name ].call( this );
  1256. }
  1257. return this.each( function() {
  1258. $( this ).css( type, reduce( this, size ) + "px" );
  1259. } );
  1260. };
  1261. $.fn[ "outer" + name ] = function( size, margin ) {
  1262. if ( typeof size !== "number" ) {
  1263. return orig[ "outer" + name ].call( this, size );
  1264. }
  1265. return this.each( function() {
  1266. $( this ).css( type, reduce( this, size, true, margin ) + "px" );
  1267. } );
  1268. };
  1269. } );
  1270. $.fn.addBack = function( selector ) {
  1271. return this.add( selector == null ?
  1272. this.prevObject : this.prevObject.filter( selector )
  1273. );
  1274. };
  1275. }
  1276. ;
  1277. /*!
  1278. * jQuery UI Keycode 1.12.1
  1279. * http://jqueryui.com
  1280. *
  1281. * Copyright jQuery Foundation and other contributors
  1282. * Released under the MIT license.
  1283. * http://jquery.org/license
  1284. */
  1285. //>>label: Keycode
  1286. //>>group: Core
  1287. //>>description: Provide keycodes as keynames
  1288. //>>docs: http://api.jqueryui.com/jQuery.ui.keyCode/
  1289. var keycode = $.ui.keyCode = {
  1290. BACKSPACE: 8,
  1291. COMMA: 188,
  1292. DELETE: 46,
  1293. DOWN: 40,
  1294. END: 35,
  1295. ENTER: 13,
  1296. ESCAPE: 27,
  1297. HOME: 36,
  1298. LEFT: 37,
  1299. PAGE_DOWN: 34,
  1300. PAGE_UP: 33,
  1301. PERIOD: 190,
  1302. RIGHT: 39,
  1303. SPACE: 32,
  1304. TAB: 9,
  1305. UP: 38
  1306. };
  1307. // Internal use only
  1308. var escapeSelector = $.ui.escapeSelector = ( function() {
  1309. var selectorEscape = /([!"#$%&'()*+,./:;<=>?@[\]^`{|}~])/g;
  1310. return function( selector ) {
  1311. return selector.replace( selectorEscape, "\\$1" );
  1312. };
  1313. } )();
  1314. /*!
  1315. * jQuery UI Labels 1.12.1
  1316. * http://jqueryui.com
  1317. *
  1318. * Copyright jQuery Foundation and other contributors
  1319. * Released under the MIT license.
  1320. * http://jquery.org/license
  1321. */
  1322. //>>label: labels
  1323. //>>group: Core
  1324. //>>description: Find all the labels associated with a given input
  1325. //>>docs: http://api.jqueryui.com/labels/
  1326. var labels = $.fn.labels = function() {
  1327. var ancestor, selector, id, labels, ancestors;
  1328. // Check control.labels first
  1329. if ( this[ 0 ].labels && this[ 0 ].labels.length ) {
  1330. return this.pushStack( this[ 0 ].labels );
  1331. }
  1332. // Support: IE <= 11, FF <= 37, Android <= 2.3 only
  1333. // Above browsers do not support control.labels. Everything below is to support them
  1334. // as well as document fragments. control.labels does not work on document fragments
  1335. labels = this.eq( 0 ).parents( "label" );
  1336. // Look for the label based on the id
  1337. id = this.attr( "id" );
  1338. if ( id ) {
  1339. // We don't search against the document in case the element
  1340. // is disconnected from the DOM
  1341. ancestor = this.eq( 0 ).parents().last();
  1342. // Get a full set of top level ancestors
  1343. ancestors = ancestor.add( ancestor.length ? ancestor.siblings() : this.siblings() );
  1344. // Create a selector for the label based on the id
  1345. selector = "label[for='" + $.ui.escapeSelector( id ) + "']";
  1346. labels = labels.add( ancestors.find( selector ).addBack( selector ) );
  1347. }
  1348. // Return whatever we have found for labels
  1349. return this.pushStack( labels );
  1350. };
  1351. /*!
  1352. * jQuery UI Scroll Parent 1.12.1
  1353. * http://jqueryui.com
  1354. *
  1355. * Copyright jQuery Foundation and other contributors
  1356. * Released under the MIT license.
  1357. * http://jquery.org/license
  1358. */
  1359. //>>label: scrollParent
  1360. //>>group: Core
  1361. //>>description: Get the closest ancestor element that is scrollable.
  1362. //>>docs: http://api.jqueryui.com/scrollParent/
  1363. var scrollParent = $.fn.scrollParent = function( includeHidden ) {
  1364. var position = this.css( "position" ),
  1365. excludeStaticParent = position === "absolute",
  1366. overflowRegex = includeHidden ? /(auto|scroll|hidden)/ : /(auto|scroll)/,
  1367. scrollParent = this.parents().filter( function() {
  1368. var parent = $( this );
  1369. if ( excludeStaticParent && parent.css( "position" ) === "static" ) {
  1370. return false;
  1371. }
  1372. return overflowRegex.test( parent.css( "overflow" ) + parent.css( "overflow-y" ) +
  1373. parent.css( "overflow-x" ) );
  1374. } ).eq( 0 );
  1375. return position === "fixed" || !scrollParent.length ?
  1376. $( this[ 0 ].ownerDocument || document ) :
  1377. scrollParent;
  1378. };
  1379. /*!
  1380. * jQuery UI Tabbable 1.12.1
  1381. * http://jqueryui.com
  1382. *
  1383. * Copyright jQuery Foundation and other contributors
  1384. * Released under the MIT license.
  1385. * http://jquery.org/license
  1386. */
  1387. //>>label: :tabbable Selector
  1388. //>>group: Core
  1389. //>>description: Selects elements which can be tabbed to.
  1390. //>>docs: http://api.jqueryui.com/tabbable-selector/
  1391. var tabbable = $.extend( $.expr[ ":" ], {
  1392. tabbable: function( element ) {
  1393. var tabIndex = $.attr( element, "tabindex" ),
  1394. hasTabindex = tabIndex != null;
  1395. return ( !hasTabindex || tabIndex >= 0 ) && $.ui.focusable( element, hasTabindex );
  1396. }
  1397. } );
  1398. /*!
  1399. * jQuery UI Unique ID 1.12.1
  1400. * http://jqueryui.com
  1401. *
  1402. * Copyright jQuery Foundation and other contributors
  1403. * Released under the MIT license.
  1404. * http://jquery.org/license
  1405. */
  1406. //>>label: uniqueId
  1407. //>>group: Core
  1408. //>>description: Functions to generate and remove uniqueId's
  1409. //>>docs: http://api.jqueryui.com/uniqueId/
  1410. var uniqueId = $.fn.extend( {
  1411. uniqueId: ( function() {
  1412. var uuid = 0;
  1413. return function() {
  1414. return this.each( function() {
  1415. if ( !this.id ) {
  1416. this.id = "ui-id-" + ( ++uuid );
  1417. }
  1418. } );
  1419. };
  1420. } )(),
  1421. removeUniqueId: function() {
  1422. return this.each( function() {
  1423. if ( /^ui-id-\d+$/.test( this.id ) ) {
  1424. $( this ).removeAttr( "id" );
  1425. }
  1426. } );
  1427. }
  1428. } );
  1429. // This file is deprecated
  1430. var ie = $.ui.ie = !!/msie [\w.]+/.exec( navigator.userAgent.toLowerCase() );
  1431. /*!
  1432. * jQuery UI Mouse 1.12.1
  1433. * http://jqueryui.com
  1434. *
  1435. * Copyright jQuery Foundation and other contributors
  1436. * Released under the MIT license.
  1437. * http://jquery.org/license
  1438. */
  1439. //>>label: Mouse
  1440. //>>group: Widgets
  1441. //>>description: Abstracts mouse-based interactions to assist in creating certain widgets.
  1442. //>>docs: http://api.jqueryui.com/mouse/
  1443. var mouseHandled = false;
  1444. $( document ).on( "mouseup", function() {
  1445. mouseHandled = false;
  1446. } );
  1447. var widgetsMouse = $.widget( "ui.mouse", {
  1448. version: "1.12.1",
  1449. options: {
  1450. cancel: "input, textarea, button, select, option",
  1451. distance: 1,
  1452. delay: 0
  1453. },
  1454. _mouseInit: function() {
  1455. var that = this;
  1456. this.element
  1457. .on( "mousedown." + this.widgetName, function( event ) {
  1458. return that._mouseDown( event );
  1459. } )
  1460. .on( "click." + this.widgetName, function( event ) {
  1461. if ( true === $.data( event.target, that.widgetName + ".preventClickEvent" ) ) {
  1462. $.removeData( event.target, that.widgetName + ".preventClickEvent" );
  1463. event.stopImmediatePropagation();
  1464. return false;
  1465. }
  1466. } );
  1467. this.started = false;
  1468. },
  1469. // TODO: make sure destroying one instance of mouse doesn't mess with
  1470. // other instances of mouse
  1471. _mouseDestroy: function() {
  1472. this.element.off( "." + this.widgetName );
  1473. if ( this._mouseMoveDelegate ) {
  1474. this.document
  1475. .off( "mousemove." + this.widgetName, this._mouseMoveDelegate )
  1476. .off( "mouseup." + this.widgetName, this._mouseUpDelegate );
  1477. }
  1478. },
  1479. _mouseDown: function( event ) {
  1480. // don't let more than one widget handle mouseStart
  1481. if ( mouseHandled ) {
  1482. return;
  1483. }
  1484. this._mouseMoved = false;
  1485. // We may have missed mouseup (out of window)
  1486. ( this._mouseStarted && this._mouseUp( event ) );
  1487. this._mouseDownEvent = event;
  1488. var that = this,
  1489. btnIsLeft = ( event.which === 1 ),
  1490. // event.target.nodeName works around a bug in IE 8 with
  1491. // disabled inputs (#7620)
  1492. elIsCancel = ( typeof this.options.cancel === "string" && event.target.nodeName ?
  1493. $( event.target ).closest( this.options.cancel ).length : false );
  1494. if ( !btnIsLeft || elIsCancel || !this._mouseCapture( event ) ) {
  1495. return true;
  1496. }
  1497. this.mouseDelayMet = !this.options.delay;
  1498. if ( !this.mouseDelayMet ) {
  1499. this._mouseDelayTimer = setTimeout( function() {
  1500. that.mouseDelayMet = true;
  1501. }, this.options.delay );
  1502. }
  1503. if ( this._mouseDistanceMet( event ) && this._mouseDelayMet( event ) ) {
  1504. this._mouseStarted = ( this._mouseStart( event ) !== false );
  1505. if ( !this._mouseStarted ) {
  1506. event.preventDefault();
  1507. return true;
  1508. }
  1509. }
  1510. // Click event may never have fired (Gecko & Opera)
  1511. if ( true === $.data( event.target, this.widgetName + ".preventClickEvent" ) ) {
  1512. $.removeData( event.target, this.widgetName + ".preventClickEvent" );
  1513. }
  1514. // These delegates are required to keep context
  1515. this._mouseMoveDelegate = function( event ) {
  1516. return that._mouseMove( event );
  1517. };
  1518. this._mouseUpDelegate = function( event ) {
  1519. return that._mouseUp( event );
  1520. };
  1521. this.document
  1522. .on( "mousemove." + this.widgetName, this._mouseMoveDelegate )
  1523. .on( "mouseup." + this.widgetName, this._mouseUpDelegate );
  1524. event.preventDefault();
  1525. mouseHandled = true;
  1526. return true;
  1527. },
  1528. _mouseMove: function( event ) {
  1529. // Only check for mouseups outside the document if you've moved inside the document
  1530. // at least once. This prevents the firing of mouseup in the case of IE<9, which will
  1531. // fire a mousemove event if content is placed under the cursor. See #7778
  1532. // Support: IE <9
  1533. if ( this._mouseMoved ) {
  1534. // IE mouseup check - mouseup happened when mouse was out of window
  1535. if ( $.ui.ie && ( !document.documentMode || document.documentMode < 9 ) &&
  1536. !event.button ) {
  1537. return this._mouseUp( event );
  1538. // Iframe mouseup check - mouseup occurred in another document
  1539. } else if ( !event.which ) {
  1540. // Support: Safari <=8 - 9
  1541. // Safari sets which to 0 if you press any of the following keys
  1542. // during a drag (#14461)
  1543. if ( event.originalEvent.altKey || event.originalEvent.ctrlKey ||
  1544. event.originalEvent.metaKey || event.originalEvent.shiftKey ) {
  1545. this.ignoreMissingWhich = true;
  1546. } else if ( !this.ignoreMissingWhich ) {
  1547. return this._mouseUp( event );
  1548. }
  1549. }
  1550. }
  1551. if ( event.which || event.button ) {
  1552. this._mouseMoved = true;
  1553. }
  1554. if ( this._mouseStarted ) {
  1555. this._mouseDrag( event );
  1556. return event.preventDefault();
  1557. }
  1558. if ( this._mouseDistanceMet( event ) && this._mouseDelayMet( event ) ) {
  1559. this._mouseStarted =
  1560. ( this._mouseStart( this._mouseDownEvent, event ) !== false );
  1561. ( this._mouseStarted ? this._mouseDrag( event ) : this._mouseUp( event ) );
  1562. }
  1563. return !this._mouseStarted;
  1564. },
  1565. _mouseUp: function( event ) {
  1566. this.document
  1567. .off( "mousemove." + this.widgetName, this._mouseMoveDelegate )
  1568. .off( "mouseup." + this.widgetName, this._mouseUpDelegate );
  1569. if ( this._mouseStarted ) {
  1570. this._mouseStarted = false;
  1571. if ( event.target === this._mouseDownEvent.target ) {
  1572. $.data( event.target, this.widgetName + ".preventClickEvent", true );
  1573. }
  1574. this._mouseStop( event );
  1575. }
  1576. if ( this._mouseDelayTimer ) {
  1577. clearTimeout( this._mouseDelayTimer );
  1578. delete this._mouseDelayTimer;
  1579. }
  1580. this.ignoreMissingWhich = false;
  1581. mouseHandled = false;
  1582. event.preventDefault();
  1583. },
  1584. _mouseDistanceMet: function( event ) {
  1585. return ( Math.max(
  1586. Math.abs( this._mouseDownEvent.pageX - event.pageX ),
  1587. Math.abs( this._mouseDownEvent.pageY - event.pageY )
  1588. ) >= this.options.distance
  1589. );
  1590. },
  1591. _mouseDelayMet: function( /* event */ ) {
  1592. return this.mouseDelayMet;
  1593. },
  1594. // These are placeholder methods, to be overriden by extending plugin
  1595. _mouseStart: function( /* event */ ) {},
  1596. _mouseDrag: function( /* event */ ) {},
  1597. _mouseStop: function( /* event */ ) {},
  1598. _mouseCapture: function( /* event */ ) { return true; }
  1599. } );
  1600. // $.ui.plugin is deprecated. Use $.widget() extensions instead.
  1601. var plugin = $.ui.plugin = {
  1602. add: function( module, option, set ) {
  1603. var i,
  1604. proto = $.ui[ module ].prototype;
  1605. for ( i in set ) {
  1606. proto.plugins[ i ] = proto.plugins[ i ] || [];
  1607. proto.plugins[ i ].push( [ option, set[ i ] ] );
  1608. }
  1609. },
  1610. call: function( instance, name, args, allowDisconnected ) {
  1611. var i,
  1612. set = instance.plugins[ name ];
  1613. if ( !set ) {
  1614. return;
  1615. }
  1616. if ( !allowDisconnected && ( !instance.element[ 0 ].parentNode ||
  1617. instance.element[ 0 ].parentNode.nodeType === 11 ) ) {
  1618. return;
  1619. }
  1620. for ( i = 0; i < set.length; i++ ) {
  1621. if ( instance.options[ set[ i ][ 0 ] ] ) {
  1622. set[ i ][ 1 ].apply( instance.element, args );
  1623. }
  1624. }
  1625. }
  1626. };
  1627. var safeActiveElement = $.ui.safeActiveElement = function( document ) {
  1628. var activeElement;
  1629. // Support: IE 9 only
  1630. // IE9 throws an "Unspecified error" accessing document.activeElement from an <iframe>
  1631. try {
  1632. activeElement = document.activeElement;
  1633. } catch ( error ) {
  1634. activeElement = document.body;
  1635. }
  1636. // Support: IE 9 - 11 only
  1637. // IE may return null instead of an element
  1638. // Interestingly, this only seems to occur when NOT in an iframe
  1639. if ( !activeElement ) {
  1640. activeElement = document.body;
  1641. }
  1642. // Support: IE 11 only
  1643. // IE11 returns a seemingly empty object in some cases when accessing
  1644. // document.activeElement from an <iframe>
  1645. if ( !activeElement.nodeName ) {
  1646. activeElement = document.body;
  1647. }
  1648. return activeElement;
  1649. };
  1650. var safeBlur = $.ui.safeBlur = function( element ) {
  1651. // Support: IE9 - 10 only
  1652. // If the <body> is blurred, IE will switch windows, see #9420
  1653. if ( element && element.nodeName.toLowerCase() !== "body" ) {
  1654. $( element ).trigger( "blur" );
  1655. }
  1656. };
  1657. /*!
  1658. * jQuery UI Draggable 1.12.1
  1659. * http://jqueryui.com
  1660. *
  1661. * Copyright jQuery Foundation and other contributors
  1662. * Released under the MIT license.
  1663. * http://jquery.org/license
  1664. */
  1665. //>>label: Draggable
  1666. //>>group: Interactions
  1667. //>>description: Enables dragging functionality for any element.
  1668. //>>docs: http://api.jqueryui.com/draggable/
  1669. //>>demos: http://jqueryui.com/draggable/
  1670. //>>css.structure: ../../themes/base/draggable.css
  1671. $.widget( "ui.draggable", $.ui.mouse, {
  1672. version: "1.12.1",
  1673. widgetEventPrefix: "drag",
  1674. options: {
  1675. addClasses: true,
  1676. appendTo: "parent",
  1677. axis: false,
  1678. connectToSortable: false,
  1679. containment: false,
  1680. cursor: "auto",
  1681. cursorAt: false,
  1682. grid: false,
  1683. handle: false,
  1684. helper: "original",
  1685. iframeFix: false,
  1686. opacity: false,
  1687. refreshPositions: false,
  1688. revert: false,
  1689. revertDuration: 500,
  1690. scope: "default",
  1691. scroll: true,
  1692. scrollSensitivity: 20,
  1693. scrollSpeed: 20,
  1694. snap: false,
  1695. snapMode: "both",
  1696. snapTolerance: 20,
  1697. stack: false,
  1698. zIndex: false,
  1699. // Callbacks
  1700. drag: null,
  1701. start: null,
  1702. stop: null
  1703. },
  1704. _create: function() {
  1705. if ( this.options.helper === "original" ) {
  1706. this._setPositionRelative();
  1707. }
  1708. if ( this.options.addClasses ) {
  1709. this._addClass( "ui-draggable" );
  1710. }
  1711. this._setHandleClassName();
  1712. this._mouseInit();
  1713. },
  1714. _setOption: function( key, value ) {
  1715. this._super( key, value );
  1716. if ( key === "handle" ) {
  1717. this._removeHandleClassName();
  1718. this._setHandleClassName();
  1719. }
  1720. },
  1721. _destroy: function() {
  1722. if ( ( this.helper || this.element ).is( ".ui-draggable-dragging" ) ) {
  1723. this.destroyOnClear = true;
  1724. return;
  1725. }
  1726. this._removeHandleClassName();
  1727. this._mouseDestroy();
  1728. },
  1729. _mouseCapture: function( event ) {
  1730. var o = this.options;
  1731. // Among others, prevent a drag on a resizable-handle
  1732. if ( this.helper || o.disabled ||
  1733. $( event.target ).closest( ".ui-resizable-handle" ).length > 0 ) {
  1734. return false;
  1735. }
  1736. //Quit if we're not on a valid handle
  1737. this.handle = this._getHandle( event );
  1738. if ( !this.handle ) {
  1739. return false;
  1740. }
  1741. this._blurActiveElement( event );
  1742. this._blockFrames( o.iframeFix === true ? "iframe" : o.iframeFix );
  1743. return true;
  1744. },
  1745. _blockFrames: function( selector ) {
  1746. this.iframeBlocks = this.document.find( selector ).map( function() {
  1747. var iframe = $( this );
  1748. return $( "<div>" )
  1749. .css( "position", "absolute" )
  1750. .appendTo( iframe.parent() )
  1751. .outerWidth( iframe.outerWidth() )
  1752. .outerHeight( iframe.outerHeight() )
  1753. .offset( iframe.offset() )[ 0 ];
  1754. } );
  1755. },
  1756. _unblockFrames: function() {
  1757. if ( this.iframeBlocks ) {
  1758. this.iframeBlocks.remove();
  1759. delete this.iframeBlocks;
  1760. }
  1761. },
  1762. _blurActiveElement: function( event ) {
  1763. var activeElement = $.ui.safeActiveElement( this.document[ 0 ] ),
  1764. target = $( event.target );
  1765. // Don't blur if the event occurred on an element that is within
  1766. // the currently focused element
  1767. // See #10527, #12472
  1768. if ( target.closest( activeElement ).length ) {
  1769. return;
  1770. }
  1771. // Blur any element that currently has focus, see #4261
  1772. $.ui.safeBlur( activeElement );
  1773. },
  1774. _mouseStart: function( event ) {
  1775. var o = this.options;
  1776. //Create and append the visible helper
  1777. this.helper = this._createHelper( event );
  1778. this._addClass( this.helper, "ui-draggable-dragging" );
  1779. //Cache the helper size
  1780. this._cacheHelperProportions();
  1781. //If ddmanager is used for droppables, set the global draggable
  1782. if ( $.ui.ddmanager ) {
  1783. $.ui.ddmanager.current = this;
  1784. }
  1785. /*
  1786. * - Position generation -
  1787. * This block generates everything position related - it's the core of draggables.
  1788. */
  1789. //Cache the margins of the original element
  1790. this._cacheMargins();
  1791. //Store the helper's css position
  1792. this.cssPosition = this.helper.css( "position" );
  1793. this.scrollParent = this.helper.scrollParent( true );
  1794. this.offsetParent = this.helper.offsetParent();
  1795. this.hasFixedAncestor = this.helper.parents().filter( function() {
  1796. return $( this ).css( "position" ) === "fixed";
  1797. } ).length > 0;
  1798. //The element's absolute position on the page minus margins
  1799. this.positionAbs = this.element.offset();
  1800. this._refreshOffsets( event );
  1801. //Generate the original position
  1802. this.originalPosition = this.position = this._generatePosition( event, false );
  1803. this.originalPageX = event.pageX;
  1804. this.originalPageY = event.pageY;
  1805. //Adjust the mouse offset relative to the helper if "cursorAt" is supplied
  1806. ( o.cursorAt && this._adjustOffsetFromHelper( o.cursorAt ) );
  1807. //Set a containment if given in the options
  1808. this._setContainment();
  1809. //Trigger event + callbacks
  1810. if ( this._trigger( "start", event ) === false ) {
  1811. this._clear();
  1812. return false;
  1813. }
  1814. //Recache the helper size
  1815. this._cacheHelperProportions();
  1816. //Prepare the droppable offsets
  1817. if ( $.ui.ddmanager && !o.dropBehaviour ) {
  1818. $.ui.ddmanager.prepareOffsets( this, event );
  1819. }
  1820. // Execute the drag once - this causes the helper not to be visible before getting its
  1821. // correct position
  1822. this._mouseDrag( event, true );
  1823. // If the ddmanager is used for droppables, inform the manager that dragging has started
  1824. // (see #5003)
  1825. if ( $.ui.ddmanager ) {
  1826. $.ui.ddmanager.dragStart( this, event );
  1827. }
  1828. return true;
  1829. },
  1830. _refreshOffsets: function( event ) {
  1831. this.offset = {
  1832. top: this.positionAbs.top - this.margins.top,
  1833. left: this.positionAbs.left - this.margins.left,
  1834. scroll: false,
  1835. parent: this._getParentOffset(),
  1836. relative: this._getRelativeOffset()
  1837. };
  1838. this.offset.click = {
  1839. left: event.pageX - this.offset.left,
  1840. top: event.pageY - this.offset.top
  1841. };
  1842. },
  1843. _mouseDrag: function( event, noPropagation ) {
  1844. // reset any necessary cached properties (see #5009)
  1845. if ( this.hasFixedAncestor ) {
  1846. this.offset.parent = this._getParentOffset();
  1847. }
  1848. //Compute the helpers position
  1849. this.position = this._generatePosition( event, true );
  1850. this.positionAbs = this._convertPositionTo( "absolute" );
  1851. //Call plugins and callbacks and use the resulting position if something is returned
  1852. if ( !noPropagation ) {
  1853. var ui = this._uiHash();
  1854. if ( this._trigger( "drag", event, ui ) === false ) {
  1855. this._mouseUp( new $.Event( "mouseup", event ) );
  1856. return false;
  1857. }
  1858. this.position = ui.position;
  1859. }
  1860. this.helper[ 0 ].style.left = this.position.left + "px";
  1861. this.helper[ 0 ].style.top = this.position.top + "px";
  1862. if ( $.ui.ddmanager ) {
  1863. $.ui.ddmanager.drag( this, event );
  1864. }
  1865. return false;
  1866. },
  1867. _mouseStop: function( event ) {
  1868. //If we are using droppables, inform the manager about the drop
  1869. var that = this,
  1870. dropped = false;
  1871. if ( $.ui.ddmanager && !this.options.dropBehaviour ) {
  1872. dropped = $.ui.ddmanager.drop( this, event );
  1873. }
  1874. //if a drop comes from outside (a sortable)
  1875. if ( this.dropped ) {
  1876. dropped = this.dropped;
  1877. this.dropped = false;
  1878. }
  1879. if ( ( this.options.revert === "invalid" && !dropped ) ||
  1880. ( this.options.revert === "valid" && dropped ) ||
  1881. this.options.revert === true || ( $.isFunction( this.options.revert ) &&
  1882. this.options.revert.call( this.element, dropped ) )
  1883. ) {
  1884. $( this.helper ).animate(
  1885. this.originalPosition,
  1886. parseInt( this.options.revertDuration, 10 ),
  1887. function() {
  1888. if ( that._trigger( "stop", event ) !== false ) {
  1889. that._clear();
  1890. }
  1891. }
  1892. );
  1893. } else {
  1894. if ( this._trigger( "stop", event ) !== false ) {
  1895. this._clear();
  1896. }
  1897. }
  1898. return false;
  1899. },
  1900. _mouseUp: function( event ) {
  1901. this._unblockFrames();
  1902. // If the ddmanager is used for droppables, inform the manager that dragging has stopped
  1903. // (see #5003)
  1904. if ( $.ui.ddmanager ) {
  1905. $.ui.ddmanager.dragStop( this, event );
  1906. }
  1907. // Only need to focus if the event occurred on the draggable itself, see #10527
  1908. if ( this.handleElement.is( event.target ) ) {
  1909. // The interaction is over; whether or not the click resulted in a drag,
  1910. // focus the element
  1911. this.element.trigger( "focus" );
  1912. }
  1913. return $.ui.mouse.prototype._mouseUp.call( this, event );
  1914. },
  1915. cancel: function() {
  1916. if ( this.helper.is( ".ui-draggable-dragging" ) ) {
  1917. this._mouseUp( new $.Event( "mouseup", { target: this.element[ 0 ] } ) );
  1918. } else {
  1919. this._clear();
  1920. }
  1921. return this;
  1922. },
  1923. _getHandle: function( event ) {
  1924. return this.options.handle ?
  1925. !!$( event.target ).closest( this.element.find( this.options.handle ) ).length :
  1926. true;
  1927. },
  1928. _setHandleClassName: function() {
  1929. this.handleElement = this.options.handle ?
  1930. this.element.find( this.options.handle ) : this.element;
  1931. this._addClass( this.handleElement, "ui-draggable-handle" );
  1932. },
  1933. _removeHandleClassName: function() {
  1934. this._removeClass( this.handleElement, "ui-draggable-handle" );
  1935. },
  1936. _createHelper: function( event ) {
  1937. var o = this.options,
  1938. helperIsFunction = $.isFunction( o.helper ),
  1939. helper = helperIsFunction ?
  1940. $( o.helper.apply( this.element[ 0 ], [ event ] ) ) :
  1941. ( o.helper === "clone" ?
  1942. this.element.clone().removeAttr( "id" ) :
  1943. this.element );
  1944. if ( !helper.parents( "body" ).length ) {
  1945. helper.appendTo( ( o.appendTo === "parent" ?
  1946. this.element[ 0 ].parentNode :
  1947. o.appendTo ) );
  1948. }
  1949. // Http://bugs.jqueryui.com/ticket/9446
  1950. // a helper function can return the original element
  1951. // which wouldn't have been set to relative in _create
  1952. if ( helperIsFunction && helper[ 0 ] === this.element[ 0 ] ) {
  1953. this._setPositionRelative();
  1954. }
  1955. if ( helper[ 0 ] !== this.element[ 0 ] &&
  1956. !( /(fixed|absolute)/ ).test( helper.css( "position" ) ) ) {
  1957. helper.css( "position", "absolute" );
  1958. }
  1959. return helper;
  1960. },
  1961. _setPositionRelative: function() {
  1962. if ( !( /^(?:r|a|f)/ ).test( this.element.css( "position" ) ) ) {
  1963. this.element[ 0 ].style.position = "relative";
  1964. }
  1965. },
  1966. _adjustOffsetFromHelper: function( obj ) {
  1967. if ( typeof obj === "string" ) {
  1968. obj = obj.split( " " );
  1969. }
  1970. if ( $.isArray( obj ) ) {
  1971. obj = { left: +obj[ 0 ], top: +obj[ 1 ] || 0 };
  1972. }
  1973. if ( "left" in obj ) {
  1974. this.offset.click.left = obj.left + this.margins.left;
  1975. }
  1976. if ( "right" in obj ) {
  1977. this.offset.click.left = this.helperProportions.width - obj.right + this.margins.left;
  1978. }
  1979. if ( "top" in obj ) {
  1980. this.offset.click.top = obj.top + this.margins.top;
  1981. }
  1982. if ( "bottom" in obj ) {
  1983. this.offset.click.top = this.helperProportions.height - obj.bottom + this.margins.top;
  1984. }
  1985. },
  1986. _isRootNode: function( element ) {
  1987. return ( /(html|body)/i ).test( element.tagName ) || element === this.document[ 0 ];
  1988. },
  1989. _getParentOffset: function() {
  1990. //Get the offsetParent and cache its position
  1991. var po = this.offsetParent.offset(),
  1992. document = this.document[ 0 ];
  1993. // This is a special case where we need to modify a offset calculated on start, since the
  1994. // following happened:
  1995. // 1. The position of the helper is absolute, so it's position is calculated based on the
  1996. // next positioned parent
  1997. // 2. The actual offset parent is a child of the scroll parent, and the scroll parent isn't
  1998. // the document, which means that the scroll is included in the initial calculation of the
  1999. // offset of the parent, and never recalculated upon drag
  2000. if ( this.cssPosition === "absolute" && this.scrollParent[ 0 ] !== document &&
  2001. $.contains( this.scrollParent[ 0 ], this.offsetParent[ 0 ] ) ) {
  2002. po.left += this.scrollParent.scrollLeft();
  2003. po.top += this.scrollParent.scrollTop();
  2004. }
  2005. if ( this._isRootNode( this.offsetParent[ 0 ] ) ) {
  2006. po = { top: 0, left: 0 };
  2007. }
  2008. return {
  2009. top: po.top + ( parseInt( this.offsetParent.css( "borderTopWidth" ), 10 ) || 0 ),
  2010. left: po.left + ( parseInt( this.offsetParent.css( "borderLeftWidth" ), 10 ) || 0 )
  2011. };
  2012. },
  2013. _getRelativeOffset: function() {
  2014. if ( this.cssPosition !== "relative" ) {
  2015. return { top: 0, left: 0 };
  2016. }
  2017. var p = this.element.position(),
  2018. scrollIsRootNode = this._isRootNode( this.scrollParent[ 0 ] );
  2019. return {
  2020. top: p.top - ( parseInt( this.helper.css( "top" ), 10 ) || 0 ) +
  2021. ( !scrollIsRootNode ? this.scrollParent.scrollTop() : 0 ),
  2022. left: p.left - ( parseInt( this.helper.css( "left" ), 10 ) || 0 ) +
  2023. ( !scrollIsRootNode ? this.scrollParent.scrollLeft() : 0 )
  2024. };
  2025. },
  2026. _cacheMargins: function() {
  2027. this.margins = {
  2028. left: ( parseInt( this.element.css( "marginLeft" ), 10 ) || 0 ),
  2029. top: ( parseInt( this.element.css( "marginTop" ), 10 ) || 0 ),
  2030. right: ( parseInt( this.element.css( "marginRight" ), 10 ) || 0 ),
  2031. bottom: ( parseInt( this.element.css( "marginBottom" ), 10 ) || 0 )
  2032. };
  2033. },
  2034. _cacheHelperProportions: function() {
  2035. this.helperProportions = {
  2036. width: this.helper.outerWidth(),
  2037. height: this.helper.outerHeight()
  2038. };
  2039. },
  2040. _setContainment: function() {
  2041. var isUserScrollable, c, ce,
  2042. o = this.options,
  2043. document = this.document[ 0 ];
  2044. this.relativeContainer = null;
  2045. if ( !o.containment ) {
  2046. this.containment = null;
  2047. return;
  2048. }
  2049. if ( o.containment === "window" ) {
  2050. this.containment = [
  2051. $( window ).scrollLeft() - this.offset.relative.left - this.offset.parent.left,
  2052. $( window ).scrollTop() - this.offset.relative.top - this.offset.parent.top,
  2053. $( window ).scrollLeft() + $( window ).width() -
  2054. this.helperProportions.width - this.margins.left,
  2055. $( window ).scrollTop() +
  2056. ( $( window ).height() || document.body.parentNode.scrollHeight ) -
  2057. this.helperProportions.height - this.margins.top
  2058. ];
  2059. return;
  2060. }
  2061. if ( o.containment === "document" ) {
  2062. this.containment = [
  2063. 0,
  2064. 0,
  2065. $( document ).width() - this.helperProportions.width - this.margins.left,
  2066. ( $( document ).height() || document.body.parentNode.scrollHeight ) -
  2067. this.helperProportions.height - this.margins.top
  2068. ];
  2069. return;
  2070. }
  2071. if ( o.containment.constructor === Array ) {
  2072. this.containment = o.containment;
  2073. return;
  2074. }
  2075. if ( o.containment === "parent" ) {
  2076. o.containment = this.helper[ 0 ].parentNode;
  2077. }
  2078. c = $( o.containment );
  2079. ce = c[ 0 ];
  2080. if ( !ce ) {
  2081. return;
  2082. }
  2083. isUserScrollable = /(scroll|auto)/.test( c.css( "overflow" ) );
  2084. this.containment = [
  2085. ( parseInt( c.css( "borderLeftWidth" ), 10 ) || 0 ) +
  2086. ( parseInt( c.css( "paddingLeft" ), 10 ) || 0 ),
  2087. ( parseInt( c.css( "borderTopWidth" ), 10 ) || 0 ) +
  2088. ( parseInt( c.css( "paddingTop" ), 10 ) || 0 ),
  2089. ( isUserScrollable ? Math.max( ce.scrollWidth, ce.offsetWidth ) : ce.offsetWidth ) -
  2090. ( parseInt( c.css( "borderRightWidth" ), 10 ) || 0 ) -
  2091. ( parseInt( c.css( "paddingRight" ), 10 ) || 0 ) -
  2092. this.helperProportions.width -
  2093. this.margins.left -
  2094. this.margins.right,
  2095. ( isUserScrollable ? Math.max( ce.scrollHeight, ce.offsetHeight ) : ce.offsetHeight ) -
  2096. ( parseInt( c.css( "borderBottomWidth" ), 10 ) || 0 ) -
  2097. ( parseInt( c.css( "paddingBottom" ), 10 ) || 0 ) -
  2098. this.helperProportions.height -
  2099. this.margins.top -
  2100. this.margins.bottom
  2101. ];
  2102. this.relativeContainer = c;
  2103. },
  2104. _convertPositionTo: function( d, pos ) {
  2105. if ( !pos ) {
  2106. pos = this.position;
  2107. }
  2108. var mod = d === "absolute" ? 1 : -1,
  2109. scrollIsRootNode = this._isRootNode( this.scrollParent[ 0 ] );
  2110. return {
  2111. top: (
  2112. // The absolute mouse position
  2113. pos.top +
  2114. // Only for relative positioned nodes: Relative offset from element to offset parent
  2115. this.offset.relative.top * mod +
  2116. // The offsetParent's offset without borders (offset + border)
  2117. this.offset.parent.top * mod -
  2118. ( ( this.cssPosition === "fixed" ?
  2119. -this.offset.scroll.top :
  2120. ( scrollIsRootNode ? 0 : this.offset.scroll.top ) ) * mod )
  2121. ),
  2122. left: (
  2123. // The absolute mouse position
  2124. pos.left +
  2125. // Only for relative positioned nodes: Relative offset from element to offset parent
  2126. this.offset.relative.left * mod +
  2127. // The offsetParent's offset without borders (offset + border)
  2128. this.offset.parent.left * mod -
  2129. ( ( this.cssPosition === "fixed" ?
  2130. -this.offset.scroll.left :
  2131. ( scrollIsRootNode ? 0 : this.offset.scroll.left ) ) * mod )
  2132. )
  2133. };
  2134. },
  2135. _generatePosition: function( event, constrainPosition ) {
  2136. var containment, co, top, left,
  2137. o = this.options,
  2138. scrollIsRootNode = this._isRootNode( this.scrollParent[ 0 ] ),
  2139. pageX = event.pageX,
  2140. pageY = event.pageY;
  2141. // Cache the scroll
  2142. if ( !scrollIsRootNode || !this.offset.scroll ) {
  2143. this.offset.scroll = {
  2144. top: this.scrollParent.scrollTop(),
  2145. left: this.scrollParent.scrollLeft()
  2146. };
  2147. }
  2148. /*
  2149. * - Position constraining -
  2150. * Constrain the position to a mix of grid, containment.
  2151. */
  2152. // If we are not dragging yet, we won't check for options
  2153. if ( constrainPosition ) {
  2154. if ( this.containment ) {
  2155. if ( this.relativeContainer ) {
  2156. co = this.relativeContainer.offset();
  2157. containment = [
  2158. this.containment[ 0 ] + co.left,
  2159. this.containment[ 1 ] + co.top,
  2160. this.containment[ 2 ] + co.left,
  2161. this.containment[ 3 ] + co.top
  2162. ];
  2163. } else {
  2164. containment = this.containment;
  2165. }
  2166. if ( event.pageX - this.offset.click.left < containment[ 0 ] ) {
  2167. pageX = containment[ 0 ] + this.offset.click.left;
  2168. }
  2169. if ( event.pageY - this.offset.click.top < containment[ 1 ] ) {
  2170. pageY = containment[ 1 ] + this.offset.click.top;
  2171. }
  2172. if ( event.pageX - this.offset.click.left > containment[ 2 ] ) {
  2173. pageX = containment[ 2 ] + this.offset.click.left;
  2174. }
  2175. if ( event.pageY - this.offset.click.top > containment[ 3 ] ) {
  2176. pageY = containment[ 3 ] + this.offset.click.top;
  2177. }
  2178. }
  2179. if ( o.grid ) {
  2180. //Check for grid elements set to 0 to prevent divide by 0 error causing invalid
  2181. // argument errors in IE (see ticket #6950)
  2182. top = o.grid[ 1 ] ? this.originalPageY + Math.round( ( pageY -
  2183. this.originalPageY ) / o.grid[ 1 ] ) * o.grid[ 1 ] : this.originalPageY;
  2184. pageY = containment ? ( ( top - this.offset.click.top >= containment[ 1 ] ||
  2185. top - this.offset.click.top > containment[ 3 ] ) ?
  2186. top :
  2187. ( ( top - this.offset.click.top >= containment[ 1 ] ) ?
  2188. top - o.grid[ 1 ] : top + o.grid[ 1 ] ) ) : top;
  2189. left = o.grid[ 0 ] ? this.originalPageX +
  2190. Math.round( ( pageX - this.originalPageX ) / o.grid[ 0 ] ) * o.grid[ 0 ] :
  2191. this.originalPageX;
  2192. pageX = containment ? ( ( left - this.offset.click.left >= containment[ 0 ] ||
  2193. left - this.offset.click.left > containment[ 2 ] ) ?
  2194. left :
  2195. ( ( left - this.offset.click.left >= containment[ 0 ] ) ?
  2196. left - o.grid[ 0 ] : left + o.grid[ 0 ] ) ) : left;
  2197. }
  2198. if ( o.axis === "y" ) {
  2199. pageX = this.originalPageX;
  2200. }
  2201. if ( o.axis === "x" ) {
  2202. pageY = this.originalPageY;
  2203. }
  2204. }
  2205. return {
  2206. top: (
  2207. // The absolute mouse position
  2208. pageY -
  2209. // Click offset (relative to the element)
  2210. this.offset.click.top -
  2211. // Only for relative positioned nodes: Relative offset from element to offset parent
  2212. this.offset.relative.top -
  2213. // The offsetParent's offset without borders (offset + border)
  2214. this.offset.parent.top +
  2215. ( this.cssPosition === "fixed" ?
  2216. -this.offset.scroll.top :
  2217. ( scrollIsRootNode ? 0 : this.offset.scroll.top ) )
  2218. ),
  2219. left: (
  2220. // The absolute mouse position
  2221. pageX -
  2222. // Click offset (relative to the element)
  2223. this.offset.click.left -
  2224. // Only for relative positioned nodes: Relative offset from element to offset parent
  2225. this.offset.relative.left -
  2226. // The offsetParent's offset without borders (offset + border)
  2227. this.offset.parent.left +
  2228. ( this.cssPosition === "fixed" ?
  2229. -this.offset.scroll.left :
  2230. ( scrollIsRootNode ? 0 : this.offset.scroll.left ) )
  2231. )
  2232. };
  2233. },
  2234. _clear: function() {
  2235. this._removeClass( this.helper, "ui-draggable-dragging" );
  2236. if ( this.helper[ 0 ] !== this.element[ 0 ] && !this.cancelHelperRemoval ) {
  2237. this.helper.remove();
  2238. }
  2239. this.helper = null;
  2240. this.cancelHelperRemoval = false;
  2241. if ( this.destroyOnClear ) {
  2242. this.destroy();
  2243. }
  2244. },
  2245. // From now on bulk stuff - mainly helpers
  2246. _trigger: function( type, event, ui ) {
  2247. ui = ui || this._uiHash();
  2248. $.ui.plugin.call( this, type, [ event, ui, this ], true );
  2249. // Absolute position and offset (see #6884 ) have to be recalculated after plugins
  2250. if ( /^(drag|start|stop)/.test( type ) ) {
  2251. this.positionAbs = this._convertPositionTo( "absolute" );
  2252. ui.offset = this.positionAbs;
  2253. }
  2254. return $.Widget.prototype._trigger.call( this, type, event, ui );
  2255. },
  2256. plugins: {},
  2257. _uiHash: function() {
  2258. return {
  2259. helper: this.helper,
  2260. position: this.position,
  2261. originalPosition: this.originalPosition,
  2262. offset: this.positionAbs
  2263. };
  2264. }
  2265. } );
  2266. $.ui.plugin.add( "draggable", "connectToSortable", {
  2267. start: function( event, ui, draggable ) {
  2268. var uiSortable = $.extend( {}, ui, {
  2269. item: draggable.element
  2270. } );
  2271. draggable.sortables = [];
  2272. $( draggable.options.connectToSortable ).each( function() {
  2273. var sortable = $( this ).sortable( "instance" );
  2274. if ( sortable && !sortable.options.disabled ) {
  2275. draggable.sortables.push( sortable );
  2276. // RefreshPositions is called at drag start to refresh the containerCache
  2277. // which is used in drag. This ensures it's initialized and synchronized
  2278. // with any changes that might have happened on the page since initialization.
  2279. sortable.refreshPositions();
  2280. sortable._trigger( "activate", event, uiSortable );
  2281. }
  2282. } );
  2283. },
  2284. stop: function( event, ui, draggable ) {
  2285. var uiSortable = $.extend( {}, ui, {
  2286. item: draggable.element
  2287. } );
  2288. draggable.cancelHelperRemoval = false;
  2289. $.each( draggable.sortables, function() {
  2290. var sortable = this;
  2291. if ( sortable.isOver ) {
  2292. sortable.isOver = 0;
  2293. // Allow this sortable to handle removing the helper
  2294. draggable.cancelHelperRemoval = true;
  2295. sortable.cancelHelperRemoval = false;
  2296. // Use _storedCSS To restore properties in the sortable,
  2297. // as this also handles revert (#9675) since the draggable
  2298. // may have modified them in unexpected ways (#8809)
  2299. sortable._storedCSS = {
  2300. position: sortable.placeholder.css( "position" ),
  2301. top: sortable.placeholder.css( "top" ),
  2302. left: sortable.placeholder.css( "left" )
  2303. };
  2304. sortable._mouseStop( event );
  2305. // Once drag has ended, the sortable should return to using
  2306. // its original helper, not the shared helper from draggable
  2307. sortable.options.helper = sortable.options._helper;
  2308. } else {
  2309. // Prevent this Sortable from removing the helper.
  2310. // However, don't set the draggable to remove the helper
  2311. // either as another connected Sortable may yet handle the removal.
  2312. sortable.cancelHelperRemoval = true;
  2313. sortable._trigger( "deactivate", event, uiSortable );
  2314. }
  2315. } );
  2316. },
  2317. drag: function( event, ui, draggable ) {
  2318. $.each( draggable.sortables, function() {
  2319. var innermostIntersecting = false,
  2320. sortable = this;
  2321. // Copy over variables that sortable's _intersectsWith uses
  2322. sortable.positionAbs = draggable.positionAbs;
  2323. sortable.helperProportions = draggable.helperProportions;
  2324. sortable.offset.click = draggable.offset.click;
  2325. if ( sortable._intersectsWith( sortable.containerCache ) ) {
  2326. innermostIntersecting = true;
  2327. $.each( draggable.sortables, function() {
  2328. // Copy over variables that sortable's _intersectsWith uses
  2329. this.positionAbs = draggable.positionAbs;
  2330. this.helperProportions = draggable.helperProportions;
  2331. this.offset.click = draggable.offset.click;
  2332. if ( this !== sortable &&
  2333. this._intersectsWith( this.containerCache ) &&
  2334. $.contains( sortable.element[ 0 ], this.element[ 0 ] ) ) {
  2335. innermostIntersecting = false;
  2336. }
  2337. return innermostIntersecting;
  2338. } );
  2339. }
  2340. if ( innermostIntersecting ) {
  2341. // If it intersects, we use a little isOver variable and set it once,
  2342. // so that the move-in stuff gets fired only once.
  2343. if ( !sortable.isOver ) {
  2344. sortable.isOver = 1;
  2345. // Store draggable's parent in case we need to reappend to it later.
  2346. draggable._parent = ui.helper.parent();
  2347. sortable.currentItem = ui.helper
  2348. .appendTo( sortable.element )
  2349. .data( "ui-sortable-item", true );
  2350. // Store helper option to later restore it
  2351. sortable.options._helper = sortable.options.helper;
  2352. sortable.options.helper = function() {
  2353. return ui.helper[ 0 ];
  2354. };
  2355. // Fire the start events of the sortable with our passed browser event,
  2356. // and our own helper (so it doesn't create a new one)
  2357. event.target = sortable.currentItem[ 0 ];
  2358. sortable._mouseCapture( event, true );
  2359. sortable._mouseStart( event, true, true );
  2360. // Because the browser event is way off the new appended portlet,
  2361. // modify necessary variables to reflect the changes
  2362. sortable.offset.click.top = draggable.offset.click.top;
  2363. sortable.offset.click.left = draggable.offset.click.left;
  2364. sortable.offset.parent.left -= draggable.offset.parent.left -
  2365. sortable.offset.parent.left;
  2366. sortable.offset.parent.top -= draggable.offset.parent.top -
  2367. sortable.offset.parent.top;
  2368. draggable._trigger( "toSortable", event );
  2369. // Inform draggable that the helper is in a valid drop zone,
  2370. // used solely in the revert option to handle "valid/invalid".
  2371. draggable.dropped = sortable.element;
  2372. // Need to refreshPositions of all sortables in the case that
  2373. // adding to one sortable changes the location of the other sortables (#9675)
  2374. $.each( draggable.sortables, function() {
  2375. this.refreshPositions();
  2376. } );
  2377. // Hack so receive/update callbacks work (mostly)
  2378. draggable.currentItem = draggable.element;
  2379. sortable.fromOutside = draggable;
  2380. }
  2381. if ( sortable.currentItem ) {
  2382. sortable._mouseDrag( event );
  2383. // Copy the sortable's position because the draggable's can potentially reflect
  2384. // a relative position, while sortable is always absolute, which the dragged
  2385. // element has now become. (#8809)
  2386. ui.position = sortable.position;
  2387. }
  2388. } else {
  2389. // If it doesn't intersect with the sortable, and it intersected before,
  2390. // we fake the drag stop of the sortable, but make sure it doesn't remove
  2391. // the helper by using cancelHelperRemoval.
  2392. if ( sortable.isOver ) {
  2393. sortable.isOver = 0;
  2394. sortable.cancelHelperRemoval = true;
  2395. // Calling sortable's mouseStop would trigger a revert,
  2396. // so revert must be temporarily false until after mouseStop is called.
  2397. sortable.options._revert = sortable.options.revert;
  2398. sortable.options.revert = false;
  2399. sortable._trigger( "out", event, sortable._uiHash( sortable ) );
  2400. sortable._mouseStop( event, true );
  2401. // Restore sortable behaviors that were modfied
  2402. // when the draggable entered the sortable area (#9481)
  2403. sortable.options.revert = sortable.options._revert;
  2404. sortable.options.helper = sortable.options._helper;
  2405. if ( sortable.placeholder ) {
  2406. sortable.placeholder.remove();
  2407. }
  2408. // Restore and recalculate the draggable's offset considering the sortable
  2409. // may have modified them in unexpected ways. (#8809, #10669)
  2410. ui.helper.appendTo( draggable._parent );
  2411. draggable._refreshOffsets( event );
  2412. ui.position = draggable._generatePosition( event, true );
  2413. draggable._trigger( "fromSortable", event );
  2414. // Inform draggable that the helper is no longer in a valid drop zone
  2415. draggable.dropped = false;
  2416. // Need to refreshPositions of all sortables just in case removing
  2417. // from one sortable changes the location of other sortables (#9675)
  2418. $.each( draggable.sortables, function() {
  2419. this.refreshPositions();
  2420. } );
  2421. }
  2422. }
  2423. } );
  2424. }
  2425. } );
  2426. $.ui.plugin.add( "draggable", "cursor", {
  2427. start: function( event, ui, instance ) {
  2428. var t = $( "body" ),
  2429. o = instance.options;
  2430. if ( t.css( "cursor" ) ) {
  2431. o._cursor = t.css( "cursor" );
  2432. }
  2433. t.css( "cursor", o.cursor );
  2434. },
  2435. stop: function( event, ui, instance ) {
  2436. var o = instance.options;
  2437. if ( o._cursor ) {
  2438. $( "body" ).css( "cursor", o._cursor );
  2439. }
  2440. }
  2441. } );
  2442. $.ui.plugin.add( "draggable", "opacity", {
  2443. start: function( event, ui, instance ) {
  2444. var t = $( ui.helper ),
  2445. o = instance.options;
  2446. if ( t.css( "opacity" ) ) {
  2447. o._opacity = t.css( "opacity" );
  2448. }
  2449. t.css( "opacity", o.opacity );
  2450. },
  2451. stop: function( event, ui, instance ) {
  2452. var o = instance.options;
  2453. if ( o._opacity ) {
  2454. $( ui.helper ).css( "opacity", o._opacity );
  2455. }
  2456. }
  2457. } );
  2458. $.ui.plugin.add( "draggable", "scroll", {
  2459. start: function( event, ui, i ) {
  2460. if ( !i.scrollParentNotHidden ) {
  2461. i.scrollParentNotHidden = i.helper.scrollParent( false );
  2462. }
  2463. if ( i.scrollParentNotHidden[ 0 ] !== i.document[ 0 ] &&
  2464. i.scrollParentNotHidden[ 0 ].tagName !== "HTML" ) {
  2465. i.overflowOffset = i.scrollParentNotHidden.offset();
  2466. }
  2467. },
  2468. drag: function( event, ui, i ) {
  2469. var o = i.options,
  2470. scrolled = false,
  2471. scrollParent = i.scrollParentNotHidden[ 0 ],
  2472. document = i.document[ 0 ];
  2473. if ( scrollParent !== document && scrollParent.tagName !== "HTML" ) {
  2474. if ( !o.axis || o.axis !== "x" ) {
  2475. if ( ( i.overflowOffset.top + scrollParent.offsetHeight ) - event.pageY <
  2476. o.scrollSensitivity ) {
  2477. scrollParent.scrollTop = scrolled = scrollParent.scrollTop + o.scrollSpeed;
  2478. } else if ( event.pageY - i.overflowOffset.top < o.scrollSensitivity ) {
  2479. scrollParent.scrollTop = scrolled = scrollParent.scrollTop - o.scrollSpeed;
  2480. }
  2481. }
  2482. if ( !o.axis || o.axis !== "y" ) {
  2483. if ( ( i.overflowOffset.left + scrollParent.offsetWidth ) - event.pageX <
  2484. o.scrollSensitivity ) {
  2485. scrollParent.scrollLeft = scrolled = scrollParent.scrollLeft + o.scrollSpeed;
  2486. } else if ( event.pageX - i.overflowOffset.left < o.scrollSensitivity ) {
  2487. scrollParent.scrollLeft = scrolled = scrollParent.scrollLeft - o.scrollSpeed;
  2488. }
  2489. }
  2490. } else {
  2491. if ( !o.axis || o.axis !== "x" ) {
  2492. if ( event.pageY - $( document ).scrollTop() < o.scrollSensitivity ) {
  2493. scrolled = $( document ).scrollTop( $( document ).scrollTop() - o.scrollSpeed );
  2494. } else if ( $( window ).height() - ( event.pageY - $( document ).scrollTop() ) <
  2495. o.scrollSensitivity ) {
  2496. scrolled = $( document ).scrollTop( $( document ).scrollTop() + o.scrollSpeed );
  2497. }
  2498. }
  2499. if ( !o.axis || o.axis !== "y" ) {
  2500. if ( event.pageX - $( document ).scrollLeft() < o.scrollSensitivity ) {
  2501. scrolled = $( document ).scrollLeft(
  2502. $( document ).scrollLeft() - o.scrollSpeed
  2503. );
  2504. } else if ( $( window ).width() - ( event.pageX - $( document ).scrollLeft() ) <
  2505. o.scrollSensitivity ) {
  2506. scrolled = $( document ).scrollLeft(
  2507. $( document ).scrollLeft() + o.scrollSpeed
  2508. );
  2509. }
  2510. }
  2511. }
  2512. if ( scrolled !== false && $.ui.ddmanager && !o.dropBehaviour ) {
  2513. $.ui.ddmanager.prepareOffsets( i, event );
  2514. }
  2515. }
  2516. } );
  2517. $.ui.plugin.add( "draggable", "snap", {
  2518. start: function( event, ui, i ) {
  2519. var o = i.options;
  2520. i.snapElements = [];
  2521. $( o.snap.constructor !== String ? ( o.snap.items || ":data(ui-draggable)" ) : o.snap )
  2522. .each( function() {
  2523. var $t = $( this ),
  2524. $o = $t.offset();
  2525. if ( this !== i.element[ 0 ] ) {
  2526. i.snapElements.push( {
  2527. item: this,
  2528. width: $t.outerWidth(), height: $t.outerHeight(),
  2529. top: $o.top, left: $o.left
  2530. } );
  2531. }
  2532. } );
  2533. },
  2534. drag: function( event, ui, inst ) {
  2535. var ts, bs, ls, rs, l, r, t, b, i, first,
  2536. o = inst.options,
  2537. d = o.snapTolerance,
  2538. x1 = ui.offset.left, x2 = x1 + inst.helperProportions.width,
  2539. y1 = ui.offset.top, y2 = y1 + inst.helperProportions.height;
  2540. for ( i = inst.snapElements.length - 1; i >= 0; i-- ) {
  2541. l = inst.snapElements[ i ].left - inst.margins.left;
  2542. r = l + inst.snapElements[ i ].width;
  2543. t = inst.snapElements[ i ].top - inst.margins.top;
  2544. b = t + inst.snapElements[ i ].height;
  2545. if ( x2 < l - d || x1 > r + d || y2 < t - d || y1 > b + d ||
  2546. !$.contains( inst.snapElements[ i ].item.ownerDocument,
  2547. inst.snapElements[ i ].item ) ) {
  2548. if ( inst.snapElements[ i ].snapping ) {
  2549. ( inst.options.snap.release &&
  2550. inst.options.snap.release.call(
  2551. inst.element,
  2552. event,
  2553. $.extend( inst._uiHash(), { snapItem: inst.snapElements[ i ].item } )
  2554. ) );
  2555. }
  2556. inst.snapElements[ i ].snapping = false;
  2557. continue;
  2558. }
  2559. if ( o.snapMode !== "inner" ) {
  2560. ts = Math.abs( t - y2 ) <= d;
  2561. bs = Math.abs( b - y1 ) <= d;
  2562. ls = Math.abs( l - x2 ) <= d;
  2563. rs = Math.abs( r - x1 ) <= d;
  2564. if ( ts ) {
  2565. ui.position.top = inst._convertPositionTo( "relative", {
  2566. top: t - inst.helperProportions.height,
  2567. left: 0
  2568. } ).top;
  2569. }
  2570. if ( bs ) {
  2571. ui.position.top = inst._convertPositionTo( "relative", {
  2572. top: b,
  2573. left: 0
  2574. } ).top;
  2575. }
  2576. if ( ls ) {
  2577. ui.position.left = inst._convertPositionTo( "relative", {
  2578. top: 0,
  2579. left: l - inst.helperProportions.width
  2580. } ).left;
  2581. }
  2582. if ( rs ) {
  2583. ui.position.left = inst._convertPositionTo( "relative", {
  2584. top: 0,
  2585. left: r
  2586. } ).left;
  2587. }
  2588. }
  2589. first = ( ts || bs || ls || rs );
  2590. if ( o.snapMode !== "outer" ) {
  2591. ts = Math.abs( t - y1 ) <= d;
  2592. bs = Math.abs( b - y2 ) <= d;
  2593. ls = Math.abs( l - x1 ) <= d;
  2594. rs = Math.abs( r - x2 ) <= d;
  2595. if ( ts ) {
  2596. ui.position.top = inst._convertPositionTo( "relative", {
  2597. top: t,
  2598. left: 0
  2599. } ).top;
  2600. }
  2601. if ( bs ) {
  2602. ui.position.top = inst._convertPositionTo( "relative", {
  2603. top: b - inst.helperProportions.height,
  2604. left: 0
  2605. } ).top;
  2606. }
  2607. if ( ls ) {
  2608. ui.position.left = inst._convertPositionTo( "relative", {
  2609. top: 0,
  2610. left: l
  2611. } ).left;
  2612. }
  2613. if ( rs ) {
  2614. ui.position.left = inst._convertPositionTo( "relative", {
  2615. top: 0,
  2616. left: r - inst.helperProportions.width
  2617. } ).left;
  2618. }
  2619. }
  2620. if ( !inst.snapElements[ i ].snapping && ( ts || bs || ls || rs || first ) ) {
  2621. ( inst.options.snap.snap &&
  2622. inst.options.snap.snap.call(
  2623. inst.element,
  2624. event,
  2625. $.extend( inst._uiHash(), {
  2626. snapItem: inst.snapElements[ i ].item
  2627. } ) ) );
  2628. }
  2629. inst.snapElements[ i ].snapping = ( ts || bs || ls || rs || first );
  2630. }
  2631. }
  2632. } );
  2633. $.ui.plugin.add( "draggable", "stack", {
  2634. start: function( event, ui, instance ) {
  2635. var min,
  2636. o = instance.options,
  2637. group = $.makeArray( $( o.stack ) ).sort( function( a, b ) {
  2638. return ( parseInt( $( a ).css( "zIndex" ), 10 ) || 0 ) -
  2639. ( parseInt( $( b ).css( "zIndex" ), 10 ) || 0 );
  2640. } );
  2641. if ( !group.length ) { return; }
  2642. min = parseInt( $( group[ 0 ] ).css( "zIndex" ), 10 ) || 0;
  2643. $( group ).each( function( i ) {
  2644. $( this ).css( "zIndex", min + i );
  2645. } );
  2646. this.css( "zIndex", ( min + group.length ) );
  2647. }
  2648. } );
  2649. $.ui.plugin.add( "draggable", "zIndex", {
  2650. start: function( event, ui, instance ) {
  2651. var t = $( ui.helper ),
  2652. o = instance.options;
  2653. if ( t.css( "zIndex" ) ) {
  2654. o._zIndex = t.css( "zIndex" );
  2655. }
  2656. t.css( "zIndex", o.zIndex );
  2657. },
  2658. stop: function( event, ui, instance ) {
  2659. var o = instance.options;
  2660. if ( o._zIndex ) {
  2661. $( ui.helper ).css( "zIndex", o._zIndex );
  2662. }
  2663. }
  2664. } );
  2665. var widgetsDraggable = $.ui.draggable;
  2666. /*!
  2667. * jQuery UI Droppable 1.12.1
  2668. * http://jqueryui.com
  2669. *
  2670. * Copyright jQuery Foundation and other contributors
  2671. * Released under the MIT license.
  2672. * http://jquery.org/license
  2673. */
  2674. //>>label: Droppable
  2675. //>>group: Interactions
  2676. //>>description: Enables drop targets for draggable elements.
  2677. //>>docs: http://api.jqueryui.com/droppable/
  2678. //>>demos: http://jqueryui.com/droppable/
  2679. $.widget( "ui.droppable", {
  2680. version: "1.12.1",
  2681. widgetEventPrefix: "drop",
  2682. options: {
  2683. accept: "*",
  2684. addClasses: true,
  2685. greedy: false,
  2686. scope: "default",
  2687. tolerance: "intersect",
  2688. // Callbacks
  2689. activate: null,
  2690. deactivate: null,
  2691. drop: null,
  2692. out: null,
  2693. over: null
  2694. },
  2695. _create: function() {
  2696. var proportions,
  2697. o = this.options,
  2698. accept = o.accept;
  2699. this.isover = false;
  2700. this.isout = true;
  2701. this.accept = $.isFunction( accept ) ? accept : function( d ) {
  2702. return d.is( accept );
  2703. };
  2704. this.proportions = function( /* valueToWrite */ ) {
  2705. if ( arguments.length ) {
  2706. // Store the droppable's proportions
  2707. proportions = arguments[ 0 ];
  2708. } else {
  2709. // Retrieve or derive the droppable's proportions
  2710. return proportions ?
  2711. proportions :
  2712. proportions = {
  2713. width: this.element[ 0 ].offsetWidth,
  2714. height: this.element[ 0 ].offsetHeight
  2715. };
  2716. }
  2717. };
  2718. this._addToManager( o.scope );
  2719. o.addClasses && this._addClass( "ui-droppable" );
  2720. },
  2721. _addToManager: function( scope ) {
  2722. // Add the reference and positions to the manager
  2723. $.ui.ddmanager.droppables[ scope ] = $.ui.ddmanager.droppables[ scope ] || [];
  2724. $.ui.ddmanager.droppables[ scope ].push( this );
  2725. },
  2726. _splice: function( drop ) {
  2727. var i = 0;
  2728. for ( ; i < drop.length; i++ ) {
  2729. if ( drop[ i ] === this ) {
  2730. drop.splice( i, 1 );
  2731. }
  2732. }
  2733. },
  2734. _destroy: function() {
  2735. var drop = $.ui.ddmanager.droppables[ this.options.scope ];
  2736. this._splice( drop );
  2737. },
  2738. _setOption: function( key, value ) {
  2739. if ( key === "accept" ) {
  2740. this.accept = $.isFunction( value ) ? value : function( d ) {
  2741. return d.is( value );
  2742. };
  2743. } else if ( key === "scope" ) {
  2744. var drop = $.ui.ddmanager.droppables[ this.options.scope ];
  2745. this._splice( drop );
  2746. this._addToManager( value );
  2747. }
  2748. this._super( key, value );
  2749. },
  2750. _activate: function( event ) {
  2751. var draggable = $.ui.ddmanager.current;
  2752. this._addActiveClass();
  2753. if ( draggable ) {
  2754. this._trigger( "activate", event, this.ui( draggable ) );
  2755. }
  2756. },
  2757. _deactivate: function( event ) {
  2758. var draggable = $.ui.ddmanager.current;
  2759. this._removeActiveClass();
  2760. if ( draggable ) {
  2761. this._trigger( "deactivate", event, this.ui( draggable ) );
  2762. }
  2763. },
  2764. _over: function( event ) {
  2765. var draggable = $.ui.ddmanager.current;
  2766. // Bail if draggable and droppable are same element
  2767. if ( !draggable || ( draggable.currentItem ||
  2768. draggable.element )[ 0 ] === this.element[ 0 ] ) {
  2769. return;
  2770. }
  2771. if ( this.accept.call( this.element[ 0 ], ( draggable.currentItem ||
  2772. draggable.element ) ) ) {
  2773. this._addHoverClass();
  2774. this._trigger( "over", event, this.ui( draggable ) );
  2775. }
  2776. },
  2777. _out: function( event ) {
  2778. var draggable = $.ui.ddmanager.current;
  2779. // Bail if draggable and droppable are same element
  2780. if ( !draggable || ( draggable.currentItem ||
  2781. draggable.element )[ 0 ] === this.element[ 0 ] ) {
  2782. return;
  2783. }
  2784. if ( this.accept.call( this.element[ 0 ], ( draggable.currentItem ||
  2785. draggable.element ) ) ) {
  2786. this._removeHoverClass();
  2787. this._trigger( "out", event, this.ui( draggable ) );
  2788. }
  2789. },
  2790. _drop: function( event, custom ) {
  2791. var draggable = custom || $.ui.ddmanager.current,
  2792. childrenIntersection = false;
  2793. // Bail if draggable and droppable are same element
  2794. if ( !draggable || ( draggable.currentItem ||
  2795. draggable.element )[ 0 ] === this.element[ 0 ] ) {
  2796. return false;
  2797. }
  2798. this.element
  2799. .find( ":data(ui-droppable)" )
  2800. .not( ".ui-draggable-dragging" )
  2801. .each( function() {
  2802. var inst = $( this ).droppable( "instance" );
  2803. if (
  2804. inst.options.greedy &&
  2805. !inst.options.disabled &&
  2806. inst.options.scope === draggable.options.scope &&
  2807. inst.accept.call(
  2808. inst.element[ 0 ], ( draggable.currentItem || draggable.element )
  2809. ) &&
  2810. intersect(
  2811. draggable,
  2812. $.extend( inst, { offset: inst.element.offset() } ),
  2813. inst.options.tolerance, event
  2814. )
  2815. ) {
  2816. childrenIntersection = true;
  2817. return false; }
  2818. } );
  2819. if ( childrenIntersection ) {
  2820. return false;
  2821. }
  2822. if ( this.accept.call( this.element[ 0 ],
  2823. ( draggable.currentItem || draggable.element ) ) ) {
  2824. this._removeActiveClass();
  2825. this._removeHoverClass();
  2826. this._trigger( "drop", event, this.ui( draggable ) );
  2827. return this.element;
  2828. }
  2829. return false;
  2830. },
  2831. ui: function( c ) {
  2832. return {
  2833. draggable: ( c.currentItem || c.element ),
  2834. helper: c.helper,
  2835. position: c.position,
  2836. offset: c.positionAbs
  2837. };
  2838. },
  2839. // Extension points just to make backcompat sane and avoid duplicating logic
  2840. // TODO: Remove in 1.13 along with call to it below
  2841. _addHoverClass: function() {
  2842. this._addClass( "ui-droppable-hover" );
  2843. },
  2844. _removeHoverClass: function() {
  2845. this._removeClass( "ui-droppable-hover" );
  2846. },
  2847. _addActiveClass: function() {
  2848. this._addClass( "ui-droppable-active" );
  2849. },
  2850. _removeActiveClass: function() {
  2851. this._removeClass( "ui-droppable-active" );
  2852. }
  2853. } );
  2854. var intersect = $.ui.intersect = ( function() {
  2855. function isOverAxis( x, reference, size ) {
  2856. return ( x >= reference ) && ( x < ( reference + size ) );
  2857. }
  2858. return function( draggable, droppable, toleranceMode, event ) {
  2859. if ( !droppable.offset ) {
  2860. return false;
  2861. }
  2862. var x1 = ( draggable.positionAbs ||
  2863. draggable.position.absolute ).left + draggable.margins.left,
  2864. y1 = ( draggable.positionAbs ||
  2865. draggable.position.absolute ).top + draggable.margins.top,
  2866. x2 = x1 + draggable.helperProportions.width,
  2867. y2 = y1 + draggable.helperProportions.height,
  2868. l = droppable.offset.left,
  2869. t = droppable.offset.top,
  2870. r = l + droppable.proportions().width,
  2871. b = t + droppable.proportions().height;
  2872. switch ( toleranceMode ) {
  2873. case "fit":
  2874. return ( l <= x1 && x2 <= r && t <= y1 && y2 <= b );
  2875. case "intersect":
  2876. return ( l < x1 + ( draggable.helperProportions.width / 2 ) && // Right Half
  2877. x2 - ( draggable.helperProportions.width / 2 ) < r && // Left Half
  2878. t < y1 + ( draggable.helperProportions.height / 2 ) && // Bottom Half
  2879. y2 - ( draggable.helperProportions.height / 2 ) < b ); // Top Half
  2880. case "pointer":
  2881. return isOverAxis( event.pageY, t, droppable.proportions().height ) &&
  2882. isOverAxis( event.pageX, l, droppable.proportions().width );
  2883. case "touch":
  2884. return (
  2885. ( y1 >= t && y1 <= b ) || // Top edge touching
  2886. ( y2 >= t && y2 <= b ) || // Bottom edge touching
  2887. ( y1 < t && y2 > b ) // Surrounded vertically
  2888. ) && (
  2889. ( x1 >= l && x1 <= r ) || // Left edge touching
  2890. ( x2 >= l && x2 <= r ) || // Right edge touching
  2891. ( x1 < l && x2 > r ) // Surrounded horizontally
  2892. );
  2893. default:
  2894. return false;
  2895. }
  2896. };
  2897. } )();
  2898. /*
  2899. This manager tracks offsets of draggables and droppables
  2900. */
  2901. $.ui.ddmanager = {
  2902. current: null,
  2903. droppables: { "default": [] },
  2904. prepareOffsets: function( t, event ) {
  2905. var i, j,
  2906. m = $.ui.ddmanager.droppables[ t.options.scope ] || [],
  2907. type = event ? event.type : null, // workaround for #2317
  2908. list = ( t.currentItem || t.element ).find( ":data(ui-droppable)" ).addBack();
  2909. droppablesLoop: for ( i = 0; i < m.length; i++ ) {
  2910. // No disabled and non-accepted
  2911. if ( m[ i ].options.disabled || ( t && !m[ i ].accept.call( m[ i ].element[ 0 ],
  2912. ( t.currentItem || t.element ) ) ) ) {
  2913. continue;
  2914. }
  2915. // Filter out elements in the current dragged item
  2916. for ( j = 0; j < list.length; j++ ) {
  2917. if ( list[ j ] === m[ i ].element[ 0 ] ) {
  2918. m[ i ].proportions().height = 0;
  2919. continue droppablesLoop;
  2920. }
  2921. }
  2922. m[ i ].visible = m[ i ].element.css( "display" ) !== "none";
  2923. if ( !m[ i ].visible ) {
  2924. continue;
  2925. }
  2926. // Activate the droppable if used directly from draggables
  2927. if ( type === "mousedown" ) {
  2928. m[ i ]._activate.call( m[ i ], event );
  2929. }
  2930. m[ i ].offset = m[ i ].element.offset();
  2931. m[ i ].proportions( {
  2932. width: m[ i ].element[ 0 ].offsetWidth,
  2933. height: m[ i ].element[ 0 ].offsetHeight
  2934. } );
  2935. }
  2936. },
  2937. drop: function( draggable, event ) {
  2938. var dropped = false;
  2939. // Create a copy of the droppables in case the list changes during the drop (#9116)
  2940. $.each( ( $.ui.ddmanager.droppables[ draggable.options.scope ] || [] ).slice(), function() {
  2941. if ( !this.options ) {
  2942. return;
  2943. }
  2944. if ( !this.options.disabled && this.visible &&
  2945. intersect( draggable, this, this.options.tolerance, event ) ) {
  2946. dropped = this._drop.call( this, event ) || dropped;
  2947. }
  2948. if ( !this.options.disabled && this.visible && this.accept.call( this.element[ 0 ],
  2949. ( draggable.currentItem || draggable.element ) ) ) {
  2950. this.isout = true;
  2951. this.isover = false;
  2952. this._deactivate.call( this, event );
  2953. }
  2954. } );
  2955. return dropped;
  2956. },
  2957. dragStart: function( draggable, event ) {
  2958. // Listen for scrolling so that if the dragging causes scrolling the position of the
  2959. // droppables can be recalculated (see #5003)
  2960. draggable.element.parentsUntil( "body" ).on( "scroll.droppable", function() {
  2961. if ( !draggable.options.refreshPositions ) {
  2962. $.ui.ddmanager.prepareOffsets( draggable, event );
  2963. }
  2964. } );
  2965. },
  2966. drag: function( draggable, event ) {
  2967. // If you have a highly dynamic page, you might try this option. It renders positions
  2968. // every time you move the mouse.
  2969. if ( draggable.options.refreshPositions ) {
  2970. $.ui.ddmanager.prepareOffsets( draggable, event );
  2971. }
  2972. // Run through all droppables and check their positions based on specific tolerance options
  2973. $.each( $.ui.ddmanager.droppables[ draggable.options.scope ] || [], function() {
  2974. if ( this.options.disabled || this.greedyChild || !this.visible ) {
  2975. return;
  2976. }
  2977. var parentInstance, scope, parent,
  2978. intersects = intersect( draggable, this, this.options.tolerance, event ),
  2979. c = !intersects && this.isover ?
  2980. "isout" :
  2981. ( intersects && !this.isover ? "isover" : null );
  2982. if ( !c ) {
  2983. return;
  2984. }
  2985. if ( this.options.greedy ) {
  2986. // find droppable parents with same scope
  2987. scope = this.options.scope;
  2988. parent = this.element.parents( ":data(ui-droppable)" ).filter( function() {
  2989. return $( this ).droppable( "instance" ).options.scope === scope;
  2990. } );
  2991. if ( parent.length ) {
  2992. parentInstance = $( parent[ 0 ] ).droppable( "instance" );
  2993. parentInstance.greedyChild = ( c === "isover" );
  2994. }
  2995. }
  2996. // We just moved into a greedy child
  2997. if ( parentInstance && c === "isover" ) {
  2998. parentInstance.isover = false;
  2999. parentInstance.isout = true;
  3000. parentInstance._out.call( parentInstance, event );
  3001. }
  3002. this[ c ] = true;
  3003. this[ c === "isout" ? "isover" : "isout" ] = false;
  3004. this[ c === "isover" ? "_over" : "_out" ].call( this, event );
  3005. // We just moved out of a greedy child
  3006. if ( parentInstance && c === "isout" ) {
  3007. parentInstance.isout = false;
  3008. parentInstance.isover = true;
  3009. parentInstance._over.call( parentInstance, event );
  3010. }
  3011. } );
  3012. },
  3013. dragStop: function( draggable, event ) {
  3014. draggable.element.parentsUntil( "body" ).off( "scroll.droppable" );
  3015. // Call prepareOffsets one final time since IE does not fire return scroll events when
  3016. // overflow was caused by drag (see #5003)
  3017. if ( !draggable.options.refreshPositions ) {
  3018. $.ui.ddmanager.prepareOffsets( draggable, event );
  3019. }
  3020. }
  3021. };
  3022. // DEPRECATED
  3023. // TODO: switch return back to widget declaration at top of file when this is removed
  3024. if ( $.uiBackCompat !== false ) {
  3025. // Backcompat for activeClass and hoverClass options
  3026. $.widget( "ui.droppable", $.ui.droppable, {
  3027. options: {
  3028. hoverClass: false,
  3029. activeClass: false
  3030. },
  3031. _addActiveClass: function() {
  3032. this._super();
  3033. if ( this.options.activeClass ) {
  3034. this.element.addClass( this.options.activeClass );
  3035. }
  3036. },
  3037. _removeActiveClass: function() {
  3038. this._super();
  3039. if ( this.options.activeClass ) {
  3040. this.element.removeClass( this.options.activeClass );
  3041. }
  3042. },
  3043. _addHoverClass: function() {
  3044. this._super();
  3045. if ( this.options.hoverClass ) {
  3046. this.element.addClass( this.options.hoverClass );
  3047. }
  3048. },
  3049. _removeHoverClass: function() {
  3050. this._super();
  3051. if ( this.options.hoverClass ) {
  3052. this.element.removeClass( this.options.hoverClass );
  3053. }
  3054. }
  3055. } );
  3056. }
  3057. var widgetsDroppable = $.ui.droppable;
  3058. /*!
  3059. * jQuery UI Resizable 1.12.1
  3060. * http://jqueryui.com
  3061. *
  3062. * Copyright jQuery Foundation and other contributors
  3063. * Released under the MIT license.
  3064. * http://jquery.org/license
  3065. */
  3066. //>>label: Resizable
  3067. //>>group: Interactions
  3068. //>>description: Enables resize functionality for any element.
  3069. //>>docs: http://api.jqueryui.com/resizable/
  3070. //>>demos: http://jqueryui.com/resizable/
  3071. //>>css.structure: ../../themes/base/core.css
  3072. //>>css.structure: ../../themes/base/resizable.css
  3073. //>>css.theme: ../../themes/base/theme.css
  3074. $.widget( "ui.resizable", $.ui.mouse, {
  3075. version: "1.12.1",
  3076. widgetEventPrefix: "resize",
  3077. options: {
  3078. alsoResize: false,
  3079. animate: false,
  3080. animateDuration: "slow",
  3081. animateEasing: "swing",
  3082. aspectRatio: false,
  3083. autoHide: false,
  3084. classes: {
  3085. "ui-resizable-se": "ui-icon ui-icon-gripsmall-diagonal-se"
  3086. },
  3087. containment: false,
  3088. ghost: false,
  3089. grid: false,
  3090. handles: "e,s,se",
  3091. helper: false,
  3092. maxHeight: null,
  3093. maxWidth: null,
  3094. minHeight: 10,
  3095. minWidth: 10,
  3096. // See #7960
  3097. zIndex: 90,
  3098. // Callbacks
  3099. resize: null,
  3100. start: null,
  3101. stop: null
  3102. },
  3103. _num: function( value ) {
  3104. return parseFloat( value ) || 0;
  3105. },
  3106. _isNumber: function( value ) {
  3107. return !isNaN( parseFloat( value ) );
  3108. },
  3109. _hasScroll: function( el, a ) {
  3110. if ( $( el ).css( "overflow" ) === "hidden" ) {
  3111. return false;
  3112. }
  3113. var scroll = ( a && a === "left" ) ? "scrollLeft" : "scrollTop",
  3114. has = false;
  3115. if ( el[ scroll ] > 0 ) {
  3116. return true;
  3117. }
  3118. // TODO: determine which cases actually cause this to happen
  3119. // if the element doesn't have the scroll set, see if it's possible to
  3120. // set the scroll
  3121. el[ scroll ] = 1;
  3122. has = ( el[ scroll ] > 0 );
  3123. el[ scroll ] = 0;
  3124. return has;
  3125. },
  3126. _create: function() {
  3127. var margins,
  3128. o = this.options,
  3129. that = this;
  3130. this._addClass( "ui-resizable" );
  3131. $.extend( this, {
  3132. _aspectRatio: !!( o.aspectRatio ),
  3133. aspectRatio: o.aspectRatio,
  3134. originalElement: this.element,
  3135. _proportionallyResizeElements: [],
  3136. _helper: o.helper || o.ghost || o.animate ? o.helper || "ui-resizable-helper" : null
  3137. } );
  3138. // Wrap the element if it cannot hold child nodes
  3139. if ( this.element[ 0 ].nodeName.match( /^(canvas|textarea|input|select|button|img)$/i ) ) {
  3140. this.element.wrap(
  3141. $( "<div class='ui-wrapper' style='overflow: hidden;'></div>" ).css( {
  3142. position: this.element.css( "position" ),
  3143. width: this.element.outerWidth(),
  3144. height: this.element.outerHeight(),
  3145. top: this.element.css( "top" ),
  3146. left: this.element.css( "left" )
  3147. } )
  3148. );
  3149. this.element = this.element.parent().data(
  3150. "ui-resizable", this.element.resizable( "instance" )
  3151. );
  3152. this.elementIsWrapper = true;
  3153. margins = {
  3154. marginTop: this.originalElement.css( "marginTop" ),
  3155. marginRight: this.originalElement.css( "marginRight" ),
  3156. marginBottom: this.originalElement.css( "marginBottom" ),
  3157. marginLeft: this.originalElement.css( "marginLeft" )
  3158. };
  3159. this.element.css( margins );
  3160. this.originalElement.css( "margin", 0 );
  3161. // support: Safari
  3162. // Prevent Safari textarea resize
  3163. this.originalResizeStyle = this.originalElement.css( "resize" );
  3164. this.originalElement.css( "resize", "none" );
  3165. this._proportionallyResizeElements.push( this.originalElement.css( {
  3166. position: "static",
  3167. zoom: 1,
  3168. display: "block"
  3169. } ) );
  3170. // Support: IE9
  3171. // avoid IE jump (hard set the margin)
  3172. this.originalElement.css( margins );
  3173. this._proportionallyResize();
  3174. }
  3175. this._setupHandles();
  3176. if ( o.autoHide ) {
  3177. $( this.element )
  3178. .on( "mouseenter", function() {
  3179. if ( o.disabled ) {
  3180. return;
  3181. }
  3182. that._removeClass( "ui-resizable-autohide" );
  3183. that._handles.show();
  3184. } )
  3185. .on( "mouseleave", function() {
  3186. if ( o.disabled ) {
  3187. return;
  3188. }
  3189. if ( !that.resizing ) {
  3190. that._addClass( "ui-resizable-autohide" );
  3191. that._handles.hide();
  3192. }
  3193. } );
  3194. }
  3195. this._mouseInit();
  3196. },
  3197. _destroy: function() {
  3198. this._mouseDestroy();
  3199. var wrapper,
  3200. _destroy = function( exp ) {
  3201. $( exp )
  3202. .removeData( "resizable" )
  3203. .removeData( "ui-resizable" )
  3204. .off( ".resizable" )
  3205. .find( ".ui-resizable-handle" )
  3206. .remove();
  3207. };
  3208. // TODO: Unwrap at same DOM position
  3209. if ( this.elementIsWrapper ) {
  3210. _destroy( this.element );
  3211. wrapper = this.element;
  3212. this.originalElement.css( {
  3213. position: wrapper.css( "position" ),
  3214. width: wrapper.outerWidth(),
  3215. height: wrapper.outerHeight(),
  3216. top: wrapper.css( "top" ),
  3217. left: wrapper.css( "left" )
  3218. } ).insertAfter( wrapper );
  3219. wrapper.remove();
  3220. }
  3221. this.originalElement.css( "resize", this.originalResizeStyle );
  3222. _destroy( this.originalElement );
  3223. return this;
  3224. },
  3225. _setOption: function( key, value ) {
  3226. this._super( key, value );
  3227. switch ( key ) {
  3228. case "handles":
  3229. this._removeHandles();
  3230. this._setupHandles();
  3231. break;
  3232. default:
  3233. break;
  3234. }
  3235. },
  3236. _setupHandles: function() {
  3237. var o = this.options, handle, i, n, hname, axis, that = this;
  3238. this.handles = o.handles ||
  3239. ( !$( ".ui-resizable-handle", this.element ).length ?
  3240. "e,s,se" : {
  3241. n: ".ui-resizable-n",
  3242. e: ".ui-resizable-e",
  3243. s: ".ui-resizable-s",
  3244. w: ".ui-resizable-w",
  3245. se: ".ui-resizable-se",
  3246. sw: ".ui-resizable-sw",
  3247. ne: ".ui-resizable-ne",
  3248. nw: ".ui-resizable-nw"
  3249. } );
  3250. this._handles = $();
  3251. if ( this.handles.constructor === String ) {
  3252. if ( this.handles === "all" ) {
  3253. this.handles = "n,e,s,w,se,sw,ne,nw";
  3254. }
  3255. n = this.handles.split( "," );
  3256. this.handles = {};
  3257. for ( i = 0; i < n.length; i++ ) {
  3258. handle = $.trim( n[ i ] );
  3259. hname = "ui-resizable-" + handle;
  3260. axis = $( "<div>" );
  3261. this._addClass( axis, "ui-resizable-handle " + hname );
  3262. axis.css( { zIndex: o.zIndex } );
  3263. this.handles[ handle ] = ".ui-resizable-" + handle;
  3264. this.element.append( axis );
  3265. }
  3266. }
  3267. this._renderAxis = function( target ) {
  3268. var i, axis, padPos, padWrapper;
  3269. target = target || this.element;
  3270. for ( i in this.handles ) {
  3271. if ( this.handles[ i ].constructor === String ) {
  3272. this.handles[ i ] = this.element.children( this.handles[ i ] ).first().show();
  3273. } else if ( this.handles[ i ].jquery || this.handles[ i ].nodeType ) {
  3274. this.handles[ i ] = $( this.handles[ i ] );
  3275. this._on( this.handles[ i ], { "mousedown": that._mouseDown } );
  3276. }
  3277. if ( this.elementIsWrapper &&
  3278. this.originalElement[ 0 ]
  3279. .nodeName
  3280. .match( /^(textarea|input|select|button)$/i ) ) {
  3281. axis = $( this.handles[ i ], this.element );
  3282. padWrapper = /sw|ne|nw|se|n|s/.test( i ) ?
  3283. axis.outerHeight() :
  3284. axis.outerWidth();
  3285. padPos = [ "padding",
  3286. /ne|nw|n/.test( i ) ? "Top" :
  3287. /se|sw|s/.test( i ) ? "Bottom" :
  3288. /^e$/.test( i ) ? "Right" : "Left" ].join( "" );
  3289. target.css( padPos, padWrapper );
  3290. this._proportionallyResize();
  3291. }
  3292. this._handles = this._handles.add( this.handles[ i ] );
  3293. }
  3294. };
  3295. // TODO: make renderAxis a prototype function
  3296. this._renderAxis( this.element );
  3297. this._handles = this._handles.add( this.element.find( ".ui-resizable-handle" ) );
  3298. this._handles.disableSelection();
  3299. this._handles.on( "mouseover", function() {
  3300. if ( !that.resizing ) {
  3301. if ( this.className ) {
  3302. axis = this.className.match( /ui-resizable-(se|sw|ne|nw|n|e|s|w)/i );
  3303. }
  3304. that.axis = axis && axis[ 1 ] ? axis[ 1 ] : "se";
  3305. }
  3306. } );
  3307. if ( o.autoHide ) {
  3308. this._handles.hide();
  3309. this._addClass( "ui-resizable-autohide" );
  3310. }
  3311. },
  3312. _removeHandles: function() {
  3313. this._handles.remove();
  3314. },
  3315. _mouseCapture: function( event ) {
  3316. var i, handle,
  3317. capture = false;
  3318. for ( i in this.handles ) {
  3319. handle = $( this.handles[ i ] )[ 0 ];
  3320. if ( handle === event.target || $.contains( handle, event.target ) ) {
  3321. capture = true;
  3322. }
  3323. }
  3324. return !this.options.disabled && capture;
  3325. },
  3326. _mouseStart: function( event ) {
  3327. var curleft, curtop, cursor,
  3328. o = this.options,
  3329. el = this.element;
  3330. this.resizing = true;
  3331. this._renderProxy();
  3332. curleft = this._num( this.helper.css( "left" ) );
  3333. curtop = this._num( this.helper.css( "top" ) );
  3334. if ( o.containment ) {
  3335. curleft += $( o.containment ).scrollLeft() || 0;
  3336. curtop += $( o.containment ).scrollTop() || 0;
  3337. }
  3338. this.offset = this.helper.offset();
  3339. this.position = { left: curleft, top: curtop };
  3340. this.size = this._helper ? {
  3341. width: this.helper.width(),
  3342. height: this.helper.height()
  3343. } : {
  3344. width: el.width(),
  3345. height: el.height()
  3346. };
  3347. this.originalSize = this._helper ? {
  3348. width: el.outerWidth(),
  3349. height: el.outerHeight()
  3350. } : {
  3351. width: el.width(),
  3352. height: el.height()
  3353. };
  3354. this.sizeDiff = {
  3355. width: el.outerWidth() - el.width(),
  3356. height: el.outerHeight() - el.height()
  3357. };
  3358. this.originalPosition = { left: curleft, top: curtop };
  3359. this.originalMousePosition = { left: event.pageX, top: event.pageY };
  3360. this.aspectRatio = ( typeof o.aspectRatio === "number" ) ?
  3361. o.aspectRatio :
  3362. ( ( this.originalSize.width / this.originalSize.height ) || 1 );
  3363. cursor = $( ".ui-resizable-" + this.axis ).css( "cursor" );
  3364. $( "body" ).css( "cursor", cursor === "auto" ? this.axis + "-resize" : cursor );
  3365. this._addClass( "ui-resizable-resizing" );
  3366. this._propagate( "start", event );
  3367. return true;
  3368. },
  3369. _mouseDrag: function( event ) {
  3370. var data, props,
  3371. smp = this.originalMousePosition,
  3372. a = this.axis,
  3373. dx = ( event.pageX - smp.left ) || 0,
  3374. dy = ( event.pageY - smp.top ) || 0,
  3375. trigger = this._change[ a ];
  3376. this._updatePrevProperties();
  3377. if ( !trigger ) {
  3378. return false;
  3379. }
  3380. data = trigger.apply( this, [ event, dx, dy ] );
  3381. this._updateVirtualBoundaries( event.shiftKey );
  3382. if ( this._aspectRatio || event.shiftKey ) {
  3383. data = this._updateRatio( data, event );
  3384. }
  3385. data = this._respectSize( data, event );
  3386. this._updateCache( data );
  3387. this._propagate( "resize", event );
  3388. props = this._applyChanges();
  3389. if ( !this._helper && this._proportionallyResizeElements.length ) {
  3390. this._proportionallyResize();
  3391. }
  3392. if ( !$.isEmptyObject( props ) ) {
  3393. this._updatePrevProperties();
  3394. this._trigger( "resize", event, this.ui() );
  3395. this._applyChanges();
  3396. }
  3397. return false;
  3398. },
  3399. _mouseStop: function( event ) {
  3400. this.resizing = false;
  3401. var pr, ista, soffseth, soffsetw, s, left, top,
  3402. o = this.options, that = this;
  3403. if ( this._helper ) {
  3404. pr = this._proportionallyResizeElements;
  3405. ista = pr.length && ( /textarea/i ).test( pr[ 0 ].nodeName );
  3406. soffseth = ista && this._hasScroll( pr[ 0 ], "left" ) ? 0 : that.sizeDiff.height;
  3407. soffsetw = ista ? 0 : that.sizeDiff.width;
  3408. s = {
  3409. width: ( that.helper.width() - soffsetw ),
  3410. height: ( that.helper.height() - soffseth )
  3411. };
  3412. left = ( parseFloat( that.element.css( "left" ) ) +
  3413. ( that.position.left - that.originalPosition.left ) ) || null;
  3414. top = ( parseFloat( that.element.css( "top" ) ) +
  3415. ( that.position.top - that.originalPosition.top ) ) || null;
  3416. if ( !o.animate ) {
  3417. this.element.css( $.extend( s, { top: top, left: left } ) );
  3418. }
  3419. that.helper.height( that.size.height );
  3420. that.helper.width( that.size.width );
  3421. if ( this._helper && !o.animate ) {
  3422. this._proportionallyResize();
  3423. }
  3424. }
  3425. $( "body" ).css( "cursor", "auto" );
  3426. this._removeClass( "ui-resizable-resizing" );
  3427. this._propagate( "stop", event );
  3428. if ( this._helper ) {
  3429. this.helper.remove();
  3430. }
  3431. return false;
  3432. },
  3433. _updatePrevProperties: function() {
  3434. this.prevPosition = {
  3435. top: this.position.top,
  3436. left: this.position.left
  3437. };
  3438. this.prevSize = {
  3439. width: this.size.width,
  3440. height: this.size.height
  3441. };
  3442. },
  3443. _applyChanges: function() {
  3444. var props = {};
  3445. if ( this.position.top !== this.prevPosition.top ) {
  3446. props.top = this.position.top + "px";
  3447. }
  3448. if ( this.position.left !== this.prevPosition.left ) {
  3449. props.left = this.position.left + "px";
  3450. }
  3451. if ( this.size.width !== this.prevSize.width ) {
  3452. props.width = this.size.width + "px";
  3453. }
  3454. if ( this.size.height !== this.prevSize.height ) {
  3455. props.height = this.size.height + "px";
  3456. }
  3457. this.helper.css( props );
  3458. return props;
  3459. },
  3460. _updateVirtualBoundaries: function( forceAspectRatio ) {
  3461. var pMinWidth, pMaxWidth, pMinHeight, pMaxHeight, b,
  3462. o = this.options;
  3463. b = {
  3464. minWidth: this._isNumber( o.minWidth ) ? o.minWidth : 0,
  3465. maxWidth: this._isNumber( o.maxWidth ) ? o.maxWidth : Infinity,
  3466. minHeight: this._isNumber( o.minHeight ) ? o.minHeight : 0,
  3467. maxHeight: this._isNumber( o.maxHeight ) ? o.maxHeight : Infinity
  3468. };
  3469. if ( this._aspectRatio || forceAspectRatio ) {
  3470. pMinWidth = b.minHeight * this.aspectRatio;
  3471. pMinHeight = b.minWidth / this.aspectRatio;
  3472. pMaxWidth = b.maxHeight * this.aspectRatio;
  3473. pMaxHeight = b.maxWidth / this.aspectRatio;
  3474. if ( pMinWidth > b.minWidth ) {
  3475. b.minWidth = pMinWidth;
  3476. }
  3477. if ( pMinHeight > b.minHeight ) {
  3478. b.minHeight = pMinHeight;
  3479. }
  3480. if ( pMaxWidth < b.maxWidth ) {
  3481. b.maxWidth = pMaxWidth;
  3482. }
  3483. if ( pMaxHeight < b.maxHeight ) {
  3484. b.maxHeight = pMaxHeight;
  3485. }
  3486. }
  3487. this._vBoundaries = b;
  3488. },
  3489. _updateCache: function( data ) {
  3490. this.offset = this.helper.offset();
  3491. if ( this._isNumber( data.left ) ) {
  3492. this.position.left = data.left;
  3493. }
  3494. if ( this._isNumber( data.top ) ) {
  3495. this.position.top = data.top;
  3496. }
  3497. if ( this._isNumber( data.height ) ) {
  3498. this.size.height = data.height;
  3499. }
  3500. if ( this._isNumber( data.width ) ) {
  3501. this.size.width = data.width;
  3502. }
  3503. },
  3504. _updateRatio: function( data ) {
  3505. var cpos = this.position,
  3506. csize = this.size,
  3507. a = this.axis;
  3508. if ( this._isNumber( data.height ) ) {
  3509. data.width = ( data.height * this.aspectRatio );
  3510. } else if ( this._isNumber( data.width ) ) {
  3511. data.height = ( data.width / this.aspectRatio );
  3512. }
  3513. if ( a === "sw" ) {
  3514. data.left = cpos.left + ( csize.width - data.width );
  3515. data.top = null;
  3516. }
  3517. if ( a === "nw" ) {
  3518. data.top = cpos.top + ( csize.height - data.height );
  3519. data.left = cpos.left + ( csize.width - data.width );
  3520. }
  3521. return data;
  3522. },
  3523. _respectSize: function( data ) {
  3524. var o = this._vBoundaries,
  3525. a = this.axis,
  3526. ismaxw = this._isNumber( data.width ) && o.maxWidth && ( o.maxWidth < data.width ),
  3527. ismaxh = this._isNumber( data.height ) && o.maxHeight && ( o.maxHeight < data.height ),
  3528. isminw = this._isNumber( data.width ) && o.minWidth && ( o.minWidth > data.width ),
  3529. isminh = this._isNumber( data.height ) && o.minHeight && ( o.minHeight > data.height ),
  3530. dw = this.originalPosition.left + this.originalSize.width,
  3531. dh = this.originalPosition.top + this.originalSize.height,
  3532. cw = /sw|nw|w/.test( a ), ch = /nw|ne|n/.test( a );
  3533. if ( isminw ) {
  3534. data.width = o.minWidth;
  3535. }
  3536. if ( isminh ) {
  3537. data.height = o.minHeight;
  3538. }
  3539. if ( ismaxw ) {
  3540. data.width = o.maxWidth;
  3541. }
  3542. if ( ismaxh ) {
  3543. data.height = o.maxHeight;
  3544. }
  3545. if ( isminw && cw ) {
  3546. data.left = dw - o.minWidth;
  3547. }
  3548. if ( ismaxw && cw ) {
  3549. data.left = dw - o.maxWidth;
  3550. }
  3551. if ( isminh && ch ) {
  3552. data.top = dh - o.minHeight;
  3553. }
  3554. if ( ismaxh && ch ) {
  3555. data.top = dh - o.maxHeight;
  3556. }
  3557. // Fixing jump error on top/left - bug #2330
  3558. if ( !data.width && !data.height && !data.left && data.top ) {
  3559. data.top = null;
  3560. } else if ( !data.width && !data.height && !data.top && data.left ) {
  3561. data.left = null;
  3562. }
  3563. return data;
  3564. },
  3565. _getPaddingPlusBorderDimensions: function( element ) {
  3566. var i = 0,
  3567. widths = [],
  3568. borders = [
  3569. element.css( "borderTopWidth" ),
  3570. element.css( "borderRightWidth" ),
  3571. element.css( "borderBottomWidth" ),
  3572. element.css( "borderLeftWidth" )
  3573. ],
  3574. paddings = [
  3575. element.css( "paddingTop" ),
  3576. element.css( "paddingRight" ),
  3577. element.css( "paddingBottom" ),
  3578. element.css( "paddingLeft" )
  3579. ];
  3580. for ( ; i < 4; i++ ) {
  3581. widths[ i ] = ( parseFloat( borders[ i ] ) || 0 );
  3582. widths[ i ] += ( parseFloat( paddings[ i ] ) || 0 );
  3583. }
  3584. return {
  3585. height: widths[ 0 ] + widths[ 2 ],
  3586. width: widths[ 1 ] + widths[ 3 ]
  3587. };
  3588. },
  3589. _proportionallyResize: function() {
  3590. if ( !this._proportionallyResizeElements.length ) {
  3591. return;
  3592. }
  3593. var prel,
  3594. i = 0,
  3595. element = this.helper || this.element;
  3596. for ( ; i < this._proportionallyResizeElements.length; i++ ) {
  3597. prel = this._proportionallyResizeElements[ i ];
  3598. // TODO: Seems like a bug to cache this.outerDimensions
  3599. // considering that we are in a loop.
  3600. if ( !this.outerDimensions ) {
  3601. this.outerDimensions = this._getPaddingPlusBorderDimensions( prel );
  3602. }
  3603. prel.css( {
  3604. height: ( element.height() - this.outerDimensions.height ) || 0,
  3605. width: ( element.width() - this.outerDimensions.width ) || 0
  3606. } );
  3607. }
  3608. },
  3609. _renderProxy: function() {
  3610. var el = this.element, o = this.options;
  3611. this.elementOffset = el.offset();
  3612. if ( this._helper ) {
  3613. this.helper = this.helper || $( "<div style='overflow:hidden;'></div>" );
  3614. this._addClass( this.helper, this._helper );
  3615. this.helper.css( {
  3616. width: this.element.outerWidth(),
  3617. height: this.element.outerHeight(),
  3618. position: "absolute",
  3619. left: this.elementOffset.left + "px",
  3620. top: this.elementOffset.top + "px",
  3621. zIndex: ++o.zIndex //TODO: Don't modify option
  3622. } );
  3623. this.helper
  3624. .appendTo( "body" )
  3625. .disableSelection();
  3626. } else {
  3627. this.helper = this.element;
  3628. }
  3629. },
  3630. _change: {
  3631. e: function( event, dx ) {
  3632. return { width: this.originalSize.width + dx };
  3633. },
  3634. w: function( event, dx ) {
  3635. var cs = this.originalSize, sp = this.originalPosition;
  3636. return { left: sp.left + dx, width: cs.width - dx };
  3637. },
  3638. n: function( event, dx, dy ) {
  3639. var cs = this.originalSize, sp = this.originalPosition;
  3640. return { top: sp.top + dy, height: cs.height - dy };
  3641. },
  3642. s: function( event, dx, dy ) {
  3643. return { height: this.originalSize.height + dy };
  3644. },
  3645. se: function( event, dx, dy ) {
  3646. return $.extend( this._change.s.apply( this, arguments ),
  3647. this._change.e.apply( this, [ event, dx, dy ] ) );
  3648. },
  3649. sw: function( event, dx, dy ) {
  3650. return $.extend( this._change.s.apply( this, arguments ),
  3651. this._change.w.apply( this, [ event, dx, dy ] ) );
  3652. },
  3653. ne: function( event, dx, dy ) {
  3654. return $.extend( this._change.n.apply( this, arguments ),
  3655. this._change.e.apply( this, [ event, dx, dy ] ) );
  3656. },
  3657. nw: function( event, dx, dy ) {
  3658. return $.extend( this._change.n.apply( this, arguments ),
  3659. this._change.w.apply( this, [ event, dx, dy ] ) );
  3660. }
  3661. },
  3662. _propagate: function( n, event ) {
  3663. $.ui.plugin.call( this, n, [ event, this.ui() ] );
  3664. ( n !== "resize" && this._trigger( n, event, this.ui() ) );
  3665. },
  3666. plugins: {},
  3667. ui: function() {
  3668. return {
  3669. originalElement: this.originalElement,
  3670. element: this.element,
  3671. helper: this.helper,
  3672. position: this.position,
  3673. size: this.size,
  3674. originalSize: this.originalSize,
  3675. originalPosition: this.originalPosition
  3676. };
  3677. }
  3678. } );
  3679. /*
  3680. * Resizable Extensions
  3681. */
  3682. $.ui.plugin.add( "resizable", "animate", {
  3683. stop: function( event ) {
  3684. var that = $( this ).resizable( "instance" ),
  3685. o = that.options,
  3686. pr = that._proportionallyResizeElements,
  3687. ista = pr.length && ( /textarea/i ).test( pr[ 0 ].nodeName ),
  3688. soffseth = ista && that._hasScroll( pr[ 0 ], "left" ) ? 0 : that.sizeDiff.height,
  3689. soffsetw = ista ? 0 : that.sizeDiff.width,
  3690. style = {
  3691. width: ( that.size.width - soffsetw ),
  3692. height: ( that.size.height - soffseth )
  3693. },
  3694. left = ( parseFloat( that.element.css( "left" ) ) +
  3695. ( that.position.left - that.originalPosition.left ) ) || null,
  3696. top = ( parseFloat( that.element.css( "top" ) ) +
  3697. ( that.position.top - that.originalPosition.top ) ) || null;
  3698. that.element.animate(
  3699. $.extend( style, top && left ? { top: top, left: left } : {} ), {
  3700. duration: o.animateDuration,
  3701. easing: o.animateEasing,
  3702. step: function() {
  3703. var data = {
  3704. width: parseFloat( that.element.css( "width" ) ),
  3705. height: parseFloat( that.element.css( "height" ) ),
  3706. top: parseFloat( that.element.css( "top" ) ),
  3707. left: parseFloat( that.element.css( "left" ) )
  3708. };
  3709. if ( pr && pr.length ) {
  3710. $( pr[ 0 ] ).css( { width: data.width, height: data.height } );
  3711. }
  3712. // Propagating resize, and updating values for each animation step
  3713. that._updateCache( data );
  3714. that._propagate( "resize", event );
  3715. }
  3716. }
  3717. );
  3718. }
  3719. } );
  3720. $.ui.plugin.add( "resizable", "containment", {
  3721. start: function() {
  3722. var element, p, co, ch, cw, width, height,
  3723. that = $( this ).resizable( "instance" ),
  3724. o = that.options,
  3725. el = that.element,
  3726. oc = o.containment,
  3727. ce = ( oc instanceof $ ) ?
  3728. oc.get( 0 ) :
  3729. ( /parent/.test( oc ) ) ? el.parent().get( 0 ) : oc;
  3730. if ( !ce ) {
  3731. return;
  3732. }
  3733. that.containerElement = $( ce );
  3734. if ( /document/.test( oc ) || oc === document ) {
  3735. that.containerOffset = {
  3736. left: 0,
  3737. top: 0
  3738. };
  3739. that.containerPosition = {
  3740. left: 0,
  3741. top: 0
  3742. };
  3743. that.parentData = {
  3744. element: $( document ),
  3745. left: 0,
  3746. top: 0,
  3747. width: $( document ).width(),
  3748. height: $( document ).height() || document.body.parentNode.scrollHeight
  3749. };
  3750. } else {
  3751. element = $( ce );
  3752. p = [];
  3753. $( [ "Top", "Right", "Left", "Bottom" ] ).each( function( i, name ) {
  3754. p[ i ] = that._num( element.css( "padding" + name ) );
  3755. } );
  3756. that.containerOffset = element.offset();
  3757. that.containerPosition = element.position();
  3758. that.containerSize = {
  3759. height: ( element.innerHeight() - p[ 3 ] ),
  3760. width: ( element.innerWidth() - p[ 1 ] )
  3761. };
  3762. co = that.containerOffset;
  3763. ch = that.containerSize.height;
  3764. cw = that.containerSize.width;
  3765. width = ( that._hasScroll ( ce, "left" ) ? ce.scrollWidth : cw );
  3766. height = ( that._hasScroll ( ce ) ? ce.scrollHeight : ch ) ;
  3767. that.parentData = {
  3768. element: ce,
  3769. left: co.left,
  3770. top: co.top,
  3771. width: width,
  3772. height: height
  3773. };
  3774. }
  3775. },
  3776. resize: function( event ) {
  3777. var woset, hoset, isParent, isOffsetRelative,
  3778. that = $( this ).resizable( "instance" ),
  3779. o = that.options,
  3780. co = that.containerOffset,
  3781. cp = that.position,
  3782. pRatio = that._aspectRatio || event.shiftKey,
  3783. cop = {
  3784. top: 0,
  3785. left: 0
  3786. },
  3787. ce = that.containerElement,
  3788. continueResize = true;
  3789. if ( ce[ 0 ] !== document && ( /static/ ).test( ce.css( "position" ) ) ) {
  3790. cop = co;
  3791. }
  3792. if ( cp.left < ( that._helper ? co.left : 0 ) ) {
  3793. that.size.width = that.size.width +
  3794. ( that._helper ?
  3795. ( that.position.left - co.left ) :
  3796. ( that.position.left - cop.left ) );
  3797. if ( pRatio ) {
  3798. that.size.height = that.size.width / that.aspectRatio;
  3799. continueResize = false;
  3800. }
  3801. that.position.left = o.helper ? co.left : 0;
  3802. }
  3803. if ( cp.top < ( that._helper ? co.top : 0 ) ) {
  3804. that.size.height = that.size.height +
  3805. ( that._helper ?
  3806. ( that.position.top - co.top ) :
  3807. that.position.top );
  3808. if ( pRatio ) {
  3809. that.size.width = that.size.height * that.aspectRatio;
  3810. continueResize = false;
  3811. }
  3812. that.position.top = that._helper ? co.top : 0;
  3813. }
  3814. isParent = that.containerElement.get( 0 ) === that.element.parent().get( 0 );
  3815. isOffsetRelative = /relative|absolute/.test( that.containerElement.css( "position" ) );
  3816. if ( isParent && isOffsetRelative ) {
  3817. that.offset.left = that.parentData.left + that.position.left;
  3818. that.offset.top = that.parentData.top + that.position.top;
  3819. } else {
  3820. that.offset.left = that.element.offset().left;
  3821. that.offset.top = that.element.offset().top;
  3822. }
  3823. woset = Math.abs( that.sizeDiff.width +
  3824. ( that._helper ?
  3825. that.offset.left - cop.left :
  3826. ( that.offset.left - co.left ) ) );
  3827. hoset = Math.abs( that.sizeDiff.height +
  3828. ( that._helper ?
  3829. that.offset.top - cop.top :
  3830. ( that.offset.top - co.top ) ) );
  3831. if ( woset + that.size.width >= that.parentData.width ) {
  3832. that.size.width = that.parentData.width - woset;
  3833. if ( pRatio ) {
  3834. that.size.height = that.size.width / that.aspectRatio;
  3835. continueResize = false;
  3836. }
  3837. }
  3838. if ( hoset + that.size.height >= that.parentData.height ) {
  3839. that.size.height = that.parentData.height - hoset;
  3840. if ( pRatio ) {
  3841. that.size.width = that.size.height * that.aspectRatio;
  3842. continueResize = false;
  3843. }
  3844. }
  3845. if ( !continueResize ) {
  3846. that.position.left = that.prevPosition.left;
  3847. that.position.top = that.prevPosition.top;
  3848. that.size.width = that.prevSize.width;
  3849. that.size.height = that.prevSize.height;
  3850. }
  3851. },
  3852. stop: function() {
  3853. var that = $( this ).resizable( "instance" ),
  3854. o = that.options,
  3855. co = that.containerOffset,
  3856. cop = that.containerPosition,
  3857. ce = that.containerElement,
  3858. helper = $( that.helper ),
  3859. ho = helper.offset(),
  3860. w = helper.outerWidth() - that.sizeDiff.width,
  3861. h = helper.outerHeight() - that.sizeDiff.height;
  3862. if ( that._helper && !o.animate && ( /relative/ ).test( ce.css( "position" ) ) ) {
  3863. $( this ).css( {
  3864. left: ho.left - cop.left - co.left,
  3865. width: w,
  3866. height: h
  3867. } );
  3868. }
  3869. if ( that._helper && !o.animate && ( /static/ ).test( ce.css( "position" ) ) ) {
  3870. $( this ).css( {
  3871. left: ho.left - cop.left - co.left,
  3872. width: w,
  3873. height: h
  3874. } );
  3875. }
  3876. }
  3877. } );
  3878. $.ui.plugin.add( "resizable", "alsoResize", {
  3879. start: function() {
  3880. var that = $( this ).resizable( "instance" ),
  3881. o = that.options;
  3882. $( o.alsoResize ).each( function() {
  3883. var el = $( this );
  3884. el.data( "ui-resizable-alsoresize", {
  3885. width: parseFloat( el.width() ), height: parseFloat( el.height() ),
  3886. left: parseFloat( el.css( "left" ) ), top: parseFloat( el.css( "top" ) )
  3887. } );
  3888. } );
  3889. },
  3890. resize: function( event, ui ) {
  3891. var that = $( this ).resizable( "instance" ),
  3892. o = that.options,
  3893. os = that.originalSize,
  3894. op = that.originalPosition,
  3895. delta = {
  3896. height: ( that.size.height - os.height ) || 0,
  3897. width: ( that.size.width - os.width ) || 0,
  3898. top: ( that.position.top - op.top ) || 0,
  3899. left: ( that.position.left - op.left ) || 0
  3900. };
  3901. $( o.alsoResize ).each( function() {
  3902. var el = $( this ), start = $( this ).data( "ui-resizable-alsoresize" ), style = {},
  3903. css = el.parents( ui.originalElement[ 0 ] ).length ?
  3904. [ "width", "height" ] :
  3905. [ "width", "height", "top", "left" ];
  3906. $.each( css, function( i, prop ) {
  3907. var sum = ( start[ prop ] || 0 ) + ( delta[ prop ] || 0 );
  3908. if ( sum && sum >= 0 ) {
  3909. style[ prop ] = sum || null;
  3910. }
  3911. } );
  3912. el.css( style );
  3913. } );
  3914. },
  3915. stop: function() {
  3916. $( this ).removeData( "ui-resizable-alsoresize" );
  3917. }
  3918. } );
  3919. $.ui.plugin.add( "resizable", "ghost", {
  3920. start: function() {
  3921. var that = $( this ).resizable( "instance" ), cs = that.size;
  3922. that.ghost = that.originalElement.clone();
  3923. that.ghost.css( {
  3924. opacity: 0.25,
  3925. display: "block",
  3926. position: "relative",
  3927. height: cs.height,
  3928. width: cs.width,
  3929. margin: 0,
  3930. left: 0,
  3931. top: 0
  3932. } );
  3933. that._addClass( that.ghost, "ui-resizable-ghost" );
  3934. // DEPRECATED
  3935. // TODO: remove after 1.12
  3936. if ( $.uiBackCompat !== false && typeof that.options.ghost === "string" ) {
  3937. // Ghost option
  3938. that.ghost.addClass( this.options.ghost );
  3939. }
  3940. that.ghost.appendTo( that.helper );
  3941. },
  3942. resize: function() {
  3943. var that = $( this ).resizable( "instance" );
  3944. if ( that.ghost ) {
  3945. that.ghost.css( {
  3946. position: "relative",
  3947. height: that.size.height,
  3948. width: that.size.width
  3949. } );
  3950. }
  3951. },
  3952. stop: function() {
  3953. var that = $( this ).resizable( "instance" );
  3954. if ( that.ghost && that.helper ) {
  3955. that.helper.get( 0 ).removeChild( that.ghost.get( 0 ) );
  3956. }
  3957. }
  3958. } );
  3959. $.ui.plugin.add( "resizable", "grid", {
  3960. resize: function() {
  3961. var outerDimensions,
  3962. that = $( this ).resizable( "instance" ),
  3963. o = that.options,
  3964. cs = that.size,
  3965. os = that.originalSize,
  3966. op = that.originalPosition,
  3967. a = that.axis,
  3968. grid = typeof o.grid === "number" ? [ o.grid, o.grid ] : o.grid,
  3969. gridX = ( grid[ 0 ] || 1 ),
  3970. gridY = ( grid[ 1 ] || 1 ),
  3971. ox = Math.round( ( cs.width - os.width ) / gridX ) * gridX,
  3972. oy = Math.round( ( cs.height - os.height ) / gridY ) * gridY,
  3973. newWidth = os.width + ox,
  3974. newHeight = os.height + oy,
  3975. isMaxWidth = o.maxWidth && ( o.maxWidth < newWidth ),
  3976. isMaxHeight = o.maxHeight && ( o.maxHeight < newHeight ),
  3977. isMinWidth = o.minWidth && ( o.minWidth > newWidth ),
  3978. isMinHeight = o.minHeight && ( o.minHeight > newHeight );
  3979. o.grid = grid;
  3980. if ( isMinWidth ) {
  3981. newWidth += gridX;
  3982. }
  3983. if ( isMinHeight ) {
  3984. newHeight += gridY;
  3985. }
  3986. if ( isMaxWidth ) {
  3987. newWidth -= gridX;
  3988. }
  3989. if ( isMaxHeight ) {
  3990. newHeight -= gridY;
  3991. }
  3992. if ( /^(se|s|e)$/.test( a ) ) {
  3993. that.size.width = newWidth;
  3994. that.size.height = newHeight;
  3995. } else if ( /^(ne)$/.test( a ) ) {
  3996. that.size.width = newWidth;
  3997. that.size.height = newHeight;
  3998. that.position.top = op.top - oy;
  3999. } else if ( /^(sw)$/.test( a ) ) {
  4000. that.size.width = newWidth;
  4001. that.size.height = newHeight;
  4002. that.position.left = op.left - ox;
  4003. } else {
  4004. if ( newHeight - gridY <= 0 || newWidth - gridX <= 0 ) {
  4005. outerDimensions = that._getPaddingPlusBorderDimensions( this );
  4006. }
  4007. if ( newHeight - gridY > 0 ) {
  4008. that.size.height = newHeight;
  4009. that.position.top = op.top - oy;
  4010. } else {
  4011. newHeight = gridY - outerDimensions.height;
  4012. that.size.height = newHeight;
  4013. that.position.top = op.top + os.height - newHeight;
  4014. }
  4015. if ( newWidth - gridX > 0 ) {
  4016. that.size.width = newWidth;
  4017. that.position.left = op.left - ox;
  4018. } else {
  4019. newWidth = gridX - outerDimensions.width;
  4020. that.size.width = newWidth;
  4021. that.position.left = op.left + os.width - newWidth;
  4022. }
  4023. }
  4024. }
  4025. } );
  4026. var widgetsResizable = $.ui.resizable;
  4027. /*!
  4028. * jQuery UI Selectable 1.12.1
  4029. * http://jqueryui.com
  4030. *
  4031. * Copyright jQuery Foundation and other contributors
  4032. * Released under the MIT license.
  4033. * http://jquery.org/license
  4034. */
  4035. //>>label: Selectable
  4036. //>>group: Interactions
  4037. //>>description: Allows groups of elements to be selected with the mouse.
  4038. //>>docs: http://api.jqueryui.com/selectable/
  4039. //>>demos: http://jqueryui.com/selectable/
  4040. //>>css.structure: ../../themes/base/selectable.css
  4041. var widgetsSelectable = $.widget( "ui.selectable", $.ui.mouse, {
  4042. version: "1.12.1",
  4043. options: {
  4044. appendTo: "body",
  4045. autoRefresh: true,
  4046. distance: 0,
  4047. filter: "*",
  4048. tolerance: "touch",
  4049. // Callbacks
  4050. selected: null,
  4051. selecting: null,
  4052. start: null,
  4053. stop: null,
  4054. unselected: null,
  4055. unselecting: null
  4056. },
  4057. _create: function() {
  4058. var that = this;
  4059. this._addClass( "ui-selectable" );
  4060. this.dragged = false;
  4061. // Cache selectee children based on filter
  4062. this.refresh = function() {
  4063. that.elementPos = $( that.element[ 0 ] ).offset();
  4064. that.selectees = $( that.options.filter, that.element[ 0 ] );
  4065. that._addClass( that.selectees, "ui-selectee" );
  4066. that.selectees.each( function() {
  4067. var $this = $( this ),
  4068. selecteeOffset = $this.offset(),
  4069. pos = {
  4070. left: selecteeOffset.left - that.elementPos.left,
  4071. top: selecteeOffset.top - that.elementPos.top
  4072. };
  4073. $.data( this, "selectable-item", {
  4074. element: this,
  4075. $element: $this,
  4076. left: pos.left,
  4077. top: pos.top,
  4078. right: pos.left + $this.outerWidth(),
  4079. bottom: pos.top + $this.outerHeight(),
  4080. startselected: false,
  4081. selected: $this.hasClass( "ui-selected" ),
  4082. selecting: $this.hasClass( "ui-selecting" ),
  4083. unselecting: $this.hasClass( "ui-unselecting" )
  4084. } );
  4085. } );
  4086. };
  4087. this.refresh();
  4088. this._mouseInit();
  4089. this.helper = $( "<div>" );
  4090. this._addClass( this.helper, "ui-selectable-helper" );
  4091. },
  4092. _destroy: function() {
  4093. this.selectees.removeData( "selectable-item" );
  4094. this._mouseDestroy();
  4095. },
  4096. _mouseStart: function( event ) {
  4097. var that = this,
  4098. options = this.options;
  4099. this.opos = [ event.pageX, event.pageY ];
  4100. this.elementPos = $( this.element[ 0 ] ).offset();
  4101. if ( this.options.disabled ) {
  4102. return;
  4103. }
  4104. this.selectees = $( options.filter, this.element[ 0 ] );
  4105. this._trigger( "start", event );
  4106. $( options.appendTo ).append( this.helper );
  4107. // position helper (lasso)
  4108. this.helper.css( {
  4109. "left": event.pageX,
  4110. "top": event.pageY,
  4111. "width": 0,
  4112. "height": 0
  4113. } );
  4114. if ( options.autoRefresh ) {
  4115. this.refresh();
  4116. }
  4117. this.selectees.filter( ".ui-selected" ).each( function() {
  4118. var selectee = $.data( this, "selectable-item" );
  4119. selectee.startselected = true;
  4120. if ( !event.metaKey && !event.ctrlKey ) {
  4121. that._removeClass( selectee.$element, "ui-selected" );
  4122. selectee.selected = false;
  4123. that._addClass( selectee.$element, "ui-unselecting" );
  4124. selectee.unselecting = true;
  4125. // selectable UNSELECTING callback
  4126. that._trigger( "unselecting", event, {
  4127. unselecting: selectee.element
  4128. } );
  4129. }
  4130. } );
  4131. $( event.target ).parents().addBack().each( function() {
  4132. var doSelect,
  4133. selectee = $.data( this, "selectable-item" );
  4134. if ( selectee ) {
  4135. doSelect = ( !event.metaKey && !event.ctrlKey ) ||
  4136. !selectee.$element.hasClass( "ui-selected" );
  4137. that._removeClass( selectee.$element, doSelect ? "ui-unselecting" : "ui-selected" )
  4138. ._addClass( selectee.$element, doSelect ? "ui-selecting" : "ui-unselecting" );
  4139. selectee.unselecting = !doSelect;
  4140. selectee.selecting = doSelect;
  4141. selectee.selected = doSelect;
  4142. // selectable (UN)SELECTING callback
  4143. if ( doSelect ) {
  4144. that._trigger( "selecting", event, {
  4145. selecting: selectee.element
  4146. } );
  4147. } else {
  4148. that._trigger( "unselecting", event, {
  4149. unselecting: selectee.element
  4150. } );
  4151. }
  4152. return false;
  4153. }
  4154. } );
  4155. },
  4156. _mouseDrag: function( event ) {
  4157. this.dragged = true;
  4158. if ( this.options.disabled ) {
  4159. return;
  4160. }
  4161. var tmp,
  4162. that = this,
  4163. options = this.options,
  4164. x1 = this.opos[ 0 ],
  4165. y1 = this.opos[ 1 ],
  4166. x2 = event.pageX,
  4167. y2 = event.pageY;
  4168. if ( x1 > x2 ) { tmp = x2; x2 = x1; x1 = tmp; }
  4169. if ( y1 > y2 ) { tmp = y2; y2 = y1; y1 = tmp; }
  4170. this.helper.css( { left: x1, top: y1, width: x2 - x1, height: y2 - y1 } );
  4171. this.selectees.each( function() {
  4172. var selectee = $.data( this, "selectable-item" ),
  4173. hit = false,
  4174. offset = {};
  4175. //prevent helper from being selected if appendTo: selectable
  4176. if ( !selectee || selectee.element === that.element[ 0 ] ) {
  4177. return;
  4178. }
  4179. offset.left = selectee.left + that.elementPos.left;
  4180. offset.right = selectee.right + that.elementPos.left;
  4181. offset.top = selectee.top + that.elementPos.top;
  4182. offset.bottom = selectee.bottom + that.elementPos.top;
  4183. if ( options.tolerance === "touch" ) {
  4184. hit = ( !( offset.left > x2 || offset.right < x1 || offset.top > y2 ||
  4185. offset.bottom < y1 ) );
  4186. } else if ( options.tolerance === "fit" ) {
  4187. hit = ( offset.left > x1 && offset.right < x2 && offset.top > y1 &&
  4188. offset.bottom < y2 );
  4189. }
  4190. if ( hit ) {
  4191. // SELECT
  4192. if ( selectee.selected ) {
  4193. that._removeClass( selectee.$element, "ui-selected" );
  4194. selectee.selected = false;
  4195. }
  4196. if ( selectee.unselecting ) {
  4197. that._removeClass( selectee.$element, "ui-unselecting" );
  4198. selectee.unselecting = false;
  4199. }
  4200. if ( !selectee.selecting ) {
  4201. that._addClass( selectee.$element, "ui-selecting" );
  4202. selectee.selecting = true;
  4203. // selectable SELECTING callback
  4204. that._trigger( "selecting", event, {
  4205. selecting: selectee.element
  4206. } );
  4207. }
  4208. } else {
  4209. // UNSELECT
  4210. if ( selectee.selecting ) {
  4211. if ( ( event.metaKey || event.ctrlKey ) && selectee.startselected ) {
  4212. that._removeClass( selectee.$element, "ui-selecting" );
  4213. selectee.selecting = false;
  4214. that._addClass( selectee.$element, "ui-selected" );
  4215. selectee.selected = true;
  4216. } else {
  4217. that._removeClass( selectee.$element, "ui-selecting" );
  4218. selectee.selecting = false;
  4219. if ( selectee.startselected ) {
  4220. that._addClass( selectee.$element, "ui-unselecting" );
  4221. selectee.unselecting = true;
  4222. }
  4223. // selectable UNSELECTING callback
  4224. that._trigger( "unselecting", event, {
  4225. unselecting: selectee.element
  4226. } );
  4227. }
  4228. }
  4229. if ( selectee.selected ) {
  4230. if ( !event.metaKey && !event.ctrlKey && !selectee.startselected ) {
  4231. that._removeClass( selectee.$element, "ui-selected" );
  4232. selectee.selected = false;
  4233. that._addClass( selectee.$element, "ui-unselecting" );
  4234. selectee.unselecting = true;
  4235. // selectable UNSELECTING callback
  4236. that._trigger( "unselecting", event, {
  4237. unselecting: selectee.element
  4238. } );
  4239. }
  4240. }
  4241. }
  4242. } );
  4243. return false;
  4244. },
  4245. _mouseStop: function( event ) {
  4246. var that = this;
  4247. this.dragged = false;
  4248. $( ".ui-unselecting", this.element[ 0 ] ).each( function() {
  4249. var selectee = $.data( this, "selectable-item" );
  4250. that._removeClass( selectee.$element, "ui-unselecting" );
  4251. selectee.unselecting = false;
  4252. selectee.startselected = false;
  4253. that._trigger( "unselected", event, {
  4254. unselected: selectee.element
  4255. } );
  4256. } );
  4257. $( ".ui-selecting", this.element[ 0 ] ).each( function() {
  4258. var selectee = $.data( this, "selectable-item" );
  4259. that._removeClass( selectee.$element, "ui-selecting" )
  4260. ._addClass( selectee.$element, "ui-selected" );
  4261. selectee.selecting = false;
  4262. selectee.selected = true;
  4263. selectee.startselected = true;
  4264. that._trigger( "selected", event, {
  4265. selected: selectee.element
  4266. } );
  4267. } );
  4268. this._trigger( "stop", event );
  4269. this.helper.remove();
  4270. return false;
  4271. }
  4272. } );
  4273. /*!
  4274. * jQuery UI Sortable 1.12.1
  4275. * http://jqueryui.com
  4276. *
  4277. * Copyright jQuery Foundation and other contributors
  4278. * Released under the MIT license.
  4279. * http://jquery.org/license
  4280. */
  4281. //>>label: Sortable
  4282. //>>group: Interactions
  4283. //>>description: Enables items in a list to be sorted using the mouse.
  4284. //>>docs: http://api.jqueryui.com/sortable/
  4285. //>>demos: http://jqueryui.com/sortable/
  4286. //>>css.structure: ../../themes/base/sortable.css
  4287. var widgetsSortable = $.widget( "ui.sortable", $.ui.mouse, {
  4288. version: "1.12.1",
  4289. widgetEventPrefix: "sort",
  4290. ready: false,
  4291. options: {
  4292. appendTo: "parent",
  4293. axis: false,
  4294. connectWith: false,
  4295. containment: false,
  4296. cursor: "auto",
  4297. cursorAt: false,
  4298. dropOnEmpty: true,
  4299. forcePlaceholderSize: false,
  4300. forceHelperSize: false,
  4301. grid: false,
  4302. handle: false,
  4303. helper: "original",
  4304. items: "> *",
  4305. opacity: false,
  4306. placeholder: false,
  4307. revert: false,
  4308. scroll: true,
  4309. scrollSensitivity: 20,
  4310. scrollSpeed: 20,
  4311. scope: "default",
  4312. tolerance: "intersect",
  4313. zIndex: 1000,
  4314. // Callbacks
  4315. activate: null,
  4316. beforeStop: null,
  4317. change: null,
  4318. deactivate: null,
  4319. out: null,
  4320. over: null,
  4321. receive: null,
  4322. remove: null,
  4323. sort: null,
  4324. start: null,
  4325. stop: null,
  4326. update: null
  4327. },
  4328. _isOverAxis: function( x, reference, size ) {
  4329. return ( x >= reference ) && ( x < ( reference + size ) );
  4330. },
  4331. _isFloating: function( item ) {
  4332. return ( /left|right/ ).test( item.css( "float" ) ) ||
  4333. ( /inline|table-cell/ ).test( item.css( "display" ) );
  4334. },
  4335. _create: function() {
  4336. this.containerCache = {};
  4337. this._addClass( "ui-sortable" );
  4338. //Get the items
  4339. this.refresh();
  4340. //Let's determine the parent's offset
  4341. this.offset = this.element.offset();
  4342. //Initialize mouse events for interaction
  4343. this._mouseInit();
  4344. this._setHandleClassName();
  4345. //We're ready to go
  4346. this.ready = true;
  4347. },
  4348. _setOption: function( key, value ) {
  4349. this._super( key, value );
  4350. if ( key === "handle" ) {
  4351. this._setHandleClassName();
  4352. }
  4353. },
  4354. _setHandleClassName: function() {
  4355. var that = this;
  4356. this._removeClass( this.element.find( ".ui-sortable-handle" ), "ui-sortable-handle" );
  4357. $.each( this.items, function() {
  4358. that._addClass(
  4359. this.instance.options.handle ?
  4360. this.item.find( this.instance.options.handle ) :
  4361. this.item,
  4362. "ui-sortable-handle"
  4363. );
  4364. } );
  4365. },
  4366. _destroy: function() {
  4367. this._mouseDestroy();
  4368. for ( var i = this.items.length - 1; i >= 0; i-- ) {
  4369. this.items[ i ].item.removeData( this.widgetName + "-item" );
  4370. }
  4371. return this;
  4372. },
  4373. _mouseCapture: function( event, overrideHandle ) {
  4374. var currentItem = null,
  4375. validHandle = false,
  4376. that = this;
  4377. if ( this.reverting ) {
  4378. return false;
  4379. }
  4380. if ( this.options.disabled || this.options.type === "static" ) {
  4381. return false;
  4382. }
  4383. //We have to refresh the items data once first
  4384. this._refreshItems( event );
  4385. //Find out if the clicked node (or one of its parents) is a actual item in this.items
  4386. $( event.target ).parents().each( function() {
  4387. if ( $.data( this, that.widgetName + "-item" ) === that ) {
  4388. currentItem = $( this );
  4389. return false;
  4390. }
  4391. } );
  4392. if ( $.data( event.target, that.widgetName + "-item" ) === that ) {
  4393. currentItem = $( event.target );
  4394. }
  4395. if ( !currentItem ) {
  4396. return false;
  4397. }
  4398. if ( this.options.handle && !overrideHandle ) {
  4399. $( this.options.handle, currentItem ).find( "*" ).addBack().each( function() {
  4400. if ( this === event.target ) {
  4401. validHandle = true;
  4402. }
  4403. } );
  4404. if ( !validHandle ) {
  4405. return false;
  4406. }
  4407. }
  4408. this.currentItem = currentItem;
  4409. this._removeCurrentsFromItems();
  4410. return true;
  4411. },
  4412. _mouseStart: function( event, overrideHandle, noActivation ) {
  4413. var i, body,
  4414. o = this.options;
  4415. this.currentContainer = this;
  4416. //We only need to call refreshPositions, because the refreshItems call has been moved to
  4417. // mouseCapture
  4418. this.refreshPositions();
  4419. //Create and append the visible helper
  4420. this.helper = this._createHelper( event );
  4421. //Cache the helper size
  4422. this._cacheHelperProportions();
  4423. /*
  4424. * - Position generation -
  4425. * This block generates everything position related - it's the core of draggables.
  4426. */
  4427. //Cache the margins of the original element
  4428. this._cacheMargins();
  4429. //Get the next scrolling parent
  4430. this.scrollParent = this.helper.scrollParent();
  4431. //The element's absolute position on the page minus margins
  4432. this.offset = this.currentItem.offset();
  4433. this.offset = {
  4434. top: this.offset.top - this.margins.top,
  4435. left: this.offset.left - this.margins.left
  4436. };
  4437. $.extend( this.offset, {
  4438. click: { //Where the click happened, relative to the element
  4439. left: event.pageX - this.offset.left,
  4440. top: event.pageY - this.offset.top
  4441. },
  4442. parent: this._getParentOffset(),
  4443. // This is a relative to absolute position minus the actual position calculation -
  4444. // only used for relative positioned helper
  4445. relative: this._getRelativeOffset()
  4446. } );
  4447. // Only after we got the offset, we can change the helper's position to absolute
  4448. // TODO: Still need to figure out a way to make relative sorting possible
  4449. this.helper.css( "position", "absolute" );
  4450. this.cssPosition = this.helper.css( "position" );
  4451. //Generate the original position
  4452. this.originalPosition = this._generatePosition( event );
  4453. this.originalPageX = event.pageX;
  4454. this.originalPageY = event.pageY;
  4455. //Adjust the mouse offset relative to the helper if "cursorAt" is supplied
  4456. ( o.cursorAt && this._adjustOffsetFromHelper( o.cursorAt ) );
  4457. //Cache the former DOM position
  4458. this.domPosition = {
  4459. prev: this.currentItem.prev()[ 0 ],
  4460. parent: this.currentItem.parent()[ 0 ]
  4461. };
  4462. // If the helper is not the original, hide the original so it's not playing any role during
  4463. // the drag, won't cause anything bad this way
  4464. if ( this.helper[ 0 ] !== this.currentItem[ 0 ] ) {
  4465. this.currentItem.hide();
  4466. }
  4467. //Create the placeholder
  4468. this._createPlaceholder();
  4469. //Set a containment if given in the options
  4470. if ( o.containment ) {
  4471. this._setContainment();
  4472. }
  4473. if ( o.cursor && o.cursor !== "auto" ) { // cursor option
  4474. body = this.document.find( "body" );
  4475. // Support: IE
  4476. this.storedCursor = body.css( "cursor" );
  4477. body.css( "cursor", o.cursor );
  4478. this.storedStylesheet =
  4479. $( "<style>*{ cursor: " + o.cursor + " !important; }</style>" ).appendTo( body );
  4480. }
  4481. if ( o.opacity ) { // opacity option
  4482. if ( this.helper.css( "opacity" ) ) {
  4483. this._storedOpacity = this.helper.css( "opacity" );
  4484. }
  4485. this.helper.css( "opacity", o.opacity );
  4486. }
  4487. if ( o.zIndex ) { // zIndex option
  4488. if ( this.helper.css( "zIndex" ) ) {
  4489. this._storedZIndex = this.helper.css( "zIndex" );
  4490. }
  4491. this.helper.css( "zIndex", o.zIndex );
  4492. }
  4493. //Prepare scrolling
  4494. if ( this.scrollParent[ 0 ] !== this.document[ 0 ] &&
  4495. this.scrollParent[ 0 ].tagName !== "HTML" ) {
  4496. this.overflowOffset = this.scrollParent.offset();
  4497. }
  4498. //Call callbacks
  4499. this._trigger( "start", event, this._uiHash() );
  4500. //Recache the helper size
  4501. if ( !this._preserveHelperProportions ) {
  4502. this._cacheHelperProportions();
  4503. }
  4504. //Post "activate" events to possible containers
  4505. if ( !noActivation ) {
  4506. for ( i = this.containers.length - 1; i >= 0; i-- ) {
  4507. this.containers[ i ]._trigger( "activate", event, this._uiHash( this ) );
  4508. }
  4509. }
  4510. //Prepare possible droppables
  4511. if ( $.ui.ddmanager ) {
  4512. $.ui.ddmanager.current = this;
  4513. }
  4514. if ( $.ui.ddmanager && !o.dropBehaviour ) {
  4515. $.ui.ddmanager.prepareOffsets( this, event );
  4516. }
  4517. this.dragging = true;
  4518. this._addClass( this.helper, "ui-sortable-helper" );
  4519. // Execute the drag once - this causes the helper not to be visiblebefore getting its
  4520. // correct position
  4521. this._mouseDrag( event );
  4522. return true;
  4523. },
  4524. _mouseDrag: function( event ) {
  4525. var i, item, itemElement, intersection,
  4526. o = this.options,
  4527. scrolled = false;
  4528. //Compute the helpers position
  4529. this.position = this._generatePosition( event );
  4530. this.positionAbs = this._convertPositionTo( "absolute" );
  4531. if ( !this.lastPositionAbs ) {
  4532. this.lastPositionAbs = this.positionAbs;
  4533. }
  4534. //Do scrolling
  4535. if ( this.options.scroll ) {
  4536. if ( this.scrollParent[ 0 ] !== this.document[ 0 ] &&
  4537. this.scrollParent[ 0 ].tagName !== "HTML" ) {
  4538. if ( ( this.overflowOffset.top + this.scrollParent[ 0 ].offsetHeight ) -
  4539. event.pageY < o.scrollSensitivity ) {
  4540. this.scrollParent[ 0 ].scrollTop =
  4541. scrolled = this.scrollParent[ 0 ].scrollTop + o.scrollSpeed;
  4542. } else if ( event.pageY - this.overflowOffset.top < o.scrollSensitivity ) {
  4543. this.scrollParent[ 0 ].scrollTop =
  4544. scrolled = this.scrollParent[ 0 ].scrollTop - o.scrollSpeed;
  4545. }
  4546. if ( ( this.overflowOffset.left + this.scrollParent[ 0 ].offsetWidth ) -
  4547. event.pageX < o.scrollSensitivity ) {
  4548. this.scrollParent[ 0 ].scrollLeft = scrolled =
  4549. this.scrollParent[ 0 ].scrollLeft + o.scrollSpeed;
  4550. } else if ( event.pageX - this.overflowOffset.left < o.scrollSensitivity ) {
  4551. this.scrollParent[ 0 ].scrollLeft = scrolled =
  4552. this.scrollParent[ 0 ].scrollLeft - o.scrollSpeed;
  4553. }
  4554. } else {
  4555. if ( event.pageY - this.document.scrollTop() < o.scrollSensitivity ) {
  4556. scrolled = this.document.scrollTop( this.document.scrollTop() - o.scrollSpeed );
  4557. } else if ( this.window.height() - ( event.pageY - this.document.scrollTop() ) <
  4558. o.scrollSensitivity ) {
  4559. scrolled = this.document.scrollTop( this.document.scrollTop() + o.scrollSpeed );
  4560. }
  4561. if ( event.pageX - this.document.scrollLeft() < o.scrollSensitivity ) {
  4562. scrolled = this.document.scrollLeft(
  4563. this.document.scrollLeft() - o.scrollSpeed
  4564. );
  4565. } else if ( this.window.width() - ( event.pageX - this.document.scrollLeft() ) <
  4566. o.scrollSensitivity ) {
  4567. scrolled = this.document.scrollLeft(
  4568. this.document.scrollLeft() + o.scrollSpeed
  4569. );
  4570. }
  4571. }
  4572. if ( scrolled !== false && $.ui.ddmanager && !o.dropBehaviour ) {
  4573. $.ui.ddmanager.prepareOffsets( this, event );
  4574. }
  4575. }
  4576. //Regenerate the absolute position used for position checks
  4577. this.positionAbs = this._convertPositionTo( "absolute" );
  4578. //Set the helper position
  4579. if ( !this.options.axis || this.options.axis !== "y" ) {
  4580. this.helper[ 0 ].style.left = this.position.left + "px";
  4581. }
  4582. if ( !this.options.axis || this.options.axis !== "x" ) {
  4583. this.helper[ 0 ].style.top = this.position.top + "px";
  4584. }
  4585. //Rearrange
  4586. for ( i = this.items.length - 1; i >= 0; i-- ) {
  4587. //Cache variables and intersection, continue if no intersection
  4588. item = this.items[ i ];
  4589. itemElement = item.item[ 0 ];
  4590. intersection = this._intersectsWithPointer( item );
  4591. if ( !intersection ) {
  4592. continue;
  4593. }
  4594. // Only put the placeholder inside the current Container, skip all
  4595. // items from other containers. This works because when moving
  4596. // an item from one container to another the
  4597. // currentContainer is switched before the placeholder is moved.
  4598. //
  4599. // Without this, moving items in "sub-sortables" can cause
  4600. // the placeholder to jitter between the outer and inner container.
  4601. if ( item.instance !== this.currentContainer ) {
  4602. continue;
  4603. }
  4604. // Cannot intersect with itself
  4605. // no useless actions that have been done before
  4606. // no action if the item moved is the parent of the item checked
  4607. if ( itemElement !== this.currentItem[ 0 ] &&
  4608. this.placeholder[ intersection === 1 ? "next" : "prev" ]()[ 0 ] !== itemElement &&
  4609. !$.contains( this.placeholder[ 0 ], itemElement ) &&
  4610. ( this.options.type === "semi-dynamic" ?
  4611. !$.contains( this.element[ 0 ], itemElement ) :
  4612. true
  4613. )
  4614. ) {
  4615. this.direction = intersection === 1 ? "down" : "up";
  4616. if ( this.options.tolerance === "pointer" || this._intersectsWithSides( item ) ) {
  4617. this._rearrange( event, item );
  4618. } else {
  4619. break;
  4620. }
  4621. this._trigger( "change", event, this._uiHash() );
  4622. break;
  4623. }
  4624. }
  4625. //Post events to containers
  4626. this._contactContainers( event );
  4627. //Interconnect with droppables
  4628. if ( $.ui.ddmanager ) {
  4629. $.ui.ddmanager.drag( this, event );
  4630. }
  4631. //Call callbacks
  4632. this._trigger( "sort", event, this._uiHash() );
  4633. this.lastPositionAbs = this.positionAbs;
  4634. return false;
  4635. },
  4636. _mouseStop: function( event, noPropagation ) {
  4637. if ( !event ) {
  4638. return;
  4639. }
  4640. //If we are using droppables, inform the manager about the drop
  4641. if ( $.ui.ddmanager && !this.options.dropBehaviour ) {
  4642. $.ui.ddmanager.drop( this, event );
  4643. }
  4644. if ( this.options.revert ) {
  4645. var that = this,
  4646. cur = this.placeholder.offset(),
  4647. axis = this.options.axis,
  4648. animation = {};
  4649. if ( !axis || axis === "x" ) {
  4650. animation.left = cur.left - this.offset.parent.left - this.margins.left +
  4651. ( this.offsetParent[ 0 ] === this.document[ 0 ].body ?
  4652. 0 :
  4653. this.offsetParent[ 0 ].scrollLeft
  4654. );
  4655. }
  4656. if ( !axis || axis === "y" ) {
  4657. animation.top = cur.top - this.offset.parent.top - this.margins.top +
  4658. ( this.offsetParent[ 0 ] === this.document[ 0 ].body ?
  4659. 0 :
  4660. this.offsetParent[ 0 ].scrollTop
  4661. );
  4662. }
  4663. this.reverting = true;
  4664. $( this.helper ).animate(
  4665. animation,
  4666. parseInt( this.options.revert, 10 ) || 500,
  4667. function() {
  4668. that._clear( event );
  4669. }
  4670. );
  4671. } else {
  4672. this._clear( event, noPropagation );
  4673. }
  4674. return false;
  4675. },
  4676. cancel: function() {
  4677. if ( this.dragging ) {
  4678. this._mouseUp( new $.Event( "mouseup", { target: null } ) );
  4679. if ( this.options.helper === "original" ) {
  4680. this.currentItem.css( this._storedCSS );
  4681. this._removeClass( this.currentItem, "ui-sortable-helper" );
  4682. } else {
  4683. this.currentItem.show();
  4684. }
  4685. //Post deactivating events to containers
  4686. for ( var i = this.containers.length - 1; i >= 0; i-- ) {
  4687. this.containers[ i ]._trigger( "deactivate", null, this._uiHash( this ) );
  4688. if ( this.containers[ i ].containerCache.over ) {
  4689. this.containers[ i ]._trigger( "out", null, this._uiHash( this ) );
  4690. this.containers[ i ].containerCache.over = 0;
  4691. }
  4692. }
  4693. }
  4694. if ( this.placeholder ) {
  4695. //$(this.placeholder[0]).remove(); would have been the jQuery way - unfortunately,
  4696. // it unbinds ALL events from the original node!
  4697. if ( this.placeholder[ 0 ].parentNode ) {
  4698. this.placeholder[ 0 ].parentNode.removeChild( this.placeholder[ 0 ] );
  4699. }
  4700. if ( this.options.helper !== "original" && this.helper &&
  4701. this.helper[ 0 ].parentNode ) {
  4702. this.helper.remove();
  4703. }
  4704. $.extend( this, {
  4705. helper: null,
  4706. dragging: false,
  4707. reverting: false,
  4708. _noFinalSort: null
  4709. } );
  4710. if ( this.domPosition.prev ) {
  4711. $( this.domPosition.prev ).after( this.currentItem );
  4712. } else {
  4713. $( this.domPosition.parent ).prepend( this.currentItem );
  4714. }
  4715. }
  4716. return this;
  4717. },
  4718. serialize: function( o ) {
  4719. var items = this._getItemsAsjQuery( o && o.connected ),
  4720. str = [];
  4721. o = o || {};
  4722. $( items ).each( function() {
  4723. var res = ( $( o.item || this ).attr( o.attribute || "id" ) || "" )
  4724. .match( o.expression || ( /(.+)[\-=_](.+)/ ) );
  4725. if ( res ) {
  4726. str.push(
  4727. ( o.key || res[ 1 ] + "[]" ) +
  4728. "=" + ( o.key && o.expression ? res[ 1 ] : res[ 2 ] ) );
  4729. }
  4730. } );
  4731. if ( !str.length && o.key ) {
  4732. str.push( o.key + "=" );
  4733. }
  4734. return str.join( "&" );
  4735. },
  4736. toArray: function( o ) {
  4737. var items = this._getItemsAsjQuery( o && o.connected ),
  4738. ret = [];
  4739. o = o || {};
  4740. items.each( function() {
  4741. ret.push( $( o.item || this ).attr( o.attribute || "id" ) || "" );
  4742. } );
  4743. return ret;
  4744. },
  4745. /* Be careful with the following core functions */
  4746. _intersectsWith: function( item ) {
  4747. var x1 = this.positionAbs.left,
  4748. x2 = x1 + this.helperProportions.width,
  4749. y1 = this.positionAbs.top,
  4750. y2 = y1 + this.helperProportions.height,
  4751. l = item.left,
  4752. r = l + item.width,
  4753. t = item.top,
  4754. b = t + item.height,
  4755. dyClick = this.offset.click.top,
  4756. dxClick = this.offset.click.left,
  4757. isOverElementHeight = ( this.options.axis === "x" ) || ( ( y1 + dyClick ) > t &&
  4758. ( y1 + dyClick ) < b ),
  4759. isOverElementWidth = ( this.options.axis === "y" ) || ( ( x1 + dxClick ) > l &&
  4760. ( x1 + dxClick ) < r ),
  4761. isOverElement = isOverElementHeight && isOverElementWidth;
  4762. if ( this.options.tolerance === "pointer" ||
  4763. this.options.forcePointerForContainers ||
  4764. ( this.options.tolerance !== "pointer" &&
  4765. this.helperProportions[ this.floating ? "width" : "height" ] >
  4766. item[ this.floating ? "width" : "height" ] )
  4767. ) {
  4768. return isOverElement;
  4769. } else {
  4770. return ( l < x1 + ( this.helperProportions.width / 2 ) && // Right Half
  4771. x2 - ( this.helperProportions.width / 2 ) < r && // Left Half
  4772. t < y1 + ( this.helperProportions.height / 2 ) && // Bottom Half
  4773. y2 - ( this.helperProportions.height / 2 ) < b ); // Top Half
  4774. }
  4775. },
  4776. _intersectsWithPointer: function( item ) {
  4777. var verticalDirection, horizontalDirection,
  4778. isOverElementHeight = ( this.options.axis === "x" ) ||
  4779. this._isOverAxis(
  4780. this.positionAbs.top + this.offset.click.top, item.top, item.height ),
  4781. isOverElementWidth = ( this.options.axis === "y" ) ||
  4782. this._isOverAxis(
  4783. this.positionAbs.left + this.offset.click.left, item.left, item.width ),
  4784. isOverElement = isOverElementHeight && isOverElementWidth;
  4785. if ( !isOverElement ) {
  4786. return false;
  4787. }
  4788. verticalDirection = this._getDragVerticalDirection();
  4789. horizontalDirection = this._getDragHorizontalDirection();
  4790. return this.floating ?
  4791. ( ( horizontalDirection === "right" || verticalDirection === "down" ) ? 2 : 1 )
  4792. : ( verticalDirection && ( verticalDirection === "down" ? 2 : 1 ) );
  4793. },
  4794. _intersectsWithSides: function( item ) {
  4795. var isOverBottomHalf = this._isOverAxis( this.positionAbs.top +
  4796. this.offset.click.top, item.top + ( item.height / 2 ), item.height ),
  4797. isOverRightHalf = this._isOverAxis( this.positionAbs.left +
  4798. this.offset.click.left, item.left + ( item.width / 2 ), item.width ),
  4799. verticalDirection = this._getDragVerticalDirection(),
  4800. horizontalDirection = this._getDragHorizontalDirection();
  4801. if ( this.floating && horizontalDirection ) {
  4802. return ( ( horizontalDirection === "right" && isOverRightHalf ) ||
  4803. ( horizontalDirection === "left" && !isOverRightHalf ) );
  4804. } else {
  4805. return verticalDirection && ( ( verticalDirection === "down" && isOverBottomHalf ) ||
  4806. ( verticalDirection === "up" && !isOverBottomHalf ) );
  4807. }
  4808. },
  4809. _getDragVerticalDirection: function() {
  4810. var delta = this.positionAbs.top - this.lastPositionAbs.top;
  4811. return delta !== 0 && ( delta > 0 ? "down" : "up" );
  4812. },
  4813. _getDragHorizontalDirection: function() {
  4814. var delta = this.positionAbs.left - this.lastPositionAbs.left;
  4815. return delta !== 0 && ( delta > 0 ? "right" : "left" );
  4816. },
  4817. refresh: function( event ) {
  4818. this._refreshItems( event );
  4819. this._setHandleClassName();
  4820. this.refreshPositions();
  4821. return this;
  4822. },
  4823. _connectWith: function() {
  4824. var options = this.options;
  4825. return options.connectWith.constructor === String ?
  4826. [ options.connectWith ] :
  4827. options.connectWith;
  4828. },
  4829. _getItemsAsjQuery: function( connected ) {
  4830. var i, j, cur, inst,
  4831. items = [],
  4832. queries = [],
  4833. connectWith = this._connectWith();
  4834. if ( connectWith && connected ) {
  4835. for ( i = connectWith.length - 1; i >= 0; i-- ) {
  4836. cur = $( connectWith[ i ], this.document[ 0 ] );
  4837. for ( j = cur.length - 1; j >= 0; j-- ) {
  4838. inst = $.data( cur[ j ], this.widgetFullName );
  4839. if ( inst && inst !== this && !inst.options.disabled ) {
  4840. queries.push( [ $.isFunction( inst.options.items ) ?
  4841. inst.options.items.call( inst.element ) :
  4842. $( inst.options.items, inst.element )
  4843. .not( ".ui-sortable-helper" )
  4844. .not( ".ui-sortable-placeholder" ), inst ] );
  4845. }
  4846. }
  4847. }
  4848. }
  4849. queries.push( [ $.isFunction( this.options.items ) ?
  4850. this.options.items
  4851. .call( this.element, null, { options: this.options, item: this.currentItem } ) :
  4852. $( this.options.items, this.element )
  4853. .not( ".ui-sortable-helper" )
  4854. .not( ".ui-sortable-placeholder" ), this ] );
  4855. function addItems() {
  4856. items.push( this );
  4857. }
  4858. for ( i = queries.length - 1; i >= 0; i-- ) {
  4859. queries[ i ][ 0 ].each( addItems );
  4860. }
  4861. return $( items );
  4862. },
  4863. _removeCurrentsFromItems: function() {
  4864. var list = this.currentItem.find( ":data(" + this.widgetName + "-item)" );
  4865. this.items = $.grep( this.items, function( item ) {
  4866. for ( var j = 0; j < list.length; j++ ) {
  4867. if ( list[ j ] === item.item[ 0 ] ) {
  4868. return false;
  4869. }
  4870. }
  4871. return true;
  4872. } );
  4873. },
  4874. _refreshItems: function( event ) {
  4875. this.items = [];
  4876. this.containers = [ this ];
  4877. var i, j, cur, inst, targetData, _queries, item, queriesLength,
  4878. items = this.items,
  4879. queries = [ [ $.isFunction( this.options.items ) ?
  4880. this.options.items.call( this.element[ 0 ], event, { item: this.currentItem } ) :
  4881. $( this.options.items, this.element ), this ] ],
  4882. connectWith = this._connectWith();
  4883. //Shouldn't be run the first time through due to massive slow-down
  4884. if ( connectWith && this.ready ) {
  4885. for ( i = connectWith.length - 1; i >= 0; i-- ) {
  4886. cur = $( connectWith[ i ], this.document[ 0 ] );
  4887. for ( j = cur.length - 1; j >= 0; j-- ) {
  4888. inst = $.data( cur[ j ], this.widgetFullName );
  4889. if ( inst && inst !== this && !inst.options.disabled ) {
  4890. queries.push( [ $.isFunction( inst.options.items ) ?
  4891. inst.options.items
  4892. .call( inst.element[ 0 ], event, { item: this.currentItem } ) :
  4893. $( inst.options.items, inst.element ), inst ] );
  4894. this.containers.push( inst );
  4895. }
  4896. }
  4897. }
  4898. }
  4899. for ( i = queries.length - 1; i >= 0; i-- ) {
  4900. targetData = queries[ i ][ 1 ];
  4901. _queries = queries[ i ][ 0 ];
  4902. for ( j = 0, queriesLength = _queries.length; j < queriesLength; j++ ) {
  4903. item = $( _queries[ j ] );
  4904. // Data for target checking (mouse manager)
  4905. item.data( this.widgetName + "-item", targetData );
  4906. items.push( {
  4907. item: item,
  4908. instance: targetData,
  4909. width: 0, height: 0,
  4910. left: 0, top: 0
  4911. } );
  4912. }
  4913. }
  4914. },
  4915. refreshPositions: function( fast ) {
  4916. // Determine whether items are being displayed horizontally
  4917. this.floating = this.items.length ?
  4918. this.options.axis === "x" || this._isFloating( this.items[ 0 ].item ) :
  4919. false;
  4920. //This has to be redone because due to the item being moved out/into the offsetParent,
  4921. // the offsetParent's position will change
  4922. if ( this.offsetParent && this.helper ) {
  4923. this.offset.parent = this._getParentOffset();
  4924. }
  4925. var i, item, t, p;
  4926. for ( i = this.items.length - 1; i >= 0; i-- ) {
  4927. item = this.items[ i ];
  4928. //We ignore calculating positions of all connected containers when we're not over them
  4929. if ( item.instance !== this.currentContainer && this.currentContainer &&
  4930. item.item[ 0 ] !== this.currentItem[ 0 ] ) {
  4931. continue;
  4932. }
  4933. t = this.options.toleranceElement ?
  4934. $( this.options.toleranceElement, item.item ) :
  4935. item.item;
  4936. if ( !fast ) {
  4937. item.width = t.outerWidth();
  4938. item.height = t.outerHeight();
  4939. }
  4940. p = t.offset();
  4941. item.left = p.left;
  4942. item.top = p.top;
  4943. }
  4944. if ( this.options.custom && this.options.custom.refreshContainers ) {
  4945. this.options.custom.refreshContainers.call( this );
  4946. } else {
  4947. for ( i = this.containers.length - 1; i >= 0; i-- ) {
  4948. p = this.containers[ i ].element.offset();
  4949. this.containers[ i ].containerCache.left = p.left;
  4950. this.containers[ i ].containerCache.top = p.top;
  4951. this.containers[ i ].containerCache.width =
  4952. this.containers[ i ].element.outerWidth();
  4953. this.containers[ i ].containerCache.height =
  4954. this.containers[ i ].element.outerHeight();
  4955. }
  4956. }
  4957. return this;
  4958. },
  4959. _createPlaceholder: function( that ) {
  4960. that = that || this;
  4961. var className,
  4962. o = that.options;
  4963. if ( !o.placeholder || o.placeholder.constructor === String ) {
  4964. className = o.placeholder;
  4965. o.placeholder = {
  4966. element: function() {
  4967. var nodeName = that.currentItem[ 0 ].nodeName.toLowerCase(),
  4968. element = $( "<" + nodeName + ">", that.document[ 0 ] );
  4969. that._addClass( element, "ui-sortable-placeholder",
  4970. className || that.currentItem[ 0 ].className )
  4971. ._removeClass( element, "ui-sortable-helper" );
  4972. if ( nodeName === "tbody" ) {
  4973. that._createTrPlaceholder(
  4974. that.currentItem.find( "tr" ).eq( 0 ),
  4975. $( "<tr>", that.document[ 0 ] ).appendTo( element )
  4976. );
  4977. } else if ( nodeName === "tr" ) {
  4978. that._createTrPlaceholder( that.currentItem, element );
  4979. } else if ( nodeName === "img" ) {
  4980. element.attr( "src", that.currentItem.attr( "src" ) );
  4981. }
  4982. if ( !className ) {
  4983. element.css( "visibility", "hidden" );
  4984. }
  4985. return element;
  4986. },
  4987. update: function( container, p ) {
  4988. // 1. If a className is set as 'placeholder option, we don't force sizes -
  4989. // the class is responsible for that
  4990. // 2. The option 'forcePlaceholderSize can be enabled to force it even if a
  4991. // class name is specified
  4992. if ( className && !o.forcePlaceholderSize ) {
  4993. return;
  4994. }
  4995. //If the element doesn't have a actual height by itself (without styles coming
  4996. // from a stylesheet), it receives the inline height from the dragged item
  4997. if ( !p.height() ) {
  4998. p.height(
  4999. that.currentItem.innerHeight() -
  5000. parseInt( that.currentItem.css( "paddingTop" ) || 0, 10 ) -
  5001. parseInt( that.currentItem.css( "paddingBottom" ) || 0, 10 ) );
  5002. }
  5003. if ( !p.width() ) {
  5004. p.width(
  5005. that.currentItem.innerWidth() -
  5006. parseInt( that.currentItem.css( "paddingLeft" ) || 0, 10 ) -
  5007. parseInt( that.currentItem.css( "paddingRight" ) || 0, 10 ) );
  5008. }
  5009. }
  5010. };
  5011. }
  5012. //Create the placeholder
  5013. that.placeholder = $( o.placeholder.element.call( that.element, that.currentItem ) );
  5014. //Append it after the actual current item
  5015. that.currentItem.after( that.placeholder );
  5016. //Update the size of the placeholder (TODO: Logic to fuzzy, see line 316/317)
  5017. o.placeholder.update( that, that.placeholder );
  5018. },
  5019. _createTrPlaceholder: function( sourceTr, targetTr ) {
  5020. var that = this;
  5021. sourceTr.children().each( function() {
  5022. $( "<td>&#160;</td>", that.document[ 0 ] )
  5023. .attr( "colspan", $( this ).attr( "colspan" ) || 1 )
  5024. .appendTo( targetTr );
  5025. } );
  5026. },
  5027. _contactContainers: function( event ) {
  5028. var i, j, dist, itemWithLeastDistance, posProperty, sizeProperty, cur, nearBottom,
  5029. floating, axis,
  5030. innermostContainer = null,
  5031. innermostIndex = null;
  5032. // Get innermost container that intersects with item
  5033. for ( i = this.containers.length - 1; i >= 0; i-- ) {
  5034. // Never consider a container that's located within the item itself
  5035. if ( $.contains( this.currentItem[ 0 ], this.containers[ i ].element[ 0 ] ) ) {
  5036. continue;
  5037. }
  5038. if ( this._intersectsWith( this.containers[ i ].containerCache ) ) {
  5039. // If we've already found a container and it's more "inner" than this, then continue
  5040. if ( innermostContainer &&
  5041. $.contains(
  5042. this.containers[ i ].element[ 0 ],
  5043. innermostContainer.element[ 0 ] ) ) {
  5044. continue;
  5045. }
  5046. innermostContainer = this.containers[ i ];
  5047. innermostIndex = i;
  5048. } else {
  5049. // container doesn't intersect. trigger "out" event if necessary
  5050. if ( this.containers[ i ].containerCache.over ) {
  5051. this.containers[ i ]._trigger( "out", event, this._uiHash( this ) );
  5052. this.containers[ i ].containerCache.over = 0;
  5053. }
  5054. }
  5055. }
  5056. // If no intersecting containers found, return
  5057. if ( !innermostContainer ) {
  5058. return;
  5059. }
  5060. // Move the item into the container if it's not there already
  5061. if ( this.containers.length === 1 ) {
  5062. if ( !this.containers[ innermostIndex ].containerCache.over ) {
  5063. this.containers[ innermostIndex ]._trigger( "over", event, this._uiHash( this ) );
  5064. this.containers[ innermostIndex ].containerCache.over = 1;
  5065. }
  5066. } else {
  5067. // When entering a new container, we will find the item with the least distance and
  5068. // append our item near it
  5069. dist = 10000;
  5070. itemWithLeastDistance = null;
  5071. floating = innermostContainer.floating || this._isFloating( this.currentItem );
  5072. posProperty = floating ? "left" : "top";
  5073. sizeProperty = floating ? "width" : "height";
  5074. axis = floating ? "pageX" : "pageY";
  5075. for ( j = this.items.length - 1; j >= 0; j-- ) {
  5076. if ( !$.contains(
  5077. this.containers[ innermostIndex ].element[ 0 ], this.items[ j ].item[ 0 ] )
  5078. ) {
  5079. continue;
  5080. }
  5081. if ( this.items[ j ].item[ 0 ] === this.currentItem[ 0 ] ) {
  5082. continue;
  5083. }
  5084. cur = this.items[ j ].item.offset()[ posProperty ];
  5085. nearBottom = false;
  5086. if ( event[ axis ] - cur > this.items[ j ][ sizeProperty ] / 2 ) {
  5087. nearBottom = true;
  5088. }
  5089. if ( Math.abs( event[ axis ] - cur ) < dist ) {
  5090. dist = Math.abs( event[ axis ] - cur );
  5091. itemWithLeastDistance = this.items[ j ];
  5092. this.direction = nearBottom ? "up" : "down";
  5093. }
  5094. }
  5095. //Check if dropOnEmpty is enabled
  5096. if ( !itemWithLeastDistance && !this.options.dropOnEmpty ) {
  5097. return;
  5098. }
  5099. if ( this.currentContainer === this.containers[ innermostIndex ] ) {
  5100. if ( !this.currentContainer.containerCache.over ) {
  5101. this.containers[ innermostIndex ]._trigger( "over", event, this._uiHash() );
  5102. this.currentContainer.containerCache.over = 1;
  5103. }
  5104. return;
  5105. }
  5106. itemWithLeastDistance ?
  5107. this._rearrange( event, itemWithLeastDistance, null, true ) :
  5108. this._rearrange( event, null, this.containers[ innermostIndex ].element, true );
  5109. this._trigger( "change", event, this._uiHash() );
  5110. this.containers[ innermostIndex ]._trigger( "change", event, this._uiHash( this ) );
  5111. this.currentContainer = this.containers[ innermostIndex ];
  5112. //Update the placeholder
  5113. this.options.placeholder.update( this.currentContainer, this.placeholder );
  5114. this.containers[ innermostIndex ]._trigger( "over", event, this._uiHash( this ) );
  5115. this.containers[ innermostIndex ].containerCache.over = 1;
  5116. }
  5117. },
  5118. _createHelper: function( event ) {
  5119. var o = this.options,
  5120. helper = $.isFunction( o.helper ) ?
  5121. $( o.helper.apply( this.element[ 0 ], [ event, this.currentItem ] ) ) :
  5122. ( o.helper === "clone" ? this.currentItem.clone() : this.currentItem );
  5123. //Add the helper to the DOM if that didn't happen already
  5124. if ( !helper.parents( "body" ).length ) {
  5125. $( o.appendTo !== "parent" ?
  5126. o.appendTo :
  5127. this.currentItem[ 0 ].parentNode )[ 0 ].appendChild( helper[ 0 ] );
  5128. }
  5129. if ( helper[ 0 ] === this.currentItem[ 0 ] ) {
  5130. this._storedCSS = {
  5131. width: this.currentItem[ 0 ].style.width,
  5132. height: this.currentItem[ 0 ].style.height,
  5133. position: this.currentItem.css( "position" ),
  5134. top: this.currentItem.css( "top" ),
  5135. left: this.currentItem.css( "left" )
  5136. };
  5137. }
  5138. if ( !helper[ 0 ].style.width || o.forceHelperSize ) {
  5139. helper.width( this.currentItem.width() );
  5140. }
  5141. if ( !helper[ 0 ].style.height || o.forceHelperSize ) {
  5142. helper.height( this.currentItem.height() );
  5143. }
  5144. return helper;
  5145. },
  5146. _adjustOffsetFromHelper: function( obj ) {
  5147. if ( typeof obj === "string" ) {
  5148. obj = obj.split( " " );
  5149. }
  5150. if ( $.isArray( obj ) ) {
  5151. obj = { left: +obj[ 0 ], top: +obj[ 1 ] || 0 };
  5152. }
  5153. if ( "left" in obj ) {
  5154. this.offset.click.left = obj.left + this.margins.left;
  5155. }
  5156. if ( "right" in obj ) {
  5157. this.offset.click.left = this.helperProportions.width - obj.right + this.margins.left;
  5158. }
  5159. if ( "top" in obj ) {
  5160. this.offset.click.top = obj.top + this.margins.top;
  5161. }
  5162. if ( "bottom" in obj ) {
  5163. this.offset.click.top = this.helperProportions.height - obj.bottom + this.margins.top;
  5164. }
  5165. },
  5166. _getParentOffset: function() {
  5167. //Get the offsetParent and cache its position
  5168. this.offsetParent = this.helper.offsetParent();
  5169. var po = this.offsetParent.offset();
  5170. // This is a special case where we need to modify a offset calculated on start, since the
  5171. // following happened:
  5172. // 1. The position of the helper is absolute, so it's position is calculated based on the
  5173. // next positioned parent
  5174. // 2. The actual offset parent is a child of the scroll parent, and the scroll parent isn't
  5175. // the document, which means that the scroll is included in the initial calculation of the
  5176. // offset of the parent, and never recalculated upon drag
  5177. if ( this.cssPosition === "absolute" && this.scrollParent[ 0 ] !== this.document[ 0 ] &&
  5178. $.contains( this.scrollParent[ 0 ], this.offsetParent[ 0 ] ) ) {
  5179. po.left += this.scrollParent.scrollLeft();
  5180. po.top += this.scrollParent.scrollTop();
  5181. }
  5182. // This needs to be actually done for all browsers, since pageX/pageY includes this
  5183. // information with an ugly IE fix
  5184. if ( this.offsetParent[ 0 ] === this.document[ 0 ].body ||
  5185. ( this.offsetParent[ 0 ].tagName &&
  5186. this.offsetParent[ 0 ].tagName.toLowerCase() === "html" && $.ui.ie ) ) {
  5187. po = { top: 0, left: 0 };
  5188. }
  5189. return {
  5190. top: po.top + ( parseInt( this.offsetParent.css( "borderTopWidth" ), 10 ) || 0 ),
  5191. left: po.left + ( parseInt( this.offsetParent.css( "borderLeftWidth" ), 10 ) || 0 )
  5192. };
  5193. },
  5194. _getRelativeOffset: function() {
  5195. if ( this.cssPosition === "relative" ) {
  5196. var p = this.currentItem.position();
  5197. return {
  5198. top: p.top - ( parseInt( this.helper.css( "top" ), 10 ) || 0 ) +
  5199. this.scrollParent.scrollTop(),
  5200. left: p.left - ( parseInt( this.helper.css( "left" ), 10 ) || 0 ) +
  5201. this.scrollParent.scrollLeft()
  5202. };
  5203. } else {
  5204. return { top: 0, left: 0 };
  5205. }
  5206. },
  5207. _cacheMargins: function() {
  5208. this.margins = {
  5209. left: ( parseInt( this.currentItem.css( "marginLeft" ), 10 ) || 0 ),
  5210. top: ( parseInt( this.currentItem.css( "marginTop" ), 10 ) || 0 )
  5211. };
  5212. },
  5213. _cacheHelperProportions: function() {
  5214. this.helperProportions = {
  5215. width: this.helper.outerWidth(),
  5216. height: this.helper.outerHeight()
  5217. };
  5218. },
  5219. _setContainment: function() {
  5220. var ce, co, over,
  5221. o = this.options;
  5222. if ( o.containment === "parent" ) {
  5223. o.containment = this.helper[ 0 ].parentNode;
  5224. }
  5225. if ( o.containment === "document" || o.containment === "window" ) {
  5226. this.containment = [
  5227. 0 - this.offset.relative.left - this.offset.parent.left,
  5228. 0 - this.offset.relative.top - this.offset.parent.top,
  5229. o.containment === "document" ?
  5230. this.document.width() :
  5231. this.window.width() - this.helperProportions.width - this.margins.left,
  5232. ( o.containment === "document" ?
  5233. ( this.document.height() || document.body.parentNode.scrollHeight ) :
  5234. this.window.height() || this.document[ 0 ].body.parentNode.scrollHeight
  5235. ) - this.helperProportions.height - this.margins.top
  5236. ];
  5237. }
  5238. if ( !( /^(document|window|parent)$/ ).test( o.containment ) ) {
  5239. ce = $( o.containment )[ 0 ];
  5240. co = $( o.containment ).offset();
  5241. over = ( $( ce ).css( "overflow" ) !== "hidden" );
  5242. this.containment = [
  5243. co.left + ( parseInt( $( ce ).css( "borderLeftWidth" ), 10 ) || 0 ) +
  5244. ( parseInt( $( ce ).css( "paddingLeft" ), 10 ) || 0 ) - this.margins.left,
  5245. co.top + ( parseInt( $( ce ).css( "borderTopWidth" ), 10 ) || 0 ) +
  5246. ( parseInt( $( ce ).css( "paddingTop" ), 10 ) || 0 ) - this.margins.top,
  5247. co.left + ( over ? Math.max( ce.scrollWidth, ce.offsetWidth ) : ce.offsetWidth ) -
  5248. ( parseInt( $( ce ).css( "borderLeftWidth" ), 10 ) || 0 ) -
  5249. ( parseInt( $( ce ).css( "paddingRight" ), 10 ) || 0 ) -
  5250. this.helperProportions.width - this.margins.left,
  5251. co.top + ( over ? Math.max( ce.scrollHeight, ce.offsetHeight ) : ce.offsetHeight ) -
  5252. ( parseInt( $( ce ).css( "borderTopWidth" ), 10 ) || 0 ) -
  5253. ( parseInt( $( ce ).css( "paddingBottom" ), 10 ) || 0 ) -
  5254. this.helperProportions.height - this.margins.top
  5255. ];
  5256. }
  5257. },
  5258. _convertPositionTo: function( d, pos ) {
  5259. if ( !pos ) {
  5260. pos = this.position;
  5261. }
  5262. var mod = d === "absolute" ? 1 : -1,
  5263. scroll = this.cssPosition === "absolute" &&
  5264. !( this.scrollParent[ 0 ] !== this.document[ 0 ] &&
  5265. $.contains( this.scrollParent[ 0 ], this.offsetParent[ 0 ] ) ) ?
  5266. this.offsetParent :
  5267. this.scrollParent,
  5268. scrollIsRootNode = ( /(html|body)/i ).test( scroll[ 0 ].tagName );
  5269. return {
  5270. top: (
  5271. // The absolute mouse position
  5272. pos.top +
  5273. // Only for relative positioned nodes: Relative offset from element to offset parent
  5274. this.offset.relative.top * mod +
  5275. // The offsetParent's offset without borders (offset + border)
  5276. this.offset.parent.top * mod -
  5277. ( ( this.cssPosition === "fixed" ?
  5278. -this.scrollParent.scrollTop() :
  5279. ( scrollIsRootNode ? 0 : scroll.scrollTop() ) ) * mod )
  5280. ),
  5281. left: (
  5282. // The absolute mouse position
  5283. pos.left +
  5284. // Only for relative positioned nodes: Relative offset from element to offset parent
  5285. this.offset.relative.left * mod +
  5286. // The offsetParent's offset without borders (offset + border)
  5287. this.offset.parent.left * mod -
  5288. ( ( this.cssPosition === "fixed" ?
  5289. -this.scrollParent.scrollLeft() : scrollIsRootNode ? 0 :
  5290. scroll.scrollLeft() ) * mod )
  5291. )
  5292. };
  5293. },
  5294. _generatePosition: function( event ) {
  5295. var top, left,
  5296. o = this.options,
  5297. pageX = event.pageX,
  5298. pageY = event.pageY,
  5299. scroll = this.cssPosition === "absolute" &&
  5300. !( this.scrollParent[ 0 ] !== this.document[ 0 ] &&
  5301. $.contains( this.scrollParent[ 0 ], this.offsetParent[ 0 ] ) ) ?
  5302. this.offsetParent :
  5303. this.scrollParent,
  5304. scrollIsRootNode = ( /(html|body)/i ).test( scroll[ 0 ].tagName );
  5305. // This is another very weird special case that only happens for relative elements:
  5306. // 1. If the css position is relative
  5307. // 2. and the scroll parent is the document or similar to the offset parent
  5308. // we have to refresh the relative offset during the scroll so there are no jumps
  5309. if ( this.cssPosition === "relative" && !( this.scrollParent[ 0 ] !== this.document[ 0 ] &&
  5310. this.scrollParent[ 0 ] !== this.offsetParent[ 0 ] ) ) {
  5311. this.offset.relative = this._getRelativeOffset();
  5312. }
  5313. /*
  5314. * - Position constraining -
  5315. * Constrain the position to a mix of grid, containment.
  5316. */
  5317. if ( this.originalPosition ) { //If we are not dragging yet, we won't check for options
  5318. if ( this.containment ) {
  5319. if ( event.pageX - this.offset.click.left < this.containment[ 0 ] ) {
  5320. pageX = this.containment[ 0 ] + this.offset.click.left;
  5321. }
  5322. if ( event.pageY - this.offset.click.top < this.containment[ 1 ] ) {
  5323. pageY = this.containment[ 1 ] + this.offset.click.top;
  5324. }
  5325. if ( event.pageX - this.offset.click.left > this.containment[ 2 ] ) {
  5326. pageX = this.containment[ 2 ] + this.offset.click.left;
  5327. }
  5328. if ( event.pageY - this.offset.click.top > this.containment[ 3 ] ) {
  5329. pageY = this.containment[ 3 ] + this.offset.click.top;
  5330. }
  5331. }
  5332. if ( o.grid ) {
  5333. top = this.originalPageY + Math.round( ( pageY - this.originalPageY ) /
  5334. o.grid[ 1 ] ) * o.grid[ 1 ];
  5335. pageY = this.containment ?
  5336. ( ( top - this.offset.click.top >= this.containment[ 1 ] &&
  5337. top - this.offset.click.top <= this.containment[ 3 ] ) ?
  5338. top :
  5339. ( ( top - this.offset.click.top >= this.containment[ 1 ] ) ?
  5340. top - o.grid[ 1 ] : top + o.grid[ 1 ] ) ) :
  5341. top;
  5342. left = this.originalPageX + Math.round( ( pageX - this.originalPageX ) /
  5343. o.grid[ 0 ] ) * o.grid[ 0 ];
  5344. pageX = this.containment ?
  5345. ( ( left - this.offset.click.left >= this.containment[ 0 ] &&
  5346. left - this.offset.click.left <= this.containment[ 2 ] ) ?
  5347. left :
  5348. ( ( left - this.offset.click.left >= this.containment[ 0 ] ) ?
  5349. left - o.grid[ 0 ] : left + o.grid[ 0 ] ) ) :
  5350. left;
  5351. }
  5352. }
  5353. return {
  5354. top: (
  5355. // The absolute mouse position
  5356. pageY -
  5357. // Click offset (relative to the element)
  5358. this.offset.click.top -
  5359. // Only for relative positioned nodes: Relative offset from element to offset parent
  5360. this.offset.relative.top -
  5361. // The offsetParent's offset without borders (offset + border)
  5362. this.offset.parent.top +
  5363. ( ( this.cssPosition === "fixed" ?
  5364. -this.scrollParent.scrollTop() :
  5365. ( scrollIsRootNode ? 0 : scroll.scrollTop() ) ) )
  5366. ),
  5367. left: (
  5368. // The absolute mouse position
  5369. pageX -
  5370. // Click offset (relative to the element)
  5371. this.offset.click.left -
  5372. // Only for relative positioned nodes: Relative offset from element to offset parent
  5373. this.offset.relative.left -
  5374. // The offsetParent's offset without borders (offset + border)
  5375. this.offset.parent.left +
  5376. ( ( this.cssPosition === "fixed" ?
  5377. -this.scrollParent.scrollLeft() :
  5378. scrollIsRootNode ? 0 : scroll.scrollLeft() ) )
  5379. )
  5380. };
  5381. },
  5382. _rearrange: function( event, i, a, hardRefresh ) {
  5383. a ? a[ 0 ].appendChild( this.placeholder[ 0 ] ) :
  5384. i.item[ 0 ].parentNode.insertBefore( this.placeholder[ 0 ],
  5385. ( this.direction === "down" ? i.item[ 0 ] : i.item[ 0 ].nextSibling ) );
  5386. //Various things done here to improve the performance:
  5387. // 1. we create a setTimeout, that calls refreshPositions
  5388. // 2. on the instance, we have a counter variable, that get's higher after every append
  5389. // 3. on the local scope, we copy the counter variable, and check in the timeout,
  5390. // if it's still the same
  5391. // 4. this lets only the last addition to the timeout stack through
  5392. this.counter = this.counter ? ++this.counter : 1;
  5393. var counter = this.counter;
  5394. this._delay( function() {
  5395. if ( counter === this.counter ) {
  5396. //Precompute after each DOM insertion, NOT on mousemove
  5397. this.refreshPositions( !hardRefresh );
  5398. }
  5399. } );
  5400. },
  5401. _clear: function( event, noPropagation ) {
  5402. this.reverting = false;
  5403. // We delay all events that have to be triggered to after the point where the placeholder
  5404. // has been removed and everything else normalized again
  5405. var i,
  5406. delayedTriggers = [];
  5407. // We first have to update the dom position of the actual currentItem
  5408. // Note: don't do it if the current item is already removed (by a user), or it gets
  5409. // reappended (see #4088)
  5410. if ( !this._noFinalSort && this.currentItem.parent().length ) {
  5411. this.placeholder.before( this.currentItem );
  5412. }
  5413. this._noFinalSort = null;
  5414. if ( this.helper[ 0 ] === this.currentItem[ 0 ] ) {
  5415. for ( i in this._storedCSS ) {
  5416. if ( this._storedCSS[ i ] === "auto" || this._storedCSS[ i ] === "static" ) {
  5417. this._storedCSS[ i ] = "";
  5418. }
  5419. }
  5420. this.currentItem.css( this._storedCSS );
  5421. this._removeClass( this.currentItem, "ui-sortable-helper" );
  5422. } else {
  5423. this.currentItem.show();
  5424. }
  5425. if ( this.fromOutside && !noPropagation ) {
  5426. delayedTriggers.push( function( event ) {
  5427. this._trigger( "receive", event, this._uiHash( this.fromOutside ) );
  5428. } );
  5429. }
  5430. if ( ( this.fromOutside ||
  5431. this.domPosition.prev !==
  5432. this.currentItem.prev().not( ".ui-sortable-helper" )[ 0 ] ||
  5433. this.domPosition.parent !== this.currentItem.parent()[ 0 ] ) && !noPropagation ) {
  5434. // Trigger update callback if the DOM position has changed
  5435. delayedTriggers.push( function( event ) {
  5436. this._trigger( "update", event, this._uiHash() );
  5437. } );
  5438. }
  5439. // Check if the items Container has Changed and trigger appropriate
  5440. // events.
  5441. if ( this !== this.currentContainer ) {
  5442. if ( !noPropagation ) {
  5443. delayedTriggers.push( function( event ) {
  5444. this._trigger( "remove", event, this._uiHash() );
  5445. } );
  5446. delayedTriggers.push( ( function( c ) {
  5447. return function( event ) {
  5448. c._trigger( "receive", event, this._uiHash( this ) );
  5449. };
  5450. } ).call( this, this.currentContainer ) );
  5451. delayedTriggers.push( ( function( c ) {
  5452. return function( event ) {
  5453. c._trigger( "update", event, this._uiHash( this ) );
  5454. };
  5455. } ).call( this, this.currentContainer ) );
  5456. }
  5457. }
  5458. //Post events to containers
  5459. function delayEvent( type, instance, container ) {
  5460. return function( event ) {
  5461. container._trigger( type, event, instance._uiHash( instance ) );
  5462. };
  5463. }
  5464. for ( i = this.containers.length - 1; i >= 0; i-- ) {
  5465. if ( !noPropagation ) {
  5466. delayedTriggers.push( delayEvent( "deactivate", this, this.containers[ i ] ) );
  5467. }
  5468. if ( this.containers[ i ].containerCache.over ) {
  5469. delayedTriggers.push( delayEvent( "out", this, this.containers[ i ] ) );
  5470. this.containers[ i ].containerCache.over = 0;
  5471. }
  5472. }
  5473. //Do what was originally in plugins
  5474. if ( this.storedCursor ) {
  5475. this.document.find( "body" ).css( "cursor", this.storedCursor );
  5476. this.storedStylesheet.remove();
  5477. }
  5478. if ( this._storedOpacity ) {
  5479. this.helper.css( "opacity", this._storedOpacity );
  5480. }
  5481. if ( this._storedZIndex ) {
  5482. this.helper.css( "zIndex", this._storedZIndex === "auto" ? "" : this._storedZIndex );
  5483. }
  5484. this.dragging = false;
  5485. if ( !noPropagation ) {
  5486. this._trigger( "beforeStop", event, this._uiHash() );
  5487. }
  5488. //$(this.placeholder[0]).remove(); would have been the jQuery way - unfortunately,
  5489. // it unbinds ALL events from the original node!
  5490. this.placeholder[ 0 ].parentNode.removeChild( this.placeholder[ 0 ] );
  5491. if ( !this.cancelHelperRemoval ) {
  5492. if ( this.helper[ 0 ] !== this.currentItem[ 0 ] ) {
  5493. this.helper.remove();
  5494. }
  5495. this.helper = null;
  5496. }
  5497. if ( !noPropagation ) {
  5498. for ( i = 0; i < delayedTriggers.length; i++ ) {
  5499. // Trigger all delayed events
  5500. delayedTriggers[ i ].call( this, event );
  5501. }
  5502. this._trigger( "stop", event, this._uiHash() );
  5503. }
  5504. this.fromOutside = false;
  5505. return !this.cancelHelperRemoval;
  5506. },
  5507. _trigger: function() {
  5508. if ( $.Widget.prototype._trigger.apply( this, arguments ) === false ) {
  5509. this.cancel();
  5510. }
  5511. },
  5512. _uiHash: function( _inst ) {
  5513. var inst = _inst || this;
  5514. return {
  5515. helper: inst.helper,
  5516. placeholder: inst.placeholder || $( [] ),
  5517. position: inst.position,
  5518. originalPosition: inst.originalPosition,
  5519. offset: inst.positionAbs,
  5520. item: inst.currentItem,
  5521. sender: _inst ? _inst.element : null
  5522. };
  5523. }
  5524. } );
  5525. /*!
  5526. * jQuery UI Controlgroup 1.12.1
  5527. * http://jqueryui.com
  5528. *
  5529. * Copyright jQuery Foundation and other contributors
  5530. * Released under the MIT license.
  5531. * http://jquery.org/license
  5532. */
  5533. //>>label: Controlgroup
  5534. //>>group: Widgets
  5535. //>>description: Visually groups form control widgets
  5536. //>>docs: http://api.jqueryui.com/controlgroup/
  5537. //>>demos: http://jqueryui.com/controlgroup/
  5538. //>>css.structure: ../../themes/base/core.css
  5539. //>>css.structure: ../../themes/base/controlgroup.css
  5540. //>>css.theme: ../../themes/base/theme.css
  5541. var controlgroupCornerRegex = /ui-corner-([a-z]){2,6}/g;
  5542. var widgetsControlgroup = $.widget( "ui.controlgroup", {
  5543. version: "1.12.1",
  5544. defaultElement: "<div>",
  5545. options: {
  5546. direction: "horizontal",
  5547. disabled: null,
  5548. onlyVisible: true,
  5549. items: {
  5550. "button": "input[type=button], input[type=submit], input[type=reset], button, a",
  5551. "controlgroupLabel": ".ui-controlgroup-label",
  5552. "checkboxradio": "input[type='checkbox'], input[type='radio']",
  5553. "selectmenu": "select",
  5554. "spinner": ".ui-spinner-input"
  5555. }
  5556. },
  5557. _create: function() {
  5558. this._enhance();
  5559. },
  5560. // To support the enhanced option in jQuery Mobile, we isolate DOM manipulation
  5561. _enhance: function() {
  5562. this.element.attr( "role", "toolbar" );
  5563. this.refresh();
  5564. },
  5565. _destroy: function() {
  5566. this._callChildMethod( "destroy" );
  5567. this.childWidgets.removeData( "ui-controlgroup-data" );
  5568. this.element.removeAttr( "role" );
  5569. if ( this.options.items.controlgroupLabel ) {
  5570. this.element
  5571. .find( this.options.items.controlgroupLabel )
  5572. .find( ".ui-controlgroup-label-contents" )
  5573. .contents().unwrap();
  5574. }
  5575. },
  5576. _initWidgets: function() {
  5577. var that = this,
  5578. childWidgets = [];
  5579. // First we iterate over each of the items options
  5580. $.each( this.options.items, function( widget, selector ) {
  5581. var labels;
  5582. var options = {};
  5583. // Make sure the widget has a selector set
  5584. if ( !selector ) {
  5585. return;
  5586. }
  5587. if ( widget === "controlgroupLabel" ) {
  5588. labels = that.element.find( selector );
  5589. labels.each( function() {
  5590. var element = $( this );
  5591. if ( element.children( ".ui-controlgroup-label-contents" ).length ) {
  5592. return;
  5593. }
  5594. element.contents()
  5595. .wrapAll( "<span class='ui-controlgroup-label-contents'></span>" );
  5596. } );
  5597. that._addClass( labels, null, "ui-widget ui-widget-content ui-state-default" );
  5598. childWidgets = childWidgets.concat( labels.get() );
  5599. return;
  5600. }
  5601. // Make sure the widget actually exists
  5602. if ( !$.fn[ widget ] ) {
  5603. return;
  5604. }
  5605. // We assume everything is in the middle to start because we can't determine
  5606. // first / last elements until all enhancments are done.
  5607. if ( that[ "_" + widget + "Options" ] ) {
  5608. options = that[ "_" + widget + "Options" ]( "middle" );
  5609. } else {
  5610. options = { classes: {} };
  5611. }
  5612. // Find instances of this widget inside controlgroup and init them
  5613. that.element
  5614. .find( selector )
  5615. .each( function() {
  5616. var element = $( this );
  5617. var instance = element[ widget ]( "instance" );
  5618. // We need to clone the default options for this type of widget to avoid
  5619. // polluting the variable options which has a wider scope than a single widget.
  5620. var instanceOptions = $.widget.extend( {}, options );
  5621. // If the button is the child of a spinner ignore it
  5622. // TODO: Find a more generic solution
  5623. if ( widget === "button" && element.parent( ".ui-spinner" ).length ) {
  5624. return;
  5625. }
  5626. // Create the widget if it doesn't exist
  5627. if ( !instance ) {
  5628. instance = element[ widget ]()[ widget ]( "instance" );
  5629. }
  5630. if ( instance ) {
  5631. instanceOptions.classes =
  5632. that._resolveClassesValues( instanceOptions.classes, instance );
  5633. }
  5634. element[ widget ]( instanceOptions );
  5635. // Store an instance of the controlgroup to be able to reference
  5636. // from the outermost element for changing options and refresh
  5637. var widgetElement = element[ widget ]( "widget" );
  5638. $.data( widgetElement[ 0 ], "ui-controlgroup-data",
  5639. instance ? instance : element[ widget ]( "instance" ) );
  5640. childWidgets.push( widgetElement[ 0 ] );
  5641. } );
  5642. } );
  5643. this.childWidgets = $( $.unique( childWidgets ) );
  5644. this._addClass( this.childWidgets, "ui-controlgroup-item" );
  5645. },
  5646. _callChildMethod: function( method ) {
  5647. this.childWidgets.each( function() {
  5648. var element = $( this ),
  5649. data = element.data( "ui-controlgroup-data" );
  5650. if ( data && data[ method ] ) {
  5651. data[ method ]();
  5652. }
  5653. } );
  5654. },
  5655. _updateCornerClass: function( element, position ) {
  5656. var remove = "ui-corner-top ui-corner-bottom ui-corner-left ui-corner-right ui-corner-all";
  5657. var add = this._buildSimpleOptions( position, "label" ).classes.label;
  5658. this._removeClass( element, null, remove );
  5659. this._addClass( element, null, add );
  5660. },
  5661. _buildSimpleOptions: function( position, key ) {
  5662. var direction = this.options.direction === "vertical";
  5663. var result = {
  5664. classes: {}
  5665. };
  5666. result.classes[ key ] = {
  5667. "middle": "",
  5668. "first": "ui-corner-" + ( direction ? "top" : "left" ),
  5669. "last": "ui-corner-" + ( direction ? "bottom" : "right" ),
  5670. "only": "ui-corner-all"
  5671. }[ position ];
  5672. return result;
  5673. },
  5674. _spinnerOptions: function( position ) {
  5675. var options = this._buildSimpleOptions( position, "ui-spinner" );
  5676. options.classes[ "ui-spinner-up" ] = "";
  5677. options.classes[ "ui-spinner-down" ] = "";
  5678. return options;
  5679. },
  5680. _buttonOptions: function( position ) {
  5681. return this._buildSimpleOptions( position, "ui-button" );
  5682. },
  5683. _checkboxradioOptions: function( position ) {
  5684. return this._buildSimpleOptions( position, "ui-checkboxradio-label" );
  5685. },
  5686. _selectmenuOptions: function( position ) {
  5687. var direction = this.options.direction === "vertical";
  5688. return {
  5689. width: direction ? "auto" : false,
  5690. classes: {
  5691. middle: {
  5692. "ui-selectmenu-button-open": "",
  5693. "ui-selectmenu-button-closed": ""
  5694. },
  5695. first: {
  5696. "ui-selectmenu-button-open": "ui-corner-" + ( direction ? "top" : "tl" ),
  5697. "ui-selectmenu-button-closed": "ui-corner-" + ( direction ? "top" : "left" )
  5698. },
  5699. last: {
  5700. "ui-selectmenu-button-open": direction ? "" : "ui-corner-tr",
  5701. "ui-selectmenu-button-closed": "ui-corner-" + ( direction ? "bottom" : "right" )
  5702. },
  5703. only: {
  5704. "ui-selectmenu-button-open": "ui-corner-top",
  5705. "ui-selectmenu-button-closed": "ui-corner-all"
  5706. }
  5707. }[ position ]
  5708. };
  5709. },
  5710. _resolveClassesValues: function( classes, instance ) {
  5711. var result = {};
  5712. $.each( classes, function( key ) {
  5713. var current = instance.options.classes[ key ] || "";
  5714. current = $.trim( current.replace( controlgroupCornerRegex, "" ) );
  5715. result[ key ] = ( current + " " + classes[ key ] ).replace( /\s+/g, " " );
  5716. } );
  5717. return result;
  5718. },
  5719. _setOption: function( key, value ) {
  5720. if ( key === "direction" ) {
  5721. this._removeClass( "ui-controlgroup-" + this.options.direction );
  5722. }
  5723. this._super( key, value );
  5724. if ( key === "disabled" ) {
  5725. this._callChildMethod( value ? "disable" : "enable" );
  5726. return;
  5727. }
  5728. this.refresh();
  5729. },
  5730. refresh: function() {
  5731. var children,
  5732. that = this;
  5733. this._addClass( "ui-controlgroup ui-controlgroup-" + this.options.direction );
  5734. if ( this.options.direction === "horizontal" ) {
  5735. this._addClass( null, "ui-helper-clearfix" );
  5736. }
  5737. this._initWidgets();
  5738. children = this.childWidgets;
  5739. // We filter here because we need to track all childWidgets not just the visible ones
  5740. if ( this.options.onlyVisible ) {
  5741. children = children.filter( ":visible" );
  5742. }
  5743. if ( children.length ) {
  5744. // We do this last because we need to make sure all enhancment is done
  5745. // before determining first and last
  5746. $.each( [ "first", "last" ], function( index, value ) {
  5747. var instance = children[ value ]().data( "ui-controlgroup-data" );
  5748. if ( instance && that[ "_" + instance.widgetName + "Options" ] ) {
  5749. var options = that[ "_" + instance.widgetName + "Options" ](
  5750. children.length === 1 ? "only" : value
  5751. );
  5752. options.classes = that._resolveClassesValues( options.classes, instance );
  5753. instance.element[ instance.widgetName ]( options );
  5754. } else {
  5755. that._updateCornerClass( children[ value ](), value );
  5756. }
  5757. } );
  5758. // Finally call the refresh method on each of the child widgets.
  5759. this._callChildMethod( "refresh" );
  5760. }
  5761. }
  5762. } );
  5763. /*!
  5764. * jQuery UI Checkboxradio 1.12.1
  5765. * http://jqueryui.com
  5766. *
  5767. * Copyright jQuery Foundation and other contributors
  5768. * Released under the MIT license.
  5769. * http://jquery.org/license
  5770. */
  5771. //>>label: Checkboxradio
  5772. //>>group: Widgets
  5773. //>>description: Enhances a form with multiple themeable checkboxes or radio buttons.
  5774. //>>docs: http://api.jqueryui.com/checkboxradio/
  5775. //>>demos: http://jqueryui.com/checkboxradio/
  5776. //>>css.structure: ../../themes/base/core.css
  5777. //>>css.structure: ../../themes/base/button.css
  5778. //>>css.structure: ../../themes/base/checkboxradio.css
  5779. //>>css.theme: ../../themes/base/theme.css
  5780. $.widget( "ui.checkboxradio", [ $.ui.formResetMixin, {
  5781. version: "1.12.1",
  5782. options: {
  5783. disabled: null,
  5784. label: null,
  5785. icon: true,
  5786. classes: {
  5787. "ui-checkboxradio-label": "ui-corner-all",
  5788. "ui-checkboxradio-icon": "ui-corner-all"
  5789. }
  5790. },
  5791. _getCreateOptions: function() {
  5792. var disabled, labels;
  5793. var that = this;
  5794. var options = this._super() || {};
  5795. // We read the type here, because it makes more sense to throw a element type error first,
  5796. // rather then the error for lack of a label. Often if its the wrong type, it
  5797. // won't have a label (e.g. calling on a div, btn, etc)
  5798. this._readType();
  5799. labels = this.element.labels();
  5800. // If there are multiple labels, use the last one
  5801. this.label = $( labels[ labels.length - 1 ] );
  5802. if ( !this.label.length ) {
  5803. $.error( "No label found for checkboxradio widget" );
  5804. }
  5805. this.originalLabel = "";
  5806. // We need to get the label text but this may also need to make sure it does not contain the
  5807. // input itself.
  5808. this.label.contents().not( this.element[ 0 ] ).each( function() {
  5809. // The label contents could be text, html, or a mix. We concat each element to get a
  5810. // string representation of the label, without the input as part of it.
  5811. that.originalLabel += this.nodeType === 3 ? $( this ).text() : this.outerHTML;
  5812. } );
  5813. // Set the label option if we found label text
  5814. if ( this.originalLabel ) {
  5815. options.label = this.originalLabel;
  5816. }
  5817. disabled = this.element[ 0 ].disabled;
  5818. if ( disabled != null ) {
  5819. options.disabled = disabled;
  5820. }
  5821. return options;
  5822. },
  5823. _create: function() {
  5824. var checked = this.element[ 0 ].checked;
  5825. this._bindFormResetHandler();
  5826. if ( this.options.disabled == null ) {
  5827. this.options.disabled = this.element[ 0 ].disabled;
  5828. }
  5829. this._setOption( "disabled", this.options.disabled );
  5830. this._addClass( "ui-checkboxradio", "ui-helper-hidden-accessible" );
  5831. this._addClass( this.label, "ui-checkboxradio-label", "ui-button ui-widget" );
  5832. if ( this.type === "radio" ) {
  5833. this._addClass( this.label, "ui-checkboxradio-radio-label" );
  5834. }
  5835. if ( this.options.label && this.options.label !== this.originalLabel ) {
  5836. this._updateLabel();
  5837. } else if ( this.originalLabel ) {
  5838. this.options.label = this.originalLabel;
  5839. }
  5840. this._enhance();
  5841. if ( checked ) {
  5842. this._addClass( this.label, "ui-checkboxradio-checked", "ui-state-active" );
  5843. if ( this.icon ) {
  5844. this._addClass( this.icon, null, "ui-state-hover" );
  5845. }
  5846. }
  5847. this._on( {
  5848. change: "_toggleClasses",
  5849. focus: function() {
  5850. this._addClass( this.label, null, "ui-state-focus ui-visual-focus" );
  5851. },
  5852. blur: function() {
  5853. this._removeClass( this.label, null, "ui-state-focus ui-visual-focus" );
  5854. }
  5855. } );
  5856. },
  5857. _readType: function() {
  5858. var nodeName = this.element[ 0 ].nodeName.toLowerCase();
  5859. this.type = this.element[ 0 ].type;
  5860. if ( nodeName !== "input" || !/radio|checkbox/.test( this.type ) ) {
  5861. $.error( "Can't create checkboxradio on element.nodeName=" + nodeName +
  5862. " and element.type=" + this.type );
  5863. }
  5864. },
  5865. // Support jQuery Mobile enhanced option
  5866. _enhance: function() {
  5867. this._updateIcon( this.element[ 0 ].checked );
  5868. },
  5869. widget: function() {
  5870. return this.label;
  5871. },
  5872. _getRadioGroup: function() {
  5873. var group;
  5874. var name = this.element[ 0 ].name;
  5875. var nameSelector = "input[name='" + $.ui.escapeSelector( name ) + "']";
  5876. if ( !name ) {
  5877. return $( [] );
  5878. }
  5879. if ( this.form.length ) {
  5880. group = $( this.form[ 0 ].elements ).filter( nameSelector );
  5881. } else {
  5882. // Not inside a form, check all inputs that also are not inside a form
  5883. group = $( nameSelector ).filter( function() {
  5884. return $( this ).form().length === 0;
  5885. } );
  5886. }
  5887. return group.not( this.element );
  5888. },
  5889. _toggleClasses: function() {
  5890. var checked = this.element[ 0 ].checked;
  5891. this._toggleClass( this.label, "ui-checkboxradio-checked", "ui-state-active", checked );
  5892. if ( this.options.icon && this.type === "checkbox" ) {
  5893. this._toggleClass( this.icon, null, "ui-icon-check ui-state-checked", checked )
  5894. ._toggleClass( this.icon, null, "ui-icon-blank", !checked );
  5895. }
  5896. if ( this.type === "radio" ) {
  5897. this._getRadioGroup()
  5898. .each( function() {
  5899. var instance = $( this ).checkboxradio( "instance" );
  5900. if ( instance ) {
  5901. instance._removeClass( instance.label,
  5902. "ui-checkboxradio-checked", "ui-state-active" );
  5903. }
  5904. } );
  5905. }
  5906. },
  5907. _destroy: function() {
  5908. this._unbindFormResetHandler();
  5909. if ( this.icon ) {
  5910. this.icon.remove();
  5911. this.iconSpace.remove();
  5912. }
  5913. },
  5914. _setOption: function( key, value ) {
  5915. // We don't allow the value to be set to nothing
  5916. if ( key === "label" && !value ) {
  5917. return;
  5918. }
  5919. this._super( key, value );
  5920. if ( key === "disabled" ) {
  5921. this._toggleClass( this.label, null, "ui-state-disabled", value );
  5922. this.element[ 0 ].disabled = value;
  5923. // Don't refresh when setting disabled
  5924. return;
  5925. }
  5926. this.refresh();
  5927. },
  5928. _updateIcon: function( checked ) {
  5929. var toAdd = "ui-icon ui-icon-background ";
  5930. if ( this.options.icon ) {
  5931. if ( !this.icon ) {
  5932. this.icon = $( "<span>" );
  5933. this.iconSpace = $( "<span> </span>" );
  5934. this._addClass( this.iconSpace, "ui-checkboxradio-icon-space" );
  5935. }
  5936. if ( this.type === "checkbox" ) {
  5937. toAdd += checked ? "ui-icon-check ui-state-checked" : "ui-icon-blank";
  5938. this._removeClass( this.icon, null, checked ? "ui-icon-blank" : "ui-icon-check" );
  5939. } else {
  5940. toAdd += "ui-icon-blank";
  5941. }
  5942. this._addClass( this.icon, "ui-checkboxradio-icon", toAdd );
  5943. if ( !checked ) {
  5944. this._removeClass( this.icon, null, "ui-icon-check ui-state-checked" );
  5945. }
  5946. this.icon.prependTo( this.label ).after( this.iconSpace );
  5947. } else if ( this.icon !== undefined ) {
  5948. this.icon.remove();
  5949. this.iconSpace.remove();
  5950. delete this.icon;
  5951. }
  5952. },
  5953. _updateLabel: function() {
  5954. // Remove the contents of the label ( minus the icon, icon space, and input )
  5955. var contents = this.label.contents().not( this.element[ 0 ] );
  5956. if ( this.icon ) {
  5957. contents = contents.not( this.icon[ 0 ] );
  5958. }
  5959. if ( this.iconSpace ) {
  5960. contents = contents.not( this.iconSpace[ 0 ] );
  5961. }
  5962. contents.remove();
  5963. this.label.append( this.options.label );
  5964. },
  5965. refresh: function() {
  5966. var checked = this.element[ 0 ].checked,
  5967. isDisabled = this.element[ 0 ].disabled;
  5968. this._updateIcon( checked );
  5969. this._toggleClass( this.label, "ui-checkboxradio-checked", "ui-state-active", checked );
  5970. if ( this.options.label !== null ) {
  5971. this._updateLabel();
  5972. }
  5973. if ( isDisabled !== this.options.disabled ) {
  5974. this._setOptions( { "disabled": isDisabled } );
  5975. }
  5976. }
  5977. } ] );
  5978. var widgetsCheckboxradio = $.ui.checkboxradio;
  5979. /*!
  5980. * jQuery UI Button 1.12.1
  5981. * http://jqueryui.com
  5982. *
  5983. * Copyright jQuery Foundation and other contributors
  5984. * Released under the MIT license.
  5985. * http://jquery.org/license
  5986. */
  5987. //>>label: Button
  5988. //>>group: Widgets
  5989. //>>description: Enhances a form with themeable buttons.
  5990. //>>docs: http://api.jqueryui.com/button/
  5991. //>>demos: http://jqueryui.com/button/
  5992. //>>css.structure: ../../themes/base/core.css
  5993. //>>css.structure: ../../themes/base/button.css
  5994. //>>css.theme: ../../themes/base/theme.css
  5995. $.widget( "ui.button", {
  5996. version: "1.12.1",
  5997. defaultElement: "<button>",
  5998. options: {
  5999. classes: {
  6000. "ui-button": "ui-corner-all"
  6001. },
  6002. disabled: null,
  6003. icon: null,
  6004. iconPosition: "beginning",
  6005. label: null,
  6006. showLabel: true
  6007. },
  6008. _getCreateOptions: function() {
  6009. var disabled,
  6010. // This is to support cases like in jQuery Mobile where the base widget does have
  6011. // an implementation of _getCreateOptions
  6012. options = this._super() || {};
  6013. this.isInput = this.element.is( "input" );
  6014. disabled = this.element[ 0 ].disabled;
  6015. if ( disabled != null ) {
  6016. options.disabled = disabled;
  6017. }
  6018. this.originalLabel = this.isInput ? this.element.val() : this.element.html();
  6019. if ( this.originalLabel ) {
  6020. options.label = this.originalLabel;
  6021. }
  6022. return options;
  6023. },
  6024. _create: function() {
  6025. if ( !this.option.showLabel & !this.options.icon ) {
  6026. this.options.showLabel = true;
  6027. }
  6028. // We have to check the option again here even though we did in _getCreateOptions,
  6029. // because null may have been passed on init which would override what was set in
  6030. // _getCreateOptions
  6031. if ( this.options.disabled == null ) {
  6032. this.options.disabled = this.element[ 0 ].disabled || false;
  6033. }
  6034. this.hasTitle = !!this.element.attr( "title" );
  6035. // Check to see if the label needs to be set or if its already correct
  6036. if ( this.options.label && this.options.label !== this.originalLabel ) {
  6037. if ( this.isInput ) {
  6038. this.element.val( this.options.label );
  6039. } else {
  6040. this.element.html( this.options.label );
  6041. }
  6042. }
  6043. this._addClass( "ui-button", "ui-widget" );
  6044. this._setOption( "disabled", this.options.disabled );
  6045. this._enhance();
  6046. if ( this.element.is( "a" ) ) {
  6047. this._on( {
  6048. "keyup": function( event ) {
  6049. if ( event.keyCode === $.ui.keyCode.SPACE ) {
  6050. event.preventDefault();
  6051. // Support: PhantomJS <= 1.9, IE 8 Only
  6052. // If a native click is available use it so we actually cause navigation
  6053. // otherwise just trigger a click event
  6054. if ( this.element[ 0 ].click ) {
  6055. this.element[ 0 ].click();
  6056. } else {
  6057. this.element.trigger( "click" );
  6058. }
  6059. }
  6060. }
  6061. } );
  6062. }
  6063. },
  6064. _enhance: function() {
  6065. if ( !this.element.is( "button" ) ) {
  6066. this.element.attr( "role", "button" );
  6067. }
  6068. if ( this.options.icon ) {
  6069. this._updateIcon( "icon", this.options.icon );
  6070. this._updateTooltip();
  6071. }
  6072. },
  6073. _updateTooltip: function() {
  6074. this.title = this.element.attr( "title" );
  6075. if ( !this.options.showLabel && !this.title ) {
  6076. this.element.attr( "title", this.options.label );
  6077. }
  6078. },
  6079. _updateIcon: function( option, value ) {
  6080. var icon = option !== "iconPosition",
  6081. position = icon ? this.options.iconPosition : value,
  6082. displayBlock = position === "top" || position === "bottom";
  6083. // Create icon
  6084. if ( !this.icon ) {
  6085. this.icon = $( "<span>" );
  6086. this._addClass( this.icon, "ui-button-icon", "ui-icon" );
  6087. if ( !this.options.showLabel ) {
  6088. this._addClass( "ui-button-icon-only" );
  6089. }
  6090. } else if ( icon ) {
  6091. // If we are updating the icon remove the old icon class
  6092. this._removeClass( this.icon, null, this.options.icon );
  6093. }
  6094. // If we are updating the icon add the new icon class
  6095. if ( icon ) {
  6096. this._addClass( this.icon, null, value );
  6097. }
  6098. this._attachIcon( position );
  6099. // If the icon is on top or bottom we need to add the ui-widget-icon-block class and remove
  6100. // the iconSpace if there is one.
  6101. if ( displayBlock ) {
  6102. this._addClass( this.icon, null, "ui-widget-icon-block" );
  6103. if ( this.iconSpace ) {
  6104. this.iconSpace.remove();
  6105. }
  6106. } else {
  6107. // Position is beginning or end so remove the ui-widget-icon-block class and add the
  6108. // space if it does not exist
  6109. if ( !this.iconSpace ) {
  6110. this.iconSpace = $( "<span> </span>" );
  6111. this._addClass( this.iconSpace, "ui-button-icon-space" );
  6112. }
  6113. this._removeClass( this.icon, null, "ui-wiget-icon-block" );
  6114. this._attachIconSpace( position );
  6115. }
  6116. },
  6117. _destroy: function() {
  6118. this.element.removeAttr( "role" );
  6119. if ( this.icon ) {
  6120. this.icon.remove();
  6121. }
  6122. if ( this.iconSpace ) {
  6123. this.iconSpace.remove();
  6124. }
  6125. if ( !this.hasTitle ) {
  6126. this.element.removeAttr( "title" );
  6127. }
  6128. },
  6129. _attachIconSpace: function( iconPosition ) {
  6130. this.icon[ /^(?:end|bottom)/.test( iconPosition ) ? "before" : "after" ]( this.iconSpace );
  6131. },
  6132. _attachIcon: function( iconPosition ) {
  6133. this.element[ /^(?:end|bottom)/.test( iconPosition ) ? "append" : "prepend" ]( this.icon );
  6134. },
  6135. _setOptions: function( options ) {
  6136. var newShowLabel = options.showLabel === undefined ?
  6137. this.options.showLabel :
  6138. options.showLabel,
  6139. newIcon = options.icon === undefined ? this.options.icon : options.icon;
  6140. if ( !newShowLabel && !newIcon ) {
  6141. options.showLabel = true;
  6142. }
  6143. this._super( options );
  6144. },
  6145. _setOption: function( key, value ) {
  6146. if ( key === "icon" ) {
  6147. if ( value ) {
  6148. this._updateIcon( key, value );
  6149. } else if ( this.icon ) {
  6150. this.icon.remove();
  6151. if ( this.iconSpace ) {
  6152. this.iconSpace.remove();
  6153. }
  6154. }
  6155. }
  6156. if ( key === "iconPosition" ) {
  6157. this._updateIcon( key, value );
  6158. }
  6159. // Make sure we can't end up with a button that has neither text nor icon
  6160. if ( key === "showLabel" ) {
  6161. this._toggleClass( "ui-button-icon-only", null, !value );
  6162. this._updateTooltip();
  6163. }
  6164. if ( key === "label" ) {
  6165. if ( this.isInput ) {
  6166. this.element.val( value );
  6167. } else {
  6168. // If there is an icon, append it, else nothing then append the value
  6169. // this avoids removal of the icon when setting label text
  6170. this.element.html( value );
  6171. if ( this.icon ) {
  6172. this._attachIcon( this.options.iconPosition );
  6173. this._attachIconSpace( this.options.iconPosition );
  6174. }
  6175. }
  6176. }
  6177. this._super( key, value );
  6178. if ( key === "disabled" ) {
  6179. this._toggleClass( null, "ui-state-disabled", value );
  6180. this.element[ 0 ].disabled = value;
  6181. if ( value ) {
  6182. this.element.blur();
  6183. }
  6184. }
  6185. },
  6186. refresh: function() {
  6187. // Make sure to only check disabled if its an element that supports this otherwise
  6188. // check for the disabled class to determine state
  6189. var isDisabled = this.element.is( "input, button" ) ?
  6190. this.element[ 0 ].disabled : this.element.hasClass( "ui-button-disabled" );
  6191. if ( isDisabled !== this.options.disabled ) {
  6192. this._setOptions( { disabled: isDisabled } );
  6193. }
  6194. this._updateTooltip();
  6195. }
  6196. } );
  6197. // DEPRECATED
  6198. if ( $.uiBackCompat !== false ) {
  6199. // Text and Icons options
  6200. $.widget( "ui.button", $.ui.button, {
  6201. options: {
  6202. text: true,
  6203. icons: {
  6204. primary: null,
  6205. secondary: null
  6206. }
  6207. },
  6208. _create: function() {
  6209. if ( this.options.showLabel && !this.options.text ) {
  6210. this.options.showLabel = this.options.text;
  6211. }
  6212. if ( !this.options.showLabel && this.options.text ) {
  6213. this.options.text = this.options.showLabel;
  6214. }
  6215. if ( !this.options.icon && ( this.options.icons.primary ||
  6216. this.options.icons.secondary ) ) {
  6217. if ( this.options.icons.primary ) {
  6218. this.options.icon = this.options.icons.primary;
  6219. } else {
  6220. this.options.icon = this.options.icons.secondary;
  6221. this.options.iconPosition = "end";
  6222. }
  6223. } else if ( this.options.icon ) {
  6224. this.options.icons.primary = this.options.icon;
  6225. }
  6226. this._super();
  6227. },
  6228. _setOption: function( key, value ) {
  6229. if ( key === "text" ) {
  6230. this._super( "showLabel", value );
  6231. return;
  6232. }
  6233. if ( key === "showLabel" ) {
  6234. this.options.text = value;
  6235. }
  6236. if ( key === "icon" ) {
  6237. this.options.icons.primary = value;
  6238. }
  6239. if ( key === "icons" ) {
  6240. if ( value.primary ) {
  6241. this._super( "icon", value.primary );
  6242. this._super( "iconPosition", "beginning" );
  6243. } else if ( value.secondary ) {
  6244. this._super( "icon", value.secondary );
  6245. this._super( "iconPosition", "end" );
  6246. }
  6247. }
  6248. this._superApply( arguments );
  6249. }
  6250. } );
  6251. $.fn.button = ( function( orig ) {
  6252. return function() {
  6253. if ( !this.length || ( this.length && this[ 0 ].tagName !== "INPUT" ) ||
  6254. ( this.length && this[ 0 ].tagName === "INPUT" && (
  6255. this.attr( "type" ) !== "checkbox" && this.attr( "type" ) !== "radio"
  6256. ) ) ) {
  6257. return orig.apply( this, arguments );
  6258. }
  6259. if ( !$.ui.checkboxradio ) {
  6260. $.error( "Checkboxradio widget missing" );
  6261. }
  6262. if ( arguments.length === 0 ) {
  6263. return this.checkboxradio( {
  6264. "icon": false
  6265. } );
  6266. }
  6267. return this.checkboxradio.apply( this, arguments );
  6268. };
  6269. } )( $.fn.button );
  6270. $.fn.buttonset = function() {
  6271. if ( !$.ui.controlgroup ) {
  6272. $.error( "Controlgroup widget missing" );
  6273. }
  6274. if ( arguments[ 0 ] === "option" && arguments[ 1 ] === "items" && arguments[ 2 ] ) {
  6275. return this.controlgroup.apply( this,
  6276. [ arguments[ 0 ], "items.button", arguments[ 2 ] ] );
  6277. }
  6278. if ( arguments[ 0 ] === "option" && arguments[ 1 ] === "items" ) {
  6279. return this.controlgroup.apply( this, [ arguments[ 0 ], "items.button" ] );
  6280. }
  6281. if ( typeof arguments[ 0 ] === "object" && arguments[ 0 ].items ) {
  6282. arguments[ 0 ].items = {
  6283. button: arguments[ 0 ].items
  6284. };
  6285. }
  6286. return this.controlgroup.apply( this, arguments );
  6287. };
  6288. }
  6289. var widgetsButton = $.ui.button;
  6290. // jscs:disable maximumLineLength
  6291. /* jscs:disable requireCamelCaseOrUpperCaseIdentifiers */
  6292. /*!
  6293. * jQuery UI Datepicker 1.12.1
  6294. * http://jqueryui.com
  6295. *
  6296. * Copyright jQuery Foundation and other contributors
  6297. * Released under the MIT license.
  6298. * http://jquery.org/license
  6299. */
  6300. //>>label: Datepicker
  6301. //>>group: Widgets
  6302. //>>description: Displays a calendar from an input or inline for selecting dates.
  6303. //>>docs: http://api.jqueryui.com/datepicker/
  6304. //>>demos: http://jqueryui.com/datepicker/
  6305. //>>css.structure: ../../themes/base/core.css
  6306. //>>css.structure: ../../themes/base/datepicker.css
  6307. //>>css.theme: ../../themes/base/theme.css
  6308. $.extend( $.ui, { datepicker: { version: "1.12.1" } } );
  6309. var datepicker_instActive;
  6310. function datepicker_getZindex( elem ) {
  6311. var position, value;
  6312. while ( elem.length && elem[ 0 ] !== document ) {
  6313. // Ignore z-index if position is set to a value where z-index is ignored by the browser
  6314. // This makes behavior of this function consistent across browsers
  6315. // WebKit always returns auto if the element is positioned
  6316. position = elem.css( "position" );
  6317. if ( position === "absolute" || position === "relative" || position === "fixed" ) {
  6318. // IE returns 0 when zIndex is not specified
  6319. // other browsers return a string
  6320. // we ignore the case of nested elements with an explicit value of 0
  6321. // <div style="z-index: -10;"><div style="z-index: 0;"></div></div>
  6322. value = parseInt( elem.css( "zIndex" ), 10 );
  6323. if ( !isNaN( value ) && value !== 0 ) {
  6324. return value;
  6325. }
  6326. }
  6327. elem = elem.parent();
  6328. }
  6329. return 0;
  6330. }
  6331. /* Date picker manager.
  6332. Use the singleton instance of this class, $.datepicker, to interact with the date picker.
  6333. Settings for (groups of) date pickers are maintained in an instance object,
  6334. allowing multiple different settings on the same page. */
  6335. function Datepicker() {
  6336. this._curInst = null; // The current instance in use
  6337. this._keyEvent = false; // If the last event was a key event
  6338. this._disabledInputs = []; // List of date picker inputs that have been disabled
  6339. this._datepickerShowing = false; // True if the popup picker is showing , false if not
  6340. this._inDialog = false; // True if showing within a "dialog", false if not
  6341. this._mainDivId = "ui-datepicker-div"; // The ID of the main datepicker division
  6342. this._inlineClass = "ui-datepicker-inline"; // The name of the inline marker class
  6343. this._appendClass = "ui-datepicker-append"; // The name of the append marker class
  6344. this._triggerClass = "ui-datepicker-trigger"; // The name of the trigger marker class
  6345. this._dialogClass = "ui-datepicker-dialog"; // The name of the dialog marker class
  6346. this._disableClass = "ui-datepicker-disabled"; // The name of the disabled covering marker class
  6347. this._unselectableClass = "ui-datepicker-unselectable"; // The name of the unselectable cell marker class
  6348. this._currentClass = "ui-datepicker-current-day"; // The name of the current day marker class
  6349. this._dayOverClass = "ui-datepicker-days-cell-over"; // The name of the day hover marker class
  6350. this.regional = []; // Available regional settings, indexed by language code
  6351. this.regional[ "" ] = { // Default regional settings
  6352. closeText: "Hecho", // Display text for close link
  6353. prevText: "", // Display text for previous month link
  6354. nextText: "", // Display text for next month link
  6355. currentText: "Hoy", // Display text for current month link
  6356. monthNames: [ "Enero","Febrero","Marzo","Abril","Mayo","Junio",
  6357. "Julio","Agosto","Septiembre","Octubre","Noviembre","Diciembre" ], // Names of months for drop-down and formatting
  6358. monthNamesShort: [ "Ene", "Feb", "Mar", "Abr", "May", "Jun", "Jul", "Ago", "Sep", "Oct", "Nov", "Dic" ], // For formatting
  6359. dayNames: [ "Domingo", "Lunes", "Martes", "Miércoles", "Jueves", "Viernes", "Sábado" ], // For formatting
  6360. dayNamesShort: [ "Dom", "Lun", "Mar", "Mie", "Jue", "Vie", "Sab" ], // For formatting
  6361. dayNamesMin: [ "Do","Lu","Ma","Mi","Ju","Vi","Sa" ], // Column headings for days starting at Sunday
  6362. weekHeader: "Wk", // Column header for week of the year
  6363. dateFormat: "dd/mm/yy", // See format options on parseDate
  6364. firstDay: 0, // The first day of the week, Sun = 0, Mon = 1, ...
  6365. isRTL: false, // True if right-to-left language, false if left-to-right
  6366. showMonthAfterYear: false, // True if the year select precedes month, false for month then year
  6367. yearSuffix: "" // Additional text to append to the year in the month headers
  6368. };
  6369. this._defaults = { // Global defaults for all the date picker instances
  6370. showOn: "focus", // "focus" for popup on focus,
  6371. // "button" for trigger button, or "both" for either
  6372. showAnim: "fadeIn", // Name of jQuery animation for popup
  6373. showOptions: {}, // Options for enhanced animations
  6374. defaultDate: null, // Used when field is blank: actual date,
  6375. // +/-number for offset from today, null for today
  6376. appendText: "", // Display text following the input box, e.g. showing the format
  6377. buttonText: "...", // Text for trigger button
  6378. buttonImage: "", // URL for trigger button image
  6379. buttonImageOnly: false, // True if the image appears alone, false if it appears on a button
  6380. hideIfNoPrevNext: false, // True to hide next/previous month links
  6381. // if not applicable, false to just disable them
  6382. navigationAsDateFormat: false, // True if date formatting applied to prev/today/next links
  6383. gotoCurrent: false, // True if today link goes back to current selection instead
  6384. changeMonth: false, // True if month can be selected directly, false if only prev/next
  6385. changeYear: false, // True if year can be selected directly, false if only prev/next
  6386. yearRange: "c-10:c+10", // Range of years to display in drop-down,
  6387. // either relative to today's year (-nn:+nn), relative to currently displayed year
  6388. // (c-nn:c+nn), absolute (nnnn:nnnn), or a combination of the above (nnnn:-n)
  6389. showOtherMonths: false, // True to show dates in other months, false to leave blank
  6390. selectOtherMonths: false, // True to allow selection of dates in other months, false for unselectable
  6391. showWeek: false, // True to show week of the year, false to not show it
  6392. calculateWeek: this.iso8601Week, // How to calculate the week of the year,
  6393. // takes a Date and returns the number of the week for it
  6394. shortYearCutoff: "+10", // Short year values < this are in the current century,
  6395. // > this are in the previous century,
  6396. // string value starting with "+" for current year + value
  6397. minDate: null, // The earliest selectable date, or null for no limit
  6398. maxDate: null, // The latest selectable date, or null for no limit
  6399. duration: "fast", // Duration of display/closure
  6400. beforeShowDay: null, // Function that takes a date and returns an array with
  6401. // [0] = true if selectable, false if not, [1] = custom CSS class name(s) or "",
  6402. // [2] = cell title (optional), e.g. $.datepicker.noWeekends
  6403. beforeShow: null, // Function that takes an input field and
  6404. // returns a set of custom settings for the date picker
  6405. onSelect: null, // Define a callback function when a date is selected
  6406. onChangeMonthYear: null, // Define a callback function when the month or year is changed
  6407. onClose: null, // Define a callback function when the datepicker is closed
  6408. numberOfMonths: 1, // Number of months to show at a time
  6409. showCurrentAtPos: 0, // The position in multipe months at which to show the current month (starting at 0)
  6410. stepMonths: 1, // Number of months to step back/forward
  6411. stepBigMonths: 12, // Number of months to step back/forward for the big links
  6412. altField: "", // Selector for an alternate field to store selected dates into
  6413. altFormat: "", // The date format to use for the alternate field
  6414. constrainInput: true, // The input is constrained by the current date format
  6415. showButtonPanel: false, // True to show button panel, false to not show it
  6416. autoSize: false, // True to size the input for the date format, false to leave as is
  6417. disabled: false // The initial disabled state
  6418. };
  6419. $.extend( this._defaults, this.regional[ "" ] );
  6420. this.regional.en = $.extend( true, {}, this.regional[ "" ] );
  6421. this.regional[ "en-US" ] = $.extend( true, {}, this.regional.en );
  6422. this.dpDiv = datepicker_bindHover( $( "<div id='" + this._mainDivId + "' class='ui-datepicker ui-widget ui-widget-content ui-helper-clearfix ui-corner-all'></div>" ) );
  6423. }
  6424. $.extend( Datepicker.prototype, {
  6425. /* Class name added to elements to indicate already configured with a date picker. */
  6426. markerClassName: "hasDatepicker",
  6427. //Keep track of the maximum number of rows displayed (see #7043)
  6428. maxRows: 4,
  6429. // TODO rename to "widget" when switching to widget factory
  6430. _widgetDatepicker: function() {
  6431. return this.dpDiv;
  6432. },
  6433. /* Override the default settings for all instances of the date picker.
  6434. * @param settings object - the new settings to use as defaults (anonymous object)
  6435. * @return the manager object
  6436. */
  6437. setDefaults: function( settings ) {
  6438. datepicker_extendRemove( this._defaults, settings || {} );
  6439. return this;
  6440. },
  6441. /* Attach the date picker to a jQuery selection.
  6442. * @param target element - the target input field or division or span
  6443. * @param settings object - the new settings to use for this date picker instance (anonymous)
  6444. */
  6445. _attachDatepicker: function( target, settings ) {
  6446. var nodeName, inline, inst;
  6447. nodeName = target.nodeName.toLowerCase();
  6448. inline = ( nodeName === "div" || nodeName === "span" );
  6449. if ( !target.id ) {
  6450. this.uuid += 1;
  6451. target.id = "dp" + this.uuid;
  6452. }
  6453. inst = this._newInst( $( target ), inline );
  6454. inst.settings = $.extend( {}, settings || {} );
  6455. if ( nodeName === "input" ) {
  6456. this._connectDatepicker( target, inst );
  6457. } else if ( inline ) {
  6458. this._inlineDatepicker( target, inst );
  6459. }
  6460. },
  6461. /* Create a new instance object. */
  6462. _newInst: function( target, inline ) {
  6463. var id = target[ 0 ].id.replace( /([^A-Za-z0-9_\-])/g, "\\\\$1" ); // escape jQuery meta chars
  6464. return { id: id, input: target, // associated target
  6465. selectedDay: 0, selectedMonth: 0, selectedYear: 0, // current selection
  6466. drawMonth: 0, drawYear: 0, // month being drawn
  6467. inline: inline, // is datepicker inline or not
  6468. dpDiv: ( !inline ? this.dpDiv : // presentation div
  6469. datepicker_bindHover( $( "<div class='" + this._inlineClass + " ui-datepicker ui-widget ui-widget-content ui-helper-clearfix ui-corner-all'></div>" ) ) ) };
  6470. },
  6471. /* Attach the date picker to an input field. */
  6472. _connectDatepicker: function( target, inst ) {
  6473. var input = $( target );
  6474. inst.append = $( [] );
  6475. inst.trigger = $( [] );
  6476. if ( input.hasClass( this.markerClassName ) ) {
  6477. return;
  6478. }
  6479. this._attachments( input, inst );
  6480. input.addClass( this.markerClassName ).on( "keydown", this._doKeyDown ).
  6481. on( "keypress", this._doKeyPress ).on( "keyup", this._doKeyUp );
  6482. this._autoSize( inst );
  6483. $.data( target, "datepicker", inst );
  6484. //If disabled option is true, disable the datepicker once it has been attached to the input (see ticket #5665)
  6485. if ( inst.settings.disabled ) {
  6486. this._disableDatepicker( target );
  6487. }
  6488. },
  6489. /* Make attachments based on settings. */
  6490. _attachments: function( input, inst ) {
  6491. var showOn, buttonText, buttonImage,
  6492. appendText = this._get( inst, "appendText" ),
  6493. isRTL = this._get( inst, "isRTL" );
  6494. if ( inst.append ) {
  6495. inst.append.remove();
  6496. }
  6497. if ( appendText ) {
  6498. inst.append = $( "<span class='" + this._appendClass + "'>" + appendText + "</span>" );
  6499. input[ isRTL ? "before" : "after" ]( inst.append );
  6500. }
  6501. input.off( "focus", this._showDatepicker );
  6502. if ( inst.trigger ) {
  6503. inst.trigger.remove();
  6504. }
  6505. showOn = this._get( inst, "showOn" );
  6506. if ( showOn === "focus" || showOn === "both" ) { // pop-up date picker when in the marked field
  6507. input.on( "focus", this._showDatepicker );
  6508. }
  6509. if ( showOn === "button" || showOn === "both" ) { // pop-up date picker when button clicked
  6510. buttonText = this._get( inst, "buttonText" );
  6511. buttonImage = this._get( inst, "buttonImage" );
  6512. inst.trigger = $( this._get( inst, "buttonImageOnly" ) ?
  6513. $( "<img/>" ).addClass( this._triggerClass ).
  6514. attr( { src: buttonImage, alt: buttonText, title: buttonText } ) :
  6515. $( "<button type='button'></button>" ).addClass( this._triggerClass ).
  6516. html( !buttonImage ? buttonText : $( "<img/>" ).attr(
  6517. { src:buttonImage, alt:buttonText, title:buttonText } ) ) );
  6518. input[ isRTL ? "before" : "after" ]( inst.trigger );
  6519. inst.trigger.on( "click", function() {
  6520. if ( $.datepicker._datepickerShowing && $.datepicker._lastInput === input[ 0 ] ) {
  6521. $.datepicker._hideDatepicker();
  6522. } else if ( $.datepicker._datepickerShowing && $.datepicker._lastInput !== input[ 0 ] ) {
  6523. $.datepicker._hideDatepicker();
  6524. $.datepicker._showDatepicker( input[ 0 ] );
  6525. } else {
  6526. $.datepicker._showDatepicker( input[ 0 ] );
  6527. }
  6528. return false;
  6529. } );
  6530. }
  6531. },
  6532. /* Apply the maximum length for the date format. */
  6533. _autoSize: function( inst ) {
  6534. if ( this._get( inst, "autoSize" ) && !inst.inline ) {
  6535. var findMax, max, maxI, i,
  6536. date = new Date( 2009, 12 - 1, 20 ), // Ensure double digits
  6537. dateFormat = this._get( inst, "dateFormat" );
  6538. if ( dateFormat.match( /[DM]/ ) ) {
  6539. findMax = function( names ) {
  6540. max = 0;
  6541. maxI = 0;
  6542. for ( i = 0; i < names.length; i++ ) {
  6543. if ( names[ i ].length > max ) {
  6544. max = names[ i ].length;
  6545. maxI = i;
  6546. }
  6547. }
  6548. return maxI;
  6549. };
  6550. date.setMonth( findMax( this._get( inst, ( dateFormat.match( /MM/ ) ?
  6551. "monthNames" : "monthNamesShort" ) ) ) );
  6552. date.setDate( findMax( this._get( inst, ( dateFormat.match( /DD/ ) ?
  6553. "dayNames" : "dayNamesShort" ) ) ) + 20 - date.getDay() );
  6554. }
  6555. inst.input.attr( "size", this._formatDate( inst, date ).length );
  6556. }
  6557. },
  6558. /* Attach an inline date picker to a div. */
  6559. _inlineDatepicker: function( target, inst ) {
  6560. var divSpan = $( target );
  6561. if ( divSpan.hasClass( this.markerClassName ) ) {
  6562. return;
  6563. }
  6564. divSpan.addClass( this.markerClassName ).append( inst.dpDiv );
  6565. $.data( target, "datepicker", inst );
  6566. this._setDate( inst, this._getDefaultDate( inst ), true );
  6567. this._updateDatepicker( inst );
  6568. this._updateAlternate( inst );
  6569. //If disabled option is true, disable the datepicker before showing it (see ticket #5665)
  6570. if ( inst.settings.disabled ) {
  6571. this._disableDatepicker( target );
  6572. }
  6573. // Set display:block in place of inst.dpDiv.show() which won't work on disconnected elements
  6574. // http://bugs.jqueryui.com/ticket/7552 - A Datepicker created on a detached div has zero height
  6575. inst.dpDiv.css( "display", "block" );
  6576. },
  6577. /* Pop-up the date picker in a "dialog" box.
  6578. * @param input element - ignored
  6579. * @param date string or Date - the initial date to display
  6580. * @param onSelect function - the function to call when a date is selected
  6581. * @param settings object - update the dialog date picker instance's settings (anonymous object)
  6582. * @param pos int[2] - coordinates for the dialog's position within the screen or
  6583. * event - with x/y coordinates or
  6584. * leave empty for default (screen centre)
  6585. * @return the manager object
  6586. */
  6587. _dialogDatepicker: function( input, date, onSelect, settings, pos ) {
  6588. var id, browserWidth, browserHeight, scrollX, scrollY,
  6589. inst = this._dialogInst; // internal instance
  6590. if ( !inst ) {
  6591. this.uuid += 1;
  6592. id = "dp" + this.uuid;
  6593. this._dialogInput = $( "<input type='text' id='" + id +
  6594. "' style='position: absolute; top: -100px; width: 0px;'/>" );
  6595. this._dialogInput.on( "keydown", this._doKeyDown );
  6596. $( "body" ).append( this._dialogInput );
  6597. inst = this._dialogInst = this._newInst( this._dialogInput, false );
  6598. inst.settings = {};
  6599. $.data( this._dialogInput[ 0 ], "datepicker", inst );
  6600. }
  6601. datepicker_extendRemove( inst.settings, settings || {} );
  6602. date = ( date && date.constructor === Date ? this._formatDate( inst, date ) : date );
  6603. this._dialogInput.val( date );
  6604. this._pos = ( pos ? ( pos.length ? pos : [ pos.pageX, pos.pageY ] ) : null );
  6605. if ( !this._pos ) {
  6606. browserWidth = document.documentElement.clientWidth;
  6607. browserHeight = document.documentElement.clientHeight;
  6608. scrollX = document.documentElement.scrollLeft || document.body.scrollLeft;
  6609. scrollY = document.documentElement.scrollTop || document.body.scrollTop;
  6610. this._pos = // should use actual width/height below
  6611. [ ( browserWidth / 2 ) - 100 + scrollX, ( browserHeight / 2 ) - 150 + scrollY ];
  6612. }
  6613. // Move input on screen for focus, but hidden behind dialog
  6614. this._dialogInput.css( "left", ( this._pos[ 0 ] + 20 ) + "px" ).css( "top", this._pos[ 1 ] + "px" );
  6615. inst.settings.onSelect = onSelect;
  6616. this._inDialog = true;
  6617. this.dpDiv.addClass( this._dialogClass );
  6618. this._showDatepicker( this._dialogInput[ 0 ] );
  6619. if ( $.blockUI ) {
  6620. $.blockUI( this.dpDiv );
  6621. }
  6622. $.data( this._dialogInput[ 0 ], "datepicker", inst );
  6623. return this;
  6624. },
  6625. /* Detach a datepicker from its control.
  6626. * @param target element - the target input field or division or span
  6627. */
  6628. _destroyDatepicker: function( target ) {
  6629. var nodeName,
  6630. $target = $( target ),
  6631. inst = $.data( target, "datepicker" );
  6632. if ( !$target.hasClass( this.markerClassName ) ) {
  6633. return;
  6634. }
  6635. nodeName = target.nodeName.toLowerCase();
  6636. $.removeData( target, "datepicker" );
  6637. if ( nodeName === "input" ) {
  6638. inst.append.remove();
  6639. inst.trigger.remove();
  6640. $target.removeClass( this.markerClassName ).
  6641. off( "focus", this._showDatepicker ).
  6642. off( "keydown", this._doKeyDown ).
  6643. off( "keypress", this._doKeyPress ).
  6644. off( "keyup", this._doKeyUp );
  6645. } else if ( nodeName === "div" || nodeName === "span" ) {
  6646. $target.removeClass( this.markerClassName ).empty();
  6647. }
  6648. if ( datepicker_instActive === inst ) {
  6649. datepicker_instActive = null;
  6650. }
  6651. },
  6652. /* Enable the date picker to a jQuery selection.
  6653. * @param target element - the target input field or division or span
  6654. */
  6655. _enableDatepicker: function( target ) {
  6656. var nodeName, inline,
  6657. $target = $( target ),
  6658. inst = $.data( target, "datepicker" );
  6659. if ( !$target.hasClass( this.markerClassName ) ) {
  6660. return;
  6661. }
  6662. nodeName = target.nodeName.toLowerCase();
  6663. if ( nodeName === "input" ) {
  6664. target.disabled = false;
  6665. inst.trigger.filter( "button" ).
  6666. each( function() { this.disabled = false; } ).end().
  6667. filter( "img" ).css( { opacity: "1.0", cursor: "" } );
  6668. } else if ( nodeName === "div" || nodeName === "span" ) {
  6669. inline = $target.children( "." + this._inlineClass );
  6670. inline.children().removeClass( "ui-state-disabled" );
  6671. inline.find( "select.ui-datepicker-month, select.ui-datepicker-year" ).
  6672. prop( "disabled", false );
  6673. }
  6674. this._disabledInputs = $.map( this._disabledInputs,
  6675. function( value ) { return ( value === target ? null : value ); } ); // delete entry
  6676. },
  6677. /* Disable the date picker to a jQuery selection.
  6678. * @param target element - the target input field or division or span
  6679. */
  6680. _disableDatepicker: function( target ) {
  6681. var nodeName, inline,
  6682. $target = $( target ),
  6683. inst = $.data( target, "datepicker" );
  6684. if ( !$target.hasClass( this.markerClassName ) ) {
  6685. return;
  6686. }
  6687. nodeName = target.nodeName.toLowerCase();
  6688. if ( nodeName === "input" ) {
  6689. target.disabled = true;
  6690. inst.trigger.filter( "button" ).
  6691. each( function() { this.disabled = true; } ).end().
  6692. filter( "img" ).css( { opacity: "0.5", cursor: "default" } );
  6693. } else if ( nodeName === "div" || nodeName === "span" ) {
  6694. inline = $target.children( "." + this._inlineClass );
  6695. inline.children().addClass( "ui-state-disabled" );
  6696. inline.find( "select.ui-datepicker-month, select.ui-datepicker-year" ).
  6697. prop( "disabled", true );
  6698. }
  6699. this._disabledInputs = $.map( this._disabledInputs,
  6700. function( value ) { return ( value === target ? null : value ); } ); // delete entry
  6701. this._disabledInputs[ this._disabledInputs.length ] = target;
  6702. },
  6703. /* Is the first field in a jQuery collection disabled as a datepicker?
  6704. * @param target element - the target input field or division or span
  6705. * @return boolean - true if disabled, false if enabled
  6706. */
  6707. _isDisabledDatepicker: function( target ) {
  6708. if ( !target ) {
  6709. return false;
  6710. }
  6711. for ( var i = 0; i < this._disabledInputs.length; i++ ) {
  6712. if ( this._disabledInputs[ i ] === target ) {
  6713. return true;
  6714. }
  6715. }
  6716. return false;
  6717. },
  6718. /* Retrieve the instance data for the target control.
  6719. * @param target element - the target input field or division or span
  6720. * @return object - the associated instance data
  6721. * @throws error if a jQuery problem getting data
  6722. */
  6723. _getInst: function( target ) {
  6724. try {
  6725. return $.data( target, "datepicker" );
  6726. }
  6727. catch ( err ) {
  6728. throw "Missing instance data for this datepicker";
  6729. }
  6730. },
  6731. /* Update or retrieve the settings for a date picker attached to an input field or division.
  6732. * @param target element - the target input field or division or span
  6733. * @param name object - the new settings to update or
  6734. * string - the name of the setting to change or retrieve,
  6735. * when retrieving also "all" for all instance settings or
  6736. * "defaults" for all global defaults
  6737. * @param value any - the new value for the setting
  6738. * (omit if above is an object or to retrieve a value)
  6739. */
  6740. _optionDatepicker: function( target, name, value ) {
  6741. var settings, date, minDate, maxDate,
  6742. inst = this._getInst( target );
  6743. if ( arguments.length === 2 && typeof name === "string" ) {
  6744. return ( name === "defaults" ? $.extend( {}, $.datepicker._defaults ) :
  6745. ( inst ? ( name === "all" ? $.extend( {}, inst.settings ) :
  6746. this._get( inst, name ) ) : null ) );
  6747. }
  6748. settings = name || {};
  6749. if ( typeof name === "string" ) {
  6750. settings = {};
  6751. settings[ name ] = value;
  6752. }
  6753. if ( inst ) {
  6754. if ( this._curInst === inst ) {
  6755. this._hideDatepicker();
  6756. }
  6757. date = this._getDateDatepicker( target, true );
  6758. minDate = this._getMinMaxDate( inst, "min" );
  6759. maxDate = this._getMinMaxDate( inst, "max" );
  6760. datepicker_extendRemove( inst.settings, settings );
  6761. // reformat the old minDate/maxDate values if dateFormat changes and a new minDate/maxDate isn't provided
  6762. if ( minDate !== null && settings.dateFormat !== undefined && settings.minDate === undefined ) {
  6763. inst.settings.minDate = this._formatDate( inst, minDate );
  6764. }
  6765. if ( maxDate !== null && settings.dateFormat !== undefined && settings.maxDate === undefined ) {
  6766. inst.settings.maxDate = this._formatDate( inst, maxDate );
  6767. }
  6768. if ( "disabled" in settings ) {
  6769. if ( settings.disabled ) {
  6770. this._disableDatepicker( target );
  6771. } else {
  6772. this._enableDatepicker( target );
  6773. }
  6774. }
  6775. this._attachments( $( target ), inst );
  6776. this._autoSize( inst );
  6777. this._setDate( inst, date );
  6778. this._updateAlternate( inst );
  6779. this._updateDatepicker( inst );
  6780. }
  6781. },
  6782. // Change method deprecated
  6783. _changeDatepicker: function( target, name, value ) {
  6784. this._optionDatepicker( target, name, value );
  6785. },
  6786. /* Redraw the date picker attached to an input field or division.
  6787. * @param target element - the target input field or division or span
  6788. */
  6789. _refreshDatepicker: function( target ) {
  6790. var inst = this._getInst( target );
  6791. if ( inst ) {
  6792. this._updateDatepicker( inst );
  6793. }
  6794. },
  6795. /* Set the dates for a jQuery selection.
  6796. * @param target element - the target input field or division or span
  6797. * @param date Date - the new date
  6798. */
  6799. _setDateDatepicker: function( target, date ) {
  6800. var inst = this._getInst( target );
  6801. if ( inst ) {
  6802. this._setDate( inst, date );
  6803. this._updateDatepicker( inst );
  6804. this._updateAlternate( inst );
  6805. }
  6806. },
  6807. /* Get the date(s) for the first entry in a jQuery selection.
  6808. * @param target element - the target input field or division or span
  6809. * @param noDefault boolean - true if no default date is to be used
  6810. * @return Date - the current date
  6811. */
  6812. _getDateDatepicker: function( target, noDefault ) {
  6813. var inst = this._getInst( target );
  6814. if ( inst && !inst.inline ) {
  6815. this._setDateFromField( inst, noDefault );
  6816. }
  6817. return ( inst ? this._getDate( inst ) : null );
  6818. },
  6819. /* Handle keystrokes. */
  6820. _doKeyDown: function( event ) {
  6821. var onSelect, dateStr, sel,
  6822. inst = $.datepicker._getInst( event.target ),
  6823. handled = true,
  6824. isRTL = inst.dpDiv.is( ".ui-datepicker-rtl" );
  6825. inst._keyEvent = true;
  6826. if ( $.datepicker._datepickerShowing ) {
  6827. switch ( event.keyCode ) {
  6828. case 9: $.datepicker._hideDatepicker();
  6829. handled = false;
  6830. break; // hide on tab out
  6831. case 13: sel = $( "td." + $.datepicker._dayOverClass + ":not(." +
  6832. $.datepicker._currentClass + ")", inst.dpDiv );
  6833. if ( sel[ 0 ] ) {
  6834. $.datepicker._selectDay( event.target, inst.selectedMonth, inst.selectedYear, sel[ 0 ] );
  6835. }
  6836. onSelect = $.datepicker._get( inst, "onSelect" );
  6837. if ( onSelect ) {
  6838. dateStr = $.datepicker._formatDate( inst );
  6839. // Trigger custom callback
  6840. onSelect.apply( ( inst.input ? inst.input[ 0 ] : null ), [ dateStr, inst ] );
  6841. } else {
  6842. $.datepicker._hideDatepicker();
  6843. }
  6844. return false; // don't submit the form
  6845. case 27: $.datepicker._hideDatepicker();
  6846. break; // hide on escape
  6847. case 33: $.datepicker._adjustDate( event.target, ( event.ctrlKey ?
  6848. -$.datepicker._get( inst, "stepBigMonths" ) :
  6849. -$.datepicker._get( inst, "stepMonths" ) ), "M" );
  6850. break; // previous month/year on page up/+ ctrl
  6851. case 34: $.datepicker._adjustDate( event.target, ( event.ctrlKey ?
  6852. +$.datepicker._get( inst, "stepBigMonths" ) :
  6853. +$.datepicker._get( inst, "stepMonths" ) ), "M" );
  6854. break; // next month/year on page down/+ ctrl
  6855. case 35: if ( event.ctrlKey || event.metaKey ) {
  6856. $.datepicker._clearDate( event.target );
  6857. }
  6858. handled = event.ctrlKey || event.metaKey;
  6859. break; // clear on ctrl or command +end
  6860. case 36: if ( event.ctrlKey || event.metaKey ) {
  6861. $.datepicker._gotoToday( event.target );
  6862. }
  6863. handled = event.ctrlKey || event.metaKey;
  6864. break; // current on ctrl or command +home
  6865. case 37: if ( event.ctrlKey || event.metaKey ) {
  6866. $.datepicker._adjustDate( event.target, ( isRTL ? +1 : -1 ), "D" );
  6867. }
  6868. handled = event.ctrlKey || event.metaKey;
  6869. // -1 day on ctrl or command +left
  6870. if ( event.originalEvent.altKey ) {
  6871. $.datepicker._adjustDate( event.target, ( event.ctrlKey ?
  6872. -$.datepicker._get( inst, "stepBigMonths" ) :
  6873. -$.datepicker._get( inst, "stepMonths" ) ), "M" );
  6874. }
  6875. // next month/year on alt +left on Mac
  6876. break;
  6877. case 38: if ( event.ctrlKey || event.metaKey ) {
  6878. $.datepicker._adjustDate( event.target, -7, "D" );
  6879. }
  6880. handled = event.ctrlKey || event.metaKey;
  6881. break; // -1 week on ctrl or command +up
  6882. case 39: if ( event.ctrlKey || event.metaKey ) {
  6883. $.datepicker._adjustDate( event.target, ( isRTL ? -1 : +1 ), "D" );
  6884. }
  6885. handled = event.ctrlKey || event.metaKey;
  6886. // +1 day on ctrl or command +right
  6887. if ( event.originalEvent.altKey ) {
  6888. $.datepicker._adjustDate( event.target, ( event.ctrlKey ?
  6889. +$.datepicker._get( inst, "stepBigMonths" ) :
  6890. +$.datepicker._get( inst, "stepMonths" ) ), "M" );
  6891. }
  6892. // next month/year on alt +right
  6893. break;
  6894. case 40: if ( event.ctrlKey || event.metaKey ) {
  6895. $.datepicker._adjustDate( event.target, +7, "D" );
  6896. }
  6897. handled = event.ctrlKey || event.metaKey;
  6898. break; // +1 week on ctrl or command +down
  6899. default: handled = false;
  6900. }
  6901. } else if ( event.keyCode === 36 && event.ctrlKey ) { // display the date picker on ctrl+home
  6902. $.datepicker._showDatepicker( this );
  6903. } else {
  6904. handled = false;
  6905. }
  6906. if ( handled ) {
  6907. event.preventDefault();
  6908. event.stopPropagation();
  6909. }
  6910. },
  6911. /* Filter entered characters - based on date format. */
  6912. _doKeyPress: function( event ) {
  6913. var chars, chr,
  6914. inst = $.datepicker._getInst( event.target );
  6915. if ( $.datepicker._get( inst, "constrainInput" ) ) {
  6916. chars = $.datepicker._possibleChars( $.datepicker._get( inst, "dateFormat" ) );
  6917. chr = String.fromCharCode( event.charCode == null ? event.keyCode : event.charCode );
  6918. return event.ctrlKey || event.metaKey || ( chr < " " || !chars || chars.indexOf( chr ) > -1 );
  6919. }
  6920. },
  6921. /* Synchronise manual entry and field/alternate field. */
  6922. _doKeyUp: function( event ) {
  6923. var date,
  6924. inst = $.datepicker._getInst( event.target );
  6925. if ( inst.input.val() !== inst.lastVal ) {
  6926. try {
  6927. date = $.datepicker.parseDate( $.datepicker._get( inst, "dateFormat" ),
  6928. ( inst.input ? inst.input.val() : null ),
  6929. $.datepicker._getFormatConfig( inst ) );
  6930. if ( date ) { // only if valid
  6931. $.datepicker._setDateFromField( inst );
  6932. $.datepicker._updateAlternate( inst );
  6933. $.datepicker._updateDatepicker( inst );
  6934. }
  6935. }
  6936. catch ( err ) {
  6937. }
  6938. }
  6939. return true;
  6940. },
  6941. /* Pop-up the date picker for a given input field.
  6942. * If false returned from beforeShow event handler do not show.
  6943. * @param input element - the input field attached to the date picker or
  6944. * event - if triggered by focus
  6945. */
  6946. _showDatepicker: function( input ) {
  6947. input = input.target || input;
  6948. if ( input.nodeName.toLowerCase() !== "input" ) { // find from button/image trigger
  6949. input = $( "input", input.parentNode )[ 0 ];
  6950. }
  6951. if ( $.datepicker._isDisabledDatepicker( input ) || $.datepicker._lastInput === input ) { // already here
  6952. return;
  6953. }
  6954. var inst, beforeShow, beforeShowSettings, isFixed,
  6955. offset, showAnim, duration;
  6956. inst = $.datepicker._getInst( input );
  6957. if ( $.datepicker._curInst && $.datepicker._curInst !== inst ) {
  6958. $.datepicker._curInst.dpDiv.stop( true, true );
  6959. if ( inst && $.datepicker._datepickerShowing ) {
  6960. $.datepicker._hideDatepicker( $.datepicker._curInst.input[ 0 ] );
  6961. }
  6962. }
  6963. beforeShow = $.datepicker._get( inst, "beforeShow" );
  6964. beforeShowSettings = beforeShow ? beforeShow.apply( input, [ input, inst ] ) : {};
  6965. if ( beforeShowSettings === false ) {
  6966. return;
  6967. }
  6968. datepicker_extendRemove( inst.settings, beforeShowSettings );
  6969. inst.lastVal = null;
  6970. $.datepicker._lastInput = input;
  6971. $.datepicker._setDateFromField( inst );
  6972. if ( $.datepicker._inDialog ) { // hide cursor
  6973. input.value = "";
  6974. }
  6975. if ( !$.datepicker._pos ) { // position below input
  6976. $.datepicker._pos = $.datepicker._findPos( input );
  6977. $.datepicker._pos[ 1 ] += input.offsetHeight; // add the height
  6978. }
  6979. isFixed = false;
  6980. $( input ).parents().each( function() {
  6981. isFixed |= $( this ).css( "position" ) === "fixed";
  6982. return !isFixed;
  6983. } );
  6984. offset = { left: $.datepicker._pos[ 0 ], top: $.datepicker._pos[ 1 ] };
  6985. $.datepicker._pos = null;
  6986. //to avoid flashes on Firefox
  6987. inst.dpDiv.empty();
  6988. // determine sizing offscreen
  6989. inst.dpDiv.css( { position: "absolute", display: "block", top: "-1000px" } );
  6990. $.datepicker._updateDatepicker( inst );
  6991. // fix width for dynamic number of date pickers
  6992. // and adjust position before showing
  6993. offset = $.datepicker._checkOffset( inst, offset, isFixed );
  6994. inst.dpDiv.css( { position: ( $.datepicker._inDialog && $.blockUI ?
  6995. "static" : ( isFixed ? "fixed" : "absolute" ) ), display: "none",
  6996. left: offset.left + "px", top: offset.top + "px" } );
  6997. if ( !inst.inline ) {
  6998. showAnim = $.datepicker._get( inst, "showAnim" );
  6999. duration = $.datepicker._get( inst, "duration" );
  7000. inst.dpDiv.css( "z-index", datepicker_getZindex( $( input ) ) + 1 );
  7001. $.datepicker._datepickerShowing = true;
  7002. if ( $.effects && $.effects.effect[ showAnim ] ) {
  7003. inst.dpDiv.show( showAnim, $.datepicker._get( inst, "showOptions" ), duration );
  7004. } else {
  7005. inst.dpDiv[ showAnim || "show" ]( showAnim ? duration : null );
  7006. }
  7007. if ( $.datepicker._shouldFocusInput( inst ) ) {
  7008. inst.input.trigger( "focus" );
  7009. }
  7010. $.datepicker._curInst = inst;
  7011. }
  7012. },
  7013. /* Generate the date picker content. */
  7014. _updateDatepicker: function( inst ) {
  7015. this.maxRows = 4; //Reset the max number of rows being displayed (see #7043)
  7016. datepicker_instActive = inst; // for delegate hover events
  7017. inst.dpDiv.empty().append( this._generateHTML( inst ) );
  7018. this._attachHandlers( inst );
  7019. var origyearshtml,
  7020. numMonths = this._getNumberOfMonths( inst ),
  7021. cols = numMonths[ 1 ],
  7022. width = 17,
  7023. activeCell = inst.dpDiv.find( "." + this._dayOverClass + " a" );
  7024. if ( activeCell.length > 0 ) {
  7025. datepicker_handleMouseover.apply( activeCell.get( 0 ) );
  7026. }
  7027. inst.dpDiv.removeClass( "ui-datepicker-multi-2 ui-datepicker-multi-3 ui-datepicker-multi-4" ).width( "" );
  7028. if ( cols > 1 ) {
  7029. inst.dpDiv.addClass( "ui-datepicker-multi-" + cols ).css( "width", ( width * cols ) + "em" );
  7030. }
  7031. inst.dpDiv[ ( numMonths[ 0 ] !== 1 || numMonths[ 1 ] !== 1 ? "add" : "remove" ) +
  7032. "Class" ]( "ui-datepicker-multi" );
  7033. inst.dpDiv[ ( this._get( inst, "isRTL" ) ? "add" : "remove" ) +
  7034. "Class" ]( "ui-datepicker-rtl" );
  7035. if ( inst === $.datepicker._curInst && $.datepicker._datepickerShowing && $.datepicker._shouldFocusInput( inst ) ) {
  7036. inst.input.trigger( "focus" );
  7037. }
  7038. // Deffered render of the years select (to avoid flashes on Firefox)
  7039. if ( inst.yearshtml ) {
  7040. origyearshtml = inst.yearshtml;
  7041. setTimeout( function() {
  7042. //assure that inst.yearshtml didn't change.
  7043. if ( origyearshtml === inst.yearshtml && inst.yearshtml ) {
  7044. inst.dpDiv.find( "select.ui-datepicker-year:first" ).replaceWith( inst.yearshtml );
  7045. }
  7046. origyearshtml = inst.yearshtml = null;
  7047. }, 0 );
  7048. }
  7049. },
  7050. // #6694 - don't focus the input if it's already focused
  7051. // this breaks the change event in IE
  7052. // Support: IE and jQuery <1.9
  7053. _shouldFocusInput: function( inst ) {
  7054. return inst.input && inst.input.is( ":visible" ) && !inst.input.is( ":disabled" ) && !inst.input.is( ":focus" );
  7055. },
  7056. /* Check positioning to remain on screen. */
  7057. _checkOffset: function( inst, offset, isFixed ) {
  7058. var dpWidth = inst.dpDiv.outerWidth(),
  7059. dpHeight = inst.dpDiv.outerHeight(),
  7060. inputWidth = inst.input ? inst.input.outerWidth() : 0,
  7061. inputHeight = inst.input ? inst.input.outerHeight() : 0,
  7062. viewWidth = document.documentElement.clientWidth + ( isFixed ? 0 : $( document ).scrollLeft() ),
  7063. viewHeight = document.documentElement.clientHeight + ( isFixed ? 0 : $( document ).scrollTop() );
  7064. offset.left -= ( this._get( inst, "isRTL" ) ? ( dpWidth - inputWidth ) : 0 );
  7065. offset.left -= ( isFixed && offset.left === inst.input.offset().left ) ? $( document ).scrollLeft() : 0;
  7066. offset.top -= ( isFixed && offset.top === ( inst.input.offset().top + inputHeight ) ) ? $( document ).scrollTop() : 0;
  7067. // Now check if datepicker is showing outside window viewport - move to a better place if so.
  7068. offset.left -= Math.min( offset.left, ( offset.left + dpWidth > viewWidth && viewWidth > dpWidth ) ?
  7069. Math.abs( offset.left + dpWidth - viewWidth ) : 0 );
  7070. offset.top -= Math.min( offset.top, ( offset.top + dpHeight > viewHeight && viewHeight > dpHeight ) ?
  7071. Math.abs( dpHeight + inputHeight ) : 0 );
  7072. return offset;
  7073. },
  7074. /* Find an object's position on the screen. */
  7075. _findPos: function( obj ) {
  7076. var position,
  7077. inst = this._getInst( obj ),
  7078. isRTL = this._get( inst, "isRTL" );
  7079. while ( obj && ( obj.type === "hidden" || obj.nodeType !== 1 || $.expr.filters.hidden( obj ) ) ) {
  7080. obj = obj[ isRTL ? "previousSibling" : "nextSibling" ];
  7081. }
  7082. position = $( obj ).offset();
  7083. return [ position.left, position.top ];
  7084. },
  7085. /* Hide the date picker from view.
  7086. * @param input element - the input field attached to the date picker
  7087. */
  7088. _hideDatepicker: function( input ) {
  7089. var showAnim, duration, postProcess, onClose,
  7090. inst = this._curInst;
  7091. if ( !inst || ( input && inst !== $.data( input, "datepicker" ) ) ) {
  7092. return;
  7093. }
  7094. if ( this._datepickerShowing ) {
  7095. showAnim = this._get( inst, "showAnim" );
  7096. duration = this._get( inst, "duration" );
  7097. postProcess = function() {
  7098. $.datepicker._tidyDialog( inst );
  7099. };
  7100. // DEPRECATED: after BC for 1.8.x $.effects[ showAnim ] is not needed
  7101. if ( $.effects && ( $.effects.effect[ showAnim ] || $.effects[ showAnim ] ) ) {
  7102. inst.dpDiv.hide( showAnim, $.datepicker._get( inst, "showOptions" ), duration, postProcess );
  7103. } else {
  7104. inst.dpDiv[ ( showAnim === "slideDown" ? "slideUp" :
  7105. ( showAnim === "fadeIn" ? "fadeOut" : "hide" ) ) ]( ( showAnim ? duration : null ), postProcess );
  7106. }
  7107. if ( !showAnim ) {
  7108. postProcess();
  7109. }
  7110. this._datepickerShowing = false;
  7111. onClose = this._get( inst, "onClose" );
  7112. if ( onClose ) {
  7113. onClose.apply( ( inst.input ? inst.input[ 0 ] : null ), [ ( inst.input ? inst.input.val() : "" ), inst ] );
  7114. }
  7115. this._lastInput = null;
  7116. if ( this._inDialog ) {
  7117. this._dialogInput.css( { position: "absolute", left: "0", top: "-100px" } );
  7118. if ( $.blockUI ) {
  7119. $.unblockUI();
  7120. $( "body" ).append( this.dpDiv );
  7121. }
  7122. }
  7123. this._inDialog = false;
  7124. }
  7125. },
  7126. /* Tidy up after a dialog display. */
  7127. _tidyDialog: function( inst ) {
  7128. inst.dpDiv.removeClass( this._dialogClass ).off( ".ui-datepicker-calendar" );
  7129. },
  7130. /* Close date picker if clicked elsewhere. */
  7131. _checkExternalClick: function( event ) {
  7132. if ( !$.datepicker._curInst ) {
  7133. return;
  7134. }
  7135. var $target = $( event.target ),
  7136. inst = $.datepicker._getInst( $target[ 0 ] );
  7137. if ( ( ( $target[ 0 ].id !== $.datepicker._mainDivId &&
  7138. $target.parents( "#" + $.datepicker._mainDivId ).length === 0 &&
  7139. !$target.hasClass( $.datepicker.markerClassName ) &&
  7140. !$target.closest( "." + $.datepicker._triggerClass ).length &&
  7141. $.datepicker._datepickerShowing && !( $.datepicker._inDialog && $.blockUI ) ) ) ||
  7142. ( $target.hasClass( $.datepicker.markerClassName ) && $.datepicker._curInst !== inst ) ) {
  7143. $.datepicker._hideDatepicker();
  7144. }
  7145. },
  7146. /* Adjust one of the date sub-fields. */
  7147. _adjustDate: function( id, offset, period ) {
  7148. var target = $( id ),
  7149. inst = this._getInst( target[ 0 ] );
  7150. if ( this._isDisabledDatepicker( target[ 0 ] ) ) {
  7151. return;
  7152. }
  7153. this._adjustInstDate( inst, offset +
  7154. ( period === "M" ? this._get( inst, "showCurrentAtPos" ) : 0 ), // undo positioning
  7155. period );
  7156. this._updateDatepicker( inst );
  7157. },
  7158. /* Action for current link. */
  7159. _gotoToday: function( id ) {
  7160. var date,
  7161. target = $( id ),
  7162. inst = this._getInst( target[ 0 ] );
  7163. if ( this._get( inst, "gotoCurrent" ) && inst.currentDay ) {
  7164. inst.selectedDay = inst.currentDay;
  7165. inst.drawMonth = inst.selectedMonth = inst.currentMonth;
  7166. inst.drawYear = inst.selectedYear = inst.currentYear;
  7167. } else {
  7168. date = new Date();
  7169. inst.selectedDay = date.getDate();
  7170. inst.drawMonth = inst.selectedMonth = date.getMonth();
  7171. inst.drawYear = inst.selectedYear = date.getFullYear();
  7172. }
  7173. this._notifyChange( inst );
  7174. this._adjustDate( target );
  7175. },
  7176. /* Action for selecting a new month/year. */
  7177. _selectMonthYear: function( id, select, period ) {
  7178. var target = $( id ),
  7179. inst = this._getInst( target[ 0 ] );
  7180. inst[ "selected" + ( period === "M" ? "Month" : "Year" ) ] =
  7181. inst[ "draw" + ( period === "M" ? "Month" : "Year" ) ] =
  7182. parseInt( select.options[ select.selectedIndex ].value, 10 );
  7183. this._notifyChange( inst );
  7184. this._adjustDate( target );
  7185. },
  7186. /* Action for selecting a day. */
  7187. _selectDay: function( id, month, year, td ) {
  7188. var inst,
  7189. target = $( id );
  7190. if ( $( td ).hasClass( this._unselectableClass ) || this._isDisabledDatepicker( target[ 0 ] ) ) {
  7191. return;
  7192. }
  7193. inst = this._getInst( target[ 0 ] );
  7194. inst.selectedDay = inst.currentDay = $( "a", td ).html();
  7195. inst.selectedMonth = inst.currentMonth = month;
  7196. inst.selectedYear = inst.currentYear = year;
  7197. this._selectDate( id, this._formatDate( inst,
  7198. inst.currentDay, inst.currentMonth, inst.currentYear ) );
  7199. },
  7200. /* Erase the input field and hide the date picker. */
  7201. _clearDate: function( id ) {
  7202. var target = $( id );
  7203. this._selectDate( target, "" );
  7204. },
  7205. /* Update the input field with the selected date. */
  7206. _selectDate: function( id, dateStr ) {
  7207. var onSelect,
  7208. target = $( id ),
  7209. inst = this._getInst( target[ 0 ] );
  7210. dateStr = ( dateStr != null ? dateStr : this._formatDate( inst ) );
  7211. if ( inst.input ) {
  7212. inst.input.val( dateStr );
  7213. }
  7214. this._updateAlternate( inst );
  7215. onSelect = this._get( inst, "onSelect" );
  7216. if ( onSelect ) {
  7217. onSelect.apply( ( inst.input ? inst.input[ 0 ] : null ), [ dateStr, inst ] ); // trigger custom callback
  7218. } else if ( inst.input ) {
  7219. inst.input.trigger( "change" ); // fire the change event
  7220. }
  7221. if ( inst.inline ) {
  7222. this._updateDatepicker( inst );
  7223. } else {
  7224. this._hideDatepicker();
  7225. this._lastInput = inst.input[ 0 ];
  7226. if ( typeof( inst.input[ 0 ] ) !== "object" ) {
  7227. inst.input.trigger( "focus" ); // restore focus
  7228. }
  7229. this._lastInput = null;
  7230. }
  7231. },
  7232. /* Update any alternate field to synchronise with the main field. */
  7233. _updateAlternate: function( inst ) {
  7234. var altFormat, date, dateStr,
  7235. altField = this._get( inst, "altField" );
  7236. if ( altField ) { // update alternate field too
  7237. altFormat = this._get( inst, "altFormat" ) || this._get( inst, "dateFormat" );
  7238. date = this._getDate( inst );
  7239. dateStr = this.formatDate( altFormat, date, this._getFormatConfig( inst ) );
  7240. $( altField ).val( dateStr );
  7241. }
  7242. },
  7243. /* Set as beforeShowDay function to prevent selection of weekends.
  7244. * @param date Date - the date to customise
  7245. * @return [boolean, string] - is this date selectable?, what is its CSS class?
  7246. */
  7247. noWeekends: function( date ) {
  7248. var day = date.getDay();
  7249. return [ ( day > 0 && day < 6 ), "" ];
  7250. },
  7251. /* Set as calculateWeek to determine the week of the year based on the ISO 8601 definition.
  7252. * @param date Date - the date to get the week for
  7253. * @return number - the number of the week within the year that contains this date
  7254. */
  7255. iso8601Week: function( date ) {
  7256. var time,
  7257. checkDate = new Date( date.getTime() );
  7258. // Find Thursday of this week starting on Monday
  7259. checkDate.setDate( checkDate.getDate() + 4 - ( checkDate.getDay() || 7 ) );
  7260. time = checkDate.getTime();
  7261. checkDate.setMonth( 0 ); // Compare with Jan 1
  7262. checkDate.setDate( 1 );
  7263. return Math.floor( Math.round( ( time - checkDate ) / 86400000 ) / 7 ) + 1;
  7264. },
  7265. /* Parse a string value into a date object.
  7266. * See formatDate below for the possible formats.
  7267. *
  7268. * @param format string - the expected format of the date
  7269. * @param value string - the date in the above format
  7270. * @param settings Object - attributes include:
  7271. * shortYearCutoff number - the cutoff year for determining the century (optional)
  7272. * dayNamesShort string[7] - abbreviated names of the days from Sunday (optional)
  7273. * dayNames string[7] - names of the days from Sunday (optional)
  7274. * monthNamesShort string[12] - abbreviated names of the months (optional)
  7275. * monthNames string[12] - names of the months (optional)
  7276. * @return Date - the extracted date value or null if value is blank
  7277. */
  7278. parseDate: function( format, value, settings ) {
  7279. if ( format == null || value == null ) {
  7280. throw "Invalid arguments";
  7281. }
  7282. value = ( typeof value === "object" ? value.toString() : value + "" );
  7283. if ( value === "" ) {
  7284. return null;
  7285. }
  7286. var iFormat, dim, extra,
  7287. iValue = 0,
  7288. shortYearCutoffTemp = ( settings ? settings.shortYearCutoff : null ) || this._defaults.shortYearCutoff,
  7289. shortYearCutoff = ( typeof shortYearCutoffTemp !== "string" ? shortYearCutoffTemp :
  7290. new Date().getFullYear() % 100 + parseInt( shortYearCutoffTemp, 10 ) ),
  7291. dayNamesShort = ( settings ? settings.dayNamesShort : null ) || this._defaults.dayNamesShort,
  7292. dayNames = ( settings ? settings.dayNames : null ) || this._defaults.dayNames,
  7293. monthNamesShort = ( settings ? settings.monthNamesShort : null ) || this._defaults.monthNamesShort,
  7294. monthNames = ( settings ? settings.monthNames : null ) || this._defaults.monthNames,
  7295. year = -1,
  7296. month = -1,
  7297. day = -1,
  7298. doy = -1,
  7299. literal = false,
  7300. date,
  7301. // Check whether a format character is doubled
  7302. lookAhead = function( match ) {
  7303. var matches = ( iFormat + 1 < format.length && format.charAt( iFormat + 1 ) === match );
  7304. if ( matches ) {
  7305. iFormat++;
  7306. }
  7307. return matches;
  7308. },
  7309. // Extract a number from the string value
  7310. getNumber = function( match ) {
  7311. var isDoubled = lookAhead( match ),
  7312. size = ( match === "@" ? 14 : ( match === "!" ? 20 :
  7313. ( match === "y" && isDoubled ? 4 : ( match === "o" ? 3 : 2 ) ) ) ),
  7314. minSize = ( match === "y" ? size : 1 ),
  7315. digits = new RegExp( "^\\d{" + minSize + "," + size + "}" ),
  7316. num = value.substring( iValue ).match( digits );
  7317. if ( !num ) {
  7318. throw "Missing number at position " + iValue;
  7319. }
  7320. iValue += num[ 0 ].length;
  7321. return parseInt( num[ 0 ], 10 );
  7322. },
  7323. // Extract a name from the string value and convert to an index
  7324. getName = function( match, shortNames, longNames ) {
  7325. var index = -1,
  7326. names = $.map( lookAhead( match ) ? longNames : shortNames, function( v, k ) {
  7327. return [ [ k, v ] ];
  7328. } ).sort( function( a, b ) {
  7329. return -( a[ 1 ].length - b[ 1 ].length );
  7330. } );
  7331. $.each( names, function( i, pair ) {
  7332. var name = pair[ 1 ];
  7333. if ( value.substr( iValue, name.length ).toLowerCase() === name.toLowerCase() ) {
  7334. index = pair[ 0 ];
  7335. iValue += name.length;
  7336. return false;
  7337. }
  7338. } );
  7339. if ( index !== -1 ) {
  7340. return index + 1;
  7341. } else {
  7342. throw "Unknown name at position " + iValue;
  7343. }
  7344. },
  7345. // Confirm that a literal character matches the string value
  7346. checkLiteral = function() {
  7347. if ( value.charAt( iValue ) !== format.charAt( iFormat ) ) {
  7348. throw "Unexpected literal at position " + iValue;
  7349. }
  7350. iValue++;
  7351. };
  7352. for ( iFormat = 0; iFormat < format.length; iFormat++ ) {
  7353. if ( literal ) {
  7354. if ( format.charAt( iFormat ) === "'" && !lookAhead( "'" ) ) {
  7355. literal = false;
  7356. } else {
  7357. checkLiteral();
  7358. }
  7359. } else {
  7360. switch ( format.charAt( iFormat ) ) {
  7361. case "d":
  7362. day = getNumber( "d" );
  7363. break;
  7364. case "D":
  7365. getName( "D", dayNamesShort, dayNames );
  7366. break;
  7367. case "o":
  7368. doy = getNumber( "o" );
  7369. break;
  7370. case "m":
  7371. month = getNumber( "m" );
  7372. break;
  7373. case "M":
  7374. month = getName( "M", monthNamesShort, monthNames );
  7375. break;
  7376. case "y":
  7377. year = getNumber( "y" );
  7378. break;
  7379. case "@":
  7380. date = new Date( getNumber( "@" ) );
  7381. year = date.getFullYear();
  7382. month = date.getMonth() + 1;
  7383. day = date.getDate();
  7384. break;
  7385. case "!":
  7386. date = new Date( ( getNumber( "!" ) - this._ticksTo1970 ) / 10000 );
  7387. year = date.getFullYear();
  7388. month = date.getMonth() + 1;
  7389. day = date.getDate();
  7390. break;
  7391. case "'":
  7392. if ( lookAhead( "'" ) ) {
  7393. checkLiteral();
  7394. } else {
  7395. literal = true;
  7396. }
  7397. break;
  7398. default:
  7399. checkLiteral();
  7400. }
  7401. }
  7402. }
  7403. if ( iValue < value.length ) {
  7404. extra = value.substr( iValue );
  7405. if ( !/^\s+/.test( extra ) ) {
  7406. throw "Extra/unparsed characters found in date: " + extra;
  7407. }
  7408. }
  7409. if ( year === -1 ) {
  7410. year = new Date().getFullYear();
  7411. } else if ( year < 100 ) {
  7412. year += new Date().getFullYear() - new Date().getFullYear() % 100 +
  7413. ( year <= shortYearCutoff ? 0 : -100 );
  7414. }
  7415. if ( doy > -1 ) {
  7416. month = 1;
  7417. day = doy;
  7418. do {
  7419. dim = this._getDaysInMonth( year, month - 1 );
  7420. if ( day <= dim ) {
  7421. break;
  7422. }
  7423. month++;
  7424. day -= dim;
  7425. } while ( true );
  7426. }
  7427. date = this._daylightSavingAdjust( new Date( year, month - 1, day ) );
  7428. if ( date.getFullYear() !== year || date.getMonth() + 1 !== month || date.getDate() !== day ) {
  7429. throw "Invalid date"; // E.g. 31/02/00
  7430. }
  7431. return date;
  7432. },
  7433. /* Standard date formats. */
  7434. ATOM: "yy-mm-dd", // RFC 3339 (ISO 8601)
  7435. COOKIE: "D, dd M yy",
  7436. ISO_8601: "yy-mm-dd",
  7437. RFC_822: "D, d M y",
  7438. RFC_850: "DD, dd-M-y",
  7439. RFC_1036: "D, d M y",
  7440. RFC_1123: "D, d M yy",
  7441. RFC_2822: "D, d M yy",
  7442. RSS: "D, d M y", // RFC 822
  7443. TICKS: "!",
  7444. TIMESTAMP: "@",
  7445. W3C: "yy-mm-dd", // ISO 8601
  7446. _ticksTo1970: ( ( ( 1970 - 1 ) * 365 + Math.floor( 1970 / 4 ) - Math.floor( 1970 / 100 ) +
  7447. Math.floor( 1970 / 400 ) ) * 24 * 60 * 60 * 10000000 ),
  7448. /* Format a date object into a string value.
  7449. * The format can be combinations of the following:
  7450. * d - day of month (no leading zero)
  7451. * dd - day of month (two digit)
  7452. * o - day of year (no leading zeros)
  7453. * oo - day of year (three digit)
  7454. * D - day name short
  7455. * DD - day name long
  7456. * m - month of year (no leading zero)
  7457. * mm - month of year (two digit)
  7458. * M - month name short
  7459. * MM - month name long
  7460. * y - year (two digit)
  7461. * yy - year (four digit)
  7462. * @ - Unix timestamp (ms since 01/01/1970)
  7463. * ! - Windows ticks (100ns since 01/01/0001)
  7464. * "..." - literal text
  7465. * '' - single quote
  7466. *
  7467. * @param format string - the desired format of the date
  7468. * @param date Date - the date value to format
  7469. * @param settings Object - attributes include:
  7470. * dayNamesShort string[7] - abbreviated names of the days from Sunday (optional)
  7471. * dayNames string[7] - names of the days from Sunday (optional)
  7472. * monthNamesShort string[12] - abbreviated names of the months (optional)
  7473. * monthNames string[12] - names of the months (optional)
  7474. * @return string - the date in the above format
  7475. */
  7476. formatDate: function( format, date, settings ) {
  7477. if ( !date ) {
  7478. return "";
  7479. }
  7480. var iFormat,
  7481. dayNamesShort = ( settings ? settings.dayNamesShort : null ) || this._defaults.dayNamesShort,
  7482. dayNames = ( settings ? settings.dayNames : null ) || this._defaults.dayNames,
  7483. monthNamesShort = ( settings ? settings.monthNamesShort : null ) || this._defaults.monthNamesShort,
  7484. monthNames = ( settings ? settings.monthNames : null ) || this._defaults.monthNames,
  7485. // Check whether a format character is doubled
  7486. lookAhead = function( match ) {
  7487. var matches = ( iFormat + 1 < format.length && format.charAt( iFormat + 1 ) === match );
  7488. if ( matches ) {
  7489. iFormat++;
  7490. }
  7491. return matches;
  7492. },
  7493. // Format a number, with leading zero if necessary
  7494. formatNumber = function( match, value, len ) {
  7495. var num = "" + value;
  7496. if ( lookAhead( match ) ) {
  7497. while ( num.length < len ) {
  7498. num = "0" + num;
  7499. }
  7500. }
  7501. return num;
  7502. },
  7503. // Format a name, short or long as requested
  7504. formatName = function( match, value, shortNames, longNames ) {
  7505. return ( lookAhead( match ) ? longNames[ value ] : shortNames[ value ] );
  7506. },
  7507. output = "",
  7508. literal = false;
  7509. if ( date ) {
  7510. for ( iFormat = 0; iFormat < format.length; iFormat++ ) {
  7511. if ( literal ) {
  7512. if ( format.charAt( iFormat ) === "'" && !lookAhead( "'" ) ) {
  7513. literal = false;
  7514. } else {
  7515. output += format.charAt( iFormat );
  7516. }
  7517. } else {
  7518. switch ( format.charAt( iFormat ) ) {
  7519. case "d":
  7520. output += formatNumber( "d", date.getDate(), 2 );
  7521. break;
  7522. case "D":
  7523. output += formatName( "D", date.getDay(), dayNamesShort, dayNames );
  7524. break;
  7525. case "o":
  7526. output += formatNumber( "o",
  7527. Math.round( ( new Date( date.getFullYear(), date.getMonth(), date.getDate() ).getTime() - new Date( date.getFullYear(), 0, 0 ).getTime() ) / 86400000 ), 3 );
  7528. break;
  7529. case "m":
  7530. output += formatNumber( "m", date.getMonth() + 1, 2 );
  7531. break;
  7532. case "M":
  7533. output += formatName( "M", date.getMonth(), monthNamesShort, monthNames );
  7534. break;
  7535. case "y":
  7536. output += ( lookAhead( "y" ) ? date.getFullYear() :
  7537. ( date.getFullYear() % 100 < 10 ? "0" : "" ) + date.getFullYear() % 100 );
  7538. break;
  7539. case "@":
  7540. output += date.getTime();
  7541. break;
  7542. case "!":
  7543. output += date.getTime() * 10000 + this._ticksTo1970;
  7544. break;
  7545. case "'":
  7546. if ( lookAhead( "'" ) ) {
  7547. output += "'";
  7548. } else {
  7549. literal = true;
  7550. }
  7551. break;
  7552. default:
  7553. output += format.charAt( iFormat );
  7554. }
  7555. }
  7556. }
  7557. }
  7558. return output;
  7559. },
  7560. /* Extract all possible characters from the date format. */
  7561. _possibleChars: function( format ) {
  7562. var iFormat,
  7563. chars = "",
  7564. literal = false,
  7565. // Check whether a format character is doubled
  7566. lookAhead = function( match ) {
  7567. var matches = ( iFormat + 1 < format.length && format.charAt( iFormat + 1 ) === match );
  7568. if ( matches ) {
  7569. iFormat++;
  7570. }
  7571. return matches;
  7572. };
  7573. for ( iFormat = 0; iFormat < format.length; iFormat++ ) {
  7574. if ( literal ) {
  7575. if ( format.charAt( iFormat ) === "'" && !lookAhead( "'" ) ) {
  7576. literal = false;
  7577. } else {
  7578. chars += format.charAt( iFormat );
  7579. }
  7580. } else {
  7581. switch ( format.charAt( iFormat ) ) {
  7582. case "d": case "m": case "y": case "@":
  7583. chars += "0123456789";
  7584. break;
  7585. case "D": case "M":
  7586. return null; // Accept anything
  7587. case "'":
  7588. if ( lookAhead( "'" ) ) {
  7589. chars += "'";
  7590. } else {
  7591. literal = true;
  7592. }
  7593. break;
  7594. default:
  7595. chars += format.charAt( iFormat );
  7596. }
  7597. }
  7598. }
  7599. return chars;
  7600. },
  7601. /* Get a setting value, defaulting if necessary. */
  7602. _get: function( inst, name ) {
  7603. return inst.settings[ name ] !== undefined ?
  7604. inst.settings[ name ] : this._defaults[ name ];
  7605. },
  7606. /* Parse existing date and initialise date picker. */
  7607. _setDateFromField: function( inst, noDefault ) {
  7608. if ( inst.input.val() === inst.lastVal ) {
  7609. return;
  7610. }
  7611. var dateFormat = this._get( inst, "dateFormat" ),
  7612. dates = inst.lastVal = inst.input ? inst.input.val() : null,
  7613. defaultDate = this._getDefaultDate( inst ),
  7614. date = defaultDate,
  7615. settings = this._getFormatConfig( inst );
  7616. try {
  7617. date = this.parseDate( dateFormat, dates, settings ) || defaultDate;
  7618. } catch ( event ) {
  7619. dates = ( noDefault ? "" : dates );
  7620. }
  7621. inst.selectedDay = date.getDate();
  7622. inst.drawMonth = inst.selectedMonth = date.getMonth();
  7623. inst.drawYear = inst.selectedYear = date.getFullYear();
  7624. inst.currentDay = ( dates ? date.getDate() : 0 );
  7625. inst.currentMonth = ( dates ? date.getMonth() : 0 );
  7626. inst.currentYear = ( dates ? date.getFullYear() : 0 );
  7627. this._adjustInstDate( inst );
  7628. },
  7629. /* Retrieve the default date shown on opening. */
  7630. _getDefaultDate: function( inst ) {
  7631. return this._restrictMinMax( inst,
  7632. this._determineDate( inst, this._get( inst, "defaultDate" ), new Date() ) );
  7633. },
  7634. /* A date may be specified as an exact value or a relative one. */
  7635. _determineDate: function( inst, date, defaultDate ) {
  7636. var offsetNumeric = function( offset ) {
  7637. var date = new Date();
  7638. date.setDate( date.getDate() + offset );
  7639. return date;
  7640. },
  7641. offsetString = function( offset ) {
  7642. try {
  7643. return $.datepicker.parseDate( $.datepicker._get( inst, "dateFormat" ),
  7644. offset, $.datepicker._getFormatConfig( inst ) );
  7645. }
  7646. catch ( e ) {
  7647. // Ignore
  7648. }
  7649. var date = ( offset.toLowerCase().match( /^c/ ) ?
  7650. $.datepicker._getDate( inst ) : null ) || new Date(),
  7651. year = date.getFullYear(),
  7652. month = date.getMonth(),
  7653. day = date.getDate(),
  7654. pattern = /([+\-]?[0-9]+)\s*(d|D|w|W|m|M|y|Y)?/g,
  7655. matches = pattern.exec( offset );
  7656. while ( matches ) {
  7657. switch ( matches[ 2 ] || "d" ) {
  7658. case "d" : case "D" :
  7659. day += parseInt( matches[ 1 ], 10 ); break;
  7660. case "w" : case "W" :
  7661. day += parseInt( matches[ 1 ], 10 ) * 7; break;
  7662. case "m" : case "M" :
  7663. month += parseInt( matches[ 1 ], 10 );
  7664. day = Math.min( day, $.datepicker._getDaysInMonth( year, month ) );
  7665. break;
  7666. case "y": case "Y" :
  7667. year += parseInt( matches[ 1 ], 10 );
  7668. day = Math.min( day, $.datepicker._getDaysInMonth( year, month ) );
  7669. break;
  7670. }
  7671. matches = pattern.exec( offset );
  7672. }
  7673. return new Date( year, month, day );
  7674. },
  7675. newDate = ( date == null || date === "" ? defaultDate : ( typeof date === "string" ? offsetString( date ) :
  7676. ( typeof date === "number" ? ( isNaN( date ) ? defaultDate : offsetNumeric( date ) ) : new Date( date.getTime() ) ) ) );
  7677. newDate = ( newDate && newDate.toString() === "Invalid Date" ? defaultDate : newDate );
  7678. if ( newDate ) {
  7679. newDate.setHours( 0 );
  7680. newDate.setMinutes( 0 );
  7681. newDate.setSeconds( 0 );
  7682. newDate.setMilliseconds( 0 );
  7683. }
  7684. return this._daylightSavingAdjust( newDate );
  7685. },
  7686. /* Handle switch to/from daylight saving.
  7687. * Hours may be non-zero on daylight saving cut-over:
  7688. * > 12 when midnight changeover, but then cannot generate
  7689. * midnight datetime, so jump to 1AM, otherwise reset.
  7690. * @param date (Date) the date to check
  7691. * @return (Date) the corrected date
  7692. */
  7693. _daylightSavingAdjust: function( date ) {
  7694. if ( !date ) {
  7695. return null;
  7696. }
  7697. date.setHours( date.getHours() > 12 ? date.getHours() + 2 : 0 );
  7698. return date;
  7699. },
  7700. /* Set the date(s) directly. */
  7701. _setDate: function( inst, date, noChange ) {
  7702. var clear = !date,
  7703. origMonth = inst.selectedMonth,
  7704. origYear = inst.selectedYear,
  7705. newDate = this._restrictMinMax( inst, this._determineDate( inst, date, new Date() ) );
  7706. inst.selectedDay = inst.currentDay = newDate.getDate();
  7707. inst.drawMonth = inst.selectedMonth = inst.currentMonth = newDate.getMonth();
  7708. inst.drawYear = inst.selectedYear = inst.currentYear = newDate.getFullYear();
  7709. if ( ( origMonth !== inst.selectedMonth || origYear !== inst.selectedYear ) && !noChange ) {
  7710. this._notifyChange( inst );
  7711. }
  7712. this._adjustInstDate( inst );
  7713. if ( inst.input ) {
  7714. inst.input.val( clear ? "" : this._formatDate( inst ) );
  7715. }
  7716. },
  7717. /* Retrieve the date(s) directly. */
  7718. _getDate: function( inst ) {
  7719. var startDate = ( !inst.currentYear || ( inst.input && inst.input.val() === "" ) ? null :
  7720. this._daylightSavingAdjust( new Date(
  7721. inst.currentYear, inst.currentMonth, inst.currentDay ) ) );
  7722. return startDate;
  7723. },
  7724. /* Attach the onxxx handlers. These are declared statically so
  7725. * they work with static code transformers like Caja.
  7726. */
  7727. _attachHandlers: function( inst ) {
  7728. var stepMonths = this._get( inst, "stepMonths" ),
  7729. id = "#" + inst.id.replace( /\\\\/g, "\\" );
  7730. inst.dpDiv.find( "[data-handler]" ).map( function() {
  7731. var handler = {
  7732. prev: function() {
  7733. $.datepicker._adjustDate( id, -stepMonths, "M" );
  7734. },
  7735. next: function() {
  7736. $.datepicker._adjustDate( id, +stepMonths, "M" );
  7737. },
  7738. hide: function() {
  7739. $.datepicker._hideDatepicker();
  7740. },
  7741. today: function() {
  7742. $.datepicker._gotoToday( id );
  7743. },
  7744. selectDay: function() {
  7745. $.datepicker._selectDay( id, +this.getAttribute( "data-month" ), +this.getAttribute( "data-year" ), this );
  7746. return false;
  7747. },
  7748. selectMonth: function() {
  7749. $.datepicker._selectMonthYear( id, this, "M" );
  7750. return false;
  7751. },
  7752. selectYear: function() {
  7753. $.datepicker._selectMonthYear( id, this, "Y" );
  7754. return false;
  7755. }
  7756. };
  7757. $( this ).on( this.getAttribute( "data-event" ), handler[ this.getAttribute( "data-handler" ) ] );
  7758. } );
  7759. },
  7760. /* Generate the HTML for the current state of the date picker. */
  7761. _generateHTML: function( inst ) {
  7762. var maxDraw, prevText, prev, nextText, next, currentText, gotoDate,
  7763. controls, buttonPanel, firstDay, showWeek, dayNames, dayNamesMin,
  7764. monthNames, monthNamesShort, beforeShowDay, showOtherMonths,
  7765. selectOtherMonths, defaultDate, html, dow, row, group, col, selectedDate,
  7766. cornerClass, calender, thead, day, daysInMonth, leadDays, curRows, numRows,
  7767. printDate, dRow, tbody, daySettings, otherMonth, unselectable,
  7768. tempDate = new Date(),
  7769. today = this._daylightSavingAdjust(
  7770. new Date( tempDate.getFullYear(), tempDate.getMonth(), tempDate.getDate() ) ), // clear time
  7771. isRTL = this._get( inst, "isRTL" ),
  7772. showButtonPanel = this._get( inst, "showButtonPanel" ),
  7773. hideIfNoPrevNext = this._get( inst, "hideIfNoPrevNext" ),
  7774. navigationAsDateFormat = this._get( inst, "navigationAsDateFormat" ),
  7775. numMonths = this._getNumberOfMonths( inst ),
  7776. showCurrentAtPos = this._get( inst, "showCurrentAtPos" ),
  7777. stepMonths = this._get( inst, "stepMonths" ),
  7778. isMultiMonth = ( numMonths[ 0 ] !== 1 || numMonths[ 1 ] !== 1 ),
  7779. currentDate = this._daylightSavingAdjust( ( !inst.currentDay ? new Date( 9999, 9, 9 ) :
  7780. new Date( inst.currentYear, inst.currentMonth, inst.currentDay ) ) ),
  7781. minDate = this._getMinMaxDate( inst, "min" ),
  7782. maxDate = this._getMinMaxDate( inst, "max" ),
  7783. drawMonth = inst.drawMonth - showCurrentAtPos,
  7784. drawYear = inst.drawYear;
  7785. if ( drawMonth < 0 ) {
  7786. drawMonth += 12;
  7787. drawYear--;
  7788. }
  7789. if ( maxDate ) {
  7790. maxDraw = this._daylightSavingAdjust( new Date( maxDate.getFullYear(),
  7791. maxDate.getMonth() - ( numMonths[ 0 ] * numMonths[ 1 ] ) + 1, maxDate.getDate() ) );
  7792. maxDraw = ( minDate && maxDraw < minDate ? minDate : maxDraw );
  7793. while ( this._daylightSavingAdjust( new Date( drawYear, drawMonth, 1 ) ) > maxDraw ) {
  7794. drawMonth--;
  7795. if ( drawMonth < 0 ) {
  7796. drawMonth = 11;
  7797. drawYear--;
  7798. }
  7799. }
  7800. }
  7801. inst.drawMonth = drawMonth;
  7802. inst.drawYear = drawYear;
  7803. prevText = this._get( inst, "prevText" );
  7804. prevText = ( !navigationAsDateFormat ? prevText : this.formatDate( prevText,
  7805. this._daylightSavingAdjust( new Date( drawYear, drawMonth - stepMonths, 1 ) ),
  7806. this._getFormatConfig( inst ) ) );
  7807. prev = ( this._canAdjustMonth( inst, -1, drawYear, drawMonth ) ?
  7808. "<a class='ui-datepicker-prev ui-corner-all' data-handler='prev' data-event='click'" +
  7809. " title='" + prevText + "'><span class='ui-icon ui-icon-circle-triangle-" + ( isRTL ? "e" : "w" ) + "'>" + prevText + "</span></a>" :
  7810. ( 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>" ) );
  7811. nextText = this._get( inst, "nextText" );
  7812. nextText = ( !navigationAsDateFormat ? nextText : this.formatDate( nextText,
  7813. this._daylightSavingAdjust( new Date( drawYear, drawMonth + stepMonths, 1 ) ),
  7814. this._getFormatConfig( inst ) ) );
  7815. next = ( this._canAdjustMonth( inst, +1, drawYear, drawMonth ) ?
  7816. "<a class='ui-datepicker-next ui-corner-all' data-handler='next' data-event='click'" +
  7817. " title='" + nextText + "'><span class='ui-icon ui-icon-circle-triangle-" + ( isRTL ? "w" : "e" ) + "'>" + nextText + "</span></a>" :
  7818. ( 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>" ) );
  7819. currentText = this._get( inst, "currentText" );
  7820. gotoDate = ( this._get( inst, "gotoCurrent" ) && inst.currentDay ? currentDate : today );
  7821. currentText = ( !navigationAsDateFormat ? currentText :
  7822. this.formatDate( currentText, gotoDate, this._getFormatConfig( inst ) ) );
  7823. 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'>" +
  7824. this._get( inst, "closeText" ) + "</button>" : "" );
  7825. buttonPanel = ( showButtonPanel ) ? "<div class='ui-datepicker-buttonpane ui-widget-content'>" + ( isRTL ? controls : "" ) +
  7826. ( 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'" +
  7827. ">" + currentText + "</button>" : "" ) + ( isRTL ? "" : controls ) + "</div>" : "";
  7828. firstDay = parseInt( this._get( inst, "firstDay" ), 10 );
  7829. firstDay = ( isNaN( firstDay ) ? 0 : firstDay );
  7830. showWeek = this._get( inst, "showWeek" );
  7831. dayNames = this._get( inst, "dayNames" );
  7832. dayNamesMin = this._get( inst, "dayNamesMin" );
  7833. monthNames = this._get( inst, "monthNames" );
  7834. monthNamesShort = this._get( inst, "monthNamesShort" );
  7835. beforeShowDay = this._get( inst, "beforeShowDay" );
  7836. showOtherMonths = this._get( inst, "showOtherMonths" );
  7837. selectOtherMonths = this._get( inst, "selectOtherMonths" );
  7838. defaultDate = this._getDefaultDate( inst );
  7839. html = "";
  7840. for ( row = 0; row < numMonths[ 0 ]; row++ ) {
  7841. group = "";
  7842. this.maxRows = 4;
  7843. for ( col = 0; col < numMonths[ 1 ]; col++ ) {
  7844. selectedDate = this._daylightSavingAdjust( new Date( drawYear, drawMonth, inst.selectedDay ) );
  7845. cornerClass = " ui-corner-all";
  7846. calender = "";
  7847. if ( isMultiMonth ) {
  7848. calender += "<div class='ui-datepicker-group";
  7849. if ( numMonths[ 1 ] > 1 ) {
  7850. switch ( col ) {
  7851. case 0: calender += " ui-datepicker-group-first";
  7852. cornerClass = " ui-corner-" + ( isRTL ? "right" : "left" ); break;
  7853. case numMonths[ 1 ] - 1: calender += " ui-datepicker-group-last";
  7854. cornerClass = " ui-corner-" + ( isRTL ? "left" : "right" ); break;
  7855. default: calender += " ui-datepicker-group-middle"; cornerClass = ""; break;
  7856. }
  7857. }
  7858. calender += "'>";
  7859. }
  7860. calender += "<div class='ui-datepicker-header ui-widget-header ui-helper-clearfix" + cornerClass + "'>" +
  7861. ( /all|left/.test( cornerClass ) && row === 0 ? ( isRTL ? next : prev ) : "" ) +
  7862. ( /all|right/.test( cornerClass ) && row === 0 ? ( isRTL ? prev : next ) : "" ) +
  7863. this._generateMonthYearHeader( inst, drawMonth, drawYear, minDate, maxDate,
  7864. row > 0 || col > 0, monthNames, monthNamesShort ) + // draw month headers
  7865. "</div><table class='ui-datepicker-calendar'><thead>" +
  7866. "<tr>";
  7867. thead = ( showWeek ? "<th class='ui-datepicker-week-col'>" + this._get( inst, "weekHeader" ) + "</th>" : "" );
  7868. for ( dow = 0; dow < 7; dow++ ) { // days of the week
  7869. day = ( dow + firstDay ) % 7;
  7870. thead += "<th scope='col'" + ( ( dow + firstDay + 6 ) % 7 >= 5 ? " class='ui-datepicker-week-end'" : "" ) + ">" +
  7871. "<span title='" + dayNames[ day ] + "'>" + dayNamesMin[ day ] + "</span></th>";
  7872. }
  7873. calender += thead + "</tr></thead><tbody>";
  7874. daysInMonth = this._getDaysInMonth( drawYear, drawMonth );
  7875. if ( drawYear === inst.selectedYear && drawMonth === inst.selectedMonth ) {
  7876. inst.selectedDay = Math.min( inst.selectedDay, daysInMonth );
  7877. }
  7878. leadDays = ( this._getFirstDayOfMonth( drawYear, drawMonth ) - firstDay + 7 ) % 7;
  7879. curRows = Math.ceil( ( leadDays + daysInMonth ) / 7 ); // calculate the number of rows to generate
  7880. numRows = ( isMultiMonth ? this.maxRows > curRows ? this.maxRows : curRows : curRows ); //If multiple months, use the higher number of rows (see #7043)
  7881. this.maxRows = numRows;
  7882. printDate = this._daylightSavingAdjust( new Date( drawYear, drawMonth, 1 - leadDays ) );
  7883. for ( dRow = 0; dRow < numRows; dRow++ ) { // create date picker rows
  7884. calender += "<tr>";
  7885. tbody = ( !showWeek ? "" : "<td class='ui-datepicker-week-col'>" +
  7886. this._get( inst, "calculateWeek" )( printDate ) + "</td>" );
  7887. for ( dow = 0; dow < 7; dow++ ) { // create date picker days
  7888. daySettings = ( beforeShowDay ?
  7889. beforeShowDay.apply( ( inst.input ? inst.input[ 0 ] : null ), [ printDate ] ) : [ true, "" ] );
  7890. otherMonth = ( printDate.getMonth() !== drawMonth );
  7891. unselectable = ( otherMonth && !selectOtherMonths ) || !daySettings[ 0 ] ||
  7892. ( minDate && printDate < minDate ) || ( maxDate && printDate > maxDate );
  7893. tbody += "<td class='" +
  7894. ( ( dow + firstDay + 6 ) % 7 >= 5 ? " ui-datepicker-week-end" : "" ) + // highlight weekends
  7895. ( otherMonth ? " ui-datepicker-other-month" : "" ) + // highlight days from other months
  7896. ( ( printDate.getTime() === selectedDate.getTime() && drawMonth === inst.selectedMonth && inst._keyEvent ) || // user pressed key
  7897. ( defaultDate.getTime() === printDate.getTime() && defaultDate.getTime() === selectedDate.getTime() ) ?
  7898. // or defaultDate is current printedDate and defaultDate is selectedDate
  7899. " " + this._dayOverClass : "" ) + // highlight selected day
  7900. ( unselectable ? " " + this._unselectableClass + " ui-state-disabled" : "" ) + // highlight unselectable days
  7901. ( otherMonth && !showOtherMonths ? "" : " " + daySettings[ 1 ] + // highlight custom dates
  7902. ( printDate.getTime() === currentDate.getTime() ? " " + this._currentClass : "" ) + // highlight selected day
  7903. ( printDate.getTime() === today.getTime() ? " ui-datepicker-today" : "" ) ) + "'" + // highlight today (if different)
  7904. ( ( !otherMonth || showOtherMonths ) && daySettings[ 2 ] ? " title='" + daySettings[ 2 ].replace( /'/g, "&#39;" ) + "'" : "" ) + // cell title
  7905. ( unselectable ? "" : " data-handler='selectDay' data-event='click' data-month='" + printDate.getMonth() + "' data-year='" + printDate.getFullYear() + "'" ) + ">" + // actions
  7906. ( otherMonth && !showOtherMonths ? "&#xa0;" : // display for other months
  7907. ( unselectable ? "<span class='ui-state-default'>" + printDate.getDate() + "</span>" : "<a class='ui-state-default" +
  7908. ( printDate.getTime() === today.getTime() ? " ui-state-highlight" : "" ) +
  7909. ( printDate.getTime() === currentDate.getTime() ? " ui-state-active" : "" ) + // highlight selected day
  7910. ( otherMonth ? " ui-priority-secondary" : "" ) + // distinguish dates from other months
  7911. "' href='#'>" + printDate.getDate() + "</a>" ) ) + "</td>"; // display selectable date
  7912. printDate.setDate( printDate.getDate() + 1 );
  7913. printDate = this._daylightSavingAdjust( printDate );
  7914. }
  7915. calender += tbody + "</tr>";
  7916. }
  7917. drawMonth++;
  7918. if ( drawMonth > 11 ) {
  7919. drawMonth = 0;
  7920. drawYear++;
  7921. }
  7922. calender += "</tbody></table>" + ( isMultiMonth ? "</div>" +
  7923. ( ( numMonths[ 0 ] > 0 && col === numMonths[ 1 ] - 1 ) ? "<div class='ui-datepicker-row-break'></div>" : "" ) : "" );
  7924. group += calender;
  7925. }
  7926. html += group;
  7927. }
  7928. html += buttonPanel;
  7929. inst._keyEvent = false;
  7930. return html;
  7931. },
  7932. /* Generate the month and year header. */
  7933. _generateMonthYearHeader: function( inst, drawMonth, drawYear, minDate, maxDate,
  7934. secondary, monthNames, monthNamesShort ) {
  7935. var inMinYear, inMaxYear, month, years, thisYear, determineYear, year, endYear,
  7936. changeMonth = this._get( inst, "changeMonth" ),
  7937. changeYear = this._get( inst, "changeYear" ),
  7938. showMonthAfterYear = this._get( inst, "showMonthAfterYear" ),
  7939. html = "<div class='ui-datepicker-title'>",
  7940. monthHtml = "";
  7941. // Month selection
  7942. if ( secondary || !changeMonth ) {
  7943. monthHtml += "<span class='ui-datepicker-month'>" + monthNames[ drawMonth ] + "</span>";
  7944. } else {
  7945. inMinYear = ( minDate && minDate.getFullYear() === drawYear );
  7946. inMaxYear = ( maxDate && maxDate.getFullYear() === drawYear );
  7947. monthHtml += "<select class='ui-datepicker-month' data-handler='selectMonth' data-event='change'>";
  7948. for ( month = 0; month < 12; month++ ) {
  7949. if ( ( !inMinYear || month >= minDate.getMonth() ) && ( !inMaxYear || month <= maxDate.getMonth() ) ) {
  7950. monthHtml += "<option value='" + month + "'" +
  7951. ( month === drawMonth ? " selected='selected'" : "" ) +
  7952. ">" + monthNamesShort[ month ] + "</option>";
  7953. }
  7954. }
  7955. monthHtml += "</select>";
  7956. }
  7957. if ( !showMonthAfterYear ) {
  7958. html += monthHtml + ( secondary || !( changeMonth && changeYear ) ? "&#xa0;" : "" );
  7959. }
  7960. // Year selection
  7961. if ( !inst.yearshtml ) {
  7962. inst.yearshtml = "";
  7963. if ( secondary || !changeYear ) {
  7964. html += "<span class='ui-datepicker-year'>" + drawYear + "</span>";
  7965. } else {
  7966. // determine range of years to display
  7967. years = this._get( inst, "yearRange" ).split( ":" );
  7968. thisYear = new Date().getFullYear();
  7969. determineYear = function( value ) {
  7970. var year = ( value.match( /c[+\-].*/ ) ? drawYear + parseInt( value.substring( 1 ), 10 ) :
  7971. ( value.match( /[+\-].*/ ) ? thisYear + parseInt( value, 10 ) :
  7972. parseInt( value, 10 ) ) );
  7973. return ( isNaN( year ) ? thisYear : year );
  7974. };
  7975. year = determineYear( years[ 0 ] );
  7976. endYear = Math.max( year, determineYear( years[ 1 ] || "" ) );
  7977. year = ( minDate ? Math.max( year, minDate.getFullYear() ) : year );
  7978. endYear = ( maxDate ? Math.min( endYear, maxDate.getFullYear() ) : endYear );
  7979. inst.yearshtml += "<select class='ui-datepicker-year' data-handler='selectYear' data-event='change'>";
  7980. for ( ; year <= endYear; year++ ) {
  7981. inst.yearshtml += "<option value='" + year + "'" +
  7982. ( year === drawYear ? " selected='selected'" : "" ) +
  7983. ">" + year + "</option>";
  7984. }
  7985. inst.yearshtml += "</select>";
  7986. html += inst.yearshtml;
  7987. inst.yearshtml = null;
  7988. }
  7989. }
  7990. html += this._get( inst, "yearSuffix" );
  7991. if ( showMonthAfterYear ) {
  7992. html += ( secondary || !( changeMonth && changeYear ) ? "&#xa0;" : "" ) + monthHtml;
  7993. }
  7994. html += "</div>"; // Close datepicker_header
  7995. return html;
  7996. },
  7997. /* Adjust one of the date sub-fields. */
  7998. _adjustInstDate: function( inst, offset, period ) {
  7999. var year = inst.selectedYear + ( period === "Y" ? offset : 0 ),
  8000. month = inst.selectedMonth + ( period === "M" ? offset : 0 ),
  8001. day = Math.min( inst.selectedDay, this._getDaysInMonth( year, month ) ) + ( period === "D" ? offset : 0 ),
  8002. date = this._restrictMinMax( inst, this._daylightSavingAdjust( new Date( year, month, day ) ) );
  8003. inst.selectedDay = date.getDate();
  8004. inst.drawMonth = inst.selectedMonth = date.getMonth();
  8005. inst.drawYear = inst.selectedYear = date.getFullYear();
  8006. if ( period === "M" || period === "Y" ) {
  8007. this._notifyChange( inst );
  8008. }
  8009. },
  8010. /* Ensure a date is within any min/max bounds. */
  8011. _restrictMinMax: function( inst, date ) {
  8012. var minDate = this._getMinMaxDate( inst, "min" ),
  8013. maxDate = this._getMinMaxDate( inst, "max" ),
  8014. newDate = ( minDate && date < minDate ? minDate : date );
  8015. return ( maxDate && newDate > maxDate ? maxDate : newDate );
  8016. },
  8017. /* Notify change of month/year. */
  8018. _notifyChange: function( inst ) {
  8019. var onChange = this._get( inst, "onChangeMonthYear" );
  8020. if ( onChange ) {
  8021. onChange.apply( ( inst.input ? inst.input[ 0 ] : null ),
  8022. [ inst.selectedYear, inst.selectedMonth + 1, inst ] );
  8023. }
  8024. },
  8025. /* Determine the number of months to show. */
  8026. _getNumberOfMonths: function( inst ) {
  8027. var numMonths = this._get( inst, "numberOfMonths" );
  8028. return ( numMonths == null ? [ 1, 1 ] : ( typeof numMonths === "number" ? [ 1, numMonths ] : numMonths ) );
  8029. },
  8030. /* Determine the current maximum date - ensure no time components are set. */
  8031. _getMinMaxDate: function( inst, minMax ) {
  8032. return this._determineDate( inst, this._get( inst, minMax + "Date" ), null );
  8033. },
  8034. /* Find the number of days in a given month. */
  8035. _getDaysInMonth: function( year, month ) {
  8036. return 32 - this._daylightSavingAdjust( new Date( year, month, 32 ) ).getDate();
  8037. },
  8038. /* Find the day of the week of the first of a month. */
  8039. _getFirstDayOfMonth: function( year, month ) {
  8040. return new Date( year, month, 1 ).getDay();
  8041. },
  8042. /* Determines if we should allow a "next/prev" month display change. */
  8043. _canAdjustMonth: function( inst, offset, curYear, curMonth ) {
  8044. var numMonths = this._getNumberOfMonths( inst ),
  8045. date = this._daylightSavingAdjust( new Date( curYear,
  8046. curMonth + ( offset < 0 ? offset : numMonths[ 0 ] * numMonths[ 1 ] ), 1 ) );
  8047. if ( offset < 0 ) {
  8048. date.setDate( this._getDaysInMonth( date.getFullYear(), date.getMonth() ) );
  8049. }
  8050. return this._isInRange( inst, date );
  8051. },
  8052. /* Is the given date in the accepted range? */
  8053. _isInRange: function( inst, date ) {
  8054. var yearSplit, currentYear,
  8055. minDate = this._getMinMaxDate( inst, "min" ),
  8056. maxDate = this._getMinMaxDate( inst, "max" ),
  8057. minYear = null,
  8058. maxYear = null,
  8059. years = this._get( inst, "yearRange" );
  8060. if ( years ) {
  8061. yearSplit = years.split( ":" );
  8062. currentYear = new Date().getFullYear();
  8063. minYear = parseInt( yearSplit[ 0 ], 10 );
  8064. maxYear = parseInt( yearSplit[ 1 ], 10 );
  8065. if ( yearSplit[ 0 ].match( /[+\-].*/ ) ) {
  8066. minYear += currentYear;
  8067. }
  8068. if ( yearSplit[ 1 ].match( /[+\-].*/ ) ) {
  8069. maxYear += currentYear;
  8070. }
  8071. }
  8072. return ( ( !minDate || date.getTime() >= minDate.getTime() ) &&
  8073. ( !maxDate || date.getTime() <= maxDate.getTime() ) &&
  8074. ( !minYear || date.getFullYear() >= minYear ) &&
  8075. ( !maxYear || date.getFullYear() <= maxYear ) );
  8076. },
  8077. /* Provide the configuration settings for formatting/parsing. */
  8078. _getFormatConfig: function( inst ) {
  8079. var shortYearCutoff = this._get( inst, "shortYearCutoff" );
  8080. shortYearCutoff = ( typeof shortYearCutoff !== "string" ? shortYearCutoff :
  8081. new Date().getFullYear() % 100 + parseInt( shortYearCutoff, 10 ) );
  8082. return { shortYearCutoff: shortYearCutoff,
  8083. dayNamesShort: this._get( inst, "dayNamesShort" ), dayNames: this._get( inst, "dayNames" ),
  8084. monthNamesShort: this._get( inst, "monthNamesShort" ), monthNames: this._get( inst, "monthNames" ) };
  8085. },
  8086. /* Format the given date for display. */
  8087. _formatDate: function( inst, day, month, year ) {
  8088. if ( !day ) {
  8089. inst.currentDay = inst.selectedDay;
  8090. inst.currentMonth = inst.selectedMonth;
  8091. inst.currentYear = inst.selectedYear;
  8092. }
  8093. var date = ( day ? ( typeof day === "object" ? day :
  8094. this._daylightSavingAdjust( new Date( year, month, day ) ) ) :
  8095. this._daylightSavingAdjust( new Date( inst.currentYear, inst.currentMonth, inst.currentDay ) ) );
  8096. return this.formatDate( this._get( inst, "dateFormat" ), date, this._getFormatConfig( inst ) );
  8097. }
  8098. } );
  8099. /*
  8100. * Bind hover events for datepicker elements.
  8101. * Done via delegate so the binding only occurs once in the lifetime of the parent div.
  8102. * Global datepicker_instActive, set by _updateDatepicker allows the handlers to find their way back to the active picker.
  8103. */
  8104. function datepicker_bindHover( dpDiv ) {
  8105. var selector = "button, .ui-datepicker-prev, .ui-datepicker-next, .ui-datepicker-calendar td a";
  8106. return dpDiv.on( "mouseout", selector, function() {
  8107. $( this ).removeClass( "ui-state-hover" );
  8108. if ( this.className.indexOf( "ui-datepicker-prev" ) !== -1 ) {
  8109. $( this ).removeClass( "ui-datepicker-prev-hover" );
  8110. }
  8111. if ( this.className.indexOf( "ui-datepicker-next" ) !== -1 ) {
  8112. $( this ).removeClass( "ui-datepicker-next-hover" );
  8113. }
  8114. } )
  8115. .on( "mouseover", selector, datepicker_handleMouseover );
  8116. }
  8117. function datepicker_handleMouseover() {
  8118. if ( !$.datepicker._isDisabledDatepicker( datepicker_instActive.inline ? datepicker_instActive.dpDiv.parent()[ 0 ] : datepicker_instActive.input[ 0 ] ) ) {
  8119. $( this ).parents( ".ui-datepicker-calendar" ).find( "a" ).removeClass( "ui-state-hover" );
  8120. $( this ).addClass( "ui-state-hover" );
  8121. if ( this.className.indexOf( "ui-datepicker-prev" ) !== -1 ) {
  8122. $( this ).addClass( "ui-datepicker-prev-hover" );
  8123. }
  8124. if ( this.className.indexOf( "ui-datepicker-next" ) !== -1 ) {
  8125. $( this ).addClass( "ui-datepicker-next-hover" );
  8126. }
  8127. }
  8128. }
  8129. /* jQuery extend now ignores nulls! */
  8130. function datepicker_extendRemove( target, props ) {
  8131. $.extend( target, props );
  8132. for ( var name in props ) {
  8133. if ( props[ name ] == null ) {
  8134. target[ name ] = props[ name ];
  8135. }
  8136. }
  8137. return target;
  8138. }
  8139. /* Invoke the datepicker functionality.
  8140. @param options string - a command, optionally followed by additional parameters or
  8141. Object - settings for attaching new datepicker functionality
  8142. @return jQuery object */
  8143. $.fn.datepicker = function( options ) {
  8144. /* Verify an empty collection wasn't passed - Fixes #6976 */
  8145. if ( !this.length ) {
  8146. return this;
  8147. }
  8148. /* Initialise the date picker. */
  8149. if ( !$.datepicker.initialized ) {
  8150. $( document ).on( "mousedown", $.datepicker._checkExternalClick );
  8151. $.datepicker.initialized = true;
  8152. }
  8153. /* Append datepicker main container to body if not exist. */
  8154. if ( $( "#" + $.datepicker._mainDivId ).length === 0 ) {
  8155. $( "body" ).append( $.datepicker.dpDiv );
  8156. }
  8157. var otherArgs = Array.prototype.slice.call( arguments, 1 );
  8158. if ( typeof options === "string" && ( options === "isDisabled" || options === "getDate" || options === "widget" ) ) {
  8159. return $.datepicker[ "_" + options + "Datepicker" ].
  8160. apply( $.datepicker, [ this[ 0 ] ].concat( otherArgs ) );
  8161. }
  8162. if ( options === "option" && arguments.length === 2 && typeof arguments[ 1 ] === "string" ) {
  8163. return $.datepicker[ "_" + options + "Datepicker" ].
  8164. apply( $.datepicker, [ this[ 0 ] ].concat( otherArgs ) );
  8165. }
  8166. return this.each( function() {
  8167. typeof options === "string" ?
  8168. $.datepicker[ "_" + options + "Datepicker" ].
  8169. apply( $.datepicker, [ this ].concat( otherArgs ) ) :
  8170. $.datepicker._attachDatepicker( this, options );
  8171. } );
  8172. };
  8173. $.datepicker = new Datepicker(); // singleton instance
  8174. $.datepicker.initialized = false;
  8175. $.datepicker.uuid = new Date().getTime();
  8176. $.datepicker.version = "1.12.1";
  8177. var widgetsDatepicker = $.datepicker;
  8178. /*!
  8179. * jQuery UI Effects 1.12.1
  8180. * http://jqueryui.com
  8181. *
  8182. * Copyright jQuery Foundation and other contributors
  8183. * Released under the MIT license.
  8184. * http://jquery.org/license
  8185. */
  8186. //>>label: Effects Core
  8187. //>>group: Effects
  8188. // jscs:disable maximumLineLength
  8189. //>>description: Extends the internal jQuery effects. Includes morphing and easing. Required by all other effects.
  8190. // jscs:enable maximumLineLength
  8191. //>>docs: http://api.jqueryui.com/category/effects-core/
  8192. //>>demos: http://jqueryui.com/effect/
  8193. var dataSpace = "ui-effects-",
  8194. dataSpaceStyle = "ui-effects-style",
  8195. dataSpaceAnimated = "ui-effects-animated",
  8196. // Create a local jQuery because jQuery Color relies on it and the
  8197. // global may not exist with AMD and a custom build (#10199)
  8198. jQuery = $;
  8199. $.effects = {
  8200. effect: {}
  8201. };
  8202. /*!
  8203. * jQuery Color Animations v2.1.2
  8204. * https://github.com/jquery/jquery-color
  8205. *
  8206. * Copyright 2014 jQuery Foundation and other contributors
  8207. * Released under the MIT license.
  8208. * http://jquery.org/license
  8209. *
  8210. * Date: Wed Jan 16 08:47:09 2013 -0600
  8211. */
  8212. ( function( jQuery, undefined ) {
  8213. var stepHooks = "backgroundColor borderBottomColor borderLeftColor borderRightColor " +
  8214. "borderTopColor color columnRuleColor outlineColor textDecorationColor textEmphasisColor",
  8215. // Plusequals test for += 100 -= 100
  8216. rplusequals = /^([\-+])=\s*(\d+\.?\d*)/,
  8217. // A set of RE's that can match strings and generate color tuples.
  8218. stringParsers = [ {
  8219. re: /rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(?:,\s*(\d?(?:\.\d+)?)\s*)?\)/,
  8220. parse: function( execResult ) {
  8221. return [
  8222. execResult[ 1 ],
  8223. execResult[ 2 ],
  8224. execResult[ 3 ],
  8225. execResult[ 4 ]
  8226. ];
  8227. }
  8228. }, {
  8229. re: /rgba?\(\s*(\d+(?:\.\d+)?)\%\s*,\s*(\d+(?:\.\d+)?)\%\s*,\s*(\d+(?:\.\d+)?)\%\s*(?:,\s*(\d?(?:\.\d+)?)\s*)?\)/,
  8230. parse: function( execResult ) {
  8231. return [
  8232. execResult[ 1 ] * 2.55,
  8233. execResult[ 2 ] * 2.55,
  8234. execResult[ 3 ] * 2.55,
  8235. execResult[ 4 ]
  8236. ];
  8237. }
  8238. }, {
  8239. // This regex ignores A-F because it's compared against an already lowercased string
  8240. re: /#([a-f0-9]{2})([a-f0-9]{2})([a-f0-9]{2})/,
  8241. parse: function( execResult ) {
  8242. return [
  8243. parseInt( execResult[ 1 ], 16 ),
  8244. parseInt( execResult[ 2 ], 16 ),
  8245. parseInt( execResult[ 3 ], 16 )
  8246. ];
  8247. }
  8248. }, {
  8249. // This regex ignores A-F because it's compared against an already lowercased string
  8250. re: /#([a-f0-9])([a-f0-9])([a-f0-9])/,
  8251. parse: function( execResult ) {
  8252. return [
  8253. parseInt( execResult[ 1 ] + execResult[ 1 ], 16 ),
  8254. parseInt( execResult[ 2 ] + execResult[ 2 ], 16 ),
  8255. parseInt( execResult[ 3 ] + execResult[ 3 ], 16 )
  8256. ];
  8257. }
  8258. }, {
  8259. re: /hsla?\(\s*(\d+(?:\.\d+)?)\s*,\s*(\d+(?:\.\d+)?)\%\s*,\s*(\d+(?:\.\d+)?)\%\s*(?:,\s*(\d?(?:\.\d+)?)\s*)?\)/,
  8260. space: "hsla",
  8261. parse: function( execResult ) {
  8262. return [
  8263. execResult[ 1 ],
  8264. execResult[ 2 ] / 100,
  8265. execResult[ 3 ] / 100,
  8266. execResult[ 4 ]
  8267. ];
  8268. }
  8269. } ],
  8270. // JQuery.Color( )
  8271. color = jQuery.Color = function( color, green, blue, alpha ) {
  8272. return new jQuery.Color.fn.parse( color, green, blue, alpha );
  8273. },
  8274. spaces = {
  8275. rgba: {
  8276. props: {
  8277. red: {
  8278. idx: 0,
  8279. type: "byte"
  8280. },
  8281. green: {
  8282. idx: 1,
  8283. type: "byte"
  8284. },
  8285. blue: {
  8286. idx: 2,
  8287. type: "byte"
  8288. }
  8289. }
  8290. },
  8291. hsla: {
  8292. props: {
  8293. hue: {
  8294. idx: 0,
  8295. type: "degrees"
  8296. },
  8297. saturation: {
  8298. idx: 1,
  8299. type: "percent"
  8300. },
  8301. lightness: {
  8302. idx: 2,
  8303. type: "percent"
  8304. }
  8305. }
  8306. }
  8307. },
  8308. propTypes = {
  8309. "byte": {
  8310. floor: true,
  8311. max: 255
  8312. },
  8313. "percent": {
  8314. max: 1
  8315. },
  8316. "degrees": {
  8317. mod: 360,
  8318. floor: true
  8319. }
  8320. },
  8321. support = color.support = {},
  8322. // Element for support tests
  8323. supportElem = jQuery( "<p>" )[ 0 ],
  8324. // Colors = jQuery.Color.names
  8325. colors,
  8326. // Local aliases of functions called often
  8327. each = jQuery.each;
  8328. // Determine rgba support immediately
  8329. supportElem.style.cssText = "background-color:rgba(1,1,1,.5)";
  8330. support.rgba = supportElem.style.backgroundColor.indexOf( "rgba" ) > -1;
  8331. // Define cache name and alpha properties
  8332. // for rgba and hsla spaces
  8333. each( spaces, function( spaceName, space ) {
  8334. space.cache = "_" + spaceName;
  8335. space.props.alpha = {
  8336. idx: 3,
  8337. type: "percent",
  8338. def: 1
  8339. };
  8340. } );
  8341. function clamp( value, prop, allowEmpty ) {
  8342. var type = propTypes[ prop.type ] || {};
  8343. if ( value == null ) {
  8344. return ( allowEmpty || !prop.def ) ? null : prop.def;
  8345. }
  8346. // ~~ is an short way of doing floor for positive numbers
  8347. value = type.floor ? ~~value : parseFloat( value );
  8348. // IE will pass in empty strings as value for alpha,
  8349. // which will hit this case
  8350. if ( isNaN( value ) ) {
  8351. return prop.def;
  8352. }
  8353. if ( type.mod ) {
  8354. // We add mod before modding to make sure that negatives values
  8355. // get converted properly: -10 -> 350
  8356. return ( value + type.mod ) % type.mod;
  8357. }
  8358. // For now all property types without mod have min and max
  8359. return 0 > value ? 0 : type.max < value ? type.max : value;
  8360. }
  8361. function stringParse( string ) {
  8362. var inst = color(),
  8363. rgba = inst._rgba = [];
  8364. string = string.toLowerCase();
  8365. each( stringParsers, function( i, parser ) {
  8366. var parsed,
  8367. match = parser.re.exec( string ),
  8368. values = match && parser.parse( match ),
  8369. spaceName = parser.space || "rgba";
  8370. if ( values ) {
  8371. parsed = inst[ spaceName ]( values );
  8372. // If this was an rgba parse the assignment might happen twice
  8373. // oh well....
  8374. inst[ spaces[ spaceName ].cache ] = parsed[ spaces[ spaceName ].cache ];
  8375. rgba = inst._rgba = parsed._rgba;
  8376. // Exit each( stringParsers ) here because we matched
  8377. return false;
  8378. }
  8379. } );
  8380. // Found a stringParser that handled it
  8381. if ( rgba.length ) {
  8382. // If this came from a parsed string, force "transparent" when alpha is 0
  8383. // chrome, (and maybe others) return "transparent" as rgba(0,0,0,0)
  8384. if ( rgba.join() === "0,0,0,0" ) {
  8385. jQuery.extend( rgba, colors.transparent );
  8386. }
  8387. return inst;
  8388. }
  8389. // Named colors
  8390. return colors[ string ];
  8391. }
  8392. color.fn = jQuery.extend( color.prototype, {
  8393. parse: function( red, green, blue, alpha ) {
  8394. if ( red === undefined ) {
  8395. this._rgba = [ null, null, null, null ];
  8396. return this;
  8397. }
  8398. if ( red.jquery || red.nodeType ) {
  8399. red = jQuery( red ).css( green );
  8400. green = undefined;
  8401. }
  8402. var inst = this,
  8403. type = jQuery.type( red ),
  8404. rgba = this._rgba = [];
  8405. // More than 1 argument specified - assume ( red, green, blue, alpha )
  8406. if ( green !== undefined ) {
  8407. red = [ red, green, blue, alpha ];
  8408. type = "array";
  8409. }
  8410. if ( type === "string" ) {
  8411. return this.parse( stringParse( red ) || colors._default );
  8412. }
  8413. if ( type === "array" ) {
  8414. each( spaces.rgba.props, function( key, prop ) {
  8415. rgba[ prop.idx ] = clamp( red[ prop.idx ], prop );
  8416. } );
  8417. return this;
  8418. }
  8419. if ( type === "object" ) {
  8420. if ( red instanceof color ) {
  8421. each( spaces, function( spaceName, space ) {
  8422. if ( red[ space.cache ] ) {
  8423. inst[ space.cache ] = red[ space.cache ].slice();
  8424. }
  8425. } );
  8426. } else {
  8427. each( spaces, function( spaceName, space ) {
  8428. var cache = space.cache;
  8429. each( space.props, function( key, prop ) {
  8430. // If the cache doesn't exist, and we know how to convert
  8431. if ( !inst[ cache ] && space.to ) {
  8432. // If the value was null, we don't need to copy it
  8433. // if the key was alpha, we don't need to copy it either
  8434. if ( key === "alpha" || red[ key ] == null ) {
  8435. return;
  8436. }
  8437. inst[ cache ] = space.to( inst._rgba );
  8438. }
  8439. // This is the only case where we allow nulls for ALL properties.
  8440. // call clamp with alwaysAllowEmpty
  8441. inst[ cache ][ prop.idx ] = clamp( red[ key ], prop, true );
  8442. } );
  8443. // Everything defined but alpha?
  8444. if ( inst[ cache ] &&
  8445. jQuery.inArray( null, inst[ cache ].slice( 0, 3 ) ) < 0 ) {
  8446. // Use the default of 1
  8447. inst[ cache ][ 3 ] = 1;
  8448. if ( space.from ) {
  8449. inst._rgba = space.from( inst[ cache ] );
  8450. }
  8451. }
  8452. } );
  8453. }
  8454. return this;
  8455. }
  8456. },
  8457. is: function( compare ) {
  8458. var is = color( compare ),
  8459. same = true,
  8460. inst = this;
  8461. each( spaces, function( _, space ) {
  8462. var localCache,
  8463. isCache = is[ space.cache ];
  8464. if ( isCache ) {
  8465. localCache = inst[ space.cache ] || space.to && space.to( inst._rgba ) || [];
  8466. each( space.props, function( _, prop ) {
  8467. if ( isCache[ prop.idx ] != null ) {
  8468. same = ( isCache[ prop.idx ] === localCache[ prop.idx ] );
  8469. return same;
  8470. }
  8471. } );
  8472. }
  8473. return same;
  8474. } );
  8475. return same;
  8476. },
  8477. _space: function() {
  8478. var used = [],
  8479. inst = this;
  8480. each( spaces, function( spaceName, space ) {
  8481. if ( inst[ space.cache ] ) {
  8482. used.push( spaceName );
  8483. }
  8484. } );
  8485. return used.pop();
  8486. },
  8487. transition: function( other, distance ) {
  8488. var end = color( other ),
  8489. spaceName = end._space(),
  8490. space = spaces[ spaceName ],
  8491. startColor = this.alpha() === 0 ? color( "transparent" ) : this,
  8492. start = startColor[ space.cache ] || space.to( startColor._rgba ),
  8493. result = start.slice();
  8494. end = end[ space.cache ];
  8495. each( space.props, function( key, prop ) {
  8496. var index = prop.idx,
  8497. startValue = start[ index ],
  8498. endValue = end[ index ],
  8499. type = propTypes[ prop.type ] || {};
  8500. // If null, don't override start value
  8501. if ( endValue === null ) {
  8502. return;
  8503. }
  8504. // If null - use end
  8505. if ( startValue === null ) {
  8506. result[ index ] = endValue;
  8507. } else {
  8508. if ( type.mod ) {
  8509. if ( endValue - startValue > type.mod / 2 ) {
  8510. startValue += type.mod;
  8511. } else if ( startValue - endValue > type.mod / 2 ) {
  8512. startValue -= type.mod;
  8513. }
  8514. }
  8515. result[ index ] = clamp( ( endValue - startValue ) * distance + startValue, prop );
  8516. }
  8517. } );
  8518. return this[ spaceName ]( result );
  8519. },
  8520. blend: function( opaque ) {
  8521. // If we are already opaque - return ourself
  8522. if ( this._rgba[ 3 ] === 1 ) {
  8523. return this;
  8524. }
  8525. var rgb = this._rgba.slice(),
  8526. a = rgb.pop(),
  8527. blend = color( opaque )._rgba;
  8528. return color( jQuery.map( rgb, function( v, i ) {
  8529. return ( 1 - a ) * blend[ i ] + a * v;
  8530. } ) );
  8531. },
  8532. toRgbaString: function() {
  8533. var prefix = "rgba(",
  8534. rgba = jQuery.map( this._rgba, function( v, i ) {
  8535. return v == null ? ( i > 2 ? 1 : 0 ) : v;
  8536. } );
  8537. if ( rgba[ 3 ] === 1 ) {
  8538. rgba.pop();
  8539. prefix = "rgb(";
  8540. }
  8541. return prefix + rgba.join() + ")";
  8542. },
  8543. toHslaString: function() {
  8544. var prefix = "hsla(",
  8545. hsla = jQuery.map( this.hsla(), function( v, i ) {
  8546. if ( v == null ) {
  8547. v = i > 2 ? 1 : 0;
  8548. }
  8549. // Catch 1 and 2
  8550. if ( i && i < 3 ) {
  8551. v = Math.round( v * 100 ) + "%";
  8552. }
  8553. return v;
  8554. } );
  8555. if ( hsla[ 3 ] === 1 ) {
  8556. hsla.pop();
  8557. prefix = "hsl(";
  8558. }
  8559. return prefix + hsla.join() + ")";
  8560. },
  8561. toHexString: function( includeAlpha ) {
  8562. var rgba = this._rgba.slice(),
  8563. alpha = rgba.pop();
  8564. if ( includeAlpha ) {
  8565. rgba.push( ~~( alpha * 255 ) );
  8566. }
  8567. return "#" + jQuery.map( rgba, function( v ) {
  8568. // Default to 0 when nulls exist
  8569. v = ( v || 0 ).toString( 16 );
  8570. return v.length === 1 ? "0" + v : v;
  8571. } ).join( "" );
  8572. },
  8573. toString: function() {
  8574. return this._rgba[ 3 ] === 0 ? "transparent" : this.toRgbaString();
  8575. }
  8576. } );
  8577. color.fn.parse.prototype = color.fn;
  8578. // Hsla conversions adapted from:
  8579. // https://code.google.com/p/maashaack/source/browse/packages/graphics/trunk/src/graphics/colors/HUE2RGB.as?r=5021
  8580. function hue2rgb( p, q, h ) {
  8581. h = ( h + 1 ) % 1;
  8582. if ( h * 6 < 1 ) {
  8583. return p + ( q - p ) * h * 6;
  8584. }
  8585. if ( h * 2 < 1 ) {
  8586. return q;
  8587. }
  8588. if ( h * 3 < 2 ) {
  8589. return p + ( q - p ) * ( ( 2 / 3 ) - h ) * 6;
  8590. }
  8591. return p;
  8592. }
  8593. spaces.hsla.to = function( rgba ) {
  8594. if ( rgba[ 0 ] == null || rgba[ 1 ] == null || rgba[ 2 ] == null ) {
  8595. return [ null, null, null, rgba[ 3 ] ];
  8596. }
  8597. var r = rgba[ 0 ] / 255,
  8598. g = rgba[ 1 ] / 255,
  8599. b = rgba[ 2 ] / 255,
  8600. a = rgba[ 3 ],
  8601. max = Math.max( r, g, b ),
  8602. min = Math.min( r, g, b ),
  8603. diff = max - min,
  8604. add = max + min,
  8605. l = add * 0.5,
  8606. h, s;
  8607. if ( min === max ) {
  8608. h = 0;
  8609. } else if ( r === max ) {
  8610. h = ( 60 * ( g - b ) / diff ) + 360;
  8611. } else if ( g === max ) {
  8612. h = ( 60 * ( b - r ) / diff ) + 120;
  8613. } else {
  8614. h = ( 60 * ( r - g ) / diff ) + 240;
  8615. }
  8616. // Chroma (diff) == 0 means greyscale which, by definition, saturation = 0%
  8617. // otherwise, saturation is based on the ratio of chroma (diff) to lightness (add)
  8618. if ( diff === 0 ) {
  8619. s = 0;
  8620. } else if ( l <= 0.5 ) {
  8621. s = diff / add;
  8622. } else {
  8623. s = diff / ( 2 - add );
  8624. }
  8625. return [ Math.round( h ) % 360, s, l, a == null ? 1 : a ];
  8626. };
  8627. spaces.hsla.from = function( hsla ) {
  8628. if ( hsla[ 0 ] == null || hsla[ 1 ] == null || hsla[ 2 ] == null ) {
  8629. return [ null, null, null, hsla[ 3 ] ];
  8630. }
  8631. var h = hsla[ 0 ] / 360,
  8632. s = hsla[ 1 ],
  8633. l = hsla[ 2 ],
  8634. a = hsla[ 3 ],
  8635. q = l <= 0.5 ? l * ( 1 + s ) : l + s - l * s,
  8636. p = 2 * l - q;
  8637. return [
  8638. Math.round( hue2rgb( p, q, h + ( 1 / 3 ) ) * 255 ),
  8639. Math.round( hue2rgb( p, q, h ) * 255 ),
  8640. Math.round( hue2rgb( p, q, h - ( 1 / 3 ) ) * 255 ),
  8641. a
  8642. ];
  8643. };
  8644. each( spaces, function( spaceName, space ) {
  8645. var props = space.props,
  8646. cache = space.cache,
  8647. to = space.to,
  8648. from = space.from;
  8649. // Makes rgba() and hsla()
  8650. color.fn[ spaceName ] = function( value ) {
  8651. // Generate a cache for this space if it doesn't exist
  8652. if ( to && !this[ cache ] ) {
  8653. this[ cache ] = to( this._rgba );
  8654. }
  8655. if ( value === undefined ) {
  8656. return this[ cache ].slice();
  8657. }
  8658. var ret,
  8659. type = jQuery.type( value ),
  8660. arr = ( type === "array" || type === "object" ) ? value : arguments,
  8661. local = this[ cache ].slice();
  8662. each( props, function( key, prop ) {
  8663. var val = arr[ type === "object" ? key : prop.idx ];
  8664. if ( val == null ) {
  8665. val = local[ prop.idx ];
  8666. }
  8667. local[ prop.idx ] = clamp( val, prop );
  8668. } );
  8669. if ( from ) {
  8670. ret = color( from( local ) );
  8671. ret[ cache ] = local;
  8672. return ret;
  8673. } else {
  8674. return color( local );
  8675. }
  8676. };
  8677. // Makes red() green() blue() alpha() hue() saturation() lightness()
  8678. each( props, function( key, prop ) {
  8679. // Alpha is included in more than one space
  8680. if ( color.fn[ key ] ) {
  8681. return;
  8682. }
  8683. color.fn[ key ] = function( value ) {
  8684. var vtype = jQuery.type( value ),
  8685. fn = ( key === "alpha" ? ( this._hsla ? "hsla" : "rgba" ) : spaceName ),
  8686. local = this[ fn ](),
  8687. cur = local[ prop.idx ],
  8688. match;
  8689. if ( vtype === "undefined" ) {
  8690. return cur;
  8691. }
  8692. if ( vtype === "function" ) {
  8693. value = value.call( this, cur );
  8694. vtype = jQuery.type( value );
  8695. }
  8696. if ( value == null && prop.empty ) {
  8697. return this;
  8698. }
  8699. if ( vtype === "string" ) {
  8700. match = rplusequals.exec( value );
  8701. if ( match ) {
  8702. value = cur + parseFloat( match[ 2 ] ) * ( match[ 1 ] === "+" ? 1 : -1 );
  8703. }
  8704. }
  8705. local[ prop.idx ] = value;
  8706. return this[ fn ]( local );
  8707. };
  8708. } );
  8709. } );
  8710. // Add cssHook and .fx.step function for each named hook.
  8711. // accept a space separated string of properties
  8712. color.hook = function( hook ) {
  8713. var hooks = hook.split( " " );
  8714. each( hooks, function( i, hook ) {
  8715. jQuery.cssHooks[ hook ] = {
  8716. set: function( elem, value ) {
  8717. var parsed, curElem,
  8718. backgroundColor = "";
  8719. if ( value !== "transparent" && ( jQuery.type( value ) !== "string" ||
  8720. ( parsed = stringParse( value ) ) ) ) {
  8721. value = color( parsed || value );
  8722. if ( !support.rgba && value._rgba[ 3 ] !== 1 ) {
  8723. curElem = hook === "backgroundColor" ? elem.parentNode : elem;
  8724. while (
  8725. ( backgroundColor === "" || backgroundColor === "transparent" ) &&
  8726. curElem && curElem.style
  8727. ) {
  8728. try {
  8729. backgroundColor = jQuery.css( curElem, "backgroundColor" );
  8730. curElem = curElem.parentNode;
  8731. } catch ( e ) {
  8732. }
  8733. }
  8734. value = value.blend( backgroundColor && backgroundColor !== "transparent" ?
  8735. backgroundColor :
  8736. "_default" );
  8737. }
  8738. value = value.toRgbaString();
  8739. }
  8740. try {
  8741. elem.style[ hook ] = value;
  8742. } catch ( e ) {
  8743. // Wrapped to prevent IE from throwing errors on "invalid" values like
  8744. // 'auto' or 'inherit'
  8745. }
  8746. }
  8747. };
  8748. jQuery.fx.step[ hook ] = function( fx ) {
  8749. if ( !fx.colorInit ) {
  8750. fx.start = color( fx.elem, hook );
  8751. fx.end = color( fx.end );
  8752. fx.colorInit = true;
  8753. }
  8754. jQuery.cssHooks[ hook ].set( fx.elem, fx.start.transition( fx.end, fx.pos ) );
  8755. };
  8756. } );
  8757. };
  8758. color.hook( stepHooks );
  8759. jQuery.cssHooks.borderColor = {
  8760. expand: function( value ) {
  8761. var expanded = {};
  8762. each( [ "Top", "Right", "Bottom", "Left" ], function( i, part ) {
  8763. expanded[ "border" + part + "Color" ] = value;
  8764. } );
  8765. return expanded;
  8766. }
  8767. };
  8768. // Basic color names only.
  8769. // Usage of any of the other color names requires adding yourself or including
  8770. // jquery.color.svg-names.js.
  8771. colors = jQuery.Color.names = {
  8772. // 4.1. Basic color keywords
  8773. aqua: "#00ffff",
  8774. black: "#000000",
  8775. blue: "#0000ff",
  8776. fuchsia: "#ff00ff",
  8777. gray: "#808080",
  8778. green: "#008000",
  8779. lime: "#00ff00",
  8780. maroon: "#800000",
  8781. navy: "#000080",
  8782. olive: "#808000",
  8783. purple: "#800080",
  8784. red: "#ff0000",
  8785. silver: "#c0c0c0",
  8786. teal: "#008080",
  8787. white: "#ffffff",
  8788. yellow: "#ffff00",
  8789. // 4.2.3. "transparent" color keyword
  8790. transparent: [ null, null, null, 0 ],
  8791. _default: "#ffffff"
  8792. };
  8793. } )( jQuery );
  8794. /******************************************************************************/
  8795. /****************************** CLASS ANIMATIONS ******************************/
  8796. /******************************************************************************/
  8797. ( function() {
  8798. var classAnimationActions = [ "add", "remove", "toggle" ],
  8799. shorthandStyles = {
  8800. border: 1,
  8801. borderBottom: 1,
  8802. borderColor: 1,
  8803. borderLeft: 1,
  8804. borderRight: 1,
  8805. borderTop: 1,
  8806. borderWidth: 1,
  8807. margin: 1,
  8808. padding: 1
  8809. };
  8810. $.each(
  8811. [ "borderLeftStyle", "borderRightStyle", "borderBottomStyle", "borderTopStyle" ],
  8812. function( _, prop ) {
  8813. $.fx.step[ prop ] = function( fx ) {
  8814. if ( fx.end !== "none" && !fx.setAttr || fx.pos === 1 && !fx.setAttr ) {
  8815. jQuery.style( fx.elem, prop, fx.end );
  8816. fx.setAttr = true;
  8817. }
  8818. };
  8819. }
  8820. );
  8821. function getElementStyles( elem ) {
  8822. var key, len,
  8823. style = elem.ownerDocument.defaultView ?
  8824. elem.ownerDocument.defaultView.getComputedStyle( elem, null ) :
  8825. elem.currentStyle,
  8826. styles = {};
  8827. if ( style && style.length && style[ 0 ] && style[ style[ 0 ] ] ) {
  8828. len = style.length;
  8829. while ( len-- ) {
  8830. key = style[ len ];
  8831. if ( typeof style[ key ] === "string" ) {
  8832. styles[ $.camelCase( key ) ] = style[ key ];
  8833. }
  8834. }
  8835. // Support: Opera, IE <9
  8836. } else {
  8837. for ( key in style ) {
  8838. if ( typeof style[ key ] === "string" ) {
  8839. styles[ key ] = style[ key ];
  8840. }
  8841. }
  8842. }
  8843. return styles;
  8844. }
  8845. function styleDifference( oldStyle, newStyle ) {
  8846. var diff = {},
  8847. name, value;
  8848. for ( name in newStyle ) {
  8849. value = newStyle[ name ];
  8850. if ( oldStyle[ name ] !== value ) {
  8851. if ( !shorthandStyles[ name ] ) {
  8852. if ( $.fx.step[ name ] || !isNaN( parseFloat( value ) ) ) {
  8853. diff[ name ] = value;
  8854. }
  8855. }
  8856. }
  8857. }
  8858. return diff;
  8859. }
  8860. // Support: jQuery <1.8
  8861. if ( !$.fn.addBack ) {
  8862. $.fn.addBack = function( selector ) {
  8863. return this.add( selector == null ?
  8864. this.prevObject : this.prevObject.filter( selector )
  8865. );
  8866. };
  8867. }
  8868. $.effects.animateClass = function( value, duration, easing, callback ) {
  8869. var o = $.speed( duration, easing, callback );
  8870. return this.queue( function() {
  8871. var animated = $( this ),
  8872. baseClass = animated.attr( "class" ) || "",
  8873. applyClassChange,
  8874. allAnimations = o.children ? animated.find( "*" ).addBack() : animated;
  8875. // Map the animated objects to store the original styles.
  8876. allAnimations = allAnimations.map( function() {
  8877. var el = $( this );
  8878. return {
  8879. el: el,
  8880. start: getElementStyles( this )
  8881. };
  8882. } );
  8883. // Apply class change
  8884. applyClassChange = function() {
  8885. $.each( classAnimationActions, function( i, action ) {
  8886. if ( value[ action ] ) {
  8887. animated[ action + "Class" ]( value[ action ] );
  8888. }
  8889. } );
  8890. };
  8891. applyClassChange();
  8892. // Map all animated objects again - calculate new styles and diff
  8893. allAnimations = allAnimations.map( function() {
  8894. this.end = getElementStyles( this.el[ 0 ] );
  8895. this.diff = styleDifference( this.start, this.end );
  8896. return this;
  8897. } );
  8898. // Apply original class
  8899. animated.attr( "class", baseClass );
  8900. // Map all animated objects again - this time collecting a promise
  8901. allAnimations = allAnimations.map( function() {
  8902. var styleInfo = this,
  8903. dfd = $.Deferred(),
  8904. opts = $.extend( {}, o, {
  8905. queue: false,
  8906. complete: function() {
  8907. dfd.resolve( styleInfo );
  8908. }
  8909. } );
  8910. this.el.animate( this.diff, opts );
  8911. return dfd.promise();
  8912. } );
  8913. // Once all animations have completed:
  8914. $.when.apply( $, allAnimations.get() ).done( function() {
  8915. // Set the final class
  8916. applyClassChange();
  8917. // For each animated element,
  8918. // clear all css properties that were animated
  8919. $.each( arguments, function() {
  8920. var el = this.el;
  8921. $.each( this.diff, function( key ) {
  8922. el.css( key, "" );
  8923. } );
  8924. } );
  8925. // This is guarnteed to be there if you use jQuery.speed()
  8926. // it also handles dequeuing the next anim...
  8927. o.complete.call( animated[ 0 ] );
  8928. } );
  8929. } );
  8930. };
  8931. $.fn.extend( {
  8932. addClass: ( function( orig ) {
  8933. return function( classNames, speed, easing, callback ) {
  8934. return speed ?
  8935. $.effects.animateClass.call( this,
  8936. { add: classNames }, speed, easing, callback ) :
  8937. orig.apply( this, arguments );
  8938. };
  8939. } )( $.fn.addClass ),
  8940. removeClass: ( function( orig ) {
  8941. return function( classNames, speed, easing, callback ) {
  8942. return arguments.length > 1 ?
  8943. $.effects.animateClass.call( this,
  8944. { remove: classNames }, speed, easing, callback ) :
  8945. orig.apply( this, arguments );
  8946. };
  8947. } )( $.fn.removeClass ),
  8948. toggleClass: ( function( orig ) {
  8949. return function( classNames, force, speed, easing, callback ) {
  8950. if ( typeof force === "boolean" || force === undefined ) {
  8951. if ( !speed ) {
  8952. // Without speed parameter
  8953. return orig.apply( this, arguments );
  8954. } else {
  8955. return $.effects.animateClass.call( this,
  8956. ( force ? { add: classNames } : { remove: classNames } ),
  8957. speed, easing, callback );
  8958. }
  8959. } else {
  8960. // Without force parameter
  8961. return $.effects.animateClass.call( this,
  8962. { toggle: classNames }, force, speed, easing );
  8963. }
  8964. };
  8965. } )( $.fn.toggleClass ),
  8966. switchClass: function( remove, add, speed, easing, callback ) {
  8967. return $.effects.animateClass.call( this, {
  8968. add: add,
  8969. remove: remove
  8970. }, speed, easing, callback );
  8971. }
  8972. } );
  8973. } )();
  8974. /******************************************************************************/
  8975. /*********************************** EFFECTS **********************************/
  8976. /******************************************************************************/
  8977. ( function() {
  8978. if ( $.expr && $.expr.filters && $.expr.filters.animated ) {
  8979. $.expr.filters.animated = ( function( orig ) {
  8980. return function( elem ) {
  8981. return !!$( elem ).data( dataSpaceAnimated ) || orig( elem );
  8982. };
  8983. } )( $.expr.filters.animated );
  8984. }
  8985. if ( $.uiBackCompat !== false ) {
  8986. $.extend( $.effects, {
  8987. // Saves a set of properties in a data storage
  8988. save: function( element, set ) {
  8989. var i = 0, length = set.length;
  8990. for ( ; i < length; i++ ) {
  8991. if ( set[ i ] !== null ) {
  8992. element.data( dataSpace + set[ i ], element[ 0 ].style[ set[ i ] ] );
  8993. }
  8994. }
  8995. },
  8996. // Restores a set of previously saved properties from a data storage
  8997. restore: function( element, set ) {
  8998. var val, i = 0, length = set.length;
  8999. for ( ; i < length; i++ ) {
  9000. if ( set[ i ] !== null ) {
  9001. val = element.data( dataSpace + set[ i ] );
  9002. element.css( set[ i ], val );
  9003. }
  9004. }
  9005. },
  9006. setMode: function( el, mode ) {
  9007. if ( mode === "toggle" ) {
  9008. mode = el.is( ":hidden" ) ? "show" : "hide";
  9009. }
  9010. return mode;
  9011. },
  9012. // Wraps the element around a wrapper that copies position properties
  9013. createWrapper: function( element ) {
  9014. // If the element is already wrapped, return it
  9015. if ( element.parent().is( ".ui-effects-wrapper" ) ) {
  9016. return element.parent();
  9017. }
  9018. // Wrap the element
  9019. var props = {
  9020. width: element.outerWidth( true ),
  9021. height: element.outerHeight( true ),
  9022. "float": element.css( "float" )
  9023. },
  9024. wrapper = $( "<div></div>" )
  9025. .addClass( "ui-effects-wrapper" )
  9026. .css( {
  9027. fontSize: "100%",
  9028. background: "transparent",
  9029. border: "none",
  9030. margin: 0,
  9031. padding: 0
  9032. } ),
  9033. // Store the size in case width/height are defined in % - Fixes #5245
  9034. size = {
  9035. width: element.width(),
  9036. height: element.height()
  9037. },
  9038. active = document.activeElement;
  9039. // Support: Firefox
  9040. // Firefox incorrectly exposes anonymous content
  9041. // https://bugzilla.mozilla.org/show_bug.cgi?id=561664
  9042. try {
  9043. active.id;
  9044. } catch ( e ) {
  9045. active = document.body;
  9046. }
  9047. element.wrap( wrapper );
  9048. // Fixes #7595 - Elements lose focus when wrapped.
  9049. if ( element[ 0 ] === active || $.contains( element[ 0 ], active ) ) {
  9050. $( active ).trigger( "focus" );
  9051. }
  9052. // Hotfix for jQuery 1.4 since some change in wrap() seems to actually
  9053. // lose the reference to the wrapped element
  9054. wrapper = element.parent();
  9055. // Transfer positioning properties to the wrapper
  9056. if ( element.css( "position" ) === "static" ) {
  9057. wrapper.css( { position: "relative" } );
  9058. element.css( { position: "relative" } );
  9059. } else {
  9060. $.extend( props, {
  9061. position: element.css( "position" ),
  9062. zIndex: element.css( "z-index" )
  9063. } );
  9064. $.each( [ "top", "left", "bottom", "right" ], function( i, pos ) {
  9065. props[ pos ] = element.css( pos );
  9066. if ( isNaN( parseInt( props[ pos ], 10 ) ) ) {
  9067. props[ pos ] = "auto";
  9068. }
  9069. } );
  9070. element.css( {
  9071. position: "relative",
  9072. top: 0,
  9073. left: 0,
  9074. right: "auto",
  9075. bottom: "auto"
  9076. } );
  9077. }
  9078. element.css( size );
  9079. return wrapper.css( props ).show();
  9080. },
  9081. removeWrapper: function( element ) {
  9082. var active = document.activeElement;
  9083. if ( element.parent().is( ".ui-effects-wrapper" ) ) {
  9084. element.parent().replaceWith( element );
  9085. // Fixes #7595 - Elements lose focus when wrapped.
  9086. if ( element[ 0 ] === active || $.contains( element[ 0 ], active ) ) {
  9087. $( active ).trigger( "focus" );
  9088. }
  9089. }
  9090. return element;
  9091. }
  9092. } );
  9093. }
  9094. $.extend( $.effects, {
  9095. version: "1.12.1",
  9096. define: function( name, mode, effect ) {
  9097. if ( !effect ) {
  9098. effect = mode;
  9099. mode = "effect";
  9100. }
  9101. $.effects.effect[ name ] = effect;
  9102. $.effects.effect[ name ].mode = mode;
  9103. return effect;
  9104. },
  9105. scaledDimensions: function( element, percent, direction ) {
  9106. if ( percent === 0 ) {
  9107. return {
  9108. height: 0,
  9109. width: 0,
  9110. outerHeight: 0,
  9111. outerWidth: 0
  9112. };
  9113. }
  9114. var x = direction !== "horizontal" ? ( ( percent || 100 ) / 100 ) : 1,
  9115. y = direction !== "vertical" ? ( ( percent || 100 ) / 100 ) : 1;
  9116. return {
  9117. height: element.height() * y,
  9118. width: element.width() * x,
  9119. outerHeight: element.outerHeight() * y,
  9120. outerWidth: element.outerWidth() * x
  9121. };
  9122. },
  9123. clipToBox: function( animation ) {
  9124. return {
  9125. width: animation.clip.right - animation.clip.left,
  9126. height: animation.clip.bottom - animation.clip.top,
  9127. left: animation.clip.left,
  9128. top: animation.clip.top
  9129. };
  9130. },
  9131. // Injects recently queued functions to be first in line (after "inprogress")
  9132. unshift: function( element, queueLength, count ) {
  9133. var queue = element.queue();
  9134. if ( queueLength > 1 ) {
  9135. queue.splice.apply( queue,
  9136. [ 1, 0 ].concat( queue.splice( queueLength, count ) ) );
  9137. }
  9138. element.dequeue();
  9139. },
  9140. saveStyle: function( element ) {
  9141. element.data( dataSpaceStyle, element[ 0 ].style.cssText );
  9142. },
  9143. restoreStyle: function( element ) {
  9144. element[ 0 ].style.cssText = element.data( dataSpaceStyle ) || "";
  9145. element.removeData( dataSpaceStyle );
  9146. },
  9147. mode: function( element, mode ) {
  9148. var hidden = element.is( ":hidden" );
  9149. if ( mode === "toggle" ) {
  9150. mode = hidden ? "show" : "hide";
  9151. }
  9152. if ( hidden ? mode === "hide" : mode === "show" ) {
  9153. mode = "none";
  9154. }
  9155. return mode;
  9156. },
  9157. // Translates a [top,left] array into a baseline value
  9158. getBaseline: function( origin, original ) {
  9159. var y, x;
  9160. switch ( origin[ 0 ] ) {
  9161. case "top":
  9162. y = 0;
  9163. break;
  9164. case "middle":
  9165. y = 0.5;
  9166. break;
  9167. case "bottom":
  9168. y = 1;
  9169. break;
  9170. default:
  9171. y = origin[ 0 ] / original.height;
  9172. }
  9173. switch ( origin[ 1 ] ) {
  9174. case "left":
  9175. x = 0;
  9176. break;
  9177. case "center":
  9178. x = 0.5;
  9179. break;
  9180. case "right":
  9181. x = 1;
  9182. break;
  9183. default:
  9184. x = origin[ 1 ] / original.width;
  9185. }
  9186. return {
  9187. x: x,
  9188. y: y
  9189. };
  9190. },
  9191. // Creates a placeholder element so that the original element can be made absolute
  9192. createPlaceholder: function( element ) {
  9193. var placeholder,
  9194. cssPosition = element.css( "position" ),
  9195. position = element.position();
  9196. // Lock in margins first to account for form elements, which
  9197. // will change margin if you explicitly set height
  9198. // see: http://jsfiddle.net/JZSMt/3/ https://bugs.webkit.org/show_bug.cgi?id=107380
  9199. // Support: Safari
  9200. element.css( {
  9201. marginTop: element.css( "marginTop" ),
  9202. marginBottom: element.css( "marginBottom" ),
  9203. marginLeft: element.css( "marginLeft" ),
  9204. marginRight: element.css( "marginRight" )
  9205. } )
  9206. .outerWidth( element.outerWidth() )
  9207. .outerHeight( element.outerHeight() );
  9208. if ( /^(static|relative)/.test( cssPosition ) ) {
  9209. cssPosition = "absolute";
  9210. placeholder = $( "<" + element[ 0 ].nodeName + ">" ).insertAfter( element ).css( {
  9211. // Convert inline to inline block to account for inline elements
  9212. // that turn to inline block based on content (like img)
  9213. display: /^(inline|ruby)/.test( element.css( "display" ) ) ?
  9214. "inline-block" :
  9215. "block",
  9216. visibility: "hidden",
  9217. // Margins need to be set to account for margin collapse
  9218. marginTop: element.css( "marginTop" ),
  9219. marginBottom: element.css( "marginBottom" ),
  9220. marginLeft: element.css( "marginLeft" ),
  9221. marginRight: element.css( "marginRight" ),
  9222. "float": element.css( "float" )
  9223. } )
  9224. .outerWidth( element.outerWidth() )
  9225. .outerHeight( element.outerHeight() )
  9226. .addClass( "ui-effects-placeholder" );
  9227. element.data( dataSpace + "placeholder", placeholder );
  9228. }
  9229. element.css( {
  9230. position: cssPosition,
  9231. left: position.left,
  9232. top: position.top
  9233. } );
  9234. return placeholder;
  9235. },
  9236. removePlaceholder: function( element ) {
  9237. var dataKey = dataSpace + "placeholder",
  9238. placeholder = element.data( dataKey );
  9239. if ( placeholder ) {
  9240. placeholder.remove();
  9241. element.removeData( dataKey );
  9242. }
  9243. },
  9244. // Removes a placeholder if it exists and restores
  9245. // properties that were modified during placeholder creation
  9246. cleanUp: function( element ) {
  9247. $.effects.restoreStyle( element );
  9248. $.effects.removePlaceholder( element );
  9249. },
  9250. setTransition: function( element, list, factor, value ) {
  9251. value = value || {};
  9252. $.each( list, function( i, x ) {
  9253. var unit = element.cssUnit( x );
  9254. if ( unit[ 0 ] > 0 ) {
  9255. value[ x ] = unit[ 0 ] * factor + unit[ 1 ];
  9256. }
  9257. } );
  9258. return value;
  9259. }
  9260. } );
  9261. // Return an effect options object for the given parameters:
  9262. function _normalizeArguments( effect, options, speed, callback ) {
  9263. // Allow passing all options as the first parameter
  9264. if ( $.isPlainObject( effect ) ) {
  9265. options = effect;
  9266. effect = effect.effect;
  9267. }
  9268. // Convert to an object
  9269. effect = { effect: effect };
  9270. // Catch (effect, null, ...)
  9271. if ( options == null ) {
  9272. options = {};
  9273. }
  9274. // Catch (effect, callback)
  9275. if ( $.isFunction( options ) ) {
  9276. callback = options;
  9277. speed = null;
  9278. options = {};
  9279. }
  9280. // Catch (effect, speed, ?)
  9281. if ( typeof options === "number" || $.fx.speeds[ options ] ) {
  9282. callback = speed;
  9283. speed = options;
  9284. options = {};
  9285. }
  9286. // Catch (effect, options, callback)
  9287. if ( $.isFunction( speed ) ) {
  9288. callback = speed;
  9289. speed = null;
  9290. }
  9291. // Add options to effect
  9292. if ( options ) {
  9293. $.extend( effect, options );
  9294. }
  9295. speed = speed || options.duration;
  9296. effect.duration = $.fx.off ? 0 :
  9297. typeof speed === "number" ? speed :
  9298. speed in $.fx.speeds ? $.fx.speeds[ speed ] :
  9299. $.fx.speeds._default;
  9300. effect.complete = callback || options.complete;
  9301. return effect;
  9302. }
  9303. function standardAnimationOption( option ) {
  9304. // Valid standard speeds (nothing, number, named speed)
  9305. if ( !option || typeof option === "number" || $.fx.speeds[ option ] ) {
  9306. return true;
  9307. }
  9308. // Invalid strings - treat as "normal" speed
  9309. if ( typeof option === "string" && !$.effects.effect[ option ] ) {
  9310. return true;
  9311. }
  9312. // Complete callback
  9313. if ( $.isFunction( option ) ) {
  9314. return true;
  9315. }
  9316. // Options hash (but not naming an effect)
  9317. if ( typeof option === "object" && !option.effect ) {
  9318. return true;
  9319. }
  9320. // Didn't match any standard API
  9321. return false;
  9322. }
  9323. $.fn.extend( {
  9324. effect: function( /* effect, options, speed, callback */ ) {
  9325. var args = _normalizeArguments.apply( this, arguments ),
  9326. effectMethod = $.effects.effect[ args.effect ],
  9327. defaultMode = effectMethod.mode,
  9328. queue = args.queue,
  9329. queueName = queue || "fx",
  9330. complete = args.complete,
  9331. mode = args.mode,
  9332. modes = [],
  9333. prefilter = function( next ) {
  9334. var el = $( this ),
  9335. normalizedMode = $.effects.mode( el, mode ) || defaultMode;
  9336. // Sentinel for duck-punching the :animated psuedo-selector
  9337. el.data( dataSpaceAnimated, true );
  9338. // Save effect mode for later use,
  9339. // we can't just call $.effects.mode again later,
  9340. // as the .show() below destroys the initial state
  9341. modes.push( normalizedMode );
  9342. // See $.uiBackCompat inside of run() for removal of defaultMode in 1.13
  9343. if ( defaultMode && ( normalizedMode === "show" ||
  9344. ( normalizedMode === defaultMode && normalizedMode === "hide" ) ) ) {
  9345. el.show();
  9346. }
  9347. if ( !defaultMode || normalizedMode !== "none" ) {
  9348. $.effects.saveStyle( el );
  9349. }
  9350. if ( $.isFunction( next ) ) {
  9351. next();
  9352. }
  9353. };
  9354. if ( $.fx.off || !effectMethod ) {
  9355. // Delegate to the original method (e.g., .show()) if possible
  9356. if ( mode ) {
  9357. return this[ mode ]( args.duration, complete );
  9358. } else {
  9359. return this.each( function() {
  9360. if ( complete ) {
  9361. complete.call( this );
  9362. }
  9363. } );
  9364. }
  9365. }
  9366. function run( next ) {
  9367. var elem = $( this );
  9368. function cleanup() {
  9369. elem.removeData( dataSpaceAnimated );
  9370. $.effects.cleanUp( elem );
  9371. if ( args.mode === "hide" ) {
  9372. elem.hide();
  9373. }
  9374. done();
  9375. }
  9376. function done() {
  9377. if ( $.isFunction( complete ) ) {
  9378. complete.call( elem[ 0 ] );
  9379. }
  9380. if ( $.isFunction( next ) ) {
  9381. next();
  9382. }
  9383. }
  9384. // Override mode option on a per element basis,
  9385. // as toggle can be either show or hide depending on element state
  9386. args.mode = modes.shift();
  9387. if ( $.uiBackCompat !== false && !defaultMode ) {
  9388. if ( elem.is( ":hidden" ) ? mode === "hide" : mode === "show" ) {
  9389. // Call the core method to track "olddisplay" properly
  9390. elem[ mode ]();
  9391. done();
  9392. } else {
  9393. effectMethod.call( elem[ 0 ], args, done );
  9394. }
  9395. } else {
  9396. if ( args.mode === "none" ) {
  9397. // Call the core method to track "olddisplay" properly
  9398. elem[ mode ]();
  9399. done();
  9400. } else {
  9401. effectMethod.call( elem[ 0 ], args, cleanup );
  9402. }
  9403. }
  9404. }
  9405. // Run prefilter on all elements first to ensure that
  9406. // any showing or hiding happens before placeholder creation,
  9407. // which ensures that any layout changes are correctly captured.
  9408. return queue === false ?
  9409. this.each( prefilter ).each( run ) :
  9410. this.queue( queueName, prefilter ).queue( queueName, run );
  9411. },
  9412. show: ( function( orig ) {
  9413. return function( option ) {
  9414. if ( standardAnimationOption( option ) ) {
  9415. return orig.apply( this, arguments );
  9416. } else {
  9417. var args = _normalizeArguments.apply( this, arguments );
  9418. args.mode = "show";
  9419. return this.effect.call( this, args );
  9420. }
  9421. };
  9422. } )( $.fn.show ),
  9423. hide: ( function( orig ) {
  9424. return function( option ) {
  9425. if ( standardAnimationOption( option ) ) {
  9426. return orig.apply( this, arguments );
  9427. } else {
  9428. var args = _normalizeArguments.apply( this, arguments );
  9429. args.mode = "hide";
  9430. return this.effect.call( this, args );
  9431. }
  9432. };
  9433. } )( $.fn.hide ),
  9434. toggle: ( function( orig ) {
  9435. return function( option ) {
  9436. if ( standardAnimationOption( option ) || typeof option === "boolean" ) {
  9437. return orig.apply( this, arguments );
  9438. } else {
  9439. var args = _normalizeArguments.apply( this, arguments );
  9440. args.mode = "toggle";
  9441. return this.effect.call( this, args );
  9442. }
  9443. };
  9444. } )( $.fn.toggle ),
  9445. cssUnit: function( key ) {
  9446. var style = this.css( key ),
  9447. val = [];
  9448. $.each( [ "em", "px", "%", "pt" ], function( i, unit ) {
  9449. if ( style.indexOf( unit ) > 0 ) {
  9450. val = [ parseFloat( style ), unit ];
  9451. }
  9452. } );
  9453. return val;
  9454. },
  9455. cssClip: function( clipObj ) {
  9456. if ( clipObj ) {
  9457. return this.css( "clip", "rect(" + clipObj.top + "px " + clipObj.right + "px " +
  9458. clipObj.bottom + "px " + clipObj.left + "px)" );
  9459. }
  9460. return parseClip( this.css( "clip" ), this );
  9461. },
  9462. transfer: function( options, done ) {
  9463. var element = $( this ),
  9464. target = $( options.to ),
  9465. targetFixed = target.css( "position" ) === "fixed",
  9466. body = $( "body" ),
  9467. fixTop = targetFixed ? body.scrollTop() : 0,
  9468. fixLeft = targetFixed ? body.scrollLeft() : 0,
  9469. endPosition = target.offset(),
  9470. animation = {
  9471. top: endPosition.top - fixTop,
  9472. left: endPosition.left - fixLeft,
  9473. height: target.innerHeight(),
  9474. width: target.innerWidth()
  9475. },
  9476. startPosition = element.offset(),
  9477. transfer = $( "<div class='ui-effects-transfer'></div>" )
  9478. .appendTo( "body" )
  9479. .addClass( options.className )
  9480. .css( {
  9481. top: startPosition.top - fixTop,
  9482. left: startPosition.left - fixLeft,
  9483. height: element.innerHeight(),
  9484. width: element.innerWidth(),
  9485. position: targetFixed ? "fixed" : "absolute"
  9486. } )
  9487. .animate( animation, options.duration, options.easing, function() {
  9488. transfer.remove();
  9489. if ( $.isFunction( done ) ) {
  9490. done();
  9491. }
  9492. } );
  9493. }
  9494. } );
  9495. function parseClip( str, element ) {
  9496. var outerWidth = element.outerWidth(),
  9497. outerHeight = element.outerHeight(),
  9498. 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)\)$/,
  9499. values = clipRegex.exec( str ) || [ "", 0, outerWidth, outerHeight, 0 ];
  9500. return {
  9501. top: parseFloat( values[ 1 ] ) || 0,
  9502. right: values[ 2 ] === "auto" ? outerWidth : parseFloat( values[ 2 ] ),
  9503. bottom: values[ 3 ] === "auto" ? outerHeight : parseFloat( values[ 3 ] ),
  9504. left: parseFloat( values[ 4 ] ) || 0
  9505. };
  9506. }
  9507. $.fx.step.clip = function( fx ) {
  9508. if ( !fx.clipInit ) {
  9509. fx.start = $( fx.elem ).cssClip();
  9510. if ( typeof fx.end === "string" ) {
  9511. fx.end = parseClip( fx.end, fx.elem );
  9512. }
  9513. fx.clipInit = true;
  9514. }
  9515. $( fx.elem ).cssClip( {
  9516. top: fx.pos * ( fx.end.top - fx.start.top ) + fx.start.top,
  9517. right: fx.pos * ( fx.end.right - fx.start.right ) + fx.start.right,
  9518. bottom: fx.pos * ( fx.end.bottom - fx.start.bottom ) + fx.start.bottom,
  9519. left: fx.pos * ( fx.end.left - fx.start.left ) + fx.start.left
  9520. } );
  9521. };
  9522. } )();
  9523. /******************************************************************************/
  9524. /*********************************** EASING ***********************************/
  9525. /******************************************************************************/
  9526. ( function() {
  9527. // Based on easing equations from Robert Penner (http://www.robertpenner.com/easing)
  9528. var baseEasings = {};
  9529. $.each( [ "Quad", "Cubic", "Quart", "Quint", "Expo" ], function( i, name ) {
  9530. baseEasings[ name ] = function( p ) {
  9531. return Math.pow( p, i + 2 );
  9532. };
  9533. } );
  9534. $.extend( baseEasings, {
  9535. Sine: function( p ) {
  9536. return 1 - Math.cos( p * Math.PI / 2 );
  9537. },
  9538. Circ: function( p ) {
  9539. return 1 - Math.sqrt( 1 - p * p );
  9540. },
  9541. Elastic: function( p ) {
  9542. return p === 0 || p === 1 ? p :
  9543. -Math.pow( 2, 8 * ( p - 1 ) ) * Math.sin( ( ( p - 1 ) * 80 - 7.5 ) * Math.PI / 15 );
  9544. },
  9545. Back: function( p ) {
  9546. return p * p * ( 3 * p - 2 );
  9547. },
  9548. Bounce: function( p ) {
  9549. var pow2,
  9550. bounce = 4;
  9551. while ( p < ( ( pow2 = Math.pow( 2, --bounce ) ) - 1 ) / 11 ) {}
  9552. return 1 / Math.pow( 4, 3 - bounce ) - 7.5625 * Math.pow( ( pow2 * 3 - 2 ) / 22 - p, 2 );
  9553. }
  9554. } );
  9555. $.each( baseEasings, function( name, easeIn ) {
  9556. $.easing[ "easeIn" + name ] = easeIn;
  9557. $.easing[ "easeOut" + name ] = function( p ) {
  9558. return 1 - easeIn( 1 - p );
  9559. };
  9560. $.easing[ "easeInOut" + name ] = function( p ) {
  9561. return p < 0.5 ?
  9562. easeIn( p * 2 ) / 2 :
  9563. 1 - easeIn( p * -2 + 2 ) / 2;
  9564. };
  9565. } );
  9566. } )();
  9567. var effect = $.effects;
  9568. /*!
  9569. * jQuery UI Effects Blind 1.12.1
  9570. * http://jqueryui.com
  9571. *
  9572. * Copyright jQuery Foundation and other contributors
  9573. * Released under the MIT license.
  9574. * http://jquery.org/license
  9575. */
  9576. //>>label: Blind Effect
  9577. //>>group: Effects
  9578. //>>description: Blinds the element.
  9579. //>>docs: http://api.jqueryui.com/blind-effect/
  9580. //>>demos: http://jqueryui.com/effect/
  9581. var effectsEffectBlind = $.effects.define( "blind", "hide", function( options, done ) {
  9582. var map = {
  9583. up: [ "bottom", "top" ],
  9584. vertical: [ "bottom", "top" ],
  9585. down: [ "top", "bottom" ],
  9586. left: [ "right", "left" ],
  9587. horizontal: [ "right", "left" ],
  9588. right: [ "left", "right" ]
  9589. },
  9590. element = $( this ),
  9591. direction = options.direction || "up",
  9592. start = element.cssClip(),
  9593. animate = { clip: $.extend( {}, start ) },
  9594. placeholder = $.effects.createPlaceholder( element );
  9595. animate.clip[ map[ direction ][ 0 ] ] = animate.clip[ map[ direction ][ 1 ] ];
  9596. if ( options.mode === "show" ) {
  9597. element.cssClip( animate.clip );
  9598. if ( placeholder ) {
  9599. placeholder.css( $.effects.clipToBox( animate ) );
  9600. }
  9601. animate.clip = start;
  9602. }
  9603. if ( placeholder ) {
  9604. placeholder.animate( $.effects.clipToBox( animate ), options.duration, options.easing );
  9605. }
  9606. element.animate( animate, {
  9607. queue: false,
  9608. duration: options.duration,
  9609. easing: options.easing,
  9610. complete: done
  9611. } );
  9612. } );
  9613. /*!
  9614. * jQuery UI Effects Bounce 1.12.1
  9615. * http://jqueryui.com
  9616. *
  9617. * Copyright jQuery Foundation and other contributors
  9618. * Released under the MIT license.
  9619. * http://jquery.org/license
  9620. */
  9621. //>>label: Bounce Effect
  9622. //>>group: Effects
  9623. //>>description: Bounces an element horizontally or vertically n times.
  9624. //>>docs: http://api.jqueryui.com/bounce-effect/
  9625. //>>demos: http://jqueryui.com/effect/
  9626. var effectsEffectBounce = $.effects.define( "bounce", function( options, done ) {
  9627. var upAnim, downAnim, refValue,
  9628. element = $( this ),
  9629. // Defaults:
  9630. mode = options.mode,
  9631. hide = mode === "hide",
  9632. show = mode === "show",
  9633. direction = options.direction || "up",
  9634. distance = options.distance,
  9635. times = options.times || 5,
  9636. // Number of internal animations
  9637. anims = times * 2 + ( show || hide ? 1 : 0 ),
  9638. speed = options.duration / anims,
  9639. easing = options.easing,
  9640. // Utility:
  9641. ref = ( direction === "up" || direction === "down" ) ? "top" : "left",
  9642. motion = ( direction === "up" || direction === "left" ),
  9643. i = 0,
  9644. queuelen = element.queue().length;
  9645. $.effects.createPlaceholder( element );
  9646. refValue = element.css( ref );
  9647. // Default distance for the BIGGEST bounce is the outer Distance / 3
  9648. if ( !distance ) {
  9649. distance = element[ ref === "top" ? "outerHeight" : "outerWidth" ]() / 3;
  9650. }
  9651. if ( show ) {
  9652. downAnim = { opacity: 1 };
  9653. downAnim[ ref ] = refValue;
  9654. // If we are showing, force opacity 0 and set the initial position
  9655. // then do the "first" animation
  9656. element
  9657. .css( "opacity", 0 )
  9658. .css( ref, motion ? -distance * 2 : distance * 2 )
  9659. .animate( downAnim, speed, easing );
  9660. }
  9661. // Start at the smallest distance if we are hiding
  9662. if ( hide ) {
  9663. distance = distance / Math.pow( 2, times - 1 );
  9664. }
  9665. downAnim = {};
  9666. downAnim[ ref ] = refValue;
  9667. // Bounces up/down/left/right then back to 0 -- times * 2 animations happen here
  9668. for ( ; i < times; i++ ) {
  9669. upAnim = {};
  9670. upAnim[ ref ] = ( motion ? "-=" : "+=" ) + distance;
  9671. element
  9672. .animate( upAnim, speed, easing )
  9673. .animate( downAnim, speed, easing );
  9674. distance = hide ? distance * 2 : distance / 2;
  9675. }
  9676. // Last Bounce when Hiding
  9677. if ( hide ) {
  9678. upAnim = { opacity: 0 };
  9679. upAnim[ ref ] = ( motion ? "-=" : "+=" ) + distance;
  9680. element.animate( upAnim, speed, easing );
  9681. }
  9682. element.queue( done );
  9683. $.effects.unshift( element, queuelen, anims + 1 );
  9684. } );
  9685. /*!
  9686. * jQuery UI Effects Clip 1.12.1
  9687. * http://jqueryui.com
  9688. *
  9689. * Copyright jQuery Foundation and other contributors
  9690. * Released under the MIT license.
  9691. * http://jquery.org/license
  9692. */
  9693. //>>label: Clip Effect
  9694. //>>group: Effects
  9695. //>>description: Clips the element on and off like an old TV.
  9696. //>>docs: http://api.jqueryui.com/clip-effect/
  9697. //>>demos: http://jqueryui.com/effect/
  9698. var effectsEffectClip = $.effects.define( "clip", "hide", function( options, done ) {
  9699. var start,
  9700. animate = {},
  9701. element = $( this ),
  9702. direction = options.direction || "vertical",
  9703. both = direction === "both",
  9704. horizontal = both || direction === "horizontal",
  9705. vertical = both || direction === "vertical";
  9706. start = element.cssClip();
  9707. animate.clip = {
  9708. top: vertical ? ( start.bottom - start.top ) / 2 : start.top,
  9709. right: horizontal ? ( start.right - start.left ) / 2 : start.right,
  9710. bottom: vertical ? ( start.bottom - start.top ) / 2 : start.bottom,
  9711. left: horizontal ? ( start.right - start.left ) / 2 : start.left
  9712. };
  9713. $.effects.createPlaceholder( element );
  9714. if ( options.mode === "show" ) {
  9715. element.cssClip( animate.clip );
  9716. animate.clip = start;
  9717. }
  9718. element.animate( animate, {
  9719. queue: false,
  9720. duration: options.duration,
  9721. easing: options.easing,
  9722. complete: done
  9723. } );
  9724. } );
  9725. /*!
  9726. * jQuery UI Effects Drop 1.12.1
  9727. * http://jqueryui.com
  9728. *
  9729. * Copyright jQuery Foundation and other contributors
  9730. * Released under the MIT license.
  9731. * http://jquery.org/license
  9732. */
  9733. //>>label: Drop Effect
  9734. //>>group: Effects
  9735. //>>description: Moves an element in one direction and hides it at the same time.
  9736. //>>docs: http://api.jqueryui.com/drop-effect/
  9737. //>>demos: http://jqueryui.com/effect/
  9738. var effectsEffectDrop = $.effects.define( "drop", "hide", function( options, done ) {
  9739. var distance,
  9740. element = $( this ),
  9741. mode = options.mode,
  9742. show = mode === "show",
  9743. direction = options.direction || "left",
  9744. ref = ( direction === "up" || direction === "down" ) ? "top" : "left",
  9745. motion = ( direction === "up" || direction === "left" ) ? "-=" : "+=",
  9746. oppositeMotion = ( motion === "+=" ) ? "-=" : "+=",
  9747. animation = {
  9748. opacity: 0
  9749. };
  9750. $.effects.createPlaceholder( element );
  9751. distance = options.distance ||
  9752. element[ ref === "top" ? "outerHeight" : "outerWidth" ]( true ) / 2;
  9753. animation[ ref ] = motion + distance;
  9754. if ( show ) {
  9755. element.css( animation );
  9756. animation[ ref ] = oppositeMotion + distance;
  9757. animation.opacity = 1;
  9758. }
  9759. // Animate
  9760. element.animate( animation, {
  9761. queue: false,
  9762. duration: options.duration,
  9763. easing: options.easing,
  9764. complete: done
  9765. } );
  9766. } );
  9767. /*!
  9768. * jQuery UI Effects Explode 1.12.1
  9769. * http://jqueryui.com
  9770. *
  9771. * Copyright jQuery Foundation and other contributors
  9772. * Released under the MIT license.
  9773. * http://jquery.org/license
  9774. */
  9775. //>>label: Explode Effect
  9776. //>>group: Effects
  9777. // jscs:disable maximumLineLength
  9778. //>>description: Explodes an element in all directions into n pieces. Implodes an element to its original wholeness.
  9779. // jscs:enable maximumLineLength
  9780. //>>docs: http://api.jqueryui.com/explode-effect/
  9781. //>>demos: http://jqueryui.com/effect/
  9782. var effectsEffectExplode = $.effects.define( "explode", "hide", function( options, done ) {
  9783. var i, j, left, top, mx, my,
  9784. rows = options.pieces ? Math.round( Math.sqrt( options.pieces ) ) : 3,
  9785. cells = rows,
  9786. element = $( this ),
  9787. mode = options.mode,
  9788. show = mode === "show",
  9789. // Show and then visibility:hidden the element before calculating offset
  9790. offset = element.show().css( "visibility", "hidden" ).offset(),
  9791. // Width and height of a piece
  9792. width = Math.ceil( element.outerWidth() / cells ),
  9793. height = Math.ceil( element.outerHeight() / rows ),
  9794. pieces = [];
  9795. // Children animate complete:
  9796. function childComplete() {
  9797. pieces.push( this );
  9798. if ( pieces.length === rows * cells ) {
  9799. animComplete();
  9800. }
  9801. }
  9802. // Clone the element for each row and cell.
  9803. for ( i = 0; i < rows; i++ ) { // ===>
  9804. top = offset.top + i * height;
  9805. my = i - ( rows - 1 ) / 2;
  9806. for ( j = 0; j < cells; j++ ) { // |||
  9807. left = offset.left + j * width;
  9808. mx = j - ( cells - 1 ) / 2;
  9809. // Create a clone of the now hidden main element that will be absolute positioned
  9810. // within a wrapper div off the -left and -top equal to size of our pieces
  9811. element
  9812. .clone()
  9813. .appendTo( "body" )
  9814. .wrap( "<div></div>" )
  9815. .css( {
  9816. position: "absolute",
  9817. visibility: "visible",
  9818. left: -j * width,
  9819. top: -i * height
  9820. } )
  9821. // Select the wrapper - make it overflow: hidden and absolute positioned based on
  9822. // where the original was located +left and +top equal to the size of pieces
  9823. .parent()
  9824. .addClass( "ui-effects-explode" )
  9825. .css( {
  9826. position: "absolute",
  9827. overflow: "hidden",
  9828. width: width,
  9829. height: height,
  9830. left: left + ( show ? mx * width : 0 ),
  9831. top: top + ( show ? my * height : 0 ),
  9832. opacity: show ? 0 : 1
  9833. } )
  9834. .animate( {
  9835. left: left + ( show ? 0 : mx * width ),
  9836. top: top + ( show ? 0 : my * height ),
  9837. opacity: show ? 1 : 0
  9838. }, options.duration || 500, options.easing, childComplete );
  9839. }
  9840. }
  9841. function animComplete() {
  9842. element.css( {
  9843. visibility: "visible"
  9844. } );
  9845. $( pieces ).remove();
  9846. done();
  9847. }
  9848. } );
  9849. /*!
  9850. * jQuery UI Effects Fade 1.12.1
  9851. * http://jqueryui.com
  9852. *
  9853. * Copyright jQuery Foundation and other contributors
  9854. * Released under the MIT license.
  9855. * http://jquery.org/license
  9856. */
  9857. //>>label: Fade Effect
  9858. //>>group: Effects
  9859. //>>description: Fades the element.
  9860. //>>docs: http://api.jqueryui.com/fade-effect/
  9861. //>>demos: http://jqueryui.com/effect/
  9862. var effectsEffectFade = $.effects.define( "fade", "toggle", function( options, done ) {
  9863. var show = options.mode === "show";
  9864. $( this )
  9865. .css( "opacity", show ? 0 : 1 )
  9866. .animate( {
  9867. opacity: show ? 1 : 0
  9868. }, {
  9869. queue: false,
  9870. duration: options.duration,
  9871. easing: options.easing,
  9872. complete: done
  9873. } );
  9874. } );
  9875. /*!
  9876. * jQuery UI Effects Fold 1.12.1
  9877. * http://jqueryui.com
  9878. *
  9879. * Copyright jQuery Foundation and other contributors
  9880. * Released under the MIT license.
  9881. * http://jquery.org/license
  9882. */
  9883. //>>label: Fold Effect
  9884. //>>group: Effects
  9885. //>>description: Folds an element first horizontally and then vertically.
  9886. //>>docs: http://api.jqueryui.com/fold-effect/
  9887. //>>demos: http://jqueryui.com/effect/
  9888. var effectsEffectFold = $.effects.define( "fold", "hide", function( options, done ) {
  9889. // Create element
  9890. var element = $( this ),
  9891. mode = options.mode,
  9892. show = mode === "show",
  9893. hide = mode === "hide",
  9894. size = options.size || 15,
  9895. percent = /([0-9]+)%/.exec( size ),
  9896. horizFirst = !!options.horizFirst,
  9897. ref = horizFirst ? [ "right", "bottom" ] : [ "bottom", "right" ],
  9898. duration = options.duration / 2,
  9899. placeholder = $.effects.createPlaceholder( element ),
  9900. start = element.cssClip(),
  9901. animation1 = { clip: $.extend( {}, start ) },
  9902. animation2 = { clip: $.extend( {}, start ) },
  9903. distance = [ start[ ref[ 0 ] ], start[ ref[ 1 ] ] ],
  9904. queuelen = element.queue().length;
  9905. if ( percent ) {
  9906. size = parseInt( percent[ 1 ], 10 ) / 100 * distance[ hide ? 0 : 1 ];
  9907. }
  9908. animation1.clip[ ref[ 0 ] ] = size;
  9909. animation2.clip[ ref[ 0 ] ] = size;
  9910. animation2.clip[ ref[ 1 ] ] = 0;
  9911. if ( show ) {
  9912. element.cssClip( animation2.clip );
  9913. if ( placeholder ) {
  9914. placeholder.css( $.effects.clipToBox( animation2 ) );
  9915. }
  9916. animation2.clip = start;
  9917. }
  9918. // Animate
  9919. element
  9920. .queue( function( next ) {
  9921. if ( placeholder ) {
  9922. placeholder
  9923. .animate( $.effects.clipToBox( animation1 ), duration, options.easing )
  9924. .animate( $.effects.clipToBox( animation2 ), duration, options.easing );
  9925. }
  9926. next();
  9927. } )
  9928. .animate( animation1, duration, options.easing )
  9929. .animate( animation2, duration, options.easing )
  9930. .queue( done );
  9931. $.effects.unshift( element, queuelen, 4 );
  9932. } );
  9933. /*!
  9934. * jQuery UI Effects Highlight 1.12.1
  9935. * http://jqueryui.com
  9936. *
  9937. * Copyright jQuery Foundation and other contributors
  9938. * Released under the MIT license.
  9939. * http://jquery.org/license
  9940. */
  9941. //>>label: Highlight Effect
  9942. //>>group: Effects
  9943. //>>description: Highlights the background of an element in a defined color for a custom duration.
  9944. //>>docs: http://api.jqueryui.com/highlight-effect/
  9945. //>>demos: http://jqueryui.com/effect/
  9946. var effectsEffectHighlight = $.effects.define( "highlight", "show", function( options, done ) {
  9947. var element = $( this ),
  9948. animation = {
  9949. backgroundColor: element.css( "backgroundColor" )
  9950. };
  9951. if ( options.mode === "hide" ) {
  9952. animation.opacity = 0;
  9953. }
  9954. $.effects.saveStyle( element );
  9955. element
  9956. .css( {
  9957. backgroundImage: "none",
  9958. backgroundColor: options.color || "#ffff99"
  9959. } )
  9960. .animate( animation, {
  9961. queue: false,
  9962. duration: options.duration,
  9963. easing: options.easing,
  9964. complete: done
  9965. } );
  9966. } );
  9967. /*!
  9968. * jQuery UI Effects Size 1.12.1
  9969. * http://jqueryui.com
  9970. *
  9971. * Copyright jQuery Foundation and other contributors
  9972. * Released under the MIT license.
  9973. * http://jquery.org/license
  9974. */
  9975. //>>label: Size Effect
  9976. //>>group: Effects
  9977. //>>description: Resize an element to a specified width and height.
  9978. //>>docs: http://api.jqueryui.com/size-effect/
  9979. //>>demos: http://jqueryui.com/effect/
  9980. var effectsEffectSize = $.effects.define( "size", function( options, done ) {
  9981. // Create element
  9982. var baseline, factor, temp,
  9983. element = $( this ),
  9984. // Copy for children
  9985. cProps = [ "fontSize" ],
  9986. vProps = [ "borderTopWidth", "borderBottomWidth", "paddingTop", "paddingBottom" ],
  9987. hProps = [ "borderLeftWidth", "borderRightWidth", "paddingLeft", "paddingRight" ],
  9988. // Set options
  9989. mode = options.mode,
  9990. restore = mode !== "effect",
  9991. scale = options.scale || "both",
  9992. origin = options.origin || [ "middle", "center" ],
  9993. position = element.css( "position" ),
  9994. pos = element.position(),
  9995. original = $.effects.scaledDimensions( element ),
  9996. from = options.from || original,
  9997. to = options.to || $.effects.scaledDimensions( element, 0 );
  9998. $.effects.createPlaceholder( element );
  9999. if ( mode === "show" ) {
  10000. temp = from;
  10001. from = to;
  10002. to = temp;
  10003. }
  10004. // Set scaling factor
  10005. factor = {
  10006. from: {
  10007. y: from.height / original.height,
  10008. x: from.width / original.width
  10009. },
  10010. to: {
  10011. y: to.height / original.height,
  10012. x: to.width / original.width
  10013. }
  10014. };
  10015. // Scale the css box
  10016. if ( scale === "box" || scale === "both" ) {
  10017. // Vertical props scaling
  10018. if ( factor.from.y !== factor.to.y ) {
  10019. from = $.effects.setTransition( element, vProps, factor.from.y, from );
  10020. to = $.effects.setTransition( element, vProps, factor.to.y, to );
  10021. }
  10022. // Horizontal props scaling
  10023. if ( factor.from.x !== factor.to.x ) {
  10024. from = $.effects.setTransition( element, hProps, factor.from.x, from );
  10025. to = $.effects.setTransition( element, hProps, factor.to.x, to );
  10026. }
  10027. }
  10028. // Scale the content
  10029. if ( scale === "content" || scale === "both" ) {
  10030. // Vertical props scaling
  10031. if ( factor.from.y !== factor.to.y ) {
  10032. from = $.effects.setTransition( element, cProps, factor.from.y, from );
  10033. to = $.effects.setTransition( element, cProps, factor.to.y, to );
  10034. }
  10035. }
  10036. // Adjust the position properties based on the provided origin points
  10037. if ( origin ) {
  10038. baseline = $.effects.getBaseline( origin, original );
  10039. from.top = ( original.outerHeight - from.outerHeight ) * baseline.y + pos.top;
  10040. from.left = ( original.outerWidth - from.outerWidth ) * baseline.x + pos.left;
  10041. to.top = ( original.outerHeight - to.outerHeight ) * baseline.y + pos.top;
  10042. to.left = ( original.outerWidth - to.outerWidth ) * baseline.x + pos.left;
  10043. }
  10044. element.css( from );
  10045. // Animate the children if desired
  10046. if ( scale === "content" || scale === "both" ) {
  10047. vProps = vProps.concat( [ "marginTop", "marginBottom" ] ).concat( cProps );
  10048. hProps = hProps.concat( [ "marginLeft", "marginRight" ] );
  10049. // Only animate children with width attributes specified
  10050. // TODO: is this right? should we include anything with css width specified as well
  10051. element.find( "*[width]" ).each( function() {
  10052. var child = $( this ),
  10053. childOriginal = $.effects.scaledDimensions( child ),
  10054. childFrom = {
  10055. height: childOriginal.height * factor.from.y,
  10056. width: childOriginal.width * factor.from.x,
  10057. outerHeight: childOriginal.outerHeight * factor.from.y,
  10058. outerWidth: childOriginal.outerWidth * factor.from.x
  10059. },
  10060. childTo = {
  10061. height: childOriginal.height * factor.to.y,
  10062. width: childOriginal.width * factor.to.x,
  10063. outerHeight: childOriginal.height * factor.to.y,
  10064. outerWidth: childOriginal.width * factor.to.x
  10065. };
  10066. // Vertical props scaling
  10067. if ( factor.from.y !== factor.to.y ) {
  10068. childFrom = $.effects.setTransition( child, vProps, factor.from.y, childFrom );
  10069. childTo = $.effects.setTransition( child, vProps, factor.to.y, childTo );
  10070. }
  10071. // Horizontal props scaling
  10072. if ( factor.from.x !== factor.to.x ) {
  10073. childFrom = $.effects.setTransition( child, hProps, factor.from.x, childFrom );
  10074. childTo = $.effects.setTransition( child, hProps, factor.to.x, childTo );
  10075. }
  10076. if ( restore ) {
  10077. $.effects.saveStyle( child );
  10078. }
  10079. // Animate children
  10080. child.css( childFrom );
  10081. child.animate( childTo, options.duration, options.easing, function() {
  10082. // Restore children
  10083. if ( restore ) {
  10084. $.effects.restoreStyle( child );
  10085. }
  10086. } );
  10087. } );
  10088. }
  10089. // Animate
  10090. element.animate( to, {
  10091. queue: false,
  10092. duration: options.duration,
  10093. easing: options.easing,
  10094. complete: function() {
  10095. var offset = element.offset();
  10096. if ( to.opacity === 0 ) {
  10097. element.css( "opacity", from.opacity );
  10098. }
  10099. if ( !restore ) {
  10100. element
  10101. .css( "position", position === "static" ? "relative" : position )
  10102. .offset( offset );
  10103. // Need to save style here so that automatic style restoration
  10104. // doesn't restore to the original styles from before the animation.
  10105. $.effects.saveStyle( element );
  10106. }
  10107. done();
  10108. }
  10109. } );
  10110. } );
  10111. /*!
  10112. * jQuery UI Effects Scale 1.12.1
  10113. * http://jqueryui.com
  10114. *
  10115. * Copyright jQuery Foundation and other contributors
  10116. * Released under the MIT license.
  10117. * http://jquery.org/license
  10118. */
  10119. //>>label: Scale Effect
  10120. //>>group: Effects
  10121. //>>description: Grows or shrinks an element and its content.
  10122. //>>docs: http://api.jqueryui.com/scale-effect/
  10123. //>>demos: http://jqueryui.com/effect/
  10124. var effectsEffectScale = $.effects.define( "scale", function( options, done ) {
  10125. // Create element
  10126. var el = $( this ),
  10127. mode = options.mode,
  10128. percent = parseInt( options.percent, 10 ) ||
  10129. ( parseInt( options.percent, 10 ) === 0 ? 0 : ( mode !== "effect" ? 0 : 100 ) ),
  10130. newOptions = $.extend( true, {
  10131. from: $.effects.scaledDimensions( el ),
  10132. to: $.effects.scaledDimensions( el, percent, options.direction || "both" ),
  10133. origin: options.origin || [ "middle", "center" ]
  10134. }, options );
  10135. // Fade option to support puff
  10136. if ( options.fade ) {
  10137. newOptions.from.opacity = 1;
  10138. newOptions.to.opacity = 0;
  10139. }
  10140. $.effects.effect.size.call( this, newOptions, done );
  10141. } );
  10142. /*!
  10143. * jQuery UI Effects Puff 1.12.1
  10144. * http://jqueryui.com
  10145. *
  10146. * Copyright jQuery Foundation and other contributors
  10147. * Released under the MIT license.
  10148. * http://jquery.org/license
  10149. */
  10150. //>>label: Puff Effect
  10151. //>>group: Effects
  10152. //>>description: Creates a puff effect by scaling the element up and hiding it at the same time.
  10153. //>>docs: http://api.jqueryui.com/puff-effect/
  10154. //>>demos: http://jqueryui.com/effect/
  10155. var effectsEffectPuff = $.effects.define( "puff", "hide", function( options, done ) {
  10156. var newOptions = $.extend( true, {}, options, {
  10157. fade: true,
  10158. percent: parseInt( options.percent, 10 ) || 150
  10159. } );
  10160. $.effects.effect.scale.call( this, newOptions, done );
  10161. } );
  10162. /*!
  10163. * jQuery UI Effects Pulsate 1.12.1
  10164. * http://jqueryui.com
  10165. *
  10166. * Copyright jQuery Foundation and other contributors
  10167. * Released under the MIT license.
  10168. * http://jquery.org/license
  10169. */
  10170. //>>label: Pulsate Effect
  10171. //>>group: Effects
  10172. //>>description: Pulsates an element n times by changing the opacity to zero and back.
  10173. //>>docs: http://api.jqueryui.com/pulsate-effect/
  10174. //>>demos: http://jqueryui.com/effect/
  10175. var effectsEffectPulsate = $.effects.define( "pulsate", "show", function( options, done ) {
  10176. var element = $( this ),
  10177. mode = options.mode,
  10178. show = mode === "show",
  10179. hide = mode === "hide",
  10180. showhide = show || hide,
  10181. // Showing or hiding leaves off the "last" animation
  10182. anims = ( ( options.times || 5 ) * 2 ) + ( showhide ? 1 : 0 ),
  10183. duration = options.duration / anims,
  10184. animateTo = 0,
  10185. i = 1,
  10186. queuelen = element.queue().length;
  10187. if ( show || !element.is( ":visible" ) ) {
  10188. element.css( "opacity", 0 ).show();
  10189. animateTo = 1;
  10190. }
  10191. // Anims - 1 opacity "toggles"
  10192. for ( ; i < anims; i++ ) {
  10193. element.animate( { opacity: animateTo }, duration, options.easing );
  10194. animateTo = 1 - animateTo;
  10195. }
  10196. element.animate( { opacity: animateTo }, duration, options.easing );
  10197. element.queue( done );
  10198. $.effects.unshift( element, queuelen, anims + 1 );
  10199. } );
  10200. /*!
  10201. * jQuery UI Effects Shake 1.12.1
  10202. * http://jqueryui.com
  10203. *
  10204. * Copyright jQuery Foundation and other contributors
  10205. * Released under the MIT license.
  10206. * http://jquery.org/license
  10207. */
  10208. //>>label: Shake Effect
  10209. //>>group: Effects
  10210. //>>description: Shakes an element horizontally or vertically n times.
  10211. //>>docs: http://api.jqueryui.com/shake-effect/
  10212. //>>demos: http://jqueryui.com/effect/
  10213. var effectsEffectShake = $.effects.define( "shake", function( options, done ) {
  10214. var i = 1,
  10215. element = $( this ),
  10216. direction = options.direction || "left",
  10217. distance = options.distance || 20,
  10218. times = options.times || 3,
  10219. anims = times * 2 + 1,
  10220. speed = Math.round( options.duration / anims ),
  10221. ref = ( direction === "up" || direction === "down" ) ? "top" : "left",
  10222. positiveMotion = ( direction === "up" || direction === "left" ),
  10223. animation = {},
  10224. animation1 = {},
  10225. animation2 = {},
  10226. queuelen = element.queue().length;
  10227. $.effects.createPlaceholder( element );
  10228. // Animation
  10229. animation[ ref ] = ( positiveMotion ? "-=" : "+=" ) + distance;
  10230. animation1[ ref ] = ( positiveMotion ? "+=" : "-=" ) + distance * 2;
  10231. animation2[ ref ] = ( positiveMotion ? "-=" : "+=" ) + distance * 2;
  10232. // Animate
  10233. element.animate( animation, speed, options.easing );
  10234. // Shakes
  10235. for ( ; i < times; i++ ) {
  10236. element
  10237. .animate( animation1, speed, options.easing )
  10238. .animate( animation2, speed, options.easing );
  10239. }
  10240. element
  10241. .animate( animation1, speed, options.easing )
  10242. .animate( animation, speed / 2, options.easing )
  10243. .queue( done );
  10244. $.effects.unshift( element, queuelen, anims + 1 );
  10245. } );
  10246. /*!
  10247. * jQuery UI Effects Slide 1.12.1
  10248. * http://jqueryui.com
  10249. *
  10250. * Copyright jQuery Foundation and other contributors
  10251. * Released under the MIT license.
  10252. * http://jquery.org/license
  10253. */
  10254. //>>label: Slide Effect
  10255. //>>group: Effects
  10256. //>>description: Slides an element in and out of the viewport.
  10257. //>>docs: http://api.jqueryui.com/slide-effect/
  10258. //>>demos: http://jqueryui.com/effect/
  10259. var effectsEffectSlide = $.effects.define( "slide", "show", function( options, done ) {
  10260. var startClip, startRef,
  10261. element = $( this ),
  10262. map = {
  10263. up: [ "bottom", "top" ],
  10264. down: [ "top", "bottom" ],
  10265. left: [ "right", "left" ],
  10266. right: [ "left", "right" ]
  10267. },
  10268. mode = options.mode,
  10269. direction = options.direction || "left",
  10270. ref = ( direction === "up" || direction === "down" ) ? "top" : "left",
  10271. positiveMotion = ( direction === "up" || direction === "left" ),
  10272. distance = options.distance ||
  10273. element[ ref === "top" ? "outerHeight" : "outerWidth" ]( true ),
  10274. animation = {};
  10275. $.effects.createPlaceholder( element );
  10276. startClip = element.cssClip();
  10277. startRef = element.position()[ ref ];
  10278. // Define hide animation
  10279. animation[ ref ] = ( positiveMotion ? -1 : 1 ) * distance + startRef;
  10280. animation.clip = element.cssClip();
  10281. animation.clip[ map[ direction ][ 1 ] ] = animation.clip[ map[ direction ][ 0 ] ];
  10282. // Reverse the animation if we're showing
  10283. if ( mode === "show" ) {
  10284. element.cssClip( animation.clip );
  10285. element.css( ref, animation[ ref ] );
  10286. animation.clip = startClip;
  10287. animation[ ref ] = startRef;
  10288. }
  10289. // Actually animate
  10290. element.animate( animation, {
  10291. queue: false,
  10292. duration: options.duration,
  10293. easing: options.easing,
  10294. complete: done
  10295. } );
  10296. } );
  10297. /*!
  10298. * jQuery UI Effects Transfer 1.12.1
  10299. * http://jqueryui.com
  10300. *
  10301. * Copyright jQuery Foundation and other contributors
  10302. * Released under the MIT license.
  10303. * http://jquery.org/license
  10304. */
  10305. //>>label: Transfer Effect
  10306. //>>group: Effects
  10307. //>>description: Displays a transfer effect from one element to another.
  10308. //>>docs: http://api.jqueryui.com/transfer-effect/
  10309. //>>demos: http://jqueryui.com/effect/
  10310. var effect;
  10311. if ( $.uiBackCompat !== false ) {
  10312. effect = $.effects.define( "transfer", function( options, done ) {
  10313. $( this ).transfer( options, done );
  10314. } );
  10315. }
  10316. var effectsEffectTransfer = effect;
  10317. }));