jquery-ui-1.9.2.custom.js 440 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879
  1. /*! jQuery UI - v1.9.2 - 2012-11-23
  2. * http://jqueryui.com
  3. * Includes: jquery.ui.core.js, jquery.ui.widget.js, jquery.ui.mouse.js, jquery.ui.position.js, jquery.ui.accordion.js, jquery.ui.autocomplete.js, jquery.ui.button.js, jquery.ui.datepicker.js, jquery.ui.dialog.js, jquery.ui.draggable.js, jquery.ui.droppable.js, jquery.ui.effect.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.progressbar.js, jquery.ui.resizable.js, jquery.ui.selectable.js, jquery.ui.slider.js, jquery.ui.sortable.js, jquery.ui.spinner.js, jquery.ui.tabs.js, jquery.ui.tooltip.js
  4. * Copyright (c) 2012 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.9.2",
  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().andSelf().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
  160. $(function() {
  161. var body = document.body,
  162. div = body.appendChild( div = document.createElement( "div" ) );
  163. // access offsetHeight before setting the style to prevent a layout bug
  164. // in IE 9 which causes the element to continue to take up space even
  165. // after it is removed from the DOM (#8026)
  166. div.offsetHeight;
  167. $.extend( div.style, {
  168. minHeight: "100px",
  169. height: "auto",
  170. padding: 0,
  171. borderWidth: 0
  172. });
  173. $.support.minHeight = div.offsetHeight === 100;
  174. $.support.selectstart = "onselectstart" in div;
  175. // set display to none to avoid a layout bug in IE
  176. // http://dev.jquery.com/ticket/4014
  177. body.removeChild( div ).style.display = "none";
  178. });
  179. // support: jQuery <1.8
  180. if ( !$( "<a>" ).outerWidth( 1 ).jquery ) {
  181. $.each( [ "Width", "Height" ], function( i, name ) {
  182. var side = name === "Width" ? [ "Left", "Right" ] : [ "Top", "Bottom" ],
  183. type = name.toLowerCase(),
  184. orig = {
  185. innerWidth: $.fn.innerWidth,
  186. innerHeight: $.fn.innerHeight,
  187. outerWidth: $.fn.outerWidth,
  188. outerHeight: $.fn.outerHeight
  189. };
  190. function reduce( elem, size, border, margin ) {
  191. $.each( side, function() {
  192. size -= parseFloat( $.css( elem, "padding" + this ) ) || 0;
  193. if ( border ) {
  194. size -= parseFloat( $.css( elem, "border" + this + "Width" ) ) || 0;
  195. }
  196. if ( margin ) {
  197. size -= parseFloat( $.css( elem, "margin" + this ) ) || 0;
  198. }
  199. });
  200. return size;
  201. }
  202. $.fn[ "inner" + name ] = function( size ) {
  203. if ( size === undefined ) {
  204. return orig[ "inner" + name ].call( this );
  205. }
  206. return this.each(function() {
  207. $( this ).css( type, reduce( this, size ) + "px" );
  208. });
  209. };
  210. $.fn[ "outer" + name] = function( size, margin ) {
  211. if ( typeof size !== "number" ) {
  212. return orig[ "outer" + name ].call( this, size );
  213. }
  214. return this.each(function() {
  215. $( this).css( type, reduce( this, size, true, margin ) + "px" );
  216. });
  217. };
  218. });
  219. }
  220. // support: jQuery 1.6.1, 1.6.2 (http://bugs.jquery.com/ticket/9413)
  221. if ( $( "<a>" ).data( "a-b", "a" ).removeData( "a-b" ).data( "a-b" ) ) {
  222. $.fn.removeData = (function( removeData ) {
  223. return function( key ) {
  224. if ( arguments.length ) {
  225. return removeData.call( this, $.camelCase( key ) );
  226. } else {
  227. return removeData.call( this );
  228. }
  229. };
  230. })( $.fn.removeData );
  231. }
  232. // deprecated
  233. (function() {
  234. var uaMatch = /msie ([\w.]+)/.exec( navigator.userAgent.toLowerCase() ) || [];
  235. $.ui.ie = uaMatch.length ? true : false;
  236. $.ui.ie6 = parseFloat( uaMatch[ 1 ], 10 ) === 6;
  237. })();
  238. $.fn.extend({
  239. disableSelection: function() {
  240. return this.bind( ( $.support.selectstart ? "selectstart" : "mousedown" ) +
  241. ".ui-disableSelection", function( event ) {
  242. event.preventDefault();
  243. });
  244. },
  245. enableSelection: function() {
  246. return this.unbind( ".ui-disableSelection" );
  247. }
  248. });
  249. $.extend( $.ui, {
  250. // $.ui.plugin is deprecated. Use the proxy pattern instead.
  251. plugin: {
  252. add: function( module, option, set ) {
  253. var i,
  254. proto = $.ui[ module ].prototype;
  255. for ( i in set ) {
  256. proto.plugins[ i ] = proto.plugins[ i ] || [];
  257. proto.plugins[ i ].push( [ option, set[ i ] ] );
  258. }
  259. },
  260. call: function( instance, name, args ) {
  261. var i,
  262. set = instance.plugins[ name ];
  263. if ( !set || !instance.element[ 0 ].parentNode || instance.element[ 0 ].parentNode.nodeType === 11 ) {
  264. return;
  265. }
  266. for ( i = 0; i < set.length; i++ ) {
  267. if ( instance.options[ set[ i ][ 0 ] ] ) {
  268. set[ i ][ 1 ].apply( instance.element, args );
  269. }
  270. }
  271. }
  272. },
  273. contains: $.contains,
  274. // only used by resizable
  275. hasScroll: function( el, a ) {
  276. //If overflow is hidden, the element might have extra content, but the user wants to hide it
  277. if ( $( el ).css( "overflow" ) === "hidden") {
  278. return false;
  279. }
  280. var scroll = ( a && a === "left" ) ? "scrollLeft" : "scrollTop",
  281. has = false;
  282. if ( el[ scroll ] > 0 ) {
  283. return true;
  284. }
  285. // TODO: determine which cases actually cause this to happen
  286. // if the element doesn't have the scroll set, see if it's possible to
  287. // set the scroll
  288. el[ scroll ] = 1;
  289. has = ( el[ scroll ] > 0 );
  290. el[ scroll ] = 0;
  291. return has;
  292. },
  293. // these are odd functions, fix the API or move into individual plugins
  294. isOverAxis: function( x, reference, size ) {
  295. //Determines when x coordinate is over "b" element axis
  296. return ( x > reference ) && ( x < ( reference + size ) );
  297. },
  298. isOver: function( y, x, top, left, height, width ) {
  299. //Determines when x, y coordinates is over "b" element
  300. return $.ui.isOverAxis( y, top, height ) && $.ui.isOverAxis( x, left, width );
  301. }
  302. });
  303. })( jQuery );
  304. (function( $, undefined ) {
  305. var uuid = 0,
  306. slice = Array.prototype.slice,
  307. _cleanData = $.cleanData;
  308. $.cleanData = function( elems ) {
  309. for ( var i = 0, elem; (elem = elems[i]) != null; i++ ) {
  310. try {
  311. $( elem ).triggerHandler( "remove" );
  312. // http://bugs.jquery.com/ticket/8235
  313. } catch( e ) {}
  314. }
  315. _cleanData( elems );
  316. };
  317. $.widget = function( name, base, prototype ) {
  318. var fullName, existingConstructor, constructor, basePrototype,
  319. namespace = name.split( "." )[ 0 ];
  320. name = name.split( "." )[ 1 ];
  321. fullName = namespace + "-" + name;
  322. if ( !prototype ) {
  323. prototype = base;
  324. base = $.Widget;
  325. }
  326. // create selector for plugin
  327. $.expr[ ":" ][ fullName.toLowerCase() ] = function( elem ) {
  328. return !!$.data( elem, fullName );
  329. };
  330. $[ namespace ] = $[ namespace ] || {};
  331. existingConstructor = $[ namespace ][ name ];
  332. constructor = $[ namespace ][ name ] = function( options, element ) {
  333. // allow instantiation without "new" keyword
  334. if ( !this._createWidget ) {
  335. return new constructor( options, element );
  336. }
  337. // allow instantiation without initializing for simple inheritance
  338. // must use "new" keyword (the code above always passes args)
  339. if ( arguments.length ) {
  340. this._createWidget( options, element );
  341. }
  342. };
  343. // extend with the existing constructor to carry over any static properties
  344. $.extend( constructor, existingConstructor, {
  345. version: prototype.version,
  346. // copy the object used to create the prototype in case we need to
  347. // redefine the widget later
  348. _proto: $.extend( {}, prototype ),
  349. // track widgets that inherit from this widget in case this widget is
  350. // redefined after a widget inherits from it
  351. _childConstructors: []
  352. });
  353. basePrototype = new base();
  354. // we need to make the options hash a property directly on the new instance
  355. // otherwise we'll modify the options hash on the prototype that we're
  356. // inheriting from
  357. basePrototype.options = $.widget.extend( {}, basePrototype.options );
  358. $.each( prototype, function( prop, value ) {
  359. if ( $.isFunction( value ) ) {
  360. prototype[ prop ] = (function() {
  361. var _super = function() {
  362. return base.prototype[ prop ].apply( this, arguments );
  363. },
  364. _superApply = function( args ) {
  365. return base.prototype[ prop ].apply( this, args );
  366. };
  367. return function() {
  368. var __super = this._super,
  369. __superApply = this._superApply,
  370. returnValue;
  371. this._super = _super;
  372. this._superApply = _superApply;
  373. returnValue = value.apply( this, arguments );
  374. this._super = __super;
  375. this._superApply = __superApply;
  376. return returnValue;
  377. };
  378. })();
  379. }
  380. });
  381. constructor.prototype = $.widget.extend( basePrototype, {
  382. // TODO: remove support for widgetEventPrefix
  383. // always use the name + a colon as the prefix, e.g., draggable:start
  384. // don't prefix for widgets that aren't DOM-based
  385. widgetEventPrefix: existingConstructor ? basePrototype.widgetEventPrefix : name
  386. }, prototype, {
  387. constructor: constructor,
  388. namespace: namespace,
  389. widgetName: name,
  390. // TODO remove widgetBaseClass, see #8155
  391. widgetBaseClass: fullName,
  392. widgetFullName: fullName
  393. });
  394. // If this widget is being redefined then we need to find all widgets that
  395. // are inheriting from it and redefine all of them so that they inherit from
  396. // the new version of this widget. We're essentially trying to replace one
  397. // level in the prototype chain.
  398. if ( existingConstructor ) {
  399. $.each( existingConstructor._childConstructors, function( i, child ) {
  400. var childPrototype = child.prototype;
  401. // redefine the child widget using the same prototype that was
  402. // originally used, but inherit from the new version of the base
  403. $.widget( childPrototype.namespace + "." + childPrototype.widgetName, constructor, child._proto );
  404. });
  405. // remove the list of existing child constructors from the old constructor
  406. // so the old child constructors can be garbage collected
  407. delete existingConstructor._childConstructors;
  408. } else {
  409. base._childConstructors.push( constructor );
  410. }
  411. $.widget.bridge( name, constructor );
  412. };
  413. $.widget.extend = function( target ) {
  414. var input = slice.call( arguments, 1 ),
  415. inputIndex = 0,
  416. inputLength = input.length,
  417. key,
  418. value;
  419. for ( ; inputIndex < inputLength; inputIndex++ ) {
  420. for ( key in input[ inputIndex ] ) {
  421. value = input[ inputIndex ][ key ];
  422. if ( input[ inputIndex ].hasOwnProperty( key ) && value !== undefined ) {
  423. // Clone objects
  424. if ( $.isPlainObject( value ) ) {
  425. target[ key ] = $.isPlainObject( target[ key ] ) ?
  426. $.widget.extend( {}, target[ key ], value ) :
  427. // Don't extend strings, arrays, etc. with objects
  428. $.widget.extend( {}, value );
  429. // Copy everything else by reference
  430. } else {
  431. target[ key ] = value;
  432. }
  433. }
  434. }
  435. }
  436. return target;
  437. };
  438. $.widget.bridge = function( name, object ) {
  439. var fullName = object.prototype.widgetFullName || name;
  440. $.fn[ name ] = function( options ) {
  441. var isMethodCall = typeof options === "string",
  442. args = slice.call( arguments, 1 ),
  443. returnValue = this;
  444. // allow multiple hashes to be passed on init
  445. options = !isMethodCall && args.length ?
  446. $.widget.extend.apply( null, [ options ].concat(args) ) :
  447. options;
  448. if ( isMethodCall ) {
  449. this.each(function() {
  450. var methodValue,
  451. instance = $.data( this, fullName );
  452. if ( !instance ) {
  453. return $.error( "cannot call methods on " + name + " prior to initialization; " +
  454. "attempted to call method '" + options + "'" );
  455. }
  456. if ( !$.isFunction( instance[options] ) || options.charAt( 0 ) === "_" ) {
  457. return $.error( "no such method '" + options + "' for " + name + " widget instance" );
  458. }
  459. methodValue = instance[ options ].apply( instance, args );
  460. if ( methodValue !== instance && methodValue !== undefined ) {
  461. returnValue = methodValue && methodValue.jquery ?
  462. returnValue.pushStack( methodValue.get() ) :
  463. methodValue;
  464. return false;
  465. }
  466. });
  467. } else {
  468. this.each(function() {
  469. var instance = $.data( this, fullName );
  470. if ( instance ) {
  471. instance.option( options || {} )._init();
  472. } else {
  473. $.data( this, fullName, new object( options, this ) );
  474. }
  475. });
  476. }
  477. return returnValue;
  478. };
  479. };
  480. $.Widget = function( /* options, element */ ) {};
  481. $.Widget._childConstructors = [];
  482. $.Widget.prototype = {
  483. widgetName: "widget",
  484. widgetEventPrefix: "",
  485. defaultElement: "<div>",
  486. options: {
  487. disabled: false,
  488. // callbacks
  489. create: null
  490. },
  491. _createWidget: function( options, element ) {
  492. element = $( element || this.defaultElement || this )[ 0 ];
  493. this.element = $( element );
  494. this.uuid = uuid++;
  495. this.eventNamespace = "." + this.widgetName + this.uuid;
  496. this.options = $.widget.extend( {},
  497. this.options,
  498. this._getCreateOptions(),
  499. options );
  500. this.bindings = $();
  501. this.hoverable = $();
  502. this.focusable = $();
  503. if ( element !== this ) {
  504. // 1.9 BC for #7810
  505. // TODO remove dual storage
  506. $.data( element, this.widgetName, this );
  507. $.data( element, this.widgetFullName, this );
  508. this._on( true, this.element, {
  509. remove: function( event ) {
  510. if ( event.target === element ) {
  511. this.destroy();
  512. }
  513. }
  514. });
  515. this.document = $( element.style ?
  516. // element within the document
  517. element.ownerDocument :
  518. // element is window or document
  519. element.document || element );
  520. this.window = $( this.document[0].defaultView || this.document[0].parentWindow );
  521. }
  522. this._create();
  523. this._trigger( "create", null, this._getCreateEventData() );
  524. this._init();
  525. },
  526. _getCreateOptions: $.noop,
  527. _getCreateEventData: $.noop,
  528. _create: $.noop,
  529. _init: $.noop,
  530. destroy: function() {
  531. this._destroy();
  532. // we can probably remove the unbind calls in 2.0
  533. // all event bindings should go through this._on()
  534. this.element
  535. .unbind( this.eventNamespace )
  536. // 1.9 BC for #7810
  537. // TODO remove dual storage
  538. .removeData( this.widgetName )
  539. .removeData( this.widgetFullName )
  540. // support: jquery <1.6.3
  541. // http://bugs.jquery.com/ticket/9413
  542. .removeData( $.camelCase( this.widgetFullName ) );
  543. this.widget()
  544. .unbind( this.eventNamespace )
  545. .removeAttr( "aria-disabled" )
  546. .removeClass(
  547. this.widgetFullName + "-disabled " +
  548. "ui-state-disabled" );
  549. // clean up events and states
  550. this.bindings.unbind( this.eventNamespace );
  551. this.hoverable.removeClass( "ui-state-hover" );
  552. this.focusable.removeClass( "ui-state-focus" );
  553. },
  554. _destroy: $.noop,
  555. widget: function() {
  556. return this.element;
  557. },
  558. option: function( key, value ) {
  559. var options = key,
  560. parts,
  561. curOption,
  562. i;
  563. if ( arguments.length === 0 ) {
  564. // don't return a reference to the internal hash
  565. return $.widget.extend( {}, this.options );
  566. }
  567. if ( typeof key === "string" ) {
  568. // handle nested keys, e.g., "foo.bar" => { foo: { bar: ___ } }
  569. options = {};
  570. parts = key.split( "." );
  571. key = parts.shift();
  572. if ( parts.length ) {
  573. curOption = options[ key ] = $.widget.extend( {}, this.options[ key ] );
  574. for ( i = 0; i < parts.length - 1; i++ ) {
  575. curOption[ parts[ i ] ] = curOption[ parts[ i ] ] || {};
  576. curOption = curOption[ parts[ i ] ];
  577. }
  578. key = parts.pop();
  579. if ( value === undefined ) {
  580. return curOption[ key ] === undefined ? null : curOption[ key ];
  581. }
  582. curOption[ key ] = value;
  583. } else {
  584. if ( value === undefined ) {
  585. return this.options[ key ] === undefined ? null : this.options[ key ];
  586. }
  587. options[ key ] = value;
  588. }
  589. }
  590. this._setOptions( options );
  591. return this;
  592. },
  593. _setOptions: function( options ) {
  594. var key;
  595. for ( key in options ) {
  596. this._setOption( key, options[ key ] );
  597. }
  598. return this;
  599. },
  600. _setOption: function( key, value ) {
  601. this.options[ key ] = value;
  602. if ( key === "disabled" ) {
  603. this.widget()
  604. .toggleClass( this.widgetFullName + "-disabled ui-state-disabled", !!value )
  605. .attr( "aria-disabled", value );
  606. this.hoverable.removeClass( "ui-state-hover" );
  607. this.focusable.removeClass( "ui-state-focus" );
  608. }
  609. return this;
  610. },
  611. enable: function() {
  612. return this._setOption( "disabled", false );
  613. },
  614. disable: function() {
  615. return this._setOption( "disabled", true );
  616. },
  617. _on: function( suppressDisabledCheck, element, handlers ) {
  618. var delegateElement,
  619. instance = this;
  620. // no suppressDisabledCheck flag, shuffle arguments
  621. if ( typeof suppressDisabledCheck !== "boolean" ) {
  622. handlers = element;
  623. element = suppressDisabledCheck;
  624. suppressDisabledCheck = false;
  625. }
  626. // no element argument, shuffle and use this.element
  627. if ( !handlers ) {
  628. handlers = element;
  629. element = this.element;
  630. delegateElement = this.widget();
  631. } else {
  632. // accept selectors, DOM elements
  633. element = delegateElement = $( element );
  634. this.bindings = this.bindings.add( element );
  635. }
  636. $.each( handlers, function( event, handler ) {
  637. function handlerProxy() {
  638. // allow widgets to customize the disabled handling
  639. // - disabled as an array instead of boolean
  640. // - disabled class as method for disabling individual parts
  641. if ( !suppressDisabledCheck &&
  642. ( instance.options.disabled === true ||
  643. $( this ).hasClass( "ui-state-disabled" ) ) ) {
  644. return;
  645. }
  646. return ( typeof handler === "string" ? instance[ handler ] : handler )
  647. .apply( instance, arguments );
  648. }
  649. // copy the guid so direct unbinding works
  650. if ( typeof handler !== "string" ) {
  651. handlerProxy.guid = handler.guid =
  652. handler.guid || handlerProxy.guid || $.guid++;
  653. }
  654. var match = event.match( /^(\w+)\s*(.*)$/ ),
  655. eventName = match[1] + instance.eventNamespace,
  656. selector = match[2];
  657. if ( selector ) {
  658. delegateElement.delegate( selector, eventName, handlerProxy );
  659. } else {
  660. element.bind( eventName, handlerProxy );
  661. }
  662. });
  663. },
  664. _off: function( element, eventName ) {
  665. eventName = (eventName || "").split( " " ).join( this.eventNamespace + " " ) + this.eventNamespace;
  666. element.unbind( eventName ).undelegate( eventName );
  667. },
  668. _delay: function( handler, delay ) {
  669. function handlerProxy() {
  670. return ( typeof handler === "string" ? instance[ handler ] : handler )
  671. .apply( instance, arguments );
  672. }
  673. var instance = this;
  674. return setTimeout( handlerProxy, delay || 0 );
  675. },
  676. _hoverable: function( element ) {
  677. this.hoverable = this.hoverable.add( element );
  678. this._on( element, {
  679. mouseenter: function( event ) {
  680. $( event.currentTarget ).addClass( "ui-state-hover" );
  681. },
  682. mouseleave: function( event ) {
  683. $( event.currentTarget ).removeClass( "ui-state-hover" );
  684. }
  685. });
  686. },
  687. _focusable: function( element ) {
  688. this.focusable = this.focusable.add( element );
  689. this._on( element, {
  690. focusin: function( event ) {
  691. $( event.currentTarget ).addClass( "ui-state-focus" );
  692. },
  693. focusout: function( event ) {
  694. $( event.currentTarget ).removeClass( "ui-state-focus" );
  695. }
  696. });
  697. },
  698. _trigger: function( type, event, data ) {
  699. var prop, orig,
  700. callback = this.options[ type ];
  701. data = data || {};
  702. event = $.Event( event );
  703. event.type = ( type === this.widgetEventPrefix ?
  704. type :
  705. this.widgetEventPrefix + type ).toLowerCase();
  706. // the original event may come from any element
  707. // so we need to reset the target on the new event
  708. event.target = this.element[ 0 ];
  709. // copy original event properties over to the new event
  710. orig = event.originalEvent;
  711. if ( orig ) {
  712. for ( prop in orig ) {
  713. if ( !( prop in event ) ) {
  714. event[ prop ] = orig[ prop ];
  715. }
  716. }
  717. }
  718. this.element.trigger( event, data );
  719. return !( $.isFunction( callback ) &&
  720. callback.apply( this.element[0], [ event ].concat( data ) ) === false ||
  721. event.isDefaultPrevented() );
  722. }
  723. };
  724. $.each( { show: "fadeIn", hide: "fadeOut" }, function( method, defaultEffect ) {
  725. $.Widget.prototype[ "_" + method ] = function( element, options, callback ) {
  726. if ( typeof options === "string" ) {
  727. options = { effect: options };
  728. }
  729. var hasOptions,
  730. effectName = !options ?
  731. method :
  732. options === true || typeof options === "number" ?
  733. defaultEffect :
  734. options.effect || defaultEffect;
  735. options = options || {};
  736. if ( typeof options === "number" ) {
  737. options = { duration: options };
  738. }
  739. hasOptions = !$.isEmptyObject( options );
  740. options.complete = callback;
  741. if ( options.delay ) {
  742. element.delay( options.delay );
  743. }
  744. if ( hasOptions && $.effects && ( $.effects.effect[ effectName ] || $.uiBackCompat !== false && $.effects[ effectName ] ) ) {
  745. element[ method ]( options );
  746. } else if ( effectName !== method && element[ effectName ] ) {
  747. element[ effectName ]( options.duration, options.easing, callback );
  748. } else {
  749. element.queue(function( next ) {
  750. $( this )[ method ]();
  751. if ( callback ) {
  752. callback.call( element[ 0 ] );
  753. }
  754. next();
  755. });
  756. }
  757. };
  758. });
  759. // DEPRECATED
  760. if ( $.uiBackCompat !== false ) {
  761. $.Widget.prototype._getCreateOptions = function() {
  762. return $.metadata && $.metadata.get( this.element[0] )[ this.widgetName ];
  763. };
  764. }
  765. })( jQuery );
  766. (function( $, undefined ) {
  767. var mouseHandled = false;
  768. $( document ).mouseup( function( e ) {
  769. mouseHandled = false;
  770. });
  771. $.widget("ui.mouse", {
  772. version: "1.9.2",
  773. options: {
  774. cancel: 'input,textarea,button,select,option',
  775. distance: 1,
  776. delay: 0
  777. },
  778. _mouseInit: function() {
  779. var that = this;
  780. this.element
  781. .bind('mousedown.'+this.widgetName, function(event) {
  782. return that._mouseDown(event);
  783. })
  784. .bind('click.'+this.widgetName, function(event) {
  785. if (true === $.data(event.target, that.widgetName + '.preventClickEvent')) {
  786. $.removeData(event.target, that.widgetName + '.preventClickEvent');
  787. event.stopImmediatePropagation();
  788. return false;
  789. }
  790. });
  791. this.started = false;
  792. },
  793. // TODO: make sure destroying one instance of mouse doesn't mess with
  794. // other instances of mouse
  795. _mouseDestroy: function() {
  796. this.element.unbind('.'+this.widgetName);
  797. if ( this._mouseMoveDelegate ) {
  798. $(document)
  799. .unbind('mousemove.'+this.widgetName, this._mouseMoveDelegate)
  800. .unbind('mouseup.'+this.widgetName, this._mouseUpDelegate);
  801. }
  802. },
  803. _mouseDown: function(event) {
  804. // don't let more than one widget handle mouseStart
  805. if( mouseHandled ) { return; }
  806. // we may have missed mouseup (out of window)
  807. (this._mouseStarted && this._mouseUp(event));
  808. this._mouseDownEvent = event;
  809. var that = this,
  810. btnIsLeft = (event.which === 1),
  811. // event.target.nodeName works around a bug in IE 8 with
  812. // disabled inputs (#7620)
  813. elIsCancel = (typeof this.options.cancel === "string" && event.target.nodeName ? $(event.target).closest(this.options.cancel).length : false);
  814. if (!btnIsLeft || elIsCancel || !this._mouseCapture(event)) {
  815. return true;
  816. }
  817. this.mouseDelayMet = !this.options.delay;
  818. if (!this.mouseDelayMet) {
  819. this._mouseDelayTimer = setTimeout(function() {
  820. that.mouseDelayMet = true;
  821. }, this.options.delay);
  822. }
  823. if (this._mouseDistanceMet(event) && this._mouseDelayMet(event)) {
  824. this._mouseStarted = (this._mouseStart(event) !== false);
  825. if (!this._mouseStarted) {
  826. event.preventDefault();
  827. return true;
  828. }
  829. }
  830. // Click event may never have fired (Gecko & Opera)
  831. if (true === $.data(event.target, this.widgetName + '.preventClickEvent')) {
  832. $.removeData(event.target, this.widgetName + '.preventClickEvent');
  833. }
  834. // these delegates are required to keep context
  835. this._mouseMoveDelegate = function(event) {
  836. return that._mouseMove(event);
  837. };
  838. this._mouseUpDelegate = function(event) {
  839. return that._mouseUp(event);
  840. };
  841. $(document)
  842. .bind('mousemove.'+this.widgetName, this._mouseMoveDelegate)
  843. .bind('mouseup.'+this.widgetName, this._mouseUpDelegate);
  844. event.preventDefault();
  845. mouseHandled = true;
  846. return true;
  847. },
  848. _mouseMove: function(event) {
  849. // IE mouseup check - mouseup happened when mouse was out of window
  850. if ($.ui.ie && !(document.documentMode >= 9) && !event.button) {
  851. return this._mouseUp(event);
  852. }
  853. if (this._mouseStarted) {
  854. this._mouseDrag(event);
  855. return event.preventDefault();
  856. }
  857. if (this._mouseDistanceMet(event) && this._mouseDelayMet(event)) {
  858. this._mouseStarted =
  859. (this._mouseStart(this._mouseDownEvent, event) !== false);
  860. (this._mouseStarted ? this._mouseDrag(event) : this._mouseUp(event));
  861. }
  862. return !this._mouseStarted;
  863. },
  864. _mouseUp: function(event) {
  865. $(document)
  866. .unbind('mousemove.'+this.widgetName, this._mouseMoveDelegate)
  867. .unbind('mouseup.'+this.widgetName, this._mouseUpDelegate);
  868. if (this._mouseStarted) {
  869. this._mouseStarted = false;
  870. if (event.target === this._mouseDownEvent.target) {
  871. $.data(event.target, this.widgetName + '.preventClickEvent', true);
  872. }
  873. this._mouseStop(event);
  874. }
  875. return false;
  876. },
  877. _mouseDistanceMet: function(event) {
  878. return (Math.max(
  879. Math.abs(this._mouseDownEvent.pageX - event.pageX),
  880. Math.abs(this._mouseDownEvent.pageY - event.pageY)
  881. ) >= this.options.distance
  882. );
  883. },
  884. _mouseDelayMet: function(event) {
  885. return this.mouseDelayMet;
  886. },
  887. // These are placeholder methods, to be overriden by extending plugin
  888. _mouseStart: function(event) {},
  889. _mouseDrag: function(event) {},
  890. _mouseStop: function(event) {},
  891. _mouseCapture: function(event) { return true; }
  892. });
  893. })(jQuery);
  894. (function( $, undefined ) {
  895. $.ui = $.ui || {};
  896. var cachedScrollbarWidth,
  897. max = Math.max,
  898. abs = Math.abs,
  899. round = Math.round,
  900. rhorizontal = /left|center|right/,
  901. rvertical = /top|center|bottom/,
  902. roffset = /[\+\-]\d+%?/,
  903. rposition = /^\w+/,
  904. rpercent = /%$/,
  905. _position = $.fn.position;
  906. function getOffsets( offsets, width, height ) {
  907. return [
  908. parseInt( offsets[ 0 ], 10 ) * ( rpercent.test( offsets[ 0 ] ) ? width / 100 : 1 ),
  909. parseInt( offsets[ 1 ], 10 ) * ( rpercent.test( offsets[ 1 ] ) ? height / 100 : 1 )
  910. ];
  911. }
  912. function parseCss( element, property ) {
  913. return parseInt( $.css( element, property ), 10 ) || 0;
  914. }
  915. $.position = {
  916. scrollbarWidth: function() {
  917. if ( cachedScrollbarWidth !== undefined ) {
  918. return cachedScrollbarWidth;
  919. }
  920. var w1, w2,
  921. div = $( "<div style='display:block;width:50px;height:50px;overflow:hidden;'><div style='height:100px;width:auto;'></div></div>" ),
  922. innerDiv = div.children()[0];
  923. $( "body" ).append( div );
  924. w1 = innerDiv.offsetWidth;
  925. div.css( "overflow", "scroll" );
  926. w2 = innerDiv.offsetWidth;
  927. if ( w1 === w2 ) {
  928. w2 = div[0].clientWidth;
  929. }
  930. div.remove();
  931. return (cachedScrollbarWidth = w1 - w2);
  932. },
  933. getScrollInfo: function( within ) {
  934. var overflowX = within.isWindow ? "" : within.element.css( "overflow-x" ),
  935. overflowY = within.isWindow ? "" : within.element.css( "overflow-y" ),
  936. hasOverflowX = overflowX === "scroll" ||
  937. ( overflowX === "auto" && within.width < within.element[0].scrollWidth ),
  938. hasOverflowY = overflowY === "scroll" ||
  939. ( overflowY === "auto" && within.height < within.element[0].scrollHeight );
  940. return {
  941. width: hasOverflowX ? $.position.scrollbarWidth() : 0,
  942. height: hasOverflowY ? $.position.scrollbarWidth() : 0
  943. };
  944. },
  945. getWithinInfo: function( element ) {
  946. var withinElement = $( element || window ),
  947. isWindow = $.isWindow( withinElement[0] );
  948. return {
  949. element: withinElement,
  950. isWindow: isWindow,
  951. offset: withinElement.offset() || { left: 0, top: 0 },
  952. scrollLeft: withinElement.scrollLeft(),
  953. scrollTop: withinElement.scrollTop(),
  954. width: isWindow ? withinElement.width() : withinElement.outerWidth(),
  955. height: isWindow ? withinElement.height() : withinElement.outerHeight()
  956. };
  957. }
  958. };
  959. $.fn.position = function( options ) {
  960. if ( !options || !options.of ) {
  961. return _position.apply( this, arguments );
  962. }
  963. // make a copy, we don't want to modify arguments
  964. options = $.extend( {}, options );
  965. var atOffset, targetWidth, targetHeight, targetOffset, basePosition,
  966. target = $( options.of ),
  967. within = $.position.getWithinInfo( options.within ),
  968. scrollInfo = $.position.getScrollInfo( within ),
  969. targetElem = target[0],
  970. collision = ( options.collision || "flip" ).split( " " ),
  971. offsets = {};
  972. if ( targetElem.nodeType === 9 ) {
  973. targetWidth = target.width();
  974. targetHeight = target.height();
  975. targetOffset = { top: 0, left: 0 };
  976. } else if ( $.isWindow( targetElem ) ) {
  977. targetWidth = target.width();
  978. targetHeight = target.height();
  979. targetOffset = { top: target.scrollTop(), left: target.scrollLeft() };
  980. } else if ( targetElem.preventDefault ) {
  981. // force left top to allow flipping
  982. options.at = "left top";
  983. targetWidth = targetHeight = 0;
  984. targetOffset = { top: targetElem.pageY, left: targetElem.pageX };
  985. } else {
  986. targetWidth = target.outerWidth();
  987. targetHeight = target.outerHeight();
  988. targetOffset = target.offset();
  989. }
  990. // clone to reuse original targetOffset later
  991. basePosition = $.extend( {}, targetOffset );
  992. // force my and at to have valid horizontal and vertical positions
  993. // if a value is missing or invalid, it will be converted to center
  994. $.each( [ "my", "at" ], function() {
  995. var pos = ( options[ this ] || "" ).split( " " ),
  996. horizontalOffset,
  997. verticalOffset;
  998. if ( pos.length === 1) {
  999. pos = rhorizontal.test( pos[ 0 ] ) ?
  1000. pos.concat( [ "center" ] ) :
  1001. rvertical.test( pos[ 0 ] ) ?
  1002. [ "center" ].concat( pos ) :
  1003. [ "center", "center" ];
  1004. }
  1005. pos[ 0 ] = rhorizontal.test( pos[ 0 ] ) ? pos[ 0 ] : "center";
  1006. pos[ 1 ] = rvertical.test( pos[ 1 ] ) ? pos[ 1 ] : "center";
  1007. // calculate offsets
  1008. horizontalOffset = roffset.exec( pos[ 0 ] );
  1009. verticalOffset = roffset.exec( pos[ 1 ] );
  1010. offsets[ this ] = [
  1011. horizontalOffset ? horizontalOffset[ 0 ] : 0,
  1012. verticalOffset ? verticalOffset[ 0 ] : 0
  1013. ];
  1014. // reduce to just the positions without the offsets
  1015. options[ this ] = [
  1016. rposition.exec( pos[ 0 ] )[ 0 ],
  1017. rposition.exec( pos[ 1 ] )[ 0 ]
  1018. ];
  1019. });
  1020. // normalize collision option
  1021. if ( collision.length === 1 ) {
  1022. collision[ 1 ] = collision[ 0 ];
  1023. }
  1024. if ( options.at[ 0 ] === "right" ) {
  1025. basePosition.left += targetWidth;
  1026. } else if ( options.at[ 0 ] === "center" ) {
  1027. basePosition.left += targetWidth / 2;
  1028. }
  1029. if ( options.at[ 1 ] === "bottom" ) {
  1030. basePosition.top += targetHeight;
  1031. } else if ( options.at[ 1 ] === "center" ) {
  1032. basePosition.top += targetHeight / 2;
  1033. }
  1034. atOffset = getOffsets( offsets.at, targetWidth, targetHeight );
  1035. basePosition.left += atOffset[ 0 ];
  1036. basePosition.top += atOffset[ 1 ];
  1037. return this.each(function() {
  1038. var collisionPosition, using,
  1039. elem = $( this ),
  1040. elemWidth = elem.outerWidth(),
  1041. elemHeight = elem.outerHeight(),
  1042. marginLeft = parseCss( this, "marginLeft" ),
  1043. marginTop = parseCss( this, "marginTop" ),
  1044. collisionWidth = elemWidth + marginLeft + parseCss( this, "marginRight" ) + scrollInfo.width,
  1045. collisionHeight = elemHeight + marginTop + parseCss( this, "marginBottom" ) + scrollInfo.height,
  1046. position = $.extend( {}, basePosition ),
  1047. myOffset = getOffsets( offsets.my, elem.outerWidth(), elem.outerHeight() );
  1048. if ( options.my[ 0 ] === "right" ) {
  1049. position.left -= elemWidth;
  1050. } else if ( options.my[ 0 ] === "center" ) {
  1051. position.left -= elemWidth / 2;
  1052. }
  1053. if ( options.my[ 1 ] === "bottom" ) {
  1054. position.top -= elemHeight;
  1055. } else if ( options.my[ 1 ] === "center" ) {
  1056. position.top -= elemHeight / 2;
  1057. }
  1058. position.left += myOffset[ 0 ];
  1059. position.top += myOffset[ 1 ];
  1060. // if the browser doesn't support fractions, then round for consistent results
  1061. if ( !$.support.offsetFractions ) {
  1062. position.left = round( position.left );
  1063. position.top = round( position.top );
  1064. }
  1065. collisionPosition = {
  1066. marginLeft: marginLeft,
  1067. marginTop: marginTop
  1068. };
  1069. $.each( [ "left", "top" ], function( i, dir ) {
  1070. if ( $.ui.position[ collision[ i ] ] ) {
  1071. $.ui.position[ collision[ i ] ][ dir ]( position, {
  1072. targetWidth: targetWidth,
  1073. targetHeight: targetHeight,
  1074. elemWidth: elemWidth,
  1075. elemHeight: elemHeight,
  1076. collisionPosition: collisionPosition,
  1077. collisionWidth: collisionWidth,
  1078. collisionHeight: collisionHeight,
  1079. offset: [ atOffset[ 0 ] + myOffset[ 0 ], atOffset [ 1 ] + myOffset[ 1 ] ],
  1080. my: options.my,
  1081. at: options.at,
  1082. within: within,
  1083. elem : elem
  1084. });
  1085. }
  1086. });
  1087. if ( $.fn.bgiframe ) {
  1088. elem.bgiframe();
  1089. }
  1090. if ( options.using ) {
  1091. // adds feedback as second argument to using callback, if present
  1092. using = function( props ) {
  1093. var left = targetOffset.left - position.left,
  1094. right = left + targetWidth - elemWidth,
  1095. top = targetOffset.top - position.top,
  1096. bottom = top + targetHeight - elemHeight,
  1097. feedback = {
  1098. target: {
  1099. element: target,
  1100. left: targetOffset.left,
  1101. top: targetOffset.top,
  1102. width: targetWidth,
  1103. height: targetHeight
  1104. },
  1105. element: {
  1106. element: elem,
  1107. left: position.left,
  1108. top: position.top,
  1109. width: elemWidth,
  1110. height: elemHeight
  1111. },
  1112. horizontal: right < 0 ? "left" : left > 0 ? "right" : "center",
  1113. vertical: bottom < 0 ? "top" : top > 0 ? "bottom" : "middle"
  1114. };
  1115. if ( targetWidth < elemWidth && abs( left + right ) < targetWidth ) {
  1116. feedback.horizontal = "center";
  1117. }
  1118. if ( targetHeight < elemHeight && abs( top + bottom ) < targetHeight ) {
  1119. feedback.vertical = "middle";
  1120. }
  1121. if ( max( abs( left ), abs( right ) ) > max( abs( top ), abs( bottom ) ) ) {
  1122. feedback.important = "horizontal";
  1123. } else {
  1124. feedback.important = "vertical";
  1125. }
  1126. options.using.call( this, props, feedback );
  1127. };
  1128. }
  1129. elem.offset( $.extend( position, { using: using } ) );
  1130. });
  1131. };
  1132. $.ui.position = {
  1133. fit: {
  1134. left: function( position, data ) {
  1135. var within = data.within,
  1136. withinOffset = within.isWindow ? within.scrollLeft : within.offset.left,
  1137. outerWidth = within.width,
  1138. collisionPosLeft = position.left - data.collisionPosition.marginLeft,
  1139. overLeft = withinOffset - collisionPosLeft,
  1140. overRight = collisionPosLeft + data.collisionWidth - outerWidth - withinOffset,
  1141. newOverRight;
  1142. // element is wider than within
  1143. if ( data.collisionWidth > outerWidth ) {
  1144. // element is initially over the left side of within
  1145. if ( overLeft > 0 && overRight <= 0 ) {
  1146. newOverRight = position.left + overLeft + data.collisionWidth - outerWidth - withinOffset;
  1147. position.left += overLeft - newOverRight;
  1148. // element is initially over right side of within
  1149. } else if ( overRight > 0 && overLeft <= 0 ) {
  1150. position.left = withinOffset;
  1151. // element is initially over both left and right sides of within
  1152. } else {
  1153. if ( overLeft > overRight ) {
  1154. position.left = withinOffset + outerWidth - data.collisionWidth;
  1155. } else {
  1156. position.left = withinOffset;
  1157. }
  1158. }
  1159. // too far left -> align with left edge
  1160. } else if ( overLeft > 0 ) {
  1161. position.left += overLeft;
  1162. // too far right -> align with right edge
  1163. } else if ( overRight > 0 ) {
  1164. position.left -= overRight;
  1165. // adjust based on position and margin
  1166. } else {
  1167. position.left = max( position.left - collisionPosLeft, position.left );
  1168. }
  1169. },
  1170. top: function( position, data ) {
  1171. var within = data.within,
  1172. withinOffset = within.isWindow ? within.scrollTop : within.offset.top,
  1173. outerHeight = data.within.height,
  1174. collisionPosTop = position.top - data.collisionPosition.marginTop,
  1175. overTop = withinOffset - collisionPosTop,
  1176. overBottom = collisionPosTop + data.collisionHeight - outerHeight - withinOffset,
  1177. newOverBottom;
  1178. // element is taller than within
  1179. if ( data.collisionHeight > outerHeight ) {
  1180. // element is initially over the top of within
  1181. if ( overTop > 0 && overBottom <= 0 ) {
  1182. newOverBottom = position.top + overTop + data.collisionHeight - outerHeight - withinOffset;
  1183. position.top += overTop - newOverBottom;
  1184. // element is initially over bottom of within
  1185. } else if ( overBottom > 0 && overTop <= 0 ) {
  1186. position.top = withinOffset;
  1187. // element is initially over both top and bottom of within
  1188. } else {
  1189. if ( overTop > overBottom ) {
  1190. position.top = withinOffset + outerHeight - data.collisionHeight;
  1191. } else {
  1192. position.top = withinOffset;
  1193. }
  1194. }
  1195. // too far up -> align with top
  1196. } else if ( overTop > 0 ) {
  1197. position.top += overTop;
  1198. // too far down -> align with bottom edge
  1199. } else if ( overBottom > 0 ) {
  1200. position.top -= overBottom;
  1201. // adjust based on position and margin
  1202. } else {
  1203. position.top = max( position.top - collisionPosTop, position.top );
  1204. }
  1205. }
  1206. },
  1207. flip: {
  1208. left: function( position, data ) {
  1209. var within = data.within,
  1210. withinOffset = within.offset.left + within.scrollLeft,
  1211. outerWidth = within.width,
  1212. offsetLeft = within.isWindow ? within.scrollLeft : within.offset.left,
  1213. collisionPosLeft = position.left - data.collisionPosition.marginLeft,
  1214. overLeft = collisionPosLeft - offsetLeft,
  1215. overRight = collisionPosLeft + data.collisionWidth - outerWidth - offsetLeft,
  1216. myOffset = data.my[ 0 ] === "left" ?
  1217. -data.elemWidth :
  1218. data.my[ 0 ] === "right" ?
  1219. data.elemWidth :
  1220. 0,
  1221. atOffset = data.at[ 0 ] === "left" ?
  1222. data.targetWidth :
  1223. data.at[ 0 ] === "right" ?
  1224. -data.targetWidth :
  1225. 0,
  1226. offset = -2 * data.offset[ 0 ],
  1227. newOverRight,
  1228. newOverLeft;
  1229. if ( overLeft < 0 ) {
  1230. newOverRight = position.left + myOffset + atOffset + offset + data.collisionWidth - outerWidth - withinOffset;
  1231. if ( newOverRight < 0 || newOverRight < abs( overLeft ) ) {
  1232. position.left += myOffset + atOffset + offset;
  1233. }
  1234. }
  1235. else if ( overRight > 0 ) {
  1236. newOverLeft = position.left - data.collisionPosition.marginLeft + myOffset + atOffset + offset - offsetLeft;
  1237. if ( newOverLeft > 0 || abs( newOverLeft ) < overRight ) {
  1238. position.left += myOffset + atOffset + offset;
  1239. }
  1240. }
  1241. },
  1242. top: function( position, data ) {
  1243. var within = data.within,
  1244. withinOffset = within.offset.top + within.scrollTop,
  1245. outerHeight = within.height,
  1246. offsetTop = within.isWindow ? within.scrollTop : within.offset.top,
  1247. collisionPosTop = position.top - data.collisionPosition.marginTop,
  1248. overTop = collisionPosTop - offsetTop,
  1249. overBottom = collisionPosTop + data.collisionHeight - outerHeight - offsetTop,
  1250. top = data.my[ 1 ] === "top",
  1251. myOffset = top ?
  1252. -data.elemHeight :
  1253. data.my[ 1 ] === "bottom" ?
  1254. data.elemHeight :
  1255. 0,
  1256. atOffset = data.at[ 1 ] === "top" ?
  1257. data.targetHeight :
  1258. data.at[ 1 ] === "bottom" ?
  1259. -data.targetHeight :
  1260. 0,
  1261. offset = -2 * data.offset[ 1 ],
  1262. newOverTop,
  1263. newOverBottom;
  1264. if ( overTop < 0 ) {
  1265. newOverBottom = position.top + myOffset + atOffset + offset + data.collisionHeight - outerHeight - withinOffset;
  1266. if ( ( position.top + myOffset + atOffset + offset) > overTop && ( newOverBottom < 0 || newOverBottom < abs( overTop ) ) ) {
  1267. position.top += myOffset + atOffset + offset;
  1268. }
  1269. }
  1270. else if ( overBottom > 0 ) {
  1271. newOverTop = position.top - data.collisionPosition.marginTop + myOffset + atOffset + offset - offsetTop;
  1272. if ( ( position.top + myOffset + atOffset + offset) > overBottom && ( newOverTop > 0 || abs( newOverTop ) < overBottom ) ) {
  1273. position.top += myOffset + atOffset + offset;
  1274. }
  1275. }
  1276. }
  1277. },
  1278. flipfit: {
  1279. left: function() {
  1280. $.ui.position.flip.left.apply( this, arguments );
  1281. $.ui.position.fit.left.apply( this, arguments );
  1282. },
  1283. top: function() {
  1284. $.ui.position.flip.top.apply( this, arguments );
  1285. $.ui.position.fit.top.apply( this, arguments );
  1286. }
  1287. }
  1288. };
  1289. // fraction support test
  1290. (function () {
  1291. var testElement, testElementParent, testElementStyle, offsetLeft, i,
  1292. body = document.getElementsByTagName( "body" )[ 0 ],
  1293. div = document.createElement( "div" );
  1294. //Create a "fake body" for testing based on method used in jQuery.support
  1295. testElement = document.createElement( body ? "div" : "body" );
  1296. testElementStyle = {
  1297. visibility: "hidden",
  1298. width: 0,
  1299. height: 0,
  1300. border: 0,
  1301. margin: 0,
  1302. background: "none"
  1303. };
  1304. if ( body ) {
  1305. $.extend( testElementStyle, {
  1306. position: "absolute",
  1307. left: "-1000px",
  1308. top: "-1000px"
  1309. });
  1310. }
  1311. for ( i in testElementStyle ) {
  1312. testElement.style[ i ] = testElementStyle[ i ];
  1313. }
  1314. testElement.appendChild( div );
  1315. testElementParent = body || document.documentElement;
  1316. testElementParent.insertBefore( testElement, testElementParent.firstChild );
  1317. div.style.cssText = "position: absolute; left: 10.7432222px;";
  1318. offsetLeft = $( div ).offset().left;
  1319. $.support.offsetFractions = offsetLeft > 10 && offsetLeft < 11;
  1320. testElement.innerHTML = "";
  1321. testElementParent.removeChild( testElement );
  1322. })();
  1323. // DEPRECATED
  1324. if ( $.uiBackCompat !== false ) {
  1325. // offset option
  1326. (function( $ ) {
  1327. var _position = $.fn.position;
  1328. $.fn.position = function( options ) {
  1329. if ( !options || !options.offset ) {
  1330. return _position.call( this, options );
  1331. }
  1332. var offset = options.offset.split( " " ),
  1333. at = options.at.split( " " );
  1334. if ( offset.length === 1 ) {
  1335. offset[ 1 ] = offset[ 0 ];
  1336. }
  1337. if ( /^\d/.test( offset[ 0 ] ) ) {
  1338. offset[ 0 ] = "+" + offset[ 0 ];
  1339. }
  1340. if ( /^\d/.test( offset[ 1 ] ) ) {
  1341. offset[ 1 ] = "+" + offset[ 1 ];
  1342. }
  1343. if ( at.length === 1 ) {
  1344. if ( /left|center|right/.test( at[ 0 ] ) ) {
  1345. at[ 1 ] = "center";
  1346. } else {
  1347. at[ 1 ] = at[ 0 ];
  1348. at[ 0 ] = "center";
  1349. }
  1350. }
  1351. return _position.call( this, $.extend( options, {
  1352. at: at[ 0 ] + offset[ 0 ] + " " + at[ 1 ] + offset[ 1 ],
  1353. offset: undefined
  1354. } ) );
  1355. };
  1356. }( jQuery ) );
  1357. }
  1358. }( jQuery ) );
  1359. (function( $, undefined ) {
  1360. var uid = 0,
  1361. hideProps = {},
  1362. showProps = {};
  1363. hideProps.height = hideProps.paddingTop = hideProps.paddingBottom =
  1364. hideProps.borderTopWidth = hideProps.borderBottomWidth = "hide";
  1365. showProps.height = showProps.paddingTop = showProps.paddingBottom =
  1366. showProps.borderTopWidth = showProps.borderBottomWidth = "show";
  1367. $.widget( "ui.accordion", {
  1368. version: "1.9.2",
  1369. options: {
  1370. active: 0,
  1371. animate: {},
  1372. collapsible: false,
  1373. event: "click",
  1374. header: "> li > :first-child,> :not(li):even",
  1375. heightStyle: "auto",
  1376. icons: {
  1377. activeHeader: "ui-icon-triangle-1-s",
  1378. header: "ui-icon-triangle-1-e"
  1379. },
  1380. // callbacks
  1381. activate: null,
  1382. beforeActivate: null
  1383. },
  1384. _create: function() {
  1385. var accordionId = this.accordionId = "ui-accordion-" +
  1386. (this.element.attr( "id" ) || ++uid),
  1387. options = this.options;
  1388. this.prevShow = this.prevHide = $();
  1389. this.element.addClass( "ui-accordion ui-widget ui-helper-reset" );
  1390. this.headers = this.element.find( options.header )
  1391. .addClass( "ui-accordion-header ui-helper-reset ui-state-default ui-corner-all" );
  1392. this._hoverable( this.headers );
  1393. this._focusable( this.headers );
  1394. this.headers.next()
  1395. .addClass( "ui-accordion-content ui-helper-reset ui-widget-content ui-corner-bottom" )
  1396. .hide();
  1397. // don't allow collapsible: false and active: false / null
  1398. if ( !options.collapsible && (options.active === false || options.active == null) ) {
  1399. options.active = 0;
  1400. }
  1401. // handle negative values
  1402. if ( options.active < 0 ) {
  1403. options.active += this.headers.length;
  1404. }
  1405. this.active = this._findActive( options.active )
  1406. .addClass( "ui-accordion-header-active ui-state-active" )
  1407. .toggleClass( "ui-corner-all ui-corner-top" );
  1408. this.active.next()
  1409. .addClass( "ui-accordion-content-active" )
  1410. .show();
  1411. this._createIcons();
  1412. this.refresh();
  1413. // ARIA
  1414. this.element.attr( "role", "tablist" );
  1415. this.headers
  1416. .attr( "role", "tab" )
  1417. .each(function( i ) {
  1418. var header = $( this ),
  1419. headerId = header.attr( "id" ),
  1420. panel = header.next(),
  1421. panelId = panel.attr( "id" );
  1422. if ( !headerId ) {
  1423. headerId = accordionId + "-header-" + i;
  1424. header.attr( "id", headerId );
  1425. }
  1426. if ( !panelId ) {
  1427. panelId = accordionId + "-panel-" + i;
  1428. panel.attr( "id", panelId );
  1429. }
  1430. header.attr( "aria-controls", panelId );
  1431. panel.attr( "aria-labelledby", headerId );
  1432. })
  1433. .next()
  1434. .attr( "role", "tabpanel" );
  1435. this.headers
  1436. .not( this.active )
  1437. .attr({
  1438. "aria-selected": "false",
  1439. tabIndex: -1
  1440. })
  1441. .next()
  1442. .attr({
  1443. "aria-expanded": "false",
  1444. "aria-hidden": "true"
  1445. })
  1446. .hide();
  1447. // make sure at least one header is in the tab order
  1448. if ( !this.active.length ) {
  1449. this.headers.eq( 0 ).attr( "tabIndex", 0 );
  1450. } else {
  1451. this.active.attr({
  1452. "aria-selected": "true",
  1453. tabIndex: 0
  1454. })
  1455. .next()
  1456. .attr({
  1457. "aria-expanded": "true",
  1458. "aria-hidden": "false"
  1459. });
  1460. }
  1461. this._on( this.headers, { keydown: "_keydown" });
  1462. this._on( this.headers.next(), { keydown: "_panelKeyDown" });
  1463. this._setupEvents( options.event );
  1464. },
  1465. _getCreateEventData: function() {
  1466. return {
  1467. header: this.active,
  1468. content: !this.active.length ? $() : this.active.next()
  1469. };
  1470. },
  1471. _createIcons: function() {
  1472. var icons = this.options.icons;
  1473. if ( icons ) {
  1474. $( "<span>" )
  1475. .addClass( "ui-accordion-header-icon ui-icon " + icons.header )
  1476. .prependTo( this.headers );
  1477. this.active.children( ".ui-accordion-header-icon" )
  1478. .removeClass( icons.header )
  1479. .addClass( icons.activeHeader );
  1480. this.headers.addClass( "ui-accordion-icons" );
  1481. }
  1482. },
  1483. _destroyIcons: function() {
  1484. this.headers
  1485. .removeClass( "ui-accordion-icons" )
  1486. .children( ".ui-accordion-header-icon" )
  1487. .remove();
  1488. },
  1489. _destroy: function() {
  1490. var contents;
  1491. // clean up main element
  1492. this.element
  1493. .removeClass( "ui-accordion ui-widget ui-helper-reset" )
  1494. .removeAttr( "role" );
  1495. // clean up headers
  1496. this.headers
  1497. .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" )
  1498. .removeAttr( "role" )
  1499. .removeAttr( "aria-selected" )
  1500. .removeAttr( "aria-controls" )
  1501. .removeAttr( "tabIndex" )
  1502. .each(function() {
  1503. if ( /^ui-accordion/.test( this.id ) ) {
  1504. this.removeAttribute( "id" );
  1505. }
  1506. });
  1507. this._destroyIcons();
  1508. // clean up content panels
  1509. contents = this.headers.next()
  1510. .css( "display", "" )
  1511. .removeAttr( "role" )
  1512. .removeAttr( "aria-expanded" )
  1513. .removeAttr( "aria-hidden" )
  1514. .removeAttr( "aria-labelledby" )
  1515. .removeClass( "ui-helper-reset ui-widget-content ui-corner-bottom ui-accordion-content ui-accordion-content-active ui-state-disabled" )
  1516. .each(function() {
  1517. if ( /^ui-accordion/.test( this.id ) ) {
  1518. this.removeAttribute( "id" );
  1519. }
  1520. });
  1521. if ( this.options.heightStyle !== "content" ) {
  1522. contents.css( "height", "" );
  1523. }
  1524. },
  1525. _setOption: function( key, value ) {
  1526. if ( key === "active" ) {
  1527. // _activate() will handle invalid values and update this.options
  1528. this._activate( value );
  1529. return;
  1530. }
  1531. if ( key === "event" ) {
  1532. if ( this.options.event ) {
  1533. this._off( this.headers, this.options.event );
  1534. }
  1535. this._setupEvents( value );
  1536. }
  1537. this._super( key, value );
  1538. // setting collapsible: false while collapsed; open first panel
  1539. if ( key === "collapsible" && !value && this.options.active === false ) {
  1540. this._activate( 0 );
  1541. }
  1542. if ( key === "icons" ) {
  1543. this._destroyIcons();
  1544. if ( value ) {
  1545. this._createIcons();
  1546. }
  1547. }
  1548. // #5332 - opacity doesn't cascade to positioned elements in IE
  1549. // so we need to add the disabled class to the headers and panels
  1550. if ( key === "disabled" ) {
  1551. this.headers.add( this.headers.next() )
  1552. .toggleClass( "ui-state-disabled", !!value );
  1553. }
  1554. },
  1555. _keydown: function( event ) {
  1556. if ( event.altKey || event.ctrlKey ) {
  1557. return;
  1558. }
  1559. var keyCode = $.ui.keyCode,
  1560. length = this.headers.length,
  1561. currentIndex = this.headers.index( event.target ),
  1562. toFocus = false;
  1563. switch ( event.keyCode ) {
  1564. case keyCode.RIGHT:
  1565. case keyCode.DOWN:
  1566. toFocus = this.headers[ ( currentIndex + 1 ) % length ];
  1567. break;
  1568. case keyCode.LEFT:
  1569. case keyCode.UP:
  1570. toFocus = this.headers[ ( currentIndex - 1 + length ) % length ];
  1571. break;
  1572. case keyCode.SPACE:
  1573. case keyCode.ENTER:
  1574. this._eventHandler( event );
  1575. break;
  1576. case keyCode.HOME:
  1577. toFocus = this.headers[ 0 ];
  1578. break;
  1579. case keyCode.END:
  1580. toFocus = this.headers[ length - 1 ];
  1581. break;
  1582. }
  1583. if ( toFocus ) {
  1584. $( event.target ).attr( "tabIndex", -1 );
  1585. $( toFocus ).attr( "tabIndex", 0 );
  1586. toFocus.focus();
  1587. event.preventDefault();
  1588. }
  1589. },
  1590. _panelKeyDown : function( event ) {
  1591. if ( event.keyCode === $.ui.keyCode.UP && event.ctrlKey ) {
  1592. $( event.currentTarget ).prev().focus();
  1593. }
  1594. },
  1595. refresh: function() {
  1596. var maxHeight, overflow,
  1597. heightStyle = this.options.heightStyle,
  1598. parent = this.element.parent();
  1599. if ( heightStyle === "fill" ) {
  1600. // IE 6 treats height like minHeight, so we need to turn off overflow
  1601. // in order to get a reliable height
  1602. // we use the minHeight support test because we assume that only
  1603. // browsers that don't support minHeight will treat height as minHeight
  1604. if ( !$.support.minHeight ) {
  1605. overflow = parent.css( "overflow" );
  1606. parent.css( "overflow", "hidden");
  1607. }
  1608. maxHeight = parent.height();
  1609. this.element.siblings( ":visible" ).each(function() {
  1610. var elem = $( this ),
  1611. position = elem.css( "position" );
  1612. if ( position === "absolute" || position === "fixed" ) {
  1613. return;
  1614. }
  1615. maxHeight -= elem.outerHeight( true );
  1616. });
  1617. if ( overflow ) {
  1618. parent.css( "overflow", overflow );
  1619. }
  1620. this.headers.each(function() {
  1621. maxHeight -= $( this ).outerHeight( true );
  1622. });
  1623. this.headers.next()
  1624. .each(function() {
  1625. $( this ).height( Math.max( 0, maxHeight -
  1626. $( this ).innerHeight() + $( this ).height() ) );
  1627. })
  1628. .css( "overflow", "auto" );
  1629. } else if ( heightStyle === "auto" ) {
  1630. maxHeight = 0;
  1631. this.headers.next()
  1632. .each(function() {
  1633. maxHeight = Math.max( maxHeight, $( this ).css( "height", "" ).height() );
  1634. })
  1635. .height( maxHeight );
  1636. }
  1637. },
  1638. _activate: function( index ) {
  1639. var active = this._findActive( index )[ 0 ];
  1640. // trying to activate the already active panel
  1641. if ( active === this.active[ 0 ] ) {
  1642. return;
  1643. }
  1644. // trying to collapse, simulate a click on the currently active header
  1645. active = active || this.active[ 0 ];
  1646. this._eventHandler({
  1647. target: active,
  1648. currentTarget: active,
  1649. preventDefault: $.noop
  1650. });
  1651. },
  1652. _findActive: function( selector ) {
  1653. return typeof selector === "number" ? this.headers.eq( selector ) : $();
  1654. },
  1655. _setupEvents: function( event ) {
  1656. var events = {};
  1657. if ( !event ) {
  1658. return;
  1659. }
  1660. $.each( event.split(" "), function( index, eventName ) {
  1661. events[ eventName ] = "_eventHandler";
  1662. });
  1663. this._on( this.headers, events );
  1664. },
  1665. _eventHandler: function( event ) {
  1666. var options = this.options,
  1667. active = this.active,
  1668. clicked = $( event.currentTarget ),
  1669. clickedIsActive = clicked[ 0 ] === active[ 0 ],
  1670. collapsing = clickedIsActive && options.collapsible,
  1671. toShow = collapsing ? $() : clicked.next(),
  1672. toHide = active.next(),
  1673. eventData = {
  1674. oldHeader: active,
  1675. oldPanel: toHide,
  1676. newHeader: collapsing ? $() : clicked,
  1677. newPanel: toShow
  1678. };
  1679. event.preventDefault();
  1680. if (
  1681. // click on active header, but not collapsible
  1682. ( clickedIsActive && !options.collapsible ) ||
  1683. // allow canceling activation
  1684. ( this._trigger( "beforeActivate", event, eventData ) === false ) ) {
  1685. return;
  1686. }
  1687. options.active = collapsing ? false : this.headers.index( clicked );
  1688. // when the call to ._toggle() comes after the class changes
  1689. // it causes a very odd bug in IE 8 (see #6720)
  1690. this.active = clickedIsActive ? $() : clicked;
  1691. this._toggle( eventData );
  1692. // switch classes
  1693. // corner classes on the previously active header stay after the animation
  1694. active.removeClass( "ui-accordion-header-active ui-state-active" );
  1695. if ( options.icons ) {
  1696. active.children( ".ui-accordion-header-icon" )
  1697. .removeClass( options.icons.activeHeader )
  1698. .addClass( options.icons.header );
  1699. }
  1700. if ( !clickedIsActive ) {
  1701. clicked
  1702. .removeClass( "ui-corner-all" )
  1703. .addClass( "ui-accordion-header-active ui-state-active ui-corner-top" );
  1704. if ( options.icons ) {
  1705. clicked.children( ".ui-accordion-header-icon" )
  1706. .removeClass( options.icons.header )
  1707. .addClass( options.icons.activeHeader );
  1708. }
  1709. clicked
  1710. .next()
  1711. .addClass( "ui-accordion-content-active" );
  1712. }
  1713. },
  1714. _toggle: function( data ) {
  1715. var toShow = data.newPanel,
  1716. toHide = this.prevShow.length ? this.prevShow : data.oldPanel;
  1717. // handle activating a panel during the animation for another activation
  1718. this.prevShow.add( this.prevHide ).stop( true, true );
  1719. this.prevShow = toShow;
  1720. this.prevHide = toHide;
  1721. if ( this.options.animate ) {
  1722. this._animate( toShow, toHide, data );
  1723. } else {
  1724. toHide.hide();
  1725. toShow.show();
  1726. this._toggleComplete( data );
  1727. }
  1728. toHide.attr({
  1729. "aria-expanded": "false",
  1730. "aria-hidden": "true"
  1731. });
  1732. toHide.prev().attr( "aria-selected", "false" );
  1733. // if we're switching panels, remove the old header from the tab order
  1734. // if we're opening from collapsed state, remove the previous header from the tab order
  1735. // if we're collapsing, then keep the collapsing header in the tab order
  1736. if ( toShow.length && toHide.length ) {
  1737. toHide.prev().attr( "tabIndex", -1 );
  1738. } else if ( toShow.length ) {
  1739. this.headers.filter(function() {
  1740. return $( this ).attr( "tabIndex" ) === 0;
  1741. })
  1742. .attr( "tabIndex", -1 );
  1743. }
  1744. toShow
  1745. .attr({
  1746. "aria-expanded": "true",
  1747. "aria-hidden": "false"
  1748. })
  1749. .prev()
  1750. .attr({
  1751. "aria-selected": "true",
  1752. tabIndex: 0
  1753. });
  1754. },
  1755. _animate: function( toShow, toHide, data ) {
  1756. var total, easing, duration,
  1757. that = this,
  1758. adjust = 0,
  1759. down = toShow.length &&
  1760. ( !toHide.length || ( toShow.index() < toHide.index() ) ),
  1761. animate = this.options.animate || {},
  1762. options = down && animate.down || animate,
  1763. complete = function() {
  1764. that._toggleComplete( data );
  1765. };
  1766. if ( typeof options === "number" ) {
  1767. duration = options;
  1768. }
  1769. if ( typeof options === "string" ) {
  1770. easing = options;
  1771. }
  1772. // fall back from options to animation in case of partial down settings
  1773. easing = easing || options.easing || animate.easing;
  1774. duration = duration || options.duration || animate.duration;
  1775. if ( !toHide.length ) {
  1776. return toShow.animate( showProps, duration, easing, complete );
  1777. }
  1778. if ( !toShow.length ) {
  1779. return toHide.animate( hideProps, duration, easing, complete );
  1780. }
  1781. total = toShow.show().outerHeight();
  1782. toHide.animate( hideProps, {
  1783. duration: duration,
  1784. easing: easing,
  1785. step: function( now, fx ) {
  1786. fx.now = Math.round( now );
  1787. }
  1788. });
  1789. toShow
  1790. .hide()
  1791. .animate( showProps, {
  1792. duration: duration,
  1793. easing: easing,
  1794. complete: complete,
  1795. step: function( now, fx ) {
  1796. fx.now = Math.round( now );
  1797. if ( fx.prop !== "height" ) {
  1798. adjust += fx.now;
  1799. } else if ( that.options.heightStyle !== "content" ) {
  1800. fx.now = Math.round( total - toHide.outerHeight() - adjust );
  1801. adjust = 0;
  1802. }
  1803. }
  1804. });
  1805. },
  1806. _toggleComplete: function( data ) {
  1807. var toHide = data.oldPanel;
  1808. toHide
  1809. .removeClass( "ui-accordion-content-active" )
  1810. .prev()
  1811. .removeClass( "ui-corner-top" )
  1812. .addClass( "ui-corner-all" );
  1813. // Work around for rendering bug in IE (#5421)
  1814. if ( toHide.length ) {
  1815. toHide.parent()[0].className = toHide.parent()[0].className;
  1816. }
  1817. this._trigger( "activate", null, data );
  1818. }
  1819. });
  1820. // DEPRECATED
  1821. if ( $.uiBackCompat !== false ) {
  1822. // navigation options
  1823. (function( $, prototype ) {
  1824. $.extend( prototype.options, {
  1825. navigation: false,
  1826. navigationFilter: function() {
  1827. return this.href.toLowerCase() === location.href.toLowerCase();
  1828. }
  1829. });
  1830. var _create = prototype._create;
  1831. prototype._create = function() {
  1832. if ( this.options.navigation ) {
  1833. var that = this,
  1834. headers = this.element.find( this.options.header ),
  1835. content = headers.next(),
  1836. current = headers.add( content )
  1837. .find( "a" )
  1838. .filter( this.options.navigationFilter )
  1839. [ 0 ];
  1840. if ( current ) {
  1841. headers.add( content ).each( function( index ) {
  1842. if ( $.contains( this, current ) ) {
  1843. that.options.active = Math.floor( index / 2 );
  1844. return false;
  1845. }
  1846. });
  1847. }
  1848. }
  1849. _create.call( this );
  1850. };
  1851. }( jQuery, jQuery.ui.accordion.prototype ) );
  1852. // height options
  1853. (function( $, prototype ) {
  1854. $.extend( prototype.options, {
  1855. heightStyle: null, // remove default so we fall back to old values
  1856. autoHeight: true, // use heightStyle: "auto"
  1857. clearStyle: false, // use heightStyle: "content"
  1858. fillSpace: false // use heightStyle: "fill"
  1859. });
  1860. var _create = prototype._create,
  1861. _setOption = prototype._setOption;
  1862. $.extend( prototype, {
  1863. _create: function() {
  1864. this.options.heightStyle = this.options.heightStyle ||
  1865. this._mergeHeightStyle();
  1866. _create.call( this );
  1867. },
  1868. _setOption: function( key ) {
  1869. if ( key === "autoHeight" || key === "clearStyle" || key === "fillSpace" ) {
  1870. this.options.heightStyle = this._mergeHeightStyle();
  1871. }
  1872. _setOption.apply( this, arguments );
  1873. },
  1874. _mergeHeightStyle: function() {
  1875. var options = this.options;
  1876. if ( options.fillSpace ) {
  1877. return "fill";
  1878. }
  1879. if ( options.clearStyle ) {
  1880. return "content";
  1881. }
  1882. if ( options.autoHeight ) {
  1883. return "auto";
  1884. }
  1885. }
  1886. });
  1887. }( jQuery, jQuery.ui.accordion.prototype ) );
  1888. // icon options
  1889. (function( $, prototype ) {
  1890. $.extend( prototype.options.icons, {
  1891. activeHeader: null, // remove default so we fall back to old values
  1892. headerSelected: "ui-icon-triangle-1-s"
  1893. });
  1894. var _createIcons = prototype._createIcons;
  1895. prototype._createIcons = function() {
  1896. if ( this.options.icons ) {
  1897. this.options.icons.activeHeader = this.options.icons.activeHeader ||
  1898. this.options.icons.headerSelected;
  1899. }
  1900. _createIcons.call( this );
  1901. };
  1902. }( jQuery, jQuery.ui.accordion.prototype ) );
  1903. // expanded active option, activate method
  1904. (function( $, prototype ) {
  1905. prototype.activate = prototype._activate;
  1906. var _findActive = prototype._findActive;
  1907. prototype._findActive = function( index ) {
  1908. if ( index === -1 ) {
  1909. index = false;
  1910. }
  1911. if ( index && typeof index !== "number" ) {
  1912. index = this.headers.index( this.headers.filter( index ) );
  1913. if ( index === -1 ) {
  1914. index = false;
  1915. }
  1916. }
  1917. return _findActive.call( this, index );
  1918. };
  1919. }( jQuery, jQuery.ui.accordion.prototype ) );
  1920. // resize method
  1921. jQuery.ui.accordion.prototype.resize = jQuery.ui.accordion.prototype.refresh;
  1922. // change events
  1923. (function( $, prototype ) {
  1924. $.extend( prototype.options, {
  1925. change: null,
  1926. changestart: null
  1927. });
  1928. var _trigger = prototype._trigger;
  1929. prototype._trigger = function( type, event, data ) {
  1930. var ret = _trigger.apply( this, arguments );
  1931. if ( !ret ) {
  1932. return false;
  1933. }
  1934. if ( type === "beforeActivate" ) {
  1935. ret = _trigger.call( this, "changestart", event, {
  1936. oldHeader: data.oldHeader,
  1937. oldContent: data.oldPanel,
  1938. newHeader: data.newHeader,
  1939. newContent: data.newPanel
  1940. });
  1941. } else if ( type === "activate" ) {
  1942. ret = _trigger.call( this, "change", event, {
  1943. oldHeader: data.oldHeader,
  1944. oldContent: data.oldPanel,
  1945. newHeader: data.newHeader,
  1946. newContent: data.newPanel
  1947. });
  1948. }
  1949. return ret;
  1950. };
  1951. }( jQuery, jQuery.ui.accordion.prototype ) );
  1952. // animated option
  1953. // NOTE: this only provides support for "slide", "bounceslide", and easings
  1954. // not the full $.ui.accordion.animations API
  1955. (function( $, prototype ) {
  1956. $.extend( prototype.options, {
  1957. animate: null,
  1958. animated: "slide"
  1959. });
  1960. var _create = prototype._create;
  1961. prototype._create = function() {
  1962. var options = this.options;
  1963. if ( options.animate === null ) {
  1964. if ( !options.animated ) {
  1965. options.animate = false;
  1966. } else if ( options.animated === "slide" ) {
  1967. options.animate = 300;
  1968. } else if ( options.animated === "bounceslide" ) {
  1969. options.animate = {
  1970. duration: 200,
  1971. down: {
  1972. easing: "easeOutBounce",
  1973. duration: 1000
  1974. }
  1975. };
  1976. } else {
  1977. options.animate = options.animated;
  1978. }
  1979. }
  1980. _create.call( this );
  1981. };
  1982. }( jQuery, jQuery.ui.accordion.prototype ) );
  1983. }
  1984. })( jQuery );
  1985. (function( $, undefined ) {
  1986. // used to prevent race conditions with remote data sources
  1987. var requestIndex = 0;
  1988. $.widget( "ui.autocomplete", {
  1989. version: "1.9.2",
  1990. defaultElement: "<input>",
  1991. options: {
  1992. appendTo: "body",
  1993. autoFocus: false,
  1994. delay: 300,
  1995. minLength: 1,
  1996. position: {
  1997. my: "left top",
  1998. at: "left bottom",
  1999. collision: "none"
  2000. },
  2001. source: null,
  2002. // callbacks
  2003. change: null,
  2004. close: null,
  2005. focus: null,
  2006. open: null,
  2007. response: null,
  2008. search: null,
  2009. select: null
  2010. },
  2011. pending: 0,
  2012. _create: function() {
  2013. // Some browsers only repeat keydown events, not keypress events,
  2014. // so we use the suppressKeyPress flag to determine if we've already
  2015. // handled the keydown event. #7269
  2016. // Unfortunately the code for & in keypress is the same as the up arrow,
  2017. // so we use the suppressKeyPressRepeat flag to avoid handling keypress
  2018. // events when we know the keydown event was used to modify the
  2019. // search term. #7799
  2020. var suppressKeyPress, suppressKeyPressRepeat, suppressInput;
  2021. this.isMultiLine = this._isMultiLine();
  2022. this.valueMethod = this.element[ this.element.is( "input,textarea" ) ? "val" : "text" ];
  2023. this.isNewMenu = true;
  2024. this.element
  2025. .addClass( "ui-autocomplete-input" )
  2026. .attr( "autocomplete", "off" );
  2027. this._on( this.element, {
  2028. keydown: function( event ) {
  2029. if ( this.element.prop( "readOnly" ) ) {
  2030. suppressKeyPress = true;
  2031. suppressInput = true;
  2032. suppressKeyPressRepeat = true;
  2033. return;
  2034. }
  2035. suppressKeyPress = false;
  2036. suppressInput = false;
  2037. suppressKeyPressRepeat = false;
  2038. var keyCode = $.ui.keyCode;
  2039. switch( event.keyCode ) {
  2040. case keyCode.PAGE_UP:
  2041. suppressKeyPress = true;
  2042. this._move( "previousPage", event );
  2043. break;
  2044. case keyCode.PAGE_DOWN:
  2045. suppressKeyPress = true;
  2046. this._move( "nextPage", event );
  2047. break;
  2048. case keyCode.UP:
  2049. suppressKeyPress = true;
  2050. this._keyEvent( "previous", event );
  2051. break;
  2052. case keyCode.DOWN:
  2053. suppressKeyPress = true;
  2054. this._keyEvent( "next", event );
  2055. break;
  2056. case keyCode.ENTER:
  2057. case keyCode.NUMPAD_ENTER:
  2058. // when menu is open and has focus
  2059. if ( this.menu.active ) {
  2060. // #6055 - Opera still allows the keypress to occur
  2061. // which causes forms to submit
  2062. suppressKeyPress = true;
  2063. event.preventDefault();
  2064. this.menu.select( event );
  2065. }
  2066. break;
  2067. case keyCode.TAB:
  2068. if ( this.menu.active ) {
  2069. this.menu.select( event );
  2070. }
  2071. break;
  2072. case keyCode.ESCAPE:
  2073. if ( this.menu.element.is( ":visible" ) ) {
  2074. this._value( this.term );
  2075. this.close( event );
  2076. // Different browsers have different default behavior for escape
  2077. // Single press can mean undo or clear
  2078. // Double press in IE means clear the whole form
  2079. event.preventDefault();
  2080. }
  2081. break;
  2082. default:
  2083. suppressKeyPressRepeat = true;
  2084. // search timeout should be triggered before the input value is changed
  2085. this._searchTimeout( event );
  2086. break;
  2087. }
  2088. },
  2089. keypress: function( event ) {
  2090. if ( suppressKeyPress ) {
  2091. suppressKeyPress = false;
  2092. event.preventDefault();
  2093. return;
  2094. }
  2095. if ( suppressKeyPressRepeat ) {
  2096. return;
  2097. }
  2098. // replicate some key handlers to allow them to repeat in Firefox and Opera
  2099. var keyCode = $.ui.keyCode;
  2100. switch( event.keyCode ) {
  2101. case keyCode.PAGE_UP:
  2102. this._move( "previousPage", event );
  2103. break;
  2104. case keyCode.PAGE_DOWN:
  2105. this._move( "nextPage", event );
  2106. break;
  2107. case keyCode.UP:
  2108. this._keyEvent( "previous", event );
  2109. break;
  2110. case keyCode.DOWN:
  2111. this._keyEvent( "next", event );
  2112. break;
  2113. }
  2114. },
  2115. input: function( event ) {
  2116. if ( suppressInput ) {
  2117. suppressInput = false;
  2118. event.preventDefault();
  2119. return;
  2120. }
  2121. this._searchTimeout( event );
  2122. },
  2123. focus: function() {
  2124. this.selectedItem = null;
  2125. this.previous = this._value();
  2126. },
  2127. blur: function( event ) {
  2128. if ( this.cancelBlur ) {
  2129. delete this.cancelBlur;
  2130. return;
  2131. }
  2132. clearTimeout( this.searching );
  2133. this.close( event );
  2134. this._change( event );
  2135. }
  2136. });
  2137. this._initSource();
  2138. this.menu = $( "<ul>" )
  2139. .addClass( "ui-autocomplete" )
  2140. .appendTo( this.document.find( this.options.appendTo || "body" )[ 0 ] )
  2141. .menu({
  2142. // custom key handling for now
  2143. input: $(),
  2144. // disable ARIA support, the live region takes care of that
  2145. role: null
  2146. })
  2147. .zIndex( this.element.zIndex() + 1 )
  2148. .hide()
  2149. .data( "menu" );
  2150. this._on( this.menu.element, {
  2151. mousedown: function( event ) {
  2152. // prevent moving focus out of the text field
  2153. event.preventDefault();
  2154. // IE doesn't prevent moving focus even with event.preventDefault()
  2155. // so we set a flag to know when we should ignore the blur event
  2156. this.cancelBlur = true;
  2157. this._delay(function() {
  2158. delete this.cancelBlur;
  2159. });
  2160. // clicking on the scrollbar causes focus to shift to the body
  2161. // but we can't detect a mouseup or a click immediately afterward
  2162. // so we have to track the next mousedown and close the menu if
  2163. // the user clicks somewhere outside of the autocomplete
  2164. var menuElement = this.menu.element[ 0 ];
  2165. if ( !$( event.target ).closest( ".ui-menu-item" ).length ) {
  2166. this._delay(function() {
  2167. var that = this;
  2168. this.document.one( "mousedown", function( event ) {
  2169. if ( event.target !== that.element[ 0 ] &&
  2170. event.target !== menuElement &&
  2171. !$.contains( menuElement, event.target ) ) {
  2172. that.close();
  2173. }
  2174. });
  2175. });
  2176. }
  2177. },
  2178. menufocus: function( event, ui ) {
  2179. // #7024 - Prevent accidental activation of menu items in Firefox
  2180. if ( this.isNewMenu ) {
  2181. this.isNewMenu = false;
  2182. if ( event.originalEvent && /^mouse/.test( event.originalEvent.type ) ) {
  2183. this.menu.blur();
  2184. this.document.one( "mousemove", function() {
  2185. $( event.target ).trigger( event.originalEvent );
  2186. });
  2187. return;
  2188. }
  2189. }
  2190. // back compat for _renderItem using item.autocomplete, via #7810
  2191. // TODO remove the fallback, see #8156
  2192. var item = ui.item.data( "ui-autocomplete-item" ) || ui.item.data( "item.autocomplete" );
  2193. if ( false !== this._trigger( "focus", event, { item: item } ) ) {
  2194. // use value to match what will end up in the input, if it was a key event
  2195. if ( event.originalEvent && /^key/.test( event.originalEvent.type ) ) {
  2196. this._value( item.value );
  2197. }
  2198. } else {
  2199. // Normally the input is populated with the item's value as the
  2200. // menu is navigated, causing screen readers to notice a change and
  2201. // announce the item. Since the focus event was canceled, this doesn't
  2202. // happen, so we update the live region so that screen readers can
  2203. // still notice the change and announce it.
  2204. this.liveRegion.text( item.value );
  2205. }
  2206. },
  2207. menuselect: function( event, ui ) {
  2208. // back compat for _renderItem using item.autocomplete, via #7810
  2209. // TODO remove the fallback, see #8156
  2210. var item = ui.item.data( "ui-autocomplete-item" ) || ui.item.data( "item.autocomplete" ),
  2211. previous = this.previous;
  2212. // only trigger when focus was lost (click on menu)
  2213. if ( this.element[0] !== this.document[0].activeElement ) {
  2214. this.element.focus();
  2215. this.previous = previous;
  2216. // #6109 - IE triggers two focus events and the second
  2217. // is asynchronous, so we need to reset the previous
  2218. // term synchronously and asynchronously :-(
  2219. this._delay(function() {
  2220. this.previous = previous;
  2221. this.selectedItem = item;
  2222. });
  2223. }
  2224. if ( false !== this._trigger( "select", event, { item: item } ) ) {
  2225. this._value( item.value );
  2226. }
  2227. // reset the term after the select event
  2228. // this allows custom select handling to work properly
  2229. this.term = this._value();
  2230. this.close( event );
  2231. this.selectedItem = item;
  2232. }
  2233. });
  2234. this.liveRegion = $( "<span>", {
  2235. role: "status",
  2236. "aria-live": "polite"
  2237. })
  2238. .addClass( "ui-helper-hidden-accessible" )
  2239. .insertAfter( this.element );
  2240. if ( $.fn.bgiframe ) {
  2241. this.menu.element.bgiframe();
  2242. }
  2243. // turning off autocomplete prevents the browser from remembering the
  2244. // value when navigating through history, so we re-enable autocomplete
  2245. // if the page is unloaded before the widget is destroyed. #7790
  2246. this._on( this.window, {
  2247. beforeunload: function() {
  2248. this.element.removeAttr( "autocomplete" );
  2249. }
  2250. });
  2251. },
  2252. _destroy: function() {
  2253. clearTimeout( this.searching );
  2254. this.element
  2255. .removeClass( "ui-autocomplete-input" )
  2256. .removeAttr( "autocomplete" );
  2257. this.menu.element.remove();
  2258. this.liveRegion.remove();
  2259. },
  2260. _setOption: function( key, value ) {
  2261. this._super( key, value );
  2262. if ( key === "source" ) {
  2263. this._initSource();
  2264. }
  2265. if ( key === "appendTo" ) {
  2266. this.menu.element.appendTo( this.document.find( value || "body" )[0] );
  2267. }
  2268. if ( key === "disabled" && value && this.xhr ) {
  2269. this.xhr.abort();
  2270. }
  2271. },
  2272. _isMultiLine: function() {
  2273. // Textareas are always multi-line
  2274. if ( this.element.is( "textarea" ) ) {
  2275. return true;
  2276. }
  2277. // Inputs are always single-line, even if inside a contentEditable element
  2278. // IE also treats inputs as contentEditable
  2279. if ( this.element.is( "input" ) ) {
  2280. return false;
  2281. }
  2282. // All other element types are determined by whether or not they're contentEditable
  2283. return this.element.prop( "isContentEditable" );
  2284. },
  2285. _initSource: function() {
  2286. var array, url,
  2287. that = this;
  2288. if ( $.isArray(this.options.source) ) {
  2289. array = this.options.source;
  2290. this.source = function( request, response ) {
  2291. response( $.ui.autocomplete.filter( array, request.term ) );
  2292. };
  2293. } else if ( typeof this.options.source === "string" ) {
  2294. url = this.options.source;
  2295. this.source = function( request, response ) {
  2296. if ( that.xhr ) {
  2297. that.xhr.abort();
  2298. }
  2299. that.xhr = $.ajax({
  2300. url: url,
  2301. data: request,
  2302. dataType: "json",
  2303. success: function( data ) {
  2304. response( data );
  2305. },
  2306. error: function() {
  2307. response( [] );
  2308. }
  2309. });
  2310. };
  2311. } else {
  2312. this.source = this.options.source;
  2313. }
  2314. },
  2315. _searchTimeout: function( event ) {
  2316. clearTimeout( this.searching );
  2317. this.searching = this._delay(function() {
  2318. // only search if the value has changed
  2319. if ( this.term !== this._value() ) {
  2320. this.selectedItem = null;
  2321. this.search( null, event );
  2322. }
  2323. }, this.options.delay );
  2324. },
  2325. search: function( value, event ) {
  2326. value = value != null ? value : this._value();
  2327. // always save the actual value, not the one passed as an argument
  2328. this.term = this._value();
  2329. if ( value.length < this.options.minLength ) {
  2330. return this.close( event );
  2331. }
  2332. if ( this._trigger( "search", event ) === false ) {
  2333. return;
  2334. }
  2335. return this._search( value );
  2336. },
  2337. _search: function( value ) {
  2338. this.pending++;
  2339. this.element.addClass( "ui-autocomplete-loading" );
  2340. this.cancelSearch = false;
  2341. this.source( { term: value }, this._response() );
  2342. },
  2343. _response: function() {
  2344. var that = this,
  2345. index = ++requestIndex;
  2346. return function( content ) {
  2347. if ( index === requestIndex ) {
  2348. that.__response( content );
  2349. }
  2350. that.pending--;
  2351. if ( !that.pending ) {
  2352. that.element.removeClass( "ui-autocomplete-loading" );
  2353. }
  2354. };
  2355. },
  2356. __response: function( content ) {
  2357. if ( content ) {
  2358. content = this._normalize( content );
  2359. }
  2360. this._trigger( "response", null, { content: content } );
  2361. if ( !this.options.disabled && content && content.length && !this.cancelSearch ) {
  2362. this._suggest( content );
  2363. this._trigger( "open" );
  2364. } else {
  2365. // use ._close() instead of .close() so we don't cancel future searches
  2366. this._close();
  2367. }
  2368. },
  2369. close: function( event ) {
  2370. this.cancelSearch = true;
  2371. this._close( event );
  2372. },
  2373. _close: function( event ) {
  2374. if ( this.menu.element.is( ":visible" ) ) {
  2375. this.menu.element.hide();
  2376. this.menu.blur();
  2377. this.isNewMenu = true;
  2378. this._trigger( "close", event );
  2379. }
  2380. },
  2381. _change: function( event ) {
  2382. if ( this.previous !== this._value() ) {
  2383. this._trigger( "change", event, { item: this.selectedItem } );
  2384. }
  2385. },
  2386. _normalize: function( items ) {
  2387. // assume all items have the right format when the first item is complete
  2388. if ( items.length && items[0].label && items[0].value ) {
  2389. return items;
  2390. }
  2391. return $.map( items, function( item ) {
  2392. if ( typeof item === "string" ) {
  2393. return {
  2394. label: item,
  2395. value: item
  2396. };
  2397. }
  2398. return $.extend({
  2399. label: item.label || item.value,
  2400. value: item.value || item.label
  2401. }, item );
  2402. });
  2403. },
  2404. _suggest: function( items ) {
  2405. var ul = this.menu.element
  2406. .empty()
  2407. .zIndex( this.element.zIndex() + 1 );
  2408. this._renderMenu( ul, items );
  2409. this.menu.refresh();
  2410. // size and position menu
  2411. ul.show();
  2412. this._resizeMenu();
  2413. ul.position( $.extend({
  2414. of: this.element
  2415. }, this.options.position ));
  2416. if ( this.options.autoFocus ) {
  2417. this.menu.next();
  2418. }
  2419. },
  2420. _resizeMenu: function() {
  2421. var ul = this.menu.element;
  2422. ul.outerWidth( Math.max(
  2423. // Firefox wraps long text (possibly a rounding bug)
  2424. // so we add 1px to avoid the wrapping (#7513)
  2425. ul.width( "" ).outerWidth() + 1,
  2426. this.element.outerWidth()
  2427. ) );
  2428. },
  2429. _renderMenu: function( ul, items ) {
  2430. var that = this;
  2431. $.each( items, function( index, item ) {
  2432. that._renderItemData( ul, item );
  2433. });
  2434. },
  2435. _renderItemData: function( ul, item ) {
  2436. return this._renderItem( ul, item ).data( "ui-autocomplete-item", item );
  2437. },
  2438. _renderItem: function( ul, item ) {
  2439. return $( "<li>" )
  2440. .append( $( "<a>" ).text( item.label ) )
  2441. .appendTo( ul );
  2442. },
  2443. _move: function( direction, event ) {
  2444. if ( !this.menu.element.is( ":visible" ) ) {
  2445. this.search( null, event );
  2446. return;
  2447. }
  2448. if ( this.menu.isFirstItem() && /^previous/.test( direction ) ||
  2449. this.menu.isLastItem() && /^next/.test( direction ) ) {
  2450. this._value( this.term );
  2451. this.menu.blur();
  2452. return;
  2453. }
  2454. this.menu[ direction ]( event );
  2455. },
  2456. widget: function() {
  2457. return this.menu.element;
  2458. },
  2459. _value: function() {
  2460. return this.valueMethod.apply( this.element, arguments );
  2461. },
  2462. _keyEvent: function( keyEvent, event ) {
  2463. if ( !this.isMultiLine || this.menu.element.is( ":visible" ) ) {
  2464. this._move( keyEvent, event );
  2465. // prevents moving cursor to beginning/end of the text field in some browsers
  2466. event.preventDefault();
  2467. }
  2468. }
  2469. });
  2470. $.extend( $.ui.autocomplete, {
  2471. escapeRegex: function( value ) {
  2472. return value.replace(/[\-\[\]{}()*+?.,\\\^$|#\s]/g, "\\$&");
  2473. },
  2474. filter: function(array, term) {
  2475. var matcher = new RegExp( $.ui.autocomplete.escapeRegex(term), "i" );
  2476. return $.grep( array, function(value) {
  2477. return matcher.test( value.label || value.value || value );
  2478. });
  2479. }
  2480. });
  2481. // live region extension, adding a `messages` option
  2482. // NOTE: This is an experimental API. We are still investigating
  2483. // a full solution for string manipulation and internationalization.
  2484. $.widget( "ui.autocomplete", $.ui.autocomplete, {
  2485. options: {
  2486. messages: {
  2487. noResults: "No search results.",
  2488. results: function( amount ) {
  2489. return amount + ( amount > 1 ? " results are" : " result is" ) +
  2490. " available, use up and down arrow keys to navigate.";
  2491. }
  2492. }
  2493. },
  2494. __response: function( content ) {
  2495. var message;
  2496. this._superApply( arguments );
  2497. if ( this.options.disabled || this.cancelSearch ) {
  2498. return;
  2499. }
  2500. if ( content && content.length ) {
  2501. message = this.options.messages.results( content.length );
  2502. } else {
  2503. message = this.options.messages.noResults;
  2504. }
  2505. this.liveRegion.text( message );
  2506. }
  2507. });
  2508. }( jQuery ));
  2509. (function( $, undefined ) {
  2510. var lastActive, startXPos, startYPos, clickDragged,
  2511. baseClasses = "ui-button ui-widget ui-state-default ui-corner-all",
  2512. stateClasses = "ui-state-hover ui-state-active ",
  2513. 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",
  2514. formResetHandler = function() {
  2515. var buttons = $( this ).find( ":ui-button" );
  2516. setTimeout(function() {
  2517. buttons.button( "refresh" );
  2518. }, 1 );
  2519. },
  2520. radioGroup = function( radio ) {
  2521. var name = radio.name,
  2522. form = radio.form,
  2523. radios = $( [] );
  2524. if ( name ) {
  2525. if ( form ) {
  2526. radios = $( form ).find( "[name='" + name + "']" );
  2527. } else {
  2528. radios = $( "[name='" + name + "']", radio.ownerDocument )
  2529. .filter(function() {
  2530. return !this.form;
  2531. });
  2532. }
  2533. }
  2534. return radios;
  2535. };
  2536. $.widget( "ui.button", {
  2537. version: "1.9.2",
  2538. defaultElement: "<button>",
  2539. options: {
  2540. disabled: null,
  2541. text: true,
  2542. label: null,
  2543. icons: {
  2544. primary: null,
  2545. secondary: null
  2546. }
  2547. },
  2548. _create: function() {
  2549. this.element.closest( "form" )
  2550. .unbind( "reset" + this.eventNamespace )
  2551. .bind( "reset" + this.eventNamespace, formResetHandler );
  2552. if ( typeof this.options.disabled !== "boolean" ) {
  2553. this.options.disabled = !!this.element.prop( "disabled" );
  2554. } else {
  2555. this.element.prop( "disabled", this.options.disabled );
  2556. }
  2557. this._determineButtonType();
  2558. this.hasTitle = !!this.buttonElement.attr( "title" );
  2559. var that = this,
  2560. options = this.options,
  2561. toggleButton = this.type === "checkbox" || this.type === "radio",
  2562. activeClass = !toggleButton ? "ui-state-active" : "",
  2563. focusClass = "ui-state-focus";
  2564. if ( options.label === null ) {
  2565. options.label = (this.type === "input" ? this.buttonElement.val() : this.buttonElement.html());
  2566. }
  2567. this._hoverable( this.buttonElement );
  2568. this.buttonElement
  2569. .addClass( baseClasses )
  2570. .attr( "role", "button" )
  2571. .bind( "mouseenter" + this.eventNamespace, function() {
  2572. if ( options.disabled ) {
  2573. return;
  2574. }
  2575. if ( this === lastActive ) {
  2576. $( this ).addClass( "ui-state-active" );
  2577. }
  2578. })
  2579. .bind( "mouseleave" + this.eventNamespace, function() {
  2580. if ( options.disabled ) {
  2581. return;
  2582. }
  2583. $( this ).removeClass( activeClass );
  2584. })
  2585. .bind( "click" + this.eventNamespace, function( event ) {
  2586. if ( options.disabled ) {
  2587. event.preventDefault();
  2588. event.stopImmediatePropagation();
  2589. }
  2590. });
  2591. this.element
  2592. .bind( "focus" + this.eventNamespace, function() {
  2593. // no need to check disabled, focus won't be triggered anyway
  2594. that.buttonElement.addClass( focusClass );
  2595. })
  2596. .bind( "blur" + this.eventNamespace, function() {
  2597. that.buttonElement.removeClass( focusClass );
  2598. });
  2599. if ( toggleButton ) {
  2600. this.element.bind( "change" + this.eventNamespace, function() {
  2601. if ( clickDragged ) {
  2602. return;
  2603. }
  2604. that.refresh();
  2605. });
  2606. // if mouse moves between mousedown and mouseup (drag) set clickDragged flag
  2607. // prevents issue where button state changes but checkbox/radio checked state
  2608. // does not in Firefox (see ticket #6970)
  2609. this.buttonElement
  2610. .bind( "mousedown" + this.eventNamespace, function( event ) {
  2611. if ( options.disabled ) {
  2612. return;
  2613. }
  2614. clickDragged = false;
  2615. startXPos = event.pageX;
  2616. startYPos = event.pageY;
  2617. })
  2618. .bind( "mouseup" + this.eventNamespace, function( event ) {
  2619. if ( options.disabled ) {
  2620. return;
  2621. }
  2622. if ( startXPos !== event.pageX || startYPos !== event.pageY ) {
  2623. clickDragged = true;
  2624. }
  2625. });
  2626. }
  2627. if ( this.type === "checkbox" ) {
  2628. this.buttonElement.bind( "click" + this.eventNamespace, function() {
  2629. if ( options.disabled || clickDragged ) {
  2630. return false;
  2631. }
  2632. $( this ).toggleClass( "ui-state-active" );
  2633. that.buttonElement.attr( "aria-pressed", that.element[0].checked );
  2634. });
  2635. } else if ( this.type === "radio" ) {
  2636. this.buttonElement.bind( "click" + this.eventNamespace, function() {
  2637. if ( options.disabled || clickDragged ) {
  2638. return false;
  2639. }
  2640. $( this ).addClass( "ui-state-active" );
  2641. that.buttonElement.attr( "aria-pressed", "true" );
  2642. var radio = that.element[ 0 ];
  2643. radioGroup( radio )
  2644. .not( radio )
  2645. .map(function() {
  2646. return $( this ).button( "widget" )[ 0 ];
  2647. })
  2648. .removeClass( "ui-state-active" )
  2649. .attr( "aria-pressed", "false" );
  2650. });
  2651. } else {
  2652. this.buttonElement
  2653. .bind( "mousedown" + this.eventNamespace, function() {
  2654. if ( options.disabled ) {
  2655. return false;
  2656. }
  2657. $( this ).addClass( "ui-state-active" );
  2658. lastActive = this;
  2659. that.document.one( "mouseup", function() {
  2660. lastActive = null;
  2661. });
  2662. })
  2663. .bind( "mouseup" + this.eventNamespace, function() {
  2664. if ( options.disabled ) {
  2665. return false;
  2666. }
  2667. $( this ).removeClass( "ui-state-active" );
  2668. })
  2669. .bind( "keydown" + this.eventNamespace, function(event) {
  2670. if ( options.disabled ) {
  2671. return false;
  2672. }
  2673. if ( event.keyCode === $.ui.keyCode.SPACE || event.keyCode === $.ui.keyCode.ENTER ) {
  2674. $( this ).addClass( "ui-state-active" );
  2675. }
  2676. })
  2677. .bind( "keyup" + this.eventNamespace, function() {
  2678. $( this ).removeClass( "ui-state-active" );
  2679. });
  2680. if ( this.buttonElement.is("a") ) {
  2681. this.buttonElement.keyup(function(event) {
  2682. if ( event.keyCode === $.ui.keyCode.SPACE ) {
  2683. // TODO pass through original event correctly (just as 2nd argument doesn't work)
  2684. $( this ).click();
  2685. }
  2686. });
  2687. }
  2688. }
  2689. // TODO: pull out $.Widget's handling for the disabled option into
  2690. // $.Widget.prototype._setOptionDisabled so it's easy to proxy and can
  2691. // be overridden by individual plugins
  2692. this._setOption( "disabled", options.disabled );
  2693. this._resetButton();
  2694. },
  2695. _determineButtonType: function() {
  2696. var ancestor, labelSelector, checked;
  2697. if ( this.element.is("[type=checkbox]") ) {
  2698. this.type = "checkbox";
  2699. } else if ( this.element.is("[type=radio]") ) {
  2700. this.type = "radio";
  2701. } else if ( this.element.is("input") ) {
  2702. this.type = "input";
  2703. } else {
  2704. this.type = "button";
  2705. }
  2706. if ( this.type === "checkbox" || this.type === "radio" ) {
  2707. // we don't search against the document in case the element
  2708. // is disconnected from the DOM
  2709. ancestor = this.element.parents().last();
  2710. labelSelector = "label[for='" + this.element.attr("id") + "']";
  2711. this.buttonElement = ancestor.find( labelSelector );
  2712. if ( !this.buttonElement.length ) {
  2713. ancestor = ancestor.length ? ancestor.siblings() : this.element.siblings();
  2714. this.buttonElement = ancestor.filter( labelSelector );
  2715. if ( !this.buttonElement.length ) {
  2716. this.buttonElement = ancestor.find( labelSelector );
  2717. }
  2718. }
  2719. this.element.addClass( "ui-helper-hidden-accessible" );
  2720. checked = this.element.is( ":checked" );
  2721. if ( checked ) {
  2722. this.buttonElement.addClass( "ui-state-active" );
  2723. }
  2724. this.buttonElement.prop( "aria-pressed", checked );
  2725. } else {
  2726. this.buttonElement = this.element;
  2727. }
  2728. },
  2729. widget: function() {
  2730. return this.buttonElement;
  2731. },
  2732. _destroy: function() {
  2733. this.element
  2734. .removeClass( "ui-helper-hidden-accessible" );
  2735. this.buttonElement
  2736. .removeClass( baseClasses + " " + stateClasses + " " + typeClasses )
  2737. .removeAttr( "role" )
  2738. .removeAttr( "aria-pressed" )
  2739. .html( this.buttonElement.find(".ui-button-text").html() );
  2740. if ( !this.hasTitle ) {
  2741. this.buttonElement.removeAttr( "title" );
  2742. }
  2743. },
  2744. _setOption: function( key, value ) {
  2745. this._super( key, value );
  2746. if ( key === "disabled" ) {
  2747. if ( value ) {
  2748. this.element.prop( "disabled", true );
  2749. } else {
  2750. this.element.prop( "disabled", false );
  2751. }
  2752. return;
  2753. }
  2754. this._resetButton();
  2755. },
  2756. refresh: function() {
  2757. //See #8237 & #8828
  2758. var isDisabled = this.element.is( "input, button" ) ? this.element.is( ":disabled" ) : this.element.hasClass( "ui-button-disabled" );
  2759. if ( isDisabled !== this.options.disabled ) {
  2760. this._setOption( "disabled", isDisabled );
  2761. }
  2762. if ( this.type === "radio" ) {
  2763. radioGroup( this.element[0] ).each(function() {
  2764. if ( $( this ).is( ":checked" ) ) {
  2765. $( this ).button( "widget" )
  2766. .addClass( "ui-state-active" )
  2767. .attr( "aria-pressed", "true" );
  2768. } else {
  2769. $( this ).button( "widget" )
  2770. .removeClass( "ui-state-active" )
  2771. .attr( "aria-pressed", "false" );
  2772. }
  2773. });
  2774. } else if ( this.type === "checkbox" ) {
  2775. if ( this.element.is( ":checked" ) ) {
  2776. this.buttonElement
  2777. .addClass( "ui-state-active" )
  2778. .attr( "aria-pressed", "true" );
  2779. } else {
  2780. this.buttonElement
  2781. .removeClass( "ui-state-active" )
  2782. .attr( "aria-pressed", "false" );
  2783. }
  2784. }
  2785. },
  2786. _resetButton: function() {
  2787. if ( this.type === "input" ) {
  2788. if ( this.options.label ) {
  2789. this.element.val( this.options.label );
  2790. }
  2791. return;
  2792. }
  2793. var buttonElement = this.buttonElement.removeClass( typeClasses ),
  2794. buttonText = $( "<span></span>", this.document[0] )
  2795. .addClass( "ui-button-text" )
  2796. .html( this.options.label )
  2797. .appendTo( buttonElement.empty() )
  2798. .text(),
  2799. icons = this.options.icons,
  2800. multipleIcons = icons.primary && icons.secondary,
  2801. buttonClasses = [];
  2802. if ( icons.primary || icons.secondary ) {
  2803. if ( this.options.text ) {
  2804. buttonClasses.push( "ui-button-text-icon" + ( multipleIcons ? "s" : ( icons.primary ? "-primary" : "-secondary" ) ) );
  2805. }
  2806. if ( icons.primary ) {
  2807. buttonElement.prepend( "<span class='ui-button-icon-primary ui-icon " + icons.primary + "'></span>" );
  2808. }
  2809. if ( icons.secondary ) {
  2810. buttonElement.append( "<span class='ui-button-icon-secondary ui-icon " + icons.secondary + "'></span>" );
  2811. }
  2812. if ( !this.options.text ) {
  2813. buttonClasses.push( multipleIcons ? "ui-button-icons-only" : "ui-button-icon-only" );
  2814. if ( !this.hasTitle ) {
  2815. buttonElement.attr( "title", $.trim( buttonText ) );
  2816. }
  2817. }
  2818. } else {
  2819. buttonClasses.push( "ui-button-text-only" );
  2820. }
  2821. buttonElement.addClass( buttonClasses.join( " " ) );
  2822. }
  2823. });
  2824. $.widget( "ui.buttonset", {
  2825. version: "1.9.2",
  2826. options: {
  2827. items: "button, input[type=button], input[type=submit], input[type=reset], input[type=checkbox], input[type=radio], a, :data(button)"
  2828. },
  2829. _create: function() {
  2830. this.element.addClass( "ui-buttonset" );
  2831. },
  2832. _init: function() {
  2833. this.refresh();
  2834. },
  2835. _setOption: function( key, value ) {
  2836. if ( key === "disabled" ) {
  2837. this.buttons.button( "option", key, value );
  2838. }
  2839. this._super( key, value );
  2840. },
  2841. refresh: function() {
  2842. var rtl = this.element.css( "direction" ) === "rtl";
  2843. this.buttons = this.element.find( this.options.items )
  2844. .filter( ":ui-button" )
  2845. .button( "refresh" )
  2846. .end()
  2847. .not( ":ui-button" )
  2848. .button()
  2849. .end()
  2850. .map(function() {
  2851. return $( this ).button( "widget" )[ 0 ];
  2852. })
  2853. .removeClass( "ui-corner-all ui-corner-left ui-corner-right" )
  2854. .filter( ":first" )
  2855. .addClass( rtl ? "ui-corner-right" : "ui-corner-left" )
  2856. .end()
  2857. .filter( ":last" )
  2858. .addClass( rtl ? "ui-corner-left" : "ui-corner-right" )
  2859. .end()
  2860. .end();
  2861. },
  2862. _destroy: function() {
  2863. this.element.removeClass( "ui-buttonset" );
  2864. this.buttons
  2865. .map(function() {
  2866. return $( this ).button( "widget" )[ 0 ];
  2867. })
  2868. .removeClass( "ui-corner-left ui-corner-right" )
  2869. .end()
  2870. .button( "destroy" );
  2871. }
  2872. });
  2873. }( jQuery ) );
  2874. (function( $, undefined ) {
  2875. $.extend($.ui, { datepicker: { version: "1.9.2" } });
  2876. var PROP_NAME = 'datepicker';
  2877. var dpuuid = new Date().getTime();
  2878. var instActive;
  2879. /* Date picker manager.
  2880. Use the singleton instance of this class, $.datepicker, to interact with the date picker.
  2881. Settings for (groups of) date pickers are maintained in an instance object,
  2882. allowing multiple different settings on the same page. */
  2883. function Datepicker() {
  2884. this.debug = false; // Change this to true to start debugging
  2885. this._curInst = null; // The current instance in use
  2886. this._keyEvent = false; // If the last event was a key event
  2887. this._disabledInputs = []; // List of date picker inputs that have been disabled
  2888. this._datepickerShowing = false; // True if the popup picker is showing , false if not
  2889. this._inDialog = false; // True if showing within a "dialog", false if not
  2890. this._mainDivId = 'ui-datepicker-div'; // The ID of the main datepicker division
  2891. this._inlineClass = 'ui-datepicker-inline'; // The name of the inline marker class
  2892. this._appendClass = 'ui-datepicker-append'; // The name of the append marker class
  2893. this._triggerClass = 'ui-datepicker-trigger'; // The name of the trigger marker class
  2894. this._dialogClass = 'ui-datepicker-dialog'; // The name of the dialog marker class
  2895. this._disableClass = 'ui-datepicker-disabled'; // The name of the disabled covering marker class
  2896. this._unselectableClass = 'ui-datepicker-unselectable'; // The name of the unselectable cell marker class
  2897. this._currentClass = 'ui-datepicker-current-day'; // The name of the current day marker class
  2898. this._dayOverClass = 'ui-datepicker-days-cell-over'; // The name of the day hover marker class
  2899. this.regional = []; // Available regional settings, indexed by language code
  2900. this.regional[''] = { // Default regional settings
  2901. closeText: 'Done', // Display text for close link
  2902. prevText: 'Prev', // Display text for previous month link
  2903. nextText: 'Next', // Display text for next month link
  2904. currentText: 'Today', // Display text for current month link
  2905. monthNames: ['January','February','March','April','May','June',
  2906. 'July','August','September','October','November','December'], // Names of months for drop-down and formatting
  2907. monthNamesShort: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'], // For formatting
  2908. dayNames: ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'], // For formatting
  2909. dayNamesShort: ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'], // For formatting
  2910. dayNamesMin: ['Su','Mo','Tu','We','Th','Fr','Sa'], // Column headings for days starting at Sunday
  2911. weekHeader: 'Wk', // Column header for week of the year
  2912. dateFormat: 'mm/dd/yy', // See format options on parseDate
  2913. firstDay: 0, // The first day of the week, Sun = 0, Mon = 1, ...
  2914. isRTL: false, // True if right-to-left language, false if left-to-right
  2915. showMonthAfterYear: false, // True if the year select precedes month, false for month then year
  2916. yearSuffix: '' // Additional text to append to the year in the month headers
  2917. };
  2918. this._defaults = { // Global defaults for all the date picker instances
  2919. showOn: 'focus', // 'focus' for popup on focus,
  2920. // 'button' for trigger button, or 'both' for either
  2921. showAnim: 'fadeIn', // Name of jQuery animation for popup
  2922. showOptions: {}, // Options for enhanced animations
  2923. defaultDate: null, // Used when field is blank: actual date,
  2924. // +/-number for offset from today, null for today
  2925. appendText: '', // Display text following the input box, e.g. showing the format
  2926. buttonText: '...', // Text for trigger button
  2927. buttonImage: '', // URL for trigger button image
  2928. buttonImageOnly: false, // True if the image appears alone, false if it appears on a button
  2929. hideIfNoPrevNext: false, // True to hide next/previous month links
  2930. // if not applicable, false to just disable them
  2931. navigationAsDateFormat: false, // True if date formatting applied to prev/today/next links
  2932. gotoCurrent: false, // True if today link goes back to current selection instead
  2933. changeMonth: false, // True if month can be selected directly, false if only prev/next
  2934. changeYear: false, // True if year can be selected directly, false if only prev/next
  2935. yearRange: 'c-10:c+10', // Range of years to display in drop-down,
  2936. // either relative to today's year (-nn:+nn), relative to currently displayed year
  2937. // (c-nn:c+nn), absolute (nnnn:nnnn), or a combination of the above (nnnn:-n)
  2938. showOtherMonths: false, // True to show dates in other months, false to leave blank
  2939. selectOtherMonths: false, // True to allow selection of dates in other months, false for unselectable
  2940. showWeek: false, // True to show week of the year, false to not show it
  2941. calculateWeek: this.iso8601Week, // How to calculate the week of the year,
  2942. // takes a Date and returns the number of the week for it
  2943. shortYearCutoff: '+10', // Short year values < this are in the current century,
  2944. // > this are in the previous century,
  2945. // string value starting with '+' for current year + value
  2946. minDate: null, // The earliest selectable date, or null for no limit
  2947. maxDate: null, // The latest selectable date, or null for no limit
  2948. duration: 'fast', // Duration of display/closure
  2949. beforeShowDay: null, // Function that takes a date and returns an array with
  2950. // [0] = true if selectable, false if not, [1] = custom CSS class name(s) or '',
  2951. // [2] = cell title (optional), e.g. $.datepicker.noWeekends
  2952. beforeShow: null, // Function that takes an input field and
  2953. // returns a set of custom settings for the date picker
  2954. onSelect: null, // Define a callback function when a date is selected
  2955. onChangeMonthYear: null, // Define a callback function when the month or year is changed
  2956. onClose: null, // Define a callback function when the datepicker is closed
  2957. numberOfMonths: 1, // Number of months to show at a time
  2958. showCurrentAtPos: 0, // The position in multipe months at which to show the current month (starting at 0)
  2959. stepMonths: 1, // Number of months to step back/forward
  2960. stepBigMonths: 12, // Number of months to step back/forward for the big links
  2961. altField: '', // Selector for an alternate field to store selected dates into
  2962. altFormat: '', // The date format to use for the alternate field
  2963. constrainInput: true, // The input is constrained by the current date format
  2964. showButtonPanel: false, // True to show button panel, false to not show it
  2965. autoSize: false, // True to size the input for the date format, false to leave as is
  2966. disabled: false // The initial disabled state
  2967. };
  2968. $.extend(this._defaults, this.regional['']);
  2969. this.dpDiv = bindHover($('<div id="' + this._mainDivId + '" class="ui-datepicker ui-widget ui-widget-content ui-helper-clearfix ui-corner-all"></div>'));
  2970. }
  2971. $.extend(Datepicker.prototype, {
  2972. /* Class name added to elements to indicate already configured with a date picker. */
  2973. markerClassName: 'hasDatepicker',
  2974. //Keep track of the maximum number of rows displayed (see #7043)
  2975. maxRows: 4,
  2976. /* Debug logging (if enabled). */
  2977. log: function () {
  2978. if (this.debug)
  2979. console.log.apply('', arguments);
  2980. },
  2981. // TODO rename to "widget" when switching to widget factory
  2982. _widgetDatepicker: function() {
  2983. return this.dpDiv;
  2984. },
  2985. /* Override the default settings for all instances of the date picker.
  2986. @param settings object - the new settings to use as defaults (anonymous object)
  2987. @return the manager object */
  2988. setDefaults: function(settings) {
  2989. extendRemove(this._defaults, settings || {});
  2990. return this;
  2991. },
  2992. /* Attach the date picker to a jQuery selection.
  2993. @param target element - the target input field or division or span
  2994. @param settings object - the new settings to use for this date picker instance (anonymous) */
  2995. _attachDatepicker: function(target, settings) {
  2996. // check for settings on the control itself - in namespace 'date:'
  2997. var inlineSettings = null;
  2998. for (var attrName in this._defaults) {
  2999. var attrValue = target.getAttribute('date:' + attrName);
  3000. if (attrValue) {
  3001. inlineSettings = inlineSettings || {};
  3002. try {
  3003. inlineSettings[attrName] = eval(attrValue);
  3004. } catch (err) {
  3005. inlineSettings[attrName] = attrValue;
  3006. }
  3007. }
  3008. }
  3009. var nodeName = target.nodeName.toLowerCase();
  3010. var inline = (nodeName == 'div' || nodeName == 'span');
  3011. if (!target.id) {
  3012. this.uuid += 1;
  3013. target.id = 'dp' + this.uuid;
  3014. }
  3015. var inst = this._newInst($(target), inline);
  3016. inst.settings = $.extend({}, settings || {}, inlineSettings || {});
  3017. if (nodeName == 'input') {
  3018. this._connectDatepicker(target, inst);
  3019. } else if (inline) {
  3020. this._inlineDatepicker(target, inst);
  3021. }
  3022. },
  3023. /* Create a new instance object. */
  3024. _newInst: function(target, inline) {
  3025. var id = target[0].id.replace(/([^A-Za-z0-9_-])/g, '\\\\$1'); // escape jQuery meta chars
  3026. return {id: id, input: target, // associated target
  3027. selectedDay: 0, selectedMonth: 0, selectedYear: 0, // current selection
  3028. drawMonth: 0, drawYear: 0, // month being drawn
  3029. inline: inline, // is datepicker inline or not
  3030. dpDiv: (!inline ? this.dpDiv : // presentation div
  3031. bindHover($('<div class="' + this._inlineClass + ' ui-datepicker ui-widget ui-widget-content ui-helper-clearfix ui-corner-all"></div>')))};
  3032. },
  3033. /* Attach the date picker to an input field. */
  3034. _connectDatepicker: function(target, inst) {
  3035. var input = $(target);
  3036. inst.append = $([]);
  3037. inst.trigger = $([]);
  3038. if (input.hasClass(this.markerClassName))
  3039. return;
  3040. this._attachments(input, inst);
  3041. input.addClass(this.markerClassName).keydown(this._doKeyDown).
  3042. keypress(this._doKeyPress).keyup(this._doKeyUp).
  3043. bind("setData.datepicker", function(event, key, value) {
  3044. inst.settings[key] = value;
  3045. }).bind("getData.datepicker", function(event, key) {
  3046. return this._get(inst, key);
  3047. });
  3048. this._autoSize(inst);
  3049. $.data(target, PROP_NAME, inst);
  3050. //If disabled option is true, disable the datepicker once it has been attached to the input (see ticket #5665)
  3051. if( inst.settings.disabled ) {
  3052. this._disableDatepicker( target );
  3053. }
  3054. },
  3055. /* Make attachments based on settings. */
  3056. _attachments: function(input, inst) {
  3057. var appendText = this._get(inst, 'appendText');
  3058. var isRTL = this._get(inst, 'isRTL');
  3059. if (inst.append)
  3060. inst.append.remove();
  3061. if (appendText) {
  3062. inst.append = $('<span class="' + this._appendClass + '">' + appendText + '</span>');
  3063. input[isRTL ? 'before' : 'after'](inst.append);
  3064. }
  3065. input.unbind('focus', this._showDatepicker);
  3066. if (inst.trigger)
  3067. inst.trigger.remove();
  3068. var showOn = this._get(inst, 'showOn');
  3069. if (showOn == 'focus' || showOn == 'both') // pop-up date picker when in the marked field
  3070. input.focus(this._showDatepicker);
  3071. if (showOn == 'button' || showOn == 'both') { // pop-up date picker when button clicked
  3072. var buttonText = this._get(inst, 'buttonText');
  3073. var buttonImage = this._get(inst, 'buttonImage');
  3074. inst.trigger = $(this._get(inst, 'buttonImageOnly') ?
  3075. $('<img/>').addClass(this._triggerClass).
  3076. attr({ src: buttonImage, alt: buttonText, title: buttonText }) :
  3077. $('<button type="button"></button>').addClass(this._triggerClass).
  3078. html(buttonImage == '' ? buttonText : $('<img/>').attr(
  3079. { src:buttonImage, alt:buttonText, title:buttonText })));
  3080. input[isRTL ? 'before' : 'after'](inst.trigger);
  3081. inst.trigger.click(function() {
  3082. if ($.datepicker._datepickerShowing && $.datepicker._lastInput == input[0])
  3083. $.datepicker._hideDatepicker();
  3084. else if ($.datepicker._datepickerShowing && $.datepicker._lastInput != input[0]) {
  3085. $.datepicker._hideDatepicker();
  3086. $.datepicker._showDatepicker(input[0]);
  3087. } else
  3088. $.datepicker._showDatepicker(input[0]);
  3089. return false;
  3090. });
  3091. }
  3092. },
  3093. /* Apply the maximum length for the date format. */
  3094. _autoSize: function(inst) {
  3095. if (this._get(inst, 'autoSize') && !inst.inline) {
  3096. var date = new Date(2009, 12 - 1, 20); // Ensure double digits
  3097. var dateFormat = this._get(inst, 'dateFormat');
  3098. if (dateFormat.match(/[DM]/)) {
  3099. var findMax = function(names) {
  3100. var max = 0;
  3101. var maxI = 0;
  3102. for (var i = 0; i < names.length; i++) {
  3103. if (names[i].length > max) {
  3104. max = names[i].length;
  3105. maxI = i;
  3106. }
  3107. }
  3108. return maxI;
  3109. };
  3110. date.setMonth(findMax(this._get(inst, (dateFormat.match(/MM/) ?
  3111. 'monthNames' : 'monthNamesShort'))));
  3112. date.setDate(findMax(this._get(inst, (dateFormat.match(/DD/) ?
  3113. 'dayNames' : 'dayNamesShort'))) + 20 - date.getDay());
  3114. }
  3115. inst.input.attr('size', this._formatDate(inst, date).length);
  3116. }
  3117. },
  3118. /* Attach an inline date picker to a div. */
  3119. _inlineDatepicker: function(target, inst) {
  3120. var divSpan = $(target);
  3121. if (divSpan.hasClass(this.markerClassName))
  3122. return;
  3123. divSpan.addClass(this.markerClassName).append(inst.dpDiv).
  3124. bind("setData.datepicker", function(event, key, value){
  3125. inst.settings[key] = value;
  3126. }).bind("getData.datepicker", function(event, key){
  3127. return this._get(inst, key);
  3128. });
  3129. $.data(target, PROP_NAME, inst);
  3130. this._setDate(inst, this._getDefaultDate(inst), true);
  3131. this._updateDatepicker(inst);
  3132. this._updateAlternate(inst);
  3133. //If disabled option is true, disable the datepicker before showing it (see ticket #5665)
  3134. if( inst.settings.disabled ) {
  3135. this._disableDatepicker( target );
  3136. }
  3137. // Set display:block in place of inst.dpDiv.show() which won't work on disconnected elements
  3138. // http://bugs.jqueryui.com/ticket/7552 - A Datepicker created on a detached div has zero height
  3139. inst.dpDiv.css( "display", "block" );
  3140. },
  3141. /* Pop-up the date picker in a "dialog" box.
  3142. @param input element - ignored
  3143. @param date string or Date - the initial date to display
  3144. @param onSelect function - the function to call when a date is selected
  3145. @param settings object - update the dialog date picker instance's settings (anonymous object)
  3146. @param pos int[2] - coordinates for the dialog's position within the screen or
  3147. event - with x/y coordinates or
  3148. leave empty for default (screen centre)
  3149. @return the manager object */
  3150. _dialogDatepicker: function(input, date, onSelect, settings, pos) {
  3151. var inst = this._dialogInst; // internal instance
  3152. if (!inst) {
  3153. this.uuid += 1;
  3154. var id = 'dp' + this.uuid;
  3155. this._dialogInput = $('<input type="text" id="' + id +
  3156. '" style="position: absolute; top: -100px; width: 0px;"/>');
  3157. this._dialogInput.keydown(this._doKeyDown);
  3158. $('body').append(this._dialogInput);
  3159. inst = this._dialogInst = this._newInst(this._dialogInput, false);
  3160. inst.settings = {};
  3161. $.data(this._dialogInput[0], PROP_NAME, inst);
  3162. }
  3163. extendRemove(inst.settings, settings || {});
  3164. date = (date && date.constructor == Date ? this._formatDate(inst, date) : date);
  3165. this._dialogInput.val(date);
  3166. this._pos = (pos ? (pos.length ? pos : [pos.pageX, pos.pageY]) : null);
  3167. if (!this._pos) {
  3168. var browserWidth = document.documentElement.clientWidth;
  3169. var browserHeight = document.documentElement.clientHeight;
  3170. var scrollX = document.documentElement.scrollLeft || document.body.scrollLeft;
  3171. var scrollY = document.documentElement.scrollTop || document.body.scrollTop;
  3172. this._pos = // should use actual width/height below
  3173. [(browserWidth / 2) - 100 + scrollX, (browserHeight / 2) - 150 + scrollY];
  3174. }
  3175. // move input on screen for focus, but hidden behind dialog
  3176. this._dialogInput.css('left', (this._pos[0] + 20) + 'px').css('top', this._pos[1] + 'px');
  3177. inst.settings.onSelect = onSelect;
  3178. this._inDialog = true;
  3179. this.dpDiv.addClass(this._dialogClass);
  3180. this._showDatepicker(this._dialogInput[0]);
  3181. if ($.blockUI)
  3182. $.blockUI(this.dpDiv);
  3183. $.data(this._dialogInput[0], PROP_NAME, inst);
  3184. return this;
  3185. },
  3186. /* Detach a datepicker from its control.
  3187. @param target element - the target input field or division or span */
  3188. _destroyDatepicker: function(target) {
  3189. var $target = $(target);
  3190. var inst = $.data(target, PROP_NAME);
  3191. if (!$target.hasClass(this.markerClassName)) {
  3192. return;
  3193. }
  3194. var nodeName = target.nodeName.toLowerCase();
  3195. $.removeData(target, PROP_NAME);
  3196. if (nodeName == 'input') {
  3197. inst.append.remove();
  3198. inst.trigger.remove();
  3199. $target.removeClass(this.markerClassName).
  3200. unbind('focus', this._showDatepicker).
  3201. unbind('keydown', this._doKeyDown).
  3202. unbind('keypress', this._doKeyPress).
  3203. unbind('keyup', this._doKeyUp);
  3204. } else if (nodeName == 'div' || nodeName == 'span')
  3205. $target.removeClass(this.markerClassName).empty();
  3206. },
  3207. /* Enable the date picker to a jQuery selection.
  3208. @param target element - the target input field or division or span */
  3209. _enableDatepicker: function(target) {
  3210. var $target = $(target);
  3211. var inst = $.data(target, PROP_NAME);
  3212. if (!$target.hasClass(this.markerClassName)) {
  3213. return;
  3214. }
  3215. var nodeName = target.nodeName.toLowerCase();
  3216. if (nodeName == 'input') {
  3217. target.disabled = false;
  3218. inst.trigger.filter('button').
  3219. each(function() { this.disabled = false; }).end().
  3220. filter('img').css({opacity: '1.0', cursor: ''});
  3221. }
  3222. else if (nodeName == 'div' || nodeName == 'span') {
  3223. var inline = $target.children('.' + this._inlineClass);
  3224. inline.children().removeClass('ui-state-disabled');
  3225. inline.find("select.ui-datepicker-month, select.ui-datepicker-year").
  3226. prop("disabled", false);
  3227. }
  3228. this._disabledInputs = $.map(this._disabledInputs,
  3229. function(value) { return (value == target ? null : value); }); // delete entry
  3230. },
  3231. /* Disable the date picker to a jQuery selection.
  3232. @param target element - the target input field or division or span */
  3233. _disableDatepicker: function(target) {
  3234. var $target = $(target);
  3235. var inst = $.data(target, PROP_NAME);
  3236. if (!$target.hasClass(this.markerClassName)) {
  3237. return;
  3238. }
  3239. var nodeName = target.nodeName.toLowerCase();
  3240. if (nodeName == 'input') {
  3241. target.disabled = true;
  3242. inst.trigger.filter('button').
  3243. each(function() { this.disabled = true; }).end().
  3244. filter('img').css({opacity: '0.5', cursor: 'default'});
  3245. }
  3246. else if (nodeName == 'div' || nodeName == 'span') {
  3247. var inline = $target.children('.' + this._inlineClass);
  3248. inline.children().addClass('ui-state-disabled');
  3249. inline.find("select.ui-datepicker-month, select.ui-datepicker-year").
  3250. prop("disabled", true);
  3251. }
  3252. this._disabledInputs = $.map(this._disabledInputs,
  3253. function(value) { return (value == target ? null : value); }); // delete entry
  3254. this._disabledInputs[this._disabledInputs.length] = target;
  3255. },
  3256. /* Is the first field in a jQuery collection disabled as a datepicker?
  3257. @param target element - the target input field or division or span
  3258. @return boolean - true if disabled, false if enabled */
  3259. _isDisabledDatepicker: function(target) {
  3260. if (!target) {
  3261. return false;
  3262. }
  3263. for (var i = 0; i < this._disabledInputs.length; i++) {
  3264. if (this._disabledInputs[i] == target)
  3265. return true;
  3266. }
  3267. return false;
  3268. },
  3269. /* Retrieve the instance data for the target control.
  3270. @param target element - the target input field or division or span
  3271. @return object - the associated instance data
  3272. @throws error if a jQuery problem getting data */
  3273. _getInst: function(target) {
  3274. try {
  3275. return $.data(target, PROP_NAME);
  3276. }
  3277. catch (err) {
  3278. throw 'Missing instance data for this datepicker';
  3279. }
  3280. },
  3281. /* Update or retrieve the settings for a date picker attached to an input field or division.
  3282. @param target element - the target input field or division or span
  3283. @param name object - the new settings to update or
  3284. string - the name of the setting to change or retrieve,
  3285. when retrieving also 'all' for all instance settings or
  3286. 'defaults' for all global defaults
  3287. @param value any - the new value for the setting
  3288. (omit if above is an object or to retrieve a value) */
  3289. _optionDatepicker: function(target, name, value) {
  3290. var inst = this._getInst(target);
  3291. if (arguments.length == 2 && typeof name == 'string') {
  3292. return (name == 'defaults' ? $.extend({}, $.datepicker._defaults) :
  3293. (inst ? (name == 'all' ? $.extend({}, inst.settings) :
  3294. this._get(inst, name)) : null));
  3295. }
  3296. var settings = name || {};
  3297. if (typeof name == 'string') {
  3298. settings = {};
  3299. settings[name] = value;
  3300. }
  3301. if (inst) {
  3302. if (this._curInst == inst) {
  3303. this._hideDatepicker();
  3304. }
  3305. var date = this._getDateDatepicker(target, true);
  3306. var minDate = this._getMinMaxDate(inst, 'min');
  3307. var maxDate = this._getMinMaxDate(inst, 'max');
  3308. extendRemove(inst.settings, settings);
  3309. // reformat the old minDate/maxDate values if dateFormat changes and a new minDate/maxDate isn't provided
  3310. if (minDate !== null && settings['dateFormat'] !== undefined && settings['minDate'] === undefined)
  3311. inst.settings.minDate = this._formatDate(inst, minDate);
  3312. if (maxDate !== null && settings['dateFormat'] !== undefined && settings['maxDate'] === undefined)
  3313. inst.settings.maxDate = this._formatDate(inst, maxDate);
  3314. this._attachments($(target), inst);
  3315. this._autoSize(inst);
  3316. this._setDate(inst, date);
  3317. this._updateAlternate(inst);
  3318. this._updateDatepicker(inst);
  3319. }
  3320. },
  3321. // change method deprecated
  3322. _changeDatepicker: function(target, name, value) {
  3323. this._optionDatepicker(target, name, value);
  3324. },
  3325. /* Redraw the date picker attached to an input field or division.
  3326. @param target element - the target input field or division or span */
  3327. _refreshDatepicker: function(target) {
  3328. var inst = this._getInst(target);
  3329. if (inst) {
  3330. this._updateDatepicker(inst);
  3331. }
  3332. },
  3333. /* Set the dates for a jQuery selection.
  3334. @param target element - the target input field or division or span
  3335. @param date Date - the new date */
  3336. _setDateDatepicker: function(target, date) {
  3337. var inst = this._getInst(target);
  3338. if (inst) {
  3339. this._setDate(inst, date);
  3340. this._updateDatepicker(inst);
  3341. this._updateAlternate(inst);
  3342. }
  3343. },
  3344. /* Get the date(s) for the first entry in a jQuery selection.
  3345. @param target element - the target input field or division or span
  3346. @param noDefault boolean - true if no default date is to be used
  3347. @return Date - the current date */
  3348. _getDateDatepicker: function(target, noDefault) {
  3349. var inst = this._getInst(target);
  3350. if (inst && !inst.inline)
  3351. this._setDateFromField(inst, noDefault);
  3352. return (inst ? this._getDate(inst) : null);
  3353. },
  3354. /* Handle keystrokes. */
  3355. _doKeyDown: function(event) {
  3356. var inst = $.datepicker._getInst(event.target);
  3357. var handled = true;
  3358. var isRTL = inst.dpDiv.is('.ui-datepicker-rtl');
  3359. inst._keyEvent = true;
  3360. if ($.datepicker._datepickerShowing)
  3361. switch (event.keyCode) {
  3362. case 9: $.datepicker._hideDatepicker();
  3363. handled = false;
  3364. break; // hide on tab out
  3365. case 13: var sel = $('td.' + $.datepicker._dayOverClass + ':not(.' +
  3366. $.datepicker._currentClass + ')', inst.dpDiv);
  3367. if (sel[0])
  3368. $.datepicker._selectDay(event.target, inst.selectedMonth, inst.selectedYear, sel[0]);
  3369. var onSelect = $.datepicker._get(inst, 'onSelect');
  3370. if (onSelect) {
  3371. var dateStr = $.datepicker._formatDate(inst);
  3372. // trigger custom callback
  3373. onSelect.apply((inst.input ? inst.input[0] : null), [dateStr, inst]);
  3374. }
  3375. else
  3376. $.datepicker._hideDatepicker();
  3377. return false; // don't submit the form
  3378. break; // select the value on enter
  3379. case 27: $.datepicker._hideDatepicker();
  3380. break; // hide on escape
  3381. case 33: $.datepicker._adjustDate(event.target, (event.ctrlKey ?
  3382. -$.datepicker._get(inst, 'stepBigMonths') :
  3383. -$.datepicker._get(inst, 'stepMonths')), 'M');
  3384. break; // previous month/year on page up/+ ctrl
  3385. case 34: $.datepicker._adjustDate(event.target, (event.ctrlKey ?
  3386. +$.datepicker._get(inst, 'stepBigMonths') :
  3387. +$.datepicker._get(inst, 'stepMonths')), 'M');
  3388. break; // next month/year on page down/+ ctrl
  3389. case 35: if (event.ctrlKey || event.metaKey) $.datepicker._clearDate(event.target);
  3390. handled = event.ctrlKey || event.metaKey;
  3391. break; // clear on ctrl or command +end
  3392. case 36: if (event.ctrlKey || event.metaKey) $.datepicker._gotoToday(event.target);
  3393. handled = event.ctrlKey || event.metaKey;
  3394. break; // current on ctrl or command +home
  3395. case 37: if (event.ctrlKey || event.metaKey) $.datepicker._adjustDate(event.target, (isRTL ? +1 : -1), 'D');
  3396. handled = event.ctrlKey || event.metaKey;
  3397. // -1 day on ctrl or command +left
  3398. if (event.originalEvent.altKey) $.datepicker._adjustDate(event.target, (event.ctrlKey ?
  3399. -$.datepicker._get(inst, 'stepBigMonths') :
  3400. -$.datepicker._get(inst, 'stepMonths')), 'M');
  3401. // next month/year on alt +left on Mac
  3402. break;
  3403. case 38: if (event.ctrlKey || event.metaKey) $.datepicker._adjustDate(event.target, -7, 'D');
  3404. handled = event.ctrlKey || event.metaKey;
  3405. break; // -1 week on ctrl or command +up
  3406. case 39: if (event.ctrlKey || event.metaKey) $.datepicker._adjustDate(event.target, (isRTL ? -1 : +1), 'D');
  3407. handled = event.ctrlKey || event.metaKey;
  3408. // +1 day on ctrl or command +right
  3409. if (event.originalEvent.altKey) $.datepicker._adjustDate(event.target, (event.ctrlKey ?
  3410. +$.datepicker._get(inst, 'stepBigMonths') :
  3411. +$.datepicker._get(inst, 'stepMonths')), 'M');
  3412. // next month/year on alt +right
  3413. break;
  3414. case 40: if (event.ctrlKey || event.metaKey) $.datepicker._adjustDate(event.target, +7, 'D');
  3415. handled = event.ctrlKey || event.metaKey;
  3416. break; // +1 week on ctrl or command +down
  3417. default: handled = false;
  3418. }
  3419. else if (event.keyCode == 36 && event.ctrlKey) // display the date picker on ctrl+home
  3420. $.datepicker._showDatepicker(this);
  3421. else {
  3422. handled = false;
  3423. }
  3424. if (handled) {
  3425. event.preventDefault();
  3426. event.stopPropagation();
  3427. }
  3428. },
  3429. /* Filter entered characters - based on date format. */
  3430. _doKeyPress: function(event) {
  3431. var inst = $.datepicker._getInst(event.target);
  3432. if ($.datepicker._get(inst, 'constrainInput')) {
  3433. var chars = $.datepicker._possibleChars($.datepicker._get(inst, 'dateFormat'));
  3434. var chr = String.fromCharCode(event.charCode == undefined ? event.keyCode : event.charCode);
  3435. return event.ctrlKey || event.metaKey || (chr < ' ' || !chars || chars.indexOf(chr) > -1);
  3436. }
  3437. },
  3438. /* Synchronise manual entry and field/alternate field. */
  3439. _doKeyUp: function(event) {
  3440. var inst = $.datepicker._getInst(event.target);
  3441. if (inst.input.val() != inst.lastVal) {
  3442. try {
  3443. var date = $.datepicker.parseDate($.datepicker._get(inst, 'dateFormat'),
  3444. (inst.input ? inst.input.val() : null),
  3445. $.datepicker._getFormatConfig(inst));
  3446. if (date) { // only if valid
  3447. $.datepicker._setDateFromField(inst);
  3448. $.datepicker._updateAlternate(inst);
  3449. $.datepicker._updateDatepicker(inst);
  3450. }
  3451. }
  3452. catch (err) {
  3453. $.datepicker.log(err);
  3454. }
  3455. }
  3456. return true;
  3457. },
  3458. /* Pop-up the date picker for a given input field.
  3459. If false returned from beforeShow event handler do not show.
  3460. @param input element - the input field attached to the date picker or
  3461. event - if triggered by focus */
  3462. _showDatepicker: function(input) {
  3463. input = input.target || input;
  3464. if (input.nodeName.toLowerCase() != 'input') // find from button/image trigger
  3465. input = $('input', input.parentNode)[0];
  3466. if ($.datepicker._isDisabledDatepicker(input) || $.datepicker._lastInput == input) // already here
  3467. return;
  3468. var inst = $.datepicker._getInst(input);
  3469. if ($.datepicker._curInst && $.datepicker._curInst != inst) {
  3470. $.datepicker._curInst.dpDiv.stop(true, true);
  3471. if ( inst && $.datepicker._datepickerShowing ) {
  3472. $.datepicker._hideDatepicker( $.datepicker._curInst.input[0] );
  3473. }
  3474. }
  3475. var beforeShow = $.datepicker._get(inst, 'beforeShow');
  3476. var beforeShowSettings = beforeShow ? beforeShow.apply(input, [input, inst]) : {};
  3477. if(beforeShowSettings === false){
  3478. //false
  3479. return;
  3480. }
  3481. extendRemove(inst.settings, beforeShowSettings);
  3482. inst.lastVal = null;
  3483. $.datepicker._lastInput = input;
  3484. $.datepicker._setDateFromField(inst);
  3485. if ($.datepicker._inDialog) // hide cursor
  3486. input.value = '';
  3487. if (!$.datepicker._pos) { // position below input
  3488. $.datepicker._pos = $.datepicker._findPos(input);
  3489. $.datepicker._pos[1] += input.offsetHeight; // add the height
  3490. }
  3491. var isFixed = false;
  3492. $(input).parents().each(function() {
  3493. isFixed |= $(this).css('position') == 'fixed';
  3494. return !isFixed;
  3495. });
  3496. var offset = {left: $.datepicker._pos[0], top: $.datepicker._pos[1]};
  3497. $.datepicker._pos = null;
  3498. //to avoid flashes on Firefox
  3499. inst.dpDiv.empty();
  3500. // determine sizing offscreen
  3501. inst.dpDiv.css({position: 'absolute', display: 'block', top: '-1000px'});
  3502. $.datepicker._updateDatepicker(inst);
  3503. // fix width for dynamic number of date pickers
  3504. // and adjust position before showing
  3505. offset = $.datepicker._checkOffset(inst, offset, isFixed);
  3506. inst.dpDiv.css({position: ($.datepicker._inDialog && $.blockUI ?
  3507. 'static' : (isFixed ? 'fixed' : 'absolute')), display: 'none',
  3508. left: offset.left + 'px', top: offset.top + 'px'});
  3509. if (!inst.inline) {
  3510. var showAnim = $.datepicker._get(inst, 'showAnim');
  3511. var duration = $.datepicker._get(inst, 'duration');
  3512. var postProcess = function() {
  3513. var cover = inst.dpDiv.find('iframe.ui-datepicker-cover'); // IE6- only
  3514. if( !! cover.length ){
  3515. var borders = $.datepicker._getBorders(inst.dpDiv);
  3516. cover.css({left: -borders[0], top: -borders[1],
  3517. width: inst.dpDiv.outerWidth(), height: inst.dpDiv.outerHeight()});
  3518. }
  3519. };
  3520. inst.dpDiv.zIndex($(input).zIndex()+1);
  3521. $.datepicker._datepickerShowing = true;
  3522. // DEPRECATED: after BC for 1.8.x $.effects[ showAnim ] is not needed
  3523. if ( $.effects && ( $.effects.effect[ showAnim ] || $.effects[ showAnim ] ) )
  3524. inst.dpDiv.show(showAnim, $.datepicker._get(inst, 'showOptions'), duration, postProcess);
  3525. else
  3526. inst.dpDiv[showAnim || 'show']((showAnim ? duration : null), postProcess);
  3527. if (!showAnim || !duration)
  3528. postProcess();
  3529. if (inst.input.is(':visible') && !inst.input.is(':disabled'))
  3530. inst.input.focus();
  3531. $.datepicker._curInst = inst;
  3532. }
  3533. },
  3534. /* Generate the date picker content. */
  3535. _updateDatepicker: function(inst) {
  3536. this.maxRows = 4; //Reset the max number of rows being displayed (see #7043)
  3537. var borders = $.datepicker._getBorders(inst.dpDiv);
  3538. instActive = inst; // for delegate hover events
  3539. inst.dpDiv.empty().append(this._generateHTML(inst));
  3540. this._attachHandlers(inst);
  3541. var cover = inst.dpDiv.find('iframe.ui-datepicker-cover'); // IE6- only
  3542. if( !!cover.length ){ //avoid call to outerXXXX() when not in IE6
  3543. cover.css({left: -borders[0], top: -borders[1], width: inst.dpDiv.outerWidth(), height: inst.dpDiv.outerHeight()})
  3544. }
  3545. inst.dpDiv.find('.' + this._dayOverClass + ' a').mouseover();
  3546. var numMonths = this._getNumberOfMonths(inst);
  3547. var cols = numMonths[1];
  3548. var width = 17;
  3549. inst.dpDiv.removeClass('ui-datepicker-multi-2 ui-datepicker-multi-3 ui-datepicker-multi-4').width('');
  3550. if (cols > 1)
  3551. inst.dpDiv.addClass('ui-datepicker-multi-' + cols).css('width', (width * cols) + 'em');
  3552. inst.dpDiv[(numMonths[0] != 1 || numMonths[1] != 1 ? 'add' : 'remove') +
  3553. 'Class']('ui-datepicker-multi');
  3554. inst.dpDiv[(this._get(inst, 'isRTL') ? 'add' : 'remove') +
  3555. 'Class']('ui-datepicker-rtl');
  3556. if (inst == $.datepicker._curInst && $.datepicker._datepickerShowing && inst.input &&
  3557. // #6694 - don't focus the input if it's already focused
  3558. // this breaks the change event in IE
  3559. inst.input.is(':visible') && !inst.input.is(':disabled') && inst.input[0] != document.activeElement)
  3560. inst.input.focus();
  3561. // deffered render of the years select (to avoid flashes on Firefox)
  3562. if( inst.yearshtml ){
  3563. var origyearshtml = inst.yearshtml;
  3564. setTimeout(function(){
  3565. //assure that inst.yearshtml didn't change.
  3566. if( origyearshtml === inst.yearshtml && inst.yearshtml ){
  3567. inst.dpDiv.find('select.ui-datepicker-year:first').replaceWith(inst.yearshtml);
  3568. }
  3569. origyearshtml = inst.yearshtml = null;
  3570. }, 0);
  3571. }
  3572. },
  3573. /* Retrieve the size of left and top borders for an element.
  3574. @param elem (jQuery object) the element of interest
  3575. @return (number[2]) the left and top borders */
  3576. _getBorders: function(elem) {
  3577. var convert = function(value) {
  3578. return {thin: 1, medium: 2, thick: 3}[value] || value;
  3579. };
  3580. return [parseFloat(convert(elem.css('border-left-width'))),
  3581. parseFloat(convert(elem.css('border-top-width')))];
  3582. },
  3583. /* Check positioning to remain on screen. */
  3584. _checkOffset: function(inst, offset, isFixed) {
  3585. var dpWidth = inst.dpDiv.outerWidth();
  3586. var dpHeight = inst.dpDiv.outerHeight();
  3587. var inputWidth = inst.input ? inst.input.outerWidth() : 0;
  3588. var inputHeight = inst.input ? inst.input.outerHeight() : 0;
  3589. var viewWidth = document.documentElement.clientWidth + (isFixed ? 0 : $(document).scrollLeft());
  3590. var viewHeight = document.documentElement.clientHeight + (isFixed ? 0 : $(document).scrollTop());
  3591. offset.left -= (this._get(inst, 'isRTL') ? (dpWidth - inputWidth) : 0);
  3592. offset.left -= (isFixed && offset.left == inst.input.offset().left) ? $(document).scrollLeft() : 0;
  3593. offset.top -= (isFixed && offset.top == (inst.input.offset().top + inputHeight)) ? $(document).scrollTop() : 0;
  3594. // now check if datepicker is showing outside window viewport - move to a better place if so.
  3595. offset.left -= Math.min(offset.left, (offset.left + dpWidth > viewWidth && viewWidth > dpWidth) ?
  3596. Math.abs(offset.left + dpWidth - viewWidth) : 0);
  3597. offset.top -= Math.min(offset.top, (offset.top + dpHeight > viewHeight && viewHeight > dpHeight) ?
  3598. Math.abs(dpHeight + inputHeight) : 0);
  3599. return offset;
  3600. },
  3601. /* Find an object's position on the screen. */
  3602. _findPos: function(obj) {
  3603. var inst = this._getInst(obj);
  3604. var isRTL = this._get(inst, 'isRTL');
  3605. while (obj && (obj.type == 'hidden' || obj.nodeType != 1 || $.expr.filters.hidden(obj))) {
  3606. obj = obj[isRTL ? 'previousSibling' : 'nextSibling'];
  3607. }
  3608. var position = $(obj).offset();
  3609. return [position.left, position.top];
  3610. },
  3611. /* Hide the date picker from view.
  3612. @param input element - the input field attached to the date picker */
  3613. _hideDatepicker: function(input) {
  3614. var inst = this._curInst;
  3615. if (!inst || (input && inst != $.data(input, PROP_NAME)))
  3616. return;
  3617. if (this._datepickerShowing) {
  3618. var showAnim = this._get(inst, 'showAnim');
  3619. var duration = this._get(inst, 'duration');
  3620. var postProcess = function() {
  3621. $.datepicker._tidyDialog(inst);
  3622. };
  3623. // DEPRECATED: after BC for 1.8.x $.effects[ showAnim ] is not needed
  3624. if ( $.effects && ( $.effects.effect[ showAnim ] || $.effects[ showAnim ] ) )
  3625. inst.dpDiv.hide(showAnim, $.datepicker._get(inst, 'showOptions'), duration, postProcess);
  3626. else
  3627. inst.dpDiv[(showAnim == 'slideDown' ? 'slideUp' :
  3628. (showAnim == 'fadeIn' ? 'fadeOut' : 'hide'))]((showAnim ? duration : null), postProcess);
  3629. if (!showAnim)
  3630. postProcess();
  3631. this._datepickerShowing = false;
  3632. var onClose = this._get(inst, 'onClose');
  3633. if (onClose)
  3634. onClose.apply((inst.input ? inst.input[0] : null),
  3635. [(inst.input ? inst.input.val() : ''), inst]);
  3636. this._lastInput = null;
  3637. if (this._inDialog) {
  3638. this._dialogInput.css({ position: 'absolute', left: '0', top: '-100px' });
  3639. if ($.blockUI) {
  3640. $.unblockUI();
  3641. $('body').append(this.dpDiv);
  3642. }
  3643. }
  3644. this._inDialog = false;
  3645. }
  3646. },
  3647. /* Tidy up after a dialog display. */
  3648. _tidyDialog: function(inst) {
  3649. inst.dpDiv.removeClass(this._dialogClass).unbind('.ui-datepicker-calendar');
  3650. },
  3651. /* Close date picker if clicked elsewhere. */
  3652. _checkExternalClick: function(event) {
  3653. if (!$.datepicker._curInst)
  3654. return;
  3655. var $target = $(event.target),
  3656. inst = $.datepicker._getInst($target[0]);
  3657. if ( ( ( $target[0].id != $.datepicker._mainDivId &&
  3658. $target.parents('#' + $.datepicker._mainDivId).length == 0 &&
  3659. !$target.hasClass($.datepicker.markerClassName) &&
  3660. !$target.closest("." + $.datepicker._triggerClass).length &&
  3661. $.datepicker._datepickerShowing && !($.datepicker._inDialog && $.blockUI) ) ) ||
  3662. ( $target.hasClass($.datepicker.markerClassName) && $.datepicker._curInst != inst ) )
  3663. $.datepicker._hideDatepicker();
  3664. },
  3665. /* Adjust one of the date sub-fields. */
  3666. _adjustDate: function(id, offset, period) {
  3667. var target = $(id);
  3668. var inst = this._getInst(target[0]);
  3669. if (this._isDisabledDatepicker(target[0])) {
  3670. return;
  3671. }
  3672. this._adjustInstDate(inst, offset +
  3673. (period == 'M' ? this._get(inst, 'showCurrentAtPos') : 0), // undo positioning
  3674. period);
  3675. this._updateDatepicker(inst);
  3676. },
  3677. /* Action for current link. */
  3678. _gotoToday: function(id) {
  3679. var target = $(id);
  3680. var inst = this._getInst(target[0]);
  3681. if (this._get(inst, 'gotoCurrent') && inst.currentDay) {
  3682. inst.selectedDay = inst.currentDay;
  3683. inst.drawMonth = inst.selectedMonth = inst.currentMonth;
  3684. inst.drawYear = inst.selectedYear = inst.currentYear;
  3685. }
  3686. else {
  3687. var date = new Date();
  3688. inst.selectedDay = date.getDate();
  3689. inst.drawMonth = inst.selectedMonth = date.getMonth();
  3690. inst.drawYear = inst.selectedYear = date.getFullYear();
  3691. }
  3692. this._notifyChange(inst);
  3693. this._adjustDate(target);
  3694. },
  3695. /* Action for selecting a new month/year. */
  3696. _selectMonthYear: function(id, select, period) {
  3697. var target = $(id);
  3698. var inst = this._getInst(target[0]);
  3699. inst['selected' + (period == 'M' ? 'Month' : 'Year')] =
  3700. inst['draw' + (period == 'M' ? 'Month' : 'Year')] =
  3701. parseInt(select.options[select.selectedIndex].value,10);
  3702. this._notifyChange(inst);
  3703. this._adjustDate(target);
  3704. },
  3705. /* Action for selecting a day. */
  3706. _selectDay: function(id, month, year, td) {
  3707. var target = $(id);
  3708. if ($(td).hasClass(this._unselectableClass) || this._isDisabledDatepicker(target[0])) {
  3709. return;
  3710. }
  3711. var inst = this._getInst(target[0]);
  3712. inst.selectedDay = inst.currentDay = $('a', td).html();
  3713. inst.selectedMonth = inst.currentMonth = month;
  3714. inst.selectedYear = inst.currentYear = year;
  3715. this._selectDate(id, this._formatDate(inst,
  3716. inst.currentDay, inst.currentMonth, inst.currentYear));
  3717. },
  3718. /* Erase the input field and hide the date picker. */
  3719. _clearDate: function(id) {
  3720. var target = $(id);
  3721. var inst = this._getInst(target[0]);
  3722. this._selectDate(target, '');
  3723. },
  3724. /* Update the input field with the selected date. */
  3725. _selectDate: function(id, dateStr) {
  3726. var target = $(id);
  3727. var inst = this._getInst(target[0]);
  3728. dateStr = (dateStr != null ? dateStr : this._formatDate(inst));
  3729. if (inst.input)
  3730. inst.input.val(dateStr);
  3731. this._updateAlternate(inst);
  3732. var onSelect = this._get(inst, 'onSelect');
  3733. if (onSelect)
  3734. onSelect.apply((inst.input ? inst.input[0] : null), [dateStr, inst]); // trigger custom callback
  3735. else if (inst.input)
  3736. inst.input.trigger('change'); // fire the change event
  3737. if (inst.inline)
  3738. this._updateDatepicker(inst);
  3739. else {
  3740. this._hideDatepicker();
  3741. this._lastInput = inst.input[0];
  3742. if (typeof(inst.input[0]) != 'object')
  3743. inst.input.focus(); // restore focus
  3744. this._lastInput = null;
  3745. }
  3746. },
  3747. /* Update any alternate field to synchronise with the main field. */
  3748. _updateAlternate: function(inst) {
  3749. var altField = this._get(inst, 'altField');
  3750. if (altField) { // update alternate field too
  3751. var altFormat = this._get(inst, 'altFormat') || this._get(inst, 'dateFormat');
  3752. var date = this._getDate(inst);
  3753. var dateStr = this.formatDate(altFormat, date, this._getFormatConfig(inst));
  3754. $(altField).each(function() { $(this).val(dateStr); });
  3755. }
  3756. },
  3757. /* Set as beforeShowDay function to prevent selection of weekends.
  3758. @param date Date - the date to customise
  3759. @return [boolean, string] - is this date selectable?, what is its CSS class? */
  3760. noWeekends: function(date) {
  3761. var day = date.getDay();
  3762. return [(day > 0 && day < 6), ''];
  3763. },
  3764. /* Set as calculateWeek to determine the week of the year based on the ISO 8601 definition.
  3765. @param date Date - the date to get the week for
  3766. @return number - the number of the week within the year that contains this date */
  3767. iso8601Week: function(date) {
  3768. var checkDate = new Date(date.getTime());
  3769. // Find Thursday of this week starting on Monday
  3770. checkDate.setDate(checkDate.getDate() + 4 - (checkDate.getDay() || 7));
  3771. var time = checkDate.getTime();
  3772. checkDate.setMonth(0); // Compare with Jan 1
  3773. checkDate.setDate(1);
  3774. return Math.floor(Math.round((time - checkDate) / 86400000) / 7) + 1;
  3775. },
  3776. /* Parse a string value into a date object.
  3777. See formatDate below for the possible formats.
  3778. @param format string - the expected format of the date
  3779. @param value string - the date in the above format
  3780. @param settings Object - attributes include:
  3781. shortYearCutoff number - the cutoff year for determining the century (optional)
  3782. dayNamesShort string[7] - abbreviated names of the days from Sunday (optional)
  3783. dayNames string[7] - names of the days from Sunday (optional)
  3784. monthNamesShort string[12] - abbreviated names of the months (optional)
  3785. monthNames string[12] - names of the months (optional)
  3786. @return Date - the extracted date value or null if value is blank */
  3787. parseDate: function (format, value, settings) {
  3788. if (format == null || value == null)
  3789. throw 'Invalid arguments';
  3790. value = (typeof value == 'object' ? value.toString() : value + '');
  3791. if (value == '')
  3792. return null;
  3793. var shortYearCutoff = (settings ? settings.shortYearCutoff : null) || this._defaults.shortYearCutoff;
  3794. shortYearCutoff = (typeof shortYearCutoff != 'string' ? shortYearCutoff :
  3795. new Date().getFullYear() % 100 + parseInt(shortYearCutoff, 10));
  3796. var dayNamesShort = (settings ? settings.dayNamesShort : null) || this._defaults.dayNamesShort;
  3797. var dayNames = (settings ? settings.dayNames : null) || this._defaults.dayNames;
  3798. var monthNamesShort = (settings ? settings.monthNamesShort : null) || this._defaults.monthNamesShort;
  3799. var monthNames = (settings ? settings.monthNames : null) || this._defaults.monthNames;
  3800. var year = -1;
  3801. var month = -1;
  3802. var day = -1;
  3803. var doy = -1;
  3804. var literal = false;
  3805. // Check whether a format character is doubled
  3806. var lookAhead = function(match) {
  3807. var matches = (iFormat + 1 < format.length && format.charAt(iFormat + 1) == match);
  3808. if (matches)
  3809. iFormat++;
  3810. return matches;
  3811. };
  3812. // Extract a number from the string value
  3813. var getNumber = function(match) {
  3814. var isDoubled = lookAhead(match);
  3815. var size = (match == '@' ? 14 : (match == '!' ? 20 :
  3816. (match == 'y' && isDoubled ? 4 : (match == 'o' ? 3 : 2))));
  3817. var digits = new RegExp('^\\d{1,' + size + '}');
  3818. var num = value.substring(iValue).match(digits);
  3819. if (!num)
  3820. throw 'Missing number at position ' + iValue;
  3821. iValue += num[0].length;
  3822. return parseInt(num[0], 10);
  3823. };
  3824. // Extract a name from the string value and convert to an index
  3825. var getName = function(match, shortNames, longNames) {
  3826. var names = $.map(lookAhead(match) ? longNames : shortNames, function (v, k) {
  3827. return [ [k, v] ];
  3828. }).sort(function (a, b) {
  3829. return -(a[1].length - b[1].length);
  3830. });
  3831. var index = -1;
  3832. $.each(names, function (i, pair) {
  3833. var name = pair[1];
  3834. if (value.substr(iValue, name.length).toLowerCase() == name.toLowerCase()) {
  3835. index = pair[0];
  3836. iValue += name.length;
  3837. return false;
  3838. }
  3839. });
  3840. if (index != -1)
  3841. return index + 1;
  3842. else
  3843. throw 'Unknown name at position ' + iValue;
  3844. };
  3845. // Confirm that a literal character matches the string value
  3846. var checkLiteral = function() {
  3847. if (value.charAt(iValue) != format.charAt(iFormat))
  3848. throw 'Unexpected literal at position ' + iValue;
  3849. iValue++;
  3850. };
  3851. var iValue = 0;
  3852. for (var iFormat = 0; iFormat < format.length; iFormat++) {
  3853. if (literal)
  3854. if (format.charAt(iFormat) == "'" && !lookAhead("'"))
  3855. literal = false;
  3856. else
  3857. checkLiteral();
  3858. else
  3859. switch (format.charAt(iFormat)) {
  3860. case 'd':
  3861. day = getNumber('d');
  3862. break;
  3863. case 'D':
  3864. getName('D', dayNamesShort, dayNames);
  3865. break;
  3866. case 'o':
  3867. doy = getNumber('o');
  3868. break;
  3869. case 'm':
  3870. month = getNumber('m');
  3871. break;
  3872. case 'M':
  3873. month = getName('M', monthNamesShort, monthNames);
  3874. break;
  3875. case 'y':
  3876. year = getNumber('y');
  3877. break;
  3878. case '@':
  3879. var date = new Date(getNumber('@'));
  3880. year = date.getFullYear();
  3881. month = date.getMonth() + 1;
  3882. day = date.getDate();
  3883. break;
  3884. case '!':
  3885. var date = new Date((getNumber('!') - this._ticksTo1970) / 10000);
  3886. year = date.getFullYear();
  3887. month = date.getMonth() + 1;
  3888. day = date.getDate();
  3889. break;
  3890. case "'":
  3891. if (lookAhead("'"))
  3892. checkLiteral();
  3893. else
  3894. literal = true;
  3895. break;
  3896. default:
  3897. checkLiteral();
  3898. }
  3899. }
  3900. if (iValue < value.length){
  3901. var extra = value.substr(iValue);
  3902. if (!/^\s+/.test(extra)) {
  3903. throw "Extra/unparsed characters found in date: " + extra;
  3904. }
  3905. }
  3906. if (year == -1)
  3907. year = new Date().getFullYear();
  3908. else if (year < 100)
  3909. year += new Date().getFullYear() - new Date().getFullYear() % 100 +
  3910. (year <= shortYearCutoff ? 0 : -100);
  3911. if (doy > -1) {
  3912. month = 1;
  3913. day = doy;
  3914. do {
  3915. var dim = this._getDaysInMonth(year, month - 1);
  3916. if (day <= dim)
  3917. break;
  3918. month++;
  3919. day -= dim;
  3920. } while (true);
  3921. }
  3922. var date = this._daylightSavingAdjust(new Date(year, month - 1, day));
  3923. if (date.getFullYear() != year || date.getMonth() + 1 != month || date.getDate() != day)
  3924. throw 'Invalid date'; // E.g. 31/02/00
  3925. return date;
  3926. },
  3927. /* Standard date formats. */
  3928. ATOM: 'yy-mm-dd', // RFC 3339 (ISO 8601)
  3929. COOKIE: 'D, dd M yy',
  3930. ISO_8601: 'yy-mm-dd',
  3931. RFC_822: 'D, d M y',
  3932. RFC_850: 'DD, dd-M-y',
  3933. RFC_1036: 'D, d M y',
  3934. RFC_1123: 'D, d M yy',
  3935. RFC_2822: 'D, d M yy',
  3936. RSS: 'D, d M y', // RFC 822
  3937. TICKS: '!',
  3938. TIMESTAMP: '@',
  3939. W3C: 'yy-mm-dd', // ISO 8601
  3940. _ticksTo1970: (((1970 - 1) * 365 + Math.floor(1970 / 4) - Math.floor(1970 / 100) +
  3941. Math.floor(1970 / 400)) * 24 * 60 * 60 * 10000000),
  3942. /* Format a date object into a string value.
  3943. The format can be combinations of the following:
  3944. d - day of month (no leading zero)
  3945. dd - day of month (two digit)
  3946. o - day of year (no leading zeros)
  3947. oo - day of year (three digit)
  3948. D - day name short
  3949. DD - day name long
  3950. m - month of year (no leading zero)
  3951. mm - month of year (two digit)
  3952. M - month name short
  3953. MM - month name long
  3954. y - year (two digit)
  3955. yy - year (four digit)
  3956. @ - Unix timestamp (ms since 01/01/1970)
  3957. ! - Windows ticks (100ns since 01/01/0001)
  3958. '...' - literal text
  3959. '' - single quote
  3960. @param format string - the desired format of the date
  3961. @param date Date - the date value to format
  3962. @param settings Object - attributes include:
  3963. dayNamesShort string[7] - abbreviated names of the days from Sunday (optional)
  3964. dayNames string[7] - names of the days from Sunday (optional)
  3965. monthNamesShort string[12] - abbreviated names of the months (optional)
  3966. monthNames string[12] - names of the months (optional)
  3967. @return string - the date in the above format */
  3968. formatDate: function (format, date, settings) {
  3969. if (!date)
  3970. return '';
  3971. var dayNamesShort = (settings ? settings.dayNamesShort : null) || this._defaults.dayNamesShort;
  3972. var dayNames = (settings ? settings.dayNames : null) || this._defaults.dayNames;
  3973. var monthNamesShort = (settings ? settings.monthNamesShort : null) || this._defaults.monthNamesShort;
  3974. var monthNames = (settings ? settings.monthNames : null) || this._defaults.monthNames;
  3975. // Check whether a format character is doubled
  3976. var lookAhead = function(match) {
  3977. var matches = (iFormat + 1 < format.length && format.charAt(iFormat + 1) == match);
  3978. if (matches)
  3979. iFormat++;
  3980. return matches;
  3981. };
  3982. // Format a number, with leading zero if necessary
  3983. var formatNumber = function(match, value, len) {
  3984. var num = '' + value;
  3985. if (lookAhead(match))
  3986. while (num.length < len)
  3987. num = '0' + num;
  3988. return num;
  3989. };
  3990. // Format a name, short or long as requested
  3991. var formatName = function(match, value, shortNames, longNames) {
  3992. return (lookAhead(match) ? longNames[value] : shortNames[value]);
  3993. };
  3994. var output = '';
  3995. var literal = false;
  3996. if (date)
  3997. for (var iFormat = 0; iFormat < format.length; iFormat++) {
  3998. if (literal)
  3999. if (format.charAt(iFormat) == "'" && !lookAhead("'"))
  4000. literal = false;
  4001. else
  4002. output += format.charAt(iFormat);
  4003. else
  4004. switch (format.charAt(iFormat)) {
  4005. case 'd':
  4006. output += formatNumber('d', date.getDate(), 2);
  4007. break;
  4008. case 'D':
  4009. output += formatName('D', date.getDay(), dayNamesShort, dayNames);
  4010. break;
  4011. case 'o':
  4012. output += formatNumber('o',
  4013. Math.round((new Date(date.getFullYear(), date.getMonth(), date.getDate()).getTime() - new Date(date.getFullYear(), 0, 0).getTime()) / 86400000), 3);
  4014. break;
  4015. case 'm':
  4016. output += formatNumber('m', date.getMonth() + 1, 2);
  4017. break;
  4018. case 'M':
  4019. output += formatName('M', date.getMonth(), monthNamesShort, monthNames);
  4020. break;
  4021. case 'y':
  4022. output += (lookAhead('y') ? date.getFullYear() :
  4023. (date.getYear() % 100 < 10 ? '0' : '') + date.getYear() % 100);
  4024. break;
  4025. case '@':
  4026. output += date.getTime();
  4027. break;
  4028. case '!':
  4029. output += date.getTime() * 10000 + this._ticksTo1970;
  4030. break;
  4031. case "'":
  4032. if (lookAhead("'"))
  4033. output += "'";
  4034. else
  4035. literal = true;
  4036. break;
  4037. default:
  4038. output += format.charAt(iFormat);
  4039. }
  4040. }
  4041. return output;
  4042. },
  4043. /* Extract all possible characters from the date format. */
  4044. _possibleChars: function (format) {
  4045. var chars = '';
  4046. var literal = false;
  4047. // Check whether a format character is doubled
  4048. var lookAhead = function(match) {
  4049. var matches = (iFormat + 1 < format.length && format.charAt(iFormat + 1) == match);
  4050. if (matches)
  4051. iFormat++;
  4052. return matches;
  4053. };
  4054. for (var iFormat = 0; iFormat < format.length; iFormat++)
  4055. if (literal)
  4056. if (format.charAt(iFormat) == "'" && !lookAhead("'"))
  4057. literal = false;
  4058. else
  4059. chars += format.charAt(iFormat);
  4060. else
  4061. switch (format.charAt(iFormat)) {
  4062. case 'd': case 'm': case 'y': case '@':
  4063. chars += '0123456789';
  4064. break;
  4065. case 'D': case 'M':
  4066. return null; // Accept anything
  4067. case "'":
  4068. if (lookAhead("'"))
  4069. chars += "'";
  4070. else
  4071. literal = true;
  4072. break;
  4073. default:
  4074. chars += format.charAt(iFormat);
  4075. }
  4076. return chars;
  4077. },
  4078. /* Get a setting value, defaulting if necessary. */
  4079. _get: function(inst, name) {
  4080. return inst.settings[name] !== undefined ?
  4081. inst.settings[name] : this._defaults[name];
  4082. },
  4083. /* Parse existing date and initialise date picker. */
  4084. _setDateFromField: function(inst, noDefault) {
  4085. if (inst.input.val() == inst.lastVal) {
  4086. return;
  4087. }
  4088. var dateFormat = this._get(inst, 'dateFormat');
  4089. var dates = inst.lastVal = inst.input ? inst.input.val() : null;
  4090. var date, defaultDate;
  4091. date = defaultDate = this._getDefaultDate(inst);
  4092. var settings = this._getFormatConfig(inst);
  4093. try {
  4094. date = this.parseDate(dateFormat, dates, settings) || defaultDate;
  4095. } catch (event) {
  4096. this.log(event);
  4097. dates = (noDefault ? '' : dates);
  4098. }
  4099. inst.selectedDay = date.getDate();
  4100. inst.drawMonth = inst.selectedMonth = date.getMonth();
  4101. inst.drawYear = inst.selectedYear = date.getFullYear();
  4102. inst.currentDay = (dates ? date.getDate() : 0);
  4103. inst.currentMonth = (dates ? date.getMonth() : 0);
  4104. inst.currentYear = (dates ? date.getFullYear() : 0);
  4105. this._adjustInstDate(inst);
  4106. },
  4107. /* Retrieve the default date shown on opening. */
  4108. _getDefaultDate: function(inst) {
  4109. return this._restrictMinMax(inst,
  4110. this._determineDate(inst, this._get(inst, 'defaultDate'), new Date()));
  4111. },
  4112. /* A date may be specified as an exact value or a relative one. */
  4113. _determineDate: function(inst, date, defaultDate) {
  4114. var offsetNumeric = function(offset) {
  4115. var date = new Date();
  4116. date.setDate(date.getDate() + offset);
  4117. return date;
  4118. };
  4119. var offsetString = function(offset) {
  4120. try {
  4121. return $.datepicker.parseDate($.datepicker._get(inst, 'dateFormat'),
  4122. offset, $.datepicker._getFormatConfig(inst));
  4123. }
  4124. catch (e) {
  4125. // Ignore
  4126. }
  4127. var date = (offset.toLowerCase().match(/^c/) ?
  4128. $.datepicker._getDate(inst) : null) || new Date();
  4129. var year = date.getFullYear();
  4130. var month = date.getMonth();
  4131. var day = date.getDate();
  4132. var pattern = /([+-]?[0-9]+)\s*(d|D|w|W|m|M|y|Y)?/g;
  4133. var matches = pattern.exec(offset);
  4134. while (matches) {
  4135. switch (matches[2] || 'd') {
  4136. case 'd' : case 'D' :
  4137. day += parseInt(matches[1],10); break;
  4138. case 'w' : case 'W' :
  4139. day += parseInt(matches[1],10) * 7; break;
  4140. case 'm' : case 'M' :
  4141. month += parseInt(matches[1],10);
  4142. day = Math.min(day, $.datepicker._getDaysInMonth(year, month));
  4143. break;
  4144. case 'y': case 'Y' :
  4145. year += parseInt(matches[1],10);
  4146. day = Math.min(day, $.datepicker._getDaysInMonth(year, month));
  4147. break;
  4148. }
  4149. matches = pattern.exec(offset);
  4150. }
  4151. return new Date(year, month, day);
  4152. };
  4153. var newDate = (date == null || date === '' ? defaultDate : (typeof date == 'string' ? offsetString(date) :
  4154. (typeof date == 'number' ? (isNaN(date) ? defaultDate : offsetNumeric(date)) : new Date(date.getTime()))));
  4155. newDate = (newDate && newDate.toString() == 'Invalid Date' ? defaultDate : newDate);
  4156. if (newDate) {
  4157. newDate.setHours(0);
  4158. newDate.setMinutes(0);
  4159. newDate.setSeconds(0);
  4160. newDate.setMilliseconds(0);
  4161. }
  4162. return this._daylightSavingAdjust(newDate);
  4163. },
  4164. /* Handle switch to/from daylight saving.
  4165. Hours may be non-zero on daylight saving cut-over:
  4166. > 12 when midnight changeover, but then cannot generate
  4167. midnight datetime, so jump to 1AM, otherwise reset.
  4168. @param date (Date) the date to check
  4169. @return (Date) the corrected date */
  4170. _daylightSavingAdjust: function(date) {
  4171. if (!date) return null;
  4172. date.setHours(date.getHours() > 12 ? date.getHours() + 2 : 0);
  4173. return date;
  4174. },
  4175. /* Set the date(s) directly. */
  4176. _setDate: function(inst, date, noChange) {
  4177. var clear = !date;
  4178. var origMonth = inst.selectedMonth;
  4179. var origYear = inst.selectedYear;
  4180. var newDate = this._restrictMinMax(inst, this._determineDate(inst, date, new Date()));
  4181. inst.selectedDay = inst.currentDay = newDate.getDate();
  4182. inst.drawMonth = inst.selectedMonth = inst.currentMonth = newDate.getMonth();
  4183. inst.drawYear = inst.selectedYear = inst.currentYear = newDate.getFullYear();
  4184. if ((origMonth != inst.selectedMonth || origYear != inst.selectedYear) && !noChange)
  4185. this._notifyChange(inst);
  4186. this._adjustInstDate(inst);
  4187. if (inst.input) {
  4188. inst.input.val(clear ? '' : this._formatDate(inst));
  4189. }
  4190. },
  4191. /* Retrieve the date(s) directly. */
  4192. _getDate: function(inst) {
  4193. var startDate = (!inst.currentYear || (inst.input && inst.input.val() == '') ? null :
  4194. this._daylightSavingAdjust(new Date(
  4195. inst.currentYear, inst.currentMonth, inst.currentDay)));
  4196. return startDate;
  4197. },
  4198. /* Attach the onxxx handlers. These are declared statically so
  4199. * they work with static code transformers like Caja.
  4200. */
  4201. _attachHandlers: function(inst) {
  4202. var stepMonths = this._get(inst, 'stepMonths');
  4203. var id = '#' + inst.id.replace( /\\\\/g, "\\" );
  4204. inst.dpDiv.find('[data-handler]').map(function () {
  4205. var handler = {
  4206. prev: function () {
  4207. window['DP_jQuery_' + dpuuid].datepicker._adjustDate(id, -stepMonths, 'M');
  4208. },
  4209. next: function () {
  4210. window['DP_jQuery_' + dpuuid].datepicker._adjustDate(id, +stepMonths, 'M');
  4211. },
  4212. hide: function () {
  4213. window['DP_jQuery_' + dpuuid].datepicker._hideDatepicker();
  4214. },
  4215. today: function () {
  4216. window['DP_jQuery_' + dpuuid].datepicker._gotoToday(id);
  4217. },
  4218. selectDay: function () {
  4219. window['DP_jQuery_' + dpuuid].datepicker._selectDay(id, +this.getAttribute('data-month'), +this.getAttribute('data-year'), this);
  4220. return false;
  4221. },
  4222. selectMonth: function () {
  4223. window['DP_jQuery_' + dpuuid].datepicker._selectMonthYear(id, this, 'M');
  4224. return false;
  4225. },
  4226. selectYear: function () {
  4227. window['DP_jQuery_' + dpuuid].datepicker._selectMonthYear(id, this, 'Y');
  4228. return false;
  4229. }
  4230. };
  4231. $(this).bind(this.getAttribute('data-event'), handler[this.getAttribute('data-handler')]);
  4232. });
  4233. },
  4234. /* Generate the HTML for the current state of the date picker. */
  4235. _generateHTML: function(inst) {
  4236. var today = new Date();
  4237. today = this._daylightSavingAdjust(
  4238. new Date(today.getFullYear(), today.getMonth(), today.getDate())); // clear time
  4239. var isRTL = this._get(inst, 'isRTL');
  4240. var showButtonPanel = this._get(inst, 'showButtonPanel');
  4241. var hideIfNoPrevNext = this._get(inst, 'hideIfNoPrevNext');
  4242. var navigationAsDateFormat = this._get(inst, 'navigationAsDateFormat');
  4243. var numMonths = this._getNumberOfMonths(inst);
  4244. var showCurrentAtPos = this._get(inst, 'showCurrentAtPos');
  4245. var stepMonths = this._get(inst, 'stepMonths');
  4246. var isMultiMonth = (numMonths[0] != 1 || numMonths[1] != 1);
  4247. var currentDate = this._daylightSavingAdjust((!inst.currentDay ? new Date(9999, 9, 9) :
  4248. new Date(inst.currentYear, inst.currentMonth, inst.currentDay)));
  4249. var minDate = this._getMinMaxDate(inst, 'min');
  4250. var maxDate = this._getMinMaxDate(inst, 'max');
  4251. var drawMonth = inst.drawMonth - showCurrentAtPos;
  4252. var drawYear = inst.drawYear;
  4253. if (drawMonth < 0) {
  4254. drawMonth += 12;
  4255. drawYear--;
  4256. }
  4257. if (maxDate) {
  4258. var maxDraw = this._daylightSavingAdjust(new Date(maxDate.getFullYear(),
  4259. maxDate.getMonth() - (numMonths[0] * numMonths[1]) + 1, maxDate.getDate()));
  4260. maxDraw = (minDate && maxDraw < minDate ? minDate : maxDraw);
  4261. while (this._daylightSavingAdjust(new Date(drawYear, drawMonth, 1)) > maxDraw) {
  4262. drawMonth--;
  4263. if (drawMonth < 0) {
  4264. drawMonth = 11;
  4265. drawYear--;
  4266. }
  4267. }
  4268. }
  4269. inst.drawMonth = drawMonth;
  4270. inst.drawYear = drawYear;
  4271. var prevText = this._get(inst, 'prevText');
  4272. prevText = (!navigationAsDateFormat ? prevText : this.formatDate(prevText,
  4273. this._daylightSavingAdjust(new Date(drawYear, drawMonth - stepMonths, 1)),
  4274. this._getFormatConfig(inst)));
  4275. var prev = (this._canAdjustMonth(inst, -1, drawYear, drawMonth) ?
  4276. '<a class="ui-datepicker-prev ui-corner-all" data-handler="prev" data-event="click"' +
  4277. ' title="' + prevText + '"><span class="ui-icon ui-icon-circle-triangle-' + ( isRTL ? 'e' : 'w') + '">' + prevText + '</span></a>' :
  4278. (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>'));
  4279. var nextText = this._get(inst, 'nextText');
  4280. nextText = (!navigationAsDateFormat ? nextText : this.formatDate(nextText,
  4281. this._daylightSavingAdjust(new Date(drawYear, drawMonth + stepMonths, 1)),
  4282. this._getFormatConfig(inst)));
  4283. var next = (this._canAdjustMonth(inst, +1, drawYear, drawMonth) ?
  4284. '<a class="ui-datepicker-next ui-corner-all" data-handler="next" data-event="click"' +
  4285. ' title="' + nextText + '"><span class="ui-icon ui-icon-circle-triangle-' + ( isRTL ? 'w' : 'e') + '">' + nextText + '</span></a>' :
  4286. (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>'));
  4287. var currentText = this._get(inst, 'currentText');
  4288. var gotoDate = (this._get(inst, 'gotoCurrent') && inst.currentDay ? currentDate : today);
  4289. currentText = (!navigationAsDateFormat ? currentText :
  4290. this.formatDate(currentText, gotoDate, this._getFormatConfig(inst)));
  4291. var 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">' +
  4292. this._get(inst, 'closeText') + '</button>' : '');
  4293. var buttonPanel = (showButtonPanel) ? '<div class="ui-datepicker-buttonpane ui-widget-content">' + (isRTL ? controls : '') +
  4294. (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"' +
  4295. '>' + currentText + '</button>' : '') + (isRTL ? '' : controls) + '</div>' : '';
  4296. var firstDay = parseInt(this._get(inst, 'firstDay'),10);
  4297. firstDay = (isNaN(firstDay) ? 0 : firstDay);
  4298. var showWeek = this._get(inst, 'showWeek');
  4299. var dayNames = this._get(inst, 'dayNames');
  4300. var dayNamesShort = this._get(inst, 'dayNamesShort');
  4301. var dayNamesMin = this._get(inst, 'dayNamesMin');
  4302. var monthNames = this._get(inst, 'monthNames');
  4303. var monthNamesShort = this._get(inst, 'monthNamesShort');
  4304. var beforeShowDay = this._get(inst, 'beforeShowDay');
  4305. var showOtherMonths = this._get(inst, 'showOtherMonths');
  4306. var selectOtherMonths = this._get(inst, 'selectOtherMonths');
  4307. var calculateWeek = this._get(inst, 'calculateWeek') || this.iso8601Week;
  4308. var defaultDate = this._getDefaultDate(inst);
  4309. var html = '';
  4310. for (var row = 0; row < numMonths[0]; row++) {
  4311. var group = '';
  4312. this.maxRows = 4;
  4313. for (var col = 0; col < numMonths[1]; col++) {
  4314. var selectedDate = this._daylightSavingAdjust(new Date(drawYear, drawMonth, inst.selectedDay));
  4315. var cornerClass = ' ui-corner-all';
  4316. var calender = '';
  4317. if (isMultiMonth) {
  4318. calender += '<div class="ui-datepicker-group';
  4319. if (numMonths[1] > 1)
  4320. switch (col) {
  4321. case 0: calender += ' ui-datepicker-group-first';
  4322. cornerClass = ' ui-corner-' + (isRTL ? 'right' : 'left'); break;
  4323. case numMonths[1]-1: calender += ' ui-datepicker-group-last';
  4324. cornerClass = ' ui-corner-' + (isRTL ? 'left' : 'right'); break;
  4325. default: calender += ' ui-datepicker-group-middle'; cornerClass = ''; break;
  4326. }
  4327. calender += '">';
  4328. }
  4329. calender += '<div class="ui-datepicker-header ui-widget-header ui-helper-clearfix' + cornerClass + '">' +
  4330. (/all|left/.test(cornerClass) && row == 0 ? (isRTL ? next : prev) : '') +
  4331. (/all|right/.test(cornerClass) && row == 0 ? (isRTL ? prev : next) : '') +
  4332. this._generateMonthYearHeader(inst, drawMonth, drawYear, minDate, maxDate,
  4333. row > 0 || col > 0, monthNames, monthNamesShort) + // draw month headers
  4334. '</div><table class="ui-datepicker-calendar"><thead>' +
  4335. '<tr>';
  4336. var thead = (showWeek ? '<th class="ui-datepicker-week-col">' + this._get(inst, 'weekHeader') + '</th>' : '');
  4337. for (var dow = 0; dow < 7; dow++) { // days of the week
  4338. var day = (dow + firstDay) % 7;
  4339. thead += '<th' + ((dow + firstDay + 6) % 7 >= 5 ? ' class="ui-datepicker-week-end"' : '') + '>' +
  4340. '<span title="' + dayNames[day] + '">' + dayNamesMin[day] + '</span></th>';
  4341. }
  4342. calender += thead + '</tr></thead><tbody>';
  4343. var daysInMonth = this._getDaysInMonth(drawYear, drawMonth);
  4344. if (drawYear == inst.selectedYear && drawMonth == inst.selectedMonth)
  4345. inst.selectedDay = Math.min(inst.selectedDay, daysInMonth);
  4346. var leadDays = (this._getFirstDayOfMonth(drawYear, drawMonth) - firstDay + 7) % 7;
  4347. var curRows = Math.ceil((leadDays + daysInMonth) / 7); // calculate the number of rows to generate
  4348. var numRows = (isMultiMonth ? this.maxRows > curRows ? this.maxRows : curRows : curRows); //If multiple months, use the higher number of rows (see #7043)
  4349. this.maxRows = numRows;
  4350. var printDate = this._daylightSavingAdjust(new Date(drawYear, drawMonth, 1 - leadDays));
  4351. for (var dRow = 0; dRow < numRows; dRow++) { // create date picker rows
  4352. calender += '<tr>';
  4353. var tbody = (!showWeek ? '' : '<td class="ui-datepicker-week-col">' +
  4354. this._get(inst, 'calculateWeek')(printDate) + '</td>');
  4355. for (var dow = 0; dow < 7; dow++) { // create date picker days
  4356. var daySettings = (beforeShowDay ?
  4357. beforeShowDay.apply((inst.input ? inst.input[0] : null), [printDate]) : [true, '']);
  4358. var otherMonth = (printDate.getMonth() != drawMonth);
  4359. var unselectable = (otherMonth && !selectOtherMonths) || !daySettings[0] ||
  4360. (minDate && printDate < minDate) || (maxDate && printDate > maxDate);
  4361. tbody += '<td class="' +
  4362. ((dow + firstDay + 6) % 7 >= 5 ? ' ui-datepicker-week-end' : '') + // highlight weekends
  4363. (otherMonth ? ' ui-datepicker-other-month' : '') + // highlight days from other months
  4364. ((printDate.getTime() == selectedDate.getTime() && drawMonth == inst.selectedMonth && inst._keyEvent) || // user pressed key
  4365. (defaultDate.getTime() == printDate.getTime() && defaultDate.getTime() == selectedDate.getTime()) ?
  4366. // or defaultDate is current printedDate and defaultDate is selectedDate
  4367. ' ' + this._dayOverClass : '') + // highlight selected day
  4368. (unselectable ? ' ' + this._unselectableClass + ' ui-state-disabled': '') + // highlight unselectable days
  4369. (otherMonth && !showOtherMonths ? '' : ' ' + daySettings[1] + // highlight custom dates
  4370. (printDate.getTime() == currentDate.getTime() ? ' ' + this._currentClass : '') + // highlight selected day
  4371. (printDate.getTime() == today.getTime() ? ' ui-datepicker-today' : '')) + '"' + // highlight today (if different)
  4372. ((!otherMonth || showOtherMonths) && daySettings[2] ? ' title="' + daySettings[2] + '"' : '') + // cell title
  4373. (unselectable ? '' : ' data-handler="selectDay" data-event="click" data-month="' + printDate.getMonth() + '" data-year="' + printDate.getFullYear() + '"') + '>' + // actions
  4374. (otherMonth && !showOtherMonths ? '&#xa0;' : // display for other months
  4375. (unselectable ? '<span class="ui-state-default">' + printDate.getDate() + '</span>' : '<a class="ui-state-default' +
  4376. (printDate.getTime() == today.getTime() ? ' ui-state-highlight' : '') +
  4377. (printDate.getTime() == currentDate.getTime() ? ' ui-state-active' : '') + // highlight selected day
  4378. (otherMonth ? ' ui-priority-secondary' : '') + // distinguish dates from other months
  4379. '" href="#">' + printDate.getDate() + '</a>')) + '</td>'; // display selectable date
  4380. printDate.setDate(printDate.getDate() + 1);
  4381. printDate = this._daylightSavingAdjust(printDate);
  4382. }
  4383. calender += tbody + '</tr>';
  4384. }
  4385. drawMonth++;
  4386. if (drawMonth > 11) {
  4387. drawMonth = 0;
  4388. drawYear++;
  4389. }
  4390. calender += '</tbody></table>' + (isMultiMonth ? '</div>' +
  4391. ((numMonths[0] > 0 && col == numMonths[1]-1) ? '<div class="ui-datepicker-row-break"></div>' : '') : '');
  4392. group += calender;
  4393. }
  4394. html += group;
  4395. }
  4396. html += buttonPanel + ($.ui.ie6 && !inst.inline ?
  4397. '<iframe src="javascript:false;" class="ui-datepicker-cover" frameborder="0"></iframe>' : '');
  4398. inst._keyEvent = false;
  4399. return html;
  4400. },
  4401. /* Generate the month and year header. */
  4402. _generateMonthYearHeader: function(inst, drawMonth, drawYear, minDate, maxDate,
  4403. secondary, monthNames, monthNamesShort) {
  4404. var changeMonth = this._get(inst, 'changeMonth');
  4405. var changeYear = this._get(inst, 'changeYear');
  4406. var showMonthAfterYear = this._get(inst, 'showMonthAfterYear');
  4407. var html = '<div class="ui-datepicker-title">';
  4408. var monthHtml = '';
  4409. // month selection
  4410. if (secondary || !changeMonth)
  4411. monthHtml += '<span class="ui-datepicker-month">' + monthNames[drawMonth] + '</span>';
  4412. else {
  4413. var inMinYear = (minDate && minDate.getFullYear() == drawYear);
  4414. var inMaxYear = (maxDate && maxDate.getFullYear() == drawYear);
  4415. monthHtml += '<select class="ui-datepicker-month" data-handler="selectMonth" data-event="change">';
  4416. for (var month = 0; month < 12; month++) {
  4417. if ((!inMinYear || month >= minDate.getMonth()) &&
  4418. (!inMaxYear || month <= maxDate.getMonth()))
  4419. monthHtml += '<option value="' + month + '"' +
  4420. (month == drawMonth ? ' selected="selected"' : '') +
  4421. '>' + monthNamesShort[month] + '</option>';
  4422. }
  4423. monthHtml += '</select>';
  4424. }
  4425. if (!showMonthAfterYear)
  4426. html += monthHtml + (secondary || !(changeMonth && changeYear) ? '&#xa0;' : '');
  4427. // year selection
  4428. if ( !inst.yearshtml ) {
  4429. inst.yearshtml = '';
  4430. if (secondary || !changeYear)
  4431. html += '<span class="ui-datepicker-year">' + drawYear + '</span>';
  4432. else {
  4433. // determine range of years to display
  4434. var years = this._get(inst, 'yearRange').split(':');
  4435. var thisYear = new Date().getFullYear();
  4436. var determineYear = function(value) {
  4437. var year = (value.match(/c[+-].*/) ? drawYear + parseInt(value.substring(1), 10) :
  4438. (value.match(/[+-].*/) ? thisYear + parseInt(value, 10) :
  4439. parseInt(value, 10)));
  4440. return (isNaN(year) ? thisYear : year);
  4441. };
  4442. var year = determineYear(years[0]);
  4443. var endYear = Math.max(year, determineYear(years[1] || ''));
  4444. year = (minDate ? Math.max(year, minDate.getFullYear()) : year);
  4445. endYear = (maxDate ? Math.min(endYear, maxDate.getFullYear()) : endYear);
  4446. inst.yearshtml += '<select class="ui-datepicker-year" data-handler="selectYear" data-event="change">';
  4447. for (; year <= endYear; year++) {
  4448. inst.yearshtml += '<option value="' + year + '"' +
  4449. (year == drawYear ? ' selected="selected"' : '') +
  4450. '>' + year + '</option>';
  4451. }
  4452. inst.yearshtml += '</select>';
  4453. html += inst.yearshtml;
  4454. inst.yearshtml = null;
  4455. }
  4456. }
  4457. html += this._get(inst, 'yearSuffix');
  4458. if (showMonthAfterYear)
  4459. html += (secondary || !(changeMonth && changeYear) ? '&#xa0;' : '') + monthHtml;
  4460. html += '</div>'; // Close datepicker_header
  4461. return html;
  4462. },
  4463. /* Adjust one of the date sub-fields. */
  4464. _adjustInstDate: function(inst, offset, period) {
  4465. var year = inst.drawYear + (period == 'Y' ? offset : 0);
  4466. var month = inst.drawMonth + (period == 'M' ? offset : 0);
  4467. var day = Math.min(inst.selectedDay, this._getDaysInMonth(year, month)) +
  4468. (period == 'D' ? offset : 0);
  4469. var date = this._restrictMinMax(inst,
  4470. this._daylightSavingAdjust(new Date(year, month, day)));
  4471. inst.selectedDay = date.getDate();
  4472. inst.drawMonth = inst.selectedMonth = date.getMonth();
  4473. inst.drawYear = inst.selectedYear = date.getFullYear();
  4474. if (period == 'M' || period == 'Y')
  4475. this._notifyChange(inst);
  4476. },
  4477. /* Ensure a date is within any min/max bounds. */
  4478. _restrictMinMax: function(inst, date) {
  4479. var minDate = this._getMinMaxDate(inst, 'min');
  4480. var maxDate = this._getMinMaxDate(inst, 'max');
  4481. var newDate = (minDate && date < minDate ? minDate : date);
  4482. newDate = (maxDate && newDate > maxDate ? maxDate : newDate);
  4483. return newDate;
  4484. },
  4485. /* Notify change of month/year. */
  4486. _notifyChange: function(inst) {
  4487. var onChange = this._get(inst, 'onChangeMonthYear');
  4488. if (onChange)
  4489. onChange.apply((inst.input ? inst.input[0] : null),
  4490. [inst.selectedYear, inst.selectedMonth + 1, inst]);
  4491. },
  4492. /* Determine the number of months to show. */
  4493. _getNumberOfMonths: function(inst) {
  4494. var numMonths = this._get(inst, 'numberOfMonths');
  4495. return (numMonths == null ? [1, 1] : (typeof numMonths == 'number' ? [1, numMonths] : numMonths));
  4496. },
  4497. /* Determine the current maximum date - ensure no time components are set. */
  4498. _getMinMaxDate: function(inst, minMax) {
  4499. return this._determineDate(inst, this._get(inst, minMax + 'Date'), null);
  4500. },
  4501. /* Find the number of days in a given month. */
  4502. _getDaysInMonth: function(year, month) {
  4503. return 32 - this._daylightSavingAdjust(new Date(year, month, 32)).getDate();
  4504. },
  4505. /* Find the day of the week of the first of a month. */
  4506. _getFirstDayOfMonth: function(year, month) {
  4507. return new Date(year, month, 1).getDay();
  4508. },
  4509. /* Determines if we should allow a "next/prev" month display change. */
  4510. _canAdjustMonth: function(inst, offset, curYear, curMonth) {
  4511. var numMonths = this._getNumberOfMonths(inst);
  4512. var date = this._daylightSavingAdjust(new Date(curYear,
  4513. curMonth + (offset < 0 ? offset : numMonths[0] * numMonths[1]), 1));
  4514. if (offset < 0)
  4515. date.setDate(this._getDaysInMonth(date.getFullYear(), date.getMonth()));
  4516. return this._isInRange(inst, date);
  4517. },
  4518. /* Is the given date in the accepted range? */
  4519. _isInRange: function(inst, date) {
  4520. var minDate = this._getMinMaxDate(inst, 'min');
  4521. var maxDate = this._getMinMaxDate(inst, 'max');
  4522. return ((!minDate || date.getTime() >= minDate.getTime()) &&
  4523. (!maxDate || date.getTime() <= maxDate.getTime()));
  4524. },
  4525. /* Provide the configuration settings for formatting/parsing. */
  4526. _getFormatConfig: function(inst) {
  4527. var shortYearCutoff = this._get(inst, 'shortYearCutoff');
  4528. shortYearCutoff = (typeof shortYearCutoff != 'string' ? shortYearCutoff :
  4529. new Date().getFullYear() % 100 + parseInt(shortYearCutoff, 10));
  4530. return {shortYearCutoff: shortYearCutoff,
  4531. dayNamesShort: this._get(inst, 'dayNamesShort'), dayNames: this._get(inst, 'dayNames'),
  4532. monthNamesShort: this._get(inst, 'monthNamesShort'), monthNames: this._get(inst, 'monthNames')};
  4533. },
  4534. /* Format the given date for display. */
  4535. _formatDate: function(inst, day, month, year) {
  4536. if (!day) {
  4537. inst.currentDay = inst.selectedDay;
  4538. inst.currentMonth = inst.selectedMonth;
  4539. inst.currentYear = inst.selectedYear;
  4540. }
  4541. var date = (day ? (typeof day == 'object' ? day :
  4542. this._daylightSavingAdjust(new Date(year, month, day))) :
  4543. this._daylightSavingAdjust(new Date(inst.currentYear, inst.currentMonth, inst.currentDay)));
  4544. return this.formatDate(this._get(inst, 'dateFormat'), date, this._getFormatConfig(inst));
  4545. }
  4546. });
  4547. /*
  4548. * Bind hover events for datepicker elements.
  4549. * Done via delegate so the binding only occurs once in the lifetime of the parent div.
  4550. * Global instActive, set by _updateDatepicker allows the handlers to find their way back to the active picker.
  4551. */
  4552. function bindHover(dpDiv) {
  4553. var selector = 'button, .ui-datepicker-prev, .ui-datepicker-next, .ui-datepicker-calendar td a';
  4554. return dpDiv.delegate(selector, 'mouseout', function() {
  4555. $(this).removeClass('ui-state-hover');
  4556. if (this.className.indexOf('ui-datepicker-prev') != -1) $(this).removeClass('ui-datepicker-prev-hover');
  4557. if (this.className.indexOf('ui-datepicker-next') != -1) $(this).removeClass('ui-datepicker-next-hover');
  4558. })
  4559. .delegate(selector, 'mouseover', function(){
  4560. if (!$.datepicker._isDisabledDatepicker( instActive.inline ? dpDiv.parent()[0] : instActive.input[0])) {
  4561. $(this).parents('.ui-datepicker-calendar').find('a').removeClass('ui-state-hover');
  4562. $(this).addClass('ui-state-hover');
  4563. if (this.className.indexOf('ui-datepicker-prev') != -1) $(this).addClass('ui-datepicker-prev-hover');
  4564. if (this.className.indexOf('ui-datepicker-next') != -1) $(this).addClass('ui-datepicker-next-hover');
  4565. }
  4566. });
  4567. }
  4568. /* jQuery extend now ignores nulls! */
  4569. function extendRemove(target, props) {
  4570. $.extend(target, props);
  4571. for (var name in props)
  4572. if (props[name] == null || props[name] == undefined)
  4573. target[name] = props[name];
  4574. return target;
  4575. };
  4576. /* Invoke the datepicker functionality.
  4577. @param options string - a command, optionally followed by additional parameters or
  4578. Object - settings for attaching new datepicker functionality
  4579. @return jQuery object */
  4580. $.fn.datepicker = function(options){
  4581. /* Verify an empty collection wasn't passed - Fixes #6976 */
  4582. if ( !this.length ) {
  4583. return this;
  4584. }
  4585. /* Initialise the date picker. */
  4586. if (!$.datepicker.initialized) {
  4587. $(document).mousedown($.datepicker._checkExternalClick).
  4588. find(document.body).append($.datepicker.dpDiv);
  4589. $.datepicker.initialized = true;
  4590. }
  4591. var otherArgs = Array.prototype.slice.call(arguments, 1);
  4592. if (typeof options == 'string' && (options == 'isDisabled' || options == 'getDate' || options == 'widget'))
  4593. return $.datepicker['_' + options + 'Datepicker'].
  4594. apply($.datepicker, [this[0]].concat(otherArgs));
  4595. if (options == 'option' && arguments.length == 2 && typeof arguments[1] == 'string')
  4596. return $.datepicker['_' + options + 'Datepicker'].
  4597. apply($.datepicker, [this[0]].concat(otherArgs));
  4598. return this.each(function() {
  4599. typeof options == 'string' ?
  4600. $.datepicker['_' + options + 'Datepicker'].
  4601. apply($.datepicker, [this].concat(otherArgs)) :
  4602. $.datepicker._attachDatepicker(this, options);
  4603. });
  4604. };
  4605. $.datepicker = new Datepicker(); // singleton instance
  4606. $.datepicker.initialized = false;
  4607. $.datepicker.uuid = new Date().getTime();
  4608. $.datepicker.version = "1.9.2";
  4609. // Workaround for #4055
  4610. // Add another global to avoid noConflict issues with inline event handlers
  4611. window['DP_jQuery_' + dpuuid] = $;
  4612. })(jQuery);
  4613. (function( $, undefined ) {
  4614. var uiDialogClasses = "ui-dialog ui-widget ui-widget-content ui-corner-all ",
  4615. sizeRelatedOptions = {
  4616. buttons: true,
  4617. height: true,
  4618. maxHeight: true,
  4619. maxWidth: true,
  4620. minHeight: true,
  4621. minWidth: true,
  4622. width: true
  4623. },
  4624. resizableRelatedOptions = {
  4625. maxHeight: true,
  4626. maxWidth: true,
  4627. minHeight: true,
  4628. minWidth: true
  4629. };
  4630. $.widget("ui.dialog", {
  4631. version: "1.9.2",
  4632. options: {
  4633. autoOpen: true,
  4634. buttons: {},
  4635. closeOnEscape: true,
  4636. closeText: "close",
  4637. dialogClass: "",
  4638. draggable: true,
  4639. hide: null,
  4640. height: "auto",
  4641. maxHeight: false,
  4642. maxWidth: false,
  4643. minHeight: 150,
  4644. minWidth: 150,
  4645. modal: false,
  4646. position: {
  4647. my: "center",
  4648. at: "center",
  4649. of: window,
  4650. collision: "fit",
  4651. // ensure that the titlebar is never outside the document
  4652. using: function( pos ) {
  4653. var topOffset = $( this ).css( pos ).offset().top;
  4654. if ( topOffset < 0 ) {
  4655. $( this ).css( "top", pos.top - topOffset );
  4656. }
  4657. }
  4658. },
  4659. resizable: true,
  4660. show: null,
  4661. stack: true,
  4662. title: "",
  4663. width: 300,
  4664. zIndex: 1000
  4665. },
  4666. _create: function() {
  4667. this.originalTitle = this.element.attr( "title" );
  4668. // #5742 - .attr() might return a DOMElement
  4669. if ( typeof this.originalTitle !== "string" ) {
  4670. this.originalTitle = "";
  4671. }
  4672. this.oldPosition = {
  4673. parent: this.element.parent(),
  4674. index: this.element.parent().children().index( this.element )
  4675. };
  4676. this.options.title = this.options.title || this.originalTitle;
  4677. var that = this,
  4678. options = this.options,
  4679. title = options.title || "&#160;",
  4680. uiDialog,
  4681. uiDialogTitlebar,
  4682. uiDialogTitlebarClose,
  4683. uiDialogTitle,
  4684. uiDialogButtonPane;
  4685. uiDialog = ( this.uiDialog = $( "<div>" ) )
  4686. .addClass( uiDialogClasses + options.dialogClass )
  4687. .css({
  4688. display: "none",
  4689. outline: 0, // TODO: move to stylesheet
  4690. zIndex: options.zIndex
  4691. })
  4692. // setting tabIndex makes the div focusable
  4693. .attr( "tabIndex", -1)
  4694. .keydown(function( event ) {
  4695. if ( options.closeOnEscape && !event.isDefaultPrevented() && event.keyCode &&
  4696. event.keyCode === $.ui.keyCode.ESCAPE ) {
  4697. that.close( event );
  4698. event.preventDefault();
  4699. }
  4700. })
  4701. .mousedown(function( event ) {
  4702. that.moveToTop( false, event );
  4703. })
  4704. .appendTo( "body" );
  4705. this.element
  4706. .show()
  4707. .removeAttr( "title" )
  4708. .addClass( "ui-dialog-content ui-widget-content" )
  4709. .appendTo( uiDialog );
  4710. uiDialogTitlebar = ( this.uiDialogTitlebar = $( "<div>" ) )
  4711. .addClass( "ui-dialog-titlebar ui-widget-header " +
  4712. "ui-corner-all ui-helper-clearfix" )
  4713. .bind( "mousedown", function() {
  4714. // Dialog isn't getting focus when dragging (#8063)
  4715. uiDialog.focus();
  4716. })
  4717. .prependTo( uiDialog );
  4718. uiDialogTitlebarClose = $( "<a href='#'></a>" )
  4719. .addClass( "ui-dialog-titlebar-close ui-corner-all" )
  4720. .attr( "role", "button" )
  4721. .click(function( event ) {
  4722. event.preventDefault();
  4723. that.close( event );
  4724. })
  4725. .appendTo( uiDialogTitlebar );
  4726. ( this.uiDialogTitlebarCloseText = $( "<span>" ) )
  4727. .addClass( "ui-icon ui-icon-closethick" )
  4728. .text( options.closeText )
  4729. .appendTo( uiDialogTitlebarClose );
  4730. uiDialogTitle = $( "<span>" )
  4731. .uniqueId()
  4732. .addClass( "ui-dialog-title" )
  4733. .html( title )
  4734. .prependTo( uiDialogTitlebar );
  4735. uiDialogButtonPane = ( this.uiDialogButtonPane = $( "<div>" ) )
  4736. .addClass( "ui-dialog-buttonpane ui-widget-content ui-helper-clearfix" );
  4737. ( this.uiButtonSet = $( "<div>" ) )
  4738. .addClass( "ui-dialog-buttonset" )
  4739. .appendTo( uiDialogButtonPane );
  4740. uiDialog.attr({
  4741. role: "dialog",
  4742. "aria-labelledby": uiDialogTitle.attr( "id" )
  4743. });
  4744. uiDialogTitlebar.find( "*" ).add( uiDialogTitlebar ).disableSelection();
  4745. this._hoverable( uiDialogTitlebarClose );
  4746. this._focusable( uiDialogTitlebarClose );
  4747. if ( options.draggable && $.fn.draggable ) {
  4748. this._makeDraggable();
  4749. }
  4750. if ( options.resizable && $.fn.resizable ) {
  4751. this._makeResizable();
  4752. }
  4753. this._createButtons( options.buttons );
  4754. this._isOpen = false;
  4755. if ( $.fn.bgiframe ) {
  4756. uiDialog.bgiframe();
  4757. }
  4758. // prevent tabbing out of modal dialogs
  4759. this._on( uiDialog, { keydown: function( event ) {
  4760. if ( !options.modal || event.keyCode !== $.ui.keyCode.TAB ) {
  4761. return;
  4762. }
  4763. var tabbables = $( ":tabbable", uiDialog ),
  4764. first = tabbables.filter( ":first" ),
  4765. last = tabbables.filter( ":last" );
  4766. if ( event.target === last[0] && !event.shiftKey ) {
  4767. first.focus( 1 );
  4768. return false;
  4769. } else if ( event.target === first[0] && event.shiftKey ) {
  4770. last.focus( 1 );
  4771. return false;
  4772. }
  4773. }});
  4774. },
  4775. _init: function() {
  4776. if ( this.options.autoOpen ) {
  4777. this.open();
  4778. }
  4779. },
  4780. _destroy: function() {
  4781. var next,
  4782. oldPosition = this.oldPosition;
  4783. if ( this.overlay ) {
  4784. this.overlay.destroy();
  4785. }
  4786. this.uiDialog.hide();
  4787. this.element
  4788. .removeClass( "ui-dialog-content ui-widget-content" )
  4789. .hide()
  4790. .appendTo( "body" );
  4791. this.uiDialog.remove();
  4792. if ( this.originalTitle ) {
  4793. this.element.attr( "title", this.originalTitle );
  4794. }
  4795. next = oldPosition.parent.children().eq( oldPosition.index );
  4796. // Don't try to place the dialog next to itself (#8613)
  4797. if ( next.length && next[ 0 ] !== this.element[ 0 ] ) {
  4798. next.before( this.element );
  4799. } else {
  4800. oldPosition.parent.append( this.element );
  4801. }
  4802. },
  4803. widget: function() {
  4804. return this.uiDialog;
  4805. },
  4806. close: function( event ) {
  4807. var that = this,
  4808. maxZ, thisZ;
  4809. if ( !this._isOpen ) {
  4810. return;
  4811. }
  4812. if ( false === this._trigger( "beforeClose", event ) ) {
  4813. return;
  4814. }
  4815. this._isOpen = false;
  4816. if ( this.overlay ) {
  4817. this.overlay.destroy();
  4818. }
  4819. if ( this.options.hide ) {
  4820. this._hide( this.uiDialog, this.options.hide, function() {
  4821. that._trigger( "close", event );
  4822. });
  4823. } else {
  4824. this.uiDialog.hide();
  4825. this._trigger( "close", event );
  4826. }
  4827. $.ui.dialog.overlay.resize();
  4828. // adjust the maxZ to allow other modal dialogs to continue to work (see #4309)
  4829. if ( this.options.modal ) {
  4830. maxZ = 0;
  4831. $( ".ui-dialog" ).each(function() {
  4832. if ( this !== that.uiDialog[0] ) {
  4833. thisZ = $( this ).css( "z-index" );
  4834. if ( !isNaN( thisZ ) ) {
  4835. maxZ = Math.max( maxZ, thisZ );
  4836. }
  4837. }
  4838. });
  4839. $.ui.dialog.maxZ = maxZ;
  4840. }
  4841. return this;
  4842. },
  4843. isOpen: function() {
  4844. return this._isOpen;
  4845. },
  4846. // the force parameter allows us to move modal dialogs to their correct
  4847. // position on open
  4848. moveToTop: function( force, event ) {
  4849. var options = this.options,
  4850. saveScroll;
  4851. if ( ( options.modal && !force ) ||
  4852. ( !options.stack && !options.modal ) ) {
  4853. return this._trigger( "focus", event );
  4854. }
  4855. if ( options.zIndex > $.ui.dialog.maxZ ) {
  4856. $.ui.dialog.maxZ = options.zIndex;
  4857. }
  4858. if ( this.overlay ) {
  4859. $.ui.dialog.maxZ += 1;
  4860. $.ui.dialog.overlay.maxZ = $.ui.dialog.maxZ;
  4861. this.overlay.$el.css( "z-index", $.ui.dialog.overlay.maxZ );
  4862. }
  4863. // Save and then restore scroll
  4864. // Opera 9.5+ resets when parent z-index is changed.
  4865. // http://bugs.jqueryui.com/ticket/3193
  4866. saveScroll = {
  4867. scrollTop: this.element.scrollTop(),
  4868. scrollLeft: this.element.scrollLeft()
  4869. };
  4870. $.ui.dialog.maxZ += 1;
  4871. this.uiDialog.css( "z-index", $.ui.dialog.maxZ );
  4872. this.element.attr( saveScroll );
  4873. this._trigger( "focus", event );
  4874. return this;
  4875. },
  4876. open: function() {
  4877. if ( this._isOpen ) {
  4878. return;
  4879. }
  4880. var hasFocus,
  4881. options = this.options,
  4882. uiDialog = this.uiDialog;
  4883. this._size();
  4884. this._position( options.position );
  4885. uiDialog.show( options.show );
  4886. this.overlay = options.modal ? new $.ui.dialog.overlay( this ) : null;
  4887. this.moveToTop( true );
  4888. // set focus to the first tabbable element in the content area or the first button
  4889. // if there are no tabbable elements, set focus on the dialog itself
  4890. hasFocus = this.element.find( ":tabbable" );
  4891. if ( !hasFocus.length ) {
  4892. hasFocus = this.uiDialogButtonPane.find( ":tabbable" );
  4893. if ( !hasFocus.length ) {
  4894. hasFocus = uiDialog;
  4895. }
  4896. }
  4897. hasFocus.eq( 0 ).focus();
  4898. this._isOpen = true;
  4899. this._trigger( "open" );
  4900. return this;
  4901. },
  4902. _createButtons: function( buttons ) {
  4903. var that = this,
  4904. hasButtons = false;
  4905. // if we already have a button pane, remove it
  4906. this.uiDialogButtonPane.remove();
  4907. this.uiButtonSet.empty();
  4908. if ( typeof buttons === "object" && buttons !== null ) {
  4909. $.each( buttons, function() {
  4910. return !(hasButtons = true);
  4911. });
  4912. }
  4913. if ( hasButtons ) {
  4914. $.each( buttons, function( name, props ) {
  4915. var button, click;
  4916. props = $.isFunction( props ) ?
  4917. { click: props, text: name } :
  4918. props;
  4919. // Default to a non-submitting button
  4920. props = $.extend( { type: "button" }, props );
  4921. // Change the context for the click callback to be the main element
  4922. click = props.click;
  4923. props.click = function() {
  4924. click.apply( that.element[0], arguments );
  4925. };
  4926. button = $( "<button></button>", props )
  4927. .appendTo( that.uiButtonSet );
  4928. if ( $.fn.button ) {
  4929. button.button();
  4930. }
  4931. });
  4932. this.uiDialog.addClass( "ui-dialog-buttons" );
  4933. this.uiDialogButtonPane.appendTo( this.uiDialog );
  4934. } else {
  4935. this.uiDialog.removeClass( "ui-dialog-buttons" );
  4936. }
  4937. },
  4938. _makeDraggable: function() {
  4939. var that = this,
  4940. options = this.options;
  4941. function filteredUi( ui ) {
  4942. return {
  4943. position: ui.position,
  4944. offset: ui.offset
  4945. };
  4946. }
  4947. this.uiDialog.draggable({
  4948. cancel: ".ui-dialog-content, .ui-dialog-titlebar-close",
  4949. handle: ".ui-dialog-titlebar",
  4950. containment: "document",
  4951. start: function( event, ui ) {
  4952. $( this )
  4953. .addClass( "ui-dialog-dragging" );
  4954. that._trigger( "dragStart", event, filteredUi( ui ) );
  4955. },
  4956. drag: function( event, ui ) {
  4957. that._trigger( "drag", event, filteredUi( ui ) );
  4958. },
  4959. stop: function( event, ui ) {
  4960. options.position = [
  4961. ui.position.left - that.document.scrollLeft(),
  4962. ui.position.top - that.document.scrollTop()
  4963. ];
  4964. $( this )
  4965. .removeClass( "ui-dialog-dragging" );
  4966. that._trigger( "dragStop", event, filteredUi( ui ) );
  4967. $.ui.dialog.overlay.resize();
  4968. }
  4969. });
  4970. },
  4971. _makeResizable: function( handles ) {
  4972. handles = (handles === undefined ? this.options.resizable : handles);
  4973. var that = this,
  4974. options = this.options,
  4975. // .ui-resizable has position: relative defined in the stylesheet
  4976. // but dialogs have to use absolute or fixed positioning
  4977. position = this.uiDialog.css( "position" ),
  4978. resizeHandles = typeof handles === 'string' ?
  4979. handles :
  4980. "n,e,s,w,se,sw,ne,nw";
  4981. function filteredUi( ui ) {
  4982. return {
  4983. originalPosition: ui.originalPosition,
  4984. originalSize: ui.originalSize,
  4985. position: ui.position,
  4986. size: ui.size
  4987. };
  4988. }
  4989. this.uiDialog.resizable({
  4990. cancel: ".ui-dialog-content",
  4991. containment: "document",
  4992. alsoResize: this.element,
  4993. maxWidth: options.maxWidth,
  4994. maxHeight: options.maxHeight,
  4995. minWidth: options.minWidth,
  4996. minHeight: this._minHeight(),
  4997. handles: resizeHandles,
  4998. start: function( event, ui ) {
  4999. $( this ).addClass( "ui-dialog-resizing" );
  5000. that._trigger( "resizeStart", event, filteredUi( ui ) );
  5001. },
  5002. resize: function( event, ui ) {
  5003. that._trigger( "resize", event, filteredUi( ui ) );
  5004. },
  5005. stop: function( event, ui ) {
  5006. $( this ).removeClass( "ui-dialog-resizing" );
  5007. options.height = $( this ).height();
  5008. options.width = $( this ).width();
  5009. that._trigger( "resizeStop", event, filteredUi( ui ) );
  5010. $.ui.dialog.overlay.resize();
  5011. }
  5012. })
  5013. .css( "position", position )
  5014. .find( ".ui-resizable-se" )
  5015. .addClass( "ui-icon ui-icon-grip-diagonal-se" );
  5016. },
  5017. _minHeight: function() {
  5018. var options = this.options;
  5019. if ( options.height === "auto" ) {
  5020. return options.minHeight;
  5021. } else {
  5022. return Math.min( options.minHeight, options.height );
  5023. }
  5024. },
  5025. _position: function( position ) {
  5026. var myAt = [],
  5027. offset = [ 0, 0 ],
  5028. isVisible;
  5029. if ( position ) {
  5030. // deep extending converts arrays to objects in jQuery <= 1.3.2 :-(
  5031. // if (typeof position == 'string' || $.isArray(position)) {
  5032. // myAt = $.isArray(position) ? position : position.split(' ');
  5033. if ( typeof position === "string" || (typeof position === "object" && "0" in position ) ) {
  5034. myAt = position.split ? position.split( " " ) : [ position[ 0 ], position[ 1 ] ];
  5035. if ( myAt.length === 1 ) {
  5036. myAt[ 1 ] = myAt[ 0 ];
  5037. }
  5038. $.each( [ "left", "top" ], function( i, offsetPosition ) {
  5039. if ( +myAt[ i ] === myAt[ i ] ) {
  5040. offset[ i ] = myAt[ i ];
  5041. myAt[ i ] = offsetPosition;
  5042. }
  5043. });
  5044. position = {
  5045. my: myAt[0] + (offset[0] < 0 ? offset[0] : "+" + offset[0]) + " " +
  5046. myAt[1] + (offset[1] < 0 ? offset[1] : "+" + offset[1]),
  5047. at: myAt.join( " " )
  5048. };
  5049. }
  5050. position = $.extend( {}, $.ui.dialog.prototype.options.position, position );
  5051. } else {
  5052. position = $.ui.dialog.prototype.options.position;
  5053. }
  5054. // need to show the dialog to get the actual offset in the position plugin
  5055. isVisible = this.uiDialog.is( ":visible" );
  5056. if ( !isVisible ) {
  5057. this.uiDialog.show();
  5058. }
  5059. this.uiDialog.position( position );
  5060. if ( !isVisible ) {
  5061. this.uiDialog.hide();
  5062. }
  5063. },
  5064. _setOptions: function( options ) {
  5065. var that = this,
  5066. resizableOptions = {},
  5067. resize = false;
  5068. $.each( options, function( key, value ) {
  5069. that._setOption( key, value );
  5070. if ( key in sizeRelatedOptions ) {
  5071. resize = true;
  5072. }
  5073. if ( key in resizableRelatedOptions ) {
  5074. resizableOptions[ key ] = value;
  5075. }
  5076. });
  5077. if ( resize ) {
  5078. this._size();
  5079. }
  5080. if ( this.uiDialog.is( ":data(resizable)" ) ) {
  5081. this.uiDialog.resizable( "option", resizableOptions );
  5082. }
  5083. },
  5084. _setOption: function( key, value ) {
  5085. var isDraggable, isResizable,
  5086. uiDialog = this.uiDialog;
  5087. switch ( key ) {
  5088. case "buttons":
  5089. this._createButtons( value );
  5090. break;
  5091. case "closeText":
  5092. // ensure that we always pass a string
  5093. this.uiDialogTitlebarCloseText.text( "" + value );
  5094. break;
  5095. case "dialogClass":
  5096. uiDialog
  5097. .removeClass( this.options.dialogClass )
  5098. .addClass( uiDialogClasses + value );
  5099. break;
  5100. case "disabled":
  5101. if ( value ) {
  5102. uiDialog.addClass( "ui-dialog-disabled" );
  5103. } else {
  5104. uiDialog.removeClass( "ui-dialog-disabled" );
  5105. }
  5106. break;
  5107. case "draggable":
  5108. isDraggable = uiDialog.is( ":data(draggable)" );
  5109. if ( isDraggable && !value ) {
  5110. uiDialog.draggable( "destroy" );
  5111. }
  5112. if ( !isDraggable && value ) {
  5113. this._makeDraggable();
  5114. }
  5115. break;
  5116. case "position":
  5117. this._position( value );
  5118. break;
  5119. case "resizable":
  5120. // currently resizable, becoming non-resizable
  5121. isResizable = uiDialog.is( ":data(resizable)" );
  5122. if ( isResizable && !value ) {
  5123. uiDialog.resizable( "destroy" );
  5124. }
  5125. // currently resizable, changing handles
  5126. if ( isResizable && typeof value === "string" ) {
  5127. uiDialog.resizable( "option", "handles", value );
  5128. }
  5129. // currently non-resizable, becoming resizable
  5130. if ( !isResizable && value !== false ) {
  5131. this._makeResizable( value );
  5132. }
  5133. break;
  5134. case "title":
  5135. // convert whatever was passed in o a string, for html() to not throw up
  5136. $( ".ui-dialog-title", this.uiDialogTitlebar )
  5137. .html( "" + ( value || "&#160;" ) );
  5138. break;
  5139. }
  5140. this._super( key, value );
  5141. },
  5142. _size: function() {
  5143. /* If the user has resized the dialog, the .ui-dialog and .ui-dialog-content
  5144. * divs will both have width and height set, so we need to reset them
  5145. */
  5146. var nonContentHeight, minContentHeight, autoHeight,
  5147. options = this.options,
  5148. isVisible = this.uiDialog.is( ":visible" );
  5149. // reset content sizing
  5150. this.element.show().css({
  5151. width: "auto",
  5152. minHeight: 0,
  5153. height: 0
  5154. });
  5155. if ( options.minWidth > options.width ) {
  5156. options.width = options.minWidth;
  5157. }
  5158. // reset wrapper sizing
  5159. // determine the height of all the non-content elements
  5160. nonContentHeight = this.uiDialog.css({
  5161. height: "auto",
  5162. width: options.width
  5163. })
  5164. .outerHeight();
  5165. minContentHeight = Math.max( 0, options.minHeight - nonContentHeight );
  5166. if ( options.height === "auto" ) {
  5167. // only needed for IE6 support
  5168. if ( $.support.minHeight ) {
  5169. this.element.css({
  5170. minHeight: minContentHeight,
  5171. height: "auto"
  5172. });
  5173. } else {
  5174. this.uiDialog.show();
  5175. autoHeight = this.element.css( "height", "auto" ).height();
  5176. if ( !isVisible ) {
  5177. this.uiDialog.hide();
  5178. }
  5179. this.element.height( Math.max( autoHeight, minContentHeight ) );
  5180. }
  5181. } else {
  5182. this.element.height( Math.max( options.height - nonContentHeight, 0 ) );
  5183. }
  5184. if (this.uiDialog.is( ":data(resizable)" ) ) {
  5185. this.uiDialog.resizable( "option", "minHeight", this._minHeight() );
  5186. }
  5187. }
  5188. });
  5189. $.extend($.ui.dialog, {
  5190. uuid: 0,
  5191. maxZ: 0,
  5192. getTitleId: function($el) {
  5193. var id = $el.attr( "id" );
  5194. if ( !id ) {
  5195. this.uuid += 1;
  5196. id = this.uuid;
  5197. }
  5198. return "ui-dialog-title-" + id;
  5199. },
  5200. overlay: function( dialog ) {
  5201. this.$el = $.ui.dialog.overlay.create( dialog );
  5202. }
  5203. });
  5204. $.extend( $.ui.dialog.overlay, {
  5205. instances: [],
  5206. // reuse old instances due to IE memory leak with alpha transparency (see #5185)
  5207. oldInstances: [],
  5208. maxZ: 0,
  5209. events: $.map(
  5210. "focus,mousedown,mouseup,keydown,keypress,click".split( "," ),
  5211. function( event ) {
  5212. return event + ".dialog-overlay";
  5213. }
  5214. ).join( " " ),
  5215. create: function( dialog ) {
  5216. if ( this.instances.length === 0 ) {
  5217. // prevent use of anchors and inputs
  5218. // we use a setTimeout in case the overlay is created from an
  5219. // event that we're going to be cancelling (see #2804)
  5220. setTimeout(function() {
  5221. // handle $(el).dialog().dialog('close') (see #4065)
  5222. if ( $.ui.dialog.overlay.instances.length ) {
  5223. $( document ).bind( $.ui.dialog.overlay.events, function( event ) {
  5224. // stop events if the z-index of the target is < the z-index of the overlay
  5225. // we cannot return true when we don't want to cancel the event (#3523)
  5226. if ( $( event.target ).zIndex() < $.ui.dialog.overlay.maxZ ) {
  5227. return false;
  5228. }
  5229. });
  5230. }
  5231. }, 1 );
  5232. // handle window resize
  5233. $( window ).bind( "resize.dialog-overlay", $.ui.dialog.overlay.resize );
  5234. }
  5235. var $el = ( this.oldInstances.pop() || $( "<div>" ).addClass( "ui-widget-overlay" ) );
  5236. // allow closing by pressing the escape key
  5237. $( document ).bind( "keydown.dialog-overlay", function( event ) {
  5238. var instances = $.ui.dialog.overlay.instances;
  5239. // only react to the event if we're the top overlay
  5240. if ( instances.length !== 0 && instances[ instances.length - 1 ] === $el &&
  5241. dialog.options.closeOnEscape && !event.isDefaultPrevented() && event.keyCode &&
  5242. event.keyCode === $.ui.keyCode.ESCAPE ) {
  5243. dialog.close( event );
  5244. event.preventDefault();
  5245. }
  5246. });
  5247. $el.appendTo( document.body ).css({
  5248. width: this.width(),
  5249. height: this.height()
  5250. });
  5251. if ( $.fn.bgiframe ) {
  5252. $el.bgiframe();
  5253. }
  5254. this.instances.push( $el );
  5255. return $el;
  5256. },
  5257. destroy: function( $el ) {
  5258. var indexOf = $.inArray( $el, this.instances ),
  5259. maxZ = 0;
  5260. if ( indexOf !== -1 ) {
  5261. this.oldInstances.push( this.instances.splice( indexOf, 1 )[ 0 ] );
  5262. }
  5263. if ( this.instances.length === 0 ) {
  5264. $( [ document, window ] ).unbind( ".dialog-overlay" );
  5265. }
  5266. $el.height( 0 ).width( 0 ).remove();
  5267. // adjust the maxZ to allow other modal dialogs to continue to work (see #4309)
  5268. $.each( this.instances, function() {
  5269. maxZ = Math.max( maxZ, this.css( "z-index" ) );
  5270. });
  5271. this.maxZ = maxZ;
  5272. },
  5273. height: function() {
  5274. var scrollHeight,
  5275. offsetHeight;
  5276. // handle IE
  5277. if ( $.ui.ie ) {
  5278. scrollHeight = Math.max(
  5279. document.documentElement.scrollHeight,
  5280. document.body.scrollHeight
  5281. );
  5282. offsetHeight = Math.max(
  5283. document.documentElement.offsetHeight,
  5284. document.body.offsetHeight
  5285. );
  5286. if ( scrollHeight < offsetHeight ) {
  5287. return $( window ).height() + "px";
  5288. } else {
  5289. return scrollHeight + "px";
  5290. }
  5291. // handle "good" browsers
  5292. } else {
  5293. return $( document ).height() + "px";
  5294. }
  5295. },
  5296. width: function() {
  5297. var scrollWidth,
  5298. offsetWidth;
  5299. // handle IE
  5300. if ( $.ui.ie ) {
  5301. scrollWidth = Math.max(
  5302. document.documentElement.scrollWidth,
  5303. document.body.scrollWidth
  5304. );
  5305. offsetWidth = Math.max(
  5306. document.documentElement.offsetWidth,
  5307. document.body.offsetWidth
  5308. );
  5309. if ( scrollWidth < offsetWidth ) {
  5310. return $( window ).width() + "px";
  5311. } else {
  5312. return scrollWidth + "px";
  5313. }
  5314. // handle "good" browsers
  5315. } else {
  5316. return $( document ).width() + "px";
  5317. }
  5318. },
  5319. resize: function() {
  5320. /* If the dialog is draggable and the user drags it past the
  5321. * right edge of the window, the document becomes wider so we
  5322. * need to stretch the overlay. If the user then drags the
  5323. * dialog back to the left, the document will become narrower,
  5324. * so we need to shrink the overlay to the appropriate size.
  5325. * This is handled by shrinking the overlay before setting it
  5326. * to the full document size.
  5327. */
  5328. var $overlays = $( [] );
  5329. $.each( $.ui.dialog.overlay.instances, function() {
  5330. $overlays = $overlays.add( this );
  5331. });
  5332. $overlays.css({
  5333. width: 0,
  5334. height: 0
  5335. }).css({
  5336. width: $.ui.dialog.overlay.width(),
  5337. height: $.ui.dialog.overlay.height()
  5338. });
  5339. }
  5340. });
  5341. $.extend( $.ui.dialog.overlay.prototype, {
  5342. destroy: function() {
  5343. $.ui.dialog.overlay.destroy( this.$el );
  5344. }
  5345. });
  5346. }( jQuery ) );
  5347. (function( $, undefined ) {
  5348. $.widget("ui.draggable", $.ui.mouse, {
  5349. version: "1.9.2",
  5350. widgetEventPrefix: "drag",
  5351. options: {
  5352. addClasses: true,
  5353. appendTo: "parent",
  5354. axis: false,
  5355. connectToSortable: false,
  5356. containment: false,
  5357. cursor: "auto",
  5358. cursorAt: false,
  5359. grid: false,
  5360. handle: false,
  5361. helper: "original",
  5362. iframeFix: false,
  5363. opacity: false,
  5364. refreshPositions: false,
  5365. revert: false,
  5366. revertDuration: 500,
  5367. scope: "default",
  5368. scroll: true,
  5369. scrollSensitivity: 20,
  5370. scrollSpeed: 20,
  5371. snap: false,
  5372. snapMode: "both",
  5373. snapTolerance: 20,
  5374. stack: false,
  5375. zIndex: false
  5376. },
  5377. _create: function() {
  5378. if (this.options.helper == 'original' && !(/^(?:r|a|f)/).test(this.element.css("position")))
  5379. this.element[0].style.position = 'relative';
  5380. (this.options.addClasses && this.element.addClass("ui-draggable"));
  5381. (this.options.disabled && this.element.addClass("ui-draggable-disabled"));
  5382. this._mouseInit();
  5383. },
  5384. _destroy: function() {
  5385. this.element.removeClass( "ui-draggable ui-draggable-dragging ui-draggable-disabled" );
  5386. this._mouseDestroy();
  5387. },
  5388. _mouseCapture: function(event) {
  5389. var o = this.options;
  5390. // among others, prevent a drag on a resizable-handle
  5391. if (this.helper || o.disabled || $(event.target).is('.ui-resizable-handle'))
  5392. return false;
  5393. //Quit if we're not on a valid handle
  5394. this.handle = this._getHandle(event);
  5395. if (!this.handle)
  5396. return false;
  5397. $(o.iframeFix === true ? "iframe" : o.iframeFix).each(function() {
  5398. $('<div class="ui-draggable-iframeFix" style="background: #fff;"></div>')
  5399. .css({
  5400. width: this.offsetWidth+"px", height: this.offsetHeight+"px",
  5401. position: "absolute", opacity: "0.001", zIndex: 1000
  5402. })
  5403. .css($(this).offset())
  5404. .appendTo("body");
  5405. });
  5406. return true;
  5407. },
  5408. _mouseStart: function(event) {
  5409. var o = this.options;
  5410. //Create and append the visible helper
  5411. this.helper = this._createHelper(event);
  5412. this.helper.addClass("ui-draggable-dragging");
  5413. //Cache the helper size
  5414. this._cacheHelperProportions();
  5415. //If ddmanager is used for droppables, set the global draggable
  5416. if($.ui.ddmanager)
  5417. $.ui.ddmanager.current = this;
  5418. /*
  5419. * - Position generation -
  5420. * This block generates everything position related - it's the core of draggables.
  5421. */
  5422. //Cache the margins of the original element
  5423. this._cacheMargins();
  5424. //Store the helper's css position
  5425. this.cssPosition = this.helper.css("position");
  5426. this.scrollParent = this.helper.scrollParent();
  5427. //The element's absolute position on the page minus margins
  5428. this.offset = this.positionAbs = this.element.offset();
  5429. this.offset = {
  5430. top: this.offset.top - this.margins.top,
  5431. left: this.offset.left - this.margins.left
  5432. };
  5433. $.extend(this.offset, {
  5434. click: { //Where the click happened, relative to the element
  5435. left: event.pageX - this.offset.left,
  5436. top: event.pageY - this.offset.top
  5437. },
  5438. parent: this._getParentOffset(),
  5439. relative: this._getRelativeOffset() //This is a relative to absolute position minus the actual position calculation - only used for relative positioned helper
  5440. });
  5441. //Generate the original position
  5442. this.originalPosition = this.position = this._generatePosition(event);
  5443. this.originalPageX = event.pageX;
  5444. this.originalPageY = event.pageY;
  5445. //Adjust the mouse offset relative to the helper if 'cursorAt' is supplied
  5446. (o.cursorAt && this._adjustOffsetFromHelper(o.cursorAt));
  5447. //Set a containment if given in the options
  5448. if(o.containment)
  5449. this._setContainment();
  5450. //Trigger event + callbacks
  5451. if(this._trigger("start", event) === false) {
  5452. this._clear();
  5453. return false;
  5454. }
  5455. //Recache the helper size
  5456. this._cacheHelperProportions();
  5457. //Prepare the droppable offsets
  5458. if ($.ui.ddmanager && !o.dropBehaviour)
  5459. $.ui.ddmanager.prepareOffsets(this, event);
  5460. this._mouseDrag(event, true); //Execute the drag once - this causes the helper not to be visible before getting its correct position
  5461. //If the ddmanager is used for droppables, inform the manager that dragging has started (see #5003)
  5462. if ( $.ui.ddmanager ) $.ui.ddmanager.dragStart(this, event);
  5463. return true;
  5464. },
  5465. _mouseDrag: function(event, noPropagation) {
  5466. //Compute the helpers position
  5467. this.position = this._generatePosition(event);
  5468. this.positionAbs = this._convertPositionTo("absolute");
  5469. //Call plugins and callbacks and use the resulting position if something is returned
  5470. if (!noPropagation) {
  5471. var ui = this._uiHash();
  5472. if(this._trigger('drag', event, ui) === false) {
  5473. this._mouseUp({});
  5474. return false;
  5475. }
  5476. this.position = ui.position;
  5477. }
  5478. if(!this.options.axis || this.options.axis != "y") this.helper[0].style.left = this.position.left+'px';
  5479. if(!this.options.axis || this.options.axis != "x") this.helper[0].style.top = this.position.top+'px';
  5480. if($.ui.ddmanager) $.ui.ddmanager.drag(this, event);
  5481. return false;
  5482. },
  5483. _mouseStop: function(event) {
  5484. //If we are using droppables, inform the manager about the drop
  5485. var dropped = false;
  5486. if ($.ui.ddmanager && !this.options.dropBehaviour)
  5487. dropped = $.ui.ddmanager.drop(this, event);
  5488. //if a drop comes from outside (a sortable)
  5489. if(this.dropped) {
  5490. dropped = this.dropped;
  5491. this.dropped = false;
  5492. }
  5493. //if the original element is no longer in the DOM don't bother to continue (see #8269)
  5494. var element = this.element[0], elementInDom = false;
  5495. while ( element && (element = element.parentNode) ) {
  5496. if (element == document ) {
  5497. elementInDom = true;
  5498. }
  5499. }
  5500. if ( !elementInDom && this.options.helper === "original" )
  5501. return false;
  5502. 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))) {
  5503. var that = this;
  5504. $(this.helper).animate(this.originalPosition, parseInt(this.options.revertDuration, 10), function() {
  5505. if(that._trigger("stop", event) !== false) {
  5506. that._clear();
  5507. }
  5508. });
  5509. } else {
  5510. if(this._trigger("stop", event) !== false) {
  5511. this._clear();
  5512. }
  5513. }
  5514. return false;
  5515. },
  5516. _mouseUp: function(event) {
  5517. //Remove frame helpers
  5518. $("div.ui-draggable-iframeFix").each(function() {
  5519. this.parentNode.removeChild(this);
  5520. });
  5521. //If the ddmanager is used for droppables, inform the manager that dragging has stopped (see #5003)
  5522. if( $.ui.ddmanager ) $.ui.ddmanager.dragStop(this, event);
  5523. return $.ui.mouse.prototype._mouseUp.call(this, event);
  5524. },
  5525. cancel: function() {
  5526. if(this.helper.is(".ui-draggable-dragging")) {
  5527. this._mouseUp({});
  5528. } else {
  5529. this._clear();
  5530. }
  5531. return this;
  5532. },
  5533. _getHandle: function(event) {
  5534. var handle = !this.options.handle || !$(this.options.handle, this.element).length ? true : false;
  5535. $(this.options.handle, this.element)
  5536. .find("*")
  5537. .andSelf()
  5538. .each(function() {
  5539. if(this == event.target) handle = true;
  5540. });
  5541. return handle;
  5542. },
  5543. _createHelper: function(event) {
  5544. var o = this.options;
  5545. var helper = $.isFunction(o.helper) ? $(o.helper.apply(this.element[0], [event])) : (o.helper == 'clone' ? this.element.clone().removeAttr('id') : this.element);
  5546. if(!helper.parents('body').length)
  5547. helper.appendTo((o.appendTo == 'parent' ? this.element[0].parentNode : o.appendTo));
  5548. if(helper[0] != this.element[0] && !(/(fixed|absolute)/).test(helper.css("position")))
  5549. helper.css("position", "absolute");
  5550. return helper;
  5551. },
  5552. _adjustOffsetFromHelper: function(obj) {
  5553. if (typeof obj == 'string') {
  5554. obj = obj.split(' ');
  5555. }
  5556. if ($.isArray(obj)) {
  5557. obj = {left: +obj[0], top: +obj[1] || 0};
  5558. }
  5559. if ('left' in obj) {
  5560. this.offset.click.left = obj.left + this.margins.left;
  5561. }
  5562. if ('right' in obj) {
  5563. this.offset.click.left = this.helperProportions.width - obj.right + this.margins.left;
  5564. }
  5565. if ('top' in obj) {
  5566. this.offset.click.top = obj.top + this.margins.top;
  5567. }
  5568. if ('bottom' in obj) {
  5569. this.offset.click.top = this.helperProportions.height - obj.bottom + this.margins.top;
  5570. }
  5571. },
  5572. _getParentOffset: function() {
  5573. //Get the offsetParent and cache its position
  5574. this.offsetParent = this.helper.offsetParent();
  5575. var po = this.offsetParent.offset();
  5576. // This is a special case where we need to modify a offset calculated on start, since the following happened:
  5577. // 1. The position of the helper is absolute, so it's position is calculated based on the next positioned parent
  5578. // 2. The actual offset parent is a child of the scroll parent, and the scroll parent isn't the document, which means that
  5579. // the scroll is included in the initial calculation of the offset of the parent, and never recalculated upon drag
  5580. if(this.cssPosition == 'absolute' && this.scrollParent[0] != document && $.contains(this.scrollParent[0], this.offsetParent[0])) {
  5581. po.left += this.scrollParent.scrollLeft();
  5582. po.top += this.scrollParent.scrollTop();
  5583. }
  5584. if((this.offsetParent[0] == document.body) //This needs to be actually done for all browsers, since pageX/pageY includes this information
  5585. || (this.offsetParent[0].tagName && this.offsetParent[0].tagName.toLowerCase() == 'html' && $.ui.ie)) //Ugly IE fix
  5586. po = { top: 0, left: 0 };
  5587. return {
  5588. top: po.top + (parseInt(this.offsetParent.css("borderTopWidth"),10) || 0),
  5589. left: po.left + (parseInt(this.offsetParent.css("borderLeftWidth"),10) || 0)
  5590. };
  5591. },
  5592. _getRelativeOffset: function() {
  5593. if(this.cssPosition == "relative") {
  5594. var p = this.element.position();
  5595. return {
  5596. top: p.top - (parseInt(this.helper.css("top"),10) || 0) + this.scrollParent.scrollTop(),
  5597. left: p.left - (parseInt(this.helper.css("left"),10) || 0) + this.scrollParent.scrollLeft()
  5598. };
  5599. } else {
  5600. return { top: 0, left: 0 };
  5601. }
  5602. },
  5603. _cacheMargins: function() {
  5604. this.margins = {
  5605. left: (parseInt(this.element.css("marginLeft"),10) || 0),
  5606. top: (parseInt(this.element.css("marginTop"),10) || 0),
  5607. right: (parseInt(this.element.css("marginRight"),10) || 0),
  5608. bottom: (parseInt(this.element.css("marginBottom"),10) || 0)
  5609. };
  5610. },
  5611. _cacheHelperProportions: function() {
  5612. this.helperProportions = {
  5613. width: this.helper.outerWidth(),
  5614. height: this.helper.outerHeight()
  5615. };
  5616. },
  5617. _setContainment: function() {
  5618. var o = this.options;
  5619. if(o.containment == 'parent') o.containment = this.helper[0].parentNode;
  5620. if(o.containment == 'document' || o.containment == 'window') this.containment = [
  5621. o.containment == 'document' ? 0 : $(window).scrollLeft() - this.offset.relative.left - this.offset.parent.left,
  5622. o.containment == 'document' ? 0 : $(window).scrollTop() - this.offset.relative.top - this.offset.parent.top,
  5623. (o.containment == 'document' ? 0 : $(window).scrollLeft()) + $(o.containment == 'document' ? document : window).width() - this.helperProportions.width - this.margins.left,
  5624. (o.containment == 'document' ? 0 : $(window).scrollTop()) + ($(o.containment == 'document' ? document : window).height() || document.body.parentNode.scrollHeight) - this.helperProportions.height - this.margins.top
  5625. ];
  5626. if(!(/^(document|window|parent)$/).test(o.containment) && o.containment.constructor != Array) {
  5627. var c = $(o.containment);
  5628. var ce = c[0]; if(!ce) return;
  5629. var co = c.offset();
  5630. var over = ($(ce).css("overflow") != 'hidden');
  5631. this.containment = [
  5632. (parseInt($(ce).css("borderLeftWidth"),10) || 0) + (parseInt($(ce).css("paddingLeft"),10) || 0),
  5633. (parseInt($(ce).css("borderTopWidth"),10) || 0) + (parseInt($(ce).css("paddingTop"),10) || 0),
  5634. (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,
  5635. (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
  5636. ];
  5637. this.relative_container = c;
  5638. } else if(o.containment.constructor == Array) {
  5639. this.containment = o.containment;
  5640. }
  5641. },
  5642. _convertPositionTo: function(d, pos) {
  5643. if(!pos) pos = this.position;
  5644. var mod = d == "absolute" ? 1 : -1;
  5645. var o = this.options, 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);
  5646. return {
  5647. top: (
  5648. pos.top // The absolute mouse position
  5649. + this.offset.relative.top * mod // Only for relative positioned nodes: Relative offset from element to offset parent
  5650. + this.offset.parent.top * mod // The offsetParent's offset without borders (offset + border)
  5651. - ( ( this.cssPosition == 'fixed' ? -this.scrollParent.scrollTop() : ( scrollIsRootNode ? 0 : scroll.scrollTop() ) ) * mod)
  5652. ),
  5653. left: (
  5654. pos.left // The absolute mouse position
  5655. + this.offset.relative.left * mod // Only for relative positioned nodes: Relative offset from element to offset parent
  5656. + this.offset.parent.left * mod // The offsetParent's offset without borders (offset + border)
  5657. - ( ( this.cssPosition == 'fixed' ? -this.scrollParent.scrollLeft() : scrollIsRootNode ? 0 : scroll.scrollLeft() ) * mod)
  5658. )
  5659. };
  5660. },
  5661. _generatePosition: function(event) {
  5662. var o = this.options, 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);
  5663. var pageX = event.pageX;
  5664. var pageY = event.pageY;
  5665. /*
  5666. * - Position constraining -
  5667. * Constrain the position to a mix of grid, containment.
  5668. */
  5669. if(this.originalPosition) { //If we are not dragging yet, we won't check for options
  5670. var containment;
  5671. if(this.containment) {
  5672. if (this.relative_container){
  5673. var co = this.relative_container.offset();
  5674. containment = [ this.containment[0] + co.left,
  5675. this.containment[1] + co.top,
  5676. this.containment[2] + co.left,
  5677. this.containment[3] + co.top ];
  5678. }
  5679. else {
  5680. containment = this.containment;
  5681. }
  5682. if(event.pageX - this.offset.click.left < containment[0]) pageX = containment[0] + this.offset.click.left;
  5683. if(event.pageY - this.offset.click.top < containment[1]) pageY = containment[1] + this.offset.click.top;
  5684. if(event.pageX - this.offset.click.left > containment[2]) pageX = containment[2] + this.offset.click.left;
  5685. if(event.pageY - this.offset.click.top > containment[3]) pageY = containment[3] + this.offset.click.top;
  5686. }
  5687. if(o.grid) {
  5688. //Check for grid elements set to 0 to prevent divide by 0 error causing invalid argument errors in IE (see ticket #6950)
  5689. var top = o.grid[1] ? this.originalPageY + Math.round((pageY - this.originalPageY) / o.grid[1]) * o.grid[1] : this.originalPageY;
  5690. 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;
  5691. var left = o.grid[0] ? this.originalPageX + Math.round((pageX - this.originalPageX) / o.grid[0]) * o.grid[0] : this.originalPageX;
  5692. 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;
  5693. }
  5694. }
  5695. return {
  5696. top: (
  5697. pageY // The absolute mouse position
  5698. - this.offset.click.top // Click offset (relative to the element)
  5699. - this.offset.relative.top // Only for relative positioned nodes: Relative offset from element to offset parent
  5700. - this.offset.parent.top // The offsetParent's offset without borders (offset + border)
  5701. + ( ( this.cssPosition == 'fixed' ? -this.scrollParent.scrollTop() : ( scrollIsRootNode ? 0 : scroll.scrollTop() ) ))
  5702. ),
  5703. left: (
  5704. pageX // The absolute mouse position
  5705. - this.offset.click.left // Click offset (relative to the element)
  5706. - this.offset.relative.left // Only for relative positioned nodes: Relative offset from element to offset parent
  5707. - this.offset.parent.left // The offsetParent's offset without borders (offset + border)
  5708. + ( ( this.cssPosition == 'fixed' ? -this.scrollParent.scrollLeft() : scrollIsRootNode ? 0 : scroll.scrollLeft() ))
  5709. )
  5710. };
  5711. },
  5712. _clear: function() {
  5713. this.helper.removeClass("ui-draggable-dragging");
  5714. if(this.helper[0] != this.element[0] && !this.cancelHelperRemoval) this.helper.remove();
  5715. //if($.ui.ddmanager) $.ui.ddmanager.current = null;
  5716. this.helper = null;
  5717. this.cancelHelperRemoval = false;
  5718. },
  5719. // From now on bulk stuff - mainly helpers
  5720. _trigger: function(type, event, ui) {
  5721. ui = ui || this._uiHash();
  5722. $.ui.plugin.call(this, type, [event, ui]);
  5723. if(type == "drag") this.positionAbs = this._convertPositionTo("absolute"); //The absolute position has to be recalculated after plugins
  5724. return $.Widget.prototype._trigger.call(this, type, event, ui);
  5725. },
  5726. plugins: {},
  5727. _uiHash: function(event) {
  5728. return {
  5729. helper: this.helper,
  5730. position: this.position,
  5731. originalPosition: this.originalPosition,
  5732. offset: this.positionAbs
  5733. };
  5734. }
  5735. });
  5736. $.ui.plugin.add("draggable", "connectToSortable", {
  5737. start: function(event, ui) {
  5738. var inst = $(this).data("draggable"), o = inst.options,
  5739. uiSortable = $.extend({}, ui, { item: inst.element });
  5740. inst.sortables = [];
  5741. $(o.connectToSortable).each(function() {
  5742. var sortable = $.data(this, 'sortable');
  5743. if (sortable && !sortable.options.disabled) {
  5744. inst.sortables.push({
  5745. instance: sortable,
  5746. shouldRevert: sortable.options.revert
  5747. });
  5748. 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).
  5749. sortable._trigger("activate", event, uiSortable);
  5750. }
  5751. });
  5752. },
  5753. stop: function(event, ui) {
  5754. //If we are still over the sortable, we fake the stop event of the sortable, but also remove helper
  5755. var inst = $(this).data("draggable"),
  5756. uiSortable = $.extend({}, ui, { item: inst.element });
  5757. $.each(inst.sortables, function() {
  5758. if(this.instance.isOver) {
  5759. this.instance.isOver = 0;
  5760. inst.cancelHelperRemoval = true; //Don't remove the helper in the draggable instance
  5761. this.instance.cancelHelperRemoval = false; //Remove it in the sortable instance (so sortable plugins like revert still work)
  5762. //The sortable revert is supported, and we have to set a temporary dropped variable on the draggable to support revert: 'valid/invalid'
  5763. if(this.shouldRevert) this.instance.options.revert = true;
  5764. //Trigger the stop of the sortable
  5765. this.instance._mouseStop(event);
  5766. this.instance.options.helper = this.instance.options._helper;
  5767. //If the helper has been the original item, restore properties in the sortable
  5768. if(inst.options.helper == 'original')
  5769. this.instance.currentItem.css({ top: 'auto', left: 'auto' });
  5770. } else {
  5771. this.instance.cancelHelperRemoval = false; //Remove the helper in the sortable instance
  5772. this.instance._trigger("deactivate", event, uiSortable);
  5773. }
  5774. });
  5775. },
  5776. drag: function(event, ui) {
  5777. var inst = $(this).data("draggable"), that = this;
  5778. var checkPos = function(o) {
  5779. var dyClick = this.offset.click.top, dxClick = this.offset.click.left;
  5780. var helperTop = this.positionAbs.top, helperLeft = this.positionAbs.left;
  5781. var itemHeight = o.height, itemWidth = o.width;
  5782. var itemTop = o.top, itemLeft = o.left;
  5783. return $.ui.isOver(helperTop + dyClick, helperLeft + dxClick, itemTop, itemLeft, itemHeight, itemWidth);
  5784. };
  5785. $.each(inst.sortables, function(i) {
  5786. var innermostIntersecting = false;
  5787. var thisSortable = this;
  5788. //Copy over some variables to allow calling the sortable's native _intersectsWith
  5789. this.instance.positionAbs = inst.positionAbs;
  5790. this.instance.helperProportions = inst.helperProportions;
  5791. this.instance.offset.click = inst.offset.click;
  5792. if(this.instance._intersectsWith(this.instance.containerCache)) {
  5793. innermostIntersecting = true;
  5794. $.each(inst.sortables, function () {
  5795. this.instance.positionAbs = inst.positionAbs;
  5796. this.instance.helperProportions = inst.helperProportions;
  5797. this.instance.offset.click = inst.offset.click;
  5798. if (this != thisSortable
  5799. && this.instance._intersectsWith(this.instance.containerCache)
  5800. && $.ui.contains(thisSortable.instance.element[0], this.instance.element[0]))
  5801. innermostIntersecting = false;
  5802. return innermostIntersecting;
  5803. });
  5804. }
  5805. if(innermostIntersecting) {
  5806. //If it intersects, we use a little isOver variable and set it once, so our move-in stuff gets fired only once
  5807. if(!this.instance.isOver) {
  5808. this.instance.isOver = 1;
  5809. //Now we fake the start of dragging for the sortable instance,
  5810. //by cloning the list group item, appending it to the sortable and using it as inst.currentItem
  5811. //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)
  5812. this.instance.currentItem = $(that).clone().removeAttr('id').appendTo(this.instance.element).data("sortable-item", true);
  5813. this.instance.options._helper = this.instance.options.helper; //Store helper option to later restore it
  5814. this.instance.options.helper = function() { return ui.helper[0]; };
  5815. event.target = this.instance.currentItem[0];
  5816. this.instance._mouseCapture(event, true);
  5817. this.instance._mouseStart(event, true, true);
  5818. //Because the browser event is way off the new appended portlet, we modify a couple of variables to reflect the changes
  5819. this.instance.offset.click.top = inst.offset.click.top;
  5820. this.instance.offset.click.left = inst.offset.click.left;
  5821. this.instance.offset.parent.left -= inst.offset.parent.left - this.instance.offset.parent.left;
  5822. this.instance.offset.parent.top -= inst.offset.parent.top - this.instance.offset.parent.top;
  5823. inst._trigger("toSortable", event);
  5824. inst.dropped = this.instance.element; //draggable revert needs that
  5825. //hack so receive/update callbacks work (mostly)
  5826. inst.currentItem = inst.element;
  5827. this.instance.fromOutside = inst;
  5828. }
  5829. //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
  5830. if(this.instance.currentItem) this.instance._mouseDrag(event);
  5831. } else {
  5832. //If it doesn't intersect with the sortable, and it intersected before,
  5833. //we fake the drag stop of the sortable, but make sure it doesn't remove the helper by using cancelHelperRemoval
  5834. if(this.instance.isOver) {
  5835. this.instance.isOver = 0;
  5836. this.instance.cancelHelperRemoval = true;
  5837. //Prevent reverting on this forced stop
  5838. this.instance.options.revert = false;
  5839. // The out event needs to be triggered independently
  5840. this.instance._trigger('out', event, this.instance._uiHash(this.instance));
  5841. this.instance._mouseStop(event, true);
  5842. this.instance.options.helper = this.instance.options._helper;
  5843. //Now we remove our currentItem, the list group clone again, and the placeholder, and animate the helper back to it's original size
  5844. this.instance.currentItem.remove();
  5845. if(this.instance.placeholder) this.instance.placeholder.remove();
  5846. inst._trigger("fromSortable", event);
  5847. inst.dropped = false; //draggable revert needs that
  5848. }
  5849. };
  5850. });
  5851. }
  5852. });
  5853. $.ui.plugin.add("draggable", "cursor", {
  5854. start: function(event, ui) {
  5855. var t = $('body'), o = $(this).data('draggable').options;
  5856. if (t.css("cursor")) o._cursor = t.css("cursor");
  5857. t.css("cursor", o.cursor);
  5858. },
  5859. stop: function(event, ui) {
  5860. var o = $(this).data('draggable').options;
  5861. if (o._cursor) $('body').css("cursor", o._cursor);
  5862. }
  5863. });
  5864. $.ui.plugin.add("draggable", "opacity", {
  5865. start: function(event, ui) {
  5866. var t = $(ui.helper), o = $(this).data('draggable').options;
  5867. if(t.css("opacity")) o._opacity = t.css("opacity");
  5868. t.css('opacity', o.opacity);
  5869. },
  5870. stop: function(event, ui) {
  5871. var o = $(this).data('draggable').options;
  5872. if(o._opacity) $(ui.helper).css('opacity', o._opacity);
  5873. }
  5874. });
  5875. $.ui.plugin.add("draggable", "scroll", {
  5876. start: function(event, ui) {
  5877. var i = $(this).data("draggable");
  5878. if(i.scrollParent[0] != document && i.scrollParent[0].tagName != 'HTML') i.overflowOffset = i.scrollParent.offset();
  5879. },
  5880. drag: function(event, ui) {
  5881. var i = $(this).data("draggable"), o = i.options, scrolled = false;
  5882. if(i.scrollParent[0] != document && i.scrollParent[0].tagName != 'HTML') {
  5883. if(!o.axis || o.axis != 'x') {
  5884. if((i.overflowOffset.top + i.scrollParent[0].offsetHeight) - event.pageY < o.scrollSensitivity)
  5885. i.scrollParent[0].scrollTop = scrolled = i.scrollParent[0].scrollTop + o.scrollSpeed;
  5886. else if(event.pageY - i.overflowOffset.top < o.scrollSensitivity)
  5887. i.scrollParent[0].scrollTop = scrolled = i.scrollParent[0].scrollTop - o.scrollSpeed;
  5888. }
  5889. if(!o.axis || o.axis != 'y') {
  5890. if((i.overflowOffset.left + i.scrollParent[0].offsetWidth) - event.pageX < o.scrollSensitivity)
  5891. i.scrollParent[0].scrollLeft = scrolled = i.scrollParent[0].scrollLeft + o.scrollSpeed;
  5892. else if(event.pageX - i.overflowOffset.left < o.scrollSensitivity)
  5893. i.scrollParent[0].scrollLeft = scrolled = i.scrollParent[0].scrollLeft - o.scrollSpeed;
  5894. }
  5895. } else {
  5896. if(!o.axis || o.axis != 'x') {
  5897. if(event.pageY - $(document).scrollTop() < o.scrollSensitivity)
  5898. scrolled = $(document).scrollTop($(document).scrollTop() - o.scrollSpeed);
  5899. else if($(window).height() - (event.pageY - $(document).scrollTop()) < o.scrollSensitivity)
  5900. scrolled = $(document).scrollTop($(document).scrollTop() + o.scrollSpeed);
  5901. }
  5902. if(!o.axis || o.axis != 'y') {
  5903. if(event.pageX - $(document).scrollLeft() < o.scrollSensitivity)
  5904. scrolled = $(document).scrollLeft($(document).scrollLeft() - o.scrollSpeed);
  5905. else if($(window).width() - (event.pageX - $(document).scrollLeft()) < o.scrollSensitivity)
  5906. scrolled = $(document).scrollLeft($(document).scrollLeft() + o.scrollSpeed);
  5907. }
  5908. }
  5909. if(scrolled !== false && $.ui.ddmanager && !o.dropBehaviour)
  5910. $.ui.ddmanager.prepareOffsets(i, event);
  5911. }
  5912. });
  5913. $.ui.plugin.add("draggable", "snap", {
  5914. start: function(event, ui) {
  5915. var i = $(this).data("draggable"), o = i.options;
  5916. i.snapElements = [];
  5917. $(o.snap.constructor != String ? ( o.snap.items || ':data(draggable)' ) : o.snap).each(function() {
  5918. var $t = $(this); var $o = $t.offset();
  5919. if(this != i.element[0]) i.snapElements.push({
  5920. item: this,
  5921. width: $t.outerWidth(), height: $t.outerHeight(),
  5922. top: $o.top, left: $o.left
  5923. });
  5924. });
  5925. },
  5926. drag: function(event, ui) {
  5927. var inst = $(this).data("draggable"), o = inst.options;
  5928. var d = o.snapTolerance;
  5929. var x1 = ui.offset.left, x2 = x1 + inst.helperProportions.width,
  5930. y1 = ui.offset.top, y2 = y1 + inst.helperProportions.height;
  5931. for (var i = inst.snapElements.length - 1; i >= 0; i--){
  5932. var l = inst.snapElements[i].left, r = l + inst.snapElements[i].width,
  5933. t = inst.snapElements[i].top, b = t + inst.snapElements[i].height;
  5934. //Yes, I know, this is insane ;)
  5935. 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))) {
  5936. if(inst.snapElements[i].snapping) (inst.options.snap.release && inst.options.snap.release.call(inst.element, event, $.extend(inst._uiHash(), { snapItem: inst.snapElements[i].item })));
  5937. inst.snapElements[i].snapping = false;
  5938. continue;
  5939. }
  5940. if(o.snapMode != 'inner') {
  5941. var ts = Math.abs(t - y2) <= d;
  5942. var bs = Math.abs(b - y1) <= d;
  5943. var ls = Math.abs(l - x2) <= d;
  5944. var rs = Math.abs(r - x1) <= d;
  5945. if(ts) ui.position.top = inst._convertPositionTo("relative", { top: t - inst.helperProportions.height, left: 0 }).top - inst.margins.top;
  5946. if(bs) ui.position.top = inst._convertPositionTo("relative", { top: b, left: 0 }).top - inst.margins.top;
  5947. if(ls) ui.position.left = inst._convertPositionTo("relative", { top: 0, left: l - inst.helperProportions.width }).left - inst.margins.left;
  5948. if(rs) ui.position.left = inst._convertPositionTo("relative", { top: 0, left: r }).left - inst.margins.left;
  5949. }
  5950. var first = (ts || bs || ls || rs);
  5951. if(o.snapMode != 'outer') {
  5952. var ts = Math.abs(t - y1) <= d;
  5953. var bs = Math.abs(b - y2) <= d;
  5954. var ls = Math.abs(l - x1) <= d;
  5955. var rs = Math.abs(r - x2) <= d;
  5956. if(ts) ui.position.top = inst._convertPositionTo("relative", { top: t, left: 0 }).top - inst.margins.top;
  5957. if(bs) ui.position.top = inst._convertPositionTo("relative", { top: b - inst.helperProportions.height, left: 0 }).top - inst.margins.top;
  5958. if(ls) ui.position.left = inst._convertPositionTo("relative", { top: 0, left: l }).left - inst.margins.left;
  5959. if(rs) ui.position.left = inst._convertPositionTo("relative", { top: 0, left: r - inst.helperProportions.width }).left - inst.margins.left;
  5960. }
  5961. if(!inst.snapElements[i].snapping && (ts || bs || ls || rs || first))
  5962. (inst.options.snap.snap && inst.options.snap.snap.call(inst.element, event, $.extend(inst._uiHash(), { snapItem: inst.snapElements[i].item })));
  5963. inst.snapElements[i].snapping = (ts || bs || ls || rs || first);
  5964. };
  5965. }
  5966. });
  5967. $.ui.plugin.add("draggable", "stack", {
  5968. start: function(event, ui) {
  5969. var o = $(this).data("draggable").options;
  5970. var group = $.makeArray($(o.stack)).sort(function(a,b) {
  5971. return (parseInt($(a).css("zIndex"),10) || 0) - (parseInt($(b).css("zIndex"),10) || 0);
  5972. });
  5973. if (!group.length) { return; }
  5974. var min = parseInt(group[0].style.zIndex) || 0;
  5975. $(group).each(function(i) {
  5976. this.style.zIndex = min + i;
  5977. });
  5978. this[0].style.zIndex = min + group.length;
  5979. }
  5980. });
  5981. $.ui.plugin.add("draggable", "zIndex", {
  5982. start: function(event, ui) {
  5983. var t = $(ui.helper), o = $(this).data("draggable").options;
  5984. if(t.css("zIndex")) o._zIndex = t.css("zIndex");
  5985. t.css('zIndex', o.zIndex);
  5986. },
  5987. stop: function(event, ui) {
  5988. var o = $(this).data("draggable").options;
  5989. if(o._zIndex) $(ui.helper).css('zIndex', o._zIndex);
  5990. }
  5991. });
  5992. })(jQuery);
  5993. (function( $, undefined ) {
  5994. $.widget("ui.droppable", {
  5995. version: "1.9.2",
  5996. widgetEventPrefix: "drop",
  5997. options: {
  5998. accept: '*',
  5999. activeClass: false,
  6000. addClasses: true,
  6001. greedy: false,
  6002. hoverClass: false,
  6003. scope: 'default',
  6004. tolerance: 'intersect'
  6005. },
  6006. _create: function() {
  6007. var o = this.options, accept = o.accept;
  6008. this.isover = 0; this.isout = 1;
  6009. this.accept = $.isFunction(accept) ? accept : function(d) {
  6010. return d.is(accept);
  6011. };
  6012. //Store the droppable's proportions
  6013. this.proportions = { width: this.element[0].offsetWidth, height: this.element[0].offsetHeight };
  6014. // Add the reference and positions to the manager
  6015. $.ui.ddmanager.droppables[o.scope] = $.ui.ddmanager.droppables[o.scope] || [];
  6016. $.ui.ddmanager.droppables[o.scope].push(this);
  6017. (o.addClasses && this.element.addClass("ui-droppable"));
  6018. },
  6019. _destroy: function() {
  6020. var drop = $.ui.ddmanager.droppables[this.options.scope];
  6021. for ( var i = 0; i < drop.length; i++ )
  6022. if ( drop[i] == this )
  6023. drop.splice(i, 1);
  6024. this.element.removeClass("ui-droppable ui-droppable-disabled");
  6025. },
  6026. _setOption: function(key, value) {
  6027. if(key == 'accept') {
  6028. this.accept = $.isFunction(value) ? value : function(d) {
  6029. return d.is(value);
  6030. };
  6031. }
  6032. $.Widget.prototype._setOption.apply(this, arguments);
  6033. },
  6034. _activate: function(event) {
  6035. var draggable = $.ui.ddmanager.current;
  6036. if(this.options.activeClass) this.element.addClass(this.options.activeClass);
  6037. (draggable && this._trigger('activate', event, this.ui(draggable)));
  6038. },
  6039. _deactivate: function(event) {
  6040. var draggable = $.ui.ddmanager.current;
  6041. if(this.options.activeClass) this.element.removeClass(this.options.activeClass);
  6042. (draggable && this._trigger('deactivate', event, this.ui(draggable)));
  6043. },
  6044. _over: function(event) {
  6045. var draggable = $.ui.ddmanager.current;
  6046. if (!draggable || (draggable.currentItem || draggable.element)[0] == this.element[0]) return; // Bail if draggable and droppable are same element
  6047. if (this.accept.call(this.element[0],(draggable.currentItem || draggable.element))) {
  6048. if(this.options.hoverClass) this.element.addClass(this.options.hoverClass);
  6049. this._trigger('over', event, this.ui(draggable));
  6050. }
  6051. },
  6052. _out: function(event) {
  6053. var draggable = $.ui.ddmanager.current;
  6054. if (!draggable || (draggable.currentItem || draggable.element)[0] == this.element[0]) return; // Bail if draggable and droppable are same element
  6055. if (this.accept.call(this.element[0],(draggable.currentItem || draggable.element))) {
  6056. if(this.options.hoverClass) this.element.removeClass(this.options.hoverClass);
  6057. this._trigger('out', event, this.ui(draggable));
  6058. }
  6059. },
  6060. _drop: function(event,custom) {
  6061. var draggable = custom || $.ui.ddmanager.current;
  6062. if (!draggable || (draggable.currentItem || draggable.element)[0] == this.element[0]) return false; // Bail if draggable and droppable are same element
  6063. var childrenIntersection = false;
  6064. this.element.find(":data(droppable)").not(".ui-draggable-dragging").each(function() {
  6065. var inst = $.data(this, 'droppable');
  6066. if(
  6067. inst.options.greedy
  6068. && !inst.options.disabled
  6069. && inst.options.scope == draggable.options.scope
  6070. && inst.accept.call(inst.element[0], (draggable.currentItem || draggable.element))
  6071. && $.ui.intersect(draggable, $.extend(inst, { offset: inst.element.offset() }), inst.options.tolerance)
  6072. ) { childrenIntersection = true; return false; }
  6073. });
  6074. if(childrenIntersection) return false;
  6075. if(this.accept.call(this.element[0],(draggable.currentItem || draggable.element))) {
  6076. if(this.options.activeClass) this.element.removeClass(this.options.activeClass);
  6077. if(this.options.hoverClass) this.element.removeClass(this.options.hoverClass);
  6078. this._trigger('drop', event, this.ui(draggable));
  6079. return this.element;
  6080. }
  6081. return false;
  6082. },
  6083. ui: function(c) {
  6084. return {
  6085. draggable: (c.currentItem || c.element),
  6086. helper: c.helper,
  6087. position: c.position,
  6088. offset: c.positionAbs
  6089. };
  6090. }
  6091. });
  6092. $.ui.intersect = function(draggable, droppable, toleranceMode) {
  6093. if (!droppable.offset) return false;
  6094. var x1 = (draggable.positionAbs || draggable.position.absolute).left, x2 = x1 + draggable.helperProportions.width,
  6095. y1 = (draggable.positionAbs || draggable.position.absolute).top, y2 = y1 + draggable.helperProportions.height;
  6096. var l = droppable.offset.left, r = l + droppable.proportions.width,
  6097. t = droppable.offset.top, b = t + droppable.proportions.height;
  6098. switch (toleranceMode) {
  6099. case 'fit':
  6100. return (l <= x1 && x2 <= r
  6101. && t <= y1 && y2 <= b);
  6102. break;
  6103. case 'intersect':
  6104. return (l < x1 + (draggable.helperProportions.width / 2) // Right Half
  6105. && x2 - (draggable.helperProportions.width / 2) < r // Left Half
  6106. && t < y1 + (draggable.helperProportions.height / 2) // Bottom Half
  6107. && y2 - (draggable.helperProportions.height / 2) < b ); // Top Half
  6108. break;
  6109. case 'pointer':
  6110. var draggableLeft = ((draggable.positionAbs || draggable.position.absolute).left + (draggable.clickOffset || draggable.offset.click).left),
  6111. draggableTop = ((draggable.positionAbs || draggable.position.absolute).top + (draggable.clickOffset || draggable.offset.click).top),
  6112. isOver = $.ui.isOver(draggableTop, draggableLeft, t, l, droppable.proportions.height, droppable.proportions.width);
  6113. return isOver;
  6114. break;
  6115. case 'touch':
  6116. return (
  6117. (y1 >= t && y1 <= b) || // Top edge touching
  6118. (y2 >= t && y2 <= b) || // Bottom edge touching
  6119. (y1 < t && y2 > b) // Surrounded vertically
  6120. ) && (
  6121. (x1 >= l && x1 <= r) || // Left edge touching
  6122. (x2 >= l && x2 <= r) || // Right edge touching
  6123. (x1 < l && x2 > r) // Surrounded horizontally
  6124. );
  6125. break;
  6126. default:
  6127. return false;
  6128. break;
  6129. }
  6130. };
  6131. /*
  6132. This manager tracks offsets of draggables and droppables
  6133. */
  6134. $.ui.ddmanager = {
  6135. current: null,
  6136. droppables: { 'default': [] },
  6137. prepareOffsets: function(t, event) {
  6138. var m = $.ui.ddmanager.droppables[t.options.scope] || [];
  6139. var type = event ? event.type : null; // workaround for #2317
  6140. var list = (t.currentItem || t.element).find(":data(droppable)").andSelf();
  6141. droppablesLoop: for (var i = 0; i < m.length; i++) {
  6142. if(m[i].options.disabled || (t && !m[i].accept.call(m[i].element[0],(t.currentItem || t.element)))) continue; //No disabled and non-accepted
  6143. for (var j=0; j < list.length; j++) { if(list[j] == m[i].element[0]) { m[i].proportions.height = 0; continue droppablesLoop; } }; //Filter out elements in the current dragged item
  6144. m[i].visible = m[i].element.css("display") != "none"; if(!m[i].visible) continue; //If the element is not visible, continue
  6145. if(type == "mousedown") m[i]._activate.call(m[i], event); //Activate the droppable if used directly from draggables
  6146. m[i].offset = m[i].element.offset();
  6147. m[i].proportions = { width: m[i].element[0].offsetWidth, height: m[i].element[0].offsetHeight };
  6148. }
  6149. },
  6150. drop: function(draggable, event) {
  6151. var dropped = false;
  6152. $.each($.ui.ddmanager.droppables[draggable.options.scope] || [], function() {
  6153. if(!this.options) return;
  6154. if (!this.options.disabled && this.visible && $.ui.intersect(draggable, this, this.options.tolerance))
  6155. dropped = this._drop.call(this, event) || dropped;
  6156. if (!this.options.disabled && this.visible && this.accept.call(this.element[0],(draggable.currentItem || draggable.element))) {
  6157. this.isout = 1; this.isover = 0;
  6158. this._deactivate.call(this, event);
  6159. }
  6160. });
  6161. return dropped;
  6162. },
  6163. dragStart: function( draggable, event ) {
  6164. //Listen for scrolling so that if the dragging causes scrolling the position of the droppables can be recalculated (see #5003)
  6165. draggable.element.parentsUntil( "body" ).bind( "scroll.droppable", function() {
  6166. if( !draggable.options.refreshPositions ) $.ui.ddmanager.prepareOffsets( draggable, event );
  6167. });
  6168. },
  6169. drag: function(draggable, event) {
  6170. //If you have a highly dynamic page, you might try this option. It renders positions every time you move the mouse.
  6171. if(draggable.options.refreshPositions) $.ui.ddmanager.prepareOffsets(draggable, event);
  6172. //Run through all droppables and check their positions based on specific tolerance options
  6173. $.each($.ui.ddmanager.droppables[draggable.options.scope] || [], function() {
  6174. if(this.options.disabled || this.greedyChild || !this.visible) return;
  6175. var intersects = $.ui.intersect(draggable, this, this.options.tolerance);
  6176. var c = !intersects && this.isover == 1 ? 'isout' : (intersects && this.isover == 0 ? 'isover' : null);
  6177. if(!c) return;
  6178. var parentInstance;
  6179. if (this.options.greedy) {
  6180. // find droppable parents with same scope
  6181. var scope = this.options.scope;
  6182. var parent = this.element.parents(':data(droppable)').filter(function () {
  6183. return $.data(this, 'droppable').options.scope === scope;
  6184. });
  6185. if (parent.length) {
  6186. parentInstance = $.data(parent[0], 'droppable');
  6187. parentInstance.greedyChild = (c == 'isover' ? 1 : 0);
  6188. }
  6189. }
  6190. // we just moved into a greedy child
  6191. if (parentInstance && c == 'isover') {
  6192. parentInstance['isover'] = 0;
  6193. parentInstance['isout'] = 1;
  6194. parentInstance._out.call(parentInstance, event);
  6195. }
  6196. this[c] = 1; this[c == 'isout' ? 'isover' : 'isout'] = 0;
  6197. this[c == "isover" ? "_over" : "_out"].call(this, event);
  6198. // we just moved out of a greedy child
  6199. if (parentInstance && c == 'isout') {
  6200. parentInstance['isout'] = 0;
  6201. parentInstance['isover'] = 1;
  6202. parentInstance._over.call(parentInstance, event);
  6203. }
  6204. });
  6205. },
  6206. dragStop: function( draggable, event ) {
  6207. draggable.element.parentsUntil( "body" ).unbind( "scroll.droppable" );
  6208. //Call prepareOffsets one final time since IE does not fire return scroll events when overflow was caused by drag (see #5003)
  6209. if( !draggable.options.refreshPositions ) $.ui.ddmanager.prepareOffsets( draggable, event );
  6210. }
  6211. };
  6212. })(jQuery);
  6213. ;(jQuery.effects || (function($, undefined) {
  6214. var backCompat = $.uiBackCompat !== false,
  6215. // prefix used for storing data on .data()
  6216. dataSpace = "ui-effects-";
  6217. $.effects = {
  6218. effect: {}
  6219. };
  6220. /*!
  6221. * jQuery Color Animations v2.0.0
  6222. * http://jquery.com/
  6223. *
  6224. * Copyright 2012 jQuery Foundation and other contributors
  6225. * Released under the MIT license.
  6226. * http://jquery.org/license
  6227. *
  6228. * Date: Mon Aug 13 13:41:02 2012 -0500
  6229. */
  6230. (function( jQuery, undefined ) {
  6231. var stepHooks = "backgroundColor borderBottomColor borderLeftColor borderRightColor borderTopColor color columnRuleColor outlineColor textDecorationColor textEmphasisColor".split(" "),
  6232. // plusequals test for += 100 -= 100
  6233. rplusequals = /^([\-+])=\s*(\d+\.?\d*)/,
  6234. // a set of RE's that can match strings and generate color tuples.
  6235. stringParsers = [{
  6236. re: /rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(?:,\s*(\d+(?:\.\d+)?)\s*)?\)/,
  6237. parse: function( execResult ) {
  6238. return [
  6239. execResult[ 1 ],
  6240. execResult[ 2 ],
  6241. execResult[ 3 ],
  6242. execResult[ 4 ]
  6243. ];
  6244. }
  6245. }, {
  6246. re: /rgba?\(\s*(\d+(?:\.\d+)?)\%\s*,\s*(\d+(?:\.\d+)?)\%\s*,\s*(\d+(?:\.\d+)?)\%\s*(?:,\s*(\d+(?:\.\d+)?)\s*)?\)/,
  6247. parse: function( execResult ) {
  6248. return [
  6249. execResult[ 1 ] * 2.55,
  6250. execResult[ 2 ] * 2.55,
  6251. execResult[ 3 ] * 2.55,
  6252. execResult[ 4 ]
  6253. ];
  6254. }
  6255. }, {
  6256. // this regex ignores A-F because it's compared against an already lowercased string
  6257. re: /#([a-f0-9]{2})([a-f0-9]{2})([a-f0-9]{2})/,
  6258. parse: function( execResult ) {
  6259. return [
  6260. parseInt( execResult[ 1 ], 16 ),
  6261. parseInt( execResult[ 2 ], 16 ),
  6262. parseInt( execResult[ 3 ], 16 )
  6263. ];
  6264. }
  6265. }, {
  6266. // this regex ignores A-F because it's compared against an already lowercased string
  6267. re: /#([a-f0-9])([a-f0-9])([a-f0-9])/,
  6268. parse: function( execResult ) {
  6269. return [
  6270. parseInt( execResult[ 1 ] + execResult[ 1 ], 16 ),
  6271. parseInt( execResult[ 2 ] + execResult[ 2 ], 16 ),
  6272. parseInt( execResult[ 3 ] + execResult[ 3 ], 16 )
  6273. ];
  6274. }
  6275. }, {
  6276. re: /hsla?\(\s*(\d+(?:\.\d+)?)\s*,\s*(\d+(?:\.\d+)?)\%\s*,\s*(\d+(?:\.\d+)?)\%\s*(?:,\s*(\d+(?:\.\d+)?)\s*)?\)/,
  6277. space: "hsla",
  6278. parse: function( execResult ) {
  6279. return [
  6280. execResult[ 1 ],
  6281. execResult[ 2 ] / 100,
  6282. execResult[ 3 ] / 100,
  6283. execResult[ 4 ]
  6284. ];
  6285. }
  6286. }],
  6287. // jQuery.Color( )
  6288. color = jQuery.Color = function( color, green, blue, alpha ) {
  6289. return new jQuery.Color.fn.parse( color, green, blue, alpha );
  6290. },
  6291. spaces = {
  6292. rgba: {
  6293. props: {
  6294. red: {
  6295. idx: 0,
  6296. type: "byte"
  6297. },
  6298. green: {
  6299. idx: 1,
  6300. type: "byte"
  6301. },
  6302. blue: {
  6303. idx: 2,
  6304. type: "byte"
  6305. }
  6306. }
  6307. },
  6308. hsla: {
  6309. props: {
  6310. hue: {
  6311. idx: 0,
  6312. type: "degrees"
  6313. },
  6314. saturation: {
  6315. idx: 1,
  6316. type: "percent"
  6317. },
  6318. lightness: {
  6319. idx: 2,
  6320. type: "percent"
  6321. }
  6322. }
  6323. }
  6324. },
  6325. propTypes = {
  6326. "byte": {
  6327. floor: true,
  6328. max: 255
  6329. },
  6330. "percent": {
  6331. max: 1
  6332. },
  6333. "degrees": {
  6334. mod: 360,
  6335. floor: true
  6336. }
  6337. },
  6338. support = color.support = {},
  6339. // element for support tests
  6340. supportElem = jQuery( "<p>" )[ 0 ],
  6341. // colors = jQuery.Color.names
  6342. colors,
  6343. // local aliases of functions called often
  6344. each = jQuery.each;
  6345. // determine rgba support immediately
  6346. supportElem.style.cssText = "background-color:rgba(1,1,1,.5)";
  6347. support.rgba = supportElem.style.backgroundColor.indexOf( "rgba" ) > -1;
  6348. // define cache name and alpha properties
  6349. // for rgba and hsla spaces
  6350. each( spaces, function( spaceName, space ) {
  6351. space.cache = "_" + spaceName;
  6352. space.props.alpha = {
  6353. idx: 3,
  6354. type: "percent",
  6355. def: 1
  6356. };
  6357. });
  6358. function clamp( value, prop, allowEmpty ) {
  6359. var type = propTypes[ prop.type ] || {};
  6360. if ( value == null ) {
  6361. return (allowEmpty || !prop.def) ? null : prop.def;
  6362. }
  6363. // ~~ is an short way of doing floor for positive numbers
  6364. value = type.floor ? ~~value : parseFloat( value );
  6365. // IE will pass in empty strings as value for alpha,
  6366. // which will hit this case
  6367. if ( isNaN( value ) ) {
  6368. return prop.def;
  6369. }
  6370. if ( type.mod ) {
  6371. // we add mod before modding to make sure that negatives values
  6372. // get converted properly: -10 -> 350
  6373. return (value + type.mod) % type.mod;
  6374. }
  6375. // for now all property types without mod have min and max
  6376. return 0 > value ? 0 : type.max < value ? type.max : value;
  6377. }
  6378. function stringParse( string ) {
  6379. var inst = color(),
  6380. rgba = inst._rgba = [];
  6381. string = string.toLowerCase();
  6382. each( stringParsers, function( i, parser ) {
  6383. var parsed,
  6384. match = parser.re.exec( string ),
  6385. values = match && parser.parse( match ),
  6386. spaceName = parser.space || "rgba";
  6387. if ( values ) {
  6388. parsed = inst[ spaceName ]( values );
  6389. // if this was an rgba parse the assignment might happen twice
  6390. // oh well....
  6391. inst[ spaces[ spaceName ].cache ] = parsed[ spaces[ spaceName ].cache ];
  6392. rgba = inst._rgba = parsed._rgba;
  6393. // exit each( stringParsers ) here because we matched
  6394. return false;
  6395. }
  6396. });
  6397. // Found a stringParser that handled it
  6398. if ( rgba.length ) {
  6399. // if this came from a parsed string, force "transparent" when alpha is 0
  6400. // chrome, (and maybe others) return "transparent" as rgba(0,0,0,0)
  6401. if ( rgba.join() === "0,0,0,0" ) {
  6402. jQuery.extend( rgba, colors.transparent );
  6403. }
  6404. return inst;
  6405. }
  6406. // named colors
  6407. return colors[ string ];
  6408. }
  6409. color.fn = jQuery.extend( color.prototype, {
  6410. parse: function( red, green, blue, alpha ) {
  6411. if ( red === undefined ) {
  6412. this._rgba = [ null, null, null, null ];
  6413. return this;
  6414. }
  6415. if ( red.jquery || red.nodeType ) {
  6416. red = jQuery( red ).css( green );
  6417. green = undefined;
  6418. }
  6419. var inst = this,
  6420. type = jQuery.type( red ),
  6421. rgba = this._rgba = [];
  6422. // more than 1 argument specified - assume ( red, green, blue, alpha )
  6423. if ( green !== undefined ) {
  6424. red = [ red, green, blue, alpha ];
  6425. type = "array";
  6426. }
  6427. if ( type === "string" ) {
  6428. return this.parse( stringParse( red ) || colors._default );
  6429. }
  6430. if ( type === "array" ) {
  6431. each( spaces.rgba.props, function( key, prop ) {
  6432. rgba[ prop.idx ] = clamp( red[ prop.idx ], prop );
  6433. });
  6434. return this;
  6435. }
  6436. if ( type === "object" ) {
  6437. if ( red instanceof color ) {
  6438. each( spaces, function( spaceName, space ) {
  6439. if ( red[ space.cache ] ) {
  6440. inst[ space.cache ] = red[ space.cache ].slice();
  6441. }
  6442. });
  6443. } else {
  6444. each( spaces, function( spaceName, space ) {
  6445. var cache = space.cache;
  6446. each( space.props, function( key, prop ) {
  6447. // if the cache doesn't exist, and we know how to convert
  6448. if ( !inst[ cache ] && space.to ) {
  6449. // if the value was null, we don't need to copy it
  6450. // if the key was alpha, we don't need to copy it either
  6451. if ( key === "alpha" || red[ key ] == null ) {
  6452. return;
  6453. }
  6454. inst[ cache ] = space.to( inst._rgba );
  6455. }
  6456. // this is the only case where we allow nulls for ALL properties.
  6457. // call clamp with alwaysAllowEmpty
  6458. inst[ cache ][ prop.idx ] = clamp( red[ key ], prop, true );
  6459. });
  6460. // everything defined but alpha?
  6461. if ( inst[ cache ] && $.inArray( null, inst[ cache ].slice( 0, 3 ) ) < 0 ) {
  6462. // use the default of 1
  6463. inst[ cache ][ 3 ] = 1;
  6464. if ( space.from ) {
  6465. inst._rgba = space.from( inst[ cache ] );
  6466. }
  6467. }
  6468. });
  6469. }
  6470. return this;
  6471. }
  6472. },
  6473. is: function( compare ) {
  6474. var is = color( compare ),
  6475. same = true,
  6476. inst = this;
  6477. each( spaces, function( _, space ) {
  6478. var localCache,
  6479. isCache = is[ space.cache ];
  6480. if (isCache) {
  6481. localCache = inst[ space.cache ] || space.to && space.to( inst._rgba ) || [];
  6482. each( space.props, function( _, prop ) {
  6483. if ( isCache[ prop.idx ] != null ) {
  6484. same = ( isCache[ prop.idx ] === localCache[ prop.idx ] );
  6485. return same;
  6486. }
  6487. });
  6488. }
  6489. return same;
  6490. });
  6491. return same;
  6492. },
  6493. _space: function() {
  6494. var used = [],
  6495. inst = this;
  6496. each( spaces, function( spaceName, space ) {
  6497. if ( inst[ space.cache ] ) {
  6498. used.push( spaceName );
  6499. }
  6500. });
  6501. return used.pop();
  6502. },
  6503. transition: function( other, distance ) {
  6504. var end = color( other ),
  6505. spaceName = end._space(),
  6506. space = spaces[ spaceName ],
  6507. startColor = this.alpha() === 0 ? color( "transparent" ) : this,
  6508. start = startColor[ space.cache ] || space.to( startColor._rgba ),
  6509. result = start.slice();
  6510. end = end[ space.cache ];
  6511. each( space.props, function( key, prop ) {
  6512. var index = prop.idx,
  6513. startValue = start[ index ],
  6514. endValue = end[ index ],
  6515. type = propTypes[ prop.type ] || {};
  6516. // if null, don't override start value
  6517. if ( endValue === null ) {
  6518. return;
  6519. }
  6520. // if null - use end
  6521. if ( startValue === null ) {
  6522. result[ index ] = endValue;
  6523. } else {
  6524. if ( type.mod ) {
  6525. if ( endValue - startValue > type.mod / 2 ) {
  6526. startValue += type.mod;
  6527. } else if ( startValue - endValue > type.mod / 2 ) {
  6528. startValue -= type.mod;
  6529. }
  6530. }
  6531. result[ index ] = clamp( ( endValue - startValue ) * distance + startValue, prop );
  6532. }
  6533. });
  6534. return this[ spaceName ]( result );
  6535. },
  6536. blend: function( opaque ) {
  6537. // if we are already opaque - return ourself
  6538. if ( this._rgba[ 3 ] === 1 ) {
  6539. return this;
  6540. }
  6541. var rgb = this._rgba.slice(),
  6542. a = rgb.pop(),
  6543. blend = color( opaque )._rgba;
  6544. return color( jQuery.map( rgb, function( v, i ) {
  6545. return ( 1 - a ) * blend[ i ] + a * v;
  6546. }));
  6547. },
  6548. toRgbaString: function() {
  6549. var prefix = "rgba(",
  6550. rgba = jQuery.map( this._rgba, function( v, i ) {
  6551. return v == null ? ( i > 2 ? 1 : 0 ) : v;
  6552. });
  6553. if ( rgba[ 3 ] === 1 ) {
  6554. rgba.pop();
  6555. prefix = "rgb(";
  6556. }
  6557. return prefix + rgba.join() + ")";
  6558. },
  6559. toHslaString: function() {
  6560. var prefix = "hsla(",
  6561. hsla = jQuery.map( this.hsla(), function( v, i ) {
  6562. if ( v == null ) {
  6563. v = i > 2 ? 1 : 0;
  6564. }
  6565. // catch 1 and 2
  6566. if ( i && i < 3 ) {
  6567. v = Math.round( v * 100 ) + "%";
  6568. }
  6569. return v;
  6570. });
  6571. if ( hsla[ 3 ] === 1 ) {
  6572. hsla.pop();
  6573. prefix = "hsl(";
  6574. }
  6575. return prefix + hsla.join() + ")";
  6576. },
  6577. toHexString: function( includeAlpha ) {
  6578. var rgba = this._rgba.slice(),
  6579. alpha = rgba.pop();
  6580. if ( includeAlpha ) {
  6581. rgba.push( ~~( alpha * 255 ) );
  6582. }
  6583. return "#" + jQuery.map( rgba, function( v ) {
  6584. // default to 0 when nulls exist
  6585. v = ( v || 0 ).toString( 16 );
  6586. return v.length === 1 ? "0" + v : v;
  6587. }).join("");
  6588. },
  6589. toString: function() {
  6590. return this._rgba[ 3 ] === 0 ? "transparent" : this.toRgbaString();
  6591. }
  6592. });
  6593. color.fn.parse.prototype = color.fn;
  6594. // hsla conversions adapted from:
  6595. // https://code.google.com/p/maashaack/source/browse/packages/graphics/trunk/src/graphics/colors/HUE2RGB.as?r=5021
  6596. function hue2rgb( p, q, h ) {
  6597. h = ( h + 1 ) % 1;
  6598. if ( h * 6 < 1 ) {
  6599. return p + (q - p) * h * 6;
  6600. }
  6601. if ( h * 2 < 1) {
  6602. return q;
  6603. }
  6604. if ( h * 3 < 2 ) {
  6605. return p + (q - p) * ((2/3) - h) * 6;
  6606. }
  6607. return p;
  6608. }
  6609. spaces.hsla.to = function ( rgba ) {
  6610. if ( rgba[ 0 ] == null || rgba[ 1 ] == null || rgba[ 2 ] == null ) {
  6611. return [ null, null, null, rgba[ 3 ] ];
  6612. }
  6613. var r = rgba[ 0 ] / 255,
  6614. g = rgba[ 1 ] / 255,
  6615. b = rgba[ 2 ] / 255,
  6616. a = rgba[ 3 ],
  6617. max = Math.max( r, g, b ),
  6618. min = Math.min( r, g, b ),
  6619. diff = max - min,
  6620. add = max + min,
  6621. l = add * 0.5,
  6622. h, s;
  6623. if ( min === max ) {
  6624. h = 0;
  6625. } else if ( r === max ) {
  6626. h = ( 60 * ( g - b ) / diff ) + 360;
  6627. } else if ( g === max ) {
  6628. h = ( 60 * ( b - r ) / diff ) + 120;
  6629. } else {
  6630. h = ( 60 * ( r - g ) / diff ) + 240;
  6631. }
  6632. if ( l === 0 || l === 1 ) {
  6633. s = l;
  6634. } else if ( l <= 0.5 ) {
  6635. s = diff / add;
  6636. } else {
  6637. s = diff / ( 2 - add );
  6638. }
  6639. return [ Math.round(h) % 360, s, l, a == null ? 1 : a ];
  6640. };
  6641. spaces.hsla.from = function ( hsla ) {
  6642. if ( hsla[ 0 ] == null || hsla[ 1 ] == null || hsla[ 2 ] == null ) {
  6643. return [ null, null, null, hsla[ 3 ] ];
  6644. }
  6645. var h = hsla[ 0 ] / 360,
  6646. s = hsla[ 1 ],
  6647. l = hsla[ 2 ],
  6648. a = hsla[ 3 ],
  6649. q = l <= 0.5 ? l * ( 1 + s ) : l + s - l * s,
  6650. p = 2 * l - q;
  6651. return [
  6652. Math.round( hue2rgb( p, q, h + ( 1 / 3 ) ) * 255 ),
  6653. Math.round( hue2rgb( p, q, h ) * 255 ),
  6654. Math.round( hue2rgb( p, q, h - ( 1 / 3 ) ) * 255 ),
  6655. a
  6656. ];
  6657. };
  6658. each( spaces, function( spaceName, space ) {
  6659. var props = space.props,
  6660. cache = space.cache,
  6661. to = space.to,
  6662. from = space.from;
  6663. // makes rgba() and hsla()
  6664. color.fn[ spaceName ] = function( value ) {
  6665. // generate a cache for this space if it doesn't exist
  6666. if ( to && !this[ cache ] ) {
  6667. this[ cache ] = to( this._rgba );
  6668. }
  6669. if ( value === undefined ) {
  6670. return this[ cache ].slice();
  6671. }
  6672. var ret,
  6673. type = jQuery.type( value ),
  6674. arr = ( type === "array" || type === "object" ) ? value : arguments,
  6675. local = this[ cache ].slice();
  6676. each( props, function( key, prop ) {
  6677. var val = arr[ type === "object" ? key : prop.idx ];
  6678. if ( val == null ) {
  6679. val = local[ prop.idx ];
  6680. }
  6681. local[ prop.idx ] = clamp( val, prop );
  6682. });
  6683. if ( from ) {
  6684. ret = color( from( local ) );
  6685. ret[ cache ] = local;
  6686. return ret;
  6687. } else {
  6688. return color( local );
  6689. }
  6690. };
  6691. // makes red() green() blue() alpha() hue() saturation() lightness()
  6692. each( props, function( key, prop ) {
  6693. // alpha is included in more than one space
  6694. if ( color.fn[ key ] ) {
  6695. return;
  6696. }
  6697. color.fn[ key ] = function( value ) {
  6698. var vtype = jQuery.type( value ),
  6699. fn = ( key === "alpha" ? ( this._hsla ? "hsla" : "rgba" ) : spaceName ),
  6700. local = this[ fn ](),
  6701. cur = local[ prop.idx ],
  6702. match;
  6703. if ( vtype === "undefined" ) {
  6704. return cur;
  6705. }
  6706. if ( vtype === "function" ) {
  6707. value = value.call( this, cur );
  6708. vtype = jQuery.type( value );
  6709. }
  6710. if ( value == null && prop.empty ) {
  6711. return this;
  6712. }
  6713. if ( vtype === "string" ) {
  6714. match = rplusequals.exec( value );
  6715. if ( match ) {
  6716. value = cur + parseFloat( match[ 2 ] ) * ( match[ 1 ] === "+" ? 1 : -1 );
  6717. }
  6718. }
  6719. local[ prop.idx ] = value;
  6720. return this[ fn ]( local );
  6721. };
  6722. });
  6723. });
  6724. // add .fx.step functions
  6725. each( stepHooks, function( i, hook ) {
  6726. jQuery.cssHooks[ hook ] = {
  6727. set: function( elem, value ) {
  6728. var parsed, curElem,
  6729. backgroundColor = "";
  6730. if ( jQuery.type( value ) !== "string" || ( parsed = stringParse( value ) ) ) {
  6731. value = color( parsed || value );
  6732. if ( !support.rgba && value._rgba[ 3 ] !== 1 ) {
  6733. curElem = hook === "backgroundColor" ? elem.parentNode : elem;
  6734. while (
  6735. (backgroundColor === "" || backgroundColor === "transparent") &&
  6736. curElem && curElem.style
  6737. ) {
  6738. try {
  6739. backgroundColor = jQuery.css( curElem, "backgroundColor" );
  6740. curElem = curElem.parentNode;
  6741. } catch ( e ) {
  6742. }
  6743. }
  6744. value = value.blend( backgroundColor && backgroundColor !== "transparent" ?
  6745. backgroundColor :
  6746. "_default" );
  6747. }
  6748. value = value.toRgbaString();
  6749. }
  6750. try {
  6751. elem.style[ hook ] = value;
  6752. } catch( error ) {
  6753. // wrapped to prevent IE from throwing errors on "invalid" values like 'auto' or 'inherit'
  6754. }
  6755. }
  6756. };
  6757. jQuery.fx.step[ hook ] = function( fx ) {
  6758. if ( !fx.colorInit ) {
  6759. fx.start = color( fx.elem, hook );
  6760. fx.end = color( fx.end );
  6761. fx.colorInit = true;
  6762. }
  6763. jQuery.cssHooks[ hook ].set( fx.elem, fx.start.transition( fx.end, fx.pos ) );
  6764. };
  6765. });
  6766. jQuery.cssHooks.borderColor = {
  6767. expand: function( value ) {
  6768. var expanded = {};
  6769. each( [ "Top", "Right", "Bottom", "Left" ], function( i, part ) {
  6770. expanded[ "border" + part + "Color" ] = value;
  6771. });
  6772. return expanded;
  6773. }
  6774. };
  6775. // Basic color names only.
  6776. // Usage of any of the other color names requires adding yourself or including
  6777. // jquery.color.svg-names.js.
  6778. colors = jQuery.Color.names = {
  6779. // 4.1. Basic color keywords
  6780. aqua: "#00ffff",
  6781. black: "#000000",
  6782. blue: "#0000ff",
  6783. fuchsia: "#ff00ff",
  6784. gray: "#808080",
  6785. green: "#008000",
  6786. lime: "#00ff00",
  6787. maroon: "#800000",
  6788. navy: "#000080",
  6789. olive: "#808000",
  6790. purple: "#800080",
  6791. red: "#ff0000",
  6792. silver: "#c0c0c0",
  6793. teal: "#008080",
  6794. white: "#ffffff",
  6795. yellow: "#ffff00",
  6796. // 4.2.3. "transparent" color keyword
  6797. transparent: [ null, null, null, 0 ],
  6798. _default: "#ffffff"
  6799. };
  6800. })( jQuery );
  6801. /******************************************************************************/
  6802. /****************************** CLASS ANIMATIONS ******************************/
  6803. /******************************************************************************/
  6804. (function() {
  6805. var classAnimationActions = [ "add", "remove", "toggle" ],
  6806. shorthandStyles = {
  6807. border: 1,
  6808. borderBottom: 1,
  6809. borderColor: 1,
  6810. borderLeft: 1,
  6811. borderRight: 1,
  6812. borderTop: 1,
  6813. borderWidth: 1,
  6814. margin: 1,
  6815. padding: 1
  6816. };
  6817. $.each([ "borderLeftStyle", "borderRightStyle", "borderBottomStyle", "borderTopStyle" ], function( _, prop ) {
  6818. $.fx.step[ prop ] = function( fx ) {
  6819. if ( fx.end !== "none" && !fx.setAttr || fx.pos === 1 && !fx.setAttr ) {
  6820. jQuery.style( fx.elem, prop, fx.end );
  6821. fx.setAttr = true;
  6822. }
  6823. };
  6824. });
  6825. function getElementStyles() {
  6826. var style = this.ownerDocument.defaultView ?
  6827. this.ownerDocument.defaultView.getComputedStyle( this, null ) :
  6828. this.currentStyle,
  6829. newStyle = {},
  6830. key,
  6831. len;
  6832. // webkit enumerates style porperties
  6833. if ( style && style.length && style[ 0 ] && style[ style[ 0 ] ] ) {
  6834. len = style.length;
  6835. while ( len-- ) {
  6836. key = style[ len ];
  6837. if ( typeof style[ key ] === "string" ) {
  6838. newStyle[ $.camelCase( key ) ] = style[ key ];
  6839. }
  6840. }
  6841. } else {
  6842. for ( key in style ) {
  6843. if ( typeof style[ key ] === "string" ) {
  6844. newStyle[ key ] = style[ key ];
  6845. }
  6846. }
  6847. }
  6848. return newStyle;
  6849. }
  6850. function styleDifference( oldStyle, newStyle ) {
  6851. var diff = {},
  6852. name, value;
  6853. for ( name in newStyle ) {
  6854. value = newStyle[ name ];
  6855. if ( oldStyle[ name ] !== value ) {
  6856. if ( !shorthandStyles[ name ] ) {
  6857. if ( $.fx.step[ name ] || !isNaN( parseFloat( value ) ) ) {
  6858. diff[ name ] = value;
  6859. }
  6860. }
  6861. }
  6862. }
  6863. return diff;
  6864. }
  6865. $.effects.animateClass = function( value, duration, easing, callback ) {
  6866. var o = $.speed( duration, easing, callback );
  6867. return this.queue( function() {
  6868. var animated = $( this ),
  6869. baseClass = animated.attr( "class" ) || "",
  6870. applyClassChange,
  6871. allAnimations = o.children ? animated.find( "*" ).andSelf() : animated;
  6872. // map the animated objects to store the original styles.
  6873. allAnimations = allAnimations.map(function() {
  6874. var el = $( this );
  6875. return {
  6876. el: el,
  6877. start: getElementStyles.call( this )
  6878. };
  6879. });
  6880. // apply class change
  6881. applyClassChange = function() {
  6882. $.each( classAnimationActions, function(i, action) {
  6883. if ( value[ action ] ) {
  6884. animated[ action + "Class" ]( value[ action ] );
  6885. }
  6886. });
  6887. };
  6888. applyClassChange();
  6889. // map all animated objects again - calculate new styles and diff
  6890. allAnimations = allAnimations.map(function() {
  6891. this.end = getElementStyles.call( this.el[ 0 ] );
  6892. this.diff = styleDifference( this.start, this.end );
  6893. return this;
  6894. });
  6895. // apply original class
  6896. animated.attr( "class", baseClass );
  6897. // map all animated objects again - this time collecting a promise
  6898. allAnimations = allAnimations.map(function() {
  6899. var styleInfo = this,
  6900. dfd = $.Deferred(),
  6901. opts = jQuery.extend({}, o, {
  6902. queue: false,
  6903. complete: function() {
  6904. dfd.resolve( styleInfo );
  6905. }
  6906. });
  6907. this.el.animate( this.diff, opts );
  6908. return dfd.promise();
  6909. });
  6910. // once all animations have completed:
  6911. $.when.apply( $, allAnimations.get() ).done(function() {
  6912. // set the final class
  6913. applyClassChange();
  6914. // for each animated element,
  6915. // clear all css properties that were animated
  6916. $.each( arguments, function() {
  6917. var el = this.el;
  6918. $.each( this.diff, function(key) {
  6919. el.css( key, '' );
  6920. });
  6921. });
  6922. // this is guarnteed to be there if you use jQuery.speed()
  6923. // it also handles dequeuing the next anim...
  6924. o.complete.call( animated[ 0 ] );
  6925. });
  6926. });
  6927. };
  6928. $.fn.extend({
  6929. _addClass: $.fn.addClass,
  6930. addClass: function( classNames, speed, easing, callback ) {
  6931. return speed ?
  6932. $.effects.animateClass.call( this,
  6933. { add: classNames }, speed, easing, callback ) :
  6934. this._addClass( classNames );
  6935. },
  6936. _removeClass: $.fn.removeClass,
  6937. removeClass: function( classNames, speed, easing, callback ) {
  6938. return speed ?
  6939. $.effects.animateClass.call( this,
  6940. { remove: classNames }, speed, easing, callback ) :
  6941. this._removeClass( classNames );
  6942. },
  6943. _toggleClass: $.fn.toggleClass,
  6944. toggleClass: function( classNames, force, speed, easing, callback ) {
  6945. if ( typeof force === "boolean" || force === undefined ) {
  6946. if ( !speed ) {
  6947. // without speed parameter
  6948. return this._toggleClass( classNames, force );
  6949. } else {
  6950. return $.effects.animateClass.call( this,
  6951. (force ? { add: classNames } : { remove: classNames }),
  6952. speed, easing, callback );
  6953. }
  6954. } else {
  6955. // without force parameter
  6956. return $.effects.animateClass.call( this,
  6957. { toggle: classNames }, force, speed, easing );
  6958. }
  6959. },
  6960. switchClass: function( remove, add, speed, easing, callback) {
  6961. return $.effects.animateClass.call( this, {
  6962. add: add,
  6963. remove: remove
  6964. }, speed, easing, callback );
  6965. }
  6966. });
  6967. })();
  6968. /******************************************************************************/
  6969. /*********************************** EFFECTS **********************************/
  6970. /******************************************************************************/
  6971. (function() {
  6972. $.extend( $.effects, {
  6973. version: "1.9.2",
  6974. // Saves a set of properties in a data storage
  6975. save: function( element, set ) {
  6976. for( var i=0; i < set.length; i++ ) {
  6977. if ( set[ i ] !== null ) {
  6978. element.data( dataSpace + set[ i ], element[ 0 ].style[ set[ i ] ] );
  6979. }
  6980. }
  6981. },
  6982. // Restores a set of previously saved properties from a data storage
  6983. restore: function( element, set ) {
  6984. var val, i;
  6985. for( i=0; i < set.length; i++ ) {
  6986. if ( set[ i ] !== null ) {
  6987. val = element.data( dataSpace + set[ i ] );
  6988. // support: jQuery 1.6.2
  6989. // http://bugs.jquery.com/ticket/9917
  6990. // jQuery 1.6.2 incorrectly returns undefined for any falsy value.
  6991. // We can't differentiate between "" and 0 here, so we just assume
  6992. // empty string since it's likely to be a more common value...
  6993. if ( val === undefined ) {
  6994. val = "";
  6995. }
  6996. element.css( set[ i ], val );
  6997. }
  6998. }
  6999. },
  7000. setMode: function( el, mode ) {
  7001. if (mode === "toggle") {
  7002. mode = el.is( ":hidden" ) ? "show" : "hide";
  7003. }
  7004. return mode;
  7005. },
  7006. // Translates a [top,left] array into a baseline value
  7007. // this should be a little more flexible in the future to handle a string & hash
  7008. getBaseline: function( origin, original ) {
  7009. var y, x;
  7010. switch ( origin[ 0 ] ) {
  7011. case "top": y = 0; break;
  7012. case "middle": y = 0.5; break;
  7013. case "bottom": y = 1; break;
  7014. default: y = origin[ 0 ] / original.height;
  7015. }
  7016. switch ( origin[ 1 ] ) {
  7017. case "left": x = 0; break;
  7018. case "center": x = 0.5; break;
  7019. case "right": x = 1; break;
  7020. default: x = origin[ 1 ] / original.width;
  7021. }
  7022. return {
  7023. x: x,
  7024. y: y
  7025. };
  7026. },
  7027. // Wraps the element around a wrapper that copies position properties
  7028. createWrapper: function( element ) {
  7029. // if the element is already wrapped, return it
  7030. if ( element.parent().is( ".ui-effects-wrapper" )) {
  7031. return element.parent();
  7032. }
  7033. // wrap the element
  7034. var props = {
  7035. width: element.outerWidth(true),
  7036. height: element.outerHeight(true),
  7037. "float": element.css( "float" )
  7038. },
  7039. wrapper = $( "<div></div>" )
  7040. .addClass( "ui-effects-wrapper" )
  7041. .css({
  7042. fontSize: "100%",
  7043. background: "transparent",
  7044. border: "none",
  7045. margin: 0,
  7046. padding: 0
  7047. }),
  7048. // Store the size in case width/height are defined in % - Fixes #5245
  7049. size = {
  7050. width: element.width(),
  7051. height: element.height()
  7052. },
  7053. active = document.activeElement;
  7054. // support: Firefox
  7055. // Firefox incorrectly exposes anonymous content
  7056. // https://bugzilla.mozilla.org/show_bug.cgi?id=561664
  7057. try {
  7058. active.id;
  7059. } catch( e ) {
  7060. active = document.body;
  7061. }
  7062. element.wrap( wrapper );
  7063. // Fixes #7595 - Elements lose focus when wrapped.
  7064. if ( element[ 0 ] === active || $.contains( element[ 0 ], active ) ) {
  7065. $( active ).focus();
  7066. }
  7067. wrapper = element.parent(); //Hotfix for jQuery 1.4 since some change in wrap() seems to actually lose the reference to the wrapped element
  7068. // transfer positioning properties to the wrapper
  7069. if ( element.css( "position" ) === "static" ) {
  7070. wrapper.css({ position: "relative" });
  7071. element.css({ position: "relative" });
  7072. } else {
  7073. $.extend( props, {
  7074. position: element.css( "position" ),
  7075. zIndex: element.css( "z-index" )
  7076. });
  7077. $.each([ "top", "left", "bottom", "right" ], function(i, pos) {
  7078. props[ pos ] = element.css( pos );
  7079. if ( isNaN( parseInt( props[ pos ], 10 ) ) ) {
  7080. props[ pos ] = "auto";
  7081. }
  7082. });
  7083. element.css({
  7084. position: "relative",
  7085. top: 0,
  7086. left: 0,
  7087. right: "auto",
  7088. bottom: "auto"
  7089. });
  7090. }
  7091. element.css(size);
  7092. return wrapper.css( props ).show();
  7093. },
  7094. removeWrapper: function( element ) {
  7095. var active = document.activeElement;
  7096. if ( element.parent().is( ".ui-effects-wrapper" ) ) {
  7097. element.parent().replaceWith( element );
  7098. // Fixes #7595 - Elements lose focus when wrapped.
  7099. if ( element[ 0 ] === active || $.contains( element[ 0 ], active ) ) {
  7100. $( active ).focus();
  7101. }
  7102. }
  7103. return element;
  7104. },
  7105. setTransition: function( element, list, factor, value ) {
  7106. value = value || {};
  7107. $.each( list, function( i, x ) {
  7108. var unit = element.cssUnit( x );
  7109. if ( unit[ 0 ] > 0 ) {
  7110. value[ x ] = unit[ 0 ] * factor + unit[ 1 ];
  7111. }
  7112. });
  7113. return value;
  7114. }
  7115. });
  7116. // return an effect options object for the given parameters:
  7117. function _normalizeArguments( effect, options, speed, callback ) {
  7118. // allow passing all options as the first parameter
  7119. if ( $.isPlainObject( effect ) ) {
  7120. options = effect;
  7121. effect = effect.effect;
  7122. }
  7123. // convert to an object
  7124. effect = { effect: effect };
  7125. // catch (effect, null, ...)
  7126. if ( options == null ) {
  7127. options = {};
  7128. }
  7129. // catch (effect, callback)
  7130. if ( $.isFunction( options ) ) {
  7131. callback = options;
  7132. speed = null;
  7133. options = {};
  7134. }
  7135. // catch (effect, speed, ?)
  7136. if ( typeof options === "number" || $.fx.speeds[ options ] ) {
  7137. callback = speed;
  7138. speed = options;
  7139. options = {};
  7140. }
  7141. // catch (effect, options, callback)
  7142. if ( $.isFunction( speed ) ) {
  7143. callback = speed;
  7144. speed = null;
  7145. }
  7146. // add options to effect
  7147. if ( options ) {
  7148. $.extend( effect, options );
  7149. }
  7150. speed = speed || options.duration;
  7151. effect.duration = $.fx.off ? 0 :
  7152. typeof speed === "number" ? speed :
  7153. speed in $.fx.speeds ? $.fx.speeds[ speed ] :
  7154. $.fx.speeds._default;
  7155. effect.complete = callback || options.complete;
  7156. return effect;
  7157. }
  7158. function standardSpeed( speed ) {
  7159. // valid standard speeds
  7160. if ( !speed || typeof speed === "number" || $.fx.speeds[ speed ] ) {
  7161. return true;
  7162. }
  7163. // invalid strings - treat as "normal" speed
  7164. if ( typeof speed === "string" && !$.effects.effect[ speed ] ) {
  7165. // TODO: remove in 2.0 (#7115)
  7166. if ( backCompat && $.effects[ speed ] ) {
  7167. return false;
  7168. }
  7169. return true;
  7170. }
  7171. return false;
  7172. }
  7173. $.fn.extend({
  7174. effect: function( /* effect, options, speed, callback */ ) {
  7175. var args = _normalizeArguments.apply( this, arguments ),
  7176. mode = args.mode,
  7177. queue = args.queue,
  7178. effectMethod = $.effects.effect[ args.effect ],
  7179. // DEPRECATED: remove in 2.0 (#7115)
  7180. oldEffectMethod = !effectMethod && backCompat && $.effects[ args.effect ];
  7181. if ( $.fx.off || !( effectMethod || oldEffectMethod ) ) {
  7182. // delegate to the original method (e.g., .show()) if possible
  7183. if ( mode ) {
  7184. return this[ mode ]( args.duration, args.complete );
  7185. } else {
  7186. return this.each( function() {
  7187. if ( args.complete ) {
  7188. args.complete.call( this );
  7189. }
  7190. });
  7191. }
  7192. }
  7193. function run( next ) {
  7194. var elem = $( this ),
  7195. complete = args.complete,
  7196. mode = args.mode;
  7197. function done() {
  7198. if ( $.isFunction( complete ) ) {
  7199. complete.call( elem[0] );
  7200. }
  7201. if ( $.isFunction( next ) ) {
  7202. next();
  7203. }
  7204. }
  7205. // if the element is hiddden and mode is hide,
  7206. // or element is visible and mode is show
  7207. if ( elem.is( ":hidden" ) ? mode === "hide" : mode === "show" ) {
  7208. done();
  7209. } else {
  7210. effectMethod.call( elem[0], args, done );
  7211. }
  7212. }
  7213. // TODO: remove this check in 2.0, effectMethod will always be true
  7214. if ( effectMethod ) {
  7215. return queue === false ? this.each( run ) : this.queue( queue || "fx", run );
  7216. } else {
  7217. // DEPRECATED: remove in 2.0 (#7115)
  7218. return oldEffectMethod.call(this, {
  7219. options: args,
  7220. duration: args.duration,
  7221. callback: args.complete,
  7222. mode: args.mode
  7223. });
  7224. }
  7225. },
  7226. _show: $.fn.show,
  7227. show: function( speed ) {
  7228. if ( standardSpeed( speed ) ) {
  7229. return this._show.apply( this, arguments );
  7230. } else {
  7231. var args = _normalizeArguments.apply( this, arguments );
  7232. args.mode = "show";
  7233. return this.effect.call( this, args );
  7234. }
  7235. },
  7236. _hide: $.fn.hide,
  7237. hide: function( speed ) {
  7238. if ( standardSpeed( speed ) ) {
  7239. return this._hide.apply( this, arguments );
  7240. } else {
  7241. var args = _normalizeArguments.apply( this, arguments );
  7242. args.mode = "hide";
  7243. return this.effect.call( this, args );
  7244. }
  7245. },
  7246. // jQuery core overloads toggle and creates _toggle
  7247. __toggle: $.fn.toggle,
  7248. toggle: function( speed ) {
  7249. if ( standardSpeed( speed ) || typeof speed === "boolean" || $.isFunction( speed ) ) {
  7250. return this.__toggle.apply( this, arguments );
  7251. } else {
  7252. var args = _normalizeArguments.apply( this, arguments );
  7253. args.mode = "toggle";
  7254. return this.effect.call( this, args );
  7255. }
  7256. },
  7257. // helper functions
  7258. cssUnit: function(key) {
  7259. var style = this.css( key ),
  7260. val = [];
  7261. $.each( [ "em", "px", "%", "pt" ], function( i, unit ) {
  7262. if ( style.indexOf( unit ) > 0 ) {
  7263. val = [ parseFloat( style ), unit ];
  7264. }
  7265. });
  7266. return val;
  7267. }
  7268. });
  7269. })();
  7270. /******************************************************************************/
  7271. /*********************************** EASING ***********************************/
  7272. /******************************************************************************/
  7273. (function() {
  7274. // based on easing equations from Robert Penner (http://www.robertpenner.com/easing)
  7275. var baseEasings = {};
  7276. $.each( [ "Quad", "Cubic", "Quart", "Quint", "Expo" ], function( i, name ) {
  7277. baseEasings[ name ] = function( p ) {
  7278. return Math.pow( p, i + 2 );
  7279. };
  7280. });
  7281. $.extend( baseEasings, {
  7282. Sine: function ( p ) {
  7283. return 1 - Math.cos( p * Math.PI / 2 );
  7284. },
  7285. Circ: function ( p ) {
  7286. return 1 - Math.sqrt( 1 - p * p );
  7287. },
  7288. Elastic: function( p ) {
  7289. return p === 0 || p === 1 ? p :
  7290. -Math.pow( 2, 8 * (p - 1) ) * Math.sin( ( (p - 1) * 80 - 7.5 ) * Math.PI / 15 );
  7291. },
  7292. Back: function( p ) {
  7293. return p * p * ( 3 * p - 2 );
  7294. },
  7295. Bounce: function ( p ) {
  7296. var pow2,
  7297. bounce = 4;
  7298. while ( p < ( ( pow2 = Math.pow( 2, --bounce ) ) - 1 ) / 11 ) {}
  7299. return 1 / Math.pow( 4, 3 - bounce ) - 7.5625 * Math.pow( ( pow2 * 3 - 2 ) / 22 - p, 2 );
  7300. }
  7301. });
  7302. $.each( baseEasings, function( name, easeIn ) {
  7303. $.easing[ "easeIn" + name ] = easeIn;
  7304. $.easing[ "easeOut" + name ] = function( p ) {
  7305. return 1 - easeIn( 1 - p );
  7306. };
  7307. $.easing[ "easeInOut" + name ] = function( p ) {
  7308. return p < 0.5 ?
  7309. easeIn( p * 2 ) / 2 :
  7310. 1 - easeIn( p * -2 + 2 ) / 2;
  7311. };
  7312. });
  7313. })();
  7314. })(jQuery));
  7315. (function( $, undefined ) {
  7316. var rvertical = /up|down|vertical/,
  7317. rpositivemotion = /up|left|vertical|horizontal/;
  7318. $.effects.effect.blind = function( o, done ) {
  7319. // Create element
  7320. var el = $( this ),
  7321. props = [ "position", "top", "bottom", "left", "right", "height", "width" ],
  7322. mode = $.effects.setMode( el, o.mode || "hide" ),
  7323. direction = o.direction || "up",
  7324. vertical = rvertical.test( direction ),
  7325. ref = vertical ? "height" : "width",
  7326. ref2 = vertical ? "top" : "left",
  7327. motion = rpositivemotion.test( direction ),
  7328. animation = {},
  7329. show = mode === "show",
  7330. wrapper, distance, margin;
  7331. // if already wrapped, the wrapper's properties are my property. #6245
  7332. if ( el.parent().is( ".ui-effects-wrapper" ) ) {
  7333. $.effects.save( el.parent(), props );
  7334. } else {
  7335. $.effects.save( el, props );
  7336. }
  7337. el.show();
  7338. wrapper = $.effects.createWrapper( el ).css({
  7339. overflow: "hidden"
  7340. });
  7341. distance = wrapper[ ref ]();
  7342. margin = parseFloat( wrapper.css( ref2 ) ) || 0;
  7343. animation[ ref ] = show ? distance : 0;
  7344. if ( !motion ) {
  7345. el
  7346. .css( vertical ? "bottom" : "right", 0 )
  7347. .css( vertical ? "top" : "left", "auto" )
  7348. .css({ position: "absolute" });
  7349. animation[ ref2 ] = show ? margin : distance + margin;
  7350. }
  7351. // start at 0 if we are showing
  7352. if ( show ) {
  7353. wrapper.css( ref, 0 );
  7354. if ( ! motion ) {
  7355. wrapper.css( ref2, margin + distance );
  7356. }
  7357. }
  7358. // Animate
  7359. wrapper.animate( animation, {
  7360. duration: o.duration,
  7361. easing: o.easing,
  7362. queue: false,
  7363. complete: function() {
  7364. if ( mode === "hide" ) {
  7365. el.hide();
  7366. }
  7367. $.effects.restore( el, props );
  7368. $.effects.removeWrapper( el );
  7369. done();
  7370. }
  7371. });
  7372. };
  7373. })(jQuery);
  7374. (function( $, undefined ) {
  7375. $.effects.effect.bounce = function( o, done ) {
  7376. var el = $( this ),
  7377. props = [ "position", "top", "bottom", "left", "right", "height", "width" ],
  7378. // defaults:
  7379. mode = $.effects.setMode( el, o.mode || "effect" ),
  7380. hide = mode === "hide",
  7381. show = mode === "show",
  7382. direction = o.direction || "up",
  7383. distance = o.distance,
  7384. times = o.times || 5,
  7385. // number of internal animations
  7386. anims = times * 2 + ( show || hide ? 1 : 0 ),
  7387. speed = o.duration / anims,
  7388. easing = o.easing,
  7389. // utility:
  7390. ref = ( direction === "up" || direction === "down" ) ? "top" : "left",
  7391. motion = ( direction === "up" || direction === "left" ),
  7392. i,
  7393. upAnim,
  7394. downAnim,
  7395. // we will need to re-assemble the queue to stack our animations in place
  7396. queue = el.queue(),
  7397. queuelen = queue.length;
  7398. // Avoid touching opacity to prevent clearType and PNG issues in IE
  7399. if ( show || hide ) {
  7400. props.push( "opacity" );
  7401. }
  7402. $.effects.save( el, props );
  7403. el.show();
  7404. $.effects.createWrapper( el ); // Create Wrapper
  7405. // default distance for the BIGGEST bounce is the outer Distance / 3
  7406. if ( !distance ) {
  7407. distance = el[ ref === "top" ? "outerHeight" : "outerWidth" ]() / 3;
  7408. }
  7409. if ( show ) {
  7410. downAnim = { opacity: 1 };
  7411. downAnim[ ref ] = 0;
  7412. // if we are showing, force opacity 0 and set the initial position
  7413. // then do the "first" animation
  7414. el.css( "opacity", 0 )
  7415. .css( ref, motion ? -distance * 2 : distance * 2 )
  7416. .animate( downAnim, speed, easing );
  7417. }
  7418. // start at the smallest distance if we are hiding
  7419. if ( hide ) {
  7420. distance = distance / Math.pow( 2, times - 1 );
  7421. }
  7422. downAnim = {};
  7423. downAnim[ ref ] = 0;
  7424. // Bounces up/down/left/right then back to 0 -- times * 2 animations happen here
  7425. for ( i = 0; i < times; i++ ) {
  7426. upAnim = {};
  7427. upAnim[ ref ] = ( motion ? "-=" : "+=" ) + distance;
  7428. el.animate( upAnim, speed, easing )
  7429. .animate( downAnim, speed, easing );
  7430. distance = hide ? distance * 2 : distance / 2;
  7431. }
  7432. // Last Bounce when Hiding
  7433. if ( hide ) {
  7434. upAnim = { opacity: 0 };
  7435. upAnim[ ref ] = ( motion ? "-=" : "+=" ) + distance;
  7436. el.animate( upAnim, speed, easing );
  7437. }
  7438. el.queue(function() {
  7439. if ( hide ) {
  7440. el.hide();
  7441. }
  7442. $.effects.restore( el, props );
  7443. $.effects.removeWrapper( el );
  7444. done();
  7445. });
  7446. // inject all the animations we just queued to be first in line (after "inprogress")
  7447. if ( queuelen > 1) {
  7448. queue.splice.apply( queue,
  7449. [ 1, 0 ].concat( queue.splice( queuelen, anims + 1 ) ) );
  7450. }
  7451. el.dequeue();
  7452. };
  7453. })(jQuery);
  7454. (function( $, undefined ) {
  7455. $.effects.effect.clip = function( o, done ) {
  7456. // Create element
  7457. var el = $( this ),
  7458. props = [ "position", "top", "bottom", "left", "right", "height", "width" ],
  7459. mode = $.effects.setMode( el, o.mode || "hide" ),
  7460. show = mode === "show",
  7461. direction = o.direction || "vertical",
  7462. vert = direction === "vertical",
  7463. size = vert ? "height" : "width",
  7464. position = vert ? "top" : "left",
  7465. animation = {},
  7466. wrapper, animate, distance;
  7467. // Save & Show
  7468. $.effects.save( el, props );
  7469. el.show();
  7470. // Create Wrapper
  7471. wrapper = $.effects.createWrapper( el ).css({
  7472. overflow: "hidden"
  7473. });
  7474. animate = ( el[0].tagName === "IMG" ) ? wrapper : el;
  7475. distance = animate[ size ]();
  7476. // Shift
  7477. if ( show ) {
  7478. animate.css( size, 0 );
  7479. animate.css( position, distance / 2 );
  7480. }
  7481. // Create Animation Object:
  7482. animation[ size ] = show ? distance : 0;
  7483. animation[ position ] = show ? 0 : distance / 2;
  7484. // Animate
  7485. animate.animate( animation, {
  7486. queue: false,
  7487. duration: o.duration,
  7488. easing: o.easing,
  7489. complete: function() {
  7490. if ( !show ) {
  7491. el.hide();
  7492. }
  7493. $.effects.restore( el, props );
  7494. $.effects.removeWrapper( el );
  7495. done();
  7496. }
  7497. });
  7498. };
  7499. })(jQuery);
  7500. (function( $, undefined ) {
  7501. $.effects.effect.drop = function( o, done ) {
  7502. var el = $( this ),
  7503. props = [ "position", "top", "bottom", "left", "right", "opacity", "height", "width" ],
  7504. mode = $.effects.setMode( el, o.mode || "hide" ),
  7505. show = mode === "show",
  7506. direction = o.direction || "left",
  7507. ref = ( direction === "up" || direction === "down" ) ? "top" : "left",
  7508. motion = ( direction === "up" || direction === "left" ) ? "pos" : "neg",
  7509. animation = {
  7510. opacity: show ? 1 : 0
  7511. },
  7512. distance;
  7513. // Adjust
  7514. $.effects.save( el, props );
  7515. el.show();
  7516. $.effects.createWrapper( el );
  7517. distance = o.distance || el[ ref === "top" ? "outerHeight": "outerWidth" ]( true ) / 2;
  7518. if ( show ) {
  7519. el
  7520. .css( "opacity", 0 )
  7521. .css( ref, motion === "pos" ? -distance : distance );
  7522. }
  7523. // Animation
  7524. animation[ ref ] = ( show ?
  7525. ( motion === "pos" ? "+=" : "-=" ) :
  7526. ( motion === "pos" ? "-=" : "+=" ) ) +
  7527. distance;
  7528. // Animate
  7529. el.animate( animation, {
  7530. queue: false,
  7531. duration: o.duration,
  7532. easing: o.easing,
  7533. complete: function() {
  7534. if ( mode === "hide" ) {
  7535. el.hide();
  7536. }
  7537. $.effects.restore( el, props );
  7538. $.effects.removeWrapper( el );
  7539. done();
  7540. }
  7541. });
  7542. };
  7543. })(jQuery);
  7544. (function( $, undefined ) {
  7545. $.effects.effect.explode = function( o, done ) {
  7546. var rows = o.pieces ? Math.round( Math.sqrt( o.pieces ) ) : 3,
  7547. cells = rows,
  7548. el = $( this ),
  7549. mode = $.effects.setMode( el, o.mode || "hide" ),
  7550. show = mode === "show",
  7551. // show and then visibility:hidden the element before calculating offset
  7552. offset = el.show().css( "visibility", "hidden" ).offset(),
  7553. // width and height of a piece
  7554. width = Math.ceil( el.outerWidth() / cells ),
  7555. height = Math.ceil( el.outerHeight() / rows ),
  7556. pieces = [],
  7557. // loop
  7558. i, j, left, top, mx, my;
  7559. // children animate complete:
  7560. function childComplete() {
  7561. pieces.push( this );
  7562. if ( pieces.length === rows * cells ) {
  7563. animComplete();
  7564. }
  7565. }
  7566. // clone the element for each row and cell.
  7567. for( i = 0; i < rows ; i++ ) { // ===>
  7568. top = offset.top + i * height;
  7569. my = i - ( rows - 1 ) / 2 ;
  7570. for( j = 0; j < cells ; j++ ) { // |||
  7571. left = offset.left + j * width;
  7572. mx = j - ( cells - 1 ) / 2 ;
  7573. // Create a clone of the now hidden main element that will be absolute positioned
  7574. // within a wrapper div off the -left and -top equal to size of our pieces
  7575. el
  7576. .clone()
  7577. .appendTo( "body" )
  7578. .wrap( "<div></div>" )
  7579. .css({
  7580. position: "absolute",
  7581. visibility: "visible",
  7582. left: -j * width,
  7583. top: -i * height
  7584. })
  7585. // select the wrapper - make it overflow: hidden and absolute positioned based on
  7586. // where the original was located +left and +top equal to the size of pieces
  7587. .parent()
  7588. .addClass( "ui-effects-explode" )
  7589. .css({
  7590. position: "absolute",
  7591. overflow: "hidden",
  7592. width: width,
  7593. height: height,
  7594. left: left + ( show ? mx * width : 0 ),
  7595. top: top + ( show ? my * height : 0 ),
  7596. opacity: show ? 0 : 1
  7597. }).animate({
  7598. left: left + ( show ? 0 : mx * width ),
  7599. top: top + ( show ? 0 : my * height ),
  7600. opacity: show ? 1 : 0
  7601. }, o.duration || 500, o.easing, childComplete );
  7602. }
  7603. }
  7604. function animComplete() {
  7605. el.css({
  7606. visibility: "visible"
  7607. });
  7608. $( pieces ).remove();
  7609. if ( !show ) {
  7610. el.hide();
  7611. }
  7612. done();
  7613. }
  7614. };
  7615. })(jQuery);
  7616. (function( $, undefined ) {
  7617. $.effects.effect.fade = function( o, done ) {
  7618. var el = $( this ),
  7619. mode = $.effects.setMode( el, o.mode || "toggle" );
  7620. el.animate({
  7621. opacity: mode
  7622. }, {
  7623. queue: false,
  7624. duration: o.duration,
  7625. easing: o.easing,
  7626. complete: done
  7627. });
  7628. };
  7629. })( jQuery );
  7630. (function( $, undefined ) {
  7631. $.effects.effect.fold = function( o, done ) {
  7632. // Create element
  7633. var el = $( this ),
  7634. props = [ "position", "top", "bottom", "left", "right", "height", "width" ],
  7635. mode = $.effects.setMode( el, o.mode || "hide" ),
  7636. show = mode === "show",
  7637. hide = mode === "hide",
  7638. size = o.size || 15,
  7639. percent = /([0-9]+)%/.exec( size ),
  7640. horizFirst = !!o.horizFirst,
  7641. widthFirst = show !== horizFirst,
  7642. ref = widthFirst ? [ "width", "height" ] : [ "height", "width" ],
  7643. duration = o.duration / 2,
  7644. wrapper, distance,
  7645. animation1 = {},
  7646. animation2 = {};
  7647. $.effects.save( el, props );
  7648. el.show();
  7649. // Create Wrapper
  7650. wrapper = $.effects.createWrapper( el ).css({
  7651. overflow: "hidden"
  7652. });
  7653. distance = widthFirst ?
  7654. [ wrapper.width(), wrapper.height() ] :
  7655. [ wrapper.height(), wrapper.width() ];
  7656. if ( percent ) {
  7657. size = parseInt( percent[ 1 ], 10 ) / 100 * distance[ hide ? 0 : 1 ];
  7658. }
  7659. if ( show ) {
  7660. wrapper.css( horizFirst ? {
  7661. height: 0,
  7662. width: size
  7663. } : {
  7664. height: size,
  7665. width: 0
  7666. });
  7667. }
  7668. // Animation
  7669. animation1[ ref[ 0 ] ] = show ? distance[ 0 ] : size;
  7670. animation2[ ref[ 1 ] ] = show ? distance[ 1 ] : 0;
  7671. // Animate
  7672. wrapper
  7673. .animate( animation1, duration, o.easing )
  7674. .animate( animation2, duration, o.easing, function() {
  7675. if ( hide ) {
  7676. el.hide();
  7677. }
  7678. $.effects.restore( el, props );
  7679. $.effects.removeWrapper( el );
  7680. done();
  7681. });
  7682. };
  7683. })(jQuery);
  7684. (function( $, undefined ) {
  7685. $.effects.effect.highlight = function( o, done ) {
  7686. var elem = $( this ),
  7687. props = [ "backgroundImage", "backgroundColor", "opacity" ],
  7688. mode = $.effects.setMode( elem, o.mode || "show" ),
  7689. animation = {
  7690. backgroundColor: elem.css( "backgroundColor" )
  7691. };
  7692. if (mode === "hide") {
  7693. animation.opacity = 0;
  7694. }
  7695. $.effects.save( elem, props );
  7696. elem
  7697. .show()
  7698. .css({
  7699. backgroundImage: "none",
  7700. backgroundColor: o.color || "#ffff99"
  7701. })
  7702. .animate( animation, {
  7703. queue: false,
  7704. duration: o.duration,
  7705. easing: o.easing,
  7706. complete: function() {
  7707. if ( mode === "hide" ) {
  7708. elem.hide();
  7709. }
  7710. $.effects.restore( elem, props );
  7711. done();
  7712. }
  7713. });
  7714. };
  7715. })(jQuery);
  7716. (function( $, undefined ) {
  7717. $.effects.effect.pulsate = function( o, done ) {
  7718. var elem = $( this ),
  7719. mode = $.effects.setMode( elem, o.mode || "show" ),
  7720. show = mode === "show",
  7721. hide = mode === "hide",
  7722. showhide = ( show || mode === "hide" ),
  7723. // showing or hiding leaves of the "last" animation
  7724. anims = ( ( o.times || 5 ) * 2 ) + ( showhide ? 1 : 0 ),
  7725. duration = o.duration / anims,
  7726. animateTo = 0,
  7727. queue = elem.queue(),
  7728. queuelen = queue.length,
  7729. i;
  7730. if ( show || !elem.is(":visible")) {
  7731. elem.css( "opacity", 0 ).show();
  7732. animateTo = 1;
  7733. }
  7734. // anims - 1 opacity "toggles"
  7735. for ( i = 1; i < anims; i++ ) {
  7736. elem.animate({
  7737. opacity: animateTo
  7738. }, duration, o.easing );
  7739. animateTo = 1 - animateTo;
  7740. }
  7741. elem.animate({
  7742. opacity: animateTo
  7743. }, duration, o.easing);
  7744. elem.queue(function() {
  7745. if ( hide ) {
  7746. elem.hide();
  7747. }
  7748. done();
  7749. });
  7750. // We just queued up "anims" animations, we need to put them next in the queue
  7751. if ( queuelen > 1 ) {
  7752. queue.splice.apply( queue,
  7753. [ 1, 0 ].concat( queue.splice( queuelen, anims + 1 ) ) );
  7754. }
  7755. elem.dequeue();
  7756. };
  7757. })(jQuery);
  7758. (function( $, undefined ) {
  7759. $.effects.effect.puff = function( o, done ) {
  7760. var elem = $( this ),
  7761. mode = $.effects.setMode( elem, o.mode || "hide" ),
  7762. hide = mode === "hide",
  7763. percent = parseInt( o.percent, 10 ) || 150,
  7764. factor = percent / 100,
  7765. original = {
  7766. height: elem.height(),
  7767. width: elem.width(),
  7768. outerHeight: elem.outerHeight(),
  7769. outerWidth: elem.outerWidth()
  7770. };
  7771. $.extend( o, {
  7772. effect: "scale",
  7773. queue: false,
  7774. fade: true,
  7775. mode: mode,
  7776. complete: done,
  7777. percent: hide ? percent : 100,
  7778. from: hide ?
  7779. original :
  7780. {
  7781. height: original.height * factor,
  7782. width: original.width * factor,
  7783. outerHeight: original.outerHeight * factor,
  7784. outerWidth: original.outerWidth * factor
  7785. }
  7786. });
  7787. elem.effect( o );
  7788. };
  7789. $.effects.effect.scale = function( o, done ) {
  7790. // Create element
  7791. var el = $( this ),
  7792. options = $.extend( true, {}, o ),
  7793. mode = $.effects.setMode( el, o.mode || "effect" ),
  7794. percent = parseInt( o.percent, 10 ) ||
  7795. ( parseInt( o.percent, 10 ) === 0 ? 0 : ( mode === "hide" ? 0 : 100 ) ),
  7796. direction = o.direction || "both",
  7797. origin = o.origin,
  7798. original = {
  7799. height: el.height(),
  7800. width: el.width(),
  7801. outerHeight: el.outerHeight(),
  7802. outerWidth: el.outerWidth()
  7803. },
  7804. factor = {
  7805. y: direction !== "horizontal" ? (percent / 100) : 1,
  7806. x: direction !== "vertical" ? (percent / 100) : 1
  7807. };
  7808. // We are going to pass this effect to the size effect:
  7809. options.effect = "size";
  7810. options.queue = false;
  7811. options.complete = done;
  7812. // Set default origin and restore for show/hide
  7813. if ( mode !== "effect" ) {
  7814. options.origin = origin || ["middle","center"];
  7815. options.restore = true;
  7816. }
  7817. options.from = o.from || ( mode === "show" ? {
  7818. height: 0,
  7819. width: 0,
  7820. outerHeight: 0,
  7821. outerWidth: 0
  7822. } : original );
  7823. options.to = {
  7824. height: original.height * factor.y,
  7825. width: original.width * factor.x,
  7826. outerHeight: original.outerHeight * factor.y,
  7827. outerWidth: original.outerWidth * factor.x
  7828. };
  7829. // Fade option to support puff
  7830. if ( options.fade ) {
  7831. if ( mode === "show" ) {
  7832. options.from.opacity = 0;
  7833. options.to.opacity = 1;
  7834. }
  7835. if ( mode === "hide" ) {
  7836. options.from.opacity = 1;
  7837. options.to.opacity = 0;
  7838. }
  7839. }
  7840. // Animate
  7841. el.effect( options );
  7842. };
  7843. $.effects.effect.size = function( o, done ) {
  7844. // Create element
  7845. var original, baseline, factor,
  7846. el = $( this ),
  7847. props0 = [ "position", "top", "bottom", "left", "right", "width", "height", "overflow", "opacity" ],
  7848. // Always restore
  7849. props1 = [ "position", "top", "bottom", "left", "right", "overflow", "opacity" ],
  7850. // Copy for children
  7851. props2 = [ "width", "height", "overflow" ],
  7852. cProps = [ "fontSize" ],
  7853. vProps = [ "borderTopWidth", "borderBottomWidth", "paddingTop", "paddingBottom" ],
  7854. hProps = [ "borderLeftWidth", "borderRightWidth", "paddingLeft", "paddingRight" ],
  7855. // Set options
  7856. mode = $.effects.setMode( el, o.mode || "effect" ),
  7857. restore = o.restore || mode !== "effect",
  7858. scale = o.scale || "both",
  7859. origin = o.origin || [ "middle", "center" ],
  7860. position = el.css( "position" ),
  7861. props = restore ? props0 : props1,
  7862. zero = {
  7863. height: 0,
  7864. width: 0,
  7865. outerHeight: 0,
  7866. outerWidth: 0
  7867. };
  7868. if ( mode === "show" ) {
  7869. el.show();
  7870. }
  7871. original = {
  7872. height: el.height(),
  7873. width: el.width(),
  7874. outerHeight: el.outerHeight(),
  7875. outerWidth: el.outerWidth()
  7876. };
  7877. if ( o.mode === "toggle" && mode === "show" ) {
  7878. el.from = o.to || zero;
  7879. el.to = o.from || original;
  7880. } else {
  7881. el.from = o.from || ( mode === "show" ? zero : original );
  7882. el.to = o.to || ( mode === "hide" ? zero : original );
  7883. }
  7884. // Set scaling factor
  7885. factor = {
  7886. from: {
  7887. y: el.from.height / original.height,
  7888. x: el.from.width / original.width
  7889. },
  7890. to: {
  7891. y: el.to.height / original.height,
  7892. x: el.to.width / original.width
  7893. }
  7894. };
  7895. // Scale the css box
  7896. if ( scale === "box" || scale === "both" ) {
  7897. // Vertical props scaling
  7898. if ( factor.from.y !== factor.to.y ) {
  7899. props = props.concat( vProps );
  7900. el.from = $.effects.setTransition( el, vProps, factor.from.y, el.from );
  7901. el.to = $.effects.setTransition( el, vProps, factor.to.y, el.to );
  7902. }
  7903. // Horizontal props scaling
  7904. if ( factor.from.x !== factor.to.x ) {
  7905. props = props.concat( hProps );
  7906. el.from = $.effects.setTransition( el, hProps, factor.from.x, el.from );
  7907. el.to = $.effects.setTransition( el, hProps, factor.to.x, el.to );
  7908. }
  7909. }
  7910. // Scale the content
  7911. if ( scale === "content" || scale === "both" ) {
  7912. // Vertical props scaling
  7913. if ( factor.from.y !== factor.to.y ) {
  7914. props = props.concat( cProps ).concat( props2 );
  7915. el.from = $.effects.setTransition( el, cProps, factor.from.y, el.from );
  7916. el.to = $.effects.setTransition( el, cProps, factor.to.y, el.to );
  7917. }
  7918. }
  7919. $.effects.save( el, props );
  7920. el.show();
  7921. $.effects.createWrapper( el );
  7922. el.css( "overflow", "hidden" ).css( el.from );
  7923. // Adjust
  7924. if (origin) { // Calculate baseline shifts
  7925. baseline = $.effects.getBaseline( origin, original );
  7926. el.from.top = ( original.outerHeight - el.outerHeight() ) * baseline.y;
  7927. el.from.left = ( original.outerWidth - el.outerWidth() ) * baseline.x;
  7928. el.to.top = ( original.outerHeight - el.to.outerHeight ) * baseline.y;
  7929. el.to.left = ( original.outerWidth - el.to.outerWidth ) * baseline.x;
  7930. }
  7931. el.css( el.from ); // set top & left
  7932. // Animate
  7933. if ( scale === "content" || scale === "both" ) { // Scale the children
  7934. // Add margins/font-size
  7935. vProps = vProps.concat([ "marginTop", "marginBottom" ]).concat(cProps);
  7936. hProps = hProps.concat([ "marginLeft", "marginRight" ]);
  7937. props2 = props0.concat(vProps).concat(hProps);
  7938. el.find( "*[width]" ).each( function(){
  7939. var child = $( this ),
  7940. c_original = {
  7941. height: child.height(),
  7942. width: child.width(),
  7943. outerHeight: child.outerHeight(),
  7944. outerWidth: child.outerWidth()
  7945. };
  7946. if (restore) {
  7947. $.effects.save(child, props2);
  7948. }
  7949. child.from = {
  7950. height: c_original.height * factor.from.y,
  7951. width: c_original.width * factor.from.x,
  7952. outerHeight: c_original.outerHeight * factor.from.y,
  7953. outerWidth: c_original.outerWidth * factor.from.x
  7954. };
  7955. child.to = {
  7956. height: c_original.height * factor.to.y,
  7957. width: c_original.width * factor.to.x,
  7958. outerHeight: c_original.height * factor.to.y,
  7959. outerWidth: c_original.width * factor.to.x
  7960. };
  7961. // Vertical props scaling
  7962. if ( factor.from.y !== factor.to.y ) {
  7963. child.from = $.effects.setTransition( child, vProps, factor.from.y, child.from );
  7964. child.to = $.effects.setTransition( child, vProps, factor.to.y, child.to );
  7965. }
  7966. // Horizontal props scaling
  7967. if ( factor.from.x !== factor.to.x ) {
  7968. child.from = $.effects.setTransition( child, hProps, factor.from.x, child.from );
  7969. child.to = $.effects.setTransition( child, hProps, factor.to.x, child.to );
  7970. }
  7971. // Animate children
  7972. child.css( child.from );
  7973. child.animate( child.to, o.duration, o.easing, function() {
  7974. // Restore children
  7975. if ( restore ) {
  7976. $.effects.restore( child, props2 );
  7977. }
  7978. });
  7979. });
  7980. }
  7981. // Animate
  7982. el.animate( el.to, {
  7983. queue: false,
  7984. duration: o.duration,
  7985. easing: o.easing,
  7986. complete: function() {
  7987. if ( el.to.opacity === 0 ) {
  7988. el.css( "opacity", el.from.opacity );
  7989. }
  7990. if( mode === "hide" ) {
  7991. el.hide();
  7992. }
  7993. $.effects.restore( el, props );
  7994. if ( !restore ) {
  7995. // we need to calculate our new positioning based on the scaling
  7996. if ( position === "static" ) {
  7997. el.css({
  7998. position: "relative",
  7999. top: el.to.top,
  8000. left: el.to.left
  8001. });
  8002. } else {
  8003. $.each([ "top", "left" ], function( idx, pos ) {
  8004. el.css( pos, function( _, str ) {
  8005. var val = parseInt( str, 10 ),
  8006. toRef = idx ? el.to.left : el.to.top;
  8007. // if original was "auto", recalculate the new value from wrapper
  8008. if ( str === "auto" ) {
  8009. return toRef + "px";
  8010. }
  8011. return val + toRef + "px";
  8012. });
  8013. });
  8014. }
  8015. }
  8016. $.effects.removeWrapper( el );
  8017. done();
  8018. }
  8019. });
  8020. };
  8021. })(jQuery);
  8022. (function( $, undefined ) {
  8023. $.effects.effect.shake = function( o, done ) {
  8024. var el = $( this ),
  8025. props = [ "position", "top", "bottom", "left", "right", "height", "width" ],
  8026. mode = $.effects.setMode( el, o.mode || "effect" ),
  8027. direction = o.direction || "left",
  8028. distance = o.distance || 20,
  8029. times = o.times || 3,
  8030. anims = times * 2 + 1,
  8031. speed = Math.round(o.duration/anims),
  8032. ref = (direction === "up" || direction === "down") ? "top" : "left",
  8033. positiveMotion = (direction === "up" || direction === "left"),
  8034. animation = {},
  8035. animation1 = {},
  8036. animation2 = {},
  8037. i,
  8038. // we will need to re-assemble the queue to stack our animations in place
  8039. queue = el.queue(),
  8040. queuelen = queue.length;
  8041. $.effects.save( el, props );
  8042. el.show();
  8043. $.effects.createWrapper( el );
  8044. // Animation
  8045. animation[ ref ] = ( positiveMotion ? "-=" : "+=" ) + distance;
  8046. animation1[ ref ] = ( positiveMotion ? "+=" : "-=" ) + distance * 2;
  8047. animation2[ ref ] = ( positiveMotion ? "-=" : "+=" ) + distance * 2;
  8048. // Animate
  8049. el.animate( animation, speed, o.easing );
  8050. // Shakes
  8051. for ( i = 1; i < times; i++ ) {
  8052. el.animate( animation1, speed, o.easing ).animate( animation2, speed, o.easing );
  8053. }
  8054. el
  8055. .animate( animation1, speed, o.easing )
  8056. .animate( animation, speed / 2, o.easing )
  8057. .queue(function() {
  8058. if ( mode === "hide" ) {
  8059. el.hide();
  8060. }
  8061. $.effects.restore( el, props );
  8062. $.effects.removeWrapper( el );
  8063. done();
  8064. });
  8065. // inject all the animations we just queued to be first in line (after "inprogress")
  8066. if ( queuelen > 1) {
  8067. queue.splice.apply( queue,
  8068. [ 1, 0 ].concat( queue.splice( queuelen, anims + 1 ) ) );
  8069. }
  8070. el.dequeue();
  8071. };
  8072. })(jQuery);
  8073. (function( $, undefined ) {
  8074. $.effects.effect.slide = function( o, done ) {
  8075. // Create element
  8076. var el = $( this ),
  8077. props = [ "position", "top", "bottom", "left", "right", "width", "height" ],
  8078. mode = $.effects.setMode( el, o.mode || "show" ),
  8079. show = mode === "show",
  8080. direction = o.direction || "left",
  8081. ref = (direction === "up" || direction === "down") ? "top" : "left",
  8082. positiveMotion = (direction === "up" || direction === "left"),
  8083. distance,
  8084. animation = {};
  8085. // Adjust
  8086. $.effects.save( el, props );
  8087. el.show();
  8088. distance = o.distance || el[ ref === "top" ? "outerHeight" : "outerWidth" ]( true );
  8089. $.effects.createWrapper( el ).css({
  8090. overflow: "hidden"
  8091. });
  8092. if ( show ) {
  8093. el.css( ref, positiveMotion ? (isNaN(distance) ? "-" + distance : -distance) : distance );
  8094. }
  8095. // Animation
  8096. animation[ ref ] = ( show ?
  8097. ( positiveMotion ? "+=" : "-=") :
  8098. ( positiveMotion ? "-=" : "+=")) +
  8099. distance;
  8100. // Animate
  8101. el.animate( animation, {
  8102. queue: false,
  8103. duration: o.duration,
  8104. easing: o.easing,
  8105. complete: function() {
  8106. if ( mode === "hide" ) {
  8107. el.hide();
  8108. }
  8109. $.effects.restore( el, props );
  8110. $.effects.removeWrapper( el );
  8111. done();
  8112. }
  8113. });
  8114. };
  8115. })(jQuery);
  8116. (function( $, undefined ) {
  8117. $.effects.effect.transfer = function( o, done ) {
  8118. var elem = $( this ),
  8119. target = $( o.to ),
  8120. targetFixed = target.css( "position" ) === "fixed",
  8121. body = $("body"),
  8122. fixTop = targetFixed ? body.scrollTop() : 0,
  8123. fixLeft = targetFixed ? body.scrollLeft() : 0,
  8124. endPosition = target.offset(),
  8125. animation = {
  8126. top: endPosition.top - fixTop ,
  8127. left: endPosition.left - fixLeft ,
  8128. height: target.innerHeight(),
  8129. width: target.innerWidth()
  8130. },
  8131. startPosition = elem.offset(),
  8132. transfer = $( '<div class="ui-effects-transfer"></div>' )
  8133. .appendTo( document.body )
  8134. .addClass( o.className )
  8135. .css({
  8136. top: startPosition.top - fixTop ,
  8137. left: startPosition.left - fixLeft ,
  8138. height: elem.innerHeight(),
  8139. width: elem.innerWidth(),
  8140. position: targetFixed ? "fixed" : "absolute"
  8141. })
  8142. .animate( animation, o.duration, o.easing, function() {
  8143. transfer.remove();
  8144. done();
  8145. });
  8146. };
  8147. })(jQuery);
  8148. (function( $, undefined ) {
  8149. var mouseHandled = false;
  8150. $.widget( "ui.menu", {
  8151. version: "1.9.2",
  8152. defaultElement: "<ul>",
  8153. delay: 300,
  8154. options: {
  8155. icons: {
  8156. submenu: "ui-icon-carat-1-e"
  8157. },
  8158. menus: "ul",
  8159. position: {
  8160. my: "left top",
  8161. at: "right top"
  8162. },
  8163. role: "menu",
  8164. // callbacks
  8165. blur: null,
  8166. focus: null,
  8167. select: null
  8168. },
  8169. _create: function() {
  8170. this.activeMenu = this.element;
  8171. this.element
  8172. .uniqueId()
  8173. .addClass( "ui-menu ui-widget ui-widget-content ui-corner-all" )
  8174. .toggleClass( "ui-menu-icons", !!this.element.find( ".ui-icon" ).length )
  8175. .attr({
  8176. role: this.options.role,
  8177. tabIndex: 0
  8178. })
  8179. // need to catch all clicks on disabled menu
  8180. // not possible through _on
  8181. .bind( "click" + this.eventNamespace, $.proxy(function( event ) {
  8182. if ( this.options.disabled ) {
  8183. event.preventDefault();
  8184. }
  8185. }, this ));
  8186. if ( this.options.disabled ) {
  8187. this.element
  8188. .addClass( "ui-state-disabled" )
  8189. .attr( "aria-disabled", "true" );
  8190. }
  8191. this._on({
  8192. // Prevent focus from sticking to links inside menu after clicking
  8193. // them (focus should always stay on UL during navigation).
  8194. "mousedown .ui-menu-item > a": function( event ) {
  8195. event.preventDefault();
  8196. },
  8197. "click .ui-state-disabled > a": function( event ) {
  8198. event.preventDefault();
  8199. },
  8200. "click .ui-menu-item:has(a)": function( event ) {
  8201. var target = $( event.target ).closest( ".ui-menu-item" );
  8202. if ( !mouseHandled && target.not( ".ui-state-disabled" ).length ) {
  8203. mouseHandled = true;
  8204. this.select( event );
  8205. // Open submenu on click
  8206. if ( target.has( ".ui-menu" ).length ) {
  8207. this.expand( event );
  8208. } else if ( !this.element.is( ":focus" ) ) {
  8209. // Redirect focus to the menu
  8210. this.element.trigger( "focus", [ true ] );
  8211. // If the active item is on the top level, let it stay active.
  8212. // Otherwise, blur the active item since it is no longer visible.
  8213. if ( this.active && this.active.parents( ".ui-menu" ).length === 1 ) {
  8214. clearTimeout( this.timer );
  8215. }
  8216. }
  8217. }
  8218. },
  8219. "mouseenter .ui-menu-item": function( event ) {
  8220. var target = $( event.currentTarget );
  8221. // Remove ui-state-active class from siblings of the newly focused menu item
  8222. // to avoid a jump caused by adjacent elements both having a class with a border
  8223. target.siblings().children( ".ui-state-active" ).removeClass( "ui-state-active" );
  8224. this.focus( event, target );
  8225. },
  8226. mouseleave: "collapseAll",
  8227. "mouseleave .ui-menu": "collapseAll",
  8228. focus: function( event, keepActiveItem ) {
  8229. // If there's already an active item, keep it active
  8230. // If not, activate the first item
  8231. var item = this.active || this.element.children( ".ui-menu-item" ).eq( 0 );
  8232. if ( !keepActiveItem ) {
  8233. this.focus( event, item );
  8234. }
  8235. },
  8236. blur: function( event ) {
  8237. this._delay(function() {
  8238. if ( !$.contains( this.element[0], this.document[0].activeElement ) ) {
  8239. this.collapseAll( event );
  8240. }
  8241. });
  8242. },
  8243. keydown: "_keydown"
  8244. });
  8245. this.refresh();
  8246. // Clicks outside of a menu collapse any open menus
  8247. this._on( this.document, {
  8248. click: function( event ) {
  8249. if ( !$( event.target ).closest( ".ui-menu" ).length ) {
  8250. this.collapseAll( event );
  8251. }
  8252. // Reset the mouseHandled flag
  8253. mouseHandled = false;
  8254. }
  8255. });
  8256. },
  8257. _destroy: function() {
  8258. // Destroy (sub)menus
  8259. this.element
  8260. .removeAttr( "aria-activedescendant" )
  8261. .find( ".ui-menu" ).andSelf()
  8262. .removeClass( "ui-menu ui-widget ui-widget-content ui-corner-all ui-menu-icons" )
  8263. .removeAttr( "role" )
  8264. .removeAttr( "tabIndex" )
  8265. .removeAttr( "aria-labelledby" )
  8266. .removeAttr( "aria-expanded" )
  8267. .removeAttr( "aria-hidden" )
  8268. .removeAttr( "aria-disabled" )
  8269. .removeUniqueId()
  8270. .show();
  8271. // Destroy menu items
  8272. this.element.find( ".ui-menu-item" )
  8273. .removeClass( "ui-menu-item" )
  8274. .removeAttr( "role" )
  8275. .removeAttr( "aria-disabled" )
  8276. .children( "a" )
  8277. .removeUniqueId()
  8278. .removeClass( "ui-corner-all ui-state-hover" )
  8279. .removeAttr( "tabIndex" )
  8280. .removeAttr( "role" )
  8281. .removeAttr( "aria-haspopup" )
  8282. .children().each( function() {
  8283. var elem = $( this );
  8284. if ( elem.data( "ui-menu-submenu-carat" ) ) {
  8285. elem.remove();
  8286. }
  8287. });
  8288. // Destroy menu dividers
  8289. this.element.find( ".ui-menu-divider" ).removeClass( "ui-menu-divider ui-widget-content" );
  8290. },
  8291. _keydown: function( event ) {
  8292. var match, prev, character, skip, regex,
  8293. preventDefault = true;
  8294. function escape( value ) {
  8295. return value.replace( /[\-\[\]{}()*+?.,\\\^$|#\s]/g, "\\$&" );
  8296. }
  8297. switch ( event.keyCode ) {
  8298. case $.ui.keyCode.PAGE_UP:
  8299. this.previousPage( event );
  8300. break;
  8301. case $.ui.keyCode.PAGE_DOWN:
  8302. this.nextPage( event );
  8303. break;
  8304. case $.ui.keyCode.HOME:
  8305. this._move( "first", "first", event );
  8306. break;
  8307. case $.ui.keyCode.END:
  8308. this._move( "last", "last", event );
  8309. break;
  8310. case $.ui.keyCode.UP:
  8311. this.previous( event );
  8312. break;
  8313. case $.ui.keyCode.DOWN:
  8314. this.next( event );
  8315. break;
  8316. case $.ui.keyCode.LEFT:
  8317. this.collapse( event );
  8318. break;
  8319. case $.ui.keyCode.RIGHT:
  8320. if ( this.active && !this.active.is( ".ui-state-disabled" ) ) {
  8321. this.expand( event );
  8322. }
  8323. break;
  8324. case $.ui.keyCode.ENTER:
  8325. case $.ui.keyCode.SPACE:
  8326. this._activate( event );
  8327. break;
  8328. case $.ui.keyCode.ESCAPE:
  8329. this.collapse( event );
  8330. break;
  8331. default:
  8332. preventDefault = false;
  8333. prev = this.previousFilter || "";
  8334. character = String.fromCharCode( event.keyCode );
  8335. skip = false;
  8336. clearTimeout( this.filterTimer );
  8337. if ( character === prev ) {
  8338. skip = true;
  8339. } else {
  8340. character = prev + character;
  8341. }
  8342. regex = new RegExp( "^" + escape( character ), "i" );
  8343. match = this.activeMenu.children( ".ui-menu-item" ).filter(function() {
  8344. return regex.test( $( this ).children( "a" ).text() );
  8345. });
  8346. match = skip && match.index( this.active.next() ) !== -1 ?
  8347. this.active.nextAll( ".ui-menu-item" ) :
  8348. match;
  8349. // If no matches on the current filter, reset to the last character pressed
  8350. // to move down the menu to the first item that starts with that character
  8351. if ( !match.length ) {
  8352. character = String.fromCharCode( event.keyCode );
  8353. regex = new RegExp( "^" + escape( character ), "i" );
  8354. match = this.activeMenu.children( ".ui-menu-item" ).filter(function() {
  8355. return regex.test( $( this ).children( "a" ).text() );
  8356. });
  8357. }
  8358. if ( match.length ) {
  8359. this.focus( event, match );
  8360. if ( match.length > 1 ) {
  8361. this.previousFilter = character;
  8362. this.filterTimer = this._delay(function() {
  8363. delete this.previousFilter;
  8364. }, 1000 );
  8365. } else {
  8366. delete this.previousFilter;
  8367. }
  8368. } else {
  8369. delete this.previousFilter;
  8370. }
  8371. }
  8372. if ( preventDefault ) {
  8373. event.preventDefault();
  8374. }
  8375. },
  8376. _activate: function( event ) {
  8377. if ( !this.active.is( ".ui-state-disabled" ) ) {
  8378. if ( this.active.children( "a[aria-haspopup='true']" ).length ) {
  8379. this.expand( event );
  8380. } else {
  8381. this.select( event );
  8382. }
  8383. }
  8384. },
  8385. refresh: function() {
  8386. var menus,
  8387. icon = this.options.icons.submenu,
  8388. submenus = this.element.find( this.options.menus );
  8389. // Initialize nested menus
  8390. submenus.filter( ":not(.ui-menu)" )
  8391. .addClass( "ui-menu ui-widget ui-widget-content ui-corner-all" )
  8392. .hide()
  8393. .attr({
  8394. role: this.options.role,
  8395. "aria-hidden": "true",
  8396. "aria-expanded": "false"
  8397. })
  8398. .each(function() {
  8399. var menu = $( this ),
  8400. item = menu.prev( "a" ),
  8401. submenuCarat = $( "<span>" )
  8402. .addClass( "ui-menu-icon ui-icon " + icon )
  8403. .data( "ui-menu-submenu-carat", true );
  8404. item
  8405. .attr( "aria-haspopup", "true" )
  8406. .prepend( submenuCarat );
  8407. menu.attr( "aria-labelledby", item.attr( "id" ) );
  8408. });
  8409. menus = submenus.add( this.element );
  8410. // Don't refresh list items that are already adapted
  8411. menus.children( ":not(.ui-menu-item):has(a)" )
  8412. .addClass( "ui-menu-item" )
  8413. .attr( "role", "presentation" )
  8414. .children( "a" )
  8415. .uniqueId()
  8416. .addClass( "ui-corner-all" )
  8417. .attr({
  8418. tabIndex: -1,
  8419. role: this._itemRole()
  8420. });
  8421. // Initialize unlinked menu-items containing spaces and/or dashes only as dividers
  8422. menus.children( ":not(.ui-menu-item)" ).each(function() {
  8423. var item = $( this );
  8424. // hyphen, em dash, en dash
  8425. if ( !/[^\-—–\s]/.test( item.text() ) ) {
  8426. item.addClass( "ui-widget-content ui-menu-divider" );
  8427. }
  8428. });
  8429. // Add aria-disabled attribute to any disabled menu item
  8430. menus.children( ".ui-state-disabled" ).attr( "aria-disabled", "true" );
  8431. // If the active item has been removed, blur the menu
  8432. if ( this.active && !$.contains( this.element[ 0 ], this.active[ 0 ] ) ) {
  8433. this.blur();
  8434. }
  8435. },
  8436. _itemRole: function() {
  8437. return {
  8438. menu: "menuitem",
  8439. listbox: "option"
  8440. }[ this.options.role ];
  8441. },
  8442. focus: function( event, item ) {
  8443. var nested, focused;
  8444. this.blur( event, event && event.type === "focus" );
  8445. this._scrollIntoView( item );
  8446. this.active = item.first();
  8447. focused = this.active.children( "a" ).addClass( "ui-state-focus" );
  8448. // Only update aria-activedescendant if there's a role
  8449. // otherwise we assume focus is managed elsewhere
  8450. if ( this.options.role ) {
  8451. this.element.attr( "aria-activedescendant", focused.attr( "id" ) );
  8452. }
  8453. // Highlight active parent menu item, if any
  8454. this.active
  8455. .parent()
  8456. .closest( ".ui-menu-item" )
  8457. .children( "a:first" )
  8458. .addClass( "ui-state-active" );
  8459. if ( event && event.type === "keydown" ) {
  8460. this._close();
  8461. } else {
  8462. this.timer = this._delay(function() {
  8463. this._close();
  8464. }, this.delay );
  8465. }
  8466. nested = item.children( ".ui-menu" );
  8467. if ( nested.length && ( /^mouse/.test( event.type ) ) ) {
  8468. this._startOpening(nested);
  8469. }
  8470. this.activeMenu = item.parent();
  8471. this._trigger( "focus", event, { item: item } );
  8472. },
  8473. _scrollIntoView: function( item ) {
  8474. var borderTop, paddingTop, offset, scroll, elementHeight, itemHeight;
  8475. if ( this._hasScroll() ) {
  8476. borderTop = parseFloat( $.css( this.activeMenu[0], "borderTopWidth" ) ) || 0;
  8477. paddingTop = parseFloat( $.css( this.activeMenu[0], "paddingTop" ) ) || 0;
  8478. offset = item.offset().top - this.activeMenu.offset().top - borderTop - paddingTop;
  8479. scroll = this.activeMenu.scrollTop();
  8480. elementHeight = this.activeMenu.height();
  8481. itemHeight = item.height();
  8482. if ( offset < 0 ) {
  8483. this.activeMenu.scrollTop( scroll + offset );
  8484. } else if ( offset + itemHeight > elementHeight ) {
  8485. this.activeMenu.scrollTop( scroll + offset - elementHeight + itemHeight );
  8486. }
  8487. }
  8488. },
  8489. blur: function( event, fromFocus ) {
  8490. if ( !fromFocus ) {
  8491. clearTimeout( this.timer );
  8492. }
  8493. if ( !this.active ) {
  8494. return;
  8495. }
  8496. this.active.children( "a" ).removeClass( "ui-state-focus" );
  8497. this.active = null;
  8498. this._trigger( "blur", event, { item: this.active } );
  8499. },
  8500. _startOpening: function( submenu ) {
  8501. clearTimeout( this.timer );
  8502. // Don't open if already open fixes a Firefox bug that caused a .5 pixel
  8503. // shift in the submenu position when mousing over the carat icon
  8504. if ( submenu.attr( "aria-hidden" ) !== "true" ) {
  8505. return;
  8506. }
  8507. this.timer = this._delay(function() {
  8508. this._close();
  8509. this._open( submenu );
  8510. }, this.delay );
  8511. },
  8512. _open: function( submenu ) {
  8513. var position = $.extend({
  8514. of: this.active
  8515. }, this.options.position );
  8516. clearTimeout( this.timer );
  8517. this.element.find( ".ui-menu" ).not( submenu.parents( ".ui-menu" ) )
  8518. .hide()
  8519. .attr( "aria-hidden", "true" );
  8520. submenu
  8521. .show()
  8522. .removeAttr( "aria-hidden" )
  8523. .attr( "aria-expanded", "true" )
  8524. .position( position );
  8525. },
  8526. collapseAll: function( event, all ) {
  8527. clearTimeout( this.timer );
  8528. this.timer = this._delay(function() {
  8529. // If we were passed an event, look for the submenu that contains the event
  8530. var currentMenu = all ? this.element :
  8531. $( event && event.target ).closest( this.element.find( ".ui-menu" ) );
  8532. // If we found no valid submenu ancestor, use the main menu to close all sub menus anyway
  8533. if ( !currentMenu.length ) {
  8534. currentMenu = this.element;
  8535. }
  8536. this._close( currentMenu );
  8537. this.blur( event );
  8538. this.activeMenu = currentMenu;
  8539. }, this.delay );
  8540. },
  8541. // With no arguments, closes the currently active menu - if nothing is active
  8542. // it closes all menus. If passed an argument, it will search for menus BELOW
  8543. _close: function( startMenu ) {
  8544. if ( !startMenu ) {
  8545. startMenu = this.active ? this.active.parent() : this.element;
  8546. }
  8547. startMenu
  8548. .find( ".ui-menu" )
  8549. .hide()
  8550. .attr( "aria-hidden", "true" )
  8551. .attr( "aria-expanded", "false" )
  8552. .end()
  8553. .find( "a.ui-state-active" )
  8554. .removeClass( "ui-state-active" );
  8555. },
  8556. collapse: function( event ) {
  8557. var newItem = this.active &&
  8558. this.active.parent().closest( ".ui-menu-item", this.element );
  8559. if ( newItem && newItem.length ) {
  8560. this._close();
  8561. this.focus( event, newItem );
  8562. }
  8563. },
  8564. expand: function( event ) {
  8565. var newItem = this.active &&
  8566. this.active
  8567. .children( ".ui-menu " )
  8568. .children( ".ui-menu-item" )
  8569. .first();
  8570. if ( newItem && newItem.length ) {
  8571. this._open( newItem.parent() );
  8572. // Delay so Firefox will not hide activedescendant change in expanding submenu from AT
  8573. this._delay(function() {
  8574. this.focus( event, newItem );
  8575. });
  8576. }
  8577. },
  8578. next: function( event ) {
  8579. this._move( "next", "first", event );
  8580. },
  8581. previous: function( event ) {
  8582. this._move( "prev", "last", event );
  8583. },
  8584. isFirstItem: function() {
  8585. return this.active && !this.active.prevAll( ".ui-menu-item" ).length;
  8586. },
  8587. isLastItem: function() {
  8588. return this.active && !this.active.nextAll( ".ui-menu-item" ).length;
  8589. },
  8590. _move: function( direction, filter, event ) {
  8591. var next;
  8592. if ( this.active ) {
  8593. if ( direction === "first" || direction === "last" ) {
  8594. next = this.active
  8595. [ direction === "first" ? "prevAll" : "nextAll" ]( ".ui-menu-item" )
  8596. .eq( -1 );
  8597. } else {
  8598. next = this.active
  8599. [ direction + "All" ]( ".ui-menu-item" )
  8600. .eq( 0 );
  8601. }
  8602. }
  8603. if ( !next || !next.length || !this.active ) {
  8604. next = this.activeMenu.children( ".ui-menu-item" )[ filter ]();
  8605. }
  8606. this.focus( event, next );
  8607. },
  8608. nextPage: function( event ) {
  8609. var item, base, height;
  8610. if ( !this.active ) {
  8611. this.next( event );
  8612. return;
  8613. }
  8614. if ( this.isLastItem() ) {
  8615. return;
  8616. }
  8617. if ( this._hasScroll() ) {
  8618. base = this.active.offset().top;
  8619. height = this.element.height();
  8620. this.active.nextAll( ".ui-menu-item" ).each(function() {
  8621. item = $( this );
  8622. return item.offset().top - base - height < 0;
  8623. });
  8624. this.focus( event, item );
  8625. } else {
  8626. this.focus( event, this.activeMenu.children( ".ui-menu-item" )
  8627. [ !this.active ? "first" : "last" ]() );
  8628. }
  8629. },
  8630. previousPage: function( event ) {
  8631. var item, base, height;
  8632. if ( !this.active ) {
  8633. this.next( event );
  8634. return;
  8635. }
  8636. if ( this.isFirstItem() ) {
  8637. return;
  8638. }
  8639. if ( this._hasScroll() ) {
  8640. base = this.active.offset().top;
  8641. height = this.element.height();
  8642. this.active.prevAll( ".ui-menu-item" ).each(function() {
  8643. item = $( this );
  8644. return item.offset().top - base + height > 0;
  8645. });
  8646. this.focus( event, item );
  8647. } else {
  8648. this.focus( event, this.activeMenu.children( ".ui-menu-item" ).first() );
  8649. }
  8650. },
  8651. _hasScroll: function() {
  8652. return this.element.outerHeight() < this.element.prop( "scrollHeight" );
  8653. },
  8654. select: function( event ) {
  8655. // TODO: It should never be possible to not have an active item at this
  8656. // point, but the tests don't trigger mouseenter before click.
  8657. this.active = this.active || $( event.target ).closest( ".ui-menu-item" );
  8658. var ui = { item: this.active };
  8659. if ( !this.active.has( ".ui-menu" ).length ) {
  8660. this.collapseAll( event, true );
  8661. }
  8662. this._trigger( "select", event, ui );
  8663. }
  8664. });
  8665. }( jQuery ));
  8666. (function( $, undefined ) {
  8667. $.widget( "ui.progressbar", {
  8668. version: "1.9.2",
  8669. options: {
  8670. value: 0,
  8671. max: 100
  8672. },
  8673. min: 0,
  8674. _create: function() {
  8675. this.element
  8676. .addClass( "ui-progressbar ui-widget ui-widget-content ui-corner-all" )
  8677. .attr({
  8678. role: "progressbar",
  8679. "aria-valuemin": this.min,
  8680. "aria-valuemax": this.options.max,
  8681. "aria-valuenow": this._value()
  8682. });
  8683. this.valueDiv = $( "<div class='ui-progressbar-value ui-widget-header ui-corner-left'></div>" )
  8684. .appendTo( this.element );
  8685. this.oldValue = this._value();
  8686. this._refreshValue();
  8687. },
  8688. _destroy: function() {
  8689. this.element
  8690. .removeClass( "ui-progressbar ui-widget ui-widget-content ui-corner-all" )
  8691. .removeAttr( "role" )
  8692. .removeAttr( "aria-valuemin" )
  8693. .removeAttr( "aria-valuemax" )
  8694. .removeAttr( "aria-valuenow" );
  8695. this.valueDiv.remove();
  8696. },
  8697. value: function( newValue ) {
  8698. if ( newValue === undefined ) {
  8699. return this._value();
  8700. }
  8701. this._setOption( "value", newValue );
  8702. return this;
  8703. },
  8704. _setOption: function( key, value ) {
  8705. if ( key === "value" ) {
  8706. this.options.value = value;
  8707. this._refreshValue();
  8708. if ( this._value() === this.options.max ) {
  8709. this._trigger( "complete" );
  8710. }
  8711. }
  8712. this._super( key, value );
  8713. },
  8714. _value: function() {
  8715. var val = this.options.value;
  8716. // normalize invalid value
  8717. if ( typeof val !== "number" ) {
  8718. val = 0;
  8719. }
  8720. return Math.min( this.options.max, Math.max( this.min, val ) );
  8721. },
  8722. _percentage: function() {
  8723. return 100 * this._value() / this.options.max;
  8724. },
  8725. _refreshValue: function() {
  8726. var value = this.value(),
  8727. percentage = this._percentage();
  8728. if ( this.oldValue !== value ) {
  8729. this.oldValue = value;
  8730. this._trigger( "change" );
  8731. }
  8732. this.valueDiv
  8733. .toggle( value > this.min )
  8734. .toggleClass( "ui-corner-right", value === this.options.max )
  8735. .width( percentage.toFixed(0) + "%" );
  8736. this.element.attr( "aria-valuenow", value );
  8737. }
  8738. });
  8739. })( jQuery );
  8740. (function( $, undefined ) {
  8741. $.widget("ui.resizable", $.ui.mouse, {
  8742. version: "1.9.2",
  8743. widgetEventPrefix: "resize",
  8744. options: {
  8745. alsoResize: false,
  8746. animate: false,
  8747. animateDuration: "slow",
  8748. animateEasing: "swing",
  8749. aspectRatio: false,
  8750. autoHide: false,
  8751. containment: false,
  8752. ghost: false,
  8753. grid: false,
  8754. handles: "e,s,se",
  8755. helper: false,
  8756. maxHeight: null,
  8757. maxWidth: null,
  8758. minHeight: 10,
  8759. minWidth: 10,
  8760. zIndex: 1000
  8761. },
  8762. _create: function() {
  8763. var that = this, o = this.options;
  8764. this.element.addClass("ui-resizable");
  8765. $.extend(this, {
  8766. _aspectRatio: !!(o.aspectRatio),
  8767. aspectRatio: o.aspectRatio,
  8768. originalElement: this.element,
  8769. _proportionallyResizeElements: [],
  8770. _helper: o.helper || o.ghost || o.animate ? o.helper || 'ui-resizable-helper' : null
  8771. });
  8772. //Wrap the element if it cannot hold child nodes
  8773. if(this.element[0].nodeName.match(/canvas|textarea|input|select|button|img/i)) {
  8774. //Create a wrapper element and set the wrapper to the new current internal element
  8775. this.element.wrap(
  8776. $('<div class="ui-wrapper" style="overflow: hidden;"></div>').css({
  8777. position: this.element.css('position'),
  8778. width: this.element.outerWidth(),
  8779. height: this.element.outerHeight(),
  8780. top: this.element.css('top'),
  8781. left: this.element.css('left')
  8782. })
  8783. );
  8784. //Overwrite the original this.element
  8785. this.element = this.element.parent().data(
  8786. "resizable", this.element.data('resizable')
  8787. );
  8788. this.elementIsWrapper = true;
  8789. //Move margins to the wrapper
  8790. this.element.css({ marginLeft: this.originalElement.css("marginLeft"), marginTop: this.originalElement.css("marginTop"), marginRight: this.originalElement.css("marginRight"), marginBottom: this.originalElement.css("marginBottom") });
  8791. this.originalElement.css({ marginLeft: 0, marginTop: 0, marginRight: 0, marginBottom: 0});
  8792. //Prevent Safari textarea resize
  8793. this.originalResizeStyle = this.originalElement.css('resize');
  8794. this.originalElement.css('resize', 'none');
  8795. //Push the actual element to our proportionallyResize internal array
  8796. this._proportionallyResizeElements.push(this.originalElement.css({ position: 'static', zoom: 1, display: 'block' }));
  8797. // avoid IE jump (hard set the margin)
  8798. this.originalElement.css({ margin: this.originalElement.css('margin') });
  8799. // fix handlers offset
  8800. this._proportionallyResize();
  8801. }
  8802. 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' });
  8803. if(this.handles.constructor == String) {
  8804. if(this.handles == 'all') this.handles = 'n,e,s,w,se,sw,ne,nw';
  8805. var n = this.handles.split(","); this.handles = {};
  8806. for(var i = 0; i < n.length; i++) {
  8807. var handle = $.trim(n[i]), hname = 'ui-resizable-'+handle;
  8808. var axis = $('<div class="ui-resizable-handle ' + hname + '"></div>');
  8809. // Apply zIndex to all handles - see #7960
  8810. axis.css({ zIndex: o.zIndex });
  8811. //TODO : What's going on here?
  8812. if ('se' == handle) {
  8813. axis.addClass('ui-icon ui-icon-gripsmall-diagonal-se');
  8814. };
  8815. //Insert into internal handles object and append to element
  8816. this.handles[handle] = '.ui-resizable-'+handle;
  8817. this.element.append(axis);
  8818. }
  8819. }
  8820. this._renderAxis = function(target) {
  8821. target = target || this.element;
  8822. for(var i in this.handles) {
  8823. if(this.handles[i].constructor == String)
  8824. this.handles[i] = $(this.handles[i], this.element).show();
  8825. //Apply pad to wrapper element, needed to fix axis position (textarea, inputs, scrolls)
  8826. if (this.elementIsWrapper && this.originalElement[0].nodeName.match(/textarea|input|select|button/i)) {
  8827. var axis = $(this.handles[i], this.element), padWrapper = 0;
  8828. //Checking the correct pad and border
  8829. padWrapper = /sw|ne|nw|se|n|s/.test(i) ? axis.outerHeight() : axis.outerWidth();
  8830. //The padding type i have to apply...
  8831. var padPos = [ 'padding',
  8832. /ne|nw|n/.test(i) ? 'Top' :
  8833. /se|sw|s/.test(i) ? 'Bottom' :
  8834. /^e$/.test(i) ? 'Right' : 'Left' ].join("");
  8835. target.css(padPos, padWrapper);
  8836. this._proportionallyResize();
  8837. }
  8838. //TODO: What's that good for? There's not anything to be executed left
  8839. if(!$(this.handles[i]).length)
  8840. continue;
  8841. }
  8842. };
  8843. //TODO: make renderAxis a prototype function
  8844. this._renderAxis(this.element);
  8845. this._handles = $('.ui-resizable-handle', this.element)
  8846. .disableSelection();
  8847. //Matching axis name
  8848. this._handles.mouseover(function() {
  8849. if (!that.resizing) {
  8850. if (this.className)
  8851. var axis = this.className.match(/ui-resizable-(se|sw|ne|nw|n|e|s|w)/i);
  8852. //Axis, default = se
  8853. that.axis = axis && axis[1] ? axis[1] : 'se';
  8854. }
  8855. });
  8856. //If we want to auto hide the elements
  8857. if (o.autoHide) {
  8858. this._handles.hide();
  8859. $(this.element)
  8860. .addClass("ui-resizable-autohide")
  8861. .mouseenter(function() {
  8862. if (o.disabled) return;
  8863. $(this).removeClass("ui-resizable-autohide");
  8864. that._handles.show();
  8865. })
  8866. .mouseleave(function(){
  8867. if (o.disabled) return;
  8868. if (!that.resizing) {
  8869. $(this).addClass("ui-resizable-autohide");
  8870. that._handles.hide();
  8871. }
  8872. });
  8873. }
  8874. //Initialize the mouse interaction
  8875. this._mouseInit();
  8876. },
  8877. _destroy: function() {
  8878. this._mouseDestroy();
  8879. var _destroy = function(exp) {
  8880. $(exp).removeClass("ui-resizable ui-resizable-disabled ui-resizable-resizing")
  8881. .removeData("resizable").removeData("ui-resizable").unbind(".resizable").find('.ui-resizable-handle').remove();
  8882. };
  8883. //TODO: Unwrap at same DOM position
  8884. if (this.elementIsWrapper) {
  8885. _destroy(this.element);
  8886. var wrapper = this.element;
  8887. this.originalElement.css({
  8888. position: wrapper.css('position'),
  8889. width: wrapper.outerWidth(),
  8890. height: wrapper.outerHeight(),
  8891. top: wrapper.css('top'),
  8892. left: wrapper.css('left')
  8893. }).insertAfter( wrapper );
  8894. wrapper.remove();
  8895. }
  8896. this.originalElement.css('resize', this.originalResizeStyle);
  8897. _destroy(this.originalElement);
  8898. return this;
  8899. },
  8900. _mouseCapture: function(event) {
  8901. var handle = false;
  8902. for (var i in this.handles) {
  8903. if ($(this.handles[i])[0] == event.target) {
  8904. handle = true;
  8905. }
  8906. }
  8907. return !this.options.disabled && handle;
  8908. },
  8909. _mouseStart: function(event) {
  8910. var o = this.options, iniPos = this.element.position(), el = this.element;
  8911. this.resizing = true;
  8912. this.documentScroll = { top: $(document).scrollTop(), left: $(document).scrollLeft() };
  8913. // bugfix for http://dev.jquery.com/ticket/1749
  8914. if (el.is('.ui-draggable') || (/absolute/).test(el.css('position'))) {
  8915. el.css({ position: 'absolute', top: iniPos.top, left: iniPos.left });
  8916. }
  8917. this._renderProxy();
  8918. var curleft = num(this.helper.css('left')), curtop = num(this.helper.css('top'));
  8919. if (o.containment) {
  8920. curleft += $(o.containment).scrollLeft() || 0;
  8921. curtop += $(o.containment).scrollTop() || 0;
  8922. }
  8923. //Store needed variables
  8924. this.offset = this.helper.offset();
  8925. this.position = { left: curleft, top: curtop };
  8926. this.size = this._helper ? { width: el.outerWidth(), height: el.outerHeight() } : { width: el.width(), height: el.height() };
  8927. this.originalSize = this._helper ? { width: el.outerWidth(), height: el.outerHeight() } : { width: el.width(), height: el.height() };
  8928. this.originalPosition = { left: curleft, top: curtop };
  8929. this.sizeDiff = { width: el.outerWidth() - el.width(), height: el.outerHeight() - el.height() };
  8930. this.originalMousePosition = { left: event.pageX, top: event.pageY };
  8931. //Aspect Ratio
  8932. this.aspectRatio = (typeof o.aspectRatio == 'number') ? o.aspectRatio : ((this.originalSize.width / this.originalSize.height) || 1);
  8933. var cursor = $('.ui-resizable-' + this.axis).css('cursor');
  8934. $('body').css('cursor', cursor == 'auto' ? this.axis + '-resize' : cursor);
  8935. el.addClass("ui-resizable-resizing");
  8936. this._propagate("start", event);
  8937. return true;
  8938. },
  8939. _mouseDrag: function(event) {
  8940. //Increase performance, avoid regex
  8941. var el = this.helper, o = this.options, props = {},
  8942. that = this, smp = this.originalMousePosition, a = this.axis;
  8943. var dx = (event.pageX-smp.left)||0, dy = (event.pageY-smp.top)||0;
  8944. var trigger = this._change[a];
  8945. if (!trigger) return false;
  8946. // Calculate the attrs that will be change
  8947. var data = trigger.apply(this, [event, dx, dy]);
  8948. // Put this in the mouseDrag handler since the user can start pressing shift while resizing
  8949. this._updateVirtualBoundaries(event.shiftKey);
  8950. if (this._aspectRatio || event.shiftKey)
  8951. data = this._updateRatio(data, event);
  8952. data = this._respectSize(data, event);
  8953. // plugins callbacks need to be called first
  8954. this._propagate("resize", event);
  8955. el.css({
  8956. top: this.position.top + "px", left: this.position.left + "px",
  8957. width: this.size.width + "px", height: this.size.height + "px"
  8958. });
  8959. if (!this._helper && this._proportionallyResizeElements.length)
  8960. this._proportionallyResize();
  8961. this._updateCache(data);
  8962. // calling the user callback at the end
  8963. this._trigger('resize', event, this.ui());
  8964. return false;
  8965. },
  8966. _mouseStop: function(event) {
  8967. this.resizing = false;
  8968. var o = this.options, that = this;
  8969. if(this._helper) {
  8970. var pr = this._proportionallyResizeElements, ista = pr.length && (/textarea/i).test(pr[0].nodeName),
  8971. soffseth = ista && $.ui.hasScroll(pr[0], 'left') /* TODO - jump height */ ? 0 : that.sizeDiff.height,
  8972. soffsetw = ista ? 0 : that.sizeDiff.width;
  8973. var s = { width: (that.helper.width() - soffsetw), height: (that.helper.height() - soffseth) },
  8974. left = (parseInt(that.element.css('left'), 10) + (that.position.left - that.originalPosition.left)) || null,
  8975. top = (parseInt(that.element.css('top'), 10) + (that.position.top - that.originalPosition.top)) || null;
  8976. if (!o.animate)
  8977. this.element.css($.extend(s, { top: top, left: left }));
  8978. that.helper.height(that.size.height);
  8979. that.helper.width(that.size.width);
  8980. if (this._helper && !o.animate) this._proportionallyResize();
  8981. }
  8982. $('body').css('cursor', 'auto');
  8983. this.element.removeClass("ui-resizable-resizing");
  8984. this._propagate("stop", event);
  8985. if (this._helper) this.helper.remove();
  8986. return false;
  8987. },
  8988. _updateVirtualBoundaries: function(forceAspectRatio) {
  8989. var o = this.options, pMinWidth, pMaxWidth, pMinHeight, pMaxHeight, b;
  8990. b = {
  8991. minWidth: isNumber(o.minWidth) ? o.minWidth : 0,
  8992. maxWidth: isNumber(o.maxWidth) ? o.maxWidth : Infinity,
  8993. minHeight: isNumber(o.minHeight) ? o.minHeight : 0,
  8994. maxHeight: isNumber(o.maxHeight) ? o.maxHeight : Infinity
  8995. };
  8996. if(this._aspectRatio || forceAspectRatio) {
  8997. // We want to create an enclosing box whose aspect ration is the requested one
  8998. // First, compute the "projected" size for each dimension based on the aspect ratio and other dimension
  8999. pMinWidth = b.minHeight * this.aspectRatio;
  9000. pMinHeight = b.minWidth / this.aspectRatio;
  9001. pMaxWidth = b.maxHeight * this.aspectRatio;
  9002. pMaxHeight = b.maxWidth / this.aspectRatio;
  9003. if(pMinWidth > b.minWidth) b.minWidth = pMinWidth;
  9004. if(pMinHeight > b.minHeight) b.minHeight = pMinHeight;
  9005. if(pMaxWidth < b.maxWidth) b.maxWidth = pMaxWidth;
  9006. if(pMaxHeight < b.maxHeight) b.maxHeight = pMaxHeight;
  9007. }
  9008. this._vBoundaries = b;
  9009. },
  9010. _updateCache: function(data) {
  9011. var o = this.options;
  9012. this.offset = this.helper.offset();
  9013. if (isNumber(data.left)) this.position.left = data.left;
  9014. if (isNumber(data.top)) this.position.top = data.top;
  9015. if (isNumber(data.height)) this.size.height = data.height;
  9016. if (isNumber(data.width)) this.size.width = data.width;
  9017. },
  9018. _updateRatio: function(data, event) {
  9019. var o = this.options, cpos = this.position, csize = this.size, a = this.axis;
  9020. if (isNumber(data.height)) data.width = (data.height * this.aspectRatio);
  9021. else if (isNumber(data.width)) data.height = (data.width / this.aspectRatio);
  9022. if (a == 'sw') {
  9023. data.left = cpos.left + (csize.width - data.width);
  9024. data.top = null;
  9025. }
  9026. if (a == 'nw') {
  9027. data.top = cpos.top + (csize.height - data.height);
  9028. data.left = cpos.left + (csize.width - data.width);
  9029. }
  9030. return data;
  9031. },
  9032. _respectSize: function(data, event) {
  9033. var el = this.helper, o = this._vBoundaries, pRatio = this._aspectRatio || event.shiftKey, a = this.axis,
  9034. ismaxw = isNumber(data.width) && o.maxWidth && (o.maxWidth < data.width), ismaxh = isNumber(data.height) && o.maxHeight && (o.maxHeight < data.height),
  9035. isminw = isNumber(data.width) && o.minWidth && (o.minWidth > data.width), isminh = isNumber(data.height) && o.minHeight && (o.minHeight > data.height);
  9036. if (isminw) data.width = o.minWidth;
  9037. if (isminh) data.height = o.minHeight;
  9038. if (ismaxw) data.width = o.maxWidth;
  9039. if (ismaxh) data.height = o.maxHeight;
  9040. var dw = this.originalPosition.left + this.originalSize.width, dh = this.position.top + this.size.height;
  9041. var cw = /sw|nw|w/.test(a), ch = /nw|ne|n/.test(a);
  9042. if (isminw && cw) data.left = dw - o.minWidth;
  9043. if (ismaxw && cw) data.left = dw - o.maxWidth;
  9044. if (isminh && ch) data.top = dh - o.minHeight;
  9045. if (ismaxh && ch) data.top = dh - o.maxHeight;
  9046. // fixing jump error on top/left - bug #2330
  9047. var isNotwh = !data.width && !data.height;
  9048. if (isNotwh && !data.left && data.top) data.top = null;
  9049. else if (isNotwh && !data.top && data.left) data.left = null;
  9050. return data;
  9051. },
  9052. _proportionallyResize: function() {
  9053. var o = this.options;
  9054. if (!this._proportionallyResizeElements.length) return;
  9055. var element = this.helper || this.element;
  9056. for (var i=0; i < this._proportionallyResizeElements.length; i++) {
  9057. var prel = this._proportionallyResizeElements[i];
  9058. if (!this.borderDif) {
  9059. var b = [prel.css('borderTopWidth'), prel.css('borderRightWidth'), prel.css('borderBottomWidth'), prel.css('borderLeftWidth')],
  9060. p = [prel.css('paddingTop'), prel.css('paddingRight'), prel.css('paddingBottom'), prel.css('paddingLeft')];
  9061. this.borderDif = $.map(b, function(v, i) {
  9062. var border = parseInt(v,10)||0, padding = parseInt(p[i],10)||0;
  9063. return border + padding;
  9064. });
  9065. }
  9066. prel.css({
  9067. height: (element.height() - this.borderDif[0] - this.borderDif[2]) || 0,
  9068. width: (element.width() - this.borderDif[1] - this.borderDif[3]) || 0
  9069. });
  9070. };
  9071. },
  9072. _renderProxy: function() {
  9073. var el = this.element, o = this.options;
  9074. this.elementOffset = el.offset();
  9075. if(this._helper) {
  9076. this.helper = this.helper || $('<div style="overflow:hidden;"></div>');
  9077. // fix ie6 offset TODO: This seems broken
  9078. var ie6offset = ($.ui.ie6 ? 1 : 0),
  9079. pxyoffset = ( $.ui.ie6 ? 2 : -1 );
  9080. this.helper.addClass(this._helper).css({
  9081. width: this.element.outerWidth() + pxyoffset,
  9082. height: this.element.outerHeight() + pxyoffset,
  9083. position: 'absolute',
  9084. left: this.elementOffset.left - ie6offset +'px',
  9085. top: this.elementOffset.top - ie6offset +'px',
  9086. zIndex: ++o.zIndex //TODO: Don't modify option
  9087. });
  9088. this.helper
  9089. .appendTo("body")
  9090. .disableSelection();
  9091. } else {
  9092. this.helper = this.element;
  9093. }
  9094. },
  9095. _change: {
  9096. e: function(event, dx, dy) {
  9097. return { width: this.originalSize.width + dx };
  9098. },
  9099. w: function(event, dx, dy) {
  9100. var o = this.options, cs = this.originalSize, sp = this.originalPosition;
  9101. return { left: sp.left + dx, width: cs.width - dx };
  9102. },
  9103. n: function(event, dx, dy) {
  9104. var o = this.options, cs = this.originalSize, sp = this.originalPosition;
  9105. return { top: sp.top + dy, height: cs.height - dy };
  9106. },
  9107. s: function(event, dx, dy) {
  9108. return { height: this.originalSize.height + dy };
  9109. },
  9110. se: function(event, dx, dy) {
  9111. return $.extend(this._change.s.apply(this, arguments), this._change.e.apply(this, [event, dx, dy]));
  9112. },
  9113. sw: function(event, dx, dy) {
  9114. return $.extend(this._change.s.apply(this, arguments), this._change.w.apply(this, [event, dx, dy]));
  9115. },
  9116. ne: function(event, dx, dy) {
  9117. return $.extend(this._change.n.apply(this, arguments), this._change.e.apply(this, [event, dx, dy]));
  9118. },
  9119. nw: function(event, dx, dy) {
  9120. return $.extend(this._change.n.apply(this, arguments), this._change.w.apply(this, [event, dx, dy]));
  9121. }
  9122. },
  9123. _propagate: function(n, event) {
  9124. $.ui.plugin.call(this, n, [event, this.ui()]);
  9125. (n != "resize" && this._trigger(n, event, this.ui()));
  9126. },
  9127. plugins: {},
  9128. ui: function() {
  9129. return {
  9130. originalElement: this.originalElement,
  9131. element: this.element,
  9132. helper: this.helper,
  9133. position: this.position,
  9134. size: this.size,
  9135. originalSize: this.originalSize,
  9136. originalPosition: this.originalPosition
  9137. };
  9138. }
  9139. });
  9140. /*
  9141. * Resizable Extensions
  9142. */
  9143. $.ui.plugin.add("resizable", "alsoResize", {
  9144. start: function (event, ui) {
  9145. var that = $(this).data("resizable"), o = that.options;
  9146. var _store = function (exp) {
  9147. $(exp).each(function() {
  9148. var el = $(this);
  9149. el.data("resizable-alsoresize", {
  9150. width: parseInt(el.width(), 10), height: parseInt(el.height(), 10),
  9151. left: parseInt(el.css('left'), 10), top: parseInt(el.css('top'), 10)
  9152. });
  9153. });
  9154. };
  9155. if (typeof(o.alsoResize) == 'object' && !o.alsoResize.parentNode) {
  9156. if (o.alsoResize.length) { o.alsoResize = o.alsoResize[0]; _store(o.alsoResize); }
  9157. else { $.each(o.alsoResize, function (exp) { _store(exp); }); }
  9158. }else{
  9159. _store(o.alsoResize);
  9160. }
  9161. },
  9162. resize: function (event, ui) {
  9163. var that = $(this).data("resizable"), o = that.options, os = that.originalSize, op = that.originalPosition;
  9164. var delta = {
  9165. height: (that.size.height - os.height) || 0, width: (that.size.width - os.width) || 0,
  9166. top: (that.position.top - op.top) || 0, left: (that.position.left - op.left) || 0
  9167. },
  9168. _alsoResize = function (exp, c) {
  9169. $(exp).each(function() {
  9170. var el = $(this), start = $(this).data("resizable-alsoresize"), style = {},
  9171. css = c && c.length ? c : el.parents(ui.originalElement[0]).length ? ['width', 'height'] : ['width', 'height', 'top', 'left'];
  9172. $.each(css, function (i, prop) {
  9173. var sum = (start[prop]||0) + (delta[prop]||0);
  9174. if (sum && sum >= 0)
  9175. style[prop] = sum || null;
  9176. });
  9177. el.css(style);
  9178. });
  9179. };
  9180. if (typeof(o.alsoResize) == 'object' && !o.alsoResize.nodeType) {
  9181. $.each(o.alsoResize, function (exp, c) { _alsoResize(exp, c); });
  9182. }else{
  9183. _alsoResize(o.alsoResize);
  9184. }
  9185. },
  9186. stop: function (event, ui) {
  9187. $(this).removeData("resizable-alsoresize");
  9188. }
  9189. });
  9190. $.ui.plugin.add("resizable", "animate", {
  9191. stop: function(event, ui) {
  9192. var that = $(this).data("resizable"), o = that.options;
  9193. var pr = that._proportionallyResizeElements, ista = pr.length && (/textarea/i).test(pr[0].nodeName),
  9194. soffseth = ista && $.ui.hasScroll(pr[0], 'left') /* TODO - jump height */ ? 0 : that.sizeDiff.height,
  9195. soffsetw = ista ? 0 : that.sizeDiff.width;
  9196. var style = { width: (that.size.width - soffsetw), height: (that.size.height - soffseth) },
  9197. left = (parseInt(that.element.css('left'), 10) + (that.position.left - that.originalPosition.left)) || null,
  9198. top = (parseInt(that.element.css('top'), 10) + (that.position.top - that.originalPosition.top)) || null;
  9199. that.element.animate(
  9200. $.extend(style, top && left ? { top: top, left: left } : {}), {
  9201. duration: o.animateDuration,
  9202. easing: o.animateEasing,
  9203. step: function() {
  9204. var data = {
  9205. width: parseInt(that.element.css('width'), 10),
  9206. height: parseInt(that.element.css('height'), 10),
  9207. top: parseInt(that.element.css('top'), 10),
  9208. left: parseInt(that.element.css('left'), 10)
  9209. };
  9210. if (pr && pr.length) $(pr[0]).css({ width: data.width, height: data.height });
  9211. // propagating resize, and updating values for each animation step
  9212. that._updateCache(data);
  9213. that._propagate("resize", event);
  9214. }
  9215. }
  9216. );
  9217. }
  9218. });
  9219. $.ui.plugin.add("resizable", "containment", {
  9220. start: function(event, ui) {
  9221. var that = $(this).data("resizable"), o = that.options, el = that.element;
  9222. var oc = o.containment, ce = (oc instanceof $) ? oc.get(0) : (/parent/.test(oc)) ? el.parent().get(0) : oc;
  9223. if (!ce) return;
  9224. that.containerElement = $(ce);
  9225. if (/document/.test(oc) || oc == document) {
  9226. that.containerOffset = { left: 0, top: 0 };
  9227. that.containerPosition = { left: 0, top: 0 };
  9228. that.parentData = {
  9229. element: $(document), left: 0, top: 0,
  9230. width: $(document).width(), height: $(document).height() || document.body.parentNode.scrollHeight
  9231. };
  9232. }
  9233. // i'm a node, so compute top, left, right, bottom
  9234. else {
  9235. var element = $(ce), p = [];
  9236. $([ "Top", "Right", "Left", "Bottom" ]).each(function(i, name) { p[i] = num(element.css("padding" + name)); });
  9237. that.containerOffset = element.offset();
  9238. that.containerPosition = element.position();
  9239. that.containerSize = { height: (element.innerHeight() - p[3]), width: (element.innerWidth() - p[1]) };
  9240. var co = that.containerOffset, ch = that.containerSize.height, cw = that.containerSize.width,
  9241. width = ($.ui.hasScroll(ce, "left") ? ce.scrollWidth : cw ), height = ($.ui.hasScroll(ce) ? ce.scrollHeight : ch);
  9242. that.parentData = {
  9243. element: ce, left: co.left, top: co.top, width: width, height: height
  9244. };
  9245. }
  9246. },
  9247. resize: function(event, ui) {
  9248. var that = $(this).data("resizable"), o = that.options,
  9249. ps = that.containerSize, co = that.containerOffset, cs = that.size, cp = that.position,
  9250. pRatio = that._aspectRatio || event.shiftKey, cop = { top:0, left:0 }, ce = that.containerElement;
  9251. if (ce[0] != document && (/static/).test(ce.css('position'))) cop = co;
  9252. if (cp.left < (that._helper ? co.left : 0)) {
  9253. that.size.width = that.size.width + (that._helper ? (that.position.left - co.left) : (that.position.left - cop.left));
  9254. if (pRatio) that.size.height = that.size.width / that.aspectRatio;
  9255. that.position.left = o.helper ? co.left : 0;
  9256. }
  9257. if (cp.top < (that._helper ? co.top : 0)) {
  9258. that.size.height = that.size.height + (that._helper ? (that.position.top - co.top) : that.position.top);
  9259. if (pRatio) that.size.width = that.size.height * that.aspectRatio;
  9260. that.position.top = that._helper ? co.top : 0;
  9261. }
  9262. that.offset.left = that.parentData.left+that.position.left;
  9263. that.offset.top = that.parentData.top+that.position.top;
  9264. var woset = Math.abs( (that._helper ? that.offset.left - cop.left : (that.offset.left - cop.left)) + that.sizeDiff.width ),
  9265. hoset = Math.abs( (that._helper ? that.offset.top - cop.top : (that.offset.top - co.top)) + that.sizeDiff.height );
  9266. var isParent = that.containerElement.get(0) == that.element.parent().get(0),
  9267. isOffsetRelative = /relative|absolute/.test(that.containerElement.css('position'));
  9268. if(isParent && isOffsetRelative) woset -= that.parentData.left;
  9269. if (woset + that.size.width >= that.parentData.width) {
  9270. that.size.width = that.parentData.width - woset;
  9271. if (pRatio) that.size.height = that.size.width / that.aspectRatio;
  9272. }
  9273. if (hoset + that.size.height >= that.parentData.height) {
  9274. that.size.height = that.parentData.height - hoset;
  9275. if (pRatio) that.size.width = that.size.height * that.aspectRatio;
  9276. }
  9277. },
  9278. stop: function(event, ui){
  9279. var that = $(this).data("resizable"), o = that.options, cp = that.position,
  9280. co = that.containerOffset, cop = that.containerPosition, ce = that.containerElement;
  9281. var helper = $(that.helper), ho = helper.offset(), w = helper.outerWidth() - that.sizeDiff.width, h = helper.outerHeight() - that.sizeDiff.height;
  9282. if (that._helper && !o.animate && (/relative/).test(ce.css('position')))
  9283. $(this).css({ left: ho.left - cop.left - co.left, width: w, height: h });
  9284. if (that._helper && !o.animate && (/static/).test(ce.css('position')))
  9285. $(this).css({ left: ho.left - cop.left - co.left, width: w, height: h });
  9286. }
  9287. });
  9288. $.ui.plugin.add("resizable", "ghost", {
  9289. start: function(event, ui) {
  9290. var that = $(this).data("resizable"), o = that.options, cs = that.size;
  9291. that.ghost = that.originalElement.clone();
  9292. that.ghost
  9293. .css({ opacity: .25, display: 'block', position: 'relative', height: cs.height, width: cs.width, margin: 0, left: 0, top: 0 })
  9294. .addClass('ui-resizable-ghost')
  9295. .addClass(typeof o.ghost == 'string' ? o.ghost : '');
  9296. that.ghost.appendTo(that.helper);
  9297. },
  9298. resize: function(event, ui){
  9299. var that = $(this).data("resizable"), o = that.options;
  9300. if (that.ghost) that.ghost.css({ position: 'relative', height: that.size.height, width: that.size.width });
  9301. },
  9302. stop: function(event, ui){
  9303. var that = $(this).data("resizable"), o = that.options;
  9304. if (that.ghost && that.helper) that.helper.get(0).removeChild(that.ghost.get(0));
  9305. }
  9306. });
  9307. $.ui.plugin.add("resizable", "grid", {
  9308. resize: function(event, ui) {
  9309. var that = $(this).data("resizable"), o = that.options, cs = that.size, os = that.originalSize, op = that.originalPosition, a = that.axis, ratio = o._aspectRatio || event.shiftKey;
  9310. o.grid = typeof o.grid == "number" ? [o.grid, o.grid] : o.grid;
  9311. var ox = Math.round((cs.width - os.width) / (o.grid[0]||1)) * (o.grid[0]||1), oy = Math.round((cs.height - os.height) / (o.grid[1]||1)) * (o.grid[1]||1);
  9312. if (/^(se|s|e)$/.test(a)) {
  9313. that.size.width = os.width + ox;
  9314. that.size.height = os.height + oy;
  9315. }
  9316. else if (/^(ne)$/.test(a)) {
  9317. that.size.width = os.width + ox;
  9318. that.size.height = os.height + oy;
  9319. that.position.top = op.top - oy;
  9320. }
  9321. else if (/^(sw)$/.test(a)) {
  9322. that.size.width = os.width + ox;
  9323. that.size.height = os.height + oy;
  9324. that.position.left = op.left - ox;
  9325. }
  9326. else {
  9327. that.size.width = os.width + ox;
  9328. that.size.height = os.height + oy;
  9329. that.position.top = op.top - oy;
  9330. that.position.left = op.left - ox;
  9331. }
  9332. }
  9333. });
  9334. var num = function(v) {
  9335. return parseInt(v, 10) || 0;
  9336. };
  9337. var isNumber = function(value) {
  9338. return !isNaN(parseInt(value, 10));
  9339. };
  9340. })(jQuery);
  9341. (function( $, undefined ) {
  9342. $.widget("ui.selectable", $.ui.mouse, {
  9343. version: "1.9.2",
  9344. options: {
  9345. appendTo: 'body',
  9346. autoRefresh: true,
  9347. distance: 0,
  9348. filter: '*',
  9349. tolerance: 'touch'
  9350. },
  9351. _create: function() {
  9352. var that = this;
  9353. this.element.addClass("ui-selectable");
  9354. this.dragged = false;
  9355. // cache selectee children based on filter
  9356. var selectees;
  9357. this.refresh = function() {
  9358. selectees = $(that.options.filter, that.element[0]);
  9359. selectees.addClass("ui-selectee");
  9360. selectees.each(function() {
  9361. var $this = $(this);
  9362. var pos = $this.offset();
  9363. $.data(this, "selectable-item", {
  9364. element: this,
  9365. $element: $this,
  9366. left: pos.left,
  9367. top: pos.top,
  9368. right: pos.left + $this.outerWidth(),
  9369. bottom: pos.top + $this.outerHeight(),
  9370. startselected: false,
  9371. selected: $this.hasClass('ui-selected'),
  9372. selecting: $this.hasClass('ui-selecting'),
  9373. unselecting: $this.hasClass('ui-unselecting')
  9374. });
  9375. });
  9376. };
  9377. this.refresh();
  9378. this.selectees = selectees.addClass("ui-selectee");
  9379. this._mouseInit();
  9380. this.helper = $("<div class='ui-selectable-helper'></div>");
  9381. },
  9382. _destroy: function() {
  9383. this.selectees
  9384. .removeClass("ui-selectee")
  9385. .removeData("selectable-item");
  9386. this.element
  9387. .removeClass("ui-selectable ui-selectable-disabled");
  9388. this._mouseDestroy();
  9389. },
  9390. _mouseStart: function(event) {
  9391. var that = this;
  9392. this.opos = [event.pageX, event.pageY];
  9393. if (this.options.disabled)
  9394. return;
  9395. var options = this.options;
  9396. this.selectees = $(options.filter, this.element[0]);
  9397. this._trigger("start", event);
  9398. $(options.appendTo).append(this.helper);
  9399. // position helper (lasso)
  9400. this.helper.css({
  9401. "left": event.clientX,
  9402. "top": event.clientY,
  9403. "width": 0,
  9404. "height": 0
  9405. });
  9406. if (options.autoRefresh) {
  9407. this.refresh();
  9408. }
  9409. this.selectees.filter('.ui-selected').each(function() {
  9410. var selectee = $.data(this, "selectable-item");
  9411. selectee.startselected = true;
  9412. if (!event.metaKey && !event.ctrlKey) {
  9413. selectee.$element.removeClass('ui-selected');
  9414. selectee.selected = false;
  9415. selectee.$element.addClass('ui-unselecting');
  9416. selectee.unselecting = true;
  9417. // selectable UNSELECTING callback
  9418. that._trigger("unselecting", event, {
  9419. unselecting: selectee.element
  9420. });
  9421. }
  9422. });
  9423. $(event.target).parents().andSelf().each(function() {
  9424. var selectee = $.data(this, "selectable-item");
  9425. if (selectee) {
  9426. var doSelect = (!event.metaKey && !event.ctrlKey) || !selectee.$element.hasClass('ui-selected');
  9427. selectee.$element
  9428. .removeClass(doSelect ? "ui-unselecting" : "ui-selected")
  9429. .addClass(doSelect ? "ui-selecting" : "ui-unselecting");
  9430. selectee.unselecting = !doSelect;
  9431. selectee.selecting = doSelect;
  9432. selectee.selected = doSelect;
  9433. // selectable (UN)SELECTING callback
  9434. if (doSelect) {
  9435. that._trigger("selecting", event, {
  9436. selecting: selectee.element
  9437. });
  9438. } else {
  9439. that._trigger("unselecting", event, {
  9440. unselecting: selectee.element
  9441. });
  9442. }
  9443. return false;
  9444. }
  9445. });
  9446. },
  9447. _mouseDrag: function(event) {
  9448. var that = this;
  9449. this.dragged = true;
  9450. if (this.options.disabled)
  9451. return;
  9452. var options = this.options;
  9453. var x1 = this.opos[0], y1 = this.opos[1], x2 = event.pageX, y2 = event.pageY;
  9454. if (x1 > x2) { var tmp = x2; x2 = x1; x1 = tmp; }
  9455. if (y1 > y2) { var tmp = y2; y2 = y1; y1 = tmp; }
  9456. this.helper.css({left: x1, top: y1, width: x2-x1, height: y2-y1});
  9457. this.selectees.each(function() {
  9458. var selectee = $.data(this, "selectable-item");
  9459. //prevent helper from being selected if appendTo: selectable
  9460. if (!selectee || selectee.element == that.element[0])
  9461. return;
  9462. var hit = false;
  9463. if (options.tolerance == 'touch') {
  9464. hit = ( !(selectee.left > x2 || selectee.right < x1 || selectee.top > y2 || selectee.bottom < y1) );
  9465. } else if (options.tolerance == 'fit') {
  9466. hit = (selectee.left > x1 && selectee.right < x2 && selectee.top > y1 && selectee.bottom < y2);
  9467. }
  9468. if (hit) {
  9469. // SELECT
  9470. if (selectee.selected) {
  9471. selectee.$element.removeClass('ui-selected');
  9472. selectee.selected = false;
  9473. }
  9474. if (selectee.unselecting) {
  9475. selectee.$element.removeClass('ui-unselecting');
  9476. selectee.unselecting = false;
  9477. }
  9478. if (!selectee.selecting) {
  9479. selectee.$element.addClass('ui-selecting');
  9480. selectee.selecting = true;
  9481. // selectable SELECTING callback
  9482. that._trigger("selecting", event, {
  9483. selecting: selectee.element
  9484. });
  9485. }
  9486. } else {
  9487. // UNSELECT
  9488. if (selectee.selecting) {
  9489. if ((event.metaKey || event.ctrlKey) && selectee.startselected) {
  9490. selectee.$element.removeClass('ui-selecting');
  9491. selectee.selecting = false;
  9492. selectee.$element.addClass('ui-selected');
  9493. selectee.selected = true;
  9494. } else {
  9495. selectee.$element.removeClass('ui-selecting');
  9496. selectee.selecting = false;
  9497. if (selectee.startselected) {
  9498. selectee.$element.addClass('ui-unselecting');
  9499. selectee.unselecting = true;
  9500. }
  9501. // selectable UNSELECTING callback
  9502. that._trigger("unselecting", event, {
  9503. unselecting: selectee.element
  9504. });
  9505. }
  9506. }
  9507. if (selectee.selected) {
  9508. if (!event.metaKey && !event.ctrlKey && !selectee.startselected) {
  9509. selectee.$element.removeClass('ui-selected');
  9510. selectee.selected = false;
  9511. selectee.$element.addClass('ui-unselecting');
  9512. selectee.unselecting = true;
  9513. // selectable UNSELECTING callback
  9514. that._trigger("unselecting", event, {
  9515. unselecting: selectee.element
  9516. });
  9517. }
  9518. }
  9519. }
  9520. });
  9521. return false;
  9522. },
  9523. _mouseStop: function(event) {
  9524. var that = this;
  9525. this.dragged = false;
  9526. var options = this.options;
  9527. $('.ui-unselecting', this.element[0]).each(function() {
  9528. var selectee = $.data(this, "selectable-item");
  9529. selectee.$element.removeClass('ui-unselecting');
  9530. selectee.unselecting = false;
  9531. selectee.startselected = false;
  9532. that._trigger("unselected", event, {
  9533. unselected: selectee.element
  9534. });
  9535. });
  9536. $('.ui-selecting', this.element[0]).each(function() {
  9537. var selectee = $.data(this, "selectable-item");
  9538. selectee.$element.removeClass('ui-selecting').addClass('ui-selected');
  9539. selectee.selecting = false;
  9540. selectee.selected = true;
  9541. selectee.startselected = true;
  9542. that._trigger("selected", event, {
  9543. selected: selectee.element
  9544. });
  9545. });
  9546. this._trigger("stop", event);
  9547. this.helper.remove();
  9548. return false;
  9549. }
  9550. });
  9551. })(jQuery);
  9552. (function( $, undefined ) {
  9553. // number of pages in a slider
  9554. // (how many times can you page up/down to go through the whole range)
  9555. var numPages = 5;
  9556. $.widget( "ui.slider", $.ui.mouse, {
  9557. version: "1.9.2",
  9558. widgetEventPrefix: "slide",
  9559. options: {
  9560. animate: false,
  9561. distance: 0,
  9562. max: 100,
  9563. min: 0,
  9564. orientation: "horizontal",
  9565. range: false,
  9566. step: 1,
  9567. value: 0,
  9568. values: null
  9569. },
  9570. _create: function() {
  9571. var i, handleCount,
  9572. o = this.options,
  9573. existingHandles = this.element.find( ".ui-slider-handle" ).addClass( "ui-state-default ui-corner-all" ),
  9574. handle = "<a class='ui-slider-handle ui-state-default ui-corner-all' href='#'></a>",
  9575. handles = [];
  9576. this._keySliding = false;
  9577. this._mouseSliding = false;
  9578. this._animateOff = true;
  9579. this._handleIndex = null;
  9580. this._detectOrientation();
  9581. this._mouseInit();
  9582. this.element
  9583. .addClass( "ui-slider" +
  9584. " ui-slider-" + this.orientation +
  9585. " ui-widget" +
  9586. " ui-widget-content" +
  9587. " ui-corner-all" +
  9588. ( o.disabled ? " ui-slider-disabled ui-disabled" : "" ) );
  9589. this.range = $([]);
  9590. if ( o.range ) {
  9591. if ( o.range === true ) {
  9592. if ( !o.values ) {
  9593. o.values = [ this._valueMin(), this._valueMin() ];
  9594. }
  9595. if ( o.values.length && o.values.length !== 2 ) {
  9596. o.values = [ o.values[0], o.values[0] ];
  9597. }
  9598. }
  9599. this.range = $( "<div></div>" )
  9600. .appendTo( this.element )
  9601. .addClass( "ui-slider-range" +
  9602. // note: this isn't the most fittingly semantic framework class for this element,
  9603. // but worked best visually with a variety of themes
  9604. " ui-widget-header" +
  9605. ( ( o.range === "min" || o.range === "max" ) ? " ui-slider-range-" + o.range : "" ) );
  9606. }
  9607. handleCount = ( o.values && o.values.length ) || 1;
  9608. for ( i = existingHandles.length; i < handleCount; i++ ) {
  9609. handles.push( handle );
  9610. }
  9611. this.handles = existingHandles.add( $( handles.join( "" ) ).appendTo( this.element ) );
  9612. this.handle = this.handles.eq( 0 );
  9613. this.handles.add( this.range ).filter( "a" )
  9614. .click(function( event ) {
  9615. event.preventDefault();
  9616. })
  9617. .mouseenter(function() {
  9618. if ( !o.disabled ) {
  9619. $( this ).addClass( "ui-state-hover" );
  9620. }
  9621. })
  9622. .mouseleave(function() {
  9623. $( this ).removeClass( "ui-state-hover" );
  9624. })
  9625. .focus(function() {
  9626. if ( !o.disabled ) {
  9627. $( ".ui-slider .ui-state-focus" ).removeClass( "ui-state-focus" );
  9628. $( this ).addClass( "ui-state-focus" );
  9629. } else {
  9630. $( this ).blur();
  9631. }
  9632. })
  9633. .blur(function() {
  9634. $( this ).removeClass( "ui-state-focus" );
  9635. });
  9636. this.handles.each(function( i ) {
  9637. $( this ).data( "ui-slider-handle-index", i );
  9638. });
  9639. this._on( this.handles, {
  9640. keydown: function( event ) {
  9641. var allowed, curVal, newVal, step,
  9642. index = $( event.target ).data( "ui-slider-handle-index" );
  9643. switch ( event.keyCode ) {
  9644. case $.ui.keyCode.HOME:
  9645. case $.ui.keyCode.END:
  9646. case $.ui.keyCode.PAGE_UP:
  9647. case $.ui.keyCode.PAGE_DOWN:
  9648. case $.ui.keyCode.UP:
  9649. case $.ui.keyCode.RIGHT:
  9650. case $.ui.keyCode.DOWN:
  9651. case $.ui.keyCode.LEFT:
  9652. event.preventDefault();
  9653. if ( !this._keySliding ) {
  9654. this._keySliding = true;
  9655. $( event.target ).addClass( "ui-state-active" );
  9656. allowed = this._start( event, index );
  9657. if ( allowed === false ) {
  9658. return;
  9659. }
  9660. }
  9661. break;
  9662. }
  9663. step = this.options.step;
  9664. if ( this.options.values && this.options.values.length ) {
  9665. curVal = newVal = this.values( index );
  9666. } else {
  9667. curVal = newVal = this.value();
  9668. }
  9669. switch ( event.keyCode ) {
  9670. case $.ui.keyCode.HOME:
  9671. newVal = this._valueMin();
  9672. break;
  9673. case $.ui.keyCode.END:
  9674. newVal = this._valueMax();
  9675. break;
  9676. case $.ui.keyCode.PAGE_UP:
  9677. newVal = this._trimAlignValue( curVal + ( (this._valueMax() - this._valueMin()) / numPages ) );
  9678. break;
  9679. case $.ui.keyCode.PAGE_DOWN:
  9680. newVal = this._trimAlignValue( curVal - ( (this._valueMax() - this._valueMin()) / numPages ) );
  9681. break;
  9682. case $.ui.keyCode.UP:
  9683. case $.ui.keyCode.RIGHT:
  9684. if ( curVal === this._valueMax() ) {
  9685. return;
  9686. }
  9687. newVal = this._trimAlignValue( curVal + step );
  9688. break;
  9689. case $.ui.keyCode.DOWN:
  9690. case $.ui.keyCode.LEFT:
  9691. if ( curVal === this._valueMin() ) {
  9692. return;
  9693. }
  9694. newVal = this._trimAlignValue( curVal - step );
  9695. break;
  9696. }
  9697. this._slide( event, index, newVal );
  9698. },
  9699. keyup: function( event ) {
  9700. var index = $( event.target ).data( "ui-slider-handle-index" );
  9701. if ( this._keySliding ) {
  9702. this._keySliding = false;
  9703. this._stop( event, index );
  9704. this._change( event, index );
  9705. $( event.target ).removeClass( "ui-state-active" );
  9706. }
  9707. }
  9708. });
  9709. this._refreshValue();
  9710. this._animateOff = false;
  9711. },
  9712. _destroy: function() {
  9713. this.handles.remove();
  9714. this.range.remove();
  9715. this.element
  9716. .removeClass( "ui-slider" +
  9717. " ui-slider-horizontal" +
  9718. " ui-slider-vertical" +
  9719. " ui-slider-disabled" +
  9720. " ui-widget" +
  9721. " ui-widget-content" +
  9722. " ui-corner-all" );
  9723. this._mouseDestroy();
  9724. },
  9725. _mouseCapture: function( event ) {
  9726. var position, normValue, distance, closestHandle, index, allowed, offset, mouseOverHandle,
  9727. that = this,
  9728. o = this.options;
  9729. if ( o.disabled ) {
  9730. return false;
  9731. }
  9732. this.elementSize = {
  9733. width: this.element.outerWidth(),
  9734. height: this.element.outerHeight()
  9735. };
  9736. this.elementOffset = this.element.offset();
  9737. position = { x: event.pageX, y: event.pageY };
  9738. normValue = this._normValueFromMouse( position );
  9739. distance = this._valueMax() - this._valueMin() + 1;
  9740. this.handles.each(function( i ) {
  9741. var thisDistance = Math.abs( normValue - that.values(i) );
  9742. if ( distance > thisDistance ) {
  9743. distance = thisDistance;
  9744. closestHandle = $( this );
  9745. index = i;
  9746. }
  9747. });
  9748. // workaround for bug #3736 (if both handles of a range are at 0,
  9749. // the first is always used as the one with least distance,
  9750. // and moving it is obviously prevented by preventing negative ranges)
  9751. if( o.range === true && this.values(1) === o.min ) {
  9752. index += 1;
  9753. closestHandle = $( this.handles[index] );
  9754. }
  9755. allowed = this._start( event, index );
  9756. if ( allowed === false ) {
  9757. return false;
  9758. }
  9759. this._mouseSliding = true;
  9760. this._handleIndex = index;
  9761. closestHandle
  9762. .addClass( "ui-state-active" )
  9763. .focus();
  9764. offset = closestHandle.offset();
  9765. mouseOverHandle = !$( event.target ).parents().andSelf().is( ".ui-slider-handle" );
  9766. this._clickOffset = mouseOverHandle ? { left: 0, top: 0 } : {
  9767. left: event.pageX - offset.left - ( closestHandle.width() / 2 ),
  9768. top: event.pageY - offset.top -
  9769. ( closestHandle.height() / 2 ) -
  9770. ( parseInt( closestHandle.css("borderTopWidth"), 10 ) || 0 ) -
  9771. ( parseInt( closestHandle.css("borderBottomWidth"), 10 ) || 0) +
  9772. ( parseInt( closestHandle.css("marginTop"), 10 ) || 0)
  9773. };
  9774. if ( !this.handles.hasClass( "ui-state-hover" ) ) {
  9775. this._slide( event, index, normValue );
  9776. }
  9777. this._animateOff = true;
  9778. return true;
  9779. },
  9780. _mouseStart: function() {
  9781. return true;
  9782. },
  9783. _mouseDrag: function( event ) {
  9784. var position = { x: event.pageX, y: event.pageY },
  9785. normValue = this._normValueFromMouse( position );
  9786. this._slide( event, this._handleIndex, normValue );
  9787. return false;
  9788. },
  9789. _mouseStop: function( event ) {
  9790. this.handles.removeClass( "ui-state-active" );
  9791. this._mouseSliding = false;
  9792. this._stop( event, this._handleIndex );
  9793. this._change( event, this._handleIndex );
  9794. this._handleIndex = null;
  9795. this._clickOffset = null;
  9796. this._animateOff = false;
  9797. return false;
  9798. },
  9799. _detectOrientation: function() {
  9800. this.orientation = ( this.options.orientation === "vertical" ) ? "vertical" : "horizontal";
  9801. },
  9802. _normValueFromMouse: function( position ) {
  9803. var pixelTotal,
  9804. pixelMouse,
  9805. percentMouse,
  9806. valueTotal,
  9807. valueMouse;
  9808. if ( this.orientation === "horizontal" ) {
  9809. pixelTotal = this.elementSize.width;
  9810. pixelMouse = position.x - this.elementOffset.left - ( this._clickOffset ? this._clickOffset.left : 0 );
  9811. } else {
  9812. pixelTotal = this.elementSize.height;
  9813. pixelMouse = position.y - this.elementOffset.top - ( this._clickOffset ? this._clickOffset.top : 0 );
  9814. }
  9815. percentMouse = ( pixelMouse / pixelTotal );
  9816. if ( percentMouse > 1 ) {
  9817. percentMouse = 1;
  9818. }
  9819. if ( percentMouse < 0 ) {
  9820. percentMouse = 0;
  9821. }
  9822. if ( this.orientation === "vertical" ) {
  9823. percentMouse = 1 - percentMouse;
  9824. }
  9825. valueTotal = this._valueMax() - this._valueMin();
  9826. valueMouse = this._valueMin() + percentMouse * valueTotal;
  9827. return this._trimAlignValue( valueMouse );
  9828. },
  9829. _start: function( event, index ) {
  9830. var uiHash = {
  9831. handle: this.handles[ index ],
  9832. value: this.value()
  9833. };
  9834. if ( this.options.values && this.options.values.length ) {
  9835. uiHash.value = this.values( index );
  9836. uiHash.values = this.values();
  9837. }
  9838. return this._trigger( "start", event, uiHash );
  9839. },
  9840. _slide: function( event, index, newVal ) {
  9841. var otherVal,
  9842. newValues,
  9843. allowed;
  9844. if ( this.options.values && this.options.values.length ) {
  9845. otherVal = this.values( index ? 0 : 1 );
  9846. if ( ( this.options.values.length === 2 && this.options.range === true ) &&
  9847. ( ( index === 0 && newVal > otherVal) || ( index === 1 && newVal < otherVal ) )
  9848. ) {
  9849. newVal = otherVal;
  9850. }
  9851. if ( newVal !== this.values( index ) ) {
  9852. newValues = this.values();
  9853. newValues[ index ] = newVal;
  9854. // A slide can be canceled by returning false from the slide callback
  9855. allowed = this._trigger( "slide", event, {
  9856. handle: this.handles[ index ],
  9857. value: newVal,
  9858. values: newValues
  9859. } );
  9860. otherVal = this.values( index ? 0 : 1 );
  9861. if ( allowed !== false ) {
  9862. this.values( index, newVal, true );
  9863. }
  9864. }
  9865. } else {
  9866. if ( newVal !== this.value() ) {
  9867. // A slide can be canceled by returning false from the slide callback
  9868. allowed = this._trigger( "slide", event, {
  9869. handle: this.handles[ index ],
  9870. value: newVal
  9871. } );
  9872. if ( allowed !== false ) {
  9873. this.value( newVal );
  9874. }
  9875. }
  9876. }
  9877. },
  9878. _stop: function( event, index ) {
  9879. var uiHash = {
  9880. handle: this.handles[ index ],
  9881. value: this.value()
  9882. };
  9883. if ( this.options.values && this.options.values.length ) {
  9884. uiHash.value = this.values( index );
  9885. uiHash.values = this.values();
  9886. }
  9887. this._trigger( "stop", event, uiHash );
  9888. },
  9889. _change: function( event, index ) {
  9890. if ( !this._keySliding && !this._mouseSliding ) {
  9891. var uiHash = {
  9892. handle: this.handles[ index ],
  9893. value: this.value()
  9894. };
  9895. if ( this.options.values && this.options.values.length ) {
  9896. uiHash.value = this.values( index );
  9897. uiHash.values = this.values();
  9898. }
  9899. this._trigger( "change", event, uiHash );
  9900. }
  9901. },
  9902. value: function( newValue ) {
  9903. if ( arguments.length ) {
  9904. this.options.value = this._trimAlignValue( newValue );
  9905. this._refreshValue();
  9906. this._change( null, 0 );
  9907. return;
  9908. }
  9909. return this._value();
  9910. },
  9911. values: function( index, newValue ) {
  9912. var vals,
  9913. newValues,
  9914. i;
  9915. if ( arguments.length > 1 ) {
  9916. this.options.values[ index ] = this._trimAlignValue( newValue );
  9917. this._refreshValue();
  9918. this._change( null, index );
  9919. return;
  9920. }
  9921. if ( arguments.length ) {
  9922. if ( $.isArray( arguments[ 0 ] ) ) {
  9923. vals = this.options.values;
  9924. newValues = arguments[ 0 ];
  9925. for ( i = 0; i < vals.length; i += 1 ) {
  9926. vals[ i ] = this._trimAlignValue( newValues[ i ] );
  9927. this._change( null, i );
  9928. }
  9929. this._refreshValue();
  9930. } else {
  9931. if ( this.options.values && this.options.values.length ) {
  9932. return this._values( index );
  9933. } else {
  9934. return this.value();
  9935. }
  9936. }
  9937. } else {
  9938. return this._values();
  9939. }
  9940. },
  9941. _setOption: function( key, value ) {
  9942. var i,
  9943. valsLength = 0;
  9944. if ( $.isArray( this.options.values ) ) {
  9945. valsLength = this.options.values.length;
  9946. }
  9947. $.Widget.prototype._setOption.apply( this, arguments );
  9948. switch ( key ) {
  9949. case "disabled":
  9950. if ( value ) {
  9951. this.handles.filter( ".ui-state-focus" ).blur();
  9952. this.handles.removeClass( "ui-state-hover" );
  9953. this.handles.prop( "disabled", true );
  9954. this.element.addClass( "ui-disabled" );
  9955. } else {
  9956. this.handles.prop( "disabled", false );
  9957. this.element.removeClass( "ui-disabled" );
  9958. }
  9959. break;
  9960. case "orientation":
  9961. this._detectOrientation();
  9962. this.element
  9963. .removeClass( "ui-slider-horizontal ui-slider-vertical" )
  9964. .addClass( "ui-slider-" + this.orientation );
  9965. this._refreshValue();
  9966. break;
  9967. case "value":
  9968. this._animateOff = true;
  9969. this._refreshValue();
  9970. this._change( null, 0 );
  9971. this._animateOff = false;
  9972. break;
  9973. case "values":
  9974. this._animateOff = true;
  9975. this._refreshValue();
  9976. for ( i = 0; i < valsLength; i += 1 ) {
  9977. this._change( null, i );
  9978. }
  9979. this._animateOff = false;
  9980. break;
  9981. case "min":
  9982. case "max":
  9983. this._animateOff = true;
  9984. this._refreshValue();
  9985. this._animateOff = false;
  9986. break;
  9987. }
  9988. },
  9989. //internal value getter
  9990. // _value() returns value trimmed by min and max, aligned by step
  9991. _value: function() {
  9992. var val = this.options.value;
  9993. val = this._trimAlignValue( val );
  9994. return val;
  9995. },
  9996. //internal values getter
  9997. // _values() returns array of values trimmed by min and max, aligned by step
  9998. // _values( index ) returns single value trimmed by min and max, aligned by step
  9999. _values: function( index ) {
  10000. var val,
  10001. vals,
  10002. i;
  10003. if ( arguments.length ) {
  10004. val = this.options.values[ index ];
  10005. val = this._trimAlignValue( val );
  10006. return val;
  10007. } else {
  10008. // .slice() creates a copy of the array
  10009. // this copy gets trimmed by min and max and then returned
  10010. vals = this.options.values.slice();
  10011. for ( i = 0; i < vals.length; i+= 1) {
  10012. vals[ i ] = this._trimAlignValue( vals[ i ] );
  10013. }
  10014. return vals;
  10015. }
  10016. },
  10017. // returns the step-aligned value that val is closest to, between (inclusive) min and max
  10018. _trimAlignValue: function( val ) {
  10019. if ( val <= this._valueMin() ) {
  10020. return this._valueMin();
  10021. }
  10022. if ( val >= this._valueMax() ) {
  10023. return this._valueMax();
  10024. }
  10025. var step = ( this.options.step > 0 ) ? this.options.step : 1,
  10026. valModStep = (val - this._valueMin()) % step,
  10027. alignValue = val - valModStep;
  10028. if ( Math.abs(valModStep) * 2 >= step ) {
  10029. alignValue += ( valModStep > 0 ) ? step : ( -step );
  10030. }
  10031. // Since JavaScript has problems with large floats, round
  10032. // the final value to 5 digits after the decimal point (see #4124)
  10033. return parseFloat( alignValue.toFixed(5) );
  10034. },
  10035. _valueMin: function() {
  10036. return this.options.min;
  10037. },
  10038. _valueMax: function() {
  10039. return this.options.max;
  10040. },
  10041. _refreshValue: function() {
  10042. var lastValPercent, valPercent, value, valueMin, valueMax,
  10043. oRange = this.options.range,
  10044. o = this.options,
  10045. that = this,
  10046. animate = ( !this._animateOff ) ? o.animate : false,
  10047. _set = {};
  10048. if ( this.options.values && this.options.values.length ) {
  10049. this.handles.each(function( i ) {
  10050. valPercent = ( that.values(i) - that._valueMin() ) / ( that._valueMax() - that._valueMin() ) * 100;
  10051. _set[ that.orientation === "horizontal" ? "left" : "bottom" ] = valPercent + "%";
  10052. $( this ).stop( 1, 1 )[ animate ? "animate" : "css" ]( _set, o.animate );
  10053. if ( that.options.range === true ) {
  10054. if ( that.orientation === "horizontal" ) {
  10055. if ( i === 0 ) {
  10056. that.range.stop( 1, 1 )[ animate ? "animate" : "css" ]( { left: valPercent + "%" }, o.animate );
  10057. }
  10058. if ( i === 1 ) {
  10059. that.range[ animate ? "animate" : "css" ]( { width: ( valPercent - lastValPercent ) + "%" }, { queue: false, duration: o.animate } );
  10060. }
  10061. } else {
  10062. if ( i === 0 ) {
  10063. that.range.stop( 1, 1 )[ animate ? "animate" : "css" ]( { bottom: ( valPercent ) + "%" }, o.animate );
  10064. }
  10065. if ( i === 1 ) {
  10066. that.range[ animate ? "animate" : "css" ]( { height: ( valPercent - lastValPercent ) + "%" }, { queue: false, duration: o.animate } );
  10067. }
  10068. }
  10069. }
  10070. lastValPercent = valPercent;
  10071. });
  10072. } else {
  10073. value = this.value();
  10074. valueMin = this._valueMin();
  10075. valueMax = this._valueMax();
  10076. valPercent = ( valueMax !== valueMin ) ?
  10077. ( value - valueMin ) / ( valueMax - valueMin ) * 100 :
  10078. 0;
  10079. _set[ this.orientation === "horizontal" ? "left" : "bottom" ] = valPercent + "%";
  10080. this.handle.stop( 1, 1 )[ animate ? "animate" : "css" ]( _set, o.animate );
  10081. if ( oRange === "min" && this.orientation === "horizontal" ) {
  10082. this.range.stop( 1, 1 )[ animate ? "animate" : "css" ]( { width: valPercent + "%" }, o.animate );
  10083. }
  10084. if ( oRange === "max" && this.orientation === "horizontal" ) {
  10085. this.range[ animate ? "animate" : "css" ]( { width: ( 100 - valPercent ) + "%" }, { queue: false, duration: o.animate } );
  10086. }
  10087. if ( oRange === "min" && this.orientation === "vertical" ) {
  10088. this.range.stop( 1, 1 )[ animate ? "animate" : "css" ]( { height: valPercent + "%" }, o.animate );
  10089. }
  10090. if ( oRange === "max" && this.orientation === "vertical" ) {
  10091. this.range[ animate ? "animate" : "css" ]( { height: ( 100 - valPercent ) + "%" }, { queue: false, duration: o.animate } );
  10092. }
  10093. }
  10094. }
  10095. });
  10096. }(jQuery));
  10097. (function( $, undefined ) {
  10098. $.widget("ui.sortable", $.ui.mouse, {
  10099. version: "1.9.2",
  10100. widgetEventPrefix: "sort",
  10101. ready: false,
  10102. options: {
  10103. appendTo: "parent",
  10104. axis: false,
  10105. connectWith: false,
  10106. containment: false,
  10107. cursor: 'auto',
  10108. cursorAt: false,
  10109. dropOnEmpty: true,
  10110. forcePlaceholderSize: false,
  10111. forceHelperSize: false,
  10112. grid: false,
  10113. handle: false,
  10114. helper: "original",
  10115. items: '> *',
  10116. opacity: false,
  10117. placeholder: false,
  10118. revert: false,
  10119. scroll: true,
  10120. scrollSensitivity: 20,
  10121. scrollSpeed: 20,
  10122. scope: "default",
  10123. tolerance: "intersect",
  10124. zIndex: 1000
  10125. },
  10126. _create: function() {
  10127. var o = this.options;
  10128. this.containerCache = {};
  10129. this.element.addClass("ui-sortable");
  10130. //Get the items
  10131. this.refresh();
  10132. //Let's determine if the items are being displayed horizontally
  10133. 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;
  10134. //Let's determine the parent's offset
  10135. this.offset = this.element.offset();
  10136. //Initialize mouse events for interaction
  10137. this._mouseInit();
  10138. //We're ready to go
  10139. this.ready = true
  10140. },
  10141. _destroy: function() {
  10142. this.element
  10143. .removeClass("ui-sortable ui-sortable-disabled");
  10144. this._mouseDestroy();
  10145. for ( var i = this.items.length - 1; i >= 0; i-- )
  10146. this.items[i].item.removeData(this.widgetName + "-item");
  10147. return this;
  10148. },
  10149. _setOption: function(key, value){
  10150. if ( key === "disabled" ) {
  10151. this.options[ key ] = value;
  10152. this.widget().toggleClass( "ui-sortable-disabled", !!value );
  10153. } else {
  10154. // Don't call widget base _setOption for disable as it adds ui-state-disabled class
  10155. $.Widget.prototype._setOption.apply(this, arguments);
  10156. }
  10157. },
  10158. _mouseCapture: function(event, overrideHandle) {
  10159. var that = this;
  10160. if (this.reverting) {
  10161. return false;
  10162. }
  10163. if(this.options.disabled || this.options.type == 'static') return false;
  10164. //We have to refresh the items data once first
  10165. this._refreshItems(event);
  10166. //Find out if the clicked node (or one of its parents) is a actual item in this.items
  10167. var currentItem = null, nodes = $(event.target).parents().each(function() {
  10168. if($.data(this, that.widgetName + '-item') == that) {
  10169. currentItem = $(this);
  10170. return false;
  10171. }
  10172. });
  10173. if($.data(event.target, that.widgetName + '-item') == that) currentItem = $(event.target);
  10174. if(!currentItem) return false;
  10175. if(this.options.handle && !overrideHandle) {
  10176. var validHandle = false;
  10177. $(this.options.handle, currentItem).find("*").andSelf().each(function() { if(this == event.target) validHandle = true; });
  10178. if(!validHandle) return false;
  10179. }
  10180. this.currentItem = currentItem;
  10181. this._removeCurrentsFromItems();
  10182. return true;
  10183. },
  10184. _mouseStart: function(event, overrideHandle, noActivation) {
  10185. var o = this.options;
  10186. this.currentContainer = this;
  10187. //We only need to call refreshPositions, because the refreshItems call has been moved to mouseCapture
  10188. this.refreshPositions();
  10189. //Create and append the visible helper
  10190. this.helper = this._createHelper(event);
  10191. //Cache the helper size
  10192. this._cacheHelperProportions();
  10193. /*
  10194. * - Position generation -
  10195. * This block generates everything position related - it's the core of draggables.
  10196. */
  10197. //Cache the margins of the original element
  10198. this._cacheMargins();
  10199. //Get the next scrolling parent
  10200. this.scrollParent = this.helper.scrollParent();
  10201. //The element's absolute position on the page minus margins
  10202. this.offset = this.currentItem.offset();
  10203. this.offset = {
  10204. top: this.offset.top - this.margins.top,
  10205. left: this.offset.left - this.margins.left
  10206. };
  10207. $.extend(this.offset, {
  10208. click: { //Where the click happened, relative to the element
  10209. left: event.pageX - this.offset.left,
  10210. top: event.pageY - this.offset.top
  10211. },
  10212. parent: this._getParentOffset(),
  10213. relative: this._getRelativeOffset() //This is a relative to absolute position minus the actual position calculation - only used for relative positioned helper
  10214. });
  10215. // Only after we got the offset, we can change the helper's position to absolute
  10216. // TODO: Still need to figure out a way to make relative sorting possible
  10217. this.helper.css("position", "absolute");
  10218. this.cssPosition = this.helper.css("position");
  10219. //Generate the original position
  10220. this.originalPosition = this._generatePosition(event);
  10221. this.originalPageX = event.pageX;
  10222. this.originalPageY = event.pageY;
  10223. //Adjust the mouse offset relative to the helper if 'cursorAt' is supplied
  10224. (o.cursorAt && this._adjustOffsetFromHelper(o.cursorAt));
  10225. //Cache the former DOM position
  10226. this.domPosition = { prev: this.currentItem.prev()[0], parent: this.currentItem.parent()[0] };
  10227. //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
  10228. if(this.helper[0] != this.currentItem[0]) {
  10229. this.currentItem.hide();
  10230. }
  10231. //Create the placeholder
  10232. this._createPlaceholder();
  10233. //Set a containment if given in the options
  10234. if(o.containment)
  10235. this._setContainment();
  10236. if(o.cursor) { // cursor option
  10237. if ($('body').css("cursor")) this._storedCursor = $('body').css("cursor");
  10238. $('body').css("cursor", o.cursor);
  10239. }
  10240. if(o.opacity) { // opacity option
  10241. if (this.helper.css("opacity")) this._storedOpacity = this.helper.css("opacity");
  10242. this.helper.css("opacity", o.opacity);
  10243. }
  10244. if(o.zIndex) { // zIndex option
  10245. if (this.helper.css("zIndex")) this._storedZIndex = this.helper.css("zIndex");
  10246. this.helper.css("zIndex", o.zIndex);
  10247. }
  10248. //Prepare scrolling
  10249. if(this.scrollParent[0] != document && this.scrollParent[0].tagName != 'HTML')
  10250. this.overflowOffset = this.scrollParent.offset();
  10251. //Call callbacks
  10252. this._trigger("start", event, this._uiHash());
  10253. //Recache the helper size
  10254. if(!this._preserveHelperProportions)
  10255. this._cacheHelperProportions();
  10256. //Post 'activate' events to possible containers
  10257. if(!noActivation) {
  10258. for (var i = this.containers.length - 1; i >= 0; i--) { this.containers[i]._trigger("activate", event, this._uiHash(this)); }
  10259. }
  10260. //Prepare possible droppables
  10261. if($.ui.ddmanager)
  10262. $.ui.ddmanager.current = this;
  10263. if ($.ui.ddmanager && !o.dropBehaviour)
  10264. $.ui.ddmanager.prepareOffsets(this, event);
  10265. this.dragging = true;
  10266. this.helper.addClass("ui-sortable-helper");
  10267. this._mouseDrag(event); //Execute the drag once - this causes the helper not to be visible before getting its correct position
  10268. return true;
  10269. },
  10270. _mouseDrag: function(event) {
  10271. //Compute the helpers position
  10272. this.position = this._generatePosition(event);
  10273. this.positionAbs = this._convertPositionTo("absolute");
  10274. if (!this.lastPositionAbs) {
  10275. this.lastPositionAbs = this.positionAbs;
  10276. }
  10277. //Do scrolling
  10278. if(this.options.scroll) {
  10279. var o = this.options, scrolled = false;
  10280. if(this.scrollParent[0] != document && this.scrollParent[0].tagName != 'HTML') {
  10281. if((this.overflowOffset.top + this.scrollParent[0].offsetHeight) - event.pageY < o.scrollSensitivity)
  10282. this.scrollParent[0].scrollTop = scrolled = this.scrollParent[0].scrollTop + o.scrollSpeed;
  10283. else if(event.pageY - this.overflowOffset.top < o.scrollSensitivity)
  10284. this.scrollParent[0].scrollTop = scrolled = this.scrollParent[0].scrollTop - o.scrollSpeed;
  10285. if((this.overflowOffset.left + this.scrollParent[0].offsetWidth) - event.pageX < o.scrollSensitivity)
  10286. this.scrollParent[0].scrollLeft = scrolled = this.scrollParent[0].scrollLeft + o.scrollSpeed;
  10287. else if(event.pageX - this.overflowOffset.left < o.scrollSensitivity)
  10288. this.scrollParent[0].scrollLeft = scrolled = this.scrollParent[0].scrollLeft - o.scrollSpeed;
  10289. } else {
  10290. if(event.pageY - $(document).scrollTop() < o.scrollSensitivity)
  10291. scrolled = $(document).scrollTop($(document).scrollTop() - o.scrollSpeed);
  10292. else if($(window).height() - (event.pageY - $(document).scrollTop()) < o.scrollSensitivity)
  10293. scrolled = $(document).scrollTop($(document).scrollTop() + o.scrollSpeed);
  10294. if(event.pageX - $(document).scrollLeft() < o.scrollSensitivity)
  10295. scrolled = $(document).scrollLeft($(document).scrollLeft() - o.scrollSpeed);
  10296. else if($(window).width() - (event.pageX - $(document).scrollLeft()) < o.scrollSensitivity)
  10297. scrolled = $(document).scrollLeft($(document).scrollLeft() + o.scrollSpeed);
  10298. }
  10299. if(scrolled !== false && $.ui.ddmanager && !o.dropBehaviour)
  10300. $.ui.ddmanager.prepareOffsets(this, event);
  10301. }
  10302. //Regenerate the absolute position used for position checks
  10303. this.positionAbs = this._convertPositionTo("absolute");
  10304. //Set the helper position
  10305. if(!this.options.axis || this.options.axis != "y") this.helper[0].style.left = this.position.left+'px';
  10306. if(!this.options.axis || this.options.axis != "x") this.helper[0].style.top = this.position.top+'px';
  10307. //Rearrange
  10308. for (var i = this.items.length - 1; i >= 0; i--) {
  10309. //Cache variables and intersection, continue if no intersection
  10310. var item = this.items[i], itemElement = item.item[0], intersection = this._intersectsWithPointer(item);
  10311. if (!intersection) continue;
  10312. // Only put the placeholder inside the current Container, skip all
  10313. // items form other containers. This works because when moving
  10314. // an item from one container to another the
  10315. // currentContainer is switched before the placeholder is moved.
  10316. //
  10317. // Without this moving items in "sub-sortables" can cause the placeholder to jitter
  10318. // beetween the outer and inner container.
  10319. if (item.instance !== this.currentContainer) continue;
  10320. if (itemElement != this.currentItem[0] //cannot intersect with itself
  10321. && this.placeholder[intersection == 1 ? "next" : "prev"]()[0] != itemElement //no useless actions that have been done before
  10322. && !$.contains(this.placeholder[0], itemElement) //no action if the item moved is the parent of the item checked
  10323. && (this.options.type == 'semi-dynamic' ? !$.contains(this.element[0], itemElement) : true)
  10324. //&& itemElement.parentNode == this.placeholder[0].parentNode // only rearrange items within the same container
  10325. ) {
  10326. this.direction = intersection == 1 ? "down" : "up";
  10327. if (this.options.tolerance == "pointer" || this._intersectsWithSides(item)) {
  10328. this._rearrange(event, item);
  10329. } else {
  10330. break;
  10331. }
  10332. this._trigger("change", event, this._uiHash());
  10333. break;
  10334. }
  10335. }
  10336. //Post events to containers
  10337. this._contactContainers(event);
  10338. //Interconnect with droppables
  10339. if($.ui.ddmanager) $.ui.ddmanager.drag(this, event);
  10340. //Call callbacks
  10341. this._trigger('sort', event, this._uiHash());
  10342. this.lastPositionAbs = this.positionAbs;
  10343. return false;
  10344. },
  10345. _mouseStop: function(event, noPropagation) {
  10346. if(!event) return;
  10347. //If we are using droppables, inform the manager about the drop
  10348. if ($.ui.ddmanager && !this.options.dropBehaviour)
  10349. $.ui.ddmanager.drop(this, event);
  10350. if(this.options.revert) {
  10351. var that = this;
  10352. var cur = this.placeholder.offset();
  10353. this.reverting = true;
  10354. $(this.helper).animate({
  10355. left: cur.left - this.offset.parent.left - this.margins.left + (this.offsetParent[0] == document.body ? 0 : this.offsetParent[0].scrollLeft),
  10356. top: cur.top - this.offset.parent.top - this.margins.top + (this.offsetParent[0] == document.body ? 0 : this.offsetParent[0].scrollTop)
  10357. }, parseInt(this.options.revert, 10) || 500, function() {
  10358. that._clear(event);
  10359. });
  10360. } else {
  10361. this._clear(event, noPropagation);
  10362. }
  10363. return false;
  10364. },
  10365. cancel: function() {
  10366. if(this.dragging) {
  10367. this._mouseUp({ target: null });
  10368. if(this.options.helper == "original")
  10369. this.currentItem.css(this._storedCSS).removeClass("ui-sortable-helper");
  10370. else
  10371. this.currentItem.show();
  10372. //Post deactivating events to containers
  10373. for (var i = this.containers.length - 1; i >= 0; i--){
  10374. this.containers[i]._trigger("deactivate", null, this._uiHash(this));
  10375. if(this.containers[i].containerCache.over) {
  10376. this.containers[i]._trigger("out", null, this._uiHash(this));
  10377. this.containers[i].containerCache.over = 0;
  10378. }
  10379. }
  10380. }
  10381. if (this.placeholder) {
  10382. //$(this.placeholder[0]).remove(); would have been the jQuery way - unfortunately, it unbinds ALL events from the original node!
  10383. if(this.placeholder[0].parentNode) this.placeholder[0].parentNode.removeChild(this.placeholder[0]);
  10384. if(this.options.helper != "original" && this.helper && this.helper[0].parentNode) this.helper.remove();
  10385. $.extend(this, {
  10386. helper: null,
  10387. dragging: false,
  10388. reverting: false,
  10389. _noFinalSort: null
  10390. });
  10391. if(this.domPosition.prev) {
  10392. $(this.domPosition.prev).after(this.currentItem);
  10393. } else {
  10394. $(this.domPosition.parent).prepend(this.currentItem);
  10395. }
  10396. }
  10397. return this;
  10398. },
  10399. serialize: function(o) {
  10400. var items = this._getItemsAsjQuery(o && o.connected);
  10401. var str = []; o = o || {};
  10402. $(items).each(function() {
  10403. var res = ($(o.item || this).attr(o.attribute || 'id') || '').match(o.expression || (/(.+)[-=_](.+)/));
  10404. if(res) str.push((o.key || res[1]+'[]')+'='+(o.key && o.expression ? res[1] : res[2]));
  10405. });
  10406. if(!str.length && o.key) {
  10407. str.push(o.key + '=');
  10408. }
  10409. return str.join('&');
  10410. },
  10411. toArray: function(o) {
  10412. var items = this._getItemsAsjQuery(o && o.connected);
  10413. var ret = []; o = o || {};
  10414. items.each(function() { ret.push($(o.item || this).attr(o.attribute || 'id') || ''); });
  10415. return ret;
  10416. },
  10417. /* Be careful with the following core functions */
  10418. _intersectsWith: function(item) {
  10419. var x1 = this.positionAbs.left,
  10420. x2 = x1 + this.helperProportions.width,
  10421. y1 = this.positionAbs.top,
  10422. y2 = y1 + this.helperProportions.height;
  10423. var l = item.left,
  10424. r = l + item.width,
  10425. t = item.top,
  10426. b = t + item.height;
  10427. var dyClick = this.offset.click.top,
  10428. dxClick = this.offset.click.left;
  10429. var isOverElement = (y1 + dyClick) > t && (y1 + dyClick) < b && (x1 + dxClick) > l && (x1 + dxClick) < r;
  10430. if( this.options.tolerance == "pointer"
  10431. || this.options.forcePointerForContainers
  10432. || (this.options.tolerance != "pointer" && this.helperProportions[this.floating ? 'width' : 'height'] > item[this.floating ? 'width' : 'height'])
  10433. ) {
  10434. return isOverElement;
  10435. } else {
  10436. return (l < x1 + (this.helperProportions.width / 2) // Right Half
  10437. && x2 - (this.helperProportions.width / 2) < r // Left Half
  10438. && t < y1 + (this.helperProportions.height / 2) // Bottom Half
  10439. && y2 - (this.helperProportions.height / 2) < b ); // Top Half
  10440. }
  10441. },
  10442. _intersectsWithPointer: function(item) {
  10443. var isOverElementHeight = (this.options.axis === 'x') || $.ui.isOverAxis(this.positionAbs.top + this.offset.click.top, item.top, item.height),
  10444. isOverElementWidth = (this.options.axis === 'y') || $.ui.isOverAxis(this.positionAbs.left + this.offset.click.left, item.left, item.width),
  10445. isOverElement = isOverElementHeight && isOverElementWidth,
  10446. verticalDirection = this._getDragVerticalDirection(),
  10447. horizontalDirection = this._getDragHorizontalDirection();
  10448. if (!isOverElement)
  10449. return false;
  10450. return this.floating ?
  10451. ( ((horizontalDirection && horizontalDirection == "right") || verticalDirection == "down") ? 2 : 1 )
  10452. : ( verticalDirection && (verticalDirection == "down" ? 2 : 1) );
  10453. },
  10454. _intersectsWithSides: function(item) {
  10455. var isOverBottomHalf = $.ui.isOverAxis(this.positionAbs.top + this.offset.click.top, item.top + (item.height/2), item.height),
  10456. isOverRightHalf = $.ui.isOverAxis(this.positionAbs.left + this.offset.click.left, item.left + (item.width/2), item.width),
  10457. verticalDirection = this._getDragVerticalDirection(),
  10458. horizontalDirection = this._getDragHorizontalDirection();
  10459. if (this.floating && horizontalDirection) {
  10460. return ((horizontalDirection == "right" && isOverRightHalf) || (horizontalDirection == "left" && !isOverRightHalf));
  10461. } else {
  10462. return verticalDirection && ((verticalDirection == "down" && isOverBottomHalf) || (verticalDirection == "up" && !isOverBottomHalf));
  10463. }
  10464. },
  10465. _getDragVerticalDirection: function() {
  10466. var delta = this.positionAbs.top - this.lastPositionAbs.top;
  10467. return delta != 0 && (delta > 0 ? "down" : "up");
  10468. },
  10469. _getDragHorizontalDirection: function() {
  10470. var delta = this.positionAbs.left - this.lastPositionAbs.left;
  10471. return delta != 0 && (delta > 0 ? "right" : "left");
  10472. },
  10473. refresh: function(event) {
  10474. this._refreshItems(event);
  10475. this.refreshPositions();
  10476. return this;
  10477. },
  10478. _connectWith: function() {
  10479. var options = this.options;
  10480. return options.connectWith.constructor == String
  10481. ? [options.connectWith]
  10482. : options.connectWith;
  10483. },
  10484. _getItemsAsjQuery: function(connected) {
  10485. var items = [];
  10486. var queries = [];
  10487. var connectWith = this._connectWith();
  10488. if(connectWith && connected) {
  10489. for (var i = connectWith.length - 1; i >= 0; i--){
  10490. var cur = $(connectWith[i]);
  10491. for (var j = cur.length - 1; j >= 0; j--){
  10492. var inst = $.data(cur[j], this.widgetName);
  10493. if(inst && inst != this && !inst.options.disabled) {
  10494. 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]);
  10495. }
  10496. };
  10497. };
  10498. }
  10499. 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]);
  10500. for (var i = queries.length - 1; i >= 0; i--){
  10501. queries[i][0].each(function() {
  10502. items.push(this);
  10503. });
  10504. };
  10505. return $(items);
  10506. },
  10507. _removeCurrentsFromItems: function() {
  10508. var list = this.currentItem.find(":data(" + this.widgetName + "-item)");
  10509. this.items = $.grep(this.items, function (item) {
  10510. for (var j=0; j < list.length; j++) {
  10511. if(list[j] == item.item[0])
  10512. return false;
  10513. };
  10514. return true;
  10515. });
  10516. },
  10517. _refreshItems: function(event) {
  10518. this.items = [];
  10519. this.containers = [this];
  10520. var items = this.items;
  10521. var queries = [[$.isFunction(this.options.items) ? this.options.items.call(this.element[0], event, { item: this.currentItem }) : $(this.options.items, this.element), this]];
  10522. var connectWith = this._connectWith();
  10523. if(connectWith && this.ready) { //Shouldn't be run the first time through due to massive slow-down
  10524. for (var i = connectWith.length - 1; i >= 0; i--){
  10525. var cur = $(connectWith[i]);
  10526. for (var j = cur.length - 1; j >= 0; j--){
  10527. var inst = $.data(cur[j], this.widgetName);
  10528. if(inst && inst != this && !inst.options.disabled) {
  10529. queries.push([$.isFunction(inst.options.items) ? inst.options.items.call(inst.element[0], event, { item: this.currentItem }) : $(inst.options.items, inst.element), inst]);
  10530. this.containers.push(inst);
  10531. }
  10532. };
  10533. };
  10534. }
  10535. for (var i = queries.length - 1; i >= 0; i--) {
  10536. var targetData = queries[i][1];
  10537. var _queries = queries[i][0];
  10538. for (var j=0, queriesLength = _queries.length; j < queriesLength; j++) {
  10539. var item = $(_queries[j]);
  10540. item.data(this.widgetName + '-item', targetData); // Data for target checking (mouse manager)
  10541. items.push({
  10542. item: item,
  10543. instance: targetData,
  10544. width: 0, height: 0,
  10545. left: 0, top: 0
  10546. });
  10547. };
  10548. };
  10549. },
  10550. refreshPositions: function(fast) {
  10551. //This has to be redone because due to the item being moved out/into the offsetParent, the offsetParent's position will change
  10552. if(this.offsetParent && this.helper) {
  10553. this.offset.parent = this._getParentOffset();
  10554. }
  10555. for (var i = this.items.length - 1; i >= 0; i--){
  10556. var item = this.items[i];
  10557. //We ignore calculating positions of all connected containers when we're not over them
  10558. if(item.instance != this.currentContainer && this.currentContainer && item.item[0] != this.currentItem[0])
  10559. continue;
  10560. var t = this.options.toleranceElement ? $(this.options.toleranceElement, item.item) : item.item;
  10561. if (!fast) {
  10562. item.width = t.outerWidth();
  10563. item.height = t.outerHeight();
  10564. }
  10565. var p = t.offset();
  10566. item.left = p.left;
  10567. item.top = p.top;
  10568. };
  10569. if(this.options.custom && this.options.custom.refreshContainers) {
  10570. this.options.custom.refreshContainers.call(this);
  10571. } else {
  10572. for (var i = this.containers.length - 1; i >= 0; i--){
  10573. var p = this.containers[i].element.offset();
  10574. this.containers[i].containerCache.left = p.left;
  10575. this.containers[i].containerCache.top = p.top;
  10576. this.containers[i].containerCache.width = this.containers[i].element.outerWidth();
  10577. this.containers[i].containerCache.height = this.containers[i].element.outerHeight();
  10578. };
  10579. }
  10580. return this;
  10581. },
  10582. _createPlaceholder: function(that) {
  10583. that = that || this;
  10584. var o = that.options;
  10585. if(!o.placeholder || o.placeholder.constructor == String) {
  10586. var className = o.placeholder;
  10587. o.placeholder = {
  10588. element: function() {
  10589. var el = $(document.createElement(that.currentItem[0].nodeName))
  10590. .addClass(className || that.currentItem[0].className+" ui-sortable-placeholder")
  10591. .removeClass("ui-sortable-helper")[0];
  10592. if(!className)
  10593. el.style.visibility = "hidden";
  10594. return el;
  10595. },
  10596. update: function(container, p) {
  10597. // 1. If a className is set as 'placeholder option, we don't force sizes - the class is responsible for that
  10598. // 2. The option 'forcePlaceholderSize can be enabled to force it even if a class name is specified
  10599. if(className && !o.forcePlaceholderSize) return;
  10600. //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
  10601. if(!p.height()) { p.height(that.currentItem.innerHeight() - parseInt(that.currentItem.css('paddingTop')||0, 10) - parseInt(that.currentItem.css('paddingBottom')||0, 10)); };
  10602. if(!p.width()) { p.width(that.currentItem.innerWidth() - parseInt(that.currentItem.css('paddingLeft')||0, 10) - parseInt(that.currentItem.css('paddingRight')||0, 10)); };
  10603. }
  10604. };
  10605. }
  10606. //Create the placeholder
  10607. that.placeholder = $(o.placeholder.element.call(that.element, that.currentItem));
  10608. //Append it after the actual current item
  10609. that.currentItem.after(that.placeholder);
  10610. //Update the size of the placeholder (TODO: Logic to fuzzy, see line 316/317)
  10611. o.placeholder.update(that, that.placeholder);
  10612. },
  10613. _contactContainers: function(event) {
  10614. // get innermost container that intersects with item
  10615. var innermostContainer = null, innermostIndex = null;
  10616. for (var i = this.containers.length - 1; i >= 0; i--){
  10617. // never consider a container that's located within the item itself
  10618. if($.contains(this.currentItem[0], this.containers[i].element[0]))
  10619. continue;
  10620. if(this._intersectsWith(this.containers[i].containerCache)) {
  10621. // if we've already found a container and it's more "inner" than this, then continue
  10622. if(innermostContainer && $.contains(this.containers[i].element[0], innermostContainer.element[0]))
  10623. continue;
  10624. innermostContainer = this.containers[i];
  10625. innermostIndex = i;
  10626. } else {
  10627. // container doesn't intersect. trigger "out" event if necessary
  10628. if(this.containers[i].containerCache.over) {
  10629. this.containers[i]._trigger("out", event, this._uiHash(this));
  10630. this.containers[i].containerCache.over = 0;
  10631. }
  10632. }
  10633. }
  10634. // if no intersecting containers found, return
  10635. if(!innermostContainer) return;
  10636. // move the item into the container if it's not there already
  10637. if(this.containers.length === 1) {
  10638. this.containers[innermostIndex]._trigger("over", event, this._uiHash(this));
  10639. this.containers[innermostIndex].containerCache.over = 1;
  10640. } else {
  10641. //When entering a new container, we will find the item with the least distance and append our item near it
  10642. var dist = 10000; var itemWithLeastDistance = null;
  10643. var posProperty = this.containers[innermostIndex].floating ? 'left' : 'top';
  10644. var sizeProperty = this.containers[innermostIndex].floating ? 'width' : 'height';
  10645. var base = this.positionAbs[posProperty] + this.offset.click[posProperty];
  10646. for (var j = this.items.length - 1; j >= 0; j--) {
  10647. if(!$.contains(this.containers[innermostIndex].element[0], this.items[j].item[0])) continue;
  10648. if(this.items[j].item[0] == this.currentItem[0]) continue;
  10649. var cur = this.items[j].item.offset()[posProperty];
  10650. var nearBottom = false;
  10651. if(Math.abs(cur - base) > Math.abs(cur + this.items[j][sizeProperty] - base)){
  10652. nearBottom = true;
  10653. cur += this.items[j][sizeProperty];
  10654. }
  10655. if(Math.abs(cur - base) < dist) {
  10656. dist = Math.abs(cur - base); itemWithLeastDistance = this.items[j];
  10657. this.direction = nearBottom ? "up": "down";
  10658. }
  10659. }
  10660. if(!itemWithLeastDistance && !this.options.dropOnEmpty) //Check if dropOnEmpty is enabled
  10661. return;
  10662. this.currentContainer = this.containers[innermostIndex];
  10663. itemWithLeastDistance ? this._rearrange(event, itemWithLeastDistance, null, true) : this._rearrange(event, null, this.containers[innermostIndex].element, true);
  10664. this._trigger("change", event, this._uiHash());
  10665. this.containers[innermostIndex]._trigger("change", event, this._uiHash(this));
  10666. //Update the placeholder
  10667. this.options.placeholder.update(this.currentContainer, this.placeholder);
  10668. this.containers[innermostIndex]._trigger("over", event, this._uiHash(this));
  10669. this.containers[innermostIndex].containerCache.over = 1;
  10670. }
  10671. },
  10672. _createHelper: function(event) {
  10673. var o = this.options;
  10674. var helper = $.isFunction(o.helper) ? $(o.helper.apply(this.element[0], [event, this.currentItem])) : (o.helper == 'clone' ? this.currentItem.clone() : this.currentItem);
  10675. if(!helper.parents('body').length) //Add the helper to the DOM if that didn't happen already
  10676. $(o.appendTo != 'parent' ? o.appendTo : this.currentItem[0].parentNode)[0].appendChild(helper[0]);
  10677. if(helper[0] == this.currentItem[0])
  10678. 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") };
  10679. if(helper[0].style.width == '' || o.forceHelperSize) helper.width(this.currentItem.width());
  10680. if(helper[0].style.height == '' || o.forceHelperSize) helper.height(this.currentItem.height());
  10681. return helper;
  10682. },
  10683. _adjustOffsetFromHelper: function(obj) {
  10684. if (typeof obj == 'string') {
  10685. obj = obj.split(' ');
  10686. }
  10687. if ($.isArray(obj)) {
  10688. obj = {left: +obj[0], top: +obj[1] || 0};
  10689. }
  10690. if ('left' in obj) {
  10691. this.offset.click.left = obj.left + this.margins.left;
  10692. }
  10693. if ('right' in obj) {
  10694. this.offset.click.left = this.helperProportions.width - obj.right + this.margins.left;
  10695. }
  10696. if ('top' in obj) {
  10697. this.offset.click.top = obj.top + this.margins.top;
  10698. }
  10699. if ('bottom' in obj) {
  10700. this.offset.click.top = this.helperProportions.height - obj.bottom + this.margins.top;
  10701. }
  10702. },
  10703. _getParentOffset: function() {
  10704. //Get the offsetParent and cache its position
  10705. this.offsetParent = this.helper.offsetParent();
  10706. var po = this.offsetParent.offset();
  10707. // This is a special case where we need to modify a offset calculated on start, since the following happened:
  10708. // 1. The position of the helper is absolute, so it's position is calculated based on the next positioned parent
  10709. // 2. The actual offset parent is a child of the scroll parent, and the scroll parent isn't the document, which means that
  10710. // the scroll is included in the initial calculation of the offset of the parent, and never recalculated upon drag
  10711. if(this.cssPosition == 'absolute' && this.scrollParent[0] != document && $.contains(this.scrollParent[0], this.offsetParent[0])) {
  10712. po.left += this.scrollParent.scrollLeft();
  10713. po.top += this.scrollParent.scrollTop();
  10714. }
  10715. if((this.offsetParent[0] == document.body) //This needs to be actually done for all browsers, since pageX/pageY includes this information
  10716. || (this.offsetParent[0].tagName && this.offsetParent[0].tagName.toLowerCase() == 'html' && $.ui.ie)) //Ugly IE fix
  10717. po = { top: 0, left: 0 };
  10718. return {
  10719. top: po.top + (parseInt(this.offsetParent.css("borderTopWidth"),10) || 0),
  10720. left: po.left + (parseInt(this.offsetParent.css("borderLeftWidth"),10) || 0)
  10721. };
  10722. },
  10723. _getRelativeOffset: function() {
  10724. if(this.cssPosition == "relative") {
  10725. var p = this.currentItem.position();
  10726. return {
  10727. top: p.top - (parseInt(this.helper.css("top"),10) || 0) + this.scrollParent.scrollTop(),
  10728. left: p.left - (parseInt(this.helper.css("left"),10) || 0) + this.scrollParent.scrollLeft()
  10729. };
  10730. } else {
  10731. return { top: 0, left: 0 };
  10732. }
  10733. },
  10734. _cacheMargins: function() {
  10735. this.margins = {
  10736. left: (parseInt(this.currentItem.css("marginLeft"),10) || 0),
  10737. top: (parseInt(this.currentItem.css("marginTop"),10) || 0)
  10738. };
  10739. },
  10740. _cacheHelperProportions: function() {
  10741. this.helperProportions = {
  10742. width: this.helper.outerWidth(),
  10743. height: this.helper.outerHeight()
  10744. };
  10745. },
  10746. _setContainment: function() {
  10747. var o = this.options;
  10748. if(o.containment == 'parent') o.containment = this.helper[0].parentNode;
  10749. if(o.containment == 'document' || o.containment == 'window') this.containment = [
  10750. 0 - this.offset.relative.left - this.offset.parent.left,
  10751. 0 - this.offset.relative.top - this.offset.parent.top,
  10752. $(o.containment == 'document' ? document : window).width() - this.helperProportions.width - this.margins.left,
  10753. ($(o.containment == 'document' ? document : window).height() || document.body.parentNode.scrollHeight) - this.helperProportions.height - this.margins.top
  10754. ];
  10755. if(!(/^(document|window|parent)$/).test(o.containment)) {
  10756. var ce = $(o.containment)[0];
  10757. var co = $(o.containment).offset();
  10758. var over = ($(ce).css("overflow") != 'hidden');
  10759. this.containment = [
  10760. co.left + (parseInt($(ce).css("borderLeftWidth"),10) || 0) + (parseInt($(ce).css("paddingLeft"),10) || 0) - this.margins.left,
  10761. co.top + (parseInt($(ce).css("borderTopWidth"),10) || 0) + (parseInt($(ce).css("paddingTop"),10) || 0) - this.margins.top,
  10762. 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,
  10763. 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
  10764. ];
  10765. }
  10766. },
  10767. _convertPositionTo: function(d, pos) {
  10768. if(!pos) pos = this.position;
  10769. var mod = d == "absolute" ? 1 : -1;
  10770. var o = this.options, 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);
  10771. return {
  10772. top: (
  10773. pos.top // The absolute mouse position
  10774. + this.offset.relative.top * mod // Only for relative positioned nodes: Relative offset from element to offset parent
  10775. + this.offset.parent.top * mod // The offsetParent's offset without borders (offset + border)
  10776. - ( ( this.cssPosition == 'fixed' ? -this.scrollParent.scrollTop() : ( scrollIsRootNode ? 0 : scroll.scrollTop() ) ) * mod)
  10777. ),
  10778. left: (
  10779. pos.left // The absolute mouse position
  10780. + this.offset.relative.left * mod // Only for relative positioned nodes: Relative offset from element to offset parent
  10781. + this.offset.parent.left * mod // The offsetParent's offset without borders (offset + border)
  10782. - ( ( this.cssPosition == 'fixed' ? -this.scrollParent.scrollLeft() : scrollIsRootNode ? 0 : scroll.scrollLeft() ) * mod)
  10783. )
  10784. };
  10785. },
  10786. _generatePosition: function(event) {
  10787. var o = this.options, 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);
  10788. // This is another very weird special case that only happens for relative elements:
  10789. // 1. If the css position is relative
  10790. // 2. and the scroll parent is the document or similar to the offset parent
  10791. // we have to refresh the relative offset during the scroll so there are no jumps
  10792. if(this.cssPosition == 'relative' && !(this.scrollParent[0] != document && this.scrollParent[0] != this.offsetParent[0])) {
  10793. this.offset.relative = this._getRelativeOffset();
  10794. }
  10795. var pageX = event.pageX;
  10796. var pageY = event.pageY;
  10797. /*
  10798. * - Position constraining -
  10799. * Constrain the position to a mix of grid, containment.
  10800. */
  10801. if(this.originalPosition) { //If we are not dragging yet, we won't check for options
  10802. if(this.containment) {
  10803. if(event.pageX - this.offset.click.left < this.containment[0]) pageX = this.containment[0] + this.offset.click.left;
  10804. if(event.pageY - this.offset.click.top < this.containment[1]) pageY = this.containment[1] + this.offset.click.top;
  10805. if(event.pageX - this.offset.click.left > this.containment[2]) pageX = this.containment[2] + this.offset.click.left;
  10806. if(event.pageY - this.offset.click.top > this.containment[3]) pageY = this.containment[3] + this.offset.click.top;
  10807. }
  10808. if(o.grid) {
  10809. var top = this.originalPageY + Math.round((pageY - this.originalPageY) / o.grid[1]) * o.grid[1];
  10810. 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;
  10811. var left = this.originalPageX + Math.round((pageX - this.originalPageX) / o.grid[0]) * o.grid[0];
  10812. 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;
  10813. }
  10814. }
  10815. return {
  10816. top: (
  10817. pageY // The absolute mouse position
  10818. - this.offset.click.top // Click offset (relative to the element)
  10819. - this.offset.relative.top // Only for relative positioned nodes: Relative offset from element to offset parent
  10820. - this.offset.parent.top // The offsetParent's offset without borders (offset + border)
  10821. + ( ( this.cssPosition == 'fixed' ? -this.scrollParent.scrollTop() : ( scrollIsRootNode ? 0 : scroll.scrollTop() ) ))
  10822. ),
  10823. left: (
  10824. pageX // The absolute mouse position
  10825. - this.offset.click.left // Click offset (relative to the element)
  10826. - this.offset.relative.left // Only for relative positioned nodes: Relative offset from element to offset parent
  10827. - this.offset.parent.left // The offsetParent's offset without borders (offset + border)
  10828. + ( ( this.cssPosition == 'fixed' ? -this.scrollParent.scrollLeft() : scrollIsRootNode ? 0 : scroll.scrollLeft() ))
  10829. )
  10830. };
  10831. },
  10832. _rearrange: function(event, i, a, hardRefresh) {
  10833. 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));
  10834. //Various things done here to improve the performance:
  10835. // 1. we create a setTimeout, that calls refreshPositions
  10836. // 2. on the instance, we have a counter variable, that get's higher after every append
  10837. // 3. on the local scope, we copy the counter variable, and check in the timeout, if it's still the same
  10838. // 4. this lets only the last addition to the timeout stack through
  10839. this.counter = this.counter ? ++this.counter : 1;
  10840. var counter = this.counter;
  10841. this._delay(function() {
  10842. if(counter == this.counter) this.refreshPositions(!hardRefresh); //Precompute after each DOM insertion, NOT on mousemove
  10843. });
  10844. },
  10845. _clear: function(event, noPropagation) {
  10846. this.reverting = false;
  10847. // We delay all events that have to be triggered to after the point where the placeholder has been removed and
  10848. // everything else normalized again
  10849. var delayedTriggers = [];
  10850. // We first have to update the dom position of the actual currentItem
  10851. // Note: don't do it if the current item is already removed (by a user), or it gets reappended (see #4088)
  10852. if(!this._noFinalSort && this.currentItem.parent().length) this.placeholder.before(this.currentItem);
  10853. this._noFinalSort = null;
  10854. if(this.helper[0] == this.currentItem[0]) {
  10855. for(var i in this._storedCSS) {
  10856. if(this._storedCSS[i] == 'auto' || this._storedCSS[i] == 'static') this._storedCSS[i] = '';
  10857. }
  10858. this.currentItem.css(this._storedCSS).removeClass("ui-sortable-helper");
  10859. } else {
  10860. this.currentItem.show();
  10861. }
  10862. if(this.fromOutside && !noPropagation) delayedTriggers.push(function(event) { this._trigger("receive", event, this._uiHash(this.fromOutside)); });
  10863. if((this.fromOutside || this.domPosition.prev != this.currentItem.prev().not(".ui-sortable-helper")[0] || this.domPosition.parent != this.currentItem.parent()[0]) && !noPropagation) delayedTriggers.push(function(event) { this._trigger("update", event, this._uiHash()); }); //Trigger update callback if the DOM position has changed
  10864. // Check if the items Container has Changed and trigger appropriate
  10865. // events.
  10866. if (this !== this.currentContainer) {
  10867. if(!noPropagation) {
  10868. delayedTriggers.push(function(event) { this._trigger("remove", event, this._uiHash()); });
  10869. delayedTriggers.push((function(c) { return function(event) { c._trigger("receive", event, this._uiHash(this)); }; }).call(this, this.currentContainer));
  10870. delayedTriggers.push((function(c) { return function(event) { c._trigger("update", event, this._uiHash(this)); }; }).call(this, this.currentContainer));
  10871. }
  10872. }
  10873. //Post events to containers
  10874. for (var i = this.containers.length - 1; i >= 0; i--){
  10875. if(!noPropagation) delayedTriggers.push((function(c) { return function(event) { c._trigger("deactivate", event, this._uiHash(this)); }; }).call(this, this.containers[i]));
  10876. if(this.containers[i].containerCache.over) {
  10877. delayedTriggers.push((function(c) { return function(event) { c._trigger("out", event, this._uiHash(this)); }; }).call(this, this.containers[i]));
  10878. this.containers[i].containerCache.over = 0;
  10879. }
  10880. }
  10881. //Do what was originally in plugins
  10882. if(this._storedCursor) $('body').css("cursor", this._storedCursor); //Reset cursor
  10883. if(this._storedOpacity) this.helper.css("opacity", this._storedOpacity); //Reset opacity
  10884. if(this._storedZIndex) this.helper.css("zIndex", this._storedZIndex == 'auto' ? '' : this._storedZIndex); //Reset z-index
  10885. this.dragging = false;
  10886. if(this.cancelHelperRemoval) {
  10887. if(!noPropagation) {
  10888. this._trigger("beforeStop", event, this._uiHash());
  10889. for (var i=0; i < delayedTriggers.length; i++) { delayedTriggers[i].call(this, event); }; //Trigger all delayed events
  10890. this._trigger("stop", event, this._uiHash());
  10891. }
  10892. this.fromOutside = false;
  10893. return false;
  10894. }
  10895. if(!noPropagation) this._trigger("beforeStop", event, this._uiHash());
  10896. //$(this.placeholder[0]).remove(); would have been the jQuery way - unfortunately, it unbinds ALL events from the original node!
  10897. this.placeholder[0].parentNode.removeChild(this.placeholder[0]);
  10898. if(this.helper[0] != this.currentItem[0]) this.helper.remove(); this.helper = null;
  10899. if(!noPropagation) {
  10900. for (var i=0; i < delayedTriggers.length; i++) { delayedTriggers[i].call(this, event); }; //Trigger all delayed events
  10901. this._trigger("stop", event, this._uiHash());
  10902. }
  10903. this.fromOutside = false;
  10904. return true;
  10905. },
  10906. _trigger: function() {
  10907. if ($.Widget.prototype._trigger.apply(this, arguments) === false) {
  10908. this.cancel();
  10909. }
  10910. },
  10911. _uiHash: function(_inst) {
  10912. var inst = _inst || this;
  10913. return {
  10914. helper: inst.helper,
  10915. placeholder: inst.placeholder || $([]),
  10916. position: inst.position,
  10917. originalPosition: inst.originalPosition,
  10918. offset: inst.positionAbs,
  10919. item: inst.currentItem,
  10920. sender: _inst ? _inst.element : null
  10921. };
  10922. }
  10923. });
  10924. })(jQuery);
  10925. (function( $ ) {
  10926. function modifier( fn ) {
  10927. return function() {
  10928. var previous = this.element.val();
  10929. fn.apply( this, arguments );
  10930. this._refresh();
  10931. if ( previous !== this.element.val() ) {
  10932. this._trigger( "change" );
  10933. }
  10934. };
  10935. }
  10936. $.widget( "ui.spinner", {
  10937. version: "1.9.2",
  10938. defaultElement: "<input>",
  10939. widgetEventPrefix: "spin",
  10940. options: {
  10941. culture: null,
  10942. icons: {
  10943. down: "ui-icon-triangle-1-s",
  10944. up: "ui-icon-triangle-1-n"
  10945. },
  10946. incremental: true,
  10947. max: null,
  10948. min: null,
  10949. numberFormat: null,
  10950. page: 10,
  10951. step: 1,
  10952. change: null,
  10953. spin: null,
  10954. start: null,
  10955. stop: null
  10956. },
  10957. _create: function() {
  10958. // handle string values that need to be parsed
  10959. this._setOption( "max", this.options.max );
  10960. this._setOption( "min", this.options.min );
  10961. this._setOption( "step", this.options.step );
  10962. // format the value, but don't constrain
  10963. this._value( this.element.val(), true );
  10964. this._draw();
  10965. this._on( this._events );
  10966. this._refresh();
  10967. // turning off autocomplete prevents the browser from remembering the
  10968. // value when navigating through history, so we re-enable autocomplete
  10969. // if the page is unloaded before the widget is destroyed. #7790
  10970. this._on( this.window, {
  10971. beforeunload: function() {
  10972. this.element.removeAttr( "autocomplete" );
  10973. }
  10974. });
  10975. },
  10976. _getCreateOptions: function() {
  10977. var options = {},
  10978. element = this.element;
  10979. $.each( [ "min", "max", "step" ], function( i, option ) {
  10980. var value = element.attr( option );
  10981. if ( value !== undefined && value.length ) {
  10982. options[ option ] = value;
  10983. }
  10984. });
  10985. return options;
  10986. },
  10987. _events: {
  10988. keydown: function( event ) {
  10989. if ( this._start( event ) && this._keydown( event ) ) {
  10990. event.preventDefault();
  10991. }
  10992. },
  10993. keyup: "_stop",
  10994. focus: function() {
  10995. this.previous = this.element.val();
  10996. },
  10997. blur: function( event ) {
  10998. if ( this.cancelBlur ) {
  10999. delete this.cancelBlur;
  11000. return;
  11001. }
  11002. this._refresh();
  11003. if ( this.previous !== this.element.val() ) {
  11004. this._trigger( "change", event );
  11005. }
  11006. },
  11007. mousewheel: function( event, delta ) {
  11008. if ( !delta ) {
  11009. return;
  11010. }
  11011. if ( !this.spinning && !this._start( event ) ) {
  11012. return false;
  11013. }
  11014. this._spin( (delta > 0 ? 1 : -1) * this.options.step, event );
  11015. clearTimeout( this.mousewheelTimer );
  11016. this.mousewheelTimer = this._delay(function() {
  11017. if ( this.spinning ) {
  11018. this._stop( event );
  11019. }
  11020. }, 100 );
  11021. event.preventDefault();
  11022. },
  11023. "mousedown .ui-spinner-button": function( event ) {
  11024. var previous;
  11025. // We never want the buttons to have focus; whenever the user is
  11026. // interacting with the spinner, the focus should be on the input.
  11027. // If the input is focused then this.previous is properly set from
  11028. // when the input first received focus. If the input is not focused
  11029. // then we need to set this.previous based on the value before spinning.
  11030. previous = this.element[0] === this.document[0].activeElement ?
  11031. this.previous : this.element.val();
  11032. function checkFocus() {
  11033. var isActive = this.element[0] === this.document[0].activeElement;
  11034. if ( !isActive ) {
  11035. this.element.focus();
  11036. this.previous = previous;
  11037. // support: IE
  11038. // IE sets focus asynchronously, so we need to check if focus
  11039. // moved off of the input because the user clicked on the button.
  11040. this._delay(function() {
  11041. this.previous = previous;
  11042. });
  11043. }
  11044. }
  11045. // ensure focus is on (or stays on) the text field
  11046. event.preventDefault();
  11047. checkFocus.call( this );
  11048. // support: IE
  11049. // IE doesn't prevent moving focus even with event.preventDefault()
  11050. // so we set a flag to know when we should ignore the blur event
  11051. // and check (again) if focus moved off of the input.
  11052. this.cancelBlur = true;
  11053. this._delay(function() {
  11054. delete this.cancelBlur;
  11055. checkFocus.call( this );
  11056. });
  11057. if ( this._start( event ) === false ) {
  11058. return;
  11059. }
  11060. this._repeat( null, $( event.currentTarget ).hasClass( "ui-spinner-up" ) ? 1 : -1, event );
  11061. },
  11062. "mouseup .ui-spinner-button": "_stop",
  11063. "mouseenter .ui-spinner-button": function( event ) {
  11064. // button will add ui-state-active if mouse was down while mouseleave and kept down
  11065. if ( !$( event.currentTarget ).hasClass( "ui-state-active" ) ) {
  11066. return;
  11067. }
  11068. if ( this._start( event ) === false ) {
  11069. return false;
  11070. }
  11071. this._repeat( null, $( event.currentTarget ).hasClass( "ui-spinner-up" ) ? 1 : -1, event );
  11072. },
  11073. // TODO: do we really want to consider this a stop?
  11074. // shouldn't we just stop the repeater and wait until mouseup before
  11075. // we trigger the stop event?
  11076. "mouseleave .ui-spinner-button": "_stop"
  11077. },
  11078. _draw: function() {
  11079. var uiSpinner = this.uiSpinner = this.element
  11080. .addClass( "ui-spinner-input" )
  11081. .attr( "autocomplete", "off" )
  11082. .wrap( this._uiSpinnerHtml() )
  11083. .parent()
  11084. // add buttons
  11085. .append( this._buttonHtml() );
  11086. this.element.attr( "role", "spinbutton" );
  11087. // button bindings
  11088. this.buttons = uiSpinner.find( ".ui-spinner-button" )
  11089. .attr( "tabIndex", -1 )
  11090. .button()
  11091. .removeClass( "ui-corner-all" );
  11092. // IE 6 doesn't understand height: 50% for the buttons
  11093. // unless the wrapper has an explicit height
  11094. if ( this.buttons.height() > Math.ceil( uiSpinner.height() * 0.5 ) &&
  11095. uiSpinner.height() > 0 ) {
  11096. uiSpinner.height( uiSpinner.height() );
  11097. }
  11098. // disable spinner if element was already disabled
  11099. if ( this.options.disabled ) {
  11100. this.disable();
  11101. }
  11102. },
  11103. _keydown: function( event ) {
  11104. var options = this.options,
  11105. keyCode = $.ui.keyCode;
  11106. switch ( event.keyCode ) {
  11107. case keyCode.UP:
  11108. this._repeat( null, 1, event );
  11109. return true;
  11110. case keyCode.DOWN:
  11111. this._repeat( null, -1, event );
  11112. return true;
  11113. case keyCode.PAGE_UP:
  11114. this._repeat( null, options.page, event );
  11115. return true;
  11116. case keyCode.PAGE_DOWN:
  11117. this._repeat( null, -options.page, event );
  11118. return true;
  11119. }
  11120. return false;
  11121. },
  11122. _uiSpinnerHtml: function() {
  11123. return "<span class='ui-spinner ui-widget ui-widget-content ui-corner-all'></span>";
  11124. },
  11125. _buttonHtml: function() {
  11126. return "" +
  11127. "<a class='ui-spinner-button ui-spinner-up ui-corner-tr'>" +
  11128. "<span class='ui-icon " + this.options.icons.up + "'>&#9650;</span>" +
  11129. "</a>" +
  11130. "<a class='ui-spinner-button ui-spinner-down ui-corner-br'>" +
  11131. "<span class='ui-icon " + this.options.icons.down + "'>&#9660;</span>" +
  11132. "</a>";
  11133. },
  11134. _start: function( event ) {
  11135. if ( !this.spinning && this._trigger( "start", event ) === false ) {
  11136. return false;
  11137. }
  11138. if ( !this.counter ) {
  11139. this.counter = 1;
  11140. }
  11141. this.spinning = true;
  11142. return true;
  11143. },
  11144. _repeat: function( i, steps, event ) {
  11145. i = i || 500;
  11146. clearTimeout( this.timer );
  11147. this.timer = this._delay(function() {
  11148. this._repeat( 40, steps, event );
  11149. }, i );
  11150. this._spin( steps * this.options.step, event );
  11151. },
  11152. _spin: function( step, event ) {
  11153. var value = this.value() || 0;
  11154. if ( !this.counter ) {
  11155. this.counter = 1;
  11156. }
  11157. value = this._adjustValue( value + step * this._increment( this.counter ) );
  11158. if ( !this.spinning || this._trigger( "spin", event, { value: value } ) !== false) {
  11159. this._value( value );
  11160. this.counter++;
  11161. }
  11162. },
  11163. _increment: function( i ) {
  11164. var incremental = this.options.incremental;
  11165. if ( incremental ) {
  11166. return $.isFunction( incremental ) ?
  11167. incremental( i ) :
  11168. Math.floor( i*i*i/50000 - i*i/500 + 17*i/200 + 1 );
  11169. }
  11170. return 1;
  11171. },
  11172. _precision: function() {
  11173. var precision = this._precisionOf( this.options.step );
  11174. if ( this.options.min !== null ) {
  11175. precision = Math.max( precision, this._precisionOf( this.options.min ) );
  11176. }
  11177. return precision;
  11178. },
  11179. _precisionOf: function( num ) {
  11180. var str = num.toString(),
  11181. decimal = str.indexOf( "." );
  11182. return decimal === -1 ? 0 : str.length - decimal - 1;
  11183. },
  11184. _adjustValue: function( value ) {
  11185. var base, aboveMin,
  11186. options = this.options;
  11187. // make sure we're at a valid step
  11188. // - find out where we are relative to the base (min or 0)
  11189. base = options.min !== null ? options.min : 0;
  11190. aboveMin = value - base;
  11191. // - round to the nearest step
  11192. aboveMin = Math.round(aboveMin / options.step) * options.step;
  11193. // - rounding is based on 0, so adjust back to our base
  11194. value = base + aboveMin;
  11195. // fix precision from bad JS floating point math
  11196. value = parseFloat( value.toFixed( this._precision() ) );
  11197. // clamp the value
  11198. if ( options.max !== null && value > options.max) {
  11199. return options.max;
  11200. }
  11201. if ( options.min !== null && value < options.min ) {
  11202. return options.min;
  11203. }
  11204. return value;
  11205. },
  11206. _stop: function( event ) {
  11207. if ( !this.spinning ) {
  11208. return;
  11209. }
  11210. clearTimeout( this.timer );
  11211. clearTimeout( this.mousewheelTimer );
  11212. this.counter = 0;
  11213. this.spinning = false;
  11214. this._trigger( "stop", event );
  11215. },
  11216. _setOption: function( key, value ) {
  11217. if ( key === "culture" || key === "numberFormat" ) {
  11218. var prevValue = this._parse( this.element.val() );
  11219. this.options[ key ] = value;
  11220. this.element.val( this._format( prevValue ) );
  11221. return;
  11222. }
  11223. if ( key === "max" || key === "min" || key === "step" ) {
  11224. if ( typeof value === "string" ) {
  11225. value = this._parse( value );
  11226. }
  11227. }
  11228. this._super( key, value );
  11229. if ( key === "disabled" ) {
  11230. if ( value ) {
  11231. this.element.prop( "disabled", true );
  11232. this.buttons.button( "disable" );
  11233. } else {
  11234. this.element.prop( "disabled", false );
  11235. this.buttons.button( "enable" );
  11236. }
  11237. }
  11238. },
  11239. _setOptions: modifier(function( options ) {
  11240. this._super( options );
  11241. this._value( this.element.val() );
  11242. }),
  11243. _parse: function( val ) {
  11244. if ( typeof val === "string" && val !== "" ) {
  11245. val = window.Globalize && this.options.numberFormat ?
  11246. Globalize.parseFloat( val, 10, this.options.culture ) : +val;
  11247. }
  11248. return val === "" || isNaN( val ) ? null : val;
  11249. },
  11250. _format: function( value ) {
  11251. if ( value === "" ) {
  11252. return "";
  11253. }
  11254. return window.Globalize && this.options.numberFormat ?
  11255. Globalize.format( value, this.options.numberFormat, this.options.culture ) :
  11256. value;
  11257. },
  11258. _refresh: function() {
  11259. this.element.attr({
  11260. "aria-valuemin": this.options.min,
  11261. "aria-valuemax": this.options.max,
  11262. // TODO: what should we do with values that can't be parsed?
  11263. "aria-valuenow": this._parse( this.element.val() )
  11264. });
  11265. },
  11266. // update the value without triggering change
  11267. _value: function( value, allowAny ) {
  11268. var parsed;
  11269. if ( value !== "" ) {
  11270. parsed = this._parse( value );
  11271. if ( parsed !== null ) {
  11272. if ( !allowAny ) {
  11273. parsed = this._adjustValue( parsed );
  11274. }
  11275. value = this._format( parsed );
  11276. }
  11277. }
  11278. this.element.val( value );
  11279. this._refresh();
  11280. },
  11281. _destroy: function() {
  11282. this.element
  11283. .removeClass( "ui-spinner-input" )
  11284. .prop( "disabled", false )
  11285. .removeAttr( "autocomplete" )
  11286. .removeAttr( "role" )
  11287. .removeAttr( "aria-valuemin" )
  11288. .removeAttr( "aria-valuemax" )
  11289. .removeAttr( "aria-valuenow" );
  11290. this.uiSpinner.replaceWith( this.element );
  11291. },
  11292. stepUp: modifier(function( steps ) {
  11293. this._stepUp( steps );
  11294. }),
  11295. _stepUp: function( steps ) {
  11296. this._spin( (steps || 1) * this.options.step );
  11297. },
  11298. stepDown: modifier(function( steps ) {
  11299. this._stepDown( steps );
  11300. }),
  11301. _stepDown: function( steps ) {
  11302. this._spin( (steps || 1) * -this.options.step );
  11303. },
  11304. pageUp: modifier(function( pages ) {
  11305. this._stepUp( (pages || 1) * this.options.page );
  11306. }),
  11307. pageDown: modifier(function( pages ) {
  11308. this._stepDown( (pages || 1) * this.options.page );
  11309. }),
  11310. value: function( newVal ) {
  11311. if ( !arguments.length ) {
  11312. return this._parse( this.element.val() );
  11313. }
  11314. modifier( this._value ).call( this, newVal );
  11315. },
  11316. widget: function() {
  11317. return this.uiSpinner;
  11318. }
  11319. });
  11320. }( jQuery ) );
  11321. (function( $, undefined ) {
  11322. var tabId = 0,
  11323. rhash = /#.*$/;
  11324. function getNextTabId() {
  11325. return ++tabId;
  11326. }
  11327. function isLocal( anchor ) {
  11328. return anchor.hash.length > 1 &&
  11329. anchor.href.replace( rhash, "" ) ===
  11330. location.href.replace( rhash, "" )
  11331. // support: Safari 5.1
  11332. // Safari 5.1 doesn't encode spaces in window.location
  11333. // but it does encode spaces from anchors (#8777)
  11334. .replace( /\s/g, "%20" );
  11335. }
  11336. $.widget( "ui.tabs", {
  11337. version: "1.9.2",
  11338. delay: 300,
  11339. options: {
  11340. active: null,
  11341. collapsible: false,
  11342. event: "click",
  11343. heightStyle: "content",
  11344. hide: null,
  11345. show: null,
  11346. // callbacks
  11347. activate: null,
  11348. beforeActivate: null,
  11349. beforeLoad: null,
  11350. load: null
  11351. },
  11352. _create: function() {
  11353. var that = this,
  11354. options = this.options,
  11355. active = options.active,
  11356. locationHash = location.hash.substring( 1 );
  11357. this.running = false;
  11358. this.element
  11359. .addClass( "ui-tabs ui-widget ui-widget-content ui-corner-all" )
  11360. .toggleClass( "ui-tabs-collapsible", options.collapsible )
  11361. // Prevent users from focusing disabled tabs via click
  11362. .delegate( ".ui-tabs-nav > li", "mousedown" + this.eventNamespace, function( event ) {
  11363. if ( $( this ).is( ".ui-state-disabled" ) ) {
  11364. event.preventDefault();
  11365. }
  11366. })
  11367. // support: IE <9
  11368. // Preventing the default action in mousedown doesn't prevent IE
  11369. // from focusing the element, so if the anchor gets focused, blur.
  11370. // We don't have to worry about focusing the previously focused
  11371. // element since clicking on a non-focusable element should focus
  11372. // the body anyway.
  11373. .delegate( ".ui-tabs-anchor", "focus" + this.eventNamespace, function() {
  11374. if ( $( this ).closest( "li" ).is( ".ui-state-disabled" ) ) {
  11375. this.blur();
  11376. }
  11377. });
  11378. this._processTabs();
  11379. if ( active === null ) {
  11380. // check the fragment identifier in the URL
  11381. if ( locationHash ) {
  11382. this.tabs.each(function( i, tab ) {
  11383. if ( $( tab ).attr( "aria-controls" ) === locationHash ) {
  11384. active = i;
  11385. return false;
  11386. }
  11387. });
  11388. }
  11389. // check for a tab marked active via a class
  11390. if ( active === null ) {
  11391. active = this.tabs.index( this.tabs.filter( ".ui-tabs-active" ) );
  11392. }
  11393. // no active tab, set to false
  11394. if ( active === null || active === -1 ) {
  11395. active = this.tabs.length ? 0 : false;
  11396. }
  11397. }
  11398. // handle numbers: negative, out of range
  11399. if ( active !== false ) {
  11400. active = this.tabs.index( this.tabs.eq( active ) );
  11401. if ( active === -1 ) {
  11402. active = options.collapsible ? false : 0;
  11403. }
  11404. }
  11405. options.active = active;
  11406. // don't allow collapsible: false and active: false
  11407. if ( !options.collapsible && options.active === false && this.anchors.length ) {
  11408. options.active = 0;
  11409. }
  11410. // Take disabling tabs via class attribute from HTML
  11411. // into account and update option properly.
  11412. if ( $.isArray( options.disabled ) ) {
  11413. options.disabled = $.unique( options.disabled.concat(
  11414. $.map( this.tabs.filter( ".ui-state-disabled" ), function( li ) {
  11415. return that.tabs.index( li );
  11416. })
  11417. ) ).sort();
  11418. }
  11419. // check for length avoids error when initializing empty list
  11420. if ( this.options.active !== false && this.anchors.length ) {
  11421. this.active = this._findActive( this.options.active );
  11422. } else {
  11423. this.active = $();
  11424. }
  11425. this._refresh();
  11426. if ( this.active.length ) {
  11427. this.load( options.active );
  11428. }
  11429. },
  11430. _getCreateEventData: function() {
  11431. return {
  11432. tab: this.active,
  11433. panel: !this.active.length ? $() : this._getPanelForTab( this.active )
  11434. };
  11435. },
  11436. _tabKeydown: function( event ) {
  11437. var focusedTab = $( this.document[0].activeElement ).closest( "li" ),
  11438. selectedIndex = this.tabs.index( focusedTab ),
  11439. goingForward = true;
  11440. if ( this._handlePageNav( event ) ) {
  11441. return;
  11442. }
  11443. switch ( event.keyCode ) {
  11444. case $.ui.keyCode.RIGHT:
  11445. case $.ui.keyCode.DOWN:
  11446. selectedIndex++;
  11447. break;
  11448. case $.ui.keyCode.UP:
  11449. case $.ui.keyCode.LEFT:
  11450. goingForward = false;
  11451. selectedIndex--;
  11452. break;
  11453. case $.ui.keyCode.END:
  11454. selectedIndex = this.anchors.length - 1;
  11455. break;
  11456. case $.ui.keyCode.HOME:
  11457. selectedIndex = 0;
  11458. break;
  11459. case $.ui.keyCode.SPACE:
  11460. // Activate only, no collapsing
  11461. event.preventDefault();
  11462. clearTimeout( this.activating );
  11463. this._activate( selectedIndex );
  11464. return;
  11465. case $.ui.keyCode.ENTER:
  11466. // Toggle (cancel delayed activation, allow collapsing)
  11467. event.preventDefault();
  11468. clearTimeout( this.activating );
  11469. // Determine if we should collapse or activate
  11470. this._activate( selectedIndex === this.options.active ? false : selectedIndex );
  11471. return;
  11472. default:
  11473. return;
  11474. }
  11475. // Focus the appropriate tab, based on which key was pressed
  11476. event.preventDefault();
  11477. clearTimeout( this.activating );
  11478. selectedIndex = this._focusNextTab( selectedIndex, goingForward );
  11479. // Navigating with control key will prevent automatic activation
  11480. if ( !event.ctrlKey ) {
  11481. // Update aria-selected immediately so that AT think the tab is already selected.
  11482. // Otherwise AT may confuse the user by stating that they need to activate the tab,
  11483. // but the tab will already be activated by the time the announcement finishes.
  11484. focusedTab.attr( "aria-selected", "false" );
  11485. this.tabs.eq( selectedIndex ).attr( "aria-selected", "true" );
  11486. this.activating = this._delay(function() {
  11487. this.option( "active", selectedIndex );
  11488. }, this.delay );
  11489. }
  11490. },
  11491. _panelKeydown: function( event ) {
  11492. if ( this._handlePageNav( event ) ) {
  11493. return;
  11494. }
  11495. // Ctrl+up moves focus to the current tab
  11496. if ( event.ctrlKey && event.keyCode === $.ui.keyCode.UP ) {
  11497. event.preventDefault();
  11498. this.active.focus();
  11499. }
  11500. },
  11501. // Alt+page up/down moves focus to the previous/next tab (and activates)
  11502. _handlePageNav: function( event ) {
  11503. if ( event.altKey && event.keyCode === $.ui.keyCode.PAGE_UP ) {
  11504. this._activate( this._focusNextTab( this.options.active - 1, false ) );
  11505. return true;
  11506. }
  11507. if ( event.altKey && event.keyCode === $.ui.keyCode.PAGE_DOWN ) {
  11508. this._activate( this._focusNextTab( this.options.active + 1, true ) );
  11509. return true;
  11510. }
  11511. },
  11512. _findNextTab: function( index, goingForward ) {
  11513. var lastTabIndex = this.tabs.length - 1;
  11514. function constrain() {
  11515. if ( index > lastTabIndex ) {
  11516. index = 0;
  11517. }
  11518. if ( index < 0 ) {
  11519. index = lastTabIndex;
  11520. }
  11521. return index;
  11522. }
  11523. while ( $.inArray( constrain(), this.options.disabled ) !== -1 ) {
  11524. index = goingForward ? index + 1 : index - 1;
  11525. }
  11526. return index;
  11527. },
  11528. _focusNextTab: function( index, goingForward ) {
  11529. index = this._findNextTab( index, goingForward );
  11530. this.tabs.eq( index ).focus();
  11531. return index;
  11532. },
  11533. _setOption: function( key, value ) {
  11534. if ( key === "active" ) {
  11535. // _activate() will handle invalid values and update this.options
  11536. this._activate( value );
  11537. return;
  11538. }
  11539. if ( key === "disabled" ) {
  11540. // don't use the widget factory's disabled handling
  11541. this._setupDisabled( value );
  11542. return;
  11543. }
  11544. this._super( key, value);
  11545. if ( key === "collapsible" ) {
  11546. this.element.toggleClass( "ui-tabs-collapsible", value );
  11547. // Setting collapsible: false while collapsed; open first panel
  11548. if ( !value && this.options.active === false ) {
  11549. this._activate( 0 );
  11550. }
  11551. }
  11552. if ( key === "event" ) {
  11553. this._setupEvents( value );
  11554. }
  11555. if ( key === "heightStyle" ) {
  11556. this._setupHeightStyle( value );
  11557. }
  11558. },
  11559. _tabId: function( tab ) {
  11560. return tab.attr( "aria-controls" ) || "ui-tabs-" + getNextTabId();
  11561. },
  11562. _sanitizeSelector: function( hash ) {
  11563. return hash ? hash.replace( /[!"$%&'()*+,.\/:;<=>?@\[\]\^`{|}~]/g, "\\$&" ) : "";
  11564. },
  11565. refresh: function() {
  11566. var options = this.options,
  11567. lis = this.tablist.children( ":has(a[href])" );
  11568. // get disabled tabs from class attribute from HTML
  11569. // this will get converted to a boolean if needed in _refresh()
  11570. options.disabled = $.map( lis.filter( ".ui-state-disabled" ), function( tab ) {
  11571. return lis.index( tab );
  11572. });
  11573. this._processTabs();
  11574. // was collapsed or no tabs
  11575. if ( options.active === false || !this.anchors.length ) {
  11576. options.active = false;
  11577. this.active = $();
  11578. // was active, but active tab is gone
  11579. } else if ( this.active.length && !$.contains( this.tablist[ 0 ], this.active[ 0 ] ) ) {
  11580. // all remaining tabs are disabled
  11581. if ( this.tabs.length === options.disabled.length ) {
  11582. options.active = false;
  11583. this.active = $();
  11584. // activate previous tab
  11585. } else {
  11586. this._activate( this._findNextTab( Math.max( 0, options.active - 1 ), false ) );
  11587. }
  11588. // was active, active tab still exists
  11589. } else {
  11590. // make sure active index is correct
  11591. options.active = this.tabs.index( this.active );
  11592. }
  11593. this._refresh();
  11594. },
  11595. _refresh: function() {
  11596. this._setupDisabled( this.options.disabled );
  11597. this._setupEvents( this.options.event );
  11598. this._setupHeightStyle( this.options.heightStyle );
  11599. this.tabs.not( this.active ).attr({
  11600. "aria-selected": "false",
  11601. tabIndex: -1
  11602. });
  11603. this.panels.not( this._getPanelForTab( this.active ) )
  11604. .hide()
  11605. .attr({
  11606. "aria-expanded": "false",
  11607. "aria-hidden": "true"
  11608. });
  11609. // Make sure one tab is in the tab order
  11610. if ( !this.active.length ) {
  11611. this.tabs.eq( 0 ).attr( "tabIndex", 0 );
  11612. } else {
  11613. this.active
  11614. .addClass( "ui-tabs-active ui-state-active" )
  11615. .attr({
  11616. "aria-selected": "true",
  11617. tabIndex: 0
  11618. });
  11619. this._getPanelForTab( this.active )
  11620. .show()
  11621. .attr({
  11622. "aria-expanded": "true",
  11623. "aria-hidden": "false"
  11624. });
  11625. }
  11626. },
  11627. _processTabs: function() {
  11628. var that = this;
  11629. this.tablist = this._getList()
  11630. .addClass( "ui-tabs-nav ui-helper-reset ui-helper-clearfix ui-widget-header ui-corner-all" )
  11631. .attr( "role", "tablist" );
  11632. this.tabs = this.tablist.find( "> li:has(a[href])" )
  11633. .addClass( "ui-state-default ui-corner-top" )
  11634. .attr({
  11635. role: "tab",
  11636. tabIndex: -1
  11637. });
  11638. this.anchors = this.tabs.map(function() {
  11639. return $( "a", this )[ 0 ];
  11640. })
  11641. .addClass( "ui-tabs-anchor" )
  11642. .attr({
  11643. role: "presentation",
  11644. tabIndex: -1
  11645. });
  11646. this.panels = $();
  11647. this.anchors.each(function( i, anchor ) {
  11648. var selector, panel, panelId,
  11649. anchorId = $( anchor ).uniqueId().attr( "id" ),
  11650. tab = $( anchor ).closest( "li" ),
  11651. originalAriaControls = tab.attr( "aria-controls" );
  11652. // inline tab
  11653. if ( isLocal( anchor ) ) {
  11654. selector = anchor.hash;
  11655. panel = that.element.find( that._sanitizeSelector( selector ) );
  11656. // remote tab
  11657. } else {
  11658. panelId = that._tabId( tab );
  11659. selector = "#" + panelId;
  11660. panel = that.element.find( selector );
  11661. if ( !panel.length ) {
  11662. panel = that._createPanel( panelId );
  11663. panel.insertAfter( that.panels[ i - 1 ] || that.tablist );
  11664. }
  11665. panel.attr( "aria-live", "polite" );
  11666. }
  11667. if ( panel.length) {
  11668. that.panels = that.panels.add( panel );
  11669. }
  11670. if ( originalAriaControls ) {
  11671. tab.data( "ui-tabs-aria-controls", originalAriaControls );
  11672. }
  11673. tab.attr({
  11674. "aria-controls": selector.substring( 1 ),
  11675. "aria-labelledby": anchorId
  11676. });
  11677. panel.attr( "aria-labelledby", anchorId );
  11678. });
  11679. this.panels
  11680. .addClass( "ui-tabs-panel ui-widget-content ui-corner-bottom" )
  11681. .attr( "role", "tabpanel" );
  11682. },
  11683. // allow overriding how to find the list for rare usage scenarios (#7715)
  11684. _getList: function() {
  11685. return this.element.find( "ol,ul" ).eq( 0 );
  11686. },
  11687. _createPanel: function( id ) {
  11688. return $( "<div>" )
  11689. .attr( "id", id )
  11690. .addClass( "ui-tabs-panel ui-widget-content ui-corner-bottom" )
  11691. .data( "ui-tabs-destroy", true );
  11692. },
  11693. _setupDisabled: function( disabled ) {
  11694. if ( $.isArray( disabled ) ) {
  11695. if ( !disabled.length ) {
  11696. disabled = false;
  11697. } else if ( disabled.length === this.anchors.length ) {
  11698. disabled = true;
  11699. }
  11700. }
  11701. // disable tabs
  11702. for ( var i = 0, li; ( li = this.tabs[ i ] ); i++ ) {
  11703. if ( disabled === true || $.inArray( i, disabled ) !== -1 ) {
  11704. $( li )
  11705. .addClass( "ui-state-disabled" )
  11706. .attr( "aria-disabled", "true" );
  11707. } else {
  11708. $( li )
  11709. .removeClass( "ui-state-disabled" )
  11710. .removeAttr( "aria-disabled" );
  11711. }
  11712. }
  11713. this.options.disabled = disabled;
  11714. },
  11715. _setupEvents: function( event ) {
  11716. var events = {
  11717. click: function( event ) {
  11718. event.preventDefault();
  11719. }
  11720. };
  11721. if ( event ) {
  11722. $.each( event.split(" "), function( index, eventName ) {
  11723. events[ eventName ] = "_eventHandler";
  11724. });
  11725. }
  11726. this._off( this.anchors.add( this.tabs ).add( this.panels ) );
  11727. this._on( this.anchors, events );
  11728. this._on( this.tabs, { keydown: "_tabKeydown" } );
  11729. this._on( this.panels, { keydown: "_panelKeydown" } );
  11730. this._focusable( this.tabs );
  11731. this._hoverable( this.tabs );
  11732. },
  11733. _setupHeightStyle: function( heightStyle ) {
  11734. var maxHeight, overflow,
  11735. parent = this.element.parent();
  11736. if ( heightStyle === "fill" ) {
  11737. // IE 6 treats height like minHeight, so we need to turn off overflow
  11738. // in order to get a reliable height
  11739. // we use the minHeight support test because we assume that only
  11740. // browsers that don't support minHeight will treat height as minHeight
  11741. if ( !$.support.minHeight ) {
  11742. overflow = parent.css( "overflow" );
  11743. parent.css( "overflow", "hidden");
  11744. }
  11745. maxHeight = parent.height();
  11746. this.element.siblings( ":visible" ).each(function() {
  11747. var elem = $( this ),
  11748. position = elem.css( "position" );
  11749. if ( position === "absolute" || position === "fixed" ) {
  11750. return;
  11751. }
  11752. maxHeight -= elem.outerHeight( true );
  11753. });
  11754. if ( overflow ) {
  11755. parent.css( "overflow", overflow );
  11756. }
  11757. this.element.children().not( this.panels ).each(function() {
  11758. maxHeight -= $( this ).outerHeight( true );
  11759. });
  11760. this.panels.each(function() {
  11761. $( this ).height( Math.max( 0, maxHeight -
  11762. $( this ).innerHeight() + $( this ).height() ) );
  11763. })
  11764. .css( "overflow", "auto" );
  11765. } else if ( heightStyle === "auto" ) {
  11766. maxHeight = 0;
  11767. this.panels.each(function() {
  11768. maxHeight = Math.max( maxHeight, $( this ).height( "" ).height() );
  11769. }).height( maxHeight );
  11770. }
  11771. },
  11772. _eventHandler: function( event ) {
  11773. var options = this.options,
  11774. active = this.active,
  11775. anchor = $( event.currentTarget ),
  11776. tab = anchor.closest( "li" ),
  11777. clickedIsActive = tab[ 0 ] === active[ 0 ],
  11778. collapsing = clickedIsActive && options.collapsible,
  11779. toShow = collapsing ? $() : this._getPanelForTab( tab ),
  11780. toHide = !active.length ? $() : this._getPanelForTab( active ),
  11781. eventData = {
  11782. oldTab: active,
  11783. oldPanel: toHide,
  11784. newTab: collapsing ? $() : tab,
  11785. newPanel: toShow
  11786. };
  11787. event.preventDefault();
  11788. if ( tab.hasClass( "ui-state-disabled" ) ||
  11789. // tab is already loading
  11790. tab.hasClass( "ui-tabs-loading" ) ||
  11791. // can't switch durning an animation
  11792. this.running ||
  11793. // click on active header, but not collapsible
  11794. ( clickedIsActive && !options.collapsible ) ||
  11795. // allow canceling activation
  11796. ( this._trigger( "beforeActivate", event, eventData ) === false ) ) {
  11797. return;
  11798. }
  11799. options.active = collapsing ? false : this.tabs.index( tab );
  11800. this.active = clickedIsActive ? $() : tab;
  11801. if ( this.xhr ) {
  11802. this.xhr.abort();
  11803. }
  11804. if ( !toHide.length && !toShow.length ) {
  11805. $.error( "jQuery UI Tabs: Mismatching fragment identifier." );
  11806. }
  11807. if ( toShow.length ) {
  11808. this.load( this.tabs.index( tab ), event );
  11809. }
  11810. this._toggle( event, eventData );
  11811. },
  11812. // handles show/hide for selecting tabs
  11813. _toggle: function( event, eventData ) {
  11814. var that = this,
  11815. toShow = eventData.newPanel,
  11816. toHide = eventData.oldPanel;
  11817. this.running = true;
  11818. function complete() {
  11819. that.running = false;
  11820. that._trigger( "activate", event, eventData );
  11821. }
  11822. function show() {
  11823. eventData.newTab.closest( "li" ).addClass( "ui-tabs-active ui-state-active" );
  11824. if ( toShow.length && that.options.show ) {
  11825. that._show( toShow, that.options.show, complete );
  11826. } else {
  11827. toShow.show();
  11828. complete();
  11829. }
  11830. }
  11831. // start out by hiding, then showing, then completing
  11832. if ( toHide.length && this.options.hide ) {
  11833. this._hide( toHide, this.options.hide, function() {
  11834. eventData.oldTab.closest( "li" ).removeClass( "ui-tabs-active ui-state-active" );
  11835. show();
  11836. });
  11837. } else {
  11838. eventData.oldTab.closest( "li" ).removeClass( "ui-tabs-active ui-state-active" );
  11839. toHide.hide();
  11840. show();
  11841. }
  11842. toHide.attr({
  11843. "aria-expanded": "false",
  11844. "aria-hidden": "true"
  11845. });
  11846. eventData.oldTab.attr( "aria-selected", "false" );
  11847. // If we're switching tabs, remove the old tab from the tab order.
  11848. // If we're opening from collapsed state, remove the previous tab from the tab order.
  11849. // If we're collapsing, then keep the collapsing tab in the tab order.
  11850. if ( toShow.length && toHide.length ) {
  11851. eventData.oldTab.attr( "tabIndex", -1 );
  11852. } else if ( toShow.length ) {
  11853. this.tabs.filter(function() {
  11854. return $( this ).attr( "tabIndex" ) === 0;
  11855. })
  11856. .attr( "tabIndex", -1 );
  11857. }
  11858. toShow.attr({
  11859. "aria-expanded": "true",
  11860. "aria-hidden": "false"
  11861. });
  11862. eventData.newTab.attr({
  11863. "aria-selected": "true",
  11864. tabIndex: 0
  11865. });
  11866. },
  11867. _activate: function( index ) {
  11868. var anchor,
  11869. active = this._findActive( index );
  11870. // trying to activate the already active panel
  11871. if ( active[ 0 ] === this.active[ 0 ] ) {
  11872. return;
  11873. }
  11874. // trying to collapse, simulate a click on the current active header
  11875. if ( !active.length ) {
  11876. active = this.active;
  11877. }
  11878. anchor = active.find( ".ui-tabs-anchor" )[ 0 ];
  11879. this._eventHandler({
  11880. target: anchor,
  11881. currentTarget: anchor,
  11882. preventDefault: $.noop
  11883. });
  11884. },
  11885. _findActive: function( index ) {
  11886. return index === false ? $() : this.tabs.eq( index );
  11887. },
  11888. _getIndex: function( index ) {
  11889. // meta-function to give users option to provide a href string instead of a numerical index.
  11890. if ( typeof index === "string" ) {
  11891. index = this.anchors.index( this.anchors.filter( "[href$='" + index + "']" ) );
  11892. }
  11893. return index;
  11894. },
  11895. _destroy: function() {
  11896. if ( this.xhr ) {
  11897. this.xhr.abort();
  11898. }
  11899. this.element.removeClass( "ui-tabs ui-widget ui-widget-content ui-corner-all ui-tabs-collapsible" );
  11900. this.tablist
  11901. .removeClass( "ui-tabs-nav ui-helper-reset ui-helper-clearfix ui-widget-header ui-corner-all" )
  11902. .removeAttr( "role" );
  11903. this.anchors
  11904. .removeClass( "ui-tabs-anchor" )
  11905. .removeAttr( "role" )
  11906. .removeAttr( "tabIndex" )
  11907. .removeData( "href.tabs" )
  11908. .removeData( "load.tabs" )
  11909. .removeUniqueId();
  11910. this.tabs.add( this.panels ).each(function() {
  11911. if ( $.data( this, "ui-tabs-destroy" ) ) {
  11912. $( this ).remove();
  11913. } else {
  11914. $( this )
  11915. .removeClass( "ui-state-default ui-state-active ui-state-disabled " +
  11916. "ui-corner-top ui-corner-bottom ui-widget-content ui-tabs-active ui-tabs-panel" )
  11917. .removeAttr( "tabIndex" )
  11918. .removeAttr( "aria-live" )
  11919. .removeAttr( "aria-busy" )
  11920. .removeAttr( "aria-selected" )
  11921. .removeAttr( "aria-labelledby" )
  11922. .removeAttr( "aria-hidden" )
  11923. .removeAttr( "aria-expanded" )
  11924. .removeAttr( "role" );
  11925. }
  11926. });
  11927. this.tabs.each(function() {
  11928. var li = $( this ),
  11929. prev = li.data( "ui-tabs-aria-controls" );
  11930. if ( prev ) {
  11931. li.attr( "aria-controls", prev );
  11932. } else {
  11933. li.removeAttr( "aria-controls" );
  11934. }
  11935. });
  11936. this.panels.show();
  11937. if ( this.options.heightStyle !== "content" ) {
  11938. this.panels.css( "height", "" );
  11939. }
  11940. },
  11941. enable: function( index ) {
  11942. var disabled = this.options.disabled;
  11943. if ( disabled === false ) {
  11944. return;
  11945. }
  11946. if ( index === undefined ) {
  11947. disabled = false;
  11948. } else {
  11949. index = this._getIndex( index );
  11950. if ( $.isArray( disabled ) ) {
  11951. disabled = $.map( disabled, function( num ) {
  11952. return num !== index ? num : null;
  11953. });
  11954. } else {
  11955. disabled = $.map( this.tabs, function( li, num ) {
  11956. return num !== index ? num : null;
  11957. });
  11958. }
  11959. }
  11960. this._setupDisabled( disabled );
  11961. },
  11962. disable: function( index ) {
  11963. var disabled = this.options.disabled;
  11964. if ( disabled === true ) {
  11965. return;
  11966. }
  11967. if ( index === undefined ) {
  11968. disabled = true;
  11969. } else {
  11970. index = this._getIndex( index );
  11971. if ( $.inArray( index, disabled ) !== -1 ) {
  11972. return;
  11973. }
  11974. if ( $.isArray( disabled ) ) {
  11975. disabled = $.merge( [ index ], disabled ).sort();
  11976. } else {
  11977. disabled = [ index ];
  11978. }
  11979. }
  11980. this._setupDisabled( disabled );
  11981. },
  11982. load: function( index, event ) {
  11983. index = this._getIndex( index );
  11984. var that = this,
  11985. tab = this.tabs.eq( index ),
  11986. anchor = tab.find( ".ui-tabs-anchor" ),
  11987. panel = this._getPanelForTab( tab ),
  11988. eventData = {
  11989. tab: tab,
  11990. panel: panel
  11991. };
  11992. // not remote
  11993. if ( isLocal( anchor[ 0 ] ) ) {
  11994. return;
  11995. }
  11996. this.xhr = $.ajax( this._ajaxSettings( anchor, event, eventData ) );
  11997. // support: jQuery <1.8
  11998. // jQuery <1.8 returns false if the request is canceled in beforeSend,
  11999. // but as of 1.8, $.ajax() always returns a jqXHR object.
  12000. if ( this.xhr && this.xhr.statusText !== "canceled" ) {
  12001. tab.addClass( "ui-tabs-loading" );
  12002. panel.attr( "aria-busy", "true" );
  12003. this.xhr
  12004. .success(function( response ) {
  12005. // support: jQuery <1.8
  12006. // http://bugs.jquery.com/ticket/11778
  12007. setTimeout(function() {
  12008. panel.html( response );
  12009. that._trigger( "load", event, eventData );
  12010. }, 1 );
  12011. })
  12012. .complete(function( jqXHR, status ) {
  12013. // support: jQuery <1.8
  12014. // http://bugs.jquery.com/ticket/11778
  12015. setTimeout(function() {
  12016. if ( status === "abort" ) {
  12017. that.panels.stop( false, true );
  12018. }
  12019. tab.removeClass( "ui-tabs-loading" );
  12020. panel.removeAttr( "aria-busy" );
  12021. if ( jqXHR === that.xhr ) {
  12022. delete that.xhr;
  12023. }
  12024. }, 1 );
  12025. });
  12026. }
  12027. },
  12028. // TODO: Remove this function in 1.10 when ajaxOptions is removed
  12029. _ajaxSettings: function( anchor, event, eventData ) {
  12030. var that = this;
  12031. return {
  12032. url: anchor.attr( "href" ),
  12033. beforeSend: function( jqXHR, settings ) {
  12034. return that._trigger( "beforeLoad", event,
  12035. $.extend( { jqXHR : jqXHR, ajaxSettings: settings }, eventData ) );
  12036. }
  12037. };
  12038. },
  12039. _getPanelForTab: function( tab ) {
  12040. var id = $( tab ).attr( "aria-controls" );
  12041. return this.element.find( this._sanitizeSelector( "#" + id ) );
  12042. }
  12043. });
  12044. // DEPRECATED
  12045. if ( $.uiBackCompat !== false ) {
  12046. // helper method for a lot of the back compat extensions
  12047. $.ui.tabs.prototype._ui = function( tab, panel ) {
  12048. return {
  12049. tab: tab,
  12050. panel: panel,
  12051. index: this.anchors.index( tab )
  12052. };
  12053. };
  12054. // url method
  12055. $.widget( "ui.tabs", $.ui.tabs, {
  12056. url: function( index, url ) {
  12057. this.anchors.eq( index ).attr( "href", url );
  12058. }
  12059. });
  12060. // TODO: Remove _ajaxSettings() method when removing this extension
  12061. // ajaxOptions and cache options
  12062. $.widget( "ui.tabs", $.ui.tabs, {
  12063. options: {
  12064. ajaxOptions: null,
  12065. cache: false
  12066. },
  12067. _create: function() {
  12068. this._super();
  12069. var that = this;
  12070. this._on({ tabsbeforeload: function( event, ui ) {
  12071. // tab is already cached
  12072. if ( $.data( ui.tab[ 0 ], "cache.tabs" ) ) {
  12073. event.preventDefault();
  12074. return;
  12075. }
  12076. ui.jqXHR.success(function() {
  12077. if ( that.options.cache ) {
  12078. $.data( ui.tab[ 0 ], "cache.tabs", true );
  12079. }
  12080. });
  12081. }});
  12082. },
  12083. _ajaxSettings: function( anchor, event, ui ) {
  12084. var ajaxOptions = this.options.ajaxOptions;
  12085. return $.extend( {}, ajaxOptions, {
  12086. error: function( xhr, status ) {
  12087. try {
  12088. // Passing index avoid a race condition when this method is
  12089. // called after the user has selected another tab.
  12090. // Pass the anchor that initiated this request allows
  12091. // loadError to manipulate the tab content panel via $(a.hash)
  12092. ajaxOptions.error(
  12093. xhr, status, ui.tab.closest( "li" ).index(), ui.tab[ 0 ] );
  12094. }
  12095. catch ( error ) {}
  12096. }
  12097. }, this._superApply( arguments ) );
  12098. },
  12099. _setOption: function( key, value ) {
  12100. // reset cache if switching from cached to not cached
  12101. if ( key === "cache" && value === false ) {
  12102. this.anchors.removeData( "cache.tabs" );
  12103. }
  12104. this._super( key, value );
  12105. },
  12106. _destroy: function() {
  12107. this.anchors.removeData( "cache.tabs" );
  12108. this._super();
  12109. },
  12110. url: function( index ){
  12111. this.anchors.eq( index ).removeData( "cache.tabs" );
  12112. this._superApply( arguments );
  12113. }
  12114. });
  12115. // abort method
  12116. $.widget( "ui.tabs", $.ui.tabs, {
  12117. abort: function() {
  12118. if ( this.xhr ) {
  12119. this.xhr.abort();
  12120. }
  12121. }
  12122. });
  12123. // spinner
  12124. $.widget( "ui.tabs", $.ui.tabs, {
  12125. options: {
  12126. spinner: "<em>Loading&#8230;</em>"
  12127. },
  12128. _create: function() {
  12129. this._super();
  12130. this._on({
  12131. tabsbeforeload: function( event, ui ) {
  12132. // Don't react to nested tabs or tabs that don't use a spinner
  12133. if ( event.target !== this.element[ 0 ] ||
  12134. !this.options.spinner ) {
  12135. return;
  12136. }
  12137. var span = ui.tab.find( "span" ),
  12138. html = span.html();
  12139. span.html( this.options.spinner );
  12140. ui.jqXHR.complete(function() {
  12141. span.html( html );
  12142. });
  12143. }
  12144. });
  12145. }
  12146. });
  12147. // enable/disable events
  12148. $.widget( "ui.tabs", $.ui.tabs, {
  12149. options: {
  12150. enable: null,
  12151. disable: null
  12152. },
  12153. enable: function( index ) {
  12154. var options = this.options,
  12155. trigger;
  12156. if ( index && options.disabled === true ||
  12157. ( $.isArray( options.disabled ) && $.inArray( index, options.disabled ) !== -1 ) ) {
  12158. trigger = true;
  12159. }
  12160. this._superApply( arguments );
  12161. if ( trigger ) {
  12162. this._trigger( "enable", null, this._ui( this.anchors[ index ], this.panels[ index ] ) );
  12163. }
  12164. },
  12165. disable: function( index ) {
  12166. var options = this.options,
  12167. trigger;
  12168. if ( index && options.disabled === false ||
  12169. ( $.isArray( options.disabled ) && $.inArray( index, options.disabled ) === -1 ) ) {
  12170. trigger = true;
  12171. }
  12172. this._superApply( arguments );
  12173. if ( trigger ) {
  12174. this._trigger( "disable", null, this._ui( this.anchors[ index ], this.panels[ index ] ) );
  12175. }
  12176. }
  12177. });
  12178. // add/remove methods and events
  12179. $.widget( "ui.tabs", $.ui.tabs, {
  12180. options: {
  12181. add: null,
  12182. remove: null,
  12183. tabTemplate: "<li><a href='#{href}'><span>#{label}</span></a></li>"
  12184. },
  12185. add: function( url, label, index ) {
  12186. if ( index === undefined ) {
  12187. index = this.anchors.length;
  12188. }
  12189. var doInsertAfter, panel,
  12190. options = this.options,
  12191. li = $( options.tabTemplate
  12192. .replace( /#\{href\}/g, url )
  12193. .replace( /#\{label\}/g, label ) ),
  12194. id = !url.indexOf( "#" ) ?
  12195. url.replace( "#", "" ) :
  12196. this._tabId( li );
  12197. li.addClass( "ui-state-default ui-corner-top" ).data( "ui-tabs-destroy", true );
  12198. li.attr( "aria-controls", id );
  12199. doInsertAfter = index >= this.tabs.length;
  12200. // try to find an existing element before creating a new one
  12201. panel = this.element.find( "#" + id );
  12202. if ( !panel.length ) {
  12203. panel = this._createPanel( id );
  12204. if ( doInsertAfter ) {
  12205. if ( index > 0 ) {
  12206. panel.insertAfter( this.panels.eq( -1 ) );
  12207. } else {
  12208. panel.appendTo( this.element );
  12209. }
  12210. } else {
  12211. panel.insertBefore( this.panels[ index ] );
  12212. }
  12213. }
  12214. panel.addClass( "ui-tabs-panel ui-widget-content ui-corner-bottom" ).hide();
  12215. if ( doInsertAfter ) {
  12216. li.appendTo( this.tablist );
  12217. } else {
  12218. li.insertBefore( this.tabs[ index ] );
  12219. }
  12220. options.disabled = $.map( options.disabled, function( n ) {
  12221. return n >= index ? ++n : n;
  12222. });
  12223. this.refresh();
  12224. if ( this.tabs.length === 1 && options.active === false ) {
  12225. this.option( "active", 0 );
  12226. }
  12227. this._trigger( "add", null, this._ui( this.anchors[ index ], this.panels[ index ] ) );
  12228. return this;
  12229. },
  12230. remove: function( index ) {
  12231. index = this._getIndex( index );
  12232. var options = this.options,
  12233. tab = this.tabs.eq( index ).remove(),
  12234. panel = this._getPanelForTab( tab ).remove();
  12235. // If selected tab was removed focus tab to the right or
  12236. // in case the last tab was removed the tab to the left.
  12237. // We check for more than 2 tabs, because if there are only 2,
  12238. // then when we remove this tab, there will only be one tab left
  12239. // so we don't need to detect which tab to activate.
  12240. if ( tab.hasClass( "ui-tabs-active" ) && this.anchors.length > 2 ) {
  12241. this._activate( index + ( index + 1 < this.anchors.length ? 1 : -1 ) );
  12242. }
  12243. options.disabled = $.map(
  12244. $.grep( options.disabled, function( n ) {
  12245. return n !== index;
  12246. }),
  12247. function( n ) {
  12248. return n >= index ? --n : n;
  12249. });
  12250. this.refresh();
  12251. this._trigger( "remove", null, this._ui( tab.find( "a" )[ 0 ], panel[ 0 ] ) );
  12252. return this;
  12253. }
  12254. });
  12255. // length method
  12256. $.widget( "ui.tabs", $.ui.tabs, {
  12257. length: function() {
  12258. return this.anchors.length;
  12259. }
  12260. });
  12261. // panel ids (idPrefix option + title attribute)
  12262. $.widget( "ui.tabs", $.ui.tabs, {
  12263. options: {
  12264. idPrefix: "ui-tabs-"
  12265. },
  12266. _tabId: function( tab ) {
  12267. var a = tab.is( "li" ) ? tab.find( "a[href]" ) : tab;
  12268. a = a[0];
  12269. return $( a ).closest( "li" ).attr( "aria-controls" ) ||
  12270. a.title && a.title.replace( /\s/g, "_" ).replace( /[^\w\u00c0-\uFFFF\-]/g, "" ) ||
  12271. this.options.idPrefix + getNextTabId();
  12272. }
  12273. });
  12274. // _createPanel method
  12275. $.widget( "ui.tabs", $.ui.tabs, {
  12276. options: {
  12277. panelTemplate: "<div></div>"
  12278. },
  12279. _createPanel: function( id ) {
  12280. return $( this.options.panelTemplate )
  12281. .attr( "id", id )
  12282. .addClass( "ui-tabs-panel ui-widget-content ui-corner-bottom" )
  12283. .data( "ui-tabs-destroy", true );
  12284. }
  12285. });
  12286. // selected option
  12287. $.widget( "ui.tabs", $.ui.tabs, {
  12288. _create: function() {
  12289. var options = this.options;
  12290. if ( options.active === null && options.selected !== undefined ) {
  12291. options.active = options.selected === -1 ? false : options.selected;
  12292. }
  12293. this._super();
  12294. options.selected = options.active;
  12295. if ( options.selected === false ) {
  12296. options.selected = -1;
  12297. }
  12298. },
  12299. _setOption: function( key, value ) {
  12300. if ( key !== "selected" ) {
  12301. return this._super( key, value );
  12302. }
  12303. var options = this.options;
  12304. this._super( "active", value === -1 ? false : value );
  12305. options.selected = options.active;
  12306. if ( options.selected === false ) {
  12307. options.selected = -1;
  12308. }
  12309. },
  12310. _eventHandler: function() {
  12311. this._superApply( arguments );
  12312. this.options.selected = this.options.active;
  12313. if ( this.options.selected === false ) {
  12314. this.options.selected = -1;
  12315. }
  12316. }
  12317. });
  12318. // show and select event
  12319. $.widget( "ui.tabs", $.ui.tabs, {
  12320. options: {
  12321. show: null,
  12322. select: null
  12323. },
  12324. _create: function() {
  12325. this._super();
  12326. if ( this.options.active !== false ) {
  12327. this._trigger( "show", null, this._ui(
  12328. this.active.find( ".ui-tabs-anchor" )[ 0 ],
  12329. this._getPanelForTab( this.active )[ 0 ] ) );
  12330. }
  12331. },
  12332. _trigger: function( type, event, data ) {
  12333. var tab, panel,
  12334. ret = this._superApply( arguments );
  12335. if ( !ret ) {
  12336. return false;
  12337. }
  12338. if ( type === "beforeActivate" ) {
  12339. tab = data.newTab.length ? data.newTab : data.oldTab;
  12340. panel = data.newPanel.length ? data.newPanel : data.oldPanel;
  12341. ret = this._super( "select", event, {
  12342. tab: tab.find( ".ui-tabs-anchor" )[ 0],
  12343. panel: panel[ 0 ],
  12344. index: tab.closest( "li" ).index()
  12345. });
  12346. } else if ( type === "activate" && data.newTab.length ) {
  12347. ret = this._super( "show", event, {
  12348. tab: data.newTab.find( ".ui-tabs-anchor" )[ 0 ],
  12349. panel: data.newPanel[ 0 ],
  12350. index: data.newTab.closest( "li" ).index()
  12351. });
  12352. }
  12353. return ret;
  12354. }
  12355. });
  12356. // select method
  12357. $.widget( "ui.tabs", $.ui.tabs, {
  12358. select: function( index ) {
  12359. index = this._getIndex( index );
  12360. if ( index === -1 ) {
  12361. if ( this.options.collapsible && this.options.selected !== -1 ) {
  12362. index = this.options.selected;
  12363. } else {
  12364. return;
  12365. }
  12366. }
  12367. this.anchors.eq( index ).trigger( this.options.event + this.eventNamespace );
  12368. }
  12369. });
  12370. // cookie option
  12371. (function() {
  12372. var listId = 0;
  12373. $.widget( "ui.tabs", $.ui.tabs, {
  12374. options: {
  12375. cookie: null // e.g. { expires: 7, path: '/', domain: 'jquery.com', secure: true }
  12376. },
  12377. _create: function() {
  12378. var options = this.options,
  12379. active;
  12380. if ( options.active == null && options.cookie ) {
  12381. active = parseInt( this._cookie(), 10 );
  12382. if ( active === -1 ) {
  12383. active = false;
  12384. }
  12385. options.active = active;
  12386. }
  12387. this._super();
  12388. },
  12389. _cookie: function( active ) {
  12390. var cookie = [ this.cookie ||
  12391. ( this.cookie = this.options.cookie.name || "ui-tabs-" + (++listId) ) ];
  12392. if ( arguments.length ) {
  12393. cookie.push( active === false ? -1 : active );
  12394. cookie.push( this.options.cookie );
  12395. }
  12396. return $.cookie.apply( null, cookie );
  12397. },
  12398. _refresh: function() {
  12399. this._super();
  12400. if ( this.options.cookie ) {
  12401. this._cookie( this.options.active, this.options.cookie );
  12402. }
  12403. },
  12404. _eventHandler: function() {
  12405. this._superApply( arguments );
  12406. if ( this.options.cookie ) {
  12407. this._cookie( this.options.active, this.options.cookie );
  12408. }
  12409. },
  12410. _destroy: function() {
  12411. this._super();
  12412. if ( this.options.cookie ) {
  12413. this._cookie( null, this.options.cookie );
  12414. }
  12415. }
  12416. });
  12417. })();
  12418. // load event
  12419. $.widget( "ui.tabs", $.ui.tabs, {
  12420. _trigger: function( type, event, data ) {
  12421. var _data = $.extend( {}, data );
  12422. if ( type === "load" ) {
  12423. _data.panel = _data.panel[ 0 ];
  12424. _data.tab = _data.tab.find( ".ui-tabs-anchor" )[ 0 ];
  12425. }
  12426. return this._super( type, event, _data );
  12427. }
  12428. });
  12429. // fx option
  12430. // The new animation options (show, hide) conflict with the old show callback.
  12431. // The old fx option wins over show/hide anyway (always favor back-compat).
  12432. // If a user wants to use the new animation API, they must give up the old API.
  12433. $.widget( "ui.tabs", $.ui.tabs, {
  12434. options: {
  12435. fx: null // e.g. { height: "toggle", opacity: "toggle", duration: 200 }
  12436. },
  12437. _getFx: function() {
  12438. var hide, show,
  12439. fx = this.options.fx;
  12440. if ( fx ) {
  12441. if ( $.isArray( fx ) ) {
  12442. hide = fx[ 0 ];
  12443. show = fx[ 1 ];
  12444. } else {
  12445. hide = show = fx;
  12446. }
  12447. }
  12448. return fx ? { show: show, hide: hide } : null;
  12449. },
  12450. _toggle: function( event, eventData ) {
  12451. var that = this,
  12452. toShow = eventData.newPanel,
  12453. toHide = eventData.oldPanel,
  12454. fx = this._getFx();
  12455. if ( !fx ) {
  12456. return this._super( event, eventData );
  12457. }
  12458. that.running = true;
  12459. function complete() {
  12460. that.running = false;
  12461. that._trigger( "activate", event, eventData );
  12462. }
  12463. function show() {
  12464. eventData.newTab.closest( "li" ).addClass( "ui-tabs-active ui-state-active" );
  12465. if ( toShow.length && fx.show ) {
  12466. toShow
  12467. .animate( fx.show, fx.show.duration, function() {
  12468. complete();
  12469. });
  12470. } else {
  12471. toShow.show();
  12472. complete();
  12473. }
  12474. }
  12475. // start out by hiding, then showing, then completing
  12476. if ( toHide.length && fx.hide ) {
  12477. toHide.animate( fx.hide, fx.hide.duration, function() {
  12478. eventData.oldTab.closest( "li" ).removeClass( "ui-tabs-active ui-state-active" );
  12479. show();
  12480. });
  12481. } else {
  12482. eventData.oldTab.closest( "li" ).removeClass( "ui-tabs-active ui-state-active" );
  12483. toHide.hide();
  12484. show();
  12485. }
  12486. }
  12487. });
  12488. }
  12489. })( jQuery );
  12490. (function( $ ) {
  12491. var increments = 0;
  12492. function addDescribedBy( elem, id ) {
  12493. var describedby = (elem.attr( "aria-describedby" ) || "").split( /\s+/ );
  12494. describedby.push( id );
  12495. elem
  12496. .data( "ui-tooltip-id", id )
  12497. .attr( "aria-describedby", $.trim( describedby.join( " " ) ) );
  12498. }
  12499. function removeDescribedBy( elem ) {
  12500. var id = elem.data( "ui-tooltip-id" ),
  12501. describedby = (elem.attr( "aria-describedby" ) || "").split( /\s+/ ),
  12502. index = $.inArray( id, describedby );
  12503. if ( index !== -1 ) {
  12504. describedby.splice( index, 1 );
  12505. }
  12506. elem.removeData( "ui-tooltip-id" );
  12507. describedby = $.trim( describedby.join( " " ) );
  12508. if ( describedby ) {
  12509. elem.attr( "aria-describedby", describedby );
  12510. } else {
  12511. elem.removeAttr( "aria-describedby" );
  12512. }
  12513. }
  12514. $.widget( "ui.tooltip", {
  12515. version: "1.9.2",
  12516. options: {
  12517. content: function() {
  12518. return $( this ).attr( "title" );
  12519. },
  12520. hide: true,
  12521. // Disabled elements have inconsistent behavior across browsers (#8661)
  12522. items: "[title]:not([disabled])",
  12523. position: {
  12524. my: "left top+15",
  12525. at: "left bottom",
  12526. collision: "flipfit flip"
  12527. },
  12528. show: true,
  12529. tooltipClass: null,
  12530. track: false,
  12531. // callbacks
  12532. close: null,
  12533. open: null
  12534. },
  12535. _create: function() {
  12536. this._on({
  12537. mouseover: "open",
  12538. focusin: "open"
  12539. });
  12540. // IDs of generated tooltips, needed for destroy
  12541. this.tooltips = {};
  12542. // IDs of parent tooltips where we removed the title attribute
  12543. this.parents = {};
  12544. if ( this.options.disabled ) {
  12545. this._disable();
  12546. }
  12547. },
  12548. _setOption: function( key, value ) {
  12549. var that = this;
  12550. if ( key === "disabled" ) {
  12551. this[ value ? "_disable" : "_enable" ]();
  12552. this.options[ key ] = value;
  12553. // disable element style changes
  12554. return;
  12555. }
  12556. this._super( key, value );
  12557. if ( key === "content" ) {
  12558. $.each( this.tooltips, function( id, element ) {
  12559. that._updateContent( element );
  12560. });
  12561. }
  12562. },
  12563. _disable: function() {
  12564. var that = this;
  12565. // close open tooltips
  12566. $.each( this.tooltips, function( id, element ) {
  12567. var event = $.Event( "blur" );
  12568. event.target = event.currentTarget = element[0];
  12569. that.close( event, true );
  12570. });
  12571. // remove title attributes to prevent native tooltips
  12572. this.element.find( this.options.items ).andSelf().each(function() {
  12573. var element = $( this );
  12574. if ( element.is( "[title]" ) ) {
  12575. element
  12576. .data( "ui-tooltip-title", element.attr( "title" ) )
  12577. .attr( "title", "" );
  12578. }
  12579. });
  12580. },
  12581. _enable: function() {
  12582. // restore title attributes
  12583. this.element.find( this.options.items ).andSelf().each(function() {
  12584. var element = $( this );
  12585. if ( element.data( "ui-tooltip-title" ) ) {
  12586. element.attr( "title", element.data( "ui-tooltip-title" ) );
  12587. }
  12588. });
  12589. },
  12590. open: function( event ) {
  12591. var that = this,
  12592. target = $( event ? event.target : this.element )
  12593. // we need closest here due to mouseover bubbling,
  12594. // but always pointing at the same event target
  12595. .closest( this.options.items );
  12596. // No element to show a tooltip for or the tooltip is already open
  12597. if ( !target.length || target.data( "ui-tooltip-id" ) ) {
  12598. return;
  12599. }
  12600. if ( target.attr( "title" ) ) {
  12601. target.data( "ui-tooltip-title", target.attr( "title" ) );
  12602. }
  12603. target.data( "ui-tooltip-open", true );
  12604. // kill parent tooltips, custom or native, for hover
  12605. if ( event && event.type === "mouseover" ) {
  12606. target.parents().each(function() {
  12607. var parent = $( this ),
  12608. blurEvent;
  12609. if ( parent.data( "ui-tooltip-open" ) ) {
  12610. blurEvent = $.Event( "blur" );
  12611. blurEvent.target = blurEvent.currentTarget = this;
  12612. that.close( blurEvent, true );
  12613. }
  12614. if ( parent.attr( "title" ) ) {
  12615. parent.uniqueId();
  12616. that.parents[ this.id ] = {
  12617. element: this,
  12618. title: parent.attr( "title" )
  12619. };
  12620. parent.attr( "title", "" );
  12621. }
  12622. });
  12623. }
  12624. this._updateContent( target, event );
  12625. },
  12626. _updateContent: function( target, event ) {
  12627. var content,
  12628. contentOption = this.options.content,
  12629. that = this,
  12630. eventType = event ? event.type : null;
  12631. if ( typeof contentOption === "string" ) {
  12632. return this._open( event, target, contentOption );
  12633. }
  12634. content = contentOption.call( target[0], function( response ) {
  12635. // ignore async response if tooltip was closed already
  12636. if ( !target.data( "ui-tooltip-open" ) ) {
  12637. return;
  12638. }
  12639. // IE may instantly serve a cached response for ajax requests
  12640. // delay this call to _open so the other call to _open runs first
  12641. that._delay(function() {
  12642. // jQuery creates a special event for focusin when it doesn't
  12643. // exist natively. To improve performance, the native event
  12644. // object is reused and the type is changed. Therefore, we can't
  12645. // rely on the type being correct after the event finished
  12646. // bubbling, so we set it back to the previous value. (#8740)
  12647. if ( event ) {
  12648. event.type = eventType;
  12649. }
  12650. this._open( event, target, response );
  12651. });
  12652. });
  12653. if ( content ) {
  12654. this._open( event, target, content );
  12655. }
  12656. },
  12657. _open: function( event, target, content ) {
  12658. var tooltip, events, delayedShow,
  12659. positionOption = $.extend( {}, this.options.position );
  12660. if ( !content ) {
  12661. return;
  12662. }
  12663. // Content can be updated multiple times. If the tooltip already
  12664. // exists, then just update the content and bail.
  12665. tooltip = this._find( target );
  12666. if ( tooltip.length ) {
  12667. tooltip.find( ".ui-tooltip-content" ).html( content );
  12668. return;
  12669. }
  12670. // if we have a title, clear it to prevent the native tooltip
  12671. // we have to check first to avoid defining a title if none exists
  12672. // (we don't want to cause an element to start matching [title])
  12673. //
  12674. // We use removeAttr only for key events, to allow IE to export the correct
  12675. // accessible attributes. For mouse events, set to empty string to avoid
  12676. // native tooltip showing up (happens only when removing inside mouseover).
  12677. if ( target.is( "[title]" ) ) {
  12678. if ( event && event.type === "mouseover" ) {
  12679. target.attr( "title", "" );
  12680. } else {
  12681. target.removeAttr( "title" );
  12682. }
  12683. }
  12684. tooltip = this._tooltip( target );
  12685. addDescribedBy( target, tooltip.attr( "id" ) );
  12686. tooltip.find( ".ui-tooltip-content" ).html( content );
  12687. function position( event ) {
  12688. positionOption.of = event;
  12689. if ( tooltip.is( ":hidden" ) ) {
  12690. return;
  12691. }
  12692. tooltip.position( positionOption );
  12693. }
  12694. if ( this.options.track && event && /^mouse/.test( event.type ) ) {
  12695. this._on( this.document, {
  12696. mousemove: position
  12697. });
  12698. // trigger once to override element-relative positioning
  12699. position( event );
  12700. } else {
  12701. tooltip.position( $.extend({
  12702. of: target
  12703. }, this.options.position ) );
  12704. }
  12705. tooltip.hide();
  12706. this._show( tooltip, this.options.show );
  12707. // Handle tracking tooltips that are shown with a delay (#8644). As soon
  12708. // as the tooltip is visible, position the tooltip using the most recent
  12709. // event.
  12710. if ( this.options.show && this.options.show.delay ) {
  12711. delayedShow = setInterval(function() {
  12712. if ( tooltip.is( ":visible" ) ) {
  12713. position( positionOption.of );
  12714. clearInterval( delayedShow );
  12715. }
  12716. }, $.fx.interval );
  12717. }
  12718. this._trigger( "open", event, { tooltip: tooltip } );
  12719. events = {
  12720. keyup: function( event ) {
  12721. if ( event.keyCode === $.ui.keyCode.ESCAPE ) {
  12722. var fakeEvent = $.Event(event);
  12723. fakeEvent.currentTarget = target[0];
  12724. this.close( fakeEvent, true );
  12725. }
  12726. },
  12727. remove: function() {
  12728. this._removeTooltip( tooltip );
  12729. }
  12730. };
  12731. if ( !event || event.type === "mouseover" ) {
  12732. events.mouseleave = "close";
  12733. }
  12734. if ( !event || event.type === "focusin" ) {
  12735. events.focusout = "close";
  12736. }
  12737. this._on( true, target, events );
  12738. },
  12739. close: function( event ) {
  12740. var that = this,
  12741. target = $( event ? event.currentTarget : this.element ),
  12742. tooltip = this._find( target );
  12743. // disabling closes the tooltip, so we need to track when we're closing
  12744. // to avoid an infinite loop in case the tooltip becomes disabled on close
  12745. if ( this.closing ) {
  12746. return;
  12747. }
  12748. // only set title if we had one before (see comment in _open())
  12749. if ( target.data( "ui-tooltip-title" ) ) {
  12750. target.attr( "title", target.data( "ui-tooltip-title" ) );
  12751. }
  12752. removeDescribedBy( target );
  12753. tooltip.stop( true );
  12754. this._hide( tooltip, this.options.hide, function() {
  12755. that._removeTooltip( $( this ) );
  12756. });
  12757. target.removeData( "ui-tooltip-open" );
  12758. this._off( target, "mouseleave focusout keyup" );
  12759. // Remove 'remove' binding only on delegated targets
  12760. if ( target[0] !== this.element[0] ) {
  12761. this._off( target, "remove" );
  12762. }
  12763. this._off( this.document, "mousemove" );
  12764. if ( event && event.type === "mouseleave" ) {
  12765. $.each( this.parents, function( id, parent ) {
  12766. $( parent.element ).attr( "title", parent.title );
  12767. delete that.parents[ id ];
  12768. });
  12769. }
  12770. this.closing = true;
  12771. this._trigger( "close", event, { tooltip: tooltip } );
  12772. this.closing = false;
  12773. },
  12774. _tooltip: function( element ) {
  12775. var id = "ui-tooltip-" + increments++,
  12776. tooltip = $( "<div>" )
  12777. .attr({
  12778. id: id,
  12779. role: "tooltip"
  12780. })
  12781. .addClass( "ui-tooltip ui-widget ui-corner-all ui-widget-content " +
  12782. ( this.options.tooltipClass || "" ) );
  12783. $( "<div>" )
  12784. .addClass( "ui-tooltip-content" )
  12785. .appendTo( tooltip );
  12786. tooltip.appendTo( this.document[0].body );
  12787. if ( $.fn.bgiframe ) {
  12788. tooltip.bgiframe();
  12789. }
  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 ) );