jquery-ui.js 426 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987
  1. /*! jQuery UI - v1.10.2 - 2013-03-14
  2. * http://jqueryui.com
  3. * Includes: jquery.ui.core.js, jquery.ui.widget.js, jquery.ui.mouse.js, jquery.ui.draggable.js, jquery.ui.droppable.js, jquery.ui.resizable.js, jquery.ui.selectable.js, jquery.ui.sortable.js, jquery.ui.effect.js, jquery.ui.accordion.js, jquery.ui.autocomplete.js, jquery.ui.button.js, jquery.ui.datepicker.js, jquery.ui.dialog.js, jquery.ui.effect-blind.js, jquery.ui.effect-bounce.js, jquery.ui.effect-clip.js, jquery.ui.effect-drop.js, jquery.ui.effect-explode.js, jquery.ui.effect-fade.js, jquery.ui.effect-fold.js, jquery.ui.effect-highlight.js, jquery.ui.effect-pulsate.js, jquery.ui.effect-scale.js, jquery.ui.effect-shake.js, jquery.ui.effect-slide.js, jquery.ui.effect-transfer.js, jquery.ui.menu.js, jquery.ui.position.js, jquery.ui.progressbar.js, jquery.ui.slider.js, jquery.ui.spinner.js, jquery.ui.tabs.js, jquery.ui.tooltip.js
  4. * Copyright 2013 jQuery Foundation and other contributors; Licensed MIT */
  5. (function( $, undefined ) {
  6. var uuid = 0,
  7. runiqueId = /^ui-id-\d+$/;
  8. // $.ui might exist from components with no dependencies, e.g., $.ui.position
  9. $.ui = $.ui || {};
  10. $.extend( $.ui, {
  11. version: "1.10.2",
  12. keyCode: {
  13. BACKSPACE: 8,
  14. COMMA: 188,
  15. DELETE: 46,
  16. DOWN: 40,
  17. END: 35,
  18. ENTER: 13,
  19. ESCAPE: 27,
  20. HOME: 36,
  21. LEFT: 37,
  22. NUMPAD_ADD: 107,
  23. NUMPAD_DECIMAL: 110,
  24. NUMPAD_DIVIDE: 111,
  25. NUMPAD_ENTER: 108,
  26. NUMPAD_MULTIPLY: 106,
  27. NUMPAD_SUBTRACT: 109,
  28. PAGE_DOWN: 34,
  29. PAGE_UP: 33,
  30. PERIOD: 190,
  31. RIGHT: 39,
  32. SPACE: 32,
  33. TAB: 9,
  34. UP: 38
  35. }
  36. });
  37. // plugins
  38. $.fn.extend({
  39. focus: (function( orig ) {
  40. return function( delay, fn ) {
  41. return typeof delay === "number" ?
  42. this.each(function() {
  43. var elem = this;
  44. setTimeout(function() {
  45. $( elem ).focus();
  46. if ( fn ) {
  47. fn.call( elem );
  48. }
  49. }, delay );
  50. }) :
  51. orig.apply( this, arguments );
  52. };
  53. })( $.fn.focus ),
  54. scrollParent: function() {
  55. var scrollParent;
  56. if (($.ui.ie && (/(static|relative)/).test(this.css("position"))) || (/absolute/).test(this.css("position"))) {
  57. scrollParent = this.parents().filter(function() {
  58. return (/(relative|absolute|fixed)/).test($.css(this,"position")) && (/(auto|scroll)/).test($.css(this,"overflow")+$.css(this,"overflow-y")+$.css(this,"overflow-x"));
  59. }).eq(0);
  60. } else {
  61. scrollParent = this.parents().filter(function() {
  62. return (/(auto|scroll)/).test($.css(this,"overflow")+$.css(this,"overflow-y")+$.css(this,"overflow-x"));
  63. }).eq(0);
  64. }
  65. return (/fixed/).test(this.css("position")) || !scrollParent.length ? $(document) : scrollParent;
  66. },
  67. zIndex: function( zIndex ) {
  68. if ( zIndex !== undefined ) {
  69. return this.css( "zIndex", zIndex );
  70. }
  71. if ( this.length ) {
  72. var elem = $( this[ 0 ] ), position, value;
  73. while ( elem.length && elem[ 0 ] !== document ) {
  74. // Ignore z-index if position is set to a value where z-index is ignored by the browser
  75. // This makes behavior of this function consistent across browsers
  76. // WebKit always returns auto if the element is positioned
  77. position = elem.css( "position" );
  78. if ( position === "absolute" || position === "relative" || position === "fixed" ) {
  79. // IE returns 0 when zIndex is not specified
  80. // other browsers return a string
  81. // we ignore the case of nested elements with an explicit value of 0
  82. // <div style="z-index: -10;"><div style="z-index: 0;"></div></div>
  83. value = parseInt( elem.css( "zIndex" ), 10 );
  84. if ( !isNaN( value ) && value !== 0 ) {
  85. return value;
  86. }
  87. }
  88. elem = elem.parent();
  89. }
  90. }
  91. return 0;
  92. },
  93. uniqueId: function() {
  94. return this.each(function() {
  95. if ( !this.id ) {
  96. this.id = "ui-id-" + (++uuid);
  97. }
  98. });
  99. },
  100. removeUniqueId: function() {
  101. return this.each(function() {
  102. if ( runiqueId.test( this.id ) ) {
  103. $( this ).removeAttr( "id" );
  104. }
  105. });
  106. }
  107. });
  108. // selectors
  109. function focusable( element, isTabIndexNotNaN ) {
  110. var map, mapName, img,
  111. nodeName = element.nodeName.toLowerCase();
  112. if ( "area" === nodeName ) {
  113. map = element.parentNode;
  114. mapName = map.name;
  115. if ( !element.href || !mapName || map.nodeName.toLowerCase() !== "map" ) {
  116. return false;
  117. }
  118. img = $( "img[usemap=#" + mapName + "]" )[0];
  119. return !!img && visible( img );
  120. }
  121. return ( /input|select|textarea|button|object/.test( nodeName ) ?
  122. !element.disabled :
  123. "a" === nodeName ?
  124. element.href || isTabIndexNotNaN :
  125. isTabIndexNotNaN) &&
  126. // the element and all of its ancestors must be visible
  127. visible( element );
  128. }
  129. function visible( element ) {
  130. return $.expr.filters.visible( element ) &&
  131. !$( element ).parents().addBack().filter(function() {
  132. return $.css( this, "visibility" ) === "hidden";
  133. }).length;
  134. }
  135. $.extend( $.expr[ ":" ], {
  136. data: $.expr.createPseudo ?
  137. $.expr.createPseudo(function( dataName ) {
  138. return function( elem ) {
  139. return !!$.data( elem, dataName );
  140. };
  141. }) :
  142. // support: jQuery <1.8
  143. function( elem, i, match ) {
  144. return !!$.data( elem, match[ 3 ] );
  145. },
  146. focusable: function( element ) {
  147. return focusable( element, !isNaN( $.attr( element, "tabindex" ) ) );
  148. },
  149. tabbable: function( element ) {
  150. var tabIndex = $.attr( element, "tabindex" ),
  151. isTabIndexNaN = isNaN( tabIndex );
  152. return ( isTabIndexNaN || tabIndex >= 0 ) && focusable( element, !isTabIndexNaN );
  153. }
  154. });
  155. // support: jQuery <1.8
  156. if ( !$( "<a>" ).outerWidth( 1 ).jquery ) {
  157. $.each( [ "Width", "Height" ], function( i, name ) {
  158. var side = name === "Width" ? [ "Left", "Right" ] : [ "Top", "Bottom" ],
  159. type = name.toLowerCase(),
  160. orig = {
  161. innerWidth: $.fn.innerWidth,
  162. innerHeight: $.fn.innerHeight,
  163. outerWidth: $.fn.outerWidth,
  164. outerHeight: $.fn.outerHeight
  165. };
  166. function reduce( elem, size, border, margin ) {
  167. $.each( side, function() {
  168. size -= parseFloat( $.css( elem, "padding" + this ) ) || 0;
  169. if ( border ) {
  170. size -= parseFloat( $.css( elem, "border" + this + "Width" ) ) || 0;
  171. }
  172. if ( margin ) {
  173. size -= parseFloat( $.css( elem, "margin" + this ) ) || 0;
  174. }
  175. });
  176. return size;
  177. }
  178. $.fn[ "inner" + name ] = function( size ) {
  179. if ( size === undefined ) {
  180. return orig[ "inner" + name ].call( this );
  181. }
  182. return this.each(function() {
  183. $( this ).css( type, reduce( this, size ) + "px" );
  184. });
  185. };
  186. $.fn[ "outer" + name] = function( size, margin ) {
  187. if ( typeof size !== "number" ) {
  188. return orig[ "outer" + name ].call( this, size );
  189. }
  190. return this.each(function() {
  191. $( this).css( type, reduce( this, size, true, margin ) + "px" );
  192. });
  193. };
  194. });
  195. }
  196. // support: jQuery <1.8
  197. if ( !$.fn.addBack ) {
  198. $.fn.addBack = function( selector ) {
  199. return this.add( selector == null ?
  200. this.prevObject : this.prevObject.filter( selector )
  201. );
  202. };
  203. }
  204. // support: jQuery 1.6.1, 1.6.2 (http://bugs.jquery.com/ticket/9413)
  205. if ( $( "<a>" ).data( "a-b", "a" ).removeData( "a-b" ).data( "a-b" ) ) {
  206. $.fn.removeData = (function( removeData ) {
  207. return function( key ) {
  208. if ( arguments.length ) {
  209. return removeData.call( this, $.camelCase( key ) );
  210. } else {
  211. return removeData.call( this );
  212. }
  213. };
  214. })( $.fn.removeData );
  215. }
  216. // deprecated
  217. $.ui.ie = !!/msie [\w.]+/.exec( navigator.userAgent.toLowerCase() );
  218. $.support.selectstart = "onselectstart" in document.createElement( "div" );
  219. $.fn.extend({
  220. disableSelection: function() {
  221. return this.bind( ( $.support.selectstart ? "selectstart" : "mousedown" ) +
  222. ".ui-disableSelection", function( event ) {
  223. event.preventDefault();
  224. });
  225. },
  226. enableSelection: function() {
  227. return this.unbind( ".ui-disableSelection" );
  228. }
  229. });
  230. $.extend( $.ui, {
  231. // $.ui.plugin is deprecated. Use the proxy pattern instead.
  232. plugin: {
  233. add: function( module, option, set ) {
  234. var i,
  235. proto = $.ui[ module ].prototype;
  236. for ( i in set ) {
  237. proto.plugins[ i ] = proto.plugins[ i ] || [];
  238. proto.plugins[ i ].push( [ option, set[ i ] ] );
  239. }
  240. },
  241. call: function( instance, name, args ) {
  242. var i,
  243. set = instance.plugins[ name ];
  244. if ( !set || !instance.element[ 0 ].parentNode || instance.element[ 0 ].parentNode.nodeType === 11 ) {
  245. return;
  246. }
  247. for ( i = 0; i < set.length; i++ ) {
  248. if ( instance.options[ set[ i ][ 0 ] ] ) {
  249. set[ i ][ 1 ].apply( instance.element, args );
  250. }
  251. }
  252. }
  253. },
  254. // only used by resizable
  255. hasScroll: function( el, a ) {
  256. //If overflow is hidden, the element might have extra content, but the user wants to hide it
  257. if ( $( el ).css( "overflow" ) === "hidden") {
  258. return false;
  259. }
  260. var scroll = ( a && a === "left" ) ? "scrollLeft" : "scrollTop",
  261. has = false;
  262. if ( el[ scroll ] > 0 ) {
  263. return true;
  264. }
  265. // TODO: determine which cases actually cause this to happen
  266. // if the element doesn't have the scroll set, see if it's possible to
  267. // set the scroll
  268. el[ scroll ] = 1;
  269. has = ( el[ scroll ] > 0 );
  270. el[ scroll ] = 0;
  271. return has;
  272. }
  273. });
  274. })( jQuery );
  275. (function( $, undefined ) {
  276. var uuid = 0,
  277. slice = Array.prototype.slice,
  278. _cleanData = $.cleanData;
  279. $.cleanData = function( elems ) {
  280. for ( var i = 0, elem; (elem = elems[i]) != null; i++ ) {
  281. try {
  282. $( elem ).triggerHandler( "remove" );
  283. // http://bugs.jquery.com/ticket/8235
  284. } catch( e ) {}
  285. }
  286. _cleanData( elems );
  287. };
  288. $.widget = function( name, base, prototype ) {
  289. var fullName, existingConstructor, constructor, basePrototype,
  290. // proxiedPrototype allows the provided prototype to remain unmodified
  291. // so that it can be used as a mixin for multiple widgets (#8876)
  292. proxiedPrototype = {},
  293. namespace = name.split( "." )[ 0 ];
  294. name = name.split( "." )[ 1 ];
  295. fullName = namespace + "-" + name;
  296. if ( !prototype ) {
  297. prototype = base;
  298. base = $.Widget;
  299. }
  300. // create selector for plugin
  301. $.expr[ ":" ][ fullName.toLowerCase() ] = function( elem ) {
  302. return !!$.data( elem, fullName );
  303. };
  304. $[ namespace ] = $[ namespace ] || {};
  305. existingConstructor = $[ namespace ][ name ];
  306. constructor = $[ namespace ][ name ] = function( options, element ) {
  307. // allow instantiation without "new" keyword
  308. if ( !this._createWidget ) {
  309. return new constructor( options, element );
  310. }
  311. // allow instantiation without initializing for simple inheritance
  312. // must use "new" keyword (the code above always passes args)
  313. if ( arguments.length ) {
  314. this._createWidget( options, element );
  315. }
  316. };
  317. // extend with the existing constructor to carry over any static properties
  318. $.extend( constructor, existingConstructor, {
  319. version: prototype.version,
  320. // copy the object used to create the prototype in case we need to
  321. // redefine the widget later
  322. _proto: $.extend( {}, prototype ),
  323. // track widgets that inherit from this widget in case this widget is
  324. // redefined after a widget inherits from it
  325. _childConstructors: []
  326. });
  327. basePrototype = new base();
  328. // we need to make the options hash a property directly on the new instance
  329. // otherwise we'll modify the options hash on the prototype that we're
  330. // inheriting from
  331. basePrototype.options = $.widget.extend( {}, basePrototype.options );
  332. $.each( prototype, function( prop, value ) {
  333. if ( !$.isFunction( value ) ) {
  334. proxiedPrototype[ prop ] = value;
  335. return;
  336. }
  337. proxiedPrototype[ prop ] = (function() {
  338. var _super = function() {
  339. return base.prototype[ prop ].apply( this, arguments );
  340. },
  341. _superApply = function( args ) {
  342. return base.prototype[ prop ].apply( this, args );
  343. };
  344. return function() {
  345. var __super = this._super,
  346. __superApply = this._superApply,
  347. returnValue;
  348. this._super = _super;
  349. this._superApply = _superApply;
  350. returnValue = value.apply( this, arguments );
  351. this._super = __super;
  352. this._superApply = __superApply;
  353. return returnValue;
  354. };
  355. })();
  356. });
  357. constructor.prototype = $.widget.extend( basePrototype, {
  358. // TODO: remove support for widgetEventPrefix
  359. // always use the name + a colon as the prefix, e.g., draggable:start
  360. // don't prefix for widgets that aren't DOM-based
  361. widgetEventPrefix: existingConstructor ? basePrototype.widgetEventPrefix : name
  362. }, proxiedPrototype, {
  363. constructor: constructor,
  364. namespace: namespace,
  365. widgetName: name,
  366. widgetFullName: fullName
  367. });
  368. // If this widget is being redefined then we need to find all widgets that
  369. // are inheriting from it and redefine all of them so that they inherit from
  370. // the new version of this widget. We're essentially trying to replace one
  371. // level in the prototype chain.
  372. if ( existingConstructor ) {
  373. $.each( existingConstructor._childConstructors, function( i, child ) {
  374. var childPrototype = child.prototype;
  375. // redefine the child widget using the same prototype that was
  376. // originally used, but inherit from the new version of the base
  377. $.widget( childPrototype.namespace + "." + childPrototype.widgetName, constructor, child._proto );
  378. });
  379. // remove the list of existing child constructors from the old constructor
  380. // so the old child constructors can be garbage collected
  381. delete existingConstructor._childConstructors;
  382. } else {
  383. base._childConstructors.push( constructor );
  384. }
  385. $.widget.bridge( name, constructor );
  386. };
  387. $.widget.extend = function( target ) {
  388. var input = slice.call( arguments, 1 ),
  389. inputIndex = 0,
  390. inputLength = input.length,
  391. key,
  392. value;
  393. for ( ; inputIndex < inputLength; inputIndex++ ) {
  394. for ( key in input[ inputIndex ] ) {
  395. value = input[ inputIndex ][ key ];
  396. if ( input[ inputIndex ].hasOwnProperty( key ) && value !== undefined ) {
  397. // Clone objects
  398. if ( $.isPlainObject( value ) ) {
  399. target[ key ] = $.isPlainObject( target[ key ] ) ?
  400. $.widget.extend( {}, target[ key ], value ) :
  401. // Don't extend strings, arrays, etc. with objects
  402. $.widget.extend( {}, value );
  403. // Copy everything else by reference
  404. } else {
  405. target[ key ] = value;
  406. }
  407. }
  408. }
  409. }
  410. return target;
  411. };
  412. $.widget.bridge = function( name, object ) {
  413. var fullName = object.prototype.widgetFullName || name;
  414. $.fn[ name ] = function( options ) {
  415. var isMethodCall = typeof options === "string",
  416. args = slice.call( arguments, 1 ),
  417. returnValue = this;
  418. // allow multiple hashes to be passed on init
  419. options = !isMethodCall && args.length ?
  420. $.widget.extend.apply( null, [ options ].concat(args) ) :
  421. options;
  422. if ( isMethodCall ) {
  423. this.each(function() {
  424. var methodValue,
  425. instance = $.data( this, fullName );
  426. if ( !instance ) {
  427. return $.error( "cannot call methods on " + name + " prior to initialization; " +
  428. "attempted to call method '" + options + "'" );
  429. }
  430. if ( !$.isFunction( instance[options] ) || options.charAt( 0 ) === "_" ) {
  431. return $.error( "no such method '" + options + "' for " + name + " widget instance" );
  432. }
  433. methodValue = instance[ options ].apply( instance, args );
  434. if ( methodValue !== instance && methodValue !== undefined ) {
  435. returnValue = methodValue && methodValue.jquery ?
  436. returnValue.pushStack( methodValue.get() ) :
  437. methodValue;
  438. return false;
  439. }
  440. });
  441. } else {
  442. this.each(function() {
  443. var instance = $.data( this, fullName );
  444. if ( instance ) {
  445. instance.option( options || {} )._init();
  446. } else {
  447. $.data( this, fullName, new object( options, this ) );
  448. }
  449. });
  450. }
  451. return returnValue;
  452. };
  453. };
  454. $.Widget = function( /* options, element */ ) {};
  455. $.Widget._childConstructors = [];
  456. $.Widget.prototype = {
  457. widgetName: "widget",
  458. widgetEventPrefix: "",
  459. defaultElement: "<div>",
  460. options: {
  461. disabled: false,
  462. // callbacks
  463. create: null
  464. },
  465. _createWidget: function( options, element ) {
  466. element = $( element || this.defaultElement || this )[ 0 ];
  467. this.element = $( element );
  468. this.uuid = uuid++;
  469. this.eventNamespace = "." + this.widgetName + this.uuid;
  470. this.options = $.widget.extend( {},
  471. this.options,
  472. this._getCreateOptions(),
  473. options );
  474. this.bindings = $();
  475. this.hoverable = $();
  476. this.focusable = $();
  477. if ( element !== this ) {
  478. $.data( element, this.widgetFullName, this );
  479. this._on( true, this.element, {
  480. remove: function( event ) {
  481. if ( event.target === element ) {
  482. this.destroy();
  483. }
  484. }
  485. });
  486. this.document = $( element.style ?
  487. // element within the document
  488. element.ownerDocument :
  489. // element is window or document
  490. element.document || element );
  491. this.window = $( this.document[0].defaultView || this.document[0].parentWindow );
  492. }
  493. this._create();
  494. this._trigger( "create", null, this._getCreateEventData() );
  495. this._init();
  496. },
  497. _getCreateOptions: $.noop,
  498. _getCreateEventData: $.noop,
  499. _create: $.noop,
  500. _init: $.noop,
  501. destroy: function() {
  502. this._destroy();
  503. // we can probably remove the unbind calls in 2.0
  504. // all event bindings should go through this._on()
  505. this.element
  506. .unbind( this.eventNamespace )
  507. // 1.9 BC for #7810
  508. // TODO remove dual storage
  509. .removeData( this.widgetName )
  510. .removeData( this.widgetFullName )
  511. // support: jquery <1.6.3
  512. // http://bugs.jquery.com/ticket/9413
  513. .removeData( $.camelCase( this.widgetFullName ) );
  514. this.widget()
  515. .unbind( this.eventNamespace )
  516. .removeAttr( "aria-disabled" )
  517. .removeClass(
  518. this.widgetFullName + "-disabled " +
  519. "ui-state-disabled" );
  520. // clean up events and states
  521. this.bindings.unbind( this.eventNamespace );
  522. this.hoverable.removeClass( "ui-state-hover" );
  523. this.focusable.removeClass( "ui-state-focus" );
  524. },
  525. _destroy: $.noop,
  526. widget: function() {
  527. return this.element;
  528. },
  529. option: function( key, value ) {
  530. var options = key,
  531. parts,
  532. curOption,
  533. i;
  534. if ( arguments.length === 0 ) {
  535. // don't return a reference to the internal hash
  536. return $.widget.extend( {}, this.options );
  537. }
  538. if ( typeof key === "string" ) {
  539. // handle nested keys, e.g., "foo.bar" => { foo: { bar: ___ } }
  540. options = {};
  541. parts = key.split( "." );
  542. key = parts.shift();
  543. if ( parts.length ) {
  544. curOption = options[ key ] = $.widget.extend( {}, this.options[ key ] );
  545. for ( i = 0; i < parts.length - 1; i++ ) {
  546. curOption[ parts[ i ] ] = curOption[ parts[ i ] ] || {};
  547. curOption = curOption[ parts[ i ] ];
  548. }
  549. key = parts.pop();
  550. if ( value === undefined ) {
  551. return curOption[ key ] === undefined ? null : curOption[ key ];
  552. }
  553. curOption[ key ] = value;
  554. } else {
  555. if ( value === undefined ) {
  556. return this.options[ key ] === undefined ? null : this.options[ key ];
  557. }
  558. options[ key ] = value;
  559. }
  560. }
  561. this._setOptions( options );
  562. return this;
  563. },
  564. _setOptions: function( options ) {
  565. var key;
  566. for ( key in options ) {
  567. this._setOption( key, options[ key ] );
  568. }
  569. return this;
  570. },
  571. _setOption: function( key, value ) {
  572. this.options[ key ] = value;
  573. if ( key === "disabled" ) {
  574. this.widget()
  575. .toggleClass( this.widgetFullName + "-disabled ui-state-disabled", !!value )
  576. .attr( "aria-disabled", value );
  577. this.hoverable.removeClass( "ui-state-hover" );
  578. this.focusable.removeClass( "ui-state-focus" );
  579. }
  580. return this;
  581. },
  582. enable: function() {
  583. return this._setOption( "disabled", false );
  584. },
  585. disable: function() {
  586. return this._setOption( "disabled", true );
  587. },
  588. _on: function( suppressDisabledCheck, element, handlers ) {
  589. var delegateElement,
  590. instance = this;
  591. // no suppressDisabledCheck flag, shuffle arguments
  592. if ( typeof suppressDisabledCheck !== "boolean" ) {
  593. handlers = element;
  594. element = suppressDisabledCheck;
  595. suppressDisabledCheck = false;
  596. }
  597. // no element argument, shuffle and use this.element
  598. if ( !handlers ) {
  599. handlers = element;
  600. element = this.element;
  601. delegateElement = this.widget();
  602. } else {
  603. // accept selectors, DOM elements
  604. element = delegateElement = $( element );
  605. this.bindings = this.bindings.add( element );
  606. }
  607. $.each( handlers, function( event, handler ) {
  608. function handlerProxy() {
  609. // allow widgets to customize the disabled handling
  610. // - disabled as an array instead of boolean
  611. // - disabled class as method for disabling individual parts
  612. if ( !suppressDisabledCheck &&
  613. ( instance.options.disabled === true ||
  614. $( this ).hasClass( "ui-state-disabled" ) ) ) {
  615. return;
  616. }
  617. return ( typeof handler === "string" ? instance[ handler ] : handler )
  618. .apply( instance, arguments );
  619. }
  620. // copy the guid so direct unbinding works
  621. if ( typeof handler !== "string" ) {
  622. handlerProxy.guid = handler.guid =
  623. handler.guid || handlerProxy.guid || $.guid++;
  624. }
  625. var match = event.match( /^(\w+)\s*(.*)$/ ),
  626. eventName = match[1] + instance.eventNamespace,
  627. selector = match[2];
  628. if ( selector ) {
  629. delegateElement.delegate( selector, eventName, handlerProxy );
  630. } else {
  631. element.bind( eventName, handlerProxy );
  632. }
  633. });
  634. },
  635. _off: function( element, eventName ) {
  636. eventName = (eventName || "").split( " " ).join( this.eventNamespace + " " ) + this.eventNamespace;
  637. element.unbind( eventName ).undelegate( eventName );
  638. },
  639. _delay: function( handler, delay ) {
  640. function handlerProxy() {
  641. return ( typeof handler === "string" ? instance[ handler ] : handler )
  642. .apply( instance, arguments );
  643. }
  644. var instance = this;
  645. return setTimeout( handlerProxy, delay || 0 );
  646. },
  647. _hoverable: function( element ) {
  648. this.hoverable = this.hoverable.add( element );
  649. this._on( element, {
  650. mouseenter: function( event ) {
  651. $( event.currentTarget ).addClass( "ui-state-hover" );
  652. },
  653. mouseleave: function( event ) {
  654. $( event.currentTarget ).removeClass( "ui-state-hover" );
  655. }
  656. });
  657. },
  658. _focusable: function( element ) {
  659. this.focusable = this.focusable.add( element );
  660. this._on( element, {
  661. focusin: function( event ) {
  662. $( event.currentTarget ).addClass( "ui-state-focus" );
  663. },
  664. focusout: function( event ) {
  665. $( event.currentTarget ).removeClass( "ui-state-focus" );
  666. }
  667. });
  668. },
  669. _trigger: function( type, event, data ) {
  670. var prop, orig,
  671. callback = this.options[ type ];
  672. data = data || {};
  673. event = $.Event( event );
  674. event.type = ( type === this.widgetEventPrefix ?
  675. type :
  676. this.widgetEventPrefix + type ).toLowerCase();
  677. // the original event may come from any element
  678. // so we need to reset the target on the new event
  679. event.target = this.element[ 0 ];
  680. // copy original event properties over to the new event
  681. orig = event.originalEvent;
  682. if ( orig ) {
  683. for ( prop in orig ) {
  684. if ( !( prop in event ) ) {
  685. event[ prop ] = orig[ prop ];
  686. }
  687. }
  688. }
  689. this.element.trigger( event, data );
  690. return !( $.isFunction( callback ) &&
  691. callback.apply( this.element[0], [ event ].concat( data ) ) === false ||
  692. event.isDefaultPrevented() );
  693. }
  694. };
  695. $.each( { show: "fadeIn", hide: "fadeOut" }, function( method, defaultEffect ) {
  696. $.Widget.prototype[ "_" + method ] = function( element, options, callback ) {
  697. if ( typeof options === "string" ) {
  698. options = { effect: options };
  699. }
  700. var hasOptions,
  701. effectName = !options ?
  702. method :
  703. options === true || typeof options === "number" ?
  704. defaultEffect :
  705. options.effect || defaultEffect;
  706. options = options || {};
  707. if ( typeof options === "number" ) {
  708. options = { duration: options };
  709. }
  710. hasOptions = !$.isEmptyObject( options );
  711. options.complete = callback;
  712. if ( options.delay ) {
  713. element.delay( options.delay );
  714. }
  715. if ( hasOptions && $.effects && $.effects.effect[ effectName ] ) {
  716. element[ method ]( options );
  717. } else if ( effectName !== method && element[ effectName ] ) {
  718. element[ effectName ]( options.duration, options.easing, callback );
  719. } else {
  720. element.queue(function( next ) {
  721. $( this )[ method ]();
  722. if ( callback ) {
  723. callback.call( element[ 0 ] );
  724. }
  725. next();
  726. });
  727. }
  728. };
  729. });
  730. })( jQuery );
  731. (function( $, undefined ) {
  732. var mouseHandled = false;
  733. $( document ).mouseup( function() {
  734. mouseHandled = false;
  735. });
  736. $.widget("ui.mouse", {
  737. version: "1.10.2",
  738. options: {
  739. cancel: "input,textarea,button,select,option",
  740. distance: 1,
  741. delay: 0
  742. },
  743. _mouseInit: function() {
  744. var that = this;
  745. this.element
  746. .bind("mousedown."+this.widgetName, function(event) {
  747. return that._mouseDown(event);
  748. })
  749. .bind("click."+this.widgetName, function(event) {
  750. if (true === $.data(event.target, that.widgetName + ".preventClickEvent")) {
  751. $.removeData(event.target, that.widgetName + ".preventClickEvent");
  752. event.stopImmediatePropagation();
  753. return false;
  754. }
  755. });
  756. this.started = false;
  757. },
  758. // TODO: make sure destroying one instance of mouse doesn't mess with
  759. // other instances of mouse
  760. _mouseDestroy: function() {
  761. this.element.unbind("."+this.widgetName);
  762. if ( this._mouseMoveDelegate ) {
  763. $(document)
  764. .unbind("mousemove."+this.widgetName, this._mouseMoveDelegate)
  765. .unbind("mouseup."+this.widgetName, this._mouseUpDelegate);
  766. }
  767. },
  768. _mouseDown: function(event) {
  769. // don't let more than one widget handle mouseStart
  770. if( mouseHandled ) { return; }
  771. // we may have missed mouseup (out of window)
  772. (this._mouseStarted && this._mouseUp(event));
  773. this._mouseDownEvent = event;
  774. var that = this,
  775. btnIsLeft = (event.which === 1),
  776. // event.target.nodeName works around a bug in IE 8 with
  777. // disabled inputs (#7620)
  778. elIsCancel = (typeof this.options.cancel === "string" && event.target.nodeName ? $(event.target).closest(this.options.cancel).length : false);
  779. if (!btnIsLeft || elIsCancel || !this._mouseCapture(event)) {
  780. return true;
  781. }
  782. this.mouseDelayMet = !this.options.delay;
  783. if (!this.mouseDelayMet) {
  784. this._mouseDelayTimer = setTimeout(function() {
  785. that.mouseDelayMet = true;
  786. }, this.options.delay);
  787. }
  788. if (this._mouseDistanceMet(event) && this._mouseDelayMet(event)) {
  789. this._mouseStarted = (this._mouseStart(event) !== false);
  790. if (!this._mouseStarted) {
  791. event.preventDefault();
  792. return true;
  793. }
  794. }
  795. // Click event may never have fired (Gecko & Opera)
  796. if (true === $.data(event.target, this.widgetName + ".preventClickEvent")) {
  797. $.removeData(event.target, this.widgetName + ".preventClickEvent");
  798. }
  799. // these delegates are required to keep context
  800. this._mouseMoveDelegate = function(event) {
  801. return that._mouseMove(event);
  802. };
  803. this._mouseUpDelegate = function(event) {
  804. return that._mouseUp(event);
  805. };
  806. $(document)
  807. .bind("mousemove."+this.widgetName, this._mouseMoveDelegate)
  808. .bind("mouseup."+this.widgetName, this._mouseUpDelegate);
  809. event.preventDefault();
  810. mouseHandled = true;
  811. return true;
  812. },
  813. _mouseMove: function(event) {
  814. // IE mouseup check - mouseup happened when mouse was out of window
  815. if ($.ui.ie && ( !document.documentMode || document.documentMode < 9 ) && !event.button) {
  816. return this._mouseUp(event);
  817. }
  818. if (this._mouseStarted) {
  819. this._mouseDrag(event);
  820. return event.preventDefault();
  821. }
  822. if (this._mouseDistanceMet(event) && this._mouseDelayMet(event)) {
  823. this._mouseStarted =
  824. (this._mouseStart(this._mouseDownEvent, event) !== false);
  825. (this._mouseStarted ? this._mouseDrag(event) : this._mouseUp(event));
  826. }
  827. return !this._mouseStarted;
  828. },
  829. _mouseUp: function(event) {
  830. $(document)
  831. .unbind("mousemove."+this.widgetName, this._mouseMoveDelegate)
  832. .unbind("mouseup."+this.widgetName, this._mouseUpDelegate);
  833. if (this._mouseStarted) {
  834. this._mouseStarted = false;
  835. if (event.target === this._mouseDownEvent.target) {
  836. $.data(event.target, this.widgetName + ".preventClickEvent", true);
  837. }
  838. this._mouseStop(event);
  839. }
  840. return false;
  841. },
  842. _mouseDistanceMet: function(event) {
  843. return (Math.max(
  844. Math.abs(this._mouseDownEvent.pageX - event.pageX),
  845. Math.abs(this._mouseDownEvent.pageY - event.pageY)
  846. ) >= this.options.distance
  847. );
  848. },
  849. _mouseDelayMet: function(/* event */) {
  850. return this.mouseDelayMet;
  851. },
  852. // These are placeholder methods, to be overriden by extending plugin
  853. _mouseStart: function(/* event */) {},
  854. _mouseDrag: function(/* event */) {},
  855. _mouseStop: function(/* event */) {},
  856. _mouseCapture: function(/* event */) { return true; }
  857. });
  858. })(jQuery);
  859. (function( $, undefined ) {
  860. $.widget("ui.draggable", $.ui.mouse, {
  861. version: "1.10.2",
  862. widgetEventPrefix: "drag",
  863. options: {
  864. addClasses: true,
  865. appendTo: "parent",
  866. axis: false,
  867. connectToSortable: false,
  868. containment: false,
  869. cursor: "auto",
  870. cursorAt: false,
  871. grid: false,
  872. handle: false,
  873. helper: "original",
  874. iframeFix: false,
  875. opacity: false,
  876. refreshPositions: false,
  877. revert: false,
  878. revertDuration: 500,
  879. scope: "default",
  880. scroll: true,
  881. scrollSensitivity: 20,
  882. scrollSpeed: 20,
  883. snap: false,
  884. snapMode: "both",
  885. snapTolerance: 20,
  886. stack: false,
  887. zIndex: false,
  888. // callbacks
  889. drag: null,
  890. start: null,
  891. stop: null
  892. },
  893. _create: function() {
  894. if (this.options.helper === "original" && !(/^(?:r|a|f)/).test(this.element.css("position"))) {
  895. this.element[0].style.position = "relative";
  896. }
  897. if (this.options.addClasses){
  898. this.element.addClass("ui-draggable");
  899. }
  900. if (this.options.disabled){
  901. this.element.addClass("ui-draggable-disabled");
  902. }
  903. this._mouseInit();
  904. },
  905. _destroy: function() {
  906. this.element.removeClass( "ui-draggable ui-draggable-dragging ui-draggable-disabled" );
  907. this._mouseDestroy();
  908. },
  909. _mouseCapture: function(event) {
  910. var o = this.options;
  911. // among others, prevent a drag on a resizable-handle
  912. if (this.helper || o.disabled || $(event.target).closest(".ui-resizable-handle").length > 0) {
  913. return false;
  914. }
  915. //Quit if we're not on a valid handle
  916. this.handle = this._getHandle(event);
  917. if (!this.handle) {
  918. return false;
  919. }
  920. $(o.iframeFix === true ? "iframe" : o.iframeFix).each(function() {
  921. $("<div class='ui-draggable-iframeFix' style='background: #fff;'></div>")
  922. .css({
  923. width: this.offsetWidth+"px", height: this.offsetHeight+"px",
  924. position: "absolute", opacity: "0.001", zIndex: 1000
  925. })
  926. .css($(this).offset())
  927. .appendTo("body");
  928. });
  929. return true;
  930. },
  931. _mouseStart: function(event) {
  932. var o = this.options;
  933. //Create and append the visible helper
  934. this.helper = this._createHelper(event);
  935. this.helper.addClass("ui-draggable-dragging");
  936. //Cache the helper size
  937. this._cacheHelperProportions();
  938. //If ddmanager is used for droppables, set the global draggable
  939. if($.ui.ddmanager) {
  940. $.ui.ddmanager.current = this;
  941. }
  942. /*
  943. * - Position generation -
  944. * This block generates everything position related - it's the core of draggables.
  945. */
  946. //Cache the margins of the original element
  947. this._cacheMargins();
  948. //Store the helper's css position
  949. this.cssPosition = this.helper.css("position");
  950. this.scrollParent = this.helper.scrollParent();
  951. //The element's absolute position on the page minus margins
  952. this.offset = this.positionAbs = this.element.offset();
  953. this.offset = {
  954. top: this.offset.top - this.margins.top,
  955. left: this.offset.left - this.margins.left
  956. };
  957. $.extend(this.offset, {
  958. click: { //Where the click happened, relative to the element
  959. left: event.pageX - this.offset.left,
  960. top: event.pageY - this.offset.top
  961. },
  962. parent: this._getParentOffset(),
  963. relative: this._getRelativeOffset() //This is a relative to absolute position minus the actual position calculation - only used for relative positioned helper
  964. });
  965. //Generate the original position
  966. this.originalPosition = this.position = this._generatePosition(event);
  967. this.originalPageX = event.pageX;
  968. this.originalPageY = event.pageY;
  969. //Adjust the mouse offset relative to the helper if "cursorAt" is supplied
  970. (o.cursorAt && this._adjustOffsetFromHelper(o.cursorAt));
  971. //Set a containment if given in the options
  972. if(o.containment) {
  973. this._setContainment();
  974. }
  975. //Trigger event + callbacks
  976. if(this._trigger("start", event) === false) {
  977. this._clear();
  978. return false;
  979. }
  980. //Recache the helper size
  981. this._cacheHelperProportions();
  982. //Prepare the droppable offsets
  983. if ($.ui.ddmanager && !o.dropBehaviour) {
  984. $.ui.ddmanager.prepareOffsets(this, event);
  985. }
  986. this._mouseDrag(event, true); //Execute the drag once - this causes the helper not to be visible before getting its correct position
  987. //If the ddmanager is used for droppables, inform the manager that dragging has started (see #5003)
  988. if ( $.ui.ddmanager ) {
  989. $.ui.ddmanager.dragStart(this, event);
  990. }
  991. return true;
  992. },
  993. _mouseDrag: function(event, noPropagation) {
  994. //Compute the helpers position
  995. this.position = this._generatePosition(event);
  996. this.positionAbs = this._convertPositionTo("absolute");
  997. //Call plugins and callbacks and use the resulting position if something is returned
  998. if (!noPropagation) {
  999. var ui = this._uiHash();
  1000. if(this._trigger("drag", event, ui) === false) {
  1001. this._mouseUp({});
  1002. return false;
  1003. }
  1004. this.position = ui.position;
  1005. }
  1006. if(!this.options.axis || this.options.axis !== "y") {
  1007. this.helper[0].style.left = this.position.left+"px";
  1008. }
  1009. if(!this.options.axis || this.options.axis !== "x") {
  1010. this.helper[0].style.top = this.position.top+"px";
  1011. }
  1012. if($.ui.ddmanager) {
  1013. $.ui.ddmanager.drag(this, event);
  1014. }
  1015. return false;
  1016. },
  1017. _mouseStop: function(event) {
  1018. //If we are using droppables, inform the manager about the drop
  1019. var element,
  1020. that = this,
  1021. elementInDom = false,
  1022. dropped = false;
  1023. if ($.ui.ddmanager && !this.options.dropBehaviour) {
  1024. dropped = $.ui.ddmanager.drop(this, event);
  1025. }
  1026. //if a drop comes from outside (a sortable)
  1027. if(this.dropped) {
  1028. dropped = this.dropped;
  1029. this.dropped = false;
  1030. }
  1031. //if the original element is no longer in the DOM don't bother to continue (see #8269)
  1032. element = this.element[0];
  1033. while ( element && (element = element.parentNode) ) {
  1034. if (element === document ) {
  1035. elementInDom = true;
  1036. }
  1037. }
  1038. if ( !elementInDom && this.options.helper === "original" ) {
  1039. return false;
  1040. }
  1041. 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))) {
  1042. $(this.helper).animate(this.originalPosition, parseInt(this.options.revertDuration, 10), function() {
  1043. if(that._trigger("stop", event) !== false) {
  1044. that._clear();
  1045. }
  1046. });
  1047. } else {
  1048. if(this._trigger("stop", event) !== false) {
  1049. this._clear();
  1050. }
  1051. }
  1052. return false;
  1053. },
  1054. _mouseUp: function(event) {
  1055. //Remove frame helpers
  1056. $("div.ui-draggable-iframeFix").each(function() {
  1057. this.parentNode.removeChild(this);
  1058. });
  1059. //If the ddmanager is used for droppables, inform the manager that dragging has stopped (see #5003)
  1060. if( $.ui.ddmanager ) {
  1061. $.ui.ddmanager.dragStop(this, event);
  1062. }
  1063. return $.ui.mouse.prototype._mouseUp.call(this, event);
  1064. },
  1065. cancel: function() {
  1066. if(this.helper.is(".ui-draggable-dragging")) {
  1067. this._mouseUp({});
  1068. } else {
  1069. this._clear();
  1070. }
  1071. return this;
  1072. },
  1073. _getHandle: function(event) {
  1074. return this.options.handle ?
  1075. !!$( event.target ).closest( this.element.find( this.options.handle ) ).length :
  1076. true;
  1077. },
  1078. _createHelper: function(event) {
  1079. var o = this.options,
  1080. helper = $.isFunction(o.helper) ? $(o.helper.apply(this.element[0], [event])) : (o.helper === "clone" ? this.element.clone().removeAttr("id") : this.element);
  1081. if(!helper.parents("body").length) {
  1082. helper.appendTo((o.appendTo === "parent" ? this.element[0].parentNode : o.appendTo));
  1083. }
  1084. if(helper[0] !== this.element[0] && !(/(fixed|absolute)/).test(helper.css("position"))) {
  1085. helper.css("position", "absolute");
  1086. }
  1087. return helper;
  1088. },
  1089. _adjustOffsetFromHelper: function(obj) {
  1090. if (typeof obj === "string") {
  1091. obj = obj.split(" ");
  1092. }
  1093. if ($.isArray(obj)) {
  1094. obj = {left: +obj[0], top: +obj[1] || 0};
  1095. }
  1096. if ("left" in obj) {
  1097. this.offset.click.left = obj.left + this.margins.left;
  1098. }
  1099. if ("right" in obj) {
  1100. this.offset.click.left = this.helperProportions.width - obj.right + this.margins.left;
  1101. }
  1102. if ("top" in obj) {
  1103. this.offset.click.top = obj.top + this.margins.top;
  1104. }
  1105. if ("bottom" in obj) {
  1106. this.offset.click.top = this.helperProportions.height - obj.bottom + this.margins.top;
  1107. }
  1108. },
  1109. _getParentOffset: function() {
  1110. //Get the offsetParent and cache its position
  1111. this.offsetParent = this.helper.offsetParent();
  1112. var po = this.offsetParent.offset();
  1113. // This is a special case where we need to modify a offset calculated on start, since the following happened:
  1114. // 1. The position of the helper is absolute, so it's position is calculated based on the next positioned parent
  1115. // 2. The actual offset parent is a child of the scroll parent, and the scroll parent isn't the document, which means that
  1116. // the scroll is included in the initial calculation of the offset of the parent, and never recalculated upon drag
  1117. if(this.cssPosition === "absolute" && this.scrollParent[0] !== document && $.contains(this.scrollParent[0], this.offsetParent[0])) {
  1118. po.left += this.scrollParent.scrollLeft();
  1119. po.top += this.scrollParent.scrollTop();
  1120. }
  1121. //This needs to be actually done for all browsers, since pageX/pageY includes this information
  1122. //Ugly IE fix
  1123. if((this.offsetParent[0] === document.body) ||
  1124. (this.offsetParent[0].tagName && this.offsetParent[0].tagName.toLowerCase() === "html" && $.ui.ie)) {
  1125. po = { top: 0, left: 0 };
  1126. }
  1127. return {
  1128. top: po.top + (parseInt(this.offsetParent.css("borderTopWidth"),10) || 0),
  1129. left: po.left + (parseInt(this.offsetParent.css("borderLeftWidth"),10) || 0)
  1130. };
  1131. },
  1132. _getRelativeOffset: function() {
  1133. if(this.cssPosition === "relative") {
  1134. var p = this.element.position();
  1135. return {
  1136. top: p.top - (parseInt(this.helper.css("top"),10) || 0) + this.scrollParent.scrollTop(),
  1137. left: p.left - (parseInt(this.helper.css("left"),10) || 0) + this.scrollParent.scrollLeft()
  1138. };
  1139. } else {
  1140. return { top: 0, left: 0 };
  1141. }
  1142. },
  1143. _cacheMargins: function() {
  1144. this.margins = {
  1145. left: (parseInt(this.element.css("marginLeft"),10) || 0),
  1146. top: (parseInt(this.element.css("marginTop"),10) || 0),
  1147. right: (parseInt(this.element.css("marginRight"),10) || 0),
  1148. bottom: (parseInt(this.element.css("marginBottom"),10) || 0)
  1149. };
  1150. },
  1151. _cacheHelperProportions: function() {
  1152. this.helperProportions = {
  1153. width: this.helper.outerWidth(),
  1154. height: this.helper.outerHeight()
  1155. };
  1156. },
  1157. _setContainment: function() {
  1158. var over, c, ce,
  1159. o = this.options;
  1160. if(o.containment === "parent") {
  1161. o.containment = this.helper[0].parentNode;
  1162. }
  1163. if(o.containment === "document" || o.containment === "window") {
  1164. this.containment = [
  1165. o.containment === "document" ? 0 : $(window).scrollLeft() - this.offset.relative.left - this.offset.parent.left,
  1166. o.containment === "document" ? 0 : $(window).scrollTop() - this.offset.relative.top - this.offset.parent.top,
  1167. (o.containment === "document" ? 0 : $(window).scrollLeft()) + $(o.containment === "document" ? document : window).width() - this.helperProportions.width - this.margins.left,
  1168. (o.containment === "document" ? 0 : $(window).scrollTop()) + ($(o.containment === "document" ? document : window).height() || document.body.parentNode.scrollHeight) - this.helperProportions.height - this.margins.top
  1169. ];
  1170. }
  1171. if(!(/^(document|window|parent)$/).test(o.containment) && o.containment.constructor !== Array) {
  1172. c = $(o.containment);
  1173. ce = c[0];
  1174. if(!ce) {
  1175. return;
  1176. }
  1177. over = ($(ce).css("overflow") !== "hidden");
  1178. this.containment = [
  1179. (parseInt($(ce).css("borderLeftWidth"),10) || 0) + (parseInt($(ce).css("paddingLeft"),10) || 0),
  1180. (parseInt($(ce).css("borderTopWidth"),10) || 0) + (parseInt($(ce).css("paddingTop"),10) || 0),
  1181. (over ? Math.max(ce.scrollWidth,ce.offsetWidth) : ce.offsetWidth) - (parseInt($(ce).css("borderRightWidth"),10) || 0) - (parseInt($(ce).css("paddingRight"),10) || 0) - this.helperProportions.width - this.margins.left - this.margins.right,
  1182. (over ? Math.max(ce.scrollHeight,ce.offsetHeight) : ce.offsetHeight) - (parseInt($(ce).css("borderBottomWidth"),10) || 0) - (parseInt($(ce).css("paddingBottom"),10) || 0) - this.helperProportions.height - this.margins.top - this.margins.bottom
  1183. ];
  1184. this.relative_container = c;
  1185. } else if(o.containment.constructor === Array) {
  1186. this.containment = o.containment;
  1187. }
  1188. },
  1189. _convertPositionTo: function(d, pos) {
  1190. if(!pos) {
  1191. pos = this.position;
  1192. }
  1193. var mod = d === "absolute" ? 1 : -1,
  1194. 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);
  1195. return {
  1196. top: (
  1197. pos.top + // The absolute mouse position
  1198. this.offset.relative.top * mod + // Only for relative positioned nodes: Relative offset from element to offset parent
  1199. this.offset.parent.top * mod - // The offsetParent's offset without borders (offset + border)
  1200. ( ( this.cssPosition === "fixed" ? -this.scrollParent.scrollTop() : ( scrollIsRootNode ? 0 : scroll.scrollTop() ) ) * mod)
  1201. ),
  1202. left: (
  1203. pos.left + // The absolute mouse position
  1204. this.offset.relative.left * mod + // Only for relative positioned nodes: Relative offset from element to offset parent
  1205. this.offset.parent.left * mod - // The offsetParent's offset without borders (offset + border)
  1206. ( ( this.cssPosition === "fixed" ? -this.scrollParent.scrollLeft() : scrollIsRootNode ? 0 : scroll.scrollLeft() ) * mod)
  1207. )
  1208. };
  1209. },
  1210. _generatePosition: function(event) {
  1211. var containment, co, top, left,
  1212. o = this.options,
  1213. scroll = this.cssPosition === "absolute" && !(this.scrollParent[0] !== document && $.contains(this.scrollParent[0], this.offsetParent[0])) ? this.offsetParent : this.scrollParent,
  1214. scrollIsRootNode = (/(html|body)/i).test(scroll[0].tagName),
  1215. pageX = event.pageX,
  1216. pageY = event.pageY;
  1217. /*
  1218. * - Position constraining -
  1219. * Constrain the position to a mix of grid, containment.
  1220. */
  1221. if(this.originalPosition) { //If we are not dragging yet, we won't check for options
  1222. if(this.containment) {
  1223. if (this.relative_container){
  1224. co = this.relative_container.offset();
  1225. containment = [ this.containment[0] + co.left,
  1226. this.containment[1] + co.top,
  1227. this.containment[2] + co.left,
  1228. this.containment[3] + co.top ];
  1229. }
  1230. else {
  1231. containment = this.containment;
  1232. }
  1233. if(event.pageX - this.offset.click.left < containment[0]) {
  1234. pageX = containment[0] + this.offset.click.left;
  1235. }
  1236. if(event.pageY - this.offset.click.top < containment[1]) {
  1237. pageY = containment[1] + this.offset.click.top;
  1238. }
  1239. if(event.pageX - this.offset.click.left > containment[2]) {
  1240. pageX = containment[2] + this.offset.click.left;
  1241. }
  1242. if(event.pageY - this.offset.click.top > containment[3]) {
  1243. pageY = containment[3] + this.offset.click.top;
  1244. }
  1245. }
  1246. if(o.grid) {
  1247. //Check for grid elements set to 0 to prevent divide by 0 error causing invalid argument errors in IE (see ticket #6950)
  1248. top = o.grid[1] ? this.originalPageY + Math.round((pageY - this.originalPageY) / o.grid[1]) * o.grid[1] : this.originalPageY;
  1249. 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;
  1250. left = o.grid[0] ? this.originalPageX + Math.round((pageX - this.originalPageX) / o.grid[0]) * o.grid[0] : this.originalPageX;
  1251. 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;
  1252. }
  1253. }
  1254. return {
  1255. top: (
  1256. pageY - // The absolute mouse position
  1257. this.offset.click.top - // Click offset (relative to the element)
  1258. this.offset.relative.top - // Only for relative positioned nodes: Relative offset from element to offset parent
  1259. this.offset.parent.top + // The offsetParent's offset without borders (offset + border)
  1260. ( ( this.cssPosition === "fixed" ? -this.scrollParent.scrollTop() : ( scrollIsRootNode ? 0 : scroll.scrollTop() ) ))
  1261. ),
  1262. left: (
  1263. pageX - // The absolute mouse position
  1264. this.offset.click.left - // Click offset (relative to the element)
  1265. this.offset.relative.left - // Only for relative positioned nodes: Relative offset from element to offset parent
  1266. this.offset.parent.left + // The offsetParent's offset without borders (offset + border)
  1267. ( ( this.cssPosition === "fixed" ? -this.scrollParent.scrollLeft() : scrollIsRootNode ? 0 : scroll.scrollLeft() ))
  1268. )
  1269. };
  1270. },
  1271. _clear: function() {
  1272. this.helper.removeClass("ui-draggable-dragging");
  1273. if(this.helper[0] !== this.element[0] && !this.cancelHelperRemoval) {
  1274. this.helper.remove();
  1275. }
  1276. this.helper = null;
  1277. this.cancelHelperRemoval = false;
  1278. },
  1279. // From now on bulk stuff - mainly helpers
  1280. _trigger: function(type, event, ui) {
  1281. ui = ui || this._uiHash();
  1282. $.ui.plugin.call(this, type, [event, ui]);
  1283. //The absolute position has to be recalculated after plugins
  1284. if(type === "drag") {
  1285. this.positionAbs = this._convertPositionTo("absolute");
  1286. }
  1287. return $.Widget.prototype._trigger.call(this, type, event, ui);
  1288. },
  1289. plugins: {},
  1290. _uiHash: function() {
  1291. return {
  1292. helper: this.helper,
  1293. position: this.position,
  1294. originalPosition: this.originalPosition,
  1295. offset: this.positionAbs
  1296. };
  1297. }
  1298. });
  1299. $.ui.plugin.add("draggable", "connectToSortable", {
  1300. start: function(event, ui) {
  1301. var inst = $(this).data("ui-draggable"), o = inst.options,
  1302. uiSortable = $.extend({}, ui, { item: inst.element });
  1303. inst.sortables = [];
  1304. $(o.connectToSortable).each(function() {
  1305. var sortable = $.data(this, "ui-sortable");
  1306. if (sortable && !sortable.options.disabled) {
  1307. inst.sortables.push({
  1308. instance: sortable,
  1309. shouldRevert: sortable.options.revert
  1310. });
  1311. 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).
  1312. sortable._trigger("activate", event, uiSortable);
  1313. }
  1314. });
  1315. },
  1316. stop: function(event, ui) {
  1317. //If we are still over the sortable, we fake the stop event of the sortable, but also remove helper
  1318. var inst = $(this).data("ui-draggable"),
  1319. uiSortable = $.extend({}, ui, { item: inst.element });
  1320. $.each(inst.sortables, function() {
  1321. if(this.instance.isOver) {
  1322. this.instance.isOver = 0;
  1323. inst.cancelHelperRemoval = true; //Don't remove the helper in the draggable instance
  1324. this.instance.cancelHelperRemoval = false; //Remove it in the sortable instance (so sortable plugins like revert still work)
  1325. //The sortable revert is supported, and we have to set a temporary dropped variable on the draggable to support revert: "valid/invalid"
  1326. if(this.shouldRevert) {
  1327. this.instance.options.revert = this.shouldRevert;
  1328. }
  1329. //Trigger the stop of the sortable
  1330. this.instance._mouseStop(event);
  1331. this.instance.options.helper = this.instance.options._helper;
  1332. //If the helper has been the original item, restore properties in the sortable
  1333. if(inst.options.helper === "original") {
  1334. this.instance.currentItem.css({ top: "auto", left: "auto" });
  1335. }
  1336. } else {
  1337. this.instance.cancelHelperRemoval = false; //Remove the helper in the sortable instance
  1338. this.instance._trigger("deactivate", event, uiSortable);
  1339. }
  1340. });
  1341. },
  1342. drag: function(event, ui) {
  1343. var inst = $(this).data("ui-draggable"), that = this;
  1344. $.each(inst.sortables, function() {
  1345. var innermostIntersecting = false,
  1346. thisSortable = this;
  1347. //Copy over some variables to allow calling the sortable's native _intersectsWith
  1348. this.instance.positionAbs = inst.positionAbs;
  1349. this.instance.helperProportions = inst.helperProportions;
  1350. this.instance.offset.click = inst.offset.click;
  1351. if(this.instance._intersectsWith(this.instance.containerCache)) {
  1352. innermostIntersecting = true;
  1353. $.each(inst.sortables, function () {
  1354. this.instance.positionAbs = inst.positionAbs;
  1355. this.instance.helperProportions = inst.helperProportions;
  1356. this.instance.offset.click = inst.offset.click;
  1357. if (this !== thisSortable &&
  1358. this.instance._intersectsWith(this.instance.containerCache) &&
  1359. $.contains(thisSortable.instance.element[0], this.instance.element[0])
  1360. ) {
  1361. innermostIntersecting = false;
  1362. }
  1363. return innermostIntersecting;
  1364. });
  1365. }
  1366. if(innermostIntersecting) {
  1367. //If it intersects, we use a little isOver variable and set it once, so our move-in stuff gets fired only once
  1368. if(!this.instance.isOver) {
  1369. this.instance.isOver = 1;
  1370. //Now we fake the start of dragging for the sortable instance,
  1371. //by cloning the list group item, appending it to the sortable and using it as inst.currentItem
  1372. //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)
  1373. this.instance.currentItem = $(that).clone().removeAttr("id").appendTo(this.instance.element).data("ui-sortable-item", true);
  1374. this.instance.options._helper = this.instance.options.helper; //Store helper option to later restore it
  1375. this.instance.options.helper = function() { return ui.helper[0]; };
  1376. event.target = this.instance.currentItem[0];
  1377. this.instance._mouseCapture(event, true);
  1378. this.instance._mouseStart(event, true, true);
  1379. //Because the browser event is way off the new appended portlet, we modify a couple of variables to reflect the changes
  1380. this.instance.offset.click.top = inst.offset.click.top;
  1381. this.instance.offset.click.left = inst.offset.click.left;
  1382. this.instance.offset.parent.left -= inst.offset.parent.left - this.instance.offset.parent.left;
  1383. this.instance.offset.parent.top -= inst.offset.parent.top - this.instance.offset.parent.top;
  1384. inst._trigger("toSortable", event);
  1385. inst.dropped = this.instance.element; //draggable revert needs that
  1386. //hack so receive/update callbacks work (mostly)
  1387. inst.currentItem = inst.element;
  1388. this.instance.fromOutside = inst;
  1389. }
  1390. //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
  1391. if(this.instance.currentItem) {
  1392. this.instance._mouseDrag(event);
  1393. }
  1394. } else {
  1395. //If it doesn't intersect with the sortable, and it intersected before,
  1396. //we fake the drag stop of the sortable, but make sure it doesn't remove the helper by using cancelHelperRemoval
  1397. if(this.instance.isOver) {
  1398. this.instance.isOver = 0;
  1399. this.instance.cancelHelperRemoval = true;
  1400. //Prevent reverting on this forced stop
  1401. this.instance.options.revert = false;
  1402. // The out event needs to be triggered independently
  1403. this.instance._trigger("out", event, this.instance._uiHash(this.instance));
  1404. this.instance._mouseStop(event, true);
  1405. this.instance.options.helper = this.instance.options._helper;
  1406. //Now we remove our currentItem, the list group clone again, and the placeholder, and animate the helper back to it's original size
  1407. this.instance.currentItem.remove();
  1408. if(this.instance.placeholder) {
  1409. this.instance.placeholder.remove();
  1410. }
  1411. inst._trigger("fromSortable", event);
  1412. inst.dropped = false; //draggable revert needs that
  1413. }
  1414. }
  1415. });
  1416. }
  1417. });
  1418. $.ui.plugin.add("draggable", "cursor", {
  1419. start: function() {
  1420. var t = $("body"), o = $(this).data("ui-draggable").options;
  1421. if (t.css("cursor")) {
  1422. o._cursor = t.css("cursor");
  1423. }
  1424. t.css("cursor", o.cursor);
  1425. },
  1426. stop: function() {
  1427. var o = $(this).data("ui-draggable").options;
  1428. if (o._cursor) {
  1429. $("body").css("cursor", o._cursor);
  1430. }
  1431. }
  1432. });
  1433. $.ui.plugin.add("draggable", "opacity", {
  1434. start: function(event, ui) {
  1435. var t = $(ui.helper), o = $(this).data("ui-draggable").options;
  1436. if(t.css("opacity")) {
  1437. o._opacity = t.css("opacity");
  1438. }
  1439. t.css("opacity", o.opacity);
  1440. },
  1441. stop: function(event, ui) {
  1442. var o = $(this).data("ui-draggable").options;
  1443. if(o._opacity) {
  1444. $(ui.helper).css("opacity", o._opacity);
  1445. }
  1446. }
  1447. });
  1448. $.ui.plugin.add("draggable", "scroll", {
  1449. start: function() {
  1450. var i = $(this).data("ui-draggable");
  1451. if(i.scrollParent[0] !== document && i.scrollParent[0].tagName !== "HTML") {
  1452. i.overflowOffset = i.scrollParent.offset();
  1453. }
  1454. },
  1455. drag: function( event ) {
  1456. var i = $(this).data("ui-draggable"), o = i.options, scrolled = false;
  1457. if(i.scrollParent[0] !== document && i.scrollParent[0].tagName !== "HTML") {
  1458. if(!o.axis || o.axis !== "x") {
  1459. if((i.overflowOffset.top + i.scrollParent[0].offsetHeight) - event.pageY < o.scrollSensitivity) {
  1460. i.scrollParent[0].scrollTop = scrolled = i.scrollParent[0].scrollTop + o.scrollSpeed;
  1461. } else if(event.pageY - i.overflowOffset.top < o.scrollSensitivity) {
  1462. i.scrollParent[0].scrollTop = scrolled = i.scrollParent[0].scrollTop - o.scrollSpeed;
  1463. }
  1464. }
  1465. if(!o.axis || o.axis !== "y") {
  1466. if((i.overflowOffset.left + i.scrollParent[0].offsetWidth) - event.pageX < o.scrollSensitivity) {
  1467. i.scrollParent[0].scrollLeft = scrolled = i.scrollParent[0].scrollLeft + o.scrollSpeed;
  1468. } else if(event.pageX - i.overflowOffset.left < o.scrollSensitivity) {
  1469. i.scrollParent[0].scrollLeft = scrolled = i.scrollParent[0].scrollLeft - o.scrollSpeed;
  1470. }
  1471. }
  1472. } else {
  1473. if(!o.axis || o.axis !== "x") {
  1474. if(event.pageY - $(document).scrollTop() < o.scrollSensitivity) {
  1475. scrolled = $(document).scrollTop($(document).scrollTop() - o.scrollSpeed);
  1476. } else if($(window).height() - (event.pageY - $(document).scrollTop()) < o.scrollSensitivity) {
  1477. scrolled = $(document).scrollTop($(document).scrollTop() + o.scrollSpeed);
  1478. }
  1479. }
  1480. if(!o.axis || o.axis !== "y") {
  1481. if(event.pageX - $(document).scrollLeft() < o.scrollSensitivity) {
  1482. scrolled = $(document).scrollLeft($(document).scrollLeft() - o.scrollSpeed);
  1483. } else if($(window).width() - (event.pageX - $(document).scrollLeft()) < o.scrollSensitivity) {
  1484. scrolled = $(document).scrollLeft($(document).scrollLeft() + o.scrollSpeed);
  1485. }
  1486. }
  1487. }
  1488. if(scrolled !== false && $.ui.ddmanager && !o.dropBehaviour) {
  1489. $.ui.ddmanager.prepareOffsets(i, event);
  1490. }
  1491. }
  1492. });
  1493. $.ui.plugin.add("draggable", "snap", {
  1494. start: function() {
  1495. var i = $(this).data("ui-draggable"),
  1496. o = i.options;
  1497. i.snapElements = [];
  1498. $(o.snap.constructor !== String ? ( o.snap.items || ":data(ui-draggable)" ) : o.snap).each(function() {
  1499. var $t = $(this),
  1500. $o = $t.offset();
  1501. if(this !== i.element[0]) {
  1502. i.snapElements.push({
  1503. item: this,
  1504. width: $t.outerWidth(), height: $t.outerHeight(),
  1505. top: $o.top, left: $o.left
  1506. });
  1507. }
  1508. });
  1509. },
  1510. drag: function(event, ui) {
  1511. var ts, bs, ls, rs, l, r, t, b, i, first,
  1512. inst = $(this).data("ui-draggable"),
  1513. o = inst.options,
  1514. d = o.snapTolerance,
  1515. x1 = ui.offset.left, x2 = x1 + inst.helperProportions.width,
  1516. y1 = ui.offset.top, y2 = y1 + inst.helperProportions.height;
  1517. for (i = inst.snapElements.length - 1; i >= 0; i--){
  1518. l = inst.snapElements[i].left;
  1519. r = l + inst.snapElements[i].width;
  1520. t = inst.snapElements[i].top;
  1521. b = t + inst.snapElements[i].height;
  1522. //Yes, I know, this is insane ;)
  1523. 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))) {
  1524. if(inst.snapElements[i].snapping) {
  1525. (inst.options.snap.release && inst.options.snap.release.call(inst.element, event, $.extend(inst._uiHash(), { snapItem: inst.snapElements[i].item })));
  1526. }
  1527. inst.snapElements[i].snapping = false;
  1528. continue;
  1529. }
  1530. if(o.snapMode !== "inner") {
  1531. ts = Math.abs(t - y2) <= d;
  1532. bs = Math.abs(b - y1) <= d;
  1533. ls = Math.abs(l - x2) <= d;
  1534. rs = Math.abs(r - x1) <= d;
  1535. if(ts) {
  1536. ui.position.top = inst._convertPositionTo("relative", { top: t - inst.helperProportions.height, left: 0 }).top - inst.margins.top;
  1537. }
  1538. if(bs) {
  1539. ui.position.top = inst._convertPositionTo("relative", { top: b, left: 0 }).top - inst.margins.top;
  1540. }
  1541. if(ls) {
  1542. ui.position.left = inst._convertPositionTo("relative", { top: 0, left: l - inst.helperProportions.width }).left - inst.margins.left;
  1543. }
  1544. if(rs) {
  1545. ui.position.left = inst._convertPositionTo("relative", { top: 0, left: r }).left - inst.margins.left;
  1546. }
  1547. }
  1548. first = (ts || bs || ls || rs);
  1549. if(o.snapMode !== "outer") {
  1550. ts = Math.abs(t - y1) <= d;
  1551. bs = Math.abs(b - y2) <= d;
  1552. ls = Math.abs(l - x1) <= d;
  1553. rs = Math.abs(r - x2) <= d;
  1554. if(ts) {
  1555. ui.position.top = inst._convertPositionTo("relative", { top: t, left: 0 }).top - inst.margins.top;
  1556. }
  1557. if(bs) {
  1558. ui.position.top = inst._convertPositionTo("relative", { top: b - inst.helperProportions.height, left: 0 }).top - inst.margins.top;
  1559. }
  1560. if(ls) {
  1561. ui.position.left = inst._convertPositionTo("relative", { top: 0, left: l }).left - inst.margins.left;
  1562. }
  1563. if(rs) {
  1564. ui.position.left = inst._convertPositionTo("relative", { top: 0, left: r - inst.helperProportions.width }).left - inst.margins.left;
  1565. }
  1566. }
  1567. if(!inst.snapElements[i].snapping && (ts || bs || ls || rs || first)) {
  1568. (inst.options.snap.snap && inst.options.snap.snap.call(inst.element, event, $.extend(inst._uiHash(), { snapItem: inst.snapElements[i].item })));
  1569. }
  1570. inst.snapElements[i].snapping = (ts || bs || ls || rs || first);
  1571. }
  1572. }
  1573. });
  1574. $.ui.plugin.add("draggable", "stack", {
  1575. start: function() {
  1576. var min,
  1577. o = this.data("ui-draggable").options,
  1578. group = $.makeArray($(o.stack)).sort(function(a,b) {
  1579. return (parseInt($(a).css("zIndex"),10) || 0) - (parseInt($(b).css("zIndex"),10) || 0);
  1580. });
  1581. if (!group.length) { return; }
  1582. min = parseInt($(group[0]).css("zIndex"), 10) || 0;
  1583. $(group).each(function(i) {
  1584. $(this).css("zIndex", min + i);
  1585. });
  1586. this.css("zIndex", (min + group.length));
  1587. }
  1588. });
  1589. $.ui.plugin.add("draggable", "zIndex", {
  1590. start: function(event, ui) {
  1591. var t = $(ui.helper), o = $(this).data("ui-draggable").options;
  1592. if(t.css("zIndex")) {
  1593. o._zIndex = t.css("zIndex");
  1594. }
  1595. t.css("zIndex", o.zIndex);
  1596. },
  1597. stop: function(event, ui) {
  1598. var o = $(this).data("ui-draggable").options;
  1599. if(o._zIndex) {
  1600. $(ui.helper).css("zIndex", o._zIndex);
  1601. }
  1602. }
  1603. });
  1604. })(jQuery);
  1605. (function( $, undefined ) {
  1606. function isOverAxis( x, reference, size ) {
  1607. return ( x > reference ) && ( x < ( reference + size ) );
  1608. }
  1609. $.widget("ui.droppable", {
  1610. version: "1.10.2",
  1611. widgetEventPrefix: "drop",
  1612. options: {
  1613. accept: "*",
  1614. activeClass: false,
  1615. addClasses: true,
  1616. greedy: false,
  1617. hoverClass: false,
  1618. scope: "default",
  1619. tolerance: "intersect",
  1620. // callbacks
  1621. activate: null,
  1622. deactivate: null,
  1623. drop: null,
  1624. out: null,
  1625. over: null
  1626. },
  1627. _create: function() {
  1628. var o = this.options,
  1629. accept = o.accept;
  1630. this.isover = false;
  1631. this.isout = true;
  1632. this.accept = $.isFunction(accept) ? accept : function(d) {
  1633. return d.is(accept);
  1634. };
  1635. //Store the droppable's proportions
  1636. this.proportions = { width: this.element[0].offsetWidth, height: this.element[0].offsetHeight };
  1637. // Add the reference and positions to the manager
  1638. $.ui.ddmanager.droppables[o.scope] = $.ui.ddmanager.droppables[o.scope] || [];
  1639. $.ui.ddmanager.droppables[o.scope].push(this);
  1640. (o.addClasses && this.element.addClass("ui-droppable"));
  1641. },
  1642. _destroy: function() {
  1643. var i = 0,
  1644. drop = $.ui.ddmanager.droppables[this.options.scope];
  1645. for ( ; i < drop.length; i++ ) {
  1646. if ( drop[i] === this ) {
  1647. drop.splice(i, 1);
  1648. }
  1649. }
  1650. this.element.removeClass("ui-droppable ui-droppable-disabled");
  1651. },
  1652. _setOption: function(key, value) {
  1653. if(key === "accept") {
  1654. this.accept = $.isFunction(value) ? value : function(d) {
  1655. return d.is(value);
  1656. };
  1657. }
  1658. $.Widget.prototype._setOption.apply(this, arguments);
  1659. },
  1660. _activate: function(event) {
  1661. var draggable = $.ui.ddmanager.current;
  1662. if(this.options.activeClass) {
  1663. this.element.addClass(this.options.activeClass);
  1664. }
  1665. if(draggable){
  1666. this._trigger("activate", event, this.ui(draggable));
  1667. }
  1668. },
  1669. _deactivate: function(event) {
  1670. var draggable = $.ui.ddmanager.current;
  1671. if(this.options.activeClass) {
  1672. this.element.removeClass(this.options.activeClass);
  1673. }
  1674. if(draggable){
  1675. this._trigger("deactivate", event, this.ui(draggable));
  1676. }
  1677. },
  1678. _over: function(event) {
  1679. var draggable = $.ui.ddmanager.current;
  1680. // Bail if draggable and droppable are same element
  1681. if (!draggable || (draggable.currentItem || draggable.element)[0] === this.element[0]) {
  1682. return;
  1683. }
  1684. if (this.accept.call(this.element[0],(draggable.currentItem || draggable.element))) {
  1685. if(this.options.hoverClass) {
  1686. this.element.addClass(this.options.hoverClass);
  1687. }
  1688. this._trigger("over", event, this.ui(draggable));
  1689. }
  1690. },
  1691. _out: function(event) {
  1692. var draggable = $.ui.ddmanager.current;
  1693. // Bail if draggable and droppable are same element
  1694. if (!draggable || (draggable.currentItem || draggable.element)[0] === this.element[0]) {
  1695. return;
  1696. }
  1697. if (this.accept.call(this.element[0],(draggable.currentItem || draggable.element))) {
  1698. if(this.options.hoverClass) {
  1699. this.element.removeClass(this.options.hoverClass);
  1700. }
  1701. this._trigger("out", event, this.ui(draggable));
  1702. }
  1703. },
  1704. _drop: function(event,custom) {
  1705. var draggable = custom || $.ui.ddmanager.current,
  1706. childrenIntersection = false;
  1707. // Bail if draggable and droppable are same element
  1708. if (!draggable || (draggable.currentItem || draggable.element)[0] === this.element[0]) {
  1709. return false;
  1710. }
  1711. this.element.find(":data(ui-droppable)").not(".ui-draggable-dragging").each(function() {
  1712. var inst = $.data(this, "ui-droppable");
  1713. if(
  1714. inst.options.greedy &&
  1715. !inst.options.disabled &&
  1716. inst.options.scope === draggable.options.scope &&
  1717. inst.accept.call(inst.element[0], (draggable.currentItem || draggable.element)) &&
  1718. $.ui.intersect(draggable, $.extend(inst, { offset: inst.element.offset() }), inst.options.tolerance)
  1719. ) { childrenIntersection = true; return false; }
  1720. });
  1721. if(childrenIntersection) {
  1722. return false;
  1723. }
  1724. if(this.accept.call(this.element[0],(draggable.currentItem || draggable.element))) {
  1725. if(this.options.activeClass) {
  1726. this.element.removeClass(this.options.activeClass);
  1727. }
  1728. if(this.options.hoverClass) {
  1729. this.element.removeClass(this.options.hoverClass);
  1730. }
  1731. this._trigger("drop", event, this.ui(draggable));
  1732. return this.element;
  1733. }
  1734. return false;
  1735. },
  1736. ui: function(c) {
  1737. return {
  1738. draggable: (c.currentItem || c.element),
  1739. helper: c.helper,
  1740. position: c.position,
  1741. offset: c.positionAbs
  1742. };
  1743. }
  1744. });
  1745. $.ui.intersect = function(draggable, droppable, toleranceMode) {
  1746. if (!droppable.offset) {
  1747. return false;
  1748. }
  1749. var draggableLeft, draggableTop,
  1750. x1 = (draggable.positionAbs || draggable.position.absolute).left, x2 = x1 + draggable.helperProportions.width,
  1751. y1 = (draggable.positionAbs || draggable.position.absolute).top, y2 = y1 + draggable.helperProportions.height,
  1752. l = droppable.offset.left, r = l + droppable.proportions.width,
  1753. t = droppable.offset.top, b = t + droppable.proportions.height;
  1754. switch (toleranceMode) {
  1755. case "fit":
  1756. return (l <= x1 && x2 <= r && t <= y1 && y2 <= b);
  1757. case "intersect":
  1758. return (l < x1 + (draggable.helperProportions.width / 2) && // Right Half
  1759. x2 - (draggable.helperProportions.width / 2) < r && // Left Half
  1760. t < y1 + (draggable.helperProportions.height / 2) && // Bottom Half
  1761. y2 - (draggable.helperProportions.height / 2) < b ); // Top Half
  1762. case "pointer":
  1763. draggableLeft = ((draggable.positionAbs || draggable.position.absolute).left + (draggable.clickOffset || draggable.offset.click).left);
  1764. draggableTop = ((draggable.positionAbs || draggable.position.absolute).top + (draggable.clickOffset || draggable.offset.click).top);
  1765. return isOverAxis( draggableTop, t, droppable.proportions.height ) && isOverAxis( draggableLeft, l, droppable.proportions.width );
  1766. case "touch":
  1767. return (
  1768. (y1 >= t && y1 <= b) || // Top edge touching
  1769. (y2 >= t && y2 <= b) || // Bottom edge touching
  1770. (y1 < t && y2 > b) // Surrounded vertically
  1771. ) && (
  1772. (x1 >= l && x1 <= r) || // Left edge touching
  1773. (x2 >= l && x2 <= r) || // Right edge touching
  1774. (x1 < l && x2 > r) // Surrounded horizontally
  1775. );
  1776. default:
  1777. return false;
  1778. }
  1779. };
  1780. /*
  1781. This manager tracks offsets of draggables and droppables
  1782. */
  1783. $.ui.ddmanager = {
  1784. current: null,
  1785. droppables: { "default": [] },
  1786. prepareOffsets: function(t, event) {
  1787. var i, j,
  1788. m = $.ui.ddmanager.droppables[t.options.scope] || [],
  1789. type = event ? event.type : null, // workaround for #2317
  1790. list = (t.currentItem || t.element).find(":data(ui-droppable)").addBack();
  1791. droppablesLoop: for (i = 0; i < m.length; i++) {
  1792. //No disabled and non-accepted
  1793. if(m[i].options.disabled || (t && !m[i].accept.call(m[i].element[0],(t.currentItem || t.element)))) {
  1794. continue;
  1795. }
  1796. // Filter out elements in the current dragged item
  1797. for (j=0; j < list.length; j++) {
  1798. if(list[j] === m[i].element[0]) {
  1799. m[i].proportions.height = 0;
  1800. continue droppablesLoop;
  1801. }
  1802. }
  1803. m[i].visible = m[i].element.css("display") !== "none";
  1804. if(!m[i].visible) {
  1805. continue;
  1806. }
  1807. //Activate the droppable if used directly from draggables
  1808. if(type === "mousedown") {
  1809. m[i]._activate.call(m[i], event);
  1810. }
  1811. m[i].offset = m[i].element.offset();
  1812. m[i].proportions = { width: m[i].element[0].offsetWidth, height: m[i].element[0].offsetHeight };
  1813. }
  1814. },
  1815. drop: function(draggable, event) {
  1816. var dropped = false;
  1817. // Create a copy of the droppables in case the list changes during the drop (#9116)
  1818. $.each(($.ui.ddmanager.droppables[draggable.options.scope] || []).slice(), function() {
  1819. if(!this.options) {
  1820. return;
  1821. }
  1822. if (!this.options.disabled && this.visible && $.ui.intersect(draggable, this, this.options.tolerance)) {
  1823. dropped = this._drop.call(this, event) || dropped;
  1824. }
  1825. if (!this.options.disabled && this.visible && this.accept.call(this.element[0],(draggable.currentItem || draggable.element))) {
  1826. this.isout = true;
  1827. this.isover = false;
  1828. this._deactivate.call(this, event);
  1829. }
  1830. });
  1831. return dropped;
  1832. },
  1833. dragStart: function( draggable, event ) {
  1834. //Listen for scrolling so that if the dragging causes scrolling the position of the droppables can be recalculated (see #5003)
  1835. draggable.element.parentsUntil( "body" ).bind( "scroll.droppable", function() {
  1836. if( !draggable.options.refreshPositions ) {
  1837. $.ui.ddmanager.prepareOffsets( draggable, event );
  1838. }
  1839. });
  1840. },
  1841. drag: function(draggable, event) {
  1842. //If you have a highly dynamic page, you might try this option. It renders positions every time you move the mouse.
  1843. if(draggable.options.refreshPositions) {
  1844. $.ui.ddmanager.prepareOffsets(draggable, event);
  1845. }
  1846. //Run through all droppables and check their positions based on specific tolerance options
  1847. $.each($.ui.ddmanager.droppables[draggable.options.scope] || [], function() {
  1848. if(this.options.disabled || this.greedyChild || !this.visible) {
  1849. return;
  1850. }
  1851. var parentInstance, scope, parent,
  1852. intersects = $.ui.intersect(draggable, this, this.options.tolerance),
  1853. c = !intersects && this.isover ? "isout" : (intersects && !this.isover ? "isover" : null);
  1854. if(!c) {
  1855. return;
  1856. }
  1857. if (this.options.greedy) {
  1858. // find droppable parents with same scope
  1859. scope = this.options.scope;
  1860. parent = this.element.parents(":data(ui-droppable)").filter(function () {
  1861. return $.data(this, "ui-droppable").options.scope === scope;
  1862. });
  1863. if (parent.length) {
  1864. parentInstance = $.data(parent[0], "ui-droppable");
  1865. parentInstance.greedyChild = (c === "isover");
  1866. }
  1867. }
  1868. // we just moved into a greedy child
  1869. if (parentInstance && c === "isover") {
  1870. parentInstance.isover = false;
  1871. parentInstance.isout = true;
  1872. parentInstance._out.call(parentInstance, event);
  1873. }
  1874. this[c] = true;
  1875. this[c === "isout" ? "isover" : "isout"] = false;
  1876. this[c === "isover" ? "_over" : "_out"].call(this, event);
  1877. // we just moved out of a greedy child
  1878. if (parentInstance && c === "isout") {
  1879. parentInstance.isout = false;
  1880. parentInstance.isover = true;
  1881. parentInstance._over.call(parentInstance, event);
  1882. }
  1883. });
  1884. },
  1885. dragStop: function( draggable, event ) {
  1886. draggable.element.parentsUntil( "body" ).unbind( "scroll.droppable" );
  1887. //Call prepareOffsets one final time since IE does not fire return scroll events when overflow was caused by drag (see #5003)
  1888. if( !draggable.options.refreshPositions ) {
  1889. $.ui.ddmanager.prepareOffsets( draggable, event );
  1890. }
  1891. }
  1892. };
  1893. })(jQuery);
  1894. (function( $, undefined ) {
  1895. function num(v) {
  1896. return parseInt(v, 10) || 0;
  1897. }
  1898. function isNumber(value) {
  1899. return !isNaN(parseInt(value, 10));
  1900. }
  1901. $.widget("ui.resizable", $.ui.mouse, {
  1902. version: "1.10.2",
  1903. widgetEventPrefix: "resize",
  1904. options: {
  1905. alsoResize: false,
  1906. animate: false,
  1907. animateDuration: "slow",
  1908. animateEasing: "swing",
  1909. aspectRatio: false,
  1910. autoHide: false,
  1911. containment: false,
  1912. ghost: false,
  1913. grid: false,
  1914. handles: "e,s,se",
  1915. helper: false,
  1916. maxHeight: null,
  1917. maxWidth: null,
  1918. minHeight: 10,
  1919. minWidth: 10,
  1920. // See #7960
  1921. zIndex: 90,
  1922. // callbacks
  1923. resize: null,
  1924. start: null,
  1925. stop: null
  1926. },
  1927. _create: function() {
  1928. var n, i, handle, axis, hname,
  1929. that = this,
  1930. o = this.options;
  1931. this.element.addClass("ui-resizable");
  1932. $.extend(this, {
  1933. _aspectRatio: !!(o.aspectRatio),
  1934. aspectRatio: o.aspectRatio,
  1935. originalElement: this.element,
  1936. _proportionallyResizeElements: [],
  1937. _helper: o.helper || o.ghost || o.animate ? o.helper || "ui-resizable-helper" : null
  1938. });
  1939. //Wrap the element if it cannot hold child nodes
  1940. if(this.element[0].nodeName.match(/canvas|textarea|input|select|button|img/i)) {
  1941. //Create a wrapper element and set the wrapper to the new current internal element
  1942. this.element.wrap(
  1943. $("<div class='ui-wrapper' style='overflow: hidden;'></div>").css({
  1944. position: this.element.css("position"),
  1945. width: this.element.outerWidth(),
  1946. height: this.element.outerHeight(),
  1947. top: this.element.css("top"),
  1948. left: this.element.css("left")
  1949. })
  1950. );
  1951. //Overwrite the original this.element
  1952. this.element = this.element.parent().data(
  1953. "ui-resizable", this.element.data("ui-resizable")
  1954. );
  1955. this.elementIsWrapper = true;
  1956. //Move margins to the wrapper
  1957. this.element.css({ marginLeft: this.originalElement.css("marginLeft"), marginTop: this.originalElement.css("marginTop"), marginRight: this.originalElement.css("marginRight"), marginBottom: this.originalElement.css("marginBottom") });
  1958. this.originalElement.css({ marginLeft: 0, marginTop: 0, marginRight: 0, marginBottom: 0});
  1959. //Prevent Safari textarea resize
  1960. this.originalResizeStyle = this.originalElement.css("resize");
  1961. this.originalElement.css("resize", "none");
  1962. //Push the actual element to our proportionallyResize internal array
  1963. this._proportionallyResizeElements.push(this.originalElement.css({ position: "static", zoom: 1, display: "block" }));
  1964. // avoid IE jump (hard set the margin)
  1965. this.originalElement.css({ margin: this.originalElement.css("margin") });
  1966. // fix handlers offset
  1967. this._proportionallyResize();
  1968. }
  1969. 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" });
  1970. if(this.handles.constructor === String) {
  1971. if ( this.handles === "all") {
  1972. this.handles = "n,e,s,w,se,sw,ne,nw";
  1973. }
  1974. n = this.handles.split(",");
  1975. this.handles = {};
  1976. for(i = 0; i < n.length; i++) {
  1977. handle = $.trim(n[i]);
  1978. hname = "ui-resizable-"+handle;
  1979. axis = $("<div class='ui-resizable-handle " + hname + "'></div>");
  1980. // Apply zIndex to all handles - see #7960
  1981. axis.css({ zIndex: o.zIndex });
  1982. //TODO : What's going on here?
  1983. if ("se" === handle) {
  1984. axis.addClass("ui-icon ui-icon-gripsmall-diagonal-se");
  1985. }
  1986. //Insert into internal handles object and append to element
  1987. this.handles[handle] = ".ui-resizable-"+handle;
  1988. this.element.append(axis);
  1989. }
  1990. }
  1991. this._renderAxis = function(target) {
  1992. var i, axis, padPos, padWrapper;
  1993. target = target || this.element;
  1994. for(i in this.handles) {
  1995. if(this.handles[i].constructor === String) {
  1996. this.handles[i] = $(this.handles[i], this.element).show();
  1997. }
  1998. //Apply pad to wrapper element, needed to fix axis position (textarea, inputs, scrolls)
  1999. if (this.elementIsWrapper && this.originalElement[0].nodeName.match(/textarea|input|select|button/i)) {
  2000. axis = $(this.handles[i], this.element);
  2001. //Checking the correct pad and border
  2002. padWrapper = /sw|ne|nw|se|n|s/.test(i) ? axis.outerHeight() : axis.outerWidth();
  2003. //The padding type i have to apply...
  2004. padPos = [ "padding",
  2005. /ne|nw|n/.test(i) ? "Top" :
  2006. /se|sw|s/.test(i) ? "Bottom" :
  2007. /^e$/.test(i) ? "Right" : "Left" ].join("");
  2008. target.css(padPos, padWrapper);
  2009. this._proportionallyResize();
  2010. }
  2011. //TODO: What's that good for? There's not anything to be executed left
  2012. if(!$(this.handles[i]).length) {
  2013. continue;
  2014. }
  2015. }
  2016. };
  2017. //TODO: make renderAxis a prototype function
  2018. this._renderAxis(this.element);
  2019. this._handles = $(".ui-resizable-handle", this.element)
  2020. .disableSelection();
  2021. //Matching axis name
  2022. this._handles.mouseover(function() {
  2023. if (!that.resizing) {
  2024. if (this.className) {
  2025. axis = this.className.match(/ui-resizable-(se|sw|ne|nw|n|e|s|w)/i);
  2026. }
  2027. //Axis, default = se
  2028. that.axis = axis && axis[1] ? axis[1] : "se";
  2029. }
  2030. });
  2031. //If we want to auto hide the elements
  2032. if (o.autoHide) {
  2033. this._handles.hide();
  2034. $(this.element)
  2035. .addClass("ui-resizable-autohide")
  2036. .mouseenter(function() {
  2037. if (o.disabled) {
  2038. return;
  2039. }
  2040. $(this).removeClass("ui-resizable-autohide");
  2041. that._handles.show();
  2042. })
  2043. .mouseleave(function(){
  2044. if (o.disabled) {
  2045. return;
  2046. }
  2047. if (!that.resizing) {
  2048. $(this).addClass("ui-resizable-autohide");
  2049. that._handles.hide();
  2050. }
  2051. });
  2052. }
  2053. //Initialize the mouse interaction
  2054. this._mouseInit();
  2055. },
  2056. _destroy: function() {
  2057. this._mouseDestroy();
  2058. var wrapper,
  2059. _destroy = function(exp) {
  2060. $(exp).removeClass("ui-resizable ui-resizable-disabled ui-resizable-resizing")
  2061. .removeData("resizable").removeData("ui-resizable").unbind(".resizable").find(".ui-resizable-handle").remove();
  2062. };
  2063. //TODO: Unwrap at same DOM position
  2064. if (this.elementIsWrapper) {
  2065. _destroy(this.element);
  2066. wrapper = this.element;
  2067. this.originalElement.css({
  2068. position: wrapper.css("position"),
  2069. width: wrapper.outerWidth(),
  2070. height: wrapper.outerHeight(),
  2071. top: wrapper.css("top"),
  2072. left: wrapper.css("left")
  2073. }).insertAfter( wrapper );
  2074. wrapper.remove();
  2075. }
  2076. this.originalElement.css("resize", this.originalResizeStyle);
  2077. _destroy(this.originalElement);
  2078. return this;
  2079. },
  2080. _mouseCapture: function(event) {
  2081. var i, handle,
  2082. capture = false;
  2083. for (i in this.handles) {
  2084. handle = $(this.handles[i])[0];
  2085. if (handle === event.target || $.contains(handle, event.target)) {
  2086. capture = true;
  2087. }
  2088. }
  2089. return !this.options.disabled && capture;
  2090. },
  2091. _mouseStart: function(event) {
  2092. var curleft, curtop, cursor,
  2093. o = this.options,
  2094. iniPos = this.element.position(),
  2095. el = this.element;
  2096. this.resizing = true;
  2097. // bugfix for http://dev.jquery.com/ticket/1749
  2098. if ( (/absolute/).test( el.css("position") ) ) {
  2099. el.css({ position: "absolute", top: el.css("top"), left: el.css("left") });
  2100. } else if (el.is(".ui-draggable")) {
  2101. el.css({ position: "absolute", top: iniPos.top, left: iniPos.left });
  2102. }
  2103. this._renderProxy();
  2104. curleft = num(this.helper.css("left"));
  2105. curtop = num(this.helper.css("top"));
  2106. if (o.containment) {
  2107. curleft += $(o.containment).scrollLeft() || 0;
  2108. curtop += $(o.containment).scrollTop() || 0;
  2109. }
  2110. //Store needed variables
  2111. this.offset = this.helper.offset();
  2112. this.position = { left: curleft, top: curtop };
  2113. this.size = this._helper ? { width: el.outerWidth(), height: el.outerHeight() } : { width: el.width(), height: el.height() };
  2114. this.originalSize = this._helper ? { width: el.outerWidth(), height: el.outerHeight() } : { width: el.width(), height: el.height() };
  2115. this.originalPosition = { left: curleft, top: curtop };
  2116. this.sizeDiff = { width: el.outerWidth() - el.width(), height: el.outerHeight() - el.height() };
  2117. this.originalMousePosition = { left: event.pageX, top: event.pageY };
  2118. //Aspect Ratio
  2119. this.aspectRatio = (typeof o.aspectRatio === "number") ? o.aspectRatio : ((this.originalSize.width / this.originalSize.height) || 1);
  2120. cursor = $(".ui-resizable-" + this.axis).css("cursor");
  2121. $("body").css("cursor", cursor === "auto" ? this.axis + "-resize" : cursor);
  2122. el.addClass("ui-resizable-resizing");
  2123. this._propagate("start", event);
  2124. return true;
  2125. },
  2126. _mouseDrag: function(event) {
  2127. //Increase performance, avoid regex
  2128. var data,
  2129. el = this.helper, props = {},
  2130. smp = this.originalMousePosition,
  2131. a = this.axis,
  2132. prevTop = this.position.top,
  2133. prevLeft = this.position.left,
  2134. prevWidth = this.size.width,
  2135. prevHeight = this.size.height,
  2136. dx = (event.pageX-smp.left)||0,
  2137. dy = (event.pageY-smp.top)||0,
  2138. trigger = this._change[a];
  2139. if (!trigger) {
  2140. return false;
  2141. }
  2142. // Calculate the attrs that will be change
  2143. data = trigger.apply(this, [event, dx, dy]);
  2144. // Put this in the mouseDrag handler since the user can start pressing shift while resizing
  2145. this._updateVirtualBoundaries(event.shiftKey);
  2146. if (this._aspectRatio || event.shiftKey) {
  2147. data = this._updateRatio(data, event);
  2148. }
  2149. data = this._respectSize(data, event);
  2150. this._updateCache(data);
  2151. // plugins callbacks need to be called first
  2152. this._propagate("resize", event);
  2153. if (this.position.top !== prevTop) {
  2154. props.top = this.position.top + "px";
  2155. }
  2156. if (this.position.left !== prevLeft) {
  2157. props.left = this.position.left + "px";
  2158. }
  2159. if (this.size.width !== prevWidth) {
  2160. props.width = this.size.width + "px";
  2161. }
  2162. if (this.size.height !== prevHeight) {
  2163. props.height = this.size.height + "px";
  2164. }
  2165. el.css(props);
  2166. if (!this._helper && this._proportionallyResizeElements.length) {
  2167. this._proportionallyResize();
  2168. }
  2169. // Call the user callback if the element was resized
  2170. if ( ! $.isEmptyObject(props) ) {
  2171. this._trigger("resize", event, this.ui());
  2172. }
  2173. return false;
  2174. },
  2175. _mouseStop: function(event) {
  2176. this.resizing = false;
  2177. var pr, ista, soffseth, soffsetw, s, left, top,
  2178. o = this.options, that = this;
  2179. if(this._helper) {
  2180. pr = this._proportionallyResizeElements;
  2181. ista = pr.length && (/textarea/i).test(pr[0].nodeName);
  2182. soffseth = ista && $.ui.hasScroll(pr[0], "left") /* TODO - jump height */ ? 0 : that.sizeDiff.height;
  2183. soffsetw = ista ? 0 : that.sizeDiff.width;
  2184. s = { width: (that.helper.width() - soffsetw), height: (that.helper.height() - soffseth) };
  2185. left = (parseInt(that.element.css("left"), 10) + (that.position.left - that.originalPosition.left)) || null;
  2186. top = (parseInt(that.element.css("top"), 10) + (that.position.top - that.originalPosition.top)) || null;
  2187. if (!o.animate) {
  2188. this.element.css($.extend(s, { top: top, left: left }));
  2189. }
  2190. that.helper.height(that.size.height);
  2191. that.helper.width(that.size.width);
  2192. if (this._helper && !o.animate) {
  2193. this._proportionallyResize();
  2194. }
  2195. }
  2196. $("body").css("cursor", "auto");
  2197. this.element.removeClass("ui-resizable-resizing");
  2198. this._propagate("stop", event);
  2199. if (this._helper) {
  2200. this.helper.remove();
  2201. }
  2202. return false;
  2203. },
  2204. _updateVirtualBoundaries: function(forceAspectRatio) {
  2205. var pMinWidth, pMaxWidth, pMinHeight, pMaxHeight, b,
  2206. o = this.options;
  2207. b = {
  2208. minWidth: isNumber(o.minWidth) ? o.minWidth : 0,
  2209. maxWidth: isNumber(o.maxWidth) ? o.maxWidth : Infinity,
  2210. minHeight: isNumber(o.minHeight) ? o.minHeight : 0,
  2211. maxHeight: isNumber(o.maxHeight) ? o.maxHeight : Infinity
  2212. };
  2213. if(this._aspectRatio || forceAspectRatio) {
  2214. // We want to create an enclosing box whose aspect ration is the requested one
  2215. // First, compute the "projected" size for each dimension based on the aspect ratio and other dimension
  2216. pMinWidth = b.minHeight * this.aspectRatio;
  2217. pMinHeight = b.minWidth / this.aspectRatio;
  2218. pMaxWidth = b.maxHeight * this.aspectRatio;
  2219. pMaxHeight = b.maxWidth / this.aspectRatio;
  2220. if(pMinWidth > b.minWidth) {
  2221. b.minWidth = pMinWidth;
  2222. }
  2223. if(pMinHeight > b.minHeight) {
  2224. b.minHeight = pMinHeight;
  2225. }
  2226. if(pMaxWidth < b.maxWidth) {
  2227. b.maxWidth = pMaxWidth;
  2228. }
  2229. if(pMaxHeight < b.maxHeight) {
  2230. b.maxHeight = pMaxHeight;
  2231. }
  2232. }
  2233. this._vBoundaries = b;
  2234. },
  2235. _updateCache: function(data) {
  2236. this.offset = this.helper.offset();
  2237. if (isNumber(data.left)) {
  2238. this.position.left = data.left;
  2239. }
  2240. if (isNumber(data.top)) {
  2241. this.position.top = data.top;
  2242. }
  2243. if (isNumber(data.height)) {
  2244. this.size.height = data.height;
  2245. }
  2246. if (isNumber(data.width)) {
  2247. this.size.width = data.width;
  2248. }
  2249. },
  2250. _updateRatio: function( data ) {
  2251. var cpos = this.position,
  2252. csize = this.size,
  2253. a = this.axis;
  2254. if (isNumber(data.height)) {
  2255. data.width = (data.height * this.aspectRatio);
  2256. } else if (isNumber(data.width)) {
  2257. data.height = (data.width / this.aspectRatio);
  2258. }
  2259. if (a === "sw") {
  2260. data.left = cpos.left + (csize.width - data.width);
  2261. data.top = null;
  2262. }
  2263. if (a === "nw") {
  2264. data.top = cpos.top + (csize.height - data.height);
  2265. data.left = cpos.left + (csize.width - data.width);
  2266. }
  2267. return data;
  2268. },
  2269. _respectSize: function( data ) {
  2270. var o = this._vBoundaries,
  2271. a = this.axis,
  2272. ismaxw = isNumber(data.width) && o.maxWidth && (o.maxWidth < data.width), ismaxh = isNumber(data.height) && o.maxHeight && (o.maxHeight < data.height),
  2273. isminw = isNumber(data.width) && o.minWidth && (o.minWidth > data.width), isminh = isNumber(data.height) && o.minHeight && (o.minHeight > data.height),
  2274. dw = this.originalPosition.left + this.originalSize.width,
  2275. dh = this.position.top + this.size.height,
  2276. cw = /sw|nw|w/.test(a), ch = /nw|ne|n/.test(a);
  2277. if (isminw) {
  2278. data.width = o.minWidth;
  2279. }
  2280. if (isminh) {
  2281. data.height = o.minHeight;
  2282. }
  2283. if (ismaxw) {
  2284. data.width = o.maxWidth;
  2285. }
  2286. if (ismaxh) {
  2287. data.height = o.maxHeight;
  2288. }
  2289. if (isminw && cw) {
  2290. data.left = dw - o.minWidth;
  2291. }
  2292. if (ismaxw && cw) {
  2293. data.left = dw - o.maxWidth;
  2294. }
  2295. if (isminh && ch) {
  2296. data.top = dh - o.minHeight;
  2297. }
  2298. if (ismaxh && ch) {
  2299. data.top = dh - o.maxHeight;
  2300. }
  2301. // fixing jump error on top/left - bug #2330
  2302. if (!data.width && !data.height && !data.left && data.top) {
  2303. data.top = null;
  2304. } else if (!data.width && !data.height && !data.top && data.left) {
  2305. data.left = null;
  2306. }
  2307. return data;
  2308. },
  2309. _proportionallyResize: function() {
  2310. if (!this._proportionallyResizeElements.length) {
  2311. return;
  2312. }
  2313. var i, j, borders, paddings, prel,
  2314. element = this.helper || this.element;
  2315. for ( i=0; i < this._proportionallyResizeElements.length; i++) {
  2316. prel = this._proportionallyResizeElements[i];
  2317. if (!this.borderDif) {
  2318. this.borderDif = [];
  2319. borders = [prel.css("borderTopWidth"), prel.css("borderRightWidth"), prel.css("borderBottomWidth"), prel.css("borderLeftWidth")];
  2320. paddings = [prel.css("paddingTop"), prel.css("paddingRight"), prel.css("paddingBottom"), prel.css("paddingLeft")];
  2321. for ( j = 0; j < borders.length; j++ ) {
  2322. this.borderDif[ j ] = ( parseInt( borders[ j ], 10 ) || 0 ) + ( parseInt( paddings[ j ], 10 ) || 0 );
  2323. }
  2324. }
  2325. prel.css({
  2326. height: (element.height() - this.borderDif[0] - this.borderDif[2]) || 0,
  2327. width: (element.width() - this.borderDif[1] - this.borderDif[3]) || 0
  2328. });
  2329. }
  2330. },
  2331. _renderProxy: function() {
  2332. var el = this.element, o = this.options;
  2333. this.elementOffset = el.offset();
  2334. if(this._helper) {
  2335. this.helper = this.helper || $("<div style='overflow:hidden;'></div>");
  2336. this.helper.addClass(this._helper).css({
  2337. width: this.element.outerWidth() - 1,
  2338. height: this.element.outerHeight() - 1,
  2339. position: "absolute",
  2340. left: this.elementOffset.left +"px",
  2341. top: this.elementOffset.top +"px",
  2342. zIndex: ++o.zIndex //TODO: Don't modify option
  2343. });
  2344. this.helper
  2345. .appendTo("body")
  2346. .disableSelection();
  2347. } else {
  2348. this.helper = this.element;
  2349. }
  2350. },
  2351. _change: {
  2352. e: function(event, dx) {
  2353. return { width: this.originalSize.width + dx };
  2354. },
  2355. w: function(event, dx) {
  2356. var cs = this.originalSize, sp = this.originalPosition;
  2357. return { left: sp.left + dx, width: cs.width - dx };
  2358. },
  2359. n: function(event, dx, dy) {
  2360. var cs = this.originalSize, sp = this.originalPosition;
  2361. return { top: sp.top + dy, height: cs.height - dy };
  2362. },
  2363. s: function(event, dx, dy) {
  2364. return { height: this.originalSize.height + dy };
  2365. },
  2366. se: function(event, dx, dy) {
  2367. return $.extend(this._change.s.apply(this, arguments), this._change.e.apply(this, [event, dx, dy]));
  2368. },
  2369. sw: function(event, dx, dy) {
  2370. return $.extend(this._change.s.apply(this, arguments), this._change.w.apply(this, [event, dx, dy]));
  2371. },
  2372. ne: function(event, dx, dy) {
  2373. return $.extend(this._change.n.apply(this, arguments), this._change.e.apply(this, [event, dx, dy]));
  2374. },
  2375. nw: function(event, dx, dy) {
  2376. return $.extend(this._change.n.apply(this, arguments), this._change.w.apply(this, [event, dx, dy]));
  2377. }
  2378. },
  2379. _propagate: function(n, event) {
  2380. $.ui.plugin.call(this, n, [event, this.ui()]);
  2381. (n !== "resize" && this._trigger(n, event, this.ui()));
  2382. },
  2383. plugins: {},
  2384. ui: function() {
  2385. return {
  2386. originalElement: this.originalElement,
  2387. element: this.element,
  2388. helper: this.helper,
  2389. position: this.position,
  2390. size: this.size,
  2391. originalSize: this.originalSize,
  2392. originalPosition: this.originalPosition
  2393. };
  2394. }
  2395. });
  2396. /*
  2397. * Resizable Extensions
  2398. */
  2399. $.ui.plugin.add("resizable", "animate", {
  2400. stop: function( event ) {
  2401. var that = $(this).data("ui-resizable"),
  2402. o = that.options,
  2403. pr = that._proportionallyResizeElements,
  2404. ista = pr.length && (/textarea/i).test(pr[0].nodeName),
  2405. soffseth = ista && $.ui.hasScroll(pr[0], "left") /* TODO - jump height */ ? 0 : that.sizeDiff.height,
  2406. soffsetw = ista ? 0 : that.sizeDiff.width,
  2407. style = { width: (that.size.width - soffsetw), height: (that.size.height - soffseth) },
  2408. left = (parseInt(that.element.css("left"), 10) + (that.position.left - that.originalPosition.left)) || null,
  2409. top = (parseInt(that.element.css("top"), 10) + (that.position.top - that.originalPosition.top)) || null;
  2410. that.element.animate(
  2411. $.extend(style, top && left ? { top: top, left: left } : {}), {
  2412. duration: o.animateDuration,
  2413. easing: o.animateEasing,
  2414. step: function() {
  2415. var data = {
  2416. width: parseInt(that.element.css("width"), 10),
  2417. height: parseInt(that.element.css("height"), 10),
  2418. top: parseInt(that.element.css("top"), 10),
  2419. left: parseInt(that.element.css("left"), 10)
  2420. };
  2421. if (pr && pr.length) {
  2422. $(pr[0]).css({ width: data.width, height: data.height });
  2423. }
  2424. // propagating resize, and updating values for each animation step
  2425. that._updateCache(data);
  2426. that._propagate("resize", event);
  2427. }
  2428. }
  2429. );
  2430. }
  2431. });
  2432. $.ui.plugin.add("resizable", "containment", {
  2433. start: function() {
  2434. var element, p, co, ch, cw, width, height,
  2435. that = $(this).data("ui-resizable"),
  2436. o = that.options,
  2437. el = that.element,
  2438. oc = o.containment,
  2439. ce = (oc instanceof $) ? oc.get(0) : (/parent/.test(oc)) ? el.parent().get(0) : oc;
  2440. if (!ce) {
  2441. return;
  2442. }
  2443. that.containerElement = $(ce);
  2444. if (/document/.test(oc) || oc === document) {
  2445. that.containerOffset = { left: 0, top: 0 };
  2446. that.containerPosition = { left: 0, top: 0 };
  2447. that.parentData = {
  2448. element: $(document), left: 0, top: 0,
  2449. width: $(document).width(), height: $(document).height() || document.body.parentNode.scrollHeight
  2450. };
  2451. }
  2452. // i'm a node, so compute top, left, right, bottom
  2453. else {
  2454. element = $(ce);
  2455. p = [];
  2456. $([ "Top", "Right", "Left", "Bottom" ]).each(function(i, name) { p[i] = num(element.css("padding" + name)); });
  2457. that.containerOffset = element.offset();
  2458. that.containerPosition = element.position();
  2459. that.containerSize = { height: (element.innerHeight() - p[3]), width: (element.innerWidth() - p[1]) };
  2460. co = that.containerOffset;
  2461. ch = that.containerSize.height;
  2462. cw = that.containerSize.width;
  2463. width = ($.ui.hasScroll(ce, "left") ? ce.scrollWidth : cw );
  2464. height = ($.ui.hasScroll(ce) ? ce.scrollHeight : ch);
  2465. that.parentData = {
  2466. element: ce, left: co.left, top: co.top, width: width, height: height
  2467. };
  2468. }
  2469. },
  2470. resize: function( event ) {
  2471. var woset, hoset, isParent, isOffsetRelative,
  2472. that = $(this).data("ui-resizable"),
  2473. o = that.options,
  2474. co = that.containerOffset, cp = that.position,
  2475. pRatio = that._aspectRatio || event.shiftKey,
  2476. cop = { top:0, left:0 }, ce = that.containerElement;
  2477. if (ce[0] !== document && (/static/).test(ce.css("position"))) {
  2478. cop = co;
  2479. }
  2480. if (cp.left < (that._helper ? co.left : 0)) {
  2481. that.size.width = that.size.width + (that._helper ? (that.position.left - co.left) : (that.position.left - cop.left));
  2482. if (pRatio) {
  2483. that.size.height = that.size.width / that.aspectRatio;
  2484. }
  2485. that.position.left = o.helper ? co.left : 0;
  2486. }
  2487. if (cp.top < (that._helper ? co.top : 0)) {
  2488. that.size.height = that.size.height + (that._helper ? (that.position.top - co.top) : that.position.top);
  2489. if (pRatio) {
  2490. that.size.width = that.size.height * that.aspectRatio;
  2491. }
  2492. that.position.top = that._helper ? co.top : 0;
  2493. }
  2494. that.offset.left = that.parentData.left+that.position.left;
  2495. that.offset.top = that.parentData.top+that.position.top;
  2496. woset = Math.abs( (that._helper ? that.offset.left - cop.left : (that.offset.left - cop.left)) + that.sizeDiff.width );
  2497. hoset = Math.abs( (that._helper ? that.offset.top - cop.top : (that.offset.top - co.top)) + that.sizeDiff.height );
  2498. isParent = that.containerElement.get(0) === that.element.parent().get(0);
  2499. isOffsetRelative = /relative|absolute/.test(that.containerElement.css("position"));
  2500. if(isParent && isOffsetRelative) {
  2501. woset -= that.parentData.left;
  2502. }
  2503. if (woset + that.size.width >= that.parentData.width) {
  2504. that.size.width = that.parentData.width - woset;
  2505. if (pRatio) {
  2506. that.size.height = that.size.width / that.aspectRatio;
  2507. }
  2508. }
  2509. if (hoset + that.size.height >= that.parentData.height) {
  2510. that.size.height = that.parentData.height - hoset;
  2511. if (pRatio) {
  2512. that.size.width = that.size.height * that.aspectRatio;
  2513. }
  2514. }
  2515. },
  2516. stop: function(){
  2517. var that = $(this).data("ui-resizable"),
  2518. o = that.options,
  2519. co = that.containerOffset,
  2520. cop = that.containerPosition,
  2521. ce = that.containerElement,
  2522. helper = $(that.helper),
  2523. ho = helper.offset(),
  2524. w = helper.outerWidth() - that.sizeDiff.width,
  2525. h = helper.outerHeight() - that.sizeDiff.height;
  2526. if (that._helper && !o.animate && (/relative/).test(ce.css("position"))) {
  2527. $(this).css({ left: ho.left - cop.left - co.left, width: w, height: h });
  2528. }
  2529. if (that._helper && !o.animate && (/static/).test(ce.css("position"))) {
  2530. $(this).css({ left: ho.left - cop.left - co.left, width: w, height: h });
  2531. }
  2532. }
  2533. });
  2534. $.ui.plugin.add("resizable", "alsoResize", {
  2535. start: function () {
  2536. var that = $(this).data("ui-resizable"),
  2537. o = that.options,
  2538. _store = function (exp) {
  2539. $(exp).each(function() {
  2540. var el = $(this);
  2541. el.data("ui-resizable-alsoresize", {
  2542. width: parseInt(el.width(), 10), height: parseInt(el.height(), 10),
  2543. left: parseInt(el.css("left"), 10), top: parseInt(el.css("top"), 10)
  2544. });
  2545. });
  2546. };
  2547. if (typeof(o.alsoResize) === "object" && !o.alsoResize.parentNode) {
  2548. if (o.alsoResize.length) { o.alsoResize = o.alsoResize[0]; _store(o.alsoResize); }
  2549. else { $.each(o.alsoResize, function (exp) { _store(exp); }); }
  2550. }else{
  2551. _store(o.alsoResize);
  2552. }
  2553. },
  2554. resize: function (event, ui) {
  2555. var that = $(this).data("ui-resizable"),
  2556. o = that.options,
  2557. os = that.originalSize,
  2558. op = that.originalPosition,
  2559. delta = {
  2560. height: (that.size.height - os.height) || 0, width: (that.size.width - os.width) || 0,
  2561. top: (that.position.top - op.top) || 0, left: (that.position.left - op.left) || 0
  2562. },
  2563. _alsoResize = function (exp, c) {
  2564. $(exp).each(function() {
  2565. var el = $(this), start = $(this).data("ui-resizable-alsoresize"), style = {},
  2566. css = c && c.length ? c : el.parents(ui.originalElement[0]).length ? ["width", "height"] : ["width", "height", "top", "left"];
  2567. $.each(css, function (i, prop) {
  2568. var sum = (start[prop]||0) + (delta[prop]||0);
  2569. if (sum && sum >= 0) {
  2570. style[prop] = sum || null;
  2571. }
  2572. });
  2573. el.css(style);
  2574. });
  2575. };
  2576. if (typeof(o.alsoResize) === "object" && !o.alsoResize.nodeType) {
  2577. $.each(o.alsoResize, function (exp, c) { _alsoResize(exp, c); });
  2578. }else{
  2579. _alsoResize(o.alsoResize);
  2580. }
  2581. },
  2582. stop: function () {
  2583. $(this).removeData("resizable-alsoresize");
  2584. }
  2585. });
  2586. $.ui.plugin.add("resizable", "ghost", {
  2587. start: function() {
  2588. var that = $(this).data("ui-resizable"), o = that.options, cs = that.size;
  2589. that.ghost = that.originalElement.clone();
  2590. that.ghost
  2591. .css({ opacity: 0.25, display: "block", position: "relative", height: cs.height, width: cs.width, margin: 0, left: 0, top: 0 })
  2592. .addClass("ui-resizable-ghost")
  2593. .addClass(typeof o.ghost === "string" ? o.ghost : "");
  2594. that.ghost.appendTo(that.helper);
  2595. },
  2596. resize: function(){
  2597. var that = $(this).data("ui-resizable");
  2598. if (that.ghost) {
  2599. that.ghost.css({ position: "relative", height: that.size.height, width: that.size.width });
  2600. }
  2601. },
  2602. stop: function() {
  2603. var that = $(this).data("ui-resizable");
  2604. if (that.ghost && that.helper) {
  2605. that.helper.get(0).removeChild(that.ghost.get(0));
  2606. }
  2607. }
  2608. });
  2609. $.ui.plugin.add("resizable", "grid", {
  2610. resize: function() {
  2611. var that = $(this).data("ui-resizable"),
  2612. o = that.options,
  2613. cs = that.size,
  2614. os = that.originalSize,
  2615. op = that.originalPosition,
  2616. a = that.axis,
  2617. grid = typeof o.grid === "number" ? [o.grid, o.grid] : o.grid,
  2618. gridX = (grid[0]||1),
  2619. gridY = (grid[1]||1),
  2620. ox = Math.round((cs.width - os.width) / gridX) * gridX,
  2621. oy = Math.round((cs.height - os.height) / gridY) * gridY,
  2622. newWidth = os.width + ox,
  2623. newHeight = os.height + oy,
  2624. isMaxWidth = o.maxWidth && (o.maxWidth < newWidth),
  2625. isMaxHeight = o.maxHeight && (o.maxHeight < newHeight),
  2626. isMinWidth = o.minWidth && (o.minWidth > newWidth),
  2627. isMinHeight = o.minHeight && (o.minHeight > newHeight);
  2628. o.grid = grid;
  2629. if (isMinWidth) {
  2630. newWidth = newWidth + gridX;
  2631. }
  2632. if (isMinHeight) {
  2633. newHeight = newHeight + gridY;
  2634. }
  2635. if (isMaxWidth) {
  2636. newWidth = newWidth - gridX;
  2637. }
  2638. if (isMaxHeight) {
  2639. newHeight = newHeight - gridY;
  2640. }
  2641. if (/^(se|s|e)$/.test(a)) {
  2642. that.size.width = newWidth;
  2643. that.size.height = newHeight;
  2644. } else if (/^(ne)$/.test(a)) {
  2645. that.size.width = newWidth;
  2646. that.size.height = newHeight;
  2647. that.position.top = op.top - oy;
  2648. } else if (/^(sw)$/.test(a)) {
  2649. that.size.width = newWidth;
  2650. that.size.height = newHeight;
  2651. that.position.left = op.left - ox;
  2652. } else {
  2653. that.size.width = newWidth;
  2654. that.size.height = newHeight;
  2655. that.position.top = op.top - oy;
  2656. that.position.left = op.left - ox;
  2657. }
  2658. }
  2659. });
  2660. })(jQuery);
  2661. (function( $, undefined ) {
  2662. $.widget("ui.selectable", $.ui.mouse, {
  2663. version: "1.10.2",
  2664. options: {
  2665. appendTo: "body",
  2666. autoRefresh: true,
  2667. distance: 0,
  2668. filter: "*",
  2669. tolerance: "touch",
  2670. // callbacks
  2671. selected: null,
  2672. selecting: null,
  2673. start: null,
  2674. stop: null,
  2675. unselected: null,
  2676. unselecting: null
  2677. },
  2678. _create: function() {
  2679. var selectees,
  2680. that = this;
  2681. this.element.addClass("ui-selectable");
  2682. this.dragged = false;
  2683. // cache selectee children based on filter
  2684. this.refresh = function() {
  2685. selectees = $(that.options.filter, that.element[0]);
  2686. selectees.addClass("ui-selectee");
  2687. selectees.each(function() {
  2688. var $this = $(this),
  2689. pos = $this.offset();
  2690. $.data(this, "selectable-item", {
  2691. element: this,
  2692. $element: $this,
  2693. left: pos.left,
  2694. top: pos.top,
  2695. right: pos.left + $this.outerWidth(),
  2696. bottom: pos.top + $this.outerHeight(),
  2697. startselected: false,
  2698. selected: $this.hasClass("ui-selected"),
  2699. selecting: $this.hasClass("ui-selecting"),
  2700. unselecting: $this.hasClass("ui-unselecting")
  2701. });
  2702. });
  2703. };
  2704. this.refresh();
  2705. this.selectees = selectees.addClass("ui-selectee");
  2706. this._mouseInit();
  2707. this.helper = $("<div class='ui-selectable-helper'></div>");
  2708. },
  2709. _destroy: function() {
  2710. this.selectees
  2711. .removeClass("ui-selectee")
  2712. .removeData("selectable-item");
  2713. this.element
  2714. .removeClass("ui-selectable ui-selectable-disabled");
  2715. this._mouseDestroy();
  2716. },
  2717. _mouseStart: function(event) {
  2718. var that = this,
  2719. options = this.options;
  2720. this.opos = [event.pageX, event.pageY];
  2721. if (this.options.disabled) {
  2722. return;
  2723. }
  2724. this.selectees = $(options.filter, this.element[0]);
  2725. this._trigger("start", event);
  2726. $(options.appendTo).append(this.helper);
  2727. // position helper (lasso)
  2728. this.helper.css({
  2729. "left": event.pageX,
  2730. "top": event.pageY,
  2731. "width": 0,
  2732. "height": 0
  2733. });
  2734. if (options.autoRefresh) {
  2735. this.refresh();
  2736. }
  2737. this.selectees.filter(".ui-selected").each(function() {
  2738. var selectee = $.data(this, "selectable-item");
  2739. selectee.startselected = true;
  2740. if (!event.metaKey && !event.ctrlKey) {
  2741. selectee.$element.removeClass("ui-selected");
  2742. selectee.selected = false;
  2743. selectee.$element.addClass("ui-unselecting");
  2744. selectee.unselecting = true;
  2745. // selectable UNSELECTING callback
  2746. that._trigger("unselecting", event, {
  2747. unselecting: selectee.element
  2748. });
  2749. }
  2750. });
  2751. $(event.target).parents().addBack().each(function() {
  2752. var doSelect,
  2753. selectee = $.data(this, "selectable-item");
  2754. if (selectee) {
  2755. doSelect = (!event.metaKey && !event.ctrlKey) || !selectee.$element.hasClass("ui-selected");
  2756. selectee.$element
  2757. .removeClass(doSelect ? "ui-unselecting" : "ui-selected")
  2758. .addClass(doSelect ? "ui-selecting" : "ui-unselecting");
  2759. selectee.unselecting = !doSelect;
  2760. selectee.selecting = doSelect;
  2761. selectee.selected = doSelect;
  2762. // selectable (UN)SELECTING callback
  2763. if (doSelect) {
  2764. that._trigger("selecting", event, {
  2765. selecting: selectee.element
  2766. });
  2767. } else {
  2768. that._trigger("unselecting", event, {
  2769. unselecting: selectee.element
  2770. });
  2771. }
  2772. return false;
  2773. }
  2774. });
  2775. },
  2776. _mouseDrag: function(event) {
  2777. this.dragged = true;
  2778. if (this.options.disabled) {
  2779. return;
  2780. }
  2781. var tmp,
  2782. that = this,
  2783. options = this.options,
  2784. x1 = this.opos[0],
  2785. y1 = this.opos[1],
  2786. x2 = event.pageX,
  2787. y2 = event.pageY;
  2788. if (x1 > x2) { tmp = x2; x2 = x1; x1 = tmp; }
  2789. if (y1 > y2) { tmp = y2; y2 = y1; y1 = tmp; }
  2790. this.helper.css({left: x1, top: y1, width: x2-x1, height: y2-y1});
  2791. this.selectees.each(function() {
  2792. var selectee = $.data(this, "selectable-item"),
  2793. hit = false;
  2794. //prevent helper from being selected if appendTo: selectable
  2795. if (!selectee || selectee.element === that.element[0]) {
  2796. return;
  2797. }
  2798. if (options.tolerance === "touch") {
  2799. hit = ( !(selectee.left > x2 || selectee.right < x1 || selectee.top > y2 || selectee.bottom < y1) );
  2800. } else if (options.tolerance === "fit") {
  2801. hit = (selectee.left > x1 && selectee.right < x2 && selectee.top > y1 && selectee.bottom < y2);
  2802. }
  2803. if (hit) {
  2804. // SELECT
  2805. if (selectee.selected) {
  2806. selectee.$element.removeClass("ui-selected");
  2807. selectee.selected = false;
  2808. }
  2809. if (selectee.unselecting) {
  2810. selectee.$element.removeClass("ui-unselecting");
  2811. selectee.unselecting = false;
  2812. }
  2813. if (!selectee.selecting) {
  2814. selectee.$element.addClass("ui-selecting");
  2815. selectee.selecting = true;
  2816. // selectable SELECTING callback
  2817. that._trigger("selecting", event, {
  2818. selecting: selectee.element
  2819. });
  2820. }
  2821. } else {
  2822. // UNSELECT
  2823. if (selectee.selecting) {
  2824. if ((event.metaKey || event.ctrlKey) && selectee.startselected) {
  2825. selectee.$element.removeClass("ui-selecting");
  2826. selectee.selecting = false;
  2827. selectee.$element.addClass("ui-selected");
  2828. selectee.selected = true;
  2829. } else {
  2830. selectee.$element.removeClass("ui-selecting");
  2831. selectee.selecting = false;
  2832. if (selectee.startselected) {
  2833. selectee.$element.addClass("ui-unselecting");
  2834. selectee.unselecting = true;
  2835. }
  2836. // selectable UNSELECTING callback
  2837. that._trigger("unselecting", event, {
  2838. unselecting: selectee.element
  2839. });
  2840. }
  2841. }
  2842. if (selectee.selected) {
  2843. if (!event.metaKey && !event.ctrlKey && !selectee.startselected) {
  2844. selectee.$element.removeClass("ui-selected");
  2845. selectee.selected = false;
  2846. selectee.$element.addClass("ui-unselecting");
  2847. selectee.unselecting = true;
  2848. // selectable UNSELECTING callback
  2849. that._trigger("unselecting", event, {
  2850. unselecting: selectee.element
  2851. });
  2852. }
  2853. }
  2854. }
  2855. });
  2856. return false;
  2857. },
  2858. _mouseStop: function(event) {
  2859. var that = this;
  2860. this.dragged = false;
  2861. $(".ui-unselecting", this.element[0]).each(function() {
  2862. var selectee = $.data(this, "selectable-item");
  2863. selectee.$element.removeClass("ui-unselecting");
  2864. selectee.unselecting = false;
  2865. selectee.startselected = false;
  2866. that._trigger("unselected", event, {
  2867. unselected: selectee.element
  2868. });
  2869. });
  2870. $(".ui-selecting", this.element[0]).each(function() {
  2871. var selectee = $.data(this, "selectable-item");
  2872. selectee.$element.removeClass("ui-selecting").addClass("ui-selected");
  2873. selectee.selecting = false;
  2874. selectee.selected = true;
  2875. selectee.startselected = true;
  2876. that._trigger("selected", event, {
  2877. selected: selectee.element
  2878. });
  2879. });
  2880. this._trigger("stop", event);
  2881. this.helper.remove();
  2882. return false;
  2883. }
  2884. });
  2885. })(jQuery);
  2886. (function( $, undefined ) {
  2887. /*jshint loopfunc: true */
  2888. function isOverAxis( x, reference, size ) {
  2889. return ( x > reference ) && ( x < ( reference + size ) );
  2890. }
  2891. function isFloating(item) {
  2892. return (/left|right/).test(item.css("float")) || (/inline|table-cell/).test(item.css("display"));
  2893. }
  2894. $.widget("ui.sortable", $.ui.mouse, {
  2895. version: "1.10.2",
  2896. widgetEventPrefix: "sort",
  2897. ready: false,
  2898. options: {
  2899. appendTo: "parent",
  2900. axis: false,
  2901. connectWith: false,
  2902. containment: false,
  2903. cursor: "auto",
  2904. cursorAt: false,
  2905. dropOnEmpty: true,
  2906. forcePlaceholderSize: false,
  2907. forceHelperSize: false,
  2908. grid: false,
  2909. handle: false,
  2910. helper: "original",
  2911. items: "> *",
  2912. opacity: false,
  2913. placeholder: false,
  2914. revert: false,
  2915. scroll: true,
  2916. scrollSensitivity: 20,
  2917. scrollSpeed: 20,
  2918. scope: "default",
  2919. tolerance: "intersect",
  2920. zIndex: 1000,
  2921. // callbacks
  2922. activate: null,
  2923. beforeStop: null,
  2924. change: null,
  2925. deactivate: null,
  2926. out: null,
  2927. over: null,
  2928. receive: null,
  2929. remove: null,
  2930. sort: null,
  2931. start: null,
  2932. stop: null,
  2933. update: null
  2934. },
  2935. _create: function() {
  2936. var o = this.options;
  2937. this.containerCache = {};
  2938. this.element.addClass("ui-sortable");
  2939. //Get the items
  2940. this.refresh();
  2941. //Let's determine if the items are being displayed horizontally
  2942. this.floating = this.items.length ? o.axis === "x" || isFloating(this.items[0].item) : false;
  2943. //Let's determine the parent's offset
  2944. this.offset = this.element.offset();
  2945. //Initialize mouse events for interaction
  2946. this._mouseInit();
  2947. //We're ready to go
  2948. this.ready = true;
  2949. },
  2950. _destroy: function() {
  2951. this.element
  2952. .removeClass("ui-sortable ui-sortable-disabled");
  2953. this._mouseDestroy();
  2954. for ( var i = this.items.length - 1; i >= 0; i-- ) {
  2955. this.items[i].item.removeData(this.widgetName + "-item");
  2956. }
  2957. return this;
  2958. },
  2959. _setOption: function(key, value){
  2960. if ( key === "disabled" ) {
  2961. this.options[ key ] = value;
  2962. this.widget().toggleClass( "ui-sortable-disabled", !!value );
  2963. } else {
  2964. // Don't call widget base _setOption for disable as it adds ui-state-disabled class
  2965. $.Widget.prototype._setOption.apply(this, arguments);
  2966. }
  2967. },
  2968. _mouseCapture: function(event, overrideHandle) {
  2969. var currentItem = null,
  2970. validHandle = false,
  2971. that = this;
  2972. if (this.reverting) {
  2973. return false;
  2974. }
  2975. if(this.options.disabled || this.options.type === "static") {
  2976. return false;
  2977. }
  2978. //We have to refresh the items data once first
  2979. this._refreshItems(event);
  2980. //Find out if the clicked node (or one of its parents) is a actual item in this.items
  2981. $(event.target).parents().each(function() {
  2982. if($.data(this, that.widgetName + "-item") === that) {
  2983. currentItem = $(this);
  2984. return false;
  2985. }
  2986. });
  2987. if($.data(event.target, that.widgetName + "-item") === that) {
  2988. currentItem = $(event.target);
  2989. }
  2990. if(!currentItem) {
  2991. return false;
  2992. }
  2993. if(this.options.handle && !overrideHandle) {
  2994. $(this.options.handle, currentItem).find("*").addBack().each(function() {
  2995. if(this === event.target) {
  2996. validHandle = true;
  2997. }
  2998. });
  2999. if(!validHandle) {
  3000. return false;
  3001. }
  3002. }
  3003. this.currentItem = currentItem;
  3004. this._removeCurrentsFromItems();
  3005. return true;
  3006. },
  3007. _mouseStart: function(event, overrideHandle, noActivation) {
  3008. var i, body,
  3009. o = this.options;
  3010. this.currentContainer = this;
  3011. //We only need to call refreshPositions, because the refreshItems call has been moved to mouseCapture
  3012. this.refreshPositions();
  3013. //Create and append the visible helper
  3014. this.helper = this._createHelper(event);
  3015. //Cache the helper size
  3016. this._cacheHelperProportions();
  3017. /*
  3018. * - Position generation -
  3019. * This block generates everything position related - it's the core of draggables.
  3020. */
  3021. //Cache the margins of the original element
  3022. this._cacheMargins();
  3023. //Get the next scrolling parent
  3024. this.scrollParent = this.helper.scrollParent();
  3025. //The element's absolute position on the page minus margins
  3026. this.offset = this.currentItem.offset();
  3027. this.offset = {
  3028. top: this.offset.top - this.margins.top,
  3029. left: this.offset.left - this.margins.left
  3030. };
  3031. $.extend(this.offset, {
  3032. click: { //Where the click happened, relative to the element
  3033. left: event.pageX - this.offset.left,
  3034. top: event.pageY - this.offset.top
  3035. },
  3036. parent: this._getParentOffset(),
  3037. relative: this._getRelativeOffset() //This is a relative to absolute position minus the actual position calculation - only used for relative positioned helper
  3038. });
  3039. // Only after we got the offset, we can change the helper's position to absolute
  3040. // TODO: Still need to figure out a way to make relative sorting possible
  3041. this.helper.css("position", "absolute");
  3042. this.cssPosition = this.helper.css("position");
  3043. //Generate the original position
  3044. this.originalPosition = this._generatePosition(event);
  3045. this.originalPageX = event.pageX;
  3046. this.originalPageY = event.pageY;
  3047. //Adjust the mouse offset relative to the helper if "cursorAt" is supplied
  3048. (o.cursorAt && this._adjustOffsetFromHelper(o.cursorAt));
  3049. //Cache the former DOM position
  3050. this.domPosition = { prev: this.currentItem.prev()[0], parent: this.currentItem.parent()[0] };
  3051. //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
  3052. if(this.helper[0] !== this.currentItem[0]) {
  3053. this.currentItem.hide();
  3054. }
  3055. //Create the placeholder
  3056. this._createPlaceholder();
  3057. //Set a containment if given in the options
  3058. if(o.containment) {
  3059. this._setContainment();
  3060. }
  3061. if( o.cursor && o.cursor !== "auto" ) { // cursor option
  3062. body = this.document.find( "body" );
  3063. // support: IE
  3064. this.storedCursor = body.css( "cursor" );
  3065. body.css( "cursor", o.cursor );
  3066. this.storedStylesheet = $( "<style>*{ cursor: "+o.cursor+" !important; }</style>" ).appendTo( body );
  3067. }
  3068. if(o.opacity) { // opacity option
  3069. if (this.helper.css("opacity")) {
  3070. this._storedOpacity = this.helper.css("opacity");
  3071. }
  3072. this.helper.css("opacity", o.opacity);
  3073. }
  3074. if(o.zIndex) { // zIndex option
  3075. if (this.helper.css("zIndex")) {
  3076. this._storedZIndex = this.helper.css("zIndex");
  3077. }
  3078. this.helper.css("zIndex", o.zIndex);
  3079. }
  3080. //Prepare scrolling
  3081. if(this.scrollParent[0] !== document && this.scrollParent[0].tagName !== "HTML") {
  3082. this.overflowOffset = this.scrollParent.offset();
  3083. }
  3084. //Call callbacks
  3085. this._trigger("start", event, this._uiHash());
  3086. //Recache the helper size
  3087. if(!this._preserveHelperProportions) {
  3088. this._cacheHelperProportions();
  3089. }
  3090. //Post "activate" events to possible containers
  3091. if( !noActivation ) {
  3092. for ( i = this.containers.length - 1; i >= 0; i-- ) {
  3093. this.containers[ i ]._trigger( "activate", event, this._uiHash( this ) );
  3094. }
  3095. }
  3096. //Prepare possible droppables
  3097. if($.ui.ddmanager) {
  3098. $.ui.ddmanager.current = this;
  3099. }
  3100. if ($.ui.ddmanager && !o.dropBehaviour) {
  3101. $.ui.ddmanager.prepareOffsets(this, event);
  3102. }
  3103. this.dragging = true;
  3104. this.helper.addClass("ui-sortable-helper");
  3105. this._mouseDrag(event); //Execute the drag once - this causes the helper not to be visible before getting its correct position
  3106. return true;
  3107. },
  3108. _mouseDrag: function(event) {
  3109. var i, item, itemElement, intersection,
  3110. o = this.options,
  3111. scrolled = false;
  3112. //Compute the helpers position
  3113. this.position = this._generatePosition(event);
  3114. this.positionAbs = this._convertPositionTo("absolute");
  3115. if (!this.lastPositionAbs) {
  3116. this.lastPositionAbs = this.positionAbs;
  3117. }
  3118. //Do scrolling
  3119. if(this.options.scroll) {
  3120. if(this.scrollParent[0] !== document && this.scrollParent[0].tagName !== "HTML") {
  3121. if((this.overflowOffset.top + this.scrollParent[0].offsetHeight) - event.pageY < o.scrollSensitivity) {
  3122. this.scrollParent[0].scrollTop = scrolled = this.scrollParent[0].scrollTop + o.scrollSpeed;
  3123. } else if(event.pageY - this.overflowOffset.top < o.scrollSensitivity) {
  3124. this.scrollParent[0].scrollTop = scrolled = this.scrollParent[0].scrollTop - o.scrollSpeed;
  3125. }
  3126. if((this.overflowOffset.left + this.scrollParent[0].offsetWidth) - event.pageX < o.scrollSensitivity) {
  3127. this.scrollParent[0].scrollLeft = scrolled = this.scrollParent[0].scrollLeft + o.scrollSpeed;
  3128. } else if(event.pageX - this.overflowOffset.left < o.scrollSensitivity) {
  3129. this.scrollParent[0].scrollLeft = scrolled = this.scrollParent[0].scrollLeft - o.scrollSpeed;
  3130. }
  3131. } else {
  3132. if(event.pageY - $(document).scrollTop() < o.scrollSensitivity) {
  3133. scrolled = $(document).scrollTop($(document).scrollTop() - o.scrollSpeed);
  3134. } else if($(window).height() - (event.pageY - $(document).scrollTop()) < o.scrollSensitivity) {
  3135. scrolled = $(document).scrollTop($(document).scrollTop() + o.scrollSpeed);
  3136. }
  3137. if(event.pageX - $(document).scrollLeft() < o.scrollSensitivity) {
  3138. scrolled = $(document).scrollLeft($(document).scrollLeft() - o.scrollSpeed);
  3139. } else if($(window).width() - (event.pageX - $(document).scrollLeft()) < o.scrollSensitivity) {
  3140. scrolled = $(document).scrollLeft($(document).scrollLeft() + o.scrollSpeed);
  3141. }
  3142. }
  3143. if(scrolled !== false && $.ui.ddmanager && !o.dropBehaviour) {
  3144. $.ui.ddmanager.prepareOffsets(this, event);
  3145. }
  3146. }
  3147. //Regenerate the absolute position used for position checks
  3148. this.positionAbs = this._convertPositionTo("absolute");
  3149. //Set the helper position
  3150. if(!this.options.axis || this.options.axis !== "y") {
  3151. this.helper[0].style.left = this.position.left+"px";
  3152. }
  3153. if(!this.options.axis || this.options.axis !== "x") {
  3154. this.helper[0].style.top = this.position.top+"px";
  3155. }
  3156. //Rearrange
  3157. for (i = this.items.length - 1; i >= 0; i--) {
  3158. //Cache variables and intersection, continue if no intersection
  3159. item = this.items[i];
  3160. itemElement = item.item[0];
  3161. intersection = this._intersectsWithPointer(item);
  3162. if (!intersection) {
  3163. continue;
  3164. }
  3165. // Only put the placeholder inside the current Container, skip all
  3166. // items form other containers. This works because when moving
  3167. // an item from one container to another the
  3168. // currentContainer is switched before the placeholder is moved.
  3169. //
  3170. // Without this moving items in "sub-sortables" can cause the placeholder to jitter
  3171. // beetween the outer and inner container.
  3172. if (item.instance !== this.currentContainer) {
  3173. continue;
  3174. }
  3175. // cannot intersect with itself
  3176. // no useless actions that have been done before
  3177. // no action if the item moved is the parent of the item checked
  3178. if (itemElement !== this.currentItem[0] &&
  3179. this.placeholder[intersection === 1 ? "next" : "prev"]()[0] !== itemElement &&
  3180. !$.contains(this.placeholder[0], itemElement) &&
  3181. (this.options.type === "semi-dynamic" ? !$.contains(this.element[0], itemElement) : true)
  3182. ) {
  3183. this.direction = intersection === 1 ? "down" : "up";
  3184. if (this.options.tolerance === "pointer" || this._intersectsWithSides(item)) {
  3185. this._rearrange(event, item);
  3186. } else {
  3187. break;
  3188. }
  3189. this._trigger("change", event, this._uiHash());
  3190. break;
  3191. }
  3192. }
  3193. //Post events to containers
  3194. this._contactContainers(event);
  3195. //Interconnect with droppables
  3196. if($.ui.ddmanager) {
  3197. $.ui.ddmanager.drag(this, event);
  3198. }
  3199. //Call callbacks
  3200. this._trigger("sort", event, this._uiHash());
  3201. this.lastPositionAbs = this.positionAbs;
  3202. return false;
  3203. },
  3204. _mouseStop: function(event, noPropagation) {
  3205. if(!event) {
  3206. return;
  3207. }
  3208. //If we are using droppables, inform the manager about the drop
  3209. if ($.ui.ddmanager && !this.options.dropBehaviour) {
  3210. $.ui.ddmanager.drop(this, event);
  3211. }
  3212. if(this.options.revert) {
  3213. var that = this,
  3214. cur = this.placeholder.offset(),
  3215. axis = this.options.axis,
  3216. animation = {};
  3217. if ( !axis || axis === "x" ) {
  3218. animation.left = cur.left - this.offset.parent.left - this.margins.left + (this.offsetParent[0] === document.body ? 0 : this.offsetParent[0].scrollLeft);
  3219. }
  3220. if ( !axis || axis === "y" ) {
  3221. animation.top = cur.top - this.offset.parent.top - this.margins.top + (this.offsetParent[0] === document.body ? 0 : this.offsetParent[0].scrollTop);
  3222. }
  3223. this.reverting = true;
  3224. $(this.helper).animate( animation, parseInt(this.options.revert, 10) || 500, function() {
  3225. that._clear(event);
  3226. });
  3227. } else {
  3228. this._clear(event, noPropagation);
  3229. }
  3230. return false;
  3231. },
  3232. cancel: function() {
  3233. if(this.dragging) {
  3234. this._mouseUp({ target: null });
  3235. if(this.options.helper === "original") {
  3236. this.currentItem.css(this._storedCSS).removeClass("ui-sortable-helper");
  3237. } else {
  3238. this.currentItem.show();
  3239. }
  3240. //Post deactivating events to containers
  3241. for (var i = this.containers.length - 1; i >= 0; i--){
  3242. this.containers[i]._trigger("deactivate", null, this._uiHash(this));
  3243. if(this.containers[i].containerCache.over) {
  3244. this.containers[i]._trigger("out", null, this._uiHash(this));
  3245. this.containers[i].containerCache.over = 0;
  3246. }
  3247. }
  3248. }
  3249. if (this.placeholder) {
  3250. //$(this.placeholder[0]).remove(); would have been the jQuery way - unfortunately, it unbinds ALL events from the original node!
  3251. if(this.placeholder[0].parentNode) {
  3252. this.placeholder[0].parentNode.removeChild(this.placeholder[0]);
  3253. }
  3254. if(this.options.helper !== "original" && this.helper && this.helper[0].parentNode) {
  3255. this.helper.remove();
  3256. }
  3257. $.extend(this, {
  3258. helper: null,
  3259. dragging: false,
  3260. reverting: false,
  3261. _noFinalSort: null
  3262. });
  3263. if(this.domPosition.prev) {
  3264. $(this.domPosition.prev).after(this.currentItem);
  3265. } else {
  3266. $(this.domPosition.parent).prepend(this.currentItem);
  3267. }
  3268. }
  3269. return this;
  3270. },
  3271. serialize: function(o) {
  3272. var items = this._getItemsAsjQuery(o && o.connected),
  3273. str = [];
  3274. o = o || {};
  3275. $(items).each(function() {
  3276. var res = ($(o.item || this).attr(o.attribute || "id") || "").match(o.expression || (/(.+)[\-=_](.+)/));
  3277. if (res) {
  3278. str.push((o.key || res[1]+"[]")+"="+(o.key && o.expression ? res[1] : res[2]));
  3279. }
  3280. });
  3281. if(!str.length && o.key) {
  3282. str.push(o.key + "=");
  3283. }
  3284. return str.join("&");
  3285. },
  3286. toArray: function(o) {
  3287. var items = this._getItemsAsjQuery(o && o.connected),
  3288. ret = [];
  3289. o = o || {};
  3290. items.each(function() { ret.push($(o.item || this).attr(o.attribute || "id") || ""); });
  3291. return ret;
  3292. },
  3293. /* Be careful with the following core functions */
  3294. _intersectsWith: function(item) {
  3295. var x1 = this.positionAbs.left,
  3296. x2 = x1 + this.helperProportions.width,
  3297. y1 = this.positionAbs.top,
  3298. y2 = y1 + this.helperProportions.height,
  3299. l = item.left,
  3300. r = l + item.width,
  3301. t = item.top,
  3302. b = t + item.height,
  3303. dyClick = this.offset.click.top,
  3304. dxClick = this.offset.click.left,
  3305. isOverElement = (y1 + dyClick) > t && (y1 + dyClick) < b && (x1 + dxClick) > l && (x1 + dxClick) < r;
  3306. if ( this.options.tolerance === "pointer" ||
  3307. this.options.forcePointerForContainers ||
  3308. (this.options.tolerance !== "pointer" && this.helperProportions[this.floating ? "width" : "height"] > item[this.floating ? "width" : "height"])
  3309. ) {
  3310. return isOverElement;
  3311. } else {
  3312. return (l < x1 + (this.helperProportions.width / 2) && // Right Half
  3313. x2 - (this.helperProportions.width / 2) < r && // Left Half
  3314. t < y1 + (this.helperProportions.height / 2) && // Bottom Half
  3315. y2 - (this.helperProportions.height / 2) < b ); // Top Half
  3316. }
  3317. },
  3318. _intersectsWithPointer: function(item) {
  3319. var isOverElementHeight = (this.options.axis === "x") || isOverAxis(this.positionAbs.top + this.offset.click.top, item.top, item.height),
  3320. isOverElementWidth = (this.options.axis === "y") || isOverAxis(this.positionAbs.left + this.offset.click.left, item.left, item.width),
  3321. isOverElement = isOverElementHeight && isOverElementWidth,
  3322. verticalDirection = this._getDragVerticalDirection(),
  3323. horizontalDirection = this._getDragHorizontalDirection();
  3324. if (!isOverElement) {
  3325. return false;
  3326. }
  3327. return this.floating ?
  3328. ( ((horizontalDirection && horizontalDirection === "right") || verticalDirection === "down") ? 2 : 1 )
  3329. : ( verticalDirection && (verticalDirection === "down" ? 2 : 1) );
  3330. },
  3331. _intersectsWithSides: function(item) {
  3332. var isOverBottomHalf = isOverAxis(this.positionAbs.top + this.offset.click.top, item.top + (item.height/2), item.height),
  3333. isOverRightHalf = isOverAxis(this.positionAbs.left + this.offset.click.left, item.left + (item.width/2), item.width),
  3334. verticalDirection = this._getDragVerticalDirection(),
  3335. horizontalDirection = this._getDragHorizontalDirection();
  3336. if (this.floating && horizontalDirection) {
  3337. return ((horizontalDirection === "right" && isOverRightHalf) || (horizontalDirection === "left" && !isOverRightHalf));
  3338. } else {
  3339. return verticalDirection && ((verticalDirection === "down" && isOverBottomHalf) || (verticalDirection === "up" && !isOverBottomHalf));
  3340. }
  3341. },
  3342. _getDragVerticalDirection: function() {
  3343. var delta = this.positionAbs.top - this.lastPositionAbs.top;
  3344. return delta !== 0 && (delta > 0 ? "down" : "up");
  3345. },
  3346. _getDragHorizontalDirection: function() {
  3347. var delta = this.positionAbs.left - this.lastPositionAbs.left;
  3348. return delta !== 0 && (delta > 0 ? "right" : "left");
  3349. },
  3350. refresh: function(event) {
  3351. this._refreshItems(event);
  3352. this.refreshPositions();
  3353. return this;
  3354. },
  3355. _connectWith: function() {
  3356. var options = this.options;
  3357. return options.connectWith.constructor === String ? [options.connectWith] : options.connectWith;
  3358. },
  3359. _getItemsAsjQuery: function(connected) {
  3360. var i, j, cur, inst,
  3361. items = [],
  3362. queries = [],
  3363. connectWith = this._connectWith();
  3364. if(connectWith && connected) {
  3365. for (i = connectWith.length - 1; i >= 0; i--){
  3366. cur = $(connectWith[i]);
  3367. for ( j = cur.length - 1; j >= 0; j--){
  3368. inst = $.data(cur[j], this.widgetFullName);
  3369. if(inst && inst !== this && !inst.options.disabled) {
  3370. 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]);
  3371. }
  3372. }
  3373. }
  3374. }
  3375. 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]);
  3376. for (i = queries.length - 1; i >= 0; i--){
  3377. queries[i][0].each(function() {
  3378. items.push(this);
  3379. });
  3380. }
  3381. return $(items);
  3382. },
  3383. _removeCurrentsFromItems: function() {
  3384. var list = this.currentItem.find(":data(" + this.widgetName + "-item)");
  3385. this.items = $.grep(this.items, function (item) {
  3386. for (var j=0; j < list.length; j++) {
  3387. if(list[j] === item.item[0]) {
  3388. return false;
  3389. }
  3390. }
  3391. return true;
  3392. });
  3393. },
  3394. _refreshItems: function(event) {
  3395. this.items = [];
  3396. this.containers = [this];
  3397. var i, j, cur, inst, targetData, _queries, item, queriesLength,
  3398. items = this.items,
  3399. queries = [[$.isFunction(this.options.items) ? this.options.items.call(this.element[0], event, { item: this.currentItem }) : $(this.options.items, this.element), this]],
  3400. connectWith = this._connectWith();
  3401. if(connectWith && this.ready) { //Shouldn't be run the first time through due to massive slow-down
  3402. for (i = connectWith.length - 1; i >= 0; i--){
  3403. cur = $(connectWith[i]);
  3404. for (j = cur.length - 1; j >= 0; j--){
  3405. inst = $.data(cur[j], this.widgetFullName);
  3406. if(inst && inst !== this && !inst.options.disabled) {
  3407. queries.push([$.isFunction(inst.options.items) ? inst.options.items.call(inst.element[0], event, { item: this.currentItem }) : $(inst.options.items, inst.element), inst]);
  3408. this.containers.push(inst);
  3409. }
  3410. }
  3411. }
  3412. }
  3413. for (i = queries.length - 1; i >= 0; i--) {
  3414. targetData = queries[i][1];
  3415. _queries = queries[i][0];
  3416. for (j=0, queriesLength = _queries.length; j < queriesLength; j++) {
  3417. item = $(_queries[j]);
  3418. item.data(this.widgetName + "-item", targetData); // Data for target checking (mouse manager)
  3419. items.push({
  3420. item: item,
  3421. instance: targetData,
  3422. width: 0, height: 0,
  3423. left: 0, top: 0
  3424. });
  3425. }
  3426. }
  3427. },
  3428. refreshPositions: function(fast) {
  3429. //This has to be redone because due to the item being moved out/into the offsetParent, the offsetParent's position will change
  3430. if(this.offsetParent && this.helper) {
  3431. this.offset.parent = this._getParentOffset();
  3432. }
  3433. var i, item, t, p;
  3434. for (i = this.items.length - 1; i >= 0; i--){
  3435. item = this.items[i];
  3436. //We ignore calculating positions of all connected containers when we're not over them
  3437. if(item.instance !== this.currentContainer && this.currentContainer && item.item[0] !== this.currentItem[0]) {
  3438. continue;
  3439. }
  3440. t = this.options.toleranceElement ? $(this.options.toleranceElement, item.item) : item.item;
  3441. if (!fast) {
  3442. item.width = t.outerWidth();
  3443. item.height = t.outerHeight();
  3444. }
  3445. p = t.offset();
  3446. item.left = p.left;
  3447. item.top = p.top;
  3448. }
  3449. if(this.options.custom && this.options.custom.refreshContainers) {
  3450. this.options.custom.refreshContainers.call(this);
  3451. } else {
  3452. for (i = this.containers.length - 1; i >= 0; i--){
  3453. p = this.containers[i].element.offset();
  3454. this.containers[i].containerCache.left = p.left;
  3455. this.containers[i].containerCache.top = p.top;
  3456. this.containers[i].containerCache.width = this.containers[i].element.outerWidth();
  3457. this.containers[i].containerCache.height = this.containers[i].element.outerHeight();
  3458. }
  3459. }
  3460. return this;
  3461. },
  3462. _createPlaceholder: function(that) {
  3463. that = that || this;
  3464. var className,
  3465. o = that.options;
  3466. if(!o.placeholder || o.placeholder.constructor === String) {
  3467. className = o.placeholder;
  3468. o.placeholder = {
  3469. element: function() {
  3470. var nodeName = that.currentItem[0].nodeName.toLowerCase(),
  3471. element = $( that.document[0].createElement( nodeName ) )
  3472. .addClass(className || that.currentItem[0].className+" ui-sortable-placeholder")
  3473. .removeClass("ui-sortable-helper");
  3474. if ( nodeName === "tr" ) {
  3475. // Use a high colspan to force the td to expand the full
  3476. // width of the table (browsers are smart enough to
  3477. // handle this properly)
  3478. element.append( "<td colspan='99'>&#160;</td>" );
  3479. } else if ( nodeName === "img" ) {
  3480. element.attr( "src", that.currentItem.attr( "src" ) );
  3481. }
  3482. if ( !className ) {
  3483. element.css( "visibility", "hidden" );
  3484. }
  3485. return element;
  3486. },
  3487. update: function(container, p) {
  3488. // 1. If a className is set as 'placeholder option, we don't force sizes - the class is responsible for that
  3489. // 2. The option 'forcePlaceholderSize can be enabled to force it even if a class name is specified
  3490. if(className && !o.forcePlaceholderSize) {
  3491. return;
  3492. }
  3493. //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
  3494. if(!p.height()) { p.height(that.currentItem.innerHeight() - parseInt(that.currentItem.css("paddingTop")||0, 10) - parseInt(that.currentItem.css("paddingBottom")||0, 10)); }
  3495. if(!p.width()) { p.width(that.currentItem.innerWidth() - parseInt(that.currentItem.css("paddingLeft")||0, 10) - parseInt(that.currentItem.css("paddingRight")||0, 10)); }
  3496. }
  3497. };
  3498. }
  3499. //Create the placeholder
  3500. that.placeholder = $(o.placeholder.element.call(that.element, that.currentItem));
  3501. //Append it after the actual current item
  3502. that.currentItem.after(that.placeholder);
  3503. //Update the size of the placeholder (TODO: Logic to fuzzy, see line 316/317)
  3504. o.placeholder.update(that, that.placeholder);
  3505. },
  3506. _contactContainers: function(event) {
  3507. var i, j, dist, itemWithLeastDistance, posProperty, sizeProperty, base, cur, nearBottom, floating,
  3508. innermostContainer = null,
  3509. innermostIndex = null;
  3510. // get innermost container that intersects with item
  3511. for (i = this.containers.length - 1; i >= 0; i--) {
  3512. // never consider a container that's located within the item itself
  3513. if($.contains(this.currentItem[0], this.containers[i].element[0])) {
  3514. continue;
  3515. }
  3516. if(this._intersectsWith(this.containers[i].containerCache)) {
  3517. // if we've already found a container and it's more "inner" than this, then continue
  3518. if(innermostContainer && $.contains(this.containers[i].element[0], innermostContainer.element[0])) {
  3519. continue;
  3520. }
  3521. innermostContainer = this.containers[i];
  3522. innermostIndex = i;
  3523. } else {
  3524. // container doesn't intersect. trigger "out" event if necessary
  3525. if(this.containers[i].containerCache.over) {
  3526. this.containers[i]._trigger("out", event, this._uiHash(this));
  3527. this.containers[i].containerCache.over = 0;
  3528. }
  3529. }
  3530. }
  3531. // if no intersecting containers found, return
  3532. if(!innermostContainer) {
  3533. return;
  3534. }
  3535. // move the item into the container if it's not there already
  3536. if(this.containers.length === 1) {
  3537. if (!this.containers[innermostIndex].containerCache.over) {
  3538. this.containers[innermostIndex]._trigger("over", event, this._uiHash(this));
  3539. this.containers[innermostIndex].containerCache.over = 1;
  3540. }
  3541. } else {
  3542. //When entering a new container, we will find the item with the least distance and append our item near it
  3543. dist = 10000;
  3544. itemWithLeastDistance = null;
  3545. floating = innermostContainer.floating || isFloating(this.currentItem);
  3546. posProperty = floating ? "left" : "top";
  3547. sizeProperty = floating ? "width" : "height";
  3548. base = this.positionAbs[posProperty] + this.offset.click[posProperty];
  3549. for (j = this.items.length - 1; j >= 0; j--) {
  3550. if(!$.contains(this.containers[innermostIndex].element[0], this.items[j].item[0])) {
  3551. continue;
  3552. }
  3553. if(this.items[j].item[0] === this.currentItem[0]) {
  3554. continue;
  3555. }
  3556. if (floating && !isOverAxis(this.positionAbs.top + this.offset.click.top, this.items[j].top, this.items[j].height)) {
  3557. continue;
  3558. }
  3559. cur = this.items[j].item.offset()[posProperty];
  3560. nearBottom = false;
  3561. if(Math.abs(cur - base) > Math.abs(cur + this.items[j][sizeProperty] - base)){
  3562. nearBottom = true;
  3563. cur += this.items[j][sizeProperty];
  3564. }
  3565. if(Math.abs(cur - base) < dist) {
  3566. dist = Math.abs(cur - base); itemWithLeastDistance = this.items[j];
  3567. this.direction = nearBottom ? "up": "down";
  3568. }
  3569. }
  3570. //Check if dropOnEmpty is enabled
  3571. if(!itemWithLeastDistance && !this.options.dropOnEmpty) {
  3572. return;
  3573. }
  3574. if(this.currentContainer === this.containers[innermostIndex]) {
  3575. return;
  3576. }
  3577. itemWithLeastDistance ? this._rearrange(event, itemWithLeastDistance, null, true) : this._rearrange(event, null, this.containers[innermostIndex].element, true);
  3578. this._trigger("change", event, this._uiHash());
  3579. this.containers[innermostIndex]._trigger("change", event, this._uiHash(this));
  3580. this.currentContainer = this.containers[innermostIndex];
  3581. //Update the placeholder
  3582. this.options.placeholder.update(this.currentContainer, this.placeholder);
  3583. this.containers[innermostIndex]._trigger("over", event, this._uiHash(this));
  3584. this.containers[innermostIndex].containerCache.over = 1;
  3585. }
  3586. },
  3587. _createHelper: function(event) {
  3588. var o = this.options,
  3589. helper = $.isFunction(o.helper) ? $(o.helper.apply(this.element[0], [event, this.currentItem])) : (o.helper === "clone" ? this.currentItem.clone() : this.currentItem);
  3590. //Add the helper to the DOM if that didn't happen already
  3591. if(!helper.parents("body").length) {
  3592. $(o.appendTo !== "parent" ? o.appendTo : this.currentItem[0].parentNode)[0].appendChild(helper[0]);
  3593. }
  3594. if(helper[0] === this.currentItem[0]) {
  3595. 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") };
  3596. }
  3597. if(!helper[0].style.width || o.forceHelperSize) {
  3598. helper.width(this.currentItem.width());
  3599. }
  3600. if(!helper[0].style.height || o.forceHelperSize) {
  3601. helper.height(this.currentItem.height());
  3602. }
  3603. return helper;
  3604. },
  3605. _adjustOffsetFromHelper: function(obj) {
  3606. if (typeof obj === "string") {
  3607. obj = obj.split(" ");
  3608. }
  3609. if ($.isArray(obj)) {
  3610. obj = {left: +obj[0], top: +obj[1] || 0};
  3611. }
  3612. if ("left" in obj) {
  3613. this.offset.click.left = obj.left + this.margins.left;
  3614. }
  3615. if ("right" in obj) {
  3616. this.offset.click.left = this.helperProportions.width - obj.right + this.margins.left;
  3617. }
  3618. if ("top" in obj) {
  3619. this.offset.click.top = obj.top + this.margins.top;
  3620. }
  3621. if ("bottom" in obj) {
  3622. this.offset.click.top = this.helperProportions.height - obj.bottom + this.margins.top;
  3623. }
  3624. },
  3625. _getParentOffset: function() {
  3626. //Get the offsetParent and cache its position
  3627. this.offsetParent = this.helper.offsetParent();
  3628. var po = this.offsetParent.offset();
  3629. // This is a special case where we need to modify a offset calculated on start, since the following happened:
  3630. // 1. The position of the helper is absolute, so it's position is calculated based on the next positioned parent
  3631. // 2. The actual offset parent is a child of the scroll parent, and the scroll parent isn't the document, which means that
  3632. // the scroll is included in the initial calculation of the offset of the parent, and never recalculated upon drag
  3633. if(this.cssPosition === "absolute" && this.scrollParent[0] !== document && $.contains(this.scrollParent[0], this.offsetParent[0])) {
  3634. po.left += this.scrollParent.scrollLeft();
  3635. po.top += this.scrollParent.scrollTop();
  3636. }
  3637. // This needs to be actually done for all browsers, since pageX/pageY includes this information
  3638. // with an ugly IE fix
  3639. if( this.offsetParent[0] === document.body || (this.offsetParent[0].tagName && this.offsetParent[0].tagName.toLowerCase() === "html" && $.ui.ie)) {
  3640. po = { top: 0, left: 0 };
  3641. }
  3642. return {
  3643. top: po.top + (parseInt(this.offsetParent.css("borderTopWidth"),10) || 0),
  3644. left: po.left + (parseInt(this.offsetParent.css("borderLeftWidth"),10) || 0)
  3645. };
  3646. },
  3647. _getRelativeOffset: function() {
  3648. if(this.cssPosition === "relative") {
  3649. var p = this.currentItem.position();
  3650. return {
  3651. top: p.top - (parseInt(this.helper.css("top"),10) || 0) + this.scrollParent.scrollTop(),
  3652. left: p.left - (parseInt(this.helper.css("left"),10) || 0) + this.scrollParent.scrollLeft()
  3653. };
  3654. } else {
  3655. return { top: 0, left: 0 };
  3656. }
  3657. },
  3658. _cacheMargins: function() {
  3659. this.margins = {
  3660. left: (parseInt(this.currentItem.css("marginLeft"),10) || 0),
  3661. top: (parseInt(this.currentItem.css("marginTop"),10) || 0)
  3662. };
  3663. },
  3664. _cacheHelperProportions: function() {
  3665. this.helperProportions = {
  3666. width: this.helper.outerWidth(),
  3667. height: this.helper.outerHeight()
  3668. };
  3669. },
  3670. _setContainment: function() {
  3671. var ce, co, over,
  3672. o = this.options;
  3673. if(o.containment === "parent") {
  3674. o.containment = this.helper[0].parentNode;
  3675. }
  3676. if(o.containment === "document" || o.containment === "window") {
  3677. this.containment = [
  3678. 0 - this.offset.relative.left - this.offset.parent.left,
  3679. 0 - this.offset.relative.top - this.offset.parent.top,
  3680. $(o.containment === "document" ? document : window).width() - this.helperProportions.width - this.margins.left,
  3681. ($(o.containment === "document" ? document : window).height() || document.body.parentNode.scrollHeight) - this.helperProportions.height - this.margins.top
  3682. ];
  3683. }
  3684. if(!(/^(document|window|parent)$/).test(o.containment)) {
  3685. ce = $(o.containment)[0];
  3686. co = $(o.containment).offset();
  3687. over = ($(ce).css("overflow") !== "hidden");
  3688. this.containment = [
  3689. co.left + (parseInt($(ce).css("borderLeftWidth"),10) || 0) + (parseInt($(ce).css("paddingLeft"),10) || 0) - this.margins.left,
  3690. co.top + (parseInt($(ce).css("borderTopWidth"),10) || 0) + (parseInt($(ce).css("paddingTop"),10) || 0) - this.margins.top,
  3691. 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,
  3692. 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
  3693. ];
  3694. }
  3695. },
  3696. _convertPositionTo: function(d, pos) {
  3697. if(!pos) {
  3698. pos = this.position;
  3699. }
  3700. var mod = d === "absolute" ? 1 : -1,
  3701. scroll = this.cssPosition === "absolute" && !(this.scrollParent[0] !== document && $.contains(this.scrollParent[0], this.offsetParent[0])) ? this.offsetParent : this.scrollParent,
  3702. scrollIsRootNode = (/(html|body)/i).test(scroll[0].tagName);
  3703. return {
  3704. top: (
  3705. pos.top + // The absolute mouse position
  3706. this.offset.relative.top * mod + // Only for relative positioned nodes: Relative offset from element to offset parent
  3707. this.offset.parent.top * mod - // The offsetParent's offset without borders (offset + border)
  3708. ( ( this.cssPosition === "fixed" ? -this.scrollParent.scrollTop() : ( scrollIsRootNode ? 0 : scroll.scrollTop() ) ) * mod)
  3709. ),
  3710. left: (
  3711. pos.left + // The absolute mouse position
  3712. this.offset.relative.left * mod + // Only for relative positioned nodes: Relative offset from element to offset parent
  3713. this.offset.parent.left * mod - // The offsetParent's offset without borders (offset + border)
  3714. ( ( this.cssPosition === "fixed" ? -this.scrollParent.scrollLeft() : scrollIsRootNode ? 0 : scroll.scrollLeft() ) * mod)
  3715. )
  3716. };
  3717. },
  3718. _generatePosition: function(event) {
  3719. var top, left,
  3720. o = this.options,
  3721. pageX = event.pageX,
  3722. pageY = event.pageY,
  3723. 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);
  3724. // This is another very weird special case that only happens for relative elements:
  3725. // 1. If the css position is relative
  3726. // 2. and the scroll parent is the document or similar to the offset parent
  3727. // we have to refresh the relative offset during the scroll so there are no jumps
  3728. if(this.cssPosition === "relative" && !(this.scrollParent[0] !== document && this.scrollParent[0] !== this.offsetParent[0])) {
  3729. this.offset.relative = this._getRelativeOffset();
  3730. }
  3731. /*
  3732. * - Position constraining -
  3733. * Constrain the position to a mix of grid, containment.
  3734. */
  3735. if(this.originalPosition) { //If we are not dragging yet, we won't check for options
  3736. if(this.containment) {
  3737. if(event.pageX - this.offset.click.left < this.containment[0]) {
  3738. pageX = this.containment[0] + this.offset.click.left;
  3739. }
  3740. if(event.pageY - this.offset.click.top < this.containment[1]) {
  3741. pageY = this.containment[1] + this.offset.click.top;
  3742. }
  3743. if(event.pageX - this.offset.click.left > this.containment[2]) {
  3744. pageX = this.containment[2] + this.offset.click.left;
  3745. }
  3746. if(event.pageY - this.offset.click.top > this.containment[3]) {
  3747. pageY = this.containment[3] + this.offset.click.top;
  3748. }
  3749. }
  3750. if(o.grid) {
  3751. top = this.originalPageY + Math.round((pageY - this.originalPageY) / o.grid[1]) * o.grid[1];
  3752. 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;
  3753. left = this.originalPageX + Math.round((pageX - this.originalPageX) / o.grid[0]) * o.grid[0];
  3754. 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;
  3755. }
  3756. }
  3757. return {
  3758. top: (
  3759. pageY - // The absolute mouse position
  3760. this.offset.click.top - // Click offset (relative to the element)
  3761. this.offset.relative.top - // Only for relative positioned nodes: Relative offset from element to offset parent
  3762. this.offset.parent.top + // The offsetParent's offset without borders (offset + border)
  3763. ( ( this.cssPosition === "fixed" ? -this.scrollParent.scrollTop() : ( scrollIsRootNode ? 0 : scroll.scrollTop() ) ))
  3764. ),
  3765. left: (
  3766. pageX - // The absolute mouse position
  3767. this.offset.click.left - // Click offset (relative to the element)
  3768. this.offset.relative.left - // Only for relative positioned nodes: Relative offset from element to offset parent
  3769. this.offset.parent.left + // The offsetParent's offset without borders (offset + border)
  3770. ( ( this.cssPosition === "fixed" ? -this.scrollParent.scrollLeft() : scrollIsRootNode ? 0 : scroll.scrollLeft() ))
  3771. )
  3772. };
  3773. },
  3774. _rearrange: function(event, i, a, hardRefresh) {
  3775. 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));
  3776. //Various things done here to improve the performance:
  3777. // 1. we create a setTimeout, that calls refreshPositions
  3778. // 2. on the instance, we have a counter variable, that get's higher after every append
  3779. // 3. on the local scope, we copy the counter variable, and check in the timeout, if it's still the same
  3780. // 4. this lets only the last addition to the timeout stack through
  3781. this.counter = this.counter ? ++this.counter : 1;
  3782. var counter = this.counter;
  3783. this._delay(function() {
  3784. if(counter === this.counter) {
  3785. this.refreshPositions(!hardRefresh); //Precompute after each DOM insertion, NOT on mousemove
  3786. }
  3787. });
  3788. },
  3789. _clear: function(event, noPropagation) {
  3790. this.reverting = false;
  3791. // We delay all events that have to be triggered to after the point where the placeholder has been removed and
  3792. // everything else normalized again
  3793. var i,
  3794. delayedTriggers = [];
  3795. // We first have to update the dom position of the actual currentItem
  3796. // Note: don't do it if the current item is already removed (by a user), or it gets reappended (see #4088)
  3797. if(!this._noFinalSort && this.currentItem.parent().length) {
  3798. this.placeholder.before(this.currentItem);
  3799. }
  3800. this._noFinalSort = null;
  3801. if(this.helper[0] === this.currentItem[0]) {
  3802. for(i in this._storedCSS) {
  3803. if(this._storedCSS[i] === "auto" || this._storedCSS[i] === "static") {
  3804. this._storedCSS[i] = "";
  3805. }
  3806. }
  3807. this.currentItem.css(this._storedCSS).removeClass("ui-sortable-helper");
  3808. } else {
  3809. this.currentItem.show();
  3810. }
  3811. if(this.fromOutside && !noPropagation) {
  3812. delayedTriggers.push(function(event) { this._trigger("receive", event, this._uiHash(this.fromOutside)); });
  3813. }
  3814. if((this.fromOutside || this.domPosition.prev !== this.currentItem.prev().not(".ui-sortable-helper")[0] || this.domPosition.parent !== this.currentItem.parent()[0]) && !noPropagation) {
  3815. delayedTriggers.push(function(event) { this._trigger("update", event, this._uiHash()); }); //Trigger update callback if the DOM position has changed
  3816. }
  3817. // Check if the items Container has Changed and trigger appropriate
  3818. // events.
  3819. if (this !== this.currentContainer) {
  3820. if(!noPropagation) {
  3821. delayedTriggers.push(function(event) { this._trigger("remove", event, this._uiHash()); });
  3822. delayedTriggers.push((function(c) { return function(event) { c._trigger("receive", event, this._uiHash(this)); }; }).call(this, this.currentContainer));
  3823. delayedTriggers.push((function(c) { return function(event) { c._trigger("update", event, this._uiHash(this)); }; }).call(this, this.currentContainer));
  3824. }
  3825. }
  3826. //Post events to containers
  3827. for (i = this.containers.length - 1; i >= 0; i--){
  3828. if(!noPropagation) {
  3829. delayedTriggers.push((function(c) { return function(event) { c._trigger("deactivate", event, this._uiHash(this)); }; }).call(this, this.containers[i]));
  3830. }
  3831. if(this.containers[i].containerCache.over) {
  3832. delayedTriggers.push((function(c) { return function(event) { c._trigger("out", event, this._uiHash(this)); }; }).call(this, this.containers[i]));
  3833. this.containers[i].containerCache.over = 0;
  3834. }
  3835. }
  3836. //Do what was originally in plugins
  3837. if ( this.storedCursor ) {
  3838. this.document.find( "body" ).css( "cursor", this.storedCursor );
  3839. this.storedStylesheet.remove();
  3840. }
  3841. if(this._storedOpacity) {
  3842. this.helper.css("opacity", this._storedOpacity);
  3843. }
  3844. if(this._storedZIndex) {
  3845. this.helper.css("zIndex", this._storedZIndex === "auto" ? "" : this._storedZIndex);
  3846. }
  3847. this.dragging = false;
  3848. if(this.cancelHelperRemoval) {
  3849. if(!noPropagation) {
  3850. this._trigger("beforeStop", event, this._uiHash());
  3851. for (i=0; i < delayedTriggers.length; i++) {
  3852. delayedTriggers[i].call(this, event);
  3853. } //Trigger all delayed events
  3854. this._trigger("stop", event, this._uiHash());
  3855. }
  3856. this.fromOutside = false;
  3857. return false;
  3858. }
  3859. if(!noPropagation) {
  3860. this._trigger("beforeStop", event, this._uiHash());
  3861. }
  3862. //$(this.placeholder[0]).remove(); would have been the jQuery way - unfortunately, it unbinds ALL events from the original node!
  3863. this.placeholder[0].parentNode.removeChild(this.placeholder[0]);
  3864. if(this.helper[0] !== this.currentItem[0]) {
  3865. this.helper.remove();
  3866. }
  3867. this.helper = null;
  3868. if(!noPropagation) {
  3869. for (i=0; i < delayedTriggers.length; i++) {
  3870. delayedTriggers[i].call(this, event);
  3871. } //Trigger all delayed events
  3872. this._trigger("stop", event, this._uiHash());
  3873. }
  3874. this.fromOutside = false;
  3875. return true;
  3876. },
  3877. _trigger: function() {
  3878. if ($.Widget.prototype._trigger.apply(this, arguments) === false) {
  3879. this.cancel();
  3880. }
  3881. },
  3882. _uiHash: function(_inst) {
  3883. var inst = _inst || this;
  3884. return {
  3885. helper: inst.helper,
  3886. placeholder: inst.placeholder || $([]),
  3887. position: inst.position,
  3888. originalPosition: inst.originalPosition,
  3889. offset: inst.positionAbs,
  3890. item: inst.currentItem,
  3891. sender: _inst ? _inst.element : null
  3892. };
  3893. }
  3894. });
  3895. })(jQuery);
  3896. (function($, undefined) {
  3897. var dataSpace = "ui-effects-";
  3898. $.effects = {
  3899. effect: {}
  3900. };
  3901. /*!
  3902. * jQuery Color Animations v2.1.2
  3903. * https://github.com/jquery/jquery-color
  3904. *
  3905. * Copyright 2013 jQuery Foundation and other contributors
  3906. * Released under the MIT license.
  3907. * http://jquery.org/license
  3908. *
  3909. * Date: Wed Jan 16 08:47:09 2013 -0600
  3910. */
  3911. (function( jQuery, undefined ) {
  3912. var stepHooks = "backgroundColor borderBottomColor borderLeftColor borderRightColor borderTopColor color columnRuleColor outlineColor textDecorationColor textEmphasisColor",
  3913. // plusequals test for += 100 -= 100
  3914. rplusequals = /^([\-+])=\s*(\d+\.?\d*)/,
  3915. // a set of RE's that can match strings and generate color tuples.
  3916. stringParsers = [{
  3917. re: /rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(?:,\s*(\d?(?:\.\d+)?)\s*)?\)/,
  3918. parse: function( execResult ) {
  3919. return [
  3920. execResult[ 1 ],
  3921. execResult[ 2 ],
  3922. execResult[ 3 ],
  3923. execResult[ 4 ]
  3924. ];
  3925. }
  3926. }, {
  3927. re: /rgba?\(\s*(\d+(?:\.\d+)?)\%\s*,\s*(\d+(?:\.\d+)?)\%\s*,\s*(\d+(?:\.\d+)?)\%\s*(?:,\s*(\d?(?:\.\d+)?)\s*)?\)/,
  3928. parse: function( execResult ) {
  3929. return [
  3930. execResult[ 1 ] * 2.55,
  3931. execResult[ 2 ] * 2.55,
  3932. execResult[ 3 ] * 2.55,
  3933. execResult[ 4 ]
  3934. ];
  3935. }
  3936. }, {
  3937. // this regex ignores A-F because it's compared against an already lowercased string
  3938. re: /#([a-f0-9]{2})([a-f0-9]{2})([a-f0-9]{2})/,
  3939. parse: function( execResult ) {
  3940. return [
  3941. parseInt( execResult[ 1 ], 16 ),
  3942. parseInt( execResult[ 2 ], 16 ),
  3943. parseInt( execResult[ 3 ], 16 )
  3944. ];
  3945. }
  3946. }, {
  3947. // this regex ignores A-F because it's compared against an already lowercased string
  3948. re: /#([a-f0-9])([a-f0-9])([a-f0-9])/,
  3949. parse: function( execResult ) {
  3950. return [
  3951. parseInt( execResult[ 1 ] + execResult[ 1 ], 16 ),
  3952. parseInt( execResult[ 2 ] + execResult[ 2 ], 16 ),
  3953. parseInt( execResult[ 3 ] + execResult[ 3 ], 16 )
  3954. ];
  3955. }
  3956. }, {
  3957. re: /hsla?\(\s*(\d+(?:\.\d+)?)\s*,\s*(\d+(?:\.\d+)?)\%\s*,\s*(\d+(?:\.\d+)?)\%\s*(?:,\s*(\d?(?:\.\d+)?)\s*)?\)/,
  3958. space: "hsla",
  3959. parse: function( execResult ) {
  3960. return [
  3961. execResult[ 1 ],
  3962. execResult[ 2 ] / 100,
  3963. execResult[ 3 ] / 100,
  3964. execResult[ 4 ]
  3965. ];
  3966. }
  3967. }],
  3968. // jQuery.Color( )
  3969. color = jQuery.Color = function( color, green, blue, alpha ) {
  3970. return new jQuery.Color.fn.parse( color, green, blue, alpha );
  3971. },
  3972. spaces = {
  3973. rgba: {
  3974. props: {
  3975. red: {
  3976. idx: 0,
  3977. type: "byte"
  3978. },
  3979. green: {
  3980. idx: 1,
  3981. type: "byte"
  3982. },
  3983. blue: {
  3984. idx: 2,
  3985. type: "byte"
  3986. }
  3987. }
  3988. },
  3989. hsla: {
  3990. props: {
  3991. hue: {
  3992. idx: 0,
  3993. type: "degrees"
  3994. },
  3995. saturation: {
  3996. idx: 1,
  3997. type: "percent"
  3998. },
  3999. lightness: {
  4000. idx: 2,
  4001. type: "percent"
  4002. }
  4003. }
  4004. }
  4005. },
  4006. propTypes = {
  4007. "byte": {
  4008. floor: true,
  4009. max: 255
  4010. },
  4011. "percent": {
  4012. max: 1
  4013. },
  4014. "degrees": {
  4015. mod: 360,
  4016. floor: true
  4017. }
  4018. },
  4019. support = color.support = {},
  4020. // element for support tests
  4021. supportElem = jQuery( "<p>" )[ 0 ],
  4022. // colors = jQuery.Color.names
  4023. colors,
  4024. // local aliases of functions called often
  4025. each = jQuery.each;
  4026. // determine rgba support immediately
  4027. supportElem.style.cssText = "background-color:rgba(1,1,1,.5)";
  4028. support.rgba = supportElem.style.backgroundColor.indexOf( "rgba" ) > -1;
  4029. // define cache name and alpha properties
  4030. // for rgba and hsla spaces
  4031. each( spaces, function( spaceName, space ) {
  4032. space.cache = "_" + spaceName;
  4033. space.props.alpha = {
  4034. idx: 3,
  4035. type: "percent",
  4036. def: 1
  4037. };
  4038. });
  4039. function clamp( value, prop, allowEmpty ) {
  4040. var type = propTypes[ prop.type ] || {};
  4041. if ( value == null ) {
  4042. return (allowEmpty || !prop.def) ? null : prop.def;
  4043. }
  4044. // ~~ is an short way of doing floor for positive numbers
  4045. value = type.floor ? ~~value : parseFloat( value );
  4046. // IE will pass in empty strings as value for alpha,
  4047. // which will hit this case
  4048. if ( isNaN( value ) ) {
  4049. return prop.def;
  4050. }
  4051. if ( type.mod ) {
  4052. // we add mod before modding to make sure that negatives values
  4053. // get converted properly: -10 -> 350
  4054. return (value + type.mod) % type.mod;
  4055. }
  4056. // for now all property types without mod have min and max
  4057. return 0 > value ? 0 : type.max < value ? type.max : value;
  4058. }
  4059. function stringParse( string ) {
  4060. var inst = color(),
  4061. rgba = inst._rgba = [];
  4062. string = string.toLowerCase();
  4063. each( stringParsers, function( i, parser ) {
  4064. var parsed,
  4065. match = parser.re.exec( string ),
  4066. values = match && parser.parse( match ),
  4067. spaceName = parser.space || "rgba";
  4068. if ( values ) {
  4069. parsed = inst[ spaceName ]( values );
  4070. // if this was an rgba parse the assignment might happen twice
  4071. // oh well....
  4072. inst[ spaces[ spaceName ].cache ] = parsed[ spaces[ spaceName ].cache ];
  4073. rgba = inst._rgba = parsed._rgba;
  4074. // exit each( stringParsers ) here because we matched
  4075. return false;
  4076. }
  4077. });
  4078. // Found a stringParser that handled it
  4079. if ( rgba.length ) {
  4080. // if this came from a parsed string, force "transparent" when alpha is 0
  4081. // chrome, (and maybe others) return "transparent" as rgba(0,0,0,0)
  4082. if ( rgba.join() === "0,0,0,0" ) {
  4083. jQuery.extend( rgba, colors.transparent );
  4084. }
  4085. return inst;
  4086. }
  4087. // named colors
  4088. return colors[ string ];
  4089. }
  4090. color.fn = jQuery.extend( color.prototype, {
  4091. parse: function( red, green, blue, alpha ) {
  4092. if ( red === undefined ) {
  4093. this._rgba = [ null, null, null, null ];
  4094. return this;
  4095. }
  4096. if ( red.jquery || red.nodeType ) {
  4097. red = jQuery( red ).css( green );
  4098. green = undefined;
  4099. }
  4100. var inst = this,
  4101. type = jQuery.type( red ),
  4102. rgba = this._rgba = [];
  4103. // more than 1 argument specified - assume ( red, green, blue, alpha )
  4104. if ( green !== undefined ) {
  4105. red = [ red, green, blue, alpha ];
  4106. type = "array";
  4107. }
  4108. if ( type === "string" ) {
  4109. return this.parse( stringParse( red ) || colors._default );
  4110. }
  4111. if ( type === "array" ) {
  4112. each( spaces.rgba.props, function( key, prop ) {
  4113. rgba[ prop.idx ] = clamp( red[ prop.idx ], prop );
  4114. });
  4115. return this;
  4116. }
  4117. if ( type === "object" ) {
  4118. if ( red instanceof color ) {
  4119. each( spaces, function( spaceName, space ) {
  4120. if ( red[ space.cache ] ) {
  4121. inst[ space.cache ] = red[ space.cache ].slice();
  4122. }
  4123. });
  4124. } else {
  4125. each( spaces, function( spaceName, space ) {
  4126. var cache = space.cache;
  4127. each( space.props, function( key, prop ) {
  4128. // if the cache doesn't exist, and we know how to convert
  4129. if ( !inst[ cache ] && space.to ) {
  4130. // if the value was null, we don't need to copy it
  4131. // if the key was alpha, we don't need to copy it either
  4132. if ( key === "alpha" || red[ key ] == null ) {
  4133. return;
  4134. }
  4135. inst[ cache ] = space.to( inst._rgba );
  4136. }
  4137. // this is the only case where we allow nulls for ALL properties.
  4138. // call clamp with alwaysAllowEmpty
  4139. inst[ cache ][ prop.idx ] = clamp( red[ key ], prop, true );
  4140. });
  4141. // everything defined but alpha?
  4142. if ( inst[ cache ] && jQuery.inArray( null, inst[ cache ].slice( 0, 3 ) ) < 0 ) {
  4143. // use the default of 1
  4144. inst[ cache ][ 3 ] = 1;
  4145. if ( space.from ) {
  4146. inst._rgba = space.from( inst[ cache ] );
  4147. }
  4148. }
  4149. });
  4150. }
  4151. return this;
  4152. }
  4153. },
  4154. is: function( compare ) {
  4155. var is = color( compare ),
  4156. same = true,
  4157. inst = this;
  4158. each( spaces, function( _, space ) {
  4159. var localCache,
  4160. isCache = is[ space.cache ];
  4161. if (isCache) {
  4162. localCache = inst[ space.cache ] || space.to && space.to( inst._rgba ) || [];
  4163. each( space.props, function( _, prop ) {
  4164. if ( isCache[ prop.idx ] != null ) {
  4165. same = ( isCache[ prop.idx ] === localCache[ prop.idx ] );
  4166. return same;
  4167. }
  4168. });
  4169. }
  4170. return same;
  4171. });
  4172. return same;
  4173. },
  4174. _space: function() {
  4175. var used = [],
  4176. inst = this;
  4177. each( spaces, function( spaceName, space ) {
  4178. if ( inst[ space.cache ] ) {
  4179. used.push( spaceName );
  4180. }
  4181. });
  4182. return used.pop();
  4183. },
  4184. transition: function( other, distance ) {
  4185. var end = color( other ),
  4186. spaceName = end._space(),
  4187. space = spaces[ spaceName ],
  4188. startColor = this.alpha() === 0 ? color( "transparent" ) : this,
  4189. start = startColor[ space.cache ] || space.to( startColor._rgba ),
  4190. result = start.slice();
  4191. end = end[ space.cache ];
  4192. each( space.props, function( key, prop ) {
  4193. var index = prop.idx,
  4194. startValue = start[ index ],
  4195. endValue = end[ index ],
  4196. type = propTypes[ prop.type ] || {};
  4197. // if null, don't override start value
  4198. if ( endValue === null ) {
  4199. return;
  4200. }
  4201. // if null - use end
  4202. if ( startValue === null ) {
  4203. result[ index ] = endValue;
  4204. } else {
  4205. if ( type.mod ) {
  4206. if ( endValue - startValue > type.mod / 2 ) {
  4207. startValue += type.mod;
  4208. } else if ( startValue - endValue > type.mod / 2 ) {
  4209. startValue -= type.mod;
  4210. }
  4211. }
  4212. result[ index ] = clamp( ( endValue - startValue ) * distance + startValue, prop );
  4213. }
  4214. });
  4215. return this[ spaceName ]( result );
  4216. },
  4217. blend: function( opaque ) {
  4218. // if we are already opaque - return ourself
  4219. if ( this._rgba[ 3 ] === 1 ) {
  4220. return this;
  4221. }
  4222. var rgb = this._rgba.slice(),
  4223. a = rgb.pop(),
  4224. blend = color( opaque )._rgba;
  4225. return color( jQuery.map( rgb, function( v, i ) {
  4226. return ( 1 - a ) * blend[ i ] + a * v;
  4227. }));
  4228. },
  4229. toRgbaString: function() {
  4230. var prefix = "rgba(",
  4231. rgba = jQuery.map( this._rgba, function( v, i ) {
  4232. return v == null ? ( i > 2 ? 1 : 0 ) : v;
  4233. });
  4234. if ( rgba[ 3 ] === 1 ) {
  4235. rgba.pop();
  4236. prefix = "rgb(";
  4237. }
  4238. return prefix + rgba.join() + ")";
  4239. },
  4240. toHslaString: function() {
  4241. var prefix = "hsla(",
  4242. hsla = jQuery.map( this.hsla(), function( v, i ) {
  4243. if ( v == null ) {
  4244. v = i > 2 ? 1 : 0;
  4245. }
  4246. // catch 1 and 2
  4247. if ( i && i < 3 ) {
  4248. v = Math.round( v * 100 ) + "%";
  4249. }
  4250. return v;
  4251. });
  4252. if ( hsla[ 3 ] === 1 ) {
  4253. hsla.pop();
  4254. prefix = "hsl(";
  4255. }
  4256. return prefix + hsla.join() + ")";
  4257. },
  4258. toHexString: function( includeAlpha ) {
  4259. var rgba = this._rgba.slice(),
  4260. alpha = rgba.pop();
  4261. if ( includeAlpha ) {
  4262. rgba.push( ~~( alpha * 255 ) );
  4263. }
  4264. return "#" + jQuery.map( rgba, function( v ) {
  4265. // default to 0 when nulls exist
  4266. v = ( v || 0 ).toString( 16 );
  4267. return v.length === 1 ? "0" + v : v;
  4268. }).join("");
  4269. },
  4270. toString: function() {
  4271. return this._rgba[ 3 ] === 0 ? "transparent" : this.toRgbaString();
  4272. }
  4273. });
  4274. color.fn.parse.prototype = color.fn;
  4275. // hsla conversions adapted from:
  4276. // https://code.google.com/p/maashaack/source/browse/packages/graphics/trunk/src/graphics/colors/HUE2RGB.as?r=5021
  4277. function hue2rgb( p, q, h ) {
  4278. h = ( h + 1 ) % 1;
  4279. if ( h * 6 < 1 ) {
  4280. return p + (q - p) * h * 6;
  4281. }
  4282. if ( h * 2 < 1) {
  4283. return q;
  4284. }
  4285. if ( h * 3 < 2 ) {
  4286. return p + (q - p) * ((2/3) - h) * 6;
  4287. }
  4288. return p;
  4289. }
  4290. spaces.hsla.to = function ( rgba ) {
  4291. if ( rgba[ 0 ] == null || rgba[ 1 ] == null || rgba[ 2 ] == null ) {
  4292. return [ null, null, null, rgba[ 3 ] ];
  4293. }
  4294. var r = rgba[ 0 ] / 255,
  4295. g = rgba[ 1 ] / 255,
  4296. b = rgba[ 2 ] / 255,
  4297. a = rgba[ 3 ],
  4298. max = Math.max( r, g, b ),
  4299. min = Math.min( r, g, b ),
  4300. diff = max - min,
  4301. add = max + min,
  4302. l = add * 0.5,
  4303. h, s;
  4304. if ( min === max ) {
  4305. h = 0;
  4306. } else if ( r === max ) {
  4307. h = ( 60 * ( g - b ) / diff ) + 360;
  4308. } else if ( g === max ) {
  4309. h = ( 60 * ( b - r ) / diff ) + 120;
  4310. } else {
  4311. h = ( 60 * ( r - g ) / diff ) + 240;
  4312. }
  4313. // chroma (diff) == 0 means greyscale which, by definition, saturation = 0%
  4314. // otherwise, saturation is based on the ratio of chroma (diff) to lightness (add)
  4315. if ( diff === 0 ) {
  4316. s = 0;
  4317. } else if ( l <= 0.5 ) {
  4318. s = diff / add;
  4319. } else {
  4320. s = diff / ( 2 - add );
  4321. }
  4322. return [ Math.round(h) % 360, s, l, a == null ? 1 : a ];
  4323. };
  4324. spaces.hsla.from = function ( hsla ) {
  4325. if ( hsla[ 0 ] == null || hsla[ 1 ] == null || hsla[ 2 ] == null ) {
  4326. return [ null, null, null, hsla[ 3 ] ];
  4327. }
  4328. var h = hsla[ 0 ] / 360,
  4329. s = hsla[ 1 ],
  4330. l = hsla[ 2 ],
  4331. a = hsla[ 3 ],
  4332. q = l <= 0.5 ? l * ( 1 + s ) : l + s - l * s,
  4333. p = 2 * l - q;
  4334. return [
  4335. Math.round( hue2rgb( p, q, h + ( 1 / 3 ) ) * 255 ),
  4336. Math.round( hue2rgb( p, q, h ) * 255 ),
  4337. Math.round( hue2rgb( p, q, h - ( 1 / 3 ) ) * 255 ),
  4338. a
  4339. ];
  4340. };
  4341. each( spaces, function( spaceName, space ) {
  4342. var props = space.props,
  4343. cache = space.cache,
  4344. to = space.to,
  4345. from = space.from;
  4346. // makes rgba() and hsla()
  4347. color.fn[ spaceName ] = function( value ) {
  4348. // generate a cache for this space if it doesn't exist
  4349. if ( to && !this[ cache ] ) {
  4350. this[ cache ] = to( this._rgba );
  4351. }
  4352. if ( value === undefined ) {
  4353. return this[ cache ].slice();
  4354. }
  4355. var ret,
  4356. type = jQuery.type( value ),
  4357. arr = ( type === "array" || type === "object" ) ? value : arguments,
  4358. local = this[ cache ].slice();
  4359. each( props, function( key, prop ) {
  4360. var val = arr[ type === "object" ? key : prop.idx ];
  4361. if ( val == null ) {
  4362. val = local[ prop.idx ];
  4363. }
  4364. local[ prop.idx ] = clamp( val, prop );
  4365. });
  4366. if ( from ) {
  4367. ret = color( from( local ) );
  4368. ret[ cache ] = local;
  4369. return ret;
  4370. } else {
  4371. return color( local );
  4372. }
  4373. };
  4374. // makes red() green() blue() alpha() hue() saturation() lightness()
  4375. each( props, function( key, prop ) {
  4376. // alpha is included in more than one space
  4377. if ( color.fn[ key ] ) {
  4378. return;
  4379. }
  4380. color.fn[ key ] = function( value ) {
  4381. var vtype = jQuery.type( value ),
  4382. fn = ( key === "alpha" ? ( this._hsla ? "hsla" : "rgba" ) : spaceName ),
  4383. local = this[ fn ](),
  4384. cur = local[ prop.idx ],
  4385. match;
  4386. if ( vtype === "undefined" ) {
  4387. return cur;
  4388. }
  4389. if ( vtype === "function" ) {
  4390. value = value.call( this, cur );
  4391. vtype = jQuery.type( value );
  4392. }
  4393. if ( value == null && prop.empty ) {
  4394. return this;
  4395. }
  4396. if ( vtype === "string" ) {
  4397. match = rplusequals.exec( value );
  4398. if ( match ) {
  4399. value = cur + parseFloat( match[ 2 ] ) * ( match[ 1 ] === "+" ? 1 : -1 );
  4400. }
  4401. }
  4402. local[ prop.idx ] = value;
  4403. return this[ fn ]( local );
  4404. };
  4405. });
  4406. });
  4407. // add cssHook and .fx.step function for each named hook.
  4408. // accept a space separated string of properties
  4409. color.hook = function( hook ) {
  4410. var hooks = hook.split( " " );
  4411. each( hooks, function( i, hook ) {
  4412. jQuery.cssHooks[ hook ] = {
  4413. set: function( elem, value ) {
  4414. var parsed, curElem,
  4415. backgroundColor = "";
  4416. if ( value !== "transparent" && ( jQuery.type( value ) !== "string" || ( parsed = stringParse( value ) ) ) ) {
  4417. value = color( parsed || value );
  4418. if ( !support.rgba && value._rgba[ 3 ] !== 1 ) {
  4419. curElem = hook === "backgroundColor" ? elem.parentNode : elem;
  4420. while (
  4421. (backgroundColor === "" || backgroundColor === "transparent") &&
  4422. curElem && curElem.style
  4423. ) {
  4424. try {
  4425. backgroundColor = jQuery.css( curElem, "backgroundColor" );
  4426. curElem = curElem.parentNode;
  4427. } catch ( e ) {
  4428. }
  4429. }
  4430. value = value.blend( backgroundColor && backgroundColor !== "transparent" ?
  4431. backgroundColor :
  4432. "_default" );
  4433. }
  4434. value = value.toRgbaString();
  4435. }
  4436. try {
  4437. elem.style[ hook ] = value;
  4438. } catch( e ) {
  4439. // wrapped to prevent IE from throwing errors on "invalid" values like 'auto' or 'inherit'
  4440. }
  4441. }
  4442. };
  4443. jQuery.fx.step[ hook ] = function( fx ) {
  4444. if ( !fx.colorInit ) {
  4445. fx.start = color( fx.elem, hook );
  4446. fx.end = color( fx.end );
  4447. fx.colorInit = true;
  4448. }
  4449. jQuery.cssHooks[ hook ].set( fx.elem, fx.start.transition( fx.end, fx.pos ) );
  4450. };
  4451. });
  4452. };
  4453. color.hook( stepHooks );
  4454. jQuery.cssHooks.borderColor = {
  4455. expand: function( value ) {
  4456. var expanded = {};
  4457. each( [ "Top", "Right", "Bottom", "Left" ], function( i, part ) {
  4458. expanded[ "border" + part + "Color" ] = value;
  4459. });
  4460. return expanded;
  4461. }
  4462. };
  4463. // Basic color names only.
  4464. // Usage of any of the other color names requires adding yourself or including
  4465. // jquery.color.svg-names.js.
  4466. colors = jQuery.Color.names = {
  4467. // 4.1. Basic color keywords
  4468. aqua: "#00ffff",
  4469. black: "#000000",
  4470. blue: "#0000ff",
  4471. fuchsia: "#ff00ff",
  4472. gray: "#808080",
  4473. green: "#008000",
  4474. lime: "#00ff00",
  4475. maroon: "#800000",
  4476. navy: "#000080",
  4477. olive: "#808000",
  4478. purple: "#800080",
  4479. red: "#ff0000",
  4480. silver: "#c0c0c0",
  4481. teal: "#008080",
  4482. white: "#ffffff",
  4483. yellow: "#ffff00",
  4484. // 4.2.3. "transparent" color keyword
  4485. transparent: [ null, null, null, 0 ],
  4486. _default: "#ffffff"
  4487. };
  4488. })( jQuery );
  4489. /******************************************************************************/
  4490. /****************************** CLASS ANIMATIONS ******************************/
  4491. /******************************************************************************/
  4492. (function() {
  4493. var classAnimationActions = [ "add", "remove", "toggle" ],
  4494. shorthandStyles = {
  4495. border: 1,
  4496. borderBottom: 1,
  4497. borderColor: 1,
  4498. borderLeft: 1,
  4499. borderRight: 1,
  4500. borderTop: 1,
  4501. borderWidth: 1,
  4502. margin: 1,
  4503. padding: 1
  4504. };
  4505. $.each([ "borderLeftStyle", "borderRightStyle", "borderBottomStyle", "borderTopStyle" ], function( _, prop ) {
  4506. $.fx.step[ prop ] = function( fx ) {
  4507. if ( fx.end !== "none" && !fx.setAttr || fx.pos === 1 && !fx.setAttr ) {
  4508. jQuery.style( fx.elem, prop, fx.end );
  4509. fx.setAttr = true;
  4510. }
  4511. };
  4512. });
  4513. function getElementStyles( elem ) {
  4514. var key, len,
  4515. style = elem.ownerDocument.defaultView ?
  4516. elem.ownerDocument.defaultView.getComputedStyle( elem, null ) :
  4517. elem.currentStyle,
  4518. styles = {};
  4519. if ( style && style.length && style[ 0 ] && style[ style[ 0 ] ] ) {
  4520. len = style.length;
  4521. while ( len-- ) {
  4522. key = style[ len ];
  4523. if ( typeof style[ key ] === "string" ) {
  4524. styles[ $.camelCase( key ) ] = style[ key ];
  4525. }
  4526. }
  4527. // support: Opera, IE <9
  4528. } else {
  4529. for ( key in style ) {
  4530. if ( typeof style[ key ] === "string" ) {
  4531. styles[ key ] = style[ key ];
  4532. }
  4533. }
  4534. }
  4535. return styles;
  4536. }
  4537. function styleDifference( oldStyle, newStyle ) {
  4538. var diff = {},
  4539. name, value;
  4540. for ( name in newStyle ) {
  4541. value = newStyle[ name ];
  4542. if ( oldStyle[ name ] !== value ) {
  4543. if ( !shorthandStyles[ name ] ) {
  4544. if ( $.fx.step[ name ] || !isNaN( parseFloat( value ) ) ) {
  4545. diff[ name ] = value;
  4546. }
  4547. }
  4548. }
  4549. }
  4550. return diff;
  4551. }
  4552. // support: jQuery <1.8
  4553. if ( !$.fn.addBack ) {
  4554. $.fn.addBack = function( selector ) {
  4555. return this.add( selector == null ?
  4556. this.prevObject : this.prevObject.filter( selector )
  4557. );
  4558. };
  4559. }
  4560. $.effects.animateClass = function( value, duration, easing, callback ) {
  4561. var o = $.speed( duration, easing, callback );
  4562. return this.queue( function() {
  4563. var animated = $( this ),
  4564. baseClass = animated.attr( "class" ) || "",
  4565. applyClassChange,
  4566. allAnimations = o.children ? animated.find( "*" ).addBack() : animated;
  4567. // map the animated objects to store the original styles.
  4568. allAnimations = allAnimations.map(function() {
  4569. var el = $( this );
  4570. return {
  4571. el: el,
  4572. start: getElementStyles( this )
  4573. };
  4574. });
  4575. // apply class change
  4576. applyClassChange = function() {
  4577. $.each( classAnimationActions, function(i, action) {
  4578. if ( value[ action ] ) {
  4579. animated[ action + "Class" ]( value[ action ] );
  4580. }
  4581. });
  4582. };
  4583. applyClassChange();
  4584. // map all animated objects again - calculate new styles and diff
  4585. allAnimations = allAnimations.map(function() {
  4586. this.end = getElementStyles( this.el[ 0 ] );
  4587. this.diff = styleDifference( this.start, this.end );
  4588. return this;
  4589. });
  4590. // apply original class
  4591. animated.attr( "class", baseClass );
  4592. // map all animated objects again - this time collecting a promise
  4593. allAnimations = allAnimations.map(function() {
  4594. var styleInfo = this,
  4595. dfd = $.Deferred(),
  4596. opts = $.extend({}, o, {
  4597. queue: false,
  4598. complete: function() {
  4599. dfd.resolve( styleInfo );
  4600. }
  4601. });
  4602. this.el.animate( this.diff, opts );
  4603. return dfd.promise();
  4604. });
  4605. // once all animations have completed:
  4606. $.when.apply( $, allAnimations.get() ).done(function() {
  4607. // set the final class
  4608. applyClassChange();
  4609. // for each animated element,
  4610. // clear all css properties that were animated
  4611. $.each( arguments, function() {
  4612. var el = this.el;
  4613. $.each( this.diff, function(key) {
  4614. el.css( key, "" );
  4615. });
  4616. });
  4617. // this is guarnteed to be there if you use jQuery.speed()
  4618. // it also handles dequeuing the next anim...
  4619. o.complete.call( animated[ 0 ] );
  4620. });
  4621. });
  4622. };
  4623. $.fn.extend({
  4624. addClass: (function( orig ) {
  4625. return function( classNames, speed, easing, callback ) {
  4626. return speed ?
  4627. $.effects.animateClass.call( this,
  4628. { add: classNames }, speed, easing, callback ) :
  4629. orig.apply( this, arguments );
  4630. };
  4631. })( $.fn.addClass ),
  4632. removeClass: (function( orig ) {
  4633. return function( classNames, speed, easing, callback ) {
  4634. return arguments.length > 1 ?
  4635. $.effects.animateClass.call( this,
  4636. { remove: classNames }, speed, easing, callback ) :
  4637. orig.apply( this, arguments );
  4638. };
  4639. })( $.fn.removeClass ),
  4640. toggleClass: (function( orig ) {
  4641. return function( classNames, force, speed, easing, callback ) {
  4642. if ( typeof force === "boolean" || force === undefined ) {
  4643. if ( !speed ) {
  4644. // without speed parameter
  4645. return orig.apply( this, arguments );
  4646. } else {
  4647. return $.effects.animateClass.call( this,
  4648. (force ? { add: classNames } : { remove: classNames }),
  4649. speed, easing, callback );
  4650. }
  4651. } else {
  4652. // without force parameter
  4653. return $.effects.animateClass.call( this,
  4654. { toggle: classNames }, force, speed, easing );
  4655. }
  4656. };
  4657. })( $.fn.toggleClass ),
  4658. switchClass: function( remove, add, speed, easing, callback) {
  4659. return $.effects.animateClass.call( this, {
  4660. add: add,
  4661. remove: remove
  4662. }, speed, easing, callback );
  4663. }
  4664. });
  4665. })();
  4666. /******************************************************************************/
  4667. /*********************************** EFFECTS **********************************/
  4668. /******************************************************************************/
  4669. (function() {
  4670. $.extend( $.effects, {
  4671. version: "1.10.2",
  4672. // Saves a set of properties in a data storage
  4673. save: function( element, set ) {
  4674. for( var i=0; i < set.length; i++ ) {
  4675. if ( set[ i ] !== null ) {
  4676. element.data( dataSpace + set[ i ], element[ 0 ].style[ set[ i ] ] );
  4677. }
  4678. }
  4679. },
  4680. // Restores a set of previously saved properties from a data storage
  4681. restore: function( element, set ) {
  4682. var val, i;
  4683. for( i=0; i < set.length; i++ ) {
  4684. if ( set[ i ] !== null ) {
  4685. val = element.data( dataSpace + set[ i ] );
  4686. // support: jQuery 1.6.2
  4687. // http://bugs.jquery.com/ticket/9917
  4688. // jQuery 1.6.2 incorrectly returns undefined for any falsy value.
  4689. // We can't differentiate between "" and 0 here, so we just assume
  4690. // empty string since it's likely to be a more common value...
  4691. if ( val === undefined ) {
  4692. val = "";
  4693. }
  4694. element.css( set[ i ], val );
  4695. }
  4696. }
  4697. },
  4698. setMode: function( el, mode ) {
  4699. if (mode === "toggle") {
  4700. mode = el.is( ":hidden" ) ? "show" : "hide";
  4701. }
  4702. return mode;
  4703. },
  4704. // Translates a [top,left] array into a baseline value
  4705. // this should be a little more flexible in the future to handle a string & hash
  4706. getBaseline: function( origin, original ) {
  4707. var y, x;
  4708. switch ( origin[ 0 ] ) {
  4709. case "top": y = 0; break;
  4710. case "middle": y = 0.5; break;
  4711. case "bottom": y = 1; break;
  4712. default: y = origin[ 0 ] / original.height;
  4713. }
  4714. switch ( origin[ 1 ] ) {
  4715. case "left": x = 0; break;
  4716. case "center": x = 0.5; break;
  4717. case "right": x = 1; break;
  4718. default: x = origin[ 1 ] / original.width;
  4719. }
  4720. return {
  4721. x: x,
  4722. y: y
  4723. };
  4724. },
  4725. // Wraps the element around a wrapper that copies position properties
  4726. createWrapper: function( element ) {
  4727. // if the element is already wrapped, return it
  4728. if ( element.parent().is( ".ui-effects-wrapper" )) {
  4729. return element.parent();
  4730. }
  4731. // wrap the element
  4732. var props = {
  4733. width: element.outerWidth(true),
  4734. height: element.outerHeight(true),
  4735. "float": element.css( "float" )
  4736. },
  4737. wrapper = $( "<div></div>" )
  4738. .addClass( "ui-effects-wrapper" )
  4739. .css({
  4740. fontSize: "100%",
  4741. background: "transparent",
  4742. border: "none",
  4743. margin: 0,
  4744. padding: 0
  4745. }),
  4746. // Store the size in case width/height are defined in % - Fixes #5245
  4747. size = {
  4748. width: element.width(),
  4749. height: element.height()
  4750. },
  4751. active = document.activeElement;
  4752. // support: Firefox
  4753. // Firefox incorrectly exposes anonymous content
  4754. // https://bugzilla.mozilla.org/show_bug.cgi?id=561664
  4755. try {
  4756. active.id;
  4757. } catch( e ) {
  4758. active = document.body;
  4759. }
  4760. element.wrap( wrapper );
  4761. // Fixes #7595 - Elements lose focus when wrapped.
  4762. if ( element[ 0 ] === active || $.contains( element[ 0 ], active ) ) {
  4763. $( active ).focus();
  4764. }
  4765. wrapper = element.parent(); //Hotfix for jQuery 1.4 since some change in wrap() seems to actually lose the reference to the wrapped element
  4766. // transfer positioning properties to the wrapper
  4767. if ( element.css( "position" ) === "static" ) {
  4768. wrapper.css({ position: "relative" });
  4769. element.css({ position: "relative" });
  4770. } else {
  4771. $.extend( props, {
  4772. position: element.css( "position" ),
  4773. zIndex: element.css( "z-index" )
  4774. });
  4775. $.each([ "top", "left", "bottom", "right" ], function(i, pos) {
  4776. props[ pos ] = element.css( pos );
  4777. if ( isNaN( parseInt( props[ pos ], 10 ) ) ) {
  4778. props[ pos ] = "auto";
  4779. }
  4780. });
  4781. element.css({
  4782. position: "relative",
  4783. top: 0,
  4784. left: 0,
  4785. right: "auto",
  4786. bottom: "auto"
  4787. });
  4788. }
  4789. element.css(size);
  4790. return wrapper.css( props ).show();
  4791. },
  4792. removeWrapper: function( element ) {
  4793. var active = document.activeElement;
  4794. if ( element.parent().is( ".ui-effects-wrapper" ) ) {
  4795. element.parent().replaceWith( element );
  4796. // Fixes #7595 - Elements lose focus when wrapped.
  4797. if ( element[ 0 ] === active || $.contains( element[ 0 ], active ) ) {
  4798. $( active ).focus();
  4799. }
  4800. }
  4801. return element;
  4802. },
  4803. setTransition: function( element, list, factor, value ) {
  4804. value = value || {};
  4805. $.each( list, function( i, x ) {
  4806. var unit = element.cssUnit( x );
  4807. if ( unit[ 0 ] > 0 ) {
  4808. value[ x ] = unit[ 0 ] * factor + unit[ 1 ];
  4809. }
  4810. });
  4811. return value;
  4812. }
  4813. });
  4814. // return an effect options object for the given parameters:
  4815. function _normalizeArguments( effect, options, speed, callback ) {
  4816. // allow passing all options as the first parameter
  4817. if ( $.isPlainObject( effect ) ) {
  4818. options = effect;
  4819. effect = effect.effect;
  4820. }
  4821. // convert to an object
  4822. effect = { effect: effect };
  4823. // catch (effect, null, ...)
  4824. if ( options == null ) {
  4825. options = {};
  4826. }
  4827. // catch (effect, callback)
  4828. if ( $.isFunction( options ) ) {
  4829. callback = options;
  4830. speed = null;
  4831. options = {};
  4832. }
  4833. // catch (effect, speed, ?)
  4834. if ( typeof options === "number" || $.fx.speeds[ options ] ) {
  4835. callback = speed;
  4836. speed = options;
  4837. options = {};
  4838. }
  4839. // catch (effect, options, callback)
  4840. if ( $.isFunction( speed ) ) {
  4841. callback = speed;
  4842. speed = null;
  4843. }
  4844. // add options to effect
  4845. if ( options ) {
  4846. $.extend( effect, options );
  4847. }
  4848. speed = speed || options.duration;
  4849. effect.duration = $.fx.off ? 0 :
  4850. typeof speed === "number" ? speed :
  4851. speed in $.fx.speeds ? $.fx.speeds[ speed ] :
  4852. $.fx.speeds._default;
  4853. effect.complete = callback || options.complete;
  4854. return effect;
  4855. }
  4856. function standardAnimationOption( option ) {
  4857. // Valid standard speeds (nothing, number, named speed)
  4858. if ( !option || typeof option === "number" || $.fx.speeds[ option ] ) {
  4859. return true;
  4860. }
  4861. // Invalid strings - treat as "normal" speed
  4862. if ( typeof option === "string" && !$.effects.effect[ option ] ) {
  4863. return true;
  4864. }
  4865. // Complete callback
  4866. if ( $.isFunction( option ) ) {
  4867. return true;
  4868. }
  4869. // Options hash (but not naming an effect)
  4870. if ( typeof option === "object" && !option.effect ) {
  4871. return true;
  4872. }
  4873. // Didn't match any standard API
  4874. return false;
  4875. }
  4876. $.fn.extend({
  4877. effect: function( /* effect, options, speed, callback */ ) {
  4878. var args = _normalizeArguments.apply( this, arguments ),
  4879. mode = args.mode,
  4880. queue = args.queue,
  4881. effectMethod = $.effects.effect[ args.effect ];
  4882. if ( $.fx.off || !effectMethod ) {
  4883. // delegate to the original method (e.g., .show()) if possible
  4884. if ( mode ) {
  4885. return this[ mode ]( args.duration, args.complete );
  4886. } else {
  4887. return this.each( function() {
  4888. if ( args.complete ) {
  4889. args.complete.call( this );
  4890. }
  4891. });
  4892. }
  4893. }
  4894. function run( next ) {
  4895. var elem = $( this ),
  4896. complete = args.complete,
  4897. mode = args.mode;
  4898. function done() {
  4899. if ( $.isFunction( complete ) ) {
  4900. complete.call( elem[0] );
  4901. }
  4902. if ( $.isFunction( next ) ) {
  4903. next();
  4904. }
  4905. }
  4906. // If the element already has the correct final state, delegate to
  4907. // the core methods so the internal tracking of "olddisplay" works.
  4908. if ( elem.is( ":hidden" ) ? mode === "hide" : mode === "show" ) {
  4909. elem[ mode ]();
  4910. done();
  4911. } else {
  4912. effectMethod.call( elem[0], args, done );
  4913. }
  4914. }
  4915. return queue === false ? this.each( run ) : this.queue( queue || "fx", run );
  4916. },
  4917. show: (function( orig ) {
  4918. return function( option ) {
  4919. if ( standardAnimationOption( option ) ) {
  4920. return orig.apply( this, arguments );
  4921. } else {
  4922. var args = _normalizeArguments.apply( this, arguments );
  4923. args.mode = "show";
  4924. return this.effect.call( this, args );
  4925. }
  4926. };
  4927. })( $.fn.show ),
  4928. hide: (function( orig ) {
  4929. return function( option ) {
  4930. if ( standardAnimationOption( option ) ) {
  4931. return orig.apply( this, arguments );
  4932. } else {
  4933. var args = _normalizeArguments.apply( this, arguments );
  4934. args.mode = "hide";
  4935. return this.effect.call( this, args );
  4936. }
  4937. };
  4938. })( $.fn.hide ),
  4939. toggle: (function( orig ) {
  4940. return function( option ) {
  4941. if ( standardAnimationOption( option ) || typeof option === "boolean" ) {
  4942. return orig.apply( this, arguments );
  4943. } else {
  4944. var args = _normalizeArguments.apply( this, arguments );
  4945. args.mode = "toggle";
  4946. return this.effect.call( this, args );
  4947. }
  4948. };
  4949. })( $.fn.toggle ),
  4950. // helper functions
  4951. cssUnit: function(key) {
  4952. var style = this.css( key ),
  4953. val = [];
  4954. $.each( [ "em", "px", "%", "pt" ], function( i, unit ) {
  4955. if ( style.indexOf( unit ) > 0 ) {
  4956. val = [ parseFloat( style ), unit ];
  4957. }
  4958. });
  4959. return val;
  4960. }
  4961. });
  4962. })();
  4963. /******************************************************************************/
  4964. /*********************************** EASING ***********************************/
  4965. /******************************************************************************/
  4966. (function() {
  4967. // based on easing equations from Robert Penner (http://www.robertpenner.com/easing)
  4968. var baseEasings = {};
  4969. $.each( [ "Quad", "Cubic", "Quart", "Quint", "Expo" ], function( i, name ) {
  4970. baseEasings[ name ] = function( p ) {
  4971. return Math.pow( p, i + 2 );
  4972. };
  4973. });
  4974. $.extend( baseEasings, {
  4975. Sine: function ( p ) {
  4976. return 1 - Math.cos( p * Math.PI / 2 );
  4977. },
  4978. Circ: function ( p ) {
  4979. return 1 - Math.sqrt( 1 - p * p );
  4980. },
  4981. Elastic: function( p ) {
  4982. return p === 0 || p === 1 ? p :
  4983. -Math.pow( 2, 8 * (p - 1) ) * Math.sin( ( (p - 1) * 80 - 7.5 ) * Math.PI / 15 );
  4984. },
  4985. Back: function( p ) {
  4986. return p * p * ( 3 * p - 2 );
  4987. },
  4988. Bounce: function ( p ) {
  4989. var pow2,
  4990. bounce = 4;
  4991. while ( p < ( ( pow2 = Math.pow( 2, --bounce ) ) - 1 ) / 11 ) {}
  4992. return 1 / Math.pow( 4, 3 - bounce ) - 7.5625 * Math.pow( ( pow2 * 3 - 2 ) / 22 - p, 2 );
  4993. }
  4994. });
  4995. $.each( baseEasings, function( name, easeIn ) {
  4996. $.easing[ "easeIn" + name ] = easeIn;
  4997. $.easing[ "easeOut" + name ] = function( p ) {
  4998. return 1 - easeIn( 1 - p );
  4999. };
  5000. $.easing[ "easeInOut" + name ] = function( p ) {
  5001. return p < 0.5 ?
  5002. easeIn( p * 2 ) / 2 :
  5003. 1 - easeIn( p * -2 + 2 ) / 2;
  5004. };
  5005. });
  5006. })();
  5007. })(jQuery);
  5008. (function( $, undefined ) {
  5009. var uid = 0,
  5010. hideProps = {},
  5011. showProps = {};
  5012. hideProps.height = hideProps.paddingTop = hideProps.paddingBottom =
  5013. hideProps.borderTopWidth = hideProps.borderBottomWidth = "hide";
  5014. showProps.height = showProps.paddingTop = showProps.paddingBottom =
  5015. showProps.borderTopWidth = showProps.borderBottomWidth = "show";
  5016. $.widget( "ui.accordion", {
  5017. version: "1.10.2",
  5018. options: {
  5019. active: 0,
  5020. animate: {},
  5021. collapsible: false,
  5022. event: "click",
  5023. header: "> li > :first-child,> :not(li):even",
  5024. heightStyle: "auto",
  5025. icons: {
  5026. activeHeader: "ui-icon-triangle-1-s",
  5027. header: "ui-icon-triangle-1-e"
  5028. },
  5029. // callbacks
  5030. activate: null,
  5031. beforeActivate: null
  5032. },
  5033. _create: function() {
  5034. var options = this.options;
  5035. this.prevShow = this.prevHide = $();
  5036. this.element.addClass( "ui-accordion ui-widget ui-helper-reset" )
  5037. // ARIA
  5038. .attr( "role", "tablist" );
  5039. // don't allow collapsible: false and active: false / null
  5040. if ( !options.collapsible && (options.active === false || options.active == null) ) {
  5041. options.active = 0;
  5042. }
  5043. this._processPanels();
  5044. // handle negative values
  5045. if ( options.active < 0 ) {
  5046. options.active += this.headers.length;
  5047. }
  5048. this._refresh();
  5049. },
  5050. _getCreateEventData: function() {
  5051. return {
  5052. header: this.active,
  5053. panel: !this.active.length ? $() : this.active.next(),
  5054. content: !this.active.length ? $() : this.active.next()
  5055. };
  5056. },
  5057. _createIcons: function() {
  5058. var icons = this.options.icons;
  5059. if ( icons ) {
  5060. $( "<span>" )
  5061. .addClass( "ui-accordion-header-icon ui-icon " + icons.header )
  5062. .prependTo( this.headers );
  5063. this.active.children( ".ui-accordion-header-icon" )
  5064. .removeClass( icons.header )
  5065. .addClass( icons.activeHeader );
  5066. this.headers.addClass( "ui-accordion-icons" );
  5067. }
  5068. },
  5069. _destroyIcons: function() {
  5070. this.headers
  5071. .removeClass( "ui-accordion-icons" )
  5072. .children( ".ui-accordion-header-icon" )
  5073. .remove();
  5074. },
  5075. _destroy: function() {
  5076. var contents;
  5077. // clean up main element
  5078. this.element
  5079. .removeClass( "ui-accordion ui-widget ui-helper-reset" )
  5080. .removeAttr( "role" );
  5081. // clean up headers
  5082. this.headers
  5083. .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" )
  5084. .removeAttr( "role" )
  5085. .removeAttr( "aria-selected" )
  5086. .removeAttr( "aria-controls" )
  5087. .removeAttr( "tabIndex" )
  5088. .each(function() {
  5089. if ( /^ui-accordion/.test( this.id ) ) {
  5090. this.removeAttribute( "id" );
  5091. }
  5092. });
  5093. this._destroyIcons();
  5094. // clean up content panels
  5095. contents = this.headers.next()
  5096. .css( "display", "" )
  5097. .removeAttr( "role" )
  5098. .removeAttr( "aria-expanded" )
  5099. .removeAttr( "aria-hidden" )
  5100. .removeAttr( "aria-labelledby" )
  5101. .removeClass( "ui-helper-reset ui-widget-content ui-corner-bottom ui-accordion-content ui-accordion-content-active ui-state-disabled" )
  5102. .each(function() {
  5103. if ( /^ui-accordion/.test( this.id ) ) {
  5104. this.removeAttribute( "id" );
  5105. }
  5106. });
  5107. if ( this.options.heightStyle !== "content" ) {
  5108. contents.css( "height", "" );
  5109. }
  5110. },
  5111. _setOption: function( key, value ) {
  5112. if ( key === "active" ) {
  5113. // _activate() will handle invalid values and update this.options
  5114. this._activate( value );
  5115. return;
  5116. }
  5117. if ( key === "event" ) {
  5118. if ( this.options.event ) {
  5119. this._off( this.headers, this.options.event );
  5120. }
  5121. this._setupEvents( value );
  5122. }
  5123. this._super( key, value );
  5124. // setting collapsible: false while collapsed; open first panel
  5125. if ( key === "collapsible" && !value && this.options.active === false ) {
  5126. this._activate( 0 );
  5127. }
  5128. if ( key === "icons" ) {
  5129. this._destroyIcons();
  5130. if ( value ) {
  5131. this._createIcons();
  5132. }
  5133. }
  5134. // #5332 - opacity doesn't cascade to positioned elements in IE
  5135. // so we need to add the disabled class to the headers and panels
  5136. if ( key === "disabled" ) {
  5137. this.headers.add( this.headers.next() )
  5138. .toggleClass( "ui-state-disabled", !!value );
  5139. }
  5140. },
  5141. _keydown: function( event ) {
  5142. /*jshint maxcomplexity:15*/
  5143. if ( event.altKey || event.ctrlKey ) {
  5144. return;
  5145. }
  5146. var keyCode = $.ui.keyCode,
  5147. length = this.headers.length,
  5148. currentIndex = this.headers.index( event.target ),
  5149. toFocus = false;
  5150. switch ( event.keyCode ) {
  5151. case keyCode.RIGHT:
  5152. case keyCode.DOWN:
  5153. toFocus = this.headers[ ( currentIndex + 1 ) % length ];
  5154. break;
  5155. case keyCode.LEFT:
  5156. case keyCode.UP:
  5157. toFocus = this.headers[ ( currentIndex - 1 + length ) % length ];
  5158. break;
  5159. case keyCode.SPACE:
  5160. case keyCode.ENTER:
  5161. this._eventHandler( event );
  5162. break;
  5163. case keyCode.HOME:
  5164. toFocus = this.headers[ 0 ];
  5165. break;
  5166. case keyCode.END:
  5167. toFocus = this.headers[ length - 1 ];
  5168. break;
  5169. }
  5170. if ( toFocus ) {
  5171. $( event.target ).attr( "tabIndex", -1 );
  5172. $( toFocus ).attr( "tabIndex", 0 );
  5173. toFocus.focus();
  5174. event.preventDefault();
  5175. }
  5176. },
  5177. _panelKeyDown : function( event ) {
  5178. if ( event.keyCode === $.ui.keyCode.UP && event.ctrlKey ) {
  5179. $( event.currentTarget ).prev().focus();
  5180. }
  5181. },
  5182. refresh: function() {
  5183. var options = this.options;
  5184. this._processPanels();
  5185. // was collapsed or no panel
  5186. if ( ( options.active === false && options.collapsible === true ) || !this.headers.length ) {
  5187. options.active = false;
  5188. this.active = $();
  5189. // active false only when collapsible is true
  5190. } if ( options.active === false ) {
  5191. this._activate( 0 );
  5192. // was active, but active panel is gone
  5193. } else if ( this.active.length && !$.contains( this.element[ 0 ], this.active[ 0 ] ) ) {
  5194. // all remaining panel are disabled
  5195. if ( this.headers.length === this.headers.find(".ui-state-disabled").length ) {
  5196. options.active = false;
  5197. this.active = $();
  5198. // activate previous panel
  5199. } else {
  5200. this._activate( Math.max( 0, options.active - 1 ) );
  5201. }
  5202. // was active, active panel still exists
  5203. } else {
  5204. // make sure active index is correct
  5205. options.active = this.headers.index( this.active );
  5206. }
  5207. this._destroyIcons();
  5208. this._refresh();
  5209. },
  5210. _processPanels: function() {
  5211. this.headers = this.element.find( this.options.header )
  5212. .addClass( "ui-accordion-header ui-helper-reset ui-state-default ui-corner-all" );
  5213. this.headers.next()
  5214. .addClass( "ui-accordion-content ui-helper-reset ui-widget-content ui-corner-bottom" )
  5215. .filter(":not(.ui-accordion-content-active)")
  5216. .hide();
  5217. },
  5218. _refresh: function() {
  5219. var maxHeight,
  5220. options = this.options,
  5221. heightStyle = options.heightStyle,
  5222. parent = this.element.parent(),
  5223. accordionId = this.accordionId = "ui-accordion-" +
  5224. (this.element.attr( "id" ) || ++uid);
  5225. this.active = this._findActive( options.active )
  5226. .addClass( "ui-accordion-header-active ui-state-active ui-corner-top" )
  5227. .removeClass( "ui-corner-all" );
  5228. this.active.next()
  5229. .addClass( "ui-accordion-content-active" )
  5230. .show();
  5231. this.headers
  5232. .attr( "role", "tab" )
  5233. .each(function( i ) {
  5234. var header = $( this ),
  5235. headerId = header.attr( "id" ),
  5236. panel = header.next(),
  5237. panelId = panel.attr( "id" );
  5238. if ( !headerId ) {
  5239. headerId = accordionId + "-header-" + i;
  5240. header.attr( "id", headerId );
  5241. }
  5242. if ( !panelId ) {
  5243. panelId = accordionId + "-panel-" + i;
  5244. panel.attr( "id", panelId );
  5245. }
  5246. header.attr( "aria-controls", panelId );
  5247. panel.attr( "aria-labelledby", headerId );
  5248. })
  5249. .next()
  5250. .attr( "role", "tabpanel" );
  5251. this.headers
  5252. .not( this.active )
  5253. .attr({
  5254. "aria-selected": "false",
  5255. tabIndex: -1
  5256. })
  5257. .next()
  5258. .attr({
  5259. "aria-expanded": "false",
  5260. "aria-hidden": "true"
  5261. })
  5262. .hide();
  5263. // make sure at least one header is in the tab order
  5264. if ( !this.active.length ) {
  5265. this.headers.eq( 0 ).attr( "tabIndex", 0 );
  5266. } else {
  5267. this.active.attr({
  5268. "aria-selected": "true",
  5269. tabIndex: 0
  5270. })
  5271. .next()
  5272. .attr({
  5273. "aria-expanded": "true",
  5274. "aria-hidden": "false"
  5275. });
  5276. }
  5277. this._createIcons();
  5278. this._setupEvents( options.event );
  5279. if ( heightStyle === "fill" ) {
  5280. maxHeight = parent.height();
  5281. this.element.siblings( ":visible" ).each(function() {
  5282. var elem = $( this ),
  5283. position = elem.css( "position" );
  5284. if ( position === "absolute" || position === "fixed" ) {
  5285. return;
  5286. }
  5287. maxHeight -= elem.outerHeight( true );
  5288. });
  5289. this.headers.each(function() {
  5290. maxHeight -= $( this ).outerHeight( true );
  5291. });
  5292. this.headers.next()
  5293. .each(function() {
  5294. $( this ).height( Math.max( 0, maxHeight -
  5295. $( this ).innerHeight() + $( this ).height() ) );
  5296. })
  5297. .css( "overflow", "auto" );
  5298. } else if ( heightStyle === "auto" ) {
  5299. maxHeight = 0;
  5300. this.headers.next()
  5301. .each(function() {
  5302. maxHeight = Math.max( maxHeight, $( this ).css( "height", "" ).height() );
  5303. })
  5304. .height( maxHeight );
  5305. }
  5306. },
  5307. _activate: function( index ) {
  5308. var active = this._findActive( index )[ 0 ];
  5309. // trying to activate the already active panel
  5310. if ( active === this.active[ 0 ] ) {
  5311. return;
  5312. }
  5313. // trying to collapse, simulate a click on the currently active header
  5314. active = active || this.active[ 0 ];
  5315. this._eventHandler({
  5316. target: active,
  5317. currentTarget: active,
  5318. preventDefault: $.noop
  5319. });
  5320. },
  5321. _findActive: function( selector ) {
  5322. return typeof selector === "number" ? this.headers.eq( selector ) : $();
  5323. },
  5324. _setupEvents: function( event ) {
  5325. var events = {
  5326. keydown: "_keydown"
  5327. };
  5328. if ( event ) {
  5329. $.each( event.split(" "), function( index, eventName ) {
  5330. events[ eventName ] = "_eventHandler";
  5331. });
  5332. }
  5333. this._off( this.headers.add( this.headers.next() ) );
  5334. this._on( this.headers, events );
  5335. this._on( this.headers.next(), { keydown: "_panelKeyDown" });
  5336. this._hoverable( this.headers );
  5337. this._focusable( this.headers );
  5338. },
  5339. _eventHandler: function( event ) {
  5340. var options = this.options,
  5341. active = this.active,
  5342. clicked = $( event.currentTarget ),
  5343. clickedIsActive = clicked[ 0 ] === active[ 0 ],
  5344. collapsing = clickedIsActive && options.collapsible,
  5345. toShow = collapsing ? $() : clicked.next(),
  5346. toHide = active.next(),
  5347. eventData = {
  5348. oldHeader: active,
  5349. oldPanel: toHide,
  5350. newHeader: collapsing ? $() : clicked,
  5351. newPanel: toShow
  5352. };
  5353. event.preventDefault();
  5354. if (
  5355. // click on active header, but not collapsible
  5356. ( clickedIsActive && !options.collapsible ) ||
  5357. // allow canceling activation
  5358. ( this._trigger( "beforeActivate", event, eventData ) === false ) ) {
  5359. return;
  5360. }
  5361. options.active = collapsing ? false : this.headers.index( clicked );
  5362. // when the call to ._toggle() comes after the class changes
  5363. // it causes a very odd bug in IE 8 (see #6720)
  5364. this.active = clickedIsActive ? $() : clicked;
  5365. this._toggle( eventData );
  5366. // switch classes
  5367. // corner classes on the previously active header stay after the animation
  5368. active.removeClass( "ui-accordion-header-active ui-state-active" );
  5369. if ( options.icons ) {
  5370. active.children( ".ui-accordion-header-icon" )
  5371. .removeClass( options.icons.activeHeader )
  5372. .addClass( options.icons.header );
  5373. }
  5374. if ( !clickedIsActive ) {
  5375. clicked
  5376. .removeClass( "ui-corner-all" )
  5377. .addClass( "ui-accordion-header-active ui-state-active ui-corner-top" );
  5378. if ( options.icons ) {
  5379. clicked.children( ".ui-accordion-header-icon" )
  5380. .removeClass( options.icons.header )
  5381. .addClass( options.icons.activeHeader );
  5382. }
  5383. clicked
  5384. .next()
  5385. .addClass( "ui-accordion-content-active" );
  5386. }
  5387. },
  5388. _toggle: function( data ) {
  5389. var toShow = data.newPanel,
  5390. toHide = this.prevShow.length ? this.prevShow : data.oldPanel;
  5391. // handle activating a panel during the animation for another activation
  5392. this.prevShow.add( this.prevHide ).stop( true, true );
  5393. this.prevShow = toShow;
  5394. this.prevHide = toHide;
  5395. if ( this.options.animate ) {
  5396. this._animate( toShow, toHide, data );
  5397. } else {
  5398. toHide.hide();
  5399. toShow.show();
  5400. this._toggleComplete( data );
  5401. }
  5402. toHide.attr({
  5403. "aria-expanded": "false",
  5404. "aria-hidden": "true"
  5405. });
  5406. toHide.prev().attr( "aria-selected", "false" );
  5407. // if we're switching panels, remove the old header from the tab order
  5408. // if we're opening from collapsed state, remove the previous header from the tab order
  5409. // if we're collapsing, then keep the collapsing header in the tab order
  5410. if ( toShow.length && toHide.length ) {
  5411. toHide.prev().attr( "tabIndex", -1 );
  5412. } else if ( toShow.length ) {
  5413. this.headers.filter(function() {
  5414. return $( this ).attr( "tabIndex" ) === 0;
  5415. })
  5416. .attr( "tabIndex", -1 );
  5417. }
  5418. toShow
  5419. .attr({
  5420. "aria-expanded": "true",
  5421. "aria-hidden": "false"
  5422. })
  5423. .prev()
  5424. .attr({
  5425. "aria-selected": "true",
  5426. tabIndex: 0
  5427. });
  5428. },
  5429. _animate: function( toShow, toHide, data ) {
  5430. var total, easing, duration,
  5431. that = this,
  5432. adjust = 0,
  5433. down = toShow.length &&
  5434. ( !toHide.length || ( toShow.index() < toHide.index() ) ),
  5435. animate = this.options.animate || {},
  5436. options = down && animate.down || animate,
  5437. complete = function() {
  5438. that._toggleComplete( data );
  5439. };
  5440. if ( typeof options === "number" ) {
  5441. duration = options;
  5442. }
  5443. if ( typeof options === "string" ) {
  5444. easing = options;
  5445. }
  5446. // fall back from options to animation in case of partial down settings
  5447. easing = easing || options.easing || animate.easing;
  5448. duration = duration || options.duration || animate.duration;
  5449. if ( !toHide.length ) {
  5450. return toShow.animate( showProps, duration, easing, complete );
  5451. }
  5452. if ( !toShow.length ) {
  5453. return toHide.animate( hideProps, duration, easing, complete );
  5454. }
  5455. total = toShow.show().outerHeight();
  5456. toHide.animate( hideProps, {
  5457. duration: duration,
  5458. easing: easing,
  5459. step: function( now, fx ) {
  5460. fx.now = Math.round( now );
  5461. }
  5462. });
  5463. toShow
  5464. .hide()
  5465. .animate( showProps, {
  5466. duration: duration,
  5467. easing: easing,
  5468. complete: complete,
  5469. step: function( now, fx ) {
  5470. fx.now = Math.round( now );
  5471. if ( fx.prop !== "height" ) {
  5472. adjust += fx.now;
  5473. } else if ( that.options.heightStyle !== "content" ) {
  5474. fx.now = Math.round( total - toHide.outerHeight() - adjust );
  5475. adjust = 0;
  5476. }
  5477. }
  5478. });
  5479. },
  5480. _toggleComplete: function( data ) {
  5481. var toHide = data.oldPanel;
  5482. toHide
  5483. .removeClass( "ui-accordion-content-active" )
  5484. .prev()
  5485. .removeClass( "ui-corner-top" )
  5486. .addClass( "ui-corner-all" );
  5487. // Work around for rendering bug in IE (#5421)
  5488. if ( toHide.length ) {
  5489. toHide.parent()[0].className = toHide.parent()[0].className;
  5490. }
  5491. this._trigger( "activate", null, data );
  5492. }
  5493. });
  5494. })( jQuery );
  5495. (function( $, undefined ) {
  5496. // used to prevent race conditions with remote data sources
  5497. var requestIndex = 0;
  5498. $.widget( "ui.autocomplete", {
  5499. version: "1.10.2",
  5500. defaultElement: "<input>",
  5501. options: {
  5502. appendTo: null,
  5503. autoFocus: false,
  5504. delay: 300,
  5505. minLength: 1,
  5506. position: {
  5507. my: "left top",
  5508. at: "left bottom",
  5509. collision: "none"
  5510. },
  5511. source: null,
  5512. // callbacks
  5513. change: null,
  5514. close: null,
  5515. focus: null,
  5516. open: null,
  5517. response: null,
  5518. search: null,
  5519. select: null
  5520. },
  5521. pending: 0,
  5522. _create: function() {
  5523. // Some browsers only repeat keydown events, not keypress events,
  5524. // so we use the suppressKeyPress flag to determine if we've already
  5525. // handled the keydown event. #7269
  5526. // Unfortunately the code for & in keypress is the same as the up arrow,
  5527. // so we use the suppressKeyPressRepeat flag to avoid handling keypress
  5528. // events when we know the keydown event was used to modify the
  5529. // search term. #7799
  5530. var suppressKeyPress, suppressKeyPressRepeat, suppressInput,
  5531. nodeName = this.element[0].nodeName.toLowerCase(),
  5532. isTextarea = nodeName === "textarea",
  5533. isInput = nodeName === "input";
  5534. this.isMultiLine =
  5535. // Textareas are always multi-line
  5536. isTextarea ? true :
  5537. // Inputs are always single-line, even if inside a contentEditable element
  5538. // IE also treats inputs as contentEditable
  5539. isInput ? false :
  5540. // All other element types are determined by whether or not they're contentEditable
  5541. this.element.prop( "isContentEditable" );
  5542. this.valueMethod = this.element[ isTextarea || isInput ? "val" : "text" ];
  5543. this.isNewMenu = true;
  5544. this.element
  5545. .addClass( "ui-autocomplete-input" )
  5546. .attr( "autocomplete", "off" );
  5547. this._on( this.element, {
  5548. keydown: function( event ) {
  5549. /*jshint maxcomplexity:15*/
  5550. if ( this.element.prop( "readOnly" ) ) {
  5551. suppressKeyPress = true;
  5552. suppressInput = true;
  5553. suppressKeyPressRepeat = true;
  5554. return;
  5555. }
  5556. suppressKeyPress = false;
  5557. suppressInput = false;
  5558. suppressKeyPressRepeat = false;
  5559. var keyCode = $.ui.keyCode;
  5560. switch( event.keyCode ) {
  5561. case keyCode.PAGE_UP:
  5562. suppressKeyPress = true;
  5563. this._move( "previousPage", event );
  5564. break;
  5565. case keyCode.PAGE_DOWN:
  5566. suppressKeyPress = true;
  5567. this._move( "nextPage", event );
  5568. break;
  5569. case keyCode.UP:
  5570. suppressKeyPress = true;
  5571. this._keyEvent( "previous", event );
  5572. break;
  5573. case keyCode.DOWN:
  5574. suppressKeyPress = true;
  5575. this._keyEvent( "next", event );
  5576. break;
  5577. case keyCode.ENTER:
  5578. case keyCode.NUMPAD_ENTER:
  5579. // when menu is open and has focus
  5580. if ( this.menu.active ) {
  5581. // #6055 - Opera still allows the keypress to occur
  5582. // which causes forms to submit
  5583. suppressKeyPress = true;
  5584. event.preventDefault();
  5585. this.menu.select( event );
  5586. }
  5587. break;
  5588. case keyCode.TAB:
  5589. if ( this.menu.active ) {
  5590. this.menu.select( event );
  5591. }
  5592. break;
  5593. case keyCode.ESCAPE:
  5594. if ( this.menu.element.is( ":visible" ) ) {
  5595. this._value( this.term );
  5596. this.close( event );
  5597. // Different browsers have different default behavior for escape
  5598. // Single press can mean undo or clear
  5599. // Double press in IE means clear the whole form
  5600. event.preventDefault();
  5601. }
  5602. break;
  5603. default:
  5604. suppressKeyPressRepeat = true;
  5605. // search timeout should be triggered before the input value is changed
  5606. this._searchTimeout( event );
  5607. break;
  5608. }
  5609. },
  5610. keypress: function( event ) {
  5611. if ( suppressKeyPress ) {
  5612. suppressKeyPress = false;
  5613. event.preventDefault();
  5614. return;
  5615. }
  5616. if ( suppressKeyPressRepeat ) {
  5617. return;
  5618. }
  5619. // replicate some key handlers to allow them to repeat in Firefox and Opera
  5620. var keyCode = $.ui.keyCode;
  5621. switch( event.keyCode ) {
  5622. case keyCode.PAGE_UP:
  5623. this._move( "previousPage", event );
  5624. break;
  5625. case keyCode.PAGE_DOWN:
  5626. this._move( "nextPage", event );
  5627. break;
  5628. case keyCode.UP:
  5629. this._keyEvent( "previous", event );
  5630. break;
  5631. case keyCode.DOWN:
  5632. this._keyEvent( "next", event );
  5633. break;
  5634. }
  5635. },
  5636. input: function( event ) {
  5637. if ( suppressInput ) {
  5638. suppressInput = false;
  5639. event.preventDefault();
  5640. return;
  5641. }
  5642. this._searchTimeout( event );
  5643. },
  5644. focus: function() {
  5645. this.selectedItem = null;
  5646. this.previous = this._value();
  5647. },
  5648. blur: function( event ) {
  5649. if ( this.cancelBlur ) {
  5650. delete this.cancelBlur;
  5651. return;
  5652. }
  5653. clearTimeout( this.searching );
  5654. this.close( event );
  5655. this._change( event );
  5656. }
  5657. });
  5658. this._initSource();
  5659. this.menu = $( "<ul>" )
  5660. .addClass( "ui-autocomplete ui-front" )
  5661. .appendTo( this._appendTo() )
  5662. .menu({
  5663. // custom key handling for now
  5664. input: $(),
  5665. // disable ARIA support, the live region takes care of that
  5666. role: null
  5667. })
  5668. .hide()
  5669. .data( "ui-menu" );
  5670. this._on( this.menu.element, {
  5671. mousedown: function( event ) {
  5672. // prevent moving focus out of the text field
  5673. event.preventDefault();
  5674. // IE doesn't prevent moving focus even with event.preventDefault()
  5675. // so we set a flag to know when we should ignore the blur event
  5676. this.cancelBlur = true;
  5677. this._delay(function() {
  5678. delete this.cancelBlur;
  5679. });
  5680. // clicking on the scrollbar causes focus to shift to the body
  5681. // but we can't detect a mouseup or a click immediately afterward
  5682. // so we have to track the next mousedown and close the menu if
  5683. // the user clicks somewhere outside of the autocomplete
  5684. var menuElement = this.menu.element[ 0 ];
  5685. if ( !$( event.target ).closest( ".ui-menu-item" ).length ) {
  5686. this._delay(function() {
  5687. var that = this;
  5688. this.document.one( "mousedown", function( event ) {
  5689. if ( event.target !== that.element[ 0 ] &&
  5690. event.target !== menuElement &&
  5691. !$.contains( menuElement, event.target ) ) {
  5692. that.close();
  5693. }
  5694. });
  5695. });
  5696. }
  5697. },
  5698. menufocus: function( event, ui ) {
  5699. // support: Firefox
  5700. // Prevent accidental activation of menu items in Firefox (#7024 #9118)
  5701. if ( this.isNewMenu ) {
  5702. this.isNewMenu = false;
  5703. if ( event.originalEvent && /^mouse/.test( event.originalEvent.type ) ) {
  5704. this.menu.blur();
  5705. this.document.one( "mousemove", function() {
  5706. $( event.target ).trigger( event.originalEvent );
  5707. });
  5708. return;
  5709. }
  5710. }
  5711. var item = ui.item.data( "ui-autocomplete-item" );
  5712. if ( false !== this._trigger( "focus", event, { item: item } ) ) {
  5713. // use value to match what will end up in the input, if it was a key event
  5714. if ( event.originalEvent && /^key/.test( event.originalEvent.type ) ) {
  5715. this._value( item.value );
  5716. }
  5717. } else {
  5718. // Normally the input is populated with the item's value as the
  5719. // menu is navigated, causing screen readers to notice a change and
  5720. // announce the item. Since the focus event was canceled, this doesn't
  5721. // happen, so we update the live region so that screen readers can
  5722. // still notice the change and announce it.
  5723. this.liveRegion.text( item.value );
  5724. }
  5725. },
  5726. menuselect: function( event, ui ) {
  5727. var item = ui.item.data( "ui-autocomplete-item" ),
  5728. previous = this.previous;
  5729. // only trigger when focus was lost (click on menu)
  5730. if ( this.element[0] !== this.document[0].activeElement ) {
  5731. this.element.focus();
  5732. this.previous = previous;
  5733. // #6109 - IE triggers two focus events and the second
  5734. // is asynchronous, so we need to reset the previous
  5735. // term synchronously and asynchronously :-(
  5736. this._delay(function() {
  5737. this.previous = previous;
  5738. this.selectedItem = item;
  5739. });
  5740. }
  5741. if ( false !== this._trigger( "select", event, { item: item } ) ) {
  5742. this._value( item.value );
  5743. }
  5744. // reset the term after the select event
  5745. // this allows custom select handling to work properly
  5746. this.term = this._value();
  5747. this.close( event );
  5748. this.selectedItem = item;
  5749. }
  5750. });
  5751. this.liveRegion = $( "<span>", {
  5752. role: "status",
  5753. "aria-live": "polite"
  5754. })
  5755. .addClass( "ui-helper-hidden-accessible" )
  5756. .insertAfter( this.element );
  5757. // turning off autocomplete prevents the browser from remembering the
  5758. // value when navigating through history, so we re-enable autocomplete
  5759. // if the page is unloaded before the widget is destroyed. #7790
  5760. this._on( this.window, {
  5761. beforeunload: function() {
  5762. this.element.removeAttr( "autocomplete" );
  5763. }
  5764. });
  5765. },
  5766. _destroy: function() {
  5767. clearTimeout( this.searching );
  5768. this.element
  5769. .removeClass( "ui-autocomplete-input" )
  5770. .removeAttr( "autocomplete" );
  5771. this.menu.element.remove();
  5772. this.liveRegion.remove();
  5773. },
  5774. _setOption: function( key, value ) {
  5775. this._super( key, value );
  5776. if ( key === "source" ) {
  5777. this._initSource();
  5778. }
  5779. if ( key === "appendTo" ) {
  5780. this.menu.element.appendTo( this._appendTo() );
  5781. }
  5782. if ( key === "disabled" && value && this.xhr ) {
  5783. this.xhr.abort();
  5784. }
  5785. },
  5786. _appendTo: function() {
  5787. var element = this.options.appendTo;
  5788. if ( element ) {
  5789. element = element.jquery || element.nodeType ?
  5790. $( element ) :
  5791. this.document.find( element ).eq( 0 );
  5792. }
  5793. if ( !element ) {
  5794. element = this.element.closest( ".ui-front" );
  5795. }
  5796. if ( !element.length ) {
  5797. element = this.document[0].body;
  5798. }
  5799. return element;
  5800. },
  5801. _initSource: function() {
  5802. var array, url,
  5803. that = this;
  5804. if ( $.isArray(this.options.source) ) {
  5805. array = this.options.source;
  5806. this.source = function( request, response ) {
  5807. response( $.ui.autocomplete.filter( array, request.term ) );
  5808. };
  5809. } else if ( typeof this.options.source === "string" ) {
  5810. url = this.options.source;
  5811. this.source = function( request, response ) {
  5812. if ( that.xhr ) {
  5813. that.xhr.abort();
  5814. }
  5815. that.xhr = $.ajax({
  5816. url: url,
  5817. data: request,
  5818. dataType: "json",
  5819. success: function( data ) {
  5820. response( data );
  5821. },
  5822. error: function() {
  5823. response( [] );
  5824. }
  5825. });
  5826. };
  5827. } else {
  5828. this.source = this.options.source;
  5829. }
  5830. },
  5831. _searchTimeout: function( event ) {
  5832. clearTimeout( this.searching );
  5833. this.searching = this._delay(function() {
  5834. // only search if the value has changed
  5835. if ( this.term !== this._value() ) {
  5836. this.selectedItem = null;
  5837. this.search( null, event );
  5838. }
  5839. }, this.options.delay );
  5840. },
  5841. search: function( value, event ) {
  5842. value = value != null ? value : this._value();
  5843. // always save the actual value, not the one passed as an argument
  5844. this.term = this._value();
  5845. if ( value.length < this.options.minLength ) {
  5846. return this.close( event );
  5847. }
  5848. if ( this._trigger( "search", event ) === false ) {
  5849. return;
  5850. }
  5851. return this._search( value );
  5852. },
  5853. _search: function( value ) {
  5854. this.pending++;
  5855. this.element.addClass( "ui-autocomplete-loading" );
  5856. this.cancelSearch = false;
  5857. this.source( { term: value }, this._response() );
  5858. },
  5859. _response: function() {
  5860. var that = this,
  5861. index = ++requestIndex;
  5862. return function( content ) {
  5863. if ( index === requestIndex ) {
  5864. that.__response( content );
  5865. }
  5866. that.pending--;
  5867. if ( !that.pending ) {
  5868. that.element.removeClass( "ui-autocomplete-loading" );
  5869. }
  5870. };
  5871. },
  5872. __response: function( content ) {
  5873. if ( content ) {
  5874. content = this._normalize( content );
  5875. }
  5876. this._trigger( "response", null, { content: content } );
  5877. if ( !this.options.disabled && content && content.length && !this.cancelSearch ) {
  5878. this._suggest( content );
  5879. this._trigger( "open" );
  5880. } else {
  5881. // use ._close() instead of .close() so we don't cancel future searches
  5882. this._close();
  5883. }
  5884. },
  5885. close: function( event ) {
  5886. this.cancelSearch = true;
  5887. this._close( event );
  5888. },
  5889. _close: function( event ) {
  5890. if ( this.menu.element.is( ":visible" ) ) {
  5891. this.menu.element.hide();
  5892. this.menu.blur();
  5893. this.isNewMenu = true;
  5894. this._trigger( "close", event );
  5895. }
  5896. },
  5897. _change: function( event ) {
  5898. if ( this.previous !== this._value() ) {
  5899. this._trigger( "change", event, { item: this.selectedItem } );
  5900. }
  5901. },
  5902. _normalize: function( items ) {
  5903. // assume all items have the right format when the first item is complete
  5904. if ( items.length && items[0].label && items[0].value ) {
  5905. return items;
  5906. }
  5907. return $.map( items, function( item ) {
  5908. if ( typeof item === "string" ) {
  5909. return {
  5910. label: item,
  5911. value: item
  5912. };
  5913. }
  5914. return $.extend({
  5915. label: item.label || item.value,
  5916. value: item.value || item.label
  5917. }, item );
  5918. });
  5919. },
  5920. _suggest: function( items ) {
  5921. var ul = this.menu.element.empty();
  5922. this._renderMenu( ul, items );
  5923. this.isNewMenu = true;
  5924. this.menu.refresh();
  5925. // size and position menu
  5926. ul.show();
  5927. this._resizeMenu();
  5928. ul.position( $.extend({
  5929. of: this.element
  5930. }, this.options.position ));
  5931. if ( this.options.autoFocus ) {
  5932. this.menu.next();
  5933. }
  5934. },
  5935. _resizeMenu: function() {
  5936. var ul = this.menu.element;
  5937. ul.outerWidth( Math.max(
  5938. // Firefox wraps long text (possibly a rounding bug)
  5939. // so we add 1px to avoid the wrapping (#7513)
  5940. ul.width( "" ).outerWidth() + 1,
  5941. this.element.outerWidth()
  5942. ) );
  5943. },
  5944. _renderMenu: function( ul, items ) {
  5945. var that = this;
  5946. $.each( items, function( index, item ) {
  5947. that._renderItemData( ul, item );
  5948. });
  5949. },
  5950. _renderItemData: function( ul, item ) {
  5951. return this._renderItem( ul, item ).data( "ui-autocomplete-item", item );
  5952. },
  5953. _renderItem: function( ul, item ) {
  5954. return $( "<li>" )
  5955. .append( $( "<a>" ).text( item.label ) )
  5956. .appendTo( ul );
  5957. },
  5958. _move: function( direction, event ) {
  5959. if ( !this.menu.element.is( ":visible" ) ) {
  5960. this.search( null, event );
  5961. return;
  5962. }
  5963. if ( this.menu.isFirstItem() && /^previous/.test( direction ) ||
  5964. this.menu.isLastItem() && /^next/.test( direction ) ) {
  5965. this._value( this.term );
  5966. this.menu.blur();
  5967. return;
  5968. }
  5969. this.menu[ direction ]( event );
  5970. },
  5971. widget: function() {
  5972. return this.menu.element;
  5973. },
  5974. _value: function() {
  5975. return this.valueMethod.apply( this.element, arguments );
  5976. },
  5977. _keyEvent: function( keyEvent, event ) {
  5978. if ( !this.isMultiLine || this.menu.element.is( ":visible" ) ) {
  5979. this._move( keyEvent, event );
  5980. // prevents moving cursor to beginning/end of the text field in some browsers
  5981. event.preventDefault();
  5982. }
  5983. }
  5984. });
  5985. $.extend( $.ui.autocomplete, {
  5986. escapeRegex: function( value ) {
  5987. return value.replace(/[\-\[\]{}()*+?.,\\\^$|#\s]/g, "\\$&");
  5988. },
  5989. filter: function(array, term) {
  5990. var matcher = new RegExp( $.ui.autocomplete.escapeRegex(term), "i" );
  5991. return $.grep( array, function(value) {
  5992. return matcher.test( value.label || value.value || value );
  5993. });
  5994. }
  5995. });
  5996. // live region extension, adding a `messages` option
  5997. // NOTE: This is an experimental API. We are still investigating
  5998. // a full solution for string manipulation and internationalization.
  5999. $.widget( "ui.autocomplete", $.ui.autocomplete, {
  6000. options: {
  6001. messages: {
  6002. noResults: "No search results.",
  6003. results: function( amount ) {
  6004. return amount + ( amount > 1 ? " results are" : " result is" ) +
  6005. " available, use up and down arrow keys to navigate.";
  6006. }
  6007. }
  6008. },
  6009. __response: function( content ) {
  6010. var message;
  6011. this._superApply( arguments );
  6012. if ( this.options.disabled || this.cancelSearch ) {
  6013. return;
  6014. }
  6015. if ( content && content.length ) {
  6016. message = this.options.messages.results( content.length );
  6017. } else {
  6018. message = this.options.messages.noResults;
  6019. }
  6020. this.liveRegion.text( message );
  6021. }
  6022. });
  6023. }( jQuery ));
  6024. (function( $, undefined ) {
  6025. var lastActive, startXPos, startYPos, clickDragged,
  6026. baseClasses = "ui-button ui-widget ui-state-default ui-corner-all",
  6027. stateClasses = "ui-state-hover ui-state-active ",
  6028. 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",
  6029. formResetHandler = function() {
  6030. var buttons = $( this ).find( ":ui-button" );
  6031. setTimeout(function() {
  6032. buttons.button( "refresh" );
  6033. }, 1 );
  6034. },
  6035. radioGroup = function( radio ) {
  6036. var name = radio.name,
  6037. form = radio.form,
  6038. radios = $( [] );
  6039. if ( name ) {
  6040. name = name.replace( /'/g, "\\'" );
  6041. if ( form ) {
  6042. radios = $( form ).find( "[name='" + name + "']" );
  6043. } else {
  6044. radios = $( "[name='" + name + "']", radio.ownerDocument )
  6045. .filter(function() {
  6046. return !this.form;
  6047. });
  6048. }
  6049. }
  6050. return radios;
  6051. };
  6052. $.widget( "ui.button", {
  6053. version: "1.10.2",
  6054. defaultElement: "<button>",
  6055. options: {
  6056. disabled: null,
  6057. text: true,
  6058. label: null,
  6059. icons: {
  6060. primary: null,
  6061. secondary: null
  6062. }
  6063. },
  6064. _create: function() {
  6065. this.element.closest( "form" )
  6066. .unbind( "reset" + this.eventNamespace )
  6067. .bind( "reset" + this.eventNamespace, formResetHandler );
  6068. if ( typeof this.options.disabled !== "boolean" ) {
  6069. this.options.disabled = !!this.element.prop( "disabled" );
  6070. } else {
  6071. this.element.prop( "disabled", this.options.disabled );
  6072. }
  6073. this._determineButtonType();
  6074. this.hasTitle = !!this.buttonElement.attr( "title" );
  6075. var that = this,
  6076. options = this.options,
  6077. toggleButton = this.type === "checkbox" || this.type === "radio",
  6078. activeClass = !toggleButton ? "ui-state-active" : "",
  6079. focusClass = "ui-state-focus";
  6080. if ( options.label === null ) {
  6081. options.label = (this.type === "input" ? this.buttonElement.val() : this.buttonElement.html());
  6082. }
  6083. this._hoverable( this.buttonElement );
  6084. this.buttonElement
  6085. .addClass( baseClasses )
  6086. .attr( "role", "button" )
  6087. .bind( "mouseenter" + this.eventNamespace, function() {
  6088. if ( options.disabled ) {
  6089. return;
  6090. }
  6091. if ( this === lastActive ) {
  6092. $( this ).addClass( "ui-state-active" );
  6093. }
  6094. })
  6095. .bind( "mouseleave" + this.eventNamespace, function() {
  6096. if ( options.disabled ) {
  6097. return;
  6098. }
  6099. $( this ).removeClass( activeClass );
  6100. })
  6101. .bind( "click" + this.eventNamespace, function( event ) {
  6102. if ( options.disabled ) {
  6103. event.preventDefault();
  6104. event.stopImmediatePropagation();
  6105. }
  6106. });
  6107. this.element
  6108. .bind( "focus" + this.eventNamespace, function() {
  6109. // no need to check disabled, focus won't be triggered anyway
  6110. that.buttonElement.addClass( focusClass );
  6111. })
  6112. .bind( "blur" + this.eventNamespace, function() {
  6113. that.buttonElement.removeClass( focusClass );
  6114. });
  6115. if ( toggleButton ) {
  6116. this.element.bind( "change" + this.eventNamespace, function() {
  6117. if ( clickDragged ) {
  6118. return;
  6119. }
  6120. that.refresh();
  6121. });
  6122. // if mouse moves between mousedown and mouseup (drag) set clickDragged flag
  6123. // prevents issue where button state changes but checkbox/radio checked state
  6124. // does not in Firefox (see ticket #6970)
  6125. this.buttonElement
  6126. .bind( "mousedown" + this.eventNamespace, function( event ) {
  6127. if ( options.disabled ) {
  6128. return;
  6129. }
  6130. clickDragged = false;
  6131. startXPos = event.pageX;
  6132. startYPos = event.pageY;
  6133. })
  6134. .bind( "mouseup" + this.eventNamespace, function( event ) {
  6135. if ( options.disabled ) {
  6136. return;
  6137. }
  6138. if ( startXPos !== event.pageX || startYPos !== event.pageY ) {
  6139. clickDragged = true;
  6140. }
  6141. });
  6142. }
  6143. if ( this.type === "checkbox" ) {
  6144. this.buttonElement.bind( "click" + this.eventNamespace, function() {
  6145. if ( options.disabled || clickDragged ) {
  6146. return false;
  6147. }
  6148. });
  6149. } else if ( this.type === "radio" ) {
  6150. this.buttonElement.bind( "click" + this.eventNamespace, function() {
  6151. if ( options.disabled || clickDragged ) {
  6152. return false;
  6153. }
  6154. $( this ).addClass( "ui-state-active" );
  6155. that.buttonElement.attr( "aria-pressed", "true" );
  6156. var radio = that.element[ 0 ];
  6157. radioGroup( radio )
  6158. .not( radio )
  6159. .map(function() {
  6160. return $( this ).button( "widget" )[ 0 ];
  6161. })
  6162. .removeClass( "ui-state-active" )
  6163. .attr( "aria-pressed", "false" );
  6164. });
  6165. } else {
  6166. this.buttonElement
  6167. .bind( "mousedown" + this.eventNamespace, function() {
  6168. if ( options.disabled ) {
  6169. return false;
  6170. }
  6171. $( this ).addClass( "ui-state-active" );
  6172. lastActive = this;
  6173. that.document.one( "mouseup", function() {
  6174. lastActive = null;
  6175. });
  6176. })
  6177. .bind( "mouseup" + this.eventNamespace, function() {
  6178. if ( options.disabled ) {
  6179. return false;
  6180. }
  6181. $( this ).removeClass( "ui-state-active" );
  6182. })
  6183. .bind( "keydown" + this.eventNamespace, function(event) {
  6184. if ( options.disabled ) {
  6185. return false;
  6186. }
  6187. if ( event.keyCode === $.ui.keyCode.SPACE || event.keyCode === $.ui.keyCode.ENTER ) {
  6188. $( this ).addClass( "ui-state-active" );
  6189. }
  6190. })
  6191. // see #8559, we bind to blur here in case the button element loses
  6192. // focus between keydown and keyup, it would be left in an "active" state
  6193. .bind( "keyup" + this.eventNamespace + " blur" + this.eventNamespace, function() {
  6194. $( this ).removeClass( "ui-state-active" );
  6195. });
  6196. if ( this.buttonElement.is("a") ) {
  6197. this.buttonElement.keyup(function(event) {
  6198. if ( event.keyCode === $.ui.keyCode.SPACE ) {
  6199. // TODO pass through original event correctly (just as 2nd argument doesn't work)
  6200. $( this ).click();
  6201. }
  6202. });
  6203. }
  6204. }
  6205. // TODO: pull out $.Widget's handling for the disabled option into
  6206. // $.Widget.prototype._setOptionDisabled so it's easy to proxy and can
  6207. // be overridden by individual plugins
  6208. this._setOption( "disabled", options.disabled );
  6209. this._resetButton();
  6210. },
  6211. _determineButtonType: function() {
  6212. var ancestor, labelSelector, checked;
  6213. if ( this.element.is("[type=checkbox]") ) {
  6214. this.type = "checkbox";
  6215. } else if ( this.element.is("[type=radio]") ) {
  6216. this.type = "radio";
  6217. } else if ( this.element.is("input") ) {
  6218. this.type = "input";
  6219. } else {
  6220. this.type = "button";
  6221. }
  6222. if ( this.type === "checkbox" || this.type === "radio" ) {
  6223. // we don't search against the document in case the element
  6224. // is disconnected from the DOM
  6225. ancestor = this.element.parents().last();
  6226. labelSelector = "label[for='" + this.element.attr("id") + "']";
  6227. this.buttonElement = ancestor.find( labelSelector );
  6228. if ( !this.buttonElement.length ) {
  6229. ancestor = ancestor.length ? ancestor.siblings() : this.element.siblings();
  6230. this.buttonElement = ancestor.filter( labelSelector );
  6231. if ( !this.buttonElement.length ) {
  6232. this.buttonElement = ancestor.find( labelSelector );
  6233. }
  6234. }
  6235. this.element.addClass( "ui-helper-hidden-accessible" );
  6236. checked = this.element.is( ":checked" );
  6237. if ( checked ) {
  6238. this.buttonElement.addClass( "ui-state-active" );
  6239. }
  6240. this.buttonElement.prop( "aria-pressed", checked );
  6241. } else {
  6242. this.buttonElement = this.element;
  6243. }
  6244. },
  6245. widget: function() {
  6246. return this.buttonElement;
  6247. },
  6248. _destroy: function() {
  6249. this.element
  6250. .removeClass( "ui-helper-hidden-accessible" );
  6251. this.buttonElement
  6252. .removeClass( baseClasses + " " + stateClasses + " " + typeClasses )
  6253. .removeAttr( "role" )
  6254. .removeAttr( "aria-pressed" )
  6255. .html( this.buttonElement.find(".ui-button-text").html() );
  6256. if ( !this.hasTitle ) {
  6257. this.buttonElement.removeAttr( "title" );
  6258. }
  6259. },
  6260. _setOption: function( key, value ) {
  6261. this._super( key, value );
  6262. if ( key === "disabled" ) {
  6263. if ( value ) {
  6264. this.element.prop( "disabled", true );
  6265. } else {
  6266. this.element.prop( "disabled", false );
  6267. }
  6268. return;
  6269. }
  6270. this._resetButton();
  6271. },
  6272. refresh: function() {
  6273. //See #8237 & #8828
  6274. var isDisabled = this.element.is( "input, button" ) ? this.element.is( ":disabled" ) : this.element.hasClass( "ui-button-disabled" );
  6275. if ( isDisabled !== this.options.disabled ) {
  6276. this._setOption( "disabled", isDisabled );
  6277. }
  6278. if ( this.type === "radio" ) {
  6279. radioGroup( this.element[0] ).each(function() {
  6280. if ( $( this ).is( ":checked" ) ) {
  6281. $( this ).button( "widget" )
  6282. .addClass( "ui-state-active" )
  6283. .attr( "aria-pressed", "true" );
  6284. } else {
  6285. $( this ).button( "widget" )
  6286. .removeClass( "ui-state-active" )
  6287. .attr( "aria-pressed", "false" );
  6288. }
  6289. });
  6290. } else if ( this.type === "checkbox" ) {
  6291. if ( this.element.is( ":checked" ) ) {
  6292. this.buttonElement
  6293. .addClass( "ui-state-active" )
  6294. .attr( "aria-pressed", "true" );
  6295. } else {
  6296. this.buttonElement
  6297. .removeClass( "ui-state-active" )
  6298. .attr( "aria-pressed", "false" );
  6299. }
  6300. }
  6301. },
  6302. _resetButton: function() {
  6303. if ( this.type === "input" ) {
  6304. if ( this.options.label ) {
  6305. this.element.val( this.options.label );
  6306. }
  6307. return;
  6308. }
  6309. var buttonElement = this.buttonElement.removeClass( typeClasses ),
  6310. buttonText = $( "<span></span>", this.document[0] )
  6311. .addClass( "ui-button-text" )
  6312. .html( this.options.label )
  6313. .appendTo( buttonElement.empty() )
  6314. .text(),
  6315. icons = this.options.icons,
  6316. multipleIcons = icons.primary && icons.secondary,
  6317. buttonClasses = [];
  6318. if ( icons.primary || icons.secondary ) {
  6319. if ( this.options.text ) {
  6320. buttonClasses.push( "ui-button-text-icon" + ( multipleIcons ? "s" : ( icons.primary ? "-primary" : "-secondary" ) ) );
  6321. }
  6322. if ( icons.primary ) {
  6323. buttonElement.prepend( "<span class='ui-button-icon-primary ui-icon " + icons.primary + "'></span>" );
  6324. }
  6325. if ( icons.secondary ) {
  6326. buttonElement.append( "<span class='ui-button-icon-secondary ui-icon " + icons.secondary + "'></span>" );
  6327. }
  6328. if ( !this.options.text ) {
  6329. buttonClasses.push( multipleIcons ? "ui-button-icons-only" : "ui-button-icon-only" );
  6330. if ( !this.hasTitle ) {
  6331. buttonElement.attr( "title", $.trim( buttonText ) );
  6332. }
  6333. }
  6334. } else {
  6335. buttonClasses.push( "ui-button-text-only" );
  6336. }
  6337. buttonElement.addClass( buttonClasses.join( " " ) );
  6338. }
  6339. });
  6340. $.widget( "ui.buttonset", {
  6341. version: "1.10.2",
  6342. options: {
  6343. items: "button, input[type=button], input[type=submit], input[type=reset], input[type=checkbox], input[type=radio], a, :data(ui-button)"
  6344. },
  6345. _create: function() {
  6346. this.element.addClass( "ui-buttonset" );
  6347. },
  6348. _init: function() {
  6349. this.refresh();
  6350. },
  6351. _setOption: function( key, value ) {
  6352. if ( key === "disabled" ) {
  6353. this.buttons.button( "option", key, value );
  6354. }
  6355. this._super( key, value );
  6356. },
  6357. refresh: function() {
  6358. var rtl = this.element.css( "direction" ) === "rtl";
  6359. this.buttons = this.element.find( this.options.items )
  6360. .filter( ":ui-button" )
  6361. .button( "refresh" )
  6362. .end()
  6363. .not( ":ui-button" )
  6364. .button()
  6365. .end()
  6366. .map(function() {
  6367. return $( this ).button( "widget" )[ 0 ];
  6368. })
  6369. .removeClass( "ui-corner-all ui-corner-left ui-corner-right" )
  6370. .filter( ":first" )
  6371. .addClass( rtl ? "ui-corner-right" : "ui-corner-left" )
  6372. .end()
  6373. .filter( ":last" )
  6374. .addClass( rtl ? "ui-corner-left" : "ui-corner-right" )
  6375. .end()
  6376. .end();
  6377. },
  6378. _destroy: function() {
  6379. this.element.removeClass( "ui-buttonset" );
  6380. this.buttons
  6381. .map(function() {
  6382. return $( this ).button( "widget" )[ 0 ];
  6383. })
  6384. .removeClass( "ui-corner-left ui-corner-right" )
  6385. .end()
  6386. .button( "destroy" );
  6387. }
  6388. });
  6389. }( jQuery ) );
  6390. (function( $, undefined ) {
  6391. $.extend($.ui, { datepicker: { version: "1.10.2" } });
  6392. var PROP_NAME = "datepicker",
  6393. dpuuid = new Date().getTime(),
  6394. instActive;
  6395. /* Date picker manager.
  6396. Use the singleton instance of this class, $.datepicker, to interact with the date picker.
  6397. Settings for (groups of) date pickers are maintained in an instance object,
  6398. allowing multiple different settings on the same page. */
  6399. function Datepicker() {
  6400. this._curInst = null; // The current instance in use
  6401. this._keyEvent = false; // If the last event was a key event
  6402. this._disabledInputs = []; // List of date picker inputs that have been disabled
  6403. this._datepickerShowing = false; // True if the popup picker is showing , false if not
  6404. this._inDialog = false; // True if showing within a "dialog", false if not
  6405. this._mainDivId = "ui-datepicker-div"; // The ID of the main datepicker division
  6406. this._inlineClass = "ui-datepicker-inline"; // The name of the inline marker class
  6407. this._appendClass = "ui-datepicker-append"; // The name of the append marker class
  6408. this._triggerClass = "ui-datepicker-trigger"; // The name of the trigger marker class
  6409. this._dialogClass = "ui-datepicker-dialog"; // The name of the dialog marker class
  6410. this._disableClass = "ui-datepicker-disabled"; // The name of the disabled covering marker class
  6411. this._unselectableClass = "ui-datepicker-unselectable"; // The name of the unselectable cell marker class
  6412. this._currentClass = "ui-datepicker-current-day"; // The name of the current day marker class
  6413. this._dayOverClass = "ui-datepicker-days-cell-over"; // The name of the day hover marker class
  6414. this.regional = []; // Available regional settings, indexed by language code
  6415. this.regional[""] = { // Default regional settings
  6416. closeText: "Done", // Display text for close link
  6417. prevText: "Prev", // Display text for previous month link
  6418. nextText: "Next", // Display text for next month link
  6419. currentText: "Today", // Display text for current month link
  6420. monthNames: ["January","February","March","April","May","June",
  6421. "July","August","September","October","November","December"], // Names of months for drop-down and formatting
  6422. monthNamesShort: ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"], // For formatting
  6423. dayNames: ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"], // For formatting
  6424. dayNamesShort: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"], // For formatting
  6425. dayNamesMin: ["Su","Mo","Tu","We","Th","Fr","Sa"], // Column headings for days starting at Sunday
  6426. weekHeader: "Wk", // Column header for week of the year
  6427. dateFormat: "mm/dd/yy", // See format options on parseDate
  6428. firstDay: 0, // The first day of the week, Sun = 0, Mon = 1, ...
  6429. isRTL: false, // True if right-to-left language, false if left-to-right
  6430. showMonthAfterYear: false, // True if the year select precedes month, false for month then year
  6431. yearSuffix: "" // Additional text to append to the year in the month headers
  6432. };
  6433. this._defaults = { // Global defaults for all the date picker instances
  6434. showOn: "focus", // "focus" for popup on focus,
  6435. // "button" for trigger button, or "both" for either
  6436. showAnim: "fadeIn", // Name of jQuery animation for popup
  6437. showOptions: {}, // Options for enhanced animations
  6438. defaultDate: null, // Used when field is blank: actual date,
  6439. // +/-number for offset from today, null for today
  6440. appendText: "", // Display text following the input box, e.g. showing the format
  6441. buttonText: "...", // Text for trigger button
  6442. buttonImage: "", // URL for trigger button image
  6443. buttonImageOnly: false, // True if the image appears alone, false if it appears on a button
  6444. hideIfNoPrevNext: false, // True to hide next/previous month links
  6445. // if not applicable, false to just disable them
  6446. navigationAsDateFormat: false, // True if date formatting applied to prev/today/next links
  6447. gotoCurrent: false, // True if today link goes back to current selection instead
  6448. changeMonth: false, // True if month can be selected directly, false if only prev/next
  6449. changeYear: false, // True if year can be selected directly, false if only prev/next
  6450. yearRange: "c-10:c+10", // Range of years to display in drop-down,
  6451. // either relative to today's year (-nn:+nn), relative to currently displayed year
  6452. // (c-nn:c+nn), absolute (nnnn:nnnn), or a combination of the above (nnnn:-n)
  6453. showOtherMonths: false, // True to show dates in other months, false to leave blank
  6454. selectOtherMonths: false, // True to allow selection of dates in other months, false for unselectable
  6455. showWeek: false, // True to show week of the year, false to not show it
  6456. calculateWeek: this.iso8601Week, // How to calculate the week of the year,
  6457. // takes a Date and returns the number of the week for it
  6458. shortYearCutoff: "+10", // Short year values < this are in the current century,
  6459. // > this are in the previous century,
  6460. // string value starting with "+" for current year + value
  6461. minDate: null, // The earliest selectable date, or null for no limit
  6462. maxDate: null, // The latest selectable date, or null for no limit
  6463. duration: "fast", // Duration of display/closure
  6464. beforeShowDay: null, // Function that takes a date and returns an array with
  6465. // [0] = true if selectable, false if not, [1] = custom CSS class name(s) or "",
  6466. // [2] = cell title (optional), e.g. $.datepicker.noWeekends
  6467. beforeShow: null, // Function that takes an input field and
  6468. // returns a set of custom settings for the date picker
  6469. onSelect: null, // Define a callback function when a date is selected
  6470. onChangeMonthYear: null, // Define a callback function when the month or year is changed
  6471. onClose: null, // Define a callback function when the datepicker is closed
  6472. numberOfMonths: 1, // Number of months to show at a time
  6473. showCurrentAtPos: 0, // The position in multipe months at which to show the current month (starting at 0)
  6474. stepMonths: 1, // Number of months to step back/forward
  6475. stepBigMonths: 12, // Number of months to step back/forward for the big links
  6476. altField: "", // Selector for an alternate field to store selected dates into
  6477. altFormat: "", // The date format to use for the alternate field
  6478. constrainInput: true, // The input is constrained by the current date format
  6479. showButtonPanel: false, // True to show button panel, false to not show it
  6480. autoSize: false, // True to size the input for the date format, false to leave as is
  6481. disabled: false // The initial disabled state
  6482. };
  6483. $.extend(this._defaults, this.regional[""]);
  6484. this.dpDiv = bindHover($("<div id='" + this._mainDivId + "' class='ui-datepicker ui-widget ui-widget-content ui-helper-clearfix ui-corner-all'></div>"));
  6485. }
  6486. $.extend(Datepicker.prototype, {
  6487. /* Class name added to elements to indicate already configured with a date picker. */
  6488. markerClassName: "hasDatepicker",
  6489. //Keep track of the maximum number of rows displayed (see #7043)
  6490. maxRows: 4,
  6491. // TODO rename to "widget" when switching to widget factory
  6492. _widgetDatepicker: function() {
  6493. return this.dpDiv;
  6494. },
  6495. /* Override the default settings for all instances of the date picker.
  6496. * @param settings object - the new settings to use as defaults (anonymous object)
  6497. * @return the manager object
  6498. */
  6499. setDefaults: function(settings) {
  6500. extendRemove(this._defaults, settings || {});
  6501. return this;
  6502. },
  6503. /* Attach the date picker to a jQuery selection.
  6504. * @param target element - the target input field or division or span
  6505. * @param settings object - the new settings to use for this date picker instance (anonymous)
  6506. */
  6507. _attachDatepicker: function(target, settings) {
  6508. var nodeName, inline, inst;
  6509. nodeName = target.nodeName.toLowerCase();
  6510. inline = (nodeName === "div" || nodeName === "span");
  6511. if (!target.id) {
  6512. this.uuid += 1;
  6513. target.id = "dp" + this.uuid;
  6514. }
  6515. inst = this._newInst($(target), inline);
  6516. inst.settings = $.extend({}, settings || {});
  6517. if (nodeName === "input") {
  6518. this._connectDatepicker(target, inst);
  6519. } else if (inline) {
  6520. this._inlineDatepicker(target, inst);
  6521. }
  6522. },
  6523. /* Create a new instance object. */
  6524. _newInst: function(target, inline) {
  6525. var id = target[0].id.replace(/([^A-Za-z0-9_\-])/g, "\\\\$1"); // escape jQuery meta chars
  6526. return {id: id, input: target, // associated target
  6527. selectedDay: 0, selectedMonth: 0, selectedYear: 0, // current selection
  6528. drawMonth: 0, drawYear: 0, // month being drawn
  6529. inline: inline, // is datepicker inline or not
  6530. dpDiv: (!inline ? this.dpDiv : // presentation div
  6531. bindHover($("<div class='" + this._inlineClass + " ui-datepicker ui-widget ui-widget-content ui-helper-clearfix ui-corner-all'></div>")))};
  6532. },
  6533. /* Attach the date picker to an input field. */
  6534. _connectDatepicker: function(target, inst) {
  6535. var input = $(target);
  6536. inst.append = $([]);
  6537. inst.trigger = $([]);
  6538. if (input.hasClass(this.markerClassName)) {
  6539. return;
  6540. }
  6541. this._attachments(input, inst);
  6542. input.addClass(this.markerClassName).keydown(this._doKeyDown).
  6543. keypress(this._doKeyPress).keyup(this._doKeyUp);
  6544. this._autoSize(inst);
  6545. $.data(target, PROP_NAME, inst);
  6546. //If disabled option is true, disable the datepicker once it has been attached to the input (see ticket #5665)
  6547. if( inst.settings.disabled ) {
  6548. this._disableDatepicker( target );
  6549. }
  6550. },
  6551. /* Make attachments based on settings. */
  6552. _attachments: function(input, inst) {
  6553. var showOn, buttonText, buttonImage,
  6554. appendText = this._get(inst, "appendText"),
  6555. isRTL = this._get(inst, "isRTL");
  6556. if (inst.append) {
  6557. inst.append.remove();
  6558. }
  6559. if (appendText) {
  6560. inst.append = $("<span class='" + this._appendClass + "'>" + appendText + "</span>");
  6561. input[isRTL ? "before" : "after"](inst.append);
  6562. }
  6563. input.unbind("focus", this._showDatepicker);
  6564. if (inst.trigger) {
  6565. inst.trigger.remove();
  6566. }
  6567. showOn = this._get(inst, "showOn");
  6568. if (showOn === "focus" || showOn === "both") { // pop-up date picker when in the marked field
  6569. input.focus(this._showDatepicker);
  6570. }
  6571. if (showOn === "button" || showOn === "both") { // pop-up date picker when button clicked
  6572. buttonText = this._get(inst, "buttonText");
  6573. buttonImage = this._get(inst, "buttonImage");
  6574. inst.trigger = $(this._get(inst, "buttonImageOnly") ?
  6575. $("<img/>").addClass(this._triggerClass).
  6576. attr({ src: buttonImage, alt: buttonText, title: buttonText }) :
  6577. $("<button type='button'></button>").addClass(this._triggerClass).
  6578. html(!buttonImage ? buttonText : $("<img/>").attr(
  6579. { src:buttonImage, alt:buttonText, title:buttonText })));
  6580. input[isRTL ? "before" : "after"](inst.trigger);
  6581. inst.trigger.click(function() {
  6582. if ($.datepicker._datepickerShowing && $.datepicker._lastInput === input[0]) {
  6583. $.datepicker._hideDatepicker();
  6584. } else if ($.datepicker._datepickerShowing && $.datepicker._lastInput !== input[0]) {
  6585. $.datepicker._hideDatepicker();
  6586. $.datepicker._showDatepicker(input[0]);
  6587. } else {
  6588. $.datepicker._showDatepicker(input[0]);
  6589. }
  6590. return false;
  6591. });
  6592. }
  6593. },
  6594. /* Apply the maximum length for the date format. */
  6595. _autoSize: function(inst) {
  6596. if (this._get(inst, "autoSize") && !inst.inline) {
  6597. var findMax, max, maxI, i,
  6598. date = new Date(2009, 12 - 1, 20), // Ensure double digits
  6599. dateFormat = this._get(inst, "dateFormat");
  6600. if (dateFormat.match(/[DM]/)) {
  6601. findMax = function(names) {
  6602. max = 0;
  6603. maxI = 0;
  6604. for (i = 0; i < names.length; i++) {
  6605. if (names[i].length > max) {
  6606. max = names[i].length;
  6607. maxI = i;
  6608. }
  6609. }
  6610. return maxI;
  6611. };
  6612. date.setMonth(findMax(this._get(inst, (dateFormat.match(/MM/) ?
  6613. "monthNames" : "monthNamesShort"))));
  6614. date.setDate(findMax(this._get(inst, (dateFormat.match(/DD/) ?
  6615. "dayNames" : "dayNamesShort"))) + 20 - date.getDay());
  6616. }
  6617. inst.input.attr("size", this._formatDate(inst, date).length);
  6618. }
  6619. },
  6620. /* Attach an inline date picker to a div. */
  6621. _inlineDatepicker: function(target, inst) {
  6622. var divSpan = $(target);
  6623. if (divSpan.hasClass(this.markerClassName)) {
  6624. return;
  6625. }
  6626. divSpan.addClass(this.markerClassName).append(inst.dpDiv);
  6627. $.data(target, PROP_NAME, inst);
  6628. this._setDate(inst, this._getDefaultDate(inst), true);
  6629. this._updateDatepicker(inst);
  6630. this._updateAlternate(inst);
  6631. //If disabled option is true, disable the datepicker before showing it (see ticket #5665)
  6632. if( inst.settings.disabled ) {
  6633. this._disableDatepicker( target );
  6634. }
  6635. // Set display:block in place of inst.dpDiv.show() which won't work on disconnected elements
  6636. // http://bugs.jqueryui.com/ticket/7552 - A Datepicker created on a detached div has zero height
  6637. inst.dpDiv.css( "display", "block" );
  6638. },
  6639. /* Pop-up the date picker in a "dialog" box.
  6640. * @param input element - ignored
  6641. * @param date string or Date - the initial date to display
  6642. * @param onSelect function - the function to call when a date is selected
  6643. * @param settings object - update the dialog date picker instance's settings (anonymous object)
  6644. * @param pos int[2] - coordinates for the dialog's position within the screen or
  6645. * event - with x/y coordinates or
  6646. * leave empty for default (screen centre)
  6647. * @return the manager object
  6648. */
  6649. _dialogDatepicker: function(input, date, onSelect, settings, pos) {
  6650. var id, browserWidth, browserHeight, scrollX, scrollY,
  6651. inst = this._dialogInst; // internal instance
  6652. if (!inst) {
  6653. this.uuid += 1;
  6654. id = "dp" + this.uuid;
  6655. this._dialogInput = $("<input type='text' id='" + id +
  6656. "' style='position: absolute; top: -100px; width: 0px;'/>");
  6657. this._dialogInput.keydown(this._doKeyDown);
  6658. $("body").append(this._dialogInput);
  6659. inst = this._dialogInst = this._newInst(this._dialogInput, false);
  6660. inst.settings = {};
  6661. $.data(this._dialogInput[0], PROP_NAME, inst);
  6662. }
  6663. extendRemove(inst.settings, settings || {});
  6664. date = (date && date.constructor === Date ? this._formatDate(inst, date) : date);
  6665. this._dialogInput.val(date);
  6666. this._pos = (pos ? (pos.length ? pos : [pos.pageX, pos.pageY]) : null);
  6667. if (!this._pos) {
  6668. browserWidth = document.documentElement.clientWidth;
  6669. browserHeight = document.documentElement.clientHeight;
  6670. scrollX = document.documentElement.scrollLeft || document.body.scrollLeft;
  6671. scrollY = document.documentElement.scrollTop || document.body.scrollTop;
  6672. this._pos = // should use actual width/height below
  6673. [(browserWidth / 2) - 100 + scrollX, (browserHeight / 2) - 150 + scrollY];
  6674. }
  6675. // move input on screen for focus, but hidden behind dialog
  6676. this._dialogInput.css("left", (this._pos[0] + 20) + "px").css("top", this._pos[1] + "px");
  6677. inst.settings.onSelect = onSelect;
  6678. this._inDialog = true;
  6679. this.dpDiv.addClass(this._dialogClass);
  6680. this._showDatepicker(this._dialogInput[0]);
  6681. if ($.blockUI) {
  6682. $.blockUI(this.dpDiv);
  6683. }
  6684. $.data(this._dialogInput[0], PROP_NAME, inst);
  6685. return this;
  6686. },
  6687. /* Detach a datepicker from its control.
  6688. * @param target element - the target input field or division or span
  6689. */
  6690. _destroyDatepicker: function(target) {
  6691. var nodeName,
  6692. $target = $(target),
  6693. inst = $.data(target, PROP_NAME);
  6694. if (!$target.hasClass(this.markerClassName)) {
  6695. return;
  6696. }
  6697. nodeName = target.nodeName.toLowerCase();
  6698. $.removeData(target, PROP_NAME);
  6699. if (nodeName === "input") {
  6700. inst.append.remove();
  6701. inst.trigger.remove();
  6702. $target.removeClass(this.markerClassName).
  6703. unbind("focus", this._showDatepicker).
  6704. unbind("keydown", this._doKeyDown).
  6705. unbind("keypress", this._doKeyPress).
  6706. unbind("keyup", this._doKeyUp);
  6707. } else if (nodeName === "div" || nodeName === "span") {
  6708. $target.removeClass(this.markerClassName).empty();
  6709. }
  6710. },
  6711. /* Enable the date picker to a jQuery selection.
  6712. * @param target element - the target input field or division or span
  6713. */
  6714. _enableDatepicker: function(target) {
  6715. var nodeName, inline,
  6716. $target = $(target),
  6717. inst = $.data(target, PROP_NAME);
  6718. if (!$target.hasClass(this.markerClassName)) {
  6719. return;
  6720. }
  6721. nodeName = target.nodeName.toLowerCase();
  6722. if (nodeName === "input") {
  6723. target.disabled = false;
  6724. inst.trigger.filter("button").
  6725. each(function() { this.disabled = false; }).end().
  6726. filter("img").css({opacity: "1.0", cursor: ""});
  6727. } else if (nodeName === "div" || nodeName === "span") {
  6728. inline = $target.children("." + this._inlineClass);
  6729. inline.children().removeClass("ui-state-disabled");
  6730. inline.find("select.ui-datepicker-month, select.ui-datepicker-year").
  6731. prop("disabled", false);
  6732. }
  6733. this._disabledInputs = $.map(this._disabledInputs,
  6734. function(value) { return (value === target ? null : value); }); // delete entry
  6735. },
  6736. /* Disable the date picker to a jQuery selection.
  6737. * @param target element - the target input field or division or span
  6738. */
  6739. _disableDatepicker: function(target) {
  6740. var nodeName, inline,
  6741. $target = $(target),
  6742. inst = $.data(target, PROP_NAME);
  6743. if (!$target.hasClass(this.markerClassName)) {
  6744. return;
  6745. }
  6746. nodeName = target.nodeName.toLowerCase();
  6747. if (nodeName === "input") {
  6748. target.disabled = true;
  6749. inst.trigger.filter("button").
  6750. each(function() { this.disabled = true; }).end().
  6751. filter("img").css({opacity: "0.5", cursor: "default"});
  6752. } else if (nodeName === "div" || nodeName === "span") {
  6753. inline = $target.children("." + this._inlineClass);
  6754. inline.children().addClass("ui-state-disabled");
  6755. inline.find("select.ui-datepicker-month, select.ui-datepicker-year").
  6756. prop("disabled", true);
  6757. }
  6758. this._disabledInputs = $.map(this._disabledInputs,
  6759. function(value) { return (value === target ? null : value); }); // delete entry
  6760. this._disabledInputs[this._disabledInputs.length] = target;
  6761. },
  6762. /* Is the first field in a jQuery collection disabled as a datepicker?
  6763. * @param target element - the target input field or division or span
  6764. * @return boolean - true if disabled, false if enabled
  6765. */
  6766. _isDisabledDatepicker: function(target) {
  6767. if (!target) {
  6768. return false;
  6769. }
  6770. for (var i = 0; i < this._disabledInputs.length; i++) {
  6771. if (this._disabledInputs[i] === target) {
  6772. return true;
  6773. }
  6774. }
  6775. return false;
  6776. },
  6777. /* Retrieve the instance data for the target control.
  6778. * @param target element - the target input field or division or span
  6779. * @return object - the associated instance data
  6780. * @throws error if a jQuery problem getting data
  6781. */
  6782. _getInst: function(target) {
  6783. try {
  6784. return $.data(target, PROP_NAME);
  6785. }
  6786. catch (err) {
  6787. throw "Missing instance data for this datepicker";
  6788. }
  6789. },
  6790. /* Update or retrieve the settings for a date picker attached to an input field or division.
  6791. * @param target element - the target input field or division or span
  6792. * @param name object - the new settings to update or
  6793. * string - the name of the setting to change or retrieve,
  6794. * when retrieving also "all" for all instance settings or
  6795. * "defaults" for all global defaults
  6796. * @param value any - the new value for the setting
  6797. * (omit if above is an object or to retrieve a value)
  6798. */
  6799. _optionDatepicker: function(target, name, value) {
  6800. var settings, date, minDate, maxDate,
  6801. inst = this._getInst(target);
  6802. if (arguments.length === 2 && typeof name === "string") {
  6803. return (name === "defaults" ? $.extend({}, $.datepicker._defaults) :
  6804. (inst ? (name === "all" ? $.extend({}, inst.settings) :
  6805. this._get(inst, name)) : null));
  6806. }
  6807. settings = name || {};
  6808. if (typeof name === "string") {
  6809. settings = {};
  6810. settings[name] = value;
  6811. }
  6812. if (inst) {
  6813. if (this._curInst === inst) {
  6814. this._hideDatepicker();
  6815. }
  6816. date = this._getDateDatepicker(target, true);
  6817. minDate = this._getMinMaxDate(inst, "min");
  6818. maxDate = this._getMinMaxDate(inst, "max");
  6819. extendRemove(inst.settings, settings);
  6820. // reformat the old minDate/maxDate values if dateFormat changes and a new minDate/maxDate isn't provided
  6821. if (minDate !== null && settings.dateFormat !== undefined && settings.minDate === undefined) {
  6822. inst.settings.minDate = this._formatDate(inst, minDate);
  6823. }
  6824. if (maxDate !== null && settings.dateFormat !== undefined && settings.maxDate === undefined) {
  6825. inst.settings.maxDate = this._formatDate(inst, maxDate);
  6826. }
  6827. if ( "disabled" in settings ) {
  6828. if ( settings.disabled ) {
  6829. this._disableDatepicker(target);
  6830. } else {
  6831. this._enableDatepicker(target);
  6832. }
  6833. }
  6834. this._attachments($(target), inst);
  6835. this._autoSize(inst);
  6836. this._setDate(inst, date);
  6837. this._updateAlternate(inst);
  6838. this._updateDatepicker(inst);
  6839. }
  6840. },
  6841. // change method deprecated
  6842. _changeDatepicker: function(target, name, value) {
  6843. this._optionDatepicker(target, name, value);
  6844. },
  6845. /* Redraw the date picker attached to an input field or division.
  6846. * @param target element - the target input field or division or span
  6847. */
  6848. _refreshDatepicker: function(target) {
  6849. var inst = this._getInst(target);
  6850. if (inst) {
  6851. this._updateDatepicker(inst);
  6852. }
  6853. },
  6854. /* Set the dates for a jQuery selection.
  6855. * @param target element - the target input field or division or span
  6856. * @param date Date - the new date
  6857. */
  6858. _setDateDatepicker: function(target, date) {
  6859. var inst = this._getInst(target);
  6860. if (inst) {
  6861. this._setDate(inst, date);
  6862. this._updateDatepicker(inst);
  6863. this._updateAlternate(inst);
  6864. }
  6865. },
  6866. /* Get the date(s) for the first entry in a jQuery selection.
  6867. * @param target element - the target input field or division or span
  6868. * @param noDefault boolean - true if no default date is to be used
  6869. * @return Date - the current date
  6870. */
  6871. _getDateDatepicker: function(target, noDefault) {
  6872. var inst = this._getInst(target);
  6873. if (inst && !inst.inline) {
  6874. this._setDateFromField(inst, noDefault);
  6875. }
  6876. return (inst ? this._getDate(inst) : null);
  6877. },
  6878. /* Handle keystrokes. */
  6879. _doKeyDown: function(event) {
  6880. var onSelect, dateStr, sel,
  6881. inst = $.datepicker._getInst(event.target),
  6882. handled = true,
  6883. isRTL = inst.dpDiv.is(".ui-datepicker-rtl");
  6884. inst._keyEvent = true;
  6885. if ($.datepicker._datepickerShowing) {
  6886. switch (event.keyCode) {
  6887. case 9: $.datepicker._hideDatepicker();
  6888. handled = false;
  6889. break; // hide on tab out
  6890. case 13: sel = $("td." + $.datepicker._dayOverClass + ":not(." +
  6891. $.datepicker._currentClass + ")", inst.dpDiv);
  6892. if (sel[0]) {
  6893. $.datepicker._selectDay(event.target, inst.selectedMonth, inst.selectedYear, sel[0]);
  6894. }
  6895. onSelect = $.datepicker._get(inst, "onSelect");
  6896. if (onSelect) {
  6897. dateStr = $.datepicker._formatDate(inst);
  6898. // trigger custom callback
  6899. onSelect.apply((inst.input ? inst.input[0] : null), [dateStr, inst]);
  6900. } else {
  6901. $.datepicker._hideDatepicker();
  6902. }
  6903. return false; // don't submit the form
  6904. case 27: $.datepicker._hideDatepicker();
  6905. break; // hide on escape
  6906. case 33: $.datepicker._adjustDate(event.target, (event.ctrlKey ?
  6907. -$.datepicker._get(inst, "stepBigMonths") :
  6908. -$.datepicker._get(inst, "stepMonths")), "M");
  6909. break; // previous month/year on page up/+ ctrl
  6910. case 34: $.datepicker._adjustDate(event.target, (event.ctrlKey ?
  6911. +$.datepicker._get(inst, "stepBigMonths") :
  6912. +$.datepicker._get(inst, "stepMonths")), "M");
  6913. break; // next month/year on page down/+ ctrl
  6914. case 35: if (event.ctrlKey || event.metaKey) {
  6915. $.datepicker._clearDate(event.target);
  6916. }
  6917. handled = event.ctrlKey || event.metaKey;
  6918. break; // clear on ctrl or command +end
  6919. case 36: if (event.ctrlKey || event.metaKey) {
  6920. $.datepicker._gotoToday(event.target);
  6921. }
  6922. handled = event.ctrlKey || event.metaKey;
  6923. break; // current on ctrl or command +home
  6924. case 37: if (event.ctrlKey || event.metaKey) {
  6925. $.datepicker._adjustDate(event.target, (isRTL ? +1 : -1), "D");
  6926. }
  6927. handled = event.ctrlKey || event.metaKey;
  6928. // -1 day on ctrl or command +left
  6929. if (event.originalEvent.altKey) {
  6930. $.datepicker._adjustDate(event.target, (event.ctrlKey ?
  6931. -$.datepicker._get(inst, "stepBigMonths") :
  6932. -$.datepicker._get(inst, "stepMonths")), "M");
  6933. }
  6934. // next month/year on alt +left on Mac
  6935. break;
  6936. case 38: if (event.ctrlKey || event.metaKey) {
  6937. $.datepicker._adjustDate(event.target, -7, "D");
  6938. }
  6939. handled = event.ctrlKey || event.metaKey;
  6940. break; // -1 week on ctrl or command +up
  6941. case 39: if (event.ctrlKey || event.metaKey) {
  6942. $.datepicker._adjustDate(event.target, (isRTL ? -1 : +1), "D");
  6943. }
  6944. handled = event.ctrlKey || event.metaKey;
  6945. // +1 day on ctrl or command +right
  6946. if (event.originalEvent.altKey) {
  6947. $.datepicker._adjustDate(event.target, (event.ctrlKey ?
  6948. +$.datepicker._get(inst, "stepBigMonths") :
  6949. +$.datepicker._get(inst, "stepMonths")), "M");
  6950. }
  6951. // next month/year on alt +right
  6952. break;
  6953. case 40: if (event.ctrlKey || event.metaKey) {
  6954. $.datepicker._adjustDate(event.target, +7, "D");
  6955. }
  6956. handled = event.ctrlKey || event.metaKey;
  6957. break; // +1 week on ctrl or command +down
  6958. default: handled = false;
  6959. }
  6960. } else if (event.keyCode === 36 && event.ctrlKey) { // display the date picker on ctrl+home
  6961. $.datepicker._showDatepicker(this);
  6962. } else {
  6963. handled = false;
  6964. }
  6965. if (handled) {
  6966. event.preventDefault();
  6967. event.stopPropagation();
  6968. }
  6969. },
  6970. /* Filter entered characters - based on date format. */
  6971. _doKeyPress: function(event) {
  6972. var chars, chr,
  6973. inst = $.datepicker._getInst(event.target);
  6974. if ($.datepicker._get(inst, "constrainInput")) {
  6975. chars = $.datepicker._possibleChars($.datepicker._get(inst, "dateFormat"));
  6976. chr = String.fromCharCode(event.charCode == null ? event.keyCode : event.charCode);
  6977. return event.ctrlKey || event.metaKey || (chr < " " || !chars || chars.indexOf(chr) > -1);
  6978. }
  6979. },
  6980. /* Synchronise manual entry and field/alternate field. */
  6981. _doKeyUp: function(event) {
  6982. var date,
  6983. inst = $.datepicker._getInst(event.target);
  6984. if (inst.input.val() !== inst.lastVal) {
  6985. try {
  6986. date = $.datepicker.parseDate($.datepicker._get(inst, "dateFormat"),
  6987. (inst.input ? inst.input.val() : null),
  6988. $.datepicker._getFormatConfig(inst));
  6989. if (date) { // only if valid
  6990. $.datepicker._setDateFromField(inst);
  6991. $.datepicker._updateAlternate(inst);
  6992. $.datepicker._updateDatepicker(inst);
  6993. }
  6994. }
  6995. catch (err) {
  6996. }
  6997. }
  6998. return true;
  6999. },
  7000. /* Pop-up the date picker for a given input field.
  7001. * If false returned from beforeShow event handler do not show.
  7002. * @param input element - the input field attached to the date picker or
  7003. * event - if triggered by focus
  7004. */
  7005. _showDatepicker: function(input) {
  7006. input = input.target || input;
  7007. if (input.nodeName.toLowerCase() !== "input") { // find from button/image trigger
  7008. input = $("input", input.parentNode)[0];
  7009. }
  7010. if ($.datepicker._isDisabledDatepicker(input) || $.datepicker._lastInput === input) { // already here
  7011. return;
  7012. }
  7013. var inst, beforeShow, beforeShowSettings, isFixed,
  7014. offset, showAnim, duration;
  7015. inst = $.datepicker._getInst(input);
  7016. if ($.datepicker._curInst && $.datepicker._curInst !== inst) {
  7017. $.datepicker._curInst.dpDiv.stop(true, true);
  7018. if ( inst && $.datepicker._datepickerShowing ) {
  7019. $.datepicker._hideDatepicker( $.datepicker._curInst.input[0] );
  7020. }
  7021. }
  7022. beforeShow = $.datepicker._get(inst, "beforeShow");
  7023. beforeShowSettings = beforeShow ? beforeShow.apply(input, [input, inst]) : {};
  7024. if(beforeShowSettings === false){
  7025. return;
  7026. }
  7027. extendRemove(inst.settings, beforeShowSettings);
  7028. inst.lastVal = null;
  7029. $.datepicker._lastInput = input;
  7030. $.datepicker._setDateFromField(inst);
  7031. if ($.datepicker._inDialog) { // hide cursor
  7032. input.value = "";
  7033. }
  7034. if (!$.datepicker._pos) { // position below input
  7035. $.datepicker._pos = $.datepicker._findPos(input);
  7036. $.datepicker._pos[1] += input.offsetHeight; // add the height
  7037. }
  7038. isFixed = false;
  7039. $(input).parents().each(function() {
  7040. isFixed |= $(this).css("position") === "fixed";
  7041. return !isFixed;
  7042. });
  7043. offset = {left: $.datepicker._pos[0], top: $.datepicker._pos[1]};
  7044. $.datepicker._pos = null;
  7045. //to avoid flashes on Firefox
  7046. inst.dpDiv.empty();
  7047. // determine sizing offscreen
  7048. inst.dpDiv.css({position: "absolute", display: "block", top: "-1000px"});
  7049. $.datepicker._updateDatepicker(inst);
  7050. // fix width for dynamic number of date pickers
  7051. // and adjust position before showing
  7052. offset = $.datepicker._checkOffset(inst, offset, isFixed);
  7053. inst.dpDiv.css({position: ($.datepicker._inDialog && $.blockUI ?
  7054. "static" : (isFixed ? "fixed" : "absolute")), display: "none",
  7055. left: offset.left + "px", top: offset.top + "px"});
  7056. if (!inst.inline) {
  7057. showAnim = $.datepicker._get(inst, "showAnim");
  7058. duration = $.datepicker._get(inst, "duration");
  7059. inst.dpDiv.zIndex($(input).zIndex()+1);
  7060. $.datepicker._datepickerShowing = true;
  7061. if ( $.effects && $.effects.effect[ showAnim ] ) {
  7062. inst.dpDiv.show(showAnim, $.datepicker._get(inst, "showOptions"), duration);
  7063. } else {
  7064. inst.dpDiv[showAnim || "show"](showAnim ? duration : null);
  7065. }
  7066. if (inst.input.is(":visible") && !inst.input.is(":disabled")) {
  7067. inst.input.focus();
  7068. }
  7069. $.datepicker._curInst = inst;
  7070. }
  7071. },
  7072. /* Generate the date picker content. */
  7073. _updateDatepicker: function(inst) {
  7074. this.maxRows = 4; //Reset the max number of rows being displayed (see #7043)
  7075. instActive = inst; // for delegate hover events
  7076. inst.dpDiv.empty().append(this._generateHTML(inst));
  7077. this._attachHandlers(inst);
  7078. inst.dpDiv.find("." + this._dayOverClass + " a").mouseover();
  7079. var origyearshtml,
  7080. numMonths = this._getNumberOfMonths(inst),
  7081. cols = numMonths[1],
  7082. width = 17;
  7083. inst.dpDiv.removeClass("ui-datepicker-multi-2 ui-datepicker-multi-3 ui-datepicker-multi-4").width("");
  7084. if (cols > 1) {
  7085. inst.dpDiv.addClass("ui-datepicker-multi-" + cols).css("width", (width * cols) + "em");
  7086. }
  7087. inst.dpDiv[(numMonths[0] !== 1 || numMonths[1] !== 1 ? "add" : "remove") +
  7088. "Class"]("ui-datepicker-multi");
  7089. inst.dpDiv[(this._get(inst, "isRTL") ? "add" : "remove") +
  7090. "Class"]("ui-datepicker-rtl");
  7091. // #6694 - don't focus the input if it's already focused
  7092. // this breaks the change event in IE
  7093. if (inst === $.datepicker._curInst && $.datepicker._datepickerShowing && inst.input &&
  7094. inst.input.is(":visible") && !inst.input.is(":disabled") && inst.input[0] !== document.activeElement) {
  7095. inst.input.focus();
  7096. }
  7097. // deffered render of the years select (to avoid flashes on Firefox)
  7098. if( inst.yearshtml ){
  7099. origyearshtml = inst.yearshtml;
  7100. setTimeout(function(){
  7101. //assure that inst.yearshtml didn't change.
  7102. if( origyearshtml === inst.yearshtml && inst.yearshtml ){
  7103. inst.dpDiv.find("select.ui-datepicker-year:first").replaceWith(inst.yearshtml);
  7104. }
  7105. origyearshtml = inst.yearshtml = null;
  7106. }, 0);
  7107. }
  7108. },
  7109. /* Retrieve the size of left and top borders for an element.
  7110. * @param elem (jQuery object) the element of interest
  7111. * @return (number[2]) the left and top borders
  7112. */
  7113. _getBorders: function(elem) {
  7114. var convert = function(value) {
  7115. return {thin: 1, medium: 2, thick: 3}[value] || value;
  7116. };
  7117. return [parseFloat(convert(elem.css("border-left-width"))),
  7118. parseFloat(convert(elem.css("border-top-width")))];
  7119. },
  7120. /* Check positioning to remain on screen. */
  7121. _checkOffset: function(inst, offset, isFixed) {
  7122. var dpWidth = inst.dpDiv.outerWidth(),
  7123. dpHeight = inst.dpDiv.outerHeight(),
  7124. inputWidth = inst.input ? inst.input.outerWidth() : 0,
  7125. inputHeight = inst.input ? inst.input.outerHeight() : 0,
  7126. viewWidth = document.documentElement.clientWidth + (isFixed ? 0 : $(document).scrollLeft()),
  7127. viewHeight = document.documentElement.clientHeight + (isFixed ? 0 : $(document).scrollTop());
  7128. offset.left -= (this._get(inst, "isRTL") ? (dpWidth - inputWidth) : 0);
  7129. offset.left -= (isFixed && offset.left === inst.input.offset().left) ? $(document).scrollLeft() : 0;
  7130. offset.top -= (isFixed && offset.top === (inst.input.offset().top + inputHeight)) ? $(document).scrollTop() : 0;
  7131. // now check if datepicker is showing outside window viewport - move to a better place if so.
  7132. offset.left -= Math.min(offset.left, (offset.left + dpWidth > viewWidth && viewWidth > dpWidth) ?
  7133. Math.abs(offset.left + dpWidth - viewWidth) : 0);
  7134. offset.top -= Math.min(offset.top, (offset.top + dpHeight > viewHeight && viewHeight > dpHeight) ?
  7135. Math.abs(dpHeight + inputHeight) : 0);
  7136. return offset;
  7137. },
  7138. /* Find an object's position on the screen. */
  7139. _findPos: function(obj) {
  7140. var position,
  7141. inst = this._getInst(obj),
  7142. isRTL = this._get(inst, "isRTL");
  7143. while (obj && (obj.type === "hidden" || obj.nodeType !== 1 || $.expr.filters.hidden(obj))) {
  7144. obj = obj[isRTL ? "previousSibling" : "nextSibling"];
  7145. }
  7146. position = $(obj).offset();
  7147. return [position.left, position.top];
  7148. },
  7149. /* Hide the date picker from view.
  7150. * @param input element - the input field attached to the date picker
  7151. */
  7152. _hideDatepicker: function(input) {
  7153. var showAnim, duration, postProcess, onClose,
  7154. inst = this._curInst;
  7155. if (!inst || (input && inst !== $.data(input, PROP_NAME))) {
  7156. return;
  7157. }
  7158. if (this._datepickerShowing) {
  7159. showAnim = this._get(inst, "showAnim");
  7160. duration = this._get(inst, "duration");
  7161. postProcess = function() {
  7162. $.datepicker._tidyDialog(inst);
  7163. };
  7164. // DEPRECATED: after BC for 1.8.x $.effects[ showAnim ] is not needed
  7165. if ( $.effects && ( $.effects.effect[ showAnim ] || $.effects[ showAnim ] ) ) {
  7166. inst.dpDiv.hide(showAnim, $.datepicker._get(inst, "showOptions"), duration, postProcess);
  7167. } else {
  7168. inst.dpDiv[(showAnim === "slideDown" ? "slideUp" :
  7169. (showAnim === "fadeIn" ? "fadeOut" : "hide"))]((showAnim ? duration : null), postProcess);
  7170. }
  7171. if (!showAnim) {
  7172. postProcess();
  7173. }
  7174. this._datepickerShowing = false;
  7175. onClose = this._get(inst, "onClose");
  7176. if (onClose) {
  7177. onClose.apply((inst.input ? inst.input[0] : null), [(inst.input ? inst.input.val() : ""), inst]);
  7178. }
  7179. this._lastInput = null;
  7180. if (this._inDialog) {
  7181. this._dialogInput.css({ position: "absolute", left: "0", top: "-100px" });
  7182. if ($.blockUI) {
  7183. $.unblockUI();
  7184. $("body").append(this.dpDiv);
  7185. }
  7186. }
  7187. this._inDialog = false;
  7188. }
  7189. },
  7190. /* Tidy up after a dialog display. */
  7191. _tidyDialog: function(inst) {
  7192. inst.dpDiv.removeClass(this._dialogClass).unbind(".ui-datepicker-calendar");
  7193. },
  7194. /* Close date picker if clicked elsewhere. */
  7195. _checkExternalClick: function(event) {
  7196. if (!$.datepicker._curInst) {
  7197. return;
  7198. }
  7199. var $target = $(event.target),
  7200. inst = $.datepicker._getInst($target[0]);
  7201. if ( ( ( $target[0].id !== $.datepicker._mainDivId &&
  7202. $target.parents("#" + $.datepicker._mainDivId).length === 0 &&
  7203. !$target.hasClass($.datepicker.markerClassName) &&
  7204. !$target.closest("." + $.datepicker._triggerClass).length &&
  7205. $.datepicker._datepickerShowing && !($.datepicker._inDialog && $.blockUI) ) ) ||
  7206. ( $target.hasClass($.datepicker.markerClassName) && $.datepicker._curInst !== inst ) ) {
  7207. $.datepicker._hideDatepicker();
  7208. }
  7209. },
  7210. /* Adjust one of the date sub-fields. */
  7211. _adjustDate: function(id, offset, period) {
  7212. var target = $(id),
  7213. inst = this._getInst(target[0]);
  7214. if (this._isDisabledDatepicker(target[0])) {
  7215. return;
  7216. }
  7217. this._adjustInstDate(inst, offset +
  7218. (period === "M" ? this._get(inst, "showCurrentAtPos") : 0), // undo positioning
  7219. period);
  7220. this._updateDatepicker(inst);
  7221. },
  7222. /* Action for current link. */
  7223. _gotoToday: function(id) {
  7224. var date,
  7225. target = $(id),
  7226. inst = this._getInst(target[0]);
  7227. if (this._get(inst, "gotoCurrent") && inst.currentDay) {
  7228. inst.selectedDay = inst.currentDay;
  7229. inst.drawMonth = inst.selectedMonth = inst.currentMonth;
  7230. inst.drawYear = inst.selectedYear = inst.currentYear;
  7231. } else {
  7232. date = new Date();
  7233. inst.selectedDay = date.getDate();
  7234. inst.drawMonth = inst.selectedMonth = date.getMonth();
  7235. inst.drawYear = inst.selectedYear = date.getFullYear();
  7236. }
  7237. this._notifyChange(inst);
  7238. this._adjustDate(target);
  7239. },
  7240. /* Action for selecting a new month/year. */
  7241. _selectMonthYear: function(id, select, period) {
  7242. var target = $(id),
  7243. inst = this._getInst(target[0]);
  7244. inst["selected" + (period === "M" ? "Month" : "Year")] =
  7245. inst["draw" + (period === "M" ? "Month" : "Year")] =
  7246. parseInt(select.options[select.selectedIndex].value,10);
  7247. this._notifyChange(inst);
  7248. this._adjustDate(target);
  7249. },
  7250. /* Action for selecting a day. */
  7251. _selectDay: function(id, month, year, td) {
  7252. var inst,
  7253. target = $(id);
  7254. if ($(td).hasClass(this._unselectableClass) || this._isDisabledDatepicker(target[0])) {
  7255. return;
  7256. }
  7257. inst = this._getInst(target[0]);
  7258. inst.selectedDay = inst.currentDay = $("a", td).html();
  7259. inst.selectedMonth = inst.currentMonth = month;
  7260. inst.selectedYear = inst.currentYear = year;
  7261. this._selectDate(id, this._formatDate(inst,
  7262. inst.currentDay, inst.currentMonth, inst.currentYear));
  7263. },
  7264. /* Erase the input field and hide the date picker. */
  7265. _clearDate: function(id) {
  7266. var target = $(id);
  7267. this._selectDate(target, "");
  7268. },
  7269. /* Update the input field with the selected date. */
  7270. _selectDate: function(id, dateStr) {
  7271. var onSelect,
  7272. target = $(id),
  7273. inst = this._getInst(target[0]);
  7274. dateStr = (dateStr != null ? dateStr : this._formatDate(inst));
  7275. if (inst.input) {
  7276. inst.input.val(dateStr);
  7277. }
  7278. this._updateAlternate(inst);
  7279. onSelect = this._get(inst, "onSelect");
  7280. if (onSelect) {
  7281. onSelect.apply((inst.input ? inst.input[0] : null), [dateStr, inst]); // trigger custom callback
  7282. } else if (inst.input) {
  7283. inst.input.trigger("change"); // fire the change event
  7284. }
  7285. if (inst.inline){
  7286. this._updateDatepicker(inst);
  7287. } else {
  7288. this._hideDatepicker();
  7289. this._lastInput = inst.input[0];
  7290. if (typeof(inst.input[0]) !== "object") {
  7291. inst.input.focus(); // restore focus
  7292. }
  7293. this._lastInput = null;
  7294. }
  7295. },
  7296. /* Update any alternate field to synchronise with the main field. */
  7297. _updateAlternate: function(inst) {
  7298. var altFormat, date, dateStr,
  7299. altField = this._get(inst, "altField");
  7300. if (altField) { // update alternate field too
  7301. altFormat = this._get(inst, "altFormat") || this._get(inst, "dateFormat");
  7302. date = this._getDate(inst);
  7303. dateStr = this.formatDate(altFormat, date, this._getFormatConfig(inst));
  7304. $(altField).each(function() { $(this).val(dateStr); });
  7305. }
  7306. },
  7307. /* Set as beforeShowDay function to prevent selection of weekends.
  7308. * @param date Date - the date to customise
  7309. * @return [boolean, string] - is this date selectable?, what is its CSS class?
  7310. */
  7311. noWeekends: function(date) {
  7312. var day = date.getDay();
  7313. return [(day > 0 && day < 6), ""];
  7314. },
  7315. /* Set as calculateWeek to determine the week of the year based on the ISO 8601 definition.
  7316. * @param date Date - the date to get the week for
  7317. * @return number - the number of the week within the year that contains this date
  7318. */
  7319. iso8601Week: function(date) {
  7320. var time,
  7321. checkDate = new Date(date.getTime());
  7322. // Find Thursday of this week starting on Monday
  7323. checkDate.setDate(checkDate.getDate() + 4 - (checkDate.getDay() || 7));
  7324. time = checkDate.getTime();
  7325. checkDate.setMonth(0); // Compare with Jan 1
  7326. checkDate.setDate(1);
  7327. return Math.floor(Math.round((time - checkDate) / 86400000) / 7) + 1;
  7328. },
  7329. /* Parse a string value into a date object.
  7330. * See formatDate below for the possible formats.
  7331. *
  7332. * @param format string - the expected format of the date
  7333. * @param value string - the date in the above format
  7334. * @param settings Object - attributes include:
  7335. * shortYearCutoff number - the cutoff year for determining the century (optional)
  7336. * dayNamesShort string[7] - abbreviated names of the days from Sunday (optional)
  7337. * dayNames string[7] - names of the days from Sunday (optional)
  7338. * monthNamesShort string[12] - abbreviated names of the months (optional)
  7339. * monthNames string[12] - names of the months (optional)
  7340. * @return Date - the extracted date value or null if value is blank
  7341. */
  7342. parseDate: function (format, value, settings) {
  7343. if (format == null || value == null) {
  7344. throw "Invalid arguments";
  7345. }
  7346. value = (typeof value === "object" ? value.toString() : value + "");
  7347. if (value === "") {
  7348. return null;
  7349. }
  7350. var iFormat, dim, extra,
  7351. iValue = 0,
  7352. shortYearCutoffTemp = (settings ? settings.shortYearCutoff : null) || this._defaults.shortYearCutoff,
  7353. shortYearCutoff = (typeof shortYearCutoffTemp !== "string" ? shortYearCutoffTemp :
  7354. new Date().getFullYear() % 100 + parseInt(shortYearCutoffTemp, 10)),
  7355. dayNamesShort = (settings ? settings.dayNamesShort : null) || this._defaults.dayNamesShort,
  7356. dayNames = (settings ? settings.dayNames : null) || this._defaults.dayNames,
  7357. monthNamesShort = (settings ? settings.monthNamesShort : null) || this._defaults.monthNamesShort,
  7358. monthNames = (settings ? settings.monthNames : null) || this._defaults.monthNames,
  7359. year = -1,
  7360. month = -1,
  7361. day = -1,
  7362. doy = -1,
  7363. literal = false,
  7364. date,
  7365. // Check whether a format character is doubled
  7366. lookAhead = function(match) {
  7367. var matches = (iFormat + 1 < format.length && format.charAt(iFormat + 1) === match);
  7368. if (matches) {
  7369. iFormat++;
  7370. }
  7371. return matches;
  7372. },
  7373. // Extract a number from the string value
  7374. getNumber = function(match) {
  7375. var isDoubled = lookAhead(match),
  7376. size = (match === "@" ? 14 : (match === "!" ? 20 :
  7377. (match === "y" && isDoubled ? 4 : (match === "o" ? 3 : 2)))),
  7378. digits = new RegExp("^\\d{1," + size + "}"),
  7379. num = value.substring(iValue).match(digits);
  7380. if (!num) {
  7381. throw "Missing number at position " + iValue;
  7382. }
  7383. iValue += num[0].length;
  7384. return parseInt(num[0], 10);
  7385. },
  7386. // Extract a name from the string value and convert to an index
  7387. getName = function(match, shortNames, longNames) {
  7388. var index = -1,
  7389. names = $.map(lookAhead(match) ? longNames : shortNames, function (v, k) {
  7390. return [ [k, v] ];
  7391. }).sort(function (a, b) {
  7392. return -(a[1].length - b[1].length);
  7393. });
  7394. $.each(names, function (i, pair) {
  7395. var name = pair[1];
  7396. if (value.substr(iValue, name.length).toLowerCase() === name.toLowerCase()) {
  7397. index = pair[0];
  7398. iValue += name.length;
  7399. return false;
  7400. }
  7401. });
  7402. if (index !== -1) {
  7403. return index + 1;
  7404. } else {
  7405. throw "Unknown name at position " + iValue;
  7406. }
  7407. },
  7408. // Confirm that a literal character matches the string value
  7409. checkLiteral = function() {
  7410. if (value.charAt(iValue) !== format.charAt(iFormat)) {
  7411. throw "Unexpected literal at position " + iValue;
  7412. }
  7413. iValue++;
  7414. };
  7415. for (iFormat = 0; iFormat < format.length; iFormat++) {
  7416. if (literal) {
  7417. if (format.charAt(iFormat) === "'" && !lookAhead("'")) {
  7418. literal = false;
  7419. } else {
  7420. checkLiteral();
  7421. }
  7422. } else {
  7423. switch (format.charAt(iFormat)) {
  7424. case "d":
  7425. day = getNumber("d");
  7426. break;
  7427. case "D":
  7428. getName("D", dayNamesShort, dayNames);
  7429. break;
  7430. case "o":
  7431. doy = getNumber("o");
  7432. break;
  7433. case "m":
  7434. month = getNumber("m");
  7435. break;
  7436. case "M":
  7437. month = getName("M", monthNamesShort, monthNames);
  7438. break;
  7439. case "y":
  7440. year = getNumber("y");
  7441. break;
  7442. case "@":
  7443. date = new Date(getNumber("@"));
  7444. year = date.getFullYear();
  7445. month = date.getMonth() + 1;
  7446. day = date.getDate();
  7447. break;
  7448. case "!":
  7449. date = new Date((getNumber("!") - this._ticksTo1970) / 10000);
  7450. year = date.getFullYear();
  7451. month = date.getMonth() + 1;
  7452. day = date.getDate();
  7453. break;
  7454. case "'":
  7455. if (lookAhead("'")){
  7456. checkLiteral();
  7457. } else {
  7458. literal = true;
  7459. }
  7460. break;
  7461. default:
  7462. checkLiteral();
  7463. }
  7464. }
  7465. }
  7466. if (iValue < value.length){
  7467. extra = value.substr(iValue);
  7468. if (!/^\s+/.test(extra)) {
  7469. throw "Extra/unparsed characters found in date: " + extra;
  7470. }
  7471. }
  7472. if (year === -1) {
  7473. year = new Date().getFullYear();
  7474. } else if (year < 100) {
  7475. year += new Date().getFullYear() - new Date().getFullYear() % 100 +
  7476. (year <= shortYearCutoff ? 0 : -100);
  7477. }
  7478. if (doy > -1) {
  7479. month = 1;
  7480. day = doy;
  7481. do {
  7482. dim = this._getDaysInMonth(year, month - 1);
  7483. if (day <= dim) {
  7484. break;
  7485. }
  7486. month++;
  7487. day -= dim;
  7488. } while (true);
  7489. }
  7490. date = this._daylightSavingAdjust(new Date(year, month - 1, day));
  7491. if (date.getFullYear() !== year || date.getMonth() + 1 !== month || date.getDate() !== day) {
  7492. throw "Invalid date"; // E.g. 31/02/00
  7493. }
  7494. return date;
  7495. },
  7496. /* Standard date formats. */
  7497. ATOM: "yy-mm-dd", // RFC 3339 (ISO 8601)
  7498. COOKIE: "D, dd M yy",
  7499. ISO_8601: "yy-mm-dd",
  7500. RFC_822: "D, d M y",
  7501. RFC_850: "DD, dd-M-y",
  7502. RFC_1036: "D, d M y",
  7503. RFC_1123: "D, d M yy",
  7504. RFC_2822: "D, d M yy",
  7505. RSS: "D, d M y", // RFC 822
  7506. TICKS: "!",
  7507. TIMESTAMP: "@",
  7508. W3C: "yy-mm-dd", // ISO 8601
  7509. _ticksTo1970: (((1970 - 1) * 365 + Math.floor(1970 / 4) - Math.floor(1970 / 100) +
  7510. Math.floor(1970 / 400)) * 24 * 60 * 60 * 10000000),
  7511. /* Format a date object into a string value.
  7512. * The format can be combinations of the following:
  7513. * d - day of month (no leading zero)
  7514. * dd - day of month (two digit)
  7515. * o - day of year (no leading zeros)
  7516. * oo - day of year (three digit)
  7517. * D - day name short
  7518. * DD - day name long
  7519. * m - month of year (no leading zero)
  7520. * mm - month of year (two digit)
  7521. * M - month name short
  7522. * MM - month name long
  7523. * y - year (two digit)
  7524. * yy - year (four digit)
  7525. * @ - Unix timestamp (ms since 01/01/1970)
  7526. * ! - Windows ticks (100ns since 01/01/0001)
  7527. * "..." - literal text
  7528. * '' - single quote
  7529. *
  7530. * @param format string - the desired format of the date
  7531. * @param date Date - the date value to format
  7532. * @param settings Object - attributes include:
  7533. * dayNamesShort string[7] - abbreviated names of the days from Sunday (optional)
  7534. * dayNames string[7] - names of the days from Sunday (optional)
  7535. * monthNamesShort string[12] - abbreviated names of the months (optional)
  7536. * monthNames string[12] - names of the months (optional)
  7537. * @return string - the date in the above format
  7538. */
  7539. formatDate: function (format, date, settings) {
  7540. if (!date) {
  7541. return "";
  7542. }
  7543. var iFormat,
  7544. dayNamesShort = (settings ? settings.dayNamesShort : null) || this._defaults.dayNamesShort,
  7545. dayNames = (settings ? settings.dayNames : null) || this._defaults.dayNames,
  7546. monthNamesShort = (settings ? settings.monthNamesShort : null) || this._defaults.monthNamesShort,
  7547. monthNames = (settings ? settings.monthNames : null) || this._defaults.monthNames,
  7548. // Check whether a format character is doubled
  7549. lookAhead = function(match) {
  7550. var matches = (iFormat + 1 < format.length && format.charAt(iFormat + 1) === match);
  7551. if (matches) {
  7552. iFormat++;
  7553. }
  7554. return matches;
  7555. },
  7556. // Format a number, with leading zero if necessary
  7557. formatNumber = function(match, value, len) {
  7558. var num = "" + value;
  7559. if (lookAhead(match)) {
  7560. while (num.length < len) {
  7561. num = "0" + num;
  7562. }
  7563. }
  7564. return num;
  7565. },
  7566. // Format a name, short or long as requested
  7567. formatName = function(match, value, shortNames, longNames) {
  7568. return (lookAhead(match) ? longNames[value] : shortNames[value]);
  7569. },
  7570. output = "",
  7571. literal = false;
  7572. if (date) {
  7573. for (iFormat = 0; iFormat < format.length; iFormat++) {
  7574. if (literal) {
  7575. if (format.charAt(iFormat) === "'" && !lookAhead("'")) {
  7576. literal = false;
  7577. } else {
  7578. output += format.charAt(iFormat);
  7579. }
  7580. } else {
  7581. switch (format.charAt(iFormat)) {
  7582. case "d":
  7583. output += formatNumber("d", date.getDate(), 2);
  7584. break;
  7585. case "D":
  7586. output += formatName("D", date.getDay(), dayNamesShort, dayNames);
  7587. break;
  7588. case "o":
  7589. output += formatNumber("o",
  7590. Math.round((new Date(date.getFullYear(), date.getMonth(), date.getDate()).getTime() - new Date(date.getFullYear(), 0, 0).getTime()) / 86400000), 3);
  7591. break;
  7592. case "m":
  7593. output += formatNumber("m", date.getMonth() + 1, 2);
  7594. break;
  7595. case "M":
  7596. output += formatName("M", date.getMonth(), monthNamesShort, monthNames);
  7597. break;
  7598. case "y":
  7599. output += (lookAhead("y") ? date.getFullYear() :
  7600. (date.getYear() % 100 < 10 ? "0" : "") + date.getYear() % 100);
  7601. break;
  7602. case "@":
  7603. output += date.getTime();
  7604. break;
  7605. case "!":
  7606. output += date.getTime() * 10000 + this._ticksTo1970;
  7607. break;
  7608. case "'":
  7609. if (lookAhead("'")) {
  7610. output += "'";
  7611. } else {
  7612. literal = true;
  7613. }
  7614. break;
  7615. default:
  7616. output += format.charAt(iFormat);
  7617. }
  7618. }
  7619. }
  7620. }
  7621. return output;
  7622. },
  7623. /* Extract all possible characters from the date format. */
  7624. _possibleChars: function (format) {
  7625. var iFormat,
  7626. chars = "",
  7627. literal = false,
  7628. // Check whether a format character is doubled
  7629. lookAhead = function(match) {
  7630. var matches = (iFormat + 1 < format.length && format.charAt(iFormat + 1) === match);
  7631. if (matches) {
  7632. iFormat++;
  7633. }
  7634. return matches;
  7635. };
  7636. for (iFormat = 0; iFormat < format.length; iFormat++) {
  7637. if (literal) {
  7638. if (format.charAt(iFormat) === "'" && !lookAhead("'")) {
  7639. literal = false;
  7640. } else {
  7641. chars += format.charAt(iFormat);
  7642. }
  7643. } else {
  7644. switch (format.charAt(iFormat)) {
  7645. case "d": case "m": case "y": case "@":
  7646. chars += "0123456789";
  7647. break;
  7648. case "D": case "M":
  7649. return null; // Accept anything
  7650. case "'":
  7651. if (lookAhead("'")) {
  7652. chars += "'";
  7653. } else {
  7654. literal = true;
  7655. }
  7656. break;
  7657. default:
  7658. chars += format.charAt(iFormat);
  7659. }
  7660. }
  7661. }
  7662. return chars;
  7663. },
  7664. /* Get a setting value, defaulting if necessary. */
  7665. _get: function(inst, name) {
  7666. return inst.settings[name] !== undefined ?
  7667. inst.settings[name] : this._defaults[name];
  7668. },
  7669. /* Parse existing date and initialise date picker. */
  7670. _setDateFromField: function(inst, noDefault) {
  7671. if (inst.input.val() === inst.lastVal) {
  7672. return;
  7673. }
  7674. var dateFormat = this._get(inst, "dateFormat"),
  7675. dates = inst.lastVal = inst.input ? inst.input.val() : null,
  7676. defaultDate = this._getDefaultDate(inst),
  7677. date = defaultDate,
  7678. settings = this._getFormatConfig(inst);
  7679. try {
  7680. date = this.parseDate(dateFormat, dates, settings) || defaultDate;
  7681. } catch (event) {
  7682. dates = (noDefault ? "" : dates);
  7683. }
  7684. inst.selectedDay = date.getDate();
  7685. inst.drawMonth = inst.selectedMonth = date.getMonth();
  7686. inst.drawYear = inst.selectedYear = date.getFullYear();
  7687. inst.currentDay = (dates ? date.getDate() : 0);
  7688. inst.currentMonth = (dates ? date.getMonth() : 0);
  7689. inst.currentYear = (dates ? date.getFullYear() : 0);
  7690. this._adjustInstDate(inst);
  7691. },
  7692. /* Retrieve the default date shown on opening. */
  7693. _getDefaultDate: function(inst) {
  7694. return this._restrictMinMax(inst,
  7695. this._determineDate(inst, this._get(inst, "defaultDate"), new Date()));
  7696. },
  7697. /* A date may be specified as an exact value or a relative one. */
  7698. _determineDate: function(inst, date, defaultDate) {
  7699. var offsetNumeric = function(offset) {
  7700. var date = new Date();
  7701. date.setDate(date.getDate() + offset);
  7702. return date;
  7703. },
  7704. offsetString = function(offset) {
  7705. try {
  7706. return $.datepicker.parseDate($.datepicker._get(inst, "dateFormat"),
  7707. offset, $.datepicker._getFormatConfig(inst));
  7708. }
  7709. catch (e) {
  7710. // Ignore
  7711. }
  7712. var date = (offset.toLowerCase().match(/^c/) ?
  7713. $.datepicker._getDate(inst) : null) || new Date(),
  7714. year = date.getFullYear(),
  7715. month = date.getMonth(),
  7716. day = date.getDate(),
  7717. pattern = /([+\-]?[0-9]+)\s*(d|D|w|W|m|M|y|Y)?/g,
  7718. matches = pattern.exec(offset);
  7719. while (matches) {
  7720. switch (matches[2] || "d") {
  7721. case "d" : case "D" :
  7722. day += parseInt(matches[1],10); break;
  7723. case "w" : case "W" :
  7724. day += parseInt(matches[1],10) * 7; break;
  7725. case "m" : case "M" :
  7726. month += parseInt(matches[1],10);
  7727. day = Math.min(day, $.datepicker._getDaysInMonth(year, month));
  7728. break;
  7729. case "y": case "Y" :
  7730. year += parseInt(matches[1],10);
  7731. day = Math.min(day, $.datepicker._getDaysInMonth(year, month));
  7732. break;
  7733. }
  7734. matches = pattern.exec(offset);
  7735. }
  7736. return new Date(year, month, day);
  7737. },
  7738. newDate = (date == null || date === "" ? defaultDate : (typeof date === "string" ? offsetString(date) :
  7739. (typeof date === "number" ? (isNaN(date) ? defaultDate : offsetNumeric(date)) : new Date(date.getTime()))));
  7740. newDate = (newDate && newDate.toString() === "Invalid Date" ? defaultDate : newDate);
  7741. if (newDate) {
  7742. newDate.setHours(0);
  7743. newDate.setMinutes(0);
  7744. newDate.setSeconds(0);
  7745. newDate.setMilliseconds(0);
  7746. }
  7747. return this._daylightSavingAdjust(newDate);
  7748. },
  7749. /* Handle switch to/from daylight saving.
  7750. * Hours may be non-zero on daylight saving cut-over:
  7751. * > 12 when midnight changeover, but then cannot generate
  7752. * midnight datetime, so jump to 1AM, otherwise reset.
  7753. * @param date (Date) the date to check
  7754. * @return (Date) the corrected date
  7755. */
  7756. _daylightSavingAdjust: function(date) {
  7757. if (!date) {
  7758. return null;
  7759. }
  7760. date.setHours(date.getHours() > 12 ? date.getHours() + 2 : 0);
  7761. return date;
  7762. },
  7763. /* Set the date(s) directly. */
  7764. _setDate: function(inst, date, noChange) {
  7765. var clear = !date,
  7766. origMonth = inst.selectedMonth,
  7767. origYear = inst.selectedYear,
  7768. newDate = this._restrictMinMax(inst, this._determineDate(inst, date, new Date()));
  7769. inst.selectedDay = inst.currentDay = newDate.getDate();
  7770. inst.drawMonth = inst.selectedMonth = inst.currentMonth = newDate.getMonth();
  7771. inst.drawYear = inst.selectedYear = inst.currentYear = newDate.getFullYear();
  7772. if ((origMonth !== inst.selectedMonth || origYear !== inst.selectedYear) && !noChange) {
  7773. this._notifyChange(inst);
  7774. }
  7775. this._adjustInstDate(inst);
  7776. if (inst.input) {
  7777. inst.input.val(clear ? "" : this._formatDate(inst));
  7778. }
  7779. },
  7780. /* Retrieve the date(s) directly. */
  7781. _getDate: function(inst) {
  7782. var startDate = (!inst.currentYear || (inst.input && inst.input.val() === "") ? null :
  7783. this._daylightSavingAdjust(new Date(
  7784. inst.currentYear, inst.currentMonth, inst.currentDay)));
  7785. return startDate;
  7786. },
  7787. /* Attach the onxxx handlers. These are declared statically so
  7788. * they work with static code transformers like Caja.
  7789. */
  7790. _attachHandlers: function(inst) {
  7791. var stepMonths = this._get(inst, "stepMonths"),
  7792. id = "#" + inst.id.replace( /\\\\/g, "\\" );
  7793. inst.dpDiv.find("[data-handler]").map(function () {
  7794. var handler = {
  7795. prev: function () {
  7796. window["DP_jQuery_" + dpuuid].datepicker._adjustDate(id, -stepMonths, "M");
  7797. },
  7798. next: function () {
  7799. window["DP_jQuery_" + dpuuid].datepicker._adjustDate(id, +stepMonths, "M");
  7800. },
  7801. hide: function () {
  7802. window["DP_jQuery_" + dpuuid].datepicker._hideDatepicker();
  7803. },
  7804. today: function () {
  7805. window["DP_jQuery_" + dpuuid].datepicker._gotoToday(id);
  7806. },
  7807. selectDay: function () {
  7808. window["DP_jQuery_" + dpuuid].datepicker._selectDay(id, +this.getAttribute("data-month"), +this.getAttribute("data-year"), this);
  7809. return false;
  7810. },
  7811. selectMonth: function () {
  7812. window["DP_jQuery_" + dpuuid].datepicker._selectMonthYear(id, this, "M");
  7813. return false;
  7814. },
  7815. selectYear: function () {
  7816. window["DP_jQuery_" + dpuuid].datepicker._selectMonthYear(id, this, "Y");
  7817. return false;
  7818. }
  7819. };
  7820. $(this).bind(this.getAttribute("data-event"), handler[this.getAttribute("data-handler")]);
  7821. });
  7822. },
  7823. /* Generate the HTML for the current state of the date picker. */
  7824. _generateHTML: function(inst) {
  7825. var maxDraw, prevText, prev, nextText, next, currentText, gotoDate,
  7826. controls, buttonPanel, firstDay, showWeek, dayNames, dayNamesMin,
  7827. monthNames, monthNamesShort, beforeShowDay, showOtherMonths,
  7828. selectOtherMonths, defaultDate, html, dow, row, group, col, selectedDate,
  7829. cornerClass, calender, thead, day, daysInMonth, leadDays, curRows, numRows,
  7830. printDate, dRow, tbody, daySettings, otherMonth, unselectable,
  7831. tempDate = new Date(),
  7832. today = this._daylightSavingAdjust(
  7833. new Date(tempDate.getFullYear(), tempDate.getMonth(), tempDate.getDate())), // clear time
  7834. isRTL = this._get(inst, "isRTL"),
  7835. showButtonPanel = this._get(inst, "showButtonPanel"),
  7836. hideIfNoPrevNext = this._get(inst, "hideIfNoPrevNext"),
  7837. navigationAsDateFormat = this._get(inst, "navigationAsDateFormat"),
  7838. numMonths = this._getNumberOfMonths(inst),
  7839. showCurrentAtPos = this._get(inst, "showCurrentAtPos"),
  7840. stepMonths = this._get(inst, "stepMonths"),
  7841. isMultiMonth = (numMonths[0] !== 1 || numMonths[1] !== 1),
  7842. currentDate = this._daylightSavingAdjust((!inst.currentDay ? new Date(9999, 9, 9) :
  7843. new Date(inst.currentYear, inst.currentMonth, inst.currentDay))),
  7844. minDate = this._getMinMaxDate(inst, "min"),
  7845. maxDate = this._getMinMaxDate(inst, "max"),
  7846. drawMonth = inst.drawMonth - showCurrentAtPos,
  7847. drawYear = inst.drawYear;
  7848. if (drawMonth < 0) {
  7849. drawMonth += 12;
  7850. drawYear--;
  7851. }
  7852. if (maxDate) {
  7853. maxDraw = this._daylightSavingAdjust(new Date(maxDate.getFullYear(),
  7854. maxDate.getMonth() - (numMonths[0] * numMonths[1]) + 1, maxDate.getDate()));
  7855. maxDraw = (minDate && maxDraw < minDate ? minDate : maxDraw);
  7856. while (this._daylightSavingAdjust(new Date(drawYear, drawMonth, 1)) > maxDraw) {
  7857. drawMonth--;
  7858. if (drawMonth < 0) {
  7859. drawMonth = 11;
  7860. drawYear--;
  7861. }
  7862. }
  7863. }
  7864. inst.drawMonth = drawMonth;
  7865. inst.drawYear = drawYear;
  7866. prevText = this._get(inst, "prevText");
  7867. prevText = (!navigationAsDateFormat ? prevText : this.formatDate(prevText,
  7868. this._daylightSavingAdjust(new Date(drawYear, drawMonth - stepMonths, 1)),
  7869. this._getFormatConfig(inst)));
  7870. prev = (this._canAdjustMonth(inst, -1, drawYear, drawMonth) ?
  7871. "<a class='ui-datepicker-prev ui-corner-all' data-handler='prev' data-event='click'" +
  7872. " title='" + prevText + "'><span class='ui-icon ui-icon-circle-triangle-" + ( isRTL ? "e" : "w") + "'>" + prevText + "</span></a>" :
  7873. (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>"));
  7874. nextText = this._get(inst, "nextText");
  7875. nextText = (!navigationAsDateFormat ? nextText : this.formatDate(nextText,
  7876. this._daylightSavingAdjust(new Date(drawYear, drawMonth + stepMonths, 1)),
  7877. this._getFormatConfig(inst)));
  7878. next = (this._canAdjustMonth(inst, +1, drawYear, drawMonth) ?
  7879. "<a class='ui-datepicker-next ui-corner-all' data-handler='next' data-event='click'" +
  7880. " title='" + nextText + "'><span class='ui-icon ui-icon-circle-triangle-" + ( isRTL ? "w" : "e") + "'>" + nextText + "</span></a>" :
  7881. (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>"));
  7882. currentText = this._get(inst, "currentText");
  7883. gotoDate = (this._get(inst, "gotoCurrent") && inst.currentDay ? currentDate : today);
  7884. currentText = (!navigationAsDateFormat ? currentText :
  7885. this.formatDate(currentText, gotoDate, this._getFormatConfig(inst)));
  7886. 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'>" +
  7887. this._get(inst, "closeText") + "</button>" : "");
  7888. buttonPanel = (showButtonPanel) ? "<div class='ui-datepicker-buttonpane ui-widget-content'>" + (isRTL ? controls : "") +
  7889. (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'" +
  7890. ">" + currentText + "</button>" : "") + (isRTL ? "" : controls) + "</div>" : "";
  7891. firstDay = parseInt(this._get(inst, "firstDay"),10);
  7892. firstDay = (isNaN(firstDay) ? 0 : firstDay);
  7893. showWeek = this._get(inst, "showWeek");
  7894. dayNames = this._get(inst, "dayNames");
  7895. dayNamesMin = this._get(inst, "dayNamesMin");
  7896. monthNames = this._get(inst, "monthNames");
  7897. monthNamesShort = this._get(inst, "monthNamesShort");
  7898. beforeShowDay = this._get(inst, "beforeShowDay");
  7899. showOtherMonths = this._get(inst, "showOtherMonths");
  7900. selectOtherMonths = this._get(inst, "selectOtherMonths");
  7901. defaultDate = this._getDefaultDate(inst);
  7902. html = "";
  7903. dow;
  7904. for (row = 0; row < numMonths[0]; row++) {
  7905. group = "";
  7906. this.maxRows = 4;
  7907. for (col = 0; col < numMonths[1]; col++) {
  7908. selectedDate = this._daylightSavingAdjust(new Date(drawYear, drawMonth, inst.selectedDay));
  7909. cornerClass = " ui-corner-all";
  7910. calender = "";
  7911. if (isMultiMonth) {
  7912. calender += "<div class='ui-datepicker-group";
  7913. if (numMonths[1] > 1) {
  7914. switch (col) {
  7915. case 0: calender += " ui-datepicker-group-first";
  7916. cornerClass = " ui-corner-" + (isRTL ? "right" : "left"); break;
  7917. case numMonths[1]-1: calender += " ui-datepicker-group-last";
  7918. cornerClass = " ui-corner-" + (isRTL ? "left" : "right"); break;
  7919. default: calender += " ui-datepicker-group-middle"; cornerClass = ""; break;
  7920. }
  7921. }
  7922. calender += "'>";
  7923. }
  7924. calender += "<div class='ui-datepicker-header ui-widget-header ui-helper-clearfix" + cornerClass + "'>" +
  7925. (/all|left/.test(cornerClass) && row === 0 ? (isRTL ? next : prev) : "") +
  7926. (/all|right/.test(cornerClass) && row === 0 ? (isRTL ? prev : next) : "") +
  7927. this._generateMonthYearHeader(inst, drawMonth, drawYear, minDate, maxDate,
  7928. row > 0 || col > 0, monthNames, monthNamesShort) + // draw month headers
  7929. "</div><table class='ui-datepicker-calendar'><thead>" +
  7930. "<tr>";
  7931. thead = (showWeek ? "<th class='ui-datepicker-week-col'>" + this._get(inst, "weekHeader") + "</th>" : "");
  7932. for (dow = 0; dow < 7; dow++) { // days of the week
  7933. day = (dow + firstDay) % 7;
  7934. thead += "<th" + ((dow + firstDay + 6) % 7 >= 5 ? " class='ui-datepicker-week-end'" : "") + ">" +
  7935. "<span title='" + dayNames[day] + "'>" + dayNamesMin[day] + "</span></th>";
  7936. }
  7937. calender += thead + "</tr></thead><tbody>";
  7938. daysInMonth = this._getDaysInMonth(drawYear, drawMonth);
  7939. if (drawYear === inst.selectedYear && drawMonth === inst.selectedMonth) {
  7940. inst.selectedDay = Math.min(inst.selectedDay, daysInMonth);
  7941. }
  7942. leadDays = (this._getFirstDayOfMonth(drawYear, drawMonth) - firstDay + 7) % 7;
  7943. curRows = Math.ceil((leadDays + daysInMonth) / 7); // calculate the number of rows to generate
  7944. numRows = (isMultiMonth ? this.maxRows > curRows ? this.maxRows : curRows : curRows); //If multiple months, use the higher number of rows (see #7043)
  7945. this.maxRows = numRows;
  7946. printDate = this._daylightSavingAdjust(new Date(drawYear, drawMonth, 1 - leadDays));
  7947. for (dRow = 0; dRow < numRows; dRow++) { // create date picker rows
  7948. calender += "<tr>";
  7949. tbody = (!showWeek ? "" : "<td class='ui-datepicker-week-col'>" +
  7950. this._get(inst, "calculateWeek")(printDate) + "</td>");
  7951. for (dow = 0; dow < 7; dow++) { // create date picker days
  7952. daySettings = (beforeShowDay ?
  7953. beforeShowDay.apply((inst.input ? inst.input[0] : null), [printDate]) : [true, ""]);
  7954. otherMonth = (printDate.getMonth() !== drawMonth);
  7955. unselectable = (otherMonth && !selectOtherMonths) || !daySettings[0] ||
  7956. (minDate && printDate < minDate) || (maxDate && printDate > maxDate);
  7957. tbody += "<td class='" +
  7958. ((dow + firstDay + 6) % 7 >= 5 ? " ui-datepicker-week-end" : "") + // highlight weekends
  7959. (otherMonth ? " ui-datepicker-other-month" : "") + // highlight days from other months
  7960. ((printDate.getTime() === selectedDate.getTime() && drawMonth === inst.selectedMonth && inst._keyEvent) || // user pressed key
  7961. (defaultDate.getTime() === printDate.getTime() && defaultDate.getTime() === selectedDate.getTime()) ?
  7962. // or defaultDate is current printedDate and defaultDate is selectedDate
  7963. " " + this._dayOverClass : "") + // highlight selected day
  7964. (unselectable ? " " + this._unselectableClass + " ui-state-disabled": "") + // highlight unselectable days
  7965. (otherMonth && !showOtherMonths ? "" : " " + daySettings[1] + // highlight custom dates
  7966. (printDate.getTime() === currentDate.getTime() ? " " + this._currentClass : "") + // highlight selected day
  7967. (printDate.getTime() === today.getTime() ? " ui-datepicker-today" : "")) + "'" + // highlight today (if different)
  7968. ((!otherMonth || showOtherMonths) && daySettings[2] ? " title='" + daySettings[2].replace(/'/g, "&#39;") + "'" : "") + // cell title
  7969. (unselectable ? "" : " data-handler='selectDay' data-event='click' data-month='" + printDate.getMonth() + "' data-year='" + printDate.getFullYear() + "'") + ">" + // actions
  7970. (otherMonth && !showOtherMonths ? "&#xa0;" : // display for other months
  7971. (unselectable ? "<span class='ui-state-default'>" + printDate.getDate() + "</span>" : "<a class='ui-state-default" +
  7972. (printDate.getTime() === today.getTime() ? " ui-state-highlight" : "") +
  7973. (printDate.getTime() === currentDate.getTime() ? " ui-state-active" : "") + // highlight selected day
  7974. (otherMonth ? " ui-priority-secondary" : "") + // distinguish dates from other months
  7975. "' href='#'>" + printDate.getDate() + "</a>")) + "</td>"; // display selectable date
  7976. printDate.setDate(printDate.getDate() + 1);
  7977. printDate = this._daylightSavingAdjust(printDate);
  7978. }
  7979. calender += tbody + "</tr>";
  7980. }
  7981. drawMonth++;
  7982. if (drawMonth > 11) {
  7983. drawMonth = 0;
  7984. drawYear++;
  7985. }
  7986. calender += "</tbody></table>" + (isMultiMonth ? "</div>" +
  7987. ((numMonths[0] > 0 && col === numMonths[1]-1) ? "<div class='ui-datepicker-row-break'></div>" : "") : "");
  7988. group += calender;
  7989. }
  7990. html += group;
  7991. }
  7992. html += buttonPanel;
  7993. inst._keyEvent = false;
  7994. return html;
  7995. },
  7996. /* Generate the month and year header. */
  7997. _generateMonthYearHeader: function(inst, drawMonth, drawYear, minDate, maxDate,
  7998. secondary, monthNames, monthNamesShort) {
  7999. var inMinYear, inMaxYear, month, years, thisYear, determineYear, year, endYear,
  8000. changeMonth = this._get(inst, "changeMonth"),
  8001. changeYear = this._get(inst, "changeYear"),
  8002. showMonthAfterYear = this._get(inst, "showMonthAfterYear"),
  8003. html = "<div class='ui-datepicker-title'>",
  8004. monthHtml = "";
  8005. // month selection
  8006. if (secondary || !changeMonth) {
  8007. monthHtml += "<span class='ui-datepicker-month'>" + monthNames[drawMonth] + "</span>";
  8008. } else {
  8009. inMinYear = (minDate && minDate.getFullYear() === drawYear);
  8010. inMaxYear = (maxDate && maxDate.getFullYear() === drawYear);
  8011. monthHtml += "<select class='ui-datepicker-month' data-handler='selectMonth' data-event='change'>";
  8012. for ( month = 0; month < 12; month++) {
  8013. if ((!inMinYear || month >= minDate.getMonth()) && (!inMaxYear || month <= maxDate.getMonth())) {
  8014. monthHtml += "<option value='" + month + "'" +
  8015. (month === drawMonth ? " selected='selected'" : "") +
  8016. ">" + monthNamesShort[month] + "</option>";
  8017. }
  8018. }
  8019. monthHtml += "</select>";
  8020. }
  8021. if (!showMonthAfterYear) {
  8022. html += monthHtml + (secondary || !(changeMonth && changeYear) ? "&#xa0;" : "");
  8023. }
  8024. // year selection
  8025. if ( !inst.yearshtml ) {
  8026. inst.yearshtml = "";
  8027. if (secondary || !changeYear) {
  8028. html += "<span class='ui-datepicker-year'>" + drawYear + "</span>";
  8029. } else {
  8030. // determine range of years to display
  8031. years = this._get(inst, "yearRange").split(":");
  8032. thisYear = new Date().getFullYear();
  8033. determineYear = function(value) {
  8034. var year = (value.match(/c[+\-].*/) ? drawYear + parseInt(value.substring(1), 10) :
  8035. (value.match(/[+\-].*/) ? thisYear + parseInt(value, 10) :
  8036. parseInt(value, 10)));
  8037. return (isNaN(year) ? thisYear : year);
  8038. };
  8039. year = determineYear(years[0]);
  8040. endYear = Math.max(year, determineYear(years[1] || ""));
  8041. year = (minDate ? Math.max(year, minDate.getFullYear()) : year);
  8042. endYear = (maxDate ? Math.min(endYear, maxDate.getFullYear()) : endYear);
  8043. inst.yearshtml += "<select class='ui-datepicker-year' data-handler='selectYear' data-event='change'>";
  8044. for (; year <= endYear; year++) {
  8045. inst.yearshtml += "<option value='" + year + "'" +
  8046. (year === drawYear ? " selected='selected'" : "") +
  8047. ">" + year + "</option>";
  8048. }
  8049. inst.yearshtml += "</select>";
  8050. html += inst.yearshtml;
  8051. inst.yearshtml = null;
  8052. }
  8053. }
  8054. html += this._get(inst, "yearSuffix");
  8055. if (showMonthAfterYear) {
  8056. html += (secondary || !(changeMonth && changeYear) ? "&#xa0;" : "") + monthHtml;
  8057. }
  8058. html += "</div>"; // Close datepicker_header
  8059. return html;
  8060. },
  8061. /* Adjust one of the date sub-fields. */
  8062. _adjustInstDate: function(inst, offset, period) {
  8063. var year = inst.drawYear + (period === "Y" ? offset : 0),
  8064. month = inst.drawMonth + (period === "M" ? offset : 0),
  8065. day = Math.min(inst.selectedDay, this._getDaysInMonth(year, month)) + (period === "D" ? offset : 0),
  8066. date = this._restrictMinMax(inst, this._daylightSavingAdjust(new Date(year, month, day)));
  8067. inst.selectedDay = date.getDate();
  8068. inst.drawMonth = inst.selectedMonth = date.getMonth();
  8069. inst.drawYear = inst.selectedYear = date.getFullYear();
  8070. if (period === "M" || period === "Y") {
  8071. this._notifyChange(inst);
  8072. }
  8073. },
  8074. /* Ensure a date is within any min/max bounds. */
  8075. _restrictMinMax: function(inst, date) {
  8076. var minDate = this._getMinMaxDate(inst, "min"),
  8077. maxDate = this._getMinMaxDate(inst, "max"),
  8078. newDate = (minDate && date < minDate ? minDate : date);
  8079. return (maxDate && newDate > maxDate ? maxDate : newDate);
  8080. },
  8081. /* Notify change of month/year. */
  8082. _notifyChange: function(inst) {
  8083. var onChange = this._get(inst, "onChangeMonthYear");
  8084. if (onChange) {
  8085. onChange.apply((inst.input ? inst.input[0] : null),
  8086. [inst.selectedYear, inst.selectedMonth + 1, inst]);
  8087. }
  8088. },
  8089. /* Determine the number of months to show. */
  8090. _getNumberOfMonths: function(inst) {
  8091. var numMonths = this._get(inst, "numberOfMonths");
  8092. return (numMonths == null ? [1, 1] : (typeof numMonths === "number" ? [1, numMonths] : numMonths));
  8093. },
  8094. /* Determine the current maximum date - ensure no time components are set. */
  8095. _getMinMaxDate: function(inst, minMax) {
  8096. return this._determineDate(inst, this._get(inst, minMax + "Date"), null);
  8097. },
  8098. /* Find the number of days in a given month. */
  8099. _getDaysInMonth: function(year, month) {
  8100. return 32 - this._daylightSavingAdjust(new Date(year, month, 32)).getDate();
  8101. },
  8102. /* Find the day of the week of the first of a month. */
  8103. _getFirstDayOfMonth: function(year, month) {
  8104. return new Date(year, month, 1).getDay();
  8105. },
  8106. /* Determines if we should allow a "next/prev" month display change. */
  8107. _canAdjustMonth: function(inst, offset, curYear, curMonth) {
  8108. var numMonths = this._getNumberOfMonths(inst),
  8109. date = this._daylightSavingAdjust(new Date(curYear,
  8110. curMonth + (offset < 0 ? offset : numMonths[0] * numMonths[1]), 1));
  8111. if (offset < 0) {
  8112. date.setDate(this._getDaysInMonth(date.getFullYear(), date.getMonth()));
  8113. }
  8114. return this._isInRange(inst, date);
  8115. },
  8116. /* Is the given date in the accepted range? */
  8117. _isInRange: function(inst, date) {
  8118. var yearSplit, currentYear,
  8119. minDate = this._getMinMaxDate(inst, "min"),
  8120. maxDate = this._getMinMaxDate(inst, "max"),
  8121. minYear = null,
  8122. maxYear = null,
  8123. years = this._get(inst, "yearRange");
  8124. if (years){
  8125. yearSplit = years.split(":");
  8126. currentYear = new Date().getFullYear();
  8127. minYear = parseInt(yearSplit[0], 10);
  8128. maxYear = parseInt(yearSplit[1], 10);
  8129. if ( yearSplit[0].match(/[+\-].*/) ) {
  8130. minYear += currentYear;
  8131. }
  8132. if ( yearSplit[1].match(/[+\-].*/) ) {
  8133. maxYear += currentYear;
  8134. }
  8135. }
  8136. return ((!minDate || date.getTime() >= minDate.getTime()) &&
  8137. (!maxDate || date.getTime() <= maxDate.getTime()) &&
  8138. (!minYear || date.getFullYear() >= minYear) &&
  8139. (!maxYear || date.getFullYear() <= maxYear));
  8140. },
  8141. /* Provide the configuration settings for formatting/parsing. */
  8142. _getFormatConfig: function(inst) {
  8143. var shortYearCutoff = this._get(inst, "shortYearCutoff");
  8144. shortYearCutoff = (typeof shortYearCutoff !== "string" ? shortYearCutoff :
  8145. new Date().getFullYear() % 100 + parseInt(shortYearCutoff, 10));
  8146. return {shortYearCutoff: shortYearCutoff,
  8147. dayNamesShort: this._get(inst, "dayNamesShort"), dayNames: this._get(inst, "dayNames"),
  8148. monthNamesShort: this._get(inst, "monthNamesShort"), monthNames: this._get(inst, "monthNames")};
  8149. },
  8150. /* Format the given date for display. */
  8151. _formatDate: function(inst, day, month, year) {
  8152. if (!day) {
  8153. inst.currentDay = inst.selectedDay;
  8154. inst.currentMonth = inst.selectedMonth;
  8155. inst.currentYear = inst.selectedYear;
  8156. }
  8157. var date = (day ? (typeof day === "object" ? day :
  8158. this._daylightSavingAdjust(new Date(year, month, day))) :
  8159. this._daylightSavingAdjust(new Date(inst.currentYear, inst.currentMonth, inst.currentDay)));
  8160. return this.formatDate(this._get(inst, "dateFormat"), date, this._getFormatConfig(inst));
  8161. }
  8162. });
  8163. /*
  8164. * Bind hover events for datepicker elements.
  8165. * Done via delegate so the binding only occurs once in the lifetime of the parent div.
  8166. * Global instActive, set by _updateDatepicker allows the handlers to find their way back to the active picker.
  8167. */
  8168. function bindHover(dpDiv) {
  8169. var selector = "button, .ui-datepicker-prev, .ui-datepicker-next, .ui-datepicker-calendar td a";
  8170. return dpDiv.delegate(selector, "mouseout", function() {
  8171. $(this).removeClass("ui-state-hover");
  8172. if (this.className.indexOf("ui-datepicker-prev") !== -1) {
  8173. $(this).removeClass("ui-datepicker-prev-hover");
  8174. }
  8175. if (this.className.indexOf("ui-datepicker-next") !== -1) {
  8176. $(this).removeClass("ui-datepicker-next-hover");
  8177. }
  8178. })
  8179. .delegate(selector, "mouseover", function(){
  8180. if (!$.datepicker._isDisabledDatepicker( instActive.inline ? dpDiv.parent()[0] : instActive.input[0])) {
  8181. $(this).parents(".ui-datepicker-calendar").find("a").removeClass("ui-state-hover");
  8182. $(this).addClass("ui-state-hover");
  8183. if (this.className.indexOf("ui-datepicker-prev") !== -1) {
  8184. $(this).addClass("ui-datepicker-prev-hover");
  8185. }
  8186. if (this.className.indexOf("ui-datepicker-next") !== -1) {
  8187. $(this).addClass("ui-datepicker-next-hover");
  8188. }
  8189. }
  8190. });
  8191. }
  8192. /* jQuery extend now ignores nulls! */
  8193. function extendRemove(target, props) {
  8194. $.extend(target, props);
  8195. for (var name in props) {
  8196. if (props[name] == null) {
  8197. target[name] = props[name];
  8198. }
  8199. }
  8200. return target;
  8201. }
  8202. /* Invoke the datepicker functionality.
  8203. @param options string - a command, optionally followed by additional parameters or
  8204. Object - settings for attaching new datepicker functionality
  8205. @return jQuery object */
  8206. $.fn.datepicker = function(options){
  8207. /* Verify an empty collection wasn't passed - Fixes #6976 */
  8208. if ( !this.length ) {
  8209. return this;
  8210. }
  8211. /* Initialise the date picker. */
  8212. if (!$.datepicker.initialized) {
  8213. $(document).mousedown($.datepicker._checkExternalClick);
  8214. $.datepicker.initialized = true;
  8215. }
  8216. /* Append datepicker main container to body if not exist. */
  8217. if ($("#"+$.datepicker._mainDivId).length === 0) {
  8218. $("body").append($.datepicker.dpDiv);
  8219. }
  8220. var otherArgs = Array.prototype.slice.call(arguments, 1);
  8221. if (typeof options === "string" && (options === "isDisabled" || options === "getDate" || options === "widget")) {
  8222. return $.datepicker["_" + options + "Datepicker"].
  8223. apply($.datepicker, [this[0]].concat(otherArgs));
  8224. }
  8225. if (options === "option" && arguments.length === 2 && typeof arguments[1] === "string") {
  8226. return $.datepicker["_" + options + "Datepicker"].
  8227. apply($.datepicker, [this[0]].concat(otherArgs));
  8228. }
  8229. return this.each(function() {
  8230. typeof options === "string" ?
  8231. $.datepicker["_" + options + "Datepicker"].
  8232. apply($.datepicker, [this].concat(otherArgs)) :
  8233. $.datepicker._attachDatepicker(this, options);
  8234. });
  8235. };
  8236. $.datepicker = new Datepicker(); // singleton instance
  8237. $.datepicker.initialized = false;
  8238. $.datepicker.uuid = new Date().getTime();
  8239. $.datepicker.version = "1.10.2";
  8240. // Workaround for #4055
  8241. // Add another global to avoid noConflict issues with inline event handlers
  8242. window["DP_jQuery_" + dpuuid] = $;
  8243. })(jQuery);
  8244. (function( $, undefined ) {
  8245. var sizeRelatedOptions = {
  8246. buttons: true,
  8247. height: true,
  8248. maxHeight: true,
  8249. maxWidth: true,
  8250. minHeight: true,
  8251. minWidth: true,
  8252. width: true
  8253. },
  8254. resizableRelatedOptions = {
  8255. maxHeight: true,
  8256. maxWidth: true,
  8257. minHeight: true,
  8258. minWidth: true
  8259. };
  8260. $.widget( "ui.dialog", {
  8261. version: "1.10.2",
  8262. options: {
  8263. appendTo: "body",
  8264. autoOpen: true,
  8265. buttons: [],
  8266. closeOnEscape: true,
  8267. closeText: "close",
  8268. dialogClass: "",
  8269. draggable: true,
  8270. hide: null,
  8271. height: "auto",
  8272. maxHeight: null,
  8273. maxWidth: null,
  8274. minHeight: 150,
  8275. minWidth: 150,
  8276. modal: false,
  8277. position: {
  8278. my: "center",
  8279. at: "center",
  8280. of: window,
  8281. collision: "fit",
  8282. // Ensure the titlebar is always visible
  8283. using: function( pos ) {
  8284. var topOffset = $( this ).css( pos ).offset().top;
  8285. if ( topOffset < 0 ) {
  8286. $( this ).css( "top", pos.top - topOffset );
  8287. }
  8288. }
  8289. },
  8290. resizable: true,
  8291. show: null,
  8292. title: null,
  8293. width: 300,
  8294. // callbacks
  8295. beforeClose: null,
  8296. close: null,
  8297. drag: null,
  8298. dragStart: null,
  8299. dragStop: null,
  8300. focus: null,
  8301. open: null,
  8302. resize: null,
  8303. resizeStart: null,
  8304. resizeStop: null
  8305. },
  8306. _create: function() {
  8307. this.originalCss = {
  8308. display: this.element[0].style.display,
  8309. width: this.element[0].style.width,
  8310. minHeight: this.element[0].style.minHeight,
  8311. maxHeight: this.element[0].style.maxHeight,
  8312. height: this.element[0].style.height
  8313. };
  8314. this.originalPosition = {
  8315. parent: this.element.parent(),
  8316. index: this.element.parent().children().index( this.element )
  8317. };
  8318. this.originalTitle = this.element.attr("title");
  8319. this.options.title = this.options.title || this.originalTitle;
  8320. this._createWrapper();
  8321. this.element
  8322. .show()
  8323. .removeAttr("title")
  8324. .addClass("ui-dialog-content ui-widget-content")
  8325. .appendTo( this.uiDialog );
  8326. this._createTitlebar();
  8327. this._createButtonPane();
  8328. if ( this.options.draggable && $.fn.draggable ) {
  8329. this._makeDraggable();
  8330. }
  8331. if ( this.options.resizable && $.fn.resizable ) {
  8332. this._makeResizable();
  8333. }
  8334. this._isOpen = false;
  8335. },
  8336. _init: function() {
  8337. if ( this.options.autoOpen ) {
  8338. this.open();
  8339. }
  8340. },
  8341. _appendTo: function() {
  8342. var element = this.options.appendTo;
  8343. if ( element && (element.jquery || element.nodeType) ) {
  8344. return $( element );
  8345. }
  8346. return this.document.find( element || "body" ).eq( 0 );
  8347. },
  8348. _destroy: function() {
  8349. var next,
  8350. originalPosition = this.originalPosition;
  8351. this._destroyOverlay();
  8352. this.element
  8353. .removeUniqueId()
  8354. .removeClass("ui-dialog-content ui-widget-content")
  8355. .css( this.originalCss )
  8356. // Without detaching first, the following becomes really slow
  8357. .detach();
  8358. this.uiDialog.stop( true, true ).remove();
  8359. if ( this.originalTitle ) {
  8360. this.element.attr( "title", this.originalTitle );
  8361. }
  8362. next = originalPosition.parent.children().eq( originalPosition.index );
  8363. // Don't try to place the dialog next to itself (#8613)
  8364. if ( next.length && next[0] !== this.element[0] ) {
  8365. next.before( this.element );
  8366. } else {
  8367. originalPosition.parent.append( this.element );
  8368. }
  8369. },
  8370. widget: function() {
  8371. return this.uiDialog;
  8372. },
  8373. disable: $.noop,
  8374. enable: $.noop,
  8375. close: function( event ) {
  8376. var that = this;
  8377. if ( !this._isOpen || this._trigger( "beforeClose", event ) === false ) {
  8378. return;
  8379. }
  8380. this._isOpen = false;
  8381. this._destroyOverlay();
  8382. if ( !this.opener.filter(":focusable").focus().length ) {
  8383. // Hiding a focused element doesn't trigger blur in WebKit
  8384. // so in case we have nothing to focus on, explicitly blur the active element
  8385. // https://bugs.webkit.org/show_bug.cgi?id=47182
  8386. $( this.document[0].activeElement ).blur();
  8387. }
  8388. this._hide( this.uiDialog, this.options.hide, function() {
  8389. that._trigger( "close", event );
  8390. });
  8391. },
  8392. isOpen: function() {
  8393. return this._isOpen;
  8394. },
  8395. moveToTop: function() {
  8396. this._moveToTop();
  8397. },
  8398. _moveToTop: function( event, silent ) {
  8399. var moved = !!this.uiDialog.nextAll(":visible").insertBefore( this.uiDialog ).length;
  8400. if ( moved && !silent ) {
  8401. this._trigger( "focus", event );
  8402. }
  8403. return moved;
  8404. },
  8405. open: function() {
  8406. var that = this;
  8407. if ( this._isOpen ) {
  8408. if ( this._moveToTop() ) {
  8409. this._focusTabbable();
  8410. }
  8411. return;
  8412. }
  8413. this._isOpen = true;
  8414. this.opener = $( this.document[0].activeElement );
  8415. this._size();
  8416. this._position();
  8417. this._createOverlay();
  8418. this._moveToTop( null, true );
  8419. this._show( this.uiDialog, this.options.show, function() {
  8420. that._focusTabbable();
  8421. that._trigger("focus");
  8422. });
  8423. this._trigger("open");
  8424. },
  8425. _focusTabbable: function() {
  8426. // Set focus to the first match:
  8427. // 1. First element inside the dialog matching [autofocus]
  8428. // 2. Tabbable element inside the content element
  8429. // 3. Tabbable element inside the buttonpane
  8430. // 4. The close button
  8431. // 5. The dialog itself
  8432. var hasFocus = this.element.find("[autofocus]");
  8433. if ( !hasFocus.length ) {
  8434. hasFocus = this.element.find(":tabbable");
  8435. }
  8436. if ( !hasFocus.length ) {
  8437. hasFocus = this.uiDialogButtonPane.find(":tabbable");
  8438. }
  8439. if ( !hasFocus.length ) {
  8440. hasFocus = this.uiDialogTitlebarClose.filter(":tabbable");
  8441. }
  8442. if ( !hasFocus.length ) {
  8443. hasFocus = this.uiDialog;
  8444. }
  8445. hasFocus.eq( 0 ).focus();
  8446. },
  8447. _keepFocus: function( event ) {
  8448. function checkFocus() {
  8449. var activeElement = this.document[0].activeElement,
  8450. isActive = this.uiDialog[0] === activeElement ||
  8451. $.contains( this.uiDialog[0], activeElement );
  8452. if ( !isActive ) {
  8453. this._focusTabbable();
  8454. }
  8455. }
  8456. event.preventDefault();
  8457. checkFocus.call( this );
  8458. // support: IE
  8459. // IE <= 8 doesn't prevent moving focus even with event.preventDefault()
  8460. // so we check again later
  8461. this._delay( checkFocus );
  8462. },
  8463. _createWrapper: function() {
  8464. this.uiDialog = $("<div>")
  8465. .addClass( "ui-dialog ui-widget ui-widget-content ui-corner-all ui-front " +
  8466. this.options.dialogClass )
  8467. .hide()
  8468. .attr({
  8469. // Setting tabIndex makes the div focusable
  8470. tabIndex: -1,
  8471. role: "dialog"
  8472. })
  8473. .appendTo( this._appendTo() );
  8474. this._on( this.uiDialog, {
  8475. keydown: function( event ) {
  8476. if ( this.options.closeOnEscape && !event.isDefaultPrevented() && event.keyCode &&
  8477. event.keyCode === $.ui.keyCode.ESCAPE ) {
  8478. event.preventDefault();
  8479. this.close( event );
  8480. return;
  8481. }
  8482. // prevent tabbing out of dialogs
  8483. if ( event.keyCode !== $.ui.keyCode.TAB ) {
  8484. return;
  8485. }
  8486. var tabbables = this.uiDialog.find(":tabbable"),
  8487. first = tabbables.filter(":first"),
  8488. last = tabbables.filter(":last");
  8489. if ( ( event.target === last[0] || event.target === this.uiDialog[0] ) && !event.shiftKey ) {
  8490. first.focus( 1 );
  8491. event.preventDefault();
  8492. } else if ( ( event.target === first[0] || event.target === this.uiDialog[0] ) && event.shiftKey ) {
  8493. last.focus( 1 );
  8494. event.preventDefault();
  8495. }
  8496. },
  8497. mousedown: function( event ) {
  8498. if ( this._moveToTop( event ) ) {
  8499. this._focusTabbable();
  8500. }
  8501. }
  8502. });
  8503. // We assume that any existing aria-describedby attribute means
  8504. // that the dialog content is marked up properly
  8505. // otherwise we brute force the content as the description
  8506. if ( !this.element.find("[aria-describedby]").length ) {
  8507. this.uiDialog.attr({
  8508. "aria-describedby": this.element.uniqueId().attr("id")
  8509. });
  8510. }
  8511. },
  8512. _createTitlebar: function() {
  8513. var uiDialogTitle;
  8514. this.uiDialogTitlebar = $("<div>")
  8515. .addClass("ui-dialog-titlebar ui-widget-header ui-corner-all ui-helper-clearfix")
  8516. .prependTo( this.uiDialog );
  8517. this._on( this.uiDialogTitlebar, {
  8518. mousedown: function( event ) {
  8519. // Don't prevent click on close button (#8838)
  8520. // Focusing a dialog that is partially scrolled out of view
  8521. // causes the browser to scroll it into view, preventing the click event
  8522. if ( !$( event.target ).closest(".ui-dialog-titlebar-close") ) {
  8523. // Dialog isn't getting focus when dragging (#8063)
  8524. this.uiDialog.focus();
  8525. }
  8526. }
  8527. });
  8528. this.uiDialogTitlebarClose = $("<button></button>")
  8529. .button({
  8530. label: this.options.closeText,
  8531. icons: {
  8532. primary: "ui-icon-closethick"
  8533. },
  8534. text: false
  8535. })
  8536. .addClass("ui-dialog-titlebar-close")
  8537. .appendTo( this.uiDialogTitlebar );
  8538. this._on( this.uiDialogTitlebarClose, {
  8539. click: function( event ) {
  8540. event.preventDefault();
  8541. this.close( event );
  8542. }
  8543. });
  8544. uiDialogTitle = $("<span>")
  8545. .uniqueId()
  8546. .addClass("ui-dialog-title")
  8547. .prependTo( this.uiDialogTitlebar );
  8548. this._title( uiDialogTitle );
  8549. this.uiDialog.attr({
  8550. "aria-labelledby": uiDialogTitle.attr("id")
  8551. });
  8552. },
  8553. _title: function( title ) {
  8554. if ( !this.options.title ) {
  8555. title.html("&#160;");
  8556. }
  8557. title.text( this.options.title );
  8558. },
  8559. _createButtonPane: function() {
  8560. this.uiDialogButtonPane = $("<div>")
  8561. .addClass("ui-dialog-buttonpane ui-widget-content ui-helper-clearfix");
  8562. this.uiButtonSet = $("<div>")
  8563. .addClass("ui-dialog-buttonset")
  8564. .appendTo( this.uiDialogButtonPane );
  8565. this._createButtons();
  8566. },
  8567. _createButtons: function() {
  8568. var that = this,
  8569. buttons = this.options.buttons;
  8570. // if we already have a button pane, remove it
  8571. this.uiDialogButtonPane.remove();
  8572. this.uiButtonSet.empty();
  8573. if ( $.isEmptyObject( buttons ) || ($.isArray( buttons ) && !buttons.length) ) {
  8574. this.uiDialog.removeClass("ui-dialog-buttons");
  8575. return;
  8576. }
  8577. $.each( buttons, function( name, props ) {
  8578. var click, buttonOptions;
  8579. props = $.isFunction( props ) ?
  8580. { click: props, text: name } :
  8581. props;
  8582. // Default to a non-submitting button
  8583. props = $.extend( { type: "button" }, props );
  8584. // Change the context for the click callback to be the main element
  8585. click = props.click;
  8586. props.click = function() {
  8587. click.apply( that.element[0], arguments );
  8588. };
  8589. buttonOptions = {
  8590. icons: props.icons,
  8591. text: props.showText
  8592. };
  8593. delete props.icons;
  8594. delete props.showText;
  8595. $( "<button></button>", props )
  8596. .button( buttonOptions )
  8597. .appendTo( that.uiButtonSet );
  8598. });
  8599. this.uiDialog.addClass("ui-dialog-buttons");
  8600. this.uiDialogButtonPane.appendTo( this.uiDialog );
  8601. },
  8602. _makeDraggable: function() {
  8603. var that = this,
  8604. options = this.options;
  8605. function filteredUi( ui ) {
  8606. return {
  8607. position: ui.position,
  8608. offset: ui.offset
  8609. };
  8610. }
  8611. this.uiDialog.draggable({
  8612. cancel: ".ui-dialog-content, .ui-dialog-titlebar-close",
  8613. handle: ".ui-dialog-titlebar",
  8614. containment: "document",
  8615. start: function( event, ui ) {
  8616. $( this ).addClass("ui-dialog-dragging");
  8617. that._blockFrames();
  8618. that._trigger( "dragStart", event, filteredUi( ui ) );
  8619. },
  8620. drag: function( event, ui ) {
  8621. that._trigger( "drag", event, filteredUi( ui ) );
  8622. },
  8623. stop: function( event, ui ) {
  8624. options.position = [
  8625. ui.position.left - that.document.scrollLeft(),
  8626. ui.position.top - that.document.scrollTop()
  8627. ];
  8628. $( this ).removeClass("ui-dialog-dragging");
  8629. that._unblockFrames();
  8630. that._trigger( "dragStop", event, filteredUi( ui ) );
  8631. }
  8632. });
  8633. },
  8634. _makeResizable: function() {
  8635. var that = this,
  8636. options = this.options,
  8637. handles = options.resizable,
  8638. // .ui-resizable has position: relative defined in the stylesheet
  8639. // but dialogs have to use absolute or fixed positioning
  8640. position = this.uiDialog.css("position"),
  8641. resizeHandles = typeof handles === "string" ?
  8642. handles :
  8643. "n,e,s,w,se,sw,ne,nw";
  8644. function filteredUi( ui ) {
  8645. return {
  8646. originalPosition: ui.originalPosition,
  8647. originalSize: ui.originalSize,
  8648. position: ui.position,
  8649. size: ui.size
  8650. };
  8651. }
  8652. this.uiDialog.resizable({
  8653. cancel: ".ui-dialog-content",
  8654. containment: "document",
  8655. alsoResize: this.element,
  8656. maxWidth: options.maxWidth,
  8657. maxHeight: options.maxHeight,
  8658. minWidth: options.minWidth,
  8659. minHeight: this._minHeight(),
  8660. handles: resizeHandles,
  8661. start: function( event, ui ) {
  8662. $( this ).addClass("ui-dialog-resizing");
  8663. that._blockFrames();
  8664. that._trigger( "resizeStart", event, filteredUi( ui ) );
  8665. },
  8666. resize: function( event, ui ) {
  8667. that._trigger( "resize", event, filteredUi( ui ) );
  8668. },
  8669. stop: function( event, ui ) {
  8670. options.height = $( this ).height();
  8671. options.width = $( this ).width();
  8672. $( this ).removeClass("ui-dialog-resizing");
  8673. that._unblockFrames();
  8674. that._trigger( "resizeStop", event, filteredUi( ui ) );
  8675. }
  8676. })
  8677. .css( "position", position );
  8678. },
  8679. _minHeight: function() {
  8680. var options = this.options;
  8681. return options.height === "auto" ?
  8682. options.minHeight :
  8683. Math.min( options.minHeight, options.height );
  8684. },
  8685. _position: function() {
  8686. // Need to show the dialog to get the actual offset in the position plugin
  8687. var isVisible = this.uiDialog.is(":visible");
  8688. if ( !isVisible ) {
  8689. this.uiDialog.show();
  8690. }
  8691. this.uiDialog.position( this.options.position );
  8692. if ( !isVisible ) {
  8693. this.uiDialog.hide();
  8694. }
  8695. },
  8696. _setOptions: function( options ) {
  8697. var that = this,
  8698. resize = false,
  8699. resizableOptions = {};
  8700. $.each( options, function( key, value ) {
  8701. that._setOption( key, value );
  8702. if ( key in sizeRelatedOptions ) {
  8703. resize = true;
  8704. }
  8705. if ( key in resizableRelatedOptions ) {
  8706. resizableOptions[ key ] = value;
  8707. }
  8708. });
  8709. if ( resize ) {
  8710. this._size();
  8711. this._position();
  8712. }
  8713. if ( this.uiDialog.is(":data(ui-resizable)") ) {
  8714. this.uiDialog.resizable( "option", resizableOptions );
  8715. }
  8716. },
  8717. _setOption: function( key, value ) {
  8718. /*jshint maxcomplexity:15*/
  8719. var isDraggable, isResizable,
  8720. uiDialog = this.uiDialog;
  8721. if ( key === "dialogClass" ) {
  8722. uiDialog
  8723. .removeClass( this.options.dialogClass )
  8724. .addClass( value );
  8725. }
  8726. if ( key === "disabled" ) {
  8727. return;
  8728. }
  8729. this._super( key, value );
  8730. if ( key === "appendTo" ) {
  8731. this.uiDialog.appendTo( this._appendTo() );
  8732. }
  8733. if ( key === "buttons" ) {
  8734. this._createButtons();
  8735. }
  8736. if ( key === "closeText" ) {
  8737. this.uiDialogTitlebarClose.button({
  8738. // Ensure that we always pass a string
  8739. label: "" + value
  8740. });
  8741. }
  8742. if ( key === "draggable" ) {
  8743. isDraggable = uiDialog.is(":data(ui-draggable)");
  8744. if ( isDraggable && !value ) {
  8745. uiDialog.draggable("destroy");
  8746. }
  8747. if ( !isDraggable && value ) {
  8748. this._makeDraggable();
  8749. }
  8750. }
  8751. if ( key === "position" ) {
  8752. this._position();
  8753. }
  8754. if ( key === "resizable" ) {
  8755. // currently resizable, becoming non-resizable
  8756. isResizable = uiDialog.is(":data(ui-resizable)");
  8757. if ( isResizable && !value ) {
  8758. uiDialog.resizable("destroy");
  8759. }
  8760. // currently resizable, changing handles
  8761. if ( isResizable && typeof value === "string" ) {
  8762. uiDialog.resizable( "option", "handles", value );
  8763. }
  8764. // currently non-resizable, becoming resizable
  8765. if ( !isResizable && value !== false ) {
  8766. this._makeResizable();
  8767. }
  8768. }
  8769. if ( key === "title" ) {
  8770. this._title( this.uiDialogTitlebar.find(".ui-dialog-title") );
  8771. }
  8772. },
  8773. _size: function() {
  8774. // If the user has resized the dialog, the .ui-dialog and .ui-dialog-content
  8775. // divs will both have width and height set, so we need to reset them
  8776. var nonContentHeight, minContentHeight, maxContentHeight,
  8777. options = this.options;
  8778. // Reset content sizing
  8779. this.element.show().css({
  8780. width: "auto",
  8781. minHeight: 0,
  8782. maxHeight: "none",
  8783. height: 0
  8784. });
  8785. if ( options.minWidth > options.width ) {
  8786. options.width = options.minWidth;
  8787. }
  8788. // reset wrapper sizing
  8789. // determine the height of all the non-content elements
  8790. nonContentHeight = this.uiDialog.css({
  8791. height: "auto",
  8792. width: options.width
  8793. })
  8794. .outerHeight();
  8795. minContentHeight = Math.max( 0, options.minHeight - nonContentHeight );
  8796. maxContentHeight = typeof options.maxHeight === "number" ?
  8797. Math.max( 0, options.maxHeight - nonContentHeight ) :
  8798. "none";
  8799. if ( options.height === "auto" ) {
  8800. this.element.css({
  8801. minHeight: minContentHeight,
  8802. maxHeight: maxContentHeight,
  8803. height: "auto"
  8804. });
  8805. } else {
  8806. this.element.height( Math.max( 0, options.height - nonContentHeight ) );
  8807. }
  8808. if (this.uiDialog.is(":data(ui-resizable)") ) {
  8809. this.uiDialog.resizable( "option", "minHeight", this._minHeight() );
  8810. }
  8811. },
  8812. _blockFrames: function() {
  8813. this.iframeBlocks = this.document.find( "iframe" ).map(function() {
  8814. var iframe = $( this );
  8815. return $( "<div>" )
  8816. .css({
  8817. position: "absolute",
  8818. width: iframe.outerWidth(),
  8819. height: iframe.outerHeight()
  8820. })
  8821. .appendTo( iframe.parent() )
  8822. .offset( iframe.offset() )[0];
  8823. });
  8824. },
  8825. _unblockFrames: function() {
  8826. if ( this.iframeBlocks ) {
  8827. this.iframeBlocks.remove();
  8828. delete this.iframeBlocks;
  8829. }
  8830. },
  8831. _allowInteraction: function( event ) {
  8832. if ( $( event.target ).closest(".ui-dialog").length ) {
  8833. return true;
  8834. }
  8835. // TODO: Remove hack when datepicker implements
  8836. // the .ui-front logic (#8989)
  8837. return !!$( event.target ).closest(".ui-datepicker").length;
  8838. },
  8839. _createOverlay: function() {
  8840. if ( !this.options.modal ) {
  8841. return;
  8842. }
  8843. var that = this,
  8844. widgetFullName = this.widgetFullName;
  8845. if ( !$.ui.dialog.overlayInstances ) {
  8846. // Prevent use of anchors and inputs.
  8847. // We use a delay in case the overlay is created from an
  8848. // event that we're going to be cancelling. (#2804)
  8849. this._delay(function() {
  8850. // Handle .dialog().dialog("close") (#4065)
  8851. if ( $.ui.dialog.overlayInstances ) {
  8852. this.document.bind( "focusin.dialog", function( event ) {
  8853. if ( !that._allowInteraction( event ) ) {
  8854. event.preventDefault();
  8855. $(".ui-dialog:visible:last .ui-dialog-content")
  8856. .data( widgetFullName )._focusTabbable();
  8857. }
  8858. });
  8859. }
  8860. });
  8861. }
  8862. this.overlay = $("<div>")
  8863. .addClass("ui-widget-overlay ui-front")
  8864. .appendTo( this._appendTo() );
  8865. this._on( this.overlay, {
  8866. mousedown: "_keepFocus"
  8867. });
  8868. $.ui.dialog.overlayInstances++;
  8869. },
  8870. _destroyOverlay: function() {
  8871. if ( !this.options.modal ) {
  8872. return;
  8873. }
  8874. if ( this.overlay ) {
  8875. $.ui.dialog.overlayInstances--;
  8876. if ( !$.ui.dialog.overlayInstances ) {
  8877. this.document.unbind( "focusin.dialog" );
  8878. }
  8879. this.overlay.remove();
  8880. this.overlay = null;
  8881. }
  8882. }
  8883. });
  8884. $.ui.dialog.overlayInstances = 0;
  8885. // DEPRECATED
  8886. if ( $.uiBackCompat !== false ) {
  8887. // position option with array notation
  8888. // just override with old implementation
  8889. $.widget( "ui.dialog", $.ui.dialog, {
  8890. _position: function() {
  8891. var position = this.options.position,
  8892. myAt = [],
  8893. offset = [ 0, 0 ],
  8894. isVisible;
  8895. if ( position ) {
  8896. if ( typeof position === "string" || (typeof position === "object" && "0" in position ) ) {
  8897. myAt = position.split ? position.split(" ") : [ position[0], position[1] ];
  8898. if ( myAt.length === 1 ) {
  8899. myAt[1] = myAt[0];
  8900. }
  8901. $.each( [ "left", "top" ], function( i, offsetPosition ) {
  8902. if ( +myAt[ i ] === myAt[ i ] ) {
  8903. offset[ i ] = myAt[ i ];
  8904. myAt[ i ] = offsetPosition;
  8905. }
  8906. });
  8907. position = {
  8908. my: myAt[0] + (offset[0] < 0 ? offset[0] : "+" + offset[0]) + " " +
  8909. myAt[1] + (offset[1] < 0 ? offset[1] : "+" + offset[1]),
  8910. at: myAt.join(" ")
  8911. };
  8912. }
  8913. position = $.extend( {}, $.ui.dialog.prototype.options.position, position );
  8914. } else {
  8915. position = $.ui.dialog.prototype.options.position;
  8916. }
  8917. // need to show the dialog to get the actual offset in the position plugin
  8918. isVisible = this.uiDialog.is(":visible");
  8919. if ( !isVisible ) {
  8920. this.uiDialog.show();
  8921. }
  8922. this.uiDialog.position( position );
  8923. if ( !isVisible ) {
  8924. this.uiDialog.hide();
  8925. }
  8926. }
  8927. });
  8928. }
  8929. }( jQuery ) );
  8930. (function( $, undefined ) {
  8931. var rvertical = /up|down|vertical/,
  8932. rpositivemotion = /up|left|vertical|horizontal/;
  8933. $.effects.effect.blind = function( o, done ) {
  8934. // Create element
  8935. var el = $( this ),
  8936. props = [ "position", "top", "bottom", "left", "right", "height", "width" ],
  8937. mode = $.effects.setMode( el, o.mode || "hide" ),
  8938. direction = o.direction || "up",
  8939. vertical = rvertical.test( direction ),
  8940. ref = vertical ? "height" : "width",
  8941. ref2 = vertical ? "top" : "left",
  8942. motion = rpositivemotion.test( direction ),
  8943. animation = {},
  8944. show = mode === "show",
  8945. wrapper, distance, margin;
  8946. // if already wrapped, the wrapper's properties are my property. #6245
  8947. if ( el.parent().is( ".ui-effects-wrapper" ) ) {
  8948. $.effects.save( el.parent(), props );
  8949. } else {
  8950. $.effects.save( el, props );
  8951. }
  8952. el.show();
  8953. wrapper = $.effects.createWrapper( el ).css({
  8954. overflow: "hidden"
  8955. });
  8956. distance = wrapper[ ref ]();
  8957. margin = parseFloat( wrapper.css( ref2 ) ) || 0;
  8958. animation[ ref ] = show ? distance : 0;
  8959. if ( !motion ) {
  8960. el
  8961. .css( vertical ? "bottom" : "right", 0 )
  8962. .css( vertical ? "top" : "left", "auto" )
  8963. .css({ position: "absolute" });
  8964. animation[ ref2 ] = show ? margin : distance + margin;
  8965. }
  8966. // start at 0 if we are showing
  8967. if ( show ) {
  8968. wrapper.css( ref, 0 );
  8969. if ( ! motion ) {
  8970. wrapper.css( ref2, margin + distance );
  8971. }
  8972. }
  8973. // Animate
  8974. wrapper.animate( animation, {
  8975. duration: o.duration,
  8976. easing: o.easing,
  8977. queue: false,
  8978. complete: function() {
  8979. if ( mode === "hide" ) {
  8980. el.hide();
  8981. }
  8982. $.effects.restore( el, props );
  8983. $.effects.removeWrapper( el );
  8984. done();
  8985. }
  8986. });
  8987. };
  8988. })(jQuery);
  8989. (function( $, undefined ) {
  8990. $.effects.effect.bounce = function( o, done ) {
  8991. var el = $( this ),
  8992. props = [ "position", "top", "bottom", "left", "right", "height", "width" ],
  8993. // defaults:
  8994. mode = $.effects.setMode( el, o.mode || "effect" ),
  8995. hide = mode === "hide",
  8996. show = mode === "show",
  8997. direction = o.direction || "up",
  8998. distance = o.distance,
  8999. times = o.times || 5,
  9000. // number of internal animations
  9001. anims = times * 2 + ( show || hide ? 1 : 0 ),
  9002. speed = o.duration / anims,
  9003. easing = o.easing,
  9004. // utility:
  9005. ref = ( direction === "up" || direction === "down" ) ? "top" : "left",
  9006. motion = ( direction === "up" || direction === "left" ),
  9007. i,
  9008. upAnim,
  9009. downAnim,
  9010. // we will need to re-assemble the queue to stack our animations in place
  9011. queue = el.queue(),
  9012. queuelen = queue.length;
  9013. // Avoid touching opacity to prevent clearType and PNG issues in IE
  9014. if ( show || hide ) {
  9015. props.push( "opacity" );
  9016. }
  9017. $.effects.save( el, props );
  9018. el.show();
  9019. $.effects.createWrapper( el ); // Create Wrapper
  9020. // default distance for the BIGGEST bounce is the outer Distance / 3
  9021. if ( !distance ) {
  9022. distance = el[ ref === "top" ? "outerHeight" : "outerWidth" ]() / 3;
  9023. }
  9024. if ( show ) {
  9025. downAnim = { opacity: 1 };
  9026. downAnim[ ref ] = 0;
  9027. // if we are showing, force opacity 0 and set the initial position
  9028. // then do the "first" animation
  9029. el.css( "opacity", 0 )
  9030. .css( ref, motion ? -distance * 2 : distance * 2 )
  9031. .animate( downAnim, speed, easing );
  9032. }
  9033. // start at the smallest distance if we are hiding
  9034. if ( hide ) {
  9035. distance = distance / Math.pow( 2, times - 1 );
  9036. }
  9037. downAnim = {};
  9038. downAnim[ ref ] = 0;
  9039. // Bounces up/down/left/right then back to 0 -- times * 2 animations happen here
  9040. for ( i = 0; i < times; i++ ) {
  9041. upAnim = {};
  9042. upAnim[ ref ] = ( motion ? "-=" : "+=" ) + distance;
  9043. el.animate( upAnim, speed, easing )
  9044. .animate( downAnim, speed, easing );
  9045. distance = hide ? distance * 2 : distance / 2;
  9046. }
  9047. // Last Bounce when Hiding
  9048. if ( hide ) {
  9049. upAnim = { opacity: 0 };
  9050. upAnim[ ref ] = ( motion ? "-=" : "+=" ) + distance;
  9051. el.animate( upAnim, speed, easing );
  9052. }
  9053. el.queue(function() {
  9054. if ( hide ) {
  9055. el.hide();
  9056. }
  9057. $.effects.restore( el, props );
  9058. $.effects.removeWrapper( el );
  9059. done();
  9060. });
  9061. // inject all the animations we just queued to be first in line (after "inprogress")
  9062. if ( queuelen > 1) {
  9063. queue.splice.apply( queue,
  9064. [ 1, 0 ].concat( queue.splice( queuelen, anims + 1 ) ) );
  9065. }
  9066. el.dequeue();
  9067. };
  9068. })(jQuery);
  9069. (function( $, undefined ) {
  9070. $.effects.effect.clip = function( o, done ) {
  9071. // Create element
  9072. var el = $( this ),
  9073. props = [ "position", "top", "bottom", "left", "right", "height", "width" ],
  9074. mode = $.effects.setMode( el, o.mode || "hide" ),
  9075. show = mode === "show",
  9076. direction = o.direction || "vertical",
  9077. vert = direction === "vertical",
  9078. size = vert ? "height" : "width",
  9079. position = vert ? "top" : "left",
  9080. animation = {},
  9081. wrapper, animate, distance;
  9082. // Save & Show
  9083. $.effects.save( el, props );
  9084. el.show();
  9085. // Create Wrapper
  9086. wrapper = $.effects.createWrapper( el ).css({
  9087. overflow: "hidden"
  9088. });
  9089. animate = ( el[0].tagName === "IMG" ) ? wrapper : el;
  9090. distance = animate[ size ]();
  9091. // Shift
  9092. if ( show ) {
  9093. animate.css( size, 0 );
  9094. animate.css( position, distance / 2 );
  9095. }
  9096. // Create Animation Object:
  9097. animation[ size ] = show ? distance : 0;
  9098. animation[ position ] = show ? 0 : distance / 2;
  9099. // Animate
  9100. animate.animate( animation, {
  9101. queue: false,
  9102. duration: o.duration,
  9103. easing: o.easing,
  9104. complete: function() {
  9105. if ( !show ) {
  9106. el.hide();
  9107. }
  9108. $.effects.restore( el, props );
  9109. $.effects.removeWrapper( el );
  9110. done();
  9111. }
  9112. });
  9113. };
  9114. })(jQuery);
  9115. (function( $, undefined ) {
  9116. $.effects.effect.drop = function( o, done ) {
  9117. var el = $( this ),
  9118. props = [ "position", "top", "bottom", "left", "right", "opacity", "height", "width" ],
  9119. mode = $.effects.setMode( el, o.mode || "hide" ),
  9120. show = mode === "show",
  9121. direction = o.direction || "left",
  9122. ref = ( direction === "up" || direction === "down" ) ? "top" : "left",
  9123. motion = ( direction === "up" || direction === "left" ) ? "pos" : "neg",
  9124. animation = {
  9125. opacity: show ? 1 : 0
  9126. },
  9127. distance;
  9128. // Adjust
  9129. $.effects.save( el, props );
  9130. el.show();
  9131. $.effects.createWrapper( el );
  9132. distance = o.distance || el[ ref === "top" ? "outerHeight": "outerWidth" ]( true ) / 2;
  9133. if ( show ) {
  9134. el
  9135. .css( "opacity", 0 )
  9136. .css( ref, motion === "pos" ? -distance : distance );
  9137. }
  9138. // Animation
  9139. animation[ ref ] = ( show ?
  9140. ( motion === "pos" ? "+=" : "-=" ) :
  9141. ( motion === "pos" ? "-=" : "+=" ) ) +
  9142. distance;
  9143. // Animate
  9144. el.animate( animation, {
  9145. queue: false,
  9146. duration: o.duration,
  9147. easing: o.easing,
  9148. complete: function() {
  9149. if ( mode === "hide" ) {
  9150. el.hide();
  9151. }
  9152. $.effects.restore( el, props );
  9153. $.effects.removeWrapper( el );
  9154. done();
  9155. }
  9156. });
  9157. };
  9158. })(jQuery);
  9159. (function( $, undefined ) {
  9160. $.effects.effect.explode = function( o, done ) {
  9161. var rows = o.pieces ? Math.round( Math.sqrt( o.pieces ) ) : 3,
  9162. cells = rows,
  9163. el = $( this ),
  9164. mode = $.effects.setMode( el, o.mode || "hide" ),
  9165. show = mode === "show",
  9166. // show and then visibility:hidden the element before calculating offset
  9167. offset = el.show().css( "visibility", "hidden" ).offset(),
  9168. // width and height of a piece
  9169. width = Math.ceil( el.outerWidth() / cells ),
  9170. height = Math.ceil( el.outerHeight() / rows ),
  9171. pieces = [],
  9172. // loop
  9173. i, j, left, top, mx, my;
  9174. // children animate complete:
  9175. function childComplete() {
  9176. pieces.push( this );
  9177. if ( pieces.length === rows * cells ) {
  9178. animComplete();
  9179. }
  9180. }
  9181. // clone the element for each row and cell.
  9182. for( i = 0; i < rows ; i++ ) { // ===>
  9183. top = offset.top + i * height;
  9184. my = i - ( rows - 1 ) / 2 ;
  9185. for( j = 0; j < cells ; j++ ) { // |||
  9186. left = offset.left + j * width;
  9187. mx = j - ( cells - 1 ) / 2 ;
  9188. // Create a clone of the now hidden main element that will be absolute positioned
  9189. // within a wrapper div off the -left and -top equal to size of our pieces
  9190. el
  9191. .clone()
  9192. .appendTo( "body" )
  9193. .wrap( "<div></div>" )
  9194. .css({
  9195. position: "absolute",
  9196. visibility: "visible",
  9197. left: -j * width,
  9198. top: -i * height
  9199. })
  9200. // select the wrapper - make it overflow: hidden and absolute positioned based on
  9201. // where the original was located +left and +top equal to the size of pieces
  9202. .parent()
  9203. .addClass( "ui-effects-explode" )
  9204. .css({
  9205. position: "absolute",
  9206. overflow: "hidden",
  9207. width: width,
  9208. height: height,
  9209. left: left + ( show ? mx * width : 0 ),
  9210. top: top + ( show ? my * height : 0 ),
  9211. opacity: show ? 0 : 1
  9212. }).animate({
  9213. left: left + ( show ? 0 : mx * width ),
  9214. top: top + ( show ? 0 : my * height ),
  9215. opacity: show ? 1 : 0
  9216. }, o.duration || 500, o.easing, childComplete );
  9217. }
  9218. }
  9219. function animComplete() {
  9220. el.css({
  9221. visibility: "visible"
  9222. });
  9223. $( pieces ).remove();
  9224. if ( !show ) {
  9225. el.hide();
  9226. }
  9227. done();
  9228. }
  9229. };
  9230. })(jQuery);
  9231. (function( $, undefined ) {
  9232. $.effects.effect.fade = function( o, done ) {
  9233. var el = $( this ),
  9234. mode = $.effects.setMode( el, o.mode || "toggle" );
  9235. el.animate({
  9236. opacity: mode
  9237. }, {
  9238. queue: false,
  9239. duration: o.duration,
  9240. easing: o.easing,
  9241. complete: done
  9242. });
  9243. };
  9244. })( jQuery );
  9245. (function( $, undefined ) {
  9246. $.effects.effect.fold = function( o, done ) {
  9247. // Create element
  9248. var el = $( this ),
  9249. props = [ "position", "top", "bottom", "left", "right", "height", "width" ],
  9250. mode = $.effects.setMode( el, o.mode || "hide" ),
  9251. show = mode === "show",
  9252. hide = mode === "hide",
  9253. size = o.size || 15,
  9254. percent = /([0-9]+)%/.exec( size ),
  9255. horizFirst = !!o.horizFirst,
  9256. widthFirst = show !== horizFirst,
  9257. ref = widthFirst ? [ "width", "height" ] : [ "height", "width" ],
  9258. duration = o.duration / 2,
  9259. wrapper, distance,
  9260. animation1 = {},
  9261. animation2 = {};
  9262. $.effects.save( el, props );
  9263. el.show();
  9264. // Create Wrapper
  9265. wrapper = $.effects.createWrapper( el ).css({
  9266. overflow: "hidden"
  9267. });
  9268. distance = widthFirst ?
  9269. [ wrapper.width(), wrapper.height() ] :
  9270. [ wrapper.height(), wrapper.width() ];
  9271. if ( percent ) {
  9272. size = parseInt( percent[ 1 ], 10 ) / 100 * distance[ hide ? 0 : 1 ];
  9273. }
  9274. if ( show ) {
  9275. wrapper.css( horizFirst ? {
  9276. height: 0,
  9277. width: size
  9278. } : {
  9279. height: size,
  9280. width: 0
  9281. });
  9282. }
  9283. // Animation
  9284. animation1[ ref[ 0 ] ] = show ? distance[ 0 ] : size;
  9285. animation2[ ref[ 1 ] ] = show ? distance[ 1 ] : 0;
  9286. // Animate
  9287. wrapper
  9288. .animate( animation1, duration, o.easing )
  9289. .animate( animation2, duration, o.easing, function() {
  9290. if ( hide ) {
  9291. el.hide();
  9292. }
  9293. $.effects.restore( el, props );
  9294. $.effects.removeWrapper( el );
  9295. done();
  9296. });
  9297. };
  9298. })(jQuery);
  9299. (function( $, undefined ) {
  9300. $.effects.effect.highlight = function( o, done ) {
  9301. var elem = $( this ),
  9302. props = [ "backgroundImage", "backgroundColor", "opacity" ],
  9303. mode = $.effects.setMode( elem, o.mode || "show" ),
  9304. animation = {
  9305. backgroundColor: elem.css( "backgroundColor" )
  9306. };
  9307. if (mode === "hide") {
  9308. animation.opacity = 0;
  9309. }
  9310. $.effects.save( elem, props );
  9311. elem
  9312. .show()
  9313. .css({
  9314. backgroundImage: "none",
  9315. backgroundColor: o.color || "#ffff99"
  9316. })
  9317. .animate( animation, {
  9318. queue: false,
  9319. duration: o.duration,
  9320. easing: o.easing,
  9321. complete: function() {
  9322. if ( mode === "hide" ) {
  9323. elem.hide();
  9324. }
  9325. $.effects.restore( elem, props );
  9326. done();
  9327. }
  9328. });
  9329. };
  9330. })(jQuery);
  9331. (function( $, undefined ) {
  9332. $.effects.effect.pulsate = function( o, done ) {
  9333. var elem = $( this ),
  9334. mode = $.effects.setMode( elem, o.mode || "show" ),
  9335. show = mode === "show",
  9336. hide = mode === "hide",
  9337. showhide = ( show || mode === "hide" ),
  9338. // showing or hiding leaves of the "last" animation
  9339. anims = ( ( o.times || 5 ) * 2 ) + ( showhide ? 1 : 0 ),
  9340. duration = o.duration / anims,
  9341. animateTo = 0,
  9342. queue = elem.queue(),
  9343. queuelen = queue.length,
  9344. i;
  9345. if ( show || !elem.is(":visible")) {
  9346. elem.css( "opacity", 0 ).show();
  9347. animateTo = 1;
  9348. }
  9349. // anims - 1 opacity "toggles"
  9350. for ( i = 1; i < anims; i++ ) {
  9351. elem.animate({
  9352. opacity: animateTo
  9353. }, duration, o.easing );
  9354. animateTo = 1 - animateTo;
  9355. }
  9356. elem.animate({
  9357. opacity: animateTo
  9358. }, duration, o.easing);
  9359. elem.queue(function() {
  9360. if ( hide ) {
  9361. elem.hide();
  9362. }
  9363. done();
  9364. });
  9365. // We just queued up "anims" animations, we need to put them next in the queue
  9366. if ( queuelen > 1 ) {
  9367. queue.splice.apply( queue,
  9368. [ 1, 0 ].concat( queue.splice( queuelen, anims + 1 ) ) );
  9369. }
  9370. elem.dequeue();
  9371. };
  9372. })(jQuery);
  9373. (function( $, undefined ) {
  9374. $.effects.effect.puff = function( o, done ) {
  9375. var elem = $( this ),
  9376. mode = $.effects.setMode( elem, o.mode || "hide" ),
  9377. hide = mode === "hide",
  9378. percent = parseInt( o.percent, 10 ) || 150,
  9379. factor = percent / 100,
  9380. original = {
  9381. height: elem.height(),
  9382. width: elem.width(),
  9383. outerHeight: elem.outerHeight(),
  9384. outerWidth: elem.outerWidth()
  9385. };
  9386. $.extend( o, {
  9387. effect: "scale",
  9388. queue: false,
  9389. fade: true,
  9390. mode: mode,
  9391. complete: done,
  9392. percent: hide ? percent : 100,
  9393. from: hide ?
  9394. original :
  9395. {
  9396. height: original.height * factor,
  9397. width: original.width * factor,
  9398. outerHeight: original.outerHeight * factor,
  9399. outerWidth: original.outerWidth * factor
  9400. }
  9401. });
  9402. elem.effect( o );
  9403. };
  9404. $.effects.effect.scale = function( o, done ) {
  9405. // Create element
  9406. var el = $( this ),
  9407. options = $.extend( true, {}, o ),
  9408. mode = $.effects.setMode( el, o.mode || "effect" ),
  9409. percent = parseInt( o.percent, 10 ) ||
  9410. ( parseInt( o.percent, 10 ) === 0 ? 0 : ( mode === "hide" ? 0 : 100 ) ),
  9411. direction = o.direction || "both",
  9412. origin = o.origin,
  9413. original = {
  9414. height: el.height(),
  9415. width: el.width(),
  9416. outerHeight: el.outerHeight(),
  9417. outerWidth: el.outerWidth()
  9418. },
  9419. factor = {
  9420. y: direction !== "horizontal" ? (percent / 100) : 1,
  9421. x: direction !== "vertical" ? (percent / 100) : 1
  9422. };
  9423. // We are going to pass this effect to the size effect:
  9424. options.effect = "size";
  9425. options.queue = false;
  9426. options.complete = done;
  9427. // Set default origin and restore for show/hide
  9428. if ( mode !== "effect" ) {
  9429. options.origin = origin || ["middle","center"];
  9430. options.restore = true;
  9431. }
  9432. options.from = o.from || ( mode === "show" ? {
  9433. height: 0,
  9434. width: 0,
  9435. outerHeight: 0,
  9436. outerWidth: 0
  9437. } : original );
  9438. options.to = {
  9439. height: original.height * factor.y,
  9440. width: original.width * factor.x,
  9441. outerHeight: original.outerHeight * factor.y,
  9442. outerWidth: original.outerWidth * factor.x
  9443. };
  9444. // Fade option to support puff
  9445. if ( options.fade ) {
  9446. if ( mode === "show" ) {
  9447. options.from.opacity = 0;
  9448. options.to.opacity = 1;
  9449. }
  9450. if ( mode === "hide" ) {
  9451. options.from.opacity = 1;
  9452. options.to.opacity = 0;
  9453. }
  9454. }
  9455. // Animate
  9456. el.effect( options );
  9457. };
  9458. $.effects.effect.size = function( o, done ) {
  9459. // Create element
  9460. var original, baseline, factor,
  9461. el = $( this ),
  9462. props0 = [ "position", "top", "bottom", "left", "right", "width", "height", "overflow", "opacity" ],
  9463. // Always restore
  9464. props1 = [ "position", "top", "bottom", "left", "right", "overflow", "opacity" ],
  9465. // Copy for children
  9466. props2 = [ "width", "height", "overflow" ],
  9467. cProps = [ "fontSize" ],
  9468. vProps = [ "borderTopWidth", "borderBottomWidth", "paddingTop", "paddingBottom" ],
  9469. hProps = [ "borderLeftWidth", "borderRightWidth", "paddingLeft", "paddingRight" ],
  9470. // Set options
  9471. mode = $.effects.setMode( el, o.mode || "effect" ),
  9472. restore = o.restore || mode !== "effect",
  9473. scale = o.scale || "both",
  9474. origin = o.origin || [ "middle", "center" ],
  9475. position = el.css( "position" ),
  9476. props = restore ? props0 : props1,
  9477. zero = {
  9478. height: 0,
  9479. width: 0,
  9480. outerHeight: 0,
  9481. outerWidth: 0
  9482. };
  9483. if ( mode === "show" ) {
  9484. el.show();
  9485. }
  9486. original = {
  9487. height: el.height(),
  9488. width: el.width(),
  9489. outerHeight: el.outerHeight(),
  9490. outerWidth: el.outerWidth()
  9491. };
  9492. if ( o.mode === "toggle" && mode === "show" ) {
  9493. el.from = o.to || zero;
  9494. el.to = o.from || original;
  9495. } else {
  9496. el.from = o.from || ( mode === "show" ? zero : original );
  9497. el.to = o.to || ( mode === "hide" ? zero : original );
  9498. }
  9499. // Set scaling factor
  9500. factor = {
  9501. from: {
  9502. y: el.from.height / original.height,
  9503. x: el.from.width / original.width
  9504. },
  9505. to: {
  9506. y: el.to.height / original.height,
  9507. x: el.to.width / original.width
  9508. }
  9509. };
  9510. // Scale the css box
  9511. if ( scale === "box" || scale === "both" ) {
  9512. // Vertical props scaling
  9513. if ( factor.from.y !== factor.to.y ) {
  9514. props = props.concat( vProps );
  9515. el.from = $.effects.setTransition( el, vProps, factor.from.y, el.from );
  9516. el.to = $.effects.setTransition( el, vProps, factor.to.y, el.to );
  9517. }
  9518. // Horizontal props scaling
  9519. if ( factor.from.x !== factor.to.x ) {
  9520. props = props.concat( hProps );
  9521. el.from = $.effects.setTransition( el, hProps, factor.from.x, el.from );
  9522. el.to = $.effects.setTransition( el, hProps, factor.to.x, el.to );
  9523. }
  9524. }
  9525. // Scale the content
  9526. if ( scale === "content" || scale === "both" ) {
  9527. // Vertical props scaling
  9528. if ( factor.from.y !== factor.to.y ) {
  9529. props = props.concat( cProps ).concat( props2 );
  9530. el.from = $.effects.setTransition( el, cProps, factor.from.y, el.from );
  9531. el.to = $.effects.setTransition( el, cProps, factor.to.y, el.to );
  9532. }
  9533. }
  9534. $.effects.save( el, props );
  9535. el.show();
  9536. $.effects.createWrapper( el );
  9537. el.css( "overflow", "hidden" ).css( el.from );
  9538. // Adjust
  9539. if (origin) { // Calculate baseline shifts
  9540. baseline = $.effects.getBaseline( origin, original );
  9541. el.from.top = ( original.outerHeight - el.outerHeight() ) * baseline.y;
  9542. el.from.left = ( original.outerWidth - el.outerWidth() ) * baseline.x;
  9543. el.to.top = ( original.outerHeight - el.to.outerHeight ) * baseline.y;
  9544. el.to.left = ( original.outerWidth - el.to.outerWidth ) * baseline.x;
  9545. }
  9546. el.css( el.from ); // set top & left
  9547. // Animate
  9548. if ( scale === "content" || scale === "both" ) { // Scale the children
  9549. // Add margins/font-size
  9550. vProps = vProps.concat([ "marginTop", "marginBottom" ]).concat(cProps);
  9551. hProps = hProps.concat([ "marginLeft", "marginRight" ]);
  9552. props2 = props0.concat(vProps).concat(hProps);
  9553. el.find( "*[width]" ).each( function(){
  9554. var child = $( this ),
  9555. c_original = {
  9556. height: child.height(),
  9557. width: child.width(),
  9558. outerHeight: child.outerHeight(),
  9559. outerWidth: child.outerWidth()
  9560. };
  9561. if (restore) {
  9562. $.effects.save(child, props2);
  9563. }
  9564. child.from = {
  9565. height: c_original.height * factor.from.y,
  9566. width: c_original.width * factor.from.x,
  9567. outerHeight: c_original.outerHeight * factor.from.y,
  9568. outerWidth: c_original.outerWidth * factor.from.x
  9569. };
  9570. child.to = {
  9571. height: c_original.height * factor.to.y,
  9572. width: c_original.width * factor.to.x,
  9573. outerHeight: c_original.height * factor.to.y,
  9574. outerWidth: c_original.width * factor.to.x
  9575. };
  9576. // Vertical props scaling
  9577. if ( factor.from.y !== factor.to.y ) {
  9578. child.from = $.effects.setTransition( child, vProps, factor.from.y, child.from );
  9579. child.to = $.effects.setTransition( child, vProps, factor.to.y, child.to );
  9580. }
  9581. // Horizontal props scaling
  9582. if ( factor.from.x !== factor.to.x ) {
  9583. child.from = $.effects.setTransition( child, hProps, factor.from.x, child.from );
  9584. child.to = $.effects.setTransition( child, hProps, factor.to.x, child.to );
  9585. }
  9586. // Animate children
  9587. child.css( child.from );
  9588. child.animate( child.to, o.duration, o.easing, function() {
  9589. // Restore children
  9590. if ( restore ) {
  9591. $.effects.restore( child, props2 );
  9592. }
  9593. });
  9594. });
  9595. }
  9596. // Animate
  9597. el.animate( el.to, {
  9598. queue: false,
  9599. duration: o.duration,
  9600. easing: o.easing,
  9601. complete: function() {
  9602. if ( el.to.opacity === 0 ) {
  9603. el.css( "opacity", el.from.opacity );
  9604. }
  9605. if( mode === "hide" ) {
  9606. el.hide();
  9607. }
  9608. $.effects.restore( el, props );
  9609. if ( !restore ) {
  9610. // we need to calculate our new positioning based on the scaling
  9611. if ( position === "static" ) {
  9612. el.css({
  9613. position: "relative",
  9614. top: el.to.top,
  9615. left: el.to.left
  9616. });
  9617. } else {
  9618. $.each([ "top", "left" ], function( idx, pos ) {
  9619. el.css( pos, function( _, str ) {
  9620. var val = parseInt( str, 10 ),
  9621. toRef = idx ? el.to.left : el.to.top;
  9622. // if original was "auto", recalculate the new value from wrapper
  9623. if ( str === "auto" ) {
  9624. return toRef + "px";
  9625. }
  9626. return val + toRef + "px";
  9627. });
  9628. });
  9629. }
  9630. }
  9631. $.effects.removeWrapper( el );
  9632. done();
  9633. }
  9634. });
  9635. };
  9636. })(jQuery);
  9637. (function( $, undefined ) {
  9638. $.effects.effect.shake = function( o, done ) {
  9639. var el = $( this ),
  9640. props = [ "position", "top", "bottom", "left", "right", "height", "width" ],
  9641. mode = $.effects.setMode( el, o.mode || "effect" ),
  9642. direction = o.direction || "left",
  9643. distance = o.distance || 20,
  9644. times = o.times || 3,
  9645. anims = times * 2 + 1,
  9646. speed = Math.round(o.duration/anims),
  9647. ref = (direction === "up" || direction === "down") ? "top" : "left",
  9648. positiveMotion = (direction === "up" || direction === "left"),
  9649. animation = {},
  9650. animation1 = {},
  9651. animation2 = {},
  9652. i,
  9653. // we will need to re-assemble the queue to stack our animations in place
  9654. queue = el.queue(),
  9655. queuelen = queue.length;
  9656. $.effects.save( el, props );
  9657. el.show();
  9658. $.effects.createWrapper( el );
  9659. // Animation
  9660. animation[ ref ] = ( positiveMotion ? "-=" : "+=" ) + distance;
  9661. animation1[ ref ] = ( positiveMotion ? "+=" : "-=" ) + distance * 2;
  9662. animation2[ ref ] = ( positiveMotion ? "-=" : "+=" ) + distance * 2;
  9663. // Animate
  9664. el.animate( animation, speed, o.easing );
  9665. // Shakes
  9666. for ( i = 1; i < times; i++ ) {
  9667. el.animate( animation1, speed, o.easing ).animate( animation2, speed, o.easing );
  9668. }
  9669. el
  9670. .animate( animation1, speed, o.easing )
  9671. .animate( animation, speed / 2, o.easing )
  9672. .queue(function() {
  9673. if ( mode === "hide" ) {
  9674. el.hide();
  9675. }
  9676. $.effects.restore( el, props );
  9677. $.effects.removeWrapper( el );
  9678. done();
  9679. });
  9680. // inject all the animations we just queued to be first in line (after "inprogress")
  9681. if ( queuelen > 1) {
  9682. queue.splice.apply( queue,
  9683. [ 1, 0 ].concat( queue.splice( queuelen, anims + 1 ) ) );
  9684. }
  9685. el.dequeue();
  9686. };
  9687. })(jQuery);
  9688. (function( $, undefined ) {
  9689. $.effects.effect.slide = function( o, done ) {
  9690. // Create element
  9691. var el = $( this ),
  9692. props = [ "position", "top", "bottom", "left", "right", "width", "height" ],
  9693. mode = $.effects.setMode( el, o.mode || "show" ),
  9694. show = mode === "show",
  9695. direction = o.direction || "left",
  9696. ref = (direction === "up" || direction === "down") ? "top" : "left",
  9697. positiveMotion = (direction === "up" || direction === "left"),
  9698. distance,
  9699. animation = {};
  9700. // Adjust
  9701. $.effects.save( el, props );
  9702. el.show();
  9703. distance = o.distance || el[ ref === "top" ? "outerHeight" : "outerWidth" ]( true );
  9704. $.effects.createWrapper( el ).css({
  9705. overflow: "hidden"
  9706. });
  9707. if ( show ) {
  9708. el.css( ref, positiveMotion ? (isNaN(distance) ? "-" + distance : -distance) : distance );
  9709. }
  9710. // Animation
  9711. animation[ ref ] = ( show ?
  9712. ( positiveMotion ? "+=" : "-=") :
  9713. ( positiveMotion ? "-=" : "+=")) +
  9714. distance;
  9715. // Animate
  9716. el.animate( animation, {
  9717. queue: false,
  9718. duration: o.duration,
  9719. easing: o.easing,
  9720. complete: function() {
  9721. if ( mode === "hide" ) {
  9722. el.hide();
  9723. }
  9724. $.effects.restore( el, props );
  9725. $.effects.removeWrapper( el );
  9726. done();
  9727. }
  9728. });
  9729. };
  9730. })(jQuery);
  9731. (function( $, undefined ) {
  9732. $.effects.effect.transfer = function( o, done ) {
  9733. var elem = $( this ),
  9734. target = $( o.to ),
  9735. targetFixed = target.css( "position" ) === "fixed",
  9736. body = $("body"),
  9737. fixTop = targetFixed ? body.scrollTop() : 0,
  9738. fixLeft = targetFixed ? body.scrollLeft() : 0,
  9739. endPosition = target.offset(),
  9740. animation = {
  9741. top: endPosition.top - fixTop ,
  9742. left: endPosition.left - fixLeft ,
  9743. height: target.innerHeight(),
  9744. width: target.innerWidth()
  9745. },
  9746. startPosition = elem.offset(),
  9747. transfer = $( "<div class='ui-effects-transfer'></div>" )
  9748. .appendTo( document.body )
  9749. .addClass( o.className )
  9750. .css({
  9751. top: startPosition.top - fixTop ,
  9752. left: startPosition.left - fixLeft ,
  9753. height: elem.innerHeight(),
  9754. width: elem.innerWidth(),
  9755. position: targetFixed ? "fixed" : "absolute"
  9756. })
  9757. .animate( animation, o.duration, o.easing, function() {
  9758. transfer.remove();
  9759. done();
  9760. });
  9761. };
  9762. })(jQuery);
  9763. (function( $, undefined ) {
  9764. $.widget( "ui.menu", {
  9765. version: "1.10.2",
  9766. defaultElement: "<ul>",
  9767. delay: 300,
  9768. options: {
  9769. icons: {
  9770. submenu: "ui-icon-carat-1-e"
  9771. },
  9772. menus: "ul",
  9773. position: {
  9774. my: "left top",
  9775. at: "right top"
  9776. },
  9777. role: "menu",
  9778. // callbacks
  9779. blur: null,
  9780. focus: null,
  9781. select: null
  9782. },
  9783. _create: function() {
  9784. this.activeMenu = this.element;
  9785. // flag used to prevent firing of the click handler
  9786. // as the event bubbles up through nested menus
  9787. this.mouseHandled = false;
  9788. this.element
  9789. .uniqueId()
  9790. .addClass( "ui-menu ui-widget ui-widget-content ui-corner-all" )
  9791. .toggleClass( "ui-menu-icons", !!this.element.find( ".ui-icon" ).length )
  9792. .attr({
  9793. role: this.options.role,
  9794. tabIndex: 0
  9795. })
  9796. // need to catch all clicks on disabled menu
  9797. // not possible through _on
  9798. .bind( "click" + this.eventNamespace, $.proxy(function( event ) {
  9799. if ( this.options.disabled ) {
  9800. event.preventDefault();
  9801. }
  9802. }, this ));
  9803. if ( this.options.disabled ) {
  9804. this.element
  9805. .addClass( "ui-state-disabled" )
  9806. .attr( "aria-disabled", "true" );
  9807. }
  9808. this._on({
  9809. // Prevent focus from sticking to links inside menu after clicking
  9810. // them (focus should always stay on UL during navigation).
  9811. "mousedown .ui-menu-item > a": function( event ) {
  9812. event.preventDefault();
  9813. },
  9814. "click .ui-state-disabled > a": function( event ) {
  9815. event.preventDefault();
  9816. },
  9817. "click .ui-menu-item:has(a)": function( event ) {
  9818. var target = $( event.target ).closest( ".ui-menu-item" );
  9819. if ( !this.mouseHandled && target.not( ".ui-state-disabled" ).length ) {
  9820. this.mouseHandled = true;
  9821. this.select( event );
  9822. // Open submenu on click
  9823. if ( target.has( ".ui-menu" ).length ) {
  9824. this.expand( event );
  9825. } else if ( !this.element.is( ":focus" ) ) {
  9826. // Redirect focus to the menu
  9827. this.element.trigger( "focus", [ true ] );
  9828. // If the active item is on the top level, let it stay active.
  9829. // Otherwise, blur the active item since it is no longer visible.
  9830. if ( this.active && this.active.parents( ".ui-menu" ).length === 1 ) {
  9831. clearTimeout( this.timer );
  9832. }
  9833. }
  9834. }
  9835. },
  9836. "mouseenter .ui-menu-item": function( event ) {
  9837. var target = $( event.currentTarget );
  9838. // Remove ui-state-active class from siblings of the newly focused menu item
  9839. // to avoid a jump caused by adjacent elements both having a class with a border
  9840. target.siblings().children( ".ui-state-active" ).removeClass( "ui-state-active" );
  9841. this.focus( event, target );
  9842. },
  9843. mouseleave: "collapseAll",
  9844. "mouseleave .ui-menu": "collapseAll",
  9845. focus: function( event, keepActiveItem ) {
  9846. // If there's already an active item, keep it active
  9847. // If not, activate the first item
  9848. var item = this.active || this.element.children( ".ui-menu-item" ).eq( 0 );
  9849. if ( !keepActiveItem ) {
  9850. this.focus( event, item );
  9851. }
  9852. },
  9853. blur: function( event ) {
  9854. this._delay(function() {
  9855. if ( !$.contains( this.element[0], this.document[0].activeElement ) ) {
  9856. this.collapseAll( event );
  9857. }
  9858. });
  9859. },
  9860. keydown: "_keydown"
  9861. });
  9862. this.refresh();
  9863. // Clicks outside of a menu collapse any open menus
  9864. this._on( this.document, {
  9865. click: function( event ) {
  9866. if ( !$( event.target ).closest( ".ui-menu" ).length ) {
  9867. this.collapseAll( event );
  9868. }
  9869. // Reset the mouseHandled flag
  9870. this.mouseHandled = false;
  9871. }
  9872. });
  9873. },
  9874. _destroy: function() {
  9875. // Destroy (sub)menus
  9876. this.element
  9877. .removeAttr( "aria-activedescendant" )
  9878. .find( ".ui-menu" ).addBack()
  9879. .removeClass( "ui-menu ui-widget ui-widget-content ui-corner-all ui-menu-icons" )
  9880. .removeAttr( "role" )
  9881. .removeAttr( "tabIndex" )
  9882. .removeAttr( "aria-labelledby" )
  9883. .removeAttr( "aria-expanded" )
  9884. .removeAttr( "aria-hidden" )
  9885. .removeAttr( "aria-disabled" )
  9886. .removeUniqueId()
  9887. .show();
  9888. // Destroy menu items
  9889. this.element.find( ".ui-menu-item" )
  9890. .removeClass( "ui-menu-item" )
  9891. .removeAttr( "role" )
  9892. .removeAttr( "aria-disabled" )
  9893. .children( "a" )
  9894. .removeUniqueId()
  9895. .removeClass( "ui-corner-all ui-state-hover" )
  9896. .removeAttr( "tabIndex" )
  9897. .removeAttr( "role" )
  9898. .removeAttr( "aria-haspopup" )
  9899. .children().each( function() {
  9900. var elem = $( this );
  9901. if ( elem.data( "ui-menu-submenu-carat" ) ) {
  9902. elem.remove();
  9903. }
  9904. });
  9905. // Destroy menu dividers
  9906. this.element.find( ".ui-menu-divider" ).removeClass( "ui-menu-divider ui-widget-content" );
  9907. },
  9908. _keydown: function( event ) {
  9909. /*jshint maxcomplexity:20*/
  9910. var match, prev, character, skip, regex,
  9911. preventDefault = true;
  9912. function escape( value ) {
  9913. return value.replace( /[\-\[\]{}()*+?.,\\\^$|#\s]/g, "\\$&" );
  9914. }
  9915. switch ( event.keyCode ) {
  9916. case $.ui.keyCode.PAGE_UP:
  9917. this.previousPage( event );
  9918. break;
  9919. case $.ui.keyCode.PAGE_DOWN:
  9920. this.nextPage( event );
  9921. break;
  9922. case $.ui.keyCode.HOME:
  9923. this._move( "first", "first", event );
  9924. break;
  9925. case $.ui.keyCode.END:
  9926. this._move( "last", "last", event );
  9927. break;
  9928. case $.ui.keyCode.UP:
  9929. this.previous( event );
  9930. break;
  9931. case $.ui.keyCode.DOWN:
  9932. this.next( event );
  9933. break;
  9934. case $.ui.keyCode.LEFT:
  9935. this.collapse( event );
  9936. break;
  9937. case $.ui.keyCode.RIGHT:
  9938. if ( this.active && !this.active.is( ".ui-state-disabled" ) ) {
  9939. this.expand( event );
  9940. }
  9941. break;
  9942. case $.ui.keyCode.ENTER:
  9943. case $.ui.keyCode.SPACE:
  9944. this._activate( event );
  9945. break;
  9946. case $.ui.keyCode.ESCAPE:
  9947. this.collapse( event );
  9948. break;
  9949. default:
  9950. preventDefault = false;
  9951. prev = this.previousFilter || "";
  9952. character = String.fromCharCode( event.keyCode );
  9953. skip = false;
  9954. clearTimeout( this.filterTimer );
  9955. if ( character === prev ) {
  9956. skip = true;
  9957. } else {
  9958. character = prev + character;
  9959. }
  9960. regex = new RegExp( "^" + escape( character ), "i" );
  9961. match = this.activeMenu.children( ".ui-menu-item" ).filter(function() {
  9962. return regex.test( $( this ).children( "a" ).text() );
  9963. });
  9964. match = skip && match.index( this.active.next() ) !== -1 ?
  9965. this.active.nextAll( ".ui-menu-item" ) :
  9966. match;
  9967. // If no matches on the current filter, reset to the last character pressed
  9968. // to move down the menu to the first item that starts with that character
  9969. if ( !match.length ) {
  9970. character = String.fromCharCode( event.keyCode );
  9971. regex = new RegExp( "^" + escape( character ), "i" );
  9972. match = this.activeMenu.children( ".ui-menu-item" ).filter(function() {
  9973. return regex.test( $( this ).children( "a" ).text() );
  9974. });
  9975. }
  9976. if ( match.length ) {
  9977. this.focus( event, match );
  9978. if ( match.length > 1 ) {
  9979. this.previousFilter = character;
  9980. this.filterTimer = this._delay(function() {
  9981. delete this.previousFilter;
  9982. }, 1000 );
  9983. } else {
  9984. delete this.previousFilter;
  9985. }
  9986. } else {
  9987. delete this.previousFilter;
  9988. }
  9989. }
  9990. if ( preventDefault ) {
  9991. event.preventDefault();
  9992. }
  9993. },
  9994. _activate: function( event ) {
  9995. if ( !this.active.is( ".ui-state-disabled" ) ) {
  9996. if ( this.active.children( "a[aria-haspopup='true']" ).length ) {
  9997. this.expand( event );
  9998. } else {
  9999. this.select( event );
  10000. }
  10001. }
  10002. },
  10003. refresh: function() {
  10004. var menus,
  10005. icon = this.options.icons.submenu,
  10006. submenus = this.element.find( this.options.menus );
  10007. // Initialize nested menus
  10008. submenus.filter( ":not(.ui-menu)" )
  10009. .addClass( "ui-menu ui-widget ui-widget-content ui-corner-all" )
  10010. .hide()
  10011. .attr({
  10012. role: this.options.role,
  10013. "aria-hidden": "true",
  10014. "aria-expanded": "false"
  10015. })
  10016. .each(function() {
  10017. var menu = $( this ),
  10018. item = menu.prev( "a" ),
  10019. submenuCarat = $( "<span>" )
  10020. .addClass( "ui-menu-icon ui-icon " + icon )
  10021. .data( "ui-menu-submenu-carat", true );
  10022. item
  10023. .attr( "aria-haspopup", "true" )
  10024. .prepend( submenuCarat );
  10025. menu.attr( "aria-labelledby", item.attr( "id" ) );
  10026. });
  10027. menus = submenus.add( this.element );
  10028. // Don't refresh list items that are already adapted
  10029. menus.children( ":not(.ui-menu-item):has(a)" )
  10030. .addClass( "ui-menu-item" )
  10031. .attr( "role", "presentation" )
  10032. .children( "a" )
  10033. .uniqueId()
  10034. .addClass( "ui-corner-all" )
  10035. .attr({
  10036. tabIndex: -1,
  10037. role: this._itemRole()
  10038. });
  10039. // Initialize unlinked menu-items containing spaces and/or dashes only as dividers
  10040. menus.children( ":not(.ui-menu-item)" ).each(function() {
  10041. var item = $( this );
  10042. // hyphen, em dash, en dash
  10043. if ( !/[^\-\u2014\u2013\s]/.test( item.text() ) ) {
  10044. item.addClass( "ui-widget-content ui-menu-divider" );
  10045. }
  10046. });
  10047. // Add aria-disabled attribute to any disabled menu item
  10048. menus.children( ".ui-state-disabled" ).attr( "aria-disabled", "true" );
  10049. // If the active item has been removed, blur the menu
  10050. if ( this.active && !$.contains( this.element[ 0 ], this.active[ 0 ] ) ) {
  10051. this.blur();
  10052. }
  10053. },
  10054. _itemRole: function() {
  10055. return {
  10056. menu: "menuitem",
  10057. listbox: "option"
  10058. }[ this.options.role ];
  10059. },
  10060. _setOption: function( key, value ) {
  10061. if ( key === "icons" ) {
  10062. this.element.find( ".ui-menu-icon" )
  10063. .removeClass( this.options.icons.submenu )
  10064. .addClass( value.submenu );
  10065. }
  10066. this._super( key, value );
  10067. },
  10068. focus: function( event, item ) {
  10069. var nested, focused;
  10070. this.blur( event, event && event.type === "focus" );
  10071. this._scrollIntoView( item );
  10072. this.active = item.first();
  10073. focused = this.active.children( "a" ).addClass( "ui-state-focus" );
  10074. // Only update aria-activedescendant if there's a role
  10075. // otherwise we assume focus is managed elsewhere
  10076. if ( this.options.role ) {
  10077. this.element.attr( "aria-activedescendant", focused.attr( "id" ) );
  10078. }
  10079. // Highlight active parent menu item, if any
  10080. this.active
  10081. .parent()
  10082. .closest( ".ui-menu-item" )
  10083. .children( "a:first" )
  10084. .addClass( "ui-state-active" );
  10085. if ( event && event.type === "keydown" ) {
  10086. this._close();
  10087. } else {
  10088. this.timer = this._delay(function() {
  10089. this._close();
  10090. }, this.delay );
  10091. }
  10092. nested = item.children( ".ui-menu" );
  10093. if ( nested.length && ( /^mouse/.test( event.type ) ) ) {
  10094. this._startOpening(nested);
  10095. }
  10096. this.activeMenu = item.parent();
  10097. this._trigger( "focus", event, { item: item } );
  10098. },
  10099. _scrollIntoView: function( item ) {
  10100. var borderTop, paddingTop, offset, scroll, elementHeight, itemHeight;
  10101. if ( this._hasScroll() ) {
  10102. borderTop = parseFloat( $.css( this.activeMenu[0], "borderTopWidth" ) ) || 0;
  10103. paddingTop = parseFloat( $.css( this.activeMenu[0], "paddingTop" ) ) || 0;
  10104. offset = item.offset().top - this.activeMenu.offset().top - borderTop - paddingTop;
  10105. scroll = this.activeMenu.scrollTop();
  10106. elementHeight = this.activeMenu.height();
  10107. itemHeight = item.height();
  10108. if ( offset < 0 ) {
  10109. this.activeMenu.scrollTop( scroll + offset );
  10110. } else if ( offset + itemHeight > elementHeight ) {
  10111. this.activeMenu.scrollTop( scroll + offset - elementHeight + itemHeight );
  10112. }
  10113. }
  10114. },
  10115. blur: function( event, fromFocus ) {
  10116. if ( !fromFocus ) {
  10117. clearTimeout( this.timer );
  10118. }
  10119. if ( !this.active ) {
  10120. return;
  10121. }
  10122. this.active.children( "a" ).removeClass( "ui-state-focus" );
  10123. this.active = null;
  10124. this._trigger( "blur", event, { item: this.active } );
  10125. },
  10126. _startOpening: function( submenu ) {
  10127. clearTimeout( this.timer );
  10128. // Don't open if already open fixes a Firefox bug that caused a .5 pixel
  10129. // shift in the submenu position when mousing over the carat icon
  10130. if ( submenu.attr( "aria-hidden" ) !== "true" ) {
  10131. return;
  10132. }
  10133. this.timer = this._delay(function() {
  10134. this._close();
  10135. this._open( submenu );
  10136. }, this.delay );
  10137. },
  10138. _open: function( submenu ) {
  10139. var position = $.extend({
  10140. of: this.active
  10141. }, this.options.position );
  10142. clearTimeout( this.timer );
  10143. this.element.find( ".ui-menu" ).not( submenu.parents( ".ui-menu" ) )
  10144. .hide()
  10145. .attr( "aria-hidden", "true" );
  10146. submenu
  10147. .show()
  10148. .removeAttr( "aria-hidden" )
  10149. .attr( "aria-expanded", "true" )
  10150. .position( position );
  10151. },
  10152. collapseAll: function( event, all ) {
  10153. clearTimeout( this.timer );
  10154. this.timer = this._delay(function() {
  10155. // If we were passed an event, look for the submenu that contains the event
  10156. var currentMenu = all ? this.element :
  10157. $( event && event.target ).closest( this.element.find( ".ui-menu" ) );
  10158. // If we found no valid submenu ancestor, use the main menu to close all sub menus anyway
  10159. if ( !currentMenu.length ) {
  10160. currentMenu = this.element;
  10161. }
  10162. this._close( currentMenu );
  10163. this.blur( event );
  10164. this.activeMenu = currentMenu;
  10165. }, this.delay );
  10166. },
  10167. // With no arguments, closes the currently active menu - if nothing is active
  10168. // it closes all menus. If passed an argument, it will search for menus BELOW
  10169. _close: function( startMenu ) {
  10170. if ( !startMenu ) {
  10171. startMenu = this.active ? this.active.parent() : this.element;
  10172. }
  10173. startMenu
  10174. .find( ".ui-menu" )
  10175. .hide()
  10176. .attr( "aria-hidden", "true" )
  10177. .attr( "aria-expanded", "false" )
  10178. .end()
  10179. .find( "a.ui-state-active" )
  10180. .removeClass( "ui-state-active" );
  10181. },
  10182. collapse: function( event ) {
  10183. var newItem = this.active &&
  10184. this.active.parent().closest( ".ui-menu-item", this.element );
  10185. if ( newItem && newItem.length ) {
  10186. this._close();
  10187. this.focus( event, newItem );
  10188. }
  10189. },
  10190. expand: function( event ) {
  10191. var newItem = this.active &&
  10192. this.active
  10193. .children( ".ui-menu " )
  10194. .children( ".ui-menu-item" )
  10195. .first();
  10196. if ( newItem && newItem.length ) {
  10197. this._open( newItem.parent() );
  10198. // Delay so Firefox will not hide activedescendant change in expanding submenu from AT
  10199. this._delay(function() {
  10200. this.focus( event, newItem );
  10201. });
  10202. }
  10203. },
  10204. next: function( event ) {
  10205. this._move( "next", "first", event );
  10206. },
  10207. previous: function( event ) {
  10208. this._move( "prev", "last", event );
  10209. },
  10210. isFirstItem: function() {
  10211. return this.active && !this.active.prevAll( ".ui-menu-item" ).length;
  10212. },
  10213. isLastItem: function() {
  10214. return this.active && !this.active.nextAll( ".ui-menu-item" ).length;
  10215. },
  10216. _move: function( direction, filter, event ) {
  10217. var next;
  10218. if ( this.active ) {
  10219. if ( direction === "first" || direction === "last" ) {
  10220. next = this.active
  10221. [ direction === "first" ? "prevAll" : "nextAll" ]( ".ui-menu-item" )
  10222. .eq( -1 );
  10223. } else {
  10224. next = this.active
  10225. [ direction + "All" ]( ".ui-menu-item" )
  10226. .eq( 0 );
  10227. }
  10228. }
  10229. if ( !next || !next.length || !this.active ) {
  10230. next = this.activeMenu.children( ".ui-menu-item" )[ filter ]();
  10231. }
  10232. this.focus( event, next );
  10233. },
  10234. nextPage: function( event ) {
  10235. var item, base, height;
  10236. if ( !this.active ) {
  10237. this.next( event );
  10238. return;
  10239. }
  10240. if ( this.isLastItem() ) {
  10241. return;
  10242. }
  10243. if ( this._hasScroll() ) {
  10244. base = this.active.offset().top;
  10245. height = this.element.height();
  10246. this.active.nextAll( ".ui-menu-item" ).each(function() {
  10247. item = $( this );
  10248. return item.offset().top - base - height < 0;
  10249. });
  10250. this.focus( event, item );
  10251. } else {
  10252. this.focus( event, this.activeMenu.children( ".ui-menu-item" )
  10253. [ !this.active ? "first" : "last" ]() );
  10254. }
  10255. },
  10256. previousPage: function( event ) {
  10257. var item, base, height;
  10258. if ( !this.active ) {
  10259. this.next( event );
  10260. return;
  10261. }
  10262. if ( this.isFirstItem() ) {
  10263. return;
  10264. }
  10265. if ( this._hasScroll() ) {
  10266. base = this.active.offset().top;
  10267. height = this.element.height();
  10268. this.active.prevAll( ".ui-menu-item" ).each(function() {
  10269. item = $( this );
  10270. return item.offset().top - base + height > 0;
  10271. });
  10272. this.focus( event, item );
  10273. } else {
  10274. this.focus( event, this.activeMenu.children( ".ui-menu-item" ).first() );
  10275. }
  10276. },
  10277. _hasScroll: function() {
  10278. return this.element.outerHeight() < this.element.prop( "scrollHeight" );
  10279. },
  10280. select: function( event ) {
  10281. // TODO: It should never be possible to not have an active item at this
  10282. // point, but the tests don't trigger mouseenter before click.
  10283. this.active = this.active || $( event.target ).closest( ".ui-menu-item" );
  10284. var ui = { item: this.active };
  10285. if ( !this.active.has( ".ui-menu" ).length ) {
  10286. this.collapseAll( event, true );
  10287. }
  10288. this._trigger( "select", event, ui );
  10289. }
  10290. });
  10291. }( jQuery ));
  10292. (function( $, undefined ) {
  10293. $.ui = $.ui || {};
  10294. var cachedScrollbarWidth,
  10295. max = Math.max,
  10296. abs = Math.abs,
  10297. round = Math.round,
  10298. rhorizontal = /left|center|right/,
  10299. rvertical = /top|center|bottom/,
  10300. roffset = /[\+\-]\d+(\.[\d]+)?%?/,
  10301. rposition = /^\w+/,
  10302. rpercent = /%$/,
  10303. _position = $.fn.position;
  10304. function getOffsets( offsets, width, height ) {
  10305. return [
  10306. parseFloat( offsets[ 0 ] ) * ( rpercent.test( offsets[ 0 ] ) ? width / 100 : 1 ),
  10307. parseFloat( offsets[ 1 ] ) * ( rpercent.test( offsets[ 1 ] ) ? height / 100 : 1 )
  10308. ];
  10309. }
  10310. function parseCss( element, property ) {
  10311. return parseInt( $.css( element, property ), 10 ) || 0;
  10312. }
  10313. function getDimensions( elem ) {
  10314. var raw = elem[0];
  10315. if ( raw.nodeType === 9 ) {
  10316. return {
  10317. width: elem.width(),
  10318. height: elem.height(),
  10319. offset: { top: 0, left: 0 }
  10320. };
  10321. }
  10322. if ( $.isWindow( raw ) ) {
  10323. return {
  10324. width: elem.width(),
  10325. height: elem.height(),
  10326. offset: { top: elem.scrollTop(), left: elem.scrollLeft() }
  10327. };
  10328. }
  10329. if ( raw.preventDefault ) {
  10330. return {
  10331. width: 0,
  10332. height: 0,
  10333. offset: { top: raw.pageY, left: raw.pageX }
  10334. };
  10335. }
  10336. return {
  10337. width: elem.outerWidth(),
  10338. height: elem.outerHeight(),
  10339. offset: elem.offset()
  10340. };
  10341. }
  10342. $.position = {
  10343. scrollbarWidth: function() {
  10344. if ( cachedScrollbarWidth !== undefined ) {
  10345. return cachedScrollbarWidth;
  10346. }
  10347. var w1, w2,
  10348. div = $( "<div style='display:block;width:50px;height:50px;overflow:hidden;'><div style='height:100px;width:auto;'></div></div>" ),
  10349. innerDiv = div.children()[0];
  10350. $( "body" ).append( div );
  10351. w1 = innerDiv.offsetWidth;
  10352. div.css( "overflow", "scroll" );
  10353. w2 = innerDiv.offsetWidth;
  10354. if ( w1 === w2 ) {
  10355. w2 = div[0].clientWidth;
  10356. }
  10357. div.remove();
  10358. return (cachedScrollbarWidth = w1 - w2);
  10359. },
  10360. getScrollInfo: function( within ) {
  10361. var overflowX = within.isWindow ? "" : within.element.css( "overflow-x" ),
  10362. overflowY = within.isWindow ? "" : within.element.css( "overflow-y" ),
  10363. hasOverflowX = overflowX === "scroll" ||
  10364. ( overflowX === "auto" && within.width < within.element[0].scrollWidth ),
  10365. hasOverflowY = overflowY === "scroll" ||
  10366. ( overflowY === "auto" && within.height < within.element[0].scrollHeight );
  10367. return {
  10368. width: hasOverflowY ? $.position.scrollbarWidth() : 0,
  10369. height: hasOverflowX ? $.position.scrollbarWidth() : 0
  10370. };
  10371. },
  10372. getWithinInfo: function( element ) {
  10373. var withinElement = $( element || window ),
  10374. isWindow = $.isWindow( withinElement[0] );
  10375. return {
  10376. element: withinElement,
  10377. isWindow: isWindow,
  10378. offset: withinElement.offset() || { left: 0, top: 0 },
  10379. scrollLeft: withinElement.scrollLeft(),
  10380. scrollTop: withinElement.scrollTop(),
  10381. width: isWindow ? withinElement.width() : withinElement.outerWidth(),
  10382. height: isWindow ? withinElement.height() : withinElement.outerHeight()
  10383. };
  10384. }
  10385. };
  10386. $.fn.position = function( options ) {
  10387. if ( !options || !options.of ) {
  10388. return _position.apply( this, arguments );
  10389. }
  10390. // make a copy, we don't want to modify arguments
  10391. options = $.extend( {}, options );
  10392. var atOffset, targetWidth, targetHeight, targetOffset, basePosition, dimensions,
  10393. target = $( options.of ),
  10394. within = $.position.getWithinInfo( options.within ),
  10395. scrollInfo = $.position.getScrollInfo( within ),
  10396. collision = ( options.collision || "flip" ).split( " " ),
  10397. offsets = {};
  10398. dimensions = getDimensions( target );
  10399. if ( target[0].preventDefault ) {
  10400. // force left top to allow flipping
  10401. options.at = "left top";
  10402. }
  10403. targetWidth = dimensions.width;
  10404. targetHeight = dimensions.height;
  10405. targetOffset = dimensions.offset;
  10406. // clone to reuse original targetOffset later
  10407. basePosition = $.extend( {}, targetOffset );
  10408. // force my and at to have valid horizontal and vertical positions
  10409. // if a value is missing or invalid, it will be converted to center
  10410. $.each( [ "my", "at" ], function() {
  10411. var pos = ( options[ this ] || "" ).split( " " ),
  10412. horizontalOffset,
  10413. verticalOffset;
  10414. if ( pos.length === 1) {
  10415. pos = rhorizontal.test( pos[ 0 ] ) ?
  10416. pos.concat( [ "center" ] ) :
  10417. rvertical.test( pos[ 0 ] ) ?
  10418. [ "center" ].concat( pos ) :
  10419. [ "center", "center" ];
  10420. }
  10421. pos[ 0 ] = rhorizontal.test( pos[ 0 ] ) ? pos[ 0 ] : "center";
  10422. pos[ 1 ] = rvertical.test( pos[ 1 ] ) ? pos[ 1 ] : "center";
  10423. // calculate offsets
  10424. horizontalOffset = roffset.exec( pos[ 0 ] );
  10425. verticalOffset = roffset.exec( pos[ 1 ] );
  10426. offsets[ this ] = [
  10427. horizontalOffset ? horizontalOffset[ 0 ] : 0,
  10428. verticalOffset ? verticalOffset[ 0 ] : 0
  10429. ];
  10430. // reduce to just the positions without the offsets
  10431. options[ this ] = [
  10432. rposition.exec( pos[ 0 ] )[ 0 ],
  10433. rposition.exec( pos[ 1 ] )[ 0 ]
  10434. ];
  10435. });
  10436. // normalize collision option
  10437. if ( collision.length === 1 ) {
  10438. collision[ 1 ] = collision[ 0 ];
  10439. }
  10440. if ( options.at[ 0 ] === "right" ) {
  10441. basePosition.left += targetWidth;
  10442. } else if ( options.at[ 0 ] === "center" ) {
  10443. basePosition.left += targetWidth / 2;
  10444. }
  10445. if ( options.at[ 1 ] === "bottom" ) {
  10446. basePosition.top += targetHeight;
  10447. } else if ( options.at[ 1 ] === "center" ) {
  10448. basePosition.top += targetHeight / 2;
  10449. }
  10450. atOffset = getOffsets( offsets.at, targetWidth, targetHeight );
  10451. basePosition.left += atOffset[ 0 ];
  10452. basePosition.top += atOffset[ 1 ];
  10453. return this.each(function() {
  10454. var collisionPosition, using,
  10455. elem = $( this ),
  10456. elemWidth = elem.outerWidth(),
  10457. elemHeight = elem.outerHeight(),
  10458. marginLeft = parseCss( this, "marginLeft" ),
  10459. marginTop = parseCss( this, "marginTop" ),
  10460. collisionWidth = elemWidth + marginLeft + parseCss( this, "marginRight" ) + scrollInfo.width,
  10461. collisionHeight = elemHeight + marginTop + parseCss( this, "marginBottom" ) + scrollInfo.height,
  10462. position = $.extend( {}, basePosition ),
  10463. myOffset = getOffsets( offsets.my, elem.outerWidth(), elem.outerHeight() );
  10464. if ( options.my[ 0 ] === "right" ) {
  10465. position.left -= elemWidth;
  10466. } else if ( options.my[ 0 ] === "center" ) {
  10467. position.left -= elemWidth / 2;
  10468. }
  10469. if ( options.my[ 1 ] === "bottom" ) {
  10470. position.top -= elemHeight;
  10471. } else if ( options.my[ 1 ] === "center" ) {
  10472. position.top -= elemHeight / 2;
  10473. }
  10474. position.left += myOffset[ 0 ];
  10475. position.top += myOffset[ 1 ];
  10476. // if the browser doesn't support fractions, then round for consistent results
  10477. if ( !$.support.offsetFractions ) {
  10478. position.left = round( position.left );
  10479. position.top = round( position.top );
  10480. }
  10481. collisionPosition = {
  10482. marginLeft: marginLeft,
  10483. marginTop: marginTop
  10484. };
  10485. $.each( [ "left", "top" ], function( i, dir ) {
  10486. if ( $.ui.position[ collision[ i ] ] ) {
  10487. $.ui.position[ collision[ i ] ][ dir ]( position, {
  10488. targetWidth: targetWidth,
  10489. targetHeight: targetHeight,
  10490. elemWidth: elemWidth,
  10491. elemHeight: elemHeight,
  10492. collisionPosition: collisionPosition,
  10493. collisionWidth: collisionWidth,
  10494. collisionHeight: collisionHeight,
  10495. offset: [ atOffset[ 0 ] + myOffset[ 0 ], atOffset [ 1 ] + myOffset[ 1 ] ],
  10496. my: options.my,
  10497. at: options.at,
  10498. within: within,
  10499. elem : elem
  10500. });
  10501. }
  10502. });
  10503. if ( options.using ) {
  10504. // adds feedback as second argument to using callback, if present
  10505. using = function( props ) {
  10506. var left = targetOffset.left - position.left,
  10507. right = left + targetWidth - elemWidth,
  10508. top = targetOffset.top - position.top,
  10509. bottom = top + targetHeight - elemHeight,
  10510. feedback = {
  10511. target: {
  10512. element: target,
  10513. left: targetOffset.left,
  10514. top: targetOffset.top,
  10515. width: targetWidth,
  10516. height: targetHeight
  10517. },
  10518. element: {
  10519. element: elem,
  10520. left: position.left,
  10521. top: position.top,
  10522. width: elemWidth,
  10523. height: elemHeight
  10524. },
  10525. horizontal: right < 0 ? "left" : left > 0 ? "right" : "center",
  10526. vertical: bottom < 0 ? "top" : top > 0 ? "bottom" : "middle"
  10527. };
  10528. if ( targetWidth < elemWidth && abs( left + right ) < targetWidth ) {
  10529. feedback.horizontal = "center";
  10530. }
  10531. if ( targetHeight < elemHeight && abs( top + bottom ) < targetHeight ) {
  10532. feedback.vertical = "middle";
  10533. }
  10534. if ( max( abs( left ), abs( right ) ) > max( abs( top ), abs( bottom ) ) ) {
  10535. feedback.important = "horizontal";
  10536. } else {
  10537. feedback.important = "vertical";
  10538. }
  10539. options.using.call( this, props, feedback );
  10540. };
  10541. }
  10542. elem.offset( $.extend( position, { using: using } ) );
  10543. });
  10544. };
  10545. $.ui.position = {
  10546. fit: {
  10547. left: function( position, data ) {
  10548. var within = data.within,
  10549. withinOffset = within.isWindow ? within.scrollLeft : within.offset.left,
  10550. outerWidth = within.width,
  10551. collisionPosLeft = position.left - data.collisionPosition.marginLeft,
  10552. overLeft = withinOffset - collisionPosLeft,
  10553. overRight = collisionPosLeft + data.collisionWidth - outerWidth - withinOffset,
  10554. newOverRight;
  10555. // element is wider than within
  10556. if ( data.collisionWidth > outerWidth ) {
  10557. // element is initially over the left side of within
  10558. if ( overLeft > 0 && overRight <= 0 ) {
  10559. newOverRight = position.left + overLeft + data.collisionWidth - outerWidth - withinOffset;
  10560. position.left += overLeft - newOverRight;
  10561. // element is initially over right side of within
  10562. } else if ( overRight > 0 && overLeft <= 0 ) {
  10563. position.left = withinOffset;
  10564. // element is initially over both left and right sides of within
  10565. } else {
  10566. if ( overLeft > overRight ) {
  10567. position.left = withinOffset + outerWidth - data.collisionWidth;
  10568. } else {
  10569. position.left = withinOffset;
  10570. }
  10571. }
  10572. // too far left -> align with left edge
  10573. } else if ( overLeft > 0 ) {
  10574. position.left += overLeft;
  10575. // too far right -> align with right edge
  10576. } else if ( overRight > 0 ) {
  10577. position.left -= overRight;
  10578. // adjust based on position and margin
  10579. } else {
  10580. position.left = max( position.left - collisionPosLeft, position.left );
  10581. }
  10582. },
  10583. top: function( position, data ) {
  10584. var within = data.within,
  10585. withinOffset = within.isWindow ? within.scrollTop : within.offset.top,
  10586. outerHeight = data.within.height,
  10587. collisionPosTop = position.top - data.collisionPosition.marginTop,
  10588. overTop = withinOffset - collisionPosTop,
  10589. overBottom = collisionPosTop + data.collisionHeight - outerHeight - withinOffset,
  10590. newOverBottom;
  10591. // element is taller than within
  10592. if ( data.collisionHeight > outerHeight ) {
  10593. // element is initially over the top of within
  10594. if ( overTop > 0 && overBottom <= 0 ) {
  10595. newOverBottom = position.top + overTop + data.collisionHeight - outerHeight - withinOffset;
  10596. position.top += overTop - newOverBottom;
  10597. // element is initially over bottom of within
  10598. } else if ( overBottom > 0 && overTop <= 0 ) {
  10599. position.top = withinOffset;
  10600. // element is initially over both top and bottom of within
  10601. } else {
  10602. if ( overTop > overBottom ) {
  10603. position.top = withinOffset + outerHeight - data.collisionHeight;
  10604. } else {
  10605. position.top = withinOffset;
  10606. }
  10607. }
  10608. // too far up -> align with top
  10609. } else if ( overTop > 0 ) {
  10610. position.top += overTop;
  10611. // too far down -> align with bottom edge
  10612. } else if ( overBottom > 0 ) {
  10613. position.top -= overBottom;
  10614. // adjust based on position and margin
  10615. } else {
  10616. position.top = max( position.top - collisionPosTop, position.top );
  10617. }
  10618. }
  10619. },
  10620. flip: {
  10621. left: function( position, data ) {
  10622. var within = data.within,
  10623. withinOffset = within.offset.left + within.scrollLeft,
  10624. outerWidth = within.width,
  10625. offsetLeft = within.isWindow ? within.scrollLeft : within.offset.left,
  10626. collisionPosLeft = position.left - data.collisionPosition.marginLeft,
  10627. overLeft = collisionPosLeft - offsetLeft,
  10628. overRight = collisionPosLeft + data.collisionWidth - outerWidth - offsetLeft,
  10629. myOffset = data.my[ 0 ] === "left" ?
  10630. -data.elemWidth :
  10631. data.my[ 0 ] === "right" ?
  10632. data.elemWidth :
  10633. 0,
  10634. atOffset = data.at[ 0 ] === "left" ?
  10635. data.targetWidth :
  10636. data.at[ 0 ] === "right" ?
  10637. -data.targetWidth :
  10638. 0,
  10639. offset = -2 * data.offset[ 0 ],
  10640. newOverRight,
  10641. newOverLeft;
  10642. if ( overLeft < 0 ) {
  10643. newOverRight = position.left + myOffset + atOffset + offset + data.collisionWidth - outerWidth - withinOffset;
  10644. if ( newOverRight < 0 || newOverRight < abs( overLeft ) ) {
  10645. position.left += myOffset + atOffset + offset;
  10646. }
  10647. }
  10648. else if ( overRight > 0 ) {
  10649. newOverLeft = position.left - data.collisionPosition.marginLeft + myOffset + atOffset + offset - offsetLeft;
  10650. if ( newOverLeft > 0 || abs( newOverLeft ) < overRight ) {
  10651. position.left += myOffset + atOffset + offset;
  10652. }
  10653. }
  10654. },
  10655. top: function( position, data ) {
  10656. var within = data.within,
  10657. withinOffset = within.offset.top + within.scrollTop,
  10658. outerHeight = within.height,
  10659. offsetTop = within.isWindow ? within.scrollTop : within.offset.top,
  10660. collisionPosTop = position.top - data.collisionPosition.marginTop,
  10661. overTop = collisionPosTop - offsetTop,
  10662. overBottom = collisionPosTop + data.collisionHeight - outerHeight - offsetTop,
  10663. top = data.my[ 1 ] === "top",
  10664. myOffset = top ?
  10665. -data.elemHeight :
  10666. data.my[ 1 ] === "bottom" ?
  10667. data.elemHeight :
  10668. 0,
  10669. atOffset = data.at[ 1 ] === "top" ?
  10670. data.targetHeight :
  10671. data.at[ 1 ] === "bottom" ?
  10672. -data.targetHeight :
  10673. 0,
  10674. offset = -2 * data.offset[ 1 ],
  10675. newOverTop,
  10676. newOverBottom;
  10677. if ( overTop < 0 ) {
  10678. newOverBottom = position.top + myOffset + atOffset + offset + data.collisionHeight - outerHeight - withinOffset;
  10679. if ( ( position.top + myOffset + atOffset + offset) > overTop && ( newOverBottom < 0 || newOverBottom < abs( overTop ) ) ) {
  10680. position.top += myOffset + atOffset + offset;
  10681. }
  10682. }
  10683. else if ( overBottom > 0 ) {
  10684. newOverTop = position.top - data.collisionPosition.marginTop + myOffset + atOffset + offset - offsetTop;
  10685. if ( ( position.top + myOffset + atOffset + offset) > overBottom && ( newOverTop > 0 || abs( newOverTop ) < overBottom ) ) {
  10686. position.top += myOffset + atOffset + offset;
  10687. }
  10688. }
  10689. }
  10690. },
  10691. flipfit: {
  10692. left: function() {
  10693. $.ui.position.flip.left.apply( this, arguments );
  10694. $.ui.position.fit.left.apply( this, arguments );
  10695. },
  10696. top: function() {
  10697. $.ui.position.flip.top.apply( this, arguments );
  10698. $.ui.position.fit.top.apply( this, arguments );
  10699. }
  10700. }
  10701. };
  10702. // fraction support test
  10703. (function () {
  10704. var testElement, testElementParent, testElementStyle, offsetLeft, i,
  10705. body = document.getElementsByTagName( "body" )[ 0 ],
  10706. div = document.createElement( "div" );
  10707. //Create a "fake body" for testing based on method used in jQuery.support
  10708. testElement = document.createElement( body ? "div" : "body" );
  10709. testElementStyle = {
  10710. visibility: "hidden",
  10711. width: 0,
  10712. height: 0,
  10713. border: 0,
  10714. margin: 0,
  10715. background: "none"
  10716. };
  10717. if ( body ) {
  10718. $.extend( testElementStyle, {
  10719. position: "absolute",
  10720. left: "-1000px",
  10721. top: "-1000px"
  10722. });
  10723. }
  10724. for ( i in testElementStyle ) {
  10725. testElement.style[ i ] = testElementStyle[ i ];
  10726. }
  10727. testElement.appendChild( div );
  10728. testElementParent = body || document.documentElement;
  10729. testElementParent.insertBefore( testElement, testElementParent.firstChild );
  10730. div.style.cssText = "position: absolute; left: 10.7432222px;";
  10731. offsetLeft = $( div ).offset().left;
  10732. $.support.offsetFractions = offsetLeft > 10 && offsetLeft < 11;
  10733. testElement.innerHTML = "";
  10734. testElementParent.removeChild( testElement );
  10735. })();
  10736. }( jQuery ) );
  10737. (function( $, undefined ) {
  10738. $.widget( "ui.progressbar", {
  10739. version: "1.10.2",
  10740. options: {
  10741. max: 100,
  10742. value: 0,
  10743. change: null,
  10744. complete: null
  10745. },
  10746. min: 0,
  10747. _create: function() {
  10748. // Constrain initial value
  10749. this.oldValue = this.options.value = this._constrainedValue();
  10750. this.element
  10751. .addClass( "ui-progressbar ui-widget ui-widget-content ui-corner-all" )
  10752. .attr({
  10753. // Only set static values, aria-valuenow and aria-valuemax are
  10754. // set inside _refreshValue()
  10755. role: "progressbar",
  10756. "aria-valuemin": this.min
  10757. });
  10758. this.valueDiv = $( "<div class='ui-progressbar-value ui-widget-header ui-corner-left'></div>" )
  10759. .appendTo( this.element );
  10760. this._refreshValue();
  10761. },
  10762. _destroy: function() {
  10763. this.element
  10764. .removeClass( "ui-progressbar ui-widget ui-widget-content ui-corner-all" )
  10765. .removeAttr( "role" )
  10766. .removeAttr( "aria-valuemin" )
  10767. .removeAttr( "aria-valuemax" )
  10768. .removeAttr( "aria-valuenow" );
  10769. this.valueDiv.remove();
  10770. },
  10771. value: function( newValue ) {
  10772. if ( newValue === undefined ) {
  10773. return this.options.value;
  10774. }
  10775. this.options.value = this._constrainedValue( newValue );
  10776. this._refreshValue();
  10777. },
  10778. _constrainedValue: function( newValue ) {
  10779. if ( newValue === undefined ) {
  10780. newValue = this.options.value;
  10781. }
  10782. this.indeterminate = newValue === false;
  10783. // sanitize value
  10784. if ( typeof newValue !== "number" ) {
  10785. newValue = 0;
  10786. }
  10787. return this.indeterminate ? false :
  10788. Math.min( this.options.max, Math.max( this.min, newValue ) );
  10789. },
  10790. _setOptions: function( options ) {
  10791. // Ensure "value" option is set after other values (like max)
  10792. var value = options.value;
  10793. delete options.value;
  10794. this._super( options );
  10795. this.options.value = this._constrainedValue( value );
  10796. this._refreshValue();
  10797. },
  10798. _setOption: function( key, value ) {
  10799. if ( key === "max" ) {
  10800. // Don't allow a max less than min
  10801. value = Math.max( this.min, value );
  10802. }
  10803. this._super( key, value );
  10804. },
  10805. _percentage: function() {
  10806. return this.indeterminate ? 100 : 100 * ( this.options.value - this.min ) / ( this.options.max - this.min );
  10807. },
  10808. _refreshValue: function() {
  10809. var value = this.options.value,
  10810. percentage = this._percentage();
  10811. this.valueDiv
  10812. .toggle( this.indeterminate || value > this.min )
  10813. .toggleClass( "ui-corner-right", value === this.options.max )
  10814. .width( percentage.toFixed(0) + "%" );
  10815. this.element.toggleClass( "ui-progressbar-indeterminate", this.indeterminate );
  10816. if ( this.indeterminate ) {
  10817. this.element.removeAttr( "aria-valuenow" );
  10818. if ( !this.overlayDiv ) {
  10819. this.overlayDiv = $( "<div class='ui-progressbar-overlay'></div>" ).appendTo( this.valueDiv );
  10820. }
  10821. } else {
  10822. this.element.attr({
  10823. "aria-valuemax": this.options.max,
  10824. "aria-valuenow": value
  10825. });
  10826. if ( this.overlayDiv ) {
  10827. this.overlayDiv.remove();
  10828. this.overlayDiv = null;
  10829. }
  10830. }
  10831. if ( this.oldValue !== value ) {
  10832. this.oldValue = value;
  10833. this._trigger( "change" );
  10834. }
  10835. if ( value === this.options.max ) {
  10836. this._trigger( "complete" );
  10837. }
  10838. }
  10839. });
  10840. })( jQuery );
  10841. (function( $, undefined ) {
  10842. // number of pages in a slider
  10843. // (how many times can you page up/down to go through the whole range)
  10844. var numPages = 5;
  10845. $.widget( "ui.slider", $.ui.mouse, {
  10846. version: "1.10.2",
  10847. widgetEventPrefix: "slide",
  10848. options: {
  10849. animate: false,
  10850. distance: 0,
  10851. max: 100,
  10852. min: 0,
  10853. orientation: "horizontal",
  10854. range: false,
  10855. step: 1,
  10856. value: 0,
  10857. values: null,
  10858. // callbacks
  10859. change: null,
  10860. slide: null,
  10861. start: null,
  10862. stop: null
  10863. },
  10864. _create: function() {
  10865. this._keySliding = false;
  10866. this._mouseSliding = false;
  10867. this._animateOff = true;
  10868. this._handleIndex = null;
  10869. this._detectOrientation();
  10870. this._mouseInit();
  10871. this.element
  10872. .addClass( "ui-slider" +
  10873. " ui-slider-" + this.orientation +
  10874. " ui-widget" +
  10875. " ui-widget-content" +
  10876. " ui-corner-all");
  10877. this._refresh();
  10878. this._setOption( "disabled", this.options.disabled );
  10879. this._animateOff = false;
  10880. },
  10881. _refresh: function() {
  10882. this._createRange();
  10883. this._createHandles();
  10884. this._setupEvents();
  10885. this._refreshValue();
  10886. },
  10887. _createHandles: function() {
  10888. var i, handleCount,
  10889. options = this.options,
  10890. existingHandles = this.element.find( ".ui-slider-handle" ).addClass( "ui-state-default ui-corner-all" ),
  10891. handle = "<a class='ui-slider-handle ui-state-default ui-corner-all' href='#'></a>",
  10892. handles = [];
  10893. handleCount = ( options.values && options.values.length ) || 1;
  10894. if ( existingHandles.length > handleCount ) {
  10895. existingHandles.slice( handleCount ).remove();
  10896. existingHandles = existingHandles.slice( 0, handleCount );
  10897. }
  10898. for ( i = existingHandles.length; i < handleCount; i++ ) {
  10899. handles.push( handle );
  10900. }
  10901. this.handles = existingHandles.add( $( handles.join( "" ) ).appendTo( this.element ) );
  10902. this.handle = this.handles.eq( 0 );
  10903. this.handles.each(function( i ) {
  10904. $( this ).data( "ui-slider-handle-index", i );
  10905. });
  10906. },
  10907. _createRange: function() {
  10908. var options = this.options,
  10909. classes = "";
  10910. if ( options.range ) {
  10911. if ( options.range === true ) {
  10912. if ( !options.values ) {
  10913. options.values = [ this._valueMin(), this._valueMin() ];
  10914. } else if ( options.values.length && options.values.length !== 2 ) {
  10915. options.values = [ options.values[0], options.values[0] ];
  10916. } else if ( $.isArray( options.values ) ) {
  10917. options.values = options.values.slice(0);
  10918. }
  10919. }
  10920. if ( !this.range || !this.range.length ) {
  10921. this.range = $( "<div></div>" )
  10922. .appendTo( this.element );
  10923. classes = "ui-slider-range" +
  10924. // note: this isn't the most fittingly semantic framework class for this element,
  10925. // but worked best visually with a variety of themes
  10926. " ui-widget-header ui-corner-all";
  10927. } else {
  10928. this.range.removeClass( "ui-slider-range-min ui-slider-range-max" )
  10929. // Handle range switching from true to min/max
  10930. .css({
  10931. "left": "",
  10932. "bottom": ""
  10933. });
  10934. }
  10935. this.range.addClass( classes +
  10936. ( ( options.range === "min" || options.range === "max" ) ? " ui-slider-range-" + options.range : "" ) );
  10937. } else {
  10938. this.range = $([]);
  10939. }
  10940. },
  10941. _setupEvents: function() {
  10942. var elements = this.handles.add( this.range ).filter( "a" );
  10943. this._off( elements );
  10944. this._on( elements, this._handleEvents );
  10945. this._hoverable( elements );
  10946. this._focusable( elements );
  10947. },
  10948. _destroy: function() {
  10949. this.handles.remove();
  10950. this.range.remove();
  10951. this.element
  10952. .removeClass( "ui-slider" +
  10953. " ui-slider-horizontal" +
  10954. " ui-slider-vertical" +
  10955. " ui-widget" +
  10956. " ui-widget-content" +
  10957. " ui-corner-all" );
  10958. this._mouseDestroy();
  10959. },
  10960. _mouseCapture: function( event ) {
  10961. var position, normValue, distance, closestHandle, index, allowed, offset, mouseOverHandle,
  10962. that = this,
  10963. o = this.options;
  10964. if ( o.disabled ) {
  10965. return false;
  10966. }
  10967. this.elementSize = {
  10968. width: this.element.outerWidth(),
  10969. height: this.element.outerHeight()
  10970. };
  10971. this.elementOffset = this.element.offset();
  10972. position = { x: event.pageX, y: event.pageY };
  10973. normValue = this._normValueFromMouse( position );
  10974. distance = this._valueMax() - this._valueMin() + 1;
  10975. this.handles.each(function( i ) {
  10976. var thisDistance = Math.abs( normValue - that.values(i) );
  10977. if (( distance > thisDistance ) ||
  10978. ( distance === thisDistance &&
  10979. (i === that._lastChangedValue || that.values(i) === o.min ))) {
  10980. distance = thisDistance;
  10981. closestHandle = $( this );
  10982. index = i;
  10983. }
  10984. });
  10985. allowed = this._start( event, index );
  10986. if ( allowed === false ) {
  10987. return false;
  10988. }
  10989. this._mouseSliding = true;
  10990. this._handleIndex = index;
  10991. closestHandle
  10992. .addClass( "ui-state-active" )
  10993. .focus();
  10994. offset = closestHandle.offset();
  10995. mouseOverHandle = !$( event.target ).parents().addBack().is( ".ui-slider-handle" );
  10996. this._clickOffset = mouseOverHandle ? { left: 0, top: 0 } : {
  10997. left: event.pageX - offset.left - ( closestHandle.width() / 2 ),
  10998. top: event.pageY - offset.top -
  10999. ( closestHandle.height() / 2 ) -
  11000. ( parseInt( closestHandle.css("borderTopWidth"), 10 ) || 0 ) -
  11001. ( parseInt( closestHandle.css("borderBottomWidth"), 10 ) || 0) +
  11002. ( parseInt( closestHandle.css("marginTop"), 10 ) || 0)
  11003. };
  11004. if ( !this.handles.hasClass( "ui-state-hover" ) ) {
  11005. this._slide( event, index, normValue );
  11006. }
  11007. this._animateOff = true;
  11008. return true;
  11009. },
  11010. _mouseStart: function() {
  11011. return true;
  11012. },
  11013. _mouseDrag: function( event ) {
  11014. var position = { x: event.pageX, y: event.pageY },
  11015. normValue = this._normValueFromMouse( position );
  11016. this._slide( event, this._handleIndex, normValue );
  11017. return false;
  11018. },
  11019. _mouseStop: function( event ) {
  11020. this.handles.removeClass( "ui-state-active" );
  11021. this._mouseSliding = false;
  11022. this._stop( event, this._handleIndex );
  11023. this._change( event, this._handleIndex );
  11024. this._handleIndex = null;
  11025. this._clickOffset = null;
  11026. this._animateOff = false;
  11027. return false;
  11028. },
  11029. _detectOrientation: function() {
  11030. this.orientation = ( this.options.orientation === "vertical" ) ? "vertical" : "horizontal";
  11031. },
  11032. _normValueFromMouse: function( position ) {
  11033. var pixelTotal,
  11034. pixelMouse,
  11035. percentMouse,
  11036. valueTotal,
  11037. valueMouse;
  11038. if ( this.orientation === "horizontal" ) {
  11039. pixelTotal = this.elementSize.width;
  11040. pixelMouse = position.x - this.elementOffset.left - ( this._clickOffset ? this._clickOffset.left : 0 );
  11041. } else {
  11042. pixelTotal = this.elementSize.height;
  11043. pixelMouse = position.y - this.elementOffset.top - ( this._clickOffset ? this._clickOffset.top : 0 );
  11044. }
  11045. percentMouse = ( pixelMouse / pixelTotal );
  11046. if ( percentMouse > 1 ) {
  11047. percentMouse = 1;
  11048. }
  11049. if ( percentMouse < 0 ) {
  11050. percentMouse = 0;
  11051. }
  11052. if ( this.orientation === "vertical" ) {
  11053. percentMouse = 1 - percentMouse;
  11054. }
  11055. valueTotal = this._valueMax() - this._valueMin();
  11056. valueMouse = this._valueMin() + percentMouse * valueTotal;
  11057. return this._trimAlignValue( valueMouse );
  11058. },
  11059. _start: function( event, index ) {
  11060. var uiHash = {
  11061. handle: this.handles[ index ],
  11062. value: this.value()
  11063. };
  11064. if ( this.options.values && this.options.values.length ) {
  11065. uiHash.value = this.values( index );
  11066. uiHash.values = this.values();
  11067. }
  11068. return this._trigger( "start", event, uiHash );
  11069. },
  11070. _slide: function( event, index, newVal ) {
  11071. var otherVal,
  11072. newValues,
  11073. allowed;
  11074. if ( this.options.values && this.options.values.length ) {
  11075. otherVal = this.values( index ? 0 : 1 );
  11076. if ( ( this.options.values.length === 2 && this.options.range === true ) &&
  11077. ( ( index === 0 && newVal > otherVal) || ( index === 1 && newVal < otherVal ) )
  11078. ) {
  11079. newVal = otherVal;
  11080. }
  11081. if ( newVal !== this.values( index ) ) {
  11082. newValues = this.values();
  11083. newValues[ index ] = newVal;
  11084. // A slide can be canceled by returning false from the slide callback
  11085. allowed = this._trigger( "slide", event, {
  11086. handle: this.handles[ index ],
  11087. value: newVal,
  11088. values: newValues
  11089. } );
  11090. otherVal = this.values( index ? 0 : 1 );
  11091. if ( allowed !== false ) {
  11092. this.values( index, newVal, true );
  11093. }
  11094. }
  11095. } else {
  11096. if ( newVal !== this.value() ) {
  11097. // A slide can be canceled by returning false from the slide callback
  11098. allowed = this._trigger( "slide", event, {
  11099. handle: this.handles[ index ],
  11100. value: newVal
  11101. } );
  11102. if ( allowed !== false ) {
  11103. this.value( newVal );
  11104. }
  11105. }
  11106. }
  11107. },
  11108. _stop: function( event, index ) {
  11109. var uiHash = {
  11110. handle: this.handles[ index ],
  11111. value: this.value()
  11112. };
  11113. if ( this.options.values && this.options.values.length ) {
  11114. uiHash.value = this.values( index );
  11115. uiHash.values = this.values();
  11116. }
  11117. this._trigger( "stop", event, uiHash );
  11118. },
  11119. _change: function( event, index ) {
  11120. if ( !this._keySliding && !this._mouseSliding ) {
  11121. var uiHash = {
  11122. handle: this.handles[ index ],
  11123. value: this.value()
  11124. };
  11125. if ( this.options.values && this.options.values.length ) {
  11126. uiHash.value = this.values( index );
  11127. uiHash.values = this.values();
  11128. }
  11129. //store the last changed value index for reference when handles overlap
  11130. this._lastChangedValue = index;
  11131. this._trigger( "change", event, uiHash );
  11132. }
  11133. },
  11134. value: function( newValue ) {
  11135. if ( arguments.length ) {
  11136. this.options.value = this._trimAlignValue( newValue );
  11137. this._refreshValue();
  11138. this._change( null, 0 );
  11139. return;
  11140. }
  11141. return this._value();
  11142. },
  11143. values: function( index, newValue ) {
  11144. var vals,
  11145. newValues,
  11146. i;
  11147. if ( arguments.length > 1 ) {
  11148. this.options.values[ index ] = this._trimAlignValue( newValue );
  11149. this._refreshValue();
  11150. this._change( null, index );
  11151. return;
  11152. }
  11153. if ( arguments.length ) {
  11154. if ( $.isArray( arguments[ 0 ] ) ) {
  11155. vals = this.options.values;
  11156. newValues = arguments[ 0 ];
  11157. for ( i = 0; i < vals.length; i += 1 ) {
  11158. vals[ i ] = this._trimAlignValue( newValues[ i ] );
  11159. this._change( null, i );
  11160. }
  11161. this._refreshValue();
  11162. } else {
  11163. if ( this.options.values && this.options.values.length ) {
  11164. return this._values( index );
  11165. } else {
  11166. return this.value();
  11167. }
  11168. }
  11169. } else {
  11170. return this._values();
  11171. }
  11172. },
  11173. _setOption: function( key, value ) {
  11174. var i,
  11175. valsLength = 0;
  11176. if ( key === "range" && this.options.range === true ) {
  11177. if ( value === "min" ) {
  11178. this.options.value = this._values( 0 );
  11179. this.options.values = null;
  11180. } else if ( value === "max" ) {
  11181. this.options.value = this._values( this.options.values.length-1 );
  11182. this.options.values = null;
  11183. }
  11184. }
  11185. if ( $.isArray( this.options.values ) ) {
  11186. valsLength = this.options.values.length;
  11187. }
  11188. $.Widget.prototype._setOption.apply( this, arguments );
  11189. switch ( key ) {
  11190. case "orientation":
  11191. this._detectOrientation();
  11192. this.element
  11193. .removeClass( "ui-slider-horizontal ui-slider-vertical" )
  11194. .addClass( "ui-slider-" + this.orientation );
  11195. this._refreshValue();
  11196. break;
  11197. case "value":
  11198. this._animateOff = true;
  11199. this._refreshValue();
  11200. this._change( null, 0 );
  11201. this._animateOff = false;
  11202. break;
  11203. case "values":
  11204. this._animateOff = true;
  11205. this._refreshValue();
  11206. for ( i = 0; i < valsLength; i += 1 ) {
  11207. this._change( null, i );
  11208. }
  11209. this._animateOff = false;
  11210. break;
  11211. case "min":
  11212. case "max":
  11213. this._animateOff = true;
  11214. this._refreshValue();
  11215. this._animateOff = false;
  11216. break;
  11217. case "range":
  11218. this._animateOff = true;
  11219. this._refresh();
  11220. this._animateOff = false;
  11221. break;
  11222. }
  11223. },
  11224. //internal value getter
  11225. // _value() returns value trimmed by min and max, aligned by step
  11226. _value: function() {
  11227. var val = this.options.value;
  11228. val = this._trimAlignValue( val );
  11229. return val;
  11230. },
  11231. //internal values getter
  11232. // _values() returns array of values trimmed by min and max, aligned by step
  11233. // _values( index ) returns single value trimmed by min and max, aligned by step
  11234. _values: function( index ) {
  11235. var val,
  11236. vals,
  11237. i;
  11238. if ( arguments.length ) {
  11239. val = this.options.values[ index ];
  11240. val = this._trimAlignValue( val );
  11241. return val;
  11242. } else if ( this.options.values && this.options.values.length ) {
  11243. // .slice() creates a copy of the array
  11244. // this copy gets trimmed by min and max and then returned
  11245. vals = this.options.values.slice();
  11246. for ( i = 0; i < vals.length; i+= 1) {
  11247. vals[ i ] = this._trimAlignValue( vals[ i ] );
  11248. }
  11249. return vals;
  11250. } else {
  11251. return [];
  11252. }
  11253. },
  11254. // returns the step-aligned value that val is closest to, between (inclusive) min and max
  11255. _trimAlignValue: function( val ) {
  11256. if ( val <= this._valueMin() ) {
  11257. return this._valueMin();
  11258. }
  11259. if ( val >= this._valueMax() ) {
  11260. return this._valueMax();
  11261. }
  11262. var step = ( this.options.step > 0 ) ? this.options.step : 1,
  11263. valModStep = (val - this._valueMin()) % step,
  11264. alignValue = val - valModStep;
  11265. if ( Math.abs(valModStep) * 2 >= step ) {
  11266. alignValue += ( valModStep > 0 ) ? step : ( -step );
  11267. }
  11268. // Since JavaScript has problems with large floats, round
  11269. // the final value to 5 digits after the decimal point (see #4124)
  11270. return parseFloat( alignValue.toFixed(5) );
  11271. },
  11272. _valueMin: function() {
  11273. return this.options.min;
  11274. },
  11275. _valueMax: function() {
  11276. return this.options.max;
  11277. },
  11278. _refreshValue: function() {
  11279. var lastValPercent, valPercent, value, valueMin, valueMax,
  11280. oRange = this.options.range,
  11281. o = this.options,
  11282. that = this,
  11283. animate = ( !this._animateOff ) ? o.animate : false,
  11284. _set = {};
  11285. if ( this.options.values && this.options.values.length ) {
  11286. this.handles.each(function( i ) {
  11287. valPercent = ( that.values(i) - that._valueMin() ) / ( that._valueMax() - that._valueMin() ) * 100;
  11288. _set[ that.orientation === "horizontal" ? "left" : "bottom" ] = valPercent + "%";
  11289. $( this ).stop( 1, 1 )[ animate ? "animate" : "css" ]( _set, o.animate );
  11290. if ( that.options.range === true ) {
  11291. if ( that.orientation === "horizontal" ) {
  11292. if ( i === 0 ) {
  11293. that.range.stop( 1, 1 )[ animate ? "animate" : "css" ]( { left: valPercent + "%" }, o.animate );
  11294. }
  11295. if ( i === 1 ) {
  11296. that.range[ animate ? "animate" : "css" ]( { width: ( valPercent - lastValPercent ) + "%" }, { queue: false, duration: o.animate } );
  11297. }
  11298. } else {
  11299. if ( i === 0 ) {
  11300. that.range.stop( 1, 1 )[ animate ? "animate" : "css" ]( { bottom: ( valPercent ) + "%" }, o.animate );
  11301. }
  11302. if ( i === 1 ) {
  11303. that.range[ animate ? "animate" : "css" ]( { height: ( valPercent - lastValPercent ) + "%" }, { queue: false, duration: o.animate } );
  11304. }
  11305. }
  11306. }
  11307. lastValPercent = valPercent;
  11308. });
  11309. } else {
  11310. value = this.value();
  11311. valueMin = this._valueMin();
  11312. valueMax = this._valueMax();
  11313. valPercent = ( valueMax !== valueMin ) ?
  11314. ( value - valueMin ) / ( valueMax - valueMin ) * 100 :
  11315. 0;
  11316. _set[ this.orientation === "horizontal" ? "left" : "bottom" ] = valPercent + "%";
  11317. this.handle.stop( 1, 1 )[ animate ? "animate" : "css" ]( _set, o.animate );
  11318. if ( oRange === "min" && this.orientation === "horizontal" ) {
  11319. this.range.stop( 1, 1 )[ animate ? "animate" : "css" ]( { width: valPercent + "%" }, o.animate );
  11320. }
  11321. if ( oRange === "max" && this.orientation === "horizontal" ) {
  11322. this.range[ animate ? "animate" : "css" ]( { width: ( 100 - valPercent ) + "%" }, { queue: false, duration: o.animate } );
  11323. }
  11324. if ( oRange === "min" && this.orientation === "vertical" ) {
  11325. this.range.stop( 1, 1 )[ animate ? "animate" : "css" ]( { height: valPercent + "%" }, o.animate );
  11326. }
  11327. if ( oRange === "max" && this.orientation === "vertical" ) {
  11328. this.range[ animate ? "animate" : "css" ]( { height: ( 100 - valPercent ) + "%" }, { queue: false, duration: o.animate } );
  11329. }
  11330. }
  11331. },
  11332. _handleEvents: {
  11333. keydown: function( event ) {
  11334. /*jshint maxcomplexity:25*/
  11335. var allowed, curVal, newVal, step,
  11336. index = $( event.target ).data( "ui-slider-handle-index" );
  11337. switch ( event.keyCode ) {
  11338. case $.ui.keyCode.HOME:
  11339. case $.ui.keyCode.END:
  11340. case $.ui.keyCode.PAGE_UP:
  11341. case $.ui.keyCode.PAGE_DOWN:
  11342. case $.ui.keyCode.UP:
  11343. case $.ui.keyCode.RIGHT:
  11344. case $.ui.keyCode.DOWN:
  11345. case $.ui.keyCode.LEFT:
  11346. event.preventDefault();
  11347. if ( !this._keySliding ) {
  11348. this._keySliding = true;
  11349. $( event.target ).addClass( "ui-state-active" );
  11350. allowed = this._start( event, index );
  11351. if ( allowed === false ) {
  11352. return;
  11353. }
  11354. }
  11355. break;
  11356. }
  11357. step = this.options.step;
  11358. if ( this.options.values && this.options.values.length ) {
  11359. curVal = newVal = this.values( index );
  11360. } else {
  11361. curVal = newVal = this.value();
  11362. }
  11363. switch ( event.keyCode ) {
  11364. case $.ui.keyCode.HOME:
  11365. newVal = this._valueMin();
  11366. break;
  11367. case $.ui.keyCode.END:
  11368. newVal = this._valueMax();
  11369. break;
  11370. case $.ui.keyCode.PAGE_UP:
  11371. newVal = this._trimAlignValue( curVal + ( (this._valueMax() - this._valueMin()) / numPages ) );
  11372. break;
  11373. case $.ui.keyCode.PAGE_DOWN:
  11374. newVal = this._trimAlignValue( curVal - ( (this._valueMax() - this._valueMin()) / numPages ) );
  11375. break;
  11376. case $.ui.keyCode.UP:
  11377. case $.ui.keyCode.RIGHT:
  11378. if ( curVal === this._valueMax() ) {
  11379. return;
  11380. }
  11381. newVal = this._trimAlignValue( curVal + step );
  11382. break;
  11383. case $.ui.keyCode.DOWN:
  11384. case $.ui.keyCode.LEFT:
  11385. if ( curVal === this._valueMin() ) {
  11386. return;
  11387. }
  11388. newVal = this._trimAlignValue( curVal - step );
  11389. break;
  11390. }
  11391. this._slide( event, index, newVal );
  11392. },
  11393. click: function( event ) {
  11394. event.preventDefault();
  11395. },
  11396. keyup: function( event ) {
  11397. var index = $( event.target ).data( "ui-slider-handle-index" );
  11398. if ( this._keySliding ) {
  11399. this._keySliding = false;
  11400. this._stop( event, index );
  11401. this._change( event, index );
  11402. $( event.target ).removeClass( "ui-state-active" );
  11403. }
  11404. }
  11405. }
  11406. });
  11407. }(jQuery));
  11408. (function( $ ) {
  11409. function modifier( fn ) {
  11410. return function() {
  11411. var previous = this.element.val();
  11412. fn.apply( this, arguments );
  11413. this._refresh();
  11414. if ( previous !== this.element.val() ) {
  11415. this._trigger( "change" );
  11416. }
  11417. };
  11418. }
  11419. $.widget( "ui.spinner", {
  11420. version: "1.10.2",
  11421. defaultElement: "<input>",
  11422. widgetEventPrefix: "spin",
  11423. options: {
  11424. culture: null,
  11425. icons: {
  11426. down: "ui-icon-triangle-1-s",
  11427. up: "ui-icon-triangle-1-n"
  11428. },
  11429. incremental: true,
  11430. max: null,
  11431. min: null,
  11432. numberFormat: null,
  11433. page: 10,
  11434. step: 1,
  11435. change: null,
  11436. spin: null,
  11437. start: null,
  11438. stop: null
  11439. },
  11440. _create: function() {
  11441. // handle string values that need to be parsed
  11442. this._setOption( "max", this.options.max );
  11443. this._setOption( "min", this.options.min );
  11444. this._setOption( "step", this.options.step );
  11445. // format the value, but don't constrain
  11446. this._value( this.element.val(), true );
  11447. this._draw();
  11448. this._on( this._events );
  11449. this._refresh();
  11450. // turning off autocomplete prevents the browser from remembering the
  11451. // value when navigating through history, so we re-enable autocomplete
  11452. // if the page is unloaded before the widget is destroyed. #7790
  11453. this._on( this.window, {
  11454. beforeunload: function() {
  11455. this.element.removeAttr( "autocomplete" );
  11456. }
  11457. });
  11458. },
  11459. _getCreateOptions: function() {
  11460. var options = {},
  11461. element = this.element;
  11462. $.each( [ "min", "max", "step" ], function( i, option ) {
  11463. var value = element.attr( option );
  11464. if ( value !== undefined && value.length ) {
  11465. options[ option ] = value;
  11466. }
  11467. });
  11468. return options;
  11469. },
  11470. _events: {
  11471. keydown: function( event ) {
  11472. if ( this._start( event ) && this._keydown( event ) ) {
  11473. event.preventDefault();
  11474. }
  11475. },
  11476. keyup: "_stop",
  11477. focus: function() {
  11478. this.previous = this.element.val();
  11479. },
  11480. blur: function( event ) {
  11481. if ( this.cancelBlur ) {
  11482. delete this.cancelBlur;
  11483. return;
  11484. }
  11485. this._stop();
  11486. this._refresh();
  11487. if ( this.previous !== this.element.val() ) {
  11488. this._trigger( "change", event );
  11489. }
  11490. },
  11491. mousewheel: function( event, delta ) {
  11492. if ( !delta ) {
  11493. return;
  11494. }
  11495. if ( !this.spinning && !this._start( event ) ) {
  11496. return false;
  11497. }
  11498. this._spin( (delta > 0 ? 1 : -1) * this.options.step, event );
  11499. clearTimeout( this.mousewheelTimer );
  11500. this.mousewheelTimer = this._delay(function() {
  11501. if ( this.spinning ) {
  11502. this._stop( event );
  11503. }
  11504. }, 100 );
  11505. event.preventDefault();
  11506. },
  11507. "mousedown .ui-spinner-button": function( event ) {
  11508. var previous;
  11509. // We never want the buttons to have focus; whenever the user is
  11510. // interacting with the spinner, the focus should be on the input.
  11511. // If the input is focused then this.previous is properly set from
  11512. // when the input first received focus. If the input is not focused
  11513. // then we need to set this.previous based on the value before spinning.
  11514. previous = this.element[0] === this.document[0].activeElement ?
  11515. this.previous : this.element.val();
  11516. function checkFocus() {
  11517. var isActive = this.element[0] === this.document[0].activeElement;
  11518. if ( !isActive ) {
  11519. this.element.focus();
  11520. this.previous = previous;
  11521. // support: IE
  11522. // IE sets focus asynchronously, so we need to check if focus
  11523. // moved off of the input because the user clicked on the button.
  11524. this._delay(function() {
  11525. this.previous = previous;
  11526. });
  11527. }
  11528. }
  11529. // ensure focus is on (or stays on) the text field
  11530. event.preventDefault();
  11531. checkFocus.call( this );
  11532. // support: IE
  11533. // IE doesn't prevent moving focus even with event.preventDefault()
  11534. // so we set a flag to know when we should ignore the blur event
  11535. // and check (again) if focus moved off of the input.
  11536. this.cancelBlur = true;
  11537. this._delay(function() {
  11538. delete this.cancelBlur;
  11539. checkFocus.call( this );
  11540. });
  11541. if ( this._start( event ) === false ) {
  11542. return;
  11543. }
  11544. this._repeat( null, $( event.currentTarget ).hasClass( "ui-spinner-up" ) ? 1 : -1, event );
  11545. },
  11546. "mouseup .ui-spinner-button": "_stop",
  11547. "mouseenter .ui-spinner-button": function( event ) {
  11548. // button will add ui-state-active if mouse was down while mouseleave and kept down
  11549. if ( !$( event.currentTarget ).hasClass( "ui-state-active" ) ) {
  11550. return;
  11551. }
  11552. if ( this._start( event ) === false ) {
  11553. return false;
  11554. }
  11555. this._repeat( null, $( event.currentTarget ).hasClass( "ui-spinner-up" ) ? 1 : -1, event );
  11556. },
  11557. // TODO: do we really want to consider this a stop?
  11558. // shouldn't we just stop the repeater and wait until mouseup before
  11559. // we trigger the stop event?
  11560. "mouseleave .ui-spinner-button": "_stop"
  11561. },
  11562. _draw: function() {
  11563. var uiSpinner = this.uiSpinner = this.element
  11564. .addClass( "ui-spinner-input" )
  11565. .attr( "autocomplete", "off" )
  11566. .wrap( this._uiSpinnerHtml() )
  11567. .parent()
  11568. // add buttons
  11569. .append( this._buttonHtml() );
  11570. this.element.attr( "role", "spinbutton" );
  11571. // button bindings
  11572. this.buttons = uiSpinner.find( ".ui-spinner-button" )
  11573. .attr( "tabIndex", -1 )
  11574. .button()
  11575. .removeClass( "ui-corner-all" );
  11576. // IE 6 doesn't understand height: 50% for the buttons
  11577. // unless the wrapper has an explicit height
  11578. if ( this.buttons.height() > Math.ceil( uiSpinner.height() * 0.5 ) &&
  11579. uiSpinner.height() > 0 ) {
  11580. uiSpinner.height( uiSpinner.height() );
  11581. }
  11582. // disable spinner if element was already disabled
  11583. if ( this.options.disabled ) {
  11584. this.disable();
  11585. }
  11586. },
  11587. _keydown: function( event ) {
  11588. var options = this.options,
  11589. keyCode = $.ui.keyCode;
  11590. switch ( event.keyCode ) {
  11591. case keyCode.UP:
  11592. this._repeat( null, 1, event );
  11593. return true;
  11594. case keyCode.DOWN:
  11595. this._repeat( null, -1, event );
  11596. return true;
  11597. case keyCode.PAGE_UP:
  11598. this._repeat( null, options.page, event );
  11599. return true;
  11600. case keyCode.PAGE_DOWN:
  11601. this._repeat( null, -options.page, event );
  11602. return true;
  11603. }
  11604. return false;
  11605. },
  11606. _uiSpinnerHtml: function() {
  11607. return "<span class='ui-spinner ui-widget ui-widget-content ui-corner-all'></span>";
  11608. },
  11609. _buttonHtml: function() {
  11610. return "" +
  11611. "<a class='ui-spinner-button ui-spinner-up ui-corner-tr'>" +
  11612. "<span class='ui-icon " + this.options.icons.up + "'>&#9650;</span>" +
  11613. "</a>" +
  11614. "<a class='ui-spinner-button ui-spinner-down ui-corner-br'>" +
  11615. "<span class='ui-icon " + this.options.icons.down + "'>&#9660;</span>" +
  11616. "</a>";
  11617. },
  11618. _start: function( event ) {
  11619. if ( !this.spinning && this._trigger( "start", event ) === false ) {
  11620. return false;
  11621. }
  11622. if ( !this.counter ) {
  11623. this.counter = 1;
  11624. }
  11625. this.spinning = true;
  11626. return true;
  11627. },
  11628. _repeat: function( i, steps, event ) {
  11629. i = i || 500;
  11630. clearTimeout( this.timer );
  11631. this.timer = this._delay(function() {
  11632. this._repeat( 40, steps, event );
  11633. }, i );
  11634. this._spin( steps * this.options.step, event );
  11635. },
  11636. _spin: function( step, event ) {
  11637. var value = this.value() || 0;
  11638. if ( !this.counter ) {
  11639. this.counter = 1;
  11640. }
  11641. value = this._adjustValue( value + step * this._increment( this.counter ) );
  11642. if ( !this.spinning || this._trigger( "spin", event, { value: value } ) !== false) {
  11643. this._value( value );
  11644. this.counter++;
  11645. }
  11646. },
  11647. _increment: function( i ) {
  11648. var incremental = this.options.incremental;
  11649. if ( incremental ) {
  11650. return $.isFunction( incremental ) ?
  11651. incremental( i ) :
  11652. Math.floor( i*i*i/50000 - i*i/500 + 17*i/200 + 1 );
  11653. }
  11654. return 1;
  11655. },
  11656. _precision: function() {
  11657. var precision = this._precisionOf( this.options.step );
  11658. if ( this.options.min !== null ) {
  11659. precision = Math.max( precision, this._precisionOf( this.options.min ) );
  11660. }
  11661. return precision;
  11662. },
  11663. _precisionOf: function( num ) {
  11664. var str = num.toString(),
  11665. decimal = str.indexOf( "." );
  11666. return decimal === -1 ? 0 : str.length - decimal - 1;
  11667. },
  11668. _adjustValue: function( value ) {
  11669. var base, aboveMin,
  11670. options = this.options;
  11671. // make sure we're at a valid step
  11672. // - find out where we are relative to the base (min or 0)
  11673. base = options.min !== null ? options.min : 0;
  11674. aboveMin = value - base;
  11675. // - round to the nearest step
  11676. aboveMin = Math.round(aboveMin / options.step) * options.step;
  11677. // - rounding is based on 0, so adjust back to our base
  11678. value = base + aboveMin;
  11679. // fix precision from bad JS floating point math
  11680. value = parseFloat( value.toFixed( this._precision() ) );
  11681. // clamp the value
  11682. if ( options.max !== null && value > options.max) {
  11683. return options.max;
  11684. }
  11685. if ( options.min !== null && value < options.min ) {
  11686. return options.min;
  11687. }
  11688. return value;
  11689. },
  11690. _stop: function( event ) {
  11691. if ( !this.spinning ) {
  11692. return;
  11693. }
  11694. clearTimeout( this.timer );
  11695. clearTimeout( this.mousewheelTimer );
  11696. this.counter = 0;
  11697. this.spinning = false;
  11698. this._trigger( "stop", event );
  11699. },
  11700. _setOption: function( key, value ) {
  11701. if ( key === "culture" || key === "numberFormat" ) {
  11702. var prevValue = this._parse( this.element.val() );
  11703. this.options[ key ] = value;
  11704. this.element.val( this._format( prevValue ) );
  11705. return;
  11706. }
  11707. if ( key === "max" || key === "min" || key === "step" ) {
  11708. if ( typeof value === "string" ) {
  11709. value = this._parse( value );
  11710. }
  11711. }
  11712. if ( key === "icons" ) {
  11713. this.buttons.first().find( ".ui-icon" )
  11714. .removeClass( this.options.icons.up )
  11715. .addClass( value.up );
  11716. this.buttons.last().find( ".ui-icon" )
  11717. .removeClass( this.options.icons.down )
  11718. .addClass( value.down );
  11719. }
  11720. this._super( key, value );
  11721. if ( key === "disabled" ) {
  11722. if ( value ) {
  11723. this.element.prop( "disabled", true );
  11724. this.buttons.button( "disable" );
  11725. } else {
  11726. this.element.prop( "disabled", false );
  11727. this.buttons.button( "enable" );
  11728. }
  11729. }
  11730. },
  11731. _setOptions: modifier(function( options ) {
  11732. this._super( options );
  11733. this._value( this.element.val() );
  11734. }),
  11735. _parse: function( val ) {
  11736. if ( typeof val === "string" && val !== "" ) {
  11737. val = window.Globalize && this.options.numberFormat ?
  11738. Globalize.parseFloat( val, 10, this.options.culture ) : +val;
  11739. }
  11740. return val === "" || isNaN( val ) ? null : val;
  11741. },
  11742. _format: function( value ) {
  11743. if ( value === "" ) {
  11744. return "";
  11745. }
  11746. return window.Globalize && this.options.numberFormat ?
  11747. Globalize.format( value, this.options.numberFormat, this.options.culture ) :
  11748. value;
  11749. },
  11750. _refresh: function() {
  11751. this.element.attr({
  11752. "aria-valuemin": this.options.min,
  11753. "aria-valuemax": this.options.max,
  11754. // TODO: what should we do with values that can't be parsed?
  11755. "aria-valuenow": this._parse( this.element.val() )
  11756. });
  11757. },
  11758. // update the value without triggering change
  11759. _value: function( value, allowAny ) {
  11760. var parsed;
  11761. if ( value !== "" ) {
  11762. parsed = this._parse( value );
  11763. if ( parsed !== null ) {
  11764. if ( !allowAny ) {
  11765. parsed = this._adjustValue( parsed );
  11766. }
  11767. value = this._format( parsed );
  11768. }
  11769. }
  11770. this.element.val( value );
  11771. this._refresh();
  11772. },
  11773. _destroy: function() {
  11774. this.element
  11775. .removeClass( "ui-spinner-input" )
  11776. .prop( "disabled", false )
  11777. .removeAttr( "autocomplete" )
  11778. .removeAttr( "role" )
  11779. .removeAttr( "aria-valuemin" )
  11780. .removeAttr( "aria-valuemax" )
  11781. .removeAttr( "aria-valuenow" );
  11782. this.uiSpinner.replaceWith( this.element );
  11783. },
  11784. stepUp: modifier(function( steps ) {
  11785. this._stepUp( steps );
  11786. }),
  11787. _stepUp: function( steps ) {
  11788. if ( this._start() ) {
  11789. this._spin( (steps || 1) * this.options.step );
  11790. this._stop();
  11791. }
  11792. },
  11793. stepDown: modifier(function( steps ) {
  11794. this._stepDown( steps );
  11795. }),
  11796. _stepDown: function( steps ) {
  11797. if ( this._start() ) {
  11798. this._spin( (steps || 1) * -this.options.step );
  11799. this._stop();
  11800. }
  11801. },
  11802. pageUp: modifier(function( pages ) {
  11803. this._stepUp( (pages || 1) * this.options.page );
  11804. }),
  11805. pageDown: modifier(function( pages ) {
  11806. this._stepDown( (pages || 1) * this.options.page );
  11807. }),
  11808. value: function( newVal ) {
  11809. if ( !arguments.length ) {
  11810. return this._parse( this.element.val() );
  11811. }
  11812. modifier( this._value ).call( this, newVal );
  11813. },
  11814. widget: function() {
  11815. return this.uiSpinner;
  11816. }
  11817. });
  11818. }( jQuery ) );
  11819. (function( $, undefined ) {
  11820. var tabId = 0,
  11821. rhash = /#.*$/;
  11822. function getNextTabId() {
  11823. return ++tabId;
  11824. }
  11825. function isLocal( anchor ) {
  11826. return anchor.hash.length > 1 &&
  11827. decodeURIComponent( anchor.href.replace( rhash, "" ) ) ===
  11828. decodeURIComponent( location.href.replace( rhash, "" ) );
  11829. }
  11830. $.widget( "ui.tabs", {
  11831. version: "1.10.2",
  11832. delay: 300,
  11833. options: {
  11834. active: null,
  11835. collapsible: false,
  11836. event: "click",
  11837. heightStyle: "content",
  11838. hide: null,
  11839. show: null,
  11840. // callbacks
  11841. activate: null,
  11842. beforeActivate: null,
  11843. beforeLoad: null,
  11844. load: null
  11845. },
  11846. _create: function() {
  11847. var that = this,
  11848. options = this.options;
  11849. this.running = false;
  11850. this.element
  11851. .addClass( "ui-tabs ui-widget ui-widget-content ui-corner-all" )
  11852. .toggleClass( "ui-tabs-collapsible", options.collapsible )
  11853. // Prevent users from focusing disabled tabs via click
  11854. .delegate( ".ui-tabs-nav > li", "mousedown" + this.eventNamespace, function( event ) {
  11855. if ( $( this ).is( ".ui-state-disabled" ) ) {
  11856. event.preventDefault();
  11857. }
  11858. })
  11859. // support: IE <9
  11860. // Preventing the default action in mousedown doesn't prevent IE
  11861. // from focusing the element, so if the anchor gets focused, blur.
  11862. // We don't have to worry about focusing the previously focused
  11863. // element since clicking on a non-focusable element should focus
  11864. // the body anyway.
  11865. .delegate( ".ui-tabs-anchor", "focus" + this.eventNamespace, function() {
  11866. if ( $( this ).closest( "li" ).is( ".ui-state-disabled" ) ) {
  11867. this.blur();
  11868. }
  11869. });
  11870. this._processTabs();
  11871. options.active = this._initialActive();
  11872. // Take disabling tabs via class attribute from HTML
  11873. // into account and update option properly.
  11874. if ( $.isArray( options.disabled ) ) {
  11875. options.disabled = $.unique( options.disabled.concat(
  11876. $.map( this.tabs.filter( ".ui-state-disabled" ), function( li ) {
  11877. return that.tabs.index( li );
  11878. })
  11879. ) ).sort();
  11880. }
  11881. // check for length avoids error when initializing empty list
  11882. if ( this.options.active !== false && this.anchors.length ) {
  11883. this.active = this._findActive( options.active );
  11884. } else {
  11885. this.active = $();
  11886. }
  11887. this._refresh();
  11888. if ( this.active.length ) {
  11889. this.load( options.active );
  11890. }
  11891. },
  11892. _initialActive: function() {
  11893. var active = this.options.active,
  11894. collapsible = this.options.collapsible,
  11895. locationHash = location.hash.substring( 1 );
  11896. if ( active === null ) {
  11897. // check the fragment identifier in the URL
  11898. if ( locationHash ) {
  11899. this.tabs.each(function( i, tab ) {
  11900. if ( $( tab ).attr( "aria-controls" ) === locationHash ) {
  11901. active = i;
  11902. return false;
  11903. }
  11904. });
  11905. }
  11906. // check for a tab marked active via a class
  11907. if ( active === null ) {
  11908. active = this.tabs.index( this.tabs.filter( ".ui-tabs-active" ) );
  11909. }
  11910. // no active tab, set to false
  11911. if ( active === null || active === -1 ) {
  11912. active = this.tabs.length ? 0 : false;
  11913. }
  11914. }
  11915. // handle numbers: negative, out of range
  11916. if ( active !== false ) {
  11917. active = this.tabs.index( this.tabs.eq( active ) );
  11918. if ( active === -1 ) {
  11919. active = collapsible ? false : 0;
  11920. }
  11921. }
  11922. // don't allow collapsible: false and active: false
  11923. if ( !collapsible && active === false && this.anchors.length ) {
  11924. active = 0;
  11925. }
  11926. return active;
  11927. },
  11928. _getCreateEventData: function() {
  11929. return {
  11930. tab: this.active,
  11931. panel: !this.active.length ? $() : this._getPanelForTab( this.active )
  11932. };
  11933. },
  11934. _tabKeydown: function( event ) {
  11935. /*jshint maxcomplexity:15*/
  11936. var focusedTab = $( this.document[0].activeElement ).closest( "li" ),
  11937. selectedIndex = this.tabs.index( focusedTab ),
  11938. goingForward = true;
  11939. if ( this._handlePageNav( event ) ) {
  11940. return;
  11941. }
  11942. switch ( event.keyCode ) {
  11943. case $.ui.keyCode.RIGHT:
  11944. case $.ui.keyCode.DOWN:
  11945. selectedIndex++;
  11946. break;
  11947. case $.ui.keyCode.UP:
  11948. case $.ui.keyCode.LEFT:
  11949. goingForward = false;
  11950. selectedIndex--;
  11951. break;
  11952. case $.ui.keyCode.END:
  11953. selectedIndex = this.anchors.length - 1;
  11954. break;
  11955. case $.ui.keyCode.HOME:
  11956. selectedIndex = 0;
  11957. break;
  11958. case $.ui.keyCode.SPACE:
  11959. // Activate only, no collapsing
  11960. event.preventDefault();
  11961. clearTimeout( this.activating );
  11962. this._activate( selectedIndex );
  11963. return;
  11964. case $.ui.keyCode.ENTER:
  11965. // Toggle (cancel delayed activation, allow collapsing)
  11966. event.preventDefault();
  11967. clearTimeout( this.activating );
  11968. // Determine if we should collapse or activate
  11969. this._activate( selectedIndex === this.options.active ? false : selectedIndex );
  11970. return;
  11971. default:
  11972. return;
  11973. }
  11974. // Focus the appropriate tab, based on which key was pressed
  11975. event.preventDefault();
  11976. clearTimeout( this.activating );
  11977. selectedIndex = this._focusNextTab( selectedIndex, goingForward );
  11978. // Navigating with control key will prevent automatic activation
  11979. if ( !event.ctrlKey ) {
  11980. // Update aria-selected immediately so that AT think the tab is already selected.
  11981. // Otherwise AT may confuse the user by stating that they need to activate the tab,
  11982. // but the tab will already be activated by the time the announcement finishes.
  11983. focusedTab.attr( "aria-selected", "false" );
  11984. this.tabs.eq( selectedIndex ).attr( "aria-selected", "true" );
  11985. this.activating = this._delay(function() {
  11986. this.option( "active", selectedIndex );
  11987. }, this.delay );
  11988. }
  11989. },
  11990. _panelKeydown: function( event ) {
  11991. if ( this._handlePageNav( event ) ) {
  11992. return;
  11993. }
  11994. // Ctrl+up moves focus to the current tab
  11995. if ( event.ctrlKey && event.keyCode === $.ui.keyCode.UP ) {
  11996. event.preventDefault();
  11997. this.active.focus();
  11998. }
  11999. },
  12000. // Alt+page up/down moves focus to the previous/next tab (and activates)
  12001. _handlePageNav: function( event ) {
  12002. if ( event.altKey && event.keyCode === $.ui.keyCode.PAGE_UP ) {
  12003. this._activate( this._focusNextTab( this.options.active - 1, false ) );
  12004. return true;
  12005. }
  12006. if ( event.altKey && event.keyCode === $.ui.keyCode.PAGE_DOWN ) {
  12007. this._activate( this._focusNextTab( this.options.active + 1, true ) );
  12008. return true;
  12009. }
  12010. },
  12011. _findNextTab: function( index, goingForward ) {
  12012. var lastTabIndex = this.tabs.length - 1;
  12013. function constrain() {
  12014. if ( index > lastTabIndex ) {
  12015. index = 0;
  12016. }
  12017. if ( index < 0 ) {
  12018. index = lastTabIndex;
  12019. }
  12020. return index;
  12021. }
  12022. while ( $.inArray( constrain(), this.options.disabled ) !== -1 ) {
  12023. index = goingForward ? index + 1 : index - 1;
  12024. }
  12025. return index;
  12026. },
  12027. _focusNextTab: function( index, goingForward ) {
  12028. index = this._findNextTab( index, goingForward );
  12029. this.tabs.eq( index ).focus();
  12030. return index;
  12031. },
  12032. _setOption: function( key, value ) {
  12033. if ( key === "active" ) {
  12034. // _activate() will handle invalid values and update this.options
  12035. this._activate( value );
  12036. return;
  12037. }
  12038. if ( key === "disabled" ) {
  12039. // don't use the widget factory's disabled handling
  12040. this._setupDisabled( value );
  12041. return;
  12042. }
  12043. this._super( key, value);
  12044. if ( key === "collapsible" ) {
  12045. this.element.toggleClass( "ui-tabs-collapsible", value );
  12046. // Setting collapsible: false while collapsed; open first panel
  12047. if ( !value && this.options.active === false ) {
  12048. this._activate( 0 );
  12049. }
  12050. }
  12051. if ( key === "event" ) {
  12052. this._setupEvents( value );
  12053. }
  12054. if ( key === "heightStyle" ) {
  12055. this._setupHeightStyle( value );
  12056. }
  12057. },
  12058. _tabId: function( tab ) {
  12059. return tab.attr( "aria-controls" ) || "ui-tabs-" + getNextTabId();
  12060. },
  12061. _sanitizeSelector: function( hash ) {
  12062. return hash ? hash.replace( /[!"$%&'()*+,.\/:;<=>?@\[\]\^`{|}~]/g, "\\$&" ) : "";
  12063. },
  12064. refresh: function() {
  12065. var options = this.options,
  12066. lis = this.tablist.children( ":has(a[href])" );
  12067. // get disabled tabs from class attribute from HTML
  12068. // this will get converted to a boolean if needed in _refresh()
  12069. options.disabled = $.map( lis.filter( ".ui-state-disabled" ), function( tab ) {
  12070. return lis.index( tab );
  12071. });
  12072. this._processTabs();
  12073. // was collapsed or no tabs
  12074. if ( options.active === false || !this.anchors.length ) {
  12075. options.active = false;
  12076. this.active = $();
  12077. // was active, but active tab is gone
  12078. } else if ( this.active.length && !$.contains( this.tablist[ 0 ], this.active[ 0 ] ) ) {
  12079. // all remaining tabs are disabled
  12080. if ( this.tabs.length === options.disabled.length ) {
  12081. options.active = false;
  12082. this.active = $();
  12083. // activate previous tab
  12084. } else {
  12085. this._activate( this._findNextTab( Math.max( 0, options.active - 1 ), false ) );
  12086. }
  12087. // was active, active tab still exists
  12088. } else {
  12089. // make sure active index is correct
  12090. options.active = this.tabs.index( this.active );
  12091. }
  12092. this._refresh();
  12093. },
  12094. _refresh: function() {
  12095. this._setupDisabled( this.options.disabled );
  12096. this._setupEvents( this.options.event );
  12097. this._setupHeightStyle( this.options.heightStyle );
  12098. this.tabs.not( this.active ).attr({
  12099. "aria-selected": "false",
  12100. tabIndex: -1
  12101. });
  12102. this.panels.not( this._getPanelForTab( this.active ) )
  12103. .hide()
  12104. .attr({
  12105. "aria-expanded": "false",
  12106. "aria-hidden": "true"
  12107. });
  12108. // Make sure one tab is in the tab order
  12109. if ( !this.active.length ) {
  12110. this.tabs.eq( 0 ).attr( "tabIndex", 0 );
  12111. } else {
  12112. this.active
  12113. .addClass( "ui-tabs-active ui-state-active" )
  12114. .attr({
  12115. "aria-selected": "true",
  12116. tabIndex: 0
  12117. });
  12118. this._getPanelForTab( this.active )
  12119. .show()
  12120. .attr({
  12121. "aria-expanded": "true",
  12122. "aria-hidden": "false"
  12123. });
  12124. }
  12125. },
  12126. _processTabs: function() {
  12127. var that = this;
  12128. this.tablist = this._getList()
  12129. .addClass( "ui-tabs-nav ui-helper-reset ui-helper-clearfix ui-widget-header ui-corner-all" )
  12130. .attr( "role", "tablist" );
  12131. this.tabs = this.tablist.find( "> li:has(a[href])" )
  12132. .addClass( "ui-state-default ui-corner-top" )
  12133. .attr({
  12134. role: "tab",
  12135. tabIndex: -1
  12136. });
  12137. this.anchors = this.tabs.map(function() {
  12138. return $( "a", this )[ 0 ];
  12139. })
  12140. .addClass( "ui-tabs-anchor" )
  12141. .attr({
  12142. role: "presentation",
  12143. tabIndex: -1
  12144. });
  12145. this.panels = $();
  12146. this.anchors.each(function( i, anchor ) {
  12147. var selector, panel, panelId,
  12148. anchorId = $( anchor ).uniqueId().attr( "id" ),
  12149. tab = $( anchor ).closest( "li" ),
  12150. originalAriaControls = tab.attr( "aria-controls" );
  12151. // inline tab
  12152. if ( isLocal( anchor ) ) {
  12153. selector = anchor.hash;
  12154. panel = that.element.find( that._sanitizeSelector( selector ) );
  12155. // remote tab
  12156. } else {
  12157. panelId = that._tabId( tab );
  12158. selector = "#" + panelId;
  12159. panel = that.element.find( selector );
  12160. if ( !panel.length ) {
  12161. panel = that._createPanel( panelId );
  12162. panel.insertAfter( that.panels[ i - 1 ] || that.tablist );
  12163. }
  12164. panel.attr( "aria-live", "polite" );
  12165. }
  12166. if ( panel.length) {
  12167. that.panels = that.panels.add( panel );
  12168. }
  12169. if ( originalAriaControls ) {
  12170. tab.data( "ui-tabs-aria-controls", originalAriaControls );
  12171. }
  12172. tab.attr({
  12173. "aria-controls": selector.substring( 1 ),
  12174. "aria-labelledby": anchorId
  12175. });
  12176. panel.attr( "aria-labelledby", anchorId );
  12177. });
  12178. this.panels
  12179. .addClass( "ui-tabs-panel ui-widget-content ui-corner-bottom" )
  12180. .attr( "role", "tabpanel" );
  12181. },
  12182. // allow overriding how to find the list for rare usage scenarios (#7715)
  12183. _getList: function() {
  12184. return this.element.find( "ol,ul" ).eq( 0 );
  12185. },
  12186. _createPanel: function( id ) {
  12187. return $( "<div>" )
  12188. .attr( "id", id )
  12189. .addClass( "ui-tabs-panel ui-widget-content ui-corner-bottom" )
  12190. .data( "ui-tabs-destroy", true );
  12191. },
  12192. _setupDisabled: function( disabled ) {
  12193. if ( $.isArray( disabled ) ) {
  12194. if ( !disabled.length ) {
  12195. disabled = false;
  12196. } else if ( disabled.length === this.anchors.length ) {
  12197. disabled = true;
  12198. }
  12199. }
  12200. // disable tabs
  12201. for ( var i = 0, li; ( li = this.tabs[ i ] ); i++ ) {
  12202. if ( disabled === true || $.inArray( i, disabled ) !== -1 ) {
  12203. $( li )
  12204. .addClass( "ui-state-disabled" )
  12205. .attr( "aria-disabled", "true" );
  12206. } else {
  12207. $( li )
  12208. .removeClass( "ui-state-disabled" )
  12209. .removeAttr( "aria-disabled" );
  12210. }
  12211. }
  12212. this.options.disabled = disabled;
  12213. },
  12214. _setupEvents: function( event ) {
  12215. var events = {
  12216. click: function( event ) {
  12217. event.preventDefault();
  12218. }
  12219. };
  12220. if ( event ) {
  12221. $.each( event.split(" "), function( index, eventName ) {
  12222. events[ eventName ] = "_eventHandler";
  12223. });
  12224. }
  12225. this._off( this.anchors.add( this.tabs ).add( this.panels ) );
  12226. this._on( this.anchors, events );
  12227. this._on( this.tabs, { keydown: "_tabKeydown" } );
  12228. this._on( this.panels, { keydown: "_panelKeydown" } );
  12229. this._focusable( this.tabs );
  12230. this._hoverable( this.tabs );
  12231. },
  12232. _setupHeightStyle: function( heightStyle ) {
  12233. var maxHeight,
  12234. parent = this.element.parent();
  12235. if ( heightStyle === "fill" ) {
  12236. maxHeight = parent.height();
  12237. maxHeight -= this.element.outerHeight() - this.element.height();
  12238. this.element.siblings( ":visible" ).each(function() {
  12239. var elem = $( this ),
  12240. position = elem.css( "position" );
  12241. if ( position === "absolute" || position === "fixed" ) {
  12242. return;
  12243. }
  12244. maxHeight -= elem.outerHeight( true );
  12245. });
  12246. this.element.children().not( this.panels ).each(function() {
  12247. maxHeight -= $( this ).outerHeight( true );
  12248. });
  12249. this.panels.each(function() {
  12250. $( this ).height( Math.max( 0, maxHeight -
  12251. $( this ).innerHeight() + $( this ).height() ) );
  12252. })
  12253. .css( "overflow", "auto" );
  12254. } else if ( heightStyle === "auto" ) {
  12255. maxHeight = 0;
  12256. this.panels.each(function() {
  12257. maxHeight = Math.max( maxHeight, $( this ).height( "" ).height() );
  12258. }).height( maxHeight );
  12259. }
  12260. },
  12261. _eventHandler: function( event ) {
  12262. var options = this.options,
  12263. active = this.active,
  12264. anchor = $( event.currentTarget ),
  12265. tab = anchor.closest( "li" ),
  12266. clickedIsActive = tab[ 0 ] === active[ 0 ],
  12267. collapsing = clickedIsActive && options.collapsible,
  12268. toShow = collapsing ? $() : this._getPanelForTab( tab ),
  12269. toHide = !active.length ? $() : this._getPanelForTab( active ),
  12270. eventData = {
  12271. oldTab: active,
  12272. oldPanel: toHide,
  12273. newTab: collapsing ? $() : tab,
  12274. newPanel: toShow
  12275. };
  12276. event.preventDefault();
  12277. if ( tab.hasClass( "ui-state-disabled" ) ||
  12278. // tab is already loading
  12279. tab.hasClass( "ui-tabs-loading" ) ||
  12280. // can't switch durning an animation
  12281. this.running ||
  12282. // click on active header, but not collapsible
  12283. ( clickedIsActive && !options.collapsible ) ||
  12284. // allow canceling activation
  12285. ( this._trigger( "beforeActivate", event, eventData ) === false ) ) {
  12286. return;
  12287. }
  12288. options.active = collapsing ? false : this.tabs.index( tab );
  12289. this.active = clickedIsActive ? $() : tab;
  12290. if ( this.xhr ) {
  12291. this.xhr.abort();
  12292. }
  12293. if ( !toHide.length && !toShow.length ) {
  12294. $.error( "jQuery UI Tabs: Mismatching fragment identifier." );
  12295. }
  12296. if ( toShow.length ) {
  12297. this.load( this.tabs.index( tab ), event );
  12298. }
  12299. this._toggle( event, eventData );
  12300. },
  12301. // handles show/hide for selecting tabs
  12302. _toggle: function( event, eventData ) {
  12303. var that = this,
  12304. toShow = eventData.newPanel,
  12305. toHide = eventData.oldPanel;
  12306. this.running = true;
  12307. function complete() {
  12308. that.running = false;
  12309. that._trigger( "activate", event, eventData );
  12310. }
  12311. function show() {
  12312. eventData.newTab.closest( "li" ).addClass( "ui-tabs-active ui-state-active" );
  12313. if ( toShow.length && that.options.show ) {
  12314. that._show( toShow, that.options.show, complete );
  12315. } else {
  12316. toShow.show();
  12317. complete();
  12318. }
  12319. }
  12320. // start out by hiding, then showing, then completing
  12321. if ( toHide.length && this.options.hide ) {
  12322. this._hide( toHide, this.options.hide, function() {
  12323. eventData.oldTab.closest( "li" ).removeClass( "ui-tabs-active ui-state-active" );
  12324. show();
  12325. });
  12326. } else {
  12327. eventData.oldTab.closest( "li" ).removeClass( "ui-tabs-active ui-state-active" );
  12328. toHide.hide();
  12329. show();
  12330. }
  12331. toHide.attr({
  12332. "aria-expanded": "false",
  12333. "aria-hidden": "true"
  12334. });
  12335. eventData.oldTab.attr( "aria-selected", "false" );
  12336. // If we're switching tabs, remove the old tab from the tab order.
  12337. // If we're opening from collapsed state, remove the previous tab from the tab order.
  12338. // If we're collapsing, then keep the collapsing tab in the tab order.
  12339. if ( toShow.length && toHide.length ) {
  12340. eventData.oldTab.attr( "tabIndex", -1 );
  12341. } else if ( toShow.length ) {
  12342. this.tabs.filter(function() {
  12343. return $( this ).attr( "tabIndex" ) === 0;
  12344. })
  12345. .attr( "tabIndex", -1 );
  12346. }
  12347. toShow.attr({
  12348. "aria-expanded": "true",
  12349. "aria-hidden": "false"
  12350. });
  12351. eventData.newTab.attr({
  12352. "aria-selected": "true",
  12353. tabIndex: 0
  12354. });
  12355. },
  12356. _activate: function( index ) {
  12357. var anchor,
  12358. active = this._findActive( index );
  12359. // trying to activate the already active panel
  12360. if ( active[ 0 ] === this.active[ 0 ] ) {
  12361. return;
  12362. }
  12363. // trying to collapse, simulate a click on the current active header
  12364. if ( !active.length ) {
  12365. active = this.active;
  12366. }
  12367. anchor = active.find( ".ui-tabs-anchor" )[ 0 ];
  12368. this._eventHandler({
  12369. target: anchor,
  12370. currentTarget: anchor,
  12371. preventDefault: $.noop
  12372. });
  12373. },
  12374. _findActive: function( index ) {
  12375. return index === false ? $() : this.tabs.eq( index );
  12376. },
  12377. _getIndex: function( index ) {
  12378. // meta-function to give users option to provide a href string instead of a numerical index.
  12379. if ( typeof index === "string" ) {
  12380. index = this.anchors.index( this.anchors.filter( "[href$='" + index + "']" ) );
  12381. }
  12382. return index;
  12383. },
  12384. _destroy: function() {
  12385. if ( this.xhr ) {
  12386. this.xhr.abort();
  12387. }
  12388. this.element.removeClass( "ui-tabs ui-widget ui-widget-content ui-corner-all ui-tabs-collapsible" );
  12389. this.tablist
  12390. .removeClass( "ui-tabs-nav ui-helper-reset ui-helper-clearfix ui-widget-header ui-corner-all" )
  12391. .removeAttr( "role" );
  12392. this.anchors
  12393. .removeClass( "ui-tabs-anchor" )
  12394. .removeAttr( "role" )
  12395. .removeAttr( "tabIndex" )
  12396. .removeUniqueId();
  12397. this.tabs.add( this.panels ).each(function() {
  12398. if ( $.data( this, "ui-tabs-destroy" ) ) {
  12399. $( this ).remove();
  12400. } else {
  12401. $( this )
  12402. .removeClass( "ui-state-default ui-state-active ui-state-disabled " +
  12403. "ui-corner-top ui-corner-bottom ui-widget-content ui-tabs-active ui-tabs-panel" )
  12404. .removeAttr( "tabIndex" )
  12405. .removeAttr( "aria-live" )
  12406. .removeAttr( "aria-busy" )
  12407. .removeAttr( "aria-selected" )
  12408. .removeAttr( "aria-labelledby" )
  12409. .removeAttr( "aria-hidden" )
  12410. .removeAttr( "aria-expanded" )
  12411. .removeAttr( "role" );
  12412. }
  12413. });
  12414. this.tabs.each(function() {
  12415. var li = $( this ),
  12416. prev = li.data( "ui-tabs-aria-controls" );
  12417. if ( prev ) {
  12418. li
  12419. .attr( "aria-controls", prev )
  12420. .removeData( "ui-tabs-aria-controls" );
  12421. } else {
  12422. li.removeAttr( "aria-controls" );
  12423. }
  12424. });
  12425. this.panels.show();
  12426. if ( this.options.heightStyle !== "content" ) {
  12427. this.panels.css( "height", "" );
  12428. }
  12429. },
  12430. enable: function( index ) {
  12431. var disabled = this.options.disabled;
  12432. if ( disabled === false ) {
  12433. return;
  12434. }
  12435. if ( index === undefined ) {
  12436. disabled = false;
  12437. } else {
  12438. index = this._getIndex( index );
  12439. if ( $.isArray( disabled ) ) {
  12440. disabled = $.map( disabled, function( num ) {
  12441. return num !== index ? num : null;
  12442. });
  12443. } else {
  12444. disabled = $.map( this.tabs, function( li, num ) {
  12445. return num !== index ? num : null;
  12446. });
  12447. }
  12448. }
  12449. this._setupDisabled( disabled );
  12450. },
  12451. disable: function( index ) {
  12452. var disabled = this.options.disabled;
  12453. if ( disabled === true ) {
  12454. return;
  12455. }
  12456. if ( index === undefined ) {
  12457. disabled = true;
  12458. } else {
  12459. index = this._getIndex( index );
  12460. if ( $.inArray( index, disabled ) !== -1 ) {
  12461. return;
  12462. }
  12463. if ( $.isArray( disabled ) ) {
  12464. disabled = $.merge( [ index ], disabled ).sort();
  12465. } else {
  12466. disabled = [ index ];
  12467. }
  12468. }
  12469. this._setupDisabled( disabled );
  12470. },
  12471. load: function( index, event ) {
  12472. index = this._getIndex( index );
  12473. var that = this,
  12474. tab = this.tabs.eq( index ),
  12475. anchor = tab.find( ".ui-tabs-anchor" ),
  12476. panel = this._getPanelForTab( tab ),
  12477. eventData = {
  12478. tab: tab,
  12479. panel: panel
  12480. };
  12481. // not remote
  12482. if ( isLocal( anchor[ 0 ] ) ) {
  12483. return;
  12484. }
  12485. this.xhr = $.ajax( this._ajaxSettings( anchor, event, eventData ) );
  12486. // support: jQuery <1.8
  12487. // jQuery <1.8 returns false if the request is canceled in beforeSend,
  12488. // but as of 1.8, $.ajax() always returns a jqXHR object.
  12489. if ( this.xhr && this.xhr.statusText !== "canceled" ) {
  12490. tab.addClass( "ui-tabs-loading" );
  12491. panel.attr( "aria-busy", "true" );
  12492. this.xhr
  12493. .success(function( response ) {
  12494. // support: jQuery <1.8
  12495. // http://bugs.jquery.com/ticket/11778
  12496. setTimeout(function() {
  12497. panel.html( response );
  12498. that._trigger( "load", event, eventData );
  12499. }, 1 );
  12500. })
  12501. .complete(function( jqXHR, status ) {
  12502. // support: jQuery <1.8
  12503. // http://bugs.jquery.com/ticket/11778
  12504. setTimeout(function() {
  12505. if ( status === "abort" ) {
  12506. that.panels.stop( false, true );
  12507. }
  12508. tab.removeClass( "ui-tabs-loading" );
  12509. panel.removeAttr( "aria-busy" );
  12510. if ( jqXHR === that.xhr ) {
  12511. delete that.xhr;
  12512. }
  12513. }, 1 );
  12514. });
  12515. }
  12516. },
  12517. _ajaxSettings: function( anchor, event, eventData ) {
  12518. var that = this;
  12519. return {
  12520. url: anchor.attr( "href" ),
  12521. beforeSend: function( jqXHR, settings ) {
  12522. return that._trigger( "beforeLoad", event,
  12523. $.extend( { jqXHR : jqXHR, ajaxSettings: settings }, eventData ) );
  12524. }
  12525. };
  12526. },
  12527. _getPanelForTab: function( tab ) {
  12528. var id = $( tab ).attr( "aria-controls" );
  12529. return this.element.find( this._sanitizeSelector( "#" + id ) );
  12530. }
  12531. });
  12532. })( jQuery );
  12533. (function( $ ) {
  12534. var increments = 0;
  12535. function addDescribedBy( elem, id ) {
  12536. var describedby = (elem.attr( "aria-describedby" ) || "").split( /\s+/ );
  12537. describedby.push( id );
  12538. elem
  12539. .data( "ui-tooltip-id", id )
  12540. .attr( "aria-describedby", $.trim( describedby.join( " " ) ) );
  12541. }
  12542. function removeDescribedBy( elem ) {
  12543. var id = elem.data( "ui-tooltip-id" ),
  12544. describedby = (elem.attr( "aria-describedby" ) || "").split( /\s+/ ),
  12545. index = $.inArray( id, describedby );
  12546. if ( index !== -1 ) {
  12547. describedby.splice( index, 1 );
  12548. }
  12549. elem.removeData( "ui-tooltip-id" );
  12550. describedby = $.trim( describedby.join( " " ) );
  12551. if ( describedby ) {
  12552. elem.attr( "aria-describedby", describedby );
  12553. } else {
  12554. elem.removeAttr( "aria-describedby" );
  12555. }
  12556. }
  12557. $.widget( "ui.tooltip", {
  12558. version: "1.10.2",
  12559. options: {
  12560. content: function() {
  12561. // support: IE<9, Opera in jQuery <1.7
  12562. // .text() can't accept undefined, so coerce to a string
  12563. var title = $( this ).attr( "title" ) || "";
  12564. // Escape title, since we're going from an attribute to raw HTML
  12565. return $( "<a>" ).text( title ).html();
  12566. },
  12567. hide: true,
  12568. // Disabled elements have inconsistent behavior across browsers (#8661)
  12569. items: "[title]:not([disabled])",
  12570. position: {
  12571. my: "left top+15",
  12572. at: "left bottom",
  12573. collision: "flipfit flip"
  12574. },
  12575. show: true,
  12576. tooltipClass: null,
  12577. track: false,
  12578. // callbacks
  12579. close: null,
  12580. open: null
  12581. },
  12582. _create: function() {
  12583. this._on({
  12584. mouseover: "open",
  12585. focusin: "open"
  12586. });
  12587. // IDs of generated tooltips, needed for destroy
  12588. this.tooltips = {};
  12589. // IDs of parent tooltips where we removed the title attribute
  12590. this.parents = {};
  12591. if ( this.options.disabled ) {
  12592. this._disable();
  12593. }
  12594. },
  12595. _setOption: function( key, value ) {
  12596. var that = this;
  12597. if ( key === "disabled" ) {
  12598. this[ value ? "_disable" : "_enable" ]();
  12599. this.options[ key ] = value;
  12600. // disable element style changes
  12601. return;
  12602. }
  12603. this._super( key, value );
  12604. if ( key === "content" ) {
  12605. $.each( this.tooltips, function( id, element ) {
  12606. that._updateContent( element );
  12607. });
  12608. }
  12609. },
  12610. _disable: function() {
  12611. var that = this;
  12612. // close open tooltips
  12613. $.each( this.tooltips, function( id, element ) {
  12614. var event = $.Event( "blur" );
  12615. event.target = event.currentTarget = element[0];
  12616. that.close( event, true );
  12617. });
  12618. // remove title attributes to prevent native tooltips
  12619. this.element.find( this.options.items ).addBack().each(function() {
  12620. var element = $( this );
  12621. if ( element.is( "[title]" ) ) {
  12622. element
  12623. .data( "ui-tooltip-title", element.attr( "title" ) )
  12624. .attr( "title", "" );
  12625. }
  12626. });
  12627. },
  12628. _enable: function() {
  12629. // restore title attributes
  12630. this.element.find( this.options.items ).addBack().each(function() {
  12631. var element = $( this );
  12632. if ( element.data( "ui-tooltip-title" ) ) {
  12633. element.attr( "title", element.data( "ui-tooltip-title" ) );
  12634. }
  12635. });
  12636. },
  12637. open: function( event ) {
  12638. var that = this,
  12639. target = $( event ? event.target : this.element )
  12640. // we need closest here due to mouseover bubbling,
  12641. // but always pointing at the same event target
  12642. .closest( this.options.items );
  12643. // No element to show a tooltip for or the tooltip is already open
  12644. if ( !target.length || target.data( "ui-tooltip-id" ) ) {
  12645. return;
  12646. }
  12647. if ( target.attr( "title" ) ) {
  12648. target.data( "ui-tooltip-title", target.attr( "title" ) );
  12649. }
  12650. target.data( "ui-tooltip-open", true );
  12651. // kill parent tooltips, custom or native, for hover
  12652. if ( event && event.type === "mouseover" ) {
  12653. target.parents().each(function() {
  12654. var parent = $( this ),
  12655. blurEvent;
  12656. if ( parent.data( "ui-tooltip-open" ) ) {
  12657. blurEvent = $.Event( "blur" );
  12658. blurEvent.target = blurEvent.currentTarget = this;
  12659. that.close( blurEvent, true );
  12660. }
  12661. if ( parent.attr( "title" ) ) {
  12662. parent.uniqueId();
  12663. that.parents[ this.id ] = {
  12664. element: this,
  12665. title: parent.attr( "title" )
  12666. };
  12667. parent.attr( "title", "" );
  12668. }
  12669. });
  12670. }
  12671. this._updateContent( target, event );
  12672. },
  12673. _updateContent: function( target, event ) {
  12674. var content,
  12675. contentOption = this.options.content,
  12676. that = this,
  12677. eventType = event ? event.type : null;
  12678. if ( typeof contentOption === "string" ) {
  12679. return this._open( event, target, contentOption );
  12680. }
  12681. content = contentOption.call( target[0], function( response ) {
  12682. // ignore async response if tooltip was closed already
  12683. if ( !target.data( "ui-tooltip-open" ) ) {
  12684. return;
  12685. }
  12686. // IE may instantly serve a cached response for ajax requests
  12687. // delay this call to _open so the other call to _open runs first
  12688. that._delay(function() {
  12689. // jQuery creates a special event for focusin when it doesn't
  12690. // exist natively. To improve performance, the native event
  12691. // object is reused and the type is changed. Therefore, we can't
  12692. // rely on the type being correct after the event finished
  12693. // bubbling, so we set it back to the previous value. (#8740)
  12694. if ( event ) {
  12695. event.type = eventType;
  12696. }
  12697. this._open( event, target, response );
  12698. });
  12699. });
  12700. if ( content ) {
  12701. this._open( event, target, content );
  12702. }
  12703. },
  12704. _open: function( event, target, content ) {
  12705. var tooltip, events, delayedShow,
  12706. positionOption = $.extend( {}, this.options.position );
  12707. if ( !content ) {
  12708. return;
  12709. }
  12710. // Content can be updated multiple times. If the tooltip already
  12711. // exists, then just update the content and bail.
  12712. tooltip = this._find( target );
  12713. if ( tooltip.length ) {
  12714. tooltip.find( ".ui-tooltip-content" ).html( content );
  12715. return;
  12716. }
  12717. // if we have a title, clear it to prevent the native tooltip
  12718. // we have to check first to avoid defining a title if none exists
  12719. // (we don't want to cause an element to start matching [title])
  12720. //
  12721. // We use removeAttr only for key events, to allow IE to export the correct
  12722. // accessible attributes. For mouse events, set to empty string to avoid
  12723. // native tooltip showing up (happens only when removing inside mouseover).
  12724. if ( target.is( "[title]" ) ) {
  12725. if ( event && event.type === "mouseover" ) {
  12726. target.attr( "title", "" );
  12727. } else {
  12728. target.removeAttr( "title" );
  12729. }
  12730. }
  12731. tooltip = this._tooltip( target );
  12732. addDescribedBy( target, tooltip.attr( "id" ) );
  12733. tooltip.find( ".ui-tooltip-content" ).html( content );
  12734. function position( event ) {
  12735. positionOption.of = event;
  12736. if ( tooltip.is( ":hidden" ) ) {
  12737. return;
  12738. }
  12739. tooltip.position( positionOption );
  12740. }
  12741. if ( this.options.track && event && /^mouse/.test( event.type ) ) {
  12742. this._on( this.document, {
  12743. mousemove: position
  12744. });
  12745. // trigger once to override element-relative positioning
  12746. position( event );
  12747. } else {
  12748. tooltip.position( $.extend({
  12749. of: target
  12750. }, this.options.position ) );
  12751. }
  12752. tooltip.hide();
  12753. this._show( tooltip, this.options.show );
  12754. // Handle tracking tooltips that are shown with a delay (#8644). As soon
  12755. // as the tooltip is visible, position the tooltip using the most recent
  12756. // event.
  12757. if ( this.options.show && this.options.show.delay ) {
  12758. delayedShow = this.delayedShow = setInterval(function() {
  12759. if ( tooltip.is( ":visible" ) ) {
  12760. position( positionOption.of );
  12761. clearInterval( delayedShow );
  12762. }
  12763. }, $.fx.interval );
  12764. }
  12765. this._trigger( "open", event, { tooltip: tooltip } );
  12766. events = {
  12767. keyup: function( event ) {
  12768. if ( event.keyCode === $.ui.keyCode.ESCAPE ) {
  12769. var fakeEvent = $.Event(event);
  12770. fakeEvent.currentTarget = target[0];
  12771. this.close( fakeEvent, true );
  12772. }
  12773. },
  12774. remove: function() {
  12775. this._removeTooltip( tooltip );
  12776. }
  12777. };
  12778. if ( !event || event.type === "mouseover" ) {
  12779. events.mouseleave = "close";
  12780. }
  12781. if ( !event || event.type === "focusin" ) {
  12782. events.focusout = "close";
  12783. }
  12784. this._on( true, target, events );
  12785. },
  12786. close: function( event ) {
  12787. var that = this,
  12788. target = $( event ? event.currentTarget : this.element ),
  12789. tooltip = this._find( target );
  12790. // disabling closes the tooltip, so we need to track when we're closing
  12791. // to avoid an infinite loop in case the tooltip becomes disabled on close
  12792. if ( this.closing ) {
  12793. return;
  12794. }
  12795. // Clear the interval for delayed tracking tooltips
  12796. clearInterval( this.delayedShow );
  12797. // only set title if we had one before (see comment in _open())
  12798. if ( target.data( "ui-tooltip-title" ) ) {
  12799. target.attr( "title", target.data( "ui-tooltip-title" ) );
  12800. }
  12801. removeDescribedBy( target );
  12802. tooltip.stop( true );
  12803. this._hide( tooltip, this.options.hide, function() {
  12804. that._removeTooltip( $( this ) );
  12805. });
  12806. target.removeData( "ui-tooltip-open" );
  12807. this._off( target, "mouseleave focusout keyup" );
  12808. // Remove 'remove' binding only on delegated targets
  12809. if ( target[0] !== this.element[0] ) {
  12810. this._off( target, "remove" );
  12811. }
  12812. this._off( this.document, "mousemove" );
  12813. if ( event && event.type === "mouseleave" ) {
  12814. $.each( this.parents, function( id, parent ) {
  12815. $( parent.element ).attr( "title", parent.title );
  12816. delete that.parents[ id ];
  12817. });
  12818. }
  12819. this.closing = true;
  12820. this._trigger( "close", event, { tooltip: tooltip } );
  12821. this.closing = false;
  12822. },
  12823. _tooltip: function( element ) {
  12824. var id = "ui-tooltip-" + increments++,
  12825. tooltip = $( "<div>" )
  12826. .attr({
  12827. id: id,
  12828. role: "tooltip"
  12829. })
  12830. .addClass( "ui-tooltip ui-widget ui-corner-all ui-widget-content " +
  12831. ( this.options.tooltipClass || "" ) );
  12832. $( "<div>" )
  12833. .addClass( "ui-tooltip-content" )
  12834. .appendTo( tooltip );
  12835. tooltip.appendTo( this.document[0].body );
  12836. this.tooltips[ id ] = element;
  12837. return tooltip;
  12838. },
  12839. _find: function( target ) {
  12840. var id = target.data( "ui-tooltip-id" );
  12841. return id ? $( "#" + id ) : $();
  12842. },
  12843. _removeTooltip: function( tooltip ) {
  12844. tooltip.remove();
  12845. delete this.tooltips[ tooltip.attr( "id" ) ];
  12846. },
  12847. _destroy: function() {
  12848. var that = this;
  12849. // close open tooltips
  12850. $.each( this.tooltips, function( id, element ) {
  12851. // Delegate to close method to handle common cleanup
  12852. var event = $.Event( "blur" );
  12853. event.target = event.currentTarget = element[0];
  12854. that.close( event, true );
  12855. // Remove immediately; destroying an open tooltip doesn't use the
  12856. // hide animation
  12857. $( "#" + id ).remove();
  12858. // Restore the title
  12859. if ( element.data( "ui-tooltip-title" ) ) {
  12860. element.attr( "title", element.data( "ui-tooltip-title" ) );
  12861. element.removeData( "ui-tooltip-title" );
  12862. }
  12863. });
  12864. }
  12865. });
  12866. }( jQuery ) );