jquery-ui-1.10.3.min.js 426 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008
  1. /*! jQuery UI - v1.10.3 - 2013-05-03
  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.3",
  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 $.widget() extensions 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.3",
  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.3",
  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. this.offsetParent = this.helper.offsetParent();
  952. this.offsetParentCssPosition = this.offsetParent.css( "position" );
  953. //The element's absolute position on the page minus margins
  954. this.offset = this.positionAbs = this.element.offset();
  955. this.offset = {
  956. top: this.offset.top - this.margins.top,
  957. left: this.offset.left - this.margins.left
  958. };
  959. //Reset scroll cache
  960. this.offset.scroll = false;
  961. $.extend(this.offset, {
  962. click: { //Where the click happened, relative to the element
  963. left: event.pageX - this.offset.left,
  964. top: event.pageY - this.offset.top
  965. },
  966. parent: this._getParentOffset(),
  967. relative: this._getRelativeOffset() //This is a relative to absolute position minus the actual position calculation - only used for relative positioned helper
  968. });
  969. //Generate the original position
  970. this.originalPosition = this.position = this._generatePosition(event);
  971. this.originalPageX = event.pageX;
  972. this.originalPageY = event.pageY;
  973. //Adjust the mouse offset relative to the helper if "cursorAt" is supplied
  974. (o.cursorAt && this._adjustOffsetFromHelper(o.cursorAt));
  975. //Set a containment if given in the options
  976. this._setContainment();
  977. //Trigger event + callbacks
  978. if(this._trigger("start", event) === false) {
  979. this._clear();
  980. return false;
  981. }
  982. //Recache the helper size
  983. this._cacheHelperProportions();
  984. //Prepare the droppable offsets
  985. if ($.ui.ddmanager && !o.dropBehaviour) {
  986. $.ui.ddmanager.prepareOffsets(this, event);
  987. }
  988. this._mouseDrag(event, true); //Execute the drag once - this causes the helper not to be visible before getting its correct position
  989. //If the ddmanager is used for droppables, inform the manager that dragging has started (see #5003)
  990. if ( $.ui.ddmanager ) {
  991. $.ui.ddmanager.dragStart(this, event);
  992. }
  993. return true;
  994. },
  995. _mouseDrag: function(event, noPropagation) {
  996. // reset any necessary cached properties (see #5009)
  997. if ( this.offsetParentCssPosition === "fixed" ) {
  998. this.offset.parent = this._getParentOffset();
  999. }
  1000. //Compute the helpers position
  1001. this.position = this._generatePosition(event);
  1002. this.positionAbs = this._convertPositionTo("absolute");
  1003. //Call plugins and callbacks and use the resulting position if something is returned
  1004. if (!noPropagation) {
  1005. var ui = this._uiHash();
  1006. if(this._trigger("drag", event, ui) === false) {
  1007. this._mouseUp({});
  1008. return false;
  1009. }
  1010. this.position = ui.position;
  1011. }
  1012. if(!this.options.axis || this.options.axis !== "y") {
  1013. this.helper[0].style.left = this.position.left+"px";
  1014. }
  1015. if(!this.options.axis || this.options.axis !== "x") {
  1016. this.helper[0].style.top = this.position.top+"px";
  1017. }
  1018. if($.ui.ddmanager) {
  1019. $.ui.ddmanager.drag(this, event);
  1020. }
  1021. return false;
  1022. },
  1023. _mouseStop: function(event) {
  1024. //If we are using droppables, inform the manager about the drop
  1025. var that = this,
  1026. dropped = false;
  1027. if ($.ui.ddmanager && !this.options.dropBehaviour) {
  1028. dropped = $.ui.ddmanager.drop(this, event);
  1029. }
  1030. //if a drop comes from outside (a sortable)
  1031. if(this.dropped) {
  1032. dropped = this.dropped;
  1033. this.dropped = false;
  1034. }
  1035. //if the original element is no longer in the DOM don't bother to continue (see #8269)
  1036. if ( this.options.helper === "original" && !$.contains( this.element[ 0 ].ownerDocument, this.element[ 0 ] ) ) {
  1037. return false;
  1038. }
  1039. 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))) {
  1040. $(this.helper).animate(this.originalPosition, parseInt(this.options.revertDuration, 10), function() {
  1041. if(that._trigger("stop", event) !== false) {
  1042. that._clear();
  1043. }
  1044. });
  1045. } else {
  1046. if(this._trigger("stop", event) !== false) {
  1047. this._clear();
  1048. }
  1049. }
  1050. return false;
  1051. },
  1052. _mouseUp: function(event) {
  1053. //Remove frame helpers
  1054. $("div.ui-draggable-iframeFix").each(function() {
  1055. this.parentNode.removeChild(this);
  1056. });
  1057. //If the ddmanager is used for droppables, inform the manager that dragging has stopped (see #5003)
  1058. if( $.ui.ddmanager ) {
  1059. $.ui.ddmanager.dragStop(this, event);
  1060. }
  1061. return $.ui.mouse.prototype._mouseUp.call(this, event);
  1062. },
  1063. cancel: function() {
  1064. if(this.helper.is(".ui-draggable-dragging")) {
  1065. this._mouseUp({});
  1066. } else {
  1067. this._clear();
  1068. }
  1069. return this;
  1070. },
  1071. _getHandle: function(event) {
  1072. return this.options.handle ?
  1073. !!$( event.target ).closest( this.element.find( this.options.handle ) ).length :
  1074. true;
  1075. },
  1076. _createHelper: function(event) {
  1077. var o = this.options,
  1078. helper = $.isFunction(o.helper) ? $(o.helper.apply(this.element[0], [event])) : (o.helper === "clone" ? this.element.clone().removeAttr("id") : this.element);
  1079. if(!helper.parents("body").length) {
  1080. helper.appendTo((o.appendTo === "parent" ? this.element[0].parentNode : o.appendTo));
  1081. }
  1082. if(helper[0] !== this.element[0] && !(/(fixed|absolute)/).test(helper.css("position"))) {
  1083. helper.css("position", "absolute");
  1084. }
  1085. return helper;
  1086. },
  1087. _adjustOffsetFromHelper: function(obj) {
  1088. if (typeof obj === "string") {
  1089. obj = obj.split(" ");
  1090. }
  1091. if ($.isArray(obj)) {
  1092. obj = {left: +obj[0], top: +obj[1] || 0};
  1093. }
  1094. if ("left" in obj) {
  1095. this.offset.click.left = obj.left + this.margins.left;
  1096. }
  1097. if ("right" in obj) {
  1098. this.offset.click.left = this.helperProportions.width - obj.right + this.margins.left;
  1099. }
  1100. if ("top" in obj) {
  1101. this.offset.click.top = obj.top + this.margins.top;
  1102. }
  1103. if ("bottom" in obj) {
  1104. this.offset.click.top = this.helperProportions.height - obj.bottom + this.margins.top;
  1105. }
  1106. },
  1107. _getParentOffset: function() {
  1108. //Get the offsetParent and cache its position
  1109. var po = this.offsetParent.offset();
  1110. // This is a special case where we need to modify a offset calculated on start, since the following happened:
  1111. // 1. The position of the helper is absolute, so it's position is calculated based on the next positioned parent
  1112. // 2. The actual offset parent is a child of the scroll parent, and the scroll parent isn't the document, which means that
  1113. // the scroll is included in the initial calculation of the offset of the parent, and never recalculated upon drag
  1114. if(this.cssPosition === "absolute" && this.scrollParent[0] !== document && $.contains(this.scrollParent[0], this.offsetParent[0])) {
  1115. po.left += this.scrollParent.scrollLeft();
  1116. po.top += this.scrollParent.scrollTop();
  1117. }
  1118. //This needs to be actually done for all browsers, since pageX/pageY includes this information
  1119. //Ugly IE fix
  1120. if((this.offsetParent[0] === document.body) ||
  1121. (this.offsetParent[0].tagName && this.offsetParent[0].tagName.toLowerCase() === "html" && $.ui.ie)) {
  1122. po = { top: 0, left: 0 };
  1123. }
  1124. return {
  1125. top: po.top + (parseInt(this.offsetParent.css("borderTopWidth"),10) || 0),
  1126. left: po.left + (parseInt(this.offsetParent.css("borderLeftWidth"),10) || 0)
  1127. };
  1128. },
  1129. _getRelativeOffset: function() {
  1130. if(this.cssPosition === "relative") {
  1131. var p = this.element.position();
  1132. return {
  1133. top: p.top - (parseInt(this.helper.css("top"),10) || 0) + this.scrollParent.scrollTop(),
  1134. left: p.left - (parseInt(this.helper.css("left"),10) || 0) + this.scrollParent.scrollLeft()
  1135. };
  1136. } else {
  1137. return { top: 0, left: 0 };
  1138. }
  1139. },
  1140. _cacheMargins: function() {
  1141. this.margins = {
  1142. left: (parseInt(this.element.css("marginLeft"),10) || 0),
  1143. top: (parseInt(this.element.css("marginTop"),10) || 0),
  1144. right: (parseInt(this.element.css("marginRight"),10) || 0),
  1145. bottom: (parseInt(this.element.css("marginBottom"),10) || 0)
  1146. };
  1147. },
  1148. _cacheHelperProportions: function() {
  1149. this.helperProportions = {
  1150. width: this.helper.outerWidth(),
  1151. height: this.helper.outerHeight()
  1152. };
  1153. },
  1154. _setContainment: function() {
  1155. var over, c, ce,
  1156. o = this.options;
  1157. if ( !o.containment ) {
  1158. this.containment = null;
  1159. return;
  1160. }
  1161. if ( o.containment === "window" ) {
  1162. this.containment = [
  1163. $( window ).scrollLeft() - this.offset.relative.left - this.offset.parent.left,
  1164. $( window ).scrollTop() - this.offset.relative.top - this.offset.parent.top,
  1165. $( window ).scrollLeft() + $( window ).width() - this.helperProportions.width - this.margins.left,
  1166. $( window ).scrollTop() + ( $( window ).height() || document.body.parentNode.scrollHeight ) - this.helperProportions.height - this.margins.top
  1167. ];
  1168. return;
  1169. }
  1170. if ( o.containment === "document") {
  1171. this.containment = [
  1172. 0,
  1173. 0,
  1174. $( document ).width() - this.helperProportions.width - this.margins.left,
  1175. ( $( document ).height() || document.body.parentNode.scrollHeight ) - this.helperProportions.height - this.margins.top
  1176. ];
  1177. return;
  1178. }
  1179. if ( o.containment.constructor === Array ) {
  1180. this.containment = o.containment;
  1181. return;
  1182. }
  1183. if ( o.containment === "parent" ) {
  1184. o.containment = this.helper[ 0 ].parentNode;
  1185. }
  1186. c = $( o.containment );
  1187. ce = c[ 0 ];
  1188. if( !ce ) {
  1189. return;
  1190. }
  1191. over = c.css( "overflow" ) !== "hidden";
  1192. this.containment = [
  1193. ( parseInt( c.css( "borderLeftWidth" ), 10 ) || 0 ) + ( parseInt( c.css( "paddingLeft" ), 10 ) || 0 ),
  1194. ( parseInt( c.css( "borderTopWidth" ), 10 ) || 0 ) + ( parseInt( c.css( "paddingTop" ), 10 ) || 0 ) ,
  1195. ( over ? Math.max( ce.scrollWidth, ce.offsetWidth ) : ce.offsetWidth ) - ( parseInt( c.css( "borderRightWidth" ), 10 ) || 0 ) - ( parseInt( c.css( "paddingRight" ), 10 ) || 0 ) - this.helperProportions.width - this.margins.left - this.margins.right,
  1196. ( over ? Math.max( ce.scrollHeight, ce.offsetHeight ) : ce.offsetHeight ) - ( parseInt( c.css( "borderBottomWidth" ), 10 ) || 0 ) - ( parseInt( c.css( "paddingBottom" ), 10 ) || 0 ) - this.helperProportions.height - this.margins.top - this.margins.bottom
  1197. ];
  1198. this.relative_container = c;
  1199. },
  1200. _convertPositionTo: function(d, pos) {
  1201. if(!pos) {
  1202. pos = this.position;
  1203. }
  1204. var mod = d === "absolute" ? 1 : -1,
  1205. scroll = this.cssPosition === "absolute" && !( this.scrollParent[ 0 ] !== document && $.contains( this.scrollParent[ 0 ], this.offsetParent[ 0 ] ) ) ? this.offsetParent : this.scrollParent;
  1206. //Cache the scroll
  1207. if (!this.offset.scroll) {
  1208. this.offset.scroll = {top : scroll.scrollTop(), left : scroll.scrollLeft()};
  1209. }
  1210. return {
  1211. top: (
  1212. pos.top + // The absolute mouse position
  1213. this.offset.relative.top * mod + // Only for relative positioned nodes: Relative offset from element to offset parent
  1214. this.offset.parent.top * mod - // The offsetParent's offset without borders (offset + border)
  1215. ( ( this.cssPosition === "fixed" ? -this.scrollParent.scrollTop() : this.offset.scroll.top ) * mod )
  1216. ),
  1217. left: (
  1218. pos.left + // The absolute mouse position
  1219. this.offset.relative.left * mod + // Only for relative positioned nodes: Relative offset from element to offset parent
  1220. this.offset.parent.left * mod - // The offsetParent's offset without borders (offset + border)
  1221. ( ( this.cssPosition === "fixed" ? -this.scrollParent.scrollLeft() : this.offset.scroll.left ) * mod )
  1222. )
  1223. };
  1224. },
  1225. _generatePosition: function(event) {
  1226. var containment, co, top, left,
  1227. o = this.options,
  1228. scroll = this.cssPosition === "absolute" && !( this.scrollParent[ 0 ] !== document && $.contains( this.scrollParent[ 0 ], this.offsetParent[ 0 ] ) ) ? this.offsetParent : this.scrollParent,
  1229. pageX = event.pageX,
  1230. pageY = event.pageY;
  1231. //Cache the scroll
  1232. if (!this.offset.scroll) {
  1233. this.offset.scroll = {top : scroll.scrollTop(), left : scroll.scrollLeft()};
  1234. }
  1235. /*
  1236. * - Position constraining -
  1237. * Constrain the position to a mix of grid, containment.
  1238. */
  1239. // If we are not dragging yet, we won't check for options
  1240. if ( this.originalPosition ) {
  1241. if ( this.containment ) {
  1242. if ( this.relative_container ){
  1243. co = this.relative_container.offset();
  1244. containment = [
  1245. this.containment[ 0 ] + co.left,
  1246. this.containment[ 1 ] + co.top,
  1247. this.containment[ 2 ] + co.left,
  1248. this.containment[ 3 ] + co.top
  1249. ];
  1250. }
  1251. else {
  1252. containment = this.containment;
  1253. }
  1254. if(event.pageX - this.offset.click.left < containment[0]) {
  1255. pageX = containment[0] + this.offset.click.left;
  1256. }
  1257. if(event.pageY - this.offset.click.top < containment[1]) {
  1258. pageY = containment[1] + this.offset.click.top;
  1259. }
  1260. if(event.pageX - this.offset.click.left > containment[2]) {
  1261. pageX = containment[2] + this.offset.click.left;
  1262. }
  1263. if(event.pageY - this.offset.click.top > containment[3]) {
  1264. pageY = containment[3] + this.offset.click.top;
  1265. }
  1266. }
  1267. if(o.grid) {
  1268. //Check for grid elements set to 0 to prevent divide by 0 error causing invalid argument errors in IE (see ticket #6950)
  1269. top = o.grid[1] ? this.originalPageY + Math.round((pageY - this.originalPageY) / o.grid[1]) * o.grid[1] : this.originalPageY;
  1270. 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;
  1271. left = o.grid[0] ? this.originalPageX + Math.round((pageX - this.originalPageX) / o.grid[0]) * o.grid[0] : this.originalPageX;
  1272. 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;
  1273. }
  1274. }
  1275. return {
  1276. top: (
  1277. pageY - // The absolute mouse position
  1278. this.offset.click.top - // Click offset (relative to the element)
  1279. this.offset.relative.top - // Only for relative positioned nodes: Relative offset from element to offset parent
  1280. this.offset.parent.top + // The offsetParent's offset without borders (offset + border)
  1281. ( this.cssPosition === "fixed" ? -this.scrollParent.scrollTop() : this.offset.scroll.top )
  1282. ),
  1283. left: (
  1284. pageX - // The absolute mouse position
  1285. this.offset.click.left - // Click offset (relative to the element)
  1286. this.offset.relative.left - // Only for relative positioned nodes: Relative offset from element to offset parent
  1287. this.offset.parent.left + // The offsetParent's offset without borders (offset + border)
  1288. ( this.cssPosition === "fixed" ? -this.scrollParent.scrollLeft() : this.offset.scroll.left )
  1289. )
  1290. };
  1291. },
  1292. _clear: function() {
  1293. this.helper.removeClass("ui-draggable-dragging");
  1294. if(this.helper[0] !== this.element[0] && !this.cancelHelperRemoval) {
  1295. this.helper.remove();
  1296. }
  1297. this.helper = null;
  1298. this.cancelHelperRemoval = false;
  1299. },
  1300. // From now on bulk stuff - mainly helpers
  1301. _trigger: function(type, event, ui) {
  1302. ui = ui || this._uiHash();
  1303. $.ui.plugin.call(this, type, [event, ui]);
  1304. //The absolute position has to be recalculated after plugins
  1305. if(type === "drag") {
  1306. this.positionAbs = this._convertPositionTo("absolute");
  1307. }
  1308. return $.Widget.prototype._trigger.call(this, type, event, ui);
  1309. },
  1310. plugins: {},
  1311. _uiHash: function() {
  1312. return {
  1313. helper: this.helper,
  1314. position: this.position,
  1315. originalPosition: this.originalPosition,
  1316. offset: this.positionAbs
  1317. };
  1318. }
  1319. });
  1320. $.ui.plugin.add("draggable", "connectToSortable", {
  1321. start: function(event, ui) {
  1322. var inst = $(this).data("ui-draggable"), o = inst.options,
  1323. uiSortable = $.extend({}, ui, { item: inst.element });
  1324. inst.sortables = [];
  1325. $(o.connectToSortable).each(function() {
  1326. var sortable = $.data(this, "ui-sortable");
  1327. if (sortable && !sortable.options.disabled) {
  1328. inst.sortables.push({
  1329. instance: sortable,
  1330. shouldRevert: sortable.options.revert
  1331. });
  1332. 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).
  1333. sortable._trigger("activate", event, uiSortable);
  1334. }
  1335. });
  1336. },
  1337. stop: function(event, ui) {
  1338. //If we are still over the sortable, we fake the stop event of the sortable, but also remove helper
  1339. var inst = $(this).data("ui-draggable"),
  1340. uiSortable = $.extend({}, ui, { item: inst.element });
  1341. $.each(inst.sortables, function() {
  1342. if(this.instance.isOver) {
  1343. this.instance.isOver = 0;
  1344. inst.cancelHelperRemoval = true; //Don't remove the helper in the draggable instance
  1345. this.instance.cancelHelperRemoval = false; //Remove it in the sortable instance (so sortable plugins like revert still work)
  1346. //The sortable revert is supported, and we have to set a temporary dropped variable on the draggable to support revert: "valid/invalid"
  1347. if(this.shouldRevert) {
  1348. this.instance.options.revert = this.shouldRevert;
  1349. }
  1350. //Trigger the stop of the sortable
  1351. this.instance._mouseStop(event);
  1352. this.instance.options.helper = this.instance.options._helper;
  1353. //If the helper has been the original item, restore properties in the sortable
  1354. if(inst.options.helper === "original") {
  1355. this.instance.currentItem.css({ top: "auto", left: "auto" });
  1356. }
  1357. } else {
  1358. this.instance.cancelHelperRemoval = false; //Remove the helper in the sortable instance
  1359. this.instance._trigger("deactivate", event, uiSortable);
  1360. }
  1361. });
  1362. },
  1363. drag: function(event, ui) {
  1364. var inst = $(this).data("ui-draggable"), that = this;
  1365. $.each(inst.sortables, function() {
  1366. var innermostIntersecting = false,
  1367. thisSortable = this;
  1368. //Copy over some variables to allow calling the sortable's native _intersectsWith
  1369. this.instance.positionAbs = inst.positionAbs;
  1370. this.instance.helperProportions = inst.helperProportions;
  1371. this.instance.offset.click = inst.offset.click;
  1372. if(this.instance._intersectsWith(this.instance.containerCache)) {
  1373. innermostIntersecting = true;
  1374. $.each(inst.sortables, function () {
  1375. this.instance.positionAbs = inst.positionAbs;
  1376. this.instance.helperProportions = inst.helperProportions;
  1377. this.instance.offset.click = inst.offset.click;
  1378. if (this !== thisSortable &&
  1379. this.instance._intersectsWith(this.instance.containerCache) &&
  1380. $.contains(thisSortable.instance.element[0], this.instance.element[0])
  1381. ) {
  1382. innermostIntersecting = false;
  1383. }
  1384. return innermostIntersecting;
  1385. });
  1386. }
  1387. if(innermostIntersecting) {
  1388. //If it intersects, we use a little isOver variable and set it once, so our move-in stuff gets fired only once
  1389. if(!this.instance.isOver) {
  1390. this.instance.isOver = 1;
  1391. //Now we fake the start of dragging for the sortable instance,
  1392. //by cloning the list group item, appending it to the sortable and using it as inst.currentItem
  1393. //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)
  1394. this.instance.currentItem = $(that).clone().removeAttr("id").appendTo(this.instance.element).data("ui-sortable-item", true);
  1395. this.instance.options._helper = this.instance.options.helper; //Store helper option to later restore it
  1396. this.instance.options.helper = function() { return ui.helper[0]; };
  1397. event.target = this.instance.currentItem[0];
  1398. this.instance._mouseCapture(event, true);
  1399. this.instance._mouseStart(event, true, true);
  1400. //Because the browser event is way off the new appended portlet, we modify a couple of variables to reflect the changes
  1401. this.instance.offset.click.top = inst.offset.click.top;
  1402. this.instance.offset.click.left = inst.offset.click.left;
  1403. this.instance.offset.parent.left -= inst.offset.parent.left - this.instance.offset.parent.left;
  1404. this.instance.offset.parent.top -= inst.offset.parent.top - this.instance.offset.parent.top;
  1405. inst._trigger("toSortable", event);
  1406. inst.dropped = this.instance.element; //draggable revert needs that
  1407. //hack so receive/update callbacks work (mostly)
  1408. inst.currentItem = inst.element;
  1409. this.instance.fromOutside = inst;
  1410. }
  1411. //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
  1412. if(this.instance.currentItem) {
  1413. this.instance._mouseDrag(event);
  1414. }
  1415. } else {
  1416. //If it doesn't intersect with the sortable, and it intersected before,
  1417. //we fake the drag stop of the sortable, but make sure it doesn't remove the helper by using cancelHelperRemoval
  1418. if(this.instance.isOver) {
  1419. this.instance.isOver = 0;
  1420. this.instance.cancelHelperRemoval = true;
  1421. //Prevent reverting on this forced stop
  1422. this.instance.options.revert = false;
  1423. // The out event needs to be triggered independently
  1424. this.instance._trigger("out", event, this.instance._uiHash(this.instance));
  1425. this.instance._mouseStop(event, true);
  1426. this.instance.options.helper = this.instance.options._helper;
  1427. //Now we remove our currentItem, the list group clone again, and the placeholder, and animate the helper back to it's original size
  1428. this.instance.currentItem.remove();
  1429. if(this.instance.placeholder) {
  1430. this.instance.placeholder.remove();
  1431. }
  1432. inst._trigger("fromSortable", event);
  1433. inst.dropped = false; //draggable revert needs that
  1434. }
  1435. }
  1436. });
  1437. }
  1438. });
  1439. $.ui.plugin.add("draggable", "cursor", {
  1440. start: function() {
  1441. var t = $("body"), o = $(this).data("ui-draggable").options;
  1442. if (t.css("cursor")) {
  1443. o._cursor = t.css("cursor");
  1444. }
  1445. t.css("cursor", o.cursor);
  1446. },
  1447. stop: function() {
  1448. var o = $(this).data("ui-draggable").options;
  1449. if (o._cursor) {
  1450. $("body").css("cursor", o._cursor);
  1451. }
  1452. }
  1453. });
  1454. $.ui.plugin.add("draggable", "opacity", {
  1455. start: function(event, ui) {
  1456. var t = $(ui.helper), o = $(this).data("ui-draggable").options;
  1457. if(t.css("opacity")) {
  1458. o._opacity = t.css("opacity");
  1459. }
  1460. t.css("opacity", o.opacity);
  1461. },
  1462. stop: function(event, ui) {
  1463. var o = $(this).data("ui-draggable").options;
  1464. if(o._opacity) {
  1465. $(ui.helper).css("opacity", o._opacity);
  1466. }
  1467. }
  1468. });
  1469. $.ui.plugin.add("draggable", "scroll", {
  1470. start: function() {
  1471. var i = $(this).data("ui-draggable");
  1472. if(i.scrollParent[0] !== document && i.scrollParent[0].tagName !== "HTML") {
  1473. i.overflowOffset = i.scrollParent.offset();
  1474. }
  1475. },
  1476. drag: function( event ) {
  1477. var i = $(this).data("ui-draggable"), o = i.options, scrolled = false;
  1478. if(i.scrollParent[0] !== document && i.scrollParent[0].tagName !== "HTML") {
  1479. if(!o.axis || o.axis !== "x") {
  1480. if((i.overflowOffset.top + i.scrollParent[0].offsetHeight) - event.pageY < o.scrollSensitivity) {
  1481. i.scrollParent[0].scrollTop = scrolled = i.scrollParent[0].scrollTop + o.scrollSpeed;
  1482. } else if(event.pageY - i.overflowOffset.top < o.scrollSensitivity) {
  1483. i.scrollParent[0].scrollTop = scrolled = i.scrollParent[0].scrollTop - o.scrollSpeed;
  1484. }
  1485. }
  1486. if(!o.axis || o.axis !== "y") {
  1487. if((i.overflowOffset.left + i.scrollParent[0].offsetWidth) - event.pageX < o.scrollSensitivity) {
  1488. i.scrollParent[0].scrollLeft = scrolled = i.scrollParent[0].scrollLeft + o.scrollSpeed;
  1489. } else if(event.pageX - i.overflowOffset.left < o.scrollSensitivity) {
  1490. i.scrollParent[0].scrollLeft = scrolled = i.scrollParent[0].scrollLeft - o.scrollSpeed;
  1491. }
  1492. }
  1493. } else {
  1494. if(!o.axis || o.axis !== "x") {
  1495. if(event.pageY - $(document).scrollTop() < o.scrollSensitivity) {
  1496. scrolled = $(document).scrollTop($(document).scrollTop() - o.scrollSpeed);
  1497. } else if($(window).height() - (event.pageY - $(document).scrollTop()) < o.scrollSensitivity) {
  1498. scrolled = $(document).scrollTop($(document).scrollTop() + o.scrollSpeed);
  1499. }
  1500. }
  1501. if(!o.axis || o.axis !== "y") {
  1502. if(event.pageX - $(document).scrollLeft() < o.scrollSensitivity) {
  1503. scrolled = $(document).scrollLeft($(document).scrollLeft() - o.scrollSpeed);
  1504. } else if($(window).width() - (event.pageX - $(document).scrollLeft()) < o.scrollSensitivity) {
  1505. scrolled = $(document).scrollLeft($(document).scrollLeft() + o.scrollSpeed);
  1506. }
  1507. }
  1508. }
  1509. if(scrolled !== false && $.ui.ddmanager && !o.dropBehaviour) {
  1510. $.ui.ddmanager.prepareOffsets(i, event);
  1511. }
  1512. }
  1513. });
  1514. $.ui.plugin.add("draggable", "snap", {
  1515. start: function() {
  1516. var i = $(this).data("ui-draggable"),
  1517. o = i.options;
  1518. i.snapElements = [];
  1519. $(o.snap.constructor !== String ? ( o.snap.items || ":data(ui-draggable)" ) : o.snap).each(function() {
  1520. var $t = $(this),
  1521. $o = $t.offset();
  1522. if(this !== i.element[0]) {
  1523. i.snapElements.push({
  1524. item: this,
  1525. width: $t.outerWidth(), height: $t.outerHeight(),
  1526. top: $o.top, left: $o.left
  1527. });
  1528. }
  1529. });
  1530. },
  1531. drag: function(event, ui) {
  1532. var ts, bs, ls, rs, l, r, t, b, i, first,
  1533. inst = $(this).data("ui-draggable"),
  1534. o = inst.options,
  1535. d = o.snapTolerance,
  1536. x1 = ui.offset.left, x2 = x1 + inst.helperProportions.width,
  1537. y1 = ui.offset.top, y2 = y1 + inst.helperProportions.height;
  1538. for (i = inst.snapElements.length - 1; i >= 0; i--){
  1539. l = inst.snapElements[i].left;
  1540. r = l + inst.snapElements[i].width;
  1541. t = inst.snapElements[i].top;
  1542. b = t + inst.snapElements[i].height;
  1543. if ( x2 < l - d || x1 > r + d || y2 < t - d || y1 > b + d || !$.contains( inst.snapElements[ i ].item.ownerDocument, inst.snapElements[ i ].item ) ) {
  1544. if(inst.snapElements[i].snapping) {
  1545. (inst.options.snap.release && inst.options.snap.release.call(inst.element, event, $.extend(inst._uiHash(), { snapItem: inst.snapElements[i].item })));
  1546. }
  1547. inst.snapElements[i].snapping = false;
  1548. continue;
  1549. }
  1550. if(o.snapMode !== "inner") {
  1551. ts = Math.abs(t - y2) <= d;
  1552. bs = Math.abs(b - y1) <= d;
  1553. ls = Math.abs(l - x2) <= d;
  1554. rs = Math.abs(r - x1) <= d;
  1555. if(ts) {
  1556. ui.position.top = inst._convertPositionTo("relative", { top: t - inst.helperProportions.height, left: 0 }).top - inst.margins.top;
  1557. }
  1558. if(bs) {
  1559. ui.position.top = inst._convertPositionTo("relative", { top: b, left: 0 }).top - inst.margins.top;
  1560. }
  1561. if(ls) {
  1562. ui.position.left = inst._convertPositionTo("relative", { top: 0, left: l - inst.helperProportions.width }).left - inst.margins.left;
  1563. }
  1564. if(rs) {
  1565. ui.position.left = inst._convertPositionTo("relative", { top: 0, left: r }).left - inst.margins.left;
  1566. }
  1567. }
  1568. first = (ts || bs || ls || rs);
  1569. if(o.snapMode !== "outer") {
  1570. ts = Math.abs(t - y1) <= d;
  1571. bs = Math.abs(b - y2) <= d;
  1572. ls = Math.abs(l - x1) <= d;
  1573. rs = Math.abs(r - x2) <= d;
  1574. if(ts) {
  1575. ui.position.top = inst._convertPositionTo("relative", { top: t, left: 0 }).top - inst.margins.top;
  1576. }
  1577. if(bs) {
  1578. ui.position.top = inst._convertPositionTo("relative", { top: b - inst.helperProportions.height, left: 0 }).top - inst.margins.top;
  1579. }
  1580. if(ls) {
  1581. ui.position.left = inst._convertPositionTo("relative", { top: 0, left: l }).left - inst.margins.left;
  1582. }
  1583. if(rs) {
  1584. ui.position.left = inst._convertPositionTo("relative", { top: 0, left: r - inst.helperProportions.width }).left - inst.margins.left;
  1585. }
  1586. }
  1587. if(!inst.snapElements[i].snapping && (ts || bs || ls || rs || first)) {
  1588. (inst.options.snap.snap && inst.options.snap.snap.call(inst.element, event, $.extend(inst._uiHash(), { snapItem: inst.snapElements[i].item })));
  1589. }
  1590. inst.snapElements[i].snapping = (ts || bs || ls || rs || first);
  1591. }
  1592. }
  1593. });
  1594. $.ui.plugin.add("draggable", "stack", {
  1595. start: function() {
  1596. var min,
  1597. o = this.data("ui-draggable").options,
  1598. group = $.makeArray($(o.stack)).sort(function(a,b) {
  1599. return (parseInt($(a).css("zIndex"),10) || 0) - (parseInt($(b).css("zIndex"),10) || 0);
  1600. });
  1601. if (!group.length) { return; }
  1602. min = parseInt($(group[0]).css("zIndex"), 10) || 0;
  1603. $(group).each(function(i) {
  1604. $(this).css("zIndex", min + i);
  1605. });
  1606. this.css("zIndex", (min + group.length));
  1607. }
  1608. });
  1609. $.ui.plugin.add("draggable", "zIndex", {
  1610. start: function(event, ui) {
  1611. var t = $(ui.helper), o = $(this).data("ui-draggable").options;
  1612. if(t.css("zIndex")) {
  1613. o._zIndex = t.css("zIndex");
  1614. }
  1615. t.css("zIndex", o.zIndex);
  1616. },
  1617. stop: function(event, ui) {
  1618. var o = $(this).data("ui-draggable").options;
  1619. if(o._zIndex) {
  1620. $(ui.helper).css("zIndex", o._zIndex);
  1621. }
  1622. }
  1623. });
  1624. })(jQuery);
  1625. (function( $, undefined ) {
  1626. function isOverAxis( x, reference, size ) {
  1627. return ( x > reference ) && ( x < ( reference + size ) );
  1628. }
  1629. $.widget("ui.droppable", {
  1630. version: "1.10.3",
  1631. widgetEventPrefix: "drop",
  1632. options: {
  1633. accept: "*",
  1634. activeClass: false,
  1635. addClasses: true,
  1636. greedy: false,
  1637. hoverClass: false,
  1638. scope: "default",
  1639. tolerance: "intersect",
  1640. // callbacks
  1641. activate: null,
  1642. deactivate: null,
  1643. drop: null,
  1644. out: null,
  1645. over: null
  1646. },
  1647. _create: function() {
  1648. var o = this.options,
  1649. accept = o.accept;
  1650. this.isover = false;
  1651. this.isout = true;
  1652. this.accept = $.isFunction(accept) ? accept : function(d) {
  1653. return d.is(accept);
  1654. };
  1655. //Store the droppable's proportions
  1656. this.proportions = { width: this.element[0].offsetWidth, height: this.element[0].offsetHeight };
  1657. // Add the reference and positions to the manager
  1658. $.ui.ddmanager.droppables[o.scope] = $.ui.ddmanager.droppables[o.scope] || [];
  1659. $.ui.ddmanager.droppables[o.scope].push(this);
  1660. (o.addClasses && this.element.addClass("ui-droppable"));
  1661. },
  1662. _destroy: function() {
  1663. var i = 0,
  1664. drop = $.ui.ddmanager.droppables[this.options.scope];
  1665. for ( ; i < drop.length; i++ ) {
  1666. if ( drop[i] === this ) {
  1667. drop.splice(i, 1);
  1668. }
  1669. }
  1670. this.element.removeClass("ui-droppable ui-droppable-disabled");
  1671. },
  1672. _setOption: function(key, value) {
  1673. if(key === "accept") {
  1674. this.accept = $.isFunction(value) ? value : function(d) {
  1675. return d.is(value);
  1676. };
  1677. }
  1678. $.Widget.prototype._setOption.apply(this, arguments);
  1679. },
  1680. _activate: function(event) {
  1681. var draggable = $.ui.ddmanager.current;
  1682. if(this.options.activeClass) {
  1683. this.element.addClass(this.options.activeClass);
  1684. }
  1685. if(draggable){
  1686. this._trigger("activate", event, this.ui(draggable));
  1687. }
  1688. },
  1689. _deactivate: function(event) {
  1690. var draggable = $.ui.ddmanager.current;
  1691. if(this.options.activeClass) {
  1692. this.element.removeClass(this.options.activeClass);
  1693. }
  1694. if(draggable){
  1695. this._trigger("deactivate", event, this.ui(draggable));
  1696. }
  1697. },
  1698. _over: function(event) {
  1699. var draggable = $.ui.ddmanager.current;
  1700. // Bail if draggable and droppable are same element
  1701. if (!draggable || (draggable.currentItem || draggable.element)[0] === this.element[0]) {
  1702. return;
  1703. }
  1704. if (this.accept.call(this.element[0],(draggable.currentItem || draggable.element))) {
  1705. if(this.options.hoverClass) {
  1706. this.element.addClass(this.options.hoverClass);
  1707. }
  1708. this._trigger("over", event, this.ui(draggable));
  1709. }
  1710. },
  1711. _out: function(event) {
  1712. var draggable = $.ui.ddmanager.current;
  1713. // Bail if draggable and droppable are same element
  1714. if (!draggable || (draggable.currentItem || draggable.element)[0] === this.element[0]) {
  1715. return;
  1716. }
  1717. if (this.accept.call(this.element[0],(draggable.currentItem || draggable.element))) {
  1718. if(this.options.hoverClass) {
  1719. this.element.removeClass(this.options.hoverClass);
  1720. }
  1721. this._trigger("out", event, this.ui(draggable));
  1722. }
  1723. },
  1724. _drop: function(event,custom) {
  1725. var draggable = custom || $.ui.ddmanager.current,
  1726. childrenIntersection = false;
  1727. // Bail if draggable and droppable are same element
  1728. if (!draggable || (draggable.currentItem || draggable.element)[0] === this.element[0]) {
  1729. return false;
  1730. }
  1731. this.element.find(":data(ui-droppable)").not(".ui-draggable-dragging").each(function() {
  1732. var inst = $.data(this, "ui-droppable");
  1733. if(
  1734. inst.options.greedy &&
  1735. !inst.options.disabled &&
  1736. inst.options.scope === draggable.options.scope &&
  1737. inst.accept.call(inst.element[0], (draggable.currentItem || draggable.element)) &&
  1738. $.ui.intersect(draggable, $.extend(inst, { offset: inst.element.offset() }), inst.options.tolerance)
  1739. ) { childrenIntersection = true; return false; }
  1740. });
  1741. if(childrenIntersection) {
  1742. return false;
  1743. }
  1744. if(this.accept.call(this.element[0],(draggable.currentItem || draggable.element))) {
  1745. if(this.options.activeClass) {
  1746. this.element.removeClass(this.options.activeClass);
  1747. }
  1748. if(this.options.hoverClass) {
  1749. this.element.removeClass(this.options.hoverClass);
  1750. }
  1751. this._trigger("drop", event, this.ui(draggable));
  1752. return this.element;
  1753. }
  1754. return false;
  1755. },
  1756. ui: function(c) {
  1757. return {
  1758. draggable: (c.currentItem || c.element),
  1759. helper: c.helper,
  1760. position: c.position,
  1761. offset: c.positionAbs
  1762. };
  1763. }
  1764. });
  1765. $.ui.intersect = function(draggable, droppable, toleranceMode) {
  1766. if (!droppable.offset) {
  1767. return false;
  1768. }
  1769. var draggableLeft, draggableTop,
  1770. x1 = (draggable.positionAbs || draggable.position.absolute).left, x2 = x1 + draggable.helperProportions.width,
  1771. y1 = (draggable.positionAbs || draggable.position.absolute).top, y2 = y1 + draggable.helperProportions.height,
  1772. l = droppable.offset.left, r = l + droppable.proportions.width,
  1773. t = droppable.offset.top, b = t + droppable.proportions.height;
  1774. switch (toleranceMode) {
  1775. case "fit":
  1776. return (l <= x1 && x2 <= r && t <= y1 && y2 <= b);
  1777. case "intersect":
  1778. return (l < x1 + (draggable.helperProportions.width / 2) && // Right Half
  1779. x2 - (draggable.helperProportions.width / 2) < r && // Left Half
  1780. t < y1 + (draggable.helperProportions.height / 2) && // Bottom Half
  1781. y2 - (draggable.helperProportions.height / 2) < b ); // Top Half
  1782. case "pointer":
  1783. draggableLeft = ((draggable.positionAbs || draggable.position.absolute).left + (draggable.clickOffset || draggable.offset.click).left);
  1784. draggableTop = ((draggable.positionAbs || draggable.position.absolute).top + (draggable.clickOffset || draggable.offset.click).top);
  1785. return isOverAxis( draggableTop, t, droppable.proportions.height ) && isOverAxis( draggableLeft, l, droppable.proportions.width );
  1786. case "touch":
  1787. return (
  1788. (y1 >= t && y1 <= b) || // Top edge touching
  1789. (y2 >= t && y2 <= b) || // Bottom edge touching
  1790. (y1 < t && y2 > b) // Surrounded vertically
  1791. ) && (
  1792. (x1 >= l && x1 <= r) || // Left edge touching
  1793. (x2 >= l && x2 <= r) || // Right edge touching
  1794. (x1 < l && x2 > r) // Surrounded horizontally
  1795. );
  1796. default:
  1797. return false;
  1798. }
  1799. };
  1800. /*
  1801. This manager tracks offsets of draggables and droppables
  1802. */
  1803. $.ui.ddmanager = {
  1804. current: null,
  1805. droppables: { "default": [] },
  1806. prepareOffsets: function(t, event) {
  1807. var i, j,
  1808. m = $.ui.ddmanager.droppables[t.options.scope] || [],
  1809. type = event ? event.type : null, // workaround for #2317
  1810. list = (t.currentItem || t.element).find(":data(ui-droppable)").addBack();
  1811. droppablesLoop: for (i = 0; i < m.length; i++) {
  1812. //No disabled and non-accepted
  1813. if(m[i].options.disabled || (t && !m[i].accept.call(m[i].element[0],(t.currentItem || t.element)))) {
  1814. continue;
  1815. }
  1816. // Filter out elements in the current dragged item
  1817. for (j=0; j < list.length; j++) {
  1818. if(list[j] === m[i].element[0]) {
  1819. m[i].proportions.height = 0;
  1820. continue droppablesLoop;
  1821. }
  1822. }
  1823. m[i].visible = m[i].element.css("display") !== "none";
  1824. if(!m[i].visible) {
  1825. continue;
  1826. }
  1827. //Activate the droppable if used directly from draggables
  1828. if(type === "mousedown") {
  1829. m[i]._activate.call(m[i], event);
  1830. }
  1831. m[i].offset = m[i].element.offset();
  1832. m[i].proportions = { width: m[i].element[0].offsetWidth, height: m[i].element[0].offsetHeight };
  1833. }
  1834. },
  1835. drop: function(draggable, event) {
  1836. var dropped = false;
  1837. // Create a copy of the droppables in case the list changes during the drop (#9116)
  1838. $.each(($.ui.ddmanager.droppables[draggable.options.scope] || []).slice(), function() {
  1839. if(!this.options) {
  1840. return;
  1841. }
  1842. if (!this.options.disabled && this.visible && $.ui.intersect(draggable, this, this.options.tolerance)) {
  1843. dropped = this._drop.call(this, event) || dropped;
  1844. }
  1845. if (!this.options.disabled && this.visible && this.accept.call(this.element[0],(draggable.currentItem || draggable.element))) {
  1846. this.isout = true;
  1847. this.isover = false;
  1848. this._deactivate.call(this, event);
  1849. }
  1850. });
  1851. return dropped;
  1852. },
  1853. dragStart: function( draggable, event ) {
  1854. //Listen for scrolling so that if the dragging causes scrolling the position of the droppables can be recalculated (see #5003)
  1855. draggable.element.parentsUntil( "body" ).bind( "scroll.droppable", function() {
  1856. if( !draggable.options.refreshPositions ) {
  1857. $.ui.ddmanager.prepareOffsets( draggable, event );
  1858. }
  1859. });
  1860. },
  1861. drag: function(draggable, event) {
  1862. //If you have a highly dynamic page, you might try this option. It renders positions every time you move the mouse.
  1863. if(draggable.options.refreshPositions) {
  1864. $.ui.ddmanager.prepareOffsets(draggable, event);
  1865. }
  1866. //Run through all droppables and check their positions based on specific tolerance options
  1867. $.each($.ui.ddmanager.droppables[draggable.options.scope] || [], function() {
  1868. if(this.options.disabled || this.greedyChild || !this.visible) {
  1869. return;
  1870. }
  1871. var parentInstance, scope, parent,
  1872. intersects = $.ui.intersect(draggable, this, this.options.tolerance),
  1873. c = !intersects && this.isover ? "isout" : (intersects && !this.isover ? "isover" : null);
  1874. if(!c) {
  1875. return;
  1876. }
  1877. if (this.options.greedy) {
  1878. // find droppable parents with same scope
  1879. scope = this.options.scope;
  1880. parent = this.element.parents(":data(ui-droppable)").filter(function () {
  1881. return $.data(this, "ui-droppable").options.scope === scope;
  1882. });
  1883. if (parent.length) {
  1884. parentInstance = $.data(parent[0], "ui-droppable");
  1885. parentInstance.greedyChild = (c === "isover");
  1886. }
  1887. }
  1888. // we just moved into a greedy child
  1889. if (parentInstance && c === "isover") {
  1890. parentInstance.isover = false;
  1891. parentInstance.isout = true;
  1892. parentInstance._out.call(parentInstance, event);
  1893. }
  1894. this[c] = true;
  1895. this[c === "isout" ? "isover" : "isout"] = false;
  1896. this[c === "isover" ? "_over" : "_out"].call(this, event);
  1897. // we just moved out of a greedy child
  1898. if (parentInstance && c === "isout") {
  1899. parentInstance.isout = false;
  1900. parentInstance.isover = true;
  1901. parentInstance._over.call(parentInstance, event);
  1902. }
  1903. });
  1904. },
  1905. dragStop: function( draggable, event ) {
  1906. draggable.element.parentsUntil( "body" ).unbind( "scroll.droppable" );
  1907. //Call prepareOffsets one final time since IE does not fire return scroll events when overflow was caused by drag (see #5003)
  1908. if( !draggable.options.refreshPositions ) {
  1909. $.ui.ddmanager.prepareOffsets( draggable, event );
  1910. }
  1911. }
  1912. };
  1913. })(jQuery);
  1914. (function( $, undefined ) {
  1915. function num(v) {
  1916. return parseInt(v, 10) || 0;
  1917. }
  1918. function isNumber(value) {
  1919. return !isNaN(parseInt(value, 10));
  1920. }
  1921. $.widget("ui.resizable", $.ui.mouse, {
  1922. version: "1.10.3",
  1923. widgetEventPrefix: "resize",
  1924. options: {
  1925. alsoResize: false,
  1926. animate: false,
  1927. animateDuration: "slow",
  1928. animateEasing: "swing",
  1929. aspectRatio: false,
  1930. autoHide: false,
  1931. containment: false,
  1932. ghost: false,
  1933. grid: false,
  1934. handles: "e,s,se",
  1935. helper: false,
  1936. maxHeight: null,
  1937. maxWidth: null,
  1938. minHeight: 10,
  1939. minWidth: 10,
  1940. // See #7960
  1941. zIndex: 90,
  1942. onlyCorner: false,
  1943. // callbacks
  1944. resize: null,
  1945. start: null,
  1946. stop: null
  1947. },
  1948. _create: function() {
  1949. var n, i, handle, axis, hname,
  1950. that = this,
  1951. o = this.options;
  1952. this.element.addClass("ui-resizable");
  1953. $.extend(this, {
  1954. _aspectRatio: !!(o.aspectRatio),
  1955. aspectRatio: o.aspectRatio,
  1956. originalElement: this.element,
  1957. _proportionallyResizeElements: [],
  1958. _helper: o.helper || o.ghost || o.animate ? o.helper || "ui-resizable-helper" : null
  1959. });
  1960. //Wrap the element if it cannot hold child nodes
  1961. if(this.element[0].nodeName.match(/canvas|textarea|input|select|button|img/i)) {
  1962. //Create a wrapper element and set the wrapper to the new current internal element
  1963. this.element.wrap(
  1964. $("<div class='ui-wrapper' style='overflow: hidden;'></div>").css({
  1965. position: this.element.css("position"),
  1966. width: this.element.outerWidth(),
  1967. height: this.element.outerHeight(),
  1968. top: this.element.css("top"),
  1969. left: this.element.css("left")
  1970. })
  1971. );
  1972. //Overwrite the original this.element
  1973. this.element = this.element.parent().data(
  1974. "ui-resizable", this.element.data("ui-resizable")
  1975. );
  1976. this.elementIsWrapper = true;
  1977. //Move margins to the wrapper
  1978. this.element.css({ marginLeft: this.originalElement.css("marginLeft"), marginTop: this.originalElement.css("marginTop"), marginRight: this.originalElement.css("marginRight"), marginBottom: this.originalElement.css("marginBottom") });
  1979. this.originalElement.css({ marginLeft: 0, marginTop: 0, marginRight: 0, marginBottom: 0});
  1980. //Prevent Safari textarea resize
  1981. this.originalResizeStyle = this.originalElement.css("resize");
  1982. this.originalElement.css("resize", "none");
  1983. //Push the actual element to our proportionallyResize internal array
  1984. this._proportionallyResizeElements.push(this.originalElement.css({ position: "static", zoom: 1, display: "block" }));
  1985. // avoid IE jump (hard set the margin)
  1986. this.originalElement.css({ margin: this.originalElement.css("margin") });
  1987. // fix handlers offset
  1988. this._proportionallyResize();
  1989. }
  1990. 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" });
  1991. if(this.handles.constructor === String) {
  1992. if ( this.handles === "all") {
  1993. this.handles = "n,e,s,w,se,sw,ne,nw";
  1994. }
  1995. n = this.handles.split(",");
  1996. this.handles = {};
  1997. for(i = 0; i < n.length; i++) {
  1998. handle = $.trim(n[i]);
  1999. hname = "ui-resizable-"+handle;
  2000. axis = $("<div class='ui-resizable-handle " + hname + "'></div>");
  2001. // Apply zIndex to all handles - see #7960
  2002. axis.css({ zIndex: o.zIndex });
  2003. //TODO : What's going on here?
  2004. if ("se" === handle) {
  2005. axis.addClass("ui-icon ui-icon-gripsmall-diagonal-se");
  2006. }
  2007. //Insert into internal handles object and append to element
  2008. this.handles[handle] = ".ui-resizable-"+handle;
  2009. this.element.append(axis);
  2010. }
  2011. }
  2012. this._renderAxis = function(target) {
  2013. var i, axis, padPos, padWrapper;
  2014. target = target || this.element;
  2015. for(i in this.handles) {
  2016. if(this.handles[i].constructor === String) {
  2017. this.handles[i] = $(this.handles[i], this.element).show();
  2018. }
  2019. //Apply pad to wrapper element, needed to fix axis position (textarea, inputs, scrolls)
  2020. if (this.elementIsWrapper && this.originalElement[0].nodeName.match(/textarea|input|select|button/i)) {
  2021. axis = $(this.handles[i], this.element);
  2022. //Checking the correct pad and border
  2023. padWrapper = /sw|ne|nw|se|n|s/.test(i) ? axis.outerHeight() : axis.outerWidth();
  2024. //The padding type i have to apply...
  2025. padPos = [ "padding",
  2026. /ne|nw|n/.test(i) ? "Top" :
  2027. /se|sw|s/.test(i) ? "Bottom" :
  2028. /^e$/.test(i) ? "Right" : "Left" ].join("");
  2029. target.css(padPos, padWrapper);
  2030. this._proportionallyResize();
  2031. }
  2032. //TODO: What's that good for? There's not anything to be executed left
  2033. if(!$(this.handles[i]).length) {
  2034. continue;
  2035. }
  2036. }
  2037. };
  2038. //TODO: make renderAxis a prototype function
  2039. this._renderAxis(this.element);
  2040. this._handles = $(".ui-resizable-handle", this.element)
  2041. .disableSelection();
  2042. //Matching axis name
  2043. this._handles.mouseover(function() {
  2044. if (!that.resizing) {
  2045. if (this.className) {
  2046. axis = this.className.match(/ui-resizable-(se|sw|ne|nw|n|e|s|w)/i);
  2047. }
  2048. //Axis, default = se
  2049. that.axis = axis && axis[1] ? axis[1] : "se";
  2050. }
  2051. });
  2052. //If we want to auto hide the elements
  2053. if (o.autoHide) {
  2054. this._handles.hide();
  2055. $(this.element)
  2056. .addClass("ui-resizable-autohide")
  2057. .mouseenter(function() {
  2058. if (o.disabled) {
  2059. return;
  2060. }
  2061. $(this).removeClass("ui-resizable-autohide");
  2062. that._handles.show();
  2063. })
  2064. .mouseleave(function(){
  2065. if (o.disabled) {
  2066. return;
  2067. }
  2068. if (!that.resizing) {
  2069. $(this).addClass("ui-resizable-autohide");
  2070. that._handles.hide();
  2071. }
  2072. });
  2073. }
  2074. //Initialize the mouse interaction
  2075. this._mouseInit();
  2076. },
  2077. _destroy: function() {
  2078. this._mouseDestroy();
  2079. var wrapper,
  2080. _destroy = function(exp) {
  2081. $(exp).removeClass("ui-resizable ui-resizable-disabled ui-resizable-resizing")
  2082. .removeData("resizable").removeData("ui-resizable").unbind(".resizable").find(".ui-resizable-handle").remove();
  2083. };
  2084. //TODO: Unwrap at same DOM position
  2085. if (this.elementIsWrapper) {
  2086. _destroy(this.element);
  2087. wrapper = this.element;
  2088. this.originalElement.css({
  2089. position: wrapper.css("position"),
  2090. width: wrapper.outerWidth(),
  2091. height: wrapper.outerHeight(),
  2092. top: wrapper.css("top"),
  2093. left: wrapper.css("left")
  2094. }).insertAfter( wrapper );
  2095. wrapper.remove();
  2096. }
  2097. this.originalElement.css("resize", this.originalResizeStyle);
  2098. _destroy(this.originalElement);
  2099. return this;
  2100. },
  2101. _mouseCapture: function(event) {
  2102. var i, handle,
  2103. capture = false;
  2104. for (i in this.handles) {
  2105. handle = $(this.handles[i])[0];
  2106. if (handle === event.target || $.contains(handle, event.target)) {
  2107. capture = true;
  2108. }
  2109. }
  2110. return !this.options.disabled && capture;
  2111. },
  2112. _mouseStart: function(event) {
  2113. var curleft, curtop, cursor,
  2114. o = this.options,
  2115. iniPos = this.element.position(),
  2116. el = this.element;
  2117. this.resizing = true;
  2118. // bugfix for http://dev.jquery.com/ticket/1749
  2119. if ( (/absolute/).test( el.css("position") ) ) {
  2120. el.css({ position: "absolute", top: el.css("top"), left: el.css("left") });
  2121. } else if (el.is(".ui-draggable")) {
  2122. el.css({ position: "absolute", top: iniPos.top, left: iniPos.left });
  2123. }
  2124. this._renderProxy();
  2125. curleft = num(this.helper.css("left"));
  2126. curtop = num(this.helper.css("top"));
  2127. if (o.containment) {
  2128. curleft += $(o.containment).scrollLeft() || 0;
  2129. curtop += $(o.containment).scrollTop() || 0;
  2130. }
  2131. //Store needed variables
  2132. this.offset = this.helper.offset();
  2133. this.position = { left: curleft, top: curtop };
  2134. this.size = this._helper ? { width: el.outerWidth(), height: el.outerHeight() } : { width: el.width(), height: el.height() };
  2135. this.originalSize = this._helper ? { width: el.outerWidth(), height: el.outerHeight() } : { width: el.width(), height: el.height() };
  2136. this.originalPosition = { left: curleft, top: curtop };
  2137. this.sizeDiff = { width: el.outerWidth() - el.width(), height: el.outerHeight() - el.height() };
  2138. this.originalMousePosition = { left: event.pageX, top: event.pageY };
  2139. //Aspect Ratio
  2140. this.aspectRatio = (typeof o.aspectRatio === "number") ? o.aspectRatio : ((this.originalSize.width / this.originalSize.height) || 1);
  2141. cursor = $(".ui-resizable-" + this.axis).css("cursor");
  2142. $("body").css("cursor", cursor === "auto" ? this.axis + "-resize" : cursor);
  2143. el.addClass("ui-resizable-resizing");
  2144. this._propagate("start", event);
  2145. return true;
  2146. },
  2147. _mouseDrag: function(event) {
  2148. //Increase performance, avoid regex
  2149. var data,
  2150. el = this.helper, props = {},
  2151. smp = this.originalMousePosition,
  2152. a = this.axis,
  2153. prevTop = this.position.top,
  2154. prevLeft = this.position.left,
  2155. prevWidth = this.size.width,
  2156. prevHeight = this.size.height,
  2157. dx = (event.pageX-smp.left)||0,
  2158. dy = (event.pageY-smp.top)||0,
  2159. trigger = this._change[a];
  2160. if (!trigger) {
  2161. return false;
  2162. }
  2163. // Calculate the attrs that will be change
  2164. data = trigger.apply(this, [event, dx, dy]);
  2165. // Put this in the mouseDrag handler since the user can start pressing shift while resizing
  2166. this._updateVirtualBoundaries(event.shiftKey);
  2167. if (this._aspectRatio || event.shiftKey) {
  2168. data = this._updateRatio(data, event);
  2169. }
  2170. data = this._respectSize(data, event);
  2171. this._updateCache(data);
  2172. // plugins callbacks need to be called first
  2173. this._propagate("resize", event);
  2174. if (this.position.top !== prevTop) {
  2175. props.top = this.position.top + "px";
  2176. }
  2177. if (this.position.left !== prevLeft) {
  2178. props.left = this.position.left + "px";
  2179. }
  2180. if (this.size.width !== prevWidth) {
  2181. props.width = this.size.width + "px";
  2182. }
  2183. if (this.size.height !== prevHeight) {
  2184. props.height = this.size.height + "px";
  2185. }
  2186. el.css(props);
  2187. if (!this._helper && this._proportionallyResizeElements.length) {
  2188. this._proportionallyResize();
  2189. }
  2190. // Call the user callback if the element was resized
  2191. if ( ! $.isEmptyObject(props) ) {
  2192. this._trigger("resize", event, this.ui());
  2193. }
  2194. return false;
  2195. },
  2196. _mouseStop: function(event) {
  2197. this.resizing = false;
  2198. var pr, ista, soffseth, soffsetw, s, left, top,
  2199. o = this.options, that = this;
  2200. if(this._helper) {
  2201. pr = this._proportionallyResizeElements;
  2202. ista = pr.length && (/textarea/i).test(pr[0].nodeName);
  2203. soffseth = ista && $.ui.hasScroll(pr[0], "left") /* TODO - jump height */ ? 0 : that.sizeDiff.height;
  2204. soffsetw = ista ? 0 : that.sizeDiff.width;
  2205. s = { width: (that.helper.width() - soffsetw), height: (that.helper.height() - soffseth) };
  2206. left = (parseInt(that.element.css("left"), 10) + (that.position.left - that.originalPosition.left)) || null;
  2207. top = (parseInt(that.element.css("top"), 10) + (that.position.top - that.originalPosition.top)) || null;
  2208. if (!o.animate) {
  2209. this.element.css($.extend(s, { top: top, left: left }));
  2210. }
  2211. that.helper.height(that.size.height);
  2212. that.helper.width(that.size.width);
  2213. if (this._helper && !o.animate) {
  2214. this._proportionallyResize();
  2215. }
  2216. }
  2217. $("body").css("cursor", "auto");
  2218. this.element.removeClass("ui-resizable-resizing");
  2219. this._propagate("stop", event);
  2220. if (this._helper) {
  2221. this.helper.remove();
  2222. }
  2223. return false;
  2224. },
  2225. _updateVirtualBoundaries: function(forceAspectRatio) {
  2226. var pMinWidth, pMaxWidth, pMinHeight, pMaxHeight, b,
  2227. o = this.options;
  2228. b = {
  2229. minWidth: isNumber(o.minWidth) ? o.minWidth : 0,
  2230. maxWidth: isNumber(o.maxWidth) ? o.maxWidth : Infinity,
  2231. minHeight: isNumber(o.minHeight) ? o.minHeight : 0,
  2232. maxHeight: isNumber(o.maxHeight) ? o.maxHeight : Infinity
  2233. };
  2234. if(this._aspectRatio || forceAspectRatio) {
  2235. // We want to create an enclosing box whose aspect ration is the requested one
  2236. // First, compute the "projected" size for each dimension based on the aspect ratio and other dimension
  2237. pMinWidth = b.minHeight * this.aspectRatio;
  2238. pMinHeight = b.minWidth / this.aspectRatio;
  2239. pMaxWidth = b.maxHeight * this.aspectRatio;
  2240. pMaxHeight = b.maxWidth / this.aspectRatio;
  2241. if(pMinWidth > b.minWidth) {
  2242. b.minWidth = pMinWidth;
  2243. }
  2244. if(pMinHeight > b.minHeight) {
  2245. b.minHeight = pMinHeight;
  2246. }
  2247. if(pMaxWidth < b.maxWidth) {
  2248. b.maxWidth = pMaxWidth;
  2249. }
  2250. if(pMaxHeight < b.maxHeight) {
  2251. b.maxHeight = pMaxHeight;
  2252. }
  2253. }
  2254. this._vBoundaries = b;
  2255. },
  2256. _updateCache: function(data) {
  2257. this.offset = this.helper.offset();
  2258. if (isNumber(data.left)) {
  2259. this.position.left = data.left;
  2260. }
  2261. if (isNumber(data.top)) {
  2262. this.position.top = data.top;
  2263. }
  2264. if (isNumber(data.height)) {
  2265. this.size.height = data.height;
  2266. }
  2267. if (isNumber(data.width)) {
  2268. this.size.width = data.width;
  2269. }
  2270. },
  2271. _updateRatio: function( data ) {
  2272. var cpos = this.position,
  2273. csize = this.size,
  2274. a = this.axis;
  2275. // if (isNumber(data.height)) {
  2276. // data.width = (data.height * this.aspectRatio);
  2277. // } else if (isNumber(data.width)) {
  2278. // data.height = (data.width / this.aspectRatio);
  2279. // }
  2280. if (!(this.options.onlyCorner && (a === 'n' || a === 's' || a === 'w' || a === 'e')) && isNumber(data.height)) {
  2281. data.width = (data.height * this.aspectRatio);
  2282. } else if (!(this.options.onlyCorner && (a === 'n' || a === 's' || a === 'w' || a === 'e')) && isNumber(data.width)) {
  2283. data.height = (data.width / this.aspectRatio);
  2284. }
  2285. if (a === "sw") {
  2286. data.left = cpos.left + (csize.width - data.width);
  2287. data.top = null;
  2288. }
  2289. if (a === "nw") {
  2290. data.top = cpos.top + (csize.height - data.height);
  2291. data.left = cpos.left + (csize.width - data.width);
  2292. }
  2293. return data;
  2294. },
  2295. _respectSize: function( data ) {
  2296. var o = this._vBoundaries,
  2297. a = this.axis,
  2298. ismaxw = isNumber(data.width) && o.maxWidth && (o.maxWidth < data.width), ismaxh = isNumber(data.height) && o.maxHeight && (o.maxHeight < data.height),
  2299. isminw = isNumber(data.width) && o.minWidth && (o.minWidth > data.width), isminh = isNumber(data.height) && o.minHeight && (o.minHeight > data.height),
  2300. dw = this.originalPosition.left + this.originalSize.width,
  2301. dh = this.position.top + this.size.height,
  2302. cw = /sw|nw|w/.test(a), ch = /nw|ne|n/.test(a);
  2303. if (isminw) {
  2304. data.width = o.minWidth;
  2305. }
  2306. if (isminh) {
  2307. data.height = o.minHeight;
  2308. }
  2309. if (ismaxw) {
  2310. data.width = o.maxWidth;
  2311. }
  2312. if (ismaxh) {
  2313. data.height = o.maxHeight;
  2314. }
  2315. if (isminw && cw) {
  2316. data.left = dw - o.minWidth;
  2317. }
  2318. if (ismaxw && cw) {
  2319. data.left = dw - o.maxWidth;
  2320. }
  2321. if (isminh && ch) {
  2322. data.top = dh - o.minHeight;
  2323. }
  2324. if (ismaxh && ch) {
  2325. data.top = dh - o.maxHeight;
  2326. }
  2327. // fixing jump error on top/left - bug #2330
  2328. if (!data.width && !data.height && !data.left && data.top) {
  2329. data.top = null;
  2330. } else if (!data.width && !data.height && !data.top && data.left) {
  2331. data.left = null;
  2332. }
  2333. return data;
  2334. },
  2335. _proportionallyResize: function() {
  2336. if (!this._proportionallyResizeElements.length) {
  2337. return;
  2338. }
  2339. var i, j, borders, paddings, prel,
  2340. element = this.helper || this.element;
  2341. for ( i=0; i < this._proportionallyResizeElements.length; i++) {
  2342. prel = this._proportionallyResizeElements[i];
  2343. if (!this.borderDif) {
  2344. this.borderDif = [];
  2345. borders = [prel.css("borderTopWidth"), prel.css("borderRightWidth"), prel.css("borderBottomWidth"), prel.css("borderLeftWidth")];
  2346. paddings = [prel.css("paddingTop"), prel.css("paddingRight"), prel.css("paddingBottom"), prel.css("paddingLeft")];
  2347. for ( j = 0; j < borders.length; j++ ) {
  2348. this.borderDif[ j ] = ( parseInt( borders[ j ], 10 ) || 0 ) + ( parseInt( paddings[ j ], 10 ) || 0 );
  2349. }
  2350. }
  2351. prel.css({
  2352. height: (element.height() - this.borderDif[0] - this.borderDif[2]) || 0,
  2353. width: (element.width() - this.borderDif[1] - this.borderDif[3]) || 0
  2354. });
  2355. }
  2356. },
  2357. _renderProxy: function() {
  2358. var el = this.element, o = this.options;
  2359. this.elementOffset = el.offset();
  2360. if(this._helper) {
  2361. this.helper = this.helper || $("<div style='overflow:hidden;'></div>");
  2362. this.helper.addClass(this._helper).css({
  2363. width: this.element.outerWidth() - 1,
  2364. height: this.element.outerHeight() - 1,
  2365. position: "absolute",
  2366. left: this.elementOffset.left +"px",
  2367. top: this.elementOffset.top +"px",
  2368. zIndex: ++o.zIndex //TODO: Don't modify option
  2369. });
  2370. this.helper
  2371. .appendTo("body")
  2372. .disableSelection();
  2373. } else {
  2374. this.helper = this.element;
  2375. }
  2376. },
  2377. _change: {
  2378. e: function(event, dx) {
  2379. return { width: this.originalSize.width + dx };
  2380. },
  2381. w: function(event, dx) {
  2382. var cs = this.originalSize, sp = this.originalPosition;
  2383. return { left: sp.left + dx, width: cs.width - dx };
  2384. },
  2385. n: function(event, dx, dy) {
  2386. var cs = this.originalSize, sp = this.originalPosition;
  2387. return { top: sp.top + dy, height: cs.height - dy };
  2388. },
  2389. s: function(event, dx, dy) {
  2390. return { height: this.originalSize.height + dy };
  2391. },
  2392. se: function(event, dx, dy) {
  2393. return $.extend(this._change.s.apply(this, arguments), this._change.e.apply(this, [event, dx, dy]));
  2394. },
  2395. sw: function(event, dx, dy) {
  2396. return $.extend(this._change.s.apply(this, arguments), this._change.w.apply(this, [event, dx, dy]));
  2397. },
  2398. ne: function(event, dx, dy) {
  2399. return $.extend(this._change.n.apply(this, arguments), this._change.e.apply(this, [event, dx, dy]));
  2400. },
  2401. nw: function(event, dx, dy) {
  2402. return $.extend(this._change.n.apply(this, arguments), this._change.w.apply(this, [event, dx, dy]));
  2403. }
  2404. },
  2405. _propagate: function(n, event) {
  2406. $.ui.plugin.call(this, n, [event, this.ui()]);
  2407. (n !== "resize" && this._trigger(n, event, this.ui()));
  2408. },
  2409. plugins: {},
  2410. ui: function() {
  2411. return {
  2412. originalElement: this.originalElement,
  2413. element: this.element,
  2414. helper: this.helper,
  2415. position: this.position,
  2416. size: this.size,
  2417. originalSize: this.originalSize,
  2418. originalPosition: this.originalPosition
  2419. };
  2420. }
  2421. });
  2422. /*
  2423. * Resizable Extensions
  2424. */
  2425. $.ui.plugin.add("resizable", "animate", {
  2426. stop: function( event ) {
  2427. var that = $(this).data("ui-resizable"),
  2428. o = that.options,
  2429. pr = that._proportionallyResizeElements,
  2430. ista = pr.length && (/textarea/i).test(pr[0].nodeName),
  2431. soffseth = ista && $.ui.hasScroll(pr[0], "left") /* TODO - jump height */ ? 0 : that.sizeDiff.height,
  2432. soffsetw = ista ? 0 : that.sizeDiff.width,
  2433. style = { width: (that.size.width - soffsetw), height: (that.size.height - soffseth) },
  2434. left = (parseInt(that.element.css("left"), 10) + (that.position.left - that.originalPosition.left)) || null,
  2435. top = (parseInt(that.element.css("top"), 10) + (that.position.top - that.originalPosition.top)) || null;
  2436. that.element.animate(
  2437. $.extend(style, top && left ? { top: top, left: left } : {}), {
  2438. duration: o.animateDuration,
  2439. easing: o.animateEasing,
  2440. step: function() {
  2441. var data = {
  2442. width: parseInt(that.element.css("width"), 10),
  2443. height: parseInt(that.element.css("height"), 10),
  2444. top: parseInt(that.element.css("top"), 10),
  2445. left: parseInt(that.element.css("left"), 10)
  2446. };
  2447. if (pr && pr.length) {
  2448. $(pr[0]).css({ width: data.width, height: data.height });
  2449. }
  2450. // propagating resize, and updating values for each animation step
  2451. that._updateCache(data);
  2452. that._propagate("resize", event);
  2453. }
  2454. }
  2455. );
  2456. }
  2457. });
  2458. $.ui.plugin.add("resizable", "containment", {
  2459. start: function() {
  2460. var element, p, co, ch, cw, width, height,
  2461. that = $(this).data("ui-resizable"),
  2462. o = that.options,
  2463. el = that.element,
  2464. oc = o.containment,
  2465. ce = (oc instanceof $) ? oc.get(0) : (/parent/.test(oc)) ? el.parent().get(0) : oc;
  2466. if (!ce) {
  2467. return;
  2468. }
  2469. that.containerElement = $(ce);
  2470. if (/document/.test(oc) || oc === document) {
  2471. that.containerOffset = { left: 0, top: 0 };
  2472. that.containerPosition = { left: 0, top: 0 };
  2473. that.parentData = {
  2474. element: $(document), left: 0, top: 0,
  2475. width: $(document).width(), height: $(document).height() || document.body.parentNode.scrollHeight
  2476. };
  2477. }
  2478. // i'm a node, so compute top, left, right, bottom
  2479. else {
  2480. element = $(ce);
  2481. p = [];
  2482. $([ "Top", "Right", "Left", "Bottom" ]).each(function(i, name) { p[i] = num(element.css("padding" + name)); });
  2483. that.containerOffset = element.offset();
  2484. that.containerPosition = element.position();
  2485. that.containerSize = { height: (element.innerHeight() - p[3]), width: (element.innerWidth() - p[1]) };
  2486. co = that.containerOffset;
  2487. ch = that.containerSize.height;
  2488. cw = that.containerSize.width;
  2489. width = ($.ui.hasScroll(ce, "left") ? ce.scrollWidth : cw );
  2490. height = ($.ui.hasScroll(ce) ? ce.scrollHeight : ch);
  2491. that.parentData = {
  2492. element: ce, left: co.left, top: co.top, width: width, height: height
  2493. };
  2494. }
  2495. },
  2496. resize: function( event ) {
  2497. var woset, hoset, isParent, isOffsetRelative,
  2498. that = $(this).data("ui-resizable"),
  2499. o = that.options,
  2500. co = that.containerOffset, cp = that.position,
  2501. pRatio = that._aspectRatio || event.shiftKey,
  2502. cop = { top:0, left:0 }, ce = that.containerElement;
  2503. if (ce[0] !== document && (/static/).test(ce.css("position"))) {
  2504. cop = co;
  2505. }
  2506. if (cp.left < (that._helper ? co.left : 0)) {
  2507. that.size.width = that.size.width + (that._helper ? (that.position.left - co.left) : (that.position.left - cop.left));
  2508. if (pRatio) {
  2509. that.size.height = that.size.width / that.aspectRatio;
  2510. }
  2511. that.position.left = o.helper ? co.left : 0;
  2512. }
  2513. if (cp.top < (that._helper ? co.top : 0)) {
  2514. that.size.height = that.size.height + (that._helper ? (that.position.top - co.top) : that.position.top);
  2515. if (pRatio) {
  2516. that.size.width = that.size.height * that.aspectRatio;
  2517. }
  2518. that.position.top = that._helper ? co.top : 0;
  2519. }
  2520. that.offset.left = that.parentData.left+that.position.left;
  2521. that.offset.top = that.parentData.top+that.position.top;
  2522. woset = Math.abs( (that._helper ? that.offset.left - cop.left : (that.offset.left - cop.left)) + that.sizeDiff.width );
  2523. hoset = Math.abs( (that._helper ? that.offset.top - cop.top : (that.offset.top - co.top)) + that.sizeDiff.height );
  2524. isParent = that.containerElement.get(0) === that.element.parent().get(0);
  2525. isOffsetRelative = /relative|absolute/.test(that.containerElement.css("position"));
  2526. if(isParent && isOffsetRelative) {
  2527. woset -= that.parentData.left;
  2528. }
  2529. if (woset + that.size.width >= that.parentData.width) {
  2530. that.size.width = that.parentData.width - woset;
  2531. if (pRatio) {
  2532. that.size.height = that.size.width / that.aspectRatio;
  2533. }
  2534. }
  2535. if (hoset + that.size.height >= that.parentData.height) {
  2536. that.size.height = that.parentData.height - hoset;
  2537. if (pRatio) {
  2538. that.size.width = that.size.height * that.aspectRatio;
  2539. }
  2540. }
  2541. },
  2542. stop: function(){
  2543. var that = $(this).data("ui-resizable"),
  2544. o = that.options,
  2545. co = that.containerOffset,
  2546. cop = that.containerPosition,
  2547. ce = that.containerElement,
  2548. helper = $(that.helper),
  2549. ho = helper.offset(),
  2550. w = helper.outerWidth() - that.sizeDiff.width,
  2551. h = helper.outerHeight() - that.sizeDiff.height;
  2552. if (that._helper && !o.animate && (/relative/).test(ce.css("position"))) {
  2553. $(this).css({ left: ho.left - cop.left - co.left, width: w, height: h });
  2554. }
  2555. if (that._helper && !o.animate && (/static/).test(ce.css("position"))) {
  2556. $(this).css({ left: ho.left - cop.left - co.left, width: w, height: h });
  2557. }
  2558. }
  2559. });
  2560. $.ui.plugin.add("resizable", "alsoResize", {
  2561. start: function () {
  2562. var that = $(this).data("ui-resizable"),
  2563. o = that.options,
  2564. _store = function (exp) {
  2565. $(exp).each(function() {
  2566. var el = $(this);
  2567. el.data("ui-resizable-alsoresize", {
  2568. width: parseInt(el.width(), 10), height: parseInt(el.height(), 10),
  2569. left: parseInt(el.css("left"), 10), top: parseInt(el.css("top"), 10)
  2570. });
  2571. });
  2572. };
  2573. if (typeof(o.alsoResize) === "object" && !o.alsoResize.parentNode) {
  2574. if (o.alsoResize.length) { o.alsoResize = o.alsoResize[0]; _store(o.alsoResize); }
  2575. else { $.each(o.alsoResize, function (exp) { _store(exp); }); }
  2576. }else{
  2577. _store(o.alsoResize);
  2578. }
  2579. },
  2580. resize: function (event, ui) {
  2581. var that = $(this).data("ui-resizable"),
  2582. o = that.options,
  2583. os = that.originalSize,
  2584. op = that.originalPosition,
  2585. delta = {
  2586. height: (that.size.height - os.height) || 0, width: (that.size.width - os.width) || 0,
  2587. top: (that.position.top - op.top) || 0, left: (that.position.left - op.left) || 0
  2588. },
  2589. _alsoResize = function (exp, c) {
  2590. $(exp).each(function() {
  2591. var el = $(this), start = $(this).data("ui-resizable-alsoresize"), style = {},
  2592. css = c && c.length ? c : el.parents(ui.originalElement[0]).length ? ["width", "height"] : ["width", "height", "top", "left"];
  2593. $.each(css, function (i, prop) {
  2594. var sum = (start[prop]||0) + (delta[prop]||0);
  2595. if (sum && sum >= 0) {
  2596. style[prop] = sum || null;
  2597. }
  2598. });
  2599. el.css(style);
  2600. });
  2601. };
  2602. if (typeof(o.alsoResize) === "object" && !o.alsoResize.nodeType) {
  2603. $.each(o.alsoResize, function (exp, c) { _alsoResize(exp, c); });
  2604. }else{
  2605. _alsoResize(o.alsoResize);
  2606. }
  2607. },
  2608. stop: function () {
  2609. $(this).removeData("resizable-alsoresize");
  2610. }
  2611. });
  2612. $.ui.plugin.add("resizable", "ghost", {
  2613. start: function() {
  2614. var that = $(this).data("ui-resizable"), o = that.options, cs = that.size;
  2615. that.ghost = that.originalElement.clone();
  2616. that.ghost
  2617. .css({ opacity: 0.25, display: "block", position: "relative", height: cs.height, width: cs.width, margin: 0, left: 0, top: 0 })
  2618. .addClass("ui-resizable-ghost")
  2619. .addClass(typeof o.ghost === "string" ? o.ghost : "");
  2620. that.ghost.appendTo(that.helper);
  2621. },
  2622. resize: function(){
  2623. var that = $(this).data("ui-resizable");
  2624. if (that.ghost) {
  2625. that.ghost.css({ position: "relative", height: that.size.height, width: that.size.width });
  2626. }
  2627. },
  2628. stop: function() {
  2629. var that = $(this).data("ui-resizable");
  2630. if (that.ghost && that.helper) {
  2631. that.helper.get(0).removeChild(that.ghost.get(0));
  2632. }
  2633. }
  2634. });
  2635. $.ui.plugin.add("resizable", "grid", {
  2636. resize: function() {
  2637. var that = $(this).data("ui-resizable"),
  2638. o = that.options,
  2639. cs = that.size,
  2640. os = that.originalSize,
  2641. op = that.originalPosition,
  2642. a = that.axis,
  2643. grid = typeof o.grid === "number" ? [o.grid, o.grid] : o.grid,
  2644. gridX = (grid[0]||1),
  2645. gridY = (grid[1]||1),
  2646. ox = Math.round((cs.width - os.width) / gridX) * gridX,
  2647. oy = Math.round((cs.height - os.height) / gridY) * gridY,
  2648. newWidth = os.width + ox,
  2649. newHeight = os.height + oy,
  2650. isMaxWidth = o.maxWidth && (o.maxWidth < newWidth),
  2651. isMaxHeight = o.maxHeight && (o.maxHeight < newHeight),
  2652. isMinWidth = o.minWidth && (o.minWidth > newWidth),
  2653. isMinHeight = o.minHeight && (o.minHeight > newHeight);
  2654. o.grid = grid;
  2655. if (isMinWidth) {
  2656. newWidth = newWidth + gridX;
  2657. }
  2658. if (isMinHeight) {
  2659. newHeight = newHeight + gridY;
  2660. }
  2661. if (isMaxWidth) {
  2662. newWidth = newWidth - gridX;
  2663. }
  2664. if (isMaxHeight) {
  2665. newHeight = newHeight - gridY;
  2666. }
  2667. if (/^(se|s|e)$/.test(a)) {
  2668. that.size.width = newWidth;
  2669. that.size.height = newHeight;
  2670. } else if (/^(ne)$/.test(a)) {
  2671. that.size.width = newWidth;
  2672. that.size.height = newHeight;
  2673. that.position.top = op.top - oy;
  2674. } else if (/^(sw)$/.test(a)) {
  2675. that.size.width = newWidth;
  2676. that.size.height = newHeight;
  2677. that.position.left = op.left - ox;
  2678. } else {
  2679. that.size.width = newWidth;
  2680. that.size.height = newHeight;
  2681. that.position.top = op.top - oy;
  2682. that.position.left = op.left - ox;
  2683. }
  2684. }
  2685. });
  2686. })(jQuery);
  2687. (function( $, undefined ) {
  2688. $.widget("ui.selectable", $.ui.mouse, {
  2689. version: "1.10.3",
  2690. options: {
  2691. appendTo: "body",
  2692. autoRefresh: true,
  2693. distance: 0,
  2694. filter: "*",
  2695. tolerance: "touch",
  2696. // callbacks
  2697. selected: null,
  2698. selecting: null,
  2699. start: null,
  2700. stop: null,
  2701. unselected: null,
  2702. unselecting: null
  2703. },
  2704. _create: function() {
  2705. var selectees,
  2706. that = this;
  2707. this.element.addClass("ui-selectable");
  2708. this.dragged = false;
  2709. // cache selectee children based on filter
  2710. this.refresh = function() {
  2711. selectees = $(that.options.filter, that.element[0]);
  2712. selectees.addClass("ui-selectee");
  2713. selectees.each(function() {
  2714. var $this = $(this),
  2715. pos = $this.offset();
  2716. $.data(this, "selectable-item", {
  2717. element: this,
  2718. $element: $this,
  2719. left: pos.left,
  2720. top: pos.top,
  2721. right: pos.left + $this.outerWidth(),
  2722. bottom: pos.top + $this.outerHeight(),
  2723. startselected: false,
  2724. selected: $this.hasClass("ui-selected"),
  2725. selecting: $this.hasClass("ui-selecting"),
  2726. unselecting: $this.hasClass("ui-unselecting")
  2727. });
  2728. });
  2729. };
  2730. this.refresh();
  2731. this.selectees = selectees.addClass("ui-selectee");
  2732. this._mouseInit();
  2733. this.helper = $("<div class='ui-selectable-helper'></div>");
  2734. },
  2735. _destroy: function() {
  2736. this.selectees
  2737. .removeClass("ui-selectee")
  2738. .removeData("selectable-item");
  2739. this.element
  2740. .removeClass("ui-selectable ui-selectable-disabled");
  2741. this._mouseDestroy();
  2742. },
  2743. _mouseStart: function(event) {
  2744. var that = this,
  2745. options = this.options;
  2746. this.opos = [event.pageX, event.pageY];
  2747. if (this.options.disabled) {
  2748. return;
  2749. }
  2750. this.selectees = $(options.filter, this.element[0]);
  2751. this._trigger("start", event);
  2752. $(options.appendTo).append(this.helper);
  2753. // position helper (lasso)
  2754. this.helper.css({
  2755. "left": event.pageX,
  2756. "top": event.pageY,
  2757. "width": 0,
  2758. "height": 0
  2759. });
  2760. if (options.autoRefresh) {
  2761. this.refresh();
  2762. }
  2763. this.selectees.filter(".ui-selected").each(function() {
  2764. var selectee = $.data(this, "selectable-item");
  2765. selectee.startselected = true;
  2766. if (!event.metaKey && !event.ctrlKey) {
  2767. selectee.$element.removeClass("ui-selected");
  2768. selectee.selected = false;
  2769. selectee.$element.addClass("ui-unselecting");
  2770. selectee.unselecting = true;
  2771. // selectable UNSELECTING callback
  2772. that._trigger("unselecting", event, {
  2773. unselecting: selectee.element
  2774. });
  2775. }
  2776. });
  2777. $(event.target).parents().addBack().each(function() {
  2778. var doSelect,
  2779. selectee = $.data(this, "selectable-item");
  2780. if (selectee) {
  2781. doSelect = (!event.metaKey && !event.ctrlKey) || !selectee.$element.hasClass("ui-selected");
  2782. selectee.$element
  2783. .removeClass(doSelect ? "ui-unselecting" : "ui-selected")
  2784. .addClass(doSelect ? "ui-selecting" : "ui-unselecting");
  2785. selectee.unselecting = !doSelect;
  2786. selectee.selecting = doSelect;
  2787. selectee.selected = doSelect;
  2788. // selectable (UN)SELECTING callback
  2789. if (doSelect) {
  2790. that._trigger("selecting", event, {
  2791. selecting: selectee.element
  2792. });
  2793. } else {
  2794. that._trigger("unselecting", event, {
  2795. unselecting: selectee.element
  2796. });
  2797. }
  2798. return false;
  2799. }
  2800. });
  2801. },
  2802. _mouseDrag: function(event) {
  2803. this.dragged = true;
  2804. if (this.options.disabled) {
  2805. return;
  2806. }
  2807. var tmp,
  2808. that = this,
  2809. options = this.options,
  2810. x1 = this.opos[0],
  2811. y1 = this.opos[1],
  2812. x2 = event.pageX,
  2813. y2 = event.pageY;
  2814. if (x1 > x2) { tmp = x2; x2 = x1; x1 = tmp; }
  2815. if (y1 > y2) { tmp = y2; y2 = y1; y1 = tmp; }
  2816. this.helper.css({left: x1, top: y1, width: x2-x1, height: y2-y1});
  2817. this.selectees.each(function() {
  2818. var selectee = $.data(this, "selectable-item"),
  2819. hit = false;
  2820. //prevent helper from being selected if appendTo: selectable
  2821. if (!selectee || selectee.element === that.element[0]) {
  2822. return;
  2823. }
  2824. if (options.tolerance === "touch") {
  2825. hit = ( !(selectee.left > x2 || selectee.right < x1 || selectee.top > y2 || selectee.bottom < y1) );
  2826. } else if (options.tolerance === "fit") {
  2827. hit = (selectee.left > x1 && selectee.right < x2 && selectee.top > y1 && selectee.bottom < y2);
  2828. }
  2829. if (hit) {
  2830. // SELECT
  2831. if (selectee.selected) {
  2832. selectee.$element.removeClass("ui-selected");
  2833. selectee.selected = false;
  2834. }
  2835. if (selectee.unselecting) {
  2836. selectee.$element.removeClass("ui-unselecting");
  2837. selectee.unselecting = false;
  2838. }
  2839. if (!selectee.selecting) {
  2840. selectee.$element.addClass("ui-selecting");
  2841. selectee.selecting = true;
  2842. // selectable SELECTING callback
  2843. that._trigger("selecting", event, {
  2844. selecting: selectee.element
  2845. });
  2846. }
  2847. } else {
  2848. // UNSELECT
  2849. if (selectee.selecting) {
  2850. if ((event.metaKey || event.ctrlKey) && selectee.startselected) {
  2851. selectee.$element.removeClass("ui-selecting");
  2852. selectee.selecting = false;
  2853. selectee.$element.addClass("ui-selected");
  2854. selectee.selected = true;
  2855. } else {
  2856. selectee.$element.removeClass("ui-selecting");
  2857. selectee.selecting = false;
  2858. if (selectee.startselected) {
  2859. selectee.$element.addClass("ui-unselecting");
  2860. selectee.unselecting = true;
  2861. }
  2862. // selectable UNSELECTING callback
  2863. that._trigger("unselecting", event, {
  2864. unselecting: selectee.element
  2865. });
  2866. }
  2867. }
  2868. if (selectee.selected) {
  2869. if (!event.metaKey && !event.ctrlKey && !selectee.startselected) {
  2870. selectee.$element.removeClass("ui-selected");
  2871. selectee.selected = false;
  2872. selectee.$element.addClass("ui-unselecting");
  2873. selectee.unselecting = true;
  2874. // selectable UNSELECTING callback
  2875. that._trigger("unselecting", event, {
  2876. unselecting: selectee.element
  2877. });
  2878. }
  2879. }
  2880. }
  2881. });
  2882. return false;
  2883. },
  2884. _mouseStop: function(event) {
  2885. var that = this;
  2886. this.dragged = false;
  2887. $(".ui-unselecting", this.element[0]).each(function() {
  2888. var selectee = $.data(this, "selectable-item");
  2889. selectee.$element.removeClass("ui-unselecting");
  2890. selectee.unselecting = false;
  2891. selectee.startselected = false;
  2892. that._trigger("unselected", event, {
  2893. unselected: selectee.element
  2894. });
  2895. });
  2896. $(".ui-selecting", this.element[0]).each(function() {
  2897. var selectee = $.data(this, "selectable-item");
  2898. selectee.$element.removeClass("ui-selecting").addClass("ui-selected");
  2899. selectee.selecting = false;
  2900. selectee.selected = true;
  2901. selectee.startselected = true;
  2902. that._trigger("selected", event, {
  2903. selected: selectee.element
  2904. });
  2905. });
  2906. this._trigger("stop", event);
  2907. this.helper.remove();
  2908. return false;
  2909. }
  2910. });
  2911. })(jQuery);
  2912. (function( $, undefined ) {
  2913. /*jshint loopfunc: true */
  2914. function isOverAxis( x, reference, size ) {
  2915. return ( x > reference ) && ( x < ( reference + size ) );
  2916. }
  2917. function isFloating(item) {
  2918. return (/left|right/).test(item.css("float")) || (/inline|table-cell/).test(item.css("display"));
  2919. }
  2920. $.widget("ui.sortable", $.ui.mouse, {
  2921. version: "1.10.3",
  2922. widgetEventPrefix: "sort",
  2923. ready: false,
  2924. options: {
  2925. appendTo: "parent",
  2926. axis: false,
  2927. connectWith: false,
  2928. containment: false,
  2929. cursor: "auto",
  2930. cursorAt: false,
  2931. dropOnEmpty: true,
  2932. forcePlaceholderSize: false,
  2933. forceHelperSize: false,
  2934. grid: false,
  2935. handle: false,
  2936. helper: "original",
  2937. items: "> *",
  2938. opacity: false,
  2939. placeholder: false,
  2940. revert: false,
  2941. scroll: true,
  2942. scrollSensitivity: 20,
  2943. scrollSpeed: 20,
  2944. scope: "default",
  2945. tolerance: "intersect",
  2946. zIndex: 1000,
  2947. // callbacks
  2948. activate: null,
  2949. beforeStop: null,
  2950. change: null,
  2951. deactivate: null,
  2952. out: null,
  2953. over: null,
  2954. receive: null,
  2955. remove: null,
  2956. sort: null,
  2957. start: null,
  2958. stop: null,
  2959. update: null
  2960. },
  2961. _create: function() {
  2962. var o = this.options;
  2963. this.containerCache = {};
  2964. this.element.addClass("ui-sortable");
  2965. //Get the items
  2966. this.refresh();
  2967. //Let's determine if the items are being displayed horizontally
  2968. this.floating = this.items.length ? o.axis === "x" || isFloating(this.items[0].item) : false;
  2969. //Let's determine the parent's offset
  2970. this.offset = this.element.offset();
  2971. //Initialize mouse events for interaction
  2972. this._mouseInit();
  2973. //We're ready to go
  2974. this.ready = true;
  2975. },
  2976. _destroy: function() {
  2977. this.element
  2978. .removeClass("ui-sortable ui-sortable-disabled");
  2979. this._mouseDestroy();
  2980. for ( var i = this.items.length - 1; i >= 0; i-- ) {
  2981. this.items[i].item.removeData(this.widgetName + "-item");
  2982. }
  2983. return this;
  2984. },
  2985. _setOption: function(key, value){
  2986. if ( key === "disabled" ) {
  2987. this.options[ key ] = value;
  2988. this.widget().toggleClass( "ui-sortable-disabled", !!value );
  2989. } else {
  2990. // Don't call widget base _setOption for disable as it adds ui-state-disabled class
  2991. $.Widget.prototype._setOption.apply(this, arguments);
  2992. }
  2993. },
  2994. _mouseCapture: function(event, overrideHandle) {
  2995. var currentItem = null,
  2996. validHandle = false,
  2997. that = this;
  2998. if (this.reverting) {
  2999. return false;
  3000. }
  3001. if(this.options.disabled || this.options.type === "static") {
  3002. return false;
  3003. }
  3004. //We have to refresh the items data once first
  3005. this._refreshItems(event);
  3006. //Find out if the clicked node (or one of its parents) is a actual item in this.items
  3007. $(event.target).parents().each(function() {
  3008. if($.data(this, that.widgetName + "-item") === that) {
  3009. currentItem = $(this);
  3010. return false;
  3011. }
  3012. });
  3013. if($.data(event.target, that.widgetName + "-item") === that) {
  3014. currentItem = $(event.target);
  3015. }
  3016. if(!currentItem) {
  3017. return false;
  3018. }
  3019. if(this.options.handle && !overrideHandle) {
  3020. $(this.options.handle, currentItem).find("*").addBack().each(function() {
  3021. if(this === event.target) {
  3022. validHandle = true;
  3023. }
  3024. });
  3025. if(!validHandle) {
  3026. return false;
  3027. }
  3028. }
  3029. this.currentItem = currentItem;
  3030. this._removeCurrentsFromItems();
  3031. return true;
  3032. },
  3033. _mouseStart: function(event, overrideHandle, noActivation) {
  3034. var i, body,
  3035. o = this.options;
  3036. this.currentContainer = this;
  3037. //We only need to call refreshPositions, because the refreshItems call has been moved to mouseCapture
  3038. this.refreshPositions();
  3039. //Create and append the visible helper
  3040. this.helper = this._createHelper(event);
  3041. //Cache the helper size
  3042. this._cacheHelperProportions();
  3043. /*
  3044. * - Position generation -
  3045. * This block generates everything position related - it's the core of draggables.
  3046. */
  3047. //Cache the margins of the original element
  3048. this._cacheMargins();
  3049. //Get the next scrolling parent
  3050. this.scrollParent = this.helper.scrollParent();
  3051. //The element's absolute position on the page minus margins
  3052. this.offset = this.currentItem.offset();
  3053. this.offset = {
  3054. top: this.offset.top - this.margins.top,
  3055. left: this.offset.left - this.margins.left
  3056. };
  3057. $.extend(this.offset, {
  3058. click: { //Where the click happened, relative to the element
  3059. left: event.pageX - this.offset.left,
  3060. top: event.pageY - this.offset.top
  3061. },
  3062. parent: this._getParentOffset(),
  3063. relative: this._getRelativeOffset() //This is a relative to absolute position minus the actual position calculation - only used for relative positioned helper
  3064. });
  3065. // Only after we got the offset, we can change the helper's position to absolute
  3066. // TODO: Still need to figure out a way to make relative sorting possible
  3067. this.helper.css("position", "absolute");
  3068. this.cssPosition = this.helper.css("position");
  3069. //Generate the original position
  3070. this.originalPosition = this._generatePosition(event);
  3071. this.originalPageX = event.pageX;
  3072. this.originalPageY = event.pageY;
  3073. //Adjust the mouse offset relative to the helper if "cursorAt" is supplied
  3074. (o.cursorAt && this._adjustOffsetFromHelper(o.cursorAt));
  3075. //Cache the former DOM position
  3076. this.domPosition = { prev: this.currentItem.prev()[0], parent: this.currentItem.parent()[0] };
  3077. //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
  3078. if(this.helper[0] !== this.currentItem[0]) {
  3079. this.currentItem.hide();
  3080. }
  3081. //Create the placeholder
  3082. this._createPlaceholder();
  3083. //Set a containment if given in the options
  3084. if(o.containment) {
  3085. this._setContainment();
  3086. }
  3087. if( o.cursor && o.cursor !== "auto" ) { // cursor option
  3088. body = this.document.find( "body" );
  3089. // support: IE
  3090. this.storedCursor = body.css( "cursor" );
  3091. body.css( "cursor", o.cursor );
  3092. this.storedStylesheet = $( "<style>*{ cursor: "+o.cursor+" !important; }</style>" ).appendTo( body );
  3093. }
  3094. if(o.opacity) { // opacity option
  3095. if (this.helper.css("opacity")) {
  3096. this._storedOpacity = this.helper.css("opacity");
  3097. }
  3098. this.helper.css("opacity", o.opacity);
  3099. }
  3100. if(o.zIndex) { // zIndex option
  3101. if (this.helper.css("zIndex")) {
  3102. this._storedZIndex = this.helper.css("zIndex");
  3103. }
  3104. this.helper.css("zIndex", o.zIndex);
  3105. }
  3106. //Prepare scrolling
  3107. if(this.scrollParent[0] !== document && this.scrollParent[0].tagName !== "HTML") {
  3108. this.overflowOffset = this.scrollParent.offset();
  3109. }
  3110. //Call callbacks
  3111. this._trigger("start", event, this._uiHash());
  3112. //Recache the helper size
  3113. if(!this._preserveHelperProportions) {
  3114. this._cacheHelperProportions();
  3115. }
  3116. //Post "activate" events to possible containers
  3117. if( !noActivation ) {
  3118. for ( i = this.containers.length - 1; i >= 0; i-- ) {
  3119. this.containers[ i ]._trigger( "activate", event, this._uiHash( this ) );
  3120. }
  3121. }
  3122. //Prepare possible droppables
  3123. if($.ui.ddmanager) {
  3124. $.ui.ddmanager.current = this;
  3125. }
  3126. if ($.ui.ddmanager && !o.dropBehaviour) {
  3127. $.ui.ddmanager.prepareOffsets(this, event);
  3128. }
  3129. this.dragging = true;
  3130. this.helper.addClass("ui-sortable-helper");
  3131. this._mouseDrag(event); //Execute the drag once - this causes the helper not to be visible before getting its correct position
  3132. return true;
  3133. },
  3134. _mouseDrag: function(event) {
  3135. var i, item, itemElement, intersection,
  3136. o = this.options,
  3137. scrolled = false;
  3138. //Compute the helpers position
  3139. this.position = this._generatePosition(event);
  3140. this.positionAbs = this._convertPositionTo("absolute");
  3141. if (!this.lastPositionAbs) {
  3142. this.lastPositionAbs = this.positionAbs;
  3143. }
  3144. //Do scrolling
  3145. if(this.options.scroll) {
  3146. if(this.scrollParent[0] !== document && this.scrollParent[0].tagName !== "HTML") {
  3147. if((this.overflowOffset.top + this.scrollParent[0].offsetHeight) - event.pageY < o.scrollSensitivity) {
  3148. this.scrollParent[0].scrollTop = scrolled = this.scrollParent[0].scrollTop + o.scrollSpeed;
  3149. } else if(event.pageY - this.overflowOffset.top < o.scrollSensitivity) {
  3150. this.scrollParent[0].scrollTop = scrolled = this.scrollParent[0].scrollTop - o.scrollSpeed;
  3151. }
  3152. if((this.overflowOffset.left + this.scrollParent[0].offsetWidth) - event.pageX < o.scrollSensitivity) {
  3153. this.scrollParent[0].scrollLeft = scrolled = this.scrollParent[0].scrollLeft + o.scrollSpeed;
  3154. } else if(event.pageX - this.overflowOffset.left < o.scrollSensitivity) {
  3155. this.scrollParent[0].scrollLeft = scrolled = this.scrollParent[0].scrollLeft - o.scrollSpeed;
  3156. }
  3157. } else {
  3158. if(event.pageY - $(document).scrollTop() < o.scrollSensitivity) {
  3159. scrolled = $(document).scrollTop($(document).scrollTop() - o.scrollSpeed);
  3160. } else if($(window).height() - (event.pageY - $(document).scrollTop()) < o.scrollSensitivity) {
  3161. scrolled = $(document).scrollTop($(document).scrollTop() + o.scrollSpeed);
  3162. }
  3163. if(event.pageX - $(document).scrollLeft() < o.scrollSensitivity) {
  3164. scrolled = $(document).scrollLeft($(document).scrollLeft() - o.scrollSpeed);
  3165. } else if($(window).width() - (event.pageX - $(document).scrollLeft()) < o.scrollSensitivity) {
  3166. scrolled = $(document).scrollLeft($(document).scrollLeft() + o.scrollSpeed);
  3167. }
  3168. }
  3169. if(scrolled !== false && $.ui.ddmanager && !o.dropBehaviour) {
  3170. $.ui.ddmanager.prepareOffsets(this, event);
  3171. }
  3172. }
  3173. //Regenerate the absolute position used for position checks
  3174. this.positionAbs = this._convertPositionTo("absolute");
  3175. //Set the helper position
  3176. if(!this.options.axis || this.options.axis !== "y") {
  3177. this.helper[0].style.left = this.position.left+"px";
  3178. }
  3179. if(!this.options.axis || this.options.axis !== "x") {
  3180. this.helper[0].style.top = this.position.top+"px";
  3181. }
  3182. //Rearrange
  3183. for (i = this.items.length - 1; i >= 0; i--) {
  3184. //Cache variables and intersection, continue if no intersection
  3185. item = this.items[i];
  3186. itemElement = item.item[0];
  3187. intersection = this._intersectsWithPointer(item);
  3188. if (!intersection) {
  3189. continue;
  3190. }
  3191. // Only put the placeholder inside the current Container, skip all
  3192. // items form other containers. This works because when moving
  3193. // an item from one container to another the
  3194. // currentContainer is switched before the placeholder is moved.
  3195. //
  3196. // Without this moving items in "sub-sortables" can cause the placeholder to jitter
  3197. // beetween the outer and inner container.
  3198. if (item.instance !== this.currentContainer) {
  3199. continue;
  3200. }
  3201. // cannot intersect with itself
  3202. // no useless actions that have been done before
  3203. // no action if the item moved is the parent of the item checked
  3204. if (itemElement !== this.currentItem[0] &&
  3205. this.placeholder[intersection === 1 ? "next" : "prev"]()[0] !== itemElement &&
  3206. !$.contains(this.placeholder[0], itemElement) &&
  3207. (this.options.type === "semi-dynamic" ? !$.contains(this.element[0], itemElement) : true)
  3208. ) {
  3209. this.direction = intersection === 1 ? "down" : "up";
  3210. if (this.options.tolerance === "pointer" || this._intersectsWithSides(item)) {
  3211. this._rearrange(event, item);
  3212. } else {
  3213. break;
  3214. }
  3215. this._trigger("change", event, this._uiHash());
  3216. break;
  3217. }
  3218. }
  3219. //Post events to containers
  3220. this._contactContainers(event);
  3221. //Interconnect with droppables
  3222. if($.ui.ddmanager) {
  3223. $.ui.ddmanager.drag(this, event);
  3224. }
  3225. //Call callbacks
  3226. this._trigger("sort", event, this._uiHash());
  3227. this.lastPositionAbs = this.positionAbs;
  3228. return false;
  3229. },
  3230. _mouseStop: function(event, noPropagation) {
  3231. if(!event) {
  3232. return;
  3233. }
  3234. //If we are using droppables, inform the manager about the drop
  3235. if ($.ui.ddmanager && !this.options.dropBehaviour) {
  3236. $.ui.ddmanager.drop(this, event);
  3237. }
  3238. if(this.options.revert) {
  3239. var that = this,
  3240. cur = this.placeholder.offset(),
  3241. axis = this.options.axis,
  3242. animation = {};
  3243. if ( !axis || axis === "x" ) {
  3244. animation.left = cur.left - this.offset.parent.left - this.margins.left + (this.offsetParent[0] === document.body ? 0 : this.offsetParent[0].scrollLeft);
  3245. }
  3246. if ( !axis || axis === "y" ) {
  3247. animation.top = cur.top - this.offset.parent.top - this.margins.top + (this.offsetParent[0] === document.body ? 0 : this.offsetParent[0].scrollTop);
  3248. }
  3249. this.reverting = true;
  3250. $(this.helper).animate( animation, parseInt(this.options.revert, 10) || 500, function() {
  3251. that._clear(event);
  3252. });
  3253. } else {
  3254. this._clear(event, noPropagation);
  3255. }
  3256. return false;
  3257. },
  3258. cancel: function() {
  3259. if(this.dragging) {
  3260. this._mouseUp({ target: null });
  3261. if(this.options.helper === "original") {
  3262. this.currentItem.css(this._storedCSS).removeClass("ui-sortable-helper");
  3263. } else {
  3264. this.currentItem.show();
  3265. }
  3266. //Post deactivating events to containers
  3267. for (var i = this.containers.length - 1; i >= 0; i--){
  3268. this.containers[i]._trigger("deactivate", null, this._uiHash(this));
  3269. if(this.containers[i].containerCache.over) {
  3270. this.containers[i]._trigger("out", null, this._uiHash(this));
  3271. this.containers[i].containerCache.over = 0;
  3272. }
  3273. }
  3274. }
  3275. if (this.placeholder) {
  3276. //$(this.placeholder[0]).remove(); would have been the jQuery way - unfortunately, it unbinds ALL events from the original node!
  3277. if(this.placeholder[0].parentNode) {
  3278. this.placeholder[0].parentNode.removeChild(this.placeholder[0]);
  3279. }
  3280. if(this.options.helper !== "original" && this.helper && this.helper[0].parentNode) {
  3281. this.helper.remove();
  3282. }
  3283. $.extend(this, {
  3284. helper: null,
  3285. dragging: false,
  3286. reverting: false,
  3287. _noFinalSort: null
  3288. });
  3289. if(this.domPosition.prev) {
  3290. $(this.domPosition.prev).after(this.currentItem);
  3291. } else {
  3292. $(this.domPosition.parent).prepend(this.currentItem);
  3293. }
  3294. }
  3295. return this;
  3296. },
  3297. serialize: function(o) {
  3298. var items = this._getItemsAsjQuery(o && o.connected),
  3299. str = [];
  3300. o = o || {};
  3301. $(items).each(function() {
  3302. var res = ($(o.item || this).attr(o.attribute || "id") || "").match(o.expression || (/(.+)[\-=_](.+)/));
  3303. if (res) {
  3304. str.push((o.key || res[1]+"[]")+"="+(o.key && o.expression ? res[1] : res[2]));
  3305. }
  3306. });
  3307. if(!str.length && o.key) {
  3308. str.push(o.key + "=");
  3309. }
  3310. return str.join("&");
  3311. },
  3312. toArray: function(o) {
  3313. var items = this._getItemsAsjQuery(o && o.connected),
  3314. ret = [];
  3315. o = o || {};
  3316. items.each(function() { ret.push($(o.item || this).attr(o.attribute || "id") || ""); });
  3317. return ret;
  3318. },
  3319. /* Be careful with the following core functions */
  3320. _intersectsWith: function(item) {
  3321. var x1 = this.positionAbs.left,
  3322. x2 = x1 + this.helperProportions.width,
  3323. y1 = this.positionAbs.top,
  3324. y2 = y1 + this.helperProportions.height,
  3325. l = item.left,
  3326. r = l + item.width,
  3327. t = item.top,
  3328. b = t + item.height,
  3329. dyClick = this.offset.click.top,
  3330. dxClick = this.offset.click.left,
  3331. isOverElementHeight = ( this.options.axis === "x" ) || ( ( y1 + dyClick ) > t && ( y1 + dyClick ) < b ),
  3332. isOverElementWidth = ( this.options.axis === "y" ) || ( ( x1 + dxClick ) > l && ( x1 + dxClick ) < r ),
  3333. isOverElement = isOverElementHeight && isOverElementWidth;
  3334. if ( this.options.tolerance === "pointer" ||
  3335. this.options.forcePointerForContainers ||
  3336. (this.options.tolerance !== "pointer" && this.helperProportions[this.floating ? "width" : "height"] > item[this.floating ? "width" : "height"])
  3337. ) {
  3338. return isOverElement;
  3339. } else {
  3340. return (l < x1 + (this.helperProportions.width / 2) && // Right Half
  3341. x2 - (this.helperProportions.width / 2) < r && // Left Half
  3342. t < y1 + (this.helperProportions.height / 2) && // Bottom Half
  3343. y2 - (this.helperProportions.height / 2) < b ); // Top Half
  3344. }
  3345. },
  3346. _intersectsWithPointer: function(item) {
  3347. var isOverElementHeight = (this.options.axis === "x") || isOverAxis(this.positionAbs.top + this.offset.click.top, item.top, item.height),
  3348. isOverElementWidth = (this.options.axis === "y") || isOverAxis(this.positionAbs.left + this.offset.click.left, item.left, item.width),
  3349. isOverElement = isOverElementHeight && isOverElementWidth,
  3350. verticalDirection = this._getDragVerticalDirection(),
  3351. horizontalDirection = this._getDragHorizontalDirection();
  3352. if (!isOverElement) {
  3353. return false;
  3354. }
  3355. return this.floating ?
  3356. ( ((horizontalDirection && horizontalDirection === "right") || verticalDirection === "down") ? 2 : 1 )
  3357. : ( verticalDirection && (verticalDirection === "down" ? 2 : 1) );
  3358. },
  3359. _intersectsWithSides: function(item) {
  3360. var isOverBottomHalf = isOverAxis(this.positionAbs.top + this.offset.click.top, item.top + (item.height/2), item.height),
  3361. isOverRightHalf = isOverAxis(this.positionAbs.left + this.offset.click.left, item.left + (item.width/2), item.width),
  3362. verticalDirection = this._getDragVerticalDirection(),
  3363. horizontalDirection = this._getDragHorizontalDirection();
  3364. if (this.floating && horizontalDirection) {
  3365. return ((horizontalDirection === "right" && isOverRightHalf) || (horizontalDirection === "left" && !isOverRightHalf));
  3366. } else {
  3367. return verticalDirection && ((verticalDirection === "down" && isOverBottomHalf) || (verticalDirection === "up" && !isOverBottomHalf));
  3368. }
  3369. },
  3370. _getDragVerticalDirection: function() {
  3371. var delta = this.positionAbs.top - this.lastPositionAbs.top;
  3372. return delta !== 0 && (delta > 0 ? "down" : "up");
  3373. },
  3374. _getDragHorizontalDirection: function() {
  3375. var delta = this.positionAbs.left - this.lastPositionAbs.left;
  3376. return delta !== 0 && (delta > 0 ? "right" : "left");
  3377. },
  3378. refresh: function(event) {
  3379. this._refreshItems(event);
  3380. this.refreshPositions();
  3381. return this;
  3382. },
  3383. _connectWith: function() {
  3384. var options = this.options;
  3385. return options.connectWith.constructor === String ? [options.connectWith] : options.connectWith;
  3386. },
  3387. _getItemsAsjQuery: function(connected) {
  3388. var i, j, cur, inst,
  3389. items = [],
  3390. queries = [],
  3391. connectWith = this._connectWith();
  3392. if(connectWith && connected) {
  3393. for (i = connectWith.length - 1; i >= 0; i--){
  3394. cur = $(connectWith[i]);
  3395. for ( j = cur.length - 1; j >= 0; j--){
  3396. inst = $.data(cur[j], this.widgetFullName);
  3397. if(inst && inst !== this && !inst.options.disabled) {
  3398. 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]);
  3399. }
  3400. }
  3401. }
  3402. }
  3403. 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]);
  3404. for (i = queries.length - 1; i >= 0; i--){
  3405. queries[i][0].each(function() {
  3406. items.push(this);
  3407. });
  3408. }
  3409. return $(items);
  3410. },
  3411. _removeCurrentsFromItems: function() {
  3412. var list = this.currentItem.find(":data(" + this.widgetName + "-item)");
  3413. this.items = $.grep(this.items, function (item) {
  3414. for (var j=0; j < list.length; j++) {
  3415. if(list[j] === item.item[0]) {
  3416. return false;
  3417. }
  3418. }
  3419. return true;
  3420. });
  3421. },
  3422. _refreshItems: function(event) {
  3423. this.items = [];
  3424. this.containers = [this];
  3425. var i, j, cur, inst, targetData, _queries, item, queriesLength,
  3426. items = this.items,
  3427. queries = [[$.isFunction(this.options.items) ? this.options.items.call(this.element[0], event, { item: this.currentItem }) : $(this.options.items, this.element), this]],
  3428. connectWith = this._connectWith();
  3429. if(connectWith && this.ready) { //Shouldn't be run the first time through due to massive slow-down
  3430. for (i = connectWith.length - 1; i >= 0; i--){
  3431. cur = $(connectWith[i]);
  3432. for (j = cur.length - 1; j >= 0; j--){
  3433. inst = $.data(cur[j], this.widgetFullName);
  3434. if(inst && inst !== this && !inst.options.disabled) {
  3435. queries.push([$.isFunction(inst.options.items) ? inst.options.items.call(inst.element[0], event, { item: this.currentItem }) : $(inst.options.items, inst.element), inst]);
  3436. this.containers.push(inst);
  3437. }
  3438. }
  3439. }
  3440. }
  3441. for (i = queries.length - 1; i >= 0; i--) {
  3442. targetData = queries[i][1];
  3443. _queries = queries[i][0];
  3444. for (j=0, queriesLength = _queries.length; j < queriesLength; j++) {
  3445. item = $(_queries[j]);
  3446. item.data(this.widgetName + "-item", targetData); // Data for target checking (mouse manager)
  3447. items.push({
  3448. item: item,
  3449. instance: targetData,
  3450. width: 0, height: 0,
  3451. left: 0, top: 0
  3452. });
  3453. }
  3454. }
  3455. },
  3456. refreshPositions: function(fast) {
  3457. //This has to be redone because due to the item being moved out/into the offsetParent, the offsetParent's position will change
  3458. if(this.offsetParent && this.helper) {
  3459. this.offset.parent = this._getParentOffset();
  3460. }
  3461. var i, item, t, p;
  3462. for (i = this.items.length - 1; i >= 0; i--){
  3463. item = this.items[i];
  3464. //We ignore calculating positions of all connected containers when we're not over them
  3465. if(item.instance !== this.currentContainer && this.currentContainer && item.item[0] !== this.currentItem[0]) {
  3466. continue;
  3467. }
  3468. t = this.options.toleranceElement ? $(this.options.toleranceElement, item.item) : item.item;
  3469. if (!fast) {
  3470. item.width = t.outerWidth();
  3471. item.height = t.outerHeight();
  3472. }
  3473. p = t.offset();
  3474. item.left = p.left;
  3475. item.top = p.top;
  3476. }
  3477. if(this.options.custom && this.options.custom.refreshContainers) {
  3478. this.options.custom.refreshContainers.call(this);
  3479. } else {
  3480. for (i = this.containers.length - 1; i >= 0; i--){
  3481. p = this.containers[i].element.offset();
  3482. this.containers[i].containerCache.left = p.left;
  3483. this.containers[i].containerCache.top = p.top;
  3484. this.containers[i].containerCache.width = this.containers[i].element.outerWidth();
  3485. this.containers[i].containerCache.height = this.containers[i].element.outerHeight();
  3486. }
  3487. }
  3488. return this;
  3489. },
  3490. _createPlaceholder: function(that) {
  3491. that = that || this;
  3492. var className,
  3493. o = that.options;
  3494. if(!o.placeholder || o.placeholder.constructor === String) {
  3495. className = o.placeholder;
  3496. o.placeholder = {
  3497. element: function() {
  3498. var nodeName = that.currentItem[0].nodeName.toLowerCase(),
  3499. element = $( "<" + nodeName + ">", that.document[0] )
  3500. .addClass(className || that.currentItem[0].className+" ui-sortable-placeholder")
  3501. .removeClass("ui-sortable-helper");
  3502. if ( nodeName === "tr" ) {
  3503. that.currentItem.children().each(function() {
  3504. $( "<td>&#160;</td>", that.document[0] )
  3505. .attr( "colspan", $( this ).attr( "colspan" ) || 1 )
  3506. .appendTo( element );
  3507. });
  3508. } else if ( nodeName === "img" ) {
  3509. element.attr( "src", that.currentItem.attr( "src" ) );
  3510. }
  3511. if ( !className ) {
  3512. element.css( "visibility", "hidden" );
  3513. }
  3514. return element;
  3515. },
  3516. update: function(container, p) {
  3517. // 1. If a className is set as 'placeholder option, we don't force sizes - the class is responsible for that
  3518. // 2. The option 'forcePlaceholderSize can be enabled to force it even if a class name is specified
  3519. if(className && !o.forcePlaceholderSize) {
  3520. return;
  3521. }
  3522. //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
  3523. if(!p.height()) { p.height(that.currentItem.innerHeight() - parseInt(that.currentItem.css("paddingTop")||0, 10) - parseInt(that.currentItem.css("paddingBottom")||0, 10)); }
  3524. if(!p.width()) { p.width(that.currentItem.innerWidth() - parseInt(that.currentItem.css("paddingLeft")||0, 10) - parseInt(that.currentItem.css("paddingRight")||0, 10)); }
  3525. }
  3526. };
  3527. }
  3528. //Create the placeholder
  3529. that.placeholder = $(o.placeholder.element.call(that.element, that.currentItem));
  3530. //Append it after the actual current item
  3531. that.currentItem.after(that.placeholder);
  3532. //Update the size of the placeholder (TODO: Logic to fuzzy, see line 316/317)
  3533. o.placeholder.update(that, that.placeholder);
  3534. },
  3535. _contactContainers: function(event) {
  3536. var i, j, dist, itemWithLeastDistance, posProperty, sizeProperty, base, cur, nearBottom, floating,
  3537. innermostContainer = null,
  3538. innermostIndex = null;
  3539. // get innermost container that intersects with item
  3540. for (i = this.containers.length - 1; i >= 0; i--) {
  3541. // never consider a container that's located within the item itself
  3542. if($.contains(this.currentItem[0], this.containers[i].element[0])) {
  3543. continue;
  3544. }
  3545. if(this._intersectsWith(this.containers[i].containerCache)) {
  3546. // if we've already found a container and it's more "inner" than this, then continue
  3547. if(innermostContainer && $.contains(this.containers[i].element[0], innermostContainer.element[0])) {
  3548. continue;
  3549. }
  3550. innermostContainer = this.containers[i];
  3551. innermostIndex = i;
  3552. } else {
  3553. // container doesn't intersect. trigger "out" event if necessary
  3554. if(this.containers[i].containerCache.over) {
  3555. this.containers[i]._trigger("out", event, this._uiHash(this));
  3556. this.containers[i].containerCache.over = 0;
  3557. }
  3558. }
  3559. }
  3560. // if no intersecting containers found, return
  3561. if(!innermostContainer) {
  3562. return;
  3563. }
  3564. // move the item into the container if it's not there already
  3565. if(this.containers.length === 1) {
  3566. if (!this.containers[innermostIndex].containerCache.over) {
  3567. this.containers[innermostIndex]._trigger("over", event, this._uiHash(this));
  3568. this.containers[innermostIndex].containerCache.over = 1;
  3569. }
  3570. } else {
  3571. //When entering a new container, we will find the item with the least distance and append our item near it
  3572. dist = 10000;
  3573. itemWithLeastDistance = null;
  3574. floating = innermostContainer.floating || isFloating(this.currentItem);
  3575. posProperty = floating ? "left" : "top";
  3576. sizeProperty = floating ? "width" : "height";
  3577. base = this.positionAbs[posProperty] + this.offset.click[posProperty];
  3578. for (j = this.items.length - 1; j >= 0; j--) {
  3579. if(!$.contains(this.containers[innermostIndex].element[0], this.items[j].item[0])) {
  3580. continue;
  3581. }
  3582. if(this.items[j].item[0] === this.currentItem[0]) {
  3583. continue;
  3584. }
  3585. if (floating && !isOverAxis(this.positionAbs.top + this.offset.click.top, this.items[j].top, this.items[j].height)) {
  3586. continue;
  3587. }
  3588. cur = this.items[j].item.offset()[posProperty];
  3589. nearBottom = false;
  3590. if(Math.abs(cur - base) > Math.abs(cur + this.items[j][sizeProperty] - base)){
  3591. nearBottom = true;
  3592. cur += this.items[j][sizeProperty];
  3593. }
  3594. if(Math.abs(cur - base) < dist) {
  3595. dist = Math.abs(cur - base); itemWithLeastDistance = this.items[j];
  3596. this.direction = nearBottom ? "up": "down";
  3597. }
  3598. }
  3599. //Check if dropOnEmpty is enabled
  3600. if(!itemWithLeastDistance && !this.options.dropOnEmpty) {
  3601. return;
  3602. }
  3603. if(this.currentContainer === this.containers[innermostIndex]) {
  3604. return;
  3605. }
  3606. itemWithLeastDistance ? this._rearrange(event, itemWithLeastDistance, null, true) : this._rearrange(event, null, this.containers[innermostIndex].element, true);
  3607. this._trigger("change", event, this._uiHash());
  3608. this.containers[innermostIndex]._trigger("change", event, this._uiHash(this));
  3609. this.currentContainer = this.containers[innermostIndex];
  3610. //Update the placeholder
  3611. this.options.placeholder.update(this.currentContainer, this.placeholder);
  3612. this.containers[innermostIndex]._trigger("over", event, this._uiHash(this));
  3613. this.containers[innermostIndex].containerCache.over = 1;
  3614. }
  3615. },
  3616. _createHelper: function(event) {
  3617. var o = this.options,
  3618. helper = $.isFunction(o.helper) ? $(o.helper.apply(this.element[0], [event, this.currentItem])) : (o.helper === "clone" ? this.currentItem.clone() : this.currentItem);
  3619. //Add the helper to the DOM if that didn't happen already
  3620. if(!helper.parents("body").length) {
  3621. $(o.appendTo !== "parent" ? o.appendTo : this.currentItem[0].parentNode)[0].appendChild(helper[0]);
  3622. }
  3623. if(helper[0] === this.currentItem[0]) {
  3624. 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") };
  3625. }
  3626. if(!helper[0].style.width || o.forceHelperSize) {
  3627. helper.width(this.currentItem.width());
  3628. }
  3629. if(!helper[0].style.height || o.forceHelperSize) {
  3630. helper.height(this.currentItem.height());
  3631. }
  3632. return helper;
  3633. },
  3634. _adjustOffsetFromHelper: function(obj) {
  3635. if (typeof obj === "string") {
  3636. obj = obj.split(" ");
  3637. }
  3638. if ($.isArray(obj)) {
  3639. obj = {left: +obj[0], top: +obj[1] || 0};
  3640. }
  3641. if ("left" in obj) {
  3642. this.offset.click.left = obj.left + this.margins.left;
  3643. }
  3644. if ("right" in obj) {
  3645. this.offset.click.left = this.helperProportions.width - obj.right + this.margins.left;
  3646. }
  3647. if ("top" in obj) {
  3648. this.offset.click.top = obj.top + this.margins.top;
  3649. }
  3650. if ("bottom" in obj) {
  3651. this.offset.click.top = this.helperProportions.height - obj.bottom + this.margins.top;
  3652. }
  3653. },
  3654. _getParentOffset: function() {
  3655. //Get the offsetParent and cache its position
  3656. this.offsetParent = this.helper.offsetParent();
  3657. var po = this.offsetParent.offset();
  3658. // This is a special case where we need to modify a offset calculated on start, since the following happened:
  3659. // 1. The position of the helper is absolute, so it's position is calculated based on the next positioned parent
  3660. // 2. The actual offset parent is a child of the scroll parent, and the scroll parent isn't the document, which means that
  3661. // the scroll is included in the initial calculation of the offset of the parent, and never recalculated upon drag
  3662. if(this.cssPosition === "absolute" && this.scrollParent[0] !== document && $.contains(this.scrollParent[0], this.offsetParent[0])) {
  3663. po.left += this.scrollParent.scrollLeft();
  3664. po.top += this.scrollParent.scrollTop();
  3665. }
  3666. // This needs to be actually done for all browsers, since pageX/pageY includes this information
  3667. // with an ugly IE fix
  3668. if( this.offsetParent[0] === document.body || (this.offsetParent[0].tagName && this.offsetParent[0].tagName.toLowerCase() === "html" && $.ui.ie)) {
  3669. po = { top: 0, left: 0 };
  3670. }
  3671. return {
  3672. top: po.top + (parseInt(this.offsetParent.css("borderTopWidth"),10) || 0),
  3673. left: po.left + (parseInt(this.offsetParent.css("borderLeftWidth"),10) || 0)
  3674. };
  3675. },
  3676. _getRelativeOffset: function() {
  3677. if(this.cssPosition === "relative") {
  3678. var p = this.currentItem.position();
  3679. return {
  3680. top: p.top - (parseInt(this.helper.css("top"),10) || 0) + this.scrollParent.scrollTop(),
  3681. left: p.left - (parseInt(this.helper.css("left"),10) || 0) + this.scrollParent.scrollLeft()
  3682. };
  3683. } else {
  3684. return { top: 0, left: 0 };
  3685. }
  3686. },
  3687. _cacheMargins: function() {
  3688. this.margins = {
  3689. left: (parseInt(this.currentItem.css("marginLeft"),10) || 0),
  3690. top: (parseInt(this.currentItem.css("marginTop"),10) || 0)
  3691. };
  3692. },
  3693. _cacheHelperProportions: function() {
  3694. this.helperProportions = {
  3695. width: this.helper.outerWidth(),
  3696. height: this.helper.outerHeight()
  3697. };
  3698. },
  3699. _setContainment: function() {
  3700. var ce, co, over,
  3701. o = this.options;
  3702. if(o.containment === "parent") {
  3703. o.containment = this.helper[0].parentNode;
  3704. }
  3705. if(o.containment === "document" || o.containment === "window") {
  3706. this.containment = [
  3707. 0 - this.offset.relative.left - this.offset.parent.left,
  3708. 0 - this.offset.relative.top - this.offset.parent.top,
  3709. $(o.containment === "document" ? document : window).width() - this.helperProportions.width - this.margins.left,
  3710. ($(o.containment === "document" ? document : window).height() || document.body.parentNode.scrollHeight) - this.helperProportions.height - this.margins.top
  3711. ];
  3712. }
  3713. if(!(/^(document|window|parent)$/).test(o.containment)) {
  3714. ce = $(o.containment)[0];
  3715. co = $(o.containment).offset();
  3716. over = ($(ce).css("overflow") !== "hidden");
  3717. this.containment = [
  3718. co.left + (parseInt($(ce).css("borderLeftWidth"),10) || 0) + (parseInt($(ce).css("paddingLeft"),10) || 0) - this.margins.left,
  3719. co.top + (parseInt($(ce).css("borderTopWidth"),10) || 0) + (parseInt($(ce).css("paddingTop"),10) || 0) - this.margins.top,
  3720. 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,
  3721. 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
  3722. ];
  3723. }
  3724. },
  3725. _convertPositionTo: function(d, pos) {
  3726. if(!pos) {
  3727. pos = this.position;
  3728. }
  3729. var mod = d === "absolute" ? 1 : -1,
  3730. scroll = this.cssPosition === "absolute" && !(this.scrollParent[0] !== document && $.contains(this.scrollParent[0], this.offsetParent[0])) ? this.offsetParent : this.scrollParent,
  3731. scrollIsRootNode = (/(html|body)/i).test(scroll[0].tagName);
  3732. return {
  3733. top: (
  3734. pos.top + // The absolute mouse position
  3735. this.offset.relative.top * mod + // Only for relative positioned nodes: Relative offset from element to offset parent
  3736. this.offset.parent.top * mod - // The offsetParent's offset without borders (offset + border)
  3737. ( ( this.cssPosition === "fixed" ? -this.scrollParent.scrollTop() : ( scrollIsRootNode ? 0 : scroll.scrollTop() ) ) * mod)
  3738. ),
  3739. left: (
  3740. pos.left + // The absolute mouse position
  3741. this.offset.relative.left * mod + // Only for relative positioned nodes: Relative offset from element to offset parent
  3742. this.offset.parent.left * mod - // The offsetParent's offset without borders (offset + border)
  3743. ( ( this.cssPosition === "fixed" ? -this.scrollParent.scrollLeft() : scrollIsRootNode ? 0 : scroll.scrollLeft() ) * mod)
  3744. )
  3745. };
  3746. },
  3747. _generatePosition: function(event) {
  3748. var top, left,
  3749. o = this.options,
  3750. pageX = event.pageX,
  3751. pageY = event.pageY,
  3752. 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);
  3753. // This is another very weird special case that only happens for relative elements:
  3754. // 1. If the css position is relative
  3755. // 2. and the scroll parent is the document or similar to the offset parent
  3756. // we have to refresh the relative offset during the scroll so there are no jumps
  3757. if(this.cssPosition === "relative" && !(this.scrollParent[0] !== document && this.scrollParent[0] !== this.offsetParent[0])) {
  3758. this.offset.relative = this._getRelativeOffset();
  3759. }
  3760. /*
  3761. * - Position constraining -
  3762. * Constrain the position to a mix of grid, containment.
  3763. */
  3764. if(this.originalPosition) { //If we are not dragging yet, we won't check for options
  3765. if(this.containment) {
  3766. if(event.pageX - this.offset.click.left < this.containment[0]) {
  3767. pageX = this.containment[0] + this.offset.click.left;
  3768. }
  3769. if(event.pageY - this.offset.click.top < this.containment[1]) {
  3770. pageY = this.containment[1] + this.offset.click.top;
  3771. }
  3772. if(event.pageX - this.offset.click.left > this.containment[2]) {
  3773. pageX = this.containment[2] + this.offset.click.left;
  3774. }
  3775. if(event.pageY - this.offset.click.top > this.containment[3]) {
  3776. pageY = this.containment[3] + this.offset.click.top;
  3777. }
  3778. }
  3779. if(o.grid) {
  3780. top = this.originalPageY + Math.round((pageY - this.originalPageY) / o.grid[1]) * o.grid[1];
  3781. 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;
  3782. left = this.originalPageX + Math.round((pageX - this.originalPageX) / o.grid[0]) * o.grid[0];
  3783. 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;
  3784. }
  3785. }
  3786. return {
  3787. top: (
  3788. pageY - // The absolute mouse position
  3789. this.offset.click.top - // Click offset (relative to the element)
  3790. this.offset.relative.top - // Only for relative positioned nodes: Relative offset from element to offset parent
  3791. this.offset.parent.top + // The offsetParent's offset without borders (offset + border)
  3792. ( ( this.cssPosition === "fixed" ? -this.scrollParent.scrollTop() : ( scrollIsRootNode ? 0 : scroll.scrollTop() ) ))
  3793. ),
  3794. left: (
  3795. pageX - // The absolute mouse position
  3796. this.offset.click.left - // Click offset (relative to the element)
  3797. this.offset.relative.left - // Only for relative positioned nodes: Relative offset from element to offset parent
  3798. this.offset.parent.left + // The offsetParent's offset without borders (offset + border)
  3799. ( ( this.cssPosition === "fixed" ? -this.scrollParent.scrollLeft() : scrollIsRootNode ? 0 : scroll.scrollLeft() ))
  3800. )
  3801. };
  3802. },
  3803. _rearrange: function(event, i, a, hardRefresh) {
  3804. 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));
  3805. //Various things done here to improve the performance:
  3806. // 1. we create a setTimeout, that calls refreshPositions
  3807. // 2. on the instance, we have a counter variable, that get's higher after every append
  3808. // 3. on the local scope, we copy the counter variable, and check in the timeout, if it's still the same
  3809. // 4. this lets only the last addition to the timeout stack through
  3810. this.counter = this.counter ? ++this.counter : 1;
  3811. var counter = this.counter;
  3812. this._delay(function() {
  3813. if(counter === this.counter) {
  3814. this.refreshPositions(!hardRefresh); //Precompute after each DOM insertion, NOT on mousemove
  3815. }
  3816. });
  3817. },
  3818. _clear: function(event, noPropagation) {
  3819. this.reverting = false;
  3820. // We delay all events that have to be triggered to after the point where the placeholder has been removed and
  3821. // everything else normalized again
  3822. var i,
  3823. delayedTriggers = [];
  3824. // We first have to update the dom position of the actual currentItem
  3825. // Note: don't do it if the current item is already removed (by a user), or it gets reappended (see #4088)
  3826. if(!this._noFinalSort && this.currentItem.parent().length) {
  3827. this.placeholder.before(this.currentItem);
  3828. }
  3829. this._noFinalSort = null;
  3830. if(this.helper[0] === this.currentItem[0]) {
  3831. for(i in this._storedCSS) {
  3832. if(this._storedCSS[i] === "auto" || this._storedCSS[i] === "static") {
  3833. this._storedCSS[i] = "";
  3834. }
  3835. }
  3836. this.currentItem.css(this._storedCSS).removeClass("ui-sortable-helper");
  3837. } else {
  3838. this.currentItem.show();
  3839. }
  3840. if(this.fromOutside && !noPropagation) {
  3841. delayedTriggers.push(function(event) { this._trigger("receive", event, this._uiHash(this.fromOutside)); });
  3842. }
  3843. if((this.fromOutside || this.domPosition.prev !== this.currentItem.prev().not(".ui-sortable-helper")[0] || this.domPosition.parent !== this.currentItem.parent()[0]) && !noPropagation) {
  3844. delayedTriggers.push(function(event) { this._trigger("update", event, this._uiHash()); }); //Trigger update callback if the DOM position has changed
  3845. }
  3846. // Check if the items Container has Changed and trigger appropriate
  3847. // events.
  3848. if (this !== this.currentContainer) {
  3849. if(!noPropagation) {
  3850. delayedTriggers.push(function(event) { this._trigger("remove", event, this._uiHash()); });
  3851. delayedTriggers.push((function(c) { return function(event) { c._trigger("receive", event, this._uiHash(this)); }; }).call(this, this.currentContainer));
  3852. delayedTriggers.push((function(c) { return function(event) { c._trigger("update", event, this._uiHash(this)); }; }).call(this, this.currentContainer));
  3853. }
  3854. }
  3855. //Post events to containers
  3856. for (i = this.containers.length - 1; i >= 0; i--){
  3857. if(!noPropagation) {
  3858. delayedTriggers.push((function(c) { return function(event) { c._trigger("deactivate", event, this._uiHash(this)); }; }).call(this, this.containers[i]));
  3859. }
  3860. if(this.containers[i].containerCache.over) {
  3861. delayedTriggers.push((function(c) { return function(event) { c._trigger("out", event, this._uiHash(this)); }; }).call(this, this.containers[i]));
  3862. this.containers[i].containerCache.over = 0;
  3863. }
  3864. }
  3865. //Do what was originally in plugins
  3866. if ( this.storedCursor ) {
  3867. this.document.find( "body" ).css( "cursor", this.storedCursor );
  3868. this.storedStylesheet.remove();
  3869. }
  3870. if(this._storedOpacity) {
  3871. this.helper.css("opacity", this._storedOpacity);
  3872. }
  3873. if(this._storedZIndex) {
  3874. this.helper.css("zIndex", this._storedZIndex === "auto" ? "" : this._storedZIndex);
  3875. }
  3876. this.dragging = false;
  3877. if(this.cancelHelperRemoval) {
  3878. if(!noPropagation) {
  3879. this._trigger("beforeStop", event, this._uiHash());
  3880. for (i=0; i < delayedTriggers.length; i++) {
  3881. delayedTriggers[i].call(this, event);
  3882. } //Trigger all delayed events
  3883. this._trigger("stop", event, this._uiHash());
  3884. }
  3885. this.fromOutside = false;
  3886. return false;
  3887. }
  3888. if(!noPropagation) {
  3889. this._trigger("beforeStop", event, this._uiHash());
  3890. }
  3891. //$(this.placeholder[0]).remove(); would have been the jQuery way - unfortunately, it unbinds ALL events from the original node!
  3892. this.placeholder[0].parentNode.removeChild(this.placeholder[0]);
  3893. if(this.helper[0] !== this.currentItem[0]) {
  3894. this.helper.remove();
  3895. }
  3896. this.helper = null;
  3897. if(!noPropagation) {
  3898. for (i=0; i < delayedTriggers.length; i++) {
  3899. delayedTriggers[i].call(this, event);
  3900. } //Trigger all delayed events
  3901. this._trigger("stop", event, this._uiHash());
  3902. }
  3903. this.fromOutside = false;
  3904. return true;
  3905. },
  3906. _trigger: function() {
  3907. if ($.Widget.prototype._trigger.apply(this, arguments) === false) {
  3908. this.cancel();
  3909. }
  3910. },
  3911. _uiHash: function(_inst) {
  3912. var inst = _inst || this;
  3913. return {
  3914. helper: inst.helper,
  3915. placeholder: inst.placeholder || $([]),
  3916. position: inst.position,
  3917. originalPosition: inst.originalPosition,
  3918. offset: inst.positionAbs,
  3919. item: inst.currentItem,
  3920. sender: _inst ? _inst.element : null
  3921. };
  3922. }
  3923. });
  3924. })(jQuery);
  3925. (function($, undefined) {
  3926. var dataSpace = "ui-effects-";
  3927. $.effects = {
  3928. effect: {}
  3929. };
  3930. /*!
  3931. * jQuery Color Animations v2.1.2
  3932. * https://github.com/jquery/jquery-color
  3933. *
  3934. * Copyright 2013 jQuery Foundation and other contributors
  3935. * Released under the MIT license.
  3936. * http://jquery.org/license
  3937. *
  3938. * Date: Wed Jan 16 08:47:09 2013 -0600
  3939. */
  3940. (function( jQuery, undefined ) {
  3941. var stepHooks = "backgroundColor borderBottomColor borderLeftColor borderRightColor borderTopColor color columnRuleColor outlineColor textDecorationColor textEmphasisColor",
  3942. // plusequals test for += 100 -= 100
  3943. rplusequals = /^([\-+])=\s*(\d+\.?\d*)/,
  3944. // a set of RE's that can match strings and generate color tuples.
  3945. stringParsers = [{
  3946. re: /rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(?:,\s*(\d?(?:\.\d+)?)\s*)?\)/,
  3947. parse: function( execResult ) {
  3948. return [
  3949. execResult[ 1 ],
  3950. execResult[ 2 ],
  3951. execResult[ 3 ],
  3952. execResult[ 4 ]
  3953. ];
  3954. }
  3955. }, {
  3956. re: /rgba?\(\s*(\d+(?:\.\d+)?)\%\s*,\s*(\d+(?:\.\d+)?)\%\s*,\s*(\d+(?:\.\d+)?)\%\s*(?:,\s*(\d?(?:\.\d+)?)\s*)?\)/,
  3957. parse: function( execResult ) {
  3958. return [
  3959. execResult[ 1 ] * 2.55,
  3960. execResult[ 2 ] * 2.55,
  3961. execResult[ 3 ] * 2.55,
  3962. execResult[ 4 ]
  3963. ];
  3964. }
  3965. }, {
  3966. // this regex ignores A-F because it's compared against an already lowercased string
  3967. re: /#([a-f0-9]{2})([a-f0-9]{2})([a-f0-9]{2})/,
  3968. parse: function( execResult ) {
  3969. return [
  3970. parseInt( execResult[ 1 ], 16 ),
  3971. parseInt( execResult[ 2 ], 16 ),
  3972. parseInt( execResult[ 3 ], 16 )
  3973. ];
  3974. }
  3975. }, {
  3976. // this regex ignores A-F because it's compared against an already lowercased string
  3977. re: /#([a-f0-9])([a-f0-9])([a-f0-9])/,
  3978. parse: function( execResult ) {
  3979. return [
  3980. parseInt( execResult[ 1 ] + execResult[ 1 ], 16 ),
  3981. parseInt( execResult[ 2 ] + execResult[ 2 ], 16 ),
  3982. parseInt( execResult[ 3 ] + execResult[ 3 ], 16 )
  3983. ];
  3984. }
  3985. }, {
  3986. re: /hsla?\(\s*(\d+(?:\.\d+)?)\s*,\s*(\d+(?:\.\d+)?)\%\s*,\s*(\d+(?:\.\d+)?)\%\s*(?:,\s*(\d?(?:\.\d+)?)\s*)?\)/,
  3987. space: "hsla",
  3988. parse: function( execResult ) {
  3989. return [
  3990. execResult[ 1 ],
  3991. execResult[ 2 ] / 100,
  3992. execResult[ 3 ] / 100,
  3993. execResult[ 4 ]
  3994. ];
  3995. }
  3996. }],
  3997. // jQuery.Color( )
  3998. color = jQuery.Color = function( color, green, blue, alpha ) {
  3999. return new jQuery.Color.fn.parse( color, green, blue, alpha );
  4000. },
  4001. spaces = {
  4002. rgba: {
  4003. props: {
  4004. red: {
  4005. idx: 0,
  4006. type: "byte"
  4007. },
  4008. green: {
  4009. idx: 1,
  4010. type: "byte"
  4011. },
  4012. blue: {
  4013. idx: 2,
  4014. type: "byte"
  4015. }
  4016. }
  4017. },
  4018. hsla: {
  4019. props: {
  4020. hue: {
  4021. idx: 0,
  4022. type: "degrees"
  4023. },
  4024. saturation: {
  4025. idx: 1,
  4026. type: "percent"
  4027. },
  4028. lightness: {
  4029. idx: 2,
  4030. type: "percent"
  4031. }
  4032. }
  4033. }
  4034. },
  4035. propTypes = {
  4036. "byte": {
  4037. floor: true,
  4038. max: 255
  4039. },
  4040. "percent": {
  4041. max: 1
  4042. },
  4043. "degrees": {
  4044. mod: 360,
  4045. floor: true
  4046. }
  4047. },
  4048. support = color.support = {},
  4049. // element for support tests
  4050. supportElem = jQuery( "<p>" )[ 0 ],
  4051. // colors = jQuery.Color.names
  4052. colors,
  4053. // local aliases of functions called often
  4054. each = jQuery.each;
  4055. // determine rgba support immediately
  4056. supportElem.style.cssText = "background-color:rgba(1,1,1,.5)";
  4057. support.rgba = supportElem.style.backgroundColor.indexOf( "rgba" ) > -1;
  4058. // define cache name and alpha properties
  4059. // for rgba and hsla spaces
  4060. each( spaces, function( spaceName, space ) {
  4061. space.cache = "_" + spaceName;
  4062. space.props.alpha = {
  4063. idx: 3,
  4064. type: "percent",
  4065. def: 1
  4066. };
  4067. });
  4068. function clamp( value, prop, allowEmpty ) {
  4069. var type = propTypes[ prop.type ] || {};
  4070. if ( value == null ) {
  4071. return (allowEmpty || !prop.def) ? null : prop.def;
  4072. }
  4073. // ~~ is an short way of doing floor for positive numbers
  4074. value = type.floor ? ~~value : parseFloat( value );
  4075. // IE will pass in empty strings as value for alpha,
  4076. // which will hit this case
  4077. if ( isNaN( value ) ) {
  4078. return prop.def;
  4079. }
  4080. if ( type.mod ) {
  4081. // we add mod before modding to make sure that negatives values
  4082. // get converted properly: -10 -> 350
  4083. return (value + type.mod) % type.mod;
  4084. }
  4085. // for now all property types without mod have min and max
  4086. return 0 > value ? 0 : type.max < value ? type.max : value;
  4087. }
  4088. function stringParse( string ) {
  4089. var inst = color(),
  4090. rgba = inst._rgba = [];
  4091. string = string.toLowerCase();
  4092. each( stringParsers, function( i, parser ) {
  4093. var parsed,
  4094. match = parser.re.exec( string ),
  4095. values = match && parser.parse( match ),
  4096. spaceName = parser.space || "rgba";
  4097. if ( values ) {
  4098. parsed = inst[ spaceName ]( values );
  4099. // if this was an rgba parse the assignment might happen twice
  4100. // oh well....
  4101. inst[ spaces[ spaceName ].cache ] = parsed[ spaces[ spaceName ].cache ];
  4102. rgba = inst._rgba = parsed._rgba;
  4103. // exit each( stringParsers ) here because we matched
  4104. return false;
  4105. }
  4106. });
  4107. // Found a stringParser that handled it
  4108. if ( rgba.length ) {
  4109. // if this came from a parsed string, force "transparent" when alpha is 0
  4110. // chrome, (and maybe others) return "transparent" as rgba(0,0,0,0)
  4111. if ( rgba.join() === "0,0,0,0" ) {
  4112. jQuery.extend( rgba, colors.transparent );
  4113. }
  4114. return inst;
  4115. }
  4116. // named colors
  4117. return colors[ string ];
  4118. }
  4119. color.fn = jQuery.extend( color.prototype, {
  4120. parse: function( red, green, blue, alpha ) {
  4121. if ( red === undefined ) {
  4122. this._rgba = [ null, null, null, null ];
  4123. return this;
  4124. }
  4125. if ( red.jquery || red.nodeType ) {
  4126. red = jQuery( red ).css( green );
  4127. green = undefined;
  4128. }
  4129. var inst = this,
  4130. type = jQuery.type( red ),
  4131. rgba = this._rgba = [];
  4132. // more than 1 argument specified - assume ( red, green, blue, alpha )
  4133. if ( green !== undefined ) {
  4134. red = [ red, green, blue, alpha ];
  4135. type = "array";
  4136. }
  4137. if ( type === "string" ) {
  4138. return this.parse( stringParse( red ) || colors._default );
  4139. }
  4140. if ( type === "array" ) {
  4141. each( spaces.rgba.props, function( key, prop ) {
  4142. rgba[ prop.idx ] = clamp( red[ prop.idx ], prop );
  4143. });
  4144. return this;
  4145. }
  4146. if ( type === "object" ) {
  4147. if ( red instanceof color ) {
  4148. each( spaces, function( spaceName, space ) {
  4149. if ( red[ space.cache ] ) {
  4150. inst[ space.cache ] = red[ space.cache ].slice();
  4151. }
  4152. });
  4153. } else {
  4154. each( spaces, function( spaceName, space ) {
  4155. var cache = space.cache;
  4156. each( space.props, function( key, prop ) {
  4157. // if the cache doesn't exist, and we know how to convert
  4158. if ( !inst[ cache ] && space.to ) {
  4159. // if the value was null, we don't need to copy it
  4160. // if the key was alpha, we don't need to copy it either
  4161. if ( key === "alpha" || red[ key ] == null ) {
  4162. return;
  4163. }
  4164. inst[ cache ] = space.to( inst._rgba );
  4165. }
  4166. // this is the only case where we allow nulls for ALL properties.
  4167. // call clamp with alwaysAllowEmpty
  4168. inst[ cache ][ prop.idx ] = clamp( red[ key ], prop, true );
  4169. });
  4170. // everything defined but alpha?
  4171. if ( inst[ cache ] && jQuery.inArray( null, inst[ cache ].slice( 0, 3 ) ) < 0 ) {
  4172. // use the default of 1
  4173. inst[ cache ][ 3 ] = 1;
  4174. if ( space.from ) {
  4175. inst._rgba = space.from( inst[ cache ] );
  4176. }
  4177. }
  4178. });
  4179. }
  4180. return this;
  4181. }
  4182. },
  4183. is: function( compare ) {
  4184. var is = color( compare ),
  4185. same = true,
  4186. inst = this;
  4187. each( spaces, function( _, space ) {
  4188. var localCache,
  4189. isCache = is[ space.cache ];
  4190. if (isCache) {
  4191. localCache = inst[ space.cache ] || space.to && space.to( inst._rgba ) || [];
  4192. each( space.props, function( _, prop ) {
  4193. if ( isCache[ prop.idx ] != null ) {
  4194. same = ( isCache[ prop.idx ] === localCache[ prop.idx ] );
  4195. return same;
  4196. }
  4197. });
  4198. }
  4199. return same;
  4200. });
  4201. return same;
  4202. },
  4203. _space: function() {
  4204. var used = [],
  4205. inst = this;
  4206. each( spaces, function( spaceName, space ) {
  4207. if ( inst[ space.cache ] ) {
  4208. used.push( spaceName );
  4209. }
  4210. });
  4211. return used.pop();
  4212. },
  4213. transition: function( other, distance ) {
  4214. var end = color( other ),
  4215. spaceName = end._space(),
  4216. space = spaces[ spaceName ],
  4217. startColor = this.alpha() === 0 ? color( "transparent" ) : this,
  4218. start = startColor[ space.cache ] || space.to( startColor._rgba ),
  4219. result = start.slice();
  4220. end = end[ space.cache ];
  4221. each( space.props, function( key, prop ) {
  4222. var index = prop.idx,
  4223. startValue = start[ index ],
  4224. endValue = end[ index ],
  4225. type = propTypes[ prop.type ] || {};
  4226. // if null, don't override start value
  4227. if ( endValue === null ) {
  4228. return;
  4229. }
  4230. // if null - use end
  4231. if ( startValue === null ) {
  4232. result[ index ] = endValue;
  4233. } else {
  4234. if ( type.mod ) {
  4235. if ( endValue - startValue > type.mod / 2 ) {
  4236. startValue += type.mod;
  4237. } else if ( startValue - endValue > type.mod / 2 ) {
  4238. startValue -= type.mod;
  4239. }
  4240. }
  4241. result[ index ] = clamp( ( endValue - startValue ) * distance + startValue, prop );
  4242. }
  4243. });
  4244. return this[ spaceName ]( result );
  4245. },
  4246. blend: function( opaque ) {
  4247. // if we are already opaque - return ourself
  4248. if ( this._rgba[ 3 ] === 1 ) {
  4249. return this;
  4250. }
  4251. var rgb = this._rgba.slice(),
  4252. a = rgb.pop(),
  4253. blend = color( opaque )._rgba;
  4254. return color( jQuery.map( rgb, function( v, i ) {
  4255. return ( 1 - a ) * blend[ i ] + a * v;
  4256. }));
  4257. },
  4258. toRgbaString: function() {
  4259. var prefix = "rgba(",
  4260. rgba = jQuery.map( this._rgba, function( v, i ) {
  4261. return v == null ? ( i > 2 ? 1 : 0 ) : v;
  4262. });
  4263. if ( rgba[ 3 ] === 1 ) {
  4264. rgba.pop();
  4265. prefix = "rgb(";
  4266. }
  4267. return prefix + rgba.join() + ")";
  4268. },
  4269. toHslaString: function() {
  4270. var prefix = "hsla(",
  4271. hsla = jQuery.map( this.hsla(), function( v, i ) {
  4272. if ( v == null ) {
  4273. v = i > 2 ? 1 : 0;
  4274. }
  4275. // catch 1 and 2
  4276. if ( i && i < 3 ) {
  4277. v = Math.round( v * 100 ) + "%";
  4278. }
  4279. return v;
  4280. });
  4281. if ( hsla[ 3 ] === 1 ) {
  4282. hsla.pop();
  4283. prefix = "hsl(";
  4284. }
  4285. return prefix + hsla.join() + ")";
  4286. },
  4287. toHexString: function( includeAlpha ) {
  4288. var rgba = this._rgba.slice(),
  4289. alpha = rgba.pop();
  4290. if ( includeAlpha ) {
  4291. rgba.push( ~~( alpha * 255 ) );
  4292. }
  4293. return "#" + jQuery.map( rgba, function( v ) {
  4294. // default to 0 when nulls exist
  4295. v = ( v || 0 ).toString( 16 );
  4296. return v.length === 1 ? "0" + v : v;
  4297. }).join("");
  4298. },
  4299. toString: function() {
  4300. return this._rgba[ 3 ] === 0 ? "transparent" : this.toRgbaString();
  4301. }
  4302. });
  4303. color.fn.parse.prototype = color.fn;
  4304. // hsla conversions adapted from:
  4305. // https://code.google.com/p/maashaack/source/browse/packages/graphics/trunk/src/graphics/colors/HUE2RGB.as?r=5021
  4306. function hue2rgb( p, q, h ) {
  4307. h = ( h + 1 ) % 1;
  4308. if ( h * 6 < 1 ) {
  4309. return p + (q - p) * h * 6;
  4310. }
  4311. if ( h * 2 < 1) {
  4312. return q;
  4313. }
  4314. if ( h * 3 < 2 ) {
  4315. return p + (q - p) * ((2/3) - h) * 6;
  4316. }
  4317. return p;
  4318. }
  4319. spaces.hsla.to = function ( rgba ) {
  4320. if ( rgba[ 0 ] == null || rgba[ 1 ] == null || rgba[ 2 ] == null ) {
  4321. return [ null, null, null, rgba[ 3 ] ];
  4322. }
  4323. var r = rgba[ 0 ] / 255,
  4324. g = rgba[ 1 ] / 255,
  4325. b = rgba[ 2 ] / 255,
  4326. a = rgba[ 3 ],
  4327. max = Math.max( r, g, b ),
  4328. min = Math.min( r, g, b ),
  4329. diff = max - min,
  4330. add = max + min,
  4331. l = add * 0.5,
  4332. h, s;
  4333. if ( min === max ) {
  4334. h = 0;
  4335. } else if ( r === max ) {
  4336. h = ( 60 * ( g - b ) / diff ) + 360;
  4337. } else if ( g === max ) {
  4338. h = ( 60 * ( b - r ) / diff ) + 120;
  4339. } else {
  4340. h = ( 60 * ( r - g ) / diff ) + 240;
  4341. }
  4342. // chroma (diff) == 0 means greyscale which, by definition, saturation = 0%
  4343. // otherwise, saturation is based on the ratio of chroma (diff) to lightness (add)
  4344. if ( diff === 0 ) {
  4345. s = 0;
  4346. } else if ( l <= 0.5 ) {
  4347. s = diff / add;
  4348. } else {
  4349. s = diff / ( 2 - add );
  4350. }
  4351. return [ Math.round(h) % 360, s, l, a == null ? 1 : a ];
  4352. };
  4353. spaces.hsla.from = function ( hsla ) {
  4354. if ( hsla[ 0 ] == null || hsla[ 1 ] == null || hsla[ 2 ] == null ) {
  4355. return [ null, null, null, hsla[ 3 ] ];
  4356. }
  4357. var h = hsla[ 0 ] / 360,
  4358. s = hsla[ 1 ],
  4359. l = hsla[ 2 ],
  4360. a = hsla[ 3 ],
  4361. q = l <= 0.5 ? l * ( 1 + s ) : l + s - l * s,
  4362. p = 2 * l - q;
  4363. return [
  4364. Math.round( hue2rgb( p, q, h + ( 1 / 3 ) ) * 255 ),
  4365. Math.round( hue2rgb( p, q, h ) * 255 ),
  4366. Math.round( hue2rgb( p, q, h - ( 1 / 3 ) ) * 255 ),
  4367. a
  4368. ];
  4369. };
  4370. each( spaces, function( spaceName, space ) {
  4371. var props = space.props,
  4372. cache = space.cache,
  4373. to = space.to,
  4374. from = space.from;
  4375. // makes rgba() and hsla()
  4376. color.fn[ spaceName ] = function( value ) {
  4377. // generate a cache for this space if it doesn't exist
  4378. if ( to && !this[ cache ] ) {
  4379. this[ cache ] = to( this._rgba );
  4380. }
  4381. if ( value === undefined ) {
  4382. return this[ cache ].slice();
  4383. }
  4384. var ret,
  4385. type = jQuery.type( value ),
  4386. arr = ( type === "array" || type === "object" ) ? value : arguments,
  4387. local = this[ cache ].slice();
  4388. each( props, function( key, prop ) {
  4389. var val = arr[ type === "object" ? key : prop.idx ];
  4390. if ( val == null ) {
  4391. val = local[ prop.idx ];
  4392. }
  4393. local[ prop.idx ] = clamp( val, prop );
  4394. });
  4395. if ( from ) {
  4396. ret = color( from( local ) );
  4397. ret[ cache ] = local;
  4398. return ret;
  4399. } else {
  4400. return color( local );
  4401. }
  4402. };
  4403. // makes red() green() blue() alpha() hue() saturation() lightness()
  4404. each( props, function( key, prop ) {
  4405. // alpha is included in more than one space
  4406. if ( color.fn[ key ] ) {
  4407. return;
  4408. }
  4409. color.fn[ key ] = function( value ) {
  4410. var vtype = jQuery.type( value ),
  4411. fn = ( key === "alpha" ? ( this._hsla ? "hsla" : "rgba" ) : spaceName ),
  4412. local = this[ fn ](),
  4413. cur = local[ prop.idx ],
  4414. match;
  4415. if ( vtype === "undefined" ) {
  4416. return cur;
  4417. }
  4418. if ( vtype === "function" ) {
  4419. value = value.call( this, cur );
  4420. vtype = jQuery.type( value );
  4421. }
  4422. if ( value == null && prop.empty ) {
  4423. return this;
  4424. }
  4425. if ( vtype === "string" ) {
  4426. match = rplusequals.exec( value );
  4427. if ( match ) {
  4428. value = cur + parseFloat( match[ 2 ] ) * ( match[ 1 ] === "+" ? 1 : -1 );
  4429. }
  4430. }
  4431. local[ prop.idx ] = value;
  4432. return this[ fn ]( local );
  4433. };
  4434. });
  4435. });
  4436. // add cssHook and .fx.step function for each named hook.
  4437. // accept a space separated string of properties
  4438. color.hook = function( hook ) {
  4439. var hooks = hook.split( " " );
  4440. each( hooks, function( i, hook ) {
  4441. jQuery.cssHooks[ hook ] = {
  4442. set: function( elem, value ) {
  4443. var parsed, curElem,
  4444. backgroundColor = "";
  4445. if ( value !== "transparent" && ( jQuery.type( value ) !== "string" || ( parsed = stringParse( value ) ) ) ) {
  4446. value = color( parsed || value );
  4447. if ( !support.rgba && value._rgba[ 3 ] !== 1 ) {
  4448. curElem = hook === "backgroundColor" ? elem.parentNode : elem;
  4449. while (
  4450. (backgroundColor === "" || backgroundColor === "transparent") &&
  4451. curElem && curElem.style
  4452. ) {
  4453. try {
  4454. backgroundColor = jQuery.css( curElem, "backgroundColor" );
  4455. curElem = curElem.parentNode;
  4456. } catch ( e ) {
  4457. }
  4458. }
  4459. value = value.blend( backgroundColor && backgroundColor !== "transparent" ?
  4460. backgroundColor :
  4461. "_default" );
  4462. }
  4463. value = value.toRgbaString();
  4464. }
  4465. try {
  4466. elem.style[ hook ] = value;
  4467. } catch( e ) {
  4468. // wrapped to prevent IE from throwing errors on "invalid" values like 'auto' or 'inherit'
  4469. }
  4470. }
  4471. };
  4472. jQuery.fx.step[ hook ] = function( fx ) {
  4473. if ( !fx.colorInit ) {
  4474. fx.start = color( fx.elem, hook );
  4475. fx.end = color( fx.end );
  4476. fx.colorInit = true;
  4477. }
  4478. jQuery.cssHooks[ hook ].set( fx.elem, fx.start.transition( fx.end, fx.pos ) );
  4479. };
  4480. });
  4481. };
  4482. color.hook( stepHooks );
  4483. jQuery.cssHooks.borderColor = {
  4484. expand: function( value ) {
  4485. var expanded = {};
  4486. each( [ "Top", "Right", "Bottom", "Left" ], function( i, part ) {
  4487. expanded[ "border" + part + "Color" ] = value;
  4488. });
  4489. return expanded;
  4490. }
  4491. };
  4492. // Basic color names only.
  4493. // Usage of any of the other color names requires adding yourself or including
  4494. // jquery.color.svg-names.js.
  4495. colors = jQuery.Color.names = {
  4496. // 4.1. Basic color keywords
  4497. aqua: "#00ffff",
  4498. black: "#000000",
  4499. blue: "#0000ff",
  4500. fuchsia: "#ff00ff",
  4501. gray: "#808080",
  4502. green: "#008000",
  4503. lime: "#00ff00",
  4504. maroon: "#800000",
  4505. navy: "#000080",
  4506. olive: "#808000",
  4507. purple: "#800080",
  4508. red: "#ff0000",
  4509. silver: "#c0c0c0",
  4510. teal: "#008080",
  4511. white: "#ffffff",
  4512. yellow: "#ffff00",
  4513. // 4.2.3. "transparent" color keyword
  4514. transparent: [ null, null, null, 0 ],
  4515. _default: "#ffffff"
  4516. };
  4517. })( jQuery );
  4518. /******************************************************************************/
  4519. /****************************** CLASS ANIMATIONS ******************************/
  4520. /******************************************************************************/
  4521. (function() {
  4522. var classAnimationActions = [ "add", "remove", "toggle" ],
  4523. shorthandStyles = {
  4524. border: 1,
  4525. borderBottom: 1,
  4526. borderColor: 1,
  4527. borderLeft: 1,
  4528. borderRight: 1,
  4529. borderTop: 1,
  4530. borderWidth: 1,
  4531. margin: 1,
  4532. padding: 1
  4533. };
  4534. $.each([ "borderLeftStyle", "borderRightStyle", "borderBottomStyle", "borderTopStyle" ], function( _, prop ) {
  4535. $.fx.step[ prop ] = function( fx ) {
  4536. if ( fx.end !== "none" && !fx.setAttr || fx.pos === 1 && !fx.setAttr ) {
  4537. jQuery.style( fx.elem, prop, fx.end );
  4538. fx.setAttr = true;
  4539. }
  4540. };
  4541. });
  4542. function getElementStyles( elem ) {
  4543. var key, len,
  4544. style = elem.ownerDocument.defaultView ?
  4545. elem.ownerDocument.defaultView.getComputedStyle( elem, null ) :
  4546. elem.currentStyle,
  4547. styles = {};
  4548. if ( style && style.length && style[ 0 ] && style[ style[ 0 ] ] ) {
  4549. len = style.length;
  4550. while ( len-- ) {
  4551. key = style[ len ];
  4552. if ( typeof style[ key ] === "string" ) {
  4553. styles[ $.camelCase( key ) ] = style[ key ];
  4554. }
  4555. }
  4556. // support: Opera, IE <9
  4557. } else {
  4558. for ( key in style ) {
  4559. if ( typeof style[ key ] === "string" ) {
  4560. styles[ key ] = style[ key ];
  4561. }
  4562. }
  4563. }
  4564. return styles;
  4565. }
  4566. function styleDifference( oldStyle, newStyle ) {
  4567. var diff = {},
  4568. name, value;
  4569. for ( name in newStyle ) {
  4570. value = newStyle[ name ];
  4571. if ( oldStyle[ name ] !== value ) {
  4572. if ( !shorthandStyles[ name ] ) {
  4573. if ( $.fx.step[ name ] || !isNaN( parseFloat( value ) ) ) {
  4574. diff[ name ] = value;
  4575. }
  4576. }
  4577. }
  4578. }
  4579. return diff;
  4580. }
  4581. // support: jQuery <1.8
  4582. if ( !$.fn.addBack ) {
  4583. $.fn.addBack = function( selector ) {
  4584. return this.add( selector == null ?
  4585. this.prevObject : this.prevObject.filter( selector )
  4586. );
  4587. };
  4588. }
  4589. $.effects.animateClass = function( value, duration, easing, callback ) {
  4590. var o = $.speed( duration, easing, callback );
  4591. return this.queue( function() {
  4592. var animated = $( this ),
  4593. baseClass = animated.attr( "class" ) || "",
  4594. applyClassChange,
  4595. allAnimations = o.children ? animated.find( "*" ).addBack() : animated;
  4596. // map the animated objects to store the original styles.
  4597. allAnimations = allAnimations.map(function() {
  4598. var el = $( this );
  4599. return {
  4600. el: el,
  4601. start: getElementStyles( this )
  4602. };
  4603. });
  4604. // apply class change
  4605. applyClassChange = function() {
  4606. $.each( classAnimationActions, function(i, action) {
  4607. if ( value[ action ] ) {
  4608. animated[ action + "Class" ]( value[ action ] );
  4609. }
  4610. });
  4611. };
  4612. applyClassChange();
  4613. // map all animated objects again - calculate new styles and diff
  4614. allAnimations = allAnimations.map(function() {
  4615. this.end = getElementStyles( this.el[ 0 ] );
  4616. this.diff = styleDifference( this.start, this.end );
  4617. return this;
  4618. });
  4619. // apply original class
  4620. animated.attr( "class", baseClass );
  4621. // map all animated objects again - this time collecting a promise
  4622. allAnimations = allAnimations.map(function() {
  4623. var styleInfo = this,
  4624. dfd = $.Deferred(),
  4625. opts = $.extend({}, o, {
  4626. queue: false,
  4627. complete: function() {
  4628. dfd.resolve( styleInfo );
  4629. }
  4630. });
  4631. this.el.animate( this.diff, opts );
  4632. return dfd.promise();
  4633. });
  4634. // once all animations have completed:
  4635. $.when.apply( $, allAnimations.get() ).done(function() {
  4636. // set the final class
  4637. applyClassChange();
  4638. // for each animated element,
  4639. // clear all css properties that were animated
  4640. $.each( arguments, function() {
  4641. var el = this.el;
  4642. $.each( this.diff, function(key) {
  4643. el.css( key, "" );
  4644. });
  4645. });
  4646. // this is guarnteed to be there if you use jQuery.speed()
  4647. // it also handles dequeuing the next anim...
  4648. o.complete.call( animated[ 0 ] );
  4649. });
  4650. });
  4651. };
  4652. $.fn.extend({
  4653. addClass: (function( orig ) {
  4654. return function( classNames, speed, easing, callback ) {
  4655. return speed ?
  4656. $.effects.animateClass.call( this,
  4657. { add: classNames }, speed, easing, callback ) :
  4658. orig.apply( this, arguments );
  4659. };
  4660. })( $.fn.addClass ),
  4661. removeClass: (function( orig ) {
  4662. return function( classNames, speed, easing, callback ) {
  4663. return arguments.length > 1 ?
  4664. $.effects.animateClass.call( this,
  4665. { remove: classNames }, speed, easing, callback ) :
  4666. orig.apply( this, arguments );
  4667. };
  4668. })( $.fn.removeClass ),
  4669. toggleClass: (function( orig ) {
  4670. return function( classNames, force, speed, easing, callback ) {
  4671. if ( typeof force === "boolean" || force === undefined ) {
  4672. if ( !speed ) {
  4673. // without speed parameter
  4674. return orig.apply( this, arguments );
  4675. } else {
  4676. return $.effects.animateClass.call( this,
  4677. (force ? { add: classNames } : { remove: classNames }),
  4678. speed, easing, callback );
  4679. }
  4680. } else {
  4681. // without force parameter
  4682. return $.effects.animateClass.call( this,
  4683. { toggle: classNames }, force, speed, easing );
  4684. }
  4685. };
  4686. })( $.fn.toggleClass ),
  4687. switchClass: function( remove, add, speed, easing, callback) {
  4688. return $.effects.animateClass.call( this, {
  4689. add: add,
  4690. remove: remove
  4691. }, speed, easing, callback );
  4692. }
  4693. });
  4694. })();
  4695. /******************************************************************************/
  4696. /*********************************** EFFECTS **********************************/
  4697. /******************************************************************************/
  4698. (function() {
  4699. $.extend( $.effects, {
  4700. version: "1.10.3",
  4701. // Saves a set of properties in a data storage
  4702. save: function( element, set ) {
  4703. for( var i=0; i < set.length; i++ ) {
  4704. if ( set[ i ] !== null ) {
  4705. element.data( dataSpace + set[ i ], element[ 0 ].style[ set[ i ] ] );
  4706. }
  4707. }
  4708. },
  4709. // Restores a set of previously saved properties from a data storage
  4710. restore: function( element, set ) {
  4711. var val, i;
  4712. for( i=0; i < set.length; i++ ) {
  4713. if ( set[ i ] !== null ) {
  4714. val = element.data( dataSpace + set[ i ] );
  4715. // support: jQuery 1.6.2
  4716. // http://bugs.jquery.com/ticket/9917
  4717. // jQuery 1.6.2 incorrectly returns undefined for any falsy value.
  4718. // We can't differentiate between "" and 0 here, so we just assume
  4719. // empty string since it's likely to be a more common value...
  4720. if ( val === undefined ) {
  4721. val = "";
  4722. }
  4723. element.css( set[ i ], val );
  4724. }
  4725. }
  4726. },
  4727. setMode: function( el, mode ) {
  4728. if (mode === "toggle") {
  4729. mode = el.is( ":hidden" ) ? "show" : "hide";
  4730. }
  4731. return mode;
  4732. },
  4733. // Translates a [top,left] array into a baseline value
  4734. // this should be a little more flexible in the future to handle a string & hash
  4735. getBaseline: function( origin, original ) {
  4736. var y, x;
  4737. switch ( origin[ 0 ] ) {
  4738. case "top": y = 0; break;
  4739. case "middle": y = 0.5; break;
  4740. case "bottom": y = 1; break;
  4741. default: y = origin[ 0 ] / original.height;
  4742. }
  4743. switch ( origin[ 1 ] ) {
  4744. case "left": x = 0; break;
  4745. case "center": x = 0.5; break;
  4746. case "right": x = 1; break;
  4747. default: x = origin[ 1 ] / original.width;
  4748. }
  4749. return {
  4750. x: x,
  4751. y: y
  4752. };
  4753. },
  4754. // Wraps the element around a wrapper that copies position properties
  4755. createWrapper: function( element ) {
  4756. // if the element is already wrapped, return it
  4757. if ( element.parent().is( ".ui-effects-wrapper" )) {
  4758. return element.parent();
  4759. }
  4760. // wrap the element
  4761. var props = {
  4762. width: element.outerWidth(true),
  4763. height: element.outerHeight(true),
  4764. "float": element.css( "float" )
  4765. },
  4766. wrapper = $( "<div></div>" )
  4767. .addClass( "ui-effects-wrapper" )
  4768. .css({
  4769. fontSize: "100%",
  4770. background: "transparent",
  4771. border: "none",
  4772. margin: 0,
  4773. padding: 0
  4774. }),
  4775. // Store the size in case width/height are defined in % - Fixes #5245
  4776. size = {
  4777. width: element.width(),
  4778. height: element.height()
  4779. },
  4780. active = document.activeElement;
  4781. // support: Firefox
  4782. // Firefox incorrectly exposes anonymous content
  4783. // https://bugzilla.mozilla.org/show_bug.cgi?id=561664
  4784. try {
  4785. active.id;
  4786. } catch( e ) {
  4787. active = document.body;
  4788. }
  4789. element.wrap( wrapper );
  4790. // Fixes #7595 - Elements lose focus when wrapped.
  4791. if ( element[ 0 ] === active || $.contains( element[ 0 ], active ) ) {
  4792. $( active ).focus();
  4793. }
  4794. wrapper = element.parent(); //Hotfix for jQuery 1.4 since some change in wrap() seems to actually lose the reference to the wrapped element
  4795. // transfer positioning properties to the wrapper
  4796. if ( element.css( "position" ) === "static" ) {
  4797. wrapper.css({ position: "relative" });
  4798. element.css({ position: "relative" });
  4799. } else {
  4800. $.extend( props, {
  4801. position: element.css( "position" ),
  4802. zIndex: element.css( "z-index" )
  4803. });
  4804. $.each([ "top", "left", "bottom", "right" ], function(i, pos) {
  4805. props[ pos ] = element.css( pos );
  4806. if ( isNaN( parseInt( props[ pos ], 10 ) ) ) {
  4807. props[ pos ] = "auto";
  4808. }
  4809. });
  4810. element.css({
  4811. position: "relative",
  4812. top: 0,
  4813. left: 0,
  4814. right: "auto",
  4815. bottom: "auto"
  4816. });
  4817. }
  4818. element.css(size);
  4819. return wrapper.css( props ).show();
  4820. },
  4821. removeWrapper: function( element ) {
  4822. var active = document.activeElement;
  4823. if ( element.parent().is( ".ui-effects-wrapper" ) ) {
  4824. element.parent().replaceWith( element );
  4825. // Fixes #7595 - Elements lose focus when wrapped.
  4826. if ( element[ 0 ] === active || $.contains( element[ 0 ], active ) ) {
  4827. $( active ).focus();
  4828. }
  4829. }
  4830. return element;
  4831. },
  4832. setTransition: function( element, list, factor, value ) {
  4833. value = value || {};
  4834. $.each( list, function( i, x ) {
  4835. var unit = element.cssUnit( x );
  4836. if ( unit[ 0 ] > 0 ) {
  4837. value[ x ] = unit[ 0 ] * factor + unit[ 1 ];
  4838. }
  4839. });
  4840. return value;
  4841. }
  4842. });
  4843. // return an effect options object for the given parameters:
  4844. function _normalizeArguments( effect, options, speed, callback ) {
  4845. // allow passing all options as the first parameter
  4846. if ( $.isPlainObject( effect ) ) {
  4847. options = effect;
  4848. effect = effect.effect;
  4849. }
  4850. // convert to an object
  4851. effect = { effect: effect };
  4852. // catch (effect, null, ...)
  4853. if ( options == null ) {
  4854. options = {};
  4855. }
  4856. // catch (effect, callback)
  4857. if ( $.isFunction( options ) ) {
  4858. callback = options;
  4859. speed = null;
  4860. options = {};
  4861. }
  4862. // catch (effect, speed, ?)
  4863. if ( typeof options === "number" || $.fx.speeds[ options ] ) {
  4864. callback = speed;
  4865. speed = options;
  4866. options = {};
  4867. }
  4868. // catch (effect, options, callback)
  4869. if ( $.isFunction( speed ) ) {
  4870. callback = speed;
  4871. speed = null;
  4872. }
  4873. // add options to effect
  4874. if ( options ) {
  4875. $.extend( effect, options );
  4876. }
  4877. speed = speed || options.duration;
  4878. effect.duration = $.fx.off ? 0 :
  4879. typeof speed === "number" ? speed :
  4880. speed in $.fx.speeds ? $.fx.speeds[ speed ] :
  4881. $.fx.speeds._default;
  4882. effect.complete = callback || options.complete;
  4883. return effect;
  4884. }
  4885. function standardAnimationOption( option ) {
  4886. // Valid standard speeds (nothing, number, named speed)
  4887. if ( !option || typeof option === "number" || $.fx.speeds[ option ] ) {
  4888. return true;
  4889. }
  4890. // Invalid strings - treat as "normal" speed
  4891. if ( typeof option === "string" && !$.effects.effect[ option ] ) {
  4892. return true;
  4893. }
  4894. // Complete callback
  4895. if ( $.isFunction( option ) ) {
  4896. return true;
  4897. }
  4898. // Options hash (but not naming an effect)
  4899. if ( typeof option === "object" && !option.effect ) {
  4900. return true;
  4901. }
  4902. // Didn't match any standard API
  4903. return false;
  4904. }
  4905. $.fn.extend({
  4906. effect: function( /* effect, options, speed, callback */ ) {
  4907. var args = _normalizeArguments.apply( this, arguments ),
  4908. mode = args.mode,
  4909. queue = args.queue,
  4910. effectMethod = $.effects.effect[ args.effect ];
  4911. if ( $.fx.off || !effectMethod ) {
  4912. // delegate to the original method (e.g., .show()) if possible
  4913. if ( mode ) {
  4914. return this[ mode ]( args.duration, args.complete );
  4915. } else {
  4916. return this.each( function() {
  4917. if ( args.complete ) {
  4918. args.complete.call( this );
  4919. }
  4920. });
  4921. }
  4922. }
  4923. function run( next ) {
  4924. var elem = $( this ),
  4925. complete = args.complete,
  4926. mode = args.mode;
  4927. function done() {
  4928. if ( $.isFunction( complete ) ) {
  4929. complete.call( elem[0] );
  4930. }
  4931. if ( $.isFunction( next ) ) {
  4932. next();
  4933. }
  4934. }
  4935. // If the element already has the correct final state, delegate to
  4936. // the core methods so the internal tracking of "olddisplay" works.
  4937. if ( elem.is( ":hidden" ) ? mode === "hide" : mode === "show" ) {
  4938. elem[ mode ]();
  4939. done();
  4940. } else {
  4941. effectMethod.call( elem[0], args, done );
  4942. }
  4943. }
  4944. return queue === false ? this.each( run ) : this.queue( queue || "fx", run );
  4945. },
  4946. show: (function( orig ) {
  4947. return function( option ) {
  4948. if ( standardAnimationOption( option ) ) {
  4949. return orig.apply( this, arguments );
  4950. } else {
  4951. var args = _normalizeArguments.apply( this, arguments );
  4952. args.mode = "show";
  4953. return this.effect.call( this, args );
  4954. }
  4955. };
  4956. })( $.fn.show ),
  4957. hide: (function( orig ) {
  4958. return function( option ) {
  4959. if ( standardAnimationOption( option ) ) {
  4960. return orig.apply( this, arguments );
  4961. } else {
  4962. var args = _normalizeArguments.apply( this, arguments );
  4963. args.mode = "hide";
  4964. return this.effect.call( this, args );
  4965. }
  4966. };
  4967. })( $.fn.hide ),
  4968. toggle: (function( orig ) {
  4969. return function( option ) {
  4970. if ( standardAnimationOption( option ) || typeof option === "boolean" ) {
  4971. return orig.apply( this, arguments );
  4972. } else {
  4973. var args = _normalizeArguments.apply( this, arguments );
  4974. args.mode = "toggle";
  4975. return this.effect.call( this, args );
  4976. }
  4977. };
  4978. })( $.fn.toggle ),
  4979. // helper functions
  4980. cssUnit: function(key) {
  4981. var style = this.css( key ),
  4982. val = [];
  4983. $.each( [ "em", "px", "%", "pt" ], function( i, unit ) {
  4984. if ( style.indexOf( unit ) > 0 ) {
  4985. val = [ parseFloat( style ), unit ];
  4986. }
  4987. });
  4988. return val;
  4989. }
  4990. });
  4991. })();
  4992. /******************************************************************************/
  4993. /*********************************** EASING ***********************************/
  4994. /******************************************************************************/
  4995. (function() {
  4996. // based on easing equations from Robert Penner (http://www.robertpenner.com/easing)
  4997. var baseEasings = {};
  4998. $.each( [ "Quad", "Cubic", "Quart", "Quint", "Expo" ], function( i, name ) {
  4999. baseEasings[ name ] = function( p ) {
  5000. return Math.pow( p, i + 2 );
  5001. };
  5002. });
  5003. $.extend( baseEasings, {
  5004. Sine: function ( p ) {
  5005. return 1 - Math.cos( p * Math.PI / 2 );
  5006. },
  5007. Circ: function ( p ) {
  5008. return 1 - Math.sqrt( 1 - p * p );
  5009. },
  5010. Elastic: function( p ) {
  5011. return p === 0 || p === 1 ? p :
  5012. -Math.pow( 2, 8 * (p - 1) ) * Math.sin( ( (p - 1) * 80 - 7.5 ) * Math.PI / 15 );
  5013. },
  5014. Back: function( p ) {
  5015. return p * p * ( 3 * p - 2 );
  5016. },
  5017. Bounce: function ( p ) {
  5018. var pow2,
  5019. bounce = 4;
  5020. while ( p < ( ( pow2 = Math.pow( 2, --bounce ) ) - 1 ) / 11 ) {}
  5021. return 1 / Math.pow( 4, 3 - bounce ) - 7.5625 * Math.pow( ( pow2 * 3 - 2 ) / 22 - p, 2 );
  5022. }
  5023. });
  5024. $.each( baseEasings, function( name, easeIn ) {
  5025. $.easing[ "easeIn" + name ] = easeIn;
  5026. $.easing[ "easeOut" + name ] = function( p ) {
  5027. return 1 - easeIn( 1 - p );
  5028. };
  5029. $.easing[ "easeInOut" + name ] = function( p ) {
  5030. return p < 0.5 ?
  5031. easeIn( p * 2 ) / 2 :
  5032. 1 - easeIn( p * -2 + 2 ) / 2;
  5033. };
  5034. });
  5035. })();
  5036. })(jQuery);
  5037. (function( $, undefined ) {
  5038. var uid = 0,
  5039. hideProps = {},
  5040. showProps = {};
  5041. hideProps.height = hideProps.paddingTop = hideProps.paddingBottom =
  5042. hideProps.borderTopWidth = hideProps.borderBottomWidth = "hide";
  5043. showProps.height = showProps.paddingTop = showProps.paddingBottom =
  5044. showProps.borderTopWidth = showProps.borderBottomWidth = "show";
  5045. $.widget( "ui.accordion", {
  5046. version: "1.10.3",
  5047. options: {
  5048. active: 0,
  5049. animate: {},
  5050. collapsible: false,
  5051. event: "click",
  5052. header: "> li > :first-child,> :not(li):even",
  5053. heightStyle: "auto",
  5054. icons: {
  5055. activeHeader: "ui-icon-triangle-1-s",
  5056. header: "ui-icon-triangle-1-e"
  5057. },
  5058. // callbacks
  5059. activate: null,
  5060. beforeActivate: null
  5061. },
  5062. _create: function() {
  5063. var options = this.options;
  5064. this.prevShow = this.prevHide = $();
  5065. this.element.addClass( "ui-accordion ui-widget ui-helper-reset" )
  5066. // ARIA
  5067. .attr( "role", "tablist" );
  5068. // don't allow collapsible: false and active: false / null
  5069. if ( !options.collapsible && (options.active === false || options.active == null) ) {
  5070. options.active = 0;
  5071. }
  5072. this._processPanels();
  5073. // handle negative values
  5074. if ( options.active < 0 ) {
  5075. options.active += this.headers.length;
  5076. }
  5077. this._refresh();
  5078. },
  5079. _getCreateEventData: function() {
  5080. return {
  5081. header: this.active,
  5082. panel: !this.active.length ? $() : this.active.next(),
  5083. content: !this.active.length ? $() : this.active.next()
  5084. };
  5085. },
  5086. _createIcons: function() {
  5087. var icons = this.options.icons;
  5088. if ( icons ) {
  5089. $( "<span>" )
  5090. .addClass( "ui-accordion-header-icon ui-icon " + icons.header )
  5091. .prependTo( this.headers );
  5092. this.active.children( ".ui-accordion-header-icon" )
  5093. .removeClass( icons.header )
  5094. .addClass( icons.activeHeader );
  5095. this.headers.addClass( "ui-accordion-icons" );
  5096. }
  5097. },
  5098. _destroyIcons: function() {
  5099. this.headers
  5100. .removeClass( "ui-accordion-icons" )
  5101. .children( ".ui-accordion-header-icon" )
  5102. .remove();
  5103. },
  5104. _destroy: function() {
  5105. var contents;
  5106. // clean up main element
  5107. this.element
  5108. .removeClass( "ui-accordion ui-widget ui-helper-reset" )
  5109. .removeAttr( "role" );
  5110. // clean up headers
  5111. this.headers
  5112. .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" )
  5113. .removeAttr( "role" )
  5114. .removeAttr( "aria-selected" )
  5115. .removeAttr( "aria-controls" )
  5116. .removeAttr( "tabIndex" )
  5117. .each(function() {
  5118. if ( /^ui-accordion/.test( this.id ) ) {
  5119. this.removeAttribute( "id" );
  5120. }
  5121. });
  5122. this._destroyIcons();
  5123. // clean up content panels
  5124. contents = this.headers.next()
  5125. .css( "display", "" )
  5126. .removeAttr( "role" )
  5127. .removeAttr( "aria-expanded" )
  5128. .removeAttr( "aria-hidden" )
  5129. .removeAttr( "aria-labelledby" )
  5130. .removeClass( "ui-helper-reset ui-widget-content ui-corner-bottom ui-accordion-content ui-accordion-content-active ui-state-disabled" )
  5131. .each(function() {
  5132. if ( /^ui-accordion/.test( this.id ) ) {
  5133. this.removeAttribute( "id" );
  5134. }
  5135. });
  5136. if ( this.options.heightStyle !== "content" ) {
  5137. contents.css( "height", "" );
  5138. }
  5139. },
  5140. _setOption: function( key, value ) {
  5141. if ( key === "active" ) {
  5142. // _activate() will handle invalid values and update this.options
  5143. this._activate( value );
  5144. return;
  5145. }
  5146. if ( key === "event" ) {
  5147. if ( this.options.event ) {
  5148. this._off( this.headers, this.options.event );
  5149. }
  5150. this._setupEvents( value );
  5151. }
  5152. this._super( key, value );
  5153. // setting collapsible: false while collapsed; open first panel
  5154. if ( key === "collapsible" && !value && this.options.active === false ) {
  5155. this._activate( 0 );
  5156. }
  5157. if ( key === "icons" ) {
  5158. this._destroyIcons();
  5159. if ( value ) {
  5160. this._createIcons();
  5161. }
  5162. }
  5163. // #5332 - opacity doesn't cascade to positioned elements in IE
  5164. // so we need to add the disabled class to the headers and panels
  5165. if ( key === "disabled" ) {
  5166. this.headers.add( this.headers.next() )
  5167. .toggleClass( "ui-state-disabled", !!value );
  5168. }
  5169. },
  5170. _keydown: function( event ) {
  5171. /*jshint maxcomplexity:15*/
  5172. if ( event.altKey || event.ctrlKey ) {
  5173. return;
  5174. }
  5175. var keyCode = $.ui.keyCode,
  5176. length = this.headers.length,
  5177. currentIndex = this.headers.index( event.target ),
  5178. toFocus = false;
  5179. switch ( event.keyCode ) {
  5180. case keyCode.RIGHT:
  5181. case keyCode.DOWN:
  5182. toFocus = this.headers[ ( currentIndex + 1 ) % length ];
  5183. break;
  5184. case keyCode.LEFT:
  5185. case keyCode.UP:
  5186. toFocus = this.headers[ ( currentIndex - 1 + length ) % length ];
  5187. break;
  5188. case keyCode.SPACE:
  5189. case keyCode.ENTER:
  5190. this._eventHandler( event );
  5191. break;
  5192. case keyCode.HOME:
  5193. toFocus = this.headers[ 0 ];
  5194. break;
  5195. case keyCode.END:
  5196. toFocus = this.headers[ length - 1 ];
  5197. break;
  5198. }
  5199. if ( toFocus ) {
  5200. $( event.target ).attr( "tabIndex", -1 );
  5201. $( toFocus ).attr( "tabIndex", 0 );
  5202. toFocus.focus();
  5203. event.preventDefault();
  5204. }
  5205. },
  5206. _panelKeyDown : function( event ) {
  5207. if ( event.keyCode === $.ui.keyCode.UP && event.ctrlKey ) {
  5208. $( event.currentTarget ).prev().focus();
  5209. }
  5210. },
  5211. refresh: function() {
  5212. var options = this.options;
  5213. this._processPanels();
  5214. // was collapsed or no panel
  5215. if ( ( options.active === false && options.collapsible === true ) || !this.headers.length ) {
  5216. options.active = false;
  5217. this.active = $();
  5218. // active false only when collapsible is true
  5219. } else if ( options.active === false ) {
  5220. this._activate( 0 );
  5221. // was active, but active panel is gone
  5222. } else if ( this.active.length && !$.contains( this.element[ 0 ], this.active[ 0 ] ) ) {
  5223. // all remaining panel are disabled
  5224. if ( this.headers.length === this.headers.find(".ui-state-disabled").length ) {
  5225. options.active = false;
  5226. this.active = $();
  5227. // activate previous panel
  5228. } else {
  5229. this._activate( Math.max( 0, options.active - 1 ) );
  5230. }
  5231. // was active, active panel still exists
  5232. } else {
  5233. // make sure active index is correct
  5234. options.active = this.headers.index( this.active );
  5235. }
  5236. this._destroyIcons();
  5237. this._refresh();
  5238. },
  5239. _processPanels: function() {
  5240. this.headers = this.element.find( this.options.header )
  5241. .addClass( "ui-accordion-header ui-helper-reset ui-state-default ui-corner-all" );
  5242. this.headers.next()
  5243. .addClass( "ui-accordion-content ui-helper-reset ui-widget-content ui-corner-bottom" )
  5244. .filter(":not(.ui-accordion-content-active)")
  5245. .hide();
  5246. },
  5247. _refresh: function() {
  5248. var maxHeight,
  5249. options = this.options,
  5250. heightStyle = options.heightStyle,
  5251. parent = this.element.parent(),
  5252. accordionId = this.accordionId = "ui-accordion-" +
  5253. (this.element.attr( "id" ) || ++uid);
  5254. this.active = this._findActive( options.active )
  5255. .addClass( "ui-accordion-header-active ui-state-active ui-corner-top" )
  5256. .removeClass( "ui-corner-all" );
  5257. this.active.next()
  5258. .addClass( "ui-accordion-content-active" )
  5259. .show();
  5260. this.headers
  5261. .attr( "role", "tab" )
  5262. .each(function( i ) {
  5263. var header = $( this ),
  5264. headerId = header.attr( "id" ),
  5265. panel = header.next(),
  5266. panelId = panel.attr( "id" );
  5267. if ( !headerId ) {
  5268. headerId = accordionId + "-header-" + i;
  5269. header.attr( "id", headerId );
  5270. }
  5271. if ( !panelId ) {
  5272. panelId = accordionId + "-panel-" + i;
  5273. panel.attr( "id", panelId );
  5274. }
  5275. header.attr( "aria-controls", panelId );
  5276. panel.attr( "aria-labelledby", headerId );
  5277. })
  5278. .next()
  5279. .attr( "role", "tabpanel" );
  5280. this.headers
  5281. .not( this.active )
  5282. .attr({
  5283. "aria-selected": "false",
  5284. tabIndex: -1
  5285. })
  5286. .next()
  5287. .attr({
  5288. "aria-expanded": "false",
  5289. "aria-hidden": "true"
  5290. })
  5291. .hide();
  5292. // make sure at least one header is in the tab order
  5293. if ( !this.active.length ) {
  5294. this.headers.eq( 0 ).attr( "tabIndex", 0 );
  5295. } else {
  5296. this.active.attr({
  5297. "aria-selected": "true",
  5298. tabIndex: 0
  5299. })
  5300. .next()
  5301. .attr({
  5302. "aria-expanded": "true",
  5303. "aria-hidden": "false"
  5304. });
  5305. }
  5306. this._createIcons();
  5307. this._setupEvents( options.event );
  5308. if ( heightStyle === "fill" ) {
  5309. maxHeight = parent.height();
  5310. this.element.siblings( ":visible" ).each(function() {
  5311. var elem = $( this ),
  5312. position = elem.css( "position" );
  5313. if ( position === "absolute" || position === "fixed" ) {
  5314. return;
  5315. }
  5316. maxHeight -= elem.outerHeight( true );
  5317. });
  5318. this.headers.each(function() {
  5319. maxHeight -= $( this ).outerHeight( true );
  5320. });
  5321. this.headers.next()
  5322. .each(function() {
  5323. $( this ).height( Math.max( 0, maxHeight -
  5324. $( this ).innerHeight() + $( this ).height() ) );
  5325. })
  5326. .css( "overflow", "auto" );
  5327. } else if ( heightStyle === "auto" ) {
  5328. maxHeight = 0;
  5329. this.headers.next()
  5330. .each(function() {
  5331. maxHeight = Math.max( maxHeight, $( this ).css( "height", "" ).height() );
  5332. })
  5333. .height( maxHeight );
  5334. }
  5335. },
  5336. _activate: function( index ) {
  5337. var active = this._findActive( index )[ 0 ];
  5338. // trying to activate the already active panel
  5339. if ( active === this.active[ 0 ] ) {
  5340. return;
  5341. }
  5342. // trying to collapse, simulate a click on the currently active header
  5343. active = active || this.active[ 0 ];
  5344. this._eventHandler({
  5345. target: active,
  5346. currentTarget: active,
  5347. preventDefault: $.noop
  5348. });
  5349. },
  5350. _findActive: function( selector ) {
  5351. return typeof selector === "number" ? this.headers.eq( selector ) : $();
  5352. },
  5353. _setupEvents: function( event ) {
  5354. var events = {
  5355. keydown: "_keydown"
  5356. };
  5357. if ( event ) {
  5358. $.each( event.split(" "), function( index, eventName ) {
  5359. events[ eventName ] = "_eventHandler";
  5360. });
  5361. }
  5362. this._off( this.headers.add( this.headers.next() ) );
  5363. this._on( this.headers, events );
  5364. this._on( this.headers.next(), { keydown: "_panelKeyDown" });
  5365. this._hoverable( this.headers );
  5366. this._focusable( this.headers );
  5367. },
  5368. _eventHandler: function( event ) {
  5369. var options = this.options,
  5370. active = this.active,
  5371. clicked = $( event.currentTarget ),
  5372. clickedIsActive = clicked[ 0 ] === active[ 0 ],
  5373. collapsing = clickedIsActive && options.collapsible,
  5374. toShow = collapsing ? $() : clicked.next(),
  5375. toHide = active.next(),
  5376. eventData = {
  5377. oldHeader: active,
  5378. oldPanel: toHide,
  5379. newHeader: collapsing ? $() : clicked,
  5380. newPanel: toShow
  5381. };
  5382. event.preventDefault();
  5383. if (
  5384. // click on active header, but not collapsible
  5385. ( clickedIsActive && !options.collapsible ) ||
  5386. // allow canceling activation
  5387. ( this._trigger( "beforeActivate", event, eventData ) === false ) ) {
  5388. return;
  5389. }
  5390. options.active = collapsing ? false : this.headers.index( clicked );
  5391. // when the call to ._toggle() comes after the class changes
  5392. // it causes a very odd bug in IE 8 (see #6720)
  5393. this.active = clickedIsActive ? $() : clicked;
  5394. this._toggle( eventData );
  5395. // switch classes
  5396. // corner classes on the previously active header stay after the animation
  5397. active.removeClass( "ui-accordion-header-active ui-state-active" );
  5398. if ( options.icons ) {
  5399. active.children( ".ui-accordion-header-icon" )
  5400. .removeClass( options.icons.activeHeader )
  5401. .addClass( options.icons.header );
  5402. }
  5403. if ( !clickedIsActive ) {
  5404. clicked
  5405. .removeClass( "ui-corner-all" )
  5406. .addClass( "ui-accordion-header-active ui-state-active ui-corner-top" );
  5407. if ( options.icons ) {
  5408. clicked.children( ".ui-accordion-header-icon" )
  5409. .removeClass( options.icons.header )
  5410. .addClass( options.icons.activeHeader );
  5411. }
  5412. clicked
  5413. .next()
  5414. .addClass( "ui-accordion-content-active" );
  5415. }
  5416. },
  5417. _toggle: function( data ) {
  5418. var toShow = data.newPanel,
  5419. toHide = this.prevShow.length ? this.prevShow : data.oldPanel;
  5420. // handle activating a panel during the animation for another activation
  5421. this.prevShow.add( this.prevHide ).stop( true, true );
  5422. this.prevShow = toShow;
  5423. this.prevHide = toHide;
  5424. if ( this.options.animate ) {
  5425. this._animate( toShow, toHide, data );
  5426. } else {
  5427. toHide.hide();
  5428. toShow.show();
  5429. this._toggleComplete( data );
  5430. }
  5431. toHide.attr({
  5432. "aria-expanded": "false",
  5433. "aria-hidden": "true"
  5434. });
  5435. toHide.prev().attr( "aria-selected", "false" );
  5436. // if we're switching panels, remove the old header from the tab order
  5437. // if we're opening from collapsed state, remove the previous header from the tab order
  5438. // if we're collapsing, then keep the collapsing header in the tab order
  5439. if ( toShow.length && toHide.length ) {
  5440. toHide.prev().attr( "tabIndex", -1 );
  5441. } else if ( toShow.length ) {
  5442. this.headers.filter(function() {
  5443. return $( this ).attr( "tabIndex" ) === 0;
  5444. })
  5445. .attr( "tabIndex", -1 );
  5446. }
  5447. toShow
  5448. .attr({
  5449. "aria-expanded": "true",
  5450. "aria-hidden": "false"
  5451. })
  5452. .prev()
  5453. .attr({
  5454. "aria-selected": "true",
  5455. tabIndex: 0
  5456. });
  5457. },
  5458. _animate: function( toShow, toHide, data ) {
  5459. var total, easing, duration,
  5460. that = this,
  5461. adjust = 0,
  5462. down = toShow.length &&
  5463. ( !toHide.length || ( toShow.index() < toHide.index() ) ),
  5464. animate = this.options.animate || {},
  5465. options = down && animate.down || animate,
  5466. complete = function() {
  5467. that._toggleComplete( data );
  5468. };
  5469. if ( typeof options === "number" ) {
  5470. duration = options;
  5471. }
  5472. if ( typeof options === "string" ) {
  5473. easing = options;
  5474. }
  5475. // fall back from options to animation in case of partial down settings
  5476. easing = easing || options.easing || animate.easing;
  5477. duration = duration || options.duration || animate.duration;
  5478. if ( !toHide.length ) {
  5479. return toShow.animate( showProps, duration, easing, complete );
  5480. }
  5481. if ( !toShow.length ) {
  5482. return toHide.animate( hideProps, duration, easing, complete );
  5483. }
  5484. total = toShow.show().outerHeight();
  5485. toHide.animate( hideProps, {
  5486. duration: duration,
  5487. easing: easing,
  5488. step: function( now, fx ) {
  5489. fx.now = Math.round( now );
  5490. }
  5491. });
  5492. toShow
  5493. .hide()
  5494. .animate( showProps, {
  5495. duration: duration,
  5496. easing: easing,
  5497. complete: complete,
  5498. step: function( now, fx ) {
  5499. fx.now = Math.round( now );
  5500. if ( fx.prop !== "height" ) {
  5501. adjust += fx.now;
  5502. } else if ( that.options.heightStyle !== "content" ) {
  5503. fx.now = Math.round( total - toHide.outerHeight() - adjust );
  5504. adjust = 0;
  5505. }
  5506. }
  5507. });
  5508. },
  5509. _toggleComplete: function( data ) {
  5510. var toHide = data.oldPanel;
  5511. toHide
  5512. .removeClass( "ui-accordion-content-active" )
  5513. .prev()
  5514. .removeClass( "ui-corner-top" )
  5515. .addClass( "ui-corner-all" );
  5516. // Work around for rendering bug in IE (#5421)
  5517. if ( toHide.length ) {
  5518. toHide.parent()[0].className = toHide.parent()[0].className;
  5519. }
  5520. this._trigger( "activate", null, data );
  5521. }
  5522. });
  5523. })( jQuery );
  5524. (function( $, undefined ) {
  5525. // used to prevent race conditions with remote data sources
  5526. var requestIndex = 0;
  5527. $.widget( "ui.autocomplete", {
  5528. version: "1.10.3",
  5529. defaultElement: "<input>",
  5530. options: {
  5531. appendTo: null,
  5532. autoFocus: false,
  5533. delay: 300,
  5534. minLength: 1,
  5535. position: {
  5536. my: "left top",
  5537. at: "left bottom",
  5538. collision: "none"
  5539. },
  5540. source: null,
  5541. // callbacks
  5542. change: null,
  5543. close: null,
  5544. focus: null,
  5545. open: null,
  5546. response: null,
  5547. search: null,
  5548. select: null
  5549. },
  5550. pending: 0,
  5551. _create: function() {
  5552. // Some browsers only repeat keydown events, not keypress events,
  5553. // so we use the suppressKeyPress flag to determine if we've already
  5554. // handled the keydown event. #7269
  5555. // Unfortunately the code for & in keypress is the same as the up arrow,
  5556. // so we use the suppressKeyPressRepeat flag to avoid handling keypress
  5557. // events when we know the keydown event was used to modify the
  5558. // search term. #7799
  5559. var suppressKeyPress, suppressKeyPressRepeat, suppressInput,
  5560. nodeName = this.element[0].nodeName.toLowerCase(),
  5561. isTextarea = nodeName === "textarea",
  5562. isInput = nodeName === "input";
  5563. this.isMultiLine =
  5564. // Textareas are always multi-line
  5565. isTextarea ? true :
  5566. // Inputs are always single-line, even if inside a contentEditable element
  5567. // IE also treats inputs as contentEditable
  5568. isInput ? false :
  5569. // All other element types are determined by whether or not they're contentEditable
  5570. this.element.prop( "isContentEditable" );
  5571. this.valueMethod = this.element[ isTextarea || isInput ? "val" : "text" ];
  5572. this.isNewMenu = true;
  5573. this.element
  5574. .addClass( "ui-autocomplete-input" )
  5575. .attr( "autocomplete", "off" );
  5576. this._on( this.element, {
  5577. keydown: function( event ) {
  5578. /*jshint maxcomplexity:15*/
  5579. if ( this.element.prop( "readOnly" ) ) {
  5580. suppressKeyPress = true;
  5581. suppressInput = true;
  5582. suppressKeyPressRepeat = true;
  5583. return;
  5584. }
  5585. suppressKeyPress = false;
  5586. suppressInput = false;
  5587. suppressKeyPressRepeat = false;
  5588. var keyCode = $.ui.keyCode;
  5589. switch( event.keyCode ) {
  5590. case keyCode.PAGE_UP:
  5591. suppressKeyPress = true;
  5592. this._move( "previousPage", event );
  5593. break;
  5594. case keyCode.PAGE_DOWN:
  5595. suppressKeyPress = true;
  5596. this._move( "nextPage", event );
  5597. break;
  5598. case keyCode.UP:
  5599. suppressKeyPress = true;
  5600. this._keyEvent( "previous", event );
  5601. break;
  5602. case keyCode.DOWN:
  5603. suppressKeyPress = true;
  5604. this._keyEvent( "next", event );
  5605. break;
  5606. case keyCode.ENTER:
  5607. case keyCode.NUMPAD_ENTER:
  5608. // when menu is open and has focus
  5609. if ( this.menu.active ) {
  5610. // #6055 - Opera still allows the keypress to occur
  5611. // which causes forms to submit
  5612. suppressKeyPress = true;
  5613. event.preventDefault();
  5614. this.menu.select( event );
  5615. }
  5616. break;
  5617. case keyCode.TAB:
  5618. if ( this.menu.active ) {
  5619. this.menu.select( event );
  5620. }
  5621. break;
  5622. case keyCode.ESCAPE:
  5623. if ( this.menu.element.is( ":visible" ) ) {
  5624. this._value( this.term );
  5625. this.close( event );
  5626. // Different browsers have different default behavior for escape
  5627. // Single press can mean undo or clear
  5628. // Double press in IE means clear the whole form
  5629. event.preventDefault();
  5630. }
  5631. break;
  5632. default:
  5633. suppressKeyPressRepeat = true;
  5634. // search timeout should be triggered before the input value is changed
  5635. this._searchTimeout( event );
  5636. break;
  5637. }
  5638. },
  5639. keypress: function( event ) {
  5640. if ( suppressKeyPress ) {
  5641. suppressKeyPress = false;
  5642. if ( !this.isMultiLine || this.menu.element.is( ":visible" ) ) {
  5643. event.preventDefault();
  5644. }
  5645. return;
  5646. }
  5647. if ( suppressKeyPressRepeat ) {
  5648. return;
  5649. }
  5650. // replicate some key handlers to allow them to repeat in Firefox and Opera
  5651. var keyCode = $.ui.keyCode;
  5652. switch( event.keyCode ) {
  5653. case keyCode.PAGE_UP:
  5654. this._move( "previousPage", event );
  5655. break;
  5656. case keyCode.PAGE_DOWN:
  5657. this._move( "nextPage", event );
  5658. break;
  5659. case keyCode.UP:
  5660. this._keyEvent( "previous", event );
  5661. break;
  5662. case keyCode.DOWN:
  5663. this._keyEvent( "next", event );
  5664. break;
  5665. }
  5666. },
  5667. input: function( event ) {
  5668. if ( suppressInput ) {
  5669. suppressInput = false;
  5670. event.preventDefault();
  5671. return;
  5672. }
  5673. this._searchTimeout( event );
  5674. },
  5675. focus: function() {
  5676. this.selectedItem = null;
  5677. this.previous = this._value();
  5678. },
  5679. blur: function( event ) {
  5680. if ( this.cancelBlur ) {
  5681. delete this.cancelBlur;
  5682. return;
  5683. }
  5684. clearTimeout( this.searching );
  5685. this.close( event );
  5686. this._change( event );
  5687. }
  5688. });
  5689. this._initSource();
  5690. this.menu = $( "<ul>" )
  5691. .addClass( "ui-autocomplete ui-front" )
  5692. .appendTo( this._appendTo() )
  5693. .menu({
  5694. // disable ARIA support, the live region takes care of that
  5695. role: null
  5696. })
  5697. .hide()
  5698. .data( "ui-menu" );
  5699. this._on( this.menu.element, {
  5700. mousedown: function( event ) {
  5701. // prevent moving focus out of the text field
  5702. event.preventDefault();
  5703. // IE doesn't prevent moving focus even with event.preventDefault()
  5704. // so we set a flag to know when we should ignore the blur event
  5705. this.cancelBlur = true;
  5706. this._delay(function() {
  5707. delete this.cancelBlur;
  5708. });
  5709. // clicking on the scrollbar causes focus to shift to the body
  5710. // but we can't detect a mouseup or a click immediately afterward
  5711. // so we have to track the next mousedown and close the menu if
  5712. // the user clicks somewhere outside of the autocomplete
  5713. var menuElement = this.menu.element[ 0 ];
  5714. if ( !$( event.target ).closest( ".ui-menu-item" ).length ) {
  5715. this._delay(function() {
  5716. var that = this;
  5717. this.document.one( "mousedown", function( event ) {
  5718. if ( event.target !== that.element[ 0 ] &&
  5719. event.target !== menuElement &&
  5720. !$.contains( menuElement, event.target ) ) {
  5721. that.close();
  5722. }
  5723. });
  5724. });
  5725. }
  5726. },
  5727. menufocus: function( event, ui ) {
  5728. // support: Firefox
  5729. // Prevent accidental activation of menu items in Firefox (#7024 #9118)
  5730. if ( this.isNewMenu ) {
  5731. this.isNewMenu = false;
  5732. if ( event.originalEvent && /^mouse/.test( event.originalEvent.type ) ) {
  5733. this.menu.blur();
  5734. this.document.one( "mousemove", function() {
  5735. $( event.target ).trigger( event.originalEvent );
  5736. });
  5737. return;
  5738. }
  5739. }
  5740. var item = ui.item.data( "ui-autocomplete-item" );
  5741. if ( false !== this._trigger( "focus", event, { item: item } ) ) {
  5742. // use value to match what will end up in the input, if it was a key event
  5743. if ( event.originalEvent && /^key/.test( event.originalEvent.type ) ) {
  5744. this._value( item.value );
  5745. }
  5746. } else {
  5747. // Normally the input is populated with the item's value as the
  5748. // menu is navigated, causing screen readers to notice a change and
  5749. // announce the item. Since the focus event was canceled, this doesn't
  5750. // happen, so we update the live region so that screen readers can
  5751. // still notice the change and announce it.
  5752. this.liveRegion.text( item.value );
  5753. }
  5754. },
  5755. menuselect: function( event, ui ) {
  5756. var item = ui.item.data( "ui-autocomplete-item" ),
  5757. previous = this.previous;
  5758. // only trigger when focus was lost (click on menu)
  5759. if ( this.element[0] !== this.document[0].activeElement ) {
  5760. this.element.focus();
  5761. this.previous = previous;
  5762. // #6109 - IE triggers two focus events and the second
  5763. // is asynchronous, so we need to reset the previous
  5764. // term synchronously and asynchronously :-(
  5765. this._delay(function() {
  5766. this.previous = previous;
  5767. this.selectedItem = item;
  5768. });
  5769. }
  5770. if ( false !== this._trigger( "select", event, { item: item } ) ) {
  5771. this._value( item.value );
  5772. }
  5773. // reset the term after the select event
  5774. // this allows custom select handling to work properly
  5775. this.term = this._value();
  5776. this.close( event );
  5777. this.selectedItem = item;
  5778. }
  5779. });
  5780. this.liveRegion = $( "<span>", {
  5781. role: "status",
  5782. "aria-live": "polite"
  5783. })
  5784. .addClass( "ui-helper-hidden-accessible" )
  5785. .insertBefore( this.element );
  5786. // turning off autocomplete prevents the browser from remembering the
  5787. // value when navigating through history, so we re-enable autocomplete
  5788. // if the page is unloaded before the widget is destroyed. #7790
  5789. this._on( this.window, {
  5790. beforeunload: function() {
  5791. this.element.removeAttr( "autocomplete" );
  5792. }
  5793. });
  5794. },
  5795. _destroy: function() {
  5796. clearTimeout( this.searching );
  5797. this.element
  5798. .removeClass( "ui-autocomplete-input" )
  5799. .removeAttr( "autocomplete" );
  5800. this.menu.element.remove();
  5801. this.liveRegion.remove();
  5802. },
  5803. _setOption: function( key, value ) {
  5804. this._super( key, value );
  5805. if ( key === "source" ) {
  5806. this._initSource();
  5807. }
  5808. if ( key === "appendTo" ) {
  5809. this.menu.element.appendTo( this._appendTo() );
  5810. }
  5811. if ( key === "disabled" && value && this.xhr ) {
  5812. this.xhr.abort();
  5813. }
  5814. },
  5815. _appendTo: function() {
  5816. var element = this.options.appendTo;
  5817. if ( element ) {
  5818. element = element.jquery || element.nodeType ?
  5819. $( element ) :
  5820. this.document.find( element ).eq( 0 );
  5821. }
  5822. if ( !element ) {
  5823. element = this.element.closest( ".ui-front" );
  5824. }
  5825. if ( !element.length ) {
  5826. element = this.document[0].body;
  5827. }
  5828. return element;
  5829. },
  5830. _initSource: function() {
  5831. var array, url,
  5832. that = this;
  5833. if ( $.isArray(this.options.source) ) {
  5834. array = this.options.source;
  5835. this.source = function( request, response ) {
  5836. response( $.ui.autocomplete.filter( array, request.term ) );
  5837. };
  5838. } else if ( typeof this.options.source === "string" ) {
  5839. url = this.options.source;
  5840. this.source = function( request, response ) {
  5841. if ( that.xhr ) {
  5842. that.xhr.abort();
  5843. }
  5844. that.xhr = $.ajax({
  5845. url: url,
  5846. data: request,
  5847. dataType: "json",
  5848. success: function( data ) {
  5849. response( data );
  5850. },
  5851. error: function() {
  5852. response( [] );
  5853. }
  5854. });
  5855. };
  5856. } else {
  5857. this.source = this.options.source;
  5858. }
  5859. },
  5860. _searchTimeout: function( event ) {
  5861. clearTimeout( this.searching );
  5862. this.searching = this._delay(function() {
  5863. // only search if the value has changed
  5864. if ( this.term !== this._value() ) {
  5865. this.selectedItem = null;
  5866. this.search( null, event );
  5867. }
  5868. }, this.options.delay );
  5869. },
  5870. search: function( value, event ) {
  5871. value = value != null ? value : this._value();
  5872. // always save the actual value, not the one passed as an argument
  5873. this.term = this._value();
  5874. if ( value.length < this.options.minLength ) {
  5875. return this.close( event );
  5876. }
  5877. if ( this._trigger( "search", event ) === false ) {
  5878. return;
  5879. }
  5880. return this._search( value );
  5881. },
  5882. _search: function( value ) {
  5883. this.pending++;
  5884. this.element.addClass( "ui-autocomplete-loading" );
  5885. this.cancelSearch = false;
  5886. this.source( { term: value }, this._response() );
  5887. },
  5888. _response: function() {
  5889. var that = this,
  5890. index = ++requestIndex;
  5891. return function( content ) {
  5892. if ( index === requestIndex ) {
  5893. that.__response( content );
  5894. }
  5895. that.pending--;
  5896. if ( !that.pending ) {
  5897. that.element.removeClass( "ui-autocomplete-loading" );
  5898. }
  5899. };
  5900. },
  5901. __response: function( content ) {
  5902. if ( content ) {
  5903. content = this._normalize( content );
  5904. }
  5905. this._trigger( "response", null, { content: content } );
  5906. if ( !this.options.disabled && content && content.length && !this.cancelSearch ) {
  5907. this._suggest( content );
  5908. this._trigger( "open" );
  5909. } else {
  5910. // use ._close() instead of .close() so we don't cancel future searches
  5911. this._close();
  5912. }
  5913. },
  5914. close: function( event ) {
  5915. this.cancelSearch = true;
  5916. this._close( event );
  5917. },
  5918. _close: function( event ) {
  5919. if ( this.menu.element.is( ":visible" ) ) {
  5920. this.menu.element.hide();
  5921. this.menu.blur();
  5922. this.isNewMenu = true;
  5923. this._trigger( "close", event );
  5924. }
  5925. },
  5926. _change: function( event ) {
  5927. if ( this.previous !== this._value() ) {
  5928. this._trigger( "change", event, { item: this.selectedItem } );
  5929. }
  5930. },
  5931. _normalize: function( items ) {
  5932. // assume all items have the right format when the first item is complete
  5933. if ( items.length && items[0].label && items[0].value ) {
  5934. return items;
  5935. }
  5936. return $.map( items, function( item ) {
  5937. if ( typeof item === "string" ) {
  5938. return {
  5939. label: item,
  5940. value: item
  5941. };
  5942. }
  5943. return $.extend({
  5944. label: item.label || item.value,
  5945. value: item.value || item.label
  5946. }, item );
  5947. });
  5948. },
  5949. _suggest: function( items ) {
  5950. var ul = this.menu.element.empty();
  5951. this._renderMenu( ul, items );
  5952. this.isNewMenu = true;
  5953. this.menu.refresh();
  5954. // size and position menu
  5955. ul.show();
  5956. this._resizeMenu();
  5957. ul.position( $.extend({
  5958. of: this.element
  5959. }, this.options.position ));
  5960. if ( this.options.autoFocus ) {
  5961. this.menu.next();
  5962. }
  5963. },
  5964. _resizeMenu: function() {
  5965. var ul = this.menu.element;
  5966. ul.outerWidth( Math.max(
  5967. // Firefox wraps long text (possibly a rounding bug)
  5968. // so we add 1px to avoid the wrapping (#7513)
  5969. ul.width( "" ).outerWidth() + 1,
  5970. this.element.outerWidth()
  5971. ) );
  5972. },
  5973. _renderMenu: function( ul, items ) {
  5974. var that = this;
  5975. $.each( items, function( index, item ) {
  5976. that._renderItemData( ul, item );
  5977. });
  5978. },
  5979. _renderItemData: function( ul, item ) {
  5980. return this._renderItem( ul, item ).data( "ui-autocomplete-item", item );
  5981. },
  5982. _renderItem: function( ul, item ) {
  5983. return $( "<li>" )
  5984. .append( $( "<a>" ).text( item.label ) )
  5985. .appendTo( ul );
  5986. },
  5987. _move: function( direction, event ) {
  5988. if ( !this.menu.element.is( ":visible" ) ) {
  5989. this.search( null, event );
  5990. return;
  5991. }
  5992. if ( this.menu.isFirstItem() && /^previous/.test( direction ) ||
  5993. this.menu.isLastItem() && /^next/.test( direction ) ) {
  5994. this._value( this.term );
  5995. this.menu.blur();
  5996. return;
  5997. }
  5998. this.menu[ direction ]( event );
  5999. },
  6000. widget: function() {
  6001. return this.menu.element;
  6002. },
  6003. _value: function() {
  6004. return this.valueMethod.apply( this.element, arguments );
  6005. },
  6006. _keyEvent: function( keyEvent, event ) {
  6007. if ( !this.isMultiLine || this.menu.element.is( ":visible" ) ) {
  6008. this._move( keyEvent, event );
  6009. // prevents moving cursor to beginning/end of the text field in some browsers
  6010. event.preventDefault();
  6011. }
  6012. }
  6013. });
  6014. $.extend( $.ui.autocomplete, {
  6015. escapeRegex: function( value ) {
  6016. return value.replace(/[\-\[\]{}()*+?.,\\\^$|#\s]/g, "\\$&");
  6017. },
  6018. filter: function(array, term) {
  6019. var matcher = new RegExp( $.ui.autocomplete.escapeRegex(term), "i" );
  6020. return $.grep( array, function(value) {
  6021. return matcher.test( value.label || value.value || value );
  6022. });
  6023. }
  6024. });
  6025. // live region extension, adding a `messages` option
  6026. // NOTE: This is an experimental API. We are still investigating
  6027. // a full solution for string manipulation and internationalization.
  6028. $.widget( "ui.autocomplete", $.ui.autocomplete, {
  6029. options: {
  6030. messages: {
  6031. noResults: "No search results.",
  6032. results: function( amount ) {
  6033. return amount + ( amount > 1 ? " results are" : " result is" ) +
  6034. " available, use up and down arrow keys to navigate.";
  6035. }
  6036. }
  6037. },
  6038. __response: function( content ) {
  6039. var message;
  6040. this._superApply( arguments );
  6041. if ( this.options.disabled || this.cancelSearch ) {
  6042. return;
  6043. }
  6044. if ( content && content.length ) {
  6045. message = this.options.messages.results( content.length );
  6046. } else {
  6047. message = this.options.messages.noResults;
  6048. }
  6049. this.liveRegion.text( message );
  6050. }
  6051. });
  6052. }( jQuery ));
  6053. (function( $, undefined ) {
  6054. var lastActive, startXPos, startYPos, clickDragged,
  6055. baseClasses = "ui-button ui-widget ui-state-default ui-corner-all",
  6056. stateClasses = "ui-state-hover ui-state-active ",
  6057. 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",
  6058. formResetHandler = function() {
  6059. var form = $( this );
  6060. setTimeout(function() {
  6061. form.find( ":ui-button" ).button( "refresh" );
  6062. }, 1 );
  6063. },
  6064. radioGroup = function( radio ) {
  6065. var name = radio.name,
  6066. form = radio.form,
  6067. radios = $( [] );
  6068. if ( name ) {
  6069. name = name.replace( /'/g, "\\'" );
  6070. if ( form ) {
  6071. radios = $( form ).find( "[name='" + name + "']" );
  6072. } else {
  6073. radios = $( "[name='" + name + "']", radio.ownerDocument )
  6074. .filter(function() {
  6075. return !this.form;
  6076. });
  6077. }
  6078. }
  6079. return radios;
  6080. };
  6081. $.widget( "ui.button", {
  6082. version: "1.10.3",
  6083. defaultElement: "<button>",
  6084. options: {
  6085. disabled: null,
  6086. text: true,
  6087. label: null,
  6088. icons: {
  6089. primary: null,
  6090. secondary: null
  6091. }
  6092. },
  6093. _create: function() {
  6094. this.element.closest( "form" )
  6095. .unbind( "reset" + this.eventNamespace )
  6096. .bind( "reset" + this.eventNamespace, formResetHandler );
  6097. if ( typeof this.options.disabled !== "boolean" ) {
  6098. this.options.disabled = !!this.element.prop( "disabled" );
  6099. } else {
  6100. this.element.prop( "disabled", this.options.disabled );
  6101. }
  6102. this._determineButtonType();
  6103. this.hasTitle = !!this.buttonElement.attr( "title" );
  6104. var that = this,
  6105. options = this.options,
  6106. toggleButton = this.type === "checkbox" || this.type === "radio",
  6107. activeClass = !toggleButton ? "ui-state-active" : "",
  6108. focusClass = "ui-state-focus";
  6109. if ( options.label === null ) {
  6110. options.label = (this.type === "input" ? this.buttonElement.val() : this.buttonElement.html());
  6111. }
  6112. this._hoverable( this.buttonElement );
  6113. this.buttonElement
  6114. .addClass( baseClasses )
  6115. .attr( "role", "button" )
  6116. .bind( "mouseenter" + this.eventNamespace, function() {
  6117. if ( options.disabled ) {
  6118. return;
  6119. }
  6120. if ( this === lastActive ) {
  6121. $( this ).addClass( "ui-state-active" );
  6122. }
  6123. })
  6124. .bind( "mouseleave" + this.eventNamespace, function() {
  6125. if ( options.disabled ) {
  6126. return;
  6127. }
  6128. $( this ).removeClass( activeClass );
  6129. })
  6130. .bind( "click" + this.eventNamespace, function( event ) {
  6131. if ( options.disabled ) {
  6132. event.preventDefault();
  6133. event.stopImmediatePropagation();
  6134. }
  6135. });
  6136. this.element
  6137. .bind( "focus" + this.eventNamespace, function() {
  6138. // no need to check disabled, focus won't be triggered anyway
  6139. that.buttonElement.addClass( focusClass );
  6140. })
  6141. .bind( "blur" + this.eventNamespace, function() {
  6142. that.buttonElement.removeClass( focusClass );
  6143. });
  6144. if ( toggleButton ) {
  6145. this.element.bind( "change" + this.eventNamespace, function() {
  6146. if ( clickDragged ) {
  6147. return;
  6148. }
  6149. that.refresh();
  6150. });
  6151. // if mouse moves between mousedown and mouseup (drag) set clickDragged flag
  6152. // prevents issue where button state changes but checkbox/radio checked state
  6153. // does not in Firefox (see ticket #6970)
  6154. this.buttonElement
  6155. .bind( "mousedown" + this.eventNamespace, function( event ) {
  6156. if ( options.disabled ) {
  6157. return;
  6158. }
  6159. clickDragged = false;
  6160. startXPos = event.pageX;
  6161. startYPos = event.pageY;
  6162. })
  6163. .bind( "mouseup" + this.eventNamespace, function( event ) {
  6164. if ( options.disabled ) {
  6165. return;
  6166. }
  6167. if ( startXPos !== event.pageX || startYPos !== event.pageY ) {
  6168. clickDragged = true;
  6169. }
  6170. });
  6171. }
  6172. if ( this.type === "checkbox" ) {
  6173. this.buttonElement.bind( "click" + this.eventNamespace, function() {
  6174. if ( options.disabled || clickDragged ) {
  6175. return false;
  6176. }
  6177. });
  6178. } else if ( this.type === "radio" ) {
  6179. this.buttonElement.bind( "click" + this.eventNamespace, function() {
  6180. if ( options.disabled || clickDragged ) {
  6181. return false;
  6182. }
  6183. $( this ).addClass( "ui-state-active" );
  6184. that.buttonElement.attr( "aria-pressed", "true" );
  6185. var radio = that.element[ 0 ];
  6186. radioGroup( radio )
  6187. .not( radio )
  6188. .map(function() {
  6189. return $( this ).button( "widget" )[ 0 ];
  6190. })
  6191. .removeClass( "ui-state-active" )
  6192. .attr( "aria-pressed", "false" );
  6193. });
  6194. } else {
  6195. this.buttonElement
  6196. .bind( "mousedown" + this.eventNamespace, function() {
  6197. if ( options.disabled ) {
  6198. return false;
  6199. }
  6200. $( this ).addClass( "ui-state-active" );
  6201. lastActive = this;
  6202. that.document.one( "mouseup", function() {
  6203. lastActive = null;
  6204. });
  6205. })
  6206. .bind( "mouseup" + this.eventNamespace, function() {
  6207. if ( options.disabled ) {
  6208. return false;
  6209. }
  6210. $( this ).removeClass( "ui-state-active" );
  6211. })
  6212. .bind( "keydown" + this.eventNamespace, function(event) {
  6213. if ( options.disabled ) {
  6214. return false;
  6215. }
  6216. if ( event.keyCode === $.ui.keyCode.SPACE || event.keyCode === $.ui.keyCode.ENTER ) {
  6217. $( this ).addClass( "ui-state-active" );
  6218. }
  6219. })
  6220. // see #8559, we bind to blur here in case the button element loses
  6221. // focus between keydown and keyup, it would be left in an "active" state
  6222. .bind( "keyup" + this.eventNamespace + " blur" + this.eventNamespace, function() {
  6223. $( this ).removeClass( "ui-state-active" );
  6224. });
  6225. if ( this.buttonElement.is("a") ) {
  6226. this.buttonElement.keyup(function(event) {
  6227. if ( event.keyCode === $.ui.keyCode.SPACE ) {
  6228. // TODO pass through original event correctly (just as 2nd argument doesn't work)
  6229. $( this ).click();
  6230. }
  6231. });
  6232. }
  6233. }
  6234. // TODO: pull out $.Widget's handling for the disabled option into
  6235. // $.Widget.prototype._setOptionDisabled so it's easy to proxy and can
  6236. // be overridden by individual plugins
  6237. this._setOption( "disabled", options.disabled );
  6238. this._resetButton();
  6239. },
  6240. _determineButtonType: function() {
  6241. var ancestor, labelSelector, checked;
  6242. if ( this.element.is("[type=checkbox]") ) {
  6243. this.type = "checkbox";
  6244. } else if ( this.element.is("[type=radio]") ) {
  6245. this.type = "radio";
  6246. } else if ( this.element.is("input") ) {
  6247. this.type = "input";
  6248. } else {
  6249. this.type = "button";
  6250. }
  6251. if ( this.type === "checkbox" || this.type === "radio" ) {
  6252. // we don't search against the document in case the element
  6253. // is disconnected from the DOM
  6254. ancestor = this.element.parents().last();
  6255. labelSelector = "label[for='" + this.element.attr("id") + "']";
  6256. this.buttonElement = ancestor.find( labelSelector );
  6257. if ( !this.buttonElement.length ) {
  6258. ancestor = ancestor.length ? ancestor.siblings() : this.element.siblings();
  6259. this.buttonElement = ancestor.filter( labelSelector );
  6260. if ( !this.buttonElement.length ) {
  6261. this.buttonElement = ancestor.find( labelSelector );
  6262. }
  6263. }
  6264. this.element.addClass( "ui-helper-hidden-accessible" );
  6265. checked = this.element.is( ":checked" );
  6266. if ( checked ) {
  6267. this.buttonElement.addClass( "ui-state-active" );
  6268. }
  6269. this.buttonElement.prop( "aria-pressed", checked );
  6270. } else {
  6271. this.buttonElement = this.element;
  6272. }
  6273. },
  6274. widget: function() {
  6275. return this.buttonElement;
  6276. },
  6277. _destroy: function() {
  6278. this.element
  6279. .removeClass( "ui-helper-hidden-accessible" );
  6280. this.buttonElement
  6281. .removeClass( baseClasses + " " + stateClasses + " " + typeClasses )
  6282. .removeAttr( "role" )
  6283. .removeAttr( "aria-pressed" )
  6284. .html( this.buttonElement.find(".ui-button-text").html() );
  6285. if ( !this.hasTitle ) {
  6286. this.buttonElement.removeAttr( "title" );
  6287. }
  6288. },
  6289. _setOption: function( key, value ) {
  6290. this._super( key, value );
  6291. if ( key === "disabled" ) {
  6292. if ( value ) {
  6293. this.element.prop( "disabled", true );
  6294. } else {
  6295. this.element.prop( "disabled", false );
  6296. }
  6297. return;
  6298. }
  6299. this._resetButton();
  6300. },
  6301. refresh: function() {
  6302. //See #8237 & #8828
  6303. var isDisabled = this.element.is( "input, button" ) ? this.element.is( ":disabled" ) : this.element.hasClass( "ui-button-disabled" );
  6304. if ( isDisabled !== this.options.disabled ) {
  6305. this._setOption( "disabled", isDisabled );
  6306. }
  6307. if ( this.type === "radio" ) {
  6308. radioGroup( this.element[0] ).each(function() {
  6309. if ( $( this ).is( ":checked" ) ) {
  6310. $( this ).button( "widget" )
  6311. .addClass( "ui-state-active" )
  6312. .attr( "aria-pressed", "true" );
  6313. } else {
  6314. $( this ).button( "widget" )
  6315. .removeClass( "ui-state-active" )
  6316. .attr( "aria-pressed", "false" );
  6317. }
  6318. });
  6319. } else if ( this.type === "checkbox" ) {
  6320. if ( this.element.is( ":checked" ) ) {
  6321. this.buttonElement
  6322. .addClass( "ui-state-active" )
  6323. .attr( "aria-pressed", "true" );
  6324. } else {
  6325. this.buttonElement
  6326. .removeClass( "ui-state-active" )
  6327. .attr( "aria-pressed", "false" );
  6328. }
  6329. }
  6330. },
  6331. _resetButton: function() {
  6332. if ( this.type === "input" ) {
  6333. if ( this.options.label ) {
  6334. this.element.val( this.options.label );
  6335. }
  6336. return;
  6337. }
  6338. var buttonElement = this.buttonElement.removeClass( typeClasses ),
  6339. buttonText = $( "<span></span>", this.document[0] )
  6340. .addClass( "ui-button-text" )
  6341. .html( this.options.label )
  6342. .appendTo( buttonElement.empty() )
  6343. .text(),
  6344. icons = this.options.icons,
  6345. multipleIcons = icons.primary && icons.secondary,
  6346. buttonClasses = [];
  6347. if ( icons.primary || icons.secondary ) {
  6348. if ( this.options.text ) {
  6349. buttonClasses.push( "ui-button-text-icon" + ( multipleIcons ? "s" : ( icons.primary ? "-primary" : "-secondary" ) ) );
  6350. }
  6351. if ( icons.primary ) {
  6352. buttonElement.prepend( "<span class='ui-button-icon-primary ui-icon " + icons.primary + "'></span>" );
  6353. }
  6354. if ( icons.secondary ) {
  6355. buttonElement.append( "<span class='ui-button-icon-secondary ui-icon " + icons.secondary + "'></span>" );
  6356. }
  6357. if ( !this.options.text ) {
  6358. buttonClasses.push( multipleIcons ? "ui-button-icons-only" : "ui-button-icon-only" );
  6359. if ( !this.hasTitle ) {
  6360. buttonElement.attr( "title", $.trim( buttonText ) );
  6361. }
  6362. }
  6363. } else {
  6364. buttonClasses.push( "ui-button-text-only" );
  6365. }
  6366. buttonElement.addClass( buttonClasses.join( " " ) );
  6367. }
  6368. });
  6369. $.widget( "ui.buttonset", {
  6370. version: "1.10.3",
  6371. options: {
  6372. items: "button, input[type=button], input[type=submit], input[type=reset], input[type=checkbox], input[type=radio], a, :data(ui-button)"
  6373. },
  6374. _create: function() {
  6375. this.element.addClass( "ui-buttonset" );
  6376. },
  6377. _init: function() {
  6378. this.refresh();
  6379. },
  6380. _setOption: function( key, value ) {
  6381. if ( key === "disabled" ) {
  6382. this.buttons.button( "option", key, value );
  6383. }
  6384. this._super( key, value );
  6385. },
  6386. refresh: function() {
  6387. var rtl = this.element.css( "direction" ) === "rtl";
  6388. this.buttons = this.element.find( this.options.items )
  6389. .filter( ":ui-button" )
  6390. .button( "refresh" )
  6391. .end()
  6392. .not( ":ui-button" )
  6393. .button()
  6394. .end()
  6395. .map(function() {
  6396. return $( this ).button( "widget" )[ 0 ];
  6397. })
  6398. .removeClass( "ui-corner-all ui-corner-left ui-corner-right" )
  6399. .filter( ":first" )
  6400. .addClass( rtl ? "ui-corner-right" : "ui-corner-left" )
  6401. .end()
  6402. .filter( ":last" )
  6403. .addClass( rtl ? "ui-corner-left" : "ui-corner-right" )
  6404. .end()
  6405. .end();
  6406. },
  6407. _destroy: function() {
  6408. this.element.removeClass( "ui-buttonset" );
  6409. this.buttons
  6410. .map(function() {
  6411. return $( this ).button( "widget" )[ 0 ];
  6412. })
  6413. .removeClass( "ui-corner-left ui-corner-right" )
  6414. .end()
  6415. .button( "destroy" );
  6416. }
  6417. });
  6418. }( jQuery ) );
  6419. (function( $, undefined ) {
  6420. $.extend($.ui, { datepicker: { version: "1.10.3" } });
  6421. var PROP_NAME = "datepicker",
  6422. instActive;
  6423. /* Date picker manager.
  6424. Use the singleton instance of this class, $.datepicker, to interact with the date picker.
  6425. Settings for (groups of) date pickers are maintained in an instance object,
  6426. allowing multiple different settings on the same page. */
  6427. function Datepicker() {
  6428. this._curInst = null; // The current instance in use
  6429. this._keyEvent = false; // If the last event was a key event
  6430. this._disabledInputs = []; // List of date picker inputs that have been disabled
  6431. this._datepickerShowing = false; // True if the popup picker is showing , false if not
  6432. this._inDialog = false; // True if showing within a "dialog", false if not
  6433. this._mainDivId = "ui-datepicker-div"; // The ID of the main datepicker division
  6434. this._inlineClass = "ui-datepicker-inline"; // The name of the inline marker class
  6435. this._appendClass = "ui-datepicker-append"; // The name of the append marker class
  6436. this._triggerClass = "ui-datepicker-trigger"; // The name of the trigger marker class
  6437. this._dialogClass = "ui-datepicker-dialog"; // The name of the dialog marker class
  6438. this._disableClass = "ui-datepicker-disabled"; // The name of the disabled covering marker class
  6439. this._unselectableClass = "ui-datepicker-unselectable"; // The name of the unselectable cell marker class
  6440. this._currentClass = "ui-datepicker-current-day"; // The name of the current day marker class
  6441. this._dayOverClass = "ui-datepicker-days-cell-over"; // The name of the day hover marker class
  6442. this.regional = []; // Available regional settings, indexed by language code
  6443. this.regional[""] = { // Default regional settings
  6444. closeText: "Done", // Display text for close link
  6445. prevText: "Prev", // Display text for previous month link
  6446. nextText: "Next", // Display text for next month link
  6447. currentText: "Today", // Display text for current month link
  6448. monthNames: ["January","February","March","April","May","June",
  6449. "July","August","September","October","November","December"], // Names of months for drop-down and formatting
  6450. monthNamesShort: ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"], // For formatting
  6451. dayNames: ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"], // For formatting
  6452. dayNamesShort: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"], // For formatting
  6453. dayNamesMin: ["Su","Mo","Tu","We","Th","Fr","Sa"], // Column headings for days starting at Sunday
  6454. weekHeader: "Wk", // Column header for week of the year
  6455. dateFormat: "mm/dd/yy", // See format options on parseDate
  6456. firstDay: 0, // The first day of the week, Sun = 0, Mon = 1, ...
  6457. isRTL: false, // True if right-to-left language, false if left-to-right
  6458. showMonthAfterYear: false, // True if the year select precedes month, false for month then year
  6459. yearSuffix: "" // Additional text to append to the year in the month headers
  6460. };
  6461. this._defaults = { // Global defaults for all the date picker instances
  6462. showOn: "focus", // "focus" for popup on focus,
  6463. // "button" for trigger button, or "both" for either
  6464. showAnim: "fadeIn", // Name of jQuery animation for popup
  6465. showOptions: {}, // Options for enhanced animations
  6466. defaultDate: null, // Used when field is blank: actual date,
  6467. // +/-number for offset from today, null for today
  6468. appendText: "", // Display text following the input box, e.g. showing the format
  6469. buttonText: "...", // Text for trigger button
  6470. buttonImage: "", // URL for trigger button image
  6471. buttonImageOnly: false, // True if the image appears alone, false if it appears on a button
  6472. hideIfNoPrevNext: false, // True to hide next/previous month links
  6473. // if not applicable, false to just disable them
  6474. navigationAsDateFormat: false, // True if date formatting applied to prev/today/next links
  6475. gotoCurrent: false, // True if today link goes back to current selection instead
  6476. changeMonth: false, // True if month can be selected directly, false if only prev/next
  6477. changeYear: false, // True if year can be selected directly, false if only prev/next
  6478. yearRange: "c-10:c+10", // Range of years to display in drop-down,
  6479. // either relative to today's year (-nn:+nn), relative to currently displayed year
  6480. // (c-nn:c+nn), absolute (nnnn:nnnn), or a combination of the above (nnnn:-n)
  6481. showOtherMonths: false, // True to show dates in other months, false to leave blank
  6482. selectOtherMonths: false, // True to allow selection of dates in other months, false for unselectable
  6483. showWeek: false, // True to show week of the year, false to not show it
  6484. calculateWeek: this.iso8601Week, // How to calculate the week of the year,
  6485. // takes a Date and returns the number of the week for it
  6486. shortYearCutoff: "+10", // Short year values < this are in the current century,
  6487. // > this are in the previous century,
  6488. // string value starting with "+" for current year + value
  6489. minDate: null, // The earliest selectable date, or null for no limit
  6490. maxDate: null, // The latest selectable date, or null for no limit
  6491. duration: "fast", // Duration of display/closure
  6492. beforeShowDay: null, // Function that takes a date and returns an array with
  6493. // [0] = true if selectable, false if not, [1] = custom CSS class name(s) or "",
  6494. // [2] = cell title (optional), e.g. $.datepicker.noWeekends
  6495. beforeShow: null, // Function that takes an input field and
  6496. // returns a set of custom settings for the date picker
  6497. onSelect: null, // Define a callback function when a date is selected
  6498. onChangeMonthYear: null, // Define a callback function when the month or year is changed
  6499. onClose: null, // Define a callback function when the datepicker is closed
  6500. numberOfMonths: 1, // Number of months to show at a time
  6501. showCurrentAtPos: 0, // The position in multipe months at which to show the current month (starting at 0)
  6502. stepMonths: 1, // Number of months to step back/forward
  6503. stepBigMonths: 12, // Number of months to step back/forward for the big links
  6504. altField: "", // Selector for an alternate field to store selected dates into
  6505. altFormat: "", // The date format to use for the alternate field
  6506. constrainInput: true, // The input is constrained by the current date format
  6507. showButtonPanel: false, // True to show button panel, false to not show it
  6508. autoSize: false, // True to size the input for the date format, false to leave as is
  6509. disabled: false // The initial disabled state
  6510. };
  6511. $.extend(this._defaults, this.regional[""]);
  6512. this.dpDiv = bindHover($("<div id='" + this._mainDivId + "' class='ui-datepicker ui-widget ui-widget-content ui-helper-clearfix ui-corner-all'></div>"));
  6513. }
  6514. $.extend(Datepicker.prototype, {
  6515. /* Class name added to elements to indicate already configured with a date picker. */
  6516. markerClassName: "hasDatepicker",
  6517. //Keep track of the maximum number of rows displayed (see #7043)
  6518. maxRows: 4,
  6519. // TODO rename to "widget" when switching to widget factory
  6520. _widgetDatepicker: function() {
  6521. return this.dpDiv;
  6522. },
  6523. /* Override the default settings for all instances of the date picker.
  6524. * @param settings object - the new settings to use as defaults (anonymous object)
  6525. * @return the manager object
  6526. */
  6527. setDefaults: function(settings) {
  6528. extendRemove(this._defaults, settings || {});
  6529. return this;
  6530. },
  6531. /* Attach the date picker to a jQuery selection.
  6532. * @param target element - the target input field or division or span
  6533. * @param settings object - the new settings to use for this date picker instance (anonymous)
  6534. */
  6535. _attachDatepicker: function(target, settings) {
  6536. var nodeName, inline, inst;
  6537. nodeName = target.nodeName.toLowerCase();
  6538. inline = (nodeName === "div" || nodeName === "span");
  6539. if (!target.id) {
  6540. this.uuid += 1;
  6541. target.id = "dp" + this.uuid;
  6542. }
  6543. inst = this._newInst($(target), inline);
  6544. inst.settings = $.extend({}, settings || {});
  6545. if (nodeName === "input") {
  6546. this._connectDatepicker(target, inst);
  6547. } else if (inline) {
  6548. this._inlineDatepicker(target, inst);
  6549. }
  6550. },
  6551. /* Create a new instance object. */
  6552. _newInst: function(target, inline) {
  6553. var id = target[0].id.replace(/([^A-Za-z0-9_\-])/g, "\\\\$1"); // escape jQuery meta chars
  6554. return {id: id, input: target, // associated target
  6555. selectedDay: 0, selectedMonth: 0, selectedYear: 0, // current selection
  6556. drawMonth: 0, drawYear: 0, // month being drawn
  6557. inline: inline, // is datepicker inline or not
  6558. dpDiv: (!inline ? this.dpDiv : // presentation div
  6559. bindHover($("<div class='" + this._inlineClass + " ui-datepicker ui-widget ui-widget-content ui-helper-clearfix ui-corner-all'></div>")))};
  6560. },
  6561. /* Attach the date picker to an input field. */
  6562. _connectDatepicker: function(target, inst) {
  6563. var input = $(target);
  6564. inst.append = $([]);
  6565. inst.trigger = $([]);
  6566. if (input.hasClass(this.markerClassName)) {
  6567. return;
  6568. }
  6569. this._attachments(input, inst);
  6570. input.addClass(this.markerClassName).keydown(this._doKeyDown).
  6571. keypress(this._doKeyPress).keyup(this._doKeyUp);
  6572. this._autoSize(inst);
  6573. $.data(target, PROP_NAME, inst);
  6574. //If disabled option is true, disable the datepicker once it has been attached to the input (see ticket #5665)
  6575. if( inst.settings.disabled ) {
  6576. this._disableDatepicker( target );
  6577. }
  6578. },
  6579. /* Make attachments based on settings. */
  6580. _attachments: function(input, inst) {
  6581. var showOn, buttonText, buttonImage,
  6582. appendText = this._get(inst, "appendText"),
  6583. isRTL = this._get(inst, "isRTL");
  6584. if (inst.append) {
  6585. inst.append.remove();
  6586. }
  6587. if (appendText) {
  6588. inst.append = $("<span class='" + this._appendClass + "'>" + appendText + "</span>");
  6589. input[isRTL ? "before" : "after"](inst.append);
  6590. }
  6591. input.unbind("focus", this._showDatepicker);
  6592. if (inst.trigger) {
  6593. inst.trigger.remove();
  6594. }
  6595. showOn = this._get(inst, "showOn");
  6596. if (showOn === "focus" || showOn === "both") { // pop-up date picker when in the marked field
  6597. input.focus(this._showDatepicker);
  6598. }
  6599. if (showOn === "button" || showOn === "both") { // pop-up date picker when button clicked
  6600. buttonText = this._get(inst, "buttonText");
  6601. buttonImage = this._get(inst, "buttonImage");
  6602. inst.trigger = $(this._get(inst, "buttonImageOnly") ?
  6603. $("<img/>").addClass(this._triggerClass).
  6604. attr({ src: buttonImage, alt: buttonText, title: buttonText }) :
  6605. $("<button type='button'></button>").addClass(this._triggerClass).
  6606. html(!buttonImage ? buttonText : $("<img/>").attr(
  6607. { src:buttonImage, alt:buttonText, title:buttonText })));
  6608. input[isRTL ? "before" : "after"](inst.trigger);
  6609. inst.trigger.click(function() {
  6610. if ($.datepicker._datepickerShowing && $.datepicker._lastInput === input[0]) {
  6611. $.datepicker._hideDatepicker();
  6612. } else if ($.datepicker._datepickerShowing && $.datepicker._lastInput !== input[0]) {
  6613. $.datepicker._hideDatepicker();
  6614. $.datepicker._showDatepicker(input[0]);
  6615. } else {
  6616. $.datepicker._showDatepicker(input[0]);
  6617. }
  6618. return false;
  6619. });
  6620. }
  6621. },
  6622. /* Apply the maximum length for the date format. */
  6623. _autoSize: function(inst) {
  6624. if (this._get(inst, "autoSize") && !inst.inline) {
  6625. var findMax, max, maxI, i,
  6626. date = new Date(2009, 12 - 1, 20), // Ensure double digits
  6627. dateFormat = this._get(inst, "dateFormat");
  6628. if (dateFormat.match(/[DM]/)) {
  6629. findMax = function(names) {
  6630. max = 0;
  6631. maxI = 0;
  6632. for (i = 0; i < names.length; i++) {
  6633. if (names[i].length > max) {
  6634. max = names[i].length;
  6635. maxI = i;
  6636. }
  6637. }
  6638. return maxI;
  6639. };
  6640. date.setMonth(findMax(this._get(inst, (dateFormat.match(/MM/) ?
  6641. "monthNames" : "monthNamesShort"))));
  6642. date.setDate(findMax(this._get(inst, (dateFormat.match(/DD/) ?
  6643. "dayNames" : "dayNamesShort"))) + 20 - date.getDay());
  6644. }
  6645. inst.input.attr("size", this._formatDate(inst, date).length);
  6646. }
  6647. },
  6648. /* Attach an inline date picker to a div. */
  6649. _inlineDatepicker: function(target, inst) {
  6650. var divSpan = $(target);
  6651. if (divSpan.hasClass(this.markerClassName)) {
  6652. return;
  6653. }
  6654. divSpan.addClass(this.markerClassName).append(inst.dpDiv);
  6655. $.data(target, PROP_NAME, inst);
  6656. this._setDate(inst, this._getDefaultDate(inst), true);
  6657. this._updateDatepicker(inst);
  6658. this._updateAlternate(inst);
  6659. //If disabled option is true, disable the datepicker before showing it (see ticket #5665)
  6660. if( inst.settings.disabled ) {
  6661. this._disableDatepicker( target );
  6662. }
  6663. // Set display:block in place of inst.dpDiv.show() which won't work on disconnected elements
  6664. // http://bugs.jqueryui.com/ticket/7552 - A Datepicker created on a detached div has zero height
  6665. inst.dpDiv.css( "display", "block" );
  6666. },
  6667. /* Pop-up the date picker in a "dialog" box.
  6668. * @param input element - ignored
  6669. * @param date string or Date - the initial date to display
  6670. * @param onSelect function - the function to call when a date is selected
  6671. * @param settings object - update the dialog date picker instance's settings (anonymous object)
  6672. * @param pos int[2] - coordinates for the dialog's position within the screen or
  6673. * event - with x/y coordinates or
  6674. * leave empty for default (screen centre)
  6675. * @return the manager object
  6676. */
  6677. _dialogDatepicker: function(input, date, onSelect, settings, pos) {
  6678. var id, browserWidth, browserHeight, scrollX, scrollY,
  6679. inst = this._dialogInst; // internal instance
  6680. if (!inst) {
  6681. this.uuid += 1;
  6682. id = "dp" + this.uuid;
  6683. this._dialogInput = $("<input type='text' id='" + id +
  6684. "' style='position: absolute; top: -100px; width: 0px;'/>");
  6685. this._dialogInput.keydown(this._doKeyDown);
  6686. $("body").append(this._dialogInput);
  6687. inst = this._dialogInst = this._newInst(this._dialogInput, false);
  6688. inst.settings = {};
  6689. $.data(this._dialogInput[0], PROP_NAME, inst);
  6690. }
  6691. extendRemove(inst.settings, settings || {});
  6692. date = (date && date.constructor === Date ? this._formatDate(inst, date) : date);
  6693. this._dialogInput.val(date);
  6694. this._pos = (pos ? (pos.length ? pos : [pos.pageX, pos.pageY]) : null);
  6695. if (!this._pos) {
  6696. browserWidth = document.documentElement.clientWidth;
  6697. browserHeight = document.documentElement.clientHeight;
  6698. scrollX = document.documentElement.scrollLeft || document.body.scrollLeft;
  6699. scrollY = document.documentElement.scrollTop || document.body.scrollTop;
  6700. this._pos = // should use actual width/height below
  6701. [(browserWidth / 2) - 100 + scrollX, (browserHeight / 2) - 150 + scrollY];
  6702. }
  6703. // move input on screen for focus, but hidden behind dialog
  6704. this._dialogInput.css("left", (this._pos[0] + 20) + "px").css("top", this._pos[1] + "px");
  6705. inst.settings.onSelect = onSelect;
  6706. this._inDialog = true;
  6707. this.dpDiv.addClass(this._dialogClass);
  6708. this._showDatepicker(this._dialogInput[0]);
  6709. if ($.blockUI) {
  6710. $.blockUI(this.dpDiv);
  6711. }
  6712. $.data(this._dialogInput[0], PROP_NAME, inst);
  6713. return this;
  6714. },
  6715. /* Detach a datepicker from its control.
  6716. * @param target element - the target input field or division or span
  6717. */
  6718. _destroyDatepicker: function(target) {
  6719. var nodeName,
  6720. $target = $(target),
  6721. inst = $.data(target, PROP_NAME);
  6722. if (!$target.hasClass(this.markerClassName)) {
  6723. return;
  6724. }
  6725. nodeName = target.nodeName.toLowerCase();
  6726. $.removeData(target, PROP_NAME);
  6727. if (nodeName === "input") {
  6728. inst.append.remove();
  6729. inst.trigger.remove();
  6730. $target.removeClass(this.markerClassName).
  6731. unbind("focus", this._showDatepicker).
  6732. unbind("keydown", this._doKeyDown).
  6733. unbind("keypress", this._doKeyPress).
  6734. unbind("keyup", this._doKeyUp);
  6735. } else if (nodeName === "div" || nodeName === "span") {
  6736. $target.removeClass(this.markerClassName).empty();
  6737. }
  6738. },
  6739. /* Enable the date picker to a jQuery selection.
  6740. * @param target element - the target input field or division or span
  6741. */
  6742. _enableDatepicker: function(target) {
  6743. var nodeName, inline,
  6744. $target = $(target),
  6745. inst = $.data(target, PROP_NAME);
  6746. if (!$target.hasClass(this.markerClassName)) {
  6747. return;
  6748. }
  6749. nodeName = target.nodeName.toLowerCase();
  6750. if (nodeName === "input") {
  6751. target.disabled = false;
  6752. inst.trigger.filter("button").
  6753. each(function() { this.disabled = false; }).end().
  6754. filter("img").css({opacity: "1.0", cursor: ""});
  6755. } else if (nodeName === "div" || nodeName === "span") {
  6756. inline = $target.children("." + this._inlineClass);
  6757. inline.children().removeClass("ui-state-disabled");
  6758. inline.find("select.ui-datepicker-month, select.ui-datepicker-year").
  6759. prop("disabled", false);
  6760. }
  6761. this._disabledInputs = $.map(this._disabledInputs,
  6762. function(value) { return (value === target ? null : value); }); // delete entry
  6763. },
  6764. /* Disable the date picker to a jQuery selection.
  6765. * @param target element - the target input field or division or span
  6766. */
  6767. _disableDatepicker: function(target) {
  6768. var nodeName, inline,
  6769. $target = $(target),
  6770. inst = $.data(target, PROP_NAME);
  6771. if (!$target.hasClass(this.markerClassName)) {
  6772. return;
  6773. }
  6774. nodeName = target.nodeName.toLowerCase();
  6775. if (nodeName === "input") {
  6776. target.disabled = true;
  6777. inst.trigger.filter("button").
  6778. each(function() { this.disabled = true; }).end().
  6779. filter("img").css({opacity: "0.5", cursor: "default"});
  6780. } else if (nodeName === "div" || nodeName === "span") {
  6781. inline = $target.children("." + this._inlineClass);
  6782. inline.children().addClass("ui-state-disabled");
  6783. inline.find("select.ui-datepicker-month, select.ui-datepicker-year").
  6784. prop("disabled", true);
  6785. }
  6786. this._disabledInputs = $.map(this._disabledInputs,
  6787. function(value) { return (value === target ? null : value); }); // delete entry
  6788. this._disabledInputs[this._disabledInputs.length] = target;
  6789. },
  6790. /* Is the first field in a jQuery collection disabled as a datepicker?
  6791. * @param target element - the target input field or division or span
  6792. * @return boolean - true if disabled, false if enabled
  6793. */
  6794. _isDisabledDatepicker: function(target) {
  6795. if (!target) {
  6796. return false;
  6797. }
  6798. for (var i = 0; i < this._disabledInputs.length; i++) {
  6799. if (this._disabledInputs[i] === target) {
  6800. return true;
  6801. }
  6802. }
  6803. return false;
  6804. },
  6805. /* Retrieve the instance data for the target control.
  6806. * @param target element - the target input field or division or span
  6807. * @return object - the associated instance data
  6808. * @throws error if a jQuery problem getting data
  6809. */
  6810. _getInst: function(target) {
  6811. try {
  6812. return $.data(target, PROP_NAME);
  6813. }
  6814. catch (err) {
  6815. throw "Missing instance data for this datepicker";
  6816. }
  6817. },
  6818. /* Update or retrieve the settings for a date picker attached to an input field or division.
  6819. * @param target element - the target input field or division or span
  6820. * @param name object - the new settings to update or
  6821. * string - the name of the setting to change or retrieve,
  6822. * when retrieving also "all" for all instance settings or
  6823. * "defaults" for all global defaults
  6824. * @param value any - the new value for the setting
  6825. * (omit if above is an object or to retrieve a value)
  6826. */
  6827. _optionDatepicker: function(target, name, value) {
  6828. var settings, date, minDate, maxDate,
  6829. inst = this._getInst(target);
  6830. if (arguments.length === 2 && typeof name === "string") {
  6831. return (name === "defaults" ? $.extend({}, $.datepicker._defaults) :
  6832. (inst ? (name === "all" ? $.extend({}, inst.settings) :
  6833. this._get(inst, name)) : null));
  6834. }
  6835. settings = name || {};
  6836. if (typeof name === "string") {
  6837. settings = {};
  6838. settings[name] = value;
  6839. }
  6840. if (inst) {
  6841. if (this._curInst === inst) {
  6842. this._hideDatepicker();
  6843. }
  6844. date = this._getDateDatepicker(target, true);
  6845. minDate = this._getMinMaxDate(inst, "min");
  6846. maxDate = this._getMinMaxDate(inst, "max");
  6847. extendRemove(inst.settings, settings);
  6848. // reformat the old minDate/maxDate values if dateFormat changes and a new minDate/maxDate isn't provided
  6849. if (minDate !== null && settings.dateFormat !== undefined && settings.minDate === undefined) {
  6850. inst.settings.minDate = this._formatDate(inst, minDate);
  6851. }
  6852. if (maxDate !== null && settings.dateFormat !== undefined && settings.maxDate === undefined) {
  6853. inst.settings.maxDate = this._formatDate(inst, maxDate);
  6854. }
  6855. if ( "disabled" in settings ) {
  6856. if ( settings.disabled ) {
  6857. this._disableDatepicker(target);
  6858. } else {
  6859. this._enableDatepicker(target);
  6860. }
  6861. }
  6862. this._attachments($(target), inst);
  6863. this._autoSize(inst);
  6864. this._setDate(inst, date);
  6865. this._updateAlternate(inst);
  6866. this._updateDatepicker(inst);
  6867. }
  6868. },
  6869. // change method deprecated
  6870. _changeDatepicker: function(target, name, value) {
  6871. this._optionDatepicker(target, name, value);
  6872. },
  6873. /* Redraw the date picker attached to an input field or division.
  6874. * @param target element - the target input field or division or span
  6875. */
  6876. _refreshDatepicker: function(target) {
  6877. var inst = this._getInst(target);
  6878. if (inst) {
  6879. this._updateDatepicker(inst);
  6880. }
  6881. },
  6882. /* Set the dates for a jQuery selection.
  6883. * @param target element - the target input field or division or span
  6884. * @param date Date - the new date
  6885. */
  6886. _setDateDatepicker: function(target, date) {
  6887. var inst = this._getInst(target);
  6888. if (inst) {
  6889. this._setDate(inst, date);
  6890. this._updateDatepicker(inst);
  6891. this._updateAlternate(inst);
  6892. }
  6893. },
  6894. /* Get the date(s) for the first entry in a jQuery selection.
  6895. * @param target element - the target input field or division or span
  6896. * @param noDefault boolean - true if no default date is to be used
  6897. * @return Date - the current date
  6898. */
  6899. _getDateDatepicker: function(target, noDefault) {
  6900. var inst = this._getInst(target);
  6901. if (inst && !inst.inline) {
  6902. this._setDateFromField(inst, noDefault);
  6903. }
  6904. return (inst ? this._getDate(inst) : null);
  6905. },
  6906. /* Handle keystrokes. */
  6907. _doKeyDown: function(event) {
  6908. var onSelect, dateStr, sel,
  6909. inst = $.datepicker._getInst(event.target),
  6910. handled = true,
  6911. isRTL = inst.dpDiv.is(".ui-datepicker-rtl");
  6912. inst._keyEvent = true;
  6913. if ($.datepicker._datepickerShowing) {
  6914. switch (event.keyCode) {
  6915. case 9: $.datepicker._hideDatepicker();
  6916. handled = false;
  6917. break; // hide on tab out
  6918. case 13: sel = $("td." + $.datepicker._dayOverClass + ":not(." +
  6919. $.datepicker._currentClass + ")", inst.dpDiv);
  6920. if (sel[0]) {
  6921. $.datepicker._selectDay(event.target, inst.selectedMonth, inst.selectedYear, sel[0]);
  6922. }
  6923. onSelect = $.datepicker._get(inst, "onSelect");
  6924. if (onSelect) {
  6925. dateStr = $.datepicker._formatDate(inst);
  6926. // trigger custom callback
  6927. onSelect.apply((inst.input ? inst.input[0] : null), [dateStr, inst]);
  6928. } else {
  6929. $.datepicker._hideDatepicker();
  6930. }
  6931. return false; // don't submit the form
  6932. case 27: $.datepicker._hideDatepicker();
  6933. break; // hide on escape
  6934. case 33: $.datepicker._adjustDate(event.target, (event.ctrlKey ?
  6935. -$.datepicker._get(inst, "stepBigMonths") :
  6936. -$.datepicker._get(inst, "stepMonths")), "M");
  6937. break; // previous month/year on page up/+ ctrl
  6938. case 34: $.datepicker._adjustDate(event.target, (event.ctrlKey ?
  6939. +$.datepicker._get(inst, "stepBigMonths") :
  6940. +$.datepicker._get(inst, "stepMonths")), "M");
  6941. break; // next month/year on page down/+ ctrl
  6942. case 35: if (event.ctrlKey || event.metaKey) {
  6943. $.datepicker._clearDate(event.target);
  6944. }
  6945. handled = event.ctrlKey || event.metaKey;
  6946. break; // clear on ctrl or command +end
  6947. case 36: if (event.ctrlKey || event.metaKey) {
  6948. $.datepicker._gotoToday(event.target);
  6949. }
  6950. handled = event.ctrlKey || event.metaKey;
  6951. break; // current on ctrl or command +home
  6952. case 37: if (event.ctrlKey || event.metaKey) {
  6953. $.datepicker._adjustDate(event.target, (isRTL ? +1 : -1), "D");
  6954. }
  6955. handled = event.ctrlKey || event.metaKey;
  6956. // -1 day on ctrl or command +left
  6957. if (event.originalEvent.altKey) {
  6958. $.datepicker._adjustDate(event.target, (event.ctrlKey ?
  6959. -$.datepicker._get(inst, "stepBigMonths") :
  6960. -$.datepicker._get(inst, "stepMonths")), "M");
  6961. }
  6962. // next month/year on alt +left on Mac
  6963. break;
  6964. case 38: if (event.ctrlKey || event.metaKey) {
  6965. $.datepicker._adjustDate(event.target, -7, "D");
  6966. }
  6967. handled = event.ctrlKey || event.metaKey;
  6968. break; // -1 week on ctrl or command +up
  6969. case 39: if (event.ctrlKey || event.metaKey) {
  6970. $.datepicker._adjustDate(event.target, (isRTL ? -1 : +1), "D");
  6971. }
  6972. handled = event.ctrlKey || event.metaKey;
  6973. // +1 day on ctrl or command +right
  6974. if (event.originalEvent.altKey) {
  6975. $.datepicker._adjustDate(event.target, (event.ctrlKey ?
  6976. +$.datepicker._get(inst, "stepBigMonths") :
  6977. +$.datepicker._get(inst, "stepMonths")), "M");
  6978. }
  6979. // next month/year on alt +right
  6980. break;
  6981. case 40: if (event.ctrlKey || event.metaKey) {
  6982. $.datepicker._adjustDate(event.target, +7, "D");
  6983. }
  6984. handled = event.ctrlKey || event.metaKey;
  6985. break; // +1 week on ctrl or command +down
  6986. default: handled = false;
  6987. }
  6988. } else if (event.keyCode === 36 && event.ctrlKey) { // display the date picker on ctrl+home
  6989. $.datepicker._showDatepicker(this);
  6990. } else {
  6991. handled = false;
  6992. }
  6993. if (handled) {
  6994. event.preventDefault();
  6995. event.stopPropagation();
  6996. }
  6997. },
  6998. /* Filter entered characters - based on date format. */
  6999. _doKeyPress: function(event) {
  7000. var chars, chr,
  7001. inst = $.datepicker._getInst(event.target);
  7002. if ($.datepicker._get(inst, "constrainInput")) {
  7003. chars = $.datepicker._possibleChars($.datepicker._get(inst, "dateFormat"));
  7004. chr = String.fromCharCode(event.charCode == null ? event.keyCode : event.charCode);
  7005. return event.ctrlKey || event.metaKey || (chr < " " || !chars || chars.indexOf(chr) > -1);
  7006. }
  7007. },
  7008. /* Synchronise manual entry and field/alternate field. */
  7009. _doKeyUp: function(event) {
  7010. var date,
  7011. inst = $.datepicker._getInst(event.target);
  7012. if (inst.input.val() !== inst.lastVal) {
  7013. try {
  7014. date = $.datepicker.parseDate($.datepicker._get(inst, "dateFormat"),
  7015. (inst.input ? inst.input.val() : null),
  7016. $.datepicker._getFormatConfig(inst));
  7017. if (date) { // only if valid
  7018. $.datepicker._setDateFromField(inst);
  7019. $.datepicker._updateAlternate(inst);
  7020. $.datepicker._updateDatepicker(inst);
  7021. }
  7022. }
  7023. catch (err) {
  7024. }
  7025. }
  7026. return true;
  7027. },
  7028. /* Pop-up the date picker for a given input field.
  7029. * If false returned from beforeShow event handler do not show.
  7030. * @param input element - the input field attached to the date picker or
  7031. * event - if triggered by focus
  7032. */
  7033. _showDatepicker: function(input) {
  7034. input = input.target || input;
  7035. if (input.nodeName.toLowerCase() !== "input") { // find from button/image trigger
  7036. input = $("input", input.parentNode)[0];
  7037. }
  7038. if ($.datepicker._isDisabledDatepicker(input) || $.datepicker._lastInput === input) { // already here
  7039. return;
  7040. }
  7041. var inst, beforeShow, beforeShowSettings, isFixed,
  7042. offset, showAnim, duration;
  7043. inst = $.datepicker._getInst(input);
  7044. if ($.datepicker._curInst && $.datepicker._curInst !== inst) {
  7045. $.datepicker._curInst.dpDiv.stop(true, true);
  7046. if ( inst && $.datepicker._datepickerShowing ) {
  7047. $.datepicker._hideDatepicker( $.datepicker._curInst.input[0] );
  7048. }
  7049. }
  7050. beforeShow = $.datepicker._get(inst, "beforeShow");
  7051. beforeShowSettings = beforeShow ? beforeShow.apply(input, [input, inst]) : {};
  7052. if(beforeShowSettings === false){
  7053. return;
  7054. }
  7055. extendRemove(inst.settings, beforeShowSettings);
  7056. inst.lastVal = null;
  7057. $.datepicker._lastInput = input;
  7058. $.datepicker._setDateFromField(inst);
  7059. if ($.datepicker._inDialog) { // hide cursor
  7060. input.value = "";
  7061. }
  7062. if (!$.datepicker._pos) { // position below input
  7063. $.datepicker._pos = $.datepicker._findPos(input);
  7064. $.datepicker._pos[1] += input.offsetHeight; // add the height
  7065. }
  7066. isFixed = false;
  7067. $(input).parents().each(function() {
  7068. isFixed |= $(this).css("position") === "fixed";
  7069. return !isFixed;
  7070. });
  7071. offset = {left: $.datepicker._pos[0], top: $.datepicker._pos[1]};
  7072. $.datepicker._pos = null;
  7073. //to avoid flashes on Firefox
  7074. inst.dpDiv.empty();
  7075. // determine sizing offscreen
  7076. inst.dpDiv.css({position: "absolute", display: "block", top: "-1000px"});
  7077. $.datepicker._updateDatepicker(inst);
  7078. // fix width for dynamic number of date pickers
  7079. // and adjust position before showing
  7080. offset = $.datepicker._checkOffset(inst, offset, isFixed);
  7081. inst.dpDiv.css({position: ($.datepicker._inDialog && $.blockUI ?
  7082. "static" : (isFixed ? "fixed" : "absolute")), display: "none",
  7083. left: offset.left + "px", top: offset.top + "px"});
  7084. if (!inst.inline) {
  7085. showAnim = $.datepicker._get(inst, "showAnim");
  7086. duration = $.datepicker._get(inst, "duration");
  7087. inst.dpDiv.zIndex($(input).zIndex()+1);
  7088. $.datepicker._datepickerShowing = true;
  7089. if ( $.effects && $.effects.effect[ showAnim ] ) {
  7090. inst.dpDiv.show(showAnim, $.datepicker._get(inst, "showOptions"), duration);
  7091. } else {
  7092. inst.dpDiv[showAnim || "show"](showAnim ? duration : null);
  7093. }
  7094. if ( $.datepicker._shouldFocusInput( inst ) ) {
  7095. inst.input.focus();
  7096. }
  7097. $.datepicker._curInst = inst;
  7098. }
  7099. },
  7100. /* Generate the date picker content. */
  7101. _updateDatepicker: function(inst) {
  7102. this.maxRows = 4; //Reset the max number of rows being displayed (see #7043)
  7103. instActive = inst; // for delegate hover events
  7104. inst.dpDiv.empty().append(this._generateHTML(inst));
  7105. this._attachHandlers(inst);
  7106. inst.dpDiv.find("." + this._dayOverClass + " a").mouseover();
  7107. var origyearshtml,
  7108. numMonths = this._getNumberOfMonths(inst),
  7109. cols = numMonths[1],
  7110. width = 17;
  7111. inst.dpDiv.removeClass("ui-datepicker-multi-2 ui-datepicker-multi-3 ui-datepicker-multi-4").width("");
  7112. if (cols > 1) {
  7113. inst.dpDiv.addClass("ui-datepicker-multi-" + cols).css("width", (width * cols) + "em");
  7114. }
  7115. inst.dpDiv[(numMonths[0] !== 1 || numMonths[1] !== 1 ? "add" : "remove") +
  7116. "Class"]("ui-datepicker-multi");
  7117. inst.dpDiv[(this._get(inst, "isRTL") ? "add" : "remove") +
  7118. "Class"]("ui-datepicker-rtl");
  7119. if (inst === $.datepicker._curInst && $.datepicker._datepickerShowing && $.datepicker._shouldFocusInput( inst ) ) {
  7120. inst.input.focus();
  7121. }
  7122. // deffered render of the years select (to avoid flashes on Firefox)
  7123. if( inst.yearshtml ){
  7124. origyearshtml = inst.yearshtml;
  7125. setTimeout(function(){
  7126. //assure that inst.yearshtml didn't change.
  7127. if( origyearshtml === inst.yearshtml && inst.yearshtml ){
  7128. inst.dpDiv.find("select.ui-datepicker-year:first").replaceWith(inst.yearshtml);
  7129. }
  7130. origyearshtml = inst.yearshtml = null;
  7131. }, 0);
  7132. }
  7133. },
  7134. // #6694 - don't focus the input if it's already focused
  7135. // this breaks the change event in IE
  7136. // Support: IE and jQuery <1.9
  7137. _shouldFocusInput: function( inst ) {
  7138. return inst.input && inst.input.is( ":visible" ) && !inst.input.is( ":disabled" ) && !inst.input.is( ":focus" );
  7139. },
  7140. /* Check positioning to remain on screen. */
  7141. _checkOffset: function(inst, offset, isFixed) {
  7142. var dpWidth = inst.dpDiv.outerWidth(),
  7143. dpHeight = inst.dpDiv.outerHeight(),
  7144. inputWidth = inst.input ? inst.input.outerWidth() : 0,
  7145. inputHeight = inst.input ? inst.input.outerHeight() : 0,
  7146. viewWidth = document.documentElement.clientWidth + (isFixed ? 0 : $(document).scrollLeft()),
  7147. viewHeight = document.documentElement.clientHeight + (isFixed ? 0 : $(document).scrollTop());
  7148. offset.left -= (this._get(inst, "isRTL") ? (dpWidth - inputWidth) : 0);
  7149. offset.left -= (isFixed && offset.left === inst.input.offset().left) ? $(document).scrollLeft() : 0;
  7150. offset.top -= (isFixed && offset.top === (inst.input.offset().top + inputHeight)) ? $(document).scrollTop() : 0;
  7151. // now check if datepicker is showing outside window viewport - move to a better place if so.
  7152. offset.left -= Math.min(offset.left, (offset.left + dpWidth > viewWidth && viewWidth > dpWidth) ?
  7153. Math.abs(offset.left + dpWidth - viewWidth) : 0);
  7154. offset.top -= Math.min(offset.top, (offset.top + dpHeight > viewHeight && viewHeight > dpHeight) ?
  7155. Math.abs(dpHeight + inputHeight) : 0);
  7156. return offset;
  7157. },
  7158. /* Find an object's position on the screen. */
  7159. _findPos: function(obj) {
  7160. var position,
  7161. inst = this._getInst(obj),
  7162. isRTL = this._get(inst, "isRTL");
  7163. while (obj && (obj.type === "hidden" || obj.nodeType !== 1 || $.expr.filters.hidden(obj))) {
  7164. obj = obj[isRTL ? "previousSibling" : "nextSibling"];
  7165. }
  7166. position = $(obj).offset();
  7167. return [position.left, position.top];
  7168. },
  7169. /* Hide the date picker from view.
  7170. * @param input element - the input field attached to the date picker
  7171. */
  7172. _hideDatepicker: function(input) {
  7173. var showAnim, duration, postProcess, onClose,
  7174. inst = this._curInst;
  7175. if (!inst || (input && inst !== $.data(input, PROP_NAME))) {
  7176. return;
  7177. }
  7178. if (this._datepickerShowing) {
  7179. showAnim = this._get(inst, "showAnim");
  7180. duration = this._get(inst, "duration");
  7181. postProcess = function() {
  7182. $.datepicker._tidyDialog(inst);
  7183. };
  7184. // DEPRECATED: after BC for 1.8.x $.effects[ showAnim ] is not needed
  7185. if ( $.effects && ( $.effects.effect[ showAnim ] || $.effects[ showAnim ] ) ) {
  7186. inst.dpDiv.hide(showAnim, $.datepicker._get(inst, "showOptions"), duration, postProcess);
  7187. } else {
  7188. inst.dpDiv[(showAnim === "slideDown" ? "slideUp" :
  7189. (showAnim === "fadeIn" ? "fadeOut" : "hide"))]((showAnim ? duration : null), postProcess);
  7190. }
  7191. if (!showAnim) {
  7192. postProcess();
  7193. }
  7194. this._datepickerShowing = false;
  7195. onClose = this._get(inst, "onClose");
  7196. if (onClose) {
  7197. onClose.apply((inst.input ? inst.input[0] : null), [(inst.input ? inst.input.val() : ""), inst]);
  7198. }
  7199. this._lastInput = null;
  7200. if (this._inDialog) {
  7201. this._dialogInput.css({ position: "absolute", left: "0", top: "-100px" });
  7202. if ($.blockUI) {
  7203. $.unblockUI();
  7204. $("body").append(this.dpDiv);
  7205. }
  7206. }
  7207. this._inDialog = false;
  7208. }
  7209. },
  7210. /* Tidy up after a dialog display. */
  7211. _tidyDialog: function(inst) {
  7212. inst.dpDiv.removeClass(this._dialogClass).unbind(".ui-datepicker-calendar");
  7213. },
  7214. /* Close date picker if clicked elsewhere. */
  7215. _checkExternalClick: function(event) {
  7216. if (!$.datepicker._curInst) {
  7217. return;
  7218. }
  7219. var $target = $(event.target),
  7220. inst = $.datepicker._getInst($target[0]);
  7221. if ( ( ( $target[0].id !== $.datepicker._mainDivId &&
  7222. $target.parents("#" + $.datepicker._mainDivId).length === 0 &&
  7223. !$target.hasClass($.datepicker.markerClassName) &&
  7224. !$target.closest("." + $.datepicker._triggerClass).length &&
  7225. $.datepicker._datepickerShowing && !($.datepicker._inDialog && $.blockUI) ) ) ||
  7226. ( $target.hasClass($.datepicker.markerClassName) && $.datepicker._curInst !== inst ) ) {
  7227. $.datepicker._hideDatepicker();
  7228. }
  7229. },
  7230. /* Adjust one of the date sub-fields. */
  7231. _adjustDate: function(id, offset, period) {
  7232. var target = $(id),
  7233. inst = this._getInst(target[0]);
  7234. if (this._isDisabledDatepicker(target[0])) {
  7235. return;
  7236. }
  7237. this._adjustInstDate(inst, offset +
  7238. (period === "M" ? this._get(inst, "showCurrentAtPos") : 0), // undo positioning
  7239. period);
  7240. this._updateDatepicker(inst);
  7241. },
  7242. /* Action for current link. */
  7243. _gotoToday: function(id) {
  7244. var date,
  7245. target = $(id),
  7246. inst = this._getInst(target[0]);
  7247. if (this._get(inst, "gotoCurrent") && inst.currentDay) {
  7248. inst.selectedDay = inst.currentDay;
  7249. inst.drawMonth = inst.selectedMonth = inst.currentMonth;
  7250. inst.drawYear = inst.selectedYear = inst.currentYear;
  7251. } else {
  7252. date = new Date();
  7253. inst.selectedDay = date.getDate();
  7254. inst.drawMonth = inst.selectedMonth = date.getMonth();
  7255. inst.drawYear = inst.selectedYear = date.getFullYear();
  7256. }
  7257. this._notifyChange(inst);
  7258. this._adjustDate(target);
  7259. },
  7260. /* Action for selecting a new month/year. */
  7261. _selectMonthYear: function(id, select, period) {
  7262. var target = $(id),
  7263. inst = this._getInst(target[0]);
  7264. inst["selected" + (period === "M" ? "Month" : "Year")] =
  7265. inst["draw" + (period === "M" ? "Month" : "Year")] =
  7266. parseInt(select.options[select.selectedIndex].value,10);
  7267. this._notifyChange(inst);
  7268. this._adjustDate(target);
  7269. },
  7270. /* Action for selecting a day. */
  7271. _selectDay: function(id, month, year, td) {
  7272. var inst,
  7273. target = $(id);
  7274. if ($(td).hasClass(this._unselectableClass) || this._isDisabledDatepicker(target[0])) {
  7275. return;
  7276. }
  7277. inst = this._getInst(target[0]);
  7278. inst.selectedDay = inst.currentDay = $("a", td).html();
  7279. inst.selectedMonth = inst.currentMonth = month;
  7280. inst.selectedYear = inst.currentYear = year;
  7281. this._selectDate(id, this._formatDate(inst,
  7282. inst.currentDay, inst.currentMonth, inst.currentYear));
  7283. },
  7284. /* Erase the input field and hide the date picker. */
  7285. _clearDate: function(id) {
  7286. var target = $(id);
  7287. this._selectDate(target, "");
  7288. },
  7289. /* Update the input field with the selected date. */
  7290. _selectDate: function(id, dateStr) {
  7291. var onSelect,
  7292. target = $(id),
  7293. inst = this._getInst(target[0]);
  7294. dateStr = (dateStr != null ? dateStr : this._formatDate(inst));
  7295. if (inst.input) {
  7296. inst.input.val(dateStr);
  7297. }
  7298. this._updateAlternate(inst);
  7299. onSelect = this._get(inst, "onSelect");
  7300. if (onSelect) {
  7301. onSelect.apply((inst.input ? inst.input[0] : null), [dateStr, inst]); // trigger custom callback
  7302. } else if (inst.input) {
  7303. inst.input.trigger("change"); // fire the change event
  7304. }
  7305. if (inst.inline){
  7306. this._updateDatepicker(inst);
  7307. } else {
  7308. this._hideDatepicker();
  7309. this._lastInput = inst.input[0];
  7310. if (typeof(inst.input[0]) !== "object") {
  7311. inst.input.focus(); // restore focus
  7312. }
  7313. this._lastInput = null;
  7314. }
  7315. },
  7316. /* Update any alternate field to synchronise with the main field. */
  7317. _updateAlternate: function(inst) {
  7318. var altFormat, date, dateStr,
  7319. altField = this._get(inst, "altField");
  7320. if (altField) { // update alternate field too
  7321. altFormat = this._get(inst, "altFormat") || this._get(inst, "dateFormat");
  7322. date = this._getDate(inst);
  7323. dateStr = this.formatDate(altFormat, date, this._getFormatConfig(inst));
  7324. $(altField).each(function() { $(this).val(dateStr); });
  7325. }
  7326. },
  7327. /* Set as beforeShowDay function to prevent selection of weekends.
  7328. * @param date Date - the date to customise
  7329. * @return [boolean, string] - is this date selectable?, what is its CSS class?
  7330. */
  7331. noWeekends: function(date) {
  7332. var day = date.getDay();
  7333. return [(day > 0 && day < 6), ""];
  7334. },
  7335. /* Set as calculateWeek to determine the week of the year based on the ISO 8601 definition.
  7336. * @param date Date - the date to get the week for
  7337. * @return number - the number of the week within the year that contains this date
  7338. */
  7339. iso8601Week: function(date) {
  7340. var time,
  7341. checkDate = new Date(date.getTime());
  7342. // Find Thursday of this week starting on Monday
  7343. checkDate.setDate(checkDate.getDate() + 4 - (checkDate.getDay() || 7));
  7344. time = checkDate.getTime();
  7345. checkDate.setMonth(0); // Compare with Jan 1
  7346. checkDate.setDate(1);
  7347. return Math.floor(Math.round((time - checkDate) / 86400000) / 7) + 1;
  7348. },
  7349. /* Parse a string value into a date object.
  7350. * See formatDate below for the possible formats.
  7351. *
  7352. * @param format string - the expected format of the date
  7353. * @param value string - the date in the above format
  7354. * @param settings Object - attributes include:
  7355. * shortYearCutoff number - the cutoff year for determining the century (optional)
  7356. * dayNamesShort string[7] - abbreviated names of the days from Sunday (optional)
  7357. * dayNames string[7] - names of the days from Sunday (optional)
  7358. * monthNamesShort string[12] - abbreviated names of the months (optional)
  7359. * monthNames string[12] - names of the months (optional)
  7360. * @return Date - the extracted date value or null if value is blank
  7361. */
  7362. parseDate: function (format, value, settings) {
  7363. if (format == null || value == null) {
  7364. throw "Invalid arguments";
  7365. }
  7366. value = (typeof value === "object" ? value.toString() : value + "");
  7367. if (value === "") {
  7368. return null;
  7369. }
  7370. var iFormat, dim, extra,
  7371. iValue = 0,
  7372. shortYearCutoffTemp = (settings ? settings.shortYearCutoff : null) || this._defaults.shortYearCutoff,
  7373. shortYearCutoff = (typeof shortYearCutoffTemp !== "string" ? shortYearCutoffTemp :
  7374. new Date().getFullYear() % 100 + parseInt(shortYearCutoffTemp, 10)),
  7375. dayNamesShort = (settings ? settings.dayNamesShort : null) || this._defaults.dayNamesShort,
  7376. dayNames = (settings ? settings.dayNames : null) || this._defaults.dayNames,
  7377. monthNamesShort = (settings ? settings.monthNamesShort : null) || this._defaults.monthNamesShort,
  7378. monthNames = (settings ? settings.monthNames : null) || this._defaults.monthNames,
  7379. year = -1,
  7380. month = -1,
  7381. day = -1,
  7382. doy = -1,
  7383. literal = false,
  7384. date,
  7385. // Check whether a format character is doubled
  7386. lookAhead = function(match) {
  7387. var matches = (iFormat + 1 < format.length && format.charAt(iFormat + 1) === match);
  7388. if (matches) {
  7389. iFormat++;
  7390. }
  7391. return matches;
  7392. },
  7393. // Extract a number from the string value
  7394. getNumber = function(match) {
  7395. var isDoubled = lookAhead(match),
  7396. size = (match === "@" ? 14 : (match === "!" ? 20 :
  7397. (match === "y" && isDoubled ? 4 : (match === "o" ? 3 : 2)))),
  7398. digits = new RegExp("^\\d{1," + size + "}"),
  7399. num = value.substring(iValue).match(digits);
  7400. if (!num) {
  7401. throw "Missing number at position " + iValue;
  7402. }
  7403. iValue += num[0].length;
  7404. return parseInt(num[0], 10);
  7405. },
  7406. // Extract a name from the string value and convert to an index
  7407. getName = function(match, shortNames, longNames) {
  7408. var index = -1,
  7409. names = $.map(lookAhead(match) ? longNames : shortNames, function (v, k) {
  7410. return [ [k, v] ];
  7411. }).sort(function (a, b) {
  7412. return -(a[1].length - b[1].length);
  7413. });
  7414. $.each(names, function (i, pair) {
  7415. var name = pair[1];
  7416. if (value.substr(iValue, name.length).toLowerCase() === name.toLowerCase()) {
  7417. index = pair[0];
  7418. iValue += name.length;
  7419. return false;
  7420. }
  7421. });
  7422. if (index !== -1) {
  7423. return index + 1;
  7424. } else {
  7425. throw "Unknown name at position " + iValue;
  7426. }
  7427. },
  7428. // Confirm that a literal character matches the string value
  7429. checkLiteral = function() {
  7430. if (value.charAt(iValue) !== format.charAt(iFormat)) {
  7431. throw "Unexpected literal at position " + iValue;
  7432. }
  7433. iValue++;
  7434. };
  7435. for (iFormat = 0; iFormat < format.length; iFormat++) {
  7436. if (literal) {
  7437. if (format.charAt(iFormat) === "'" && !lookAhead("'")) {
  7438. literal = false;
  7439. } else {
  7440. checkLiteral();
  7441. }
  7442. } else {
  7443. switch (format.charAt(iFormat)) {
  7444. case "d":
  7445. day = getNumber("d");
  7446. break;
  7447. case "D":
  7448. getName("D", dayNamesShort, dayNames);
  7449. break;
  7450. case "o":
  7451. doy = getNumber("o");
  7452. break;
  7453. case "m":
  7454. month = getNumber("m");
  7455. break;
  7456. case "M":
  7457. month = getName("M", monthNamesShort, monthNames);
  7458. break;
  7459. case "y":
  7460. year = getNumber("y");
  7461. break;
  7462. case "@":
  7463. date = new Date(getNumber("@"));
  7464. year = date.getFullYear();
  7465. month = date.getMonth() + 1;
  7466. day = date.getDate();
  7467. break;
  7468. case "!":
  7469. date = new Date((getNumber("!") - this._ticksTo1970) / 10000);
  7470. year = date.getFullYear();
  7471. month = date.getMonth() + 1;
  7472. day = date.getDate();
  7473. break;
  7474. case "'":
  7475. if (lookAhead("'")){
  7476. checkLiteral();
  7477. } else {
  7478. literal = true;
  7479. }
  7480. break;
  7481. default:
  7482. checkLiteral();
  7483. }
  7484. }
  7485. }
  7486. if (iValue < value.length){
  7487. extra = value.substr(iValue);
  7488. if (!/^\s+/.test(extra)) {
  7489. throw "Extra/unparsed characters found in date: " + extra;
  7490. }
  7491. }
  7492. if (year === -1) {
  7493. year = new Date().getFullYear();
  7494. } else if (year < 100) {
  7495. year += new Date().getFullYear() - new Date().getFullYear() % 100 +
  7496. (year <= shortYearCutoff ? 0 : -100);
  7497. }
  7498. if (doy > -1) {
  7499. month = 1;
  7500. day = doy;
  7501. do {
  7502. dim = this._getDaysInMonth(year, month - 1);
  7503. if (day <= dim) {
  7504. break;
  7505. }
  7506. month++;
  7507. day -= dim;
  7508. } while (true);
  7509. }
  7510. date = this._daylightSavingAdjust(new Date(year, month - 1, day));
  7511. if (date.getFullYear() !== year || date.getMonth() + 1 !== month || date.getDate() !== day) {
  7512. throw "Invalid date"; // E.g. 31/02/00
  7513. }
  7514. return date;
  7515. },
  7516. /* Standard date formats. */
  7517. ATOM: "yy-mm-dd", // RFC 3339 (ISO 8601)
  7518. COOKIE: "D, dd M yy",
  7519. ISO_8601: "yy-mm-dd",
  7520. RFC_822: "D, d M y",
  7521. RFC_850: "DD, dd-M-y",
  7522. RFC_1036: "D, d M y",
  7523. RFC_1123: "D, d M yy",
  7524. RFC_2822: "D, d M yy",
  7525. RSS: "D, d M y", // RFC 822
  7526. TICKS: "!",
  7527. TIMESTAMP: "@",
  7528. W3C: "yy-mm-dd", // ISO 8601
  7529. _ticksTo1970: (((1970 - 1) * 365 + Math.floor(1970 / 4) - Math.floor(1970 / 100) +
  7530. Math.floor(1970 / 400)) * 24 * 60 * 60 * 10000000),
  7531. /* Format a date object into a string value.
  7532. * The format can be combinations of the following:
  7533. * d - day of month (no leading zero)
  7534. * dd - day of month (two digit)
  7535. * o - day of year (no leading zeros)
  7536. * oo - day of year (three digit)
  7537. * D - day name short
  7538. * DD - day name long
  7539. * m - month of year (no leading zero)
  7540. * mm - month of year (two digit)
  7541. * M - month name short
  7542. * MM - month name long
  7543. * y - year (two digit)
  7544. * yy - year (four digit)
  7545. * @ - Unix timestamp (ms since 01/01/1970)
  7546. * ! - Windows ticks (100ns since 01/01/0001)
  7547. * "..." - literal text
  7548. * '' - single quote
  7549. *
  7550. * @param format string - the desired format of the date
  7551. * @param date Date - the date value to format
  7552. * @param settings Object - attributes include:
  7553. * dayNamesShort string[7] - abbreviated names of the days from Sunday (optional)
  7554. * dayNames string[7] - names of the days from Sunday (optional)
  7555. * monthNamesShort string[12] - abbreviated names of the months (optional)
  7556. * monthNames string[12] - names of the months (optional)
  7557. * @return string - the date in the above format
  7558. */
  7559. formatDate: function (format, date, settings) {
  7560. if (!date) {
  7561. return "";
  7562. }
  7563. var iFormat,
  7564. dayNamesShort = (settings ? settings.dayNamesShort : null) || this._defaults.dayNamesShort,
  7565. dayNames = (settings ? settings.dayNames : null) || this._defaults.dayNames,
  7566. monthNamesShort = (settings ? settings.monthNamesShort : null) || this._defaults.monthNamesShort,
  7567. monthNames = (settings ? settings.monthNames : null) || this._defaults.monthNames,
  7568. // Check whether a format character is doubled
  7569. lookAhead = function(match) {
  7570. var matches = (iFormat + 1 < format.length && format.charAt(iFormat + 1) === match);
  7571. if (matches) {
  7572. iFormat++;
  7573. }
  7574. return matches;
  7575. },
  7576. // Format a number, with leading zero if necessary
  7577. formatNumber = function(match, value, len) {
  7578. var num = "" + value;
  7579. if (lookAhead(match)) {
  7580. while (num.length < len) {
  7581. num = "0" + num;
  7582. }
  7583. }
  7584. return num;
  7585. },
  7586. // Format a name, short or long as requested
  7587. formatName = function(match, value, shortNames, longNames) {
  7588. return (lookAhead(match) ? longNames[value] : shortNames[value]);
  7589. },
  7590. output = "",
  7591. literal = false;
  7592. if (date) {
  7593. for (iFormat = 0; iFormat < format.length; iFormat++) {
  7594. if (literal) {
  7595. if (format.charAt(iFormat) === "'" && !lookAhead("'")) {
  7596. literal = false;
  7597. } else {
  7598. output += format.charAt(iFormat);
  7599. }
  7600. } else {
  7601. switch (format.charAt(iFormat)) {
  7602. case "d":
  7603. output += formatNumber("d", date.getDate(), 2);
  7604. break;
  7605. case "D":
  7606. output += formatName("D", date.getDay(), dayNamesShort, dayNames);
  7607. break;
  7608. case "o":
  7609. output += formatNumber("o",
  7610. Math.round((new Date(date.getFullYear(), date.getMonth(), date.getDate()).getTime() - new Date(date.getFullYear(), 0, 0).getTime()) / 86400000), 3);
  7611. break;
  7612. case "m":
  7613. output += formatNumber("m", date.getMonth() + 1, 2);
  7614. break;
  7615. case "M":
  7616. output += formatName("M", date.getMonth(), monthNamesShort, monthNames);
  7617. break;
  7618. case "y":
  7619. output += (lookAhead("y") ? date.getFullYear() :
  7620. (date.getYear() % 100 < 10 ? "0" : "") + date.getYear() % 100);
  7621. break;
  7622. case "@":
  7623. output += date.getTime();
  7624. break;
  7625. case "!":
  7626. output += date.getTime() * 10000 + this._ticksTo1970;
  7627. break;
  7628. case "'":
  7629. if (lookAhead("'")) {
  7630. output += "'";
  7631. } else {
  7632. literal = true;
  7633. }
  7634. break;
  7635. default:
  7636. output += format.charAt(iFormat);
  7637. }
  7638. }
  7639. }
  7640. }
  7641. return output;
  7642. },
  7643. /* Extract all possible characters from the date format. */
  7644. _possibleChars: function (format) {
  7645. var iFormat,
  7646. chars = "",
  7647. literal = false,
  7648. // Check whether a format character is doubled
  7649. lookAhead = function(match) {
  7650. var matches = (iFormat + 1 < format.length && format.charAt(iFormat + 1) === match);
  7651. if (matches) {
  7652. iFormat++;
  7653. }
  7654. return matches;
  7655. };
  7656. for (iFormat = 0; iFormat < format.length; iFormat++) {
  7657. if (literal) {
  7658. if (format.charAt(iFormat) === "'" && !lookAhead("'")) {
  7659. literal = false;
  7660. } else {
  7661. chars += format.charAt(iFormat);
  7662. }
  7663. } else {
  7664. switch (format.charAt(iFormat)) {
  7665. case "d": case "m": case "y": case "@":
  7666. chars += "0123456789";
  7667. break;
  7668. case "D": case "M":
  7669. return null; // Accept anything
  7670. case "'":
  7671. if (lookAhead("'")) {
  7672. chars += "'";
  7673. } else {
  7674. literal = true;
  7675. }
  7676. break;
  7677. default:
  7678. chars += format.charAt(iFormat);
  7679. }
  7680. }
  7681. }
  7682. return chars;
  7683. },
  7684. /* Get a setting value, defaulting if necessary. */
  7685. _get: function(inst, name) {
  7686. return inst.settings[name] !== undefined ?
  7687. inst.settings[name] : this._defaults[name];
  7688. },
  7689. /* Parse existing date and initialise date picker. */
  7690. _setDateFromField: function(inst, noDefault) {
  7691. if (inst.input.val() === inst.lastVal) {
  7692. return;
  7693. }
  7694. var dateFormat = this._get(inst, "dateFormat"),
  7695. dates = inst.lastVal = inst.input ? inst.input.val() : null,
  7696. defaultDate = this._getDefaultDate(inst),
  7697. date = defaultDate,
  7698. settings = this._getFormatConfig(inst);
  7699. try {
  7700. date = this.parseDate(dateFormat, dates, settings) || defaultDate;
  7701. } catch (event) {
  7702. dates = (noDefault ? "" : dates);
  7703. }
  7704. inst.selectedDay = date.getDate();
  7705. inst.drawMonth = inst.selectedMonth = date.getMonth();
  7706. inst.drawYear = inst.selectedYear = date.getFullYear();
  7707. inst.currentDay = (dates ? date.getDate() : 0);
  7708. inst.currentMonth = (dates ? date.getMonth() : 0);
  7709. inst.currentYear = (dates ? date.getFullYear() : 0);
  7710. this._adjustInstDate(inst);
  7711. },
  7712. /* Retrieve the default date shown on opening. */
  7713. _getDefaultDate: function(inst) {
  7714. return this._restrictMinMax(inst,
  7715. this._determineDate(inst, this._get(inst, "defaultDate"), new Date()));
  7716. },
  7717. /* A date may be specified as an exact value or a relative one. */
  7718. _determineDate: function(inst, date, defaultDate) {
  7719. var offsetNumeric = function(offset) {
  7720. var date = new Date();
  7721. date.setDate(date.getDate() + offset);
  7722. return date;
  7723. },
  7724. offsetString = function(offset) {
  7725. try {
  7726. return $.datepicker.parseDate($.datepicker._get(inst, "dateFormat"),
  7727. offset, $.datepicker._getFormatConfig(inst));
  7728. }
  7729. catch (e) {
  7730. // Ignore
  7731. }
  7732. var date = (offset.toLowerCase().match(/^c/) ?
  7733. $.datepicker._getDate(inst) : null) || new Date(),
  7734. year = date.getFullYear(),
  7735. month = date.getMonth(),
  7736. day = date.getDate(),
  7737. pattern = /([+\-]?[0-9]+)\s*(d|D|w|W|m|M|y|Y)?/g,
  7738. matches = pattern.exec(offset);
  7739. while (matches) {
  7740. switch (matches[2] || "d") {
  7741. case "d" : case "D" :
  7742. day += parseInt(matches[1],10); break;
  7743. case "w" : case "W" :
  7744. day += parseInt(matches[1],10) * 7; break;
  7745. case "m" : case "M" :
  7746. month += parseInt(matches[1],10);
  7747. day = Math.min(day, $.datepicker._getDaysInMonth(year, month));
  7748. break;
  7749. case "y": case "Y" :
  7750. year += parseInt(matches[1],10);
  7751. day = Math.min(day, $.datepicker._getDaysInMonth(year, month));
  7752. break;
  7753. }
  7754. matches = pattern.exec(offset);
  7755. }
  7756. return new Date(year, month, day);
  7757. },
  7758. newDate = (date == null || date === "" ? defaultDate : (typeof date === "string" ? offsetString(date) :
  7759. (typeof date === "number" ? (isNaN(date) ? defaultDate : offsetNumeric(date)) : new Date(date.getTime()))));
  7760. newDate = (newDate && newDate.toString() === "Invalid Date" ? defaultDate : newDate);
  7761. if (newDate) {
  7762. newDate.setHours(0);
  7763. newDate.setMinutes(0);
  7764. newDate.setSeconds(0);
  7765. newDate.setMilliseconds(0);
  7766. }
  7767. return this._daylightSavingAdjust(newDate);
  7768. },
  7769. /* Handle switch to/from daylight saving.
  7770. * Hours may be non-zero on daylight saving cut-over:
  7771. * > 12 when midnight changeover, but then cannot generate
  7772. * midnight datetime, so jump to 1AM, otherwise reset.
  7773. * @param date (Date) the date to check
  7774. * @return (Date) the corrected date
  7775. */
  7776. _daylightSavingAdjust: function(date) {
  7777. if (!date) {
  7778. return null;
  7779. }
  7780. date.setHours(date.getHours() > 12 ? date.getHours() + 2 : 0);
  7781. return date;
  7782. },
  7783. /* Set the date(s) directly. */
  7784. _setDate: function(inst, date, noChange) {
  7785. var clear = !date,
  7786. origMonth = inst.selectedMonth,
  7787. origYear = inst.selectedYear,
  7788. newDate = this._restrictMinMax(inst, this._determineDate(inst, date, new Date()));
  7789. inst.selectedDay = inst.currentDay = newDate.getDate();
  7790. inst.drawMonth = inst.selectedMonth = inst.currentMonth = newDate.getMonth();
  7791. inst.drawYear = inst.selectedYear = inst.currentYear = newDate.getFullYear();
  7792. if ((origMonth !== inst.selectedMonth || origYear !== inst.selectedYear) && !noChange) {
  7793. this._notifyChange(inst);
  7794. }
  7795. this._adjustInstDate(inst);
  7796. if (inst.input) {
  7797. inst.input.val(clear ? "" : this._formatDate(inst));
  7798. }
  7799. },
  7800. /* Retrieve the date(s) directly. */
  7801. _getDate: function(inst) {
  7802. var startDate = (!inst.currentYear || (inst.input && inst.input.val() === "") ? null :
  7803. this._daylightSavingAdjust(new Date(
  7804. inst.currentYear, inst.currentMonth, inst.currentDay)));
  7805. return startDate;
  7806. },
  7807. /* Attach the onxxx handlers. These are declared statically so
  7808. * they work with static code transformers like Caja.
  7809. */
  7810. _attachHandlers: function(inst) {
  7811. var stepMonths = this._get(inst, "stepMonths"),
  7812. id = "#" + inst.id.replace( /\\\\/g, "\\" );
  7813. inst.dpDiv.find("[data-handler]").map(function () {
  7814. var handler = {
  7815. prev: function () {
  7816. $.datepicker._adjustDate(id, -stepMonths, "M");
  7817. },
  7818. next: function () {
  7819. $.datepicker._adjustDate(id, +stepMonths, "M");
  7820. },
  7821. hide: function () {
  7822. $.datepicker._hideDatepicker();
  7823. },
  7824. today: function () {
  7825. $.datepicker._gotoToday(id);
  7826. },
  7827. selectDay: function () {
  7828. $.datepicker._selectDay(id, +this.getAttribute("data-month"), +this.getAttribute("data-year"), this);
  7829. return false;
  7830. },
  7831. selectMonth: function () {
  7832. $.datepicker._selectMonthYear(id, this, "M");
  7833. return false;
  7834. },
  7835. selectYear: function () {
  7836. $.datepicker._selectMonthYear(id, this, "Y");
  7837. return false;
  7838. }
  7839. };
  7840. $(this).bind(this.getAttribute("data-event"), handler[this.getAttribute("data-handler")]);
  7841. });
  7842. },
  7843. /* Generate the HTML for the current state of the date picker. */
  7844. _generateHTML: function(inst) {
  7845. var maxDraw, prevText, prev, nextText, next, currentText, gotoDate,
  7846. controls, buttonPanel, firstDay, showWeek, dayNames, dayNamesMin,
  7847. monthNames, monthNamesShort, beforeShowDay, showOtherMonths,
  7848. selectOtherMonths, defaultDate, html, dow, row, group, col, selectedDate,
  7849. cornerClass, calender, thead, day, daysInMonth, leadDays, curRows, numRows,
  7850. printDate, dRow, tbody, daySettings, otherMonth, unselectable,
  7851. tempDate = new Date(),
  7852. today = this._daylightSavingAdjust(
  7853. new Date(tempDate.getFullYear(), tempDate.getMonth(), tempDate.getDate())), // clear time
  7854. isRTL = this._get(inst, "isRTL"),
  7855. showButtonPanel = this._get(inst, "showButtonPanel"),
  7856. hideIfNoPrevNext = this._get(inst, "hideIfNoPrevNext"),
  7857. navigationAsDateFormat = this._get(inst, "navigationAsDateFormat"),
  7858. numMonths = this._getNumberOfMonths(inst),
  7859. showCurrentAtPos = this._get(inst, "showCurrentAtPos"),
  7860. stepMonths = this._get(inst, "stepMonths"),
  7861. isMultiMonth = (numMonths[0] !== 1 || numMonths[1] !== 1),
  7862. currentDate = this._daylightSavingAdjust((!inst.currentDay ? new Date(9999, 9, 9) :
  7863. new Date(inst.currentYear, inst.currentMonth, inst.currentDay))),
  7864. minDate = this._getMinMaxDate(inst, "min"),
  7865. maxDate = this._getMinMaxDate(inst, "max"),
  7866. drawMonth = inst.drawMonth - showCurrentAtPos,
  7867. drawYear = inst.drawYear;
  7868. if (drawMonth < 0) {
  7869. drawMonth += 12;
  7870. drawYear--;
  7871. }
  7872. if (maxDate) {
  7873. maxDraw = this._daylightSavingAdjust(new Date(maxDate.getFullYear(),
  7874. maxDate.getMonth() - (numMonths[0] * numMonths[1]) + 1, maxDate.getDate()));
  7875. maxDraw = (minDate && maxDraw < minDate ? minDate : maxDraw);
  7876. while (this._daylightSavingAdjust(new Date(drawYear, drawMonth, 1)) > maxDraw) {
  7877. drawMonth--;
  7878. if (drawMonth < 0) {
  7879. drawMonth = 11;
  7880. drawYear--;
  7881. }
  7882. }
  7883. }
  7884. inst.drawMonth = drawMonth;
  7885. inst.drawYear = drawYear;
  7886. prevText = this._get(inst, "prevText");
  7887. prevText = (!navigationAsDateFormat ? prevText : this.formatDate(prevText,
  7888. this._daylightSavingAdjust(new Date(drawYear, drawMonth - stepMonths, 1)),
  7889. this._getFormatConfig(inst)));
  7890. prev = (this._canAdjustMonth(inst, -1, drawYear, drawMonth) ?
  7891. "<a class='ui-datepicker-prev ui-corner-all' data-handler='prev' data-event='click'" +
  7892. " title='" + prevText + "'><span class='ui-icon ui-icon-circle-triangle-" + ( isRTL ? "e" : "w") + "'>" + prevText + "</span></a>" :
  7893. (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>"));
  7894. nextText = this._get(inst, "nextText");
  7895. nextText = (!navigationAsDateFormat ? nextText : this.formatDate(nextText,
  7896. this._daylightSavingAdjust(new Date(drawYear, drawMonth + stepMonths, 1)),
  7897. this._getFormatConfig(inst)));
  7898. next = (this._canAdjustMonth(inst, +1, drawYear, drawMonth) ?
  7899. "<a class='ui-datepicker-next ui-corner-all' data-handler='next' data-event='click'" +
  7900. " title='" + nextText + "'><span class='ui-icon ui-icon-circle-triangle-" + ( isRTL ? "w" : "e") + "'>" + nextText + "</span></a>" :
  7901. (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>"));
  7902. currentText = this._get(inst, "currentText");
  7903. gotoDate = (this._get(inst, "gotoCurrent") && inst.currentDay ? currentDate : today);
  7904. currentText = (!navigationAsDateFormat ? currentText :
  7905. this.formatDate(currentText, gotoDate, this._getFormatConfig(inst)));
  7906. 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'>" +
  7907. this._get(inst, "closeText") + "</button>" : "");
  7908. buttonPanel = (showButtonPanel) ? "<div class='ui-datepicker-buttonpane ui-widget-content'>" + (isRTL ? controls : "") +
  7909. (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'" +
  7910. ">" + currentText + "</button>" : "") + (isRTL ? "" : controls) + "</div>" : "";
  7911. firstDay = parseInt(this._get(inst, "firstDay"),10);
  7912. firstDay = (isNaN(firstDay) ? 0 : firstDay);
  7913. showWeek = this._get(inst, "showWeek");
  7914. dayNames = this._get(inst, "dayNames");
  7915. dayNamesMin = this._get(inst, "dayNamesMin");
  7916. monthNames = this._get(inst, "monthNames");
  7917. monthNamesShort = this._get(inst, "monthNamesShort");
  7918. beforeShowDay = this._get(inst, "beforeShowDay");
  7919. showOtherMonths = this._get(inst, "showOtherMonths");
  7920. selectOtherMonths = this._get(inst, "selectOtherMonths");
  7921. defaultDate = this._getDefaultDate(inst);
  7922. html = "";
  7923. dow;
  7924. for (row = 0; row < numMonths[0]; row++) {
  7925. group = "";
  7926. this.maxRows = 4;
  7927. for (col = 0; col < numMonths[1]; col++) {
  7928. selectedDate = this._daylightSavingAdjust(new Date(drawYear, drawMonth, inst.selectedDay));
  7929. cornerClass = " ui-corner-all";
  7930. calender = "";
  7931. if (isMultiMonth) {
  7932. calender += "<div class='ui-datepicker-group";
  7933. if (numMonths[1] > 1) {
  7934. switch (col) {
  7935. case 0: calender += " ui-datepicker-group-first";
  7936. cornerClass = " ui-corner-" + (isRTL ? "right" : "left"); break;
  7937. case numMonths[1]-1: calender += " ui-datepicker-group-last";
  7938. cornerClass = " ui-corner-" + (isRTL ? "left" : "right"); break;
  7939. default: calender += " ui-datepicker-group-middle"; cornerClass = ""; break;
  7940. }
  7941. }
  7942. calender += "'>";
  7943. }
  7944. calender += "<div class='ui-datepicker-header ui-widget-header ui-helper-clearfix" + cornerClass + "'>" +
  7945. (/all|left/.test(cornerClass) && row === 0 ? (isRTL ? next : prev) : "") +
  7946. (/all|right/.test(cornerClass) && row === 0 ? (isRTL ? prev : next) : "") +
  7947. this._generateMonthYearHeader(inst, drawMonth, drawYear, minDate, maxDate,
  7948. row > 0 || col > 0, monthNames, monthNamesShort) + // draw month headers
  7949. "</div><table class='ui-datepicker-calendar'><thead>" +
  7950. "<tr>";
  7951. thead = (showWeek ? "<th class='ui-datepicker-week-col'>" + this._get(inst, "weekHeader") + "</th>" : "");
  7952. for (dow = 0; dow < 7; dow++) { // days of the week
  7953. day = (dow + firstDay) % 7;
  7954. thead += "<th" + ((dow + firstDay + 6) % 7 >= 5 ? " class='ui-datepicker-week-end'" : "") + ">" +
  7955. "<span title='" + dayNames[day] + "'>" + dayNamesMin[day] + "</span></th>";
  7956. }
  7957. calender += thead + "</tr></thead><tbody>";
  7958. daysInMonth = this._getDaysInMonth(drawYear, drawMonth);
  7959. if (drawYear === inst.selectedYear && drawMonth === inst.selectedMonth) {
  7960. inst.selectedDay = Math.min(inst.selectedDay, daysInMonth);
  7961. }
  7962. leadDays = (this._getFirstDayOfMonth(drawYear, drawMonth) - firstDay + 7) % 7;
  7963. curRows = Math.ceil((leadDays + daysInMonth) / 7); // calculate the number of rows to generate
  7964. numRows = (isMultiMonth ? this.maxRows > curRows ? this.maxRows : curRows : curRows); //If multiple months, use the higher number of rows (see #7043)
  7965. this.maxRows = numRows;
  7966. printDate = this._daylightSavingAdjust(new Date(drawYear, drawMonth, 1 - leadDays));
  7967. for (dRow = 0; dRow < numRows; dRow++) { // create date picker rows
  7968. calender += "<tr>";
  7969. tbody = (!showWeek ? "" : "<td class='ui-datepicker-week-col'>" +
  7970. this._get(inst, "calculateWeek")(printDate) + "</td>");
  7971. for (dow = 0; dow < 7; dow++) { // create date picker days
  7972. daySettings = (beforeShowDay ?
  7973. beforeShowDay.apply((inst.input ? inst.input[0] : null), [printDate]) : [true, ""]);
  7974. otherMonth = (printDate.getMonth() !== drawMonth);
  7975. unselectable = (otherMonth && !selectOtherMonths) || !daySettings[0] ||
  7976. (minDate && printDate < minDate) || (maxDate && printDate > maxDate);
  7977. tbody += "<td class='" +
  7978. ((dow + firstDay + 6) % 7 >= 5 ? " ui-datepicker-week-end" : "") + // highlight weekends
  7979. (otherMonth ? " ui-datepicker-other-month" : "") + // highlight days from other months
  7980. ((printDate.getTime() === selectedDate.getTime() && drawMonth === inst.selectedMonth && inst._keyEvent) || // user pressed key
  7981. (defaultDate.getTime() === printDate.getTime() && defaultDate.getTime() === selectedDate.getTime()) ?
  7982. // or defaultDate is current printedDate and defaultDate is selectedDate
  7983. " " + this._dayOverClass : "") + // highlight selected day
  7984. (unselectable ? " " + this._unselectableClass + " ui-state-disabled": "") + // highlight unselectable days
  7985. (otherMonth && !showOtherMonths ? "" : " " + daySettings[1] + // highlight custom dates
  7986. (printDate.getTime() === currentDate.getTime() ? " " + this._currentClass : "") + // highlight selected day
  7987. (printDate.getTime() === today.getTime() ? " ui-datepicker-today" : "")) + "'" + // highlight today (if different)
  7988. ((!otherMonth || showOtherMonths) && daySettings[2] ? " title='" + daySettings[2].replace(/'/g, "&#39;") + "'" : "") + // cell title
  7989. (unselectable ? "" : " data-handler='selectDay' data-event='click' data-month='" + printDate.getMonth() + "' data-year='" + printDate.getFullYear() + "'") + ">" + // actions
  7990. (otherMonth && !showOtherMonths ? "&#xa0;" : // display for other months
  7991. (unselectable ? "<span class='ui-state-default'>" + printDate.getDate() + "</span>" : "<a class='ui-state-default" +
  7992. (printDate.getTime() === today.getTime() ? " ui-state-highlight" : "") +
  7993. (printDate.getTime() === currentDate.getTime() ? " ui-state-active" : "") + // highlight selected day
  7994. (otherMonth ? " ui-priority-secondary" : "") + // distinguish dates from other months
  7995. "' href='#'>" + printDate.getDate() + "</a>")) + "</td>"; // display selectable date
  7996. printDate.setDate(printDate.getDate() + 1);
  7997. printDate = this._daylightSavingAdjust(printDate);
  7998. }
  7999. calender += tbody + "</tr>";
  8000. }
  8001. drawMonth++;
  8002. if (drawMonth > 11) {
  8003. drawMonth = 0;
  8004. drawYear++;
  8005. }
  8006. calender += "</tbody></table>" + (isMultiMonth ? "</div>" +
  8007. ((numMonths[0] > 0 && col === numMonths[1]-1) ? "<div class='ui-datepicker-row-break'></div>" : "") : "");
  8008. group += calender;
  8009. }
  8010. html += group;
  8011. }
  8012. html += buttonPanel;
  8013. inst._keyEvent = false;
  8014. return html;
  8015. },
  8016. /* Generate the month and year header. */
  8017. _generateMonthYearHeader: function(inst, drawMonth, drawYear, minDate, maxDate,
  8018. secondary, monthNames, monthNamesShort) {
  8019. var inMinYear, inMaxYear, month, years, thisYear, determineYear, year, endYear,
  8020. changeMonth = this._get(inst, "changeMonth"),
  8021. changeYear = this._get(inst, "changeYear"),
  8022. showMonthAfterYear = this._get(inst, "showMonthAfterYear"),
  8023. html = "<div class='ui-datepicker-title'>",
  8024. monthHtml = "";
  8025. // month selection
  8026. if (secondary || !changeMonth) {
  8027. monthHtml += "<span class='ui-datepicker-month'>" + monthNames[drawMonth] + "</span>";
  8028. } else {
  8029. inMinYear = (minDate && minDate.getFullYear() === drawYear);
  8030. inMaxYear = (maxDate && maxDate.getFullYear() === drawYear);
  8031. monthHtml += "<select class='ui-datepicker-month' data-handler='selectMonth' data-event='change'>";
  8032. for ( month = 0; month < 12; month++) {
  8033. if ((!inMinYear || month >= minDate.getMonth()) && (!inMaxYear || month <= maxDate.getMonth())) {
  8034. monthHtml += "<option value='" + month + "'" +
  8035. (month === drawMonth ? " selected='selected'" : "") +
  8036. ">" + monthNamesShort[month] + "</option>";
  8037. }
  8038. }
  8039. monthHtml += "</select>";
  8040. }
  8041. if (!showMonthAfterYear) {
  8042. html += monthHtml + (secondary || !(changeMonth && changeYear) ? "&#xa0;" : "");
  8043. }
  8044. // year selection
  8045. if ( !inst.yearshtml ) {
  8046. inst.yearshtml = "";
  8047. if (secondary || !changeYear) {
  8048. html += "<span class='ui-datepicker-year'>" + drawYear + "</span>";
  8049. } else {
  8050. // determine range of years to display
  8051. years = this._get(inst, "yearRange").split(":");
  8052. thisYear = new Date().getFullYear();
  8053. determineYear = function(value) {
  8054. var year = (value.match(/c[+\-].*/) ? drawYear + parseInt(value.substring(1), 10) :
  8055. (value.match(/[+\-].*/) ? thisYear + parseInt(value, 10) :
  8056. parseInt(value, 10)));
  8057. return (isNaN(year) ? thisYear : year);
  8058. };
  8059. year = determineYear(years[0]);
  8060. endYear = Math.max(year, determineYear(years[1] || ""));
  8061. year = (minDate ? Math.max(year, minDate.getFullYear()) : year);
  8062. endYear = (maxDate ? Math.min(endYear, maxDate.getFullYear()) : endYear);
  8063. inst.yearshtml += "<select class='ui-datepicker-year' data-handler='selectYear' data-event='change'>";
  8064. for (; year <= endYear; year++) {
  8065. inst.yearshtml += "<option value='" + year + "'" +
  8066. (year === drawYear ? " selected='selected'" : "") +
  8067. ">" + year + "</option>";
  8068. }
  8069. inst.yearshtml += "</select>";
  8070. html += inst.yearshtml;
  8071. inst.yearshtml = null;
  8072. }
  8073. }
  8074. html += this._get(inst, "yearSuffix");
  8075. if (showMonthAfterYear) {
  8076. html += (secondary || !(changeMonth && changeYear) ? "&#xa0;" : "") + monthHtml;
  8077. }
  8078. html += "</div>"; // Close datepicker_header
  8079. return html;
  8080. },
  8081. /* Adjust one of the date sub-fields. */
  8082. _adjustInstDate: function(inst, offset, period) {
  8083. var year = inst.drawYear + (period === "Y" ? offset : 0),
  8084. month = inst.drawMonth + (period === "M" ? offset : 0),
  8085. day = Math.min(inst.selectedDay, this._getDaysInMonth(year, month)) + (period === "D" ? offset : 0),
  8086. date = this._restrictMinMax(inst, this._daylightSavingAdjust(new Date(year, month, day)));
  8087. inst.selectedDay = date.getDate();
  8088. inst.drawMonth = inst.selectedMonth = date.getMonth();
  8089. inst.drawYear = inst.selectedYear = date.getFullYear();
  8090. if (period === "M" || period === "Y") {
  8091. this._notifyChange(inst);
  8092. }
  8093. },
  8094. /* Ensure a date is within any min/max bounds. */
  8095. _restrictMinMax: function(inst, date) {
  8096. var minDate = this._getMinMaxDate(inst, "min"),
  8097. maxDate = this._getMinMaxDate(inst, "max"),
  8098. newDate = (minDate && date < minDate ? minDate : date);
  8099. return (maxDate && newDate > maxDate ? maxDate : newDate);
  8100. },
  8101. /* Notify change of month/year. */
  8102. _notifyChange: function(inst) {
  8103. var onChange = this._get(inst, "onChangeMonthYear");
  8104. if (onChange) {
  8105. onChange.apply((inst.input ? inst.input[0] : null),
  8106. [inst.selectedYear, inst.selectedMonth + 1, inst]);
  8107. }
  8108. },
  8109. /* Determine the number of months to show. */
  8110. _getNumberOfMonths: function(inst) {
  8111. var numMonths = this._get(inst, "numberOfMonths");
  8112. return (numMonths == null ? [1, 1] : (typeof numMonths === "number" ? [1, numMonths] : numMonths));
  8113. },
  8114. /* Determine the current maximum date - ensure no time components are set. */
  8115. _getMinMaxDate: function(inst, minMax) {
  8116. return this._determineDate(inst, this._get(inst, minMax + "Date"), null);
  8117. },
  8118. /* Find the number of days in a given month. */
  8119. _getDaysInMonth: function(year, month) {
  8120. return 32 - this._daylightSavingAdjust(new Date(year, month, 32)).getDate();
  8121. },
  8122. /* Find the day of the week of the first of a month. */
  8123. _getFirstDayOfMonth: function(year, month) {
  8124. return new Date(year, month, 1).getDay();
  8125. },
  8126. /* Determines if we should allow a "next/prev" month display change. */
  8127. _canAdjustMonth: function(inst, offset, curYear, curMonth) {
  8128. var numMonths = this._getNumberOfMonths(inst),
  8129. date = this._daylightSavingAdjust(new Date(curYear,
  8130. curMonth + (offset < 0 ? offset : numMonths[0] * numMonths[1]), 1));
  8131. if (offset < 0) {
  8132. date.setDate(this._getDaysInMonth(date.getFullYear(), date.getMonth()));
  8133. }
  8134. return this._isInRange(inst, date);
  8135. },
  8136. /* Is the given date in the accepted range? */
  8137. _isInRange: function(inst, date) {
  8138. var yearSplit, currentYear,
  8139. minDate = this._getMinMaxDate(inst, "min"),
  8140. maxDate = this._getMinMaxDate(inst, "max"),
  8141. minYear = null,
  8142. maxYear = null,
  8143. years = this._get(inst, "yearRange");
  8144. if (years){
  8145. yearSplit = years.split(":");
  8146. currentYear = new Date().getFullYear();
  8147. minYear = parseInt(yearSplit[0], 10);
  8148. maxYear = parseInt(yearSplit[1], 10);
  8149. if ( yearSplit[0].match(/[+\-].*/) ) {
  8150. minYear += currentYear;
  8151. }
  8152. if ( yearSplit[1].match(/[+\-].*/) ) {
  8153. maxYear += currentYear;
  8154. }
  8155. }
  8156. return ((!minDate || date.getTime() >= minDate.getTime()) &&
  8157. (!maxDate || date.getTime() <= maxDate.getTime()) &&
  8158. (!minYear || date.getFullYear() >= minYear) &&
  8159. (!maxYear || date.getFullYear() <= maxYear));
  8160. },
  8161. /* Provide the configuration settings for formatting/parsing. */
  8162. _getFormatConfig: function(inst) {
  8163. var shortYearCutoff = this._get(inst, "shortYearCutoff");
  8164. shortYearCutoff = (typeof shortYearCutoff !== "string" ? shortYearCutoff :
  8165. new Date().getFullYear() % 100 + parseInt(shortYearCutoff, 10));
  8166. return {shortYearCutoff: shortYearCutoff,
  8167. dayNamesShort: this._get(inst, "dayNamesShort"), dayNames: this._get(inst, "dayNames"),
  8168. monthNamesShort: this._get(inst, "monthNamesShort"), monthNames: this._get(inst, "monthNames")};
  8169. },
  8170. /* Format the given date for display. */
  8171. _formatDate: function(inst, day, month, year) {
  8172. if (!day) {
  8173. inst.currentDay = inst.selectedDay;
  8174. inst.currentMonth = inst.selectedMonth;
  8175. inst.currentYear = inst.selectedYear;
  8176. }
  8177. var date = (day ? (typeof day === "object" ? day :
  8178. this._daylightSavingAdjust(new Date(year, month, day))) :
  8179. this._daylightSavingAdjust(new Date(inst.currentYear, inst.currentMonth, inst.currentDay)));
  8180. return this.formatDate(this._get(inst, "dateFormat"), date, this._getFormatConfig(inst));
  8181. }
  8182. });
  8183. /*
  8184. * Bind hover events for datepicker elements.
  8185. * Done via delegate so the binding only occurs once in the lifetime of the parent div.
  8186. * Global instActive, set by _updateDatepicker allows the handlers to find their way back to the active picker.
  8187. */
  8188. function bindHover(dpDiv) {
  8189. var selector = "button, .ui-datepicker-prev, .ui-datepicker-next, .ui-datepicker-calendar td a";
  8190. return dpDiv.delegate(selector, "mouseout", function() {
  8191. $(this).removeClass("ui-state-hover");
  8192. if (this.className.indexOf("ui-datepicker-prev") !== -1) {
  8193. $(this).removeClass("ui-datepicker-prev-hover");
  8194. }
  8195. if (this.className.indexOf("ui-datepicker-next") !== -1) {
  8196. $(this).removeClass("ui-datepicker-next-hover");
  8197. }
  8198. })
  8199. .delegate(selector, "mouseover", function(){
  8200. if (!$.datepicker._isDisabledDatepicker( instActive.inline ? dpDiv.parent()[0] : instActive.input[0])) {
  8201. $(this).parents(".ui-datepicker-calendar").find("a").removeClass("ui-state-hover");
  8202. $(this).addClass("ui-state-hover");
  8203. if (this.className.indexOf("ui-datepicker-prev") !== -1) {
  8204. $(this).addClass("ui-datepicker-prev-hover");
  8205. }
  8206. if (this.className.indexOf("ui-datepicker-next") !== -1) {
  8207. $(this).addClass("ui-datepicker-next-hover");
  8208. }
  8209. }
  8210. });
  8211. }
  8212. /* jQuery extend now ignores nulls! */
  8213. function extendRemove(target, props) {
  8214. $.extend(target, props);
  8215. for (var name in props) {
  8216. if (props[name] == null) {
  8217. target[name] = props[name];
  8218. }
  8219. }
  8220. return target;
  8221. }
  8222. /* Invoke the datepicker functionality.
  8223. @param options string - a command, optionally followed by additional parameters or
  8224. Object - settings for attaching new datepicker functionality
  8225. @return jQuery object */
  8226. $.fn.datepicker = function(options){
  8227. /* Verify an empty collection wasn't passed - Fixes #6976 */
  8228. if ( !this.length ) {
  8229. return this;
  8230. }
  8231. /* Initialise the date picker. */
  8232. if (!$.datepicker.initialized) {
  8233. $(document).mousedown($.datepicker._checkExternalClick);
  8234. $.datepicker.initialized = true;
  8235. }
  8236. /* Append datepicker main container to body if not exist. */
  8237. if ($("#"+$.datepicker._mainDivId).length === 0) {
  8238. $("body").append($.datepicker.dpDiv);
  8239. }
  8240. var otherArgs = Array.prototype.slice.call(arguments, 1);
  8241. if (typeof options === "string" && (options === "isDisabled" || options === "getDate" || options === "widget")) {
  8242. return $.datepicker["_" + options + "Datepicker"].
  8243. apply($.datepicker, [this[0]].concat(otherArgs));
  8244. }
  8245. if (options === "option" && arguments.length === 2 && typeof arguments[1] === "string") {
  8246. return $.datepicker["_" + options + "Datepicker"].
  8247. apply($.datepicker, [this[0]].concat(otherArgs));
  8248. }
  8249. return this.each(function() {
  8250. typeof options === "string" ?
  8251. $.datepicker["_" + options + "Datepicker"].
  8252. apply($.datepicker, [this].concat(otherArgs)) :
  8253. $.datepicker._attachDatepicker(this, options);
  8254. });
  8255. };
  8256. $.datepicker = new Datepicker(); // singleton instance
  8257. $.datepicker.initialized = false;
  8258. $.datepicker.uuid = new Date().getTime();
  8259. $.datepicker.version = "1.10.3";
  8260. })(jQuery);
  8261. (function( $, undefined ) {
  8262. var sizeRelatedOptions = {
  8263. buttons: true,
  8264. height: true,
  8265. maxHeight: true,
  8266. maxWidth: true,
  8267. minHeight: true,
  8268. minWidth: true,
  8269. width: true
  8270. },
  8271. resizableRelatedOptions = {
  8272. maxHeight: true,
  8273. maxWidth: true,
  8274. minHeight: true,
  8275. minWidth: true
  8276. };
  8277. $.widget( "ui.dialog", {
  8278. version: "1.10.3",
  8279. options: {
  8280. appendTo: "body",
  8281. autoOpen: true,
  8282. buttons: [],
  8283. closeOnEscape: true,
  8284. closeText: "close",
  8285. dialogClass: "",
  8286. draggable: true,
  8287. hide: null,
  8288. height: "auto",
  8289. maxHeight: null,
  8290. maxWidth: null,
  8291. minHeight: 150,
  8292. minWidth: 150,
  8293. modal: false,
  8294. position: {
  8295. my: "center",
  8296. at: "center",
  8297. of: window,
  8298. collision: "fit",
  8299. // Ensure the titlebar is always visible
  8300. using: function( pos ) {
  8301. var topOffset = $( this ).css( pos ).offset().top;
  8302. if ( topOffset < 0 ) {
  8303. $( this ).css( "top", pos.top - topOffset );
  8304. }
  8305. }
  8306. },
  8307. resizable: true,
  8308. show: null,
  8309. title: null,
  8310. width: 300,
  8311. // callbacks
  8312. beforeClose: null,
  8313. close: null,
  8314. drag: null,
  8315. dragStart: null,
  8316. dragStop: null,
  8317. focus: null,
  8318. open: null,
  8319. resize: null,
  8320. resizeStart: null,
  8321. resizeStop: null
  8322. },
  8323. _create: function() {
  8324. this.originalCss = {
  8325. display: this.element[0].style.display,
  8326. width: this.element[0].style.width,
  8327. minHeight: this.element[0].style.minHeight,
  8328. maxHeight: this.element[0].style.maxHeight,
  8329. height: this.element[0].style.height
  8330. };
  8331. this.originalPosition = {
  8332. parent: this.element.parent(),
  8333. index: this.element.parent().children().index( this.element )
  8334. };
  8335. this.originalTitle = this.element.attr("title");
  8336. this.options.title = this.options.title || this.originalTitle;
  8337. this._createWrapper();
  8338. this.element
  8339. .show()
  8340. .removeAttr("title")
  8341. .addClass("ui-dialog-content ui-widget-content")
  8342. .appendTo( this.uiDialog );
  8343. this._createTitlebar();
  8344. this._createButtonPane();
  8345. if ( this.options.draggable && $.fn.draggable ) {
  8346. this._makeDraggable();
  8347. }
  8348. if ( this.options.resizable && $.fn.resizable ) {
  8349. this._makeResizable();
  8350. }
  8351. this._isOpen = false;
  8352. },
  8353. _init: function() {
  8354. if ( this.options.autoOpen ) {
  8355. this.open();
  8356. }
  8357. },
  8358. _appendTo: function() {
  8359. var element = this.options.appendTo;
  8360. if ( element && (element.jquery || element.nodeType) ) {
  8361. return $( element );
  8362. }
  8363. return this.document.find( element || "body" ).eq( 0 );
  8364. },
  8365. _destroy: function() {
  8366. var next,
  8367. originalPosition = this.originalPosition;
  8368. this._destroyOverlay();
  8369. this.element
  8370. .removeUniqueId()
  8371. .removeClass("ui-dialog-content ui-widget-content")
  8372. .css( this.originalCss )
  8373. // Without detaching first, the following becomes really slow
  8374. .detach();
  8375. this.uiDialog.stop( true, true ).remove();
  8376. if ( this.originalTitle ) {
  8377. this.element.attr( "title", this.originalTitle );
  8378. }
  8379. next = originalPosition.parent.children().eq( originalPosition.index );
  8380. // Don't try to place the dialog next to itself (#8613)
  8381. if ( next.length && next[0] !== this.element[0] ) {
  8382. next.before( this.element );
  8383. } else {
  8384. originalPosition.parent.append( this.element );
  8385. }
  8386. },
  8387. widget: function() {
  8388. return this.uiDialog;
  8389. },
  8390. disable: $.noop,
  8391. enable: $.noop,
  8392. close: function( event ) {
  8393. var that = this;
  8394. if ( !this._isOpen || this._trigger( "beforeClose", event ) === false ) {
  8395. return;
  8396. }
  8397. this._isOpen = false;
  8398. this._destroyOverlay();
  8399. if ( !this.opener.filter(":focusable").focus().length ) {
  8400. // Hiding a focused element doesn't trigger blur in WebKit
  8401. // so in case we have nothing to focus on, explicitly blur the active element
  8402. // https://bugs.webkit.org/show_bug.cgi?id=47182
  8403. $( this.document[0].activeElement ).blur();
  8404. }
  8405. this._hide( this.uiDialog, this.options.hide, function() {
  8406. that._trigger( "close", event );
  8407. });
  8408. },
  8409. isOpen: function() {
  8410. return this._isOpen;
  8411. },
  8412. moveToTop: function() {
  8413. this._moveToTop();
  8414. },
  8415. _moveToTop: function( event, silent ) {
  8416. var moved = !!this.uiDialog.nextAll(":visible").insertBefore( this.uiDialog ).length;
  8417. if ( moved && !silent ) {
  8418. this._trigger( "focus", event );
  8419. }
  8420. return moved;
  8421. },
  8422. open: function() {
  8423. var that = this;
  8424. if ( this._isOpen ) {
  8425. if ( this._moveToTop() ) {
  8426. this._focusTabbable();
  8427. }
  8428. return;
  8429. }
  8430. this._isOpen = true;
  8431. this.opener = $( this.document[0].activeElement );
  8432. this._size();
  8433. this._position();
  8434. this._createOverlay();
  8435. this._moveToTop( null, true );
  8436. this._show( this.uiDialog, this.options.show, function() {
  8437. that._focusTabbable();
  8438. that._trigger("focus");
  8439. });
  8440. this._trigger("open");
  8441. },
  8442. _focusTabbable: function() {
  8443. // Set focus to the first match:
  8444. // 1. First element inside the dialog matching [autofocus]
  8445. // 2. Tabbable element inside the content element
  8446. // 3. Tabbable element inside the buttonpane
  8447. // 4. The close button
  8448. // 5. The dialog itself
  8449. var hasFocus = this.element.find("[autofocus]");
  8450. if ( !hasFocus.length ) {
  8451. hasFocus = this.element.find(":tabbable");
  8452. }
  8453. if ( !hasFocus.length ) {
  8454. hasFocus = this.uiDialogButtonPane.find(":tabbable");
  8455. }
  8456. if ( !hasFocus.length ) {
  8457. hasFocus = this.uiDialogTitlebarClose.filter(":tabbable");
  8458. }
  8459. if ( !hasFocus.length ) {
  8460. hasFocus = this.uiDialog;
  8461. }
  8462. hasFocus.eq( 0 ).focus();
  8463. },
  8464. _keepFocus: function( event ) {
  8465. function checkFocus() {
  8466. var activeElement = this.document[0].activeElement,
  8467. isActive = this.uiDialog[0] === activeElement ||
  8468. $.contains( this.uiDialog[0], activeElement );
  8469. if ( !isActive ) {
  8470. this._focusTabbable();
  8471. }
  8472. }
  8473. event.preventDefault();
  8474. checkFocus.call( this );
  8475. // support: IE
  8476. // IE <= 8 doesn't prevent moving focus even with event.preventDefault()
  8477. // so we check again later
  8478. this._delay( checkFocus );
  8479. },
  8480. _createWrapper: function() {
  8481. this.uiDialog = $("<div>")
  8482. .addClass( "ui-dialog ui-widget ui-widget-content ui-corner-all ui-front " +
  8483. this.options.dialogClass )
  8484. .hide()
  8485. .attr({
  8486. // Setting tabIndex makes the div focusable
  8487. tabIndex: -1,
  8488. role: "dialog"
  8489. })
  8490. .appendTo( this._appendTo() );
  8491. this._on( this.uiDialog, {
  8492. keydown: function( event ) {
  8493. if ( this.options.closeOnEscape && !event.isDefaultPrevented() && event.keyCode &&
  8494. event.keyCode === $.ui.keyCode.ESCAPE ) {
  8495. event.preventDefault();
  8496. this.close( event );
  8497. return;
  8498. }
  8499. // prevent tabbing out of dialogs
  8500. if ( event.keyCode !== $.ui.keyCode.TAB ) {
  8501. return;
  8502. }
  8503. var tabbables = this.uiDialog.find(":tabbable"),
  8504. first = tabbables.filter(":first"),
  8505. last = tabbables.filter(":last");
  8506. if ( ( event.target === last[0] || event.target === this.uiDialog[0] ) && !event.shiftKey ) {
  8507. first.focus( 1 );
  8508. event.preventDefault();
  8509. } else if ( ( event.target === first[0] || event.target === this.uiDialog[0] ) && event.shiftKey ) {
  8510. last.focus( 1 );
  8511. event.preventDefault();
  8512. }
  8513. },
  8514. mousedown: function( event ) {
  8515. if ( this._moveToTop( event ) ) {
  8516. this._focusTabbable();
  8517. }
  8518. }
  8519. });
  8520. // We assume that any existing aria-describedby attribute means
  8521. // that the dialog content is marked up properly
  8522. // otherwise we brute force the content as the description
  8523. if ( !this.element.find("[aria-describedby]").length ) {
  8524. this.uiDialog.attr({
  8525. "aria-describedby": this.element.uniqueId().attr("id")
  8526. });
  8527. }
  8528. },
  8529. _createTitlebar: function() {
  8530. var uiDialogTitle;
  8531. this.uiDialogTitlebar = $("<div>")
  8532. .addClass("ui-dialog-titlebar ui-widget-header ui-corner-all ui-helper-clearfix")
  8533. .prependTo( this.uiDialog );
  8534. this._on( this.uiDialogTitlebar, {
  8535. mousedown: function( event ) {
  8536. // Don't prevent click on close button (#8838)
  8537. // Focusing a dialog that is partially scrolled out of view
  8538. // causes the browser to scroll it into view, preventing the click event
  8539. if ( !$( event.target ).closest(".ui-dialog-titlebar-close") ) {
  8540. // Dialog isn't getting focus when dragging (#8063)
  8541. this.uiDialog.focus();
  8542. }
  8543. }
  8544. });
  8545. this.uiDialogTitlebarClose = $("<button></button>")
  8546. .button({
  8547. label: this.options.closeText,
  8548. icons: {
  8549. primary: "ui-icon-closethick"
  8550. },
  8551. text: false
  8552. })
  8553. .addClass("ui-dialog-titlebar-close")
  8554. .appendTo( this.uiDialogTitlebar );
  8555. this._on( this.uiDialogTitlebarClose, {
  8556. click: function( event ) {
  8557. event.preventDefault();
  8558. this.close( event );
  8559. }
  8560. });
  8561. uiDialogTitle = $("<span>")
  8562. .uniqueId()
  8563. .addClass("ui-dialog-title")
  8564. .prependTo( this.uiDialogTitlebar );
  8565. this._title( uiDialogTitle );
  8566. this.uiDialog.attr({
  8567. "aria-labelledby": uiDialogTitle.attr("id")
  8568. });
  8569. },
  8570. _title: function( title ) {
  8571. if ( !this.options.title ) {
  8572. title.html("&#160;");
  8573. }
  8574. title.text( this.options.title );
  8575. },
  8576. _createButtonPane: function() {
  8577. this.uiDialogButtonPane = $("<div>")
  8578. .addClass("ui-dialog-buttonpane ui-widget-content ui-helper-clearfix");
  8579. this.uiButtonSet = $("<div>")
  8580. .addClass("ui-dialog-buttonset")
  8581. .appendTo( this.uiDialogButtonPane );
  8582. this._createButtons();
  8583. },
  8584. _createButtons: function() {
  8585. var that = this,
  8586. buttons = this.options.buttons;
  8587. // if we already have a button pane, remove it
  8588. this.uiDialogButtonPane.remove();
  8589. this.uiButtonSet.empty();
  8590. if ( $.isEmptyObject( buttons ) || ($.isArray( buttons ) && !buttons.length) ) {
  8591. this.uiDialog.removeClass("ui-dialog-buttons");
  8592. return;
  8593. }
  8594. $.each( buttons, function( name, props ) {
  8595. var click, buttonOptions;
  8596. props = $.isFunction( props ) ?
  8597. { click: props, text: name } :
  8598. props;
  8599. // Default to a non-submitting button
  8600. props = $.extend( { type: "button" }, props );
  8601. // Change the context for the click callback to be the main element
  8602. click = props.click;
  8603. props.click = function() {
  8604. click.apply( that.element[0], arguments );
  8605. };
  8606. buttonOptions = {
  8607. icons: props.icons,
  8608. text: props.showText
  8609. };
  8610. delete props.icons;
  8611. delete props.showText;
  8612. $( "<button></button>", props )
  8613. .button( buttonOptions )
  8614. .appendTo( that.uiButtonSet );
  8615. });
  8616. this.uiDialog.addClass("ui-dialog-buttons");
  8617. this.uiDialogButtonPane.appendTo( this.uiDialog );
  8618. },
  8619. _makeDraggable: function() {
  8620. var that = this,
  8621. options = this.options;
  8622. function filteredUi( ui ) {
  8623. return {
  8624. position: ui.position,
  8625. offset: ui.offset
  8626. };
  8627. }
  8628. this.uiDialog.draggable({
  8629. cancel: ".ui-dialog-content, .ui-dialog-titlebar-close",
  8630. handle: ".ui-dialog-titlebar",
  8631. containment: "document",
  8632. start: function( event, ui ) {
  8633. $( this ).addClass("ui-dialog-dragging");
  8634. that._blockFrames();
  8635. that._trigger( "dragStart", event, filteredUi( ui ) );
  8636. },
  8637. drag: function( event, ui ) {
  8638. that._trigger( "drag", event, filteredUi( ui ) );
  8639. },
  8640. stop: function( event, ui ) {
  8641. options.position = [
  8642. ui.position.left - that.document.scrollLeft(),
  8643. ui.position.top - that.document.scrollTop()
  8644. ];
  8645. $( this ).removeClass("ui-dialog-dragging");
  8646. that._unblockFrames();
  8647. that._trigger( "dragStop", event, filteredUi( ui ) );
  8648. }
  8649. });
  8650. },
  8651. _makeResizable: function() {
  8652. var that = this,
  8653. options = this.options,
  8654. handles = options.resizable,
  8655. // .ui-resizable has position: relative defined in the stylesheet
  8656. // but dialogs have to use absolute or fixed positioning
  8657. position = this.uiDialog.css("position"),
  8658. resizeHandles = typeof handles === "string" ?
  8659. handles :
  8660. "n,e,s,w,se,sw,ne,nw";
  8661. function filteredUi( ui ) {
  8662. return {
  8663. originalPosition: ui.originalPosition,
  8664. originalSize: ui.originalSize,
  8665. position: ui.position,
  8666. size: ui.size
  8667. };
  8668. }
  8669. this.uiDialog.resizable({
  8670. cancel: ".ui-dialog-content",
  8671. containment: "document",
  8672. alsoResize: this.element,
  8673. maxWidth: options.maxWidth,
  8674. maxHeight: options.maxHeight,
  8675. minWidth: options.minWidth,
  8676. minHeight: this._minHeight(),
  8677. handles: resizeHandles,
  8678. start: function( event, ui ) {
  8679. $( this ).addClass("ui-dialog-resizing");
  8680. that._blockFrames();
  8681. that._trigger( "resizeStart", event, filteredUi( ui ) );
  8682. },
  8683. resize: function( event, ui ) {
  8684. that._trigger( "resize", event, filteredUi( ui ) );
  8685. },
  8686. stop: function( event, ui ) {
  8687. options.height = $( this ).height();
  8688. options.width = $( this ).width();
  8689. $( this ).removeClass("ui-dialog-resizing");
  8690. that._unblockFrames();
  8691. that._trigger( "resizeStop", event, filteredUi( ui ) );
  8692. }
  8693. })
  8694. .css( "position", position );
  8695. },
  8696. _minHeight: function() {
  8697. var options = this.options;
  8698. return options.height === "auto" ?
  8699. options.minHeight :
  8700. Math.min( options.minHeight, options.height );
  8701. },
  8702. _position: function() {
  8703. // Need to show the dialog to get the actual offset in the position plugin
  8704. var isVisible = this.uiDialog.is(":visible");
  8705. if ( !isVisible ) {
  8706. this.uiDialog.show();
  8707. }
  8708. this.uiDialog.position( this.options.position );
  8709. if ( !isVisible ) {
  8710. this.uiDialog.hide();
  8711. }
  8712. },
  8713. _setOptions: function( options ) {
  8714. var that = this,
  8715. resize = false,
  8716. resizableOptions = {};
  8717. $.each( options, function( key, value ) {
  8718. that._setOption( key, value );
  8719. if ( key in sizeRelatedOptions ) {
  8720. resize = true;
  8721. }
  8722. if ( key in resizableRelatedOptions ) {
  8723. resizableOptions[ key ] = value;
  8724. }
  8725. });
  8726. if ( resize ) {
  8727. this._size();
  8728. this._position();
  8729. }
  8730. if ( this.uiDialog.is(":data(ui-resizable)") ) {
  8731. this.uiDialog.resizable( "option", resizableOptions );
  8732. }
  8733. },
  8734. _setOption: function( key, value ) {
  8735. /*jshint maxcomplexity:15*/
  8736. var isDraggable, isResizable,
  8737. uiDialog = this.uiDialog;
  8738. if ( key === "dialogClass" ) {
  8739. uiDialog
  8740. .removeClass( this.options.dialogClass )
  8741. .addClass( value );
  8742. }
  8743. if ( key === "disabled" ) {
  8744. return;
  8745. }
  8746. this._super( key, value );
  8747. if ( key === "appendTo" ) {
  8748. this.uiDialog.appendTo( this._appendTo() );
  8749. }
  8750. if ( key === "buttons" ) {
  8751. this._createButtons();
  8752. }
  8753. if ( key === "closeText" ) {
  8754. this.uiDialogTitlebarClose.button({
  8755. // Ensure that we always pass a string
  8756. label: "" + value
  8757. });
  8758. }
  8759. if ( key === "draggable" ) {
  8760. isDraggable = uiDialog.is(":data(ui-draggable)");
  8761. if ( isDraggable && !value ) {
  8762. uiDialog.draggable("destroy");
  8763. }
  8764. if ( !isDraggable && value ) {
  8765. this._makeDraggable();
  8766. }
  8767. }
  8768. if ( key === "position" ) {
  8769. this._position();
  8770. }
  8771. if ( key === "resizable" ) {
  8772. // currently resizable, becoming non-resizable
  8773. isResizable = uiDialog.is(":data(ui-resizable)");
  8774. if ( isResizable && !value ) {
  8775. uiDialog.resizable("destroy");
  8776. }
  8777. // currently resizable, changing handles
  8778. if ( isResizable && typeof value === "string" ) {
  8779. uiDialog.resizable( "option", "handles", value );
  8780. }
  8781. // currently non-resizable, becoming resizable
  8782. if ( !isResizable && value !== false ) {
  8783. this._makeResizable();
  8784. }
  8785. }
  8786. if ( key === "title" ) {
  8787. this._title( this.uiDialogTitlebar.find(".ui-dialog-title") );
  8788. }
  8789. },
  8790. _size: function() {
  8791. // If the user has resized the dialog, the .ui-dialog and .ui-dialog-content
  8792. // divs will both have width and height set, so we need to reset them
  8793. var nonContentHeight, minContentHeight, maxContentHeight,
  8794. options = this.options;
  8795. // Reset content sizing
  8796. this.element.show().css({
  8797. width: "auto",
  8798. minHeight: 0,
  8799. maxHeight: "none",
  8800. height: 0
  8801. });
  8802. if ( options.minWidth > options.width ) {
  8803. options.width = options.minWidth;
  8804. }
  8805. // reset wrapper sizing
  8806. // determine the height of all the non-content elements
  8807. nonContentHeight = this.uiDialog.css({
  8808. height: "auto",
  8809. width: options.width
  8810. })
  8811. .outerHeight();
  8812. minContentHeight = Math.max( 0, options.minHeight - nonContentHeight );
  8813. maxContentHeight = typeof options.maxHeight === "number" ?
  8814. Math.max( 0, options.maxHeight - nonContentHeight ) :
  8815. "none";
  8816. if ( options.height === "auto" ) {
  8817. this.element.css({
  8818. minHeight: minContentHeight,
  8819. maxHeight: maxContentHeight,
  8820. height: "auto"
  8821. });
  8822. } else {
  8823. this.element.height( Math.max( 0, options.height - nonContentHeight ) );
  8824. }
  8825. if (this.uiDialog.is(":data(ui-resizable)") ) {
  8826. this.uiDialog.resizable( "option", "minHeight", this._minHeight() );
  8827. }
  8828. },
  8829. _blockFrames: function() {
  8830. this.iframeBlocks = this.document.find( "iframe" ).map(function() {
  8831. var iframe = $( this );
  8832. return $( "<div>" )
  8833. .css({
  8834. position: "absolute",
  8835. width: iframe.outerWidth(),
  8836. height: iframe.outerHeight()
  8837. })
  8838. .appendTo( iframe.parent() )
  8839. .offset( iframe.offset() )[0];
  8840. });
  8841. },
  8842. _unblockFrames: function() {
  8843. if ( this.iframeBlocks ) {
  8844. this.iframeBlocks.remove();
  8845. delete this.iframeBlocks;
  8846. }
  8847. },
  8848. _allowInteraction: function( event ) {
  8849. if ( $( event.target ).closest(".ui-dialog").length ) {
  8850. return true;
  8851. }
  8852. // TODO: Remove hack when datepicker implements
  8853. // the .ui-front logic (#8989)
  8854. return !!$( event.target ).closest(".ui-datepicker").length;
  8855. },
  8856. _createOverlay: function() {
  8857. if ( !this.options.modal ) {
  8858. return;
  8859. }
  8860. var that = this,
  8861. widgetFullName = this.widgetFullName;
  8862. if ( !$.ui.dialog.overlayInstances ) {
  8863. // Prevent use of anchors and inputs.
  8864. // We use a delay in case the overlay is created from an
  8865. // event that we're going to be cancelling. (#2804)
  8866. this._delay(function() {
  8867. // Handle .dialog().dialog("close") (#4065)
  8868. if ( $.ui.dialog.overlayInstances ) {
  8869. this.document.bind( "focusin.dialog", function( event ) {
  8870. if ( !that._allowInteraction( event ) ) {
  8871. event.preventDefault();
  8872. $(".ui-dialog:visible:last .ui-dialog-content")
  8873. .data( widgetFullName )._focusTabbable();
  8874. }
  8875. });
  8876. }
  8877. });
  8878. }
  8879. this.overlay = $("<div>")
  8880. .addClass("ui-widget-overlay ui-front")
  8881. .appendTo( this._appendTo() );
  8882. this._on( this.overlay, {
  8883. mousedown: "_keepFocus"
  8884. });
  8885. $.ui.dialog.overlayInstances++;
  8886. },
  8887. _destroyOverlay: function() {
  8888. if ( !this.options.modal ) {
  8889. return;
  8890. }
  8891. if ( this.overlay ) {
  8892. $.ui.dialog.overlayInstances--;
  8893. if ( !$.ui.dialog.overlayInstances ) {
  8894. this.document.unbind( "focusin.dialog" );
  8895. }
  8896. this.overlay.remove();
  8897. this.overlay = null;
  8898. }
  8899. }
  8900. });
  8901. $.ui.dialog.overlayInstances = 0;
  8902. // DEPRECATED
  8903. if ( $.uiBackCompat !== false ) {
  8904. // position option with array notation
  8905. // just override with old implementation
  8906. $.widget( "ui.dialog", $.ui.dialog, {
  8907. _position: function() {
  8908. var position = this.options.position,
  8909. myAt = [],
  8910. offset = [ 0, 0 ],
  8911. isVisible;
  8912. if ( position ) {
  8913. if ( typeof position === "string" || (typeof position === "object" && "0" in position ) ) {
  8914. myAt = position.split ? position.split(" ") : [ position[0], position[1] ];
  8915. if ( myAt.length === 1 ) {
  8916. myAt[1] = myAt[0];
  8917. }
  8918. $.each( [ "left", "top" ], function( i, offsetPosition ) {
  8919. if ( +myAt[ i ] === myAt[ i ] ) {
  8920. offset[ i ] = myAt[ i ];
  8921. myAt[ i ] = offsetPosition;
  8922. }
  8923. });
  8924. position = {
  8925. my: myAt[0] + (offset[0] < 0 ? offset[0] : "+" + offset[0]) + " " +
  8926. myAt[1] + (offset[1] < 0 ? offset[1] : "+" + offset[1]),
  8927. at: myAt.join(" ")
  8928. };
  8929. }
  8930. position = $.extend( {}, $.ui.dialog.prototype.options.position, position );
  8931. } else {
  8932. position = $.ui.dialog.prototype.options.position;
  8933. }
  8934. // need to show the dialog to get the actual offset in the position plugin
  8935. isVisible = this.uiDialog.is(":visible");
  8936. if ( !isVisible ) {
  8937. this.uiDialog.show();
  8938. }
  8939. this.uiDialog.position( position );
  8940. if ( !isVisible ) {
  8941. this.uiDialog.hide();
  8942. }
  8943. }
  8944. });
  8945. }
  8946. }( jQuery ) );
  8947. (function( $, undefined ) {
  8948. var rvertical = /up|down|vertical/,
  8949. rpositivemotion = /up|left|vertical|horizontal/;
  8950. $.effects.effect.blind = function( o, done ) {
  8951. // Create element
  8952. var el = $( this ),
  8953. props = [ "position", "top", "bottom", "left", "right", "height", "width" ],
  8954. mode = $.effects.setMode( el, o.mode || "hide" ),
  8955. direction = o.direction || "up",
  8956. vertical = rvertical.test( direction ),
  8957. ref = vertical ? "height" : "width",
  8958. ref2 = vertical ? "top" : "left",
  8959. motion = rpositivemotion.test( direction ),
  8960. animation = {},
  8961. show = mode === "show",
  8962. wrapper, distance, margin;
  8963. // if already wrapped, the wrapper's properties are my property. #6245
  8964. if ( el.parent().is( ".ui-effects-wrapper" ) ) {
  8965. $.effects.save( el.parent(), props );
  8966. } else {
  8967. $.effects.save( el, props );
  8968. }
  8969. el.show();
  8970. wrapper = $.effects.createWrapper( el ).css({
  8971. overflow: "hidden"
  8972. });
  8973. distance = wrapper[ ref ]();
  8974. margin = parseFloat( wrapper.css( ref2 ) ) || 0;
  8975. animation[ ref ] = show ? distance : 0;
  8976. if ( !motion ) {
  8977. el
  8978. .css( vertical ? "bottom" : "right", 0 )
  8979. .css( vertical ? "top" : "left", "auto" )
  8980. .css({ position: "absolute" });
  8981. animation[ ref2 ] = show ? margin : distance + margin;
  8982. }
  8983. // start at 0 if we are showing
  8984. if ( show ) {
  8985. wrapper.css( ref, 0 );
  8986. if ( ! motion ) {
  8987. wrapper.css( ref2, margin + distance );
  8988. }
  8989. }
  8990. // Animate
  8991. wrapper.animate( animation, {
  8992. duration: o.duration,
  8993. easing: o.easing,
  8994. queue: false,
  8995. complete: function() {
  8996. if ( mode === "hide" ) {
  8997. el.hide();
  8998. }
  8999. $.effects.restore( el, props );
  9000. $.effects.removeWrapper( el );
  9001. done();
  9002. }
  9003. });
  9004. };
  9005. })(jQuery);
  9006. (function( $, undefined ) {
  9007. $.effects.effect.bounce = function( o, done ) {
  9008. var el = $( this ),
  9009. props = [ "position", "top", "bottom", "left", "right", "height", "width" ],
  9010. // defaults:
  9011. mode = $.effects.setMode( el, o.mode || "effect" ),
  9012. hide = mode === "hide",
  9013. show = mode === "show",
  9014. direction = o.direction || "up",
  9015. distance = o.distance,
  9016. times = o.times || 5,
  9017. // number of internal animations
  9018. anims = times * 2 + ( show || hide ? 1 : 0 ),
  9019. speed = o.duration / anims,
  9020. easing = o.easing,
  9021. // utility:
  9022. ref = ( direction === "up" || direction === "down" ) ? "top" : "left",
  9023. motion = ( direction === "up" || direction === "left" ),
  9024. i,
  9025. upAnim,
  9026. downAnim,
  9027. // we will need to re-assemble the queue to stack our animations in place
  9028. queue = el.queue(),
  9029. queuelen = queue.length;
  9030. // Avoid touching opacity to prevent clearType and PNG issues in IE
  9031. if ( show || hide ) {
  9032. props.push( "opacity" );
  9033. }
  9034. $.effects.save( el, props );
  9035. el.show();
  9036. $.effects.createWrapper( el ); // Create Wrapper
  9037. // default distance for the BIGGEST bounce is the outer Distance / 3
  9038. if ( !distance ) {
  9039. distance = el[ ref === "top" ? "outerHeight" : "outerWidth" ]() / 3;
  9040. }
  9041. if ( show ) {
  9042. downAnim = { opacity: 1 };
  9043. downAnim[ ref ] = 0;
  9044. // if we are showing, force opacity 0 and set the initial position
  9045. // then do the "first" animation
  9046. el.css( "opacity", 0 )
  9047. .css( ref, motion ? -distance * 2 : distance * 2 )
  9048. .animate( downAnim, speed, easing );
  9049. }
  9050. // start at the smallest distance if we are hiding
  9051. if ( hide ) {
  9052. distance = distance / Math.pow( 2, times - 1 );
  9053. }
  9054. downAnim = {};
  9055. downAnim[ ref ] = 0;
  9056. // Bounces up/down/left/right then back to 0 -- times * 2 animations happen here
  9057. for ( i = 0; i < times; i++ ) {
  9058. upAnim = {};
  9059. upAnim[ ref ] = ( motion ? "-=" : "+=" ) + distance;
  9060. el.animate( upAnim, speed, easing )
  9061. .animate( downAnim, speed, easing );
  9062. distance = hide ? distance * 2 : distance / 2;
  9063. }
  9064. // Last Bounce when Hiding
  9065. if ( hide ) {
  9066. upAnim = { opacity: 0 };
  9067. upAnim[ ref ] = ( motion ? "-=" : "+=" ) + distance;
  9068. el.animate( upAnim, speed, easing );
  9069. }
  9070. el.queue(function() {
  9071. if ( hide ) {
  9072. el.hide();
  9073. }
  9074. $.effects.restore( el, props );
  9075. $.effects.removeWrapper( el );
  9076. done();
  9077. });
  9078. // inject all the animations we just queued to be first in line (after "inprogress")
  9079. if ( queuelen > 1) {
  9080. queue.splice.apply( queue,
  9081. [ 1, 0 ].concat( queue.splice( queuelen, anims + 1 ) ) );
  9082. }
  9083. el.dequeue();
  9084. };
  9085. })(jQuery);
  9086. (function( $, undefined ) {
  9087. $.effects.effect.clip = function( o, done ) {
  9088. // Create element
  9089. var el = $( this ),
  9090. props = [ "position", "top", "bottom", "left", "right", "height", "width" ],
  9091. mode = $.effects.setMode( el, o.mode || "hide" ),
  9092. show = mode === "show",
  9093. direction = o.direction || "vertical",
  9094. vert = direction === "vertical",
  9095. size = vert ? "height" : "width",
  9096. position = vert ? "top" : "left",
  9097. animation = {},
  9098. wrapper, animate, distance;
  9099. // Save & Show
  9100. $.effects.save( el, props );
  9101. el.show();
  9102. // Create Wrapper
  9103. wrapper = $.effects.createWrapper( el ).css({
  9104. overflow: "hidden"
  9105. });
  9106. animate = ( el[0].tagName === "IMG" ) ? wrapper : el;
  9107. distance = animate[ size ]();
  9108. // Shift
  9109. if ( show ) {
  9110. animate.css( size, 0 );
  9111. animate.css( position, distance / 2 );
  9112. }
  9113. // Create Animation Object:
  9114. animation[ size ] = show ? distance : 0;
  9115. animation[ position ] = show ? 0 : distance / 2;
  9116. // Animate
  9117. animate.animate( animation, {
  9118. queue: false,
  9119. duration: o.duration,
  9120. easing: o.easing,
  9121. complete: function() {
  9122. if ( !show ) {
  9123. el.hide();
  9124. }
  9125. $.effects.restore( el, props );
  9126. $.effects.removeWrapper( el );
  9127. done();
  9128. }
  9129. });
  9130. };
  9131. })(jQuery);
  9132. (function( $, undefined ) {
  9133. $.effects.effect.drop = function( o, done ) {
  9134. var el = $( this ),
  9135. props = [ "position", "top", "bottom", "left", "right", "opacity", "height", "width" ],
  9136. mode = $.effects.setMode( el, o.mode || "hide" ),
  9137. show = mode === "show",
  9138. direction = o.direction || "left",
  9139. ref = ( direction === "up" || direction === "down" ) ? "top" : "left",
  9140. motion = ( direction === "up" || direction === "left" ) ? "pos" : "neg",
  9141. animation = {
  9142. opacity: show ? 1 : 0
  9143. },
  9144. distance;
  9145. // Adjust
  9146. $.effects.save( el, props );
  9147. el.show();
  9148. $.effects.createWrapper( el );
  9149. distance = o.distance || el[ ref === "top" ? "outerHeight": "outerWidth" ]( true ) / 2;
  9150. if ( show ) {
  9151. el
  9152. .css( "opacity", 0 )
  9153. .css( ref, motion === "pos" ? -distance : distance );
  9154. }
  9155. // Animation
  9156. animation[ ref ] = ( show ?
  9157. ( motion === "pos" ? "+=" : "-=" ) :
  9158. ( motion === "pos" ? "-=" : "+=" ) ) +
  9159. distance;
  9160. // Animate
  9161. el.animate( animation, {
  9162. queue: false,
  9163. duration: o.duration,
  9164. easing: o.easing,
  9165. complete: function() {
  9166. if ( mode === "hide" ) {
  9167. el.hide();
  9168. }
  9169. $.effects.restore( el, props );
  9170. $.effects.removeWrapper( el );
  9171. done();
  9172. }
  9173. });
  9174. };
  9175. })(jQuery);
  9176. (function( $, undefined ) {
  9177. $.effects.effect.explode = function( o, done ) {
  9178. var rows = o.pieces ? Math.round( Math.sqrt( o.pieces ) ) : 3,
  9179. cells = rows,
  9180. el = $( this ),
  9181. mode = $.effects.setMode( el, o.mode || "hide" ),
  9182. show = mode === "show",
  9183. // show and then visibility:hidden the element before calculating offset
  9184. offset = el.show().css( "visibility", "hidden" ).offset(),
  9185. // width and height of a piece
  9186. width = Math.ceil( el.outerWidth() / cells ),
  9187. height = Math.ceil( el.outerHeight() / rows ),
  9188. pieces = [],
  9189. // loop
  9190. i, j, left, top, mx, my;
  9191. // children animate complete:
  9192. function childComplete() {
  9193. pieces.push( this );
  9194. if ( pieces.length === rows * cells ) {
  9195. animComplete();
  9196. }
  9197. }
  9198. // clone the element for each row and cell.
  9199. for( i = 0; i < rows ; i++ ) { // ===>
  9200. top = offset.top + i * height;
  9201. my = i - ( rows - 1 ) / 2 ;
  9202. for( j = 0; j < cells ; j++ ) { // |||
  9203. left = offset.left + j * width;
  9204. mx = j - ( cells - 1 ) / 2 ;
  9205. // Create a clone of the now hidden main element that will be absolute positioned
  9206. // within a wrapper div off the -left and -top equal to size of our pieces
  9207. el
  9208. .clone()
  9209. .appendTo( "body" )
  9210. .wrap( "<div></div>" )
  9211. .css({
  9212. position: "absolute",
  9213. visibility: "visible",
  9214. left: -j * width,
  9215. top: -i * height
  9216. })
  9217. // select the wrapper - make it overflow: hidden and absolute positioned based on
  9218. // where the original was located +left and +top equal to the size of pieces
  9219. .parent()
  9220. .addClass( "ui-effects-explode" )
  9221. .css({
  9222. position: "absolute",
  9223. overflow: "hidden",
  9224. width: width,
  9225. height: height,
  9226. left: left + ( show ? mx * width : 0 ),
  9227. top: top + ( show ? my * height : 0 ),
  9228. opacity: show ? 0 : 1
  9229. }).animate({
  9230. left: left + ( show ? 0 : mx * width ),
  9231. top: top + ( show ? 0 : my * height ),
  9232. opacity: show ? 1 : 0
  9233. }, o.duration || 500, o.easing, childComplete );
  9234. }
  9235. }
  9236. function animComplete() {
  9237. el.css({
  9238. visibility: "visible"
  9239. });
  9240. $( pieces ).remove();
  9241. if ( !show ) {
  9242. el.hide();
  9243. }
  9244. done();
  9245. }
  9246. };
  9247. })(jQuery);
  9248. (function( $, undefined ) {
  9249. $.effects.effect.fade = function( o, done ) {
  9250. var el = $( this ),
  9251. mode = $.effects.setMode( el, o.mode || "toggle" );
  9252. el.animate({
  9253. opacity: mode
  9254. }, {
  9255. queue: false,
  9256. duration: o.duration,
  9257. easing: o.easing,
  9258. complete: done
  9259. });
  9260. };
  9261. })( jQuery );
  9262. (function( $, undefined ) {
  9263. $.effects.effect.fold = function( o, done ) {
  9264. // Create element
  9265. var el = $( this ),
  9266. props = [ "position", "top", "bottom", "left", "right", "height", "width" ],
  9267. mode = $.effects.setMode( el, o.mode || "hide" ),
  9268. show = mode === "show",
  9269. hide = mode === "hide",
  9270. size = o.size || 15,
  9271. percent = /([0-9]+)%/.exec( size ),
  9272. horizFirst = !!o.horizFirst,
  9273. widthFirst = show !== horizFirst,
  9274. ref = widthFirst ? [ "width", "height" ] : [ "height", "width" ],
  9275. duration = o.duration / 2,
  9276. wrapper, distance,
  9277. animation1 = {},
  9278. animation2 = {};
  9279. $.effects.save( el, props );
  9280. el.show();
  9281. // Create Wrapper
  9282. wrapper = $.effects.createWrapper( el ).css({
  9283. overflow: "hidden"
  9284. });
  9285. distance = widthFirst ?
  9286. [ wrapper.width(), wrapper.height() ] :
  9287. [ wrapper.height(), wrapper.width() ];
  9288. if ( percent ) {
  9289. size = parseInt( percent[ 1 ], 10 ) / 100 * distance[ hide ? 0 : 1 ];
  9290. }
  9291. if ( show ) {
  9292. wrapper.css( horizFirst ? {
  9293. height: 0,
  9294. width: size
  9295. } : {
  9296. height: size,
  9297. width: 0
  9298. });
  9299. }
  9300. // Animation
  9301. animation1[ ref[ 0 ] ] = show ? distance[ 0 ] : size;
  9302. animation2[ ref[ 1 ] ] = show ? distance[ 1 ] : 0;
  9303. // Animate
  9304. wrapper
  9305. .animate( animation1, duration, o.easing )
  9306. .animate( animation2, duration, o.easing, function() {
  9307. if ( hide ) {
  9308. el.hide();
  9309. }
  9310. $.effects.restore( el, props );
  9311. $.effects.removeWrapper( el );
  9312. done();
  9313. });
  9314. };
  9315. })(jQuery);
  9316. (function( $, undefined ) {
  9317. $.effects.effect.highlight = function( o, done ) {
  9318. var elem = $( this ),
  9319. props = [ "backgroundImage", "backgroundColor", "opacity" ],
  9320. mode = $.effects.setMode( elem, o.mode || "show" ),
  9321. animation = {
  9322. backgroundColor: elem.css( "backgroundColor" )
  9323. };
  9324. if (mode === "hide") {
  9325. animation.opacity = 0;
  9326. }
  9327. $.effects.save( elem, props );
  9328. elem
  9329. .show()
  9330. .css({
  9331. backgroundImage: "none",
  9332. backgroundColor: o.color || "#ffff99"
  9333. })
  9334. .animate( animation, {
  9335. queue: false,
  9336. duration: o.duration,
  9337. easing: o.easing,
  9338. complete: function() {
  9339. if ( mode === "hide" ) {
  9340. elem.hide();
  9341. }
  9342. $.effects.restore( elem, props );
  9343. done();
  9344. }
  9345. });
  9346. };
  9347. })(jQuery);
  9348. (function( $, undefined ) {
  9349. $.effects.effect.pulsate = function( o, done ) {
  9350. var elem = $( this ),
  9351. mode = $.effects.setMode( elem, o.mode || "show" ),
  9352. show = mode === "show",
  9353. hide = mode === "hide",
  9354. showhide = ( show || mode === "hide" ),
  9355. // showing or hiding leaves of the "last" animation
  9356. anims = ( ( o.times || 5 ) * 2 ) + ( showhide ? 1 : 0 ),
  9357. duration = o.duration / anims,
  9358. animateTo = 0,
  9359. queue = elem.queue(),
  9360. queuelen = queue.length,
  9361. i;
  9362. if ( show || !elem.is(":visible")) {
  9363. elem.css( "opacity", 0 ).show();
  9364. animateTo = 1;
  9365. }
  9366. // anims - 1 opacity "toggles"
  9367. for ( i = 1; i < anims; i++ ) {
  9368. elem.animate({
  9369. opacity: animateTo
  9370. }, duration, o.easing );
  9371. animateTo = 1 - animateTo;
  9372. }
  9373. elem.animate({
  9374. opacity: animateTo
  9375. }, duration, o.easing);
  9376. elem.queue(function() {
  9377. if ( hide ) {
  9378. elem.hide();
  9379. }
  9380. done();
  9381. });
  9382. // We just queued up "anims" animations, we need to put them next in the queue
  9383. if ( queuelen > 1 ) {
  9384. queue.splice.apply( queue,
  9385. [ 1, 0 ].concat( queue.splice( queuelen, anims + 1 ) ) );
  9386. }
  9387. elem.dequeue();
  9388. };
  9389. })(jQuery);
  9390. (function( $, undefined ) {
  9391. $.effects.effect.puff = function( o, done ) {
  9392. var elem = $( this ),
  9393. mode = $.effects.setMode( elem, o.mode || "hide" ),
  9394. hide = mode === "hide",
  9395. percent = parseInt( o.percent, 10 ) || 150,
  9396. factor = percent / 100,
  9397. original = {
  9398. height: elem.height(),
  9399. width: elem.width(),
  9400. outerHeight: elem.outerHeight(),
  9401. outerWidth: elem.outerWidth()
  9402. };
  9403. $.extend( o, {
  9404. effect: "scale",
  9405. queue: false,
  9406. fade: true,
  9407. mode: mode,
  9408. complete: done,
  9409. percent: hide ? percent : 100,
  9410. from: hide ?
  9411. original :
  9412. {
  9413. height: original.height * factor,
  9414. width: original.width * factor,
  9415. outerHeight: original.outerHeight * factor,
  9416. outerWidth: original.outerWidth * factor
  9417. }
  9418. });
  9419. elem.effect( o );
  9420. };
  9421. $.effects.effect.scale = function( o, done ) {
  9422. // Create element
  9423. var el = $( this ),
  9424. options = $.extend( true, {}, o ),
  9425. mode = $.effects.setMode( el, o.mode || "effect" ),
  9426. percent = parseInt( o.percent, 10 ) ||
  9427. ( parseInt( o.percent, 10 ) === 0 ? 0 : ( mode === "hide" ? 0 : 100 ) ),
  9428. direction = o.direction || "both",
  9429. origin = o.origin,
  9430. original = {
  9431. height: el.height(),
  9432. width: el.width(),
  9433. outerHeight: el.outerHeight(),
  9434. outerWidth: el.outerWidth()
  9435. },
  9436. factor = {
  9437. y: direction !== "horizontal" ? (percent / 100) : 1,
  9438. x: direction !== "vertical" ? (percent / 100) : 1
  9439. };
  9440. // We are going to pass this effect to the size effect:
  9441. options.effect = "size";
  9442. options.queue = false;
  9443. options.complete = done;
  9444. // Set default origin and restore for show/hide
  9445. if ( mode !== "effect" ) {
  9446. options.origin = origin || ["middle","center"];
  9447. options.restore = true;
  9448. }
  9449. options.from = o.from || ( mode === "show" ? {
  9450. height: 0,
  9451. width: 0,
  9452. outerHeight: 0,
  9453. outerWidth: 0
  9454. } : original );
  9455. options.to = {
  9456. height: original.height * factor.y,
  9457. width: original.width * factor.x,
  9458. outerHeight: original.outerHeight * factor.y,
  9459. outerWidth: original.outerWidth * factor.x
  9460. };
  9461. // Fade option to support puff
  9462. if ( options.fade ) {
  9463. if ( mode === "show" ) {
  9464. options.from.opacity = 0;
  9465. options.to.opacity = 1;
  9466. }
  9467. if ( mode === "hide" ) {
  9468. options.from.opacity = 1;
  9469. options.to.opacity = 0;
  9470. }
  9471. }
  9472. // Animate
  9473. el.effect( options );
  9474. };
  9475. $.effects.effect.size = function( o, done ) {
  9476. // Create element
  9477. var original, baseline, factor,
  9478. el = $( this ),
  9479. props0 = [ "position", "top", "bottom", "left", "right", "width", "height", "overflow", "opacity" ],
  9480. // Always restore
  9481. props1 = [ "position", "top", "bottom", "left", "right", "overflow", "opacity" ],
  9482. // Copy for children
  9483. props2 = [ "width", "height", "overflow" ],
  9484. cProps = [ "fontSize" ],
  9485. vProps = [ "borderTopWidth", "borderBottomWidth", "paddingTop", "paddingBottom" ],
  9486. hProps = [ "borderLeftWidth", "borderRightWidth", "paddingLeft", "paddingRight" ],
  9487. // Set options
  9488. mode = $.effects.setMode( el, o.mode || "effect" ),
  9489. restore = o.restore || mode !== "effect",
  9490. scale = o.scale || "both",
  9491. origin = o.origin || [ "middle", "center" ],
  9492. position = el.css( "position" ),
  9493. props = restore ? props0 : props1,
  9494. zero = {
  9495. height: 0,
  9496. width: 0,
  9497. outerHeight: 0,
  9498. outerWidth: 0
  9499. };
  9500. if ( mode === "show" ) {
  9501. el.show();
  9502. }
  9503. original = {
  9504. height: el.height(),
  9505. width: el.width(),
  9506. outerHeight: el.outerHeight(),
  9507. outerWidth: el.outerWidth()
  9508. };
  9509. if ( o.mode === "toggle" && mode === "show" ) {
  9510. el.from = o.to || zero;
  9511. el.to = o.from || original;
  9512. } else {
  9513. el.from = o.from || ( mode === "show" ? zero : original );
  9514. el.to = o.to || ( mode === "hide" ? zero : original );
  9515. }
  9516. // Set scaling factor
  9517. factor = {
  9518. from: {
  9519. y: el.from.height / original.height,
  9520. x: el.from.width / original.width
  9521. },
  9522. to: {
  9523. y: el.to.height / original.height,
  9524. x: el.to.width / original.width
  9525. }
  9526. };
  9527. // Scale the css box
  9528. if ( scale === "box" || scale === "both" ) {
  9529. // Vertical props scaling
  9530. if ( factor.from.y !== factor.to.y ) {
  9531. props = props.concat( vProps );
  9532. el.from = $.effects.setTransition( el, vProps, factor.from.y, el.from );
  9533. el.to = $.effects.setTransition( el, vProps, factor.to.y, el.to );
  9534. }
  9535. // Horizontal props scaling
  9536. if ( factor.from.x !== factor.to.x ) {
  9537. props = props.concat( hProps );
  9538. el.from = $.effects.setTransition( el, hProps, factor.from.x, el.from );
  9539. el.to = $.effects.setTransition( el, hProps, factor.to.x, el.to );
  9540. }
  9541. }
  9542. // Scale the content
  9543. if ( scale === "content" || scale === "both" ) {
  9544. // Vertical props scaling
  9545. if ( factor.from.y !== factor.to.y ) {
  9546. props = props.concat( cProps ).concat( props2 );
  9547. el.from = $.effects.setTransition( el, cProps, factor.from.y, el.from );
  9548. el.to = $.effects.setTransition( el, cProps, factor.to.y, el.to );
  9549. }
  9550. }
  9551. $.effects.save( el, props );
  9552. el.show();
  9553. $.effects.createWrapper( el );
  9554. el.css( "overflow", "hidden" ).css( el.from );
  9555. // Adjust
  9556. if (origin) { // Calculate baseline shifts
  9557. baseline = $.effects.getBaseline( origin, original );
  9558. el.from.top = ( original.outerHeight - el.outerHeight() ) * baseline.y;
  9559. el.from.left = ( original.outerWidth - el.outerWidth() ) * baseline.x;
  9560. el.to.top = ( original.outerHeight - el.to.outerHeight ) * baseline.y;
  9561. el.to.left = ( original.outerWidth - el.to.outerWidth ) * baseline.x;
  9562. }
  9563. el.css( el.from ); // set top & left
  9564. // Animate
  9565. if ( scale === "content" || scale === "both" ) { // Scale the children
  9566. // Add margins/font-size
  9567. vProps = vProps.concat([ "marginTop", "marginBottom" ]).concat(cProps);
  9568. hProps = hProps.concat([ "marginLeft", "marginRight" ]);
  9569. props2 = props0.concat(vProps).concat(hProps);
  9570. el.find( "*[width]" ).each( function(){
  9571. var child = $( this ),
  9572. c_original = {
  9573. height: child.height(),
  9574. width: child.width(),
  9575. outerHeight: child.outerHeight(),
  9576. outerWidth: child.outerWidth()
  9577. };
  9578. if (restore) {
  9579. $.effects.save(child, props2);
  9580. }
  9581. child.from = {
  9582. height: c_original.height * factor.from.y,
  9583. width: c_original.width * factor.from.x,
  9584. outerHeight: c_original.outerHeight * factor.from.y,
  9585. outerWidth: c_original.outerWidth * factor.from.x
  9586. };
  9587. child.to = {
  9588. height: c_original.height * factor.to.y,
  9589. width: c_original.width * factor.to.x,
  9590. outerHeight: c_original.height * factor.to.y,
  9591. outerWidth: c_original.width * factor.to.x
  9592. };
  9593. // Vertical props scaling
  9594. if ( factor.from.y !== factor.to.y ) {
  9595. child.from = $.effects.setTransition( child, vProps, factor.from.y, child.from );
  9596. child.to = $.effects.setTransition( child, vProps, factor.to.y, child.to );
  9597. }
  9598. // Horizontal props scaling
  9599. if ( factor.from.x !== factor.to.x ) {
  9600. child.from = $.effects.setTransition( child, hProps, factor.from.x, child.from );
  9601. child.to = $.effects.setTransition( child, hProps, factor.to.x, child.to );
  9602. }
  9603. // Animate children
  9604. child.css( child.from );
  9605. child.animate( child.to, o.duration, o.easing, function() {
  9606. // Restore children
  9607. if ( restore ) {
  9608. $.effects.restore( child, props2 );
  9609. }
  9610. });
  9611. });
  9612. }
  9613. // Animate
  9614. el.animate( el.to, {
  9615. queue: false,
  9616. duration: o.duration,
  9617. easing: o.easing,
  9618. complete: function() {
  9619. if ( el.to.opacity === 0 ) {
  9620. el.css( "opacity", el.from.opacity );
  9621. }
  9622. if( mode === "hide" ) {
  9623. el.hide();
  9624. }
  9625. $.effects.restore( el, props );
  9626. if ( !restore ) {
  9627. // we need to calculate our new positioning based on the scaling
  9628. if ( position === "static" ) {
  9629. el.css({
  9630. position: "relative",
  9631. top: el.to.top,
  9632. left: el.to.left
  9633. });
  9634. } else {
  9635. $.each([ "top", "left" ], function( idx, pos ) {
  9636. el.css( pos, function( _, str ) {
  9637. var val = parseInt( str, 10 ),
  9638. toRef = idx ? el.to.left : el.to.top;
  9639. // if original was "auto", recalculate the new value from wrapper
  9640. if ( str === "auto" ) {
  9641. return toRef + "px";
  9642. }
  9643. return val + toRef + "px";
  9644. });
  9645. });
  9646. }
  9647. }
  9648. $.effects.removeWrapper( el );
  9649. done();
  9650. }
  9651. });
  9652. };
  9653. })(jQuery);
  9654. (function( $, undefined ) {
  9655. $.effects.effect.shake = function( o, done ) {
  9656. var el = $( this ),
  9657. props = [ "position", "top", "bottom", "left", "right", "height", "width" ],
  9658. mode = $.effects.setMode( el, o.mode || "effect" ),
  9659. direction = o.direction || "left",
  9660. distance = o.distance || 20,
  9661. times = o.times || 3,
  9662. anims = times * 2 + 1,
  9663. speed = Math.round(o.duration/anims),
  9664. ref = (direction === "up" || direction === "down") ? "top" : "left",
  9665. positiveMotion = (direction === "up" || direction === "left"),
  9666. animation = {},
  9667. animation1 = {},
  9668. animation2 = {},
  9669. i,
  9670. // we will need to re-assemble the queue to stack our animations in place
  9671. queue = el.queue(),
  9672. queuelen = queue.length;
  9673. $.effects.save( el, props );
  9674. el.show();
  9675. $.effects.createWrapper( el );
  9676. // Animation
  9677. animation[ ref ] = ( positiveMotion ? "-=" : "+=" ) + distance;
  9678. animation1[ ref ] = ( positiveMotion ? "+=" : "-=" ) + distance * 2;
  9679. animation2[ ref ] = ( positiveMotion ? "-=" : "+=" ) + distance * 2;
  9680. // Animate
  9681. el.animate( animation, speed, o.easing );
  9682. // Shakes
  9683. for ( i = 1; i < times; i++ ) {
  9684. el.animate( animation1, speed, o.easing ).animate( animation2, speed, o.easing );
  9685. }
  9686. el
  9687. .animate( animation1, speed, o.easing )
  9688. .animate( animation, speed / 2, o.easing )
  9689. .queue(function() {
  9690. if ( mode === "hide" ) {
  9691. el.hide();
  9692. }
  9693. $.effects.restore( el, props );
  9694. $.effects.removeWrapper( el );
  9695. done();
  9696. });
  9697. // inject all the animations we just queued to be first in line (after "inprogress")
  9698. if ( queuelen > 1) {
  9699. queue.splice.apply( queue,
  9700. [ 1, 0 ].concat( queue.splice( queuelen, anims + 1 ) ) );
  9701. }
  9702. el.dequeue();
  9703. };
  9704. })(jQuery);
  9705. (function( $, undefined ) {
  9706. $.effects.effect.slide = function( o, done ) {
  9707. // Create element
  9708. var el = $( this ),
  9709. props = [ "position", "top", "bottom", "left", "right", "width", "height" ],
  9710. mode = $.effects.setMode( el, o.mode || "show" ),
  9711. show = mode === "show",
  9712. direction = o.direction || "left",
  9713. ref = (direction === "up" || direction === "down") ? "top" : "left",
  9714. positiveMotion = (direction === "up" || direction === "left"),
  9715. distance,
  9716. animation = {};
  9717. // Adjust
  9718. $.effects.save( el, props );
  9719. el.show();
  9720. distance = o.distance || el[ ref === "top" ? "outerHeight" : "outerWidth" ]( true );
  9721. $.effects.createWrapper( el ).css({
  9722. overflow: "hidden"
  9723. });
  9724. if ( show ) {
  9725. el.css( ref, positiveMotion ? (isNaN(distance) ? "-" + distance : -distance) : distance );
  9726. }
  9727. // Animation
  9728. animation[ ref ] = ( show ?
  9729. ( positiveMotion ? "+=" : "-=") :
  9730. ( positiveMotion ? "-=" : "+=")) +
  9731. distance;
  9732. // Animate
  9733. el.animate( animation, {
  9734. queue: false,
  9735. duration: o.duration,
  9736. easing: o.easing,
  9737. complete: function() {
  9738. if ( mode === "hide" ) {
  9739. el.hide();
  9740. }
  9741. $.effects.restore( el, props );
  9742. $.effects.removeWrapper( el );
  9743. done();
  9744. }
  9745. });
  9746. };
  9747. })(jQuery);
  9748. (function( $, undefined ) {
  9749. $.effects.effect.transfer = function( o, done ) {
  9750. var elem = $( this ),
  9751. target = $( o.to ),
  9752. targetFixed = target.css( "position" ) === "fixed",
  9753. body = $("body"),
  9754. fixTop = targetFixed ? body.scrollTop() : 0,
  9755. fixLeft = targetFixed ? body.scrollLeft() : 0,
  9756. endPosition = target.offset(),
  9757. animation = {
  9758. top: endPosition.top - fixTop ,
  9759. left: endPosition.left - fixLeft ,
  9760. height: target.innerHeight(),
  9761. width: target.innerWidth()
  9762. },
  9763. startPosition = elem.offset(),
  9764. transfer = $( "<div class='ui-effects-transfer'></div>" )
  9765. .appendTo( document.body )
  9766. .addClass( o.className )
  9767. .css({
  9768. top: startPosition.top - fixTop ,
  9769. left: startPosition.left - fixLeft ,
  9770. height: elem.innerHeight(),
  9771. width: elem.innerWidth(),
  9772. position: targetFixed ? "fixed" : "absolute"
  9773. })
  9774. .animate( animation, o.duration, o.easing, function() {
  9775. transfer.remove();
  9776. done();
  9777. });
  9778. };
  9779. })(jQuery);
  9780. (function( $, undefined ) {
  9781. $.widget( "ui.menu", {
  9782. version: "1.10.3",
  9783. defaultElement: "<ul>",
  9784. delay: 300,
  9785. options: {
  9786. icons: {
  9787. submenu: "ui-icon-carat-1-e"
  9788. },
  9789. menus: "ul",
  9790. position: {
  9791. my: "left top",
  9792. at: "right top"
  9793. },
  9794. role: "menu",
  9795. // callbacks
  9796. blur: null,
  9797. focus: null,
  9798. select: null
  9799. },
  9800. _create: function() {
  9801. this.activeMenu = this.element;
  9802. // flag used to prevent firing of the click handler
  9803. // as the event bubbles up through nested menus
  9804. this.mouseHandled = false;
  9805. this.element
  9806. .uniqueId()
  9807. .addClass( "ui-menu ui-widget ui-widget-content ui-corner-all" )
  9808. .toggleClass( "ui-menu-icons", !!this.element.find( ".ui-icon" ).length )
  9809. .attr({
  9810. role: this.options.role,
  9811. tabIndex: 0
  9812. })
  9813. // need to catch all clicks on disabled menu
  9814. // not possible through _on
  9815. .bind( "click" + this.eventNamespace, $.proxy(function( event ) {
  9816. if ( this.options.disabled ) {
  9817. event.preventDefault();
  9818. }
  9819. }, this ));
  9820. if ( this.options.disabled ) {
  9821. this.element
  9822. .addClass( "ui-state-disabled" )
  9823. .attr( "aria-disabled", "true" );
  9824. }
  9825. this._on({
  9826. // Prevent focus from sticking to links inside menu after clicking
  9827. // them (focus should always stay on UL during navigation).
  9828. "mousedown .ui-menu-item > a": function( event ) {
  9829. event.preventDefault();
  9830. },
  9831. "click .ui-state-disabled > a": function( event ) {
  9832. event.preventDefault();
  9833. },
  9834. "click .ui-menu-item:has(a)": function( event ) {
  9835. var target = $( event.target ).closest( ".ui-menu-item" );
  9836. if ( !this.mouseHandled && target.not( ".ui-state-disabled" ).length ) {
  9837. this.mouseHandled = true;
  9838. this.select( event );
  9839. // Open submenu on click
  9840. if ( target.has( ".ui-menu" ).length ) {
  9841. this.expand( event );
  9842. } else if ( !this.element.is( ":focus" ) ) {
  9843. // Redirect focus to the menu
  9844. this.element.trigger( "focus", [ true ] );
  9845. // If the active item is on the top level, let it stay active.
  9846. // Otherwise, blur the active item since it is no longer visible.
  9847. if ( this.active && this.active.parents( ".ui-menu" ).length === 1 ) {
  9848. clearTimeout( this.timer );
  9849. }
  9850. }
  9851. }
  9852. },
  9853. "mouseenter .ui-menu-item": function( event ) {
  9854. var target = $( event.currentTarget );
  9855. // Remove ui-state-active class from siblings of the newly focused menu item
  9856. // to avoid a jump caused by adjacent elements both having a class with a border
  9857. target.siblings().children( ".ui-state-active" ).removeClass( "ui-state-active" );
  9858. this.focus( event, target );
  9859. },
  9860. mouseleave: "collapseAll",
  9861. "mouseleave .ui-menu": "collapseAll",
  9862. focus: function( event, keepActiveItem ) {
  9863. // If there's already an active item, keep it active
  9864. // If not, activate the first item
  9865. var item = this.active || this.element.children( ".ui-menu-item" ).eq( 0 );
  9866. if ( !keepActiveItem ) {
  9867. this.focus( event, item );
  9868. }
  9869. },
  9870. blur: function( event ) {
  9871. this._delay(function() {
  9872. if ( !$.contains( this.element[0], this.document[0].activeElement ) ) {
  9873. this.collapseAll( event );
  9874. }
  9875. });
  9876. },
  9877. keydown: "_keydown"
  9878. });
  9879. this.refresh();
  9880. // Clicks outside of a menu collapse any open menus
  9881. this._on( this.document, {
  9882. click: function( event ) {
  9883. if ( !$( event.target ).closest( ".ui-menu" ).length ) {
  9884. this.collapseAll( event );
  9885. }
  9886. // Reset the mouseHandled flag
  9887. this.mouseHandled = false;
  9888. }
  9889. });
  9890. },
  9891. _destroy: function() {
  9892. // Destroy (sub)menus
  9893. this.element
  9894. .removeAttr( "aria-activedescendant" )
  9895. .find( ".ui-menu" ).addBack()
  9896. .removeClass( "ui-menu ui-widget ui-widget-content ui-corner-all ui-menu-icons" )
  9897. .removeAttr( "role" )
  9898. .removeAttr( "tabIndex" )
  9899. .removeAttr( "aria-labelledby" )
  9900. .removeAttr( "aria-expanded" )
  9901. .removeAttr( "aria-hidden" )
  9902. .removeAttr( "aria-disabled" )
  9903. .removeUniqueId()
  9904. .show();
  9905. // Destroy menu items
  9906. this.element.find( ".ui-menu-item" )
  9907. .removeClass( "ui-menu-item" )
  9908. .removeAttr( "role" )
  9909. .removeAttr( "aria-disabled" )
  9910. .children( "a" )
  9911. .removeUniqueId()
  9912. .removeClass( "ui-corner-all ui-state-hover" )
  9913. .removeAttr( "tabIndex" )
  9914. .removeAttr( "role" )
  9915. .removeAttr( "aria-haspopup" )
  9916. .children().each( function() {
  9917. var elem = $( this );
  9918. if ( elem.data( "ui-menu-submenu-carat" ) ) {
  9919. elem.remove();
  9920. }
  9921. });
  9922. // Destroy menu dividers
  9923. this.element.find( ".ui-menu-divider" ).removeClass( "ui-menu-divider ui-widget-content" );
  9924. },
  9925. _keydown: function( event ) {
  9926. /*jshint maxcomplexity:20*/
  9927. var match, prev, character, skip, regex,
  9928. preventDefault = true;
  9929. function escape( value ) {
  9930. return value.replace( /[\-\[\]{}()*+?.,\\\^$|#\s]/g, "\\$&" );
  9931. }
  9932. switch ( event.keyCode ) {
  9933. case $.ui.keyCode.PAGE_UP:
  9934. this.previousPage( event );
  9935. break;
  9936. case $.ui.keyCode.PAGE_DOWN:
  9937. this.nextPage( event );
  9938. break;
  9939. case $.ui.keyCode.HOME:
  9940. this._move( "first", "first", event );
  9941. break;
  9942. case $.ui.keyCode.END:
  9943. this._move( "last", "last", event );
  9944. break;
  9945. case $.ui.keyCode.UP:
  9946. this.previous( event );
  9947. break;
  9948. case $.ui.keyCode.DOWN:
  9949. this.next( event );
  9950. break;
  9951. case $.ui.keyCode.LEFT:
  9952. this.collapse( event );
  9953. break;
  9954. case $.ui.keyCode.RIGHT:
  9955. if ( this.active && !this.active.is( ".ui-state-disabled" ) ) {
  9956. this.expand( event );
  9957. }
  9958. break;
  9959. case $.ui.keyCode.ENTER:
  9960. case $.ui.keyCode.SPACE:
  9961. this._activate( event );
  9962. break;
  9963. case $.ui.keyCode.ESCAPE:
  9964. this.collapse( event );
  9965. break;
  9966. default:
  9967. preventDefault = false;
  9968. prev = this.previousFilter || "";
  9969. character = String.fromCharCode( event.keyCode );
  9970. skip = false;
  9971. clearTimeout( this.filterTimer );
  9972. if ( character === prev ) {
  9973. skip = true;
  9974. } else {
  9975. character = prev + character;
  9976. }
  9977. regex = new RegExp( "^" + escape( character ), "i" );
  9978. match = this.activeMenu.children( ".ui-menu-item" ).filter(function() {
  9979. return regex.test( $( this ).children( "a" ).text() );
  9980. });
  9981. match = skip && match.index( this.active.next() ) !== -1 ?
  9982. this.active.nextAll( ".ui-menu-item" ) :
  9983. match;
  9984. // If no matches on the current filter, reset to the last character pressed
  9985. // to move down the menu to the first item that starts with that character
  9986. if ( !match.length ) {
  9987. character = String.fromCharCode( event.keyCode );
  9988. regex = new RegExp( "^" + escape( character ), "i" );
  9989. match = this.activeMenu.children( ".ui-menu-item" ).filter(function() {
  9990. return regex.test( $( this ).children( "a" ).text() );
  9991. });
  9992. }
  9993. if ( match.length ) {
  9994. this.focus( event, match );
  9995. if ( match.length > 1 ) {
  9996. this.previousFilter = character;
  9997. this.filterTimer = this._delay(function() {
  9998. delete this.previousFilter;
  9999. }, 1000 );
  10000. } else {
  10001. delete this.previousFilter;
  10002. }
  10003. } else {
  10004. delete this.previousFilter;
  10005. }
  10006. }
  10007. if ( preventDefault ) {
  10008. event.preventDefault();
  10009. }
  10010. },
  10011. _activate: function( event ) {
  10012. if ( !this.active.is( ".ui-state-disabled" ) ) {
  10013. if ( this.active.children( "a[aria-haspopup='true']" ).length ) {
  10014. this.expand( event );
  10015. } else {
  10016. this.select( event );
  10017. }
  10018. }
  10019. },
  10020. refresh: function() {
  10021. var menus,
  10022. icon = this.options.icons.submenu,
  10023. submenus = this.element.find( this.options.menus );
  10024. // Initialize nested menus
  10025. submenus.filter( ":not(.ui-menu)" )
  10026. .addClass( "ui-menu ui-widget ui-widget-content ui-corner-all" )
  10027. .hide()
  10028. .attr({
  10029. role: this.options.role,
  10030. "aria-hidden": "true",
  10031. "aria-expanded": "false"
  10032. })
  10033. .each(function() {
  10034. var menu = $( this ),
  10035. item = menu.prev( "a" ),
  10036. submenuCarat = $( "<span>" )
  10037. .addClass( "ui-menu-icon ui-icon " + icon )
  10038. .data( "ui-menu-submenu-carat", true );
  10039. item
  10040. .attr( "aria-haspopup", "true" )
  10041. .prepend( submenuCarat );
  10042. menu.attr( "aria-labelledby", item.attr( "id" ) );
  10043. });
  10044. menus = submenus.add( this.element );
  10045. // Don't refresh list items that are already adapted
  10046. menus.children( ":not(.ui-menu-item):has(a)" )
  10047. .addClass( "ui-menu-item" )
  10048. .attr( "role", "presentation" )
  10049. .children( "a" )
  10050. .uniqueId()
  10051. .addClass( "ui-corner-all" )
  10052. .attr({
  10053. tabIndex: -1,
  10054. role: this._itemRole()
  10055. });
  10056. // Initialize unlinked menu-items containing spaces and/or dashes only as dividers
  10057. menus.children( ":not(.ui-menu-item)" ).each(function() {
  10058. var item = $( this );
  10059. // hyphen, em dash, en dash
  10060. if ( !/[^\-\u2014\u2013\s]/.test( item.text() ) ) {
  10061. item.addClass( "ui-widget-content ui-menu-divider" );
  10062. }
  10063. });
  10064. // Add aria-disabled attribute to any disabled menu item
  10065. menus.children( ".ui-state-disabled" ).attr( "aria-disabled", "true" );
  10066. // If the active item has been removed, blur the menu
  10067. if ( this.active && !$.contains( this.element[ 0 ], this.active[ 0 ] ) ) {
  10068. this.blur();
  10069. }
  10070. },
  10071. _itemRole: function() {
  10072. return {
  10073. menu: "menuitem",
  10074. listbox: "option"
  10075. }[ this.options.role ];
  10076. },
  10077. _setOption: function( key, value ) {
  10078. if ( key === "icons" ) {
  10079. this.element.find( ".ui-menu-icon" )
  10080. .removeClass( this.options.icons.submenu )
  10081. .addClass( value.submenu );
  10082. }
  10083. this._super( key, value );
  10084. },
  10085. focus: function( event, item ) {
  10086. var nested, focused;
  10087. this.blur( event, event && event.type === "focus" );
  10088. this._scrollIntoView( item );
  10089. this.active = item.first();
  10090. focused = this.active.children( "a" ).addClass( "ui-state-focus" );
  10091. // Only update aria-activedescendant if there's a role
  10092. // otherwise we assume focus is managed elsewhere
  10093. if ( this.options.role ) {
  10094. this.element.attr( "aria-activedescendant", focused.attr( "id" ) );
  10095. }
  10096. // Highlight active parent menu item, if any
  10097. this.active
  10098. .parent()
  10099. .closest( ".ui-menu-item" )
  10100. .children( "a:first" )
  10101. .addClass( "ui-state-active" );
  10102. if ( event && event.type === "keydown" ) {
  10103. this._close();
  10104. } else {
  10105. this.timer = this._delay(function() {
  10106. this._close();
  10107. }, this.delay );
  10108. }
  10109. nested = item.children( ".ui-menu" );
  10110. if ( nested.length && ( /^mouse/.test( event.type ) ) ) {
  10111. this._startOpening(nested);
  10112. }
  10113. this.activeMenu = item.parent();
  10114. this._trigger( "focus", event, { item: item } );
  10115. },
  10116. _scrollIntoView: function( item ) {
  10117. var borderTop, paddingTop, offset, scroll, elementHeight, itemHeight;
  10118. if ( this._hasScroll() ) {
  10119. borderTop = parseFloat( $.css( this.activeMenu[0], "borderTopWidth" ) ) || 0;
  10120. paddingTop = parseFloat( $.css( this.activeMenu[0], "paddingTop" ) ) || 0;
  10121. offset = item.offset().top - this.activeMenu.offset().top - borderTop - paddingTop;
  10122. scroll = this.activeMenu.scrollTop();
  10123. elementHeight = this.activeMenu.height();
  10124. itemHeight = item.height();
  10125. if ( offset < 0 ) {
  10126. this.activeMenu.scrollTop( scroll + offset );
  10127. } else if ( offset + itemHeight > elementHeight ) {
  10128. this.activeMenu.scrollTop( scroll + offset - elementHeight + itemHeight );
  10129. }
  10130. }
  10131. },
  10132. blur: function( event, fromFocus ) {
  10133. if ( !fromFocus ) {
  10134. clearTimeout( this.timer );
  10135. }
  10136. if ( !this.active ) {
  10137. return;
  10138. }
  10139. this.active.children( "a" ).removeClass( "ui-state-focus" );
  10140. this.active = null;
  10141. this._trigger( "blur", event, { item: this.active } );
  10142. },
  10143. _startOpening: function( submenu ) {
  10144. clearTimeout( this.timer );
  10145. // Don't open if already open fixes a Firefox bug that caused a .5 pixel
  10146. // shift in the submenu position when mousing over the carat icon
  10147. if ( submenu.attr( "aria-hidden" ) !== "true" ) {
  10148. return;
  10149. }
  10150. this.timer = this._delay(function() {
  10151. this._close();
  10152. this._open( submenu );
  10153. }, this.delay );
  10154. },
  10155. _open: function( submenu ) {
  10156. var position = $.extend({
  10157. of: this.active
  10158. }, this.options.position );
  10159. clearTimeout( this.timer );
  10160. this.element.find( ".ui-menu" ).not( submenu.parents( ".ui-menu" ) )
  10161. .hide()
  10162. .attr( "aria-hidden", "true" );
  10163. submenu
  10164. .show()
  10165. .removeAttr( "aria-hidden" )
  10166. .attr( "aria-expanded", "true" )
  10167. .position( position );
  10168. },
  10169. collapseAll: function( event, all ) {
  10170. clearTimeout( this.timer );
  10171. this.timer = this._delay(function() {
  10172. // If we were passed an event, look for the submenu that contains the event
  10173. var currentMenu = all ? this.element :
  10174. $( event && event.target ).closest( this.element.find( ".ui-menu" ) );
  10175. // If we found no valid submenu ancestor, use the main menu to close all sub menus anyway
  10176. if ( !currentMenu.length ) {
  10177. currentMenu = this.element;
  10178. }
  10179. this._close( currentMenu );
  10180. this.blur( event );
  10181. this.activeMenu = currentMenu;
  10182. }, this.delay );
  10183. },
  10184. // With no arguments, closes the currently active menu - if nothing is active
  10185. // it closes all menus. If passed an argument, it will search for menus BELOW
  10186. _close: function( startMenu ) {
  10187. if ( !startMenu ) {
  10188. startMenu = this.active ? this.active.parent() : this.element;
  10189. }
  10190. startMenu
  10191. .find( ".ui-menu" )
  10192. .hide()
  10193. .attr( "aria-hidden", "true" )
  10194. .attr( "aria-expanded", "false" )
  10195. .end()
  10196. .find( "a.ui-state-active" )
  10197. .removeClass( "ui-state-active" );
  10198. },
  10199. collapse: function( event ) {
  10200. var newItem = this.active &&
  10201. this.active.parent().closest( ".ui-menu-item", this.element );
  10202. if ( newItem && newItem.length ) {
  10203. this._close();
  10204. this.focus( event, newItem );
  10205. }
  10206. },
  10207. expand: function( event ) {
  10208. var newItem = this.active &&
  10209. this.active
  10210. .children( ".ui-menu " )
  10211. .children( ".ui-menu-item" )
  10212. .first();
  10213. if ( newItem && newItem.length ) {
  10214. this._open( newItem.parent() );
  10215. // Delay so Firefox will not hide activedescendant change in expanding submenu from AT
  10216. this._delay(function() {
  10217. this.focus( event, newItem );
  10218. });
  10219. }
  10220. },
  10221. next: function( event ) {
  10222. this._move( "next", "first", event );
  10223. },
  10224. previous: function( event ) {
  10225. this._move( "prev", "last", event );
  10226. },
  10227. isFirstItem: function() {
  10228. return this.active && !this.active.prevAll( ".ui-menu-item" ).length;
  10229. },
  10230. isLastItem: function() {
  10231. return this.active && !this.active.nextAll( ".ui-menu-item" ).length;
  10232. },
  10233. _move: function( direction, filter, event ) {
  10234. var next;
  10235. if ( this.active ) {
  10236. if ( direction === "first" || direction === "last" ) {
  10237. next = this.active
  10238. [ direction === "first" ? "prevAll" : "nextAll" ]( ".ui-menu-item" )
  10239. .eq( -1 );
  10240. } else {
  10241. next = this.active
  10242. [ direction + "All" ]( ".ui-menu-item" )
  10243. .eq( 0 );
  10244. }
  10245. }
  10246. if ( !next || !next.length || !this.active ) {
  10247. next = this.activeMenu.children( ".ui-menu-item" )[ filter ]();
  10248. }
  10249. this.focus( event, next );
  10250. },
  10251. nextPage: function( event ) {
  10252. var item, base, height;
  10253. if ( !this.active ) {
  10254. this.next( event );
  10255. return;
  10256. }
  10257. if ( this.isLastItem() ) {
  10258. return;
  10259. }
  10260. if ( this._hasScroll() ) {
  10261. base = this.active.offset().top;
  10262. height = this.element.height();
  10263. this.active.nextAll( ".ui-menu-item" ).each(function() {
  10264. item = $( this );
  10265. return item.offset().top - base - height < 0;
  10266. });
  10267. this.focus( event, item );
  10268. } else {
  10269. this.focus( event, this.activeMenu.children( ".ui-menu-item" )
  10270. [ !this.active ? "first" : "last" ]() );
  10271. }
  10272. },
  10273. previousPage: function( event ) {
  10274. var item, base, height;
  10275. if ( !this.active ) {
  10276. this.next( event );
  10277. return;
  10278. }
  10279. if ( this.isFirstItem() ) {
  10280. return;
  10281. }
  10282. if ( this._hasScroll() ) {
  10283. base = this.active.offset().top;
  10284. height = this.element.height();
  10285. this.active.prevAll( ".ui-menu-item" ).each(function() {
  10286. item = $( this );
  10287. return item.offset().top - base + height > 0;
  10288. });
  10289. this.focus( event, item );
  10290. } else {
  10291. this.focus( event, this.activeMenu.children( ".ui-menu-item" ).first() );
  10292. }
  10293. },
  10294. _hasScroll: function() {
  10295. return this.element.outerHeight() < this.element.prop( "scrollHeight" );
  10296. },
  10297. select: function( event ) {
  10298. // TODO: It should never be possible to not have an active item at this
  10299. // point, but the tests don't trigger mouseenter before click.
  10300. this.active = this.active || $( event.target ).closest( ".ui-menu-item" );
  10301. var ui = { item: this.active };
  10302. if ( !this.active.has( ".ui-menu" ).length ) {
  10303. this.collapseAll( event, true );
  10304. }
  10305. this._trigger( "select", event, ui );
  10306. }
  10307. });
  10308. }( jQuery ));
  10309. (function( $, undefined ) {
  10310. $.ui = $.ui || {};
  10311. var cachedScrollbarWidth,
  10312. max = Math.max,
  10313. abs = Math.abs,
  10314. round = Math.round,
  10315. rhorizontal = /left|center|right/,
  10316. rvertical = /top|center|bottom/,
  10317. roffset = /[\+\-]\d+(\.[\d]+)?%?/,
  10318. rposition = /^\w+/,
  10319. rpercent = /%$/,
  10320. _position = $.fn.position;
  10321. function getOffsets( offsets, width, height ) {
  10322. return [
  10323. parseFloat( offsets[ 0 ] ) * ( rpercent.test( offsets[ 0 ] ) ? width / 100 : 1 ),
  10324. parseFloat( offsets[ 1 ] ) * ( rpercent.test( offsets[ 1 ] ) ? height / 100 : 1 )
  10325. ];
  10326. }
  10327. function parseCss( element, property ) {
  10328. return parseInt( $.css( element, property ), 10 ) || 0;
  10329. }
  10330. function getDimensions( elem ) {
  10331. var raw = elem[0];
  10332. if ( raw.nodeType === 9 ) {
  10333. return {
  10334. width: elem.width(),
  10335. height: elem.height(),
  10336. offset: { top: 0, left: 0 }
  10337. };
  10338. }
  10339. if ( $.isWindow( raw ) ) {
  10340. return {
  10341. width: elem.width(),
  10342. height: elem.height(),
  10343. offset: { top: elem.scrollTop(), left: elem.scrollLeft() }
  10344. };
  10345. }
  10346. if ( raw.preventDefault ) {
  10347. return {
  10348. width: 0,
  10349. height: 0,
  10350. offset: { top: raw.pageY, left: raw.pageX }
  10351. };
  10352. }
  10353. return {
  10354. width: elem.outerWidth(),
  10355. height: elem.outerHeight(),
  10356. offset: elem.offset()
  10357. };
  10358. }
  10359. $.position = {
  10360. scrollbarWidth: function() {
  10361. if ( cachedScrollbarWidth !== undefined ) {
  10362. return cachedScrollbarWidth;
  10363. }
  10364. var w1, w2,
  10365. div = $( "<div style='display:block;width:50px;height:50px;overflow:hidden;'><div style='height:100px;width:auto;'></div></div>" ),
  10366. innerDiv = div.children()[0];
  10367. $( "body" ).append( div );
  10368. w1 = innerDiv.offsetWidth;
  10369. div.css( "overflow", "scroll" );
  10370. w2 = innerDiv.offsetWidth;
  10371. if ( w1 === w2 ) {
  10372. w2 = div[0].clientWidth;
  10373. }
  10374. div.remove();
  10375. return (cachedScrollbarWidth = w1 - w2);
  10376. },
  10377. getScrollInfo: function( within ) {
  10378. var overflowX = within.isWindow ? "" : within.element.css( "overflow-x" ),
  10379. overflowY = within.isWindow ? "" : within.element.css( "overflow-y" ),
  10380. hasOverflowX = overflowX === "scroll" ||
  10381. ( overflowX === "auto" && within.width < within.element[0].scrollWidth ),
  10382. hasOverflowY = overflowY === "scroll" ||
  10383. ( overflowY === "auto" && within.height < within.element[0].scrollHeight );
  10384. return {
  10385. width: hasOverflowY ? $.position.scrollbarWidth() : 0,
  10386. height: hasOverflowX ? $.position.scrollbarWidth() : 0
  10387. };
  10388. },
  10389. getWithinInfo: function( element ) {
  10390. var withinElement = $( element || window ),
  10391. isWindow = $.isWindow( withinElement[0] );
  10392. return {
  10393. element: withinElement,
  10394. isWindow: isWindow,
  10395. offset: withinElement.offset() || { left: 0, top: 0 },
  10396. scrollLeft: withinElement.scrollLeft(),
  10397. scrollTop: withinElement.scrollTop(),
  10398. width: isWindow ? withinElement.width() : withinElement.outerWidth(),
  10399. height: isWindow ? withinElement.height() : withinElement.outerHeight()
  10400. };
  10401. }
  10402. };
  10403. $.fn.position = function( options ) {
  10404. if ( !options || !options.of ) {
  10405. return _position.apply( this, arguments );
  10406. }
  10407. // make a copy, we don't want to modify arguments
  10408. options = $.extend( {}, options );
  10409. var atOffset, targetWidth, targetHeight, targetOffset, basePosition, dimensions,
  10410. target = $( options.of ),
  10411. within = $.position.getWithinInfo( options.within ),
  10412. scrollInfo = $.position.getScrollInfo( within ),
  10413. collision = ( options.collision || "flip" ).split( " " ),
  10414. offsets = {};
  10415. dimensions = getDimensions( target );
  10416. if ( target[0].preventDefault ) {
  10417. // force left top to allow flipping
  10418. options.at = "left top";
  10419. }
  10420. targetWidth = dimensions.width;
  10421. targetHeight = dimensions.height;
  10422. targetOffset = dimensions.offset;
  10423. // clone to reuse original targetOffset later
  10424. basePosition = $.extend( {}, targetOffset );
  10425. // force my and at to have valid horizontal and vertical positions
  10426. // if a value is missing or invalid, it will be converted to center
  10427. $.each( [ "my", "at" ], function() {
  10428. var pos = ( options[ this ] || "" ).split( " " ),
  10429. horizontalOffset,
  10430. verticalOffset;
  10431. if ( pos.length === 1) {
  10432. pos = rhorizontal.test( pos[ 0 ] ) ?
  10433. pos.concat( [ "center" ] ) :
  10434. rvertical.test( pos[ 0 ] ) ?
  10435. [ "center" ].concat( pos ) :
  10436. [ "center", "center" ];
  10437. }
  10438. pos[ 0 ] = rhorizontal.test( pos[ 0 ] ) ? pos[ 0 ] : "center";
  10439. pos[ 1 ] = rvertical.test( pos[ 1 ] ) ? pos[ 1 ] : "center";
  10440. // calculate offsets
  10441. horizontalOffset = roffset.exec( pos[ 0 ] );
  10442. verticalOffset = roffset.exec( pos[ 1 ] );
  10443. offsets[ this ] = [
  10444. horizontalOffset ? horizontalOffset[ 0 ] : 0,
  10445. verticalOffset ? verticalOffset[ 0 ] : 0
  10446. ];
  10447. // reduce to just the positions without the offsets
  10448. options[ this ] = [
  10449. rposition.exec( pos[ 0 ] )[ 0 ],
  10450. rposition.exec( pos[ 1 ] )[ 0 ]
  10451. ];
  10452. });
  10453. // normalize collision option
  10454. if ( collision.length === 1 ) {
  10455. collision[ 1 ] = collision[ 0 ];
  10456. }
  10457. if ( options.at[ 0 ] === "right" ) {
  10458. basePosition.left += targetWidth;
  10459. } else if ( options.at[ 0 ] === "center" ) {
  10460. basePosition.left += targetWidth / 2;
  10461. }
  10462. if ( options.at[ 1 ] === "bottom" ) {
  10463. basePosition.top += targetHeight;
  10464. } else if ( options.at[ 1 ] === "center" ) {
  10465. basePosition.top += targetHeight / 2;
  10466. }
  10467. atOffset = getOffsets( offsets.at, targetWidth, targetHeight );
  10468. basePosition.left += atOffset[ 0 ];
  10469. basePosition.top += atOffset[ 1 ];
  10470. return this.each(function() {
  10471. var collisionPosition, using,
  10472. elem = $( this ),
  10473. elemWidth = elem.outerWidth(),
  10474. elemHeight = elem.outerHeight(),
  10475. marginLeft = parseCss( this, "marginLeft" ),
  10476. marginTop = parseCss( this, "marginTop" ),
  10477. collisionWidth = elemWidth + marginLeft + parseCss( this, "marginRight" ) + scrollInfo.width,
  10478. collisionHeight = elemHeight + marginTop + parseCss( this, "marginBottom" ) + scrollInfo.height,
  10479. position = $.extend( {}, basePosition ),
  10480. myOffset = getOffsets( offsets.my, elem.outerWidth(), elem.outerHeight() );
  10481. if ( options.my[ 0 ] === "right" ) {
  10482. position.left -= elemWidth;
  10483. } else if ( options.my[ 0 ] === "center" ) {
  10484. position.left -= elemWidth / 2;
  10485. }
  10486. if ( options.my[ 1 ] === "bottom" ) {
  10487. position.top -= elemHeight;
  10488. } else if ( options.my[ 1 ] === "center" ) {
  10489. position.top -= elemHeight / 2;
  10490. }
  10491. position.left += myOffset[ 0 ];
  10492. position.top += myOffset[ 1 ];
  10493. // if the browser doesn't support fractions, then round for consistent results
  10494. if ( !$.support.offsetFractions ) {
  10495. position.left = round( position.left );
  10496. position.top = round( position.top );
  10497. }
  10498. collisionPosition = {
  10499. marginLeft: marginLeft,
  10500. marginTop: marginTop
  10501. };
  10502. $.each( [ "left", "top" ], function( i, dir ) {
  10503. if ( $.ui.position[ collision[ i ] ] ) {
  10504. $.ui.position[ collision[ i ] ][ dir ]( position, {
  10505. targetWidth: targetWidth,
  10506. targetHeight: targetHeight,
  10507. elemWidth: elemWidth,
  10508. elemHeight: elemHeight,
  10509. collisionPosition: collisionPosition,
  10510. collisionWidth: collisionWidth,
  10511. collisionHeight: collisionHeight,
  10512. offset: [ atOffset[ 0 ] + myOffset[ 0 ], atOffset [ 1 ] + myOffset[ 1 ] ],
  10513. my: options.my,
  10514. at: options.at,
  10515. within: within,
  10516. elem : elem
  10517. });
  10518. }
  10519. });
  10520. if ( options.using ) {
  10521. // adds feedback as second argument to using callback, if present
  10522. using = function( props ) {
  10523. var left = targetOffset.left - position.left,
  10524. right = left + targetWidth - elemWidth,
  10525. top = targetOffset.top - position.top,
  10526. bottom = top + targetHeight - elemHeight,
  10527. feedback = {
  10528. target: {
  10529. element: target,
  10530. left: targetOffset.left,
  10531. top: targetOffset.top,
  10532. width: targetWidth,
  10533. height: targetHeight
  10534. },
  10535. element: {
  10536. element: elem,
  10537. left: position.left,
  10538. top: position.top,
  10539. width: elemWidth,
  10540. height: elemHeight
  10541. },
  10542. horizontal: right < 0 ? "left" : left > 0 ? "right" : "center",
  10543. vertical: bottom < 0 ? "top" : top > 0 ? "bottom" : "middle"
  10544. };
  10545. if ( targetWidth < elemWidth && abs( left + right ) < targetWidth ) {
  10546. feedback.horizontal = "center";
  10547. }
  10548. if ( targetHeight < elemHeight && abs( top + bottom ) < targetHeight ) {
  10549. feedback.vertical = "middle";
  10550. }
  10551. if ( max( abs( left ), abs( right ) ) > max( abs( top ), abs( bottom ) ) ) {
  10552. feedback.important = "horizontal";
  10553. } else {
  10554. feedback.important = "vertical";
  10555. }
  10556. options.using.call( this, props, feedback );
  10557. };
  10558. }
  10559. elem.offset( $.extend( position, { using: using } ) );
  10560. });
  10561. };
  10562. $.ui.position = {
  10563. fit: {
  10564. left: function( position, data ) {
  10565. var within = data.within,
  10566. withinOffset = within.isWindow ? within.scrollLeft : within.offset.left,
  10567. outerWidth = within.width,
  10568. collisionPosLeft = position.left - data.collisionPosition.marginLeft,
  10569. overLeft = withinOffset - collisionPosLeft,
  10570. overRight = collisionPosLeft + data.collisionWidth - outerWidth - withinOffset,
  10571. newOverRight;
  10572. // element is wider than within
  10573. if ( data.collisionWidth > outerWidth ) {
  10574. // element is initially over the left side of within
  10575. if ( overLeft > 0 && overRight <= 0 ) {
  10576. newOverRight = position.left + overLeft + data.collisionWidth - outerWidth - withinOffset;
  10577. position.left += overLeft - newOverRight;
  10578. // element is initially over right side of within
  10579. } else if ( overRight > 0 && overLeft <= 0 ) {
  10580. position.left = withinOffset;
  10581. // element is initially over both left and right sides of within
  10582. } else {
  10583. if ( overLeft > overRight ) {
  10584. position.left = withinOffset + outerWidth - data.collisionWidth;
  10585. } else {
  10586. position.left = withinOffset;
  10587. }
  10588. }
  10589. // too far left -> align with left edge
  10590. } else if ( overLeft > 0 ) {
  10591. position.left += overLeft;
  10592. // too far right -> align with right edge
  10593. } else if ( overRight > 0 ) {
  10594. position.left -= overRight;
  10595. // adjust based on position and margin
  10596. } else {
  10597. position.left = max( position.left - collisionPosLeft, position.left );
  10598. }
  10599. },
  10600. top: function( position, data ) {
  10601. var within = data.within,
  10602. withinOffset = within.isWindow ? within.scrollTop : within.offset.top,
  10603. outerHeight = data.within.height,
  10604. collisionPosTop = position.top - data.collisionPosition.marginTop,
  10605. overTop = withinOffset - collisionPosTop,
  10606. overBottom = collisionPosTop + data.collisionHeight - outerHeight - withinOffset,
  10607. newOverBottom;
  10608. // element is taller than within
  10609. if ( data.collisionHeight > outerHeight ) {
  10610. // element is initially over the top of within
  10611. if ( overTop > 0 && overBottom <= 0 ) {
  10612. newOverBottom = position.top + overTop + data.collisionHeight - outerHeight - withinOffset;
  10613. position.top += overTop - newOverBottom;
  10614. // element is initially over bottom of within
  10615. } else if ( overBottom > 0 && overTop <= 0 ) {
  10616. position.top = withinOffset;
  10617. // element is initially over both top and bottom of within
  10618. } else {
  10619. if ( overTop > overBottom ) {
  10620. position.top = withinOffset + outerHeight - data.collisionHeight;
  10621. } else {
  10622. position.top = withinOffset;
  10623. }
  10624. }
  10625. // too far up -> align with top
  10626. } else if ( overTop > 0 ) {
  10627. position.top += overTop;
  10628. // too far down -> align with bottom edge
  10629. } else if ( overBottom > 0 ) {
  10630. position.top -= overBottom;
  10631. // adjust based on position and margin
  10632. } else {
  10633. position.top = max( position.top - collisionPosTop, position.top );
  10634. }
  10635. }
  10636. },
  10637. flip: {
  10638. left: function( position, data ) {
  10639. var within = data.within,
  10640. withinOffset = within.offset.left + within.scrollLeft,
  10641. outerWidth = within.width,
  10642. offsetLeft = within.isWindow ? within.scrollLeft : within.offset.left,
  10643. collisionPosLeft = position.left - data.collisionPosition.marginLeft,
  10644. overLeft = collisionPosLeft - offsetLeft,
  10645. overRight = collisionPosLeft + data.collisionWidth - outerWidth - offsetLeft,
  10646. myOffset = data.my[ 0 ] === "left" ?
  10647. -data.elemWidth :
  10648. data.my[ 0 ] === "right" ?
  10649. data.elemWidth :
  10650. 0,
  10651. atOffset = data.at[ 0 ] === "left" ?
  10652. data.targetWidth :
  10653. data.at[ 0 ] === "right" ?
  10654. -data.targetWidth :
  10655. 0,
  10656. offset = -2 * data.offset[ 0 ],
  10657. newOverRight,
  10658. newOverLeft;
  10659. if ( overLeft < 0 ) {
  10660. newOverRight = position.left + myOffset + atOffset + offset + data.collisionWidth - outerWidth - withinOffset;
  10661. if ( newOverRight < 0 || newOverRight < abs( overLeft ) ) {
  10662. position.left += myOffset + atOffset + offset;
  10663. }
  10664. }
  10665. else if ( overRight > 0 ) {
  10666. newOverLeft = position.left - data.collisionPosition.marginLeft + myOffset + atOffset + offset - offsetLeft;
  10667. if ( newOverLeft > 0 || abs( newOverLeft ) < overRight ) {
  10668. position.left += myOffset + atOffset + offset;
  10669. }
  10670. }
  10671. },
  10672. top: function( position, data ) {
  10673. var within = data.within,
  10674. withinOffset = within.offset.top + within.scrollTop,
  10675. outerHeight = within.height,
  10676. offsetTop = within.isWindow ? within.scrollTop : within.offset.top,
  10677. collisionPosTop = position.top - data.collisionPosition.marginTop,
  10678. overTop = collisionPosTop - offsetTop,
  10679. overBottom = collisionPosTop + data.collisionHeight - outerHeight - offsetTop,
  10680. top = data.my[ 1 ] === "top",
  10681. myOffset = top ?
  10682. -data.elemHeight :
  10683. data.my[ 1 ] === "bottom" ?
  10684. data.elemHeight :
  10685. 0,
  10686. atOffset = data.at[ 1 ] === "top" ?
  10687. data.targetHeight :
  10688. data.at[ 1 ] === "bottom" ?
  10689. -data.targetHeight :
  10690. 0,
  10691. offset = -2 * data.offset[ 1 ],
  10692. newOverTop,
  10693. newOverBottom;
  10694. if ( overTop < 0 ) {
  10695. newOverBottom = position.top + myOffset + atOffset + offset + data.collisionHeight - outerHeight - withinOffset;
  10696. if ( ( position.top + myOffset + atOffset + offset) > overTop && ( newOverBottom < 0 || newOverBottom < abs( overTop ) ) ) {
  10697. position.top += myOffset + atOffset + offset;
  10698. }
  10699. }
  10700. else if ( overBottom > 0 ) {
  10701. newOverTop = position.top - data.collisionPosition.marginTop + myOffset + atOffset + offset - offsetTop;
  10702. if ( ( position.top + myOffset + atOffset + offset) > overBottom && ( newOverTop > 0 || abs( newOverTop ) < overBottom ) ) {
  10703. position.top += myOffset + atOffset + offset;
  10704. }
  10705. }
  10706. }
  10707. },
  10708. flipfit: {
  10709. left: function() {
  10710. $.ui.position.flip.left.apply( this, arguments );
  10711. $.ui.position.fit.left.apply( this, arguments );
  10712. },
  10713. top: function() {
  10714. $.ui.position.flip.top.apply( this, arguments );
  10715. $.ui.position.fit.top.apply( this, arguments );
  10716. }
  10717. }
  10718. };
  10719. // fraction support test
  10720. (function () {
  10721. var testElement, testElementParent, testElementStyle, offsetLeft, i,
  10722. body = document.getElementsByTagName( "body" )[ 0 ],
  10723. div = document.createElement( "div" );
  10724. //Create a "fake body" for testing based on method used in jQuery.support
  10725. testElement = document.createElement( body ? "div" : "body" );
  10726. testElementStyle = {
  10727. visibility: "hidden",
  10728. width: 0,
  10729. height: 0,
  10730. border: 0,
  10731. margin: 0,
  10732. background: "none"
  10733. };
  10734. if ( body ) {
  10735. $.extend( testElementStyle, {
  10736. position: "absolute",
  10737. left: "-1000px",
  10738. top: "-1000px"
  10739. });
  10740. }
  10741. for ( i in testElementStyle ) {
  10742. testElement.style[ i ] = testElementStyle[ i ];
  10743. }
  10744. testElement.appendChild( div );
  10745. testElementParent = body || document.documentElement;
  10746. testElementParent.insertBefore( testElement, testElementParent.firstChild );
  10747. div.style.cssText = "position: absolute; left: 10.7432222px;";
  10748. offsetLeft = $( div ).offset().left;
  10749. $.support.offsetFractions = offsetLeft > 10 && offsetLeft < 11;
  10750. testElement.innerHTML = "";
  10751. testElementParent.removeChild( testElement );
  10752. })();
  10753. }( jQuery ) );
  10754. (function( $, undefined ) {
  10755. $.widget( "ui.progressbar", {
  10756. version: "1.10.3",
  10757. options: {
  10758. max: 100,
  10759. value: 0,
  10760. change: null,
  10761. complete: null
  10762. },
  10763. min: 0,
  10764. _create: function() {
  10765. // Constrain initial value
  10766. this.oldValue = this.options.value = this._constrainedValue();
  10767. this.element
  10768. .addClass( "ui-progressbar ui-widget ui-widget-content ui-corner-all" )
  10769. .attr({
  10770. // Only set static values, aria-valuenow and aria-valuemax are
  10771. // set inside _refreshValue()
  10772. role: "progressbar",
  10773. "aria-valuemin": this.min
  10774. });
  10775. this.valueDiv = $( "<div class='ui-progressbar-value ui-widget-header ui-corner-left'></div>" )
  10776. .appendTo( this.element );
  10777. this._refreshValue();
  10778. },
  10779. _destroy: function() {
  10780. this.element
  10781. .removeClass( "ui-progressbar ui-widget ui-widget-content ui-corner-all" )
  10782. .removeAttr( "role" )
  10783. .removeAttr( "aria-valuemin" )
  10784. .removeAttr( "aria-valuemax" )
  10785. .removeAttr( "aria-valuenow" );
  10786. this.valueDiv.remove();
  10787. },
  10788. value: function( newValue ) {
  10789. if ( newValue === undefined ) {
  10790. return this.options.value;
  10791. }
  10792. this.options.value = this._constrainedValue( newValue );
  10793. this._refreshValue();
  10794. },
  10795. _constrainedValue: function( newValue ) {
  10796. if ( newValue === undefined ) {
  10797. newValue = this.options.value;
  10798. }
  10799. this.indeterminate = newValue === false;
  10800. // sanitize value
  10801. if ( typeof newValue !== "number" ) {
  10802. newValue = 0;
  10803. }
  10804. return this.indeterminate ? false :
  10805. Math.min( this.options.max, Math.max( this.min, newValue ) );
  10806. },
  10807. _setOptions: function( options ) {
  10808. // Ensure "value" option is set after other values (like max)
  10809. var value = options.value;
  10810. delete options.value;
  10811. this._super( options );
  10812. this.options.value = this._constrainedValue( value );
  10813. this._refreshValue();
  10814. },
  10815. _setOption: function( key, value ) {
  10816. if ( key === "max" ) {
  10817. // Don't allow a max less than min
  10818. value = Math.max( this.min, value );
  10819. }
  10820. this._super( key, value );
  10821. },
  10822. _percentage: function() {
  10823. return this.indeterminate ? 100 : 100 * ( this.options.value - this.min ) / ( this.options.max - this.min );
  10824. },
  10825. _refreshValue: function() {
  10826. var value = this.options.value,
  10827. percentage = this._percentage();
  10828. this.valueDiv
  10829. .toggle( this.indeterminate || value > this.min )
  10830. .toggleClass( "ui-corner-right", value === this.options.max )
  10831. .width( percentage.toFixed(0) + "%" );
  10832. this.element.toggleClass( "ui-progressbar-indeterminate", this.indeterminate );
  10833. if ( this.indeterminate ) {
  10834. this.element.removeAttr( "aria-valuenow" );
  10835. if ( !this.overlayDiv ) {
  10836. this.overlayDiv = $( "<div class='ui-progressbar-overlay'></div>" ).appendTo( this.valueDiv );
  10837. }
  10838. } else {
  10839. this.element.attr({
  10840. "aria-valuemax": this.options.max,
  10841. "aria-valuenow": value
  10842. });
  10843. if ( this.overlayDiv ) {
  10844. this.overlayDiv.remove();
  10845. this.overlayDiv = null;
  10846. }
  10847. }
  10848. if ( this.oldValue !== value ) {
  10849. this.oldValue = value;
  10850. this._trigger( "change" );
  10851. }
  10852. if ( value === this.options.max ) {
  10853. this._trigger( "complete" );
  10854. }
  10855. }
  10856. });
  10857. })( jQuery );
  10858. (function( $, undefined ) {
  10859. // number of pages in a slider
  10860. // (how many times can you page up/down to go through the whole range)
  10861. var numPages = 5;
  10862. $.widget( "ui.slider", $.ui.mouse, {
  10863. version: "1.10.3",
  10864. widgetEventPrefix: "slide",
  10865. options: {
  10866. animate: false,
  10867. distance: 0,
  10868. max: 100,
  10869. min: 0,
  10870. orientation: "horizontal",
  10871. range: false,
  10872. step: 1,
  10873. value: 0,
  10874. values: null,
  10875. // callbacks
  10876. change: null,
  10877. slide: null,
  10878. start: null,
  10879. stop: null
  10880. },
  10881. _create: function() {
  10882. this._keySliding = false;
  10883. this._mouseSliding = false;
  10884. this._animateOff = true;
  10885. this._handleIndex = null;
  10886. this._detectOrientation();
  10887. this._mouseInit();
  10888. this.element
  10889. .addClass( "ui-slider" +
  10890. " ui-slider-" + this.orientation +
  10891. " ui-widget" +
  10892. " ui-widget-content" +
  10893. " ui-corner-all");
  10894. this._refresh();
  10895. this._setOption( "disabled", this.options.disabled );
  10896. this._animateOff = false;
  10897. },
  10898. _refresh: function() {
  10899. this._createRange();
  10900. this._createHandles();
  10901. this._setupEvents();
  10902. this._refreshValue();
  10903. },
  10904. _createHandles: function() {
  10905. var i, handleCount,
  10906. options = this.options,
  10907. existingHandles = this.element.find( ".ui-slider-handle" ).addClass( "ui-state-default ui-corner-all" ),
  10908. handle = "<a class='ui-slider-handle ui-state-default ui-corner-all' href='#'></a>",
  10909. handles = [];
  10910. handleCount = ( options.values && options.values.length ) || 1;
  10911. if ( existingHandles.length > handleCount ) {
  10912. existingHandles.slice( handleCount ).remove();
  10913. existingHandles = existingHandles.slice( 0, handleCount );
  10914. }
  10915. for ( i = existingHandles.length; i < handleCount; i++ ) {
  10916. handles.push( handle );
  10917. }
  10918. this.handles = existingHandles.add( $( handles.join( "" ) ).appendTo( this.element ) );
  10919. this.handle = this.handles.eq( 0 );
  10920. this.handles.each(function( i ) {
  10921. $( this ).data( "ui-slider-handle-index", i );
  10922. });
  10923. },
  10924. _createRange: function() {
  10925. var options = this.options,
  10926. classes = "";
  10927. if ( options.range ) {
  10928. if ( options.range === true ) {
  10929. if ( !options.values ) {
  10930. options.values = [ this._valueMin(), this._valueMin() ];
  10931. } else if ( options.values.length && options.values.length !== 2 ) {
  10932. options.values = [ options.values[0], options.values[0] ];
  10933. } else if ( $.isArray( options.values ) ) {
  10934. options.values = options.values.slice(0);
  10935. }
  10936. }
  10937. if ( !this.range || !this.range.length ) {
  10938. this.range = $( "<div></div>" )
  10939. .appendTo( this.element );
  10940. classes = "ui-slider-range" +
  10941. // note: this isn't the most fittingly semantic framework class for this element,
  10942. // but worked best visually with a variety of themes
  10943. " ui-widget-header ui-corner-all";
  10944. } else {
  10945. this.range.removeClass( "ui-slider-range-min ui-slider-range-max" )
  10946. // Handle range switching from true to min/max
  10947. .css({
  10948. "left": "",
  10949. "bottom": ""
  10950. });
  10951. }
  10952. this.range.addClass( classes +
  10953. ( ( options.range === "min" || options.range === "max" ) ? " ui-slider-range-" + options.range : "" ) );
  10954. } else {
  10955. this.range = $([]);
  10956. }
  10957. },
  10958. _setupEvents: function() {
  10959. var elements = this.handles.add( this.range ).filter( "a" );
  10960. this._off( elements );
  10961. this._on( elements, this._handleEvents );
  10962. this._hoverable( elements );
  10963. this._focusable( elements );
  10964. },
  10965. _destroy: function() {
  10966. this.handles.remove();
  10967. this.range.remove();
  10968. this.element
  10969. .removeClass( "ui-slider" +
  10970. " ui-slider-horizontal" +
  10971. " ui-slider-vertical" +
  10972. " ui-widget" +
  10973. " ui-widget-content" +
  10974. " ui-corner-all" );
  10975. this._mouseDestroy();
  10976. },
  10977. _mouseCapture: function( event ) {
  10978. var position, normValue, distance, closestHandle, index, allowed, offset, mouseOverHandle,
  10979. that = this,
  10980. o = this.options;
  10981. if ( o.disabled ) {
  10982. return false;
  10983. }
  10984. this.elementSize = {
  10985. width: this.element.outerWidth(),
  10986. height: this.element.outerHeight()
  10987. };
  10988. this.elementOffset = this.element.offset();
  10989. position = { x: event.pageX, y: event.pageY };
  10990. normValue = this._normValueFromMouse( position );
  10991. distance = this._valueMax() - this._valueMin() + 1;
  10992. this.handles.each(function( i ) {
  10993. var thisDistance = Math.abs( normValue - that.values(i) );
  10994. if (( distance > thisDistance ) ||
  10995. ( distance === thisDistance &&
  10996. (i === that._lastChangedValue || that.values(i) === o.min ))) {
  10997. distance = thisDistance;
  10998. closestHandle = $( this );
  10999. index = i;
  11000. }
  11001. });
  11002. allowed = this._start( event, index );
  11003. if ( allowed === false ) {
  11004. return false;
  11005. }
  11006. this._mouseSliding = true;
  11007. this._handleIndex = index;
  11008. closestHandle
  11009. .addClass( "ui-state-active" )
  11010. .focus();
  11011. offset = closestHandle.offset();
  11012. mouseOverHandle = !$( event.target ).parents().addBack().is( ".ui-slider-handle" );
  11013. this._clickOffset = mouseOverHandle ? { left: 0, top: 0 } : {
  11014. left: event.pageX - offset.left - ( closestHandle.width() / 2 ),
  11015. top: event.pageY - offset.top -
  11016. ( closestHandle.height() / 2 ) -
  11017. ( parseInt( closestHandle.css("borderTopWidth"), 10 ) || 0 ) -
  11018. ( parseInt( closestHandle.css("borderBottomWidth"), 10 ) || 0) +
  11019. ( parseInt( closestHandle.css("marginTop"), 10 ) || 0)
  11020. };
  11021. if ( !this.handles.hasClass( "ui-state-hover" ) ) {
  11022. this._slide( event, index, normValue );
  11023. }
  11024. this._animateOff = true;
  11025. return true;
  11026. },
  11027. _mouseStart: function() {
  11028. return true;
  11029. },
  11030. _mouseDrag: function( event ) {
  11031. var position = { x: event.pageX, y: event.pageY },
  11032. normValue = this._normValueFromMouse( position );
  11033. this._slide( event, this._handleIndex, normValue );
  11034. return false;
  11035. },
  11036. _mouseStop: function( event ) {
  11037. this.handles.removeClass( "ui-state-active" );
  11038. this._mouseSliding = false;
  11039. this._stop( event, this._handleIndex );
  11040. this._change( event, this._handleIndex );
  11041. this._handleIndex = null;
  11042. this._clickOffset = null;
  11043. this._animateOff = false;
  11044. return false;
  11045. },
  11046. _detectOrientation: function() {
  11047. this.orientation = ( this.options.orientation === "vertical" ) ? "vertical" : "horizontal";
  11048. },
  11049. _normValueFromMouse: function( position ) {
  11050. var pixelTotal,
  11051. pixelMouse,
  11052. percentMouse,
  11053. valueTotal,
  11054. valueMouse;
  11055. if ( this.orientation === "horizontal" ) {
  11056. pixelTotal = this.elementSize.width;
  11057. pixelMouse = position.x - this.elementOffset.left - ( this._clickOffset ? this._clickOffset.left : 0 );
  11058. } else {
  11059. pixelTotal = this.elementSize.height;
  11060. pixelMouse = position.y - this.elementOffset.top - ( this._clickOffset ? this._clickOffset.top : 0 );
  11061. }
  11062. percentMouse = ( pixelMouse / pixelTotal );
  11063. if ( percentMouse > 1 ) {
  11064. percentMouse = 1;
  11065. }
  11066. if ( percentMouse < 0 ) {
  11067. percentMouse = 0;
  11068. }
  11069. if ( this.orientation === "vertical" ) {
  11070. percentMouse = 1 - percentMouse;
  11071. }
  11072. valueTotal = this._valueMax() - this._valueMin();
  11073. valueMouse = this._valueMin() + percentMouse * valueTotal;
  11074. return this._trimAlignValue( valueMouse );
  11075. },
  11076. _start: function( event, index ) {
  11077. var uiHash = {
  11078. handle: this.handles[ index ],
  11079. value: this.value()
  11080. };
  11081. if ( this.options.values && this.options.values.length ) {
  11082. uiHash.value = this.values( index );
  11083. uiHash.values = this.values();
  11084. }
  11085. return this._trigger( "start", event, uiHash );
  11086. },
  11087. _slide: function( event, index, newVal ) {
  11088. var otherVal,
  11089. newValues,
  11090. allowed;
  11091. if ( this.options.values && this.options.values.length ) {
  11092. otherVal = this.values( index ? 0 : 1 );
  11093. if ( ( this.options.values.length === 2 && this.options.range === true ) &&
  11094. ( ( index === 0 && newVal > otherVal) || ( index === 1 && newVal < otherVal ) )
  11095. ) {
  11096. newVal = otherVal;
  11097. }
  11098. if ( newVal !== this.values( index ) ) {
  11099. newValues = this.values();
  11100. newValues[ index ] = newVal;
  11101. // A slide can be canceled by returning false from the slide callback
  11102. allowed = this._trigger( "slide", event, {
  11103. handle: this.handles[ index ],
  11104. value: newVal,
  11105. values: newValues
  11106. } );
  11107. otherVal = this.values( index ? 0 : 1 );
  11108. if ( allowed !== false ) {
  11109. this.values( index, newVal, true );
  11110. }
  11111. }
  11112. } else {
  11113. if ( newVal !== this.value() ) {
  11114. // A slide can be canceled by returning false from the slide callback
  11115. allowed = this._trigger( "slide", event, {
  11116. handle: this.handles[ index ],
  11117. value: newVal
  11118. } );
  11119. if ( allowed !== false ) {
  11120. this.value( newVal );
  11121. }
  11122. }
  11123. }
  11124. },
  11125. _stop: function( event, index ) {
  11126. var uiHash = {
  11127. handle: this.handles[ index ],
  11128. value: this.value()
  11129. };
  11130. if ( this.options.values && this.options.values.length ) {
  11131. uiHash.value = this.values( index );
  11132. uiHash.values = this.values();
  11133. }
  11134. this._trigger( "stop", event, uiHash );
  11135. },
  11136. _change: function( event, index ) {
  11137. if ( !this._keySliding && !this._mouseSliding ) {
  11138. var uiHash = {
  11139. handle: this.handles[ index ],
  11140. value: this.value()
  11141. };
  11142. if ( this.options.values && this.options.values.length ) {
  11143. uiHash.value = this.values( index );
  11144. uiHash.values = this.values();
  11145. }
  11146. //store the last changed value index for reference when handles overlap
  11147. this._lastChangedValue = index;
  11148. this._trigger( "change", event, uiHash );
  11149. }
  11150. },
  11151. value: function( newValue ) {
  11152. if ( arguments.length ) {
  11153. this.options.value = this._trimAlignValue( newValue );
  11154. this._refreshValue();
  11155. this._change( null, 0 );
  11156. return;
  11157. }
  11158. return this._value();
  11159. },
  11160. values: function( index, newValue ) {
  11161. var vals,
  11162. newValues,
  11163. i;
  11164. if ( arguments.length > 1 ) {
  11165. this.options.values[ index ] = this._trimAlignValue( newValue );
  11166. this._refreshValue();
  11167. this._change( null, index );
  11168. return;
  11169. }
  11170. if ( arguments.length ) {
  11171. if ( $.isArray( arguments[ 0 ] ) ) {
  11172. vals = this.options.values;
  11173. newValues = arguments[ 0 ];
  11174. for ( i = 0; i < vals.length; i += 1 ) {
  11175. vals[ i ] = this._trimAlignValue( newValues[ i ] );
  11176. this._change( null, i );
  11177. }
  11178. this._refreshValue();
  11179. } else {
  11180. if ( this.options.values && this.options.values.length ) {
  11181. return this._values( index );
  11182. } else {
  11183. return this.value();
  11184. }
  11185. }
  11186. } else {
  11187. return this._values();
  11188. }
  11189. },
  11190. _setOption: function( key, value ) {
  11191. var i,
  11192. valsLength = 0;
  11193. if ( key === "range" && this.options.range === true ) {
  11194. if ( value === "min" ) {
  11195. this.options.value = this._values( 0 );
  11196. this.options.values = null;
  11197. } else if ( value === "max" ) {
  11198. this.options.value = this._values( this.options.values.length-1 );
  11199. this.options.values = null;
  11200. }
  11201. }
  11202. if ( $.isArray( this.options.values ) ) {
  11203. valsLength = this.options.values.length;
  11204. }
  11205. $.Widget.prototype._setOption.apply( this, arguments );
  11206. switch ( key ) {
  11207. case "orientation":
  11208. this._detectOrientation();
  11209. this.element
  11210. .removeClass( "ui-slider-horizontal ui-slider-vertical" )
  11211. .addClass( "ui-slider-" + this.orientation );
  11212. this._refreshValue();
  11213. break;
  11214. case "value":
  11215. this._animateOff = true;
  11216. this._refreshValue();
  11217. this._change( null, 0 );
  11218. this._animateOff = false;
  11219. break;
  11220. case "values":
  11221. this._animateOff = true;
  11222. this._refreshValue();
  11223. for ( i = 0; i < valsLength; i += 1 ) {
  11224. this._change( null, i );
  11225. }
  11226. this._animateOff = false;
  11227. break;
  11228. case "min":
  11229. case "max":
  11230. this._animateOff = true;
  11231. this._refreshValue();
  11232. this._animateOff = false;
  11233. break;
  11234. case "range":
  11235. this._animateOff = true;
  11236. this._refresh();
  11237. this._animateOff = false;
  11238. break;
  11239. }
  11240. },
  11241. //internal value getter
  11242. // _value() returns value trimmed by min and max, aligned by step
  11243. _value: function() {
  11244. var val = this.options.value;
  11245. val = this._trimAlignValue( val );
  11246. return val;
  11247. },
  11248. //internal values getter
  11249. // _values() returns array of values trimmed by min and max, aligned by step
  11250. // _values( index ) returns single value trimmed by min and max, aligned by step
  11251. _values: function( index ) {
  11252. var val,
  11253. vals,
  11254. i;
  11255. if ( arguments.length ) {
  11256. val = this.options.values[ index ];
  11257. val = this._trimAlignValue( val );
  11258. return val;
  11259. } else if ( this.options.values && this.options.values.length ) {
  11260. // .slice() creates a copy of the array
  11261. // this copy gets trimmed by min and max and then returned
  11262. vals = this.options.values.slice();
  11263. for ( i = 0; i < vals.length; i+= 1) {
  11264. vals[ i ] = this._trimAlignValue( vals[ i ] );
  11265. }
  11266. return vals;
  11267. } else {
  11268. return [];
  11269. }
  11270. },
  11271. // returns the step-aligned value that val is closest to, between (inclusive) min and max
  11272. _trimAlignValue: function( val ) {
  11273. if ( val <= this._valueMin() ) {
  11274. return this._valueMin();
  11275. }
  11276. if ( val >= this._valueMax() ) {
  11277. return this._valueMax();
  11278. }
  11279. var step = ( this.options.step > 0 ) ? this.options.step : 1,
  11280. valModStep = (val - this._valueMin()) % step,
  11281. alignValue = val - valModStep;
  11282. if ( Math.abs(valModStep) * 2 >= step ) {
  11283. alignValue += ( valModStep > 0 ) ? step : ( -step );
  11284. }
  11285. // Since JavaScript has problems with large floats, round
  11286. // the final value to 5 digits after the decimal point (see #4124)
  11287. return parseFloat( alignValue.toFixed(5) );
  11288. },
  11289. _valueMin: function() {
  11290. return this.options.min;
  11291. },
  11292. _valueMax: function() {
  11293. return this.options.max;
  11294. },
  11295. _refreshValue: function() {
  11296. var lastValPercent, valPercent, value, valueMin, valueMax,
  11297. oRange = this.options.range,
  11298. o = this.options,
  11299. that = this,
  11300. animate = ( !this._animateOff ) ? o.animate : false,
  11301. _set = {};
  11302. if ( this.options.values && this.options.values.length ) {
  11303. this.handles.each(function( i ) {
  11304. valPercent = ( that.values(i) - that._valueMin() ) / ( that._valueMax() - that._valueMin() ) * 100;
  11305. _set[ that.orientation === "horizontal" ? "left" : "bottom" ] = valPercent + "%";
  11306. $( this ).stop( 1, 1 )[ animate ? "animate" : "css" ]( _set, o.animate );
  11307. if ( that.options.range === true ) {
  11308. if ( that.orientation === "horizontal" ) {
  11309. if ( i === 0 ) {
  11310. that.range.stop( 1, 1 )[ animate ? "animate" : "css" ]( { left: valPercent + "%" }, o.animate );
  11311. }
  11312. if ( i === 1 ) {
  11313. that.range[ animate ? "animate" : "css" ]( { width: ( valPercent - lastValPercent ) + "%" }, { queue: false, duration: o.animate } );
  11314. }
  11315. } else {
  11316. if ( i === 0 ) {
  11317. that.range.stop( 1, 1 )[ animate ? "animate" : "css" ]( { bottom: ( valPercent ) + "%" }, o.animate );
  11318. }
  11319. if ( i === 1 ) {
  11320. that.range[ animate ? "animate" : "css" ]( { height: ( valPercent - lastValPercent ) + "%" }, { queue: false, duration: o.animate } );
  11321. }
  11322. }
  11323. }
  11324. lastValPercent = valPercent;
  11325. });
  11326. } else {
  11327. value = this.value();
  11328. valueMin = this._valueMin();
  11329. valueMax = this._valueMax();
  11330. valPercent = ( valueMax !== valueMin ) ?
  11331. ( value - valueMin ) / ( valueMax - valueMin ) * 100 :
  11332. 0;
  11333. _set[ this.orientation === "horizontal" ? "left" : "bottom" ] = valPercent + "%";
  11334. this.handle.stop( 1, 1 )[ animate ? "animate" : "css" ]( _set, o.animate );
  11335. if ( oRange === "min" && this.orientation === "horizontal" ) {
  11336. this.range.stop( 1, 1 )[ animate ? "animate" : "css" ]( { width: valPercent + "%" }, o.animate );
  11337. }
  11338. if ( oRange === "max" && this.orientation === "horizontal" ) {
  11339. this.range[ animate ? "animate" : "css" ]( { width: ( 100 - valPercent ) + "%" }, { queue: false, duration: o.animate } );
  11340. }
  11341. if ( oRange === "min" && this.orientation === "vertical" ) {
  11342. this.range.stop( 1, 1 )[ animate ? "animate" : "css" ]( { height: valPercent + "%" }, o.animate );
  11343. }
  11344. if ( oRange === "max" && this.orientation === "vertical" ) {
  11345. this.range[ animate ? "animate" : "css" ]( { height: ( 100 - valPercent ) + "%" }, { queue: false, duration: o.animate } );
  11346. }
  11347. }
  11348. },
  11349. _handleEvents: {
  11350. keydown: function( event ) {
  11351. /*jshint maxcomplexity:25*/
  11352. var allowed, curVal, newVal, step,
  11353. index = $( event.target ).data( "ui-slider-handle-index" );
  11354. switch ( event.keyCode ) {
  11355. case $.ui.keyCode.HOME:
  11356. case $.ui.keyCode.END:
  11357. case $.ui.keyCode.PAGE_UP:
  11358. case $.ui.keyCode.PAGE_DOWN:
  11359. case $.ui.keyCode.UP:
  11360. case $.ui.keyCode.RIGHT:
  11361. case $.ui.keyCode.DOWN:
  11362. case $.ui.keyCode.LEFT:
  11363. event.preventDefault();
  11364. if ( !this._keySliding ) {
  11365. this._keySliding = true;
  11366. $( event.target ).addClass( "ui-state-active" );
  11367. allowed = this._start( event, index );
  11368. if ( allowed === false ) {
  11369. return;
  11370. }
  11371. }
  11372. break;
  11373. }
  11374. step = this.options.step;
  11375. if ( this.options.values && this.options.values.length ) {
  11376. curVal = newVal = this.values( index );
  11377. } else {
  11378. curVal = newVal = this.value();
  11379. }
  11380. switch ( event.keyCode ) {
  11381. case $.ui.keyCode.HOME:
  11382. newVal = this._valueMin();
  11383. break;
  11384. case $.ui.keyCode.END:
  11385. newVal = this._valueMax();
  11386. break;
  11387. case $.ui.keyCode.PAGE_UP:
  11388. newVal = this._trimAlignValue( curVal + ( (this._valueMax() - this._valueMin()) / numPages ) );
  11389. break;
  11390. case $.ui.keyCode.PAGE_DOWN:
  11391. newVal = this._trimAlignValue( curVal - ( (this._valueMax() - this._valueMin()) / numPages ) );
  11392. break;
  11393. case $.ui.keyCode.UP:
  11394. case $.ui.keyCode.RIGHT:
  11395. if ( curVal === this._valueMax() ) {
  11396. return;
  11397. }
  11398. newVal = this._trimAlignValue( curVal + step );
  11399. break;
  11400. case $.ui.keyCode.DOWN:
  11401. case $.ui.keyCode.LEFT:
  11402. if ( curVal === this._valueMin() ) {
  11403. return;
  11404. }
  11405. newVal = this._trimAlignValue( curVal - step );
  11406. break;
  11407. }
  11408. this._slide( event, index, newVal );
  11409. },
  11410. click: function( event ) {
  11411. event.preventDefault();
  11412. },
  11413. keyup: function( event ) {
  11414. var index = $( event.target ).data( "ui-slider-handle-index" );
  11415. if ( this._keySliding ) {
  11416. this._keySliding = false;
  11417. this._stop( event, index );
  11418. this._change( event, index );
  11419. $( event.target ).removeClass( "ui-state-active" );
  11420. }
  11421. }
  11422. }
  11423. });
  11424. }(jQuery));
  11425. (function( $ ) {
  11426. function modifier( fn ) {
  11427. return function() {
  11428. var previous = this.element.val();
  11429. fn.apply( this, arguments );
  11430. this._refresh();
  11431. if ( previous !== this.element.val() ) {
  11432. this._trigger( "change" );
  11433. }
  11434. };
  11435. }
  11436. $.widget( "ui.spinner", {
  11437. version: "1.10.3",
  11438. defaultElement: "<input>",
  11439. widgetEventPrefix: "spin",
  11440. options: {
  11441. culture: null,
  11442. icons: {
  11443. down: "ui-icon-triangle-1-s",
  11444. up: "ui-icon-triangle-1-n"
  11445. },
  11446. incremental: true,
  11447. max: null,
  11448. min: null,
  11449. numberFormat: null,
  11450. page: 10,
  11451. step: 1,
  11452. change: null,
  11453. spin: null,
  11454. start: null,
  11455. stop: null
  11456. },
  11457. _create: function() {
  11458. // handle string values that need to be parsed
  11459. this._setOption( "max", this.options.max );
  11460. this._setOption( "min", this.options.min );
  11461. this._setOption( "step", this.options.step );
  11462. // format the value, but don't constrain
  11463. this._value( this.element.val(), true );
  11464. this._draw();
  11465. this._on( this._events );
  11466. this._refresh();
  11467. // turning off autocomplete prevents the browser from remembering the
  11468. // value when navigating through history, so we re-enable autocomplete
  11469. // if the page is unloaded before the widget is destroyed. #7790
  11470. this._on( this.window, {
  11471. beforeunload: function() {
  11472. this.element.removeAttr( "autocomplete" );
  11473. }
  11474. });
  11475. },
  11476. _getCreateOptions: function() {
  11477. var options = {},
  11478. element = this.element;
  11479. $.each( [ "min", "max", "step" ], function( i, option ) {
  11480. var value = element.attr( option );
  11481. if ( value !== undefined && value.length ) {
  11482. options[ option ] = value;
  11483. }
  11484. });
  11485. return options;
  11486. },
  11487. _events: {
  11488. keydown: function( event ) {
  11489. if ( this._start( event ) && this._keydown( event ) ) {
  11490. event.preventDefault();
  11491. }
  11492. },
  11493. keyup: "_stop",
  11494. focus: function() {
  11495. this.previous = this.element.val();
  11496. },
  11497. blur: function( event ) {
  11498. if ( this.cancelBlur ) {
  11499. delete this.cancelBlur;
  11500. return;
  11501. }
  11502. this._stop();
  11503. this._refresh();
  11504. if ( this.previous !== this.element.val() ) {
  11505. this._trigger( "change", event );
  11506. }
  11507. },
  11508. mousewheel: function( event, delta ) {
  11509. if ( !delta ) {
  11510. return;
  11511. }
  11512. if ( !this.spinning && !this._start( event ) ) {
  11513. return false;
  11514. }
  11515. this._spin( (delta > 0 ? 1 : -1) * this.options.step, event );
  11516. clearTimeout( this.mousewheelTimer );
  11517. this.mousewheelTimer = this._delay(function() {
  11518. if ( this.spinning ) {
  11519. this._stop( event );
  11520. }
  11521. }, 100 );
  11522. event.preventDefault();
  11523. },
  11524. "mousedown .ui-spinner-button": function( event ) {
  11525. var previous;
  11526. // We never want the buttons to have focus; whenever the user is
  11527. // interacting with the spinner, the focus should be on the input.
  11528. // If the input is focused then this.previous is properly set from
  11529. // when the input first received focus. If the input is not focused
  11530. // then we need to set this.previous based on the value before spinning.
  11531. previous = this.element[0] === this.document[0].activeElement ?
  11532. this.previous : this.element.val();
  11533. function checkFocus() {
  11534. var isActive = this.element[0] === this.document[0].activeElement;
  11535. if ( !isActive ) {
  11536. this.element.focus();
  11537. this.previous = previous;
  11538. // support: IE
  11539. // IE sets focus asynchronously, so we need to check if focus
  11540. // moved off of the input because the user clicked on the button.
  11541. this._delay(function() {
  11542. this.previous = previous;
  11543. });
  11544. }
  11545. }
  11546. // ensure focus is on (or stays on) the text field
  11547. event.preventDefault();
  11548. checkFocus.call( this );
  11549. // support: IE
  11550. // IE doesn't prevent moving focus even with event.preventDefault()
  11551. // so we set a flag to know when we should ignore the blur event
  11552. // and check (again) if focus moved off of the input.
  11553. this.cancelBlur = true;
  11554. this._delay(function() {
  11555. delete this.cancelBlur;
  11556. checkFocus.call( this );
  11557. });
  11558. if ( this._start( event ) === false ) {
  11559. return;
  11560. }
  11561. this._repeat( null, $( event.currentTarget ).hasClass( "ui-spinner-up" ) ? 1 : -1, event );
  11562. },
  11563. "mouseup .ui-spinner-button": "_stop",
  11564. "mouseenter .ui-spinner-button": function( event ) {
  11565. // button will add ui-state-active if mouse was down while mouseleave and kept down
  11566. if ( !$( event.currentTarget ).hasClass( "ui-state-active" ) ) {
  11567. return;
  11568. }
  11569. if ( this._start( event ) === false ) {
  11570. return false;
  11571. }
  11572. this._repeat( null, $( event.currentTarget ).hasClass( "ui-spinner-up" ) ? 1 : -1, event );
  11573. },
  11574. // TODO: do we really want to consider this a stop?
  11575. // shouldn't we just stop the repeater and wait until mouseup before
  11576. // we trigger the stop event?
  11577. "mouseleave .ui-spinner-button": "_stop"
  11578. },
  11579. _draw: function() {
  11580. var uiSpinner = this.uiSpinner = this.element
  11581. .addClass( "ui-spinner-input" )
  11582. .attr( "autocomplete", "off" )
  11583. .wrap( this._uiSpinnerHtml() )
  11584. .parent()
  11585. // add buttons
  11586. .append( this._buttonHtml() );
  11587. this.element.attr( "role", "spinbutton" );
  11588. // button bindings
  11589. this.buttons = uiSpinner.find( ".ui-spinner-button" )
  11590. .attr( "tabIndex", -1 )
  11591. .button()
  11592. .removeClass( "ui-corner-all" );
  11593. // IE 6 doesn't understand height: 50% for the buttons
  11594. // unless the wrapper has an explicit height
  11595. if ( this.buttons.height() > Math.ceil( uiSpinner.height() * 0.5 ) &&
  11596. uiSpinner.height() > 0 ) {
  11597. uiSpinner.height( uiSpinner.height() );
  11598. }
  11599. // disable spinner if element was already disabled
  11600. if ( this.options.disabled ) {
  11601. this.disable();
  11602. }
  11603. },
  11604. _keydown: function( event ) {
  11605. var options = this.options,
  11606. keyCode = $.ui.keyCode;
  11607. switch ( event.keyCode ) {
  11608. case keyCode.UP:
  11609. this._repeat( null, 1, event );
  11610. return true;
  11611. case keyCode.DOWN:
  11612. this._repeat( null, -1, event );
  11613. return true;
  11614. case keyCode.PAGE_UP:
  11615. this._repeat( null, options.page, event );
  11616. return true;
  11617. case keyCode.PAGE_DOWN:
  11618. this._repeat( null, -options.page, event );
  11619. return true;
  11620. }
  11621. return false;
  11622. },
  11623. _uiSpinnerHtml: function() {
  11624. return "<span class='ui-spinner ui-widget ui-widget-content ui-corner-all'></span>";
  11625. },
  11626. _buttonHtml: function() {
  11627. return "" +
  11628. "<a class='ui-spinner-button ui-spinner-up ui-corner-tr'>" +
  11629. "<span class='ui-icon " + this.options.icons.up + "'>&#9650;</span>" +
  11630. "</a>" +
  11631. "<a class='ui-spinner-button ui-spinner-down ui-corner-br'>" +
  11632. "<span class='ui-icon " + this.options.icons.down + "'>&#9660;</span>" +
  11633. "</a>";
  11634. },
  11635. _start: function( event ) {
  11636. if ( !this.spinning && this._trigger( "start", event ) === false ) {
  11637. return false;
  11638. }
  11639. if ( !this.counter ) {
  11640. this.counter = 1;
  11641. }
  11642. this.spinning = true;
  11643. return true;
  11644. },
  11645. _repeat: function( i, steps, event ) {
  11646. i = i || 500;
  11647. clearTimeout( this.timer );
  11648. this.timer = this._delay(function() {
  11649. this._repeat( 40, steps, event );
  11650. }, i );
  11651. this._spin( steps * this.options.step, event );
  11652. },
  11653. _spin: function( step, event ) {
  11654. var value = this.value() || 0;
  11655. if ( !this.counter ) {
  11656. this.counter = 1;
  11657. }
  11658. value = this._adjustValue( value + step * this._increment( this.counter ) );
  11659. if ( !this.spinning || this._trigger( "spin", event, { value: value } ) !== false) {
  11660. this._value( value );
  11661. this.counter++;
  11662. }
  11663. },
  11664. _increment: function( i ) {
  11665. var incremental = this.options.incremental;
  11666. if ( incremental ) {
  11667. return $.isFunction( incremental ) ?
  11668. incremental( i ) :
  11669. Math.floor( i*i*i/50000 - i*i/500 + 17*i/200 + 1 );
  11670. }
  11671. return 1;
  11672. },
  11673. _precision: function() {
  11674. var precision = this._precisionOf( this.options.step );
  11675. if ( this.options.min !== null ) {
  11676. precision = Math.max( precision, this._precisionOf( this.options.min ) );
  11677. }
  11678. return precision;
  11679. },
  11680. _precisionOf: function( num ) {
  11681. var str = num.toString(),
  11682. decimal = str.indexOf( "." );
  11683. return decimal === -1 ? 0 : str.length - decimal - 1;
  11684. },
  11685. _adjustValue: function( value ) {
  11686. var base, aboveMin,
  11687. options = this.options;
  11688. // make sure we're at a valid step
  11689. // - find out where we are relative to the base (min or 0)
  11690. base = options.min !== null ? options.min : 0;
  11691. aboveMin = value - base;
  11692. // - round to the nearest step
  11693. aboveMin = Math.round(aboveMin / options.step) * options.step;
  11694. // - rounding is based on 0, so adjust back to our base
  11695. value = base + aboveMin;
  11696. // fix precision from bad JS floating point math
  11697. value = parseFloat( value.toFixed( this._precision() ) );
  11698. // clamp the value
  11699. if ( options.max !== null && value > options.max) {
  11700. return options.max;
  11701. }
  11702. if ( options.min !== null && value < options.min ) {
  11703. return options.min;
  11704. }
  11705. return value;
  11706. },
  11707. _stop: function( event ) {
  11708. if ( !this.spinning ) {
  11709. return;
  11710. }
  11711. clearTimeout( this.timer );
  11712. clearTimeout( this.mousewheelTimer );
  11713. this.counter = 0;
  11714. this.spinning = false;
  11715. this._trigger( "stop", event );
  11716. },
  11717. _setOption: function( key, value ) {
  11718. if ( key === "culture" || key === "numberFormat" ) {
  11719. var prevValue = this._parse( this.element.val() );
  11720. this.options[ key ] = value;
  11721. this.element.val( this._format( prevValue ) );
  11722. return;
  11723. }
  11724. if ( key === "max" || key === "min" || key === "step" ) {
  11725. if ( typeof value === "string" ) {
  11726. value = this._parse( value );
  11727. }
  11728. }
  11729. if ( key === "icons" ) {
  11730. this.buttons.first().find( ".ui-icon" )
  11731. .removeClass( this.options.icons.up )
  11732. .addClass( value.up );
  11733. this.buttons.last().find( ".ui-icon" )
  11734. .removeClass( this.options.icons.down )
  11735. .addClass( value.down );
  11736. }
  11737. this._super( key, value );
  11738. if ( key === "disabled" ) {
  11739. if ( value ) {
  11740. this.element.prop( "disabled", true );
  11741. this.buttons.button( "disable" );
  11742. } else {
  11743. this.element.prop( "disabled", false );
  11744. this.buttons.button( "enable" );
  11745. }
  11746. }
  11747. },
  11748. _setOptions: modifier(function( options ) {
  11749. this._super( options );
  11750. this._value( this.element.val() );
  11751. }),
  11752. _parse: function( val ) {
  11753. if ( typeof val === "string" && val !== "" ) {
  11754. val = window.Globalize && this.options.numberFormat ?
  11755. Globalize.parseFloat( val, 10, this.options.culture ) : +val;
  11756. }
  11757. return val === "" || isNaN( val ) ? null : val;
  11758. },
  11759. _format: function( value ) {
  11760. if ( value === "" ) {
  11761. return "";
  11762. }
  11763. return window.Globalize && this.options.numberFormat ?
  11764. Globalize.format( value, this.options.numberFormat, this.options.culture ) :
  11765. value;
  11766. },
  11767. _refresh: function() {
  11768. this.element.attr({
  11769. "aria-valuemin": this.options.min,
  11770. "aria-valuemax": this.options.max,
  11771. // TODO: what should we do with values that can't be parsed?
  11772. "aria-valuenow": this._parse( this.element.val() )
  11773. });
  11774. },
  11775. // update the value without triggering change
  11776. _value: function( value, allowAny ) {
  11777. var parsed;
  11778. if ( value !== "" ) {
  11779. parsed = this._parse( value );
  11780. if ( parsed !== null ) {
  11781. if ( !allowAny ) {
  11782. parsed = this._adjustValue( parsed );
  11783. }
  11784. value = this._format( parsed );
  11785. }
  11786. }
  11787. this.element.val( value );
  11788. this._refresh();
  11789. },
  11790. _destroy: function() {
  11791. this.element
  11792. .removeClass( "ui-spinner-input" )
  11793. .prop( "disabled", false )
  11794. .removeAttr( "autocomplete" )
  11795. .removeAttr( "role" )
  11796. .removeAttr( "aria-valuemin" )
  11797. .removeAttr( "aria-valuemax" )
  11798. .removeAttr( "aria-valuenow" );
  11799. this.uiSpinner.replaceWith( this.element );
  11800. },
  11801. stepUp: modifier(function( steps ) {
  11802. this._stepUp( steps );
  11803. }),
  11804. _stepUp: function( steps ) {
  11805. if ( this._start() ) {
  11806. this._spin( (steps || 1) * this.options.step );
  11807. this._stop();
  11808. }
  11809. },
  11810. stepDown: modifier(function( steps ) {
  11811. this._stepDown( steps );
  11812. }),
  11813. _stepDown: function( steps ) {
  11814. if ( this._start() ) {
  11815. this._spin( (steps || 1) * -this.options.step );
  11816. this._stop();
  11817. }
  11818. },
  11819. pageUp: modifier(function( pages ) {
  11820. this._stepUp( (pages || 1) * this.options.page );
  11821. }),
  11822. pageDown: modifier(function( pages ) {
  11823. this._stepDown( (pages || 1) * this.options.page );
  11824. }),
  11825. value: function( newVal ) {
  11826. if ( !arguments.length ) {
  11827. return this._parse( this.element.val() );
  11828. }
  11829. modifier( this._value ).call( this, newVal );
  11830. },
  11831. widget: function() {
  11832. return this.uiSpinner;
  11833. }
  11834. });
  11835. }( jQuery ) );
  11836. (function( $, undefined ) {
  11837. var tabId = 0,
  11838. rhash = /#.*$/;
  11839. function getNextTabId() {
  11840. return ++tabId;
  11841. }
  11842. function isLocal( anchor ) {
  11843. return anchor.hash.length > 1 &&
  11844. decodeURIComponent( anchor.href.replace( rhash, "" ) ) ===
  11845. decodeURIComponent( location.href.replace( rhash, "" ) );
  11846. }
  11847. $.widget( "ui.tabs", {
  11848. version: "1.10.3",
  11849. delay: 300,
  11850. options: {
  11851. active: null,
  11852. collapsible: false,
  11853. event: "click",
  11854. heightStyle: "content",
  11855. hide: null,
  11856. show: null,
  11857. // callbacks
  11858. activate: null,
  11859. beforeActivate: null,
  11860. beforeLoad: null,
  11861. load: null
  11862. },
  11863. _create: function() {
  11864. var that = this,
  11865. options = this.options;
  11866. this.running = false;
  11867. this.element
  11868. .addClass( "ui-tabs ui-widget ui-widget-content ui-corner-all" )
  11869. .toggleClass( "ui-tabs-collapsible", options.collapsible )
  11870. // Prevent users from focusing disabled tabs via click
  11871. .delegate( ".ui-tabs-nav > li", "mousedown" + this.eventNamespace, function( event ) {
  11872. if ( $( this ).is( ".ui-state-disabled" ) ) {
  11873. event.preventDefault();
  11874. }
  11875. })
  11876. // support: IE <9
  11877. // Preventing the default action in mousedown doesn't prevent IE
  11878. // from focusing the element, so if the anchor gets focused, blur.
  11879. // We don't have to worry about focusing the previously focused
  11880. // element since clicking on a non-focusable element should focus
  11881. // the body anyway.
  11882. .delegate( ".ui-tabs-anchor", "focus" + this.eventNamespace, function() {
  11883. if ( $( this ).closest( "li" ).is( ".ui-state-disabled" ) ) {
  11884. this.blur();
  11885. }
  11886. });
  11887. this._processTabs();
  11888. options.active = this._initialActive();
  11889. // Take disabling tabs via class attribute from HTML
  11890. // into account and update option properly.
  11891. if ( $.isArray( options.disabled ) ) {
  11892. options.disabled = $.unique( options.disabled.concat(
  11893. $.map( this.tabs.filter( ".ui-state-disabled" ), function( li ) {
  11894. return that.tabs.index( li );
  11895. })
  11896. ) ).sort();
  11897. }
  11898. // check for length avoids error when initializing empty list
  11899. if ( this.options.active !== false && this.anchors.length ) {
  11900. this.active = this._findActive( options.active );
  11901. } else {
  11902. this.active = $();
  11903. }
  11904. this._refresh();
  11905. if ( this.active.length ) {
  11906. this.load( options.active );
  11907. }
  11908. },
  11909. _initialActive: function() {
  11910. var active = this.options.active,
  11911. collapsible = this.options.collapsible,
  11912. locationHash = location.hash.substring( 1 );
  11913. if ( active === null ) {
  11914. // check the fragment identifier in the URL
  11915. if ( locationHash ) {
  11916. this.tabs.each(function( i, tab ) {
  11917. if ( $( tab ).attr( "aria-controls" ) === locationHash ) {
  11918. active = i;
  11919. return false;
  11920. }
  11921. });
  11922. }
  11923. // check for a tab marked active via a class
  11924. if ( active === null ) {
  11925. active = this.tabs.index( this.tabs.filter( ".ui-tabs-active" ) );
  11926. }
  11927. // no active tab, set to false
  11928. if ( active === null || active === -1 ) {
  11929. active = this.tabs.length ? 0 : false;
  11930. }
  11931. }
  11932. // handle numbers: negative, out of range
  11933. if ( active !== false ) {
  11934. active = this.tabs.index( this.tabs.eq( active ) );
  11935. if ( active === -1 ) {
  11936. active = collapsible ? false : 0;
  11937. }
  11938. }
  11939. // don't allow collapsible: false and active: false
  11940. if ( !collapsible && active === false && this.anchors.length ) {
  11941. active = 0;
  11942. }
  11943. return active;
  11944. },
  11945. _getCreateEventData: function() {
  11946. return {
  11947. tab: this.active,
  11948. panel: !this.active.length ? $() : this._getPanelForTab( this.active )
  11949. };
  11950. },
  11951. _tabKeydown: function( event ) {
  11952. /*jshint maxcomplexity:15*/
  11953. var focusedTab = $( this.document[0].activeElement ).closest( "li" ),
  11954. selectedIndex = this.tabs.index( focusedTab ),
  11955. goingForward = true;
  11956. if ( this._handlePageNav( event ) ) {
  11957. return;
  11958. }
  11959. switch ( event.keyCode ) {
  11960. case $.ui.keyCode.RIGHT:
  11961. case $.ui.keyCode.DOWN:
  11962. selectedIndex++;
  11963. break;
  11964. case $.ui.keyCode.UP:
  11965. case $.ui.keyCode.LEFT:
  11966. goingForward = false;
  11967. selectedIndex--;
  11968. break;
  11969. case $.ui.keyCode.END:
  11970. selectedIndex = this.anchors.length - 1;
  11971. break;
  11972. case $.ui.keyCode.HOME:
  11973. selectedIndex = 0;
  11974. break;
  11975. case $.ui.keyCode.SPACE:
  11976. // Activate only, no collapsing
  11977. event.preventDefault();
  11978. clearTimeout( this.activating );
  11979. this._activate( selectedIndex );
  11980. return;
  11981. case $.ui.keyCode.ENTER:
  11982. // Toggle (cancel delayed activation, allow collapsing)
  11983. event.preventDefault();
  11984. clearTimeout( this.activating );
  11985. // Determine if we should collapse or activate
  11986. this._activate( selectedIndex === this.options.active ? false : selectedIndex );
  11987. return;
  11988. default:
  11989. return;
  11990. }
  11991. // Focus the appropriate tab, based on which key was pressed
  11992. event.preventDefault();
  11993. clearTimeout( this.activating );
  11994. selectedIndex = this._focusNextTab( selectedIndex, goingForward );
  11995. // Navigating with control key will prevent automatic activation
  11996. if ( !event.ctrlKey ) {
  11997. // Update aria-selected immediately so that AT think the tab is already selected.
  11998. // Otherwise AT may confuse the user by stating that they need to activate the tab,
  11999. // but the tab will already be activated by the time the announcement finishes.
  12000. focusedTab.attr( "aria-selected", "false" );
  12001. this.tabs.eq( selectedIndex ).attr( "aria-selected", "true" );
  12002. this.activating = this._delay(function() {
  12003. this.option( "active", selectedIndex );
  12004. }, this.delay );
  12005. }
  12006. },
  12007. _panelKeydown: function( event ) {
  12008. if ( this._handlePageNav( event ) ) {
  12009. return;
  12010. }
  12011. // Ctrl+up moves focus to the current tab
  12012. if ( event.ctrlKey && event.keyCode === $.ui.keyCode.UP ) {
  12013. event.preventDefault();
  12014. this.active.focus();
  12015. }
  12016. },
  12017. // Alt+page up/down moves focus to the previous/next tab (and activates)
  12018. _handlePageNav: function( event ) {
  12019. if ( event.altKey && event.keyCode === $.ui.keyCode.PAGE_UP ) {
  12020. this._activate( this._focusNextTab( this.options.active - 1, false ) );
  12021. return true;
  12022. }
  12023. if ( event.altKey && event.keyCode === $.ui.keyCode.PAGE_DOWN ) {
  12024. this._activate( this._focusNextTab( this.options.active + 1, true ) );
  12025. return true;
  12026. }
  12027. },
  12028. _findNextTab: function( index, goingForward ) {
  12029. var lastTabIndex = this.tabs.length - 1;
  12030. function constrain() {
  12031. if ( index > lastTabIndex ) {
  12032. index = 0;
  12033. }
  12034. if ( index < 0 ) {
  12035. index = lastTabIndex;
  12036. }
  12037. return index;
  12038. }
  12039. while ( $.inArray( constrain(), this.options.disabled ) !== -1 ) {
  12040. index = goingForward ? index + 1 : index - 1;
  12041. }
  12042. return index;
  12043. },
  12044. _focusNextTab: function( index, goingForward ) {
  12045. index = this._findNextTab( index, goingForward );
  12046. this.tabs.eq( index ).focus();
  12047. return index;
  12048. },
  12049. _setOption: function( key, value ) {
  12050. if ( key === "active" ) {
  12051. // _activate() will handle invalid values and update this.options
  12052. this._activate( value );
  12053. return;
  12054. }
  12055. if ( key === "disabled" ) {
  12056. // don't use the widget factory's disabled handling
  12057. this._setupDisabled( value );
  12058. return;
  12059. }
  12060. this._super( key, value);
  12061. if ( key === "collapsible" ) {
  12062. this.element.toggleClass( "ui-tabs-collapsible", value );
  12063. // Setting collapsible: false while collapsed; open first panel
  12064. if ( !value && this.options.active === false ) {
  12065. this._activate( 0 );
  12066. }
  12067. }
  12068. if ( key === "event" ) {
  12069. this._setupEvents( value );
  12070. }
  12071. if ( key === "heightStyle" ) {
  12072. this._setupHeightStyle( value );
  12073. }
  12074. },
  12075. _tabId: function( tab ) {
  12076. return tab.attr( "aria-controls" ) || "ui-tabs-" + getNextTabId();
  12077. },
  12078. _sanitizeSelector: function( hash ) {
  12079. return hash ? hash.replace( /[!"$%&'()*+,.\/:;<=>?@\[\]\^`{|}~]/g, "\\$&" ) : "";
  12080. },
  12081. refresh: function() {
  12082. var options = this.options,
  12083. lis = this.tablist.children( ":has(a[href])" );
  12084. // get disabled tabs from class attribute from HTML
  12085. // this will get converted to a boolean if needed in _refresh()
  12086. options.disabled = $.map( lis.filter( ".ui-state-disabled" ), function( tab ) {
  12087. return lis.index( tab );
  12088. });
  12089. this._processTabs();
  12090. // was collapsed or no tabs
  12091. if ( options.active === false || !this.anchors.length ) {
  12092. options.active = false;
  12093. this.active = $();
  12094. // was active, but active tab is gone
  12095. } else if ( this.active.length && !$.contains( this.tablist[ 0 ], this.active[ 0 ] ) ) {
  12096. // all remaining tabs are disabled
  12097. if ( this.tabs.length === options.disabled.length ) {
  12098. options.active = false;
  12099. this.active = $();
  12100. // activate previous tab
  12101. } else {
  12102. this._activate( this._findNextTab( Math.max( 0, options.active - 1 ), false ) );
  12103. }
  12104. // was active, active tab still exists
  12105. } else {
  12106. // make sure active index is correct
  12107. options.active = this.tabs.index( this.active );
  12108. }
  12109. this._refresh();
  12110. },
  12111. _refresh: function() {
  12112. this._setupDisabled( this.options.disabled );
  12113. this._setupEvents( this.options.event );
  12114. this._setupHeightStyle( this.options.heightStyle );
  12115. this.tabs.not( this.active ).attr({
  12116. "aria-selected": "false",
  12117. tabIndex: -1
  12118. });
  12119. this.panels.not( this._getPanelForTab( this.active ) )
  12120. .hide()
  12121. .attr({
  12122. "aria-expanded": "false",
  12123. "aria-hidden": "true"
  12124. });
  12125. // Make sure one tab is in the tab order
  12126. if ( !this.active.length ) {
  12127. this.tabs.eq( 0 ).attr( "tabIndex", 0 );
  12128. } else {
  12129. this.active
  12130. .addClass( "ui-tabs-active ui-state-active" )
  12131. .attr({
  12132. "aria-selected": "true",
  12133. tabIndex: 0
  12134. });
  12135. this._getPanelForTab( this.active )
  12136. .show()
  12137. .attr({
  12138. "aria-expanded": "true",
  12139. "aria-hidden": "false"
  12140. });
  12141. }
  12142. },
  12143. _processTabs: function() {
  12144. var that = this;
  12145. this.tablist = this._getList()
  12146. .addClass( "ui-tabs-nav ui-helper-reset ui-helper-clearfix ui-widget-header ui-corner-all" )
  12147. .attr( "role", "tablist" );
  12148. this.tabs = this.tablist.find( "> li:has(a[href])" )
  12149. .addClass( "ui-state-default ui-corner-top" )
  12150. .attr({
  12151. role: "tab",
  12152. tabIndex: -1
  12153. });
  12154. this.anchors = this.tabs.map(function() {
  12155. return $( "a", this )[ 0 ];
  12156. })
  12157. .addClass( "ui-tabs-anchor" )
  12158. .attr({
  12159. role: "presentation",
  12160. tabIndex: -1
  12161. });
  12162. this.panels = $();
  12163. this.anchors.each(function( i, anchor ) {
  12164. var selector, panel, panelId,
  12165. anchorId = $( anchor ).uniqueId().attr( "id" ),
  12166. tab = $( anchor ).closest( "li" ),
  12167. originalAriaControls = tab.attr( "aria-controls" );
  12168. // inline tab
  12169. if ( isLocal( anchor ) ) {
  12170. selector = anchor.hash;
  12171. panel = that.element.find( that._sanitizeSelector( selector ) );
  12172. // remote tab
  12173. } else {
  12174. panelId = that._tabId( tab );
  12175. selector = "#" + panelId;
  12176. panel = that.element.find( selector );
  12177. if ( !panel.length ) {
  12178. panel = that._createPanel( panelId );
  12179. panel.insertAfter( that.panels[ i - 1 ] || that.tablist );
  12180. }
  12181. panel.attr( "aria-live", "polite" );
  12182. }
  12183. if ( panel.length) {
  12184. that.panels = that.panels.add( panel );
  12185. }
  12186. if ( originalAriaControls ) {
  12187. tab.data( "ui-tabs-aria-controls", originalAriaControls );
  12188. }
  12189. tab.attr({
  12190. "aria-controls": selector.substring( 1 ),
  12191. "aria-labelledby": anchorId
  12192. });
  12193. panel.attr( "aria-labelledby", anchorId );
  12194. });
  12195. this.panels
  12196. .addClass( "ui-tabs-panel ui-widget-content ui-corner-bottom" )
  12197. .attr( "role", "tabpanel" );
  12198. },
  12199. // allow overriding how to find the list for rare usage scenarios (#7715)
  12200. _getList: function() {
  12201. return this.element.find( "ol,ul" ).eq( 0 );
  12202. },
  12203. _createPanel: function( id ) {
  12204. return $( "<div>" )
  12205. .attr( "id", id )
  12206. .addClass( "ui-tabs-panel ui-widget-content ui-corner-bottom" )
  12207. .data( "ui-tabs-destroy", true );
  12208. },
  12209. _setupDisabled: function( disabled ) {
  12210. if ( $.isArray( disabled ) ) {
  12211. if ( !disabled.length ) {
  12212. disabled = false;
  12213. } else if ( disabled.length === this.anchors.length ) {
  12214. disabled = true;
  12215. }
  12216. }
  12217. // disable tabs
  12218. for ( var i = 0, li; ( li = this.tabs[ i ] ); i++ ) {
  12219. if ( disabled === true || $.inArray( i, disabled ) !== -1 ) {
  12220. $( li )
  12221. .addClass( "ui-state-disabled" )
  12222. .attr( "aria-disabled", "true" );
  12223. } else {
  12224. $( li )
  12225. .removeClass( "ui-state-disabled" )
  12226. .removeAttr( "aria-disabled" );
  12227. }
  12228. }
  12229. this.options.disabled = disabled;
  12230. },
  12231. _setupEvents: function( event ) {
  12232. var events = {
  12233. click: function( event ) {
  12234. event.preventDefault();
  12235. }
  12236. };
  12237. if ( event ) {
  12238. $.each( event.split(" "), function( index, eventName ) {
  12239. events[ eventName ] = "_eventHandler";
  12240. });
  12241. }
  12242. this._off( this.anchors.add( this.tabs ).add( this.panels ) );
  12243. this._on( this.anchors, events );
  12244. this._on( this.tabs, { keydown: "_tabKeydown" } );
  12245. this._on( this.panels, { keydown: "_panelKeydown" } );
  12246. this._focusable( this.tabs );
  12247. this._hoverable( this.tabs );
  12248. },
  12249. _setupHeightStyle: function( heightStyle ) {
  12250. var maxHeight,
  12251. parent = this.element.parent();
  12252. if ( heightStyle === "fill" ) {
  12253. maxHeight = parent.height();
  12254. maxHeight -= this.element.outerHeight() - this.element.height();
  12255. this.element.siblings( ":visible" ).each(function() {
  12256. var elem = $( this ),
  12257. position = elem.css( "position" );
  12258. if ( position === "absolute" || position === "fixed" ) {
  12259. return;
  12260. }
  12261. maxHeight -= elem.outerHeight( true );
  12262. });
  12263. this.element.children().not( this.panels ).each(function() {
  12264. maxHeight -= $( this ).outerHeight( true );
  12265. });
  12266. this.panels.each(function() {
  12267. $( this ).height( Math.max( 0, maxHeight -
  12268. $( this ).innerHeight() + $( this ).height() ) );
  12269. })
  12270. .css( "overflow", "auto" );
  12271. } else if ( heightStyle === "auto" ) {
  12272. maxHeight = 0;
  12273. this.panels.each(function() {
  12274. maxHeight = Math.max( maxHeight, $( this ).height( "" ).height() );
  12275. }).height( maxHeight );
  12276. }
  12277. },
  12278. _eventHandler: function( event ) {
  12279. var options = this.options,
  12280. active = this.active,
  12281. anchor = $( event.currentTarget ),
  12282. tab = anchor.closest( "li" ),
  12283. clickedIsActive = tab[ 0 ] === active[ 0 ],
  12284. collapsing = clickedIsActive && options.collapsible,
  12285. toShow = collapsing ? $() : this._getPanelForTab( tab ),
  12286. toHide = !active.length ? $() : this._getPanelForTab( active ),
  12287. eventData = {
  12288. oldTab: active,
  12289. oldPanel: toHide,
  12290. newTab: collapsing ? $() : tab,
  12291. newPanel: toShow
  12292. };
  12293. event.preventDefault();
  12294. if ( tab.hasClass( "ui-state-disabled" ) ||
  12295. // tab is already loading
  12296. tab.hasClass( "ui-tabs-loading" ) ||
  12297. // can't switch durning an animation
  12298. this.running ||
  12299. // click on active header, but not collapsible
  12300. ( clickedIsActive && !options.collapsible ) ||
  12301. // allow canceling activation
  12302. ( this._trigger( "beforeActivate", event, eventData ) === false ) ) {
  12303. return;
  12304. }
  12305. options.active = collapsing ? false : this.tabs.index( tab );
  12306. this.active = clickedIsActive ? $() : tab;
  12307. if ( this.xhr ) {
  12308. this.xhr.abort();
  12309. }
  12310. if ( !toHide.length && !toShow.length ) {
  12311. $.error( "jQuery UI Tabs: Mismatching fragment identifier." );
  12312. }
  12313. if ( toShow.length ) {
  12314. this.load( this.tabs.index( tab ), event );
  12315. }
  12316. this._toggle( event, eventData );
  12317. },
  12318. // handles show/hide for selecting tabs
  12319. _toggle: function( event, eventData ) {
  12320. var that = this,
  12321. toShow = eventData.newPanel,
  12322. toHide = eventData.oldPanel;
  12323. this.running = true;
  12324. function complete() {
  12325. that.running = false;
  12326. that._trigger( "activate", event, eventData );
  12327. }
  12328. function show() {
  12329. eventData.newTab.closest( "li" ).addClass( "ui-tabs-active ui-state-active" );
  12330. if ( toShow.length && that.options.show ) {
  12331. that._show( toShow, that.options.show, complete );
  12332. } else {
  12333. toShow.show();
  12334. complete();
  12335. }
  12336. }
  12337. // start out by hiding, then showing, then completing
  12338. if ( toHide.length && this.options.hide ) {
  12339. this._hide( toHide, this.options.hide, function() {
  12340. eventData.oldTab.closest( "li" ).removeClass( "ui-tabs-active ui-state-active" );
  12341. show();
  12342. });
  12343. } else {
  12344. eventData.oldTab.closest( "li" ).removeClass( "ui-tabs-active ui-state-active" );
  12345. toHide.hide();
  12346. show();
  12347. }
  12348. toHide.attr({
  12349. "aria-expanded": "false",
  12350. "aria-hidden": "true"
  12351. });
  12352. eventData.oldTab.attr( "aria-selected", "false" );
  12353. // If we're switching tabs, remove the old tab from the tab order.
  12354. // If we're opening from collapsed state, remove the previous tab from the tab order.
  12355. // If we're collapsing, then keep the collapsing tab in the tab order.
  12356. if ( toShow.length && toHide.length ) {
  12357. eventData.oldTab.attr( "tabIndex", -1 );
  12358. } else if ( toShow.length ) {
  12359. this.tabs.filter(function() {
  12360. return $( this ).attr( "tabIndex" ) === 0;
  12361. })
  12362. .attr( "tabIndex", -1 );
  12363. }
  12364. toShow.attr({
  12365. "aria-expanded": "true",
  12366. "aria-hidden": "false"
  12367. });
  12368. eventData.newTab.attr({
  12369. "aria-selected": "true",
  12370. tabIndex: 0
  12371. });
  12372. },
  12373. _activate: function( index ) {
  12374. var anchor,
  12375. active = this._findActive( index );
  12376. // trying to activate the already active panel
  12377. if ( active[ 0 ] === this.active[ 0 ] ) {
  12378. return;
  12379. }
  12380. // trying to collapse, simulate a click on the current active header
  12381. if ( !active.length ) {
  12382. active = this.active;
  12383. }
  12384. anchor = active.find( ".ui-tabs-anchor" )[ 0 ];
  12385. this._eventHandler({
  12386. target: anchor,
  12387. currentTarget: anchor,
  12388. preventDefault: $.noop
  12389. });
  12390. },
  12391. _findActive: function( index ) {
  12392. return index === false ? $() : this.tabs.eq( index );
  12393. },
  12394. _getIndex: function( index ) {
  12395. // meta-function to give users option to provide a href string instead of a numerical index.
  12396. if ( typeof index === "string" ) {
  12397. index = this.anchors.index( this.anchors.filter( "[href$='" + index + "']" ) );
  12398. }
  12399. return index;
  12400. },
  12401. _destroy: function() {
  12402. if ( this.xhr ) {
  12403. this.xhr.abort();
  12404. }
  12405. this.element.removeClass( "ui-tabs ui-widget ui-widget-content ui-corner-all ui-tabs-collapsible" );
  12406. this.tablist
  12407. .removeClass( "ui-tabs-nav ui-helper-reset ui-helper-clearfix ui-widget-header ui-corner-all" )
  12408. .removeAttr( "role" );
  12409. this.anchors
  12410. .removeClass( "ui-tabs-anchor" )
  12411. .removeAttr( "role" )
  12412. .removeAttr( "tabIndex" )
  12413. .removeUniqueId();
  12414. this.tabs.add( this.panels ).each(function() {
  12415. if ( $.data( this, "ui-tabs-destroy" ) ) {
  12416. $( this ).remove();
  12417. } else {
  12418. $( this )
  12419. .removeClass( "ui-state-default ui-state-active ui-state-disabled " +
  12420. "ui-corner-top ui-corner-bottom ui-widget-content ui-tabs-active ui-tabs-panel" )
  12421. .removeAttr( "tabIndex" )
  12422. .removeAttr( "aria-live" )
  12423. .removeAttr( "aria-busy" )
  12424. .removeAttr( "aria-selected" )
  12425. .removeAttr( "aria-labelledby" )
  12426. .removeAttr( "aria-hidden" )
  12427. .removeAttr( "aria-expanded" )
  12428. .removeAttr( "role" );
  12429. }
  12430. });
  12431. this.tabs.each(function() {
  12432. var li = $( this ),
  12433. prev = li.data( "ui-tabs-aria-controls" );
  12434. if ( prev ) {
  12435. li
  12436. .attr( "aria-controls", prev )
  12437. .removeData( "ui-tabs-aria-controls" );
  12438. } else {
  12439. li.removeAttr( "aria-controls" );
  12440. }
  12441. });
  12442. this.panels.show();
  12443. if ( this.options.heightStyle !== "content" ) {
  12444. this.panels.css( "height", "" );
  12445. }
  12446. },
  12447. enable: function( index ) {
  12448. var disabled = this.options.disabled;
  12449. if ( disabled === false ) {
  12450. return;
  12451. }
  12452. if ( index === undefined ) {
  12453. disabled = false;
  12454. } else {
  12455. index = this._getIndex( index );
  12456. if ( $.isArray( disabled ) ) {
  12457. disabled = $.map( disabled, function( num ) {
  12458. return num !== index ? num : null;
  12459. });
  12460. } else {
  12461. disabled = $.map( this.tabs, function( li, num ) {
  12462. return num !== index ? num : null;
  12463. });
  12464. }
  12465. }
  12466. this._setupDisabled( disabled );
  12467. },
  12468. disable: function( index ) {
  12469. var disabled = this.options.disabled;
  12470. if ( disabled === true ) {
  12471. return;
  12472. }
  12473. if ( index === undefined ) {
  12474. disabled = true;
  12475. } else {
  12476. index = this._getIndex( index );
  12477. if ( $.inArray( index, disabled ) !== -1 ) {
  12478. return;
  12479. }
  12480. if ( $.isArray( disabled ) ) {
  12481. disabled = $.merge( [ index ], disabled ).sort();
  12482. } else {
  12483. disabled = [ index ];
  12484. }
  12485. }
  12486. this._setupDisabled( disabled );
  12487. },
  12488. load: function( index, event ) {
  12489. index = this._getIndex( index );
  12490. var that = this,
  12491. tab = this.tabs.eq( index ),
  12492. anchor = tab.find( ".ui-tabs-anchor" ),
  12493. panel = this._getPanelForTab( tab ),
  12494. eventData = {
  12495. tab: tab,
  12496. panel: panel
  12497. };
  12498. // not remote
  12499. if ( isLocal( anchor[ 0 ] ) ) {
  12500. return;
  12501. }
  12502. this.xhr = $.ajax( this._ajaxSettings( anchor, event, eventData ) );
  12503. // support: jQuery <1.8
  12504. // jQuery <1.8 returns false if the request is canceled in beforeSend,
  12505. // but as of 1.8, $.ajax() always returns a jqXHR object.
  12506. if ( this.xhr && this.xhr.statusText !== "canceled" ) {
  12507. tab.addClass( "ui-tabs-loading" );
  12508. panel.attr( "aria-busy", "true" );
  12509. this.xhr
  12510. .success(function( response ) {
  12511. // support: jQuery <1.8
  12512. // http://bugs.jquery.com/ticket/11778
  12513. setTimeout(function() {
  12514. panel.html( response );
  12515. that._trigger( "load", event, eventData );
  12516. }, 1 );
  12517. })
  12518. .complete(function( jqXHR, status ) {
  12519. // support: jQuery <1.8
  12520. // http://bugs.jquery.com/ticket/11778
  12521. setTimeout(function() {
  12522. if ( status === "abort" ) {
  12523. that.panels.stop( false, true );
  12524. }
  12525. tab.removeClass( "ui-tabs-loading" );
  12526. panel.removeAttr( "aria-busy" );
  12527. if ( jqXHR === that.xhr ) {
  12528. delete that.xhr;
  12529. }
  12530. }, 1 );
  12531. });
  12532. }
  12533. },
  12534. _ajaxSettings: function( anchor, event, eventData ) {
  12535. var that = this;
  12536. return {
  12537. url: anchor.attr( "href" ),
  12538. beforeSend: function( jqXHR, settings ) {
  12539. return that._trigger( "beforeLoad", event,
  12540. $.extend( { jqXHR : jqXHR, ajaxSettings: settings }, eventData ) );
  12541. }
  12542. };
  12543. },
  12544. _getPanelForTab: function( tab ) {
  12545. var id = $( tab ).attr( "aria-controls" );
  12546. return this.element.find( this._sanitizeSelector( "#" + id ) );
  12547. }
  12548. });
  12549. })( jQuery );
  12550. (function( $ ) {
  12551. var increments = 0;
  12552. function addDescribedBy( elem, id ) {
  12553. var describedby = (elem.attr( "aria-describedby" ) || "").split( /\s+/ );
  12554. describedby.push( id );
  12555. elem
  12556. .data( "ui-tooltip-id", id )
  12557. .attr( "aria-describedby", $.trim( describedby.join( " " ) ) );
  12558. }
  12559. function removeDescribedBy( elem ) {
  12560. var id = elem.data( "ui-tooltip-id" ),
  12561. describedby = (elem.attr( "aria-describedby" ) || "").split( /\s+/ ),
  12562. index = $.inArray( id, describedby );
  12563. if ( index !== -1 ) {
  12564. describedby.splice( index, 1 );
  12565. }
  12566. elem.removeData( "ui-tooltip-id" );
  12567. describedby = $.trim( describedby.join( " " ) );
  12568. if ( describedby ) {
  12569. elem.attr( "aria-describedby", describedby );
  12570. } else {
  12571. elem.removeAttr( "aria-describedby" );
  12572. }
  12573. }
  12574. $.widget( "ui.tooltip", {
  12575. version: "1.10.3",
  12576. options: {
  12577. content: function() {
  12578. // support: IE<9, Opera in jQuery <1.7
  12579. // .text() can't accept undefined, so coerce to a string
  12580. var title = $( this ).attr( "title" ) || "";
  12581. // Escape title, since we're going from an attribute to raw HTML
  12582. return $( "<a>" ).text( title ).html();
  12583. },
  12584. hide: true,
  12585. // Disabled elements have inconsistent behavior across browsers (#8661)
  12586. items: "[title]:not([disabled])",
  12587. position: {
  12588. my: "left top+15",
  12589. at: "left bottom",
  12590. collision: "flipfit flip"
  12591. },
  12592. show: true,
  12593. tooltipClass: null,
  12594. track: false,
  12595. // callbacks
  12596. close: null,
  12597. open: null
  12598. },
  12599. _create: function() {
  12600. this._on({
  12601. mouseover: "open",
  12602. focusin: "open"
  12603. });
  12604. // IDs of generated tooltips, needed for destroy
  12605. this.tooltips = {};
  12606. // IDs of parent tooltips where we removed the title attribute
  12607. this.parents = {};
  12608. if ( this.options.disabled ) {
  12609. this._disable();
  12610. }
  12611. },
  12612. _setOption: function( key, value ) {
  12613. var that = this;
  12614. if ( key === "disabled" ) {
  12615. this[ value ? "_disable" : "_enable" ]();
  12616. this.options[ key ] = value;
  12617. // disable element style changes
  12618. return;
  12619. }
  12620. this._super( key, value );
  12621. if ( key === "content" ) {
  12622. $.each( this.tooltips, function( id, element ) {
  12623. that._updateContent( element );
  12624. });
  12625. }
  12626. },
  12627. _disable: function() {
  12628. var that = this;
  12629. // close open tooltips
  12630. $.each( this.tooltips, function( id, element ) {
  12631. var event = $.Event( "blur" );
  12632. event.target = event.currentTarget = element[0];
  12633. that.close( event, true );
  12634. });
  12635. // remove title attributes to prevent native tooltips
  12636. this.element.find( this.options.items ).addBack().each(function() {
  12637. var element = $( this );
  12638. if ( element.is( "[title]" ) ) {
  12639. element
  12640. .data( "ui-tooltip-title", element.attr( "title" ) )
  12641. .attr( "title", "" );
  12642. }
  12643. });
  12644. },
  12645. _enable: function() {
  12646. // restore title attributes
  12647. this.element.find( this.options.items ).addBack().each(function() {
  12648. var element = $( this );
  12649. if ( element.data( "ui-tooltip-title" ) ) {
  12650. element.attr( "title", element.data( "ui-tooltip-title" ) );
  12651. }
  12652. });
  12653. },
  12654. open: function( event ) {
  12655. var that = this,
  12656. target = $( event ? event.target : this.element )
  12657. // we need closest here due to mouseover bubbling,
  12658. // but always pointing at the same event target
  12659. .closest( this.options.items );
  12660. // No element to show a tooltip for or the tooltip is already open
  12661. if ( !target.length || target.data( "ui-tooltip-id" ) ) {
  12662. return;
  12663. }
  12664. if ( target.attr( "title" ) ) {
  12665. target.data( "ui-tooltip-title", target.attr( "title" ) );
  12666. }
  12667. target.data( "ui-tooltip-open", true );
  12668. // kill parent tooltips, custom or native, for hover
  12669. if ( event && event.type === "mouseover" ) {
  12670. target.parents().each(function() {
  12671. var parent = $( this ),
  12672. blurEvent;
  12673. if ( parent.data( "ui-tooltip-open" ) ) {
  12674. blurEvent = $.Event( "blur" );
  12675. blurEvent.target = blurEvent.currentTarget = this;
  12676. that.close( blurEvent, true );
  12677. }
  12678. if ( parent.attr( "title" ) ) {
  12679. parent.uniqueId();
  12680. that.parents[ this.id ] = {
  12681. element: this,
  12682. title: parent.attr( "title" )
  12683. };
  12684. parent.attr( "title", "" );
  12685. }
  12686. });
  12687. }
  12688. this._updateContent( target, event );
  12689. },
  12690. _updateContent: function( target, event ) {
  12691. var content,
  12692. contentOption = this.options.content,
  12693. that = this,
  12694. eventType = event ? event.type : null;
  12695. if ( typeof contentOption === "string" ) {
  12696. return this._open( event, target, contentOption );
  12697. }
  12698. content = contentOption.call( target[0], function( response ) {
  12699. // ignore async response if tooltip was closed already
  12700. if ( !target.data( "ui-tooltip-open" ) ) {
  12701. return;
  12702. }
  12703. // IE may instantly serve a cached response for ajax requests
  12704. // delay this call to _open so the other call to _open runs first
  12705. that._delay(function() {
  12706. // jQuery creates a special event for focusin when it doesn't
  12707. // exist natively. To improve performance, the native event
  12708. // object is reused and the type is changed. Therefore, we can't
  12709. // rely on the type being correct after the event finished
  12710. // bubbling, so we set it back to the previous value. (#8740)
  12711. if ( event ) {
  12712. event.type = eventType;
  12713. }
  12714. this._open( event, target, response );
  12715. });
  12716. });
  12717. if ( content ) {
  12718. this._open( event, target, content );
  12719. }
  12720. },
  12721. _open: function( event, target, content ) {
  12722. var tooltip, events, delayedShow,
  12723. positionOption = $.extend( {}, this.options.position );
  12724. if ( !content ) {
  12725. return;
  12726. }
  12727. // Content can be updated multiple times. If the tooltip already
  12728. // exists, then just update the content and bail.
  12729. tooltip = this._find( target );
  12730. if ( tooltip.length ) {
  12731. tooltip.find( ".ui-tooltip-content" ).html( content );
  12732. return;
  12733. }
  12734. // if we have a title, clear it to prevent the native tooltip
  12735. // we have to check first to avoid defining a title if none exists
  12736. // (we don't want to cause an element to start matching [title])
  12737. //
  12738. // We use removeAttr only for key events, to allow IE to export the correct
  12739. // accessible attributes. For mouse events, set to empty string to avoid
  12740. // native tooltip showing up (happens only when removing inside mouseover).
  12741. if ( target.is( "[title]" ) ) {
  12742. if ( event && event.type === "mouseover" ) {
  12743. target.attr( "title", "" );
  12744. } else {
  12745. target.removeAttr( "title" );
  12746. }
  12747. }
  12748. tooltip = this._tooltip( target );
  12749. addDescribedBy( target, tooltip.attr( "id" ) );
  12750. tooltip.find( ".ui-tooltip-content" ).html( content );
  12751. function position( event ) {
  12752. positionOption.of = event;
  12753. if ( tooltip.is( ":hidden" ) ) {
  12754. return;
  12755. }
  12756. tooltip.position( positionOption );
  12757. }
  12758. if ( this.options.track && event && /^mouse/.test( event.type ) ) {
  12759. this._on( this.document, {
  12760. mousemove: position
  12761. });
  12762. // trigger once to override element-relative positioning
  12763. position( event );
  12764. } else {
  12765. tooltip.position( $.extend({
  12766. of: target
  12767. }, this.options.position ) );
  12768. }
  12769. tooltip.hide();
  12770. this._show( tooltip, this.options.show );
  12771. // Handle tracking tooltips that are shown with a delay (#8644). As soon
  12772. // as the tooltip is visible, position the tooltip using the most recent
  12773. // event.
  12774. if ( this.options.show && this.options.show.delay ) {
  12775. delayedShow = this.delayedShow = setInterval(function() {
  12776. if ( tooltip.is( ":visible" ) ) {
  12777. position( positionOption.of );
  12778. clearInterval( delayedShow );
  12779. }
  12780. }, $.fx.interval );
  12781. }
  12782. this._trigger( "open", event, { tooltip: tooltip } );
  12783. events = {
  12784. keyup: function( event ) {
  12785. if ( event.keyCode === $.ui.keyCode.ESCAPE ) {
  12786. var fakeEvent = $.Event(event);
  12787. fakeEvent.currentTarget = target[0];
  12788. this.close( fakeEvent, true );
  12789. }
  12790. },
  12791. remove: function() {
  12792. this._removeTooltip( tooltip );
  12793. }
  12794. };
  12795. if ( !event || event.type === "mouseover" ) {
  12796. events.mouseleave = "close";
  12797. }
  12798. if ( !event || event.type === "focusin" ) {
  12799. events.focusout = "close";
  12800. }
  12801. this._on( true, target, events );
  12802. },
  12803. close: function( event ) {
  12804. var that = this,
  12805. target = $( event ? event.currentTarget : this.element ),
  12806. tooltip = this._find( target );
  12807. // disabling closes the tooltip, so we need to track when we're closing
  12808. // to avoid an infinite loop in case the tooltip becomes disabled on close
  12809. if ( this.closing ) {
  12810. return;
  12811. }
  12812. // Clear the interval for delayed tracking tooltips
  12813. clearInterval( this.delayedShow );
  12814. // only set title if we had one before (see comment in _open())
  12815. if ( target.data( "ui-tooltip-title" ) ) {
  12816. target.attr( "title", target.data( "ui-tooltip-title" ) );
  12817. }
  12818. removeDescribedBy( target );
  12819. tooltip.stop( true );
  12820. this._hide( tooltip, this.options.hide, function() {
  12821. that._removeTooltip( $( this ) );
  12822. });
  12823. target.removeData( "ui-tooltip-open" );
  12824. this._off( target, "mouseleave focusout keyup" );
  12825. // Remove 'remove' binding only on delegated targets
  12826. if ( target[0] !== this.element[0] ) {
  12827. this._off( target, "remove" );
  12828. }
  12829. this._off( this.document, "mousemove" );
  12830. if ( event && event.type === "mouseleave" ) {
  12831. $.each( this.parents, function( id, parent ) {
  12832. $( parent.element ).attr( "title", parent.title );
  12833. delete that.parents[ id ];
  12834. });
  12835. }
  12836. this.closing = true;
  12837. this._trigger( "close", event, { tooltip: tooltip } );
  12838. this.closing = false;
  12839. },
  12840. _tooltip: function( element ) {
  12841. var id = "ui-tooltip-" + increments++,
  12842. tooltip = $( "<div>" )
  12843. .attr({
  12844. id: id,
  12845. role: "tooltip"
  12846. })
  12847. .addClass( "ui-tooltip ui-widget ui-corner-all ui-widget-content " +
  12848. ( this.options.tooltipClass || "" ) );
  12849. $( "<div>" )
  12850. .addClass( "ui-tooltip-content" )
  12851. .appendTo( tooltip );
  12852. tooltip.appendTo( this.document[0].body );
  12853. this.tooltips[ id ] = element;
  12854. return tooltip;
  12855. },
  12856. _find: function( target ) {
  12857. var id = target.data( "ui-tooltip-id" );
  12858. return id ? $( "#" + id ) : $();
  12859. },
  12860. _removeTooltip: function( tooltip ) {
  12861. tooltip.remove();
  12862. delete this.tooltips[ tooltip.attr( "id" ) ];
  12863. },
  12864. _destroy: function() {
  12865. var that = this;
  12866. // close open tooltips
  12867. $.each( this.tooltips, function( id, element ) {
  12868. // Delegate to close method to handle common cleanup
  12869. var event = $.Event( "blur" );
  12870. event.target = event.currentTarget = element[0];
  12871. that.close( event, true );
  12872. // Remove immediately; destroying an open tooltip doesn't use the
  12873. // hide animation
  12874. $( "#" + id ).remove();
  12875. // Restore the title
  12876. if ( element.data( "ui-tooltip-title" ) ) {
  12877. element.attr( "title", element.data( "ui-tooltip-title" ) );
  12878. element.removeData( "ui-tooltip-title" );
  12879. }
  12880. });
  12881. }
  12882. });
  12883. }( jQuery ) );