jquery-ui.js 424 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936
  1. /*! jQuery UI - v1.10.1 - 2013-02-15
  2. * http://jqueryui.com
  3. * Includes: jquery.ui.core.js, jquery.ui.widget.js, jquery.ui.mouse.js, jquery.ui.draggable.js, jquery.ui.droppable.js, jquery.ui.resizable.js, jquery.ui.selectable.js, jquery.ui.sortable.js, jquery.ui.effect.js, jquery.ui.accordion.js, jquery.ui.autocomplete.js, jquery.ui.button.js, jquery.ui.datepicker.js, jquery.ui.dialog.js, jquery.ui.effect-blind.js, jquery.ui.effect-bounce.js, jquery.ui.effect-clip.js, jquery.ui.effect-drop.js, jquery.ui.effect-explode.js, jquery.ui.effect-fade.js, jquery.ui.effect-fold.js, jquery.ui.effect-highlight.js, jquery.ui.effect-pulsate.js, jquery.ui.effect-scale.js, jquery.ui.effect-shake.js, jquery.ui.effect-slide.js, jquery.ui.effect-transfer.js, jquery.ui.menu.js, jquery.ui.position.js, jquery.ui.progressbar.js, jquery.ui.slider.js, jquery.ui.spinner.js, jquery.ui.tabs.js, jquery.ui.tooltip.js
  4. * Copyright 2013 jQuery Foundation and other contributors; Licensed MIT */
  5. (function( $, undefined ) {
  6. var uuid = 0,
  7. runiqueId = /^ui-id-\d+$/;
  8. // prevent duplicate loading
  9. // this is only a problem because we proxy existing functions
  10. // and we don't want to double proxy them
  11. $.ui = $.ui || {};
  12. if ( $.ui.version ) {
  13. return;
  14. }
  15. $.extend( $.ui, {
  16. version: "1.10.1",
  17. keyCode: {
  18. BACKSPACE: 8,
  19. COMMA: 188,
  20. DELETE: 46,
  21. DOWN: 40,
  22. END: 35,
  23. ENTER: 13,
  24. ESCAPE: 27,
  25. HOME: 36,
  26. LEFT: 37,
  27. NUMPAD_ADD: 107,
  28. NUMPAD_DECIMAL: 110,
  29. NUMPAD_DIVIDE: 111,
  30. NUMPAD_ENTER: 108,
  31. NUMPAD_MULTIPLY: 106,
  32. NUMPAD_SUBTRACT: 109,
  33. PAGE_DOWN: 34,
  34. PAGE_UP: 33,
  35. PERIOD: 190,
  36. RIGHT: 39,
  37. SPACE: 32,
  38. TAB: 9,
  39. UP: 38
  40. }
  41. });
  42. // plugins
  43. $.fn.extend({
  44. _focus: $.fn.focus,
  45. focus: function( delay, fn ) {
  46. return typeof delay === "number" ?
  47. this.each(function() {
  48. var elem = this;
  49. setTimeout(function() {
  50. $( elem ).focus();
  51. if ( fn ) {
  52. fn.call( elem );
  53. }
  54. }, delay );
  55. }) :
  56. this._focus.apply( this, arguments );
  57. },
  58. scrollParent: function() {
  59. var scrollParent;
  60. if (($.ui.ie && (/(static|relative)/).test(this.css("position"))) || (/absolute/).test(this.css("position"))) {
  61. scrollParent = this.parents().filter(function() {
  62. return (/(relative|absolute|fixed)/).test($.css(this,"position")) && (/(auto|scroll)/).test($.css(this,"overflow")+$.css(this,"overflow-y")+$.css(this,"overflow-x"));
  63. }).eq(0);
  64. } else {
  65. scrollParent = this.parents().filter(function() {
  66. return (/(auto|scroll)/).test($.css(this,"overflow")+$.css(this,"overflow-y")+$.css(this,"overflow-x"));
  67. }).eq(0);
  68. }
  69. return (/fixed/).test(this.css("position")) || !scrollParent.length ? $(document) : scrollParent;
  70. },
  71. zIndex: function( zIndex ) {
  72. if ( zIndex !== undefined ) {
  73. return this.css( "zIndex", zIndex );
  74. }
  75. if ( this.length ) {
  76. var elem = $( this[ 0 ] ), position, value;
  77. while ( elem.length && elem[ 0 ] !== document ) {
  78. // Ignore z-index if position is set to a value where z-index is ignored by the browser
  79. // This makes behavior of this function consistent across browsers
  80. // WebKit always returns auto if the element is positioned
  81. position = elem.css( "position" );
  82. if ( position === "absolute" || position === "relative" || position === "fixed" ) {
  83. // IE returns 0 when zIndex is not specified
  84. // other browsers return a string
  85. // we ignore the case of nested elements with an explicit value of 0
  86. // <div style="z-index: -10;"><div style="z-index: 0;"></div></div>
  87. value = parseInt( elem.css( "zIndex" ), 10 );
  88. if ( !isNaN( value ) && value !== 0 ) {
  89. return value;
  90. }
  91. }
  92. elem = elem.parent();
  93. }
  94. }
  95. return 0;
  96. },
  97. uniqueId: function() {
  98. return this.each(function() {
  99. if ( !this.id ) {
  100. this.id = "ui-id-" + (++uuid);
  101. }
  102. });
  103. },
  104. removeUniqueId: function() {
  105. return this.each(function() {
  106. if ( runiqueId.test( this.id ) ) {
  107. $( this ).removeAttr( "id" );
  108. }
  109. });
  110. }
  111. });
  112. // selectors
  113. function focusable( element, isTabIndexNotNaN ) {
  114. var map, mapName, img,
  115. nodeName = element.nodeName.toLowerCase();
  116. if ( "area" === nodeName ) {
  117. map = element.parentNode;
  118. mapName = map.name;
  119. if ( !element.href || !mapName || map.nodeName.toLowerCase() !== "map" ) {
  120. return false;
  121. }
  122. img = $( "img[usemap=#" + mapName + "]" )[0];
  123. return !!img && visible( img );
  124. }
  125. return ( /input|select|textarea|button|object/.test( nodeName ) ?
  126. !element.disabled :
  127. "a" === nodeName ?
  128. element.href || isTabIndexNotNaN :
  129. isTabIndexNotNaN) &&
  130. // the element and all of its ancestors must be visible
  131. visible( element );
  132. }
  133. function visible( element ) {
  134. return $.expr.filters.visible( element ) &&
  135. !$( element ).parents().addBack().filter(function() {
  136. return $.css( this, "visibility" ) === "hidden";
  137. }).length;
  138. }
  139. $.extend( $.expr[ ":" ], {
  140. data: $.expr.createPseudo ?
  141. $.expr.createPseudo(function( dataName ) {
  142. return function( elem ) {
  143. return !!$.data( elem, dataName );
  144. };
  145. }) :
  146. // support: jQuery <1.8
  147. function( elem, i, match ) {
  148. return !!$.data( elem, match[ 3 ] );
  149. },
  150. focusable: function( element ) {
  151. return focusable( element, !isNaN( $.attr( element, "tabindex" ) ) );
  152. },
  153. tabbable: function( element ) {
  154. var tabIndex = $.attr( element, "tabindex" ),
  155. isTabIndexNaN = isNaN( tabIndex );
  156. return ( isTabIndexNaN || tabIndex >= 0 ) && focusable( element, !isTabIndexNaN );
  157. }
  158. });
  159. // support: jQuery <1.8
  160. if ( !$( "<a>" ).outerWidth( 1 ).jquery ) {
  161. $.each( [ "Width", "Height" ], function( i, name ) {
  162. var side = name === "Width" ? [ "Left", "Right" ] : [ "Top", "Bottom" ],
  163. type = name.toLowerCase(),
  164. orig = {
  165. innerWidth: $.fn.innerWidth,
  166. innerHeight: $.fn.innerHeight,
  167. outerWidth: $.fn.outerWidth,
  168. outerHeight: $.fn.outerHeight
  169. };
  170. function reduce( elem, size, border, margin ) {
  171. $.each( side, function() {
  172. size -= parseFloat( $.css( elem, "padding" + this ) ) || 0;
  173. if ( border ) {
  174. size -= parseFloat( $.css( elem, "border" + this + "Width" ) ) || 0;
  175. }
  176. if ( margin ) {
  177. size -= parseFloat( $.css( elem, "margin" + this ) ) || 0;
  178. }
  179. });
  180. return size;
  181. }
  182. $.fn[ "inner" + name ] = function( size ) {
  183. if ( size === undefined ) {
  184. return orig[ "inner" + name ].call( this );
  185. }
  186. return this.each(function() {
  187. $( this ).css( type, reduce( this, size ) + "px" );
  188. });
  189. };
  190. $.fn[ "outer" + name] = function( size, margin ) {
  191. if ( typeof size !== "number" ) {
  192. return orig[ "outer" + name ].call( this, size );
  193. }
  194. return this.each(function() {
  195. $( this).css( type, reduce( this, size, true, margin ) + "px" );
  196. });
  197. };
  198. });
  199. }
  200. // support: jQuery <1.8
  201. if ( !$.fn.addBack ) {
  202. $.fn.addBack = function( selector ) {
  203. return this.add( selector == null ?
  204. this.prevObject : this.prevObject.filter( selector )
  205. );
  206. };
  207. }
  208. // support: jQuery 1.6.1, 1.6.2 (http://bugs.jquery.com/ticket/9413)
  209. if ( $( "<a>" ).data( "a-b", "a" ).removeData( "a-b" ).data( "a-b" ) ) {
  210. $.fn.removeData = (function( removeData ) {
  211. return function( key ) {
  212. if ( arguments.length ) {
  213. return removeData.call( this, $.camelCase( key ) );
  214. } else {
  215. return removeData.call( this );
  216. }
  217. };
  218. })( $.fn.removeData );
  219. }
  220. // deprecated
  221. $.ui.ie = !!/msie [\w.]+/.exec( navigator.userAgent.toLowerCase() );
  222. $.support.selectstart = "onselectstart" in document.createElement( "div" );
  223. $.fn.extend({
  224. disableSelection: function() {
  225. return this.bind( ( $.support.selectstart ? "selectstart" : "mousedown" ) +
  226. ".ui-disableSelection", function( event ) {
  227. event.preventDefault();
  228. });
  229. },
  230. enableSelection: function() {
  231. return this.unbind( ".ui-disableSelection" );
  232. }
  233. });
  234. $.extend( $.ui, {
  235. // $.ui.plugin is deprecated. Use the proxy pattern instead.
  236. plugin: {
  237. add: function( module, option, set ) {
  238. var i,
  239. proto = $.ui[ module ].prototype;
  240. for ( i in set ) {
  241. proto.plugins[ i ] = proto.plugins[ i ] || [];
  242. proto.plugins[ i ].push( [ option, set[ i ] ] );
  243. }
  244. },
  245. call: function( instance, name, args ) {
  246. var i,
  247. set = instance.plugins[ name ];
  248. if ( !set || !instance.element[ 0 ].parentNode || instance.element[ 0 ].parentNode.nodeType === 11 ) {
  249. return;
  250. }
  251. for ( i = 0; i < set.length; i++ ) {
  252. if ( instance.options[ set[ i ][ 0 ] ] ) {
  253. set[ i ][ 1 ].apply( instance.element, args );
  254. }
  255. }
  256. }
  257. },
  258. // only used by resizable
  259. hasScroll: function( el, a ) {
  260. //If overflow is hidden, the element might have extra content, but the user wants to hide it
  261. if ( $( el ).css( "overflow" ) === "hidden") {
  262. return false;
  263. }
  264. var scroll = ( a && a === "left" ) ? "scrollLeft" : "scrollTop",
  265. has = false;
  266. if ( el[ scroll ] > 0 ) {
  267. return true;
  268. }
  269. // TODO: determine which cases actually cause this to happen
  270. // if the element doesn't have the scroll set, see if it's possible to
  271. // set the scroll
  272. el[ scroll ] = 1;
  273. has = ( el[ scroll ] > 0 );
  274. el[ scroll ] = 0;
  275. return has;
  276. }
  277. });
  278. })( jQuery );
  279. (function( $, undefined ) {
  280. var uuid = 0,
  281. slice = Array.prototype.slice,
  282. _cleanData = $.cleanData;
  283. $.cleanData = function( elems ) {
  284. for ( var i = 0, elem; (elem = elems[i]) != null; i++ ) {
  285. try {
  286. $( elem ).triggerHandler( "remove" );
  287. // http://bugs.jquery.com/ticket/8235
  288. } catch( e ) {}
  289. }
  290. _cleanData( elems );
  291. };
  292. $.widget = function( name, base, prototype ) {
  293. var fullName, existingConstructor, constructor, basePrototype,
  294. // proxiedPrototype allows the provided prototype to remain unmodified
  295. // so that it can be used as a mixin for multiple widgets (#8876)
  296. proxiedPrototype = {},
  297. namespace = name.split( "." )[ 0 ];
  298. name = name.split( "." )[ 1 ];
  299. fullName = namespace + "-" + name;
  300. if ( !prototype ) {
  301. prototype = base;
  302. base = $.Widget;
  303. }
  304. // create selector for plugin
  305. $.expr[ ":" ][ fullName.toLowerCase() ] = function( elem ) {
  306. return !!$.data( elem, fullName );
  307. };
  308. $[ namespace ] = $[ namespace ] || {};
  309. existingConstructor = $[ namespace ][ name ];
  310. constructor = $[ namespace ][ name ] = function( options, element ) {
  311. // allow instantiation without "new" keyword
  312. if ( !this._createWidget ) {
  313. return new constructor( options, element );
  314. }
  315. // allow instantiation without initializing for simple inheritance
  316. // must use "new" keyword (the code above always passes args)
  317. if ( arguments.length ) {
  318. this._createWidget( options, element );
  319. }
  320. };
  321. // extend with the existing constructor to carry over any static properties
  322. $.extend( constructor, existingConstructor, {
  323. version: prototype.version,
  324. // copy the object used to create the prototype in case we need to
  325. // redefine the widget later
  326. _proto: $.extend( {}, prototype ),
  327. // track widgets that inherit from this widget in case this widget is
  328. // redefined after a widget inherits from it
  329. _childConstructors: []
  330. });
  331. basePrototype = new base();
  332. // we need to make the options hash a property directly on the new instance
  333. // otherwise we'll modify the options hash on the prototype that we're
  334. // inheriting from
  335. basePrototype.options = $.widget.extend( {}, basePrototype.options );
  336. $.each( prototype, function( prop, value ) {
  337. if ( !$.isFunction( value ) ) {
  338. proxiedPrototype[ prop ] = value;
  339. return;
  340. }
  341. proxiedPrototype[ prop ] = (function() {
  342. var _super = function() {
  343. return base.prototype[ prop ].apply( this, arguments );
  344. },
  345. _superApply = function( args ) {
  346. return base.prototype[ prop ].apply( this, args );
  347. };
  348. return function() {
  349. var __super = this._super,
  350. __superApply = this._superApply,
  351. returnValue;
  352. this._super = _super;
  353. this._superApply = _superApply;
  354. returnValue = value.apply( this, arguments );
  355. this._super = __super;
  356. this._superApply = __superApply;
  357. return returnValue;
  358. };
  359. })();
  360. });
  361. constructor.prototype = $.widget.extend( basePrototype, {
  362. // TODO: remove support for widgetEventPrefix
  363. // always use the name + a colon as the prefix, e.g., draggable:start
  364. // don't prefix for widgets that aren't DOM-based
  365. widgetEventPrefix: existingConstructor ? basePrototype.widgetEventPrefix : name
  366. }, proxiedPrototype, {
  367. constructor: constructor,
  368. namespace: namespace,
  369. widgetName: name,
  370. widgetFullName: fullName
  371. });
  372. // If this widget is being redefined then we need to find all widgets that
  373. // are inheriting from it and redefine all of them so that they inherit from
  374. // the new version of this widget. We're essentially trying to replace one
  375. // level in the prototype chain.
  376. if ( existingConstructor ) {
  377. $.each( existingConstructor._childConstructors, function( i, child ) {
  378. var childPrototype = child.prototype;
  379. // redefine the child widget using the same prototype that was
  380. // originally used, but inherit from the new version of the base
  381. $.widget( childPrototype.namespace + "." + childPrototype.widgetName, constructor, child._proto );
  382. });
  383. // remove the list of existing child constructors from the old constructor
  384. // so the old child constructors can be garbage collected
  385. delete existingConstructor._childConstructors;
  386. } else {
  387. base._childConstructors.push( constructor );
  388. }
  389. $.widget.bridge( name, constructor );
  390. };
  391. $.widget.extend = function( target ) {
  392. var input = slice.call( arguments, 1 ),
  393. inputIndex = 0,
  394. inputLength = input.length,
  395. key,
  396. value;
  397. for ( ; inputIndex < inputLength; inputIndex++ ) {
  398. for ( key in input[ inputIndex ] ) {
  399. value = input[ inputIndex ][ key ];
  400. if ( input[ inputIndex ].hasOwnProperty( key ) && value !== undefined ) {
  401. // Clone objects
  402. if ( $.isPlainObject( value ) ) {
  403. target[ key ] = $.isPlainObject( target[ key ] ) ?
  404. $.widget.extend( {}, target[ key ], value ) :
  405. // Don't extend strings, arrays, etc. with objects
  406. $.widget.extend( {}, value );
  407. // Copy everything else by reference
  408. } else {
  409. target[ key ] = value;
  410. }
  411. }
  412. }
  413. }
  414. return target;
  415. };
  416. $.widget.bridge = function( name, object ) {
  417. var fullName = object.prototype.widgetFullName || name;
  418. $.fn[ name ] = function( options ) {
  419. var isMethodCall = typeof options === "string",
  420. args = slice.call( arguments, 1 ),
  421. returnValue = this;
  422. // allow multiple hashes to be passed on init
  423. options = !isMethodCall && args.length ?
  424. $.widget.extend.apply( null, [ options ].concat(args) ) :
  425. options;
  426. if ( isMethodCall ) {
  427. this.each(function() {
  428. var methodValue,
  429. instance = $.data( this, fullName );
  430. if ( !instance ) {
  431. return $.error( "cannot call methods on " + name + " prior to initialization; " +
  432. "attempted to call method '" + options + "'" );
  433. }
  434. if ( !$.isFunction( instance[options] ) || options.charAt( 0 ) === "_" ) {
  435. return $.error( "no such method '" + options + "' for " + name + " widget instance" );
  436. }
  437. methodValue = instance[ options ].apply( instance, args );
  438. if ( methodValue !== instance && methodValue !== undefined ) {
  439. returnValue = methodValue && methodValue.jquery ?
  440. returnValue.pushStack( methodValue.get() ) :
  441. methodValue;
  442. return false;
  443. }
  444. });
  445. } else {
  446. this.each(function() {
  447. var instance = $.data( this, fullName );
  448. if ( instance ) {
  449. instance.option( options || {} )._init();
  450. } else {
  451. $.data( this, fullName, new object( options, this ) );
  452. }
  453. });
  454. }
  455. return returnValue;
  456. };
  457. };
  458. $.Widget = function( /* options, element */ ) {};
  459. $.Widget._childConstructors = [];
  460. $.Widget.prototype = {
  461. widgetName: "widget",
  462. widgetEventPrefix: "",
  463. defaultElement: "<div>",
  464. options: {
  465. disabled: false,
  466. // callbacks
  467. create: null
  468. },
  469. _createWidget: function( options, element ) {
  470. element = $( element || this.defaultElement || this )[ 0 ];
  471. this.element = $( element );
  472. this.uuid = uuid++;
  473. this.eventNamespace = "." + this.widgetName + this.uuid;
  474. this.options = $.widget.extend( {},
  475. this.options,
  476. this._getCreateOptions(),
  477. options );
  478. this.bindings = $();
  479. this.hoverable = $();
  480. this.focusable = $();
  481. if ( element !== this ) {
  482. $.data( element, this.widgetFullName, this );
  483. this._on( true, this.element, {
  484. remove: function( event ) {
  485. if ( event.target === element ) {
  486. this.destroy();
  487. }
  488. }
  489. });
  490. this.document = $( element.style ?
  491. // element within the document
  492. element.ownerDocument :
  493. // element is window or document
  494. element.document || element );
  495. this.window = $( this.document[0].defaultView || this.document[0].parentWindow );
  496. }
  497. this._create();
  498. this._trigger( "create", null, this._getCreateEventData() );
  499. this._init();
  500. },
  501. _getCreateOptions: $.noop,
  502. _getCreateEventData: $.noop,
  503. _create: $.noop,
  504. _init: $.noop,
  505. destroy: function() {
  506. this._destroy();
  507. // we can probably remove the unbind calls in 2.0
  508. // all event bindings should go through this._on()
  509. this.element
  510. .unbind( this.eventNamespace )
  511. // 1.9 BC for #7810
  512. // TODO remove dual storage
  513. .removeData( this.widgetName )
  514. .removeData( this.widgetFullName )
  515. // support: jquery <1.6.3
  516. // http://bugs.jquery.com/ticket/9413
  517. .removeData( $.camelCase( this.widgetFullName ) );
  518. this.widget()
  519. .unbind( this.eventNamespace )
  520. .removeAttr( "aria-disabled" )
  521. .removeClass(
  522. this.widgetFullName + "-disabled " +
  523. "ui-state-disabled" );
  524. // clean up events and states
  525. this.bindings.unbind( this.eventNamespace );
  526. this.hoverable.removeClass( "ui-state-hover" );
  527. this.focusable.removeClass( "ui-state-focus" );
  528. },
  529. _destroy: $.noop,
  530. widget: function() {
  531. return this.element;
  532. },
  533. option: function( key, value ) {
  534. var options = key,
  535. parts,
  536. curOption,
  537. i;
  538. if ( arguments.length === 0 ) {
  539. // don't return a reference to the internal hash
  540. return $.widget.extend( {}, this.options );
  541. }
  542. if ( typeof key === "string" ) {
  543. // handle nested keys, e.g., "foo.bar" => { foo: { bar: ___ } }
  544. options = {};
  545. parts = key.split( "." );
  546. key = parts.shift();
  547. if ( parts.length ) {
  548. curOption = options[ key ] = $.widget.extend( {}, this.options[ key ] );
  549. for ( i = 0; i < parts.length - 1; i++ ) {
  550. curOption[ parts[ i ] ] = curOption[ parts[ i ] ] || {};
  551. curOption = curOption[ parts[ i ] ];
  552. }
  553. key = parts.pop();
  554. if ( value === undefined ) {
  555. return curOption[ key ] === undefined ? null : curOption[ key ];
  556. }
  557. curOption[ key ] = value;
  558. } else {
  559. if ( value === undefined ) {
  560. return this.options[ key ] === undefined ? null : this.options[ key ];
  561. }
  562. options[ key ] = value;
  563. }
  564. }
  565. this._setOptions( options );
  566. return this;
  567. },
  568. _setOptions: function( options ) {
  569. var key;
  570. for ( key in options ) {
  571. this._setOption( key, options[ key ] );
  572. }
  573. return this;
  574. },
  575. _setOption: function( key, value ) {
  576. this.options[ key ] = value;
  577. if ( key === "disabled" ) {
  578. this.widget()
  579. .toggleClass( this.widgetFullName + "-disabled ui-state-disabled", !!value )
  580. .attr( "aria-disabled", value );
  581. this.hoverable.removeClass( "ui-state-hover" );
  582. this.focusable.removeClass( "ui-state-focus" );
  583. }
  584. return this;
  585. },
  586. enable: function() {
  587. return this._setOption( "disabled", false );
  588. },
  589. disable: function() {
  590. return this._setOption( "disabled", true );
  591. },
  592. _on: function( suppressDisabledCheck, element, handlers ) {
  593. var delegateElement,
  594. instance = this;
  595. // no suppressDisabledCheck flag, shuffle arguments
  596. if ( typeof suppressDisabledCheck !== "boolean" ) {
  597. handlers = element;
  598. element = suppressDisabledCheck;
  599. suppressDisabledCheck = false;
  600. }
  601. // no element argument, shuffle and use this.element
  602. if ( !handlers ) {
  603. handlers = element;
  604. element = this.element;
  605. delegateElement = this.widget();
  606. } else {
  607. // accept selectors, DOM elements
  608. element = delegateElement = $( element );
  609. this.bindings = this.bindings.add( element );
  610. }
  611. $.each( handlers, function( event, handler ) {
  612. function handlerProxy() {
  613. // allow widgets to customize the disabled handling
  614. // - disabled as an array instead of boolean
  615. // - disabled class as method for disabling individual parts
  616. if ( !suppressDisabledCheck &&
  617. ( instance.options.disabled === true ||
  618. $( this ).hasClass( "ui-state-disabled" ) ) ) {
  619. return;
  620. }
  621. return ( typeof handler === "string" ? instance[ handler ] : handler )
  622. .apply( instance, arguments );
  623. }
  624. // copy the guid so direct unbinding works
  625. if ( typeof handler !== "string" ) {
  626. handlerProxy.guid = handler.guid =
  627. handler.guid || handlerProxy.guid || $.guid++;
  628. }
  629. var match = event.match( /^(\w+)\s*(.*)$/ ),
  630. eventName = match[1] + instance.eventNamespace,
  631. selector = match[2];
  632. if ( selector ) {
  633. delegateElement.delegate( selector, eventName, handlerProxy );
  634. } else {
  635. element.bind( eventName, handlerProxy );
  636. }
  637. });
  638. },
  639. _off: function( element, eventName ) {
  640. eventName = (eventName || "").split( " " ).join( this.eventNamespace + " " ) + this.eventNamespace;
  641. element.unbind( eventName ).undelegate( eventName );
  642. },
  643. _delay: function( handler, delay ) {
  644. function handlerProxy() {
  645. return ( typeof handler === "string" ? instance[ handler ] : handler )
  646. .apply( instance, arguments );
  647. }
  648. var instance = this;
  649. return setTimeout( handlerProxy, delay || 0 );
  650. },
  651. _hoverable: function( element ) {
  652. this.hoverable = this.hoverable.add( element );
  653. this._on( element, {
  654. mouseenter: function( event ) {
  655. $( event.currentTarget ).addClass( "ui-state-hover" );
  656. },
  657. mouseleave: function( event ) {
  658. $( event.currentTarget ).removeClass( "ui-state-hover" );
  659. }
  660. });
  661. },
  662. _focusable: function( element ) {
  663. this.focusable = this.focusable.add( element );
  664. this._on( element, {
  665. focusin: function( event ) {
  666. $( event.currentTarget ).addClass( "ui-state-focus" );
  667. },
  668. focusout: function( event ) {
  669. $( event.currentTarget ).removeClass( "ui-state-focus" );
  670. }
  671. });
  672. },
  673. _trigger: function( type, event, data ) {
  674. var prop, orig,
  675. callback = this.options[ type ];
  676. data = data || {};
  677. event = $.Event( event );
  678. event.type = ( type === this.widgetEventPrefix ?
  679. type :
  680. this.widgetEventPrefix + type ).toLowerCase();
  681. // the original event may come from any element
  682. // so we need to reset the target on the new event
  683. event.target = this.element[ 0 ];
  684. // copy original event properties over to the new event
  685. orig = event.originalEvent;
  686. if ( orig ) {
  687. for ( prop in orig ) {
  688. if ( !( prop in event ) ) {
  689. event[ prop ] = orig[ prop ];
  690. }
  691. }
  692. }
  693. this.element.trigger( event, data );
  694. return !( $.isFunction( callback ) &&
  695. callback.apply( this.element[0], [ event ].concat( data ) ) === false ||
  696. event.isDefaultPrevented() );
  697. }
  698. };
  699. $.each( { show: "fadeIn", hide: "fadeOut" }, function( method, defaultEffect ) {
  700. $.Widget.prototype[ "_" + method ] = function( element, options, callback ) {
  701. if ( typeof options === "string" ) {
  702. options = { effect: options };
  703. }
  704. var hasOptions,
  705. effectName = !options ?
  706. method :
  707. options === true || typeof options === "number" ?
  708. defaultEffect :
  709. options.effect || defaultEffect;
  710. options = options || {};
  711. if ( typeof options === "number" ) {
  712. options = { duration: options };
  713. }
  714. hasOptions = !$.isEmptyObject( options );
  715. options.complete = callback;
  716. if ( options.delay ) {
  717. element.delay( options.delay );
  718. }
  719. if ( hasOptions && $.effects && $.effects.effect[ effectName ] ) {
  720. element[ method ]( options );
  721. } else if ( effectName !== method && element[ effectName ] ) {
  722. element[ effectName ]( options.duration, options.easing, callback );
  723. } else {
  724. element.queue(function( next ) {
  725. $( this )[ method ]();
  726. if ( callback ) {
  727. callback.call( element[ 0 ] );
  728. }
  729. next();
  730. });
  731. }
  732. };
  733. });
  734. })( jQuery );
  735. (function( $, undefined ) {
  736. var mouseHandled = false;
  737. $( document ).mouseup( function() {
  738. mouseHandled = false;
  739. });
  740. $.widget("ui.mouse", {
  741. version: "1.10.1",
  742. options: {
  743. cancel: "input,textarea,button,select,option",
  744. distance: 1,
  745. delay: 0
  746. },
  747. _mouseInit: function() {
  748. var that = this;
  749. this.element
  750. .bind("mousedown."+this.widgetName, function(event) {
  751. return that._mouseDown(event);
  752. })
  753. .bind("click."+this.widgetName, function(event) {
  754. if (true === $.data(event.target, that.widgetName + ".preventClickEvent")) {
  755. $.removeData(event.target, that.widgetName + ".preventClickEvent");
  756. event.stopImmediatePropagation();
  757. return false;
  758. }
  759. });
  760. this.started = false;
  761. },
  762. // TODO: make sure destroying one instance of mouse doesn't mess with
  763. // other instances of mouse
  764. _mouseDestroy: function() {
  765. this.element.unbind("."+this.widgetName);
  766. if ( this._mouseMoveDelegate ) {
  767. $(document)
  768. .unbind("mousemove."+this.widgetName, this._mouseMoveDelegate)
  769. .unbind("mouseup."+this.widgetName, this._mouseUpDelegate);
  770. }
  771. },
  772. _mouseDown: function(event) {
  773. // don't let more than one widget handle mouseStart
  774. if( mouseHandled ) { return; }
  775. // we may have missed mouseup (out of window)
  776. (this._mouseStarted && this._mouseUp(event));
  777. this._mouseDownEvent = event;
  778. var that = this,
  779. btnIsLeft = (event.which === 1),
  780. // event.target.nodeName works around a bug in IE 8 with
  781. // disabled inputs (#7620)
  782. elIsCancel = (typeof this.options.cancel === "string" && event.target.nodeName ? $(event.target).closest(this.options.cancel).length : false);
  783. if (!btnIsLeft || elIsCancel || !this._mouseCapture(event)) {
  784. return true;
  785. }
  786. this.mouseDelayMet = !this.options.delay;
  787. if (!this.mouseDelayMet) {
  788. this._mouseDelayTimer = setTimeout(function() {
  789. that.mouseDelayMet = true;
  790. }, this.options.delay);
  791. }
  792. if (this._mouseDistanceMet(event) && this._mouseDelayMet(event)) {
  793. this._mouseStarted = (this._mouseStart(event) !== false);
  794. if (!this._mouseStarted) {
  795. event.preventDefault();
  796. return true;
  797. }
  798. }
  799. // Click event may never have fired (Gecko & Opera)
  800. if (true === $.data(event.target, this.widgetName + ".preventClickEvent")) {
  801. $.removeData(event.target, this.widgetName + ".preventClickEvent");
  802. }
  803. // these delegates are required to keep context
  804. this._mouseMoveDelegate = function(event) {
  805. return that._mouseMove(event);
  806. };
  807. this._mouseUpDelegate = function(event) {
  808. return that._mouseUp(event);
  809. };
  810. $(document)
  811. .bind("mousemove."+this.widgetName, this._mouseMoveDelegate)
  812. .bind("mouseup."+this.widgetName, this._mouseUpDelegate);
  813. event.preventDefault();
  814. mouseHandled = true;
  815. return true;
  816. },
  817. _mouseMove: function(event) {
  818. // IE mouseup check - mouseup happened when mouse was out of window
  819. if ($.ui.ie && ( !document.documentMode || document.documentMode < 9 ) && !event.button) {
  820. return this._mouseUp(event);
  821. }
  822. if (this._mouseStarted) {
  823. this._mouseDrag(event);
  824. return event.preventDefault();
  825. }
  826. if (this._mouseDistanceMet(event) && this._mouseDelayMet(event)) {
  827. this._mouseStarted =
  828. (this._mouseStart(this._mouseDownEvent, event) !== false);
  829. (this._mouseStarted ? this._mouseDrag(event) : this._mouseUp(event));
  830. }
  831. return !this._mouseStarted;
  832. },
  833. _mouseUp: function(event) {
  834. $(document)
  835. .unbind("mousemove."+this.widgetName, this._mouseMoveDelegate)
  836. .unbind("mouseup."+this.widgetName, this._mouseUpDelegate);
  837. if (this._mouseStarted) {
  838. this._mouseStarted = false;
  839. if (event.target === this._mouseDownEvent.target) {
  840. $.data(event.target, this.widgetName + ".preventClickEvent", true);
  841. }
  842. this._mouseStop(event);
  843. }
  844. return false;
  845. },
  846. _mouseDistanceMet: function(event) {
  847. return (Math.max(
  848. Math.abs(this._mouseDownEvent.pageX - event.pageX),
  849. Math.abs(this._mouseDownEvent.pageY - event.pageY)
  850. ) >= this.options.distance
  851. );
  852. },
  853. _mouseDelayMet: function(/* event */) {
  854. return this.mouseDelayMet;
  855. },
  856. // These are placeholder methods, to be overriden by extending plugin
  857. _mouseStart: function(/* event */) {},
  858. _mouseDrag: function(/* event */) {},
  859. _mouseStop: function(/* event */) {},
  860. _mouseCapture: function(/* event */) { return true; }
  861. });
  862. })(jQuery);
  863. (function( $, undefined ) {
  864. $.widget("ui.draggable", $.ui.mouse, {
  865. version: "1.10.1",
  866. widgetEventPrefix: "drag",
  867. options: {
  868. addClasses: true,
  869. appendTo: "parent",
  870. axis: false,
  871. connectToSortable: false,
  872. containment: false,
  873. cursor: "auto",
  874. cursorAt: false,
  875. grid: false,
  876. handle: false,
  877. helper: "original",
  878. iframeFix: false,
  879. opacity: false,
  880. refreshPositions: false,
  881. revert: false,
  882. revertDuration: 500,
  883. scope: "default",
  884. scroll: true,
  885. scrollSensitivity: 20,
  886. scrollSpeed: 20,
  887. snap: false,
  888. snapMode: "both",
  889. snapTolerance: 20,
  890. stack: false,
  891. zIndex: false,
  892. // callbacks
  893. drag: null,
  894. start: null,
  895. stop: null
  896. },
  897. _create: function() {
  898. if (this.options.helper === "original" && !(/^(?:r|a|f)/).test(this.element.css("position"))) {
  899. this.element[0].style.position = "relative";
  900. }
  901. if (this.options.addClasses){
  902. this.element.addClass("ui-draggable");
  903. }
  904. if (this.options.disabled){
  905. this.element.addClass("ui-draggable-disabled");
  906. }
  907. this._mouseInit();
  908. },
  909. _destroy: function() {
  910. this.element.removeClass( "ui-draggable ui-draggable-dragging ui-draggable-disabled" );
  911. this._mouseDestroy();
  912. },
  913. _mouseCapture: function(event) {
  914. var o = this.options;
  915. // among others, prevent a drag on a resizable-handle
  916. if (this.helper || o.disabled || $(event.target).closest(".ui-resizable-handle").length > 0) {
  917. return false;
  918. }
  919. //Quit if we're not on a valid handle
  920. this.handle = this._getHandle(event);
  921. if (!this.handle) {
  922. return false;
  923. }
  924. $(o.iframeFix === true ? "iframe" : o.iframeFix).each(function() {
  925. $("<div class='ui-draggable-iframeFix' style='background: #fff;'></div>")
  926. .css({
  927. width: this.offsetWidth+"px", height: this.offsetHeight+"px",
  928. position: "absolute", opacity: "0.001", zIndex: 1000
  929. })
  930. .css($(this).offset())
  931. .appendTo("body");
  932. });
  933. return true;
  934. },
  935. _mouseStart: function(event) {
  936. var o = this.options;
  937. //Create and append the visible helper
  938. this.helper = this._createHelper(event);
  939. this.helper.addClass("ui-draggable-dragging");
  940. //Cache the helper size
  941. this._cacheHelperProportions();
  942. //If ddmanager is used for droppables, set the global draggable
  943. if($.ui.ddmanager) {
  944. $.ui.ddmanager.current = this;
  945. }
  946. /*
  947. * - Position generation -
  948. * This block generates everything position related - it's the core of draggables.
  949. */
  950. //Cache the margins of the original element
  951. this._cacheMargins();
  952. //Store the helper's css position
  953. this.cssPosition = this.helper.css("position");
  954. this.scrollParent = this.helper.scrollParent();
  955. //The element's absolute position on the page minus margins
  956. this.offset = this.positionAbs = this.element.offset();
  957. this.offset = {
  958. top: this.offset.top - this.margins.top,
  959. left: this.offset.left - this.margins.left
  960. };
  961. $.extend(this.offset, {
  962. click: { //Where the click happened, relative to the element
  963. left: event.pageX - this.offset.left,
  964. top: event.pageY - this.offset.top
  965. },
  966. parent: this._getParentOffset(),
  967. relative: this._getRelativeOffset() //This is a relative to absolute position minus the actual position calculation - only used for relative positioned helper
  968. });
  969. //Generate the original position
  970. this.originalPosition = this.position = this._generatePosition(event);
  971. this.originalPageX = event.pageX;
  972. this.originalPageY = event.pageY;
  973. //Adjust the mouse offset relative to the helper if "cursorAt" is supplied
  974. (o.cursorAt && this._adjustOffsetFromHelper(o.cursorAt));
  975. //Set a containment if given in the options
  976. if(o.containment) {
  977. this._setContainment();
  978. }
  979. //Trigger event + callbacks
  980. if(this._trigger("start", event) === false) {
  981. this._clear();
  982. return false;
  983. }
  984. //Recache the helper size
  985. this._cacheHelperProportions();
  986. //Prepare the droppable offsets
  987. if ($.ui.ddmanager && !o.dropBehaviour) {
  988. $.ui.ddmanager.prepareOffsets(this, event);
  989. }
  990. this._mouseDrag(event, true); //Execute the drag once - this causes the helper not to be visible before getting its correct position
  991. //If the ddmanager is used for droppables, inform the manager that dragging has started (see #5003)
  992. if ( $.ui.ddmanager ) {
  993. $.ui.ddmanager.dragStart(this, event);
  994. }
  995. return true;
  996. },
  997. _mouseDrag: function(event, noPropagation) {
  998. //Compute the helpers position
  999. this.position = this._generatePosition(event);
  1000. this.positionAbs = this._convertPositionTo("absolute");
  1001. //Call plugins and callbacks and use the resulting position if something is returned
  1002. if (!noPropagation) {
  1003. var ui = this._uiHash();
  1004. if(this._trigger("drag", event, ui) === false) {
  1005. this._mouseUp({});
  1006. return false;
  1007. }
  1008. this.position = ui.position;
  1009. }
  1010. if(!this.options.axis || this.options.axis !== "y") {
  1011. this.helper[0].style.left = this.position.left+"px";
  1012. }
  1013. if(!this.options.axis || this.options.axis !== "x") {
  1014. this.helper[0].style.top = this.position.top+"px";
  1015. }
  1016. if($.ui.ddmanager) {
  1017. $.ui.ddmanager.drag(this, event);
  1018. }
  1019. return false;
  1020. },
  1021. _mouseStop: function(event) {
  1022. //If we are using droppables, inform the manager about the drop
  1023. var element,
  1024. that = this,
  1025. elementInDom = false,
  1026. dropped = false;
  1027. if ($.ui.ddmanager && !this.options.dropBehaviour) {
  1028. dropped = $.ui.ddmanager.drop(this, event);
  1029. }
  1030. //if a drop comes from outside (a sortable)
  1031. if(this.dropped) {
  1032. dropped = this.dropped;
  1033. this.dropped = false;
  1034. }
  1035. //if the original element is no longer in the DOM don't bother to continue (see #8269)
  1036. element = this.element[0];
  1037. while ( element && (element = element.parentNode) ) {
  1038. if (element === document ) {
  1039. elementInDom = true;
  1040. }
  1041. }
  1042. if ( !elementInDom && this.options.helper === "original" ) {
  1043. return false;
  1044. }
  1045. 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))) {
  1046. $(this.helper).animate(this.originalPosition, parseInt(this.options.revertDuration, 10), function() {
  1047. if(that._trigger("stop", event) !== false) {
  1048. that._clear();
  1049. }
  1050. });
  1051. } else {
  1052. if(this._trigger("stop", event) !== false) {
  1053. this._clear();
  1054. }
  1055. }
  1056. return false;
  1057. },
  1058. _mouseUp: function(event) {
  1059. //Remove frame helpers
  1060. $("div.ui-draggable-iframeFix").each(function() {
  1061. this.parentNode.removeChild(this);
  1062. });
  1063. //If the ddmanager is used for droppables, inform the manager that dragging has stopped (see #5003)
  1064. if( $.ui.ddmanager ) {
  1065. $.ui.ddmanager.dragStop(this, event);
  1066. }
  1067. return $.ui.mouse.prototype._mouseUp.call(this, event);
  1068. },
  1069. cancel: function() {
  1070. if(this.helper.is(".ui-draggable-dragging")) {
  1071. this._mouseUp({});
  1072. } else {
  1073. this._clear();
  1074. }
  1075. return this;
  1076. },
  1077. _getHandle: function(event) {
  1078. var handle = !this.options.handle || !$(this.options.handle, this.element).length ? true : false;
  1079. $(this.options.handle, this.element)
  1080. .find("*")
  1081. .addBack()
  1082. .each(function() {
  1083. if(this === event.target) {
  1084. handle = true;
  1085. }
  1086. });
  1087. return handle;
  1088. },
  1089. _createHelper: function(event) {
  1090. var o = this.options,
  1091. helper = $.isFunction(o.helper) ? $(o.helper.apply(this.element[0], [event])) : (o.helper === "clone" ? this.element.clone().removeAttr("id") : this.element);
  1092. if(!helper.parents("body").length) {
  1093. helper.appendTo((o.appendTo === "parent" ? this.element[0].parentNode : o.appendTo));
  1094. }
  1095. if(helper[0] !== this.element[0] && !(/(fixed|absolute)/).test(helper.css("position"))) {
  1096. helper.css("position", "absolute");
  1097. }
  1098. return helper;
  1099. },
  1100. _adjustOffsetFromHelper: function(obj) {
  1101. if (typeof obj === "string") {
  1102. obj = obj.split(" ");
  1103. }
  1104. if ($.isArray(obj)) {
  1105. obj = {left: +obj[0], top: +obj[1] || 0};
  1106. }
  1107. if ("left" in obj) {
  1108. this.offset.click.left = obj.left + this.margins.left;
  1109. }
  1110. if ("right" in obj) {
  1111. this.offset.click.left = this.helperProportions.width - obj.right + this.margins.left;
  1112. }
  1113. if ("top" in obj) {
  1114. this.offset.click.top = obj.top + this.margins.top;
  1115. }
  1116. if ("bottom" in obj) {
  1117. this.offset.click.top = this.helperProportions.height - obj.bottom + this.margins.top;
  1118. }
  1119. },
  1120. _getParentOffset: function() {
  1121. //Get the offsetParent and cache its position
  1122. this.offsetParent = this.helper.offsetParent();
  1123. var po = this.offsetParent.offset();
  1124. // This is a special case where we need to modify a offset calculated on start, since the following happened:
  1125. // 1. The position of the helper is absolute, so it's position is calculated based on the next positioned parent
  1126. // 2. The actual offset parent is a child of the scroll parent, and the scroll parent isn't the document, which means that
  1127. // the scroll is included in the initial calculation of the offset of the parent, and never recalculated upon drag
  1128. if(this.cssPosition === "absolute" && this.scrollParent[0] !== document && $.contains(this.scrollParent[0], this.offsetParent[0])) {
  1129. po.left += this.scrollParent.scrollLeft();
  1130. po.top += this.scrollParent.scrollTop();
  1131. }
  1132. //This needs to be actually done for all browsers, since pageX/pageY includes this information
  1133. //Ugly IE fix
  1134. if((this.offsetParent[0] === document.body) ||
  1135. (this.offsetParent[0].tagName && this.offsetParent[0].tagName.toLowerCase() === "html" && $.ui.ie)) {
  1136. po = { top: 0, left: 0 };
  1137. }
  1138. return {
  1139. top: po.top + (parseInt(this.offsetParent.css("borderTopWidth"),10) || 0),
  1140. left: po.left + (parseInt(this.offsetParent.css("borderLeftWidth"),10) || 0)
  1141. };
  1142. },
  1143. _getRelativeOffset: function() {
  1144. if(this.cssPosition === "relative") {
  1145. var p = this.element.position();
  1146. return {
  1147. top: p.top - (parseInt(this.helper.css("top"),10) || 0) + this.scrollParent.scrollTop(),
  1148. left: p.left - (parseInt(this.helper.css("left"),10) || 0) + this.scrollParent.scrollLeft()
  1149. };
  1150. } else {
  1151. return { top: 0, left: 0 };
  1152. }
  1153. },
  1154. _cacheMargins: function() {
  1155. this.margins = {
  1156. left: (parseInt(this.element.css("marginLeft"),10) || 0),
  1157. top: (parseInt(this.element.css("marginTop"),10) || 0),
  1158. right: (parseInt(this.element.css("marginRight"),10) || 0),
  1159. bottom: (parseInt(this.element.css("marginBottom"),10) || 0)
  1160. };
  1161. },
  1162. _cacheHelperProportions: function() {
  1163. this.helperProportions = {
  1164. width: this.helper.outerWidth(),
  1165. height: this.helper.outerHeight()
  1166. };
  1167. },
  1168. _setContainment: function() {
  1169. var over, c, ce,
  1170. o = this.options;
  1171. if(o.containment === "parent") {
  1172. o.containment = this.helper[0].parentNode;
  1173. }
  1174. if(o.containment === "document" || o.containment === "window") {
  1175. this.containment = [
  1176. o.containment === "document" ? 0 : $(window).scrollLeft() - this.offset.relative.left - this.offset.parent.left,
  1177. o.containment === "document" ? 0 : $(window).scrollTop() - this.offset.relative.top - this.offset.parent.top,
  1178. (o.containment === "document" ? 0 : $(window).scrollLeft()) + $(o.containment === "document" ? document : window).width() - this.helperProportions.width - this.margins.left,
  1179. (o.containment === "document" ? 0 : $(window).scrollTop()) + ($(o.containment === "document" ? document : window).height() || document.body.parentNode.scrollHeight) - this.helperProportions.height - this.margins.top
  1180. ];
  1181. }
  1182. if(!(/^(document|window|parent)$/).test(o.containment) && o.containment.constructor !== Array) {
  1183. c = $(o.containment);
  1184. ce = c[0];
  1185. if(!ce) {
  1186. return;
  1187. }
  1188. over = ($(ce).css("overflow") !== "hidden");
  1189. this.containment = [
  1190. (parseInt($(ce).css("borderLeftWidth"),10) || 0) + (parseInt($(ce).css("paddingLeft"),10) || 0),
  1191. (parseInt($(ce).css("borderTopWidth"),10) || 0) + (parseInt($(ce).css("paddingTop"),10) || 0),
  1192. (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 - this.margins.right,
  1193. (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 - this.margins.bottom
  1194. ];
  1195. this.relative_container = c;
  1196. } else if(o.containment.constructor === Array) {
  1197. this.containment = o.containment;
  1198. }
  1199. },
  1200. _convertPositionTo: function(d, pos) {
  1201. if(!pos) {
  1202. pos = this.position;
  1203. }
  1204. var mod = d === "absolute" ? 1 : -1,
  1205. 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);
  1206. return {
  1207. top: (
  1208. pos.top + // The absolute mouse position
  1209. this.offset.relative.top * mod + // Only for relative positioned nodes: Relative offset from element to offset parent
  1210. this.offset.parent.top * mod - // The offsetParent's offset without borders (offset + border)
  1211. ( ( this.cssPosition === "fixed" ? -this.scrollParent.scrollTop() : ( scrollIsRootNode ? 0 : scroll.scrollTop() ) ) * mod)
  1212. ),
  1213. left: (
  1214. pos.left + // The absolute mouse position
  1215. this.offset.relative.left * mod + // Only for relative positioned nodes: Relative offset from element to offset parent
  1216. this.offset.parent.left * mod - // The offsetParent's offset without borders (offset + border)
  1217. ( ( this.cssPosition === "fixed" ? -this.scrollParent.scrollLeft() : scrollIsRootNode ? 0 : scroll.scrollLeft() ) * mod)
  1218. )
  1219. };
  1220. },
  1221. _generatePosition: function(event) {
  1222. var containment, co, top, left,
  1223. o = this.options,
  1224. scroll = this.cssPosition === "absolute" && !(this.scrollParent[0] !== document && $.contains(this.scrollParent[0], this.offsetParent[0])) ? this.offsetParent : this.scrollParent,
  1225. scrollIsRootNode = (/(html|body)/i).test(scroll[0].tagName),
  1226. pageX = event.pageX,
  1227. pageY = event.pageY;
  1228. /*
  1229. * - Position constraining -
  1230. * Constrain the position to a mix of grid, containment.
  1231. */
  1232. if(this.originalPosition) { //If we are not dragging yet, we won't check for options
  1233. if(this.containment) {
  1234. if (this.relative_container){
  1235. co = this.relative_container.offset();
  1236. containment = [ this.containment[0] + co.left,
  1237. this.containment[1] + co.top,
  1238. this.containment[2] + co.left,
  1239. this.containment[3] + co.top ];
  1240. }
  1241. else {
  1242. containment = this.containment;
  1243. }
  1244. if(event.pageX - this.offset.click.left < containment[0]) {
  1245. pageX = containment[0] + this.offset.click.left;
  1246. }
  1247. if(event.pageY - this.offset.click.top < containment[1]) {
  1248. pageY = containment[1] + this.offset.click.top;
  1249. }
  1250. if(event.pageX - this.offset.click.left > containment[2]) {
  1251. pageX = containment[2] + this.offset.click.left;
  1252. }
  1253. if(event.pageY - this.offset.click.top > containment[3]) {
  1254. pageY = containment[3] + this.offset.click.top;
  1255. }
  1256. }
  1257. if(o.grid) {
  1258. //Check for grid elements set to 0 to prevent divide by 0 error causing invalid argument errors in IE (see ticket #6950)
  1259. top = o.grid[1] ? this.originalPageY + Math.round((pageY - this.originalPageY) / o.grid[1]) * o.grid[1] : this.originalPageY;
  1260. 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;
  1261. left = o.grid[0] ? this.originalPageX + Math.round((pageX - this.originalPageX) / o.grid[0]) * o.grid[0] : this.originalPageX;
  1262. 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;
  1263. }
  1264. }
  1265. return {
  1266. top: (
  1267. pageY - // The absolute mouse position
  1268. this.offset.click.top - // Click offset (relative to the element)
  1269. this.offset.relative.top - // Only for relative positioned nodes: Relative offset from element to offset parent
  1270. this.offset.parent.top + // The offsetParent's offset without borders (offset + border)
  1271. ( ( this.cssPosition === "fixed" ? -this.scrollParent.scrollTop() : ( scrollIsRootNode ? 0 : scroll.scrollTop() ) ))
  1272. ),
  1273. left: (
  1274. pageX - // The absolute mouse position
  1275. this.offset.click.left - // Click offset (relative to the element)
  1276. this.offset.relative.left - // Only for relative positioned nodes: Relative offset from element to offset parent
  1277. this.offset.parent.left + // The offsetParent's offset without borders (offset + border)
  1278. ( ( this.cssPosition === "fixed" ? -this.scrollParent.scrollLeft() : scrollIsRootNode ? 0 : scroll.scrollLeft() ))
  1279. )
  1280. };
  1281. },
  1282. _clear: function() {
  1283. this.helper.removeClass("ui-draggable-dragging");
  1284. if(this.helper[0] !== this.element[0] && !this.cancelHelperRemoval) {
  1285. this.helper.remove();
  1286. }
  1287. this.helper = null;
  1288. this.cancelHelperRemoval = false;
  1289. },
  1290. // From now on bulk stuff - mainly helpers
  1291. _trigger: function(type, event, ui) {
  1292. ui = ui || this._uiHash();
  1293. $.ui.plugin.call(this, type, [event, ui]);
  1294. //The absolute position has to be recalculated after plugins
  1295. if(type === "drag") {
  1296. this.positionAbs = this._convertPositionTo("absolute");
  1297. }
  1298. return $.Widget.prototype._trigger.call(this, type, event, ui);
  1299. },
  1300. plugins: {},
  1301. _uiHash: function() {
  1302. return {
  1303. helper: this.helper,
  1304. position: this.position,
  1305. originalPosition: this.originalPosition,
  1306. offset: this.positionAbs
  1307. };
  1308. }
  1309. });
  1310. $.ui.plugin.add("draggable", "connectToSortable", {
  1311. start: function(event, ui) {
  1312. var inst = $(this).data("ui-draggable"), o = inst.options,
  1313. uiSortable = $.extend({}, ui, { item: inst.element });
  1314. inst.sortables = [];
  1315. $(o.connectToSortable).each(function() {
  1316. var sortable = $.data(this, "ui-sortable");
  1317. if (sortable && !sortable.options.disabled) {
  1318. inst.sortables.push({
  1319. instance: sortable,
  1320. shouldRevert: sortable.options.revert
  1321. });
  1322. sortable.refreshPositions(); // Call the sortable's refreshPositions at drag start to refresh the containerCache since the sortable container cache is used in drag and needs to be up to date (this will ensure it's initialised as well as being kept in step with any changes that might have happened on the page).
  1323. sortable._trigger("activate", event, uiSortable);
  1324. }
  1325. });
  1326. },
  1327. stop: function(event, ui) {
  1328. //If we are still over the sortable, we fake the stop event of the sortable, but also remove helper
  1329. var inst = $(this).data("ui-draggable"),
  1330. uiSortable = $.extend({}, ui, { item: inst.element });
  1331. $.each(inst.sortables, function() {
  1332. if(this.instance.isOver) {
  1333. this.instance.isOver = 0;
  1334. inst.cancelHelperRemoval = true; //Don't remove the helper in the draggable instance
  1335. this.instance.cancelHelperRemoval = false; //Remove it in the sortable instance (so sortable plugins like revert still work)
  1336. //The sortable revert is supported, and we have to set a temporary dropped variable on the draggable to support revert: "valid/invalid"
  1337. if(this.shouldRevert) {
  1338. this.instance.options.revert = true;
  1339. }
  1340. //Trigger the stop of the sortable
  1341. this.instance._mouseStop(event);
  1342. this.instance.options.helper = this.instance.options._helper;
  1343. //If the helper has been the original item, restore properties in the sortable
  1344. if(inst.options.helper === "original") {
  1345. this.instance.currentItem.css({ top: "auto", left: "auto" });
  1346. }
  1347. } else {
  1348. this.instance.cancelHelperRemoval = false; //Remove the helper in the sortable instance
  1349. this.instance._trigger("deactivate", event, uiSortable);
  1350. }
  1351. });
  1352. },
  1353. drag: function(event, ui) {
  1354. var inst = $(this).data("ui-draggable"), that = this;
  1355. $.each(inst.sortables, function() {
  1356. var innermostIntersecting = false,
  1357. thisSortable = this;
  1358. //Copy over some variables to allow calling the sortable's native _intersectsWith
  1359. this.instance.positionAbs = inst.positionAbs;
  1360. this.instance.helperProportions = inst.helperProportions;
  1361. this.instance.offset.click = inst.offset.click;
  1362. if(this.instance._intersectsWith(this.instance.containerCache)) {
  1363. innermostIntersecting = true;
  1364. $.each(inst.sortables, function () {
  1365. this.instance.positionAbs = inst.positionAbs;
  1366. this.instance.helperProportions = inst.helperProportions;
  1367. this.instance.offset.click = inst.offset.click;
  1368. if (this !== thisSortable &&
  1369. this.instance._intersectsWith(this.instance.containerCache) &&
  1370. $.contains(thisSortable.instance.element[0], this.instance.element[0])
  1371. ) {
  1372. innermostIntersecting = false;
  1373. }
  1374. return innermostIntersecting;
  1375. });
  1376. }
  1377. if(innermostIntersecting) {
  1378. //If it intersects, we use a little isOver variable and set it once, so our move-in stuff gets fired only once
  1379. if(!this.instance.isOver) {
  1380. this.instance.isOver = 1;
  1381. //Now we fake the start of dragging for the sortable instance,
  1382. //by cloning the list group item, appending it to the sortable and using it as inst.currentItem
  1383. //We can then fire the start event of the sortable with our passed browser event, and our own helper (so it doesn't create a new one)
  1384. this.instance.currentItem = $(that).clone().removeAttr("id").appendTo(this.instance.element).data("ui-sortable-item", true);
  1385. this.instance.options._helper = this.instance.options.helper; //Store helper option to later restore it
  1386. this.instance.options.helper = function() { return ui.helper[0]; };
  1387. event.target = this.instance.currentItem[0];
  1388. this.instance._mouseCapture(event, true);
  1389. this.instance._mouseStart(event, true, true);
  1390. //Because the browser event is way off the new appended portlet, we modify a couple of variables to reflect the changes
  1391. this.instance.offset.click.top = inst.offset.click.top;
  1392. this.instance.offset.click.left = inst.offset.click.left;
  1393. this.instance.offset.parent.left -= inst.offset.parent.left - this.instance.offset.parent.left;
  1394. this.instance.offset.parent.top -= inst.offset.parent.top - this.instance.offset.parent.top;
  1395. inst._trigger("toSortable", event);
  1396. inst.dropped = this.instance.element; //draggable revert needs that
  1397. //hack so receive/update callbacks work (mostly)
  1398. inst.currentItem = inst.element;
  1399. this.instance.fromOutside = inst;
  1400. }
  1401. //Provided we did all the previous steps, we can fire the drag event of the sortable on every draggable drag, when it intersects with the sortable
  1402. if(this.instance.currentItem) {
  1403. this.instance._mouseDrag(event);
  1404. }
  1405. } else {
  1406. //If it doesn't intersect with the sortable, and it intersected before,
  1407. //we fake the drag stop of the sortable, but make sure it doesn't remove the helper by using cancelHelperRemoval
  1408. if(this.instance.isOver) {
  1409. this.instance.isOver = 0;
  1410. this.instance.cancelHelperRemoval = true;
  1411. //Prevent reverting on this forced stop
  1412. this.instance.options.revert = false;
  1413. // The out event needs to be triggered independently
  1414. this.instance._trigger("out", event, this.instance._uiHash(this.instance));
  1415. this.instance._mouseStop(event, true);
  1416. this.instance.options.helper = this.instance.options._helper;
  1417. //Now we remove our currentItem, the list group clone again, and the placeholder, and animate the helper back to it's original size
  1418. this.instance.currentItem.remove();
  1419. if(this.instance.placeholder) {
  1420. this.instance.placeholder.remove();
  1421. }
  1422. inst._trigger("fromSortable", event);
  1423. inst.dropped = false; //draggable revert needs that
  1424. }
  1425. }
  1426. });
  1427. }
  1428. });
  1429. $.ui.plugin.add("draggable", "cursor", {
  1430. start: function() {
  1431. var t = $("body"), o = $(this).data("ui-draggable").options;
  1432. if (t.css("cursor")) {
  1433. o._cursor = t.css("cursor");
  1434. }
  1435. t.css("cursor", o.cursor);
  1436. },
  1437. stop: function() {
  1438. var o = $(this).data("ui-draggable").options;
  1439. if (o._cursor) {
  1440. $("body").css("cursor", o._cursor);
  1441. }
  1442. }
  1443. });
  1444. $.ui.plugin.add("draggable", "opacity", {
  1445. start: function(event, ui) {
  1446. var t = $(ui.helper), o = $(this).data("ui-draggable").options;
  1447. if(t.css("opacity")) {
  1448. o._opacity = t.css("opacity");
  1449. }
  1450. t.css("opacity", o.opacity);
  1451. },
  1452. stop: function(event, ui) {
  1453. var o = $(this).data("ui-draggable").options;
  1454. if(o._opacity) {
  1455. $(ui.helper).css("opacity", o._opacity);
  1456. }
  1457. }
  1458. });
  1459. $.ui.plugin.add("draggable", "scroll", {
  1460. start: function() {
  1461. var i = $(this).data("ui-draggable");
  1462. if(i.scrollParent[0] !== document && i.scrollParent[0].tagName !== "HTML") {
  1463. i.overflowOffset = i.scrollParent.offset();
  1464. }
  1465. },
  1466. drag: function( event ) {
  1467. var i = $(this).data("ui-draggable"), o = i.options, scrolled = false;
  1468. if(i.scrollParent[0] !== document && i.scrollParent[0].tagName !== "HTML") {
  1469. if(!o.axis || o.axis !== "x") {
  1470. if((i.overflowOffset.top + i.scrollParent[0].offsetHeight) - event.pageY < o.scrollSensitivity) {
  1471. i.scrollParent[0].scrollTop = scrolled = i.scrollParent[0].scrollTop + o.scrollSpeed;
  1472. } else if(event.pageY - i.overflowOffset.top < o.scrollSensitivity) {
  1473. i.scrollParent[0].scrollTop = scrolled = i.scrollParent[0].scrollTop - o.scrollSpeed;
  1474. }
  1475. }
  1476. if(!o.axis || o.axis !== "y") {
  1477. if((i.overflowOffset.left + i.scrollParent[0].offsetWidth) - event.pageX < o.scrollSensitivity) {
  1478. i.scrollParent[0].scrollLeft = scrolled = i.scrollParent[0].scrollLeft + o.scrollSpeed;
  1479. } else if(event.pageX - i.overflowOffset.left < o.scrollSensitivity) {
  1480. i.scrollParent[0].scrollLeft = scrolled = i.scrollParent[0].scrollLeft - o.scrollSpeed;
  1481. }
  1482. }
  1483. } else {
  1484. if(!o.axis || o.axis !== "x") {
  1485. if(event.pageY - $(document).scrollTop() < o.scrollSensitivity) {
  1486. scrolled = $(document).scrollTop($(document).scrollTop() - o.scrollSpeed);
  1487. } else if($(window).height() - (event.pageY - $(document).scrollTop()) < o.scrollSensitivity) {
  1488. scrolled = $(document).scrollTop($(document).scrollTop() + o.scrollSpeed);
  1489. }
  1490. }
  1491. if(!o.axis || o.axis !== "y") {
  1492. if(event.pageX - $(document).scrollLeft() < o.scrollSensitivity) {
  1493. scrolled = $(document).scrollLeft($(document).scrollLeft() - o.scrollSpeed);
  1494. } else if($(window).width() - (event.pageX - $(document).scrollLeft()) < o.scrollSensitivity) {
  1495. scrolled = $(document).scrollLeft($(document).scrollLeft() + o.scrollSpeed);
  1496. }
  1497. }
  1498. }
  1499. if(scrolled !== false && $.ui.ddmanager && !o.dropBehaviour) {
  1500. $.ui.ddmanager.prepareOffsets(i, event);
  1501. }
  1502. }
  1503. });
  1504. $.ui.plugin.add("draggable", "snap", {
  1505. start: function() {
  1506. var i = $(this).data("ui-draggable"),
  1507. o = i.options;
  1508. i.snapElements = [];
  1509. $(o.snap.constructor !== String ? ( o.snap.items || ":data(ui-draggable)" ) : o.snap).each(function() {
  1510. var $t = $(this),
  1511. $o = $t.offset();
  1512. if(this !== i.element[0]) {
  1513. i.snapElements.push({
  1514. item: this,
  1515. width: $t.outerWidth(), height: $t.outerHeight(),
  1516. top: $o.top, left: $o.left
  1517. });
  1518. }
  1519. });
  1520. },
  1521. drag: function(event, ui) {
  1522. var ts, bs, ls, rs, l, r, t, b, i, first,
  1523. inst = $(this).data("ui-draggable"),
  1524. o = inst.options,
  1525. d = o.snapTolerance,
  1526. x1 = ui.offset.left, x2 = x1 + inst.helperProportions.width,
  1527. y1 = ui.offset.top, y2 = y1 + inst.helperProportions.height;
  1528. for (i = inst.snapElements.length - 1; i >= 0; i--){
  1529. l = inst.snapElements[i].left;
  1530. r = l + inst.snapElements[i].width;
  1531. t = inst.snapElements[i].top;
  1532. b = t + inst.snapElements[i].height;
  1533. //Yes, I know, this is insane ;)
  1534. if(!((l-d < x1 && x1 < r+d && t-d < y1 && y1 < b+d) || (l-d < x1 && x1 < r+d && t-d < y2 && y2 < b+d) || (l-d < x2 && x2 < r+d && t-d < y1 && y1 < b+d) || (l-d < x2 && x2 < r+d && t-d < y2 && y2 < b+d))) {
  1535. if(inst.snapElements[i].snapping) {
  1536. (inst.options.snap.release && inst.options.snap.release.call(inst.element, event, $.extend(inst._uiHash(), { snapItem: inst.snapElements[i].item })));
  1537. }
  1538. inst.snapElements[i].snapping = false;
  1539. continue;
  1540. }
  1541. if(o.snapMode !== "inner") {
  1542. ts = Math.abs(t - y2) <= d;
  1543. bs = Math.abs(b - y1) <= d;
  1544. ls = Math.abs(l - x2) <= d;
  1545. rs = Math.abs(r - x1) <= d;
  1546. if(ts) {
  1547. ui.position.top = inst._convertPositionTo("relative", { top: t - inst.helperProportions.height, left: 0 }).top - inst.margins.top;
  1548. }
  1549. if(bs) {
  1550. ui.position.top = inst._convertPositionTo("relative", { top: b, left: 0 }).top - inst.margins.top;
  1551. }
  1552. if(ls) {
  1553. ui.position.left = inst._convertPositionTo("relative", { top: 0, left: l - inst.helperProportions.width }).left - inst.margins.left;
  1554. }
  1555. if(rs) {
  1556. ui.position.left = inst._convertPositionTo("relative", { top: 0, left: r }).left - inst.margins.left;
  1557. }
  1558. }
  1559. first = (ts || bs || ls || rs);
  1560. if(o.snapMode !== "outer") {
  1561. ts = Math.abs(t - y1) <= d;
  1562. bs = Math.abs(b - y2) <= d;
  1563. ls = Math.abs(l - x1) <= d;
  1564. rs = Math.abs(r - x2) <= d;
  1565. if(ts) {
  1566. ui.position.top = inst._convertPositionTo("relative", { top: t, left: 0 }).top - inst.margins.top;
  1567. }
  1568. if(bs) {
  1569. ui.position.top = inst._convertPositionTo("relative", { top: b - inst.helperProportions.height, left: 0 }).top - inst.margins.top;
  1570. }
  1571. if(ls) {
  1572. ui.position.left = inst._convertPositionTo("relative", { top: 0, left: l }).left - inst.margins.left;
  1573. }
  1574. if(rs) {
  1575. ui.position.left = inst._convertPositionTo("relative", { top: 0, left: r - inst.helperProportions.width }).left - inst.margins.left;
  1576. }
  1577. }
  1578. if(!inst.snapElements[i].snapping && (ts || bs || ls || rs || first)) {
  1579. (inst.options.snap.snap && inst.options.snap.snap.call(inst.element, event, $.extend(inst._uiHash(), { snapItem: inst.snapElements[i].item })));
  1580. }
  1581. inst.snapElements[i].snapping = (ts || bs || ls || rs || first);
  1582. }
  1583. }
  1584. });
  1585. $.ui.plugin.add("draggable", "stack", {
  1586. start: function() {
  1587. var min,
  1588. o = this.data("ui-draggable").options,
  1589. group = $.makeArray($(o.stack)).sort(function(a,b) {
  1590. return (parseInt($(a).css("zIndex"),10) || 0) - (parseInt($(b).css("zIndex"),10) || 0);
  1591. });
  1592. if (!group.length) { return; }
  1593. min = parseInt($(group[0]).css("zIndex"), 10) || 0;
  1594. $(group).each(function(i) {
  1595. $(this).css("zIndex", min + i);
  1596. });
  1597. this.css("zIndex", (min + group.length));
  1598. }
  1599. });
  1600. $.ui.plugin.add("draggable", "zIndex", {
  1601. start: function(event, ui) {
  1602. var t = $(ui.helper), o = $(this).data("ui-draggable").options;
  1603. if(t.css("zIndex")) {
  1604. o._zIndex = t.css("zIndex");
  1605. }
  1606. t.css("zIndex", o.zIndex);
  1607. },
  1608. stop: function(event, ui) {
  1609. var o = $(this).data("ui-draggable").options;
  1610. if(o._zIndex) {
  1611. $(ui.helper).css("zIndex", o._zIndex);
  1612. }
  1613. }
  1614. });
  1615. })(jQuery);
  1616. (function( $, undefined ) {
  1617. function isOverAxis( x, reference, size ) {
  1618. return ( x > reference ) && ( x < ( reference + size ) );
  1619. }
  1620. $.widget("ui.droppable", {
  1621. version: "1.10.1",
  1622. widgetEventPrefix: "drop",
  1623. options: {
  1624. accept: "*",
  1625. activeClass: false,
  1626. addClasses: true,
  1627. greedy: false,
  1628. hoverClass: false,
  1629. scope: "default",
  1630. tolerance: "intersect",
  1631. // callbacks
  1632. activate: null,
  1633. deactivate: null,
  1634. drop: null,
  1635. out: null,
  1636. over: null
  1637. },
  1638. _create: function() {
  1639. var o = this.options,
  1640. accept = o.accept;
  1641. this.isover = false;
  1642. this.isout = true;
  1643. this.accept = $.isFunction(accept) ? accept : function(d) {
  1644. return d.is(accept);
  1645. };
  1646. //Store the droppable's proportions
  1647. this.proportions = { width: this.element[0].offsetWidth, height: this.element[0].offsetHeight };
  1648. // Add the reference and positions to the manager
  1649. $.ui.ddmanager.droppables[o.scope] = $.ui.ddmanager.droppables[o.scope] || [];
  1650. $.ui.ddmanager.droppables[o.scope].push(this);
  1651. (o.addClasses && this.element.addClass("ui-droppable"));
  1652. },
  1653. _destroy: function() {
  1654. var i = 0,
  1655. drop = $.ui.ddmanager.droppables[this.options.scope];
  1656. for ( ; i < drop.length; i++ ) {
  1657. if ( drop[i] === this ) {
  1658. drop.splice(i, 1);
  1659. }
  1660. }
  1661. this.element.removeClass("ui-droppable ui-droppable-disabled");
  1662. },
  1663. _setOption: function(key, value) {
  1664. if(key === "accept") {
  1665. this.accept = $.isFunction(value) ? value : function(d) {
  1666. return d.is(value);
  1667. };
  1668. }
  1669. $.Widget.prototype._setOption.apply(this, arguments);
  1670. },
  1671. _activate: function(event) {
  1672. var draggable = $.ui.ddmanager.current;
  1673. if(this.options.activeClass) {
  1674. this.element.addClass(this.options.activeClass);
  1675. }
  1676. if(draggable){
  1677. this._trigger("activate", event, this.ui(draggable));
  1678. }
  1679. },
  1680. _deactivate: function(event) {
  1681. var draggable = $.ui.ddmanager.current;
  1682. if(this.options.activeClass) {
  1683. this.element.removeClass(this.options.activeClass);
  1684. }
  1685. if(draggable){
  1686. this._trigger("deactivate", event, this.ui(draggable));
  1687. }
  1688. },
  1689. _over: function(event) {
  1690. var draggable = $.ui.ddmanager.current;
  1691. // Bail if draggable and droppable are same element
  1692. if (!draggable || (draggable.currentItem || draggable.element)[0] === this.element[0]) {
  1693. return;
  1694. }
  1695. if (this.accept.call(this.element[0],(draggable.currentItem || draggable.element))) {
  1696. if(this.options.hoverClass) {
  1697. this.element.addClass(this.options.hoverClass);
  1698. }
  1699. this._trigger("over", event, this.ui(draggable));
  1700. }
  1701. },
  1702. _out: function(event) {
  1703. var draggable = $.ui.ddmanager.current;
  1704. // Bail if draggable and droppable are same element
  1705. if (!draggable || (draggable.currentItem || draggable.element)[0] === this.element[0]) {
  1706. return;
  1707. }
  1708. if (this.accept.call(this.element[0],(draggable.currentItem || draggable.element))) {
  1709. if(this.options.hoverClass) {
  1710. this.element.removeClass(this.options.hoverClass);
  1711. }
  1712. this._trigger("out", event, this.ui(draggable));
  1713. }
  1714. },
  1715. _drop: function(event,custom) {
  1716. var draggable = custom || $.ui.ddmanager.current,
  1717. childrenIntersection = false;
  1718. // Bail if draggable and droppable are same element
  1719. if (!draggable || (draggable.currentItem || draggable.element)[0] === this.element[0]) {
  1720. return false;
  1721. }
  1722. this.element.find(":data(ui-droppable)").not(".ui-draggable-dragging").each(function() {
  1723. var inst = $.data(this, "ui-droppable");
  1724. if(
  1725. inst.options.greedy &&
  1726. !inst.options.disabled &&
  1727. inst.options.scope === draggable.options.scope &&
  1728. inst.accept.call(inst.element[0], (draggable.currentItem || draggable.element)) &&
  1729. $.ui.intersect(draggable, $.extend(inst, { offset: inst.element.offset() }), inst.options.tolerance)
  1730. ) { childrenIntersection = true; return false; }
  1731. });
  1732. if(childrenIntersection) {
  1733. return false;
  1734. }
  1735. if(this.accept.call(this.element[0],(draggable.currentItem || draggable.element))) {
  1736. if(this.options.activeClass) {
  1737. this.element.removeClass(this.options.activeClass);
  1738. }
  1739. if(this.options.hoverClass) {
  1740. this.element.removeClass(this.options.hoverClass);
  1741. }
  1742. this._trigger("drop", event, this.ui(draggable));
  1743. return this.element;
  1744. }
  1745. return false;
  1746. },
  1747. ui: function(c) {
  1748. return {
  1749. draggable: (c.currentItem || c.element),
  1750. helper: c.helper,
  1751. position: c.position,
  1752. offset: c.positionAbs
  1753. };
  1754. }
  1755. });
  1756. $.ui.intersect = function(draggable, droppable, toleranceMode) {
  1757. if (!droppable.offset) {
  1758. return false;
  1759. }
  1760. var draggableLeft, draggableTop,
  1761. x1 = (draggable.positionAbs || draggable.position.absolute).left, x2 = x1 + draggable.helperProportions.width,
  1762. y1 = (draggable.positionAbs || draggable.position.absolute).top, y2 = y1 + draggable.helperProportions.height,
  1763. l = droppable.offset.left, r = l + droppable.proportions.width,
  1764. t = droppable.offset.top, b = t + droppable.proportions.height;
  1765. switch (toleranceMode) {
  1766. case "fit":
  1767. return (l <= x1 && x2 <= r && t <= y1 && y2 <= b);
  1768. case "intersect":
  1769. return (l < x1 + (draggable.helperProportions.width / 2) && // Right Half
  1770. x2 - (draggable.helperProportions.width / 2) < r && // Left Half
  1771. t < y1 + (draggable.helperProportions.height / 2) && // Bottom Half
  1772. y2 - (draggable.helperProportions.height / 2) < b ); // Top Half
  1773. case "pointer":
  1774. draggableLeft = ((draggable.positionAbs || draggable.position.absolute).left + (draggable.clickOffset || draggable.offset.click).left);
  1775. draggableTop = ((draggable.positionAbs || draggable.position.absolute).top + (draggable.clickOffset || draggable.offset.click).top);
  1776. return isOverAxis( draggableTop, t, droppable.proportions.height ) && isOverAxis( draggableLeft, l, droppable.proportions.width );
  1777. case "touch":
  1778. return (
  1779. (y1 >= t && y1 <= b) || // Top edge touching
  1780. (y2 >= t && y2 <= b) || // Bottom edge touching
  1781. (y1 < t && y2 > b) // Surrounded vertically
  1782. ) && (
  1783. (x1 >= l && x1 <= r) || // Left edge touching
  1784. (x2 >= l && x2 <= r) || // Right edge touching
  1785. (x1 < l && x2 > r) // Surrounded horizontally
  1786. );
  1787. default:
  1788. return false;
  1789. }
  1790. };
  1791. /*
  1792. This manager tracks offsets of draggables and droppables
  1793. */
  1794. $.ui.ddmanager = {
  1795. current: null,
  1796. droppables: { "default": [] },
  1797. prepareOffsets: function(t, event) {
  1798. var i, j,
  1799. m = $.ui.ddmanager.droppables[t.options.scope] || [],
  1800. type = event ? event.type : null, // workaround for #2317
  1801. list = (t.currentItem || t.element).find(":data(ui-droppable)").addBack();
  1802. droppablesLoop: for (i = 0; i < m.length; i++) {
  1803. //No disabled and non-accepted
  1804. if(m[i].options.disabled || (t && !m[i].accept.call(m[i].element[0],(t.currentItem || t.element)))) {
  1805. continue;
  1806. }
  1807. // Filter out elements in the current dragged item
  1808. for (j=0; j < list.length; j++) {
  1809. if(list[j] === m[i].element[0]) {
  1810. m[i].proportions.height = 0;
  1811. continue droppablesLoop;
  1812. }
  1813. }
  1814. m[i].visible = m[i].element.css("display") !== "none";
  1815. if(!m[i].visible) {
  1816. continue;
  1817. }
  1818. //Activate the droppable if used directly from draggables
  1819. if(type === "mousedown") {
  1820. m[i]._activate.call(m[i], event);
  1821. }
  1822. m[i].offset = m[i].element.offset();
  1823. m[i].proportions = { width: m[i].element[0].offsetWidth, height: m[i].element[0].offsetHeight };
  1824. }
  1825. },
  1826. drop: function(draggable, event) {
  1827. var dropped = false;
  1828. $.each($.ui.ddmanager.droppables[draggable.options.scope] || [], function() {
  1829. if(!this.options) {
  1830. return;
  1831. }
  1832. if (!this.options.disabled && this.visible && $.ui.intersect(draggable, this, this.options.tolerance)) {
  1833. dropped = this._drop.call(this, event) || dropped;
  1834. }
  1835. if (!this.options.disabled && this.visible && this.accept.call(this.element[0],(draggable.currentItem || draggable.element))) {
  1836. this.isout = true;
  1837. this.isover = false;
  1838. this._deactivate.call(this, event);
  1839. }
  1840. });
  1841. return dropped;
  1842. },
  1843. dragStart: function( draggable, event ) {
  1844. //Listen for scrolling so that if the dragging causes scrolling the position of the droppables can be recalculated (see #5003)
  1845. draggable.element.parentsUntil( "body" ).bind( "scroll.droppable", function() {
  1846. if( !draggable.options.refreshPositions ) {
  1847. $.ui.ddmanager.prepareOffsets( draggable, event );
  1848. }
  1849. });
  1850. },
  1851. drag: function(draggable, event) {
  1852. //If you have a highly dynamic page, you might try this option. It renders positions every time you move the mouse.
  1853. if(draggable.options.refreshPositions) {
  1854. $.ui.ddmanager.prepareOffsets(draggable, event);
  1855. }
  1856. //Run through all droppables and check their positions based on specific tolerance options
  1857. $.each($.ui.ddmanager.droppables[draggable.options.scope] || [], function() {
  1858. if(this.options.disabled || this.greedyChild || !this.visible) {
  1859. return;
  1860. }
  1861. var parentInstance, scope, parent,
  1862. intersects = $.ui.intersect(draggable, this, this.options.tolerance),
  1863. c = !intersects && this.isover ? "isout" : (intersects && !this.isover ? "isover" : null);
  1864. if(!c) {
  1865. return;
  1866. }
  1867. if (this.options.greedy) {
  1868. // find droppable parents with same scope
  1869. scope = this.options.scope;
  1870. parent = this.element.parents(":data(ui-droppable)").filter(function () {
  1871. return $.data(this, "ui-droppable").options.scope === scope;
  1872. });
  1873. if (parent.length) {
  1874. parentInstance = $.data(parent[0], "ui-droppable");
  1875. parentInstance.greedyChild = (c === "isover");
  1876. }
  1877. }
  1878. // we just moved into a greedy child
  1879. if (parentInstance && c === "isover") {
  1880. parentInstance.isover = false;
  1881. parentInstance.isout = true;
  1882. parentInstance._out.call(parentInstance, event);
  1883. }
  1884. this[c] = true;
  1885. this[c === "isout" ? "isover" : "isout"] = false;
  1886. this[c === "isover" ? "_over" : "_out"].call(this, event);
  1887. // we just moved out of a greedy child
  1888. if (parentInstance && c === "isout") {
  1889. parentInstance.isout = false;
  1890. parentInstance.isover = true;
  1891. parentInstance._over.call(parentInstance, event);
  1892. }
  1893. });
  1894. },
  1895. dragStop: function( draggable, event ) {
  1896. draggable.element.parentsUntil( "body" ).unbind( "scroll.droppable" );
  1897. //Call prepareOffsets one final time since IE does not fire return scroll events when overflow was caused by drag (see #5003)
  1898. if( !draggable.options.refreshPositions ) {
  1899. $.ui.ddmanager.prepareOffsets( draggable, event );
  1900. }
  1901. }
  1902. };
  1903. })(jQuery);
  1904. (function( $, undefined ) {
  1905. function num(v) {
  1906. return parseInt(v, 10) || 0;
  1907. }
  1908. function isNumber(value) {
  1909. return !isNaN(parseInt(value, 10));
  1910. }
  1911. $.widget("ui.resizable", $.ui.mouse, {
  1912. version: "1.10.1",
  1913. widgetEventPrefix: "resize",
  1914. options: {
  1915. alsoResize: false,
  1916. animate: false,
  1917. animateDuration: "slow",
  1918. animateEasing: "swing",
  1919. aspectRatio: false,
  1920. autoHide: false,
  1921. containment: false,
  1922. ghost: false,
  1923. grid: false,
  1924. handles: "e,s,se",
  1925. helper: false,
  1926. maxHeight: null,
  1927. maxWidth: null,
  1928. minHeight: 10,
  1929. minWidth: 10,
  1930. // See #7960
  1931. zIndex: 90,
  1932. // callbacks
  1933. resize: null,
  1934. start: null,
  1935. stop: null
  1936. },
  1937. _create: function() {
  1938. var n, i, handle, axis, hname,
  1939. that = this,
  1940. o = this.options;
  1941. this.element.addClass("ui-resizable");
  1942. $.extend(this, {
  1943. _aspectRatio: !!(o.aspectRatio),
  1944. aspectRatio: o.aspectRatio,
  1945. originalElement: this.element,
  1946. _proportionallyResizeElements: [],
  1947. _helper: o.helper || o.ghost || o.animate ? o.helper || "ui-resizable-helper" : null
  1948. });
  1949. //Wrap the element if it cannot hold child nodes
  1950. if(this.element[0].nodeName.match(/canvas|textarea|input|select|button|img/i)) {
  1951. //Create a wrapper element and set the wrapper to the new current internal element
  1952. this.element.wrap(
  1953. $("<div class='ui-wrapper' style='overflow: hidden;'></div>").css({
  1954. position: this.element.css("position"),
  1955. width: this.element.outerWidth(),
  1956. height: this.element.outerHeight(),
  1957. top: this.element.css("top"),
  1958. left: this.element.css("left")
  1959. })
  1960. );
  1961. //Overwrite the original this.element
  1962. this.element = this.element.parent().data(
  1963. "ui-resizable", this.element.data("ui-resizable")
  1964. );
  1965. this.elementIsWrapper = true;
  1966. //Move margins to the wrapper
  1967. this.element.css({ marginLeft: this.originalElement.css("marginLeft"), marginTop: this.originalElement.css("marginTop"), marginRight: this.originalElement.css("marginRight"), marginBottom: this.originalElement.css("marginBottom") });
  1968. this.originalElement.css({ marginLeft: 0, marginTop: 0, marginRight: 0, marginBottom: 0});
  1969. //Prevent Safari textarea resize
  1970. this.originalResizeStyle = this.originalElement.css("resize");
  1971. this.originalElement.css("resize", "none");
  1972. //Push the actual element to our proportionallyResize internal array
  1973. this._proportionallyResizeElements.push(this.originalElement.css({ position: "static", zoom: 1, display: "block" }));
  1974. // avoid IE jump (hard set the margin)
  1975. this.originalElement.css({ margin: this.originalElement.css("margin") });
  1976. // fix handlers offset
  1977. this._proportionallyResize();
  1978. }
  1979. this.handles = o.handles || (!$(".ui-resizable-handle", this.element).length ? "e,s,se" : { n: ".ui-resizable-n", e: ".ui-resizable-e", s: ".ui-resizable-s", w: ".ui-resizable-w", se: ".ui-resizable-se", sw: ".ui-resizable-sw", ne: ".ui-resizable-ne", nw: ".ui-resizable-nw" });
  1980. if(this.handles.constructor === String) {
  1981. if ( this.handles === "all") {
  1982. this.handles = "n,e,s,w,se,sw,ne,nw";
  1983. }
  1984. n = this.handles.split(",");
  1985. this.handles = {};
  1986. for(i = 0; i < n.length; i++) {
  1987. handle = $.trim(n[i]);
  1988. hname = "ui-resizable-"+handle;
  1989. axis = $("<div class='ui-resizable-handle " + hname + "'></div>");
  1990. // Apply zIndex to all handles - see #7960
  1991. axis.css({ zIndex: o.zIndex });
  1992. //TODO : What's going on here?
  1993. if ("se" === handle) {
  1994. axis.addClass("ui-icon ui-icon-gripsmall-diagonal-se");
  1995. }
  1996. //Insert into internal handles object and append to element
  1997. this.handles[handle] = ".ui-resizable-"+handle;
  1998. this.element.append(axis);
  1999. }
  2000. }
  2001. this._renderAxis = function(target) {
  2002. var i, axis, padPos, padWrapper;
  2003. target = target || this.element;
  2004. for(i in this.handles) {
  2005. if(this.handles[i].constructor === String) {
  2006. this.handles[i] = $(this.handles[i], this.element).show();
  2007. }
  2008. //Apply pad to wrapper element, needed to fix axis position (textarea, inputs, scrolls)
  2009. if (this.elementIsWrapper && this.originalElement[0].nodeName.match(/textarea|input|select|button/i)) {
  2010. axis = $(this.handles[i], this.element);
  2011. //Checking the correct pad and border
  2012. padWrapper = /sw|ne|nw|se|n|s/.test(i) ? axis.outerHeight() : axis.outerWidth();
  2013. //The padding type i have to apply...
  2014. padPos = [ "padding",
  2015. /ne|nw|n/.test(i) ? "Top" :
  2016. /se|sw|s/.test(i) ? "Bottom" :
  2017. /^e$/.test(i) ? "Right" : "Left" ].join("");
  2018. target.css(padPos, padWrapper);
  2019. this._proportionallyResize();
  2020. }
  2021. //TODO: What's that good for? There's not anything to be executed left
  2022. if(!$(this.handles[i]).length) {
  2023. continue;
  2024. }
  2025. }
  2026. };
  2027. //TODO: make renderAxis a prototype function
  2028. this._renderAxis(this.element);
  2029. this._handles = $(".ui-resizable-handle", this.element)
  2030. .disableSelection();
  2031. //Matching axis name
  2032. this._handles.mouseover(function() {
  2033. if (!that.resizing) {
  2034. if (this.className) {
  2035. axis = this.className.match(/ui-resizable-(se|sw|ne|nw|n|e|s|w)/i);
  2036. }
  2037. //Axis, default = se
  2038. that.axis = axis && axis[1] ? axis[1] : "se";
  2039. }
  2040. });
  2041. //If we want to auto hide the elements
  2042. if (o.autoHide) {
  2043. this._handles.hide();
  2044. $(this.element)
  2045. .addClass("ui-resizable-autohide")
  2046. .mouseenter(function() {
  2047. if (o.disabled) {
  2048. return;
  2049. }
  2050. $(this).removeClass("ui-resizable-autohide");
  2051. that._handles.show();
  2052. })
  2053. .mouseleave(function(){
  2054. if (o.disabled) {
  2055. return;
  2056. }
  2057. if (!that.resizing) {
  2058. $(this).addClass("ui-resizable-autohide");
  2059. that._handles.hide();
  2060. }
  2061. });
  2062. }
  2063. //Initialize the mouse interaction
  2064. this._mouseInit();
  2065. },
  2066. _destroy: function() {
  2067. this._mouseDestroy();
  2068. var wrapper,
  2069. _destroy = function(exp) {
  2070. $(exp).removeClass("ui-resizable ui-resizable-disabled ui-resizable-resizing")
  2071. .removeData("resizable").removeData("ui-resizable").unbind(".resizable").find(".ui-resizable-handle").remove();
  2072. };
  2073. //TODO: Unwrap at same DOM position
  2074. if (this.elementIsWrapper) {
  2075. _destroy(this.element);
  2076. wrapper = this.element;
  2077. this.originalElement.css({
  2078. position: wrapper.css("position"),
  2079. width: wrapper.outerWidth(),
  2080. height: wrapper.outerHeight(),
  2081. top: wrapper.css("top"),
  2082. left: wrapper.css("left")
  2083. }).insertAfter( wrapper );
  2084. wrapper.remove();
  2085. }
  2086. this.originalElement.css("resize", this.originalResizeStyle);
  2087. _destroy(this.originalElement);
  2088. return this;
  2089. },
  2090. _mouseCapture: function(event) {
  2091. var i, handle,
  2092. capture = false;
  2093. for (i in this.handles) {
  2094. handle = $(this.handles[i])[0];
  2095. if (handle === event.target || $.contains(handle, event.target)) {
  2096. capture = true;
  2097. }
  2098. }
  2099. return !this.options.disabled && capture;
  2100. },
  2101. _mouseStart: function(event) {
  2102. var curleft, curtop, cursor,
  2103. o = this.options,
  2104. iniPos = this.element.position(),
  2105. el = this.element;
  2106. this.resizing = true;
  2107. // bugfix for http://dev.jquery.com/ticket/1749
  2108. if ( (/absolute/).test( el.css("position") ) ) {
  2109. el.css({ position: "absolute", top: el.css("top"), left: el.css("left") });
  2110. } else if (el.is(".ui-draggable")) {
  2111. el.css({ position: "absolute", top: iniPos.top, left: iniPos.left });
  2112. }
  2113. this._renderProxy();
  2114. curleft = num(this.helper.css("left"));
  2115. curtop = num(this.helper.css("top"));
  2116. if (o.containment) {
  2117. curleft += $(o.containment).scrollLeft() || 0;
  2118. curtop += $(o.containment).scrollTop() || 0;
  2119. }
  2120. //Store needed variables
  2121. this.offset = this.helper.offset();
  2122. this.position = { left: curleft, top: curtop };
  2123. this.size = this._helper ? { width: el.outerWidth(), height: el.outerHeight() } : { width: el.width(), height: el.height() };
  2124. this.originalSize = this._helper ? { width: el.outerWidth(), height: el.outerHeight() } : { width: el.width(), height: el.height() };
  2125. this.originalPosition = { left: curleft, top: curtop };
  2126. this.sizeDiff = { width: el.outerWidth() - el.width(), height: el.outerHeight() - el.height() };
  2127. this.originalMousePosition = { left: event.pageX, top: event.pageY };
  2128. //Aspect Ratio
  2129. this.aspectRatio = (typeof o.aspectRatio === "number") ? o.aspectRatio : ((this.originalSize.width / this.originalSize.height) || 1);
  2130. cursor = $(".ui-resizable-" + this.axis).css("cursor");
  2131. $("body").css("cursor", cursor === "auto" ? this.axis + "-resize" : cursor);
  2132. el.addClass("ui-resizable-resizing");
  2133. this._propagate("start", event);
  2134. return true;
  2135. },
  2136. _mouseDrag: function(event) {
  2137. //Increase performance, avoid regex
  2138. var data,
  2139. el = this.helper, props = {},
  2140. smp = this.originalMousePosition,
  2141. a = this.axis,
  2142. prevTop = this.position.top,
  2143. prevLeft = this.position.left,
  2144. prevWidth = this.size.width,
  2145. prevHeight = this.size.height,
  2146. dx = (event.pageX-smp.left)||0,
  2147. dy = (event.pageY-smp.top)||0,
  2148. trigger = this._change[a];
  2149. if (!trigger) {
  2150. return false;
  2151. }
  2152. // Calculate the attrs that will be change
  2153. data = trigger.apply(this, [event, dx, dy]);
  2154. // Put this in the mouseDrag handler since the user can start pressing shift while resizing
  2155. this._updateVirtualBoundaries(event.shiftKey);
  2156. if (this._aspectRatio || event.shiftKey) {
  2157. data = this._updateRatio(data, event);
  2158. }
  2159. data = this._respectSize(data, event);
  2160. this._updateCache(data);
  2161. // plugins callbacks need to be called first
  2162. this._propagate("resize", event);
  2163. if (this.position.top !== prevTop) {
  2164. props.top = this.position.top + "px";
  2165. }
  2166. if (this.position.left !== prevLeft) {
  2167. props.left = this.position.left + "px";
  2168. }
  2169. if (this.size.width !== prevWidth) {
  2170. props.width = this.size.width + "px";
  2171. }
  2172. if (this.size.height !== prevHeight) {
  2173. props.height = this.size.height + "px";
  2174. }
  2175. el.css(props);
  2176. if (!this._helper && this._proportionallyResizeElements.length) {
  2177. this._proportionallyResize();
  2178. }
  2179. // Call the user callback if the element was resized
  2180. if ( ! $.isEmptyObject(props) ) {
  2181. this._trigger("resize", event, this.ui());
  2182. }
  2183. return false;
  2184. },
  2185. _mouseStop: function(event) {
  2186. this.resizing = false;
  2187. var pr, ista, soffseth, soffsetw, s, left, top,
  2188. o = this.options, that = this;
  2189. if(this._helper) {
  2190. pr = this._proportionallyResizeElements;
  2191. ista = pr.length && (/textarea/i).test(pr[0].nodeName);
  2192. soffseth = ista && $.ui.hasScroll(pr[0], "left") /* TODO - jump height */ ? 0 : that.sizeDiff.height;
  2193. soffsetw = ista ? 0 : that.sizeDiff.width;
  2194. s = { width: (that.helper.width() - soffsetw), height: (that.helper.height() - soffseth) };
  2195. left = (parseInt(that.element.css("left"), 10) + (that.position.left - that.originalPosition.left)) || null;
  2196. top = (parseInt(that.element.css("top"), 10) + (that.position.top - that.originalPosition.top)) || null;
  2197. if (!o.animate) {
  2198. this.element.css($.extend(s, { top: top, left: left }));
  2199. }
  2200. that.helper.height(that.size.height);
  2201. that.helper.width(that.size.width);
  2202. if (this._helper && !o.animate) {
  2203. this._proportionallyResize();
  2204. }
  2205. }
  2206. $("body").css("cursor", "auto");
  2207. this.element.removeClass("ui-resizable-resizing");
  2208. this._propagate("stop", event);
  2209. if (this._helper) {
  2210. this.helper.remove();
  2211. }
  2212. return false;
  2213. },
  2214. _updateVirtualBoundaries: function(forceAspectRatio) {
  2215. var pMinWidth, pMaxWidth, pMinHeight, pMaxHeight, b,
  2216. o = this.options;
  2217. b = {
  2218. minWidth: isNumber(o.minWidth) ? o.minWidth : 0,
  2219. maxWidth: isNumber(o.maxWidth) ? o.maxWidth : Infinity,
  2220. minHeight: isNumber(o.minHeight) ? o.minHeight : 0,
  2221. maxHeight: isNumber(o.maxHeight) ? o.maxHeight : Infinity
  2222. };
  2223. if(this._aspectRatio || forceAspectRatio) {
  2224. // We want to create an enclosing box whose aspect ration is the requested one
  2225. // First, compute the "projected" size for each dimension based on the aspect ratio and other dimension
  2226. pMinWidth = b.minHeight * this.aspectRatio;
  2227. pMinHeight = b.minWidth / this.aspectRatio;
  2228. pMaxWidth = b.maxHeight * this.aspectRatio;
  2229. pMaxHeight = b.maxWidth / this.aspectRatio;
  2230. if(pMinWidth > b.minWidth) {
  2231. b.minWidth = pMinWidth;
  2232. }
  2233. if(pMinHeight > b.minHeight) {
  2234. b.minHeight = pMinHeight;
  2235. }
  2236. if(pMaxWidth < b.maxWidth) {
  2237. b.maxWidth = pMaxWidth;
  2238. }
  2239. if(pMaxHeight < b.maxHeight) {
  2240. b.maxHeight = pMaxHeight;
  2241. }
  2242. }
  2243. this._vBoundaries = b;
  2244. },
  2245. _updateCache: function(data) {
  2246. this.offset = this.helper.offset();
  2247. if (isNumber(data.left)) {
  2248. this.position.left = data.left;
  2249. }
  2250. if (isNumber(data.top)) {
  2251. this.position.top = data.top;
  2252. }
  2253. if (isNumber(data.height)) {
  2254. this.size.height = data.height;
  2255. }
  2256. if (isNumber(data.width)) {
  2257. this.size.width = data.width;
  2258. }
  2259. },
  2260. _updateRatio: function( data ) {
  2261. var cpos = this.position,
  2262. csize = this.size,
  2263. a = this.axis;
  2264. if (isNumber(data.height)) {
  2265. data.width = (data.height * this.aspectRatio);
  2266. } else if (isNumber(data.width)) {
  2267. data.height = (data.width / this.aspectRatio);
  2268. }
  2269. if (a === "sw") {
  2270. data.left = cpos.left + (csize.width - data.width);
  2271. data.top = null;
  2272. }
  2273. if (a === "nw") {
  2274. data.top = cpos.top + (csize.height - data.height);
  2275. data.left = cpos.left + (csize.width - data.width);
  2276. }
  2277. return data;
  2278. },
  2279. _respectSize: function( data ) {
  2280. var o = this._vBoundaries,
  2281. a = this.axis,
  2282. ismaxw = isNumber(data.width) && o.maxWidth && (o.maxWidth < data.width), ismaxh = isNumber(data.height) && o.maxHeight && (o.maxHeight < data.height),
  2283. isminw = isNumber(data.width) && o.minWidth && (o.minWidth > data.width), isminh = isNumber(data.height) && o.minHeight && (o.minHeight > data.height),
  2284. dw = this.originalPosition.left + this.originalSize.width,
  2285. dh = this.position.top + this.size.height,
  2286. cw = /sw|nw|w/.test(a), ch = /nw|ne|n/.test(a);
  2287. if (isminw) {
  2288. data.width = o.minWidth;
  2289. }
  2290. if (isminh) {
  2291. data.height = o.minHeight;
  2292. }
  2293. if (ismaxw) {
  2294. data.width = o.maxWidth;
  2295. }
  2296. if (ismaxh) {
  2297. data.height = o.maxHeight;
  2298. }
  2299. if (isminw && cw) {
  2300. data.left = dw - o.minWidth;
  2301. }
  2302. if (ismaxw && cw) {
  2303. data.left = dw - o.maxWidth;
  2304. }
  2305. if (isminh && ch) {
  2306. data.top = dh - o.minHeight;
  2307. }
  2308. if (ismaxh && ch) {
  2309. data.top = dh - o.maxHeight;
  2310. }
  2311. // fixing jump error on top/left - bug #2330
  2312. if (!data.width && !data.height && !data.left && data.top) {
  2313. data.top = null;
  2314. } else if (!data.width && !data.height && !data.top && data.left) {
  2315. data.left = null;
  2316. }
  2317. return data;
  2318. },
  2319. _proportionallyResize: function() {
  2320. if (!this._proportionallyResizeElements.length) {
  2321. return;
  2322. }
  2323. var i, j, borders, paddings, prel,
  2324. element = this.helper || this.element;
  2325. for ( i=0; i < this._proportionallyResizeElements.length; i++) {
  2326. prel = this._proportionallyResizeElements[i];
  2327. if (!this.borderDif) {
  2328. this.borderDif = [];
  2329. borders = [prel.css("borderTopWidth"), prel.css("borderRightWidth"), prel.css("borderBottomWidth"), prel.css("borderLeftWidth")];
  2330. paddings = [prel.css("paddingTop"), prel.css("paddingRight"), prel.css("paddingBottom"), prel.css("paddingLeft")];
  2331. for ( j = 0; j < borders.length; j++ ) {
  2332. this.borderDif[ j ] = ( parseInt( borders[ j ], 10 ) || 0 ) + ( parseInt( paddings[ j ], 10 ) || 0 );
  2333. }
  2334. }
  2335. prel.css({
  2336. height: (element.height() - this.borderDif[0] - this.borderDif[2]) || 0,
  2337. width: (element.width() - this.borderDif[1] - this.borderDif[3]) || 0
  2338. });
  2339. }
  2340. },
  2341. _renderProxy: function() {
  2342. var el = this.element, o = this.options;
  2343. this.elementOffset = el.offset();
  2344. if(this._helper) {
  2345. this.helper = this.helper || $("<div style='overflow:hidden;'></div>");
  2346. this.helper.addClass(this._helper).css({
  2347. width: this.element.outerWidth() - 1,
  2348. height: this.element.outerHeight() - 1,
  2349. position: "absolute",
  2350. left: this.elementOffset.left +"px",
  2351. top: this.elementOffset.top +"px",
  2352. zIndex: ++o.zIndex //TODO: Don't modify option
  2353. });
  2354. this.helper
  2355. .appendTo("body")
  2356. .disableSelection();
  2357. } else {
  2358. this.helper = this.element;
  2359. }
  2360. },
  2361. _change: {
  2362. e: function(event, dx) {
  2363. return { width: this.originalSize.width + dx };
  2364. },
  2365. w: function(event, dx) {
  2366. var cs = this.originalSize, sp = this.originalPosition;
  2367. return { left: sp.left + dx, width: cs.width - dx };
  2368. },
  2369. n: function(event, dx, dy) {
  2370. var cs = this.originalSize, sp = this.originalPosition;
  2371. return { top: sp.top + dy, height: cs.height - dy };
  2372. },
  2373. s: function(event, dx, dy) {
  2374. return { height: this.originalSize.height + dy };
  2375. },
  2376. se: function(event, dx, dy) {
  2377. return $.extend(this._change.s.apply(this, arguments), this._change.e.apply(this, [event, dx, dy]));
  2378. },
  2379. sw: function(event, dx, dy) {
  2380. return $.extend(this._change.s.apply(this, arguments), this._change.w.apply(this, [event, dx, dy]));
  2381. },
  2382. ne: function(event, dx, dy) {
  2383. return $.extend(this._change.n.apply(this, arguments), this._change.e.apply(this, [event, dx, dy]));
  2384. },
  2385. nw: function(event, dx, dy) {
  2386. return $.extend(this._change.n.apply(this, arguments), this._change.w.apply(this, [event, dx, dy]));
  2387. }
  2388. },
  2389. _propagate: function(n, event) {
  2390. $.ui.plugin.call(this, n, [event, this.ui()]);
  2391. (n !== "resize" && this._trigger(n, event, this.ui()));
  2392. },
  2393. plugins: {},
  2394. ui: function() {
  2395. return {
  2396. originalElement: this.originalElement,
  2397. element: this.element,
  2398. helper: this.helper,
  2399. position: this.position,
  2400. size: this.size,
  2401. originalSize: this.originalSize,
  2402. originalPosition: this.originalPosition
  2403. };
  2404. }
  2405. });
  2406. /*
  2407. * Resizable Extensions
  2408. */
  2409. $.ui.plugin.add("resizable", "animate", {
  2410. stop: function( event ) {
  2411. var that = $(this).data("ui-resizable"),
  2412. o = that.options,
  2413. pr = that._proportionallyResizeElements,
  2414. ista = pr.length && (/textarea/i).test(pr[0].nodeName),
  2415. soffseth = ista && $.ui.hasScroll(pr[0], "left") /* TODO - jump height */ ? 0 : that.sizeDiff.height,
  2416. soffsetw = ista ? 0 : that.sizeDiff.width,
  2417. style = { width: (that.size.width - soffsetw), height: (that.size.height - soffseth) },
  2418. left = (parseInt(that.element.css("left"), 10) + (that.position.left - that.originalPosition.left)) || null,
  2419. top = (parseInt(that.element.css("top"), 10) + (that.position.top - that.originalPosition.top)) || null;
  2420. that.element.animate(
  2421. $.extend(style, top && left ? { top: top, left: left } : {}), {
  2422. duration: o.animateDuration,
  2423. easing: o.animateEasing,
  2424. step: function() {
  2425. var data = {
  2426. width: parseInt(that.element.css("width"), 10),
  2427. height: parseInt(that.element.css("height"), 10),
  2428. top: parseInt(that.element.css("top"), 10),
  2429. left: parseInt(that.element.css("left"), 10)
  2430. };
  2431. if (pr && pr.length) {
  2432. $(pr[0]).css({ width: data.width, height: data.height });
  2433. }
  2434. // propagating resize, and updating values for each animation step
  2435. that._updateCache(data);
  2436. that._propagate("resize", event);
  2437. }
  2438. }
  2439. );
  2440. }
  2441. });
  2442. $.ui.plugin.add("resizable", "containment", {
  2443. start: function() {
  2444. var element, p, co, ch, cw, width, height,
  2445. that = $(this).data("ui-resizable"),
  2446. o = that.options,
  2447. el = that.element,
  2448. oc = o.containment,
  2449. ce = (oc instanceof $) ? oc.get(0) : (/parent/.test(oc)) ? el.parent().get(0) : oc;
  2450. if (!ce) {
  2451. return;
  2452. }
  2453. that.containerElement = $(ce);
  2454. if (/document/.test(oc) || oc === document) {
  2455. that.containerOffset = { left: 0, top: 0 };
  2456. that.containerPosition = { left: 0, top: 0 };
  2457. that.parentData = {
  2458. element: $(document), left: 0, top: 0,
  2459. width: $(document).width(), height: $(document).height() || document.body.parentNode.scrollHeight
  2460. };
  2461. }
  2462. // i'm a node, so compute top, left, right, bottom
  2463. else {
  2464. element = $(ce);
  2465. p = [];
  2466. $([ "Top", "Right", "Left", "Bottom" ]).each(function(i, name) { p[i] = num(element.css("padding" + name)); });
  2467. that.containerOffset = element.offset();
  2468. that.containerPosition = element.position();
  2469. that.containerSize = { height: (element.innerHeight() - p[3]), width: (element.innerWidth() - p[1]) };
  2470. co = that.containerOffset;
  2471. ch = that.containerSize.height;
  2472. cw = that.containerSize.width;
  2473. width = ($.ui.hasScroll(ce, "left") ? ce.scrollWidth : cw );
  2474. height = ($.ui.hasScroll(ce) ? ce.scrollHeight : ch);
  2475. that.parentData = {
  2476. element: ce, left: co.left, top: co.top, width: width, height: height
  2477. };
  2478. }
  2479. },
  2480. resize: function( event ) {
  2481. var woset, hoset, isParent, isOffsetRelative,
  2482. that = $(this).data("ui-resizable"),
  2483. o = that.options,
  2484. co = that.containerOffset, cp = that.position,
  2485. pRatio = that._aspectRatio || event.shiftKey,
  2486. cop = { top:0, left:0 }, ce = that.containerElement;
  2487. if (ce[0] !== document && (/static/).test(ce.css("position"))) {
  2488. cop = co;
  2489. }
  2490. if (cp.left < (that._helper ? co.left : 0)) {
  2491. that.size.width = that.size.width + (that._helper ? (that.position.left - co.left) : (that.position.left - cop.left));
  2492. if (pRatio) {
  2493. that.size.height = that.size.width / that.aspectRatio;
  2494. }
  2495. that.position.left = o.helper ? co.left : 0;
  2496. }
  2497. if (cp.top < (that._helper ? co.top : 0)) {
  2498. that.size.height = that.size.height + (that._helper ? (that.position.top - co.top) : that.position.top);
  2499. if (pRatio) {
  2500. that.size.width = that.size.height * that.aspectRatio;
  2501. }
  2502. that.position.top = that._helper ? co.top : 0;
  2503. }
  2504. that.offset.left = that.parentData.left+that.position.left;
  2505. that.offset.top = that.parentData.top+that.position.top;
  2506. woset = Math.abs( (that._helper ? that.offset.left - cop.left : (that.offset.left - cop.left)) + that.sizeDiff.width );
  2507. hoset = Math.abs( (that._helper ? that.offset.top - cop.top : (that.offset.top - co.top)) + that.sizeDiff.height );
  2508. isParent = that.containerElement.get(0) === that.element.parent().get(0);
  2509. isOffsetRelative = /relative|absolute/.test(that.containerElement.css("position"));
  2510. if(isParent && isOffsetRelative) {
  2511. woset -= that.parentData.left;
  2512. }
  2513. if (woset + that.size.width >= that.parentData.width) {
  2514. that.size.width = that.parentData.width - woset;
  2515. if (pRatio) {
  2516. that.size.height = that.size.width / that.aspectRatio;
  2517. }
  2518. }
  2519. if (hoset + that.size.height >= that.parentData.height) {
  2520. that.size.height = that.parentData.height - hoset;
  2521. if (pRatio) {
  2522. that.size.width = that.size.height * that.aspectRatio;
  2523. }
  2524. }
  2525. },
  2526. stop: function(){
  2527. var that = $(this).data("ui-resizable"),
  2528. o = that.options,
  2529. co = that.containerOffset,
  2530. cop = that.containerPosition,
  2531. ce = that.containerElement,
  2532. helper = $(that.helper),
  2533. ho = helper.offset(),
  2534. w = helper.outerWidth() - that.sizeDiff.width,
  2535. h = helper.outerHeight() - that.sizeDiff.height;
  2536. if (that._helper && !o.animate && (/relative/).test(ce.css("position"))) {
  2537. $(this).css({ left: ho.left - cop.left - co.left, width: w, height: h });
  2538. }
  2539. if (that._helper && !o.animate && (/static/).test(ce.css("position"))) {
  2540. $(this).css({ left: ho.left - cop.left - co.left, width: w, height: h });
  2541. }
  2542. }
  2543. });
  2544. $.ui.plugin.add("resizable", "alsoResize", {
  2545. start: function () {
  2546. var that = $(this).data("ui-resizable"),
  2547. o = that.options,
  2548. _store = function (exp) {
  2549. $(exp).each(function() {
  2550. var el = $(this);
  2551. el.data("ui-resizable-alsoresize", {
  2552. width: parseInt(el.width(), 10), height: parseInt(el.height(), 10),
  2553. left: parseInt(el.css("left"), 10), top: parseInt(el.css("top"), 10)
  2554. });
  2555. });
  2556. };
  2557. if (typeof(o.alsoResize) === "object" && !o.alsoResize.parentNode) {
  2558. if (o.alsoResize.length) { o.alsoResize = o.alsoResize[0]; _store(o.alsoResize); }
  2559. else { $.each(o.alsoResize, function (exp) { _store(exp); }); }
  2560. }else{
  2561. _store(o.alsoResize);
  2562. }
  2563. },
  2564. resize: function (event, ui) {
  2565. var that = $(this).data("ui-resizable"),
  2566. o = that.options,
  2567. os = that.originalSize,
  2568. op = that.originalPosition,
  2569. delta = {
  2570. height: (that.size.height - os.height) || 0, width: (that.size.width - os.width) || 0,
  2571. top: (that.position.top - op.top) || 0, left: (that.position.left - op.left) || 0
  2572. },
  2573. _alsoResize = function (exp, c) {
  2574. $(exp).each(function() {
  2575. var el = $(this), start = $(this).data("ui-resizable-alsoresize"), style = {},
  2576. css = c && c.length ? c : el.parents(ui.originalElement[0]).length ? ["width", "height"] : ["width", "height", "top", "left"];
  2577. $.each(css, function (i, prop) {
  2578. var sum = (start[prop]||0) + (delta[prop]||0);
  2579. if (sum && sum >= 0) {
  2580. style[prop] = sum || null;
  2581. }
  2582. });
  2583. el.css(style);
  2584. });
  2585. };
  2586. if (typeof(o.alsoResize) === "object" && !o.alsoResize.nodeType) {
  2587. $.each(o.alsoResize, function (exp, c) { _alsoResize(exp, c); });
  2588. }else{
  2589. _alsoResize(o.alsoResize);
  2590. }
  2591. },
  2592. stop: function () {
  2593. $(this).removeData("resizable-alsoresize");
  2594. }
  2595. });
  2596. $.ui.plugin.add("resizable", "ghost", {
  2597. start: function() {
  2598. var that = $(this).data("ui-resizable"), o = that.options, cs = that.size;
  2599. that.ghost = that.originalElement.clone();
  2600. that.ghost
  2601. .css({ opacity: 0.25, display: "block", position: "relative", height: cs.height, width: cs.width, margin: 0, left: 0, top: 0 })
  2602. .addClass("ui-resizable-ghost")
  2603. .addClass(typeof o.ghost === "string" ? o.ghost : "");
  2604. that.ghost.appendTo(that.helper);
  2605. },
  2606. resize: function(){
  2607. var that = $(this).data("ui-resizable");
  2608. if (that.ghost) {
  2609. that.ghost.css({ position: "relative", height: that.size.height, width: that.size.width });
  2610. }
  2611. },
  2612. stop: function() {
  2613. var that = $(this).data("ui-resizable");
  2614. if (that.ghost && that.helper) {
  2615. that.helper.get(0).removeChild(that.ghost.get(0));
  2616. }
  2617. }
  2618. });
  2619. $.ui.plugin.add("resizable", "grid", {
  2620. resize: function() {
  2621. var that = $(this).data("ui-resizable"),
  2622. o = that.options,
  2623. cs = that.size,
  2624. os = that.originalSize,
  2625. op = that.originalPosition,
  2626. a = that.axis,
  2627. grid = typeof o.grid === "number" ? [o.grid, o.grid] : o.grid,
  2628. gridX = (grid[0]||1),
  2629. gridY = (grid[1]||1),
  2630. ox = Math.round((cs.width - os.width) / gridX) * gridX,
  2631. oy = Math.round((cs.height - os.height) / gridY) * gridY,
  2632. newWidth = os.width + ox,
  2633. newHeight = os.height + oy,
  2634. isMaxWidth = o.maxWidth && (o.maxWidth < newWidth),
  2635. isMaxHeight = o.maxHeight && (o.maxHeight < newHeight),
  2636. isMinWidth = o.minWidth && (o.minWidth > newWidth),
  2637. isMinHeight = o.minHeight && (o.minHeight > newHeight);
  2638. o.grid = grid;
  2639. if (isMinWidth) {
  2640. newWidth = newWidth + gridX;
  2641. }
  2642. if (isMinHeight) {
  2643. newHeight = newHeight + gridY;
  2644. }
  2645. if (isMaxWidth) {
  2646. newWidth = newWidth - gridX;
  2647. }
  2648. if (isMaxHeight) {
  2649. newHeight = newHeight - gridY;
  2650. }
  2651. if (/^(se|s|e)$/.test(a)) {
  2652. that.size.width = newWidth;
  2653. that.size.height = newHeight;
  2654. } else if (/^(ne)$/.test(a)) {
  2655. that.size.width = newWidth;
  2656. that.size.height = newHeight;
  2657. that.position.top = op.top - oy;
  2658. } else if (/^(sw)$/.test(a)) {
  2659. that.size.width = newWidth;
  2660. that.size.height = newHeight;
  2661. that.position.left = op.left - ox;
  2662. } else {
  2663. that.size.width = newWidth;
  2664. that.size.height = newHeight;
  2665. that.position.top = op.top - oy;
  2666. that.position.left = op.left - ox;
  2667. }
  2668. }
  2669. });
  2670. })(jQuery);
  2671. (function( $, undefined ) {
  2672. $.widget("ui.selectable", $.ui.mouse, {
  2673. version: "1.10.1",
  2674. options: {
  2675. appendTo: "body",
  2676. autoRefresh: true,
  2677. distance: 0,
  2678. filter: "*",
  2679. tolerance: "touch",
  2680. // callbacks
  2681. selected: null,
  2682. selecting: null,
  2683. start: null,
  2684. stop: null,
  2685. unselected: null,
  2686. unselecting: null
  2687. },
  2688. _create: function() {
  2689. var selectees,
  2690. that = this;
  2691. this.element.addClass("ui-selectable");
  2692. this.dragged = false;
  2693. // cache selectee children based on filter
  2694. this.refresh = function() {
  2695. selectees = $(that.options.filter, that.element[0]);
  2696. selectees.addClass("ui-selectee");
  2697. selectees.each(function() {
  2698. var $this = $(this),
  2699. pos = $this.offset();
  2700. $.data(this, "selectable-item", {
  2701. element: this,
  2702. $element: $this,
  2703. left: pos.left,
  2704. top: pos.top,
  2705. right: pos.left + $this.outerWidth(),
  2706. bottom: pos.top + $this.outerHeight(),
  2707. startselected: false,
  2708. selected: $this.hasClass("ui-selected"),
  2709. selecting: $this.hasClass("ui-selecting"),
  2710. unselecting: $this.hasClass("ui-unselecting")
  2711. });
  2712. });
  2713. };
  2714. this.refresh();
  2715. this.selectees = selectees.addClass("ui-selectee");
  2716. this._mouseInit();
  2717. this.helper = $("<div class='ui-selectable-helper'></div>");
  2718. },
  2719. _destroy: function() {
  2720. this.selectees
  2721. .removeClass("ui-selectee")
  2722. .removeData("selectable-item");
  2723. this.element
  2724. .removeClass("ui-selectable ui-selectable-disabled");
  2725. this._mouseDestroy();
  2726. },
  2727. _mouseStart: function(event) {
  2728. var that = this,
  2729. options = this.options;
  2730. this.opos = [event.pageX, event.pageY];
  2731. if (this.options.disabled) {
  2732. return;
  2733. }
  2734. this.selectees = $(options.filter, this.element[0]);
  2735. this._trigger("start", event);
  2736. $(options.appendTo).append(this.helper);
  2737. // position helper (lasso)
  2738. this.helper.css({
  2739. "left": event.pageX,
  2740. "top": event.pageY,
  2741. "width": 0,
  2742. "height": 0
  2743. });
  2744. if (options.autoRefresh) {
  2745. this.refresh();
  2746. }
  2747. this.selectees.filter(".ui-selected").each(function() {
  2748. var selectee = $.data(this, "selectable-item");
  2749. selectee.startselected = true;
  2750. if (!event.metaKey && !event.ctrlKey) {
  2751. selectee.$element.removeClass("ui-selected");
  2752. selectee.selected = false;
  2753. selectee.$element.addClass("ui-unselecting");
  2754. selectee.unselecting = true;
  2755. // selectable UNSELECTING callback
  2756. that._trigger("unselecting", event, {
  2757. unselecting: selectee.element
  2758. });
  2759. }
  2760. });
  2761. $(event.target).parents().addBack().each(function() {
  2762. var doSelect,
  2763. selectee = $.data(this, "selectable-item");
  2764. if (selectee) {
  2765. doSelect = (!event.metaKey && !event.ctrlKey) || !selectee.$element.hasClass("ui-selected");
  2766. selectee.$element
  2767. .removeClass(doSelect ? "ui-unselecting" : "ui-selected")
  2768. .addClass(doSelect ? "ui-selecting" : "ui-unselecting");
  2769. selectee.unselecting = !doSelect;
  2770. selectee.selecting = doSelect;
  2771. selectee.selected = doSelect;
  2772. // selectable (UN)SELECTING callback
  2773. if (doSelect) {
  2774. that._trigger("selecting", event, {
  2775. selecting: selectee.element
  2776. });
  2777. } else {
  2778. that._trigger("unselecting", event, {
  2779. unselecting: selectee.element
  2780. });
  2781. }
  2782. return false;
  2783. }
  2784. });
  2785. },
  2786. _mouseDrag: function(event) {
  2787. this.dragged = true;
  2788. if (this.options.disabled) {
  2789. return;
  2790. }
  2791. var tmp,
  2792. that = this,
  2793. options = this.options,
  2794. x1 = this.opos[0],
  2795. y1 = this.opos[1],
  2796. x2 = event.pageX,
  2797. y2 = event.pageY;
  2798. if (x1 > x2) { tmp = x2; x2 = x1; x1 = tmp; }
  2799. if (y1 > y2) { tmp = y2; y2 = y1; y1 = tmp; }
  2800. this.helper.css({left: x1, top: y1, width: x2-x1, height: y2-y1});
  2801. this.selectees.each(function() {
  2802. var selectee = $.data(this, "selectable-item"),
  2803. hit = false;
  2804. //prevent helper from being selected if appendTo: selectable
  2805. if (!selectee || selectee.element === that.element[0]) {
  2806. return;
  2807. }
  2808. if (options.tolerance === "touch") {
  2809. hit = ( !(selectee.left > x2 || selectee.right < x1 || selectee.top > y2 || selectee.bottom < y1) );
  2810. } else if (options.tolerance === "fit") {
  2811. hit = (selectee.left > x1 && selectee.right < x2 && selectee.top > y1 && selectee.bottom < y2);
  2812. }
  2813. if (hit) {
  2814. // SELECT
  2815. if (selectee.selected) {
  2816. selectee.$element.removeClass("ui-selected");
  2817. selectee.selected = false;
  2818. }
  2819. if (selectee.unselecting) {
  2820. selectee.$element.removeClass("ui-unselecting");
  2821. selectee.unselecting = false;
  2822. }
  2823. if (!selectee.selecting) {
  2824. selectee.$element.addClass("ui-selecting");
  2825. selectee.selecting = true;
  2826. // selectable SELECTING callback
  2827. that._trigger("selecting", event, {
  2828. selecting: selectee.element
  2829. });
  2830. }
  2831. } else {
  2832. // UNSELECT
  2833. if (selectee.selecting) {
  2834. if ((event.metaKey || event.ctrlKey) && selectee.startselected) {
  2835. selectee.$element.removeClass("ui-selecting");
  2836. selectee.selecting = false;
  2837. selectee.$element.addClass("ui-selected");
  2838. selectee.selected = true;
  2839. } else {
  2840. selectee.$element.removeClass("ui-selecting");
  2841. selectee.selecting = false;
  2842. if (selectee.startselected) {
  2843. selectee.$element.addClass("ui-unselecting");
  2844. selectee.unselecting = true;
  2845. }
  2846. // selectable UNSELECTING callback
  2847. that._trigger("unselecting", event, {
  2848. unselecting: selectee.element
  2849. });
  2850. }
  2851. }
  2852. if (selectee.selected) {
  2853. if (!event.metaKey && !event.ctrlKey && !selectee.startselected) {
  2854. selectee.$element.removeClass("ui-selected");
  2855. selectee.selected = false;
  2856. selectee.$element.addClass("ui-unselecting");
  2857. selectee.unselecting = true;
  2858. // selectable UNSELECTING callback
  2859. that._trigger("unselecting", event, {
  2860. unselecting: selectee.element
  2861. });
  2862. }
  2863. }
  2864. }
  2865. });
  2866. return false;
  2867. },
  2868. _mouseStop: function(event) {
  2869. var that = this;
  2870. this.dragged = false;
  2871. $(".ui-unselecting", this.element[0]).each(function() {
  2872. var selectee = $.data(this, "selectable-item");
  2873. selectee.$element.removeClass("ui-unselecting");
  2874. selectee.unselecting = false;
  2875. selectee.startselected = false;
  2876. that._trigger("unselected", event, {
  2877. unselected: selectee.element
  2878. });
  2879. });
  2880. $(".ui-selecting", this.element[0]).each(function() {
  2881. var selectee = $.data(this, "selectable-item");
  2882. selectee.$element.removeClass("ui-selecting").addClass("ui-selected");
  2883. selectee.selecting = false;
  2884. selectee.selected = true;
  2885. selectee.startselected = true;
  2886. that._trigger("selected", event, {
  2887. selected: selectee.element
  2888. });
  2889. });
  2890. this._trigger("stop", event);
  2891. this.helper.remove();
  2892. return false;
  2893. }
  2894. });
  2895. })(jQuery);
  2896. (function( $, undefined ) {
  2897. /*jshint loopfunc: true */
  2898. function isOverAxis( x, reference, size ) {
  2899. return ( x > reference ) && ( x < ( reference + size ) );
  2900. }
  2901. $.widget("ui.sortable", $.ui.mouse, {
  2902. version: "1.10.1",
  2903. widgetEventPrefix: "sort",
  2904. ready: false,
  2905. options: {
  2906. appendTo: "parent",
  2907. axis: false,
  2908. connectWith: false,
  2909. containment: false,
  2910. cursor: "auto",
  2911. cursorAt: false,
  2912. dropOnEmpty: true,
  2913. forcePlaceholderSize: false,
  2914. forceHelperSize: false,
  2915. grid: false,
  2916. handle: false,
  2917. helper: "original",
  2918. items: "> *",
  2919. opacity: false,
  2920. placeholder: false,
  2921. revert: false,
  2922. scroll: true,
  2923. scrollSensitivity: 20,
  2924. scrollSpeed: 20,
  2925. scope: "default",
  2926. tolerance: "intersect",
  2927. zIndex: 1000,
  2928. // callbacks
  2929. activate: null,
  2930. beforeStop: null,
  2931. change: null,
  2932. deactivate: null,
  2933. out: null,
  2934. over: null,
  2935. receive: null,
  2936. remove: null,
  2937. sort: null,
  2938. start: null,
  2939. stop: null,
  2940. update: null
  2941. },
  2942. _create: function() {
  2943. var o = this.options;
  2944. this.containerCache = {};
  2945. this.element.addClass("ui-sortable");
  2946. //Get the items
  2947. this.refresh();
  2948. //Let's determine if the items are being displayed horizontally
  2949. this.floating = this.items.length ? o.axis === "x" || (/left|right/).test(this.items[0].item.css("float")) || (/inline|table-cell/).test(this.items[0].item.css("display")) : false;
  2950. //Let's determine the parent's offset
  2951. this.offset = this.element.offset();
  2952. //Initialize mouse events for interaction
  2953. this._mouseInit();
  2954. //We're ready to go
  2955. this.ready = true;
  2956. },
  2957. _destroy: function() {
  2958. this.element
  2959. .removeClass("ui-sortable ui-sortable-disabled");
  2960. this._mouseDestroy();
  2961. for ( var i = this.items.length - 1; i >= 0; i-- ) {
  2962. this.items[i].item.removeData(this.widgetName + "-item");
  2963. }
  2964. return this;
  2965. },
  2966. _setOption: function(key, value){
  2967. if ( key === "disabled" ) {
  2968. this.options[ key ] = value;
  2969. this.widget().toggleClass( "ui-sortable-disabled", !!value );
  2970. } else {
  2971. // Don't call widget base _setOption for disable as it adds ui-state-disabled class
  2972. $.Widget.prototype._setOption.apply(this, arguments);
  2973. }
  2974. },
  2975. _mouseCapture: function(event, overrideHandle) {
  2976. var currentItem = null,
  2977. validHandle = false,
  2978. that = this;
  2979. if (this.reverting) {
  2980. return false;
  2981. }
  2982. if(this.options.disabled || this.options.type === "static") {
  2983. return false;
  2984. }
  2985. //We have to refresh the items data once first
  2986. this._refreshItems(event);
  2987. //Find out if the clicked node (or one of its parents) is a actual item in this.items
  2988. $(event.target).parents().each(function() {
  2989. if($.data(this, that.widgetName + "-item") === that) {
  2990. currentItem = $(this);
  2991. return false;
  2992. }
  2993. });
  2994. if($.data(event.target, that.widgetName + "-item") === that) {
  2995. currentItem = $(event.target);
  2996. }
  2997. if(!currentItem) {
  2998. return false;
  2999. }
  3000. if(this.options.handle && !overrideHandle) {
  3001. $(this.options.handle, currentItem).find("*").addBack().each(function() {
  3002. if(this === event.target) {
  3003. validHandle = true;
  3004. }
  3005. });
  3006. if(!validHandle) {
  3007. return false;
  3008. }
  3009. }
  3010. this.currentItem = currentItem;
  3011. this._removeCurrentsFromItems();
  3012. return true;
  3013. },
  3014. _mouseStart: function(event, overrideHandle, noActivation) {
  3015. var i,
  3016. o = this.options;
  3017. this.currentContainer = this;
  3018. //We only need to call refreshPositions, because the refreshItems call has been moved to mouseCapture
  3019. this.refreshPositions();
  3020. //Create and append the visible helper
  3021. this.helper = this._createHelper(event);
  3022. //Cache the helper size
  3023. this._cacheHelperProportions();
  3024. /*
  3025. * - Position generation -
  3026. * This block generates everything position related - it's the core of draggables.
  3027. */
  3028. //Cache the margins of the original element
  3029. this._cacheMargins();
  3030. //Get the next scrolling parent
  3031. this.scrollParent = this.helper.scrollParent();
  3032. //The element's absolute position on the page minus margins
  3033. this.offset = this.currentItem.offset();
  3034. this.offset = {
  3035. top: this.offset.top - this.margins.top,
  3036. left: this.offset.left - this.margins.left
  3037. };
  3038. $.extend(this.offset, {
  3039. click: { //Where the click happened, relative to the element
  3040. left: event.pageX - this.offset.left,
  3041. top: event.pageY - this.offset.top
  3042. },
  3043. parent: this._getParentOffset(),
  3044. relative: this._getRelativeOffset() //This is a relative to absolute position minus the actual position calculation - only used for relative positioned helper
  3045. });
  3046. // Only after we got the offset, we can change the helper's position to absolute
  3047. // TODO: Still need to figure out a way to make relative sorting possible
  3048. this.helper.css("position", "absolute");
  3049. this.cssPosition = this.helper.css("position");
  3050. //Generate the original position
  3051. this.originalPosition = this._generatePosition(event);
  3052. this.originalPageX = event.pageX;
  3053. this.originalPageY = event.pageY;
  3054. //Adjust the mouse offset relative to the helper if "cursorAt" is supplied
  3055. (o.cursorAt && this._adjustOffsetFromHelper(o.cursorAt));
  3056. //Cache the former DOM position
  3057. this.domPosition = { prev: this.currentItem.prev()[0], parent: this.currentItem.parent()[0] };
  3058. //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
  3059. if(this.helper[0] !== this.currentItem[0]) {
  3060. this.currentItem.hide();
  3061. }
  3062. //Create the placeholder
  3063. this._createPlaceholder();
  3064. //Set a containment if given in the options
  3065. if(o.containment) {
  3066. this._setContainment();
  3067. }
  3068. if(o.cursor) { // cursor option
  3069. if ($("body").css("cursor")) {
  3070. this._storedCursor = $("body").css("cursor");
  3071. }
  3072. $("body").css("cursor", o.cursor);
  3073. }
  3074. if(o.opacity) { // opacity option
  3075. if (this.helper.css("opacity")) {
  3076. this._storedOpacity = this.helper.css("opacity");
  3077. }
  3078. this.helper.css("opacity", o.opacity);
  3079. }
  3080. if(o.zIndex) { // zIndex option
  3081. if (this.helper.css("zIndex")) {
  3082. this._storedZIndex = this.helper.css("zIndex");
  3083. }
  3084. this.helper.css("zIndex", o.zIndex);
  3085. }
  3086. //Prepare scrolling
  3087. if(this.scrollParent[0] !== document && this.scrollParent[0].tagName !== "HTML") {
  3088. this.overflowOffset = this.scrollParent.offset();
  3089. }
  3090. //Call callbacks
  3091. this._trigger("start", event, this._uiHash());
  3092. //Recache the helper size
  3093. if(!this._preserveHelperProportions) {
  3094. this._cacheHelperProportions();
  3095. }
  3096. //Post "activate" events to possible containers
  3097. if( !noActivation ) {
  3098. for ( i = this.containers.length - 1; i >= 0; i-- ) {
  3099. this.containers[ i ]._trigger( "activate", event, this._uiHash( this ) );
  3100. }
  3101. }
  3102. //Prepare possible droppables
  3103. if($.ui.ddmanager) {
  3104. $.ui.ddmanager.current = this;
  3105. }
  3106. if ($.ui.ddmanager && !o.dropBehaviour) {
  3107. $.ui.ddmanager.prepareOffsets(this, event);
  3108. }
  3109. this.dragging = true;
  3110. this.helper.addClass("ui-sortable-helper");
  3111. this._mouseDrag(event); //Execute the drag once - this causes the helper not to be visible before getting its correct position
  3112. return true;
  3113. },
  3114. _mouseDrag: function(event) {
  3115. var i, item, itemElement, intersection,
  3116. o = this.options,
  3117. scrolled = false;
  3118. //Compute the helpers position
  3119. this.position = this._generatePosition(event);
  3120. this.positionAbs = this._convertPositionTo("absolute");
  3121. if (!this.lastPositionAbs) {
  3122. this.lastPositionAbs = this.positionAbs;
  3123. }
  3124. //Do scrolling
  3125. if(this.options.scroll) {
  3126. if(this.scrollParent[0] !== document && this.scrollParent[0].tagName !== "HTML") {
  3127. if((this.overflowOffset.top + this.scrollParent[0].offsetHeight) - event.pageY < o.scrollSensitivity) {
  3128. this.scrollParent[0].scrollTop = scrolled = this.scrollParent[0].scrollTop + o.scrollSpeed;
  3129. } else if(event.pageY - this.overflowOffset.top < o.scrollSensitivity) {
  3130. this.scrollParent[0].scrollTop = scrolled = this.scrollParent[0].scrollTop - o.scrollSpeed;
  3131. }
  3132. if((this.overflowOffset.left + this.scrollParent[0].offsetWidth) - event.pageX < o.scrollSensitivity) {
  3133. this.scrollParent[0].scrollLeft = scrolled = this.scrollParent[0].scrollLeft + o.scrollSpeed;
  3134. } else if(event.pageX - this.overflowOffset.left < o.scrollSensitivity) {
  3135. this.scrollParent[0].scrollLeft = scrolled = this.scrollParent[0].scrollLeft - o.scrollSpeed;
  3136. }
  3137. } else {
  3138. if(event.pageY - $(document).scrollTop() < o.scrollSensitivity) {
  3139. scrolled = $(document).scrollTop($(document).scrollTop() - o.scrollSpeed);
  3140. } else if($(window).height() - (event.pageY - $(document).scrollTop()) < o.scrollSensitivity) {
  3141. scrolled = $(document).scrollTop($(document).scrollTop() + o.scrollSpeed);
  3142. }
  3143. if(event.pageX - $(document).scrollLeft() < o.scrollSensitivity) {
  3144. scrolled = $(document).scrollLeft($(document).scrollLeft() - o.scrollSpeed);
  3145. } else if($(window).width() - (event.pageX - $(document).scrollLeft()) < o.scrollSensitivity) {
  3146. scrolled = $(document).scrollLeft($(document).scrollLeft() + o.scrollSpeed);
  3147. }
  3148. }
  3149. if(scrolled !== false && $.ui.ddmanager && !o.dropBehaviour) {
  3150. $.ui.ddmanager.prepareOffsets(this, event);
  3151. }
  3152. }
  3153. //Regenerate the absolute position used for position checks
  3154. this.positionAbs = this._convertPositionTo("absolute");
  3155. //Set the helper position
  3156. if(!this.options.axis || this.options.axis !== "y") {
  3157. this.helper[0].style.left = this.position.left+"px";
  3158. }
  3159. if(!this.options.axis || this.options.axis !== "x") {
  3160. this.helper[0].style.top = this.position.top+"px";
  3161. }
  3162. //Rearrange
  3163. for (i = this.items.length - 1; i >= 0; i--) {
  3164. //Cache variables and intersection, continue if no intersection
  3165. item = this.items[i];
  3166. itemElement = item.item[0];
  3167. intersection = this._intersectsWithPointer(item);
  3168. if (!intersection) {
  3169. continue;
  3170. }
  3171. // Only put the placeholder inside the current Container, skip all
  3172. // items form other containers. This works because when moving
  3173. // an item from one container to another the
  3174. // currentContainer is switched before the placeholder is moved.
  3175. //
  3176. // Without this moving items in "sub-sortables" can cause the placeholder to jitter
  3177. // beetween the outer and inner container.
  3178. if (item.instance !== this.currentContainer) {
  3179. continue;
  3180. }
  3181. // cannot intersect with itself
  3182. // no useless actions that have been done before
  3183. // no action if the item moved is the parent of the item checked
  3184. if (itemElement !== this.currentItem[0] &&
  3185. this.placeholder[intersection === 1 ? "next" : "prev"]()[0] !== itemElement &&
  3186. !$.contains(this.placeholder[0], itemElement) &&
  3187. (this.options.type === "semi-dynamic" ? !$.contains(this.element[0], itemElement) : true)
  3188. ) {
  3189. this.direction = intersection === 1 ? "down" : "up";
  3190. if (this.options.tolerance === "pointer" || this._intersectsWithSides(item)) {
  3191. this._rearrange(event, item);
  3192. } else {
  3193. break;
  3194. }
  3195. this._trigger("change", event, this._uiHash());
  3196. break;
  3197. }
  3198. }
  3199. //Post events to containers
  3200. this._contactContainers(event);
  3201. //Interconnect with droppables
  3202. if($.ui.ddmanager) {
  3203. $.ui.ddmanager.drag(this, event);
  3204. }
  3205. //Call callbacks
  3206. this._trigger("sort", event, this._uiHash());
  3207. this.lastPositionAbs = this.positionAbs;
  3208. return false;
  3209. },
  3210. _mouseStop: function(event, noPropagation) {
  3211. if(!event) {
  3212. return;
  3213. }
  3214. //If we are using droppables, inform the manager about the drop
  3215. if ($.ui.ddmanager && !this.options.dropBehaviour) {
  3216. $.ui.ddmanager.drop(this, event);
  3217. }
  3218. if(this.options.revert) {
  3219. var that = this,
  3220. cur = this.placeholder.offset();
  3221. this.reverting = true;
  3222. $(this.helper).animate({
  3223. left: cur.left - this.offset.parent.left - this.margins.left + (this.offsetParent[0] === document.body ? 0 : this.offsetParent[0].scrollLeft),
  3224. top: cur.top - this.offset.parent.top - this.margins.top + (this.offsetParent[0] === document.body ? 0 : this.offsetParent[0].scrollTop)
  3225. }, parseInt(this.options.revert, 10) || 500, function() {
  3226. that._clear(event);
  3227. });
  3228. } else {
  3229. this._clear(event, noPropagation);
  3230. }
  3231. return false;
  3232. },
  3233. cancel: function() {
  3234. if(this.dragging) {
  3235. this._mouseUp({ target: null });
  3236. if(this.options.helper === "original") {
  3237. this.currentItem.css(this._storedCSS).removeClass("ui-sortable-helper");
  3238. } else {
  3239. this.currentItem.show();
  3240. }
  3241. //Post deactivating events to containers
  3242. for (var i = this.containers.length - 1; i >= 0; i--){
  3243. this.containers[i]._trigger("deactivate", null, this._uiHash(this));
  3244. if(this.containers[i].containerCache.over) {
  3245. this.containers[i]._trigger("out", null, this._uiHash(this));
  3246. this.containers[i].containerCache.over = 0;
  3247. }
  3248. }
  3249. }
  3250. if (this.placeholder) {
  3251. //$(this.placeholder[0]).remove(); would have been the jQuery way - unfortunately, it unbinds ALL events from the original node!
  3252. if(this.placeholder[0].parentNode) {
  3253. this.placeholder[0].parentNode.removeChild(this.placeholder[0]);
  3254. }
  3255. if(this.options.helper !== "original" && this.helper && this.helper[0].parentNode) {
  3256. this.helper.remove();
  3257. }
  3258. $.extend(this, {
  3259. helper: null,
  3260. dragging: false,
  3261. reverting: false,
  3262. _noFinalSort: null
  3263. });
  3264. if(this.domPosition.prev) {
  3265. $(this.domPosition.prev).after(this.currentItem);
  3266. } else {
  3267. $(this.domPosition.parent).prepend(this.currentItem);
  3268. }
  3269. }
  3270. return this;
  3271. },
  3272. serialize: function(o) {
  3273. var items = this._getItemsAsjQuery(o && o.connected),
  3274. str = [];
  3275. o = o || {};
  3276. $(items).each(function() {
  3277. var res = ($(o.item || this).attr(o.attribute || "id") || "").match(o.expression || (/(.+)[\-=_](.+)/));
  3278. if (res) {
  3279. str.push((o.key || res[1]+"[]")+"="+(o.key && o.expression ? res[1] : res[2]));
  3280. }
  3281. });
  3282. if(!str.length && o.key) {
  3283. str.push(o.key + "=");
  3284. }
  3285. return str.join("&");
  3286. },
  3287. toArray: function(o) {
  3288. var items = this._getItemsAsjQuery(o && o.connected),
  3289. ret = [];
  3290. o = o || {};
  3291. items.each(function() { ret.push($(o.item || this).attr(o.attribute || "id") || ""); });
  3292. return ret;
  3293. },
  3294. /* Be careful with the following core functions */
  3295. _intersectsWith: function(item) {
  3296. var x1 = this.positionAbs.left,
  3297. x2 = x1 + this.helperProportions.width,
  3298. y1 = this.positionAbs.top,
  3299. y2 = y1 + this.helperProportions.height,
  3300. l = item.left,
  3301. r = l + item.width,
  3302. t = item.top,
  3303. b = t + item.height,
  3304. dyClick = this.offset.click.top,
  3305. dxClick = this.offset.click.left,
  3306. isOverElement = (y1 + dyClick) > t && (y1 + dyClick) < b && (x1 + dxClick) > l && (x1 + dxClick) < r;
  3307. if ( this.options.tolerance === "pointer" ||
  3308. this.options.forcePointerForContainers ||
  3309. (this.options.tolerance !== "pointer" && this.helperProportions[this.floating ? "width" : "height"] > item[this.floating ? "width" : "height"])
  3310. ) {
  3311. return isOverElement;
  3312. } else {
  3313. return (l < x1 + (this.helperProportions.width / 2) && // Right Half
  3314. x2 - (this.helperProportions.width / 2) < r && // Left Half
  3315. t < y1 + (this.helperProportions.height / 2) && // Bottom Half
  3316. y2 - (this.helperProportions.height / 2) < b ); // Top Half
  3317. }
  3318. },
  3319. _intersectsWithPointer: function(item) {
  3320. var isOverElementHeight = (this.options.axis === "x") || isOverAxis(this.positionAbs.top + this.offset.click.top, item.top, item.height),
  3321. isOverElementWidth = (this.options.axis === "y") || isOverAxis(this.positionAbs.left + this.offset.click.left, item.left, item.width),
  3322. isOverElement = isOverElementHeight && isOverElementWidth,
  3323. verticalDirection = this._getDragVerticalDirection(),
  3324. horizontalDirection = this._getDragHorizontalDirection();
  3325. if (!isOverElement) {
  3326. return false;
  3327. }
  3328. return this.floating ?
  3329. ( ((horizontalDirection && horizontalDirection === "right") || verticalDirection === "down") ? 2 : 1 )
  3330. : ( verticalDirection && (verticalDirection === "down" ? 2 : 1) );
  3331. },
  3332. _intersectsWithSides: function(item) {
  3333. var isOverBottomHalf = isOverAxis(this.positionAbs.top + this.offset.click.top, item.top + (item.height/2), item.height),
  3334. isOverRightHalf = isOverAxis(this.positionAbs.left + this.offset.click.left, item.left + (item.width/2), item.width),
  3335. verticalDirection = this._getDragVerticalDirection(),
  3336. horizontalDirection = this._getDragHorizontalDirection();
  3337. if (this.floating && horizontalDirection) {
  3338. return ((horizontalDirection === "right" && isOverRightHalf) || (horizontalDirection === "left" && !isOverRightHalf));
  3339. } else {
  3340. return verticalDirection && ((verticalDirection === "down" && isOverBottomHalf) || (verticalDirection === "up" && !isOverBottomHalf));
  3341. }
  3342. },
  3343. _getDragVerticalDirection: function() {
  3344. var delta = this.positionAbs.top - this.lastPositionAbs.top;
  3345. return delta !== 0 && (delta > 0 ? "down" : "up");
  3346. },
  3347. _getDragHorizontalDirection: function() {
  3348. var delta = this.positionAbs.left - this.lastPositionAbs.left;
  3349. return delta !== 0 && (delta > 0 ? "right" : "left");
  3350. },
  3351. refresh: function(event) {
  3352. this._refreshItems(event);
  3353. this.refreshPositions();
  3354. return this;
  3355. },
  3356. _connectWith: function() {
  3357. var options = this.options;
  3358. return options.connectWith.constructor === String ? [options.connectWith] : options.connectWith;
  3359. },
  3360. _getItemsAsjQuery: function(connected) {
  3361. var i, j, cur, inst,
  3362. items = [],
  3363. queries = [],
  3364. connectWith = this._connectWith();
  3365. if(connectWith && connected) {
  3366. for (i = connectWith.length - 1; i >= 0; i--){
  3367. cur = $(connectWith[i]);
  3368. for ( j = cur.length - 1; j >= 0; j--){
  3369. inst = $.data(cur[j], this.widgetFullName);
  3370. if(inst && inst !== this && !inst.options.disabled) {
  3371. 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]);
  3372. }
  3373. }
  3374. }
  3375. }
  3376. 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]);
  3377. for (i = queries.length - 1; i >= 0; i--){
  3378. queries[i][0].each(function() {
  3379. items.push(this);
  3380. });
  3381. }
  3382. return $(items);
  3383. },
  3384. _removeCurrentsFromItems: function() {
  3385. var list = this.currentItem.find(":data(" + this.widgetName + "-item)");
  3386. this.items = $.grep(this.items, function (item) {
  3387. for (var j=0; j < list.length; j++) {
  3388. if(list[j] === item.item[0]) {
  3389. return false;
  3390. }
  3391. }
  3392. return true;
  3393. });
  3394. },
  3395. _refreshItems: function(event) {
  3396. this.items = [];
  3397. this.containers = [this];
  3398. var i, j, cur, inst, targetData, _queries, item, queriesLength,
  3399. items = this.items,
  3400. queries = [[$.isFunction(this.options.items) ? this.options.items.call(this.element[0], event, { item: this.currentItem }) : $(this.options.items, this.element), this]],
  3401. connectWith = this._connectWith();
  3402. if(connectWith && this.ready) { //Shouldn't be run the first time through due to massive slow-down
  3403. for (i = connectWith.length - 1; i >= 0; i--){
  3404. cur = $(connectWith[i]);
  3405. for (j = cur.length - 1; j >= 0; j--){
  3406. inst = $.data(cur[j], this.widgetFullName);
  3407. if(inst && inst !== this && !inst.options.disabled) {
  3408. queries.push([$.isFunction(inst.options.items) ? inst.options.items.call(inst.element[0], event, { item: this.currentItem }) : $(inst.options.items, inst.element), inst]);
  3409. this.containers.push(inst);
  3410. }
  3411. }
  3412. }
  3413. }
  3414. for (i = queries.length - 1; i >= 0; i--) {
  3415. targetData = queries[i][1];
  3416. _queries = queries[i][0];
  3417. for (j=0, queriesLength = _queries.length; j < queriesLength; j++) {
  3418. item = $(_queries[j]);
  3419. item.data(this.widgetName + "-item", targetData); // Data for target checking (mouse manager)
  3420. items.push({
  3421. item: item,
  3422. instance: targetData,
  3423. width: 0, height: 0,
  3424. left: 0, top: 0
  3425. });
  3426. }
  3427. }
  3428. },
  3429. refreshPositions: function(fast) {
  3430. //This has to be redone because due to the item being moved out/into the offsetParent, the offsetParent's position will change
  3431. if(this.offsetParent && this.helper) {
  3432. this.offset.parent = this._getParentOffset();
  3433. }
  3434. var i, item, t, p;
  3435. for (i = this.items.length - 1; i >= 0; i--){
  3436. item = this.items[i];
  3437. //We ignore calculating positions of all connected containers when we're not over them
  3438. if(item.instance !== this.currentContainer && this.currentContainer && item.item[0] !== this.currentItem[0]) {
  3439. continue;
  3440. }
  3441. t = this.options.toleranceElement ? $(this.options.toleranceElement, item.item) : item.item;
  3442. if (!fast) {
  3443. item.width = t.outerWidth();
  3444. item.height = t.outerHeight();
  3445. }
  3446. p = t.offset();
  3447. item.left = p.left;
  3448. item.top = p.top;
  3449. }
  3450. if(this.options.custom && this.options.custom.refreshContainers) {
  3451. this.options.custom.refreshContainers.call(this);
  3452. } else {
  3453. for (i = this.containers.length - 1; i >= 0; i--){
  3454. p = this.containers[i].element.offset();
  3455. this.containers[i].containerCache.left = p.left;
  3456. this.containers[i].containerCache.top = p.top;
  3457. this.containers[i].containerCache.width = this.containers[i].element.outerWidth();
  3458. this.containers[i].containerCache.height = this.containers[i].element.outerHeight();
  3459. }
  3460. }
  3461. return this;
  3462. },
  3463. _createPlaceholder: function(that) {
  3464. that = that || this;
  3465. var className,
  3466. o = that.options;
  3467. if(!o.placeholder || o.placeholder.constructor === String) {
  3468. className = o.placeholder;
  3469. o.placeholder = {
  3470. element: function() {
  3471. var el = $(document.createElement(that.currentItem[0].nodeName))
  3472. .addClass(className || that.currentItem[0].className+" ui-sortable-placeholder")
  3473. .removeClass("ui-sortable-helper")[0];
  3474. if(!className) {
  3475. el.style.visibility = "hidden";
  3476. }
  3477. return el;
  3478. },
  3479. update: function(container, p) {
  3480. // 1. If a className is set as 'placeholder option, we don't force sizes - the class is responsible for that
  3481. // 2. The option 'forcePlaceholderSize can be enabled to force it even if a class name is specified
  3482. if(className && !o.forcePlaceholderSize) {
  3483. return;
  3484. }
  3485. //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
  3486. if(!p.height()) { p.height(that.currentItem.innerHeight() - parseInt(that.currentItem.css("paddingTop")||0, 10) - parseInt(that.currentItem.css("paddingBottom")||0, 10)); }
  3487. if(!p.width()) { p.width(that.currentItem.innerWidth() - parseInt(that.currentItem.css("paddingLeft")||0, 10) - parseInt(that.currentItem.css("paddingRight")||0, 10)); }
  3488. }
  3489. };
  3490. }
  3491. //Create the placeholder
  3492. that.placeholder = $(o.placeholder.element.call(that.element, that.currentItem));
  3493. //Append it after the actual current item
  3494. that.currentItem.after(that.placeholder);
  3495. //Update the size of the placeholder (TODO: Logic to fuzzy, see line 316/317)
  3496. o.placeholder.update(that, that.placeholder);
  3497. },
  3498. _contactContainers: function(event) {
  3499. var i, j, dist, itemWithLeastDistance, posProperty, sizeProperty, base, cur, nearBottom,
  3500. innermostContainer = null,
  3501. innermostIndex = null;
  3502. // get innermost container that intersects with item
  3503. for (i = this.containers.length - 1; i >= 0; i--) {
  3504. // never consider a container that's located within the item itself
  3505. if($.contains(this.currentItem[0], this.containers[i].element[0])) {
  3506. continue;
  3507. }
  3508. if(this._intersectsWith(this.containers[i].containerCache)) {
  3509. // if we've already found a container and it's more "inner" than this, then continue
  3510. if(innermostContainer && $.contains(this.containers[i].element[0], innermostContainer.element[0])) {
  3511. continue;
  3512. }
  3513. innermostContainer = this.containers[i];
  3514. innermostIndex = i;
  3515. } else {
  3516. // container doesn't intersect. trigger "out" event if necessary
  3517. if(this.containers[i].containerCache.over) {
  3518. this.containers[i]._trigger("out", event, this._uiHash(this));
  3519. this.containers[i].containerCache.over = 0;
  3520. }
  3521. }
  3522. }
  3523. // if no intersecting containers found, return
  3524. if(!innermostContainer) {
  3525. return;
  3526. }
  3527. // move the item into the container if it's not there already
  3528. if(this.containers.length === 1) {
  3529. this.containers[innermostIndex]._trigger("over", event, this._uiHash(this));
  3530. this.containers[innermostIndex].containerCache.over = 1;
  3531. } else {
  3532. //When entering a new container, we will find the item with the least distance and append our item near it
  3533. dist = 10000;
  3534. itemWithLeastDistance = null;
  3535. posProperty = this.containers[innermostIndex].floating ? "left" : "top";
  3536. sizeProperty = this.containers[innermostIndex].floating ? "width" : "height";
  3537. base = this.positionAbs[posProperty] + this.offset.click[posProperty];
  3538. for (j = this.items.length - 1; j >= 0; j--) {
  3539. if(!$.contains(this.containers[innermostIndex].element[0], this.items[j].item[0])) {
  3540. continue;
  3541. }
  3542. if(this.items[j].item[0] === this.currentItem[0]) {
  3543. continue;
  3544. }
  3545. cur = this.items[j].item.offset()[posProperty];
  3546. nearBottom = false;
  3547. if(Math.abs(cur - base) > Math.abs(cur + this.items[j][sizeProperty] - base)){
  3548. nearBottom = true;
  3549. cur += this.items[j][sizeProperty];
  3550. }
  3551. if(Math.abs(cur - base) < dist) {
  3552. dist = Math.abs(cur - base); itemWithLeastDistance = this.items[j];
  3553. this.direction = nearBottom ? "up": "down";
  3554. }
  3555. }
  3556. //Check if dropOnEmpty is enabled
  3557. if(!itemWithLeastDistance && !this.options.dropOnEmpty) {
  3558. return;
  3559. }
  3560. this.currentContainer = this.containers[innermostIndex];
  3561. itemWithLeastDistance ? this._rearrange(event, itemWithLeastDistance, null, true) : this._rearrange(event, null, this.containers[innermostIndex].element, true);
  3562. this._trigger("change", event, this._uiHash());
  3563. this.containers[innermostIndex]._trigger("change", event, this._uiHash(this));
  3564. //Update the placeholder
  3565. this.options.placeholder.update(this.currentContainer, this.placeholder);
  3566. this.containers[innermostIndex]._trigger("over", event, this._uiHash(this));
  3567. this.containers[innermostIndex].containerCache.over = 1;
  3568. }
  3569. },
  3570. _createHelper: function(event) {
  3571. var o = this.options,
  3572. helper = $.isFunction(o.helper) ? $(o.helper.apply(this.element[0], [event, this.currentItem])) : (o.helper === "clone" ? this.currentItem.clone() : this.currentItem);
  3573. //Add the helper to the DOM if that didn't happen already
  3574. if(!helper.parents("body").length) {
  3575. $(o.appendTo !== "parent" ? o.appendTo : this.currentItem[0].parentNode)[0].appendChild(helper[0]);
  3576. }
  3577. if(helper[0] === this.currentItem[0]) {
  3578. 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") };
  3579. }
  3580. if(!helper[0].style.width || o.forceHelperSize) {
  3581. helper.width(this.currentItem.width());
  3582. }
  3583. if(!helper[0].style.height || o.forceHelperSize) {
  3584. helper.height(this.currentItem.height());
  3585. }
  3586. return helper;
  3587. },
  3588. _adjustOffsetFromHelper: function(obj) {
  3589. if (typeof obj === "string") {
  3590. obj = obj.split(" ");
  3591. }
  3592. if ($.isArray(obj)) {
  3593. obj = {left: +obj[0], top: +obj[1] || 0};
  3594. }
  3595. if ("left" in obj) {
  3596. this.offset.click.left = obj.left + this.margins.left;
  3597. }
  3598. if ("right" in obj) {
  3599. this.offset.click.left = this.helperProportions.width - obj.right + this.margins.left;
  3600. }
  3601. if ("top" in obj) {
  3602. this.offset.click.top = obj.top + this.margins.top;
  3603. }
  3604. if ("bottom" in obj) {
  3605. this.offset.click.top = this.helperProportions.height - obj.bottom + this.margins.top;
  3606. }
  3607. },
  3608. _getParentOffset: function() {
  3609. //Get the offsetParent and cache its position
  3610. this.offsetParent = this.helper.offsetParent();
  3611. var po = this.offsetParent.offset();
  3612. // This is a special case where we need to modify a offset calculated on start, since the following happened:
  3613. // 1. The position of the helper is absolute, so it's position is calculated based on the next positioned parent
  3614. // 2. The actual offset parent is a child of the scroll parent, and the scroll parent isn't the document, which means that
  3615. // the scroll is included in the initial calculation of the offset of the parent, and never recalculated upon drag
  3616. if(this.cssPosition === "absolute" && this.scrollParent[0] !== document && $.contains(this.scrollParent[0], this.offsetParent[0])) {
  3617. po.left += this.scrollParent.scrollLeft();
  3618. po.top += this.scrollParent.scrollTop();
  3619. }
  3620. // This needs to be actually done for all browsers, since pageX/pageY includes this information
  3621. // with an ugly IE fix
  3622. if( this.offsetParent[0] === document.body || (this.offsetParent[0].tagName && this.offsetParent[0].tagName.toLowerCase() === "html" && $.ui.ie)) {
  3623. po = { top: 0, left: 0 };
  3624. }
  3625. return {
  3626. top: po.top + (parseInt(this.offsetParent.css("borderTopWidth"),10) || 0),
  3627. left: po.left + (parseInt(this.offsetParent.css("borderLeftWidth"),10) || 0)
  3628. };
  3629. },
  3630. _getRelativeOffset: function() {
  3631. if(this.cssPosition === "relative") {
  3632. var p = this.currentItem.position();
  3633. return {
  3634. top: p.top - (parseInt(this.helper.css("top"),10) || 0) + this.scrollParent.scrollTop(),
  3635. left: p.left - (parseInt(this.helper.css("left"),10) || 0) + this.scrollParent.scrollLeft()
  3636. };
  3637. } else {
  3638. return { top: 0, left: 0 };
  3639. }
  3640. },
  3641. _cacheMargins: function() {
  3642. this.margins = {
  3643. left: (parseInt(this.currentItem.css("marginLeft"),10) || 0),
  3644. top: (parseInt(this.currentItem.css("marginTop"),10) || 0)
  3645. };
  3646. },
  3647. _cacheHelperProportions: function() {
  3648. this.helperProportions = {
  3649. width: this.helper.outerWidth(),
  3650. height: this.helper.outerHeight()
  3651. };
  3652. },
  3653. _setContainment: function() {
  3654. var ce, co, over,
  3655. o = this.options;
  3656. if(o.containment === "parent") {
  3657. o.containment = this.helper[0].parentNode;
  3658. }
  3659. if(o.containment === "document" || o.containment === "window") {
  3660. this.containment = [
  3661. 0 - this.offset.relative.left - this.offset.parent.left,
  3662. 0 - this.offset.relative.top - this.offset.parent.top,
  3663. $(o.containment === "document" ? document : window).width() - this.helperProportions.width - this.margins.left,
  3664. ($(o.containment === "document" ? document : window).height() || document.body.parentNode.scrollHeight) - this.helperProportions.height - this.margins.top
  3665. ];
  3666. }
  3667. if(!(/^(document|window|parent)$/).test(o.containment)) {
  3668. ce = $(o.containment)[0];
  3669. co = $(o.containment).offset();
  3670. over = ($(ce).css("overflow") !== "hidden");
  3671. this.containment = [
  3672. co.left + (parseInt($(ce).css("borderLeftWidth"),10) || 0) + (parseInt($(ce).css("paddingLeft"),10) || 0) - this.margins.left,
  3673. co.top + (parseInt($(ce).css("borderTopWidth"),10) || 0) + (parseInt($(ce).css("paddingTop"),10) || 0) - this.margins.top,
  3674. 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,
  3675. 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
  3676. ];
  3677. }
  3678. },
  3679. _convertPositionTo: function(d, pos) {
  3680. if(!pos) {
  3681. pos = this.position;
  3682. }
  3683. var mod = d === "absolute" ? 1 : -1,
  3684. scroll = this.cssPosition === "absolute" && !(this.scrollParent[0] !== document && $.contains(this.scrollParent[0], this.offsetParent[0])) ? this.offsetParent : this.scrollParent,
  3685. scrollIsRootNode = (/(html|body)/i).test(scroll[0].tagName);
  3686. return {
  3687. top: (
  3688. pos.top + // The absolute mouse position
  3689. this.offset.relative.top * mod + // Only for relative positioned nodes: Relative offset from element to offset parent
  3690. this.offset.parent.top * mod - // The offsetParent's offset without borders (offset + border)
  3691. ( ( this.cssPosition === "fixed" ? -this.scrollParent.scrollTop() : ( scrollIsRootNode ? 0 : scroll.scrollTop() ) ) * mod)
  3692. ),
  3693. left: (
  3694. pos.left + // The absolute mouse position
  3695. this.offset.relative.left * mod + // Only for relative positioned nodes: Relative offset from element to offset parent
  3696. this.offset.parent.left * mod - // The offsetParent's offset without borders (offset + border)
  3697. ( ( this.cssPosition === "fixed" ? -this.scrollParent.scrollLeft() : scrollIsRootNode ? 0 : scroll.scrollLeft() ) * mod)
  3698. )
  3699. };
  3700. },
  3701. _generatePosition: function(event) {
  3702. var top, left,
  3703. o = this.options,
  3704. pageX = event.pageX,
  3705. pageY = event.pageY,
  3706. 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);
  3707. // This is another very weird special case that only happens for relative elements:
  3708. // 1. If the css position is relative
  3709. // 2. and the scroll parent is the document or similar to the offset parent
  3710. // we have to refresh the relative offset during the scroll so there are no jumps
  3711. if(this.cssPosition === "relative" && !(this.scrollParent[0] !== document && this.scrollParent[0] !== this.offsetParent[0])) {
  3712. this.offset.relative = this._getRelativeOffset();
  3713. }
  3714. /*
  3715. * - Position constraining -
  3716. * Constrain the position to a mix of grid, containment.
  3717. */
  3718. if(this.originalPosition) { //If we are not dragging yet, we won't check for options
  3719. if(this.containment) {
  3720. if(event.pageX - this.offset.click.left < this.containment[0]) {
  3721. pageX = this.containment[0] + this.offset.click.left;
  3722. }
  3723. if(event.pageY - this.offset.click.top < this.containment[1]) {
  3724. pageY = this.containment[1] + this.offset.click.top;
  3725. }
  3726. if(event.pageX - this.offset.click.left > this.containment[2]) {
  3727. pageX = this.containment[2] + this.offset.click.left;
  3728. }
  3729. if(event.pageY - this.offset.click.top > this.containment[3]) {
  3730. pageY = this.containment[3] + this.offset.click.top;
  3731. }
  3732. }
  3733. if(o.grid) {
  3734. top = this.originalPageY + Math.round((pageY - this.originalPageY) / o.grid[1]) * o.grid[1];
  3735. 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;
  3736. left = this.originalPageX + Math.round((pageX - this.originalPageX) / o.grid[0]) * o.grid[0];
  3737. 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;
  3738. }
  3739. }
  3740. return {
  3741. top: (
  3742. pageY - // The absolute mouse position
  3743. this.offset.click.top - // Click offset (relative to the element)
  3744. this.offset.relative.top - // Only for relative positioned nodes: Relative offset from element to offset parent
  3745. this.offset.parent.top + // The offsetParent's offset without borders (offset + border)
  3746. ( ( this.cssPosition === "fixed" ? -this.scrollParent.scrollTop() : ( scrollIsRootNode ? 0 : scroll.scrollTop() ) ))
  3747. ),
  3748. left: (
  3749. pageX - // The absolute mouse position
  3750. this.offset.click.left - // Click offset (relative to the element)
  3751. this.offset.relative.left - // Only for relative positioned nodes: Relative offset from element to offset parent
  3752. this.offset.parent.left + // The offsetParent's offset without borders (offset + border)
  3753. ( ( this.cssPosition === "fixed" ? -this.scrollParent.scrollLeft() : scrollIsRootNode ? 0 : scroll.scrollLeft() ))
  3754. )
  3755. };
  3756. },
  3757. _rearrange: function(event, i, a, hardRefresh) {
  3758. 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));
  3759. //Various things done here to improve the performance:
  3760. // 1. we create a setTimeout, that calls refreshPositions
  3761. // 2. on the instance, we have a counter variable, that get's higher after every append
  3762. // 3. on the local scope, we copy the counter variable, and check in the timeout, if it's still the same
  3763. // 4. this lets only the last addition to the timeout stack through
  3764. this.counter = this.counter ? ++this.counter : 1;
  3765. var counter = this.counter;
  3766. this._delay(function() {
  3767. if(counter === this.counter) {
  3768. this.refreshPositions(!hardRefresh); //Precompute after each DOM insertion, NOT on mousemove
  3769. }
  3770. });
  3771. },
  3772. _clear: function(event, noPropagation) {
  3773. this.reverting = false;
  3774. // We delay all events that have to be triggered to after the point where the placeholder has been removed and
  3775. // everything else normalized again
  3776. var i,
  3777. delayedTriggers = [];
  3778. // We first have to update the dom position of the actual currentItem
  3779. // Note: don't do it if the current item is already removed (by a user), or it gets reappended (see #4088)
  3780. if(!this._noFinalSort && this.currentItem.parent().length) {
  3781. this.placeholder.before(this.currentItem);
  3782. }
  3783. this._noFinalSort = null;
  3784. if(this.helper[0] === this.currentItem[0]) {
  3785. for(i in this._storedCSS) {
  3786. if(this._storedCSS[i] === "auto" || this._storedCSS[i] === "static") {
  3787. this._storedCSS[i] = "";
  3788. }
  3789. }
  3790. this.currentItem.css(this._storedCSS).removeClass("ui-sortable-helper");
  3791. } else {
  3792. this.currentItem.show();
  3793. }
  3794. if(this.fromOutside && !noPropagation) {
  3795. delayedTriggers.push(function(event) { this._trigger("receive", event, this._uiHash(this.fromOutside)); });
  3796. }
  3797. if((this.fromOutside || this.domPosition.prev !== this.currentItem.prev().not(".ui-sortable-helper")[0] || this.domPosition.parent !== this.currentItem.parent()[0]) && !noPropagation) {
  3798. delayedTriggers.push(function(event) { this._trigger("update", event, this._uiHash()); }); //Trigger update callback if the DOM position has changed
  3799. }
  3800. // Check if the items Container has Changed and trigger appropriate
  3801. // events.
  3802. if (this !== this.currentContainer) {
  3803. if(!noPropagation) {
  3804. delayedTriggers.push(function(event) { this._trigger("remove", event, this._uiHash()); });
  3805. delayedTriggers.push((function(c) { return function(event) { c._trigger("receive", event, this._uiHash(this)); }; }).call(this, this.currentContainer));
  3806. delayedTriggers.push((function(c) { return function(event) { c._trigger("update", event, this._uiHash(this)); }; }).call(this, this.currentContainer));
  3807. }
  3808. }
  3809. //Post events to containers
  3810. for (i = this.containers.length - 1; i >= 0; i--){
  3811. if(!noPropagation) {
  3812. delayedTriggers.push((function(c) { return function(event) { c._trigger("deactivate", event, this._uiHash(this)); }; }).call(this, this.containers[i]));
  3813. }
  3814. if(this.containers[i].containerCache.over) {
  3815. delayedTriggers.push((function(c) { return function(event) { c._trigger("out", event, this._uiHash(this)); }; }).call(this, this.containers[i]));
  3816. this.containers[i].containerCache.over = 0;
  3817. }
  3818. }
  3819. //Do what was originally in plugins
  3820. if(this._storedCursor) {
  3821. $("body").css("cursor", this._storedCursor);
  3822. }
  3823. if(this._storedOpacity) {
  3824. this.helper.css("opacity", this._storedOpacity);
  3825. }
  3826. if(this._storedZIndex) {
  3827. this.helper.css("zIndex", this._storedZIndex === "auto" ? "" : this._storedZIndex);
  3828. }
  3829. this.dragging = false;
  3830. if(this.cancelHelperRemoval) {
  3831. if(!noPropagation) {
  3832. this._trigger("beforeStop", event, this._uiHash());
  3833. for (i=0; i < delayedTriggers.length; i++) {
  3834. delayedTriggers[i].call(this, event);
  3835. } //Trigger all delayed events
  3836. this._trigger("stop", event, this._uiHash());
  3837. }
  3838. this.fromOutside = false;
  3839. return false;
  3840. }
  3841. if(!noPropagation) {
  3842. this._trigger("beforeStop", event, this._uiHash());
  3843. }
  3844. //$(this.placeholder[0]).remove(); would have been the jQuery way - unfortunately, it unbinds ALL events from the original node!
  3845. this.placeholder[0].parentNode.removeChild(this.placeholder[0]);
  3846. if(this.helper[0] !== this.currentItem[0]) {
  3847. this.helper.remove();
  3848. }
  3849. this.helper = null;
  3850. if(!noPropagation) {
  3851. for (i=0; i < delayedTriggers.length; i++) {
  3852. delayedTriggers[i].call(this, event);
  3853. } //Trigger all delayed events
  3854. this._trigger("stop", event, this._uiHash());
  3855. }
  3856. this.fromOutside = false;
  3857. return true;
  3858. },
  3859. _trigger: function() {
  3860. if ($.Widget.prototype._trigger.apply(this, arguments) === false) {
  3861. this.cancel();
  3862. }
  3863. },
  3864. _uiHash: function(_inst) {
  3865. var inst = _inst || this;
  3866. return {
  3867. helper: inst.helper,
  3868. placeholder: inst.placeholder || $([]),
  3869. position: inst.position,
  3870. originalPosition: inst.originalPosition,
  3871. offset: inst.positionAbs,
  3872. item: inst.currentItem,
  3873. sender: _inst ? _inst.element : null
  3874. };
  3875. }
  3876. });
  3877. })(jQuery);
  3878. ;(jQuery.effects || (function($, undefined) {
  3879. var dataSpace = "ui-effects-";
  3880. $.effects = {
  3881. effect: {}
  3882. };
  3883. /*!
  3884. * jQuery Color Animations v2.1.2
  3885. * https://github.com/jquery/jquery-color
  3886. *
  3887. * Copyright 2013 jQuery Foundation and other contributors
  3888. * Released under the MIT license.
  3889. * http://jquery.org/license
  3890. *
  3891. * Date: Wed Jan 16 08:47:09 2013 -0600
  3892. */
  3893. (function( jQuery, undefined ) {
  3894. var stepHooks = "backgroundColor borderBottomColor borderLeftColor borderRightColor borderTopColor color columnRuleColor outlineColor textDecorationColor textEmphasisColor",
  3895. // plusequals test for += 100 -= 100
  3896. rplusequals = /^([\-+])=\s*(\d+\.?\d*)/,
  3897. // a set of RE's that can match strings and generate color tuples.
  3898. stringParsers = [{
  3899. re: /rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(?:,\s*(\d?(?:\.\d+)?)\s*)?\)/,
  3900. parse: function( execResult ) {
  3901. return [
  3902. execResult[ 1 ],
  3903. execResult[ 2 ],
  3904. execResult[ 3 ],
  3905. execResult[ 4 ]
  3906. ];
  3907. }
  3908. }, {
  3909. re: /rgba?\(\s*(\d+(?:\.\d+)?)\%\s*,\s*(\d+(?:\.\d+)?)\%\s*,\s*(\d+(?:\.\d+)?)\%\s*(?:,\s*(\d?(?:\.\d+)?)\s*)?\)/,
  3910. parse: function( execResult ) {
  3911. return [
  3912. execResult[ 1 ] * 2.55,
  3913. execResult[ 2 ] * 2.55,
  3914. execResult[ 3 ] * 2.55,
  3915. execResult[ 4 ]
  3916. ];
  3917. }
  3918. }, {
  3919. // this regex ignores A-F because it's compared against an already lowercased string
  3920. re: /#([a-f0-9]{2})([a-f0-9]{2})([a-f0-9]{2})/,
  3921. parse: function( execResult ) {
  3922. return [
  3923. parseInt( execResult[ 1 ], 16 ),
  3924. parseInt( execResult[ 2 ], 16 ),
  3925. parseInt( execResult[ 3 ], 16 )
  3926. ];
  3927. }
  3928. }, {
  3929. // this regex ignores A-F because it's compared against an already lowercased string
  3930. re: /#([a-f0-9])([a-f0-9])([a-f0-9])/,
  3931. parse: function( execResult ) {
  3932. return [
  3933. parseInt( execResult[ 1 ] + execResult[ 1 ], 16 ),
  3934. parseInt( execResult[ 2 ] + execResult[ 2 ], 16 ),
  3935. parseInt( execResult[ 3 ] + execResult[ 3 ], 16 )
  3936. ];
  3937. }
  3938. }, {
  3939. re: /hsla?\(\s*(\d+(?:\.\d+)?)\s*,\s*(\d+(?:\.\d+)?)\%\s*,\s*(\d+(?:\.\d+)?)\%\s*(?:,\s*(\d?(?:\.\d+)?)\s*)?\)/,
  3940. space: "hsla",
  3941. parse: function( execResult ) {
  3942. return [
  3943. execResult[ 1 ],
  3944. execResult[ 2 ] / 100,
  3945. execResult[ 3 ] / 100,
  3946. execResult[ 4 ]
  3947. ];
  3948. }
  3949. }],
  3950. // jQuery.Color( )
  3951. color = jQuery.Color = function( color, green, blue, alpha ) {
  3952. return new jQuery.Color.fn.parse( color, green, blue, alpha );
  3953. },
  3954. spaces = {
  3955. rgba: {
  3956. props: {
  3957. red: {
  3958. idx: 0,
  3959. type: "byte"
  3960. },
  3961. green: {
  3962. idx: 1,
  3963. type: "byte"
  3964. },
  3965. blue: {
  3966. idx: 2,
  3967. type: "byte"
  3968. }
  3969. }
  3970. },
  3971. hsla: {
  3972. props: {
  3973. hue: {
  3974. idx: 0,
  3975. type: "degrees"
  3976. },
  3977. saturation: {
  3978. idx: 1,
  3979. type: "percent"
  3980. },
  3981. lightness: {
  3982. idx: 2,
  3983. type: "percent"
  3984. }
  3985. }
  3986. }
  3987. },
  3988. propTypes = {
  3989. "byte": {
  3990. floor: true,
  3991. max: 255
  3992. },
  3993. "percent": {
  3994. max: 1
  3995. },
  3996. "degrees": {
  3997. mod: 360,
  3998. floor: true
  3999. }
  4000. },
  4001. support = color.support = {},
  4002. // element for support tests
  4003. supportElem = jQuery( "<p>" )[ 0 ],
  4004. // colors = jQuery.Color.names
  4005. colors,
  4006. // local aliases of functions called often
  4007. each = jQuery.each;
  4008. // determine rgba support immediately
  4009. supportElem.style.cssText = "background-color:rgba(1,1,1,.5)";
  4010. support.rgba = supportElem.style.backgroundColor.indexOf( "rgba" ) > -1;
  4011. // define cache name and alpha properties
  4012. // for rgba and hsla spaces
  4013. each( spaces, function( spaceName, space ) {
  4014. space.cache = "_" + spaceName;
  4015. space.props.alpha = {
  4016. idx: 3,
  4017. type: "percent",
  4018. def: 1
  4019. };
  4020. });
  4021. function clamp( value, prop, allowEmpty ) {
  4022. var type = propTypes[ prop.type ] || {};
  4023. if ( value == null ) {
  4024. return (allowEmpty || !prop.def) ? null : prop.def;
  4025. }
  4026. // ~~ is an short way of doing floor for positive numbers
  4027. value = type.floor ? ~~value : parseFloat( value );
  4028. // IE will pass in empty strings as value for alpha,
  4029. // which will hit this case
  4030. if ( isNaN( value ) ) {
  4031. return prop.def;
  4032. }
  4033. if ( type.mod ) {
  4034. // we add mod before modding to make sure that negatives values
  4035. // get converted properly: -10 -> 350
  4036. return (value + type.mod) % type.mod;
  4037. }
  4038. // for now all property types without mod have min and max
  4039. return 0 > value ? 0 : type.max < value ? type.max : value;
  4040. }
  4041. function stringParse( string ) {
  4042. var inst = color(),
  4043. rgba = inst._rgba = [];
  4044. string = string.toLowerCase();
  4045. each( stringParsers, function( i, parser ) {
  4046. var parsed,
  4047. match = parser.re.exec( string ),
  4048. values = match && parser.parse( match ),
  4049. spaceName = parser.space || "rgba";
  4050. if ( values ) {
  4051. parsed = inst[ spaceName ]( values );
  4052. // if this was an rgba parse the assignment might happen twice
  4053. // oh well....
  4054. inst[ spaces[ spaceName ].cache ] = parsed[ spaces[ spaceName ].cache ];
  4055. rgba = inst._rgba = parsed._rgba;
  4056. // exit each( stringParsers ) here because we matched
  4057. return false;
  4058. }
  4059. });
  4060. // Found a stringParser that handled it
  4061. if ( rgba.length ) {
  4062. // if this came from a parsed string, force "transparent" when alpha is 0
  4063. // chrome, (and maybe others) return "transparent" as rgba(0,0,0,0)
  4064. if ( rgba.join() === "0,0,0,0" ) {
  4065. jQuery.extend( rgba, colors.transparent );
  4066. }
  4067. return inst;
  4068. }
  4069. // named colors
  4070. return colors[ string ];
  4071. }
  4072. color.fn = jQuery.extend( color.prototype, {
  4073. parse: function( red, green, blue, alpha ) {
  4074. if ( red === undefined ) {
  4075. this._rgba = [ null, null, null, null ];
  4076. return this;
  4077. }
  4078. if ( red.jquery || red.nodeType ) {
  4079. red = jQuery( red ).css( green );
  4080. green = undefined;
  4081. }
  4082. var inst = this,
  4083. type = jQuery.type( red ),
  4084. rgba = this._rgba = [];
  4085. // more than 1 argument specified - assume ( red, green, blue, alpha )
  4086. if ( green !== undefined ) {
  4087. red = [ red, green, blue, alpha ];
  4088. type = "array";
  4089. }
  4090. if ( type === "string" ) {
  4091. return this.parse( stringParse( red ) || colors._default );
  4092. }
  4093. if ( type === "array" ) {
  4094. each( spaces.rgba.props, function( key, prop ) {
  4095. rgba[ prop.idx ] = clamp( red[ prop.idx ], prop );
  4096. });
  4097. return this;
  4098. }
  4099. if ( type === "object" ) {
  4100. if ( red instanceof color ) {
  4101. each( spaces, function( spaceName, space ) {
  4102. if ( red[ space.cache ] ) {
  4103. inst[ space.cache ] = red[ space.cache ].slice();
  4104. }
  4105. });
  4106. } else {
  4107. each( spaces, function( spaceName, space ) {
  4108. var cache = space.cache;
  4109. each( space.props, function( key, prop ) {
  4110. // if the cache doesn't exist, and we know how to convert
  4111. if ( !inst[ cache ] && space.to ) {
  4112. // if the value was null, we don't need to copy it
  4113. // if the key was alpha, we don't need to copy it either
  4114. if ( key === "alpha" || red[ key ] == null ) {
  4115. return;
  4116. }
  4117. inst[ cache ] = space.to( inst._rgba );
  4118. }
  4119. // this is the only case where we allow nulls for ALL properties.
  4120. // call clamp with alwaysAllowEmpty
  4121. inst[ cache ][ prop.idx ] = clamp( red[ key ], prop, true );
  4122. });
  4123. // everything defined but alpha?
  4124. if ( inst[ cache ] && jQuery.inArray( null, inst[ cache ].slice( 0, 3 ) ) < 0 ) {
  4125. // use the default of 1
  4126. inst[ cache ][ 3 ] = 1;
  4127. if ( space.from ) {
  4128. inst._rgba = space.from( inst[ cache ] );
  4129. }
  4130. }
  4131. });
  4132. }
  4133. return this;
  4134. }
  4135. },
  4136. is: function( compare ) {
  4137. var is = color( compare ),
  4138. same = true,
  4139. inst = this;
  4140. each( spaces, function( _, space ) {
  4141. var localCache,
  4142. isCache = is[ space.cache ];
  4143. if (isCache) {
  4144. localCache = inst[ space.cache ] || space.to && space.to( inst._rgba ) || [];
  4145. each( space.props, function( _, prop ) {
  4146. if ( isCache[ prop.idx ] != null ) {
  4147. same = ( isCache[ prop.idx ] === localCache[ prop.idx ] );
  4148. return same;
  4149. }
  4150. });
  4151. }
  4152. return same;
  4153. });
  4154. return same;
  4155. },
  4156. _space: function() {
  4157. var used = [],
  4158. inst = this;
  4159. each( spaces, function( spaceName, space ) {
  4160. if ( inst[ space.cache ] ) {
  4161. used.push( spaceName );
  4162. }
  4163. });
  4164. return used.pop();
  4165. },
  4166. transition: function( other, distance ) {
  4167. var end = color( other ),
  4168. spaceName = end._space(),
  4169. space = spaces[ spaceName ],
  4170. startColor = this.alpha() === 0 ? color( "transparent" ) : this,
  4171. start = startColor[ space.cache ] || space.to( startColor._rgba ),
  4172. result = start.slice();
  4173. end = end[ space.cache ];
  4174. each( space.props, function( key, prop ) {
  4175. var index = prop.idx,
  4176. startValue = start[ index ],
  4177. endValue = end[ index ],
  4178. type = propTypes[ prop.type ] || {};
  4179. // if null, don't override start value
  4180. if ( endValue === null ) {
  4181. return;
  4182. }
  4183. // if null - use end
  4184. if ( startValue === null ) {
  4185. result[ index ] = endValue;
  4186. } else {
  4187. if ( type.mod ) {
  4188. if ( endValue - startValue > type.mod / 2 ) {
  4189. startValue += type.mod;
  4190. } else if ( startValue - endValue > type.mod / 2 ) {
  4191. startValue -= type.mod;
  4192. }
  4193. }
  4194. result[ index ] = clamp( ( endValue - startValue ) * distance + startValue, prop );
  4195. }
  4196. });
  4197. return this[ spaceName ]( result );
  4198. },
  4199. blend: function( opaque ) {
  4200. // if we are already opaque - return ourself
  4201. if ( this._rgba[ 3 ] === 1 ) {
  4202. return this;
  4203. }
  4204. var rgb = this._rgba.slice(),
  4205. a = rgb.pop(),
  4206. blend = color( opaque )._rgba;
  4207. return color( jQuery.map( rgb, function( v, i ) {
  4208. return ( 1 - a ) * blend[ i ] + a * v;
  4209. }));
  4210. },
  4211. toRgbaString: function() {
  4212. var prefix = "rgba(",
  4213. rgba = jQuery.map( this._rgba, function( v, i ) {
  4214. return v == null ? ( i > 2 ? 1 : 0 ) : v;
  4215. });
  4216. if ( rgba[ 3 ] === 1 ) {
  4217. rgba.pop();
  4218. prefix = "rgb(";
  4219. }
  4220. return prefix + rgba.join() + ")";
  4221. },
  4222. toHslaString: function() {
  4223. var prefix = "hsla(",
  4224. hsla = jQuery.map( this.hsla(), function( v, i ) {
  4225. if ( v == null ) {
  4226. v = i > 2 ? 1 : 0;
  4227. }
  4228. // catch 1 and 2
  4229. if ( i && i < 3 ) {
  4230. v = Math.round( v * 100 ) + "%";
  4231. }
  4232. return v;
  4233. });
  4234. if ( hsla[ 3 ] === 1 ) {
  4235. hsla.pop();
  4236. prefix = "hsl(";
  4237. }
  4238. return prefix + hsla.join() + ")";
  4239. },
  4240. toHexString: function( includeAlpha ) {
  4241. var rgba = this._rgba.slice(),
  4242. alpha = rgba.pop();
  4243. if ( includeAlpha ) {
  4244. rgba.push( ~~( alpha * 255 ) );
  4245. }
  4246. return "#" + jQuery.map( rgba, function( v ) {
  4247. // default to 0 when nulls exist
  4248. v = ( v || 0 ).toString( 16 );
  4249. return v.length === 1 ? "0" + v : v;
  4250. }).join("");
  4251. },
  4252. toString: function() {
  4253. return this._rgba[ 3 ] === 0 ? "transparent" : this.toRgbaString();
  4254. }
  4255. });
  4256. color.fn.parse.prototype = color.fn;
  4257. // hsla conversions adapted from:
  4258. // https://code.google.com/p/maashaack/source/browse/packages/graphics/trunk/src/graphics/colors/HUE2RGB.as?r=5021
  4259. function hue2rgb( p, q, h ) {
  4260. h = ( h + 1 ) % 1;
  4261. if ( h * 6 < 1 ) {
  4262. return p + (q - p) * h * 6;
  4263. }
  4264. if ( h * 2 < 1) {
  4265. return q;
  4266. }
  4267. if ( h * 3 < 2 ) {
  4268. return p + (q - p) * ((2/3) - h) * 6;
  4269. }
  4270. return p;
  4271. }
  4272. spaces.hsla.to = function ( rgba ) {
  4273. if ( rgba[ 0 ] == null || rgba[ 1 ] == null || rgba[ 2 ] == null ) {
  4274. return [ null, null, null, rgba[ 3 ] ];
  4275. }
  4276. var r = rgba[ 0 ] / 255,
  4277. g = rgba[ 1 ] / 255,
  4278. b = rgba[ 2 ] / 255,
  4279. a = rgba[ 3 ],
  4280. max = Math.max( r, g, b ),
  4281. min = Math.min( r, g, b ),
  4282. diff = max - min,
  4283. add = max + min,
  4284. l = add * 0.5,
  4285. h, s;
  4286. if ( min === max ) {
  4287. h = 0;
  4288. } else if ( r === max ) {
  4289. h = ( 60 * ( g - b ) / diff ) + 360;
  4290. } else if ( g === max ) {
  4291. h = ( 60 * ( b - r ) / diff ) + 120;
  4292. } else {
  4293. h = ( 60 * ( r - g ) / diff ) + 240;
  4294. }
  4295. // chroma (diff) == 0 means greyscale which, by definition, saturation = 0%
  4296. // otherwise, saturation is based on the ratio of chroma (diff) to lightness (add)
  4297. if ( diff === 0 ) {
  4298. s = 0;
  4299. } else if ( l <= 0.5 ) {
  4300. s = diff / add;
  4301. } else {
  4302. s = diff / ( 2 - add );
  4303. }
  4304. return [ Math.round(h) % 360, s, l, a == null ? 1 : a ];
  4305. };
  4306. spaces.hsla.from = function ( hsla ) {
  4307. if ( hsla[ 0 ] == null || hsla[ 1 ] == null || hsla[ 2 ] == null ) {
  4308. return [ null, null, null, hsla[ 3 ] ];
  4309. }
  4310. var h = hsla[ 0 ] / 360,
  4311. s = hsla[ 1 ],
  4312. l = hsla[ 2 ],
  4313. a = hsla[ 3 ],
  4314. q = l <= 0.5 ? l * ( 1 + s ) : l + s - l * s,
  4315. p = 2 * l - q;
  4316. return [
  4317. Math.round( hue2rgb( p, q, h + ( 1 / 3 ) ) * 255 ),
  4318. Math.round( hue2rgb( p, q, h ) * 255 ),
  4319. Math.round( hue2rgb( p, q, h - ( 1 / 3 ) ) * 255 ),
  4320. a
  4321. ];
  4322. };
  4323. each( spaces, function( spaceName, space ) {
  4324. var props = space.props,
  4325. cache = space.cache,
  4326. to = space.to,
  4327. from = space.from;
  4328. // makes rgba() and hsla()
  4329. color.fn[ spaceName ] = function( value ) {
  4330. // generate a cache for this space if it doesn't exist
  4331. if ( to && !this[ cache ] ) {
  4332. this[ cache ] = to( this._rgba );
  4333. }
  4334. if ( value === undefined ) {
  4335. return this[ cache ].slice();
  4336. }
  4337. var ret,
  4338. type = jQuery.type( value ),
  4339. arr = ( type === "array" || type === "object" ) ? value : arguments,
  4340. local = this[ cache ].slice();
  4341. each( props, function( key, prop ) {
  4342. var val = arr[ type === "object" ? key : prop.idx ];
  4343. if ( val == null ) {
  4344. val = local[ prop.idx ];
  4345. }
  4346. local[ prop.idx ] = clamp( val, prop );
  4347. });
  4348. if ( from ) {
  4349. ret = color( from( local ) );
  4350. ret[ cache ] = local;
  4351. return ret;
  4352. } else {
  4353. return color( local );
  4354. }
  4355. };
  4356. // makes red() green() blue() alpha() hue() saturation() lightness()
  4357. each( props, function( key, prop ) {
  4358. // alpha is included in more than one space
  4359. if ( color.fn[ key ] ) {
  4360. return;
  4361. }
  4362. color.fn[ key ] = function( value ) {
  4363. var vtype = jQuery.type( value ),
  4364. fn = ( key === "alpha" ? ( this._hsla ? "hsla" : "rgba" ) : spaceName ),
  4365. local = this[ fn ](),
  4366. cur = local[ prop.idx ],
  4367. match;
  4368. if ( vtype === "undefined" ) {
  4369. return cur;
  4370. }
  4371. if ( vtype === "function" ) {
  4372. value = value.call( this, cur );
  4373. vtype = jQuery.type( value );
  4374. }
  4375. if ( value == null && prop.empty ) {
  4376. return this;
  4377. }
  4378. if ( vtype === "string" ) {
  4379. match = rplusequals.exec( value );
  4380. if ( match ) {
  4381. value = cur + parseFloat( match[ 2 ] ) * ( match[ 1 ] === "+" ? 1 : -1 );
  4382. }
  4383. }
  4384. local[ prop.idx ] = value;
  4385. return this[ fn ]( local );
  4386. };
  4387. });
  4388. });
  4389. // add cssHook and .fx.step function for each named hook.
  4390. // accept a space separated string of properties
  4391. color.hook = function( hook ) {
  4392. var hooks = hook.split( " " );
  4393. each( hooks, function( i, hook ) {
  4394. jQuery.cssHooks[ hook ] = {
  4395. set: function( elem, value ) {
  4396. var parsed, curElem,
  4397. backgroundColor = "";
  4398. if ( value !== "transparent" && ( jQuery.type( value ) !== "string" || ( parsed = stringParse( value ) ) ) ) {
  4399. value = color( parsed || value );
  4400. if ( !support.rgba && value._rgba[ 3 ] !== 1 ) {
  4401. curElem = hook === "backgroundColor" ? elem.parentNode : elem;
  4402. while (
  4403. (backgroundColor === "" || backgroundColor === "transparent") &&
  4404. curElem && curElem.style
  4405. ) {
  4406. try {
  4407. backgroundColor = jQuery.css( curElem, "backgroundColor" );
  4408. curElem = curElem.parentNode;
  4409. } catch ( e ) {
  4410. }
  4411. }
  4412. value = value.blend( backgroundColor && backgroundColor !== "transparent" ?
  4413. backgroundColor :
  4414. "_default" );
  4415. }
  4416. value = value.toRgbaString();
  4417. }
  4418. try {
  4419. elem.style[ hook ] = value;
  4420. } catch( e ) {
  4421. // wrapped to prevent IE from throwing errors on "invalid" values like 'auto' or 'inherit'
  4422. }
  4423. }
  4424. };
  4425. jQuery.fx.step[ hook ] = function( fx ) {
  4426. if ( !fx.colorInit ) {
  4427. fx.start = color( fx.elem, hook );
  4428. fx.end = color( fx.end );
  4429. fx.colorInit = true;
  4430. }
  4431. jQuery.cssHooks[ hook ].set( fx.elem, fx.start.transition( fx.end, fx.pos ) );
  4432. };
  4433. });
  4434. };
  4435. color.hook( stepHooks );
  4436. jQuery.cssHooks.borderColor = {
  4437. expand: function( value ) {
  4438. var expanded = {};
  4439. each( [ "Top", "Right", "Bottom", "Left" ], function( i, part ) {
  4440. expanded[ "border" + part + "Color" ] = value;
  4441. });
  4442. return expanded;
  4443. }
  4444. };
  4445. // Basic color names only.
  4446. // Usage of any of the other color names requires adding yourself or including
  4447. // jquery.color.svg-names.js.
  4448. colors = jQuery.Color.names = {
  4449. // 4.1. Basic color keywords
  4450. aqua: "#00ffff",
  4451. black: "#000000",
  4452. blue: "#0000ff",
  4453. fuchsia: "#ff00ff",
  4454. gray: "#808080",
  4455. green: "#008000",
  4456. lime: "#00ff00",
  4457. maroon: "#800000",
  4458. navy: "#000080",
  4459. olive: "#808000",
  4460. purple: "#800080",
  4461. red: "#ff0000",
  4462. silver: "#c0c0c0",
  4463. teal: "#008080",
  4464. white: "#ffffff",
  4465. yellow: "#ffff00",
  4466. // 4.2.3. "transparent" color keyword
  4467. transparent: [ null, null, null, 0 ],
  4468. _default: "#ffffff"
  4469. };
  4470. })( jQuery );
  4471. /******************************************************************************/
  4472. /****************************** CLASS ANIMATIONS ******************************/
  4473. /******************************************************************************/
  4474. (function() {
  4475. var classAnimationActions = [ "add", "remove", "toggle" ],
  4476. shorthandStyles = {
  4477. border: 1,
  4478. borderBottom: 1,
  4479. borderColor: 1,
  4480. borderLeft: 1,
  4481. borderRight: 1,
  4482. borderTop: 1,
  4483. borderWidth: 1,
  4484. margin: 1,
  4485. padding: 1
  4486. };
  4487. $.each([ "borderLeftStyle", "borderRightStyle", "borderBottomStyle", "borderTopStyle" ], function( _, prop ) {
  4488. $.fx.step[ prop ] = function( fx ) {
  4489. if ( fx.end !== "none" && !fx.setAttr || fx.pos === 1 && !fx.setAttr ) {
  4490. jQuery.style( fx.elem, prop, fx.end );
  4491. fx.setAttr = true;
  4492. }
  4493. };
  4494. });
  4495. function getElementStyles( elem ) {
  4496. var key, len,
  4497. style = elem.ownerDocument.defaultView ?
  4498. elem.ownerDocument.defaultView.getComputedStyle( elem, null ) :
  4499. elem.currentStyle,
  4500. styles = {};
  4501. if ( style && style.length && style[ 0 ] && style[ style[ 0 ] ] ) {
  4502. len = style.length;
  4503. while ( len-- ) {
  4504. key = style[ len ];
  4505. if ( typeof style[ key ] === "string" ) {
  4506. styles[ $.camelCase( key ) ] = style[ key ];
  4507. }
  4508. }
  4509. // support: Opera, IE <9
  4510. } else {
  4511. for ( key in style ) {
  4512. if ( typeof style[ key ] === "string" ) {
  4513. styles[ key ] = style[ key ];
  4514. }
  4515. }
  4516. }
  4517. return styles;
  4518. }
  4519. function styleDifference( oldStyle, newStyle ) {
  4520. var diff = {},
  4521. name, value;
  4522. for ( name in newStyle ) {
  4523. value = newStyle[ name ];
  4524. if ( oldStyle[ name ] !== value ) {
  4525. if ( !shorthandStyles[ name ] ) {
  4526. if ( $.fx.step[ name ] || !isNaN( parseFloat( value ) ) ) {
  4527. diff[ name ] = value;
  4528. }
  4529. }
  4530. }
  4531. }
  4532. return diff;
  4533. }
  4534. // support: jQuery <1.8
  4535. if ( !$.fn.addBack ) {
  4536. $.fn.addBack = function( selector ) {
  4537. return this.add( selector == null ?
  4538. this.prevObject : this.prevObject.filter( selector )
  4539. );
  4540. };
  4541. }
  4542. $.effects.animateClass = function( value, duration, easing, callback ) {
  4543. var o = $.speed( duration, easing, callback );
  4544. return this.queue( function() {
  4545. var animated = $( this ),
  4546. baseClass = animated.attr( "class" ) || "",
  4547. applyClassChange,
  4548. allAnimations = o.children ? animated.find( "*" ).addBack() : animated;
  4549. // map the animated objects to store the original styles.
  4550. allAnimations = allAnimations.map(function() {
  4551. var el = $( this );
  4552. return {
  4553. el: el,
  4554. start: getElementStyles( this )
  4555. };
  4556. });
  4557. // apply class change
  4558. applyClassChange = function() {
  4559. $.each( classAnimationActions, function(i, action) {
  4560. if ( value[ action ] ) {
  4561. animated[ action + "Class" ]( value[ action ] );
  4562. }
  4563. });
  4564. };
  4565. applyClassChange();
  4566. // map all animated objects again - calculate new styles and diff
  4567. allAnimations = allAnimations.map(function() {
  4568. this.end = getElementStyles( this.el[ 0 ] );
  4569. this.diff = styleDifference( this.start, this.end );
  4570. return this;
  4571. });
  4572. // apply original class
  4573. animated.attr( "class", baseClass );
  4574. // map all animated objects again - this time collecting a promise
  4575. allAnimations = allAnimations.map(function() {
  4576. var styleInfo = this,
  4577. dfd = $.Deferred(),
  4578. opts = $.extend({}, o, {
  4579. queue: false,
  4580. complete: function() {
  4581. dfd.resolve( styleInfo );
  4582. }
  4583. });
  4584. this.el.animate( this.diff, opts );
  4585. return dfd.promise();
  4586. });
  4587. // once all animations have completed:
  4588. $.when.apply( $, allAnimations.get() ).done(function() {
  4589. // set the final class
  4590. applyClassChange();
  4591. // for each animated element,
  4592. // clear all css properties that were animated
  4593. $.each( arguments, function() {
  4594. var el = this.el;
  4595. $.each( this.diff, function(key) {
  4596. el.css( key, "" );
  4597. });
  4598. });
  4599. // this is guarnteed to be there if you use jQuery.speed()
  4600. // it also handles dequeuing the next anim...
  4601. o.complete.call( animated[ 0 ] );
  4602. });
  4603. });
  4604. };
  4605. $.fn.extend({
  4606. _addClass: $.fn.addClass,
  4607. addClass: function( classNames, speed, easing, callback ) {
  4608. return speed ?
  4609. $.effects.animateClass.call( this,
  4610. { add: classNames }, speed, easing, callback ) :
  4611. this._addClass( classNames );
  4612. },
  4613. _removeClass: $.fn.removeClass,
  4614. removeClass: function( classNames, speed, easing, callback ) {
  4615. return arguments.length > 1 ?
  4616. $.effects.animateClass.call( this,
  4617. { remove: classNames }, speed, easing, callback ) :
  4618. this._removeClass.apply( this, arguments );
  4619. },
  4620. _toggleClass: $.fn.toggleClass,
  4621. toggleClass: function( classNames, force, speed, easing, callback ) {
  4622. if ( typeof force === "boolean" || force === undefined ) {
  4623. if ( !speed ) {
  4624. // without speed parameter
  4625. return this._toggleClass( classNames, force );
  4626. } else {
  4627. return $.effects.animateClass.call( this,
  4628. (force ? { add: classNames } : { remove: classNames }),
  4629. speed, easing, callback );
  4630. }
  4631. } else {
  4632. // without force parameter
  4633. return $.effects.animateClass.call( this,
  4634. { toggle: classNames }, force, speed, easing );
  4635. }
  4636. },
  4637. switchClass: function( remove, add, speed, easing, callback) {
  4638. return $.effects.animateClass.call( this, {
  4639. add: add,
  4640. remove: remove
  4641. }, speed, easing, callback );
  4642. }
  4643. });
  4644. })();
  4645. /******************************************************************************/
  4646. /*********************************** EFFECTS **********************************/
  4647. /******************************************************************************/
  4648. (function() {
  4649. $.extend( $.effects, {
  4650. version: "1.10.1",
  4651. // Saves a set of properties in a data storage
  4652. save: function( element, set ) {
  4653. for( var i=0; i < set.length; i++ ) {
  4654. if ( set[ i ] !== null ) {
  4655. element.data( dataSpace + set[ i ], element[ 0 ].style[ set[ i ] ] );
  4656. }
  4657. }
  4658. },
  4659. // Restores a set of previously saved properties from a data storage
  4660. restore: function( element, set ) {
  4661. var val, i;
  4662. for( i=0; i < set.length; i++ ) {
  4663. if ( set[ i ] !== null ) {
  4664. val = element.data( dataSpace + set[ i ] );
  4665. // support: jQuery 1.6.2
  4666. // http://bugs.jquery.com/ticket/9917
  4667. // jQuery 1.6.2 incorrectly returns undefined for any falsy value.
  4668. // We can't differentiate between "" and 0 here, so we just assume
  4669. // empty string since it's likely to be a more common value...
  4670. if ( val === undefined ) {
  4671. val = "";
  4672. }
  4673. element.css( set[ i ], val );
  4674. }
  4675. }
  4676. },
  4677. setMode: function( el, mode ) {
  4678. if (mode === "toggle") {
  4679. mode = el.is( ":hidden" ) ? "show" : "hide";
  4680. }
  4681. return mode;
  4682. },
  4683. // Translates a [top,left] array into a baseline value
  4684. // this should be a little more flexible in the future to handle a string & hash
  4685. getBaseline: function( origin, original ) {
  4686. var y, x;
  4687. switch ( origin[ 0 ] ) {
  4688. case "top": y = 0; break;
  4689. case "middle": y = 0.5; break;
  4690. case "bottom": y = 1; break;
  4691. default: y = origin[ 0 ] / original.height;
  4692. }
  4693. switch ( origin[ 1 ] ) {
  4694. case "left": x = 0; break;
  4695. case "center": x = 0.5; break;
  4696. case "right": x = 1; break;
  4697. default: x = origin[ 1 ] / original.width;
  4698. }
  4699. return {
  4700. x: x,
  4701. y: y
  4702. };
  4703. },
  4704. // Wraps the element around a wrapper that copies position properties
  4705. createWrapper: function( element ) {
  4706. // if the element is already wrapped, return it
  4707. if ( element.parent().is( ".ui-effects-wrapper" )) {
  4708. return element.parent();
  4709. }
  4710. // wrap the element
  4711. var props = {
  4712. width: element.outerWidth(true),
  4713. height: element.outerHeight(true),
  4714. "float": element.css( "float" )
  4715. },
  4716. wrapper = $( "<div></div>" )
  4717. .addClass( "ui-effects-wrapper" )
  4718. .css({
  4719. fontSize: "100%",
  4720. background: "transparent",
  4721. border: "none",
  4722. margin: 0,
  4723. padding: 0
  4724. }),
  4725. // Store the size in case width/height are defined in % - Fixes #5245
  4726. size = {
  4727. width: element.width(),
  4728. height: element.height()
  4729. },
  4730. active = document.activeElement;
  4731. // support: Firefox
  4732. // Firefox incorrectly exposes anonymous content
  4733. // https://bugzilla.mozilla.org/show_bug.cgi?id=561664
  4734. try {
  4735. active.id;
  4736. } catch( e ) {
  4737. active = document.body;
  4738. }
  4739. element.wrap( wrapper );
  4740. // Fixes #7595 - Elements lose focus when wrapped.
  4741. if ( element[ 0 ] === active || $.contains( element[ 0 ], active ) ) {
  4742. $( active ).focus();
  4743. }
  4744. wrapper = element.parent(); //Hotfix for jQuery 1.4 since some change in wrap() seems to actually lose the reference to the wrapped element
  4745. // transfer positioning properties to the wrapper
  4746. if ( element.css( "position" ) === "static" ) {
  4747. wrapper.css({ position: "relative" });
  4748. element.css({ position: "relative" });
  4749. } else {
  4750. $.extend( props, {
  4751. position: element.css( "position" ),
  4752. zIndex: element.css( "z-index" )
  4753. });
  4754. $.each([ "top", "left", "bottom", "right" ], function(i, pos) {
  4755. props[ pos ] = element.css( pos );
  4756. if ( isNaN( parseInt( props[ pos ], 10 ) ) ) {
  4757. props[ pos ] = "auto";
  4758. }
  4759. });
  4760. element.css({
  4761. position: "relative",
  4762. top: 0,
  4763. left: 0,
  4764. right: "auto",
  4765. bottom: "auto"
  4766. });
  4767. }
  4768. element.css(size);
  4769. return wrapper.css( props ).show();
  4770. },
  4771. removeWrapper: function( element ) {
  4772. var active = document.activeElement;
  4773. if ( element.parent().is( ".ui-effects-wrapper" ) ) {
  4774. element.parent().replaceWith( element );
  4775. // Fixes #7595 - Elements lose focus when wrapped.
  4776. if ( element[ 0 ] === active || $.contains( element[ 0 ], active ) ) {
  4777. $( active ).focus();
  4778. }
  4779. }
  4780. return element;
  4781. },
  4782. setTransition: function( element, list, factor, value ) {
  4783. value = value || {};
  4784. $.each( list, function( i, x ) {
  4785. var unit = element.cssUnit( x );
  4786. if ( unit[ 0 ] > 0 ) {
  4787. value[ x ] = unit[ 0 ] * factor + unit[ 1 ];
  4788. }
  4789. });
  4790. return value;
  4791. }
  4792. });
  4793. // return an effect options object for the given parameters:
  4794. function _normalizeArguments( effect, options, speed, callback ) {
  4795. // allow passing all options as the first parameter
  4796. if ( $.isPlainObject( effect ) ) {
  4797. options = effect;
  4798. effect = effect.effect;
  4799. }
  4800. // convert to an object
  4801. effect = { effect: effect };
  4802. // catch (effect, null, ...)
  4803. if ( options == null ) {
  4804. options = {};
  4805. }
  4806. // catch (effect, callback)
  4807. if ( $.isFunction( options ) ) {
  4808. callback = options;
  4809. speed = null;
  4810. options = {};
  4811. }
  4812. // catch (effect, speed, ?)
  4813. if ( typeof options === "number" || $.fx.speeds[ options ] ) {
  4814. callback = speed;
  4815. speed = options;
  4816. options = {};
  4817. }
  4818. // catch (effect, options, callback)
  4819. if ( $.isFunction( speed ) ) {
  4820. callback = speed;
  4821. speed = null;
  4822. }
  4823. // add options to effect
  4824. if ( options ) {
  4825. $.extend( effect, options );
  4826. }
  4827. speed = speed || options.duration;
  4828. effect.duration = $.fx.off ? 0 :
  4829. typeof speed === "number" ? speed :
  4830. speed in $.fx.speeds ? $.fx.speeds[ speed ] :
  4831. $.fx.speeds._default;
  4832. effect.complete = callback || options.complete;
  4833. return effect;
  4834. }
  4835. function standardSpeed( speed ) {
  4836. // valid standard speeds
  4837. if ( !speed || typeof speed === "number" || $.fx.speeds[ speed ] ) {
  4838. return true;
  4839. }
  4840. // invalid strings - treat as "normal" speed
  4841. return typeof speed === "string" && !$.effects.effect[ speed ];
  4842. }
  4843. $.fn.extend({
  4844. effect: function( /* effect, options, speed, callback */ ) {
  4845. var args = _normalizeArguments.apply( this, arguments ),
  4846. mode = args.mode,
  4847. queue = args.queue,
  4848. effectMethod = $.effects.effect[ args.effect ];
  4849. if ( $.fx.off || !effectMethod ) {
  4850. // delegate to the original method (e.g., .show()) if possible
  4851. if ( mode ) {
  4852. return this[ mode ]( args.duration, args.complete );
  4853. } else {
  4854. return this.each( function() {
  4855. if ( args.complete ) {
  4856. args.complete.call( this );
  4857. }
  4858. });
  4859. }
  4860. }
  4861. function run( next ) {
  4862. var elem = $( this ),
  4863. complete = args.complete,
  4864. mode = args.mode;
  4865. function done() {
  4866. if ( $.isFunction( complete ) ) {
  4867. complete.call( elem[0] );
  4868. }
  4869. if ( $.isFunction( next ) ) {
  4870. next();
  4871. }
  4872. }
  4873. // if the element is hiddden and mode is hide,
  4874. // or element is visible and mode is show
  4875. if ( elem.is( ":hidden" ) ? mode === "hide" : mode === "show" ) {
  4876. done();
  4877. } else {
  4878. effectMethod.call( elem[0], args, done );
  4879. }
  4880. }
  4881. return queue === false ? this.each( run ) : this.queue( queue || "fx", run );
  4882. },
  4883. _show: $.fn.show,
  4884. show: function( speed ) {
  4885. if ( standardSpeed( speed ) ) {
  4886. return this._show.apply( this, arguments );
  4887. } else {
  4888. var args = _normalizeArguments.apply( this, arguments );
  4889. args.mode = "show";
  4890. return this.effect.call( this, args );
  4891. }
  4892. },
  4893. _hide: $.fn.hide,
  4894. hide: function( speed ) {
  4895. if ( standardSpeed( speed ) ) {
  4896. return this._hide.apply( this, arguments );
  4897. } else {
  4898. var args = _normalizeArguments.apply( this, arguments );
  4899. args.mode = "hide";
  4900. return this.effect.call( this, args );
  4901. }
  4902. },
  4903. // jQuery core overloads toggle and creates _toggle
  4904. __toggle: $.fn.toggle,
  4905. toggle: function( speed ) {
  4906. if ( standardSpeed( speed ) || typeof speed === "boolean" || $.isFunction( speed ) ) {
  4907. return this.__toggle.apply( this, arguments );
  4908. } else {
  4909. var args = _normalizeArguments.apply( this, arguments );
  4910. args.mode = "toggle";
  4911. return this.effect.call( this, args );
  4912. }
  4913. },
  4914. // helper functions
  4915. cssUnit: function(key) {
  4916. var style = this.css( key ),
  4917. val = [];
  4918. $.each( [ "em", "px", "%", "pt" ], function( i, unit ) {
  4919. if ( style.indexOf( unit ) > 0 ) {
  4920. val = [ parseFloat( style ), unit ];
  4921. }
  4922. });
  4923. return val;
  4924. }
  4925. });
  4926. })();
  4927. /******************************************************************************/
  4928. /*********************************** EASING ***********************************/
  4929. /******************************************************************************/
  4930. (function() {
  4931. // based on easing equations from Robert Penner (http://www.robertpenner.com/easing)
  4932. var baseEasings = {};
  4933. $.each( [ "Quad", "Cubic", "Quart", "Quint", "Expo" ], function( i, name ) {
  4934. baseEasings[ name ] = function( p ) {
  4935. return Math.pow( p, i + 2 );
  4936. };
  4937. });
  4938. $.extend( baseEasings, {
  4939. Sine: function ( p ) {
  4940. return 1 - Math.cos( p * Math.PI / 2 );
  4941. },
  4942. Circ: function ( p ) {
  4943. return 1 - Math.sqrt( 1 - p * p );
  4944. },
  4945. Elastic: function( p ) {
  4946. return p === 0 || p === 1 ? p :
  4947. -Math.pow( 2, 8 * (p - 1) ) * Math.sin( ( (p - 1) * 80 - 7.5 ) * Math.PI / 15 );
  4948. },
  4949. Back: function( p ) {
  4950. return p * p * ( 3 * p - 2 );
  4951. },
  4952. Bounce: function ( p ) {
  4953. var pow2,
  4954. bounce = 4;
  4955. while ( p < ( ( pow2 = Math.pow( 2, --bounce ) ) - 1 ) / 11 ) {}
  4956. return 1 / Math.pow( 4, 3 - bounce ) - 7.5625 * Math.pow( ( pow2 * 3 - 2 ) / 22 - p, 2 );
  4957. }
  4958. });
  4959. $.each( baseEasings, function( name, easeIn ) {
  4960. $.easing[ "easeIn" + name ] = easeIn;
  4961. $.easing[ "easeOut" + name ] = function( p ) {
  4962. return 1 - easeIn( 1 - p );
  4963. };
  4964. $.easing[ "easeInOut" + name ] = function( p ) {
  4965. return p < 0.5 ?
  4966. easeIn( p * 2 ) / 2 :
  4967. 1 - easeIn( p * -2 + 2 ) / 2;
  4968. };
  4969. });
  4970. })();
  4971. })(jQuery));
  4972. (function( $, undefined ) {
  4973. var uid = 0,
  4974. hideProps = {},
  4975. showProps = {};
  4976. hideProps.height = hideProps.paddingTop = hideProps.paddingBottom =
  4977. hideProps.borderTopWidth = hideProps.borderBottomWidth = "hide";
  4978. showProps.height = showProps.paddingTop = showProps.paddingBottom =
  4979. showProps.borderTopWidth = showProps.borderBottomWidth = "show";
  4980. $.widget( "ui.accordion", {
  4981. version: "1.10.1",
  4982. options: {
  4983. active: 0,
  4984. animate: {},
  4985. collapsible: false,
  4986. event: "click",
  4987. header: "> li > :first-child,> :not(li):even",
  4988. heightStyle: "auto",
  4989. icons: {
  4990. activeHeader: "ui-icon-triangle-1-s",
  4991. header: "ui-icon-triangle-1-e"
  4992. },
  4993. // callbacks
  4994. activate: null,
  4995. beforeActivate: null
  4996. },
  4997. _create: function() {
  4998. var options = this.options;
  4999. this.prevShow = this.prevHide = $();
  5000. this.element.addClass( "ui-accordion ui-widget ui-helper-reset" )
  5001. // ARIA
  5002. .attr( "role", "tablist" );
  5003. // don't allow collapsible: false and active: false / null
  5004. if ( !options.collapsible && (options.active === false || options.active == null) ) {
  5005. options.active = 0;
  5006. }
  5007. this._processPanels();
  5008. // handle negative values
  5009. if ( options.active < 0 ) {
  5010. options.active += this.headers.length;
  5011. }
  5012. this._refresh();
  5013. },
  5014. _getCreateEventData: function() {
  5015. return {
  5016. header: this.active,
  5017. panel: !this.active.length ? $() : this.active.next(),
  5018. content: !this.active.length ? $() : this.active.next()
  5019. };
  5020. },
  5021. _createIcons: function() {
  5022. var icons = this.options.icons;
  5023. if ( icons ) {
  5024. $( "<span>" )
  5025. .addClass( "ui-accordion-header-icon ui-icon " + icons.header )
  5026. .prependTo( this.headers );
  5027. this.active.children( ".ui-accordion-header-icon" )
  5028. .removeClass( icons.header )
  5029. .addClass( icons.activeHeader );
  5030. this.headers.addClass( "ui-accordion-icons" );
  5031. }
  5032. },
  5033. _destroyIcons: function() {
  5034. this.headers
  5035. .removeClass( "ui-accordion-icons" )
  5036. .children( ".ui-accordion-header-icon" )
  5037. .remove();
  5038. },
  5039. _destroy: function() {
  5040. var contents;
  5041. // clean up main element
  5042. this.element
  5043. .removeClass( "ui-accordion ui-widget ui-helper-reset" )
  5044. .removeAttr( "role" );
  5045. // clean up headers
  5046. this.headers
  5047. .removeClass( "ui-accordion-header ui-accordion-header-active ui-helper-reset ui-state-default ui-corner-all ui-state-active ui-state-disabled ui-corner-top" )
  5048. .removeAttr( "role" )
  5049. .removeAttr( "aria-selected" )
  5050. .removeAttr( "aria-controls" )
  5051. .removeAttr( "tabIndex" )
  5052. .each(function() {
  5053. if ( /^ui-accordion/.test( this.id ) ) {
  5054. this.removeAttribute( "id" );
  5055. }
  5056. });
  5057. this._destroyIcons();
  5058. // clean up content panels
  5059. contents = this.headers.next()
  5060. .css( "display", "" )
  5061. .removeAttr( "role" )
  5062. .removeAttr( "aria-expanded" )
  5063. .removeAttr( "aria-hidden" )
  5064. .removeAttr( "aria-labelledby" )
  5065. .removeClass( "ui-helper-reset ui-widget-content ui-corner-bottom ui-accordion-content ui-accordion-content-active ui-state-disabled" )
  5066. .each(function() {
  5067. if ( /^ui-accordion/.test( this.id ) ) {
  5068. this.removeAttribute( "id" );
  5069. }
  5070. });
  5071. if ( this.options.heightStyle !== "content" ) {
  5072. contents.css( "height", "" );
  5073. }
  5074. },
  5075. _setOption: function( key, value ) {
  5076. if ( key === "active" ) {
  5077. // _activate() will handle invalid values and update this.options
  5078. this._activate( value );
  5079. return;
  5080. }
  5081. if ( key === "event" ) {
  5082. if ( this.options.event ) {
  5083. this._off( this.headers, this.options.event );
  5084. }
  5085. this._setupEvents( value );
  5086. }
  5087. this._super( key, value );
  5088. // setting collapsible: false while collapsed; open first panel
  5089. if ( key === "collapsible" && !value && this.options.active === false ) {
  5090. this._activate( 0 );
  5091. }
  5092. if ( key === "icons" ) {
  5093. this._destroyIcons();
  5094. if ( value ) {
  5095. this._createIcons();
  5096. }
  5097. }
  5098. // #5332 - opacity doesn't cascade to positioned elements in IE
  5099. // so we need to add the disabled class to the headers and panels
  5100. if ( key === "disabled" ) {
  5101. this.headers.add( this.headers.next() )
  5102. .toggleClass( "ui-state-disabled", !!value );
  5103. }
  5104. },
  5105. _keydown: function( event ) {
  5106. /*jshint maxcomplexity:15*/
  5107. if ( event.altKey || event.ctrlKey ) {
  5108. return;
  5109. }
  5110. var keyCode = $.ui.keyCode,
  5111. length = this.headers.length,
  5112. currentIndex = this.headers.index( event.target ),
  5113. toFocus = false;
  5114. switch ( event.keyCode ) {
  5115. case keyCode.RIGHT:
  5116. case keyCode.DOWN:
  5117. toFocus = this.headers[ ( currentIndex + 1 ) % length ];
  5118. break;
  5119. case keyCode.LEFT:
  5120. case keyCode.UP:
  5121. toFocus = this.headers[ ( currentIndex - 1 + length ) % length ];
  5122. break;
  5123. case keyCode.SPACE:
  5124. case keyCode.ENTER:
  5125. this._eventHandler( event );
  5126. break;
  5127. case keyCode.HOME:
  5128. toFocus = this.headers[ 0 ];
  5129. break;
  5130. case keyCode.END:
  5131. toFocus = this.headers[ length - 1 ];
  5132. break;
  5133. }
  5134. if ( toFocus ) {
  5135. $( event.target ).attr( "tabIndex", -1 );
  5136. $( toFocus ).attr( "tabIndex", 0 );
  5137. toFocus.focus();
  5138. event.preventDefault();
  5139. }
  5140. },
  5141. _panelKeyDown : function( event ) {
  5142. if ( event.keyCode === $.ui.keyCode.UP && event.ctrlKey ) {
  5143. $( event.currentTarget ).prev().focus();
  5144. }
  5145. },
  5146. refresh: function() {
  5147. var options = this.options;
  5148. this._processPanels();
  5149. // was collapsed or no panel
  5150. if ( ( options.active === false && options.collapsible === true ) || !this.headers.length ) {
  5151. options.active = false;
  5152. this.active = $();
  5153. // active false only when collapsible is true
  5154. } if ( options.active === false ) {
  5155. this._activate( 0 );
  5156. // was active, but active panel is gone
  5157. } else if ( this.active.length && !$.contains( this.element[ 0 ], this.active[ 0 ] ) ) {
  5158. // all remaining panel are disabled
  5159. if ( this.headers.length === this.headers.find(".ui-state-disabled").length ) {
  5160. options.active = false;
  5161. this.active = $();
  5162. // activate previous panel
  5163. } else {
  5164. this._activate( Math.max( 0, options.active - 1 ) );
  5165. }
  5166. // was active, active panel still exists
  5167. } else {
  5168. // make sure active index is correct
  5169. options.active = this.headers.index( this.active );
  5170. }
  5171. this._destroyIcons();
  5172. this._refresh();
  5173. },
  5174. _processPanels: function() {
  5175. this.headers = this.element.find( this.options.header )
  5176. .addClass( "ui-accordion-header ui-helper-reset ui-state-default ui-corner-all" );
  5177. this.headers.next()
  5178. .addClass( "ui-accordion-content ui-helper-reset ui-widget-content ui-corner-bottom" )
  5179. .filter(":not(.ui-accordion-content-active)")
  5180. .hide();
  5181. },
  5182. _refresh: function() {
  5183. var maxHeight,
  5184. options = this.options,
  5185. heightStyle = options.heightStyle,
  5186. parent = this.element.parent(),
  5187. accordionId = this.accordionId = "ui-accordion-" +
  5188. (this.element.attr( "id" ) || ++uid);
  5189. this.active = this._findActive( options.active )
  5190. .addClass( "ui-accordion-header-active ui-state-active ui-corner-top" )
  5191. .removeClass( "ui-corner-all" );
  5192. this.active.next()
  5193. .addClass( "ui-accordion-content-active" )
  5194. .show();
  5195. this.headers
  5196. .attr( "role", "tab" )
  5197. .each(function( i ) {
  5198. var header = $( this ),
  5199. headerId = header.attr( "id" ),
  5200. panel = header.next(),
  5201. panelId = panel.attr( "id" );
  5202. if ( !headerId ) {
  5203. headerId = accordionId + "-header-" + i;
  5204. header.attr( "id", headerId );
  5205. }
  5206. if ( !panelId ) {
  5207. panelId = accordionId + "-panel-" + i;
  5208. panel.attr( "id", panelId );
  5209. }
  5210. header.attr( "aria-controls", panelId );
  5211. panel.attr( "aria-labelledby", headerId );
  5212. })
  5213. .next()
  5214. .attr( "role", "tabpanel" );
  5215. this.headers
  5216. .not( this.active )
  5217. .attr({
  5218. "aria-selected": "false",
  5219. tabIndex: -1
  5220. })
  5221. .next()
  5222. .attr({
  5223. "aria-expanded": "false",
  5224. "aria-hidden": "true"
  5225. })
  5226. .hide();
  5227. // make sure at least one header is in the tab order
  5228. if ( !this.active.length ) {
  5229. this.headers.eq( 0 ).attr( "tabIndex", 0 );
  5230. } else {
  5231. this.active.attr({
  5232. "aria-selected": "true",
  5233. tabIndex: 0
  5234. })
  5235. .next()
  5236. .attr({
  5237. "aria-expanded": "true",
  5238. "aria-hidden": "false"
  5239. });
  5240. }
  5241. this._createIcons();
  5242. this._setupEvents( options.event );
  5243. if ( heightStyle === "fill" ) {
  5244. maxHeight = parent.height();
  5245. this.element.siblings( ":visible" ).each(function() {
  5246. var elem = $( this ),
  5247. position = elem.css( "position" );
  5248. if ( position === "absolute" || position === "fixed" ) {
  5249. return;
  5250. }
  5251. maxHeight -= elem.outerHeight( true );
  5252. });
  5253. this.headers.each(function() {
  5254. maxHeight -= $( this ).outerHeight( true );
  5255. });
  5256. this.headers.next()
  5257. .each(function() {
  5258. $( this ).height( Math.max( 0, maxHeight -
  5259. $( this ).innerHeight() + $( this ).height() ) );
  5260. })
  5261. .css( "overflow", "auto" );
  5262. } else if ( heightStyle === "auto" ) {
  5263. maxHeight = 0;
  5264. this.headers.next()
  5265. .each(function() {
  5266. maxHeight = Math.max( maxHeight, $( this ).css( "height", "" ).height() );
  5267. })
  5268. .height( maxHeight );
  5269. }
  5270. },
  5271. _activate: function( index ) {
  5272. var active = this._findActive( index )[ 0 ];
  5273. // trying to activate the already active panel
  5274. if ( active === this.active[ 0 ] ) {
  5275. return;
  5276. }
  5277. // trying to collapse, simulate a click on the currently active header
  5278. active = active || this.active[ 0 ];
  5279. this._eventHandler({
  5280. target: active,
  5281. currentTarget: active,
  5282. preventDefault: $.noop
  5283. });
  5284. },
  5285. _findActive: function( selector ) {
  5286. return typeof selector === "number" ? this.headers.eq( selector ) : $();
  5287. },
  5288. _setupEvents: function( event ) {
  5289. var events = {
  5290. keydown: "_keydown"
  5291. };
  5292. if ( event ) {
  5293. $.each( event.split(" "), function( index, eventName ) {
  5294. events[ eventName ] = "_eventHandler";
  5295. });
  5296. }
  5297. this._off( this.headers.add( this.headers.next() ) );
  5298. this._on( this.headers, events );
  5299. this._on( this.headers.next(), { keydown: "_panelKeyDown" });
  5300. this._hoverable( this.headers );
  5301. this._focusable( this.headers );
  5302. },
  5303. _eventHandler: function( event ) {
  5304. var options = this.options,
  5305. active = this.active,
  5306. clicked = $( event.currentTarget ),
  5307. clickedIsActive = clicked[ 0 ] === active[ 0 ],
  5308. collapsing = clickedIsActive && options.collapsible,
  5309. toShow = collapsing ? $() : clicked.next(),
  5310. toHide = active.next(),
  5311. eventData = {
  5312. oldHeader: active,
  5313. oldPanel: toHide,
  5314. newHeader: collapsing ? $() : clicked,
  5315. newPanel: toShow
  5316. };
  5317. event.preventDefault();
  5318. if (
  5319. // click on active header, but not collapsible
  5320. ( clickedIsActive && !options.collapsible ) ||
  5321. // allow canceling activation
  5322. ( this._trigger( "beforeActivate", event, eventData ) === false ) ) {
  5323. return;
  5324. }
  5325. options.active = collapsing ? false : this.headers.index( clicked );
  5326. // when the call to ._toggle() comes after the class changes
  5327. // it causes a very odd bug in IE 8 (see #6720)
  5328. this.active = clickedIsActive ? $() : clicked;
  5329. this._toggle( eventData );
  5330. // switch classes
  5331. // corner classes on the previously active header stay after the animation
  5332. active.removeClass( "ui-accordion-header-active ui-state-active" );
  5333. if ( options.icons ) {
  5334. active.children( ".ui-accordion-header-icon" )
  5335. .removeClass( options.icons.activeHeader )
  5336. .addClass( options.icons.header );
  5337. }
  5338. if ( !clickedIsActive ) {
  5339. clicked
  5340. .removeClass( "ui-corner-all" )
  5341. .addClass( "ui-accordion-header-active ui-state-active ui-corner-top" );
  5342. if ( options.icons ) {
  5343. clicked.children( ".ui-accordion-header-icon" )
  5344. .removeClass( options.icons.header )
  5345. .addClass( options.icons.activeHeader );
  5346. }
  5347. clicked
  5348. .next()
  5349. .addClass( "ui-accordion-content-active" );
  5350. }
  5351. },
  5352. _toggle: function( data ) {
  5353. var toShow = data.newPanel,
  5354. toHide = this.prevShow.length ? this.prevShow : data.oldPanel;
  5355. // handle activating a panel during the animation for another activation
  5356. this.prevShow.add( this.prevHide ).stop( true, true );
  5357. this.prevShow = toShow;
  5358. this.prevHide = toHide;
  5359. if ( this.options.animate ) {
  5360. this._animate( toShow, toHide, data );
  5361. } else {
  5362. toHide.hide();
  5363. toShow.show();
  5364. this._toggleComplete( data );
  5365. }
  5366. toHide.attr({
  5367. "aria-expanded": "false",
  5368. "aria-hidden": "true"
  5369. });
  5370. toHide.prev().attr( "aria-selected", "false" );
  5371. // if we're switching panels, remove the old header from the tab order
  5372. // if we're opening from collapsed state, remove the previous header from the tab order
  5373. // if we're collapsing, then keep the collapsing header in the tab order
  5374. if ( toShow.length && toHide.length ) {
  5375. toHide.prev().attr( "tabIndex", -1 );
  5376. } else if ( toShow.length ) {
  5377. this.headers.filter(function() {
  5378. return $( this ).attr( "tabIndex" ) === 0;
  5379. })
  5380. .attr( "tabIndex", -1 );
  5381. }
  5382. toShow
  5383. .attr({
  5384. "aria-expanded": "true",
  5385. "aria-hidden": "false"
  5386. })
  5387. .prev()
  5388. .attr({
  5389. "aria-selected": "true",
  5390. tabIndex: 0
  5391. });
  5392. },
  5393. _animate: function( toShow, toHide, data ) {
  5394. var total, easing, duration,
  5395. that = this,
  5396. adjust = 0,
  5397. down = toShow.length &&
  5398. ( !toHide.length || ( toShow.index() < toHide.index() ) ),
  5399. animate = this.options.animate || {},
  5400. options = down && animate.down || animate,
  5401. complete = function() {
  5402. that._toggleComplete( data );
  5403. };
  5404. if ( typeof options === "number" ) {
  5405. duration = options;
  5406. }
  5407. if ( typeof options === "string" ) {
  5408. easing = options;
  5409. }
  5410. // fall back from options to animation in case of partial down settings
  5411. easing = easing || options.easing || animate.easing;
  5412. duration = duration || options.duration || animate.duration;
  5413. if ( !toHide.length ) {
  5414. return toShow.animate( showProps, duration, easing, complete );
  5415. }
  5416. if ( !toShow.length ) {
  5417. return toHide.animate( hideProps, duration, easing, complete );
  5418. }
  5419. total = toShow.show().outerHeight();
  5420. toHide.animate( hideProps, {
  5421. duration: duration,
  5422. easing: easing,
  5423. step: function( now, fx ) {
  5424. fx.now = Math.round( now );
  5425. }
  5426. });
  5427. toShow
  5428. .hide()
  5429. .animate( showProps, {
  5430. duration: duration,
  5431. easing: easing,
  5432. complete: complete,
  5433. step: function( now, fx ) {
  5434. fx.now = Math.round( now );
  5435. if ( fx.prop !== "height" ) {
  5436. adjust += fx.now;
  5437. } else if ( that.options.heightStyle !== "content" ) {
  5438. fx.now = Math.round( total - toHide.outerHeight() - adjust );
  5439. adjust = 0;
  5440. }
  5441. }
  5442. });
  5443. },
  5444. _toggleComplete: function( data ) {
  5445. var toHide = data.oldPanel;
  5446. toHide
  5447. .removeClass( "ui-accordion-content-active" )
  5448. .prev()
  5449. .removeClass( "ui-corner-top" )
  5450. .addClass( "ui-corner-all" );
  5451. // Work around for rendering bug in IE (#5421)
  5452. if ( toHide.length ) {
  5453. toHide.parent()[0].className = toHide.parent()[0].className;
  5454. }
  5455. this._trigger( "activate", null, data );
  5456. }
  5457. });
  5458. })( jQuery );
  5459. (function( $, undefined ) {
  5460. // used to prevent race conditions with remote data sources
  5461. var requestIndex = 0;
  5462. $.widget( "ui.autocomplete", {
  5463. version: "1.10.1",
  5464. defaultElement: "<input>",
  5465. options: {
  5466. appendTo: null,
  5467. autoFocus: false,
  5468. delay: 300,
  5469. minLength: 1,
  5470. position: {
  5471. my: "left top",
  5472. at: "left bottom",
  5473. collision: "none"
  5474. },
  5475. source: null,
  5476. // callbacks
  5477. change: null,
  5478. close: null,
  5479. focus: null,
  5480. open: null,
  5481. response: null,
  5482. search: null,
  5483. select: null
  5484. },
  5485. pending: 0,
  5486. _create: function() {
  5487. // Some browsers only repeat keydown events, not keypress events,
  5488. // so we use the suppressKeyPress flag to determine if we've already
  5489. // handled the keydown event. #7269
  5490. // Unfortunately the code for & in keypress is the same as the up arrow,
  5491. // so we use the suppressKeyPressRepeat flag to avoid handling keypress
  5492. // events when we know the keydown event was used to modify the
  5493. // search term. #7799
  5494. var suppressKeyPress, suppressKeyPressRepeat, suppressInput,
  5495. nodeName = this.element[0].nodeName.toLowerCase(),
  5496. isTextarea = nodeName === "textarea",
  5497. isInput = nodeName === "input";
  5498. this.isMultiLine =
  5499. // Textareas are always multi-line
  5500. isTextarea ? true :
  5501. // Inputs are always single-line, even if inside a contentEditable element
  5502. // IE also treats inputs as contentEditable
  5503. isInput ? false :
  5504. // All other element types are determined by whether or not they're contentEditable
  5505. this.element.prop( "isContentEditable" );
  5506. this.valueMethod = this.element[ isTextarea || isInput ? "val" : "text" ];
  5507. this.isNewMenu = true;
  5508. this.element
  5509. .addClass( "ui-autocomplete-input" )
  5510. .attr( "autocomplete", "off" );
  5511. this._on( this.element, {
  5512. keydown: function( event ) {
  5513. /*jshint maxcomplexity:15*/
  5514. if ( this.element.prop( "readOnly" ) ) {
  5515. suppressKeyPress = true;
  5516. suppressInput = true;
  5517. suppressKeyPressRepeat = true;
  5518. return;
  5519. }
  5520. suppressKeyPress = false;
  5521. suppressInput = false;
  5522. suppressKeyPressRepeat = false;
  5523. var keyCode = $.ui.keyCode;
  5524. switch( event.keyCode ) {
  5525. case keyCode.PAGE_UP:
  5526. suppressKeyPress = true;
  5527. this._move( "previousPage", event );
  5528. break;
  5529. case keyCode.PAGE_DOWN:
  5530. suppressKeyPress = true;
  5531. this._move( "nextPage", event );
  5532. break;
  5533. case keyCode.UP:
  5534. suppressKeyPress = true;
  5535. this._keyEvent( "previous", event );
  5536. break;
  5537. case keyCode.DOWN:
  5538. suppressKeyPress = true;
  5539. this._keyEvent( "next", event );
  5540. break;
  5541. case keyCode.ENTER:
  5542. case keyCode.NUMPAD_ENTER:
  5543. // when menu is open and has focus
  5544. if ( this.menu.active ) {
  5545. // #6055 - Opera still allows the keypress to occur
  5546. // which causes forms to submit
  5547. suppressKeyPress = true;
  5548. event.preventDefault();
  5549. this.menu.select( event );
  5550. }
  5551. break;
  5552. case keyCode.TAB:
  5553. if ( this.menu.active ) {
  5554. this.menu.select( event );
  5555. }
  5556. break;
  5557. case keyCode.ESCAPE:
  5558. if ( this.menu.element.is( ":visible" ) ) {
  5559. this._value( this.term );
  5560. this.close( event );
  5561. // Different browsers have different default behavior for escape
  5562. // Single press can mean undo or clear
  5563. // Double press in IE means clear the whole form
  5564. event.preventDefault();
  5565. }
  5566. break;
  5567. default:
  5568. suppressKeyPressRepeat = true;
  5569. // search timeout should be triggered before the input value is changed
  5570. this._searchTimeout( event );
  5571. break;
  5572. }
  5573. },
  5574. keypress: function( event ) {
  5575. if ( suppressKeyPress ) {
  5576. suppressKeyPress = false;
  5577. event.preventDefault();
  5578. return;
  5579. }
  5580. if ( suppressKeyPressRepeat ) {
  5581. return;
  5582. }
  5583. // replicate some key handlers to allow them to repeat in Firefox and Opera
  5584. var keyCode = $.ui.keyCode;
  5585. switch( event.keyCode ) {
  5586. case keyCode.PAGE_UP:
  5587. this._move( "previousPage", event );
  5588. break;
  5589. case keyCode.PAGE_DOWN:
  5590. this._move( "nextPage", event );
  5591. break;
  5592. case keyCode.UP:
  5593. this._keyEvent( "previous", event );
  5594. break;
  5595. case keyCode.DOWN:
  5596. this._keyEvent( "next", event );
  5597. break;
  5598. }
  5599. },
  5600. input: function( event ) {
  5601. if ( suppressInput ) {
  5602. suppressInput = false;
  5603. event.preventDefault();
  5604. return;
  5605. }
  5606. this._searchTimeout( event );
  5607. },
  5608. focus: function() {
  5609. this.selectedItem = null;
  5610. this.previous = this._value();
  5611. },
  5612. blur: function( event ) {
  5613. if ( this.cancelBlur ) {
  5614. delete this.cancelBlur;
  5615. return;
  5616. }
  5617. clearTimeout( this.searching );
  5618. this.close( event );
  5619. this._change( event );
  5620. }
  5621. });
  5622. this._initSource();
  5623. this.menu = $( "<ul>" )
  5624. .addClass( "ui-autocomplete ui-front" )
  5625. .appendTo( this._appendTo() )
  5626. .menu({
  5627. // custom key handling for now
  5628. input: $(),
  5629. // disable ARIA support, the live region takes care of that
  5630. role: null
  5631. })
  5632. .hide()
  5633. .data( "ui-menu" );
  5634. this._on( this.menu.element, {
  5635. mousedown: function( event ) {
  5636. // prevent moving focus out of the text field
  5637. event.preventDefault();
  5638. // IE doesn't prevent moving focus even with event.preventDefault()
  5639. // so we set a flag to know when we should ignore the blur event
  5640. this.cancelBlur = true;
  5641. this._delay(function() {
  5642. delete this.cancelBlur;
  5643. });
  5644. // clicking on the scrollbar causes focus to shift to the body
  5645. // but we can't detect a mouseup or a click immediately afterward
  5646. // so we have to track the next mousedown and close the menu if
  5647. // the user clicks somewhere outside of the autocomplete
  5648. var menuElement = this.menu.element[ 0 ];
  5649. if ( !$( event.target ).closest( ".ui-menu-item" ).length ) {
  5650. this._delay(function() {
  5651. var that = this;
  5652. this.document.one( "mousedown", function( event ) {
  5653. if ( event.target !== that.element[ 0 ] &&
  5654. event.target !== menuElement &&
  5655. !$.contains( menuElement, event.target ) ) {
  5656. that.close();
  5657. }
  5658. });
  5659. });
  5660. }
  5661. },
  5662. menufocus: function( event, ui ) {
  5663. // #7024 - Prevent accidental activation of menu items in Firefox
  5664. if ( this.isNewMenu ) {
  5665. this.isNewMenu = false;
  5666. if ( event.originalEvent && /^mouse/.test( event.originalEvent.type ) ) {
  5667. this.menu.blur();
  5668. this.document.one( "mousemove", function() {
  5669. $( event.target ).trigger( event.originalEvent );
  5670. });
  5671. return;
  5672. }
  5673. }
  5674. var item = ui.item.data( "ui-autocomplete-item" );
  5675. if ( false !== this._trigger( "focus", event, { item: item } ) ) {
  5676. // use value to match what will end up in the input, if it was a key event
  5677. if ( event.originalEvent && /^key/.test( event.originalEvent.type ) ) {
  5678. this._value( item.value );
  5679. }
  5680. } else {
  5681. // Normally the input is populated with the item's value as the
  5682. // menu is navigated, causing screen readers to notice a change and
  5683. // announce the item. Since the focus event was canceled, this doesn't
  5684. // happen, so we update the live region so that screen readers can
  5685. // still notice the change and announce it.
  5686. this.liveRegion.text( item.value );
  5687. }
  5688. },
  5689. menuselect: function( event, ui ) {
  5690. var item = ui.item.data( "ui-autocomplete-item" ),
  5691. previous = this.previous;
  5692. // only trigger when focus was lost (click on menu)
  5693. if ( this.element[0] !== this.document[0].activeElement ) {
  5694. this.element.focus();
  5695. this.previous = previous;
  5696. // #6109 - IE triggers two focus events and the second
  5697. // is asynchronous, so we need to reset the previous
  5698. // term synchronously and asynchronously :-(
  5699. this._delay(function() {
  5700. this.previous = previous;
  5701. this.selectedItem = item;
  5702. });
  5703. }
  5704. if ( false !== this._trigger( "select", event, { item: item } ) ) {
  5705. this._value( item.value );
  5706. }
  5707. // reset the term after the select event
  5708. // this allows custom select handling to work properly
  5709. this.term = this._value();
  5710. this.close( event );
  5711. this.selectedItem = item;
  5712. }
  5713. });
  5714. this.liveRegion = $( "<span>", {
  5715. role: "status",
  5716. "aria-live": "polite"
  5717. })
  5718. .addClass( "ui-helper-hidden-accessible" )
  5719. .insertAfter( this.element );
  5720. // turning off autocomplete prevents the browser from remembering the
  5721. // value when navigating through history, so we re-enable autocomplete
  5722. // if the page is unloaded before the widget is destroyed. #7790
  5723. this._on( this.window, {
  5724. beforeunload: function() {
  5725. this.element.removeAttr( "autocomplete" );
  5726. }
  5727. });
  5728. },
  5729. _destroy: function() {
  5730. clearTimeout( this.searching );
  5731. this.element
  5732. .removeClass( "ui-autocomplete-input" )
  5733. .removeAttr( "autocomplete" );
  5734. this.menu.element.remove();
  5735. this.liveRegion.remove();
  5736. },
  5737. _setOption: function( key, value ) {
  5738. this._super( key, value );
  5739. if ( key === "source" ) {
  5740. this._initSource();
  5741. }
  5742. if ( key === "appendTo" ) {
  5743. this.menu.element.appendTo( this._appendTo() );
  5744. }
  5745. if ( key === "disabled" && value && this.xhr ) {
  5746. this.xhr.abort();
  5747. }
  5748. },
  5749. _appendTo: function() {
  5750. var element = this.options.appendTo;
  5751. if ( element ) {
  5752. element = element.jquery || element.nodeType ?
  5753. $( element ) :
  5754. this.document.find( element ).eq( 0 );
  5755. }
  5756. if ( !element ) {
  5757. element = this.element.closest( ".ui-front" );
  5758. }
  5759. if ( !element.length ) {
  5760. element = this.document[0].body;
  5761. }
  5762. return element;
  5763. },
  5764. _initSource: function() {
  5765. var array, url,
  5766. that = this;
  5767. if ( $.isArray(this.options.source) ) {
  5768. array = this.options.source;
  5769. this.source = function( request, response ) {
  5770. response( $.ui.autocomplete.filter( array, request.term ) );
  5771. };
  5772. } else if ( typeof this.options.source === "string" ) {
  5773. url = this.options.source;
  5774. this.source = function( request, response ) {
  5775. if ( that.xhr ) {
  5776. that.xhr.abort();
  5777. }
  5778. that.xhr = $.ajax({
  5779. url: url,
  5780. data: request,
  5781. dataType: "json",
  5782. success: function( data ) {
  5783. response( data );
  5784. },
  5785. error: function() {
  5786. response( [] );
  5787. }
  5788. });
  5789. };
  5790. } else {
  5791. this.source = this.options.source;
  5792. }
  5793. },
  5794. _searchTimeout: function( event ) {
  5795. clearTimeout( this.searching );
  5796. this.searching = this._delay(function() {
  5797. // only search if the value has changed
  5798. if ( this.term !== this._value() ) {
  5799. this.selectedItem = null;
  5800. this.search( null, event );
  5801. }
  5802. }, this.options.delay );
  5803. },
  5804. search: function( value, event ) {
  5805. value = value != null ? value : this._value();
  5806. // always save the actual value, not the one passed as an argument
  5807. this.term = this._value();
  5808. if ( value.length < this.options.minLength ) {
  5809. return this.close( event );
  5810. }
  5811. if ( this._trigger( "search", event ) === false ) {
  5812. return;
  5813. }
  5814. return this._search( value );
  5815. },
  5816. _search: function( value ) {
  5817. this.pending++;
  5818. this.element.addClass( "ui-autocomplete-loading" );
  5819. this.cancelSearch = false;
  5820. this.source( { term: value }, this._response() );
  5821. },
  5822. _response: function() {
  5823. var that = this,
  5824. index = ++requestIndex;
  5825. return function( content ) {
  5826. if ( index === requestIndex ) {
  5827. that.__response( content );
  5828. }
  5829. that.pending--;
  5830. if ( !that.pending ) {
  5831. that.element.removeClass( "ui-autocomplete-loading" );
  5832. }
  5833. };
  5834. },
  5835. __response: function( content ) {
  5836. if ( content ) {
  5837. content = this._normalize( content );
  5838. }
  5839. this._trigger( "response", null, { content: content } );
  5840. if ( !this.options.disabled && content && content.length && !this.cancelSearch ) {
  5841. this._suggest( content );
  5842. this._trigger( "open" );
  5843. } else {
  5844. // use ._close() instead of .close() so we don't cancel future searches
  5845. this._close();
  5846. }
  5847. },
  5848. close: function( event ) {
  5849. this.cancelSearch = true;
  5850. this._close( event );
  5851. },
  5852. _close: function( event ) {
  5853. if ( this.menu.element.is( ":visible" ) ) {
  5854. this.menu.element.hide();
  5855. this.menu.blur();
  5856. this.isNewMenu = true;
  5857. this._trigger( "close", event );
  5858. }
  5859. },
  5860. _change: function( event ) {
  5861. if ( this.previous !== this._value() ) {
  5862. this._trigger( "change", event, { item: this.selectedItem } );
  5863. }
  5864. },
  5865. _normalize: function( items ) {
  5866. // assume all items have the right format when the first item is complete
  5867. if ( items.length && items[0].label && items[0].value ) {
  5868. return items;
  5869. }
  5870. return $.map( items, function( item ) {
  5871. if ( typeof item === "string" ) {
  5872. return {
  5873. label: item,
  5874. value: item
  5875. };
  5876. }
  5877. return $.extend({
  5878. label: item.label || item.value,
  5879. value: item.value || item.label
  5880. }, item );
  5881. });
  5882. },
  5883. _suggest: function( items ) {
  5884. var ul = this.menu.element.empty();
  5885. this._renderMenu( ul, items );
  5886. this.menu.refresh();
  5887. // size and position menu
  5888. ul.show();
  5889. this._resizeMenu();
  5890. ul.position( $.extend({
  5891. of: this.element
  5892. }, this.options.position ));
  5893. if ( this.options.autoFocus ) {
  5894. this.menu.next();
  5895. }
  5896. },
  5897. _resizeMenu: function() {
  5898. var ul = this.menu.element;
  5899. ul.outerWidth( Math.max(
  5900. // Firefox wraps long text (possibly a rounding bug)
  5901. // so we add 1px to avoid the wrapping (#7513)
  5902. ul.width( "" ).outerWidth() + 1,
  5903. this.element.outerWidth()
  5904. ) );
  5905. },
  5906. _renderMenu: function( ul, items ) {
  5907. var that = this;
  5908. $.each( items, function( index, item ) {
  5909. that._renderItemData( ul, item );
  5910. });
  5911. },
  5912. _renderItemData: function( ul, item ) {
  5913. return this._renderItem( ul, item ).data( "ui-autocomplete-item", item );
  5914. },
  5915. _renderItem: function( ul, item ) {
  5916. return $( "<li>" )
  5917. .append( $( "<a>" ).text( item.label ) )
  5918. .appendTo( ul );
  5919. },
  5920. _move: function( direction, event ) {
  5921. if ( !this.menu.element.is( ":visible" ) ) {
  5922. this.search( null, event );
  5923. return;
  5924. }
  5925. if ( this.menu.isFirstItem() && /^previous/.test( direction ) ||
  5926. this.menu.isLastItem() && /^next/.test( direction ) ) {
  5927. this._value( this.term );
  5928. this.menu.blur();
  5929. return;
  5930. }
  5931. this.menu[ direction ]( event );
  5932. },
  5933. widget: function() {
  5934. return this.menu.element;
  5935. },
  5936. _value: function() {
  5937. return this.valueMethod.apply( this.element, arguments );
  5938. },
  5939. _keyEvent: function( keyEvent, event ) {
  5940. if ( !this.isMultiLine || this.menu.element.is( ":visible" ) ) {
  5941. this._move( keyEvent, event );
  5942. // prevents moving cursor to beginning/end of the text field in some browsers
  5943. event.preventDefault();
  5944. }
  5945. }
  5946. });
  5947. $.extend( $.ui.autocomplete, {
  5948. escapeRegex: function( value ) {
  5949. return value.replace(/[\-\[\]{}()*+?.,\\\^$|#\s]/g, "\\$&");
  5950. },
  5951. filter: function(array, term) {
  5952. var matcher = new RegExp( $.ui.autocomplete.escapeRegex(term), "i" );
  5953. return $.grep( array, function(value) {
  5954. return matcher.test( value.label || value.value || value );
  5955. });
  5956. }
  5957. });
  5958. // live region extension, adding a `messages` option
  5959. // NOTE: This is an experimental API. We are still investigating
  5960. // a full solution for string manipulation and internationalization.
  5961. $.widget( "ui.autocomplete", $.ui.autocomplete, {
  5962. options: {
  5963. messages: {
  5964. noResults: "No search results.",
  5965. results: function( amount ) {
  5966. return amount + ( amount > 1 ? " results are" : " result is" ) +
  5967. " available, use up and down arrow keys to navigate.";
  5968. }
  5969. }
  5970. },
  5971. __response: function( content ) {
  5972. var message;
  5973. this._superApply( arguments );
  5974. if ( this.options.disabled || this.cancelSearch ) {
  5975. return;
  5976. }
  5977. if ( content && content.length ) {
  5978. message = this.options.messages.results( content.length );
  5979. } else {
  5980. message = this.options.messages.noResults;
  5981. }
  5982. this.liveRegion.text( message );
  5983. }
  5984. });
  5985. }( jQuery ));
  5986. (function( $, undefined ) {
  5987. var lastActive, startXPos, startYPos, clickDragged,
  5988. baseClasses = "ui-button ui-widget ui-state-default ui-corner-all",
  5989. stateClasses = "ui-state-hover ui-state-active ",
  5990. 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",
  5991. formResetHandler = function() {
  5992. var buttons = $( this ).find( ":ui-button" );
  5993. setTimeout(function() {
  5994. buttons.button( "refresh" );
  5995. }, 1 );
  5996. },
  5997. radioGroup = function( radio ) {
  5998. var name = radio.name,
  5999. form = radio.form,
  6000. radios = $( [] );
  6001. if ( name ) {
  6002. name = name.replace( /'/g, "\\'" );
  6003. if ( form ) {
  6004. radios = $( form ).find( "[name='" + name + "']" );
  6005. } else {
  6006. radios = $( "[name='" + name + "']", radio.ownerDocument )
  6007. .filter(function() {
  6008. return !this.form;
  6009. });
  6010. }
  6011. }
  6012. return radios;
  6013. };
  6014. $.widget( "ui.button", {
  6015. version: "1.10.1",
  6016. defaultElement: "<button>",
  6017. options: {
  6018. disabled: null,
  6019. text: true,
  6020. label: null,
  6021. icons: {
  6022. primary: null,
  6023. secondary: null
  6024. }
  6025. },
  6026. _create: function() {
  6027. this.element.closest( "form" )
  6028. .unbind( "reset" + this.eventNamespace )
  6029. .bind( "reset" + this.eventNamespace, formResetHandler );
  6030. if ( typeof this.options.disabled !== "boolean" ) {
  6031. this.options.disabled = !!this.element.prop( "disabled" );
  6032. } else {
  6033. this.element.prop( "disabled", this.options.disabled );
  6034. }
  6035. this._determineButtonType();
  6036. this.hasTitle = !!this.buttonElement.attr( "title" );
  6037. var that = this,
  6038. options = this.options,
  6039. toggleButton = this.type === "checkbox" || this.type === "radio",
  6040. activeClass = !toggleButton ? "ui-state-active" : "",
  6041. focusClass = "ui-state-focus";
  6042. if ( options.label === null ) {
  6043. options.label = (this.type === "input" ? this.buttonElement.val() : this.buttonElement.html());
  6044. }
  6045. this._hoverable( this.buttonElement );
  6046. this.buttonElement
  6047. .addClass( baseClasses )
  6048. .attr( "role", "button" )
  6049. .bind( "mouseenter" + this.eventNamespace, function() {
  6050. if ( options.disabled ) {
  6051. return;
  6052. }
  6053. if ( this === lastActive ) {
  6054. $( this ).addClass( "ui-state-active" );
  6055. }
  6056. })
  6057. .bind( "mouseleave" + this.eventNamespace, function() {
  6058. if ( options.disabled ) {
  6059. return;
  6060. }
  6061. $( this ).removeClass( activeClass );
  6062. })
  6063. .bind( "click" + this.eventNamespace, function( event ) {
  6064. if ( options.disabled ) {
  6065. event.preventDefault();
  6066. event.stopImmediatePropagation();
  6067. }
  6068. });
  6069. this.element
  6070. .bind( "focus" + this.eventNamespace, function() {
  6071. // no need to check disabled, focus won't be triggered anyway
  6072. that.buttonElement.addClass( focusClass );
  6073. })
  6074. .bind( "blur" + this.eventNamespace, function() {
  6075. that.buttonElement.removeClass( focusClass );
  6076. });
  6077. if ( toggleButton ) {
  6078. this.element.bind( "change" + this.eventNamespace, function() {
  6079. if ( clickDragged ) {
  6080. return;
  6081. }
  6082. that.refresh();
  6083. });
  6084. // if mouse moves between mousedown and mouseup (drag) set clickDragged flag
  6085. // prevents issue where button state changes but checkbox/radio checked state
  6086. // does not in Firefox (see ticket #6970)
  6087. this.buttonElement
  6088. .bind( "mousedown" + this.eventNamespace, function( event ) {
  6089. if ( options.disabled ) {
  6090. return;
  6091. }
  6092. clickDragged = false;
  6093. startXPos = event.pageX;
  6094. startYPos = event.pageY;
  6095. })
  6096. .bind( "mouseup" + this.eventNamespace, function( event ) {
  6097. if ( options.disabled ) {
  6098. return;
  6099. }
  6100. if ( startXPos !== event.pageX || startYPos !== event.pageY ) {
  6101. clickDragged = true;
  6102. }
  6103. });
  6104. }
  6105. if ( this.type === "checkbox" ) {
  6106. this.buttonElement.bind( "click" + this.eventNamespace, function() {
  6107. if ( options.disabled || clickDragged ) {
  6108. return false;
  6109. }
  6110. });
  6111. } else if ( this.type === "radio" ) {
  6112. this.buttonElement.bind( "click" + this.eventNamespace, function() {
  6113. if ( options.disabled || clickDragged ) {
  6114. return false;
  6115. }
  6116. $( this ).addClass( "ui-state-active" );
  6117. that.buttonElement.attr( "aria-pressed", "true" );
  6118. var radio = that.element[ 0 ];
  6119. radioGroup( radio )
  6120. .not( radio )
  6121. .map(function() {
  6122. return $( this ).button( "widget" )[ 0 ];
  6123. })
  6124. .removeClass( "ui-state-active" )
  6125. .attr( "aria-pressed", "false" );
  6126. });
  6127. } else {
  6128. this.buttonElement
  6129. .bind( "mousedown" + this.eventNamespace, function() {
  6130. if ( options.disabled ) {
  6131. return false;
  6132. }
  6133. $( this ).addClass( "ui-state-active" );
  6134. lastActive = this;
  6135. that.document.one( "mouseup", function() {
  6136. lastActive = null;
  6137. });
  6138. })
  6139. .bind( "mouseup" + this.eventNamespace, function() {
  6140. if ( options.disabled ) {
  6141. return false;
  6142. }
  6143. $( this ).removeClass( "ui-state-active" );
  6144. })
  6145. .bind( "keydown" + this.eventNamespace, function(event) {
  6146. if ( options.disabled ) {
  6147. return false;
  6148. }
  6149. if ( event.keyCode === $.ui.keyCode.SPACE || event.keyCode === $.ui.keyCode.ENTER ) {
  6150. $( this ).addClass( "ui-state-active" );
  6151. }
  6152. })
  6153. // see #8559, we bind to blur here in case the button element loses
  6154. // focus between keydown and keyup, it would be left in an "active" state
  6155. .bind( "keyup" + this.eventNamespace + " blur" + this.eventNamespace, function() {
  6156. $( this ).removeClass( "ui-state-active" );
  6157. });
  6158. if ( this.buttonElement.is("a") ) {
  6159. this.buttonElement.keyup(function(event) {
  6160. if ( event.keyCode === $.ui.keyCode.SPACE ) {
  6161. // TODO pass through original event correctly (just as 2nd argument doesn't work)
  6162. $( this ).click();
  6163. }
  6164. });
  6165. }
  6166. }
  6167. // TODO: pull out $.Widget's handling for the disabled option into
  6168. // $.Widget.prototype._setOptionDisabled so it's easy to proxy and can
  6169. // be overridden by individual plugins
  6170. this._setOption( "disabled", options.disabled );
  6171. this._resetButton();
  6172. },
  6173. _determineButtonType: function() {
  6174. var ancestor, labelSelector, checked;
  6175. if ( this.element.is("[type=checkbox]") ) {
  6176. this.type = "checkbox";
  6177. } else if ( this.element.is("[type=radio]") ) {
  6178. this.type = "radio";
  6179. } else if ( this.element.is("input") ) {
  6180. this.type = "input";
  6181. } else {
  6182. this.type = "button";
  6183. }
  6184. if ( this.type === "checkbox" || this.type === "radio" ) {
  6185. // we don't search against the document in case the element
  6186. // is disconnected from the DOM
  6187. ancestor = this.element.parents().last();
  6188. labelSelector = "label[for='" + this.element.attr("id") + "']";
  6189. this.buttonElement = ancestor.find( labelSelector );
  6190. if ( !this.buttonElement.length ) {
  6191. ancestor = ancestor.length ? ancestor.siblings() : this.element.siblings();
  6192. this.buttonElement = ancestor.filter( labelSelector );
  6193. if ( !this.buttonElement.length ) {
  6194. this.buttonElement = ancestor.find( labelSelector );
  6195. }
  6196. }
  6197. this.element.addClass( "ui-helper-hidden-accessible" );
  6198. checked = this.element.is( ":checked" );
  6199. if ( checked ) {
  6200. this.buttonElement.addClass( "ui-state-active" );
  6201. }
  6202. this.buttonElement.prop( "aria-pressed", checked );
  6203. } else {
  6204. this.buttonElement = this.element;
  6205. }
  6206. },
  6207. widget: function() {
  6208. return this.buttonElement;
  6209. },
  6210. _destroy: function() {
  6211. this.element
  6212. .removeClass( "ui-helper-hidden-accessible" );
  6213. this.buttonElement
  6214. .removeClass( baseClasses + " " + stateClasses + " " + typeClasses )
  6215. .removeAttr( "role" )
  6216. .removeAttr( "aria-pressed" )
  6217. .html( this.buttonElement.find(".ui-button-text").html() );
  6218. if ( !this.hasTitle ) {
  6219. this.buttonElement.removeAttr( "title" );
  6220. }
  6221. },
  6222. _setOption: function( key, value ) {
  6223. this._super( key, value );
  6224. if ( key === "disabled" ) {
  6225. if ( value ) {
  6226. this.element.prop( "disabled", true );
  6227. } else {
  6228. this.element.prop( "disabled", false );
  6229. }
  6230. return;
  6231. }
  6232. this._resetButton();
  6233. },
  6234. refresh: function() {
  6235. //See #8237 & #8828
  6236. var isDisabled = this.element.is( "input, button" ) ? this.element.is( ":disabled" ) : this.element.hasClass( "ui-button-disabled" );
  6237. if ( isDisabled !== this.options.disabled ) {
  6238. this._setOption( "disabled", isDisabled );
  6239. }
  6240. if ( this.type === "radio" ) {
  6241. radioGroup( this.element[0] ).each(function() {
  6242. if ( $( this ).is( ":checked" ) ) {
  6243. $( this ).button( "widget" )
  6244. .addClass( "ui-state-active" )
  6245. .attr( "aria-pressed", "true" );
  6246. } else {
  6247. $( this ).button( "widget" )
  6248. .removeClass( "ui-state-active" )
  6249. .attr( "aria-pressed", "false" );
  6250. }
  6251. });
  6252. } else if ( this.type === "checkbox" ) {
  6253. if ( this.element.is( ":checked" ) ) {
  6254. this.buttonElement
  6255. .addClass( "ui-state-active" )
  6256. .attr( "aria-pressed", "true" );
  6257. } else {
  6258. this.buttonElement
  6259. .removeClass( "ui-state-active" )
  6260. .attr( "aria-pressed", "false" );
  6261. }
  6262. }
  6263. },
  6264. _resetButton: function() {
  6265. if ( this.type === "input" ) {
  6266. if ( this.options.label ) {
  6267. this.element.val( this.options.label );
  6268. }
  6269. return;
  6270. }
  6271. var buttonElement = this.buttonElement.removeClass( typeClasses ),
  6272. buttonText = $( "<span></span>", this.document[0] )
  6273. .addClass( "ui-button-text" )
  6274. .html( this.options.label )
  6275. .appendTo( buttonElement.empty() )
  6276. .text(),
  6277. icons = this.options.icons,
  6278. multipleIcons = icons.primary && icons.secondary,
  6279. buttonClasses = [];
  6280. if ( icons.primary || icons.secondary ) {
  6281. if ( this.options.text ) {
  6282. buttonClasses.push( "ui-button-text-icon" + ( multipleIcons ? "s" : ( icons.primary ? "-primary" : "-secondary" ) ) );
  6283. }
  6284. if ( icons.primary ) {
  6285. buttonElement.prepend( "<span class='ui-button-icon-primary ui-icon " + icons.primary + "'></span>" );
  6286. }
  6287. if ( icons.secondary ) {
  6288. buttonElement.append( "<span class='ui-button-icon-secondary ui-icon " + icons.secondary + "'></span>" );
  6289. }
  6290. if ( !this.options.text ) {
  6291. buttonClasses.push( multipleIcons ? "ui-button-icons-only" : "ui-button-icon-only" );
  6292. if ( !this.hasTitle ) {
  6293. buttonElement.attr( "title", $.trim( buttonText ) );
  6294. }
  6295. }
  6296. } else {
  6297. buttonClasses.push( "ui-button-text-only" );
  6298. }
  6299. buttonElement.addClass( buttonClasses.join( " " ) );
  6300. }
  6301. });
  6302. $.widget( "ui.buttonset", {
  6303. version: "1.10.1",
  6304. options: {
  6305. items: "button, input[type=button], input[type=submit], input[type=reset], input[type=checkbox], input[type=radio], a, :data(ui-button)"
  6306. },
  6307. _create: function() {
  6308. this.element.addClass( "ui-buttonset" );
  6309. },
  6310. _init: function() {
  6311. this.refresh();
  6312. },
  6313. _setOption: function( key, value ) {
  6314. if ( key === "disabled" ) {
  6315. this.buttons.button( "option", key, value );
  6316. }
  6317. this._super( key, value );
  6318. },
  6319. refresh: function() {
  6320. var rtl = this.element.css( "direction" ) === "rtl";
  6321. this.buttons = this.element.find( this.options.items )
  6322. .filter( ":ui-button" )
  6323. .button( "refresh" )
  6324. .end()
  6325. .not( ":ui-button" )
  6326. .button()
  6327. .end()
  6328. .map(function() {
  6329. return $( this ).button( "widget" )[ 0 ];
  6330. })
  6331. .removeClass( "ui-corner-all ui-corner-left ui-corner-right" )
  6332. .filter( ":first" )
  6333. .addClass( rtl ? "ui-corner-right" : "ui-corner-left" )
  6334. .end()
  6335. .filter( ":last" )
  6336. .addClass( rtl ? "ui-corner-left" : "ui-corner-right" )
  6337. .end()
  6338. .end();
  6339. },
  6340. _destroy: function() {
  6341. this.element.removeClass( "ui-buttonset" );
  6342. this.buttons
  6343. .map(function() {
  6344. return $( this ).button( "widget" )[ 0 ];
  6345. })
  6346. .removeClass( "ui-corner-left ui-corner-right" )
  6347. .end()
  6348. .button( "destroy" );
  6349. }
  6350. });
  6351. }( jQuery ) );
  6352. (function( $, undefined ) {
  6353. $.extend($.ui, { datepicker: { version: "1.10.1" } });
  6354. var PROP_NAME = "datepicker",
  6355. dpuuid = new Date().getTime(),
  6356. instActive;
  6357. /* Date picker manager.
  6358. Use the singleton instance of this class, $.datepicker, to interact with the date picker.
  6359. Settings for (groups of) date pickers are maintained in an instance object,
  6360. allowing multiple different settings on the same page. */
  6361. function Datepicker() {
  6362. this._curInst = null; // The current instance in use
  6363. this._keyEvent = false; // If the last event was a key event
  6364. this._disabledInputs = []; // List of date picker inputs that have been disabled
  6365. this._datepickerShowing = false; // True if the popup picker is showing , false if not
  6366. this._inDialog = false; // True if showing within a "dialog", false if not
  6367. this._mainDivId = "ui-datepicker-div"; // The ID of the main datepicker division
  6368. this._inlineClass = "ui-datepicker-inline"; // The name of the inline marker class
  6369. this._appendClass = "ui-datepicker-append"; // The name of the append marker class
  6370. this._triggerClass = "ui-datepicker-trigger"; // The name of the trigger marker class
  6371. this._dialogClass = "ui-datepicker-dialog"; // The name of the dialog marker class
  6372. this._disableClass = "ui-datepicker-disabled"; // The name of the disabled covering marker class
  6373. this._unselectableClass = "ui-datepicker-unselectable"; // The name of the unselectable cell marker class
  6374. this._currentClass = "ui-datepicker-current-day"; // The name of the current day marker class
  6375. this._dayOverClass = "ui-datepicker-days-cell-over"; // The name of the day hover marker class
  6376. this.regional = []; // Available regional settings, indexed by language code
  6377. this.regional[""] = { // Default regional settings
  6378. closeText: "Done", // Display text for close link
  6379. prevText: "Prev", // Display text for previous month link
  6380. nextText: "Next", // Display text for next month link
  6381. currentText: "Today", // Display text for current month link
  6382. monthNames: ["January","February","March","April","May","June",
  6383. "July","August","September","October","November","December"], // Names of months for drop-down and formatting
  6384. monthNamesShort: ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"], // For formatting
  6385. dayNames: ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"], // For formatting
  6386. dayNamesShort: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"], // For formatting
  6387. dayNamesMin: ["Su","Mo","Tu","We","Th","Fr","Sa"], // Column headings for days starting at Sunday
  6388. weekHeader: "Wk", // Column header for week of the year
  6389. dateFormat: "mm/dd/yy", // See format options on parseDate
  6390. firstDay: 0, // The first day of the week, Sun = 0, Mon = 1, ...
  6391. isRTL: false, // True if right-to-left language, false if left-to-right
  6392. showMonthAfterYear: false, // True if the year select precedes month, false for month then year
  6393. yearSuffix: "" // Additional text to append to the year in the month headers
  6394. };
  6395. this._defaults = { // Global defaults for all the date picker instances
  6396. showOn: "focus", // "focus" for popup on focus,
  6397. // "button" for trigger button, or "both" for either
  6398. showAnim: "fadeIn", // Name of jQuery animation for popup
  6399. showOptions: {}, // Options for enhanced animations
  6400. defaultDate: null, // Used when field is blank: actual date,
  6401. // +/-number for offset from today, null for today
  6402. appendText: "", // Display text following the input box, e.g. showing the format
  6403. buttonText: "...", // Text for trigger button
  6404. buttonImage: "", // URL for trigger button image
  6405. buttonImageOnly: false, // True if the image appears alone, false if it appears on a button
  6406. hideIfNoPrevNext: false, // True to hide next/previous month links
  6407. // if not applicable, false to just disable them
  6408. navigationAsDateFormat: false, // True if date formatting applied to prev/today/next links
  6409. gotoCurrent: false, // True if today link goes back to current selection instead
  6410. changeMonth: false, // True if month can be selected directly, false if only prev/next
  6411. changeYear: false, // True if year can be selected directly, false if only prev/next
  6412. yearRange: "c-10:c+10", // Range of years to display in drop-down,
  6413. // either relative to today's year (-nn:+nn), relative to currently displayed year
  6414. // (c-nn:c+nn), absolute (nnnn:nnnn), or a combination of the above (nnnn:-n)
  6415. showOtherMonths: false, // True to show dates in other months, false to leave blank
  6416. selectOtherMonths: false, // True to allow selection of dates in other months, false for unselectable
  6417. showWeek: false, // True to show week of the year, false to not show it
  6418. calculateWeek: this.iso8601Week, // How to calculate the week of the year,
  6419. // takes a Date and returns the number of the week for it
  6420. shortYearCutoff: "+10", // Short year values < this are in the current century,
  6421. // > this are in the previous century,
  6422. // string value starting with "+" for current year + value
  6423. minDate: null, // The earliest selectable date, or null for no limit
  6424. maxDate: null, // The latest selectable date, or null for no limit
  6425. duration: "fast", // Duration of display/closure
  6426. beforeShowDay: null, // Function that takes a date and returns an array with
  6427. // [0] = true if selectable, false if not, [1] = custom CSS class name(s) or "",
  6428. // [2] = cell title (optional), e.g. $.datepicker.noWeekends
  6429. beforeShow: null, // Function that takes an input field and
  6430. // returns a set of custom settings for the date picker
  6431. onSelect: null, // Define a callback function when a date is selected
  6432. onChangeMonthYear: null, // Define a callback function when the month or year is changed
  6433. onClose: null, // Define a callback function when the datepicker is closed
  6434. numberOfMonths: 1, // Number of months to show at a time
  6435. showCurrentAtPos: 0, // The position in multipe months at which to show the current month (starting at 0)
  6436. stepMonths: 1, // Number of months to step back/forward
  6437. stepBigMonths: 12, // Number of months to step back/forward for the big links
  6438. altField: "", // Selector for an alternate field to store selected dates into
  6439. altFormat: "", // The date format to use for the alternate field
  6440. constrainInput: true, // The input is constrained by the current date format
  6441. showButtonPanel: false, // True to show button panel, false to not show it
  6442. autoSize: false, // True to size the input for the date format, false to leave as is
  6443. disabled: false // The initial disabled state
  6444. };
  6445. $.extend(this._defaults, this.regional[""]);
  6446. this.dpDiv = bindHover($("<div id='" + this._mainDivId + "' class='ui-datepicker ui-widget ui-widget-content ui-helper-clearfix ui-corner-all'></div>"));
  6447. }
  6448. $.extend(Datepicker.prototype, {
  6449. /* Class name added to elements to indicate already configured with a date picker. */
  6450. markerClassName: "hasDatepicker",
  6451. //Keep track of the maximum number of rows displayed (see #7043)
  6452. maxRows: 4,
  6453. // TODO rename to "widget" when switching to widget factory
  6454. _widgetDatepicker: function() {
  6455. return this.dpDiv;
  6456. },
  6457. /* Override the default settings for all instances of the date picker.
  6458. * @param settings object - the new settings to use as defaults (anonymous object)
  6459. * @return the manager object
  6460. */
  6461. setDefaults: function(settings) {
  6462. extendRemove(this._defaults, settings || {});
  6463. return this;
  6464. },
  6465. /* Attach the date picker to a jQuery selection.
  6466. * @param target element - the target input field or division or span
  6467. * @param settings object - the new settings to use for this date picker instance (anonymous)
  6468. */
  6469. _attachDatepicker: function(target, settings) {
  6470. var nodeName, inline, inst;
  6471. nodeName = target.nodeName.toLowerCase();
  6472. inline = (nodeName === "div" || nodeName === "span");
  6473. if (!target.id) {
  6474. this.uuid += 1;
  6475. target.id = "dp" + this.uuid;
  6476. }
  6477. inst = this._newInst($(target), inline);
  6478. inst.settings = $.extend({}, settings || {});
  6479. if (nodeName === "input") {
  6480. this._connectDatepicker(target, inst);
  6481. } else if (inline) {
  6482. this._inlineDatepicker(target, inst);
  6483. }
  6484. },
  6485. /* Create a new instance object. */
  6486. _newInst: function(target, inline) {
  6487. var id = target[0].id.replace(/([^A-Za-z0-9_\-])/g, "\\\\$1"); // escape jQuery meta chars
  6488. return {id: id, input: target, // associated target
  6489. selectedDay: 0, selectedMonth: 0, selectedYear: 0, // current selection
  6490. drawMonth: 0, drawYear: 0, // month being drawn
  6491. inline: inline, // is datepicker inline or not
  6492. dpDiv: (!inline ? this.dpDiv : // presentation div
  6493. bindHover($("<div class='" + this._inlineClass + " ui-datepicker ui-widget ui-widget-content ui-helper-clearfix ui-corner-all'></div>")))};
  6494. },
  6495. /* Attach the date picker to an input field. */
  6496. _connectDatepicker: function(target, inst) {
  6497. var input = $(target);
  6498. inst.append = $([]);
  6499. inst.trigger = $([]);
  6500. if (input.hasClass(this.markerClassName)) {
  6501. return;
  6502. }
  6503. this._attachments(input, inst);
  6504. input.addClass(this.markerClassName).keydown(this._doKeyDown).
  6505. keypress(this._doKeyPress).keyup(this._doKeyUp);
  6506. this._autoSize(inst);
  6507. $.data(target, PROP_NAME, inst);
  6508. //If disabled option is true, disable the datepicker once it has been attached to the input (see ticket #5665)
  6509. if( inst.settings.disabled ) {
  6510. this._disableDatepicker( target );
  6511. }
  6512. },
  6513. /* Make attachments based on settings. */
  6514. _attachments: function(input, inst) {
  6515. var showOn, buttonText, buttonImage,
  6516. appendText = this._get(inst, "appendText"),
  6517. isRTL = this._get(inst, "isRTL");
  6518. if (inst.append) {
  6519. inst.append.remove();
  6520. }
  6521. if (appendText) {
  6522. inst.append = $("<span class='" + this._appendClass + "'>" + appendText + "</span>");
  6523. input[isRTL ? "before" : "after"](inst.append);
  6524. }
  6525. input.unbind("focus", this._showDatepicker);
  6526. if (inst.trigger) {
  6527. inst.trigger.remove();
  6528. }
  6529. showOn = this._get(inst, "showOn");
  6530. if (showOn === "focus" || showOn === "both") { // pop-up date picker when in the marked field
  6531. input.focus(this._showDatepicker);
  6532. }
  6533. if (showOn === "button" || showOn === "both") { // pop-up date picker when button clicked
  6534. buttonText = this._get(inst, "buttonText");
  6535. buttonImage = this._get(inst, "buttonImage");
  6536. inst.trigger = $(this._get(inst, "buttonImageOnly") ?
  6537. $("<img/>").addClass(this._triggerClass).
  6538. attr({ src: buttonImage, alt: buttonText, title: buttonText }) :
  6539. $("<button type='button'></button>").addClass(this._triggerClass).
  6540. html(!buttonImage ? buttonText : $("<img/>").attr(
  6541. { src:buttonImage, alt:buttonText, title:buttonText })));
  6542. input[isRTL ? "before" : "after"](inst.trigger);
  6543. inst.trigger.click(function() {
  6544. if ($.datepicker._datepickerShowing && $.datepicker._lastInput === input[0]) {
  6545. $.datepicker._hideDatepicker();
  6546. } else if ($.datepicker._datepickerShowing && $.datepicker._lastInput !== input[0]) {
  6547. $.datepicker._hideDatepicker();
  6548. $.datepicker._showDatepicker(input[0]);
  6549. } else {
  6550. $.datepicker._showDatepicker(input[0]);
  6551. }
  6552. return false;
  6553. });
  6554. }
  6555. },
  6556. /* Apply the maximum length for the date format. */
  6557. _autoSize: function(inst) {
  6558. if (this._get(inst, "autoSize") && !inst.inline) {
  6559. var findMax, max, maxI, i,
  6560. date = new Date(2009, 12 - 1, 20), // Ensure double digits
  6561. dateFormat = this._get(inst, "dateFormat");
  6562. if (dateFormat.match(/[DM]/)) {
  6563. findMax = function(names) {
  6564. max = 0;
  6565. maxI = 0;
  6566. for (i = 0; i < names.length; i++) {
  6567. if (names[i].length > max) {
  6568. max = names[i].length;
  6569. maxI = i;
  6570. }
  6571. }
  6572. return maxI;
  6573. };
  6574. date.setMonth(findMax(this._get(inst, (dateFormat.match(/MM/) ?
  6575. "monthNames" : "monthNamesShort"))));
  6576. date.setDate(findMax(this._get(inst, (dateFormat.match(/DD/) ?
  6577. "dayNames" : "dayNamesShort"))) + 20 - date.getDay());
  6578. }
  6579. inst.input.attr("size", this._formatDate(inst, date).length);
  6580. }
  6581. },
  6582. /* Attach an inline date picker to a div. */
  6583. _inlineDatepicker: function(target, inst) {
  6584. var divSpan = $(target);
  6585. if (divSpan.hasClass(this.markerClassName)) {
  6586. return;
  6587. }
  6588. divSpan.addClass(this.markerClassName).append(inst.dpDiv);
  6589. $.data(target, PROP_NAME, inst);
  6590. this._setDate(inst, this._getDefaultDate(inst), true);
  6591. this._updateDatepicker(inst);
  6592. this._updateAlternate(inst);
  6593. //If disabled option is true, disable the datepicker before showing it (see ticket #5665)
  6594. if( inst.settings.disabled ) {
  6595. this._disableDatepicker( target );
  6596. }
  6597. // Set display:block in place of inst.dpDiv.show() which won't work on disconnected elements
  6598. // http://bugs.jqueryui.com/ticket/7552 - A Datepicker created on a detached div has zero height
  6599. inst.dpDiv.css( "display", "block" );
  6600. },
  6601. /* Pop-up the date picker in a "dialog" box.
  6602. * @param input element - ignored
  6603. * @param date string or Date - the initial date to display
  6604. * @param onSelect function - the function to call when a date is selected
  6605. * @param settings object - update the dialog date picker instance's settings (anonymous object)
  6606. * @param pos int[2] - coordinates for the dialog's position within the screen or
  6607. * event - with x/y coordinates or
  6608. * leave empty for default (screen centre)
  6609. * @return the manager object
  6610. */
  6611. _dialogDatepicker: function(input, date, onSelect, settings, pos) {
  6612. var id, browserWidth, browserHeight, scrollX, scrollY,
  6613. inst = this._dialogInst; // internal instance
  6614. if (!inst) {
  6615. this.uuid += 1;
  6616. id = "dp" + this.uuid;
  6617. this._dialogInput = $("<input type='text' id='" + id +
  6618. "' style='position: absolute; top: -100px; width: 0px;'/>");
  6619. this._dialogInput.keydown(this._doKeyDown);
  6620. $("body").append(this._dialogInput);
  6621. inst = this._dialogInst = this._newInst(this._dialogInput, false);
  6622. inst.settings = {};
  6623. $.data(this._dialogInput[0], PROP_NAME, inst);
  6624. }
  6625. extendRemove(inst.settings, settings || {});
  6626. date = (date && date.constructor === Date ? this._formatDate(inst, date) : date);
  6627. this._dialogInput.val(date);
  6628. this._pos = (pos ? (pos.length ? pos : [pos.pageX, pos.pageY]) : null);
  6629. if (!this._pos) {
  6630. browserWidth = document.documentElement.clientWidth;
  6631. browserHeight = document.documentElement.clientHeight;
  6632. scrollX = document.documentElement.scrollLeft || document.body.scrollLeft;
  6633. scrollY = document.documentElement.scrollTop || document.body.scrollTop;
  6634. this._pos = // should use actual width/height below
  6635. [(browserWidth / 2) - 100 + scrollX, (browserHeight / 2) - 150 + scrollY];
  6636. }
  6637. // move input on screen for focus, but hidden behind dialog
  6638. this._dialogInput.css("left", (this._pos[0] + 20) + "px").css("top", this._pos[1] + "px");
  6639. inst.settings.onSelect = onSelect;
  6640. this._inDialog = true;
  6641. this.dpDiv.addClass(this._dialogClass);
  6642. this._showDatepicker(this._dialogInput[0]);
  6643. if ($.blockUI) {
  6644. $.blockUI(this.dpDiv);
  6645. }
  6646. $.data(this._dialogInput[0], PROP_NAME, inst);
  6647. return this;
  6648. },
  6649. /* Detach a datepicker from its control.
  6650. * @param target element - the target input field or division or span
  6651. */
  6652. _destroyDatepicker: function(target) {
  6653. var nodeName,
  6654. $target = $(target),
  6655. inst = $.data(target, PROP_NAME);
  6656. if (!$target.hasClass(this.markerClassName)) {
  6657. return;
  6658. }
  6659. nodeName = target.nodeName.toLowerCase();
  6660. $.removeData(target, PROP_NAME);
  6661. if (nodeName === "input") {
  6662. inst.append.remove();
  6663. inst.trigger.remove();
  6664. $target.removeClass(this.markerClassName).
  6665. unbind("focus", this._showDatepicker).
  6666. unbind("keydown", this._doKeyDown).
  6667. unbind("keypress", this._doKeyPress).
  6668. unbind("keyup", this._doKeyUp);
  6669. } else if (nodeName === "div" || nodeName === "span") {
  6670. $target.removeClass(this.markerClassName).empty();
  6671. }
  6672. },
  6673. /* Enable the date picker to a jQuery selection.
  6674. * @param target element - the target input field or division or span
  6675. */
  6676. _enableDatepicker: function(target) {
  6677. var nodeName, inline,
  6678. $target = $(target),
  6679. inst = $.data(target, PROP_NAME);
  6680. if (!$target.hasClass(this.markerClassName)) {
  6681. return;
  6682. }
  6683. nodeName = target.nodeName.toLowerCase();
  6684. if (nodeName === "input") {
  6685. target.disabled = false;
  6686. inst.trigger.filter("button").
  6687. each(function() { this.disabled = false; }).end().
  6688. filter("img").css({opacity: "1.0", cursor: ""});
  6689. } else if (nodeName === "div" || nodeName === "span") {
  6690. inline = $target.children("." + this._inlineClass);
  6691. inline.children().removeClass("ui-state-disabled");
  6692. inline.find("select.ui-datepicker-month, select.ui-datepicker-year").
  6693. prop("disabled", false);
  6694. }
  6695. this._disabledInputs = $.map(this._disabledInputs,
  6696. function(value) { return (value === target ? null : value); }); // delete entry
  6697. },
  6698. /* Disable the date picker to a jQuery selection.
  6699. * @param target element - the target input field or division or span
  6700. */
  6701. _disableDatepicker: function(target) {
  6702. var nodeName, inline,
  6703. $target = $(target),
  6704. inst = $.data(target, PROP_NAME);
  6705. if (!$target.hasClass(this.markerClassName)) {
  6706. return;
  6707. }
  6708. nodeName = target.nodeName.toLowerCase();
  6709. if (nodeName === "input") {
  6710. target.disabled = true;
  6711. inst.trigger.filter("button").
  6712. each(function() { this.disabled = true; }).end().
  6713. filter("img").css({opacity: "0.5", cursor: "default"});
  6714. } else if (nodeName === "div" || nodeName === "span") {
  6715. inline = $target.children("." + this._inlineClass);
  6716. inline.children().addClass("ui-state-disabled");
  6717. inline.find("select.ui-datepicker-month, select.ui-datepicker-year").
  6718. prop("disabled", true);
  6719. }
  6720. this._disabledInputs = $.map(this._disabledInputs,
  6721. function(value) { return (value === target ? null : value); }); // delete entry
  6722. this._disabledInputs[this._disabledInputs.length] = target;
  6723. },
  6724. /* Is the first field in a jQuery collection disabled as a datepicker?
  6725. * @param target element - the target input field or division or span
  6726. * @return boolean - true if disabled, false if enabled
  6727. */
  6728. _isDisabledDatepicker: function(target) {
  6729. if (!target) {
  6730. return false;
  6731. }
  6732. for (var i = 0; i < this._disabledInputs.length; i++) {
  6733. if (this._disabledInputs[i] === target) {
  6734. return true;
  6735. }
  6736. }
  6737. return false;
  6738. },
  6739. /* Retrieve the instance data for the target control.
  6740. * @param target element - the target input field or division or span
  6741. * @return object - the associated instance data
  6742. * @throws error if a jQuery problem getting data
  6743. */
  6744. _getInst: function(target) {
  6745. try {
  6746. return $.data(target, PROP_NAME);
  6747. }
  6748. catch (err) {
  6749. throw "Missing instance data for this datepicker";
  6750. }
  6751. },
  6752. /* Update or retrieve the settings for a date picker attached to an input field or division.
  6753. * @param target element - the target input field or division or span
  6754. * @param name object - the new settings to update or
  6755. * string - the name of the setting to change or retrieve,
  6756. * when retrieving also "all" for all instance settings or
  6757. * "defaults" for all global defaults
  6758. * @param value any - the new value for the setting
  6759. * (omit if above is an object or to retrieve a value)
  6760. */
  6761. _optionDatepicker: function(target, name, value) {
  6762. var settings, date, minDate, maxDate,
  6763. inst = this._getInst(target);
  6764. if (arguments.length === 2 && typeof name === "string") {
  6765. return (name === "defaults" ? $.extend({}, $.datepicker._defaults) :
  6766. (inst ? (name === "all" ? $.extend({}, inst.settings) :
  6767. this._get(inst, name)) : null));
  6768. }
  6769. settings = name || {};
  6770. if (typeof name === "string") {
  6771. settings = {};
  6772. settings[name] = value;
  6773. }
  6774. if (inst) {
  6775. if (this._curInst === inst) {
  6776. this._hideDatepicker();
  6777. }
  6778. date = this._getDateDatepicker(target, true);
  6779. minDate = this._getMinMaxDate(inst, "min");
  6780. maxDate = this._getMinMaxDate(inst, "max");
  6781. extendRemove(inst.settings, settings);
  6782. // reformat the old minDate/maxDate values if dateFormat changes and a new minDate/maxDate isn't provided
  6783. if (minDate !== null && settings.dateFormat !== undefined && settings.minDate === undefined) {
  6784. inst.settings.minDate = this._formatDate(inst, minDate);
  6785. }
  6786. if (maxDate !== null && settings.dateFormat !== undefined && settings.maxDate === undefined) {
  6787. inst.settings.maxDate = this._formatDate(inst, maxDate);
  6788. }
  6789. if ( "disabled" in settings ) {
  6790. if ( settings.disabled ) {
  6791. this._disableDatepicker(target);
  6792. } else {
  6793. this._enableDatepicker(target);
  6794. }
  6795. }
  6796. this._attachments($(target), inst);
  6797. this._autoSize(inst);
  6798. this._setDate(inst, date);
  6799. this._updateAlternate(inst);
  6800. this._updateDatepicker(inst);
  6801. }
  6802. },
  6803. // change method deprecated
  6804. _changeDatepicker: function(target, name, value) {
  6805. this._optionDatepicker(target, name, value);
  6806. },
  6807. /* Redraw the date picker attached to an input field or division.
  6808. * @param target element - the target input field or division or span
  6809. */
  6810. _refreshDatepicker: function(target) {
  6811. var inst = this._getInst(target);
  6812. if (inst) {
  6813. this._updateDatepicker(inst);
  6814. }
  6815. },
  6816. /* Set the dates for a jQuery selection.
  6817. * @param target element - the target input field or division or span
  6818. * @param date Date - the new date
  6819. */
  6820. _setDateDatepicker: function(target, date) {
  6821. var inst = this._getInst(target);
  6822. if (inst) {
  6823. this._setDate(inst, date);
  6824. this._updateDatepicker(inst);
  6825. this._updateAlternate(inst);
  6826. }
  6827. },
  6828. /* Get the date(s) for the first entry in a jQuery selection.
  6829. * @param target element - the target input field or division or span
  6830. * @param noDefault boolean - true if no default date is to be used
  6831. * @return Date - the current date
  6832. */
  6833. _getDateDatepicker: function(target, noDefault) {
  6834. var inst = this._getInst(target);
  6835. if (inst && !inst.inline) {
  6836. this._setDateFromField(inst, noDefault);
  6837. }
  6838. return (inst ? this._getDate(inst) : null);
  6839. },
  6840. /* Handle keystrokes. */
  6841. _doKeyDown: function(event) {
  6842. var onSelect, dateStr, sel,
  6843. inst = $.datepicker._getInst(event.target),
  6844. handled = true,
  6845. isRTL = inst.dpDiv.is(".ui-datepicker-rtl");
  6846. inst._keyEvent = true;
  6847. if ($.datepicker._datepickerShowing) {
  6848. switch (event.keyCode) {
  6849. case 9: $.datepicker._hideDatepicker();
  6850. handled = false;
  6851. break; // hide on tab out
  6852. case 13: sel = $("td." + $.datepicker._dayOverClass + ":not(." +
  6853. $.datepicker._currentClass + ")", inst.dpDiv);
  6854. if (sel[0]) {
  6855. $.datepicker._selectDay(event.target, inst.selectedMonth, inst.selectedYear, sel[0]);
  6856. }
  6857. onSelect = $.datepicker._get(inst, "onSelect");
  6858. if (onSelect) {
  6859. dateStr = $.datepicker._formatDate(inst);
  6860. // trigger custom callback
  6861. onSelect.apply((inst.input ? inst.input[0] : null), [dateStr, inst]);
  6862. } else {
  6863. $.datepicker._hideDatepicker();
  6864. }
  6865. return false; // don't submit the form
  6866. case 27: $.datepicker._hideDatepicker();
  6867. break; // hide on escape
  6868. case 33: $.datepicker._adjustDate(event.target, (event.ctrlKey ?
  6869. -$.datepicker._get(inst, "stepBigMonths") :
  6870. -$.datepicker._get(inst, "stepMonths")), "M");
  6871. break; // previous month/year on page up/+ ctrl
  6872. case 34: $.datepicker._adjustDate(event.target, (event.ctrlKey ?
  6873. +$.datepicker._get(inst, "stepBigMonths") :
  6874. +$.datepicker._get(inst, "stepMonths")), "M");
  6875. break; // next month/year on page down/+ ctrl
  6876. case 35: if (event.ctrlKey || event.metaKey) {
  6877. $.datepicker._clearDate(event.target);
  6878. }
  6879. handled = event.ctrlKey || event.metaKey;
  6880. break; // clear on ctrl or command +end
  6881. case 36: if (event.ctrlKey || event.metaKey) {
  6882. $.datepicker._gotoToday(event.target);
  6883. }
  6884. handled = event.ctrlKey || event.metaKey;
  6885. break; // current on ctrl or command +home
  6886. case 37: if (event.ctrlKey || event.metaKey) {
  6887. $.datepicker._adjustDate(event.target, (isRTL ? +1 : -1), "D");
  6888. }
  6889. handled = event.ctrlKey || event.metaKey;
  6890. // -1 day on ctrl or command +left
  6891. if (event.originalEvent.altKey) {
  6892. $.datepicker._adjustDate(event.target, (event.ctrlKey ?
  6893. -$.datepicker._get(inst, "stepBigMonths") :
  6894. -$.datepicker._get(inst, "stepMonths")), "M");
  6895. }
  6896. // next month/year on alt +left on Mac
  6897. break;
  6898. case 38: if (event.ctrlKey || event.metaKey) {
  6899. $.datepicker._adjustDate(event.target, -7, "D");
  6900. }
  6901. handled = event.ctrlKey || event.metaKey;
  6902. break; // -1 week on ctrl or command +up
  6903. case 39: if (event.ctrlKey || event.metaKey) {
  6904. $.datepicker._adjustDate(event.target, (isRTL ? -1 : +1), "D");
  6905. }
  6906. handled = event.ctrlKey || event.metaKey;
  6907. // +1 day on ctrl or command +right
  6908. if (event.originalEvent.altKey) {
  6909. $.datepicker._adjustDate(event.target, (event.ctrlKey ?
  6910. +$.datepicker._get(inst, "stepBigMonths") :
  6911. +$.datepicker._get(inst, "stepMonths")), "M");
  6912. }
  6913. // next month/year on alt +right
  6914. break;
  6915. case 40: if (event.ctrlKey || event.metaKey) {
  6916. $.datepicker._adjustDate(event.target, +7, "D");
  6917. }
  6918. handled = event.ctrlKey || event.metaKey;
  6919. break; // +1 week on ctrl or command +down
  6920. default: handled = false;
  6921. }
  6922. } else if (event.keyCode === 36 && event.ctrlKey) { // display the date picker on ctrl+home
  6923. $.datepicker._showDatepicker(this);
  6924. } else {
  6925. handled = false;
  6926. }
  6927. if (handled) {
  6928. event.preventDefault();
  6929. event.stopPropagation();
  6930. }
  6931. },
  6932. /* Filter entered characters - based on date format. */
  6933. _doKeyPress: function(event) {
  6934. var chars, chr,
  6935. inst = $.datepicker._getInst(event.target);
  6936. if ($.datepicker._get(inst, "constrainInput")) {
  6937. chars = $.datepicker._possibleChars($.datepicker._get(inst, "dateFormat"));
  6938. chr = String.fromCharCode(event.charCode == null ? event.keyCode : event.charCode);
  6939. return event.ctrlKey || event.metaKey || (chr < " " || !chars || chars.indexOf(chr) > -1);
  6940. }
  6941. },
  6942. /* Synchronise manual entry and field/alternate field. */
  6943. _doKeyUp: function(event) {
  6944. var date,
  6945. inst = $.datepicker._getInst(event.target);
  6946. if (inst.input.val() !== inst.lastVal) {
  6947. try {
  6948. date = $.datepicker.parseDate($.datepicker._get(inst, "dateFormat"),
  6949. (inst.input ? inst.input.val() : null),
  6950. $.datepicker._getFormatConfig(inst));
  6951. if (date) { // only if valid
  6952. $.datepicker._setDateFromField(inst);
  6953. $.datepicker._updateAlternate(inst);
  6954. $.datepicker._updateDatepicker(inst);
  6955. }
  6956. }
  6957. catch (err) {
  6958. }
  6959. }
  6960. return true;
  6961. },
  6962. /* Pop-up the date picker for a given input field.
  6963. * If false returned from beforeShow event handler do not show.
  6964. * @param input element - the input field attached to the date picker or
  6965. * event - if triggered by focus
  6966. */
  6967. _showDatepicker: function(input) {
  6968. input = input.target || input;
  6969. if (input.nodeName.toLowerCase() !== "input") { // find from button/image trigger
  6970. input = $("input", input.parentNode)[0];
  6971. }
  6972. if ($.datepicker._isDisabledDatepicker(input) || $.datepicker._lastInput === input) { // already here
  6973. return;
  6974. }
  6975. var inst, beforeShow, beforeShowSettings, isFixed,
  6976. offset, showAnim, duration;
  6977. inst = $.datepicker._getInst(input);
  6978. if ($.datepicker._curInst && $.datepicker._curInst !== inst) {
  6979. $.datepicker._curInst.dpDiv.stop(true, true);
  6980. if ( inst && $.datepicker._datepickerShowing ) {
  6981. $.datepicker._hideDatepicker( $.datepicker._curInst.input[0] );
  6982. }
  6983. }
  6984. beforeShow = $.datepicker._get(inst, "beforeShow");
  6985. beforeShowSettings = beforeShow ? beforeShow.apply(input, [input, inst]) : {};
  6986. if(beforeShowSettings === false){
  6987. return;
  6988. }
  6989. extendRemove(inst.settings, beforeShowSettings);
  6990. inst.lastVal = null;
  6991. $.datepicker._lastInput = input;
  6992. $.datepicker._setDateFromField(inst);
  6993. if ($.datepicker._inDialog) { // hide cursor
  6994. input.value = "";
  6995. }
  6996. if (!$.datepicker._pos) { // position below input
  6997. $.datepicker._pos = $.datepicker._findPos(input);
  6998. $.datepicker._pos[1] += input.offsetHeight; // add the height
  6999. }
  7000. isFixed = false;
  7001. $(input).parents().each(function() {
  7002. isFixed |= $(this).css("position") === "fixed";
  7003. return !isFixed;
  7004. });
  7005. offset = {left: $.datepicker._pos[0], top: $.datepicker._pos[1]};
  7006. $.datepicker._pos = null;
  7007. //to avoid flashes on Firefox
  7008. inst.dpDiv.empty();
  7009. // determine sizing offscreen
  7010. inst.dpDiv.css({position: "absolute", display: "block", top: "-1000px"});
  7011. $.datepicker._updateDatepicker(inst);
  7012. // fix width for dynamic number of date pickers
  7013. // and adjust position before showing
  7014. offset = $.datepicker._checkOffset(inst, offset, isFixed);
  7015. inst.dpDiv.css({position: ($.datepicker._inDialog && $.blockUI ?
  7016. "static" : (isFixed ? "fixed" : "absolute")), display: "none",
  7017. left: offset.left + "px", top: offset.top + "px"});
  7018. if (!inst.inline) {
  7019. showAnim = $.datepicker._get(inst, "showAnim");
  7020. duration = $.datepicker._get(inst, "duration");
  7021. inst.dpDiv.zIndex($(input).zIndex()+1);
  7022. $.datepicker._datepickerShowing = true;
  7023. if ( $.effects && $.effects.effect[ showAnim ] ) {
  7024. inst.dpDiv.show(showAnim, $.datepicker._get(inst, "showOptions"), duration);
  7025. } else {
  7026. inst.dpDiv[showAnim || "show"](showAnim ? duration : null);
  7027. }
  7028. if (inst.input.is(":visible") && !inst.input.is(":disabled")) {
  7029. inst.input.focus();
  7030. }
  7031. $.datepicker._curInst = inst;
  7032. }
  7033. },
  7034. /* Generate the date picker content. */
  7035. _updateDatepicker: function(inst) {
  7036. this.maxRows = 4; //Reset the max number of rows being displayed (see #7043)
  7037. instActive = inst; // for delegate hover events
  7038. inst.dpDiv.empty().append(this._generateHTML(inst));
  7039. this._attachHandlers(inst);
  7040. inst.dpDiv.find("." + this._dayOverClass + " a").mouseover();
  7041. var origyearshtml,
  7042. numMonths = this._getNumberOfMonths(inst),
  7043. cols = numMonths[1],
  7044. width = 17;
  7045. inst.dpDiv.removeClass("ui-datepicker-multi-2 ui-datepicker-multi-3 ui-datepicker-multi-4").width("");
  7046. if (cols > 1) {
  7047. inst.dpDiv.addClass("ui-datepicker-multi-" + cols).css("width", (width * cols) + "em");
  7048. }
  7049. inst.dpDiv[(numMonths[0] !== 1 || numMonths[1] !== 1 ? "add" : "remove") +
  7050. "Class"]("ui-datepicker-multi");
  7051. inst.dpDiv[(this._get(inst, "isRTL") ? "add" : "remove") +
  7052. "Class"]("ui-datepicker-rtl");
  7053. // #6694 - don't focus the input if it's already focused
  7054. // this breaks the change event in IE
  7055. if (inst === $.datepicker._curInst && $.datepicker._datepickerShowing && inst.input &&
  7056. inst.input.is(":visible") && !inst.input.is(":disabled") && inst.input[0] !== document.activeElement) {
  7057. inst.input.focus();
  7058. }
  7059. // deffered render of the years select (to avoid flashes on Firefox)
  7060. if( inst.yearshtml ){
  7061. origyearshtml = inst.yearshtml;
  7062. setTimeout(function(){
  7063. //assure that inst.yearshtml didn't change.
  7064. if( origyearshtml === inst.yearshtml && inst.yearshtml ){
  7065. inst.dpDiv.find("select.ui-datepicker-year:first").replaceWith(inst.yearshtml);
  7066. }
  7067. origyearshtml = inst.yearshtml = null;
  7068. }, 0);
  7069. }
  7070. },
  7071. /* Retrieve the size of left and top borders for an element.
  7072. * @param elem (jQuery object) the element of interest
  7073. * @return (number[2]) the left and top borders
  7074. */
  7075. _getBorders: function(elem) {
  7076. var convert = function(value) {
  7077. return {thin: 1, medium: 2, thick: 3}[value] || value;
  7078. };
  7079. return [parseFloat(convert(elem.css("border-left-width"))),
  7080. parseFloat(convert(elem.css("border-top-width")))];
  7081. },
  7082. /* Check positioning to remain on screen. */
  7083. _checkOffset: function(inst, offset, isFixed) {
  7084. var dpWidth = inst.dpDiv.outerWidth(),
  7085. dpHeight = inst.dpDiv.outerHeight(),
  7086. inputWidth = inst.input ? inst.input.outerWidth() : 0,
  7087. inputHeight = inst.input ? inst.input.outerHeight() : 0,
  7088. viewWidth = document.documentElement.clientWidth + (isFixed ? 0 : $(document).scrollLeft()),
  7089. viewHeight = document.documentElement.clientHeight + (isFixed ? 0 : $(document).scrollTop());
  7090. offset.left -= (this._get(inst, "isRTL") ? (dpWidth - inputWidth) : 0);
  7091. offset.left -= (isFixed && offset.left === inst.input.offset().left) ? $(document).scrollLeft() : 0;
  7092. offset.top -= (isFixed && offset.top === (inst.input.offset().top + inputHeight)) ? $(document).scrollTop() : 0;
  7093. // now check if datepicker is showing outside window viewport - move to a better place if so.
  7094. offset.left -= Math.min(offset.left, (offset.left + dpWidth > viewWidth && viewWidth > dpWidth) ?
  7095. Math.abs(offset.left + dpWidth - viewWidth) : 0);
  7096. offset.top -= Math.min(offset.top, (offset.top + dpHeight > viewHeight && viewHeight > dpHeight) ?
  7097. Math.abs(dpHeight + inputHeight) : 0);
  7098. return offset;
  7099. },
  7100. /* Find an object's position on the screen. */
  7101. _findPos: function(obj) {
  7102. var position,
  7103. inst = this._getInst(obj),
  7104. isRTL = this._get(inst, "isRTL");
  7105. while (obj && (obj.type === "hidden" || obj.nodeType !== 1 || $.expr.filters.hidden(obj))) {
  7106. obj = obj[isRTL ? "previousSibling" : "nextSibling"];
  7107. }
  7108. position = $(obj).offset();
  7109. return [position.left, position.top];
  7110. },
  7111. /* Hide the date picker from view.
  7112. * @param input element - the input field attached to the date picker
  7113. */
  7114. _hideDatepicker: function(input) {
  7115. var showAnim, duration, postProcess, onClose,
  7116. inst = this._curInst;
  7117. if (!inst || (input && inst !== $.data(input, PROP_NAME))) {
  7118. return;
  7119. }
  7120. if (this._datepickerShowing) {
  7121. showAnim = this._get(inst, "showAnim");
  7122. duration = this._get(inst, "duration");
  7123. postProcess = function() {
  7124. $.datepicker._tidyDialog(inst);
  7125. };
  7126. // DEPRECATED: after BC for 1.8.x $.effects[ showAnim ] is not needed
  7127. if ( $.effects && ( $.effects.effect[ showAnim ] || $.effects[ showAnim ] ) ) {
  7128. inst.dpDiv.hide(showAnim, $.datepicker._get(inst, "showOptions"), duration, postProcess);
  7129. } else {
  7130. inst.dpDiv[(showAnim === "slideDown" ? "slideUp" :
  7131. (showAnim === "fadeIn" ? "fadeOut" : "hide"))]((showAnim ? duration : null), postProcess);
  7132. }
  7133. if (!showAnim) {
  7134. postProcess();
  7135. }
  7136. this._datepickerShowing = false;
  7137. onClose = this._get(inst, "onClose");
  7138. if (onClose) {
  7139. onClose.apply((inst.input ? inst.input[0] : null), [(inst.input ? inst.input.val() : ""), inst]);
  7140. }
  7141. this._lastInput = null;
  7142. if (this._inDialog) {
  7143. this._dialogInput.css({ position: "absolute", left: "0", top: "-100px" });
  7144. if ($.blockUI) {
  7145. $.unblockUI();
  7146. $("body").append(this.dpDiv);
  7147. }
  7148. }
  7149. this._inDialog = false;
  7150. }
  7151. },
  7152. /* Tidy up after a dialog display. */
  7153. _tidyDialog: function(inst) {
  7154. inst.dpDiv.removeClass(this._dialogClass).unbind(".ui-datepicker-calendar");
  7155. },
  7156. /* Close date picker if clicked elsewhere. */
  7157. _checkExternalClick: function(event) {
  7158. if (!$.datepicker._curInst) {
  7159. return;
  7160. }
  7161. var $target = $(event.target),
  7162. inst = $.datepicker._getInst($target[0]);
  7163. if ( ( ( $target[0].id !== $.datepicker._mainDivId &&
  7164. $target.parents("#" + $.datepicker._mainDivId).length === 0 &&
  7165. !$target.hasClass($.datepicker.markerClassName) &&
  7166. !$target.closest("." + $.datepicker._triggerClass).length &&
  7167. $.datepicker._datepickerShowing && !($.datepicker._inDialog && $.blockUI) ) ) ||
  7168. ( $target.hasClass($.datepicker.markerClassName) && $.datepicker._curInst !== inst ) ) {
  7169. $.datepicker._hideDatepicker();
  7170. }
  7171. },
  7172. /* Adjust one of the date sub-fields. */
  7173. _adjustDate: function(id, offset, period) {
  7174. var target = $(id),
  7175. inst = this._getInst(target[0]);
  7176. if (this._isDisabledDatepicker(target[0])) {
  7177. return;
  7178. }
  7179. this._adjustInstDate(inst, offset +
  7180. (period === "M" ? this._get(inst, "showCurrentAtPos") : 0), // undo positioning
  7181. period);
  7182. this._updateDatepicker(inst);
  7183. },
  7184. /* Action for current link. */
  7185. _gotoToday: function(id) {
  7186. var date,
  7187. target = $(id),
  7188. inst = this._getInst(target[0]);
  7189. if (this._get(inst, "gotoCurrent") && inst.currentDay) {
  7190. inst.selectedDay = inst.currentDay;
  7191. inst.drawMonth = inst.selectedMonth = inst.currentMonth;
  7192. inst.drawYear = inst.selectedYear = inst.currentYear;
  7193. } else {
  7194. date = new Date();
  7195. inst.selectedDay = date.getDate();
  7196. inst.drawMonth = inst.selectedMonth = date.getMonth();
  7197. inst.drawYear = inst.selectedYear = date.getFullYear();
  7198. }
  7199. this._notifyChange(inst);
  7200. this._adjustDate(target);
  7201. },
  7202. /* Action for selecting a new month/year. */
  7203. _selectMonthYear: function(id, select, period) {
  7204. var target = $(id),
  7205. inst = this._getInst(target[0]);
  7206. inst["selected" + (period === "M" ? "Month" : "Year")] =
  7207. inst["draw" + (period === "M" ? "Month" : "Year")] =
  7208. parseInt(select.options[select.selectedIndex].value,10);
  7209. this._notifyChange(inst);
  7210. this._adjustDate(target);
  7211. },
  7212. /* Action for selecting a day. */
  7213. _selectDay: function(id, month, year, td) {
  7214. var inst,
  7215. target = $(id);
  7216. if ($(td).hasClass(this._unselectableClass) || this._isDisabledDatepicker(target[0])) {
  7217. return;
  7218. }
  7219. inst = this._getInst(target[0]);
  7220. inst.selectedDay = inst.currentDay = $("a", td).html();
  7221. inst.selectedMonth = inst.currentMonth = month;
  7222. inst.selectedYear = inst.currentYear = year;
  7223. this._selectDate(id, this._formatDate(inst,
  7224. inst.currentDay, inst.currentMonth, inst.currentYear));
  7225. },
  7226. /* Erase the input field and hide the date picker. */
  7227. _clearDate: function(id) {
  7228. var target = $(id);
  7229. this._selectDate(target, "");
  7230. },
  7231. /* Update the input field with the selected date. */
  7232. _selectDate: function(id, dateStr) {
  7233. var onSelect,
  7234. target = $(id),
  7235. inst = this._getInst(target[0]);
  7236. dateStr = (dateStr != null ? dateStr : this._formatDate(inst));
  7237. if (inst.input) {
  7238. inst.input.val(dateStr);
  7239. }
  7240. this._updateAlternate(inst);
  7241. onSelect = this._get(inst, "onSelect");
  7242. if (onSelect) {
  7243. onSelect.apply((inst.input ? inst.input[0] : null), [dateStr, inst]); // trigger custom callback
  7244. } else if (inst.input) {
  7245. inst.input.trigger("change"); // fire the change event
  7246. }
  7247. if (inst.inline){
  7248. this._updateDatepicker(inst);
  7249. } else {
  7250. this._hideDatepicker();
  7251. this._lastInput = inst.input[0];
  7252. if (typeof(inst.input[0]) !== "object") {
  7253. inst.input.focus(); // restore focus
  7254. }
  7255. this._lastInput = null;
  7256. }
  7257. },
  7258. /* Update any alternate field to synchronise with the main field. */
  7259. _updateAlternate: function(inst) {
  7260. var altFormat, date, dateStr,
  7261. altField = this._get(inst, "altField");
  7262. if (altField) { // update alternate field too
  7263. altFormat = this._get(inst, "altFormat") || this._get(inst, "dateFormat");
  7264. date = this._getDate(inst);
  7265. dateStr = this.formatDate(altFormat, date, this._getFormatConfig(inst));
  7266. $(altField).each(function() { $(this).val(dateStr); });
  7267. }
  7268. },
  7269. /* Set as beforeShowDay function to prevent selection of weekends.
  7270. * @param date Date - the date to customise
  7271. * @return [boolean, string] - is this date selectable?, what is its CSS class?
  7272. */
  7273. noWeekends: function(date) {
  7274. var day = date.getDay();
  7275. return [(day > 0 && day < 6), ""];
  7276. },
  7277. /* Set as calculateWeek to determine the week of the year based on the ISO 8601 definition.
  7278. * @param date Date - the date to get the week for
  7279. * @return number - the number of the week within the year that contains this date
  7280. */
  7281. iso8601Week: function(date) {
  7282. var time,
  7283. checkDate = new Date(date.getTime());
  7284. // Find Thursday of this week starting on Monday
  7285. checkDate.setDate(checkDate.getDate() + 4 - (checkDate.getDay() || 7));
  7286. time = checkDate.getTime();
  7287. checkDate.setMonth(0); // Compare with Jan 1
  7288. checkDate.setDate(1);
  7289. return Math.floor(Math.round((time - checkDate) / 86400000) / 7) + 1;
  7290. },
  7291. /* Parse a string value into a date object.
  7292. * See formatDate below for the possible formats.
  7293. *
  7294. * @param format string - the expected format of the date
  7295. * @param value string - the date in the above format
  7296. * @param settings Object - attributes include:
  7297. * shortYearCutoff number - the cutoff year for determining the century (optional)
  7298. * dayNamesShort string[7] - abbreviated names of the days from Sunday (optional)
  7299. * dayNames string[7] - names of the days from Sunday (optional)
  7300. * monthNamesShort string[12] - abbreviated names of the months (optional)
  7301. * monthNames string[12] - names of the months (optional)
  7302. * @return Date - the extracted date value or null if value is blank
  7303. */
  7304. parseDate: function (format, value, settings) {
  7305. if (format == null || value == null) {
  7306. throw "Invalid arguments";
  7307. }
  7308. value = (typeof value === "object" ? value.toString() : value + "");
  7309. if (value === "") {
  7310. return null;
  7311. }
  7312. var iFormat, dim, extra,
  7313. iValue = 0,
  7314. shortYearCutoffTemp = (settings ? settings.shortYearCutoff : null) || this._defaults.shortYearCutoff,
  7315. shortYearCutoff = (typeof shortYearCutoffTemp !== "string" ? shortYearCutoffTemp :
  7316. new Date().getFullYear() % 100 + parseInt(shortYearCutoffTemp, 10)),
  7317. dayNamesShort = (settings ? settings.dayNamesShort : null) || this._defaults.dayNamesShort,
  7318. dayNames = (settings ? settings.dayNames : null) || this._defaults.dayNames,
  7319. monthNamesShort = (settings ? settings.monthNamesShort : null) || this._defaults.monthNamesShort,
  7320. monthNames = (settings ? settings.monthNames : null) || this._defaults.monthNames,
  7321. year = -1,
  7322. month = -1,
  7323. day = -1,
  7324. doy = -1,
  7325. literal = false,
  7326. date,
  7327. // Check whether a format character is doubled
  7328. lookAhead = function(match) {
  7329. var matches = (iFormat + 1 < format.length && format.charAt(iFormat + 1) === match);
  7330. if (matches) {
  7331. iFormat++;
  7332. }
  7333. return matches;
  7334. },
  7335. // Extract a number from the string value
  7336. getNumber = function(match) {
  7337. var isDoubled = lookAhead(match),
  7338. size = (match === "@" ? 14 : (match === "!" ? 20 :
  7339. (match === "y" && isDoubled ? 4 : (match === "o" ? 3 : 2)))),
  7340. digits = new RegExp("^\\d{1," + size + "}"),
  7341. num = value.substring(iValue).match(digits);
  7342. if (!num) {
  7343. throw "Missing number at position " + iValue;
  7344. }
  7345. iValue += num[0].length;
  7346. return parseInt(num[0], 10);
  7347. },
  7348. // Extract a name from the string value and convert to an index
  7349. getName = function(match, shortNames, longNames) {
  7350. var index = -1,
  7351. names = $.map(lookAhead(match) ? longNames : shortNames, function (v, k) {
  7352. return [ [k, v] ];
  7353. }).sort(function (a, b) {
  7354. return -(a[1].length - b[1].length);
  7355. });
  7356. $.each(names, function (i, pair) {
  7357. var name = pair[1];
  7358. if (value.substr(iValue, name.length).toLowerCase() === name.toLowerCase()) {
  7359. index = pair[0];
  7360. iValue += name.length;
  7361. return false;
  7362. }
  7363. });
  7364. if (index !== -1) {
  7365. return index + 1;
  7366. } else {
  7367. throw "Unknown name at position " + iValue;
  7368. }
  7369. },
  7370. // Confirm that a literal character matches the string value
  7371. checkLiteral = function() {
  7372. if (value.charAt(iValue) !== format.charAt(iFormat)) {
  7373. throw "Unexpected literal at position " + iValue;
  7374. }
  7375. iValue++;
  7376. };
  7377. for (iFormat = 0; iFormat < format.length; iFormat++) {
  7378. if (literal) {
  7379. if (format.charAt(iFormat) === "'" && !lookAhead("'")) {
  7380. literal = false;
  7381. } else {
  7382. checkLiteral();
  7383. }
  7384. } else {
  7385. switch (format.charAt(iFormat)) {
  7386. case "d":
  7387. day = getNumber("d");
  7388. break;
  7389. case "D":
  7390. getName("D", dayNamesShort, dayNames);
  7391. break;
  7392. case "o":
  7393. doy = getNumber("o");
  7394. break;
  7395. case "m":
  7396. month = getNumber("m");
  7397. break;
  7398. case "M":
  7399. month = getName("M", monthNamesShort, monthNames);
  7400. break;
  7401. case "y":
  7402. year = getNumber("y");
  7403. break;
  7404. case "@":
  7405. date = new Date(getNumber("@"));
  7406. year = date.getFullYear();
  7407. month = date.getMonth() + 1;
  7408. day = date.getDate();
  7409. break;
  7410. case "!":
  7411. date = new Date((getNumber("!") - this._ticksTo1970) / 10000);
  7412. year = date.getFullYear();
  7413. month = date.getMonth() + 1;
  7414. day = date.getDate();
  7415. break;
  7416. case "'":
  7417. if (lookAhead("'")){
  7418. checkLiteral();
  7419. } else {
  7420. literal = true;
  7421. }
  7422. break;
  7423. default:
  7424. checkLiteral();
  7425. }
  7426. }
  7427. }
  7428. if (iValue < value.length){
  7429. extra = value.substr(iValue);
  7430. if (!/^\s+/.test(extra)) {
  7431. throw "Extra/unparsed characters found in date: " + extra;
  7432. }
  7433. }
  7434. if (year === -1) {
  7435. year = new Date().getFullYear();
  7436. } else if (year < 100) {
  7437. year += new Date().getFullYear() - new Date().getFullYear() % 100 +
  7438. (year <= shortYearCutoff ? 0 : -100);
  7439. }
  7440. if (doy > -1) {
  7441. month = 1;
  7442. day = doy;
  7443. do {
  7444. dim = this._getDaysInMonth(year, month - 1);
  7445. if (day <= dim) {
  7446. break;
  7447. }
  7448. month++;
  7449. day -= dim;
  7450. } while (true);
  7451. }
  7452. date = this._daylightSavingAdjust(new Date(year, month - 1, day));
  7453. if (date.getFullYear() !== year || date.getMonth() + 1 !== month || date.getDate() !== day) {
  7454. throw "Invalid date"; // E.g. 31/02/00
  7455. }
  7456. return date;
  7457. },
  7458. /* Standard date formats. */
  7459. ATOM: "yy-mm-dd", // RFC 3339 (ISO 8601)
  7460. COOKIE: "D, dd M yy",
  7461. ISO_8601: "yy-mm-dd",
  7462. RFC_822: "D, d M y",
  7463. RFC_850: "DD, dd-M-y",
  7464. RFC_1036: "D, d M y",
  7465. RFC_1123: "D, d M yy",
  7466. RFC_2822: "D, d M yy",
  7467. RSS: "D, d M y", // RFC 822
  7468. TICKS: "!",
  7469. TIMESTAMP: "@",
  7470. W3C: "yy-mm-dd", // ISO 8601
  7471. _ticksTo1970: (((1970 - 1) * 365 + Math.floor(1970 / 4) - Math.floor(1970 / 100) +
  7472. Math.floor(1970 / 400)) * 24 * 60 * 60 * 10000000),
  7473. /* Format a date object into a string value.
  7474. * The format can be combinations of the following:
  7475. * d - day of month (no leading zero)
  7476. * dd - day of month (two digit)
  7477. * o - day of year (no leading zeros)
  7478. * oo - day of year (three digit)
  7479. * D - day name short
  7480. * DD - day name long
  7481. * m - month of year (no leading zero)
  7482. * mm - month of year (two digit)
  7483. * M - month name short
  7484. * MM - month name long
  7485. * y - year (two digit)
  7486. * yy - year (four digit)
  7487. * @ - Unix timestamp (ms since 01/01/1970)
  7488. * ! - Windows ticks (100ns since 01/01/0001)
  7489. * "..." - literal text
  7490. * '' - single quote
  7491. *
  7492. * @param format string - the desired format of the date
  7493. * @param date Date - the date value to format
  7494. * @param settings Object - attributes include:
  7495. * dayNamesShort string[7] - abbreviated names of the days from Sunday (optional)
  7496. * dayNames string[7] - names of the days from Sunday (optional)
  7497. * monthNamesShort string[12] - abbreviated names of the months (optional)
  7498. * monthNames string[12] - names of the months (optional)
  7499. * @return string - the date in the above format
  7500. */
  7501. formatDate: function (format, date, settings) {
  7502. if (!date) {
  7503. return "";
  7504. }
  7505. var iFormat,
  7506. dayNamesShort = (settings ? settings.dayNamesShort : null) || this._defaults.dayNamesShort,
  7507. dayNames = (settings ? settings.dayNames : null) || this._defaults.dayNames,
  7508. monthNamesShort = (settings ? settings.monthNamesShort : null) || this._defaults.monthNamesShort,
  7509. monthNames = (settings ? settings.monthNames : null) || this._defaults.monthNames,
  7510. // Check whether a format character is doubled
  7511. lookAhead = function(match) {
  7512. var matches = (iFormat + 1 < format.length && format.charAt(iFormat + 1) === match);
  7513. if (matches) {
  7514. iFormat++;
  7515. }
  7516. return matches;
  7517. },
  7518. // Format a number, with leading zero if necessary
  7519. formatNumber = function(match, value, len) {
  7520. var num = "" + value;
  7521. if (lookAhead(match)) {
  7522. while (num.length < len) {
  7523. num = "0" + num;
  7524. }
  7525. }
  7526. return num;
  7527. },
  7528. // Format a name, short or long as requested
  7529. formatName = function(match, value, shortNames, longNames) {
  7530. return (lookAhead(match) ? longNames[value] : shortNames[value]);
  7531. },
  7532. output = "",
  7533. literal = false;
  7534. if (date) {
  7535. for (iFormat = 0; iFormat < format.length; iFormat++) {
  7536. if (literal) {
  7537. if (format.charAt(iFormat) === "'" && !lookAhead("'")) {
  7538. literal = false;
  7539. } else {
  7540. output += format.charAt(iFormat);
  7541. }
  7542. } else {
  7543. switch (format.charAt(iFormat)) {
  7544. case "d":
  7545. output += formatNumber("d", date.getDate(), 2);
  7546. break;
  7547. case "D":
  7548. output += formatName("D", date.getDay(), dayNamesShort, dayNames);
  7549. break;
  7550. case "o":
  7551. output += formatNumber("o",
  7552. Math.round((new Date(date.getFullYear(), date.getMonth(), date.getDate()).getTime() - new Date(date.getFullYear(), 0, 0).getTime()) / 86400000), 3);
  7553. break;
  7554. case "m":
  7555. output += formatNumber("m", date.getMonth() + 1, 2);
  7556. break;
  7557. case "M":
  7558. output += formatName("M", date.getMonth(), monthNamesShort, monthNames);
  7559. break;
  7560. case "y":
  7561. output += (lookAhead("y") ? date.getFullYear() :
  7562. (date.getYear() % 100 < 10 ? "0" : "") + date.getYear() % 100);
  7563. break;
  7564. case "@":
  7565. output += date.getTime();
  7566. break;
  7567. case "!":
  7568. output += date.getTime() * 10000 + this._ticksTo1970;
  7569. break;
  7570. case "'":
  7571. if (lookAhead("'")) {
  7572. output += "'";
  7573. } else {
  7574. literal = true;
  7575. }
  7576. break;
  7577. default:
  7578. output += format.charAt(iFormat);
  7579. }
  7580. }
  7581. }
  7582. }
  7583. return output;
  7584. },
  7585. /* Extract all possible characters from the date format. */
  7586. _possibleChars: function (format) {
  7587. var iFormat,
  7588. chars = "",
  7589. literal = false,
  7590. // Check whether a format character is doubled
  7591. lookAhead = function(match) {
  7592. var matches = (iFormat + 1 < format.length && format.charAt(iFormat + 1) === match);
  7593. if (matches) {
  7594. iFormat++;
  7595. }
  7596. return matches;
  7597. };
  7598. for (iFormat = 0; iFormat < format.length; iFormat++) {
  7599. if (literal) {
  7600. if (format.charAt(iFormat) === "'" && !lookAhead("'")) {
  7601. literal = false;
  7602. } else {
  7603. chars += format.charAt(iFormat);
  7604. }
  7605. } else {
  7606. switch (format.charAt(iFormat)) {
  7607. case "d": case "m": case "y": case "@":
  7608. chars += "0123456789";
  7609. break;
  7610. case "D": case "M":
  7611. return null; // Accept anything
  7612. case "'":
  7613. if (lookAhead("'")) {
  7614. chars += "'";
  7615. } else {
  7616. literal = true;
  7617. }
  7618. break;
  7619. default:
  7620. chars += format.charAt(iFormat);
  7621. }
  7622. }
  7623. }
  7624. return chars;
  7625. },
  7626. /* Get a setting value, defaulting if necessary. */
  7627. _get: function(inst, name) {
  7628. return inst.settings[name] !== undefined ?
  7629. inst.settings[name] : this._defaults[name];
  7630. },
  7631. /* Parse existing date and initialise date picker. */
  7632. _setDateFromField: function(inst, noDefault) {
  7633. if (inst.input.val() === inst.lastVal) {
  7634. return;
  7635. }
  7636. var dateFormat = this._get(inst, "dateFormat"),
  7637. dates = inst.lastVal = inst.input ? inst.input.val() : null,
  7638. defaultDate = this._getDefaultDate(inst),
  7639. date = defaultDate,
  7640. settings = this._getFormatConfig(inst);
  7641. try {
  7642. date = this.parseDate(dateFormat, dates, settings) || defaultDate;
  7643. } catch (event) {
  7644. dates = (noDefault ? "" : dates);
  7645. }
  7646. inst.selectedDay = date.getDate();
  7647. inst.drawMonth = inst.selectedMonth = date.getMonth();
  7648. inst.drawYear = inst.selectedYear = date.getFullYear();
  7649. inst.currentDay = (dates ? date.getDate() : 0);
  7650. inst.currentMonth = (dates ? date.getMonth() : 0);
  7651. inst.currentYear = (dates ? date.getFullYear() : 0);
  7652. this._adjustInstDate(inst);
  7653. },
  7654. /* Retrieve the default date shown on opening. */
  7655. _getDefaultDate: function(inst) {
  7656. return this._restrictMinMax(inst,
  7657. this._determineDate(inst, this._get(inst, "defaultDate"), new Date()));
  7658. },
  7659. /* A date may be specified as an exact value or a relative one. */
  7660. _determineDate: function(inst, date, defaultDate) {
  7661. var offsetNumeric = function(offset) {
  7662. var date = new Date();
  7663. date.setDate(date.getDate() + offset);
  7664. return date;
  7665. },
  7666. offsetString = function(offset) {
  7667. try {
  7668. return $.datepicker.parseDate($.datepicker._get(inst, "dateFormat"),
  7669. offset, $.datepicker._getFormatConfig(inst));
  7670. }
  7671. catch (e) {
  7672. // Ignore
  7673. }
  7674. var date = (offset.toLowerCase().match(/^c/) ?
  7675. $.datepicker._getDate(inst) : null) || new Date(),
  7676. year = date.getFullYear(),
  7677. month = date.getMonth(),
  7678. day = date.getDate(),
  7679. pattern = /([+\-]?[0-9]+)\s*(d|D|w|W|m|M|y|Y)?/g,
  7680. matches = pattern.exec(offset);
  7681. while (matches) {
  7682. switch (matches[2] || "d") {
  7683. case "d" : case "D" :
  7684. day += parseInt(matches[1],10); break;
  7685. case "w" : case "W" :
  7686. day += parseInt(matches[1],10) * 7; break;
  7687. case "m" : case "M" :
  7688. month += parseInt(matches[1],10);
  7689. day = Math.min(day, $.datepicker._getDaysInMonth(year, month));
  7690. break;
  7691. case "y": case "Y" :
  7692. year += parseInt(matches[1],10);
  7693. day = Math.min(day, $.datepicker._getDaysInMonth(year, month));
  7694. break;
  7695. }
  7696. matches = pattern.exec(offset);
  7697. }
  7698. return new Date(year, month, day);
  7699. },
  7700. newDate = (date == null || date === "" ? defaultDate : (typeof date === "string" ? offsetString(date) :
  7701. (typeof date === "number" ? (isNaN(date) ? defaultDate : offsetNumeric(date)) : new Date(date.getTime()))));
  7702. newDate = (newDate && newDate.toString() === "Invalid Date" ? defaultDate : newDate);
  7703. if (newDate) {
  7704. newDate.setHours(0);
  7705. newDate.setMinutes(0);
  7706. newDate.setSeconds(0);
  7707. newDate.setMilliseconds(0);
  7708. }
  7709. return this._daylightSavingAdjust(newDate);
  7710. },
  7711. /* Handle switch to/from daylight saving.
  7712. * Hours may be non-zero on daylight saving cut-over:
  7713. * > 12 when midnight changeover, but then cannot generate
  7714. * midnight datetime, so jump to 1AM, otherwise reset.
  7715. * @param date (Date) the date to check
  7716. * @return (Date) the corrected date
  7717. */
  7718. _daylightSavingAdjust: function(date) {
  7719. if (!date) {
  7720. return null;
  7721. }
  7722. date.setHours(date.getHours() > 12 ? date.getHours() + 2 : 0);
  7723. return date;
  7724. },
  7725. /* Set the date(s) directly. */
  7726. _setDate: function(inst, date, noChange) {
  7727. var clear = !date,
  7728. origMonth = inst.selectedMonth,
  7729. origYear = inst.selectedYear,
  7730. newDate = this._restrictMinMax(inst, this._determineDate(inst, date, new Date()));
  7731. inst.selectedDay = inst.currentDay = newDate.getDate();
  7732. inst.drawMonth = inst.selectedMonth = inst.currentMonth = newDate.getMonth();
  7733. inst.drawYear = inst.selectedYear = inst.currentYear = newDate.getFullYear();
  7734. if ((origMonth !== inst.selectedMonth || origYear !== inst.selectedYear) && !noChange) {
  7735. this._notifyChange(inst);
  7736. }
  7737. this._adjustInstDate(inst);
  7738. if (inst.input) {
  7739. inst.input.val(clear ? "" : this._formatDate(inst));
  7740. }
  7741. },
  7742. /* Retrieve the date(s) directly. */
  7743. _getDate: function(inst) {
  7744. var startDate = (!inst.currentYear || (inst.input && inst.input.val() === "") ? null :
  7745. this._daylightSavingAdjust(new Date(
  7746. inst.currentYear, inst.currentMonth, inst.currentDay)));
  7747. return startDate;
  7748. },
  7749. /* Attach the onxxx handlers. These are declared statically so
  7750. * they work with static code transformers like Caja.
  7751. */
  7752. _attachHandlers: function(inst) {
  7753. var stepMonths = this._get(inst, "stepMonths"),
  7754. id = "#" + inst.id.replace( /\\\\/g, "\\" );
  7755. inst.dpDiv.find("[data-handler]").map(function () {
  7756. var handler = {
  7757. prev: function () {
  7758. window["DP_jQuery_" + dpuuid].datepicker._adjustDate(id, -stepMonths, "M");
  7759. },
  7760. next: function () {
  7761. window["DP_jQuery_" + dpuuid].datepicker._adjustDate(id, +stepMonths, "M");
  7762. },
  7763. hide: function () {
  7764. window["DP_jQuery_" + dpuuid].datepicker._hideDatepicker();
  7765. },
  7766. today: function () {
  7767. window["DP_jQuery_" + dpuuid].datepicker._gotoToday(id);
  7768. },
  7769. selectDay: function () {
  7770. window["DP_jQuery_" + dpuuid].datepicker._selectDay(id, +this.getAttribute("data-month"), +this.getAttribute("data-year"), this);
  7771. return false;
  7772. },
  7773. selectMonth: function () {
  7774. window["DP_jQuery_" + dpuuid].datepicker._selectMonthYear(id, this, "M");
  7775. return false;
  7776. },
  7777. selectYear: function () {
  7778. window["DP_jQuery_" + dpuuid].datepicker._selectMonthYear(id, this, "Y");
  7779. return false;
  7780. }
  7781. };
  7782. $(this).bind(this.getAttribute("data-event"), handler[this.getAttribute("data-handler")]);
  7783. });
  7784. },
  7785. /* Generate the HTML for the current state of the date picker. */
  7786. _generateHTML: function(inst) {
  7787. var maxDraw, prevText, prev, nextText, next, currentText, gotoDate,
  7788. controls, buttonPanel, firstDay, showWeek, dayNames, dayNamesMin,
  7789. monthNames, monthNamesShort, beforeShowDay, showOtherMonths,
  7790. selectOtherMonths, defaultDate, html, dow, row, group, col, selectedDate,
  7791. cornerClass, calender, thead, day, daysInMonth, leadDays, curRows, numRows,
  7792. printDate, dRow, tbody, daySettings, otherMonth, unselectable,
  7793. tempDate = new Date(),
  7794. today = this._daylightSavingAdjust(
  7795. new Date(tempDate.getFullYear(), tempDate.getMonth(), tempDate.getDate())), // clear time
  7796. isRTL = this._get(inst, "isRTL"),
  7797. showButtonPanel = this._get(inst, "showButtonPanel"),
  7798. hideIfNoPrevNext = this._get(inst, "hideIfNoPrevNext"),
  7799. navigationAsDateFormat = this._get(inst, "navigationAsDateFormat"),
  7800. numMonths = this._getNumberOfMonths(inst),
  7801. showCurrentAtPos = this._get(inst, "showCurrentAtPos"),
  7802. stepMonths = this._get(inst, "stepMonths"),
  7803. isMultiMonth = (numMonths[0] !== 1 || numMonths[1] !== 1),
  7804. currentDate = this._daylightSavingAdjust((!inst.currentDay ? new Date(9999, 9, 9) :
  7805. new Date(inst.currentYear, inst.currentMonth, inst.currentDay))),
  7806. minDate = this._getMinMaxDate(inst, "min"),
  7807. maxDate = this._getMinMaxDate(inst, "max"),
  7808. drawMonth = inst.drawMonth - showCurrentAtPos,
  7809. drawYear = inst.drawYear;
  7810. if (drawMonth < 0) {
  7811. drawMonth += 12;
  7812. drawYear--;
  7813. }
  7814. if (maxDate) {
  7815. maxDraw = this._daylightSavingAdjust(new Date(maxDate.getFullYear(),
  7816. maxDate.getMonth() - (numMonths[0] * numMonths[1]) + 1, maxDate.getDate()));
  7817. maxDraw = (minDate && maxDraw < minDate ? minDate : maxDraw);
  7818. while (this._daylightSavingAdjust(new Date(drawYear, drawMonth, 1)) > maxDraw) {
  7819. drawMonth--;
  7820. if (drawMonth < 0) {
  7821. drawMonth = 11;
  7822. drawYear--;
  7823. }
  7824. }
  7825. }
  7826. inst.drawMonth = drawMonth;
  7827. inst.drawYear = drawYear;
  7828. prevText = this._get(inst, "prevText");
  7829. prevText = (!navigationAsDateFormat ? prevText : this.formatDate(prevText,
  7830. this._daylightSavingAdjust(new Date(drawYear, drawMonth - stepMonths, 1)),
  7831. this._getFormatConfig(inst)));
  7832. prev = (this._canAdjustMonth(inst, -1, drawYear, drawMonth) ?
  7833. "<a class='ui-datepicker-prev ui-corner-all' data-handler='prev' data-event='click'" +
  7834. " title='" + prevText + "'><span class='ui-icon ui-icon-circle-triangle-" + ( isRTL ? "e" : "w") + "'>" + prevText + "</span></a>" :
  7835. (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>"));
  7836. nextText = this._get(inst, "nextText");
  7837. nextText = (!navigationAsDateFormat ? nextText : this.formatDate(nextText,
  7838. this._daylightSavingAdjust(new Date(drawYear, drawMonth + stepMonths, 1)),
  7839. this._getFormatConfig(inst)));
  7840. next = (this._canAdjustMonth(inst, +1, drawYear, drawMonth) ?
  7841. "<a class='ui-datepicker-next ui-corner-all' data-handler='next' data-event='click'" +
  7842. " title='" + nextText + "'><span class='ui-icon ui-icon-circle-triangle-" + ( isRTL ? "w" : "e") + "'>" + nextText + "</span></a>" :
  7843. (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>"));
  7844. currentText = this._get(inst, "currentText");
  7845. gotoDate = (this._get(inst, "gotoCurrent") && inst.currentDay ? currentDate : today);
  7846. currentText = (!navigationAsDateFormat ? currentText :
  7847. this.formatDate(currentText, gotoDate, this._getFormatConfig(inst)));
  7848. 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'>" +
  7849. this._get(inst, "closeText") + "</button>" : "");
  7850. buttonPanel = (showButtonPanel) ? "<div class='ui-datepicker-buttonpane ui-widget-content'>" + (isRTL ? controls : "") +
  7851. (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'" +
  7852. ">" + currentText + "</button>" : "") + (isRTL ? "" : controls) + "</div>" : "";
  7853. firstDay = parseInt(this._get(inst, "firstDay"),10);
  7854. firstDay = (isNaN(firstDay) ? 0 : firstDay);
  7855. showWeek = this._get(inst, "showWeek");
  7856. dayNames = this._get(inst, "dayNames");
  7857. dayNamesMin = this._get(inst, "dayNamesMin");
  7858. monthNames = this._get(inst, "monthNames");
  7859. monthNamesShort = this._get(inst, "monthNamesShort");
  7860. beforeShowDay = this._get(inst, "beforeShowDay");
  7861. showOtherMonths = this._get(inst, "showOtherMonths");
  7862. selectOtherMonths = this._get(inst, "selectOtherMonths");
  7863. defaultDate = this._getDefaultDate(inst);
  7864. html = "";
  7865. dow;
  7866. for (row = 0; row < numMonths[0]; row++) {
  7867. group = "";
  7868. this.maxRows = 4;
  7869. for (col = 0; col < numMonths[1]; col++) {
  7870. selectedDate = this._daylightSavingAdjust(new Date(drawYear, drawMonth, inst.selectedDay));
  7871. cornerClass = " ui-corner-all";
  7872. calender = "";
  7873. if (isMultiMonth) {
  7874. calender += "<div class='ui-datepicker-group";
  7875. if (numMonths[1] > 1) {
  7876. switch (col) {
  7877. case 0: calender += " ui-datepicker-group-first";
  7878. cornerClass = " ui-corner-" + (isRTL ? "right" : "left"); break;
  7879. case numMonths[1]-1: calender += " ui-datepicker-group-last";
  7880. cornerClass = " ui-corner-" + (isRTL ? "left" : "right"); break;
  7881. default: calender += " ui-datepicker-group-middle"; cornerClass = ""; break;
  7882. }
  7883. }
  7884. calender += "'>";
  7885. }
  7886. calender += "<div class='ui-datepicker-header ui-widget-header ui-helper-clearfix" + cornerClass + "'>" +
  7887. (/all|left/.test(cornerClass) && row === 0 ? (isRTL ? next : prev) : "") +
  7888. (/all|right/.test(cornerClass) && row === 0 ? (isRTL ? prev : next) : "") +
  7889. this._generateMonthYearHeader(inst, drawMonth, drawYear, minDate, maxDate,
  7890. row > 0 || col > 0, monthNames, monthNamesShort) + // draw month headers
  7891. "</div><table class='ui-datepicker-calendar'><thead>" +
  7892. "<tr>";
  7893. thead = (showWeek ? "<th class='ui-datepicker-week-col'>" + this._get(inst, "weekHeader") + "</th>" : "");
  7894. for (dow = 0; dow < 7; dow++) { // days of the week
  7895. day = (dow + firstDay) % 7;
  7896. thead += "<th" + ((dow + firstDay + 6) % 7 >= 5 ? " class='ui-datepicker-week-end'" : "") + ">" +
  7897. "<span title='" + dayNames[day] + "'>" + dayNamesMin[day] + "</span></th>";
  7898. }
  7899. calender += thead + "</tr></thead><tbody>";
  7900. daysInMonth = this._getDaysInMonth(drawYear, drawMonth);
  7901. if (drawYear === inst.selectedYear && drawMonth === inst.selectedMonth) {
  7902. inst.selectedDay = Math.min(inst.selectedDay, daysInMonth);
  7903. }
  7904. leadDays = (this._getFirstDayOfMonth(drawYear, drawMonth) - firstDay + 7) % 7;
  7905. curRows = Math.ceil((leadDays + daysInMonth) / 7); // calculate the number of rows to generate
  7906. numRows = (isMultiMonth ? this.maxRows > curRows ? this.maxRows : curRows : curRows); //If multiple months, use the higher number of rows (see #7043)
  7907. this.maxRows = numRows;
  7908. printDate = this._daylightSavingAdjust(new Date(drawYear, drawMonth, 1 - leadDays));
  7909. for (dRow = 0; dRow < numRows; dRow++) { // create date picker rows
  7910. calender += "<tr>";
  7911. tbody = (!showWeek ? "" : "<td class='ui-datepicker-week-col'>" +
  7912. this._get(inst, "calculateWeek")(printDate) + "</td>");
  7913. for (dow = 0; dow < 7; dow++) { // create date picker days
  7914. daySettings = (beforeShowDay ?
  7915. beforeShowDay.apply((inst.input ? inst.input[0] : null), [printDate]) : [true, ""]);
  7916. otherMonth = (printDate.getMonth() !== drawMonth);
  7917. unselectable = (otherMonth && !selectOtherMonths) || !daySettings[0] ||
  7918. (minDate && printDate < minDate) || (maxDate && printDate > maxDate);
  7919. tbody += "<td class='" +
  7920. ((dow + firstDay + 6) % 7 >= 5 ? " ui-datepicker-week-end" : "") + // highlight weekends
  7921. (otherMonth ? " ui-datepicker-other-month" : "") + // highlight days from other months
  7922. ((printDate.getTime() === selectedDate.getTime() && drawMonth === inst.selectedMonth && inst._keyEvent) || // user pressed key
  7923. (defaultDate.getTime() === printDate.getTime() && defaultDate.getTime() === selectedDate.getTime()) ?
  7924. // or defaultDate is current printedDate and defaultDate is selectedDate
  7925. " " + this._dayOverClass : "") + // highlight selected day
  7926. (unselectable ? " " + this._unselectableClass + " ui-state-disabled": "") + // highlight unselectable days
  7927. (otherMonth && !showOtherMonths ? "" : " " + daySettings[1] + // highlight custom dates
  7928. (printDate.getTime() === currentDate.getTime() ? " " + this._currentClass : "") + // highlight selected day
  7929. (printDate.getTime() === today.getTime() ? " ui-datepicker-today" : "")) + "'" + // highlight today (if different)
  7930. ((!otherMonth || showOtherMonths) && daySettings[2] ? " title='" + daySettings[2].replace(/'/g, "&#39;") + "'" : "") + // cell title
  7931. (unselectable ? "" : " data-handler='selectDay' data-event='click' data-month='" + printDate.getMonth() + "' data-year='" + printDate.getFullYear() + "'") + ">" + // actions
  7932. (otherMonth && !showOtherMonths ? "&#xa0;" : // display for other months
  7933. (unselectable ? "<span class='ui-state-default'>" + printDate.getDate() + "</span>" : "<a class='ui-state-default" +
  7934. (printDate.getTime() === today.getTime() ? " ui-state-highlight" : "") +
  7935. (printDate.getTime() === currentDate.getTime() ? " ui-state-active" : "") + // highlight selected day
  7936. (otherMonth ? " ui-priority-secondary" : "") + // distinguish dates from other months
  7937. "' href='#'>" + printDate.getDate() + "</a>")) + "</td>"; // display selectable date
  7938. printDate.setDate(printDate.getDate() + 1);
  7939. printDate = this._daylightSavingAdjust(printDate);
  7940. }
  7941. calender += tbody + "</tr>";
  7942. }
  7943. drawMonth++;
  7944. if (drawMonth > 11) {
  7945. drawMonth = 0;
  7946. drawYear++;
  7947. }
  7948. calender += "</tbody></table>" + (isMultiMonth ? "</div>" +
  7949. ((numMonths[0] > 0 && col === numMonths[1]-1) ? "<div class='ui-datepicker-row-break'></div>" : "") : "");
  7950. group += calender;
  7951. }
  7952. html += group;
  7953. }
  7954. html += buttonPanel;
  7955. inst._keyEvent = false;
  7956. return html;
  7957. },
  7958. /* Generate the month and year header. */
  7959. _generateMonthYearHeader: function(inst, drawMonth, drawYear, minDate, maxDate,
  7960. secondary, monthNames, monthNamesShort) {
  7961. var inMinYear, inMaxYear, month, years, thisYear, determineYear, year, endYear,
  7962. changeMonth = this._get(inst, "changeMonth"),
  7963. changeYear = this._get(inst, "changeYear"),
  7964. showMonthAfterYear = this._get(inst, "showMonthAfterYear"),
  7965. html = "<div class='ui-datepicker-title'>",
  7966. monthHtml = "";
  7967. // month selection
  7968. if (secondary || !changeMonth) {
  7969. monthHtml += "<span class='ui-datepicker-month'>" + monthNames[drawMonth] + "</span>";
  7970. } else {
  7971. inMinYear = (minDate && minDate.getFullYear() === drawYear);
  7972. inMaxYear = (maxDate && maxDate.getFullYear() === drawYear);
  7973. monthHtml += "<select class='ui-datepicker-month' data-handler='selectMonth' data-event='change'>";
  7974. for ( month = 0; month < 12; month++) {
  7975. if ((!inMinYear || month >= minDate.getMonth()) && (!inMaxYear || month <= maxDate.getMonth())) {
  7976. monthHtml += "<option value='" + month + "'" +
  7977. (month === drawMonth ? " selected='selected'" : "") +
  7978. ">" + monthNamesShort[month] + "</option>";
  7979. }
  7980. }
  7981. monthHtml += "</select>";
  7982. }
  7983. if (!showMonthAfterYear) {
  7984. html += monthHtml + (secondary || !(changeMonth && changeYear) ? "&#xa0;" : "");
  7985. }
  7986. // year selection
  7987. if ( !inst.yearshtml ) {
  7988. inst.yearshtml = "";
  7989. if (secondary || !changeYear) {
  7990. html += "<span class='ui-datepicker-year'>" + drawYear + "</span>";
  7991. } else {
  7992. // determine range of years to display
  7993. years = this._get(inst, "yearRange").split(":");
  7994. thisYear = new Date().getFullYear();
  7995. determineYear = function(value) {
  7996. var year = (value.match(/c[+\-].*/) ? drawYear + parseInt(value.substring(1), 10) :
  7997. (value.match(/[+\-].*/) ? thisYear + parseInt(value, 10) :
  7998. parseInt(value, 10)));
  7999. return (isNaN(year) ? thisYear : year);
  8000. };
  8001. year = determineYear(years[0]);
  8002. endYear = Math.max(year, determineYear(years[1] || ""));
  8003. year = (minDate ? Math.max(year, minDate.getFullYear()) : year);
  8004. endYear = (maxDate ? Math.min(endYear, maxDate.getFullYear()) : endYear);
  8005. inst.yearshtml += "<select class='ui-datepicker-year' data-handler='selectYear' data-event='change'>";
  8006. for (; year <= endYear; year++) {
  8007. inst.yearshtml += "<option value='" + year + "'" +
  8008. (year === drawYear ? " selected='selected'" : "") +
  8009. ">" + year + "</option>";
  8010. }
  8011. inst.yearshtml += "</select>";
  8012. html += inst.yearshtml;
  8013. inst.yearshtml = null;
  8014. }
  8015. }
  8016. html += this._get(inst, "yearSuffix");
  8017. if (showMonthAfterYear) {
  8018. html += (secondary || !(changeMonth && changeYear) ? "&#xa0;" : "") + monthHtml;
  8019. }
  8020. html += "</div>"; // Close datepicker_header
  8021. return html;
  8022. },
  8023. /* Adjust one of the date sub-fields. */
  8024. _adjustInstDate: function(inst, offset, period) {
  8025. var year = inst.drawYear + (period === "Y" ? offset : 0),
  8026. month = inst.drawMonth + (period === "M" ? offset : 0),
  8027. day = Math.min(inst.selectedDay, this._getDaysInMonth(year, month)) + (period === "D" ? offset : 0),
  8028. date = this._restrictMinMax(inst, this._daylightSavingAdjust(new Date(year, month, day)));
  8029. inst.selectedDay = date.getDate();
  8030. inst.drawMonth = inst.selectedMonth = date.getMonth();
  8031. inst.drawYear = inst.selectedYear = date.getFullYear();
  8032. if (period === "M" || period === "Y") {
  8033. this._notifyChange(inst);
  8034. }
  8035. },
  8036. /* Ensure a date is within any min/max bounds. */
  8037. _restrictMinMax: function(inst, date) {
  8038. var minDate = this._getMinMaxDate(inst, "min"),
  8039. maxDate = this._getMinMaxDate(inst, "max"),
  8040. newDate = (minDate && date < minDate ? minDate : date);
  8041. return (maxDate && newDate > maxDate ? maxDate : newDate);
  8042. },
  8043. /* Notify change of month/year. */
  8044. _notifyChange: function(inst) {
  8045. var onChange = this._get(inst, "onChangeMonthYear");
  8046. if (onChange) {
  8047. onChange.apply((inst.input ? inst.input[0] : null),
  8048. [inst.selectedYear, inst.selectedMonth + 1, inst]);
  8049. }
  8050. },
  8051. /* Determine the number of months to show. */
  8052. _getNumberOfMonths: function(inst) {
  8053. var numMonths = this._get(inst, "numberOfMonths");
  8054. return (numMonths == null ? [1, 1] : (typeof numMonths === "number" ? [1, numMonths] : numMonths));
  8055. },
  8056. /* Determine the current maximum date - ensure no time components are set. */
  8057. _getMinMaxDate: function(inst, minMax) {
  8058. return this._determineDate(inst, this._get(inst, minMax + "Date"), null);
  8059. },
  8060. /* Find the number of days in a given month. */
  8061. _getDaysInMonth: function(year, month) {
  8062. return 32 - this._daylightSavingAdjust(new Date(year, month, 32)).getDate();
  8063. },
  8064. /* Find the day of the week of the first of a month. */
  8065. _getFirstDayOfMonth: function(year, month) {
  8066. return new Date(year, month, 1).getDay();
  8067. },
  8068. /* Determines if we should allow a "next/prev" month display change. */
  8069. _canAdjustMonth: function(inst, offset, curYear, curMonth) {
  8070. var numMonths = this._getNumberOfMonths(inst),
  8071. date = this._daylightSavingAdjust(new Date(curYear,
  8072. curMonth + (offset < 0 ? offset : numMonths[0] * numMonths[1]), 1));
  8073. if (offset < 0) {
  8074. date.setDate(this._getDaysInMonth(date.getFullYear(), date.getMonth()));
  8075. }
  8076. return this._isInRange(inst, date);
  8077. },
  8078. /* Is the given date in the accepted range? */
  8079. _isInRange: function(inst, date) {
  8080. var yearSplit, currentYear,
  8081. minDate = this._getMinMaxDate(inst, "min"),
  8082. maxDate = this._getMinMaxDate(inst, "max"),
  8083. minYear = null,
  8084. maxYear = null,
  8085. years = this._get(inst, "yearRange");
  8086. if (years){
  8087. yearSplit = years.split(":");
  8088. currentYear = new Date().getFullYear();
  8089. minYear = parseInt(yearSplit[0], 10);
  8090. maxYear = parseInt(yearSplit[1], 10);
  8091. if ( yearSplit[0].match(/[+\-].*/) ) {
  8092. minYear += currentYear;
  8093. }
  8094. if ( yearSplit[1].match(/[+\-].*/) ) {
  8095. maxYear += currentYear;
  8096. }
  8097. }
  8098. return ((!minDate || date.getTime() >= minDate.getTime()) &&
  8099. (!maxDate || date.getTime() <= maxDate.getTime()) &&
  8100. (!minYear || date.getFullYear() >= minYear) &&
  8101. (!maxYear || date.getFullYear() <= maxYear));
  8102. },
  8103. /* Provide the configuration settings for formatting/parsing. */
  8104. _getFormatConfig: function(inst) {
  8105. var shortYearCutoff = this._get(inst, "shortYearCutoff");
  8106. shortYearCutoff = (typeof shortYearCutoff !== "string" ? shortYearCutoff :
  8107. new Date().getFullYear() % 100 + parseInt(shortYearCutoff, 10));
  8108. return {shortYearCutoff: shortYearCutoff,
  8109. dayNamesShort: this._get(inst, "dayNamesShort"), dayNames: this._get(inst, "dayNames"),
  8110. monthNamesShort: this._get(inst, "monthNamesShort"), monthNames: this._get(inst, "monthNames")};
  8111. },
  8112. /* Format the given date for display. */
  8113. _formatDate: function(inst, day, month, year) {
  8114. if (!day) {
  8115. inst.currentDay = inst.selectedDay;
  8116. inst.currentMonth = inst.selectedMonth;
  8117. inst.currentYear = inst.selectedYear;
  8118. }
  8119. var date = (day ? (typeof day === "object" ? day :
  8120. this._daylightSavingAdjust(new Date(year, month, day))) :
  8121. this._daylightSavingAdjust(new Date(inst.currentYear, inst.currentMonth, inst.currentDay)));
  8122. return this.formatDate(this._get(inst, "dateFormat"), date, this._getFormatConfig(inst));
  8123. }
  8124. });
  8125. /*
  8126. * Bind hover events for datepicker elements.
  8127. * Done via delegate so the binding only occurs once in the lifetime of the parent div.
  8128. * Global instActive, set by _updateDatepicker allows the handlers to find their way back to the active picker.
  8129. */
  8130. function bindHover(dpDiv) {
  8131. var selector = "button, .ui-datepicker-prev, .ui-datepicker-next, .ui-datepicker-calendar td a";
  8132. return dpDiv.delegate(selector, "mouseout", function() {
  8133. $(this).removeClass("ui-state-hover");
  8134. if (this.className.indexOf("ui-datepicker-prev") !== -1) {
  8135. $(this).removeClass("ui-datepicker-prev-hover");
  8136. }
  8137. if (this.className.indexOf("ui-datepicker-next") !== -1) {
  8138. $(this).removeClass("ui-datepicker-next-hover");
  8139. }
  8140. })
  8141. .delegate(selector, "mouseover", function(){
  8142. if (!$.datepicker._isDisabledDatepicker( instActive.inline ? dpDiv.parent()[0] : instActive.input[0])) {
  8143. $(this).parents(".ui-datepicker-calendar").find("a").removeClass("ui-state-hover");
  8144. $(this).addClass("ui-state-hover");
  8145. if (this.className.indexOf("ui-datepicker-prev") !== -1) {
  8146. $(this).addClass("ui-datepicker-prev-hover");
  8147. }
  8148. if (this.className.indexOf("ui-datepicker-next") !== -1) {
  8149. $(this).addClass("ui-datepicker-next-hover");
  8150. }
  8151. }
  8152. });
  8153. }
  8154. /* jQuery extend now ignores nulls! */
  8155. function extendRemove(target, props) {
  8156. $.extend(target, props);
  8157. for (var name in props) {
  8158. if (props[name] == null) {
  8159. target[name] = props[name];
  8160. }
  8161. }
  8162. return target;
  8163. }
  8164. /* Invoke the datepicker functionality.
  8165. @param options string - a command, optionally followed by additional parameters or
  8166. Object - settings for attaching new datepicker functionality
  8167. @return jQuery object */
  8168. $.fn.datepicker = function(options){
  8169. /* Verify an empty collection wasn't passed - Fixes #6976 */
  8170. if ( !this.length ) {
  8171. return this;
  8172. }
  8173. /* Initialise the date picker. */
  8174. if (!$.datepicker.initialized) {
  8175. $(document).mousedown($.datepicker._checkExternalClick);
  8176. $.datepicker.initialized = true;
  8177. }
  8178. /* Append datepicker main container to body if not exist. */
  8179. if ($("#"+$.datepicker._mainDivId).length === 0) {
  8180. $("body").append($.datepicker.dpDiv);
  8181. }
  8182. var otherArgs = Array.prototype.slice.call(arguments, 1);
  8183. if (typeof options === "string" && (options === "isDisabled" || options === "getDate" || options === "widget")) {
  8184. return $.datepicker["_" + options + "Datepicker"].
  8185. apply($.datepicker, [this[0]].concat(otherArgs));
  8186. }
  8187. if (options === "option" && arguments.length === 2 && typeof arguments[1] === "string") {
  8188. return $.datepicker["_" + options + "Datepicker"].
  8189. apply($.datepicker, [this[0]].concat(otherArgs));
  8190. }
  8191. return this.each(function() {
  8192. typeof options === "string" ?
  8193. $.datepicker["_" + options + "Datepicker"].
  8194. apply($.datepicker, [this].concat(otherArgs)) :
  8195. $.datepicker._attachDatepicker(this, options);
  8196. });
  8197. };
  8198. $.datepicker = new Datepicker(); // singleton instance
  8199. $.datepicker.initialized = false;
  8200. $.datepicker.uuid = new Date().getTime();
  8201. $.datepicker.version = "1.10.1";
  8202. // Workaround for #4055
  8203. // Add another global to avoid noConflict issues with inline event handlers
  8204. window["DP_jQuery_" + dpuuid] = $;
  8205. })(jQuery);
  8206. (function( $, undefined ) {
  8207. var sizeRelatedOptions = {
  8208. buttons: true,
  8209. height: true,
  8210. maxHeight: true,
  8211. maxWidth: true,
  8212. minHeight: true,
  8213. minWidth: true,
  8214. width: true
  8215. },
  8216. resizableRelatedOptions = {
  8217. maxHeight: true,
  8218. maxWidth: true,
  8219. minHeight: true,
  8220. minWidth: true
  8221. };
  8222. $.widget( "ui.dialog", {
  8223. version: "1.10.1",
  8224. options: {
  8225. appendTo: "body",
  8226. autoOpen: true,
  8227. buttons: [],
  8228. closeOnEscape: true,
  8229. closeText: "close",
  8230. dialogClass: "",
  8231. draggable: true,
  8232. hide: null,
  8233. height: "auto",
  8234. maxHeight: null,
  8235. maxWidth: null,
  8236. minHeight: 150,
  8237. minWidth: 150,
  8238. modal: false,
  8239. position: {
  8240. my: "center",
  8241. at: "center",
  8242. of: window,
  8243. collision: "fit",
  8244. // Ensure the titlebar is always visible
  8245. using: function( pos ) {
  8246. var topOffset = $( this ).css( pos ).offset().top;
  8247. if ( topOffset < 0 ) {
  8248. $( this ).css( "top", pos.top - topOffset );
  8249. }
  8250. }
  8251. },
  8252. resizable: true,
  8253. show: null,
  8254. title: null,
  8255. width: 300,
  8256. // callbacks
  8257. beforeClose: null,
  8258. close: null,
  8259. drag: null,
  8260. dragStart: null,
  8261. dragStop: null,
  8262. focus: null,
  8263. open: null,
  8264. resize: null,
  8265. resizeStart: null,
  8266. resizeStop: null
  8267. },
  8268. _create: function() {
  8269. this.originalCss = {
  8270. display: this.element[0].style.display,
  8271. width: this.element[0].style.width,
  8272. minHeight: this.element[0].style.minHeight,
  8273. maxHeight: this.element[0].style.maxHeight,
  8274. height: this.element[0].style.height
  8275. };
  8276. this.originalPosition = {
  8277. parent: this.element.parent(),
  8278. index: this.element.parent().children().index( this.element )
  8279. };
  8280. this.originalTitle = this.element.attr("title");
  8281. this.options.title = this.options.title || this.originalTitle;
  8282. this._createWrapper();
  8283. this.element
  8284. .show()
  8285. .removeAttr("title")
  8286. .addClass("ui-dialog-content ui-widget-content")
  8287. .appendTo( this.uiDialog );
  8288. this._createTitlebar();
  8289. this._createButtonPane();
  8290. if ( this.options.draggable && $.fn.draggable ) {
  8291. this._makeDraggable();
  8292. }
  8293. if ( this.options.resizable && $.fn.resizable ) {
  8294. this._makeResizable();
  8295. }
  8296. this._isOpen = false;
  8297. },
  8298. _init: function() {
  8299. if ( this.options.autoOpen ) {
  8300. this.open();
  8301. }
  8302. },
  8303. _appendTo: function() {
  8304. var element = this.options.appendTo;
  8305. if ( element && (element.jquery || element.nodeType) ) {
  8306. return $( element );
  8307. }
  8308. return this.document.find( element || "body" ).eq( 0 );
  8309. },
  8310. _destroy: function() {
  8311. var next,
  8312. originalPosition = this.originalPosition;
  8313. this._destroyOverlay();
  8314. this.element
  8315. .removeUniqueId()
  8316. .removeClass("ui-dialog-content ui-widget-content")
  8317. .css( this.originalCss )
  8318. // Without detaching first, the following becomes really slow
  8319. .detach();
  8320. this.uiDialog.stop( true, true ).remove();
  8321. if ( this.originalTitle ) {
  8322. this.element.attr( "title", this.originalTitle );
  8323. }
  8324. next = originalPosition.parent.children().eq( originalPosition.index );
  8325. // Don't try to place the dialog next to itself (#8613)
  8326. if ( next.length && next[0] !== this.element[0] ) {
  8327. next.before( this.element );
  8328. } else {
  8329. originalPosition.parent.append( this.element );
  8330. }
  8331. },
  8332. widget: function() {
  8333. return this.uiDialog;
  8334. },
  8335. disable: $.noop,
  8336. enable: $.noop,
  8337. close: function( event ) {
  8338. var that = this;
  8339. if ( !this._isOpen || this._trigger( "beforeClose", event ) === false ) {
  8340. return;
  8341. }
  8342. this._isOpen = false;
  8343. this._destroyOverlay();
  8344. if ( !this.opener.filter(":focusable").focus().length ) {
  8345. // Hiding a focused element doesn't trigger blur in WebKit
  8346. // so in case we have nothing to focus on, explicitly blur the active element
  8347. // https://bugs.webkit.org/show_bug.cgi?id=47182
  8348. $( this.document[0].activeElement ).blur();
  8349. }
  8350. this._hide( this.uiDialog, this.options.hide, function() {
  8351. that._trigger( "close", event );
  8352. });
  8353. },
  8354. isOpen: function() {
  8355. return this._isOpen;
  8356. },
  8357. moveToTop: function() {
  8358. this._moveToTop();
  8359. },
  8360. _moveToTop: function( event, silent ) {
  8361. var moved = !!this.uiDialog.nextAll(":visible").insertBefore( this.uiDialog ).length;
  8362. if ( moved && !silent ) {
  8363. this._trigger( "focus", event );
  8364. }
  8365. return moved;
  8366. },
  8367. open: function() {
  8368. var that = this;
  8369. if ( this._isOpen ) {
  8370. if ( this._moveToTop() ) {
  8371. this._focusTabbable();
  8372. }
  8373. return;
  8374. }
  8375. this._isOpen = true;
  8376. this.opener = $( this.document[0].activeElement );
  8377. this._size();
  8378. this._position();
  8379. this._createOverlay();
  8380. this._moveToTop( null, true );
  8381. this._show( this.uiDialog, this.options.show, function() {
  8382. that._focusTabbable();
  8383. that._trigger("focus");
  8384. });
  8385. this._trigger("open");
  8386. },
  8387. _focusTabbable: function() {
  8388. // Set focus to the first match:
  8389. // 1. First element inside the dialog matching [autofocus]
  8390. // 2. Tabbable element inside the content element
  8391. // 3. Tabbable element inside the buttonpane
  8392. // 4. The close button
  8393. // 5. The dialog itself
  8394. var hasFocus = this.element.find("[autofocus]");
  8395. if ( !hasFocus.length ) {
  8396. hasFocus = this.element.find(":tabbable");
  8397. }
  8398. if ( !hasFocus.length ) {
  8399. hasFocus = this.uiDialogButtonPane.find(":tabbable");
  8400. }
  8401. if ( !hasFocus.length ) {
  8402. hasFocus = this.uiDialogTitlebarClose.filter(":tabbable");
  8403. }
  8404. if ( !hasFocus.length ) {
  8405. hasFocus = this.uiDialog;
  8406. }
  8407. hasFocus.eq( 0 ).focus();
  8408. },
  8409. _keepFocus: function( event ) {
  8410. function checkFocus() {
  8411. var activeElement = this.document[0].activeElement,
  8412. isActive = this.uiDialog[0] === activeElement ||
  8413. $.contains( this.uiDialog[0], activeElement );
  8414. if ( !isActive ) {
  8415. this._focusTabbable();
  8416. }
  8417. }
  8418. event.preventDefault();
  8419. checkFocus.call( this );
  8420. // support: IE
  8421. // IE <= 8 doesn't prevent moving focus even with event.preventDefault()
  8422. // so we check again later
  8423. this._delay( checkFocus );
  8424. },
  8425. _createWrapper: function() {
  8426. this.uiDialog = $("<div>")
  8427. .addClass( "ui-dialog ui-widget ui-widget-content ui-corner-all ui-front " +
  8428. this.options.dialogClass )
  8429. .hide()
  8430. .attr({
  8431. // Setting tabIndex makes the div focusable
  8432. tabIndex: -1,
  8433. role: "dialog"
  8434. })
  8435. .appendTo( this._appendTo() );
  8436. this._on( this.uiDialog, {
  8437. keydown: function( event ) {
  8438. if ( this.options.closeOnEscape && !event.isDefaultPrevented() && event.keyCode &&
  8439. event.keyCode === $.ui.keyCode.ESCAPE ) {
  8440. event.preventDefault();
  8441. this.close( event );
  8442. return;
  8443. }
  8444. // prevent tabbing out of dialogs
  8445. if ( event.keyCode !== $.ui.keyCode.TAB ) {
  8446. return;
  8447. }
  8448. var tabbables = this.uiDialog.find(":tabbable"),
  8449. first = tabbables.filter(":first"),
  8450. last = tabbables.filter(":last");
  8451. if ( ( event.target === last[0] || event.target === this.uiDialog[0] ) && !event.shiftKey ) {
  8452. first.focus( 1 );
  8453. event.preventDefault();
  8454. } else if ( ( event.target === first[0] || event.target === this.uiDialog[0] ) && event.shiftKey ) {
  8455. last.focus( 1 );
  8456. event.preventDefault();
  8457. }
  8458. },
  8459. mousedown: function( event ) {
  8460. if ( this._moveToTop( event ) ) {
  8461. this._focusTabbable();
  8462. }
  8463. }
  8464. });
  8465. // We assume that any existing aria-describedby attribute means
  8466. // that the dialog content is marked up properly
  8467. // otherwise we brute force the content as the description
  8468. if ( !this.element.find("[aria-describedby]").length ) {
  8469. this.uiDialog.attr({
  8470. "aria-describedby": this.element.uniqueId().attr("id")
  8471. });
  8472. }
  8473. },
  8474. _createTitlebar: function() {
  8475. var uiDialogTitle;
  8476. this.uiDialogTitlebar = $("<div>")
  8477. .addClass("ui-dialog-titlebar ui-widget-header ui-corner-all ui-helper-clearfix")
  8478. .prependTo( this.uiDialog );
  8479. this._on( this.uiDialogTitlebar, {
  8480. mousedown: function( event ) {
  8481. // Don't prevent click on close button (#8838)
  8482. // Focusing a dialog that is partially scrolled out of view
  8483. // causes the browser to scroll it into view, preventing the click event
  8484. if ( !$( event.target ).closest(".ui-dialog-titlebar-close") ) {
  8485. // Dialog isn't getting focus when dragging (#8063)
  8486. this.uiDialog.focus();
  8487. }
  8488. }
  8489. });
  8490. this.uiDialogTitlebarClose = $("<button></button>")
  8491. .button({
  8492. label: this.options.closeText,
  8493. icons: {
  8494. primary: "ui-icon-closethick"
  8495. },
  8496. text: false
  8497. })
  8498. .addClass("ui-dialog-titlebar-close")
  8499. .appendTo( this.uiDialogTitlebar );
  8500. this._on( this.uiDialogTitlebarClose, {
  8501. click: function( event ) {
  8502. event.preventDefault();
  8503. this.close( event );
  8504. }
  8505. });
  8506. uiDialogTitle = $("<span>")
  8507. .uniqueId()
  8508. .addClass("ui-dialog-title")
  8509. .prependTo( this.uiDialogTitlebar );
  8510. this._title( uiDialogTitle );
  8511. this.uiDialog.attr({
  8512. "aria-labelledby": uiDialogTitle.attr("id")
  8513. });
  8514. },
  8515. _title: function( title ) {
  8516. if ( !this.options.title ) {
  8517. title.html("&#160;");
  8518. }
  8519. title.text( this.options.title );
  8520. },
  8521. _createButtonPane: function() {
  8522. this.uiDialogButtonPane = $("<div>")
  8523. .addClass("ui-dialog-buttonpane ui-widget-content ui-helper-clearfix");
  8524. this.uiButtonSet = $("<div>")
  8525. .addClass("ui-dialog-buttonset")
  8526. .appendTo( this.uiDialogButtonPane );
  8527. this._createButtons();
  8528. },
  8529. _createButtons: function() {
  8530. var that = this,
  8531. buttons = this.options.buttons;
  8532. // if we already have a button pane, remove it
  8533. this.uiDialogButtonPane.remove();
  8534. this.uiButtonSet.empty();
  8535. if ( $.isEmptyObject( buttons ) || ($.isArray( buttons ) && !buttons.length) ) {
  8536. this.uiDialog.removeClass("ui-dialog-buttons");
  8537. return;
  8538. }
  8539. $.each( buttons, function( name, props ) {
  8540. var click, buttonOptions;
  8541. props = $.isFunction( props ) ?
  8542. { click: props, text: name } :
  8543. props;
  8544. // Default to a non-submitting button
  8545. props = $.extend( { type: "button" }, props );
  8546. // Change the context for the click callback to be the main element
  8547. click = props.click;
  8548. props.click = function() {
  8549. click.apply( that.element[0], arguments );
  8550. };
  8551. buttonOptions = {
  8552. icons: props.icons,
  8553. text: props.showText
  8554. };
  8555. delete props.icons;
  8556. delete props.showText;
  8557. $( "<button></button>", props )
  8558. .button( buttonOptions )
  8559. .appendTo( that.uiButtonSet );
  8560. });
  8561. this.uiDialog.addClass("ui-dialog-buttons");
  8562. this.uiDialogButtonPane.appendTo( this.uiDialog );
  8563. },
  8564. _makeDraggable: function() {
  8565. var that = this,
  8566. options = this.options;
  8567. function filteredUi( ui ) {
  8568. return {
  8569. position: ui.position,
  8570. offset: ui.offset
  8571. };
  8572. }
  8573. this.uiDialog.draggable({
  8574. cancel: ".ui-dialog-content, .ui-dialog-titlebar-close",
  8575. handle: ".ui-dialog-titlebar",
  8576. containment: "document",
  8577. start: function( event, ui ) {
  8578. $( this ).addClass("ui-dialog-dragging");
  8579. that._blockFrames();
  8580. that._trigger( "dragStart", event, filteredUi( ui ) );
  8581. },
  8582. drag: function( event, ui ) {
  8583. that._trigger( "drag", event, filteredUi( ui ) );
  8584. },
  8585. stop: function( event, ui ) {
  8586. options.position = [
  8587. ui.position.left - that.document.scrollLeft(),
  8588. ui.position.top - that.document.scrollTop()
  8589. ];
  8590. $( this ).removeClass("ui-dialog-dragging");
  8591. that._unblockFrames();
  8592. that._trigger( "dragStop", event, filteredUi( ui ) );
  8593. }
  8594. });
  8595. },
  8596. _makeResizable: function() {
  8597. var that = this,
  8598. options = this.options,
  8599. handles = options.resizable,
  8600. // .ui-resizable has position: relative defined in the stylesheet
  8601. // but dialogs have to use absolute or fixed positioning
  8602. position = this.uiDialog.css("position"),
  8603. resizeHandles = typeof handles === "string" ?
  8604. handles :
  8605. "n,e,s,w,se,sw,ne,nw";
  8606. function filteredUi( ui ) {
  8607. return {
  8608. originalPosition: ui.originalPosition,
  8609. originalSize: ui.originalSize,
  8610. position: ui.position,
  8611. size: ui.size
  8612. };
  8613. }
  8614. this.uiDialog.resizable({
  8615. cancel: ".ui-dialog-content",
  8616. containment: "document",
  8617. alsoResize: this.element,
  8618. maxWidth: options.maxWidth,
  8619. maxHeight: options.maxHeight,
  8620. minWidth: options.minWidth,
  8621. minHeight: this._minHeight(),
  8622. handles: resizeHandles,
  8623. start: function( event, ui ) {
  8624. $( this ).addClass("ui-dialog-resizing");
  8625. that._blockFrames();
  8626. that._trigger( "resizeStart", event, filteredUi( ui ) );
  8627. },
  8628. resize: function( event, ui ) {
  8629. that._trigger( "resize", event, filteredUi( ui ) );
  8630. },
  8631. stop: function( event, ui ) {
  8632. options.height = $( this ).height();
  8633. options.width = $( this ).width();
  8634. $( this ).removeClass("ui-dialog-resizing");
  8635. that._unblockFrames();
  8636. that._trigger( "resizeStop", event, filteredUi( ui ) );
  8637. }
  8638. })
  8639. .css( "position", position );
  8640. },
  8641. _minHeight: function() {
  8642. var options = this.options;
  8643. return options.height === "auto" ?
  8644. options.minHeight :
  8645. Math.min( options.minHeight, options.height );
  8646. },
  8647. _position: function() {
  8648. // Need to show the dialog to get the actual offset in the position plugin
  8649. var isVisible = this.uiDialog.is(":visible");
  8650. if ( !isVisible ) {
  8651. this.uiDialog.show();
  8652. }
  8653. this.uiDialog.position( this.options.position );
  8654. if ( !isVisible ) {
  8655. this.uiDialog.hide();
  8656. }
  8657. },
  8658. _setOptions: function( options ) {
  8659. var that = this,
  8660. resize = false,
  8661. resizableOptions = {};
  8662. $.each( options, function( key, value ) {
  8663. that._setOption( key, value );
  8664. if ( key in sizeRelatedOptions ) {
  8665. resize = true;
  8666. }
  8667. if ( key in resizableRelatedOptions ) {
  8668. resizableOptions[ key ] = value;
  8669. }
  8670. });
  8671. if ( resize ) {
  8672. this._size();
  8673. this._position();
  8674. }
  8675. if ( this.uiDialog.is(":data(ui-resizable)") ) {
  8676. this.uiDialog.resizable( "option", resizableOptions );
  8677. }
  8678. },
  8679. _setOption: function( key, value ) {
  8680. /*jshint maxcomplexity:15*/
  8681. var isDraggable, isResizable,
  8682. uiDialog = this.uiDialog;
  8683. if ( key === "dialogClass" ) {
  8684. uiDialog
  8685. .removeClass( this.options.dialogClass )
  8686. .addClass( value );
  8687. }
  8688. if ( key === "disabled" ) {
  8689. return;
  8690. }
  8691. this._super( key, value );
  8692. if ( key === "appendTo" ) {
  8693. this.uiDialog.appendTo( this._appendTo() );
  8694. }
  8695. if ( key === "buttons" ) {
  8696. this._createButtons();
  8697. }
  8698. if ( key === "closeText" ) {
  8699. this.uiDialogTitlebarClose.button({
  8700. // Ensure that we always pass a string
  8701. label: "" + value
  8702. });
  8703. }
  8704. if ( key === "draggable" ) {
  8705. isDraggable = uiDialog.is(":data(ui-draggable)");
  8706. if ( isDraggable && !value ) {
  8707. uiDialog.draggable("destroy");
  8708. }
  8709. if ( !isDraggable && value ) {
  8710. this._makeDraggable();
  8711. }
  8712. }
  8713. if ( key === "position" ) {
  8714. this._position();
  8715. }
  8716. if ( key === "resizable" ) {
  8717. // currently resizable, becoming non-resizable
  8718. isResizable = uiDialog.is(":data(ui-resizable)");
  8719. if ( isResizable && !value ) {
  8720. uiDialog.resizable("destroy");
  8721. }
  8722. // currently resizable, changing handles
  8723. if ( isResizable && typeof value === "string" ) {
  8724. uiDialog.resizable( "option", "handles", value );
  8725. }
  8726. // currently non-resizable, becoming resizable
  8727. if ( !isResizable && value !== false ) {
  8728. this._makeResizable();
  8729. }
  8730. }
  8731. if ( key === "title" ) {
  8732. this._title( this.uiDialogTitlebar.find(".ui-dialog-title") );
  8733. }
  8734. },
  8735. _size: function() {
  8736. // If the user has resized the dialog, the .ui-dialog and .ui-dialog-content
  8737. // divs will both have width and height set, so we need to reset them
  8738. var nonContentHeight, minContentHeight, maxContentHeight,
  8739. options = this.options;
  8740. // Reset content sizing
  8741. this.element.show().css({
  8742. width: "auto",
  8743. minHeight: 0,
  8744. maxHeight: "none",
  8745. height: 0
  8746. });
  8747. if ( options.minWidth > options.width ) {
  8748. options.width = options.minWidth;
  8749. }
  8750. // reset wrapper sizing
  8751. // determine the height of all the non-content elements
  8752. nonContentHeight = this.uiDialog.css({
  8753. height: "auto",
  8754. width: options.width
  8755. })
  8756. .outerHeight();
  8757. minContentHeight = Math.max( 0, options.minHeight - nonContentHeight );
  8758. maxContentHeight = typeof options.maxHeight === "number" ?
  8759. Math.max( 0, options.maxHeight - nonContentHeight ) :
  8760. "none";
  8761. if ( options.height === "auto" ) {
  8762. this.element.css({
  8763. minHeight: minContentHeight,
  8764. maxHeight: maxContentHeight,
  8765. height: "auto"
  8766. });
  8767. } else {
  8768. this.element.height( Math.max( 0, options.height - nonContentHeight ) );
  8769. }
  8770. if (this.uiDialog.is(":data(ui-resizable)") ) {
  8771. this.uiDialog.resizable( "option", "minHeight", this._minHeight() );
  8772. }
  8773. },
  8774. _blockFrames: function() {
  8775. this.iframeBlocks = this.document.find( "iframe" ).map(function() {
  8776. var iframe = $( this );
  8777. return $( "<div>" )
  8778. .css({
  8779. position: "absolute",
  8780. width: iframe.outerWidth(),
  8781. height: iframe.outerHeight()
  8782. })
  8783. .appendTo( iframe.parent() )
  8784. .offset( iframe.offset() )[0];
  8785. });
  8786. },
  8787. _unblockFrames: function() {
  8788. if ( this.iframeBlocks ) {
  8789. this.iframeBlocks.remove();
  8790. delete this.iframeBlocks;
  8791. }
  8792. },
  8793. _createOverlay: function() {
  8794. if ( !this.options.modal ) {
  8795. return;
  8796. }
  8797. if ( !$.ui.dialog.overlayInstances ) {
  8798. // Prevent use of anchors and inputs.
  8799. // We use a delay in case the overlay is created from an
  8800. // event that we're going to be cancelling. (#2804)
  8801. this._delay(function() {
  8802. // Handle .dialog().dialog("close") (#4065)
  8803. if ( $.ui.dialog.overlayInstances ) {
  8804. this.document.bind( "focusin.dialog", function( event ) {
  8805. if ( !$( event.target ).closest(".ui-dialog").length &&
  8806. // TODO: Remove hack when datepicker implements
  8807. // the .ui-front logic (#8989)
  8808. !$( event.target ).closest(".ui-datepicker").length ) {
  8809. event.preventDefault();
  8810. $(".ui-dialog:visible:last .ui-dialog-content")
  8811. .data("ui-dialog")._focusTabbable();
  8812. }
  8813. });
  8814. }
  8815. });
  8816. }
  8817. this.overlay = $("<div>")
  8818. .addClass("ui-widget-overlay ui-front")
  8819. .appendTo( this._appendTo() );
  8820. this._on( this.overlay, {
  8821. mousedown: "_keepFocus"
  8822. });
  8823. $.ui.dialog.overlayInstances++;
  8824. },
  8825. _destroyOverlay: function() {
  8826. if ( !this.options.modal ) {
  8827. return;
  8828. }
  8829. if ( this.overlay ) {
  8830. $.ui.dialog.overlayInstances--;
  8831. if ( !$.ui.dialog.overlayInstances ) {
  8832. this.document.unbind( "focusin.dialog" );
  8833. }
  8834. this.overlay.remove();
  8835. this.overlay = null;
  8836. }
  8837. }
  8838. });
  8839. $.ui.dialog.overlayInstances = 0;
  8840. // DEPRECATED
  8841. if ( $.uiBackCompat !== false ) {
  8842. // position option with array notation
  8843. // just override with old implementation
  8844. $.widget( "ui.dialog", $.ui.dialog, {
  8845. _position: function() {
  8846. var position = this.options.position,
  8847. myAt = [],
  8848. offset = [ 0, 0 ],
  8849. isVisible;
  8850. if ( position ) {
  8851. if ( typeof position === "string" || (typeof position === "object" && "0" in position ) ) {
  8852. myAt = position.split ? position.split(" ") : [ position[0], position[1] ];
  8853. if ( myAt.length === 1 ) {
  8854. myAt[1] = myAt[0];
  8855. }
  8856. $.each( [ "left", "top" ], function( i, offsetPosition ) {
  8857. if ( +myAt[ i ] === myAt[ i ] ) {
  8858. offset[ i ] = myAt[ i ];
  8859. myAt[ i ] = offsetPosition;
  8860. }
  8861. });
  8862. position = {
  8863. my: myAt[0] + (offset[0] < 0 ? offset[0] : "+" + offset[0]) + " " +
  8864. myAt[1] + (offset[1] < 0 ? offset[1] : "+" + offset[1]),
  8865. at: myAt.join(" ")
  8866. };
  8867. }
  8868. position = $.extend( {}, $.ui.dialog.prototype.options.position, position );
  8869. } else {
  8870. position = $.ui.dialog.prototype.options.position;
  8871. }
  8872. // need to show the dialog to get the actual offset in the position plugin
  8873. isVisible = this.uiDialog.is(":visible");
  8874. if ( !isVisible ) {
  8875. this.uiDialog.show();
  8876. }
  8877. this.uiDialog.position( position );
  8878. if ( !isVisible ) {
  8879. this.uiDialog.hide();
  8880. }
  8881. }
  8882. });
  8883. }
  8884. }( jQuery ) );
  8885. (function( $, undefined ) {
  8886. var rvertical = /up|down|vertical/,
  8887. rpositivemotion = /up|left|vertical|horizontal/;
  8888. $.effects.effect.blind = function( o, done ) {
  8889. // Create element
  8890. var el = $( this ),
  8891. props = [ "position", "top", "bottom", "left", "right", "height", "width" ],
  8892. mode = $.effects.setMode( el, o.mode || "hide" ),
  8893. direction = o.direction || "up",
  8894. vertical = rvertical.test( direction ),
  8895. ref = vertical ? "height" : "width",
  8896. ref2 = vertical ? "top" : "left",
  8897. motion = rpositivemotion.test( direction ),
  8898. animation = {},
  8899. show = mode === "show",
  8900. wrapper, distance, margin;
  8901. // if already wrapped, the wrapper's properties are my property. #6245
  8902. if ( el.parent().is( ".ui-effects-wrapper" ) ) {
  8903. $.effects.save( el.parent(), props );
  8904. } else {
  8905. $.effects.save( el, props );
  8906. }
  8907. el.show();
  8908. wrapper = $.effects.createWrapper( el ).css({
  8909. overflow: "hidden"
  8910. });
  8911. distance = wrapper[ ref ]();
  8912. margin = parseFloat( wrapper.css( ref2 ) ) || 0;
  8913. animation[ ref ] = show ? distance : 0;
  8914. if ( !motion ) {
  8915. el
  8916. .css( vertical ? "bottom" : "right", 0 )
  8917. .css( vertical ? "top" : "left", "auto" )
  8918. .css({ position: "absolute" });
  8919. animation[ ref2 ] = show ? margin : distance + margin;
  8920. }
  8921. // start at 0 if we are showing
  8922. if ( show ) {
  8923. wrapper.css( ref, 0 );
  8924. if ( ! motion ) {
  8925. wrapper.css( ref2, margin + distance );
  8926. }
  8927. }
  8928. // Animate
  8929. wrapper.animate( animation, {
  8930. duration: o.duration,
  8931. easing: o.easing,
  8932. queue: false,
  8933. complete: function() {
  8934. if ( mode === "hide" ) {
  8935. el.hide();
  8936. }
  8937. $.effects.restore( el, props );
  8938. $.effects.removeWrapper( el );
  8939. done();
  8940. }
  8941. });
  8942. };
  8943. })(jQuery);
  8944. (function( $, undefined ) {
  8945. $.effects.effect.bounce = function( o, done ) {
  8946. var el = $( this ),
  8947. props = [ "position", "top", "bottom", "left", "right", "height", "width" ],
  8948. // defaults:
  8949. mode = $.effects.setMode( el, o.mode || "effect" ),
  8950. hide = mode === "hide",
  8951. show = mode === "show",
  8952. direction = o.direction || "up",
  8953. distance = o.distance,
  8954. times = o.times || 5,
  8955. // number of internal animations
  8956. anims = times * 2 + ( show || hide ? 1 : 0 ),
  8957. speed = o.duration / anims,
  8958. easing = o.easing,
  8959. // utility:
  8960. ref = ( direction === "up" || direction === "down" ) ? "top" : "left",
  8961. motion = ( direction === "up" || direction === "left" ),
  8962. i,
  8963. upAnim,
  8964. downAnim,
  8965. // we will need to re-assemble the queue to stack our animations in place
  8966. queue = el.queue(),
  8967. queuelen = queue.length;
  8968. // Avoid touching opacity to prevent clearType and PNG issues in IE
  8969. if ( show || hide ) {
  8970. props.push( "opacity" );
  8971. }
  8972. $.effects.save( el, props );
  8973. el.show();
  8974. $.effects.createWrapper( el ); // Create Wrapper
  8975. // default distance for the BIGGEST bounce is the outer Distance / 3
  8976. if ( !distance ) {
  8977. distance = el[ ref === "top" ? "outerHeight" : "outerWidth" ]() / 3;
  8978. }
  8979. if ( show ) {
  8980. downAnim = { opacity: 1 };
  8981. downAnim[ ref ] = 0;
  8982. // if we are showing, force opacity 0 and set the initial position
  8983. // then do the "first" animation
  8984. el.css( "opacity", 0 )
  8985. .css( ref, motion ? -distance * 2 : distance * 2 )
  8986. .animate( downAnim, speed, easing );
  8987. }
  8988. // start at the smallest distance if we are hiding
  8989. if ( hide ) {
  8990. distance = distance / Math.pow( 2, times - 1 );
  8991. }
  8992. downAnim = {};
  8993. downAnim[ ref ] = 0;
  8994. // Bounces up/down/left/right then back to 0 -- times * 2 animations happen here
  8995. for ( i = 0; i < times; i++ ) {
  8996. upAnim = {};
  8997. upAnim[ ref ] = ( motion ? "-=" : "+=" ) + distance;
  8998. el.animate( upAnim, speed, easing )
  8999. .animate( downAnim, speed, easing );
  9000. distance = hide ? distance * 2 : distance / 2;
  9001. }
  9002. // Last Bounce when Hiding
  9003. if ( hide ) {
  9004. upAnim = { opacity: 0 };
  9005. upAnim[ ref ] = ( motion ? "-=" : "+=" ) + distance;
  9006. el.animate( upAnim, speed, easing );
  9007. }
  9008. el.queue(function() {
  9009. if ( hide ) {
  9010. el.hide();
  9011. }
  9012. $.effects.restore( el, props );
  9013. $.effects.removeWrapper( el );
  9014. done();
  9015. });
  9016. // inject all the animations we just queued to be first in line (after "inprogress")
  9017. if ( queuelen > 1) {
  9018. queue.splice.apply( queue,
  9019. [ 1, 0 ].concat( queue.splice( queuelen, anims + 1 ) ) );
  9020. }
  9021. el.dequeue();
  9022. };
  9023. })(jQuery);
  9024. (function( $, undefined ) {
  9025. $.effects.effect.clip = function( o, done ) {
  9026. // Create element
  9027. var el = $( this ),
  9028. props = [ "position", "top", "bottom", "left", "right", "height", "width" ],
  9029. mode = $.effects.setMode( el, o.mode || "hide" ),
  9030. show = mode === "show",
  9031. direction = o.direction || "vertical",
  9032. vert = direction === "vertical",
  9033. size = vert ? "height" : "width",
  9034. position = vert ? "top" : "left",
  9035. animation = {},
  9036. wrapper, animate, distance;
  9037. // Save & Show
  9038. $.effects.save( el, props );
  9039. el.show();
  9040. // Create Wrapper
  9041. wrapper = $.effects.createWrapper( el ).css({
  9042. overflow: "hidden"
  9043. });
  9044. animate = ( el[0].tagName === "IMG" ) ? wrapper : el;
  9045. distance = animate[ size ]();
  9046. // Shift
  9047. if ( show ) {
  9048. animate.css( size, 0 );
  9049. animate.css( position, distance / 2 );
  9050. }
  9051. // Create Animation Object:
  9052. animation[ size ] = show ? distance : 0;
  9053. animation[ position ] = show ? 0 : distance / 2;
  9054. // Animate
  9055. animate.animate( animation, {
  9056. queue: false,
  9057. duration: o.duration,
  9058. easing: o.easing,
  9059. complete: function() {
  9060. if ( !show ) {
  9061. el.hide();
  9062. }
  9063. $.effects.restore( el, props );
  9064. $.effects.removeWrapper( el );
  9065. done();
  9066. }
  9067. });
  9068. };
  9069. })(jQuery);
  9070. (function( $, undefined ) {
  9071. $.effects.effect.drop = function( o, done ) {
  9072. var el = $( this ),
  9073. props = [ "position", "top", "bottom", "left", "right", "opacity", "height", "width" ],
  9074. mode = $.effects.setMode( el, o.mode || "hide" ),
  9075. show = mode === "show",
  9076. direction = o.direction || "left",
  9077. ref = ( direction === "up" || direction === "down" ) ? "top" : "left",
  9078. motion = ( direction === "up" || direction === "left" ) ? "pos" : "neg",
  9079. animation = {
  9080. opacity: show ? 1 : 0
  9081. },
  9082. distance;
  9083. // Adjust
  9084. $.effects.save( el, props );
  9085. el.show();
  9086. $.effects.createWrapper( el );
  9087. distance = o.distance || el[ ref === "top" ? "outerHeight": "outerWidth" ]( true ) / 2;
  9088. if ( show ) {
  9089. el
  9090. .css( "opacity", 0 )
  9091. .css( ref, motion === "pos" ? -distance : distance );
  9092. }
  9093. // Animation
  9094. animation[ ref ] = ( show ?
  9095. ( motion === "pos" ? "+=" : "-=" ) :
  9096. ( motion === "pos" ? "-=" : "+=" ) ) +
  9097. distance;
  9098. // Animate
  9099. el.animate( animation, {
  9100. queue: false,
  9101. duration: o.duration,
  9102. easing: o.easing,
  9103. complete: function() {
  9104. if ( mode === "hide" ) {
  9105. el.hide();
  9106. }
  9107. $.effects.restore( el, props );
  9108. $.effects.removeWrapper( el );
  9109. done();
  9110. }
  9111. });
  9112. };
  9113. })(jQuery);
  9114. (function( $, undefined ) {
  9115. $.effects.effect.explode = function( o, done ) {
  9116. var rows = o.pieces ? Math.round( Math.sqrt( o.pieces ) ) : 3,
  9117. cells = rows,
  9118. el = $( this ),
  9119. mode = $.effects.setMode( el, o.mode || "hide" ),
  9120. show = mode === "show",
  9121. // show and then visibility:hidden the element before calculating offset
  9122. offset = el.show().css( "visibility", "hidden" ).offset(),
  9123. // width and height of a piece
  9124. width = Math.ceil( el.outerWidth() / cells ),
  9125. height = Math.ceil( el.outerHeight() / rows ),
  9126. pieces = [],
  9127. // loop
  9128. i, j, left, top, mx, my;
  9129. // children animate complete:
  9130. function childComplete() {
  9131. pieces.push( this );
  9132. if ( pieces.length === rows * cells ) {
  9133. animComplete();
  9134. }
  9135. }
  9136. // clone the element for each row and cell.
  9137. for( i = 0; i < rows ; i++ ) { // ===>
  9138. top = offset.top + i * height;
  9139. my = i - ( rows - 1 ) / 2 ;
  9140. for( j = 0; j < cells ; j++ ) { // |||
  9141. left = offset.left + j * width;
  9142. mx = j - ( cells - 1 ) / 2 ;
  9143. // Create a clone of the now hidden main element that will be absolute positioned
  9144. // within a wrapper div off the -left and -top equal to size of our pieces
  9145. el
  9146. .clone()
  9147. .appendTo( "body" )
  9148. .wrap( "<div></div>" )
  9149. .css({
  9150. position: "absolute",
  9151. visibility: "visible",
  9152. left: -j * width,
  9153. top: -i * height
  9154. })
  9155. // select the wrapper - make it overflow: hidden and absolute positioned based on
  9156. // where the original was located +left and +top equal to the size of pieces
  9157. .parent()
  9158. .addClass( "ui-effects-explode" )
  9159. .css({
  9160. position: "absolute",
  9161. overflow: "hidden",
  9162. width: width,
  9163. height: height,
  9164. left: left + ( show ? mx * width : 0 ),
  9165. top: top + ( show ? my * height : 0 ),
  9166. opacity: show ? 0 : 1
  9167. }).animate({
  9168. left: left + ( show ? 0 : mx * width ),
  9169. top: top + ( show ? 0 : my * height ),
  9170. opacity: show ? 1 : 0
  9171. }, o.duration || 500, o.easing, childComplete );
  9172. }
  9173. }
  9174. function animComplete() {
  9175. el.css({
  9176. visibility: "visible"
  9177. });
  9178. $( pieces ).remove();
  9179. if ( !show ) {
  9180. el.hide();
  9181. }
  9182. done();
  9183. }
  9184. };
  9185. })(jQuery);
  9186. (function( $, undefined ) {
  9187. $.effects.effect.fade = function( o, done ) {
  9188. var el = $( this ),
  9189. mode = $.effects.setMode( el, o.mode || "toggle" );
  9190. el.animate({
  9191. opacity: mode
  9192. }, {
  9193. queue: false,
  9194. duration: o.duration,
  9195. easing: o.easing,
  9196. complete: done
  9197. });
  9198. };
  9199. })( jQuery );
  9200. (function( $, undefined ) {
  9201. $.effects.effect.fold = function( o, done ) {
  9202. // Create element
  9203. var el = $( this ),
  9204. props = [ "position", "top", "bottom", "left", "right", "height", "width" ],
  9205. mode = $.effects.setMode( el, o.mode || "hide" ),
  9206. show = mode === "show",
  9207. hide = mode === "hide",
  9208. size = o.size || 15,
  9209. percent = /([0-9]+)%/.exec( size ),
  9210. horizFirst = !!o.horizFirst,
  9211. widthFirst = show !== horizFirst,
  9212. ref = widthFirst ? [ "width", "height" ] : [ "height", "width" ],
  9213. duration = o.duration / 2,
  9214. wrapper, distance,
  9215. animation1 = {},
  9216. animation2 = {};
  9217. $.effects.save( el, props );
  9218. el.show();
  9219. // Create Wrapper
  9220. wrapper = $.effects.createWrapper( el ).css({
  9221. overflow: "hidden"
  9222. });
  9223. distance = widthFirst ?
  9224. [ wrapper.width(), wrapper.height() ] :
  9225. [ wrapper.height(), wrapper.width() ];
  9226. if ( percent ) {
  9227. size = parseInt( percent[ 1 ], 10 ) / 100 * distance[ hide ? 0 : 1 ];
  9228. }
  9229. if ( show ) {
  9230. wrapper.css( horizFirst ? {
  9231. height: 0,
  9232. width: size
  9233. } : {
  9234. height: size,
  9235. width: 0
  9236. });
  9237. }
  9238. // Animation
  9239. animation1[ ref[ 0 ] ] = show ? distance[ 0 ] : size;
  9240. animation2[ ref[ 1 ] ] = show ? distance[ 1 ] : 0;
  9241. // Animate
  9242. wrapper
  9243. .animate( animation1, duration, o.easing )
  9244. .animate( animation2, duration, o.easing, function() {
  9245. if ( hide ) {
  9246. el.hide();
  9247. }
  9248. $.effects.restore( el, props );
  9249. $.effects.removeWrapper( el );
  9250. done();
  9251. });
  9252. };
  9253. })(jQuery);
  9254. (function( $, undefined ) {
  9255. $.effects.effect.highlight = function( o, done ) {
  9256. var elem = $( this ),
  9257. props = [ "backgroundImage", "backgroundColor", "opacity" ],
  9258. mode = $.effects.setMode( elem, o.mode || "show" ),
  9259. animation = {
  9260. backgroundColor: elem.css( "backgroundColor" )
  9261. };
  9262. if (mode === "hide") {
  9263. animation.opacity = 0;
  9264. }
  9265. $.effects.save( elem, props );
  9266. elem
  9267. .show()
  9268. .css({
  9269. backgroundImage: "none",
  9270. backgroundColor: o.color || "#ffff99"
  9271. })
  9272. .animate( animation, {
  9273. queue: false,
  9274. duration: o.duration,
  9275. easing: o.easing,
  9276. complete: function() {
  9277. if ( mode === "hide" ) {
  9278. elem.hide();
  9279. }
  9280. $.effects.restore( elem, props );
  9281. done();
  9282. }
  9283. });
  9284. };
  9285. })(jQuery);
  9286. (function( $, undefined ) {
  9287. $.effects.effect.pulsate = function( o, done ) {
  9288. var elem = $( this ),
  9289. mode = $.effects.setMode( elem, o.mode || "show" ),
  9290. show = mode === "show",
  9291. hide = mode === "hide",
  9292. showhide = ( show || mode === "hide" ),
  9293. // showing or hiding leaves of the "last" animation
  9294. anims = ( ( o.times || 5 ) * 2 ) + ( showhide ? 1 : 0 ),
  9295. duration = o.duration / anims,
  9296. animateTo = 0,
  9297. queue = elem.queue(),
  9298. queuelen = queue.length,
  9299. i;
  9300. if ( show || !elem.is(":visible")) {
  9301. elem.css( "opacity", 0 ).show();
  9302. animateTo = 1;
  9303. }
  9304. // anims - 1 opacity "toggles"
  9305. for ( i = 1; i < anims; i++ ) {
  9306. elem.animate({
  9307. opacity: animateTo
  9308. }, duration, o.easing );
  9309. animateTo = 1 - animateTo;
  9310. }
  9311. elem.animate({
  9312. opacity: animateTo
  9313. }, duration, o.easing);
  9314. elem.queue(function() {
  9315. if ( hide ) {
  9316. elem.hide();
  9317. }
  9318. done();
  9319. });
  9320. // We just queued up "anims" animations, we need to put them next in the queue
  9321. if ( queuelen > 1 ) {
  9322. queue.splice.apply( queue,
  9323. [ 1, 0 ].concat( queue.splice( queuelen, anims + 1 ) ) );
  9324. }
  9325. elem.dequeue();
  9326. };
  9327. })(jQuery);
  9328. (function( $, undefined ) {
  9329. $.effects.effect.puff = function( o, done ) {
  9330. var elem = $( this ),
  9331. mode = $.effects.setMode( elem, o.mode || "hide" ),
  9332. hide = mode === "hide",
  9333. percent = parseInt( o.percent, 10 ) || 150,
  9334. factor = percent / 100,
  9335. original = {
  9336. height: elem.height(),
  9337. width: elem.width(),
  9338. outerHeight: elem.outerHeight(),
  9339. outerWidth: elem.outerWidth()
  9340. };
  9341. $.extend( o, {
  9342. effect: "scale",
  9343. queue: false,
  9344. fade: true,
  9345. mode: mode,
  9346. complete: done,
  9347. percent: hide ? percent : 100,
  9348. from: hide ?
  9349. original :
  9350. {
  9351. height: original.height * factor,
  9352. width: original.width * factor,
  9353. outerHeight: original.outerHeight * factor,
  9354. outerWidth: original.outerWidth * factor
  9355. }
  9356. });
  9357. elem.effect( o );
  9358. };
  9359. $.effects.effect.scale = function( o, done ) {
  9360. // Create element
  9361. var el = $( this ),
  9362. options = $.extend( true, {}, o ),
  9363. mode = $.effects.setMode( el, o.mode || "effect" ),
  9364. percent = parseInt( o.percent, 10 ) ||
  9365. ( parseInt( o.percent, 10 ) === 0 ? 0 : ( mode === "hide" ? 0 : 100 ) ),
  9366. direction = o.direction || "both",
  9367. origin = o.origin,
  9368. original = {
  9369. height: el.height(),
  9370. width: el.width(),
  9371. outerHeight: el.outerHeight(),
  9372. outerWidth: el.outerWidth()
  9373. },
  9374. factor = {
  9375. y: direction !== "horizontal" ? (percent / 100) : 1,
  9376. x: direction !== "vertical" ? (percent / 100) : 1
  9377. };
  9378. // We are going to pass this effect to the size effect:
  9379. options.effect = "size";
  9380. options.queue = false;
  9381. options.complete = done;
  9382. // Set default origin and restore for show/hide
  9383. if ( mode !== "effect" ) {
  9384. options.origin = origin || ["middle","center"];
  9385. options.restore = true;
  9386. }
  9387. options.from = o.from || ( mode === "show" ? {
  9388. height: 0,
  9389. width: 0,
  9390. outerHeight: 0,
  9391. outerWidth: 0
  9392. } : original );
  9393. options.to = {
  9394. height: original.height * factor.y,
  9395. width: original.width * factor.x,
  9396. outerHeight: original.outerHeight * factor.y,
  9397. outerWidth: original.outerWidth * factor.x
  9398. };
  9399. // Fade option to support puff
  9400. if ( options.fade ) {
  9401. if ( mode === "show" ) {
  9402. options.from.opacity = 0;
  9403. options.to.opacity = 1;
  9404. }
  9405. if ( mode === "hide" ) {
  9406. options.from.opacity = 1;
  9407. options.to.opacity = 0;
  9408. }
  9409. }
  9410. // Animate
  9411. el.effect( options );
  9412. };
  9413. $.effects.effect.size = function( o, done ) {
  9414. // Create element
  9415. var original, baseline, factor,
  9416. el = $( this ),
  9417. props0 = [ "position", "top", "bottom", "left", "right", "width", "height", "overflow", "opacity" ],
  9418. // Always restore
  9419. props1 = [ "position", "top", "bottom", "left", "right", "overflow", "opacity" ],
  9420. // Copy for children
  9421. props2 = [ "width", "height", "overflow" ],
  9422. cProps = [ "fontSize" ],
  9423. vProps = [ "borderTopWidth", "borderBottomWidth", "paddingTop", "paddingBottom" ],
  9424. hProps = [ "borderLeftWidth", "borderRightWidth", "paddingLeft", "paddingRight" ],
  9425. // Set options
  9426. mode = $.effects.setMode( el, o.mode || "effect" ),
  9427. restore = o.restore || mode !== "effect",
  9428. scale = o.scale || "both",
  9429. origin = o.origin || [ "middle", "center" ],
  9430. position = el.css( "position" ),
  9431. props = restore ? props0 : props1,
  9432. zero = {
  9433. height: 0,
  9434. width: 0,
  9435. outerHeight: 0,
  9436. outerWidth: 0
  9437. };
  9438. if ( mode === "show" ) {
  9439. el.show();
  9440. }
  9441. original = {
  9442. height: el.height(),
  9443. width: el.width(),
  9444. outerHeight: el.outerHeight(),
  9445. outerWidth: el.outerWidth()
  9446. };
  9447. if ( o.mode === "toggle" && mode === "show" ) {
  9448. el.from = o.to || zero;
  9449. el.to = o.from || original;
  9450. } else {
  9451. el.from = o.from || ( mode === "show" ? zero : original );
  9452. el.to = o.to || ( mode === "hide" ? zero : original );
  9453. }
  9454. // Set scaling factor
  9455. factor = {
  9456. from: {
  9457. y: el.from.height / original.height,
  9458. x: el.from.width / original.width
  9459. },
  9460. to: {
  9461. y: el.to.height / original.height,
  9462. x: el.to.width / original.width
  9463. }
  9464. };
  9465. // Scale the css box
  9466. if ( scale === "box" || scale === "both" ) {
  9467. // Vertical props scaling
  9468. if ( factor.from.y !== factor.to.y ) {
  9469. props = props.concat( vProps );
  9470. el.from = $.effects.setTransition( el, vProps, factor.from.y, el.from );
  9471. el.to = $.effects.setTransition( el, vProps, factor.to.y, el.to );
  9472. }
  9473. // Horizontal props scaling
  9474. if ( factor.from.x !== factor.to.x ) {
  9475. props = props.concat( hProps );
  9476. el.from = $.effects.setTransition( el, hProps, factor.from.x, el.from );
  9477. el.to = $.effects.setTransition( el, hProps, factor.to.x, el.to );
  9478. }
  9479. }
  9480. // Scale the content
  9481. if ( scale === "content" || scale === "both" ) {
  9482. // Vertical props scaling
  9483. if ( factor.from.y !== factor.to.y ) {
  9484. props = props.concat( cProps ).concat( props2 );
  9485. el.from = $.effects.setTransition( el, cProps, factor.from.y, el.from );
  9486. el.to = $.effects.setTransition( el, cProps, factor.to.y, el.to );
  9487. }
  9488. }
  9489. $.effects.save( el, props );
  9490. el.show();
  9491. $.effects.createWrapper( el );
  9492. el.css( "overflow", "hidden" ).css( el.from );
  9493. // Adjust
  9494. if (origin) { // Calculate baseline shifts
  9495. baseline = $.effects.getBaseline( origin, original );
  9496. el.from.top = ( original.outerHeight - el.outerHeight() ) * baseline.y;
  9497. el.from.left = ( original.outerWidth - el.outerWidth() ) * baseline.x;
  9498. el.to.top = ( original.outerHeight - el.to.outerHeight ) * baseline.y;
  9499. el.to.left = ( original.outerWidth - el.to.outerWidth ) * baseline.x;
  9500. }
  9501. el.css( el.from ); // set top & left
  9502. // Animate
  9503. if ( scale === "content" || scale === "both" ) { // Scale the children
  9504. // Add margins/font-size
  9505. vProps = vProps.concat([ "marginTop", "marginBottom" ]).concat(cProps);
  9506. hProps = hProps.concat([ "marginLeft", "marginRight" ]);
  9507. props2 = props0.concat(vProps).concat(hProps);
  9508. el.find( "*[width]" ).each( function(){
  9509. var child = $( this ),
  9510. c_original = {
  9511. height: child.height(),
  9512. width: child.width(),
  9513. outerHeight: child.outerHeight(),
  9514. outerWidth: child.outerWidth()
  9515. };
  9516. if (restore) {
  9517. $.effects.save(child, props2);
  9518. }
  9519. child.from = {
  9520. height: c_original.height * factor.from.y,
  9521. width: c_original.width * factor.from.x,
  9522. outerHeight: c_original.outerHeight * factor.from.y,
  9523. outerWidth: c_original.outerWidth * factor.from.x
  9524. };
  9525. child.to = {
  9526. height: c_original.height * factor.to.y,
  9527. width: c_original.width * factor.to.x,
  9528. outerHeight: c_original.height * factor.to.y,
  9529. outerWidth: c_original.width * factor.to.x
  9530. };
  9531. // Vertical props scaling
  9532. if ( factor.from.y !== factor.to.y ) {
  9533. child.from = $.effects.setTransition( child, vProps, factor.from.y, child.from );
  9534. child.to = $.effects.setTransition( child, vProps, factor.to.y, child.to );
  9535. }
  9536. // Horizontal props scaling
  9537. if ( factor.from.x !== factor.to.x ) {
  9538. child.from = $.effects.setTransition( child, hProps, factor.from.x, child.from );
  9539. child.to = $.effects.setTransition( child, hProps, factor.to.x, child.to );
  9540. }
  9541. // Animate children
  9542. child.css( child.from );
  9543. child.animate( child.to, o.duration, o.easing, function() {
  9544. // Restore children
  9545. if ( restore ) {
  9546. $.effects.restore( child, props2 );
  9547. }
  9548. });
  9549. });
  9550. }
  9551. // Animate
  9552. el.animate( el.to, {
  9553. queue: false,
  9554. duration: o.duration,
  9555. easing: o.easing,
  9556. complete: function() {
  9557. if ( el.to.opacity === 0 ) {
  9558. el.css( "opacity", el.from.opacity );
  9559. }
  9560. if( mode === "hide" ) {
  9561. el.hide();
  9562. }
  9563. $.effects.restore( el, props );
  9564. if ( !restore ) {
  9565. // we need to calculate our new positioning based on the scaling
  9566. if ( position === "static" ) {
  9567. el.css({
  9568. position: "relative",
  9569. top: el.to.top,
  9570. left: el.to.left
  9571. });
  9572. } else {
  9573. $.each([ "top", "left" ], function( idx, pos ) {
  9574. el.css( pos, function( _, str ) {
  9575. var val = parseInt( str, 10 ),
  9576. toRef = idx ? el.to.left : el.to.top;
  9577. // if original was "auto", recalculate the new value from wrapper
  9578. if ( str === "auto" ) {
  9579. return toRef + "px";
  9580. }
  9581. return val + toRef + "px";
  9582. });
  9583. });
  9584. }
  9585. }
  9586. $.effects.removeWrapper( el );
  9587. done();
  9588. }
  9589. });
  9590. };
  9591. })(jQuery);
  9592. (function( $, undefined ) {
  9593. $.effects.effect.shake = function( o, done ) {
  9594. var el = $( this ),
  9595. props = [ "position", "top", "bottom", "left", "right", "height", "width" ],
  9596. mode = $.effects.setMode( el, o.mode || "effect" ),
  9597. direction = o.direction || "left",
  9598. distance = o.distance || 20,
  9599. times = o.times || 3,
  9600. anims = times * 2 + 1,
  9601. speed = Math.round(o.duration/anims),
  9602. ref = (direction === "up" || direction === "down") ? "top" : "left",
  9603. positiveMotion = (direction === "up" || direction === "left"),
  9604. animation = {},
  9605. animation1 = {},
  9606. animation2 = {},
  9607. i,
  9608. // we will need to re-assemble the queue to stack our animations in place
  9609. queue = el.queue(),
  9610. queuelen = queue.length;
  9611. $.effects.save( el, props );
  9612. el.show();
  9613. $.effects.createWrapper( el );
  9614. // Animation
  9615. animation[ ref ] = ( positiveMotion ? "-=" : "+=" ) + distance;
  9616. animation1[ ref ] = ( positiveMotion ? "+=" : "-=" ) + distance * 2;
  9617. animation2[ ref ] = ( positiveMotion ? "-=" : "+=" ) + distance * 2;
  9618. // Animate
  9619. el.animate( animation, speed, o.easing );
  9620. // Shakes
  9621. for ( i = 1; i < times; i++ ) {
  9622. el.animate( animation1, speed, o.easing ).animate( animation2, speed, o.easing );
  9623. }
  9624. el
  9625. .animate( animation1, speed, o.easing )
  9626. .animate( animation, speed / 2, o.easing )
  9627. .queue(function() {
  9628. if ( mode === "hide" ) {
  9629. el.hide();
  9630. }
  9631. $.effects.restore( el, props );
  9632. $.effects.removeWrapper( el );
  9633. done();
  9634. });
  9635. // inject all the animations we just queued to be first in line (after "inprogress")
  9636. if ( queuelen > 1) {
  9637. queue.splice.apply( queue,
  9638. [ 1, 0 ].concat( queue.splice( queuelen, anims + 1 ) ) );
  9639. }
  9640. el.dequeue();
  9641. };
  9642. })(jQuery);
  9643. (function( $, undefined ) {
  9644. $.effects.effect.slide = function( o, done ) {
  9645. // Create element
  9646. var el = $( this ),
  9647. props = [ "position", "top", "bottom", "left", "right", "width", "height" ],
  9648. mode = $.effects.setMode( el, o.mode || "show" ),
  9649. show = mode === "show",
  9650. direction = o.direction || "left",
  9651. ref = (direction === "up" || direction === "down") ? "top" : "left",
  9652. positiveMotion = (direction === "up" || direction === "left"),
  9653. distance,
  9654. animation = {};
  9655. // Adjust
  9656. $.effects.save( el, props );
  9657. el.show();
  9658. distance = o.distance || el[ ref === "top" ? "outerHeight" : "outerWidth" ]( true );
  9659. $.effects.createWrapper( el ).css({
  9660. overflow: "hidden"
  9661. });
  9662. if ( show ) {
  9663. el.css( ref, positiveMotion ? (isNaN(distance) ? "-" + distance : -distance) : distance );
  9664. }
  9665. // Animation
  9666. animation[ ref ] = ( show ?
  9667. ( positiveMotion ? "+=" : "-=") :
  9668. ( positiveMotion ? "-=" : "+=")) +
  9669. distance;
  9670. // Animate
  9671. el.animate( animation, {
  9672. queue: false,
  9673. duration: o.duration,
  9674. easing: o.easing,
  9675. complete: function() {
  9676. if ( mode === "hide" ) {
  9677. el.hide();
  9678. }
  9679. $.effects.restore( el, props );
  9680. $.effects.removeWrapper( el );
  9681. done();
  9682. }
  9683. });
  9684. };
  9685. })(jQuery);
  9686. (function( $, undefined ) {
  9687. $.effects.effect.transfer = function( o, done ) {
  9688. var elem = $( this ),
  9689. target = $( o.to ),
  9690. targetFixed = target.css( "position" ) === "fixed",
  9691. body = $("body"),
  9692. fixTop = targetFixed ? body.scrollTop() : 0,
  9693. fixLeft = targetFixed ? body.scrollLeft() : 0,
  9694. endPosition = target.offset(),
  9695. animation = {
  9696. top: endPosition.top - fixTop ,
  9697. left: endPosition.left - fixLeft ,
  9698. height: target.innerHeight(),
  9699. width: target.innerWidth()
  9700. },
  9701. startPosition = elem.offset(),
  9702. transfer = $( "<div class='ui-effects-transfer'></div>" )
  9703. .appendTo( document.body )
  9704. .addClass( o.className )
  9705. .css({
  9706. top: startPosition.top - fixTop ,
  9707. left: startPosition.left - fixLeft ,
  9708. height: elem.innerHeight(),
  9709. width: elem.innerWidth(),
  9710. position: targetFixed ? "fixed" : "absolute"
  9711. })
  9712. .animate( animation, o.duration, o.easing, function() {
  9713. transfer.remove();
  9714. done();
  9715. });
  9716. };
  9717. })(jQuery);
  9718. (function( $, undefined ) {
  9719. $.widget( "ui.menu", {
  9720. version: "1.10.1",
  9721. defaultElement: "<ul>",
  9722. delay: 300,
  9723. options: {
  9724. icons: {
  9725. submenu: "ui-icon-carat-1-e"
  9726. },
  9727. menus: "ul",
  9728. position: {
  9729. my: "left top",
  9730. at: "right top"
  9731. },
  9732. role: "menu",
  9733. // callbacks
  9734. blur: null,
  9735. focus: null,
  9736. select: null
  9737. },
  9738. _create: function() {
  9739. this.activeMenu = this.element;
  9740. // flag used to prevent firing of the click handler
  9741. // as the event bubbles up through nested menus
  9742. this.mouseHandled = false;
  9743. this.element
  9744. .uniqueId()
  9745. .addClass( "ui-menu ui-widget ui-widget-content ui-corner-all" )
  9746. .toggleClass( "ui-menu-icons", !!this.element.find( ".ui-icon" ).length )
  9747. .attr({
  9748. role: this.options.role,
  9749. tabIndex: 0
  9750. })
  9751. // need to catch all clicks on disabled menu
  9752. // not possible through _on
  9753. .bind( "click" + this.eventNamespace, $.proxy(function( event ) {
  9754. if ( this.options.disabled ) {
  9755. event.preventDefault();
  9756. }
  9757. }, this ));
  9758. if ( this.options.disabled ) {
  9759. this.element
  9760. .addClass( "ui-state-disabled" )
  9761. .attr( "aria-disabled", "true" );
  9762. }
  9763. this._on({
  9764. // Prevent focus from sticking to links inside menu after clicking
  9765. // them (focus should always stay on UL during navigation).
  9766. "mousedown .ui-menu-item > a": function( event ) {
  9767. event.preventDefault();
  9768. },
  9769. "click .ui-state-disabled > a": function( event ) {
  9770. event.preventDefault();
  9771. },
  9772. "click .ui-menu-item:has(a)": function( event ) {
  9773. var target = $( event.target ).closest( ".ui-menu-item" );
  9774. if ( !this.mouseHandled && target.not( ".ui-state-disabled" ).length ) {
  9775. this.mouseHandled = true;
  9776. this.select( event );
  9777. // Open submenu on click
  9778. if ( target.has( ".ui-menu" ).length ) {
  9779. this.expand( event );
  9780. } else if ( !this.element.is( ":focus" ) ) {
  9781. // Redirect focus to the menu
  9782. this.element.trigger( "focus", [ true ] );
  9783. // If the active item is on the top level, let it stay active.
  9784. // Otherwise, blur the active item since it is no longer visible.
  9785. if ( this.active && this.active.parents( ".ui-menu" ).length === 1 ) {
  9786. clearTimeout( this.timer );
  9787. }
  9788. }
  9789. }
  9790. },
  9791. "mouseenter .ui-menu-item": function( event ) {
  9792. var target = $( event.currentTarget );
  9793. // Remove ui-state-active class from siblings of the newly focused menu item
  9794. // to avoid a jump caused by adjacent elements both having a class with a border
  9795. target.siblings().children( ".ui-state-active" ).removeClass( "ui-state-active" );
  9796. this.focus( event, target );
  9797. },
  9798. mouseleave: "collapseAll",
  9799. "mouseleave .ui-menu": "collapseAll",
  9800. focus: function( event, keepActiveItem ) {
  9801. // If there's already an active item, keep it active
  9802. // If not, activate the first item
  9803. var item = this.active || this.element.children( ".ui-menu-item" ).eq( 0 );
  9804. if ( !keepActiveItem ) {
  9805. this.focus( event, item );
  9806. }
  9807. },
  9808. blur: function( event ) {
  9809. this._delay(function() {
  9810. if ( !$.contains( this.element[0], this.document[0].activeElement ) ) {
  9811. this.collapseAll( event );
  9812. }
  9813. });
  9814. },
  9815. keydown: "_keydown"
  9816. });
  9817. this.refresh();
  9818. // Clicks outside of a menu collapse any open menus
  9819. this._on( this.document, {
  9820. click: function( event ) {
  9821. if ( !$( event.target ).closest( ".ui-menu" ).length ) {
  9822. this.collapseAll( event );
  9823. }
  9824. // Reset the mouseHandled flag
  9825. this.mouseHandled = false;
  9826. }
  9827. });
  9828. },
  9829. _destroy: function() {
  9830. // Destroy (sub)menus
  9831. this.element
  9832. .removeAttr( "aria-activedescendant" )
  9833. .find( ".ui-menu" ).addBack()
  9834. .removeClass( "ui-menu ui-widget ui-widget-content ui-corner-all ui-menu-icons" )
  9835. .removeAttr( "role" )
  9836. .removeAttr( "tabIndex" )
  9837. .removeAttr( "aria-labelledby" )
  9838. .removeAttr( "aria-expanded" )
  9839. .removeAttr( "aria-hidden" )
  9840. .removeAttr( "aria-disabled" )
  9841. .removeUniqueId()
  9842. .show();
  9843. // Destroy menu items
  9844. this.element.find( ".ui-menu-item" )
  9845. .removeClass( "ui-menu-item" )
  9846. .removeAttr( "role" )
  9847. .removeAttr( "aria-disabled" )
  9848. .children( "a" )
  9849. .removeUniqueId()
  9850. .removeClass( "ui-corner-all ui-state-hover" )
  9851. .removeAttr( "tabIndex" )
  9852. .removeAttr( "role" )
  9853. .removeAttr( "aria-haspopup" )
  9854. .children().each( function() {
  9855. var elem = $( this );
  9856. if ( elem.data( "ui-menu-submenu-carat" ) ) {
  9857. elem.remove();
  9858. }
  9859. });
  9860. // Destroy menu dividers
  9861. this.element.find( ".ui-menu-divider" ).removeClass( "ui-menu-divider ui-widget-content" );
  9862. },
  9863. _keydown: function( event ) {
  9864. /*jshint maxcomplexity:20*/
  9865. var match, prev, character, skip, regex,
  9866. preventDefault = true;
  9867. function escape( value ) {
  9868. return value.replace( /[\-\[\]{}()*+?.,\\\^$|#\s]/g, "\\$&" );
  9869. }
  9870. switch ( event.keyCode ) {
  9871. case $.ui.keyCode.PAGE_UP:
  9872. this.previousPage( event );
  9873. break;
  9874. case $.ui.keyCode.PAGE_DOWN:
  9875. this.nextPage( event );
  9876. break;
  9877. case $.ui.keyCode.HOME:
  9878. this._move( "first", "first", event );
  9879. break;
  9880. case $.ui.keyCode.END:
  9881. this._move( "last", "last", event );
  9882. break;
  9883. case $.ui.keyCode.UP:
  9884. this.previous( event );
  9885. break;
  9886. case $.ui.keyCode.DOWN:
  9887. this.next( event );
  9888. break;
  9889. case $.ui.keyCode.LEFT:
  9890. this.collapse( event );
  9891. break;
  9892. case $.ui.keyCode.RIGHT:
  9893. if ( this.active && !this.active.is( ".ui-state-disabled" ) ) {
  9894. this.expand( event );
  9895. }
  9896. break;
  9897. case $.ui.keyCode.ENTER:
  9898. case $.ui.keyCode.SPACE:
  9899. this._activate( event );
  9900. break;
  9901. case $.ui.keyCode.ESCAPE:
  9902. this.collapse( event );
  9903. break;
  9904. default:
  9905. preventDefault = false;
  9906. prev = this.previousFilter || "";
  9907. character = String.fromCharCode( event.keyCode );
  9908. skip = false;
  9909. clearTimeout( this.filterTimer );
  9910. if ( character === prev ) {
  9911. skip = true;
  9912. } else {
  9913. character = prev + character;
  9914. }
  9915. regex = new RegExp( "^" + escape( character ), "i" );
  9916. match = this.activeMenu.children( ".ui-menu-item" ).filter(function() {
  9917. return regex.test( $( this ).children( "a" ).text() );
  9918. });
  9919. match = skip && match.index( this.active.next() ) !== -1 ?
  9920. this.active.nextAll( ".ui-menu-item" ) :
  9921. match;
  9922. // If no matches on the current filter, reset to the last character pressed
  9923. // to move down the menu to the first item that starts with that character
  9924. if ( !match.length ) {
  9925. character = String.fromCharCode( event.keyCode );
  9926. regex = new RegExp( "^" + escape( character ), "i" );
  9927. match = this.activeMenu.children( ".ui-menu-item" ).filter(function() {
  9928. return regex.test( $( this ).children( "a" ).text() );
  9929. });
  9930. }
  9931. if ( match.length ) {
  9932. this.focus( event, match );
  9933. if ( match.length > 1 ) {
  9934. this.previousFilter = character;
  9935. this.filterTimer = this._delay(function() {
  9936. delete this.previousFilter;
  9937. }, 1000 );
  9938. } else {
  9939. delete this.previousFilter;
  9940. }
  9941. } else {
  9942. delete this.previousFilter;
  9943. }
  9944. }
  9945. if ( preventDefault ) {
  9946. event.preventDefault();
  9947. }
  9948. },
  9949. _activate: function( event ) {
  9950. if ( !this.active.is( ".ui-state-disabled" ) ) {
  9951. if ( this.active.children( "a[aria-haspopup='true']" ).length ) {
  9952. this.expand( event );
  9953. } else {
  9954. this.select( event );
  9955. }
  9956. }
  9957. },
  9958. refresh: function() {
  9959. var menus,
  9960. icon = this.options.icons.submenu,
  9961. submenus = this.element.find( this.options.menus );
  9962. // Initialize nested menus
  9963. submenus.filter( ":not(.ui-menu)" )
  9964. .addClass( "ui-menu ui-widget ui-widget-content ui-corner-all" )
  9965. .hide()
  9966. .attr({
  9967. role: this.options.role,
  9968. "aria-hidden": "true",
  9969. "aria-expanded": "false"
  9970. })
  9971. .each(function() {
  9972. var menu = $( this ),
  9973. item = menu.prev( "a" ),
  9974. submenuCarat = $( "<span>" )
  9975. .addClass( "ui-menu-icon ui-icon " + icon )
  9976. .data( "ui-menu-submenu-carat", true );
  9977. item
  9978. .attr( "aria-haspopup", "true" )
  9979. .prepend( submenuCarat );
  9980. menu.attr( "aria-labelledby", item.attr( "id" ) );
  9981. });
  9982. menus = submenus.add( this.element );
  9983. // Don't refresh list items that are already adapted
  9984. menus.children( ":not(.ui-menu-item):has(a)" )
  9985. .addClass( "ui-menu-item" )
  9986. .attr( "role", "presentation" )
  9987. .children( "a" )
  9988. .uniqueId()
  9989. .addClass( "ui-corner-all" )
  9990. .attr({
  9991. tabIndex: -1,
  9992. role: this._itemRole()
  9993. });
  9994. // Initialize unlinked menu-items containing spaces and/or dashes only as dividers
  9995. menus.children( ":not(.ui-menu-item)" ).each(function() {
  9996. var item = $( this );
  9997. // hyphen, em dash, en dash
  9998. if ( !/[^\-\u2014\u2013\s]/.test( item.text() ) ) {
  9999. item.addClass( "ui-widget-content ui-menu-divider" );
  10000. }
  10001. });
  10002. // Add aria-disabled attribute to any disabled menu item
  10003. menus.children( ".ui-state-disabled" ).attr( "aria-disabled", "true" );
  10004. // If the active item has been removed, blur the menu
  10005. if ( this.active && !$.contains( this.element[ 0 ], this.active[ 0 ] ) ) {
  10006. this.blur();
  10007. }
  10008. },
  10009. _itemRole: function() {
  10010. return {
  10011. menu: "menuitem",
  10012. listbox: "option"
  10013. }[ this.options.role ];
  10014. },
  10015. _setOption: function( key, value ) {
  10016. if ( key === "icons" ) {
  10017. this.element.find( ".ui-menu-icon" )
  10018. .removeClass( this.options.icons.submenu )
  10019. .addClass( value.submenu );
  10020. }
  10021. this._super( key, value );
  10022. },
  10023. focus: function( event, item ) {
  10024. var nested, focused;
  10025. this.blur( event, event && event.type === "focus" );
  10026. this._scrollIntoView( item );
  10027. this.active = item.first();
  10028. focused = this.active.children( "a" ).addClass( "ui-state-focus" );
  10029. // Only update aria-activedescendant if there's a role
  10030. // otherwise we assume focus is managed elsewhere
  10031. if ( this.options.role ) {
  10032. this.element.attr( "aria-activedescendant", focused.attr( "id" ) );
  10033. }
  10034. // Highlight active parent menu item, if any
  10035. this.active
  10036. .parent()
  10037. .closest( ".ui-menu-item" )
  10038. .children( "a:first" )
  10039. .addClass( "ui-state-active" );
  10040. if ( event && event.type === "keydown" ) {
  10041. this._close();
  10042. } else {
  10043. this.timer = this._delay(function() {
  10044. this._close();
  10045. }, this.delay );
  10046. }
  10047. nested = item.children( ".ui-menu" );
  10048. if ( nested.length && ( /^mouse/.test( event.type ) ) ) {
  10049. this._startOpening(nested);
  10050. }
  10051. this.activeMenu = item.parent();
  10052. this._trigger( "focus", event, { item: item } );
  10053. },
  10054. _scrollIntoView: function( item ) {
  10055. var borderTop, paddingTop, offset, scroll, elementHeight, itemHeight;
  10056. if ( this._hasScroll() ) {
  10057. borderTop = parseFloat( $.css( this.activeMenu[0], "borderTopWidth" ) ) || 0;
  10058. paddingTop = parseFloat( $.css( this.activeMenu[0], "paddingTop" ) ) || 0;
  10059. offset = item.offset().top - this.activeMenu.offset().top - borderTop - paddingTop;
  10060. scroll = this.activeMenu.scrollTop();
  10061. elementHeight = this.activeMenu.height();
  10062. itemHeight = item.height();
  10063. if ( offset < 0 ) {
  10064. this.activeMenu.scrollTop( scroll + offset );
  10065. } else if ( offset + itemHeight > elementHeight ) {
  10066. this.activeMenu.scrollTop( scroll + offset - elementHeight + itemHeight );
  10067. }
  10068. }
  10069. },
  10070. blur: function( event, fromFocus ) {
  10071. if ( !fromFocus ) {
  10072. clearTimeout( this.timer );
  10073. }
  10074. if ( !this.active ) {
  10075. return;
  10076. }
  10077. this.active.children( "a" ).removeClass( "ui-state-focus" );
  10078. this.active = null;
  10079. this._trigger( "blur", event, { item: this.active } );
  10080. },
  10081. _startOpening: function( submenu ) {
  10082. clearTimeout( this.timer );
  10083. // Don't open if already open fixes a Firefox bug that caused a .5 pixel
  10084. // shift in the submenu position when mousing over the carat icon
  10085. if ( submenu.attr( "aria-hidden" ) !== "true" ) {
  10086. return;
  10087. }
  10088. this.timer = this._delay(function() {
  10089. this._close();
  10090. this._open( submenu );
  10091. }, this.delay );
  10092. },
  10093. _open: function( submenu ) {
  10094. var position = $.extend({
  10095. of: this.active
  10096. }, this.options.position );
  10097. clearTimeout( this.timer );
  10098. this.element.find( ".ui-menu" ).not( submenu.parents( ".ui-menu" ) )
  10099. .hide()
  10100. .attr( "aria-hidden", "true" );
  10101. submenu
  10102. .show()
  10103. .removeAttr( "aria-hidden" )
  10104. .attr( "aria-expanded", "true" )
  10105. .position( position );
  10106. },
  10107. collapseAll: function( event, all ) {
  10108. clearTimeout( this.timer );
  10109. this.timer = this._delay(function() {
  10110. // If we were passed an event, look for the submenu that contains the event
  10111. var currentMenu = all ? this.element :
  10112. $( event && event.target ).closest( this.element.find( ".ui-menu" ) );
  10113. // If we found no valid submenu ancestor, use the main menu to close all sub menus anyway
  10114. if ( !currentMenu.length ) {
  10115. currentMenu = this.element;
  10116. }
  10117. this._close( currentMenu );
  10118. this.blur( event );
  10119. this.activeMenu = currentMenu;
  10120. }, this.delay );
  10121. },
  10122. // With no arguments, closes the currently active menu - if nothing is active
  10123. // it closes all menus. If passed an argument, it will search for menus BELOW
  10124. _close: function( startMenu ) {
  10125. if ( !startMenu ) {
  10126. startMenu = this.active ? this.active.parent() : this.element;
  10127. }
  10128. startMenu
  10129. .find( ".ui-menu" )
  10130. .hide()
  10131. .attr( "aria-hidden", "true" )
  10132. .attr( "aria-expanded", "false" )
  10133. .end()
  10134. .find( "a.ui-state-active" )
  10135. .removeClass( "ui-state-active" );
  10136. },
  10137. collapse: function( event ) {
  10138. var newItem = this.active &&
  10139. this.active.parent().closest( ".ui-menu-item", this.element );
  10140. if ( newItem && newItem.length ) {
  10141. this._close();
  10142. this.focus( event, newItem );
  10143. }
  10144. },
  10145. expand: function( event ) {
  10146. var newItem = this.active &&
  10147. this.active
  10148. .children( ".ui-menu " )
  10149. .children( ".ui-menu-item" )
  10150. .first();
  10151. if ( newItem && newItem.length ) {
  10152. this._open( newItem.parent() );
  10153. // Delay so Firefox will not hide activedescendant change in expanding submenu from AT
  10154. this._delay(function() {
  10155. this.focus( event, newItem );
  10156. });
  10157. }
  10158. },
  10159. next: function( event ) {
  10160. this._move( "next", "first", event );
  10161. },
  10162. previous: function( event ) {
  10163. this._move( "prev", "last", event );
  10164. },
  10165. isFirstItem: function() {
  10166. return this.active && !this.active.prevAll( ".ui-menu-item" ).length;
  10167. },
  10168. isLastItem: function() {
  10169. return this.active && !this.active.nextAll( ".ui-menu-item" ).length;
  10170. },
  10171. _move: function( direction, filter, event ) {
  10172. var next;
  10173. if ( this.active ) {
  10174. if ( direction === "first" || direction === "last" ) {
  10175. next = this.active
  10176. [ direction === "first" ? "prevAll" : "nextAll" ]( ".ui-menu-item" )
  10177. .eq( -1 );
  10178. } else {
  10179. next = this.active
  10180. [ direction + "All" ]( ".ui-menu-item" )
  10181. .eq( 0 );
  10182. }
  10183. }
  10184. if ( !next || !next.length || !this.active ) {
  10185. next = this.activeMenu.children( ".ui-menu-item" )[ filter ]();
  10186. }
  10187. this.focus( event, next );
  10188. },
  10189. nextPage: function( event ) {
  10190. var item, base, height;
  10191. if ( !this.active ) {
  10192. this.next( event );
  10193. return;
  10194. }
  10195. if ( this.isLastItem() ) {
  10196. return;
  10197. }
  10198. if ( this._hasScroll() ) {
  10199. base = this.active.offset().top;
  10200. height = this.element.height();
  10201. this.active.nextAll( ".ui-menu-item" ).each(function() {
  10202. item = $( this );
  10203. return item.offset().top - base - height < 0;
  10204. });
  10205. this.focus( event, item );
  10206. } else {
  10207. this.focus( event, this.activeMenu.children( ".ui-menu-item" )
  10208. [ !this.active ? "first" : "last" ]() );
  10209. }
  10210. },
  10211. previousPage: function( event ) {
  10212. var item, base, height;
  10213. if ( !this.active ) {
  10214. this.next( event );
  10215. return;
  10216. }
  10217. if ( this.isFirstItem() ) {
  10218. return;
  10219. }
  10220. if ( this._hasScroll() ) {
  10221. base = this.active.offset().top;
  10222. height = this.element.height();
  10223. this.active.prevAll( ".ui-menu-item" ).each(function() {
  10224. item = $( this );
  10225. return item.offset().top - base + height > 0;
  10226. });
  10227. this.focus( event, item );
  10228. } else {
  10229. this.focus( event, this.activeMenu.children( ".ui-menu-item" ).first() );
  10230. }
  10231. },
  10232. _hasScroll: function() {
  10233. return this.element.outerHeight() < this.element.prop( "scrollHeight" );
  10234. },
  10235. select: function( event ) {
  10236. // TODO: It should never be possible to not have an active item at this
  10237. // point, but the tests don't trigger mouseenter before click.
  10238. this.active = this.active || $( event.target ).closest( ".ui-menu-item" );
  10239. var ui = { item: this.active };
  10240. if ( !this.active.has( ".ui-menu" ).length ) {
  10241. this.collapseAll( event, true );
  10242. }
  10243. this._trigger( "select", event, ui );
  10244. }
  10245. });
  10246. }( jQuery ));
  10247. (function( $, undefined ) {
  10248. $.ui = $.ui || {};
  10249. var cachedScrollbarWidth,
  10250. max = Math.max,
  10251. abs = Math.abs,
  10252. round = Math.round,
  10253. rhorizontal = /left|center|right/,
  10254. rvertical = /top|center|bottom/,
  10255. roffset = /[\+\-]\d+(\.[\d]+)?%?/,
  10256. rposition = /^\w+/,
  10257. rpercent = /%$/,
  10258. _position = $.fn.position;
  10259. function getOffsets( offsets, width, height ) {
  10260. return [
  10261. parseFloat( offsets[ 0 ] ) * ( rpercent.test( offsets[ 0 ] ) ? width / 100 : 1 ),
  10262. parseFloat( offsets[ 1 ] ) * ( rpercent.test( offsets[ 1 ] ) ? height / 100 : 1 )
  10263. ];
  10264. }
  10265. function parseCss( element, property ) {
  10266. return parseInt( $.css( element, property ), 10 ) || 0;
  10267. }
  10268. function getDimensions( elem ) {
  10269. var raw = elem[0];
  10270. if ( raw.nodeType === 9 ) {
  10271. return {
  10272. width: elem.width(),
  10273. height: elem.height(),
  10274. offset: { top: 0, left: 0 }
  10275. };
  10276. }
  10277. if ( $.isWindow( raw ) ) {
  10278. return {
  10279. width: elem.width(),
  10280. height: elem.height(),
  10281. offset: { top: elem.scrollTop(), left: elem.scrollLeft() }
  10282. };
  10283. }
  10284. if ( raw.preventDefault ) {
  10285. return {
  10286. width: 0,
  10287. height: 0,
  10288. offset: { top: raw.pageY, left: raw.pageX }
  10289. };
  10290. }
  10291. return {
  10292. width: elem.outerWidth(),
  10293. height: elem.outerHeight(),
  10294. offset: elem.offset()
  10295. };
  10296. }
  10297. $.position = {
  10298. scrollbarWidth: function() {
  10299. if ( cachedScrollbarWidth !== undefined ) {
  10300. return cachedScrollbarWidth;
  10301. }
  10302. var w1, w2,
  10303. div = $( "<div style='display:block;width:50px;height:50px;overflow:hidden;'><div style='height:100px;width:auto;'></div></div>" ),
  10304. innerDiv = div.children()[0];
  10305. $( "body" ).append( div );
  10306. w1 = innerDiv.offsetWidth;
  10307. div.css( "overflow", "scroll" );
  10308. w2 = innerDiv.offsetWidth;
  10309. if ( w1 === w2 ) {
  10310. w2 = div[0].clientWidth;
  10311. }
  10312. div.remove();
  10313. return (cachedScrollbarWidth = w1 - w2);
  10314. },
  10315. getScrollInfo: function( within ) {
  10316. var overflowX = within.isWindow ? "" : within.element.css( "overflow-x" ),
  10317. overflowY = within.isWindow ? "" : within.element.css( "overflow-y" ),
  10318. hasOverflowX = overflowX === "scroll" ||
  10319. ( overflowX === "auto" && within.width < within.element[0].scrollWidth ),
  10320. hasOverflowY = overflowY === "scroll" ||
  10321. ( overflowY === "auto" && within.height < within.element[0].scrollHeight );
  10322. return {
  10323. width: hasOverflowX ? $.position.scrollbarWidth() : 0,
  10324. height: hasOverflowY ? $.position.scrollbarWidth() : 0
  10325. };
  10326. },
  10327. getWithinInfo: function( element ) {
  10328. var withinElement = $( element || window ),
  10329. isWindow = $.isWindow( withinElement[0] );
  10330. return {
  10331. element: withinElement,
  10332. isWindow: isWindow,
  10333. offset: withinElement.offset() || { left: 0, top: 0 },
  10334. scrollLeft: withinElement.scrollLeft(),
  10335. scrollTop: withinElement.scrollTop(),
  10336. width: isWindow ? withinElement.width() : withinElement.outerWidth(),
  10337. height: isWindow ? withinElement.height() : withinElement.outerHeight()
  10338. };
  10339. }
  10340. };
  10341. $.fn.position = function( options ) {
  10342. if ( !options || !options.of ) {
  10343. return _position.apply( this, arguments );
  10344. }
  10345. // make a copy, we don't want to modify arguments
  10346. options = $.extend( {}, options );
  10347. var atOffset, targetWidth, targetHeight, targetOffset, basePosition, dimensions,
  10348. target = $( options.of ),
  10349. within = $.position.getWithinInfo( options.within ),
  10350. scrollInfo = $.position.getScrollInfo( within ),
  10351. collision = ( options.collision || "flip" ).split( " " ),
  10352. offsets = {};
  10353. dimensions = getDimensions( target );
  10354. if ( target[0].preventDefault ) {
  10355. // force left top to allow flipping
  10356. options.at = "left top";
  10357. }
  10358. targetWidth = dimensions.width;
  10359. targetHeight = dimensions.height;
  10360. targetOffset = dimensions.offset;
  10361. // clone to reuse original targetOffset later
  10362. basePosition = $.extend( {}, targetOffset );
  10363. // force my and at to have valid horizontal and vertical positions
  10364. // if a value is missing or invalid, it will be converted to center
  10365. $.each( [ "my", "at" ], function() {
  10366. var pos = ( options[ this ] || "" ).split( " " ),
  10367. horizontalOffset,
  10368. verticalOffset;
  10369. if ( pos.length === 1) {
  10370. pos = rhorizontal.test( pos[ 0 ] ) ?
  10371. pos.concat( [ "center" ] ) :
  10372. rvertical.test( pos[ 0 ] ) ?
  10373. [ "center" ].concat( pos ) :
  10374. [ "center", "center" ];
  10375. }
  10376. pos[ 0 ] = rhorizontal.test( pos[ 0 ] ) ? pos[ 0 ] : "center";
  10377. pos[ 1 ] = rvertical.test( pos[ 1 ] ) ? pos[ 1 ] : "center";
  10378. // calculate offsets
  10379. horizontalOffset = roffset.exec( pos[ 0 ] );
  10380. verticalOffset = roffset.exec( pos[ 1 ] );
  10381. offsets[ this ] = [
  10382. horizontalOffset ? horizontalOffset[ 0 ] : 0,
  10383. verticalOffset ? verticalOffset[ 0 ] : 0
  10384. ];
  10385. // reduce to just the positions without the offsets
  10386. options[ this ] = [
  10387. rposition.exec( pos[ 0 ] )[ 0 ],
  10388. rposition.exec( pos[ 1 ] )[ 0 ]
  10389. ];
  10390. });
  10391. // normalize collision option
  10392. if ( collision.length === 1 ) {
  10393. collision[ 1 ] = collision[ 0 ];
  10394. }
  10395. if ( options.at[ 0 ] === "right" ) {
  10396. basePosition.left += targetWidth;
  10397. } else if ( options.at[ 0 ] === "center" ) {
  10398. basePosition.left += targetWidth / 2;
  10399. }
  10400. if ( options.at[ 1 ] === "bottom" ) {
  10401. basePosition.top += targetHeight;
  10402. } else if ( options.at[ 1 ] === "center" ) {
  10403. basePosition.top += targetHeight / 2;
  10404. }
  10405. atOffset = getOffsets( offsets.at, targetWidth, targetHeight );
  10406. basePosition.left += atOffset[ 0 ];
  10407. basePosition.top += atOffset[ 1 ];
  10408. return this.each(function() {
  10409. var collisionPosition, using,
  10410. elem = $( this ),
  10411. elemWidth = elem.outerWidth(),
  10412. elemHeight = elem.outerHeight(),
  10413. marginLeft = parseCss( this, "marginLeft" ),
  10414. marginTop = parseCss( this, "marginTop" ),
  10415. collisionWidth = elemWidth + marginLeft + parseCss( this, "marginRight" ) + scrollInfo.width,
  10416. collisionHeight = elemHeight + marginTop + parseCss( this, "marginBottom" ) + scrollInfo.height,
  10417. position = $.extend( {}, basePosition ),
  10418. myOffset = getOffsets( offsets.my, elem.outerWidth(), elem.outerHeight() );
  10419. if ( options.my[ 0 ] === "right" ) {
  10420. position.left -= elemWidth;
  10421. } else if ( options.my[ 0 ] === "center" ) {
  10422. position.left -= elemWidth / 2;
  10423. }
  10424. if ( options.my[ 1 ] === "bottom" ) {
  10425. position.top -= elemHeight;
  10426. } else if ( options.my[ 1 ] === "center" ) {
  10427. position.top -= elemHeight / 2;
  10428. }
  10429. position.left += myOffset[ 0 ];
  10430. position.top += myOffset[ 1 ];
  10431. // if the browser doesn't support fractions, then round for consistent results
  10432. if ( !$.support.offsetFractions ) {
  10433. position.left = round( position.left );
  10434. position.top = round( position.top );
  10435. }
  10436. collisionPosition = {
  10437. marginLeft: marginLeft,
  10438. marginTop: marginTop
  10439. };
  10440. $.each( [ "left", "top" ], function( i, dir ) {
  10441. if ( $.ui.position[ collision[ i ] ] ) {
  10442. $.ui.position[ collision[ i ] ][ dir ]( position, {
  10443. targetWidth: targetWidth,
  10444. targetHeight: targetHeight,
  10445. elemWidth: elemWidth,
  10446. elemHeight: elemHeight,
  10447. collisionPosition: collisionPosition,
  10448. collisionWidth: collisionWidth,
  10449. collisionHeight: collisionHeight,
  10450. offset: [ atOffset[ 0 ] + myOffset[ 0 ], atOffset [ 1 ] + myOffset[ 1 ] ],
  10451. my: options.my,
  10452. at: options.at,
  10453. within: within,
  10454. elem : elem
  10455. });
  10456. }
  10457. });
  10458. if ( options.using ) {
  10459. // adds feedback as second argument to using callback, if present
  10460. using = function( props ) {
  10461. var left = targetOffset.left - position.left,
  10462. right = left + targetWidth - elemWidth,
  10463. top = targetOffset.top - position.top,
  10464. bottom = top + targetHeight - elemHeight,
  10465. feedback = {
  10466. target: {
  10467. element: target,
  10468. left: targetOffset.left,
  10469. top: targetOffset.top,
  10470. width: targetWidth,
  10471. height: targetHeight
  10472. },
  10473. element: {
  10474. element: elem,
  10475. left: position.left,
  10476. top: position.top,
  10477. width: elemWidth,
  10478. height: elemHeight
  10479. },
  10480. horizontal: right < 0 ? "left" : left > 0 ? "right" : "center",
  10481. vertical: bottom < 0 ? "top" : top > 0 ? "bottom" : "middle"
  10482. };
  10483. if ( targetWidth < elemWidth && abs( left + right ) < targetWidth ) {
  10484. feedback.horizontal = "center";
  10485. }
  10486. if ( targetHeight < elemHeight && abs( top + bottom ) < targetHeight ) {
  10487. feedback.vertical = "middle";
  10488. }
  10489. if ( max( abs( left ), abs( right ) ) > max( abs( top ), abs( bottom ) ) ) {
  10490. feedback.important = "horizontal";
  10491. } else {
  10492. feedback.important = "vertical";
  10493. }
  10494. options.using.call( this, props, feedback );
  10495. };
  10496. }
  10497. elem.offset( $.extend( position, { using: using } ) );
  10498. });
  10499. };
  10500. $.ui.position = {
  10501. fit: {
  10502. left: function( position, data ) {
  10503. var within = data.within,
  10504. withinOffset = within.isWindow ? within.scrollLeft : within.offset.left,
  10505. outerWidth = within.width,
  10506. collisionPosLeft = position.left - data.collisionPosition.marginLeft,
  10507. overLeft = withinOffset - collisionPosLeft,
  10508. overRight = collisionPosLeft + data.collisionWidth - outerWidth - withinOffset,
  10509. newOverRight;
  10510. // element is wider than within
  10511. if ( data.collisionWidth > outerWidth ) {
  10512. // element is initially over the left side of within
  10513. if ( overLeft > 0 && overRight <= 0 ) {
  10514. newOverRight = position.left + overLeft + data.collisionWidth - outerWidth - withinOffset;
  10515. position.left += overLeft - newOverRight;
  10516. // element is initially over right side of within
  10517. } else if ( overRight > 0 && overLeft <= 0 ) {
  10518. position.left = withinOffset;
  10519. // element is initially over both left and right sides of within
  10520. } else {
  10521. if ( overLeft > overRight ) {
  10522. position.left = withinOffset + outerWidth - data.collisionWidth;
  10523. } else {
  10524. position.left = withinOffset;
  10525. }
  10526. }
  10527. // too far left -> align with left edge
  10528. } else if ( overLeft > 0 ) {
  10529. position.left += overLeft;
  10530. // too far right -> align with right edge
  10531. } else if ( overRight > 0 ) {
  10532. position.left -= overRight;
  10533. // adjust based on position and margin
  10534. } else {
  10535. position.left = max( position.left - collisionPosLeft, position.left );
  10536. }
  10537. },
  10538. top: function( position, data ) {
  10539. var within = data.within,
  10540. withinOffset = within.isWindow ? within.scrollTop : within.offset.top,
  10541. outerHeight = data.within.height,
  10542. collisionPosTop = position.top - data.collisionPosition.marginTop,
  10543. overTop = withinOffset - collisionPosTop,
  10544. overBottom = collisionPosTop + data.collisionHeight - outerHeight - withinOffset,
  10545. newOverBottom;
  10546. // element is taller than within
  10547. if ( data.collisionHeight > outerHeight ) {
  10548. // element is initially over the top of within
  10549. if ( overTop > 0 && overBottom <= 0 ) {
  10550. newOverBottom = position.top + overTop + data.collisionHeight - outerHeight - withinOffset;
  10551. position.top += overTop - newOverBottom;
  10552. // element is initially over bottom of within
  10553. } else if ( overBottom > 0 && overTop <= 0 ) {
  10554. position.top = withinOffset;
  10555. // element is initially over both top and bottom of within
  10556. } else {
  10557. if ( overTop > overBottom ) {
  10558. position.top = withinOffset + outerHeight - data.collisionHeight;
  10559. } else {
  10560. position.top = withinOffset;
  10561. }
  10562. }
  10563. // too far up -> align with top
  10564. } else if ( overTop > 0 ) {
  10565. position.top += overTop;
  10566. // too far down -> align with bottom edge
  10567. } else if ( overBottom > 0 ) {
  10568. position.top -= overBottom;
  10569. // adjust based on position and margin
  10570. } else {
  10571. position.top = max( position.top - collisionPosTop, position.top );
  10572. }
  10573. }
  10574. },
  10575. flip: {
  10576. left: function( position, data ) {
  10577. var within = data.within,
  10578. withinOffset = within.offset.left + within.scrollLeft,
  10579. outerWidth = within.width,
  10580. offsetLeft = within.isWindow ? within.scrollLeft : within.offset.left,
  10581. collisionPosLeft = position.left - data.collisionPosition.marginLeft,
  10582. overLeft = collisionPosLeft - offsetLeft,
  10583. overRight = collisionPosLeft + data.collisionWidth - outerWidth - offsetLeft,
  10584. myOffset = data.my[ 0 ] === "left" ?
  10585. -data.elemWidth :
  10586. data.my[ 0 ] === "right" ?
  10587. data.elemWidth :
  10588. 0,
  10589. atOffset = data.at[ 0 ] === "left" ?
  10590. data.targetWidth :
  10591. data.at[ 0 ] === "right" ?
  10592. -data.targetWidth :
  10593. 0,
  10594. offset = -2 * data.offset[ 0 ],
  10595. newOverRight,
  10596. newOverLeft;
  10597. if ( overLeft < 0 ) {
  10598. newOverRight = position.left + myOffset + atOffset + offset + data.collisionWidth - outerWidth - withinOffset;
  10599. if ( newOverRight < 0 || newOverRight < abs( overLeft ) ) {
  10600. position.left += myOffset + atOffset + offset;
  10601. }
  10602. }
  10603. else if ( overRight > 0 ) {
  10604. newOverLeft = position.left - data.collisionPosition.marginLeft + myOffset + atOffset + offset - offsetLeft;
  10605. if ( newOverLeft > 0 || abs( newOverLeft ) < overRight ) {
  10606. position.left += myOffset + atOffset + offset;
  10607. }
  10608. }
  10609. },
  10610. top: function( position, data ) {
  10611. var within = data.within,
  10612. withinOffset = within.offset.top + within.scrollTop,
  10613. outerHeight = within.height,
  10614. offsetTop = within.isWindow ? within.scrollTop : within.offset.top,
  10615. collisionPosTop = position.top - data.collisionPosition.marginTop,
  10616. overTop = collisionPosTop - offsetTop,
  10617. overBottom = collisionPosTop + data.collisionHeight - outerHeight - offsetTop,
  10618. top = data.my[ 1 ] === "top",
  10619. myOffset = top ?
  10620. -data.elemHeight :
  10621. data.my[ 1 ] === "bottom" ?
  10622. data.elemHeight :
  10623. 0,
  10624. atOffset = data.at[ 1 ] === "top" ?
  10625. data.targetHeight :
  10626. data.at[ 1 ] === "bottom" ?
  10627. -data.targetHeight :
  10628. 0,
  10629. offset = -2 * data.offset[ 1 ],
  10630. newOverTop,
  10631. newOverBottom;
  10632. if ( overTop < 0 ) {
  10633. newOverBottom = position.top + myOffset + atOffset + offset + data.collisionHeight - outerHeight - withinOffset;
  10634. if ( ( position.top + myOffset + atOffset + offset) > overTop && ( newOverBottom < 0 || newOverBottom < abs( overTop ) ) ) {
  10635. position.top += myOffset + atOffset + offset;
  10636. }
  10637. }
  10638. else if ( overBottom > 0 ) {
  10639. newOverTop = position.top - data.collisionPosition.marginTop + myOffset + atOffset + offset - offsetTop;
  10640. if ( ( position.top + myOffset + atOffset + offset) > overBottom && ( newOverTop > 0 || abs( newOverTop ) < overBottom ) ) {
  10641. position.top += myOffset + atOffset + offset;
  10642. }
  10643. }
  10644. }
  10645. },
  10646. flipfit: {
  10647. left: function() {
  10648. $.ui.position.flip.left.apply( this, arguments );
  10649. $.ui.position.fit.left.apply( this, arguments );
  10650. },
  10651. top: function() {
  10652. $.ui.position.flip.top.apply( this, arguments );
  10653. $.ui.position.fit.top.apply( this, arguments );
  10654. }
  10655. }
  10656. };
  10657. // fraction support test
  10658. (function () {
  10659. var testElement, testElementParent, testElementStyle, offsetLeft, i,
  10660. body = document.getElementsByTagName( "body" )[ 0 ],
  10661. div = document.createElement( "div" );
  10662. //Create a "fake body" for testing based on method used in jQuery.support
  10663. testElement = document.createElement( body ? "div" : "body" );
  10664. testElementStyle = {
  10665. visibility: "hidden",
  10666. width: 0,
  10667. height: 0,
  10668. border: 0,
  10669. margin: 0,
  10670. background: "none"
  10671. };
  10672. if ( body ) {
  10673. $.extend( testElementStyle, {
  10674. position: "absolute",
  10675. left: "-1000px",
  10676. top: "-1000px"
  10677. });
  10678. }
  10679. for ( i in testElementStyle ) {
  10680. testElement.style[ i ] = testElementStyle[ i ];
  10681. }
  10682. testElement.appendChild( div );
  10683. testElementParent = body || document.documentElement;
  10684. testElementParent.insertBefore( testElement, testElementParent.firstChild );
  10685. div.style.cssText = "position: absolute; left: 10.7432222px;";
  10686. offsetLeft = $( div ).offset().left;
  10687. $.support.offsetFractions = offsetLeft > 10 && offsetLeft < 11;
  10688. testElement.innerHTML = "";
  10689. testElementParent.removeChild( testElement );
  10690. })();
  10691. }( jQuery ) );
  10692. (function( $, undefined ) {
  10693. $.widget( "ui.progressbar", {
  10694. version: "1.10.1",
  10695. options: {
  10696. max: 100,
  10697. value: 0,
  10698. change: null,
  10699. complete: null
  10700. },
  10701. min: 0,
  10702. _create: function() {
  10703. // Constrain initial value
  10704. this.oldValue = this.options.value = this._constrainedValue();
  10705. this.element
  10706. .addClass( "ui-progressbar ui-widget ui-widget-content ui-corner-all" )
  10707. .attr({
  10708. // Only set static values, aria-valuenow and aria-valuemax are
  10709. // set inside _refreshValue()
  10710. role: "progressbar",
  10711. "aria-valuemin": this.min
  10712. });
  10713. this.valueDiv = $( "<div class='ui-progressbar-value ui-widget-header ui-corner-left'></div>" )
  10714. .appendTo( this.element );
  10715. this._refreshValue();
  10716. },
  10717. _destroy: function() {
  10718. this.element
  10719. .removeClass( "ui-progressbar ui-widget ui-widget-content ui-corner-all" )
  10720. .removeAttr( "role" )
  10721. .removeAttr( "aria-valuemin" )
  10722. .removeAttr( "aria-valuemax" )
  10723. .removeAttr( "aria-valuenow" );
  10724. this.valueDiv.remove();
  10725. },
  10726. value: function( newValue ) {
  10727. if ( newValue === undefined ) {
  10728. return this.options.value;
  10729. }
  10730. this.options.value = this._constrainedValue( newValue );
  10731. this._refreshValue();
  10732. },
  10733. _constrainedValue: function( newValue ) {
  10734. if ( newValue === undefined ) {
  10735. newValue = this.options.value;
  10736. }
  10737. this.indeterminate = newValue === false;
  10738. // sanitize value
  10739. if ( typeof newValue !== "number" ) {
  10740. newValue = 0;
  10741. }
  10742. return this.indeterminate ? false :
  10743. Math.min( this.options.max, Math.max( this.min, newValue ) );
  10744. },
  10745. _setOptions: function( options ) {
  10746. // Ensure "value" option is set after other values (like max)
  10747. var value = options.value;
  10748. delete options.value;
  10749. this._super( options );
  10750. this.options.value = this._constrainedValue( value );
  10751. this._refreshValue();
  10752. },
  10753. _setOption: function( key, value ) {
  10754. if ( key === "max" ) {
  10755. // Don't allow a max less than min
  10756. value = Math.max( this.min, value );
  10757. }
  10758. this._super( key, value );
  10759. },
  10760. _percentage: function() {
  10761. return this.indeterminate ? 100 : 100 * ( this.options.value - this.min ) / ( this.options.max - this.min );
  10762. },
  10763. _refreshValue: function() {
  10764. var value = this.options.value,
  10765. percentage = this._percentage();
  10766. this.valueDiv
  10767. .toggle( this.indeterminate || value > this.min )
  10768. .toggleClass( "ui-corner-right", value === this.options.max )
  10769. .width( percentage.toFixed(0) + "%" );
  10770. this.element.toggleClass( "ui-progressbar-indeterminate", this.indeterminate );
  10771. if ( this.indeterminate ) {
  10772. this.element.removeAttr( "aria-valuenow" );
  10773. if ( !this.overlayDiv ) {
  10774. this.overlayDiv = $( "<div class='ui-progressbar-overlay'></div>" ).appendTo( this.valueDiv );
  10775. }
  10776. } else {
  10777. this.element.attr({
  10778. "aria-valuemax": this.options.max,
  10779. "aria-valuenow": value
  10780. });
  10781. if ( this.overlayDiv ) {
  10782. this.overlayDiv.remove();
  10783. this.overlayDiv = null;
  10784. }
  10785. }
  10786. if ( this.oldValue !== value ) {
  10787. this.oldValue = value;
  10788. this._trigger( "change" );
  10789. }
  10790. if ( value === this.options.max ) {
  10791. this._trigger( "complete" );
  10792. }
  10793. }
  10794. });
  10795. })( jQuery );
  10796. (function( $, undefined ) {
  10797. // number of pages in a slider
  10798. // (how many times can you page up/down to go through the whole range)
  10799. var numPages = 5;
  10800. $.widget( "ui.slider", $.ui.mouse, {
  10801. version: "1.10.1",
  10802. widgetEventPrefix: "slide",
  10803. options: {
  10804. animate: false,
  10805. distance: 0,
  10806. max: 100,
  10807. min: 0,
  10808. orientation: "horizontal",
  10809. range: false,
  10810. step: 1,
  10811. value: 0,
  10812. values: null,
  10813. // callbacks
  10814. change: null,
  10815. slide: null,
  10816. start: null,
  10817. stop: null
  10818. },
  10819. _create: function() {
  10820. this._keySliding = false;
  10821. this._mouseSliding = false;
  10822. this._animateOff = true;
  10823. this._handleIndex = null;
  10824. this._detectOrientation();
  10825. this._mouseInit();
  10826. this.element
  10827. .addClass( "ui-slider" +
  10828. " ui-slider-" + this.orientation +
  10829. " ui-widget" +
  10830. " ui-widget-content" +
  10831. " ui-corner-all");
  10832. this._refresh();
  10833. this._setOption( "disabled", this.options.disabled );
  10834. this._animateOff = false;
  10835. },
  10836. _refresh: function() {
  10837. this._createRange();
  10838. this._createHandles();
  10839. this._setupEvents();
  10840. this._refreshValue();
  10841. },
  10842. _createHandles: function() {
  10843. var i, handleCount,
  10844. options = this.options,
  10845. existingHandles = this.element.find( ".ui-slider-handle" ).addClass( "ui-state-default ui-corner-all" ),
  10846. handle = "<a class='ui-slider-handle ui-state-default ui-corner-all' href='#'></a>",
  10847. handles = [];
  10848. handleCount = ( options.values && options.values.length ) || 1;
  10849. if ( existingHandles.length > handleCount ) {
  10850. existingHandles.slice( handleCount ).remove();
  10851. existingHandles = existingHandles.slice( 0, handleCount );
  10852. }
  10853. for ( i = existingHandles.length; i < handleCount; i++ ) {
  10854. handles.push( handle );
  10855. }
  10856. this.handles = existingHandles.add( $( handles.join( "" ) ).appendTo( this.element ) );
  10857. this.handle = this.handles.eq( 0 );
  10858. this.handles.each(function( i ) {
  10859. $( this ).data( "ui-slider-handle-index", i );
  10860. });
  10861. },
  10862. _createRange: function() {
  10863. var options = this.options,
  10864. classes = "";
  10865. if ( options.range ) {
  10866. if ( options.range === true ) {
  10867. if ( !options.values ) {
  10868. options.values = [ this._valueMin(), this._valueMin() ];
  10869. } else if ( options.values.length && options.values.length !== 2 ) {
  10870. options.values = [ options.values[0], options.values[0] ];
  10871. } else if ( $.isArray( options.values ) ) {
  10872. options.values = options.values.slice(0);
  10873. }
  10874. }
  10875. if ( !this.range || !this.range.length ) {
  10876. this.range = $( "<div></div>" )
  10877. .appendTo( this.element );
  10878. classes = "ui-slider-range" +
  10879. // note: this isn't the most fittingly semantic framework class for this element,
  10880. // but worked best visually with a variety of themes
  10881. " ui-widget-header ui-corner-all";
  10882. } else {
  10883. this.range.removeClass( "ui-slider-range-min ui-slider-range-max" )
  10884. // Handle range switching from true to min/max
  10885. .css({
  10886. "left": "",
  10887. "bottom": ""
  10888. });
  10889. }
  10890. this.range.addClass( classes +
  10891. ( ( options.range === "min" || options.range === "max" ) ? " ui-slider-range-" + options.range : "" ) );
  10892. } else {
  10893. this.range = $([]);
  10894. }
  10895. },
  10896. _setupEvents: function() {
  10897. var elements = this.handles.add( this.range ).filter( "a" );
  10898. this._off( elements );
  10899. this._on( elements, this._handleEvents );
  10900. this._hoverable( elements );
  10901. this._focusable( elements );
  10902. },
  10903. _destroy: function() {
  10904. this.handles.remove();
  10905. this.range.remove();
  10906. this.element
  10907. .removeClass( "ui-slider" +
  10908. " ui-slider-horizontal" +
  10909. " ui-slider-vertical" +
  10910. " ui-widget" +
  10911. " ui-widget-content" +
  10912. " ui-corner-all" );
  10913. this._mouseDestroy();
  10914. },
  10915. _mouseCapture: function( event ) {
  10916. var position, normValue, distance, closestHandle, index, allowed, offset, mouseOverHandle,
  10917. that = this,
  10918. o = this.options;
  10919. if ( o.disabled ) {
  10920. return false;
  10921. }
  10922. this.elementSize = {
  10923. width: this.element.outerWidth(),
  10924. height: this.element.outerHeight()
  10925. };
  10926. this.elementOffset = this.element.offset();
  10927. position = { x: event.pageX, y: event.pageY };
  10928. normValue = this._normValueFromMouse( position );
  10929. distance = this._valueMax() - this._valueMin() + 1;
  10930. this.handles.each(function( i ) {
  10931. var thisDistance = Math.abs( normValue - that.values(i) );
  10932. if (( distance > thisDistance ) ||
  10933. ( distance === thisDistance &&
  10934. (i === that._lastChangedValue || that.values(i) === o.min ))) {
  10935. distance = thisDistance;
  10936. closestHandle = $( this );
  10937. index = i;
  10938. }
  10939. });
  10940. allowed = this._start( event, index );
  10941. if ( allowed === false ) {
  10942. return false;
  10943. }
  10944. this._mouseSliding = true;
  10945. this._handleIndex = index;
  10946. closestHandle
  10947. .addClass( "ui-state-active" )
  10948. .focus();
  10949. offset = closestHandle.offset();
  10950. mouseOverHandle = !$( event.target ).parents().addBack().is( ".ui-slider-handle" );
  10951. this._clickOffset = mouseOverHandle ? { left: 0, top: 0 } : {
  10952. left: event.pageX - offset.left - ( closestHandle.width() / 2 ),
  10953. top: event.pageY - offset.top -
  10954. ( closestHandle.height() / 2 ) -
  10955. ( parseInt( closestHandle.css("borderTopWidth"), 10 ) || 0 ) -
  10956. ( parseInt( closestHandle.css("borderBottomWidth"), 10 ) || 0) +
  10957. ( parseInt( closestHandle.css("marginTop"), 10 ) || 0)
  10958. };
  10959. if ( !this.handles.hasClass( "ui-state-hover" ) ) {
  10960. this._slide( event, index, normValue );
  10961. }
  10962. this._animateOff = true;
  10963. return true;
  10964. },
  10965. _mouseStart: function() {
  10966. return true;
  10967. },
  10968. _mouseDrag: function( event ) {
  10969. var position = { x: event.pageX, y: event.pageY },
  10970. normValue = this._normValueFromMouse( position );
  10971. this._slide( event, this._handleIndex, normValue );
  10972. return false;
  10973. },
  10974. _mouseStop: function( event ) {
  10975. this.handles.removeClass( "ui-state-active" );
  10976. this._mouseSliding = false;
  10977. this._stop( event, this._handleIndex );
  10978. this._change( event, this._handleIndex );
  10979. this._handleIndex = null;
  10980. this._clickOffset = null;
  10981. this._animateOff = false;
  10982. return false;
  10983. },
  10984. _detectOrientation: function() {
  10985. this.orientation = ( this.options.orientation === "vertical" ) ? "vertical" : "horizontal";
  10986. },
  10987. _normValueFromMouse: function( position ) {
  10988. var pixelTotal,
  10989. pixelMouse,
  10990. percentMouse,
  10991. valueTotal,
  10992. valueMouse;
  10993. if ( this.orientation === "horizontal" ) {
  10994. pixelTotal = this.elementSize.width;
  10995. pixelMouse = position.x - this.elementOffset.left - ( this._clickOffset ? this._clickOffset.left : 0 );
  10996. } else {
  10997. pixelTotal = this.elementSize.height;
  10998. pixelMouse = position.y - this.elementOffset.top - ( this._clickOffset ? this._clickOffset.top : 0 );
  10999. }
  11000. percentMouse = ( pixelMouse / pixelTotal );
  11001. if ( percentMouse > 1 ) {
  11002. percentMouse = 1;
  11003. }
  11004. if ( percentMouse < 0 ) {
  11005. percentMouse = 0;
  11006. }
  11007. if ( this.orientation === "vertical" ) {
  11008. percentMouse = 1 - percentMouse;
  11009. }
  11010. valueTotal = this._valueMax() - this._valueMin();
  11011. valueMouse = this._valueMin() + percentMouse * valueTotal;
  11012. return this._trimAlignValue( valueMouse );
  11013. },
  11014. _start: function( event, index ) {
  11015. var uiHash = {
  11016. handle: this.handles[ index ],
  11017. value: this.value()
  11018. };
  11019. if ( this.options.values && this.options.values.length ) {
  11020. uiHash.value = this.values( index );
  11021. uiHash.values = this.values();
  11022. }
  11023. return this._trigger( "start", event, uiHash );
  11024. },
  11025. _slide: function( event, index, newVal ) {
  11026. var otherVal,
  11027. newValues,
  11028. allowed;
  11029. if ( this.options.values && this.options.values.length ) {
  11030. otherVal = this.values( index ? 0 : 1 );
  11031. if ( ( this.options.values.length === 2 && this.options.range === true ) &&
  11032. ( ( index === 0 && newVal > otherVal) || ( index === 1 && newVal < otherVal ) )
  11033. ) {
  11034. newVal = otherVal;
  11035. }
  11036. if ( newVal !== this.values( index ) ) {
  11037. newValues = this.values();
  11038. newValues[ index ] = newVal;
  11039. // A slide can be canceled by returning false from the slide callback
  11040. allowed = this._trigger( "slide", event, {
  11041. handle: this.handles[ index ],
  11042. value: newVal,
  11043. values: newValues
  11044. } );
  11045. otherVal = this.values( index ? 0 : 1 );
  11046. if ( allowed !== false ) {
  11047. this.values( index, newVal, true );
  11048. }
  11049. }
  11050. } else {
  11051. if ( newVal !== this.value() ) {
  11052. // A slide can be canceled by returning false from the slide callback
  11053. allowed = this._trigger( "slide", event, {
  11054. handle: this.handles[ index ],
  11055. value: newVal
  11056. } );
  11057. if ( allowed !== false ) {
  11058. this.value( newVal );
  11059. }
  11060. }
  11061. }
  11062. },
  11063. _stop: function( event, index ) {
  11064. var uiHash = {
  11065. handle: this.handles[ index ],
  11066. value: this.value()
  11067. };
  11068. if ( this.options.values && this.options.values.length ) {
  11069. uiHash.value = this.values( index );
  11070. uiHash.values = this.values();
  11071. }
  11072. this._trigger( "stop", event, uiHash );
  11073. },
  11074. _change: function( event, index ) {
  11075. if ( !this._keySliding && !this._mouseSliding ) {
  11076. var uiHash = {
  11077. handle: this.handles[ index ],
  11078. value: this.value()
  11079. };
  11080. if ( this.options.values && this.options.values.length ) {
  11081. uiHash.value = this.values( index );
  11082. uiHash.values = this.values();
  11083. }
  11084. //store the last changed value index for reference when handles overlap
  11085. this._lastChangedValue = index;
  11086. this._trigger( "change", event, uiHash );
  11087. }
  11088. },
  11089. value: function( newValue ) {
  11090. if ( arguments.length ) {
  11091. this.options.value = this._trimAlignValue( newValue );
  11092. this._refreshValue();
  11093. this._change( null, 0 );
  11094. return;
  11095. }
  11096. return this._value();
  11097. },
  11098. values: function( index, newValue ) {
  11099. var vals,
  11100. newValues,
  11101. i;
  11102. if ( arguments.length > 1 ) {
  11103. this.options.values[ index ] = this._trimAlignValue( newValue );
  11104. this._refreshValue();
  11105. this._change( null, index );
  11106. return;
  11107. }
  11108. if ( arguments.length ) {
  11109. if ( $.isArray( arguments[ 0 ] ) ) {
  11110. vals = this.options.values;
  11111. newValues = arguments[ 0 ];
  11112. for ( i = 0; i < vals.length; i += 1 ) {
  11113. vals[ i ] = this._trimAlignValue( newValues[ i ] );
  11114. this._change( null, i );
  11115. }
  11116. this._refreshValue();
  11117. } else {
  11118. if ( this.options.values && this.options.values.length ) {
  11119. return this._values( index );
  11120. } else {
  11121. return this.value();
  11122. }
  11123. }
  11124. } else {
  11125. return this._values();
  11126. }
  11127. },
  11128. _setOption: function( key, value ) {
  11129. var i,
  11130. valsLength = 0;
  11131. if ( key === "range" && this.options.range === true ) {
  11132. if ( value === "min" ) {
  11133. this.options.value = this._values( 0 );
  11134. this.options.values = null;
  11135. } else if ( value === "max" ) {
  11136. this.options.value = this._values( this.options.values.length-1 );
  11137. this.options.values = null;
  11138. }
  11139. }
  11140. if ( $.isArray( this.options.values ) ) {
  11141. valsLength = this.options.values.length;
  11142. }
  11143. $.Widget.prototype._setOption.apply( this, arguments );
  11144. switch ( key ) {
  11145. case "orientation":
  11146. this._detectOrientation();
  11147. this.element
  11148. .removeClass( "ui-slider-horizontal ui-slider-vertical" )
  11149. .addClass( "ui-slider-" + this.orientation );
  11150. this._refreshValue();
  11151. break;
  11152. case "value":
  11153. this._animateOff = true;
  11154. this._refreshValue();
  11155. this._change( null, 0 );
  11156. this._animateOff = false;
  11157. break;
  11158. case "values":
  11159. this._animateOff = true;
  11160. this._refreshValue();
  11161. for ( i = 0; i < valsLength; i += 1 ) {
  11162. this._change( null, i );
  11163. }
  11164. this._animateOff = false;
  11165. break;
  11166. case "min":
  11167. case "max":
  11168. this._animateOff = true;
  11169. this._refreshValue();
  11170. this._animateOff = false;
  11171. break;
  11172. case "range":
  11173. this._animateOff = true;
  11174. this._refresh();
  11175. this._animateOff = false;
  11176. break;
  11177. }
  11178. },
  11179. //internal value getter
  11180. // _value() returns value trimmed by min and max, aligned by step
  11181. _value: function() {
  11182. var val = this.options.value;
  11183. val = this._trimAlignValue( val );
  11184. return val;
  11185. },
  11186. //internal values getter
  11187. // _values() returns array of values trimmed by min and max, aligned by step
  11188. // _values( index ) returns single value trimmed by min and max, aligned by step
  11189. _values: function( index ) {
  11190. var val,
  11191. vals,
  11192. i;
  11193. if ( arguments.length ) {
  11194. val = this.options.values[ index ];
  11195. val = this._trimAlignValue( val );
  11196. return val;
  11197. } else if ( this.options.values && this.options.values.length ) {
  11198. // .slice() creates a copy of the array
  11199. // this copy gets trimmed by min and max and then returned
  11200. vals = this.options.values.slice();
  11201. for ( i = 0; i < vals.length; i+= 1) {
  11202. vals[ i ] = this._trimAlignValue( vals[ i ] );
  11203. }
  11204. return vals;
  11205. } else {
  11206. return [];
  11207. }
  11208. },
  11209. // returns the step-aligned value that val is closest to, between (inclusive) min and max
  11210. _trimAlignValue: function( val ) {
  11211. if ( val <= this._valueMin() ) {
  11212. return this._valueMin();
  11213. }
  11214. if ( val >= this._valueMax() ) {
  11215. return this._valueMax();
  11216. }
  11217. var step = ( this.options.step > 0 ) ? this.options.step : 1,
  11218. valModStep = (val - this._valueMin()) % step,
  11219. alignValue = val - valModStep;
  11220. if ( Math.abs(valModStep) * 2 >= step ) {
  11221. alignValue += ( valModStep > 0 ) ? step : ( -step );
  11222. }
  11223. // Since JavaScript has problems with large floats, round
  11224. // the final value to 5 digits after the decimal point (see #4124)
  11225. return parseFloat( alignValue.toFixed(5) );
  11226. },
  11227. _valueMin: function() {
  11228. return this.options.min;
  11229. },
  11230. _valueMax: function() {
  11231. return this.options.max;
  11232. },
  11233. _refreshValue: function() {
  11234. var lastValPercent, valPercent, value, valueMin, valueMax,
  11235. oRange = this.options.range,
  11236. o = this.options,
  11237. that = this,
  11238. animate = ( !this._animateOff ) ? o.animate : false,
  11239. _set = {};
  11240. if ( this.options.values && this.options.values.length ) {
  11241. this.handles.each(function( i ) {
  11242. valPercent = ( that.values(i) - that._valueMin() ) / ( that._valueMax() - that._valueMin() ) * 100;
  11243. _set[ that.orientation === "horizontal" ? "left" : "bottom" ] = valPercent + "%";
  11244. $( this ).stop( 1, 1 )[ animate ? "animate" : "css" ]( _set, o.animate );
  11245. if ( that.options.range === true ) {
  11246. if ( that.orientation === "horizontal" ) {
  11247. if ( i === 0 ) {
  11248. that.range.stop( 1, 1 )[ animate ? "animate" : "css" ]( { left: valPercent + "%" }, o.animate );
  11249. }
  11250. if ( i === 1 ) {
  11251. that.range[ animate ? "animate" : "css" ]( { width: ( valPercent - lastValPercent ) + "%" }, { queue: false, duration: o.animate } );
  11252. }
  11253. } else {
  11254. if ( i === 0 ) {
  11255. that.range.stop( 1, 1 )[ animate ? "animate" : "css" ]( { bottom: ( valPercent ) + "%" }, o.animate );
  11256. }
  11257. if ( i === 1 ) {
  11258. that.range[ animate ? "animate" : "css" ]( { height: ( valPercent - lastValPercent ) + "%" }, { queue: false, duration: o.animate } );
  11259. }
  11260. }
  11261. }
  11262. lastValPercent = valPercent;
  11263. });
  11264. } else {
  11265. value = this.value();
  11266. valueMin = this._valueMin();
  11267. valueMax = this._valueMax();
  11268. valPercent = ( valueMax !== valueMin ) ?
  11269. ( value - valueMin ) / ( valueMax - valueMin ) * 100 :
  11270. 0;
  11271. _set[ this.orientation === "horizontal" ? "left" : "bottom" ] = valPercent + "%";
  11272. this.handle.stop( 1, 1 )[ animate ? "animate" : "css" ]( _set, o.animate );
  11273. if ( oRange === "min" && this.orientation === "horizontal" ) {
  11274. this.range.stop( 1, 1 )[ animate ? "animate" : "css" ]( { width: valPercent + "%" }, o.animate );
  11275. }
  11276. if ( oRange === "max" && this.orientation === "horizontal" ) {
  11277. this.range[ animate ? "animate" : "css" ]( { width: ( 100 - valPercent ) + "%" }, { queue: false, duration: o.animate } );
  11278. }
  11279. if ( oRange === "min" && this.orientation === "vertical" ) {
  11280. this.range.stop( 1, 1 )[ animate ? "animate" : "css" ]( { height: valPercent + "%" }, o.animate );
  11281. }
  11282. if ( oRange === "max" && this.orientation === "vertical" ) {
  11283. this.range[ animate ? "animate" : "css" ]( { height: ( 100 - valPercent ) + "%" }, { queue: false, duration: o.animate } );
  11284. }
  11285. }
  11286. },
  11287. _handleEvents: {
  11288. keydown: function( event ) {
  11289. /*jshint maxcomplexity:25*/
  11290. var allowed, curVal, newVal, step,
  11291. index = $( event.target ).data( "ui-slider-handle-index" );
  11292. switch ( event.keyCode ) {
  11293. case $.ui.keyCode.HOME:
  11294. case $.ui.keyCode.END:
  11295. case $.ui.keyCode.PAGE_UP:
  11296. case $.ui.keyCode.PAGE_DOWN:
  11297. case $.ui.keyCode.UP:
  11298. case $.ui.keyCode.RIGHT:
  11299. case $.ui.keyCode.DOWN:
  11300. case $.ui.keyCode.LEFT:
  11301. event.preventDefault();
  11302. if ( !this._keySliding ) {
  11303. this._keySliding = true;
  11304. $( event.target ).addClass( "ui-state-active" );
  11305. allowed = this._start( event, index );
  11306. if ( allowed === false ) {
  11307. return;
  11308. }
  11309. }
  11310. break;
  11311. }
  11312. step = this.options.step;
  11313. if ( this.options.values && this.options.values.length ) {
  11314. curVal = newVal = this.values( index );
  11315. } else {
  11316. curVal = newVal = this.value();
  11317. }
  11318. switch ( event.keyCode ) {
  11319. case $.ui.keyCode.HOME:
  11320. newVal = this._valueMin();
  11321. break;
  11322. case $.ui.keyCode.END:
  11323. newVal = this._valueMax();
  11324. break;
  11325. case $.ui.keyCode.PAGE_UP:
  11326. newVal = this._trimAlignValue( curVal + ( (this._valueMax() - this._valueMin()) / numPages ) );
  11327. break;
  11328. case $.ui.keyCode.PAGE_DOWN:
  11329. newVal = this._trimAlignValue( curVal - ( (this._valueMax() - this._valueMin()) / numPages ) );
  11330. break;
  11331. case $.ui.keyCode.UP:
  11332. case $.ui.keyCode.RIGHT:
  11333. if ( curVal === this._valueMax() ) {
  11334. return;
  11335. }
  11336. newVal = this._trimAlignValue( curVal + step );
  11337. break;
  11338. case $.ui.keyCode.DOWN:
  11339. case $.ui.keyCode.LEFT:
  11340. if ( curVal === this._valueMin() ) {
  11341. return;
  11342. }
  11343. newVal = this._trimAlignValue( curVal - step );
  11344. break;
  11345. }
  11346. this._slide( event, index, newVal );
  11347. },
  11348. click: function( event ) {
  11349. event.preventDefault();
  11350. },
  11351. keyup: function( event ) {
  11352. var index = $( event.target ).data( "ui-slider-handle-index" );
  11353. if ( this._keySliding ) {
  11354. this._keySliding = false;
  11355. this._stop( event, index );
  11356. this._change( event, index );
  11357. $( event.target ).removeClass( "ui-state-active" );
  11358. }
  11359. }
  11360. }
  11361. });
  11362. }(jQuery));
  11363. (function( $ ) {
  11364. function modifier( fn ) {
  11365. return function() {
  11366. var previous = this.element.val();
  11367. fn.apply( this, arguments );
  11368. this._refresh();
  11369. if ( previous !== this.element.val() ) {
  11370. this._trigger( "change" );
  11371. }
  11372. };
  11373. }
  11374. $.widget( "ui.spinner", {
  11375. version: "1.10.1",
  11376. defaultElement: "<input>",
  11377. widgetEventPrefix: "spin",
  11378. options: {
  11379. culture: null,
  11380. icons: {
  11381. down: "ui-icon-triangle-1-s",
  11382. up: "ui-icon-triangle-1-n"
  11383. },
  11384. incremental: true,
  11385. max: null,
  11386. min: null,
  11387. numberFormat: null,
  11388. page: 10,
  11389. step: 1,
  11390. change: null,
  11391. spin: null,
  11392. start: null,
  11393. stop: null
  11394. },
  11395. _create: function() {
  11396. // handle string values that need to be parsed
  11397. this._setOption( "max", this.options.max );
  11398. this._setOption( "min", this.options.min );
  11399. this._setOption( "step", this.options.step );
  11400. // format the value, but don't constrain
  11401. this._value( this.element.val(), true );
  11402. this._draw();
  11403. this._on( this._events );
  11404. this._refresh();
  11405. // turning off autocomplete prevents the browser from remembering the
  11406. // value when navigating through history, so we re-enable autocomplete
  11407. // if the page is unloaded before the widget is destroyed. #7790
  11408. this._on( this.window, {
  11409. beforeunload: function() {
  11410. this.element.removeAttr( "autocomplete" );
  11411. }
  11412. });
  11413. },
  11414. _getCreateOptions: function() {
  11415. var options = {},
  11416. element = this.element;
  11417. $.each( [ "min", "max", "step" ], function( i, option ) {
  11418. var value = element.attr( option );
  11419. if ( value !== undefined && value.length ) {
  11420. options[ option ] = value;
  11421. }
  11422. });
  11423. return options;
  11424. },
  11425. _events: {
  11426. keydown: function( event ) {
  11427. if ( this._start( event ) && this._keydown( event ) ) {
  11428. event.preventDefault();
  11429. }
  11430. },
  11431. keyup: "_stop",
  11432. focus: function() {
  11433. this.previous = this.element.val();
  11434. },
  11435. blur: function( event ) {
  11436. if ( this.cancelBlur ) {
  11437. delete this.cancelBlur;
  11438. return;
  11439. }
  11440. this._refresh();
  11441. if ( this.previous !== this.element.val() ) {
  11442. this._trigger( "change", event );
  11443. }
  11444. },
  11445. mousewheel: function( event, delta ) {
  11446. if ( !delta ) {
  11447. return;
  11448. }
  11449. if ( !this.spinning && !this._start( event ) ) {
  11450. return false;
  11451. }
  11452. this._spin( (delta > 0 ? 1 : -1) * this.options.step, event );
  11453. clearTimeout( this.mousewheelTimer );
  11454. this.mousewheelTimer = this._delay(function() {
  11455. if ( this.spinning ) {
  11456. this._stop( event );
  11457. }
  11458. }, 100 );
  11459. event.preventDefault();
  11460. },
  11461. "mousedown .ui-spinner-button": function( event ) {
  11462. var previous;
  11463. // We never want the buttons to have focus; whenever the user is
  11464. // interacting with the spinner, the focus should be on the input.
  11465. // If the input is focused then this.previous is properly set from
  11466. // when the input first received focus. If the input is not focused
  11467. // then we need to set this.previous based on the value before spinning.
  11468. previous = this.element[0] === this.document[0].activeElement ?
  11469. this.previous : this.element.val();
  11470. function checkFocus() {
  11471. var isActive = this.element[0] === this.document[0].activeElement;
  11472. if ( !isActive ) {
  11473. this.element.focus();
  11474. this.previous = previous;
  11475. // support: IE
  11476. // IE sets focus asynchronously, so we need to check if focus
  11477. // moved off of the input because the user clicked on the button.
  11478. this._delay(function() {
  11479. this.previous = previous;
  11480. });
  11481. }
  11482. }
  11483. // ensure focus is on (or stays on) the text field
  11484. event.preventDefault();
  11485. checkFocus.call( this );
  11486. // support: IE
  11487. // IE doesn't prevent moving focus even with event.preventDefault()
  11488. // so we set a flag to know when we should ignore the blur event
  11489. // and check (again) if focus moved off of the input.
  11490. this.cancelBlur = true;
  11491. this._delay(function() {
  11492. delete this.cancelBlur;
  11493. checkFocus.call( this );
  11494. });
  11495. if ( this._start( event ) === false ) {
  11496. return;
  11497. }
  11498. this._repeat( null, $( event.currentTarget ).hasClass( "ui-spinner-up" ) ? 1 : -1, event );
  11499. },
  11500. "mouseup .ui-spinner-button": "_stop",
  11501. "mouseenter .ui-spinner-button": function( event ) {
  11502. // button will add ui-state-active if mouse was down while mouseleave and kept down
  11503. if ( !$( event.currentTarget ).hasClass( "ui-state-active" ) ) {
  11504. return;
  11505. }
  11506. if ( this._start( event ) === false ) {
  11507. return false;
  11508. }
  11509. this._repeat( null, $( event.currentTarget ).hasClass( "ui-spinner-up" ) ? 1 : -1, event );
  11510. },
  11511. // TODO: do we really want to consider this a stop?
  11512. // shouldn't we just stop the repeater and wait until mouseup before
  11513. // we trigger the stop event?
  11514. "mouseleave .ui-spinner-button": "_stop"
  11515. },
  11516. _draw: function() {
  11517. var uiSpinner = this.uiSpinner = this.element
  11518. .addClass( "ui-spinner-input" )
  11519. .attr( "autocomplete", "off" )
  11520. .wrap( this._uiSpinnerHtml() )
  11521. .parent()
  11522. // add buttons
  11523. .append( this._buttonHtml() );
  11524. this.element.attr( "role", "spinbutton" );
  11525. // button bindings
  11526. this.buttons = uiSpinner.find( ".ui-spinner-button" )
  11527. .attr( "tabIndex", -1 )
  11528. .button()
  11529. .removeClass( "ui-corner-all" );
  11530. // IE 6 doesn't understand height: 50% for the buttons
  11531. // unless the wrapper has an explicit height
  11532. if ( this.buttons.height() > Math.ceil( uiSpinner.height() * 0.5 ) &&
  11533. uiSpinner.height() > 0 ) {
  11534. uiSpinner.height( uiSpinner.height() );
  11535. }
  11536. // disable spinner if element was already disabled
  11537. if ( this.options.disabled ) {
  11538. this.disable();
  11539. }
  11540. },
  11541. _keydown: function( event ) {
  11542. var options = this.options,
  11543. keyCode = $.ui.keyCode;
  11544. switch ( event.keyCode ) {
  11545. case keyCode.UP:
  11546. this._repeat( null, 1, event );
  11547. return true;
  11548. case keyCode.DOWN:
  11549. this._repeat( null, -1, event );
  11550. return true;
  11551. case keyCode.PAGE_UP:
  11552. this._repeat( null, options.page, event );
  11553. return true;
  11554. case keyCode.PAGE_DOWN:
  11555. this._repeat( null, -options.page, event );
  11556. return true;
  11557. }
  11558. return false;
  11559. },
  11560. _uiSpinnerHtml: function() {
  11561. return "<span class='ui-spinner ui-widget ui-widget-content ui-corner-all'></span>";
  11562. },
  11563. _buttonHtml: function() {
  11564. return "" +
  11565. "<a class='ui-spinner-button ui-spinner-up ui-corner-tr'>" +
  11566. "<span class='ui-icon " + this.options.icons.up + "'>&#9650;</span>" +
  11567. "</a>" +
  11568. "<a class='ui-spinner-button ui-spinner-down ui-corner-br'>" +
  11569. "<span class='ui-icon " + this.options.icons.down + "'>&#9660;</span>" +
  11570. "</a>";
  11571. },
  11572. _start: function( event ) {
  11573. if ( !this.spinning && this._trigger( "start", event ) === false ) {
  11574. return false;
  11575. }
  11576. if ( !this.counter ) {
  11577. this.counter = 1;
  11578. }
  11579. this.spinning = true;
  11580. return true;
  11581. },
  11582. _repeat: function( i, steps, event ) {
  11583. i = i || 500;
  11584. clearTimeout( this.timer );
  11585. this.timer = this._delay(function() {
  11586. this._repeat( 40, steps, event );
  11587. }, i );
  11588. this._spin( steps * this.options.step, event );
  11589. },
  11590. _spin: function( step, event ) {
  11591. var value = this.value() || 0;
  11592. if ( !this.counter ) {
  11593. this.counter = 1;
  11594. }
  11595. value = this._adjustValue( value + step * this._increment( this.counter ) );
  11596. if ( !this.spinning || this._trigger( "spin", event, { value: value } ) !== false) {
  11597. this._value( value );
  11598. this.counter++;
  11599. }
  11600. },
  11601. _increment: function( i ) {
  11602. var incremental = this.options.incremental;
  11603. if ( incremental ) {
  11604. return $.isFunction( incremental ) ?
  11605. incremental( i ) :
  11606. Math.floor( i*i*i/50000 - i*i/500 + 17*i/200 + 1 );
  11607. }
  11608. return 1;
  11609. },
  11610. _precision: function() {
  11611. var precision = this._precisionOf( this.options.step );
  11612. if ( this.options.min !== null ) {
  11613. precision = Math.max( precision, this._precisionOf( this.options.min ) );
  11614. }
  11615. return precision;
  11616. },
  11617. _precisionOf: function( num ) {
  11618. var str = num.toString(),
  11619. decimal = str.indexOf( "." );
  11620. return decimal === -1 ? 0 : str.length - decimal - 1;
  11621. },
  11622. _adjustValue: function( value ) {
  11623. var base, aboveMin,
  11624. options = this.options;
  11625. // make sure we're at a valid step
  11626. // - find out where we are relative to the base (min or 0)
  11627. base = options.min !== null ? options.min : 0;
  11628. aboveMin = value - base;
  11629. // - round to the nearest step
  11630. aboveMin = Math.round(aboveMin / options.step) * options.step;
  11631. // - rounding is based on 0, so adjust back to our base
  11632. value = base + aboveMin;
  11633. // fix precision from bad JS floating point math
  11634. value = parseFloat( value.toFixed( this._precision() ) );
  11635. // clamp the value
  11636. if ( options.max !== null && value > options.max) {
  11637. return options.max;
  11638. }
  11639. if ( options.min !== null && value < options.min ) {
  11640. return options.min;
  11641. }
  11642. return value;
  11643. },
  11644. _stop: function( event ) {
  11645. if ( !this.spinning ) {
  11646. return;
  11647. }
  11648. clearTimeout( this.timer );
  11649. clearTimeout( this.mousewheelTimer );
  11650. this.counter = 0;
  11651. this.spinning = false;
  11652. this._trigger( "stop", event );
  11653. },
  11654. _setOption: function( key, value ) {
  11655. if ( key === "culture" || key === "numberFormat" ) {
  11656. var prevValue = this._parse( this.element.val() );
  11657. this.options[ key ] = value;
  11658. this.element.val( this._format( prevValue ) );
  11659. return;
  11660. }
  11661. if ( key === "max" || key === "min" || key === "step" ) {
  11662. if ( typeof value === "string" ) {
  11663. value = this._parse( value );
  11664. }
  11665. }
  11666. if ( key === "icons" ) {
  11667. this.buttons.first().find( ".ui-icon" )
  11668. .removeClass( this.options.icons.up )
  11669. .addClass( value.up );
  11670. this.buttons.last().find( ".ui-icon" )
  11671. .removeClass( this.options.icons.down )
  11672. .addClass( value.down );
  11673. }
  11674. this._super( key, value );
  11675. if ( key === "disabled" ) {
  11676. if ( value ) {
  11677. this.element.prop( "disabled", true );
  11678. this.buttons.button( "disable" );
  11679. } else {
  11680. this.element.prop( "disabled", false );
  11681. this.buttons.button( "enable" );
  11682. }
  11683. }
  11684. },
  11685. _setOptions: modifier(function( options ) {
  11686. this._super( options );
  11687. this._value( this.element.val() );
  11688. }),
  11689. _parse: function( val ) {
  11690. if ( typeof val === "string" && val !== "" ) {
  11691. val = window.Globalize && this.options.numberFormat ?
  11692. Globalize.parseFloat( val, 10, this.options.culture ) : +val;
  11693. }
  11694. return val === "" || isNaN( val ) ? null : val;
  11695. },
  11696. _format: function( value ) {
  11697. if ( value === "" ) {
  11698. return "";
  11699. }
  11700. return window.Globalize && this.options.numberFormat ?
  11701. Globalize.format( value, this.options.numberFormat, this.options.culture ) :
  11702. value;
  11703. },
  11704. _refresh: function() {
  11705. this.element.attr({
  11706. "aria-valuemin": this.options.min,
  11707. "aria-valuemax": this.options.max,
  11708. // TODO: what should we do with values that can't be parsed?
  11709. "aria-valuenow": this._parse( this.element.val() )
  11710. });
  11711. },
  11712. // update the value without triggering change
  11713. _value: function( value, allowAny ) {
  11714. var parsed;
  11715. if ( value !== "" ) {
  11716. parsed = this._parse( value );
  11717. if ( parsed !== null ) {
  11718. if ( !allowAny ) {
  11719. parsed = this._adjustValue( parsed );
  11720. }
  11721. value = this._format( parsed );
  11722. }
  11723. }
  11724. this.element.val( value );
  11725. this._refresh();
  11726. },
  11727. _destroy: function() {
  11728. this.element
  11729. .removeClass( "ui-spinner-input" )
  11730. .prop( "disabled", false )
  11731. .removeAttr( "autocomplete" )
  11732. .removeAttr( "role" )
  11733. .removeAttr( "aria-valuemin" )
  11734. .removeAttr( "aria-valuemax" )
  11735. .removeAttr( "aria-valuenow" );
  11736. this.uiSpinner.replaceWith( this.element );
  11737. },
  11738. stepUp: modifier(function( steps ) {
  11739. this._stepUp( steps );
  11740. }),
  11741. _stepUp: function( steps ) {
  11742. if ( this._start() ) {
  11743. this._spin( (steps || 1) * this.options.step );
  11744. this._stop();
  11745. }
  11746. },
  11747. stepDown: modifier(function( steps ) {
  11748. this._stepDown( steps );
  11749. }),
  11750. _stepDown: function( steps ) {
  11751. if ( this._start() ) {
  11752. this._spin( (steps || 1) * -this.options.step );
  11753. this._stop();
  11754. }
  11755. },
  11756. pageUp: modifier(function( pages ) {
  11757. this._stepUp( (pages || 1) * this.options.page );
  11758. }),
  11759. pageDown: modifier(function( pages ) {
  11760. this._stepDown( (pages || 1) * this.options.page );
  11761. }),
  11762. value: function( newVal ) {
  11763. if ( !arguments.length ) {
  11764. return this._parse( this.element.val() );
  11765. }
  11766. modifier( this._value ).call( this, newVal );
  11767. },
  11768. widget: function() {
  11769. return this.uiSpinner;
  11770. }
  11771. });
  11772. }( jQuery ) );
  11773. (function( $, undefined ) {
  11774. var tabId = 0,
  11775. rhash = /#.*$/;
  11776. function getNextTabId() {
  11777. return ++tabId;
  11778. }
  11779. function isLocal( anchor ) {
  11780. return anchor.hash.length > 1 &&
  11781. decodeURIComponent( anchor.href.replace( rhash, "" ) ) ===
  11782. decodeURIComponent( location.href.replace( rhash, "" ) );
  11783. }
  11784. $.widget( "ui.tabs", {
  11785. version: "1.10.1",
  11786. delay: 300,
  11787. options: {
  11788. active: null,
  11789. collapsible: false,
  11790. event: "click",
  11791. heightStyle: "content",
  11792. hide: null,
  11793. show: null,
  11794. // callbacks
  11795. activate: null,
  11796. beforeActivate: null,
  11797. beforeLoad: null,
  11798. load: null
  11799. },
  11800. _create: function() {
  11801. var that = this,
  11802. options = this.options;
  11803. this.running = false;
  11804. this.element
  11805. .addClass( "ui-tabs ui-widget ui-widget-content ui-corner-all" )
  11806. .toggleClass( "ui-tabs-collapsible", options.collapsible )
  11807. // Prevent users from focusing disabled tabs via click
  11808. .delegate( ".ui-tabs-nav > li", "mousedown" + this.eventNamespace, function( event ) {
  11809. if ( $( this ).is( ".ui-state-disabled" ) ) {
  11810. event.preventDefault();
  11811. }
  11812. })
  11813. // support: IE <9
  11814. // Preventing the default action in mousedown doesn't prevent IE
  11815. // from focusing the element, so if the anchor gets focused, blur.
  11816. // We don't have to worry about focusing the previously focused
  11817. // element since clicking on a non-focusable element should focus
  11818. // the body anyway.
  11819. .delegate( ".ui-tabs-anchor", "focus" + this.eventNamespace, function() {
  11820. if ( $( this ).closest( "li" ).is( ".ui-state-disabled" ) ) {
  11821. this.blur();
  11822. }
  11823. });
  11824. this._processTabs();
  11825. options.active = this._initialActive();
  11826. // Take disabling tabs via class attribute from HTML
  11827. // into account and update option properly.
  11828. if ( $.isArray( options.disabled ) ) {
  11829. options.disabled = $.unique( options.disabled.concat(
  11830. $.map( this.tabs.filter( ".ui-state-disabled" ), function( li ) {
  11831. return that.tabs.index( li );
  11832. })
  11833. ) ).sort();
  11834. }
  11835. // check for length avoids error when initializing empty list
  11836. if ( this.options.active !== false && this.anchors.length ) {
  11837. this.active = this._findActive( options.active );
  11838. } else {
  11839. this.active = $();
  11840. }
  11841. this._refresh();
  11842. if ( this.active.length ) {
  11843. this.load( options.active );
  11844. }
  11845. },
  11846. _initialActive: function() {
  11847. var active = this.options.active,
  11848. collapsible = this.options.collapsible,
  11849. locationHash = location.hash.substring( 1 );
  11850. if ( active === null ) {
  11851. // check the fragment identifier in the URL
  11852. if ( locationHash ) {
  11853. this.tabs.each(function( i, tab ) {
  11854. if ( $( tab ).attr( "aria-controls" ) === locationHash ) {
  11855. active = i;
  11856. return false;
  11857. }
  11858. });
  11859. }
  11860. // check for a tab marked active via a class
  11861. if ( active === null ) {
  11862. active = this.tabs.index( this.tabs.filter( ".ui-tabs-active" ) );
  11863. }
  11864. // no active tab, set to false
  11865. if ( active === null || active === -1 ) {
  11866. active = this.tabs.length ? 0 : false;
  11867. }
  11868. }
  11869. // handle numbers: negative, out of range
  11870. if ( active !== false ) {
  11871. active = this.tabs.index( this.tabs.eq( active ) );
  11872. if ( active === -1 ) {
  11873. active = collapsible ? false : 0;
  11874. }
  11875. }
  11876. // don't allow collapsible: false and active: false
  11877. if ( !collapsible && active === false && this.anchors.length ) {
  11878. active = 0;
  11879. }
  11880. return active;
  11881. },
  11882. _getCreateEventData: function() {
  11883. return {
  11884. tab: this.active,
  11885. panel: !this.active.length ? $() : this._getPanelForTab( this.active )
  11886. };
  11887. },
  11888. _tabKeydown: function( event ) {
  11889. /*jshint maxcomplexity:15*/
  11890. var focusedTab = $( this.document[0].activeElement ).closest( "li" ),
  11891. selectedIndex = this.tabs.index( focusedTab ),
  11892. goingForward = true;
  11893. if ( this._handlePageNav( event ) ) {
  11894. return;
  11895. }
  11896. switch ( event.keyCode ) {
  11897. case $.ui.keyCode.RIGHT:
  11898. case $.ui.keyCode.DOWN:
  11899. selectedIndex++;
  11900. break;
  11901. case $.ui.keyCode.UP:
  11902. case $.ui.keyCode.LEFT:
  11903. goingForward = false;
  11904. selectedIndex--;
  11905. break;
  11906. case $.ui.keyCode.END:
  11907. selectedIndex = this.anchors.length - 1;
  11908. break;
  11909. case $.ui.keyCode.HOME:
  11910. selectedIndex = 0;
  11911. break;
  11912. case $.ui.keyCode.SPACE:
  11913. // Activate only, no collapsing
  11914. event.preventDefault();
  11915. clearTimeout( this.activating );
  11916. this._activate( selectedIndex );
  11917. return;
  11918. case $.ui.keyCode.ENTER:
  11919. // Toggle (cancel delayed activation, allow collapsing)
  11920. event.preventDefault();
  11921. clearTimeout( this.activating );
  11922. // Determine if we should collapse or activate
  11923. this._activate( selectedIndex === this.options.active ? false : selectedIndex );
  11924. return;
  11925. default:
  11926. return;
  11927. }
  11928. // Focus the appropriate tab, based on which key was pressed
  11929. event.preventDefault();
  11930. clearTimeout( this.activating );
  11931. selectedIndex = this._focusNextTab( selectedIndex, goingForward );
  11932. // Navigating with control key will prevent automatic activation
  11933. if ( !event.ctrlKey ) {
  11934. // Update aria-selected immediately so that AT think the tab is already selected.
  11935. // Otherwise AT may confuse the user by stating that they need to activate the tab,
  11936. // but the tab will already be activated by the time the announcement finishes.
  11937. focusedTab.attr( "aria-selected", "false" );
  11938. this.tabs.eq( selectedIndex ).attr( "aria-selected", "true" );
  11939. this.activating = this._delay(function() {
  11940. this.option( "active", selectedIndex );
  11941. }, this.delay );
  11942. }
  11943. },
  11944. _panelKeydown: function( event ) {
  11945. if ( this._handlePageNav( event ) ) {
  11946. return;
  11947. }
  11948. // Ctrl+up moves focus to the current tab
  11949. if ( event.ctrlKey && event.keyCode === $.ui.keyCode.UP ) {
  11950. event.preventDefault();
  11951. this.active.focus();
  11952. }
  11953. },
  11954. // Alt+page up/down moves focus to the previous/next tab (and activates)
  11955. _handlePageNav: function( event ) {
  11956. if ( event.altKey && event.keyCode === $.ui.keyCode.PAGE_UP ) {
  11957. this._activate( this._focusNextTab( this.options.active - 1, false ) );
  11958. return true;
  11959. }
  11960. if ( event.altKey && event.keyCode === $.ui.keyCode.PAGE_DOWN ) {
  11961. this._activate( this._focusNextTab( this.options.active + 1, true ) );
  11962. return true;
  11963. }
  11964. },
  11965. _findNextTab: function( index, goingForward ) {
  11966. var lastTabIndex = this.tabs.length - 1;
  11967. function constrain() {
  11968. if ( index > lastTabIndex ) {
  11969. index = 0;
  11970. }
  11971. if ( index < 0 ) {
  11972. index = lastTabIndex;
  11973. }
  11974. return index;
  11975. }
  11976. while ( $.inArray( constrain(), this.options.disabled ) !== -1 ) {
  11977. index = goingForward ? index + 1 : index - 1;
  11978. }
  11979. return index;
  11980. },
  11981. _focusNextTab: function( index, goingForward ) {
  11982. index = this._findNextTab( index, goingForward );
  11983. this.tabs.eq( index ).focus();
  11984. return index;
  11985. },
  11986. _setOption: function( key, value ) {
  11987. if ( key === "active" ) {
  11988. // _activate() will handle invalid values and update this.options
  11989. this._activate( value );
  11990. return;
  11991. }
  11992. if ( key === "disabled" ) {
  11993. // don't use the widget factory's disabled handling
  11994. this._setupDisabled( value );
  11995. return;
  11996. }
  11997. this._super( key, value);
  11998. if ( key === "collapsible" ) {
  11999. this.element.toggleClass( "ui-tabs-collapsible", value );
  12000. // Setting collapsible: false while collapsed; open first panel
  12001. if ( !value && this.options.active === false ) {
  12002. this._activate( 0 );
  12003. }
  12004. }
  12005. if ( key === "event" ) {
  12006. this._setupEvents( value );
  12007. }
  12008. if ( key === "heightStyle" ) {
  12009. this._setupHeightStyle( value );
  12010. }
  12011. },
  12012. _tabId: function( tab ) {
  12013. return tab.attr( "aria-controls" ) || "ui-tabs-" + getNextTabId();
  12014. },
  12015. _sanitizeSelector: function( hash ) {
  12016. return hash ? hash.replace( /[!"$%&'()*+,.\/:;<=>?@\[\]\^`{|}~]/g, "\\$&" ) : "";
  12017. },
  12018. refresh: function() {
  12019. var options = this.options,
  12020. lis = this.tablist.children( ":has(a[href])" );
  12021. // get disabled tabs from class attribute from HTML
  12022. // this will get converted to a boolean if needed in _refresh()
  12023. options.disabled = $.map( lis.filter( ".ui-state-disabled" ), function( tab ) {
  12024. return lis.index( tab );
  12025. });
  12026. this._processTabs();
  12027. // was collapsed or no tabs
  12028. if ( options.active === false || !this.anchors.length ) {
  12029. options.active = false;
  12030. this.active = $();
  12031. // was active, but active tab is gone
  12032. } else if ( this.active.length && !$.contains( this.tablist[ 0 ], this.active[ 0 ] ) ) {
  12033. // all remaining tabs are disabled
  12034. if ( this.tabs.length === options.disabled.length ) {
  12035. options.active = false;
  12036. this.active = $();
  12037. // activate previous tab
  12038. } else {
  12039. this._activate( this._findNextTab( Math.max( 0, options.active - 1 ), false ) );
  12040. }
  12041. // was active, active tab still exists
  12042. } else {
  12043. // make sure active index is correct
  12044. options.active = this.tabs.index( this.active );
  12045. }
  12046. this._refresh();
  12047. },
  12048. _refresh: function() {
  12049. this._setupDisabled( this.options.disabled );
  12050. this._setupEvents( this.options.event );
  12051. this._setupHeightStyle( this.options.heightStyle );
  12052. this.tabs.not( this.active ).attr({
  12053. "aria-selected": "false",
  12054. tabIndex: -1
  12055. });
  12056. this.panels.not( this._getPanelForTab( this.active ) )
  12057. .hide()
  12058. .attr({
  12059. "aria-expanded": "false",
  12060. "aria-hidden": "true"
  12061. });
  12062. // Make sure one tab is in the tab order
  12063. if ( !this.active.length ) {
  12064. this.tabs.eq( 0 ).attr( "tabIndex", 0 );
  12065. } else {
  12066. this.active
  12067. .addClass( "ui-tabs-active ui-state-active" )
  12068. .attr({
  12069. "aria-selected": "true",
  12070. tabIndex: 0
  12071. });
  12072. this._getPanelForTab( this.active )
  12073. .show()
  12074. .attr({
  12075. "aria-expanded": "true",
  12076. "aria-hidden": "false"
  12077. });
  12078. }
  12079. },
  12080. _processTabs: function() {
  12081. var that = this;
  12082. this.tablist = this._getList()
  12083. .addClass( "ui-tabs-nav ui-helper-reset ui-helper-clearfix ui-widget-header ui-corner-all" )
  12084. .attr( "role", "tablist" );
  12085. this.tabs = this.tablist.find( "> li:has(a[href])" )
  12086. .addClass( "ui-state-default ui-corner-top" )
  12087. .attr({
  12088. role: "tab",
  12089. tabIndex: -1
  12090. });
  12091. this.anchors = this.tabs.map(function() {
  12092. return $( "a", this )[ 0 ];
  12093. })
  12094. .addClass( "ui-tabs-anchor" )
  12095. .attr({
  12096. role: "presentation",
  12097. tabIndex: -1
  12098. });
  12099. this.panels = $();
  12100. this.anchors.each(function( i, anchor ) {
  12101. var selector, panel, panelId,
  12102. anchorId = $( anchor ).uniqueId().attr( "id" ),
  12103. tab = $( anchor ).closest( "li" ),
  12104. originalAriaControls = tab.attr( "aria-controls" );
  12105. // inline tab
  12106. if ( isLocal( anchor ) ) {
  12107. selector = anchor.hash;
  12108. panel = that.element.find( that._sanitizeSelector( selector ) );
  12109. // remote tab
  12110. } else {
  12111. panelId = that._tabId( tab );
  12112. selector = "#" + panelId;
  12113. panel = that.element.find( selector );
  12114. if ( !panel.length ) {
  12115. panel = that._createPanel( panelId );
  12116. panel.insertAfter( that.panels[ i - 1 ] || that.tablist );
  12117. }
  12118. panel.attr( "aria-live", "polite" );
  12119. }
  12120. if ( panel.length) {
  12121. that.panels = that.panels.add( panel );
  12122. }
  12123. if ( originalAriaControls ) {
  12124. tab.data( "ui-tabs-aria-controls", originalAriaControls );
  12125. }
  12126. tab.attr({
  12127. "aria-controls": selector.substring( 1 ),
  12128. "aria-labelledby": anchorId
  12129. });
  12130. panel.attr( "aria-labelledby", anchorId );
  12131. });
  12132. this.panels
  12133. .addClass( "ui-tabs-panel ui-widget-content ui-corner-bottom" )
  12134. .attr( "role", "tabpanel" );
  12135. },
  12136. // allow overriding how to find the list for rare usage scenarios (#7715)
  12137. _getList: function() {
  12138. return this.element.find( "ol,ul" ).eq( 0 );
  12139. },
  12140. _createPanel: function( id ) {
  12141. return $( "<div>" )
  12142. .attr( "id", id )
  12143. .addClass( "ui-tabs-panel ui-widget-content ui-corner-bottom" )
  12144. .data( "ui-tabs-destroy", true );
  12145. },
  12146. _setupDisabled: function( disabled ) {
  12147. if ( $.isArray( disabled ) ) {
  12148. if ( !disabled.length ) {
  12149. disabled = false;
  12150. } else if ( disabled.length === this.anchors.length ) {
  12151. disabled = true;
  12152. }
  12153. }
  12154. // disable tabs
  12155. for ( var i = 0, li; ( li = this.tabs[ i ] ); i++ ) {
  12156. if ( disabled === true || $.inArray( i, disabled ) !== -1 ) {
  12157. $( li )
  12158. .addClass( "ui-state-disabled" )
  12159. .attr( "aria-disabled", "true" );
  12160. } else {
  12161. $( li )
  12162. .removeClass( "ui-state-disabled" )
  12163. .removeAttr( "aria-disabled" );
  12164. }
  12165. }
  12166. this.options.disabled = disabled;
  12167. },
  12168. _setupEvents: function( event ) {
  12169. var events = {
  12170. click: function( event ) {
  12171. event.preventDefault();
  12172. }
  12173. };
  12174. if ( event ) {
  12175. $.each( event.split(" "), function( index, eventName ) {
  12176. events[ eventName ] = "_eventHandler";
  12177. });
  12178. }
  12179. this._off( this.anchors.add( this.tabs ).add( this.panels ) );
  12180. this._on( this.anchors, events );
  12181. this._on( this.tabs, { keydown: "_tabKeydown" } );
  12182. this._on( this.panels, { keydown: "_panelKeydown" } );
  12183. this._focusable( this.tabs );
  12184. this._hoverable( this.tabs );
  12185. },
  12186. _setupHeightStyle: function( heightStyle ) {
  12187. var maxHeight,
  12188. parent = this.element.parent();
  12189. if ( heightStyle === "fill" ) {
  12190. maxHeight = parent.height();
  12191. maxHeight -= this.element.outerHeight() - this.element.height();
  12192. this.element.siblings( ":visible" ).each(function() {
  12193. var elem = $( this ),
  12194. position = elem.css( "position" );
  12195. if ( position === "absolute" || position === "fixed" ) {
  12196. return;
  12197. }
  12198. maxHeight -= elem.outerHeight( true );
  12199. });
  12200. this.element.children().not( this.panels ).each(function() {
  12201. maxHeight -= $( this ).outerHeight( true );
  12202. });
  12203. this.panels.each(function() {
  12204. $( this ).height( Math.max( 0, maxHeight -
  12205. $( this ).innerHeight() + $( this ).height() ) );
  12206. })
  12207. .css( "overflow", "auto" );
  12208. } else if ( heightStyle === "auto" ) {
  12209. maxHeight = 0;
  12210. this.panels.each(function() {
  12211. maxHeight = Math.max( maxHeight, $( this ).height( "" ).height() );
  12212. }).height( maxHeight );
  12213. }
  12214. },
  12215. _eventHandler: function( event ) {
  12216. var options = this.options,
  12217. active = this.active,
  12218. anchor = $( event.currentTarget ),
  12219. tab = anchor.closest( "li" ),
  12220. clickedIsActive = tab[ 0 ] === active[ 0 ],
  12221. collapsing = clickedIsActive && options.collapsible,
  12222. toShow = collapsing ? $() : this._getPanelForTab( tab ),
  12223. toHide = !active.length ? $() : this._getPanelForTab( active ),
  12224. eventData = {
  12225. oldTab: active,
  12226. oldPanel: toHide,
  12227. newTab: collapsing ? $() : tab,
  12228. newPanel: toShow
  12229. };
  12230. event.preventDefault();
  12231. if ( tab.hasClass( "ui-state-disabled" ) ||
  12232. // tab is already loading
  12233. tab.hasClass( "ui-tabs-loading" ) ||
  12234. // can't switch durning an animation
  12235. this.running ||
  12236. // click on active header, but not collapsible
  12237. ( clickedIsActive && !options.collapsible ) ||
  12238. // allow canceling activation
  12239. ( this._trigger( "beforeActivate", event, eventData ) === false ) ) {
  12240. return;
  12241. }
  12242. options.active = collapsing ? false : this.tabs.index( tab );
  12243. this.active = clickedIsActive ? $() : tab;
  12244. if ( this.xhr ) {
  12245. this.xhr.abort();
  12246. }
  12247. if ( !toHide.length && !toShow.length ) {
  12248. $.error( "jQuery UI Tabs: Mismatching fragment identifier." );
  12249. }
  12250. if ( toShow.length ) {
  12251. this.load( this.tabs.index( tab ), event );
  12252. }
  12253. this._toggle( event, eventData );
  12254. },
  12255. // handles show/hide for selecting tabs
  12256. _toggle: function( event, eventData ) {
  12257. var that = this,
  12258. toShow = eventData.newPanel,
  12259. toHide = eventData.oldPanel;
  12260. this.running = true;
  12261. function complete() {
  12262. that.running = false;
  12263. that._trigger( "activate", event, eventData );
  12264. }
  12265. function show() {
  12266. eventData.newTab.closest( "li" ).addClass( "ui-tabs-active ui-state-active" );
  12267. if ( toShow.length && that.options.show ) {
  12268. that._show( toShow, that.options.show, complete );
  12269. } else {
  12270. toShow.show();
  12271. complete();
  12272. }
  12273. }
  12274. // start out by hiding, then showing, then completing
  12275. if ( toHide.length && this.options.hide ) {
  12276. this._hide( toHide, this.options.hide, function() {
  12277. eventData.oldTab.closest( "li" ).removeClass( "ui-tabs-active ui-state-active" );
  12278. show();
  12279. });
  12280. } else {
  12281. eventData.oldTab.closest( "li" ).removeClass( "ui-tabs-active ui-state-active" );
  12282. toHide.hide();
  12283. show();
  12284. }
  12285. toHide.attr({
  12286. "aria-expanded": "false",
  12287. "aria-hidden": "true"
  12288. });
  12289. eventData.oldTab.attr( "aria-selected", "false" );
  12290. // If we're switching tabs, remove the old tab from the tab order.
  12291. // If we're opening from collapsed state, remove the previous tab from the tab order.
  12292. // If we're collapsing, then keep the collapsing tab in the tab order.
  12293. if ( toShow.length && toHide.length ) {
  12294. eventData.oldTab.attr( "tabIndex", -1 );
  12295. } else if ( toShow.length ) {
  12296. this.tabs.filter(function() {
  12297. return $( this ).attr( "tabIndex" ) === 0;
  12298. })
  12299. .attr( "tabIndex", -1 );
  12300. }
  12301. toShow.attr({
  12302. "aria-expanded": "true",
  12303. "aria-hidden": "false"
  12304. });
  12305. eventData.newTab.attr({
  12306. "aria-selected": "true",
  12307. tabIndex: 0
  12308. });
  12309. },
  12310. _activate: function( index ) {
  12311. var anchor,
  12312. active = this._findActive( index );
  12313. // trying to activate the already active panel
  12314. if ( active[ 0 ] === this.active[ 0 ] ) {
  12315. return;
  12316. }
  12317. // trying to collapse, simulate a click on the current active header
  12318. if ( !active.length ) {
  12319. active = this.active;
  12320. }
  12321. anchor = active.find( ".ui-tabs-anchor" )[ 0 ];
  12322. this._eventHandler({
  12323. target: anchor,
  12324. currentTarget: anchor,
  12325. preventDefault: $.noop
  12326. });
  12327. },
  12328. _findActive: function( index ) {
  12329. return index === false ? $() : this.tabs.eq( index );
  12330. },
  12331. _getIndex: function( index ) {
  12332. // meta-function to give users option to provide a href string instead of a numerical index.
  12333. if ( typeof index === "string" ) {
  12334. index = this.anchors.index( this.anchors.filter( "[href$='" + index + "']" ) );
  12335. }
  12336. return index;
  12337. },
  12338. _destroy: function() {
  12339. if ( this.xhr ) {
  12340. this.xhr.abort();
  12341. }
  12342. this.element.removeClass( "ui-tabs ui-widget ui-widget-content ui-corner-all ui-tabs-collapsible" );
  12343. this.tablist
  12344. .removeClass( "ui-tabs-nav ui-helper-reset ui-helper-clearfix ui-widget-header ui-corner-all" )
  12345. .removeAttr( "role" );
  12346. this.anchors
  12347. .removeClass( "ui-tabs-anchor" )
  12348. .removeAttr( "role" )
  12349. .removeAttr( "tabIndex" )
  12350. .removeUniqueId();
  12351. this.tabs.add( this.panels ).each(function() {
  12352. if ( $.data( this, "ui-tabs-destroy" ) ) {
  12353. $( this ).remove();
  12354. } else {
  12355. $( this )
  12356. .removeClass( "ui-state-default ui-state-active ui-state-disabled " +
  12357. "ui-corner-top ui-corner-bottom ui-widget-content ui-tabs-active ui-tabs-panel" )
  12358. .removeAttr( "tabIndex" )
  12359. .removeAttr( "aria-live" )
  12360. .removeAttr( "aria-busy" )
  12361. .removeAttr( "aria-selected" )
  12362. .removeAttr( "aria-labelledby" )
  12363. .removeAttr( "aria-hidden" )
  12364. .removeAttr( "aria-expanded" )
  12365. .removeAttr( "role" );
  12366. }
  12367. });
  12368. this.tabs.each(function() {
  12369. var li = $( this ),
  12370. prev = li.data( "ui-tabs-aria-controls" );
  12371. if ( prev ) {
  12372. li
  12373. .attr( "aria-controls", prev )
  12374. .removeData( "ui-tabs-aria-controls" );
  12375. } else {
  12376. li.removeAttr( "aria-controls" );
  12377. }
  12378. });
  12379. this.panels.show();
  12380. if ( this.options.heightStyle !== "content" ) {
  12381. this.panels.css( "height", "" );
  12382. }
  12383. },
  12384. enable: function( index ) {
  12385. var disabled = this.options.disabled;
  12386. if ( disabled === false ) {
  12387. return;
  12388. }
  12389. if ( index === undefined ) {
  12390. disabled = false;
  12391. } else {
  12392. index = this._getIndex( index );
  12393. if ( $.isArray( disabled ) ) {
  12394. disabled = $.map( disabled, function( num ) {
  12395. return num !== index ? num : null;
  12396. });
  12397. } else {
  12398. disabled = $.map( this.tabs, function( li, num ) {
  12399. return num !== index ? num : null;
  12400. });
  12401. }
  12402. }
  12403. this._setupDisabled( disabled );
  12404. },
  12405. disable: function( index ) {
  12406. var disabled = this.options.disabled;
  12407. if ( disabled === true ) {
  12408. return;
  12409. }
  12410. if ( index === undefined ) {
  12411. disabled = true;
  12412. } else {
  12413. index = this._getIndex( index );
  12414. if ( $.inArray( index, disabled ) !== -1 ) {
  12415. return;
  12416. }
  12417. if ( $.isArray( disabled ) ) {
  12418. disabled = $.merge( [ index ], disabled ).sort();
  12419. } else {
  12420. disabled = [ index ];
  12421. }
  12422. }
  12423. this._setupDisabled( disabled );
  12424. },
  12425. load: function( index, event ) {
  12426. index = this._getIndex( index );
  12427. var that = this,
  12428. tab = this.tabs.eq( index ),
  12429. anchor = tab.find( ".ui-tabs-anchor" ),
  12430. panel = this._getPanelForTab( tab ),
  12431. eventData = {
  12432. tab: tab,
  12433. panel: panel
  12434. };
  12435. // not remote
  12436. if ( isLocal( anchor[ 0 ] ) ) {
  12437. return;
  12438. }
  12439. this.xhr = $.ajax( this._ajaxSettings( anchor, event, eventData ) );
  12440. // support: jQuery <1.8
  12441. // jQuery <1.8 returns false if the request is canceled in beforeSend,
  12442. // but as of 1.8, $.ajax() always returns a jqXHR object.
  12443. if ( this.xhr && this.xhr.statusText !== "canceled" ) {
  12444. tab.addClass( "ui-tabs-loading" );
  12445. panel.attr( "aria-busy", "true" );
  12446. this.xhr
  12447. .success(function( response ) {
  12448. // support: jQuery <1.8
  12449. // http://bugs.jquery.com/ticket/11778
  12450. setTimeout(function() {
  12451. panel.html( response );
  12452. that._trigger( "load", event, eventData );
  12453. }, 1 );
  12454. })
  12455. .complete(function( jqXHR, status ) {
  12456. // support: jQuery <1.8
  12457. // http://bugs.jquery.com/ticket/11778
  12458. setTimeout(function() {
  12459. if ( status === "abort" ) {
  12460. that.panels.stop( false, true );
  12461. }
  12462. tab.removeClass( "ui-tabs-loading" );
  12463. panel.removeAttr( "aria-busy" );
  12464. if ( jqXHR === that.xhr ) {
  12465. delete that.xhr;
  12466. }
  12467. }, 1 );
  12468. });
  12469. }
  12470. },
  12471. _ajaxSettings: function( anchor, event, eventData ) {
  12472. var that = this;
  12473. return {
  12474. url: anchor.attr( "href" ),
  12475. beforeSend: function( jqXHR, settings ) {
  12476. return that._trigger( "beforeLoad", event,
  12477. $.extend( { jqXHR : jqXHR, ajaxSettings: settings }, eventData ) );
  12478. }
  12479. };
  12480. },
  12481. _getPanelForTab: function( tab ) {
  12482. var id = $( tab ).attr( "aria-controls" );
  12483. return this.element.find( this._sanitizeSelector( "#" + id ) );
  12484. }
  12485. });
  12486. })( jQuery );
  12487. (function( $ ) {
  12488. var increments = 0;
  12489. function addDescribedBy( elem, id ) {
  12490. var describedby = (elem.attr( "aria-describedby" ) || "").split( /\s+/ );
  12491. describedby.push( id );
  12492. elem
  12493. .data( "ui-tooltip-id", id )
  12494. .attr( "aria-describedby", $.trim( describedby.join( " " ) ) );
  12495. }
  12496. function removeDescribedBy( elem ) {
  12497. var id = elem.data( "ui-tooltip-id" ),
  12498. describedby = (elem.attr( "aria-describedby" ) || "").split( /\s+/ ),
  12499. index = $.inArray( id, describedby );
  12500. if ( index !== -1 ) {
  12501. describedby.splice( index, 1 );
  12502. }
  12503. elem.removeData( "ui-tooltip-id" );
  12504. describedby = $.trim( describedby.join( " " ) );
  12505. if ( describedby ) {
  12506. elem.attr( "aria-describedby", describedby );
  12507. } else {
  12508. elem.removeAttr( "aria-describedby" );
  12509. }
  12510. }
  12511. $.widget( "ui.tooltip", {
  12512. version: "1.10.1",
  12513. options: {
  12514. content: function() {
  12515. // support: IE<9, Opera in jQuery <1.7
  12516. // .text() can't accept undefined, so coerce to a string
  12517. var title = $( this ).attr( "title" ) || "";
  12518. // Escape title, since we're going from an attribute to raw HTML
  12519. return $( "<a>" ).text( title ).html();
  12520. },
  12521. hide: true,
  12522. // Disabled elements have inconsistent behavior across browsers (#8661)
  12523. items: "[title]:not([disabled])",
  12524. position: {
  12525. my: "left top+15",
  12526. at: "left bottom",
  12527. collision: "flipfit flip"
  12528. },
  12529. show: true,
  12530. tooltipClass: null,
  12531. track: false,
  12532. // callbacks
  12533. close: null,
  12534. open: null
  12535. },
  12536. _create: function() {
  12537. this._on({
  12538. mouseover: "open",
  12539. focusin: "open"
  12540. });
  12541. // IDs of generated tooltips, needed for destroy
  12542. this.tooltips = {};
  12543. // IDs of parent tooltips where we removed the title attribute
  12544. this.parents = {};
  12545. if ( this.options.disabled ) {
  12546. this._disable();
  12547. }
  12548. },
  12549. _setOption: function( key, value ) {
  12550. var that = this;
  12551. if ( key === "disabled" ) {
  12552. this[ value ? "_disable" : "_enable" ]();
  12553. this.options[ key ] = value;
  12554. // disable element style changes
  12555. return;
  12556. }
  12557. this._super( key, value );
  12558. if ( key === "content" ) {
  12559. $.each( this.tooltips, function( id, element ) {
  12560. that._updateContent( element );
  12561. });
  12562. }
  12563. },
  12564. _disable: function() {
  12565. var that = this;
  12566. // close open tooltips
  12567. $.each( this.tooltips, function( id, element ) {
  12568. var event = $.Event( "blur" );
  12569. event.target = event.currentTarget = element[0];
  12570. that.close( event, true );
  12571. });
  12572. // remove title attributes to prevent native tooltips
  12573. this.element.find( this.options.items ).addBack().each(function() {
  12574. var element = $( this );
  12575. if ( element.is( "[title]" ) ) {
  12576. element
  12577. .data( "ui-tooltip-title", element.attr( "title" ) )
  12578. .attr( "title", "" );
  12579. }
  12580. });
  12581. },
  12582. _enable: function() {
  12583. // restore title attributes
  12584. this.element.find( this.options.items ).addBack().each(function() {
  12585. var element = $( this );
  12586. if ( element.data( "ui-tooltip-title" ) ) {
  12587. element.attr( "title", element.data( "ui-tooltip-title" ) );
  12588. }
  12589. });
  12590. },
  12591. open: function( event ) {
  12592. var that = this,
  12593. target = $( event ? event.target : this.element )
  12594. // we need closest here due to mouseover bubbling,
  12595. // but always pointing at the same event target
  12596. .closest( this.options.items );
  12597. // No element to show a tooltip for or the tooltip is already open
  12598. if ( !target.length || target.data( "ui-tooltip-id" ) ) {
  12599. return;
  12600. }
  12601. if ( target.attr( "title" ) ) {
  12602. target.data( "ui-tooltip-title", target.attr( "title" ) );
  12603. }
  12604. target.data( "ui-tooltip-open", true );
  12605. // kill parent tooltips, custom or native, for hover
  12606. if ( event && event.type === "mouseover" ) {
  12607. target.parents().each(function() {
  12608. var parent = $( this ),
  12609. blurEvent;
  12610. if ( parent.data( "ui-tooltip-open" ) ) {
  12611. blurEvent = $.Event( "blur" );
  12612. blurEvent.target = blurEvent.currentTarget = this;
  12613. that.close( blurEvent, true );
  12614. }
  12615. if ( parent.attr( "title" ) ) {
  12616. parent.uniqueId();
  12617. that.parents[ this.id ] = {
  12618. element: this,
  12619. title: parent.attr( "title" )
  12620. };
  12621. parent.attr( "title", "" );
  12622. }
  12623. });
  12624. }
  12625. this._updateContent( target, event );
  12626. },
  12627. _updateContent: function( target, event ) {
  12628. var content,
  12629. contentOption = this.options.content,
  12630. that = this,
  12631. eventType = event ? event.type : null;
  12632. if ( typeof contentOption === "string" ) {
  12633. return this._open( event, target, contentOption );
  12634. }
  12635. content = contentOption.call( target[0], function( response ) {
  12636. // ignore async response if tooltip was closed already
  12637. if ( !target.data( "ui-tooltip-open" ) ) {
  12638. return;
  12639. }
  12640. // IE may instantly serve a cached response for ajax requests
  12641. // delay this call to _open so the other call to _open runs first
  12642. that._delay(function() {
  12643. // jQuery creates a special event for focusin when it doesn't
  12644. // exist natively. To improve performance, the native event
  12645. // object is reused and the type is changed. Therefore, we can't
  12646. // rely on the type being correct after the event finished
  12647. // bubbling, so we set it back to the previous value. (#8740)
  12648. if ( event ) {
  12649. event.type = eventType;
  12650. }
  12651. this._open( event, target, response );
  12652. });
  12653. });
  12654. if ( content ) {
  12655. this._open( event, target, content );
  12656. }
  12657. },
  12658. _open: function( event, target, content ) {
  12659. var tooltip, events, delayedShow,
  12660. positionOption = $.extend( {}, this.options.position );
  12661. if ( !content ) {
  12662. return;
  12663. }
  12664. // Content can be updated multiple times. If the tooltip already
  12665. // exists, then just update the content and bail.
  12666. tooltip = this._find( target );
  12667. if ( tooltip.length ) {
  12668. tooltip.find( ".ui-tooltip-content" ).html( content );
  12669. return;
  12670. }
  12671. // if we have a title, clear it to prevent the native tooltip
  12672. // we have to check first to avoid defining a title if none exists
  12673. // (we don't want to cause an element to start matching [title])
  12674. //
  12675. // We use removeAttr only for key events, to allow IE to export the correct
  12676. // accessible attributes. For mouse events, set to empty string to avoid
  12677. // native tooltip showing up (happens only when removing inside mouseover).
  12678. if ( target.is( "[title]" ) ) {
  12679. if ( event && event.type === "mouseover" ) {
  12680. target.attr( "title", "" );
  12681. } else {
  12682. target.removeAttr( "title" );
  12683. }
  12684. }
  12685. tooltip = this._tooltip( target );
  12686. addDescribedBy( target, tooltip.attr( "id" ) );
  12687. tooltip.find( ".ui-tooltip-content" ).html( content );
  12688. function position( event ) {
  12689. positionOption.of = event;
  12690. if ( tooltip.is( ":hidden" ) ) {
  12691. return;
  12692. }
  12693. tooltip.position( positionOption );
  12694. }
  12695. if ( this.options.track && event && /^mouse/.test( event.type ) ) {
  12696. this._on( this.document, {
  12697. mousemove: position
  12698. });
  12699. // trigger once to override element-relative positioning
  12700. position( event );
  12701. } else {
  12702. tooltip.position( $.extend({
  12703. of: target
  12704. }, this.options.position ) );
  12705. }
  12706. tooltip.hide();
  12707. this._show( tooltip, this.options.show );
  12708. // Handle tracking tooltips that are shown with a delay (#8644). As soon
  12709. // as the tooltip is visible, position the tooltip using the most recent
  12710. // event.
  12711. if ( this.options.show && this.options.show.delay ) {
  12712. delayedShow = this.delayedShow = setInterval(function() {
  12713. if ( tooltip.is( ":visible" ) ) {
  12714. position( positionOption.of );
  12715. clearInterval( delayedShow );
  12716. }
  12717. }, $.fx.interval );
  12718. }
  12719. this._trigger( "open", event, { tooltip: tooltip } );
  12720. events = {
  12721. keyup: function( event ) {
  12722. if ( event.keyCode === $.ui.keyCode.ESCAPE ) {
  12723. var fakeEvent = $.Event(event);
  12724. fakeEvent.currentTarget = target[0];
  12725. this.close( fakeEvent, true );
  12726. }
  12727. },
  12728. remove: function() {
  12729. this._removeTooltip( tooltip );
  12730. }
  12731. };
  12732. if ( !event || event.type === "mouseover" ) {
  12733. events.mouseleave = "close";
  12734. }
  12735. if ( !event || event.type === "focusin" ) {
  12736. events.focusout = "close";
  12737. }
  12738. this._on( true, target, events );
  12739. },
  12740. close: function( event ) {
  12741. var that = this,
  12742. target = $( event ? event.currentTarget : this.element ),
  12743. tooltip = this._find( target );
  12744. // disabling closes the tooltip, so we need to track when we're closing
  12745. // to avoid an infinite loop in case the tooltip becomes disabled on close
  12746. if ( this.closing ) {
  12747. return;
  12748. }
  12749. // Clear the interval for delayed tracking tooltips
  12750. clearInterval( this.delayedShow );
  12751. // only set title if we had one before (see comment in _open())
  12752. if ( target.data( "ui-tooltip-title" ) ) {
  12753. target.attr( "title", target.data( "ui-tooltip-title" ) );
  12754. }
  12755. removeDescribedBy( target );
  12756. tooltip.stop( true );
  12757. this._hide( tooltip, this.options.hide, function() {
  12758. that._removeTooltip( $( this ) );
  12759. });
  12760. target.removeData( "ui-tooltip-open" );
  12761. this._off( target, "mouseleave focusout keyup" );
  12762. // Remove 'remove' binding only on delegated targets
  12763. if ( target[0] !== this.element[0] ) {
  12764. this._off( target, "remove" );
  12765. }
  12766. this._off( this.document, "mousemove" );
  12767. if ( event && event.type === "mouseleave" ) {
  12768. $.each( this.parents, function( id, parent ) {
  12769. $( parent.element ).attr( "title", parent.title );
  12770. delete that.parents[ id ];
  12771. });
  12772. }
  12773. this.closing = true;
  12774. this._trigger( "close", event, { tooltip: tooltip } );
  12775. this.closing = false;
  12776. },
  12777. _tooltip: function( element ) {
  12778. var id = "ui-tooltip-" + increments++,
  12779. tooltip = $( "<div>" )
  12780. .attr({
  12781. id: id,
  12782. role: "tooltip"
  12783. })
  12784. .addClass( "ui-tooltip ui-widget ui-corner-all ui-widget-content " +
  12785. ( this.options.tooltipClass || "" ) );
  12786. $( "<div>" )
  12787. .addClass( "ui-tooltip-content" )
  12788. .appendTo( tooltip );
  12789. tooltip.appendTo( this.document[0].body );
  12790. this.tooltips[ id ] = element;
  12791. return tooltip;
  12792. },
  12793. _find: function( target ) {
  12794. var id = target.data( "ui-tooltip-id" );
  12795. return id ? $( "#" + id ) : $();
  12796. },
  12797. _removeTooltip: function( tooltip ) {
  12798. tooltip.remove();
  12799. delete this.tooltips[ tooltip.attr( "id" ) ];
  12800. },
  12801. _destroy: function() {
  12802. var that = this;
  12803. // close open tooltips
  12804. $.each( this.tooltips, function( id, element ) {
  12805. // Delegate to close method to handle common cleanup
  12806. var event = $.Event( "blur" );
  12807. event.target = event.currentTarget = element[0];
  12808. that.close( event, true );
  12809. // Remove immediately; destroying an open tooltip doesn't use the
  12810. // hide animation
  12811. $( "#" + id ).remove();
  12812. // Restore the title
  12813. if ( element.data( "ui-tooltip-title" ) ) {
  12814. element.attr( "title", element.data( "ui-tooltip-title" ) );
  12815. element.removeData( "ui-tooltip-title" );
  12816. }
  12817. });
  12818. }
  12819. });
  12820. }( jQuery ) );