jquery-ui.js 458 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582
  1. /*! jQuery UI - v1.11.2 - 2014-10-16
  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 2014 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.2
  16. * http://jqueryui.com
  17. *
  18. * Copyright 2014 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.2",
  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.2
  274. * http://jqueryui.com
  275. *
  276. * Copyright 2014 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. // allow multiple hashes to be passed on init
  432. options = !isMethodCall && args.length ?
  433. $.widget.extend.apply( null, [ options ].concat(args) ) :
  434. options;
  435. if ( isMethodCall ) {
  436. this.each(function() {
  437. var methodValue,
  438. instance = $.data( this, fullName );
  439. if ( options === "instance" ) {
  440. returnValue = instance;
  441. return false;
  442. }
  443. if ( !instance ) {
  444. return $.error( "cannot call methods on " + name + " prior to initialization; " +
  445. "attempted to call method '" + options + "'" );
  446. }
  447. if ( !$.isFunction( instance[options] ) || options.charAt( 0 ) === "_" ) {
  448. return $.error( "no such method '" + options + "' for " + name + " widget instance" );
  449. }
  450. methodValue = instance[ options ].apply( instance, args );
  451. if ( methodValue !== instance && methodValue !== undefined ) {
  452. returnValue = methodValue && methodValue.jquery ?
  453. returnValue.pushStack( methodValue.get() ) :
  454. methodValue;
  455. return false;
  456. }
  457. });
  458. } else {
  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.2
  756. * http://jqueryui.com
  757. *
  758. * Copyright 2014 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.2",
  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.2
  908. * http://jqueryui.com
  909. *
  910. * Copyright 2014 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 ( ( position.top + myOffset + atOffset + offset) > overTop && ( 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 ( ( position.top + myOffset + atOffset + offset) > overBottom && ( 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.2
  1368. * http://jqueryui.com
  1369. *
  1370. * Copyright 2014 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.2",
  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( "aria-selected", "false" );
  1772. // if we're switching panels, remove the old header from the tab order
  1773. // if we're opening from collapsed state, remove the previous header from the tab order
  1774. // if we're collapsing, then keep the collapsing header in the tab order
  1775. if ( toShow.length && toHide.length ) {
  1776. toHide.prev().attr({
  1777. "tabIndex": -1,
  1778. "aria-expanded": "false"
  1779. });
  1780. } else if ( toShow.length ) {
  1781. this.headers.filter(function() {
  1782. return $( this ).attr( "tabIndex" ) === 0;
  1783. })
  1784. .attr( "tabIndex", -1 );
  1785. }
  1786. toShow
  1787. .attr( "aria-hidden", "false" )
  1788. .prev()
  1789. .attr({
  1790. "aria-selected": "true",
  1791. tabIndex: 0,
  1792. "aria-expanded": "true"
  1793. });
  1794. },
  1795. _animate: function( toShow, toHide, data ) {
  1796. var total, easing, duration,
  1797. that = this,
  1798. adjust = 0,
  1799. down = toShow.length &&
  1800. ( !toHide.length || ( toShow.index() < toHide.index() ) ),
  1801. animate = this.options.animate || {},
  1802. options = down && animate.down || animate,
  1803. complete = function() {
  1804. that._toggleComplete( data );
  1805. };
  1806. if ( typeof options === "number" ) {
  1807. duration = options;
  1808. }
  1809. if ( typeof options === "string" ) {
  1810. easing = options;
  1811. }
  1812. // fall back from options to animation in case of partial down settings
  1813. easing = easing || options.easing || animate.easing;
  1814. duration = duration || options.duration || animate.duration;
  1815. if ( !toHide.length ) {
  1816. return toShow.animate( this.showProps, duration, easing, complete );
  1817. }
  1818. if ( !toShow.length ) {
  1819. return toHide.animate( this.hideProps, duration, easing, complete );
  1820. }
  1821. total = toShow.show().outerHeight();
  1822. toHide.animate( this.hideProps, {
  1823. duration: duration,
  1824. easing: easing,
  1825. step: function( now, fx ) {
  1826. fx.now = Math.round( now );
  1827. }
  1828. });
  1829. toShow
  1830. .hide()
  1831. .animate( this.showProps, {
  1832. duration: duration,
  1833. easing: easing,
  1834. complete: complete,
  1835. step: function( now, fx ) {
  1836. fx.now = Math.round( now );
  1837. if ( fx.prop !== "height" ) {
  1838. adjust += fx.now;
  1839. } else if ( that.options.heightStyle !== "content" ) {
  1840. fx.now = Math.round( total - toHide.outerHeight() - adjust );
  1841. adjust = 0;
  1842. }
  1843. }
  1844. });
  1845. },
  1846. _toggleComplete: function( data ) {
  1847. var toHide = data.oldPanel;
  1848. toHide
  1849. .removeClass( "ui-accordion-content-active" )
  1850. .prev()
  1851. .removeClass( "ui-corner-top" )
  1852. .addClass( "ui-corner-all" );
  1853. // Work around for rendering bug in IE (#5421)
  1854. if ( toHide.length ) {
  1855. toHide.parent()[ 0 ].className = toHide.parent()[ 0 ].className;
  1856. }
  1857. this._trigger( "activate", null, data );
  1858. }
  1859. });
  1860. /*!
  1861. * jQuery UI Menu 1.11.2
  1862. * http://jqueryui.com
  1863. *
  1864. * Copyright 2014 jQuery Foundation and other contributors
  1865. * Released under the MIT license.
  1866. * http://jquery.org/license
  1867. *
  1868. * http://api.jqueryui.com/menu/
  1869. */
  1870. var menu = $.widget( "ui.menu", {
  1871. version: "1.11.2",
  1872. defaultElement: "<ul>",
  1873. delay: 300,
  1874. options: {
  1875. icons: {
  1876. submenu: "ui-icon-carat-1-e"
  1877. },
  1878. items: "> *",
  1879. menus: "ul",
  1880. position: {
  1881. my: "left-1 top",
  1882. at: "right top"
  1883. },
  1884. role: "menu",
  1885. // callbacks
  1886. blur: null,
  1887. focus: null,
  1888. select: null
  1889. },
  1890. _create: function() {
  1891. this.activeMenu = this.element;
  1892. // Flag used to prevent firing of the click handler
  1893. // as the event bubbles up through nested menus
  1894. this.mouseHandled = false;
  1895. this.element
  1896. .uniqueId()
  1897. .addClass( "ui-menu ui-widget ui-widget-content" )
  1898. .toggleClass( "ui-menu-icons", !!this.element.find( ".ui-icon" ).length )
  1899. .attr({
  1900. role: this.options.role,
  1901. tabIndex: 0
  1902. });
  1903. if ( this.options.disabled ) {
  1904. this.element
  1905. .addClass( "ui-state-disabled" )
  1906. .attr( "aria-disabled", "true" );
  1907. }
  1908. this._on({
  1909. // Prevent focus from sticking to links inside menu after clicking
  1910. // them (focus should always stay on UL during navigation).
  1911. "mousedown .ui-menu-item": function( event ) {
  1912. event.preventDefault();
  1913. },
  1914. "click .ui-menu-item": function( event ) {
  1915. var target = $( event.target );
  1916. if ( !this.mouseHandled && target.not( ".ui-state-disabled" ).length ) {
  1917. this.select( event );
  1918. // Only set the mouseHandled flag if the event will bubble, see #9469.
  1919. if ( !event.isPropagationStopped() ) {
  1920. this.mouseHandled = true;
  1921. }
  1922. // Open submenu on click
  1923. if ( target.has( ".ui-menu" ).length ) {
  1924. this.expand( event );
  1925. } else if ( !this.element.is( ":focus" ) && $( this.document[ 0 ].activeElement ).closest( ".ui-menu" ).length ) {
  1926. // Redirect focus to the menu
  1927. this.element.trigger( "focus", [ true ] );
  1928. // If the active item is on the top level, let it stay active.
  1929. // Otherwise, blur the active item since it is no longer visible.
  1930. if ( this.active && this.active.parents( ".ui-menu" ).length === 1 ) {
  1931. clearTimeout( this.timer );
  1932. }
  1933. }
  1934. }
  1935. },
  1936. "mouseenter .ui-menu-item": function( event ) {
  1937. // Ignore mouse events while typeahead is active, see #10458.
  1938. // Prevents focusing the wrong item when typeahead causes a scroll while the mouse
  1939. // is over an item in the menu
  1940. if ( this.previousFilter ) {
  1941. return;
  1942. }
  1943. var target = $( event.currentTarget );
  1944. // Remove ui-state-active class from siblings of the newly focused menu item
  1945. // to avoid a jump caused by adjacent elements both having a class with a border
  1946. target.siblings( ".ui-state-active" ).removeClass( "ui-state-active" );
  1947. this.focus( event, target );
  1948. },
  1949. mouseleave: "collapseAll",
  1950. "mouseleave .ui-menu": "collapseAll",
  1951. focus: function( event, keepActiveItem ) {
  1952. // If there's already an active item, keep it active
  1953. // If not, activate the first item
  1954. var item = this.active || this.element.find( this.options.items ).eq( 0 );
  1955. if ( !keepActiveItem ) {
  1956. this.focus( event, item );
  1957. }
  1958. },
  1959. blur: function( event ) {
  1960. this._delay(function() {
  1961. if ( !$.contains( this.element[0], this.document[0].activeElement ) ) {
  1962. this.collapseAll( event );
  1963. }
  1964. });
  1965. },
  1966. keydown: "_keydown"
  1967. });
  1968. this.refresh();
  1969. // Clicks outside of a menu collapse any open menus
  1970. this._on( this.document, {
  1971. click: function( event ) {
  1972. if ( this._closeOnDocumentClick( event ) ) {
  1973. this.collapseAll( event );
  1974. }
  1975. // Reset the mouseHandled flag
  1976. this.mouseHandled = false;
  1977. }
  1978. });
  1979. },
  1980. _destroy: function() {
  1981. // Destroy (sub)menus
  1982. this.element
  1983. .removeAttr( "aria-activedescendant" )
  1984. .find( ".ui-menu" ).addBack()
  1985. .removeClass( "ui-menu ui-widget ui-widget-content ui-menu-icons ui-front" )
  1986. .removeAttr( "role" )
  1987. .removeAttr( "tabIndex" )
  1988. .removeAttr( "aria-labelledby" )
  1989. .removeAttr( "aria-expanded" )
  1990. .removeAttr( "aria-hidden" )
  1991. .removeAttr( "aria-disabled" )
  1992. .removeUniqueId()
  1993. .show();
  1994. // Destroy menu items
  1995. this.element.find( ".ui-menu-item" )
  1996. .removeClass( "ui-menu-item" )
  1997. .removeAttr( "role" )
  1998. .removeAttr( "aria-disabled" )
  1999. .removeUniqueId()
  2000. .removeClass( "ui-state-hover" )
  2001. .removeAttr( "tabIndex" )
  2002. .removeAttr( "role" )
  2003. .removeAttr( "aria-haspopup" )
  2004. .children().each( function() {
  2005. var elem = $( this );
  2006. if ( elem.data( "ui-menu-submenu-carat" ) ) {
  2007. elem.remove();
  2008. }
  2009. });
  2010. // Destroy menu dividers
  2011. this.element.find( ".ui-menu-divider" ).removeClass( "ui-menu-divider ui-widget-content" );
  2012. },
  2013. _keydown: function( event ) {
  2014. var match, prev, character, skip,
  2015. preventDefault = true;
  2016. switch ( event.keyCode ) {
  2017. case $.ui.keyCode.PAGE_UP:
  2018. this.previousPage( event );
  2019. break;
  2020. case $.ui.keyCode.PAGE_DOWN:
  2021. this.nextPage( event );
  2022. break;
  2023. case $.ui.keyCode.HOME:
  2024. this._move( "first", "first", event );
  2025. break;
  2026. case $.ui.keyCode.END:
  2027. this._move( "last", "last", event );
  2028. break;
  2029. case $.ui.keyCode.UP:
  2030. this.previous( event );
  2031. break;
  2032. case $.ui.keyCode.DOWN:
  2033. this.next( event );
  2034. break;
  2035. case $.ui.keyCode.LEFT:
  2036. this.collapse( event );
  2037. break;
  2038. case $.ui.keyCode.RIGHT:
  2039. if ( this.active && !this.active.is( ".ui-state-disabled" ) ) {
  2040. this.expand( event );
  2041. }
  2042. break;
  2043. case $.ui.keyCode.ENTER:
  2044. case $.ui.keyCode.SPACE:
  2045. this._activate( event );
  2046. break;
  2047. case $.ui.keyCode.ESCAPE:
  2048. this.collapse( event );
  2049. break;
  2050. default:
  2051. preventDefault = false;
  2052. prev = this.previousFilter || "";
  2053. character = String.fromCharCode( event.keyCode );
  2054. skip = false;
  2055. clearTimeout( this.filterTimer );
  2056. if ( character === prev ) {
  2057. skip = true;
  2058. } else {
  2059. character = prev + character;
  2060. }
  2061. match = this._filterMenuItems( character );
  2062. match = skip && match.index( this.active.next() ) !== -1 ?
  2063. this.active.nextAll( ".ui-menu-item" ) :
  2064. match;
  2065. // If no matches on the current filter, reset to the last character pressed
  2066. // to move down the menu to the first item that starts with that character
  2067. if ( !match.length ) {
  2068. character = String.fromCharCode( event.keyCode );
  2069. match = this._filterMenuItems( character );
  2070. }
  2071. if ( match.length ) {
  2072. this.focus( event, match );
  2073. this.previousFilter = character;
  2074. this.filterTimer = this._delay(function() {
  2075. delete this.previousFilter;
  2076. }, 1000 );
  2077. } else {
  2078. delete this.previousFilter;
  2079. }
  2080. }
  2081. if ( preventDefault ) {
  2082. event.preventDefault();
  2083. }
  2084. },
  2085. _activate: function( event ) {
  2086. if ( !this.active.is( ".ui-state-disabled" ) ) {
  2087. if ( this.active.is( "[aria-haspopup='true']" ) ) {
  2088. this.expand( event );
  2089. } else {
  2090. this.select( event );
  2091. }
  2092. }
  2093. },
  2094. refresh: function() {
  2095. var menus, items,
  2096. that = this,
  2097. icon = this.options.icons.submenu,
  2098. submenus = this.element.find( this.options.menus );
  2099. this.element.toggleClass( "ui-menu-icons", !!this.element.find( ".ui-icon" ).length );
  2100. // Initialize nested menus
  2101. submenus.filter( ":not(.ui-menu)" )
  2102. .addClass( "ui-menu ui-widget ui-widget-content ui-front" )
  2103. .hide()
  2104. .attr({
  2105. role: this.options.role,
  2106. "aria-hidden": "true",
  2107. "aria-expanded": "false"
  2108. })
  2109. .each(function() {
  2110. var menu = $( this ),
  2111. item = menu.parent(),
  2112. submenuCarat = $( "<span>" )
  2113. .addClass( "ui-menu-icon ui-icon " + icon )
  2114. .data( "ui-menu-submenu-carat", true );
  2115. item
  2116. .attr( "aria-haspopup", "true" )
  2117. .prepend( submenuCarat );
  2118. menu.attr( "aria-labelledby", item.attr( "id" ) );
  2119. });
  2120. menus = submenus.add( this.element );
  2121. items = menus.find( this.options.items );
  2122. // Initialize menu-items containing spaces and/or dashes only as dividers
  2123. items.not( ".ui-menu-item" ).each(function() {
  2124. var item = $( this );
  2125. if ( that._isDivider( item ) ) {
  2126. item.addClass( "ui-widget-content ui-menu-divider" );
  2127. }
  2128. });
  2129. // Don't refresh list items that are already adapted
  2130. items.not( ".ui-menu-item, .ui-menu-divider" )
  2131. .addClass( "ui-menu-item" )
  2132. .uniqueId()
  2133. .attr({
  2134. tabIndex: -1,
  2135. role: this._itemRole()
  2136. });
  2137. // Add aria-disabled attribute to any disabled menu item
  2138. items.filter( ".ui-state-disabled" ).attr( "aria-disabled", "true" );
  2139. // If the active item has been removed, blur the menu
  2140. if ( this.active && !$.contains( this.element[ 0 ], this.active[ 0 ] ) ) {
  2141. this.blur();
  2142. }
  2143. },
  2144. _itemRole: function() {
  2145. return {
  2146. menu: "menuitem",
  2147. listbox: "option"
  2148. }[ this.options.role ];
  2149. },
  2150. _setOption: function( key, value ) {
  2151. if ( key === "icons" ) {
  2152. this.element.find( ".ui-menu-icon" )
  2153. .removeClass( this.options.icons.submenu )
  2154. .addClass( value.submenu );
  2155. }
  2156. if ( key === "disabled" ) {
  2157. this.element
  2158. .toggleClass( "ui-state-disabled", !!value )
  2159. .attr( "aria-disabled", value );
  2160. }
  2161. this._super( key, value );
  2162. },
  2163. focus: function( event, item ) {
  2164. var nested, focused;
  2165. this.blur( event, event && event.type === "focus" );
  2166. this._scrollIntoView( item );
  2167. this.active = item.first();
  2168. focused = this.active.addClass( "ui-state-focus" ).removeClass( "ui-state-active" );
  2169. // Only update aria-activedescendant if there's a role
  2170. // otherwise we assume focus is managed elsewhere
  2171. if ( this.options.role ) {
  2172. this.element.attr( "aria-activedescendant", focused.attr( "id" ) );
  2173. }
  2174. // Highlight active parent menu item, if any
  2175. this.active
  2176. .parent()
  2177. .closest( ".ui-menu-item" )
  2178. .addClass( "ui-state-active" );
  2179. if ( event && event.type === "keydown" ) {
  2180. this._close();
  2181. } else {
  2182. this.timer = this._delay(function() {
  2183. this._close();
  2184. }, this.delay );
  2185. }
  2186. nested = item.children( ".ui-menu" );
  2187. if ( nested.length && event && ( /^mouse/.test( event.type ) ) ) {
  2188. this._startOpening(nested);
  2189. }
  2190. this.activeMenu = item.parent();
  2191. this._trigger( "focus", event, { item: item } );
  2192. },
  2193. _scrollIntoView: function( item ) {
  2194. var borderTop, paddingTop, offset, scroll, elementHeight, itemHeight;
  2195. if ( this._hasScroll() ) {
  2196. borderTop = parseFloat( $.css( this.activeMenu[0], "borderTopWidth" ) ) || 0;
  2197. paddingTop = parseFloat( $.css( this.activeMenu[0], "paddingTop" ) ) || 0;
  2198. offset = item.offset().top - this.activeMenu.offset().top - borderTop - paddingTop;
  2199. scroll = this.activeMenu.scrollTop();
  2200. elementHeight = this.activeMenu.height();
  2201. itemHeight = item.outerHeight();
  2202. if ( offset < 0 ) {
  2203. this.activeMenu.scrollTop( scroll + offset );
  2204. } else if ( offset + itemHeight > elementHeight ) {
  2205. this.activeMenu.scrollTop( scroll + offset - elementHeight + itemHeight );
  2206. }
  2207. }
  2208. },
  2209. blur: function( event, fromFocus ) {
  2210. if ( !fromFocus ) {
  2211. clearTimeout( this.timer );
  2212. }
  2213. if ( !this.active ) {
  2214. return;
  2215. }
  2216. this.active.removeClass( "ui-state-focus" );
  2217. this.active = null;
  2218. this._trigger( "blur", event, { item: this.active } );
  2219. },
  2220. _startOpening: function( submenu ) {
  2221. clearTimeout( this.timer );
  2222. // Don't open if already open fixes a Firefox bug that caused a .5 pixel
  2223. // shift in the submenu position when mousing over the carat icon
  2224. if ( submenu.attr( "aria-hidden" ) !== "true" ) {
  2225. return;
  2226. }
  2227. this.timer = this._delay(function() {
  2228. this._close();
  2229. this._open( submenu );
  2230. }, this.delay );
  2231. },
  2232. _open: function( submenu ) {
  2233. var position = $.extend({
  2234. of: this.active
  2235. }, this.options.position );
  2236. clearTimeout( this.timer );
  2237. this.element.find( ".ui-menu" ).not( submenu.parents( ".ui-menu" ) )
  2238. .hide()
  2239. .attr( "aria-hidden", "true" );
  2240. submenu
  2241. .show()
  2242. .removeAttr( "aria-hidden" )
  2243. .attr( "aria-expanded", "true" )
  2244. .position( position );
  2245. },
  2246. collapseAll: function( event, all ) {
  2247. clearTimeout( this.timer );
  2248. this.timer = this._delay(function() {
  2249. // If we were passed an event, look for the submenu that contains the event
  2250. var currentMenu = all ? this.element :
  2251. $( event && event.target ).closest( this.element.find( ".ui-menu" ) );
  2252. // If we found no valid submenu ancestor, use the main menu to close all sub menus anyway
  2253. if ( !currentMenu.length ) {
  2254. currentMenu = this.element;
  2255. }
  2256. this._close( currentMenu );
  2257. this.blur( event );
  2258. this.activeMenu = currentMenu;
  2259. }, this.delay );
  2260. },
  2261. // With no arguments, closes the currently active menu - if nothing is active
  2262. // it closes all menus. If passed an argument, it will search for menus BELOW
  2263. _close: function( startMenu ) {
  2264. if ( !startMenu ) {
  2265. startMenu = this.active ? this.active.parent() : this.element;
  2266. }
  2267. startMenu
  2268. .find( ".ui-menu" )
  2269. .hide()
  2270. .attr( "aria-hidden", "true" )
  2271. .attr( "aria-expanded", "false" )
  2272. .end()
  2273. .find( ".ui-state-active" ).not( ".ui-state-focus" )
  2274. .removeClass( "ui-state-active" );
  2275. },
  2276. _closeOnDocumentClick: function( event ) {
  2277. return !$( event.target ).closest( ".ui-menu" ).length;
  2278. },
  2279. _isDivider: function( item ) {
  2280. // Match hyphen, em dash, en dash
  2281. return !/[^\-\u2014\u2013\s]/.test( item.text() );
  2282. },
  2283. collapse: function( event ) {
  2284. var newItem = this.active &&
  2285. this.active.parent().closest( ".ui-menu-item", this.element );
  2286. if ( newItem && newItem.length ) {
  2287. this._close();
  2288. this.focus( event, newItem );
  2289. }
  2290. },
  2291. expand: function( event ) {
  2292. var newItem = this.active &&
  2293. this.active
  2294. .children( ".ui-menu " )
  2295. .find( this.options.items )
  2296. .first();
  2297. if ( newItem && newItem.length ) {
  2298. this._open( newItem.parent() );
  2299. // Delay so Firefox will not hide activedescendant change in expanding submenu from AT
  2300. this._delay(function() {
  2301. this.focus( event, newItem );
  2302. });
  2303. }
  2304. },
  2305. next: function( event ) {
  2306. this._move( "next", "first", event );
  2307. },
  2308. previous: function( event ) {
  2309. this._move( "prev", "last", event );
  2310. },
  2311. isFirstItem: function() {
  2312. return this.active && !this.active.prevAll( ".ui-menu-item" ).length;
  2313. },
  2314. isLastItem: function() {
  2315. return this.active && !this.active.nextAll( ".ui-menu-item" ).length;
  2316. },
  2317. _move: function( direction, filter, event ) {
  2318. var next;
  2319. if ( this.active ) {
  2320. if ( direction === "first" || direction === "last" ) {
  2321. next = this.active
  2322. [ direction === "first" ? "prevAll" : "nextAll" ]( ".ui-menu-item" )
  2323. .eq( -1 );
  2324. } else {
  2325. next = this.active
  2326. [ direction + "All" ]( ".ui-menu-item" )
  2327. .eq( 0 );
  2328. }
  2329. }
  2330. if ( !next || !next.length || !this.active ) {
  2331. next = this.activeMenu.find( this.options.items )[ filter ]();
  2332. }
  2333. this.focus( event, next );
  2334. },
  2335. nextPage: function( event ) {
  2336. var item, base, height;
  2337. if ( !this.active ) {
  2338. this.next( event );
  2339. return;
  2340. }
  2341. if ( this.isLastItem() ) {
  2342. return;
  2343. }
  2344. if ( this._hasScroll() ) {
  2345. base = this.active.offset().top;
  2346. height = this.element.height();
  2347. this.active.nextAll( ".ui-menu-item" ).each(function() {
  2348. item = $( this );
  2349. return item.offset().top - base - height < 0;
  2350. });
  2351. this.focus( event, item );
  2352. } else {
  2353. this.focus( event, this.activeMenu.find( this.options.items )
  2354. [ !this.active ? "first" : "last" ]() );
  2355. }
  2356. },
  2357. previousPage: function( event ) {
  2358. var item, base, height;
  2359. if ( !this.active ) {
  2360. this.next( event );
  2361. return;
  2362. }
  2363. if ( this.isFirstItem() ) {
  2364. return;
  2365. }
  2366. if ( this._hasScroll() ) {
  2367. base = this.active.offset().top;
  2368. height = this.element.height();
  2369. this.active.prevAll( ".ui-menu-item" ).each(function() {
  2370. item = $( this );
  2371. return item.offset().top - base + height > 0;
  2372. });
  2373. this.focus( event, item );
  2374. } else {
  2375. this.focus( event, this.activeMenu.find( this.options.items ).first() );
  2376. }
  2377. },
  2378. _hasScroll: function() {
  2379. return this.element.outerHeight() < this.element.prop( "scrollHeight" );
  2380. },
  2381. select: function( event ) {
  2382. // TODO: It should never be possible to not have an active item at this
  2383. // point, but the tests don't trigger mouseenter before click.
  2384. this.active = this.active || $( event.target ).closest( ".ui-menu-item" );
  2385. var ui = { item: this.active };
  2386. if ( !this.active.has( ".ui-menu" ).length ) {
  2387. this.collapseAll( event, true );
  2388. }
  2389. this._trigger( "select", event, ui );
  2390. },
  2391. _filterMenuItems: function(character) {
  2392. var escapedCharacter = character.replace( /[\-\[\]{}()*+?.,\\\^$|#\s]/g, "\\$&" ),
  2393. regex = new RegExp( "^" + escapedCharacter, "i" );
  2394. return this.activeMenu
  2395. .find( this.options.items )
  2396. // Only match on items, not dividers or other content (#10571)
  2397. .filter( ".ui-menu-item" )
  2398. .filter(function() {
  2399. return regex.test( $.trim( $( this ).text() ) );
  2400. });
  2401. }
  2402. });
  2403. /*!
  2404. * jQuery UI Autocomplete 1.11.2
  2405. * http://jqueryui.com
  2406. *
  2407. * Copyright 2014 jQuery Foundation and other contributors
  2408. * Released under the MIT license.
  2409. * http://jquery.org/license
  2410. *
  2411. * http://api.jqueryui.com/autocomplete/
  2412. */
  2413. $.widget( "ui.autocomplete", {
  2414. version: "1.11.2",
  2415. defaultElement: "<input>",
  2416. options: {
  2417. appendTo: null,
  2418. autoFocus: false,
  2419. delay: 300,
  2420. minLength: 1,
  2421. position: {
  2422. my: "left top",
  2423. at: "left bottom",
  2424. collision: "none"
  2425. },
  2426. source: null,
  2427. // callbacks
  2428. change: null,
  2429. close: null,
  2430. focus: null,
  2431. open: null,
  2432. response: null,
  2433. search: null,
  2434. select: null
  2435. },
  2436. requestIndex: 0,
  2437. pending: 0,
  2438. _create: function() {
  2439. // Some browsers only repeat keydown events, not keypress events,
  2440. // so we use the suppressKeyPress flag to determine if we've already
  2441. // handled the keydown event. #7269
  2442. // Unfortunately the code for & in keypress is the same as the up arrow,
  2443. // so we use the suppressKeyPressRepeat flag to avoid handling keypress
  2444. // events when we know the keydown event was used to modify the
  2445. // search term. #7799
  2446. var suppressKeyPress, suppressKeyPressRepeat, suppressInput,
  2447. nodeName = this.element[ 0 ].nodeName.toLowerCase(),
  2448. isTextarea = nodeName === "textarea",
  2449. isInput = nodeName === "input";
  2450. this.isMultiLine =
  2451. // Textareas are always multi-line
  2452. isTextarea ? true :
  2453. // Inputs are always single-line, even if inside a contentEditable element
  2454. // IE also treats inputs as contentEditable
  2455. isInput ? false :
  2456. // All other element types are determined by whether or not they're contentEditable
  2457. this.element.prop( "isContentEditable" );
  2458. this.valueMethod = this.element[ isTextarea || isInput ? "val" : "text" ];
  2459. this.isNewMenu = true;
  2460. this.element
  2461. .addClass( "ui-autocomplete-input" )
  2462. .attr( "autocomplete", "off" );
  2463. this._on( this.element, {
  2464. keydown: function( event ) {
  2465. if ( this.element.prop( "readOnly" ) ) {
  2466. suppressKeyPress = true;
  2467. suppressInput = true;
  2468. suppressKeyPressRepeat = true;
  2469. return;
  2470. }
  2471. suppressKeyPress = false;
  2472. suppressInput = false;
  2473. suppressKeyPressRepeat = false;
  2474. var keyCode = $.ui.keyCode;
  2475. switch ( event.keyCode ) {
  2476. case keyCode.PAGE_UP:
  2477. suppressKeyPress = true;
  2478. this._move( "previousPage", event );
  2479. break;
  2480. case keyCode.PAGE_DOWN:
  2481. suppressKeyPress = true;
  2482. this._move( "nextPage", event );
  2483. break;
  2484. case keyCode.UP:
  2485. suppressKeyPress = true;
  2486. this._keyEvent( "previous", event );
  2487. break;
  2488. case keyCode.DOWN:
  2489. suppressKeyPress = true;
  2490. this._keyEvent( "next", event );
  2491. break;
  2492. case keyCode.ENTER:
  2493. // when menu is open and has focus
  2494. if ( this.menu.active ) {
  2495. // #6055 - Opera still allows the keypress to occur
  2496. // which causes forms to submit
  2497. suppressKeyPress = true;
  2498. event.preventDefault();
  2499. this.menu.select( event );
  2500. }
  2501. break;
  2502. case keyCode.TAB:
  2503. if ( this.menu.active ) {
  2504. this.menu.select( event );
  2505. }
  2506. break;
  2507. case keyCode.ESCAPE:
  2508. if ( this.menu.element.is( ":visible" ) ) {
  2509. if ( !this.isMultiLine ) {
  2510. this._value( this.term );
  2511. }
  2512. this.close( event );
  2513. // Different browsers have different default behavior for escape
  2514. // Single press can mean undo or clear
  2515. // Double press in IE means clear the whole form
  2516. event.preventDefault();
  2517. }
  2518. break;
  2519. default:
  2520. suppressKeyPressRepeat = true;
  2521. // search timeout should be triggered before the input value is changed
  2522. this._searchTimeout( event );
  2523. break;
  2524. }
  2525. },
  2526. keypress: function( event ) {
  2527. if ( suppressKeyPress ) {
  2528. suppressKeyPress = false;
  2529. if ( !this.isMultiLine || this.menu.element.is( ":visible" ) ) {
  2530. event.preventDefault();
  2531. }
  2532. return;
  2533. }
  2534. if ( suppressKeyPressRepeat ) {
  2535. return;
  2536. }
  2537. // replicate some key handlers to allow them to repeat in Firefox and Opera
  2538. var keyCode = $.ui.keyCode;
  2539. switch ( event.keyCode ) {
  2540. case keyCode.PAGE_UP:
  2541. this._move( "previousPage", event );
  2542. break;
  2543. case keyCode.PAGE_DOWN:
  2544. this._move( "nextPage", event );
  2545. break;
  2546. case keyCode.UP:
  2547. this._keyEvent( "previous", event );
  2548. break;
  2549. case keyCode.DOWN:
  2550. this._keyEvent( "next", event );
  2551. break;
  2552. }
  2553. },
  2554. input: function( event ) {
  2555. if ( suppressInput ) {
  2556. suppressInput = false;
  2557. event.preventDefault();
  2558. return;
  2559. }
  2560. this._searchTimeout( event );
  2561. },
  2562. focus: function() {
  2563. this.selectedItem = null;
  2564. this.previous = this._value();
  2565. },
  2566. blur: function( event ) {
  2567. if ( this.cancelBlur ) {
  2568. delete this.cancelBlur;
  2569. return;
  2570. }
  2571. clearTimeout( this.searching );
  2572. this.close( event );
  2573. this._change( event );
  2574. }
  2575. });
  2576. this._initSource();
  2577. this.menu = $( "<ul>" )
  2578. .addClass( "ui-autocomplete ui-front" )
  2579. .appendTo( this._appendTo() )
  2580. .menu({
  2581. // disable ARIA support, the live region takes care of that
  2582. role: null
  2583. })
  2584. .hide()
  2585. .menu( "instance" );
  2586. this._on( this.menu.element, {
  2587. mousedown: function( event ) {
  2588. // prevent moving focus out of the text field
  2589. event.preventDefault();
  2590. // IE doesn't prevent moving focus even with event.preventDefault()
  2591. // so we set a flag to know when we should ignore the blur event
  2592. this.cancelBlur = true;
  2593. this._delay(function() {
  2594. delete this.cancelBlur;
  2595. });
  2596. // clicking on the scrollbar causes focus to shift to the body
  2597. // but we can't detect a mouseup or a click immediately afterward
  2598. // so we have to track the next mousedown and close the menu if
  2599. // the user clicks somewhere outside of the autocomplete
  2600. var menuElement = this.menu.element[ 0 ];
  2601. if ( !$( event.target ).closest( ".ui-menu-item" ).length ) {
  2602. this._delay(function() {
  2603. var that = this;
  2604. this.document.one( "mousedown", function( event ) {
  2605. if ( event.target !== that.element[ 0 ] &&
  2606. event.target !== menuElement &&
  2607. !$.contains( menuElement, event.target ) ) {
  2608. that.close();
  2609. }
  2610. });
  2611. });
  2612. }
  2613. },
  2614. menufocus: function( event, ui ) {
  2615. var label, item;
  2616. // support: Firefox
  2617. // Prevent accidental activation of menu items in Firefox (#7024 #9118)
  2618. if ( this.isNewMenu ) {
  2619. this.isNewMenu = false;
  2620. if ( event.originalEvent && /^mouse/.test( event.originalEvent.type ) ) {
  2621. this.menu.blur();
  2622. this.document.one( "mousemove", function() {
  2623. $( event.target ).trigger( event.originalEvent );
  2624. });
  2625. return;
  2626. }
  2627. }
  2628. item = ui.item.data( "ui-autocomplete-item" );
  2629. if ( false !== this._trigger( "focus", event, { item: item } ) ) {
  2630. // use value to match what will end up in the input, if it was a key event
  2631. if ( event.originalEvent && /^key/.test( event.originalEvent.type ) ) {
  2632. this._value( item.value );
  2633. }
  2634. }
  2635. // Announce the value in the liveRegion
  2636. label = ui.item.attr( "aria-label" ) || item.value;
  2637. if ( label && $.trim( label ).length ) {
  2638. this.liveRegion.children().hide();
  2639. $( "<div>" ).text( label ).appendTo( this.liveRegion );
  2640. }
  2641. },
  2642. menuselect: function( event, ui ) {
  2643. var item = ui.item.data( "ui-autocomplete-item" ),
  2644. previous = this.previous;
  2645. // only trigger when focus was lost (click on menu)
  2646. if ( this.element[ 0 ] !== this.document[ 0 ].activeElement ) {
  2647. this.element.focus();
  2648. this.previous = previous;
  2649. // #6109 - IE triggers two focus events and the second
  2650. // is asynchronous, so we need to reset the previous
  2651. // term synchronously and asynchronously :-(
  2652. this._delay(function() {
  2653. this.previous = previous;
  2654. this.selectedItem = item;
  2655. });
  2656. }
  2657. if ( false !== this._trigger( "select", event, { item: item } ) ) {
  2658. this._value( item.value );
  2659. }
  2660. // reset the term after the select event
  2661. // this allows custom select handling to work properly
  2662. this.term = this._value();
  2663. this.close( event );
  2664. this.selectedItem = item;
  2665. }
  2666. });
  2667. this.liveRegion = $( "<span>", {
  2668. role: "status",
  2669. "aria-live": "assertive",
  2670. "aria-relevant": "additions"
  2671. })
  2672. .addClass( "ui-helper-hidden-accessible" )
  2673. .appendTo( this.document[ 0 ].body );
  2674. // turning off autocomplete prevents the browser from remembering the
  2675. // value when navigating through history, so we re-enable autocomplete
  2676. // if the page is unloaded before the widget is destroyed. #7790
  2677. this._on( this.window, {
  2678. beforeunload: function() {
  2679. this.element.removeAttr( "autocomplete" );
  2680. }
  2681. });
  2682. },
  2683. _destroy: function() {
  2684. clearTimeout( this.searching );
  2685. this.element
  2686. .removeClass( "ui-autocomplete-input" )
  2687. .removeAttr( "autocomplete" );
  2688. this.menu.element.remove();
  2689. this.liveRegion.remove();
  2690. },
  2691. _setOption: function( key, value ) {
  2692. this._super( key, value );
  2693. if ( key === "source" ) {
  2694. this._initSource();
  2695. }
  2696. if ( key === "appendTo" ) {
  2697. this.menu.element.appendTo( this._appendTo() );
  2698. }
  2699. if ( key === "disabled" && value && this.xhr ) {
  2700. this.xhr.abort();
  2701. }
  2702. },
  2703. _appendTo: function() {
  2704. var element = this.options.appendTo;
  2705. if ( element ) {
  2706. element = element.jquery || element.nodeType ?
  2707. $( element ) :
  2708. this.document.find( element ).eq( 0 );
  2709. }
  2710. if ( !element || !element[ 0 ] ) {
  2711. element = this.element.closest( ".ui-front" );
  2712. }
  2713. if ( !element.length ) {
  2714. element = this.document[ 0 ].body;
  2715. }
  2716. return element;
  2717. },
  2718. _initSource: function() {
  2719. var array, url,
  2720. that = this;
  2721. if ( $.isArray( this.options.source ) ) {
  2722. array = this.options.source;
  2723. this.source = function( request, response ) {
  2724. response( $.ui.autocomplete.filter( array, request.term ) );
  2725. };
  2726. } else if ( typeof this.options.source === "string" ) {
  2727. url = this.options.source;
  2728. this.source = function( request, response ) {
  2729. if ( that.xhr ) {
  2730. that.xhr.abort();
  2731. }
  2732. that.xhr = $.ajax({
  2733. url: url,
  2734. data: request,
  2735. dataType: "json",
  2736. success: function( data ) {
  2737. response( data );
  2738. },
  2739. error: function() {
  2740. response([]);
  2741. }
  2742. });
  2743. };
  2744. } else {
  2745. this.source = this.options.source;
  2746. }
  2747. },
  2748. _searchTimeout: function( event ) {
  2749. clearTimeout( this.searching );
  2750. this.searching = this._delay(function() {
  2751. // Search if the value has changed, or if the user retypes the same value (see #7434)
  2752. var equalValues = this.term === this._value(),
  2753. menuVisible = this.menu.element.is( ":visible" ),
  2754. modifierKey = event.altKey || event.ctrlKey || event.metaKey || event.shiftKey;
  2755. if ( !equalValues || ( equalValues && !menuVisible && !modifierKey ) ) {
  2756. this.selectedItem = null;
  2757. this.search( null, event );
  2758. }
  2759. }, this.options.delay );
  2760. },
  2761. search: function( value, event ) {
  2762. value = value != null ? value : this._value();
  2763. // always save the actual value, not the one passed as an argument
  2764. this.term = this._value();
  2765. if ( value.length < this.options.minLength ) {
  2766. return this.close( event );
  2767. }
  2768. if ( this._trigger( "search", event ) === false ) {
  2769. return;
  2770. }
  2771. return this._search( value );
  2772. },
  2773. _search: function( value ) {
  2774. this.pending++;
  2775. this.element.addClass( "ui-autocomplete-loading" );
  2776. this.cancelSearch = false;
  2777. this.source( { term: value }, this._response() );
  2778. },
  2779. _response: function() {
  2780. var index = ++this.requestIndex;
  2781. return $.proxy(function( content ) {
  2782. if ( index === this.requestIndex ) {
  2783. this.__response( content );
  2784. }
  2785. this.pending--;
  2786. if ( !this.pending ) {
  2787. this.element.removeClass( "ui-autocomplete-loading" );
  2788. }
  2789. }, this );
  2790. },
  2791. __response: function( content ) {
  2792. if ( content ) {
  2793. content = this._normalize( content );
  2794. }
  2795. this._trigger( "response", null, { content: content } );
  2796. if ( !this.options.disabled && content && content.length && !this.cancelSearch ) {
  2797. this._suggest( content );
  2798. this._trigger( "open" );
  2799. } else {
  2800. // use ._close() instead of .close() so we don't cancel future searches
  2801. this._close();
  2802. }
  2803. },
  2804. close: function( event ) {
  2805. this.cancelSearch = true;
  2806. this._close( event );
  2807. },
  2808. _close: function( event ) {
  2809. if ( this.menu.element.is( ":visible" ) ) {
  2810. this.menu.element.hide();
  2811. this.menu.blur();
  2812. this.isNewMenu = true;
  2813. this._trigger( "close", event );
  2814. }
  2815. },
  2816. _change: function( event ) {
  2817. if ( this.previous !== this._value() ) {
  2818. this._trigger( "change", event, { item: this.selectedItem } );
  2819. }
  2820. },
  2821. _normalize: function( items ) {
  2822. // assume all items have the right format when the first item is complete
  2823. if ( items.length && items[ 0 ].label && items[ 0 ].value ) {
  2824. return items;
  2825. }
  2826. return $.map( items, function( item ) {
  2827. if ( typeof item === "string" ) {
  2828. return {
  2829. label: item,
  2830. value: item
  2831. };
  2832. }
  2833. return $.extend( {}, item, {
  2834. label: item.label || item.value,
  2835. value: item.value || item.label
  2836. });
  2837. });
  2838. },
  2839. _suggest: function( items ) {
  2840. var ul = this.menu.element.empty();
  2841. this._renderMenu( ul, items );
  2842. this.isNewMenu = true;
  2843. this.menu.refresh();
  2844. // size and position menu
  2845. ul.show();
  2846. this._resizeMenu();
  2847. ul.position( $.extend({
  2848. of: this.element
  2849. }, this.options.position ) );
  2850. if ( this.options.autoFocus ) {
  2851. this.menu.next();
  2852. }
  2853. },
  2854. _resizeMenu: function() {
  2855. var ul = this.menu.element;
  2856. ul.outerWidth( Math.max(
  2857. // Firefox wraps long text (possibly a rounding bug)
  2858. // so we add 1px to avoid the wrapping (#7513)
  2859. ul.width( "" ).outerWidth() + 1,
  2860. this.element.outerWidth()
  2861. ) );
  2862. },
  2863. _renderMenu: function( ul, items ) {
  2864. var that = this;
  2865. $.each( items, function( index, item ) {
  2866. that._renderItemData( ul, item );
  2867. });
  2868. },
  2869. _renderItemData: function( ul, item ) {
  2870. return this._renderItem( ul, item ).data( "ui-autocomplete-item", item );
  2871. },
  2872. _renderItem: function( ul, item ) {
  2873. return $( "<li>" ).text( item.label ).appendTo( ul );
  2874. },
  2875. _move: function( direction, event ) {
  2876. if ( !this.menu.element.is( ":visible" ) ) {
  2877. this.search( null, event );
  2878. return;
  2879. }
  2880. if ( this.menu.isFirstItem() && /^previous/.test( direction ) ||
  2881. this.menu.isLastItem() && /^next/.test( direction ) ) {
  2882. if ( !this.isMultiLine ) {
  2883. this._value( this.term );
  2884. }
  2885. this.menu.blur();
  2886. return;
  2887. }
  2888. this.menu[ direction ]( event );
  2889. },
  2890. widget: function() {
  2891. return this.menu.element;
  2892. },
  2893. _value: function() {
  2894. return this.valueMethod.apply( this.element, arguments );
  2895. },
  2896. _keyEvent: function( keyEvent, event ) {
  2897. if ( !this.isMultiLine || this.menu.element.is( ":visible" ) ) {
  2898. this._move( keyEvent, event );
  2899. // prevents moving cursor to beginning/end of the text field in some browsers
  2900. event.preventDefault();
  2901. }
  2902. }
  2903. });
  2904. $.extend( $.ui.autocomplete, {
  2905. escapeRegex: function( value ) {
  2906. return value.replace( /[\-\[\]{}()*+?.,\\\^$|#\s]/g, "\\$&" );
  2907. },
  2908. filter: function( array, term ) {
  2909. var matcher = new RegExp( $.ui.autocomplete.escapeRegex( term ), "i" );
  2910. return $.grep( array, function( value ) {
  2911. return matcher.test( value.label || value.value || value );
  2912. });
  2913. }
  2914. });
  2915. // live region extension, adding a `messages` option
  2916. // NOTE: This is an experimental API. We are still investigating
  2917. // a full solution for string manipulation and internationalization.
  2918. $.widget( "ui.autocomplete", $.ui.autocomplete, {
  2919. options: {
  2920. messages: {
  2921. noResults: "No search results.",
  2922. results: function( amount ) {
  2923. return amount + ( amount > 1 ? " results are" : " result is" ) +
  2924. " available, use up and down arrow keys to navigate.";
  2925. }
  2926. }
  2927. },
  2928. __response: function( content ) {
  2929. var message;
  2930. this._superApply( arguments );
  2931. if ( this.options.disabled || this.cancelSearch ) {
  2932. return;
  2933. }
  2934. if ( content && content.length ) {
  2935. message = this.options.messages.results( content.length );
  2936. } else {
  2937. message = this.options.messages.noResults;
  2938. }
  2939. this.liveRegion.children().hide();
  2940. $( "<div>" ).text( message ).appendTo( this.liveRegion );
  2941. }
  2942. });
  2943. var autocomplete = $.ui.autocomplete;
  2944. /*!
  2945. * jQuery UI Button 1.11.2
  2946. * http://jqueryui.com
  2947. *
  2948. * Copyright 2014 jQuery Foundation and other contributors
  2949. * Released under the MIT license.
  2950. * http://jquery.org/license
  2951. *
  2952. * http://api.jqueryui.com/button/
  2953. */
  2954. var lastActive,
  2955. baseClasses = "ui-button ui-widget ui-state-default ui-corner-all",
  2956. 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",
  2957. formResetHandler = function() {
  2958. var form = $( this );
  2959. setTimeout(function() {
  2960. form.find( ":ui-button" ).button( "refresh" );
  2961. }, 1 );
  2962. },
  2963. radioGroup = function( radio ) {
  2964. var name = radio.name,
  2965. form = radio.form,
  2966. radios = $( [] );
  2967. if ( name ) {
  2968. name = name.replace( /'/g, "\\'" );
  2969. if ( form ) {
  2970. radios = $( form ).find( "[name='" + name + "'][type=radio]" );
  2971. } else {
  2972. radios = $( "[name='" + name + "'][type=radio]", radio.ownerDocument )
  2973. .filter(function() {
  2974. return !this.form;
  2975. });
  2976. }
  2977. }
  2978. return radios;
  2979. };
  2980. $.widget( "ui.button", {
  2981. version: "1.11.2",
  2982. defaultElement: "<button>",
  2983. options: {
  2984. disabled: null,
  2985. text: true,
  2986. label: null,
  2987. icons: {
  2988. primary: null,
  2989. secondary: null
  2990. }
  2991. },
  2992. _create: function() {
  2993. this.element.closest( "form" )
  2994. .unbind( "reset" + this.eventNamespace )
  2995. .bind( "reset" + this.eventNamespace, formResetHandler );
  2996. if ( typeof this.options.disabled !== "boolean" ) {
  2997. this.options.disabled = !!this.element.prop( "disabled" );
  2998. } else {
  2999. this.element.prop( "disabled", this.options.disabled );
  3000. }
  3001. this._determineButtonType();
  3002. this.hasTitle = !!this.buttonElement.attr( "title" );
  3003. var that = this,
  3004. options = this.options,
  3005. toggleButton = this.type === "checkbox" || this.type === "radio",
  3006. activeClass = !toggleButton ? "ui-state-active" : "";
  3007. if ( options.label === null ) {
  3008. options.label = (this.type === "input" ? this.buttonElement.val() : this.buttonElement.html());
  3009. }
  3010. this._hoverable( this.buttonElement );
  3011. this.buttonElement
  3012. .addClass( baseClasses )
  3013. .attr( "role", "button" )
  3014. .bind( "mouseenter" + this.eventNamespace, function() {
  3015. if ( options.disabled ) {
  3016. return;
  3017. }
  3018. if ( this === lastActive ) {
  3019. $( this ).addClass( "ui-state-active" );
  3020. }
  3021. })
  3022. .bind( "mouseleave" + this.eventNamespace, function() {
  3023. if ( options.disabled ) {
  3024. return;
  3025. }
  3026. $( this ).removeClass( activeClass );
  3027. })
  3028. .bind( "click" + this.eventNamespace, function( event ) {
  3029. if ( options.disabled ) {
  3030. event.preventDefault();
  3031. event.stopImmediatePropagation();
  3032. }
  3033. });
  3034. // Can't use _focusable() because the element that receives focus
  3035. // and the element that gets the ui-state-focus class are different
  3036. this._on({
  3037. focus: function() {
  3038. this.buttonElement.addClass( "ui-state-focus" );
  3039. },
  3040. blur: function() {
  3041. this.buttonElement.removeClass( "ui-state-focus" );
  3042. }
  3043. });
  3044. if ( toggleButton ) {
  3045. this.element.bind( "change" + this.eventNamespace, function() {
  3046. that.refresh();
  3047. });
  3048. }
  3049. if ( this.type === "checkbox" ) {
  3050. this.buttonElement.bind( "click" + this.eventNamespace, function() {
  3051. if ( options.disabled ) {
  3052. return false;
  3053. }
  3054. });
  3055. } else if ( this.type === "radio" ) {
  3056. this.buttonElement.bind( "click" + this.eventNamespace, function() {
  3057. if ( options.disabled ) {
  3058. return false;
  3059. }
  3060. $( this ).addClass( "ui-state-active" );
  3061. that.buttonElement.attr( "aria-pressed", "true" );
  3062. var radio = that.element[ 0 ];
  3063. radioGroup( radio )
  3064. .not( radio )
  3065. .map(function() {
  3066. return $( this ).button( "widget" )[ 0 ];
  3067. })
  3068. .removeClass( "ui-state-active" )
  3069. .attr( "aria-pressed", "false" );
  3070. });
  3071. } else {
  3072. this.buttonElement
  3073. .bind( "mousedown" + this.eventNamespace, function() {
  3074. if ( options.disabled ) {
  3075. return false;
  3076. }
  3077. $( this ).addClass( "ui-state-active" );
  3078. lastActive = this;
  3079. that.document.one( "mouseup", function() {
  3080. lastActive = null;
  3081. });
  3082. })
  3083. .bind( "mouseup" + this.eventNamespace, function() {
  3084. if ( options.disabled ) {
  3085. return false;
  3086. }
  3087. $( this ).removeClass( "ui-state-active" );
  3088. })
  3089. .bind( "keydown" + this.eventNamespace, function(event) {
  3090. if ( options.disabled ) {
  3091. return false;
  3092. }
  3093. if ( event.keyCode === $.ui.keyCode.SPACE || event.keyCode === $.ui.keyCode.ENTER ) {
  3094. $( this ).addClass( "ui-state-active" );
  3095. }
  3096. })
  3097. // see #8559, we bind to blur here in case the button element loses
  3098. // focus between keydown and keyup, it would be left in an "active" state
  3099. .bind( "keyup" + this.eventNamespace + " blur" + this.eventNamespace, function() {
  3100. $( this ).removeClass( "ui-state-active" );
  3101. });
  3102. if ( this.buttonElement.is("a") ) {
  3103. this.buttonElement.keyup(function(event) {
  3104. if ( event.keyCode === $.ui.keyCode.SPACE ) {
  3105. // TODO pass through original event correctly (just as 2nd argument doesn't work)
  3106. $( this ).click();
  3107. }
  3108. });
  3109. }
  3110. }
  3111. this._setOption( "disabled", options.disabled );
  3112. this._resetButton();
  3113. },
  3114. _determineButtonType: function() {
  3115. var ancestor, labelSelector, checked;
  3116. if ( this.element.is("[type=checkbox]") ) {
  3117. this.type = "checkbox";
  3118. } else if ( this.element.is("[type=radio]") ) {
  3119. this.type = "radio";
  3120. } else if ( this.element.is("input") ) {
  3121. this.type = "input";
  3122. } else {
  3123. this.type = "button";
  3124. }
  3125. if ( this.type === "checkbox" || this.type === "radio" ) {
  3126. // we don't search against the document in case the element
  3127. // is disconnected from the DOM
  3128. ancestor = this.element.parents().last();
  3129. labelSelector = "label[for='" + this.element.attr("id") + "']";
  3130. this.buttonElement = ancestor.find( labelSelector );
  3131. if ( !this.buttonElement.length ) {
  3132. ancestor = ancestor.length ? ancestor.siblings() : this.element.siblings();
  3133. this.buttonElement = ancestor.filter( labelSelector );
  3134. if ( !this.buttonElement.length ) {
  3135. this.buttonElement = ancestor.find( labelSelector );
  3136. }
  3137. }
  3138. this.element.addClass( "ui-helper-hidden-accessible" );
  3139. checked = this.element.is( ":checked" );
  3140. if ( checked ) {
  3141. this.buttonElement.addClass( "ui-state-active" );
  3142. }
  3143. this.buttonElement.prop( "aria-pressed", checked );
  3144. } else {
  3145. this.buttonElement = this.element;
  3146. }
  3147. },
  3148. widget: function() {
  3149. return this.buttonElement;
  3150. },
  3151. _destroy: function() {
  3152. this.element
  3153. .removeClass( "ui-helper-hidden-accessible" );
  3154. this.buttonElement
  3155. .removeClass( baseClasses + " ui-state-active " + typeClasses )
  3156. .removeAttr( "role" )
  3157. .removeAttr( "aria-pressed" )
  3158. .html( this.buttonElement.find(".ui-button-text").html() );
  3159. if ( !this.hasTitle ) {
  3160. this.buttonElement.removeAttr( "title" );
  3161. }
  3162. },
  3163. _setOption: function( key, value ) {
  3164. this._super( key, value );
  3165. if ( key === "disabled" ) {
  3166. this.widget().toggleClass( "ui-state-disabled", !!value );
  3167. this.element.prop( "disabled", !!value );
  3168. if ( value ) {
  3169. if ( this.type === "checkbox" || this.type === "radio" ) {
  3170. this.buttonElement.removeClass( "ui-state-focus" );
  3171. } else {
  3172. this.buttonElement.removeClass( "ui-state-focus ui-state-active" );
  3173. }
  3174. }
  3175. return;
  3176. }
  3177. this._resetButton();
  3178. },
  3179. refresh: function() {
  3180. //See #8237 & #8828
  3181. var isDisabled = this.element.is( "input, button" ) ? this.element.is( ":disabled" ) : this.element.hasClass( "ui-button-disabled" );
  3182. if ( isDisabled !== this.options.disabled ) {
  3183. this._setOption( "disabled", isDisabled );
  3184. }
  3185. if ( this.type === "radio" ) {
  3186. radioGroup( this.element[0] ).each(function() {
  3187. if ( $( this ).is( ":checked" ) ) {
  3188. $( this ).button( "widget" )
  3189. .addClass( "ui-state-active" )
  3190. .attr( "aria-pressed", "true" );
  3191. } else {
  3192. $( this ).button( "widget" )
  3193. .removeClass( "ui-state-active" )
  3194. .attr( "aria-pressed", "false" );
  3195. }
  3196. });
  3197. } else if ( this.type === "checkbox" ) {
  3198. if ( this.element.is( ":checked" ) ) {
  3199. this.buttonElement
  3200. .addClass( "ui-state-active" )
  3201. .attr( "aria-pressed", "true" );
  3202. } else {
  3203. this.buttonElement
  3204. .removeClass( "ui-state-active" )
  3205. .attr( "aria-pressed", "false" );
  3206. }
  3207. }
  3208. },
  3209. _resetButton: function() {
  3210. if ( this.type === "input" ) {
  3211. if ( this.options.label ) {
  3212. this.element.val( this.options.label );
  3213. }
  3214. return;
  3215. }
  3216. var buttonElement = this.buttonElement.removeClass( typeClasses ),
  3217. buttonText = $( "<span></span>", this.document[0] )
  3218. .addClass( "ui-button-text" )
  3219. .html( this.options.label )
  3220. .appendTo( buttonElement.empty() )
  3221. .text(),
  3222. icons = this.options.icons,
  3223. multipleIcons = icons.primary && icons.secondary,
  3224. buttonClasses = [];
  3225. if ( icons.primary || icons.secondary ) {
  3226. if ( this.options.text ) {
  3227. buttonClasses.push( "ui-button-text-icon" + ( multipleIcons ? "s" : ( icons.primary ? "-primary" : "-secondary" ) ) );
  3228. }
  3229. if ( icons.primary ) {
  3230. buttonElement.prepend( "<span class='ui-button-icon-primary ui-icon " + icons.primary + "'></span>" );
  3231. }
  3232. if ( icons.secondary ) {
  3233. buttonElement.append( "<span class='ui-button-icon-secondary ui-icon " + icons.secondary + "'></span>" );
  3234. }
  3235. if ( !this.options.text ) {
  3236. buttonClasses.push( multipleIcons ? "ui-button-icons-only" : "ui-button-icon-only" );
  3237. if ( !this.hasTitle ) {
  3238. buttonElement.attr( "title", $.trim( buttonText ) );
  3239. }
  3240. }
  3241. } else {
  3242. buttonClasses.push( "ui-button-text-only" );
  3243. }
  3244. buttonElement.addClass( buttonClasses.join( " " ) );
  3245. }
  3246. });
  3247. $.widget( "ui.buttonset", {
  3248. version: "1.11.2",
  3249. options: {
  3250. items: "button, input[type=button], input[type=submit], input[type=reset], input[type=checkbox], input[type=radio], a, :data(ui-button)"
  3251. },
  3252. _create: function() {
  3253. this.element.addClass( "ui-buttonset" );
  3254. },
  3255. _init: function() {
  3256. this.refresh();
  3257. },
  3258. _setOption: function( key, value ) {
  3259. if ( key === "disabled" ) {
  3260. this.buttons.button( "option", key, value );
  3261. }
  3262. this._super( key, value );
  3263. },
  3264. refresh: function() {
  3265. var rtl = this.element.css( "direction" ) === "rtl",
  3266. allButtons = this.element.find( this.options.items ),
  3267. existingButtons = allButtons.filter( ":ui-button" );
  3268. // Initialize new buttons
  3269. allButtons.not( ":ui-button" ).button();
  3270. // Refresh existing buttons
  3271. existingButtons.button( "refresh" );
  3272. this.buttons = allButtons
  3273. .map(function() {
  3274. return $( this ).button( "widget" )[ 0 ];
  3275. })
  3276. .removeClass( "ui-corner-all ui-corner-left ui-corner-right" )
  3277. .filter( ":first" )
  3278. .addClass( rtl ? "ui-corner-right" : "ui-corner-left" )
  3279. .end()
  3280. .filter( ":last" )
  3281. .addClass( rtl ? "ui-corner-left" : "ui-corner-right" )
  3282. .end()
  3283. .end();
  3284. },
  3285. _destroy: function() {
  3286. this.element.removeClass( "ui-buttonset" );
  3287. this.buttons
  3288. .map(function() {
  3289. return $( this ).button( "widget" )[ 0 ];
  3290. })
  3291. .removeClass( "ui-corner-left ui-corner-right" )
  3292. .end()
  3293. .button( "destroy" );
  3294. }
  3295. });
  3296. var button = $.ui.button;
  3297. /*!
  3298. * jQuery UI Datepicker 1.11.2
  3299. * http://jqueryui.com
  3300. *
  3301. * Copyright 2014 jQuery Foundation and other contributors
  3302. * Released under the MIT license.
  3303. * http://jquery.org/license
  3304. *
  3305. * http://api.jqueryui.com/datepicker/
  3306. */
  3307. $.extend($.ui, { datepicker: { version: "1.11.2" } });
  3308. var datepicker_instActive;
  3309. function datepicker_getZindex( elem ) {
  3310. var position, value;
  3311. while ( elem.length && elem[ 0 ] !== document ) {
  3312. // Ignore z-index if position is set to a value where z-index is ignored by the browser
  3313. // This makes behavior of this function consistent across browsers
  3314. // WebKit always returns auto if the element is positioned
  3315. position = elem.css( "position" );
  3316. if ( position === "absolute" || position === "relative" || position === "fixed" ) {
  3317. // IE returns 0 when zIndex is not specified
  3318. // other browsers return a string
  3319. // we ignore the case of nested elements with an explicit value of 0
  3320. // <div style="z-index: -10;"><div style="z-index: 0;"></div></div>
  3321. value = parseInt( elem.css( "zIndex" ), 10 );
  3322. if ( !isNaN( value ) && value !== 0 ) {
  3323. return value;
  3324. }
  3325. }
  3326. elem = elem.parent();
  3327. }
  3328. return 0;
  3329. }
  3330. /* Date picker manager.
  3331. Use the singleton instance of this class, $.datepicker, to interact with the date picker.
  3332. Settings for (groups of) date pickers are maintained in an instance object,
  3333. allowing multiple different settings on the same page. */
  3334. function Datepicker() {
  3335. this._curInst = null; // The current instance in use
  3336. this._keyEvent = false; // If the last event was a key event
  3337. this._disabledInputs = []; // List of date picker inputs that have been disabled
  3338. this._datepickerShowing = false; // True if the popup picker is showing , false if not
  3339. this._inDialog = false; // True if showing within a "dialog", false if not
  3340. this._mainDivId = "ui-datepicker-div"; // The ID of the main datepicker division
  3341. this._inlineClass = "ui-datepicker-inline"; // The name of the inline marker class
  3342. this._appendClass = "ui-datepicker-append"; // The name of the append marker class
  3343. this._triggerClass = "ui-datepicker-trigger"; // The name of the trigger marker class
  3344. this._dialogClass = "ui-datepicker-dialog"; // The name of the dialog marker class
  3345. this._disableClass = "ui-datepicker-disabled"; // The name of the disabled covering marker class
  3346. this._unselectableClass = "ui-datepicker-unselectable"; // The name of the unselectable cell marker class
  3347. this._currentClass = "ui-datepicker-current-day"; // The name of the current day marker class
  3348. this._dayOverClass = "ui-datepicker-days-cell-over"; // The name of the day hover marker class
  3349. this.regional = []; // Available regional settings, indexed by language code
  3350. this.regional[""] = { // Default regional settings
  3351. closeText: "Done", // Display text for close link
  3352. prevText: "Prev", // Display text for previous month link
  3353. nextText: "Next", // Display text for next month link
  3354. currentText: "Today", // Display text for current month link
  3355. monthNames: ["January","February","March","April","May","June",
  3356. "July","August","September","October","November","December"], // Names of months for drop-down and formatting
  3357. monthNamesShort: ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"], // For formatting
  3358. dayNames: ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"], // For formatting
  3359. dayNamesShort: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"], // For formatting
  3360. dayNamesMin: ["Su","Mo","Tu","We","Th","Fr","Sa"], // Column headings for days starting at Sunday
  3361. weekHeader: "Wk", // Column header for week of the year
  3362. dateFormat: "mm/dd/yy", // See format options on parseDate
  3363. firstDay: 0, // The first day of the week, Sun = 0, Mon = 1, ...
  3364. isRTL: false, // True if right-to-left language, false if left-to-right
  3365. showMonthAfterYear: false, // True if the year select precedes month, false for month then year
  3366. yearSuffix: "" // Additional text to append to the year in the month headers
  3367. };
  3368. this._defaults = { // Global defaults for all the date picker instances
  3369. showOn: "focus", // "focus" for popup on focus,
  3370. // "button" for trigger button, or "both" for either
  3371. showAnim: "fadeIn", // Name of jQuery animation for popup
  3372. showOptions: {}, // Options for enhanced animations
  3373. defaultDate: null, // Used when field is blank: actual date,
  3374. // +/-number for offset from today, null for today
  3375. appendText: "", // Display text following the input box, e.g. showing the format
  3376. buttonText: "...", // Text for trigger button
  3377. buttonImage: "", // URL for trigger button image
  3378. buttonImageOnly: false, // True if the image appears alone, false if it appears on a button
  3379. hideIfNoPrevNext: false, // True to hide next/previous month links
  3380. // if not applicable, false to just disable them
  3381. navigationAsDateFormat: false, // True if date formatting applied to prev/today/next links
  3382. gotoCurrent: false, // True if today link goes back to current selection instead
  3383. changeMonth: false, // True if month can be selected directly, false if only prev/next
  3384. changeYear: false, // True if year can be selected directly, false if only prev/next
  3385. yearRange: "c-10:c+10", // Range of years to display in drop-down,
  3386. // either relative to today's year (-nn:+nn), relative to currently displayed year
  3387. // (c-nn:c+nn), absolute (nnnn:nnnn), or a combination of the above (nnnn:-n)
  3388. showOtherMonths: false, // True to show dates in other months, false to leave blank
  3389. selectOtherMonths: false, // True to allow selection of dates in other months, false for unselectable
  3390. showWeek: false, // True to show week of the year, false to not show it
  3391. calculateWeek: this.iso8601Week, // How to calculate the week of the year,
  3392. // takes a Date and returns the number of the week for it
  3393. shortYearCutoff: "+10", // Short year values < this are in the current century,
  3394. // > this are in the previous century,
  3395. // string value starting with "+" for current year + value
  3396. minDate: null, // The earliest selectable date, or null for no limit
  3397. maxDate: null, // The latest selectable date, or null for no limit
  3398. duration: "fast", // Duration of display/closure
  3399. beforeShowDay: null, // Function that takes a date and returns an array with
  3400. // [0] = true if selectable, false if not, [1] = custom CSS class name(s) or "",
  3401. // [2] = cell title (optional), e.g. $.datepicker.noWeekends
  3402. beforeShow: null, // Function that takes an input field and
  3403. // returns a set of custom settings for the date picker
  3404. onSelect: null, // Define a callback function when a date is selected
  3405. onChangeMonthYear: null, // Define a callback function when the month or year is changed
  3406. onClose: null, // Define a callback function when the datepicker is closed
  3407. numberOfMonths: 1, // Number of months to show at a time
  3408. showCurrentAtPos: 0, // The position in multipe months at which to show the current month (starting at 0)
  3409. stepMonths: 1, // Number of months to step back/forward
  3410. stepBigMonths: 12, // Number of months to step back/forward for the big links
  3411. altField: "", // Selector for an alternate field to store selected dates into
  3412. altFormat: "", // The date format to use for the alternate field
  3413. constrainInput: true, // The input is constrained by the current date format
  3414. showButtonPanel: false, // True to show button panel, false to not show it
  3415. autoSize: false, // True to size the input for the date format, false to leave as is
  3416. disabled: false // The initial disabled state
  3417. };
  3418. $.extend(this._defaults, this.regional[""]);
  3419. this.regional.en = $.extend( true, {}, this.regional[ "" ]);
  3420. this.regional[ "en-US" ] = $.extend( true, {}, this.regional.en );
  3421. this.dpDiv = datepicker_bindHover($("<div id='" + this._mainDivId + "' class='ui-datepicker ui-widget ui-widget-content ui-helper-clearfix ui-corner-all'></div>"));
  3422. }
  3423. $.extend(Datepicker.prototype, {
  3424. /* Class name added to elements to indicate already configured with a date picker. */
  3425. markerClassName: "hasDatepicker",
  3426. //Keep track of the maximum number of rows displayed (see #7043)
  3427. maxRows: 4,
  3428. // TODO rename to "widget" when switching to widget factory
  3429. _widgetDatepicker: function() {
  3430. return this.dpDiv;
  3431. },
  3432. /* Override the default settings for all instances of the date picker.
  3433. * @param settings object - the new settings to use as defaults (anonymous object)
  3434. * @return the manager object
  3435. */
  3436. setDefaults: function(settings) {
  3437. datepicker_extendRemove(this._defaults, settings || {});
  3438. return this;
  3439. },
  3440. /* Attach the date picker to a jQuery selection.
  3441. * @param target element - the target input field or division or span
  3442. * @param settings object - the new settings to use for this date picker instance (anonymous)
  3443. */
  3444. _attachDatepicker: function(target, settings) {
  3445. var nodeName, inline, inst;
  3446. nodeName = target.nodeName.toLowerCase();
  3447. inline = (nodeName === "div" || nodeName === "span");
  3448. if (!target.id) {
  3449. this.uuid += 1;
  3450. target.id = "dp" + this.uuid;
  3451. }
  3452. inst = this._newInst($(target), inline);
  3453. inst.settings = $.extend({}, settings || {});
  3454. if (nodeName === "input") {
  3455. this._connectDatepicker(target, inst);
  3456. } else if (inline) {
  3457. this._inlineDatepicker(target, inst);
  3458. }
  3459. },
  3460. /* Create a new instance object. */
  3461. _newInst: function(target, inline) {
  3462. var id = target[0].id.replace(/([^A-Za-z0-9_\-])/g, "\\\\$1"); // escape jQuery meta chars
  3463. return {id: id, input: target, // associated target
  3464. selectedDay: 0, selectedMonth: 0, selectedYear: 0, // current selection
  3465. drawMonth: 0, drawYear: 0, // month being drawn
  3466. inline: inline, // is datepicker inline or not
  3467. dpDiv: (!inline ? this.dpDiv : // presentation div
  3468. datepicker_bindHover($("<div class='" + this._inlineClass + " ui-datepicker ui-widget ui-widget-content ui-helper-clearfix ui-corner-all'></div>")))};
  3469. },
  3470. /* Attach the date picker to an input field. */
  3471. _connectDatepicker: function(target, inst) {
  3472. var input = $(target);
  3473. inst.append = $([]);
  3474. inst.trigger = $([]);
  3475. if (input.hasClass(this.markerClassName)) {
  3476. return;
  3477. }
  3478. this._attachments(input, inst);
  3479. input.addClass(this.markerClassName).keydown(this._doKeyDown).
  3480. keypress(this._doKeyPress).keyup(this._doKeyUp);
  3481. this._autoSize(inst);
  3482. $.data(target, "datepicker", inst);
  3483. //If disabled option is true, disable the datepicker once it has been attached to the input (see ticket #5665)
  3484. if( inst.settings.disabled ) {
  3485. this._disableDatepicker( target );
  3486. }
  3487. },
  3488. /* Make attachments based on settings. */
  3489. _attachments: function(input, inst) {
  3490. var showOn, buttonText, buttonImage,
  3491. appendText = this._get(inst, "appendText"),
  3492. isRTL = this._get(inst, "isRTL");
  3493. if (inst.append) {
  3494. inst.append.remove();
  3495. }
  3496. if (appendText) {
  3497. inst.append = $("<span class='" + this._appendClass + "'>" + appendText + "</span>");
  3498. input[isRTL ? "before" : "after"](inst.append);
  3499. }
  3500. input.unbind("focus", this._showDatepicker);
  3501. if (inst.trigger) {
  3502. inst.trigger.remove();
  3503. }
  3504. showOn = this._get(inst, "showOn");
  3505. if (showOn === "focus" || showOn === "both") { // pop-up date picker when in the marked field
  3506. input.focus(this._showDatepicker);
  3507. }
  3508. if (showOn === "button" || showOn === "both") { // pop-up date picker when button clicked
  3509. buttonText = this._get(inst, "buttonText");
  3510. buttonImage = this._get(inst, "buttonImage");
  3511. inst.trigger = $(this._get(inst, "buttonImageOnly") ?
  3512. $("<img/>").addClass(this._triggerClass).
  3513. attr({ src: buttonImage, alt: buttonText, title: buttonText }) :
  3514. $("<button type='button'></button>").addClass(this._triggerClass).
  3515. html(!buttonImage ? buttonText : $("<img/>").attr(
  3516. { src:buttonImage, alt:buttonText, title:buttonText })));
  3517. input[isRTL ? "before" : "after"](inst.trigger);
  3518. inst.trigger.click(function() {
  3519. if ($.datepicker._datepickerShowing && $.datepicker._lastInput === input[0]) {
  3520. $.datepicker._hideDatepicker();
  3521. } else if ($.datepicker._datepickerShowing && $.datepicker._lastInput !== input[0]) {
  3522. $.datepicker._hideDatepicker();
  3523. $.datepicker._showDatepicker(input[0]);
  3524. } else {
  3525. $.datepicker._showDatepicker(input[0]);
  3526. }
  3527. return false;
  3528. });
  3529. }
  3530. },
  3531. /* Apply the maximum length for the date format. */
  3532. _autoSize: function(inst) {
  3533. if (this._get(inst, "autoSize") && !inst.inline) {
  3534. var findMax, max, maxI, i,
  3535. date = new Date(2009, 12 - 1, 20), // Ensure double digits
  3536. dateFormat = this._get(inst, "dateFormat");
  3537. if (dateFormat.match(/[DM]/)) {
  3538. findMax = function(names) {
  3539. max = 0;
  3540. maxI = 0;
  3541. for (i = 0; i < names.length; i++) {
  3542. if (names[i].length > max) {
  3543. max = names[i].length;
  3544. maxI = i;
  3545. }
  3546. }
  3547. return maxI;
  3548. };
  3549. date.setMonth(findMax(this._get(inst, (dateFormat.match(/MM/) ?
  3550. "monthNames" : "monthNamesShort"))));
  3551. date.setDate(findMax(this._get(inst, (dateFormat.match(/DD/) ?
  3552. "dayNames" : "dayNamesShort"))) + 20 - date.getDay());
  3553. }
  3554. inst.input.attr("size", this._formatDate(inst, date).length);
  3555. }
  3556. },
  3557. /* Attach an inline date picker to a div. */
  3558. _inlineDatepicker: function(target, inst) {
  3559. var divSpan = $(target);
  3560. if (divSpan.hasClass(this.markerClassName)) {
  3561. return;
  3562. }
  3563. divSpan.addClass(this.markerClassName).append(inst.dpDiv);
  3564. $.data(target, "datepicker", inst);
  3565. this._setDate(inst, this._getDefaultDate(inst), true);
  3566. this._updateDatepicker(inst);
  3567. this._updateAlternate(inst);
  3568. //If disabled option is true, disable the datepicker before showing it (see ticket #5665)
  3569. if( inst.settings.disabled ) {
  3570. this._disableDatepicker( target );
  3571. }
  3572. // Set display:block in place of inst.dpDiv.show() which won't work on disconnected elements
  3573. // http://bugs.jqueryui.com/ticket/7552 - A Datepicker created on a detached div has zero height
  3574. inst.dpDiv.css( "display", "block" );
  3575. },
  3576. /* Pop-up the date picker in a "dialog" box.
  3577. * @param input element - ignored
  3578. * @param date string or Date - the initial date to display
  3579. * @param onSelect function - the function to call when a date is selected
  3580. * @param settings object - update the dialog date picker instance's settings (anonymous object)
  3581. * @param pos int[2] - coordinates for the dialog's position within the screen or
  3582. * event - with x/y coordinates or
  3583. * leave empty for default (screen centre)
  3584. * @return the manager object
  3585. */
  3586. _dialogDatepicker: function(input, date, onSelect, settings, pos) {
  3587. var id, browserWidth, browserHeight, scrollX, scrollY,
  3588. inst = this._dialogInst; // internal instance
  3589. if (!inst) {
  3590. this.uuid += 1;
  3591. id = "dp" + this.uuid;
  3592. this._dialogInput = $("<input type='text' id='" + id +
  3593. "' style='position: absolute; top: -100px; width: 0px;'/>");
  3594. this._dialogInput.keydown(this._doKeyDown);
  3595. $("body").append(this._dialogInput);
  3596. inst = this._dialogInst = this._newInst(this._dialogInput, false);
  3597. inst.settings = {};
  3598. $.data(this._dialogInput[0], "datepicker", inst);
  3599. }
  3600. datepicker_extendRemove(inst.settings, settings || {});
  3601. date = (date && date.constructor === Date ? this._formatDate(inst, date) : date);
  3602. this._dialogInput.val(date);
  3603. this._pos = (pos ? (pos.length ? pos : [pos.pageX, pos.pageY]) : null);
  3604. if (!this._pos) {
  3605. browserWidth = document.documentElement.clientWidth;
  3606. browserHeight = document.documentElement.clientHeight;
  3607. scrollX = document.documentElement.scrollLeft || document.body.scrollLeft;
  3608. scrollY = document.documentElement.scrollTop || document.body.scrollTop;
  3609. this._pos = // should use actual width/height below
  3610. [(browserWidth / 2) - 100 + scrollX, (browserHeight / 2) - 150 + scrollY];
  3611. }
  3612. // move input on screen for focus, but hidden behind dialog
  3613. this._dialogInput.css("left", (this._pos[0] + 20) + "px").css("top", this._pos[1] + "px");
  3614. inst.settings.onSelect = onSelect;
  3615. this._inDialog = true;
  3616. this.dpDiv.addClass(this._dialogClass);
  3617. this._showDatepicker(this._dialogInput[0]);
  3618. if ($.blockUI) {
  3619. $.blockUI(this.dpDiv);
  3620. }
  3621. $.data(this._dialogInput[0], "datepicker", inst);
  3622. return this;
  3623. },
  3624. /* Detach a datepicker from its control.
  3625. * @param target element - the target input field or division or span
  3626. */
  3627. _destroyDatepicker: function(target) {
  3628. var nodeName,
  3629. $target = $(target),
  3630. inst = $.data(target, "datepicker");
  3631. if (!$target.hasClass(this.markerClassName)) {
  3632. return;
  3633. }
  3634. nodeName = target.nodeName.toLowerCase();
  3635. $.removeData(target, "datepicker");
  3636. if (nodeName === "input") {
  3637. inst.append.remove();
  3638. inst.trigger.remove();
  3639. $target.removeClass(this.markerClassName).
  3640. unbind("focus", this._showDatepicker).
  3641. unbind("keydown", this._doKeyDown).
  3642. unbind("keypress", this._doKeyPress).
  3643. unbind("keyup", this._doKeyUp);
  3644. } else if (nodeName === "div" || nodeName === "span") {
  3645. $target.removeClass(this.markerClassName).empty();
  3646. }
  3647. },
  3648. /* Enable the date picker to a jQuery selection.
  3649. * @param target element - the target input field or division or span
  3650. */
  3651. _enableDatepicker: function(target) {
  3652. var nodeName, inline,
  3653. $target = $(target),
  3654. inst = $.data(target, "datepicker");
  3655. if (!$target.hasClass(this.markerClassName)) {
  3656. return;
  3657. }
  3658. nodeName = target.nodeName.toLowerCase();
  3659. if (nodeName === "input") {
  3660. target.disabled = false;
  3661. inst.trigger.filter("button").
  3662. each(function() { this.disabled = false; }).end().
  3663. filter("img").css({opacity: "1.0", cursor: ""});
  3664. } else if (nodeName === "div" || nodeName === "span") {
  3665. inline = $target.children("." + this._inlineClass);
  3666. inline.children().removeClass("ui-state-disabled");
  3667. inline.find("select.ui-datepicker-month, select.ui-datepicker-year").
  3668. prop("disabled", false);
  3669. }
  3670. this._disabledInputs = $.map(this._disabledInputs,
  3671. function(value) { return (value === target ? null : value); }); // delete entry
  3672. },
  3673. /* Disable the date picker to a jQuery selection.
  3674. * @param target element - the target input field or division or span
  3675. */
  3676. _disableDatepicker: function(target) {
  3677. var nodeName, inline,
  3678. $target = $(target),
  3679. inst = $.data(target, "datepicker");
  3680. if (!$target.hasClass(this.markerClassName)) {
  3681. return;
  3682. }
  3683. nodeName = target.nodeName.toLowerCase();
  3684. if (nodeName === "input") {
  3685. target.disabled = true;
  3686. inst.trigger.filter("button").
  3687. each(function() { this.disabled = true; }).end().
  3688. filter("img").css({opacity: "0.5", cursor: "default"});
  3689. } else if (nodeName === "div" || nodeName === "span") {
  3690. inline = $target.children("." + this._inlineClass);
  3691. inline.children().addClass("ui-state-disabled");
  3692. inline.find("select.ui-datepicker-month, select.ui-datepicker-year").
  3693. prop("disabled", true);
  3694. }
  3695. this._disabledInputs = $.map(this._disabledInputs,
  3696. function(value) { return (value === target ? null : value); }); // delete entry
  3697. this._disabledInputs[this._disabledInputs.length] = target;
  3698. },
  3699. /* Is the first field in a jQuery collection disabled as a datepicker?
  3700. * @param target element - the target input field or division or span
  3701. * @return boolean - true if disabled, false if enabled
  3702. */
  3703. _isDisabledDatepicker: function(target) {
  3704. if (!target) {
  3705. return false;
  3706. }
  3707. for (var i = 0; i < this._disabledInputs.length; i++) {
  3708. if (this._disabledInputs[i] === target) {
  3709. return true;
  3710. }
  3711. }
  3712. return false;
  3713. },
  3714. /* Retrieve the instance data for the target control.
  3715. * @param target element - the target input field or division or span
  3716. * @return object - the associated instance data
  3717. * @throws error if a jQuery problem getting data
  3718. */
  3719. _getInst: function(target) {
  3720. try {
  3721. return $.data(target, "datepicker");
  3722. }
  3723. catch (err) {
  3724. throw "Missing instance data for this datepicker";
  3725. }
  3726. },
  3727. /* Update or retrieve the settings for a date picker attached to an input field or division.
  3728. * @param target element - the target input field or division or span
  3729. * @param name object - the new settings to update or
  3730. * string - the name of the setting to change or retrieve,
  3731. * when retrieving also "all" for all instance settings or
  3732. * "defaults" for all global defaults
  3733. * @param value any - the new value for the setting
  3734. * (omit if above is an object or to retrieve a value)
  3735. */
  3736. _optionDatepicker: function(target, name, value) {
  3737. var settings, date, minDate, maxDate,
  3738. inst = this._getInst(target);
  3739. if (arguments.length === 2 && typeof name === "string") {
  3740. return (name === "defaults" ? $.extend({}, $.datepicker._defaults) :
  3741. (inst ? (name === "all" ? $.extend({}, inst.settings) :
  3742. this._get(inst, name)) : null));
  3743. }
  3744. settings = name || {};
  3745. if (typeof name === "string") {
  3746. settings = {};
  3747. settings[name] = value;
  3748. }
  3749. if (inst) {
  3750. if (this._curInst === inst) {
  3751. this._hideDatepicker();
  3752. }
  3753. date = this._getDateDatepicker(target, true);
  3754. minDate = this._getMinMaxDate(inst, "min");
  3755. maxDate = this._getMinMaxDate(inst, "max");
  3756. datepicker_extendRemove(inst.settings, settings);
  3757. // reformat the old minDate/maxDate values if dateFormat changes and a new minDate/maxDate isn't provided
  3758. if (minDate !== null && settings.dateFormat !== undefined && settings.minDate === undefined) {
  3759. inst.settings.minDate = this._formatDate(inst, minDate);
  3760. }
  3761. if (maxDate !== null && settings.dateFormat !== undefined && settings.maxDate === undefined) {
  3762. inst.settings.maxDate = this._formatDate(inst, maxDate);
  3763. }
  3764. if ( "disabled" in settings ) {
  3765. if ( settings.disabled ) {
  3766. this._disableDatepicker(target);
  3767. } else {
  3768. this._enableDatepicker(target);
  3769. }
  3770. }
  3771. this._attachments($(target), inst);
  3772. this._autoSize(inst);
  3773. this._setDate(inst, date);
  3774. this._updateAlternate(inst);
  3775. this._updateDatepicker(inst);
  3776. }
  3777. },
  3778. // change method deprecated
  3779. _changeDatepicker: function(target, name, value) {
  3780. this._optionDatepicker(target, name, value);
  3781. },
  3782. /* Redraw the date picker attached to an input field or division.
  3783. * @param target element - the target input field or division or span
  3784. */
  3785. _refreshDatepicker: function(target) {
  3786. var inst = this._getInst(target);
  3787. if (inst) {
  3788. this._updateDatepicker(inst);
  3789. }
  3790. },
  3791. /* Set the dates for a jQuery selection.
  3792. * @param target element - the target input field or division or span
  3793. * @param date Date - the new date
  3794. */
  3795. _setDateDatepicker: function(target, date) {
  3796. var inst = this._getInst(target);
  3797. if (inst) {
  3798. this._setDate(inst, date);
  3799. this._updateDatepicker(inst);
  3800. this._updateAlternate(inst);
  3801. }
  3802. },
  3803. /* Get the date(s) for the first entry in a jQuery selection.
  3804. * @param target element - the target input field or division or span
  3805. * @param noDefault boolean - true if no default date is to be used
  3806. * @return Date - the current date
  3807. */
  3808. _getDateDatepicker: function(target, noDefault) {
  3809. var inst = this._getInst(target);
  3810. if (inst && !inst.inline) {
  3811. this._setDateFromField(inst, noDefault);
  3812. }
  3813. return (inst ? this._getDate(inst) : null);
  3814. },
  3815. /* Handle keystrokes. */
  3816. _doKeyDown: function(event) {
  3817. var onSelect, dateStr, sel,
  3818. inst = $.datepicker._getInst(event.target),
  3819. handled = true,
  3820. isRTL = inst.dpDiv.is(".ui-datepicker-rtl");
  3821. inst._keyEvent = true;
  3822. if ($.datepicker._datepickerShowing) {
  3823. switch (event.keyCode) {
  3824. case 9: $.datepicker._hideDatepicker();
  3825. handled = false;
  3826. break; // hide on tab out
  3827. case 13: sel = $("td." + $.datepicker._dayOverClass + ":not(." +
  3828. $.datepicker._currentClass + ")", inst.dpDiv);
  3829. if (sel[0]) {
  3830. $.datepicker._selectDay(event.target, inst.selectedMonth, inst.selectedYear, sel[0]);
  3831. }
  3832. onSelect = $.datepicker._get(inst, "onSelect");
  3833. if (onSelect) {
  3834. dateStr = $.datepicker._formatDate(inst);
  3835. // trigger custom callback
  3836. onSelect.apply((inst.input ? inst.input[0] : null), [dateStr, inst]);
  3837. } else {
  3838. $.datepicker._hideDatepicker();
  3839. }
  3840. return false; // don't submit the form
  3841. case 27: $.datepicker._hideDatepicker();
  3842. break; // hide on escape
  3843. case 33: $.datepicker._adjustDate(event.target, (event.ctrlKey ?
  3844. -$.datepicker._get(inst, "stepBigMonths") :
  3845. -$.datepicker._get(inst, "stepMonths")), "M");
  3846. break; // previous month/year on page up/+ ctrl
  3847. case 34: $.datepicker._adjustDate(event.target, (event.ctrlKey ?
  3848. +$.datepicker._get(inst, "stepBigMonths") :
  3849. +$.datepicker._get(inst, "stepMonths")), "M");
  3850. break; // next month/year on page down/+ ctrl
  3851. case 35: if (event.ctrlKey || event.metaKey) {
  3852. $.datepicker._clearDate(event.target);
  3853. }
  3854. handled = event.ctrlKey || event.metaKey;
  3855. break; // clear on ctrl or command +end
  3856. case 36: if (event.ctrlKey || event.metaKey) {
  3857. $.datepicker._gotoToday(event.target);
  3858. }
  3859. handled = event.ctrlKey || event.metaKey;
  3860. break; // current on ctrl or command +home
  3861. case 37: if (event.ctrlKey || event.metaKey) {
  3862. $.datepicker._adjustDate(event.target, (isRTL ? +1 : -1), "D");
  3863. }
  3864. handled = event.ctrlKey || event.metaKey;
  3865. // -1 day on ctrl or command +left
  3866. if (event.originalEvent.altKey) {
  3867. $.datepicker._adjustDate(event.target, (event.ctrlKey ?
  3868. -$.datepicker._get(inst, "stepBigMonths") :
  3869. -$.datepicker._get(inst, "stepMonths")), "M");
  3870. }
  3871. // next month/year on alt +left on Mac
  3872. break;
  3873. case 38: if (event.ctrlKey || event.metaKey) {
  3874. $.datepicker._adjustDate(event.target, -7, "D");
  3875. }
  3876. handled = event.ctrlKey || event.metaKey;
  3877. break; // -1 week on ctrl or command +up
  3878. case 39: if (event.ctrlKey || event.metaKey) {
  3879. $.datepicker._adjustDate(event.target, (isRTL ? -1 : +1), "D");
  3880. }
  3881. handled = event.ctrlKey || event.metaKey;
  3882. // +1 day on ctrl or command +right
  3883. if (event.originalEvent.altKey) {
  3884. $.datepicker._adjustDate(event.target, (event.ctrlKey ?
  3885. +$.datepicker._get(inst, "stepBigMonths") :
  3886. +$.datepicker._get(inst, "stepMonths")), "M");
  3887. }
  3888. // next month/year on alt +right
  3889. break;
  3890. case 40: if (event.ctrlKey || event.metaKey) {
  3891. $.datepicker._adjustDate(event.target, +7, "D");
  3892. }
  3893. handled = event.ctrlKey || event.metaKey;
  3894. break; // +1 week on ctrl or command +down
  3895. default: handled = false;
  3896. }
  3897. } else if (event.keyCode === 36 && event.ctrlKey) { // display the date picker on ctrl+home
  3898. $.datepicker._showDatepicker(this);
  3899. } else {
  3900. handled = false;
  3901. }
  3902. if (handled) {
  3903. event.preventDefault();
  3904. event.stopPropagation();
  3905. }
  3906. },
  3907. /* Filter entered characters - based on date format. */
  3908. _doKeyPress: function(event) {
  3909. var chars, chr,
  3910. inst = $.datepicker._getInst(event.target);
  3911. if ($.datepicker._get(inst, "constrainInput")) {
  3912. chars = $.datepicker._possibleChars($.datepicker._get(inst, "dateFormat"));
  3913. chr = String.fromCharCode(event.charCode == null ? event.keyCode : event.charCode);
  3914. return event.ctrlKey || event.metaKey || (chr < " " || !chars || chars.indexOf(chr) > -1);
  3915. }
  3916. },
  3917. /* Synchronise manual entry and field/alternate field. */
  3918. _doKeyUp: function(event) {
  3919. var date,
  3920. inst = $.datepicker._getInst(event.target);
  3921. if (inst.input.val() !== inst.lastVal) {
  3922. try {
  3923. date = $.datepicker.parseDate($.datepicker._get(inst, "dateFormat"),
  3924. (inst.input ? inst.input.val() : null),
  3925. $.datepicker._getFormatConfig(inst));
  3926. if (date) { // only if valid
  3927. $.datepicker._setDateFromField(inst);
  3928. $.datepicker._updateAlternate(inst);
  3929. $.datepicker._updateDatepicker(inst);
  3930. }
  3931. }
  3932. catch (err) {
  3933. }
  3934. }
  3935. return true;
  3936. },
  3937. /* Pop-up the date picker for a given input field.
  3938. * If false returned from beforeShow event handler do not show.
  3939. * @param input element - the input field attached to the date picker or
  3940. * event - if triggered by focus
  3941. */
  3942. _showDatepicker: function(input) {
  3943. input = input.target || input;
  3944. if (input.nodeName.toLowerCase() !== "input") { // find from button/image trigger
  3945. input = $("input", input.parentNode)[0];
  3946. }
  3947. if ($.datepicker._isDisabledDatepicker(input) || $.datepicker._lastInput === input) { // already here
  3948. return;
  3949. }
  3950. var inst, beforeShow, beforeShowSettings, isFixed,
  3951. offset, showAnim, duration;
  3952. inst = $.datepicker._getInst(input);
  3953. if ($.datepicker._curInst && $.datepicker._curInst !== inst) {
  3954. $.datepicker._curInst.dpDiv.stop(true, true);
  3955. if ( inst && $.datepicker._datepickerShowing ) {
  3956. $.datepicker._hideDatepicker( $.datepicker._curInst.input[0] );
  3957. }
  3958. }
  3959. beforeShow = $.datepicker._get(inst, "beforeShow");
  3960. beforeShowSettings = beforeShow ? beforeShow.apply(input, [input, inst]) : {};
  3961. if(beforeShowSettings === false){
  3962. return;
  3963. }
  3964. datepicker_extendRemove(inst.settings, beforeShowSettings);
  3965. inst.lastVal = null;
  3966. $.datepicker._lastInput = input;
  3967. $.datepicker._setDateFromField(inst);
  3968. if ($.datepicker._inDialog) { // hide cursor
  3969. input.value = "";
  3970. }
  3971. if (!$.datepicker._pos) { // position below input
  3972. $.datepicker._pos = $.datepicker._findPos(input);
  3973. $.datepicker._pos[1] += input.offsetHeight; // add the height
  3974. }
  3975. isFixed = false;
  3976. $(input).parents().each(function() {
  3977. isFixed |= $(this).css("position") === "fixed";
  3978. return !isFixed;
  3979. });
  3980. offset = {left: $.datepicker._pos[0], top: $.datepicker._pos[1]};
  3981. $.datepicker._pos = null;
  3982. //to avoid flashes on Firefox
  3983. inst.dpDiv.empty();
  3984. // determine sizing offscreen
  3985. inst.dpDiv.css({position: "absolute", display: "block", top: "-1000px"});
  3986. $.datepicker._updateDatepicker(inst);
  3987. // fix width for dynamic number of date pickers
  3988. // and adjust position before showing
  3989. offset = $.datepicker._checkOffset(inst, offset, isFixed);
  3990. inst.dpDiv.css({position: ($.datepicker._inDialog && $.blockUI ?
  3991. "static" : (isFixed ? "fixed" : "absolute")), display: "none",
  3992. left: offset.left + "px", top: offset.top + "px"});
  3993. if (!inst.inline) {
  3994. showAnim = $.datepicker._get(inst, "showAnim");
  3995. duration = $.datepicker._get(inst, "duration");
  3996. inst.dpDiv.css( "z-index", datepicker_getZindex( $( input ) ) + 1 );
  3997. $.datepicker._datepickerShowing = true;
  3998. if ( $.effects && $.effects.effect[ showAnim ] ) {
  3999. inst.dpDiv.show(showAnim, $.datepicker._get(inst, "showOptions"), duration);
  4000. } else {
  4001. inst.dpDiv[showAnim || "show"](showAnim ? duration : null);
  4002. }
  4003. if ( $.datepicker._shouldFocusInput( inst ) ) {
  4004. inst.input.focus();
  4005. }
  4006. $.datepicker._curInst = inst;
  4007. }
  4008. },
  4009. /* Generate the date picker content. */
  4010. _updateDatepicker: function(inst) {
  4011. this.maxRows = 4; //Reset the max number of rows being displayed (see #7043)
  4012. datepicker_instActive = inst; // for delegate hover events
  4013. inst.dpDiv.empty().append(this._generateHTML(inst));
  4014. this._attachHandlers(inst);
  4015. var origyearshtml,
  4016. numMonths = this._getNumberOfMonths(inst),
  4017. cols = numMonths[1],
  4018. width = 17,
  4019. activeCell = inst.dpDiv.find( "." + this._dayOverClass + " a" );
  4020. if ( activeCell.length > 0 ) {
  4021. datepicker_handleMouseover.apply( activeCell.get( 0 ) );
  4022. }
  4023. inst.dpDiv.removeClass("ui-datepicker-multi-2 ui-datepicker-multi-3 ui-datepicker-multi-4").width("");
  4024. if (cols > 1) {
  4025. inst.dpDiv.addClass("ui-datepicker-multi-" + cols).css("width", (width * cols) + "em");
  4026. }
  4027. inst.dpDiv[(numMonths[0] !== 1 || numMonths[1] !== 1 ? "add" : "remove") +
  4028. "Class"]("ui-datepicker-multi");
  4029. inst.dpDiv[(this._get(inst, "isRTL") ? "add" : "remove") +
  4030. "Class"]("ui-datepicker-rtl");
  4031. if (inst === $.datepicker._curInst && $.datepicker._datepickerShowing && $.datepicker._shouldFocusInput( inst ) ) {
  4032. inst.input.focus();
  4033. }
  4034. // deffered render of the years select (to avoid flashes on Firefox)
  4035. if( inst.yearshtml ){
  4036. origyearshtml = inst.yearshtml;
  4037. setTimeout(function(){
  4038. //assure that inst.yearshtml didn't change.
  4039. if( origyearshtml === inst.yearshtml && inst.yearshtml ){
  4040. inst.dpDiv.find("select.ui-datepicker-year:first").replaceWith(inst.yearshtml);
  4041. }
  4042. origyearshtml = inst.yearshtml = null;
  4043. }, 0);
  4044. }
  4045. },
  4046. // #6694 - don't focus the input if it's already focused
  4047. // this breaks the change event in IE
  4048. // Support: IE and jQuery <1.9
  4049. _shouldFocusInput: function( inst ) {
  4050. return inst.input && inst.input.is( ":visible" ) && !inst.input.is( ":disabled" ) && !inst.input.is( ":focus" );
  4051. },
  4052. /* Check positioning to remain on screen. */
  4053. _checkOffset: function(inst, offset, isFixed) {
  4054. var dpWidth = inst.dpDiv.outerWidth(),
  4055. dpHeight = inst.dpDiv.outerHeight(),
  4056. inputWidth = inst.input ? inst.input.outerWidth() : 0,
  4057. inputHeight = inst.input ? inst.input.outerHeight() : 0,
  4058. viewWidth = document.documentElement.clientWidth + (isFixed ? 0 : $(document).scrollLeft()),
  4059. viewHeight = document.documentElement.clientHeight + (isFixed ? 0 : $(document).scrollTop());
  4060. offset.left -= (this._get(inst, "isRTL") ? (dpWidth - inputWidth) : 0);
  4061. offset.left -= (isFixed && offset.left === inst.input.offset().left) ? $(document).scrollLeft() : 0;
  4062. offset.top -= (isFixed && offset.top === (inst.input.offset().top + inputHeight)) ? $(document).scrollTop() : 0;
  4063. // now check if datepicker is showing outside window viewport - move to a better place if so.
  4064. offset.left -= Math.min(offset.left, (offset.left + dpWidth > viewWidth && viewWidth > dpWidth) ?
  4065. Math.abs(offset.left + dpWidth - viewWidth) : 0);
  4066. offset.top -= Math.min(offset.top, (offset.top + dpHeight > viewHeight && viewHeight > dpHeight) ?
  4067. Math.abs(dpHeight + inputHeight) : 0);
  4068. return offset;
  4069. },
  4070. /* Find an object's position on the screen. */
  4071. _findPos: function(obj) {
  4072. var position,
  4073. inst = this._getInst(obj),
  4074. isRTL = this._get(inst, "isRTL");
  4075. while (obj && (obj.type === "hidden" || obj.nodeType !== 1 || $.expr.filters.hidden(obj))) {
  4076. obj = obj[isRTL ? "previousSibling" : "nextSibling"];
  4077. }
  4078. position = $(obj).offset();
  4079. return [position.left, position.top];
  4080. },
  4081. /* Hide the date picker from view.
  4082. * @param input element - the input field attached to the date picker
  4083. */
  4084. _hideDatepicker: function(input) {
  4085. var showAnim, duration, postProcess, onClose,
  4086. inst = this._curInst;
  4087. if (!inst || (input && inst !== $.data(input, "datepicker"))) {
  4088. return;
  4089. }
  4090. if (this._datepickerShowing) {
  4091. showAnim = this._get(inst, "showAnim");
  4092. duration = this._get(inst, "duration");
  4093. postProcess = function() {
  4094. $.datepicker._tidyDialog(inst);
  4095. };
  4096. // DEPRECATED: after BC for 1.8.x $.effects[ showAnim ] is not needed
  4097. if ( $.effects && ( $.effects.effect[ showAnim ] || $.effects[ showAnim ] ) ) {
  4098. inst.dpDiv.hide(showAnim, $.datepicker._get(inst, "showOptions"), duration, postProcess);
  4099. } else {
  4100. inst.dpDiv[(showAnim === "slideDown" ? "slideUp" :
  4101. (showAnim === "fadeIn" ? "fadeOut" : "hide"))]((showAnim ? duration : null), postProcess);
  4102. }
  4103. if (!showAnim) {
  4104. postProcess();
  4105. }
  4106. this._datepickerShowing = false;
  4107. onClose = this._get(inst, "onClose");
  4108. if (onClose) {
  4109. onClose.apply((inst.input ? inst.input[0] : null), [(inst.input ? inst.input.val() : ""), inst]);
  4110. }
  4111. this._lastInput = null;
  4112. if (this._inDialog) {
  4113. this._dialogInput.css({ position: "absolute", left: "0", top: "-100px" });
  4114. if ($.blockUI) {
  4115. $.unblockUI();
  4116. $("body").append(this.dpDiv);
  4117. }
  4118. }
  4119. this._inDialog = false;
  4120. }
  4121. },
  4122. /* Tidy up after a dialog display. */
  4123. _tidyDialog: function(inst) {
  4124. inst.dpDiv.removeClass(this._dialogClass).unbind(".ui-datepicker-calendar");
  4125. },
  4126. /* Close date picker if clicked elsewhere. */
  4127. _checkExternalClick: function(event) {
  4128. if (!$.datepicker._curInst) {
  4129. return;
  4130. }
  4131. var $target = $(event.target),
  4132. inst = $.datepicker._getInst($target[0]);
  4133. if ( ( ( $target[0].id !== $.datepicker._mainDivId &&
  4134. $target.parents("#" + $.datepicker._mainDivId).length === 0 &&
  4135. !$target.hasClass($.datepicker.markerClassName) &&
  4136. !$target.closest("." + $.datepicker._triggerClass).length &&
  4137. $.datepicker._datepickerShowing && !($.datepicker._inDialog && $.blockUI) ) ) ||
  4138. ( $target.hasClass($.datepicker.markerClassName) && $.datepicker._curInst !== inst ) ) {
  4139. $.datepicker._hideDatepicker();
  4140. }
  4141. },
  4142. /* Adjust one of the date sub-fields. */
  4143. _adjustDate: function(id, offset, period) {
  4144. var target = $(id),
  4145. inst = this._getInst(target[0]);
  4146. if (this._isDisabledDatepicker(target[0])) {
  4147. return;
  4148. }
  4149. this._adjustInstDate(inst, offset +
  4150. (period === "M" ? this._get(inst, "showCurrentAtPos") : 0), // undo positioning
  4151. period);
  4152. this._updateDatepicker(inst);
  4153. },
  4154. /* Action for current link. */
  4155. _gotoToday: function(id) {
  4156. var date,
  4157. target = $(id),
  4158. inst = this._getInst(target[0]);
  4159. if (this._get(inst, "gotoCurrent") && inst.currentDay) {
  4160. inst.selectedDay = inst.currentDay;
  4161. inst.drawMonth = inst.selectedMonth = inst.currentMonth;
  4162. inst.drawYear = inst.selectedYear = inst.currentYear;
  4163. } else {
  4164. date = new Date();
  4165. inst.selectedDay = date.getDate();
  4166. inst.drawMonth = inst.selectedMonth = date.getMonth();
  4167. inst.drawYear = inst.selectedYear = date.getFullYear();
  4168. }
  4169. this._notifyChange(inst);
  4170. this._adjustDate(target);
  4171. },
  4172. /* Action for selecting a new month/year. */
  4173. _selectMonthYear: function(id, select, period) {
  4174. var target = $(id),
  4175. inst = this._getInst(target[0]);
  4176. inst["selected" + (period === "M" ? "Month" : "Year")] =
  4177. inst["draw" + (period === "M" ? "Month" : "Year")] =
  4178. parseInt(select.options[select.selectedIndex].value,10);
  4179. this._notifyChange(inst);
  4180. this._adjustDate(target);
  4181. },
  4182. /* Action for selecting a day. */
  4183. _selectDay: function(id, month, year, td) {
  4184. var inst,
  4185. target = $(id);
  4186. if ($(td).hasClass(this._unselectableClass) || this._isDisabledDatepicker(target[0])) {
  4187. return;
  4188. }
  4189. inst = this._getInst(target[0]);
  4190. inst.selectedDay = inst.currentDay = $("a", td).html();
  4191. inst.selectedMonth = inst.currentMonth = month;
  4192. inst.selectedYear = inst.currentYear = year;
  4193. this._selectDate(id, this._formatDate(inst,
  4194. inst.currentDay, inst.currentMonth, inst.currentYear));
  4195. },
  4196. /* Erase the input field and hide the date picker. */
  4197. _clearDate: function(id) {
  4198. var target = $(id);
  4199. this._selectDate(target, "");
  4200. },
  4201. /* Update the input field with the selected date. */
  4202. _selectDate: function(id, dateStr) {
  4203. var onSelect,
  4204. target = $(id),
  4205. inst = this._getInst(target[0]);
  4206. dateStr = (dateStr != null ? dateStr : this._formatDate(inst));
  4207. if (inst.input) {
  4208. inst.input.val(dateStr);
  4209. }
  4210. this._updateAlternate(inst);
  4211. onSelect = this._get(inst, "onSelect");
  4212. if (onSelect) {
  4213. onSelect.apply((inst.input ? inst.input[0] : null), [dateStr, inst]); // trigger custom callback
  4214. } else if (inst.input) {
  4215. inst.input.trigger("change"); // fire the change event
  4216. }
  4217. if (inst.inline){
  4218. this._updateDatepicker(inst);
  4219. } else {
  4220. this._hideDatepicker();
  4221. this._lastInput = inst.input[0];
  4222. if (typeof(inst.input[0]) !== "object") {
  4223. inst.input.focus(); // restore focus
  4224. }
  4225. this._lastInput = null;
  4226. }
  4227. },
  4228. /* Update any alternate field to synchronise with the main field. */
  4229. _updateAlternate: function(inst) {
  4230. var altFormat, date, dateStr,
  4231. altField = this._get(inst, "altField");
  4232. if (altField) { // update alternate field too
  4233. altFormat = this._get(inst, "altFormat") || this._get(inst, "dateFormat");
  4234. date = this._getDate(inst);
  4235. dateStr = this.formatDate(altFormat, date, this._getFormatConfig(inst));
  4236. $(altField).each(function() { $(this).val(dateStr); });
  4237. }
  4238. },
  4239. /* Set as beforeShowDay function to prevent selection of weekends.
  4240. * @param date Date - the date to customise
  4241. * @return [boolean, string] - is this date selectable?, what is its CSS class?
  4242. */
  4243. noWeekends: function(date) {
  4244. var day = date.getDay();
  4245. return [(day > 0 && day < 6), ""];
  4246. },
  4247. /* Set as calculateWeek to determine the week of the year based on the ISO 8601 definition.
  4248. * @param date Date - the date to get the week for
  4249. * @return number - the number of the week within the year that contains this date
  4250. */
  4251. iso8601Week: function(date) {
  4252. var time,
  4253. checkDate = new Date(date.getTime());
  4254. // Find Thursday of this week starting on Monday
  4255. checkDate.setDate(checkDate.getDate() + 4 - (checkDate.getDay() || 7));
  4256. time = checkDate.getTime();
  4257. checkDate.setMonth(0); // Compare with Jan 1
  4258. checkDate.setDate(1);
  4259. return Math.floor(Math.round((time - checkDate) / 86400000) / 7) + 1;
  4260. },
  4261. /* Parse a string value into a date object.
  4262. * See formatDate below for the possible formats.
  4263. *
  4264. * @param format string - the expected format of the date
  4265. * @param value string - the date in the above format
  4266. * @param settings Object - attributes include:
  4267. * shortYearCutoff number - the cutoff year for determining the century (optional)
  4268. * dayNamesShort string[7] - abbreviated names of the days from Sunday (optional)
  4269. * dayNames string[7] - names of the days from Sunday (optional)
  4270. * monthNamesShort string[12] - abbreviated names of the months (optional)
  4271. * monthNames string[12] - names of the months (optional)
  4272. * @return Date - the extracted date value or null if value is blank
  4273. */
  4274. parseDate: function (format, value, settings) {
  4275. if (format == null || value == null) {
  4276. throw "Invalid arguments";
  4277. }
  4278. value = (typeof value === "object" ? value.toString() : value + "");
  4279. if (value === "") {
  4280. return null;
  4281. }
  4282. var iFormat, dim, extra,
  4283. iValue = 0,
  4284. shortYearCutoffTemp = (settings ? settings.shortYearCutoff : null) || this._defaults.shortYearCutoff,
  4285. shortYearCutoff = (typeof shortYearCutoffTemp !== "string" ? shortYearCutoffTemp :
  4286. new Date().getFullYear() % 100 + parseInt(shortYearCutoffTemp, 10)),
  4287. dayNamesShort = (settings ? settings.dayNamesShort : null) || this._defaults.dayNamesShort,
  4288. dayNames = (settings ? settings.dayNames : null) || this._defaults.dayNames,
  4289. monthNamesShort = (settings ? settings.monthNamesShort : null) || this._defaults.monthNamesShort,
  4290. monthNames = (settings ? settings.monthNames : null) || this._defaults.monthNames,
  4291. year = -1,
  4292. month = -1,
  4293. day = -1,
  4294. doy = -1,
  4295. literal = false,
  4296. date,
  4297. // Check whether a format character is doubled
  4298. lookAhead = function(match) {
  4299. var matches = (iFormat + 1 < format.length && format.charAt(iFormat + 1) === match);
  4300. if (matches) {
  4301. iFormat++;
  4302. }
  4303. return matches;
  4304. },
  4305. // Extract a number from the string value
  4306. getNumber = function(match) {
  4307. var isDoubled = lookAhead(match),
  4308. size = (match === "@" ? 14 : (match === "!" ? 20 :
  4309. (match === "y" && isDoubled ? 4 : (match === "o" ? 3 : 2)))),
  4310. minSize = (match === "y" ? size : 1),
  4311. digits = new RegExp("^\\d{" + minSize + "," + size + "}"),
  4312. num = value.substring(iValue).match(digits);
  4313. if (!num) {
  4314. throw "Missing number at position " + iValue;
  4315. }
  4316. iValue += num[0].length;
  4317. return parseInt(num[0], 10);
  4318. },
  4319. // Extract a name from the string value and convert to an index
  4320. getName = function(match, shortNames, longNames) {
  4321. var index = -1,
  4322. names = $.map(lookAhead(match) ? longNames : shortNames, function (v, k) {
  4323. return [ [k, v] ];
  4324. }).sort(function (a, b) {
  4325. return -(a[1].length - b[1].length);
  4326. });
  4327. $.each(names, function (i, pair) {
  4328. var name = pair[1];
  4329. if (value.substr(iValue, name.length).toLowerCase() === name.toLowerCase()) {
  4330. index = pair[0];
  4331. iValue += name.length;
  4332. return false;
  4333. }
  4334. });
  4335. if (index !== -1) {
  4336. return index + 1;
  4337. } else {
  4338. throw "Unknown name at position " + iValue;
  4339. }
  4340. },
  4341. // Confirm that a literal character matches the string value
  4342. checkLiteral = function() {
  4343. if (value.charAt(iValue) !== format.charAt(iFormat)) {
  4344. throw "Unexpected literal at position " + iValue;
  4345. }
  4346. iValue++;
  4347. };
  4348. for (iFormat = 0; iFormat < format.length; iFormat++) {
  4349. if (literal) {
  4350. if (format.charAt(iFormat) === "'" && !lookAhead("'")) {
  4351. literal = false;
  4352. } else {
  4353. checkLiteral();
  4354. }
  4355. } else {
  4356. switch (format.charAt(iFormat)) {
  4357. case "d":
  4358. day = getNumber("d");
  4359. break;
  4360. case "D":
  4361. getName("D", dayNamesShort, dayNames);
  4362. break;
  4363. case "o":
  4364. doy = getNumber("o");
  4365. break;
  4366. case "m":
  4367. month = getNumber("m");
  4368. break;
  4369. case "M":
  4370. month = getName("M", monthNamesShort, monthNames);
  4371. break;
  4372. case "y":
  4373. year = getNumber("y");
  4374. break;
  4375. case "@":
  4376. date = new Date(getNumber("@"));
  4377. year = date.getFullYear();
  4378. month = date.getMonth() + 1;
  4379. day = date.getDate();
  4380. break;
  4381. case "!":
  4382. date = new Date((getNumber("!") - this._ticksTo1970) / 10000);
  4383. year = date.getFullYear();
  4384. month = date.getMonth() + 1;
  4385. day = date.getDate();
  4386. break;
  4387. case "'":
  4388. if (lookAhead("'")){
  4389. checkLiteral();
  4390. } else {
  4391. literal = true;
  4392. }
  4393. break;
  4394. default:
  4395. checkLiteral();
  4396. }
  4397. }
  4398. }
  4399. if (iValue < value.length){
  4400. extra = value.substr(iValue);
  4401. if (!/^\s+/.test(extra)) {
  4402. throw "Extra/unparsed characters found in date: " + extra;
  4403. }
  4404. }
  4405. if (year === -1) {
  4406. year = new Date().getFullYear();
  4407. } else if (year < 100) {
  4408. year += new Date().getFullYear() - new Date().getFullYear() % 100 +
  4409. (year <= shortYearCutoff ? 0 : -100);
  4410. }
  4411. if (doy > -1) {
  4412. month = 1;
  4413. day = doy;
  4414. do {
  4415. dim = this._getDaysInMonth(year, month - 1);
  4416. if (day <= dim) {
  4417. break;
  4418. }
  4419. month++;
  4420. day -= dim;
  4421. } while (true);
  4422. }
  4423. date = this._daylightSavingAdjust(new Date(year, month - 1, day));
  4424. if (date.getFullYear() !== year || date.getMonth() + 1 !== month || date.getDate() !== day) {
  4425. throw "Invalid date"; // E.g. 31/02/00
  4426. }
  4427. return date;
  4428. },
  4429. /* Standard date formats. */
  4430. ATOM: "yy-mm-dd", // RFC 3339 (ISO 8601)
  4431. COOKIE: "D, dd M yy",
  4432. ISO_8601: "yy-mm-dd",
  4433. RFC_822: "D, d M y",
  4434. RFC_850: "DD, dd-M-y",
  4435. RFC_1036: "D, d M y",
  4436. RFC_1123: "D, d M yy",
  4437. RFC_2822: "D, d M yy",
  4438. RSS: "D, d M y", // RFC 822
  4439. TICKS: "!",
  4440. TIMESTAMP: "@",
  4441. W3C: "yy-mm-dd", // ISO 8601
  4442. _ticksTo1970: (((1970 - 1) * 365 + Math.floor(1970 / 4) - Math.floor(1970 / 100) +
  4443. Math.floor(1970 / 400)) * 24 * 60 * 60 * 10000000),
  4444. /* Format a date object into a string value.
  4445. * The format can be combinations of the following:
  4446. * d - day of month (no leading zero)
  4447. * dd - day of month (two digit)
  4448. * o - day of year (no leading zeros)
  4449. * oo - day of year (three digit)
  4450. * D - day name short
  4451. * DD - day name long
  4452. * m - month of year (no leading zero)
  4453. * mm - month of year (two digit)
  4454. * M - month name short
  4455. * MM - month name long
  4456. * y - year (two digit)
  4457. * yy - year (four digit)
  4458. * @ - Unix timestamp (ms since 01/01/1970)
  4459. * ! - Windows ticks (100ns since 01/01/0001)
  4460. * "..." - literal text
  4461. * '' - single quote
  4462. *
  4463. * @param format string - the desired format of the date
  4464. * @param date Date - the date value to format
  4465. * @param settings Object - attributes include:
  4466. * dayNamesShort string[7] - abbreviated names of the days from Sunday (optional)
  4467. * dayNames string[7] - names of the days from Sunday (optional)
  4468. * monthNamesShort string[12] - abbreviated names of the months (optional)
  4469. * monthNames string[12] - names of the months (optional)
  4470. * @return string - the date in the above format
  4471. */
  4472. formatDate: function (format, date, settings) {
  4473. if (!date) {
  4474. return "";
  4475. }
  4476. var iFormat,
  4477. dayNamesShort = (settings ? settings.dayNamesShort : null) || this._defaults.dayNamesShort,
  4478. dayNames = (settings ? settings.dayNames : null) || this._defaults.dayNames,
  4479. monthNamesShort = (settings ? settings.monthNamesShort : null) || this._defaults.monthNamesShort,
  4480. monthNames = (settings ? settings.monthNames : null) || this._defaults.monthNames,
  4481. // Check whether a format character is doubled
  4482. lookAhead = function(match) {
  4483. var matches = (iFormat + 1 < format.length && format.charAt(iFormat + 1) === match);
  4484. if (matches) {
  4485. iFormat++;
  4486. }
  4487. return matches;
  4488. },
  4489. // Format a number, with leading zero if necessary
  4490. formatNumber = function(match, value, len) {
  4491. var num = "" + value;
  4492. if (lookAhead(match)) {
  4493. while (num.length < len) {
  4494. num = "0" + num;
  4495. }
  4496. }
  4497. return num;
  4498. },
  4499. // Format a name, short or long as requested
  4500. formatName = function(match, value, shortNames, longNames) {
  4501. return (lookAhead(match) ? longNames[value] : shortNames[value]);
  4502. },
  4503. output = "",
  4504. literal = false;
  4505. if (date) {
  4506. for (iFormat = 0; iFormat < format.length; iFormat++) {
  4507. if (literal) {
  4508. if (format.charAt(iFormat) === "'" && !lookAhead("'")) {
  4509. literal = false;
  4510. } else {
  4511. output += format.charAt(iFormat);
  4512. }
  4513. } else {
  4514. switch (format.charAt(iFormat)) {
  4515. case "d":
  4516. output += formatNumber("d", date.getDate(), 2);
  4517. break;
  4518. case "D":
  4519. output += formatName("D", date.getDay(), dayNamesShort, dayNames);
  4520. break;
  4521. case "o":
  4522. output += formatNumber("o",
  4523. Math.round((new Date(date.getFullYear(), date.getMonth(), date.getDate()).getTime() - new Date(date.getFullYear(), 0, 0).getTime()) / 86400000), 3);
  4524. break;
  4525. case "m":
  4526. output += formatNumber("m", date.getMonth() + 1, 2);
  4527. break;
  4528. case "M":
  4529. output += formatName("M", date.getMonth(), monthNamesShort, monthNames);
  4530. break;
  4531. case "y":
  4532. output += (lookAhead("y") ? date.getFullYear() :
  4533. (date.getYear() % 100 < 10 ? "0" : "") + date.getYear() % 100);
  4534. break;
  4535. case "@":
  4536. output += date.getTime();
  4537. break;
  4538. case "!":
  4539. output += date.getTime() * 10000 + this._ticksTo1970;
  4540. break;
  4541. case "'":
  4542. if (lookAhead("'")) {
  4543. output += "'";
  4544. } else {
  4545. literal = true;
  4546. }
  4547. break;
  4548. default:
  4549. output += format.charAt(iFormat);
  4550. }
  4551. }
  4552. }
  4553. }
  4554. return output;
  4555. },
  4556. /* Extract all possible characters from the date format. */
  4557. _possibleChars: function (format) {
  4558. var iFormat,
  4559. chars = "",
  4560. literal = false,
  4561. // Check whether a format character is doubled
  4562. lookAhead = function(match) {
  4563. var matches = (iFormat + 1 < format.length && format.charAt(iFormat + 1) === match);
  4564. if (matches) {
  4565. iFormat++;
  4566. }
  4567. return matches;
  4568. };
  4569. for (iFormat = 0; iFormat < format.length; iFormat++) {
  4570. if (literal) {
  4571. if (format.charAt(iFormat) === "'" && !lookAhead("'")) {
  4572. literal = false;
  4573. } else {
  4574. chars += format.charAt(iFormat);
  4575. }
  4576. } else {
  4577. switch (format.charAt(iFormat)) {
  4578. case "d": case "m": case "y": case "@":
  4579. chars += "0123456789";
  4580. break;
  4581. case "D": case "M":
  4582. return null; // Accept anything
  4583. case "'":
  4584. if (lookAhead("'")) {
  4585. chars += "'";
  4586. } else {
  4587. literal = true;
  4588. }
  4589. break;
  4590. default:
  4591. chars += format.charAt(iFormat);
  4592. }
  4593. }
  4594. }
  4595. return chars;
  4596. },
  4597. /* Get a setting value, defaulting if necessary. */
  4598. _get: function(inst, name) {
  4599. return inst.settings[name] !== undefined ?
  4600. inst.settings[name] : this._defaults[name];
  4601. },
  4602. /* Parse existing date and initialise date picker. */
  4603. _setDateFromField: function(inst, noDefault) {
  4604. if (inst.input.val() === inst.lastVal) {
  4605. return;
  4606. }
  4607. var dateFormat = this._get(inst, "dateFormat"),
  4608. dates = inst.lastVal = inst.input ? inst.input.val() : null,
  4609. defaultDate = this._getDefaultDate(inst),
  4610. date = defaultDate,
  4611. settings = this._getFormatConfig(inst);
  4612. try {
  4613. date = this.parseDate(dateFormat, dates, settings) || defaultDate;
  4614. } catch (event) {
  4615. dates = (noDefault ? "" : dates);
  4616. }
  4617. inst.selectedDay = date.getDate();
  4618. inst.drawMonth = inst.selectedMonth = date.getMonth();
  4619. inst.drawYear = inst.selectedYear = date.getFullYear();
  4620. inst.currentDay = (dates ? date.getDate() : 0);
  4621. inst.currentMonth = (dates ? date.getMonth() : 0);
  4622. inst.currentYear = (dates ? date.getFullYear() : 0);
  4623. this._adjustInstDate(inst);
  4624. },
  4625. /* Retrieve the default date shown on opening. */
  4626. _getDefaultDate: function(inst) {
  4627. return this._restrictMinMax(inst,
  4628. this._determineDate(inst, this._get(inst, "defaultDate"), new Date()));
  4629. },
  4630. /* A date may be specified as an exact value or a relative one. */
  4631. _determineDate: function(inst, date, defaultDate) {
  4632. var offsetNumeric = function(offset) {
  4633. var date = new Date();
  4634. date.setDate(date.getDate() + offset);
  4635. return date;
  4636. },
  4637. offsetString = function(offset) {
  4638. try {
  4639. return $.datepicker.parseDate($.datepicker._get(inst, "dateFormat"),
  4640. offset, $.datepicker._getFormatConfig(inst));
  4641. }
  4642. catch (e) {
  4643. // Ignore
  4644. }
  4645. var date = (offset.toLowerCase().match(/^c/) ?
  4646. $.datepicker._getDate(inst) : null) || new Date(),
  4647. year = date.getFullYear(),
  4648. month = date.getMonth(),
  4649. day = date.getDate(),
  4650. pattern = /([+\-]?[0-9]+)\s*(d|D|w|W|m|M|y|Y)?/g,
  4651. matches = pattern.exec(offset);
  4652. while (matches) {
  4653. switch (matches[2] || "d") {
  4654. case "d" : case "D" :
  4655. day += parseInt(matches[1],10); break;
  4656. case "w" : case "W" :
  4657. day += parseInt(matches[1],10) * 7; break;
  4658. case "m" : case "M" :
  4659. month += parseInt(matches[1],10);
  4660. day = Math.min(day, $.datepicker._getDaysInMonth(year, month));
  4661. break;
  4662. case "y": case "Y" :
  4663. year += parseInt(matches[1],10);
  4664. day = Math.min(day, $.datepicker._getDaysInMonth(year, month));
  4665. break;
  4666. }
  4667. matches = pattern.exec(offset);
  4668. }
  4669. return new Date(year, month, day);
  4670. },
  4671. newDate = (date == null || date === "" ? defaultDate : (typeof date === "string" ? offsetString(date) :
  4672. (typeof date === "number" ? (isNaN(date) ? defaultDate : offsetNumeric(date)) : new Date(date.getTime()))));
  4673. newDate = (newDate && newDate.toString() === "Invalid Date" ? defaultDate : newDate);
  4674. if (newDate) {
  4675. newDate.setHours(0);
  4676. newDate.setMinutes(0);
  4677. newDate.setSeconds(0);
  4678. newDate.setMilliseconds(0);
  4679. }
  4680. return this._daylightSavingAdjust(newDate);
  4681. },
  4682. /* Handle switch to/from daylight saving.
  4683. * Hours may be non-zero on daylight saving cut-over:
  4684. * > 12 when midnight changeover, but then cannot generate
  4685. * midnight datetime, so jump to 1AM, otherwise reset.
  4686. * @param date (Date) the date to check
  4687. * @return (Date) the corrected date
  4688. */
  4689. _daylightSavingAdjust: function(date) {
  4690. if (!date) {
  4691. return null;
  4692. }
  4693. date.setHours(date.getHours() > 12 ? date.getHours() + 2 : 0);
  4694. return date;
  4695. },
  4696. /* Set the date(s) directly. */
  4697. _setDate: function(inst, date, noChange) {
  4698. var clear = !date,
  4699. origMonth = inst.selectedMonth,
  4700. origYear = inst.selectedYear,
  4701. newDate = this._restrictMinMax(inst, this._determineDate(inst, date, new Date()));
  4702. inst.selectedDay = inst.currentDay = newDate.getDate();
  4703. inst.drawMonth = inst.selectedMonth = inst.currentMonth = newDate.getMonth();
  4704. inst.drawYear = inst.selectedYear = inst.currentYear = newDate.getFullYear();
  4705. if ((origMonth !== inst.selectedMonth || origYear !== inst.selectedYear) && !noChange) {
  4706. this._notifyChange(inst);
  4707. }
  4708. this._adjustInstDate(inst);
  4709. if (inst.input) {
  4710. inst.input.val(clear ? "" : this._formatDate(inst));
  4711. }
  4712. },
  4713. /* Retrieve the date(s) directly. */
  4714. _getDate: function(inst) {
  4715. var startDate = (!inst.currentYear || (inst.input && inst.input.val() === "") ? null :
  4716. this._daylightSavingAdjust(new Date(
  4717. inst.currentYear, inst.currentMonth, inst.currentDay)));
  4718. return startDate;
  4719. },
  4720. /* Attach the onxxx handlers. These are declared statically so
  4721. * they work with static code transformers like Caja.
  4722. */
  4723. _attachHandlers: function(inst) {
  4724. var stepMonths = this._get(inst, "stepMonths"),
  4725. id = "#" + inst.id.replace( /\\\\/g, "\\" );
  4726. inst.dpDiv.find("[data-handler]").map(function () {
  4727. var handler = {
  4728. prev: function () {
  4729. $.datepicker._adjustDate(id, -stepMonths, "M");
  4730. },
  4731. next: function () {
  4732. $.datepicker._adjustDate(id, +stepMonths, "M");
  4733. },
  4734. hide: function () {
  4735. $.datepicker._hideDatepicker();
  4736. },
  4737. today: function () {
  4738. $.datepicker._gotoToday(id);
  4739. },
  4740. selectDay: function () {
  4741. $.datepicker._selectDay(id, +this.getAttribute("data-month"), +this.getAttribute("data-year"), this);
  4742. return false;
  4743. },
  4744. selectMonth: function () {
  4745. $.datepicker._selectMonthYear(id, this, "M");
  4746. return false;
  4747. },
  4748. selectYear: function () {
  4749. $.datepicker._selectMonthYear(id, this, "Y");
  4750. return false;
  4751. }
  4752. };
  4753. $(this).bind(this.getAttribute("data-event"), handler[this.getAttribute("data-handler")]);
  4754. });
  4755. },
  4756. /* Generate the HTML for the current state of the date picker. */
  4757. _generateHTML: function(inst) {
  4758. var maxDraw, prevText, prev, nextText, next, currentText, gotoDate,
  4759. controls, buttonPanel, firstDay, showWeek, dayNames, dayNamesMin,
  4760. monthNames, monthNamesShort, beforeShowDay, showOtherMonths,
  4761. selectOtherMonths, defaultDate, html, dow, row, group, col, selectedDate,
  4762. cornerClass, calender, thead, day, daysInMonth, leadDays, curRows, numRows,
  4763. printDate, dRow, tbody, daySettings, otherMonth, unselectable,
  4764. tempDate = new Date(),
  4765. today = this._daylightSavingAdjust(
  4766. new Date(tempDate.getFullYear(), tempDate.getMonth(), tempDate.getDate())), // clear time
  4767. isRTL = this._get(inst, "isRTL"),
  4768. showButtonPanel = this._get(inst, "showButtonPanel"),
  4769. hideIfNoPrevNext = this._get(inst, "hideIfNoPrevNext"),
  4770. navigationAsDateFormat = this._get(inst, "navigationAsDateFormat"),
  4771. numMonths = this._getNumberOfMonths(inst),
  4772. showCurrentAtPos = this._get(inst, "showCurrentAtPos"),
  4773. stepMonths = this._get(inst, "stepMonths"),
  4774. isMultiMonth = (numMonths[0] !== 1 || numMonths[1] !== 1),
  4775. currentDate = this._daylightSavingAdjust((!inst.currentDay ? new Date(9999, 9, 9) :
  4776. new Date(inst.currentYear, inst.currentMonth, inst.currentDay))),
  4777. minDate = this._getMinMaxDate(inst, "min"),
  4778. maxDate = this._getMinMaxDate(inst, "max"),
  4779. drawMonth = inst.drawMonth - showCurrentAtPos,
  4780. drawYear = inst.drawYear;
  4781. if (drawMonth < 0) {
  4782. drawMonth += 12;
  4783. drawYear--;
  4784. }
  4785. if (maxDate) {
  4786. maxDraw = this._daylightSavingAdjust(new Date(maxDate.getFullYear(),
  4787. maxDate.getMonth() - (numMonths[0] * numMonths[1]) + 1, maxDate.getDate()));
  4788. maxDraw = (minDate && maxDraw < minDate ? minDate : maxDraw);
  4789. while (this._daylightSavingAdjust(new Date(drawYear, drawMonth, 1)) > maxDraw) {
  4790. drawMonth--;
  4791. if (drawMonth < 0) {
  4792. drawMonth = 11;
  4793. drawYear--;
  4794. }
  4795. }
  4796. }
  4797. inst.drawMonth = drawMonth;
  4798. inst.drawYear = drawYear;
  4799. prevText = this._get(inst, "prevText");
  4800. prevText = (!navigationAsDateFormat ? prevText : this.formatDate(prevText,
  4801. this._daylightSavingAdjust(new Date(drawYear, drawMonth - stepMonths, 1)),
  4802. this._getFormatConfig(inst)));
  4803. prev = (this._canAdjustMonth(inst, -1, drawYear, drawMonth) ?
  4804. "<a class='ui-datepicker-prev ui-corner-all' data-handler='prev' data-event='click'" +
  4805. " title='" + prevText + "'><span class='ui-icon ui-icon-circle-triangle-" + ( isRTL ? "e" : "w") + "'>" + prevText + "</span></a>" :
  4806. (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>"));
  4807. nextText = this._get(inst, "nextText");
  4808. nextText = (!navigationAsDateFormat ? nextText : this.formatDate(nextText,
  4809. this._daylightSavingAdjust(new Date(drawYear, drawMonth + stepMonths, 1)),
  4810. this._getFormatConfig(inst)));
  4811. next = (this._canAdjustMonth(inst, +1, drawYear, drawMonth) ?
  4812. "<a class='ui-datepicker-next ui-corner-all' data-handler='next' data-event='click'" +
  4813. " title='" + nextText + "'><span class='ui-icon ui-icon-circle-triangle-" + ( isRTL ? "w" : "e") + "'>" + nextText + "</span></a>" :
  4814. (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>"));
  4815. currentText = this._get(inst, "currentText");
  4816. gotoDate = (this._get(inst, "gotoCurrent") && inst.currentDay ? currentDate : today);
  4817. currentText = (!navigationAsDateFormat ? currentText :
  4818. this.formatDate(currentText, gotoDate, this._getFormatConfig(inst)));
  4819. 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'>" +
  4820. this._get(inst, "closeText") + "</button>" : "");
  4821. buttonPanel = (showButtonPanel) ? "<div class='ui-datepicker-buttonpane ui-widget-content'>" + (isRTL ? controls : "") +
  4822. (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'" +
  4823. ">" + currentText + "</button>" : "") + (isRTL ? "" : controls) + "</div>" : "";
  4824. firstDay = parseInt(this._get(inst, "firstDay"),10);
  4825. firstDay = (isNaN(firstDay) ? 0 : firstDay);
  4826. showWeek = this._get(inst, "showWeek");
  4827. dayNames = this._get(inst, "dayNames");
  4828. dayNamesMin = this._get(inst, "dayNamesMin");
  4829. monthNames = this._get(inst, "monthNames");
  4830. monthNamesShort = this._get(inst, "monthNamesShort");
  4831. beforeShowDay = this._get(inst, "beforeShowDay");
  4832. showOtherMonths = this._get(inst, "showOtherMonths");
  4833. selectOtherMonths = this._get(inst, "selectOtherMonths");
  4834. defaultDate = this._getDefaultDate(inst);
  4835. html = "";
  4836. dow;
  4837. for (row = 0; row < numMonths[0]; row++) {
  4838. group = "";
  4839. this.maxRows = 4;
  4840. for (col = 0; col < numMonths[1]; col++) {
  4841. selectedDate = this._daylightSavingAdjust(new Date(drawYear, drawMonth, inst.selectedDay));
  4842. cornerClass = " ui-corner-all";
  4843. calender = "";
  4844. if (isMultiMonth) {
  4845. calender += "<div class='ui-datepicker-group";
  4846. if (numMonths[1] > 1) {
  4847. switch (col) {
  4848. case 0: calender += " ui-datepicker-group-first";
  4849. cornerClass = " ui-corner-" + (isRTL ? "right" : "left"); break;
  4850. case numMonths[1]-1: calender += " ui-datepicker-group-last";
  4851. cornerClass = " ui-corner-" + (isRTL ? "left" : "right"); break;
  4852. default: calender += " ui-datepicker-group-middle"; cornerClass = ""; break;
  4853. }
  4854. }
  4855. calender += "'>";
  4856. }
  4857. calender += "<div class='ui-datepicker-header ui-widget-header ui-helper-clearfix" + cornerClass + "'>" +
  4858. (/all|left/.test(cornerClass) && row === 0 ? (isRTL ? next : prev) : "") +
  4859. (/all|right/.test(cornerClass) && row === 0 ? (isRTL ? prev : next) : "") +
  4860. this._generateMonthYearHeader(inst, drawMonth, drawYear, minDate, maxDate,
  4861. row > 0 || col > 0, monthNames, monthNamesShort) + // draw month headers
  4862. "</div><table class='ui-datepicker-calendar'><thead>" +
  4863. "<tr>";
  4864. thead = (showWeek ? "<th class='ui-datepicker-week-col'>" + this._get(inst, "weekHeader") + "</th>" : "");
  4865. for (dow = 0; dow < 7; dow++) { // days of the week
  4866. day = (dow + firstDay) % 7;
  4867. thead += "<th scope='col'" + ((dow + firstDay + 6) % 7 >= 5 ? " class='ui-datepicker-week-end'" : "") + ">" +
  4868. "<span title='" + dayNames[day] + "'>" + dayNamesMin[day] + "</span></th>";
  4869. }
  4870. calender += thead + "</tr></thead><tbody>";
  4871. daysInMonth = this._getDaysInMonth(drawYear, drawMonth);
  4872. if (drawYear === inst.selectedYear && drawMonth === inst.selectedMonth) {
  4873. inst.selectedDay = Math.min(inst.selectedDay, daysInMonth);
  4874. }
  4875. leadDays = (this._getFirstDayOfMonth(drawYear, drawMonth) - firstDay + 7) % 7;
  4876. curRows = Math.ceil((leadDays + daysInMonth) / 7); // calculate the number of rows to generate
  4877. numRows = (isMultiMonth ? this.maxRows > curRows ? this.maxRows : curRows : curRows); //If multiple months, use the higher number of rows (see #7043)
  4878. this.maxRows = numRows;
  4879. printDate = this._daylightSavingAdjust(new Date(drawYear, drawMonth, 1 - leadDays));
  4880. for (dRow = 0; dRow < numRows; dRow++) { // create date picker rows
  4881. calender += "<tr>";
  4882. tbody = (!showWeek ? "" : "<td class='ui-datepicker-week-col'>" +
  4883. this._get(inst, "calculateWeek")(printDate) + "</td>");
  4884. for (dow = 0; dow < 7; dow++) { // create date picker days
  4885. daySettings = (beforeShowDay ?
  4886. beforeShowDay.apply((inst.input ? inst.input[0] : null), [printDate]) : [true, ""]);
  4887. otherMonth = (printDate.getMonth() !== drawMonth);
  4888. unselectable = (otherMonth && !selectOtherMonths) || !daySettings[0] ||
  4889. (minDate && printDate < minDate) || (maxDate && printDate > maxDate);
  4890. tbody += "<td class='" +
  4891. ((dow + firstDay + 6) % 7 >= 5 ? " ui-datepicker-week-end" : "") + // highlight weekends
  4892. (otherMonth ? " ui-datepicker-other-month" : "") + // highlight days from other months
  4893. ((printDate.getTime() === selectedDate.getTime() && drawMonth === inst.selectedMonth && inst._keyEvent) || // user pressed key
  4894. (defaultDate.getTime() === printDate.getTime() && defaultDate.getTime() === selectedDate.getTime()) ?
  4895. // or defaultDate is current printedDate and defaultDate is selectedDate
  4896. " " + this._dayOverClass : "") + // highlight selected day
  4897. (unselectable ? " " + this._unselectableClass + " ui-state-disabled": "") + // highlight unselectable days
  4898. (otherMonth && !showOtherMonths ? "" : " " + daySettings[1] + // highlight custom dates
  4899. (printDate.getTime() === currentDate.getTime() ? " " + this._currentClass : "") + // highlight selected day
  4900. (printDate.getTime() === today.getTime() ? " ui-datepicker-today" : "")) + "'" + // highlight today (if different)
  4901. ((!otherMonth || showOtherMonths) && daySettings[2] ? " title='" + daySettings[2].replace(/'/g, "&#39;") + "'" : "") + // cell title
  4902. (unselectable ? "" : " data-handler='selectDay' data-event='click' data-month='" + printDate.getMonth() + "' data-year='" + printDate.getFullYear() + "'") + ">" + // actions
  4903. (otherMonth && !showOtherMonths ? "&#xa0;" : // display for other months
  4904. (unselectable ? "<span class='ui-state-default'>" + printDate.getDate() + "</span>" : "<a class='ui-state-default" +
  4905. (printDate.getTime() === today.getTime() ? " ui-state-highlight" : "") +
  4906. (printDate.getTime() === currentDate.getTime() ? " ui-state-active" : "") + // highlight selected day
  4907. (otherMonth ? " ui-priority-secondary" : "") + // distinguish dates from other months
  4908. "' href='#'>" + printDate.getDate() + "</a>")) + "</td>"; // display selectable date
  4909. printDate.setDate(printDate.getDate() + 1);
  4910. printDate = this._daylightSavingAdjust(printDate);
  4911. }
  4912. calender += tbody + "</tr>";
  4913. }
  4914. drawMonth++;
  4915. if (drawMonth > 11) {
  4916. drawMonth = 0;
  4917. drawYear++;
  4918. }
  4919. calender += "</tbody></table>" + (isMultiMonth ? "</div>" +
  4920. ((numMonths[0] > 0 && col === numMonths[1]-1) ? "<div class='ui-datepicker-row-break'></div>" : "") : "");
  4921. group += calender;
  4922. }
  4923. html += group;
  4924. }
  4925. html += buttonPanel;
  4926. inst._keyEvent = false;
  4927. return html;
  4928. },
  4929. /* Generate the month and year header. */
  4930. _generateMonthYearHeader: function(inst, drawMonth, drawYear, minDate, maxDate,
  4931. secondary, monthNames, monthNamesShort) {
  4932. var inMinYear, inMaxYear, month, years, thisYear, determineYear, year, endYear,
  4933. changeMonth = this._get(inst, "changeMonth"),
  4934. changeYear = this._get(inst, "changeYear"),
  4935. showMonthAfterYear = this._get(inst, "showMonthAfterYear"),
  4936. html = "<div class='ui-datepicker-title'>",
  4937. monthHtml = "";
  4938. // month selection
  4939. if (secondary || !changeMonth) {
  4940. monthHtml += "<span class='ui-datepicker-month'>" + monthNames[drawMonth] + "</span>";
  4941. } else {
  4942. inMinYear = (minDate && minDate.getFullYear() === drawYear);
  4943. inMaxYear = (maxDate && maxDate.getFullYear() === drawYear);
  4944. monthHtml += "<select class='ui-datepicker-month' data-handler='selectMonth' data-event='change'>";
  4945. for ( month = 0; month < 12; month++) {
  4946. if ((!inMinYear || month >= minDate.getMonth()) && (!inMaxYear || month <= maxDate.getMonth())) {
  4947. monthHtml += "<option value='" + month + "'" +
  4948. (month === drawMonth ? " selected='selected'" : "") +
  4949. ">" + monthNamesShort[month] + "</option>";
  4950. }
  4951. }
  4952. monthHtml += "</select>";
  4953. }
  4954. if (!showMonthAfterYear) {
  4955. html += monthHtml + (secondary || !(changeMonth && changeYear) ? "&#xa0;" : "");
  4956. }
  4957. // year selection
  4958. if ( !inst.yearshtml ) {
  4959. inst.yearshtml = "";
  4960. if (secondary || !changeYear) {
  4961. html += "<span class='ui-datepicker-year'>" + drawYear + "</span>";
  4962. } else {
  4963. // determine range of years to display
  4964. years = this._get(inst, "yearRange").split(":");
  4965. thisYear = new Date().getFullYear();
  4966. determineYear = function(value) {
  4967. var year = (value.match(/c[+\-].*/) ? drawYear + parseInt(value.substring(1), 10) :
  4968. (value.match(/[+\-].*/) ? thisYear + parseInt(value, 10) :
  4969. parseInt(value, 10)));
  4970. return (isNaN(year) ? thisYear : year);
  4971. };
  4972. year = determineYear(years[0]);
  4973. endYear = Math.max(year, determineYear(years[1] || ""));
  4974. year = (minDate ? Math.max(year, minDate.getFullYear()) : year);
  4975. endYear = (maxDate ? Math.min(endYear, maxDate.getFullYear()) : endYear);
  4976. inst.yearshtml += "<select class='ui-datepicker-year' data-handler='selectYear' data-event='change'>";
  4977. for (; year <= endYear; year++) {
  4978. inst.yearshtml += "<option value='" + year + "'" +
  4979. (year === drawYear ? " selected='selected'" : "") +
  4980. ">" + year + "</option>";
  4981. }
  4982. inst.yearshtml += "</select>";
  4983. html += inst.yearshtml;
  4984. inst.yearshtml = null;
  4985. }
  4986. }
  4987. html += this._get(inst, "yearSuffix");
  4988. if (showMonthAfterYear) {
  4989. html += (secondary || !(changeMonth && changeYear) ? "&#xa0;" : "") + monthHtml;
  4990. }
  4991. html += "</div>"; // Close datepicker_header
  4992. return html;
  4993. },
  4994. /* Adjust one of the date sub-fields. */
  4995. _adjustInstDate: function(inst, offset, period) {
  4996. var year = inst.drawYear + (period === "Y" ? offset : 0),
  4997. month = inst.drawMonth + (period === "M" ? offset : 0),
  4998. day = Math.min(inst.selectedDay, this._getDaysInMonth(year, month)) + (period === "D" ? offset : 0),
  4999. date = this._restrictMinMax(inst, this._daylightSavingAdjust(new Date(year, month, day)));
  5000. inst.selectedDay = date.getDate();
  5001. inst.drawMonth = inst.selectedMonth = date.getMonth();
  5002. inst.drawYear = inst.selectedYear = date.getFullYear();
  5003. if (period === "M" || period === "Y") {
  5004. this._notifyChange(inst);
  5005. }
  5006. },
  5007. /* Ensure a date is within any min/max bounds. */
  5008. _restrictMinMax: function(inst, date) {
  5009. var minDate = this._getMinMaxDate(inst, "min"),
  5010. maxDate = this._getMinMaxDate(inst, "max"),
  5011. newDate = (minDate && date < minDate ? minDate : date);
  5012. return (maxDate && newDate > maxDate ? maxDate : newDate);
  5013. },
  5014. /* Notify change of month/year. */
  5015. _notifyChange: function(inst) {
  5016. var onChange = this._get(inst, "onChangeMonthYear");
  5017. if (onChange) {
  5018. onChange.apply((inst.input ? inst.input[0] : null),
  5019. [inst.selectedYear, inst.selectedMonth + 1, inst]);
  5020. }
  5021. },
  5022. /* Determine the number of months to show. */
  5023. _getNumberOfMonths: function(inst) {
  5024. var numMonths = this._get(inst, "numberOfMonths");
  5025. return (numMonths == null ? [1, 1] : (typeof numMonths === "number" ? [1, numMonths] : numMonths));
  5026. },
  5027. /* Determine the current maximum date - ensure no time components are set. */
  5028. _getMinMaxDate: function(inst, minMax) {
  5029. return this._determineDate(inst, this._get(inst, minMax + "Date"), null);
  5030. },
  5031. /* Find the number of days in a given month. */
  5032. _getDaysInMonth: function(year, month) {
  5033. return 32 - this._daylightSavingAdjust(new Date(year, month, 32)).getDate();
  5034. },
  5035. /* Find the day of the week of the first of a month. */
  5036. _getFirstDayOfMonth: function(year, month) {
  5037. return new Date(year, month, 1).getDay();
  5038. },
  5039. /* Determines if we should allow a "next/prev" month display change. */
  5040. _canAdjustMonth: function(inst, offset, curYear, curMonth) {
  5041. var numMonths = this._getNumberOfMonths(inst),
  5042. date = this._daylightSavingAdjust(new Date(curYear,
  5043. curMonth + (offset < 0 ? offset : numMonths[0] * numMonths[1]), 1));
  5044. if (offset < 0) {
  5045. date.setDate(this._getDaysInMonth(date.getFullYear(), date.getMonth()));
  5046. }
  5047. return this._isInRange(inst, date);
  5048. },
  5049. /* Is the given date in the accepted range? */
  5050. _isInRange: function(inst, date) {
  5051. var yearSplit, currentYear,
  5052. minDate = this._getMinMaxDate(inst, "min"),
  5053. maxDate = this._getMinMaxDate(inst, "max"),
  5054. minYear = null,
  5055. maxYear = null,
  5056. years = this._get(inst, "yearRange");
  5057. if (years){
  5058. yearSplit = years.split(":");
  5059. currentYear = new Date().getFullYear();
  5060. minYear = parseInt(yearSplit[0], 10);
  5061. maxYear = parseInt(yearSplit[1], 10);
  5062. if ( yearSplit[0].match(/[+\-].*/) ) {
  5063. minYear += currentYear;
  5064. }
  5065. if ( yearSplit[1].match(/[+\-].*/) ) {
  5066. maxYear += currentYear;
  5067. }
  5068. }
  5069. return ((!minDate || date.getTime() >= minDate.getTime()) &&
  5070. (!maxDate || date.getTime() <= maxDate.getTime()) &&
  5071. (!minYear || date.getFullYear() >= minYear) &&
  5072. (!maxYear || date.getFullYear() <= maxYear));
  5073. },
  5074. /* Provide the configuration settings for formatting/parsing. */
  5075. _getFormatConfig: function(inst) {
  5076. var shortYearCutoff = this._get(inst, "shortYearCutoff");
  5077. shortYearCutoff = (typeof shortYearCutoff !== "string" ? shortYearCutoff :
  5078. new Date().getFullYear() % 100 + parseInt(shortYearCutoff, 10));
  5079. return {shortYearCutoff: shortYearCutoff,
  5080. dayNamesShort: this._get(inst, "dayNamesShort"), dayNames: this._get(inst, "dayNames"),
  5081. monthNamesShort: this._get(inst, "monthNamesShort"), monthNames: this._get(inst, "monthNames")};
  5082. },
  5083. /* Format the given date for display. */
  5084. _formatDate: function(inst, day, month, year) {
  5085. if (!day) {
  5086. inst.currentDay = inst.selectedDay;
  5087. inst.currentMonth = inst.selectedMonth;
  5088. inst.currentYear = inst.selectedYear;
  5089. }
  5090. var date = (day ? (typeof day === "object" ? day :
  5091. this._daylightSavingAdjust(new Date(year, month, day))) :
  5092. this._daylightSavingAdjust(new Date(inst.currentYear, inst.currentMonth, inst.currentDay)));
  5093. return this.formatDate(this._get(inst, "dateFormat"), date, this._getFormatConfig(inst));
  5094. }
  5095. });
  5096. /*
  5097. * Bind hover events for datepicker elements.
  5098. * Done via delegate so the binding only occurs once in the lifetime of the parent div.
  5099. * Global datepicker_instActive, set by _updateDatepicker allows the handlers to find their way back to the active picker.
  5100. */
  5101. function datepicker_bindHover(dpDiv) {
  5102. var selector = "button, .ui-datepicker-prev, .ui-datepicker-next, .ui-datepicker-calendar td a";
  5103. return dpDiv.delegate(selector, "mouseout", function() {
  5104. $(this).removeClass("ui-state-hover");
  5105. if (this.className.indexOf("ui-datepicker-prev") !== -1) {
  5106. $(this).removeClass("ui-datepicker-prev-hover");
  5107. }
  5108. if (this.className.indexOf("ui-datepicker-next") !== -1) {
  5109. $(this).removeClass("ui-datepicker-next-hover");
  5110. }
  5111. })
  5112. .delegate( selector, "mouseover", datepicker_handleMouseover );
  5113. }
  5114. function datepicker_handleMouseover() {
  5115. if (!$.datepicker._isDisabledDatepicker( datepicker_instActive.inline? datepicker_instActive.dpDiv.parent()[0] : datepicker_instActive.input[0])) {
  5116. $(this).parents(".ui-datepicker-calendar").find("a").removeClass("ui-state-hover");
  5117. $(this).addClass("ui-state-hover");
  5118. if (this.className.indexOf("ui-datepicker-prev") !== -1) {
  5119. $(this).addClass("ui-datepicker-prev-hover");
  5120. }
  5121. if (this.className.indexOf("ui-datepicker-next") !== -1) {
  5122. $(this).addClass("ui-datepicker-next-hover");
  5123. }
  5124. }
  5125. }
  5126. /* jQuery extend now ignores nulls! */
  5127. function datepicker_extendRemove(target, props) {
  5128. $.extend(target, props);
  5129. for (var name in props) {
  5130. if (props[name] == null) {
  5131. target[name] = props[name];
  5132. }
  5133. }
  5134. return target;
  5135. }
  5136. /* Invoke the datepicker functionality.
  5137. @param options string - a command, optionally followed by additional parameters or
  5138. Object - settings for attaching new datepicker functionality
  5139. @return jQuery object */
  5140. $.fn.datepicker = function(options){
  5141. /* Verify an empty collection wasn't passed - Fixes #6976 */
  5142. if ( !this.length ) {
  5143. return this;
  5144. }
  5145. /* Initialise the date picker. */
  5146. if (!$.datepicker.initialized) {
  5147. $(document).mousedown($.datepicker._checkExternalClick);
  5148. $.datepicker.initialized = true;
  5149. }
  5150. /* Append datepicker main container to body if not exist. */
  5151. if ($("#"+$.datepicker._mainDivId).length === 0) {
  5152. $("body").append($.datepicker.dpDiv);
  5153. }
  5154. var otherArgs = Array.prototype.slice.call(arguments, 1);
  5155. if (typeof options === "string" && (options === "isDisabled" || options === "getDate" || options === "widget")) {
  5156. return $.datepicker["_" + options + "Datepicker"].
  5157. apply($.datepicker, [this[0]].concat(otherArgs));
  5158. }
  5159. if (options === "option" && arguments.length === 2 && typeof arguments[1] === "string") {
  5160. return $.datepicker["_" + options + "Datepicker"].
  5161. apply($.datepicker, [this[0]].concat(otherArgs));
  5162. }
  5163. return this.each(function() {
  5164. typeof options === "string" ?
  5165. $.datepicker["_" + options + "Datepicker"].
  5166. apply($.datepicker, [this].concat(otherArgs)) :
  5167. $.datepicker._attachDatepicker(this, options);
  5168. });
  5169. };
  5170. $.datepicker = new Datepicker(); // singleton instance
  5171. $.datepicker.initialized = false;
  5172. $.datepicker.uuid = new Date().getTime();
  5173. $.datepicker.version = "1.11.2";
  5174. var datepicker = $.datepicker;
  5175. /*!
  5176. * jQuery UI Draggable 1.11.2
  5177. * http://jqueryui.com
  5178. *
  5179. * Copyright 2014 jQuery Foundation and other contributors
  5180. * Released under the MIT license.
  5181. * http://jquery.org/license
  5182. *
  5183. * http://api.jqueryui.com/draggable/
  5184. */
  5185. $.widget("ui.draggable", $.ui.mouse, {
  5186. version: "1.11.2",
  5187. widgetEventPrefix: "drag",
  5188. options: {
  5189. addClasses: true,
  5190. appendTo: "parent",
  5191. axis: false,
  5192. connectToSortable: false,
  5193. containment: false,
  5194. cursor: "auto",
  5195. cursorAt: false,
  5196. grid: false,
  5197. handle: false,
  5198. helper: "original",
  5199. iframeFix: false,
  5200. opacity: false,
  5201. refreshPositions: false,
  5202. revert: false,
  5203. revertDuration: 500,
  5204. scope: "default",
  5205. scroll: true,
  5206. scrollSensitivity: 20,
  5207. scrollSpeed: 20,
  5208. snap: false,
  5209. snapMode: "both",
  5210. snapTolerance: 20,
  5211. stack: false,
  5212. zIndex: false,
  5213. // callbacks
  5214. drag: null,
  5215. start: null,
  5216. stop: null
  5217. },
  5218. _create: function() {
  5219. if ( this.options.helper === "original" ) {
  5220. this._setPositionRelative();
  5221. }
  5222. if (this.options.addClasses){
  5223. this.element.addClass("ui-draggable");
  5224. }
  5225. if (this.options.disabled){
  5226. this.element.addClass("ui-draggable-disabled");
  5227. }
  5228. this._setHandleClassName();
  5229. this._mouseInit();
  5230. },
  5231. _setOption: function( key, value ) {
  5232. this._super( key, value );
  5233. if ( key === "handle" ) {
  5234. this._removeHandleClassName();
  5235. this._setHandleClassName();
  5236. }
  5237. },
  5238. _destroy: function() {
  5239. if ( ( this.helper || this.element ).is( ".ui-draggable-dragging" ) ) {
  5240. this.destroyOnClear = true;
  5241. return;
  5242. }
  5243. this.element.removeClass( "ui-draggable ui-draggable-dragging ui-draggable-disabled" );
  5244. this._removeHandleClassName();
  5245. this._mouseDestroy();
  5246. },
  5247. _mouseCapture: function(event) {
  5248. var o = this.options;
  5249. this._blurActiveElement( event );
  5250. // among others, prevent a drag on a resizable-handle
  5251. if (this.helper || o.disabled || $(event.target).closest(".ui-resizable-handle").length > 0) {
  5252. return false;
  5253. }
  5254. //Quit if we're not on a valid handle
  5255. this.handle = this._getHandle(event);
  5256. if (!this.handle) {
  5257. return false;
  5258. }
  5259. this._blockFrames( o.iframeFix === true ? "iframe" : o.iframeFix );
  5260. return true;
  5261. },
  5262. _blockFrames: function( selector ) {
  5263. this.iframeBlocks = this.document.find( selector ).map(function() {
  5264. var iframe = $( this );
  5265. return $( "<div>" )
  5266. .css( "position", "absolute" )
  5267. .appendTo( iframe.parent() )
  5268. .outerWidth( iframe.outerWidth() )
  5269. .outerHeight( iframe.outerHeight() )
  5270. .offset( iframe.offset() )[ 0 ];
  5271. });
  5272. },
  5273. _unblockFrames: function() {
  5274. if ( this.iframeBlocks ) {
  5275. this.iframeBlocks.remove();
  5276. delete this.iframeBlocks;
  5277. }
  5278. },
  5279. _blurActiveElement: function( event ) {
  5280. var document = this.document[ 0 ];
  5281. // Only need to blur if the event occurred on the draggable itself, see #10527
  5282. if ( !this.handleElement.is( event.target ) ) {
  5283. return;
  5284. }
  5285. // support: IE9
  5286. // IE9 throws an "Unspecified error" accessing document.activeElement from an <iframe>
  5287. try {
  5288. // Support: IE9, IE10
  5289. // If the <body> is blurred, IE will switch windows, see #9520
  5290. if ( document.activeElement && document.activeElement.nodeName.toLowerCase() !== "body" ) {
  5291. // Blur any element that currently has focus, see #4261
  5292. $( document.activeElement ).blur();
  5293. }
  5294. } catch ( error ) {}
  5295. },
  5296. _mouseStart: function(event) {
  5297. var o = this.options;
  5298. //Create and append the visible helper
  5299. this.helper = this._createHelper(event);
  5300. this.helper.addClass("ui-draggable-dragging");
  5301. //Cache the helper size
  5302. this._cacheHelperProportions();
  5303. //If ddmanager is used for droppables, set the global draggable
  5304. if ($.ui.ddmanager) {
  5305. $.ui.ddmanager.current = this;
  5306. }
  5307. /*
  5308. * - Position generation -
  5309. * This block generates everything position related - it's the core of draggables.
  5310. */
  5311. //Cache the margins of the original element
  5312. this._cacheMargins();
  5313. //Store the helper's css position
  5314. this.cssPosition = this.helper.css( "position" );
  5315. this.scrollParent = this.helper.scrollParent( true );
  5316. this.offsetParent = this.helper.offsetParent();
  5317. this.hasFixedAncestor = this.helper.parents().filter(function() {
  5318. return $( this ).css( "position" ) === "fixed";
  5319. }).length > 0;
  5320. //The element's absolute position on the page minus margins
  5321. this.positionAbs = this.element.offset();
  5322. this._refreshOffsets( event );
  5323. //Generate the original position
  5324. this.originalPosition = this.position = this._generatePosition( event, false );
  5325. this.originalPageX = event.pageX;
  5326. this.originalPageY = event.pageY;
  5327. //Adjust the mouse offset relative to the helper if "cursorAt" is supplied
  5328. (o.cursorAt && this._adjustOffsetFromHelper(o.cursorAt));
  5329. //Set a containment if given in the options
  5330. this._setContainment();
  5331. //Trigger event + callbacks
  5332. if (this._trigger("start", event) === false) {
  5333. this._clear();
  5334. return false;
  5335. }
  5336. //Recache the helper size
  5337. this._cacheHelperProportions();
  5338. //Prepare the droppable offsets
  5339. if ($.ui.ddmanager && !o.dropBehaviour) {
  5340. $.ui.ddmanager.prepareOffsets(this, event);
  5341. }
  5342. // Reset helper's right/bottom css if they're set and set explicit width/height instead
  5343. // as this prevents resizing of elements with right/bottom set (see #7772)
  5344. this._normalizeRightBottom();
  5345. this._mouseDrag(event, true); //Execute the drag once - this causes the helper not to be visible before getting its correct position
  5346. //If the ddmanager is used for droppables, inform the manager that dragging has started (see #5003)
  5347. if ( $.ui.ddmanager ) {
  5348. $.ui.ddmanager.dragStart(this, event);
  5349. }
  5350. return true;
  5351. },
  5352. _refreshOffsets: function( event ) {
  5353. this.offset = {
  5354. top: this.positionAbs.top - this.margins.top,
  5355. left: this.positionAbs.left - this.margins.left,
  5356. scroll: false,
  5357. parent: this._getParentOffset(),
  5358. relative: this._getRelativeOffset()
  5359. };
  5360. this.offset.click = {
  5361. left: event.pageX - this.offset.left,
  5362. top: event.pageY - this.offset.top
  5363. };
  5364. },
  5365. _mouseDrag: function(event, noPropagation) {
  5366. // reset any necessary cached properties (see #5009)
  5367. if ( this.hasFixedAncestor ) {
  5368. this.offset.parent = this._getParentOffset();
  5369. }
  5370. //Compute the helpers position
  5371. this.position = this._generatePosition( event, true );
  5372. this.positionAbs = this._convertPositionTo("absolute");
  5373. //Call plugins and callbacks and use the resulting position if something is returned
  5374. if (!noPropagation) {
  5375. var ui = this._uiHash();
  5376. if (this._trigger("drag", event, ui) === false) {
  5377. this._mouseUp({});
  5378. return false;
  5379. }
  5380. this.position = ui.position;
  5381. }
  5382. this.helper[ 0 ].style.left = this.position.left + "px";
  5383. this.helper[ 0 ].style.top = this.position.top + "px";
  5384. if ($.ui.ddmanager) {
  5385. $.ui.ddmanager.drag(this, event);
  5386. }
  5387. return false;
  5388. },
  5389. _mouseStop: function(event) {
  5390. //If we are using droppables, inform the manager about the drop
  5391. var that = this,
  5392. dropped = false;
  5393. if ($.ui.ddmanager && !this.options.dropBehaviour) {
  5394. dropped = $.ui.ddmanager.drop(this, event);
  5395. }
  5396. //if a drop comes from outside (a sortable)
  5397. if (this.dropped) {
  5398. dropped = this.dropped;
  5399. this.dropped = false;
  5400. }
  5401. 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))) {
  5402. $(this.helper).animate(this.originalPosition, parseInt(this.options.revertDuration, 10), function() {
  5403. if (that._trigger("stop", event) !== false) {
  5404. that._clear();
  5405. }
  5406. });
  5407. } else {
  5408. if (this._trigger("stop", event) !== false) {
  5409. this._clear();
  5410. }
  5411. }
  5412. return false;
  5413. },
  5414. _mouseUp: function( event ) {
  5415. this._unblockFrames();
  5416. //If the ddmanager is used for droppables, inform the manager that dragging has stopped (see #5003)
  5417. if ( $.ui.ddmanager ) {
  5418. $.ui.ddmanager.dragStop(this, event);
  5419. }
  5420. // Only need to focus if the event occurred on the draggable itself, see #10527
  5421. if ( this.handleElement.is( event.target ) ) {
  5422. // The interaction is over; whether or not the click resulted in a drag, focus the element
  5423. this.element.focus();
  5424. }
  5425. return $.ui.mouse.prototype._mouseUp.call(this, event);
  5426. },
  5427. cancel: function() {
  5428. if (this.helper.is(".ui-draggable-dragging")) {
  5429. this._mouseUp({});
  5430. } else {
  5431. this._clear();
  5432. }
  5433. return this;
  5434. },
  5435. _getHandle: function(event) {
  5436. return this.options.handle ?
  5437. !!$( event.target ).closest( this.element.find( this.options.handle ) ).length :
  5438. true;
  5439. },
  5440. _setHandleClassName: function() {
  5441. this.handleElement = this.options.handle ?
  5442. this.element.find( this.options.handle ) : this.element;
  5443. this.handleElement.addClass( "ui-draggable-handle" );
  5444. },
  5445. _removeHandleClassName: function() {
  5446. this.handleElement.removeClass( "ui-draggable-handle" );
  5447. },
  5448. _createHelper: function(event) {
  5449. var o = this.options,
  5450. helperIsFunction = $.isFunction( o.helper ),
  5451. helper = helperIsFunction ?
  5452. $( o.helper.apply( this.element[ 0 ], [ event ] ) ) :
  5453. ( o.helper === "clone" ?
  5454. this.element.clone().removeAttr( "id" ) :
  5455. this.element );
  5456. if (!helper.parents("body").length) {
  5457. helper.appendTo((o.appendTo === "parent" ? this.element[0].parentNode : o.appendTo));
  5458. }
  5459. // http://bugs.jqueryui.com/ticket/9446
  5460. // a helper function can return the original element
  5461. // which wouldn't have been set to relative in _create
  5462. if ( helperIsFunction && helper[ 0 ] === this.element[ 0 ] ) {
  5463. this._setPositionRelative();
  5464. }
  5465. if (helper[0] !== this.element[0] && !(/(fixed|absolute)/).test(helper.css("position"))) {
  5466. helper.css("position", "absolute");
  5467. }
  5468. return helper;
  5469. },
  5470. _setPositionRelative: function() {
  5471. if ( !( /^(?:r|a|f)/ ).test( this.element.css( "position" ) ) ) {
  5472. this.element[ 0 ].style.position = "relative";
  5473. }
  5474. },
  5475. _adjustOffsetFromHelper: function(obj) {
  5476. if (typeof obj === "string") {
  5477. obj = obj.split(" ");
  5478. }
  5479. if ($.isArray(obj)) {
  5480. obj = { left: +obj[0], top: +obj[1] || 0 };
  5481. }
  5482. if ("left" in obj) {
  5483. this.offset.click.left = obj.left + this.margins.left;
  5484. }
  5485. if ("right" in obj) {
  5486. this.offset.click.left = this.helperProportions.width - obj.right + this.margins.left;
  5487. }
  5488. if ("top" in obj) {
  5489. this.offset.click.top = obj.top + this.margins.top;
  5490. }
  5491. if ("bottom" in obj) {
  5492. this.offset.click.top = this.helperProportions.height - obj.bottom + this.margins.top;
  5493. }
  5494. },
  5495. _isRootNode: function( element ) {
  5496. return ( /(html|body)/i ).test( element.tagName ) || element === this.document[ 0 ];
  5497. },
  5498. _getParentOffset: function() {
  5499. //Get the offsetParent and cache its position
  5500. var po = this.offsetParent.offset(),
  5501. document = this.document[ 0 ];
  5502. // This is a special case where we need to modify a offset calculated on start, since the following happened:
  5503. // 1. The position of the helper is absolute, so it's position is calculated based on the next positioned parent
  5504. // 2. The actual offset parent is a child of the scroll parent, and the scroll parent isn't the document, which means that
  5505. // the scroll is included in the initial calculation of the offset of the parent, and never recalculated upon drag
  5506. if (this.cssPosition === "absolute" && this.scrollParent[0] !== document && $.contains(this.scrollParent[0], this.offsetParent[0])) {
  5507. po.left += this.scrollParent.scrollLeft();
  5508. po.top += this.scrollParent.scrollTop();
  5509. }
  5510. if ( this._isRootNode( this.offsetParent[ 0 ] ) ) {
  5511. po = { top: 0, left: 0 };
  5512. }
  5513. return {
  5514. top: po.top + (parseInt(this.offsetParent.css("borderTopWidth"), 10) || 0),
  5515. left: po.left + (parseInt(this.offsetParent.css("borderLeftWidth"), 10) || 0)
  5516. };
  5517. },
  5518. _getRelativeOffset: function() {
  5519. if ( this.cssPosition !== "relative" ) {
  5520. return { top: 0, left: 0 };
  5521. }
  5522. var p = this.element.position(),
  5523. scrollIsRootNode = this._isRootNode( this.scrollParent[ 0 ] );
  5524. return {
  5525. top: p.top - ( parseInt(this.helper.css( "top" ), 10) || 0 ) + ( !scrollIsRootNode ? this.scrollParent.scrollTop() : 0 ),
  5526. left: p.left - ( parseInt(this.helper.css( "left" ), 10) || 0 ) + ( !scrollIsRootNode ? this.scrollParent.scrollLeft() : 0 )
  5527. };
  5528. },
  5529. _cacheMargins: function() {
  5530. this.margins = {
  5531. left: (parseInt(this.element.css("marginLeft"), 10) || 0),
  5532. top: (parseInt(this.element.css("marginTop"), 10) || 0),
  5533. right: (parseInt(this.element.css("marginRight"), 10) || 0),
  5534. bottom: (parseInt(this.element.css("marginBottom"), 10) || 0)
  5535. };
  5536. },
  5537. _cacheHelperProportions: function() {
  5538. this.helperProportions = {
  5539. width: this.helper.outerWidth(),
  5540. height: this.helper.outerHeight()
  5541. };
  5542. },
  5543. _setContainment: function() {
  5544. var isUserScrollable, c, ce,
  5545. o = this.options,
  5546. document = this.document[ 0 ];
  5547. this.relativeContainer = null;
  5548. if ( !o.containment ) {
  5549. this.containment = null;
  5550. return;
  5551. }
  5552. if ( o.containment === "window" ) {
  5553. this.containment = [
  5554. $( window ).scrollLeft() - this.offset.relative.left - this.offset.parent.left,
  5555. $( window ).scrollTop() - this.offset.relative.top - this.offset.parent.top,
  5556. $( window ).scrollLeft() + $( window ).width() - this.helperProportions.width - this.margins.left,
  5557. $( window ).scrollTop() + ( $( window ).height() || document.body.parentNode.scrollHeight ) - this.helperProportions.height - this.margins.top
  5558. ];
  5559. return;
  5560. }
  5561. if ( o.containment === "document") {
  5562. this.containment = [
  5563. 0,
  5564. 0,
  5565. $( document ).width() - this.helperProportions.width - this.margins.left,
  5566. ( $( document ).height() || document.body.parentNode.scrollHeight ) - this.helperProportions.height - this.margins.top
  5567. ];
  5568. return;
  5569. }
  5570. if ( o.containment.constructor === Array ) {
  5571. this.containment = o.containment;
  5572. return;
  5573. }
  5574. if ( o.containment === "parent" ) {
  5575. o.containment = this.helper[ 0 ].parentNode;
  5576. }
  5577. c = $( o.containment );
  5578. ce = c[ 0 ];
  5579. if ( !ce ) {
  5580. return;
  5581. }
  5582. isUserScrollable = /(scroll|auto)/.test( c.css( "overflow" ) );
  5583. this.containment = [
  5584. ( parseInt( c.css( "borderLeftWidth" ), 10 ) || 0 ) + ( parseInt( c.css( "paddingLeft" ), 10 ) || 0 ),
  5585. ( parseInt( c.css( "borderTopWidth" ), 10 ) || 0 ) + ( parseInt( c.css( "paddingTop" ), 10 ) || 0 ),
  5586. ( isUserScrollable ? Math.max( ce.scrollWidth, ce.offsetWidth ) : ce.offsetWidth ) -
  5587. ( parseInt( c.css( "borderRightWidth" ), 10 ) || 0 ) -
  5588. ( parseInt( c.css( "paddingRight" ), 10 ) || 0 ) -
  5589. this.helperProportions.width -
  5590. this.margins.left -
  5591. this.margins.right,
  5592. ( isUserScrollable ? Math.max( ce.scrollHeight, ce.offsetHeight ) : ce.offsetHeight ) -
  5593. ( parseInt( c.css( "borderBottomWidth" ), 10 ) || 0 ) -
  5594. ( parseInt( c.css( "paddingBottom" ), 10 ) || 0 ) -
  5595. this.helperProportions.height -
  5596. this.margins.top -
  5597. this.margins.bottom
  5598. ];
  5599. this.relativeContainer = c;
  5600. },
  5601. _convertPositionTo: function(d, pos) {
  5602. if (!pos) {
  5603. pos = this.position;
  5604. }
  5605. var mod = d === "absolute" ? 1 : -1,
  5606. scrollIsRootNode = this._isRootNode( this.scrollParent[ 0 ] );
  5607. return {
  5608. top: (
  5609. pos.top + // The absolute mouse position
  5610. this.offset.relative.top * mod + // Only for relative positioned nodes: Relative offset from element to offset parent
  5611. this.offset.parent.top * mod - // The offsetParent's offset without borders (offset + border)
  5612. ( ( this.cssPosition === "fixed" ? -this.offset.scroll.top : ( scrollIsRootNode ? 0 : this.offset.scroll.top ) ) * mod)
  5613. ),
  5614. left: (
  5615. pos.left + // The absolute mouse position
  5616. this.offset.relative.left * mod + // Only for relative positioned nodes: Relative offset from element to offset parent
  5617. this.offset.parent.left * mod - // The offsetParent's offset without borders (offset + border)
  5618. ( ( this.cssPosition === "fixed" ? -this.offset.scroll.left : ( scrollIsRootNode ? 0 : this.offset.scroll.left ) ) * mod)
  5619. )
  5620. };
  5621. },
  5622. _generatePosition: function( event, constrainPosition ) {
  5623. var containment, co, top, left,
  5624. o = this.options,
  5625. scrollIsRootNode = this._isRootNode( this.scrollParent[ 0 ] ),
  5626. pageX = event.pageX,
  5627. pageY = event.pageY;
  5628. // Cache the scroll
  5629. if ( !scrollIsRootNode || !this.offset.scroll ) {
  5630. this.offset.scroll = {
  5631. top: this.scrollParent.scrollTop(),
  5632. left: this.scrollParent.scrollLeft()
  5633. };
  5634. }
  5635. /*
  5636. * - Position constraining -
  5637. * Constrain the position to a mix of grid, containment.
  5638. */
  5639. // If we are not dragging yet, we won't check for options
  5640. if ( constrainPosition ) {
  5641. if ( this.containment ) {
  5642. if ( this.relativeContainer ){
  5643. co = this.relativeContainer.offset();
  5644. containment = [
  5645. this.containment[ 0 ] + co.left,
  5646. this.containment[ 1 ] + co.top,
  5647. this.containment[ 2 ] + co.left,
  5648. this.containment[ 3 ] + co.top
  5649. ];
  5650. } else {
  5651. containment = this.containment;
  5652. }
  5653. if (event.pageX - this.offset.click.left < containment[0]) {
  5654. pageX = containment[0] + this.offset.click.left;
  5655. }
  5656. if (event.pageY - this.offset.click.top < containment[1]) {
  5657. pageY = containment[1] + this.offset.click.top;
  5658. }
  5659. if (event.pageX - this.offset.click.left > containment[2]) {
  5660. pageX = containment[2] + this.offset.click.left;
  5661. }
  5662. if (event.pageY - this.offset.click.top > containment[3]) {
  5663. pageY = containment[3] + this.offset.click.top;
  5664. }
  5665. }
  5666. if (o.grid) {
  5667. //Check for grid elements set to 0 to prevent divide by 0 error causing invalid argument errors in IE (see ticket #6950)
  5668. top = o.grid[1] ? this.originalPageY + Math.round((pageY - this.originalPageY) / o.grid[1]) * o.grid[1] : this.originalPageY;
  5669. 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;
  5670. left = o.grid[0] ? this.originalPageX + Math.round((pageX - this.originalPageX) / o.grid[0]) * o.grid[0] : this.originalPageX;
  5671. 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;
  5672. }
  5673. if ( o.axis === "y" ) {
  5674. pageX = this.originalPageX;
  5675. }
  5676. if ( o.axis === "x" ) {
  5677. pageY = this.originalPageY;
  5678. }
  5679. }
  5680. return {
  5681. top: (
  5682. pageY - // The absolute mouse position
  5683. this.offset.click.top - // Click offset (relative to the element)
  5684. this.offset.relative.top - // Only for relative positioned nodes: Relative offset from element to offset parent
  5685. this.offset.parent.top + // The offsetParent's offset without borders (offset + border)
  5686. ( this.cssPosition === "fixed" ? -this.offset.scroll.top : ( scrollIsRootNode ? 0 : this.offset.scroll.top ) )
  5687. ),
  5688. left: (
  5689. pageX - // The absolute mouse position
  5690. this.offset.click.left - // Click offset (relative to the element)
  5691. this.offset.relative.left - // Only for relative positioned nodes: Relative offset from element to offset parent
  5692. this.offset.parent.left + // The offsetParent's offset without borders (offset + border)
  5693. ( this.cssPosition === "fixed" ? -this.offset.scroll.left : ( scrollIsRootNode ? 0 : this.offset.scroll.left ) )
  5694. )
  5695. };
  5696. },
  5697. _clear: function() {
  5698. this.helper.removeClass("ui-draggable-dragging");
  5699. if (this.helper[0] !== this.element[0] && !this.cancelHelperRemoval) {
  5700. this.helper.remove();
  5701. }
  5702. this.helper = null;
  5703. this.cancelHelperRemoval = false;
  5704. if ( this.destroyOnClear ) {
  5705. this.destroy();
  5706. }
  5707. },
  5708. _normalizeRightBottom: function() {
  5709. if ( this.options.axis !== "y" && this.helper.css( "right" ) !== "auto" ) {
  5710. this.helper.width( this.helper.width() );
  5711. this.helper.css( "right", "auto" );
  5712. }
  5713. if ( this.options.axis !== "x" && this.helper.css( "bottom" ) !== "auto" ) {
  5714. this.helper.height( this.helper.height() );
  5715. this.helper.css( "bottom", "auto" );
  5716. }
  5717. },
  5718. // From now on bulk stuff - mainly helpers
  5719. _trigger: function( type, event, ui ) {
  5720. ui = ui || this._uiHash();
  5721. $.ui.plugin.call( this, type, [ event, ui, this ], true );
  5722. // Absolute position and offset (see #6884 ) have to be recalculated after plugins
  5723. if ( /^(drag|start|stop)/.test( type ) ) {
  5724. this.positionAbs = this._convertPositionTo( "absolute" );
  5725. ui.offset = this.positionAbs;
  5726. }
  5727. return $.Widget.prototype._trigger.call( this, type, event, ui );
  5728. },
  5729. plugins: {},
  5730. _uiHash: function() {
  5731. return {
  5732. helper: this.helper,
  5733. position: this.position,
  5734. originalPosition: this.originalPosition,
  5735. offset: this.positionAbs
  5736. };
  5737. }
  5738. });
  5739. $.ui.plugin.add( "draggable", "connectToSortable", {
  5740. start: function( event, ui, draggable ) {
  5741. var uiSortable = $.extend( {}, ui, {
  5742. item: draggable.element
  5743. });
  5744. draggable.sortables = [];
  5745. $( draggable.options.connectToSortable ).each(function() {
  5746. var sortable = $( this ).sortable( "instance" );
  5747. if ( sortable && !sortable.options.disabled ) {
  5748. draggable.sortables.push( sortable );
  5749. // refreshPositions is called at drag start to refresh the containerCache
  5750. // which is used in drag. This ensures it's initialized and synchronized
  5751. // with any changes that might have happened on the page since initialization.
  5752. sortable.refreshPositions();
  5753. sortable._trigger("activate", event, uiSortable);
  5754. }
  5755. });
  5756. },
  5757. stop: function( event, ui, draggable ) {
  5758. var uiSortable = $.extend( {}, ui, {
  5759. item: draggable.element
  5760. });
  5761. draggable.cancelHelperRemoval = false;
  5762. $.each( draggable.sortables, function() {
  5763. var sortable = this;
  5764. if ( sortable.isOver ) {
  5765. sortable.isOver = 0;
  5766. // Allow this sortable to handle removing the helper
  5767. draggable.cancelHelperRemoval = true;
  5768. sortable.cancelHelperRemoval = false;
  5769. // Use _storedCSS To restore properties in the sortable,
  5770. // as this also handles revert (#9675) since the draggable
  5771. // may have modified them in unexpected ways (#8809)
  5772. sortable._storedCSS = {
  5773. position: sortable.placeholder.css( "position" ),
  5774. top: sortable.placeholder.css( "top" ),
  5775. left: sortable.placeholder.css( "left" )
  5776. };
  5777. sortable._mouseStop(event);
  5778. // Once drag has ended, the sortable should return to using
  5779. // its original helper, not the shared helper from draggable
  5780. sortable.options.helper = sortable.options._helper;
  5781. } else {
  5782. // Prevent this Sortable from removing the helper.
  5783. // However, don't set the draggable to remove the helper
  5784. // either as another connected Sortable may yet handle the removal.
  5785. sortable.cancelHelperRemoval = true;
  5786. sortable._trigger( "deactivate", event, uiSortable );
  5787. }
  5788. });
  5789. },
  5790. drag: function( event, ui, draggable ) {
  5791. $.each( draggable.sortables, function() {
  5792. var innermostIntersecting = false,
  5793. sortable = this;
  5794. // Copy over variables that sortable's _intersectsWith uses
  5795. sortable.positionAbs = draggable.positionAbs;
  5796. sortable.helperProportions = draggable.helperProportions;
  5797. sortable.offset.click = draggable.offset.click;
  5798. if ( sortable._intersectsWith( sortable.containerCache ) ) {
  5799. innermostIntersecting = true;
  5800. $.each( draggable.sortables, function() {
  5801. // Copy over variables that sortable's _intersectsWith uses
  5802. this.positionAbs = draggable.positionAbs;
  5803. this.helperProportions = draggable.helperProportions;
  5804. this.offset.click = draggable.offset.click;
  5805. if ( this !== sortable &&
  5806. this._intersectsWith( this.containerCache ) &&
  5807. $.contains( sortable.element[ 0 ], this.element[ 0 ] ) ) {
  5808. innermostIntersecting = false;
  5809. }
  5810. return innermostIntersecting;
  5811. });
  5812. }
  5813. if ( innermostIntersecting ) {
  5814. // If it intersects, we use a little isOver variable and set it once,
  5815. // so that the move-in stuff gets fired only once.
  5816. if ( !sortable.isOver ) {
  5817. sortable.isOver = 1;
  5818. sortable.currentItem = ui.helper
  5819. .appendTo( sortable.element )
  5820. .data( "ui-sortable-item", true );
  5821. // Store helper option to later restore it
  5822. sortable.options._helper = sortable.options.helper;
  5823. sortable.options.helper = function() {
  5824. return ui.helper[ 0 ];
  5825. };
  5826. // Fire the start events of the sortable with our passed browser event,
  5827. // and our own helper (so it doesn't create a new one)
  5828. event.target = sortable.currentItem[ 0 ];
  5829. sortable._mouseCapture( event, true );
  5830. sortable._mouseStart( event, true, true );
  5831. // Because the browser event is way off the new appended portlet,
  5832. // modify necessary variables to reflect the changes
  5833. sortable.offset.click.top = draggable.offset.click.top;
  5834. sortable.offset.click.left = draggable.offset.click.left;
  5835. sortable.offset.parent.left -= draggable.offset.parent.left -
  5836. sortable.offset.parent.left;
  5837. sortable.offset.parent.top -= draggable.offset.parent.top -
  5838. sortable.offset.parent.top;
  5839. draggable._trigger( "toSortable", event );
  5840. // Inform draggable that the helper is in a valid drop zone,
  5841. // used solely in the revert option to handle "valid/invalid".
  5842. draggable.dropped = sortable.element;
  5843. // Need to refreshPositions of all sortables in the case that
  5844. // adding to one sortable changes the location of the other sortables (#9675)
  5845. $.each( draggable.sortables, function() {
  5846. this.refreshPositions();
  5847. });
  5848. // hack so receive/update callbacks work (mostly)
  5849. draggable.currentItem = draggable.element;
  5850. sortable.fromOutside = draggable;
  5851. }
  5852. if ( sortable.currentItem ) {
  5853. sortable._mouseDrag( event );
  5854. // Copy the sortable's position because the draggable's can potentially reflect
  5855. // a relative position, while sortable is always absolute, which the dragged
  5856. // element has now become. (#8809)
  5857. ui.position = sortable.position;
  5858. }
  5859. } else {
  5860. // If it doesn't intersect with the sortable, and it intersected before,
  5861. // we fake the drag stop of the sortable, but make sure it doesn't remove
  5862. // the helper by using cancelHelperRemoval.
  5863. if ( sortable.isOver ) {
  5864. sortable.isOver = 0;
  5865. sortable.cancelHelperRemoval = true;
  5866. // Calling sortable's mouseStop would trigger a revert,
  5867. // so revert must be temporarily false until after mouseStop is called.
  5868. sortable.options._revert = sortable.options.revert;
  5869. sortable.options.revert = false;
  5870. sortable._trigger( "out", event, sortable._uiHash( sortable ) );
  5871. sortable._mouseStop( event, true );
  5872. // restore sortable behaviors that were modfied
  5873. // when the draggable entered the sortable area (#9481)
  5874. sortable.options.revert = sortable.options._revert;
  5875. sortable.options.helper = sortable.options._helper;
  5876. if ( sortable.placeholder ) {
  5877. sortable.placeholder.remove();
  5878. }
  5879. // Recalculate the draggable's offset considering the sortable
  5880. // may have modified them in unexpected ways (#8809)
  5881. draggable._refreshOffsets( event );
  5882. ui.position = draggable._generatePosition( event, true );
  5883. draggable._trigger( "fromSortable", event );
  5884. // Inform draggable that the helper is no longer in a valid drop zone
  5885. draggable.dropped = false;
  5886. // Need to refreshPositions of all sortables just in case removing
  5887. // from one sortable changes the location of other sortables (#9675)
  5888. $.each( draggable.sortables, function() {
  5889. this.refreshPositions();
  5890. });
  5891. }
  5892. }
  5893. });
  5894. }
  5895. });
  5896. $.ui.plugin.add("draggable", "cursor", {
  5897. start: function( event, ui, instance ) {
  5898. var t = $( "body" ),
  5899. o = instance.options;
  5900. if (t.css("cursor")) {
  5901. o._cursor = t.css("cursor");
  5902. }
  5903. t.css("cursor", o.cursor);
  5904. },
  5905. stop: function( event, ui, instance ) {
  5906. var o = instance.options;
  5907. if (o._cursor) {
  5908. $("body").css("cursor", o._cursor);
  5909. }
  5910. }
  5911. });
  5912. $.ui.plugin.add("draggable", "opacity", {
  5913. start: function( event, ui, instance ) {
  5914. var t = $( ui.helper ),
  5915. o = instance.options;
  5916. if (t.css("opacity")) {
  5917. o._opacity = t.css("opacity");
  5918. }
  5919. t.css("opacity", o.opacity);
  5920. },
  5921. stop: function( event, ui, instance ) {
  5922. var o = instance.options;
  5923. if (o._opacity) {
  5924. $(ui.helper).css("opacity", o._opacity);
  5925. }
  5926. }
  5927. });
  5928. $.ui.plugin.add("draggable", "scroll", {
  5929. start: function( event, ui, i ) {
  5930. if ( !i.scrollParentNotHidden ) {
  5931. i.scrollParentNotHidden = i.helper.scrollParent( false );
  5932. }
  5933. if ( i.scrollParentNotHidden[ 0 ] !== i.document[ 0 ] && i.scrollParentNotHidden[ 0 ].tagName !== "HTML" ) {
  5934. i.overflowOffset = i.scrollParentNotHidden.offset();
  5935. }
  5936. },
  5937. drag: function( event, ui, i ) {
  5938. var o = i.options,
  5939. scrolled = false,
  5940. scrollParent = i.scrollParentNotHidden[ 0 ],
  5941. document = i.document[ 0 ];
  5942. if ( scrollParent !== document && scrollParent.tagName !== "HTML" ) {
  5943. if ( !o.axis || o.axis !== "x" ) {
  5944. if ( ( i.overflowOffset.top + scrollParent.offsetHeight ) - event.pageY < o.scrollSensitivity ) {
  5945. scrollParent.scrollTop = scrolled = scrollParent.scrollTop + o.scrollSpeed;
  5946. } else if ( event.pageY - i.overflowOffset.top < o.scrollSensitivity ) {
  5947. scrollParent.scrollTop = scrolled = scrollParent.scrollTop - o.scrollSpeed;
  5948. }
  5949. }
  5950. if ( !o.axis || o.axis !== "y" ) {
  5951. if ( ( i.overflowOffset.left + scrollParent.offsetWidth ) - event.pageX < o.scrollSensitivity ) {
  5952. scrollParent.scrollLeft = scrolled = scrollParent.scrollLeft + o.scrollSpeed;
  5953. } else if ( event.pageX - i.overflowOffset.left < o.scrollSensitivity ) {
  5954. scrollParent.scrollLeft = scrolled = scrollParent.scrollLeft - o.scrollSpeed;
  5955. }
  5956. }
  5957. } else {
  5958. if (!o.axis || o.axis !== "x") {
  5959. if (event.pageY - $(document).scrollTop() < o.scrollSensitivity) {
  5960. scrolled = $(document).scrollTop($(document).scrollTop() - o.scrollSpeed);
  5961. } else if ($(window).height() - (event.pageY - $(document).scrollTop()) < o.scrollSensitivity) {
  5962. scrolled = $(document).scrollTop($(document).scrollTop() + o.scrollSpeed);
  5963. }
  5964. }
  5965. if (!o.axis || o.axis !== "y") {
  5966. if (event.pageX - $(document).scrollLeft() < o.scrollSensitivity) {
  5967. scrolled = $(document).scrollLeft($(document).scrollLeft() - o.scrollSpeed);
  5968. } else if ($(window).width() - (event.pageX - $(document).scrollLeft()) < o.scrollSensitivity) {
  5969. scrolled = $(document).scrollLeft($(document).scrollLeft() + o.scrollSpeed);
  5970. }
  5971. }
  5972. }
  5973. if (scrolled !== false && $.ui.ddmanager && !o.dropBehaviour) {
  5974. $.ui.ddmanager.prepareOffsets(i, event);
  5975. }
  5976. }
  5977. });
  5978. $.ui.plugin.add("draggable", "snap", {
  5979. start: function( event, ui, i ) {
  5980. var o = i.options;
  5981. i.snapElements = [];
  5982. $(o.snap.constructor !== String ? ( o.snap.items || ":data(ui-draggable)" ) : o.snap).each(function() {
  5983. var $t = $(this),
  5984. $o = $t.offset();
  5985. if (this !== i.element[0]) {
  5986. i.snapElements.push({
  5987. item: this,
  5988. width: $t.outerWidth(), height: $t.outerHeight(),
  5989. top: $o.top, left: $o.left
  5990. });
  5991. }
  5992. });
  5993. },
  5994. drag: function( event, ui, inst ) {
  5995. var ts, bs, ls, rs, l, r, t, b, i, first,
  5996. o = inst.options,
  5997. d = o.snapTolerance,
  5998. x1 = ui.offset.left, x2 = x1 + inst.helperProportions.width,
  5999. y1 = ui.offset.top, y2 = y1 + inst.helperProportions.height;
  6000. for (i = inst.snapElements.length - 1; i >= 0; i--){
  6001. l = inst.snapElements[i].left - inst.margins.left;
  6002. r = l + inst.snapElements[i].width;
  6003. t = inst.snapElements[i].top - inst.margins.top;
  6004. b = t + inst.snapElements[i].height;
  6005. if ( x2 < l - d || x1 > r + d || y2 < t - d || y1 > b + d || !$.contains( inst.snapElements[ i ].item.ownerDocument, inst.snapElements[ i ].item ) ) {
  6006. if (inst.snapElements[i].snapping) {
  6007. (inst.options.snap.release && inst.options.snap.release.call(inst.element, event, $.extend(inst._uiHash(), { snapItem: inst.snapElements[i].item })));
  6008. }
  6009. inst.snapElements[i].snapping = false;
  6010. continue;
  6011. }
  6012. if (o.snapMode !== "inner") {
  6013. ts = Math.abs(t - y2) <= d;
  6014. bs = Math.abs(b - y1) <= d;
  6015. ls = Math.abs(l - x2) <= d;
  6016. rs = Math.abs(r - x1) <= d;
  6017. if (ts) {
  6018. ui.position.top = inst._convertPositionTo("relative", { top: t - inst.helperProportions.height, left: 0 }).top;
  6019. }
  6020. if (bs) {
  6021. ui.position.top = inst._convertPositionTo("relative", { top: b, left: 0 }).top;
  6022. }
  6023. if (ls) {
  6024. ui.position.left = inst._convertPositionTo("relative", { top: 0, left: l - inst.helperProportions.width }).left;
  6025. }
  6026. if (rs) {
  6027. ui.position.left = inst._convertPositionTo("relative", { top: 0, left: r }).left;
  6028. }
  6029. }
  6030. first = (ts || bs || ls || rs);
  6031. if (o.snapMode !== "outer") {
  6032. ts = Math.abs(t - y1) <= d;
  6033. bs = Math.abs(b - y2) <= d;
  6034. ls = Math.abs(l - x1) <= d;
  6035. rs = Math.abs(r - x2) <= d;
  6036. if (ts) {
  6037. ui.position.top = inst._convertPositionTo("relative", { top: t, left: 0 }).top;
  6038. }
  6039. if (bs) {
  6040. ui.position.top = inst._convertPositionTo("relative", { top: b - inst.helperProportions.height, left: 0 }).top;
  6041. }
  6042. if (ls) {
  6043. ui.position.left = inst._convertPositionTo("relative", { top: 0, left: l }).left;
  6044. }
  6045. if (rs) {
  6046. ui.position.left = inst._convertPositionTo("relative", { top: 0, left: r - inst.helperProportions.width }).left;
  6047. }
  6048. }
  6049. if (!inst.snapElements[i].snapping && (ts || bs || ls || rs || first)) {
  6050. (inst.options.snap.snap && inst.options.snap.snap.call(inst.element, event, $.extend(inst._uiHash(), { snapItem: inst.snapElements[i].item })));
  6051. }
  6052. inst.snapElements[i].snapping = (ts || bs || ls || rs || first);
  6053. }
  6054. }
  6055. });
  6056. $.ui.plugin.add("draggable", "stack", {
  6057. start: function( event, ui, instance ) {
  6058. var min,
  6059. o = instance.options,
  6060. group = $.makeArray($(o.stack)).sort(function(a, b) {
  6061. return (parseInt($(a).css("zIndex"), 10) || 0) - (parseInt($(b).css("zIndex"), 10) || 0);
  6062. });
  6063. if (!group.length) { return; }
  6064. min = parseInt($(group[0]).css("zIndex"), 10) || 0;
  6065. $(group).each(function(i) {
  6066. $(this).css("zIndex", min + i);
  6067. });
  6068. this.css("zIndex", (min + group.length));
  6069. }
  6070. });
  6071. $.ui.plugin.add("draggable", "zIndex", {
  6072. start: function( event, ui, instance ) {
  6073. var t = $( ui.helper ),
  6074. o = instance.options;
  6075. if (t.css("zIndex")) {
  6076. o._zIndex = t.css("zIndex");
  6077. }
  6078. t.css("zIndex", o.zIndex);
  6079. },
  6080. stop: function( event, ui, instance ) {
  6081. var o = instance.options;
  6082. if (o._zIndex) {
  6083. $(ui.helper).css("zIndex", o._zIndex);
  6084. }
  6085. }
  6086. });
  6087. var draggable = $.ui.draggable;
  6088. /*!
  6089. * jQuery UI Resizable 1.11.2
  6090. * http://jqueryui.com
  6091. *
  6092. * Copyright 2014 jQuery Foundation and other contributors
  6093. * Released under the MIT license.
  6094. * http://jquery.org/license
  6095. *
  6096. * http://api.jqueryui.com/resizable/
  6097. */
  6098. $.widget("ui.resizable", $.ui.mouse, {
  6099. version: "1.11.2",
  6100. widgetEventPrefix: "resize",
  6101. options: {
  6102. alsoResize: false,
  6103. animate: false,
  6104. animateDuration: "slow",
  6105. animateEasing: "swing",
  6106. aspectRatio: false,
  6107. autoHide: false,
  6108. containment: false,
  6109. ghost: false,
  6110. grid: false,
  6111. handles: "e,s,se",
  6112. helper: false,
  6113. maxHeight: null,
  6114. maxWidth: null,
  6115. minHeight: 10,
  6116. minWidth: 10,
  6117. // See #7960
  6118. zIndex: 90,
  6119. // callbacks
  6120. resize: null,
  6121. start: null,
  6122. stop: null
  6123. },
  6124. _num: function( value ) {
  6125. return parseInt( value, 10 ) || 0;
  6126. },
  6127. _isNumber: function( value ) {
  6128. return !isNaN( parseInt( value, 10 ) );
  6129. },
  6130. _hasScroll: function( el, a ) {
  6131. if ( $( el ).css( "overflow" ) === "hidden") {
  6132. return false;
  6133. }
  6134. var scroll = ( a && a === "left" ) ? "scrollLeft" : "scrollTop",
  6135. has = false;
  6136. if ( el[ scroll ] > 0 ) {
  6137. return true;
  6138. }
  6139. // TODO: determine which cases actually cause this to happen
  6140. // if the element doesn't have the scroll set, see if it's possible to
  6141. // set the scroll
  6142. el[ scroll ] = 1;
  6143. has = ( el[ scroll ] > 0 );
  6144. el[ scroll ] = 0;
  6145. return has;
  6146. },
  6147. _create: function() {
  6148. var n, i, handle, axis, hname,
  6149. that = this,
  6150. o = this.options;
  6151. this.element.addClass("ui-resizable");
  6152. $.extend(this, {
  6153. _aspectRatio: !!(o.aspectRatio),
  6154. aspectRatio: o.aspectRatio,
  6155. originalElement: this.element,
  6156. _proportionallyResizeElements: [],
  6157. _helper: o.helper || o.ghost || o.animate ? o.helper || "ui-resizable-helper" : null
  6158. });
  6159. // Wrap the element if it cannot hold child nodes
  6160. if (this.element[0].nodeName.match(/canvas|textarea|input|select|button|img/i)) {
  6161. this.element.wrap(
  6162. $("<div class='ui-wrapper' style='overflow: hidden;'></div>").css({
  6163. position: this.element.css("position"),
  6164. width: this.element.outerWidth(),
  6165. height: this.element.outerHeight(),
  6166. top: this.element.css("top"),
  6167. left: this.element.css("left")
  6168. })
  6169. );
  6170. this.element = this.element.parent().data(
  6171. "ui-resizable", this.element.resizable( "instance" )
  6172. );
  6173. this.elementIsWrapper = true;
  6174. this.element.css({
  6175. marginLeft: this.originalElement.css("marginLeft"),
  6176. marginTop: this.originalElement.css("marginTop"),
  6177. marginRight: this.originalElement.css("marginRight"),
  6178. marginBottom: this.originalElement.css("marginBottom")
  6179. });
  6180. this.originalElement.css({
  6181. marginLeft: 0,
  6182. marginTop: 0,
  6183. marginRight: 0,
  6184. marginBottom: 0
  6185. });
  6186. // support: Safari
  6187. // Prevent Safari textarea resize
  6188. this.originalResizeStyle = this.originalElement.css("resize");
  6189. this.originalElement.css("resize", "none");
  6190. this._proportionallyResizeElements.push( this.originalElement.css({
  6191. position: "static",
  6192. zoom: 1,
  6193. display: "block"
  6194. }) );
  6195. // support: IE9
  6196. // avoid IE jump (hard set the margin)
  6197. this.originalElement.css({ margin: this.originalElement.css("margin") });
  6198. this._proportionallyResize();
  6199. }
  6200. this.handles = o.handles ||
  6201. ( !$(".ui-resizable-handle", this.element).length ?
  6202. "e,s,se" : {
  6203. n: ".ui-resizable-n",
  6204. e: ".ui-resizable-e",
  6205. s: ".ui-resizable-s",
  6206. w: ".ui-resizable-w",
  6207. se: ".ui-resizable-se",
  6208. sw: ".ui-resizable-sw",
  6209. ne: ".ui-resizable-ne",
  6210. nw: ".ui-resizable-nw"
  6211. } );
  6212. if (this.handles.constructor === String) {
  6213. if ( this.handles === "all") {
  6214. this.handles = "n,e,s,w,se,sw,ne,nw";
  6215. }
  6216. n = this.handles.split(",");
  6217. this.handles = {};
  6218. for (i = 0; i < n.length; i++) {
  6219. handle = $.trim(n[i]);
  6220. hname = "ui-resizable-" + handle;
  6221. axis = $("<div class='ui-resizable-handle " + hname + "'></div>");
  6222. axis.css({ zIndex: o.zIndex });
  6223. // TODO : What's going on here?
  6224. if ("se" === handle) {
  6225. axis.addClass("ui-icon ui-icon-gripsmall-diagonal-se");
  6226. }
  6227. this.handles[handle] = ".ui-resizable-" + handle;
  6228. this.element.append(axis);
  6229. }
  6230. }
  6231. this._renderAxis = function(target) {
  6232. var i, axis, padPos, padWrapper;
  6233. target = target || this.element;
  6234. for (i in this.handles) {
  6235. if (this.handles[i].constructor === String) {
  6236. this.handles[i] = this.element.children( this.handles[ i ] ).first().show();
  6237. }
  6238. if (this.elementIsWrapper && this.originalElement[0].nodeName.match(/textarea|input|select|button/i)) {
  6239. axis = $(this.handles[i], this.element);
  6240. padWrapper = /sw|ne|nw|se|n|s/.test(i) ? axis.outerHeight() : axis.outerWidth();
  6241. padPos = [ "padding",
  6242. /ne|nw|n/.test(i) ? "Top" :
  6243. /se|sw|s/.test(i) ? "Bottom" :
  6244. /^e$/.test(i) ? "Right" : "Left" ].join("");
  6245. target.css(padPos, padWrapper);
  6246. this._proportionallyResize();
  6247. }
  6248. // TODO: What's that good for? There's not anything to be executed left
  6249. if (!$(this.handles[i]).length) {
  6250. continue;
  6251. }
  6252. }
  6253. };
  6254. // TODO: make renderAxis a prototype function
  6255. this._renderAxis(this.element);
  6256. this._handles = $(".ui-resizable-handle", this.element)
  6257. .disableSelection();
  6258. this._handles.mouseover(function() {
  6259. if (!that.resizing) {
  6260. if (this.className) {
  6261. axis = this.className.match(/ui-resizable-(se|sw|ne|nw|n|e|s|w)/i);
  6262. }
  6263. that.axis = axis && axis[1] ? axis[1] : "se";
  6264. }
  6265. });
  6266. if (o.autoHide) {
  6267. this._handles.hide();
  6268. $(this.element)
  6269. .addClass("ui-resizable-autohide")
  6270. .mouseenter(function() {
  6271. if (o.disabled) {
  6272. return;
  6273. }
  6274. $(this).removeClass("ui-resizable-autohide");
  6275. that._handles.show();
  6276. })
  6277. .mouseleave(function() {
  6278. if (o.disabled) {
  6279. return;
  6280. }
  6281. if (!that.resizing) {
  6282. $(this).addClass("ui-resizable-autohide");
  6283. that._handles.hide();
  6284. }
  6285. });
  6286. }
  6287. this._mouseInit();
  6288. },
  6289. _destroy: function() {
  6290. this._mouseDestroy();
  6291. var wrapper,
  6292. _destroy = function(exp) {
  6293. $(exp)
  6294. .removeClass("ui-resizable ui-resizable-disabled ui-resizable-resizing")
  6295. .removeData("resizable")
  6296. .removeData("ui-resizable")
  6297. .unbind(".resizable")
  6298. .find(".ui-resizable-handle")
  6299. .remove();
  6300. };
  6301. // TODO: Unwrap at same DOM position
  6302. if (this.elementIsWrapper) {
  6303. _destroy(this.element);
  6304. wrapper = this.element;
  6305. this.originalElement.css({
  6306. position: wrapper.css("position"),
  6307. width: wrapper.outerWidth(),
  6308. height: wrapper.outerHeight(),
  6309. top: wrapper.css("top"),
  6310. left: wrapper.css("left")
  6311. }).insertAfter( wrapper );
  6312. wrapper.remove();
  6313. }
  6314. this.originalElement.css("resize", this.originalResizeStyle);
  6315. _destroy(this.originalElement);
  6316. return this;
  6317. },
  6318. _mouseCapture: function(event) {
  6319. var i, handle,
  6320. capture = false;
  6321. for (i in this.handles) {
  6322. handle = $(this.handles[i])[0];
  6323. if (handle === event.target || $.contains(handle, event.target)) {
  6324. capture = true;
  6325. }
  6326. }
  6327. return !this.options.disabled && capture;
  6328. },
  6329. _mouseStart: function(event) {
  6330. var curleft, curtop, cursor,
  6331. o = this.options,
  6332. el = this.element;
  6333. this.resizing = true;
  6334. this._renderProxy();
  6335. curleft = this._num(this.helper.css("left"));
  6336. curtop = this._num(this.helper.css("top"));
  6337. if (o.containment) {
  6338. curleft += $(o.containment).scrollLeft() || 0;
  6339. curtop += $(o.containment).scrollTop() || 0;
  6340. }
  6341. this.offset = this.helper.offset();
  6342. this.position = { left: curleft, top: curtop };
  6343. this.size = this._helper ? {
  6344. width: this.helper.width(),
  6345. height: this.helper.height()
  6346. } : {
  6347. width: el.width(),
  6348. height: el.height()
  6349. };
  6350. this.originalSize = this._helper ? {
  6351. width: el.outerWidth(),
  6352. height: el.outerHeight()
  6353. } : {
  6354. width: el.width(),
  6355. height: el.height()
  6356. };
  6357. this.sizeDiff = {
  6358. width: el.outerWidth() - el.width(),
  6359. height: el.outerHeight() - el.height()
  6360. };
  6361. this.originalPosition = { left: curleft, top: curtop };
  6362. this.originalMousePosition = { left: event.pageX, top: event.pageY };
  6363. this.aspectRatio = (typeof o.aspectRatio === "number") ?
  6364. o.aspectRatio :
  6365. ((this.originalSize.width / this.originalSize.height) || 1);
  6366. cursor = $(".ui-resizable-" + this.axis).css("cursor");
  6367. $("body").css("cursor", cursor === "auto" ? this.axis + "-resize" : cursor);
  6368. el.addClass("ui-resizable-resizing");
  6369. this._propagate("start", event);
  6370. return true;
  6371. },
  6372. _mouseDrag: function(event) {
  6373. var data, props,
  6374. smp = this.originalMousePosition,
  6375. a = this.axis,
  6376. dx = (event.pageX - smp.left) || 0,
  6377. dy = (event.pageY - smp.top) || 0,
  6378. trigger = this._change[a];
  6379. this._updatePrevProperties();
  6380. if (!trigger) {
  6381. return false;
  6382. }
  6383. data = trigger.apply(this, [ event, dx, dy ]);
  6384. this._updateVirtualBoundaries(event.shiftKey);
  6385. if (this._aspectRatio || event.shiftKey) {
  6386. data = this._updateRatio(data, event);
  6387. }
  6388. data = this._respectSize(data, event);
  6389. this._updateCache(data);
  6390. this._propagate("resize", event);
  6391. props = this._applyChanges();
  6392. if ( !this._helper && this._proportionallyResizeElements.length ) {
  6393. this._proportionallyResize();
  6394. }
  6395. if ( !$.isEmptyObject( props ) ) {
  6396. this._updatePrevProperties();
  6397. this._trigger( "resize", event, this.ui() );
  6398. this._applyChanges();
  6399. }
  6400. return false;
  6401. },
  6402. _mouseStop: function(event) {
  6403. this.resizing = false;
  6404. var pr, ista, soffseth, soffsetw, s, left, top,
  6405. o = this.options, that = this;
  6406. if (this._helper) {
  6407. pr = this._proportionallyResizeElements;
  6408. ista = pr.length && (/textarea/i).test(pr[0].nodeName);
  6409. soffseth = ista && this._hasScroll(pr[0], "left") ? 0 : that.sizeDiff.height;
  6410. soffsetw = ista ? 0 : that.sizeDiff.width;
  6411. s = {
  6412. width: (that.helper.width() - soffsetw),
  6413. height: (that.helper.height() - soffseth)
  6414. };
  6415. left = (parseInt(that.element.css("left"), 10) +
  6416. (that.position.left - that.originalPosition.left)) || null;
  6417. top = (parseInt(that.element.css("top"), 10) +
  6418. (that.position.top - that.originalPosition.top)) || null;
  6419. if (!o.animate) {
  6420. this.element.css($.extend(s, { top: top, left: left }));
  6421. }
  6422. that.helper.height(that.size.height);
  6423. that.helper.width(that.size.width);
  6424. if (this._helper && !o.animate) {
  6425. this._proportionallyResize();
  6426. }
  6427. }
  6428. $("body").css("cursor", "auto");
  6429. this.element.removeClass("ui-resizable-resizing");
  6430. this._propagate("stop", event);
  6431. if (this._helper) {
  6432. this.helper.remove();
  6433. }
  6434. return false;
  6435. },
  6436. _updatePrevProperties: function() {
  6437. this.prevPosition = {
  6438. top: this.position.top,
  6439. left: this.position.left
  6440. };
  6441. this.prevSize = {
  6442. width: this.size.width,
  6443. height: this.size.height
  6444. };
  6445. },
  6446. _applyChanges: function() {
  6447. var props = {};
  6448. if ( this.position.top !== this.prevPosition.top ) {
  6449. props.top = this.position.top + "px";
  6450. }
  6451. if ( this.position.left !== this.prevPosition.left ) {
  6452. props.left = this.position.left + "px";
  6453. }
  6454. if ( this.size.width !== this.prevSize.width ) {
  6455. props.width = this.size.width + "px";
  6456. }
  6457. if ( this.size.height !== this.prevSize.height ) {
  6458. props.height = this.size.height + "px";
  6459. }
  6460. this.helper.css( props );
  6461. return props;
  6462. },
  6463. _updateVirtualBoundaries: function(forceAspectRatio) {
  6464. var pMinWidth, pMaxWidth, pMinHeight, pMaxHeight, b,
  6465. o = this.options;
  6466. b = {
  6467. minWidth: this._isNumber(o.minWidth) ? o.minWidth : 0,
  6468. maxWidth: this._isNumber(o.maxWidth) ? o.maxWidth : Infinity,
  6469. minHeight: this._isNumber(o.minHeight) ? o.minHeight : 0,
  6470. maxHeight: this._isNumber(o.maxHeight) ? o.maxHeight : Infinity
  6471. };
  6472. if (this._aspectRatio || forceAspectRatio) {
  6473. pMinWidth = b.minHeight * this.aspectRatio;
  6474. pMinHeight = b.minWidth / this.aspectRatio;
  6475. pMaxWidth = b.maxHeight * this.aspectRatio;
  6476. pMaxHeight = b.maxWidth / this.aspectRatio;
  6477. if (pMinWidth > b.minWidth) {
  6478. b.minWidth = pMinWidth;
  6479. }
  6480. if (pMinHeight > b.minHeight) {
  6481. b.minHeight = pMinHeight;
  6482. }
  6483. if (pMaxWidth < b.maxWidth) {
  6484. b.maxWidth = pMaxWidth;
  6485. }
  6486. if (pMaxHeight < b.maxHeight) {
  6487. b.maxHeight = pMaxHeight;
  6488. }
  6489. }
  6490. this._vBoundaries = b;
  6491. },
  6492. _updateCache: function(data) {
  6493. this.offset = this.helper.offset();
  6494. if (this._isNumber(data.left)) {
  6495. this.position.left = data.left;
  6496. }
  6497. if (this._isNumber(data.top)) {
  6498. this.position.top = data.top;
  6499. }
  6500. if (this._isNumber(data.height)) {
  6501. this.size.height = data.height;
  6502. }
  6503. if (this._isNumber(data.width)) {
  6504. this.size.width = data.width;
  6505. }
  6506. },
  6507. _updateRatio: function( data ) {
  6508. var cpos = this.position,
  6509. csize = this.size,
  6510. a = this.axis;
  6511. if (this._isNumber(data.height)) {
  6512. data.width = (data.height * this.aspectRatio);
  6513. } else if (this._isNumber(data.width)) {
  6514. data.height = (data.width / this.aspectRatio);
  6515. }
  6516. if (a === "sw") {
  6517. data.left = cpos.left + (csize.width - data.width);
  6518. data.top = null;
  6519. }
  6520. if (a === "nw") {
  6521. data.top = cpos.top + (csize.height - data.height);
  6522. data.left = cpos.left + (csize.width - data.width);
  6523. }
  6524. return data;
  6525. },
  6526. _respectSize: function( data ) {
  6527. var o = this._vBoundaries,
  6528. a = this.axis,
  6529. ismaxw = this._isNumber(data.width) && o.maxWidth && (o.maxWidth < data.width),
  6530. ismaxh = this._isNumber(data.height) && o.maxHeight && (o.maxHeight < data.height),
  6531. isminw = this._isNumber(data.width) && o.minWidth && (o.minWidth > data.width),
  6532. isminh = this._isNumber(data.height) && o.minHeight && (o.minHeight > data.height),
  6533. dw = this.originalPosition.left + this.originalSize.width,
  6534. dh = this.position.top + this.size.height,
  6535. cw = /sw|nw|w/.test(a), ch = /nw|ne|n/.test(a);
  6536. if (isminw) {
  6537. data.width = o.minWidth;
  6538. }
  6539. if (isminh) {
  6540. data.height = o.minHeight;
  6541. }
  6542. if (ismaxw) {
  6543. data.width = o.maxWidth;
  6544. }
  6545. if (ismaxh) {
  6546. data.height = o.maxHeight;
  6547. }
  6548. if (isminw && cw) {
  6549. data.left = dw - o.minWidth;
  6550. }
  6551. if (ismaxw && cw) {
  6552. data.left = dw - o.maxWidth;
  6553. }
  6554. if (isminh && ch) {
  6555. data.top = dh - o.minHeight;
  6556. }
  6557. if (ismaxh && ch) {
  6558. data.top = dh - o.maxHeight;
  6559. }
  6560. // Fixing jump error on top/left - bug #2330
  6561. if (!data.width && !data.height && !data.left && data.top) {
  6562. data.top = null;
  6563. } else if (!data.width && !data.height && !data.top && data.left) {
  6564. data.left = null;
  6565. }
  6566. return data;
  6567. },
  6568. _getPaddingPlusBorderDimensions: function( element ) {
  6569. var i = 0,
  6570. widths = [],
  6571. borders = [
  6572. element.css( "borderTopWidth" ),
  6573. element.css( "borderRightWidth" ),
  6574. element.css( "borderBottomWidth" ),
  6575. element.css( "borderLeftWidth" )
  6576. ],
  6577. paddings = [
  6578. element.css( "paddingTop" ),
  6579. element.css( "paddingRight" ),
  6580. element.css( "paddingBottom" ),
  6581. element.css( "paddingLeft" )
  6582. ];
  6583. for ( ; i < 4; i++ ) {
  6584. widths[ i ] = ( parseInt( borders[ i ], 10 ) || 0 );
  6585. widths[ i ] += ( parseInt( paddings[ i ], 10 ) || 0 );
  6586. }
  6587. return {
  6588. height: widths[ 0 ] + widths[ 2 ],
  6589. width: widths[ 1 ] + widths[ 3 ]
  6590. };
  6591. },
  6592. _proportionallyResize: function() {
  6593. if (!this._proportionallyResizeElements.length) {
  6594. return;
  6595. }
  6596. var prel,
  6597. i = 0,
  6598. element = this.helper || this.element;
  6599. for ( ; i < this._proportionallyResizeElements.length; i++) {
  6600. prel = this._proportionallyResizeElements[i];
  6601. // TODO: Seems like a bug to cache this.outerDimensions
  6602. // considering that we are in a loop.
  6603. if (!this.outerDimensions) {
  6604. this.outerDimensions = this._getPaddingPlusBorderDimensions( prel );
  6605. }
  6606. prel.css({
  6607. height: (element.height() - this.outerDimensions.height) || 0,
  6608. width: (element.width() - this.outerDimensions.width) || 0
  6609. });
  6610. }
  6611. },
  6612. _renderProxy: function() {
  6613. var el = this.element, o = this.options;
  6614. this.elementOffset = el.offset();
  6615. if (this._helper) {
  6616. this.helper = this.helper || $("<div style='overflow:hidden;'></div>");
  6617. this.helper.addClass(this._helper).css({
  6618. width: this.element.outerWidth() - 1,
  6619. height: this.element.outerHeight() - 1,
  6620. position: "absolute",
  6621. left: this.elementOffset.left + "px",
  6622. top: this.elementOffset.top + "px",
  6623. zIndex: ++o.zIndex //TODO: Don't modify option
  6624. });
  6625. this.helper
  6626. .appendTo("body")
  6627. .disableSelection();
  6628. } else {
  6629. this.helper = this.element;
  6630. }
  6631. },
  6632. _change: {
  6633. e: function(event, dx) {
  6634. return { width: this.originalSize.width + dx };
  6635. },
  6636. w: function(event, dx) {
  6637. var cs = this.originalSize, sp = this.originalPosition;
  6638. return { left: sp.left + dx, width: cs.width - dx };
  6639. },
  6640. n: function(event, dx, dy) {
  6641. var cs = this.originalSize, sp = this.originalPosition;
  6642. return { top: sp.top + dy, height: cs.height - dy };
  6643. },
  6644. s: function(event, dx, dy) {
  6645. return { height: this.originalSize.height + dy };
  6646. },
  6647. se: function(event, dx, dy) {
  6648. return $.extend(this._change.s.apply(this, arguments),
  6649. this._change.e.apply(this, [ event, dx, dy ]));
  6650. },
  6651. sw: function(event, dx, dy) {
  6652. return $.extend(this._change.s.apply(this, arguments),
  6653. this._change.w.apply(this, [ event, dx, dy ]));
  6654. },
  6655. ne: function(event, dx, dy) {
  6656. return $.extend(this._change.n.apply(this, arguments),
  6657. this._change.e.apply(this, [ event, dx, dy ]));
  6658. },
  6659. nw: function(event, dx, dy) {
  6660. return $.extend(this._change.n.apply(this, arguments),
  6661. this._change.w.apply(this, [ event, dx, dy ]));
  6662. }
  6663. },
  6664. _propagate: function(n, event) {
  6665. $.ui.plugin.call(this, n, [ event, this.ui() ]);
  6666. (n !== "resize" && this._trigger(n, event, this.ui()));
  6667. },
  6668. plugins: {},
  6669. ui: function() {
  6670. return {
  6671. originalElement: this.originalElement,
  6672. element: this.element,
  6673. helper: this.helper,
  6674. position: this.position,
  6675. size: this.size,
  6676. originalSize: this.originalSize,
  6677. originalPosition: this.originalPosition
  6678. };
  6679. }
  6680. });
  6681. /*
  6682. * Resizable Extensions
  6683. */
  6684. $.ui.plugin.add("resizable", "animate", {
  6685. stop: function( event ) {
  6686. var that = $(this).resizable( "instance" ),
  6687. o = that.options,
  6688. pr = that._proportionallyResizeElements,
  6689. ista = pr.length && (/textarea/i).test(pr[0].nodeName),
  6690. soffseth = ista && that._hasScroll(pr[0], "left") ? 0 : that.sizeDiff.height,
  6691. soffsetw = ista ? 0 : that.sizeDiff.width,
  6692. style = { width: (that.size.width - soffsetw), height: (that.size.height - soffseth) },
  6693. left = (parseInt(that.element.css("left"), 10) +
  6694. (that.position.left - that.originalPosition.left)) || null,
  6695. top = (parseInt(that.element.css("top"), 10) +
  6696. (that.position.top - that.originalPosition.top)) || null;
  6697. that.element.animate(
  6698. $.extend(style, top && left ? { top: top, left: left } : {}), {
  6699. duration: o.animateDuration,
  6700. easing: o.animateEasing,
  6701. step: function() {
  6702. var data = {
  6703. width: parseInt(that.element.css("width"), 10),
  6704. height: parseInt(that.element.css("height"), 10),
  6705. top: parseInt(that.element.css("top"), 10),
  6706. left: parseInt(that.element.css("left"), 10)
  6707. };
  6708. if (pr && pr.length) {
  6709. $(pr[0]).css({ width: data.width, height: data.height });
  6710. }
  6711. // propagating resize, and updating values for each animation step
  6712. that._updateCache(data);
  6713. that._propagate("resize", event);
  6714. }
  6715. }
  6716. );
  6717. }
  6718. });
  6719. $.ui.plugin.add( "resizable", "containment", {
  6720. start: function() {
  6721. var element, p, co, ch, cw, width, height,
  6722. that = $( this ).resizable( "instance" ),
  6723. o = that.options,
  6724. el = that.element,
  6725. oc = o.containment,
  6726. ce = ( oc instanceof $ ) ? oc.get( 0 ) : ( /parent/.test( oc ) ) ? el.parent().get( 0 ) : oc;
  6727. if ( !ce ) {
  6728. return;
  6729. }
  6730. that.containerElement = $( ce );
  6731. if ( /document/.test( oc ) || oc === document ) {
  6732. that.containerOffset = {
  6733. left: 0,
  6734. top: 0
  6735. };
  6736. that.containerPosition = {
  6737. left: 0,
  6738. top: 0
  6739. };
  6740. that.parentData = {
  6741. element: $( document ),
  6742. left: 0,
  6743. top: 0,
  6744. width: $( document ).width(),
  6745. height: $( document ).height() || document.body.parentNode.scrollHeight
  6746. };
  6747. } else {
  6748. element = $( ce );
  6749. p = [];
  6750. $([ "Top", "Right", "Left", "Bottom" ]).each(function( i, name ) {
  6751. p[ i ] = that._num( element.css( "padding" + name ) );
  6752. });
  6753. that.containerOffset = element.offset();
  6754. that.containerPosition = element.position();
  6755. that.containerSize = {
  6756. height: ( element.innerHeight() - p[ 3 ] ),
  6757. width: ( element.innerWidth() - p[ 1 ] )
  6758. };
  6759. co = that.containerOffset;
  6760. ch = that.containerSize.height;
  6761. cw = that.containerSize.width;
  6762. width = ( that._hasScroll ( ce, "left" ) ? ce.scrollWidth : cw );
  6763. height = ( that._hasScroll ( ce ) ? ce.scrollHeight : ch ) ;
  6764. that.parentData = {
  6765. element: ce,
  6766. left: co.left,
  6767. top: co.top,
  6768. width: width,
  6769. height: height
  6770. };
  6771. }
  6772. },
  6773. resize: function( event ) {
  6774. var woset, hoset, isParent, isOffsetRelative,
  6775. that = $( this ).resizable( "instance" ),
  6776. o = that.options,
  6777. co = that.containerOffset,
  6778. cp = that.position,
  6779. pRatio = that._aspectRatio || event.shiftKey,
  6780. cop = {
  6781. top: 0,
  6782. left: 0
  6783. },
  6784. ce = that.containerElement,
  6785. continueResize = true;
  6786. if ( ce[ 0 ] !== document && ( /static/ ).test( ce.css( "position" ) ) ) {
  6787. cop = co;
  6788. }
  6789. if ( cp.left < ( that._helper ? co.left : 0 ) ) {
  6790. that.size.width = that.size.width +
  6791. ( that._helper ?
  6792. ( that.position.left - co.left ) :
  6793. ( that.position.left - cop.left ) );
  6794. if ( pRatio ) {
  6795. that.size.height = that.size.width / that.aspectRatio;
  6796. continueResize = false;
  6797. }
  6798. that.position.left = o.helper ? co.left : 0;
  6799. }
  6800. if ( cp.top < ( that._helper ? co.top : 0 ) ) {
  6801. that.size.height = that.size.height +
  6802. ( that._helper ?
  6803. ( that.position.top - co.top ) :
  6804. that.position.top );
  6805. if ( pRatio ) {
  6806. that.size.width = that.size.height * that.aspectRatio;
  6807. continueResize = false;
  6808. }
  6809. that.position.top = that._helper ? co.top : 0;
  6810. }
  6811. isParent = that.containerElement.get( 0 ) === that.element.parent().get( 0 );
  6812. isOffsetRelative = /relative|absolute/.test( that.containerElement.css( "position" ) );
  6813. if ( isParent && isOffsetRelative ) {
  6814. that.offset.left = that.parentData.left + that.position.left;
  6815. that.offset.top = that.parentData.top + that.position.top;
  6816. } else {
  6817. that.offset.left = that.element.offset().left;
  6818. that.offset.top = that.element.offset().top;
  6819. }
  6820. woset = Math.abs( that.sizeDiff.width +
  6821. (that._helper ?
  6822. that.offset.left - cop.left :
  6823. (that.offset.left - co.left)) );
  6824. hoset = Math.abs( that.sizeDiff.height +
  6825. (that._helper ?
  6826. that.offset.top - cop.top :
  6827. (that.offset.top - co.top)) );
  6828. if ( woset + that.size.width >= that.parentData.width ) {
  6829. that.size.width = that.parentData.width - woset;
  6830. if ( pRatio ) {
  6831. that.size.height = that.size.width / that.aspectRatio;
  6832. continueResize = false;
  6833. }
  6834. }
  6835. if ( hoset + that.size.height >= that.parentData.height ) {
  6836. that.size.height = that.parentData.height - hoset;
  6837. if ( pRatio ) {
  6838. that.size.width = that.size.height * that.aspectRatio;
  6839. continueResize = false;
  6840. }
  6841. }
  6842. if ( !continueResize ){
  6843. that.position.left = that.prevPosition.left;
  6844. that.position.top = that.prevPosition.top;
  6845. that.size.width = that.prevSize.width;
  6846. that.size.height = that.prevSize.height;
  6847. }
  6848. },
  6849. stop: function() {
  6850. var that = $( this ).resizable( "instance" ),
  6851. o = that.options,
  6852. co = that.containerOffset,
  6853. cop = that.containerPosition,
  6854. ce = that.containerElement,
  6855. helper = $( that.helper ),
  6856. ho = helper.offset(),
  6857. w = helper.outerWidth() - that.sizeDiff.width,
  6858. h = helper.outerHeight() - that.sizeDiff.height;
  6859. if ( that._helper && !o.animate && ( /relative/ ).test( ce.css( "position" ) ) ) {
  6860. $( this ).css({
  6861. left: ho.left - cop.left - co.left,
  6862. width: w,
  6863. height: h
  6864. });
  6865. }
  6866. if ( that._helper && !o.animate && ( /static/ ).test( ce.css( "position" ) ) ) {
  6867. $( this ).css({
  6868. left: ho.left - cop.left - co.left,
  6869. width: w,
  6870. height: h
  6871. });
  6872. }
  6873. }
  6874. });
  6875. $.ui.plugin.add("resizable", "alsoResize", {
  6876. start: function() {
  6877. var that = $(this).resizable( "instance" ),
  6878. o = that.options,
  6879. _store = function(exp) {
  6880. $(exp).each(function() {
  6881. var el = $(this);
  6882. el.data("ui-resizable-alsoresize", {
  6883. width: parseInt(el.width(), 10), height: parseInt(el.height(), 10),
  6884. left: parseInt(el.css("left"), 10), top: parseInt(el.css("top"), 10)
  6885. });
  6886. });
  6887. };
  6888. if (typeof(o.alsoResize) === "object" && !o.alsoResize.parentNode) {
  6889. if (o.alsoResize.length) {
  6890. o.alsoResize = o.alsoResize[0];
  6891. _store(o.alsoResize);
  6892. } else {
  6893. $.each(o.alsoResize, function(exp) {
  6894. _store(exp);
  6895. });
  6896. }
  6897. } else {
  6898. _store(o.alsoResize);
  6899. }
  6900. },
  6901. resize: function(event, ui) {
  6902. var that = $(this).resizable( "instance" ),
  6903. o = that.options,
  6904. os = that.originalSize,
  6905. op = that.originalPosition,
  6906. delta = {
  6907. height: (that.size.height - os.height) || 0,
  6908. width: (that.size.width - os.width) || 0,
  6909. top: (that.position.top - op.top) || 0,
  6910. left: (that.position.left - op.left) || 0
  6911. },
  6912. _alsoResize = function(exp, c) {
  6913. $(exp).each(function() {
  6914. var el = $(this), start = $(this).data("ui-resizable-alsoresize"), style = {},
  6915. css = c && c.length ?
  6916. c :
  6917. el.parents(ui.originalElement[0]).length ?
  6918. [ "width", "height" ] :
  6919. [ "width", "height", "top", "left" ];
  6920. $.each(css, function(i, prop) {
  6921. var sum = (start[prop] || 0) + (delta[prop] || 0);
  6922. if (sum && sum >= 0) {
  6923. style[prop] = sum || null;
  6924. }
  6925. });
  6926. el.css(style);
  6927. });
  6928. };
  6929. if (typeof(o.alsoResize) === "object" && !o.alsoResize.nodeType) {
  6930. $.each(o.alsoResize, function(exp, c) {
  6931. _alsoResize(exp, c);
  6932. });
  6933. } else {
  6934. _alsoResize(o.alsoResize);
  6935. }
  6936. },
  6937. stop: function() {
  6938. $(this).removeData("resizable-alsoresize");
  6939. }
  6940. });
  6941. $.ui.plugin.add("resizable", "ghost", {
  6942. start: function() {
  6943. var that = $(this).resizable( "instance" ), o = that.options, cs = that.size;
  6944. that.ghost = that.originalElement.clone();
  6945. that.ghost
  6946. .css({
  6947. opacity: 0.25,
  6948. display: "block",
  6949. position: "relative",
  6950. height: cs.height,
  6951. width: cs.width,
  6952. margin: 0,
  6953. left: 0,
  6954. top: 0
  6955. })
  6956. .addClass("ui-resizable-ghost")
  6957. .addClass(typeof o.ghost === "string" ? o.ghost : "");
  6958. that.ghost.appendTo(that.helper);
  6959. },
  6960. resize: function() {
  6961. var that = $(this).resizable( "instance" );
  6962. if (that.ghost) {
  6963. that.ghost.css({
  6964. position: "relative",
  6965. height: that.size.height,
  6966. width: that.size.width
  6967. });
  6968. }
  6969. },
  6970. stop: function() {
  6971. var that = $(this).resizable( "instance" );
  6972. if (that.ghost && that.helper) {
  6973. that.helper.get(0).removeChild(that.ghost.get(0));
  6974. }
  6975. }
  6976. });
  6977. $.ui.plugin.add("resizable", "grid", {
  6978. resize: function() {
  6979. var outerDimensions,
  6980. that = $(this).resizable( "instance" ),
  6981. o = that.options,
  6982. cs = that.size,
  6983. os = that.originalSize,
  6984. op = that.originalPosition,
  6985. a = that.axis,
  6986. grid = typeof o.grid === "number" ? [ o.grid, o.grid ] : o.grid,
  6987. gridX = (grid[0] || 1),
  6988. gridY = (grid[1] || 1),
  6989. ox = Math.round((cs.width - os.width) / gridX) * gridX,
  6990. oy = Math.round((cs.height - os.height) / gridY) * gridY,
  6991. newWidth = os.width + ox,
  6992. newHeight = os.height + oy,
  6993. isMaxWidth = o.maxWidth && (o.maxWidth < newWidth),
  6994. isMaxHeight = o.maxHeight && (o.maxHeight < newHeight),
  6995. isMinWidth = o.minWidth && (o.minWidth > newWidth),
  6996. isMinHeight = o.minHeight && (o.minHeight > newHeight);
  6997. o.grid = grid;
  6998. if (isMinWidth) {
  6999. newWidth += gridX;
  7000. }
  7001. if (isMinHeight) {
  7002. newHeight += gridY;
  7003. }
  7004. if (isMaxWidth) {
  7005. newWidth -= gridX;
  7006. }
  7007. if (isMaxHeight) {
  7008. newHeight -= gridY;
  7009. }
  7010. if (/^(se|s|e)$/.test(a)) {
  7011. that.size.width = newWidth;
  7012. that.size.height = newHeight;
  7013. } else if (/^(ne)$/.test(a)) {
  7014. that.size.width = newWidth;
  7015. that.size.height = newHeight;
  7016. that.position.top = op.top - oy;
  7017. } else if (/^(sw)$/.test(a)) {
  7018. that.size.width = newWidth;
  7019. that.size.height = newHeight;
  7020. that.position.left = op.left - ox;
  7021. } else {
  7022. if ( newHeight - gridY <= 0 || newWidth - gridX <= 0) {
  7023. outerDimensions = that._getPaddingPlusBorderDimensions( this );
  7024. }
  7025. if ( newHeight - gridY > 0 ) {
  7026. that.size.height = newHeight;
  7027. that.position.top = op.top - oy;
  7028. } else {
  7029. newHeight = gridY - outerDimensions.height;
  7030. that.size.height = newHeight;
  7031. that.position.top = op.top + os.height - newHeight;
  7032. }
  7033. if ( newWidth - gridX > 0 ) {
  7034. that.size.width = newWidth;
  7035. that.position.left = op.left - ox;
  7036. } else {
  7037. newWidth = gridY - outerDimensions.height;
  7038. that.size.width = newWidth;
  7039. that.position.left = op.left + os.width - newWidth;
  7040. }
  7041. }
  7042. }
  7043. });
  7044. var resizable = $.ui.resizable;
  7045. /*!
  7046. * jQuery UI Dialog 1.11.2
  7047. * http://jqueryui.com
  7048. *
  7049. * Copyright 2014 jQuery Foundation and other contributors
  7050. * Released under the MIT license.
  7051. * http://jquery.org/license
  7052. *
  7053. * http://api.jqueryui.com/dialog/
  7054. */
  7055. var dialog = $.widget( "ui.dialog", {
  7056. version: "1.11.2",
  7057. options: {
  7058. appendTo: "body",
  7059. autoOpen: true,
  7060. buttons: [],
  7061. closeOnEscape: true,
  7062. closeText: "Close",
  7063. dialogClass: "",
  7064. draggable: true,
  7065. hide: null,
  7066. height: "auto",
  7067. maxHeight: null,
  7068. maxWidth: null,
  7069. minHeight: 150,
  7070. minWidth: 150,
  7071. modal: false,
  7072. position: {
  7073. my: "center",
  7074. at: "center",
  7075. of: window,
  7076. collision: "fit",
  7077. // Ensure the titlebar is always visible
  7078. using: function( pos ) {
  7079. var topOffset = $( this ).css( pos ).offset().top;
  7080. if ( topOffset < 0 ) {
  7081. $( this ).css( "top", pos.top - topOffset );
  7082. }
  7083. }
  7084. },
  7085. resizable: true,
  7086. show: null,
  7087. title: null,
  7088. width: 300,
  7089. // callbacks
  7090. beforeClose: null,
  7091. close: null,
  7092. drag: null,
  7093. dragStart: null,
  7094. dragStop: null,
  7095. focus: null,
  7096. open: null,
  7097. resize: null,
  7098. resizeStart: null,
  7099. resizeStop: null
  7100. },
  7101. sizeRelatedOptions: {
  7102. buttons: true,
  7103. height: true,
  7104. maxHeight: true,
  7105. maxWidth: true,
  7106. minHeight: true,
  7107. minWidth: true,
  7108. width: true
  7109. },
  7110. resizableRelatedOptions: {
  7111. maxHeight: true,
  7112. maxWidth: true,
  7113. minHeight: true,
  7114. minWidth: true
  7115. },
  7116. _create: function() {
  7117. this.originalCss = {
  7118. display: this.element[ 0 ].style.display,
  7119. width: this.element[ 0 ].style.width,
  7120. minHeight: this.element[ 0 ].style.minHeight,
  7121. maxHeight: this.element[ 0 ].style.maxHeight,
  7122. height: this.element[ 0 ].style.height
  7123. };
  7124. this.originalPosition = {
  7125. parent: this.element.parent(),
  7126. index: this.element.parent().children().index( this.element )
  7127. };
  7128. this.originalTitle = this.element.attr( "title" );
  7129. this.options.title = this.options.title || this.originalTitle;
  7130. this._createWrapper();
  7131. this.element
  7132. .show()
  7133. .removeAttr( "title" )
  7134. .addClass( "ui-dialog-content ui-widget-content" )
  7135. .appendTo( this.uiDialog );
  7136. this._createTitlebar();
  7137. this._createButtonPane();
  7138. if ( this.options.draggable && $.fn.draggable ) {
  7139. this._makeDraggable();
  7140. }
  7141. if ( this.options.resizable && $.fn.resizable ) {
  7142. this._makeResizable();
  7143. }
  7144. this._isOpen = false;
  7145. this._trackFocus();
  7146. },
  7147. _init: function() {
  7148. if ( this.options.autoOpen ) {
  7149. this.open();
  7150. }
  7151. },
  7152. _appendTo: function() {
  7153. var element = this.options.appendTo;
  7154. if ( element && (element.jquery || element.nodeType) ) {
  7155. return $( element );
  7156. }
  7157. return this.document.find( element || "body" ).eq( 0 );
  7158. },
  7159. _destroy: function() {
  7160. var next,
  7161. originalPosition = this.originalPosition;
  7162. this._destroyOverlay();
  7163. this.element
  7164. .removeUniqueId()
  7165. .removeClass( "ui-dialog-content ui-widget-content" )
  7166. .css( this.originalCss )
  7167. // Without detaching first, the following becomes really slow
  7168. .detach();
  7169. this.uiDialog.stop( true, true ).remove();
  7170. if ( this.originalTitle ) {
  7171. this.element.attr( "title", this.originalTitle );
  7172. }
  7173. next = originalPosition.parent.children().eq( originalPosition.index );
  7174. // Don't try to place the dialog next to itself (#8613)
  7175. if ( next.length && next[ 0 ] !== this.element[ 0 ] ) {
  7176. next.before( this.element );
  7177. } else {
  7178. originalPosition.parent.append( this.element );
  7179. }
  7180. },
  7181. widget: function() {
  7182. return this.uiDialog;
  7183. },
  7184. disable: $.noop,
  7185. enable: $.noop,
  7186. close: function( event ) {
  7187. var activeElement,
  7188. that = this;
  7189. if ( !this._isOpen || this._trigger( "beforeClose", event ) === false ) {
  7190. return;
  7191. }
  7192. this._isOpen = false;
  7193. this._focusedElement = null;
  7194. this._destroyOverlay();
  7195. this._untrackInstance();
  7196. if ( !this.opener.filter( ":focusable" ).focus().length ) {
  7197. // support: IE9
  7198. // IE9 throws an "Unspecified error" accessing document.activeElement from an <iframe>
  7199. try {
  7200. activeElement = this.document[ 0 ].activeElement;
  7201. // Support: IE9, IE10
  7202. // If the <body> is blurred, IE will switch windows, see #4520
  7203. if ( activeElement && activeElement.nodeName.toLowerCase() !== "body" ) {
  7204. // Hiding a focused element doesn't trigger blur in WebKit
  7205. // so in case we have nothing to focus on, explicitly blur the active element
  7206. // https://bugs.webkit.org/show_bug.cgi?id=47182
  7207. $( activeElement ).blur();
  7208. }
  7209. } catch ( error ) {}
  7210. }
  7211. this._hide( this.uiDialog, this.options.hide, function() {
  7212. that._trigger( "close", event );
  7213. });
  7214. },
  7215. isOpen: function() {
  7216. return this._isOpen;
  7217. },
  7218. moveToTop: function() {
  7219. this._moveToTop();
  7220. },
  7221. _moveToTop: function( event, silent ) {
  7222. var moved = false,
  7223. zIndicies = this.uiDialog.siblings( ".ui-front:visible" ).map(function() {
  7224. return +$( this ).css( "z-index" );
  7225. }).get(),
  7226. zIndexMax = Math.max.apply( null, zIndicies );
  7227. if ( zIndexMax >= +this.uiDialog.css( "z-index" ) ) {
  7228. this.uiDialog.css( "z-index", zIndexMax + 1 );
  7229. moved = true;
  7230. }
  7231. if ( moved && !silent ) {
  7232. this._trigger( "focus", event );
  7233. }
  7234. return moved;
  7235. },
  7236. open: function() {
  7237. var that = this;
  7238. if ( this._isOpen ) {
  7239. if ( this._moveToTop() ) {
  7240. this._focusTabbable();
  7241. }
  7242. return;
  7243. }
  7244. this._isOpen = true;
  7245. this.opener = $( this.document[ 0 ].activeElement );
  7246. this._size();
  7247. this._position();
  7248. this._createOverlay();
  7249. this._moveToTop( null, true );
  7250. // Ensure the overlay is moved to the top with the dialog, but only when
  7251. // opening. The overlay shouldn't move after the dialog is open so that
  7252. // modeless dialogs opened after the modal dialog stack properly.
  7253. if ( this.overlay ) {
  7254. this.overlay.css( "z-index", this.uiDialog.css( "z-index" ) - 1 );
  7255. }
  7256. this._show( this.uiDialog, this.options.show, function() {
  7257. that._focusTabbable();
  7258. that._trigger( "focus" );
  7259. });
  7260. // Track the dialog immediately upon openening in case a focus event
  7261. // somehow occurs outside of the dialog before an element inside the
  7262. // dialog is focused (#10152)
  7263. this._makeFocusTarget();
  7264. this._trigger( "open" );
  7265. },
  7266. _focusTabbable: function() {
  7267. // Set focus to the first match:
  7268. // 1. An element that was focused previously
  7269. // 2. First element inside the dialog matching [autofocus]
  7270. // 3. Tabbable element inside the content element
  7271. // 4. Tabbable element inside the buttonpane
  7272. // 5. The close button
  7273. // 6. The dialog itself
  7274. var hasFocus = this._focusedElement;
  7275. if ( !hasFocus ) {
  7276. hasFocus = this.element.find( "[autofocus]" );
  7277. }
  7278. if ( !hasFocus.length ) {
  7279. hasFocus = this.element.find( ":tabbable" );
  7280. }
  7281. if ( !hasFocus.length ) {
  7282. hasFocus = this.uiDialogButtonPane.find( ":tabbable" );
  7283. }
  7284. if ( !hasFocus.length ) {
  7285. hasFocus = this.uiDialogTitlebarClose.filter( ":tabbable" );
  7286. }
  7287. if ( !hasFocus.length ) {
  7288. hasFocus = this.uiDialog;
  7289. }
  7290. hasFocus.eq( 0 ).focus();
  7291. },
  7292. _keepFocus: function( event ) {
  7293. function checkFocus() {
  7294. var activeElement = this.document[0].activeElement,
  7295. isActive = this.uiDialog[0] === activeElement ||
  7296. $.contains( this.uiDialog[0], activeElement );
  7297. if ( !isActive ) {
  7298. this._focusTabbable();
  7299. }
  7300. }
  7301. event.preventDefault();
  7302. checkFocus.call( this );
  7303. // support: IE
  7304. // IE <= 8 doesn't prevent moving focus even with event.preventDefault()
  7305. // so we check again later
  7306. this._delay( checkFocus );
  7307. },
  7308. _createWrapper: function() {
  7309. this.uiDialog = $("<div>")
  7310. .addClass( "ui-dialog ui-widget ui-widget-content ui-corner-all ui-front " +
  7311. this.options.dialogClass )
  7312. .hide()
  7313. .attr({
  7314. // Setting tabIndex makes the div focusable
  7315. tabIndex: -1,
  7316. role: "dialog"
  7317. })
  7318. .appendTo( this._appendTo() );
  7319. this._on( this.uiDialog, {
  7320. keydown: function( event ) {
  7321. if ( this.options.closeOnEscape && !event.isDefaultPrevented() && event.keyCode &&
  7322. event.keyCode === $.ui.keyCode.ESCAPE ) {
  7323. event.preventDefault();
  7324. this.close( event );
  7325. return;
  7326. }
  7327. // prevent tabbing out of dialogs
  7328. if ( event.keyCode !== $.ui.keyCode.TAB || event.isDefaultPrevented() ) {
  7329. return;
  7330. }
  7331. var tabbables = this.uiDialog.find( ":tabbable" ),
  7332. first = tabbables.filter( ":first" ),
  7333. last = tabbables.filter( ":last" );
  7334. if ( ( event.target === last[0] || event.target === this.uiDialog[0] ) && !event.shiftKey ) {
  7335. this._delay(function() {
  7336. first.focus();
  7337. });
  7338. event.preventDefault();
  7339. } else if ( ( event.target === first[0] || event.target === this.uiDialog[0] ) && event.shiftKey ) {
  7340. this._delay(function() {
  7341. last.focus();
  7342. });
  7343. event.preventDefault();
  7344. }
  7345. },
  7346. mousedown: function( event ) {
  7347. if ( this._moveToTop( event ) ) {
  7348. this._focusTabbable();
  7349. }
  7350. }
  7351. });
  7352. // We assume that any existing aria-describedby attribute means
  7353. // that the dialog content is marked up properly
  7354. // otherwise we brute force the content as the description
  7355. if ( !this.element.find( "[aria-describedby]" ).length ) {
  7356. this.uiDialog.attr({
  7357. "aria-describedby": this.element.uniqueId().attr( "id" )
  7358. });
  7359. }
  7360. },
  7361. _createTitlebar: function() {
  7362. var uiDialogTitle;
  7363. this.uiDialogTitlebar = $( "<div>" )
  7364. .addClass( "ui-dialog-titlebar ui-widget-header ui-corner-all ui-helper-clearfix" )
  7365. .prependTo( this.uiDialog );
  7366. this._on( this.uiDialogTitlebar, {
  7367. mousedown: function( event ) {
  7368. // Don't prevent click on close button (#8838)
  7369. // Focusing a dialog that is partially scrolled out of view
  7370. // causes the browser to scroll it into view, preventing the click event
  7371. if ( !$( event.target ).closest( ".ui-dialog-titlebar-close" ) ) {
  7372. // Dialog isn't getting focus when dragging (#8063)
  7373. this.uiDialog.focus();
  7374. }
  7375. }
  7376. });
  7377. // support: IE
  7378. // Use type="button" to prevent enter keypresses in textboxes from closing the
  7379. // dialog in IE (#9312)
  7380. this.uiDialogTitlebarClose = $( "<button type='button'></button>" )
  7381. .button({
  7382. label: this.options.closeText,
  7383. icons: {
  7384. primary: "ui-icon-closethick"
  7385. },
  7386. text: false
  7387. })
  7388. .addClass( "ui-dialog-titlebar-close" )
  7389. .appendTo( this.uiDialogTitlebar );
  7390. this._on( this.uiDialogTitlebarClose, {
  7391. click: function( event ) {
  7392. event.preventDefault();
  7393. this.close( event );
  7394. }
  7395. });
  7396. uiDialogTitle = $( "<span>" )
  7397. .uniqueId()
  7398. .addClass( "ui-dialog-title" )
  7399. .prependTo( this.uiDialogTitlebar );
  7400. this._title( uiDialogTitle );
  7401. this.uiDialog.attr({
  7402. "aria-labelledby": uiDialogTitle.attr( "id" )
  7403. });
  7404. },
  7405. _title: function( title ) {
  7406. if ( !this.options.title ) {
  7407. title.html( "&#160;" );
  7408. }
  7409. title.text( this.options.title );
  7410. },
  7411. _createButtonPane: function() {
  7412. this.uiDialogButtonPane = $( "<div>" )
  7413. .addClass( "ui-dialog-buttonpane ui-widget-content ui-helper-clearfix" );
  7414. this.uiButtonSet = $( "<div>" )
  7415. .addClass( "ui-dialog-buttonset" )
  7416. .appendTo( this.uiDialogButtonPane );
  7417. this._createButtons();
  7418. },
  7419. _createButtons: function() {
  7420. var that = this,
  7421. buttons = this.options.buttons;
  7422. // if we already have a button pane, remove it
  7423. this.uiDialogButtonPane.remove();
  7424. this.uiButtonSet.empty();
  7425. if ( $.isEmptyObject( buttons ) || ($.isArray( buttons ) && !buttons.length) ) {
  7426. this.uiDialog.removeClass( "ui-dialog-buttons" );
  7427. return;
  7428. }
  7429. $.each( buttons, function( name, props ) {
  7430. var click, buttonOptions;
  7431. props = $.isFunction( props ) ?
  7432. { click: props, text: name } :
  7433. props;
  7434. // Default to a non-submitting button
  7435. props = $.extend( { type: "button" }, props );
  7436. // Change the context for the click callback to be the main element
  7437. click = props.click;
  7438. props.click = function() {
  7439. click.apply( that.element[ 0 ], arguments );
  7440. };
  7441. buttonOptions = {
  7442. icons: props.icons,
  7443. text: props.showText
  7444. };
  7445. delete props.icons;
  7446. delete props.showText;
  7447. $( "<button></button>", props )
  7448. .button( buttonOptions )
  7449. .appendTo( that.uiButtonSet );
  7450. });
  7451. this.uiDialog.addClass( "ui-dialog-buttons" );
  7452. this.uiDialogButtonPane.appendTo( this.uiDialog );
  7453. },
  7454. _makeDraggable: function() {
  7455. var that = this,
  7456. options = this.options;
  7457. function filteredUi( ui ) {
  7458. return {
  7459. position: ui.position,
  7460. offset: ui.offset
  7461. };
  7462. }
  7463. this.uiDialog.draggable({
  7464. cancel: ".ui-dialog-content, .ui-dialog-titlebar-close",
  7465. handle: ".ui-dialog-titlebar",
  7466. containment: "document",
  7467. start: function( event, ui ) {
  7468. $( this ).addClass( "ui-dialog-dragging" );
  7469. that._blockFrames();
  7470. that._trigger( "dragStart", event, filteredUi( ui ) );
  7471. },
  7472. drag: function( event, ui ) {
  7473. that._trigger( "drag", event, filteredUi( ui ) );
  7474. },
  7475. stop: function( event, ui ) {
  7476. var left = ui.offset.left - that.document.scrollLeft(),
  7477. top = ui.offset.top - that.document.scrollTop();
  7478. options.position = {
  7479. my: "left top",
  7480. at: "left" + (left >= 0 ? "+" : "") + left + " " +
  7481. "top" + (top >= 0 ? "+" : "") + top,
  7482. of: that.window
  7483. };
  7484. $( this ).removeClass( "ui-dialog-dragging" );
  7485. that._unblockFrames();
  7486. that._trigger( "dragStop", event, filteredUi( ui ) );
  7487. }
  7488. });
  7489. },
  7490. _makeResizable: function() {
  7491. var that = this,
  7492. options = this.options,
  7493. handles = options.resizable,
  7494. // .ui-resizable has position: relative defined in the stylesheet
  7495. // but dialogs have to use absolute or fixed positioning
  7496. position = this.uiDialog.css("position"),
  7497. resizeHandles = typeof handles === "string" ?
  7498. handles :
  7499. "n,e,s,w,se,sw,ne,nw";
  7500. function filteredUi( ui ) {
  7501. return {
  7502. originalPosition: ui.originalPosition,
  7503. originalSize: ui.originalSize,
  7504. position: ui.position,
  7505. size: ui.size
  7506. };
  7507. }
  7508. this.uiDialog.resizable({
  7509. cancel: ".ui-dialog-content",
  7510. containment: "document",
  7511. alsoResize: this.element,
  7512. maxWidth: options.maxWidth,
  7513. maxHeight: options.maxHeight,
  7514. minWidth: options.minWidth,
  7515. minHeight: this._minHeight(),
  7516. handles: resizeHandles,
  7517. start: function( event, ui ) {
  7518. $( this ).addClass( "ui-dialog-resizing" );
  7519. that._blockFrames();
  7520. that._trigger( "resizeStart", event, filteredUi( ui ) );
  7521. },
  7522. resize: function( event, ui ) {
  7523. that._trigger( "resize", event, filteredUi( ui ) );
  7524. },
  7525. stop: function( event, ui ) {
  7526. var offset = that.uiDialog.offset(),
  7527. left = offset.left - that.document.scrollLeft(),
  7528. top = offset.top - that.document.scrollTop();
  7529. options.height = that.uiDialog.height();
  7530. options.width = that.uiDialog.width();
  7531. options.position = {
  7532. my: "left top",
  7533. at: "left" + (left >= 0 ? "+" : "") + left + " " +
  7534. "top" + (top >= 0 ? "+" : "") + top,
  7535. of: that.window
  7536. };
  7537. $( this ).removeClass( "ui-dialog-resizing" );
  7538. that._unblockFrames();
  7539. that._trigger( "resizeStop", event, filteredUi( ui ) );
  7540. }
  7541. })
  7542. .css( "position", position );
  7543. },
  7544. _trackFocus: function() {
  7545. this._on( this.widget(), {
  7546. focusin: function( event ) {
  7547. this._makeFocusTarget();
  7548. this._focusedElement = $( event.target );
  7549. }
  7550. });
  7551. },
  7552. _makeFocusTarget: function() {
  7553. this._untrackInstance();
  7554. this._trackingInstances().unshift( this );
  7555. },
  7556. _untrackInstance: function() {
  7557. var instances = this._trackingInstances(),
  7558. exists = $.inArray( this, instances );
  7559. if ( exists !== -1 ) {
  7560. instances.splice( exists, 1 );
  7561. }
  7562. },
  7563. _trackingInstances: function() {
  7564. var instances = this.document.data( "ui-dialog-instances" );
  7565. if ( !instances ) {
  7566. instances = [];
  7567. this.document.data( "ui-dialog-instances", instances );
  7568. }
  7569. return instances;
  7570. },
  7571. _minHeight: function() {
  7572. var options = this.options;
  7573. return options.height === "auto" ?
  7574. options.minHeight :
  7575. Math.min( options.minHeight, options.height );
  7576. },
  7577. _position: function() {
  7578. // Need to show the dialog to get the actual offset in the position plugin
  7579. var isVisible = this.uiDialog.is( ":visible" );
  7580. if ( !isVisible ) {
  7581. this.uiDialog.show();
  7582. }
  7583. this.uiDialog.position( this.options.position );
  7584. if ( !isVisible ) {
  7585. this.uiDialog.hide();
  7586. }
  7587. },
  7588. _setOptions: function( options ) {
  7589. var that = this,
  7590. resize = false,
  7591. resizableOptions = {};
  7592. $.each( options, function( key, value ) {
  7593. that._setOption( key, value );
  7594. if ( key in that.sizeRelatedOptions ) {
  7595. resize = true;
  7596. }
  7597. if ( key in that.resizableRelatedOptions ) {
  7598. resizableOptions[ key ] = value;
  7599. }
  7600. });
  7601. if ( resize ) {
  7602. this._size();
  7603. this._position();
  7604. }
  7605. if ( this.uiDialog.is( ":data(ui-resizable)" ) ) {
  7606. this.uiDialog.resizable( "option", resizableOptions );
  7607. }
  7608. },
  7609. _setOption: function( key, value ) {
  7610. var isDraggable, isResizable,
  7611. uiDialog = this.uiDialog;
  7612. if ( key === "dialogClass" ) {
  7613. uiDialog
  7614. .removeClass( this.options.dialogClass )
  7615. .addClass( value );
  7616. }
  7617. if ( key === "disabled" ) {
  7618. return;
  7619. }
  7620. this._super( key, value );
  7621. if ( key === "appendTo" ) {
  7622. this.uiDialog.appendTo( this._appendTo() );
  7623. }
  7624. if ( key === "buttons" ) {
  7625. this._createButtons();
  7626. }
  7627. if ( key === "closeText" ) {
  7628. this.uiDialogTitlebarClose.button({
  7629. // Ensure that we always pass a string
  7630. label: "" + value
  7631. });
  7632. }
  7633. if ( key === "draggable" ) {
  7634. isDraggable = uiDialog.is( ":data(ui-draggable)" );
  7635. if ( isDraggable && !value ) {
  7636. uiDialog.draggable( "destroy" );
  7637. }
  7638. if ( !isDraggable && value ) {
  7639. this._makeDraggable();
  7640. }
  7641. }
  7642. if ( key === "position" ) {
  7643. this._position();
  7644. }
  7645. if ( key === "resizable" ) {
  7646. // currently resizable, becoming non-resizable
  7647. isResizable = uiDialog.is( ":data(ui-resizable)" );
  7648. if ( isResizable && !value ) {
  7649. uiDialog.resizable( "destroy" );
  7650. }
  7651. // currently resizable, changing handles
  7652. if ( isResizable && typeof value === "string" ) {
  7653. uiDialog.resizable( "option", "handles", value );
  7654. }
  7655. // currently non-resizable, becoming resizable
  7656. if ( !isResizable && value !== false ) {
  7657. this._makeResizable();
  7658. }
  7659. }
  7660. if ( key === "title" ) {
  7661. this._title( this.uiDialogTitlebar.find( ".ui-dialog-title" ) );
  7662. }
  7663. },
  7664. _size: function() {
  7665. // If the user has resized the dialog, the .ui-dialog and .ui-dialog-content
  7666. // divs will both have width and height set, so we need to reset them
  7667. var nonContentHeight, minContentHeight, maxContentHeight,
  7668. options = this.options;
  7669. // Reset content sizing
  7670. this.element.show().css({
  7671. width: "auto",
  7672. minHeight: 0,
  7673. maxHeight: "none",
  7674. height: 0
  7675. });
  7676. if ( options.minWidth > options.width ) {
  7677. options.width = options.minWidth;
  7678. }
  7679. // reset wrapper sizing
  7680. // determine the height of all the non-content elements
  7681. nonContentHeight = this.uiDialog.css({
  7682. height: "auto",
  7683. width: options.width
  7684. })
  7685. .outerHeight();
  7686. minContentHeight = Math.max( 0, options.minHeight - nonContentHeight );
  7687. maxContentHeight = typeof options.maxHeight === "number" ?
  7688. Math.max( 0, options.maxHeight - nonContentHeight ) :
  7689. "none";
  7690. if ( options.height === "auto" ) {
  7691. this.element.css({
  7692. minHeight: minContentHeight,
  7693. maxHeight: maxContentHeight,
  7694. height: "auto"
  7695. });
  7696. } else {
  7697. this.element.height( Math.max( 0, options.height - nonContentHeight ) );
  7698. }
  7699. if ( this.uiDialog.is( ":data(ui-resizable)" ) ) {
  7700. this.uiDialog.resizable( "option", "minHeight", this._minHeight() );
  7701. }
  7702. },
  7703. _blockFrames: function() {
  7704. this.iframeBlocks = this.document.find( "iframe" ).map(function() {
  7705. var iframe = $( this );
  7706. return $( "<div>" )
  7707. .css({
  7708. position: "absolute",
  7709. width: iframe.outerWidth(),
  7710. height: iframe.outerHeight()
  7711. })
  7712. .appendTo( iframe.parent() )
  7713. .offset( iframe.offset() )[0];
  7714. });
  7715. },
  7716. _unblockFrames: function() {
  7717. if ( this.iframeBlocks ) {
  7718. this.iframeBlocks.remove();
  7719. delete this.iframeBlocks;
  7720. }
  7721. },
  7722. _allowInteraction: function( event ) {
  7723. if ( $( event.target ).closest( ".ui-dialog" ).length ) {
  7724. return true;
  7725. }
  7726. // TODO: Remove hack when datepicker implements
  7727. // the .ui-front logic (#8989)
  7728. return !!$( event.target ).closest( ".ui-datepicker" ).length;
  7729. },
  7730. _createOverlay: function() {
  7731. if ( !this.options.modal ) {
  7732. return;
  7733. }
  7734. // We use a delay in case the overlay is created from an
  7735. // event that we're going to be cancelling (#2804)
  7736. var isOpening = true;
  7737. this._delay(function() {
  7738. isOpening = false;
  7739. });
  7740. if ( !this.document.data( "ui-dialog-overlays" ) ) {
  7741. // Prevent use of anchors and inputs
  7742. // Using _on() for an event handler shared across many instances is
  7743. // safe because the dialogs stack and must be closed in reverse order
  7744. this._on( this.document, {
  7745. focusin: function( event ) {
  7746. if ( isOpening ) {
  7747. return;
  7748. }
  7749. if ( !this._allowInteraction( event ) ) {
  7750. event.preventDefault();
  7751. this._trackingInstances()[ 0 ]._focusTabbable();
  7752. }
  7753. }
  7754. });
  7755. }
  7756. this.overlay = $( "<div>" )
  7757. .addClass( "ui-widget-overlay ui-front" )
  7758. .appendTo( this._appendTo() );
  7759. this._on( this.overlay, {
  7760. mousedown: "_keepFocus"
  7761. });
  7762. this.document.data( "ui-dialog-overlays",
  7763. (this.document.data( "ui-dialog-overlays" ) || 0) + 1 );
  7764. },
  7765. _destroyOverlay: function() {
  7766. if ( !this.options.modal ) {
  7767. return;
  7768. }
  7769. if ( this.overlay ) {
  7770. var overlays = this.document.data( "ui-dialog-overlays" ) - 1;
  7771. if ( !overlays ) {
  7772. this.document
  7773. .unbind( "focusin" )
  7774. .removeData( "ui-dialog-overlays" );
  7775. } else {
  7776. this.document.data( "ui-dialog-overlays", overlays );
  7777. }
  7778. this.overlay.remove();
  7779. this.overlay = null;
  7780. }
  7781. }
  7782. });
  7783. /*!
  7784. * jQuery UI Droppable 1.11.2
  7785. * http://jqueryui.com
  7786. *
  7787. * Copyright 2014 jQuery Foundation and other contributors
  7788. * Released under the MIT license.
  7789. * http://jquery.org/license
  7790. *
  7791. * http://api.jqueryui.com/droppable/
  7792. */
  7793. $.widget( "ui.droppable", {
  7794. version: "1.11.2",
  7795. widgetEventPrefix: "drop",
  7796. options: {
  7797. accept: "*",
  7798. activeClass: false,
  7799. addClasses: true,
  7800. greedy: false,
  7801. hoverClass: false,
  7802. scope: "default",
  7803. tolerance: "intersect",
  7804. // callbacks
  7805. activate: null,
  7806. deactivate: null,
  7807. drop: null,
  7808. out: null,
  7809. over: null
  7810. },
  7811. _create: function() {
  7812. var proportions,
  7813. o = this.options,
  7814. accept = o.accept;
  7815. this.isover = false;
  7816. this.isout = true;
  7817. this.accept = $.isFunction( accept ) ? accept : function( d ) {
  7818. return d.is( accept );
  7819. };
  7820. this.proportions = function( /* valueToWrite */ ) {
  7821. if ( arguments.length ) {
  7822. // Store the droppable's proportions
  7823. proportions = arguments[ 0 ];
  7824. } else {
  7825. // Retrieve or derive the droppable's proportions
  7826. return proportions ?
  7827. proportions :
  7828. proportions = {
  7829. width: this.element[ 0 ].offsetWidth,
  7830. height: this.element[ 0 ].offsetHeight
  7831. };
  7832. }
  7833. };
  7834. this._addToManager( o.scope );
  7835. o.addClasses && this.element.addClass( "ui-droppable" );
  7836. },
  7837. _addToManager: function( scope ) {
  7838. // Add the reference and positions to the manager
  7839. $.ui.ddmanager.droppables[ scope ] = $.ui.ddmanager.droppables[ scope ] || [];
  7840. $.ui.ddmanager.droppables[ scope ].push( this );
  7841. },
  7842. _splice: function( drop ) {
  7843. var i = 0;
  7844. for ( ; i < drop.length; i++ ) {
  7845. if ( drop[ i ] === this ) {
  7846. drop.splice( i, 1 );
  7847. }
  7848. }
  7849. },
  7850. _destroy: function() {
  7851. var drop = $.ui.ddmanager.droppables[ this.options.scope ];
  7852. this._splice( drop );
  7853. this.element.removeClass( "ui-droppable ui-droppable-disabled" );
  7854. },
  7855. _setOption: function( key, value ) {
  7856. if ( key === "accept" ) {
  7857. this.accept = $.isFunction( value ) ? value : function( d ) {
  7858. return d.is( value );
  7859. };
  7860. } else if ( key === "scope" ) {
  7861. var drop = $.ui.ddmanager.droppables[ this.options.scope ];
  7862. this._splice( drop );
  7863. this._addToManager( value );
  7864. }
  7865. this._super( key, value );
  7866. },
  7867. _activate: function( event ) {
  7868. var draggable = $.ui.ddmanager.current;
  7869. if ( this.options.activeClass ) {
  7870. this.element.addClass( this.options.activeClass );
  7871. }
  7872. if ( draggable ){
  7873. this._trigger( "activate", event, this.ui( draggable ) );
  7874. }
  7875. },
  7876. _deactivate: function( event ) {
  7877. var draggable = $.ui.ddmanager.current;
  7878. if ( this.options.activeClass ) {
  7879. this.element.removeClass( this.options.activeClass );
  7880. }
  7881. if ( draggable ){
  7882. this._trigger( "deactivate", event, this.ui( draggable ) );
  7883. }
  7884. },
  7885. _over: function( event ) {
  7886. var draggable = $.ui.ddmanager.current;
  7887. // Bail if draggable and droppable are same element
  7888. if ( !draggable || ( draggable.currentItem || draggable.element )[ 0 ] === this.element[ 0 ] ) {
  7889. return;
  7890. }
  7891. if ( this.accept.call( this.element[ 0 ], ( draggable.currentItem || draggable.element ) ) ) {
  7892. if ( this.options.hoverClass ) {
  7893. this.element.addClass( this.options.hoverClass );
  7894. }
  7895. this._trigger( "over", event, this.ui( draggable ) );
  7896. }
  7897. },
  7898. _out: function( event ) {
  7899. var draggable = $.ui.ddmanager.current;
  7900. // Bail if draggable and droppable are same element
  7901. if ( !draggable || ( draggable.currentItem || draggable.element )[ 0 ] === this.element[ 0 ] ) {
  7902. return;
  7903. }
  7904. if ( this.accept.call( this.element[ 0 ], ( draggable.currentItem || draggable.element ) ) ) {
  7905. if ( this.options.hoverClass ) {
  7906. this.element.removeClass( this.options.hoverClass );
  7907. }
  7908. this._trigger( "out", event, this.ui( draggable ) );
  7909. }
  7910. },
  7911. _drop: function( event, custom ) {
  7912. var draggable = custom || $.ui.ddmanager.current,
  7913. childrenIntersection = false;
  7914. // Bail if draggable and droppable are same element
  7915. if ( !draggable || ( draggable.currentItem || draggable.element )[ 0 ] === this.element[ 0 ] ) {
  7916. return false;
  7917. }
  7918. this.element.find( ":data(ui-droppable)" ).not( ".ui-draggable-dragging" ).each(function() {
  7919. var inst = $( this ).droppable( "instance" );
  7920. if (
  7921. inst.options.greedy &&
  7922. !inst.options.disabled &&
  7923. inst.options.scope === draggable.options.scope &&
  7924. inst.accept.call( inst.element[ 0 ], ( draggable.currentItem || draggable.element ) ) &&
  7925. $.ui.intersect( draggable, $.extend( inst, { offset: inst.element.offset() } ), inst.options.tolerance, event )
  7926. ) { childrenIntersection = true; return false; }
  7927. });
  7928. if ( childrenIntersection ) {
  7929. return false;
  7930. }
  7931. if ( this.accept.call( this.element[ 0 ], ( draggable.currentItem || draggable.element ) ) ) {
  7932. if ( this.options.activeClass ) {
  7933. this.element.removeClass( this.options.activeClass );
  7934. }
  7935. if ( this.options.hoverClass ) {
  7936. this.element.removeClass( this.options.hoverClass );
  7937. }
  7938. this._trigger( "drop", event, this.ui( draggable ) );
  7939. return this.element;
  7940. }
  7941. return false;
  7942. },
  7943. ui: function( c ) {
  7944. return {
  7945. draggable: ( c.currentItem || c.element ),
  7946. helper: c.helper,
  7947. position: c.position,
  7948. offset: c.positionAbs
  7949. };
  7950. }
  7951. });
  7952. $.ui.intersect = (function() {
  7953. function isOverAxis( x, reference, size ) {
  7954. return ( x >= reference ) && ( x < ( reference + size ) );
  7955. }
  7956. return function( draggable, droppable, toleranceMode, event ) {
  7957. if ( !droppable.offset ) {
  7958. return false;
  7959. }
  7960. var x1 = ( draggable.positionAbs || draggable.position.absolute ).left + draggable.margins.left,
  7961. y1 = ( draggable.positionAbs || draggable.position.absolute ).top + draggable.margins.top,
  7962. x2 = x1 + draggable.helperProportions.width,
  7963. y2 = y1 + draggable.helperProportions.height,
  7964. l = droppable.offset.left,
  7965. t = droppable.offset.top,
  7966. r = l + droppable.proportions().width,
  7967. b = t + droppable.proportions().height;
  7968. switch ( toleranceMode ) {
  7969. case "fit":
  7970. return ( l <= x1 && x2 <= r && t <= y1 && y2 <= b );
  7971. case "intersect":
  7972. return ( l < x1 + ( draggable.helperProportions.width / 2 ) && // Right Half
  7973. x2 - ( draggable.helperProportions.width / 2 ) < r && // Left Half
  7974. t < y1 + ( draggable.helperProportions.height / 2 ) && // Bottom Half
  7975. y2 - ( draggable.helperProportions.height / 2 ) < b ); // Top Half
  7976. case "pointer":
  7977. return isOverAxis( event.pageY, t, droppable.proportions().height ) && isOverAxis( event.pageX, l, droppable.proportions().width );
  7978. case "touch":
  7979. return (
  7980. ( y1 >= t && y1 <= b ) || // Top edge touching
  7981. ( y2 >= t && y2 <= b ) || // Bottom edge touching
  7982. ( y1 < t && y2 > b ) // Surrounded vertically
  7983. ) && (
  7984. ( x1 >= l && x1 <= r ) || // Left edge touching
  7985. ( x2 >= l && x2 <= r ) || // Right edge touching
  7986. ( x1 < l && x2 > r ) // Surrounded horizontally
  7987. );
  7988. default:
  7989. return false;
  7990. }
  7991. };
  7992. })();
  7993. /*
  7994. This manager tracks offsets of draggables and droppables
  7995. */
  7996. $.ui.ddmanager = {
  7997. current: null,
  7998. droppables: { "default": [] },
  7999. prepareOffsets: function( t, event ) {
  8000. var i, j,
  8001. m = $.ui.ddmanager.droppables[ t.options.scope ] || [],
  8002. type = event ? event.type : null, // workaround for #2317
  8003. list = ( t.currentItem || t.element ).find( ":data(ui-droppable)" ).addBack();
  8004. droppablesLoop: for ( i = 0; i < m.length; i++ ) {
  8005. // No disabled and non-accepted
  8006. if ( m[ i ].options.disabled || ( t && !m[ i ].accept.call( m[ i ].element[ 0 ], ( t.currentItem || t.element ) ) ) ) {
  8007. continue;
  8008. }
  8009. // Filter out elements in the current dragged item
  8010. for ( j = 0; j < list.length; j++ ) {
  8011. if ( list[ j ] === m[ i ].element[ 0 ] ) {
  8012. m[ i ].proportions().height = 0;
  8013. continue droppablesLoop;
  8014. }
  8015. }
  8016. m[ i ].visible = m[ i ].element.css( "display" ) !== "none";
  8017. if ( !m[ i ].visible ) {
  8018. continue;
  8019. }
  8020. // Activate the droppable if used directly from draggables
  8021. if ( type === "mousedown" ) {
  8022. m[ i ]._activate.call( m[ i ], event );
  8023. }
  8024. m[ i ].offset = m[ i ].element.offset();
  8025. m[ i ].proportions({ width: m[ i ].element[ 0 ].offsetWidth, height: m[ i ].element[ 0 ].offsetHeight });
  8026. }
  8027. },
  8028. drop: function( draggable, event ) {
  8029. var dropped = false;
  8030. // Create a copy of the droppables in case the list changes during the drop (#9116)
  8031. $.each( ( $.ui.ddmanager.droppables[ draggable.options.scope ] || [] ).slice(), function() {
  8032. if ( !this.options ) {
  8033. return;
  8034. }
  8035. if ( !this.options.disabled && this.visible && $.ui.intersect( draggable, this, this.options.tolerance, event ) ) {
  8036. dropped = this._drop.call( this, event ) || dropped;
  8037. }
  8038. if ( !this.options.disabled && this.visible && this.accept.call( this.element[ 0 ], ( draggable.currentItem || draggable.element ) ) ) {
  8039. this.isout = true;
  8040. this.isover = false;
  8041. this._deactivate.call( this, event );
  8042. }
  8043. });
  8044. return dropped;
  8045. },
  8046. dragStart: function( draggable, event ) {
  8047. // Listen for scrolling so that if the dragging causes scrolling the position of the droppables can be recalculated (see #5003)
  8048. draggable.element.parentsUntil( "body" ).bind( "scroll.droppable", function() {
  8049. if ( !draggable.options.refreshPositions ) {
  8050. $.ui.ddmanager.prepareOffsets( draggable, event );
  8051. }
  8052. });
  8053. },
  8054. drag: function( draggable, event ) {
  8055. // If you have a highly dynamic page, you might try this option. It renders positions every time you move the mouse.
  8056. if ( draggable.options.refreshPositions ) {
  8057. $.ui.ddmanager.prepareOffsets( draggable, event );
  8058. }
  8059. // Run through all droppables and check their positions based on specific tolerance options
  8060. $.each( $.ui.ddmanager.droppables[ draggable.options.scope ] || [], function() {
  8061. if ( this.options.disabled || this.greedyChild || !this.visible ) {
  8062. return;
  8063. }
  8064. var parentInstance, scope, parent,
  8065. intersects = $.ui.intersect( draggable, this, this.options.tolerance, event ),
  8066. c = !intersects && this.isover ? "isout" : ( intersects && !this.isover ? "isover" : null );
  8067. if ( !c ) {
  8068. return;
  8069. }
  8070. if ( this.options.greedy ) {
  8071. // find droppable parents with same scope
  8072. scope = this.options.scope;
  8073. parent = this.element.parents( ":data(ui-droppable)" ).filter(function() {
  8074. return $( this ).droppable( "instance" ).options.scope === scope;
  8075. });
  8076. if ( parent.length ) {
  8077. parentInstance = $( parent[ 0 ] ).droppable( "instance" );
  8078. parentInstance.greedyChild = ( c === "isover" );
  8079. }
  8080. }
  8081. // we just moved into a greedy child
  8082. if ( parentInstance && c === "isover" ) {
  8083. parentInstance.isover = false;
  8084. parentInstance.isout = true;
  8085. parentInstance._out.call( parentInstance, event );
  8086. }
  8087. this[ c ] = true;
  8088. this[c === "isout" ? "isover" : "isout"] = false;
  8089. this[c === "isover" ? "_over" : "_out"].call( this, event );
  8090. // we just moved out of a greedy child
  8091. if ( parentInstance && c === "isout" ) {
  8092. parentInstance.isout = false;
  8093. parentInstance.isover = true;
  8094. parentInstance._over.call( parentInstance, event );
  8095. }
  8096. });
  8097. },
  8098. dragStop: function( draggable, event ) {
  8099. draggable.element.parentsUntil( "body" ).unbind( "scroll.droppable" );
  8100. // Call prepareOffsets one final time since IE does not fire return scroll events when overflow was caused by drag (see #5003)
  8101. if ( !draggable.options.refreshPositions ) {
  8102. $.ui.ddmanager.prepareOffsets( draggable, event );
  8103. }
  8104. }
  8105. };
  8106. var droppable = $.ui.droppable;
  8107. /*!
  8108. * jQuery UI Effects 1.11.2
  8109. * http://jqueryui.com
  8110. *
  8111. * Copyright 2014 jQuery Foundation and other contributors
  8112. * Released under the MIT license.
  8113. * http://jquery.org/license
  8114. *
  8115. * http://api.jqueryui.com/category/effects-core/
  8116. */
  8117. var dataSpace = "ui-effects-",
  8118. // Create a local jQuery because jQuery Color relies on it and the
  8119. // global may not exist with AMD and a custom build (#10199)
  8120. jQuery = $;
  8121. $.effects = {
  8122. effect: {}
  8123. };
  8124. /*!
  8125. * jQuery Color Animations v2.1.2
  8126. * https://github.com/jquery/jquery-color
  8127. *
  8128. * Copyright 2014 jQuery Foundation and other contributors
  8129. * Released under the MIT license.
  8130. * http://jquery.org/license
  8131. *
  8132. * Date: Wed Jan 16 08:47:09 2013 -0600
  8133. */
  8134. (function( jQuery, undefined ) {
  8135. var stepHooks = "backgroundColor borderBottomColor borderLeftColor borderRightColor borderTopColor color columnRuleColor outlineColor textDecorationColor textEmphasisColor",
  8136. // plusequals test for += 100 -= 100
  8137. rplusequals = /^([\-+])=\s*(\d+\.?\d*)/,
  8138. // a set of RE's that can match strings and generate color tuples.
  8139. stringParsers = [ {
  8140. re: /rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(?:,\s*(\d?(?:\.\d+)?)\s*)?\)/,
  8141. parse: function( execResult ) {
  8142. return [
  8143. execResult[ 1 ],
  8144. execResult[ 2 ],
  8145. execResult[ 3 ],
  8146. execResult[ 4 ]
  8147. ];
  8148. }
  8149. }, {
  8150. re: /rgba?\(\s*(\d+(?:\.\d+)?)\%\s*,\s*(\d+(?:\.\d+)?)\%\s*,\s*(\d+(?:\.\d+)?)\%\s*(?:,\s*(\d?(?:\.\d+)?)\s*)?\)/,
  8151. parse: function( execResult ) {
  8152. return [
  8153. execResult[ 1 ] * 2.55,
  8154. execResult[ 2 ] * 2.55,
  8155. execResult[ 3 ] * 2.55,
  8156. execResult[ 4 ]
  8157. ];
  8158. }
  8159. }, {
  8160. // this regex ignores A-F because it's compared against an already lowercased string
  8161. re: /#([a-f0-9]{2})([a-f0-9]{2})([a-f0-9]{2})/,
  8162. parse: function( execResult ) {
  8163. return [
  8164. parseInt( execResult[ 1 ], 16 ),
  8165. parseInt( execResult[ 2 ], 16 ),
  8166. parseInt( execResult[ 3 ], 16 )
  8167. ];
  8168. }
  8169. }, {
  8170. // this regex ignores A-F because it's compared against an already lowercased string
  8171. re: /#([a-f0-9])([a-f0-9])([a-f0-9])/,
  8172. parse: function( execResult ) {
  8173. return [
  8174. parseInt( execResult[ 1 ] + execResult[ 1 ], 16 ),
  8175. parseInt( execResult[ 2 ] + execResult[ 2 ], 16 ),
  8176. parseInt( execResult[ 3 ] + execResult[ 3 ], 16 )
  8177. ];
  8178. }
  8179. }, {
  8180. re: /hsla?\(\s*(\d+(?:\.\d+)?)\s*,\s*(\d+(?:\.\d+)?)\%\s*,\s*(\d+(?:\.\d+)?)\%\s*(?:,\s*(\d?(?:\.\d+)?)\s*)?\)/,
  8181. space: "hsla",
  8182. parse: function( execResult ) {
  8183. return [
  8184. execResult[ 1 ],
  8185. execResult[ 2 ] / 100,
  8186. execResult[ 3 ] / 100,
  8187. execResult[ 4 ]
  8188. ];
  8189. }
  8190. } ],
  8191. // jQuery.Color( )
  8192. color = jQuery.Color = function( color, green, blue, alpha ) {
  8193. return new jQuery.Color.fn.parse( color, green, blue, alpha );
  8194. },
  8195. spaces = {
  8196. rgba: {
  8197. props: {
  8198. red: {
  8199. idx: 0,
  8200. type: "byte"
  8201. },
  8202. green: {
  8203. idx: 1,
  8204. type: "byte"
  8205. },
  8206. blue: {
  8207. idx: 2,
  8208. type: "byte"
  8209. }
  8210. }
  8211. },
  8212. hsla: {
  8213. props: {
  8214. hue: {
  8215. idx: 0,
  8216. type: "degrees"
  8217. },
  8218. saturation: {
  8219. idx: 1,
  8220. type: "percent"
  8221. },
  8222. lightness: {
  8223. idx: 2,
  8224. type: "percent"
  8225. }
  8226. }
  8227. }
  8228. },
  8229. propTypes = {
  8230. "byte": {
  8231. floor: true,
  8232. max: 255
  8233. },
  8234. "percent": {
  8235. max: 1
  8236. },
  8237. "degrees": {
  8238. mod: 360,
  8239. floor: true
  8240. }
  8241. },
  8242. support = color.support = {},
  8243. // element for support tests
  8244. supportElem = jQuery( "<p>" )[ 0 ],
  8245. // colors = jQuery.Color.names
  8246. colors,
  8247. // local aliases of functions called often
  8248. each = jQuery.each;
  8249. // determine rgba support immediately
  8250. supportElem.style.cssText = "background-color:rgba(1,1,1,.5)";
  8251. support.rgba = supportElem.style.backgroundColor.indexOf( "rgba" ) > -1;
  8252. // define cache name and alpha properties
  8253. // for rgba and hsla spaces
  8254. each( spaces, function( spaceName, space ) {
  8255. space.cache = "_" + spaceName;
  8256. space.props.alpha = {
  8257. idx: 3,
  8258. type: "percent",
  8259. def: 1
  8260. };
  8261. });
  8262. function clamp( value, prop, allowEmpty ) {
  8263. var type = propTypes[ prop.type ] || {};
  8264. if ( value == null ) {
  8265. return (allowEmpty || !prop.def) ? null : prop.def;
  8266. }
  8267. // ~~ is an short way of doing floor for positive numbers
  8268. value = type.floor ? ~~value : parseFloat( value );
  8269. // IE will pass in empty strings as value for alpha,
  8270. // which will hit this case
  8271. if ( isNaN( value ) ) {
  8272. return prop.def;
  8273. }
  8274. if ( type.mod ) {
  8275. // we add mod before modding to make sure that negatives values
  8276. // get converted properly: -10 -> 350
  8277. return (value + type.mod) % type.mod;
  8278. }
  8279. // for now all property types without mod have min and max
  8280. return 0 > value ? 0 : type.max < value ? type.max : value;
  8281. }
  8282. function stringParse( string ) {
  8283. var inst = color(),
  8284. rgba = inst._rgba = [];
  8285. string = string.toLowerCase();
  8286. each( stringParsers, function( i, parser ) {
  8287. var parsed,
  8288. match = parser.re.exec( string ),
  8289. values = match && parser.parse( match ),
  8290. spaceName = parser.space || "rgba";
  8291. if ( values ) {
  8292. parsed = inst[ spaceName ]( values );
  8293. // if this was an rgba parse the assignment might happen twice
  8294. // oh well....
  8295. inst[ spaces[ spaceName ].cache ] = parsed[ spaces[ spaceName ].cache ];
  8296. rgba = inst._rgba = parsed._rgba;
  8297. // exit each( stringParsers ) here because we matched
  8298. return false;
  8299. }
  8300. });
  8301. // Found a stringParser that handled it
  8302. if ( rgba.length ) {
  8303. // if this came from a parsed string, force "transparent" when alpha is 0
  8304. // chrome, (and maybe others) return "transparent" as rgba(0,0,0,0)
  8305. if ( rgba.join() === "0,0,0,0" ) {
  8306. jQuery.extend( rgba, colors.transparent );
  8307. }
  8308. return inst;
  8309. }
  8310. // named colors
  8311. return colors[ string ];
  8312. }
  8313. color.fn = jQuery.extend( color.prototype, {
  8314. parse: function( red, green, blue, alpha ) {
  8315. if ( red === undefined ) {
  8316. this._rgba = [ null, null, null, null ];
  8317. return this;
  8318. }
  8319. if ( red.jquery || red.nodeType ) {
  8320. red = jQuery( red ).css( green );
  8321. green = undefined;
  8322. }
  8323. var inst = this,
  8324. type = jQuery.type( red ),
  8325. rgba = this._rgba = [];
  8326. // more than 1 argument specified - assume ( red, green, blue, alpha )
  8327. if ( green !== undefined ) {
  8328. red = [ red, green, blue, alpha ];
  8329. type = "array";
  8330. }
  8331. if ( type === "string" ) {
  8332. return this.parse( stringParse( red ) || colors._default );
  8333. }
  8334. if ( type === "array" ) {
  8335. each( spaces.rgba.props, function( key, prop ) {
  8336. rgba[ prop.idx ] = clamp( red[ prop.idx ], prop );
  8337. });
  8338. return this;
  8339. }
  8340. if ( type === "object" ) {
  8341. if ( red instanceof color ) {
  8342. each( spaces, function( spaceName, space ) {
  8343. if ( red[ space.cache ] ) {
  8344. inst[ space.cache ] = red[ space.cache ].slice();
  8345. }
  8346. });
  8347. } else {
  8348. each( spaces, function( spaceName, space ) {
  8349. var cache = space.cache;
  8350. each( space.props, function( key, prop ) {
  8351. // if the cache doesn't exist, and we know how to convert
  8352. if ( !inst[ cache ] && space.to ) {
  8353. // if the value was null, we don't need to copy it
  8354. // if the key was alpha, we don't need to copy it either
  8355. if ( key === "alpha" || red[ key ] == null ) {
  8356. return;
  8357. }
  8358. inst[ cache ] = space.to( inst._rgba );
  8359. }
  8360. // this is the only case where we allow nulls for ALL properties.
  8361. // call clamp with alwaysAllowEmpty
  8362. inst[ cache ][ prop.idx ] = clamp( red[ key ], prop, true );
  8363. });
  8364. // everything defined but alpha?
  8365. if ( inst[ cache ] && jQuery.inArray( null, inst[ cache ].slice( 0, 3 ) ) < 0 ) {
  8366. // use the default of 1
  8367. inst[ cache ][ 3 ] = 1;
  8368. if ( space.from ) {
  8369. inst._rgba = space.from( inst[ cache ] );
  8370. }
  8371. }
  8372. });
  8373. }
  8374. return this;
  8375. }
  8376. },
  8377. is: function( compare ) {
  8378. var is = color( compare ),
  8379. same = true,
  8380. inst = this;
  8381. each( spaces, function( _, space ) {
  8382. var localCache,
  8383. isCache = is[ space.cache ];
  8384. if (isCache) {
  8385. localCache = inst[ space.cache ] || space.to && space.to( inst._rgba ) || [];
  8386. each( space.props, function( _, prop ) {
  8387. if ( isCache[ prop.idx ] != null ) {
  8388. same = ( isCache[ prop.idx ] === localCache[ prop.idx ] );
  8389. return same;
  8390. }
  8391. });
  8392. }
  8393. return same;
  8394. });
  8395. return same;
  8396. },
  8397. _space: function() {
  8398. var used = [],
  8399. inst = this;
  8400. each( spaces, function( spaceName, space ) {
  8401. if ( inst[ space.cache ] ) {
  8402. used.push( spaceName );
  8403. }
  8404. });
  8405. return used.pop();
  8406. },
  8407. transition: function( other, distance ) {
  8408. var end = color( other ),
  8409. spaceName = end._space(),
  8410. space = spaces[ spaceName ],
  8411. startColor = this.alpha() === 0 ? color( "transparent" ) : this,
  8412. start = startColor[ space.cache ] || space.to( startColor._rgba ),
  8413. result = start.slice();
  8414. end = end[ space.cache ];
  8415. each( space.props, function( key, prop ) {
  8416. var index = prop.idx,
  8417. startValue = start[ index ],
  8418. endValue = end[ index ],
  8419. type = propTypes[ prop.type ] || {};
  8420. // if null, don't override start value
  8421. if ( endValue === null ) {
  8422. return;
  8423. }
  8424. // if null - use end
  8425. if ( startValue === null ) {
  8426. result[ index ] = endValue;
  8427. } else {
  8428. if ( type.mod ) {
  8429. if ( endValue - startValue > type.mod / 2 ) {
  8430. startValue += type.mod;
  8431. } else if ( startValue - endValue > type.mod / 2 ) {
  8432. startValue -= type.mod;
  8433. }
  8434. }
  8435. result[ index ] = clamp( ( endValue - startValue ) * distance + startValue, prop );
  8436. }
  8437. });
  8438. return this[ spaceName ]( result );
  8439. },
  8440. blend: function( opaque ) {
  8441. // if we are already opaque - return ourself
  8442. if ( this._rgba[ 3 ] === 1 ) {
  8443. return this;
  8444. }
  8445. var rgb = this._rgba.slice(),
  8446. a = rgb.pop(),
  8447. blend = color( opaque )._rgba;
  8448. return color( jQuery.map( rgb, function( v, i ) {
  8449. return ( 1 - a ) * blend[ i ] + a * v;
  8450. }));
  8451. },
  8452. toRgbaString: function() {
  8453. var prefix = "rgba(",
  8454. rgba = jQuery.map( this._rgba, function( v, i ) {
  8455. return v == null ? ( i > 2 ? 1 : 0 ) : v;
  8456. });
  8457. if ( rgba[ 3 ] === 1 ) {
  8458. rgba.pop();
  8459. prefix = "rgb(";
  8460. }
  8461. return prefix + rgba.join() + ")";
  8462. },
  8463. toHslaString: function() {
  8464. var prefix = "hsla(",
  8465. hsla = jQuery.map( this.hsla(), function( v, i ) {
  8466. if ( v == null ) {
  8467. v = i > 2 ? 1 : 0;
  8468. }
  8469. // catch 1 and 2
  8470. if ( i && i < 3 ) {
  8471. v = Math.round( v * 100 ) + "%";
  8472. }
  8473. return v;
  8474. });
  8475. if ( hsla[ 3 ] === 1 ) {
  8476. hsla.pop();
  8477. prefix = "hsl(";
  8478. }
  8479. return prefix + hsla.join() + ")";
  8480. },
  8481. toHexString: function( includeAlpha ) {
  8482. var rgba = this._rgba.slice(),
  8483. alpha = rgba.pop();
  8484. if ( includeAlpha ) {
  8485. rgba.push( ~~( alpha * 255 ) );
  8486. }
  8487. return "#" + jQuery.map( rgba, function( v ) {
  8488. // default to 0 when nulls exist
  8489. v = ( v || 0 ).toString( 16 );
  8490. return v.length === 1 ? "0" + v : v;
  8491. }).join("");
  8492. },
  8493. toString: function() {
  8494. return this._rgba[ 3 ] === 0 ? "transparent" : this.toRgbaString();
  8495. }
  8496. });
  8497. color.fn.parse.prototype = color.fn;
  8498. // hsla conversions adapted from:
  8499. // https://code.google.com/p/maashaack/source/browse/packages/graphics/trunk/src/graphics/colors/HUE2RGB.as?r=5021
  8500. function hue2rgb( p, q, h ) {
  8501. h = ( h + 1 ) % 1;
  8502. if ( h * 6 < 1 ) {
  8503. return p + ( q - p ) * h * 6;
  8504. }
  8505. if ( h * 2 < 1) {
  8506. return q;
  8507. }
  8508. if ( h * 3 < 2 ) {
  8509. return p + ( q - p ) * ( ( 2 / 3 ) - h ) * 6;
  8510. }
  8511. return p;
  8512. }
  8513. spaces.hsla.to = function( rgba ) {
  8514. if ( rgba[ 0 ] == null || rgba[ 1 ] == null || rgba[ 2 ] == null ) {
  8515. return [ null, null, null, rgba[ 3 ] ];
  8516. }
  8517. var r = rgba[ 0 ] / 255,
  8518. g = rgba[ 1 ] / 255,
  8519. b = rgba[ 2 ] / 255,
  8520. a = rgba[ 3 ],
  8521. max = Math.max( r, g, b ),
  8522. min = Math.min( r, g, b ),
  8523. diff = max - min,
  8524. add = max + min,
  8525. l = add * 0.5,
  8526. h, s;
  8527. if ( min === max ) {
  8528. h = 0;
  8529. } else if ( r === max ) {
  8530. h = ( 60 * ( g - b ) / diff ) + 360;
  8531. } else if ( g === max ) {
  8532. h = ( 60 * ( b - r ) / diff ) + 120;
  8533. } else {
  8534. h = ( 60 * ( r - g ) / diff ) + 240;
  8535. }
  8536. // chroma (diff) == 0 means greyscale which, by definition, saturation = 0%
  8537. // otherwise, saturation is based on the ratio of chroma (diff) to lightness (add)
  8538. if ( diff === 0 ) {
  8539. s = 0;
  8540. } else if ( l <= 0.5 ) {
  8541. s = diff / add;
  8542. } else {
  8543. s = diff / ( 2 - add );
  8544. }
  8545. return [ Math.round(h) % 360, s, l, a == null ? 1 : a ];
  8546. };
  8547. spaces.hsla.from = function( hsla ) {
  8548. if ( hsla[ 0 ] == null || hsla[ 1 ] == null || hsla[ 2 ] == null ) {
  8549. return [ null, null, null, hsla[ 3 ] ];
  8550. }
  8551. var h = hsla[ 0 ] / 360,
  8552. s = hsla[ 1 ],
  8553. l = hsla[ 2 ],
  8554. a = hsla[ 3 ],
  8555. q = l <= 0.5 ? l * ( 1 + s ) : l + s - l * s,
  8556. p = 2 * l - q;
  8557. return [
  8558. Math.round( hue2rgb( p, q, h + ( 1 / 3 ) ) * 255 ),
  8559. Math.round( hue2rgb( p, q, h ) * 255 ),
  8560. Math.round( hue2rgb( p, q, h - ( 1 / 3 ) ) * 255 ),
  8561. a
  8562. ];
  8563. };
  8564. each( spaces, function( spaceName, space ) {
  8565. var props = space.props,
  8566. cache = space.cache,
  8567. to = space.to,
  8568. from = space.from;
  8569. // makes rgba() and hsla()
  8570. color.fn[ spaceName ] = function( value ) {
  8571. // generate a cache for this space if it doesn't exist
  8572. if ( to && !this[ cache ] ) {
  8573. this[ cache ] = to( this._rgba );
  8574. }
  8575. if ( value === undefined ) {
  8576. return this[ cache ].slice();
  8577. }
  8578. var ret,
  8579. type = jQuery.type( value ),
  8580. arr = ( type === "array" || type === "object" ) ? value : arguments,
  8581. local = this[ cache ].slice();
  8582. each( props, function( key, prop ) {
  8583. var val = arr[ type === "object" ? key : prop.idx ];
  8584. if ( val == null ) {
  8585. val = local[ prop.idx ];
  8586. }
  8587. local[ prop.idx ] = clamp( val, prop );
  8588. });
  8589. if ( from ) {
  8590. ret = color( from( local ) );
  8591. ret[ cache ] = local;
  8592. return ret;
  8593. } else {
  8594. return color( local );
  8595. }
  8596. };
  8597. // makes red() green() blue() alpha() hue() saturation() lightness()
  8598. each( props, function( key, prop ) {
  8599. // alpha is included in more than one space
  8600. if ( color.fn[ key ] ) {
  8601. return;
  8602. }
  8603. color.fn[ key ] = function( value ) {
  8604. var vtype = jQuery.type( value ),
  8605. fn = ( key === "alpha" ? ( this._hsla ? "hsla" : "rgba" ) : spaceName ),
  8606. local = this[ fn ](),
  8607. cur = local[ prop.idx ],
  8608. match;
  8609. if ( vtype === "undefined" ) {
  8610. return cur;
  8611. }
  8612. if ( vtype === "function" ) {
  8613. value = value.call( this, cur );
  8614. vtype = jQuery.type( value );
  8615. }
  8616. if ( value == null && prop.empty ) {
  8617. return this;
  8618. }
  8619. if ( vtype === "string" ) {
  8620. match = rplusequals.exec( value );
  8621. if ( match ) {
  8622. value = cur + parseFloat( match[ 2 ] ) * ( match[ 1 ] === "+" ? 1 : -1 );
  8623. }
  8624. }
  8625. local[ prop.idx ] = value;
  8626. return this[ fn ]( local );
  8627. };
  8628. });
  8629. });
  8630. // add cssHook and .fx.step function for each named hook.
  8631. // accept a space separated string of properties
  8632. color.hook = function( hook ) {
  8633. var hooks = hook.split( " " );
  8634. each( hooks, function( i, hook ) {
  8635. jQuery.cssHooks[ hook ] = {
  8636. set: function( elem, value ) {
  8637. var parsed, curElem,
  8638. backgroundColor = "";
  8639. if ( value !== "transparent" && ( jQuery.type( value ) !== "string" || ( parsed = stringParse( value ) ) ) ) {
  8640. value = color( parsed || value );
  8641. if ( !support.rgba && value._rgba[ 3 ] !== 1 ) {
  8642. curElem = hook === "backgroundColor" ? elem.parentNode : elem;
  8643. while (
  8644. (backgroundColor === "" || backgroundColor === "transparent") &&
  8645. curElem && curElem.style
  8646. ) {
  8647. try {
  8648. backgroundColor = jQuery.css( curElem, "backgroundColor" );
  8649. curElem = curElem.parentNode;
  8650. } catch ( e ) {
  8651. }
  8652. }
  8653. value = value.blend( backgroundColor && backgroundColor !== "transparent" ?
  8654. backgroundColor :
  8655. "_default" );
  8656. }
  8657. value = value.toRgbaString();
  8658. }
  8659. try {
  8660. elem.style[ hook ] = value;
  8661. } catch ( e ) {
  8662. // wrapped to prevent IE from throwing errors on "invalid" values like 'auto' or 'inherit'
  8663. }
  8664. }
  8665. };
  8666. jQuery.fx.step[ hook ] = function( fx ) {
  8667. if ( !fx.colorInit ) {
  8668. fx.start = color( fx.elem, hook );
  8669. fx.end = color( fx.end );
  8670. fx.colorInit = true;
  8671. }
  8672. jQuery.cssHooks[ hook ].set( fx.elem, fx.start.transition( fx.end, fx.pos ) );
  8673. };
  8674. });
  8675. };
  8676. color.hook( stepHooks );
  8677. jQuery.cssHooks.borderColor = {
  8678. expand: function( value ) {
  8679. var expanded = {};
  8680. each( [ "Top", "Right", "Bottom", "Left" ], function( i, part ) {
  8681. expanded[ "border" + part + "Color" ] = value;
  8682. });
  8683. return expanded;
  8684. }
  8685. };
  8686. // Basic color names only.
  8687. // Usage of any of the other color names requires adding yourself or including
  8688. // jquery.color.svg-names.js.
  8689. colors = jQuery.Color.names = {
  8690. // 4.1. Basic color keywords
  8691. aqua: "#00ffff",
  8692. black: "#000000",
  8693. blue: "#0000ff",
  8694. fuchsia: "#ff00ff",
  8695. gray: "#808080",
  8696. green: "#008000",
  8697. lime: "#00ff00",
  8698. maroon: "#800000",
  8699. navy: "#000080",
  8700. olive: "#808000",
  8701. purple: "#800080",
  8702. red: "#ff0000",
  8703. silver: "#c0c0c0",
  8704. teal: "#008080",
  8705. white: "#ffffff",
  8706. yellow: "#ffff00",
  8707. // 4.2.3. "transparent" color keyword
  8708. transparent: [ null, null, null, 0 ],
  8709. _default: "#ffffff"
  8710. };
  8711. })( jQuery );
  8712. /******************************************************************************/
  8713. /****************************** CLASS ANIMATIONS ******************************/
  8714. /******************************************************************************/
  8715. (function() {
  8716. var classAnimationActions = [ "add", "remove", "toggle" ],
  8717. shorthandStyles = {
  8718. border: 1,
  8719. borderBottom: 1,
  8720. borderColor: 1,
  8721. borderLeft: 1,
  8722. borderRight: 1,
  8723. borderTop: 1,
  8724. borderWidth: 1,
  8725. margin: 1,
  8726. padding: 1
  8727. };
  8728. $.each([ "borderLeftStyle", "borderRightStyle", "borderBottomStyle", "borderTopStyle" ], function( _, prop ) {
  8729. $.fx.step[ prop ] = function( fx ) {
  8730. if ( fx.end !== "none" && !fx.setAttr || fx.pos === 1 && !fx.setAttr ) {
  8731. jQuery.style( fx.elem, prop, fx.end );
  8732. fx.setAttr = true;
  8733. }
  8734. };
  8735. });
  8736. function getElementStyles( elem ) {
  8737. var key, len,
  8738. style = elem.ownerDocument.defaultView ?
  8739. elem.ownerDocument.defaultView.getComputedStyle( elem, null ) :
  8740. elem.currentStyle,
  8741. styles = {};
  8742. if ( style && style.length && style[ 0 ] && style[ style[ 0 ] ] ) {
  8743. len = style.length;
  8744. while ( len-- ) {
  8745. key = style[ len ];
  8746. if ( typeof style[ key ] === "string" ) {
  8747. styles[ $.camelCase( key ) ] = style[ key ];
  8748. }
  8749. }
  8750. // support: Opera, IE <9
  8751. } else {
  8752. for ( key in style ) {
  8753. if ( typeof style[ key ] === "string" ) {
  8754. styles[ key ] = style[ key ];
  8755. }
  8756. }
  8757. }
  8758. return styles;
  8759. }
  8760. function styleDifference( oldStyle, newStyle ) {
  8761. var diff = {},
  8762. name, value;
  8763. for ( name in newStyle ) {
  8764. value = newStyle[ name ];
  8765. if ( oldStyle[ name ] !== value ) {
  8766. if ( !shorthandStyles[ name ] ) {
  8767. if ( $.fx.step[ name ] || !isNaN( parseFloat( value ) ) ) {
  8768. diff[ name ] = value;
  8769. }
  8770. }
  8771. }
  8772. }
  8773. return diff;
  8774. }
  8775. // support: jQuery <1.8
  8776. if ( !$.fn.addBack ) {
  8777. $.fn.addBack = function( selector ) {
  8778. return this.add( selector == null ?
  8779. this.prevObject : this.prevObject.filter( selector )
  8780. );
  8781. };
  8782. }
  8783. $.effects.animateClass = function( value, duration, easing, callback ) {
  8784. var o = $.speed( duration, easing, callback );
  8785. return this.queue( function() {
  8786. var animated = $( this ),
  8787. baseClass = animated.attr( "class" ) || "",
  8788. applyClassChange,
  8789. allAnimations = o.children ? animated.find( "*" ).addBack() : animated;
  8790. // map the animated objects to store the original styles.
  8791. allAnimations = allAnimations.map(function() {
  8792. var el = $( this );
  8793. return {
  8794. el: el,
  8795. start: getElementStyles( this )
  8796. };
  8797. });
  8798. // apply class change
  8799. applyClassChange = function() {
  8800. $.each( classAnimationActions, function(i, action) {
  8801. if ( value[ action ] ) {
  8802. animated[ action + "Class" ]( value[ action ] );
  8803. }
  8804. });
  8805. };
  8806. applyClassChange();
  8807. // map all animated objects again - calculate new styles and diff
  8808. allAnimations = allAnimations.map(function() {
  8809. this.end = getElementStyles( this.el[ 0 ] );
  8810. this.diff = styleDifference( this.start, this.end );
  8811. return this;
  8812. });
  8813. // apply original class
  8814. animated.attr( "class", baseClass );
  8815. // map all animated objects again - this time collecting a promise
  8816. allAnimations = allAnimations.map(function() {
  8817. var styleInfo = this,
  8818. dfd = $.Deferred(),
  8819. opts = $.extend({}, o, {
  8820. queue: false,
  8821. complete: function() {
  8822. dfd.resolve( styleInfo );
  8823. }
  8824. });
  8825. this.el.animate( this.diff, opts );
  8826. return dfd.promise();
  8827. });
  8828. // once all animations have completed:
  8829. $.when.apply( $, allAnimations.get() ).done(function() {
  8830. // set the final class
  8831. applyClassChange();
  8832. // for each animated element,
  8833. // clear all css properties that were animated
  8834. $.each( arguments, function() {
  8835. var el = this.el;
  8836. $.each( this.diff, function(key) {
  8837. el.css( key, "" );
  8838. });
  8839. });
  8840. // this is guarnteed to be there if you use jQuery.speed()
  8841. // it also handles dequeuing the next anim...
  8842. o.complete.call( animated[ 0 ] );
  8843. });
  8844. });
  8845. };
  8846. $.fn.extend({
  8847. addClass: (function( orig ) {
  8848. return function( classNames, speed, easing, callback ) {
  8849. return speed ?
  8850. $.effects.animateClass.call( this,
  8851. { add: classNames }, speed, easing, callback ) :
  8852. orig.apply( this, arguments );
  8853. };
  8854. })( $.fn.addClass ),
  8855. removeClass: (function( orig ) {
  8856. return function( classNames, speed, easing, callback ) {
  8857. return arguments.length > 1 ?
  8858. $.effects.animateClass.call( this,
  8859. { remove: classNames }, speed, easing, callback ) :
  8860. orig.apply( this, arguments );
  8861. };
  8862. })( $.fn.removeClass ),
  8863. toggleClass: (function( orig ) {
  8864. return function( classNames, force, speed, easing, callback ) {
  8865. if ( typeof force === "boolean" || force === undefined ) {
  8866. if ( !speed ) {
  8867. // without speed parameter
  8868. return orig.apply( this, arguments );
  8869. } else {
  8870. return $.effects.animateClass.call( this,
  8871. (force ? { add: classNames } : { remove: classNames }),
  8872. speed, easing, callback );
  8873. }
  8874. } else {
  8875. // without force parameter
  8876. return $.effects.animateClass.call( this,
  8877. { toggle: classNames }, force, speed, easing );
  8878. }
  8879. };
  8880. })( $.fn.toggleClass ),
  8881. switchClass: function( remove, add, speed, easing, callback) {
  8882. return $.effects.animateClass.call( this, {
  8883. add: add,
  8884. remove: remove
  8885. }, speed, easing, callback );
  8886. }
  8887. });
  8888. })();
  8889. /******************************************************************************/
  8890. /*********************************** EFFECTS **********************************/
  8891. /******************************************************************************/
  8892. (function() {
  8893. $.extend( $.effects, {
  8894. version: "1.11.2",
  8895. // Saves a set of properties in a data storage
  8896. save: function( element, set ) {
  8897. for ( var i = 0; i < set.length; i++ ) {
  8898. if ( set[ i ] !== null ) {
  8899. element.data( dataSpace + set[ i ], element[ 0 ].style[ set[ i ] ] );
  8900. }
  8901. }
  8902. },
  8903. // Restores a set of previously saved properties from a data storage
  8904. restore: function( element, set ) {
  8905. var val, i;
  8906. for ( i = 0; i < set.length; i++ ) {
  8907. if ( set[ i ] !== null ) {
  8908. val = element.data( dataSpace + set[ i ] );
  8909. // support: jQuery 1.6.2
  8910. // http://bugs.jquery.com/ticket/9917
  8911. // jQuery 1.6.2 incorrectly returns undefined for any falsy value.
  8912. // We can't differentiate between "" and 0 here, so we just assume
  8913. // empty string since it's likely to be a more common value...
  8914. if ( val === undefined ) {
  8915. val = "";
  8916. }
  8917. element.css( set[ i ], val );
  8918. }
  8919. }
  8920. },
  8921. setMode: function( el, mode ) {
  8922. if (mode === "toggle") {
  8923. mode = el.is( ":hidden" ) ? "show" : "hide";
  8924. }
  8925. return mode;
  8926. },
  8927. // Translates a [top,left] array into a baseline value
  8928. // this should be a little more flexible in the future to handle a string & hash
  8929. getBaseline: function( origin, original ) {
  8930. var y, x;
  8931. switch ( origin[ 0 ] ) {
  8932. case "top": y = 0; break;
  8933. case "middle": y = 0.5; break;
  8934. case "bottom": y = 1; break;
  8935. default: y = origin[ 0 ] / original.height;
  8936. }
  8937. switch ( origin[ 1 ] ) {
  8938. case "left": x = 0; break;
  8939. case "center": x = 0.5; break;
  8940. case "right": x = 1; break;
  8941. default: x = origin[ 1 ] / original.width;
  8942. }
  8943. return {
  8944. x: x,
  8945. y: y
  8946. };
  8947. },
  8948. // Wraps the element around a wrapper that copies position properties
  8949. createWrapper: function( element ) {
  8950. // if the element is already wrapped, return it
  8951. if ( element.parent().is( ".ui-effects-wrapper" )) {
  8952. return element.parent();
  8953. }
  8954. // wrap the element
  8955. var props = {
  8956. width: element.outerWidth(true),
  8957. height: element.outerHeight(true),
  8958. "float": element.css( "float" )
  8959. },
  8960. wrapper = $( "<div></div>" )
  8961. .addClass( "ui-effects-wrapper" )
  8962. .css({
  8963. fontSize: "100%",
  8964. background: "transparent",
  8965. border: "none",
  8966. margin: 0,
  8967. padding: 0
  8968. }),
  8969. // Store the size in case width/height are defined in % - Fixes #5245
  8970. size = {
  8971. width: element.width(),
  8972. height: element.height()
  8973. },
  8974. active = document.activeElement;
  8975. // support: Firefox
  8976. // Firefox incorrectly exposes anonymous content
  8977. // https://bugzilla.mozilla.org/show_bug.cgi?id=561664
  8978. try {
  8979. active.id;
  8980. } catch ( e ) {
  8981. active = document.body;
  8982. }
  8983. element.wrap( wrapper );
  8984. // Fixes #7595 - Elements lose focus when wrapped.
  8985. if ( element[ 0 ] === active || $.contains( element[ 0 ], active ) ) {
  8986. $( active ).focus();
  8987. }
  8988. wrapper = element.parent(); //Hotfix for jQuery 1.4 since some change in wrap() seems to actually lose the reference to the wrapped element
  8989. // transfer positioning properties to the wrapper
  8990. if ( element.css( "position" ) === "static" ) {
  8991. wrapper.css({ position: "relative" });
  8992. element.css({ position: "relative" });
  8993. } else {
  8994. $.extend( props, {
  8995. position: element.css( "position" ),
  8996. zIndex: element.css( "z-index" )
  8997. });
  8998. $.each([ "top", "left", "bottom", "right" ], function(i, pos) {
  8999. props[ pos ] = element.css( pos );
  9000. if ( isNaN( parseInt( props[ pos ], 10 ) ) ) {
  9001. props[ pos ] = "auto";
  9002. }
  9003. });
  9004. element.css({
  9005. position: "relative",
  9006. top: 0,
  9007. left: 0,
  9008. right: "auto",
  9009. bottom: "auto"
  9010. });
  9011. }
  9012. element.css(size);
  9013. return wrapper.css( props ).show();
  9014. },
  9015. removeWrapper: function( element ) {
  9016. var active = document.activeElement;
  9017. if ( element.parent().is( ".ui-effects-wrapper" ) ) {
  9018. element.parent().replaceWith( element );
  9019. // Fixes #7595 - Elements lose focus when wrapped.
  9020. if ( element[ 0 ] === active || $.contains( element[ 0 ], active ) ) {
  9021. $( active ).focus();
  9022. }
  9023. }
  9024. return element;
  9025. },
  9026. setTransition: function( element, list, factor, value ) {
  9027. value = value || {};
  9028. $.each( list, function( i, x ) {
  9029. var unit = element.cssUnit( x );
  9030. if ( unit[ 0 ] > 0 ) {
  9031. value[ x ] = unit[ 0 ] * factor + unit[ 1 ];
  9032. }
  9033. });
  9034. return value;
  9035. }
  9036. });
  9037. // return an effect options object for the given parameters:
  9038. function _normalizeArguments( effect, options, speed, callback ) {
  9039. // allow passing all options as the first parameter
  9040. if ( $.isPlainObject( effect ) ) {
  9041. options = effect;
  9042. effect = effect.effect;
  9043. }
  9044. // convert to an object
  9045. effect = { effect: effect };
  9046. // catch (effect, null, ...)
  9047. if ( options == null ) {
  9048. options = {};
  9049. }
  9050. // catch (effect, callback)
  9051. if ( $.isFunction( options ) ) {
  9052. callback = options;
  9053. speed = null;
  9054. options = {};
  9055. }
  9056. // catch (effect, speed, ?)
  9057. if ( typeof options === "number" || $.fx.speeds[ options ] ) {
  9058. callback = speed;
  9059. speed = options;
  9060. options = {};
  9061. }
  9062. // catch (effect, options, callback)
  9063. if ( $.isFunction( speed ) ) {
  9064. callback = speed;
  9065. speed = null;
  9066. }
  9067. // add options to effect
  9068. if ( options ) {
  9069. $.extend( effect, options );
  9070. }
  9071. speed = speed || options.duration;
  9072. effect.duration = $.fx.off ? 0 :
  9073. typeof speed === "number" ? speed :
  9074. speed in $.fx.speeds ? $.fx.speeds[ speed ] :
  9075. $.fx.speeds._default;
  9076. effect.complete = callback || options.complete;
  9077. return effect;
  9078. }
  9079. function standardAnimationOption( option ) {
  9080. // Valid standard speeds (nothing, number, named speed)
  9081. if ( !option || typeof option === "number" || $.fx.speeds[ option ] ) {
  9082. return true;
  9083. }
  9084. // Invalid strings - treat as "normal" speed
  9085. if ( typeof option === "string" && !$.effects.effect[ option ] ) {
  9086. return true;
  9087. }
  9088. // Complete callback
  9089. if ( $.isFunction( option ) ) {
  9090. return true;
  9091. }
  9092. // Options hash (but not naming an effect)
  9093. if ( typeof option === "object" && !option.effect ) {
  9094. return true;
  9095. }
  9096. // Didn't match any standard API
  9097. return false;
  9098. }
  9099. $.fn.extend({
  9100. effect: function( /* effect, options, speed, callback */ ) {
  9101. var args = _normalizeArguments.apply( this, arguments ),
  9102. mode = args.mode,
  9103. queue = args.queue,
  9104. effectMethod = $.effects.effect[ args.effect ];
  9105. if ( $.fx.off || !effectMethod ) {
  9106. // delegate to the original method (e.g., .show()) if possible
  9107. if ( mode ) {
  9108. return this[ mode ]( args.duration, args.complete );
  9109. } else {
  9110. return this.each( function() {
  9111. if ( args.complete ) {
  9112. args.complete.call( this );
  9113. }
  9114. });
  9115. }
  9116. }
  9117. function run( next ) {
  9118. var elem = $( this ),
  9119. complete = args.complete,
  9120. mode = args.mode;
  9121. function done() {
  9122. if ( $.isFunction( complete ) ) {
  9123. complete.call( elem[0] );
  9124. }
  9125. if ( $.isFunction( next ) ) {
  9126. next();
  9127. }
  9128. }
  9129. // If the element already has the correct final state, delegate to
  9130. // the core methods so the internal tracking of "olddisplay" works.
  9131. if ( elem.is( ":hidden" ) ? mode === "hide" : mode === "show" ) {
  9132. elem[ mode ]();
  9133. done();
  9134. } else {
  9135. effectMethod.call( elem[0], args, done );
  9136. }
  9137. }
  9138. return queue === false ? this.each( run ) : this.queue( queue || "fx", run );
  9139. },
  9140. show: (function( orig ) {
  9141. return function( option ) {
  9142. if ( standardAnimationOption( option ) ) {
  9143. return orig.apply( this, arguments );
  9144. } else {
  9145. var args = _normalizeArguments.apply( this, arguments );
  9146. args.mode = "show";
  9147. return this.effect.call( this, args );
  9148. }
  9149. };
  9150. })( $.fn.show ),
  9151. hide: (function( orig ) {
  9152. return function( option ) {
  9153. if ( standardAnimationOption( option ) ) {
  9154. return orig.apply( this, arguments );
  9155. } else {
  9156. var args = _normalizeArguments.apply( this, arguments );
  9157. args.mode = "hide";
  9158. return this.effect.call( this, args );
  9159. }
  9160. };
  9161. })( $.fn.hide ),
  9162. toggle: (function( orig ) {
  9163. return function( option ) {
  9164. if ( standardAnimationOption( option ) || typeof option === "boolean" ) {
  9165. return orig.apply( this, arguments );
  9166. } else {
  9167. var args = _normalizeArguments.apply( this, arguments );
  9168. args.mode = "toggle";
  9169. return this.effect.call( this, args );
  9170. }
  9171. };
  9172. })( $.fn.toggle ),
  9173. // helper functions
  9174. cssUnit: function(key) {
  9175. var style = this.css( key ),
  9176. val = [];
  9177. $.each( [ "em", "px", "%", "pt" ], function( i, unit ) {
  9178. if ( style.indexOf( unit ) > 0 ) {
  9179. val = [ parseFloat( style ), unit ];
  9180. }
  9181. });
  9182. return val;
  9183. }
  9184. });
  9185. })();
  9186. /******************************************************************************/
  9187. /*********************************** EASING ***********************************/
  9188. /******************************************************************************/
  9189. (function() {
  9190. // based on easing equations from Robert Penner (http://www.robertpenner.com/easing)
  9191. var baseEasings = {};
  9192. $.each( [ "Quad", "Cubic", "Quart", "Quint", "Expo" ], function( i, name ) {
  9193. baseEasings[ name ] = function( p ) {
  9194. return Math.pow( p, i + 2 );
  9195. };
  9196. });
  9197. $.extend( baseEasings, {
  9198. Sine: function( p ) {
  9199. return 1 - Math.cos( p * Math.PI / 2 );
  9200. },
  9201. Circ: function( p ) {
  9202. return 1 - Math.sqrt( 1 - p * p );
  9203. },
  9204. Elastic: function( p ) {
  9205. return p === 0 || p === 1 ? p :
  9206. -Math.pow( 2, 8 * (p - 1) ) * Math.sin( ( (p - 1) * 80 - 7.5 ) * Math.PI / 15 );
  9207. },
  9208. Back: function( p ) {
  9209. return p * p * ( 3 * p - 2 );
  9210. },
  9211. Bounce: function( p ) {
  9212. var pow2,
  9213. bounce = 4;
  9214. while ( p < ( ( pow2 = Math.pow( 2, --bounce ) ) - 1 ) / 11 ) {}
  9215. return 1 / Math.pow( 4, 3 - bounce ) - 7.5625 * Math.pow( ( pow2 * 3 - 2 ) / 22 - p, 2 );
  9216. }
  9217. });
  9218. $.each( baseEasings, function( name, easeIn ) {
  9219. $.easing[ "easeIn" + name ] = easeIn;
  9220. $.easing[ "easeOut" + name ] = function( p ) {
  9221. return 1 - easeIn( 1 - p );
  9222. };
  9223. $.easing[ "easeInOut" + name ] = function( p ) {
  9224. return p < 0.5 ?
  9225. easeIn( p * 2 ) / 2 :
  9226. 1 - easeIn( p * -2 + 2 ) / 2;
  9227. };
  9228. });
  9229. })();
  9230. var effect = $.effects;
  9231. /*!
  9232. * jQuery UI Effects Blind 1.11.2
  9233. * http://jqueryui.com
  9234. *
  9235. * Copyright 2014 jQuery Foundation and other contributors
  9236. * Released under the MIT license.
  9237. * http://jquery.org/license
  9238. *
  9239. * http://api.jqueryui.com/blind-effect/
  9240. */
  9241. var effectBlind = $.effects.effect.blind = function( o, done ) {
  9242. // Create element
  9243. var el = $( this ),
  9244. rvertical = /up|down|vertical/,
  9245. rpositivemotion = /up|left|vertical|horizontal/,
  9246. props = [ "position", "top", "bottom", "left", "right", "height", "width" ],
  9247. mode = $.effects.setMode( el, o.mode || "hide" ),
  9248. direction = o.direction || "up",
  9249. vertical = rvertical.test( direction ),
  9250. ref = vertical ? "height" : "width",
  9251. ref2 = vertical ? "top" : "left",
  9252. motion = rpositivemotion.test( direction ),
  9253. animation = {},
  9254. show = mode === "show",
  9255. wrapper, distance, margin;
  9256. // if already wrapped, the wrapper's properties are my property. #6245
  9257. if ( el.parent().is( ".ui-effects-wrapper" ) ) {
  9258. $.effects.save( el.parent(), props );
  9259. } else {
  9260. $.effects.save( el, props );
  9261. }
  9262. el.show();
  9263. wrapper = $.effects.createWrapper( el ).css({
  9264. overflow: "hidden"
  9265. });
  9266. distance = wrapper[ ref ]();
  9267. margin = parseFloat( wrapper.css( ref2 ) ) || 0;
  9268. animation[ ref ] = show ? distance : 0;
  9269. if ( !motion ) {
  9270. el
  9271. .css( vertical ? "bottom" : "right", 0 )
  9272. .css( vertical ? "top" : "left", "auto" )
  9273. .css({ position: "absolute" });
  9274. animation[ ref2 ] = show ? margin : distance + margin;
  9275. }
  9276. // start at 0 if we are showing
  9277. if ( show ) {
  9278. wrapper.css( ref, 0 );
  9279. if ( !motion ) {
  9280. wrapper.css( ref2, margin + distance );
  9281. }
  9282. }
  9283. // Animate
  9284. wrapper.animate( animation, {
  9285. duration: o.duration,
  9286. easing: o.easing,
  9287. queue: false,
  9288. complete: function() {
  9289. if ( mode === "hide" ) {
  9290. el.hide();
  9291. }
  9292. $.effects.restore( el, props );
  9293. $.effects.removeWrapper( el );
  9294. done();
  9295. }
  9296. });
  9297. };
  9298. /*!
  9299. * jQuery UI Effects Bounce 1.11.2
  9300. * http://jqueryui.com
  9301. *
  9302. * Copyright 2014 jQuery Foundation and other contributors
  9303. * Released under the MIT license.
  9304. * http://jquery.org/license
  9305. *
  9306. * http://api.jqueryui.com/bounce-effect/
  9307. */
  9308. var effectBounce = $.effects.effect.bounce = function( o, done ) {
  9309. var el = $( this ),
  9310. props = [ "position", "top", "bottom", "left", "right", "height", "width" ],
  9311. // defaults:
  9312. mode = $.effects.setMode( el, o.mode || "effect" ),
  9313. hide = mode === "hide",
  9314. show = mode === "show",
  9315. direction = o.direction || "up",
  9316. distance = o.distance,
  9317. times = o.times || 5,
  9318. // number of internal animations
  9319. anims = times * 2 + ( show || hide ? 1 : 0 ),
  9320. speed = o.duration / anims,
  9321. easing = o.easing,
  9322. // utility:
  9323. ref = ( direction === "up" || direction === "down" ) ? "top" : "left",
  9324. motion = ( direction === "up" || direction === "left" ),
  9325. i,
  9326. upAnim,
  9327. downAnim,
  9328. // we will need to re-assemble the queue to stack our animations in place
  9329. queue = el.queue(),
  9330. queuelen = queue.length;
  9331. // Avoid touching opacity to prevent clearType and PNG issues in IE
  9332. if ( show || hide ) {
  9333. props.push( "opacity" );
  9334. }
  9335. $.effects.save( el, props );
  9336. el.show();
  9337. $.effects.createWrapper( el ); // Create Wrapper
  9338. // default distance for the BIGGEST bounce is the outer Distance / 3
  9339. if ( !distance ) {
  9340. distance = el[ ref === "top" ? "outerHeight" : "outerWidth" ]() / 3;
  9341. }
  9342. if ( show ) {
  9343. downAnim = { opacity: 1 };
  9344. downAnim[ ref ] = 0;
  9345. // if we are showing, force opacity 0 and set the initial position
  9346. // then do the "first" animation
  9347. el.css( "opacity", 0 )
  9348. .css( ref, motion ? -distance * 2 : distance * 2 )
  9349. .animate( downAnim, speed, easing );
  9350. }
  9351. // start at the smallest distance if we are hiding
  9352. if ( hide ) {
  9353. distance = distance / Math.pow( 2, times - 1 );
  9354. }
  9355. downAnim = {};
  9356. downAnim[ ref ] = 0;
  9357. // Bounces up/down/left/right then back to 0 -- times * 2 animations happen here
  9358. for ( i = 0; i < times; i++ ) {
  9359. upAnim = {};
  9360. upAnim[ ref ] = ( motion ? "-=" : "+=" ) + distance;
  9361. el.animate( upAnim, speed, easing )
  9362. .animate( downAnim, speed, easing );
  9363. distance = hide ? distance * 2 : distance / 2;
  9364. }
  9365. // Last Bounce when Hiding
  9366. if ( hide ) {
  9367. upAnim = { opacity: 0 };
  9368. upAnim[ ref ] = ( motion ? "-=" : "+=" ) + distance;
  9369. el.animate( upAnim, speed, easing );
  9370. }
  9371. el.queue(function() {
  9372. if ( hide ) {
  9373. el.hide();
  9374. }
  9375. $.effects.restore( el, props );
  9376. $.effects.removeWrapper( el );
  9377. done();
  9378. });
  9379. // inject all the animations we just queued to be first in line (after "inprogress")
  9380. if ( queuelen > 1) {
  9381. queue.splice.apply( queue,
  9382. [ 1, 0 ].concat( queue.splice( queuelen, anims + 1 ) ) );
  9383. }
  9384. el.dequeue();
  9385. };
  9386. /*!
  9387. * jQuery UI Effects Clip 1.11.2
  9388. * http://jqueryui.com
  9389. *
  9390. * Copyright 2014 jQuery Foundation and other contributors
  9391. * Released under the MIT license.
  9392. * http://jquery.org/license
  9393. *
  9394. * http://api.jqueryui.com/clip-effect/
  9395. */
  9396. var effectClip = $.effects.effect.clip = function( o, done ) {
  9397. // Create element
  9398. var el = $( this ),
  9399. props = [ "position", "top", "bottom", "left", "right", "height", "width" ],
  9400. mode = $.effects.setMode( el, o.mode || "hide" ),
  9401. show = mode === "show",
  9402. direction = o.direction || "vertical",
  9403. vert = direction === "vertical",
  9404. size = vert ? "height" : "width",
  9405. position = vert ? "top" : "left",
  9406. animation = {},
  9407. wrapper, animate, distance;
  9408. // Save & Show
  9409. $.effects.save( el, props );
  9410. el.show();
  9411. // Create Wrapper
  9412. wrapper = $.effects.createWrapper( el ).css({
  9413. overflow: "hidden"
  9414. });
  9415. animate = ( el[0].tagName === "IMG" ) ? wrapper : el;
  9416. distance = animate[ size ]();
  9417. // Shift
  9418. if ( show ) {
  9419. animate.css( size, 0 );
  9420. animate.css( position, distance / 2 );
  9421. }
  9422. // Create Animation Object:
  9423. animation[ size ] = show ? distance : 0;
  9424. animation[ position ] = show ? 0 : distance / 2;
  9425. // Animate
  9426. animate.animate( animation, {
  9427. queue: false,
  9428. duration: o.duration,
  9429. easing: o.easing,
  9430. complete: function() {
  9431. if ( !show ) {
  9432. el.hide();
  9433. }
  9434. $.effects.restore( el, props );
  9435. $.effects.removeWrapper( el );
  9436. done();
  9437. }
  9438. });
  9439. };
  9440. /*!
  9441. * jQuery UI Effects Drop 1.11.2
  9442. * http://jqueryui.com
  9443. *
  9444. * Copyright 2014 jQuery Foundation and other contributors
  9445. * Released under the MIT license.
  9446. * http://jquery.org/license
  9447. *
  9448. * http://api.jqueryui.com/drop-effect/
  9449. */
  9450. var effectDrop = $.effects.effect.drop = function( o, done ) {
  9451. var el = $( this ),
  9452. props = [ "position", "top", "bottom", "left", "right", "opacity", "height", "width" ],
  9453. mode = $.effects.setMode( el, o.mode || "hide" ),
  9454. show = mode === "show",
  9455. direction = o.direction || "left",
  9456. ref = ( direction === "up" || direction === "down" ) ? "top" : "left",
  9457. motion = ( direction === "up" || direction === "left" ) ? "pos" : "neg",
  9458. animation = {
  9459. opacity: show ? 1 : 0
  9460. },
  9461. distance;
  9462. // Adjust
  9463. $.effects.save( el, props );
  9464. el.show();
  9465. $.effects.createWrapper( el );
  9466. distance = o.distance || el[ ref === "top" ? "outerHeight" : "outerWidth" ]( true ) / 2;
  9467. if ( show ) {
  9468. el
  9469. .css( "opacity", 0 )
  9470. .css( ref, motion === "pos" ? -distance : distance );
  9471. }
  9472. // Animation
  9473. animation[ ref ] = ( show ?
  9474. ( motion === "pos" ? "+=" : "-=" ) :
  9475. ( motion === "pos" ? "-=" : "+=" ) ) +
  9476. distance;
  9477. // Animate
  9478. el.animate( animation, {
  9479. queue: false,
  9480. duration: o.duration,
  9481. easing: o.easing,
  9482. complete: function() {
  9483. if ( mode === "hide" ) {
  9484. el.hide();
  9485. }
  9486. $.effects.restore( el, props );
  9487. $.effects.removeWrapper( el );
  9488. done();
  9489. }
  9490. });
  9491. };
  9492. /*!
  9493. * jQuery UI Effects Explode 1.11.2
  9494. * http://jqueryui.com
  9495. *
  9496. * Copyright 2014 jQuery Foundation and other contributors
  9497. * Released under the MIT license.
  9498. * http://jquery.org/license
  9499. *
  9500. * http://api.jqueryui.com/explode-effect/
  9501. */
  9502. var effectExplode = $.effects.effect.explode = function( o, done ) {
  9503. var rows = o.pieces ? Math.round( Math.sqrt( o.pieces ) ) : 3,
  9504. cells = rows,
  9505. el = $( this ),
  9506. mode = $.effects.setMode( el, o.mode || "hide" ),
  9507. show = mode === "show",
  9508. // show and then visibility:hidden the element before calculating offset
  9509. offset = el.show().css( "visibility", "hidden" ).offset(),
  9510. // width and height of a piece
  9511. width = Math.ceil( el.outerWidth() / cells ),
  9512. height = Math.ceil( el.outerHeight() / rows ),
  9513. pieces = [],
  9514. // loop
  9515. i, j, left, top, mx, my;
  9516. // children animate complete:
  9517. function childComplete() {
  9518. pieces.push( this );
  9519. if ( pieces.length === rows * cells ) {
  9520. animComplete();
  9521. }
  9522. }
  9523. // clone the element for each row and cell.
  9524. for ( i = 0; i < rows ; i++ ) { // ===>
  9525. top = offset.top + i * height;
  9526. my = i - ( rows - 1 ) / 2 ;
  9527. for ( j = 0; j < cells ; j++ ) { // |||
  9528. left = offset.left + j * width;
  9529. mx = j - ( cells - 1 ) / 2 ;
  9530. // Create a clone of the now hidden main element that will be absolute positioned
  9531. // within a wrapper div off the -left and -top equal to size of our pieces
  9532. el
  9533. .clone()
  9534. .appendTo( "body" )
  9535. .wrap( "<div></div>" )
  9536. .css({
  9537. position: "absolute",
  9538. visibility: "visible",
  9539. left: -j * width,
  9540. top: -i * height
  9541. })
  9542. // select the wrapper - make it overflow: hidden and absolute positioned based on
  9543. // where the original was located +left and +top equal to the size of pieces
  9544. .parent()
  9545. .addClass( "ui-effects-explode" )
  9546. .css({
  9547. position: "absolute",
  9548. overflow: "hidden",
  9549. width: width,
  9550. height: height,
  9551. left: left + ( show ? mx * width : 0 ),
  9552. top: top + ( show ? my * height : 0 ),
  9553. opacity: show ? 0 : 1
  9554. }).animate({
  9555. left: left + ( show ? 0 : mx * width ),
  9556. top: top + ( show ? 0 : my * height ),
  9557. opacity: show ? 1 : 0
  9558. }, o.duration || 500, o.easing, childComplete );
  9559. }
  9560. }
  9561. function animComplete() {
  9562. el.css({
  9563. visibility: "visible"
  9564. });
  9565. $( pieces ).remove();
  9566. if ( !show ) {
  9567. el.hide();
  9568. }
  9569. done();
  9570. }
  9571. };
  9572. /*!
  9573. * jQuery UI Effects Fade 1.11.2
  9574. * http://jqueryui.com
  9575. *
  9576. * Copyright 2014 jQuery Foundation and other contributors
  9577. * Released under the MIT license.
  9578. * http://jquery.org/license
  9579. *
  9580. * http://api.jqueryui.com/fade-effect/
  9581. */
  9582. var effectFade = $.effects.effect.fade = function( o, done ) {
  9583. var el = $( this ),
  9584. mode = $.effects.setMode( el, o.mode || "toggle" );
  9585. el.animate({
  9586. opacity: mode
  9587. }, {
  9588. queue: false,
  9589. duration: o.duration,
  9590. easing: o.easing,
  9591. complete: done
  9592. });
  9593. };
  9594. /*!
  9595. * jQuery UI Effects Fold 1.11.2
  9596. * http://jqueryui.com
  9597. *
  9598. * Copyright 2014 jQuery Foundation and other contributors
  9599. * Released under the MIT license.
  9600. * http://jquery.org/license
  9601. *
  9602. * http://api.jqueryui.com/fold-effect/
  9603. */
  9604. var effectFold = $.effects.effect.fold = function( o, done ) {
  9605. // Create element
  9606. var el = $( this ),
  9607. props = [ "position", "top", "bottom", "left", "right", "height", "width" ],
  9608. mode = $.effects.setMode( el, o.mode || "hide" ),
  9609. show = mode === "show",
  9610. hide = mode === "hide",
  9611. size = o.size || 15,
  9612. percent = /([0-9]+)%/.exec( size ),
  9613. horizFirst = !!o.horizFirst,
  9614. widthFirst = show !== horizFirst,
  9615. ref = widthFirst ? [ "width", "height" ] : [ "height", "width" ],
  9616. duration = o.duration / 2,
  9617. wrapper, distance,
  9618. animation1 = {},
  9619. animation2 = {};
  9620. $.effects.save( el, props );
  9621. el.show();
  9622. // Create Wrapper
  9623. wrapper = $.effects.createWrapper( el ).css({
  9624. overflow: "hidden"
  9625. });
  9626. distance = widthFirst ?
  9627. [ wrapper.width(), wrapper.height() ] :
  9628. [ wrapper.height(), wrapper.width() ];
  9629. if ( percent ) {
  9630. size = parseInt( percent[ 1 ], 10 ) / 100 * distance[ hide ? 0 : 1 ];
  9631. }
  9632. if ( show ) {
  9633. wrapper.css( horizFirst ? {
  9634. height: 0,
  9635. width: size
  9636. } : {
  9637. height: size,
  9638. width: 0
  9639. });
  9640. }
  9641. // Animation
  9642. animation1[ ref[ 0 ] ] = show ? distance[ 0 ] : size;
  9643. animation2[ ref[ 1 ] ] = show ? distance[ 1 ] : 0;
  9644. // Animate
  9645. wrapper
  9646. .animate( animation1, duration, o.easing )
  9647. .animate( animation2, duration, o.easing, function() {
  9648. if ( hide ) {
  9649. el.hide();
  9650. }
  9651. $.effects.restore( el, props );
  9652. $.effects.removeWrapper( el );
  9653. done();
  9654. });
  9655. };
  9656. /*!
  9657. * jQuery UI Effects Highlight 1.11.2
  9658. * http://jqueryui.com
  9659. *
  9660. * Copyright 2014 jQuery Foundation and other contributors
  9661. * Released under the MIT license.
  9662. * http://jquery.org/license
  9663. *
  9664. * http://api.jqueryui.com/highlight-effect/
  9665. */
  9666. var effectHighlight = $.effects.effect.highlight = function( o, done ) {
  9667. var elem = $( this ),
  9668. props = [ "backgroundImage", "backgroundColor", "opacity" ],
  9669. mode = $.effects.setMode( elem, o.mode || "show" ),
  9670. animation = {
  9671. backgroundColor: elem.css( "backgroundColor" )
  9672. };
  9673. if (mode === "hide") {
  9674. animation.opacity = 0;
  9675. }
  9676. $.effects.save( elem, props );
  9677. elem
  9678. .show()
  9679. .css({
  9680. backgroundImage: "none",
  9681. backgroundColor: o.color || "#ffff99"
  9682. })
  9683. .animate( animation, {
  9684. queue: false,
  9685. duration: o.duration,
  9686. easing: o.easing,
  9687. complete: function() {
  9688. if ( mode === "hide" ) {
  9689. elem.hide();
  9690. }
  9691. $.effects.restore( elem, props );
  9692. done();
  9693. }
  9694. });
  9695. };
  9696. /*!
  9697. * jQuery UI Effects Size 1.11.2
  9698. * http://jqueryui.com
  9699. *
  9700. * Copyright 2014 jQuery Foundation and other contributors
  9701. * Released under the MIT license.
  9702. * http://jquery.org/license
  9703. *
  9704. * http://api.jqueryui.com/size-effect/
  9705. */
  9706. var effectSize = $.effects.effect.size = function( o, done ) {
  9707. // Create element
  9708. var original, baseline, factor,
  9709. el = $( this ),
  9710. props0 = [ "position", "top", "bottom", "left", "right", "width", "height", "overflow", "opacity" ],
  9711. // Always restore
  9712. props1 = [ "position", "top", "bottom", "left", "right", "overflow", "opacity" ],
  9713. // Copy for children
  9714. props2 = [ "width", "height", "overflow" ],
  9715. cProps = [ "fontSize" ],
  9716. vProps = [ "borderTopWidth", "borderBottomWidth", "paddingTop", "paddingBottom" ],
  9717. hProps = [ "borderLeftWidth", "borderRightWidth", "paddingLeft", "paddingRight" ],
  9718. // Set options
  9719. mode = $.effects.setMode( el, o.mode || "effect" ),
  9720. restore = o.restore || mode !== "effect",
  9721. scale = o.scale || "both",
  9722. origin = o.origin || [ "middle", "center" ],
  9723. position = el.css( "position" ),
  9724. props = restore ? props0 : props1,
  9725. zero = {
  9726. height: 0,
  9727. width: 0,
  9728. outerHeight: 0,
  9729. outerWidth: 0
  9730. };
  9731. if ( mode === "show" ) {
  9732. el.show();
  9733. }
  9734. original = {
  9735. height: el.height(),
  9736. width: el.width(),
  9737. outerHeight: el.outerHeight(),
  9738. outerWidth: el.outerWidth()
  9739. };
  9740. if ( o.mode === "toggle" && mode === "show" ) {
  9741. el.from = o.to || zero;
  9742. el.to = o.from || original;
  9743. } else {
  9744. el.from = o.from || ( mode === "show" ? zero : original );
  9745. el.to = o.to || ( mode === "hide" ? zero : original );
  9746. }
  9747. // Set scaling factor
  9748. factor = {
  9749. from: {
  9750. y: el.from.height / original.height,
  9751. x: el.from.width / original.width
  9752. },
  9753. to: {
  9754. y: el.to.height / original.height,
  9755. x: el.to.width / original.width
  9756. }
  9757. };
  9758. // Scale the css box
  9759. if ( scale === "box" || scale === "both" ) {
  9760. // Vertical props scaling
  9761. if ( factor.from.y !== factor.to.y ) {
  9762. props = props.concat( vProps );
  9763. el.from = $.effects.setTransition( el, vProps, factor.from.y, el.from );
  9764. el.to = $.effects.setTransition( el, vProps, factor.to.y, el.to );
  9765. }
  9766. // Horizontal props scaling
  9767. if ( factor.from.x !== factor.to.x ) {
  9768. props = props.concat( hProps );
  9769. el.from = $.effects.setTransition( el, hProps, factor.from.x, el.from );
  9770. el.to = $.effects.setTransition( el, hProps, factor.to.x, el.to );
  9771. }
  9772. }
  9773. // Scale the content
  9774. if ( scale === "content" || scale === "both" ) {
  9775. // Vertical props scaling
  9776. if ( factor.from.y !== factor.to.y ) {
  9777. props = props.concat( cProps ).concat( props2 );
  9778. el.from = $.effects.setTransition( el, cProps, factor.from.y, el.from );
  9779. el.to = $.effects.setTransition( el, cProps, factor.to.y, el.to );
  9780. }
  9781. }
  9782. $.effects.save( el, props );
  9783. el.show();
  9784. $.effects.createWrapper( el );
  9785. el.css( "overflow", "hidden" ).css( el.from );
  9786. // Adjust
  9787. if (origin) { // Calculate baseline shifts
  9788. baseline = $.effects.getBaseline( origin, original );
  9789. el.from.top = ( original.outerHeight - el.outerHeight() ) * baseline.y;
  9790. el.from.left = ( original.outerWidth - el.outerWidth() ) * baseline.x;
  9791. el.to.top = ( original.outerHeight - el.to.outerHeight ) * baseline.y;
  9792. el.to.left = ( original.outerWidth - el.to.outerWidth ) * baseline.x;
  9793. }
  9794. el.css( el.from ); // set top & left
  9795. // Animate
  9796. if ( scale === "content" || scale === "both" ) { // Scale the children
  9797. // Add margins/font-size
  9798. vProps = vProps.concat([ "marginTop", "marginBottom" ]).concat(cProps);
  9799. hProps = hProps.concat([ "marginLeft", "marginRight" ]);
  9800. props2 = props0.concat(vProps).concat(hProps);
  9801. el.find( "*[width]" ).each( function() {
  9802. var child = $( this ),
  9803. c_original = {
  9804. height: child.height(),
  9805. width: child.width(),
  9806. outerHeight: child.outerHeight(),
  9807. outerWidth: child.outerWidth()
  9808. };
  9809. if (restore) {
  9810. $.effects.save(child, props2);
  9811. }
  9812. child.from = {
  9813. height: c_original.height * factor.from.y,
  9814. width: c_original.width * factor.from.x,
  9815. outerHeight: c_original.outerHeight * factor.from.y,
  9816. outerWidth: c_original.outerWidth * factor.from.x
  9817. };
  9818. child.to = {
  9819. height: c_original.height * factor.to.y,
  9820. width: c_original.width * factor.to.x,
  9821. outerHeight: c_original.height * factor.to.y,
  9822. outerWidth: c_original.width * factor.to.x
  9823. };
  9824. // Vertical props scaling
  9825. if ( factor.from.y !== factor.to.y ) {
  9826. child.from = $.effects.setTransition( child, vProps, factor.from.y, child.from );
  9827. child.to = $.effects.setTransition( child, vProps, factor.to.y, child.to );
  9828. }
  9829. // Horizontal props scaling
  9830. if ( factor.from.x !== factor.to.x ) {
  9831. child.from = $.effects.setTransition( child, hProps, factor.from.x, child.from );
  9832. child.to = $.effects.setTransition( child, hProps, factor.to.x, child.to );
  9833. }
  9834. // Animate children
  9835. child.css( child.from );
  9836. child.animate( child.to, o.duration, o.easing, function() {
  9837. // Restore children
  9838. if ( restore ) {
  9839. $.effects.restore( child, props2 );
  9840. }
  9841. });
  9842. });
  9843. }
  9844. // Animate
  9845. el.animate( el.to, {
  9846. queue: false,
  9847. duration: o.duration,
  9848. easing: o.easing,
  9849. complete: function() {
  9850. if ( el.to.opacity === 0 ) {
  9851. el.css( "opacity", el.from.opacity );
  9852. }
  9853. if ( mode === "hide" ) {
  9854. el.hide();
  9855. }
  9856. $.effects.restore( el, props );
  9857. if ( !restore ) {
  9858. // we need to calculate our new positioning based on the scaling
  9859. if ( position === "static" ) {
  9860. el.css({
  9861. position: "relative",
  9862. top: el.to.top,
  9863. left: el.to.left
  9864. });
  9865. } else {
  9866. $.each([ "top", "left" ], function( idx, pos ) {
  9867. el.css( pos, function( _, str ) {
  9868. var val = parseInt( str, 10 ),
  9869. toRef = idx ? el.to.left : el.to.top;
  9870. // if original was "auto", recalculate the new value from wrapper
  9871. if ( str === "auto" ) {
  9872. return toRef + "px";
  9873. }
  9874. return val + toRef + "px";
  9875. });
  9876. });
  9877. }
  9878. }
  9879. $.effects.removeWrapper( el );
  9880. done();
  9881. }
  9882. });
  9883. };
  9884. /*!
  9885. * jQuery UI Effects Scale 1.11.2
  9886. * http://jqueryui.com
  9887. *
  9888. * Copyright 2014 jQuery Foundation and other contributors
  9889. * Released under the MIT license.
  9890. * http://jquery.org/license
  9891. *
  9892. * http://api.jqueryui.com/scale-effect/
  9893. */
  9894. var effectScale = $.effects.effect.scale = function( o, done ) {
  9895. // Create element
  9896. var el = $( this ),
  9897. options = $.extend( true, {}, o ),
  9898. mode = $.effects.setMode( el, o.mode || "effect" ),
  9899. percent = parseInt( o.percent, 10 ) ||
  9900. ( parseInt( o.percent, 10 ) === 0 ? 0 : ( mode === "hide" ? 0 : 100 ) ),
  9901. direction = o.direction || "both",
  9902. origin = o.origin,
  9903. original = {
  9904. height: el.height(),
  9905. width: el.width(),
  9906. outerHeight: el.outerHeight(),
  9907. outerWidth: el.outerWidth()
  9908. },
  9909. factor = {
  9910. y: direction !== "horizontal" ? (percent / 100) : 1,
  9911. x: direction !== "vertical" ? (percent / 100) : 1
  9912. };
  9913. // We are going to pass this effect to the size effect:
  9914. options.effect = "size";
  9915. options.queue = false;
  9916. options.complete = done;
  9917. // Set default origin and restore for show/hide
  9918. if ( mode !== "effect" ) {
  9919. options.origin = origin || [ "middle", "center" ];
  9920. options.restore = true;
  9921. }
  9922. options.from = o.from || ( mode === "show" ? {
  9923. height: 0,
  9924. width: 0,
  9925. outerHeight: 0,
  9926. outerWidth: 0
  9927. } : original );
  9928. options.to = {
  9929. height: original.height * factor.y,
  9930. width: original.width * factor.x,
  9931. outerHeight: original.outerHeight * factor.y,
  9932. outerWidth: original.outerWidth * factor.x
  9933. };
  9934. // Fade option to support puff
  9935. if ( options.fade ) {
  9936. if ( mode === "show" ) {
  9937. options.from.opacity = 0;
  9938. options.to.opacity = 1;
  9939. }
  9940. if ( mode === "hide" ) {
  9941. options.from.opacity = 1;
  9942. options.to.opacity = 0;
  9943. }
  9944. }
  9945. // Animate
  9946. el.effect( options );
  9947. };
  9948. /*!
  9949. * jQuery UI Effects Puff 1.11.2
  9950. * http://jqueryui.com
  9951. *
  9952. * Copyright 2014 jQuery Foundation and other contributors
  9953. * Released under the MIT license.
  9954. * http://jquery.org/license
  9955. *
  9956. * http://api.jqueryui.com/puff-effect/
  9957. */
  9958. var effectPuff = $.effects.effect.puff = function( o, done ) {
  9959. var elem = $( this ),
  9960. mode = $.effects.setMode( elem, o.mode || "hide" ),
  9961. hide = mode === "hide",
  9962. percent = parseInt( o.percent, 10 ) || 150,
  9963. factor = percent / 100,
  9964. original = {
  9965. height: elem.height(),
  9966. width: elem.width(),
  9967. outerHeight: elem.outerHeight(),
  9968. outerWidth: elem.outerWidth()
  9969. };
  9970. $.extend( o, {
  9971. effect: "scale",
  9972. queue: false,
  9973. fade: true,
  9974. mode: mode,
  9975. complete: done,
  9976. percent: hide ? percent : 100,
  9977. from: hide ?
  9978. original :
  9979. {
  9980. height: original.height * factor,
  9981. width: original.width * factor,
  9982. outerHeight: original.outerHeight * factor,
  9983. outerWidth: original.outerWidth * factor
  9984. }
  9985. });
  9986. elem.effect( o );
  9987. };
  9988. /*!
  9989. * jQuery UI Effects Pulsate 1.11.2
  9990. * http://jqueryui.com
  9991. *
  9992. * Copyright 2014 jQuery Foundation and other contributors
  9993. * Released under the MIT license.
  9994. * http://jquery.org/license
  9995. *
  9996. * http://api.jqueryui.com/pulsate-effect/
  9997. */
  9998. var effectPulsate = $.effects.effect.pulsate = function( o, done ) {
  9999. var elem = $( this ),
  10000. mode = $.effects.setMode( elem, o.mode || "show" ),
  10001. show = mode === "show",
  10002. hide = mode === "hide",
  10003. showhide = ( show || mode === "hide" ),
  10004. // showing or hiding leaves of the "last" animation
  10005. anims = ( ( o.times || 5 ) * 2 ) + ( showhide ? 1 : 0 ),
  10006. duration = o.duration / anims,
  10007. animateTo = 0,
  10008. queue = elem.queue(),
  10009. queuelen = queue.length,
  10010. i;
  10011. if ( show || !elem.is(":visible")) {
  10012. elem.css( "opacity", 0 ).show();
  10013. animateTo = 1;
  10014. }
  10015. // anims - 1 opacity "toggles"
  10016. for ( i = 1; i < anims; i++ ) {
  10017. elem.animate({
  10018. opacity: animateTo
  10019. }, duration, o.easing );
  10020. animateTo = 1 - animateTo;
  10021. }
  10022. elem.animate({
  10023. opacity: animateTo
  10024. }, duration, o.easing);
  10025. elem.queue(function() {
  10026. if ( hide ) {
  10027. elem.hide();
  10028. }
  10029. done();
  10030. });
  10031. // We just queued up "anims" animations, we need to put them next in the queue
  10032. if ( queuelen > 1 ) {
  10033. queue.splice.apply( queue,
  10034. [ 1, 0 ].concat( queue.splice( queuelen, anims + 1 ) ) );
  10035. }
  10036. elem.dequeue();
  10037. };
  10038. /*!
  10039. * jQuery UI Effects Shake 1.11.2
  10040. * http://jqueryui.com
  10041. *
  10042. * Copyright 2014 jQuery Foundation and other contributors
  10043. * Released under the MIT license.
  10044. * http://jquery.org/license
  10045. *
  10046. * http://api.jqueryui.com/shake-effect/
  10047. */
  10048. var effectShake = $.effects.effect.shake = function( o, done ) {
  10049. var el = $( this ),
  10050. props = [ "position", "top", "bottom", "left", "right", "height", "width" ],
  10051. mode = $.effects.setMode( el, o.mode || "effect" ),
  10052. direction = o.direction || "left",
  10053. distance = o.distance || 20,
  10054. times = o.times || 3,
  10055. anims = times * 2 + 1,
  10056. speed = Math.round( o.duration / anims ),
  10057. ref = (direction === "up" || direction === "down") ? "top" : "left",
  10058. positiveMotion = (direction === "up" || direction === "left"),
  10059. animation = {},
  10060. animation1 = {},
  10061. animation2 = {},
  10062. i,
  10063. // we will need to re-assemble the queue to stack our animations in place
  10064. queue = el.queue(),
  10065. queuelen = queue.length;
  10066. $.effects.save( el, props );
  10067. el.show();
  10068. $.effects.createWrapper( el );
  10069. // Animation
  10070. animation[ ref ] = ( positiveMotion ? "-=" : "+=" ) + distance;
  10071. animation1[ ref ] = ( positiveMotion ? "+=" : "-=" ) + distance * 2;
  10072. animation2[ ref ] = ( positiveMotion ? "-=" : "+=" ) + distance * 2;
  10073. // Animate
  10074. el.animate( animation, speed, o.easing );
  10075. // Shakes
  10076. for ( i = 1; i < times; i++ ) {
  10077. el.animate( animation1, speed, o.easing ).animate( animation2, speed, o.easing );
  10078. }
  10079. el
  10080. .animate( animation1, speed, o.easing )
  10081. .animate( animation, speed / 2, o.easing )
  10082. .queue(function() {
  10083. if ( mode === "hide" ) {
  10084. el.hide();
  10085. }
  10086. $.effects.restore( el, props );
  10087. $.effects.removeWrapper( el );
  10088. done();
  10089. });
  10090. // inject all the animations we just queued to be first in line (after "inprogress")
  10091. if ( queuelen > 1) {
  10092. queue.splice.apply( queue,
  10093. [ 1, 0 ].concat( queue.splice( queuelen, anims + 1 ) ) );
  10094. }
  10095. el.dequeue();
  10096. };
  10097. /*!
  10098. * jQuery UI Effects Slide 1.11.2
  10099. * http://jqueryui.com
  10100. *
  10101. * Copyright 2014 jQuery Foundation and other contributors
  10102. * Released under the MIT license.
  10103. * http://jquery.org/license
  10104. *
  10105. * http://api.jqueryui.com/slide-effect/
  10106. */
  10107. var effectSlide = $.effects.effect.slide = function( o, done ) {
  10108. // Create element
  10109. var el = $( this ),
  10110. props = [ "position", "top", "bottom", "left", "right", "width", "height" ],
  10111. mode = $.effects.setMode( el, o.mode || "show" ),
  10112. show = mode === "show",
  10113. direction = o.direction || "left",
  10114. ref = (direction === "up" || direction === "down") ? "top" : "left",
  10115. positiveMotion = (direction === "up" || direction === "left"),
  10116. distance,
  10117. animation = {};
  10118. // Adjust
  10119. $.effects.save( el, props );
  10120. el.show();
  10121. distance = o.distance || el[ ref === "top" ? "outerHeight" : "outerWidth" ]( true );
  10122. $.effects.createWrapper( el ).css({
  10123. overflow: "hidden"
  10124. });
  10125. if ( show ) {
  10126. el.css( ref, positiveMotion ? (isNaN(distance) ? "-" + distance : -distance) : distance );
  10127. }
  10128. // Animation
  10129. animation[ ref ] = ( show ?
  10130. ( positiveMotion ? "+=" : "-=") :
  10131. ( positiveMotion ? "-=" : "+=")) +
  10132. distance;
  10133. // Animate
  10134. el.animate( animation, {
  10135. queue: false,
  10136. duration: o.duration,
  10137. easing: o.easing,
  10138. complete: function() {
  10139. if ( mode === "hide" ) {
  10140. el.hide();
  10141. }
  10142. $.effects.restore( el, props );
  10143. $.effects.removeWrapper( el );
  10144. done();
  10145. }
  10146. });
  10147. };
  10148. /*!
  10149. * jQuery UI Effects Transfer 1.11.2
  10150. * http://jqueryui.com
  10151. *
  10152. * Copyright 2014 jQuery Foundation and other contributors
  10153. * Released under the MIT license.
  10154. * http://jquery.org/license
  10155. *
  10156. * http://api.jqueryui.com/transfer-effect/
  10157. */
  10158. var effectTransfer = $.effects.effect.transfer = function( o, done ) {
  10159. var elem = $( this ),
  10160. target = $( o.to ),
  10161. targetFixed = target.css( "position" ) === "fixed",
  10162. body = $("body"),
  10163. fixTop = targetFixed ? body.scrollTop() : 0,
  10164. fixLeft = targetFixed ? body.scrollLeft() : 0,
  10165. endPosition = target.offset(),
  10166. animation = {
  10167. top: endPosition.top - fixTop,
  10168. left: endPosition.left - fixLeft,
  10169. height: target.innerHeight(),
  10170. width: target.innerWidth()
  10171. },
  10172. startPosition = elem.offset(),
  10173. transfer = $( "<div class='ui-effects-transfer'></div>" )
  10174. .appendTo( document.body )
  10175. .addClass( o.className )
  10176. .css({
  10177. top: startPosition.top - fixTop,
  10178. left: startPosition.left - fixLeft,
  10179. height: elem.innerHeight(),
  10180. width: elem.innerWidth(),
  10181. position: targetFixed ? "fixed" : "absolute"
  10182. })
  10183. .animate( animation, o.duration, o.easing, function() {
  10184. transfer.remove();
  10185. done();
  10186. });
  10187. };
  10188. /*!
  10189. * jQuery UI Progressbar 1.11.2
  10190. * http://jqueryui.com
  10191. *
  10192. * Copyright 2014 jQuery Foundation and other contributors
  10193. * Released under the MIT license.
  10194. * http://jquery.org/license
  10195. *
  10196. * http://api.jqueryui.com/progressbar/
  10197. */
  10198. var progressbar = $.widget( "ui.progressbar", {
  10199. version: "1.11.2",
  10200. options: {
  10201. max: 100,
  10202. value: 0,
  10203. change: null,
  10204. complete: null
  10205. },
  10206. min: 0,
  10207. _create: function() {
  10208. // Constrain initial value
  10209. this.oldValue = this.options.value = this._constrainedValue();
  10210. this.element
  10211. .addClass( "ui-progressbar ui-widget ui-widget-content ui-corner-all" )
  10212. .attr({
  10213. // Only set static values, aria-valuenow and aria-valuemax are
  10214. // set inside _refreshValue()
  10215. role: "progressbar",
  10216. "aria-valuemin": this.min
  10217. });
  10218. this.valueDiv = $( "<div class='ui-progressbar-value ui-widget-header ui-corner-left'></div>" )
  10219. .appendTo( this.element );
  10220. this._refreshValue();
  10221. },
  10222. _destroy: function() {
  10223. this.element
  10224. .removeClass( "ui-progressbar ui-widget ui-widget-content ui-corner-all" )
  10225. .removeAttr( "role" )
  10226. .removeAttr( "aria-valuemin" )
  10227. .removeAttr( "aria-valuemax" )
  10228. .removeAttr( "aria-valuenow" );
  10229. this.valueDiv.remove();
  10230. },
  10231. value: function( newValue ) {
  10232. if ( newValue === undefined ) {
  10233. return this.options.value;
  10234. }
  10235. this.options.value = this._constrainedValue( newValue );
  10236. this._refreshValue();
  10237. },
  10238. _constrainedValue: function( newValue ) {
  10239. if ( newValue === undefined ) {
  10240. newValue = this.options.value;
  10241. }
  10242. this.indeterminate = newValue === false;
  10243. // sanitize value
  10244. if ( typeof newValue !== "number" ) {
  10245. newValue = 0;
  10246. }
  10247. return this.indeterminate ? false :
  10248. Math.min( this.options.max, Math.max( this.min, newValue ) );
  10249. },
  10250. _setOptions: function( options ) {
  10251. // Ensure "value" option is set after other values (like max)
  10252. var value = options.value;
  10253. delete options.value;
  10254. this._super( options );
  10255. this.options.value = this._constrainedValue( value );
  10256. this._refreshValue();
  10257. },
  10258. _setOption: function( key, value ) {
  10259. if ( key === "max" ) {
  10260. // Don't allow a max less than min
  10261. value = Math.max( this.min, value );
  10262. }
  10263. if ( key === "disabled" ) {
  10264. this.element
  10265. .toggleClass( "ui-state-disabled", !!value )
  10266. .attr( "aria-disabled", value );
  10267. }
  10268. this._super( key, value );
  10269. },
  10270. _percentage: function() {
  10271. return this.indeterminate ? 100 : 100 * ( this.options.value - this.min ) / ( this.options.max - this.min );
  10272. },
  10273. _refreshValue: function() {
  10274. var value = this.options.value,
  10275. percentage = this._percentage();
  10276. this.valueDiv
  10277. .toggle( this.indeterminate || value > this.min )
  10278. .toggleClass( "ui-corner-right", value === this.options.max )
  10279. .width( percentage.toFixed(0) + "%" );
  10280. this.element.toggleClass( "ui-progressbar-indeterminate", this.indeterminate );
  10281. if ( this.indeterminate ) {
  10282. this.element.removeAttr( "aria-valuenow" );
  10283. if ( !this.overlayDiv ) {
  10284. this.overlayDiv = $( "<div class='ui-progressbar-overlay'></div>" ).appendTo( this.valueDiv );
  10285. }
  10286. } else {
  10287. this.element.attr({
  10288. "aria-valuemax": this.options.max,
  10289. "aria-valuenow": value
  10290. });
  10291. if ( this.overlayDiv ) {
  10292. this.overlayDiv.remove();
  10293. this.overlayDiv = null;
  10294. }
  10295. }
  10296. if ( this.oldValue !== value ) {
  10297. this.oldValue = value;
  10298. this._trigger( "change" );
  10299. }
  10300. if ( value === this.options.max ) {
  10301. this._trigger( "complete" );
  10302. }
  10303. }
  10304. });
  10305. /*!
  10306. * jQuery UI Selectable 1.11.2
  10307. * http://jqueryui.com
  10308. *
  10309. * Copyright 2014 jQuery Foundation and other contributors
  10310. * Released under the MIT license.
  10311. * http://jquery.org/license
  10312. *
  10313. * http://api.jqueryui.com/selectable/
  10314. */
  10315. var selectable = $.widget("ui.selectable", $.ui.mouse, {
  10316. version: "1.11.2",
  10317. options: {
  10318. appendTo: "body",
  10319. autoRefresh: true,
  10320. distance: 0,
  10321. filter: "*",
  10322. tolerance: "touch",
  10323. // callbacks
  10324. selected: null,
  10325. selecting: null,
  10326. start: null,
  10327. stop: null,
  10328. unselected: null,
  10329. unselecting: null
  10330. },
  10331. _create: function() {
  10332. var selectees,
  10333. that = this;
  10334. this.element.addClass("ui-selectable");
  10335. this.dragged = false;
  10336. // cache selectee children based on filter
  10337. this.refresh = function() {
  10338. selectees = $(that.options.filter, that.element[0]);
  10339. selectees.addClass("ui-selectee");
  10340. selectees.each(function() {
  10341. var $this = $(this),
  10342. pos = $this.offset();
  10343. $.data(this, "selectable-item", {
  10344. element: this,
  10345. $element: $this,
  10346. left: pos.left,
  10347. top: pos.top,
  10348. right: pos.left + $this.outerWidth(),
  10349. bottom: pos.top + $this.outerHeight(),
  10350. startselected: false,
  10351. selected: $this.hasClass("ui-selected"),
  10352. selecting: $this.hasClass("ui-selecting"),
  10353. unselecting: $this.hasClass("ui-unselecting")
  10354. });
  10355. });
  10356. };
  10357. this.refresh();
  10358. this.selectees = selectees.addClass("ui-selectee");
  10359. this._mouseInit();
  10360. this.helper = $("<div class='ui-selectable-helper'></div>");
  10361. },
  10362. _destroy: function() {
  10363. this.selectees
  10364. .removeClass("ui-selectee")
  10365. .removeData("selectable-item");
  10366. this.element
  10367. .removeClass("ui-selectable ui-selectable-disabled");
  10368. this._mouseDestroy();
  10369. },
  10370. _mouseStart: function(event) {
  10371. var that = this,
  10372. options = this.options;
  10373. this.opos = [ event.pageX, event.pageY ];
  10374. if (this.options.disabled) {
  10375. return;
  10376. }
  10377. this.selectees = $(options.filter, this.element[0]);
  10378. this._trigger("start", event);
  10379. $(options.appendTo).append(this.helper);
  10380. // position helper (lasso)
  10381. this.helper.css({
  10382. "left": event.pageX,
  10383. "top": event.pageY,
  10384. "width": 0,
  10385. "height": 0
  10386. });
  10387. if (options.autoRefresh) {
  10388. this.refresh();
  10389. }
  10390. this.selectees.filter(".ui-selected").each(function() {
  10391. var selectee = $.data(this, "selectable-item");
  10392. selectee.startselected = true;
  10393. if (!event.metaKey && !event.ctrlKey) {
  10394. selectee.$element.removeClass("ui-selected");
  10395. selectee.selected = false;
  10396. selectee.$element.addClass("ui-unselecting");
  10397. selectee.unselecting = true;
  10398. // selectable UNSELECTING callback
  10399. that._trigger("unselecting", event, {
  10400. unselecting: selectee.element
  10401. });
  10402. }
  10403. });
  10404. $(event.target).parents().addBack().each(function() {
  10405. var doSelect,
  10406. selectee = $.data(this, "selectable-item");
  10407. if (selectee) {
  10408. doSelect = (!event.metaKey && !event.ctrlKey) || !selectee.$element.hasClass("ui-selected");
  10409. selectee.$element
  10410. .removeClass(doSelect ? "ui-unselecting" : "ui-selected")
  10411. .addClass(doSelect ? "ui-selecting" : "ui-unselecting");
  10412. selectee.unselecting = !doSelect;
  10413. selectee.selecting = doSelect;
  10414. selectee.selected = doSelect;
  10415. // selectable (UN)SELECTING callback
  10416. if (doSelect) {
  10417. that._trigger("selecting", event, {
  10418. selecting: selectee.element
  10419. });
  10420. } else {
  10421. that._trigger("unselecting", event, {
  10422. unselecting: selectee.element
  10423. });
  10424. }
  10425. return false;
  10426. }
  10427. });
  10428. },
  10429. _mouseDrag: function(event) {
  10430. this.dragged = true;
  10431. if (this.options.disabled) {
  10432. return;
  10433. }
  10434. var tmp,
  10435. that = this,
  10436. options = this.options,
  10437. x1 = this.opos[0],
  10438. y1 = this.opos[1],
  10439. x2 = event.pageX,
  10440. y2 = event.pageY;
  10441. if (x1 > x2) { tmp = x2; x2 = x1; x1 = tmp; }
  10442. if (y1 > y2) { tmp = y2; y2 = y1; y1 = tmp; }
  10443. this.helper.css({ left: x1, top: y1, width: x2 - x1, height: y2 - y1 });
  10444. this.selectees.each(function() {
  10445. var selectee = $.data(this, "selectable-item"),
  10446. hit = false;
  10447. //prevent helper from being selected if appendTo: selectable
  10448. if (!selectee || selectee.element === that.element[0]) {
  10449. return;
  10450. }
  10451. if (options.tolerance === "touch") {
  10452. hit = ( !(selectee.left > x2 || selectee.right < x1 || selectee.top > y2 || selectee.bottom < y1) );
  10453. } else if (options.tolerance === "fit") {
  10454. hit = (selectee.left > x1 && selectee.right < x2 && selectee.top > y1 && selectee.bottom < y2);
  10455. }
  10456. if (hit) {
  10457. // SELECT
  10458. if (selectee.selected) {
  10459. selectee.$element.removeClass("ui-selected");
  10460. selectee.selected = false;
  10461. }
  10462. if (selectee.unselecting) {
  10463. selectee.$element.removeClass("ui-unselecting");
  10464. selectee.unselecting = false;
  10465. }
  10466. if (!selectee.selecting) {
  10467. selectee.$element.addClass("ui-selecting");
  10468. selectee.selecting = true;
  10469. // selectable SELECTING callback
  10470. that._trigger("selecting", event, {
  10471. selecting: selectee.element
  10472. });
  10473. }
  10474. } else {
  10475. // UNSELECT
  10476. if (selectee.selecting) {
  10477. if ((event.metaKey || event.ctrlKey) && selectee.startselected) {
  10478. selectee.$element.removeClass("ui-selecting");
  10479. selectee.selecting = false;
  10480. selectee.$element.addClass("ui-selected");
  10481. selectee.selected = true;
  10482. } else {
  10483. selectee.$element.removeClass("ui-selecting");
  10484. selectee.selecting = false;
  10485. if (selectee.startselected) {
  10486. selectee.$element.addClass("ui-unselecting");
  10487. selectee.unselecting = true;
  10488. }
  10489. // selectable UNSELECTING callback
  10490. that._trigger("unselecting", event, {
  10491. unselecting: selectee.element
  10492. });
  10493. }
  10494. }
  10495. if (selectee.selected) {
  10496. if (!event.metaKey && !event.ctrlKey && !selectee.startselected) {
  10497. selectee.$element.removeClass("ui-selected");
  10498. selectee.selected = false;
  10499. selectee.$element.addClass("ui-unselecting");
  10500. selectee.unselecting = true;
  10501. // selectable UNSELECTING callback
  10502. that._trigger("unselecting", event, {
  10503. unselecting: selectee.element
  10504. });
  10505. }
  10506. }
  10507. }
  10508. });
  10509. return false;
  10510. },
  10511. _mouseStop: function(event) {
  10512. var that = this;
  10513. this.dragged = false;
  10514. $(".ui-unselecting", this.element[0]).each(function() {
  10515. var selectee = $.data(this, "selectable-item");
  10516. selectee.$element.removeClass("ui-unselecting");
  10517. selectee.unselecting = false;
  10518. selectee.startselected = false;
  10519. that._trigger("unselected", event, {
  10520. unselected: selectee.element
  10521. });
  10522. });
  10523. $(".ui-selecting", this.element[0]).each(function() {
  10524. var selectee = $.data(this, "selectable-item");
  10525. selectee.$element.removeClass("ui-selecting").addClass("ui-selected");
  10526. selectee.selecting = false;
  10527. selectee.selected = true;
  10528. selectee.startselected = true;
  10529. that._trigger("selected", event, {
  10530. selected: selectee.element
  10531. });
  10532. });
  10533. this._trigger("stop", event);
  10534. this.helper.remove();
  10535. return false;
  10536. }
  10537. });
  10538. /*!
  10539. * jQuery UI Selectmenu 1.11.2
  10540. * http://jqueryui.com
  10541. *
  10542. * Copyright 2014 jQuery Foundation and other contributors
  10543. * Released under the MIT license.
  10544. * http://jquery.org/license
  10545. *
  10546. * http://api.jqueryui.com/selectmenu
  10547. */
  10548. var selectmenu = $.widget( "ui.selectmenu", {
  10549. version: "1.11.2",
  10550. defaultElement: "<select>",
  10551. options: {
  10552. appendTo: null,
  10553. disabled: null,
  10554. icons: {
  10555. button: "ui-icon-triangle-1-s"
  10556. },
  10557. position: {
  10558. my: "left top",
  10559. at: "left bottom",
  10560. collision: "none"
  10561. },
  10562. width: null,
  10563. // callbacks
  10564. change: null,
  10565. close: null,
  10566. focus: null,
  10567. open: null,
  10568. select: null
  10569. },
  10570. _create: function() {
  10571. var selectmenuId = this.element.uniqueId().attr( "id" );
  10572. this.ids = {
  10573. element: selectmenuId,
  10574. button: selectmenuId + "-button",
  10575. menu: selectmenuId + "-menu"
  10576. };
  10577. this._drawButton();
  10578. this._drawMenu();
  10579. if ( this.options.disabled ) {
  10580. this.disable();
  10581. }
  10582. },
  10583. _drawButton: function() {
  10584. var that = this,
  10585. tabindex = this.element.attr( "tabindex" );
  10586. // Associate existing label with the new button
  10587. this.label = $( "label[for='" + this.ids.element + "']" ).attr( "for", this.ids.button );
  10588. this._on( this.label, {
  10589. click: function( event ) {
  10590. this.button.focus();
  10591. event.preventDefault();
  10592. }
  10593. });
  10594. // Hide original select element
  10595. this.element.hide();
  10596. // Create button
  10597. this.button = $( "<span>", {
  10598. "class": "ui-selectmenu-button ui-widget ui-state-default ui-corner-all",
  10599. tabindex: tabindex || this.options.disabled ? -1 : 0,
  10600. id: this.ids.button,
  10601. role: "combobox",
  10602. "aria-expanded": "false",
  10603. "aria-autocomplete": "list",
  10604. "aria-owns": this.ids.menu,
  10605. "aria-haspopup": "true"
  10606. })
  10607. .insertAfter( this.element );
  10608. $( "<span>", {
  10609. "class": "ui-icon " + this.options.icons.button
  10610. })
  10611. .prependTo( this.button );
  10612. this.buttonText = $( "<span>", {
  10613. "class": "ui-selectmenu-text"
  10614. })
  10615. .appendTo( this.button );
  10616. this._setText( this.buttonText, this.element.find( "option:selected" ).text() );
  10617. this._resizeButton();
  10618. this._on( this.button, this._buttonEvents );
  10619. this.button.one( "focusin", function() {
  10620. // Delay rendering the menu items until the button receives focus.
  10621. // The menu may have already been rendered via a programmatic open.
  10622. if ( !that.menuItems ) {
  10623. that._refreshMenu();
  10624. }
  10625. });
  10626. this._hoverable( this.button );
  10627. this._focusable( this.button );
  10628. },
  10629. _drawMenu: function() {
  10630. var that = this;
  10631. // Create menu
  10632. this.menu = $( "<ul>", {
  10633. "aria-hidden": "true",
  10634. "aria-labelledby": this.ids.button,
  10635. id: this.ids.menu
  10636. });
  10637. // Wrap menu
  10638. this.menuWrap = $( "<div>", {
  10639. "class": "ui-selectmenu-menu ui-front"
  10640. })
  10641. .append( this.menu )
  10642. .appendTo( this._appendTo() );
  10643. // Initialize menu widget
  10644. this.menuInstance = this.menu
  10645. .menu({
  10646. role: "listbox",
  10647. select: function( event, ui ) {
  10648. event.preventDefault();
  10649. // support: IE8
  10650. // If the item was selected via a click, the text selection
  10651. // will be destroyed in IE
  10652. that._setSelection();
  10653. that._select( ui.item.data( "ui-selectmenu-item" ), event );
  10654. },
  10655. focus: function( event, ui ) {
  10656. var item = ui.item.data( "ui-selectmenu-item" );
  10657. // Prevent inital focus from firing and check if its a newly focused item
  10658. if ( that.focusIndex != null && item.index !== that.focusIndex ) {
  10659. that._trigger( "focus", event, { item: item } );
  10660. if ( !that.isOpen ) {
  10661. that._select( item, event );
  10662. }
  10663. }
  10664. that.focusIndex = item.index;
  10665. that.button.attr( "aria-activedescendant",
  10666. that.menuItems.eq( item.index ).attr( "id" ) );
  10667. }
  10668. })
  10669. .menu( "instance" );
  10670. // Adjust menu styles to dropdown
  10671. this.menu
  10672. .addClass( "ui-corner-bottom" )
  10673. .removeClass( "ui-corner-all" );
  10674. // Don't close the menu on mouseleave
  10675. this.menuInstance._off( this.menu, "mouseleave" );
  10676. // Cancel the menu's collapseAll on document click
  10677. this.menuInstance._closeOnDocumentClick = function() {
  10678. return false;
  10679. };
  10680. // Selects often contain empty items, but never contain dividers
  10681. this.menuInstance._isDivider = function() {
  10682. return false;
  10683. };
  10684. },
  10685. refresh: function() {
  10686. this._refreshMenu();
  10687. this._setText( this.buttonText, this._getSelectedItem().text() );
  10688. if ( !this.options.width ) {
  10689. this._resizeButton();
  10690. }
  10691. },
  10692. _refreshMenu: function() {
  10693. this.menu.empty();
  10694. var item,
  10695. options = this.element.find( "option" );
  10696. if ( !options.length ) {
  10697. return;
  10698. }
  10699. this._parseOptions( options );
  10700. this._renderMenu( this.menu, this.items );
  10701. this.menuInstance.refresh();
  10702. this.menuItems = this.menu.find( "li" ).not( ".ui-selectmenu-optgroup" );
  10703. item = this._getSelectedItem();
  10704. // Update the menu to have the correct item focused
  10705. this.menuInstance.focus( null, item );
  10706. this._setAria( item.data( "ui-selectmenu-item" ) );
  10707. // Set disabled state
  10708. this._setOption( "disabled", this.element.prop( "disabled" ) );
  10709. },
  10710. open: function( event ) {
  10711. if ( this.options.disabled ) {
  10712. return;
  10713. }
  10714. // If this is the first time the menu is being opened, render the items
  10715. if ( !this.menuItems ) {
  10716. this._refreshMenu();
  10717. } else {
  10718. // Menu clears focus on close, reset focus to selected item
  10719. this.menu.find( ".ui-state-focus" ).removeClass( "ui-state-focus" );
  10720. this.menuInstance.focus( null, this._getSelectedItem() );
  10721. }
  10722. this.isOpen = true;
  10723. this._toggleAttr();
  10724. this._resizeMenu();
  10725. this._position();
  10726. this._on( this.document, this._documentClick );
  10727. this._trigger( "open", event );
  10728. },
  10729. _position: function() {
  10730. this.menuWrap.position( $.extend( { of: this.button }, this.options.position ) );
  10731. },
  10732. close: function( event ) {
  10733. if ( !this.isOpen ) {
  10734. return;
  10735. }
  10736. this.isOpen = false;
  10737. this._toggleAttr();
  10738. this.range = null;
  10739. this._off( this.document );
  10740. this._trigger( "close", event );
  10741. },
  10742. widget: function() {
  10743. return this.button;
  10744. },
  10745. menuWidget: function() {
  10746. return this.menu;
  10747. },
  10748. _renderMenu: function( ul, items ) {
  10749. var that = this,
  10750. currentOptgroup = "";
  10751. $.each( items, function( index, item ) {
  10752. if ( item.optgroup !== currentOptgroup ) {
  10753. $( "<li>", {
  10754. "class": "ui-selectmenu-optgroup ui-menu-divider" +
  10755. ( item.element.parent( "optgroup" ).prop( "disabled" ) ?
  10756. " ui-state-disabled" :
  10757. "" ),
  10758. text: item.optgroup
  10759. })
  10760. .appendTo( ul );
  10761. currentOptgroup = item.optgroup;
  10762. }
  10763. that._renderItemData( ul, item );
  10764. });
  10765. },
  10766. _renderItemData: function( ul, item ) {
  10767. return this._renderItem( ul, item ).data( "ui-selectmenu-item", item );
  10768. },
  10769. _renderItem: function( ul, item ) {
  10770. var li = $( "<li>" );
  10771. if ( item.disabled ) {
  10772. li.addClass( "ui-state-disabled" );
  10773. }
  10774. this._setText( li, item.label );
  10775. return li.appendTo( ul );
  10776. },
  10777. _setText: function( element, value ) {
  10778. if ( value ) {
  10779. element.text( value );
  10780. } else {
  10781. element.html( "&#160;" );
  10782. }
  10783. },
  10784. _move: function( direction, event ) {
  10785. var item, next,
  10786. filter = ".ui-menu-item";
  10787. if ( this.isOpen ) {
  10788. item = this.menuItems.eq( this.focusIndex );
  10789. } else {
  10790. item = this.menuItems.eq( this.element[ 0 ].selectedIndex );
  10791. filter += ":not(.ui-state-disabled)";
  10792. }
  10793. if ( direction === "first" || direction === "last" ) {
  10794. next = item[ direction === "first" ? "prevAll" : "nextAll" ]( filter ).eq( -1 );
  10795. } else {
  10796. next = item[ direction + "All" ]( filter ).eq( 0 );
  10797. }
  10798. if ( next.length ) {
  10799. this.menuInstance.focus( event, next );
  10800. }
  10801. },
  10802. _getSelectedItem: function() {
  10803. return this.menuItems.eq( this.element[ 0 ].selectedIndex );
  10804. },
  10805. _toggle: function( event ) {
  10806. this[ this.isOpen ? "close" : "open" ]( event );
  10807. },
  10808. _setSelection: function() {
  10809. var selection;
  10810. if ( !this.range ) {
  10811. return;
  10812. }
  10813. if ( window.getSelection ) {
  10814. selection = window.getSelection();
  10815. selection.removeAllRanges();
  10816. selection.addRange( this.range );
  10817. // support: IE8
  10818. } else {
  10819. this.range.select();
  10820. }
  10821. // support: IE
  10822. // Setting the text selection kills the button focus in IE, but
  10823. // restoring the focus doesn't kill the selection.
  10824. this.button.focus();
  10825. },
  10826. _documentClick: {
  10827. mousedown: function( event ) {
  10828. if ( !this.isOpen ) {
  10829. return;
  10830. }
  10831. if ( !$( event.target ).closest( ".ui-selectmenu-menu, #" + this.ids.button ).length ) {
  10832. this.close( event );
  10833. }
  10834. }
  10835. },
  10836. _buttonEvents: {
  10837. // Prevent text selection from being reset when interacting with the selectmenu (#10144)
  10838. mousedown: function() {
  10839. var selection;
  10840. if ( window.getSelection ) {
  10841. selection = window.getSelection();
  10842. if ( selection.rangeCount ) {
  10843. this.range = selection.getRangeAt( 0 );
  10844. }
  10845. // support: IE8
  10846. } else {
  10847. this.range = document.selection.createRange();
  10848. }
  10849. },
  10850. click: function( event ) {
  10851. this._setSelection();
  10852. this._toggle( event );
  10853. },
  10854. keydown: function( event ) {
  10855. var preventDefault = true;
  10856. switch ( event.keyCode ) {
  10857. case $.ui.keyCode.TAB:
  10858. case $.ui.keyCode.ESCAPE:
  10859. this.close( event );
  10860. preventDefault = false;
  10861. break;
  10862. case $.ui.keyCode.ENTER:
  10863. if ( this.isOpen ) {
  10864. this._selectFocusedItem( event );
  10865. }
  10866. break;
  10867. case $.ui.keyCode.UP:
  10868. if ( event.altKey ) {
  10869. this._toggle( event );
  10870. } else {
  10871. this._move( "prev", event );
  10872. }
  10873. break;
  10874. case $.ui.keyCode.DOWN:
  10875. if ( event.altKey ) {
  10876. this._toggle( event );
  10877. } else {
  10878. this._move( "next", event );
  10879. }
  10880. break;
  10881. case $.ui.keyCode.SPACE:
  10882. if ( this.isOpen ) {
  10883. this._selectFocusedItem( event );
  10884. } else {
  10885. this._toggle( event );
  10886. }
  10887. break;
  10888. case $.ui.keyCode.LEFT:
  10889. this._move( "prev", event );
  10890. break;
  10891. case $.ui.keyCode.RIGHT:
  10892. this._move( "next", event );
  10893. break;
  10894. case $.ui.keyCode.HOME:
  10895. case $.ui.keyCode.PAGE_UP:
  10896. this._move( "first", event );
  10897. break;
  10898. case $.ui.keyCode.END:
  10899. case $.ui.keyCode.PAGE_DOWN:
  10900. this._move( "last", event );
  10901. break;
  10902. default:
  10903. this.menu.trigger( event );
  10904. preventDefault = false;
  10905. }
  10906. if ( preventDefault ) {
  10907. event.preventDefault();
  10908. }
  10909. }
  10910. },
  10911. _selectFocusedItem: function( event ) {
  10912. var item = this.menuItems.eq( this.focusIndex );
  10913. if ( !item.hasClass( "ui-state-disabled" ) ) {
  10914. this._select( item.data( "ui-selectmenu-item" ), event );
  10915. }
  10916. },
  10917. _select: function( item, event ) {
  10918. var oldIndex = this.element[ 0 ].selectedIndex;
  10919. // Change native select element
  10920. this.element[ 0 ].selectedIndex = item.index;
  10921. this._setText( this.buttonText, item.label );
  10922. this._setAria( item );
  10923. this._trigger( "select", event, { item: item } );
  10924. if ( item.index !== oldIndex ) {
  10925. this._trigger( "change", event, { item: item } );
  10926. }
  10927. this.close( event );
  10928. },
  10929. _setAria: function( item ) {
  10930. var id = this.menuItems.eq( item.index ).attr( "id" );
  10931. this.button.attr({
  10932. "aria-labelledby": id,
  10933. "aria-activedescendant": id
  10934. });
  10935. this.menu.attr( "aria-activedescendant", id );
  10936. },
  10937. _setOption: function( key, value ) {
  10938. if ( key === "icons" ) {
  10939. this.button.find( "span.ui-icon" )
  10940. .removeClass( this.options.icons.button )
  10941. .addClass( value.button );
  10942. }
  10943. this._super( key, value );
  10944. if ( key === "appendTo" ) {
  10945. this.menuWrap.appendTo( this._appendTo() );
  10946. }
  10947. if ( key === "disabled" ) {
  10948. this.menuInstance.option( "disabled", value );
  10949. this.button
  10950. .toggleClass( "ui-state-disabled", value )
  10951. .attr( "aria-disabled", value );
  10952. this.element.prop( "disabled", value );
  10953. if ( value ) {
  10954. this.button.attr( "tabindex", -1 );
  10955. this.close();
  10956. } else {
  10957. this.button.attr( "tabindex", 0 );
  10958. }
  10959. }
  10960. if ( key === "width" ) {
  10961. this._resizeButton();
  10962. }
  10963. },
  10964. _appendTo: function() {
  10965. var element = this.options.appendTo;
  10966. if ( element ) {
  10967. element = element.jquery || element.nodeType ?
  10968. $( element ) :
  10969. this.document.find( element ).eq( 0 );
  10970. }
  10971. if ( !element || !element[ 0 ] ) {
  10972. element = this.element.closest( ".ui-front" );
  10973. }
  10974. if ( !element.length ) {
  10975. element = this.document[ 0 ].body;
  10976. }
  10977. return element;
  10978. },
  10979. _toggleAttr: function() {
  10980. this.button
  10981. .toggleClass( "ui-corner-top", this.isOpen )
  10982. .toggleClass( "ui-corner-all", !this.isOpen )
  10983. .attr( "aria-expanded", this.isOpen );
  10984. this.menuWrap.toggleClass( "ui-selectmenu-open", this.isOpen );
  10985. this.menu.attr( "aria-hidden", !this.isOpen );
  10986. },
  10987. _resizeButton: function() {
  10988. var width = this.options.width;
  10989. if ( !width ) {
  10990. width = this.element.show().outerWidth();
  10991. this.element.hide();
  10992. }
  10993. this.button.outerWidth( width );
  10994. },
  10995. _resizeMenu: function() {
  10996. this.menu.outerWidth( Math.max(
  10997. this.button.outerWidth(),
  10998. // support: IE10
  10999. // IE10 wraps long text (possibly a rounding bug)
  11000. // so we add 1px to avoid the wrapping
  11001. this.menu.width( "" ).outerWidth() + 1
  11002. ) );
  11003. },
  11004. _getCreateOptions: function() {
  11005. return { disabled: this.element.prop( "disabled" ) };
  11006. },
  11007. _parseOptions: function( options ) {
  11008. var data = [];
  11009. options.each(function( index, item ) {
  11010. var option = $( item ),
  11011. optgroup = option.parent( "optgroup" );
  11012. data.push({
  11013. element: option,
  11014. index: index,
  11015. value: option.attr( "value" ),
  11016. label: option.text(),
  11017. optgroup: optgroup.attr( "label" ) || "",
  11018. disabled: optgroup.prop( "disabled" ) || option.prop( "disabled" )
  11019. });
  11020. });
  11021. this.items = data;
  11022. },
  11023. _destroy: function() {
  11024. this.menuWrap.remove();
  11025. this.button.remove();
  11026. this.element.show();
  11027. this.element.removeUniqueId();
  11028. this.label.attr( "for", this.ids.element );
  11029. }
  11030. });
  11031. /*!
  11032. * jQuery UI Slider 1.11.2
  11033. * http://jqueryui.com
  11034. *
  11035. * Copyright 2014 jQuery Foundation and other contributors
  11036. * Released under the MIT license.
  11037. * http://jquery.org/license
  11038. *
  11039. * http://api.jqueryui.com/slider/
  11040. */
  11041. var slider = $.widget( "ui.slider", $.ui.mouse, {
  11042. version: "1.11.2",
  11043. widgetEventPrefix: "slide",
  11044. options: {
  11045. animate: false,
  11046. distance: 0,
  11047. max: 100,
  11048. min: 0,
  11049. orientation: "horizontal",
  11050. range: false,
  11051. step: 1,
  11052. value: 0,
  11053. values: null,
  11054. // callbacks
  11055. change: null,
  11056. slide: null,
  11057. start: null,
  11058. stop: null
  11059. },
  11060. // number of pages in a slider
  11061. // (how many times can you page up/down to go through the whole range)
  11062. numPages: 5,
  11063. _create: function() {
  11064. this._keySliding = false;
  11065. this._mouseSliding = false;
  11066. this._animateOff = true;
  11067. this._handleIndex = null;
  11068. this._detectOrientation();
  11069. this._mouseInit();
  11070. this._calculateNewMax();
  11071. this.element
  11072. .addClass( "ui-slider" +
  11073. " ui-slider-" + this.orientation +
  11074. " ui-widget" +
  11075. " ui-widget-content" +
  11076. " ui-corner-all");
  11077. this._refresh();
  11078. this._setOption( "disabled", this.options.disabled );
  11079. this._animateOff = false;
  11080. },
  11081. _refresh: function() {
  11082. this._createRange();
  11083. this._createHandles();
  11084. this._setupEvents();
  11085. this._refreshValue();
  11086. },
  11087. _createHandles: function() {
  11088. var i, handleCount,
  11089. options = this.options,
  11090. existingHandles = this.element.find( ".ui-slider-handle" ).addClass( "ui-state-default ui-corner-all" ),
  11091. handle = "<span class='ui-slider-handle ui-state-default ui-corner-all' tabindex='0'></span>",
  11092. handles = [];
  11093. handleCount = ( options.values && options.values.length ) || 1;
  11094. if ( existingHandles.length > handleCount ) {
  11095. existingHandles.slice( handleCount ).remove();
  11096. existingHandles = existingHandles.slice( 0, handleCount );
  11097. }
  11098. for ( i = existingHandles.length; i < handleCount; i++ ) {
  11099. handles.push( handle );
  11100. }
  11101. this.handles = existingHandles.add( $( handles.join( "" ) ).appendTo( this.element ) );
  11102. this.handle = this.handles.eq( 0 );
  11103. this.handles.each(function( i ) {
  11104. $( this ).data( "ui-slider-handle-index", i );
  11105. });
  11106. },
  11107. _createRange: function() {
  11108. var options = this.options,
  11109. classes = "";
  11110. if ( options.range ) {
  11111. if ( options.range === true ) {
  11112. if ( !options.values ) {
  11113. options.values = [ this._valueMin(), this._valueMin() ];
  11114. } else if ( options.values.length && options.values.length !== 2 ) {
  11115. options.values = [ options.values[0], options.values[0] ];
  11116. } else if ( $.isArray( options.values ) ) {
  11117. options.values = options.values.slice(0);
  11118. }
  11119. }
  11120. if ( !this.range || !this.range.length ) {
  11121. this.range = $( "<div></div>" )
  11122. .appendTo( this.element );
  11123. classes = "ui-slider-range" +
  11124. // note: this isn't the most fittingly semantic framework class for this element,
  11125. // but worked best visually with a variety of themes
  11126. " ui-widget-header ui-corner-all";
  11127. } else {
  11128. this.range.removeClass( "ui-slider-range-min ui-slider-range-max" )
  11129. // Handle range switching from true to min/max
  11130. .css({
  11131. "left": "",
  11132. "bottom": ""
  11133. });
  11134. }
  11135. this.range.addClass( classes +
  11136. ( ( options.range === "min" || options.range === "max" ) ? " ui-slider-range-" + options.range : "" ) );
  11137. } else {
  11138. if ( this.range ) {
  11139. this.range.remove();
  11140. }
  11141. this.range = null;
  11142. }
  11143. },
  11144. _setupEvents: function() {
  11145. this._off( this.handles );
  11146. this._on( this.handles, this._handleEvents );
  11147. this._hoverable( this.handles );
  11148. this._focusable( this.handles );
  11149. },
  11150. _destroy: function() {
  11151. this.handles.remove();
  11152. if ( this.range ) {
  11153. this.range.remove();
  11154. }
  11155. this.element
  11156. .removeClass( "ui-slider" +
  11157. " ui-slider-horizontal" +
  11158. " ui-slider-vertical" +
  11159. " ui-widget" +
  11160. " ui-widget-content" +
  11161. " ui-corner-all" );
  11162. this._mouseDestroy();
  11163. },
  11164. _mouseCapture: function( event ) {
  11165. var position, normValue, distance, closestHandle, index, allowed, offset, mouseOverHandle,
  11166. that = this,
  11167. o = this.options;
  11168. if ( o.disabled ) {
  11169. return false;
  11170. }
  11171. this.elementSize = {
  11172. width: this.element.outerWidth(),
  11173. height: this.element.outerHeight()
  11174. };
  11175. this.elementOffset = this.element.offset();
  11176. position = { x: event.pageX, y: event.pageY };
  11177. normValue = this._normValueFromMouse( position );
  11178. distance = this._valueMax() - this._valueMin() + 1;
  11179. this.handles.each(function( i ) {
  11180. var thisDistance = Math.abs( normValue - that.values(i) );
  11181. if (( distance > thisDistance ) ||
  11182. ( distance === thisDistance &&
  11183. (i === that._lastChangedValue || that.values(i) === o.min ))) {
  11184. distance = thisDistance;
  11185. closestHandle = $( this );
  11186. index = i;
  11187. }
  11188. });
  11189. allowed = this._start( event, index );
  11190. if ( allowed === false ) {
  11191. return false;
  11192. }
  11193. this._mouseSliding = true;
  11194. this._handleIndex = index;
  11195. closestHandle
  11196. .addClass( "ui-state-active" )
  11197. .focus();
  11198. offset = closestHandle.offset();
  11199. mouseOverHandle = !$( event.target ).parents().addBack().is( ".ui-slider-handle" );
  11200. this._clickOffset = mouseOverHandle ? { left: 0, top: 0 } : {
  11201. left: event.pageX - offset.left - ( closestHandle.width() / 2 ),
  11202. top: event.pageY - offset.top -
  11203. ( closestHandle.height() / 2 ) -
  11204. ( parseInt( closestHandle.css("borderTopWidth"), 10 ) || 0 ) -
  11205. ( parseInt( closestHandle.css("borderBottomWidth"), 10 ) || 0) +
  11206. ( parseInt( closestHandle.css("marginTop"), 10 ) || 0)
  11207. };
  11208. if ( !this.handles.hasClass( "ui-state-hover" ) ) {
  11209. this._slide( event, index, normValue );
  11210. }
  11211. this._animateOff = true;
  11212. return true;
  11213. },
  11214. _mouseStart: function() {
  11215. return true;
  11216. },
  11217. _mouseDrag: function( event ) {
  11218. var position = { x: event.pageX, y: event.pageY },
  11219. normValue = this._normValueFromMouse( position );
  11220. this._slide( event, this._handleIndex, normValue );
  11221. return false;
  11222. },
  11223. _mouseStop: function( event ) {
  11224. this.handles.removeClass( "ui-state-active" );
  11225. this._mouseSliding = false;
  11226. this._stop( event, this._handleIndex );
  11227. this._change( event, this._handleIndex );
  11228. this._handleIndex = null;
  11229. this._clickOffset = null;
  11230. this._animateOff = false;
  11231. return false;
  11232. },
  11233. _detectOrientation: function() {
  11234. this.orientation = ( this.options.orientation === "vertical" ) ? "vertical" : "horizontal";
  11235. },
  11236. _normValueFromMouse: function( position ) {
  11237. var pixelTotal,
  11238. pixelMouse,
  11239. percentMouse,
  11240. valueTotal,
  11241. valueMouse;
  11242. if ( this.orientation === "horizontal" ) {
  11243. pixelTotal = this.elementSize.width;
  11244. pixelMouse = position.x - this.elementOffset.left - ( this._clickOffset ? this._clickOffset.left : 0 );
  11245. } else {
  11246. pixelTotal = this.elementSize.height;
  11247. pixelMouse = position.y - this.elementOffset.top - ( this._clickOffset ? this._clickOffset.top : 0 );
  11248. }
  11249. percentMouse = ( pixelMouse / pixelTotal );
  11250. if ( percentMouse > 1 ) {
  11251. percentMouse = 1;
  11252. }
  11253. if ( percentMouse < 0 ) {
  11254. percentMouse = 0;
  11255. }
  11256. if ( this.orientation === "vertical" ) {
  11257. percentMouse = 1 - percentMouse;
  11258. }
  11259. valueTotal = this._valueMax() - this._valueMin();
  11260. valueMouse = this._valueMin() + percentMouse * valueTotal;
  11261. return this._trimAlignValue( valueMouse );
  11262. },
  11263. _start: function( event, index ) {
  11264. var uiHash = {
  11265. handle: this.handles[ index ],
  11266. value: this.value()
  11267. };
  11268. if ( this.options.values && this.options.values.length ) {
  11269. uiHash.value = this.values( index );
  11270. uiHash.values = this.values();
  11271. }
  11272. return this._trigger( "start", event, uiHash );
  11273. },
  11274. _slide: function( event, index, newVal ) {
  11275. var otherVal,
  11276. newValues,
  11277. allowed;
  11278. if ( this.options.values && this.options.values.length ) {
  11279. otherVal = this.values( index ? 0 : 1 );
  11280. if ( ( this.options.values.length === 2 && this.options.range === true ) &&
  11281. ( ( index === 0 && newVal > otherVal) || ( index === 1 && newVal < otherVal ) )
  11282. ) {
  11283. newVal = otherVal;
  11284. }
  11285. if ( newVal !== this.values( index ) ) {
  11286. newValues = this.values();
  11287. newValues[ index ] = newVal;
  11288. // A slide can be canceled by returning false from the slide callback
  11289. allowed = this._trigger( "slide", event, {
  11290. handle: this.handles[ index ],
  11291. value: newVal,
  11292. values: newValues
  11293. } );
  11294. otherVal = this.values( index ? 0 : 1 );
  11295. if ( allowed !== false ) {
  11296. this.values( index, newVal );
  11297. }
  11298. }
  11299. } else {
  11300. if ( newVal !== this.value() ) {
  11301. // A slide can be canceled by returning false from the slide callback
  11302. allowed = this._trigger( "slide", event, {
  11303. handle: this.handles[ index ],
  11304. value: newVal
  11305. } );
  11306. if ( allowed !== false ) {
  11307. this.value( newVal );
  11308. }
  11309. }
  11310. }
  11311. },
  11312. _stop: function( event, index ) {
  11313. var uiHash = {
  11314. handle: this.handles[ index ],
  11315. value: this.value()
  11316. };
  11317. if ( this.options.values && this.options.values.length ) {
  11318. uiHash.value = this.values( index );
  11319. uiHash.values = this.values();
  11320. }
  11321. this._trigger( "stop", event, uiHash );
  11322. },
  11323. _change: function( event, index ) {
  11324. if ( !this._keySliding && !this._mouseSliding ) {
  11325. var uiHash = {
  11326. handle: this.handles[ index ],
  11327. value: this.value()
  11328. };
  11329. if ( this.options.values && this.options.values.length ) {
  11330. uiHash.value = this.values( index );
  11331. uiHash.values = this.values();
  11332. }
  11333. //store the last changed value index for reference when handles overlap
  11334. this._lastChangedValue = index;
  11335. this._trigger( "change", event, uiHash );
  11336. }
  11337. },
  11338. value: function( newValue ) {
  11339. if ( arguments.length ) {
  11340. this.options.value = this._trimAlignValue( newValue );
  11341. this._refreshValue();
  11342. this._change( null, 0 );
  11343. return;
  11344. }
  11345. return this._value();
  11346. },
  11347. values: function( index, newValue ) {
  11348. var vals,
  11349. newValues,
  11350. i;
  11351. if ( arguments.length > 1 ) {
  11352. this.options.values[ index ] = this._trimAlignValue( newValue );
  11353. this._refreshValue();
  11354. this._change( null, index );
  11355. return;
  11356. }
  11357. if ( arguments.length ) {
  11358. if ( $.isArray( arguments[ 0 ] ) ) {
  11359. vals = this.options.values;
  11360. newValues = arguments[ 0 ];
  11361. for ( i = 0; i < vals.length; i += 1 ) {
  11362. vals[ i ] = this._trimAlignValue( newValues[ i ] );
  11363. this._change( null, i );
  11364. }
  11365. this._refreshValue();
  11366. } else {
  11367. if ( this.options.values && this.options.values.length ) {
  11368. return this._values( index );
  11369. } else {
  11370. return this.value();
  11371. }
  11372. }
  11373. } else {
  11374. return this._values();
  11375. }
  11376. },
  11377. _setOption: function( key, value ) {
  11378. var i,
  11379. valsLength = 0;
  11380. if ( key === "range" && this.options.range === true ) {
  11381. if ( value === "min" ) {
  11382. this.options.value = this._values( 0 );
  11383. this.options.values = null;
  11384. } else if ( value === "max" ) {
  11385. this.options.value = this._values( this.options.values.length - 1 );
  11386. this.options.values = null;
  11387. }
  11388. }
  11389. if ( $.isArray( this.options.values ) ) {
  11390. valsLength = this.options.values.length;
  11391. }
  11392. if ( key === "disabled" ) {
  11393. this.element.toggleClass( "ui-state-disabled", !!value );
  11394. }
  11395. this._super( key, value );
  11396. switch ( key ) {
  11397. case "orientation":
  11398. this._detectOrientation();
  11399. this.element
  11400. .removeClass( "ui-slider-horizontal ui-slider-vertical" )
  11401. .addClass( "ui-slider-" + this.orientation );
  11402. this._refreshValue();
  11403. // Reset positioning from previous orientation
  11404. this.handles.css( value === "horizontal" ? "bottom" : "left", "" );
  11405. break;
  11406. case "value":
  11407. this._animateOff = true;
  11408. this._refreshValue();
  11409. this._change( null, 0 );
  11410. this._animateOff = false;
  11411. break;
  11412. case "values":
  11413. this._animateOff = true;
  11414. this._refreshValue();
  11415. for ( i = 0; i < valsLength; i += 1 ) {
  11416. this._change( null, i );
  11417. }
  11418. this._animateOff = false;
  11419. break;
  11420. case "step":
  11421. case "min":
  11422. case "max":
  11423. this._animateOff = true;
  11424. this._calculateNewMax();
  11425. this._refreshValue();
  11426. this._animateOff = false;
  11427. break;
  11428. case "range":
  11429. this._animateOff = true;
  11430. this._refresh();
  11431. this._animateOff = false;
  11432. break;
  11433. }
  11434. },
  11435. //internal value getter
  11436. // _value() returns value trimmed by min and max, aligned by step
  11437. _value: function() {
  11438. var val = this.options.value;
  11439. val = this._trimAlignValue( val );
  11440. return val;
  11441. },
  11442. //internal values getter
  11443. // _values() returns array of values trimmed by min and max, aligned by step
  11444. // _values( index ) returns single value trimmed by min and max, aligned by step
  11445. _values: function( index ) {
  11446. var val,
  11447. vals,
  11448. i;
  11449. if ( arguments.length ) {
  11450. val = this.options.values[ index ];
  11451. val = this._trimAlignValue( val );
  11452. return val;
  11453. } else if ( this.options.values && this.options.values.length ) {
  11454. // .slice() creates a copy of the array
  11455. // this copy gets trimmed by min and max and then returned
  11456. vals = this.options.values.slice();
  11457. for ( i = 0; i < vals.length; i += 1) {
  11458. vals[ i ] = this._trimAlignValue( vals[ i ] );
  11459. }
  11460. return vals;
  11461. } else {
  11462. return [];
  11463. }
  11464. },
  11465. // returns the step-aligned value that val is closest to, between (inclusive) min and max
  11466. _trimAlignValue: function( val ) {
  11467. if ( val <= this._valueMin() ) {
  11468. return this._valueMin();
  11469. }
  11470. if ( val >= this._valueMax() ) {
  11471. return this._valueMax();
  11472. }
  11473. var step = ( this.options.step > 0 ) ? this.options.step : 1,
  11474. valModStep = (val - this._valueMin()) % step,
  11475. alignValue = val - valModStep;
  11476. if ( Math.abs(valModStep) * 2 >= step ) {
  11477. alignValue += ( valModStep > 0 ) ? step : ( -step );
  11478. }
  11479. // Since JavaScript has problems with large floats, round
  11480. // the final value to 5 digits after the decimal point (see #4124)
  11481. return parseFloat( alignValue.toFixed(5) );
  11482. },
  11483. _calculateNewMax: function() {
  11484. var remainder = ( this.options.max - this._valueMin() ) % this.options.step;
  11485. this.max = this.options.max - remainder;
  11486. },
  11487. _valueMin: function() {
  11488. return this.options.min;
  11489. },
  11490. _valueMax: function() {
  11491. return this.max;
  11492. },
  11493. _refreshValue: function() {
  11494. var lastValPercent, valPercent, value, valueMin, valueMax,
  11495. oRange = this.options.range,
  11496. o = this.options,
  11497. that = this,
  11498. animate = ( !this._animateOff ) ? o.animate : false,
  11499. _set = {};
  11500. if ( this.options.values && this.options.values.length ) {
  11501. this.handles.each(function( i ) {
  11502. valPercent = ( that.values(i) - that._valueMin() ) / ( that._valueMax() - that._valueMin() ) * 100;
  11503. _set[ that.orientation === "horizontal" ? "left" : "bottom" ] = valPercent + "%";
  11504. $( this ).stop( 1, 1 )[ animate ? "animate" : "css" ]( _set, o.animate );
  11505. if ( that.options.range === true ) {
  11506. if ( that.orientation === "horizontal" ) {
  11507. if ( i === 0 ) {
  11508. that.range.stop( 1, 1 )[ animate ? "animate" : "css" ]( { left: valPercent + "%" }, o.animate );
  11509. }
  11510. if ( i === 1 ) {
  11511. that.range[ animate ? "animate" : "css" ]( { width: ( valPercent - lastValPercent ) + "%" }, { queue: false, duration: o.animate } );
  11512. }
  11513. } else {
  11514. if ( i === 0 ) {
  11515. that.range.stop( 1, 1 )[ animate ? "animate" : "css" ]( { bottom: ( valPercent ) + "%" }, o.animate );
  11516. }
  11517. if ( i === 1 ) {
  11518. that.range[ animate ? "animate" : "css" ]( { height: ( valPercent - lastValPercent ) + "%" }, { queue: false, duration: o.animate } );
  11519. }
  11520. }
  11521. }
  11522. lastValPercent = valPercent;
  11523. });
  11524. } else {
  11525. value = this.value();
  11526. valueMin = this._valueMin();
  11527. valueMax = this._valueMax();
  11528. valPercent = ( valueMax !== valueMin ) ?
  11529. ( value - valueMin ) / ( valueMax - valueMin ) * 100 :
  11530. 0;
  11531. _set[ this.orientation === "horizontal" ? "left" : "bottom" ] = valPercent + "%";
  11532. this.handle.stop( 1, 1 )[ animate ? "animate" : "css" ]( _set, o.animate );
  11533. if ( oRange === "min" && this.orientation === "horizontal" ) {
  11534. this.range.stop( 1, 1 )[ animate ? "animate" : "css" ]( { width: valPercent + "%" }, o.animate );
  11535. }
  11536. if ( oRange === "max" && this.orientation === "horizontal" ) {
  11537. this.range[ animate ? "animate" : "css" ]( { width: ( 100 - valPercent ) + "%" }, { queue: false, duration: o.animate } );
  11538. }
  11539. if ( oRange === "min" && this.orientation === "vertical" ) {
  11540. this.range.stop( 1, 1 )[ animate ? "animate" : "css" ]( { height: valPercent + "%" }, o.animate );
  11541. }
  11542. if ( oRange === "max" && this.orientation === "vertical" ) {
  11543. this.range[ animate ? "animate" : "css" ]( { height: ( 100 - valPercent ) + "%" }, { queue: false, duration: o.animate } );
  11544. }
  11545. }
  11546. },
  11547. _handleEvents: {
  11548. keydown: function( event ) {
  11549. var allowed, curVal, newVal, step,
  11550. index = $( event.target ).data( "ui-slider-handle-index" );
  11551. switch ( event.keyCode ) {
  11552. case $.ui.keyCode.HOME:
  11553. case $.ui.keyCode.END:
  11554. case $.ui.keyCode.PAGE_UP:
  11555. case $.ui.keyCode.PAGE_DOWN:
  11556. case $.ui.keyCode.UP:
  11557. case $.ui.keyCode.RIGHT:
  11558. case $.ui.keyCode.DOWN:
  11559. case $.ui.keyCode.LEFT:
  11560. event.preventDefault();
  11561. if ( !this._keySliding ) {
  11562. this._keySliding = true;
  11563. $( event.target ).addClass( "ui-state-active" );
  11564. allowed = this._start( event, index );
  11565. if ( allowed === false ) {
  11566. return;
  11567. }
  11568. }
  11569. break;
  11570. }
  11571. step = this.options.step;
  11572. if ( this.options.values && this.options.values.length ) {
  11573. curVal = newVal = this.values( index );
  11574. } else {
  11575. curVal = newVal = this.value();
  11576. }
  11577. switch ( event.keyCode ) {
  11578. case $.ui.keyCode.HOME:
  11579. newVal = this._valueMin();
  11580. break;
  11581. case $.ui.keyCode.END:
  11582. newVal = this._valueMax();
  11583. break;
  11584. case $.ui.keyCode.PAGE_UP:
  11585. newVal = this._trimAlignValue(
  11586. curVal + ( ( this._valueMax() - this._valueMin() ) / this.numPages )
  11587. );
  11588. break;
  11589. case $.ui.keyCode.PAGE_DOWN:
  11590. newVal = this._trimAlignValue(
  11591. curVal - ( (this._valueMax() - this._valueMin()) / this.numPages ) );
  11592. break;
  11593. case $.ui.keyCode.UP:
  11594. case $.ui.keyCode.RIGHT:
  11595. if ( curVal === this._valueMax() ) {
  11596. return;
  11597. }
  11598. newVal = this._trimAlignValue( curVal + step );
  11599. break;
  11600. case $.ui.keyCode.DOWN:
  11601. case $.ui.keyCode.LEFT:
  11602. if ( curVal === this._valueMin() ) {
  11603. return;
  11604. }
  11605. newVal = this._trimAlignValue( curVal - step );
  11606. break;
  11607. }
  11608. this._slide( event, index, newVal );
  11609. },
  11610. keyup: function( event ) {
  11611. var index = $( event.target ).data( "ui-slider-handle-index" );
  11612. if ( this._keySliding ) {
  11613. this._keySliding = false;
  11614. this._stop( event, index );
  11615. this._change( event, index );
  11616. $( event.target ).removeClass( "ui-state-active" );
  11617. }
  11618. }
  11619. }
  11620. });
  11621. /*!
  11622. * jQuery UI Sortable 1.11.2
  11623. * http://jqueryui.com
  11624. *
  11625. * Copyright 2014 jQuery Foundation and other contributors
  11626. * Released under the MIT license.
  11627. * http://jquery.org/license
  11628. *
  11629. * http://api.jqueryui.com/sortable/
  11630. */
  11631. var sortable = $.widget("ui.sortable", $.ui.mouse, {
  11632. version: "1.11.2",
  11633. widgetEventPrefix: "sort",
  11634. ready: false,
  11635. options: {
  11636. appendTo: "parent",
  11637. axis: false,
  11638. connectWith: false,
  11639. containment: false,
  11640. cursor: "auto",
  11641. cursorAt: false,
  11642. dropOnEmpty: true,
  11643. forcePlaceholderSize: false,
  11644. forceHelperSize: false,
  11645. grid: false,
  11646. handle: false,
  11647. helper: "original",
  11648. items: "> *",
  11649. opacity: false,
  11650. placeholder: false,
  11651. revert: false,
  11652. scroll: true,
  11653. scrollSensitivity: 20,
  11654. scrollSpeed: 20,
  11655. scope: "default",
  11656. tolerance: "intersect",
  11657. zIndex: 1000,
  11658. // callbacks
  11659. activate: null,
  11660. beforeStop: null,
  11661. change: null,
  11662. deactivate: null,
  11663. out: null,
  11664. over: null,
  11665. receive: null,
  11666. remove: null,
  11667. sort: null,
  11668. start: null,
  11669. stop: null,
  11670. update: null
  11671. },
  11672. _isOverAxis: function( x, reference, size ) {
  11673. return ( x >= reference ) && ( x < ( reference + size ) );
  11674. },
  11675. _isFloating: function( item ) {
  11676. return (/left|right/).test(item.css("float")) || (/inline|table-cell/).test(item.css("display"));
  11677. },
  11678. _create: function() {
  11679. var o = this.options;
  11680. this.containerCache = {};
  11681. this.element.addClass("ui-sortable");
  11682. //Get the items
  11683. this.refresh();
  11684. //Let's determine if the items are being displayed horizontally
  11685. this.floating = this.items.length ? o.axis === "x" || this._isFloating(this.items[0].item) : false;
  11686. //Let's determine the parent's offset
  11687. this.offset = this.element.offset();
  11688. //Initialize mouse events for interaction
  11689. this._mouseInit();
  11690. this._setHandleClassName();
  11691. //We're ready to go
  11692. this.ready = true;
  11693. },
  11694. _setOption: function( key, value ) {
  11695. this._super( key, value );
  11696. if ( key === "handle" ) {
  11697. this._setHandleClassName();
  11698. }
  11699. },
  11700. _setHandleClassName: function() {
  11701. this.element.find( ".ui-sortable-handle" ).removeClass( "ui-sortable-handle" );
  11702. $.each( this.items, function() {
  11703. ( this.instance.options.handle ?
  11704. this.item.find( this.instance.options.handle ) : this.item )
  11705. .addClass( "ui-sortable-handle" );
  11706. });
  11707. },
  11708. _destroy: function() {
  11709. this.element
  11710. .removeClass( "ui-sortable ui-sortable-disabled" )
  11711. .find( ".ui-sortable-handle" )
  11712. .removeClass( "ui-sortable-handle" );
  11713. this._mouseDestroy();
  11714. for ( var i = this.items.length - 1; i >= 0; i-- ) {
  11715. this.items[i].item.removeData(this.widgetName + "-item");
  11716. }
  11717. return this;
  11718. },
  11719. _mouseCapture: function(event, overrideHandle) {
  11720. var currentItem = null,
  11721. validHandle = false,
  11722. that = this;
  11723. if (this.reverting) {
  11724. return false;
  11725. }
  11726. if(this.options.disabled || this.options.type === "static") {
  11727. return false;
  11728. }
  11729. //We have to refresh the items data once first
  11730. this._refreshItems(event);
  11731. //Find out if the clicked node (or one of its parents) is a actual item in this.items
  11732. $(event.target).parents().each(function() {
  11733. if($.data(this, that.widgetName + "-item") === that) {
  11734. currentItem = $(this);
  11735. return false;
  11736. }
  11737. });
  11738. if($.data(event.target, that.widgetName + "-item") === that) {
  11739. currentItem = $(event.target);
  11740. }
  11741. if(!currentItem) {
  11742. return false;
  11743. }
  11744. if(this.options.handle && !overrideHandle) {
  11745. $(this.options.handle, currentItem).find("*").addBack().each(function() {
  11746. if(this === event.target) {
  11747. validHandle = true;
  11748. }
  11749. });
  11750. if(!validHandle) {
  11751. return false;
  11752. }
  11753. }
  11754. this.currentItem = currentItem;
  11755. this._removeCurrentsFromItems();
  11756. return true;
  11757. },
  11758. _mouseStart: function(event, overrideHandle, noActivation) {
  11759. var i, body,
  11760. o = this.options;
  11761. this.currentContainer = this;
  11762. //We only need to call refreshPositions, because the refreshItems call has been moved to mouseCapture
  11763. this.refreshPositions();
  11764. //Create and append the visible helper
  11765. this.helper = this._createHelper(event);
  11766. //Cache the helper size
  11767. this._cacheHelperProportions();
  11768. /*
  11769. * - Position generation -
  11770. * This block generates everything position related - it's the core of draggables.
  11771. */
  11772. //Cache the margins of the original element
  11773. this._cacheMargins();
  11774. //Get the next scrolling parent
  11775. this.scrollParent = this.helper.scrollParent();
  11776. //The element's absolute position on the page minus margins
  11777. this.offset = this.currentItem.offset();
  11778. this.offset = {
  11779. top: this.offset.top - this.margins.top,
  11780. left: this.offset.left - this.margins.left
  11781. };
  11782. $.extend(this.offset, {
  11783. click: { //Where the click happened, relative to the element
  11784. left: event.pageX - this.offset.left,
  11785. top: event.pageY - this.offset.top
  11786. },
  11787. parent: this._getParentOffset(),
  11788. relative: this._getRelativeOffset() //This is a relative to absolute position minus the actual position calculation - only used for relative positioned helper
  11789. });
  11790. // Only after we got the offset, we can change the helper's position to absolute
  11791. // TODO: Still need to figure out a way to make relative sorting possible
  11792. this.helper.css("position", "absolute");
  11793. this.cssPosition = this.helper.css("position");
  11794. //Generate the original position
  11795. this.originalPosition = this._generatePosition(event);
  11796. this.originalPageX = event.pageX;
  11797. this.originalPageY = event.pageY;
  11798. //Adjust the mouse offset relative to the helper if "cursorAt" is supplied
  11799. (o.cursorAt && this._adjustOffsetFromHelper(o.cursorAt));
  11800. //Cache the former DOM position
  11801. this.domPosition = { prev: this.currentItem.prev()[0], parent: this.currentItem.parent()[0] };
  11802. //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
  11803. if(this.helper[0] !== this.currentItem[0]) {
  11804. this.currentItem.hide();
  11805. }
  11806. //Create the placeholder
  11807. this._createPlaceholder();
  11808. //Set a containment if given in the options
  11809. if(o.containment) {
  11810. this._setContainment();
  11811. }
  11812. if( o.cursor && o.cursor !== "auto" ) { // cursor option
  11813. body = this.document.find( "body" );
  11814. // support: IE
  11815. this.storedCursor = body.css( "cursor" );
  11816. body.css( "cursor", o.cursor );
  11817. this.storedStylesheet = $( "<style>*{ cursor: "+o.cursor+" !important; }</style>" ).appendTo( body );
  11818. }
  11819. if(o.opacity) { // opacity option
  11820. if (this.helper.css("opacity")) {
  11821. this._storedOpacity = this.helper.css("opacity");
  11822. }
  11823. this.helper.css("opacity", o.opacity);
  11824. }
  11825. if(o.zIndex) { // zIndex option
  11826. if (this.helper.css("zIndex")) {
  11827. this._storedZIndex = this.helper.css("zIndex");
  11828. }
  11829. this.helper.css("zIndex", o.zIndex);
  11830. }
  11831. //Prepare scrolling
  11832. if(this.scrollParent[0] !== document && this.scrollParent[0].tagName !== "HTML") {
  11833. this.overflowOffset = this.scrollParent.offset();
  11834. }
  11835. //Call callbacks
  11836. this._trigger("start", event, this._uiHash());
  11837. //Recache the helper size
  11838. if(!this._preserveHelperProportions) {
  11839. this._cacheHelperProportions();
  11840. }
  11841. //Post "activate" events to possible containers
  11842. if( !noActivation ) {
  11843. for ( i = this.containers.length - 1; i >= 0; i-- ) {
  11844. this.containers[ i ]._trigger( "activate", event, this._uiHash( this ) );
  11845. }
  11846. }
  11847. //Prepare possible droppables
  11848. if($.ui.ddmanager) {
  11849. $.ui.ddmanager.current = this;
  11850. }
  11851. if ($.ui.ddmanager && !o.dropBehaviour) {
  11852. $.ui.ddmanager.prepareOffsets(this, event);
  11853. }
  11854. this.dragging = true;
  11855. this.helper.addClass("ui-sortable-helper");
  11856. this._mouseDrag(event); //Execute the drag once - this causes the helper not to be visible before getting its correct position
  11857. return true;
  11858. },
  11859. _mouseDrag: function(event) {
  11860. var i, item, itemElement, intersection,
  11861. o = this.options,
  11862. scrolled = false;
  11863. //Compute the helpers position
  11864. this.position = this._generatePosition(event);
  11865. this.positionAbs = this._convertPositionTo("absolute");
  11866. if (!this.lastPositionAbs) {
  11867. this.lastPositionAbs = this.positionAbs;
  11868. }
  11869. //Do scrolling
  11870. if(this.options.scroll) {
  11871. if(this.scrollParent[0] !== document && this.scrollParent[0].tagName !== "HTML") {
  11872. if((this.overflowOffset.top + this.scrollParent[0].offsetHeight) - event.pageY < o.scrollSensitivity) {
  11873. this.scrollParent[0].scrollTop = scrolled = this.scrollParent[0].scrollTop + o.scrollSpeed;
  11874. } else if(event.pageY - this.overflowOffset.top < o.scrollSensitivity) {
  11875. this.scrollParent[0].scrollTop = scrolled = this.scrollParent[0].scrollTop - o.scrollSpeed;
  11876. }
  11877. if((this.overflowOffset.left + this.scrollParent[0].offsetWidth) - event.pageX < o.scrollSensitivity) {
  11878. this.scrollParent[0].scrollLeft = scrolled = this.scrollParent[0].scrollLeft + o.scrollSpeed;
  11879. } else if(event.pageX - this.overflowOffset.left < o.scrollSensitivity) {
  11880. this.scrollParent[0].scrollLeft = scrolled = this.scrollParent[0].scrollLeft - o.scrollSpeed;
  11881. }
  11882. } else {
  11883. if(event.pageY - $(document).scrollTop() < o.scrollSensitivity) {
  11884. scrolled = $(document).scrollTop($(document).scrollTop() - o.scrollSpeed);
  11885. } else if($(window).height() - (event.pageY - $(document).scrollTop()) < o.scrollSensitivity) {
  11886. scrolled = $(document).scrollTop($(document).scrollTop() + o.scrollSpeed);
  11887. }
  11888. if(event.pageX - $(document).scrollLeft() < o.scrollSensitivity) {
  11889. scrolled = $(document).scrollLeft($(document).scrollLeft() - o.scrollSpeed);
  11890. } else if($(window).width() - (event.pageX - $(document).scrollLeft()) < o.scrollSensitivity) {
  11891. scrolled = $(document).scrollLeft($(document).scrollLeft() + o.scrollSpeed);
  11892. }
  11893. }
  11894. if(scrolled !== false && $.ui.ddmanager && !o.dropBehaviour) {
  11895. $.ui.ddmanager.prepareOffsets(this, event);
  11896. }
  11897. }
  11898. //Regenerate the absolute position used for position checks
  11899. this.positionAbs = this._convertPositionTo("absolute");
  11900. //Set the helper position
  11901. if(!this.options.axis || this.options.axis !== "y") {
  11902. this.helper[0].style.left = this.position.left+"px";
  11903. }
  11904. if(!this.options.axis || this.options.axis !== "x") {
  11905. this.helper[0].style.top = this.position.top+"px";
  11906. }
  11907. //Rearrange
  11908. for (i = this.items.length - 1; i >= 0; i--) {
  11909. //Cache variables and intersection, continue if no intersection
  11910. item = this.items[i];
  11911. itemElement = item.item[0];
  11912. intersection = this._intersectsWithPointer(item);
  11913. if (!intersection) {
  11914. continue;
  11915. }
  11916. // Only put the placeholder inside the current Container, skip all
  11917. // items from other containers. This works because when moving
  11918. // an item from one container to another the
  11919. // currentContainer is switched before the placeholder is moved.
  11920. //
  11921. // Without this, moving items in "sub-sortables" can cause
  11922. // the placeholder to jitter between the outer and inner container.
  11923. if (item.instance !== this.currentContainer) {
  11924. continue;
  11925. }
  11926. // cannot intersect with itself
  11927. // no useless actions that have been done before
  11928. // no action if the item moved is the parent of the item checked
  11929. if (itemElement !== this.currentItem[0] &&
  11930. this.placeholder[intersection === 1 ? "next" : "prev"]()[0] !== itemElement &&
  11931. !$.contains(this.placeholder[0], itemElement) &&
  11932. (this.options.type === "semi-dynamic" ? !$.contains(this.element[0], itemElement) : true)
  11933. ) {
  11934. this.direction = intersection === 1 ? "down" : "up";
  11935. if (this.options.tolerance === "pointer" || this._intersectsWithSides(item)) {
  11936. this._rearrange(event, item);
  11937. } else {
  11938. break;
  11939. }
  11940. this._trigger("change", event, this._uiHash());
  11941. break;
  11942. }
  11943. }
  11944. //Post events to containers
  11945. this._contactContainers(event);
  11946. //Interconnect with droppables
  11947. if($.ui.ddmanager) {
  11948. $.ui.ddmanager.drag(this, event);
  11949. }
  11950. //Call callbacks
  11951. this._trigger("sort", event, this._uiHash());
  11952. this.lastPositionAbs = this.positionAbs;
  11953. return false;
  11954. },
  11955. _mouseStop: function(event, noPropagation) {
  11956. if(!event) {
  11957. return;
  11958. }
  11959. //If we are using droppables, inform the manager about the drop
  11960. if ($.ui.ddmanager && !this.options.dropBehaviour) {
  11961. $.ui.ddmanager.drop(this, event);
  11962. }
  11963. if(this.options.revert) {
  11964. var that = this,
  11965. cur = this.placeholder.offset(),
  11966. axis = this.options.axis,
  11967. animation = {};
  11968. if ( !axis || axis === "x" ) {
  11969. animation.left = cur.left - this.offset.parent.left - this.margins.left + (this.offsetParent[0] === document.body ? 0 : this.offsetParent[0].scrollLeft);
  11970. }
  11971. if ( !axis || axis === "y" ) {
  11972. animation.top = cur.top - this.offset.parent.top - this.margins.top + (this.offsetParent[0] === document.body ? 0 : this.offsetParent[0].scrollTop);
  11973. }
  11974. this.reverting = true;
  11975. $(this.helper).animate( animation, parseInt(this.options.revert, 10) || 500, function() {
  11976. that._clear(event);
  11977. });
  11978. } else {
  11979. this._clear(event, noPropagation);
  11980. }
  11981. return false;
  11982. },
  11983. cancel: function() {
  11984. if(this.dragging) {
  11985. this._mouseUp({ target: null });
  11986. if(this.options.helper === "original") {
  11987. this.currentItem.css(this._storedCSS).removeClass("ui-sortable-helper");
  11988. } else {
  11989. this.currentItem.show();
  11990. }
  11991. //Post deactivating events to containers
  11992. for (var i = this.containers.length - 1; i >= 0; i--){
  11993. this.containers[i]._trigger("deactivate", null, this._uiHash(this));
  11994. if(this.containers[i].containerCache.over) {
  11995. this.containers[i]._trigger("out", null, this._uiHash(this));
  11996. this.containers[i].containerCache.over = 0;
  11997. }
  11998. }
  11999. }
  12000. if (this.placeholder) {
  12001. //$(this.placeholder[0]).remove(); would have been the jQuery way - unfortunately, it unbinds ALL events from the original node!
  12002. if(this.placeholder[0].parentNode) {
  12003. this.placeholder[0].parentNode.removeChild(this.placeholder[0]);
  12004. }
  12005. if(this.options.helper !== "original" && this.helper && this.helper[0].parentNode) {
  12006. this.helper.remove();
  12007. }
  12008. $.extend(this, {
  12009. helper: null,
  12010. dragging: false,
  12011. reverting: false,
  12012. _noFinalSort: null
  12013. });
  12014. if(this.domPosition.prev) {
  12015. $(this.domPosition.prev).after(this.currentItem);
  12016. } else {
  12017. $(this.domPosition.parent).prepend(this.currentItem);
  12018. }
  12019. }
  12020. return this;
  12021. },
  12022. serialize: function(o) {
  12023. var items = this._getItemsAsjQuery(o && o.connected),
  12024. str = [];
  12025. o = o || {};
  12026. $(items).each(function() {
  12027. var res = ($(o.item || this).attr(o.attribute || "id") || "").match(o.expression || (/(.+)[\-=_](.+)/));
  12028. if (res) {
  12029. str.push((o.key || res[1]+"[]")+"="+(o.key && o.expression ? res[1] : res[2]));
  12030. }
  12031. });
  12032. if(!str.length && o.key) {
  12033. str.push(o.key + "=");
  12034. }
  12035. return str.join("&");
  12036. },
  12037. toArray: function(o) {
  12038. var items = this._getItemsAsjQuery(o && o.connected),
  12039. ret = [];
  12040. o = o || {};
  12041. items.each(function() { ret.push($(o.item || this).attr(o.attribute || "id") || ""); });
  12042. return ret;
  12043. },
  12044. /* Be careful with the following core functions */
  12045. _intersectsWith: function(item) {
  12046. var x1 = this.positionAbs.left,
  12047. x2 = x1 + this.helperProportions.width,
  12048. y1 = this.positionAbs.top,
  12049. y2 = y1 + this.helperProportions.height,
  12050. l = item.left,
  12051. r = l + item.width,
  12052. t = item.top,
  12053. b = t + item.height,
  12054. dyClick = this.offset.click.top,
  12055. dxClick = this.offset.click.left,
  12056. isOverElementHeight = ( this.options.axis === "x" ) || ( ( y1 + dyClick ) > t && ( y1 + dyClick ) < b ),
  12057. isOverElementWidth = ( this.options.axis === "y" ) || ( ( x1 + dxClick ) > l && ( x1 + dxClick ) < r ),
  12058. isOverElement = isOverElementHeight && isOverElementWidth;
  12059. if ( this.options.tolerance === "pointer" ||
  12060. this.options.forcePointerForContainers ||
  12061. (this.options.tolerance !== "pointer" && this.helperProportions[this.floating ? "width" : "height"] > item[this.floating ? "width" : "height"])
  12062. ) {
  12063. return isOverElement;
  12064. } else {
  12065. return (l < x1 + (this.helperProportions.width / 2) && // Right Half
  12066. x2 - (this.helperProportions.width / 2) < r && // Left Half
  12067. t < y1 + (this.helperProportions.height / 2) && // Bottom Half
  12068. y2 - (this.helperProportions.height / 2) < b ); // Top Half
  12069. }
  12070. },
  12071. _intersectsWithPointer: function(item) {
  12072. var isOverElementHeight = (this.options.axis === "x") || this._isOverAxis(this.positionAbs.top + this.offset.click.top, item.top, item.height),
  12073. isOverElementWidth = (this.options.axis === "y") || this._isOverAxis(this.positionAbs.left + this.offset.click.left, item.left, item.width),
  12074. isOverElement = isOverElementHeight && isOverElementWidth,
  12075. verticalDirection = this._getDragVerticalDirection(),
  12076. horizontalDirection = this._getDragHorizontalDirection();
  12077. if (!isOverElement) {
  12078. return false;
  12079. }
  12080. return this.floating ?
  12081. ( ((horizontalDirection && horizontalDirection === "right") || verticalDirection === "down") ? 2 : 1 )
  12082. : ( verticalDirection && (verticalDirection === "down" ? 2 : 1) );
  12083. },
  12084. _intersectsWithSides: function(item) {
  12085. var isOverBottomHalf = this._isOverAxis(this.positionAbs.top + this.offset.click.top, item.top + (item.height/2), item.height),
  12086. isOverRightHalf = this._isOverAxis(this.positionAbs.left + this.offset.click.left, item.left + (item.width/2), item.width),
  12087. verticalDirection = this._getDragVerticalDirection(),
  12088. horizontalDirection = this._getDragHorizontalDirection();
  12089. if (this.floating && horizontalDirection) {
  12090. return ((horizontalDirection === "right" && isOverRightHalf) || (horizontalDirection === "left" && !isOverRightHalf));
  12091. } else {
  12092. return verticalDirection && ((verticalDirection === "down" && isOverBottomHalf) || (verticalDirection === "up" && !isOverBottomHalf));
  12093. }
  12094. },
  12095. _getDragVerticalDirection: function() {
  12096. var delta = this.positionAbs.top - this.lastPositionAbs.top;
  12097. return delta !== 0 && (delta > 0 ? "down" : "up");
  12098. },
  12099. _getDragHorizontalDirection: function() {
  12100. var delta = this.positionAbs.left - this.lastPositionAbs.left;
  12101. return delta !== 0 && (delta > 0 ? "right" : "left");
  12102. },
  12103. refresh: function(event) {
  12104. this._refreshItems(event);
  12105. this._setHandleClassName();
  12106. this.refreshPositions();
  12107. return this;
  12108. },
  12109. _connectWith: function() {
  12110. var options = this.options;
  12111. return options.connectWith.constructor === String ? [options.connectWith] : options.connectWith;
  12112. },
  12113. _getItemsAsjQuery: function(connected) {
  12114. var i, j, cur, inst,
  12115. items = [],
  12116. queries = [],
  12117. connectWith = this._connectWith();
  12118. if(connectWith && connected) {
  12119. for (i = connectWith.length - 1; i >= 0; i--){
  12120. cur = $(connectWith[i]);
  12121. for ( j = cur.length - 1; j >= 0; j--){
  12122. inst = $.data(cur[j], this.widgetFullName);
  12123. if(inst && inst !== this && !inst.options.disabled) {
  12124. 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]);
  12125. }
  12126. }
  12127. }
  12128. }
  12129. 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]);
  12130. function addItems() {
  12131. items.push( this );
  12132. }
  12133. for (i = queries.length - 1; i >= 0; i--){
  12134. queries[i][0].each( addItems );
  12135. }
  12136. return $(items);
  12137. },
  12138. _removeCurrentsFromItems: function() {
  12139. var list = this.currentItem.find(":data(" + this.widgetName + "-item)");
  12140. this.items = $.grep(this.items, function (item) {
  12141. for (var j=0; j < list.length; j++) {
  12142. if(list[j] === item.item[0]) {
  12143. return false;
  12144. }
  12145. }
  12146. return true;
  12147. });
  12148. },
  12149. _refreshItems: function(event) {
  12150. this.items = [];
  12151. this.containers = [this];
  12152. var i, j, cur, inst, targetData, _queries, item, queriesLength,
  12153. items = this.items,
  12154. queries = [[$.isFunction(this.options.items) ? this.options.items.call(this.element[0], event, { item: this.currentItem }) : $(this.options.items, this.element), this]],
  12155. connectWith = this._connectWith();
  12156. if(connectWith && this.ready) { //Shouldn't be run the first time through due to massive slow-down
  12157. for (i = connectWith.length - 1; i >= 0; i--){
  12158. cur = $(connectWith[i]);
  12159. for (j = cur.length - 1; j >= 0; j--){
  12160. inst = $.data(cur[j], this.widgetFullName);
  12161. if(inst && inst !== this && !inst.options.disabled) {
  12162. queries.push([$.isFunction(inst.options.items) ? inst.options.items.call(inst.element[0], event, { item: this.currentItem }) : $(inst.options.items, inst.element), inst]);
  12163. this.containers.push(inst);
  12164. }
  12165. }
  12166. }
  12167. }
  12168. for (i = queries.length - 1; i >= 0; i--) {
  12169. targetData = queries[i][1];
  12170. _queries = queries[i][0];
  12171. for (j=0, queriesLength = _queries.length; j < queriesLength; j++) {
  12172. item = $(_queries[j]);
  12173. item.data(this.widgetName + "-item", targetData); // Data for target checking (mouse manager)
  12174. items.push({
  12175. item: item,
  12176. instance: targetData,
  12177. width: 0, height: 0,
  12178. left: 0, top: 0
  12179. });
  12180. }
  12181. }
  12182. },
  12183. refreshPositions: function(fast) {
  12184. //This has to be redone because due to the item being moved out/into the offsetParent, the offsetParent's position will change
  12185. if(this.offsetParent && this.helper) {
  12186. this.offset.parent = this._getParentOffset();
  12187. }
  12188. var i, item, t, p;
  12189. for (i = this.items.length - 1; i >= 0; i--){
  12190. item = this.items[i];
  12191. //We ignore calculating positions of all connected containers when we're not over them
  12192. if(item.instance !== this.currentContainer && this.currentContainer && item.item[0] !== this.currentItem[0]) {
  12193. continue;
  12194. }
  12195. t = this.options.toleranceElement ? $(this.options.toleranceElement, item.item) : item.item;
  12196. if (!fast) {
  12197. item.width = t.outerWidth();
  12198. item.height = t.outerHeight();
  12199. }
  12200. p = t.offset();
  12201. item.left = p.left;
  12202. item.top = p.top;
  12203. }
  12204. if(this.options.custom && this.options.custom.refreshContainers) {
  12205. this.options.custom.refreshContainers.call(this);
  12206. } else {
  12207. for (i = this.containers.length - 1; i >= 0; i--){
  12208. p = this.containers[i].element.offset();
  12209. this.containers[i].containerCache.left = p.left;
  12210. this.containers[i].containerCache.top = p.top;
  12211. this.containers[i].containerCache.width = this.containers[i].element.outerWidth();
  12212. this.containers[i].containerCache.height = this.containers[i].element.outerHeight();
  12213. }
  12214. }
  12215. return this;
  12216. },
  12217. _createPlaceholder: function(that) {
  12218. that = that || this;
  12219. var className,
  12220. o = that.options;
  12221. if(!o.placeholder || o.placeholder.constructor === String) {
  12222. className = o.placeholder;
  12223. o.placeholder = {
  12224. element: function() {
  12225. var nodeName = that.currentItem[0].nodeName.toLowerCase(),
  12226. element = $( "<" + nodeName + ">", that.document[0] )
  12227. .addClass(className || that.currentItem[0].className+" ui-sortable-placeholder")
  12228. .removeClass("ui-sortable-helper");
  12229. if ( nodeName === "tr" ) {
  12230. that.currentItem.children().each(function() {
  12231. $( "<td>&#160;</td>", that.document[0] )
  12232. .attr( "colspan", $( this ).attr( "colspan" ) || 1 )
  12233. .appendTo( element );
  12234. });
  12235. } else if ( nodeName === "img" ) {
  12236. element.attr( "src", that.currentItem.attr( "src" ) );
  12237. }
  12238. if ( !className ) {
  12239. element.css( "visibility", "hidden" );
  12240. }
  12241. return element;
  12242. },
  12243. update: function(container, p) {
  12244. // 1. If a className is set as 'placeholder option, we don't force sizes - the class is responsible for that
  12245. // 2. The option 'forcePlaceholderSize can be enabled to force it even if a class name is specified
  12246. if(className && !o.forcePlaceholderSize) {
  12247. return;
  12248. }
  12249. //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
  12250. if(!p.height()) { p.height(that.currentItem.innerHeight() - parseInt(that.currentItem.css("paddingTop")||0, 10) - parseInt(that.currentItem.css("paddingBottom")||0, 10)); }
  12251. if(!p.width()) { p.width(that.currentItem.innerWidth() - parseInt(that.currentItem.css("paddingLeft")||0, 10) - parseInt(that.currentItem.css("paddingRight")||0, 10)); }
  12252. }
  12253. };
  12254. }
  12255. //Create the placeholder
  12256. that.placeholder = $(o.placeholder.element.call(that.element, that.currentItem));
  12257. //Append it after the actual current item
  12258. that.currentItem.after(that.placeholder);
  12259. //Update the size of the placeholder (TODO: Logic to fuzzy, see line 316/317)
  12260. o.placeholder.update(that, that.placeholder);
  12261. },
  12262. _contactContainers: function(event) {
  12263. var i, j, dist, itemWithLeastDistance, posProperty, sizeProperty, cur, nearBottom, floating, axis,
  12264. innermostContainer = null,
  12265. innermostIndex = null;
  12266. // get innermost container that intersects with item
  12267. for (i = this.containers.length - 1; i >= 0; i--) {
  12268. // never consider a container that's located within the item itself
  12269. if($.contains(this.currentItem[0], this.containers[i].element[0])) {
  12270. continue;
  12271. }
  12272. if(this._intersectsWith(this.containers[i].containerCache)) {
  12273. // if we've already found a container and it's more "inner" than this, then continue
  12274. if(innermostContainer && $.contains(this.containers[i].element[0], innermostContainer.element[0])) {
  12275. continue;
  12276. }
  12277. innermostContainer = this.containers[i];
  12278. innermostIndex = i;
  12279. } else {
  12280. // container doesn't intersect. trigger "out" event if necessary
  12281. if(this.containers[i].containerCache.over) {
  12282. this.containers[i]._trigger("out", event, this._uiHash(this));
  12283. this.containers[i].containerCache.over = 0;
  12284. }
  12285. }
  12286. }
  12287. // if no intersecting containers found, return
  12288. if(!innermostContainer) {
  12289. return;
  12290. }
  12291. // move the item into the container if it's not there already
  12292. if(this.containers.length === 1) {
  12293. if (!this.containers[innermostIndex].containerCache.over) {
  12294. this.containers[innermostIndex]._trigger("over", event, this._uiHash(this));
  12295. this.containers[innermostIndex].containerCache.over = 1;
  12296. }
  12297. } else {
  12298. //When entering a new container, we will find the item with the least distance and append our item near it
  12299. dist = 10000;
  12300. itemWithLeastDistance = null;
  12301. floating = innermostContainer.floating || this._isFloating(this.currentItem);
  12302. posProperty = floating ? "left" : "top";
  12303. sizeProperty = floating ? "width" : "height";
  12304. axis = floating ? "clientX" : "clientY";
  12305. for (j = this.items.length - 1; j >= 0; j--) {
  12306. if(!$.contains(this.containers[innermostIndex].element[0], this.items[j].item[0])) {
  12307. continue;
  12308. }
  12309. if(this.items[j].item[0] === this.currentItem[0]) {
  12310. continue;
  12311. }
  12312. cur = this.items[j].item.offset()[posProperty];
  12313. nearBottom = false;
  12314. if ( event[ axis ] - cur > this.items[ j ][ sizeProperty ] / 2 ) {
  12315. nearBottom = true;
  12316. }
  12317. if ( Math.abs( event[ axis ] - cur ) < dist ) {
  12318. dist = Math.abs( event[ axis ] - cur );
  12319. itemWithLeastDistance = this.items[ j ];
  12320. this.direction = nearBottom ? "up": "down";
  12321. }
  12322. }
  12323. //Check if dropOnEmpty is enabled
  12324. if(!itemWithLeastDistance && !this.options.dropOnEmpty) {
  12325. return;
  12326. }
  12327. if(this.currentContainer === this.containers[innermostIndex]) {
  12328. if ( !this.currentContainer.containerCache.over ) {
  12329. this.containers[ innermostIndex ]._trigger( "over", event, this._uiHash() );
  12330. this.currentContainer.containerCache.over = 1;
  12331. }
  12332. return;
  12333. }
  12334. itemWithLeastDistance ? this._rearrange(event, itemWithLeastDistance, null, true) : this._rearrange(event, null, this.containers[innermostIndex].element, true);
  12335. this._trigger("change", event, this._uiHash());
  12336. this.containers[innermostIndex]._trigger("change", event, this._uiHash(this));
  12337. this.currentContainer = this.containers[innermostIndex];
  12338. //Update the placeholder
  12339. this.options.placeholder.update(this.currentContainer, this.placeholder);
  12340. this.containers[innermostIndex]._trigger("over", event, this._uiHash(this));
  12341. this.containers[innermostIndex].containerCache.over = 1;
  12342. }
  12343. },
  12344. _createHelper: function(event) {
  12345. var o = this.options,
  12346. helper = $.isFunction(o.helper) ? $(o.helper.apply(this.element[0], [event, this.currentItem])) : (o.helper === "clone" ? this.currentItem.clone() : this.currentItem);
  12347. //Add the helper to the DOM if that didn't happen already
  12348. if(!helper.parents("body").length) {
  12349. $(o.appendTo !== "parent" ? o.appendTo : this.currentItem[0].parentNode)[0].appendChild(helper[0]);
  12350. }
  12351. if(helper[0] === this.currentItem[0]) {
  12352. 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") };
  12353. }
  12354. if(!helper[0].style.width || o.forceHelperSize) {
  12355. helper.width(this.currentItem.width());
  12356. }
  12357. if(!helper[0].style.height || o.forceHelperSize) {
  12358. helper.height(this.currentItem.height());
  12359. }
  12360. return helper;
  12361. },
  12362. _adjustOffsetFromHelper: function(obj) {
  12363. if (typeof obj === "string") {
  12364. obj = obj.split(" ");
  12365. }
  12366. if ($.isArray(obj)) {
  12367. obj = {left: +obj[0], top: +obj[1] || 0};
  12368. }
  12369. if ("left" in obj) {
  12370. this.offset.click.left = obj.left + this.margins.left;
  12371. }
  12372. if ("right" in obj) {
  12373. this.offset.click.left = this.helperProportions.width - obj.right + this.margins.left;
  12374. }
  12375. if ("top" in obj) {
  12376. this.offset.click.top = obj.top + this.margins.top;
  12377. }
  12378. if ("bottom" in obj) {
  12379. this.offset.click.top = this.helperProportions.height - obj.bottom + this.margins.top;
  12380. }
  12381. },
  12382. _getParentOffset: function() {
  12383. //Get the offsetParent and cache its position
  12384. this.offsetParent = this.helper.offsetParent();
  12385. var po = this.offsetParent.offset();
  12386. // This is a special case where we need to modify a offset calculated on start, since the following happened:
  12387. // 1. The position of the helper is absolute, so it's position is calculated based on the next positioned parent
  12388. // 2. The actual offset parent is a child of the scroll parent, and the scroll parent isn't the document, which means that
  12389. // the scroll is included in the initial calculation of the offset of the parent, and never recalculated upon drag
  12390. if(this.cssPosition === "absolute" && this.scrollParent[0] !== document && $.contains(this.scrollParent[0], this.offsetParent[0])) {
  12391. po.left += this.scrollParent.scrollLeft();
  12392. po.top += this.scrollParent.scrollTop();
  12393. }
  12394. // This needs to be actually done for all browsers, since pageX/pageY includes this information
  12395. // with an ugly IE fix
  12396. if( this.offsetParent[0] === document.body || (this.offsetParent[0].tagName && this.offsetParent[0].tagName.toLowerCase() === "html" && $.ui.ie)) {
  12397. po = { top: 0, left: 0 };
  12398. }
  12399. return {
  12400. top: po.top + (parseInt(this.offsetParent.css("borderTopWidth"),10) || 0),
  12401. left: po.left + (parseInt(this.offsetParent.css("borderLeftWidth"),10) || 0)
  12402. };
  12403. },
  12404. _getRelativeOffset: function() {
  12405. if(this.cssPosition === "relative") {
  12406. var p = this.currentItem.position();
  12407. return {
  12408. top: p.top - (parseInt(this.helper.css("top"),10) || 0) + this.scrollParent.scrollTop(),
  12409. left: p.left - (parseInt(this.helper.css("left"),10) || 0) + this.scrollParent.scrollLeft()
  12410. };
  12411. } else {
  12412. return { top: 0, left: 0 };
  12413. }
  12414. },
  12415. _cacheMargins: function() {
  12416. this.margins = {
  12417. left: (parseInt(this.currentItem.css("marginLeft"),10) || 0),
  12418. top: (parseInt(this.currentItem.css("marginTop"),10) || 0)
  12419. };
  12420. },
  12421. _cacheHelperProportions: function() {
  12422. this.helperProportions = {
  12423. width: this.helper.outerWidth(),
  12424. height: this.helper.outerHeight()
  12425. };
  12426. },
  12427. _setContainment: function() {
  12428. var ce, co, over,
  12429. o = this.options;
  12430. if(o.containment === "parent") {
  12431. o.containment = this.helper[0].parentNode;
  12432. }
  12433. if(o.containment === "document" || o.containment === "window") {
  12434. this.containment = [
  12435. 0 - this.offset.relative.left - this.offset.parent.left,
  12436. 0 - this.offset.relative.top - this.offset.parent.top,
  12437. $(o.containment === "document" ? document : window).width() - this.helperProportions.width - this.margins.left,
  12438. ($(o.containment === "document" ? document : window).height() || document.body.parentNode.scrollHeight) - this.helperProportions.height - this.margins.top
  12439. ];
  12440. }
  12441. if(!(/^(document|window|parent)$/).test(o.containment)) {
  12442. ce = $(o.containment)[0];
  12443. co = $(o.containment).offset();
  12444. over = ($(ce).css("overflow") !== "hidden");
  12445. this.containment = [
  12446. co.left + (parseInt($(ce).css("borderLeftWidth"),10) || 0) + (parseInt($(ce).css("paddingLeft"),10) || 0) - this.margins.left,
  12447. co.top + (parseInt($(ce).css("borderTopWidth"),10) || 0) + (parseInt($(ce).css("paddingTop"),10) || 0) - this.margins.top,
  12448. 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,
  12449. 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
  12450. ];
  12451. }
  12452. },
  12453. _convertPositionTo: function(d, pos) {
  12454. if(!pos) {
  12455. pos = this.position;
  12456. }
  12457. var mod = d === "absolute" ? 1 : -1,
  12458. scroll = this.cssPosition === "absolute" && !(this.scrollParent[0] !== document && $.contains(this.scrollParent[0], this.offsetParent[0])) ? this.offsetParent : this.scrollParent,
  12459. scrollIsRootNode = (/(html|body)/i).test(scroll[0].tagName);
  12460. return {
  12461. top: (
  12462. pos.top + // The absolute mouse position
  12463. this.offset.relative.top * mod + // Only for relative positioned nodes: Relative offset from element to offset parent
  12464. this.offset.parent.top * mod - // The offsetParent's offset without borders (offset + border)
  12465. ( ( this.cssPosition === "fixed" ? -this.scrollParent.scrollTop() : ( scrollIsRootNode ? 0 : scroll.scrollTop() ) ) * mod)
  12466. ),
  12467. left: (
  12468. pos.left + // The absolute mouse position
  12469. this.offset.relative.left * mod + // Only for relative positioned nodes: Relative offset from element to offset parent
  12470. this.offset.parent.left * mod - // The offsetParent's offset without borders (offset + border)
  12471. ( ( this.cssPosition === "fixed" ? -this.scrollParent.scrollLeft() : scrollIsRootNode ? 0 : scroll.scrollLeft() ) * mod)
  12472. )
  12473. };
  12474. },
  12475. _generatePosition: function(event) {
  12476. var top, left,
  12477. o = this.options,
  12478. pageX = event.pageX,
  12479. pageY = event.pageY,
  12480. scroll = this.cssPosition === "absolute" && !(this.scrollParent[0] !== document && $.contains(this.scrollParent[0], this.offsetParent[0])) ? this.offsetParent : this.scrollParent, scrollIsRootNode = (/(html|body)/i).test(scroll[0].tagName);
  12481. // This is another very weird special case that only happens for relative elements:
  12482. // 1. If the css position is relative
  12483. // 2. and the scroll parent is the document or similar to the offset parent
  12484. // we have to refresh the relative offset during the scroll so there are no jumps
  12485. if(this.cssPosition === "relative" && !(this.scrollParent[0] !== document && this.scrollParent[0] !== this.offsetParent[0])) {
  12486. this.offset.relative = this._getRelativeOffset();
  12487. }
  12488. /*
  12489. * - Position constraining -
  12490. * Constrain the position to a mix of grid, containment.
  12491. */
  12492. if(this.originalPosition) { //If we are not dragging yet, we won't check for options
  12493. if(this.containment) {
  12494. if(event.pageX - this.offset.click.left < this.containment[0]) {
  12495. pageX = this.containment[0] + this.offset.click.left;
  12496. }
  12497. if(event.pageY - this.offset.click.top < this.containment[1]) {
  12498. pageY = this.containment[1] + this.offset.click.top;
  12499. }
  12500. if(event.pageX - this.offset.click.left > this.containment[2]) {
  12501. pageX = this.containment[2] + this.offset.click.left;
  12502. }
  12503. if(event.pageY - this.offset.click.top > this.containment[3]) {
  12504. pageY = this.containment[3] + this.offset.click.top;
  12505. }
  12506. }
  12507. if(o.grid) {
  12508. top = this.originalPageY + Math.round((pageY - this.originalPageY) / o.grid[1]) * o.grid[1];
  12509. 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;
  12510. left = this.originalPageX + Math.round((pageX - this.originalPageX) / o.grid[0]) * o.grid[0];
  12511. 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;
  12512. }
  12513. }
  12514. return {
  12515. top: (
  12516. pageY - // The absolute mouse position
  12517. this.offset.click.top - // Click offset (relative to the element)
  12518. this.offset.relative.top - // Only for relative positioned nodes: Relative offset from element to offset parent
  12519. this.offset.parent.top + // The offsetParent's offset without borders (offset + border)
  12520. ( ( this.cssPosition === "fixed" ? -this.scrollParent.scrollTop() : ( scrollIsRootNode ? 0 : scroll.scrollTop() ) ))
  12521. ),
  12522. left: (
  12523. pageX - // The absolute mouse position
  12524. this.offset.click.left - // Click offset (relative to the element)
  12525. this.offset.relative.left - // Only for relative positioned nodes: Relative offset from element to offset parent
  12526. this.offset.parent.left + // The offsetParent's offset without borders (offset + border)
  12527. ( ( this.cssPosition === "fixed" ? -this.scrollParent.scrollLeft() : scrollIsRootNode ? 0 : scroll.scrollLeft() ))
  12528. )
  12529. };
  12530. },
  12531. _rearrange: function(event, i, a, hardRefresh) {
  12532. 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));
  12533. //Various things done here to improve the performance:
  12534. // 1. we create a setTimeout, that calls refreshPositions
  12535. // 2. on the instance, we have a counter variable, that get's higher after every append
  12536. // 3. on the local scope, we copy the counter variable, and check in the timeout, if it's still the same
  12537. // 4. this lets only the last addition to the timeout stack through
  12538. this.counter = this.counter ? ++this.counter : 1;
  12539. var counter = this.counter;
  12540. this._delay(function() {
  12541. if(counter === this.counter) {
  12542. this.refreshPositions(!hardRefresh); //Precompute after each DOM insertion, NOT on mousemove
  12543. }
  12544. });
  12545. },
  12546. _clear: function(event, noPropagation) {
  12547. this.reverting = false;
  12548. // We delay all events that have to be triggered to after the point where the placeholder has been removed and
  12549. // everything else normalized again
  12550. var i,
  12551. delayedTriggers = [];
  12552. // We first have to update the dom position of the actual currentItem
  12553. // Note: don't do it if the current item is already removed (by a user), or it gets reappended (see #4088)
  12554. if(!this._noFinalSort && this.currentItem.parent().length) {
  12555. this.placeholder.before(this.currentItem);
  12556. }
  12557. this._noFinalSort = null;
  12558. if(this.helper[0] === this.currentItem[0]) {
  12559. for(i in this._storedCSS) {
  12560. if(this._storedCSS[i] === "auto" || this._storedCSS[i] === "static") {
  12561. this._storedCSS[i] = "";
  12562. }
  12563. }
  12564. this.currentItem.css(this._storedCSS).removeClass("ui-sortable-helper");
  12565. } else {
  12566. this.currentItem.show();
  12567. }
  12568. if(this.fromOutside && !noPropagation) {
  12569. delayedTriggers.push(function(event) { this._trigger("receive", event, this._uiHash(this.fromOutside)); });
  12570. }
  12571. if((this.fromOutside || this.domPosition.prev !== this.currentItem.prev().not(".ui-sortable-helper")[0] || this.domPosition.parent !== this.currentItem.parent()[0]) && !noPropagation) {
  12572. delayedTriggers.push(function(event) { this._trigger("update", event, this._uiHash()); }); //Trigger update callback if the DOM position has changed
  12573. }
  12574. // Check if the items Container has Changed and trigger appropriate
  12575. // events.
  12576. if (this !== this.currentContainer) {
  12577. if(!noPropagation) {
  12578. delayedTriggers.push(function(event) { this._trigger("remove", event, this._uiHash()); });
  12579. delayedTriggers.push((function(c) { return function(event) { c._trigger("receive", event, this._uiHash(this)); }; }).call(this, this.currentContainer));
  12580. delayedTriggers.push((function(c) { return function(event) { c._trigger("update", event, this._uiHash(this)); }; }).call(this, this.currentContainer));
  12581. }
  12582. }
  12583. //Post events to containers
  12584. function delayEvent( type, instance, container ) {
  12585. return function( event ) {
  12586. container._trigger( type, event, instance._uiHash( instance ) );
  12587. };
  12588. }
  12589. for (i = this.containers.length - 1; i >= 0; i--){
  12590. if (!noPropagation) {
  12591. delayedTriggers.push( delayEvent( "deactivate", this, this.containers[ i ] ) );
  12592. }
  12593. if(this.containers[i].containerCache.over) {
  12594. delayedTriggers.push( delayEvent( "out", this, this.containers[ i ] ) );
  12595. this.containers[i].containerCache.over = 0;
  12596. }
  12597. }
  12598. //Do what was originally in plugins
  12599. if ( this.storedCursor ) {
  12600. this.document.find( "body" ).css( "cursor", this.storedCursor );
  12601. this.storedStylesheet.remove();
  12602. }
  12603. if(this._storedOpacity) {
  12604. this.helper.css("opacity", this._storedOpacity);
  12605. }
  12606. if(this._storedZIndex) {
  12607. this.helper.css("zIndex", this._storedZIndex === "auto" ? "" : this._storedZIndex);
  12608. }
  12609. this.dragging = false;
  12610. if(!noPropagation) {
  12611. this._trigger("beforeStop", event, this._uiHash());
  12612. }
  12613. //$(this.placeholder[0]).remove(); would have been the jQuery way - unfortunately, it unbinds ALL events from the original node!
  12614. this.placeholder[0].parentNode.removeChild(this.placeholder[0]);
  12615. if ( !this.cancelHelperRemoval ) {
  12616. if ( this.helper[ 0 ] !== this.currentItem[ 0 ] ) {
  12617. this.helper.remove();
  12618. }
  12619. this.helper = null;
  12620. }
  12621. if(!noPropagation) {
  12622. for (i=0; i < delayedTriggers.length; i++) {
  12623. delayedTriggers[i].call(this, event);
  12624. } //Trigger all delayed events
  12625. this._trigger("stop", event, this._uiHash());
  12626. }
  12627. this.fromOutside = false;
  12628. return !this.cancelHelperRemoval;
  12629. },
  12630. _trigger: function() {
  12631. if ($.Widget.prototype._trigger.apply(this, arguments) === false) {
  12632. this.cancel();
  12633. }
  12634. },
  12635. _uiHash: function(_inst) {
  12636. var inst = _inst || this;
  12637. return {
  12638. helper: inst.helper,
  12639. placeholder: inst.placeholder || $([]),
  12640. position: inst.position,
  12641. originalPosition: inst.originalPosition,
  12642. offset: inst.positionAbs,
  12643. item: inst.currentItem,
  12644. sender: _inst ? _inst.element : null
  12645. };
  12646. }
  12647. });
  12648. /*!
  12649. * jQuery UI Spinner 1.11.2
  12650. * http://jqueryui.com
  12651. *
  12652. * Copyright 2014 jQuery Foundation and other contributors
  12653. * Released under the MIT license.
  12654. * http://jquery.org/license
  12655. *
  12656. * http://api.jqueryui.com/spinner/
  12657. */
  12658. function spinner_modifier( fn ) {
  12659. return function() {
  12660. var previous = this.element.val();
  12661. fn.apply( this, arguments );
  12662. this._refresh();
  12663. if ( previous !== this.element.val() ) {
  12664. this._trigger( "change" );
  12665. }
  12666. };
  12667. }
  12668. var spinner = $.widget( "ui.spinner", {
  12669. version: "1.11.2",
  12670. defaultElement: "<input>",
  12671. widgetEventPrefix: "spin",
  12672. options: {
  12673. culture: null,
  12674. icons: {
  12675. down: "ui-icon-triangle-1-s",
  12676. up: "ui-icon-triangle-1-n"
  12677. },
  12678. incremental: true,
  12679. max: null,
  12680. min: null,
  12681. numberFormat: null,
  12682. page: 10,
  12683. step: 1,
  12684. change: null,
  12685. spin: null,
  12686. start: null,
  12687. stop: null
  12688. },
  12689. _create: function() {
  12690. // handle string values that need to be parsed
  12691. this._setOption( "max", this.options.max );
  12692. this._setOption( "min", this.options.min );
  12693. this._setOption( "step", this.options.step );
  12694. // Only format if there is a value, prevents the field from being marked
  12695. // as invalid in Firefox, see #9573.
  12696. if ( this.value() !== "" ) {
  12697. // Format the value, but don't constrain.
  12698. this._value( this.element.val(), true );
  12699. }
  12700. this._draw();
  12701. this._on( this._events );
  12702. this._refresh();
  12703. // turning off autocomplete prevents the browser from remembering the
  12704. // value when navigating through history, so we re-enable autocomplete
  12705. // if the page is unloaded before the widget is destroyed. #7790
  12706. this._on( this.window, {
  12707. beforeunload: function() {
  12708. this.element.removeAttr( "autocomplete" );
  12709. }
  12710. });
  12711. },
  12712. _getCreateOptions: function() {
  12713. var options = {},
  12714. element = this.element;
  12715. $.each( [ "min", "max", "step" ], function( i, option ) {
  12716. var value = element.attr( option );
  12717. if ( value !== undefined && value.length ) {
  12718. options[ option ] = value;
  12719. }
  12720. });
  12721. return options;
  12722. },
  12723. _events: {
  12724. keydown: function( event ) {
  12725. if ( this._start( event ) && this._keydown( event ) ) {
  12726. event.preventDefault();
  12727. }
  12728. },
  12729. keyup: "_stop",
  12730. focus: function() {
  12731. this.previous = this.element.val();
  12732. },
  12733. blur: function( event ) {
  12734. if ( this.cancelBlur ) {
  12735. delete this.cancelBlur;
  12736. return;
  12737. }
  12738. this._stop();
  12739. this._refresh();
  12740. if ( this.previous !== this.element.val() ) {
  12741. this._trigger( "change", event );
  12742. }
  12743. },
  12744. mousewheel: function( event, delta ) {
  12745. if ( !delta ) {
  12746. return;
  12747. }
  12748. if ( !this.spinning && !this._start( event ) ) {
  12749. return false;
  12750. }
  12751. this._spin( (delta > 0 ? 1 : -1) * this.options.step, event );
  12752. clearTimeout( this.mousewheelTimer );
  12753. this.mousewheelTimer = this._delay(function() {
  12754. if ( this.spinning ) {
  12755. this._stop( event );
  12756. }
  12757. }, 100 );
  12758. event.preventDefault();
  12759. },
  12760. "mousedown .ui-spinner-button": function( event ) {
  12761. var previous;
  12762. // We never want the buttons to have focus; whenever the user is
  12763. // interacting with the spinner, the focus should be on the input.
  12764. // If the input is focused then this.previous is properly set from
  12765. // when the input first received focus. If the input is not focused
  12766. // then we need to set this.previous based on the value before spinning.
  12767. previous = this.element[0] === this.document[0].activeElement ?
  12768. this.previous : this.element.val();
  12769. function checkFocus() {
  12770. var isActive = this.element[0] === this.document[0].activeElement;
  12771. if ( !isActive ) {
  12772. this.element.focus();
  12773. this.previous = previous;
  12774. // support: IE
  12775. // IE sets focus asynchronously, so we need to check if focus
  12776. // moved off of the input because the user clicked on the button.
  12777. this._delay(function() {
  12778. this.previous = previous;
  12779. });
  12780. }
  12781. }
  12782. // ensure focus is on (or stays on) the text field
  12783. event.preventDefault();
  12784. checkFocus.call( this );
  12785. // support: IE
  12786. // IE doesn't prevent moving focus even with event.preventDefault()
  12787. // so we set a flag to know when we should ignore the blur event
  12788. // and check (again) if focus moved off of the input.
  12789. this.cancelBlur = true;
  12790. this._delay(function() {
  12791. delete this.cancelBlur;
  12792. checkFocus.call( this );
  12793. });
  12794. if ( this._start( event ) === false ) {
  12795. return;
  12796. }
  12797. this._repeat( null, $( event.currentTarget ).hasClass( "ui-spinner-up" ) ? 1 : -1, event );
  12798. },
  12799. "mouseup .ui-spinner-button": "_stop",
  12800. "mouseenter .ui-spinner-button": function( event ) {
  12801. // button will add ui-state-active if mouse was down while mouseleave and kept down
  12802. if ( !$( event.currentTarget ).hasClass( "ui-state-active" ) ) {
  12803. return;
  12804. }
  12805. if ( this._start( event ) === false ) {
  12806. return false;
  12807. }
  12808. this._repeat( null, $( event.currentTarget ).hasClass( "ui-spinner-up" ) ? 1 : -1, event );
  12809. },
  12810. // TODO: do we really want to consider this a stop?
  12811. // shouldn't we just stop the repeater and wait until mouseup before
  12812. // we trigger the stop event?
  12813. "mouseleave .ui-spinner-button": "_stop"
  12814. },
  12815. _draw: function() {
  12816. var uiSpinner = this.uiSpinner = this.element
  12817. .addClass( "ui-spinner-input" )
  12818. .attr( "autocomplete", "off" )
  12819. .wrap( this._uiSpinnerHtml() )
  12820. .parent()
  12821. // add buttons
  12822. .append( this._buttonHtml() );
  12823. this.element.attr( "role", "spinbutton" );
  12824. // button bindings
  12825. this.buttons = uiSpinner.find( ".ui-spinner-button" )
  12826. .attr( "tabIndex", -1 )
  12827. .button()
  12828. .removeClass( "ui-corner-all" );
  12829. // IE 6 doesn't understand height: 50% for the buttons
  12830. // unless the wrapper has an explicit height
  12831. if ( this.buttons.height() > Math.ceil( uiSpinner.height() * 0.5 ) &&
  12832. uiSpinner.height() > 0 ) {
  12833. uiSpinner.height( uiSpinner.height() );
  12834. }
  12835. // disable spinner if element was already disabled
  12836. if ( this.options.disabled ) {
  12837. this.disable();
  12838. }
  12839. },
  12840. _keydown: function( event ) {
  12841. var options = this.options,
  12842. keyCode = $.ui.keyCode;
  12843. switch ( event.keyCode ) {
  12844. case keyCode.UP:
  12845. this._repeat( null, 1, event );
  12846. return true;
  12847. case keyCode.DOWN:
  12848. this._repeat( null, -1, event );
  12849. return true;
  12850. case keyCode.PAGE_UP:
  12851. this._repeat( null, options.page, event );
  12852. return true;
  12853. case keyCode.PAGE_DOWN:
  12854. this._repeat( null, -options.page, event );
  12855. return true;
  12856. }
  12857. return false;
  12858. },
  12859. _uiSpinnerHtml: function() {
  12860. return "<span class='ui-spinner ui-widget ui-widget-content ui-corner-all'></span>";
  12861. },
  12862. _buttonHtml: function() {
  12863. return "" +
  12864. "<a class='ui-spinner-button ui-spinner-up ui-corner-tr'>" +
  12865. "<span class='ui-icon " + this.options.icons.up + "'>&#9650;</span>" +
  12866. "</a>" +
  12867. "<a class='ui-spinner-button ui-spinner-down ui-corner-br'>" +
  12868. "<span class='ui-icon " + this.options.icons.down + "'>&#9660;</span>" +
  12869. "</a>";
  12870. },
  12871. _start: function( event ) {
  12872. if ( !this.spinning && this._trigger( "start", event ) === false ) {
  12873. return false;
  12874. }
  12875. if ( !this.counter ) {
  12876. this.counter = 1;
  12877. }
  12878. this.spinning = true;
  12879. return true;
  12880. },
  12881. _repeat: function( i, steps, event ) {
  12882. i = i || 500;
  12883. clearTimeout( this.timer );
  12884. this.timer = this._delay(function() {
  12885. this._repeat( 40, steps, event );
  12886. }, i );
  12887. this._spin( steps * this.options.step, event );
  12888. },
  12889. _spin: function( step, event ) {
  12890. var value = this.value() || 0;
  12891. if ( !this.counter ) {
  12892. this.counter = 1;
  12893. }
  12894. value = this._adjustValue( value + step * this._increment( this.counter ) );
  12895. if ( !this.spinning || this._trigger( "spin", event, { value: value } ) !== false) {
  12896. this._value( value );
  12897. this.counter++;
  12898. }
  12899. },
  12900. _increment: function( i ) {
  12901. var incremental = this.options.incremental;
  12902. if ( incremental ) {
  12903. return $.isFunction( incremental ) ?
  12904. incremental( i ) :
  12905. Math.floor( i * i * i / 50000 - i * i / 500 + 17 * i / 200 + 1 );
  12906. }
  12907. return 1;
  12908. },
  12909. _precision: function() {
  12910. var precision = this._precisionOf( this.options.step );
  12911. if ( this.options.min !== null ) {
  12912. precision = Math.max( precision, this._precisionOf( this.options.min ) );
  12913. }
  12914. return precision;
  12915. },
  12916. _precisionOf: function( num ) {
  12917. var str = num.toString(),
  12918. decimal = str.indexOf( "." );
  12919. return decimal === -1 ? 0 : str.length - decimal - 1;
  12920. },
  12921. _adjustValue: function( value ) {
  12922. var base, aboveMin,
  12923. options = this.options;
  12924. // make sure we're at a valid step
  12925. // - find out where we are relative to the base (min or 0)
  12926. base = options.min !== null ? options.min : 0;
  12927. aboveMin = value - base;
  12928. // - round to the nearest step
  12929. aboveMin = Math.round(aboveMin / options.step) * options.step;
  12930. // - rounding is based on 0, so adjust back to our base
  12931. value = base + aboveMin;
  12932. // fix precision from bad JS floating point math
  12933. value = parseFloat( value.toFixed( this._precision() ) );
  12934. // clamp the value
  12935. if ( options.max !== null && value > options.max) {
  12936. return options.max;
  12937. }
  12938. if ( options.min !== null && value < options.min ) {
  12939. return options.min;
  12940. }
  12941. return value;
  12942. },
  12943. _stop: function( event ) {
  12944. if ( !this.spinning ) {
  12945. return;
  12946. }
  12947. clearTimeout( this.timer );
  12948. clearTimeout( this.mousewheelTimer );
  12949. this.counter = 0;
  12950. this.spinning = false;
  12951. this._trigger( "stop", event );
  12952. },
  12953. _setOption: function( key, value ) {
  12954. if ( key === "culture" || key === "numberFormat" ) {
  12955. var prevValue = this._parse( this.element.val() );
  12956. this.options[ key ] = value;
  12957. this.element.val( this._format( prevValue ) );
  12958. return;
  12959. }
  12960. if ( key === "max" || key === "min" || key === "step" ) {
  12961. if ( typeof value === "string" ) {
  12962. value = this._parse( value );
  12963. }
  12964. }
  12965. if ( key === "icons" ) {
  12966. this.buttons.first().find( ".ui-icon" )
  12967. .removeClass( this.options.icons.up )
  12968. .addClass( value.up );
  12969. this.buttons.last().find( ".ui-icon" )
  12970. .removeClass( this.options.icons.down )
  12971. .addClass( value.down );
  12972. }
  12973. this._super( key, value );
  12974. if ( key === "disabled" ) {
  12975. this.widget().toggleClass( "ui-state-disabled", !!value );
  12976. this.element.prop( "disabled", !!value );
  12977. this.buttons.button( value ? "disable" : "enable" );
  12978. }
  12979. },
  12980. _setOptions: spinner_modifier(function( options ) {
  12981. this._super( options );
  12982. }),
  12983. _parse: function( val ) {
  12984. if ( typeof val === "string" && val !== "" ) {
  12985. val = window.Globalize && this.options.numberFormat ?
  12986. Globalize.parseFloat( val, 10, this.options.culture ) : +val;
  12987. }
  12988. return val === "" || isNaN( val ) ? null : val;
  12989. },
  12990. _format: function( value ) {
  12991. if ( value === "" ) {
  12992. return "";
  12993. }
  12994. return window.Globalize && this.options.numberFormat ?
  12995. Globalize.format( value, this.options.numberFormat, this.options.culture ) :
  12996. value;
  12997. },
  12998. _refresh: function() {
  12999. this.element.attr({
  13000. "aria-valuemin": this.options.min,
  13001. "aria-valuemax": this.options.max,
  13002. // TODO: what should we do with values that can't be parsed?
  13003. "aria-valuenow": this._parse( this.element.val() )
  13004. });
  13005. },
  13006. isValid: function() {
  13007. var value = this.value();
  13008. // null is invalid
  13009. if ( value === null ) {
  13010. return false;
  13011. }
  13012. // if value gets adjusted, it's invalid
  13013. return value === this._adjustValue( value );
  13014. },
  13015. // update the value without triggering change
  13016. _value: function( value, allowAny ) {
  13017. var parsed;
  13018. if ( value !== "" ) {
  13019. parsed = this._parse( value );
  13020. if ( parsed !== null ) {
  13021. if ( !allowAny ) {
  13022. parsed = this._adjustValue( parsed );
  13023. }
  13024. value = this._format( parsed );
  13025. }
  13026. }
  13027. this.element.val( value );
  13028. this._refresh();
  13029. },
  13030. _destroy: function() {
  13031. this.element
  13032. .removeClass( "ui-spinner-input" )
  13033. .prop( "disabled", false )
  13034. .removeAttr( "autocomplete" )
  13035. .removeAttr( "role" )
  13036. .removeAttr( "aria-valuemin" )
  13037. .removeAttr( "aria-valuemax" )
  13038. .removeAttr( "aria-valuenow" );
  13039. this.uiSpinner.replaceWith( this.element );
  13040. },
  13041. stepUp: spinner_modifier(function( steps ) {
  13042. this._stepUp( steps );
  13043. }),
  13044. _stepUp: function( steps ) {
  13045. if ( this._start() ) {
  13046. this._spin( (steps || 1) * this.options.step );
  13047. this._stop();
  13048. }
  13049. },
  13050. stepDown: spinner_modifier(function( steps ) {
  13051. this._stepDown( steps );
  13052. }),
  13053. _stepDown: function( steps ) {
  13054. if ( this._start() ) {
  13055. this._spin( (steps || 1) * -this.options.step );
  13056. this._stop();
  13057. }
  13058. },
  13059. pageUp: spinner_modifier(function( pages ) {
  13060. this._stepUp( (pages || 1) * this.options.page );
  13061. }),
  13062. pageDown: spinner_modifier(function( pages ) {
  13063. this._stepDown( (pages || 1) * this.options.page );
  13064. }),
  13065. value: function( newVal ) {
  13066. if ( !arguments.length ) {
  13067. return this._parse( this.element.val() );
  13068. }
  13069. spinner_modifier( this._value ).call( this, newVal );
  13070. },
  13071. widget: function() {
  13072. return this.uiSpinner;
  13073. }
  13074. });
  13075. /*!
  13076. * jQuery UI Tabs 1.11.2
  13077. * http://jqueryui.com
  13078. *
  13079. * Copyright 2014 jQuery Foundation and other contributors
  13080. * Released under the MIT license.
  13081. * http://jquery.org/license
  13082. *
  13083. * http://api.jqueryui.com/tabs/
  13084. */
  13085. var tabs = $.widget( "ui.tabs", {
  13086. version: "1.11.2",
  13087. delay: 300,
  13088. options: {
  13089. active: null,
  13090. collapsible: false,
  13091. event: "click",
  13092. heightStyle: "content",
  13093. hide: null,
  13094. show: null,
  13095. // callbacks
  13096. activate: null,
  13097. beforeActivate: null,
  13098. beforeLoad: null,
  13099. load: null
  13100. },
  13101. _isLocal: (function() {
  13102. var rhash = /#.*$/;
  13103. return function( anchor ) {
  13104. var anchorUrl, locationUrl;
  13105. // support: IE7
  13106. // IE7 doesn't normalize the href property when set via script (#9317)
  13107. anchor = anchor.cloneNode( false );
  13108. anchorUrl = anchor.href.replace( rhash, "" );
  13109. locationUrl = location.href.replace( rhash, "" );
  13110. // decoding may throw an error if the URL isn't UTF-8 (#9518)
  13111. try {
  13112. anchorUrl = decodeURIComponent( anchorUrl );
  13113. } catch ( error ) {}
  13114. try {
  13115. locationUrl = decodeURIComponent( locationUrl );
  13116. } catch ( error ) {}
  13117. return anchor.hash.length > 1 && anchorUrl === locationUrl;
  13118. };
  13119. })(),
  13120. _create: function() {
  13121. var that = this,
  13122. options = this.options;
  13123. this.running = false;
  13124. this.element
  13125. .addClass( "ui-tabs ui-widget ui-widget-content ui-corner-all" )
  13126. .toggleClass( "ui-tabs-collapsible", options.collapsible );
  13127. this._processTabs();
  13128. options.active = this._initialActive();
  13129. // Take disabling tabs via class attribute from HTML
  13130. // into account and update option properly.
  13131. if ( $.isArray( options.disabled ) ) {
  13132. options.disabled = $.unique( options.disabled.concat(
  13133. $.map( this.tabs.filter( ".ui-state-disabled" ), function( li ) {
  13134. return that.tabs.index( li );
  13135. })
  13136. ) ).sort();
  13137. }
  13138. // check for length avoids error when initializing empty list
  13139. if ( this.options.active !== false && this.anchors.length ) {
  13140. this.active = this._findActive( options.active );
  13141. } else {
  13142. this.active = $();
  13143. }
  13144. this._refresh();
  13145. if ( this.active.length ) {
  13146. this.load( options.active );
  13147. }
  13148. },
  13149. _initialActive: function() {
  13150. var active = this.options.active,
  13151. collapsible = this.options.collapsible,
  13152. locationHash = location.hash.substring( 1 );
  13153. if ( active === null ) {
  13154. // check the fragment identifier in the URL
  13155. if ( locationHash ) {
  13156. this.tabs.each(function( i, tab ) {
  13157. if ( $( tab ).attr( "aria-controls" ) === locationHash ) {
  13158. active = i;
  13159. return false;
  13160. }
  13161. });
  13162. }
  13163. // check for a tab marked active via a class
  13164. if ( active === null ) {
  13165. active = this.tabs.index( this.tabs.filter( ".ui-tabs-active" ) );
  13166. }
  13167. // no active tab, set to false
  13168. if ( active === null || active === -1 ) {
  13169. active = this.tabs.length ? 0 : false;
  13170. }
  13171. }
  13172. // handle numbers: negative, out of range
  13173. if ( active !== false ) {
  13174. active = this.tabs.index( this.tabs.eq( active ) );
  13175. if ( active === -1 ) {
  13176. active = collapsible ? false : 0;
  13177. }
  13178. }
  13179. // don't allow collapsible: false and active: false
  13180. if ( !collapsible && active === false && this.anchors.length ) {
  13181. active = 0;
  13182. }
  13183. return active;
  13184. },
  13185. _getCreateEventData: function() {
  13186. return {
  13187. tab: this.active,
  13188. panel: !this.active.length ? $() : this._getPanelForTab( this.active )
  13189. };
  13190. },
  13191. _tabKeydown: function( event ) {
  13192. var focusedTab = $( this.document[0].activeElement ).closest( "li" ),
  13193. selectedIndex = this.tabs.index( focusedTab ),
  13194. goingForward = true;
  13195. if ( this._handlePageNav( event ) ) {
  13196. return;
  13197. }
  13198. switch ( event.keyCode ) {
  13199. case $.ui.keyCode.RIGHT:
  13200. case $.ui.keyCode.DOWN:
  13201. selectedIndex++;
  13202. break;
  13203. case $.ui.keyCode.UP:
  13204. case $.ui.keyCode.LEFT:
  13205. goingForward = false;
  13206. selectedIndex--;
  13207. break;
  13208. case $.ui.keyCode.END:
  13209. selectedIndex = this.anchors.length - 1;
  13210. break;
  13211. case $.ui.keyCode.HOME:
  13212. selectedIndex = 0;
  13213. break;
  13214. case $.ui.keyCode.SPACE:
  13215. // Activate only, no collapsing
  13216. event.preventDefault();
  13217. clearTimeout( this.activating );
  13218. this._activate( selectedIndex );
  13219. return;
  13220. case $.ui.keyCode.ENTER:
  13221. // Toggle (cancel delayed activation, allow collapsing)
  13222. event.preventDefault();
  13223. clearTimeout( this.activating );
  13224. // Determine if we should collapse or activate
  13225. this._activate( selectedIndex === this.options.active ? false : selectedIndex );
  13226. return;
  13227. default:
  13228. return;
  13229. }
  13230. // Focus the appropriate tab, based on which key was pressed
  13231. event.preventDefault();
  13232. clearTimeout( this.activating );
  13233. selectedIndex = this._focusNextTab( selectedIndex, goingForward );
  13234. // Navigating with control key will prevent automatic activation
  13235. if ( !event.ctrlKey ) {
  13236. // Update aria-selected immediately so that AT think the tab is already selected.
  13237. // Otherwise AT may confuse the user by stating that they need to activate the tab,
  13238. // but the tab will already be activated by the time the announcement finishes.
  13239. focusedTab.attr( "aria-selected", "false" );
  13240. this.tabs.eq( selectedIndex ).attr( "aria-selected", "true" );
  13241. this.activating = this._delay(function() {
  13242. this.option( "active", selectedIndex );
  13243. }, this.delay );
  13244. }
  13245. },
  13246. _panelKeydown: function( event ) {
  13247. if ( this._handlePageNav( event ) ) {
  13248. return;
  13249. }
  13250. // Ctrl+up moves focus to the current tab
  13251. if ( event.ctrlKey && event.keyCode === $.ui.keyCode.UP ) {
  13252. event.preventDefault();
  13253. this.active.focus();
  13254. }
  13255. },
  13256. // Alt+page up/down moves focus to the previous/next tab (and activates)
  13257. _handlePageNav: function( event ) {
  13258. if ( event.altKey && event.keyCode === $.ui.keyCode.PAGE_UP ) {
  13259. this._activate( this._focusNextTab( this.options.active - 1, false ) );
  13260. return true;
  13261. }
  13262. if ( event.altKey && event.keyCode === $.ui.keyCode.PAGE_DOWN ) {
  13263. this._activate( this._focusNextTab( this.options.active + 1, true ) );
  13264. return true;
  13265. }
  13266. },
  13267. _findNextTab: function( index, goingForward ) {
  13268. var lastTabIndex = this.tabs.length - 1;
  13269. function constrain() {
  13270. if ( index > lastTabIndex ) {
  13271. index = 0;
  13272. }
  13273. if ( index < 0 ) {
  13274. index = lastTabIndex;
  13275. }
  13276. return index;
  13277. }
  13278. while ( $.inArray( constrain(), this.options.disabled ) !== -1 ) {
  13279. index = goingForward ? index + 1 : index - 1;
  13280. }
  13281. return index;
  13282. },
  13283. _focusNextTab: function( index, goingForward ) {
  13284. index = this._findNextTab( index, goingForward );
  13285. this.tabs.eq( index ).focus();
  13286. return index;
  13287. },
  13288. _setOption: function( key, value ) {
  13289. if ( key === "active" ) {
  13290. // _activate() will handle invalid values and update this.options
  13291. this._activate( value );
  13292. return;
  13293. }
  13294. if ( key === "disabled" ) {
  13295. // don't use the widget factory's disabled handling
  13296. this._setupDisabled( value );
  13297. return;
  13298. }
  13299. this._super( key, value);
  13300. if ( key === "collapsible" ) {
  13301. this.element.toggleClass( "ui-tabs-collapsible", value );
  13302. // Setting collapsible: false while collapsed; open first panel
  13303. if ( !value && this.options.active === false ) {
  13304. this._activate( 0 );
  13305. }
  13306. }
  13307. if ( key === "event" ) {
  13308. this._setupEvents( value );
  13309. }
  13310. if ( key === "heightStyle" ) {
  13311. this._setupHeightStyle( value );
  13312. }
  13313. },
  13314. _sanitizeSelector: function( hash ) {
  13315. return hash ? hash.replace( /[!"$%&'()*+,.\/:;<=>?@\[\]\^`{|}~]/g, "\\$&" ) : "";
  13316. },
  13317. refresh: function() {
  13318. var options = this.options,
  13319. lis = this.tablist.children( ":has(a[href])" );
  13320. // get disabled tabs from class attribute from HTML
  13321. // this will get converted to a boolean if needed in _refresh()
  13322. options.disabled = $.map( lis.filter( ".ui-state-disabled" ), function( tab ) {
  13323. return lis.index( tab );
  13324. });
  13325. this._processTabs();
  13326. // was collapsed or no tabs
  13327. if ( options.active === false || !this.anchors.length ) {
  13328. options.active = false;
  13329. this.active = $();
  13330. // was active, but active tab is gone
  13331. } else if ( this.active.length && !$.contains( this.tablist[ 0 ], this.active[ 0 ] ) ) {
  13332. // all remaining tabs are disabled
  13333. if ( this.tabs.length === options.disabled.length ) {
  13334. options.active = false;
  13335. this.active = $();
  13336. // activate previous tab
  13337. } else {
  13338. this._activate( this._findNextTab( Math.max( 0, options.active - 1 ), false ) );
  13339. }
  13340. // was active, active tab still exists
  13341. } else {
  13342. // make sure active index is correct
  13343. options.active = this.tabs.index( this.active );
  13344. }
  13345. this._refresh();
  13346. },
  13347. _refresh: function() {
  13348. this._setupDisabled( this.options.disabled );
  13349. this._setupEvents( this.options.event );
  13350. this._setupHeightStyle( this.options.heightStyle );
  13351. this.tabs.not( this.active ).attr({
  13352. "aria-selected": "false",
  13353. "aria-expanded": "false",
  13354. tabIndex: -1
  13355. });
  13356. this.panels.not( this._getPanelForTab( this.active ) )
  13357. .hide()
  13358. .attr({
  13359. "aria-hidden": "true"
  13360. });
  13361. // Make sure one tab is in the tab order
  13362. if ( !this.active.length ) {
  13363. this.tabs.eq( 0 ).attr( "tabIndex", 0 );
  13364. } else {
  13365. this.active
  13366. .addClass( "ui-tabs-active ui-state-active" )
  13367. .attr({
  13368. "aria-selected": "true",
  13369. "aria-expanded": "true",
  13370. tabIndex: 0
  13371. });
  13372. this._getPanelForTab( this.active )
  13373. .show()
  13374. .attr({
  13375. "aria-hidden": "false"
  13376. });
  13377. }
  13378. },
  13379. _processTabs: function() {
  13380. var that = this,
  13381. prevTabs = this.tabs,
  13382. prevAnchors = this.anchors,
  13383. prevPanels = this.panels;
  13384. this.tablist = this._getList()
  13385. .addClass( "ui-tabs-nav ui-helper-reset ui-helper-clearfix ui-widget-header ui-corner-all" )
  13386. .attr( "role", "tablist" )
  13387. // Prevent users from focusing disabled tabs via click
  13388. .delegate( "> li", "mousedown" + this.eventNamespace, function( event ) {
  13389. if ( $( this ).is( ".ui-state-disabled" ) ) {
  13390. event.preventDefault();
  13391. }
  13392. })
  13393. // support: IE <9
  13394. // Preventing the default action in mousedown doesn't prevent IE
  13395. // from focusing the element, so if the anchor gets focused, blur.
  13396. // We don't have to worry about focusing the previously focused
  13397. // element since clicking on a non-focusable element should focus
  13398. // the body anyway.
  13399. .delegate( ".ui-tabs-anchor", "focus" + this.eventNamespace, function() {
  13400. if ( $( this ).closest( "li" ).is( ".ui-state-disabled" ) ) {
  13401. this.blur();
  13402. }
  13403. });
  13404. this.tabs = this.tablist.find( "> li:has(a[href])" )
  13405. .addClass( "ui-state-default ui-corner-top" )
  13406. .attr({
  13407. role: "tab",
  13408. tabIndex: -1
  13409. });
  13410. this.anchors = this.tabs.map(function() {
  13411. return $( "a", this )[ 0 ];
  13412. })
  13413. .addClass( "ui-tabs-anchor" )
  13414. .attr({
  13415. role: "presentation",
  13416. tabIndex: -1
  13417. });
  13418. this.panels = $();
  13419. this.anchors.each(function( i, anchor ) {
  13420. var selector, panel, panelId,
  13421. anchorId = $( anchor ).uniqueId().attr( "id" ),
  13422. tab = $( anchor ).closest( "li" ),
  13423. originalAriaControls = tab.attr( "aria-controls" );
  13424. // inline tab
  13425. if ( that._isLocal( anchor ) ) {
  13426. selector = anchor.hash;
  13427. panelId = selector.substring( 1 );
  13428. panel = that.element.find( that._sanitizeSelector( selector ) );
  13429. // remote tab
  13430. } else {
  13431. // If the tab doesn't already have aria-controls,
  13432. // generate an id by using a throw-away element
  13433. panelId = tab.attr( "aria-controls" ) || $( {} ).uniqueId()[ 0 ].id;
  13434. selector = "#" + panelId;
  13435. panel = that.element.find( selector );
  13436. if ( !panel.length ) {
  13437. panel = that._createPanel( panelId );
  13438. panel.insertAfter( that.panels[ i - 1 ] || that.tablist );
  13439. }
  13440. panel.attr( "aria-live", "polite" );
  13441. }
  13442. if ( panel.length) {
  13443. that.panels = that.panels.add( panel );
  13444. }
  13445. if ( originalAriaControls ) {
  13446. tab.data( "ui-tabs-aria-controls", originalAriaControls );
  13447. }
  13448. tab.attr({
  13449. "aria-controls": panelId,
  13450. "aria-labelledby": anchorId
  13451. });
  13452. panel.attr( "aria-labelledby", anchorId );
  13453. });
  13454. this.panels
  13455. .addClass( "ui-tabs-panel ui-widget-content ui-corner-bottom" )
  13456. .attr( "role", "tabpanel" );
  13457. // Avoid memory leaks (#10056)
  13458. if ( prevTabs ) {
  13459. this._off( prevTabs.not( this.tabs ) );
  13460. this._off( prevAnchors.not( this.anchors ) );
  13461. this._off( prevPanels.not( this.panels ) );
  13462. }
  13463. },
  13464. // allow overriding how to find the list for rare usage scenarios (#7715)
  13465. _getList: function() {
  13466. return this.tablist || this.element.find( "ol,ul" ).eq( 0 );
  13467. },
  13468. _createPanel: function( id ) {
  13469. return $( "<div>" )
  13470. .attr( "id", id )
  13471. .addClass( "ui-tabs-panel ui-widget-content ui-corner-bottom" )
  13472. .data( "ui-tabs-destroy", true );
  13473. },
  13474. _setupDisabled: function( disabled ) {
  13475. if ( $.isArray( disabled ) ) {
  13476. if ( !disabled.length ) {
  13477. disabled = false;
  13478. } else if ( disabled.length === this.anchors.length ) {
  13479. disabled = true;
  13480. }
  13481. }
  13482. // disable tabs
  13483. for ( var i = 0, li; ( li = this.tabs[ i ] ); i++ ) {
  13484. if ( disabled === true || $.inArray( i, disabled ) !== -1 ) {
  13485. $( li )
  13486. .addClass( "ui-state-disabled" )
  13487. .attr( "aria-disabled", "true" );
  13488. } else {
  13489. $( li )
  13490. .removeClass( "ui-state-disabled" )
  13491. .removeAttr( "aria-disabled" );
  13492. }
  13493. }
  13494. this.options.disabled = disabled;
  13495. },
  13496. _setupEvents: function( event ) {
  13497. var events = {};
  13498. if ( event ) {
  13499. $.each( event.split(" "), function( index, eventName ) {
  13500. events[ eventName ] = "_eventHandler";
  13501. });
  13502. }
  13503. this._off( this.anchors.add( this.tabs ).add( this.panels ) );
  13504. // Always prevent the default action, even when disabled
  13505. this._on( true, this.anchors, {
  13506. click: function( event ) {
  13507. event.preventDefault();
  13508. }
  13509. });
  13510. this._on( this.anchors, events );
  13511. this._on( this.tabs, { keydown: "_tabKeydown" } );
  13512. this._on( this.panels, { keydown: "_panelKeydown" } );
  13513. this._focusable( this.tabs );
  13514. this._hoverable( this.tabs );
  13515. },
  13516. _setupHeightStyle: function( heightStyle ) {
  13517. var maxHeight,
  13518. parent = this.element.parent();
  13519. if ( heightStyle === "fill" ) {
  13520. maxHeight = parent.height();
  13521. maxHeight -= this.element.outerHeight() - this.element.height();
  13522. this.element.siblings( ":visible" ).each(function() {
  13523. var elem = $( this ),
  13524. position = elem.css( "position" );
  13525. if ( position === "absolute" || position === "fixed" ) {
  13526. return;
  13527. }
  13528. maxHeight -= elem.outerHeight( true );
  13529. });
  13530. this.element.children().not( this.panels ).each(function() {
  13531. maxHeight -= $( this ).outerHeight( true );
  13532. });
  13533. this.panels.each(function() {
  13534. $( this ).height( Math.max( 0, maxHeight -
  13535. $( this ).innerHeight() + $( this ).height() ) );
  13536. })
  13537. .css( "overflow", "auto" );
  13538. } else if ( heightStyle === "auto" ) {
  13539. maxHeight = 0;
  13540. this.panels.each(function() {
  13541. maxHeight = Math.max( maxHeight, $( this ).height( "" ).height() );
  13542. }).height( maxHeight );
  13543. }
  13544. },
  13545. _eventHandler: function( event ) {
  13546. var options = this.options,
  13547. active = this.active,
  13548. anchor = $( event.currentTarget ),
  13549. tab = anchor.closest( "li" ),
  13550. clickedIsActive = tab[ 0 ] === active[ 0 ],
  13551. collapsing = clickedIsActive && options.collapsible,
  13552. toShow = collapsing ? $() : this._getPanelForTab( tab ),
  13553. toHide = !active.length ? $() : this._getPanelForTab( active ),
  13554. eventData = {
  13555. oldTab: active,
  13556. oldPanel: toHide,
  13557. newTab: collapsing ? $() : tab,
  13558. newPanel: toShow
  13559. };
  13560. event.preventDefault();
  13561. if ( tab.hasClass( "ui-state-disabled" ) ||
  13562. // tab is already loading
  13563. tab.hasClass( "ui-tabs-loading" ) ||
  13564. // can't switch durning an animation
  13565. this.running ||
  13566. // click on active header, but not collapsible
  13567. ( clickedIsActive && !options.collapsible ) ||
  13568. // allow canceling activation
  13569. ( this._trigger( "beforeActivate", event, eventData ) === false ) ) {
  13570. return;
  13571. }
  13572. options.active = collapsing ? false : this.tabs.index( tab );
  13573. this.active = clickedIsActive ? $() : tab;
  13574. if ( this.xhr ) {
  13575. this.xhr.abort();
  13576. }
  13577. if ( !toHide.length && !toShow.length ) {
  13578. $.error( "jQuery UI Tabs: Mismatching fragment identifier." );
  13579. }
  13580. if ( toShow.length ) {
  13581. this.load( this.tabs.index( tab ), event );
  13582. }
  13583. this._toggle( event, eventData );
  13584. },
  13585. // handles show/hide for selecting tabs
  13586. _toggle: function( event, eventData ) {
  13587. var that = this,
  13588. toShow = eventData.newPanel,
  13589. toHide = eventData.oldPanel;
  13590. this.running = true;
  13591. function complete() {
  13592. that.running = false;
  13593. that._trigger( "activate", event, eventData );
  13594. }
  13595. function show() {
  13596. eventData.newTab.closest( "li" ).addClass( "ui-tabs-active ui-state-active" );
  13597. if ( toShow.length && that.options.show ) {
  13598. that._show( toShow, that.options.show, complete );
  13599. } else {
  13600. toShow.show();
  13601. complete();
  13602. }
  13603. }
  13604. // start out by hiding, then showing, then completing
  13605. if ( toHide.length && this.options.hide ) {
  13606. this._hide( toHide, this.options.hide, function() {
  13607. eventData.oldTab.closest( "li" ).removeClass( "ui-tabs-active ui-state-active" );
  13608. show();
  13609. });
  13610. } else {
  13611. eventData.oldTab.closest( "li" ).removeClass( "ui-tabs-active ui-state-active" );
  13612. toHide.hide();
  13613. show();
  13614. }
  13615. toHide.attr( "aria-hidden", "true" );
  13616. eventData.oldTab.attr({
  13617. "aria-selected": "false",
  13618. "aria-expanded": "false"
  13619. });
  13620. // If we're switching tabs, remove the old tab from the tab order.
  13621. // If we're opening from collapsed state, remove the previous tab from the tab order.
  13622. // If we're collapsing, then keep the collapsing tab in the tab order.
  13623. if ( toShow.length && toHide.length ) {
  13624. eventData.oldTab.attr( "tabIndex", -1 );
  13625. } else if ( toShow.length ) {
  13626. this.tabs.filter(function() {
  13627. return $( this ).attr( "tabIndex" ) === 0;
  13628. })
  13629. .attr( "tabIndex", -1 );
  13630. }
  13631. toShow.attr( "aria-hidden", "false" );
  13632. eventData.newTab.attr({
  13633. "aria-selected": "true",
  13634. "aria-expanded": "true",
  13635. tabIndex: 0
  13636. });
  13637. },
  13638. _activate: function( index ) {
  13639. var anchor,
  13640. active = this._findActive( index );
  13641. // trying to activate the already active panel
  13642. if ( active[ 0 ] === this.active[ 0 ] ) {
  13643. return;
  13644. }
  13645. // trying to collapse, simulate a click on the current active header
  13646. if ( !active.length ) {
  13647. active = this.active;
  13648. }
  13649. anchor = active.find( ".ui-tabs-anchor" )[ 0 ];
  13650. this._eventHandler({
  13651. target: anchor,
  13652. currentTarget: anchor,
  13653. preventDefault: $.noop
  13654. });
  13655. },
  13656. _findActive: function( index ) {
  13657. return index === false ? $() : this.tabs.eq( index );
  13658. },
  13659. _getIndex: function( index ) {
  13660. // meta-function to give users option to provide a href string instead of a numerical index.
  13661. if ( typeof index === "string" ) {
  13662. index = this.anchors.index( this.anchors.filter( "[href$='" + index + "']" ) );
  13663. }
  13664. return index;
  13665. },
  13666. _destroy: function() {
  13667. if ( this.xhr ) {
  13668. this.xhr.abort();
  13669. }
  13670. this.element.removeClass( "ui-tabs ui-widget ui-widget-content ui-corner-all ui-tabs-collapsible" );
  13671. this.tablist
  13672. .removeClass( "ui-tabs-nav ui-helper-reset ui-helper-clearfix ui-widget-header ui-corner-all" )
  13673. .removeAttr( "role" );
  13674. this.anchors
  13675. .removeClass( "ui-tabs-anchor" )
  13676. .removeAttr( "role" )
  13677. .removeAttr( "tabIndex" )
  13678. .removeUniqueId();
  13679. this.tablist.unbind( this.eventNamespace );
  13680. this.tabs.add( this.panels ).each(function() {
  13681. if ( $.data( this, "ui-tabs-destroy" ) ) {
  13682. $( this ).remove();
  13683. } else {
  13684. $( this )
  13685. .removeClass( "ui-state-default ui-state-active ui-state-disabled " +
  13686. "ui-corner-top ui-corner-bottom ui-widget-content ui-tabs-active ui-tabs-panel" )
  13687. .removeAttr( "tabIndex" )
  13688. .removeAttr( "aria-live" )
  13689. .removeAttr( "aria-busy" )
  13690. .removeAttr( "aria-selected" )
  13691. .removeAttr( "aria-labelledby" )
  13692. .removeAttr( "aria-hidden" )
  13693. .removeAttr( "aria-expanded" )
  13694. .removeAttr( "role" );
  13695. }
  13696. });
  13697. this.tabs.each(function() {
  13698. var li = $( this ),
  13699. prev = li.data( "ui-tabs-aria-controls" );
  13700. if ( prev ) {
  13701. li
  13702. .attr( "aria-controls", prev )
  13703. .removeData( "ui-tabs-aria-controls" );
  13704. } else {
  13705. li.removeAttr( "aria-controls" );
  13706. }
  13707. });
  13708. this.panels.show();
  13709. if ( this.options.heightStyle !== "content" ) {
  13710. this.panels.css( "height", "" );
  13711. }
  13712. },
  13713. enable: function( index ) {
  13714. var disabled = this.options.disabled;
  13715. if ( disabled === false ) {
  13716. return;
  13717. }
  13718. if ( index === undefined ) {
  13719. disabled = false;
  13720. } else {
  13721. index = this._getIndex( index );
  13722. if ( $.isArray( disabled ) ) {
  13723. disabled = $.map( disabled, function( num ) {
  13724. return num !== index ? num : null;
  13725. });
  13726. } else {
  13727. disabled = $.map( this.tabs, function( li, num ) {
  13728. return num !== index ? num : null;
  13729. });
  13730. }
  13731. }
  13732. this._setupDisabled( disabled );
  13733. },
  13734. disable: function( index ) {
  13735. var disabled = this.options.disabled;
  13736. if ( disabled === true ) {
  13737. return;
  13738. }
  13739. if ( index === undefined ) {
  13740. disabled = true;
  13741. } else {
  13742. index = this._getIndex( index );
  13743. if ( $.inArray( index, disabled ) !== -1 ) {
  13744. return;
  13745. }
  13746. if ( $.isArray( disabled ) ) {
  13747. disabled = $.merge( [ index ], disabled ).sort();
  13748. } else {
  13749. disabled = [ index ];
  13750. }
  13751. }
  13752. this._setupDisabled( disabled );
  13753. },
  13754. load: function( index, event ) {
  13755. index = this._getIndex( index );
  13756. var that = this,
  13757. tab = this.tabs.eq( index ),
  13758. anchor = tab.find( ".ui-tabs-anchor" ),
  13759. panel = this._getPanelForTab( tab ),
  13760. eventData = {
  13761. tab: tab,
  13762. panel: panel
  13763. };
  13764. // not remote
  13765. if ( this._isLocal( anchor[ 0 ] ) ) {
  13766. return;
  13767. }
  13768. this.xhr = $.ajax( this._ajaxSettings( anchor, event, eventData ) );
  13769. // support: jQuery <1.8
  13770. // jQuery <1.8 returns false if the request is canceled in beforeSend,
  13771. // but as of 1.8, $.ajax() always returns a jqXHR object.
  13772. if ( this.xhr && this.xhr.statusText !== "canceled" ) {
  13773. tab.addClass( "ui-tabs-loading" );
  13774. panel.attr( "aria-busy", "true" );
  13775. this.xhr
  13776. .success(function( response ) {
  13777. // support: jQuery <1.8
  13778. // http://bugs.jquery.com/ticket/11778
  13779. setTimeout(function() {
  13780. panel.html( response );
  13781. that._trigger( "load", event, eventData );
  13782. }, 1 );
  13783. })
  13784. .complete(function( jqXHR, status ) {
  13785. // support: jQuery <1.8
  13786. // http://bugs.jquery.com/ticket/11778
  13787. setTimeout(function() {
  13788. if ( status === "abort" ) {
  13789. that.panels.stop( false, true );
  13790. }
  13791. tab.removeClass( "ui-tabs-loading" );
  13792. panel.removeAttr( "aria-busy" );
  13793. if ( jqXHR === that.xhr ) {
  13794. delete that.xhr;
  13795. }
  13796. }, 1 );
  13797. });
  13798. }
  13799. },
  13800. _ajaxSettings: function( anchor, event, eventData ) {
  13801. var that = this;
  13802. return {
  13803. url: anchor.attr( "href" ),
  13804. beforeSend: function( jqXHR, settings ) {
  13805. return that._trigger( "beforeLoad", event,
  13806. $.extend( { jqXHR: jqXHR, ajaxSettings: settings }, eventData ) );
  13807. }
  13808. };
  13809. },
  13810. _getPanelForTab: function( tab ) {
  13811. var id = $( tab ).attr( "aria-controls" );
  13812. return this.element.find( this._sanitizeSelector( "#" + id ) );
  13813. }
  13814. });
  13815. /*!
  13816. * jQuery UI Tooltip 1.11.2
  13817. * http://jqueryui.com
  13818. *
  13819. * Copyright 2014 jQuery Foundation and other contributors
  13820. * Released under the MIT license.
  13821. * http://jquery.org/license
  13822. *
  13823. * http://api.jqueryui.com/tooltip/
  13824. */
  13825. var tooltip = $.widget( "ui.tooltip", {
  13826. version: "1.11.2",
  13827. options: {
  13828. content: function() {
  13829. // support: IE<9, Opera in jQuery <1.7
  13830. // .text() can't accept undefined, so coerce to a string
  13831. var title = $( this ).attr( "title" ) || "";
  13832. // Escape title, since we're going from an attribute to raw HTML
  13833. return $( "<a>" ).text( title ).html();
  13834. },
  13835. hide: true,
  13836. // Disabled elements have inconsistent behavior across browsers (#8661)
  13837. items: "[title]:not([disabled])",
  13838. position: {
  13839. my: "left top+15",
  13840. at: "left bottom",
  13841. collision: "flipfit flip"
  13842. },
  13843. show: true,
  13844. tooltipClass: null,
  13845. track: false,
  13846. // callbacks
  13847. close: null,
  13848. open: null
  13849. },
  13850. _addDescribedBy: function( elem, id ) {
  13851. var describedby = (elem.attr( "aria-describedby" ) || "").split( /\s+/ );
  13852. describedby.push( id );
  13853. elem
  13854. .data( "ui-tooltip-id", id )
  13855. .attr( "aria-describedby", $.trim( describedby.join( " " ) ) );
  13856. },
  13857. _removeDescribedBy: function( elem ) {
  13858. var id = elem.data( "ui-tooltip-id" ),
  13859. describedby = (elem.attr( "aria-describedby" ) || "").split( /\s+/ ),
  13860. index = $.inArray( id, describedby );
  13861. if ( index !== -1 ) {
  13862. describedby.splice( index, 1 );
  13863. }
  13864. elem.removeData( "ui-tooltip-id" );
  13865. describedby = $.trim( describedby.join( " " ) );
  13866. if ( describedby ) {
  13867. elem.attr( "aria-describedby", describedby );
  13868. } else {
  13869. elem.removeAttr( "aria-describedby" );
  13870. }
  13871. },
  13872. _create: function() {
  13873. this._on({
  13874. mouseover: "open",
  13875. focusin: "open"
  13876. });
  13877. // IDs of generated tooltips, needed for destroy
  13878. this.tooltips = {};
  13879. // IDs of parent tooltips where we removed the title attribute
  13880. this.parents = {};
  13881. if ( this.options.disabled ) {
  13882. this._disable();
  13883. }
  13884. // Append the aria-live region so tooltips announce correctly
  13885. this.liveRegion = $( "<div>" )
  13886. .attr({
  13887. role: "log",
  13888. "aria-live": "assertive",
  13889. "aria-relevant": "additions"
  13890. })
  13891. .addClass( "ui-helper-hidden-accessible" )
  13892. .appendTo( this.document[ 0 ].body );
  13893. },
  13894. _setOption: function( key, value ) {
  13895. var that = this;
  13896. if ( key === "disabled" ) {
  13897. this[ value ? "_disable" : "_enable" ]();
  13898. this.options[ key ] = value;
  13899. // disable element style changes
  13900. return;
  13901. }
  13902. this._super( key, value );
  13903. if ( key === "content" ) {
  13904. $.each( this.tooltips, function( id, tooltipData ) {
  13905. that._updateContent( tooltipData.element );
  13906. });
  13907. }
  13908. },
  13909. _disable: function() {
  13910. var that = this;
  13911. // close open tooltips
  13912. $.each( this.tooltips, function( id, tooltipData ) {
  13913. var event = $.Event( "blur" );
  13914. event.target = event.currentTarget = tooltipData.element[ 0 ];
  13915. that.close( event, true );
  13916. });
  13917. // remove title attributes to prevent native tooltips
  13918. this.element.find( this.options.items ).addBack().each(function() {
  13919. var element = $( this );
  13920. if ( element.is( "[title]" ) ) {
  13921. element
  13922. .data( "ui-tooltip-title", element.attr( "title" ) )
  13923. .removeAttr( "title" );
  13924. }
  13925. });
  13926. },
  13927. _enable: function() {
  13928. // restore title attributes
  13929. this.element.find( this.options.items ).addBack().each(function() {
  13930. var element = $( this );
  13931. if ( element.data( "ui-tooltip-title" ) ) {
  13932. element.attr( "title", element.data( "ui-tooltip-title" ) );
  13933. }
  13934. });
  13935. },
  13936. open: function( event ) {
  13937. var that = this,
  13938. target = $( event ? event.target : this.element )
  13939. // we need closest here due to mouseover bubbling,
  13940. // but always pointing at the same event target
  13941. .closest( this.options.items );
  13942. // No element to show a tooltip for or the tooltip is already open
  13943. if ( !target.length || target.data( "ui-tooltip-id" ) ) {
  13944. return;
  13945. }
  13946. if ( target.attr( "title" ) ) {
  13947. target.data( "ui-tooltip-title", target.attr( "title" ) );
  13948. }
  13949. target.data( "ui-tooltip-open", true );
  13950. // kill parent tooltips, custom or native, for hover
  13951. if ( event && event.type === "mouseover" ) {
  13952. target.parents().each(function() {
  13953. var parent = $( this ),
  13954. blurEvent;
  13955. if ( parent.data( "ui-tooltip-open" ) ) {
  13956. blurEvent = $.Event( "blur" );
  13957. blurEvent.target = blurEvent.currentTarget = this;
  13958. that.close( blurEvent, true );
  13959. }
  13960. if ( parent.attr( "title" ) ) {
  13961. parent.uniqueId();
  13962. that.parents[ this.id ] = {
  13963. element: this,
  13964. title: parent.attr( "title" )
  13965. };
  13966. parent.attr( "title", "" );
  13967. }
  13968. });
  13969. }
  13970. this._updateContent( target, event );
  13971. },
  13972. _updateContent: function( target, event ) {
  13973. var content,
  13974. contentOption = this.options.content,
  13975. that = this,
  13976. eventType = event ? event.type : null;
  13977. if ( typeof contentOption === "string" ) {
  13978. return this._open( event, target, contentOption );
  13979. }
  13980. content = contentOption.call( target[0], function( response ) {
  13981. // ignore async response if tooltip was closed already
  13982. if ( !target.data( "ui-tooltip-open" ) ) {
  13983. return;
  13984. }
  13985. // IE may instantly serve a cached response for ajax requests
  13986. // delay this call to _open so the other call to _open runs first
  13987. that._delay(function() {
  13988. // jQuery creates a special event for focusin when it doesn't
  13989. // exist natively. To improve performance, the native event
  13990. // object is reused and the type is changed. Therefore, we can't
  13991. // rely on the type being correct after the event finished
  13992. // bubbling, so we set it back to the previous value. (#8740)
  13993. if ( event ) {
  13994. event.type = eventType;
  13995. }
  13996. this._open( event, target, response );
  13997. });
  13998. });
  13999. if ( content ) {
  14000. this._open( event, target, content );
  14001. }
  14002. },
  14003. _open: function( event, target, content ) {
  14004. var tooltipData, tooltip, events, delayedShow, a11yContent,
  14005. positionOption = $.extend( {}, this.options.position );
  14006. if ( !content ) {
  14007. return;
  14008. }
  14009. // Content can be updated multiple times. If the tooltip already
  14010. // exists, then just update the content and bail.
  14011. tooltipData = this._find( target );
  14012. if ( tooltipData ) {
  14013. tooltipData.tooltip.find( ".ui-tooltip-content" ).html( content );
  14014. return;
  14015. }
  14016. // if we have a title, clear it to prevent the native tooltip
  14017. // we have to check first to avoid defining a title if none exists
  14018. // (we don't want to cause an element to start matching [title])
  14019. //
  14020. // We use removeAttr only for key events, to allow IE to export the correct
  14021. // accessible attributes. For mouse events, set to empty string to avoid
  14022. // native tooltip showing up (happens only when removing inside mouseover).
  14023. if ( target.is( "[title]" ) ) {
  14024. if ( event && event.type === "mouseover" ) {
  14025. target.attr( "title", "" );
  14026. } else {
  14027. target.removeAttr( "title" );
  14028. }
  14029. }
  14030. tooltipData = this._tooltip( target );
  14031. tooltip = tooltipData.tooltip;
  14032. this._addDescribedBy( target, tooltip.attr( "id" ) );
  14033. tooltip.find( ".ui-tooltip-content" ).html( content );
  14034. // Support: Voiceover on OS X, JAWS on IE <= 9
  14035. // JAWS announces deletions even when aria-relevant="additions"
  14036. // Voiceover will sometimes re-read the entire log region's contents from the beginning
  14037. this.liveRegion.children().hide();
  14038. if ( content.clone ) {
  14039. a11yContent = content.clone();
  14040. a11yContent.removeAttr( "id" ).find( "[id]" ).removeAttr( "id" );
  14041. } else {
  14042. a11yContent = content;
  14043. }
  14044. $( "<div>" ).html( a11yContent ).appendTo( this.liveRegion );
  14045. function position( event ) {
  14046. positionOption.of = event;
  14047. if ( tooltip.is( ":hidden" ) ) {
  14048. return;
  14049. }
  14050. tooltip.position( positionOption );
  14051. }
  14052. if ( this.options.track && event && /^mouse/.test( event.type ) ) {
  14053. this._on( this.document, {
  14054. mousemove: position
  14055. });
  14056. // trigger once to override element-relative positioning
  14057. position( event );
  14058. } else {
  14059. tooltip.position( $.extend({
  14060. of: target
  14061. }, this.options.position ) );
  14062. }
  14063. tooltip.hide();
  14064. this._show( tooltip, this.options.show );
  14065. // Handle tracking tooltips that are shown with a delay (#8644). As soon
  14066. // as the tooltip is visible, position the tooltip using the most recent
  14067. // event.
  14068. if ( this.options.show && this.options.show.delay ) {
  14069. delayedShow = this.delayedShow = setInterval(function() {
  14070. if ( tooltip.is( ":visible" ) ) {
  14071. position( positionOption.of );
  14072. clearInterval( delayedShow );
  14073. }
  14074. }, $.fx.interval );
  14075. }
  14076. this._trigger( "open", event, { tooltip: tooltip } );
  14077. events = {
  14078. keyup: function( event ) {
  14079. if ( event.keyCode === $.ui.keyCode.ESCAPE ) {
  14080. var fakeEvent = $.Event(event);
  14081. fakeEvent.currentTarget = target[0];
  14082. this.close( fakeEvent, true );
  14083. }
  14084. }
  14085. };
  14086. // Only bind remove handler for delegated targets. Non-delegated
  14087. // tooltips will handle this in destroy.
  14088. if ( target[ 0 ] !== this.element[ 0 ] ) {
  14089. events.remove = function() {
  14090. this._removeTooltip( tooltip );
  14091. };
  14092. }
  14093. if ( !event || event.type === "mouseover" ) {
  14094. events.mouseleave = "close";
  14095. }
  14096. if ( !event || event.type === "focusin" ) {
  14097. events.focusout = "close";
  14098. }
  14099. this._on( true, target, events );
  14100. },
  14101. close: function( event ) {
  14102. var tooltip,
  14103. that = this,
  14104. target = $( event ? event.currentTarget : this.element ),
  14105. tooltipData = this._find( target );
  14106. // The tooltip may already be closed
  14107. if ( !tooltipData ) {
  14108. return;
  14109. }
  14110. tooltip = tooltipData.tooltip;
  14111. // disabling closes the tooltip, so we need to track when we're closing
  14112. // to avoid an infinite loop in case the tooltip becomes disabled on close
  14113. if ( tooltipData.closing ) {
  14114. return;
  14115. }
  14116. // Clear the interval for delayed tracking tooltips
  14117. clearInterval( this.delayedShow );
  14118. // only set title if we had one before (see comment in _open())
  14119. // If the title attribute has changed since open(), don't restore
  14120. if ( target.data( "ui-tooltip-title" ) && !target.attr( "title" ) ) {
  14121. target.attr( "title", target.data( "ui-tooltip-title" ) );
  14122. }
  14123. this._removeDescribedBy( target );
  14124. tooltipData.hiding = true;
  14125. tooltip.stop( true );
  14126. this._hide( tooltip, this.options.hide, function() {
  14127. that._removeTooltip( $( this ) );
  14128. });
  14129. target.removeData( "ui-tooltip-open" );
  14130. this._off( target, "mouseleave focusout keyup" );
  14131. // Remove 'remove' binding only on delegated targets
  14132. if ( target[ 0 ] !== this.element[ 0 ] ) {
  14133. this._off( target, "remove" );
  14134. }
  14135. this._off( this.document, "mousemove" );
  14136. if ( event && event.type === "mouseleave" ) {
  14137. $.each( this.parents, function( id, parent ) {
  14138. $( parent.element ).attr( "title", parent.title );
  14139. delete that.parents[ id ];
  14140. });
  14141. }
  14142. tooltipData.closing = true;
  14143. this._trigger( "close", event, { tooltip: tooltip } );
  14144. if ( !tooltipData.hiding ) {
  14145. tooltipData.closing = false;
  14146. }
  14147. },
  14148. _tooltip: function( element ) {
  14149. var tooltip = $( "<div>" )
  14150. .attr( "role", "tooltip" )
  14151. .addClass( "ui-tooltip ui-widget ui-corner-all ui-widget-content " +
  14152. ( this.options.tooltipClass || "" ) ),
  14153. id = tooltip.uniqueId().attr( "id" );
  14154. $( "<div>" )
  14155. .addClass( "ui-tooltip-content" )
  14156. .appendTo( tooltip );
  14157. tooltip.appendTo( this.document[0].body );
  14158. return this.tooltips[ id ] = {
  14159. element: element,
  14160. tooltip: tooltip
  14161. };
  14162. },
  14163. _find: function( target ) {
  14164. var id = target.data( "ui-tooltip-id" );
  14165. return id ? this.tooltips[ id ] : null;
  14166. },
  14167. _removeTooltip: function( tooltip ) {
  14168. tooltip.remove();
  14169. delete this.tooltips[ tooltip.attr( "id" ) ];
  14170. },
  14171. _destroy: function() {
  14172. var that = this;
  14173. // close open tooltips
  14174. $.each( this.tooltips, function( id, tooltipData ) {
  14175. // Delegate to close method to handle common cleanup
  14176. var event = $.Event( "blur" ),
  14177. element = tooltipData.element;
  14178. event.target = event.currentTarget = element[ 0 ];
  14179. that.close( event, true );
  14180. // Remove immediately; destroying an open tooltip doesn't use the
  14181. // hide animation
  14182. $( "#" + id ).remove();
  14183. // Restore the title
  14184. if ( element.data( "ui-tooltip-title" ) ) {
  14185. // If the title attribute has changed since open(), don't restore
  14186. if ( !element.attr( "title" ) ) {
  14187. element.attr( "title", element.data( "ui-tooltip-title" ) );
  14188. }
  14189. element.removeData( "ui-tooltip-title" );
  14190. }
  14191. });
  14192. this.liveRegion.remove();
  14193. }
  14194. });
  14195. }));