jquery-ui.js 459 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608
  1. /*! jQuery UI - v1.11.3 - 2015-02-12
  2. * http://jqueryui.com
  3. * Includes: core.js, widget.js, mouse.js, position.js, accordion.js, autocomplete.js, button.js, datepicker.js, dialog.js, draggable.js, droppable.js, effect.js, effect-blind.js, effect-bounce.js, effect-clip.js, effect-drop.js, effect-explode.js, effect-fade.js, effect-fold.js, effect-highlight.js, effect-puff.js, effect-pulsate.js, effect-scale.js, effect-shake.js, effect-size.js, effect-slide.js, effect-transfer.js, menu.js, progressbar.js, resizable.js, selectable.js, selectmenu.js, slider.js, sortable.js, spinner.js, tabs.js, tooltip.js
  4. * Copyright 2015 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. /*!
  15. * jQuery UI Core 1.11.3
  16. * http://jqueryui.com
  17. *
  18. * Copyright jQuery Foundation and other contributors
  19. * Released under the MIT license.
  20. * http://jquery.org/license
  21. *
  22. * http://api.jqueryui.com/category/ui-core/
  23. */
  24. // $.ui might exist from components with no dependencies, e.g., $.ui.position
  25. $.ui = $.ui || {};
  26. $.extend( $.ui, {
  27. version: "1.11.3",
  28. keyCode: {
  29. BACKSPACE: 8,
  30. COMMA: 188,
  31. DELETE: 46,
  32. DOWN: 40,
  33. END: 35,
  34. ENTER: 13,
  35. ESCAPE: 27,
  36. HOME: 36,
  37. LEFT: 37,
  38. PAGE_DOWN: 34,
  39. PAGE_UP: 33,
  40. PERIOD: 190,
  41. RIGHT: 39,
  42. SPACE: 32,
  43. TAB: 9,
  44. UP: 38
  45. }
  46. });
  47. // plugins
  48. $.fn.extend({
  49. scrollParent: function( includeHidden ) {
  50. var position = this.css( "position" ),
  51. excludeStaticParent = position === "absolute",
  52. overflowRegex = includeHidden ? /(auto|scroll|hidden)/ : /(auto|scroll)/,
  53. scrollParent = this.parents().filter( function() {
  54. var parent = $( this );
  55. if ( excludeStaticParent && parent.css( "position" ) === "static" ) {
  56. return false;
  57. }
  58. return overflowRegex.test( parent.css( "overflow" ) + parent.css( "overflow-y" ) + parent.css( "overflow-x" ) );
  59. }).eq( 0 );
  60. return position === "fixed" || !scrollParent.length ? $( this[ 0 ].ownerDocument || document ) : scrollParent;
  61. },
  62. uniqueId: (function() {
  63. var uuid = 0;
  64. return function() {
  65. return this.each(function() {
  66. if ( !this.id ) {
  67. this.id = "ui-id-" + ( ++uuid );
  68. }
  69. });
  70. };
  71. })(),
  72. removeUniqueId: function() {
  73. return this.each(function() {
  74. if ( /^ui-id-\d+$/.test( this.id ) ) {
  75. $( this ).removeAttr( "id" );
  76. }
  77. });
  78. }
  79. });
  80. // selectors
  81. function focusable( element, isTabIndexNotNaN ) {
  82. var map, mapName, img,
  83. nodeName = element.nodeName.toLowerCase();
  84. if ( "area" === nodeName ) {
  85. map = element.parentNode;
  86. mapName = map.name;
  87. if ( !element.href || !mapName || map.nodeName.toLowerCase() !== "map" ) {
  88. return false;
  89. }
  90. img = $( "img[usemap='#" + mapName + "']" )[ 0 ];
  91. return !!img && visible( img );
  92. }
  93. return ( /^(input|select|textarea|button|object)$/.test( nodeName ) ?
  94. !element.disabled :
  95. "a" === nodeName ?
  96. element.href || isTabIndexNotNaN :
  97. isTabIndexNotNaN) &&
  98. // the element and all of its ancestors must be visible
  99. visible( element );
  100. }
  101. function visible( element ) {
  102. return $.expr.filters.visible( element ) &&
  103. !$( element ).parents().addBack().filter(function() {
  104. return $.css( this, "visibility" ) === "hidden";
  105. }).length;
  106. }
  107. $.extend( $.expr[ ":" ], {
  108. data: $.expr.createPseudo ?
  109. $.expr.createPseudo(function( dataName ) {
  110. return function( elem ) {
  111. return !!$.data( elem, dataName );
  112. };
  113. }) :
  114. // support: jQuery <1.8
  115. function( elem, i, match ) {
  116. return !!$.data( elem, match[ 3 ] );
  117. },
  118. focusable: function( element ) {
  119. return focusable( element, !isNaN( $.attr( element, "tabindex" ) ) );
  120. },
  121. tabbable: function( element ) {
  122. var tabIndex = $.attr( element, "tabindex" ),
  123. isTabIndexNaN = isNaN( tabIndex );
  124. return ( isTabIndexNaN || tabIndex >= 0 ) && focusable( element, !isTabIndexNaN );
  125. }
  126. });
  127. // support: jQuery <1.8
  128. if ( !$( "<a>" ).outerWidth( 1 ).jquery ) {
  129. $.each( [ "Width", "Height" ], function( i, name ) {
  130. var side = name === "Width" ? [ "Left", "Right" ] : [ "Top", "Bottom" ],
  131. type = name.toLowerCase(),
  132. orig = {
  133. innerWidth: $.fn.innerWidth,
  134. innerHeight: $.fn.innerHeight,
  135. outerWidth: $.fn.outerWidth,
  136. outerHeight: $.fn.outerHeight
  137. };
  138. function reduce( elem, size, border, margin ) {
  139. $.each( side, function() {
  140. size -= parseFloat( $.css( elem, "padding" + this ) ) || 0;
  141. if ( border ) {
  142. size -= parseFloat( $.css( elem, "border" + this + "Width" ) ) || 0;
  143. }
  144. if ( margin ) {
  145. size -= parseFloat( $.css( elem, "margin" + this ) ) || 0;
  146. }
  147. });
  148. return size;
  149. }
  150. $.fn[ "inner" + name ] = function( size ) {
  151. if ( size === undefined ) {
  152. return orig[ "inner" + name ].call( this );
  153. }
  154. return this.each(function() {
  155. $( this ).css( type, reduce( this, size ) + "px" );
  156. });
  157. };
  158. $.fn[ "outer" + name] = function( size, margin ) {
  159. if ( typeof size !== "number" ) {
  160. return orig[ "outer" + name ].call( this, size );
  161. }
  162. return this.each(function() {
  163. $( this).css( type, reduce( this, size, true, margin ) + "px" );
  164. });
  165. };
  166. });
  167. }
  168. // support: jQuery <1.8
  169. if ( !$.fn.addBack ) {
  170. $.fn.addBack = function( selector ) {
  171. return this.add( selector == null ?
  172. this.prevObject : this.prevObject.filter( selector )
  173. );
  174. };
  175. }
  176. // support: jQuery 1.6.1, 1.6.2 (http://bugs.jquery.com/ticket/9413)
  177. if ( $( "<a>" ).data( "a-b", "a" ).removeData( "a-b" ).data( "a-b" ) ) {
  178. $.fn.removeData = (function( removeData ) {
  179. return function( key ) {
  180. if ( arguments.length ) {
  181. return removeData.call( this, $.camelCase( key ) );
  182. } else {
  183. return removeData.call( this );
  184. }
  185. };
  186. })( $.fn.removeData );
  187. }
  188. // deprecated
  189. $.ui.ie = !!/msie [\w.]+/.exec( navigator.userAgent.toLowerCase() );
  190. $.fn.extend({
  191. focus: (function( orig ) {
  192. return function( delay, fn ) {
  193. return typeof delay === "number" ?
  194. this.each(function() {
  195. var elem = this;
  196. setTimeout(function() {
  197. $( elem ).focus();
  198. if ( fn ) {
  199. fn.call( elem );
  200. }
  201. }, delay );
  202. }) :
  203. orig.apply( this, arguments );
  204. };
  205. })( $.fn.focus ),
  206. disableSelection: (function() {
  207. var eventType = "onselectstart" in document.createElement( "div" ) ?
  208. "selectstart" :
  209. "mousedown";
  210. return function() {
  211. return this.bind( eventType + ".ui-disableSelection", function( event ) {
  212. event.preventDefault();
  213. });
  214. };
  215. })(),
  216. enableSelection: function() {
  217. return this.unbind( ".ui-disableSelection" );
  218. },
  219. zIndex: function( zIndex ) {
  220. if ( zIndex !== undefined ) {
  221. return this.css( "zIndex", zIndex );
  222. }
  223. if ( this.length ) {
  224. var elem = $( this[ 0 ] ), position, value;
  225. while ( elem.length && elem[ 0 ] !== document ) {
  226. // Ignore z-index if position is set to a value where z-index is ignored by the browser
  227. // This makes behavior of this function consistent across browsers
  228. // WebKit always returns auto if the element is positioned
  229. position = elem.css( "position" );
  230. if ( position === "absolute" || position === "relative" || position === "fixed" ) {
  231. // IE returns 0 when zIndex is not specified
  232. // other browsers return a string
  233. // we ignore the case of nested elements with an explicit value of 0
  234. // <div style="z-index: -10;"><div style="z-index: 0;"></div></div>
  235. value = parseInt( elem.css( "zIndex" ), 10 );
  236. if ( !isNaN( value ) && value !== 0 ) {
  237. return value;
  238. }
  239. }
  240. elem = elem.parent();
  241. }
  242. }
  243. return 0;
  244. }
  245. });
  246. // $.ui.plugin is deprecated. Use $.widget() extensions instead.
  247. $.ui.plugin = {
  248. add: function( module, option, set ) {
  249. var i,
  250. proto = $.ui[ module ].prototype;
  251. for ( i in set ) {
  252. proto.plugins[ i ] = proto.plugins[ i ] || [];
  253. proto.plugins[ i ].push( [ option, set[ i ] ] );
  254. }
  255. },
  256. call: function( instance, name, args, allowDisconnected ) {
  257. var i,
  258. set = instance.plugins[ name ];
  259. if ( !set ) {
  260. return;
  261. }
  262. if ( !allowDisconnected && ( !instance.element[ 0 ].parentNode || instance.element[ 0 ].parentNode.nodeType === 11 ) ) {
  263. return;
  264. }
  265. for ( i = 0; i < set.length; i++ ) {
  266. if ( instance.options[ set[ i ][ 0 ] ] ) {
  267. set[ i ][ 1 ].apply( instance.element, args );
  268. }
  269. }
  270. }
  271. };
  272. /*!
  273. * jQuery UI Widget 1.11.3
  274. * http://jqueryui.com
  275. *
  276. * Copyright jQuery Foundation and other contributors
  277. * Released under the MIT license.
  278. * http://jquery.org/license
  279. *
  280. * http://api.jqueryui.com/jQuery.widget/
  281. */
  282. var widget_uuid = 0,
  283. widget_slice = Array.prototype.slice;
  284. $.cleanData = (function( orig ) {
  285. return function( elems ) {
  286. var events, elem, i;
  287. for ( i = 0; (elem = elems[i]) != null; i++ ) {
  288. try {
  289. // Only trigger remove when necessary to save time
  290. events = $._data( elem, "events" );
  291. if ( events && events.remove ) {
  292. $( elem ).triggerHandler( "remove" );
  293. }
  294. // http://bugs.jquery.com/ticket/8235
  295. } catch ( e ) {}
  296. }
  297. orig( elems );
  298. };
  299. })( $.cleanData );
  300. $.widget = function( name, base, prototype ) {
  301. var fullName, existingConstructor, constructor, basePrototype,
  302. // proxiedPrototype allows the provided prototype to remain unmodified
  303. // so that it can be used as a mixin for multiple widgets (#8876)
  304. proxiedPrototype = {},
  305. namespace = name.split( "." )[ 0 ];
  306. name = name.split( "." )[ 1 ];
  307. fullName = namespace + "-" + name;
  308. if ( !prototype ) {
  309. prototype = base;
  310. base = $.Widget;
  311. }
  312. // create selector for plugin
  313. $.expr[ ":" ][ fullName.toLowerCase() ] = function( elem ) {
  314. return !!$.data( elem, fullName );
  315. };
  316. $[ namespace ] = $[ namespace ] || {};
  317. existingConstructor = $[ namespace ][ name ];
  318. constructor = $[ namespace ][ name ] = function( options, element ) {
  319. // allow instantiation without "new" keyword
  320. if ( !this._createWidget ) {
  321. return new constructor( options, element );
  322. }
  323. // allow instantiation without initializing for simple inheritance
  324. // must use "new" keyword (the code above always passes args)
  325. if ( arguments.length ) {
  326. this._createWidget( options, element );
  327. }
  328. };
  329. // extend with the existing constructor to carry over any static properties
  330. $.extend( constructor, existingConstructor, {
  331. version: prototype.version,
  332. // copy the object used to create the prototype in case we need to
  333. // redefine the widget later
  334. _proto: $.extend( {}, prototype ),
  335. // track widgets that inherit from this widget in case this widget is
  336. // redefined after a widget inherits from it
  337. _childConstructors: []
  338. });
  339. basePrototype = new base();
  340. // we need to make the options hash a property directly on the new instance
  341. // otherwise we'll modify the options hash on the prototype that we're
  342. // inheriting from
  343. basePrototype.options = $.widget.extend( {}, basePrototype.options );
  344. $.each( prototype, function( prop, value ) {
  345. if ( !$.isFunction( value ) ) {
  346. proxiedPrototype[ prop ] = value;
  347. return;
  348. }
  349. proxiedPrototype[ prop ] = (function() {
  350. var _super = function() {
  351. return base.prototype[ prop ].apply( this, arguments );
  352. },
  353. _superApply = function( args ) {
  354. return base.prototype[ prop ].apply( this, args );
  355. };
  356. return function() {
  357. var __super = this._super,
  358. __superApply = this._superApply,
  359. returnValue;
  360. this._super = _super;
  361. this._superApply = _superApply;
  362. returnValue = value.apply( this, arguments );
  363. this._super = __super;
  364. this._superApply = __superApply;
  365. return returnValue;
  366. };
  367. })();
  368. });
  369. constructor.prototype = $.widget.extend( basePrototype, {
  370. // TODO: remove support for widgetEventPrefix
  371. // always use the name + a colon as the prefix, e.g., draggable:start
  372. // don't prefix for widgets that aren't DOM-based
  373. widgetEventPrefix: existingConstructor ? (basePrototype.widgetEventPrefix || name) : name
  374. }, proxiedPrototype, {
  375. constructor: constructor,
  376. namespace: namespace,
  377. widgetName: name,
  378. widgetFullName: fullName
  379. });
  380. // If this widget is being redefined then we need to find all widgets that
  381. // are inheriting from it and redefine all of them so that they inherit from
  382. // the new version of this widget. We're essentially trying to replace one
  383. // level in the prototype chain.
  384. if ( existingConstructor ) {
  385. $.each( existingConstructor._childConstructors, function( i, child ) {
  386. var childPrototype = child.prototype;
  387. // redefine the child widget using the same prototype that was
  388. // originally used, but inherit from the new version of the base
  389. $.widget( childPrototype.namespace + "." + childPrototype.widgetName, constructor, child._proto );
  390. });
  391. // remove the list of existing child constructors from the old constructor
  392. // so the old child constructors can be garbage collected
  393. delete existingConstructor._childConstructors;
  394. } else {
  395. base._childConstructors.push( constructor );
  396. }
  397. $.widget.bridge( name, constructor );
  398. return constructor;
  399. };
  400. $.widget.extend = function( target ) {
  401. var input = widget_slice.call( arguments, 1 ),
  402. inputIndex = 0,
  403. inputLength = input.length,
  404. key,
  405. value;
  406. for ( ; inputIndex < inputLength; inputIndex++ ) {
  407. for ( key in input[ inputIndex ] ) {
  408. value = input[ inputIndex ][ key ];
  409. if ( input[ inputIndex ].hasOwnProperty( key ) && value !== undefined ) {
  410. // Clone objects
  411. if ( $.isPlainObject( value ) ) {
  412. target[ key ] = $.isPlainObject( target[ key ] ) ?
  413. $.widget.extend( {}, target[ key ], value ) :
  414. // Don't extend strings, arrays, etc. with objects
  415. $.widget.extend( {}, value );
  416. // Copy everything else by reference
  417. } else {
  418. target[ key ] = value;
  419. }
  420. }
  421. }
  422. }
  423. return target;
  424. };
  425. $.widget.bridge = function( name, object ) {
  426. var fullName = object.prototype.widgetFullName || name;
  427. $.fn[ name ] = function( options ) {
  428. var isMethodCall = typeof options === "string",
  429. args = widget_slice.call( arguments, 1 ),
  430. returnValue = this;
  431. if ( isMethodCall ) {
  432. this.each(function() {
  433. var methodValue,
  434. instance = $.data( this, fullName );
  435. if ( options === "instance" ) {
  436. returnValue = instance;
  437. return false;
  438. }
  439. if ( !instance ) {
  440. return $.error( "cannot call methods on " + name + " prior to initialization; " +
  441. "attempted to call method '" + options + "'" );
  442. }
  443. if ( !$.isFunction( instance[options] ) || options.charAt( 0 ) === "_" ) {
  444. return $.error( "no such method '" + options + "' for " + name + " widget instance" );
  445. }
  446. methodValue = instance[ options ].apply( instance, args );
  447. if ( methodValue !== instance && methodValue !== undefined ) {
  448. returnValue = methodValue && methodValue.jquery ?
  449. returnValue.pushStack( methodValue.get() ) :
  450. methodValue;
  451. return false;
  452. }
  453. });
  454. } else {
  455. // Allow multiple hashes to be passed on init
  456. if ( args.length ) {
  457. options = $.widget.extend.apply( null, [ options ].concat(args) );
  458. }
  459. this.each(function() {
  460. var instance = $.data( this, fullName );
  461. if ( instance ) {
  462. instance.option( options || {} );
  463. if ( instance._init ) {
  464. instance._init();
  465. }
  466. } else {
  467. $.data( this, fullName, new object( options, this ) );
  468. }
  469. });
  470. }
  471. return returnValue;
  472. };
  473. };
  474. $.Widget = function( /* options, element */ ) {};
  475. $.Widget._childConstructors = [];
  476. $.Widget.prototype = {
  477. widgetName: "widget",
  478. widgetEventPrefix: "",
  479. defaultElement: "<div>",
  480. options: {
  481. disabled: false,
  482. // callbacks
  483. create: null
  484. },
  485. _createWidget: function( options, element ) {
  486. element = $( element || this.defaultElement || this )[ 0 ];
  487. this.element = $( element );
  488. this.uuid = widget_uuid++;
  489. this.eventNamespace = "." + this.widgetName + this.uuid;
  490. this.bindings = $();
  491. this.hoverable = $();
  492. this.focusable = $();
  493. if ( element !== this ) {
  494. $.data( element, this.widgetFullName, this );
  495. this._on( true, this.element, {
  496. remove: function( event ) {
  497. if ( event.target === element ) {
  498. this.destroy();
  499. }
  500. }
  501. });
  502. this.document = $( element.style ?
  503. // element within the document
  504. element.ownerDocument :
  505. // element is window or document
  506. element.document || element );
  507. this.window = $( this.document[0].defaultView || this.document[0].parentWindow );
  508. }
  509. this.options = $.widget.extend( {},
  510. this.options,
  511. this._getCreateOptions(),
  512. options );
  513. this._create();
  514. this._trigger( "create", null, this._getCreateEventData() );
  515. this._init();
  516. },
  517. _getCreateOptions: $.noop,
  518. _getCreateEventData: $.noop,
  519. _create: $.noop,
  520. _init: $.noop,
  521. destroy: function() {
  522. this._destroy();
  523. // we can probably remove the unbind calls in 2.0
  524. // all event bindings should go through this._on()
  525. this.element
  526. .unbind( this.eventNamespace )
  527. .removeData( this.widgetFullName )
  528. // support: jquery <1.6.3
  529. // http://bugs.jquery.com/ticket/9413
  530. .removeData( $.camelCase( this.widgetFullName ) );
  531. this.widget()
  532. .unbind( this.eventNamespace )
  533. .removeAttr( "aria-disabled" )
  534. .removeClass(
  535. this.widgetFullName + "-disabled " +
  536. "ui-state-disabled" );
  537. // clean up events and states
  538. this.bindings.unbind( this.eventNamespace );
  539. this.hoverable.removeClass( "ui-state-hover" );
  540. this.focusable.removeClass( "ui-state-focus" );
  541. },
  542. _destroy: $.noop,
  543. widget: function() {
  544. return this.element;
  545. },
  546. option: function( key, value ) {
  547. var options = key,
  548. parts,
  549. curOption,
  550. i;
  551. if ( arguments.length === 0 ) {
  552. // don't return a reference to the internal hash
  553. return $.widget.extend( {}, this.options );
  554. }
  555. if ( typeof key === "string" ) {
  556. // handle nested keys, e.g., "foo.bar" => { foo: { bar: ___ } }
  557. options = {};
  558. parts = key.split( "." );
  559. key = parts.shift();
  560. if ( parts.length ) {
  561. curOption = options[ key ] = $.widget.extend( {}, this.options[ key ] );
  562. for ( i = 0; i < parts.length - 1; i++ ) {
  563. curOption[ parts[ i ] ] = curOption[ parts[ i ] ] || {};
  564. curOption = curOption[ parts[ i ] ];
  565. }
  566. key = parts.pop();
  567. if ( arguments.length === 1 ) {
  568. return curOption[ key ] === undefined ? null : curOption[ key ];
  569. }
  570. curOption[ key ] = value;
  571. } else {
  572. if ( arguments.length === 1 ) {
  573. return this.options[ key ] === undefined ? null : this.options[ key ];
  574. }
  575. options[ key ] = value;
  576. }
  577. }
  578. this._setOptions( options );
  579. return this;
  580. },
  581. _setOptions: function( options ) {
  582. var key;
  583. for ( key in options ) {
  584. this._setOption( key, options[ key ] );
  585. }
  586. return this;
  587. },
  588. _setOption: function( key, value ) {
  589. this.options[ key ] = value;
  590. if ( key === "disabled" ) {
  591. this.widget()
  592. .toggleClass( this.widgetFullName + "-disabled", !!value );
  593. // If the widget is becoming disabled, then nothing is interactive
  594. if ( value ) {
  595. this.hoverable.removeClass( "ui-state-hover" );
  596. this.focusable.removeClass( "ui-state-focus" );
  597. }
  598. }
  599. return this;
  600. },
  601. enable: function() {
  602. return this._setOptions({ disabled: false });
  603. },
  604. disable: function() {
  605. return this._setOptions({ disabled: true });
  606. },
  607. _on: function( suppressDisabledCheck, element, handlers ) {
  608. var delegateElement,
  609. instance = this;
  610. // no suppressDisabledCheck flag, shuffle arguments
  611. if ( typeof suppressDisabledCheck !== "boolean" ) {
  612. handlers = element;
  613. element = suppressDisabledCheck;
  614. suppressDisabledCheck = false;
  615. }
  616. // no element argument, shuffle and use this.element
  617. if ( !handlers ) {
  618. handlers = element;
  619. element = this.element;
  620. delegateElement = this.widget();
  621. } else {
  622. element = delegateElement = $( element );
  623. this.bindings = this.bindings.add( element );
  624. }
  625. $.each( handlers, function( event, handler ) {
  626. function handlerProxy() {
  627. // allow widgets to customize the disabled handling
  628. // - disabled as an array instead of boolean
  629. // - disabled class as method for disabling individual parts
  630. if ( !suppressDisabledCheck &&
  631. ( instance.options.disabled === true ||
  632. $( this ).hasClass( "ui-state-disabled" ) ) ) {
  633. return;
  634. }
  635. return ( typeof handler === "string" ? instance[ handler ] : handler )
  636. .apply( instance, arguments );
  637. }
  638. // copy the guid so direct unbinding works
  639. if ( typeof handler !== "string" ) {
  640. handlerProxy.guid = handler.guid =
  641. handler.guid || handlerProxy.guid || $.guid++;
  642. }
  643. var match = event.match( /^([\w:-]*)\s*(.*)$/ ),
  644. eventName = match[1] + instance.eventNamespace,
  645. selector = match[2];
  646. if ( selector ) {
  647. delegateElement.delegate( selector, eventName, handlerProxy );
  648. } else {
  649. element.bind( eventName, handlerProxy );
  650. }
  651. });
  652. },
  653. _off: function( element, eventName ) {
  654. eventName = (eventName || "").split( " " ).join( this.eventNamespace + " " ) +
  655. this.eventNamespace;
  656. element.unbind( eventName ).undelegate( eventName );
  657. // Clear the stack to avoid memory leaks (#10056)
  658. this.bindings = $( this.bindings.not( element ).get() );
  659. this.focusable = $( this.focusable.not( element ).get() );
  660. this.hoverable = $( this.hoverable.not( element ).get() );
  661. },
  662. _delay: function( handler, delay ) {
  663. function handlerProxy() {
  664. return ( typeof handler === "string" ? instance[ handler ] : handler )
  665. .apply( instance, arguments );
  666. }
  667. var instance = this;
  668. return setTimeout( handlerProxy, delay || 0 );
  669. },
  670. _hoverable: function( element ) {
  671. this.hoverable = this.hoverable.add( element );
  672. this._on( element, {
  673. mouseenter: function( event ) {
  674. $( event.currentTarget ).addClass( "ui-state-hover" );
  675. },
  676. mouseleave: function( event ) {
  677. $( event.currentTarget ).removeClass( "ui-state-hover" );
  678. }
  679. });
  680. },
  681. _focusable: function( element ) {
  682. this.focusable = this.focusable.add( element );
  683. this._on( element, {
  684. focusin: function( event ) {
  685. $( event.currentTarget ).addClass( "ui-state-focus" );
  686. },
  687. focusout: function( event ) {
  688. $( event.currentTarget ).removeClass( "ui-state-focus" );
  689. }
  690. });
  691. },
  692. _trigger: function( type, event, data ) {
  693. var prop, orig,
  694. callback = this.options[ type ];
  695. data = data || {};
  696. event = $.Event( event );
  697. event.type = ( type === this.widgetEventPrefix ?
  698. type :
  699. this.widgetEventPrefix + type ).toLowerCase();
  700. // the original event may come from any element
  701. // so we need to reset the target on the new event
  702. event.target = this.element[ 0 ];
  703. // copy original event properties over to the new event
  704. orig = event.originalEvent;
  705. if ( orig ) {
  706. for ( prop in orig ) {
  707. if ( !( prop in event ) ) {
  708. event[ prop ] = orig[ prop ];
  709. }
  710. }
  711. }
  712. this.element.trigger( event, data );
  713. return !( $.isFunction( callback ) &&
  714. callback.apply( this.element[0], [ event ].concat( data ) ) === false ||
  715. event.isDefaultPrevented() );
  716. }
  717. };
  718. $.each( { show: "fadeIn", hide: "fadeOut" }, function( method, defaultEffect ) {
  719. $.Widget.prototype[ "_" + method ] = function( element, options, callback ) {
  720. if ( typeof options === "string" ) {
  721. options = { effect: options };
  722. }
  723. var hasOptions,
  724. effectName = !options ?
  725. method :
  726. options === true || typeof options === "number" ?
  727. defaultEffect :
  728. options.effect || defaultEffect;
  729. options = options || {};
  730. if ( typeof options === "number" ) {
  731. options = { duration: options };
  732. }
  733. hasOptions = !$.isEmptyObject( options );
  734. options.complete = callback;
  735. if ( options.delay ) {
  736. element.delay( options.delay );
  737. }
  738. if ( hasOptions && $.effects && $.effects.effect[ effectName ] ) {
  739. element[ method ]( options );
  740. } else if ( effectName !== method && element[ effectName ] ) {
  741. element[ effectName ]( options.duration, options.easing, callback );
  742. } else {
  743. element.queue(function( next ) {
  744. $( this )[ method ]();
  745. if ( callback ) {
  746. callback.call( element[ 0 ] );
  747. }
  748. next();
  749. });
  750. }
  751. };
  752. });
  753. var widget = $.widget;
  754. /*!
  755. * jQuery UI Mouse 1.11.3
  756. * http://jqueryui.com
  757. *
  758. * Copyright jQuery Foundation and other contributors
  759. * Released under the MIT license.
  760. * http://jquery.org/license
  761. *
  762. * http://api.jqueryui.com/mouse/
  763. */
  764. var mouseHandled = false;
  765. $( document ).mouseup( function() {
  766. mouseHandled = false;
  767. });
  768. var mouse = $.widget("ui.mouse", {
  769. version: "1.11.3",
  770. options: {
  771. cancel: "input,textarea,button,select,option",
  772. distance: 1,
  773. delay: 0
  774. },
  775. _mouseInit: function() {
  776. var that = this;
  777. this.element
  778. .bind("mousedown." + this.widgetName, function(event) {
  779. return that._mouseDown(event);
  780. })
  781. .bind("click." + this.widgetName, function(event) {
  782. if (true === $.data(event.target, that.widgetName + ".preventClickEvent")) {
  783. $.removeData(event.target, that.widgetName + ".preventClickEvent");
  784. event.stopImmediatePropagation();
  785. return false;
  786. }
  787. });
  788. this.started = false;
  789. },
  790. // TODO: make sure destroying one instance of mouse doesn't mess with
  791. // other instances of mouse
  792. _mouseDestroy: function() {
  793. this.element.unbind("." + this.widgetName);
  794. if ( this._mouseMoveDelegate ) {
  795. this.document
  796. .unbind("mousemove." + this.widgetName, this._mouseMoveDelegate)
  797. .unbind("mouseup." + this.widgetName, this._mouseUpDelegate);
  798. }
  799. },
  800. _mouseDown: function(event) {
  801. // don't let more than one widget handle mouseStart
  802. if ( mouseHandled ) {
  803. return;
  804. }
  805. this._mouseMoved = false;
  806. // we may have missed mouseup (out of window)
  807. (this._mouseStarted && this._mouseUp(event));
  808. this._mouseDownEvent = event;
  809. var that = this,
  810. btnIsLeft = (event.which === 1),
  811. // event.target.nodeName works around a bug in IE 8 with
  812. // disabled inputs (#7620)
  813. elIsCancel = (typeof this.options.cancel === "string" && event.target.nodeName ? $(event.target).closest(this.options.cancel).length : false);
  814. if (!btnIsLeft || elIsCancel || !this._mouseCapture(event)) {
  815. return true;
  816. }
  817. this.mouseDelayMet = !this.options.delay;
  818. if (!this.mouseDelayMet) {
  819. this._mouseDelayTimer = setTimeout(function() {
  820. that.mouseDelayMet = true;
  821. }, this.options.delay);
  822. }
  823. if (this._mouseDistanceMet(event) && this._mouseDelayMet(event)) {
  824. this._mouseStarted = (this._mouseStart(event) !== false);
  825. if (!this._mouseStarted) {
  826. event.preventDefault();
  827. return true;
  828. }
  829. }
  830. // Click event may never have fired (Gecko & Opera)
  831. if (true === $.data(event.target, this.widgetName + ".preventClickEvent")) {
  832. $.removeData(event.target, this.widgetName + ".preventClickEvent");
  833. }
  834. // these delegates are required to keep context
  835. this._mouseMoveDelegate = function(event) {
  836. return that._mouseMove(event);
  837. };
  838. this._mouseUpDelegate = function(event) {
  839. return that._mouseUp(event);
  840. };
  841. this.document
  842. .bind( "mousemove." + this.widgetName, this._mouseMoveDelegate )
  843. .bind( "mouseup." + this.widgetName, this._mouseUpDelegate );
  844. event.preventDefault();
  845. mouseHandled = true;
  846. return true;
  847. },
  848. _mouseMove: function(event) {
  849. // Only check for mouseups outside the document if you've moved inside the document
  850. // at least once. This prevents the firing of mouseup in the case of IE<9, which will
  851. // fire a mousemove event if content is placed under the cursor. See #7778
  852. // Support: IE <9
  853. if ( this._mouseMoved ) {
  854. // IE mouseup check - mouseup happened when mouse was out of window
  855. if ($.ui.ie && ( !document.documentMode || document.documentMode < 9 ) && !event.button) {
  856. return this._mouseUp(event);
  857. // Iframe mouseup check - mouseup occurred in another document
  858. } else if ( !event.which ) {
  859. return this._mouseUp( event );
  860. }
  861. }
  862. if ( event.which || event.button ) {
  863. this._mouseMoved = true;
  864. }
  865. if (this._mouseStarted) {
  866. this._mouseDrag(event);
  867. return event.preventDefault();
  868. }
  869. if (this._mouseDistanceMet(event) && this._mouseDelayMet(event)) {
  870. this._mouseStarted =
  871. (this._mouseStart(this._mouseDownEvent, event) !== false);
  872. (this._mouseStarted ? this._mouseDrag(event) : this._mouseUp(event));
  873. }
  874. return !this._mouseStarted;
  875. },
  876. _mouseUp: function(event) {
  877. this.document
  878. .unbind( "mousemove." + this.widgetName, this._mouseMoveDelegate )
  879. .unbind( "mouseup." + this.widgetName, this._mouseUpDelegate );
  880. if (this._mouseStarted) {
  881. this._mouseStarted = false;
  882. if (event.target === this._mouseDownEvent.target) {
  883. $.data(event.target, this.widgetName + ".preventClickEvent", true);
  884. }
  885. this._mouseStop(event);
  886. }
  887. mouseHandled = false;
  888. return false;
  889. },
  890. _mouseDistanceMet: function(event) {
  891. return (Math.max(
  892. Math.abs(this._mouseDownEvent.pageX - event.pageX),
  893. Math.abs(this._mouseDownEvent.pageY - event.pageY)
  894. ) >= this.options.distance
  895. );
  896. },
  897. _mouseDelayMet: function(/* event */) {
  898. return this.mouseDelayMet;
  899. },
  900. // These are placeholder methods, to be overriden by extending plugin
  901. _mouseStart: function(/* event */) {},
  902. _mouseDrag: function(/* event */) {},
  903. _mouseStop: function(/* event */) {},
  904. _mouseCapture: function(/* event */) { return true; }
  905. });
  906. /*!
  907. * jQuery UI Position 1.11.3
  908. * http://jqueryui.com
  909. *
  910. * Copyright jQuery Foundation and other contributors
  911. * Released under the MIT license.
  912. * http://jquery.org/license
  913. *
  914. * http://api.jqueryui.com/position/
  915. */
  916. (function() {
  917. $.ui = $.ui || {};
  918. var cachedScrollbarWidth, supportsOffsetFractions,
  919. max = Math.max,
  920. abs = Math.abs,
  921. round = Math.round,
  922. rhorizontal = /left|center|right/,
  923. rvertical = /top|center|bottom/,
  924. roffset = /[\+\-]\d+(\.[\d]+)?%?/,
  925. rposition = /^\w+/,
  926. rpercent = /%$/,
  927. _position = $.fn.position;
  928. function getOffsets( offsets, width, height ) {
  929. return [
  930. parseFloat( offsets[ 0 ] ) * ( rpercent.test( offsets[ 0 ] ) ? width / 100 : 1 ),
  931. parseFloat( offsets[ 1 ] ) * ( rpercent.test( offsets[ 1 ] ) ? height / 100 : 1 )
  932. ];
  933. }
  934. function parseCss( element, property ) {
  935. return parseInt( $.css( element, property ), 10 ) || 0;
  936. }
  937. function getDimensions( elem ) {
  938. var raw = elem[0];
  939. if ( raw.nodeType === 9 ) {
  940. return {
  941. width: elem.width(),
  942. height: elem.height(),
  943. offset: { top: 0, left: 0 }
  944. };
  945. }
  946. if ( $.isWindow( raw ) ) {
  947. return {
  948. width: elem.width(),
  949. height: elem.height(),
  950. offset: { top: elem.scrollTop(), left: elem.scrollLeft() }
  951. };
  952. }
  953. if ( raw.preventDefault ) {
  954. return {
  955. width: 0,
  956. height: 0,
  957. offset: { top: raw.pageY, left: raw.pageX }
  958. };
  959. }
  960. return {
  961. width: elem.outerWidth(),
  962. height: elem.outerHeight(),
  963. offset: elem.offset()
  964. };
  965. }
  966. $.position = {
  967. scrollbarWidth: function() {
  968. if ( cachedScrollbarWidth !== undefined ) {
  969. return cachedScrollbarWidth;
  970. }
  971. var w1, w2,
  972. div = $( "<div style='display:block;position:absolute;width:50px;height:50px;overflow:hidden;'><div style='height:100px;width:auto;'></div></div>" ),
  973. innerDiv = div.children()[0];
  974. $( "body" ).append( div );
  975. w1 = innerDiv.offsetWidth;
  976. div.css( "overflow", "scroll" );
  977. w2 = innerDiv.offsetWidth;
  978. if ( w1 === w2 ) {
  979. w2 = div[0].clientWidth;
  980. }
  981. div.remove();
  982. return (cachedScrollbarWidth = w1 - w2);
  983. },
  984. getScrollInfo: function( within ) {
  985. var overflowX = within.isWindow || within.isDocument ? "" :
  986. within.element.css( "overflow-x" ),
  987. overflowY = within.isWindow || within.isDocument ? "" :
  988. within.element.css( "overflow-y" ),
  989. hasOverflowX = overflowX === "scroll" ||
  990. ( overflowX === "auto" && within.width < within.element[0].scrollWidth ),
  991. hasOverflowY = overflowY === "scroll" ||
  992. ( overflowY === "auto" && within.height < within.element[0].scrollHeight );
  993. return {
  994. width: hasOverflowY ? $.position.scrollbarWidth() : 0,
  995. height: hasOverflowX ? $.position.scrollbarWidth() : 0
  996. };
  997. },
  998. getWithinInfo: function( element ) {
  999. var withinElement = $( element || window ),
  1000. isWindow = $.isWindow( withinElement[0] ),
  1001. isDocument = !!withinElement[ 0 ] && withinElement[ 0 ].nodeType === 9;
  1002. return {
  1003. element: withinElement,
  1004. isWindow: isWindow,
  1005. isDocument: isDocument,
  1006. offset: withinElement.offset() || { left: 0, top: 0 },
  1007. scrollLeft: withinElement.scrollLeft(),
  1008. scrollTop: withinElement.scrollTop(),
  1009. // support: jQuery 1.6.x
  1010. // jQuery 1.6 doesn't support .outerWidth/Height() on documents or windows
  1011. width: isWindow || isDocument ? withinElement.width() : withinElement.outerWidth(),
  1012. height: isWindow || isDocument ? withinElement.height() : withinElement.outerHeight()
  1013. };
  1014. }
  1015. };
  1016. $.fn.position = function( options ) {
  1017. if ( !options || !options.of ) {
  1018. return _position.apply( this, arguments );
  1019. }
  1020. // make a copy, we don't want to modify arguments
  1021. options = $.extend( {}, options );
  1022. var atOffset, targetWidth, targetHeight, targetOffset, basePosition, dimensions,
  1023. target = $( options.of ),
  1024. within = $.position.getWithinInfo( options.within ),
  1025. scrollInfo = $.position.getScrollInfo( within ),
  1026. collision = ( options.collision || "flip" ).split( " " ),
  1027. offsets = {};
  1028. dimensions = getDimensions( target );
  1029. if ( target[0].preventDefault ) {
  1030. // force left top to allow flipping
  1031. options.at = "left top";
  1032. }
  1033. targetWidth = dimensions.width;
  1034. targetHeight = dimensions.height;
  1035. targetOffset = dimensions.offset;
  1036. // clone to reuse original targetOffset later
  1037. basePosition = $.extend( {}, targetOffset );
  1038. // force my and at to have valid horizontal and vertical positions
  1039. // if a value is missing or invalid, it will be converted to center
  1040. $.each( [ "my", "at" ], function() {
  1041. var pos = ( options[ this ] || "" ).split( " " ),
  1042. horizontalOffset,
  1043. verticalOffset;
  1044. if ( pos.length === 1) {
  1045. pos = rhorizontal.test( pos[ 0 ] ) ?
  1046. pos.concat( [ "center" ] ) :
  1047. rvertical.test( pos[ 0 ] ) ?
  1048. [ "center" ].concat( pos ) :
  1049. [ "center", "center" ];
  1050. }
  1051. pos[ 0 ] = rhorizontal.test( pos[ 0 ] ) ? pos[ 0 ] : "center";
  1052. pos[ 1 ] = rvertical.test( pos[ 1 ] ) ? pos[ 1 ] : "center";
  1053. // calculate offsets
  1054. horizontalOffset = roffset.exec( pos[ 0 ] );
  1055. verticalOffset = roffset.exec( pos[ 1 ] );
  1056. offsets[ this ] = [
  1057. horizontalOffset ? horizontalOffset[ 0 ] : 0,
  1058. verticalOffset ? verticalOffset[ 0 ] : 0
  1059. ];
  1060. // reduce to just the positions without the offsets
  1061. options[ this ] = [
  1062. rposition.exec( pos[ 0 ] )[ 0 ],
  1063. rposition.exec( pos[ 1 ] )[ 0 ]
  1064. ];
  1065. });
  1066. // normalize collision option
  1067. if ( collision.length === 1 ) {
  1068. collision[ 1 ] = collision[ 0 ];
  1069. }
  1070. if ( options.at[ 0 ] === "right" ) {
  1071. basePosition.left += targetWidth;
  1072. } else if ( options.at[ 0 ] === "center" ) {
  1073. basePosition.left += targetWidth / 2;
  1074. }
  1075. if ( options.at[ 1 ] === "bottom" ) {
  1076. basePosition.top += targetHeight;
  1077. } else if ( options.at[ 1 ] === "center" ) {
  1078. basePosition.top += targetHeight / 2;
  1079. }
  1080. atOffset = getOffsets( offsets.at, targetWidth, targetHeight );
  1081. basePosition.left += atOffset[ 0 ];
  1082. basePosition.top += atOffset[ 1 ];
  1083. return this.each(function() {
  1084. var collisionPosition, using,
  1085. elem = $( this ),
  1086. elemWidth = elem.outerWidth(),
  1087. elemHeight = elem.outerHeight(),
  1088. marginLeft = parseCss( this, "marginLeft" ),
  1089. marginTop = parseCss( this, "marginTop" ),
  1090. collisionWidth = elemWidth + marginLeft + parseCss( this, "marginRight" ) + scrollInfo.width,
  1091. collisionHeight = elemHeight + marginTop + parseCss( this, "marginBottom" ) + scrollInfo.height,
  1092. position = $.extend( {}, basePosition ),
  1093. myOffset = getOffsets( offsets.my, elem.outerWidth(), elem.outerHeight() );
  1094. if ( options.my[ 0 ] === "right" ) {
  1095. position.left -= elemWidth;
  1096. } else if ( options.my[ 0 ] === "center" ) {
  1097. position.left -= elemWidth / 2;
  1098. }
  1099. if ( options.my[ 1 ] === "bottom" ) {
  1100. position.top -= elemHeight;
  1101. } else if ( options.my[ 1 ] === "center" ) {
  1102. position.top -= elemHeight / 2;
  1103. }
  1104. position.left += myOffset[ 0 ];
  1105. position.top += myOffset[ 1 ];
  1106. // if the browser doesn't support fractions, then round for consistent results
  1107. if ( !supportsOffsetFractions ) {
  1108. position.left = round( position.left );
  1109. position.top = round( position.top );
  1110. }
  1111. collisionPosition = {
  1112. marginLeft: marginLeft,
  1113. marginTop: marginTop
  1114. };
  1115. $.each( [ "left", "top" ], function( i, dir ) {
  1116. if ( $.ui.position[ collision[ i ] ] ) {
  1117. $.ui.position[ collision[ i ] ][ dir ]( position, {
  1118. targetWidth: targetWidth,
  1119. targetHeight: targetHeight,
  1120. elemWidth: elemWidth,
  1121. elemHeight: elemHeight,
  1122. collisionPosition: collisionPosition,
  1123. collisionWidth: collisionWidth,
  1124. collisionHeight: collisionHeight,
  1125. offset: [ atOffset[ 0 ] + myOffset[ 0 ], atOffset [ 1 ] + myOffset[ 1 ] ],
  1126. my: options.my,
  1127. at: options.at,
  1128. within: within,
  1129. elem: elem
  1130. });
  1131. }
  1132. });
  1133. if ( options.using ) {
  1134. // adds feedback as second argument to using callback, if present
  1135. using = function( props ) {
  1136. var left = targetOffset.left - position.left,
  1137. right = left + targetWidth - elemWidth,
  1138. top = targetOffset.top - position.top,
  1139. bottom = top + targetHeight - elemHeight,
  1140. feedback = {
  1141. target: {
  1142. element: target,
  1143. left: targetOffset.left,
  1144. top: targetOffset.top,
  1145. width: targetWidth,
  1146. height: targetHeight
  1147. },
  1148. element: {
  1149. element: elem,
  1150. left: position.left,
  1151. top: position.top,
  1152. width: elemWidth,
  1153. height: elemHeight
  1154. },
  1155. horizontal: right < 0 ? "left" : left > 0 ? "right" : "center",
  1156. vertical: bottom < 0 ? "top" : top > 0 ? "bottom" : "middle"
  1157. };
  1158. if ( targetWidth < elemWidth && abs( left + right ) < targetWidth ) {
  1159. feedback.horizontal = "center";
  1160. }
  1161. if ( targetHeight < elemHeight && abs( top + bottom ) < targetHeight ) {
  1162. feedback.vertical = "middle";
  1163. }
  1164. if ( max( abs( left ), abs( right ) ) > max( abs( top ), abs( bottom ) ) ) {
  1165. feedback.important = "horizontal";
  1166. } else {
  1167. feedback.important = "vertical";
  1168. }
  1169. options.using.call( this, props, feedback );
  1170. };
  1171. }
  1172. elem.offset( $.extend( position, { using: using } ) );
  1173. });
  1174. };
  1175. $.ui.position = {
  1176. fit: {
  1177. left: function( position, data ) {
  1178. var within = data.within,
  1179. withinOffset = within.isWindow ? within.scrollLeft : within.offset.left,
  1180. outerWidth = within.width,
  1181. collisionPosLeft = position.left - data.collisionPosition.marginLeft,
  1182. overLeft = withinOffset - collisionPosLeft,
  1183. overRight = collisionPosLeft + data.collisionWidth - outerWidth - withinOffset,
  1184. newOverRight;
  1185. // element is wider than within
  1186. if ( data.collisionWidth > outerWidth ) {
  1187. // element is initially over the left side of within
  1188. if ( overLeft > 0 && overRight <= 0 ) {
  1189. newOverRight = position.left + overLeft + data.collisionWidth - outerWidth - withinOffset;
  1190. position.left += overLeft - newOverRight;
  1191. // element is initially over right side of within
  1192. } else if ( overRight > 0 && overLeft <= 0 ) {
  1193. position.left = withinOffset;
  1194. // element is initially over both left and right sides of within
  1195. } else {
  1196. if ( overLeft > overRight ) {
  1197. position.left = withinOffset + outerWidth - data.collisionWidth;
  1198. } else {
  1199. position.left = withinOffset;
  1200. }
  1201. }
  1202. // too far left -> align with left edge
  1203. } else if ( overLeft > 0 ) {
  1204. position.left += overLeft;
  1205. // too far right -> align with right edge
  1206. } else if ( overRight > 0 ) {
  1207. position.left -= overRight;
  1208. // adjust based on position and margin
  1209. } else {
  1210. position.left = max( position.left - collisionPosLeft, position.left );
  1211. }
  1212. },
  1213. top: function( position, data ) {
  1214. var within = data.within,
  1215. withinOffset = within.isWindow ? within.scrollTop : within.offset.top,
  1216. outerHeight = data.within.height,
  1217. collisionPosTop = position.top - data.collisionPosition.marginTop,
  1218. overTop = withinOffset - collisionPosTop,
  1219. overBottom = collisionPosTop + data.collisionHeight - outerHeight - withinOffset,
  1220. newOverBottom;
  1221. // element is taller than within
  1222. if ( data.collisionHeight > outerHeight ) {
  1223. // element is initially over the top of within
  1224. if ( overTop > 0 && overBottom <= 0 ) {
  1225. newOverBottom = position.top + overTop + data.collisionHeight - outerHeight - withinOffset;
  1226. position.top += overTop - newOverBottom;
  1227. // element is initially over bottom of within
  1228. } else if ( overBottom > 0 && overTop <= 0 ) {
  1229. position.top = withinOffset;
  1230. // element is initially over both top and bottom of within
  1231. } else {
  1232. if ( overTop > overBottom ) {
  1233. position.top = withinOffset + outerHeight - data.collisionHeight;
  1234. } else {
  1235. position.top = withinOffset;
  1236. }
  1237. }
  1238. // too far up -> align with top
  1239. } else if ( overTop > 0 ) {
  1240. position.top += overTop;
  1241. // too far down -> align with bottom edge
  1242. } else if ( overBottom > 0 ) {
  1243. position.top -= overBottom;
  1244. // adjust based on position and margin
  1245. } else {
  1246. position.top = max( position.top - collisionPosTop, position.top );
  1247. }
  1248. }
  1249. },
  1250. flip: {
  1251. left: function( position, data ) {
  1252. var within = data.within,
  1253. withinOffset = within.offset.left + within.scrollLeft,
  1254. outerWidth = within.width,
  1255. offsetLeft = within.isWindow ? within.scrollLeft : within.offset.left,
  1256. collisionPosLeft = position.left - data.collisionPosition.marginLeft,
  1257. overLeft = collisionPosLeft - offsetLeft,
  1258. overRight = collisionPosLeft + data.collisionWidth - outerWidth - offsetLeft,
  1259. myOffset = data.my[ 0 ] === "left" ?
  1260. -data.elemWidth :
  1261. data.my[ 0 ] === "right" ?
  1262. data.elemWidth :
  1263. 0,
  1264. atOffset = data.at[ 0 ] === "left" ?
  1265. data.targetWidth :
  1266. data.at[ 0 ] === "right" ?
  1267. -data.targetWidth :
  1268. 0,
  1269. offset = -2 * data.offset[ 0 ],
  1270. newOverRight,
  1271. newOverLeft;
  1272. if ( overLeft < 0 ) {
  1273. newOverRight = position.left + myOffset + atOffset + offset + data.collisionWidth - outerWidth - withinOffset;
  1274. if ( newOverRight < 0 || newOverRight < abs( overLeft ) ) {
  1275. position.left += myOffset + atOffset + offset;
  1276. }
  1277. } else if ( overRight > 0 ) {
  1278. newOverLeft = position.left - data.collisionPosition.marginLeft + myOffset + atOffset + offset - offsetLeft;
  1279. if ( newOverLeft > 0 || abs( newOverLeft ) < overRight ) {
  1280. position.left += myOffset + atOffset + offset;
  1281. }
  1282. }
  1283. },
  1284. top: function( position, data ) {
  1285. var within = data.within,
  1286. withinOffset = within.offset.top + within.scrollTop,
  1287. outerHeight = within.height,
  1288. offsetTop = within.isWindow ? within.scrollTop : within.offset.top,
  1289. collisionPosTop = position.top - data.collisionPosition.marginTop,
  1290. overTop = collisionPosTop - offsetTop,
  1291. overBottom = collisionPosTop + data.collisionHeight - outerHeight - offsetTop,
  1292. top = data.my[ 1 ] === "top",
  1293. myOffset = top ?
  1294. -data.elemHeight :
  1295. data.my[ 1 ] === "bottom" ?
  1296. data.elemHeight :
  1297. 0,
  1298. atOffset = data.at[ 1 ] === "top" ?
  1299. data.targetHeight :
  1300. data.at[ 1 ] === "bottom" ?
  1301. -data.targetHeight :
  1302. 0,
  1303. offset = -2 * data.offset[ 1 ],
  1304. newOverTop,
  1305. newOverBottom;
  1306. if ( overTop < 0 ) {
  1307. newOverBottom = position.top + myOffset + atOffset + offset + data.collisionHeight - outerHeight - withinOffset;
  1308. if ( newOverBottom < 0 || newOverBottom < abs( overTop ) ) {
  1309. position.top += myOffset + atOffset + offset;
  1310. }
  1311. } else if ( overBottom > 0 ) {
  1312. newOverTop = position.top - data.collisionPosition.marginTop + myOffset + atOffset + offset - offsetTop;
  1313. if ( newOverTop > 0 || abs( newOverTop ) < overBottom ) {
  1314. position.top += myOffset + atOffset + offset;
  1315. }
  1316. }
  1317. }
  1318. },
  1319. flipfit: {
  1320. left: function() {
  1321. $.ui.position.flip.left.apply( this, arguments );
  1322. $.ui.position.fit.left.apply( this, arguments );
  1323. },
  1324. top: function() {
  1325. $.ui.position.flip.top.apply( this, arguments );
  1326. $.ui.position.fit.top.apply( this, arguments );
  1327. }
  1328. }
  1329. };
  1330. // fraction support test
  1331. (function() {
  1332. var testElement, testElementParent, testElementStyle, offsetLeft, i,
  1333. body = document.getElementsByTagName( "body" )[ 0 ],
  1334. div = document.createElement( "div" );
  1335. //Create a "fake body" for testing based on method used in jQuery.support
  1336. testElement = document.createElement( body ? "div" : "body" );
  1337. testElementStyle = {
  1338. visibility: "hidden",
  1339. width: 0,
  1340. height: 0,
  1341. border: 0,
  1342. margin: 0,
  1343. background: "none"
  1344. };
  1345. if ( body ) {
  1346. $.extend( testElementStyle, {
  1347. position: "absolute",
  1348. left: "-1000px",
  1349. top: "-1000px"
  1350. });
  1351. }
  1352. for ( i in testElementStyle ) {
  1353. testElement.style[ i ] = testElementStyle[ i ];
  1354. }
  1355. testElement.appendChild( div );
  1356. testElementParent = body || document.documentElement;
  1357. testElementParent.insertBefore( testElement, testElementParent.firstChild );
  1358. div.style.cssText = "position: absolute; left: 10.7432222px;";
  1359. offsetLeft = $( div ).offset().left;
  1360. supportsOffsetFractions = offsetLeft > 10 && offsetLeft < 11;
  1361. testElement.innerHTML = "";
  1362. testElementParent.removeChild( testElement );
  1363. })();
  1364. })();
  1365. var position = $.ui.position;
  1366. /*!
  1367. * jQuery UI Accordion 1.11.3
  1368. * http://jqueryui.com
  1369. *
  1370. * Copyright jQuery Foundation and other contributors
  1371. * Released under the MIT license.
  1372. * http://jquery.org/license
  1373. *
  1374. * http://api.jqueryui.com/accordion/
  1375. */
  1376. var accordion = $.widget( "ui.accordion", {
  1377. version: "1.11.3",
  1378. options: {
  1379. active: 0,
  1380. animate: {},
  1381. collapsible: false,
  1382. event: "click",
  1383. header: "> li > :first-child,> :not(li):even",
  1384. heightStyle: "auto",
  1385. icons: {
  1386. activeHeader: "ui-icon-triangle-1-s",
  1387. header: "ui-icon-triangle-1-e"
  1388. },
  1389. // callbacks
  1390. activate: null,
  1391. beforeActivate: null
  1392. },
  1393. hideProps: {
  1394. borderTopWidth: "hide",
  1395. borderBottomWidth: "hide",
  1396. paddingTop: "hide",
  1397. paddingBottom: "hide",
  1398. height: "hide"
  1399. },
  1400. showProps: {
  1401. borderTopWidth: "show",
  1402. borderBottomWidth: "show",
  1403. paddingTop: "show",
  1404. paddingBottom: "show",
  1405. height: "show"
  1406. },
  1407. _create: function() {
  1408. var options = this.options;
  1409. this.prevShow = this.prevHide = $();
  1410. this.element.addClass( "ui-accordion ui-widget ui-helper-reset" )
  1411. // ARIA
  1412. .attr( "role", "tablist" );
  1413. // don't allow collapsible: false and active: false / null
  1414. if ( !options.collapsible && (options.active === false || options.active == null) ) {
  1415. options.active = 0;
  1416. }
  1417. this._processPanels();
  1418. // handle negative values
  1419. if ( options.active < 0 ) {
  1420. options.active += this.headers.length;
  1421. }
  1422. this._refresh();
  1423. },
  1424. _getCreateEventData: function() {
  1425. return {
  1426. header: this.active,
  1427. panel: !this.active.length ? $() : this.active.next()
  1428. };
  1429. },
  1430. _createIcons: function() {
  1431. var icons = this.options.icons;
  1432. if ( icons ) {
  1433. $( "<span>" )
  1434. .addClass( "ui-accordion-header-icon ui-icon " + icons.header )
  1435. .prependTo( this.headers );
  1436. this.active.children( ".ui-accordion-header-icon" )
  1437. .removeClass( icons.header )
  1438. .addClass( icons.activeHeader );
  1439. this.headers.addClass( "ui-accordion-icons" );
  1440. }
  1441. },
  1442. _destroyIcons: function() {
  1443. this.headers
  1444. .removeClass( "ui-accordion-icons" )
  1445. .children( ".ui-accordion-header-icon" )
  1446. .remove();
  1447. },
  1448. _destroy: function() {
  1449. var contents;
  1450. // clean up main element
  1451. this.element
  1452. .removeClass( "ui-accordion ui-widget ui-helper-reset" )
  1453. .removeAttr( "role" );
  1454. // clean up headers
  1455. this.headers
  1456. .removeClass( "ui-accordion-header ui-accordion-header-active ui-state-default " +
  1457. "ui-corner-all ui-state-active ui-state-disabled ui-corner-top" )
  1458. .removeAttr( "role" )
  1459. .removeAttr( "aria-expanded" )
  1460. .removeAttr( "aria-selected" )
  1461. .removeAttr( "aria-controls" )
  1462. .removeAttr( "tabIndex" )
  1463. .removeUniqueId();
  1464. this._destroyIcons();
  1465. // clean up content panels
  1466. contents = this.headers.next()
  1467. .removeClass( "ui-helper-reset ui-widget-content ui-corner-bottom " +
  1468. "ui-accordion-content ui-accordion-content-active ui-state-disabled" )
  1469. .css( "display", "" )
  1470. .removeAttr( "role" )
  1471. .removeAttr( "aria-hidden" )
  1472. .removeAttr( "aria-labelledby" )
  1473. .removeUniqueId();
  1474. if ( this.options.heightStyle !== "content" ) {
  1475. contents.css( "height", "" );
  1476. }
  1477. },
  1478. _setOption: function( key, value ) {
  1479. if ( key === "active" ) {
  1480. // _activate() will handle invalid values and update this.options
  1481. this._activate( value );
  1482. return;
  1483. }
  1484. if ( key === "event" ) {
  1485. if ( this.options.event ) {
  1486. this._off( this.headers, this.options.event );
  1487. }
  1488. this._setupEvents( value );
  1489. }
  1490. this._super( key, value );
  1491. // setting collapsible: false while collapsed; open first panel
  1492. if ( key === "collapsible" && !value && this.options.active === false ) {
  1493. this._activate( 0 );
  1494. }
  1495. if ( key === "icons" ) {
  1496. this._destroyIcons();
  1497. if ( value ) {
  1498. this._createIcons();
  1499. }
  1500. }
  1501. // #5332 - opacity doesn't cascade to positioned elements in IE
  1502. // so we need to add the disabled class to the headers and panels
  1503. if ( key === "disabled" ) {
  1504. this.element
  1505. .toggleClass( "ui-state-disabled", !!value )
  1506. .attr( "aria-disabled", value );
  1507. this.headers.add( this.headers.next() )
  1508. .toggleClass( "ui-state-disabled", !!value );
  1509. }
  1510. },
  1511. _keydown: function( event ) {
  1512. if ( event.altKey || event.ctrlKey ) {
  1513. return;
  1514. }
  1515. var keyCode = $.ui.keyCode,
  1516. length = this.headers.length,
  1517. currentIndex = this.headers.index( event.target ),
  1518. toFocus = false;
  1519. switch ( event.keyCode ) {
  1520. case keyCode.RIGHT:
  1521. case keyCode.DOWN:
  1522. toFocus = this.headers[ ( currentIndex + 1 ) % length ];
  1523. break;
  1524. case keyCode.LEFT:
  1525. case keyCode.UP:
  1526. toFocus = this.headers[ ( currentIndex - 1 + length ) % length ];
  1527. break;
  1528. case keyCode.SPACE:
  1529. case keyCode.ENTER:
  1530. this._eventHandler( event );
  1531. break;
  1532. case keyCode.HOME:
  1533. toFocus = this.headers[ 0 ];
  1534. break;
  1535. case keyCode.END:
  1536. toFocus = this.headers[ length - 1 ];
  1537. break;
  1538. }
  1539. if ( toFocus ) {
  1540. $( event.target ).attr( "tabIndex", -1 );
  1541. $( toFocus ).attr( "tabIndex", 0 );
  1542. toFocus.focus();
  1543. event.preventDefault();
  1544. }
  1545. },
  1546. _panelKeyDown: function( event ) {
  1547. if ( event.keyCode === $.ui.keyCode.UP && event.ctrlKey ) {
  1548. $( event.currentTarget ).prev().focus();
  1549. }
  1550. },
  1551. refresh: function() {
  1552. var options = this.options;
  1553. this._processPanels();
  1554. // was collapsed or no panel
  1555. if ( ( options.active === false && options.collapsible === true ) || !this.headers.length ) {
  1556. options.active = false;
  1557. this.active = $();
  1558. // active false only when collapsible is true
  1559. } else if ( options.active === false ) {
  1560. this._activate( 0 );
  1561. // was active, but active panel is gone
  1562. } else if ( this.active.length && !$.contains( this.element[ 0 ], this.active[ 0 ] ) ) {
  1563. // all remaining panel are disabled
  1564. if ( this.headers.length === this.headers.find(".ui-state-disabled").length ) {
  1565. options.active = false;
  1566. this.active = $();
  1567. // activate previous panel
  1568. } else {
  1569. this._activate( Math.max( 0, options.active - 1 ) );
  1570. }
  1571. // was active, active panel still exists
  1572. } else {
  1573. // make sure active index is correct
  1574. options.active = this.headers.index( this.active );
  1575. }
  1576. this._destroyIcons();
  1577. this._refresh();
  1578. },
  1579. _processPanels: function() {
  1580. var prevHeaders = this.headers,
  1581. prevPanels = this.panels;
  1582. this.headers = this.element.find( this.options.header )
  1583. .addClass( "ui-accordion-header ui-state-default ui-corner-all" );
  1584. this.panels = this.headers.next()
  1585. .addClass( "ui-accordion-content ui-helper-reset ui-widget-content ui-corner-bottom" )
  1586. .filter( ":not(.ui-accordion-content-active)" )
  1587. .hide();
  1588. // Avoid memory leaks (#10056)
  1589. if ( prevPanels ) {
  1590. this._off( prevHeaders.not( this.headers ) );
  1591. this._off( prevPanels.not( this.panels ) );
  1592. }
  1593. },
  1594. _refresh: function() {
  1595. var maxHeight,
  1596. options = this.options,
  1597. heightStyle = options.heightStyle,
  1598. parent = this.element.parent();
  1599. this.active = this._findActive( options.active )
  1600. .addClass( "ui-accordion-header-active ui-state-active ui-corner-top" )
  1601. .removeClass( "ui-corner-all" );
  1602. this.active.next()
  1603. .addClass( "ui-accordion-content-active" )
  1604. .show();
  1605. this.headers
  1606. .attr( "role", "tab" )
  1607. .each(function() {
  1608. var header = $( this ),
  1609. headerId = header.uniqueId().attr( "id" ),
  1610. panel = header.next(),
  1611. panelId = panel.uniqueId().attr( "id" );
  1612. header.attr( "aria-controls", panelId );
  1613. panel.attr( "aria-labelledby", headerId );
  1614. })
  1615. .next()
  1616. .attr( "role", "tabpanel" );
  1617. this.headers
  1618. .not( this.active )
  1619. .attr({
  1620. "aria-selected": "false",
  1621. "aria-expanded": "false",
  1622. tabIndex: -1
  1623. })
  1624. .next()
  1625. .attr({
  1626. "aria-hidden": "true"
  1627. })
  1628. .hide();
  1629. // make sure at least one header is in the tab order
  1630. if ( !this.active.length ) {
  1631. this.headers.eq( 0 ).attr( "tabIndex", 0 );
  1632. } else {
  1633. this.active.attr({
  1634. "aria-selected": "true",
  1635. "aria-expanded": "true",
  1636. tabIndex: 0
  1637. })
  1638. .next()
  1639. .attr({
  1640. "aria-hidden": "false"
  1641. });
  1642. }
  1643. this._createIcons();
  1644. this._setupEvents( options.event );
  1645. if ( heightStyle === "fill" ) {
  1646. maxHeight = parent.height();
  1647. this.element.siblings( ":visible" ).each(function() {
  1648. var elem = $( this ),
  1649. position = elem.css( "position" );
  1650. if ( position === "absolute" || position === "fixed" ) {
  1651. return;
  1652. }
  1653. maxHeight -= elem.outerHeight( true );
  1654. });
  1655. this.headers.each(function() {
  1656. maxHeight -= $( this ).outerHeight( true );
  1657. });
  1658. this.headers.next()
  1659. .each(function() {
  1660. $( this ).height( Math.max( 0, maxHeight -
  1661. $( this ).innerHeight() + $( this ).height() ) );
  1662. })
  1663. .css( "overflow", "auto" );
  1664. } else if ( heightStyle === "auto" ) {
  1665. maxHeight = 0;
  1666. this.headers.next()
  1667. .each(function() {
  1668. maxHeight = Math.max( maxHeight, $( this ).css( "height", "" ).height() );
  1669. })
  1670. .height( maxHeight );
  1671. }
  1672. },
  1673. _activate: function( index ) {
  1674. var active = this._findActive( index )[ 0 ];
  1675. // trying to activate the already active panel
  1676. if ( active === this.active[ 0 ] ) {
  1677. return;
  1678. }
  1679. // trying to collapse, simulate a click on the currently active header
  1680. active = active || this.active[ 0 ];
  1681. this._eventHandler({
  1682. target: active,
  1683. currentTarget: active,
  1684. preventDefault: $.noop
  1685. });
  1686. },
  1687. _findActive: function( selector ) {
  1688. return typeof selector === "number" ? this.headers.eq( selector ) : $();
  1689. },
  1690. _setupEvents: function( event ) {
  1691. var events = {
  1692. keydown: "_keydown"
  1693. };
  1694. if ( event ) {
  1695. $.each( event.split( " " ), function( index, eventName ) {
  1696. events[ eventName ] = "_eventHandler";
  1697. });
  1698. }
  1699. this._off( this.headers.add( this.headers.next() ) );
  1700. this._on( this.headers, events );
  1701. this._on( this.headers.next(), { keydown: "_panelKeyDown" });
  1702. this._hoverable( this.headers );
  1703. this._focusable( this.headers );
  1704. },
  1705. _eventHandler: function( event ) {
  1706. var options = this.options,
  1707. active = this.active,
  1708. clicked = $( event.currentTarget ),
  1709. clickedIsActive = clicked[ 0 ] === active[ 0 ],
  1710. collapsing = clickedIsActive && options.collapsible,
  1711. toShow = collapsing ? $() : clicked.next(),
  1712. toHide = active.next(),
  1713. eventData = {
  1714. oldHeader: active,
  1715. oldPanel: toHide,
  1716. newHeader: collapsing ? $() : clicked,
  1717. newPanel: toShow
  1718. };
  1719. event.preventDefault();
  1720. if (
  1721. // click on active header, but not collapsible
  1722. ( clickedIsActive && !options.collapsible ) ||
  1723. // allow canceling activation
  1724. ( this._trigger( "beforeActivate", event, eventData ) === false ) ) {
  1725. return;
  1726. }
  1727. options.active = collapsing ? false : this.headers.index( clicked );
  1728. // when the call to ._toggle() comes after the class changes
  1729. // it causes a very odd bug in IE 8 (see #6720)
  1730. this.active = clickedIsActive ? $() : clicked;
  1731. this._toggle( eventData );
  1732. // switch classes
  1733. // corner classes on the previously active header stay after the animation
  1734. active.removeClass( "ui-accordion-header-active ui-state-active" );
  1735. if ( options.icons ) {
  1736. active.children( ".ui-accordion-header-icon" )
  1737. .removeClass( options.icons.activeHeader )
  1738. .addClass( options.icons.header );
  1739. }
  1740. if ( !clickedIsActive ) {
  1741. clicked
  1742. .removeClass( "ui-corner-all" )
  1743. .addClass( "ui-accordion-header-active ui-state-active ui-corner-top" );
  1744. if ( options.icons ) {
  1745. clicked.children( ".ui-accordion-header-icon" )
  1746. .removeClass( options.icons.header )
  1747. .addClass( options.icons.activeHeader );
  1748. }
  1749. clicked
  1750. .next()
  1751. .addClass( "ui-accordion-content-active" );
  1752. }
  1753. },
  1754. _toggle: function( data ) {
  1755. var toShow = data.newPanel,
  1756. toHide = this.prevShow.length ? this.prevShow : data.oldPanel;
  1757. // handle activating a panel during the animation for another activation
  1758. this.prevShow.add( this.prevHide ).stop( true, true );
  1759. this.prevShow = toShow;
  1760. this.prevHide = toHide;
  1761. if ( this.options.animate ) {
  1762. this._animate( toShow, toHide, data );
  1763. } else {
  1764. toHide.hide();
  1765. toShow.show();
  1766. this._toggleComplete( data );
  1767. }
  1768. toHide.attr({
  1769. "aria-hidden": "true"
  1770. });
  1771. toHide.prev().attr({
  1772. "aria-selected": "false",
  1773. "aria-expanded": "false"
  1774. });
  1775. // if we're switching panels, remove the old header from the tab order
  1776. // if we're opening from collapsed state, remove the previous header from the tab order
  1777. // if we're collapsing, then keep the collapsing header in the tab order
  1778. if ( toShow.length && toHide.length ) {
  1779. toHide.prev().attr({
  1780. "tabIndex": -1,
  1781. "aria-expanded": "false"
  1782. });
  1783. } else if ( toShow.length ) {
  1784. this.headers.filter(function() {
  1785. return parseInt( $( this ).attr( "tabIndex" ), 10 ) === 0;
  1786. })
  1787. .attr( "tabIndex", -1 );
  1788. }
  1789. toShow
  1790. .attr( "aria-hidden", "false" )
  1791. .prev()
  1792. .attr({
  1793. "aria-selected": "true",
  1794. "aria-expanded": "true",
  1795. tabIndex: 0
  1796. });
  1797. },
  1798. _animate: function( toShow, toHide, data ) {
  1799. var total, easing, duration,
  1800. that = this,
  1801. adjust = 0,
  1802. down = toShow.length &&
  1803. ( !toHide.length || ( toShow.index() < toHide.index() ) ),
  1804. animate = this.options.animate || {},
  1805. options = down && animate.down || animate,
  1806. complete = function() {
  1807. that._toggleComplete( data );
  1808. };
  1809. if ( typeof options === "number" ) {
  1810. duration = options;
  1811. }
  1812. if ( typeof options === "string" ) {
  1813. easing = options;
  1814. }
  1815. // fall back from options to animation in case of partial down settings
  1816. easing = easing || options.easing || animate.easing;
  1817. duration = duration || options.duration || animate.duration;
  1818. if ( !toHide.length ) {
  1819. return toShow.animate( this.showProps, duration, easing, complete );
  1820. }
  1821. if ( !toShow.length ) {
  1822. return toHide.animate( this.hideProps, duration, easing, complete );
  1823. }
  1824. total = toShow.show().outerHeight();
  1825. toHide.animate( this.hideProps, {
  1826. duration: duration,
  1827. easing: easing,
  1828. step: function( now, fx ) {
  1829. fx.now = Math.round( now );
  1830. }
  1831. });
  1832. toShow
  1833. .hide()
  1834. .animate( this.showProps, {
  1835. duration: duration,
  1836. easing: easing,
  1837. complete: complete,
  1838. step: function( now, fx ) {
  1839. fx.now = Math.round( now );
  1840. if ( fx.prop !== "height" ) {
  1841. adjust += fx.now;
  1842. } else if ( that.options.heightStyle !== "content" ) {
  1843. fx.now = Math.round( total - toHide.outerHeight() - adjust );
  1844. adjust = 0;
  1845. }
  1846. }
  1847. });
  1848. },
  1849. _toggleComplete: function( data ) {
  1850. var toHide = data.oldPanel;
  1851. toHide
  1852. .removeClass( "ui-accordion-content-active" )
  1853. .prev()
  1854. .removeClass( "ui-corner-top" )
  1855. .addClass( "ui-corner-all" );
  1856. // Work around for rendering bug in IE (#5421)
  1857. if ( toHide.length ) {
  1858. toHide.parent()[ 0 ].className = toHide.parent()[ 0 ].className;
  1859. }
  1860. this._trigger( "activate", null, data );
  1861. }
  1862. });
  1863. /*!
  1864. * jQuery UI Menu 1.11.3
  1865. * http://jqueryui.com
  1866. *
  1867. * Copyright jQuery Foundation and other contributors
  1868. * Released under the MIT license.
  1869. * http://jquery.org/license
  1870. *
  1871. * http://api.jqueryui.com/menu/
  1872. */
  1873. var menu = $.widget( "ui.menu", {
  1874. version: "1.11.3",
  1875. defaultElement: "<ul>",
  1876. delay: 300,
  1877. options: {
  1878. icons: {
  1879. submenu: "ui-icon-carat-1-e"
  1880. },
  1881. items: "> *",
  1882. menus: "ul",
  1883. position: {
  1884. my: "left-1 top",
  1885. at: "right top"
  1886. },
  1887. role: "menu",
  1888. // callbacks
  1889. blur: null,
  1890. focus: null,
  1891. select: null
  1892. },
  1893. _create: function() {
  1894. this.activeMenu = this.element;
  1895. // Flag used to prevent firing of the click handler
  1896. // as the event bubbles up through nested menus
  1897. this.mouseHandled = false;
  1898. this.element
  1899. .uniqueId()
  1900. .addClass( "ui-menu ui-widget ui-widget-content" )
  1901. .toggleClass( "ui-menu-icons", !!this.element.find( ".ui-icon" ).length )
  1902. .attr({
  1903. role: this.options.role,
  1904. tabIndex: 0
  1905. });
  1906. if ( this.options.disabled ) {
  1907. this.element
  1908. .addClass( "ui-state-disabled" )
  1909. .attr( "aria-disabled", "true" );
  1910. }
  1911. this._on({
  1912. // Prevent focus from sticking to links inside menu after clicking
  1913. // them (focus should always stay on UL during navigation).
  1914. "mousedown .ui-menu-item": function( event ) {
  1915. event.preventDefault();
  1916. },
  1917. "click .ui-menu-item": function( event ) {
  1918. var target = $( event.target );
  1919. if ( !this.mouseHandled && target.not( ".ui-state-disabled" ).length ) {
  1920. this.select( event );
  1921. // Only set the mouseHandled flag if the event will bubble, see #9469.
  1922. if ( !event.isPropagationStopped() ) {
  1923. this.mouseHandled = true;
  1924. }
  1925. // Open submenu on click
  1926. if ( target.has( ".ui-menu" ).length ) {
  1927. this.expand( event );
  1928. } else if ( !this.element.is( ":focus" ) && $( this.document[ 0 ].activeElement ).closest( ".ui-menu" ).length ) {
  1929. // Redirect focus to the menu
  1930. this.element.trigger( "focus", [ true ] );
  1931. // If the active item is on the top level, let it stay active.
  1932. // Otherwise, blur the active item since it is no longer visible.
  1933. if ( this.active && this.active.parents( ".ui-menu" ).length === 1 ) {
  1934. clearTimeout( this.timer );
  1935. }
  1936. }
  1937. }
  1938. },
  1939. "mouseenter .ui-menu-item": function( event ) {
  1940. // Ignore mouse events while typeahead is active, see #10458.
  1941. // Prevents focusing the wrong item when typeahead causes a scroll while the mouse
  1942. // is over an item in the menu
  1943. if ( this.previousFilter ) {
  1944. return;
  1945. }
  1946. var target = $( event.currentTarget );
  1947. // Remove ui-state-active class from siblings of the newly focused menu item
  1948. // to avoid a jump caused by adjacent elements both having a class with a border
  1949. target.siblings( ".ui-state-active" ).removeClass( "ui-state-active" );
  1950. this.focus( event, target );
  1951. },
  1952. mouseleave: "collapseAll",
  1953. "mouseleave .ui-menu": "collapseAll",
  1954. focus: function( event, keepActiveItem ) {
  1955. // If there's already an active item, keep it active
  1956. // If not, activate the first item
  1957. var item = this.active || this.element.find( this.options.items ).eq( 0 );
  1958. if ( !keepActiveItem ) {
  1959. this.focus( event, item );
  1960. }
  1961. },
  1962. blur: function( event ) {
  1963. this._delay(function() {
  1964. if ( !$.contains( this.element[0], this.document[0].activeElement ) ) {
  1965. this.collapseAll( event );
  1966. }
  1967. });
  1968. },
  1969. keydown: "_keydown"
  1970. });
  1971. this.refresh();
  1972. // Clicks outside of a menu collapse any open menus
  1973. this._on( this.document, {
  1974. click: function( event ) {
  1975. if ( this._closeOnDocumentClick( event ) ) {
  1976. this.collapseAll( event );
  1977. }
  1978. // Reset the mouseHandled flag
  1979. this.mouseHandled = false;
  1980. }
  1981. });
  1982. },
  1983. _destroy: function() {
  1984. // Destroy (sub)menus
  1985. this.element
  1986. .removeAttr( "aria-activedescendant" )
  1987. .find( ".ui-menu" ).addBack()
  1988. .removeClass( "ui-menu ui-widget ui-widget-content ui-menu-icons ui-front" )
  1989. .removeAttr( "role" )
  1990. .removeAttr( "tabIndex" )
  1991. .removeAttr( "aria-labelledby" )
  1992. .removeAttr( "aria-expanded" )
  1993. .removeAttr( "aria-hidden" )
  1994. .removeAttr( "aria-disabled" )
  1995. .removeUniqueId()
  1996. .show();
  1997. // Destroy menu items
  1998. this.element.find( ".ui-menu-item" )
  1999. .removeClass( "ui-menu-item" )
  2000. .removeAttr( "role" )
  2001. .removeAttr( "aria-disabled" )
  2002. .removeUniqueId()
  2003. .removeClass( "ui-state-hover" )
  2004. .removeAttr( "tabIndex" )
  2005. .removeAttr( "role" )
  2006. .removeAttr( "aria-haspopup" )
  2007. .children().each( function() {
  2008. var elem = $( this );
  2009. if ( elem.data( "ui-menu-submenu-carat" ) ) {
  2010. elem.remove();
  2011. }
  2012. });
  2013. // Destroy menu dividers
  2014. this.element.find( ".ui-menu-divider" ).removeClass( "ui-menu-divider ui-widget-content" );
  2015. },
  2016. _keydown: function( event ) {
  2017. var match, prev, character, skip,
  2018. preventDefault = true;
  2019. switch ( event.keyCode ) {
  2020. case $.ui.keyCode.PAGE_UP:
  2021. this.previousPage( event );
  2022. break;
  2023. case $.ui.keyCode.PAGE_DOWN:
  2024. this.nextPage( event );
  2025. break;
  2026. case $.ui.keyCode.HOME:
  2027. this._move( "first", "first", event );
  2028. break;
  2029. case $.ui.keyCode.END:
  2030. this._move( "last", "last", event );
  2031. break;
  2032. case $.ui.keyCode.UP:
  2033. this.previous( event );
  2034. break;
  2035. case $.ui.keyCode.DOWN:
  2036. this.next( event );
  2037. break;
  2038. case $.ui.keyCode.LEFT:
  2039. this.collapse( event );
  2040. break;
  2041. case $.ui.keyCode.RIGHT:
  2042. if ( this.active && !this.active.is( ".ui-state-disabled" ) ) {
  2043. this.expand( event );
  2044. }
  2045. break;
  2046. case $.ui.keyCode.ENTER:
  2047. case $.ui.keyCode.SPACE:
  2048. this._activate( event );
  2049. break;
  2050. case $.ui.keyCode.ESCAPE:
  2051. this.collapse( event );
  2052. break;
  2053. default:
  2054. preventDefault = false;
  2055. prev = this.previousFilter || "";
  2056. character = String.fromCharCode( event.keyCode );
  2057. skip = false;
  2058. clearTimeout( this.filterTimer );
  2059. if ( character === prev ) {
  2060. skip = true;
  2061. } else {
  2062. character = prev + character;
  2063. }
  2064. match = this._filterMenuItems( character );
  2065. match = skip && match.index( this.active.next() ) !== -1 ?
  2066. this.active.nextAll( ".ui-menu-item" ) :
  2067. match;
  2068. // If no matches on the current filter, reset to the last character pressed
  2069. // to move down the menu to the first item that starts with that character
  2070. if ( !match.length ) {
  2071. character = String.fromCharCode( event.keyCode );
  2072. match = this._filterMenuItems( character );
  2073. }
  2074. if ( match.length ) {
  2075. this.focus( event, match );
  2076. this.previousFilter = character;
  2077. this.filterTimer = this._delay(function() {
  2078. delete this.previousFilter;
  2079. }, 1000 );
  2080. } else {
  2081. delete this.previousFilter;
  2082. }
  2083. }
  2084. if ( preventDefault ) {
  2085. event.preventDefault();
  2086. }
  2087. },
  2088. _activate: function( event ) {
  2089. if ( !this.active.is( ".ui-state-disabled" ) ) {
  2090. if ( this.active.is( "[aria-haspopup='true']" ) ) {
  2091. this.expand( event );
  2092. } else {
  2093. this.select( event );
  2094. }
  2095. }
  2096. },
  2097. refresh: function() {
  2098. var menus, items,
  2099. that = this,
  2100. icon = this.options.icons.submenu,
  2101. submenus = this.element.find( this.options.menus );
  2102. this.element.toggleClass( "ui-menu-icons", !!this.element.find( ".ui-icon" ).length );
  2103. // Initialize nested menus
  2104. submenus.filter( ":not(.ui-menu)" )
  2105. .addClass( "ui-menu ui-widget ui-widget-content ui-front" )
  2106. .hide()
  2107. .attr({
  2108. role: this.options.role,
  2109. "aria-hidden": "true",
  2110. "aria-expanded": "false"
  2111. })
  2112. .each(function() {
  2113. var menu = $( this ),
  2114. item = menu.parent(),
  2115. submenuCarat = $( "<span>" )
  2116. .addClass( "ui-menu-icon ui-icon " + icon )
  2117. .data( "ui-menu-submenu-carat", true );
  2118. item
  2119. .attr( "aria-haspopup", "true" )
  2120. .prepend( submenuCarat );
  2121. menu.attr( "aria-labelledby", item.attr( "id" ) );
  2122. });
  2123. menus = submenus.add( this.element );
  2124. items = menus.find( this.options.items );
  2125. // Initialize menu-items containing spaces and/or dashes only as dividers
  2126. items.not( ".ui-menu-item" ).each(function() {
  2127. var item = $( this );
  2128. if ( that._isDivider( item ) ) {
  2129. item.addClass( "ui-widget-content ui-menu-divider" );
  2130. }
  2131. });
  2132. // Don't refresh list items that are already adapted
  2133. items.not( ".ui-menu-item, .ui-menu-divider" )
  2134. .addClass( "ui-menu-item" )
  2135. .uniqueId()
  2136. .attr({
  2137. tabIndex: -1,
  2138. role: this._itemRole()
  2139. });
  2140. // Add aria-disabled attribute to any disabled menu item
  2141. items.filter( ".ui-state-disabled" ).attr( "aria-disabled", "true" );
  2142. // If the active item has been removed, blur the menu
  2143. if ( this.active && !$.contains( this.element[ 0 ], this.active[ 0 ] ) ) {
  2144. this.blur();
  2145. }
  2146. },
  2147. _itemRole: function() {
  2148. return {
  2149. menu: "menuitem",
  2150. listbox: "option"
  2151. }[ this.options.role ];
  2152. },
  2153. _setOption: function( key, value ) {
  2154. if ( key === "icons" ) {
  2155. this.element.find( ".ui-menu-icon" )
  2156. .removeClass( this.options.icons.submenu )
  2157. .addClass( value.submenu );
  2158. }
  2159. if ( key === "disabled" ) {
  2160. this.element
  2161. .toggleClass( "ui-state-disabled", !!value )
  2162. .attr( "aria-disabled", value );
  2163. }
  2164. this._super( key, value );
  2165. },
  2166. focus: function( event, item ) {
  2167. var nested, focused;
  2168. this.blur( event, event && event.type === "focus" );
  2169. this._scrollIntoView( item );
  2170. this.active = item.first();
  2171. focused = this.active.addClass( "ui-state-focus" ).removeClass( "ui-state-active" );
  2172. // Only update aria-activedescendant if there's a role
  2173. // otherwise we assume focus is managed elsewhere
  2174. if ( this.options.role ) {
  2175. this.element.attr( "aria-activedescendant", focused.attr( "id" ) );
  2176. }
  2177. // Highlight active parent menu item, if any
  2178. this.active
  2179. .parent()
  2180. .closest( ".ui-menu-item" )
  2181. .addClass( "ui-state-active" );
  2182. if ( event && event.type === "keydown" ) {
  2183. this._close();
  2184. } else {
  2185. this.timer = this._delay(function() {
  2186. this._close();
  2187. }, this.delay );
  2188. }
  2189. nested = item.children( ".ui-menu" );
  2190. if ( nested.length && event && ( /^mouse/.test( event.type ) ) ) {
  2191. this._startOpening(nested);
  2192. }
  2193. this.activeMenu = item.parent();
  2194. this._trigger( "focus", event, { item: item } );
  2195. },
  2196. _scrollIntoView: function( item ) {
  2197. var borderTop, paddingTop, offset, scroll, elementHeight, itemHeight;
  2198. if ( this._hasScroll() ) {
  2199. borderTop = parseFloat( $.css( this.activeMenu[0], "borderTopWidth" ) ) || 0;
  2200. paddingTop = parseFloat( $.css( this.activeMenu[0], "paddingTop" ) ) || 0;
  2201. offset = item.offset().top - this.activeMenu.offset().top - borderTop - paddingTop;
  2202. scroll = this.activeMenu.scrollTop();
  2203. elementHeight = this.activeMenu.height();
  2204. itemHeight = item.outerHeight();
  2205. if ( offset < 0 ) {
  2206. this.activeMenu.scrollTop( scroll + offset );
  2207. } else if ( offset + itemHeight > elementHeight ) {
  2208. this.activeMenu.scrollTop( scroll + offset - elementHeight + itemHeight );
  2209. }
  2210. }
  2211. },
  2212. blur: function( event, fromFocus ) {
  2213. if ( !fromFocus ) {
  2214. clearTimeout( this.timer );
  2215. }
  2216. if ( !this.active ) {
  2217. return;
  2218. }
  2219. this.active.removeClass( "ui-state-focus" );
  2220. this.active = null;
  2221. this._trigger( "blur", event, { item: this.active } );
  2222. },
  2223. _startOpening: function( submenu ) {
  2224. clearTimeout( this.timer );
  2225. // Don't open if already open fixes a Firefox bug that caused a .5 pixel
  2226. // shift in the submenu position when mousing over the carat icon
  2227. if ( submenu.attr( "aria-hidden" ) !== "true" ) {
  2228. return;
  2229. }
  2230. this.timer = this._delay(function() {
  2231. this._close();
  2232. this._open( submenu );
  2233. }, this.delay );
  2234. },
  2235. _open: function( submenu ) {
  2236. var position = $.extend({
  2237. of: this.active
  2238. }, this.options.position );
  2239. clearTimeout( this.timer );
  2240. this.element.find( ".ui-menu" ).not( submenu.parents( ".ui-menu" ) )
  2241. .hide()
  2242. .attr( "aria-hidden", "true" );
  2243. submenu
  2244. .show()
  2245. .removeAttr( "aria-hidden" )
  2246. .attr( "aria-expanded", "true" )
  2247. .position( position );
  2248. },
  2249. collapseAll: function( event, all ) {
  2250. clearTimeout( this.timer );
  2251. this.timer = this._delay(function() {
  2252. // If we were passed an event, look for the submenu that contains the event
  2253. var currentMenu = all ? this.element :
  2254. $( event && event.target ).closest( this.element.find( ".ui-menu" ) );
  2255. // If we found no valid submenu ancestor, use the main menu to close all sub menus anyway
  2256. if ( !currentMenu.length ) {
  2257. currentMenu = this.element;
  2258. }
  2259. this._close( currentMenu );
  2260. this.blur( event );
  2261. this.activeMenu = currentMenu;
  2262. }, this.delay );
  2263. },
  2264. // With no arguments, closes the currently active menu - if nothing is active
  2265. // it closes all menus. If passed an argument, it will search for menus BELOW
  2266. _close: function( startMenu ) {
  2267. if ( !startMenu ) {
  2268. startMenu = this.active ? this.active.parent() : this.element;
  2269. }
  2270. startMenu
  2271. .find( ".ui-menu" )
  2272. .hide()
  2273. .attr( "aria-hidden", "true" )
  2274. .attr( "aria-expanded", "false" )
  2275. .end()
  2276. .find( ".ui-state-active" ).not( ".ui-state-focus" )
  2277. .removeClass( "ui-state-active" );
  2278. },
  2279. _closeOnDocumentClick: function( event ) {
  2280. return !$( event.target ).closest( ".ui-menu" ).length;
  2281. },
  2282. _isDivider: function( item ) {
  2283. // Match hyphen, em dash, en dash
  2284. return !/[^\-\u2014\u2013\s]/.test( item.text() );
  2285. },
  2286. collapse: function( event ) {
  2287. var newItem = this.active &&
  2288. this.active.parent().closest( ".ui-menu-item", this.element );
  2289. if ( newItem && newItem.length ) {
  2290. this._close();
  2291. this.focus( event, newItem );
  2292. }
  2293. },
  2294. expand: function( event ) {
  2295. var newItem = this.active &&
  2296. this.active
  2297. .children( ".ui-menu " )
  2298. .find( this.options.items )
  2299. .first();
  2300. if ( newItem && newItem.length ) {
  2301. this._open( newItem.parent() );
  2302. // Delay so Firefox will not hide activedescendant change in expanding submenu from AT
  2303. this._delay(function() {
  2304. this.focus( event, newItem );
  2305. });
  2306. }
  2307. },
  2308. next: function( event ) {
  2309. this._move( "next", "first", event );
  2310. },
  2311. previous: function( event ) {
  2312. this._move( "prev", "last", event );
  2313. },
  2314. isFirstItem: function() {
  2315. return this.active && !this.active.prevAll( ".ui-menu-item" ).length;
  2316. },
  2317. isLastItem: function() {
  2318. return this.active && !this.active.nextAll( ".ui-menu-item" ).length;
  2319. },
  2320. _move: function( direction, filter, event ) {
  2321. var next;
  2322. if ( this.active ) {
  2323. if ( direction === "first" || direction === "last" ) {
  2324. next = this.active
  2325. [ direction === "first" ? "prevAll" : "nextAll" ]( ".ui-menu-item" )
  2326. .eq( -1 );
  2327. } else {
  2328. next = this.active
  2329. [ direction + "All" ]( ".ui-menu-item" )
  2330. .eq( 0 );
  2331. }
  2332. }
  2333. if ( !next || !next.length || !this.active ) {
  2334. next = this.activeMenu.find( this.options.items )[ filter ]();
  2335. }
  2336. this.focus( event, next );
  2337. },
  2338. nextPage: function( event ) {
  2339. var item, base, height;
  2340. if ( !this.active ) {
  2341. this.next( event );
  2342. return;
  2343. }
  2344. if ( this.isLastItem() ) {
  2345. return;
  2346. }
  2347. if ( this._hasScroll() ) {
  2348. base = this.active.offset().top;
  2349. height = this.element.height();
  2350. this.active.nextAll( ".ui-menu-item" ).each(function() {
  2351. item = $( this );
  2352. return item.offset().top - base - height < 0;
  2353. });
  2354. this.focus( event, item );
  2355. } else {
  2356. this.focus( event, this.activeMenu.find( this.options.items )
  2357. [ !this.active ? "first" : "last" ]() );
  2358. }
  2359. },
  2360. previousPage: function( event ) {
  2361. var item, base, height;
  2362. if ( !this.active ) {
  2363. this.next( event );
  2364. return;
  2365. }
  2366. if ( this.isFirstItem() ) {
  2367. return;
  2368. }
  2369. if ( this._hasScroll() ) {
  2370. base = this.active.offset().top;
  2371. height = this.element.height();
  2372. this.active.prevAll( ".ui-menu-item" ).each(function() {
  2373. item = $( this );
  2374. return item.offset().top - base + height > 0;
  2375. });
  2376. this.focus( event, item );
  2377. } else {
  2378. this.focus( event, this.activeMenu.find( this.options.items ).first() );
  2379. }
  2380. },
  2381. _hasScroll: function() {
  2382. return this.element.outerHeight() < this.element.prop( "scrollHeight" );
  2383. },
  2384. select: function( event ) {
  2385. // TODO: It should never be possible to not have an active item at this
  2386. // point, but the tests don't trigger mouseenter before click.
  2387. this.active = this.active || $( event.target ).closest( ".ui-menu-item" );
  2388. var ui = { item: this.active };
  2389. if ( !this.active.has( ".ui-menu" ).length ) {
  2390. this.collapseAll( event, true );
  2391. }
  2392. this._trigger( "select", event, ui );
  2393. },
  2394. _filterMenuItems: function(character) {
  2395. var escapedCharacter = character.replace( /[\-\[\]{}()*+?.,\\\^$|#\s]/g, "\\$&" ),
  2396. regex = new RegExp( "^" + escapedCharacter, "i" );
  2397. return this.activeMenu
  2398. .find( this.options.items )
  2399. // Only match on items, not dividers or other content (#10571)
  2400. .filter( ".ui-menu-item" )
  2401. .filter(function() {
  2402. return regex.test( $.trim( $( this ).text() ) );
  2403. });
  2404. }
  2405. });
  2406. /*!
  2407. * jQuery UI Autocomplete 1.11.3
  2408. * http://jqueryui.com
  2409. *
  2410. * Copyright jQuery Foundation and other contributors
  2411. * Released under the MIT license.
  2412. * http://jquery.org/license
  2413. *
  2414. * http://api.jqueryui.com/autocomplete/
  2415. */
  2416. $.widget( "ui.autocomplete", {
  2417. version: "1.11.3",
  2418. defaultElement: "<input>",
  2419. options: {
  2420. appendTo: null,
  2421. autoFocus: false,
  2422. delay: 300,
  2423. minLength: 1,
  2424. position: {
  2425. my: "left top",
  2426. at: "left bottom",
  2427. collision: "none"
  2428. },
  2429. source: null,
  2430. // callbacks
  2431. change: null,
  2432. close: null,
  2433. focus: null,
  2434. open: null,
  2435. response: null,
  2436. search: null,
  2437. select: null
  2438. },
  2439. requestIndex: 0,
  2440. pending: 0,
  2441. _create: function() {
  2442. // Some browsers only repeat keydown events, not keypress events,
  2443. // so we use the suppressKeyPress flag to determine if we've already
  2444. // handled the keydown event. #7269
  2445. // Unfortunately the code for & in keypress is the same as the up arrow,
  2446. // so we use the suppressKeyPressRepeat flag to avoid handling keypress
  2447. // events when we know the keydown event was used to modify the
  2448. // search term. #7799
  2449. var suppressKeyPress, suppressKeyPressRepeat, suppressInput,
  2450. nodeName = this.element[ 0 ].nodeName.toLowerCase(),
  2451. isTextarea = nodeName === "textarea",
  2452. isInput = nodeName === "input";
  2453. this.isMultiLine =
  2454. // Textareas are always multi-line
  2455. isTextarea ? true :
  2456. // Inputs are always single-line, even if inside a contentEditable element
  2457. // IE also treats inputs as contentEditable
  2458. isInput ? false :
  2459. // All other element types are determined by whether or not they're contentEditable
  2460. this.element.prop( "isContentEditable" );
  2461. this.valueMethod = this.element[ isTextarea || isInput ? "val" : "text" ];
  2462. this.isNewMenu = true;
  2463. this.element
  2464. .addClass( "ui-autocomplete-input" )
  2465. .attr( "autocomplete", "off" );
  2466. this._on( this.element, {
  2467. keydown: function( event ) {
  2468. if ( this.element.prop( "readOnly" ) ) {
  2469. suppressKeyPress = true;
  2470. suppressInput = true;
  2471. suppressKeyPressRepeat = true;
  2472. return;
  2473. }
  2474. suppressKeyPress = false;
  2475. suppressInput = false;
  2476. suppressKeyPressRepeat = false;
  2477. var keyCode = $.ui.keyCode;
  2478. switch ( event.keyCode ) {
  2479. case keyCode.PAGE_UP:
  2480. suppressKeyPress = true;
  2481. this._move( "previousPage", event );
  2482. break;
  2483. case keyCode.PAGE_DOWN:
  2484. suppressKeyPress = true;
  2485. this._move( "nextPage", event );
  2486. break;
  2487. case keyCode.UP:
  2488. suppressKeyPress = true;
  2489. this._keyEvent( "previous", event );
  2490. break;
  2491. case keyCode.DOWN:
  2492. suppressKeyPress = true;
  2493. this._keyEvent( "next", event );
  2494. break;
  2495. case keyCode.ENTER:
  2496. // when menu is open and has focus
  2497. if ( this.menu.active ) {
  2498. // #6055 - Opera still allows the keypress to occur
  2499. // which causes forms to submit
  2500. suppressKeyPress = true;
  2501. event.preventDefault();
  2502. this.menu.select( event );
  2503. }
  2504. break;
  2505. case keyCode.TAB:
  2506. if ( this.menu.active ) {
  2507. this.menu.select( event );
  2508. }
  2509. break;
  2510. case keyCode.ESCAPE:
  2511. if ( this.menu.element.is( ":visible" ) ) {
  2512. if ( !this.isMultiLine ) {
  2513. this._value( this.term );
  2514. }
  2515. this.close( event );
  2516. // Different browsers have different default behavior for escape
  2517. // Single press can mean undo or clear
  2518. // Double press in IE means clear the whole form
  2519. event.preventDefault();
  2520. }
  2521. break;
  2522. default:
  2523. suppressKeyPressRepeat = true;
  2524. // search timeout should be triggered before the input value is changed
  2525. this._searchTimeout( event );
  2526. break;
  2527. }
  2528. },
  2529. keypress: function( event ) {
  2530. if ( suppressKeyPress ) {
  2531. suppressKeyPress = false;
  2532. if ( !this.isMultiLine || this.menu.element.is( ":visible" ) ) {
  2533. event.preventDefault();
  2534. }
  2535. return;
  2536. }
  2537. if ( suppressKeyPressRepeat ) {
  2538. return;
  2539. }
  2540. // replicate some key handlers to allow them to repeat in Firefox and Opera
  2541. var keyCode = $.ui.keyCode;
  2542. switch ( event.keyCode ) {
  2543. case keyCode.PAGE_UP:
  2544. this._move( "previousPage", event );
  2545. break;
  2546. case keyCode.PAGE_DOWN:
  2547. this._move( "nextPage", event );
  2548. break;
  2549. case keyCode.UP:
  2550. this._keyEvent( "previous", event );
  2551. break;
  2552. case keyCode.DOWN:
  2553. this._keyEvent( "next", event );
  2554. break;
  2555. }
  2556. },
  2557. input: function( event ) {
  2558. if ( suppressInput ) {
  2559. suppressInput = false;
  2560. event.preventDefault();
  2561. return;
  2562. }
  2563. this._searchTimeout( event );
  2564. },
  2565. focus: function() {
  2566. this.selectedItem = null;
  2567. this.previous = this._value();
  2568. },
  2569. blur: function( event ) {
  2570. if ( this.cancelBlur ) {
  2571. delete this.cancelBlur;
  2572. return;
  2573. }
  2574. clearTimeout( this.searching );
  2575. this.close( event );
  2576. this._change( event );
  2577. }
  2578. });
  2579. this._initSource();
  2580. this.menu = $( "<ul>" )
  2581. .addClass( "ui-autocomplete ui-front" )
  2582. .appendTo( this._appendTo() )
  2583. .menu({
  2584. // disable ARIA support, the live region takes care of that
  2585. role: null
  2586. })
  2587. .hide()
  2588. .menu( "instance" );
  2589. this._on( this.menu.element, {
  2590. mousedown: function( event ) {
  2591. // prevent moving focus out of the text field
  2592. event.preventDefault();
  2593. // IE doesn't prevent moving focus even with event.preventDefault()
  2594. // so we set a flag to know when we should ignore the blur event
  2595. this.cancelBlur = true;
  2596. this._delay(function() {
  2597. delete this.cancelBlur;
  2598. });
  2599. // clicking on the scrollbar causes focus to shift to the body
  2600. // but we can't detect a mouseup or a click immediately afterward
  2601. // so we have to track the next mousedown and close the menu if
  2602. // the user clicks somewhere outside of the autocomplete
  2603. var menuElement = this.menu.element[ 0 ];
  2604. if ( !$( event.target ).closest( ".ui-menu-item" ).length ) {
  2605. this._delay(function() {
  2606. var that = this;
  2607. this.document.one( "mousedown", function( event ) {
  2608. if ( event.target !== that.element[ 0 ] &&
  2609. event.target !== menuElement &&
  2610. !$.contains( menuElement, event.target ) ) {
  2611. that.close();
  2612. }
  2613. });
  2614. });
  2615. }
  2616. },
  2617. menufocus: function( event, ui ) {
  2618. var label, item;
  2619. // support: Firefox
  2620. // Prevent accidental activation of menu items in Firefox (#7024 #9118)
  2621. if ( this.isNewMenu ) {
  2622. this.isNewMenu = false;
  2623. if ( event.originalEvent && /^mouse/.test( event.originalEvent.type ) ) {
  2624. this.menu.blur();
  2625. this.document.one( "mousemove", function() {
  2626. $( event.target ).trigger( event.originalEvent );
  2627. });
  2628. return;
  2629. }
  2630. }
  2631. item = ui.item.data( "ui-autocomplete-item" );
  2632. if ( false !== this._trigger( "focus", event, { item: item } ) ) {
  2633. // use value to match what will end up in the input, if it was a key event
  2634. if ( event.originalEvent && /^key/.test( event.originalEvent.type ) ) {
  2635. this._value( item.value );
  2636. }
  2637. }
  2638. // Announce the value in the liveRegion
  2639. label = ui.item.attr( "aria-label" ) || item.value;
  2640. if ( label && $.trim( label ).length ) {
  2641. this.liveRegion.children().hide();
  2642. $( "<div>" ).text( label ).appendTo( this.liveRegion );
  2643. }
  2644. },
  2645. menuselect: function( event, ui ) {
  2646. var item = ui.item.data( "ui-autocomplete-item" ),
  2647. previous = this.previous;
  2648. // only trigger when focus was lost (click on menu)
  2649. if ( this.element[ 0 ] !== this.document[ 0 ].activeElement ) {
  2650. this.element.focus();
  2651. this.previous = previous;
  2652. // #6109 - IE triggers two focus events and the second
  2653. // is asynchronous, so we need to reset the previous
  2654. // term synchronously and asynchronously :-(
  2655. this._delay(function() {
  2656. this.previous = previous;
  2657. this.selectedItem = item;
  2658. });
  2659. }
  2660. if ( false !== this._trigger( "select", event, { item: item } ) ) {
  2661. this._value( item.value );
  2662. }
  2663. // reset the term after the select event
  2664. // this allows custom select handling to work properly
  2665. this.term = this._value();
  2666. this.close( event );
  2667. this.selectedItem = item;
  2668. }
  2669. });
  2670. this.liveRegion = $( "<span>", {
  2671. role: "status",
  2672. "aria-live": "assertive",
  2673. "aria-relevant": "additions"
  2674. })
  2675. .addClass( "ui-helper-hidden-accessible" )
  2676. .appendTo( this.document[ 0 ].body );
  2677. // turning off autocomplete prevents the browser from remembering the
  2678. // value when navigating through history, so we re-enable autocomplete
  2679. // if the page is unloaded before the widget is destroyed. #7790
  2680. this._on( this.window, {
  2681. beforeunload: function() {
  2682. this.element.removeAttr( "autocomplete" );
  2683. }
  2684. });
  2685. },
  2686. _destroy: function() {
  2687. clearTimeout( this.searching );
  2688. this.element
  2689. .removeClass( "ui-autocomplete-input" )
  2690. .removeAttr( "autocomplete" );
  2691. this.menu.element.remove();
  2692. this.liveRegion.remove();
  2693. },
  2694. _setOption: function( key, value ) {
  2695. this._super( key, value );
  2696. if ( key === "source" ) {
  2697. this._initSource();
  2698. }
  2699. if ( key === "appendTo" ) {
  2700. this.menu.element.appendTo( this._appendTo() );
  2701. }
  2702. if ( key === "disabled" && value && this.xhr ) {
  2703. this.xhr.abort();
  2704. }
  2705. },
  2706. _appendTo: function() {
  2707. var element = this.options.appendTo;
  2708. if ( element ) {
  2709. element = element.jquery || element.nodeType ?
  2710. $( element ) :
  2711. this.document.find( element ).eq( 0 );
  2712. }
  2713. if ( !element || !element[ 0 ] ) {
  2714. element = this.element.closest( ".ui-front" );
  2715. }
  2716. if ( !element.length ) {
  2717. element = this.document[ 0 ].body;
  2718. }
  2719. return element;
  2720. },
  2721. _initSource: function() {
  2722. var array, url,
  2723. that = this;
  2724. if ( $.isArray( this.options.source ) ) {
  2725. array = this.options.source;
  2726. this.source = function( request, response ) {
  2727. response( $.ui.autocomplete.filter( array, request.term ) );
  2728. };
  2729. } else if ( typeof this.options.source === "string" ) {
  2730. url = this.options.source;
  2731. this.source = function( request, response ) {
  2732. if ( that.xhr ) {
  2733. that.xhr.abort();
  2734. }
  2735. that.xhr = $.ajax({
  2736. url: url,
  2737. data: request,
  2738. dataType: "json",
  2739. success: function( data ) {
  2740. response( data );
  2741. },
  2742. error: function() {
  2743. response([]);
  2744. }
  2745. });
  2746. };
  2747. } else {
  2748. this.source = this.options.source;
  2749. }
  2750. },
  2751. _searchTimeout: function( event ) {
  2752. clearTimeout( this.searching );
  2753. this.searching = this._delay(function() {
  2754. // Search if the value has changed, or if the user retypes the same value (see #7434)
  2755. var equalValues = this.term === this._value(),
  2756. menuVisible = this.menu.element.is( ":visible" ),
  2757. modifierKey = event.altKey || event.ctrlKey || event.metaKey || event.shiftKey;
  2758. if ( !equalValues || ( equalValues && !menuVisible && !modifierKey ) ) {
  2759. this.selectedItem = null;
  2760. this.search( null, event );
  2761. }
  2762. }, this.options.delay );
  2763. },
  2764. search: function( value, event ) {
  2765. value = value != null ? value : this._value();
  2766. // always save the actual value, not the one passed as an argument
  2767. this.term = this._value();
  2768. if ( value.length < this.options.minLength ) {
  2769. return this.close( event );
  2770. }
  2771. if ( this._trigger( "search", event ) === false ) {
  2772. return;
  2773. }
  2774. return this._search( value );
  2775. },
  2776. _search: function( value ) {
  2777. this.pending++;
  2778. this.element.addClass( "ui-autocomplete-loading" );
  2779. this.cancelSearch = false;
  2780. this.source( { term: value }, this._response() );
  2781. },
  2782. _response: function() {
  2783. var index = ++this.requestIndex;
  2784. return $.proxy(function( content ) {
  2785. if ( index === this.requestIndex ) {
  2786. this.__response( content );
  2787. }
  2788. this.pending--;
  2789. if ( !this.pending ) {
  2790. this.element.removeClass( "ui-autocomplete-loading" );
  2791. }
  2792. }, this );
  2793. },
  2794. __response: function( content ) {
  2795. if ( content ) {
  2796. content = this._normalize( content );
  2797. }
  2798. this._trigger( "response", null, { content: content } );
  2799. if ( !this.options.disabled && content && content.length && !this.cancelSearch ) {
  2800. this._suggest( content );
  2801. this._trigger( "open" );
  2802. } else {
  2803. // use ._close() instead of .close() so we don't cancel future searches
  2804. this._close();
  2805. }
  2806. },
  2807. close: function( event ) {
  2808. this.cancelSearch = true;
  2809. this._close( event );
  2810. },
  2811. _close: function( event ) {
  2812. if ( this.menu.element.is( ":visible" ) ) {
  2813. this.menu.element.hide();
  2814. this.menu.blur();
  2815. this.isNewMenu = true;
  2816. this._trigger( "close", event );
  2817. }
  2818. },
  2819. _change: function( event ) {
  2820. if ( this.previous !== this._value() ) {
  2821. this._trigger( "change", event, { item: this.selectedItem } );
  2822. }
  2823. },
  2824. _normalize: function( items ) {
  2825. // assume all items have the right format when the first item is complete
  2826. if ( items.length && items[ 0 ].label && items[ 0 ].value ) {
  2827. return items;
  2828. }
  2829. return $.map( items, function( item ) {
  2830. if ( typeof item === "string" ) {
  2831. return {
  2832. label: item,
  2833. value: item
  2834. };
  2835. }
  2836. return $.extend( {}, item, {
  2837. label: item.label || item.value,
  2838. value: item.value || item.label
  2839. });
  2840. });
  2841. },
  2842. _suggest: function( items ) {
  2843. var ul = this.menu.element.empty();
  2844. this._renderMenu( ul, items );
  2845. this.isNewMenu = true;
  2846. this.menu.refresh();
  2847. // size and position menu
  2848. ul.show();
  2849. this._resizeMenu();
  2850. ul.position( $.extend({
  2851. of: this.element
  2852. }, this.options.position ) );
  2853. if ( this.options.autoFocus ) {
  2854. this.menu.next();
  2855. }
  2856. },
  2857. _resizeMenu: function() {
  2858. var ul = this.menu.element;
  2859. ul.outerWidth( Math.max(
  2860. // Firefox wraps long text (possibly a rounding bug)
  2861. // so we add 1px to avoid the wrapping (#7513)
  2862. ul.width( "" ).outerWidth() + 1,
  2863. this.element.outerWidth()
  2864. ) );
  2865. },
  2866. _renderMenu: function( ul, items ) {
  2867. var that = this;
  2868. $.each( items, function( index, item ) {
  2869. that._renderItemData( ul, item );
  2870. });
  2871. },
  2872. _renderItemData: function( ul, item ) {
  2873. return this._renderItem( ul, item ).data( "ui-autocomplete-item", item );
  2874. },
  2875. _renderItem: function( ul, item ) {
  2876. return $( "<li>" ).text( item.label ).appendTo( ul );
  2877. },
  2878. _move: function( direction, event ) {
  2879. if ( !this.menu.element.is( ":visible" ) ) {
  2880. this.search( null, event );
  2881. return;
  2882. }
  2883. if ( this.menu.isFirstItem() && /^previous/.test( direction ) ||
  2884. this.menu.isLastItem() && /^next/.test( direction ) ) {
  2885. if ( !this.isMultiLine ) {
  2886. this._value( this.term );
  2887. }
  2888. this.menu.blur();
  2889. return;
  2890. }
  2891. this.menu[ direction ]( event );
  2892. },
  2893. widget: function() {
  2894. return this.menu.element;
  2895. },
  2896. _value: function() {
  2897. return this.valueMethod.apply( this.element, arguments );
  2898. },
  2899. _keyEvent: function( keyEvent, event ) {
  2900. if ( !this.isMultiLine || this.menu.element.is( ":visible" ) ) {
  2901. this._move( keyEvent, event );
  2902. // prevents moving cursor to beginning/end of the text field in some browsers
  2903. event.preventDefault();
  2904. }
  2905. }
  2906. });
  2907. $.extend( $.ui.autocomplete, {
  2908. escapeRegex: function( value ) {
  2909. return value.replace( /[\-\[\]{}()*+?.,\\\^$|#\s]/g, "\\$&" );
  2910. },
  2911. filter: function( array, term ) {
  2912. var matcher = new RegExp( $.ui.autocomplete.escapeRegex( term ), "i" );
  2913. return $.grep( array, function( value ) {
  2914. return matcher.test( value.label || value.value || value );
  2915. });
  2916. }
  2917. });
  2918. // live region extension, adding a `messages` option
  2919. // NOTE: This is an experimental API. We are still investigating
  2920. // a full solution for string manipulation and internationalization.
  2921. $.widget( "ui.autocomplete", $.ui.autocomplete, {
  2922. options: {
  2923. messages: {
  2924. noResults: "No search results.",
  2925. results: function( amount ) {
  2926. return amount + ( amount > 1 ? " results are" : " result is" ) +
  2927. " available, use up and down arrow keys to navigate.";
  2928. }
  2929. }
  2930. },
  2931. __response: function( content ) {
  2932. var message;
  2933. this._superApply( arguments );
  2934. if ( this.options.disabled || this.cancelSearch ) {
  2935. return;
  2936. }
  2937. if ( content && content.length ) {
  2938. message = this.options.messages.results( content.length );
  2939. } else {
  2940. message = this.options.messages.noResults;
  2941. }
  2942. this.liveRegion.children().hide();
  2943. $( "<div>" ).text( message ).appendTo( this.liveRegion );
  2944. }
  2945. });
  2946. var autocomplete = $.ui.autocomplete;
  2947. /*!
  2948. * jQuery UI Button 1.11.3
  2949. * http://jqueryui.com
  2950. *
  2951. * Copyright jQuery Foundation and other contributors
  2952. * Released under the MIT license.
  2953. * http://jquery.org/license
  2954. *
  2955. * http://api.jqueryui.com/button/
  2956. */
  2957. var lastActive,
  2958. baseClasses = "ui-button ui-widget ui-state-default ui-corner-all",
  2959. typeClasses = "ui-button-icons-only ui-button-icon-only ui-button-text-icons ui-button-text-icon-primary ui-button-text-icon-secondary ui-button-text-only",
  2960. formResetHandler = function() {
  2961. var form = $( this );
  2962. setTimeout(function() {
  2963. form.find( ":ui-button" ).button( "refresh" );
  2964. }, 1 );
  2965. },
  2966. radioGroup = function( radio ) {
  2967. var name = radio.name,
  2968. form = radio.form,
  2969. radios = $( [] );
  2970. if ( name ) {
  2971. name = name.replace( /'/g, "\\'" );
  2972. if ( form ) {
  2973. radios = $( form ).find( "[name='" + name + "'][type=radio]" );
  2974. } else {
  2975. radios = $( "[name='" + name + "'][type=radio]", radio.ownerDocument )
  2976. .filter(function() {
  2977. return !this.form;
  2978. });
  2979. }
  2980. }
  2981. return radios;
  2982. };
  2983. $.widget( "ui.button", {
  2984. version: "1.11.3",
  2985. defaultElement: "<button>",
  2986. options: {
  2987. disabled: null,
  2988. text: true,
  2989. label: null,
  2990. icons: {
  2991. primary: null,
  2992. secondary: null
  2993. }
  2994. },
  2995. _create: function() {
  2996. this.element.closest( "form" )
  2997. .unbind( "reset" + this.eventNamespace )
  2998. .bind( "reset" + this.eventNamespace, formResetHandler );
  2999. if ( typeof this.options.disabled !== "boolean" ) {
  3000. this.options.disabled = !!this.element.prop( "disabled" );
  3001. } else {
  3002. this.element.prop( "disabled", this.options.disabled );
  3003. }
  3004. this._determineButtonType();
  3005. this.hasTitle = !!this.buttonElement.attr( "title" );
  3006. var that = this,
  3007. options = this.options,
  3008. toggleButton = this.type === "checkbox" || this.type === "radio",
  3009. activeClass = !toggleButton ? "ui-state-active" : "";
  3010. if ( options.label === null ) {
  3011. options.label = (this.type === "input" ? this.buttonElement.val() : this.buttonElement.html());
  3012. }
  3013. this._hoverable( this.buttonElement );
  3014. this.buttonElement
  3015. .addClass( baseClasses )
  3016. .attr( "role", "button" )
  3017. .bind( "mouseenter" + this.eventNamespace, function() {
  3018. if ( options.disabled ) {
  3019. return;
  3020. }
  3021. if ( this === lastActive ) {
  3022. $( this ).addClass( "ui-state-active" );
  3023. }
  3024. })
  3025. .bind( "mouseleave" + this.eventNamespace, function() {
  3026. if ( options.disabled ) {
  3027. return;
  3028. }
  3029. $( this ).removeClass( activeClass );
  3030. })
  3031. .bind( "click" + this.eventNamespace, function( event ) {
  3032. if ( options.disabled ) {
  3033. event.preventDefault();
  3034. event.stopImmediatePropagation();
  3035. }
  3036. });
  3037. // Can't use _focusable() because the element that receives focus
  3038. // and the element that gets the ui-state-focus class are different
  3039. this._on({
  3040. focus: function() {
  3041. this.buttonElement.addClass( "ui-state-focus" );
  3042. },
  3043. blur: function() {
  3044. this.buttonElement.removeClass( "ui-state-focus" );
  3045. }
  3046. });
  3047. if ( toggleButton ) {
  3048. this.element.bind( "change" + this.eventNamespace, function() {
  3049. that.refresh();
  3050. });
  3051. }
  3052. if ( this.type === "checkbox" ) {
  3053. this.buttonElement.bind( "click" + this.eventNamespace, function() {
  3054. if ( options.disabled ) {
  3055. return false;
  3056. }
  3057. });
  3058. } else if ( this.type === "radio" ) {
  3059. this.buttonElement.bind( "click" + this.eventNamespace, function() {
  3060. if ( options.disabled ) {
  3061. return false;
  3062. }
  3063. $( this ).addClass( "ui-state-active" );
  3064. that.buttonElement.attr( "aria-pressed", "true" );
  3065. var radio = that.element[ 0 ];
  3066. radioGroup( radio )
  3067. .not( radio )
  3068. .map(function() {
  3069. return $( this ).button( "widget" )[ 0 ];
  3070. })
  3071. .removeClass( "ui-state-active" )
  3072. .attr( "aria-pressed", "false" );
  3073. });
  3074. } else {
  3075. this.buttonElement
  3076. .bind( "mousedown" + this.eventNamespace, function() {
  3077. if ( options.disabled ) {
  3078. return false;
  3079. }
  3080. $( this ).addClass( "ui-state-active" );
  3081. lastActive = this;
  3082. that.document.one( "mouseup", function() {
  3083. lastActive = null;
  3084. });
  3085. })
  3086. .bind( "mouseup" + this.eventNamespace, function() {
  3087. if ( options.disabled ) {
  3088. return false;
  3089. }
  3090. $( this ).removeClass( "ui-state-active" );
  3091. })
  3092. .bind( "keydown" + this.eventNamespace, function(event) {
  3093. if ( options.disabled ) {
  3094. return false;
  3095. }
  3096. if ( event.keyCode === $.ui.keyCode.SPACE || event.keyCode === $.ui.keyCode.ENTER ) {
  3097. $( this ).addClass( "ui-state-active" );
  3098. }
  3099. })
  3100. // see #8559, we bind to blur here in case the button element loses
  3101. // focus between keydown and keyup, it would be left in an "active" state
  3102. .bind( "keyup" + this.eventNamespace + " blur" + this.eventNamespace, function() {
  3103. $( this ).removeClass( "ui-state-active" );
  3104. });
  3105. if ( this.buttonElement.is("a") ) {
  3106. this.buttonElement.keyup(function(event) {
  3107. if ( event.keyCode === $.ui.keyCode.SPACE ) {
  3108. // TODO pass through original event correctly (just as 2nd argument doesn't work)
  3109. $( this ).click();
  3110. }
  3111. });
  3112. }
  3113. }
  3114. this._setOption( "disabled", options.disabled );
  3115. this._resetButton();
  3116. },
  3117. _determineButtonType: function() {
  3118. var ancestor, labelSelector, checked;
  3119. if ( this.element.is("[type=checkbox]") ) {
  3120. this.type = "checkbox";
  3121. } else if ( this.element.is("[type=radio]") ) {
  3122. this.type = "radio";
  3123. } else if ( this.element.is("input") ) {
  3124. this.type = "input";
  3125. } else {
  3126. this.type = "button";
  3127. }
  3128. if ( this.type === "checkbox" || this.type === "radio" ) {
  3129. // we don't search against the document in case the element
  3130. // is disconnected from the DOM
  3131. ancestor = this.element.parents().last();
  3132. labelSelector = "label[for='" + this.element.attr("id") + "']";
  3133. this.buttonElement = ancestor.find( labelSelector );
  3134. if ( !this.buttonElement.length ) {
  3135. ancestor = ancestor.length ? ancestor.siblings() : this.element.siblings();
  3136. this.buttonElement = ancestor.filter( labelSelector );
  3137. if ( !this.buttonElement.length ) {
  3138. this.buttonElement = ancestor.find( labelSelector );
  3139. }
  3140. }
  3141. this.element.addClass( "ui-helper-hidden-accessible" );
  3142. checked = this.element.is( ":checked" );
  3143. if ( checked ) {
  3144. this.buttonElement.addClass( "ui-state-active" );
  3145. }
  3146. this.buttonElement.prop( "aria-pressed", checked );
  3147. } else {
  3148. this.buttonElement = this.element;
  3149. }
  3150. },
  3151. widget: function() {
  3152. return this.buttonElement;
  3153. },
  3154. _destroy: function() {
  3155. this.element
  3156. .removeClass( "ui-helper-hidden-accessible" );
  3157. this.buttonElement
  3158. .removeClass( baseClasses + " ui-state-active " + typeClasses )
  3159. .removeAttr( "role" )
  3160. .removeAttr( "aria-pressed" )
  3161. .html( this.buttonElement.find(".ui-button-text").html() );
  3162. if ( !this.hasTitle ) {
  3163. this.buttonElement.removeAttr( "title" );
  3164. }
  3165. },
  3166. _setOption: function( key, value ) {
  3167. this._super( key, value );
  3168. if ( key === "disabled" ) {
  3169. this.widget().toggleClass( "ui-state-disabled", !!value );
  3170. this.element.prop( "disabled", !!value );
  3171. if ( value ) {
  3172. if ( this.type === "checkbox" || this.type === "radio" ) {
  3173. this.buttonElement.removeClass( "ui-state-focus" );
  3174. } else {
  3175. this.buttonElement.removeClass( "ui-state-focus ui-state-active" );
  3176. }
  3177. }
  3178. return;
  3179. }
  3180. this._resetButton();
  3181. },
  3182. refresh: function() {
  3183. //See #8237 & #8828
  3184. var isDisabled = this.element.is( "input, button" ) ? this.element.is( ":disabled" ) : this.element.hasClass( "ui-button-disabled" );
  3185. if ( isDisabled !== this.options.disabled ) {
  3186. this._setOption( "disabled", isDisabled );
  3187. }
  3188. if ( this.type === "radio" ) {
  3189. radioGroup( this.element[0] ).each(function() {
  3190. if ( $( this ).is( ":checked" ) ) {
  3191. $( this ).button( "widget" )
  3192. .addClass( "ui-state-active" )
  3193. .attr( "aria-pressed", "true" );
  3194. } else {
  3195. $( this ).button( "widget" )
  3196. .removeClass( "ui-state-active" )
  3197. .attr( "aria-pressed", "false" );
  3198. }
  3199. });
  3200. } else if ( this.type === "checkbox" ) {
  3201. if ( this.element.is( ":checked" ) ) {
  3202. this.buttonElement
  3203. .addClass( "ui-state-active" )
  3204. .attr( "aria-pressed", "true" );
  3205. } else {
  3206. this.buttonElement
  3207. .removeClass( "ui-state-active" )
  3208. .attr( "aria-pressed", "false" );
  3209. }
  3210. }
  3211. },
  3212. _resetButton: function() {
  3213. if ( this.type === "input" ) {
  3214. if ( this.options.label ) {
  3215. this.element.val( this.options.label );
  3216. }
  3217. return;
  3218. }
  3219. var buttonElement = this.buttonElement.removeClass( typeClasses ),
  3220. buttonText = $( "<span></span>", this.document[0] )
  3221. .addClass( "ui-button-text" )
  3222. .html( this.options.label )
  3223. .appendTo( buttonElement.empty() )
  3224. .text(),
  3225. icons = this.options.icons,
  3226. multipleIcons = icons.primary && icons.secondary,
  3227. buttonClasses = [];
  3228. if ( icons.primary || icons.secondary ) {
  3229. if ( this.options.text ) {
  3230. buttonClasses.push( "ui-button-text-icon" + ( multipleIcons ? "s" : ( icons.primary ? "-primary" : "-secondary" ) ) );
  3231. }
  3232. if ( icons.primary ) {
  3233. buttonElement.prepend( "<span class='ui-button-icon-primary ui-icon " + icons.primary + "'></span>" );
  3234. }
  3235. if ( icons.secondary ) {
  3236. buttonElement.append( "<span class='ui-button-icon-secondary ui-icon " + icons.secondary + "'></span>" );
  3237. }
  3238. if ( !this.options.text ) {
  3239. buttonClasses.push( multipleIcons ? "ui-button-icons-only" : "ui-button-icon-only" );
  3240. if ( !this.hasTitle ) {
  3241. buttonElement.attr( "title", $.trim( buttonText ) );
  3242. }
  3243. }
  3244. } else {
  3245. buttonClasses.push( "ui-button-text-only" );
  3246. }
  3247. buttonElement.addClass( buttonClasses.join( " " ) );
  3248. }
  3249. });
  3250. $.widget( "ui.buttonset", {
  3251. version: "1.11.3",
  3252. options: {
  3253. items: "button, input[type=button], input[type=submit], input[type=reset], input[type=checkbox], input[type=radio], a, :data(ui-button)"
  3254. },
  3255. _create: function() {
  3256. this.element.addClass( "ui-buttonset" );
  3257. },
  3258. _init: function() {
  3259. this.refresh();
  3260. },
  3261. _setOption: function( key, value ) {
  3262. if ( key === "disabled" ) {
  3263. this.buttons.button( "option", key, value );
  3264. }
  3265. this._super( key, value );
  3266. },
  3267. refresh: function() {
  3268. var rtl = this.element.css( "direction" ) === "rtl",
  3269. allButtons = this.element.find( this.options.items ),
  3270. existingButtons = allButtons.filter( ":ui-button" );
  3271. // Initialize new buttons
  3272. allButtons.not( ":ui-button" ).button();
  3273. // Refresh existing buttons
  3274. existingButtons.button( "refresh" );
  3275. this.buttons = allButtons
  3276. .map(function() {
  3277. return $( this ).button( "widget" )[ 0 ];
  3278. })
  3279. .removeClass( "ui-corner-all ui-corner-left ui-corner-right" )
  3280. .filter( ":first" )
  3281. .addClass( rtl ? "ui-corner-right" : "ui-corner-left" )
  3282. .end()
  3283. .filter( ":last" )
  3284. .addClass( rtl ? "ui-corner-left" : "ui-corner-right" )
  3285. .end()
  3286. .end();
  3287. },
  3288. _destroy: function() {
  3289. this.element.removeClass( "ui-buttonset" );
  3290. this.buttons
  3291. .map(function() {
  3292. return $( this ).button( "widget" )[ 0 ];
  3293. })
  3294. .removeClass( "ui-corner-left ui-corner-right" )
  3295. .end()
  3296. .button( "destroy" );
  3297. }
  3298. });
  3299. var button = $.ui.button;
  3300. /*!
  3301. * jQuery UI Datepicker 1.11.3
  3302. * http://jqueryui.com
  3303. *
  3304. * Copyright jQuery Foundation and other contributors
  3305. * Released under the MIT license.
  3306. * http://jquery.org/license
  3307. *
  3308. * http://api.jqueryui.com/datepicker/
  3309. */
  3310. $.extend($.ui, { datepicker: { version: "1.11.3" } });
  3311. var datepicker_instActive;
  3312. function datepicker_getZindex( elem ) {
  3313. var position, value;
  3314. while ( elem.length && elem[ 0 ] !== document ) {
  3315. // Ignore z-index if position is set to a value where z-index is ignored by the browser
  3316. // This makes behavior of this function consistent across browsers
  3317. // WebKit always returns auto if the element is positioned
  3318. position = elem.css( "position" );
  3319. if ( position === "absolute" || position === "relative" || position === "fixed" ) {
  3320. // IE returns 0 when zIndex is not specified
  3321. // other browsers return a string
  3322. // we ignore the case of nested elements with an explicit value of 0
  3323. // <div style="z-index: -10;"><div style="z-index: 0;"></div></div>
  3324. value = parseInt( elem.css( "zIndex" ), 10 );
  3325. if ( !isNaN( value ) && value !== 0 ) {
  3326. return value;
  3327. }
  3328. }
  3329. elem = elem.parent();
  3330. }
  3331. return 0;
  3332. }
  3333. /* Date picker manager.
  3334. Use the singleton instance of this class, $.datepicker, to interact with the date picker.
  3335. Settings for (groups of) date pickers are maintained in an instance object,
  3336. allowing multiple different settings on the same page. */
  3337. function Datepicker() {
  3338. this._curInst = null; // The current instance in use
  3339. this._keyEvent = false; // If the last event was a key event
  3340. this._disabledInputs = []; // List of date picker inputs that have been disabled
  3341. this._datepickerShowing = false; // True if the popup picker is showing , false if not
  3342. this._inDialog = false; // True if showing within a "dialog", false if not
  3343. this._mainDivId = "ui-datepicker-div"; // The ID of the main datepicker division
  3344. this._inlineClass = "ui-datepicker-inline"; // The name of the inline marker class
  3345. this._appendClass = "ui-datepicker-append"; // The name of the append marker class
  3346. this._triggerClass = "ui-datepicker-trigger"; // The name of the trigger marker class
  3347. this._dialogClass = "ui-datepicker-dialog"; // The name of the dialog marker class
  3348. this._disableClass = "ui-datepicker-disabled"; // The name of the disabled covering marker class
  3349. this._unselectableClass = "ui-datepicker-unselectable"; // The name of the unselectable cell marker class
  3350. this._currentClass = "ui-datepicker-current-day"; // The name of the current day marker class
  3351. this._dayOverClass = "ui-datepicker-days-cell-over"; // The name of the day hover marker class
  3352. this.regional = []; // Available regional settings, indexed by language code
  3353. this.regional[""] = { // Default regional settings
  3354. closeText: "Done", // Display text for close link
  3355. prevText: "Prev", // Display text for previous month link
  3356. nextText: "Next", // Display text for next month link
  3357. currentText: "Today", // Display text for current month link
  3358. monthNames: ["January","February","March","April","May","June",
  3359. "July","August","September","October","November","December"], // Names of months for drop-down and formatting
  3360. monthNamesShort: ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"], // For formatting
  3361. dayNames: ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"], // For formatting
  3362. dayNamesShort: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"], // For formatting
  3363. dayNamesMin: ["Su","Mo","Tu","We","Th","Fr","Sa"], // Column headings for days starting at Sunday
  3364. weekHeader: "Wk", // Column header for week of the year
  3365. dateFormat: "mm/dd/yy", // See format options on parseDate
  3366. firstDay: 0, // The first day of the week, Sun = 0, Mon = 1, ...
  3367. isRTL: false, // True if right-to-left language, false if left-to-right
  3368. showMonthAfterYear: false, // True if the year select precedes month, false for month then year
  3369. yearSuffix: "" // Additional text to append to the year in the month headers
  3370. };
  3371. this._defaults = { // Global defaults for all the date picker instances
  3372. showOn: "focus", // "focus" for popup on focus,
  3373. // "button" for trigger button, or "both" for either
  3374. showAnim: "fadeIn", // Name of jQuery animation for popup
  3375. showOptions: {}, // Options for enhanced animations
  3376. defaultDate: null, // Used when field is blank: actual date,
  3377. // +/-number for offset from today, null for today
  3378. appendText: "", // Display text following the input box, e.g. showing the format
  3379. buttonText: "...", // Text for trigger button
  3380. buttonImage: "", // URL for trigger button image
  3381. buttonImageOnly: false, // True if the image appears alone, false if it appears on a button
  3382. hideIfNoPrevNext: false, // True to hide next/previous month links
  3383. // if not applicable, false to just disable them
  3384. navigationAsDateFormat: false, // True if date formatting applied to prev/today/next links
  3385. gotoCurrent: false, // True if today link goes back to current selection instead
  3386. changeMonth: false, // True if month can be selected directly, false if only prev/next
  3387. changeYear: false, // True if year can be selected directly, false if only prev/next
  3388. yearRange: "c-10:c+10", // Range of years to display in drop-down,
  3389. // either relative to today's year (-nn:+nn), relative to currently displayed year
  3390. // (c-nn:c+nn), absolute (nnnn:nnnn), or a combination of the above (nnnn:-n)
  3391. showOtherMonths: false, // True to show dates in other months, false to leave blank
  3392. selectOtherMonths: false, // True to allow selection of dates in other months, false for unselectable
  3393. showWeek: false, // True to show week of the year, false to not show it
  3394. calculateWeek: this.iso8601Week, // How to calculate the week of the year,
  3395. // takes a Date and returns the number of the week for it
  3396. shortYearCutoff: "+10", // Short year values < this are in the current century,
  3397. // > this are in the previous century,
  3398. // string value starting with "+" for current year + value
  3399. minDate: null, // The earliest selectable date, or null for no limit
  3400. maxDate: null, // The latest selectable date, or null for no limit
  3401. duration: "fast", // Duration of display/closure
  3402. beforeShowDay: null, // Function that takes a date and returns an array with
  3403. // [0] = true if selectable, false if not, [1] = custom CSS class name(s) or "",
  3404. // [2] = cell title (optional), e.g. $.datepicker.noWeekends
  3405. beforeShow: null, // Function that takes an input field and
  3406. // returns a set of custom settings for the date picker
  3407. onSelect: null, // Define a callback function when a date is selected
  3408. onChangeMonthYear: null, // Define a callback function when the month or year is changed
  3409. onClose: null, // Define a callback function when the datepicker is closed
  3410. numberOfMonths: 1, // Number of months to show at a time
  3411. showCurrentAtPos: 0, // The position in multipe months at which to show the current month (starting at 0)
  3412. stepMonths: 1, // Number of months to step back/forward
  3413. stepBigMonths: 12, // Number of months to step back/forward for the big links
  3414. altField: "", // Selector for an alternate field to store selected dates into
  3415. altFormat: "", // The date format to use for the alternate field
  3416. constrainInput: true, // The input is constrained by the current date format
  3417. showButtonPanel: false, // True to show button panel, false to not show it
  3418. autoSize: false, // True to size the input for the date format, false to leave as is
  3419. disabled: false // The initial disabled state
  3420. };
  3421. $.extend(this._defaults, this.regional[""]);
  3422. this.regional.en = $.extend( true, {}, this.regional[ "" ]);
  3423. this.regional[ "en-US" ] = $.extend( true, {}, this.regional.en );
  3424. this.dpDiv = datepicker_bindHover($("<div id='" + this._mainDivId + "' class='ui-datepicker ui-widget ui-widget-content ui-helper-clearfix ui-corner-all'></div>"));
  3425. }
  3426. $.extend(Datepicker.prototype, {
  3427. /* Class name added to elements to indicate already configured with a date picker. */
  3428. markerClassName: "hasDatepicker",
  3429. //Keep track of the maximum number of rows displayed (see #7043)
  3430. maxRows: 4,
  3431. // TODO rename to "widget" when switching to widget factory
  3432. _widgetDatepicker: function() {
  3433. return this.dpDiv;
  3434. },
  3435. /* Override the default settings for all instances of the date picker.
  3436. * @param settings object - the new settings to use as defaults (anonymous object)
  3437. * @return the manager object
  3438. */
  3439. setDefaults: function(settings) {
  3440. datepicker_extendRemove(this._defaults, settings || {});
  3441. return this;
  3442. },
  3443. /* Attach the date picker to a jQuery selection.
  3444. * @param target element - the target input field or division or span
  3445. * @param settings object - the new settings to use for this date picker instance (anonymous)
  3446. */
  3447. _attachDatepicker: function(target, settings) {
  3448. var nodeName, inline, inst;
  3449. nodeName = target.nodeName.toLowerCase();
  3450. inline = (nodeName === "div" || nodeName === "span");
  3451. if (!target.id) {
  3452. this.uuid += 1;
  3453. target.id = "dp" + this.uuid;
  3454. }
  3455. inst = this._newInst($(target), inline);
  3456. inst.settings = $.extend({}, settings || {});
  3457. if (nodeName === "input") {
  3458. this._connectDatepicker(target, inst);
  3459. } else if (inline) {
  3460. this._inlineDatepicker(target, inst);
  3461. }
  3462. },
  3463. /* Create a new instance object. */
  3464. _newInst: function(target, inline) {
  3465. var id = target[0].id.replace(/([^A-Za-z0-9_\-])/g, "\\\\$1"); // escape jQuery meta chars
  3466. return {id: id, input: target, // associated target
  3467. selectedDay: 0, selectedMonth: 0, selectedYear: 0, // current selection
  3468. drawMonth: 0, drawYear: 0, // month being drawn
  3469. inline: inline, // is datepicker inline or not
  3470. dpDiv: (!inline ? this.dpDiv : // presentation div
  3471. datepicker_bindHover($("<div class='" + this._inlineClass + " ui-datepicker ui-widget ui-widget-content ui-helper-clearfix ui-corner-all'></div>")))};
  3472. },
  3473. /* Attach the date picker to an input field. */
  3474. _connectDatepicker: function(target, inst) {
  3475. var input = $(target);
  3476. inst.append = $([]);
  3477. inst.trigger = $([]);
  3478. if (input.hasClass(this.markerClassName)) {
  3479. return;
  3480. }
  3481. this._attachments(input, inst);
  3482. input.addClass(this.markerClassName).keydown(this._doKeyDown).
  3483. keypress(this._doKeyPress).keyup(this._doKeyUp);
  3484. this._autoSize(inst);
  3485. $.data(target, "datepicker", inst);
  3486. //If disabled option is true, disable the datepicker once it has been attached to the input (see ticket #5665)
  3487. if( inst.settings.disabled ) {
  3488. this._disableDatepicker( target );
  3489. }
  3490. },
  3491. /* Make attachments based on settings. */
  3492. _attachments: function(input, inst) {
  3493. var showOn, buttonText, buttonImage,
  3494. appendText = this._get(inst, "appendText"),
  3495. isRTL = this._get(inst, "isRTL");
  3496. if (inst.append) {
  3497. inst.append.remove();
  3498. }
  3499. if (appendText) {
  3500. inst.append = $("<span class='" + this._appendClass + "'>" + appendText + "</span>");
  3501. input[isRTL ? "before" : "after"](inst.append);
  3502. }
  3503. input.unbind("focus", this._showDatepicker);
  3504. if (inst.trigger) {
  3505. inst.trigger.remove();
  3506. }
  3507. showOn = this._get(inst, "showOn");
  3508. if (showOn === "focus" || showOn === "both") { // pop-up date picker when in the marked field
  3509. input.focus(this._showDatepicker);
  3510. }
  3511. if (showOn === "button" || showOn === "both") { // pop-up date picker when button clicked
  3512. buttonText = this._get(inst, "buttonText");
  3513. buttonImage = this._get(inst, "buttonImage");
  3514. inst.trigger = $(this._get(inst, "buttonImageOnly") ?
  3515. $("<img/>").addClass(this._triggerClass).
  3516. attr({ src: buttonImage, alt: buttonText, title: buttonText }) :
  3517. $("<button type='button'></button>").addClass(this._triggerClass).
  3518. html(!buttonImage ? buttonText : $("<img/>").attr(
  3519. { src:buttonImage, alt:buttonText, title:buttonText })));
  3520. input[isRTL ? "before" : "after"](inst.trigger);
  3521. inst.trigger.click(function() {
  3522. if ($.datepicker._datepickerShowing && $.datepicker._lastInput === input[0]) {
  3523. $.datepicker._hideDatepicker();
  3524. } else if ($.datepicker._datepickerShowing && $.datepicker._lastInput !== input[0]) {
  3525. $.datepicker._hideDatepicker();
  3526. $.datepicker._showDatepicker(input[0]);
  3527. } else {
  3528. $.datepicker._showDatepicker(input[0]);
  3529. }
  3530. return false;
  3531. });
  3532. }
  3533. },
  3534. /* Apply the maximum length for the date format. */
  3535. _autoSize: function(inst) {
  3536. if (this._get(inst, "autoSize") && !inst.inline) {
  3537. var findMax, max, maxI, i,
  3538. date = new Date(2009, 12 - 1, 20), // Ensure double digits
  3539. dateFormat = this._get(inst, "dateFormat");
  3540. if (dateFormat.match(/[DM]/)) {
  3541. findMax = function(names) {
  3542. max = 0;
  3543. maxI = 0;
  3544. for (i = 0; i < names.length; i++) {
  3545. if (names[i].length > max) {
  3546. max = names[i].length;
  3547. maxI = i;
  3548. }
  3549. }
  3550. return maxI;
  3551. };
  3552. date.setMonth(findMax(this._get(inst, (dateFormat.match(/MM/) ?
  3553. "monthNames" : "monthNamesShort"))));
  3554. date.setDate(findMax(this._get(inst, (dateFormat.match(/DD/) ?
  3555. "dayNames" : "dayNamesShort"))) + 20 - date.getDay());
  3556. }
  3557. inst.input.attr("size", this._formatDate(inst, date).length);
  3558. }
  3559. },
  3560. /* Attach an inline date picker to a div. */
  3561. _inlineDatepicker: function(target, inst) {
  3562. var divSpan = $(target);
  3563. if (divSpan.hasClass(this.markerClassName)) {
  3564. return;
  3565. }
  3566. divSpan.addClass(this.markerClassName).append(inst.dpDiv);
  3567. $.data(target, "datepicker", inst);
  3568. this._setDate(inst, this._getDefaultDate(inst), true);
  3569. this._updateDatepicker(inst);
  3570. this._updateAlternate(inst);
  3571. //If disabled option is true, disable the datepicker before showing it (see ticket #5665)
  3572. if( inst.settings.disabled ) {
  3573. this._disableDatepicker( target );
  3574. }
  3575. // Set display:block in place of inst.dpDiv.show() which won't work on disconnected elements
  3576. // http://bugs.jqueryui.com/ticket/7552 - A Datepicker created on a detached div has zero height
  3577. inst.dpDiv.css( "display", "block" );
  3578. },
  3579. /* Pop-up the date picker in a "dialog" box.
  3580. * @param input element - ignored
  3581. * @param date string or Date - the initial date to display
  3582. * @param onSelect function - the function to call when a date is selected
  3583. * @param settings object - update the dialog date picker instance's settings (anonymous object)
  3584. * @param pos int[2] - coordinates for the dialog's position within the screen or
  3585. * event - with x/y coordinates or
  3586. * leave empty for default (screen centre)
  3587. * @return the manager object
  3588. */
  3589. _dialogDatepicker: function(input, date, onSelect, settings, pos) {
  3590. var id, browserWidth, browserHeight, scrollX, scrollY,
  3591. inst = this._dialogInst; // internal instance
  3592. if (!inst) {
  3593. this.uuid += 1;
  3594. id = "dp" + this.uuid;
  3595. this._dialogInput = $("<input type='text' id='" + id +
  3596. "' style='position: absolute; top: -100px; width: 0px;'/>");
  3597. this._dialogInput.keydown(this._doKeyDown);
  3598. $("body").append(this._dialogInput);
  3599. inst = this._dialogInst = this._newInst(this._dialogInput, false);
  3600. inst.settings = {};
  3601. $.data(this._dialogInput[0], "datepicker", inst);
  3602. }
  3603. datepicker_extendRemove(inst.settings, settings || {});
  3604. date = (date && date.constructor === Date ? this._formatDate(inst, date) : date);
  3605. this._dialogInput.val(date);
  3606. this._pos = (pos ? (pos.length ? pos : [pos.pageX, pos.pageY]) : null);
  3607. if (!this._pos) {
  3608. browserWidth = document.documentElement.clientWidth;
  3609. browserHeight = document.documentElement.clientHeight;
  3610. scrollX = document.documentElement.scrollLeft || document.body.scrollLeft;
  3611. scrollY = document.documentElement.scrollTop || document.body.scrollTop;
  3612. this._pos = // should use actual width/height below
  3613. [(browserWidth / 2) - 100 + scrollX, (browserHeight / 2) - 150 + scrollY];
  3614. }
  3615. // move input on screen for focus, but hidden behind dialog
  3616. this._dialogInput.css("left", (this._pos[0] + 20) + "px").css("top", this._pos[1] + "px");
  3617. inst.settings.onSelect = onSelect;
  3618. this._inDialog = true;
  3619. this.dpDiv.addClass(this._dialogClass);
  3620. this._showDatepicker(this._dialogInput[0]);
  3621. if ($.blockUI) {
  3622. $.blockUI(this.dpDiv);
  3623. }
  3624. $.data(this._dialogInput[0], "datepicker", inst);
  3625. return this;
  3626. },
  3627. /* Detach a datepicker from its control.
  3628. * @param target element - the target input field or division or span
  3629. */
  3630. _destroyDatepicker: function(target) {
  3631. var nodeName,
  3632. $target = $(target),
  3633. inst = $.data(target, "datepicker");
  3634. if (!$target.hasClass(this.markerClassName)) {
  3635. return;
  3636. }
  3637. nodeName = target.nodeName.toLowerCase();
  3638. $.removeData(target, "datepicker");
  3639. if (nodeName === "input") {
  3640. inst.append.remove();
  3641. inst.trigger.remove();
  3642. $target.removeClass(this.markerClassName).
  3643. unbind("focus", this._showDatepicker).
  3644. unbind("keydown", this._doKeyDown).
  3645. unbind("keypress", this._doKeyPress).
  3646. unbind("keyup", this._doKeyUp);
  3647. } else if (nodeName === "div" || nodeName === "span") {
  3648. $target.removeClass(this.markerClassName).empty();
  3649. }
  3650. if ( datepicker_instActive === inst ) {
  3651. datepicker_instActive = null;
  3652. }
  3653. },
  3654. /* Enable the date picker to a jQuery selection.
  3655. * @param target element - the target input field or division or span
  3656. */
  3657. _enableDatepicker: function(target) {
  3658. var nodeName, inline,
  3659. $target = $(target),
  3660. inst = $.data(target, "datepicker");
  3661. if (!$target.hasClass(this.markerClassName)) {
  3662. return;
  3663. }
  3664. nodeName = target.nodeName.toLowerCase();
  3665. if (nodeName === "input") {
  3666. target.disabled = false;
  3667. inst.trigger.filter("button").
  3668. each(function() { this.disabled = false; }).end().
  3669. filter("img").css({opacity: "1.0", cursor: ""});
  3670. } else if (nodeName === "div" || nodeName === "span") {
  3671. inline = $target.children("." + this._inlineClass);
  3672. inline.children().removeClass("ui-state-disabled");
  3673. inline.find("select.ui-datepicker-month, select.ui-datepicker-year").
  3674. prop("disabled", false);
  3675. }
  3676. this._disabledInputs = $.map(this._disabledInputs,
  3677. function(value) { return (value === target ? null : value); }); // delete entry
  3678. },
  3679. /* Disable the date picker to a jQuery selection.
  3680. * @param target element - the target input field or division or span
  3681. */
  3682. _disableDatepicker: function(target) {
  3683. var nodeName, inline,
  3684. $target = $(target),
  3685. inst = $.data(target, "datepicker");
  3686. if (!$target.hasClass(this.markerClassName)) {
  3687. return;
  3688. }
  3689. nodeName = target.nodeName.toLowerCase();
  3690. if (nodeName === "input") {
  3691. target.disabled = true;
  3692. inst.trigger.filter("button").
  3693. each(function() { this.disabled = true; }).end().
  3694. filter("img").css({opacity: "0.5", cursor: "default"});
  3695. } else if (nodeName === "div" || nodeName === "span") {
  3696. inline = $target.children("." + this._inlineClass);
  3697. inline.children().addClass("ui-state-disabled");
  3698. inline.find("select.ui-datepicker-month, select.ui-datepicker-year").
  3699. prop("disabled", true);
  3700. }
  3701. this._disabledInputs = $.map(this._disabledInputs,
  3702. function(value) { return (value === target ? null : value); }); // delete entry
  3703. this._disabledInputs[this._disabledInputs.length] = target;
  3704. },
  3705. /* Is the first field in a jQuery collection disabled as a datepicker?
  3706. * @param target element - the target input field or division or span
  3707. * @return boolean - true if disabled, false if enabled
  3708. */
  3709. _isDisabledDatepicker: function(target) {
  3710. if (!target) {
  3711. return false;
  3712. }
  3713. for (var i = 0; i < this._disabledInputs.length; i++) {
  3714. if (this._disabledInputs[i] === target) {
  3715. return true;
  3716. }
  3717. }
  3718. return false;
  3719. },
  3720. /* Retrieve the instance data for the target control.
  3721. * @param target element - the target input field or division or span
  3722. * @return object - the associated instance data
  3723. * @throws error if a jQuery problem getting data
  3724. */
  3725. _getInst: function(target) {
  3726. try {
  3727. return $.data(target, "datepicker");
  3728. }
  3729. catch (err) {
  3730. throw "Missing instance data for this datepicker";
  3731. }
  3732. },
  3733. /* Update or retrieve the settings for a date picker attached to an input field or division.
  3734. * @param target element - the target input field or division or span
  3735. * @param name object - the new settings to update or
  3736. * string - the name of the setting to change or retrieve,
  3737. * when retrieving also "all" for all instance settings or
  3738. * "defaults" for all global defaults
  3739. * @param value any - the new value for the setting
  3740. * (omit if above is an object or to retrieve a value)
  3741. */
  3742. _optionDatepicker: function(target, name, value) {
  3743. var settings, date, minDate, maxDate,
  3744. inst = this._getInst(target);
  3745. if (arguments.length === 2 && typeof name === "string") {
  3746. return (name === "defaults" ? $.extend({}, $.datepicker._defaults) :
  3747. (inst ? (name === "all" ? $.extend({}, inst.settings) :
  3748. this._get(inst, name)) : null));
  3749. }
  3750. settings = name || {};
  3751. if (typeof name === "string") {
  3752. settings = {};
  3753. settings[name] = value;
  3754. }
  3755. if (inst) {
  3756. if (this._curInst === inst) {
  3757. this._hideDatepicker();
  3758. }
  3759. date = this._getDateDatepicker(target, true);
  3760. minDate = this._getMinMaxDate(inst, "min");
  3761. maxDate = this._getMinMaxDate(inst, "max");
  3762. datepicker_extendRemove(inst.settings, settings);
  3763. // reformat the old minDate/maxDate values if dateFormat changes and a new minDate/maxDate isn't provided
  3764. if (minDate !== null && settings.dateFormat !== undefined && settings.minDate === undefined) {
  3765. inst.settings.minDate = this._formatDate(inst, minDate);
  3766. }
  3767. if (maxDate !== null && settings.dateFormat !== undefined && settings.maxDate === undefined) {
  3768. inst.settings.maxDate = this._formatDate(inst, maxDate);
  3769. }
  3770. if ( "disabled" in settings ) {
  3771. if ( settings.disabled ) {
  3772. this._disableDatepicker(target);
  3773. } else {
  3774. this._enableDatepicker(target);
  3775. }
  3776. }
  3777. this._attachments($(target), inst);
  3778. this._autoSize(inst);
  3779. this._setDate(inst, date);
  3780. this._updateAlternate(inst);
  3781. this._updateDatepicker(inst);
  3782. }
  3783. },
  3784. // change method deprecated
  3785. _changeDatepicker: function(target, name, value) {
  3786. this._optionDatepicker(target, name, value);
  3787. },
  3788. /* Redraw the date picker attached to an input field or division.
  3789. * @param target element - the target input field or division or span
  3790. */
  3791. _refreshDatepicker: function(target) {
  3792. var inst = this._getInst(target);
  3793. if (inst) {
  3794. this._updateDatepicker(inst);
  3795. }
  3796. },
  3797. /* Set the dates for a jQuery selection.
  3798. * @param target element - the target input field or division or span
  3799. * @param date Date - the new date
  3800. */
  3801. _setDateDatepicker: function(target, date) {
  3802. var inst = this._getInst(target);
  3803. if (inst) {
  3804. this._setDate(inst, date);
  3805. this._updateDatepicker(inst);
  3806. this._updateAlternate(inst);
  3807. }
  3808. },
  3809. /* Get the date(s) for the first entry in a jQuery selection.
  3810. * @param target element - the target input field or division or span
  3811. * @param noDefault boolean - true if no default date is to be used
  3812. * @return Date - the current date
  3813. */
  3814. _getDateDatepicker: function(target, noDefault) {
  3815. var inst = this._getInst(target);
  3816. if (inst && !inst.inline) {
  3817. this._setDateFromField(inst, noDefault);
  3818. }
  3819. return (inst ? this._getDate(inst) : null);
  3820. },
  3821. /* Handle keystrokes. */
  3822. _doKeyDown: function(event) {
  3823. var onSelect, dateStr, sel,
  3824. inst = $.datepicker._getInst(event.target),
  3825. handled = true,
  3826. isRTL = inst.dpDiv.is(".ui-datepicker-rtl");
  3827. inst._keyEvent = true;
  3828. if ($.datepicker._datepickerShowing) {
  3829. switch (event.keyCode) {
  3830. case 9: $.datepicker._hideDatepicker();
  3831. handled = false;
  3832. break; // hide on tab out
  3833. case 13: sel = $("td." + $.datepicker._dayOverClass + ":not(." +
  3834. $.datepicker._currentClass + ")", inst.dpDiv);
  3835. if (sel[0]) {
  3836. $.datepicker._selectDay(event.target, inst.selectedMonth, inst.selectedYear, sel[0]);
  3837. }
  3838. onSelect = $.datepicker._get(inst, "onSelect");
  3839. if (onSelect) {
  3840. dateStr = $.datepicker._formatDate(inst);
  3841. // trigger custom callback
  3842. onSelect.apply((inst.input ? inst.input[0] : null), [dateStr, inst]);
  3843. } else {
  3844. $.datepicker._hideDatepicker();
  3845. }
  3846. return false; // don't submit the form
  3847. case 27: $.datepicker._hideDatepicker();
  3848. break; // hide on escape
  3849. case 33: $.datepicker._adjustDate(event.target, (event.ctrlKey ?
  3850. -$.datepicker._get(inst, "stepBigMonths") :
  3851. -$.datepicker._get(inst, "stepMonths")), "M");
  3852. break; // previous month/year on page up/+ ctrl
  3853. case 34: $.datepicker._adjustDate(event.target, (event.ctrlKey ?
  3854. +$.datepicker._get(inst, "stepBigMonths") :
  3855. +$.datepicker._get(inst, "stepMonths")), "M");
  3856. break; // next month/year on page down/+ ctrl
  3857. case 35: if (event.ctrlKey || event.metaKey) {
  3858. $.datepicker._clearDate(event.target);
  3859. }
  3860. handled = event.ctrlKey || event.metaKey;
  3861. break; // clear on ctrl or command +end
  3862. case 36: if (event.ctrlKey || event.metaKey) {
  3863. $.datepicker._gotoToday(event.target);
  3864. }
  3865. handled = event.ctrlKey || event.metaKey;
  3866. break; // current on ctrl or command +home
  3867. case 37: if (event.ctrlKey || event.metaKey) {
  3868. $.datepicker._adjustDate(event.target, (isRTL ? +1 : -1), "D");
  3869. }
  3870. handled = event.ctrlKey || event.metaKey;
  3871. // -1 day on ctrl or command +left
  3872. if (event.originalEvent.altKey) {
  3873. $.datepicker._adjustDate(event.target, (event.ctrlKey ?
  3874. -$.datepicker._get(inst, "stepBigMonths") :
  3875. -$.datepicker._get(inst, "stepMonths")), "M");
  3876. }
  3877. // next month/year on alt +left on Mac
  3878. break;
  3879. case 38: if (event.ctrlKey || event.metaKey) {
  3880. $.datepicker._adjustDate(event.target, -7, "D");
  3881. }
  3882. handled = event.ctrlKey || event.metaKey;
  3883. break; // -1 week on ctrl or command +up
  3884. case 39: if (event.ctrlKey || event.metaKey) {
  3885. $.datepicker._adjustDate(event.target, (isRTL ? -1 : +1), "D");
  3886. }
  3887. handled = event.ctrlKey || event.metaKey;
  3888. // +1 day on ctrl or command +right
  3889. if (event.originalEvent.altKey) {
  3890. $.datepicker._adjustDate(event.target, (event.ctrlKey ?
  3891. +$.datepicker._get(inst, "stepBigMonths") :
  3892. +$.datepicker._get(inst, "stepMonths")), "M");
  3893. }
  3894. // next month/year on alt +right
  3895. break;
  3896. case 40: if (event.ctrlKey || event.metaKey) {
  3897. $.datepicker._adjustDate(event.target, +7, "D");
  3898. }
  3899. handled = event.ctrlKey || event.metaKey;
  3900. break; // +1 week on ctrl or command +down
  3901. default: handled = false;
  3902. }
  3903. } else if (event.keyCode === 36 && event.ctrlKey) { // display the date picker on ctrl+home
  3904. $.datepicker._showDatepicker(this);
  3905. } else {
  3906. handled = false;
  3907. }
  3908. if (handled) {
  3909. event.preventDefault();
  3910. event.stopPropagation();
  3911. }
  3912. },
  3913. /* Filter entered characters - based on date format. */
  3914. _doKeyPress: function(event) {
  3915. var chars, chr,
  3916. inst = $.datepicker._getInst(event.target);
  3917. if ($.datepicker._get(inst, "constrainInput")) {
  3918. chars = $.datepicker._possibleChars($.datepicker._get(inst, "dateFormat"));
  3919. chr = String.fromCharCode(event.charCode == null ? event.keyCode : event.charCode);
  3920. return event.ctrlKey || event.metaKey || (chr < " " || !chars || chars.indexOf(chr) > -1);
  3921. }
  3922. },
  3923. /* Synchronise manual entry and field/alternate field. */
  3924. _doKeyUp: function(event) {
  3925. var date,
  3926. inst = $.datepicker._getInst(event.target);
  3927. if (inst.input.val() !== inst.lastVal) {
  3928. try {
  3929. date = $.datepicker.parseDate($.datepicker._get(inst, "dateFormat"),
  3930. (inst.input ? inst.input.val() : null),
  3931. $.datepicker._getFormatConfig(inst));
  3932. if (date) { // only if valid
  3933. $.datepicker._setDateFromField(inst);
  3934. $.datepicker._updateAlternate(inst);
  3935. $.datepicker._updateDatepicker(inst);
  3936. }
  3937. }
  3938. catch (err) {
  3939. }
  3940. }
  3941. return true;
  3942. },
  3943. /* Pop-up the date picker for a given input field.
  3944. * If false returned from beforeShow event handler do not show.
  3945. * @param input element - the input field attached to the date picker or
  3946. * event - if triggered by focus
  3947. */
  3948. _showDatepicker: function(input) {
  3949. input = input.target || input;
  3950. if (input.nodeName.toLowerCase() !== "input") { // find from button/image trigger
  3951. input = $("input", input.parentNode)[0];
  3952. }
  3953. if ($.datepicker._isDisabledDatepicker(input) || $.datepicker._lastInput === input) { // already here
  3954. return;
  3955. }
  3956. var inst, beforeShow, beforeShowSettings, isFixed,
  3957. offset, showAnim, duration;
  3958. inst = $.datepicker._getInst(input);
  3959. if ($.datepicker._curInst && $.datepicker._curInst !== inst) {
  3960. $.datepicker._curInst.dpDiv.stop(true, true);
  3961. if ( inst && $.datepicker._datepickerShowing ) {
  3962. $.datepicker._hideDatepicker( $.datepicker._curInst.input[0] );
  3963. }
  3964. }
  3965. beforeShow = $.datepicker._get(inst, "beforeShow");
  3966. beforeShowSettings = beforeShow ? beforeShow.apply(input, [input, inst]) : {};
  3967. if(beforeShowSettings === false){
  3968. return;
  3969. }
  3970. datepicker_extendRemove(inst.settings, beforeShowSettings);
  3971. inst.lastVal = null;
  3972. $.datepicker._lastInput = input;
  3973. $.datepicker._setDateFromField(inst);
  3974. if ($.datepicker._inDialog) { // hide cursor
  3975. input.value = "";
  3976. }
  3977. if (!$.datepicker._pos) { // position below input
  3978. $.datepicker._pos = $.datepicker._findPos(input);
  3979. $.datepicker._pos[1] += input.offsetHeight; // add the height
  3980. }
  3981. isFixed = false;
  3982. $(input).parents().each(function() {
  3983. isFixed |= $(this).css("position") === "fixed";
  3984. return !isFixed;
  3985. });
  3986. offset = {left: $.datepicker._pos[0], top: $.datepicker._pos[1]};
  3987. $.datepicker._pos = null;
  3988. //to avoid flashes on Firefox
  3989. inst.dpDiv.empty();
  3990. // determine sizing offscreen
  3991. inst.dpDiv.css({position: "absolute", display: "block", top: "-1000px"});
  3992. $.datepicker._updateDatepicker(inst);
  3993. // fix width for dynamic number of date pickers
  3994. // and adjust position before showing
  3995. offset = $.datepicker._checkOffset(inst, offset, isFixed);
  3996. inst.dpDiv.css({position: ($.datepicker._inDialog && $.blockUI ?
  3997. "static" : (isFixed ? "fixed" : "absolute")), display: "none",
  3998. left: offset.left + "px", top: offset.top + "px"});
  3999. if (!inst.inline) {
  4000. showAnim = $.datepicker._get(inst, "showAnim");
  4001. duration = $.datepicker._get(inst, "duration");
  4002. inst.dpDiv.css( "z-index", datepicker_getZindex( $( input ) ) + 1 );
  4003. $.datepicker._datepickerShowing = true;
  4004. if ( $.effects && $.effects.effect[ showAnim ] ) {
  4005. inst.dpDiv.show(showAnim, $.datepicker._get(inst, "showOptions"), duration);
  4006. } else {
  4007. inst.dpDiv[showAnim || "show"](showAnim ? duration : null);
  4008. }
  4009. if ( $.datepicker._shouldFocusInput( inst ) ) {
  4010. inst.input.focus();
  4011. }
  4012. $.datepicker._curInst = inst;
  4013. }
  4014. },
  4015. /* Generate the date picker content. */
  4016. _updateDatepicker: function(inst) {
  4017. this.maxRows = 4; //Reset the max number of rows being displayed (see #7043)
  4018. datepicker_instActive = inst; // for delegate hover events
  4019. inst.dpDiv.empty().append(this._generateHTML(inst));
  4020. this._attachHandlers(inst);
  4021. var origyearshtml,
  4022. numMonths = this._getNumberOfMonths(inst),
  4023. cols = numMonths[1],
  4024. width = 17,
  4025. activeCell = inst.dpDiv.find( "." + this._dayOverClass + " a" );
  4026. if ( activeCell.length > 0 ) {
  4027. datepicker_handleMouseover.apply( activeCell.get( 0 ) );
  4028. }
  4029. inst.dpDiv.removeClass("ui-datepicker-multi-2 ui-datepicker-multi-3 ui-datepicker-multi-4").width("");
  4030. if (cols > 1) {
  4031. inst.dpDiv.addClass("ui-datepicker-multi-" + cols).css("width", (width * cols) + "em");
  4032. }
  4033. inst.dpDiv[(numMonths[0] !== 1 || numMonths[1] !== 1 ? "add" : "remove") +
  4034. "Class"]("ui-datepicker-multi");
  4035. inst.dpDiv[(this._get(inst, "isRTL") ? "add" : "remove") +
  4036. "Class"]("ui-datepicker-rtl");
  4037. if (inst === $.datepicker._curInst && $.datepicker._datepickerShowing && $.datepicker._shouldFocusInput( inst ) ) {
  4038. inst.input.focus();
  4039. }
  4040. // deffered render of the years select (to avoid flashes on Firefox)
  4041. if( inst.yearshtml ){
  4042. origyearshtml = inst.yearshtml;
  4043. setTimeout(function(){
  4044. //assure that inst.yearshtml didn't change.
  4045. if( origyearshtml === inst.yearshtml && inst.yearshtml ){
  4046. inst.dpDiv.find("select.ui-datepicker-year:first").replaceWith(inst.yearshtml);
  4047. }
  4048. origyearshtml = inst.yearshtml = null;
  4049. }, 0);
  4050. }
  4051. },
  4052. // #6694 - don't focus the input if it's already focused
  4053. // this breaks the change event in IE
  4054. // Support: IE and jQuery <1.9
  4055. _shouldFocusInput: function( inst ) {
  4056. return inst.input && inst.input.is( ":visible" ) && !inst.input.is( ":disabled" ) && !inst.input.is( ":focus" );
  4057. },
  4058. /* Check positioning to remain on screen. */
  4059. _checkOffset: function(inst, offset, isFixed) {
  4060. var dpWidth = inst.dpDiv.outerWidth(),
  4061. dpHeight = inst.dpDiv.outerHeight(),
  4062. inputWidth = inst.input ? inst.input.outerWidth() : 0,
  4063. inputHeight = inst.input ? inst.input.outerHeight() : 0,
  4064. viewWidth = document.documentElement.clientWidth + (isFixed ? 0 : $(document).scrollLeft()),
  4065. viewHeight = document.documentElement.clientHeight + (isFixed ? 0 : $(document).scrollTop());
  4066. offset.left -= (this._get(inst, "isRTL") ? (dpWidth - inputWidth) : 0);
  4067. offset.left -= (isFixed && offset.left === inst.input.offset().left) ? $(document).scrollLeft() : 0;
  4068. offset.top -= (isFixed && offset.top === (inst.input.offset().top + inputHeight)) ? $(document).scrollTop() : 0;
  4069. // now check if datepicker is showing outside window viewport - move to a better place if so.
  4070. offset.left -= Math.min(offset.left, (offset.left + dpWidth > viewWidth && viewWidth > dpWidth) ?
  4071. Math.abs(offset.left + dpWidth - viewWidth) : 0);
  4072. offset.top -= Math.min(offset.top, (offset.top + dpHeight > viewHeight && viewHeight > dpHeight) ?
  4073. Math.abs(dpHeight + inputHeight) : 0);
  4074. return offset;
  4075. },
  4076. /* Find an object's position on the screen. */
  4077. _findPos: function(obj) {
  4078. var position,
  4079. inst = this._getInst(obj),
  4080. isRTL = this._get(inst, "isRTL");
  4081. while (obj && (obj.type === "hidden" || obj.nodeType !== 1 || $.expr.filters.hidden(obj))) {
  4082. obj = obj[isRTL ? "previousSibling" : "nextSibling"];
  4083. }
  4084. position = $(obj).offset();
  4085. return [position.left, position.top];
  4086. },
  4087. /* Hide the date picker from view.
  4088. * @param input element - the input field attached to the date picker
  4089. */
  4090. _hideDatepicker: function(input) {
  4091. var showAnim, duration, postProcess, onClose,
  4092. inst = this._curInst;
  4093. if (!inst || (input && inst !== $.data(input, "datepicker"))) {
  4094. return;
  4095. }
  4096. if (this._datepickerShowing) {
  4097. showAnim = this._get(inst, "showAnim");
  4098. duration = this._get(inst, "duration");
  4099. postProcess = function() {
  4100. $.datepicker._tidyDialog(inst);
  4101. };
  4102. // DEPRECATED: after BC for 1.8.x $.effects[ showAnim ] is not needed
  4103. if ( $.effects && ( $.effects.effect[ showAnim ] || $.effects[ showAnim ] ) ) {
  4104. inst.dpDiv.hide(showAnim, $.datepicker._get(inst, "showOptions"), duration, postProcess);
  4105. } else {
  4106. inst.dpDiv[(showAnim === "slideDown" ? "slideUp" :
  4107. (showAnim === "fadeIn" ? "fadeOut" : "hide"))]((showAnim ? duration : null), postProcess);
  4108. }
  4109. if (!showAnim) {
  4110. postProcess();
  4111. }
  4112. this._datepickerShowing = false;
  4113. onClose = this._get(inst, "onClose");
  4114. if (onClose) {
  4115. onClose.apply((inst.input ? inst.input[0] : null), [(inst.input ? inst.input.val() : ""), inst]);
  4116. }
  4117. this._lastInput = null;
  4118. if (this._inDialog) {
  4119. this._dialogInput.css({ position: "absolute", left: "0", top: "-100px" });
  4120. if ($.blockUI) {
  4121. $.unblockUI();
  4122. $("body").append(this.dpDiv);
  4123. }
  4124. }
  4125. this._inDialog = false;
  4126. }
  4127. },
  4128. /* Tidy up after a dialog display. */
  4129. _tidyDialog: function(inst) {
  4130. inst.dpDiv.removeClass(this._dialogClass).unbind(".ui-datepicker-calendar");
  4131. },
  4132. /* Close date picker if clicked elsewhere. */
  4133. _checkExternalClick: function(event) {
  4134. if (!$.datepicker._curInst) {
  4135. return;
  4136. }
  4137. var $target = $(event.target),
  4138. inst = $.datepicker._getInst($target[0]);
  4139. if ( ( ( $target[0].id !== $.datepicker._mainDivId &&
  4140. $target.parents("#" + $.datepicker._mainDivId).length === 0 &&
  4141. !$target.hasClass($.datepicker.markerClassName) &&
  4142. !$target.closest("." + $.datepicker._triggerClass).length &&
  4143. $.datepicker._datepickerShowing && !($.datepicker._inDialog && $.blockUI) ) ) ||
  4144. ( $target.hasClass($.datepicker.markerClassName) && $.datepicker._curInst !== inst ) ) {
  4145. $.datepicker._hideDatepicker();
  4146. }
  4147. },
  4148. /* Adjust one of the date sub-fields. */
  4149. _adjustDate: function(id, offset, period) {
  4150. var target = $(id),
  4151. inst = this._getInst(target[0]);
  4152. if (this._isDisabledDatepicker(target[0])) {
  4153. return;
  4154. }
  4155. this._adjustInstDate(inst, offset +
  4156. (period === "M" ? this._get(inst, "showCurrentAtPos") : 0), // undo positioning
  4157. period);
  4158. this._updateDatepicker(inst);
  4159. },
  4160. /* Action for current link. */
  4161. _gotoToday: function(id) {
  4162. var date,
  4163. target = $(id),
  4164. inst = this._getInst(target[0]);
  4165. if (this._get(inst, "gotoCurrent") && inst.currentDay) {
  4166. inst.selectedDay = inst.currentDay;
  4167. inst.drawMonth = inst.selectedMonth = inst.currentMonth;
  4168. inst.drawYear = inst.selectedYear = inst.currentYear;
  4169. } else {
  4170. date = new Date();
  4171. inst.selectedDay = date.getDate();
  4172. inst.drawMonth = inst.selectedMonth = date.getMonth();
  4173. inst.drawYear = inst.selectedYear = date.getFullYear();
  4174. }
  4175. this._notifyChange(inst);
  4176. this._adjustDate(target);
  4177. },
  4178. /* Action for selecting a new month/year. */
  4179. _selectMonthYear: function(id, select, period) {
  4180. var target = $(id),
  4181. inst = this._getInst(target[0]);
  4182. inst["selected" + (period === "M" ? "Month" : "Year")] =
  4183. inst["draw" + (period === "M" ? "Month" : "Year")] =
  4184. parseInt(select.options[select.selectedIndex].value,10);
  4185. this._notifyChange(inst);
  4186. this._adjustDate(target);
  4187. },
  4188. /* Action for selecting a day. */
  4189. _selectDay: function(id, month, year, td) {
  4190. var inst,
  4191. target = $(id);
  4192. if ($(td).hasClass(this._unselectableClass) || this._isDisabledDatepicker(target[0])) {
  4193. return;
  4194. }
  4195. inst = this._getInst(target[0]);
  4196. inst.selectedDay = inst.currentDay = $("a", td).html();
  4197. inst.selectedMonth = inst.currentMonth = month;
  4198. inst.selectedYear = inst.currentYear = year;
  4199. this._selectDate(id, this._formatDate(inst,
  4200. inst.currentDay, inst.currentMonth, inst.currentYear));
  4201. },
  4202. /* Erase the input field and hide the date picker. */
  4203. _clearDate: function(id) {
  4204. var target = $(id);
  4205. this._selectDate(target, "");
  4206. },
  4207. /* Update the input field with the selected date. */
  4208. _selectDate: function(id, dateStr) {
  4209. var onSelect,
  4210. target = $(id),
  4211. inst = this._getInst(target[0]);
  4212. dateStr = (dateStr != null ? dateStr : this._formatDate(inst));
  4213. if (inst.input) {
  4214. inst.input.val(dateStr);
  4215. }
  4216. this._updateAlternate(inst);
  4217. onSelect = this._get(inst, "onSelect");
  4218. if (onSelect) {
  4219. onSelect.apply((inst.input ? inst.input[0] : null), [dateStr, inst]); // trigger custom callback
  4220. } else if (inst.input) {
  4221. inst.input.trigger("change"); // fire the change event
  4222. }
  4223. if (inst.inline){
  4224. this._updateDatepicker(inst);
  4225. } else {
  4226. this._hideDatepicker();
  4227. this._lastInput = inst.input[0];
  4228. if (typeof(inst.input[0]) !== "object") {
  4229. inst.input.focus(); // restore focus
  4230. }
  4231. this._lastInput = null;
  4232. }
  4233. },
  4234. /* Update any alternate field to synchronise with the main field. */
  4235. _updateAlternate: function(inst) {
  4236. var altFormat, date, dateStr,
  4237. altField = this._get(inst, "altField");
  4238. if (altField) { // update alternate field too
  4239. altFormat = this._get(inst, "altFormat") || this._get(inst, "dateFormat");
  4240. date = this._getDate(inst);
  4241. dateStr = this.formatDate(altFormat, date, this._getFormatConfig(inst));
  4242. $(altField).each(function() { $(this).val(dateStr); });
  4243. }
  4244. },
  4245. /* Set as beforeShowDay function to prevent selection of weekends.
  4246. * @param date Date - the date to customise
  4247. * @return [boolean, string] - is this date selectable?, what is its CSS class?
  4248. */
  4249. noWeekends: function(date) {
  4250. var day = date.getDay();
  4251. return [(day > 0 && day < 6), ""];
  4252. },
  4253. /* Set as calculateWeek to determine the week of the year based on the ISO 8601 definition.
  4254. * @param date Date - the date to get the week for
  4255. * @return number - the number of the week within the year that contains this date
  4256. */
  4257. iso8601Week: function(date) {
  4258. var time,
  4259. checkDate = new Date(date.getTime());
  4260. // Find Thursday of this week starting on Monday
  4261. checkDate.setDate(checkDate.getDate() + 4 - (checkDate.getDay() || 7));
  4262. time = checkDate.getTime();
  4263. checkDate.setMonth(0); // Compare with Jan 1
  4264. checkDate.setDate(1);
  4265. return Math.floor(Math.round((time - checkDate) / 86400000) / 7) + 1;
  4266. },
  4267. /* Parse a string value into a date object.
  4268. * See formatDate below for the possible formats.
  4269. *
  4270. * @param format string - the expected format of the date
  4271. * @param value string - the date in the above format
  4272. * @param settings Object - attributes include:
  4273. * shortYearCutoff number - the cutoff year for determining the century (optional)
  4274. * dayNamesShort string[7] - abbreviated names of the days from Sunday (optional)
  4275. * dayNames string[7] - names of the days from Sunday (optional)
  4276. * monthNamesShort string[12] - abbreviated names of the months (optional)
  4277. * monthNames string[12] - names of the months (optional)
  4278. * @return Date - the extracted date value or null if value is blank
  4279. */
  4280. parseDate: function (format, value, settings) {
  4281. if (format == null || value == null) {
  4282. throw "Invalid arguments";
  4283. }
  4284. value = (typeof value === "object" ? value.toString() : value + "");
  4285. if (value === "") {
  4286. return null;
  4287. }
  4288. var iFormat, dim, extra,
  4289. iValue = 0,
  4290. shortYearCutoffTemp = (settings ? settings.shortYearCutoff : null) || this._defaults.shortYearCutoff,
  4291. shortYearCutoff = (typeof shortYearCutoffTemp !== "string" ? shortYearCutoffTemp :
  4292. new Date().getFullYear() % 100 + parseInt(shortYearCutoffTemp, 10)),
  4293. dayNamesShort = (settings ? settings.dayNamesShort : null) || this._defaults.dayNamesShort,
  4294. dayNames = (settings ? settings.dayNames : null) || this._defaults.dayNames,
  4295. monthNamesShort = (settings ? settings.monthNamesShort : null) || this._defaults.monthNamesShort,
  4296. monthNames = (settings ? settings.monthNames : null) || this._defaults.monthNames,
  4297. year = -1,
  4298. month = -1,
  4299. day = -1,
  4300. doy = -1,
  4301. literal = false,
  4302. date,
  4303. // Check whether a format character is doubled
  4304. lookAhead = function(match) {
  4305. var matches = (iFormat + 1 < format.length && format.charAt(iFormat + 1) === match);
  4306. if (matches) {
  4307. iFormat++;
  4308. }
  4309. return matches;
  4310. },
  4311. // Extract a number from the string value
  4312. getNumber = function(match) {
  4313. var isDoubled = lookAhead(match),
  4314. size = (match === "@" ? 14 : (match === "!" ? 20 :
  4315. (match === "y" && isDoubled ? 4 : (match === "o" ? 3 : 2)))),
  4316. minSize = (match === "y" ? size : 1),
  4317. digits = new RegExp("^\\d{" + minSize + "," + size + "}"),
  4318. num = value.substring(iValue).match(digits);
  4319. if (!num) {
  4320. throw "Missing number at position " + iValue;
  4321. }
  4322. iValue += num[0].length;
  4323. return parseInt(num[0], 10);
  4324. },
  4325. // Extract a name from the string value and convert to an index
  4326. getName = function(match, shortNames, longNames) {
  4327. var index = -1,
  4328. names = $.map(lookAhead(match) ? longNames : shortNames, function (v, k) {
  4329. return [ [k, v] ];
  4330. }).sort(function (a, b) {
  4331. return -(a[1].length - b[1].length);
  4332. });
  4333. $.each(names, function (i, pair) {
  4334. var name = pair[1];
  4335. if (value.substr(iValue, name.length).toLowerCase() === name.toLowerCase()) {
  4336. index = pair[0];
  4337. iValue += name.length;
  4338. return false;
  4339. }
  4340. });
  4341. if (index !== -1) {
  4342. return index + 1;
  4343. } else {
  4344. throw "Unknown name at position " + iValue;
  4345. }
  4346. },
  4347. // Confirm that a literal character matches the string value
  4348. checkLiteral = function() {
  4349. if (value.charAt(iValue) !== format.charAt(iFormat)) {
  4350. throw "Unexpected literal at position " + iValue;
  4351. }
  4352. iValue++;
  4353. };
  4354. for (iFormat = 0; iFormat < format.length; iFormat++) {
  4355. if (literal) {
  4356. if (format.charAt(iFormat) === "'" && !lookAhead("'")) {
  4357. literal = false;
  4358. } else {
  4359. checkLiteral();
  4360. }
  4361. } else {
  4362. switch (format.charAt(iFormat)) {
  4363. case "d":
  4364. day = getNumber("d");
  4365. break;
  4366. case "D":
  4367. getName("D", dayNamesShort, dayNames);
  4368. break;
  4369. case "o":
  4370. doy = getNumber("o");
  4371. break;
  4372. case "m":
  4373. month = getNumber("m");
  4374. break;
  4375. case "M":
  4376. month = getName("M", monthNamesShort, monthNames);
  4377. break;
  4378. case "y":
  4379. year = getNumber("y");
  4380. break;
  4381. case "@":
  4382. date = new Date(getNumber("@"));
  4383. year = date.getFullYear();
  4384. month = date.getMonth() + 1;
  4385. day = date.getDate();
  4386. break;
  4387. case "!":
  4388. date = new Date((getNumber("!") - this._ticksTo1970) / 10000);
  4389. year = date.getFullYear();
  4390. month = date.getMonth() + 1;
  4391. day = date.getDate();
  4392. break;
  4393. case "'":
  4394. if (lookAhead("'")){
  4395. checkLiteral();
  4396. } else {
  4397. literal = true;
  4398. }
  4399. break;
  4400. default:
  4401. checkLiteral();
  4402. }
  4403. }
  4404. }
  4405. if (iValue < value.length){
  4406. extra = value.substr(iValue);
  4407. if (!/^\s+/.test(extra)) {
  4408. throw "Extra/unparsed characters found in date: " + extra;
  4409. }
  4410. }
  4411. if (year === -1) {
  4412. year = new Date().getFullYear();
  4413. } else if (year < 100) {
  4414. year += new Date().getFullYear() - new Date().getFullYear() % 100 +
  4415. (year <= shortYearCutoff ? 0 : -100);
  4416. }
  4417. if (doy > -1) {
  4418. month = 1;
  4419. day = doy;
  4420. do {
  4421. dim = this._getDaysInMonth(year, month - 1);
  4422. if (day <= dim) {
  4423. break;
  4424. }
  4425. month++;
  4426. day -= dim;
  4427. } while (true);
  4428. }
  4429. date = this._daylightSavingAdjust(new Date(year, month - 1, day));
  4430. if (date.getFullYear() !== year || date.getMonth() + 1 !== month || date.getDate() !== day) {
  4431. throw "Invalid date"; // E.g. 31/02/00
  4432. }
  4433. return date;
  4434. },
  4435. /* Standard date formats. */
  4436. ATOM: "yy-mm-dd", // RFC 3339 (ISO 8601)
  4437. COOKIE: "D, dd M yy",
  4438. ISO_8601: "yy-mm-dd",
  4439. RFC_822: "D, d M y",
  4440. RFC_850: "DD, dd-M-y",
  4441. RFC_1036: "D, d M y",
  4442. RFC_1123: "D, d M yy",
  4443. RFC_2822: "D, d M yy",
  4444. RSS: "D, d M y", // RFC 822
  4445. TICKS: "!",
  4446. TIMESTAMP: "@",
  4447. W3C: "yy-mm-dd", // ISO 8601
  4448. _ticksTo1970: (((1970 - 1) * 365 + Math.floor(1970 / 4) - Math.floor(1970 / 100) +
  4449. Math.floor(1970 / 400)) * 24 * 60 * 60 * 10000000),
  4450. /* Format a date object into a string value.
  4451. * The format can be combinations of the following:
  4452. * d - day of month (no leading zero)
  4453. * dd - day of month (two digit)
  4454. * o - day of year (no leading zeros)
  4455. * oo - day of year (three digit)
  4456. * D - day name short
  4457. * DD - day name long
  4458. * m - month of year (no leading zero)
  4459. * mm - month of year (two digit)
  4460. * M - month name short
  4461. * MM - month name long
  4462. * y - year (two digit)
  4463. * yy - year (four digit)
  4464. * @ - Unix timestamp (ms since 01/01/1970)
  4465. * ! - Windows ticks (100ns since 01/01/0001)
  4466. * "..." - literal text
  4467. * '' - single quote
  4468. *
  4469. * @param format string - the desired format of the date
  4470. * @param date Date - the date value to format
  4471. * @param settings Object - attributes include:
  4472. * dayNamesShort string[7] - abbreviated names of the days from Sunday (optional)
  4473. * dayNames string[7] - names of the days from Sunday (optional)
  4474. * monthNamesShort string[12] - abbreviated names of the months (optional)
  4475. * monthNames string[12] - names of the months (optional)
  4476. * @return string - the date in the above format
  4477. */
  4478. formatDate: function (format, date, settings) {
  4479. if (!date) {
  4480. return "";
  4481. }
  4482. var iFormat,
  4483. dayNamesShort = (settings ? settings.dayNamesShort : null) || this._defaults.dayNamesShort,
  4484. dayNames = (settings ? settings.dayNames : null) || this._defaults.dayNames,
  4485. monthNamesShort = (settings ? settings.monthNamesShort : null) || this._defaults.monthNamesShort,
  4486. monthNames = (settings ? settings.monthNames : null) || this._defaults.monthNames,
  4487. // Check whether a format character is doubled
  4488. lookAhead = function(match) {
  4489. var matches = (iFormat + 1 < format.length && format.charAt(iFormat + 1) === match);
  4490. if (matches) {
  4491. iFormat++;
  4492. }
  4493. return matches;
  4494. },
  4495. // Format a number, with leading zero if necessary
  4496. formatNumber = function(match, value, len) {
  4497. var num = "" + value;
  4498. if (lookAhead(match)) {
  4499. while (num.length < len) {
  4500. num = "0" + num;
  4501. }
  4502. }
  4503. return num;
  4504. },
  4505. // Format a name, short or long as requested
  4506. formatName = function(match, value, shortNames, longNames) {
  4507. return (lookAhead(match) ? longNames[value] : shortNames[value]);
  4508. },
  4509. output = "",
  4510. literal = false;
  4511. if (date) {
  4512. for (iFormat = 0; iFormat < format.length; iFormat++) {
  4513. if (literal) {
  4514. if (format.charAt(iFormat) === "'" && !lookAhead("'")) {
  4515. literal = false;
  4516. } else {
  4517. output += format.charAt(iFormat);
  4518. }
  4519. } else {
  4520. switch (format.charAt(iFormat)) {
  4521. case "d":
  4522. output += formatNumber("d", date.getDate(), 2);
  4523. break;
  4524. case "D":
  4525. output += formatName("D", date.getDay(), dayNamesShort, dayNames);
  4526. break;
  4527. case "o":
  4528. output += formatNumber("o",
  4529. Math.round((new Date(date.getFullYear(), date.getMonth(), date.getDate()).getTime() - new Date(date.getFullYear(), 0, 0).getTime()) / 86400000), 3);
  4530. break;
  4531. case "m":
  4532. output += formatNumber("m", date.getMonth() + 1, 2);
  4533. break;
  4534. case "M":
  4535. output += formatName("M", date.getMonth(), monthNamesShort, monthNames);
  4536. break;
  4537. case "y":
  4538. output += (lookAhead("y") ? date.getFullYear() :
  4539. (date.getYear() % 100 < 10 ? "0" : "") + date.getYear() % 100);
  4540. break;
  4541. case "@":
  4542. output += date.getTime();
  4543. break;
  4544. case "!":
  4545. output += date.getTime() * 10000 + this._ticksTo1970;
  4546. break;
  4547. case "'":
  4548. if (lookAhead("'")) {
  4549. output += "'";
  4550. } else {
  4551. literal = true;
  4552. }
  4553. break;
  4554. default:
  4555. output += format.charAt(iFormat);
  4556. }
  4557. }
  4558. }
  4559. }
  4560. return output;
  4561. },
  4562. /* Extract all possible characters from the date format. */
  4563. _possibleChars: function (format) {
  4564. var iFormat,
  4565. chars = "",
  4566. literal = false,
  4567. // Check whether a format character is doubled
  4568. lookAhead = function(match) {
  4569. var matches = (iFormat + 1 < format.length && format.charAt(iFormat + 1) === match);
  4570. if (matches) {
  4571. iFormat++;
  4572. }
  4573. return matches;
  4574. };
  4575. for (iFormat = 0; iFormat < format.length; iFormat++) {
  4576. if (literal) {
  4577. if (format.charAt(iFormat) === "'" && !lookAhead("'")) {
  4578. literal = false;
  4579. } else {
  4580. chars += format.charAt(iFormat);
  4581. }
  4582. } else {
  4583. switch (format.charAt(iFormat)) {
  4584. case "d": case "m": case "y": case "@":
  4585. chars += "0123456789";
  4586. break;
  4587. case "D": case "M":
  4588. return null; // Accept anything
  4589. case "'":
  4590. if (lookAhead("'")) {
  4591. chars += "'";
  4592. } else {
  4593. literal = true;
  4594. }
  4595. break;
  4596. default:
  4597. chars += format.charAt(iFormat);
  4598. }
  4599. }
  4600. }
  4601. return chars;
  4602. },
  4603. /* Get a setting value, defaulting if necessary. */
  4604. _get: function(inst, name) {
  4605. return inst.settings[name] !== undefined ?
  4606. inst.settings[name] : this._defaults[name];
  4607. },
  4608. /* Parse existing date and initialise date picker. */
  4609. _setDateFromField: function(inst, noDefault) {
  4610. if (inst.input.val() === inst.lastVal) {
  4611. return;
  4612. }
  4613. var dateFormat = this._get(inst, "dateFormat"),
  4614. dates = inst.lastVal = inst.input ? inst.input.val() : null,
  4615. defaultDate = this._getDefaultDate(inst),
  4616. date = defaultDate,
  4617. settings = this._getFormatConfig(inst);
  4618. try {
  4619. date = this.parseDate(dateFormat, dates, settings) || defaultDate;
  4620. } catch (event) {
  4621. dates = (noDefault ? "" : dates);
  4622. }
  4623. inst.selectedDay = date.getDate();
  4624. inst.drawMonth = inst.selectedMonth = date.getMonth();
  4625. inst.drawYear = inst.selectedYear = date.getFullYear();
  4626. inst.currentDay = (dates ? date.getDate() : 0);
  4627. inst.currentMonth = (dates ? date.getMonth() : 0);
  4628. inst.currentYear = (dates ? date.getFullYear() : 0);
  4629. this._adjustInstDate(inst);
  4630. },
  4631. /* Retrieve the default date shown on opening. */
  4632. _getDefaultDate: function(inst) {
  4633. return this._restrictMinMax(inst,
  4634. this._determineDate(inst, this._get(inst, "defaultDate"), new Date()));
  4635. },
  4636. /* A date may be specified as an exact value or a relative one. */
  4637. _determineDate: function(inst, date, defaultDate) {
  4638. var offsetNumeric = function(offset) {
  4639. var date = new Date();
  4640. date.setDate(date.getDate() + offset);
  4641. return date;
  4642. },
  4643. offsetString = function(offset) {
  4644. try {
  4645. return $.datepicker.parseDate($.datepicker._get(inst, "dateFormat"),
  4646. offset, $.datepicker._getFormatConfig(inst));
  4647. }
  4648. catch (e) {
  4649. // Ignore
  4650. }
  4651. var date = (offset.toLowerCase().match(/^c/) ?
  4652. $.datepicker._getDate(inst) : null) || new Date(),
  4653. year = date.getFullYear(),
  4654. month = date.getMonth(),
  4655. day = date.getDate(),
  4656. pattern = /([+\-]?[0-9]+)\s*(d|D|w|W|m|M|y|Y)?/g,
  4657. matches = pattern.exec(offset);
  4658. while (matches) {
  4659. switch (matches[2] || "d") {
  4660. case "d" : case "D" :
  4661. day += parseInt(matches[1],10); break;
  4662. case "w" : case "W" :
  4663. day += parseInt(matches[1],10) * 7; break;
  4664. case "m" : case "M" :
  4665. month += parseInt(matches[1],10);
  4666. day = Math.min(day, $.datepicker._getDaysInMonth(year, month));
  4667. break;
  4668. case "y": case "Y" :
  4669. year += parseInt(matches[1],10);
  4670. day = Math.min(day, $.datepicker._getDaysInMonth(year, month));
  4671. break;
  4672. }
  4673. matches = pattern.exec(offset);
  4674. }
  4675. return new Date(year, month, day);
  4676. },
  4677. newDate = (date == null || date === "" ? defaultDate : (typeof date === "string" ? offsetString(date) :
  4678. (typeof date === "number" ? (isNaN(date) ? defaultDate : offsetNumeric(date)) : new Date(date.getTime()))));
  4679. newDate = (newDate && newDate.toString() === "Invalid Date" ? defaultDate : newDate);
  4680. if (newDate) {
  4681. newDate.setHours(0);
  4682. newDate.setMinutes(0);
  4683. newDate.setSeconds(0);
  4684. newDate.setMilliseconds(0);
  4685. }
  4686. return this._daylightSavingAdjust(newDate);
  4687. },
  4688. /* Handle switch to/from daylight saving.
  4689. * Hours may be non-zero on daylight saving cut-over:
  4690. * > 12 when midnight changeover, but then cannot generate
  4691. * midnight datetime, so jump to 1AM, otherwise reset.
  4692. * @param date (Date) the date to check
  4693. * @return (Date) the corrected date
  4694. */
  4695. _daylightSavingAdjust: function(date) {
  4696. if (!date) {
  4697. return null;
  4698. }
  4699. date.setHours(date.getHours() > 12 ? date.getHours() + 2 : 0);
  4700. return date;
  4701. },
  4702. /* Set the date(s) directly. */
  4703. _setDate: function(inst, date, noChange) {
  4704. var clear = !date,
  4705. origMonth = inst.selectedMonth,
  4706. origYear = inst.selectedYear,
  4707. newDate = this._restrictMinMax(inst, this._determineDate(inst, date, new Date()));
  4708. inst.selectedDay = inst.currentDay = newDate.getDate();
  4709. inst.drawMonth = inst.selectedMonth = inst.currentMonth = newDate.getMonth();
  4710. inst.drawYear = inst.selectedYear = inst.currentYear = newDate.getFullYear();
  4711. if ((origMonth !== inst.selectedMonth || origYear !== inst.selectedYear) && !noChange) {
  4712. this._notifyChange(inst);
  4713. }
  4714. this._adjustInstDate(inst);
  4715. if (inst.input) {
  4716. inst.input.val(clear ? "" : this._formatDate(inst));
  4717. }
  4718. },
  4719. /* Retrieve the date(s) directly. */
  4720. _getDate: function(inst) {
  4721. var startDate = (!inst.currentYear || (inst.input && inst.input.val() === "") ? null :
  4722. this._daylightSavingAdjust(new Date(
  4723. inst.currentYear, inst.currentMonth, inst.currentDay)));
  4724. return startDate;
  4725. },
  4726. /* Attach the onxxx handlers. These are declared statically so
  4727. * they work with static code transformers like Caja.
  4728. */
  4729. _attachHandlers: function(inst) {
  4730. var stepMonths = this._get(inst, "stepMonths"),
  4731. id = "#" + inst.id.replace( /\\\\/g, "\\" );
  4732. inst.dpDiv.find("[data-handler]").map(function () {
  4733. var handler = {
  4734. prev: function () {
  4735. $.datepicker._adjustDate(id, -stepMonths, "M");
  4736. },
  4737. next: function () {
  4738. $.datepicker._adjustDate(id, +stepMonths, "M");
  4739. },
  4740. hide: function () {
  4741. $.datepicker._hideDatepicker();
  4742. },
  4743. today: function () {
  4744. $.datepicker._gotoToday(id);
  4745. },
  4746. selectDay: function () {
  4747. $.datepicker._selectDay(id, +this.getAttribute("data-month"), +this.getAttribute("data-year"), this);
  4748. return false;
  4749. },
  4750. selectMonth: function () {
  4751. $.datepicker._selectMonthYear(id, this, "M");
  4752. return false;
  4753. },
  4754. selectYear: function () {
  4755. $.datepicker._selectMonthYear(id, this, "Y");
  4756. return false;
  4757. }
  4758. };
  4759. $(this).bind(this.getAttribute("data-event"), handler[this.getAttribute("data-handler")]);
  4760. });
  4761. },
  4762. /* Generate the HTML for the current state of the date picker. */
  4763. _generateHTML: function(inst) {
  4764. var maxDraw, prevText, prev, nextText, next, currentText, gotoDate,
  4765. controls, buttonPanel, firstDay, showWeek, dayNames, dayNamesMin,
  4766. monthNames, monthNamesShort, beforeShowDay, showOtherMonths,
  4767. selectOtherMonths, defaultDate, html, dow, row, group, col, selectedDate,
  4768. cornerClass, calender, thead, day, daysInMonth, leadDays, curRows, numRows,
  4769. printDate, dRow, tbody, daySettings, otherMonth, unselectable,
  4770. tempDate = new Date(),
  4771. today = this._daylightSavingAdjust(
  4772. new Date(tempDate.getFullYear(), tempDate.getMonth(), tempDate.getDate())), // clear time
  4773. isRTL = this._get(inst, "isRTL"),
  4774. showButtonPanel = this._get(inst, "showButtonPanel"),
  4775. hideIfNoPrevNext = this._get(inst, "hideIfNoPrevNext"),
  4776. navigationAsDateFormat = this._get(inst, "navigationAsDateFormat"),
  4777. numMonths = this._getNumberOfMonths(inst),
  4778. showCurrentAtPos = this._get(inst, "showCurrentAtPos"),
  4779. stepMonths = this._get(inst, "stepMonths"),
  4780. isMultiMonth = (numMonths[0] !== 1 || numMonths[1] !== 1),
  4781. currentDate = this._daylightSavingAdjust((!inst.currentDay ? new Date(9999, 9, 9) :
  4782. new Date(inst.currentYear, inst.currentMonth, inst.currentDay))),
  4783. minDate = this._getMinMaxDate(inst, "min"),
  4784. maxDate = this._getMinMaxDate(inst, "max"),
  4785. drawMonth = inst.drawMonth - showCurrentAtPos,
  4786. drawYear = inst.drawYear;
  4787. if (drawMonth < 0) {
  4788. drawMonth += 12;
  4789. drawYear--;
  4790. }
  4791. if (maxDate) {
  4792. maxDraw = this._daylightSavingAdjust(new Date(maxDate.getFullYear(),
  4793. maxDate.getMonth() - (numMonths[0] * numMonths[1]) + 1, maxDate.getDate()));
  4794. maxDraw = (minDate && maxDraw < minDate ? minDate : maxDraw);
  4795. while (this._daylightSavingAdjust(new Date(drawYear, drawMonth, 1)) > maxDraw) {
  4796. drawMonth--;
  4797. if (drawMonth < 0) {
  4798. drawMonth = 11;
  4799. drawYear--;
  4800. }
  4801. }
  4802. }
  4803. inst.drawMonth = drawMonth;
  4804. inst.drawYear = drawYear;
  4805. prevText = this._get(inst, "prevText");
  4806. prevText = (!navigationAsDateFormat ? prevText : this.formatDate(prevText,
  4807. this._daylightSavingAdjust(new Date(drawYear, drawMonth - stepMonths, 1)),
  4808. this._getFormatConfig(inst)));
  4809. prev = (this._canAdjustMonth(inst, -1, drawYear, drawMonth) ?
  4810. "<a class='ui-datepicker-prev ui-corner-all' data-handler='prev' data-event='click'" +
  4811. " title='" + prevText + "'><span class='ui-icon ui-icon-circle-triangle-" + ( isRTL ? "e" : "w") + "'>" + prevText + "</span></a>" :
  4812. (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>"));
  4813. nextText = this._get(inst, "nextText");
  4814. nextText = (!navigationAsDateFormat ? nextText : this.formatDate(nextText,
  4815. this._daylightSavingAdjust(new Date(drawYear, drawMonth + stepMonths, 1)),
  4816. this._getFormatConfig(inst)));
  4817. next = (this._canAdjustMonth(inst, +1, drawYear, drawMonth) ?
  4818. "<a class='ui-datepicker-next ui-corner-all' data-handler='next' data-event='click'" +
  4819. " title='" + nextText + "'><span class='ui-icon ui-icon-circle-triangle-" + ( isRTL ? "w" : "e") + "'>" + nextText + "</span></a>" :
  4820. (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>"));
  4821. currentText = this._get(inst, "currentText");
  4822. gotoDate = (this._get(inst, "gotoCurrent") && inst.currentDay ? currentDate : today);
  4823. currentText = (!navigationAsDateFormat ? currentText :
  4824. this.formatDate(currentText, gotoDate, this._getFormatConfig(inst)));
  4825. 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'>" +
  4826. this._get(inst, "closeText") + "</button>" : "");
  4827. buttonPanel = (showButtonPanel) ? "<div class='ui-datepicker-buttonpane ui-widget-content'>" + (isRTL ? controls : "") +
  4828. (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'" +
  4829. ">" + currentText + "</button>" : "") + (isRTL ? "" : controls) + "</div>" : "";
  4830. firstDay = parseInt(this._get(inst, "firstDay"),10);
  4831. firstDay = (isNaN(firstDay) ? 0 : firstDay);
  4832. showWeek = this._get(inst, "showWeek");
  4833. dayNames = this._get(inst, "dayNames");
  4834. dayNamesMin = this._get(inst, "dayNamesMin");
  4835. monthNames = this._get(inst, "monthNames");
  4836. monthNamesShort = this._get(inst, "monthNamesShort");
  4837. beforeShowDay = this._get(inst, "beforeShowDay");
  4838. showOtherMonths = this._get(inst, "showOtherMonths");
  4839. selectOtherMonths = this._get(inst, "selectOtherMonths");
  4840. defaultDate = this._getDefaultDate(inst);
  4841. html = "";
  4842. dow;
  4843. for (row = 0; row < numMonths[0]; row++) {
  4844. group = "";
  4845. this.maxRows = 4;
  4846. for (col = 0; col < numMonths[1]; col++) {
  4847. selectedDate = this._daylightSavingAdjust(new Date(drawYear, drawMonth, inst.selectedDay));
  4848. cornerClass = " ui-corner-all";
  4849. calender = "";
  4850. if (isMultiMonth) {
  4851. calender += "<div class='ui-datepicker-group";
  4852. if (numMonths[1] > 1) {
  4853. switch (col) {
  4854. case 0: calender += " ui-datepicker-group-first";
  4855. cornerClass = " ui-corner-" + (isRTL ? "right" : "left"); break;
  4856. case numMonths[1]-1: calender += " ui-datepicker-group-last";
  4857. cornerClass = " ui-corner-" + (isRTL ? "left" : "right"); break;
  4858. default: calender += " ui-datepicker-group-middle"; cornerClass = ""; break;
  4859. }
  4860. }
  4861. calender += "'>";
  4862. }
  4863. calender += "<div class='ui-datepicker-header ui-widget-header ui-helper-clearfix" + cornerClass + "'>" +
  4864. (/all|left/.test(cornerClass) && row === 0 ? (isRTL ? next : prev) : "") +
  4865. (/all|right/.test(cornerClass) && row === 0 ? (isRTL ? prev : next) : "") +
  4866. this._generateMonthYearHeader(inst, drawMonth, drawYear, minDate, maxDate,
  4867. row > 0 || col > 0, monthNames, monthNamesShort) + // draw month headers
  4868. "</div><table class='ui-datepicker-calendar'><thead>" +
  4869. "<tr>";
  4870. thead = (showWeek ? "<th class='ui-datepicker-week-col'>" + this._get(inst, "weekHeader") + "</th>" : "");
  4871. for (dow = 0; dow < 7; dow++) { // days of the week
  4872. day = (dow + firstDay) % 7;
  4873. thead += "<th scope='col'" + ((dow + firstDay + 6) % 7 >= 5 ? " class='ui-datepicker-week-end'" : "") + ">" +
  4874. "<span title='" + dayNames[day] + "'>" + dayNamesMin[day] + "</span></th>";
  4875. }
  4876. calender += thead + "</tr></thead><tbody>";
  4877. daysInMonth = this._getDaysInMonth(drawYear, drawMonth);
  4878. if (drawYear === inst.selectedYear && drawMonth === inst.selectedMonth) {
  4879. inst.selectedDay = Math.min(inst.selectedDay, daysInMonth);
  4880. }
  4881. leadDays = (this._getFirstDayOfMonth(drawYear, drawMonth) - firstDay + 7) % 7;
  4882. curRows = Math.ceil((leadDays + daysInMonth) / 7); // calculate the number of rows to generate
  4883. numRows = (isMultiMonth ? this.maxRows > curRows ? this.maxRows : curRows : curRows); //If multiple months, use the higher number of rows (see #7043)
  4884. this.maxRows = numRows;
  4885. printDate = this._daylightSavingAdjust(new Date(drawYear, drawMonth, 1 - leadDays));
  4886. for (dRow = 0; dRow < numRows; dRow++) { // create date picker rows
  4887. calender += "<tr>";
  4888. tbody = (!showWeek ? "" : "<td class='ui-datepicker-week-col'>" +
  4889. this._get(inst, "calculateWeek")(printDate) + "</td>");
  4890. for (dow = 0; dow < 7; dow++) { // create date picker days
  4891. daySettings = (beforeShowDay ?
  4892. beforeShowDay.apply((inst.input ? inst.input[0] : null), [printDate]) : [true, ""]);
  4893. otherMonth = (printDate.getMonth() !== drawMonth);
  4894. unselectable = (otherMonth && !selectOtherMonths) || !daySettings[0] ||
  4895. (minDate && printDate < minDate) || (maxDate && printDate > maxDate);
  4896. tbody += "<td class='" +
  4897. ((dow + firstDay + 6) % 7 >= 5 ? " ui-datepicker-week-end" : "") + // highlight weekends
  4898. (otherMonth ? " ui-datepicker-other-month" : "") + // highlight days from other months
  4899. ((printDate.getTime() === selectedDate.getTime() && drawMonth === inst.selectedMonth && inst._keyEvent) || // user pressed key
  4900. (defaultDate.getTime() === printDate.getTime() && defaultDate.getTime() === selectedDate.getTime()) ?
  4901. // or defaultDate is current printedDate and defaultDate is selectedDate
  4902. " " + this._dayOverClass : "") + // highlight selected day
  4903. (unselectable ? " " + this._unselectableClass + " ui-state-disabled": "") + // highlight unselectable days
  4904. (otherMonth && !showOtherMonths ? "" : " " + daySettings[1] + // highlight custom dates
  4905. (printDate.getTime() === currentDate.getTime() ? " " + this._currentClass : "") + // highlight selected day
  4906. (printDate.getTime() === today.getTime() ? " ui-datepicker-today" : "")) + "'" + // highlight today (if different)
  4907. ((!otherMonth || showOtherMonths) && daySettings[2] ? " title='" + daySettings[2].replace(/'/g, "&#39;") + "'" : "") + // cell title
  4908. (unselectable ? "" : " data-handler='selectDay' data-event='click' data-month='" + printDate.getMonth() + "' data-year='" + printDate.getFullYear() + "'") + ">" + // actions
  4909. (otherMonth && !showOtherMonths ? "&#xa0;" : // display for other months
  4910. (unselectable ? "<span class='ui-state-default'>" + printDate.getDate() + "</span>" : "<a class='ui-state-default" +
  4911. (printDate.getTime() === today.getTime() ? " ui-state-highlight" : "") +
  4912. (printDate.getTime() === currentDate.getTime() ? " ui-state-active" : "") + // highlight selected day
  4913. (otherMonth ? " ui-priority-secondary" : "") + // distinguish dates from other months
  4914. "' href='#'>" + printDate.getDate() + "</a>")) + "</td>"; // display selectable date
  4915. printDate.setDate(printDate.getDate() + 1);
  4916. printDate = this._daylightSavingAdjust(printDate);
  4917. }
  4918. calender += tbody + "</tr>";
  4919. }
  4920. drawMonth++;
  4921. if (drawMonth > 11) {
  4922. drawMonth = 0;
  4923. drawYear++;
  4924. }
  4925. calender += "</tbody></table>" + (isMultiMonth ? "</div>" +
  4926. ((numMonths[0] > 0 && col === numMonths[1]-1) ? "<div class='ui-datepicker-row-break'></div>" : "") : "");
  4927. group += calender;
  4928. }
  4929. html += group;
  4930. }
  4931. html += buttonPanel;
  4932. inst._keyEvent = false;
  4933. return html;
  4934. },
  4935. /* Generate the month and year header. */
  4936. _generateMonthYearHeader: function(inst, drawMonth, drawYear, minDate, maxDate,
  4937. secondary, monthNames, monthNamesShort) {
  4938. var inMinYear, inMaxYear, month, years, thisYear, determineYear, year, endYear,
  4939. changeMonth = this._get(inst, "changeMonth"),
  4940. changeYear = this._get(inst, "changeYear"),
  4941. showMonthAfterYear = this._get(inst, "showMonthAfterYear"),
  4942. html = "<div class='ui-datepicker-title'>",
  4943. monthHtml = "";
  4944. // month selection
  4945. if (secondary || !changeMonth) {
  4946. monthHtml += "<span class='ui-datepicker-month'>" + monthNames[drawMonth] + "</span>";
  4947. } else {
  4948. inMinYear = (minDate && minDate.getFullYear() === drawYear);
  4949. inMaxYear = (maxDate && maxDate.getFullYear() === drawYear);
  4950. monthHtml += "<select class='ui-datepicker-month' data-handler='selectMonth' data-event='change'>";
  4951. for ( month = 0; month < 12; month++) {
  4952. if ((!inMinYear || month >= minDate.getMonth()) && (!inMaxYear || month <= maxDate.getMonth())) {
  4953. monthHtml += "<option value='" + month + "'" +
  4954. (month === drawMonth ? " selected='selected'" : "") +
  4955. ">" + monthNamesShort[month] + "</option>";
  4956. }
  4957. }
  4958. monthHtml += "</select>";
  4959. }
  4960. if (!showMonthAfterYear) {
  4961. html += monthHtml + (secondary || !(changeMonth && changeYear) ? "&#xa0;" : "");
  4962. }
  4963. // year selection
  4964. if ( !inst.yearshtml ) {
  4965. inst.yearshtml = "";
  4966. if (secondary || !changeYear) {
  4967. html += "<span class='ui-datepicker-year'>" + drawYear + "</span>";
  4968. } else {
  4969. // determine range of years to display
  4970. years = this._get(inst, "yearRange").split(":");
  4971. thisYear = new Date().getFullYear();
  4972. determineYear = function(value) {
  4973. var year = (value.match(/c[+\-].*/) ? drawYear + parseInt(value.substring(1), 10) :
  4974. (value.match(/[+\-].*/) ? thisYear + parseInt(value, 10) :
  4975. parseInt(value, 10)));
  4976. return (isNaN(year) ? thisYear : year);
  4977. };
  4978. year = determineYear(years[0]);
  4979. endYear = Math.max(year, determineYear(years[1] || ""));
  4980. year = (minDate ? Math.max(year, minDate.getFullYear()) : year);
  4981. endYear = (maxDate ? Math.min(endYear, maxDate.getFullYear()) : endYear);
  4982. inst.yearshtml += "<select class='ui-datepicker-year' data-handler='selectYear' data-event='change'>";
  4983. for (; year <= endYear; year++) {
  4984. inst.yearshtml += "<option value='" + year + "'" +
  4985. (year === drawYear ? " selected='selected'" : "") +
  4986. ">" + year + "</option>";
  4987. }
  4988. inst.yearshtml += "</select>";
  4989. html += inst.yearshtml;
  4990. inst.yearshtml = null;
  4991. }
  4992. }
  4993. html += this._get(inst, "yearSuffix");
  4994. if (showMonthAfterYear) {
  4995. html += (secondary || !(changeMonth && changeYear) ? "&#xa0;" : "") + monthHtml;
  4996. }
  4997. html += "</div>"; // Close datepicker_header
  4998. return html;
  4999. },
  5000. /* Adjust one of the date sub-fields. */
  5001. _adjustInstDate: function(inst, offset, period) {
  5002. var year = inst.drawYear + (period === "Y" ? offset : 0),
  5003. month = inst.drawMonth + (period === "M" ? offset : 0),
  5004. day = Math.min(inst.selectedDay, this._getDaysInMonth(year, month)) + (period === "D" ? offset : 0),
  5005. date = this._restrictMinMax(inst, this._daylightSavingAdjust(new Date(year, month, day)));
  5006. inst.selectedDay = date.getDate();
  5007. inst.drawMonth = inst.selectedMonth = date.getMonth();
  5008. inst.drawYear = inst.selectedYear = date.getFullYear();
  5009. if (period === "M" || period === "Y") {
  5010. this._notifyChange(inst);
  5011. }
  5012. },
  5013. /* Ensure a date is within any min/max bounds. */
  5014. _restrictMinMax: function(inst, date) {
  5015. var minDate = this._getMinMaxDate(inst, "min"),
  5016. maxDate = this._getMinMaxDate(inst, "max"),
  5017. newDate = (minDate && date < minDate ? minDate : date);
  5018. return (maxDate && newDate > maxDate ? maxDate : newDate);
  5019. },
  5020. /* Notify change of month/year. */
  5021. _notifyChange: function(inst) {
  5022. var onChange = this._get(inst, "onChangeMonthYear");
  5023. if (onChange) {
  5024. onChange.apply((inst.input ? inst.input[0] : null),
  5025. [inst.selectedYear, inst.selectedMonth + 1, inst]);
  5026. }
  5027. },
  5028. /* Determine the number of months to show. */
  5029. _getNumberOfMonths: function(inst) {
  5030. var numMonths = this._get(inst, "numberOfMonths");
  5031. return (numMonths == null ? [1, 1] : (typeof numMonths === "number" ? [1, numMonths] : numMonths));
  5032. },
  5033. /* Determine the current maximum date - ensure no time components are set. */
  5034. _getMinMaxDate: function(inst, minMax) {
  5035. return this._determineDate(inst, this._get(inst, minMax + "Date"), null);
  5036. },
  5037. /* Find the number of days in a given month. */
  5038. _getDaysInMonth: function(year, month) {
  5039. return 32 - this._daylightSavingAdjust(new Date(year, month, 32)).getDate();
  5040. },
  5041. /* Find the day of the week of the first of a month. */
  5042. _getFirstDayOfMonth: function(year, month) {
  5043. return new Date(year, month, 1).getDay();
  5044. },
  5045. /* Determines if we should allow a "next/prev" month display change. */
  5046. _canAdjustMonth: function(inst, offset, curYear, curMonth) {
  5047. var numMonths = this._getNumberOfMonths(inst),
  5048. date = this._daylightSavingAdjust(new Date(curYear,
  5049. curMonth + (offset < 0 ? offset : numMonths[0] * numMonths[1]), 1));
  5050. if (offset < 0) {
  5051. date.setDate(this._getDaysInMonth(date.getFullYear(), date.getMonth()));
  5052. }
  5053. return this._isInRange(inst, date);
  5054. },
  5055. /* Is the given date in the accepted range? */
  5056. _isInRange: function(inst, date) {
  5057. var yearSplit, currentYear,
  5058. minDate = this._getMinMaxDate(inst, "min"),
  5059. maxDate = this._getMinMaxDate(inst, "max"),
  5060. minYear = null,
  5061. maxYear = null,
  5062. years = this._get(inst, "yearRange");
  5063. if (years){
  5064. yearSplit = years.split(":");
  5065. currentYear = new Date().getFullYear();
  5066. minYear = parseInt(yearSplit[0], 10);
  5067. maxYear = parseInt(yearSplit[1], 10);
  5068. if ( yearSplit[0].match(/[+\-].*/) ) {
  5069. minYear += currentYear;
  5070. }
  5071. if ( yearSplit[1].match(/[+\-].*/) ) {
  5072. maxYear += currentYear;
  5073. }
  5074. }
  5075. return ((!minDate || date.getTime() >= minDate.getTime()) &&
  5076. (!maxDate || date.getTime() <= maxDate.getTime()) &&
  5077. (!minYear || date.getFullYear() >= minYear) &&
  5078. (!maxYear || date.getFullYear() <= maxYear));
  5079. },
  5080. /* Provide the configuration settings for formatting/parsing. */
  5081. _getFormatConfig: function(inst) {
  5082. var shortYearCutoff = this._get(inst, "shortYearCutoff");
  5083. shortYearCutoff = (typeof shortYearCutoff !== "string" ? shortYearCutoff :
  5084. new Date().getFullYear() % 100 + parseInt(shortYearCutoff, 10));
  5085. return {shortYearCutoff: shortYearCutoff,
  5086. dayNamesShort: this._get(inst, "dayNamesShort"), dayNames: this._get(inst, "dayNames"),
  5087. monthNamesShort: this._get(inst, "monthNamesShort"), monthNames: this._get(inst, "monthNames")};
  5088. },
  5089. /* Format the given date for display. */
  5090. _formatDate: function(inst, day, month, year) {
  5091. if (!day) {
  5092. inst.currentDay = inst.selectedDay;
  5093. inst.currentMonth = inst.selectedMonth;
  5094. inst.currentYear = inst.selectedYear;
  5095. }
  5096. var date = (day ? (typeof day === "object" ? day :
  5097. this._daylightSavingAdjust(new Date(year, month, day))) :
  5098. this._daylightSavingAdjust(new Date(inst.currentYear, inst.currentMonth, inst.currentDay)));
  5099. return this.formatDate(this._get(inst, "dateFormat"), date, this._getFormatConfig(inst));
  5100. }
  5101. });
  5102. /*
  5103. * Bind hover events for datepicker elements.
  5104. * Done via delegate so the binding only occurs once in the lifetime of the parent div.
  5105. * Global datepicker_instActive, set by _updateDatepicker allows the handlers to find their way back to the active picker.
  5106. */
  5107. function datepicker_bindHover(dpDiv) {
  5108. var selector = "button, .ui-datepicker-prev, .ui-datepicker-next, .ui-datepicker-calendar td a";
  5109. return dpDiv.delegate(selector, "mouseout", function() {
  5110. $(this).removeClass("ui-state-hover");
  5111. if (this.className.indexOf("ui-datepicker-prev") !== -1) {
  5112. $(this).removeClass("ui-datepicker-prev-hover");
  5113. }
  5114. if (this.className.indexOf("ui-datepicker-next") !== -1) {
  5115. $(this).removeClass("ui-datepicker-next-hover");
  5116. }
  5117. })
  5118. .delegate( selector, "mouseover", datepicker_handleMouseover );
  5119. }
  5120. function datepicker_handleMouseover() {
  5121. if (!$.datepicker._isDisabledDatepicker( datepicker_instActive.inline? datepicker_instActive.dpDiv.parent()[0] : datepicker_instActive.input[0])) {
  5122. $(this).parents(".ui-datepicker-calendar").find("a").removeClass("ui-state-hover");
  5123. $(this).addClass("ui-state-hover");
  5124. if (this.className.indexOf("ui-datepicker-prev") !== -1) {
  5125. $(this).addClass("ui-datepicker-prev-hover");
  5126. }
  5127. if (this.className.indexOf("ui-datepicker-next") !== -1) {
  5128. $(this).addClass("ui-datepicker-next-hover");
  5129. }
  5130. }
  5131. }
  5132. /* jQuery extend now ignores nulls! */
  5133. function datepicker_extendRemove(target, props) {
  5134. $.extend(target, props);
  5135. for (var name in props) {
  5136. if (props[name] == null) {
  5137. target[name] = props[name];
  5138. }
  5139. }
  5140. return target;
  5141. }
  5142. /* Invoke the datepicker functionality.
  5143. @param options string - a command, optionally followed by additional parameters or
  5144. Object - settings for attaching new datepicker functionality
  5145. @return jQuery object */
  5146. $.fn.datepicker = function(options){
  5147. /* Verify an empty collection wasn't passed - Fixes #6976 */
  5148. if ( !this.length ) {
  5149. return this;
  5150. }
  5151. /* Initialise the date picker. */
  5152. if (!$.datepicker.initialized) {
  5153. $(document).mousedown($.datepicker._checkExternalClick);
  5154. $.datepicker.initialized = true;
  5155. }
  5156. /* Append datepicker main container to body if not exist. */
  5157. if ($("#"+$.datepicker._mainDivId).length === 0) {
  5158. $("body").append($.datepicker.dpDiv);
  5159. }
  5160. var otherArgs = Array.prototype.slice.call(arguments, 1);
  5161. if (typeof options === "string" && (options === "isDisabled" || options === "getDate" || options === "widget")) {
  5162. return $.datepicker["_" + options + "Datepicker"].
  5163. apply($.datepicker, [this[0]].concat(otherArgs));
  5164. }
  5165. if (options === "option" && arguments.length === 2 && typeof arguments[1] === "string") {
  5166. return $.datepicker["_" + options + "Datepicker"].
  5167. apply($.datepicker, [this[0]].concat(otherArgs));
  5168. }
  5169. return this.each(function() {
  5170. typeof options === "string" ?
  5171. $.datepicker["_" + options + "Datepicker"].
  5172. apply($.datepicker, [this].concat(otherArgs)) :
  5173. $.datepicker._attachDatepicker(this, options);
  5174. });
  5175. };
  5176. $.datepicker = new Datepicker(); // singleton instance
  5177. $.datepicker.initialized = false;
  5178. $.datepicker.uuid = new Date().getTime();
  5179. $.datepicker.version = "1.11.3";
  5180. var datepicker = $.datepicker;
  5181. /*!
  5182. * jQuery UI Draggable 1.11.3
  5183. * http://jqueryui.com
  5184. *
  5185. * Copyright jQuery Foundation and other contributors
  5186. * Released under the MIT license.
  5187. * http://jquery.org/license
  5188. *
  5189. * http://api.jqueryui.com/draggable/
  5190. */
  5191. $.widget("ui.draggable", $.ui.mouse, {
  5192. version: "1.11.3",
  5193. widgetEventPrefix: "drag",
  5194. options: {
  5195. addClasses: true,
  5196. appendTo: "parent",
  5197. axis: false,
  5198. connectToSortable: false,
  5199. containment: false,
  5200. cursor: "auto",
  5201. cursorAt: false,
  5202. grid: false,
  5203. handle: false,
  5204. helper: "original",
  5205. iframeFix: false,
  5206. opacity: false,
  5207. refreshPositions: false,
  5208. revert: false,
  5209. revertDuration: 500,
  5210. scope: "default",
  5211. scroll: true,
  5212. scrollSensitivity: 20,
  5213. scrollSpeed: 20,
  5214. snap: false,
  5215. snapMode: "both",
  5216. snapTolerance: 20,
  5217. stack: false,
  5218. zIndex: false,
  5219. // callbacks
  5220. drag: null,
  5221. start: null,
  5222. stop: null
  5223. },
  5224. _create: function() {
  5225. if ( this.options.helper === "original" ) {
  5226. this._setPositionRelative();
  5227. }
  5228. if (this.options.addClasses){
  5229. this.element.addClass("ui-draggable");
  5230. }
  5231. if (this.options.disabled){
  5232. this.element.addClass("ui-draggable-disabled");
  5233. }
  5234. this._setHandleClassName();
  5235. this._mouseInit();
  5236. },
  5237. _setOption: function( key, value ) {
  5238. this._super( key, value );
  5239. if ( key === "handle" ) {
  5240. this._removeHandleClassName();
  5241. this._setHandleClassName();
  5242. }
  5243. },
  5244. _destroy: function() {
  5245. if ( ( this.helper || this.element ).is( ".ui-draggable-dragging" ) ) {
  5246. this.destroyOnClear = true;
  5247. return;
  5248. }
  5249. this.element.removeClass( "ui-draggable ui-draggable-dragging ui-draggable-disabled" );
  5250. this._removeHandleClassName();
  5251. this._mouseDestroy();
  5252. },
  5253. _mouseCapture: function(event) {
  5254. var o = this.options;
  5255. this._blurActiveElement( event );
  5256. // among others, prevent a drag on a resizable-handle
  5257. if (this.helper || o.disabled || $(event.target).closest(".ui-resizable-handle").length > 0) {
  5258. return false;
  5259. }
  5260. //Quit if we're not on a valid handle
  5261. this.handle = this._getHandle(event);
  5262. if (!this.handle) {
  5263. return false;
  5264. }
  5265. this._blockFrames( o.iframeFix === true ? "iframe" : o.iframeFix );
  5266. return true;
  5267. },
  5268. _blockFrames: function( selector ) {
  5269. this.iframeBlocks = this.document.find( selector ).map(function() {
  5270. var iframe = $( this );
  5271. return $( "<div>" )
  5272. .css( "position", "absolute" )
  5273. .appendTo( iframe.parent() )
  5274. .outerWidth( iframe.outerWidth() )
  5275. .outerHeight( iframe.outerHeight() )
  5276. .offset( iframe.offset() )[ 0 ];
  5277. });
  5278. },
  5279. _unblockFrames: function() {
  5280. if ( this.iframeBlocks ) {
  5281. this.iframeBlocks.remove();
  5282. delete this.iframeBlocks;
  5283. }
  5284. },
  5285. _blurActiveElement: function( event ) {
  5286. var document = this.document[ 0 ];
  5287. // Only need to blur if the event occurred on the draggable itself, see #10527
  5288. if ( !this.handleElement.is( event.target ) ) {
  5289. return;
  5290. }
  5291. // support: IE9
  5292. // IE9 throws an "Unspecified error" accessing document.activeElement from an <iframe>
  5293. try {
  5294. // Support: IE9, IE10
  5295. // If the <body> is blurred, IE will switch windows, see #9520
  5296. if ( document.activeElement && document.activeElement.nodeName.toLowerCase() !== "body" ) {
  5297. // Blur any element that currently has focus, see #4261
  5298. $( document.activeElement ).blur();
  5299. }
  5300. } catch ( error ) {}
  5301. },
  5302. _mouseStart: function(event) {
  5303. var o = this.options;
  5304. //Create and append the visible helper
  5305. this.helper = this._createHelper(event);
  5306. this.helper.addClass("ui-draggable-dragging");
  5307. //Cache the helper size
  5308. this._cacheHelperProportions();
  5309. //If ddmanager is used for droppables, set the global draggable
  5310. if ($.ui.ddmanager) {
  5311. $.ui.ddmanager.current = this;
  5312. }
  5313. /*
  5314. * - Position generation -
  5315. * This block generates everything position related - it's the core of draggables.
  5316. */
  5317. //Cache the margins of the original element
  5318. this._cacheMargins();
  5319. //Store the helper's css position
  5320. this.cssPosition = this.helper.css( "position" );
  5321. this.scrollParent = this.helper.scrollParent( true );
  5322. this.offsetParent = this.helper.offsetParent();
  5323. this.hasFixedAncestor = this.helper.parents().filter(function() {
  5324. return $( this ).css( "position" ) === "fixed";
  5325. }).length > 0;
  5326. //The element's absolute position on the page minus margins
  5327. this.positionAbs = this.element.offset();
  5328. this._refreshOffsets( event );
  5329. //Generate the original position
  5330. this.originalPosition = this.position = this._generatePosition( event, false );
  5331. this.originalPageX = event.pageX;
  5332. this.originalPageY = event.pageY;
  5333. //Adjust the mouse offset relative to the helper if "cursorAt" is supplied
  5334. (o.cursorAt && this._adjustOffsetFromHelper(o.cursorAt));
  5335. //Set a containment if given in the options
  5336. this._setContainment();
  5337. //Trigger event + callbacks
  5338. if (this._trigger("start", event) === false) {
  5339. this._clear();
  5340. return false;
  5341. }
  5342. //Recache the helper size
  5343. this._cacheHelperProportions();
  5344. //Prepare the droppable offsets
  5345. if ($.ui.ddmanager && !o.dropBehaviour) {
  5346. $.ui.ddmanager.prepareOffsets(this, event);
  5347. }
  5348. // Reset helper's right/bottom css if they're set and set explicit width/height instead
  5349. // as this prevents resizing of elements with right/bottom set (see #7772)
  5350. this._normalizeRightBottom();
  5351. this._mouseDrag(event, true); //Execute the drag once - this causes the helper not to be visible before getting its correct position
  5352. //If the ddmanager is used for droppables, inform the manager that dragging has started (see #5003)
  5353. if ( $.ui.ddmanager ) {
  5354. $.ui.ddmanager.dragStart(this, event);
  5355. }
  5356. return true;
  5357. },
  5358. _refreshOffsets: function( event ) {
  5359. this.offset = {
  5360. top: this.positionAbs.top - this.margins.top,
  5361. left: this.positionAbs.left - this.margins.left,
  5362. scroll: false,
  5363. parent: this._getParentOffset(),
  5364. relative: this._getRelativeOffset()
  5365. };
  5366. this.offset.click = {
  5367. left: event.pageX - this.offset.left,
  5368. top: event.pageY - this.offset.top
  5369. };
  5370. },
  5371. _mouseDrag: function(event, noPropagation) {
  5372. // reset any necessary cached properties (see #5009)
  5373. if ( this.hasFixedAncestor ) {
  5374. this.offset.parent = this._getParentOffset();
  5375. }
  5376. //Compute the helpers position
  5377. this.position = this._generatePosition( event, true );
  5378. this.positionAbs = this._convertPositionTo("absolute");
  5379. //Call plugins and callbacks and use the resulting position if something is returned
  5380. if (!noPropagation) {
  5381. var ui = this._uiHash();
  5382. if (this._trigger("drag", event, ui) === false) {
  5383. this._mouseUp({});
  5384. return false;
  5385. }
  5386. this.position = ui.position;
  5387. }
  5388. this.helper[ 0 ].style.left = this.position.left + "px";
  5389. this.helper[ 0 ].style.top = this.position.top + "px";
  5390. if ($.ui.ddmanager) {
  5391. $.ui.ddmanager.drag(this, event);
  5392. }
  5393. return false;
  5394. },
  5395. _mouseStop: function(event) {
  5396. //If we are using droppables, inform the manager about the drop
  5397. var that = this,
  5398. dropped = false;
  5399. if ($.ui.ddmanager && !this.options.dropBehaviour) {
  5400. dropped = $.ui.ddmanager.drop(this, event);
  5401. }
  5402. //if a drop comes from outside (a sortable)
  5403. if (this.dropped) {
  5404. dropped = this.dropped;
  5405. this.dropped = false;
  5406. }
  5407. if ((this.options.revert === "invalid" && !dropped) || (this.options.revert === "valid" && dropped) || this.options.revert === true || ($.isFunction(this.options.revert) && this.options.revert.call(this.element, dropped))) {
  5408. $(this.helper).animate(this.originalPosition, parseInt(this.options.revertDuration, 10), function() {
  5409. if (that._trigger("stop", event) !== false) {
  5410. that._clear();
  5411. }
  5412. });
  5413. } else {
  5414. if (this._trigger("stop", event) !== false) {
  5415. this._clear();
  5416. }
  5417. }
  5418. return false;
  5419. },
  5420. _mouseUp: function( event ) {
  5421. this._unblockFrames();
  5422. //If the ddmanager is used for droppables, inform the manager that dragging has stopped (see #5003)
  5423. if ( $.ui.ddmanager ) {
  5424. $.ui.ddmanager.dragStop(this, event);
  5425. }
  5426. // Only need to focus if the event occurred on the draggable itself, see #10527
  5427. if ( this.handleElement.is( event.target ) ) {
  5428. // The interaction is over; whether or not the click resulted in a drag, focus the element
  5429. this.element.focus();
  5430. }
  5431. return $.ui.mouse.prototype._mouseUp.call(this, event);
  5432. },
  5433. cancel: function() {
  5434. if (this.helper.is(".ui-draggable-dragging")) {
  5435. this._mouseUp({});
  5436. } else {
  5437. this._clear();
  5438. }
  5439. return this;
  5440. },
  5441. _getHandle: function(event) {
  5442. return this.options.handle ?
  5443. !!$( event.target ).closest( this.element.find( this.options.handle ) ).length :
  5444. true;
  5445. },
  5446. _setHandleClassName: function() {
  5447. this.handleElement = this.options.handle ?
  5448. this.element.find( this.options.handle ) : this.element;
  5449. this.handleElement.addClass( "ui-draggable-handle" );
  5450. },
  5451. _removeHandleClassName: function() {
  5452. this.handleElement.removeClass( "ui-draggable-handle" );
  5453. },
  5454. _createHelper: function(event) {
  5455. var o = this.options,
  5456. helperIsFunction = $.isFunction( o.helper ),
  5457. helper = helperIsFunction ?
  5458. $( o.helper.apply( this.element[ 0 ], [ event ] ) ) :
  5459. ( o.helper === "clone" ?
  5460. this.element.clone().removeAttr( "id" ) :
  5461. this.element );
  5462. if (!helper.parents("body").length) {
  5463. helper.appendTo((o.appendTo === "parent" ? this.element[0].parentNode : o.appendTo));
  5464. }
  5465. // http://bugs.jqueryui.com/ticket/9446
  5466. // a helper function can return the original element
  5467. // which wouldn't have been set to relative in _create
  5468. if ( helperIsFunction && helper[ 0 ] === this.element[ 0 ] ) {
  5469. this._setPositionRelative();
  5470. }
  5471. if (helper[0] !== this.element[0] && !(/(fixed|absolute)/).test(helper.css("position"))) {
  5472. helper.css("position", "absolute");
  5473. }
  5474. return helper;
  5475. },
  5476. _setPositionRelative: function() {
  5477. if ( !( /^(?:r|a|f)/ ).test( this.element.css( "position" ) ) ) {
  5478. this.element[ 0 ].style.position = "relative";
  5479. }
  5480. },
  5481. _adjustOffsetFromHelper: function(obj) {
  5482. if (typeof obj === "string") {
  5483. obj = obj.split(" ");
  5484. }
  5485. if ($.isArray(obj)) {
  5486. obj = { left: +obj[0], top: +obj[1] || 0 };
  5487. }
  5488. if ("left" in obj) {
  5489. this.offset.click.left = obj.left + this.margins.left;
  5490. }
  5491. if ("right" in obj) {
  5492. this.offset.click.left = this.helperProportions.width - obj.right + this.margins.left;
  5493. }
  5494. if ("top" in obj) {
  5495. this.offset.click.top = obj.top + this.margins.top;
  5496. }
  5497. if ("bottom" in obj) {
  5498. this.offset.click.top = this.helperProportions.height - obj.bottom + this.margins.top;
  5499. }
  5500. },
  5501. _isRootNode: function( element ) {
  5502. return ( /(html|body)/i ).test( element.tagName ) || element === this.document[ 0 ];
  5503. },
  5504. _getParentOffset: function() {
  5505. //Get the offsetParent and cache its position
  5506. var po = this.offsetParent.offset(),
  5507. document = this.document[ 0 ];
  5508. // This is a special case where we need to modify a offset calculated on start, since the following happened:
  5509. // 1. The position of the helper is absolute, so it's position is calculated based on the next positioned parent
  5510. // 2. The actual offset parent is a child of the scroll parent, and the scroll parent isn't the document, which means that
  5511. // the scroll is included in the initial calculation of the offset of the parent, and never recalculated upon drag
  5512. if (this.cssPosition === "absolute" && this.scrollParent[0] !== document && $.contains(this.scrollParent[0], this.offsetParent[0])) {
  5513. po.left += this.scrollParent.scrollLeft();
  5514. po.top += this.scrollParent.scrollTop();
  5515. }
  5516. if ( this._isRootNode( this.offsetParent[ 0 ] ) ) {
  5517. po = { top: 0, left: 0 };
  5518. }
  5519. return {
  5520. top: po.top + (parseInt(this.offsetParent.css("borderTopWidth"), 10) || 0),
  5521. left: po.left + (parseInt(this.offsetParent.css("borderLeftWidth"), 10) || 0)
  5522. };
  5523. },
  5524. _getRelativeOffset: function() {
  5525. if ( this.cssPosition !== "relative" ) {
  5526. return { top: 0, left: 0 };
  5527. }
  5528. var p = this.element.position(),
  5529. scrollIsRootNode = this._isRootNode( this.scrollParent[ 0 ] );
  5530. return {
  5531. top: p.top - ( parseInt(this.helper.css( "top" ), 10) || 0 ) + ( !scrollIsRootNode ? this.scrollParent.scrollTop() : 0 ),
  5532. left: p.left - ( parseInt(this.helper.css( "left" ), 10) || 0 ) + ( !scrollIsRootNode ? this.scrollParent.scrollLeft() : 0 )
  5533. };
  5534. },
  5535. _cacheMargins: function() {
  5536. this.margins = {
  5537. left: (parseInt(this.element.css("marginLeft"), 10) || 0),
  5538. top: (parseInt(this.element.css("marginTop"), 10) || 0),
  5539. right: (parseInt(this.element.css("marginRight"), 10) || 0),
  5540. bottom: (parseInt(this.element.css("marginBottom"), 10) || 0)
  5541. };
  5542. },
  5543. _cacheHelperProportions: function() {
  5544. this.helperProportions = {
  5545. width: this.helper.outerWidth(),
  5546. height: this.helper.outerHeight()
  5547. };
  5548. },
  5549. _setContainment: function() {
  5550. var isUserScrollable, c, ce,
  5551. o = this.options,
  5552. document = this.document[ 0 ];
  5553. this.relativeContainer = null;
  5554. if ( !o.containment ) {
  5555. this.containment = null;
  5556. return;
  5557. }
  5558. if ( o.containment === "window" ) {
  5559. this.containment = [
  5560. $( window ).scrollLeft() - this.offset.relative.left - this.offset.parent.left,
  5561. $( window ).scrollTop() - this.offset.relative.top - this.offset.parent.top,
  5562. $( window ).scrollLeft() + $( window ).width() - this.helperProportions.width - this.margins.left,
  5563. $( window ).scrollTop() + ( $( window ).height() || document.body.parentNode.scrollHeight ) - this.helperProportions.height - this.margins.top
  5564. ];
  5565. return;
  5566. }
  5567. if ( o.containment === "document") {
  5568. this.containment = [
  5569. 0,
  5570. 0,
  5571. $( document ).width() - this.helperProportions.width - this.margins.left,
  5572. ( $( document ).height() || document.body.parentNode.scrollHeight ) - this.helperProportions.height - this.margins.top
  5573. ];
  5574. return;
  5575. }
  5576. if ( o.containment.constructor === Array ) {
  5577. this.containment = o.containment;
  5578. return;
  5579. }
  5580. if ( o.containment === "parent" ) {
  5581. o.containment = this.helper[ 0 ].parentNode;
  5582. }
  5583. c = $( o.containment );
  5584. ce = c[ 0 ];
  5585. if ( !ce ) {
  5586. return;
  5587. }
  5588. isUserScrollable = /(scroll|auto)/.test( c.css( "overflow" ) );
  5589. this.containment = [
  5590. ( parseInt( c.css( "borderLeftWidth" ), 10 ) || 0 ) + ( parseInt( c.css( "paddingLeft" ), 10 ) || 0 ),
  5591. ( parseInt( c.css( "borderTopWidth" ), 10 ) || 0 ) + ( parseInt( c.css( "paddingTop" ), 10 ) || 0 ),
  5592. ( isUserScrollable ? Math.max( ce.scrollWidth, ce.offsetWidth ) : ce.offsetWidth ) -
  5593. ( parseInt( c.css( "borderRightWidth" ), 10 ) || 0 ) -
  5594. ( parseInt( c.css( "paddingRight" ), 10 ) || 0 ) -
  5595. this.helperProportions.width -
  5596. this.margins.left -
  5597. this.margins.right,
  5598. ( isUserScrollable ? Math.max( ce.scrollHeight, ce.offsetHeight ) : ce.offsetHeight ) -
  5599. ( parseInt( c.css( "borderBottomWidth" ), 10 ) || 0 ) -
  5600. ( parseInt( c.css( "paddingBottom" ), 10 ) || 0 ) -
  5601. this.helperProportions.height -
  5602. this.margins.top -
  5603. this.margins.bottom
  5604. ];
  5605. this.relativeContainer = c;
  5606. },
  5607. _convertPositionTo: function(d, pos) {
  5608. if (!pos) {
  5609. pos = this.position;
  5610. }
  5611. var mod = d === "absolute" ? 1 : -1,
  5612. scrollIsRootNode = this._isRootNode( this.scrollParent[ 0 ] );
  5613. return {
  5614. top: (
  5615. pos.top + // The absolute mouse position
  5616. this.offset.relative.top * mod + // Only for relative positioned nodes: Relative offset from element to offset parent
  5617. this.offset.parent.top * mod - // The offsetParent's offset without borders (offset + border)
  5618. ( ( this.cssPosition === "fixed" ? -this.offset.scroll.top : ( scrollIsRootNode ? 0 : this.offset.scroll.top ) ) * mod)
  5619. ),
  5620. left: (
  5621. pos.left + // The absolute mouse position
  5622. this.offset.relative.left * mod + // Only for relative positioned nodes: Relative offset from element to offset parent
  5623. this.offset.parent.left * mod - // The offsetParent's offset without borders (offset + border)
  5624. ( ( this.cssPosition === "fixed" ? -this.offset.scroll.left : ( scrollIsRootNode ? 0 : this.offset.scroll.left ) ) * mod)
  5625. )
  5626. };
  5627. },
  5628. _generatePosition: function( event, constrainPosition ) {
  5629. var containment, co, top, left,
  5630. o = this.options,
  5631. scrollIsRootNode = this._isRootNode( this.scrollParent[ 0 ] ),
  5632. pageX = event.pageX,
  5633. pageY = event.pageY;
  5634. // Cache the scroll
  5635. if ( !scrollIsRootNode || !this.offset.scroll ) {
  5636. this.offset.scroll = {
  5637. top: this.scrollParent.scrollTop(),
  5638. left: this.scrollParent.scrollLeft()
  5639. };
  5640. }
  5641. /*
  5642. * - Position constraining -
  5643. * Constrain the position to a mix of grid, containment.
  5644. */
  5645. // If we are not dragging yet, we won't check for options
  5646. if ( constrainPosition ) {
  5647. if ( this.containment ) {
  5648. if ( this.relativeContainer ){
  5649. co = this.relativeContainer.offset();
  5650. containment = [
  5651. this.containment[ 0 ] + co.left,
  5652. this.containment[ 1 ] + co.top,
  5653. this.containment[ 2 ] + co.left,
  5654. this.containment[ 3 ] + co.top
  5655. ];
  5656. } else {
  5657. containment = this.containment;
  5658. }
  5659. if (event.pageX - this.offset.click.left < containment[0]) {
  5660. pageX = containment[0] + this.offset.click.left;
  5661. }
  5662. if (event.pageY - this.offset.click.top < containment[1]) {
  5663. pageY = containment[1] + this.offset.click.top;
  5664. }
  5665. if (event.pageX - this.offset.click.left > containment[2]) {
  5666. pageX = containment[2] + this.offset.click.left;
  5667. }
  5668. if (event.pageY - this.offset.click.top > containment[3]) {
  5669. pageY = containment[3] + this.offset.click.top;
  5670. }
  5671. }
  5672. if (o.grid) {
  5673. //Check for grid elements set to 0 to prevent divide by 0 error causing invalid argument errors in IE (see ticket #6950)
  5674. top = o.grid[1] ? this.originalPageY + Math.round((pageY - this.originalPageY) / o.grid[1]) * o.grid[1] : this.originalPageY;
  5675. pageY = containment ? ((top - this.offset.click.top >= containment[1] || top - this.offset.click.top > containment[3]) ? top : ((top - this.offset.click.top >= containment[1]) ? top - o.grid[1] : top + o.grid[1])) : top;
  5676. left = o.grid[0] ? this.originalPageX + Math.round((pageX - this.originalPageX) / o.grid[0]) * o.grid[0] : this.originalPageX;
  5677. pageX = containment ? ((left - this.offset.click.left >= containment[0] || left - this.offset.click.left > containment[2]) ? left : ((left - this.offset.click.left >= containment[0]) ? left - o.grid[0] : left + o.grid[0])) : left;
  5678. }
  5679. if ( o.axis === "y" ) {
  5680. pageX = this.originalPageX;
  5681. }
  5682. if ( o.axis === "x" ) {
  5683. pageY = this.originalPageY;
  5684. }
  5685. }
  5686. return {
  5687. top: (
  5688. pageY - // The absolute mouse position
  5689. this.offset.click.top - // Click offset (relative to the element)
  5690. this.offset.relative.top - // Only for relative positioned nodes: Relative offset from element to offset parent
  5691. this.offset.parent.top + // The offsetParent's offset without borders (offset + border)
  5692. ( this.cssPosition === "fixed" ? -this.offset.scroll.top : ( scrollIsRootNode ? 0 : this.offset.scroll.top ) )
  5693. ),
  5694. left: (
  5695. pageX - // The absolute mouse position
  5696. this.offset.click.left - // Click offset (relative to the element)
  5697. this.offset.relative.left - // Only for relative positioned nodes: Relative offset from element to offset parent
  5698. this.offset.parent.left + // The offsetParent's offset without borders (offset + border)
  5699. ( this.cssPosition === "fixed" ? -this.offset.scroll.left : ( scrollIsRootNode ? 0 : this.offset.scroll.left ) )
  5700. )
  5701. };
  5702. },
  5703. _clear: function() {
  5704. this.helper.removeClass("ui-draggable-dragging");
  5705. if (this.helper[0] !== this.element[0] && !this.cancelHelperRemoval) {
  5706. this.helper.remove();
  5707. }
  5708. this.helper = null;
  5709. this.cancelHelperRemoval = false;
  5710. if ( this.destroyOnClear ) {
  5711. this.destroy();
  5712. }
  5713. },
  5714. _normalizeRightBottom: function() {
  5715. if ( this.options.axis !== "y" && this.helper.css( "right" ) !== "auto" ) {
  5716. this.helper.width( this.helper.width() );
  5717. this.helper.css( "right", "auto" );
  5718. }
  5719. if ( this.options.axis !== "x" && this.helper.css( "bottom" ) !== "auto" ) {
  5720. this.helper.height( this.helper.height() );
  5721. this.helper.css( "bottom", "auto" );
  5722. }
  5723. },
  5724. // From now on bulk stuff - mainly helpers
  5725. _trigger: function( type, event, ui ) {
  5726. ui = ui || this._uiHash();
  5727. $.ui.plugin.call( this, type, [ event, ui, this ], true );
  5728. // Absolute position and offset (see #6884 ) have to be recalculated after plugins
  5729. if ( /^(drag|start|stop)/.test( type ) ) {
  5730. this.positionAbs = this._convertPositionTo( "absolute" );
  5731. ui.offset = this.positionAbs;
  5732. }
  5733. return $.Widget.prototype._trigger.call( this, type, event, ui );
  5734. },
  5735. plugins: {},
  5736. _uiHash: function() {
  5737. return {
  5738. helper: this.helper,
  5739. position: this.position,
  5740. originalPosition: this.originalPosition,
  5741. offset: this.positionAbs
  5742. };
  5743. }
  5744. });
  5745. $.ui.plugin.add( "draggable", "connectToSortable", {
  5746. start: function( event, ui, draggable ) {
  5747. var uiSortable = $.extend( {}, ui, {
  5748. item: draggable.element
  5749. });
  5750. draggable.sortables = [];
  5751. $( draggable.options.connectToSortable ).each(function() {
  5752. var sortable = $( this ).sortable( "instance" );
  5753. if ( sortable && !sortable.options.disabled ) {
  5754. draggable.sortables.push( sortable );
  5755. // refreshPositions is called at drag start to refresh the containerCache
  5756. // which is used in drag. This ensures it's initialized and synchronized
  5757. // with any changes that might have happened on the page since initialization.
  5758. sortable.refreshPositions();
  5759. sortable._trigger("activate", event, uiSortable);
  5760. }
  5761. });
  5762. },
  5763. stop: function( event, ui, draggable ) {
  5764. var uiSortable = $.extend( {}, ui, {
  5765. item: draggable.element
  5766. });
  5767. draggable.cancelHelperRemoval = false;
  5768. $.each( draggable.sortables, function() {
  5769. var sortable = this;
  5770. if ( sortable.isOver ) {
  5771. sortable.isOver = 0;
  5772. // Allow this sortable to handle removing the helper
  5773. draggable.cancelHelperRemoval = true;
  5774. sortable.cancelHelperRemoval = false;
  5775. // Use _storedCSS To restore properties in the sortable,
  5776. // as this also handles revert (#9675) since the draggable
  5777. // may have modified them in unexpected ways (#8809)
  5778. sortable._storedCSS = {
  5779. position: sortable.placeholder.css( "position" ),
  5780. top: sortable.placeholder.css( "top" ),
  5781. left: sortable.placeholder.css( "left" )
  5782. };
  5783. sortable._mouseStop(event);
  5784. // Once drag has ended, the sortable should return to using
  5785. // its original helper, not the shared helper from draggable
  5786. sortable.options.helper = sortable.options._helper;
  5787. } else {
  5788. // Prevent this Sortable from removing the helper.
  5789. // However, don't set the draggable to remove the helper
  5790. // either as another connected Sortable may yet handle the removal.
  5791. sortable.cancelHelperRemoval = true;
  5792. sortable._trigger( "deactivate", event, uiSortable );
  5793. }
  5794. });
  5795. },
  5796. drag: function( event, ui, draggable ) {
  5797. $.each( draggable.sortables, function() {
  5798. var innermostIntersecting = false,
  5799. sortable = this;
  5800. // Copy over variables that sortable's _intersectsWith uses
  5801. sortable.positionAbs = draggable.positionAbs;
  5802. sortable.helperProportions = draggable.helperProportions;
  5803. sortable.offset.click = draggable.offset.click;
  5804. if ( sortable._intersectsWith( sortable.containerCache ) ) {
  5805. innermostIntersecting = true;
  5806. $.each( draggable.sortables, function() {
  5807. // Copy over variables that sortable's _intersectsWith uses
  5808. this.positionAbs = draggable.positionAbs;
  5809. this.helperProportions = draggable.helperProportions;
  5810. this.offset.click = draggable.offset.click;
  5811. if ( this !== sortable &&
  5812. this._intersectsWith( this.containerCache ) &&
  5813. $.contains( sortable.element[ 0 ], this.element[ 0 ] ) ) {
  5814. innermostIntersecting = false;
  5815. }
  5816. return innermostIntersecting;
  5817. });
  5818. }
  5819. if ( innermostIntersecting ) {
  5820. // If it intersects, we use a little isOver variable and set it once,
  5821. // so that the move-in stuff gets fired only once.
  5822. if ( !sortable.isOver ) {
  5823. sortable.isOver = 1;
  5824. sortable.currentItem = ui.helper
  5825. .appendTo( sortable.element )
  5826. .data( "ui-sortable-item", true );
  5827. // Store helper option to later restore it
  5828. sortable.options._helper = sortable.options.helper;
  5829. sortable.options.helper = function() {
  5830. return ui.helper[ 0 ];
  5831. };
  5832. // Fire the start events of the sortable with our passed browser event,
  5833. // and our own helper (so it doesn't create a new one)
  5834. event.target = sortable.currentItem[ 0 ];
  5835. sortable._mouseCapture( event, true );
  5836. sortable._mouseStart( event, true, true );
  5837. // Because the browser event is way off the new appended portlet,
  5838. // modify necessary variables to reflect the changes
  5839. sortable.offset.click.top = draggable.offset.click.top;
  5840. sortable.offset.click.left = draggable.offset.click.left;
  5841. sortable.offset.parent.left -= draggable.offset.parent.left -
  5842. sortable.offset.parent.left;
  5843. sortable.offset.parent.top -= draggable.offset.parent.top -
  5844. sortable.offset.parent.top;
  5845. draggable._trigger( "toSortable", event );
  5846. // Inform draggable that the helper is in a valid drop zone,
  5847. // used solely in the revert option to handle "valid/invalid".
  5848. draggable.dropped = sortable.element;
  5849. // Need to refreshPositions of all sortables in the case that
  5850. // adding to one sortable changes the location of the other sortables (#9675)
  5851. $.each( draggable.sortables, function() {
  5852. this.refreshPositions();
  5853. });
  5854. // hack so receive/update callbacks work (mostly)
  5855. draggable.currentItem = draggable.element;
  5856. sortable.fromOutside = draggable;
  5857. }
  5858. if ( sortable.currentItem ) {
  5859. sortable._mouseDrag( event );
  5860. // Copy the sortable's position because the draggable's can potentially reflect
  5861. // a relative position, while sortable is always absolute, which the dragged
  5862. // element has now become. (#8809)
  5863. ui.position = sortable.position;
  5864. }
  5865. } else {
  5866. // If it doesn't intersect with the sortable, and it intersected before,
  5867. // we fake the drag stop of the sortable, but make sure it doesn't remove
  5868. // the helper by using cancelHelperRemoval.
  5869. if ( sortable.isOver ) {
  5870. sortable.isOver = 0;
  5871. sortable.cancelHelperRemoval = true;
  5872. // Calling sortable's mouseStop would trigger a revert,
  5873. // so revert must be temporarily false until after mouseStop is called.
  5874. sortable.options._revert = sortable.options.revert;
  5875. sortable.options.revert = false;
  5876. sortable._trigger( "out", event, sortable._uiHash( sortable ) );
  5877. sortable._mouseStop( event, true );
  5878. // restore sortable behaviors that were modfied
  5879. // when the draggable entered the sortable area (#9481)
  5880. sortable.options.revert = sortable.options._revert;
  5881. sortable.options.helper = sortable.options._helper;
  5882. if ( sortable.placeholder ) {
  5883. sortable.placeholder.remove();
  5884. }
  5885. // Recalculate the draggable's offset considering the sortable
  5886. // may have modified them in unexpected ways (#8809)
  5887. draggable._refreshOffsets( event );
  5888. ui.position = draggable._generatePosition( event, true );
  5889. draggable._trigger( "fromSortable", event );
  5890. // Inform draggable that the helper is no longer in a valid drop zone
  5891. draggable.dropped = false;
  5892. // Need to refreshPositions of all sortables just in case removing
  5893. // from one sortable changes the location of other sortables (#9675)
  5894. $.each( draggable.sortables, function() {
  5895. this.refreshPositions();
  5896. });
  5897. }
  5898. }
  5899. });
  5900. }
  5901. });
  5902. $.ui.plugin.add("draggable", "cursor", {
  5903. start: function( event, ui, instance ) {
  5904. var t = $( "body" ),
  5905. o = instance.options;
  5906. if (t.css("cursor")) {
  5907. o._cursor = t.css("cursor");
  5908. }
  5909. t.css("cursor", o.cursor);
  5910. },
  5911. stop: function( event, ui, instance ) {
  5912. var o = instance.options;
  5913. if (o._cursor) {
  5914. $("body").css("cursor", o._cursor);
  5915. }
  5916. }
  5917. });
  5918. $.ui.plugin.add("draggable", "opacity", {
  5919. start: function( event, ui, instance ) {
  5920. var t = $( ui.helper ),
  5921. o = instance.options;
  5922. if (t.css("opacity")) {
  5923. o._opacity = t.css("opacity");
  5924. }
  5925. t.css("opacity", o.opacity);
  5926. },
  5927. stop: function( event, ui, instance ) {
  5928. var o = instance.options;
  5929. if (o._opacity) {
  5930. $(ui.helper).css("opacity", o._opacity);
  5931. }
  5932. }
  5933. });
  5934. $.ui.plugin.add("draggable", "scroll", {
  5935. start: function( event, ui, i ) {
  5936. if ( !i.scrollParentNotHidden ) {
  5937. i.scrollParentNotHidden = i.helper.scrollParent( false );
  5938. }
  5939. if ( i.scrollParentNotHidden[ 0 ] !== i.document[ 0 ] && i.scrollParentNotHidden[ 0 ].tagName !== "HTML" ) {
  5940. i.overflowOffset = i.scrollParentNotHidden.offset();
  5941. }
  5942. },
  5943. drag: function( event, ui, i ) {
  5944. var o = i.options,
  5945. scrolled = false,
  5946. scrollParent = i.scrollParentNotHidden[ 0 ],
  5947. document = i.document[ 0 ];
  5948. if ( scrollParent !== document && scrollParent.tagName !== "HTML" ) {
  5949. if ( !o.axis || o.axis !== "x" ) {
  5950. if ( ( i.overflowOffset.top + scrollParent.offsetHeight ) - event.pageY < o.scrollSensitivity ) {
  5951. scrollParent.scrollTop = scrolled = scrollParent.scrollTop + o.scrollSpeed;
  5952. } else if ( event.pageY - i.overflowOffset.top < o.scrollSensitivity ) {
  5953. scrollParent.scrollTop = scrolled = scrollParent.scrollTop - o.scrollSpeed;
  5954. }
  5955. }
  5956. if ( !o.axis || o.axis !== "y" ) {
  5957. if ( ( i.overflowOffset.left + scrollParent.offsetWidth ) - event.pageX < o.scrollSensitivity ) {
  5958. scrollParent.scrollLeft = scrolled = scrollParent.scrollLeft + o.scrollSpeed;
  5959. } else if ( event.pageX - i.overflowOffset.left < o.scrollSensitivity ) {
  5960. scrollParent.scrollLeft = scrolled = scrollParent.scrollLeft - o.scrollSpeed;
  5961. }
  5962. }
  5963. } else {
  5964. if (!o.axis || o.axis !== "x") {
  5965. if (event.pageY - $(document).scrollTop() < o.scrollSensitivity) {
  5966. scrolled = $(document).scrollTop($(document).scrollTop() - o.scrollSpeed);
  5967. } else if ($(window).height() - (event.pageY - $(document).scrollTop()) < o.scrollSensitivity) {
  5968. scrolled = $(document).scrollTop($(document).scrollTop() + o.scrollSpeed);
  5969. }
  5970. }
  5971. if (!o.axis || o.axis !== "y") {
  5972. if (event.pageX - $(document).scrollLeft() < o.scrollSensitivity) {
  5973. scrolled = $(document).scrollLeft($(document).scrollLeft() - o.scrollSpeed);
  5974. } else if ($(window).width() - (event.pageX - $(document).scrollLeft()) < o.scrollSensitivity) {
  5975. scrolled = $(document).scrollLeft($(document).scrollLeft() + o.scrollSpeed);
  5976. }
  5977. }
  5978. }
  5979. if (scrolled !== false && $.ui.ddmanager && !o.dropBehaviour) {
  5980. $.ui.ddmanager.prepareOffsets(i, event);
  5981. }
  5982. }
  5983. });
  5984. $.ui.plugin.add("draggable", "snap", {
  5985. start: function( event, ui, i ) {
  5986. var o = i.options;
  5987. i.snapElements = [];
  5988. $(o.snap.constructor !== String ? ( o.snap.items || ":data(ui-draggable)" ) : o.snap).each(function() {
  5989. var $t = $(this),
  5990. $o = $t.offset();
  5991. if (this !== i.element[0]) {
  5992. i.snapElements.push({
  5993. item: this,
  5994. width: $t.outerWidth(), height: $t.outerHeight(),
  5995. top: $o.top, left: $o.left
  5996. });
  5997. }
  5998. });
  5999. },
  6000. drag: function( event, ui, inst ) {
  6001. var ts, bs, ls, rs, l, r, t, b, i, first,
  6002. o = inst.options,
  6003. d = o.snapTolerance,
  6004. x1 = ui.offset.left, x2 = x1 + inst.helperProportions.width,
  6005. y1 = ui.offset.top, y2 = y1 + inst.helperProportions.height;
  6006. for (i = inst.snapElements.length - 1; i >= 0; i--){
  6007. l = inst.snapElements[i].left - inst.margins.left;
  6008. r = l + inst.snapElements[i].width;
  6009. t = inst.snapElements[i].top - inst.margins.top;
  6010. b = t + inst.snapElements[i].height;
  6011. if ( x2 < l - d || x1 > r + d || y2 < t - d || y1 > b + d || !$.contains( inst.snapElements[ i ].item.ownerDocument, inst.snapElements[ i ].item ) ) {
  6012. if (inst.snapElements[i].snapping) {
  6013. (inst.options.snap.release && inst.options.snap.release.call(inst.element, event, $.extend(inst._uiHash(), { snapItem: inst.snapElements[i].item })));
  6014. }
  6015. inst.snapElements[i].snapping = false;
  6016. continue;
  6017. }
  6018. if (o.snapMode !== "inner") {
  6019. ts = Math.abs(t - y2) <= d;
  6020. bs = Math.abs(b - y1) <= d;
  6021. ls = Math.abs(l - x2) <= d;
  6022. rs = Math.abs(r - x1) <= d;
  6023. if (ts) {
  6024. ui.position.top = inst._convertPositionTo("relative", { top: t - inst.helperProportions.height, left: 0 }).top;
  6025. }
  6026. if (bs) {
  6027. ui.position.top = inst._convertPositionTo("relative", { top: b, left: 0 }).top;
  6028. }
  6029. if (ls) {
  6030. ui.position.left = inst._convertPositionTo("relative", { top: 0, left: l - inst.helperProportions.width }).left;
  6031. }
  6032. if (rs) {
  6033. ui.position.left = inst._convertPositionTo("relative", { top: 0, left: r }).left;
  6034. }
  6035. }
  6036. first = (ts || bs || ls || rs);
  6037. if (o.snapMode !== "outer") {
  6038. ts = Math.abs(t - y1) <= d;
  6039. bs = Math.abs(b - y2) <= d;
  6040. ls = Math.abs(l - x1) <= d;
  6041. rs = Math.abs(r - x2) <= d;
  6042. if (ts) {
  6043. ui.position.top = inst._convertPositionTo("relative", { top: t, left: 0 }).top;
  6044. }
  6045. if (bs) {
  6046. ui.position.top = inst._convertPositionTo("relative", { top: b - inst.helperProportions.height, left: 0 }).top;
  6047. }
  6048. if (ls) {
  6049. ui.position.left = inst._convertPositionTo("relative", { top: 0, left: l }).left;
  6050. }
  6051. if (rs) {
  6052. ui.position.left = inst._convertPositionTo("relative", { top: 0, left: r - inst.helperProportions.width }).left;
  6053. }
  6054. }
  6055. if (!inst.snapElements[i].snapping && (ts || bs || ls || rs || first)) {
  6056. (inst.options.snap.snap && inst.options.snap.snap.call(inst.element, event, $.extend(inst._uiHash(), { snapItem: inst.snapElements[i].item })));
  6057. }
  6058. inst.snapElements[i].snapping = (ts || bs || ls || rs || first);
  6059. }
  6060. }
  6061. });
  6062. $.ui.plugin.add("draggable", "stack", {
  6063. start: function( event, ui, instance ) {
  6064. var min,
  6065. o = instance.options,
  6066. group = $.makeArray($(o.stack)).sort(function(a, b) {
  6067. return (parseInt($(a).css("zIndex"), 10) || 0) - (parseInt($(b).css("zIndex"), 10) || 0);
  6068. });
  6069. if (!group.length) { return; }
  6070. min = parseInt($(group[0]).css("zIndex"), 10) || 0;
  6071. $(group).each(function(i) {
  6072. $(this).css("zIndex", min + i);
  6073. });
  6074. this.css("zIndex", (min + group.length));
  6075. }
  6076. });
  6077. $.ui.plugin.add("draggable", "zIndex", {
  6078. start: function( event, ui, instance ) {
  6079. var t = $( ui.helper ),
  6080. o = instance.options;
  6081. if (t.css("zIndex")) {
  6082. o._zIndex = t.css("zIndex");
  6083. }
  6084. t.css("zIndex", o.zIndex);
  6085. },
  6086. stop: function( event, ui, instance ) {
  6087. var o = instance.options;
  6088. if (o._zIndex) {
  6089. $(ui.helper).css("zIndex", o._zIndex);
  6090. }
  6091. }
  6092. });
  6093. var draggable = $.ui.draggable;
  6094. /*!
  6095. * jQuery UI Resizable 1.11.3
  6096. * http://jqueryui.com
  6097. *
  6098. * Copyright jQuery Foundation and other contributors
  6099. * Released under the MIT license.
  6100. * http://jquery.org/license
  6101. *
  6102. * http://api.jqueryui.com/resizable/
  6103. */
  6104. $.widget("ui.resizable", $.ui.mouse, {
  6105. version: "1.11.3",
  6106. widgetEventPrefix: "resize",
  6107. options: {
  6108. alsoResize: false,
  6109. animate: false,
  6110. animateDuration: "slow",
  6111. animateEasing: "swing",
  6112. aspectRatio: false,
  6113. autoHide: false,
  6114. containment: false,
  6115. ghost: false,
  6116. grid: false,
  6117. handles: "e,s,se",
  6118. helper: false,
  6119. maxHeight: null,
  6120. maxWidth: null,
  6121. minHeight: 10,
  6122. minWidth: 10,
  6123. // See #7960
  6124. zIndex: 90,
  6125. // callbacks
  6126. resize: null,
  6127. start: null,
  6128. stop: null
  6129. },
  6130. _num: function( value ) {
  6131. return parseInt( value, 10 ) || 0;
  6132. },
  6133. _isNumber: function( value ) {
  6134. return !isNaN( parseInt( value, 10 ) );
  6135. },
  6136. _hasScroll: function( el, a ) {
  6137. if ( $( el ).css( "overflow" ) === "hidden") {
  6138. return false;
  6139. }
  6140. var scroll = ( a && a === "left" ) ? "scrollLeft" : "scrollTop",
  6141. has = false;
  6142. if ( el[ scroll ] > 0 ) {
  6143. return true;
  6144. }
  6145. // TODO: determine which cases actually cause this to happen
  6146. // if the element doesn't have the scroll set, see if it's possible to
  6147. // set the scroll
  6148. el[ scroll ] = 1;
  6149. has = ( el[ scroll ] > 0 );
  6150. el[ scroll ] = 0;
  6151. return has;
  6152. },
  6153. _create: function() {
  6154. var n, i, handle, axis, hname,
  6155. that = this,
  6156. o = this.options;
  6157. this.element.addClass("ui-resizable");
  6158. $.extend(this, {
  6159. _aspectRatio: !!(o.aspectRatio),
  6160. aspectRatio: o.aspectRatio,
  6161. originalElement: this.element,
  6162. _proportionallyResizeElements: [],
  6163. _helper: o.helper || o.ghost || o.animate ? o.helper || "ui-resizable-helper" : null
  6164. });
  6165. // Wrap the element if it cannot hold child nodes
  6166. if (this.element[0].nodeName.match(/^(canvas|textarea|input|select|button|img)$/i)) {
  6167. this.element.wrap(
  6168. $("<div class='ui-wrapper' style='overflow: hidden;'></div>").css({
  6169. position: this.element.css("position"),
  6170. width: this.element.outerWidth(),
  6171. height: this.element.outerHeight(),
  6172. top: this.element.css("top"),
  6173. left: this.element.css("left")
  6174. })
  6175. );
  6176. this.element = this.element.parent().data(
  6177. "ui-resizable", this.element.resizable( "instance" )
  6178. );
  6179. this.elementIsWrapper = true;
  6180. this.element.css({
  6181. marginLeft: this.originalElement.css("marginLeft"),
  6182. marginTop: this.originalElement.css("marginTop"),
  6183. marginRight: this.originalElement.css("marginRight"),
  6184. marginBottom: this.originalElement.css("marginBottom")
  6185. });
  6186. this.originalElement.css({
  6187. marginLeft: 0,
  6188. marginTop: 0,
  6189. marginRight: 0,
  6190. marginBottom: 0
  6191. });
  6192. // support: Safari
  6193. // Prevent Safari textarea resize
  6194. this.originalResizeStyle = this.originalElement.css("resize");
  6195. this.originalElement.css("resize", "none");
  6196. this._proportionallyResizeElements.push( this.originalElement.css({
  6197. position: "static",
  6198. zoom: 1,
  6199. display: "block"
  6200. }) );
  6201. // support: IE9
  6202. // avoid IE jump (hard set the margin)
  6203. this.originalElement.css({ margin: this.originalElement.css("margin") });
  6204. this._proportionallyResize();
  6205. }
  6206. this.handles = o.handles ||
  6207. ( !$(".ui-resizable-handle", this.element).length ?
  6208. "e,s,se" : {
  6209. n: ".ui-resizable-n",
  6210. e: ".ui-resizable-e",
  6211. s: ".ui-resizable-s",
  6212. w: ".ui-resizable-w",
  6213. se: ".ui-resizable-se",
  6214. sw: ".ui-resizable-sw",
  6215. ne: ".ui-resizable-ne",
  6216. nw: ".ui-resizable-nw"
  6217. } );
  6218. if (this.handles.constructor === String) {
  6219. if ( this.handles === "all") {
  6220. this.handles = "n,e,s,w,se,sw,ne,nw";
  6221. }
  6222. n = this.handles.split(",");
  6223. this.handles = {};
  6224. for (i = 0; i < n.length; i++) {
  6225. handle = $.trim(n[i]);
  6226. hname = "ui-resizable-" + handle;
  6227. axis = $("<div class='ui-resizable-handle " + hname + "'></div>");
  6228. axis.css({ zIndex: o.zIndex });
  6229. // TODO : What's going on here?
  6230. if ("se" === handle) {
  6231. axis.addClass("ui-icon ui-icon-gripsmall-diagonal-se");
  6232. }
  6233. this.handles[handle] = ".ui-resizable-" + handle;
  6234. this.element.append(axis);
  6235. }
  6236. }
  6237. this._renderAxis = function(target) {
  6238. var i, axis, padPos, padWrapper;
  6239. target = target || this.element;
  6240. for (i in this.handles) {
  6241. if (this.handles[i].constructor === String) {
  6242. this.handles[i] = this.element.children( this.handles[ i ] ).first().show();
  6243. }
  6244. if (this.elementIsWrapper && this.originalElement[0].nodeName.match(/^(textarea|input|select|button)$/i)) {
  6245. axis = $(this.handles[i], this.element);
  6246. padWrapper = /sw|ne|nw|se|n|s/.test(i) ? axis.outerHeight() : axis.outerWidth();
  6247. padPos = [ "padding",
  6248. /ne|nw|n/.test(i) ? "Top" :
  6249. /se|sw|s/.test(i) ? "Bottom" :
  6250. /^e$/.test(i) ? "Right" : "Left" ].join("");
  6251. target.css(padPos, padWrapper);
  6252. this._proportionallyResize();
  6253. }
  6254. // TODO: What's that good for? There's not anything to be executed left
  6255. if (!$(this.handles[i]).length) {
  6256. continue;
  6257. }
  6258. }
  6259. };
  6260. // TODO: make renderAxis a prototype function
  6261. this._renderAxis(this.element);
  6262. this._handles = $(".ui-resizable-handle", this.element)
  6263. .disableSelection();
  6264. this._handles.mouseover(function() {
  6265. if (!that.resizing) {
  6266. if (this.className) {
  6267. axis = this.className.match(/ui-resizable-(se|sw|ne|nw|n|e|s|w)/i);
  6268. }
  6269. that.axis = axis && axis[1] ? axis[1] : "se";
  6270. }
  6271. });
  6272. if (o.autoHide) {
  6273. this._handles.hide();
  6274. $(this.element)
  6275. .addClass("ui-resizable-autohide")
  6276. .mouseenter(function() {
  6277. if (o.disabled) {
  6278. return;
  6279. }
  6280. $(this).removeClass("ui-resizable-autohide");
  6281. that._handles.show();
  6282. })
  6283. .mouseleave(function() {
  6284. if (o.disabled) {
  6285. return;
  6286. }
  6287. if (!that.resizing) {
  6288. $(this).addClass("ui-resizable-autohide");
  6289. that._handles.hide();
  6290. }
  6291. });
  6292. }
  6293. this._mouseInit();
  6294. },
  6295. _destroy: function() {
  6296. this._mouseDestroy();
  6297. var wrapper,
  6298. _destroy = function(exp) {
  6299. $(exp)
  6300. .removeClass("ui-resizable ui-resizable-disabled ui-resizable-resizing")
  6301. .removeData("resizable")
  6302. .removeData("ui-resizable")
  6303. .unbind(".resizable")
  6304. .find(".ui-resizable-handle")
  6305. .remove();
  6306. };
  6307. // TODO: Unwrap at same DOM position
  6308. if (this.elementIsWrapper) {
  6309. _destroy(this.element);
  6310. wrapper = this.element;
  6311. this.originalElement.css({
  6312. position: wrapper.css("position"),
  6313. width: wrapper.outerWidth(),
  6314. height: wrapper.outerHeight(),
  6315. top: wrapper.css("top"),
  6316. left: wrapper.css("left")
  6317. }).insertAfter( wrapper );
  6318. wrapper.remove();
  6319. }
  6320. this.originalElement.css("resize", this.originalResizeStyle);
  6321. _destroy(this.originalElement);
  6322. return this;
  6323. },
  6324. _mouseCapture: function(event) {
  6325. var i, handle,
  6326. capture = false;
  6327. for (i in this.handles) {
  6328. handle = $(this.handles[i])[0];
  6329. if (handle === event.target || $.contains(handle, event.target)) {
  6330. capture = true;
  6331. }
  6332. }
  6333. return !this.options.disabled && capture;
  6334. },
  6335. _mouseStart: function(event) {
  6336. var curleft, curtop, cursor,
  6337. o = this.options,
  6338. el = this.element;
  6339. this.resizing = true;
  6340. this._renderProxy();
  6341. curleft = this._num(this.helper.css("left"));
  6342. curtop = this._num(this.helper.css("top"));
  6343. if (o.containment) {
  6344. curleft += $(o.containment).scrollLeft() || 0;
  6345. curtop += $(o.containment).scrollTop() || 0;
  6346. }
  6347. this.offset = this.helper.offset();
  6348. this.position = { left: curleft, top: curtop };
  6349. this.size = this._helper ? {
  6350. width: this.helper.width(),
  6351. height: this.helper.height()
  6352. } : {
  6353. width: el.width(),
  6354. height: el.height()
  6355. };
  6356. this.originalSize = this._helper ? {
  6357. width: el.outerWidth(),
  6358. height: el.outerHeight()
  6359. } : {
  6360. width: el.width(),
  6361. height: el.height()
  6362. };
  6363. this.sizeDiff = {
  6364. width: el.outerWidth() - el.width(),
  6365. height: el.outerHeight() - el.height()
  6366. };
  6367. this.originalPosition = { left: curleft, top: curtop };
  6368. this.originalMousePosition = { left: event.pageX, top: event.pageY };
  6369. this.aspectRatio = (typeof o.aspectRatio === "number") ?
  6370. o.aspectRatio :
  6371. ((this.originalSize.width / this.originalSize.height) || 1);
  6372. cursor = $(".ui-resizable-" + this.axis).css("cursor");
  6373. $("body").css("cursor", cursor === "auto" ? this.axis + "-resize" : cursor);
  6374. el.addClass("ui-resizable-resizing");
  6375. this._propagate("start", event);
  6376. return true;
  6377. },
  6378. _mouseDrag: function(event) {
  6379. var data, props,
  6380. smp = this.originalMousePosition,
  6381. a = this.axis,
  6382. dx = (event.pageX - smp.left) || 0,
  6383. dy = (event.pageY - smp.top) || 0,
  6384. trigger = this._change[a];
  6385. this._updatePrevProperties();
  6386. if (!trigger) {
  6387. return false;
  6388. }
  6389. data = trigger.apply(this, [ event, dx, dy ]);
  6390. this._updateVirtualBoundaries(event.shiftKey);
  6391. if (this._aspectRatio || event.shiftKey) {
  6392. data = this._updateRatio(data, event);
  6393. }
  6394. data = this._respectSize(data, event);
  6395. this._updateCache(data);
  6396. this._propagate("resize", event);
  6397. props = this._applyChanges();
  6398. if ( !this._helper && this._proportionallyResizeElements.length ) {
  6399. this._proportionallyResize();
  6400. }
  6401. if ( !$.isEmptyObject( props ) ) {
  6402. this._updatePrevProperties();
  6403. this._trigger( "resize", event, this.ui() );
  6404. this._applyChanges();
  6405. }
  6406. return false;
  6407. },
  6408. _mouseStop: function(event) {
  6409. this.resizing = false;
  6410. var pr, ista, soffseth, soffsetw, s, left, top,
  6411. o = this.options, that = this;
  6412. if (this._helper) {
  6413. pr = this._proportionallyResizeElements;
  6414. ista = pr.length && (/textarea/i).test(pr[0].nodeName);
  6415. soffseth = ista && this._hasScroll(pr[0], "left") ? 0 : that.sizeDiff.height;
  6416. soffsetw = ista ? 0 : that.sizeDiff.width;
  6417. s = {
  6418. width: (that.helper.width() - soffsetw),
  6419. height: (that.helper.height() - soffseth)
  6420. };
  6421. left = (parseInt(that.element.css("left"), 10) +
  6422. (that.position.left - that.originalPosition.left)) || null;
  6423. top = (parseInt(that.element.css("top"), 10) +
  6424. (that.position.top - that.originalPosition.top)) || null;
  6425. if (!o.animate) {
  6426. this.element.css($.extend(s, { top: top, left: left }));
  6427. }
  6428. that.helper.height(that.size.height);
  6429. that.helper.width(that.size.width);
  6430. if (this._helper && !o.animate) {
  6431. this._proportionallyResize();
  6432. }
  6433. }
  6434. $("body").css("cursor", "auto");
  6435. this.element.removeClass("ui-resizable-resizing");
  6436. this._propagate("stop", event);
  6437. if (this._helper) {
  6438. this.helper.remove();
  6439. }
  6440. return false;
  6441. },
  6442. _updatePrevProperties: function() {
  6443. this.prevPosition = {
  6444. top: this.position.top,
  6445. left: this.position.left
  6446. };
  6447. this.prevSize = {
  6448. width: this.size.width,
  6449. height: this.size.height
  6450. };
  6451. },
  6452. _applyChanges: function() {
  6453. var props = {};
  6454. if ( this.position.top !== this.prevPosition.top ) {
  6455. props.top = this.position.top + "px";
  6456. }
  6457. if ( this.position.left !== this.prevPosition.left ) {
  6458. props.left = this.position.left + "px";
  6459. }
  6460. if ( this.size.width !== this.prevSize.width ) {
  6461. props.width = this.size.width + "px";
  6462. }
  6463. if ( this.size.height !== this.prevSize.height ) {
  6464. props.height = this.size.height + "px";
  6465. }
  6466. this.helper.css( props );
  6467. return props;
  6468. },
  6469. _updateVirtualBoundaries: function(forceAspectRatio) {
  6470. var pMinWidth, pMaxWidth, pMinHeight, pMaxHeight, b,
  6471. o = this.options;
  6472. b = {
  6473. minWidth: this._isNumber(o.minWidth) ? o.minWidth : 0,
  6474. maxWidth: this._isNumber(o.maxWidth) ? o.maxWidth : Infinity,
  6475. minHeight: this._isNumber(o.minHeight) ? o.minHeight : 0,
  6476. maxHeight: this._isNumber(o.maxHeight) ? o.maxHeight : Infinity
  6477. };
  6478. if (this._aspectRatio || forceAspectRatio) {
  6479. pMinWidth = b.minHeight * this.aspectRatio;
  6480. pMinHeight = b.minWidth / this.aspectRatio;
  6481. pMaxWidth = b.maxHeight * this.aspectRatio;
  6482. pMaxHeight = b.maxWidth / this.aspectRatio;
  6483. if (pMinWidth > b.minWidth) {
  6484. b.minWidth = pMinWidth;
  6485. }
  6486. if (pMinHeight > b.minHeight) {
  6487. b.minHeight = pMinHeight;
  6488. }
  6489. if (pMaxWidth < b.maxWidth) {
  6490. b.maxWidth = pMaxWidth;
  6491. }
  6492. if (pMaxHeight < b.maxHeight) {
  6493. b.maxHeight = pMaxHeight;
  6494. }
  6495. }
  6496. this._vBoundaries = b;
  6497. },
  6498. _updateCache: function(data) {
  6499. this.offset = this.helper.offset();
  6500. if (this._isNumber(data.left)) {
  6501. this.position.left = data.left;
  6502. }
  6503. if (this._isNumber(data.top)) {
  6504. this.position.top = data.top;
  6505. }
  6506. if (this._isNumber(data.height)) {
  6507. this.size.height = data.height;
  6508. }
  6509. if (this._isNumber(data.width)) {
  6510. this.size.width = data.width;
  6511. }
  6512. },
  6513. _updateRatio: function( data ) {
  6514. var cpos = this.position,
  6515. csize = this.size,
  6516. a = this.axis;
  6517. if (this._isNumber(data.height)) {
  6518. data.width = (data.height * this.aspectRatio);
  6519. } else if (this._isNumber(data.width)) {
  6520. data.height = (data.width / this.aspectRatio);
  6521. }
  6522. if (a === "sw") {
  6523. data.left = cpos.left + (csize.width - data.width);
  6524. data.top = null;
  6525. }
  6526. if (a === "nw") {
  6527. data.top = cpos.top + (csize.height - data.height);
  6528. data.left = cpos.left + (csize.width - data.width);
  6529. }
  6530. return data;
  6531. },
  6532. _respectSize: function( data ) {
  6533. var o = this._vBoundaries,
  6534. a = this.axis,
  6535. ismaxw = this._isNumber(data.width) && o.maxWidth && (o.maxWidth < data.width),
  6536. ismaxh = this._isNumber(data.height) && o.maxHeight && (o.maxHeight < data.height),
  6537. isminw = this._isNumber(data.width) && o.minWidth && (o.minWidth > data.width),
  6538. isminh = this._isNumber(data.height) && o.minHeight && (o.minHeight > data.height),
  6539. dw = this.originalPosition.left + this.originalSize.width,
  6540. dh = this.position.top + this.size.height,
  6541. cw = /sw|nw|w/.test(a), ch = /nw|ne|n/.test(a);
  6542. if (isminw) {
  6543. data.width = o.minWidth;
  6544. }
  6545. if (isminh) {
  6546. data.height = o.minHeight;
  6547. }
  6548. if (ismaxw) {
  6549. data.width = o.maxWidth;
  6550. }
  6551. if (ismaxh) {
  6552. data.height = o.maxHeight;
  6553. }
  6554. if (isminw && cw) {
  6555. data.left = dw - o.minWidth;
  6556. }
  6557. if (ismaxw && cw) {
  6558. data.left = dw - o.maxWidth;
  6559. }
  6560. if (isminh && ch) {
  6561. data.top = dh - o.minHeight;
  6562. }
  6563. if (ismaxh && ch) {
  6564. data.top = dh - o.maxHeight;
  6565. }
  6566. // Fixing jump error on top/left - bug #2330
  6567. if (!data.width && !data.height && !data.left && data.top) {
  6568. data.top = null;
  6569. } else if (!data.width && !data.height && !data.top && data.left) {
  6570. data.left = null;
  6571. }
  6572. return data;
  6573. },
  6574. _getPaddingPlusBorderDimensions: function( element ) {
  6575. var i = 0,
  6576. widths = [],
  6577. borders = [
  6578. element.css( "borderTopWidth" ),
  6579. element.css( "borderRightWidth" ),
  6580. element.css( "borderBottomWidth" ),
  6581. element.css( "borderLeftWidth" )
  6582. ],
  6583. paddings = [
  6584. element.css( "paddingTop" ),
  6585. element.css( "paddingRight" ),
  6586. element.css( "paddingBottom" ),
  6587. element.css( "paddingLeft" )
  6588. ];
  6589. for ( ; i < 4; i++ ) {
  6590. widths[ i ] = ( parseInt( borders[ i ], 10 ) || 0 );
  6591. widths[ i ] += ( parseInt( paddings[ i ], 10 ) || 0 );
  6592. }
  6593. return {
  6594. height: widths[ 0 ] + widths[ 2 ],
  6595. width: widths[ 1 ] + widths[ 3 ]
  6596. };
  6597. },
  6598. _proportionallyResize: function() {
  6599. if (!this._proportionallyResizeElements.length) {
  6600. return;
  6601. }
  6602. var prel,
  6603. i = 0,
  6604. element = this.helper || this.element;
  6605. for ( ; i < this._proportionallyResizeElements.length; i++) {
  6606. prel = this._proportionallyResizeElements[i];
  6607. // TODO: Seems like a bug to cache this.outerDimensions
  6608. // considering that we are in a loop.
  6609. if (!this.outerDimensions) {
  6610. this.outerDimensions = this._getPaddingPlusBorderDimensions( prel );
  6611. }
  6612. prel.css({
  6613. height: (element.height() - this.outerDimensions.height) || 0,
  6614. width: (element.width() - this.outerDimensions.width) || 0
  6615. });
  6616. }
  6617. },
  6618. _renderProxy: function() {
  6619. var el = this.element, o = this.options;
  6620. this.elementOffset = el.offset();
  6621. if (this._helper) {
  6622. this.helper = this.helper || $("<div style='overflow:hidden;'></div>");
  6623. this.helper.addClass(this._helper).css({
  6624. width: this.element.outerWidth() - 1,
  6625. height: this.element.outerHeight() - 1,
  6626. position: "absolute",
  6627. left: this.elementOffset.left + "px",
  6628. top: this.elementOffset.top + "px",
  6629. zIndex: ++o.zIndex //TODO: Don't modify option
  6630. });
  6631. this.helper
  6632. .appendTo("body")
  6633. .disableSelection();
  6634. } else {
  6635. this.helper = this.element;
  6636. }
  6637. },
  6638. _change: {
  6639. e: function(event, dx) {
  6640. return { width: this.originalSize.width + dx };
  6641. },
  6642. w: function(event, dx) {
  6643. var cs = this.originalSize, sp = this.originalPosition;
  6644. return { left: sp.left + dx, width: cs.width - dx };
  6645. },
  6646. n: function(event, dx, dy) {
  6647. var cs = this.originalSize, sp = this.originalPosition;
  6648. return { top: sp.top + dy, height: cs.height - dy };
  6649. },
  6650. s: function(event, dx, dy) {
  6651. return { height: this.originalSize.height + dy };
  6652. },
  6653. se: function(event, dx, dy) {
  6654. return $.extend(this._change.s.apply(this, arguments),
  6655. this._change.e.apply(this, [ event, dx, dy ]));
  6656. },
  6657. sw: function(event, dx, dy) {
  6658. return $.extend(this._change.s.apply(this, arguments),
  6659. this._change.w.apply(this, [ event, dx, dy ]));
  6660. },
  6661. ne: function(event, dx, dy) {
  6662. return $.extend(this._change.n.apply(this, arguments),
  6663. this._change.e.apply(this, [ event, dx, dy ]));
  6664. },
  6665. nw: function(event, dx, dy) {
  6666. return $.extend(this._change.n.apply(this, arguments),
  6667. this._change.w.apply(this, [ event, dx, dy ]));
  6668. }
  6669. },
  6670. _propagate: function(n, event) {
  6671. $.ui.plugin.call(this, n, [ event, this.ui() ]);
  6672. (n !== "resize" && this._trigger(n, event, this.ui()));
  6673. },
  6674. plugins: {},
  6675. ui: function() {
  6676. return {
  6677. originalElement: this.originalElement,
  6678. element: this.element,
  6679. helper: this.helper,
  6680. position: this.position,
  6681. size: this.size,
  6682. originalSize: this.originalSize,
  6683. originalPosition: this.originalPosition
  6684. };
  6685. }
  6686. });
  6687. /*
  6688. * Resizable Extensions
  6689. */
  6690. $.ui.plugin.add("resizable", "animate", {
  6691. stop: function( event ) {
  6692. var that = $(this).resizable( "instance" ),
  6693. o = that.options,
  6694. pr = that._proportionallyResizeElements,
  6695. ista = pr.length && (/textarea/i).test(pr[0].nodeName),
  6696. soffseth = ista && that._hasScroll(pr[0], "left") ? 0 : that.sizeDiff.height,
  6697. soffsetw = ista ? 0 : that.sizeDiff.width,
  6698. style = { width: (that.size.width - soffsetw), height: (that.size.height - soffseth) },
  6699. left = (parseInt(that.element.css("left"), 10) +
  6700. (that.position.left - that.originalPosition.left)) || null,
  6701. top = (parseInt(that.element.css("top"), 10) +
  6702. (that.position.top - that.originalPosition.top)) || null;
  6703. that.element.animate(
  6704. $.extend(style, top && left ? { top: top, left: left } : {}), {
  6705. duration: o.animateDuration,
  6706. easing: o.animateEasing,
  6707. step: function() {
  6708. var data = {
  6709. width: parseInt(that.element.css("width"), 10),
  6710. height: parseInt(that.element.css("height"), 10),
  6711. top: parseInt(that.element.css("top"), 10),
  6712. left: parseInt(that.element.css("left"), 10)
  6713. };
  6714. if (pr && pr.length) {
  6715. $(pr[0]).css({ width: data.width, height: data.height });
  6716. }
  6717. // propagating resize, and updating values for each animation step
  6718. that._updateCache(data);
  6719. that._propagate("resize", event);
  6720. }
  6721. }
  6722. );
  6723. }
  6724. });
  6725. $.ui.plugin.add( "resizable", "containment", {
  6726. start: function() {
  6727. var element, p, co, ch, cw, width, height,
  6728. that = $( this ).resizable( "instance" ),
  6729. o = that.options,
  6730. el = that.element,
  6731. oc = o.containment,
  6732. ce = ( oc instanceof $ ) ? oc.get( 0 ) : ( /parent/.test( oc ) ) ? el.parent().get( 0 ) : oc;
  6733. if ( !ce ) {
  6734. return;
  6735. }
  6736. that.containerElement = $( ce );
  6737. if ( /document/.test( oc ) || oc === document ) {
  6738. that.containerOffset = {
  6739. left: 0,
  6740. top: 0
  6741. };
  6742. that.containerPosition = {
  6743. left: 0,
  6744. top: 0
  6745. };
  6746. that.parentData = {
  6747. element: $( document ),
  6748. left: 0,
  6749. top: 0,
  6750. width: $( document ).width(),
  6751. height: $( document ).height() || document.body.parentNode.scrollHeight
  6752. };
  6753. } else {
  6754. element = $( ce );
  6755. p = [];
  6756. $([ "Top", "Right", "Left", "Bottom" ]).each(function( i, name ) {
  6757. p[ i ] = that._num( element.css( "padding" + name ) );
  6758. });
  6759. that.containerOffset = element.offset();
  6760. that.containerPosition = element.position();
  6761. that.containerSize = {
  6762. height: ( element.innerHeight() - p[ 3 ] ),
  6763. width: ( element.innerWidth() - p[ 1 ] )
  6764. };
  6765. co = that.containerOffset;
  6766. ch = that.containerSize.height;
  6767. cw = that.containerSize.width;
  6768. width = ( that._hasScroll ( ce, "left" ) ? ce.scrollWidth : cw );
  6769. height = ( that._hasScroll ( ce ) ? ce.scrollHeight : ch ) ;
  6770. that.parentData = {
  6771. element: ce,
  6772. left: co.left,
  6773. top: co.top,
  6774. width: width,
  6775. height: height
  6776. };
  6777. }
  6778. },
  6779. resize: function( event ) {
  6780. var woset, hoset, isParent, isOffsetRelative,
  6781. that = $( this ).resizable( "instance" ),
  6782. o = that.options,
  6783. co = that.containerOffset,
  6784. cp = that.position,
  6785. pRatio = that._aspectRatio || event.shiftKey,
  6786. cop = {
  6787. top: 0,
  6788. left: 0
  6789. },
  6790. ce = that.containerElement,
  6791. continueResize = true;
  6792. if ( ce[ 0 ] !== document && ( /static/ ).test( ce.css( "position" ) ) ) {
  6793. cop = co;
  6794. }
  6795. if ( cp.left < ( that._helper ? co.left : 0 ) ) {
  6796. that.size.width = that.size.width +
  6797. ( that._helper ?
  6798. ( that.position.left - co.left ) :
  6799. ( that.position.left - cop.left ) );
  6800. if ( pRatio ) {
  6801. that.size.height = that.size.width / that.aspectRatio;
  6802. continueResize = false;
  6803. }
  6804. that.position.left = o.helper ? co.left : 0;
  6805. }
  6806. if ( cp.top < ( that._helper ? co.top : 0 ) ) {
  6807. that.size.height = that.size.height +
  6808. ( that._helper ?
  6809. ( that.position.top - co.top ) :
  6810. that.position.top );
  6811. if ( pRatio ) {
  6812. that.size.width = that.size.height * that.aspectRatio;
  6813. continueResize = false;
  6814. }
  6815. that.position.top = that._helper ? co.top : 0;
  6816. }
  6817. isParent = that.containerElement.get( 0 ) === that.element.parent().get( 0 );
  6818. isOffsetRelative = /relative|absolute/.test( that.containerElement.css( "position" ) );
  6819. if ( isParent && isOffsetRelative ) {
  6820. that.offset.left = that.parentData.left + that.position.left;
  6821. that.offset.top = that.parentData.top + that.position.top;
  6822. } else {
  6823. that.offset.left = that.element.offset().left;
  6824. that.offset.top = that.element.offset().top;
  6825. }
  6826. woset = Math.abs( that.sizeDiff.width +
  6827. (that._helper ?
  6828. that.offset.left - cop.left :
  6829. (that.offset.left - co.left)) );
  6830. hoset = Math.abs( that.sizeDiff.height +
  6831. (that._helper ?
  6832. that.offset.top - cop.top :
  6833. (that.offset.top - co.top)) );
  6834. if ( woset + that.size.width >= that.parentData.width ) {
  6835. that.size.width = that.parentData.width - woset;
  6836. if ( pRatio ) {
  6837. that.size.height = that.size.width / that.aspectRatio;
  6838. continueResize = false;
  6839. }
  6840. }
  6841. if ( hoset + that.size.height >= that.parentData.height ) {
  6842. that.size.height = that.parentData.height - hoset;
  6843. if ( pRatio ) {
  6844. that.size.width = that.size.height * that.aspectRatio;
  6845. continueResize = false;
  6846. }
  6847. }
  6848. if ( !continueResize ) {
  6849. that.position.left = that.prevPosition.left;
  6850. that.position.top = that.prevPosition.top;
  6851. that.size.width = that.prevSize.width;
  6852. that.size.height = that.prevSize.height;
  6853. }
  6854. },
  6855. stop: function() {
  6856. var that = $( this ).resizable( "instance" ),
  6857. o = that.options,
  6858. co = that.containerOffset,
  6859. cop = that.containerPosition,
  6860. ce = that.containerElement,
  6861. helper = $( that.helper ),
  6862. ho = helper.offset(),
  6863. w = helper.outerWidth() - that.sizeDiff.width,
  6864. h = helper.outerHeight() - that.sizeDiff.height;
  6865. if ( that._helper && !o.animate && ( /relative/ ).test( ce.css( "position" ) ) ) {
  6866. $( this ).css({
  6867. left: ho.left - cop.left - co.left,
  6868. width: w,
  6869. height: h
  6870. });
  6871. }
  6872. if ( that._helper && !o.animate && ( /static/ ).test( ce.css( "position" ) ) ) {
  6873. $( this ).css({
  6874. left: ho.left - cop.left - co.left,
  6875. width: w,
  6876. height: h
  6877. });
  6878. }
  6879. }
  6880. });
  6881. $.ui.plugin.add("resizable", "alsoResize", {
  6882. start: function() {
  6883. var that = $(this).resizable( "instance" ),
  6884. o = that.options,
  6885. _store = function(exp) {
  6886. $(exp).each(function() {
  6887. var el = $(this);
  6888. el.data("ui-resizable-alsoresize", {
  6889. width: parseInt(el.width(), 10), height: parseInt(el.height(), 10),
  6890. left: parseInt(el.css("left"), 10), top: parseInt(el.css("top"), 10)
  6891. });
  6892. });
  6893. };
  6894. if (typeof(o.alsoResize) === "object" && !o.alsoResize.parentNode) {
  6895. if (o.alsoResize.length) {
  6896. o.alsoResize = o.alsoResize[0];
  6897. _store(o.alsoResize);
  6898. } else {
  6899. $.each(o.alsoResize, function(exp) {
  6900. _store(exp);
  6901. });
  6902. }
  6903. } else {
  6904. _store(o.alsoResize);
  6905. }
  6906. },
  6907. resize: function(event, ui) {
  6908. var that = $(this).resizable( "instance" ),
  6909. o = that.options,
  6910. os = that.originalSize,
  6911. op = that.originalPosition,
  6912. delta = {
  6913. height: (that.size.height - os.height) || 0,
  6914. width: (that.size.width - os.width) || 0,
  6915. top: (that.position.top - op.top) || 0,
  6916. left: (that.position.left - op.left) || 0
  6917. },
  6918. _alsoResize = function(exp, c) {
  6919. $(exp).each(function() {
  6920. var el = $(this), start = $(this).data("ui-resizable-alsoresize"), style = {},
  6921. css = c && c.length ?
  6922. c :
  6923. el.parents(ui.originalElement[0]).length ?
  6924. [ "width", "height" ] :
  6925. [ "width", "height", "top", "left" ];
  6926. $.each(css, function(i, prop) {
  6927. var sum = (start[prop] || 0) + (delta[prop] || 0);
  6928. if (sum && sum >= 0) {
  6929. style[prop] = sum || null;
  6930. }
  6931. });
  6932. el.css(style);
  6933. });
  6934. };
  6935. if (typeof(o.alsoResize) === "object" && !o.alsoResize.nodeType) {
  6936. $.each(o.alsoResize, function(exp, c) {
  6937. _alsoResize(exp, c);
  6938. });
  6939. } else {
  6940. _alsoResize(o.alsoResize);
  6941. }
  6942. },
  6943. stop: function() {
  6944. $(this).removeData("resizable-alsoresize");
  6945. }
  6946. });
  6947. $.ui.plugin.add("resizable", "ghost", {
  6948. start: function() {
  6949. var that = $(this).resizable( "instance" ), o = that.options, cs = that.size;
  6950. that.ghost = that.originalElement.clone();
  6951. that.ghost
  6952. .css({
  6953. opacity: 0.25,
  6954. display: "block",
  6955. position: "relative",
  6956. height: cs.height,
  6957. width: cs.width,
  6958. margin: 0,
  6959. left: 0,
  6960. top: 0
  6961. })
  6962. .addClass("ui-resizable-ghost")
  6963. .addClass(typeof o.ghost === "string" ? o.ghost : "");
  6964. that.ghost.appendTo(that.helper);
  6965. },
  6966. resize: function() {
  6967. var that = $(this).resizable( "instance" );
  6968. if (that.ghost) {
  6969. that.ghost.css({
  6970. position: "relative",
  6971. height: that.size.height,
  6972. width: that.size.width
  6973. });
  6974. }
  6975. },
  6976. stop: function() {
  6977. var that = $(this).resizable( "instance" );
  6978. if (that.ghost && that.helper) {
  6979. that.helper.get(0).removeChild(that.ghost.get(0));
  6980. }
  6981. }
  6982. });
  6983. $.ui.plugin.add("resizable", "grid", {
  6984. resize: function() {
  6985. var outerDimensions,
  6986. that = $(this).resizable( "instance" ),
  6987. o = that.options,
  6988. cs = that.size,
  6989. os = that.originalSize,
  6990. op = that.originalPosition,
  6991. a = that.axis,
  6992. grid = typeof o.grid === "number" ? [ o.grid, o.grid ] : o.grid,
  6993. gridX = (grid[0] || 1),
  6994. gridY = (grid[1] || 1),
  6995. ox = Math.round((cs.width - os.width) / gridX) * gridX,
  6996. oy = Math.round((cs.height - os.height) / gridY) * gridY,
  6997. newWidth = os.width + ox,
  6998. newHeight = os.height + oy,
  6999. isMaxWidth = o.maxWidth && (o.maxWidth < newWidth),
  7000. isMaxHeight = o.maxHeight && (o.maxHeight < newHeight),
  7001. isMinWidth = o.minWidth && (o.minWidth > newWidth),
  7002. isMinHeight = o.minHeight && (o.minHeight > newHeight);
  7003. o.grid = grid;
  7004. if (isMinWidth) {
  7005. newWidth += gridX;
  7006. }
  7007. if (isMinHeight) {
  7008. newHeight += gridY;
  7009. }
  7010. if (isMaxWidth) {
  7011. newWidth -= gridX;
  7012. }
  7013. if (isMaxHeight) {
  7014. newHeight -= gridY;
  7015. }
  7016. if (/^(se|s|e)$/.test(a)) {
  7017. that.size.width = newWidth;
  7018. that.size.height = newHeight;
  7019. } else if (/^(ne)$/.test(a)) {
  7020. that.size.width = newWidth;
  7021. that.size.height = newHeight;
  7022. that.position.top = op.top - oy;
  7023. } else if (/^(sw)$/.test(a)) {
  7024. that.size.width = newWidth;
  7025. that.size.height = newHeight;
  7026. that.position.left = op.left - ox;
  7027. } else {
  7028. if ( newHeight - gridY <= 0 || newWidth - gridX <= 0) {
  7029. outerDimensions = that._getPaddingPlusBorderDimensions( this );
  7030. }
  7031. if ( newHeight - gridY > 0 ) {
  7032. that.size.height = newHeight;
  7033. that.position.top = op.top - oy;
  7034. } else {
  7035. newHeight = gridY - outerDimensions.height;
  7036. that.size.height = newHeight;
  7037. that.position.top = op.top + os.height - newHeight;
  7038. }
  7039. if ( newWidth - gridX > 0 ) {
  7040. that.size.width = newWidth;
  7041. that.position.left = op.left - ox;
  7042. } else {
  7043. newWidth = gridX - outerDimensions.width;
  7044. that.size.width = newWidth;
  7045. that.position.left = op.left + os.width - newWidth;
  7046. }
  7047. }
  7048. }
  7049. });
  7050. var resizable = $.ui.resizable;
  7051. /*!
  7052. * jQuery UI Dialog 1.11.3
  7053. * http://jqueryui.com
  7054. *
  7055. * Copyright jQuery Foundation and other contributors
  7056. * Released under the MIT license.
  7057. * http://jquery.org/license
  7058. *
  7059. * http://api.jqueryui.com/dialog/
  7060. */
  7061. var dialog = $.widget( "ui.dialog", {
  7062. version: "1.11.3",
  7063. options: {
  7064. appendTo: "body",
  7065. autoOpen: true,
  7066. buttons: [],
  7067. closeOnEscape: true,
  7068. closeText: "Close",
  7069. dialogClass: "",
  7070. draggable: true,
  7071. hide: null,
  7072. height: "auto",
  7073. maxHeight: null,
  7074. maxWidth: null,
  7075. minHeight: 150,
  7076. minWidth: 150,
  7077. modal: false,
  7078. position: {
  7079. my: "center",
  7080. at: "center",
  7081. of: window,
  7082. collision: "fit",
  7083. // Ensure the titlebar is always visible
  7084. using: function( pos ) {
  7085. var topOffset = $( this ).css( pos ).offset().top;
  7086. if ( topOffset < 0 ) {
  7087. $( this ).css( "top", pos.top - topOffset );
  7088. }
  7089. }
  7090. },
  7091. resizable: true,
  7092. show: null,
  7093. title: null,
  7094. width: 300,
  7095. // callbacks
  7096. beforeClose: null,
  7097. close: null,
  7098. drag: null,
  7099. dragStart: null,
  7100. dragStop: null,
  7101. focus: null,
  7102. open: null,
  7103. resize: null,
  7104. resizeStart: null,
  7105. resizeStop: null
  7106. },
  7107. sizeRelatedOptions: {
  7108. buttons: true,
  7109. height: true,
  7110. maxHeight: true,
  7111. maxWidth: true,
  7112. minHeight: true,
  7113. minWidth: true,
  7114. width: true
  7115. },
  7116. resizableRelatedOptions: {
  7117. maxHeight: true,
  7118. maxWidth: true,
  7119. minHeight: true,
  7120. minWidth: true
  7121. },
  7122. _create: function() {
  7123. this.originalCss = {
  7124. display: this.element[ 0 ].style.display,
  7125. width: this.element[ 0 ].style.width,
  7126. minHeight: this.element[ 0 ].style.minHeight,
  7127. maxHeight: this.element[ 0 ].style.maxHeight,
  7128. height: this.element[ 0 ].style.height
  7129. };
  7130. this.originalPosition = {
  7131. parent: this.element.parent(),
  7132. index: this.element.parent().children().index( this.element )
  7133. };
  7134. this.originalTitle = this.element.attr( "title" );
  7135. this.options.title = this.options.title || this.originalTitle;
  7136. this._createWrapper();
  7137. this.element
  7138. .show()
  7139. .removeAttr( "title" )
  7140. .addClass( "ui-dialog-content ui-widget-content" )
  7141. .appendTo( this.uiDialog );
  7142. this._createTitlebar();
  7143. this._createButtonPane();
  7144. if ( this.options.draggable && $.fn.draggable ) {
  7145. this._makeDraggable();
  7146. }
  7147. if ( this.options.resizable && $.fn.resizable ) {
  7148. this._makeResizable();
  7149. }
  7150. this._isOpen = false;
  7151. this._trackFocus();
  7152. },
  7153. _init: function() {
  7154. if ( this.options.autoOpen ) {
  7155. this.open();
  7156. }
  7157. },
  7158. _appendTo: function() {
  7159. var element = this.options.appendTo;
  7160. if ( element && (element.jquery || element.nodeType) ) {
  7161. return $( element );
  7162. }
  7163. return this.document.find( element || "body" ).eq( 0 );
  7164. },
  7165. _destroy: function() {
  7166. var next,
  7167. originalPosition = this.originalPosition;
  7168. this._destroyOverlay();
  7169. this.element
  7170. .removeUniqueId()
  7171. .removeClass( "ui-dialog-content ui-widget-content" )
  7172. .css( this.originalCss )
  7173. // Without detaching first, the following becomes really slow
  7174. .detach();
  7175. this.uiDialog.stop( true, true ).remove();
  7176. if ( this.originalTitle ) {
  7177. this.element.attr( "title", this.originalTitle );
  7178. }
  7179. next = originalPosition.parent.children().eq( originalPosition.index );
  7180. // Don't try to place the dialog next to itself (#8613)
  7181. if ( next.length && next[ 0 ] !== this.element[ 0 ] ) {
  7182. next.before( this.element );
  7183. } else {
  7184. originalPosition.parent.append( this.element );
  7185. }
  7186. },
  7187. widget: function() {
  7188. return this.uiDialog;
  7189. },
  7190. disable: $.noop,
  7191. enable: $.noop,
  7192. close: function( event ) {
  7193. var activeElement,
  7194. that = this;
  7195. if ( !this._isOpen || this._trigger( "beforeClose", event ) === false ) {
  7196. return;
  7197. }
  7198. this._isOpen = false;
  7199. this._focusedElement = null;
  7200. this._destroyOverlay();
  7201. this._untrackInstance();
  7202. if ( !this.opener.filter( ":focusable" ).focus().length ) {
  7203. // support: IE9
  7204. // IE9 throws an "Unspecified error" accessing document.activeElement from an <iframe>
  7205. try {
  7206. activeElement = this.document[ 0 ].activeElement;
  7207. // Support: IE9, IE10
  7208. // If the <body> is blurred, IE will switch windows, see #4520
  7209. if ( activeElement && activeElement.nodeName.toLowerCase() !== "body" ) {
  7210. // Hiding a focused element doesn't trigger blur in WebKit
  7211. // so in case we have nothing to focus on, explicitly blur the active element
  7212. // https://bugs.webkit.org/show_bug.cgi?id=47182
  7213. $( activeElement ).blur();
  7214. }
  7215. } catch ( error ) {}
  7216. }
  7217. this._hide( this.uiDialog, this.options.hide, function() {
  7218. that._trigger( "close", event );
  7219. });
  7220. },
  7221. isOpen: function() {
  7222. return this._isOpen;
  7223. },
  7224. moveToTop: function() {
  7225. this._moveToTop();
  7226. },
  7227. _moveToTop: function( event, silent ) {
  7228. var moved = false,
  7229. zIndicies = this.uiDialog.siblings( ".ui-front:visible" ).map(function() {
  7230. return +$( this ).css( "z-index" );
  7231. }).get(),
  7232. zIndexMax = Math.max.apply( null, zIndicies );
  7233. if ( zIndexMax >= +this.uiDialog.css( "z-index" ) ) {
  7234. this.uiDialog.css( "z-index", zIndexMax + 1 );
  7235. moved = true;
  7236. }
  7237. if ( moved && !silent ) {
  7238. this._trigger( "focus", event );
  7239. }
  7240. return moved;
  7241. },
  7242. open: function() {
  7243. var that = this;
  7244. if ( this._isOpen ) {
  7245. if ( this._moveToTop() ) {
  7246. this._focusTabbable();
  7247. }
  7248. return;
  7249. }
  7250. this._isOpen = true;
  7251. this.opener = $( this.document[ 0 ].activeElement );
  7252. this._size();
  7253. this._position();
  7254. this._createOverlay();
  7255. this._moveToTop( null, true );
  7256. // Ensure the overlay is moved to the top with the dialog, but only when
  7257. // opening. The overlay shouldn't move after the dialog is open so that
  7258. // modeless dialogs opened after the modal dialog stack properly.
  7259. if ( this.overlay ) {
  7260. this.overlay.css( "z-index", this.uiDialog.css( "z-index" ) - 1 );
  7261. }
  7262. this._show( this.uiDialog, this.options.show, function() {
  7263. that._focusTabbable();
  7264. that._trigger( "focus" );
  7265. });
  7266. // Track the dialog immediately upon openening in case a focus event
  7267. // somehow occurs outside of the dialog before an element inside the
  7268. // dialog is focused (#10152)
  7269. this._makeFocusTarget();
  7270. this._trigger( "open" );
  7271. },
  7272. _focusTabbable: function() {
  7273. // Set focus to the first match:
  7274. // 1. An element that was focused previously
  7275. // 2. First element inside the dialog matching [autofocus]
  7276. // 3. Tabbable element inside the content element
  7277. // 4. Tabbable element inside the buttonpane
  7278. // 5. The close button
  7279. // 6. The dialog itself
  7280. var hasFocus = this._focusedElement;
  7281. if ( !hasFocus ) {
  7282. hasFocus = this.element.find( "[autofocus]" );
  7283. }
  7284. if ( !hasFocus.length ) {
  7285. hasFocus = this.element.find( ":tabbable" );
  7286. }
  7287. if ( !hasFocus.length ) {
  7288. hasFocus = this.uiDialogButtonPane.find( ":tabbable" );
  7289. }
  7290. if ( !hasFocus.length ) {
  7291. hasFocus = this.uiDialogTitlebarClose.filter( ":tabbable" );
  7292. }
  7293. if ( !hasFocus.length ) {
  7294. hasFocus = this.uiDialog;
  7295. }
  7296. hasFocus.eq( 0 ).focus();
  7297. },
  7298. _keepFocus: function( event ) {
  7299. function checkFocus() {
  7300. var activeElement = this.document[0].activeElement,
  7301. isActive = this.uiDialog[0] === activeElement ||
  7302. $.contains( this.uiDialog[0], activeElement );
  7303. if ( !isActive ) {
  7304. this._focusTabbable();
  7305. }
  7306. }
  7307. event.preventDefault();
  7308. checkFocus.call( this );
  7309. // support: IE
  7310. // IE <= 8 doesn't prevent moving focus even with event.preventDefault()
  7311. // so we check again later
  7312. this._delay( checkFocus );
  7313. },
  7314. _createWrapper: function() {
  7315. this.uiDialog = $("<div>")
  7316. .addClass( "ui-dialog ui-widget ui-widget-content ui-corner-all ui-front " +
  7317. this.options.dialogClass )
  7318. .hide()
  7319. .attr({
  7320. // Setting tabIndex makes the div focusable
  7321. tabIndex: -1,
  7322. role: "dialog"
  7323. })
  7324. .appendTo( this._appendTo() );
  7325. this._on( this.uiDialog, {
  7326. keydown: function( event ) {
  7327. if ( this.options.closeOnEscape && !event.isDefaultPrevented() && event.keyCode &&
  7328. event.keyCode === $.ui.keyCode.ESCAPE ) {
  7329. event.preventDefault();
  7330. this.close( event );
  7331. return;
  7332. }
  7333. // prevent tabbing out of dialogs
  7334. if ( event.keyCode !== $.ui.keyCode.TAB || event.isDefaultPrevented() ) {
  7335. return;
  7336. }
  7337. var tabbables = this.uiDialog.find( ":tabbable" ),
  7338. first = tabbables.filter( ":first" ),
  7339. last = tabbables.filter( ":last" );
  7340. if ( ( event.target === last[0] || event.target === this.uiDialog[0] ) && !event.shiftKey ) {
  7341. this._delay(function() {
  7342. first.focus();
  7343. });
  7344. event.preventDefault();
  7345. } else if ( ( event.target === first[0] || event.target === this.uiDialog[0] ) && event.shiftKey ) {
  7346. this._delay(function() {
  7347. last.focus();
  7348. });
  7349. event.preventDefault();
  7350. }
  7351. },
  7352. mousedown: function( event ) {
  7353. if ( this._moveToTop( event ) ) {
  7354. this._focusTabbable();
  7355. }
  7356. }
  7357. });
  7358. // We assume that any existing aria-describedby attribute means
  7359. // that the dialog content is marked up properly
  7360. // otherwise we brute force the content as the description
  7361. if ( !this.element.find( "[aria-describedby]" ).length ) {
  7362. this.uiDialog.attr({
  7363. "aria-describedby": this.element.uniqueId().attr( "id" )
  7364. });
  7365. }
  7366. },
  7367. _createTitlebar: function() {
  7368. var uiDialogTitle;
  7369. this.uiDialogTitlebar = $( "<div>" )
  7370. .addClass( "ui-dialog-titlebar ui-widget-header ui-corner-all ui-helper-clearfix" )
  7371. .prependTo( this.uiDialog );
  7372. this._on( this.uiDialogTitlebar, {
  7373. mousedown: function( event ) {
  7374. // Don't prevent click on close button (#8838)
  7375. // Focusing a dialog that is partially scrolled out of view
  7376. // causes the browser to scroll it into view, preventing the click event
  7377. if ( !$( event.target ).closest( ".ui-dialog-titlebar-close" ) ) {
  7378. // Dialog isn't getting focus when dragging (#8063)
  7379. this.uiDialog.focus();
  7380. }
  7381. }
  7382. });
  7383. // support: IE
  7384. // Use type="button" to prevent enter keypresses in textboxes from closing the
  7385. // dialog in IE (#9312)
  7386. this.uiDialogTitlebarClose = $( "<button type='button'></button>" )
  7387. .button({
  7388. label: this.options.closeText,
  7389. icons: {
  7390. primary: "ui-icon-closethick"
  7391. },
  7392. text: false
  7393. })
  7394. .addClass( "ui-dialog-titlebar-close" )
  7395. .appendTo( this.uiDialogTitlebar );
  7396. this._on( this.uiDialogTitlebarClose, {
  7397. click: function( event ) {
  7398. event.preventDefault();
  7399. this.close( event );
  7400. }
  7401. });
  7402. uiDialogTitle = $( "<span>" )
  7403. .uniqueId()
  7404. .addClass( "ui-dialog-title" )
  7405. .prependTo( this.uiDialogTitlebar );
  7406. this._title( uiDialogTitle );
  7407. this.uiDialog.attr({
  7408. "aria-labelledby": uiDialogTitle.attr( "id" )
  7409. });
  7410. },
  7411. _title: function( title ) {
  7412. if ( !this.options.title ) {
  7413. title.html( "&#160;" );
  7414. }
  7415. title.text( this.options.title );
  7416. },
  7417. _createButtonPane: function() {
  7418. this.uiDialogButtonPane = $( "<div>" )
  7419. .addClass( "ui-dialog-buttonpane ui-widget-content ui-helper-clearfix" );
  7420. this.uiButtonSet = $( "<div>" )
  7421. .addClass( "ui-dialog-buttonset" )
  7422. .appendTo( this.uiDialogButtonPane );
  7423. this._createButtons();
  7424. },
  7425. _createButtons: function() {
  7426. var that = this,
  7427. buttons = this.options.buttons;
  7428. // if we already have a button pane, remove it
  7429. this.uiDialogButtonPane.remove();
  7430. this.uiButtonSet.empty();
  7431. if ( $.isEmptyObject( buttons ) || ($.isArray( buttons ) && !buttons.length) ) {
  7432. this.uiDialog.removeClass( "ui-dialog-buttons" );
  7433. return;
  7434. }
  7435. $.each( buttons, function( name, props ) {
  7436. var click, buttonOptions;
  7437. props = $.isFunction( props ) ?
  7438. { click: props, text: name } :
  7439. props;
  7440. // Default to a non-submitting button
  7441. props = $.extend( { type: "button" }, props );
  7442. // Change the context for the click callback to be the main element
  7443. click = props.click;
  7444. props.click = function() {
  7445. click.apply( that.element[ 0 ], arguments );
  7446. };
  7447. buttonOptions = {
  7448. icons: props.icons,
  7449. text: props.showText
  7450. };
  7451. delete props.icons;
  7452. delete props.showText;
  7453. $( "<button></button>", props )
  7454. .button( buttonOptions )
  7455. .appendTo( that.uiButtonSet );
  7456. });
  7457. this.uiDialog.addClass( "ui-dialog-buttons" );
  7458. this.uiDialogButtonPane.appendTo( this.uiDialog );
  7459. },
  7460. _makeDraggable: function() {
  7461. var that = this,
  7462. options = this.options;
  7463. function filteredUi( ui ) {
  7464. return {
  7465. position: ui.position,
  7466. offset: ui.offset
  7467. };
  7468. }
  7469. this.uiDialog.draggable({
  7470. cancel: ".ui-dialog-content, .ui-dialog-titlebar-close",
  7471. handle: ".ui-dialog-titlebar",
  7472. containment: "document",
  7473. start: function( event, ui ) {
  7474. $( this ).addClass( "ui-dialog-dragging" );
  7475. that._blockFrames();
  7476. that._trigger( "dragStart", event, filteredUi( ui ) );
  7477. },
  7478. drag: function( event, ui ) {
  7479. that._trigger( "drag", event, filteredUi( ui ) );
  7480. },
  7481. stop: function( event, ui ) {
  7482. var left = ui.offset.left - that.document.scrollLeft(),
  7483. top = ui.offset.top - that.document.scrollTop();
  7484. options.position = {
  7485. my: "left top",
  7486. at: "left" + (left >= 0 ? "+" : "") + left + " " +
  7487. "top" + (top >= 0 ? "+" : "") + top,
  7488. of: that.window
  7489. };
  7490. $( this ).removeClass( "ui-dialog-dragging" );
  7491. that._unblockFrames();
  7492. that._trigger( "dragStop", event, filteredUi( ui ) );
  7493. }
  7494. });
  7495. },
  7496. _makeResizable: function() {
  7497. var that = this,
  7498. options = this.options,
  7499. handles = options.resizable,
  7500. // .ui-resizable has position: relative defined in the stylesheet
  7501. // but dialogs have to use absolute or fixed positioning
  7502. position = this.uiDialog.css("position"),
  7503. resizeHandles = typeof handles === "string" ?
  7504. handles :
  7505. "n,e,s,w,se,sw,ne,nw";
  7506. function filteredUi( ui ) {
  7507. return {
  7508. originalPosition: ui.originalPosition,
  7509. originalSize: ui.originalSize,
  7510. position: ui.position,
  7511. size: ui.size
  7512. };
  7513. }
  7514. this.uiDialog.resizable({
  7515. cancel: ".ui-dialog-content",
  7516. containment: "document",
  7517. alsoResize: this.element,
  7518. maxWidth: options.maxWidth,
  7519. maxHeight: options.maxHeight,
  7520. minWidth: options.minWidth,
  7521. minHeight: this._minHeight(),
  7522. handles: resizeHandles,
  7523. start: function( event, ui ) {
  7524. $( this ).addClass( "ui-dialog-resizing" );
  7525. that._blockFrames();
  7526. that._trigger( "resizeStart", event, filteredUi( ui ) );
  7527. },
  7528. resize: function( event, ui ) {
  7529. that._trigger( "resize", event, filteredUi( ui ) );
  7530. },
  7531. stop: function( event, ui ) {
  7532. var offset = that.uiDialog.offset(),
  7533. left = offset.left - that.document.scrollLeft(),
  7534. top = offset.top - that.document.scrollTop();
  7535. options.height = that.uiDialog.height();
  7536. options.width = that.uiDialog.width();
  7537. options.position = {
  7538. my: "left top",
  7539. at: "left" + (left >= 0 ? "+" : "") + left + " " +
  7540. "top" + (top >= 0 ? "+" : "") + top,
  7541. of: that.window
  7542. };
  7543. $( this ).removeClass( "ui-dialog-resizing" );
  7544. that._unblockFrames();
  7545. that._trigger( "resizeStop", event, filteredUi( ui ) );
  7546. }
  7547. })
  7548. .css( "position", position );
  7549. },
  7550. _trackFocus: function() {
  7551. this._on( this.widget(), {
  7552. focusin: function( event ) {
  7553. this._makeFocusTarget();
  7554. this._focusedElement = $( event.target );
  7555. }
  7556. });
  7557. },
  7558. _makeFocusTarget: function() {
  7559. this._untrackInstance();
  7560. this._trackingInstances().unshift( this );
  7561. },
  7562. _untrackInstance: function() {
  7563. var instances = this._trackingInstances(),
  7564. exists = $.inArray( this, instances );
  7565. if ( exists !== -1 ) {
  7566. instances.splice( exists, 1 );
  7567. }
  7568. },
  7569. _trackingInstances: function() {
  7570. var instances = this.document.data( "ui-dialog-instances" );
  7571. if ( !instances ) {
  7572. instances = [];
  7573. this.document.data( "ui-dialog-instances", instances );
  7574. }
  7575. return instances;
  7576. },
  7577. _minHeight: function() {
  7578. var options = this.options;
  7579. return options.height === "auto" ?
  7580. options.minHeight :
  7581. Math.min( options.minHeight, options.height );
  7582. },
  7583. _position: function() {
  7584. // Need to show the dialog to get the actual offset in the position plugin
  7585. var isVisible = this.uiDialog.is( ":visible" );
  7586. if ( !isVisible ) {
  7587. this.uiDialog.show();
  7588. }
  7589. this.uiDialog.position( this.options.position );
  7590. if ( !isVisible ) {
  7591. this.uiDialog.hide();
  7592. }
  7593. },
  7594. _setOptions: function( options ) {
  7595. var that = this,
  7596. resize = false,
  7597. resizableOptions = {};
  7598. $.each( options, function( key, value ) {
  7599. that._setOption( key, value );
  7600. if ( key in that.sizeRelatedOptions ) {
  7601. resize = true;
  7602. }
  7603. if ( key in that.resizableRelatedOptions ) {
  7604. resizableOptions[ key ] = value;
  7605. }
  7606. });
  7607. if ( resize ) {
  7608. this._size();
  7609. this._position();
  7610. }
  7611. if ( this.uiDialog.is( ":data(ui-resizable)" ) ) {
  7612. this.uiDialog.resizable( "option", resizableOptions );
  7613. }
  7614. },
  7615. _setOption: function( key, value ) {
  7616. var isDraggable, isResizable,
  7617. uiDialog = this.uiDialog;
  7618. if ( key === "dialogClass" ) {
  7619. uiDialog
  7620. .removeClass( this.options.dialogClass )
  7621. .addClass( value );
  7622. }
  7623. if ( key === "disabled" ) {
  7624. return;
  7625. }
  7626. this._super( key, value );
  7627. if ( key === "appendTo" ) {
  7628. this.uiDialog.appendTo( this._appendTo() );
  7629. }
  7630. if ( key === "buttons" ) {
  7631. this._createButtons();
  7632. }
  7633. if ( key === "closeText" ) {
  7634. this.uiDialogTitlebarClose.button({
  7635. // Ensure that we always pass a string
  7636. label: "" + value
  7637. });
  7638. }
  7639. if ( key === "draggable" ) {
  7640. isDraggable = uiDialog.is( ":data(ui-draggable)" );
  7641. if ( isDraggable && !value ) {
  7642. uiDialog.draggable( "destroy" );
  7643. }
  7644. if ( !isDraggable && value ) {
  7645. this._makeDraggable();
  7646. }
  7647. }
  7648. if ( key === "position" ) {
  7649. this._position();
  7650. }
  7651. if ( key === "resizable" ) {
  7652. // currently resizable, becoming non-resizable
  7653. isResizable = uiDialog.is( ":data(ui-resizable)" );
  7654. if ( isResizable && !value ) {
  7655. uiDialog.resizable( "destroy" );
  7656. }
  7657. // currently resizable, changing handles
  7658. if ( isResizable && typeof value === "string" ) {
  7659. uiDialog.resizable( "option", "handles", value );
  7660. }
  7661. // currently non-resizable, becoming resizable
  7662. if ( !isResizable && value !== false ) {
  7663. this._makeResizable();
  7664. }
  7665. }
  7666. if ( key === "title" ) {
  7667. this._title( this.uiDialogTitlebar.find( ".ui-dialog-title" ) );
  7668. }
  7669. },
  7670. _size: function() {
  7671. // If the user has resized the dialog, the .ui-dialog and .ui-dialog-content
  7672. // divs will both have width and height set, so we need to reset them
  7673. var nonContentHeight, minContentHeight, maxContentHeight,
  7674. options = this.options;
  7675. // Reset content sizing
  7676. this.element.show().css({
  7677. width: "auto",
  7678. minHeight: 0,
  7679. maxHeight: "none",
  7680. height: 0
  7681. });
  7682. if ( options.minWidth > options.width ) {
  7683. options.width = options.minWidth;
  7684. }
  7685. // reset wrapper sizing
  7686. // determine the height of all the non-content elements
  7687. nonContentHeight = this.uiDialog.css({
  7688. height: "auto",
  7689. width: options.width
  7690. })
  7691. .outerHeight();
  7692. minContentHeight = Math.max( 0, options.minHeight - nonContentHeight );
  7693. maxContentHeight = typeof options.maxHeight === "number" ?
  7694. Math.max( 0, options.maxHeight - nonContentHeight ) :
  7695. "none";
  7696. if ( options.height === "auto" ) {
  7697. this.element.css({
  7698. minHeight: minContentHeight,
  7699. maxHeight: maxContentHeight,
  7700. height: "auto"
  7701. });
  7702. } else {
  7703. this.element.height( Math.max( 0, options.height - nonContentHeight ) );
  7704. }
  7705. if ( this.uiDialog.is( ":data(ui-resizable)" ) ) {
  7706. this.uiDialog.resizable( "option", "minHeight", this._minHeight() );
  7707. }
  7708. },
  7709. _blockFrames: function() {
  7710. this.iframeBlocks = this.document.find( "iframe" ).map(function() {
  7711. var iframe = $( this );
  7712. return $( "<div>" )
  7713. .css({
  7714. position: "absolute",
  7715. width: iframe.outerWidth(),
  7716. height: iframe.outerHeight()
  7717. })
  7718. .appendTo( iframe.parent() )
  7719. .offset( iframe.offset() )[0];
  7720. });
  7721. },
  7722. _unblockFrames: function() {
  7723. if ( this.iframeBlocks ) {
  7724. this.iframeBlocks.remove();
  7725. delete this.iframeBlocks;
  7726. }
  7727. },
  7728. _allowInteraction: function( event ) {
  7729. if ( $( event.target ).closest( ".ui-dialog" ).length ) {
  7730. return true;
  7731. }
  7732. // TODO: Remove hack when datepicker implements
  7733. // the .ui-front logic (#8989)
  7734. return !!$( event.target ).closest( ".ui-datepicker" ).length;
  7735. },
  7736. _createOverlay: function() {
  7737. if ( !this.options.modal ) {
  7738. return;
  7739. }
  7740. // We use a delay in case the overlay is created from an
  7741. // event that we're going to be cancelling (#2804)
  7742. var isOpening = true;
  7743. this._delay(function() {
  7744. isOpening = false;
  7745. });
  7746. if ( !this.document.data( "ui-dialog-overlays" ) ) {
  7747. // Prevent use of anchors and inputs
  7748. // Using _on() for an event handler shared across many instances is
  7749. // safe because the dialogs stack and must be closed in reverse order
  7750. this._on( this.document, {
  7751. focusin: function( event ) {
  7752. if ( isOpening ) {
  7753. return;
  7754. }
  7755. if ( !this._allowInteraction( event ) ) {
  7756. event.preventDefault();
  7757. this._trackingInstances()[ 0 ]._focusTabbable();
  7758. }
  7759. }
  7760. });
  7761. }
  7762. this.overlay = $( "<div>" )
  7763. .addClass( "ui-widget-overlay ui-front" )
  7764. .appendTo( this._appendTo() );
  7765. this._on( this.overlay, {
  7766. mousedown: "_keepFocus"
  7767. });
  7768. this.document.data( "ui-dialog-overlays",
  7769. (this.document.data( "ui-dialog-overlays" ) || 0) + 1 );
  7770. },
  7771. _destroyOverlay: function() {
  7772. if ( !this.options.modal ) {
  7773. return;
  7774. }
  7775. if ( this.overlay ) {
  7776. var overlays = this.document.data( "ui-dialog-overlays" ) - 1;
  7777. if ( !overlays ) {
  7778. this.document
  7779. .unbind( "focusin" )
  7780. .removeData( "ui-dialog-overlays" );
  7781. } else {
  7782. this.document.data( "ui-dialog-overlays", overlays );
  7783. }
  7784. this.overlay.remove();
  7785. this.overlay = null;
  7786. }
  7787. }
  7788. });
  7789. /*!
  7790. * jQuery UI Droppable 1.11.3
  7791. * http://jqueryui.com
  7792. *
  7793. * Copyright jQuery Foundation and other contributors
  7794. * Released under the MIT license.
  7795. * http://jquery.org/license
  7796. *
  7797. * http://api.jqueryui.com/droppable/
  7798. */
  7799. $.widget( "ui.droppable", {
  7800. version: "1.11.3",
  7801. widgetEventPrefix: "drop",
  7802. options: {
  7803. accept: "*",
  7804. activeClass: false,
  7805. addClasses: true,
  7806. greedy: false,
  7807. hoverClass: false,
  7808. scope: "default",
  7809. tolerance: "intersect",
  7810. // callbacks
  7811. activate: null,
  7812. deactivate: null,
  7813. drop: null,
  7814. out: null,
  7815. over: null
  7816. },
  7817. _create: function() {
  7818. var proportions,
  7819. o = this.options,
  7820. accept = o.accept;
  7821. this.isover = false;
  7822. this.isout = true;
  7823. this.accept = $.isFunction( accept ) ? accept : function( d ) {
  7824. return d.is( accept );
  7825. };
  7826. this.proportions = function( /* valueToWrite */ ) {
  7827. if ( arguments.length ) {
  7828. // Store the droppable's proportions
  7829. proportions = arguments[ 0 ];
  7830. } else {
  7831. // Retrieve or derive the droppable's proportions
  7832. return proportions ?
  7833. proportions :
  7834. proportions = {
  7835. width: this.element[ 0 ].offsetWidth,
  7836. height: this.element[ 0 ].offsetHeight
  7837. };
  7838. }
  7839. };
  7840. this._addToManager( o.scope );
  7841. o.addClasses && this.element.addClass( "ui-droppable" );
  7842. },
  7843. _addToManager: function( scope ) {
  7844. // Add the reference and positions to the manager
  7845. $.ui.ddmanager.droppables[ scope ] = $.ui.ddmanager.droppables[ scope ] || [];
  7846. $.ui.ddmanager.droppables[ scope ].push( this );
  7847. },
  7848. _splice: function( drop ) {
  7849. var i = 0;
  7850. for ( ; i < drop.length; i++ ) {
  7851. if ( drop[ i ] === this ) {
  7852. drop.splice( i, 1 );
  7853. }
  7854. }
  7855. },
  7856. _destroy: function() {
  7857. var drop = $.ui.ddmanager.droppables[ this.options.scope ];
  7858. this._splice( drop );
  7859. this.element.removeClass( "ui-droppable ui-droppable-disabled" );
  7860. },
  7861. _setOption: function( key, value ) {
  7862. if ( key === "accept" ) {
  7863. this.accept = $.isFunction( value ) ? value : function( d ) {
  7864. return d.is( value );
  7865. };
  7866. } else if ( key === "scope" ) {
  7867. var drop = $.ui.ddmanager.droppables[ this.options.scope ];
  7868. this._splice( drop );
  7869. this._addToManager( value );
  7870. }
  7871. this._super( key, value );
  7872. },
  7873. _activate: function( event ) {
  7874. var draggable = $.ui.ddmanager.current;
  7875. if ( this.options.activeClass ) {
  7876. this.element.addClass( this.options.activeClass );
  7877. }
  7878. if ( draggable ){
  7879. this._trigger( "activate", event, this.ui( draggable ) );
  7880. }
  7881. },
  7882. _deactivate: function( event ) {
  7883. var draggable = $.ui.ddmanager.current;
  7884. if ( this.options.activeClass ) {
  7885. this.element.removeClass( this.options.activeClass );
  7886. }
  7887. if ( draggable ){
  7888. this._trigger( "deactivate", event, this.ui( draggable ) );
  7889. }
  7890. },
  7891. _over: function( event ) {
  7892. var draggable = $.ui.ddmanager.current;
  7893. // Bail if draggable and droppable are same element
  7894. if ( !draggable || ( draggable.currentItem || draggable.element )[ 0 ] === this.element[ 0 ] ) {
  7895. return;
  7896. }
  7897. if ( this.accept.call( this.element[ 0 ], ( draggable.currentItem || draggable.element ) ) ) {
  7898. if ( this.options.hoverClass ) {
  7899. this.element.addClass( this.options.hoverClass );
  7900. }
  7901. this._trigger( "over", event, this.ui( draggable ) );
  7902. }
  7903. },
  7904. _out: function( event ) {
  7905. var draggable = $.ui.ddmanager.current;
  7906. // Bail if draggable and droppable are same element
  7907. if ( !draggable || ( draggable.currentItem || draggable.element )[ 0 ] === this.element[ 0 ] ) {
  7908. return;
  7909. }
  7910. if ( this.accept.call( this.element[ 0 ], ( draggable.currentItem || draggable.element ) ) ) {
  7911. if ( this.options.hoverClass ) {
  7912. this.element.removeClass( this.options.hoverClass );
  7913. }
  7914. this._trigger( "out", event, this.ui( draggable ) );
  7915. }
  7916. },
  7917. _drop: function( event, custom ) {
  7918. var draggable = custom || $.ui.ddmanager.current,
  7919. childrenIntersection = false;
  7920. // Bail if draggable and droppable are same element
  7921. if ( !draggable || ( draggable.currentItem || draggable.element )[ 0 ] === this.element[ 0 ] ) {
  7922. return false;
  7923. }
  7924. this.element.find( ":data(ui-droppable)" ).not( ".ui-draggable-dragging" ).each(function() {
  7925. var inst = $( this ).droppable( "instance" );
  7926. if (
  7927. inst.options.greedy &&
  7928. !inst.options.disabled &&
  7929. inst.options.scope === draggable.options.scope &&
  7930. inst.accept.call( inst.element[ 0 ], ( draggable.currentItem || draggable.element ) ) &&
  7931. $.ui.intersect( draggable, $.extend( inst, { offset: inst.element.offset() } ), inst.options.tolerance, event )
  7932. ) { childrenIntersection = true; return false; }
  7933. });
  7934. if ( childrenIntersection ) {
  7935. return false;
  7936. }
  7937. if ( this.accept.call( this.element[ 0 ], ( draggable.currentItem || draggable.element ) ) ) {
  7938. if ( this.options.activeClass ) {
  7939. this.element.removeClass( this.options.activeClass );
  7940. }
  7941. if ( this.options.hoverClass ) {
  7942. this.element.removeClass( this.options.hoverClass );
  7943. }
  7944. this._trigger( "drop", event, this.ui( draggable ) );
  7945. return this.element;
  7946. }
  7947. return false;
  7948. },
  7949. ui: function( c ) {
  7950. return {
  7951. draggable: ( c.currentItem || c.element ),
  7952. helper: c.helper,
  7953. position: c.position,
  7954. offset: c.positionAbs
  7955. };
  7956. }
  7957. });
  7958. $.ui.intersect = (function() {
  7959. function isOverAxis( x, reference, size ) {
  7960. return ( x >= reference ) && ( x < ( reference + size ) );
  7961. }
  7962. return function( draggable, droppable, toleranceMode, event ) {
  7963. if ( !droppable.offset ) {
  7964. return false;
  7965. }
  7966. var x1 = ( draggable.positionAbs || draggable.position.absolute ).left + draggable.margins.left,
  7967. y1 = ( draggable.positionAbs || draggable.position.absolute ).top + draggable.margins.top,
  7968. x2 = x1 + draggable.helperProportions.width,
  7969. y2 = y1 + draggable.helperProportions.height,
  7970. l = droppable.offset.left,
  7971. t = droppable.offset.top,
  7972. r = l + droppable.proportions().width,
  7973. b = t + droppable.proportions().height;
  7974. switch ( toleranceMode ) {
  7975. case "fit":
  7976. return ( l <= x1 && x2 <= r && t <= y1 && y2 <= b );
  7977. case "intersect":
  7978. return ( l < x1 + ( draggable.helperProportions.width / 2 ) && // Right Half
  7979. x2 - ( draggable.helperProportions.width / 2 ) < r && // Left Half
  7980. t < y1 + ( draggable.helperProportions.height / 2 ) && // Bottom Half
  7981. y2 - ( draggable.helperProportions.height / 2 ) < b ); // Top Half
  7982. case "pointer":
  7983. return isOverAxis( event.pageY, t, droppable.proportions().height ) && isOverAxis( event.pageX, l, droppable.proportions().width );
  7984. case "touch":
  7985. return (
  7986. ( y1 >= t && y1 <= b ) || // Top edge touching
  7987. ( y2 >= t && y2 <= b ) || // Bottom edge touching
  7988. ( y1 < t && y2 > b ) // Surrounded vertically
  7989. ) && (
  7990. ( x1 >= l && x1 <= r ) || // Left edge touching
  7991. ( x2 >= l && x2 <= r ) || // Right edge touching
  7992. ( x1 < l && x2 > r ) // Surrounded horizontally
  7993. );
  7994. default:
  7995. return false;
  7996. }
  7997. };
  7998. })();
  7999. /*
  8000. This manager tracks offsets of draggables and droppables
  8001. */
  8002. $.ui.ddmanager = {
  8003. current: null,
  8004. droppables: { "default": [] },
  8005. prepareOffsets: function( t, event ) {
  8006. var i, j,
  8007. m = $.ui.ddmanager.droppables[ t.options.scope ] || [],
  8008. type = event ? event.type : null, // workaround for #2317
  8009. list = ( t.currentItem || t.element ).find( ":data(ui-droppable)" ).addBack();
  8010. droppablesLoop: for ( i = 0; i < m.length; i++ ) {
  8011. // No disabled and non-accepted
  8012. if ( m[ i ].options.disabled || ( t && !m[ i ].accept.call( m[ i ].element[ 0 ], ( t.currentItem || t.element ) ) ) ) {
  8013. continue;
  8014. }
  8015. // Filter out elements in the current dragged item
  8016. for ( j = 0; j < list.length; j++ ) {
  8017. if ( list[ j ] === m[ i ].element[ 0 ] ) {
  8018. m[ i ].proportions().height = 0;
  8019. continue droppablesLoop;
  8020. }
  8021. }
  8022. m[ i ].visible = m[ i ].element.css( "display" ) !== "none";
  8023. if ( !m[ i ].visible ) {
  8024. continue;
  8025. }
  8026. // Activate the droppable if used directly from draggables
  8027. if ( type === "mousedown" ) {
  8028. m[ i ]._activate.call( m[ i ], event );
  8029. }
  8030. m[ i ].offset = m[ i ].element.offset();
  8031. m[ i ].proportions({ width: m[ i ].element[ 0 ].offsetWidth, height: m[ i ].element[ 0 ].offsetHeight });
  8032. }
  8033. },
  8034. drop: function( draggable, event ) {
  8035. var dropped = false;
  8036. // Create a copy of the droppables in case the list changes during the drop (#9116)
  8037. $.each( ( $.ui.ddmanager.droppables[ draggable.options.scope ] || [] ).slice(), function() {
  8038. if ( !this.options ) {
  8039. return;
  8040. }
  8041. if ( !this.options.disabled && this.visible && $.ui.intersect( draggable, this, this.options.tolerance, event ) ) {
  8042. dropped = this._drop.call( this, event ) || dropped;
  8043. }
  8044. if ( !this.options.disabled && this.visible && this.accept.call( this.element[ 0 ], ( draggable.currentItem || draggable.element ) ) ) {
  8045. this.isout = true;
  8046. this.isover = false;
  8047. this._deactivate.call( this, event );
  8048. }
  8049. });
  8050. return dropped;
  8051. },
  8052. dragStart: function( draggable, event ) {
  8053. // Listen for scrolling so that if the dragging causes scrolling the position of the droppables can be recalculated (see #5003)
  8054. draggable.element.parentsUntil( "body" ).bind( "scroll.droppable", function() {
  8055. if ( !draggable.options.refreshPositions ) {
  8056. $.ui.ddmanager.prepareOffsets( draggable, event );
  8057. }
  8058. });
  8059. },
  8060. drag: function( draggable, event ) {
  8061. // If you have a highly dynamic page, you might try this option. It renders positions every time you move the mouse.
  8062. if ( draggable.options.refreshPositions ) {
  8063. $.ui.ddmanager.prepareOffsets( draggable, event );
  8064. }
  8065. // Run through all droppables and check their positions based on specific tolerance options
  8066. $.each( $.ui.ddmanager.droppables[ draggable.options.scope ] || [], function() {
  8067. if ( this.options.disabled || this.greedyChild || !this.visible ) {
  8068. return;
  8069. }
  8070. var parentInstance, scope, parent,
  8071. intersects = $.ui.intersect( draggable, this, this.options.tolerance, event ),
  8072. c = !intersects && this.isover ? "isout" : ( intersects && !this.isover ? "isover" : null );
  8073. if ( !c ) {
  8074. return;
  8075. }
  8076. if ( this.options.greedy ) {
  8077. // find droppable parents with same scope
  8078. scope = this.options.scope;
  8079. parent = this.element.parents( ":data(ui-droppable)" ).filter(function() {
  8080. return $( this ).droppable( "instance" ).options.scope === scope;
  8081. });
  8082. if ( parent.length ) {
  8083. parentInstance = $( parent[ 0 ] ).droppable( "instance" );
  8084. parentInstance.greedyChild = ( c === "isover" );
  8085. }
  8086. }
  8087. // we just moved into a greedy child
  8088. if ( parentInstance && c === "isover" ) {
  8089. parentInstance.isover = false;
  8090. parentInstance.isout = true;
  8091. parentInstance._out.call( parentInstance, event );
  8092. }
  8093. this[ c ] = true;
  8094. this[c === "isout" ? "isover" : "isout"] = false;
  8095. this[c === "isover" ? "_over" : "_out"].call( this, event );
  8096. // we just moved out of a greedy child
  8097. if ( parentInstance && c === "isout" ) {
  8098. parentInstance.isout = false;
  8099. parentInstance.isover = true;
  8100. parentInstance._over.call( parentInstance, event );
  8101. }
  8102. });
  8103. },
  8104. dragStop: function( draggable, event ) {
  8105. draggable.element.parentsUntil( "body" ).unbind( "scroll.droppable" );
  8106. // Call prepareOffsets one final time since IE does not fire return scroll events when overflow was caused by drag (see #5003)
  8107. if ( !draggable.options.refreshPositions ) {
  8108. $.ui.ddmanager.prepareOffsets( draggable, event );
  8109. }
  8110. }
  8111. };
  8112. var droppable = $.ui.droppable;
  8113. /*!
  8114. * jQuery UI Effects 1.11.3
  8115. * http://jqueryui.com
  8116. *
  8117. * Copyright jQuery Foundation and other contributors
  8118. * Released under the MIT license.
  8119. * http://jquery.org/license
  8120. *
  8121. * http://api.jqueryui.com/category/effects-core/
  8122. */
  8123. var dataSpace = "ui-effects-",
  8124. // Create a local jQuery because jQuery Color relies on it and the
  8125. // global may not exist with AMD and a custom build (#10199)
  8126. jQuery = $;
  8127. $.effects = {
  8128. effect: {}
  8129. };
  8130. /*!
  8131. * jQuery Color Animations v2.1.2
  8132. * https://github.com/jquery/jquery-color
  8133. *
  8134. * Copyright 2014 jQuery Foundation and other contributors
  8135. * Released under the MIT license.
  8136. * http://jquery.org/license
  8137. *
  8138. * Date: Wed Jan 16 08:47:09 2013 -0600
  8139. */
  8140. (function( jQuery, undefined ) {
  8141. var stepHooks = "backgroundColor borderBottomColor borderLeftColor borderRightColor borderTopColor color columnRuleColor outlineColor textDecorationColor textEmphasisColor",
  8142. // plusequals test for += 100 -= 100
  8143. rplusequals = /^([\-+])=\s*(\d+\.?\d*)/,
  8144. // a set of RE's that can match strings and generate color tuples.
  8145. stringParsers = [ {
  8146. re: /rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(?:,\s*(\d?(?:\.\d+)?)\s*)?\)/,
  8147. parse: function( execResult ) {
  8148. return [
  8149. execResult[ 1 ],
  8150. execResult[ 2 ],
  8151. execResult[ 3 ],
  8152. execResult[ 4 ]
  8153. ];
  8154. }
  8155. }, {
  8156. re: /rgba?\(\s*(\d+(?:\.\d+)?)\%\s*,\s*(\d+(?:\.\d+)?)\%\s*,\s*(\d+(?:\.\d+)?)\%\s*(?:,\s*(\d?(?:\.\d+)?)\s*)?\)/,
  8157. parse: function( execResult ) {
  8158. return [
  8159. execResult[ 1 ] * 2.55,
  8160. execResult[ 2 ] * 2.55,
  8161. execResult[ 3 ] * 2.55,
  8162. execResult[ 4 ]
  8163. ];
  8164. }
  8165. }, {
  8166. // this regex ignores A-F because it's compared against an already lowercased string
  8167. re: /#([a-f0-9]{2})([a-f0-9]{2})([a-f0-9]{2})/,
  8168. parse: function( execResult ) {
  8169. return [
  8170. parseInt( execResult[ 1 ], 16 ),
  8171. parseInt( execResult[ 2 ], 16 ),
  8172. parseInt( execResult[ 3 ], 16 )
  8173. ];
  8174. }
  8175. }, {
  8176. // this regex ignores A-F because it's compared against an already lowercased string
  8177. re: /#([a-f0-9])([a-f0-9])([a-f0-9])/,
  8178. parse: function( execResult ) {
  8179. return [
  8180. parseInt( execResult[ 1 ] + execResult[ 1 ], 16 ),
  8181. parseInt( execResult[ 2 ] + execResult[ 2 ], 16 ),
  8182. parseInt( execResult[ 3 ] + execResult[ 3 ], 16 )
  8183. ];
  8184. }
  8185. }, {
  8186. re: /hsla?\(\s*(\d+(?:\.\d+)?)\s*,\s*(\d+(?:\.\d+)?)\%\s*,\s*(\d+(?:\.\d+)?)\%\s*(?:,\s*(\d?(?:\.\d+)?)\s*)?\)/,
  8187. space: "hsla",
  8188. parse: function( execResult ) {
  8189. return [
  8190. execResult[ 1 ],
  8191. execResult[ 2 ] / 100,
  8192. execResult[ 3 ] / 100,
  8193. execResult[ 4 ]
  8194. ];
  8195. }
  8196. } ],
  8197. // jQuery.Color( )
  8198. color = jQuery.Color = function( color, green, blue, alpha ) {
  8199. return new jQuery.Color.fn.parse( color, green, blue, alpha );
  8200. },
  8201. spaces = {
  8202. rgba: {
  8203. props: {
  8204. red: {
  8205. idx: 0,
  8206. type: "byte"
  8207. },
  8208. green: {
  8209. idx: 1,
  8210. type: "byte"
  8211. },
  8212. blue: {
  8213. idx: 2,
  8214. type: "byte"
  8215. }
  8216. }
  8217. },
  8218. hsla: {
  8219. props: {
  8220. hue: {
  8221. idx: 0,
  8222. type: "degrees"
  8223. },
  8224. saturation: {
  8225. idx: 1,
  8226. type: "percent"
  8227. },
  8228. lightness: {
  8229. idx: 2,
  8230. type: "percent"
  8231. }
  8232. }
  8233. }
  8234. },
  8235. propTypes = {
  8236. "byte": {
  8237. floor: true,
  8238. max: 255
  8239. },
  8240. "percent": {
  8241. max: 1
  8242. },
  8243. "degrees": {
  8244. mod: 360,
  8245. floor: true
  8246. }
  8247. },
  8248. support = color.support = {},
  8249. // element for support tests
  8250. supportElem = jQuery( "<p>" )[ 0 ],
  8251. // colors = jQuery.Color.names
  8252. colors,
  8253. // local aliases of functions called often
  8254. each = jQuery.each;
  8255. // determine rgba support immediately
  8256. supportElem.style.cssText = "background-color:rgba(1,1,1,.5)";
  8257. support.rgba = supportElem.style.backgroundColor.indexOf( "rgba" ) > -1;
  8258. // define cache name and alpha properties
  8259. // for rgba and hsla spaces
  8260. each( spaces, function( spaceName, space ) {
  8261. space.cache = "_" + spaceName;
  8262. space.props.alpha = {
  8263. idx: 3,
  8264. type: "percent",
  8265. def: 1
  8266. };
  8267. });
  8268. function clamp( value, prop, allowEmpty ) {
  8269. var type = propTypes[ prop.type ] || {};
  8270. if ( value == null ) {
  8271. return (allowEmpty || !prop.def) ? null : prop.def;
  8272. }
  8273. // ~~ is an short way of doing floor for positive numbers
  8274. value = type.floor ? ~~value : parseFloat( value );
  8275. // IE will pass in empty strings as value for alpha,
  8276. // which will hit this case
  8277. if ( isNaN( value ) ) {
  8278. return prop.def;
  8279. }
  8280. if ( type.mod ) {
  8281. // we add mod before modding to make sure that negatives values
  8282. // get converted properly: -10 -> 350
  8283. return (value + type.mod) % type.mod;
  8284. }
  8285. // for now all property types without mod have min and max
  8286. return 0 > value ? 0 : type.max < value ? type.max : value;
  8287. }
  8288. function stringParse( string ) {
  8289. var inst = color(),
  8290. rgba = inst._rgba = [];
  8291. string = string.toLowerCase();
  8292. each( stringParsers, function( i, parser ) {
  8293. var parsed,
  8294. match = parser.re.exec( string ),
  8295. values = match && parser.parse( match ),
  8296. spaceName = parser.space || "rgba";
  8297. if ( values ) {
  8298. parsed = inst[ spaceName ]( values );
  8299. // if this was an rgba parse the assignment might happen twice
  8300. // oh well....
  8301. inst[ spaces[ spaceName ].cache ] = parsed[ spaces[ spaceName ].cache ];
  8302. rgba = inst._rgba = parsed._rgba;
  8303. // exit each( stringParsers ) here because we matched
  8304. return false;
  8305. }
  8306. });
  8307. // Found a stringParser that handled it
  8308. if ( rgba.length ) {
  8309. // if this came from a parsed string, force "transparent" when alpha is 0
  8310. // chrome, (and maybe others) return "transparent" as rgba(0,0,0,0)
  8311. if ( rgba.join() === "0,0,0,0" ) {
  8312. jQuery.extend( rgba, colors.transparent );
  8313. }
  8314. return inst;
  8315. }
  8316. // named colors
  8317. return colors[ string ];
  8318. }
  8319. color.fn = jQuery.extend( color.prototype, {
  8320. parse: function( red, green, blue, alpha ) {
  8321. if ( red === undefined ) {
  8322. this._rgba = [ null, null, null, null ];
  8323. return this;
  8324. }
  8325. if ( red.jquery || red.nodeType ) {
  8326. red = jQuery( red ).css( green );
  8327. green = undefined;
  8328. }
  8329. var inst = this,
  8330. type = jQuery.type( red ),
  8331. rgba = this._rgba = [];
  8332. // more than 1 argument specified - assume ( red, green, blue, alpha )
  8333. if ( green !== undefined ) {
  8334. red = [ red, green, blue, alpha ];
  8335. type = "array";
  8336. }
  8337. if ( type === "string" ) {
  8338. return this.parse( stringParse( red ) || colors._default );
  8339. }
  8340. if ( type === "array" ) {
  8341. each( spaces.rgba.props, function( key, prop ) {
  8342. rgba[ prop.idx ] = clamp( red[ prop.idx ], prop );
  8343. });
  8344. return this;
  8345. }
  8346. if ( type === "object" ) {
  8347. if ( red instanceof color ) {
  8348. each( spaces, function( spaceName, space ) {
  8349. if ( red[ space.cache ] ) {
  8350. inst[ space.cache ] = red[ space.cache ].slice();
  8351. }
  8352. });
  8353. } else {
  8354. each( spaces, function( spaceName, space ) {
  8355. var cache = space.cache;
  8356. each( space.props, function( key, prop ) {
  8357. // if the cache doesn't exist, and we know how to convert
  8358. if ( !inst[ cache ] && space.to ) {
  8359. // if the value was null, we don't need to copy it
  8360. // if the key was alpha, we don't need to copy it either
  8361. if ( key === "alpha" || red[ key ] == null ) {
  8362. return;
  8363. }
  8364. inst[ cache ] = space.to( inst._rgba );
  8365. }
  8366. // this is the only case where we allow nulls for ALL properties.
  8367. // call clamp with alwaysAllowEmpty
  8368. inst[ cache ][ prop.idx ] = clamp( red[ key ], prop, true );
  8369. });
  8370. // everything defined but alpha?
  8371. if ( inst[ cache ] && jQuery.inArray( null, inst[ cache ].slice( 0, 3 ) ) < 0 ) {
  8372. // use the default of 1
  8373. inst[ cache ][ 3 ] = 1;
  8374. if ( space.from ) {
  8375. inst._rgba = space.from( inst[ cache ] );
  8376. }
  8377. }
  8378. });
  8379. }
  8380. return this;
  8381. }
  8382. },
  8383. is: function( compare ) {
  8384. var is = color( compare ),
  8385. same = true,
  8386. inst = this;
  8387. each( spaces, function( _, space ) {
  8388. var localCache,
  8389. isCache = is[ space.cache ];
  8390. if (isCache) {
  8391. localCache = inst[ space.cache ] || space.to && space.to( inst._rgba ) || [];
  8392. each( space.props, function( _, prop ) {
  8393. if ( isCache[ prop.idx ] != null ) {
  8394. same = ( isCache[ prop.idx ] === localCache[ prop.idx ] );
  8395. return same;
  8396. }
  8397. });
  8398. }
  8399. return same;
  8400. });
  8401. return same;
  8402. },
  8403. _space: function() {
  8404. var used = [],
  8405. inst = this;
  8406. each( spaces, function( spaceName, space ) {
  8407. if ( inst[ space.cache ] ) {
  8408. used.push( spaceName );
  8409. }
  8410. });
  8411. return used.pop();
  8412. },
  8413. transition: function( other, distance ) {
  8414. var end = color( other ),
  8415. spaceName = end._space(),
  8416. space = spaces[ spaceName ],
  8417. startColor = this.alpha() === 0 ? color( "transparent" ) : this,
  8418. start = startColor[ space.cache ] || space.to( startColor._rgba ),
  8419. result = start.slice();
  8420. end = end[ space.cache ];
  8421. each( space.props, function( key, prop ) {
  8422. var index = prop.idx,
  8423. startValue = start[ index ],
  8424. endValue = end[ index ],
  8425. type = propTypes[ prop.type ] || {};
  8426. // if null, don't override start value
  8427. if ( endValue === null ) {
  8428. return;
  8429. }
  8430. // if null - use end
  8431. if ( startValue === null ) {
  8432. result[ index ] = endValue;
  8433. } else {
  8434. if ( type.mod ) {
  8435. if ( endValue - startValue > type.mod / 2 ) {
  8436. startValue += type.mod;
  8437. } else if ( startValue - endValue > type.mod / 2 ) {
  8438. startValue -= type.mod;
  8439. }
  8440. }
  8441. result[ index ] = clamp( ( endValue - startValue ) * distance + startValue, prop );
  8442. }
  8443. });
  8444. return this[ spaceName ]( result );
  8445. },
  8446. blend: function( opaque ) {
  8447. // if we are already opaque - return ourself
  8448. if ( this._rgba[ 3 ] === 1 ) {
  8449. return this;
  8450. }
  8451. var rgb = this._rgba.slice(),
  8452. a = rgb.pop(),
  8453. blend = color( opaque )._rgba;
  8454. return color( jQuery.map( rgb, function( v, i ) {
  8455. return ( 1 - a ) * blend[ i ] + a * v;
  8456. }));
  8457. },
  8458. toRgbaString: function() {
  8459. var prefix = "rgba(",
  8460. rgba = jQuery.map( this._rgba, function( v, i ) {
  8461. return v == null ? ( i > 2 ? 1 : 0 ) : v;
  8462. });
  8463. if ( rgba[ 3 ] === 1 ) {
  8464. rgba.pop();
  8465. prefix = "rgb(";
  8466. }
  8467. return prefix + rgba.join() + ")";
  8468. },
  8469. toHslaString: function() {
  8470. var prefix = "hsla(",
  8471. hsla = jQuery.map( this.hsla(), function( v, i ) {
  8472. if ( v == null ) {
  8473. v = i > 2 ? 1 : 0;
  8474. }
  8475. // catch 1 and 2
  8476. if ( i && i < 3 ) {
  8477. v = Math.round( v * 100 ) + "%";
  8478. }
  8479. return v;
  8480. });
  8481. if ( hsla[ 3 ] === 1 ) {
  8482. hsla.pop();
  8483. prefix = "hsl(";
  8484. }
  8485. return prefix + hsla.join() + ")";
  8486. },
  8487. toHexString: function( includeAlpha ) {
  8488. var rgba = this._rgba.slice(),
  8489. alpha = rgba.pop();
  8490. if ( includeAlpha ) {
  8491. rgba.push( ~~( alpha * 255 ) );
  8492. }
  8493. return "#" + jQuery.map( rgba, function( v ) {
  8494. // default to 0 when nulls exist
  8495. v = ( v || 0 ).toString( 16 );
  8496. return v.length === 1 ? "0" + v : v;
  8497. }).join("");
  8498. },
  8499. toString: function() {
  8500. return this._rgba[ 3 ] === 0 ? "transparent" : this.toRgbaString();
  8501. }
  8502. });
  8503. color.fn.parse.prototype = color.fn;
  8504. // hsla conversions adapted from:
  8505. // https://code.google.com/p/maashaack/source/browse/packages/graphics/trunk/src/graphics/colors/HUE2RGB.as?r=5021
  8506. function hue2rgb( p, q, h ) {
  8507. h = ( h + 1 ) % 1;
  8508. if ( h * 6 < 1 ) {
  8509. return p + ( q - p ) * h * 6;
  8510. }
  8511. if ( h * 2 < 1) {
  8512. return q;
  8513. }
  8514. if ( h * 3 < 2 ) {
  8515. return p + ( q - p ) * ( ( 2 / 3 ) - h ) * 6;
  8516. }
  8517. return p;
  8518. }
  8519. spaces.hsla.to = function( rgba ) {
  8520. if ( rgba[ 0 ] == null || rgba[ 1 ] == null || rgba[ 2 ] == null ) {
  8521. return [ null, null, null, rgba[ 3 ] ];
  8522. }
  8523. var r = rgba[ 0 ] / 255,
  8524. g = rgba[ 1 ] / 255,
  8525. b = rgba[ 2 ] / 255,
  8526. a = rgba[ 3 ],
  8527. max = Math.max( r, g, b ),
  8528. min = Math.min( r, g, b ),
  8529. diff = max - min,
  8530. add = max + min,
  8531. l = add * 0.5,
  8532. h, s;
  8533. if ( min === max ) {
  8534. h = 0;
  8535. } else if ( r === max ) {
  8536. h = ( 60 * ( g - b ) / diff ) + 360;
  8537. } else if ( g === max ) {
  8538. h = ( 60 * ( b - r ) / diff ) + 120;
  8539. } else {
  8540. h = ( 60 * ( r - g ) / diff ) + 240;
  8541. }
  8542. // chroma (diff) == 0 means greyscale which, by definition, saturation = 0%
  8543. // otherwise, saturation is based on the ratio of chroma (diff) to lightness (add)
  8544. if ( diff === 0 ) {
  8545. s = 0;
  8546. } else if ( l <= 0.5 ) {
  8547. s = diff / add;
  8548. } else {
  8549. s = diff / ( 2 - add );
  8550. }
  8551. return [ Math.round(h) % 360, s, l, a == null ? 1 : a ];
  8552. };
  8553. spaces.hsla.from = function( hsla ) {
  8554. if ( hsla[ 0 ] == null || hsla[ 1 ] == null || hsla[ 2 ] == null ) {
  8555. return [ null, null, null, hsla[ 3 ] ];
  8556. }
  8557. var h = hsla[ 0 ] / 360,
  8558. s = hsla[ 1 ],
  8559. l = hsla[ 2 ],
  8560. a = hsla[ 3 ],
  8561. q = l <= 0.5 ? l * ( 1 + s ) : l + s - l * s,
  8562. p = 2 * l - q;
  8563. return [
  8564. Math.round( hue2rgb( p, q, h + ( 1 / 3 ) ) * 255 ),
  8565. Math.round( hue2rgb( p, q, h ) * 255 ),
  8566. Math.round( hue2rgb( p, q, h - ( 1 / 3 ) ) * 255 ),
  8567. a
  8568. ];
  8569. };
  8570. each( spaces, function( spaceName, space ) {
  8571. var props = space.props,
  8572. cache = space.cache,
  8573. to = space.to,
  8574. from = space.from;
  8575. // makes rgba() and hsla()
  8576. color.fn[ spaceName ] = function( value ) {
  8577. // generate a cache for this space if it doesn't exist
  8578. if ( to && !this[ cache ] ) {
  8579. this[ cache ] = to( this._rgba );
  8580. }
  8581. if ( value === undefined ) {
  8582. return this[ cache ].slice();
  8583. }
  8584. var ret,
  8585. type = jQuery.type( value ),
  8586. arr = ( type === "array" || type === "object" ) ? value : arguments,
  8587. local = this[ cache ].slice();
  8588. each( props, function( key, prop ) {
  8589. var val = arr[ type === "object" ? key : prop.idx ];
  8590. if ( val == null ) {
  8591. val = local[ prop.idx ];
  8592. }
  8593. local[ prop.idx ] = clamp( val, prop );
  8594. });
  8595. if ( from ) {
  8596. ret = color( from( local ) );
  8597. ret[ cache ] = local;
  8598. return ret;
  8599. } else {
  8600. return color( local );
  8601. }
  8602. };
  8603. // makes red() green() blue() alpha() hue() saturation() lightness()
  8604. each( props, function( key, prop ) {
  8605. // alpha is included in more than one space
  8606. if ( color.fn[ key ] ) {
  8607. return;
  8608. }
  8609. color.fn[ key ] = function( value ) {
  8610. var vtype = jQuery.type( value ),
  8611. fn = ( key === "alpha" ? ( this._hsla ? "hsla" : "rgba" ) : spaceName ),
  8612. local = this[ fn ](),
  8613. cur = local[ prop.idx ],
  8614. match;
  8615. if ( vtype === "undefined" ) {
  8616. return cur;
  8617. }
  8618. if ( vtype === "function" ) {
  8619. value = value.call( this, cur );
  8620. vtype = jQuery.type( value );
  8621. }
  8622. if ( value == null && prop.empty ) {
  8623. return this;
  8624. }
  8625. if ( vtype === "string" ) {
  8626. match = rplusequals.exec( value );
  8627. if ( match ) {
  8628. value = cur + parseFloat( match[ 2 ] ) * ( match[ 1 ] === "+" ? 1 : -1 );
  8629. }
  8630. }
  8631. local[ prop.idx ] = value;
  8632. return this[ fn ]( local );
  8633. };
  8634. });
  8635. });
  8636. // add cssHook and .fx.step function for each named hook.
  8637. // accept a space separated string of properties
  8638. color.hook = function( hook ) {
  8639. var hooks = hook.split( " " );
  8640. each( hooks, function( i, hook ) {
  8641. jQuery.cssHooks[ hook ] = {
  8642. set: function( elem, value ) {
  8643. var parsed, curElem,
  8644. backgroundColor = "";
  8645. if ( value !== "transparent" && ( jQuery.type( value ) !== "string" || ( parsed = stringParse( value ) ) ) ) {
  8646. value = color( parsed || value );
  8647. if ( !support.rgba && value._rgba[ 3 ] !== 1 ) {
  8648. curElem = hook === "backgroundColor" ? elem.parentNode : elem;
  8649. while (
  8650. (backgroundColor === "" || backgroundColor === "transparent") &&
  8651. curElem && curElem.style
  8652. ) {
  8653. try {
  8654. backgroundColor = jQuery.css( curElem, "backgroundColor" );
  8655. curElem = curElem.parentNode;
  8656. } catch ( e ) {
  8657. }
  8658. }
  8659. value = value.blend( backgroundColor && backgroundColor !== "transparent" ?
  8660. backgroundColor :
  8661. "_default" );
  8662. }
  8663. value = value.toRgbaString();
  8664. }
  8665. try {
  8666. elem.style[ hook ] = value;
  8667. } catch ( e ) {
  8668. // wrapped to prevent IE from throwing errors on "invalid" values like 'auto' or 'inherit'
  8669. }
  8670. }
  8671. };
  8672. jQuery.fx.step[ hook ] = function( fx ) {
  8673. if ( !fx.colorInit ) {
  8674. fx.start = color( fx.elem, hook );
  8675. fx.end = color( fx.end );
  8676. fx.colorInit = true;
  8677. }
  8678. jQuery.cssHooks[ hook ].set( fx.elem, fx.start.transition( fx.end, fx.pos ) );
  8679. };
  8680. });
  8681. };
  8682. color.hook( stepHooks );
  8683. jQuery.cssHooks.borderColor = {
  8684. expand: function( value ) {
  8685. var expanded = {};
  8686. each( [ "Top", "Right", "Bottom", "Left" ], function( i, part ) {
  8687. expanded[ "border" + part + "Color" ] = value;
  8688. });
  8689. return expanded;
  8690. }
  8691. };
  8692. // Basic color names only.
  8693. // Usage of any of the other color names requires adding yourself or including
  8694. // jquery.color.svg-names.js.
  8695. colors = jQuery.Color.names = {
  8696. // 4.1. Basic color keywords
  8697. aqua: "#00ffff",
  8698. black: "#000000",
  8699. blue: "#0000ff",
  8700. fuchsia: "#ff00ff",
  8701. gray: "#808080",
  8702. green: "#008000",
  8703. lime: "#00ff00",
  8704. maroon: "#800000",
  8705. navy: "#000080",
  8706. olive: "#808000",
  8707. purple: "#800080",
  8708. red: "#ff0000",
  8709. silver: "#c0c0c0",
  8710. teal: "#008080",
  8711. white: "#ffffff",
  8712. yellow: "#ffff00",
  8713. // 4.2.3. "transparent" color keyword
  8714. transparent: [ null, null, null, 0 ],
  8715. _default: "#ffffff"
  8716. };
  8717. })( jQuery );
  8718. /******************************************************************************/
  8719. /****************************** CLASS ANIMATIONS ******************************/
  8720. /******************************************************************************/
  8721. (function() {
  8722. var classAnimationActions = [ "add", "remove", "toggle" ],
  8723. shorthandStyles = {
  8724. border: 1,
  8725. borderBottom: 1,
  8726. borderColor: 1,
  8727. borderLeft: 1,
  8728. borderRight: 1,
  8729. borderTop: 1,
  8730. borderWidth: 1,
  8731. margin: 1,
  8732. padding: 1
  8733. };
  8734. $.each([ "borderLeftStyle", "borderRightStyle", "borderBottomStyle", "borderTopStyle" ], function( _, prop ) {
  8735. $.fx.step[ prop ] = function( fx ) {
  8736. if ( fx.end !== "none" && !fx.setAttr || fx.pos === 1 && !fx.setAttr ) {
  8737. jQuery.style( fx.elem, prop, fx.end );
  8738. fx.setAttr = true;
  8739. }
  8740. };
  8741. });
  8742. function getElementStyles( elem ) {
  8743. var key, len,
  8744. style = elem.ownerDocument.defaultView ?
  8745. elem.ownerDocument.defaultView.getComputedStyle( elem, null ) :
  8746. elem.currentStyle,
  8747. styles = {};
  8748. if ( style && style.length && style[ 0 ] && style[ style[ 0 ] ] ) {
  8749. len = style.length;
  8750. while ( len-- ) {
  8751. key = style[ len ];
  8752. if ( typeof style[ key ] === "string" ) {
  8753. styles[ $.camelCase( key ) ] = style[ key ];
  8754. }
  8755. }
  8756. // support: Opera, IE <9
  8757. } else {
  8758. for ( key in style ) {
  8759. if ( typeof style[ key ] === "string" ) {
  8760. styles[ key ] = style[ key ];
  8761. }
  8762. }
  8763. }
  8764. return styles;
  8765. }
  8766. function styleDifference( oldStyle, newStyle ) {
  8767. var diff = {},
  8768. name, value;
  8769. for ( name in newStyle ) {
  8770. value = newStyle[ name ];
  8771. if ( oldStyle[ name ] !== value ) {
  8772. if ( !shorthandStyles[ name ] ) {
  8773. if ( $.fx.step[ name ] || !isNaN( parseFloat( value ) ) ) {
  8774. diff[ name ] = value;
  8775. }
  8776. }
  8777. }
  8778. }
  8779. return diff;
  8780. }
  8781. // support: jQuery <1.8
  8782. if ( !$.fn.addBack ) {
  8783. $.fn.addBack = function( selector ) {
  8784. return this.add( selector == null ?
  8785. this.prevObject : this.prevObject.filter( selector )
  8786. );
  8787. };
  8788. }
  8789. $.effects.animateClass = function( value, duration, easing, callback ) {
  8790. var o = $.speed( duration, easing, callback );
  8791. return this.queue( function() {
  8792. var animated = $( this ),
  8793. baseClass = animated.attr( "class" ) || "",
  8794. applyClassChange,
  8795. allAnimations = o.children ? animated.find( "*" ).addBack() : animated;
  8796. // map the animated objects to store the original styles.
  8797. allAnimations = allAnimations.map(function() {
  8798. var el = $( this );
  8799. return {
  8800. el: el,
  8801. start: getElementStyles( this )
  8802. };
  8803. });
  8804. // apply class change
  8805. applyClassChange = function() {
  8806. $.each( classAnimationActions, function(i, action) {
  8807. if ( value[ action ] ) {
  8808. animated[ action + "Class" ]( value[ action ] );
  8809. }
  8810. });
  8811. };
  8812. applyClassChange();
  8813. // map all animated objects again - calculate new styles and diff
  8814. allAnimations = allAnimations.map(function() {
  8815. this.end = getElementStyles( this.el[ 0 ] );
  8816. this.diff = styleDifference( this.start, this.end );
  8817. return this;
  8818. });
  8819. // apply original class
  8820. animated.attr( "class", baseClass );
  8821. // map all animated objects again - this time collecting a promise
  8822. allAnimations = allAnimations.map(function() {
  8823. var styleInfo = this,
  8824. dfd = $.Deferred(),
  8825. opts = $.extend({}, o, {
  8826. queue: false,
  8827. complete: function() {
  8828. dfd.resolve( styleInfo );
  8829. }
  8830. });
  8831. this.el.animate( this.diff, opts );
  8832. return dfd.promise();
  8833. });
  8834. // once all animations have completed:
  8835. $.when.apply( $, allAnimations.get() ).done(function() {
  8836. // set the final class
  8837. applyClassChange();
  8838. // for each animated element,
  8839. // clear all css properties that were animated
  8840. $.each( arguments, function() {
  8841. var el = this.el;
  8842. $.each( this.diff, function(key) {
  8843. el.css( key, "" );
  8844. });
  8845. });
  8846. // this is guarnteed to be there if you use jQuery.speed()
  8847. // it also handles dequeuing the next anim...
  8848. o.complete.call( animated[ 0 ] );
  8849. });
  8850. });
  8851. };
  8852. $.fn.extend({
  8853. addClass: (function( orig ) {
  8854. return function( classNames, speed, easing, callback ) {
  8855. return speed ?
  8856. $.effects.animateClass.call( this,
  8857. { add: classNames }, speed, easing, callback ) :
  8858. orig.apply( this, arguments );
  8859. };
  8860. })( $.fn.addClass ),
  8861. removeClass: (function( orig ) {
  8862. return function( classNames, speed, easing, callback ) {
  8863. return arguments.length > 1 ?
  8864. $.effects.animateClass.call( this,
  8865. { remove: classNames }, speed, easing, callback ) :
  8866. orig.apply( this, arguments );
  8867. };
  8868. })( $.fn.removeClass ),
  8869. toggleClass: (function( orig ) {
  8870. return function( classNames, force, speed, easing, callback ) {
  8871. if ( typeof force === "boolean" || force === undefined ) {
  8872. if ( !speed ) {
  8873. // without speed parameter
  8874. return orig.apply( this, arguments );
  8875. } else {
  8876. return $.effects.animateClass.call( this,
  8877. (force ? { add: classNames } : { remove: classNames }),
  8878. speed, easing, callback );
  8879. }
  8880. } else {
  8881. // without force parameter
  8882. return $.effects.animateClass.call( this,
  8883. { toggle: classNames }, force, speed, easing );
  8884. }
  8885. };
  8886. })( $.fn.toggleClass ),
  8887. switchClass: function( remove, add, speed, easing, callback) {
  8888. return $.effects.animateClass.call( this, {
  8889. add: add,
  8890. remove: remove
  8891. }, speed, easing, callback );
  8892. }
  8893. });
  8894. })();
  8895. /******************************************************************************/
  8896. /*********************************** EFFECTS **********************************/
  8897. /******************************************************************************/
  8898. (function() {
  8899. $.extend( $.effects, {
  8900. version: "1.11.3",
  8901. // Saves a set of properties in a data storage
  8902. save: function( element, set ) {
  8903. for ( var i = 0; i < set.length; i++ ) {
  8904. if ( set[ i ] !== null ) {
  8905. element.data( dataSpace + set[ i ], element[ 0 ].style[ set[ i ] ] );
  8906. }
  8907. }
  8908. },
  8909. // Restores a set of previously saved properties from a data storage
  8910. restore: function( element, set ) {
  8911. var val, i;
  8912. for ( i = 0; i < set.length; i++ ) {
  8913. if ( set[ i ] !== null ) {
  8914. val = element.data( dataSpace + set[ i ] );
  8915. // support: jQuery 1.6.2
  8916. // http://bugs.jquery.com/ticket/9917
  8917. // jQuery 1.6.2 incorrectly returns undefined for any falsy value.
  8918. // We can't differentiate between "" and 0 here, so we just assume
  8919. // empty string since it's likely to be a more common value...
  8920. if ( val === undefined ) {
  8921. val = "";
  8922. }
  8923. element.css( set[ i ], val );
  8924. }
  8925. }
  8926. },
  8927. setMode: function( el, mode ) {
  8928. if (mode === "toggle") {
  8929. mode = el.is( ":hidden" ) ? "show" : "hide";
  8930. }
  8931. return mode;
  8932. },
  8933. // Translates a [top,left] array into a baseline value
  8934. // this should be a little more flexible in the future to handle a string & hash
  8935. getBaseline: function( origin, original ) {
  8936. var y, x;
  8937. switch ( origin[ 0 ] ) {
  8938. case "top": y = 0; break;
  8939. case "middle": y = 0.5; break;
  8940. case "bottom": y = 1; break;
  8941. default: y = origin[ 0 ] / original.height;
  8942. }
  8943. switch ( origin[ 1 ] ) {
  8944. case "left": x = 0; break;
  8945. case "center": x = 0.5; break;
  8946. case "right": x = 1; break;
  8947. default: x = origin[ 1 ] / original.width;
  8948. }
  8949. return {
  8950. x: x,
  8951. y: y
  8952. };
  8953. },
  8954. // Wraps the element around a wrapper that copies position properties
  8955. createWrapper: function( element ) {
  8956. // if the element is already wrapped, return it
  8957. if ( element.parent().is( ".ui-effects-wrapper" )) {
  8958. return element.parent();
  8959. }
  8960. // wrap the element
  8961. var props = {
  8962. width: element.outerWidth(true),
  8963. height: element.outerHeight(true),
  8964. "float": element.css( "float" )
  8965. },
  8966. wrapper = $( "<div></div>" )
  8967. .addClass( "ui-effects-wrapper" )
  8968. .css({
  8969. fontSize: "100%",
  8970. background: "transparent",
  8971. border: "none",
  8972. margin: 0,
  8973. padding: 0
  8974. }),
  8975. // Store the size in case width/height are defined in % - Fixes #5245
  8976. size = {
  8977. width: element.width(),
  8978. height: element.height()
  8979. },
  8980. active = document.activeElement;
  8981. // support: Firefox
  8982. // Firefox incorrectly exposes anonymous content
  8983. // https://bugzilla.mozilla.org/show_bug.cgi?id=561664
  8984. try {
  8985. active.id;
  8986. } catch ( e ) {
  8987. active = document.body;
  8988. }
  8989. element.wrap( wrapper );
  8990. // Fixes #7595 - Elements lose focus when wrapped.
  8991. if ( element[ 0 ] === active || $.contains( element[ 0 ], active ) ) {
  8992. $( active ).focus();
  8993. }
  8994. wrapper = element.parent(); //Hotfix for jQuery 1.4 since some change in wrap() seems to actually lose the reference to the wrapped element
  8995. // transfer positioning properties to the wrapper
  8996. if ( element.css( "position" ) === "static" ) {
  8997. wrapper.css({ position: "relative" });
  8998. element.css({ position: "relative" });
  8999. } else {
  9000. $.extend( props, {
  9001. position: element.css( "position" ),
  9002. zIndex: element.css( "z-index" )
  9003. });
  9004. $.each([ "top", "left", "bottom", "right" ], function(i, pos) {
  9005. props[ pos ] = element.css( pos );
  9006. if ( isNaN( parseInt( props[ pos ], 10 ) ) ) {
  9007. props[ pos ] = "auto";
  9008. }
  9009. });
  9010. element.css({
  9011. position: "relative",
  9012. top: 0,
  9013. left: 0,
  9014. right: "auto",
  9015. bottom: "auto"
  9016. });
  9017. }
  9018. element.css(size);
  9019. return wrapper.css( props ).show();
  9020. },
  9021. removeWrapper: function( element ) {
  9022. var active = document.activeElement;
  9023. if ( element.parent().is( ".ui-effects-wrapper" ) ) {
  9024. element.parent().replaceWith( element );
  9025. // Fixes #7595 - Elements lose focus when wrapped.
  9026. if ( element[ 0 ] === active || $.contains( element[ 0 ], active ) ) {
  9027. $( active ).focus();
  9028. }
  9029. }
  9030. return element;
  9031. },
  9032. setTransition: function( element, list, factor, value ) {
  9033. value = value || {};
  9034. $.each( list, function( i, x ) {
  9035. var unit = element.cssUnit( x );
  9036. if ( unit[ 0 ] > 0 ) {
  9037. value[ x ] = unit[ 0 ] * factor + unit[ 1 ];
  9038. }
  9039. });
  9040. return value;
  9041. }
  9042. });
  9043. // return an effect options object for the given parameters:
  9044. function _normalizeArguments( effect, options, speed, callback ) {
  9045. // allow passing all options as the first parameter
  9046. if ( $.isPlainObject( effect ) ) {
  9047. options = effect;
  9048. effect = effect.effect;
  9049. }
  9050. // convert to an object
  9051. effect = { effect: effect };
  9052. // catch (effect, null, ...)
  9053. if ( options == null ) {
  9054. options = {};
  9055. }
  9056. // catch (effect, callback)
  9057. if ( $.isFunction( options ) ) {
  9058. callback = options;
  9059. speed = null;
  9060. options = {};
  9061. }
  9062. // catch (effect, speed, ?)
  9063. if ( typeof options === "number" || $.fx.speeds[ options ] ) {
  9064. callback = speed;
  9065. speed = options;
  9066. options = {};
  9067. }
  9068. // catch (effect, options, callback)
  9069. if ( $.isFunction( speed ) ) {
  9070. callback = speed;
  9071. speed = null;
  9072. }
  9073. // add options to effect
  9074. if ( options ) {
  9075. $.extend( effect, options );
  9076. }
  9077. speed = speed || options.duration;
  9078. effect.duration = $.fx.off ? 0 :
  9079. typeof speed === "number" ? speed :
  9080. speed in $.fx.speeds ? $.fx.speeds[ speed ] :
  9081. $.fx.speeds._default;
  9082. effect.complete = callback || options.complete;
  9083. return effect;
  9084. }
  9085. function standardAnimationOption( option ) {
  9086. // Valid standard speeds (nothing, number, named speed)
  9087. if ( !option || typeof option === "number" || $.fx.speeds[ option ] ) {
  9088. return true;
  9089. }
  9090. // Invalid strings - treat as "normal" speed
  9091. if ( typeof option === "string" && !$.effects.effect[ option ] ) {
  9092. return true;
  9093. }
  9094. // Complete callback
  9095. if ( $.isFunction( option ) ) {
  9096. return true;
  9097. }
  9098. // Options hash (but not naming an effect)
  9099. if ( typeof option === "object" && !option.effect ) {
  9100. return true;
  9101. }
  9102. // Didn't match any standard API
  9103. return false;
  9104. }
  9105. $.fn.extend({
  9106. effect: function( /* effect, options, speed, callback */ ) {
  9107. var args = _normalizeArguments.apply( this, arguments ),
  9108. mode = args.mode,
  9109. queue = args.queue,
  9110. effectMethod = $.effects.effect[ args.effect ];
  9111. if ( $.fx.off || !effectMethod ) {
  9112. // delegate to the original method (e.g., .show()) if possible
  9113. if ( mode ) {
  9114. return this[ mode ]( args.duration, args.complete );
  9115. } else {
  9116. return this.each( function() {
  9117. if ( args.complete ) {
  9118. args.complete.call( this );
  9119. }
  9120. });
  9121. }
  9122. }
  9123. function run( next ) {
  9124. var elem = $( this ),
  9125. complete = args.complete,
  9126. mode = args.mode;
  9127. function done() {
  9128. if ( $.isFunction( complete ) ) {
  9129. complete.call( elem[0] );
  9130. }
  9131. if ( $.isFunction( next ) ) {
  9132. next();
  9133. }
  9134. }
  9135. // If the element already has the correct final state, delegate to
  9136. // the core methods so the internal tracking of "olddisplay" works.
  9137. if ( elem.is( ":hidden" ) ? mode === "hide" : mode === "show" ) {
  9138. elem[ mode ]();
  9139. done();
  9140. } else {
  9141. effectMethod.call( elem[0], args, done );
  9142. }
  9143. }
  9144. return queue === false ? this.each( run ) : this.queue( queue || "fx", run );
  9145. },
  9146. show: (function( orig ) {
  9147. return function( option ) {
  9148. if ( standardAnimationOption( option ) ) {
  9149. return orig.apply( this, arguments );
  9150. } else {
  9151. var args = _normalizeArguments.apply( this, arguments );
  9152. args.mode = "show";
  9153. return this.effect.call( this, args );
  9154. }
  9155. };
  9156. })( $.fn.show ),
  9157. hide: (function( orig ) {
  9158. return function( option ) {
  9159. if ( standardAnimationOption( option ) ) {
  9160. return orig.apply( this, arguments );
  9161. } else {
  9162. var args = _normalizeArguments.apply( this, arguments );
  9163. args.mode = "hide";
  9164. return this.effect.call( this, args );
  9165. }
  9166. };
  9167. })( $.fn.hide ),
  9168. toggle: (function( orig ) {
  9169. return function( option ) {
  9170. if ( standardAnimationOption( option ) || typeof option === "boolean" ) {
  9171. return orig.apply( this, arguments );
  9172. } else {
  9173. var args = _normalizeArguments.apply( this, arguments );
  9174. args.mode = "toggle";
  9175. return this.effect.call( this, args );
  9176. }
  9177. };
  9178. })( $.fn.toggle ),
  9179. // helper functions
  9180. cssUnit: function(key) {
  9181. var style = this.css( key ),
  9182. val = [];
  9183. $.each( [ "em", "px", "%", "pt" ], function( i, unit ) {
  9184. if ( style.indexOf( unit ) > 0 ) {
  9185. val = [ parseFloat( style ), unit ];
  9186. }
  9187. });
  9188. return val;
  9189. }
  9190. });
  9191. })();
  9192. /******************************************************************************/
  9193. /*********************************** EASING ***********************************/
  9194. /******************************************************************************/
  9195. (function() {
  9196. // based on easing equations from Robert Penner (http://www.robertpenner.com/easing)
  9197. var baseEasings = {};
  9198. $.each( [ "Quad", "Cubic", "Quart", "Quint", "Expo" ], function( i, name ) {
  9199. baseEasings[ name ] = function( p ) {
  9200. return Math.pow( p, i + 2 );
  9201. };
  9202. });
  9203. $.extend( baseEasings, {
  9204. Sine: function( p ) {
  9205. return 1 - Math.cos( p * Math.PI / 2 );
  9206. },
  9207. Circ: function( p ) {
  9208. return 1 - Math.sqrt( 1 - p * p );
  9209. },
  9210. Elastic: function( p ) {
  9211. return p === 0 || p === 1 ? p :
  9212. -Math.pow( 2, 8 * (p - 1) ) * Math.sin( ( (p - 1) * 80 - 7.5 ) * Math.PI / 15 );
  9213. },
  9214. Back: function( p ) {
  9215. return p * p * ( 3 * p - 2 );
  9216. },
  9217. Bounce: function( p ) {
  9218. var pow2,
  9219. bounce = 4;
  9220. while ( p < ( ( pow2 = Math.pow( 2, --bounce ) ) - 1 ) / 11 ) {}
  9221. return 1 / Math.pow( 4, 3 - bounce ) - 7.5625 * Math.pow( ( pow2 * 3 - 2 ) / 22 - p, 2 );
  9222. }
  9223. });
  9224. $.each( baseEasings, function( name, easeIn ) {
  9225. $.easing[ "easeIn" + name ] = easeIn;
  9226. $.easing[ "easeOut" + name ] = function( p ) {
  9227. return 1 - easeIn( 1 - p );
  9228. };
  9229. $.easing[ "easeInOut" + name ] = function( p ) {
  9230. return p < 0.5 ?
  9231. easeIn( p * 2 ) / 2 :
  9232. 1 - easeIn( p * -2 + 2 ) / 2;
  9233. };
  9234. });
  9235. })();
  9236. var effect = $.effects;
  9237. /*!
  9238. * jQuery UI Effects Blind 1.11.3
  9239. * http://jqueryui.com
  9240. *
  9241. * Copyright jQuery Foundation and other contributors
  9242. * Released under the MIT license.
  9243. * http://jquery.org/license
  9244. *
  9245. * http://api.jqueryui.com/blind-effect/
  9246. */
  9247. var effectBlind = $.effects.effect.blind = function( o, done ) {
  9248. // Create element
  9249. var el = $( this ),
  9250. rvertical = /up|down|vertical/,
  9251. rpositivemotion = /up|left|vertical|horizontal/,
  9252. props = [ "position", "top", "bottom", "left", "right", "height", "width" ],
  9253. mode = $.effects.setMode( el, o.mode || "hide" ),
  9254. direction = o.direction || "up",
  9255. vertical = rvertical.test( direction ),
  9256. ref = vertical ? "height" : "width",
  9257. ref2 = vertical ? "top" : "left",
  9258. motion = rpositivemotion.test( direction ),
  9259. animation = {},
  9260. show = mode === "show",
  9261. wrapper, distance, margin;
  9262. // if already wrapped, the wrapper's properties are my property. #6245
  9263. if ( el.parent().is( ".ui-effects-wrapper" ) ) {
  9264. $.effects.save( el.parent(), props );
  9265. } else {
  9266. $.effects.save( el, props );
  9267. }
  9268. el.show();
  9269. wrapper = $.effects.createWrapper( el ).css({
  9270. overflow: "hidden"
  9271. });
  9272. distance = wrapper[ ref ]();
  9273. margin = parseFloat( wrapper.css( ref2 ) ) || 0;
  9274. animation[ ref ] = show ? distance : 0;
  9275. if ( !motion ) {
  9276. el
  9277. .css( vertical ? "bottom" : "right", 0 )
  9278. .css( vertical ? "top" : "left", "auto" )
  9279. .css({ position: "absolute" });
  9280. animation[ ref2 ] = show ? margin : distance + margin;
  9281. }
  9282. // start at 0 if we are showing
  9283. if ( show ) {
  9284. wrapper.css( ref, 0 );
  9285. if ( !motion ) {
  9286. wrapper.css( ref2, margin + distance );
  9287. }
  9288. }
  9289. // Animate
  9290. wrapper.animate( animation, {
  9291. duration: o.duration,
  9292. easing: o.easing,
  9293. queue: false,
  9294. complete: function() {
  9295. if ( mode === "hide" ) {
  9296. el.hide();
  9297. }
  9298. $.effects.restore( el, props );
  9299. $.effects.removeWrapper( el );
  9300. done();
  9301. }
  9302. });
  9303. };
  9304. /*!
  9305. * jQuery UI Effects Bounce 1.11.3
  9306. * http://jqueryui.com
  9307. *
  9308. * Copyright jQuery Foundation and other contributors
  9309. * Released under the MIT license.
  9310. * http://jquery.org/license
  9311. *
  9312. * http://api.jqueryui.com/bounce-effect/
  9313. */
  9314. var effectBounce = $.effects.effect.bounce = function( o, done ) {
  9315. var el = $( this ),
  9316. props = [ "position", "top", "bottom", "left", "right", "height", "width" ],
  9317. // defaults:
  9318. mode = $.effects.setMode( el, o.mode || "effect" ),
  9319. hide = mode === "hide",
  9320. show = mode === "show",
  9321. direction = o.direction || "up",
  9322. distance = o.distance,
  9323. times = o.times || 5,
  9324. // number of internal animations
  9325. anims = times * 2 + ( show || hide ? 1 : 0 ),
  9326. speed = o.duration / anims,
  9327. easing = o.easing,
  9328. // utility:
  9329. ref = ( direction === "up" || direction === "down" ) ? "top" : "left",
  9330. motion = ( direction === "up" || direction === "left" ),
  9331. i,
  9332. upAnim,
  9333. downAnim,
  9334. // we will need to re-assemble the queue to stack our animations in place
  9335. queue = el.queue(),
  9336. queuelen = queue.length;
  9337. // Avoid touching opacity to prevent clearType and PNG issues in IE
  9338. if ( show || hide ) {
  9339. props.push( "opacity" );
  9340. }
  9341. $.effects.save( el, props );
  9342. el.show();
  9343. $.effects.createWrapper( el ); // Create Wrapper
  9344. // default distance for the BIGGEST bounce is the outer Distance / 3
  9345. if ( !distance ) {
  9346. distance = el[ ref === "top" ? "outerHeight" : "outerWidth" ]() / 3;
  9347. }
  9348. if ( show ) {
  9349. downAnim = { opacity: 1 };
  9350. downAnim[ ref ] = 0;
  9351. // if we are showing, force opacity 0 and set the initial position
  9352. // then do the "first" animation
  9353. el.css( "opacity", 0 )
  9354. .css( ref, motion ? -distance * 2 : distance * 2 )
  9355. .animate( downAnim, speed, easing );
  9356. }
  9357. // start at the smallest distance if we are hiding
  9358. if ( hide ) {
  9359. distance = distance / Math.pow( 2, times - 1 );
  9360. }
  9361. downAnim = {};
  9362. downAnim[ ref ] = 0;
  9363. // Bounces up/down/left/right then back to 0 -- times * 2 animations happen here
  9364. for ( i = 0; i < times; i++ ) {
  9365. upAnim = {};
  9366. upAnim[ ref ] = ( motion ? "-=" : "+=" ) + distance;
  9367. el.animate( upAnim, speed, easing )
  9368. .animate( downAnim, speed, easing );
  9369. distance = hide ? distance * 2 : distance / 2;
  9370. }
  9371. // Last Bounce when Hiding
  9372. if ( hide ) {
  9373. upAnim = { opacity: 0 };
  9374. upAnim[ ref ] = ( motion ? "-=" : "+=" ) + distance;
  9375. el.animate( upAnim, speed, easing );
  9376. }
  9377. el.queue(function() {
  9378. if ( hide ) {
  9379. el.hide();
  9380. }
  9381. $.effects.restore( el, props );
  9382. $.effects.removeWrapper( el );
  9383. done();
  9384. });
  9385. // inject all the animations we just queued to be first in line (after "inprogress")
  9386. if ( queuelen > 1) {
  9387. queue.splice.apply( queue,
  9388. [ 1, 0 ].concat( queue.splice( queuelen, anims + 1 ) ) );
  9389. }
  9390. el.dequeue();
  9391. };
  9392. /*!
  9393. * jQuery UI Effects Clip 1.11.3
  9394. * http://jqueryui.com
  9395. *
  9396. * Copyright jQuery Foundation and other contributors
  9397. * Released under the MIT license.
  9398. * http://jquery.org/license
  9399. *
  9400. * http://api.jqueryui.com/clip-effect/
  9401. */
  9402. var effectClip = $.effects.effect.clip = function( o, done ) {
  9403. // Create element
  9404. var el = $( this ),
  9405. props = [ "position", "top", "bottom", "left", "right", "height", "width" ],
  9406. mode = $.effects.setMode( el, o.mode || "hide" ),
  9407. show = mode === "show",
  9408. direction = o.direction || "vertical",
  9409. vert = direction === "vertical",
  9410. size = vert ? "height" : "width",
  9411. position = vert ? "top" : "left",
  9412. animation = {},
  9413. wrapper, animate, distance;
  9414. // Save & Show
  9415. $.effects.save( el, props );
  9416. el.show();
  9417. // Create Wrapper
  9418. wrapper = $.effects.createWrapper( el ).css({
  9419. overflow: "hidden"
  9420. });
  9421. animate = ( el[0].tagName === "IMG" ) ? wrapper : el;
  9422. distance = animate[ size ]();
  9423. // Shift
  9424. if ( show ) {
  9425. animate.css( size, 0 );
  9426. animate.css( position, distance / 2 );
  9427. }
  9428. // Create Animation Object:
  9429. animation[ size ] = show ? distance : 0;
  9430. animation[ position ] = show ? 0 : distance / 2;
  9431. // Animate
  9432. animate.animate( animation, {
  9433. queue: false,
  9434. duration: o.duration,
  9435. easing: o.easing,
  9436. complete: function() {
  9437. if ( !show ) {
  9438. el.hide();
  9439. }
  9440. $.effects.restore( el, props );
  9441. $.effects.removeWrapper( el );
  9442. done();
  9443. }
  9444. });
  9445. };
  9446. /*!
  9447. * jQuery UI Effects Drop 1.11.3
  9448. * http://jqueryui.com
  9449. *
  9450. * Copyright jQuery Foundation and other contributors
  9451. * Released under the MIT license.
  9452. * http://jquery.org/license
  9453. *
  9454. * http://api.jqueryui.com/drop-effect/
  9455. */
  9456. var effectDrop = $.effects.effect.drop = function( o, done ) {
  9457. var el = $( this ),
  9458. props = [ "position", "top", "bottom", "left", "right", "opacity", "height", "width" ],
  9459. mode = $.effects.setMode( el, o.mode || "hide" ),
  9460. show = mode === "show",
  9461. direction = o.direction || "left",
  9462. ref = ( direction === "up" || direction === "down" ) ? "top" : "left",
  9463. motion = ( direction === "up" || direction === "left" ) ? "pos" : "neg",
  9464. animation = {
  9465. opacity: show ? 1 : 0
  9466. },
  9467. distance;
  9468. // Adjust
  9469. $.effects.save( el, props );
  9470. el.show();
  9471. $.effects.createWrapper( el );
  9472. distance = o.distance || el[ ref === "top" ? "outerHeight" : "outerWidth" ]( true ) / 2;
  9473. if ( show ) {
  9474. el
  9475. .css( "opacity", 0 )
  9476. .css( ref, motion === "pos" ? -distance : distance );
  9477. }
  9478. // Animation
  9479. animation[ ref ] = ( show ?
  9480. ( motion === "pos" ? "+=" : "-=" ) :
  9481. ( motion === "pos" ? "-=" : "+=" ) ) +
  9482. distance;
  9483. // Animate
  9484. el.animate( animation, {
  9485. queue: false,
  9486. duration: o.duration,
  9487. easing: o.easing,
  9488. complete: function() {
  9489. if ( mode === "hide" ) {
  9490. el.hide();
  9491. }
  9492. $.effects.restore( el, props );
  9493. $.effects.removeWrapper( el );
  9494. done();
  9495. }
  9496. });
  9497. };
  9498. /*!
  9499. * jQuery UI Effects Explode 1.11.3
  9500. * http://jqueryui.com
  9501. *
  9502. * Copyright jQuery Foundation and other contributors
  9503. * Released under the MIT license.
  9504. * http://jquery.org/license
  9505. *
  9506. * http://api.jqueryui.com/explode-effect/
  9507. */
  9508. var effectExplode = $.effects.effect.explode = function( o, done ) {
  9509. var rows = o.pieces ? Math.round( Math.sqrt( o.pieces ) ) : 3,
  9510. cells = rows,
  9511. el = $( this ),
  9512. mode = $.effects.setMode( el, o.mode || "hide" ),
  9513. show = mode === "show",
  9514. // show and then visibility:hidden the element before calculating offset
  9515. offset = el.show().css( "visibility", "hidden" ).offset(),
  9516. // width and height of a piece
  9517. width = Math.ceil( el.outerWidth() / cells ),
  9518. height = Math.ceil( el.outerHeight() / rows ),
  9519. pieces = [],
  9520. // loop
  9521. i, j, left, top, mx, my;
  9522. // children animate complete:
  9523. function childComplete() {
  9524. pieces.push( this );
  9525. if ( pieces.length === rows * cells ) {
  9526. animComplete();
  9527. }
  9528. }
  9529. // clone the element for each row and cell.
  9530. for ( i = 0; i < rows ; i++ ) { // ===>
  9531. top = offset.top + i * height;
  9532. my = i - ( rows - 1 ) / 2 ;
  9533. for ( j = 0; j < cells ; j++ ) { // |||
  9534. left = offset.left + j * width;
  9535. mx = j - ( cells - 1 ) / 2 ;
  9536. // Create a clone of the now hidden main element that will be absolute positioned
  9537. // within a wrapper div off the -left and -top equal to size of our pieces
  9538. el
  9539. .clone()
  9540. .appendTo( "body" )
  9541. .wrap( "<div></div>" )
  9542. .css({
  9543. position: "absolute",
  9544. visibility: "visible",
  9545. left: -j * width,
  9546. top: -i * height
  9547. })
  9548. // select the wrapper - make it overflow: hidden and absolute positioned based on
  9549. // where the original was located +left and +top equal to the size of pieces
  9550. .parent()
  9551. .addClass( "ui-effects-explode" )
  9552. .css({
  9553. position: "absolute",
  9554. overflow: "hidden",
  9555. width: width,
  9556. height: height,
  9557. left: left + ( show ? mx * width : 0 ),
  9558. top: top + ( show ? my * height : 0 ),
  9559. opacity: show ? 0 : 1
  9560. }).animate({
  9561. left: left + ( show ? 0 : mx * width ),
  9562. top: top + ( show ? 0 : my * height ),
  9563. opacity: show ? 1 : 0
  9564. }, o.duration || 500, o.easing, childComplete );
  9565. }
  9566. }
  9567. function animComplete() {
  9568. el.css({
  9569. visibility: "visible"
  9570. });
  9571. $( pieces ).remove();
  9572. if ( !show ) {
  9573. el.hide();
  9574. }
  9575. done();
  9576. }
  9577. };
  9578. /*!
  9579. * jQuery UI Effects Fade 1.11.3
  9580. * http://jqueryui.com
  9581. *
  9582. * Copyright jQuery Foundation and other contributors
  9583. * Released under the MIT license.
  9584. * http://jquery.org/license
  9585. *
  9586. * http://api.jqueryui.com/fade-effect/
  9587. */
  9588. var effectFade = $.effects.effect.fade = function( o, done ) {
  9589. var el = $( this ),
  9590. mode = $.effects.setMode( el, o.mode || "toggle" );
  9591. el.animate({
  9592. opacity: mode
  9593. }, {
  9594. queue: false,
  9595. duration: o.duration,
  9596. easing: o.easing,
  9597. complete: done
  9598. });
  9599. };
  9600. /*!
  9601. * jQuery UI Effects Fold 1.11.3
  9602. * http://jqueryui.com
  9603. *
  9604. * Copyright jQuery Foundation and other contributors
  9605. * Released under the MIT license.
  9606. * http://jquery.org/license
  9607. *
  9608. * http://api.jqueryui.com/fold-effect/
  9609. */
  9610. var effectFold = $.effects.effect.fold = function( o, done ) {
  9611. // Create element
  9612. var el = $( this ),
  9613. props = [ "position", "top", "bottom", "left", "right", "height", "width" ],
  9614. mode = $.effects.setMode( el, o.mode || "hide" ),
  9615. show = mode === "show",
  9616. hide = mode === "hide",
  9617. size = o.size || 15,
  9618. percent = /([0-9]+)%/.exec( size ),
  9619. horizFirst = !!o.horizFirst,
  9620. widthFirst = show !== horizFirst,
  9621. ref = widthFirst ? [ "width", "height" ] : [ "height", "width" ],
  9622. duration = o.duration / 2,
  9623. wrapper, distance,
  9624. animation1 = {},
  9625. animation2 = {};
  9626. $.effects.save( el, props );
  9627. el.show();
  9628. // Create Wrapper
  9629. wrapper = $.effects.createWrapper( el ).css({
  9630. overflow: "hidden"
  9631. });
  9632. distance = widthFirst ?
  9633. [ wrapper.width(), wrapper.height() ] :
  9634. [ wrapper.height(), wrapper.width() ];
  9635. if ( percent ) {
  9636. size = parseInt( percent[ 1 ], 10 ) / 100 * distance[ hide ? 0 : 1 ];
  9637. }
  9638. if ( show ) {
  9639. wrapper.css( horizFirst ? {
  9640. height: 0,
  9641. width: size
  9642. } : {
  9643. height: size,
  9644. width: 0
  9645. });
  9646. }
  9647. // Animation
  9648. animation1[ ref[ 0 ] ] = show ? distance[ 0 ] : size;
  9649. animation2[ ref[ 1 ] ] = show ? distance[ 1 ] : 0;
  9650. // Animate
  9651. wrapper
  9652. .animate( animation1, duration, o.easing )
  9653. .animate( animation2, duration, o.easing, function() {
  9654. if ( hide ) {
  9655. el.hide();
  9656. }
  9657. $.effects.restore( el, props );
  9658. $.effects.removeWrapper( el );
  9659. done();
  9660. });
  9661. };
  9662. /*!
  9663. * jQuery UI Effects Highlight 1.11.3
  9664. * http://jqueryui.com
  9665. *
  9666. * Copyright jQuery Foundation and other contributors
  9667. * Released under the MIT license.
  9668. * http://jquery.org/license
  9669. *
  9670. * http://api.jqueryui.com/highlight-effect/
  9671. */
  9672. var effectHighlight = $.effects.effect.highlight = function( o, done ) {
  9673. var elem = $( this ),
  9674. props = [ "backgroundImage", "backgroundColor", "opacity" ],
  9675. mode = $.effects.setMode( elem, o.mode || "show" ),
  9676. animation = {
  9677. backgroundColor: elem.css( "backgroundColor" )
  9678. };
  9679. if (mode === "hide") {
  9680. animation.opacity = 0;
  9681. }
  9682. $.effects.save( elem, props );
  9683. elem
  9684. .show()
  9685. .css({
  9686. backgroundImage: "none",
  9687. backgroundColor: o.color || "#ffff99"
  9688. })
  9689. .animate( animation, {
  9690. queue: false,
  9691. duration: o.duration,
  9692. easing: o.easing,
  9693. complete: function() {
  9694. if ( mode === "hide" ) {
  9695. elem.hide();
  9696. }
  9697. $.effects.restore( elem, props );
  9698. done();
  9699. }
  9700. });
  9701. };
  9702. /*!
  9703. * jQuery UI Effects Size 1.11.3
  9704. * http://jqueryui.com
  9705. *
  9706. * Copyright jQuery Foundation and other contributors
  9707. * Released under the MIT license.
  9708. * http://jquery.org/license
  9709. *
  9710. * http://api.jqueryui.com/size-effect/
  9711. */
  9712. var effectSize = $.effects.effect.size = function( o, done ) {
  9713. // Create element
  9714. var original, baseline, factor,
  9715. el = $( this ),
  9716. props0 = [ "position", "top", "bottom", "left", "right", "width", "height", "overflow", "opacity" ],
  9717. // Always restore
  9718. props1 = [ "position", "top", "bottom", "left", "right", "overflow", "opacity" ],
  9719. // Copy for children
  9720. props2 = [ "width", "height", "overflow" ],
  9721. cProps = [ "fontSize" ],
  9722. vProps = [ "borderTopWidth", "borderBottomWidth", "paddingTop", "paddingBottom" ],
  9723. hProps = [ "borderLeftWidth", "borderRightWidth", "paddingLeft", "paddingRight" ],
  9724. // Set options
  9725. mode = $.effects.setMode( el, o.mode || "effect" ),
  9726. restore = o.restore || mode !== "effect",
  9727. scale = o.scale || "both",
  9728. origin = o.origin || [ "middle", "center" ],
  9729. position = el.css( "position" ),
  9730. props = restore ? props0 : props1,
  9731. zero = {
  9732. height: 0,
  9733. width: 0,
  9734. outerHeight: 0,
  9735. outerWidth: 0
  9736. };
  9737. if ( mode === "show" ) {
  9738. el.show();
  9739. }
  9740. original = {
  9741. height: el.height(),
  9742. width: el.width(),
  9743. outerHeight: el.outerHeight(),
  9744. outerWidth: el.outerWidth()
  9745. };
  9746. if ( o.mode === "toggle" && mode === "show" ) {
  9747. el.from = o.to || zero;
  9748. el.to = o.from || original;
  9749. } else {
  9750. el.from = o.from || ( mode === "show" ? zero : original );
  9751. el.to = o.to || ( mode === "hide" ? zero : original );
  9752. }
  9753. // Set scaling factor
  9754. factor = {
  9755. from: {
  9756. y: el.from.height / original.height,
  9757. x: el.from.width / original.width
  9758. },
  9759. to: {
  9760. y: el.to.height / original.height,
  9761. x: el.to.width / original.width
  9762. }
  9763. };
  9764. // Scale the css box
  9765. if ( scale === "box" || scale === "both" ) {
  9766. // Vertical props scaling
  9767. if ( factor.from.y !== factor.to.y ) {
  9768. props = props.concat( vProps );
  9769. el.from = $.effects.setTransition( el, vProps, factor.from.y, el.from );
  9770. el.to = $.effects.setTransition( el, vProps, factor.to.y, el.to );
  9771. }
  9772. // Horizontal props scaling
  9773. if ( factor.from.x !== factor.to.x ) {
  9774. props = props.concat( hProps );
  9775. el.from = $.effects.setTransition( el, hProps, factor.from.x, el.from );
  9776. el.to = $.effects.setTransition( el, hProps, factor.to.x, el.to );
  9777. }
  9778. }
  9779. // Scale the content
  9780. if ( scale === "content" || scale === "both" ) {
  9781. // Vertical props scaling
  9782. if ( factor.from.y !== factor.to.y ) {
  9783. props = props.concat( cProps ).concat( props2 );
  9784. el.from = $.effects.setTransition( el, cProps, factor.from.y, el.from );
  9785. el.to = $.effects.setTransition( el, cProps, factor.to.y, el.to );
  9786. }
  9787. }
  9788. $.effects.save( el, props );
  9789. el.show();
  9790. $.effects.createWrapper( el );
  9791. el.css( "overflow", "hidden" ).css( el.from );
  9792. // Adjust
  9793. if (origin) { // Calculate baseline shifts
  9794. baseline = $.effects.getBaseline( origin, original );
  9795. el.from.top = ( original.outerHeight - el.outerHeight() ) * baseline.y;
  9796. el.from.left = ( original.outerWidth - el.outerWidth() ) * baseline.x;
  9797. el.to.top = ( original.outerHeight - el.to.outerHeight ) * baseline.y;
  9798. el.to.left = ( original.outerWidth - el.to.outerWidth ) * baseline.x;
  9799. }
  9800. el.css( el.from ); // set top & left
  9801. // Animate
  9802. if ( scale === "content" || scale === "both" ) { // Scale the children
  9803. // Add margins/font-size
  9804. vProps = vProps.concat([ "marginTop", "marginBottom" ]).concat(cProps);
  9805. hProps = hProps.concat([ "marginLeft", "marginRight" ]);
  9806. props2 = props0.concat(vProps).concat(hProps);
  9807. el.find( "*[width]" ).each( function() {
  9808. var child = $( this ),
  9809. c_original = {
  9810. height: child.height(),
  9811. width: child.width(),
  9812. outerHeight: child.outerHeight(),
  9813. outerWidth: child.outerWidth()
  9814. };
  9815. if (restore) {
  9816. $.effects.save(child, props2);
  9817. }
  9818. child.from = {
  9819. height: c_original.height * factor.from.y,
  9820. width: c_original.width * factor.from.x,
  9821. outerHeight: c_original.outerHeight * factor.from.y,
  9822. outerWidth: c_original.outerWidth * factor.from.x
  9823. };
  9824. child.to = {
  9825. height: c_original.height * factor.to.y,
  9826. width: c_original.width * factor.to.x,
  9827. outerHeight: c_original.height * factor.to.y,
  9828. outerWidth: c_original.width * factor.to.x
  9829. };
  9830. // Vertical props scaling
  9831. if ( factor.from.y !== factor.to.y ) {
  9832. child.from = $.effects.setTransition( child, vProps, factor.from.y, child.from );
  9833. child.to = $.effects.setTransition( child, vProps, factor.to.y, child.to );
  9834. }
  9835. // Horizontal props scaling
  9836. if ( factor.from.x !== factor.to.x ) {
  9837. child.from = $.effects.setTransition( child, hProps, factor.from.x, child.from );
  9838. child.to = $.effects.setTransition( child, hProps, factor.to.x, child.to );
  9839. }
  9840. // Animate children
  9841. child.css( child.from );
  9842. child.animate( child.to, o.duration, o.easing, function() {
  9843. // Restore children
  9844. if ( restore ) {
  9845. $.effects.restore( child, props2 );
  9846. }
  9847. });
  9848. });
  9849. }
  9850. // Animate
  9851. el.animate( el.to, {
  9852. queue: false,
  9853. duration: o.duration,
  9854. easing: o.easing,
  9855. complete: function() {
  9856. if ( el.to.opacity === 0 ) {
  9857. el.css( "opacity", el.from.opacity );
  9858. }
  9859. if ( mode === "hide" ) {
  9860. el.hide();
  9861. }
  9862. $.effects.restore( el, props );
  9863. if ( !restore ) {
  9864. // we need to calculate our new positioning based on the scaling
  9865. if ( position === "static" ) {
  9866. el.css({
  9867. position: "relative",
  9868. top: el.to.top,
  9869. left: el.to.left
  9870. });
  9871. } else {
  9872. $.each([ "top", "left" ], function( idx, pos ) {
  9873. el.css( pos, function( _, str ) {
  9874. var val = parseInt( str, 10 ),
  9875. toRef = idx ? el.to.left : el.to.top;
  9876. // if original was "auto", recalculate the new value from wrapper
  9877. if ( str === "auto" ) {
  9878. return toRef + "px";
  9879. }
  9880. return val + toRef + "px";
  9881. });
  9882. });
  9883. }
  9884. }
  9885. $.effects.removeWrapper( el );
  9886. done();
  9887. }
  9888. });
  9889. };
  9890. /*!
  9891. * jQuery UI Effects Scale 1.11.3
  9892. * http://jqueryui.com
  9893. *
  9894. * Copyright jQuery Foundation and other contributors
  9895. * Released under the MIT license.
  9896. * http://jquery.org/license
  9897. *
  9898. * http://api.jqueryui.com/scale-effect/
  9899. */
  9900. var effectScale = $.effects.effect.scale = function( o, done ) {
  9901. // Create element
  9902. var el = $( this ),
  9903. options = $.extend( true, {}, o ),
  9904. mode = $.effects.setMode( el, o.mode || "effect" ),
  9905. percent = parseInt( o.percent, 10 ) ||
  9906. ( parseInt( o.percent, 10 ) === 0 ? 0 : ( mode === "hide" ? 0 : 100 ) ),
  9907. direction = o.direction || "both",
  9908. origin = o.origin,
  9909. original = {
  9910. height: el.height(),
  9911. width: el.width(),
  9912. outerHeight: el.outerHeight(),
  9913. outerWidth: el.outerWidth()
  9914. },
  9915. factor = {
  9916. y: direction !== "horizontal" ? (percent / 100) : 1,
  9917. x: direction !== "vertical" ? (percent / 100) : 1
  9918. };
  9919. // We are going to pass this effect to the size effect:
  9920. options.effect = "size";
  9921. options.queue = false;
  9922. options.complete = done;
  9923. // Set default origin and restore for show/hide
  9924. if ( mode !== "effect" ) {
  9925. options.origin = origin || [ "middle", "center" ];
  9926. options.restore = true;
  9927. }
  9928. options.from = o.from || ( mode === "show" ? {
  9929. height: 0,
  9930. width: 0,
  9931. outerHeight: 0,
  9932. outerWidth: 0
  9933. } : original );
  9934. options.to = {
  9935. height: original.height * factor.y,
  9936. width: original.width * factor.x,
  9937. outerHeight: original.outerHeight * factor.y,
  9938. outerWidth: original.outerWidth * factor.x
  9939. };
  9940. // Fade option to support puff
  9941. if ( options.fade ) {
  9942. if ( mode === "show" ) {
  9943. options.from.opacity = 0;
  9944. options.to.opacity = 1;
  9945. }
  9946. if ( mode === "hide" ) {
  9947. options.from.opacity = 1;
  9948. options.to.opacity = 0;
  9949. }
  9950. }
  9951. // Animate
  9952. el.effect( options );
  9953. };
  9954. /*!
  9955. * jQuery UI Effects Puff 1.11.3
  9956. * http://jqueryui.com
  9957. *
  9958. * Copyright jQuery Foundation and other contributors
  9959. * Released under the MIT license.
  9960. * http://jquery.org/license
  9961. *
  9962. * http://api.jqueryui.com/puff-effect/
  9963. */
  9964. var effectPuff = $.effects.effect.puff = function( o, done ) {
  9965. var elem = $( this ),
  9966. mode = $.effects.setMode( elem, o.mode || "hide" ),
  9967. hide = mode === "hide",
  9968. percent = parseInt( o.percent, 10 ) || 150,
  9969. factor = percent / 100,
  9970. original = {
  9971. height: elem.height(),
  9972. width: elem.width(),
  9973. outerHeight: elem.outerHeight(),
  9974. outerWidth: elem.outerWidth()
  9975. };
  9976. $.extend( o, {
  9977. effect: "scale",
  9978. queue: false,
  9979. fade: true,
  9980. mode: mode,
  9981. complete: done,
  9982. percent: hide ? percent : 100,
  9983. from: hide ?
  9984. original :
  9985. {
  9986. height: original.height * factor,
  9987. width: original.width * factor,
  9988. outerHeight: original.outerHeight * factor,
  9989. outerWidth: original.outerWidth * factor
  9990. }
  9991. });
  9992. elem.effect( o );
  9993. };
  9994. /*!
  9995. * jQuery UI Effects Pulsate 1.11.3
  9996. * http://jqueryui.com
  9997. *
  9998. * Copyright jQuery Foundation and other contributors
  9999. * Released under the MIT license.
  10000. * http://jquery.org/license
  10001. *
  10002. * http://api.jqueryui.com/pulsate-effect/
  10003. */
  10004. var effectPulsate = $.effects.effect.pulsate = function( o, done ) {
  10005. var elem = $( this ),
  10006. mode = $.effects.setMode( elem, o.mode || "show" ),
  10007. show = mode === "show",
  10008. hide = mode === "hide",
  10009. showhide = ( show || mode === "hide" ),
  10010. // showing or hiding leaves of the "last" animation
  10011. anims = ( ( o.times || 5 ) * 2 ) + ( showhide ? 1 : 0 ),
  10012. duration = o.duration / anims,
  10013. animateTo = 0,
  10014. queue = elem.queue(),
  10015. queuelen = queue.length,
  10016. i;
  10017. if ( show || !elem.is(":visible")) {
  10018. elem.css( "opacity", 0 ).show();
  10019. animateTo = 1;
  10020. }
  10021. // anims - 1 opacity "toggles"
  10022. for ( i = 1; i < anims; i++ ) {
  10023. elem.animate({
  10024. opacity: animateTo
  10025. }, duration, o.easing );
  10026. animateTo = 1 - animateTo;
  10027. }
  10028. elem.animate({
  10029. opacity: animateTo
  10030. }, duration, o.easing);
  10031. elem.queue(function() {
  10032. if ( hide ) {
  10033. elem.hide();
  10034. }
  10035. done();
  10036. });
  10037. // We just queued up "anims" animations, we need to put them next in the queue
  10038. if ( queuelen > 1 ) {
  10039. queue.splice.apply( queue,
  10040. [ 1, 0 ].concat( queue.splice( queuelen, anims + 1 ) ) );
  10041. }
  10042. elem.dequeue();
  10043. };
  10044. /*!
  10045. * jQuery UI Effects Shake 1.11.3
  10046. * http://jqueryui.com
  10047. *
  10048. * Copyright jQuery Foundation and other contributors
  10049. * Released under the MIT license.
  10050. * http://jquery.org/license
  10051. *
  10052. * http://api.jqueryui.com/shake-effect/
  10053. */
  10054. var effectShake = $.effects.effect.shake = function( o, done ) {
  10055. var el = $( this ),
  10056. props = [ "position", "top", "bottom", "left", "right", "height", "width" ],
  10057. mode = $.effects.setMode( el, o.mode || "effect" ),
  10058. direction = o.direction || "left",
  10059. distance = o.distance || 20,
  10060. times = o.times || 3,
  10061. anims = times * 2 + 1,
  10062. speed = Math.round( o.duration / anims ),
  10063. ref = (direction === "up" || direction === "down") ? "top" : "left",
  10064. positiveMotion = (direction === "up" || direction === "left"),
  10065. animation = {},
  10066. animation1 = {},
  10067. animation2 = {},
  10068. i,
  10069. // we will need to re-assemble the queue to stack our animations in place
  10070. queue = el.queue(),
  10071. queuelen = queue.length;
  10072. $.effects.save( el, props );
  10073. el.show();
  10074. $.effects.createWrapper( el );
  10075. // Animation
  10076. animation[ ref ] = ( positiveMotion ? "-=" : "+=" ) + distance;
  10077. animation1[ ref ] = ( positiveMotion ? "+=" : "-=" ) + distance * 2;
  10078. animation2[ ref ] = ( positiveMotion ? "-=" : "+=" ) + distance * 2;
  10079. // Animate
  10080. el.animate( animation, speed, o.easing );
  10081. // Shakes
  10082. for ( i = 1; i < times; i++ ) {
  10083. el.animate( animation1, speed, o.easing ).animate( animation2, speed, o.easing );
  10084. }
  10085. el
  10086. .animate( animation1, speed, o.easing )
  10087. .animate( animation, speed / 2, o.easing )
  10088. .queue(function() {
  10089. if ( mode === "hide" ) {
  10090. el.hide();
  10091. }
  10092. $.effects.restore( el, props );
  10093. $.effects.removeWrapper( el );
  10094. done();
  10095. });
  10096. // inject all the animations we just queued to be first in line (after "inprogress")
  10097. if ( queuelen > 1) {
  10098. queue.splice.apply( queue,
  10099. [ 1, 0 ].concat( queue.splice( queuelen, anims + 1 ) ) );
  10100. }
  10101. el.dequeue();
  10102. };
  10103. /*!
  10104. * jQuery UI Effects Slide 1.11.3
  10105. * http://jqueryui.com
  10106. *
  10107. * Copyright jQuery Foundation and other contributors
  10108. * Released under the MIT license.
  10109. * http://jquery.org/license
  10110. *
  10111. * http://api.jqueryui.com/slide-effect/
  10112. */
  10113. var effectSlide = $.effects.effect.slide = function( o, done ) {
  10114. // Create element
  10115. var el = $( this ),
  10116. props = [ "position", "top", "bottom", "left", "right", "width", "height" ],
  10117. mode = $.effects.setMode( el, o.mode || "show" ),
  10118. show = mode === "show",
  10119. direction = o.direction || "left",
  10120. ref = (direction === "up" || direction === "down") ? "top" : "left",
  10121. positiveMotion = (direction === "up" || direction === "left"),
  10122. distance,
  10123. animation = {};
  10124. // Adjust
  10125. $.effects.save( el, props );
  10126. el.show();
  10127. distance = o.distance || el[ ref === "top" ? "outerHeight" : "outerWidth" ]( true );
  10128. $.effects.createWrapper( el ).css({
  10129. overflow: "hidden"
  10130. });
  10131. if ( show ) {
  10132. el.css( ref, positiveMotion ? (isNaN(distance) ? "-" + distance : -distance) : distance );
  10133. }
  10134. // Animation
  10135. animation[ ref ] = ( show ?
  10136. ( positiveMotion ? "+=" : "-=") :
  10137. ( positiveMotion ? "-=" : "+=")) +
  10138. distance;
  10139. // Animate
  10140. el.animate( animation, {
  10141. queue: false,
  10142. duration: o.duration,
  10143. easing: o.easing,
  10144. complete: function() {
  10145. if ( mode === "hide" ) {
  10146. el.hide();
  10147. }
  10148. $.effects.restore( el, props );
  10149. $.effects.removeWrapper( el );
  10150. done();
  10151. }
  10152. });
  10153. };
  10154. /*!
  10155. * jQuery UI Effects Transfer 1.11.3
  10156. * http://jqueryui.com
  10157. *
  10158. * Copyright jQuery Foundation and other contributors
  10159. * Released under the MIT license.
  10160. * http://jquery.org/license
  10161. *
  10162. * http://api.jqueryui.com/transfer-effect/
  10163. */
  10164. var effectTransfer = $.effects.effect.transfer = function( o, done ) {
  10165. var elem = $( this ),
  10166. target = $( o.to ),
  10167. targetFixed = target.css( "position" ) === "fixed",
  10168. body = $("body"),
  10169. fixTop = targetFixed ? body.scrollTop() : 0,
  10170. fixLeft = targetFixed ? body.scrollLeft() : 0,
  10171. endPosition = target.offset(),
  10172. animation = {
  10173. top: endPosition.top - fixTop,
  10174. left: endPosition.left - fixLeft,
  10175. height: target.innerHeight(),
  10176. width: target.innerWidth()
  10177. },
  10178. startPosition = elem.offset(),
  10179. transfer = $( "<div class='ui-effects-transfer'></div>" )
  10180. .appendTo( document.body )
  10181. .addClass( o.className )
  10182. .css({
  10183. top: startPosition.top - fixTop,
  10184. left: startPosition.left - fixLeft,
  10185. height: elem.innerHeight(),
  10186. width: elem.innerWidth(),
  10187. position: targetFixed ? "fixed" : "absolute"
  10188. })
  10189. .animate( animation, o.duration, o.easing, function() {
  10190. transfer.remove();
  10191. done();
  10192. });
  10193. };
  10194. /*!
  10195. * jQuery UI Progressbar 1.11.3
  10196. * http://jqueryui.com
  10197. *
  10198. * Copyright jQuery Foundation and other contributors
  10199. * Released under the MIT license.
  10200. * http://jquery.org/license
  10201. *
  10202. * http://api.jqueryui.com/progressbar/
  10203. */
  10204. var progressbar = $.widget( "ui.progressbar", {
  10205. version: "1.11.3",
  10206. options: {
  10207. max: 100,
  10208. value: 0,
  10209. change: null,
  10210. complete: null
  10211. },
  10212. min: 0,
  10213. _create: function() {
  10214. // Constrain initial value
  10215. this.oldValue = this.options.value = this._constrainedValue();
  10216. this.element
  10217. .addClass( "ui-progressbar ui-widget ui-widget-content ui-corner-all" )
  10218. .attr({
  10219. // Only set static values, aria-valuenow and aria-valuemax are
  10220. // set inside _refreshValue()
  10221. role: "progressbar",
  10222. "aria-valuemin": this.min
  10223. });
  10224. this.valueDiv = $( "<div class='ui-progressbar-value ui-widget-header ui-corner-left'></div>" )
  10225. .appendTo( this.element );
  10226. this._refreshValue();
  10227. },
  10228. _destroy: function() {
  10229. this.element
  10230. .removeClass( "ui-progressbar ui-widget ui-widget-content ui-corner-all" )
  10231. .removeAttr( "role" )
  10232. .removeAttr( "aria-valuemin" )
  10233. .removeAttr( "aria-valuemax" )
  10234. .removeAttr( "aria-valuenow" );
  10235. this.valueDiv.remove();
  10236. },
  10237. value: function( newValue ) {
  10238. if ( newValue === undefined ) {
  10239. return this.options.value;
  10240. }
  10241. this.options.value = this._constrainedValue( newValue );
  10242. this._refreshValue();
  10243. },
  10244. _constrainedValue: function( newValue ) {
  10245. if ( newValue === undefined ) {
  10246. newValue = this.options.value;
  10247. }
  10248. this.indeterminate = newValue === false;
  10249. // sanitize value
  10250. if ( typeof newValue !== "number" ) {
  10251. newValue = 0;
  10252. }
  10253. return this.indeterminate ? false :
  10254. Math.min( this.options.max, Math.max( this.min, newValue ) );
  10255. },
  10256. _setOptions: function( options ) {
  10257. // Ensure "value" option is set after other values (like max)
  10258. var value = options.value;
  10259. delete options.value;
  10260. this._super( options );
  10261. this.options.value = this._constrainedValue( value );
  10262. this._refreshValue();
  10263. },
  10264. _setOption: function( key, value ) {
  10265. if ( key === "max" ) {
  10266. // Don't allow a max less than min
  10267. value = Math.max( this.min, value );
  10268. }
  10269. if ( key === "disabled" ) {
  10270. this.element
  10271. .toggleClass( "ui-state-disabled", !!value )
  10272. .attr( "aria-disabled", value );
  10273. }
  10274. this._super( key, value );
  10275. },
  10276. _percentage: function() {
  10277. return this.indeterminate ? 100 : 100 * ( this.options.value - this.min ) / ( this.options.max - this.min );
  10278. },
  10279. _refreshValue: function() {
  10280. var value = this.options.value,
  10281. percentage = this._percentage();
  10282. this.valueDiv
  10283. .toggle( this.indeterminate || value > this.min )
  10284. .toggleClass( "ui-corner-right", value === this.options.max )
  10285. .width( percentage.toFixed(0) + "%" );
  10286. this.element.toggleClass( "ui-progressbar-indeterminate", this.indeterminate );
  10287. if ( this.indeterminate ) {
  10288. this.element.removeAttr( "aria-valuenow" );
  10289. if ( !this.overlayDiv ) {
  10290. this.overlayDiv = $( "<div class='ui-progressbar-overlay'></div>" ).appendTo( this.valueDiv );
  10291. }
  10292. } else {
  10293. this.element.attr({
  10294. "aria-valuemax": this.options.max,
  10295. "aria-valuenow": value
  10296. });
  10297. if ( this.overlayDiv ) {
  10298. this.overlayDiv.remove();
  10299. this.overlayDiv = null;
  10300. }
  10301. }
  10302. if ( this.oldValue !== value ) {
  10303. this.oldValue = value;
  10304. this._trigger( "change" );
  10305. }
  10306. if ( value === this.options.max ) {
  10307. this._trigger( "complete" );
  10308. }
  10309. }
  10310. });
  10311. /*!
  10312. * jQuery UI Selectable 1.11.3
  10313. * http://jqueryui.com
  10314. *
  10315. * Copyright jQuery Foundation and other contributors
  10316. * Released under the MIT license.
  10317. * http://jquery.org/license
  10318. *
  10319. * http://api.jqueryui.com/selectable/
  10320. */
  10321. var selectable = $.widget("ui.selectable", $.ui.mouse, {
  10322. version: "1.11.3",
  10323. options: {
  10324. appendTo: "body",
  10325. autoRefresh: true,
  10326. distance: 0,
  10327. filter: "*",
  10328. tolerance: "touch",
  10329. // callbacks
  10330. selected: null,
  10331. selecting: null,
  10332. start: null,
  10333. stop: null,
  10334. unselected: null,
  10335. unselecting: null
  10336. },
  10337. _create: function() {
  10338. var selectees,
  10339. that = this;
  10340. this.element.addClass("ui-selectable");
  10341. this.dragged = false;
  10342. // cache selectee children based on filter
  10343. this.refresh = function() {
  10344. selectees = $(that.options.filter, that.element[0]);
  10345. selectees.addClass("ui-selectee");
  10346. selectees.each(function() {
  10347. var $this = $(this),
  10348. pos = $this.offset();
  10349. $.data(this, "selectable-item", {
  10350. element: this,
  10351. $element: $this,
  10352. left: pos.left,
  10353. top: pos.top,
  10354. right: pos.left + $this.outerWidth(),
  10355. bottom: pos.top + $this.outerHeight(),
  10356. startselected: false,
  10357. selected: $this.hasClass("ui-selected"),
  10358. selecting: $this.hasClass("ui-selecting"),
  10359. unselecting: $this.hasClass("ui-unselecting")
  10360. });
  10361. });
  10362. };
  10363. this.refresh();
  10364. this.selectees = selectees.addClass("ui-selectee");
  10365. this._mouseInit();
  10366. this.helper = $("<div class='ui-selectable-helper'></div>");
  10367. },
  10368. _destroy: function() {
  10369. this.selectees
  10370. .removeClass("ui-selectee")
  10371. .removeData("selectable-item");
  10372. this.element
  10373. .removeClass("ui-selectable ui-selectable-disabled");
  10374. this._mouseDestroy();
  10375. },
  10376. _mouseStart: function(event) {
  10377. var that = this,
  10378. options = this.options;
  10379. this.opos = [ event.pageX, event.pageY ];
  10380. if (this.options.disabled) {
  10381. return;
  10382. }
  10383. this.selectees = $(options.filter, this.element[0]);
  10384. this._trigger("start", event);
  10385. $(options.appendTo).append(this.helper);
  10386. // position helper (lasso)
  10387. this.helper.css({
  10388. "left": event.pageX,
  10389. "top": event.pageY,
  10390. "width": 0,
  10391. "height": 0
  10392. });
  10393. if (options.autoRefresh) {
  10394. this.refresh();
  10395. }
  10396. this.selectees.filter(".ui-selected").each(function() {
  10397. var selectee = $.data(this, "selectable-item");
  10398. selectee.startselected = true;
  10399. if (!event.metaKey && !event.ctrlKey) {
  10400. selectee.$element.removeClass("ui-selected");
  10401. selectee.selected = false;
  10402. selectee.$element.addClass("ui-unselecting");
  10403. selectee.unselecting = true;
  10404. // selectable UNSELECTING callback
  10405. that._trigger("unselecting", event, {
  10406. unselecting: selectee.element
  10407. });
  10408. }
  10409. });
  10410. $(event.target).parents().addBack().each(function() {
  10411. var doSelect,
  10412. selectee = $.data(this, "selectable-item");
  10413. if (selectee) {
  10414. doSelect = (!event.metaKey && !event.ctrlKey) || !selectee.$element.hasClass("ui-selected");
  10415. selectee.$element
  10416. .removeClass(doSelect ? "ui-unselecting" : "ui-selected")
  10417. .addClass(doSelect ? "ui-selecting" : "ui-unselecting");
  10418. selectee.unselecting = !doSelect;
  10419. selectee.selecting = doSelect;
  10420. selectee.selected = doSelect;
  10421. // selectable (UN)SELECTING callback
  10422. if (doSelect) {
  10423. that._trigger("selecting", event, {
  10424. selecting: selectee.element
  10425. });
  10426. } else {
  10427. that._trigger("unselecting", event, {
  10428. unselecting: selectee.element
  10429. });
  10430. }
  10431. return false;
  10432. }
  10433. });
  10434. },
  10435. _mouseDrag: function(event) {
  10436. this.dragged = true;
  10437. if (this.options.disabled) {
  10438. return;
  10439. }
  10440. var tmp,
  10441. that = this,
  10442. options = this.options,
  10443. x1 = this.opos[0],
  10444. y1 = this.opos[1],
  10445. x2 = event.pageX,
  10446. y2 = event.pageY;
  10447. if (x1 > x2) { tmp = x2; x2 = x1; x1 = tmp; }
  10448. if (y1 > y2) { tmp = y2; y2 = y1; y1 = tmp; }
  10449. this.helper.css({ left: x1, top: y1, width: x2 - x1, height: y2 - y1 });
  10450. this.selectees.each(function() {
  10451. var selectee = $.data(this, "selectable-item"),
  10452. hit = false;
  10453. //prevent helper from being selected if appendTo: selectable
  10454. if (!selectee || selectee.element === that.element[0]) {
  10455. return;
  10456. }
  10457. if (options.tolerance === "touch") {
  10458. hit = ( !(selectee.left > x2 || selectee.right < x1 || selectee.top > y2 || selectee.bottom < y1) );
  10459. } else if (options.tolerance === "fit") {
  10460. hit = (selectee.left > x1 && selectee.right < x2 && selectee.top > y1 && selectee.bottom < y2);
  10461. }
  10462. if (hit) {
  10463. // SELECT
  10464. if (selectee.selected) {
  10465. selectee.$element.removeClass("ui-selected");
  10466. selectee.selected = false;
  10467. }
  10468. if (selectee.unselecting) {
  10469. selectee.$element.removeClass("ui-unselecting");
  10470. selectee.unselecting = false;
  10471. }
  10472. if (!selectee.selecting) {
  10473. selectee.$element.addClass("ui-selecting");
  10474. selectee.selecting = true;
  10475. // selectable SELECTING callback
  10476. that._trigger("selecting", event, {
  10477. selecting: selectee.element
  10478. });
  10479. }
  10480. } else {
  10481. // UNSELECT
  10482. if (selectee.selecting) {
  10483. if ((event.metaKey || event.ctrlKey) && selectee.startselected) {
  10484. selectee.$element.removeClass("ui-selecting");
  10485. selectee.selecting = false;
  10486. selectee.$element.addClass("ui-selected");
  10487. selectee.selected = true;
  10488. } else {
  10489. selectee.$element.removeClass("ui-selecting");
  10490. selectee.selecting = false;
  10491. if (selectee.startselected) {
  10492. selectee.$element.addClass("ui-unselecting");
  10493. selectee.unselecting = true;
  10494. }
  10495. // selectable UNSELECTING callback
  10496. that._trigger("unselecting", event, {
  10497. unselecting: selectee.element
  10498. });
  10499. }
  10500. }
  10501. if (selectee.selected) {
  10502. if (!event.metaKey && !event.ctrlKey && !selectee.startselected) {
  10503. selectee.$element.removeClass("ui-selected");
  10504. selectee.selected = false;
  10505. selectee.$element.addClass("ui-unselecting");
  10506. selectee.unselecting = true;
  10507. // selectable UNSELECTING callback
  10508. that._trigger("unselecting", event, {
  10509. unselecting: selectee.element
  10510. });
  10511. }
  10512. }
  10513. }
  10514. });
  10515. return false;
  10516. },
  10517. _mouseStop: function(event) {
  10518. var that = this;
  10519. this.dragged = false;
  10520. $(".ui-unselecting", this.element[0]).each(function() {
  10521. var selectee = $.data(this, "selectable-item");
  10522. selectee.$element.removeClass("ui-unselecting");
  10523. selectee.unselecting = false;
  10524. selectee.startselected = false;
  10525. that._trigger("unselected", event, {
  10526. unselected: selectee.element
  10527. });
  10528. });
  10529. $(".ui-selecting", this.element[0]).each(function() {
  10530. var selectee = $.data(this, "selectable-item");
  10531. selectee.$element.removeClass("ui-selecting").addClass("ui-selected");
  10532. selectee.selecting = false;
  10533. selectee.selected = true;
  10534. selectee.startselected = true;
  10535. that._trigger("selected", event, {
  10536. selected: selectee.element
  10537. });
  10538. });
  10539. this._trigger("stop", event);
  10540. this.helper.remove();
  10541. return false;
  10542. }
  10543. });
  10544. /*!
  10545. * jQuery UI Selectmenu 1.11.3
  10546. * http://jqueryui.com
  10547. *
  10548. * Copyright jQuery Foundation and other contributors
  10549. * Released under the MIT license.
  10550. * http://jquery.org/license
  10551. *
  10552. * http://api.jqueryui.com/selectmenu
  10553. */
  10554. var selectmenu = $.widget( "ui.selectmenu", {
  10555. version: "1.11.3",
  10556. defaultElement: "<select>",
  10557. options: {
  10558. appendTo: null,
  10559. disabled: null,
  10560. icons: {
  10561. button: "ui-icon-triangle-1-s"
  10562. },
  10563. position: {
  10564. my: "left top",
  10565. at: "left bottom",
  10566. collision: "none"
  10567. },
  10568. width: null,
  10569. // callbacks
  10570. change: null,
  10571. close: null,
  10572. focus: null,
  10573. open: null,
  10574. select: null
  10575. },
  10576. _create: function() {
  10577. var selectmenuId = this.element.uniqueId().attr( "id" );
  10578. this.ids = {
  10579. element: selectmenuId,
  10580. button: selectmenuId + "-button",
  10581. menu: selectmenuId + "-menu"
  10582. };
  10583. this._drawButton();
  10584. this._drawMenu();
  10585. if ( this.options.disabled ) {
  10586. this.disable();
  10587. }
  10588. },
  10589. _drawButton: function() {
  10590. var that = this;
  10591. // Associate existing label with the new button
  10592. this.label = $( "label[for='" + this.ids.element + "']" ).attr( "for", this.ids.button );
  10593. this._on( this.label, {
  10594. click: function( event ) {
  10595. this.button.focus();
  10596. event.preventDefault();
  10597. }
  10598. });
  10599. // Hide original select element
  10600. this.element.hide();
  10601. // Create button
  10602. this.button = $( "<span>", {
  10603. "class": "ui-selectmenu-button ui-widget ui-state-default ui-corner-all",
  10604. tabindex: this.options.disabled ? -1 : 0,
  10605. id: this.ids.button,
  10606. role: "combobox",
  10607. "aria-expanded": "false",
  10608. "aria-autocomplete": "list",
  10609. "aria-owns": this.ids.menu,
  10610. "aria-haspopup": "true"
  10611. })
  10612. .insertAfter( this.element );
  10613. $( "<span>", {
  10614. "class": "ui-icon " + this.options.icons.button
  10615. })
  10616. .prependTo( this.button );
  10617. this.buttonText = $( "<span>", {
  10618. "class": "ui-selectmenu-text"
  10619. })
  10620. .appendTo( this.button );
  10621. this._setText( this.buttonText, this.element.find( "option:selected" ).text() );
  10622. this._resizeButton();
  10623. this._on( this.button, this._buttonEvents );
  10624. this.button.one( "focusin", function() {
  10625. // Delay rendering the menu items until the button receives focus.
  10626. // The menu may have already been rendered via a programmatic open.
  10627. if ( !that.menuItems ) {
  10628. that._refreshMenu();
  10629. }
  10630. });
  10631. this._hoverable( this.button );
  10632. this._focusable( this.button );
  10633. },
  10634. _drawMenu: function() {
  10635. var that = this;
  10636. // Create menu
  10637. this.menu = $( "<ul>", {
  10638. "aria-hidden": "true",
  10639. "aria-labelledby": this.ids.button,
  10640. id: this.ids.menu
  10641. });
  10642. // Wrap menu
  10643. this.menuWrap = $( "<div>", {
  10644. "class": "ui-selectmenu-menu ui-front"
  10645. })
  10646. .append( this.menu )
  10647. .appendTo( this._appendTo() );
  10648. // Initialize menu widget
  10649. this.menuInstance = this.menu
  10650. .menu({
  10651. role: "listbox",
  10652. select: function( event, ui ) {
  10653. event.preventDefault();
  10654. // support: IE8
  10655. // If the item was selected via a click, the text selection
  10656. // will be destroyed in IE
  10657. that._setSelection();
  10658. that._select( ui.item.data( "ui-selectmenu-item" ), event );
  10659. },
  10660. focus: function( event, ui ) {
  10661. var item = ui.item.data( "ui-selectmenu-item" );
  10662. // Prevent inital focus from firing and check if its a newly focused item
  10663. if ( that.focusIndex != null && item.index !== that.focusIndex ) {
  10664. that._trigger( "focus", event, { item: item } );
  10665. if ( !that.isOpen ) {
  10666. that._select( item, event );
  10667. }
  10668. }
  10669. that.focusIndex = item.index;
  10670. that.button.attr( "aria-activedescendant",
  10671. that.menuItems.eq( item.index ).attr( "id" ) );
  10672. }
  10673. })
  10674. .menu( "instance" );
  10675. // Adjust menu styles to dropdown
  10676. this.menu
  10677. .addClass( "ui-corner-bottom" )
  10678. .removeClass( "ui-corner-all" );
  10679. // Don't close the menu on mouseleave
  10680. this.menuInstance._off( this.menu, "mouseleave" );
  10681. // Cancel the menu's collapseAll on document click
  10682. this.menuInstance._closeOnDocumentClick = function() {
  10683. return false;
  10684. };
  10685. // Selects often contain empty items, but never contain dividers
  10686. this.menuInstance._isDivider = function() {
  10687. return false;
  10688. };
  10689. },
  10690. refresh: function() {
  10691. this._refreshMenu();
  10692. this._setText( this.buttonText, this._getSelectedItem().text() );
  10693. if ( !this.options.width ) {
  10694. this._resizeButton();
  10695. }
  10696. },
  10697. _refreshMenu: function() {
  10698. this.menu.empty();
  10699. var item,
  10700. options = this.element.find( "option" );
  10701. if ( !options.length ) {
  10702. return;
  10703. }
  10704. this._parseOptions( options );
  10705. this._renderMenu( this.menu, this.items );
  10706. this.menuInstance.refresh();
  10707. this.menuItems = this.menu.find( "li" ).not( ".ui-selectmenu-optgroup" );
  10708. item = this._getSelectedItem();
  10709. // Update the menu to have the correct item focused
  10710. this.menuInstance.focus( null, item );
  10711. this._setAria( item.data( "ui-selectmenu-item" ) );
  10712. // Set disabled state
  10713. this._setOption( "disabled", this.element.prop( "disabled" ) );
  10714. },
  10715. open: function( event ) {
  10716. if ( this.options.disabled ) {
  10717. return;
  10718. }
  10719. // If this is the first time the menu is being opened, render the items
  10720. if ( !this.menuItems ) {
  10721. this._refreshMenu();
  10722. } else {
  10723. // Menu clears focus on close, reset focus to selected item
  10724. this.menu.find( ".ui-state-focus" ).removeClass( "ui-state-focus" );
  10725. this.menuInstance.focus( null, this._getSelectedItem() );
  10726. }
  10727. this.isOpen = true;
  10728. this._toggleAttr();
  10729. this._resizeMenu();
  10730. this._position();
  10731. this._on( this.document, this._documentClick );
  10732. this._trigger( "open", event );
  10733. },
  10734. _position: function() {
  10735. this.menuWrap.position( $.extend( { of: this.button }, this.options.position ) );
  10736. },
  10737. close: function( event ) {
  10738. if ( !this.isOpen ) {
  10739. return;
  10740. }
  10741. this.isOpen = false;
  10742. this._toggleAttr();
  10743. this.range = null;
  10744. this._off( this.document );
  10745. this._trigger( "close", event );
  10746. },
  10747. widget: function() {
  10748. return this.button;
  10749. },
  10750. menuWidget: function() {
  10751. return this.menu;
  10752. },
  10753. _renderMenu: function( ul, items ) {
  10754. var that = this,
  10755. currentOptgroup = "";
  10756. $.each( items, function( index, item ) {
  10757. if ( item.optgroup !== currentOptgroup ) {
  10758. $( "<li>", {
  10759. "class": "ui-selectmenu-optgroup ui-menu-divider" +
  10760. ( item.element.parent( "optgroup" ).prop( "disabled" ) ?
  10761. " ui-state-disabled" :
  10762. "" ),
  10763. text: item.optgroup
  10764. })
  10765. .appendTo( ul );
  10766. currentOptgroup = item.optgroup;
  10767. }
  10768. that._renderItemData( ul, item );
  10769. });
  10770. },
  10771. _renderItemData: function( ul, item ) {
  10772. return this._renderItem( ul, item ).data( "ui-selectmenu-item", item );
  10773. },
  10774. _renderItem: function( ul, item ) {
  10775. var li = $( "<li>" );
  10776. if ( item.disabled ) {
  10777. li.addClass( "ui-state-disabled" );
  10778. }
  10779. this._setText( li, item.label );
  10780. return li.appendTo( ul );
  10781. },
  10782. _setText: function( element, value ) {
  10783. if ( value ) {
  10784. element.text( value );
  10785. } else {
  10786. element.html( "&#160;" );
  10787. }
  10788. },
  10789. _move: function( direction, event ) {
  10790. var item, next,
  10791. filter = ".ui-menu-item";
  10792. if ( this.isOpen ) {
  10793. item = this.menuItems.eq( this.focusIndex );
  10794. } else {
  10795. item = this.menuItems.eq( this.element[ 0 ].selectedIndex );
  10796. filter += ":not(.ui-state-disabled)";
  10797. }
  10798. if ( direction === "first" || direction === "last" ) {
  10799. next = item[ direction === "first" ? "prevAll" : "nextAll" ]( filter ).eq( -1 );
  10800. } else {
  10801. next = item[ direction + "All" ]( filter ).eq( 0 );
  10802. }
  10803. if ( next.length ) {
  10804. this.menuInstance.focus( event, next );
  10805. }
  10806. },
  10807. _getSelectedItem: function() {
  10808. return this.menuItems.eq( this.element[ 0 ].selectedIndex );
  10809. },
  10810. _toggle: function( event ) {
  10811. this[ this.isOpen ? "close" : "open" ]( event );
  10812. },
  10813. _setSelection: function() {
  10814. var selection;
  10815. if ( !this.range ) {
  10816. return;
  10817. }
  10818. if ( window.getSelection ) {
  10819. selection = window.getSelection();
  10820. selection.removeAllRanges();
  10821. selection.addRange( this.range );
  10822. // support: IE8
  10823. } else {
  10824. this.range.select();
  10825. }
  10826. // support: IE
  10827. // Setting the text selection kills the button focus in IE, but
  10828. // restoring the focus doesn't kill the selection.
  10829. this.button.focus();
  10830. },
  10831. _documentClick: {
  10832. mousedown: function( event ) {
  10833. if ( !this.isOpen ) {
  10834. return;
  10835. }
  10836. if ( !$( event.target ).closest( ".ui-selectmenu-menu, #" + this.ids.button ).length ) {
  10837. this.close( event );
  10838. }
  10839. }
  10840. },
  10841. _buttonEvents: {
  10842. // Prevent text selection from being reset when interacting with the selectmenu (#10144)
  10843. mousedown: function() {
  10844. var selection;
  10845. if ( window.getSelection ) {
  10846. selection = window.getSelection();
  10847. if ( selection.rangeCount ) {
  10848. this.range = selection.getRangeAt( 0 );
  10849. }
  10850. // support: IE8
  10851. } else {
  10852. this.range = document.selection.createRange();
  10853. }
  10854. },
  10855. click: function( event ) {
  10856. this._setSelection();
  10857. this._toggle( event );
  10858. },
  10859. keydown: function( event ) {
  10860. var preventDefault = true;
  10861. switch ( event.keyCode ) {
  10862. case $.ui.keyCode.TAB:
  10863. case $.ui.keyCode.ESCAPE:
  10864. this.close( event );
  10865. preventDefault = false;
  10866. break;
  10867. case $.ui.keyCode.ENTER:
  10868. if ( this.isOpen ) {
  10869. this._selectFocusedItem( event );
  10870. }
  10871. break;
  10872. case $.ui.keyCode.UP:
  10873. if ( event.altKey ) {
  10874. this._toggle( event );
  10875. } else {
  10876. this._move( "prev", event );
  10877. }
  10878. break;
  10879. case $.ui.keyCode.DOWN:
  10880. if ( event.altKey ) {
  10881. this._toggle( event );
  10882. } else {
  10883. this._move( "next", event );
  10884. }
  10885. break;
  10886. case $.ui.keyCode.SPACE:
  10887. if ( this.isOpen ) {
  10888. this._selectFocusedItem( event );
  10889. } else {
  10890. this._toggle( event );
  10891. }
  10892. break;
  10893. case $.ui.keyCode.LEFT:
  10894. this._move( "prev", event );
  10895. break;
  10896. case $.ui.keyCode.RIGHT:
  10897. this._move( "next", event );
  10898. break;
  10899. case $.ui.keyCode.HOME:
  10900. case $.ui.keyCode.PAGE_UP:
  10901. this._move( "first", event );
  10902. break;
  10903. case $.ui.keyCode.END:
  10904. case $.ui.keyCode.PAGE_DOWN:
  10905. this._move( "last", event );
  10906. break;
  10907. default:
  10908. this.menu.trigger( event );
  10909. preventDefault = false;
  10910. }
  10911. if ( preventDefault ) {
  10912. event.preventDefault();
  10913. }
  10914. }
  10915. },
  10916. _selectFocusedItem: function( event ) {
  10917. var item = this.menuItems.eq( this.focusIndex );
  10918. if ( !item.hasClass( "ui-state-disabled" ) ) {
  10919. this._select( item.data( "ui-selectmenu-item" ), event );
  10920. }
  10921. },
  10922. _select: function( item, event ) {
  10923. var oldIndex = this.element[ 0 ].selectedIndex;
  10924. // Change native select element
  10925. this.element[ 0 ].selectedIndex = item.index;
  10926. this._setText( this.buttonText, item.label );
  10927. this._setAria( item );
  10928. this._trigger( "select", event, { item: item } );
  10929. if ( item.index !== oldIndex ) {
  10930. this._trigger( "change", event, { item: item } );
  10931. }
  10932. this.close( event );
  10933. },
  10934. _setAria: function( item ) {
  10935. var id = this.menuItems.eq( item.index ).attr( "id" );
  10936. this.button.attr({
  10937. "aria-labelledby": id,
  10938. "aria-activedescendant": id
  10939. });
  10940. this.menu.attr( "aria-activedescendant", id );
  10941. },
  10942. _setOption: function( key, value ) {
  10943. if ( key === "icons" ) {
  10944. this.button.find( "span.ui-icon" )
  10945. .removeClass( this.options.icons.button )
  10946. .addClass( value.button );
  10947. }
  10948. this._super( key, value );
  10949. if ( key === "appendTo" ) {
  10950. this.menuWrap.appendTo( this._appendTo() );
  10951. }
  10952. if ( key === "disabled" ) {
  10953. this.menuInstance.option( "disabled", value );
  10954. this.button
  10955. .toggleClass( "ui-state-disabled", value )
  10956. .attr( "aria-disabled", value );
  10957. this.element.prop( "disabled", value );
  10958. if ( value ) {
  10959. this.button.attr( "tabindex", -1 );
  10960. this.close();
  10961. } else {
  10962. this.button.attr( "tabindex", 0 );
  10963. }
  10964. }
  10965. if ( key === "width" ) {
  10966. this._resizeButton();
  10967. }
  10968. },
  10969. _appendTo: function() {
  10970. var element = this.options.appendTo;
  10971. if ( element ) {
  10972. element = element.jquery || element.nodeType ?
  10973. $( element ) :
  10974. this.document.find( element ).eq( 0 );
  10975. }
  10976. if ( !element || !element[ 0 ] ) {
  10977. element = this.element.closest( ".ui-front" );
  10978. }
  10979. if ( !element.length ) {
  10980. element = this.document[ 0 ].body;
  10981. }
  10982. return element;
  10983. },
  10984. _toggleAttr: function() {
  10985. this.button
  10986. .toggleClass( "ui-corner-top", this.isOpen )
  10987. .toggleClass( "ui-corner-all", !this.isOpen )
  10988. .attr( "aria-expanded", this.isOpen );
  10989. this.menuWrap.toggleClass( "ui-selectmenu-open", this.isOpen );
  10990. this.menu.attr( "aria-hidden", !this.isOpen );
  10991. },
  10992. _resizeButton: function() {
  10993. var width = this.options.width;
  10994. if ( !width ) {
  10995. width = this.element.show().outerWidth();
  10996. this.element.hide();
  10997. }
  10998. this.button.outerWidth( width );
  10999. },
  11000. _resizeMenu: function() {
  11001. this.menu.outerWidth( Math.max(
  11002. this.button.outerWidth(),
  11003. // support: IE10
  11004. // IE10 wraps long text (possibly a rounding bug)
  11005. // so we add 1px to avoid the wrapping
  11006. this.menu.width( "" ).outerWidth() + 1
  11007. ) );
  11008. },
  11009. _getCreateOptions: function() {
  11010. return { disabled: this.element.prop( "disabled" ) };
  11011. },
  11012. _parseOptions: function( options ) {
  11013. var data = [];
  11014. options.each(function( index, item ) {
  11015. var option = $( item ),
  11016. optgroup = option.parent( "optgroup" );
  11017. data.push({
  11018. element: option,
  11019. index: index,
  11020. value: option.val(),
  11021. label: option.text(),
  11022. optgroup: optgroup.attr( "label" ) || "",
  11023. disabled: optgroup.prop( "disabled" ) || option.prop( "disabled" )
  11024. });
  11025. });
  11026. this.items = data;
  11027. },
  11028. _destroy: function() {
  11029. this.menuWrap.remove();
  11030. this.button.remove();
  11031. this.element.show();
  11032. this.element.removeUniqueId();
  11033. this.label.attr( "for", this.ids.element );
  11034. }
  11035. });
  11036. /*!
  11037. * jQuery UI Slider 1.11.3
  11038. * http://jqueryui.com
  11039. *
  11040. * Copyright jQuery Foundation and other contributors
  11041. * Released under the MIT license.
  11042. * http://jquery.org/license
  11043. *
  11044. * http://api.jqueryui.com/slider/
  11045. */
  11046. var slider = $.widget( "ui.slider", $.ui.mouse, {
  11047. version: "1.11.3",
  11048. widgetEventPrefix: "slide",
  11049. options: {
  11050. animate: false,
  11051. distance: 0,
  11052. max: 100,
  11053. min: 0,
  11054. orientation: "horizontal",
  11055. range: false,
  11056. step: 1,
  11057. value: 0,
  11058. values: null,
  11059. // callbacks
  11060. change: null,
  11061. slide: null,
  11062. start: null,
  11063. stop: null
  11064. },
  11065. // number of pages in a slider
  11066. // (how many times can you page up/down to go through the whole range)
  11067. numPages: 5,
  11068. _create: function() {
  11069. this._keySliding = false;
  11070. this._mouseSliding = false;
  11071. this._animateOff = true;
  11072. this._handleIndex = null;
  11073. this._detectOrientation();
  11074. this._mouseInit();
  11075. this._calculateNewMax();
  11076. this.element
  11077. .addClass( "ui-slider" +
  11078. " ui-slider-" + this.orientation +
  11079. " ui-widget" +
  11080. " ui-widget-content" +
  11081. " ui-corner-all");
  11082. this._refresh();
  11083. this._setOption( "disabled", this.options.disabled );
  11084. this._animateOff = false;
  11085. },
  11086. _refresh: function() {
  11087. this._createRange();
  11088. this._createHandles();
  11089. this._setupEvents();
  11090. this._refreshValue();
  11091. },
  11092. _createHandles: function() {
  11093. var i, handleCount,
  11094. options = this.options,
  11095. existingHandles = this.element.find( ".ui-slider-handle" ).addClass( "ui-state-default ui-corner-all" ),
  11096. handle = "<span class='ui-slider-handle ui-state-default ui-corner-all' tabindex='0'></span>",
  11097. handles = [];
  11098. handleCount = ( options.values && options.values.length ) || 1;
  11099. if ( existingHandles.length > handleCount ) {
  11100. existingHandles.slice( handleCount ).remove();
  11101. existingHandles = existingHandles.slice( 0, handleCount );
  11102. }
  11103. for ( i = existingHandles.length; i < handleCount; i++ ) {
  11104. handles.push( handle );
  11105. }
  11106. this.handles = existingHandles.add( $( handles.join( "" ) ).appendTo( this.element ) );
  11107. this.handle = this.handles.eq( 0 );
  11108. this.handles.each(function( i ) {
  11109. $( this ).data( "ui-slider-handle-index", i );
  11110. });
  11111. },
  11112. _createRange: function() {
  11113. var options = this.options,
  11114. classes = "";
  11115. if ( options.range ) {
  11116. if ( options.range === true ) {
  11117. if ( !options.values ) {
  11118. options.values = [ this._valueMin(), this._valueMin() ];
  11119. } else if ( options.values.length && options.values.length !== 2 ) {
  11120. options.values = [ options.values[0], options.values[0] ];
  11121. } else if ( $.isArray( options.values ) ) {
  11122. options.values = options.values.slice(0);
  11123. }
  11124. }
  11125. if ( !this.range || !this.range.length ) {
  11126. this.range = $( "<div></div>" )
  11127. .appendTo( this.element );
  11128. classes = "ui-slider-range" +
  11129. // note: this isn't the most fittingly semantic framework class for this element,
  11130. // but worked best visually with a variety of themes
  11131. " ui-widget-header ui-corner-all";
  11132. } else {
  11133. this.range.removeClass( "ui-slider-range-min ui-slider-range-max" )
  11134. // Handle range switching from true to min/max
  11135. .css({
  11136. "left": "",
  11137. "bottom": ""
  11138. });
  11139. }
  11140. this.range.addClass( classes +
  11141. ( ( options.range === "min" || options.range === "max" ) ? " ui-slider-range-" + options.range : "" ) );
  11142. } else {
  11143. if ( this.range ) {
  11144. this.range.remove();
  11145. }
  11146. this.range = null;
  11147. }
  11148. },
  11149. _setupEvents: function() {
  11150. this._off( this.handles );
  11151. this._on( this.handles, this._handleEvents );
  11152. this._hoverable( this.handles );
  11153. this._focusable( this.handles );
  11154. },
  11155. _destroy: function() {
  11156. this.handles.remove();
  11157. if ( this.range ) {
  11158. this.range.remove();
  11159. }
  11160. this.element
  11161. .removeClass( "ui-slider" +
  11162. " ui-slider-horizontal" +
  11163. " ui-slider-vertical" +
  11164. " ui-widget" +
  11165. " ui-widget-content" +
  11166. " ui-corner-all" );
  11167. this._mouseDestroy();
  11168. },
  11169. _mouseCapture: function( event ) {
  11170. var position, normValue, distance, closestHandle, index, allowed, offset, mouseOverHandle,
  11171. that = this,
  11172. o = this.options;
  11173. if ( o.disabled ) {
  11174. return false;
  11175. }
  11176. this.elementSize = {
  11177. width: this.element.outerWidth(),
  11178. height: this.element.outerHeight()
  11179. };
  11180. this.elementOffset = this.element.offset();
  11181. position = { x: event.pageX, y: event.pageY };
  11182. normValue = this._normValueFromMouse( position );
  11183. distance = this._valueMax() - this._valueMin() + 1;
  11184. this.handles.each(function( i ) {
  11185. var thisDistance = Math.abs( normValue - that.values(i) );
  11186. if (( distance > thisDistance ) ||
  11187. ( distance === thisDistance &&
  11188. (i === that._lastChangedValue || that.values(i) === o.min ))) {
  11189. distance = thisDistance;
  11190. closestHandle = $( this );
  11191. index = i;
  11192. }
  11193. });
  11194. allowed = this._start( event, index );
  11195. if ( allowed === false ) {
  11196. return false;
  11197. }
  11198. this._mouseSliding = true;
  11199. this._handleIndex = index;
  11200. closestHandle
  11201. .addClass( "ui-state-active" )
  11202. .focus();
  11203. offset = closestHandle.offset();
  11204. mouseOverHandle = !$( event.target ).parents().addBack().is( ".ui-slider-handle" );
  11205. this._clickOffset = mouseOverHandle ? { left: 0, top: 0 } : {
  11206. left: event.pageX - offset.left - ( closestHandle.width() / 2 ),
  11207. top: event.pageY - offset.top -
  11208. ( closestHandle.height() / 2 ) -
  11209. ( parseInt( closestHandle.css("borderTopWidth"), 10 ) || 0 ) -
  11210. ( parseInt( closestHandle.css("borderBottomWidth"), 10 ) || 0) +
  11211. ( parseInt( closestHandle.css("marginTop"), 10 ) || 0)
  11212. };
  11213. if ( !this.handles.hasClass( "ui-state-hover" ) ) {
  11214. this._slide( event, index, normValue );
  11215. }
  11216. this._animateOff = true;
  11217. return true;
  11218. },
  11219. _mouseStart: function() {
  11220. return true;
  11221. },
  11222. _mouseDrag: function( event ) {
  11223. var position = { x: event.pageX, y: event.pageY },
  11224. normValue = this._normValueFromMouse( position );
  11225. this._slide( event, this._handleIndex, normValue );
  11226. return false;
  11227. },
  11228. _mouseStop: function( event ) {
  11229. this.handles.removeClass( "ui-state-active" );
  11230. this._mouseSliding = false;
  11231. this._stop( event, this._handleIndex );
  11232. this._change( event, this._handleIndex );
  11233. this._handleIndex = null;
  11234. this._clickOffset = null;
  11235. this._animateOff = false;
  11236. return false;
  11237. },
  11238. _detectOrientation: function() {
  11239. this.orientation = ( this.options.orientation === "vertical" ) ? "vertical" : "horizontal";
  11240. },
  11241. _normValueFromMouse: function( position ) {
  11242. var pixelTotal,
  11243. pixelMouse,
  11244. percentMouse,
  11245. valueTotal,
  11246. valueMouse;
  11247. if ( this.orientation === "horizontal" ) {
  11248. pixelTotal = this.elementSize.width;
  11249. pixelMouse = position.x - this.elementOffset.left - ( this._clickOffset ? this._clickOffset.left : 0 );
  11250. } else {
  11251. pixelTotal = this.elementSize.height;
  11252. pixelMouse = position.y - this.elementOffset.top - ( this._clickOffset ? this._clickOffset.top : 0 );
  11253. }
  11254. percentMouse = ( pixelMouse / pixelTotal );
  11255. if ( percentMouse > 1 ) {
  11256. percentMouse = 1;
  11257. }
  11258. if ( percentMouse < 0 ) {
  11259. percentMouse = 0;
  11260. }
  11261. if ( this.orientation === "vertical" ) {
  11262. percentMouse = 1 - percentMouse;
  11263. }
  11264. valueTotal = this._valueMax() - this._valueMin();
  11265. valueMouse = this._valueMin() + percentMouse * valueTotal;
  11266. return this._trimAlignValue( valueMouse );
  11267. },
  11268. _start: function( event, index ) {
  11269. var uiHash = {
  11270. handle: this.handles[ index ],
  11271. value: this.value()
  11272. };
  11273. if ( this.options.values && this.options.values.length ) {
  11274. uiHash.value = this.values( index );
  11275. uiHash.values = this.values();
  11276. }
  11277. return this._trigger( "start", event, uiHash );
  11278. },
  11279. _slide: function( event, index, newVal ) {
  11280. var otherVal,
  11281. newValues,
  11282. allowed;
  11283. if ( this.options.values && this.options.values.length ) {
  11284. otherVal = this.values( index ? 0 : 1 );
  11285. if ( ( this.options.values.length === 2 && this.options.range === true ) &&
  11286. ( ( index === 0 && newVal > otherVal) || ( index === 1 && newVal < otherVal ) )
  11287. ) {
  11288. newVal = otherVal;
  11289. }
  11290. if ( newVal !== this.values( index ) ) {
  11291. newValues = this.values();
  11292. newValues[ index ] = newVal;
  11293. // A slide can be canceled by returning false from the slide callback
  11294. allowed = this._trigger( "slide", event, {
  11295. handle: this.handles[ index ],
  11296. value: newVal,
  11297. values: newValues
  11298. } );
  11299. otherVal = this.values( index ? 0 : 1 );
  11300. if ( allowed !== false ) {
  11301. this.values( index, newVal );
  11302. }
  11303. }
  11304. } else {
  11305. if ( newVal !== this.value() ) {
  11306. // A slide can be canceled by returning false from the slide callback
  11307. allowed = this._trigger( "slide", event, {
  11308. handle: this.handles[ index ],
  11309. value: newVal
  11310. } );
  11311. if ( allowed !== false ) {
  11312. this.value( newVal );
  11313. }
  11314. }
  11315. }
  11316. },
  11317. _stop: function( event, index ) {
  11318. var uiHash = {
  11319. handle: this.handles[ index ],
  11320. value: this.value()
  11321. };
  11322. if ( this.options.values && this.options.values.length ) {
  11323. uiHash.value = this.values( index );
  11324. uiHash.values = this.values();
  11325. }
  11326. this._trigger( "stop", event, uiHash );
  11327. },
  11328. _change: function( event, index ) {
  11329. if ( !this._keySliding && !this._mouseSliding ) {
  11330. var uiHash = {
  11331. handle: this.handles[ index ],
  11332. value: this.value()
  11333. };
  11334. if ( this.options.values && this.options.values.length ) {
  11335. uiHash.value = this.values( index );
  11336. uiHash.values = this.values();
  11337. }
  11338. //store the last changed value index for reference when handles overlap
  11339. this._lastChangedValue = index;
  11340. this._trigger( "change", event, uiHash );
  11341. }
  11342. },
  11343. value: function( newValue ) {
  11344. if ( arguments.length ) {
  11345. this.options.value = this._trimAlignValue( newValue );
  11346. this._refreshValue();
  11347. this._change( null, 0 );
  11348. return;
  11349. }
  11350. return this._value();
  11351. },
  11352. values: function( index, newValue ) {
  11353. var vals,
  11354. newValues,
  11355. i;
  11356. if ( arguments.length > 1 ) {
  11357. this.options.values[ index ] = this._trimAlignValue( newValue );
  11358. this._refreshValue();
  11359. this._change( null, index );
  11360. return;
  11361. }
  11362. if ( arguments.length ) {
  11363. if ( $.isArray( arguments[ 0 ] ) ) {
  11364. vals = this.options.values;
  11365. newValues = arguments[ 0 ];
  11366. for ( i = 0; i < vals.length; i += 1 ) {
  11367. vals[ i ] = this._trimAlignValue( newValues[ i ] );
  11368. this._change( null, i );
  11369. }
  11370. this._refreshValue();
  11371. } else {
  11372. if ( this.options.values && this.options.values.length ) {
  11373. return this._values( index );
  11374. } else {
  11375. return this.value();
  11376. }
  11377. }
  11378. } else {
  11379. return this._values();
  11380. }
  11381. },
  11382. _setOption: function( key, value ) {
  11383. var i,
  11384. valsLength = 0;
  11385. if ( key === "range" && this.options.range === true ) {
  11386. if ( value === "min" ) {
  11387. this.options.value = this._values( 0 );
  11388. this.options.values = null;
  11389. } else if ( value === "max" ) {
  11390. this.options.value = this._values( this.options.values.length - 1 );
  11391. this.options.values = null;
  11392. }
  11393. }
  11394. if ( $.isArray( this.options.values ) ) {
  11395. valsLength = this.options.values.length;
  11396. }
  11397. if ( key === "disabled" ) {
  11398. this.element.toggleClass( "ui-state-disabled", !!value );
  11399. }
  11400. this._super( key, value );
  11401. switch ( key ) {
  11402. case "orientation":
  11403. this._detectOrientation();
  11404. this.element
  11405. .removeClass( "ui-slider-horizontal ui-slider-vertical" )
  11406. .addClass( "ui-slider-" + this.orientation );
  11407. this._refreshValue();
  11408. // Reset positioning from previous orientation
  11409. this.handles.css( value === "horizontal" ? "bottom" : "left", "" );
  11410. break;
  11411. case "value":
  11412. this._animateOff = true;
  11413. this._refreshValue();
  11414. this._change( null, 0 );
  11415. this._animateOff = false;
  11416. break;
  11417. case "values":
  11418. this._animateOff = true;
  11419. this._refreshValue();
  11420. for ( i = 0; i < valsLength; i += 1 ) {
  11421. this._change( null, i );
  11422. }
  11423. this._animateOff = false;
  11424. break;
  11425. case "step":
  11426. case "min":
  11427. case "max":
  11428. this._animateOff = true;
  11429. this._calculateNewMax();
  11430. this._refreshValue();
  11431. this._animateOff = false;
  11432. break;
  11433. case "range":
  11434. this._animateOff = true;
  11435. this._refresh();
  11436. this._animateOff = false;
  11437. break;
  11438. }
  11439. },
  11440. //internal value getter
  11441. // _value() returns value trimmed by min and max, aligned by step
  11442. _value: function() {
  11443. var val = this.options.value;
  11444. val = this._trimAlignValue( val );
  11445. return val;
  11446. },
  11447. //internal values getter
  11448. // _values() returns array of values trimmed by min and max, aligned by step
  11449. // _values( index ) returns single value trimmed by min and max, aligned by step
  11450. _values: function( index ) {
  11451. var val,
  11452. vals,
  11453. i;
  11454. if ( arguments.length ) {
  11455. val = this.options.values[ index ];
  11456. val = this._trimAlignValue( val );
  11457. return val;
  11458. } else if ( this.options.values && this.options.values.length ) {
  11459. // .slice() creates a copy of the array
  11460. // this copy gets trimmed by min and max and then returned
  11461. vals = this.options.values.slice();
  11462. for ( i = 0; i < vals.length; i += 1) {
  11463. vals[ i ] = this._trimAlignValue( vals[ i ] );
  11464. }
  11465. return vals;
  11466. } else {
  11467. return [];
  11468. }
  11469. },
  11470. // returns the step-aligned value that val is closest to, between (inclusive) min and max
  11471. _trimAlignValue: function( val ) {
  11472. if ( val <= this._valueMin() ) {
  11473. return this._valueMin();
  11474. }
  11475. if ( val >= this._valueMax() ) {
  11476. return this._valueMax();
  11477. }
  11478. var step = ( this.options.step > 0 ) ? this.options.step : 1,
  11479. valModStep = (val - this._valueMin()) % step,
  11480. alignValue = val - valModStep;
  11481. if ( Math.abs(valModStep) * 2 >= step ) {
  11482. alignValue += ( valModStep > 0 ) ? step : ( -step );
  11483. }
  11484. // Since JavaScript has problems with large floats, round
  11485. // the final value to 5 digits after the decimal point (see #4124)
  11486. return parseFloat( alignValue.toFixed(5) );
  11487. },
  11488. _calculateNewMax: function() {
  11489. var max = this.options.max,
  11490. min = this._valueMin(),
  11491. step = this.options.step,
  11492. aboveMin = Math.floor( ( max - min ) / step ) * step;
  11493. max = aboveMin + min;
  11494. this.max = parseFloat( max.toFixed( this._precision() ) );
  11495. },
  11496. _precision: function() {
  11497. var precision = this._precisionOf( this.options.step );
  11498. if ( this.options.min !== null ) {
  11499. precision = Math.max( precision, this._precisionOf( this.options.min ) );
  11500. }
  11501. return precision;
  11502. },
  11503. _precisionOf: function( num ) {
  11504. var str = num.toString(),
  11505. decimal = str.indexOf( "." );
  11506. return decimal === -1 ? 0 : str.length - decimal - 1;
  11507. },
  11508. _valueMin: function() {
  11509. return this.options.min;
  11510. },
  11511. _valueMax: function() {
  11512. return this.max;
  11513. },
  11514. _refreshValue: function() {
  11515. var lastValPercent, valPercent, value, valueMin, valueMax,
  11516. oRange = this.options.range,
  11517. o = this.options,
  11518. that = this,
  11519. animate = ( !this._animateOff ) ? o.animate : false,
  11520. _set = {};
  11521. if ( this.options.values && this.options.values.length ) {
  11522. this.handles.each(function( i ) {
  11523. valPercent = ( that.values(i) - that._valueMin() ) / ( that._valueMax() - that._valueMin() ) * 100;
  11524. _set[ that.orientation === "horizontal" ? "left" : "bottom" ] = valPercent + "%";
  11525. $( this ).stop( 1, 1 )[ animate ? "animate" : "css" ]( _set, o.animate );
  11526. if ( that.options.range === true ) {
  11527. if ( that.orientation === "horizontal" ) {
  11528. if ( i === 0 ) {
  11529. that.range.stop( 1, 1 )[ animate ? "animate" : "css" ]( { left: valPercent + "%" }, o.animate );
  11530. }
  11531. if ( i === 1 ) {
  11532. that.range[ animate ? "animate" : "css" ]( { width: ( valPercent - lastValPercent ) + "%" }, { queue: false, duration: o.animate } );
  11533. }
  11534. } else {
  11535. if ( i === 0 ) {
  11536. that.range.stop( 1, 1 )[ animate ? "animate" : "css" ]( { bottom: ( valPercent ) + "%" }, o.animate );
  11537. }
  11538. if ( i === 1 ) {
  11539. that.range[ animate ? "animate" : "css" ]( { height: ( valPercent - lastValPercent ) + "%" }, { queue: false, duration: o.animate } );
  11540. }
  11541. }
  11542. }
  11543. lastValPercent = valPercent;
  11544. });
  11545. } else {
  11546. value = this.value();
  11547. valueMin = this._valueMin();
  11548. valueMax = this._valueMax();
  11549. valPercent = ( valueMax !== valueMin ) ?
  11550. ( value - valueMin ) / ( valueMax - valueMin ) * 100 :
  11551. 0;
  11552. _set[ this.orientation === "horizontal" ? "left" : "bottom" ] = valPercent + "%";
  11553. this.handle.stop( 1, 1 )[ animate ? "animate" : "css" ]( _set, o.animate );
  11554. if ( oRange === "min" && this.orientation === "horizontal" ) {
  11555. this.range.stop( 1, 1 )[ animate ? "animate" : "css" ]( { width: valPercent + "%" }, o.animate );
  11556. }
  11557. if ( oRange === "max" && this.orientation === "horizontal" ) {
  11558. this.range[ animate ? "animate" : "css" ]( { width: ( 100 - valPercent ) + "%" }, { queue: false, duration: o.animate } );
  11559. }
  11560. if ( oRange === "min" && this.orientation === "vertical" ) {
  11561. this.range.stop( 1, 1 )[ animate ? "animate" : "css" ]( { height: valPercent + "%" }, o.animate );
  11562. }
  11563. if ( oRange === "max" && this.orientation === "vertical" ) {
  11564. this.range[ animate ? "animate" : "css" ]( { height: ( 100 - valPercent ) + "%" }, { queue: false, duration: o.animate } );
  11565. }
  11566. }
  11567. },
  11568. _handleEvents: {
  11569. keydown: function( event ) {
  11570. var allowed, curVal, newVal, step,
  11571. index = $( event.target ).data( "ui-slider-handle-index" );
  11572. switch ( event.keyCode ) {
  11573. case $.ui.keyCode.HOME:
  11574. case $.ui.keyCode.END:
  11575. case $.ui.keyCode.PAGE_UP:
  11576. case $.ui.keyCode.PAGE_DOWN:
  11577. case $.ui.keyCode.UP:
  11578. case $.ui.keyCode.RIGHT:
  11579. case $.ui.keyCode.DOWN:
  11580. case $.ui.keyCode.LEFT:
  11581. event.preventDefault();
  11582. if ( !this._keySliding ) {
  11583. this._keySliding = true;
  11584. $( event.target ).addClass( "ui-state-active" );
  11585. allowed = this._start( event, index );
  11586. if ( allowed === false ) {
  11587. return;
  11588. }
  11589. }
  11590. break;
  11591. }
  11592. step = this.options.step;
  11593. if ( this.options.values && this.options.values.length ) {
  11594. curVal = newVal = this.values( index );
  11595. } else {
  11596. curVal = newVal = this.value();
  11597. }
  11598. switch ( event.keyCode ) {
  11599. case $.ui.keyCode.HOME:
  11600. newVal = this._valueMin();
  11601. break;
  11602. case $.ui.keyCode.END:
  11603. newVal = this._valueMax();
  11604. break;
  11605. case $.ui.keyCode.PAGE_UP:
  11606. newVal = this._trimAlignValue(
  11607. curVal + ( ( this._valueMax() - this._valueMin() ) / this.numPages )
  11608. );
  11609. break;
  11610. case $.ui.keyCode.PAGE_DOWN:
  11611. newVal = this._trimAlignValue(
  11612. curVal - ( (this._valueMax() - this._valueMin()) / this.numPages ) );
  11613. break;
  11614. case $.ui.keyCode.UP:
  11615. case $.ui.keyCode.RIGHT:
  11616. if ( curVal === this._valueMax() ) {
  11617. return;
  11618. }
  11619. newVal = this._trimAlignValue( curVal + step );
  11620. break;
  11621. case $.ui.keyCode.DOWN:
  11622. case $.ui.keyCode.LEFT:
  11623. if ( curVal === this._valueMin() ) {
  11624. return;
  11625. }
  11626. newVal = this._trimAlignValue( curVal - step );
  11627. break;
  11628. }
  11629. this._slide( event, index, newVal );
  11630. },
  11631. keyup: function( event ) {
  11632. var index = $( event.target ).data( "ui-slider-handle-index" );
  11633. if ( this._keySliding ) {
  11634. this._keySliding = false;
  11635. this._stop( event, index );
  11636. this._change( event, index );
  11637. $( event.target ).removeClass( "ui-state-active" );
  11638. }
  11639. }
  11640. }
  11641. });
  11642. /*!
  11643. * jQuery UI Sortable 1.11.3
  11644. * http://jqueryui.com
  11645. *
  11646. * Copyright jQuery Foundation and other contributors
  11647. * Released under the MIT license.
  11648. * http://jquery.org/license
  11649. *
  11650. * http://api.jqueryui.com/sortable/
  11651. */
  11652. var sortable = $.widget("ui.sortable", $.ui.mouse, {
  11653. version: "1.11.3",
  11654. widgetEventPrefix: "sort",
  11655. ready: false,
  11656. options: {
  11657. appendTo: "parent",
  11658. axis: false,
  11659. connectWith: false,
  11660. containment: false,
  11661. cursor: "auto",
  11662. cursorAt: false,
  11663. dropOnEmpty: true,
  11664. forcePlaceholderSize: false,
  11665. forceHelperSize: false,
  11666. grid: false,
  11667. handle: false,
  11668. helper: "original",
  11669. items: "> *",
  11670. opacity: false,
  11671. placeholder: false,
  11672. revert: false,
  11673. scroll: true,
  11674. scrollSensitivity: 20,
  11675. scrollSpeed: 20,
  11676. scope: "default",
  11677. tolerance: "intersect",
  11678. zIndex: 1000,
  11679. // callbacks
  11680. activate: null,
  11681. beforeStop: null,
  11682. change: null,
  11683. deactivate: null,
  11684. out: null,
  11685. over: null,
  11686. receive: null,
  11687. remove: null,
  11688. sort: null,
  11689. start: null,
  11690. stop: null,
  11691. update: null
  11692. },
  11693. _isOverAxis: function( x, reference, size ) {
  11694. return ( x >= reference ) && ( x < ( reference + size ) );
  11695. },
  11696. _isFloating: function( item ) {
  11697. return (/left|right/).test(item.css("float")) || (/inline|table-cell/).test(item.css("display"));
  11698. },
  11699. _create: function() {
  11700. var o = this.options;
  11701. this.containerCache = {};
  11702. this.element.addClass("ui-sortable");
  11703. //Get the items
  11704. this.refresh();
  11705. //Let's determine if the items are being displayed horizontally
  11706. this.floating = this.items.length ? o.axis === "x" || this._isFloating(this.items[0].item) : false;
  11707. //Let's determine the parent's offset
  11708. this.offset = this.element.offset();
  11709. //Initialize mouse events for interaction
  11710. this._mouseInit();
  11711. this._setHandleClassName();
  11712. //We're ready to go
  11713. this.ready = true;
  11714. },
  11715. _setOption: function( key, value ) {
  11716. this._super( key, value );
  11717. if ( key === "handle" ) {
  11718. this._setHandleClassName();
  11719. }
  11720. },
  11721. _setHandleClassName: function() {
  11722. this.element.find( ".ui-sortable-handle" ).removeClass( "ui-sortable-handle" );
  11723. $.each( this.items, function() {
  11724. ( this.instance.options.handle ?
  11725. this.item.find( this.instance.options.handle ) : this.item )
  11726. .addClass( "ui-sortable-handle" );
  11727. });
  11728. },
  11729. _destroy: function() {
  11730. this.element
  11731. .removeClass( "ui-sortable ui-sortable-disabled" )
  11732. .find( ".ui-sortable-handle" )
  11733. .removeClass( "ui-sortable-handle" );
  11734. this._mouseDestroy();
  11735. for ( var i = this.items.length - 1; i >= 0; i-- ) {
  11736. this.items[i].item.removeData(this.widgetName + "-item");
  11737. }
  11738. return this;
  11739. },
  11740. _mouseCapture: function(event, overrideHandle) {
  11741. var currentItem = null,
  11742. validHandle = false,
  11743. that = this;
  11744. if (this.reverting) {
  11745. return false;
  11746. }
  11747. if(this.options.disabled || this.options.type === "static") {
  11748. return false;
  11749. }
  11750. //We have to refresh the items data once first
  11751. this._refreshItems(event);
  11752. //Find out if the clicked node (or one of its parents) is a actual item in this.items
  11753. $(event.target).parents().each(function() {
  11754. if($.data(this, that.widgetName + "-item") === that) {
  11755. currentItem = $(this);
  11756. return false;
  11757. }
  11758. });
  11759. if($.data(event.target, that.widgetName + "-item") === that) {
  11760. currentItem = $(event.target);
  11761. }
  11762. if(!currentItem) {
  11763. return false;
  11764. }
  11765. if(this.options.handle && !overrideHandle) {
  11766. $(this.options.handle, currentItem).find("*").addBack().each(function() {
  11767. if(this === event.target) {
  11768. validHandle = true;
  11769. }
  11770. });
  11771. if(!validHandle) {
  11772. return false;
  11773. }
  11774. }
  11775. this.currentItem = currentItem;
  11776. this._removeCurrentsFromItems();
  11777. return true;
  11778. },
  11779. _mouseStart: function(event, overrideHandle, noActivation) {
  11780. var i, body,
  11781. o = this.options;
  11782. this.currentContainer = this;
  11783. //We only need to call refreshPositions, because the refreshItems call has been moved to mouseCapture
  11784. this.refreshPositions();
  11785. //Create and append the visible helper
  11786. this.helper = this._createHelper(event);
  11787. //Cache the helper size
  11788. this._cacheHelperProportions();
  11789. /*
  11790. * - Position generation -
  11791. * This block generates everything position related - it's the core of draggables.
  11792. */
  11793. //Cache the margins of the original element
  11794. this._cacheMargins();
  11795. //Get the next scrolling parent
  11796. this.scrollParent = this.helper.scrollParent();
  11797. //The element's absolute position on the page minus margins
  11798. this.offset = this.currentItem.offset();
  11799. this.offset = {
  11800. top: this.offset.top - this.margins.top,
  11801. left: this.offset.left - this.margins.left
  11802. };
  11803. $.extend(this.offset, {
  11804. click: { //Where the click happened, relative to the element
  11805. left: event.pageX - this.offset.left,
  11806. top: event.pageY - this.offset.top
  11807. },
  11808. parent: this._getParentOffset(),
  11809. relative: this._getRelativeOffset() //This is a relative to absolute position minus the actual position calculation - only used for relative positioned helper
  11810. });
  11811. // Only after we got the offset, we can change the helper's position to absolute
  11812. // TODO: Still need to figure out a way to make relative sorting possible
  11813. this.helper.css("position", "absolute");
  11814. this.cssPosition = this.helper.css("position");
  11815. //Generate the original position
  11816. this.originalPosition = this._generatePosition(event);
  11817. this.originalPageX = event.pageX;
  11818. this.originalPageY = event.pageY;
  11819. //Adjust the mouse offset relative to the helper if "cursorAt" is supplied
  11820. (o.cursorAt && this._adjustOffsetFromHelper(o.cursorAt));
  11821. //Cache the former DOM position
  11822. this.domPosition = { prev: this.currentItem.prev()[0], parent: this.currentItem.parent()[0] };
  11823. //If the helper is not the original, hide the original so it's not playing any role during the drag, won't cause anything bad this way
  11824. if(this.helper[0] !== this.currentItem[0]) {
  11825. this.currentItem.hide();
  11826. }
  11827. //Create the placeholder
  11828. this._createPlaceholder();
  11829. //Set a containment if given in the options
  11830. if(o.containment) {
  11831. this._setContainment();
  11832. }
  11833. if( o.cursor && o.cursor !== "auto" ) { // cursor option
  11834. body = this.document.find( "body" );
  11835. // support: IE
  11836. this.storedCursor = body.css( "cursor" );
  11837. body.css( "cursor", o.cursor );
  11838. this.storedStylesheet = $( "<style>*{ cursor: "+o.cursor+" !important; }</style>" ).appendTo( body );
  11839. }
  11840. if(o.opacity) { // opacity option
  11841. if (this.helper.css("opacity")) {
  11842. this._storedOpacity = this.helper.css("opacity");
  11843. }
  11844. this.helper.css("opacity", o.opacity);
  11845. }
  11846. if(o.zIndex) { // zIndex option
  11847. if (this.helper.css("zIndex")) {
  11848. this._storedZIndex = this.helper.css("zIndex");
  11849. }
  11850. this.helper.css("zIndex", o.zIndex);
  11851. }
  11852. //Prepare scrolling
  11853. if(this.scrollParent[0] !== this.document[0] && this.scrollParent[0].tagName !== "HTML") {
  11854. this.overflowOffset = this.scrollParent.offset();
  11855. }
  11856. //Call callbacks
  11857. this._trigger("start", event, this._uiHash());
  11858. //Recache the helper size
  11859. if(!this._preserveHelperProportions) {
  11860. this._cacheHelperProportions();
  11861. }
  11862. //Post "activate" events to possible containers
  11863. if( !noActivation ) {
  11864. for ( i = this.containers.length - 1; i >= 0; i-- ) {
  11865. this.containers[ i ]._trigger( "activate", event, this._uiHash( this ) );
  11866. }
  11867. }
  11868. //Prepare possible droppables
  11869. if($.ui.ddmanager) {
  11870. $.ui.ddmanager.current = this;
  11871. }
  11872. if ($.ui.ddmanager && !o.dropBehaviour) {
  11873. $.ui.ddmanager.prepareOffsets(this, event);
  11874. }
  11875. this.dragging = true;
  11876. this.helper.addClass("ui-sortable-helper");
  11877. this._mouseDrag(event); //Execute the drag once - this causes the helper not to be visible before getting its correct position
  11878. return true;
  11879. },
  11880. _mouseDrag: function(event) {
  11881. var i, item, itemElement, intersection,
  11882. o = this.options,
  11883. scrolled = false;
  11884. //Compute the helpers position
  11885. this.position = this._generatePosition(event);
  11886. this.positionAbs = this._convertPositionTo("absolute");
  11887. if (!this.lastPositionAbs) {
  11888. this.lastPositionAbs = this.positionAbs;
  11889. }
  11890. //Do scrolling
  11891. if(this.options.scroll) {
  11892. if(this.scrollParent[0] !== this.document[0] && this.scrollParent[0].tagName !== "HTML") {
  11893. if((this.overflowOffset.top + this.scrollParent[0].offsetHeight) - event.pageY < o.scrollSensitivity) {
  11894. this.scrollParent[0].scrollTop = scrolled = this.scrollParent[0].scrollTop + o.scrollSpeed;
  11895. } else if(event.pageY - this.overflowOffset.top < o.scrollSensitivity) {
  11896. this.scrollParent[0].scrollTop = scrolled = this.scrollParent[0].scrollTop - o.scrollSpeed;
  11897. }
  11898. if((this.overflowOffset.left + this.scrollParent[0].offsetWidth) - event.pageX < o.scrollSensitivity) {
  11899. this.scrollParent[0].scrollLeft = scrolled = this.scrollParent[0].scrollLeft + o.scrollSpeed;
  11900. } else if(event.pageX - this.overflowOffset.left < o.scrollSensitivity) {
  11901. this.scrollParent[0].scrollLeft = scrolled = this.scrollParent[0].scrollLeft - o.scrollSpeed;
  11902. }
  11903. } else {
  11904. if(event.pageY - this.document.scrollTop() < o.scrollSensitivity) {
  11905. scrolled = this.document.scrollTop(this.document.scrollTop() - o.scrollSpeed);
  11906. } else if(this.window.height() - (event.pageY - this.document.scrollTop()) < o.scrollSensitivity) {
  11907. scrolled = this.document.scrollTop(this.document.scrollTop() + o.scrollSpeed);
  11908. }
  11909. if(event.pageX - this.document.scrollLeft() < o.scrollSensitivity) {
  11910. scrolled = this.document.scrollLeft(this.document.scrollLeft() - o.scrollSpeed);
  11911. } else if(this.window.width() - (event.pageX - this.document.scrollLeft()) < o.scrollSensitivity) {
  11912. scrolled = this.document.scrollLeft(this.document.scrollLeft() + o.scrollSpeed);
  11913. }
  11914. }
  11915. if(scrolled !== false && $.ui.ddmanager && !o.dropBehaviour) {
  11916. $.ui.ddmanager.prepareOffsets(this, event);
  11917. }
  11918. }
  11919. //Regenerate the absolute position used for position checks
  11920. this.positionAbs = this._convertPositionTo("absolute");
  11921. //Set the helper position
  11922. if(!this.options.axis || this.options.axis !== "y") {
  11923. this.helper[0].style.left = this.position.left+"px";
  11924. }
  11925. if(!this.options.axis || this.options.axis !== "x") {
  11926. this.helper[0].style.top = this.position.top+"px";
  11927. }
  11928. //Rearrange
  11929. for (i = this.items.length - 1; i >= 0; i--) {
  11930. //Cache variables and intersection, continue if no intersection
  11931. item = this.items[i];
  11932. itemElement = item.item[0];
  11933. intersection = this._intersectsWithPointer(item);
  11934. if (!intersection) {
  11935. continue;
  11936. }
  11937. // Only put the placeholder inside the current Container, skip all
  11938. // items from other containers. This works because when moving
  11939. // an item from one container to another the
  11940. // currentContainer is switched before the placeholder is moved.
  11941. //
  11942. // Without this, moving items in "sub-sortables" can cause
  11943. // the placeholder to jitter between the outer and inner container.
  11944. if (item.instance !== this.currentContainer) {
  11945. continue;
  11946. }
  11947. // cannot intersect with itself
  11948. // no useless actions that have been done before
  11949. // no action if the item moved is the parent of the item checked
  11950. if (itemElement !== this.currentItem[0] &&
  11951. this.placeholder[intersection === 1 ? "next" : "prev"]()[0] !== itemElement &&
  11952. !$.contains(this.placeholder[0], itemElement) &&
  11953. (this.options.type === "semi-dynamic" ? !$.contains(this.element[0], itemElement) : true)
  11954. ) {
  11955. this.direction = intersection === 1 ? "down" : "up";
  11956. if (this.options.tolerance === "pointer" || this._intersectsWithSides(item)) {
  11957. this._rearrange(event, item);
  11958. } else {
  11959. break;
  11960. }
  11961. this._trigger("change", event, this._uiHash());
  11962. break;
  11963. }
  11964. }
  11965. //Post events to containers
  11966. this._contactContainers(event);
  11967. //Interconnect with droppables
  11968. if($.ui.ddmanager) {
  11969. $.ui.ddmanager.drag(this, event);
  11970. }
  11971. //Call callbacks
  11972. this._trigger("sort", event, this._uiHash());
  11973. this.lastPositionAbs = this.positionAbs;
  11974. return false;
  11975. },
  11976. _mouseStop: function(event, noPropagation) {
  11977. if(!event) {
  11978. return;
  11979. }
  11980. //If we are using droppables, inform the manager about the drop
  11981. if ($.ui.ddmanager && !this.options.dropBehaviour) {
  11982. $.ui.ddmanager.drop(this, event);
  11983. }
  11984. if(this.options.revert) {
  11985. var that = this,
  11986. cur = this.placeholder.offset(),
  11987. axis = this.options.axis,
  11988. animation = {};
  11989. if ( !axis || axis === "x" ) {
  11990. animation.left = cur.left - this.offset.parent.left - this.margins.left + (this.offsetParent[0] === this.document[0].body ? 0 : this.offsetParent[0].scrollLeft);
  11991. }
  11992. if ( !axis || axis === "y" ) {
  11993. animation.top = cur.top - this.offset.parent.top - this.margins.top + (this.offsetParent[0] === this.document[0].body ? 0 : this.offsetParent[0].scrollTop);
  11994. }
  11995. this.reverting = true;
  11996. $(this.helper).animate( animation, parseInt(this.options.revert, 10) || 500, function() {
  11997. that._clear(event);
  11998. });
  11999. } else {
  12000. this._clear(event, noPropagation);
  12001. }
  12002. return false;
  12003. },
  12004. cancel: function() {
  12005. if(this.dragging) {
  12006. this._mouseUp({ target: null });
  12007. if(this.options.helper === "original") {
  12008. this.currentItem.css(this._storedCSS).removeClass("ui-sortable-helper");
  12009. } else {
  12010. this.currentItem.show();
  12011. }
  12012. //Post deactivating events to containers
  12013. for (var i = this.containers.length - 1; i >= 0; i--){
  12014. this.containers[i]._trigger("deactivate", null, this._uiHash(this));
  12015. if(this.containers[i].containerCache.over) {
  12016. this.containers[i]._trigger("out", null, this._uiHash(this));
  12017. this.containers[i].containerCache.over = 0;
  12018. }
  12019. }
  12020. }
  12021. if (this.placeholder) {
  12022. //$(this.placeholder[0]).remove(); would have been the jQuery way - unfortunately, it unbinds ALL events from the original node!
  12023. if(this.placeholder[0].parentNode) {
  12024. this.placeholder[0].parentNode.removeChild(this.placeholder[0]);
  12025. }
  12026. if(this.options.helper !== "original" && this.helper && this.helper[0].parentNode) {
  12027. this.helper.remove();
  12028. }
  12029. $.extend(this, {
  12030. helper: null,
  12031. dragging: false,
  12032. reverting: false,
  12033. _noFinalSort: null
  12034. });
  12035. if(this.domPosition.prev) {
  12036. $(this.domPosition.prev).after(this.currentItem);
  12037. } else {
  12038. $(this.domPosition.parent).prepend(this.currentItem);
  12039. }
  12040. }
  12041. return this;
  12042. },
  12043. serialize: function(o) {
  12044. var items = this._getItemsAsjQuery(o && o.connected),
  12045. str = [];
  12046. o = o || {};
  12047. $(items).each(function() {
  12048. var res = ($(o.item || this).attr(o.attribute || "id") || "").match(o.expression || (/(.+)[\-=_](.+)/));
  12049. if (res) {
  12050. str.push((o.key || res[1]+"[]")+"="+(o.key && o.expression ? res[1] : res[2]));
  12051. }
  12052. });
  12053. if(!str.length && o.key) {
  12054. str.push(o.key + "=");
  12055. }
  12056. return str.join("&");
  12057. },
  12058. toArray: function(o) {
  12059. var items = this._getItemsAsjQuery(o && o.connected),
  12060. ret = [];
  12061. o = o || {};
  12062. items.each(function() { ret.push($(o.item || this).attr(o.attribute || "id") || ""); });
  12063. return ret;
  12064. },
  12065. /* Be careful with the following core functions */
  12066. _intersectsWith: function(item) {
  12067. var x1 = this.positionAbs.left,
  12068. x2 = x1 + this.helperProportions.width,
  12069. y1 = this.positionAbs.top,
  12070. y2 = y1 + this.helperProportions.height,
  12071. l = item.left,
  12072. r = l + item.width,
  12073. t = item.top,
  12074. b = t + item.height,
  12075. dyClick = this.offset.click.top,
  12076. dxClick = this.offset.click.left,
  12077. isOverElementHeight = ( this.options.axis === "x" ) || ( ( y1 + dyClick ) > t && ( y1 + dyClick ) < b ),
  12078. isOverElementWidth = ( this.options.axis === "y" ) || ( ( x1 + dxClick ) > l && ( x1 + dxClick ) < r ),
  12079. isOverElement = isOverElementHeight && isOverElementWidth;
  12080. if ( this.options.tolerance === "pointer" ||
  12081. this.options.forcePointerForContainers ||
  12082. (this.options.tolerance !== "pointer" && this.helperProportions[this.floating ? "width" : "height"] > item[this.floating ? "width" : "height"])
  12083. ) {
  12084. return isOverElement;
  12085. } else {
  12086. return (l < x1 + (this.helperProportions.width / 2) && // Right Half
  12087. x2 - (this.helperProportions.width / 2) < r && // Left Half
  12088. t < y1 + (this.helperProportions.height / 2) && // Bottom Half
  12089. y2 - (this.helperProportions.height / 2) < b ); // Top Half
  12090. }
  12091. },
  12092. _intersectsWithPointer: function(item) {
  12093. var isOverElementHeight = (this.options.axis === "x") || this._isOverAxis(this.positionAbs.top + this.offset.click.top, item.top, item.height),
  12094. isOverElementWidth = (this.options.axis === "y") || this._isOverAxis(this.positionAbs.left + this.offset.click.left, item.left, item.width),
  12095. isOverElement = isOverElementHeight && isOverElementWidth,
  12096. verticalDirection = this._getDragVerticalDirection(),
  12097. horizontalDirection = this._getDragHorizontalDirection();
  12098. if (!isOverElement) {
  12099. return false;
  12100. }
  12101. return this.floating ?
  12102. ( ((horizontalDirection && horizontalDirection === "right") || verticalDirection === "down") ? 2 : 1 )
  12103. : ( verticalDirection && (verticalDirection === "down" ? 2 : 1) );
  12104. },
  12105. _intersectsWithSides: function(item) {
  12106. var isOverBottomHalf = this._isOverAxis(this.positionAbs.top + this.offset.click.top, item.top + (item.height/2), item.height),
  12107. isOverRightHalf = this._isOverAxis(this.positionAbs.left + this.offset.click.left, item.left + (item.width/2), item.width),
  12108. verticalDirection = this._getDragVerticalDirection(),
  12109. horizontalDirection = this._getDragHorizontalDirection();
  12110. if (this.floating && horizontalDirection) {
  12111. return ((horizontalDirection === "right" && isOverRightHalf) || (horizontalDirection === "left" && !isOverRightHalf));
  12112. } else {
  12113. return verticalDirection && ((verticalDirection === "down" && isOverBottomHalf) || (verticalDirection === "up" && !isOverBottomHalf));
  12114. }
  12115. },
  12116. _getDragVerticalDirection: function() {
  12117. var delta = this.positionAbs.top - this.lastPositionAbs.top;
  12118. return delta !== 0 && (delta > 0 ? "down" : "up");
  12119. },
  12120. _getDragHorizontalDirection: function() {
  12121. var delta = this.positionAbs.left - this.lastPositionAbs.left;
  12122. return delta !== 0 && (delta > 0 ? "right" : "left");
  12123. },
  12124. refresh: function(event) {
  12125. this._refreshItems(event);
  12126. this._setHandleClassName();
  12127. this.refreshPositions();
  12128. return this;
  12129. },
  12130. _connectWith: function() {
  12131. var options = this.options;
  12132. return options.connectWith.constructor === String ? [options.connectWith] : options.connectWith;
  12133. },
  12134. _getItemsAsjQuery: function(connected) {
  12135. var i, j, cur, inst,
  12136. items = [],
  12137. queries = [],
  12138. connectWith = this._connectWith();
  12139. if(connectWith && connected) {
  12140. for (i = connectWith.length - 1; i >= 0; i--){
  12141. cur = $(connectWith[i], this.document[0]);
  12142. for ( j = cur.length - 1; j >= 0; j--){
  12143. inst = $.data(cur[j], this.widgetFullName);
  12144. if(inst && inst !== this && !inst.options.disabled) {
  12145. queries.push([$.isFunction(inst.options.items) ? inst.options.items.call(inst.element) : $(inst.options.items, inst.element).not(".ui-sortable-helper").not(".ui-sortable-placeholder"), inst]);
  12146. }
  12147. }
  12148. }
  12149. }
  12150. queries.push([$.isFunction(this.options.items) ? this.options.items.call(this.element, null, { options: this.options, item: this.currentItem }) : $(this.options.items, this.element).not(".ui-sortable-helper").not(".ui-sortable-placeholder"), this]);
  12151. function addItems() {
  12152. items.push( this );
  12153. }
  12154. for (i = queries.length - 1; i >= 0; i--){
  12155. queries[i][0].each( addItems );
  12156. }
  12157. return $(items);
  12158. },
  12159. _removeCurrentsFromItems: function() {
  12160. var list = this.currentItem.find(":data(" + this.widgetName + "-item)");
  12161. this.items = $.grep(this.items, function (item) {
  12162. for (var j=0; j < list.length; j++) {
  12163. if(list[j] === item.item[0]) {
  12164. return false;
  12165. }
  12166. }
  12167. return true;
  12168. });
  12169. },
  12170. _refreshItems: function(event) {
  12171. this.items = [];
  12172. this.containers = [this];
  12173. var i, j, cur, inst, targetData, _queries, item, queriesLength,
  12174. items = this.items,
  12175. queries = [[$.isFunction(this.options.items) ? this.options.items.call(this.element[0], event, { item: this.currentItem }) : $(this.options.items, this.element), this]],
  12176. connectWith = this._connectWith();
  12177. if(connectWith && this.ready) { //Shouldn't be run the first time through due to massive slow-down
  12178. for (i = connectWith.length - 1; i >= 0; i--){
  12179. cur = $(connectWith[i], this.document[0]);
  12180. for (j = cur.length - 1; j >= 0; j--){
  12181. inst = $.data(cur[j], this.widgetFullName);
  12182. if(inst && inst !== this && !inst.options.disabled) {
  12183. queries.push([$.isFunction(inst.options.items) ? inst.options.items.call(inst.element[0], event, { item: this.currentItem }) : $(inst.options.items, inst.element), inst]);
  12184. this.containers.push(inst);
  12185. }
  12186. }
  12187. }
  12188. }
  12189. for (i = queries.length - 1; i >= 0; i--) {
  12190. targetData = queries[i][1];
  12191. _queries = queries[i][0];
  12192. for (j=0, queriesLength = _queries.length; j < queriesLength; j++) {
  12193. item = $(_queries[j]);
  12194. item.data(this.widgetName + "-item", targetData); // Data for target checking (mouse manager)
  12195. items.push({
  12196. item: item,
  12197. instance: targetData,
  12198. width: 0, height: 0,
  12199. left: 0, top: 0
  12200. });
  12201. }
  12202. }
  12203. },
  12204. refreshPositions: function(fast) {
  12205. //This has to be redone because due to the item being moved out/into the offsetParent, the offsetParent's position will change
  12206. if(this.offsetParent && this.helper) {
  12207. this.offset.parent = this._getParentOffset();
  12208. }
  12209. var i, item, t, p;
  12210. for (i = this.items.length - 1; i >= 0; i--){
  12211. item = this.items[i];
  12212. //We ignore calculating positions of all connected containers when we're not over them
  12213. if(item.instance !== this.currentContainer && this.currentContainer && item.item[0] !== this.currentItem[0]) {
  12214. continue;
  12215. }
  12216. t = this.options.toleranceElement ? $(this.options.toleranceElement, item.item) : item.item;
  12217. if (!fast) {
  12218. item.width = t.outerWidth();
  12219. item.height = t.outerHeight();
  12220. }
  12221. p = t.offset();
  12222. item.left = p.left;
  12223. item.top = p.top;
  12224. }
  12225. if(this.options.custom && this.options.custom.refreshContainers) {
  12226. this.options.custom.refreshContainers.call(this);
  12227. } else {
  12228. for (i = this.containers.length - 1; i >= 0; i--){
  12229. p = this.containers[i].element.offset();
  12230. this.containers[i].containerCache.left = p.left;
  12231. this.containers[i].containerCache.top = p.top;
  12232. this.containers[i].containerCache.width = this.containers[i].element.outerWidth();
  12233. this.containers[i].containerCache.height = this.containers[i].element.outerHeight();
  12234. }
  12235. }
  12236. return this;
  12237. },
  12238. _createPlaceholder: function(that) {
  12239. that = that || this;
  12240. var className,
  12241. o = that.options;
  12242. if(!o.placeholder || o.placeholder.constructor === String) {
  12243. className = o.placeholder;
  12244. o.placeholder = {
  12245. element: function() {
  12246. var nodeName = that.currentItem[0].nodeName.toLowerCase(),
  12247. element = $( "<" + nodeName + ">", that.document[0] )
  12248. .addClass(className || that.currentItem[0].className+" ui-sortable-placeholder")
  12249. .removeClass("ui-sortable-helper");
  12250. if ( nodeName === "tr" ) {
  12251. that.currentItem.children().each(function() {
  12252. $( "<td>&#160;</td>", that.document[0] )
  12253. .attr( "colspan", $( this ).attr( "colspan" ) || 1 )
  12254. .appendTo( element );
  12255. });
  12256. } else if ( nodeName === "img" ) {
  12257. element.attr( "src", that.currentItem.attr( "src" ) );
  12258. }
  12259. if ( !className ) {
  12260. element.css( "visibility", "hidden" );
  12261. }
  12262. return element;
  12263. },
  12264. update: function(container, p) {
  12265. // 1. If a className is set as 'placeholder option, we don't force sizes - the class is responsible for that
  12266. // 2. The option 'forcePlaceholderSize can be enabled to force it even if a class name is specified
  12267. if(className && !o.forcePlaceholderSize) {
  12268. return;
  12269. }
  12270. //If the element doesn't have a actual height by itself (without styles coming from a stylesheet), it receives the inline height from the dragged item
  12271. if(!p.height()) { p.height(that.currentItem.innerHeight() - parseInt(that.currentItem.css("paddingTop")||0, 10) - parseInt(that.currentItem.css("paddingBottom")||0, 10)); }
  12272. if(!p.width()) { p.width(that.currentItem.innerWidth() - parseInt(that.currentItem.css("paddingLeft")||0, 10) - parseInt(that.currentItem.css("paddingRight")||0, 10)); }
  12273. }
  12274. };
  12275. }
  12276. //Create the placeholder
  12277. that.placeholder = $(o.placeholder.element.call(that.element, that.currentItem));
  12278. //Append it after the actual current item
  12279. that.currentItem.after(that.placeholder);
  12280. //Update the size of the placeholder (TODO: Logic to fuzzy, see line 316/317)
  12281. o.placeholder.update(that, that.placeholder);
  12282. },
  12283. _contactContainers: function(event) {
  12284. var i, j, dist, itemWithLeastDistance, posProperty, sizeProperty, cur, nearBottom, floating, axis,
  12285. innermostContainer = null,
  12286. innermostIndex = null;
  12287. // get innermost container that intersects with item
  12288. for (i = this.containers.length - 1; i >= 0; i--) {
  12289. // never consider a container that's located within the item itself
  12290. if($.contains(this.currentItem[0], this.containers[i].element[0])) {
  12291. continue;
  12292. }
  12293. if(this._intersectsWith(this.containers[i].containerCache)) {
  12294. // if we've already found a container and it's more "inner" than this, then continue
  12295. if(innermostContainer && $.contains(this.containers[i].element[0], innermostContainer.element[0])) {
  12296. continue;
  12297. }
  12298. innermostContainer = this.containers[i];
  12299. innermostIndex = i;
  12300. } else {
  12301. // container doesn't intersect. trigger "out" event if necessary
  12302. if(this.containers[i].containerCache.over) {
  12303. this.containers[i]._trigger("out", event, this._uiHash(this));
  12304. this.containers[i].containerCache.over = 0;
  12305. }
  12306. }
  12307. }
  12308. // if no intersecting containers found, return
  12309. if(!innermostContainer) {
  12310. return;
  12311. }
  12312. // move the item into the container if it's not there already
  12313. if(this.containers.length === 1) {
  12314. if (!this.containers[innermostIndex].containerCache.over) {
  12315. this.containers[innermostIndex]._trigger("over", event, this._uiHash(this));
  12316. this.containers[innermostIndex].containerCache.over = 1;
  12317. }
  12318. } else {
  12319. //When entering a new container, we will find the item with the least distance and append our item near it
  12320. dist = 10000;
  12321. itemWithLeastDistance = null;
  12322. floating = innermostContainer.floating || this._isFloating(this.currentItem);
  12323. posProperty = floating ? "left" : "top";
  12324. sizeProperty = floating ? "width" : "height";
  12325. axis = floating ? "clientX" : "clientY";
  12326. for (j = this.items.length - 1; j >= 0; j--) {
  12327. if(!$.contains(this.containers[innermostIndex].element[0], this.items[j].item[0])) {
  12328. continue;
  12329. }
  12330. if(this.items[j].item[0] === this.currentItem[0]) {
  12331. continue;
  12332. }
  12333. cur = this.items[j].item.offset()[posProperty];
  12334. nearBottom = false;
  12335. if ( event[ axis ] - cur > this.items[ j ][ sizeProperty ] / 2 ) {
  12336. nearBottom = true;
  12337. }
  12338. if ( Math.abs( event[ axis ] - cur ) < dist ) {
  12339. dist = Math.abs( event[ axis ] - cur );
  12340. itemWithLeastDistance = this.items[ j ];
  12341. this.direction = nearBottom ? "up": "down";
  12342. }
  12343. }
  12344. //Check if dropOnEmpty is enabled
  12345. if(!itemWithLeastDistance && !this.options.dropOnEmpty) {
  12346. return;
  12347. }
  12348. if(this.currentContainer === this.containers[innermostIndex]) {
  12349. if ( !this.currentContainer.containerCache.over ) {
  12350. this.containers[ innermostIndex ]._trigger( "over", event, this._uiHash() );
  12351. this.currentContainer.containerCache.over = 1;
  12352. }
  12353. return;
  12354. }
  12355. itemWithLeastDistance ? this._rearrange(event, itemWithLeastDistance, null, true) : this._rearrange(event, null, this.containers[innermostIndex].element, true);
  12356. this._trigger("change", event, this._uiHash());
  12357. this.containers[innermostIndex]._trigger("change", event, this._uiHash(this));
  12358. this.currentContainer = this.containers[innermostIndex];
  12359. //Update the placeholder
  12360. this.options.placeholder.update(this.currentContainer, this.placeholder);
  12361. this.containers[innermostIndex]._trigger("over", event, this._uiHash(this));
  12362. this.containers[innermostIndex].containerCache.over = 1;
  12363. }
  12364. },
  12365. _createHelper: function(event) {
  12366. var o = this.options,
  12367. helper = $.isFunction(o.helper) ? $(o.helper.apply(this.element[0], [event, this.currentItem])) : (o.helper === "clone" ? this.currentItem.clone() : this.currentItem);
  12368. //Add the helper to the DOM if that didn't happen already
  12369. if(!helper.parents("body").length) {
  12370. $(o.appendTo !== "parent" ? o.appendTo : this.currentItem[0].parentNode)[0].appendChild(helper[0]);
  12371. }
  12372. if(helper[0] === this.currentItem[0]) {
  12373. this._storedCSS = { width: this.currentItem[0].style.width, height: this.currentItem[0].style.height, position: this.currentItem.css("position"), top: this.currentItem.css("top"), left: this.currentItem.css("left") };
  12374. }
  12375. if(!helper[0].style.width || o.forceHelperSize) {
  12376. helper.width(this.currentItem.width());
  12377. }
  12378. if(!helper[0].style.height || o.forceHelperSize) {
  12379. helper.height(this.currentItem.height());
  12380. }
  12381. return helper;
  12382. },
  12383. _adjustOffsetFromHelper: function(obj) {
  12384. if (typeof obj === "string") {
  12385. obj = obj.split(" ");
  12386. }
  12387. if ($.isArray(obj)) {
  12388. obj = {left: +obj[0], top: +obj[1] || 0};
  12389. }
  12390. if ("left" in obj) {
  12391. this.offset.click.left = obj.left + this.margins.left;
  12392. }
  12393. if ("right" in obj) {
  12394. this.offset.click.left = this.helperProportions.width - obj.right + this.margins.left;
  12395. }
  12396. if ("top" in obj) {
  12397. this.offset.click.top = obj.top + this.margins.top;
  12398. }
  12399. if ("bottom" in obj) {
  12400. this.offset.click.top = this.helperProportions.height - obj.bottom + this.margins.top;
  12401. }
  12402. },
  12403. _getParentOffset: function() {
  12404. //Get the offsetParent and cache its position
  12405. this.offsetParent = this.helper.offsetParent();
  12406. var po = this.offsetParent.offset();
  12407. // This is a special case where we need to modify a offset calculated on start, since the following happened:
  12408. // 1. The position of the helper is absolute, so it's position is calculated based on the next positioned parent
  12409. // 2. The actual offset parent is a child of the scroll parent, and the scroll parent isn't the document, which means that
  12410. // the scroll is included in the initial calculation of the offset of the parent, and never recalculated upon drag
  12411. if(this.cssPosition === "absolute" && this.scrollParent[0] !== this.document[0] && $.contains(this.scrollParent[0], this.offsetParent[0])) {
  12412. po.left += this.scrollParent.scrollLeft();
  12413. po.top += this.scrollParent.scrollTop();
  12414. }
  12415. // This needs to be actually done for all browsers, since pageX/pageY includes this information
  12416. // with an ugly IE fix
  12417. if( this.offsetParent[0] === this.document[0].body || (this.offsetParent[0].tagName && this.offsetParent[0].tagName.toLowerCase() === "html" && $.ui.ie)) {
  12418. po = { top: 0, left: 0 };
  12419. }
  12420. return {
  12421. top: po.top + (parseInt(this.offsetParent.css("borderTopWidth"),10) || 0),
  12422. left: po.left + (parseInt(this.offsetParent.css("borderLeftWidth"),10) || 0)
  12423. };
  12424. },
  12425. _getRelativeOffset: function() {
  12426. if(this.cssPosition === "relative") {
  12427. var p = this.currentItem.position();
  12428. return {
  12429. top: p.top - (parseInt(this.helper.css("top"),10) || 0) + this.scrollParent.scrollTop(),
  12430. left: p.left - (parseInt(this.helper.css("left"),10) || 0) + this.scrollParent.scrollLeft()
  12431. };
  12432. } else {
  12433. return { top: 0, left: 0 };
  12434. }
  12435. },
  12436. _cacheMargins: function() {
  12437. this.margins = {
  12438. left: (parseInt(this.currentItem.css("marginLeft"),10) || 0),
  12439. top: (parseInt(this.currentItem.css("marginTop"),10) || 0)
  12440. };
  12441. },
  12442. _cacheHelperProportions: function() {
  12443. this.helperProportions = {
  12444. width: this.helper.outerWidth(),
  12445. height: this.helper.outerHeight()
  12446. };
  12447. },
  12448. _setContainment: function() {
  12449. var ce, co, over,
  12450. o = this.options;
  12451. if(o.containment === "parent") {
  12452. o.containment = this.helper[0].parentNode;
  12453. }
  12454. if(o.containment === "document" || o.containment === "window") {
  12455. this.containment = [
  12456. 0 - this.offset.relative.left - this.offset.parent.left,
  12457. 0 - this.offset.relative.top - this.offset.parent.top,
  12458. o.containment === "document" ? this.document.width() : this.window.width() - this.helperProportions.width - this.margins.left,
  12459. (o.containment === "document" ? this.document.width() : this.window.height() || this.document[0].body.parentNode.scrollHeight) - this.helperProportions.height - this.margins.top
  12460. ];
  12461. }
  12462. if(!(/^(document|window|parent)$/).test(o.containment)) {
  12463. ce = $(o.containment)[0];
  12464. co = $(o.containment).offset();
  12465. over = ($(ce).css("overflow") !== "hidden");
  12466. this.containment = [
  12467. co.left + (parseInt($(ce).css("borderLeftWidth"),10) || 0) + (parseInt($(ce).css("paddingLeft"),10) || 0) - this.margins.left,
  12468. co.top + (parseInt($(ce).css("borderTopWidth"),10) || 0) + (parseInt($(ce).css("paddingTop"),10) || 0) - this.margins.top,
  12469. co.left+(over ? Math.max(ce.scrollWidth,ce.offsetWidth) : ce.offsetWidth) - (parseInt($(ce).css("borderLeftWidth"),10) || 0) - (parseInt($(ce).css("paddingRight"),10) || 0) - this.helperProportions.width - this.margins.left,
  12470. co.top+(over ? Math.max(ce.scrollHeight,ce.offsetHeight) : ce.offsetHeight) - (parseInt($(ce).css("borderTopWidth"),10) || 0) - (parseInt($(ce).css("paddingBottom"),10) || 0) - this.helperProportions.height - this.margins.top
  12471. ];
  12472. }
  12473. },
  12474. _convertPositionTo: function(d, pos) {
  12475. if(!pos) {
  12476. pos = this.position;
  12477. }
  12478. var mod = d === "absolute" ? 1 : -1,
  12479. scroll = this.cssPosition === "absolute" && !(this.scrollParent[0] !== this.document[0] && $.contains(this.scrollParent[0], this.offsetParent[0])) ? this.offsetParent : this.scrollParent,
  12480. scrollIsRootNode = (/(html|body)/i).test(scroll[0].tagName);
  12481. return {
  12482. top: (
  12483. pos.top + // The absolute mouse position
  12484. this.offset.relative.top * mod + // Only for relative positioned nodes: Relative offset from element to offset parent
  12485. this.offset.parent.top * mod - // The offsetParent's offset without borders (offset + border)
  12486. ( ( this.cssPosition === "fixed" ? -this.scrollParent.scrollTop() : ( scrollIsRootNode ? 0 : scroll.scrollTop() ) ) * mod)
  12487. ),
  12488. left: (
  12489. pos.left + // The absolute mouse position
  12490. this.offset.relative.left * mod + // Only for relative positioned nodes: Relative offset from element to offset parent
  12491. this.offset.parent.left * mod - // The offsetParent's offset without borders (offset + border)
  12492. ( ( this.cssPosition === "fixed" ? -this.scrollParent.scrollLeft() : scrollIsRootNode ? 0 : scroll.scrollLeft() ) * mod)
  12493. )
  12494. };
  12495. },
  12496. _generatePosition: function(event) {
  12497. var top, left,
  12498. o = this.options,
  12499. pageX = event.pageX,
  12500. pageY = event.pageY,
  12501. scroll = this.cssPosition === "absolute" && !(this.scrollParent[0] !== this.document[0] && $.contains(this.scrollParent[0], this.offsetParent[0])) ? this.offsetParent : this.scrollParent, scrollIsRootNode = (/(html|body)/i).test(scroll[0].tagName);
  12502. // This is another very weird special case that only happens for relative elements:
  12503. // 1. If the css position is relative
  12504. // 2. and the scroll parent is the document or similar to the offset parent
  12505. // we have to refresh the relative offset during the scroll so there are no jumps
  12506. if(this.cssPosition === "relative" && !(this.scrollParent[0] !== this.document[0] && this.scrollParent[0] !== this.offsetParent[0])) {
  12507. this.offset.relative = this._getRelativeOffset();
  12508. }
  12509. /*
  12510. * - Position constraining -
  12511. * Constrain the position to a mix of grid, containment.
  12512. */
  12513. if(this.originalPosition) { //If we are not dragging yet, we won't check for options
  12514. if(this.containment) {
  12515. if(event.pageX - this.offset.click.left < this.containment[0]) {
  12516. pageX = this.containment[0] + this.offset.click.left;
  12517. }
  12518. if(event.pageY - this.offset.click.top < this.containment[1]) {
  12519. pageY = this.containment[1] + this.offset.click.top;
  12520. }
  12521. if(event.pageX - this.offset.click.left > this.containment[2]) {
  12522. pageX = this.containment[2] + this.offset.click.left;
  12523. }
  12524. if(event.pageY - this.offset.click.top > this.containment[3]) {
  12525. pageY = this.containment[3] + this.offset.click.top;
  12526. }
  12527. }
  12528. if(o.grid) {
  12529. top = this.originalPageY + Math.round((pageY - this.originalPageY) / o.grid[1]) * o.grid[1];
  12530. pageY = this.containment ? ( (top - this.offset.click.top >= this.containment[1] && top - this.offset.click.top <= this.containment[3]) ? top : ((top - this.offset.click.top >= this.containment[1]) ? top - o.grid[1] : top + o.grid[1])) : top;
  12531. left = this.originalPageX + Math.round((pageX - this.originalPageX) / o.grid[0]) * o.grid[0];
  12532. pageX = this.containment ? ( (left - this.offset.click.left >= this.containment[0] && left - this.offset.click.left <= this.containment[2]) ? left : ((left - this.offset.click.left >= this.containment[0]) ? left - o.grid[0] : left + o.grid[0])) : left;
  12533. }
  12534. }
  12535. return {
  12536. top: (
  12537. pageY - // The absolute mouse position
  12538. this.offset.click.top - // Click offset (relative to the element)
  12539. this.offset.relative.top - // Only for relative positioned nodes: Relative offset from element to offset parent
  12540. this.offset.parent.top + // The offsetParent's offset without borders (offset + border)
  12541. ( ( this.cssPosition === "fixed" ? -this.scrollParent.scrollTop() : ( scrollIsRootNode ? 0 : scroll.scrollTop() ) ))
  12542. ),
  12543. left: (
  12544. pageX - // The absolute mouse position
  12545. this.offset.click.left - // Click offset (relative to the element)
  12546. this.offset.relative.left - // Only for relative positioned nodes: Relative offset from element to offset parent
  12547. this.offset.parent.left + // The offsetParent's offset without borders (offset + border)
  12548. ( ( this.cssPosition === "fixed" ? -this.scrollParent.scrollLeft() : scrollIsRootNode ? 0 : scroll.scrollLeft() ))
  12549. )
  12550. };
  12551. },
  12552. _rearrange: function(event, i, a, hardRefresh) {
  12553. a ? a[0].appendChild(this.placeholder[0]) : i.item[0].parentNode.insertBefore(this.placeholder[0], (this.direction === "down" ? i.item[0] : i.item[0].nextSibling));
  12554. //Various things done here to improve the performance:
  12555. // 1. we create a setTimeout, that calls refreshPositions
  12556. // 2. on the instance, we have a counter variable, that get's higher after every append
  12557. // 3. on the local scope, we copy the counter variable, and check in the timeout, if it's still the same
  12558. // 4. this lets only the last addition to the timeout stack through
  12559. this.counter = this.counter ? ++this.counter : 1;
  12560. var counter = this.counter;
  12561. this._delay(function() {
  12562. if(counter === this.counter) {
  12563. this.refreshPositions(!hardRefresh); //Precompute after each DOM insertion, NOT on mousemove
  12564. }
  12565. });
  12566. },
  12567. _clear: function(event, noPropagation) {
  12568. this.reverting = false;
  12569. // We delay all events that have to be triggered to after the point where the placeholder has been removed and
  12570. // everything else normalized again
  12571. var i,
  12572. delayedTriggers = [];
  12573. // We first have to update the dom position of the actual currentItem
  12574. // Note: don't do it if the current item is already removed (by a user), or it gets reappended (see #4088)
  12575. if(!this._noFinalSort && this.currentItem.parent().length) {
  12576. this.placeholder.before(this.currentItem);
  12577. }
  12578. this._noFinalSort = null;
  12579. if(this.helper[0] === this.currentItem[0]) {
  12580. for(i in this._storedCSS) {
  12581. if(this._storedCSS[i] === "auto" || this._storedCSS[i] === "static") {
  12582. this._storedCSS[i] = "";
  12583. }
  12584. }
  12585. this.currentItem.css(this._storedCSS).removeClass("ui-sortable-helper");
  12586. } else {
  12587. this.currentItem.show();
  12588. }
  12589. if(this.fromOutside && !noPropagation) {
  12590. delayedTriggers.push(function(event) { this._trigger("receive", event, this._uiHash(this.fromOutside)); });
  12591. }
  12592. if((this.fromOutside || this.domPosition.prev !== this.currentItem.prev().not(".ui-sortable-helper")[0] || this.domPosition.parent !== this.currentItem.parent()[0]) && !noPropagation) {
  12593. delayedTriggers.push(function(event) { this._trigger("update", event, this._uiHash()); }); //Trigger update callback if the DOM position has changed
  12594. }
  12595. // Check if the items Container has Changed and trigger appropriate
  12596. // events.
  12597. if (this !== this.currentContainer) {
  12598. if(!noPropagation) {
  12599. delayedTriggers.push(function(event) { this._trigger("remove", event, this._uiHash()); });
  12600. delayedTriggers.push((function(c) { return function(event) { c._trigger("receive", event, this._uiHash(this)); }; }).call(this, this.currentContainer));
  12601. delayedTriggers.push((function(c) { return function(event) { c._trigger("update", event, this._uiHash(this)); }; }).call(this, this.currentContainer));
  12602. }
  12603. }
  12604. //Post events to containers
  12605. function delayEvent( type, instance, container ) {
  12606. return function( event ) {
  12607. container._trigger( type, event, instance._uiHash( instance ) );
  12608. };
  12609. }
  12610. for (i = this.containers.length - 1; i >= 0; i--){
  12611. if (!noPropagation) {
  12612. delayedTriggers.push( delayEvent( "deactivate", this, this.containers[ i ] ) );
  12613. }
  12614. if(this.containers[i].containerCache.over) {
  12615. delayedTriggers.push( delayEvent( "out", this, this.containers[ i ] ) );
  12616. this.containers[i].containerCache.over = 0;
  12617. }
  12618. }
  12619. //Do what was originally in plugins
  12620. if ( this.storedCursor ) {
  12621. this.document.find( "body" ).css( "cursor", this.storedCursor );
  12622. this.storedStylesheet.remove();
  12623. }
  12624. if(this._storedOpacity) {
  12625. this.helper.css("opacity", this._storedOpacity);
  12626. }
  12627. if(this._storedZIndex) {
  12628. this.helper.css("zIndex", this._storedZIndex === "auto" ? "" : this._storedZIndex);
  12629. }
  12630. this.dragging = false;
  12631. if(!noPropagation) {
  12632. this._trigger("beforeStop", event, this._uiHash());
  12633. }
  12634. //$(this.placeholder[0]).remove(); would have been the jQuery way - unfortunately, it unbinds ALL events from the original node!
  12635. this.placeholder[0].parentNode.removeChild(this.placeholder[0]);
  12636. if ( !this.cancelHelperRemoval ) {
  12637. if ( this.helper[ 0 ] !== this.currentItem[ 0 ] ) {
  12638. this.helper.remove();
  12639. }
  12640. this.helper = null;
  12641. }
  12642. if(!noPropagation) {
  12643. for (i=0; i < delayedTriggers.length; i++) {
  12644. delayedTriggers[i].call(this, event);
  12645. } //Trigger all delayed events
  12646. this._trigger("stop", event, this._uiHash());
  12647. }
  12648. this.fromOutside = false;
  12649. return !this.cancelHelperRemoval;
  12650. },
  12651. _trigger: function() {
  12652. if ($.Widget.prototype._trigger.apply(this, arguments) === false) {
  12653. this.cancel();
  12654. }
  12655. },
  12656. _uiHash: function(_inst) {
  12657. var inst = _inst || this;
  12658. return {
  12659. helper: inst.helper,
  12660. placeholder: inst.placeholder || $([]),
  12661. position: inst.position,
  12662. originalPosition: inst.originalPosition,
  12663. offset: inst.positionAbs,
  12664. item: inst.currentItem,
  12665. sender: _inst ? _inst.element : null
  12666. };
  12667. }
  12668. });
  12669. /*!
  12670. * jQuery UI Spinner 1.11.3
  12671. * http://jqueryui.com
  12672. *
  12673. * Copyright jQuery Foundation and other contributors
  12674. * Released under the MIT license.
  12675. * http://jquery.org/license
  12676. *
  12677. * http://api.jqueryui.com/spinner/
  12678. */
  12679. function spinner_modifier( fn ) {
  12680. return function() {
  12681. var previous = this.element.val();
  12682. fn.apply( this, arguments );
  12683. this._refresh();
  12684. if ( previous !== this.element.val() ) {
  12685. this._trigger( "change" );
  12686. }
  12687. };
  12688. }
  12689. var spinner = $.widget( "ui.spinner", {
  12690. version: "1.11.3",
  12691. defaultElement: "<input>",
  12692. widgetEventPrefix: "spin",
  12693. options: {
  12694. culture: null,
  12695. icons: {
  12696. down: "ui-icon-triangle-1-s",
  12697. up: "ui-icon-triangle-1-n"
  12698. },
  12699. incremental: true,
  12700. max: null,
  12701. min: null,
  12702. numberFormat: null,
  12703. page: 10,
  12704. step: 1,
  12705. change: null,
  12706. spin: null,
  12707. start: null,
  12708. stop: null
  12709. },
  12710. _create: function() {
  12711. // handle string values that need to be parsed
  12712. this._setOption( "max", this.options.max );
  12713. this._setOption( "min", this.options.min );
  12714. this._setOption( "step", this.options.step );
  12715. // Only format if there is a value, prevents the field from being marked
  12716. // as invalid in Firefox, see #9573.
  12717. if ( this.value() !== "" ) {
  12718. // Format the value, but don't constrain.
  12719. this._value( this.element.val(), true );
  12720. }
  12721. this._draw();
  12722. this._on( this._events );
  12723. this._refresh();
  12724. // turning off autocomplete prevents the browser from remembering the
  12725. // value when navigating through history, so we re-enable autocomplete
  12726. // if the page is unloaded before the widget is destroyed. #7790
  12727. this._on( this.window, {
  12728. beforeunload: function() {
  12729. this.element.removeAttr( "autocomplete" );
  12730. }
  12731. });
  12732. },
  12733. _getCreateOptions: function() {
  12734. var options = {},
  12735. element = this.element;
  12736. $.each( [ "min", "max", "step" ], function( i, option ) {
  12737. var value = element.attr( option );
  12738. if ( value !== undefined && value.length ) {
  12739. options[ option ] = value;
  12740. }
  12741. });
  12742. return options;
  12743. },
  12744. _events: {
  12745. keydown: function( event ) {
  12746. if ( this._start( event ) && this._keydown( event ) ) {
  12747. event.preventDefault();
  12748. }
  12749. },
  12750. keyup: "_stop",
  12751. focus: function() {
  12752. this.previous = this.element.val();
  12753. },
  12754. blur: function( event ) {
  12755. if ( this.cancelBlur ) {
  12756. delete this.cancelBlur;
  12757. return;
  12758. }
  12759. this._stop();
  12760. this._refresh();
  12761. if ( this.previous !== this.element.val() ) {
  12762. this._trigger( "change", event );
  12763. }
  12764. },
  12765. mousewheel: function( event, delta ) {
  12766. if ( !delta ) {
  12767. return;
  12768. }
  12769. if ( !this.spinning && !this._start( event ) ) {
  12770. return false;
  12771. }
  12772. this._spin( (delta > 0 ? 1 : -1) * this.options.step, event );
  12773. clearTimeout( this.mousewheelTimer );
  12774. this.mousewheelTimer = this._delay(function() {
  12775. if ( this.spinning ) {
  12776. this._stop( event );
  12777. }
  12778. }, 100 );
  12779. event.preventDefault();
  12780. },
  12781. "mousedown .ui-spinner-button": function( event ) {
  12782. var previous;
  12783. // We never want the buttons to have focus; whenever the user is
  12784. // interacting with the spinner, the focus should be on the input.
  12785. // If the input is focused then this.previous is properly set from
  12786. // when the input first received focus. If the input is not focused
  12787. // then we need to set this.previous based on the value before spinning.
  12788. previous = this.element[0] === this.document[0].activeElement ?
  12789. this.previous : this.element.val();
  12790. function checkFocus() {
  12791. var isActive = this.element[0] === this.document[0].activeElement;
  12792. if ( !isActive ) {
  12793. this.element.focus();
  12794. this.previous = previous;
  12795. // support: IE
  12796. // IE sets focus asynchronously, so we need to check if focus
  12797. // moved off of the input because the user clicked on the button.
  12798. this._delay(function() {
  12799. this.previous = previous;
  12800. });
  12801. }
  12802. }
  12803. // ensure focus is on (or stays on) the text field
  12804. event.preventDefault();
  12805. checkFocus.call( this );
  12806. // support: IE
  12807. // IE doesn't prevent moving focus even with event.preventDefault()
  12808. // so we set a flag to know when we should ignore the blur event
  12809. // and check (again) if focus moved off of the input.
  12810. this.cancelBlur = true;
  12811. this._delay(function() {
  12812. delete this.cancelBlur;
  12813. checkFocus.call( this );
  12814. });
  12815. if ( this._start( event ) === false ) {
  12816. return;
  12817. }
  12818. this._repeat( null, $( event.currentTarget ).hasClass( "ui-spinner-up" ) ? 1 : -1, event );
  12819. },
  12820. "mouseup .ui-spinner-button": "_stop",
  12821. "mouseenter .ui-spinner-button": function( event ) {
  12822. // button will add ui-state-active if mouse was down while mouseleave and kept down
  12823. if ( !$( event.currentTarget ).hasClass( "ui-state-active" ) ) {
  12824. return;
  12825. }
  12826. if ( this._start( event ) === false ) {
  12827. return false;
  12828. }
  12829. this._repeat( null, $( event.currentTarget ).hasClass( "ui-spinner-up" ) ? 1 : -1, event );
  12830. },
  12831. // TODO: do we really want to consider this a stop?
  12832. // shouldn't we just stop the repeater and wait until mouseup before
  12833. // we trigger the stop event?
  12834. "mouseleave .ui-spinner-button": "_stop"
  12835. },
  12836. _draw: function() {
  12837. var uiSpinner = this.uiSpinner = this.element
  12838. .addClass( "ui-spinner-input" )
  12839. .attr( "autocomplete", "off" )
  12840. .wrap( this._uiSpinnerHtml() )
  12841. .parent()
  12842. // add buttons
  12843. .append( this._buttonHtml() );
  12844. this.element.attr( "role", "spinbutton" );
  12845. // button bindings
  12846. this.buttons = uiSpinner.find( ".ui-spinner-button" )
  12847. .attr( "tabIndex", -1 )
  12848. .button()
  12849. .removeClass( "ui-corner-all" );
  12850. // IE 6 doesn't understand height: 50% for the buttons
  12851. // unless the wrapper has an explicit height
  12852. if ( this.buttons.height() > Math.ceil( uiSpinner.height() * 0.5 ) &&
  12853. uiSpinner.height() > 0 ) {
  12854. uiSpinner.height( uiSpinner.height() );
  12855. }
  12856. // disable spinner if element was already disabled
  12857. if ( this.options.disabled ) {
  12858. this.disable();
  12859. }
  12860. },
  12861. _keydown: function( event ) {
  12862. var options = this.options,
  12863. keyCode = $.ui.keyCode;
  12864. switch ( event.keyCode ) {
  12865. case keyCode.UP:
  12866. this._repeat( null, 1, event );
  12867. return true;
  12868. case keyCode.DOWN:
  12869. this._repeat( null, -1, event );
  12870. return true;
  12871. case keyCode.PAGE_UP:
  12872. this._repeat( null, options.page, event );
  12873. return true;
  12874. case keyCode.PAGE_DOWN:
  12875. this._repeat( null, -options.page, event );
  12876. return true;
  12877. }
  12878. return false;
  12879. },
  12880. _uiSpinnerHtml: function() {
  12881. return "<span class='ui-spinner ui-widget ui-widget-content ui-corner-all'></span>";
  12882. },
  12883. _buttonHtml: function() {
  12884. return "" +
  12885. "<a class='ui-spinner-button ui-spinner-up ui-corner-tr'>" +
  12886. "<span class='ui-icon " + this.options.icons.up + "'>&#9650;</span>" +
  12887. "</a>" +
  12888. "<a class='ui-spinner-button ui-spinner-down ui-corner-br'>" +
  12889. "<span class='ui-icon " + this.options.icons.down + "'>&#9660;</span>" +
  12890. "</a>";
  12891. },
  12892. _start: function( event ) {
  12893. if ( !this.spinning && this._trigger( "start", event ) === false ) {
  12894. return false;
  12895. }
  12896. if ( !this.counter ) {
  12897. this.counter = 1;
  12898. }
  12899. this.spinning = true;
  12900. return true;
  12901. },
  12902. _repeat: function( i, steps, event ) {
  12903. i = i || 500;
  12904. clearTimeout( this.timer );
  12905. this.timer = this._delay(function() {
  12906. this._repeat( 40, steps, event );
  12907. }, i );
  12908. this._spin( steps * this.options.step, event );
  12909. },
  12910. _spin: function( step, event ) {
  12911. var value = this.value() || 0;
  12912. if ( !this.counter ) {
  12913. this.counter = 1;
  12914. }
  12915. value = this._adjustValue( value + step * this._increment( this.counter ) );
  12916. if ( !this.spinning || this._trigger( "spin", event, { value: value } ) !== false) {
  12917. this._value( value );
  12918. this.counter++;
  12919. }
  12920. },
  12921. _increment: function( i ) {
  12922. var incremental = this.options.incremental;
  12923. if ( incremental ) {
  12924. return $.isFunction( incremental ) ?
  12925. incremental( i ) :
  12926. Math.floor( i * i * i / 50000 - i * i / 500 + 17 * i / 200 + 1 );
  12927. }
  12928. return 1;
  12929. },
  12930. _precision: function() {
  12931. var precision = this._precisionOf( this.options.step );
  12932. if ( this.options.min !== null ) {
  12933. precision = Math.max( precision, this._precisionOf( this.options.min ) );
  12934. }
  12935. return precision;
  12936. },
  12937. _precisionOf: function( num ) {
  12938. var str = num.toString(),
  12939. decimal = str.indexOf( "." );
  12940. return decimal === -1 ? 0 : str.length - decimal - 1;
  12941. },
  12942. _adjustValue: function( value ) {
  12943. var base, aboveMin,
  12944. options = this.options;
  12945. // make sure we're at a valid step
  12946. // - find out where we are relative to the base (min or 0)
  12947. base = options.min !== null ? options.min : 0;
  12948. aboveMin = value - base;
  12949. // - round to the nearest step
  12950. aboveMin = Math.round(aboveMin / options.step) * options.step;
  12951. // - rounding is based on 0, so adjust back to our base
  12952. value = base + aboveMin;
  12953. // fix precision from bad JS floating point math
  12954. value = parseFloat( value.toFixed( this._precision() ) );
  12955. // clamp the value
  12956. if ( options.max !== null && value > options.max) {
  12957. return options.max;
  12958. }
  12959. if ( options.min !== null && value < options.min ) {
  12960. return options.min;
  12961. }
  12962. return value;
  12963. },
  12964. _stop: function( event ) {
  12965. if ( !this.spinning ) {
  12966. return;
  12967. }
  12968. clearTimeout( this.timer );
  12969. clearTimeout( this.mousewheelTimer );
  12970. this.counter = 0;
  12971. this.spinning = false;
  12972. this._trigger( "stop", event );
  12973. },
  12974. _setOption: function( key, value ) {
  12975. if ( key === "culture" || key === "numberFormat" ) {
  12976. var prevValue = this._parse( this.element.val() );
  12977. this.options[ key ] = value;
  12978. this.element.val( this._format( prevValue ) );
  12979. return;
  12980. }
  12981. if ( key === "max" || key === "min" || key === "step" ) {
  12982. if ( typeof value === "string" ) {
  12983. value = this._parse( value );
  12984. }
  12985. }
  12986. if ( key === "icons" ) {
  12987. this.buttons.first().find( ".ui-icon" )
  12988. .removeClass( this.options.icons.up )
  12989. .addClass( value.up );
  12990. this.buttons.last().find( ".ui-icon" )
  12991. .removeClass( this.options.icons.down )
  12992. .addClass( value.down );
  12993. }
  12994. this._super( key, value );
  12995. if ( key === "disabled" ) {
  12996. this.widget().toggleClass( "ui-state-disabled", !!value );
  12997. this.element.prop( "disabled", !!value );
  12998. this.buttons.button( value ? "disable" : "enable" );
  12999. }
  13000. },
  13001. _setOptions: spinner_modifier(function( options ) {
  13002. this._super( options );
  13003. }),
  13004. _parse: function( val ) {
  13005. if ( typeof val === "string" && val !== "" ) {
  13006. val = window.Globalize && this.options.numberFormat ?
  13007. Globalize.parseFloat( val, 10, this.options.culture ) : +val;
  13008. }
  13009. return val === "" || isNaN( val ) ? null : val;
  13010. },
  13011. _format: function( value ) {
  13012. if ( value === "" ) {
  13013. return "";
  13014. }
  13015. return window.Globalize && this.options.numberFormat ?
  13016. Globalize.format( value, this.options.numberFormat, this.options.culture ) :
  13017. value;
  13018. },
  13019. _refresh: function() {
  13020. this.element.attr({
  13021. "aria-valuemin": this.options.min,
  13022. "aria-valuemax": this.options.max,
  13023. // TODO: what should we do with values that can't be parsed?
  13024. "aria-valuenow": this._parse( this.element.val() )
  13025. });
  13026. },
  13027. isValid: function() {
  13028. var value = this.value();
  13029. // null is invalid
  13030. if ( value === null ) {
  13031. return false;
  13032. }
  13033. // if value gets adjusted, it's invalid
  13034. return value === this._adjustValue( value );
  13035. },
  13036. // update the value without triggering change
  13037. _value: function( value, allowAny ) {
  13038. var parsed;
  13039. if ( value !== "" ) {
  13040. parsed = this._parse( value );
  13041. if ( parsed !== null ) {
  13042. if ( !allowAny ) {
  13043. parsed = this._adjustValue( parsed );
  13044. }
  13045. value = this._format( parsed );
  13046. }
  13047. }
  13048. this.element.val( value );
  13049. this._refresh();
  13050. },
  13051. _destroy: function() {
  13052. this.element
  13053. .removeClass( "ui-spinner-input" )
  13054. .prop( "disabled", false )
  13055. .removeAttr( "autocomplete" )
  13056. .removeAttr( "role" )
  13057. .removeAttr( "aria-valuemin" )
  13058. .removeAttr( "aria-valuemax" )
  13059. .removeAttr( "aria-valuenow" );
  13060. this.uiSpinner.replaceWith( this.element );
  13061. },
  13062. stepUp: spinner_modifier(function( steps ) {
  13063. this._stepUp( steps );
  13064. }),
  13065. _stepUp: function( steps ) {
  13066. if ( this._start() ) {
  13067. this._spin( (steps || 1) * this.options.step );
  13068. this._stop();
  13069. }
  13070. },
  13071. stepDown: spinner_modifier(function( steps ) {
  13072. this._stepDown( steps );
  13073. }),
  13074. _stepDown: function( steps ) {
  13075. if ( this._start() ) {
  13076. this._spin( (steps || 1) * -this.options.step );
  13077. this._stop();
  13078. }
  13079. },
  13080. pageUp: spinner_modifier(function( pages ) {
  13081. this._stepUp( (pages || 1) * this.options.page );
  13082. }),
  13083. pageDown: spinner_modifier(function( pages ) {
  13084. this._stepDown( (pages || 1) * this.options.page );
  13085. }),
  13086. value: function( newVal ) {
  13087. if ( !arguments.length ) {
  13088. return this._parse( this.element.val() );
  13089. }
  13090. spinner_modifier( this._value ).call( this, newVal );
  13091. },
  13092. widget: function() {
  13093. return this.uiSpinner;
  13094. }
  13095. });
  13096. /*!
  13097. * jQuery UI Tabs 1.11.3
  13098. * http://jqueryui.com
  13099. *
  13100. * Copyright jQuery Foundation and other contributors
  13101. * Released under the MIT license.
  13102. * http://jquery.org/license
  13103. *
  13104. * http://api.jqueryui.com/tabs/
  13105. */
  13106. var tabs = $.widget( "ui.tabs", {
  13107. version: "1.11.3",
  13108. delay: 300,
  13109. options: {
  13110. active: null,
  13111. collapsible: false,
  13112. event: "click",
  13113. heightStyle: "content",
  13114. hide: null,
  13115. show: null,
  13116. // callbacks
  13117. activate: null,
  13118. beforeActivate: null,
  13119. beforeLoad: null,
  13120. load: null
  13121. },
  13122. _isLocal: (function() {
  13123. var rhash = /#.*$/;
  13124. return function( anchor ) {
  13125. var anchorUrl, locationUrl;
  13126. // support: IE7
  13127. // IE7 doesn't normalize the href property when set via script (#9317)
  13128. anchor = anchor.cloneNode( false );
  13129. anchorUrl = anchor.href.replace( rhash, "" );
  13130. locationUrl = location.href.replace( rhash, "" );
  13131. // decoding may throw an error if the URL isn't UTF-8 (#9518)
  13132. try {
  13133. anchorUrl = decodeURIComponent( anchorUrl );
  13134. } catch ( error ) {}
  13135. try {
  13136. locationUrl = decodeURIComponent( locationUrl );
  13137. } catch ( error ) {}
  13138. return anchor.hash.length > 1 && anchorUrl === locationUrl;
  13139. };
  13140. })(),
  13141. _create: function() {
  13142. var that = this,
  13143. options = this.options;
  13144. this.running = false;
  13145. this.element
  13146. .addClass( "ui-tabs ui-widget ui-widget-content ui-corner-all" )
  13147. .toggleClass( "ui-tabs-collapsible", options.collapsible );
  13148. this._processTabs();
  13149. options.active = this._initialActive();
  13150. // Take disabling tabs via class attribute from HTML
  13151. // into account and update option properly.
  13152. if ( $.isArray( options.disabled ) ) {
  13153. options.disabled = $.unique( options.disabled.concat(
  13154. $.map( this.tabs.filter( ".ui-state-disabled" ), function( li ) {
  13155. return that.tabs.index( li );
  13156. })
  13157. ) ).sort();
  13158. }
  13159. // check for length avoids error when initializing empty list
  13160. if ( this.options.active !== false && this.anchors.length ) {
  13161. this.active = this._findActive( options.active );
  13162. } else {
  13163. this.active = $();
  13164. }
  13165. this._refresh();
  13166. if ( this.active.length ) {
  13167. this.load( options.active );
  13168. }
  13169. },
  13170. _initialActive: function() {
  13171. var active = this.options.active,
  13172. collapsible = this.options.collapsible,
  13173. locationHash = location.hash.substring( 1 );
  13174. if ( active === null ) {
  13175. // check the fragment identifier in the URL
  13176. if ( locationHash ) {
  13177. this.tabs.each(function( i, tab ) {
  13178. if ( $( tab ).attr( "aria-controls" ) === locationHash ) {
  13179. active = i;
  13180. return false;
  13181. }
  13182. });
  13183. }
  13184. // check for a tab marked active via a class
  13185. if ( active === null ) {
  13186. active = this.tabs.index( this.tabs.filter( ".ui-tabs-active" ) );
  13187. }
  13188. // no active tab, set to false
  13189. if ( active === null || active === -1 ) {
  13190. active = this.tabs.length ? 0 : false;
  13191. }
  13192. }
  13193. // handle numbers: negative, out of range
  13194. if ( active !== false ) {
  13195. active = this.tabs.index( this.tabs.eq( active ) );
  13196. if ( active === -1 ) {
  13197. active = collapsible ? false : 0;
  13198. }
  13199. }
  13200. // don't allow collapsible: false and active: false
  13201. if ( !collapsible && active === false && this.anchors.length ) {
  13202. active = 0;
  13203. }
  13204. return active;
  13205. },
  13206. _getCreateEventData: function() {
  13207. return {
  13208. tab: this.active,
  13209. panel: !this.active.length ? $() : this._getPanelForTab( this.active )
  13210. };
  13211. },
  13212. _tabKeydown: function( event ) {
  13213. var focusedTab = $( this.document[0].activeElement ).closest( "li" ),
  13214. selectedIndex = this.tabs.index( focusedTab ),
  13215. goingForward = true;
  13216. if ( this._handlePageNav( event ) ) {
  13217. return;
  13218. }
  13219. switch ( event.keyCode ) {
  13220. case $.ui.keyCode.RIGHT:
  13221. case $.ui.keyCode.DOWN:
  13222. selectedIndex++;
  13223. break;
  13224. case $.ui.keyCode.UP:
  13225. case $.ui.keyCode.LEFT:
  13226. goingForward = false;
  13227. selectedIndex--;
  13228. break;
  13229. case $.ui.keyCode.END:
  13230. selectedIndex = this.anchors.length - 1;
  13231. break;
  13232. case $.ui.keyCode.HOME:
  13233. selectedIndex = 0;
  13234. break;
  13235. case $.ui.keyCode.SPACE:
  13236. // Activate only, no collapsing
  13237. event.preventDefault();
  13238. clearTimeout( this.activating );
  13239. this._activate( selectedIndex );
  13240. return;
  13241. case $.ui.keyCode.ENTER:
  13242. // Toggle (cancel delayed activation, allow collapsing)
  13243. event.preventDefault();
  13244. clearTimeout( this.activating );
  13245. // Determine if we should collapse or activate
  13246. this._activate( selectedIndex === this.options.active ? false : selectedIndex );
  13247. return;
  13248. default:
  13249. return;
  13250. }
  13251. // Focus the appropriate tab, based on which key was pressed
  13252. event.preventDefault();
  13253. clearTimeout( this.activating );
  13254. selectedIndex = this._focusNextTab( selectedIndex, goingForward );
  13255. // Navigating with control/command key will prevent automatic activation
  13256. if ( !event.ctrlKey && !event.metaKey ) {
  13257. // Update aria-selected immediately so that AT think the tab is already selected.
  13258. // Otherwise AT may confuse the user by stating that they need to activate the tab,
  13259. // but the tab will already be activated by the time the announcement finishes.
  13260. focusedTab.attr( "aria-selected", "false" );
  13261. this.tabs.eq( selectedIndex ).attr( "aria-selected", "true" );
  13262. this.activating = this._delay(function() {
  13263. this.option( "active", selectedIndex );
  13264. }, this.delay );
  13265. }
  13266. },
  13267. _panelKeydown: function( event ) {
  13268. if ( this._handlePageNav( event ) ) {
  13269. return;
  13270. }
  13271. // Ctrl+up moves focus to the current tab
  13272. if ( event.ctrlKey && event.keyCode === $.ui.keyCode.UP ) {
  13273. event.preventDefault();
  13274. this.active.focus();
  13275. }
  13276. },
  13277. // Alt+page up/down moves focus to the previous/next tab (and activates)
  13278. _handlePageNav: function( event ) {
  13279. if ( event.altKey && event.keyCode === $.ui.keyCode.PAGE_UP ) {
  13280. this._activate( this._focusNextTab( this.options.active - 1, false ) );
  13281. return true;
  13282. }
  13283. if ( event.altKey && event.keyCode === $.ui.keyCode.PAGE_DOWN ) {
  13284. this._activate( this._focusNextTab( this.options.active + 1, true ) );
  13285. return true;
  13286. }
  13287. },
  13288. _findNextTab: function( index, goingForward ) {
  13289. var lastTabIndex = this.tabs.length - 1;
  13290. function constrain() {
  13291. if ( index > lastTabIndex ) {
  13292. index = 0;
  13293. }
  13294. if ( index < 0 ) {
  13295. index = lastTabIndex;
  13296. }
  13297. return index;
  13298. }
  13299. while ( $.inArray( constrain(), this.options.disabled ) !== -1 ) {
  13300. index = goingForward ? index + 1 : index - 1;
  13301. }
  13302. return index;
  13303. },
  13304. _focusNextTab: function( index, goingForward ) {
  13305. index = this._findNextTab( index, goingForward );
  13306. this.tabs.eq( index ).focus();
  13307. return index;
  13308. },
  13309. _setOption: function( key, value ) {
  13310. if ( key === "active" ) {
  13311. // _activate() will handle invalid values and update this.options
  13312. this._activate( value );
  13313. return;
  13314. }
  13315. if ( key === "disabled" ) {
  13316. // don't use the widget factory's disabled handling
  13317. this._setupDisabled( value );
  13318. return;
  13319. }
  13320. this._super( key, value);
  13321. if ( key === "collapsible" ) {
  13322. this.element.toggleClass( "ui-tabs-collapsible", value );
  13323. // Setting collapsible: false while collapsed; open first panel
  13324. if ( !value && this.options.active === false ) {
  13325. this._activate( 0 );
  13326. }
  13327. }
  13328. if ( key === "event" ) {
  13329. this._setupEvents( value );
  13330. }
  13331. if ( key === "heightStyle" ) {
  13332. this._setupHeightStyle( value );
  13333. }
  13334. },
  13335. _sanitizeSelector: function( hash ) {
  13336. return hash ? hash.replace( /[!"$%&'()*+,.\/:;<=>?@\[\]\^`{|}~]/g, "\\$&" ) : "";
  13337. },
  13338. refresh: function() {
  13339. var options = this.options,
  13340. lis = this.tablist.children( ":has(a[href])" );
  13341. // get disabled tabs from class attribute from HTML
  13342. // this will get converted to a boolean if needed in _refresh()
  13343. options.disabled = $.map( lis.filter( ".ui-state-disabled" ), function( tab ) {
  13344. return lis.index( tab );
  13345. });
  13346. this._processTabs();
  13347. // was collapsed or no tabs
  13348. if ( options.active === false || !this.anchors.length ) {
  13349. options.active = false;
  13350. this.active = $();
  13351. // was active, but active tab is gone
  13352. } else if ( this.active.length && !$.contains( this.tablist[ 0 ], this.active[ 0 ] ) ) {
  13353. // all remaining tabs are disabled
  13354. if ( this.tabs.length === options.disabled.length ) {
  13355. options.active = false;
  13356. this.active = $();
  13357. // activate previous tab
  13358. } else {
  13359. this._activate( this._findNextTab( Math.max( 0, options.active - 1 ), false ) );
  13360. }
  13361. // was active, active tab still exists
  13362. } else {
  13363. // make sure active index is correct
  13364. options.active = this.tabs.index( this.active );
  13365. }
  13366. this._refresh();
  13367. },
  13368. _refresh: function() {
  13369. this._setupDisabled( this.options.disabled );
  13370. this._setupEvents( this.options.event );
  13371. this._setupHeightStyle( this.options.heightStyle );
  13372. this.tabs.not( this.active ).attr({
  13373. "aria-selected": "false",
  13374. "aria-expanded": "false",
  13375. tabIndex: -1
  13376. });
  13377. this.panels.not( this._getPanelForTab( this.active ) )
  13378. .hide()
  13379. .attr({
  13380. "aria-hidden": "true"
  13381. });
  13382. // Make sure one tab is in the tab order
  13383. if ( !this.active.length ) {
  13384. this.tabs.eq( 0 ).attr( "tabIndex", 0 );
  13385. } else {
  13386. this.active
  13387. .addClass( "ui-tabs-active ui-state-active" )
  13388. .attr({
  13389. "aria-selected": "true",
  13390. "aria-expanded": "true",
  13391. tabIndex: 0
  13392. });
  13393. this._getPanelForTab( this.active )
  13394. .show()
  13395. .attr({
  13396. "aria-hidden": "false"
  13397. });
  13398. }
  13399. },
  13400. _processTabs: function() {
  13401. var that = this,
  13402. prevTabs = this.tabs,
  13403. prevAnchors = this.anchors,
  13404. prevPanels = this.panels;
  13405. this.tablist = this._getList()
  13406. .addClass( "ui-tabs-nav ui-helper-reset ui-helper-clearfix ui-widget-header ui-corner-all" )
  13407. .attr( "role", "tablist" )
  13408. // Prevent users from focusing disabled tabs via click
  13409. .delegate( "> li", "mousedown" + this.eventNamespace, function( event ) {
  13410. if ( $( this ).is( ".ui-state-disabled" ) ) {
  13411. event.preventDefault();
  13412. }
  13413. })
  13414. // support: IE <9
  13415. // Preventing the default action in mousedown doesn't prevent IE
  13416. // from focusing the element, so if the anchor gets focused, blur.
  13417. // We don't have to worry about focusing the previously focused
  13418. // element since clicking on a non-focusable element should focus
  13419. // the body anyway.
  13420. .delegate( ".ui-tabs-anchor", "focus" + this.eventNamespace, function() {
  13421. if ( $( this ).closest( "li" ).is( ".ui-state-disabled" ) ) {
  13422. this.blur();
  13423. }
  13424. });
  13425. this.tabs = this.tablist.find( "> li:has(a[href])" )
  13426. .addClass( "ui-state-default ui-corner-top" )
  13427. .attr({
  13428. role: "tab",
  13429. tabIndex: -1
  13430. });
  13431. this.anchors = this.tabs.map(function() {
  13432. return $( "a", this )[ 0 ];
  13433. })
  13434. .addClass( "ui-tabs-anchor" )
  13435. .attr({
  13436. role: "presentation",
  13437. tabIndex: -1
  13438. });
  13439. this.panels = $();
  13440. this.anchors.each(function( i, anchor ) {
  13441. var selector, panel, panelId,
  13442. anchorId = $( anchor ).uniqueId().attr( "id" ),
  13443. tab = $( anchor ).closest( "li" ),
  13444. originalAriaControls = tab.attr( "aria-controls" );
  13445. // inline tab
  13446. if ( that._isLocal( anchor ) ) {
  13447. selector = anchor.hash;
  13448. panelId = selector.substring( 1 );
  13449. panel = that.element.find( that._sanitizeSelector( selector ) );
  13450. // remote tab
  13451. } else {
  13452. // If the tab doesn't already have aria-controls,
  13453. // generate an id by using a throw-away element
  13454. panelId = tab.attr( "aria-controls" ) || $( {} ).uniqueId()[ 0 ].id;
  13455. selector = "#" + panelId;
  13456. panel = that.element.find( selector );
  13457. if ( !panel.length ) {
  13458. panel = that._createPanel( panelId );
  13459. panel.insertAfter( that.panels[ i - 1 ] || that.tablist );
  13460. }
  13461. panel.attr( "aria-live", "polite" );
  13462. }
  13463. if ( panel.length) {
  13464. that.panels = that.panels.add( panel );
  13465. }
  13466. if ( originalAriaControls ) {
  13467. tab.data( "ui-tabs-aria-controls", originalAriaControls );
  13468. }
  13469. tab.attr({
  13470. "aria-controls": panelId,
  13471. "aria-labelledby": anchorId
  13472. });
  13473. panel.attr( "aria-labelledby", anchorId );
  13474. });
  13475. this.panels
  13476. .addClass( "ui-tabs-panel ui-widget-content ui-corner-bottom" )
  13477. .attr( "role", "tabpanel" );
  13478. // Avoid memory leaks (#10056)
  13479. if ( prevTabs ) {
  13480. this._off( prevTabs.not( this.tabs ) );
  13481. this._off( prevAnchors.not( this.anchors ) );
  13482. this._off( prevPanels.not( this.panels ) );
  13483. }
  13484. },
  13485. // allow overriding how to find the list for rare usage scenarios (#7715)
  13486. _getList: function() {
  13487. return this.tablist || this.element.find( "ol,ul" ).eq( 0 );
  13488. },
  13489. _createPanel: function( id ) {
  13490. return $( "<div>" )
  13491. .attr( "id", id )
  13492. .addClass( "ui-tabs-panel ui-widget-content ui-corner-bottom" )
  13493. .data( "ui-tabs-destroy", true );
  13494. },
  13495. _setupDisabled: function( disabled ) {
  13496. if ( $.isArray( disabled ) ) {
  13497. if ( !disabled.length ) {
  13498. disabled = false;
  13499. } else if ( disabled.length === this.anchors.length ) {
  13500. disabled = true;
  13501. }
  13502. }
  13503. // disable tabs
  13504. for ( var i = 0, li; ( li = this.tabs[ i ] ); i++ ) {
  13505. if ( disabled === true || $.inArray( i, disabled ) !== -1 ) {
  13506. $( li )
  13507. .addClass( "ui-state-disabled" )
  13508. .attr( "aria-disabled", "true" );
  13509. } else {
  13510. $( li )
  13511. .removeClass( "ui-state-disabled" )
  13512. .removeAttr( "aria-disabled" );
  13513. }
  13514. }
  13515. this.options.disabled = disabled;
  13516. },
  13517. _setupEvents: function( event ) {
  13518. var events = {};
  13519. if ( event ) {
  13520. $.each( event.split(" "), function( index, eventName ) {
  13521. events[ eventName ] = "_eventHandler";
  13522. });
  13523. }
  13524. this._off( this.anchors.add( this.tabs ).add( this.panels ) );
  13525. // Always prevent the default action, even when disabled
  13526. this._on( true, this.anchors, {
  13527. click: function( event ) {
  13528. event.preventDefault();
  13529. }
  13530. });
  13531. this._on( this.anchors, events );
  13532. this._on( this.tabs, { keydown: "_tabKeydown" } );
  13533. this._on( this.panels, { keydown: "_panelKeydown" } );
  13534. this._focusable( this.tabs );
  13535. this._hoverable( this.tabs );
  13536. },
  13537. _setupHeightStyle: function( heightStyle ) {
  13538. var maxHeight,
  13539. parent = this.element.parent();
  13540. if ( heightStyle === "fill" ) {
  13541. maxHeight = parent.height();
  13542. maxHeight -= this.element.outerHeight() - this.element.height();
  13543. this.element.siblings( ":visible" ).each(function() {
  13544. var elem = $( this ),
  13545. position = elem.css( "position" );
  13546. if ( position === "absolute" || position === "fixed" ) {
  13547. return;
  13548. }
  13549. maxHeight -= elem.outerHeight( true );
  13550. });
  13551. this.element.children().not( this.panels ).each(function() {
  13552. maxHeight -= $( this ).outerHeight( true );
  13553. });
  13554. this.panels.each(function() {
  13555. $( this ).height( Math.max( 0, maxHeight -
  13556. $( this ).innerHeight() + $( this ).height() ) );
  13557. })
  13558. .css( "overflow", "auto" );
  13559. } else if ( heightStyle === "auto" ) {
  13560. maxHeight = 0;
  13561. this.panels.each(function() {
  13562. maxHeight = Math.max( maxHeight, $( this ).height( "" ).height() );
  13563. }).height( maxHeight );
  13564. }
  13565. },
  13566. _eventHandler: function( event ) {
  13567. var options = this.options,
  13568. active = this.active,
  13569. anchor = $( event.currentTarget ),
  13570. tab = anchor.closest( "li" ),
  13571. clickedIsActive = tab[ 0 ] === active[ 0 ],
  13572. collapsing = clickedIsActive && options.collapsible,
  13573. toShow = collapsing ? $() : this._getPanelForTab( tab ),
  13574. toHide = !active.length ? $() : this._getPanelForTab( active ),
  13575. eventData = {
  13576. oldTab: active,
  13577. oldPanel: toHide,
  13578. newTab: collapsing ? $() : tab,
  13579. newPanel: toShow
  13580. };
  13581. event.preventDefault();
  13582. if ( tab.hasClass( "ui-state-disabled" ) ||
  13583. // tab is already loading
  13584. tab.hasClass( "ui-tabs-loading" ) ||
  13585. // can't switch durning an animation
  13586. this.running ||
  13587. // click on active header, but not collapsible
  13588. ( clickedIsActive && !options.collapsible ) ||
  13589. // allow canceling activation
  13590. ( this._trigger( "beforeActivate", event, eventData ) === false ) ) {
  13591. return;
  13592. }
  13593. options.active = collapsing ? false : this.tabs.index( tab );
  13594. this.active = clickedIsActive ? $() : tab;
  13595. if ( this.xhr ) {
  13596. this.xhr.abort();
  13597. }
  13598. if ( !toHide.length && !toShow.length ) {
  13599. $.error( "jQuery UI Tabs: Mismatching fragment identifier." );
  13600. }
  13601. if ( toShow.length ) {
  13602. this.load( this.tabs.index( tab ), event );
  13603. }
  13604. this._toggle( event, eventData );
  13605. },
  13606. // handles show/hide for selecting tabs
  13607. _toggle: function( event, eventData ) {
  13608. var that = this,
  13609. toShow = eventData.newPanel,
  13610. toHide = eventData.oldPanel;
  13611. this.running = true;
  13612. function complete() {
  13613. that.running = false;
  13614. that._trigger( "activate", event, eventData );
  13615. }
  13616. function show() {
  13617. eventData.newTab.closest( "li" ).addClass( "ui-tabs-active ui-state-active" );
  13618. if ( toShow.length && that.options.show ) {
  13619. that._show( toShow, that.options.show, complete );
  13620. } else {
  13621. toShow.show();
  13622. complete();
  13623. }
  13624. }
  13625. // start out by hiding, then showing, then completing
  13626. if ( toHide.length && this.options.hide ) {
  13627. this._hide( toHide, this.options.hide, function() {
  13628. eventData.oldTab.closest( "li" ).removeClass( "ui-tabs-active ui-state-active" );
  13629. show();
  13630. });
  13631. } else {
  13632. eventData.oldTab.closest( "li" ).removeClass( "ui-tabs-active ui-state-active" );
  13633. toHide.hide();
  13634. show();
  13635. }
  13636. toHide.attr( "aria-hidden", "true" );
  13637. eventData.oldTab.attr({
  13638. "aria-selected": "false",
  13639. "aria-expanded": "false"
  13640. });
  13641. // If we're switching tabs, remove the old tab from the tab order.
  13642. // If we're opening from collapsed state, remove the previous tab from the tab order.
  13643. // If we're collapsing, then keep the collapsing tab in the tab order.
  13644. if ( toShow.length && toHide.length ) {
  13645. eventData.oldTab.attr( "tabIndex", -1 );
  13646. } else if ( toShow.length ) {
  13647. this.tabs.filter(function() {
  13648. return $( this ).attr( "tabIndex" ) === 0;
  13649. })
  13650. .attr( "tabIndex", -1 );
  13651. }
  13652. toShow.attr( "aria-hidden", "false" );
  13653. eventData.newTab.attr({
  13654. "aria-selected": "true",
  13655. "aria-expanded": "true",
  13656. tabIndex: 0
  13657. });
  13658. },
  13659. _activate: function( index ) {
  13660. var anchor,
  13661. active = this._findActive( index );
  13662. // trying to activate the already active panel
  13663. if ( active[ 0 ] === this.active[ 0 ] ) {
  13664. return;
  13665. }
  13666. // trying to collapse, simulate a click on the current active header
  13667. if ( !active.length ) {
  13668. active = this.active;
  13669. }
  13670. anchor = active.find( ".ui-tabs-anchor" )[ 0 ];
  13671. this._eventHandler({
  13672. target: anchor,
  13673. currentTarget: anchor,
  13674. preventDefault: $.noop
  13675. });
  13676. },
  13677. _findActive: function( index ) {
  13678. return index === false ? $() : this.tabs.eq( index );
  13679. },
  13680. _getIndex: function( index ) {
  13681. // meta-function to give users option to provide a href string instead of a numerical index.
  13682. if ( typeof index === "string" ) {
  13683. index = this.anchors.index( this.anchors.filter( "[href$='" + index + "']" ) );
  13684. }
  13685. return index;
  13686. },
  13687. _destroy: function() {
  13688. if ( this.xhr ) {
  13689. this.xhr.abort();
  13690. }
  13691. this.element.removeClass( "ui-tabs ui-widget ui-widget-content ui-corner-all ui-tabs-collapsible" );
  13692. this.tablist
  13693. .removeClass( "ui-tabs-nav ui-helper-reset ui-helper-clearfix ui-widget-header ui-corner-all" )
  13694. .removeAttr( "role" );
  13695. this.anchors
  13696. .removeClass( "ui-tabs-anchor" )
  13697. .removeAttr( "role" )
  13698. .removeAttr( "tabIndex" )
  13699. .removeUniqueId();
  13700. this.tablist.unbind( this.eventNamespace );
  13701. this.tabs.add( this.panels ).each(function() {
  13702. if ( $.data( this, "ui-tabs-destroy" ) ) {
  13703. $( this ).remove();
  13704. } else {
  13705. $( this )
  13706. .removeClass( "ui-state-default ui-state-active ui-state-disabled " +
  13707. "ui-corner-top ui-corner-bottom ui-widget-content ui-tabs-active ui-tabs-panel" )
  13708. .removeAttr( "tabIndex" )
  13709. .removeAttr( "aria-live" )
  13710. .removeAttr( "aria-busy" )
  13711. .removeAttr( "aria-selected" )
  13712. .removeAttr( "aria-labelledby" )
  13713. .removeAttr( "aria-hidden" )
  13714. .removeAttr( "aria-expanded" )
  13715. .removeAttr( "role" );
  13716. }
  13717. });
  13718. this.tabs.each(function() {
  13719. var li = $( this ),
  13720. prev = li.data( "ui-tabs-aria-controls" );
  13721. if ( prev ) {
  13722. li
  13723. .attr( "aria-controls", prev )
  13724. .removeData( "ui-tabs-aria-controls" );
  13725. } else {
  13726. li.removeAttr( "aria-controls" );
  13727. }
  13728. });
  13729. this.panels.show();
  13730. if ( this.options.heightStyle !== "content" ) {
  13731. this.panels.css( "height", "" );
  13732. }
  13733. },
  13734. enable: function( index ) {
  13735. var disabled = this.options.disabled;
  13736. if ( disabled === false ) {
  13737. return;
  13738. }
  13739. if ( index === undefined ) {
  13740. disabled = false;
  13741. } else {
  13742. index = this._getIndex( index );
  13743. if ( $.isArray( disabled ) ) {
  13744. disabled = $.map( disabled, function( num ) {
  13745. return num !== index ? num : null;
  13746. });
  13747. } else {
  13748. disabled = $.map( this.tabs, function( li, num ) {
  13749. return num !== index ? num : null;
  13750. });
  13751. }
  13752. }
  13753. this._setupDisabled( disabled );
  13754. },
  13755. disable: function( index ) {
  13756. var disabled = this.options.disabled;
  13757. if ( disabled === true ) {
  13758. return;
  13759. }
  13760. if ( index === undefined ) {
  13761. disabled = true;
  13762. } else {
  13763. index = this._getIndex( index );
  13764. if ( $.inArray( index, disabled ) !== -1 ) {
  13765. return;
  13766. }
  13767. if ( $.isArray( disabled ) ) {
  13768. disabled = $.merge( [ index ], disabled ).sort();
  13769. } else {
  13770. disabled = [ index ];
  13771. }
  13772. }
  13773. this._setupDisabled( disabled );
  13774. },
  13775. load: function( index, event ) {
  13776. index = this._getIndex( index );
  13777. var that = this,
  13778. tab = this.tabs.eq( index ),
  13779. anchor = tab.find( ".ui-tabs-anchor" ),
  13780. panel = this._getPanelForTab( tab ),
  13781. eventData = {
  13782. tab: tab,
  13783. panel: panel
  13784. };
  13785. // not remote
  13786. if ( this._isLocal( anchor[ 0 ] ) ) {
  13787. return;
  13788. }
  13789. this.xhr = $.ajax( this._ajaxSettings( anchor, event, eventData ) );
  13790. // support: jQuery <1.8
  13791. // jQuery <1.8 returns false if the request is canceled in beforeSend,
  13792. // but as of 1.8, $.ajax() always returns a jqXHR object.
  13793. if ( this.xhr && this.xhr.statusText !== "canceled" ) {
  13794. tab.addClass( "ui-tabs-loading" );
  13795. panel.attr( "aria-busy", "true" );
  13796. this.xhr
  13797. .success(function( response ) {
  13798. // support: jQuery <1.8
  13799. // http://bugs.jquery.com/ticket/11778
  13800. setTimeout(function() {
  13801. panel.html( response );
  13802. that._trigger( "load", event, eventData );
  13803. }, 1 );
  13804. })
  13805. .complete(function( jqXHR, status ) {
  13806. // support: jQuery <1.8
  13807. // http://bugs.jquery.com/ticket/11778
  13808. setTimeout(function() {
  13809. if ( status === "abort" ) {
  13810. that.panels.stop( false, true );
  13811. }
  13812. tab.removeClass( "ui-tabs-loading" );
  13813. panel.removeAttr( "aria-busy" );
  13814. if ( jqXHR === that.xhr ) {
  13815. delete that.xhr;
  13816. }
  13817. }, 1 );
  13818. });
  13819. }
  13820. },
  13821. _ajaxSettings: function( anchor, event, eventData ) {
  13822. var that = this;
  13823. return {
  13824. url: anchor.attr( "href" ),
  13825. beforeSend: function( jqXHR, settings ) {
  13826. return that._trigger( "beforeLoad", event,
  13827. $.extend( { jqXHR: jqXHR, ajaxSettings: settings }, eventData ) );
  13828. }
  13829. };
  13830. },
  13831. _getPanelForTab: function( tab ) {
  13832. var id = $( tab ).attr( "aria-controls" );
  13833. return this.element.find( this._sanitizeSelector( "#" + id ) );
  13834. }
  13835. });
  13836. /*!
  13837. * jQuery UI Tooltip 1.11.3
  13838. * http://jqueryui.com
  13839. *
  13840. * Copyright jQuery Foundation and other contributors
  13841. * Released under the MIT license.
  13842. * http://jquery.org/license
  13843. *
  13844. * http://api.jqueryui.com/tooltip/
  13845. */
  13846. var tooltip = $.widget( "ui.tooltip", {
  13847. version: "1.11.3",
  13848. options: {
  13849. content: function() {
  13850. // support: IE<9, Opera in jQuery <1.7
  13851. // .text() can't accept undefined, so coerce to a string
  13852. var title = $( this ).attr( "title" ) || "";
  13853. // Escape title, since we're going from an attribute to raw HTML
  13854. return $( "<a>" ).text( title ).html();
  13855. },
  13856. hide: true,
  13857. // Disabled elements have inconsistent behavior across browsers (#8661)
  13858. items: "[title]:not([disabled])",
  13859. position: {
  13860. my: "left top+15",
  13861. at: "left bottom",
  13862. collision: "flipfit flip"
  13863. },
  13864. show: true,
  13865. tooltipClass: null,
  13866. track: false,
  13867. // callbacks
  13868. close: null,
  13869. open: null
  13870. },
  13871. _addDescribedBy: function( elem, id ) {
  13872. var describedby = (elem.attr( "aria-describedby" ) || "").split( /\s+/ );
  13873. describedby.push( id );
  13874. elem
  13875. .data( "ui-tooltip-id", id )
  13876. .attr( "aria-describedby", $.trim( describedby.join( " " ) ) );
  13877. },
  13878. _removeDescribedBy: function( elem ) {
  13879. var id = elem.data( "ui-tooltip-id" ),
  13880. describedby = (elem.attr( "aria-describedby" ) || "").split( /\s+/ ),
  13881. index = $.inArray( id, describedby );
  13882. if ( index !== -1 ) {
  13883. describedby.splice( index, 1 );
  13884. }
  13885. elem.removeData( "ui-tooltip-id" );
  13886. describedby = $.trim( describedby.join( " " ) );
  13887. if ( describedby ) {
  13888. elem.attr( "aria-describedby", describedby );
  13889. } else {
  13890. elem.removeAttr( "aria-describedby" );
  13891. }
  13892. },
  13893. _create: function() {
  13894. this._on({
  13895. mouseover: "open",
  13896. focusin: "open"
  13897. });
  13898. // IDs of generated tooltips, needed for destroy
  13899. this.tooltips = {};
  13900. // IDs of parent tooltips where we removed the title attribute
  13901. this.parents = {};
  13902. if ( this.options.disabled ) {
  13903. this._disable();
  13904. }
  13905. // Append the aria-live region so tooltips announce correctly
  13906. this.liveRegion = $( "<div>" )
  13907. .attr({
  13908. role: "log",
  13909. "aria-live": "assertive",
  13910. "aria-relevant": "additions"
  13911. })
  13912. .addClass( "ui-helper-hidden-accessible" )
  13913. .appendTo( this.document[ 0 ].body );
  13914. },
  13915. _setOption: function( key, value ) {
  13916. var that = this;
  13917. if ( key === "disabled" ) {
  13918. this[ value ? "_disable" : "_enable" ]();
  13919. this.options[ key ] = value;
  13920. // disable element style changes
  13921. return;
  13922. }
  13923. this._super( key, value );
  13924. if ( key === "content" ) {
  13925. $.each( this.tooltips, function( id, tooltipData ) {
  13926. that._updateContent( tooltipData.element );
  13927. });
  13928. }
  13929. },
  13930. _disable: function() {
  13931. var that = this;
  13932. // close open tooltips
  13933. $.each( this.tooltips, function( id, tooltipData ) {
  13934. var event = $.Event( "blur" );
  13935. event.target = event.currentTarget = tooltipData.element[ 0 ];
  13936. that.close( event, true );
  13937. });
  13938. // remove title attributes to prevent native tooltips
  13939. this.element.find( this.options.items ).addBack().each(function() {
  13940. var element = $( this );
  13941. if ( element.is( "[title]" ) ) {
  13942. element
  13943. .data( "ui-tooltip-title", element.attr( "title" ) )
  13944. .removeAttr( "title" );
  13945. }
  13946. });
  13947. },
  13948. _enable: function() {
  13949. // restore title attributes
  13950. this.element.find( this.options.items ).addBack().each(function() {
  13951. var element = $( this );
  13952. if ( element.data( "ui-tooltip-title" ) ) {
  13953. element.attr( "title", element.data( "ui-tooltip-title" ) );
  13954. }
  13955. });
  13956. },
  13957. open: function( event ) {
  13958. var that = this,
  13959. target = $( event ? event.target : this.element )
  13960. // we need closest here due to mouseover bubbling,
  13961. // but always pointing at the same event target
  13962. .closest( this.options.items );
  13963. // No element to show a tooltip for or the tooltip is already open
  13964. if ( !target.length || target.data( "ui-tooltip-id" ) ) {
  13965. return;
  13966. }
  13967. if ( target.attr( "title" ) ) {
  13968. target.data( "ui-tooltip-title", target.attr( "title" ) );
  13969. }
  13970. target.data( "ui-tooltip-open", true );
  13971. // kill parent tooltips, custom or native, for hover
  13972. if ( event && event.type === "mouseover" ) {
  13973. target.parents().each(function() {
  13974. var parent = $( this ),
  13975. blurEvent;
  13976. if ( parent.data( "ui-tooltip-open" ) ) {
  13977. blurEvent = $.Event( "blur" );
  13978. blurEvent.target = blurEvent.currentTarget = this;
  13979. that.close( blurEvent, true );
  13980. }
  13981. if ( parent.attr( "title" ) ) {
  13982. parent.uniqueId();
  13983. that.parents[ this.id ] = {
  13984. element: this,
  13985. title: parent.attr( "title" )
  13986. };
  13987. parent.attr( "title", "" );
  13988. }
  13989. });
  13990. }
  13991. this._updateContent( target, event );
  13992. },
  13993. _updateContent: function( target, event ) {
  13994. var content,
  13995. contentOption = this.options.content,
  13996. that = this,
  13997. eventType = event ? event.type : null;
  13998. if ( typeof contentOption === "string" ) {
  13999. return this._open( event, target, contentOption );
  14000. }
  14001. content = contentOption.call( target[0], function( response ) {
  14002. // ignore async response if tooltip was closed already
  14003. if ( !target.data( "ui-tooltip-open" ) ) {
  14004. return;
  14005. }
  14006. // IE may instantly serve a cached response for ajax requests
  14007. // delay this call to _open so the other call to _open runs first
  14008. that._delay(function() {
  14009. // jQuery creates a special event for focusin when it doesn't
  14010. // exist natively. To improve performance, the native event
  14011. // object is reused and the type is changed. Therefore, we can't
  14012. // rely on the type being correct after the event finished
  14013. // bubbling, so we set it back to the previous value. (#8740)
  14014. if ( event ) {
  14015. event.type = eventType;
  14016. }
  14017. this._open( event, target, response );
  14018. });
  14019. });
  14020. if ( content ) {
  14021. this._open( event, target, content );
  14022. }
  14023. },
  14024. _open: function( event, target, content ) {
  14025. var tooltipData, tooltip, events, delayedShow, a11yContent,
  14026. positionOption = $.extend( {}, this.options.position );
  14027. if ( !content ) {
  14028. return;
  14029. }
  14030. // Content can be updated multiple times. If the tooltip already
  14031. // exists, then just update the content and bail.
  14032. tooltipData = this._find( target );
  14033. if ( tooltipData ) {
  14034. tooltipData.tooltip.find( ".ui-tooltip-content" ).html( content );
  14035. return;
  14036. }
  14037. // if we have a title, clear it to prevent the native tooltip
  14038. // we have to check first to avoid defining a title if none exists
  14039. // (we don't want to cause an element to start matching [title])
  14040. //
  14041. // We use removeAttr only for key events, to allow IE to export the correct
  14042. // accessible attributes. For mouse events, set to empty string to avoid
  14043. // native tooltip showing up (happens only when removing inside mouseover).
  14044. if ( target.is( "[title]" ) ) {
  14045. if ( event && event.type === "mouseover" ) {
  14046. target.attr( "title", "" );
  14047. } else {
  14048. target.removeAttr( "title" );
  14049. }
  14050. }
  14051. tooltipData = this._tooltip( target );
  14052. tooltip = tooltipData.tooltip;
  14053. this._addDescribedBy( target, tooltip.attr( "id" ) );
  14054. tooltip.find( ".ui-tooltip-content" ).html( content );
  14055. // Support: Voiceover on OS X, JAWS on IE <= 9
  14056. // JAWS announces deletions even when aria-relevant="additions"
  14057. // Voiceover will sometimes re-read the entire log region's contents from the beginning
  14058. this.liveRegion.children().hide();
  14059. if ( content.clone ) {
  14060. a11yContent = content.clone();
  14061. a11yContent.removeAttr( "id" ).find( "[id]" ).removeAttr( "id" );
  14062. } else {
  14063. a11yContent = content;
  14064. }
  14065. $( "<div>" ).html( a11yContent ).appendTo( this.liveRegion );
  14066. function position( event ) {
  14067. positionOption.of = event;
  14068. if ( tooltip.is( ":hidden" ) ) {
  14069. return;
  14070. }
  14071. tooltip.position( positionOption );
  14072. }
  14073. if ( this.options.track && event && /^mouse/.test( event.type ) ) {
  14074. this._on( this.document, {
  14075. mousemove: position
  14076. });
  14077. // trigger once to override element-relative positioning
  14078. position( event );
  14079. } else {
  14080. tooltip.position( $.extend({
  14081. of: target
  14082. }, this.options.position ) );
  14083. }
  14084. tooltip.hide();
  14085. this._show( tooltip, this.options.show );
  14086. // Handle tracking tooltips that are shown with a delay (#8644). As soon
  14087. // as the tooltip is visible, position the tooltip using the most recent
  14088. // event.
  14089. if ( this.options.show && this.options.show.delay ) {
  14090. delayedShow = this.delayedShow = setInterval(function() {
  14091. if ( tooltip.is( ":visible" ) ) {
  14092. position( positionOption.of );
  14093. clearInterval( delayedShow );
  14094. }
  14095. }, $.fx.interval );
  14096. }
  14097. this._trigger( "open", event, { tooltip: tooltip } );
  14098. events = {
  14099. keyup: function( event ) {
  14100. if ( event.keyCode === $.ui.keyCode.ESCAPE ) {
  14101. var fakeEvent = $.Event(event);
  14102. fakeEvent.currentTarget = target[0];
  14103. this.close( fakeEvent, true );
  14104. }
  14105. }
  14106. };
  14107. // Only bind remove handler for delegated targets. Non-delegated
  14108. // tooltips will handle this in destroy.
  14109. if ( target[ 0 ] !== this.element[ 0 ] ) {
  14110. events.remove = function() {
  14111. this._removeTooltip( tooltip );
  14112. };
  14113. }
  14114. if ( !event || event.type === "mouseover" ) {
  14115. events.mouseleave = "close";
  14116. }
  14117. if ( !event || event.type === "focusin" ) {
  14118. events.focusout = "close";
  14119. }
  14120. this._on( true, target, events );
  14121. },
  14122. close: function( event ) {
  14123. var tooltip,
  14124. that = this,
  14125. target = $( event ? event.currentTarget : this.element ),
  14126. tooltipData = this._find( target );
  14127. // The tooltip may already be closed
  14128. if ( !tooltipData ) {
  14129. return;
  14130. }
  14131. tooltip = tooltipData.tooltip;
  14132. // disabling closes the tooltip, so we need to track when we're closing
  14133. // to avoid an infinite loop in case the tooltip becomes disabled on close
  14134. if ( tooltipData.closing ) {
  14135. return;
  14136. }
  14137. // Clear the interval for delayed tracking tooltips
  14138. clearInterval( this.delayedShow );
  14139. // only set title if we had one before (see comment in _open())
  14140. // If the title attribute has changed since open(), don't restore
  14141. if ( target.data( "ui-tooltip-title" ) && !target.attr( "title" ) ) {
  14142. target.attr( "title", target.data( "ui-tooltip-title" ) );
  14143. }
  14144. this._removeDescribedBy( target );
  14145. tooltipData.hiding = true;
  14146. tooltip.stop( true );
  14147. this._hide( tooltip, this.options.hide, function() {
  14148. that._removeTooltip( $( this ) );
  14149. });
  14150. target.removeData( "ui-tooltip-open" );
  14151. this._off( target, "mouseleave focusout keyup" );
  14152. // Remove 'remove' binding only on delegated targets
  14153. if ( target[ 0 ] !== this.element[ 0 ] ) {
  14154. this._off( target, "remove" );
  14155. }
  14156. this._off( this.document, "mousemove" );
  14157. if ( event && event.type === "mouseleave" ) {
  14158. $.each( this.parents, function( id, parent ) {
  14159. $( parent.element ).attr( "title", parent.title );
  14160. delete that.parents[ id ];
  14161. });
  14162. }
  14163. tooltipData.closing = true;
  14164. this._trigger( "close", event, { tooltip: tooltip } );
  14165. if ( !tooltipData.hiding ) {
  14166. tooltipData.closing = false;
  14167. }
  14168. },
  14169. _tooltip: function( element ) {
  14170. var tooltip = $( "<div>" )
  14171. .attr( "role", "tooltip" )
  14172. .addClass( "ui-tooltip ui-widget ui-corner-all ui-widget-content " +
  14173. ( this.options.tooltipClass || "" ) ),
  14174. id = tooltip.uniqueId().attr( "id" );
  14175. $( "<div>" )
  14176. .addClass( "ui-tooltip-content" )
  14177. .appendTo( tooltip );
  14178. tooltip.appendTo( this.document[0].body );
  14179. return this.tooltips[ id ] = {
  14180. element: element,
  14181. tooltip: tooltip
  14182. };
  14183. },
  14184. _find: function( target ) {
  14185. var id = target.data( "ui-tooltip-id" );
  14186. return id ? this.tooltips[ id ] : null;
  14187. },
  14188. _removeTooltip: function( tooltip ) {
  14189. tooltip.remove();
  14190. delete this.tooltips[ tooltip.attr( "id" ) ];
  14191. },
  14192. _destroy: function() {
  14193. var that = this;
  14194. // close open tooltips
  14195. $.each( this.tooltips, function( id, tooltipData ) {
  14196. // Delegate to close method to handle common cleanup
  14197. var event = $.Event( "blur" ),
  14198. element = tooltipData.element;
  14199. event.target = event.currentTarget = element[ 0 ];
  14200. that.close( event, true );
  14201. // Remove immediately; destroying an open tooltip doesn't use the
  14202. // hide animation
  14203. $( "#" + id ).remove();
  14204. // Restore the title
  14205. if ( element.data( "ui-tooltip-title" ) ) {
  14206. // If the title attribute has changed since open(), don't restore
  14207. if ( !element.attr( "title" ) ) {
  14208. element.attr( "title", element.data( "ui-tooltip-title" ) );
  14209. }
  14210. element.removeData( "ui-tooltip-title" );
  14211. }
  14212. });
  14213. this.liveRegion.remove();
  14214. }
  14215. });
  14216. }));