jquery-ui.js 426 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972
  1. /*! jQuery UI - v1.10.3 - 2013-09-11
  2. * http://jqueryui.com
  3. * Includes: jquery.ui.core.js, jquery.ui.widget.js, jquery.ui.mouse.js, jquery.ui.position.js, jquery.ui.draggable.js, jquery.ui.droppable.js, jquery.ui.resizable.js, jquery.ui.selectable.js, jquery.ui.sortable.js, jquery.ui.accordion.js, jquery.ui.autocomplete.js, jquery.ui.button.js, jquery.ui.datepicker.js, jquery.ui.dialog.js, jquery.ui.menu.js, jquery.ui.progressbar.js, jquery.ui.slider.js, jquery.ui.spinner.js, jquery.ui.tabs.js, jquery.ui.tooltip.js, jquery.ui.effect.js, jquery.ui.effect-blind.js, jquery.ui.effect-bounce.js, jquery.ui.effect-clip.js, jquery.ui.effect-drop.js, jquery.ui.effect-explode.js, jquery.ui.effect-fade.js, jquery.ui.effect-fold.js, jquery.ui.effect-highlight.js, jquery.ui.effect-pulsate.js, jquery.ui.effect-scale.js, jquery.ui.effect-shake.js, jquery.ui.effect-slide.js, jquery.ui.effect-transfer.js
  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. $.ui = $.ui || {};
  861. var cachedScrollbarWidth,
  862. max = Math.max,
  863. abs = Math.abs,
  864. round = Math.round,
  865. rhorizontal = /left|center|right/,
  866. rvertical = /top|center|bottom/,
  867. roffset = /[\+\-]\d+(\.[\d]+)?%?/,
  868. rposition = /^\w+/,
  869. rpercent = /%$/,
  870. _position = $.fn.position;
  871. function getOffsets( offsets, width, height ) {
  872. return [
  873. parseFloat( offsets[ 0 ] ) * ( rpercent.test( offsets[ 0 ] ) ? width / 100 : 1 ),
  874. parseFloat( offsets[ 1 ] ) * ( rpercent.test( offsets[ 1 ] ) ? height / 100 : 1 )
  875. ];
  876. }
  877. function parseCss( element, property ) {
  878. return parseInt( $.css( element, property ), 10 ) || 0;
  879. }
  880. function getDimensions( elem ) {
  881. var raw = elem[0];
  882. if ( raw.nodeType === 9 ) {
  883. return {
  884. width: elem.width(),
  885. height: elem.height(),
  886. offset: { top: 0, left: 0 }
  887. };
  888. }
  889. if ( $.isWindow( raw ) ) {
  890. return {
  891. width: elem.width(),
  892. height: elem.height(),
  893. offset: { top: elem.scrollTop(), left: elem.scrollLeft() }
  894. };
  895. }
  896. if ( raw.preventDefault ) {
  897. return {
  898. width: 0,
  899. height: 0,
  900. offset: { top: raw.pageY, left: raw.pageX }
  901. };
  902. }
  903. return {
  904. width: elem.outerWidth(),
  905. height: elem.outerHeight(),
  906. offset: elem.offset()
  907. };
  908. }
  909. $.position = {
  910. scrollbarWidth: function() {
  911. if ( cachedScrollbarWidth !== undefined ) {
  912. return cachedScrollbarWidth;
  913. }
  914. var w1, w2,
  915. div = $( "<div style='display:block;width:50px;height:50px;overflow:hidden;'><div style='height:100px;width:auto;'></div></div>" ),
  916. innerDiv = div.children()[0];
  917. $( "body" ).append( div );
  918. w1 = innerDiv.offsetWidth;
  919. div.css( "overflow", "scroll" );
  920. w2 = innerDiv.offsetWidth;
  921. if ( w1 === w2 ) {
  922. w2 = div[0].clientWidth;
  923. }
  924. div.remove();
  925. return (cachedScrollbarWidth = w1 - w2);
  926. },
  927. getScrollInfo: function( within ) {
  928. var overflowX = within.isWindow ? "" : within.element.css( "overflow-x" ),
  929. overflowY = within.isWindow ? "" : within.element.css( "overflow-y" ),
  930. hasOverflowX = overflowX === "scroll" ||
  931. ( overflowX === "auto" && within.width < within.element[0].scrollWidth ),
  932. hasOverflowY = overflowY === "scroll" ||
  933. ( overflowY === "auto" && within.height < within.element[0].scrollHeight );
  934. return {
  935. width: hasOverflowY ? $.position.scrollbarWidth() : 0,
  936. height: hasOverflowX ? $.position.scrollbarWidth() : 0
  937. };
  938. },
  939. getWithinInfo: function( element ) {
  940. var withinElement = $( element || window ),
  941. isWindow = $.isWindow( withinElement[0] );
  942. return {
  943. element: withinElement,
  944. isWindow: isWindow,
  945. offset: withinElement.offset() || { left: 0, top: 0 },
  946. scrollLeft: withinElement.scrollLeft(),
  947. scrollTop: withinElement.scrollTop(),
  948. width: isWindow ? withinElement.width() : withinElement.outerWidth(),
  949. height: isWindow ? withinElement.height() : withinElement.outerHeight()
  950. };
  951. }
  952. };
  953. $.fn.position = function( options ) {
  954. if ( !options || !options.of ) {
  955. return _position.apply( this, arguments );
  956. }
  957. // make a copy, we don't want to modify arguments
  958. options = $.extend( {}, options );
  959. var atOffset, targetWidth, targetHeight, targetOffset, basePosition, dimensions,
  960. target = $( options.of ),
  961. within = $.position.getWithinInfo( options.within ),
  962. scrollInfo = $.position.getScrollInfo( within ),
  963. collision = ( options.collision || "flip" ).split( " " ),
  964. offsets = {};
  965. dimensions = getDimensions( target );
  966. if ( target[0].preventDefault ) {
  967. // force left top to allow flipping
  968. options.at = "left top";
  969. }
  970. targetWidth = dimensions.width;
  971. targetHeight = dimensions.height;
  972. targetOffset = dimensions.offset;
  973. // clone to reuse original targetOffset later
  974. basePosition = $.extend( {}, targetOffset );
  975. // force my and at to have valid horizontal and vertical positions
  976. // if a value is missing or invalid, it will be converted to center
  977. $.each( [ "my", "at" ], function() {
  978. var pos = ( options[ this ] || "" ).split( " " ),
  979. horizontalOffset,
  980. verticalOffset;
  981. if ( pos.length === 1) {
  982. pos = rhorizontal.test( pos[ 0 ] ) ?
  983. pos.concat( [ "center" ] ) :
  984. rvertical.test( pos[ 0 ] ) ?
  985. [ "center" ].concat( pos ) :
  986. [ "center", "center" ];
  987. }
  988. pos[ 0 ] = rhorizontal.test( pos[ 0 ] ) ? pos[ 0 ] : "center";
  989. pos[ 1 ] = rvertical.test( pos[ 1 ] ) ? pos[ 1 ] : "center";
  990. // calculate offsets
  991. horizontalOffset = roffset.exec( pos[ 0 ] );
  992. verticalOffset = roffset.exec( pos[ 1 ] );
  993. offsets[ this ] = [
  994. horizontalOffset ? horizontalOffset[ 0 ] : 0,
  995. verticalOffset ? verticalOffset[ 0 ] : 0
  996. ];
  997. // reduce to just the positions without the offsets
  998. options[ this ] = [
  999. rposition.exec( pos[ 0 ] )[ 0 ],
  1000. rposition.exec( pos[ 1 ] )[ 0 ]
  1001. ];
  1002. });
  1003. // normalize collision option
  1004. if ( collision.length === 1 ) {
  1005. collision[ 1 ] = collision[ 0 ];
  1006. }
  1007. if ( options.at[ 0 ] === "right" ) {
  1008. basePosition.left += targetWidth;
  1009. } else if ( options.at[ 0 ] === "center" ) {
  1010. basePosition.left += targetWidth / 2;
  1011. }
  1012. if ( options.at[ 1 ] === "bottom" ) {
  1013. basePosition.top += targetHeight;
  1014. } else if ( options.at[ 1 ] === "center" ) {
  1015. basePosition.top += targetHeight / 2;
  1016. }
  1017. atOffset = getOffsets( offsets.at, targetWidth, targetHeight );
  1018. basePosition.left += atOffset[ 0 ];
  1019. basePosition.top += atOffset[ 1 ];
  1020. return this.each(function() {
  1021. var collisionPosition, using,
  1022. elem = $( this ),
  1023. elemWidth = elem.outerWidth(),
  1024. elemHeight = elem.outerHeight(),
  1025. marginLeft = parseCss( this, "marginLeft" ),
  1026. marginTop = parseCss( this, "marginTop" ),
  1027. collisionWidth = elemWidth + marginLeft + parseCss( this, "marginRight" ) + scrollInfo.width,
  1028. collisionHeight = elemHeight + marginTop + parseCss( this, "marginBottom" ) + scrollInfo.height,
  1029. position = $.extend( {}, basePosition ),
  1030. myOffset = getOffsets( offsets.my, elem.outerWidth(), elem.outerHeight() );
  1031. if ( options.my[ 0 ] === "right" ) {
  1032. position.left -= elemWidth;
  1033. } else if ( options.my[ 0 ] === "center" ) {
  1034. position.left -= elemWidth / 2;
  1035. }
  1036. if ( options.my[ 1 ] === "bottom" ) {
  1037. position.top -= elemHeight;
  1038. } else if ( options.my[ 1 ] === "center" ) {
  1039. position.top -= elemHeight / 2;
  1040. }
  1041. position.left += myOffset[ 0 ];
  1042. position.top += myOffset[ 1 ];
  1043. // if the browser doesn't support fractions, then round for consistent results
  1044. if ( !$.support.offsetFractions ) {
  1045. position.left = round( position.left );
  1046. position.top = round( position.top );
  1047. }
  1048. collisionPosition = {
  1049. marginLeft: marginLeft,
  1050. marginTop: marginTop
  1051. };
  1052. $.each( [ "left", "top" ], function( i, dir ) {
  1053. if ( $.ui.position[ collision[ i ] ] ) {
  1054. $.ui.position[ collision[ i ] ][ dir ]( position, {
  1055. targetWidth: targetWidth,
  1056. targetHeight: targetHeight,
  1057. elemWidth: elemWidth,
  1058. elemHeight: elemHeight,
  1059. collisionPosition: collisionPosition,
  1060. collisionWidth: collisionWidth,
  1061. collisionHeight: collisionHeight,
  1062. offset: [ atOffset[ 0 ] + myOffset[ 0 ], atOffset [ 1 ] + myOffset[ 1 ] ],
  1063. my: options.my,
  1064. at: options.at,
  1065. within: within,
  1066. elem : elem
  1067. });
  1068. }
  1069. });
  1070. if ( options.using ) {
  1071. // adds feedback as second argument to using callback, if present
  1072. using = function( props ) {
  1073. var left = targetOffset.left - position.left,
  1074. right = left + targetWidth - elemWidth,
  1075. top = targetOffset.top - position.top,
  1076. bottom = top + targetHeight - elemHeight,
  1077. feedback = {
  1078. target: {
  1079. element: target,
  1080. left: targetOffset.left,
  1081. top: targetOffset.top,
  1082. width: targetWidth,
  1083. height: targetHeight
  1084. },
  1085. element: {
  1086. element: elem,
  1087. left: position.left,
  1088. top: position.top,
  1089. width: elemWidth,
  1090. height: elemHeight
  1091. },
  1092. horizontal: right < 0 ? "left" : left > 0 ? "right" : "center",
  1093. vertical: bottom < 0 ? "top" : top > 0 ? "bottom" : "middle"
  1094. };
  1095. if ( targetWidth < elemWidth && abs( left + right ) < targetWidth ) {
  1096. feedback.horizontal = "center";
  1097. }
  1098. if ( targetHeight < elemHeight && abs( top + bottom ) < targetHeight ) {
  1099. feedback.vertical = "middle";
  1100. }
  1101. if ( max( abs( left ), abs( right ) ) > max( abs( top ), abs( bottom ) ) ) {
  1102. feedback.important = "horizontal";
  1103. } else {
  1104. feedback.important = "vertical";
  1105. }
  1106. options.using.call( this, props, feedback );
  1107. };
  1108. }
  1109. elem.offset( $.extend( position, { using: using } ) );
  1110. });
  1111. };
  1112. $.ui.position = {
  1113. fit: {
  1114. left: function( position, data ) {
  1115. var within = data.within,
  1116. withinOffset = within.isWindow ? within.scrollLeft : within.offset.left,
  1117. outerWidth = within.width,
  1118. collisionPosLeft = position.left - data.collisionPosition.marginLeft,
  1119. overLeft = withinOffset - collisionPosLeft,
  1120. overRight = collisionPosLeft + data.collisionWidth - outerWidth - withinOffset,
  1121. newOverRight;
  1122. // element is wider than within
  1123. if ( data.collisionWidth > outerWidth ) {
  1124. // element is initially over the left side of within
  1125. if ( overLeft > 0 && overRight <= 0 ) {
  1126. newOverRight = position.left + overLeft + data.collisionWidth - outerWidth - withinOffset;
  1127. position.left += overLeft - newOverRight;
  1128. // element is initially over right side of within
  1129. } else if ( overRight > 0 && overLeft <= 0 ) {
  1130. position.left = withinOffset;
  1131. // element is initially over both left and right sides of within
  1132. } else {
  1133. if ( overLeft > overRight ) {
  1134. position.left = withinOffset + outerWidth - data.collisionWidth;
  1135. } else {
  1136. position.left = withinOffset;
  1137. }
  1138. }
  1139. // too far left -> align with left edge
  1140. } else if ( overLeft > 0 ) {
  1141. position.left += overLeft;
  1142. // too far right -> align with right edge
  1143. } else if ( overRight > 0 ) {
  1144. position.left -= overRight;
  1145. // adjust based on position and margin
  1146. } else {
  1147. position.left = max( position.left - collisionPosLeft, position.left );
  1148. }
  1149. },
  1150. top: function( position, data ) {
  1151. var within = data.within,
  1152. withinOffset = within.isWindow ? within.scrollTop : within.offset.top,
  1153. outerHeight = data.within.height,
  1154. collisionPosTop = position.top - data.collisionPosition.marginTop,
  1155. overTop = withinOffset - collisionPosTop,
  1156. overBottom = collisionPosTop + data.collisionHeight - outerHeight - withinOffset,
  1157. newOverBottom;
  1158. // element is taller than within
  1159. if ( data.collisionHeight > outerHeight ) {
  1160. // element is initially over the top of within
  1161. if ( overTop > 0 && overBottom <= 0 ) {
  1162. newOverBottom = position.top + overTop + data.collisionHeight - outerHeight - withinOffset;
  1163. position.top += overTop - newOverBottom;
  1164. // element is initially over bottom of within
  1165. } else if ( overBottom > 0 && overTop <= 0 ) {
  1166. position.top = withinOffset;
  1167. // element is initially over both top and bottom of within
  1168. } else {
  1169. if ( overTop > overBottom ) {
  1170. position.top = withinOffset + outerHeight - data.collisionHeight;
  1171. } else {
  1172. position.top = withinOffset;
  1173. }
  1174. }
  1175. // too far up -> align with top
  1176. } else if ( overTop > 0 ) {
  1177. position.top += overTop;
  1178. // too far down -> align with bottom edge
  1179. } else if ( overBottom > 0 ) {
  1180. position.top -= overBottom;
  1181. // adjust based on position and margin
  1182. } else {
  1183. position.top = max( position.top - collisionPosTop, position.top );
  1184. }
  1185. }
  1186. },
  1187. flip: {
  1188. left: function( position, data ) {
  1189. var within = data.within,
  1190. withinOffset = within.offset.left + within.scrollLeft,
  1191. outerWidth = within.width,
  1192. offsetLeft = within.isWindow ? within.scrollLeft : within.offset.left,
  1193. collisionPosLeft = position.left - data.collisionPosition.marginLeft,
  1194. overLeft = collisionPosLeft - offsetLeft,
  1195. overRight = collisionPosLeft + data.collisionWidth - outerWidth - offsetLeft,
  1196. myOffset = data.my[ 0 ] === "left" ?
  1197. -data.elemWidth :
  1198. data.my[ 0 ] === "right" ?
  1199. data.elemWidth :
  1200. 0,
  1201. atOffset = data.at[ 0 ] === "left" ?
  1202. data.targetWidth :
  1203. data.at[ 0 ] === "right" ?
  1204. -data.targetWidth :
  1205. 0,
  1206. offset = -2 * data.offset[ 0 ],
  1207. newOverRight,
  1208. newOverLeft;
  1209. if ( overLeft < 0 ) {
  1210. newOverRight = position.left + myOffset + atOffset + offset + data.collisionWidth - outerWidth - withinOffset;
  1211. if ( newOverRight < 0 || newOverRight < abs( overLeft ) ) {
  1212. position.left += myOffset + atOffset + offset;
  1213. }
  1214. }
  1215. else if ( overRight > 0 ) {
  1216. newOverLeft = position.left - data.collisionPosition.marginLeft + myOffset + atOffset + offset - offsetLeft;
  1217. if ( newOverLeft > 0 || abs( newOverLeft ) < overRight ) {
  1218. position.left += myOffset + atOffset + offset;
  1219. }
  1220. }
  1221. },
  1222. top: function( position, data ) {
  1223. var within = data.within,
  1224. withinOffset = within.offset.top + within.scrollTop,
  1225. outerHeight = within.height,
  1226. offsetTop = within.isWindow ? within.scrollTop : within.offset.top,
  1227. collisionPosTop = position.top - data.collisionPosition.marginTop,
  1228. overTop = collisionPosTop - offsetTop,
  1229. overBottom = collisionPosTop + data.collisionHeight - outerHeight - offsetTop,
  1230. top = data.my[ 1 ] === "top",
  1231. myOffset = top ?
  1232. -data.elemHeight :
  1233. data.my[ 1 ] === "bottom" ?
  1234. data.elemHeight :
  1235. 0,
  1236. atOffset = data.at[ 1 ] === "top" ?
  1237. data.targetHeight :
  1238. data.at[ 1 ] === "bottom" ?
  1239. -data.targetHeight :
  1240. 0,
  1241. offset = -2 * data.offset[ 1 ],
  1242. newOverTop,
  1243. newOverBottom;
  1244. if ( overTop < 0 ) {
  1245. newOverBottom = position.top + myOffset + atOffset + offset + data.collisionHeight - outerHeight - withinOffset;
  1246. if ( ( position.top + myOffset + atOffset + offset) > overTop && ( newOverBottom < 0 || newOverBottom < abs( overTop ) ) ) {
  1247. position.top += myOffset + atOffset + offset;
  1248. }
  1249. }
  1250. else if ( overBottom > 0 ) {
  1251. newOverTop = position.top - data.collisionPosition.marginTop + myOffset + atOffset + offset - offsetTop;
  1252. if ( ( position.top + myOffset + atOffset + offset) > overBottom && ( newOverTop > 0 || abs( newOverTop ) < overBottom ) ) {
  1253. position.top += myOffset + atOffset + offset;
  1254. }
  1255. }
  1256. }
  1257. },
  1258. flipfit: {
  1259. left: function() {
  1260. $.ui.position.flip.left.apply( this, arguments );
  1261. $.ui.position.fit.left.apply( this, arguments );
  1262. },
  1263. top: function() {
  1264. $.ui.position.flip.top.apply( this, arguments );
  1265. $.ui.position.fit.top.apply( this, arguments );
  1266. }
  1267. }
  1268. };
  1269. // fraction support test
  1270. (function () {
  1271. var testElement, testElementParent, testElementStyle, offsetLeft, i,
  1272. body = document.getElementsByTagName( "body" )[ 0 ],
  1273. div = document.createElement( "div" );
  1274. //Create a "fake body" for testing based on method used in jQuery.support
  1275. testElement = document.createElement( body ? "div" : "body" );
  1276. testElementStyle = {
  1277. visibility: "hidden",
  1278. width: 0,
  1279. height: 0,
  1280. border: 0,
  1281. margin: 0,
  1282. background: "none"
  1283. };
  1284. if ( body ) {
  1285. $.extend( testElementStyle, {
  1286. position: "absolute",
  1287. left: "-1000px",
  1288. top: "-1000px"
  1289. });
  1290. }
  1291. for ( i in testElementStyle ) {
  1292. testElement.style[ i ] = testElementStyle[ i ];
  1293. }
  1294. testElement.appendChild( div );
  1295. testElementParent = body || document.documentElement;
  1296. testElementParent.insertBefore( testElement, testElementParent.firstChild );
  1297. div.style.cssText = "position: absolute; left: 10.7432222px;";
  1298. offsetLeft = $( div ).offset().left;
  1299. $.support.offsetFractions = offsetLeft > 10 && offsetLeft < 11;
  1300. testElement.innerHTML = "";
  1301. testElementParent.removeChild( testElement );
  1302. })();
  1303. }( jQuery ) );
  1304. (function( $, undefined ) {
  1305. $.widget("ui.draggable", $.ui.mouse, {
  1306. version: "1.10.3",
  1307. widgetEventPrefix: "drag",
  1308. options: {
  1309. addClasses: true,
  1310. appendTo: "parent",
  1311. axis: false,
  1312. connectToSortable: false,
  1313. containment: false,
  1314. cursor: "auto",
  1315. cursorAt: false,
  1316. grid: false,
  1317. handle: false,
  1318. helper: "original",
  1319. iframeFix: false,
  1320. opacity: false,
  1321. refreshPositions: false,
  1322. revert: false,
  1323. revertDuration: 500,
  1324. scope: "default",
  1325. scroll: true,
  1326. scrollSensitivity: 20,
  1327. scrollSpeed: 20,
  1328. snap: false,
  1329. snapMode: "both",
  1330. snapTolerance: 20,
  1331. stack: false,
  1332. zIndex: false,
  1333. // callbacks
  1334. drag: null,
  1335. start: null,
  1336. stop: null
  1337. },
  1338. _create: function() {
  1339. if (this.options.helper === "original" && !(/^(?:r|a|f)/).test(this.element.css("position"))) {
  1340. this.element[0].style.position = "relative";
  1341. }
  1342. if (this.options.addClasses){
  1343. this.element.addClass("ui-draggable");
  1344. }
  1345. if (this.options.disabled){
  1346. this.element.addClass("ui-draggable-disabled");
  1347. }
  1348. this._mouseInit();
  1349. },
  1350. _destroy: function() {
  1351. this.element.removeClass( "ui-draggable ui-draggable-dragging ui-draggable-disabled" );
  1352. this._mouseDestroy();
  1353. },
  1354. _mouseCapture: function(event) {
  1355. var o = this.options;
  1356. // among others, prevent a drag on a resizable-handle
  1357. if (this.helper || o.disabled || $(event.target).closest(".ui-resizable-handle").length > 0) {
  1358. return false;
  1359. }
  1360. //Quit if we're not on a valid handle
  1361. this.handle = this._getHandle(event);
  1362. if (!this.handle) {
  1363. return false;
  1364. }
  1365. $(o.iframeFix === true ? "iframe" : o.iframeFix).each(function() {
  1366. $("<div class='ui-draggable-iframeFix' style='background: #fff;'></div>")
  1367. .css({
  1368. width: this.offsetWidth+"px", height: this.offsetHeight+"px",
  1369. position: "absolute", opacity: "0.001", zIndex: 1000
  1370. })
  1371. .css($(this).offset())
  1372. .appendTo("body");
  1373. });
  1374. return true;
  1375. },
  1376. _mouseStart: function(event) {
  1377. var o = this.options;
  1378. //Create and append the visible helper
  1379. this.helper = this._createHelper(event);
  1380. this.helper.addClass("ui-draggable-dragging");
  1381. //Cache the helper size
  1382. this._cacheHelperProportions();
  1383. //If ddmanager is used for droppables, set the global draggable
  1384. if($.ui.ddmanager) {
  1385. $.ui.ddmanager.current = this;
  1386. }
  1387. /*
  1388. * - Position generation -
  1389. * This block generates everything position related - it's the core of draggables.
  1390. */
  1391. //Cache the margins of the original element
  1392. this._cacheMargins();
  1393. //Store the helper's css position
  1394. this.cssPosition = this.helper.css( "position" );
  1395. this.scrollParent = this.helper.scrollParent();
  1396. this.offsetParent = this.helper.offsetParent();
  1397. this.offsetParentCssPosition = this.offsetParent.css( "position" );
  1398. //The element's absolute position on the page minus margins
  1399. this.offset = this.positionAbs = this.element.offset();
  1400. this.offset = {
  1401. top: this.offset.top - this.margins.top,
  1402. left: this.offset.left - this.margins.left
  1403. };
  1404. //Reset scroll cache
  1405. this.offset.scroll = false;
  1406. $.extend(this.offset, {
  1407. click: { //Where the click happened, relative to the element
  1408. left: event.pageX - this.offset.left,
  1409. top: event.pageY - this.offset.top
  1410. },
  1411. parent: this._getParentOffset(),
  1412. relative: this._getRelativeOffset() //This is a relative to absolute position minus the actual position calculation - only used for relative positioned helper
  1413. });
  1414. //Generate the original position
  1415. this.originalPosition = this.position = this._generatePosition(event);
  1416. this.originalPageX = event.pageX;
  1417. this.originalPageY = event.pageY;
  1418. //Adjust the mouse offset relative to the helper if "cursorAt" is supplied
  1419. (o.cursorAt && this._adjustOffsetFromHelper(o.cursorAt));
  1420. //Set a containment if given in the options
  1421. this._setContainment();
  1422. //Trigger event + callbacks
  1423. if(this._trigger("start", event) === false) {
  1424. this._clear();
  1425. return false;
  1426. }
  1427. //Recache the helper size
  1428. this._cacheHelperProportions();
  1429. //Prepare the droppable offsets
  1430. if ($.ui.ddmanager && !o.dropBehaviour) {
  1431. $.ui.ddmanager.prepareOffsets(this, event);
  1432. }
  1433. this._mouseDrag(event, true); //Execute the drag once - this causes the helper not to be visible before getting its correct position
  1434. //If the ddmanager is used for droppables, inform the manager that dragging has started (see #5003)
  1435. if ( $.ui.ddmanager ) {
  1436. $.ui.ddmanager.dragStart(this, event);
  1437. }
  1438. return true;
  1439. },
  1440. _mouseDrag: function(event, noPropagation) {
  1441. // reset any necessary cached properties (see #5009)
  1442. if ( this.offsetParentCssPosition === "fixed" ) {
  1443. this.offset.parent = this._getParentOffset();
  1444. }
  1445. //Compute the helpers position
  1446. this.position = this._generatePosition(event);
  1447. this.positionAbs = this._convertPositionTo("absolute");
  1448. //Call plugins and callbacks and use the resulting position if something is returned
  1449. if (!noPropagation) {
  1450. var ui = this._uiHash();
  1451. if(this._trigger("drag", event, ui) === false) {
  1452. this._mouseUp({});
  1453. return false;
  1454. }
  1455. this.position = ui.position;
  1456. }
  1457. if(!this.options.axis || this.options.axis !== "y") {
  1458. this.helper[0].style.left = this.position.left+"px";
  1459. }
  1460. if(!this.options.axis || this.options.axis !== "x") {
  1461. this.helper[0].style.top = this.position.top+"px";
  1462. }
  1463. if($.ui.ddmanager) {
  1464. $.ui.ddmanager.drag(this, event);
  1465. }
  1466. return false;
  1467. },
  1468. _mouseStop: function(event) {
  1469. //If we are using droppables, inform the manager about the drop
  1470. var that = this,
  1471. dropped = false;
  1472. if ($.ui.ddmanager && !this.options.dropBehaviour) {
  1473. dropped = $.ui.ddmanager.drop(this, event);
  1474. }
  1475. //if a drop comes from outside (a sortable)
  1476. if(this.dropped) {
  1477. dropped = this.dropped;
  1478. this.dropped = false;
  1479. }
  1480. //if the original element is no longer in the DOM don't bother to continue (see #8269)
  1481. if ( this.options.helper === "original" && !$.contains( this.element[ 0 ].ownerDocument, this.element[ 0 ] ) ) {
  1482. return false;
  1483. }
  1484. 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))) {
  1485. $(this.helper).animate(this.originalPosition, parseInt(this.options.revertDuration, 10), function() {
  1486. if(that._trigger("stop", event) !== false) {
  1487. that._clear();
  1488. }
  1489. });
  1490. } else {
  1491. if(this._trigger("stop", event) !== false) {
  1492. this._clear();
  1493. }
  1494. }
  1495. return false;
  1496. },
  1497. _mouseUp: function(event) {
  1498. //Remove frame helpers
  1499. $("div.ui-draggable-iframeFix").each(function() {
  1500. this.parentNode.removeChild(this);
  1501. });
  1502. //If the ddmanager is used for droppables, inform the manager that dragging has stopped (see #5003)
  1503. if( $.ui.ddmanager ) {
  1504. $.ui.ddmanager.dragStop(this, event);
  1505. }
  1506. return $.ui.mouse.prototype._mouseUp.call(this, event);
  1507. },
  1508. cancel: function() {
  1509. if(this.helper.is(".ui-draggable-dragging")) {
  1510. this._mouseUp({});
  1511. } else {
  1512. this._clear();
  1513. }
  1514. return this;
  1515. },
  1516. _getHandle: function(event) {
  1517. return this.options.handle ?
  1518. !!$( event.target ).closest( this.element.find( this.options.handle ) ).length :
  1519. true;
  1520. },
  1521. _createHelper: function(event) {
  1522. var o = this.options,
  1523. helper = $.isFunction(o.helper) ? $(o.helper.apply(this.element[0], [event])) : (o.helper === "clone" ? this.element.clone().removeAttr("id") : this.element);
  1524. if(!helper.parents("body").length) {
  1525. helper.appendTo((o.appendTo === "parent" ? this.element[0].parentNode : o.appendTo));
  1526. }
  1527. if(helper[0] !== this.element[0] && !(/(fixed|absolute)/).test(helper.css("position"))) {
  1528. helper.css("position", "absolute");
  1529. }
  1530. return helper;
  1531. },
  1532. _adjustOffsetFromHelper: function(obj) {
  1533. if (typeof obj === "string") {
  1534. obj = obj.split(" ");
  1535. }
  1536. if ($.isArray(obj)) {
  1537. obj = {left: +obj[0], top: +obj[1] || 0};
  1538. }
  1539. if ("left" in obj) {
  1540. this.offset.click.left = obj.left + this.margins.left;
  1541. }
  1542. if ("right" in obj) {
  1543. this.offset.click.left = this.helperProportions.width - obj.right + this.margins.left;
  1544. }
  1545. if ("top" in obj) {
  1546. this.offset.click.top = obj.top + this.margins.top;
  1547. }
  1548. if ("bottom" in obj) {
  1549. this.offset.click.top = this.helperProportions.height - obj.bottom + this.margins.top;
  1550. }
  1551. },
  1552. _getParentOffset: function() {
  1553. //Get the offsetParent and cache its position
  1554. var po = this.offsetParent.offset();
  1555. // This is a special case where we need to modify a offset calculated on start, since the following happened:
  1556. // 1. The position of the helper is absolute, so it's position is calculated based on the next positioned parent
  1557. // 2. The actual offset parent is a child of the scroll parent, and the scroll parent isn't the document, which means that
  1558. // the scroll is included in the initial calculation of the offset of the parent, and never recalculated upon drag
  1559. if(this.cssPosition === "absolute" && this.scrollParent[0] !== document && $.contains(this.scrollParent[0], this.offsetParent[0])) {
  1560. po.left += this.scrollParent.scrollLeft();
  1561. po.top += this.scrollParent.scrollTop();
  1562. }
  1563. //This needs to be actually done for all browsers, since pageX/pageY includes this information
  1564. //Ugly IE fix
  1565. if((this.offsetParent[0] === document.body) ||
  1566. (this.offsetParent[0].tagName && this.offsetParent[0].tagName.toLowerCase() === "html" && $.ui.ie)) {
  1567. po = { top: 0, left: 0 };
  1568. }
  1569. return {
  1570. top: po.top + (parseInt(this.offsetParent.css("borderTopWidth"),10) || 0),
  1571. left: po.left + (parseInt(this.offsetParent.css("borderLeftWidth"),10) || 0)
  1572. };
  1573. },
  1574. _getRelativeOffset: function() {
  1575. if(this.cssPosition === "relative") {
  1576. var p = this.element.position();
  1577. return {
  1578. top: p.top - (parseInt(this.helper.css("top"),10) || 0) + this.scrollParent.scrollTop(),
  1579. left: p.left - (parseInt(this.helper.css("left"),10) || 0) + this.scrollParent.scrollLeft()
  1580. };
  1581. } else {
  1582. return { top: 0, left: 0 };
  1583. }
  1584. },
  1585. _cacheMargins: function() {
  1586. this.margins = {
  1587. left: (parseInt(this.element.css("marginLeft"),10) || 0),
  1588. top: (parseInt(this.element.css("marginTop"),10) || 0),
  1589. right: (parseInt(this.element.css("marginRight"),10) || 0),
  1590. bottom: (parseInt(this.element.css("marginBottom"),10) || 0)
  1591. };
  1592. },
  1593. _cacheHelperProportions: function() {
  1594. this.helperProportions = {
  1595. width: this.helper.outerWidth(),
  1596. height: this.helper.outerHeight()
  1597. };
  1598. },
  1599. _setContainment: function() {
  1600. var over, c, ce,
  1601. o = this.options;
  1602. if ( !o.containment ) {
  1603. this.containment = null;
  1604. return;
  1605. }
  1606. if ( o.containment === "window" ) {
  1607. this.containment = [
  1608. $( window ).scrollLeft() - this.offset.relative.left - this.offset.parent.left,
  1609. $( window ).scrollTop() - this.offset.relative.top - this.offset.parent.top,
  1610. $( window ).scrollLeft() + $( window ).width() - this.helperProportions.width - this.margins.left,
  1611. $( window ).scrollTop() + ( $( window ).height() || document.body.parentNode.scrollHeight ) - this.helperProportions.height - this.margins.top
  1612. ];
  1613. return;
  1614. }
  1615. if ( o.containment === "document") {
  1616. this.containment = [
  1617. 0,
  1618. 0,
  1619. $( document ).width() - this.helperProportions.width - this.margins.left,
  1620. ( $( document ).height() || document.body.parentNode.scrollHeight ) - this.helperProportions.height - this.margins.top
  1621. ];
  1622. return;
  1623. }
  1624. if ( o.containment.constructor === Array ) {
  1625. this.containment = o.containment;
  1626. return;
  1627. }
  1628. if ( o.containment === "parent" ) {
  1629. o.containment = this.helper[ 0 ].parentNode;
  1630. }
  1631. c = $( o.containment );
  1632. ce = c[ 0 ];
  1633. if( !ce ) {
  1634. return;
  1635. }
  1636. over = c.css( "overflow" ) !== "hidden";
  1637. this.containment = [
  1638. ( parseInt( c.css( "borderLeftWidth" ), 10 ) || 0 ) + ( parseInt( c.css( "paddingLeft" ), 10 ) || 0 ),
  1639. ( parseInt( c.css( "borderTopWidth" ), 10 ) || 0 ) + ( parseInt( c.css( "paddingTop" ), 10 ) || 0 ) ,
  1640. ( 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,
  1641. ( 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
  1642. ];
  1643. this.relative_container = c;
  1644. },
  1645. _convertPositionTo: function(d, pos) {
  1646. if(!pos) {
  1647. pos = this.position;
  1648. }
  1649. var mod = d === "absolute" ? 1 : -1,
  1650. scroll = this.cssPosition === "absolute" && !( this.scrollParent[ 0 ] !== document && $.contains( this.scrollParent[ 0 ], this.offsetParent[ 0 ] ) ) ? this.offsetParent : this.scrollParent;
  1651. //Cache the scroll
  1652. if (!this.offset.scroll) {
  1653. this.offset.scroll = {top : scroll.scrollTop(), left : scroll.scrollLeft()};
  1654. }
  1655. return {
  1656. top: (
  1657. pos.top + // The absolute mouse position
  1658. this.offset.relative.top * mod + // Only for relative positioned nodes: Relative offset from element to offset parent
  1659. this.offset.parent.top * mod - // The offsetParent's offset without borders (offset + border)
  1660. ( ( this.cssPosition === "fixed" ? -this.scrollParent.scrollTop() : this.offset.scroll.top ) * mod )
  1661. ),
  1662. left: (
  1663. pos.left + // The absolute mouse position
  1664. this.offset.relative.left * mod + // Only for relative positioned nodes: Relative offset from element to offset parent
  1665. this.offset.parent.left * mod - // The offsetParent's offset without borders (offset + border)
  1666. ( ( this.cssPosition === "fixed" ? -this.scrollParent.scrollLeft() : this.offset.scroll.left ) * mod )
  1667. )
  1668. };
  1669. },
  1670. _generatePosition: function(event) {
  1671. var containment, co, top, left,
  1672. o = this.options,
  1673. scroll = this.cssPosition === "absolute" && !( this.scrollParent[ 0 ] !== document && $.contains( this.scrollParent[ 0 ], this.offsetParent[ 0 ] ) ) ? this.offsetParent : this.scrollParent,
  1674. pageX = event.pageX,
  1675. pageY = event.pageY;
  1676. //Cache the scroll
  1677. if (!this.offset.scroll) {
  1678. this.offset.scroll = {top : scroll.scrollTop(), left : scroll.scrollLeft()};
  1679. }
  1680. /*
  1681. * - Position constraining -
  1682. * Constrain the position to a mix of grid, containment.
  1683. */
  1684. // If we are not dragging yet, we won't check for options
  1685. if ( this.originalPosition ) {
  1686. if ( this.containment ) {
  1687. if ( this.relative_container ){
  1688. co = this.relative_container.offset();
  1689. containment = [
  1690. this.containment[ 0 ] + co.left,
  1691. this.containment[ 1 ] + co.top,
  1692. this.containment[ 2 ] + co.left,
  1693. this.containment[ 3 ] + co.top
  1694. ];
  1695. }
  1696. else {
  1697. containment = this.containment;
  1698. }
  1699. if(event.pageX - this.offset.click.left < containment[0]) {
  1700. pageX = containment[0] + this.offset.click.left;
  1701. }
  1702. if(event.pageY - this.offset.click.top < containment[1]) {
  1703. pageY = containment[1] + this.offset.click.top;
  1704. }
  1705. if(event.pageX - this.offset.click.left > containment[2]) {
  1706. pageX = containment[2] + this.offset.click.left;
  1707. }
  1708. if(event.pageY - this.offset.click.top > containment[3]) {
  1709. pageY = containment[3] + this.offset.click.top;
  1710. }
  1711. }
  1712. if(o.grid) {
  1713. //Check for grid elements set to 0 to prevent divide by 0 error causing invalid argument errors in IE (see ticket #6950)
  1714. top = o.grid[1] ? this.originalPageY + Math.round((pageY - this.originalPageY) / o.grid[1]) * o.grid[1] : this.originalPageY;
  1715. 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;
  1716. left = o.grid[0] ? this.originalPageX + Math.round((pageX - this.originalPageX) / o.grid[0]) * o.grid[0] : this.originalPageX;
  1717. 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;
  1718. }
  1719. }
  1720. return {
  1721. top: (
  1722. pageY - // The absolute mouse position
  1723. this.offset.click.top - // Click offset (relative to the element)
  1724. this.offset.relative.top - // Only for relative positioned nodes: Relative offset from element to offset parent
  1725. this.offset.parent.top + // The offsetParent's offset without borders (offset + border)
  1726. ( this.cssPosition === "fixed" ? -this.scrollParent.scrollTop() : this.offset.scroll.top )
  1727. ),
  1728. left: (
  1729. pageX - // The absolute mouse position
  1730. this.offset.click.left - // Click offset (relative to the element)
  1731. this.offset.relative.left - // Only for relative positioned nodes: Relative offset from element to offset parent
  1732. this.offset.parent.left + // The offsetParent's offset without borders (offset + border)
  1733. ( this.cssPosition === "fixed" ? -this.scrollParent.scrollLeft() : this.offset.scroll.left )
  1734. )
  1735. };
  1736. },
  1737. _clear: function() {
  1738. this.helper.removeClass("ui-draggable-dragging");
  1739. if(this.helper[0] !== this.element[0] && !this.cancelHelperRemoval) {
  1740. this.helper.remove();
  1741. }
  1742. this.helper = null;
  1743. this.cancelHelperRemoval = false;
  1744. },
  1745. // From now on bulk stuff - mainly helpers
  1746. _trigger: function(type, event, ui) {
  1747. ui = ui || this._uiHash();
  1748. $.ui.plugin.call(this, type, [event, ui]);
  1749. //The absolute position has to be recalculated after plugins
  1750. if(type === "drag") {
  1751. this.positionAbs = this._convertPositionTo("absolute");
  1752. }
  1753. return $.Widget.prototype._trigger.call(this, type, event, ui);
  1754. },
  1755. plugins: {},
  1756. _uiHash: function() {
  1757. return {
  1758. helper: this.helper,
  1759. position: this.position,
  1760. originalPosition: this.originalPosition,
  1761. offset: this.positionAbs
  1762. };
  1763. }
  1764. });
  1765. $.ui.plugin.add("draggable", "connectToSortable", {
  1766. start: function(event, ui) {
  1767. var inst = $(this).data("ui-draggable"), o = inst.options,
  1768. uiSortable = $.extend({}, ui, { item: inst.element });
  1769. inst.sortables = [];
  1770. $(o.connectToSortable).each(function() {
  1771. var sortable = $.data(this, "ui-sortable");
  1772. if (sortable && !sortable.options.disabled) {
  1773. inst.sortables.push({
  1774. instance: sortable,
  1775. shouldRevert: sortable.options.revert
  1776. });
  1777. 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).
  1778. sortable._trigger("activate", event, uiSortable);
  1779. }
  1780. });
  1781. },
  1782. stop: function(event, ui) {
  1783. //If we are still over the sortable, we fake the stop event of the sortable, but also remove helper
  1784. var inst = $(this).data("ui-draggable"),
  1785. uiSortable = $.extend({}, ui, { item: inst.element });
  1786. $.each(inst.sortables, function() {
  1787. if(this.instance.isOver) {
  1788. this.instance.isOver = 0;
  1789. inst.cancelHelperRemoval = true; //Don't remove the helper in the draggable instance
  1790. this.instance.cancelHelperRemoval = false; //Remove it in the sortable instance (so sortable plugins like revert still work)
  1791. //The sortable revert is supported, and we have to set a temporary dropped variable on the draggable to support revert: "valid/invalid"
  1792. if(this.shouldRevert) {
  1793. this.instance.options.revert = this.shouldRevert;
  1794. }
  1795. //Trigger the stop of the sortable
  1796. this.instance._mouseStop(event);
  1797. this.instance.options.helper = this.instance.options._helper;
  1798. //If the helper has been the original item, restore properties in the sortable
  1799. if(inst.options.helper === "original") {
  1800. this.instance.currentItem.css({ top: "auto", left: "auto" });
  1801. }
  1802. } else {
  1803. this.instance.cancelHelperRemoval = false; //Remove the helper in the sortable instance
  1804. this.instance._trigger("deactivate", event, uiSortable);
  1805. }
  1806. });
  1807. },
  1808. drag: function(event, ui) {
  1809. var inst = $(this).data("ui-draggable"), that = this;
  1810. $.each(inst.sortables, function() {
  1811. var innermostIntersecting = false,
  1812. thisSortable = this;
  1813. //Copy over some variables to allow calling the sortable's native _intersectsWith
  1814. this.instance.positionAbs = inst.positionAbs;
  1815. this.instance.helperProportions = inst.helperProportions;
  1816. this.instance.offset.click = inst.offset.click;
  1817. if(this.instance._intersectsWith(this.instance.containerCache)) {
  1818. innermostIntersecting = true;
  1819. $.each(inst.sortables, function () {
  1820. this.instance.positionAbs = inst.positionAbs;
  1821. this.instance.helperProportions = inst.helperProportions;
  1822. this.instance.offset.click = inst.offset.click;
  1823. if (this !== thisSortable &&
  1824. this.instance._intersectsWith(this.instance.containerCache) &&
  1825. $.contains(thisSortable.instance.element[0], this.instance.element[0])
  1826. ) {
  1827. innermostIntersecting = false;
  1828. }
  1829. return innermostIntersecting;
  1830. });
  1831. }
  1832. if(innermostIntersecting) {
  1833. //If it intersects, we use a little isOver variable and set it once, so our move-in stuff gets fired only once
  1834. if(!this.instance.isOver) {
  1835. this.instance.isOver = 1;
  1836. //Now we fake the start of dragging for the sortable instance,
  1837. //by cloning the list group item, appending it to the sortable and using it as inst.currentItem
  1838. //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)
  1839. this.instance.currentItem = $(that).clone().removeAttr("id").appendTo(this.instance.element).data("ui-sortable-item", true);
  1840. this.instance.options._helper = this.instance.options.helper; //Store helper option to later restore it
  1841. this.instance.options.helper = function() { return ui.helper[0]; };
  1842. event.target = this.instance.currentItem[0];
  1843. this.instance._mouseCapture(event, true);
  1844. this.instance._mouseStart(event, true, true);
  1845. //Because the browser event is way off the new appended portlet, we modify a couple of variables to reflect the changes
  1846. this.instance.offset.click.top = inst.offset.click.top;
  1847. this.instance.offset.click.left = inst.offset.click.left;
  1848. this.instance.offset.parent.left -= inst.offset.parent.left - this.instance.offset.parent.left;
  1849. this.instance.offset.parent.top -= inst.offset.parent.top - this.instance.offset.parent.top;
  1850. inst._trigger("toSortable", event);
  1851. inst.dropped = this.instance.element; //draggable revert needs that
  1852. //hack so receive/update callbacks work (mostly)
  1853. inst.currentItem = inst.element;
  1854. this.instance.fromOutside = inst;
  1855. }
  1856. //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
  1857. if(this.instance.currentItem) {
  1858. this.instance._mouseDrag(event);
  1859. }
  1860. } else {
  1861. //If it doesn't intersect with the sortable, and it intersected before,
  1862. //we fake the drag stop of the sortable, but make sure it doesn't remove the helper by using cancelHelperRemoval
  1863. if(this.instance.isOver) {
  1864. this.instance.isOver = 0;
  1865. this.instance.cancelHelperRemoval = true;
  1866. //Prevent reverting on this forced stop
  1867. this.instance.options.revert = false;
  1868. // The out event needs to be triggered independently
  1869. this.instance._trigger("out", event, this.instance._uiHash(this.instance));
  1870. this.instance._mouseStop(event, true);
  1871. this.instance.options.helper = this.instance.options._helper;
  1872. //Now we remove our currentItem, the list group clone again, and the placeholder, and animate the helper back to it's original size
  1873. this.instance.currentItem.remove();
  1874. if(this.instance.placeholder) {
  1875. this.instance.placeholder.remove();
  1876. }
  1877. inst._trigger("fromSortable", event);
  1878. inst.dropped = false; //draggable revert needs that
  1879. }
  1880. }
  1881. });
  1882. }
  1883. });
  1884. $.ui.plugin.add("draggable", "cursor", {
  1885. start: function() {
  1886. var t = $("body"), o = $(this).data("ui-draggable").options;
  1887. if (t.css("cursor")) {
  1888. o._cursor = t.css("cursor");
  1889. }
  1890. t.css("cursor", o.cursor);
  1891. },
  1892. stop: function() {
  1893. var o = $(this).data("ui-draggable").options;
  1894. if (o._cursor) {
  1895. $("body").css("cursor", o._cursor);
  1896. }
  1897. }
  1898. });
  1899. $.ui.plugin.add("draggable", "opacity", {
  1900. start: function(event, ui) {
  1901. var t = $(ui.helper), o = $(this).data("ui-draggable").options;
  1902. if(t.css("opacity")) {
  1903. o._opacity = t.css("opacity");
  1904. }
  1905. t.css("opacity", o.opacity);
  1906. },
  1907. stop: function(event, ui) {
  1908. var o = $(this).data("ui-draggable").options;
  1909. if(o._opacity) {
  1910. $(ui.helper).css("opacity", o._opacity);
  1911. }
  1912. }
  1913. });
  1914. $.ui.plugin.add("draggable", "scroll", {
  1915. start: function() {
  1916. var i = $(this).data("ui-draggable");
  1917. if(i.scrollParent[0] !== document && i.scrollParent[0].tagName !== "HTML") {
  1918. i.overflowOffset = i.scrollParent.offset();
  1919. }
  1920. },
  1921. drag: function( event ) {
  1922. var i = $(this).data("ui-draggable"), o = i.options, scrolled = false;
  1923. if(i.scrollParent[0] !== document && i.scrollParent[0].tagName !== "HTML") {
  1924. if(!o.axis || o.axis !== "x") {
  1925. if((i.overflowOffset.top + i.scrollParent[0].offsetHeight) - event.pageY < o.scrollSensitivity) {
  1926. i.scrollParent[0].scrollTop = scrolled = i.scrollParent[0].scrollTop + o.scrollSpeed;
  1927. } else if(event.pageY - i.overflowOffset.top < o.scrollSensitivity) {
  1928. i.scrollParent[0].scrollTop = scrolled = i.scrollParent[0].scrollTop - o.scrollSpeed;
  1929. }
  1930. }
  1931. if(!o.axis || o.axis !== "y") {
  1932. if((i.overflowOffset.left + i.scrollParent[0].offsetWidth) - event.pageX < o.scrollSensitivity) {
  1933. i.scrollParent[0].scrollLeft = scrolled = i.scrollParent[0].scrollLeft + o.scrollSpeed;
  1934. } else if(event.pageX - i.overflowOffset.left < o.scrollSensitivity) {
  1935. i.scrollParent[0].scrollLeft = scrolled = i.scrollParent[0].scrollLeft - o.scrollSpeed;
  1936. }
  1937. }
  1938. } else {
  1939. if(!o.axis || o.axis !== "x") {
  1940. if(event.pageY - $(document).scrollTop() < o.scrollSensitivity) {
  1941. scrolled = $(document).scrollTop($(document).scrollTop() - o.scrollSpeed);
  1942. } else if($(window).height() - (event.pageY - $(document).scrollTop()) < o.scrollSensitivity) {
  1943. scrolled = $(document).scrollTop($(document).scrollTop() + o.scrollSpeed);
  1944. }
  1945. }
  1946. if(!o.axis || o.axis !== "y") {
  1947. if(event.pageX - $(document).scrollLeft() < o.scrollSensitivity) {
  1948. scrolled = $(document).scrollLeft($(document).scrollLeft() - o.scrollSpeed);
  1949. } else if($(window).width() - (event.pageX - $(document).scrollLeft()) < o.scrollSensitivity) {
  1950. scrolled = $(document).scrollLeft($(document).scrollLeft() + o.scrollSpeed);
  1951. }
  1952. }
  1953. }
  1954. if(scrolled !== false && $.ui.ddmanager && !o.dropBehaviour) {
  1955. $.ui.ddmanager.prepareOffsets(i, event);
  1956. }
  1957. }
  1958. });
  1959. $.ui.plugin.add("draggable", "snap", {
  1960. start: function() {
  1961. var i = $(this).data("ui-draggable"),
  1962. o = i.options;
  1963. i.snapElements = [];
  1964. $(o.snap.constructor !== String ? ( o.snap.items || ":data(ui-draggable)" ) : o.snap).each(function() {
  1965. var $t = $(this),
  1966. $o = $t.offset();
  1967. if(this !== i.element[0]) {
  1968. i.snapElements.push({
  1969. item: this,
  1970. width: $t.outerWidth(), height: $t.outerHeight(),
  1971. top: $o.top, left: $o.left
  1972. });
  1973. }
  1974. });
  1975. },
  1976. drag: function(event, ui) {
  1977. var ts, bs, ls, rs, l, r, t, b, i, first,
  1978. inst = $(this).data("ui-draggable"),
  1979. o = inst.options,
  1980. d = o.snapTolerance,
  1981. x1 = ui.offset.left, x2 = x1 + inst.helperProportions.width,
  1982. y1 = ui.offset.top, y2 = y1 + inst.helperProportions.height;
  1983. for (i = inst.snapElements.length - 1; i >= 0; i--){
  1984. l = inst.snapElements[i].left;
  1985. r = l + inst.snapElements[i].width;
  1986. t = inst.snapElements[i].top;
  1987. b = t + inst.snapElements[i].height;
  1988. if ( x2 < l - d || x1 > r + d || y2 < t - d || y1 > b + d || !$.contains( inst.snapElements[ i ].item.ownerDocument, inst.snapElements[ i ].item ) ) {
  1989. if(inst.snapElements[i].snapping) {
  1990. (inst.options.snap.release && inst.options.snap.release.call(inst.element, event, $.extend(inst._uiHash(), { snapItem: inst.snapElements[i].item })));
  1991. }
  1992. inst.snapElements[i].snapping = false;
  1993. continue;
  1994. }
  1995. if(o.snapMode !== "inner") {
  1996. ts = Math.abs(t - y2) <= d;
  1997. bs = Math.abs(b - y1) <= d;
  1998. ls = Math.abs(l - x2) <= d;
  1999. rs = Math.abs(r - x1) <= d;
  2000. if(ts) {
  2001. ui.position.top = inst._convertPositionTo("relative", { top: t - inst.helperProportions.height, left: 0 }).top - inst.margins.top;
  2002. }
  2003. if(bs) {
  2004. ui.position.top = inst._convertPositionTo("relative", { top: b, left: 0 }).top - inst.margins.top;
  2005. }
  2006. if(ls) {
  2007. ui.position.left = inst._convertPositionTo("relative", { top: 0, left: l - inst.helperProportions.width }).left - inst.margins.left;
  2008. }
  2009. if(rs) {
  2010. ui.position.left = inst._convertPositionTo("relative", { top: 0, left: r }).left - inst.margins.left;
  2011. }
  2012. }
  2013. first = (ts || bs || ls || rs);
  2014. if(o.snapMode !== "outer") {
  2015. ts = Math.abs(t - y1) <= d;
  2016. bs = Math.abs(b - y2) <= d;
  2017. ls = Math.abs(l - x1) <= d;
  2018. rs = Math.abs(r - x2) <= d;
  2019. if(ts) {
  2020. ui.position.top = inst._convertPositionTo("relative", { top: t, left: 0 }).top - inst.margins.top;
  2021. }
  2022. if(bs) {
  2023. ui.position.top = inst._convertPositionTo("relative", { top: b - inst.helperProportions.height, left: 0 }).top - inst.margins.top;
  2024. }
  2025. if(ls) {
  2026. ui.position.left = inst._convertPositionTo("relative", { top: 0, left: l }).left - inst.margins.left;
  2027. }
  2028. if(rs) {
  2029. ui.position.left = inst._convertPositionTo("relative", { top: 0, left: r - inst.helperProportions.width }).left - inst.margins.left;
  2030. }
  2031. }
  2032. if(!inst.snapElements[i].snapping && (ts || bs || ls || rs || first)) {
  2033. (inst.options.snap.snap && inst.options.snap.snap.call(inst.element, event, $.extend(inst._uiHash(), { snapItem: inst.snapElements[i].item })));
  2034. }
  2035. inst.snapElements[i].snapping = (ts || bs || ls || rs || first);
  2036. }
  2037. }
  2038. });
  2039. $.ui.plugin.add("draggable", "stack", {
  2040. start: function() {
  2041. var min,
  2042. o = this.data("ui-draggable").options,
  2043. group = $.makeArray($(o.stack)).sort(function(a,b) {
  2044. return (parseInt($(a).css("zIndex"),10) || 0) - (parseInt($(b).css("zIndex"),10) || 0);
  2045. });
  2046. if (!group.length) { return; }
  2047. min = parseInt($(group[0]).css("zIndex"), 10) || 0;
  2048. $(group).each(function(i) {
  2049. $(this).css("zIndex", min + i);
  2050. });
  2051. this.css("zIndex", (min + group.length));
  2052. }
  2053. });
  2054. $.ui.plugin.add("draggable", "zIndex", {
  2055. start: function(event, ui) {
  2056. var t = $(ui.helper), o = $(this).data("ui-draggable").options;
  2057. if(t.css("zIndex")) {
  2058. o._zIndex = t.css("zIndex");
  2059. }
  2060. t.css("zIndex", o.zIndex);
  2061. },
  2062. stop: function(event, ui) {
  2063. var o = $(this).data("ui-draggable").options;
  2064. if(o._zIndex) {
  2065. $(ui.helper).css("zIndex", o._zIndex);
  2066. }
  2067. }
  2068. });
  2069. })(jQuery);
  2070. (function( $, undefined ) {
  2071. function isOverAxis( x, reference, size ) {
  2072. return ( x > reference ) && ( x < ( reference + size ) );
  2073. }
  2074. $.widget("ui.droppable", {
  2075. version: "1.10.3",
  2076. widgetEventPrefix: "drop",
  2077. options: {
  2078. accept: "*",
  2079. activeClass: false,
  2080. addClasses: true,
  2081. greedy: false,
  2082. hoverClass: false,
  2083. scope: "default",
  2084. tolerance: "intersect",
  2085. // callbacks
  2086. activate: null,
  2087. deactivate: null,
  2088. drop: null,
  2089. out: null,
  2090. over: null
  2091. },
  2092. _create: function() {
  2093. var o = this.options,
  2094. accept = o.accept;
  2095. this.isover = false;
  2096. this.isout = true;
  2097. this.accept = $.isFunction(accept) ? accept : function(d) {
  2098. return d.is(accept);
  2099. };
  2100. //Store the droppable's proportions
  2101. this.proportions = { width: this.element[0].offsetWidth, height: this.element[0].offsetHeight };
  2102. // Add the reference and positions to the manager
  2103. $.ui.ddmanager.droppables[o.scope] = $.ui.ddmanager.droppables[o.scope] || [];
  2104. $.ui.ddmanager.droppables[o.scope].push(this);
  2105. (o.addClasses && this.element.addClass("ui-droppable"));
  2106. },
  2107. _destroy: function() {
  2108. var i = 0,
  2109. drop = $.ui.ddmanager.droppables[this.options.scope];
  2110. for ( ; i < drop.length; i++ ) {
  2111. if ( drop[i] === this ) {
  2112. drop.splice(i, 1);
  2113. }
  2114. }
  2115. this.element.removeClass("ui-droppable ui-droppable-disabled");
  2116. },
  2117. _setOption: function(key, value) {
  2118. if(key === "accept") {
  2119. this.accept = $.isFunction(value) ? value : function(d) {
  2120. return d.is(value);
  2121. };
  2122. }
  2123. $.Widget.prototype._setOption.apply(this, arguments);
  2124. },
  2125. _activate: function(event) {
  2126. var draggable = $.ui.ddmanager.current;
  2127. if(this.options.activeClass) {
  2128. this.element.addClass(this.options.activeClass);
  2129. }
  2130. if(draggable){
  2131. this._trigger("activate", event, this.ui(draggable));
  2132. }
  2133. },
  2134. _deactivate: function(event) {
  2135. var draggable = $.ui.ddmanager.current;
  2136. if(this.options.activeClass) {
  2137. this.element.removeClass(this.options.activeClass);
  2138. }
  2139. if(draggable){
  2140. this._trigger("deactivate", event, this.ui(draggable));
  2141. }
  2142. },
  2143. _over: function(event) {
  2144. var draggable = $.ui.ddmanager.current;
  2145. // Bail if draggable and droppable are same element
  2146. if (!draggable || (draggable.currentItem || draggable.element)[0] === this.element[0]) {
  2147. return;
  2148. }
  2149. if (this.accept.call(this.element[0],(draggable.currentItem || draggable.element))) {
  2150. if(this.options.hoverClass) {
  2151. this.element.addClass(this.options.hoverClass);
  2152. }
  2153. this._trigger("over", event, this.ui(draggable));
  2154. }
  2155. },
  2156. _out: function(event) {
  2157. var draggable = $.ui.ddmanager.current;
  2158. // Bail if draggable and droppable are same element
  2159. if (!draggable || (draggable.currentItem || draggable.element)[0] === this.element[0]) {
  2160. return;
  2161. }
  2162. if (this.accept.call(this.element[0],(draggable.currentItem || draggable.element))) {
  2163. if(this.options.hoverClass) {
  2164. this.element.removeClass(this.options.hoverClass);
  2165. }
  2166. this._trigger("out", event, this.ui(draggable));
  2167. }
  2168. },
  2169. _drop: function(event,custom) {
  2170. var draggable = custom || $.ui.ddmanager.current,
  2171. childrenIntersection = false;
  2172. // Bail if draggable and droppable are same element
  2173. if (!draggable || (draggable.currentItem || draggable.element)[0] === this.element[0]) {
  2174. return false;
  2175. }
  2176. this.element.find(":data(ui-droppable)").not(".ui-draggable-dragging").each(function() {
  2177. var inst = $.data(this, "ui-droppable");
  2178. if(
  2179. inst.options.greedy &&
  2180. !inst.options.disabled &&
  2181. inst.options.scope === draggable.options.scope &&
  2182. inst.accept.call(inst.element[0], (draggable.currentItem || draggable.element)) &&
  2183. $.ui.intersect(draggable, $.extend(inst, { offset: inst.element.offset() }), inst.options.tolerance)
  2184. ) { childrenIntersection = true; return false; }
  2185. });
  2186. if(childrenIntersection) {
  2187. return false;
  2188. }
  2189. if(this.accept.call(this.element[0],(draggable.currentItem || draggable.element))) {
  2190. if(this.options.activeClass) {
  2191. this.element.removeClass(this.options.activeClass);
  2192. }
  2193. if(this.options.hoverClass) {
  2194. this.element.removeClass(this.options.hoverClass);
  2195. }
  2196. this._trigger("drop", event, this.ui(draggable));
  2197. return this.element;
  2198. }
  2199. return false;
  2200. },
  2201. ui: function(c) {
  2202. return {
  2203. draggable: (c.currentItem || c.element),
  2204. helper: c.helper,
  2205. position: c.position,
  2206. offset: c.positionAbs
  2207. };
  2208. }
  2209. });
  2210. $.ui.intersect = function(draggable, droppable, toleranceMode) {
  2211. if (!droppable.offset) {
  2212. return false;
  2213. }
  2214. var draggableLeft, draggableTop,
  2215. x1 = (draggable.positionAbs || draggable.position.absolute).left, x2 = x1 + draggable.helperProportions.width,
  2216. y1 = (draggable.positionAbs || draggable.position.absolute).top, y2 = y1 + draggable.helperProportions.height,
  2217. l = droppable.offset.left, r = l + droppable.proportions.width,
  2218. t = droppable.offset.top, b = t + droppable.proportions.height;
  2219. switch (toleranceMode) {
  2220. case "fit":
  2221. return (l <= x1 && x2 <= r && t <= y1 && y2 <= b);
  2222. case "intersect":
  2223. return (l < x1 + (draggable.helperProportions.width / 2) && // Right Half
  2224. x2 - (draggable.helperProportions.width / 2) < r && // Left Half
  2225. t < y1 + (draggable.helperProportions.height / 2) && // Bottom Half
  2226. y2 - (draggable.helperProportions.height / 2) < b ); // Top Half
  2227. case "pointer":
  2228. draggableLeft = ((draggable.positionAbs || draggable.position.absolute).left + (draggable.clickOffset || draggable.offset.click).left);
  2229. draggableTop = ((draggable.positionAbs || draggable.position.absolute).top + (draggable.clickOffset || draggable.offset.click).top);
  2230. return isOverAxis( draggableTop, t, droppable.proportions.height ) && isOverAxis( draggableLeft, l, droppable.proportions.width );
  2231. case "touch":
  2232. return (
  2233. (y1 >= t && y1 <= b) || // Top edge touching
  2234. (y2 >= t && y2 <= b) || // Bottom edge touching
  2235. (y1 < t && y2 > b) // Surrounded vertically
  2236. ) && (
  2237. (x1 >= l && x1 <= r) || // Left edge touching
  2238. (x2 >= l && x2 <= r) || // Right edge touching
  2239. (x1 < l && x2 > r) // Surrounded horizontally
  2240. );
  2241. default:
  2242. return false;
  2243. }
  2244. };
  2245. /*
  2246. This manager tracks offsets of draggables and droppables
  2247. */
  2248. $.ui.ddmanager = {
  2249. current: null,
  2250. droppables: { "default": [] },
  2251. prepareOffsets: function(t, event) {
  2252. var i, j,
  2253. m = $.ui.ddmanager.droppables[t.options.scope] || [],
  2254. type = event ? event.type : null, // workaround for #2317
  2255. list = (t.currentItem || t.element).find(":data(ui-droppable)").addBack();
  2256. droppablesLoop: for (i = 0; i < m.length; i++) {
  2257. //No disabled and non-accepted
  2258. if(m[i].options.disabled || (t && !m[i].accept.call(m[i].element[0],(t.currentItem || t.element)))) {
  2259. continue;
  2260. }
  2261. // Filter out elements in the current dragged item
  2262. for (j=0; j < list.length; j++) {
  2263. if(list[j] === m[i].element[0]) {
  2264. m[i].proportions.height = 0;
  2265. continue droppablesLoop;
  2266. }
  2267. }
  2268. m[i].visible = m[i].element.css("display") !== "none";
  2269. if(!m[i].visible) {
  2270. continue;
  2271. }
  2272. //Activate the droppable if used directly from draggables
  2273. if(type === "mousedown") {
  2274. m[i]._activate.call(m[i], event);
  2275. }
  2276. m[i].offset = m[i].element.offset();
  2277. m[i].proportions = { width: m[i].element[0].offsetWidth, height: m[i].element[0].offsetHeight };
  2278. }
  2279. },
  2280. drop: function(draggable, event) {
  2281. var dropped = false;
  2282. // Create a copy of the droppables in case the list changes during the drop (#9116)
  2283. $.each(($.ui.ddmanager.droppables[draggable.options.scope] || []).slice(), function() {
  2284. if(!this.options) {
  2285. return;
  2286. }
  2287. if (!this.options.disabled && this.visible && $.ui.intersect(draggable, this, this.options.tolerance)) {
  2288. dropped = this._drop.call(this, event) || dropped;
  2289. }
  2290. if (!this.options.disabled && this.visible && this.accept.call(this.element[0],(draggable.currentItem || draggable.element))) {
  2291. this.isout = true;
  2292. this.isover = false;
  2293. this._deactivate.call(this, event);
  2294. }
  2295. });
  2296. return dropped;
  2297. },
  2298. dragStart: function( draggable, event ) {
  2299. //Listen for scrolling so that if the dragging causes scrolling the position of the droppables can be recalculated (see #5003)
  2300. draggable.element.parentsUntil( "body" ).bind( "scroll.droppable", function() {
  2301. if( !draggable.options.refreshPositions ) {
  2302. $.ui.ddmanager.prepareOffsets( draggable, event );
  2303. }
  2304. });
  2305. },
  2306. drag: function(draggable, event) {
  2307. //If you have a highly dynamic page, you might try this option. It renders positions every time you move the mouse.
  2308. if(draggable.options.refreshPositions) {
  2309. $.ui.ddmanager.prepareOffsets(draggable, event);
  2310. }
  2311. //Run through all droppables and check their positions based on specific tolerance options
  2312. $.each($.ui.ddmanager.droppables[draggable.options.scope] || [], function() {
  2313. if(this.options.disabled || this.greedyChild || !this.visible) {
  2314. return;
  2315. }
  2316. var parentInstance, scope, parent,
  2317. intersects = $.ui.intersect(draggable, this, this.options.tolerance),
  2318. c = !intersects && this.isover ? "isout" : (intersects && !this.isover ? "isover" : null);
  2319. if(!c) {
  2320. return;
  2321. }
  2322. if (this.options.greedy) {
  2323. // find droppable parents with same scope
  2324. scope = this.options.scope;
  2325. parent = this.element.parents(":data(ui-droppable)").filter(function () {
  2326. return $.data(this, "ui-droppable").options.scope === scope;
  2327. });
  2328. if (parent.length) {
  2329. parentInstance = $.data(parent[0], "ui-droppable");
  2330. parentInstance.greedyChild = (c === "isover");
  2331. }
  2332. }
  2333. // we just moved into a greedy child
  2334. if (parentInstance && c === "isover") {
  2335. parentInstance.isover = false;
  2336. parentInstance.isout = true;
  2337. parentInstance._out.call(parentInstance, event);
  2338. }
  2339. this[c] = true;
  2340. this[c === "isout" ? "isover" : "isout"] = false;
  2341. this[c === "isover" ? "_over" : "_out"].call(this, event);
  2342. // we just moved out of a greedy child
  2343. if (parentInstance && c === "isout") {
  2344. parentInstance.isout = false;
  2345. parentInstance.isover = true;
  2346. parentInstance._over.call(parentInstance, event);
  2347. }
  2348. });
  2349. },
  2350. dragStop: function( draggable, event ) {
  2351. draggable.element.parentsUntil( "body" ).unbind( "scroll.droppable" );
  2352. //Call prepareOffsets one final time since IE does not fire return scroll events when overflow was caused by drag (see #5003)
  2353. if( !draggable.options.refreshPositions ) {
  2354. $.ui.ddmanager.prepareOffsets( draggable, event );
  2355. }
  2356. }
  2357. };
  2358. })(jQuery);
  2359. (function( $, undefined ) {
  2360. function num(v) {
  2361. return parseInt(v, 10) || 0;
  2362. }
  2363. function isNumber(value) {
  2364. return !isNaN(parseInt(value, 10));
  2365. }
  2366. $.widget("ui.resizable", $.ui.mouse, {
  2367. version: "1.10.3",
  2368. widgetEventPrefix: "resize",
  2369. options: {
  2370. alsoResize: false,
  2371. animate: false,
  2372. animateDuration: "slow",
  2373. animateEasing: "swing",
  2374. aspectRatio: false,
  2375. autoHide: false,
  2376. containment: false,
  2377. ghost: false,
  2378. grid: false,
  2379. handles: "e,s,se",
  2380. helper: false,
  2381. maxHeight: null,
  2382. maxWidth: null,
  2383. minHeight: 10,
  2384. minWidth: 10,
  2385. // See #7960
  2386. zIndex: 90,
  2387. // callbacks
  2388. resize: null,
  2389. start: null,
  2390. stop: null
  2391. },
  2392. _create: function() {
  2393. var n, i, handle, axis, hname,
  2394. that = this,
  2395. o = this.options;
  2396. this.element.addClass("ui-resizable");
  2397. $.extend(this, {
  2398. _aspectRatio: !!(o.aspectRatio),
  2399. aspectRatio: o.aspectRatio,
  2400. originalElement: this.element,
  2401. _proportionallyResizeElements: [],
  2402. _helper: o.helper || o.ghost || o.animate ? o.helper || "ui-resizable-helper" : null
  2403. });
  2404. //Wrap the element if it cannot hold child nodes
  2405. if(this.element[0].nodeName.match(/canvas|textarea|input|select|button|img/i)) {
  2406. //Create a wrapper element and set the wrapper to the new current internal element
  2407. this.element.wrap(
  2408. $("<div class='ui-wrapper' style='overflow: hidden;'></div>").css({
  2409. position: this.element.css("position"),
  2410. width: this.element.outerWidth(),
  2411. height: this.element.outerHeight(),
  2412. top: this.element.css("top"),
  2413. left: this.element.css("left")
  2414. })
  2415. );
  2416. //Overwrite the original this.element
  2417. this.element = this.element.parent().data(
  2418. "ui-resizable", this.element.data("ui-resizable")
  2419. );
  2420. this.elementIsWrapper = true;
  2421. //Move margins to the wrapper
  2422. this.element.css({ marginLeft: this.originalElement.css("marginLeft"), marginTop: this.originalElement.css("marginTop"), marginRight: this.originalElement.css("marginRight"), marginBottom: this.originalElement.css("marginBottom") });
  2423. this.originalElement.css({ marginLeft: 0, marginTop: 0, marginRight: 0, marginBottom: 0});
  2424. //Prevent Safari textarea resize
  2425. this.originalResizeStyle = this.originalElement.css("resize");
  2426. this.originalElement.css("resize", "none");
  2427. //Push the actual element to our proportionallyResize internal array
  2428. this._proportionallyResizeElements.push(this.originalElement.css({ position: "static", zoom: 1, display: "block" }));
  2429. // avoid IE jump (hard set the margin)
  2430. this.originalElement.css({ margin: this.originalElement.css("margin") });
  2431. // fix handlers offset
  2432. this._proportionallyResize();
  2433. }
  2434. 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" });
  2435. if(this.handles.constructor === String) {
  2436. if ( this.handles === "all") {
  2437. this.handles = "n,e,s,w,se,sw,ne,nw";
  2438. }
  2439. n = this.handles.split(",");
  2440. this.handles = {};
  2441. for(i = 0; i < n.length; i++) {
  2442. handle = $.trim(n[i]);
  2443. hname = "ui-resizable-"+handle;
  2444. axis = $("<div class='ui-resizable-handle " + hname + "'></div>");
  2445. // Apply zIndex to all handles - see #7960
  2446. axis.css({ zIndex: o.zIndex });
  2447. //TODO : What's going on here?
  2448. if ("se" === handle) {
  2449. axis.addClass("ui-icon ui-icon-gripsmall-diagonal-se");
  2450. }
  2451. //Insert into internal handles object and append to element
  2452. this.handles[handle] = ".ui-resizable-"+handle;
  2453. this.element.append(axis);
  2454. }
  2455. }
  2456. this._renderAxis = function(target) {
  2457. var i, axis, padPos, padWrapper;
  2458. target = target || this.element;
  2459. for(i in this.handles) {
  2460. if(this.handles[i].constructor === String) {
  2461. this.handles[i] = $(this.handles[i], this.element).show();
  2462. }
  2463. //Apply pad to wrapper element, needed to fix axis position (textarea, inputs, scrolls)
  2464. if (this.elementIsWrapper && this.originalElement[0].nodeName.match(/textarea|input|select|button/i)) {
  2465. axis = $(this.handles[i], this.element);
  2466. //Checking the correct pad and border
  2467. padWrapper = /sw|ne|nw|se|n|s/.test(i) ? axis.outerHeight() : axis.outerWidth();
  2468. //The padding type i have to apply...
  2469. padPos = [ "padding",
  2470. /ne|nw|n/.test(i) ? "Top" :
  2471. /se|sw|s/.test(i) ? "Bottom" :
  2472. /^e$/.test(i) ? "Right" : "Left" ].join("");
  2473. target.css(padPos, padWrapper);
  2474. this._proportionallyResize();
  2475. }
  2476. //TODO: What's that good for? There's not anything to be executed left
  2477. if(!$(this.handles[i]).length) {
  2478. continue;
  2479. }
  2480. }
  2481. };
  2482. //TODO: make renderAxis a prototype function
  2483. this._renderAxis(this.element);
  2484. this._handles = $(".ui-resizable-handle", this.element)
  2485. .disableSelection();
  2486. //Matching axis name
  2487. this._handles.mouseover(function() {
  2488. if (!that.resizing) {
  2489. if (this.className) {
  2490. axis = this.className.match(/ui-resizable-(se|sw|ne|nw|n|e|s|w)/i);
  2491. }
  2492. //Axis, default = se
  2493. that.axis = axis && axis[1] ? axis[1] : "se";
  2494. }
  2495. });
  2496. //If we want to auto hide the elements
  2497. if (o.autoHide) {
  2498. this._handles.hide();
  2499. $(this.element)
  2500. .addClass("ui-resizable-autohide")
  2501. .mouseenter(function() {
  2502. if (o.disabled) {
  2503. return;
  2504. }
  2505. $(this).removeClass("ui-resizable-autohide");
  2506. that._handles.show();
  2507. })
  2508. .mouseleave(function(){
  2509. if (o.disabled) {
  2510. return;
  2511. }
  2512. if (!that.resizing) {
  2513. $(this).addClass("ui-resizable-autohide");
  2514. that._handles.hide();
  2515. }
  2516. });
  2517. }
  2518. //Initialize the mouse interaction
  2519. this._mouseInit();
  2520. },
  2521. _destroy: function() {
  2522. this._mouseDestroy();
  2523. var wrapper,
  2524. _destroy = function(exp) {
  2525. $(exp).removeClass("ui-resizable ui-resizable-disabled ui-resizable-resizing")
  2526. .removeData("resizable").removeData("ui-resizable").unbind(".resizable").find(".ui-resizable-handle").remove();
  2527. };
  2528. //TODO: Unwrap at same DOM position
  2529. if (this.elementIsWrapper) {
  2530. _destroy(this.element);
  2531. wrapper = this.element;
  2532. this.originalElement.css({
  2533. position: wrapper.css("position"),
  2534. width: wrapper.outerWidth(),
  2535. height: wrapper.outerHeight(),
  2536. top: wrapper.css("top"),
  2537. left: wrapper.css("left")
  2538. }).insertAfter( wrapper );
  2539. wrapper.remove();
  2540. }
  2541. this.originalElement.css("resize", this.originalResizeStyle);
  2542. _destroy(this.originalElement);
  2543. return this;
  2544. },
  2545. _mouseCapture: function(event) {
  2546. var i, handle,
  2547. capture = false;
  2548. for (i in this.handles) {
  2549. handle = $(this.handles[i])[0];
  2550. if (handle === event.target || $.contains(handle, event.target)) {
  2551. capture = true;
  2552. }
  2553. }
  2554. return !this.options.disabled && capture;
  2555. },
  2556. _mouseStart: function(event) {
  2557. var curleft, curtop, cursor,
  2558. o = this.options,
  2559. iniPos = this.element.position(),
  2560. el = this.element;
  2561. this.resizing = true;
  2562. // bugfix for http://dev.jquery.com/ticket/1749
  2563. if ( (/absolute/).test( el.css("position") ) ) {
  2564. el.css({ position: "absolute", top: el.css("top"), left: el.css("left") });
  2565. } else if (el.is(".ui-draggable")) {
  2566. el.css({ position: "absolute", top: iniPos.top, left: iniPos.left });
  2567. }
  2568. this._renderProxy();
  2569. curleft = num(this.helper.css("left"));
  2570. curtop = num(this.helper.css("top"));
  2571. if (o.containment) {
  2572. curleft += $(o.containment).scrollLeft() || 0;
  2573. curtop += $(o.containment).scrollTop() || 0;
  2574. }
  2575. //Store needed variables
  2576. this.offset = this.helper.offset();
  2577. this.position = { left: curleft, top: curtop };
  2578. this.size = this._helper ? { width: el.outerWidth(), height: el.outerHeight() } : { width: el.width(), height: el.height() };
  2579. this.originalSize = this._helper ? { width: el.outerWidth(), height: el.outerHeight() } : { width: el.width(), height: el.height() };
  2580. this.originalPosition = { left: curleft, top: curtop };
  2581. this.sizeDiff = { width: el.outerWidth() - el.width(), height: el.outerHeight() - el.height() };
  2582. this.originalMousePosition = { left: event.pageX, top: event.pageY };
  2583. //Aspect Ratio
  2584. this.aspectRatio = (typeof o.aspectRatio === "number") ? o.aspectRatio : ((this.originalSize.width / this.originalSize.height) || 1);
  2585. cursor = $(".ui-resizable-" + this.axis).css("cursor");
  2586. $("body").css("cursor", cursor === "auto" ? this.axis + "-resize" : cursor);
  2587. el.addClass("ui-resizable-resizing");
  2588. this._propagate("start", event);
  2589. return true;
  2590. },
  2591. _mouseDrag: function(event) {
  2592. //Increase performance, avoid regex
  2593. var data,
  2594. el = this.helper, props = {},
  2595. smp = this.originalMousePosition,
  2596. a = this.axis,
  2597. prevTop = this.position.top,
  2598. prevLeft = this.position.left,
  2599. prevWidth = this.size.width,
  2600. prevHeight = this.size.height,
  2601. dx = (event.pageX-smp.left)||0,
  2602. dy = (event.pageY-smp.top)||0,
  2603. trigger = this._change[a];
  2604. if (!trigger) {
  2605. return false;
  2606. }
  2607. // Calculate the attrs that will be change
  2608. data = trigger.apply(this, [event, dx, dy]);
  2609. // Put this in the mouseDrag handler since the user can start pressing shift while resizing
  2610. this._updateVirtualBoundaries(event.shiftKey);
  2611. if (this._aspectRatio || event.shiftKey) {
  2612. data = this._updateRatio(data, event);
  2613. }
  2614. data = this._respectSize(data, event);
  2615. this._updateCache(data);
  2616. // plugins callbacks need to be called first
  2617. this._propagate("resize", event);
  2618. if (this.position.top !== prevTop) {
  2619. props.top = this.position.top + "px";
  2620. }
  2621. if (this.position.left !== prevLeft) {
  2622. props.left = this.position.left + "px";
  2623. }
  2624. if (this.size.width !== prevWidth) {
  2625. props.width = this.size.width + "px";
  2626. }
  2627. if (this.size.height !== prevHeight) {
  2628. props.height = this.size.height + "px";
  2629. }
  2630. el.css(props);
  2631. if (!this._helper && this._proportionallyResizeElements.length) {
  2632. this._proportionallyResize();
  2633. }
  2634. // Call the user callback if the element was resized
  2635. if ( ! $.isEmptyObject(props) ) {
  2636. this._trigger("resize", event, this.ui());
  2637. }
  2638. return false;
  2639. },
  2640. _mouseStop: function(event) {
  2641. this.resizing = false;
  2642. var pr, ista, soffseth, soffsetw, s, left, top,
  2643. o = this.options, that = this;
  2644. if(this._helper) {
  2645. pr = this._proportionallyResizeElements;
  2646. ista = pr.length && (/textarea/i).test(pr[0].nodeName);
  2647. soffseth = ista && $.ui.hasScroll(pr[0], "left") /* TODO - jump height */ ? 0 : that.sizeDiff.height;
  2648. soffsetw = ista ? 0 : that.sizeDiff.width;
  2649. s = { width: (that.helper.width() - soffsetw), height: (that.helper.height() - soffseth) };
  2650. left = (parseInt(that.element.css("left"), 10) + (that.position.left - that.originalPosition.left)) || null;
  2651. top = (parseInt(that.element.css("top"), 10) + (that.position.top - that.originalPosition.top)) || null;
  2652. if (!o.animate) {
  2653. this.element.css($.extend(s, { top: top, left: left }));
  2654. }
  2655. that.helper.height(that.size.height);
  2656. that.helper.width(that.size.width);
  2657. if (this._helper && !o.animate) {
  2658. this._proportionallyResize();
  2659. }
  2660. }
  2661. $("body").css("cursor", "auto");
  2662. this.element.removeClass("ui-resizable-resizing");
  2663. this._propagate("stop", event);
  2664. if (this._helper) {
  2665. this.helper.remove();
  2666. }
  2667. return false;
  2668. },
  2669. _updateVirtualBoundaries: function(forceAspectRatio) {
  2670. var pMinWidth, pMaxWidth, pMinHeight, pMaxHeight, b,
  2671. o = this.options;
  2672. b = {
  2673. minWidth: isNumber(o.minWidth) ? o.minWidth : 0,
  2674. maxWidth: isNumber(o.maxWidth) ? o.maxWidth : Infinity,
  2675. minHeight: isNumber(o.minHeight) ? o.minHeight : 0,
  2676. maxHeight: isNumber(o.maxHeight) ? o.maxHeight : Infinity
  2677. };
  2678. if(this._aspectRatio || forceAspectRatio) {
  2679. // We want to create an enclosing box whose aspect ration is the requested one
  2680. // First, compute the "projected" size for each dimension based on the aspect ratio and other dimension
  2681. pMinWidth = b.minHeight * this.aspectRatio;
  2682. pMinHeight = b.minWidth / this.aspectRatio;
  2683. pMaxWidth = b.maxHeight * this.aspectRatio;
  2684. pMaxHeight = b.maxWidth / this.aspectRatio;
  2685. if(pMinWidth > b.minWidth) {
  2686. b.minWidth = pMinWidth;
  2687. }
  2688. if(pMinHeight > b.minHeight) {
  2689. b.minHeight = pMinHeight;
  2690. }
  2691. if(pMaxWidth < b.maxWidth) {
  2692. b.maxWidth = pMaxWidth;
  2693. }
  2694. if(pMaxHeight < b.maxHeight) {
  2695. b.maxHeight = pMaxHeight;
  2696. }
  2697. }
  2698. this._vBoundaries = b;
  2699. },
  2700. _updateCache: function(data) {
  2701. this.offset = this.helper.offset();
  2702. if (isNumber(data.left)) {
  2703. this.position.left = data.left;
  2704. }
  2705. if (isNumber(data.top)) {
  2706. this.position.top = data.top;
  2707. }
  2708. if (isNumber(data.height)) {
  2709. this.size.height = data.height;
  2710. }
  2711. if (isNumber(data.width)) {
  2712. this.size.width = data.width;
  2713. }
  2714. },
  2715. _updateRatio: function( data ) {
  2716. var cpos = this.position,
  2717. csize = this.size,
  2718. a = this.axis;
  2719. if (isNumber(data.height)) {
  2720. data.width = (data.height * this.aspectRatio);
  2721. } else if (isNumber(data.width)) {
  2722. data.height = (data.width / this.aspectRatio);
  2723. }
  2724. if (a === "sw") {
  2725. data.left = cpos.left + (csize.width - data.width);
  2726. data.top = null;
  2727. }
  2728. if (a === "nw") {
  2729. data.top = cpos.top + (csize.height - data.height);
  2730. data.left = cpos.left + (csize.width - data.width);
  2731. }
  2732. return data;
  2733. },
  2734. _respectSize: function( data ) {
  2735. var o = this._vBoundaries,
  2736. a = this.axis,
  2737. ismaxw = isNumber(data.width) && o.maxWidth && (o.maxWidth < data.width), ismaxh = isNumber(data.height) && o.maxHeight && (o.maxHeight < data.height),
  2738. isminw = isNumber(data.width) && o.minWidth && (o.minWidth > data.width), isminh = isNumber(data.height) && o.minHeight && (o.minHeight > data.height),
  2739. dw = this.originalPosition.left + this.originalSize.width,
  2740. dh = this.position.top + this.size.height,
  2741. cw = /sw|nw|w/.test(a), ch = /nw|ne|n/.test(a);
  2742. if (isminw) {
  2743. data.width = o.minWidth;
  2744. }
  2745. if (isminh) {
  2746. data.height = o.minHeight;
  2747. }
  2748. if (ismaxw) {
  2749. data.width = o.maxWidth;
  2750. }
  2751. if (ismaxh) {
  2752. data.height = o.maxHeight;
  2753. }
  2754. if (isminw && cw) {
  2755. data.left = dw - o.minWidth;
  2756. }
  2757. if (ismaxw && cw) {
  2758. data.left = dw - o.maxWidth;
  2759. }
  2760. if (isminh && ch) {
  2761. data.top = dh - o.minHeight;
  2762. }
  2763. if (ismaxh && ch) {
  2764. data.top = dh - o.maxHeight;
  2765. }
  2766. // fixing jump error on top/left - bug #2330
  2767. if (!data.width && !data.height && !data.left && data.top) {
  2768. data.top = null;
  2769. } else if (!data.width && !data.height && !data.top && data.left) {
  2770. data.left = null;
  2771. }
  2772. return data;
  2773. },
  2774. _proportionallyResize: function() {
  2775. if (!this._proportionallyResizeElements.length) {
  2776. return;
  2777. }
  2778. var i, j, borders, paddings, prel,
  2779. element = this.helper || this.element;
  2780. for ( i=0; i < this._proportionallyResizeElements.length; i++) {
  2781. prel = this._proportionallyResizeElements[i];
  2782. if (!this.borderDif) {
  2783. this.borderDif = [];
  2784. borders = [prel.css("borderTopWidth"), prel.css("borderRightWidth"), prel.css("borderBottomWidth"), prel.css("borderLeftWidth")];
  2785. paddings = [prel.css("paddingTop"), prel.css("paddingRight"), prel.css("paddingBottom"), prel.css("paddingLeft")];
  2786. for ( j = 0; j < borders.length; j++ ) {
  2787. this.borderDif[ j ] = ( parseInt( borders[ j ], 10 ) || 0 ) + ( parseInt( paddings[ j ], 10 ) || 0 );
  2788. }
  2789. }
  2790. prel.css({
  2791. height: (element.height() - this.borderDif[0] - this.borderDif[2]) || 0,
  2792. width: (element.width() - this.borderDif[1] - this.borderDif[3]) || 0
  2793. });
  2794. }
  2795. },
  2796. _renderProxy: function() {
  2797. var el = this.element, o = this.options;
  2798. this.elementOffset = el.offset();
  2799. if(this._helper) {
  2800. this.helper = this.helper || $("<div style='overflow:hidden;'></div>");
  2801. this.helper.addClass(this._helper).css({
  2802. width: this.element.outerWidth() - 1,
  2803. height: this.element.outerHeight() - 1,
  2804. position: "absolute",
  2805. left: this.elementOffset.left +"px",
  2806. top: this.elementOffset.top +"px",
  2807. zIndex: ++o.zIndex //TODO: Don't modify option
  2808. });
  2809. this.helper
  2810. .appendTo("body")
  2811. .disableSelection();
  2812. } else {
  2813. this.helper = this.element;
  2814. }
  2815. },
  2816. _change: {
  2817. e: function(event, dx) {
  2818. return { width: this.originalSize.width + dx };
  2819. },
  2820. w: function(event, dx) {
  2821. var cs = this.originalSize, sp = this.originalPosition;
  2822. return { left: sp.left + dx, width: cs.width - dx };
  2823. },
  2824. n: function(event, dx, dy) {
  2825. var cs = this.originalSize, sp = this.originalPosition;
  2826. return { top: sp.top + dy, height: cs.height - dy };
  2827. },
  2828. s: function(event, dx, dy) {
  2829. return { height: this.originalSize.height + dy };
  2830. },
  2831. se: function(event, dx, dy) {
  2832. return $.extend(this._change.s.apply(this, arguments), this._change.e.apply(this, [event, dx, dy]));
  2833. },
  2834. sw: function(event, dx, dy) {
  2835. return $.extend(this._change.s.apply(this, arguments), this._change.w.apply(this, [event, dx, dy]));
  2836. },
  2837. ne: function(event, dx, dy) {
  2838. return $.extend(this._change.n.apply(this, arguments), this._change.e.apply(this, [event, dx, dy]));
  2839. },
  2840. nw: function(event, dx, dy) {
  2841. return $.extend(this._change.n.apply(this, arguments), this._change.w.apply(this, [event, dx, dy]));
  2842. }
  2843. },
  2844. _propagate: function(n, event) {
  2845. $.ui.plugin.call(this, n, [event, this.ui()]);
  2846. (n !== "resize" && this._trigger(n, event, this.ui()));
  2847. },
  2848. plugins: {},
  2849. ui: function() {
  2850. return {
  2851. originalElement: this.originalElement,
  2852. element: this.element,
  2853. helper: this.helper,
  2854. position: this.position,
  2855. size: this.size,
  2856. originalSize: this.originalSize,
  2857. originalPosition: this.originalPosition
  2858. };
  2859. }
  2860. });
  2861. /*
  2862. * Resizable Extensions
  2863. */
  2864. $.ui.plugin.add("resizable", "animate", {
  2865. stop: function( event ) {
  2866. var that = $(this).data("ui-resizable"),
  2867. o = that.options,
  2868. pr = that._proportionallyResizeElements,
  2869. ista = pr.length && (/textarea/i).test(pr[0].nodeName),
  2870. soffseth = ista && $.ui.hasScroll(pr[0], "left") /* TODO - jump height */ ? 0 : that.sizeDiff.height,
  2871. soffsetw = ista ? 0 : that.sizeDiff.width,
  2872. style = { width: (that.size.width - soffsetw), height: (that.size.height - soffseth) },
  2873. left = (parseInt(that.element.css("left"), 10) + (that.position.left - that.originalPosition.left)) || null,
  2874. top = (parseInt(that.element.css("top"), 10) + (that.position.top - that.originalPosition.top)) || null;
  2875. that.element.animate(
  2876. $.extend(style, top && left ? { top: top, left: left } : {}), {
  2877. duration: o.animateDuration,
  2878. easing: o.animateEasing,
  2879. step: function() {
  2880. var data = {
  2881. width: parseInt(that.element.css("width"), 10),
  2882. height: parseInt(that.element.css("height"), 10),
  2883. top: parseInt(that.element.css("top"), 10),
  2884. left: parseInt(that.element.css("left"), 10)
  2885. };
  2886. if (pr && pr.length) {
  2887. $(pr[0]).css({ width: data.width, height: data.height });
  2888. }
  2889. // propagating resize, and updating values for each animation step
  2890. that._updateCache(data);
  2891. that._propagate("resize", event);
  2892. }
  2893. }
  2894. );
  2895. }
  2896. });
  2897. $.ui.plugin.add("resizable", "containment", {
  2898. start: function() {
  2899. var element, p, co, ch, cw, width, height,
  2900. that = $(this).data("ui-resizable"),
  2901. o = that.options,
  2902. el = that.element,
  2903. oc = o.containment,
  2904. ce = (oc instanceof $) ? oc.get(0) : (/parent/.test(oc)) ? el.parent().get(0) : oc;
  2905. if (!ce) {
  2906. return;
  2907. }
  2908. that.containerElement = $(ce);
  2909. if (/document/.test(oc) || oc === document) {
  2910. that.containerOffset = { left: 0, top: 0 };
  2911. that.containerPosition = { left: 0, top: 0 };
  2912. that.parentData = {
  2913. element: $(document), left: 0, top: 0,
  2914. width: $(document).width(), height: $(document).height() || document.body.parentNode.scrollHeight
  2915. };
  2916. }
  2917. // i'm a node, so compute top, left, right, bottom
  2918. else {
  2919. element = $(ce);
  2920. p = [];
  2921. $([ "Top", "Right", "Left", "Bottom" ]).each(function(i, name) { p[i] = num(element.css("padding" + name)); });
  2922. that.containerOffset = element.offset();
  2923. that.containerPosition = element.position();
  2924. that.containerSize = { height: (element.innerHeight() - p[3]), width: (element.innerWidth() - p[1]) };
  2925. co = that.containerOffset;
  2926. ch = that.containerSize.height;
  2927. cw = that.containerSize.width;
  2928. width = ($.ui.hasScroll(ce, "left") ? ce.scrollWidth : cw );
  2929. height = ($.ui.hasScroll(ce) ? ce.scrollHeight : ch);
  2930. that.parentData = {
  2931. element: ce, left: co.left, top: co.top, width: width, height: height
  2932. };
  2933. }
  2934. },
  2935. resize: function( event ) {
  2936. var woset, hoset, isParent, isOffsetRelative,
  2937. that = $(this).data("ui-resizable"),
  2938. o = that.options,
  2939. co = that.containerOffset, cp = that.position,
  2940. pRatio = that._aspectRatio || event.shiftKey,
  2941. cop = { top:0, left:0 }, ce = that.containerElement;
  2942. if (ce[0] !== document && (/static/).test(ce.css("position"))) {
  2943. cop = co;
  2944. }
  2945. if (cp.left < (that._helper ? co.left : 0)) {
  2946. that.size.width = that.size.width + (that._helper ? (that.position.left - co.left) : (that.position.left - cop.left));
  2947. if (pRatio) {
  2948. that.size.height = that.size.width / that.aspectRatio;
  2949. }
  2950. that.position.left = o.helper ? co.left : 0;
  2951. }
  2952. if (cp.top < (that._helper ? co.top : 0)) {
  2953. that.size.height = that.size.height + (that._helper ? (that.position.top - co.top) : that.position.top);
  2954. if (pRatio) {
  2955. that.size.width = that.size.height * that.aspectRatio;
  2956. }
  2957. that.position.top = that._helper ? co.top : 0;
  2958. }
  2959. that.offset.left = that.parentData.left+that.position.left;
  2960. that.offset.top = that.parentData.top+that.position.top;
  2961. woset = Math.abs( (that._helper ? that.offset.left - cop.left : (that.offset.left - cop.left)) + that.sizeDiff.width );
  2962. hoset = Math.abs( (that._helper ? that.offset.top - cop.top : (that.offset.top - co.top)) + that.sizeDiff.height );
  2963. isParent = that.containerElement.get(0) === that.element.parent().get(0);
  2964. isOffsetRelative = /relative|absolute/.test(that.containerElement.css("position"));
  2965. if(isParent && isOffsetRelative) {
  2966. woset -= that.parentData.left;
  2967. }
  2968. if (woset + that.size.width >= that.parentData.width) {
  2969. that.size.width = that.parentData.width - woset;
  2970. if (pRatio) {
  2971. that.size.height = that.size.width / that.aspectRatio;
  2972. }
  2973. }
  2974. if (hoset + that.size.height >= that.parentData.height) {
  2975. that.size.height = that.parentData.height - hoset;
  2976. if (pRatio) {
  2977. that.size.width = that.size.height * that.aspectRatio;
  2978. }
  2979. }
  2980. },
  2981. stop: function(){
  2982. var that = $(this).data("ui-resizable"),
  2983. o = that.options,
  2984. co = that.containerOffset,
  2985. cop = that.containerPosition,
  2986. ce = that.containerElement,
  2987. helper = $(that.helper),
  2988. ho = helper.offset(),
  2989. w = helper.outerWidth() - that.sizeDiff.width,
  2990. h = helper.outerHeight() - that.sizeDiff.height;
  2991. if (that._helper && !o.animate && (/relative/).test(ce.css("position"))) {
  2992. $(this).css({ left: ho.left - cop.left - co.left, width: w, height: h });
  2993. }
  2994. if (that._helper && !o.animate && (/static/).test(ce.css("position"))) {
  2995. $(this).css({ left: ho.left - cop.left - co.left, width: w, height: h });
  2996. }
  2997. }
  2998. });
  2999. $.ui.plugin.add("resizable", "alsoResize", {
  3000. start: function () {
  3001. var that = $(this).data("ui-resizable"),
  3002. o = that.options,
  3003. _store = function (exp) {
  3004. $(exp).each(function() {
  3005. var el = $(this);
  3006. el.data("ui-resizable-alsoresize", {
  3007. width: parseInt(el.width(), 10), height: parseInt(el.height(), 10),
  3008. left: parseInt(el.css("left"), 10), top: parseInt(el.css("top"), 10)
  3009. });
  3010. });
  3011. };
  3012. if (typeof(o.alsoResize) === "object" && !o.alsoResize.parentNode) {
  3013. if (o.alsoResize.length) { o.alsoResize = o.alsoResize[0]; _store(o.alsoResize); }
  3014. else { $.each(o.alsoResize, function (exp) { _store(exp); }); }
  3015. }else{
  3016. _store(o.alsoResize);
  3017. }
  3018. },
  3019. resize: function (event, ui) {
  3020. var that = $(this).data("ui-resizable"),
  3021. o = that.options,
  3022. os = that.originalSize,
  3023. op = that.originalPosition,
  3024. delta = {
  3025. height: (that.size.height - os.height) || 0, width: (that.size.width - os.width) || 0,
  3026. top: (that.position.top - op.top) || 0, left: (that.position.left - op.left) || 0
  3027. },
  3028. _alsoResize = function (exp, c) {
  3029. $(exp).each(function() {
  3030. var el = $(this), start = $(this).data("ui-resizable-alsoresize"), style = {},
  3031. css = c && c.length ? c : el.parents(ui.originalElement[0]).length ? ["width", "height"] : ["width", "height", "top", "left"];
  3032. $.each(css, function (i, prop) {
  3033. var sum = (start[prop]||0) + (delta[prop]||0);
  3034. if (sum && sum >= 0) {
  3035. style[prop] = sum || null;
  3036. }
  3037. });
  3038. el.css(style);
  3039. });
  3040. };
  3041. if (typeof(o.alsoResize) === "object" && !o.alsoResize.nodeType) {
  3042. $.each(o.alsoResize, function (exp, c) { _alsoResize(exp, c); });
  3043. }else{
  3044. _alsoResize(o.alsoResize);
  3045. }
  3046. },
  3047. stop: function () {
  3048. $(this).removeData("resizable-alsoresize");
  3049. }
  3050. });
  3051. $.ui.plugin.add("resizable", "ghost", {
  3052. start: function() {
  3053. var that = $(this).data("ui-resizable"), o = that.options, cs = that.size;
  3054. that.ghost = that.originalElement.clone();
  3055. that.ghost
  3056. .css({ opacity: 0.25, display: "block", position: "relative", height: cs.height, width: cs.width, margin: 0, left: 0, top: 0 })
  3057. .addClass("ui-resizable-ghost")
  3058. .addClass(typeof o.ghost === "string" ? o.ghost : "");
  3059. that.ghost.appendTo(that.helper);
  3060. },
  3061. resize: function(){
  3062. var that = $(this).data("ui-resizable");
  3063. if (that.ghost) {
  3064. that.ghost.css({ position: "relative", height: that.size.height, width: that.size.width });
  3065. }
  3066. },
  3067. stop: function() {
  3068. var that = $(this).data("ui-resizable");
  3069. if (that.ghost && that.helper) {
  3070. that.helper.get(0).removeChild(that.ghost.get(0));
  3071. }
  3072. }
  3073. });
  3074. $.ui.plugin.add("resizable", "grid", {
  3075. resize: function() {
  3076. var that = $(this).data("ui-resizable"),
  3077. o = that.options,
  3078. cs = that.size,
  3079. os = that.originalSize,
  3080. op = that.originalPosition,
  3081. a = that.axis,
  3082. grid = typeof o.grid === "number" ? [o.grid, o.grid] : o.grid,
  3083. gridX = (grid[0]||1),
  3084. gridY = (grid[1]||1),
  3085. ox = Math.round((cs.width - os.width) / gridX) * gridX,
  3086. oy = Math.round((cs.height - os.height) / gridY) * gridY,
  3087. newWidth = os.width + ox,
  3088. newHeight = os.height + oy,
  3089. isMaxWidth = o.maxWidth && (o.maxWidth < newWidth),
  3090. isMaxHeight = o.maxHeight && (o.maxHeight < newHeight),
  3091. isMinWidth = o.minWidth && (o.minWidth > newWidth),
  3092. isMinHeight = o.minHeight && (o.minHeight > newHeight);
  3093. o.grid = grid;
  3094. if (isMinWidth) {
  3095. newWidth = newWidth + gridX;
  3096. }
  3097. if (isMinHeight) {
  3098. newHeight = newHeight + gridY;
  3099. }
  3100. if (isMaxWidth) {
  3101. newWidth = newWidth - gridX;
  3102. }
  3103. if (isMaxHeight) {
  3104. newHeight = newHeight - gridY;
  3105. }
  3106. if (/^(se|s|e)$/.test(a)) {
  3107. that.size.width = newWidth;
  3108. that.size.height = newHeight;
  3109. } else if (/^(ne)$/.test(a)) {
  3110. that.size.width = newWidth;
  3111. that.size.height = newHeight;
  3112. that.position.top = op.top - oy;
  3113. } else if (/^(sw)$/.test(a)) {
  3114. that.size.width = newWidth;
  3115. that.size.height = newHeight;
  3116. that.position.left = op.left - ox;
  3117. } else {
  3118. that.size.width = newWidth;
  3119. that.size.height = newHeight;
  3120. that.position.top = op.top - oy;
  3121. that.position.left = op.left - ox;
  3122. }
  3123. }
  3124. });
  3125. })(jQuery);
  3126. (function( $, undefined ) {
  3127. $.widget("ui.selectable", $.ui.mouse, {
  3128. version: "1.10.3",
  3129. options: {
  3130. appendTo: "body",
  3131. autoRefresh: true,
  3132. distance: 0,
  3133. filter: "*",
  3134. tolerance: "touch",
  3135. // callbacks
  3136. selected: null,
  3137. selecting: null,
  3138. start: null,
  3139. stop: null,
  3140. unselected: null,
  3141. unselecting: null
  3142. },
  3143. _create: function() {
  3144. var selectees,
  3145. that = this;
  3146. this.element.addClass("ui-selectable");
  3147. this.dragged = false;
  3148. // cache selectee children based on filter
  3149. this.refresh = function() {
  3150. selectees = $(that.options.filter, that.element[0]);
  3151. selectees.addClass("ui-selectee");
  3152. selectees.each(function() {
  3153. var $this = $(this),
  3154. pos = $this.offset();
  3155. $.data(this, "selectable-item", {
  3156. element: this,
  3157. $element: $this,
  3158. left: pos.left,
  3159. top: pos.top,
  3160. right: pos.left + $this.outerWidth(),
  3161. bottom: pos.top + $this.outerHeight(),
  3162. startselected: false,
  3163. selected: $this.hasClass("ui-selected"),
  3164. selecting: $this.hasClass("ui-selecting"),
  3165. unselecting: $this.hasClass("ui-unselecting")
  3166. });
  3167. });
  3168. };
  3169. this.refresh();
  3170. this.selectees = selectees.addClass("ui-selectee");
  3171. this._mouseInit();
  3172. this.helper = $("<div class='ui-selectable-helper'></div>");
  3173. },
  3174. _destroy: function() {
  3175. this.selectees
  3176. .removeClass("ui-selectee")
  3177. .removeData("selectable-item");
  3178. this.element
  3179. .removeClass("ui-selectable ui-selectable-disabled");
  3180. this._mouseDestroy();
  3181. },
  3182. _mouseStart: function(event) {
  3183. var that = this,
  3184. options = this.options;
  3185. this.opos = [event.pageX, event.pageY];
  3186. if (this.options.disabled) {
  3187. return;
  3188. }
  3189. this.selectees = $(options.filter, this.element[0]);
  3190. this._trigger("start", event);
  3191. $(options.appendTo).append(this.helper);
  3192. // position helper (lasso)
  3193. this.helper.css({
  3194. "left": event.pageX,
  3195. "top": event.pageY,
  3196. "width": 0,
  3197. "height": 0
  3198. });
  3199. if (options.autoRefresh) {
  3200. this.refresh();
  3201. }
  3202. this.selectees.filter(".ui-selected").each(function() {
  3203. var selectee = $.data(this, "selectable-item");
  3204. selectee.startselected = true;
  3205. if (!event.metaKey && !event.ctrlKey) {
  3206. selectee.$element.removeClass("ui-selected");
  3207. selectee.selected = false;
  3208. selectee.$element.addClass("ui-unselecting");
  3209. selectee.unselecting = true;
  3210. // selectable UNSELECTING callback
  3211. that._trigger("unselecting", event, {
  3212. unselecting: selectee.element
  3213. });
  3214. }
  3215. });
  3216. $(event.target).parents().addBack().each(function() {
  3217. var doSelect,
  3218. selectee = $.data(this, "selectable-item");
  3219. if (selectee) {
  3220. doSelect = (!event.metaKey && !event.ctrlKey) || !selectee.$element.hasClass("ui-selected");
  3221. selectee.$element
  3222. .removeClass(doSelect ? "ui-unselecting" : "ui-selected")
  3223. .addClass(doSelect ? "ui-selecting" : "ui-unselecting");
  3224. selectee.unselecting = !doSelect;
  3225. selectee.selecting = doSelect;
  3226. selectee.selected = doSelect;
  3227. // selectable (UN)SELECTING callback
  3228. if (doSelect) {
  3229. that._trigger("selecting", event, {
  3230. selecting: selectee.element
  3231. });
  3232. } else {
  3233. that._trigger("unselecting", event, {
  3234. unselecting: selectee.element
  3235. });
  3236. }
  3237. return false;
  3238. }
  3239. });
  3240. },
  3241. _mouseDrag: function(event) {
  3242. this.dragged = true;
  3243. if (this.options.disabled) {
  3244. return;
  3245. }
  3246. var tmp,
  3247. that = this,
  3248. options = this.options,
  3249. x1 = this.opos[0],
  3250. y1 = this.opos[1],
  3251. x2 = event.pageX,
  3252. y2 = event.pageY;
  3253. if (x1 > x2) { tmp = x2; x2 = x1; x1 = tmp; }
  3254. if (y1 > y2) { tmp = y2; y2 = y1; y1 = tmp; }
  3255. this.helper.css({left: x1, top: y1, width: x2-x1, height: y2-y1});
  3256. this.selectees.each(function() {
  3257. var selectee = $.data(this, "selectable-item"),
  3258. hit = false;
  3259. //prevent helper from being selected if appendTo: selectable
  3260. if (!selectee || selectee.element === that.element[0]) {
  3261. return;
  3262. }
  3263. if (options.tolerance === "touch") {
  3264. hit = ( !(selectee.left > x2 || selectee.right < x1 || selectee.top > y2 || selectee.bottom < y1) );
  3265. } else if (options.tolerance === "fit") {
  3266. hit = (selectee.left > x1 && selectee.right < x2 && selectee.top > y1 && selectee.bottom < y2);
  3267. }
  3268. if (hit) {
  3269. // SELECT
  3270. if (selectee.selected) {
  3271. selectee.$element.removeClass("ui-selected");
  3272. selectee.selected = false;
  3273. }
  3274. if (selectee.unselecting) {
  3275. selectee.$element.removeClass("ui-unselecting");
  3276. selectee.unselecting = false;
  3277. }
  3278. if (!selectee.selecting) {
  3279. selectee.$element.addClass("ui-selecting");
  3280. selectee.selecting = true;
  3281. // selectable SELECTING callback
  3282. that._trigger("selecting", event, {
  3283. selecting: selectee.element
  3284. });
  3285. }
  3286. } else {
  3287. // UNSELECT
  3288. if (selectee.selecting) {
  3289. if ((event.metaKey || event.ctrlKey) && selectee.startselected) {
  3290. selectee.$element.removeClass("ui-selecting");
  3291. selectee.selecting = false;
  3292. selectee.$element.addClass("ui-selected");
  3293. selectee.selected = true;
  3294. } else {
  3295. selectee.$element.removeClass("ui-selecting");
  3296. selectee.selecting = false;
  3297. if (selectee.startselected) {
  3298. selectee.$element.addClass("ui-unselecting");
  3299. selectee.unselecting = true;
  3300. }
  3301. // selectable UNSELECTING callback
  3302. that._trigger("unselecting", event, {
  3303. unselecting: selectee.element
  3304. });
  3305. }
  3306. }
  3307. if (selectee.selected) {
  3308. if (!event.metaKey && !event.ctrlKey && !selectee.startselected) {
  3309. selectee.$element.removeClass("ui-selected");
  3310. selectee.selected = false;
  3311. selectee.$element.addClass("ui-unselecting");
  3312. selectee.unselecting = true;
  3313. // selectable UNSELECTING callback
  3314. that._trigger("unselecting", event, {
  3315. unselecting: selectee.element
  3316. });
  3317. }
  3318. }
  3319. }
  3320. });
  3321. return false;
  3322. },
  3323. _mouseStop: function(event) {
  3324. var that = this;
  3325. this.dragged = false;
  3326. $(".ui-unselecting", this.element[0]).each(function() {
  3327. var selectee = $.data(this, "selectable-item");
  3328. selectee.$element.removeClass("ui-unselecting");
  3329. selectee.unselecting = false;
  3330. selectee.startselected = false;
  3331. that._trigger("unselected", event, {
  3332. unselected: selectee.element
  3333. });
  3334. });
  3335. $(".ui-selecting", this.element[0]).each(function() {
  3336. var selectee = $.data(this, "selectable-item");
  3337. selectee.$element.removeClass("ui-selecting").addClass("ui-selected");
  3338. selectee.selecting = false;
  3339. selectee.selected = true;
  3340. selectee.startselected = true;
  3341. that._trigger("selected", event, {
  3342. selected: selectee.element
  3343. });
  3344. });
  3345. this._trigger("stop", event);
  3346. this.helper.remove();
  3347. return false;
  3348. }
  3349. });
  3350. })(jQuery);
  3351. (function( $, undefined ) {
  3352. /*jshint loopfunc: true */
  3353. function isOverAxis( x, reference, size ) {
  3354. return ( x > reference ) && ( x < ( reference + size ) );
  3355. }
  3356. function isFloating(item) {
  3357. return (/left|right/).test(item.css("float")) || (/inline|table-cell/).test(item.css("display"));
  3358. }
  3359. $.widget("ui.sortable", $.ui.mouse, {
  3360. version: "1.10.3",
  3361. widgetEventPrefix: "sort",
  3362. ready: false,
  3363. options: {
  3364. appendTo: "parent",
  3365. axis: false,
  3366. connectWith: false,
  3367. containment: false,
  3368. cursor: "auto",
  3369. cursorAt: false,
  3370. dropOnEmpty: true,
  3371. forcePlaceholderSize: false,
  3372. forceHelperSize: false,
  3373. grid: false,
  3374. handle: false,
  3375. helper: "original",
  3376. items: "> *",
  3377. opacity: false,
  3378. placeholder: false,
  3379. revert: false,
  3380. scroll: true,
  3381. scrollSensitivity: 20,
  3382. scrollSpeed: 20,
  3383. scope: "default",
  3384. tolerance: "intersect",
  3385. zIndex: 1000,
  3386. // callbacks
  3387. activate: null,
  3388. beforeStop: null,
  3389. change: null,
  3390. deactivate: null,
  3391. out: null,
  3392. over: null,
  3393. receive: null,
  3394. remove: null,
  3395. sort: null,
  3396. start: null,
  3397. stop: null,
  3398. update: null
  3399. },
  3400. _create: function() {
  3401. var o = this.options;
  3402. this.containerCache = {};
  3403. this.element.addClass("ui-sortable");
  3404. //Get the items
  3405. this.refresh();
  3406. //Let's determine if the items are being displayed horizontally
  3407. this.floating = this.items.length ? o.axis === "x" || isFloating(this.items[0].item) : false;
  3408. //Let's determine the parent's offset
  3409. this.offset = this.element.offset();
  3410. //Initialize mouse events for interaction
  3411. this._mouseInit();
  3412. //We're ready to go
  3413. this.ready = true;
  3414. },
  3415. _destroy: function() {
  3416. this.element
  3417. .removeClass("ui-sortable ui-sortable-disabled");
  3418. this._mouseDestroy();
  3419. for ( var i = this.items.length - 1; i >= 0; i-- ) {
  3420. this.items[i].item.removeData(this.widgetName + "-item");
  3421. }
  3422. return this;
  3423. },
  3424. _setOption: function(key, value){
  3425. if ( key === "disabled" ) {
  3426. this.options[ key ] = value;
  3427. this.widget().toggleClass( "ui-sortable-disabled", !!value );
  3428. } else {
  3429. // Don't call widget base _setOption for disable as it adds ui-state-disabled class
  3430. $.Widget.prototype._setOption.apply(this, arguments);
  3431. }
  3432. },
  3433. _mouseCapture: function(event, overrideHandle) {
  3434. var currentItem = null,
  3435. validHandle = false,
  3436. that = this;
  3437. if (this.reverting) {
  3438. return false;
  3439. }
  3440. if(this.options.disabled || this.options.type === "static") {
  3441. return false;
  3442. }
  3443. //We have to refresh the items data once first
  3444. this._refreshItems(event);
  3445. //Find out if the clicked node (or one of its parents) is a actual item in this.items
  3446. $(event.target).parents().each(function() {
  3447. if($.data(this, that.widgetName + "-item") === that) {
  3448. currentItem = $(this);
  3449. return false;
  3450. }
  3451. });
  3452. if($.data(event.target, that.widgetName + "-item") === that) {
  3453. currentItem = $(event.target);
  3454. }
  3455. if(!currentItem) {
  3456. return false;
  3457. }
  3458. if(this.options.handle && !overrideHandle) {
  3459. $(this.options.handle, currentItem).find("*").addBack().each(function() {
  3460. if(this === event.target) {
  3461. validHandle = true;
  3462. }
  3463. });
  3464. if(!validHandle) {
  3465. return false;
  3466. }
  3467. }
  3468. this.currentItem = currentItem;
  3469. this._removeCurrentsFromItems();
  3470. return true;
  3471. },
  3472. _mouseStart: function(event, overrideHandle, noActivation) {
  3473. var i, body,
  3474. o = this.options;
  3475. this.currentContainer = this;
  3476. //We only need to call refreshPositions, because the refreshItems call has been moved to mouseCapture
  3477. this.refreshPositions();
  3478. //Create and append the visible helper
  3479. this.helper = this._createHelper(event);
  3480. //Cache the helper size
  3481. this._cacheHelperProportions();
  3482. /*
  3483. * - Position generation -
  3484. * This block generates everything position related - it's the core of draggables.
  3485. */
  3486. //Cache the margins of the original element
  3487. this._cacheMargins();
  3488. //Get the next scrolling parent
  3489. this.scrollParent = this.helper.scrollParent();
  3490. //The element's absolute position on the page minus margins
  3491. this.offset = this.currentItem.offset();
  3492. this.offset = {
  3493. top: this.offset.top - this.margins.top,
  3494. left: this.offset.left - this.margins.left
  3495. };
  3496. $.extend(this.offset, {
  3497. click: { //Where the click happened, relative to the element
  3498. left: event.pageX - this.offset.left,
  3499. top: event.pageY - this.offset.top
  3500. },
  3501. parent: this._getParentOffset(),
  3502. relative: this._getRelativeOffset() //This is a relative to absolute position minus the actual position calculation - only used for relative positioned helper
  3503. });
  3504. // Only after we got the offset, we can change the helper's position to absolute
  3505. // TODO: Still need to figure out a way to make relative sorting possible
  3506. this.helper.css("position", "absolute");
  3507. this.cssPosition = this.helper.css("position");
  3508. //Generate the original position
  3509. this.originalPosition = this._generatePosition(event);
  3510. this.originalPageX = event.pageX;
  3511. this.originalPageY = event.pageY;
  3512. //Adjust the mouse offset relative to the helper if "cursorAt" is supplied
  3513. (o.cursorAt && this._adjustOffsetFromHelper(o.cursorAt));
  3514. //Cache the former DOM position
  3515. this.domPosition = { prev: this.currentItem.prev()[0], parent: this.currentItem.parent()[0] };
  3516. //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
  3517. if(this.helper[0] !== this.currentItem[0]) {
  3518. this.currentItem.hide();
  3519. }
  3520. //Create the placeholder
  3521. this._createPlaceholder();
  3522. //Set a containment if given in the options
  3523. if(o.containment) {
  3524. this._setContainment();
  3525. }
  3526. if( o.cursor && o.cursor !== "auto" ) { // cursor option
  3527. body = this.document.find( "body" );
  3528. // support: IE
  3529. this.storedCursor = body.css( "cursor" );
  3530. body.css( "cursor", o.cursor );
  3531. this.storedStylesheet = $( "<style>*{ cursor: "+o.cursor+" !important; }</style>" ).appendTo( body );
  3532. }
  3533. if(o.opacity) { // opacity option
  3534. if (this.helper.css("opacity")) {
  3535. this._storedOpacity = this.helper.css("opacity");
  3536. }
  3537. this.helper.css("opacity", o.opacity);
  3538. }
  3539. if(o.zIndex) { // zIndex option
  3540. if (this.helper.css("zIndex")) {
  3541. this._storedZIndex = this.helper.css("zIndex");
  3542. }
  3543. this.helper.css("zIndex", o.zIndex);
  3544. }
  3545. //Prepare scrolling
  3546. if(this.scrollParent[0] !== document && this.scrollParent[0].tagName !== "HTML") {
  3547. this.overflowOffset = this.scrollParent.offset();
  3548. }
  3549. //Call callbacks
  3550. this._trigger("start", event, this._uiHash());
  3551. //Recache the helper size
  3552. if(!this._preserveHelperProportions) {
  3553. this._cacheHelperProportions();
  3554. }
  3555. //Post "activate" events to possible containers
  3556. if( !noActivation ) {
  3557. for ( i = this.containers.length - 1; i >= 0; i-- ) {
  3558. this.containers[ i ]._trigger( "activate", event, this._uiHash( this ) );
  3559. }
  3560. }
  3561. //Prepare possible droppables
  3562. if($.ui.ddmanager) {
  3563. $.ui.ddmanager.current = this;
  3564. }
  3565. if ($.ui.ddmanager && !o.dropBehaviour) {
  3566. $.ui.ddmanager.prepareOffsets(this, event);
  3567. }
  3568. this.dragging = true;
  3569. this.helper.addClass("ui-sortable-helper");
  3570. this._mouseDrag(event); //Execute the drag once - this causes the helper not to be visible before getting its correct position
  3571. return true;
  3572. },
  3573. _mouseDrag: function(event) {
  3574. var i, item, itemElement, intersection,
  3575. o = this.options,
  3576. scrolled = false;
  3577. //Compute the helpers position
  3578. this.position = this._generatePosition(event);
  3579. this.positionAbs = this._convertPositionTo("absolute");
  3580. if (!this.lastPositionAbs) {
  3581. this.lastPositionAbs = this.positionAbs;
  3582. }
  3583. //Do scrolling
  3584. if(this.options.scroll) {
  3585. if(this.scrollParent[0] !== document && this.scrollParent[0].tagName !== "HTML") {
  3586. if((this.overflowOffset.top + this.scrollParent[0].offsetHeight) - event.pageY < o.scrollSensitivity) {
  3587. this.scrollParent[0].scrollTop = scrolled = this.scrollParent[0].scrollTop + o.scrollSpeed;
  3588. } else if(event.pageY - this.overflowOffset.top < o.scrollSensitivity) {
  3589. this.scrollParent[0].scrollTop = scrolled = this.scrollParent[0].scrollTop - o.scrollSpeed;
  3590. }
  3591. if((this.overflowOffset.left + this.scrollParent[0].offsetWidth) - event.pageX < o.scrollSensitivity) {
  3592. this.scrollParent[0].scrollLeft = scrolled = this.scrollParent[0].scrollLeft + o.scrollSpeed;
  3593. } else if(event.pageX - this.overflowOffset.left < o.scrollSensitivity) {
  3594. this.scrollParent[0].scrollLeft = scrolled = this.scrollParent[0].scrollLeft - o.scrollSpeed;
  3595. }
  3596. } else {
  3597. if(event.pageY - $(document).scrollTop() < o.scrollSensitivity) {
  3598. scrolled = $(document).scrollTop($(document).scrollTop() - o.scrollSpeed);
  3599. } else if($(window).height() - (event.pageY - $(document).scrollTop()) < o.scrollSensitivity) {
  3600. scrolled = $(document).scrollTop($(document).scrollTop() + o.scrollSpeed);
  3601. }
  3602. if(event.pageX - $(document).scrollLeft() < o.scrollSensitivity) {
  3603. scrolled = $(document).scrollLeft($(document).scrollLeft() - o.scrollSpeed);
  3604. } else if($(window).width() - (event.pageX - $(document).scrollLeft()) < o.scrollSensitivity) {
  3605. scrolled = $(document).scrollLeft($(document).scrollLeft() + o.scrollSpeed);
  3606. }
  3607. }
  3608. if(scrolled !== false && $.ui.ddmanager && !o.dropBehaviour) {
  3609. $.ui.ddmanager.prepareOffsets(this, event);
  3610. }
  3611. }
  3612. //Regenerate the absolute position used for position checks
  3613. this.positionAbs = this._convertPositionTo("absolute");
  3614. //Set the helper position
  3615. if(!this.options.axis || this.options.axis !== "y") {
  3616. this.helper[0].style.left = this.position.left+"px";
  3617. }
  3618. if(!this.options.axis || this.options.axis !== "x") {
  3619. this.helper[0].style.top = this.position.top+"px";
  3620. }
  3621. //Rearrange
  3622. for (i = this.items.length - 1; i >= 0; i--) {
  3623. //Cache variables and intersection, continue if no intersection
  3624. item = this.items[i];
  3625. itemElement = item.item[0];
  3626. intersection = this._intersectsWithPointer(item);
  3627. if (!intersection) {
  3628. continue;
  3629. }
  3630. // Only put the placeholder inside the current Container, skip all
  3631. // items form other containers. This works because when moving
  3632. // an item from one container to another the
  3633. // currentContainer is switched before the placeholder is moved.
  3634. //
  3635. // Without this moving items in "sub-sortables" can cause the placeholder to jitter
  3636. // beetween the outer and inner container.
  3637. if (item.instance !== this.currentContainer) {
  3638. continue;
  3639. }
  3640. // cannot intersect with itself
  3641. // no useless actions that have been done before
  3642. // no action if the item moved is the parent of the item checked
  3643. if (itemElement !== this.currentItem[0] &&
  3644. this.placeholder[intersection === 1 ? "next" : "prev"]()[0] !== itemElement &&
  3645. !$.contains(this.placeholder[0], itemElement) &&
  3646. (this.options.type === "semi-dynamic" ? !$.contains(this.element[0], itemElement) : true)
  3647. ) {
  3648. this.direction = intersection === 1 ? "down" : "up";
  3649. if (this.options.tolerance === "pointer" || this._intersectsWithSides(item)) {
  3650. this._rearrange(event, item);
  3651. } else {
  3652. break;
  3653. }
  3654. this._trigger("change", event, this._uiHash());
  3655. break;
  3656. }
  3657. }
  3658. //Post events to containers
  3659. this._contactContainers(event);
  3660. //Interconnect with droppables
  3661. if($.ui.ddmanager) {
  3662. $.ui.ddmanager.drag(this, event);
  3663. }
  3664. //Call callbacks
  3665. this._trigger("sort", event, this._uiHash());
  3666. this.lastPositionAbs = this.positionAbs;
  3667. return false;
  3668. },
  3669. _mouseStop: function(event, noPropagation) {
  3670. if(!event) {
  3671. return;
  3672. }
  3673. //If we are using droppables, inform the manager about the drop
  3674. if ($.ui.ddmanager && !this.options.dropBehaviour) {
  3675. $.ui.ddmanager.drop(this, event);
  3676. }
  3677. if(this.options.revert) {
  3678. var that = this,
  3679. cur = this.placeholder.offset(),
  3680. axis = this.options.axis,
  3681. animation = {};
  3682. if ( !axis || axis === "x" ) {
  3683. animation.left = cur.left - this.offset.parent.left - this.margins.left + (this.offsetParent[0] === document.body ? 0 : this.offsetParent[0].scrollLeft);
  3684. }
  3685. if ( !axis || axis === "y" ) {
  3686. animation.top = cur.top - this.offset.parent.top - this.margins.top + (this.offsetParent[0] === document.body ? 0 : this.offsetParent[0].scrollTop);
  3687. }
  3688. this.reverting = true;
  3689. $(this.helper).animate( animation, parseInt(this.options.revert, 10) || 500, function() {
  3690. that._clear(event);
  3691. });
  3692. } else {
  3693. this._clear(event, noPropagation);
  3694. }
  3695. return false;
  3696. },
  3697. cancel: function() {
  3698. if(this.dragging) {
  3699. this._mouseUp({ target: null });
  3700. if(this.options.helper === "original") {
  3701. this.currentItem.css(this._storedCSS).removeClass("ui-sortable-helper");
  3702. } else {
  3703. this.currentItem.show();
  3704. }
  3705. //Post deactivating events to containers
  3706. for (var i = this.containers.length - 1; i >= 0; i--){
  3707. this.containers[i]._trigger("deactivate", null, this._uiHash(this));
  3708. if(this.containers[i].containerCache.over) {
  3709. this.containers[i]._trigger("out", null, this._uiHash(this));
  3710. this.containers[i].containerCache.over = 0;
  3711. }
  3712. }
  3713. }
  3714. if (this.placeholder) {
  3715. //$(this.placeholder[0]).remove(); would have been the jQuery way - unfortunately, it unbinds ALL events from the original node!
  3716. if(this.placeholder[0].parentNode) {
  3717. this.placeholder[0].parentNode.removeChild(this.placeholder[0]);
  3718. }
  3719. if(this.options.helper !== "original" && this.helper && this.helper[0].parentNode) {
  3720. this.helper.remove();
  3721. }
  3722. $.extend(this, {
  3723. helper: null,
  3724. dragging: false,
  3725. reverting: false,
  3726. _noFinalSort: null
  3727. });
  3728. if(this.domPosition.prev) {
  3729. $(this.domPosition.prev).after(this.currentItem);
  3730. } else {
  3731. $(this.domPosition.parent).prepend(this.currentItem);
  3732. }
  3733. }
  3734. return this;
  3735. },
  3736. serialize: function(o) {
  3737. var items = this._getItemsAsjQuery(o && o.connected),
  3738. str = [];
  3739. o = o || {};
  3740. $(items).each(function() {
  3741. var res = ($(o.item || this).attr(o.attribute || "id") || "").match(o.expression || (/(.+)[\-=_](.+)/));
  3742. if (res) {
  3743. str.push((o.key || res[1]+"[]")+"="+(o.key && o.expression ? res[1] : res[2]));
  3744. }
  3745. });
  3746. if(!str.length && o.key) {
  3747. str.push(o.key + "=");
  3748. }
  3749. return str.join("&");
  3750. },
  3751. toArray: function(o) {
  3752. var items = this._getItemsAsjQuery(o && o.connected),
  3753. ret = [];
  3754. o = o || {};
  3755. items.each(function() { ret.push($(o.item || this).attr(o.attribute || "id") || ""); });
  3756. return ret;
  3757. },
  3758. /* Be careful with the following core functions */
  3759. _intersectsWith: function(item) {
  3760. var x1 = this.positionAbs.left,
  3761. x2 = x1 + this.helperProportions.width,
  3762. y1 = this.positionAbs.top,
  3763. y2 = y1 + this.helperProportions.height,
  3764. l = item.left,
  3765. r = l + item.width,
  3766. t = item.top,
  3767. b = t + item.height,
  3768. dyClick = this.offset.click.top,
  3769. dxClick = this.offset.click.left,
  3770. isOverElementHeight = ( this.options.axis === "x" ) || ( ( y1 + dyClick ) > t && ( y1 + dyClick ) < b ),
  3771. isOverElementWidth = ( this.options.axis === "y" ) || ( ( x1 + dxClick ) > l && ( x1 + dxClick ) < r ),
  3772. isOverElement = isOverElementHeight && isOverElementWidth;
  3773. if ( this.options.tolerance === "pointer" ||
  3774. this.options.forcePointerForContainers ||
  3775. (this.options.tolerance !== "pointer" && this.helperProportions[this.floating ? "width" : "height"] > item[this.floating ? "width" : "height"])
  3776. ) {
  3777. return isOverElement;
  3778. } else {
  3779. return (l < x1 + (this.helperProportions.width / 2) && // Right Half
  3780. x2 - (this.helperProportions.width / 2) < r && // Left Half
  3781. t < y1 + (this.helperProportions.height / 2) && // Bottom Half
  3782. y2 - (this.helperProportions.height / 2) < b ); // Top Half
  3783. }
  3784. },
  3785. _intersectsWithPointer: function(item) {
  3786. var isOverElementHeight = (this.options.axis === "x") || isOverAxis(this.positionAbs.top + this.offset.click.top, item.top, item.height),
  3787. isOverElementWidth = (this.options.axis === "y") || isOverAxis(this.positionAbs.left + this.offset.click.left, item.left, item.width),
  3788. isOverElement = isOverElementHeight && isOverElementWidth,
  3789. verticalDirection = this._getDragVerticalDirection(),
  3790. horizontalDirection = this._getDragHorizontalDirection();
  3791. if (!isOverElement) {
  3792. return false;
  3793. }
  3794. return this.floating ?
  3795. ( ((horizontalDirection && horizontalDirection === "right") || verticalDirection === "down") ? 2 : 1 )
  3796. : ( verticalDirection && (verticalDirection === "down" ? 2 : 1) );
  3797. },
  3798. _intersectsWithSides: function(item) {
  3799. var isOverBottomHalf = isOverAxis(this.positionAbs.top + this.offset.click.top, item.top + (item.height/2), item.height),
  3800. isOverRightHalf = isOverAxis(this.positionAbs.left + this.offset.click.left, item.left + (item.width/2), item.width),
  3801. verticalDirection = this._getDragVerticalDirection(),
  3802. horizontalDirection = this._getDragHorizontalDirection();
  3803. if (this.floating && horizontalDirection) {
  3804. return ((horizontalDirection === "right" && isOverRightHalf) || (horizontalDirection === "left" && !isOverRightHalf));
  3805. } else {
  3806. return verticalDirection && ((verticalDirection === "down" && isOverBottomHalf) || (verticalDirection === "up" && !isOverBottomHalf));
  3807. }
  3808. },
  3809. _getDragVerticalDirection: function() {
  3810. var delta = this.positionAbs.top - this.lastPositionAbs.top;
  3811. return delta !== 0 && (delta > 0 ? "down" : "up");
  3812. },
  3813. _getDragHorizontalDirection: function() {
  3814. var delta = this.positionAbs.left - this.lastPositionAbs.left;
  3815. return delta !== 0 && (delta > 0 ? "right" : "left");
  3816. },
  3817. refresh: function(event) {
  3818. this._refreshItems(event);
  3819. this.refreshPositions();
  3820. return this;
  3821. },
  3822. _connectWith: function() {
  3823. var options = this.options;
  3824. return options.connectWith.constructor === String ? [options.connectWith] : options.connectWith;
  3825. },
  3826. _getItemsAsjQuery: function(connected) {
  3827. var i, j, cur, inst,
  3828. items = [],
  3829. queries = [],
  3830. connectWith = this._connectWith();
  3831. if(connectWith && connected) {
  3832. for (i = connectWith.length - 1; i >= 0; i--){
  3833. cur = $(connectWith[i]);
  3834. for ( j = cur.length - 1; j >= 0; j--){
  3835. inst = $.data(cur[j], this.widgetFullName);
  3836. if(inst && inst !== this && !inst.options.disabled) {
  3837. 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]);
  3838. }
  3839. }
  3840. }
  3841. }
  3842. 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]);
  3843. for (i = queries.length - 1; i >= 0; i--){
  3844. queries[i][0].each(function() {
  3845. items.push(this);
  3846. });
  3847. }
  3848. return $(items);
  3849. },
  3850. _removeCurrentsFromItems: function() {
  3851. var list = this.currentItem.find(":data(" + this.widgetName + "-item)");
  3852. this.items = $.grep(this.items, function (item) {
  3853. for (var j=0; j < list.length; j++) {
  3854. if(list[j] === item.item[0]) {
  3855. return false;
  3856. }
  3857. }
  3858. return true;
  3859. });
  3860. },
  3861. _refreshItems: function(event) {
  3862. this.items = [];
  3863. this.containers = [this];
  3864. var i, j, cur, inst, targetData, _queries, item, queriesLength,
  3865. items = this.items,
  3866. queries = [[$.isFunction(this.options.items) ? this.options.items.call(this.element[0], event, { item: this.currentItem }) : $(this.options.items, this.element), this]],
  3867. connectWith = this._connectWith();
  3868. if(connectWith && this.ready) { //Shouldn't be run the first time through due to massive slow-down
  3869. for (i = connectWith.length - 1; i >= 0; i--){
  3870. cur = $(connectWith[i]);
  3871. for (j = cur.length - 1; j >= 0; j--){
  3872. inst = $.data(cur[j], this.widgetFullName);
  3873. if(inst && inst !== this && !inst.options.disabled) {
  3874. queries.push([$.isFunction(inst.options.items) ? inst.options.items.call(inst.element[0], event, { item: this.currentItem }) : $(inst.options.items, inst.element), inst]);
  3875. this.containers.push(inst);
  3876. }
  3877. }
  3878. }
  3879. }
  3880. for (i = queries.length - 1; i >= 0; i--) {
  3881. targetData = queries[i][1];
  3882. _queries = queries[i][0];
  3883. for (j=0, queriesLength = _queries.length; j < queriesLength; j++) {
  3884. item = $(_queries[j]);
  3885. item.data(this.widgetName + "-item", targetData); // Data for target checking (mouse manager)
  3886. items.push({
  3887. item: item,
  3888. instance: targetData,
  3889. width: 0, height: 0,
  3890. left: 0, top: 0
  3891. });
  3892. }
  3893. }
  3894. },
  3895. refreshPositions: function(fast) {
  3896. //This has to be redone because due to the item being moved out/into the offsetParent, the offsetParent's position will change
  3897. if(this.offsetParent && this.helper) {
  3898. this.offset.parent = this._getParentOffset();
  3899. }
  3900. var i, item, t, p;
  3901. for (i = this.items.length - 1; i >= 0; i--){
  3902. item = this.items[i];
  3903. //We ignore calculating positions of all connected containers when we're not over them
  3904. if(item.instance !== this.currentContainer && this.currentContainer && item.item[0] !== this.currentItem[0]) {
  3905. continue;
  3906. }
  3907. t = this.options.toleranceElement ? $(this.options.toleranceElement, item.item) : item.item;
  3908. if (!fast) {
  3909. item.width = t.outerWidth();
  3910. item.height = t.outerHeight();
  3911. }
  3912. p = t.offset();
  3913. item.left = p.left;
  3914. item.top = p.top;
  3915. }
  3916. if(this.options.custom && this.options.custom.refreshContainers) {
  3917. this.options.custom.refreshContainers.call(this);
  3918. } else {
  3919. for (i = this.containers.length - 1; i >= 0; i--){
  3920. p = this.containers[i].element.offset();
  3921. this.containers[i].containerCache.left = p.left;
  3922. this.containers[i].containerCache.top = p.top;
  3923. this.containers[i].containerCache.width = this.containers[i].element.outerWidth();
  3924. this.containers[i].containerCache.height = this.containers[i].element.outerHeight();
  3925. }
  3926. }
  3927. return this;
  3928. },
  3929. _createPlaceholder: function(that) {
  3930. that = that || this;
  3931. var className,
  3932. o = that.options;
  3933. if(!o.placeholder || o.placeholder.constructor === String) {
  3934. className = o.placeholder;
  3935. o.placeholder = {
  3936. element: function() {
  3937. var nodeName = that.currentItem[0].nodeName.toLowerCase(),
  3938. element = $( "<" + nodeName + ">", that.document[0] )
  3939. .addClass(className || that.currentItem[0].className+" ui-sortable-placeholder")
  3940. .removeClass("ui-sortable-helper");
  3941. if ( nodeName === "tr" ) {
  3942. that.currentItem.children().each(function() {
  3943. $( "<td>&#160;</td>", that.document[0] )
  3944. .attr( "colspan", $( this ).attr( "colspan" ) || 1 )
  3945. .appendTo( element );
  3946. });
  3947. } else if ( nodeName === "img" ) {
  3948. element.attr( "src", that.currentItem.attr( "src" ) );
  3949. }
  3950. if ( !className ) {
  3951. element.css( "visibility", "hidden" );
  3952. }
  3953. return element;
  3954. },
  3955. update: function(container, p) {
  3956. // 1. If a className is set as 'placeholder option, we don't force sizes - the class is responsible for that
  3957. // 2. The option 'forcePlaceholderSize can be enabled to force it even if a class name is specified
  3958. if(className && !o.forcePlaceholderSize) {
  3959. return;
  3960. }
  3961. //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
  3962. if(!p.height()) { p.height(that.currentItem.innerHeight() - parseInt(that.currentItem.css("paddingTop")||0, 10) - parseInt(that.currentItem.css("paddingBottom")||0, 10)); }
  3963. if(!p.width()) { p.width(that.currentItem.innerWidth() - parseInt(that.currentItem.css("paddingLeft")||0, 10) - parseInt(that.currentItem.css("paddingRight")||0, 10)); }
  3964. }
  3965. };
  3966. }
  3967. //Create the placeholder
  3968. that.placeholder = $(o.placeholder.element.call(that.element, that.currentItem));
  3969. //Append it after the actual current item
  3970. that.currentItem.after(that.placeholder);
  3971. //Update the size of the placeholder (TODO: Logic to fuzzy, see line 316/317)
  3972. o.placeholder.update(that, that.placeholder);
  3973. },
  3974. _contactContainers: function(event) {
  3975. var i, j, dist, itemWithLeastDistance, posProperty, sizeProperty, base, cur, nearBottom, floating,
  3976. innermostContainer = null,
  3977. innermostIndex = null;
  3978. // get innermost container that intersects with item
  3979. for (i = this.containers.length - 1; i >= 0; i--) {
  3980. // never consider a container that's located within the item itself
  3981. if($.contains(this.currentItem[0], this.containers[i].element[0])) {
  3982. continue;
  3983. }
  3984. if(this._intersectsWith(this.containers[i].containerCache)) {
  3985. // if we've already found a container and it's more "inner" than this, then continue
  3986. if(innermostContainer && $.contains(this.containers[i].element[0], innermostContainer.element[0])) {
  3987. continue;
  3988. }
  3989. innermostContainer = this.containers[i];
  3990. innermostIndex = i;
  3991. } else {
  3992. // container doesn't intersect. trigger "out" event if necessary
  3993. if(this.containers[i].containerCache.over) {
  3994. this.containers[i]._trigger("out", event, this._uiHash(this));
  3995. this.containers[i].containerCache.over = 0;
  3996. }
  3997. }
  3998. }
  3999. // if no intersecting containers found, return
  4000. if(!innermostContainer) {
  4001. return;
  4002. }
  4003. // move the item into the container if it's not there already
  4004. if(this.containers.length === 1) {
  4005. if (!this.containers[innermostIndex].containerCache.over) {
  4006. this.containers[innermostIndex]._trigger("over", event, this._uiHash(this));
  4007. this.containers[innermostIndex].containerCache.over = 1;
  4008. }
  4009. } else {
  4010. //When entering a new container, we will find the item with the least distance and append our item near it
  4011. dist = 10000;
  4012. itemWithLeastDistance = null;
  4013. floating = innermostContainer.floating || isFloating(this.currentItem);
  4014. posProperty = floating ? "left" : "top";
  4015. sizeProperty = floating ? "width" : "height";
  4016. base = this.positionAbs[posProperty] + this.offset.click[posProperty];
  4017. for (j = this.items.length - 1; j >= 0; j--) {
  4018. if(!$.contains(this.containers[innermostIndex].element[0], this.items[j].item[0])) {
  4019. continue;
  4020. }
  4021. if(this.items[j].item[0] === this.currentItem[0]) {
  4022. continue;
  4023. }
  4024. if (floating && !isOverAxis(this.positionAbs.top + this.offset.click.top, this.items[j].top, this.items[j].height)) {
  4025. continue;
  4026. }
  4027. cur = this.items[j].item.offset()[posProperty];
  4028. nearBottom = false;
  4029. if(Math.abs(cur - base) > Math.abs(cur + this.items[j][sizeProperty] - base)){
  4030. nearBottom = true;
  4031. cur += this.items[j][sizeProperty];
  4032. }
  4033. if(Math.abs(cur - base) < dist) {
  4034. dist = Math.abs(cur - base); itemWithLeastDistance = this.items[j];
  4035. this.direction = nearBottom ? "up": "down";
  4036. }
  4037. }
  4038. //Check if dropOnEmpty is enabled
  4039. if(!itemWithLeastDistance && !this.options.dropOnEmpty) {
  4040. return;
  4041. }
  4042. if(this.currentContainer === this.containers[innermostIndex]) {
  4043. return;
  4044. }
  4045. itemWithLeastDistance ? this._rearrange(event, itemWithLeastDistance, null, true) : this._rearrange(event, null, this.containers[innermostIndex].element, true);
  4046. this._trigger("change", event, this._uiHash());
  4047. this.containers[innermostIndex]._trigger("change", event, this._uiHash(this));
  4048. this.currentContainer = this.containers[innermostIndex];
  4049. //Update the placeholder
  4050. this.options.placeholder.update(this.currentContainer, this.placeholder);
  4051. this.containers[innermostIndex]._trigger("over", event, this._uiHash(this));
  4052. this.containers[innermostIndex].containerCache.over = 1;
  4053. }
  4054. },
  4055. _createHelper: function(event) {
  4056. var o = this.options,
  4057. helper = $.isFunction(o.helper) ? $(o.helper.apply(this.element[0], [event, this.currentItem])) : (o.helper === "clone" ? this.currentItem.clone() : this.currentItem);
  4058. //Add the helper to the DOM if that didn't happen already
  4059. if(!helper.parents("body").length) {
  4060. $(o.appendTo !== "parent" ? o.appendTo : this.currentItem[0].parentNode)[0].appendChild(helper[0]);
  4061. }
  4062. if(helper[0] === this.currentItem[0]) {
  4063. 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") };
  4064. }
  4065. if(!helper[0].style.width || o.forceHelperSize) {
  4066. helper.width(this.currentItem.width());
  4067. }
  4068. if(!helper[0].style.height || o.forceHelperSize) {
  4069. helper.height(this.currentItem.height());
  4070. }
  4071. return helper;
  4072. },
  4073. _adjustOffsetFromHelper: function(obj) {
  4074. if (typeof obj === "string") {
  4075. obj = obj.split(" ");
  4076. }
  4077. if ($.isArray(obj)) {
  4078. obj = {left: +obj[0], top: +obj[1] || 0};
  4079. }
  4080. if ("left" in obj) {
  4081. this.offset.click.left = obj.left + this.margins.left;
  4082. }
  4083. if ("right" in obj) {
  4084. this.offset.click.left = this.helperProportions.width - obj.right + this.margins.left;
  4085. }
  4086. if ("top" in obj) {
  4087. this.offset.click.top = obj.top + this.margins.top;
  4088. }
  4089. if ("bottom" in obj) {
  4090. this.offset.click.top = this.helperProportions.height - obj.bottom + this.margins.top;
  4091. }
  4092. },
  4093. _getParentOffset: function() {
  4094. //Get the offsetParent and cache its position
  4095. this.offsetParent = this.helper.offsetParent();
  4096. var po = this.offsetParent.offset();
  4097. // This is a special case where we need to modify a offset calculated on start, since the following happened:
  4098. // 1. The position of the helper is absolute, so it's position is calculated based on the next positioned parent
  4099. // 2. The actual offset parent is a child of the scroll parent, and the scroll parent isn't the document, which means that
  4100. // the scroll is included in the initial calculation of the offset of the parent, and never recalculated upon drag
  4101. if(this.cssPosition === "absolute" && this.scrollParent[0] !== document && $.contains(this.scrollParent[0], this.offsetParent[0])) {
  4102. po.left += this.scrollParent.scrollLeft();
  4103. po.top += this.scrollParent.scrollTop();
  4104. }
  4105. // This needs to be actually done for all browsers, since pageX/pageY includes this information
  4106. // with an ugly IE fix
  4107. if( this.offsetParent[0] === document.body || (this.offsetParent[0].tagName && this.offsetParent[0].tagName.toLowerCase() === "html" && $.ui.ie)) {
  4108. po = { top: 0, left: 0 };
  4109. }
  4110. return {
  4111. top: po.top + (parseInt(this.offsetParent.css("borderTopWidth"),10) || 0),
  4112. left: po.left + (parseInt(this.offsetParent.css("borderLeftWidth"),10) || 0)
  4113. };
  4114. },
  4115. _getRelativeOffset: function() {
  4116. if(this.cssPosition === "relative") {
  4117. var p = this.currentItem.position();
  4118. return {
  4119. top: p.top - (parseInt(this.helper.css("top"),10) || 0) + this.scrollParent.scrollTop(),
  4120. left: p.left - (parseInt(this.helper.css("left"),10) || 0) + this.scrollParent.scrollLeft()
  4121. };
  4122. } else {
  4123. return { top: 0, left: 0 };
  4124. }
  4125. },
  4126. _cacheMargins: function() {
  4127. this.margins = {
  4128. left: (parseInt(this.currentItem.css("marginLeft"),10) || 0),
  4129. top: (parseInt(this.currentItem.css("marginTop"),10) || 0)
  4130. };
  4131. },
  4132. _cacheHelperProportions: function() {
  4133. this.helperProportions = {
  4134. width: this.helper.outerWidth(),
  4135. height: this.helper.outerHeight()
  4136. };
  4137. },
  4138. _setContainment: function() {
  4139. var ce, co, over,
  4140. o = this.options;
  4141. if(o.containment === "parent") {
  4142. o.containment = this.helper[0].parentNode;
  4143. }
  4144. if(o.containment === "document" || o.containment === "window") {
  4145. this.containment = [
  4146. 0 - this.offset.relative.left - this.offset.parent.left,
  4147. 0 - this.offset.relative.top - this.offset.parent.top,
  4148. $(o.containment === "document" ? document : window).width() - this.helperProportions.width - this.margins.left,
  4149. ($(o.containment === "document" ? document : window).height() || document.body.parentNode.scrollHeight) - this.helperProportions.height - this.margins.top
  4150. ];
  4151. }
  4152. if(!(/^(document|window|parent)$/).test(o.containment)) {
  4153. ce = $(o.containment)[0];
  4154. co = $(o.containment).offset();
  4155. over = ($(ce).css("overflow") !== "hidden");
  4156. this.containment = [
  4157. co.left + (parseInt($(ce).css("borderLeftWidth"),10) || 0) + (parseInt($(ce).css("paddingLeft"),10) || 0) - this.margins.left,
  4158. co.top + (parseInt($(ce).css("borderTopWidth"),10) || 0) + (parseInt($(ce).css("paddingTop"),10) || 0) - this.margins.top,
  4159. 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,
  4160. 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
  4161. ];
  4162. }
  4163. },
  4164. _convertPositionTo: function(d, pos) {
  4165. if(!pos) {
  4166. pos = this.position;
  4167. }
  4168. var mod = d === "absolute" ? 1 : -1,
  4169. scroll = this.cssPosition === "absolute" && !(this.scrollParent[0] !== document && $.contains(this.scrollParent[0], this.offsetParent[0])) ? this.offsetParent : this.scrollParent,
  4170. scrollIsRootNode = (/(html|body)/i).test(scroll[0].tagName);
  4171. return {
  4172. top: (
  4173. pos.top + // The absolute mouse position
  4174. this.offset.relative.top * mod + // Only for relative positioned nodes: Relative offset from element to offset parent
  4175. this.offset.parent.top * mod - // The offsetParent's offset without borders (offset + border)
  4176. ( ( this.cssPosition === "fixed" ? -this.scrollParent.scrollTop() : ( scrollIsRootNode ? 0 : scroll.scrollTop() ) ) * mod)
  4177. ),
  4178. left: (
  4179. pos.left + // The absolute mouse position
  4180. this.offset.relative.left * mod + // Only for relative positioned nodes: Relative offset from element to offset parent
  4181. this.offset.parent.left * mod - // The offsetParent's offset without borders (offset + border)
  4182. ( ( this.cssPosition === "fixed" ? -this.scrollParent.scrollLeft() : scrollIsRootNode ? 0 : scroll.scrollLeft() ) * mod)
  4183. )
  4184. };
  4185. },
  4186. _generatePosition: function(event) {
  4187. var top, left,
  4188. o = this.options,
  4189. pageX = event.pageX,
  4190. pageY = event.pageY,
  4191. 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);
  4192. // This is another very weird special case that only happens for relative elements:
  4193. // 1. If the css position is relative
  4194. // 2. and the scroll parent is the document or similar to the offset parent
  4195. // we have to refresh the relative offset during the scroll so there are no jumps
  4196. if(this.cssPosition === "relative" && !(this.scrollParent[0] !== document && this.scrollParent[0] !== this.offsetParent[0])) {
  4197. this.offset.relative = this._getRelativeOffset();
  4198. }
  4199. /*
  4200. * - Position constraining -
  4201. * Constrain the position to a mix of grid, containment.
  4202. */
  4203. if(this.originalPosition) { //If we are not dragging yet, we won't check for options
  4204. if(this.containment) {
  4205. if(event.pageX - this.offset.click.left < this.containment[0]) {
  4206. pageX = this.containment[0] + this.offset.click.left;
  4207. }
  4208. if(event.pageY - this.offset.click.top < this.containment[1]) {
  4209. pageY = this.containment[1] + this.offset.click.top;
  4210. }
  4211. if(event.pageX - this.offset.click.left > this.containment[2]) {
  4212. pageX = this.containment[2] + this.offset.click.left;
  4213. }
  4214. if(event.pageY - this.offset.click.top > this.containment[3]) {
  4215. pageY = this.containment[3] + this.offset.click.top;
  4216. }
  4217. }
  4218. if(o.grid) {
  4219. top = this.originalPageY + Math.round((pageY - this.originalPageY) / o.grid[1]) * o.grid[1];
  4220. 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;
  4221. left = this.originalPageX + Math.round((pageX - this.originalPageX) / o.grid[0]) * o.grid[0];
  4222. 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;
  4223. }
  4224. }
  4225. return {
  4226. top: (
  4227. pageY - // The absolute mouse position
  4228. this.offset.click.top - // Click offset (relative to the element)
  4229. this.offset.relative.top - // Only for relative positioned nodes: Relative offset from element to offset parent
  4230. this.offset.parent.top + // The offsetParent's offset without borders (offset + border)
  4231. ( ( this.cssPosition === "fixed" ? -this.scrollParent.scrollTop() : ( scrollIsRootNode ? 0 : scroll.scrollTop() ) ))
  4232. ),
  4233. left: (
  4234. pageX - // The absolute mouse position
  4235. this.offset.click.left - // Click offset (relative to the element)
  4236. this.offset.relative.left - // Only for relative positioned nodes: Relative offset from element to offset parent
  4237. this.offset.parent.left + // The offsetParent's offset without borders (offset + border)
  4238. ( ( this.cssPosition === "fixed" ? -this.scrollParent.scrollLeft() : scrollIsRootNode ? 0 : scroll.scrollLeft() ))
  4239. )
  4240. };
  4241. },
  4242. _rearrange: function(event, i, a, hardRefresh) {
  4243. 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));
  4244. //Various things done here to improve the performance:
  4245. // 1. we create a setTimeout, that calls refreshPositions
  4246. // 2. on the instance, we have a counter variable, that get's higher after every append
  4247. // 3. on the local scope, we copy the counter variable, and check in the timeout, if it's still the same
  4248. // 4. this lets only the last addition to the timeout stack through
  4249. this.counter = this.counter ? ++this.counter : 1;
  4250. var counter = this.counter;
  4251. this._delay(function() {
  4252. if(counter === this.counter) {
  4253. this.refreshPositions(!hardRefresh); //Precompute after each DOM insertion, NOT on mousemove
  4254. }
  4255. });
  4256. },
  4257. _clear: function(event, noPropagation) {
  4258. this.reverting = false;
  4259. // We delay all events that have to be triggered to after the point where the placeholder has been removed and
  4260. // everything else normalized again
  4261. var i,
  4262. delayedTriggers = [];
  4263. // We first have to update the dom position of the actual currentItem
  4264. // Note: don't do it if the current item is already removed (by a user), or it gets reappended (see #4088)
  4265. if(!this._noFinalSort && this.currentItem.parent().length) {
  4266. this.placeholder.before(this.currentItem);
  4267. }
  4268. this._noFinalSort = null;
  4269. if(this.helper[0] === this.currentItem[0]) {
  4270. for(i in this._storedCSS) {
  4271. if(this._storedCSS[i] === "auto" || this._storedCSS[i] === "static") {
  4272. this._storedCSS[i] = "";
  4273. }
  4274. }
  4275. this.currentItem.css(this._storedCSS).removeClass("ui-sortable-helper");
  4276. } else {
  4277. this.currentItem.show();
  4278. }
  4279. if(this.fromOutside && !noPropagation) {
  4280. delayedTriggers.push(function(event) { this._trigger("receive", event, this._uiHash(this.fromOutside)); });
  4281. }
  4282. if((this.fromOutside || this.domPosition.prev !== this.currentItem.prev().not(".ui-sortable-helper")[0] || this.domPosition.parent !== this.currentItem.parent()[0]) && !noPropagation) {
  4283. delayedTriggers.push(function(event) { this._trigger("update", event, this._uiHash()); }); //Trigger update callback if the DOM position has changed
  4284. }
  4285. // Check if the items Container has Changed and trigger appropriate
  4286. // events.
  4287. if (this !== this.currentContainer) {
  4288. if(!noPropagation) {
  4289. delayedTriggers.push(function(event) { this._trigger("remove", event, this._uiHash()); });
  4290. delayedTriggers.push((function(c) { return function(event) { c._trigger("receive", event, this._uiHash(this)); }; }).call(this, this.currentContainer));
  4291. delayedTriggers.push((function(c) { return function(event) { c._trigger("update", event, this._uiHash(this)); }; }).call(this, this.currentContainer));
  4292. }
  4293. }
  4294. //Post events to containers
  4295. for (i = this.containers.length - 1; i >= 0; i--){
  4296. if(!noPropagation) {
  4297. delayedTriggers.push((function(c) { return function(event) { c._trigger("deactivate", event, this._uiHash(this)); }; }).call(this, this.containers[i]));
  4298. }
  4299. if(this.containers[i].containerCache.over) {
  4300. delayedTriggers.push((function(c) { return function(event) { c._trigger("out", event, this._uiHash(this)); }; }).call(this, this.containers[i]));
  4301. this.containers[i].containerCache.over = 0;
  4302. }
  4303. }
  4304. //Do what was originally in plugins
  4305. if ( this.storedCursor ) {
  4306. this.document.find( "body" ).css( "cursor", this.storedCursor );
  4307. this.storedStylesheet.remove();
  4308. }
  4309. if(this._storedOpacity) {
  4310. this.helper.css("opacity", this._storedOpacity);
  4311. }
  4312. if(this._storedZIndex) {
  4313. this.helper.css("zIndex", this._storedZIndex === "auto" ? "" : this._storedZIndex);
  4314. }
  4315. this.dragging = false;
  4316. if(this.cancelHelperRemoval) {
  4317. if(!noPropagation) {
  4318. this._trigger("beforeStop", event, this._uiHash());
  4319. for (i=0; i < delayedTriggers.length; i++) {
  4320. delayedTriggers[i].call(this, event);
  4321. } //Trigger all delayed events
  4322. this._trigger("stop", event, this._uiHash());
  4323. }
  4324. this.fromOutside = false;
  4325. return false;
  4326. }
  4327. if(!noPropagation) {
  4328. this._trigger("beforeStop", event, this._uiHash());
  4329. }
  4330. //$(this.placeholder[0]).remove(); would have been the jQuery way - unfortunately, it unbinds ALL events from the original node!
  4331. this.placeholder[0].parentNode.removeChild(this.placeholder[0]);
  4332. if(this.helper[0] !== this.currentItem[0]) {
  4333. this.helper.remove();
  4334. }
  4335. this.helper = null;
  4336. if(!noPropagation) {
  4337. for (i=0; i < delayedTriggers.length; i++) {
  4338. delayedTriggers[i].call(this, event);
  4339. } //Trigger all delayed events
  4340. this._trigger("stop", event, this._uiHash());
  4341. }
  4342. this.fromOutside = false;
  4343. return true;
  4344. },
  4345. _trigger: function() {
  4346. if ($.Widget.prototype._trigger.apply(this, arguments) === false) {
  4347. this.cancel();
  4348. }
  4349. },
  4350. _uiHash: function(_inst) {
  4351. var inst = _inst || this;
  4352. return {
  4353. helper: inst.helper,
  4354. placeholder: inst.placeholder || $([]),
  4355. position: inst.position,
  4356. originalPosition: inst.originalPosition,
  4357. offset: inst.positionAbs,
  4358. item: inst.currentItem,
  4359. sender: _inst ? _inst.element : null
  4360. };
  4361. }
  4362. });
  4363. })(jQuery);
  4364. (function( $, undefined ) {
  4365. var uid = 0,
  4366. hideProps = {},
  4367. showProps = {};
  4368. hideProps.height = hideProps.paddingTop = hideProps.paddingBottom =
  4369. hideProps.borderTopWidth = hideProps.borderBottomWidth = "hide";
  4370. showProps.height = showProps.paddingTop = showProps.paddingBottom =
  4371. showProps.borderTopWidth = showProps.borderBottomWidth = "show";
  4372. $.widget( "ui.accordion", {
  4373. version: "1.10.3",
  4374. options: {
  4375. active: 0,
  4376. animate: {},
  4377. collapsible: false,
  4378. event: "click",
  4379. header: "> li > :first-child,> :not(li):even",
  4380. heightStyle: "auto",
  4381. icons: {
  4382. activeHeader: "ui-icon-triangle-1-s",
  4383. header: "ui-icon-triangle-1-e"
  4384. },
  4385. // callbacks
  4386. activate: null,
  4387. beforeActivate: null
  4388. },
  4389. _create: function() {
  4390. var options = this.options;
  4391. this.prevShow = this.prevHide = $();
  4392. this.element.addClass( "ui-accordion ui-widget ui-helper-reset" )
  4393. // ARIA
  4394. .attr( "role", "tablist" );
  4395. // don't allow collapsible: false and active: false / null
  4396. if ( !options.collapsible && (options.active === false || options.active == null) ) {
  4397. options.active = 0;
  4398. }
  4399. this._processPanels();
  4400. // handle negative values
  4401. if ( options.active < 0 ) {
  4402. options.active += this.headers.length;
  4403. }
  4404. this._refresh();
  4405. },
  4406. _getCreateEventData: function() {
  4407. return {
  4408. header: this.active,
  4409. panel: !this.active.length ? $() : this.active.next(),
  4410. content: !this.active.length ? $() : this.active.next()
  4411. };
  4412. },
  4413. _createIcons: function() {
  4414. var icons = this.options.icons;
  4415. if ( icons ) {
  4416. $( "<span>" )
  4417. .addClass( "ui-accordion-header-icon ui-icon " + icons.header )
  4418. .prependTo( this.headers );
  4419. this.active.children( ".ui-accordion-header-icon" )
  4420. .removeClass( icons.header )
  4421. .addClass( icons.activeHeader );
  4422. this.headers.addClass( "ui-accordion-icons" );
  4423. }
  4424. },
  4425. _destroyIcons: function() {
  4426. this.headers
  4427. .removeClass( "ui-accordion-icons" )
  4428. .children( ".ui-accordion-header-icon" )
  4429. .remove();
  4430. },
  4431. _destroy: function() {
  4432. var contents;
  4433. // clean up main element
  4434. this.element
  4435. .removeClass( "ui-accordion ui-widget ui-helper-reset" )
  4436. .removeAttr( "role" );
  4437. // clean up headers
  4438. this.headers
  4439. .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" )
  4440. .removeAttr( "role" )
  4441. .removeAttr( "aria-selected" )
  4442. .removeAttr( "aria-controls" )
  4443. .removeAttr( "tabIndex" )
  4444. .each(function() {
  4445. if ( /^ui-accordion/.test( this.id ) ) {
  4446. this.removeAttribute( "id" );
  4447. }
  4448. });
  4449. this._destroyIcons();
  4450. // clean up content panels
  4451. contents = this.headers.next()
  4452. .css( "display", "" )
  4453. .removeAttr( "role" )
  4454. .removeAttr( "aria-expanded" )
  4455. .removeAttr( "aria-hidden" )
  4456. .removeAttr( "aria-labelledby" )
  4457. .removeClass( "ui-helper-reset ui-widget-content ui-corner-bottom ui-accordion-content ui-accordion-content-active ui-state-disabled" )
  4458. .each(function() {
  4459. if ( /^ui-accordion/.test( this.id ) ) {
  4460. this.removeAttribute( "id" );
  4461. }
  4462. });
  4463. if ( this.options.heightStyle !== "content" ) {
  4464. contents.css( "height", "" );
  4465. }
  4466. },
  4467. _setOption: function( key, value ) {
  4468. if ( key === "active" ) {
  4469. // _activate() will handle invalid values and update this.options
  4470. this._activate( value );
  4471. return;
  4472. }
  4473. if ( key === "event" ) {
  4474. if ( this.options.event ) {
  4475. this._off( this.headers, this.options.event );
  4476. }
  4477. this._setupEvents( value );
  4478. }
  4479. this._super( key, value );
  4480. // setting collapsible: false while collapsed; open first panel
  4481. if ( key === "collapsible" && !value && this.options.active === false ) {
  4482. this._activate( 0 );
  4483. }
  4484. if ( key === "icons" ) {
  4485. this._destroyIcons();
  4486. if ( value ) {
  4487. this._createIcons();
  4488. }
  4489. }
  4490. // #5332 - opacity doesn't cascade to positioned elements in IE
  4491. // so we need to add the disabled class to the headers and panels
  4492. if ( key === "disabled" ) {
  4493. this.headers.add( this.headers.next() )
  4494. .toggleClass( "ui-state-disabled", !!value );
  4495. }
  4496. },
  4497. _keydown: function( event ) {
  4498. /*jshint maxcomplexity:15*/
  4499. if ( event.altKey || event.ctrlKey ) {
  4500. return;
  4501. }
  4502. var keyCode = $.ui.keyCode,
  4503. length = this.headers.length,
  4504. currentIndex = this.headers.index( event.target ),
  4505. toFocus = false;
  4506. switch ( event.keyCode ) {
  4507. case keyCode.RIGHT:
  4508. case keyCode.DOWN:
  4509. toFocus = this.headers[ ( currentIndex + 1 ) % length ];
  4510. break;
  4511. case keyCode.LEFT:
  4512. case keyCode.UP:
  4513. toFocus = this.headers[ ( currentIndex - 1 + length ) % length ];
  4514. break;
  4515. case keyCode.SPACE:
  4516. case keyCode.ENTER:
  4517. this._eventHandler( event );
  4518. break;
  4519. case keyCode.HOME:
  4520. toFocus = this.headers[ 0 ];
  4521. break;
  4522. case keyCode.END:
  4523. toFocus = this.headers[ length - 1 ];
  4524. break;
  4525. }
  4526. if ( toFocus ) {
  4527. $( event.target ).attr( "tabIndex", -1 );
  4528. $( toFocus ).attr( "tabIndex", 0 );
  4529. toFocus.focus();
  4530. event.preventDefault();
  4531. }
  4532. },
  4533. _panelKeyDown : function( event ) {
  4534. if ( event.keyCode === $.ui.keyCode.UP && event.ctrlKey ) {
  4535. $( event.currentTarget ).prev().focus();
  4536. }
  4537. },
  4538. refresh: function() {
  4539. var options = this.options;
  4540. this._processPanels();
  4541. // was collapsed or no panel
  4542. if ( ( options.active === false && options.collapsible === true ) || !this.headers.length ) {
  4543. options.active = false;
  4544. this.active = $();
  4545. // active false only when collapsible is true
  4546. } else if ( options.active === false ) {
  4547. this._activate( 0 );
  4548. // was active, but active panel is gone
  4549. } else if ( this.active.length && !$.contains( this.element[ 0 ], this.active[ 0 ] ) ) {
  4550. // all remaining panel are disabled
  4551. if ( this.headers.length === this.headers.find(".ui-state-disabled").length ) {
  4552. options.active = false;
  4553. this.active = $();
  4554. // activate previous panel
  4555. } else {
  4556. this._activate( Math.max( 0, options.active - 1 ) );
  4557. }
  4558. // was active, active panel still exists
  4559. } else {
  4560. // make sure active index is correct
  4561. options.active = this.headers.index( this.active );
  4562. }
  4563. this._destroyIcons();
  4564. this._refresh();
  4565. },
  4566. _processPanels: function() {
  4567. this.headers = this.element.find( this.options.header )
  4568. .addClass( "ui-accordion-header ui-helper-reset ui-state-default ui-corner-all" );
  4569. this.headers.next()
  4570. .addClass( "ui-accordion-content ui-helper-reset ui-widget-content ui-corner-bottom" )
  4571. .filter(":not(.ui-accordion-content-active)")
  4572. .hide();
  4573. },
  4574. _refresh: function() {
  4575. var maxHeight,
  4576. options = this.options,
  4577. heightStyle = options.heightStyle,
  4578. parent = this.element.parent(),
  4579. accordionId = this.accordionId = "ui-accordion-" +
  4580. (this.element.attr( "id" ) || ++uid);
  4581. this.active = this._findActive( options.active )
  4582. .addClass( "ui-accordion-header-active ui-state-active ui-corner-top" )
  4583. .removeClass( "ui-corner-all" );
  4584. this.active.next()
  4585. .addClass( "ui-accordion-content-active" )
  4586. .show();
  4587. this.headers
  4588. .attr( "role", "tab" )
  4589. .each(function( i ) {
  4590. var header = $( this ),
  4591. headerId = header.attr( "id" ),
  4592. panel = header.next(),
  4593. panelId = panel.attr( "id" );
  4594. if ( !headerId ) {
  4595. headerId = accordionId + "-header-" + i;
  4596. header.attr( "id", headerId );
  4597. }
  4598. if ( !panelId ) {
  4599. panelId = accordionId + "-panel-" + i;
  4600. panel.attr( "id", panelId );
  4601. }
  4602. header.attr( "aria-controls", panelId );
  4603. panel.attr( "aria-labelledby", headerId );
  4604. })
  4605. .next()
  4606. .attr( "role", "tabpanel" );
  4607. this.headers
  4608. .not( this.active )
  4609. .attr({
  4610. "aria-selected": "false",
  4611. tabIndex: -1
  4612. })
  4613. .next()
  4614. .attr({
  4615. "aria-expanded": "false",
  4616. "aria-hidden": "true"
  4617. })
  4618. .hide();
  4619. // make sure at least one header is in the tab order
  4620. if ( !this.active.length ) {
  4621. this.headers.eq( 0 ).attr( "tabIndex", 0 );
  4622. } else {
  4623. this.active.attr({
  4624. "aria-selected": "true",
  4625. tabIndex: 0
  4626. })
  4627. .next()
  4628. .attr({
  4629. "aria-expanded": "true",
  4630. "aria-hidden": "false"
  4631. });
  4632. }
  4633. this._createIcons();
  4634. this._setupEvents( options.event );
  4635. if ( heightStyle === "fill" ) {
  4636. maxHeight = parent.height();
  4637. this.element.siblings( ":visible" ).each(function() {
  4638. var elem = $( this ),
  4639. position = elem.css( "position" );
  4640. if ( position === "absolute" || position === "fixed" ) {
  4641. return;
  4642. }
  4643. maxHeight -= elem.outerHeight( true );
  4644. });
  4645. this.headers.each(function() {
  4646. maxHeight -= $( this ).outerHeight( true );
  4647. });
  4648. this.headers.next()
  4649. .each(function() {
  4650. $( this ).height( Math.max( 0, maxHeight -
  4651. $( this ).innerHeight() + $( this ).height() ) );
  4652. })
  4653. .css( "overflow", "auto" );
  4654. } else if ( heightStyle === "auto" ) {
  4655. maxHeight = 0;
  4656. this.headers.next()
  4657. .each(function() {
  4658. maxHeight = Math.max( maxHeight, $( this ).css( "height", "" ).height() );
  4659. })
  4660. .height( maxHeight );
  4661. }
  4662. },
  4663. _activate: function( index ) {
  4664. var active = this._findActive( index )[ 0 ];
  4665. // trying to activate the already active panel
  4666. if ( active === this.active[ 0 ] ) {
  4667. return;
  4668. }
  4669. // trying to collapse, simulate a click on the currently active header
  4670. active = active || this.active[ 0 ];
  4671. this._eventHandler({
  4672. target: active,
  4673. currentTarget: active,
  4674. preventDefault: $.noop
  4675. });
  4676. },
  4677. _findActive: function( selector ) {
  4678. return typeof selector === "number" ? this.headers.eq( selector ) : $();
  4679. },
  4680. _setupEvents: function( event ) {
  4681. var events = {
  4682. keydown: "_keydown"
  4683. };
  4684. if ( event ) {
  4685. $.each( event.split(" "), function( index, eventName ) {
  4686. events[ eventName ] = "_eventHandler";
  4687. });
  4688. }
  4689. this._off( this.headers.add( this.headers.next() ) );
  4690. this._on( this.headers, events );
  4691. this._on( this.headers.next(), { keydown: "_panelKeyDown" });
  4692. this._hoverable( this.headers );
  4693. this._focusable( this.headers );
  4694. },
  4695. _eventHandler: function( event ) {
  4696. var options = this.options,
  4697. active = this.active,
  4698. clicked = $( event.currentTarget ),
  4699. clickedIsActive = clicked[ 0 ] === active[ 0 ],
  4700. collapsing = clickedIsActive && options.collapsible,
  4701. toShow = collapsing ? $() : clicked.next(),
  4702. toHide = active.next(),
  4703. eventData = {
  4704. oldHeader: active,
  4705. oldPanel: toHide,
  4706. newHeader: collapsing ? $() : clicked,
  4707. newPanel: toShow
  4708. };
  4709. event.preventDefault();
  4710. if (
  4711. // click on active header, but not collapsible
  4712. ( clickedIsActive && !options.collapsible ) ||
  4713. // allow canceling activation
  4714. ( this._trigger( "beforeActivate", event, eventData ) === false ) ) {
  4715. return;
  4716. }
  4717. options.active = collapsing ? false : this.headers.index( clicked );
  4718. // when the call to ._toggle() comes after the class changes
  4719. // it causes a very odd bug in IE 8 (see #6720)
  4720. this.active = clickedIsActive ? $() : clicked;
  4721. this._toggle( eventData );
  4722. // switch classes
  4723. // corner classes on the previously active header stay after the animation
  4724. active.removeClass( "ui-accordion-header-active ui-state-active" );
  4725. if ( options.icons ) {
  4726. active.children( ".ui-accordion-header-icon" )
  4727. .removeClass( options.icons.activeHeader )
  4728. .addClass( options.icons.header );
  4729. }
  4730. if ( !clickedIsActive ) {
  4731. clicked
  4732. .removeClass( "ui-corner-all" )
  4733. .addClass( "ui-accordion-header-active ui-state-active ui-corner-top" );
  4734. if ( options.icons ) {
  4735. clicked.children( ".ui-accordion-header-icon" )
  4736. .removeClass( options.icons.header )
  4737. .addClass( options.icons.activeHeader );
  4738. }
  4739. clicked
  4740. .next()
  4741. .addClass( "ui-accordion-content-active" );
  4742. }
  4743. },
  4744. _toggle: function( data ) {
  4745. var toShow = data.newPanel,
  4746. toHide = this.prevShow.length ? this.prevShow : data.oldPanel;
  4747. // handle activating a panel during the animation for another activation
  4748. this.prevShow.add( this.prevHide ).stop( true, true );
  4749. this.prevShow = toShow;
  4750. this.prevHide = toHide;
  4751. if ( this.options.animate ) {
  4752. this._animate( toShow, toHide, data );
  4753. } else {
  4754. toHide.hide();
  4755. toShow.show();
  4756. this._toggleComplete( data );
  4757. }
  4758. toHide.attr({
  4759. "aria-expanded": "false",
  4760. "aria-hidden": "true"
  4761. });
  4762. toHide.prev().attr( "aria-selected", "false" );
  4763. // if we're switching panels, remove the old header from the tab order
  4764. // if we're opening from collapsed state, remove the previous header from the tab order
  4765. // if we're collapsing, then keep the collapsing header in the tab order
  4766. if ( toShow.length && toHide.length ) {
  4767. toHide.prev().attr( "tabIndex", -1 );
  4768. } else if ( toShow.length ) {
  4769. this.headers.filter(function() {
  4770. return $( this ).attr( "tabIndex" ) === 0;
  4771. })
  4772. .attr( "tabIndex", -1 );
  4773. }
  4774. toShow
  4775. .attr({
  4776. "aria-expanded": "true",
  4777. "aria-hidden": "false"
  4778. })
  4779. .prev()
  4780. .attr({
  4781. "aria-selected": "true",
  4782. tabIndex: 0
  4783. });
  4784. },
  4785. _animate: function( toShow, toHide, data ) {
  4786. var total, easing, duration,
  4787. that = this,
  4788. adjust = 0,
  4789. down = toShow.length &&
  4790. ( !toHide.length || ( toShow.index() < toHide.index() ) ),
  4791. animate = this.options.animate || {},
  4792. options = down && animate.down || animate,
  4793. complete = function() {
  4794. that._toggleComplete( data );
  4795. };
  4796. if ( typeof options === "number" ) {
  4797. duration = options;
  4798. }
  4799. if ( typeof options === "string" ) {
  4800. easing = options;
  4801. }
  4802. // fall back from options to animation in case of partial down settings
  4803. easing = easing || options.easing || animate.easing;
  4804. duration = duration || options.duration || animate.duration;
  4805. if ( !toHide.length ) {
  4806. return toShow.animate( showProps, duration, easing, complete );
  4807. }
  4808. if ( !toShow.length ) {
  4809. return toHide.animate( hideProps, duration, easing, complete );
  4810. }
  4811. total = toShow.show().outerHeight();
  4812. toHide.animate( hideProps, {
  4813. duration: duration,
  4814. easing: easing,
  4815. step: function( now, fx ) {
  4816. fx.now = Math.round( now );
  4817. }
  4818. });
  4819. toShow
  4820. .hide()
  4821. .animate( showProps, {
  4822. duration: duration,
  4823. easing: easing,
  4824. complete: complete,
  4825. step: function( now, fx ) {
  4826. fx.now = Math.round( now );
  4827. if ( fx.prop !== "height" ) {
  4828. adjust += fx.now;
  4829. } else if ( that.options.heightStyle !== "content" ) {
  4830. fx.now = Math.round( total - toHide.outerHeight() - adjust );
  4831. adjust = 0;
  4832. }
  4833. }
  4834. });
  4835. },
  4836. _toggleComplete: function( data ) {
  4837. var toHide = data.oldPanel;
  4838. toHide
  4839. .removeClass( "ui-accordion-content-active" )
  4840. .prev()
  4841. .removeClass( "ui-corner-top" )
  4842. .addClass( "ui-corner-all" );
  4843. // Work around for rendering bug in IE (#5421)
  4844. if ( toHide.length ) {
  4845. toHide.parent()[0].className = toHide.parent()[0].className;
  4846. }
  4847. this._trigger( "activate", null, data );
  4848. }
  4849. });
  4850. })( jQuery );
  4851. (function( $, undefined ) {
  4852. // used to prevent race conditions with remote data sources
  4853. var requestIndex = 0;
  4854. $.widget( "ui.autocomplete", {
  4855. version: "1.10.3",
  4856. defaultElement: "<input>",
  4857. options: {
  4858. appendTo: null,
  4859. autoFocus: false,
  4860. delay: 300,
  4861. minLength: 1,
  4862. position: {
  4863. my: "left top",
  4864. at: "left bottom",
  4865. collision: "none"
  4866. },
  4867. source: null,
  4868. // callbacks
  4869. change: null,
  4870. close: null,
  4871. focus: null,
  4872. open: null,
  4873. response: null,
  4874. search: null,
  4875. select: null
  4876. },
  4877. pending: 0,
  4878. _create: function() {
  4879. // Some browsers only repeat keydown events, not keypress events,
  4880. // so we use the suppressKeyPress flag to determine if we've already
  4881. // handled the keydown event. #7269
  4882. // Unfortunately the code for & in keypress is the same as the up arrow,
  4883. // so we use the suppressKeyPressRepeat flag to avoid handling keypress
  4884. // events when we know the keydown event was used to modify the
  4885. // search term. #7799
  4886. var suppressKeyPress, suppressKeyPressRepeat, suppressInput,
  4887. nodeName = this.element[0].nodeName.toLowerCase(),
  4888. isTextarea = nodeName === "textarea",
  4889. isInput = nodeName === "input";
  4890. this.isMultiLine =
  4891. // Textareas are always multi-line
  4892. isTextarea ? true :
  4893. // Inputs are always single-line, even if inside a contentEditable element
  4894. // IE also treats inputs as contentEditable
  4895. isInput ? false :
  4896. // All other element types are determined by whether or not they're contentEditable
  4897. this.element.prop( "isContentEditable" );
  4898. this.valueMethod = this.element[ isTextarea || isInput ? "val" : "text" ];
  4899. this.isNewMenu = true;
  4900. this.element
  4901. .addClass( "ui-autocomplete-input" )
  4902. .attr( "autocomplete", "off" );
  4903. this._on( this.element, {
  4904. keydown: function( event ) {
  4905. /*jshint maxcomplexity:15*/
  4906. if ( this.element.prop( "readOnly" ) ) {
  4907. suppressKeyPress = true;
  4908. suppressInput = true;
  4909. suppressKeyPressRepeat = true;
  4910. return;
  4911. }
  4912. suppressKeyPress = false;
  4913. suppressInput = false;
  4914. suppressKeyPressRepeat = false;
  4915. var keyCode = $.ui.keyCode;
  4916. switch( event.keyCode ) {
  4917. case keyCode.PAGE_UP:
  4918. suppressKeyPress = true;
  4919. this._move( "previousPage", event );
  4920. break;
  4921. case keyCode.PAGE_DOWN:
  4922. suppressKeyPress = true;
  4923. this._move( "nextPage", event );
  4924. break;
  4925. case keyCode.UP:
  4926. suppressKeyPress = true;
  4927. this._keyEvent( "previous", event );
  4928. break;
  4929. case keyCode.DOWN:
  4930. suppressKeyPress = true;
  4931. this._keyEvent( "next", event );
  4932. break;
  4933. case keyCode.ENTER:
  4934. case keyCode.NUMPAD_ENTER:
  4935. // when menu is open and has focus
  4936. if ( this.menu.active ) {
  4937. // #6055 - Opera still allows the keypress to occur
  4938. // which causes forms to submit
  4939. suppressKeyPress = true;
  4940. event.preventDefault();
  4941. this.menu.select( event );
  4942. }
  4943. break;
  4944. case keyCode.TAB:
  4945. if ( this.menu.active ) {
  4946. this.menu.select( event );
  4947. }
  4948. break;
  4949. case keyCode.ESCAPE:
  4950. if ( this.menu.element.is( ":visible" ) ) {
  4951. this._value( this.term );
  4952. this.close( event );
  4953. // Different browsers have different default behavior for escape
  4954. // Single press can mean undo or clear
  4955. // Double press in IE means clear the whole form
  4956. event.preventDefault();
  4957. }
  4958. break;
  4959. default:
  4960. suppressKeyPressRepeat = true;
  4961. // search timeout should be triggered before the input value is changed
  4962. this._searchTimeout( event );
  4963. break;
  4964. }
  4965. },
  4966. keypress: function( event ) {
  4967. if ( suppressKeyPress ) {
  4968. suppressKeyPress = false;
  4969. if ( !this.isMultiLine || this.menu.element.is( ":visible" ) ) {
  4970. event.preventDefault();
  4971. }
  4972. return;
  4973. }
  4974. if ( suppressKeyPressRepeat ) {
  4975. return;
  4976. }
  4977. // replicate some key handlers to allow them to repeat in Firefox and Opera
  4978. var keyCode = $.ui.keyCode;
  4979. switch( event.keyCode ) {
  4980. case keyCode.PAGE_UP:
  4981. this._move( "previousPage", event );
  4982. break;
  4983. case keyCode.PAGE_DOWN:
  4984. this._move( "nextPage", event );
  4985. break;
  4986. case keyCode.UP:
  4987. this._keyEvent( "previous", event );
  4988. break;
  4989. case keyCode.DOWN:
  4990. this._keyEvent( "next", event );
  4991. break;
  4992. }
  4993. },
  4994. input: function( event ) {
  4995. if ( suppressInput ) {
  4996. suppressInput = false;
  4997. event.preventDefault();
  4998. return;
  4999. }
  5000. this._searchTimeout( event );
  5001. },
  5002. focus: function() {
  5003. this.selectedItem = null;
  5004. this.previous = this._value();
  5005. },
  5006. blur: function( event ) {
  5007. if ( this.cancelBlur ) {
  5008. delete this.cancelBlur;
  5009. return;
  5010. }
  5011. clearTimeout( this.searching );
  5012. this.close( event );
  5013. this._change( event );
  5014. }
  5015. });
  5016. this._initSource();
  5017. this.menu = $( "<ul>" )
  5018. .addClass( "ui-autocomplete ui-front" )
  5019. .appendTo( this._appendTo() )
  5020. .menu({
  5021. // disable ARIA support, the live region takes care of that
  5022. role: null
  5023. })
  5024. .hide()
  5025. .data( "ui-menu" );
  5026. this._on( this.menu.element, {
  5027. mousedown: function( event ) {
  5028. // prevent moving focus out of the text field
  5029. event.preventDefault();
  5030. // IE doesn't prevent moving focus even with event.preventDefault()
  5031. // so we set a flag to know when we should ignore the blur event
  5032. this.cancelBlur = true;
  5033. this._delay(function() {
  5034. delete this.cancelBlur;
  5035. });
  5036. // clicking on the scrollbar causes focus to shift to the body
  5037. // but we can't detect a mouseup or a click immediately afterward
  5038. // so we have to track the next mousedown and close the menu if
  5039. // the user clicks somewhere outside of the autocomplete
  5040. var menuElement = this.menu.element[ 0 ];
  5041. if ( !$( event.target ).closest( ".ui-menu-item" ).length ) {
  5042. this._delay(function() {
  5043. var that = this;
  5044. this.document.one( "mousedown", function( event ) {
  5045. if ( event.target !== that.element[ 0 ] &&
  5046. event.target !== menuElement &&
  5047. !$.contains( menuElement, event.target ) ) {
  5048. that.close();
  5049. }
  5050. });
  5051. });
  5052. }
  5053. },
  5054. menufocus: function( event, ui ) {
  5055. // support: Firefox
  5056. // Prevent accidental activation of menu items in Firefox (#7024 #9118)
  5057. if ( this.isNewMenu ) {
  5058. this.isNewMenu = false;
  5059. if ( event.originalEvent && /^mouse/.test( event.originalEvent.type ) ) {
  5060. this.menu.blur();
  5061. this.document.one( "mousemove", function() {
  5062. $( event.target ).trigger( event.originalEvent );
  5063. });
  5064. return;
  5065. }
  5066. }
  5067. var item = ui.item.data( "ui-autocomplete-item" );
  5068. if ( false !== this._trigger( "focus", event, { item: item } ) ) {
  5069. // use value to match what will end up in the input, if it was a key event
  5070. if ( event.originalEvent && /^key/.test( event.originalEvent.type ) ) {
  5071. this._value( item.value );
  5072. }
  5073. } else {
  5074. // Normally the input is populated with the item's value as the
  5075. // menu is navigated, causing screen readers to notice a change and
  5076. // announce the item. Since the focus event was canceled, this doesn't
  5077. // happen, so we update the live region so that screen readers can
  5078. // still notice the change and announce it.
  5079. this.liveRegion.text( item.value );
  5080. }
  5081. },
  5082. menuselect: function( event, ui ) {
  5083. var item = ui.item.data( "ui-autocomplete-item" ),
  5084. previous = this.previous;
  5085. // only trigger when focus was lost (click on menu)
  5086. if ( this.element[0] !== this.document[0].activeElement ) {
  5087. this.element.focus();
  5088. this.previous = previous;
  5089. // #6109 - IE triggers two focus events and the second
  5090. // is asynchronous, so we need to reset the previous
  5091. // term synchronously and asynchronously :-(
  5092. this._delay(function() {
  5093. this.previous = previous;
  5094. this.selectedItem = item;
  5095. });
  5096. }
  5097. if ( false !== this._trigger( "select", event, { item: item } ) ) {
  5098. this._value( item.value );
  5099. }
  5100. // reset the term after the select event
  5101. // this allows custom select handling to work properly
  5102. this.term = this._value();
  5103. this.close( event );
  5104. this.selectedItem = item;
  5105. }
  5106. });
  5107. this.liveRegion = $( "<span>", {
  5108. role: "status",
  5109. "aria-live": "polite"
  5110. })
  5111. .addClass( "ui-helper-hidden-accessible" )
  5112. .insertBefore( this.element );
  5113. // turning off autocomplete prevents the browser from remembering the
  5114. // value when navigating through history, so we re-enable autocomplete
  5115. // if the page is unloaded before the widget is destroyed. #7790
  5116. this._on( this.window, {
  5117. beforeunload: function() {
  5118. this.element.removeAttr( "autocomplete" );
  5119. }
  5120. });
  5121. },
  5122. _destroy: function() {
  5123. clearTimeout( this.searching );
  5124. this.element
  5125. .removeClass( "ui-autocomplete-input" )
  5126. .removeAttr( "autocomplete" );
  5127. this.menu.element.remove();
  5128. this.liveRegion.remove();
  5129. },
  5130. _setOption: function( key, value ) {
  5131. this._super( key, value );
  5132. if ( key === "source" ) {
  5133. this._initSource();
  5134. }
  5135. if ( key === "appendTo" ) {
  5136. this.menu.element.appendTo( this._appendTo() );
  5137. }
  5138. if ( key === "disabled" && value && this.xhr ) {
  5139. this.xhr.abort();
  5140. }
  5141. },
  5142. _appendTo: function() {
  5143. var element = this.options.appendTo;
  5144. if ( element ) {
  5145. element = element.jquery || element.nodeType ?
  5146. $( element ) :
  5147. this.document.find( element ).eq( 0 );
  5148. }
  5149. if ( !element ) {
  5150. element = this.element.closest( ".ui-front" );
  5151. }
  5152. if ( !element.length ) {
  5153. element = this.document[0].body;
  5154. }
  5155. return element;
  5156. },
  5157. _initSource: function() {
  5158. var array, url,
  5159. that = this;
  5160. if ( $.isArray(this.options.source) ) {
  5161. array = this.options.source;
  5162. this.source = function( request, response ) {
  5163. response( $.ui.autocomplete.filter( array, request.term ) );
  5164. };
  5165. } else if ( typeof this.options.source === "string" ) {
  5166. url = this.options.source;
  5167. this.source = function( request, response ) {
  5168. if ( that.xhr ) {
  5169. that.xhr.abort();
  5170. }
  5171. that.xhr = $.ajax({
  5172. url: url,
  5173. data: request,
  5174. dataType: "json",
  5175. success: function( data ) {
  5176. response( data );
  5177. },
  5178. error: function() {
  5179. response( [] );
  5180. }
  5181. });
  5182. };
  5183. } else {
  5184. this.source = this.options.source;
  5185. }
  5186. },
  5187. _searchTimeout: function( event ) {
  5188. clearTimeout( this.searching );
  5189. this.searching = this._delay(function() {
  5190. // only search if the value has changed
  5191. if ( this.term !== this._value() ) {
  5192. this.selectedItem = null;
  5193. this.search( null, event );
  5194. }
  5195. }, this.options.delay );
  5196. },
  5197. search: function( value, event ) {
  5198. value = value != null ? value : this._value();
  5199. // always save the actual value, not the one passed as an argument
  5200. this.term = this._value();
  5201. if ( value.length < this.options.minLength ) {
  5202. return this.close( event );
  5203. }
  5204. if ( this._trigger( "search", event ) === false ) {
  5205. return;
  5206. }
  5207. return this._search( value );
  5208. },
  5209. _search: function( value ) {
  5210. this.pending++;
  5211. this.element.addClass( "ui-autocomplete-loading" );
  5212. this.cancelSearch = false;
  5213. this.source( { term: value }, this._response() );
  5214. },
  5215. _response: function() {
  5216. var that = this,
  5217. index = ++requestIndex;
  5218. return function( content ) {
  5219. if ( index === requestIndex ) {
  5220. that.__response( content );
  5221. }
  5222. that.pending--;
  5223. if ( !that.pending ) {
  5224. that.element.removeClass( "ui-autocomplete-loading" );
  5225. }
  5226. };
  5227. },
  5228. __response: function( content ) {
  5229. if ( content ) {
  5230. content = this._normalize( content );
  5231. }
  5232. this._trigger( "response", null, { content: content } );
  5233. if ( !this.options.disabled && content && content.length && !this.cancelSearch ) {
  5234. this._suggest( content );
  5235. this._trigger( "open" );
  5236. } else {
  5237. // use ._close() instead of .close() so we don't cancel future searches
  5238. this._close();
  5239. }
  5240. },
  5241. close: function( event ) {
  5242. this.cancelSearch = true;
  5243. this._close( event );
  5244. },
  5245. _close: function( event ) {
  5246. if ( this.menu.element.is( ":visible" ) ) {
  5247. this.menu.element.hide();
  5248. this.menu.blur();
  5249. this.isNewMenu = true;
  5250. this._trigger( "close", event );
  5251. }
  5252. },
  5253. _change: function( event ) {
  5254. if ( this.previous !== this._value() ) {
  5255. this._trigger( "change", event, { item: this.selectedItem } );
  5256. }
  5257. },
  5258. _normalize: function( items ) {
  5259. // assume all items have the right format when the first item is complete
  5260. if ( items.length && items[0].label && items[0].value ) {
  5261. return items;
  5262. }
  5263. return $.map( items, function( item ) {
  5264. if ( typeof item === "string" ) {
  5265. return {
  5266. label: item,
  5267. value: item
  5268. };
  5269. }
  5270. return $.extend({
  5271. label: item.label || item.value,
  5272. value: item.value || item.label
  5273. }, item );
  5274. });
  5275. },
  5276. _suggest: function( items ) {
  5277. var ul = this.menu.element.empty();
  5278. this._renderMenu( ul, items );
  5279. this.isNewMenu = true;
  5280. this.menu.refresh();
  5281. // size and position menu
  5282. ul.show();
  5283. this._resizeMenu();
  5284. ul.position( $.extend({
  5285. of: this.element
  5286. }, this.options.position ));
  5287. if ( this.options.autoFocus ) {
  5288. this.menu.next();
  5289. }
  5290. },
  5291. _resizeMenu: function() {
  5292. var ul = this.menu.element;
  5293. ul.outerWidth( Math.max(
  5294. // Firefox wraps long text (possibly a rounding bug)
  5295. // so we add 1px to avoid the wrapping (#7513)
  5296. ul.width( "" ).outerWidth() + 1,
  5297. this.element.outerWidth()
  5298. ) );
  5299. },
  5300. _renderMenu: function( ul, items ) {
  5301. var that = this;
  5302. $.each( items, function( index, item ) {
  5303. that._renderItemData( ul, item );
  5304. });
  5305. },
  5306. _renderItemData: function( ul, item ) {
  5307. return this._renderItem( ul, item ).data( "ui-autocomplete-item", item );
  5308. },
  5309. _renderItem: function( ul, item ) {
  5310. return $( "<li>" )
  5311. .append( $( "<a>" ).text( item.label ) )
  5312. .appendTo( ul );
  5313. },
  5314. _move: function( direction, event ) {
  5315. if ( !this.menu.element.is( ":visible" ) ) {
  5316. this.search( null, event );
  5317. return;
  5318. }
  5319. if ( this.menu.isFirstItem() && /^previous/.test( direction ) ||
  5320. this.menu.isLastItem() && /^next/.test( direction ) ) {
  5321. this._value( this.term );
  5322. this.menu.blur();
  5323. return;
  5324. }
  5325. this.menu[ direction ]( event );
  5326. },
  5327. widget: function() {
  5328. return this.menu.element;
  5329. },
  5330. _value: function() {
  5331. return this.valueMethod.apply( this.element, arguments );
  5332. },
  5333. _keyEvent: function( keyEvent, event ) {
  5334. if ( !this.isMultiLine || this.menu.element.is( ":visible" ) ) {
  5335. this._move( keyEvent, event );
  5336. // prevents moving cursor to beginning/end of the text field in some browsers
  5337. event.preventDefault();
  5338. }
  5339. }
  5340. });
  5341. $.extend( $.ui.autocomplete, {
  5342. escapeRegex: function( value ) {
  5343. return value.replace(/[\-\[\]{}()*+?.,\\\^$|#\s]/g, "\\$&");
  5344. },
  5345. filter: function(array, term) {
  5346. var matcher = new RegExp( $.ui.autocomplete.escapeRegex(term), "i" );
  5347. return $.grep( array, function(value) {
  5348. return matcher.test( value.label || value.value || value );
  5349. });
  5350. }
  5351. });
  5352. // live region extension, adding a `messages` option
  5353. // NOTE: This is an experimental API. We are still investigating
  5354. // a full solution for string manipulation and internationalization.
  5355. $.widget( "ui.autocomplete", $.ui.autocomplete, {
  5356. options: {
  5357. messages: {
  5358. noResults: "No search results.",
  5359. results: function( amount ) {
  5360. return amount + ( amount > 1 ? " results are" : " result is" ) +
  5361. " available, use up and down arrow keys to navigate.";
  5362. }
  5363. }
  5364. },
  5365. __response: function( content ) {
  5366. var message;
  5367. this._superApply( arguments );
  5368. if ( this.options.disabled || this.cancelSearch ) {
  5369. return;
  5370. }
  5371. if ( content && content.length ) {
  5372. message = this.options.messages.results( content.length );
  5373. } else {
  5374. message = this.options.messages.noResults;
  5375. }
  5376. this.liveRegion.text( message );
  5377. }
  5378. });
  5379. }( jQuery ));
  5380. (function( $, undefined ) {
  5381. var lastActive, startXPos, startYPos, clickDragged,
  5382. baseClasses = "ui-button ui-widget ui-state-default ui-corner-all",
  5383. stateClasses = "ui-state-hover ui-state-active ",
  5384. 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",
  5385. formResetHandler = function() {
  5386. var form = $( this );
  5387. setTimeout(function() {
  5388. form.find( ":ui-button" ).button( "refresh" );
  5389. }, 1 );
  5390. },
  5391. radioGroup = function( radio ) {
  5392. var name = radio.name,
  5393. form = radio.form,
  5394. radios = $( [] );
  5395. if ( name ) {
  5396. name = name.replace( /'/g, "\\'" );
  5397. if ( form ) {
  5398. radios = $( form ).find( "[name='" + name + "']" );
  5399. } else {
  5400. radios = $( "[name='" + name + "']", radio.ownerDocument )
  5401. .filter(function() {
  5402. return !this.form;
  5403. });
  5404. }
  5405. }
  5406. return radios;
  5407. };
  5408. $.widget( "ui.button", {
  5409. version: "1.10.3",
  5410. defaultElement: "<button>",
  5411. options: {
  5412. disabled: null,
  5413. text: true,
  5414. label: null,
  5415. icons: {
  5416. primary: null,
  5417. secondary: null
  5418. }
  5419. },
  5420. _create: function() {
  5421. this.element.closest( "form" )
  5422. .unbind( "reset" + this.eventNamespace )
  5423. .bind( "reset" + this.eventNamespace, formResetHandler );
  5424. if ( typeof this.options.disabled !== "boolean" ) {
  5425. this.options.disabled = !!this.element.prop( "disabled" );
  5426. } else {
  5427. this.element.prop( "disabled", this.options.disabled );
  5428. }
  5429. this._determineButtonType();
  5430. this.hasTitle = !!this.buttonElement.attr( "title" );
  5431. var that = this,
  5432. options = this.options,
  5433. toggleButton = this.type === "checkbox" || this.type === "radio",
  5434. activeClass = !toggleButton ? "ui-state-active" : "",
  5435. focusClass = "ui-state-focus";
  5436. if ( options.label === null ) {
  5437. options.label = (this.type === "input" ? this.buttonElement.val() : this.buttonElement.html());
  5438. }
  5439. this._hoverable( this.buttonElement );
  5440. this.buttonElement
  5441. .addClass( baseClasses )
  5442. .attr( "role", "button" )
  5443. .bind( "mouseenter" + this.eventNamespace, function() {
  5444. if ( options.disabled ) {
  5445. return;
  5446. }
  5447. if ( this === lastActive ) {
  5448. $( this ).addClass( "ui-state-active" );
  5449. }
  5450. })
  5451. .bind( "mouseleave" + this.eventNamespace, function() {
  5452. if ( options.disabled ) {
  5453. return;
  5454. }
  5455. $( this ).removeClass( activeClass );
  5456. })
  5457. .bind( "click" + this.eventNamespace, function( event ) {
  5458. if ( options.disabled ) {
  5459. event.preventDefault();
  5460. event.stopImmediatePropagation();
  5461. }
  5462. });
  5463. this.element
  5464. .bind( "focus" + this.eventNamespace, function() {
  5465. // no need to check disabled, focus won't be triggered anyway
  5466. that.buttonElement.addClass( focusClass );
  5467. })
  5468. .bind( "blur" + this.eventNamespace, function() {
  5469. that.buttonElement.removeClass( focusClass );
  5470. });
  5471. if ( toggleButton ) {
  5472. this.element.bind( "change" + this.eventNamespace, function() {
  5473. if ( clickDragged ) {
  5474. return;
  5475. }
  5476. that.refresh();
  5477. });
  5478. // if mouse moves between mousedown and mouseup (drag) set clickDragged flag
  5479. // prevents issue where button state changes but checkbox/radio checked state
  5480. // does not in Firefox (see ticket #6970)
  5481. this.buttonElement
  5482. .bind( "mousedown" + this.eventNamespace, function( event ) {
  5483. if ( options.disabled ) {
  5484. return;
  5485. }
  5486. clickDragged = false;
  5487. startXPos = event.pageX;
  5488. startYPos = event.pageY;
  5489. })
  5490. .bind( "mouseup" + this.eventNamespace, function( event ) {
  5491. if ( options.disabled ) {
  5492. return;
  5493. }
  5494. if ( startXPos !== event.pageX || startYPos !== event.pageY ) {
  5495. clickDragged = true;
  5496. }
  5497. });
  5498. }
  5499. if ( this.type === "checkbox" ) {
  5500. this.buttonElement.bind( "click" + this.eventNamespace, function() {
  5501. if ( options.disabled || clickDragged ) {
  5502. return false;
  5503. }
  5504. });
  5505. } else if ( this.type === "radio" ) {
  5506. this.buttonElement.bind( "click" + this.eventNamespace, function() {
  5507. if ( options.disabled || clickDragged ) {
  5508. return false;
  5509. }
  5510. $( this ).addClass( "ui-state-active" );
  5511. that.buttonElement.attr( "aria-pressed", "true" );
  5512. var radio = that.element[ 0 ];
  5513. radioGroup( radio )
  5514. .not( radio )
  5515. .map(function() {
  5516. return $( this ).button( "widget" )[ 0 ];
  5517. })
  5518. .removeClass( "ui-state-active" )
  5519. .attr( "aria-pressed", "false" );
  5520. });
  5521. } else {
  5522. this.buttonElement
  5523. .bind( "mousedown" + this.eventNamespace, function() {
  5524. if ( options.disabled ) {
  5525. return false;
  5526. }
  5527. $( this ).addClass( "ui-state-active" );
  5528. lastActive = this;
  5529. that.document.one( "mouseup", function() {
  5530. lastActive = null;
  5531. });
  5532. })
  5533. .bind( "mouseup" + this.eventNamespace, function() {
  5534. if ( options.disabled ) {
  5535. return false;
  5536. }
  5537. $( this ).removeClass( "ui-state-active" );
  5538. })
  5539. .bind( "keydown" + this.eventNamespace, function(event) {
  5540. if ( options.disabled ) {
  5541. return false;
  5542. }
  5543. if ( event.keyCode === $.ui.keyCode.SPACE || event.keyCode === $.ui.keyCode.ENTER ) {
  5544. $( this ).addClass( "ui-state-active" );
  5545. }
  5546. })
  5547. // see #8559, we bind to blur here in case the button element loses
  5548. // focus between keydown and keyup, it would be left in an "active" state
  5549. .bind( "keyup" + this.eventNamespace + " blur" + this.eventNamespace, function() {
  5550. $( this ).removeClass( "ui-state-active" );
  5551. });
  5552. if ( this.buttonElement.is("a") ) {
  5553. this.buttonElement.keyup(function(event) {
  5554. if ( event.keyCode === $.ui.keyCode.SPACE ) {
  5555. // TODO pass through original event correctly (just as 2nd argument doesn't work)
  5556. $( this ).click();
  5557. }
  5558. });
  5559. }
  5560. }
  5561. // TODO: pull out $.Widget's handling for the disabled option into
  5562. // $.Widget.prototype._setOptionDisabled so it's easy to proxy and can
  5563. // be overridden by individual plugins
  5564. this._setOption( "disabled", options.disabled );
  5565. this._resetButton();
  5566. },
  5567. _determineButtonType: function() {
  5568. var ancestor, labelSelector, checked;
  5569. if ( this.element.is("[type=checkbox]") ) {
  5570. this.type = "checkbox";
  5571. } else if ( this.element.is("[type=radio]") ) {
  5572. this.type = "radio";
  5573. } else if ( this.element.is("input") ) {
  5574. this.type = "input";
  5575. } else {
  5576. this.type = "button";
  5577. }
  5578. if ( this.type === "checkbox" || this.type === "radio" ) {
  5579. // we don't search against the document in case the element
  5580. // is disconnected from the DOM
  5581. ancestor = this.element.parents().last();
  5582. labelSelector = "label[for='" + this.element.attr("id") + "']";
  5583. this.buttonElement = ancestor.find( labelSelector );
  5584. if ( !this.buttonElement.length ) {
  5585. ancestor = ancestor.length ? ancestor.siblings() : this.element.siblings();
  5586. this.buttonElement = ancestor.filter( labelSelector );
  5587. if ( !this.buttonElement.length ) {
  5588. this.buttonElement = ancestor.find( labelSelector );
  5589. }
  5590. }
  5591. this.element.addClass( "ui-helper-hidden-accessible" );
  5592. checked = this.element.is( ":checked" );
  5593. if ( checked ) {
  5594. this.buttonElement.addClass( "ui-state-active" );
  5595. }
  5596. this.buttonElement.prop( "aria-pressed", checked );
  5597. } else {
  5598. this.buttonElement = this.element;
  5599. }
  5600. },
  5601. widget: function() {
  5602. return this.buttonElement;
  5603. },
  5604. _destroy: function() {
  5605. this.element
  5606. .removeClass( "ui-helper-hidden-accessible" );
  5607. this.buttonElement
  5608. .removeClass( baseClasses + " " + stateClasses + " " + typeClasses )
  5609. .removeAttr( "role" )
  5610. .removeAttr( "aria-pressed" )
  5611. .html( this.buttonElement.find(".ui-button-text").html() );
  5612. if ( !this.hasTitle ) {
  5613. this.buttonElement.removeAttr( "title" );
  5614. }
  5615. },
  5616. _setOption: function( key, value ) {
  5617. this._super( key, value );
  5618. if ( key === "disabled" ) {
  5619. if ( value ) {
  5620. this.element.prop( "disabled", true );
  5621. } else {
  5622. this.element.prop( "disabled", false );
  5623. }
  5624. return;
  5625. }
  5626. this._resetButton();
  5627. },
  5628. refresh: function() {
  5629. //See #8237 & #8828
  5630. var isDisabled = this.element.is( "input, button" ) ? this.element.is( ":disabled" ) : this.element.hasClass( "ui-button-disabled" );
  5631. if ( isDisabled !== this.options.disabled ) {
  5632. this._setOption( "disabled", isDisabled );
  5633. }
  5634. if ( this.type === "radio" ) {
  5635. radioGroup( this.element[0] ).each(function() {
  5636. if ( $( this ).is( ":checked" ) ) {
  5637. $( this ).button( "widget" )
  5638. .addClass( "ui-state-active" )
  5639. .attr( "aria-pressed", "true" );
  5640. } else {
  5641. $( this ).button( "widget" )
  5642. .removeClass( "ui-state-active" )
  5643. .attr( "aria-pressed", "false" );
  5644. }
  5645. });
  5646. } else if ( this.type === "checkbox" ) {
  5647. if ( this.element.is( ":checked" ) ) {
  5648. this.buttonElement
  5649. .addClass( "ui-state-active" )
  5650. .attr( "aria-pressed", "true" );
  5651. } else {
  5652. this.buttonElement
  5653. .removeClass( "ui-state-active" )
  5654. .attr( "aria-pressed", "false" );
  5655. }
  5656. }
  5657. },
  5658. _resetButton: function() {
  5659. if ( this.type === "input" ) {
  5660. if ( this.options.label ) {
  5661. this.element.val( this.options.label );
  5662. }
  5663. return;
  5664. }
  5665. var buttonElement = this.buttonElement.removeClass( typeClasses ),
  5666. buttonText = $( "<span></span>", this.document[0] )
  5667. .addClass( "ui-button-text" )
  5668. .html( this.options.label )
  5669. .appendTo( buttonElement.empty() )
  5670. .text(),
  5671. icons = this.options.icons,
  5672. multipleIcons = icons.primary && icons.secondary,
  5673. buttonClasses = [];
  5674. if ( icons.primary || icons.secondary ) {
  5675. if ( this.options.text ) {
  5676. buttonClasses.push( "ui-button-text-icon" + ( multipleIcons ? "s" : ( icons.primary ? "-primary" : "-secondary" ) ) );
  5677. }
  5678. if ( icons.primary ) {
  5679. buttonElement.prepend( "<span class='ui-button-icon-primary ui-icon " + icons.primary + "'></span>" );
  5680. }
  5681. if ( icons.secondary ) {
  5682. buttonElement.append( "<span class='ui-button-icon-secondary ui-icon " + icons.secondary + "'></span>" );
  5683. }
  5684. if ( !this.options.text ) {
  5685. buttonClasses.push( multipleIcons ? "ui-button-icons-only" : "ui-button-icon-only" );
  5686. if ( !this.hasTitle ) {
  5687. buttonElement.attr( "title", $.trim( buttonText ) );
  5688. }
  5689. }
  5690. } else {
  5691. buttonClasses.push( "ui-button-text-only" );
  5692. }
  5693. buttonElement.addClass( buttonClasses.join( " " ) );
  5694. }
  5695. });
  5696. $.widget( "ui.buttonset", {
  5697. version: "1.10.3",
  5698. options: {
  5699. items: "button, input[type=button], input[type=submit], input[type=reset], input[type=checkbox], input[type=radio], a, :data(ui-button)"
  5700. },
  5701. _create: function() {
  5702. this.element.addClass( "ui-buttonset" );
  5703. },
  5704. _init: function() {
  5705. this.refresh();
  5706. },
  5707. _setOption: function( key, value ) {
  5708. if ( key === "disabled" ) {
  5709. this.buttons.button( "option", key, value );
  5710. }
  5711. this._super( key, value );
  5712. },
  5713. refresh: function() {
  5714. var rtl = this.element.css( "direction" ) === "rtl";
  5715. this.buttons = this.element.find( this.options.items )
  5716. .filter( ":ui-button" )
  5717. .button( "refresh" )
  5718. .end()
  5719. .not( ":ui-button" )
  5720. .button()
  5721. .end()
  5722. .map(function() {
  5723. return $( this ).button( "widget" )[ 0 ];
  5724. })
  5725. .removeClass( "ui-corner-all ui-corner-left ui-corner-right" )
  5726. .filter( ":first" )
  5727. .addClass( rtl ? "ui-corner-right" : "ui-corner-left" )
  5728. .end()
  5729. .filter( ":last" )
  5730. .addClass( rtl ? "ui-corner-left" : "ui-corner-right" )
  5731. .end()
  5732. .end();
  5733. },
  5734. _destroy: function() {
  5735. this.element.removeClass( "ui-buttonset" );
  5736. this.buttons
  5737. .map(function() {
  5738. return $( this ).button( "widget" )[ 0 ];
  5739. })
  5740. .removeClass( "ui-corner-left ui-corner-right" )
  5741. .end()
  5742. .button( "destroy" );
  5743. }
  5744. });
  5745. }( jQuery ) );
  5746. (function( $, undefined ) {
  5747. $.extend($.ui, { datepicker: { version: "1.10.3" } });
  5748. var PROP_NAME = "datepicker",
  5749. instActive;
  5750. /* Date picker manager.
  5751. Use the singleton instance of this class, $.datepicker, to interact with the date picker.
  5752. Settings for (groups of) date pickers are maintained in an instance object,
  5753. allowing multiple different settings on the same page. */
  5754. function Datepicker() {
  5755. this._curInst = null; // The current instance in use
  5756. this._keyEvent = false; // If the last event was a key event
  5757. this._disabledInputs = []; // List of date picker inputs that have been disabled
  5758. this._datepickerShowing = false; // True if the popup picker is showing , false if not
  5759. this._inDialog = false; // True if showing within a "dialog", false if not
  5760. this._mainDivId = "ui-datepicker-div"; // The ID of the main datepicker division
  5761. this._inlineClass = "ui-datepicker-inline"; // The name of the inline marker class
  5762. this._appendClass = "ui-datepicker-append"; // The name of the append marker class
  5763. this._triggerClass = "ui-datepicker-trigger"; // The name of the trigger marker class
  5764. this._dialogClass = "ui-datepicker-dialog"; // The name of the dialog marker class
  5765. this._disableClass = "ui-datepicker-disabled"; // The name of the disabled covering marker class
  5766. this._unselectableClass = "ui-datepicker-unselectable"; // The name of the unselectable cell marker class
  5767. this._currentClass = "ui-datepicker-current-day"; // The name of the current day marker class
  5768. this._dayOverClass = "ui-datepicker-days-cell-over"; // The name of the day hover marker class
  5769. this.regional = []; // Available regional settings, indexed by language code
  5770. this.regional[""] = { // Default regional settings
  5771. closeText: "Done", // Display text for close link
  5772. prevText: "Prev", // Display text for previous month link
  5773. nextText: "Next", // Display text for next month link
  5774. currentText: "Today", // Display text for current month link
  5775. monthNames: ["January","February","March","April","May","June",
  5776. "July","August","September","October","November","December"], // Names of months for drop-down and formatting
  5777. monthNamesShort: ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"], // For formatting
  5778. dayNames: ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"], // For formatting
  5779. dayNamesShort: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"], // For formatting
  5780. dayNamesMin: ["Su","Mo","Tu","We","Th","Fr","Sa"], // Column headings for days starting at Sunday
  5781. weekHeader: "Wk", // Column header for week of the year
  5782. dateFormat: "mm/dd/yy", // See format options on parseDate
  5783. firstDay: 0, // The first day of the week, Sun = 0, Mon = 1, ...
  5784. isRTL: false, // True if right-to-left language, false if left-to-right
  5785. showMonthAfterYear: false, // True if the year select precedes month, false for month then year
  5786. yearSuffix: "" // Additional text to append to the year in the month headers
  5787. };
  5788. this._defaults = { // Global defaults for all the date picker instances
  5789. showOn: "focus", // "focus" for popup on focus,
  5790. // "button" for trigger button, or "both" for either
  5791. showAnim: "fadeIn", // Name of jQuery animation for popup
  5792. showOptions: {}, // Options for enhanced animations
  5793. defaultDate: null, // Used when field is blank: actual date,
  5794. // +/-number for offset from today, null for today
  5795. appendText: "", // Display text following the input box, e.g. showing the format
  5796. buttonText: "...", // Text for trigger button
  5797. buttonImage: "", // URL for trigger button image
  5798. buttonImageOnly: false, // True if the image appears alone, false if it appears on a button
  5799. hideIfNoPrevNext: false, // True to hide next/previous month links
  5800. // if not applicable, false to just disable them
  5801. navigationAsDateFormat: false, // True if date formatting applied to prev/today/next links
  5802. gotoCurrent: false, // True if today link goes back to current selection instead
  5803. changeMonth: false, // True if month can be selected directly, false if only prev/next
  5804. changeYear: false, // True if year can be selected directly, false if only prev/next
  5805. yearRange: "c-10:c+10", // Range of years to display in drop-down,
  5806. // either relative to today's year (-nn:+nn), relative to currently displayed year
  5807. // (c-nn:c+nn), absolute (nnnn:nnnn), or a combination of the above (nnnn:-n)
  5808. showOtherMonths: false, // True to show dates in other months, false to leave blank
  5809. selectOtherMonths: false, // True to allow selection of dates in other months, false for unselectable
  5810. showWeek: false, // True to show week of the year, false to not show it
  5811. calculateWeek: this.iso8601Week, // How to calculate the week of the year,
  5812. // takes a Date and returns the number of the week for it
  5813. shortYearCutoff: "+10", // Short year values < this are in the current century,
  5814. // > this are in the previous century,
  5815. // string value starting with "+" for current year + value
  5816. minDate: null, // The earliest selectable date, or null for no limit
  5817. maxDate: null, // The latest selectable date, or null for no limit
  5818. duration: "fast", // Duration of display/closure
  5819. beforeShowDay: null, // Function that takes a date and returns an array with
  5820. // [0] = true if selectable, false if not, [1] = custom CSS class name(s) or "",
  5821. // [2] = cell title (optional), e.g. $.datepicker.noWeekends
  5822. beforeShow: null, // Function that takes an input field and
  5823. // returns a set of custom settings for the date picker
  5824. onSelect: null, // Define a callback function when a date is selected
  5825. onChangeMonthYear: null, // Define a callback function when the month or year is changed
  5826. onClose: null, // Define a callback function when the datepicker is closed
  5827. numberOfMonths: 1, // Number of months to show at a time
  5828. showCurrentAtPos: 0, // The position in multipe months at which to show the current month (starting at 0)
  5829. stepMonths: 1, // Number of months to step back/forward
  5830. stepBigMonths: 12, // Number of months to step back/forward for the big links
  5831. altField: "", // Selector for an alternate field to store selected dates into
  5832. altFormat: "", // The date format to use for the alternate field
  5833. constrainInput: true, // The input is constrained by the current date format
  5834. showButtonPanel: false, // True to show button panel, false to not show it
  5835. autoSize: false, // True to size the input for the date format, false to leave as is
  5836. disabled: false // The initial disabled state
  5837. };
  5838. $.extend(this._defaults, this.regional[""]);
  5839. this.dpDiv = bindHover($("<div id='" + this._mainDivId + "' class='ui-datepicker ui-widget ui-widget-content ui-helper-clearfix ui-corner-all'></div>"));
  5840. }
  5841. $.extend(Datepicker.prototype, {
  5842. /* Class name added to elements to indicate already configured with a date picker. */
  5843. markerClassName: "hasDatepicker",
  5844. //Keep track of the maximum number of rows displayed (see #7043)
  5845. maxRows: 4,
  5846. // TODO rename to "widget" when switching to widget factory
  5847. _widgetDatepicker: function() {
  5848. return this.dpDiv;
  5849. },
  5850. /* Override the default settings for all instances of the date picker.
  5851. * @param settings object - the new settings to use as defaults (anonymous object)
  5852. * @return the manager object
  5853. */
  5854. setDefaults: function(settings) {
  5855. extendRemove(this._defaults, settings || {});
  5856. return this;
  5857. },
  5858. /* Attach the date picker to a jQuery selection.
  5859. * @param target element - the target input field or division or span
  5860. * @param settings object - the new settings to use for this date picker instance (anonymous)
  5861. */
  5862. _attachDatepicker: function(target, settings) {
  5863. var nodeName, inline, inst;
  5864. nodeName = target.nodeName.toLowerCase();
  5865. inline = (nodeName === "div" || nodeName === "span");
  5866. if (!target.id) {
  5867. this.uuid += 1;
  5868. target.id = "dp" + this.uuid;
  5869. }
  5870. inst = this._newInst($(target), inline);
  5871. inst.settings = $.extend({}, settings || {});
  5872. if (nodeName === "input") {
  5873. this._connectDatepicker(target, inst);
  5874. } else if (inline) {
  5875. this._inlineDatepicker(target, inst);
  5876. }
  5877. },
  5878. /* Create a new instance object. */
  5879. _newInst: function(target, inline) {
  5880. var id = target[0].id.replace(/([^A-Za-z0-9_\-])/g, "\\\\$1"); // escape jQuery meta chars
  5881. return {id: id, input: target, // associated target
  5882. selectedDay: 0, selectedMonth: 0, selectedYear: 0, // current selection
  5883. drawMonth: 0, drawYear: 0, // month being drawn
  5884. inline: inline, // is datepicker inline or not
  5885. dpDiv: (!inline ? this.dpDiv : // presentation div
  5886. bindHover($("<div class='" + this._inlineClass + " ui-datepicker ui-widget ui-widget-content ui-helper-clearfix ui-corner-all'></div>")))};
  5887. },
  5888. /* Attach the date picker to an input field. */
  5889. _connectDatepicker: function(target, inst) {
  5890. var input = $(target);
  5891. inst.append = $([]);
  5892. inst.trigger = $([]);
  5893. if (input.hasClass(this.markerClassName)) {
  5894. return;
  5895. }
  5896. this._attachments(input, inst);
  5897. input.addClass(this.markerClassName).keydown(this._doKeyDown).
  5898. keypress(this._doKeyPress).keyup(this._doKeyUp);
  5899. this._autoSize(inst);
  5900. $.data(target, PROP_NAME, inst);
  5901. //If disabled option is true, disable the datepicker once it has been attached to the input (see ticket #5665)
  5902. if( inst.settings.disabled ) {
  5903. this._disableDatepicker( target );
  5904. }
  5905. },
  5906. /* Make attachments based on settings. */
  5907. _attachments: function(input, inst) {
  5908. var showOn, buttonText, buttonImage,
  5909. appendText = this._get(inst, "appendText"),
  5910. isRTL = this._get(inst, "isRTL");
  5911. if (inst.append) {
  5912. inst.append.remove();
  5913. }
  5914. if (appendText) {
  5915. inst.append = $("<span class='" + this._appendClass + "'>" + appendText + "</span>");
  5916. input[isRTL ? "before" : "after"](inst.append);
  5917. }
  5918. input.unbind("focus", this._showDatepicker);
  5919. if (inst.trigger) {
  5920. inst.trigger.remove();
  5921. }
  5922. showOn = this._get(inst, "showOn");
  5923. if (showOn === "focus" || showOn === "both") { // pop-up date picker when in the marked field
  5924. input.focus(this._showDatepicker);
  5925. }
  5926. if (showOn === "button" || showOn === "both") { // pop-up date picker when button clicked
  5927. buttonText = this._get(inst, "buttonText");
  5928. buttonImage = this._get(inst, "buttonImage");
  5929. inst.trigger = $(this._get(inst, "buttonImageOnly") ?
  5930. $("<img/>").addClass(this._triggerClass).
  5931. attr({ src: buttonImage, alt: buttonText, title: buttonText }) :
  5932. $("<button type='button'></button>").addClass(this._triggerClass).
  5933. html(!buttonImage ? buttonText : $("<img/>").attr(
  5934. { src:buttonImage, alt:buttonText, title:buttonText })));
  5935. input[isRTL ? "before" : "after"](inst.trigger);
  5936. inst.trigger.click(function() {
  5937. if ($.datepicker._datepickerShowing && $.datepicker._lastInput === input[0]) {
  5938. $.datepicker._hideDatepicker();
  5939. } else if ($.datepicker._datepickerShowing && $.datepicker._lastInput !== input[0]) {
  5940. $.datepicker._hideDatepicker();
  5941. $.datepicker._showDatepicker(input[0]);
  5942. } else {
  5943. $.datepicker._showDatepicker(input[0]);
  5944. }
  5945. return false;
  5946. });
  5947. }
  5948. },
  5949. /* Apply the maximum length for the date format. */
  5950. _autoSize: function(inst) {
  5951. if (this._get(inst, "autoSize") && !inst.inline) {
  5952. var findMax, max, maxI, i,
  5953. date = new Date(2009, 12 - 1, 20), // Ensure double digits
  5954. dateFormat = this._get(inst, "dateFormat");
  5955. if (dateFormat.match(/[DM]/)) {
  5956. findMax = function(names) {
  5957. max = 0;
  5958. maxI = 0;
  5959. for (i = 0; i < names.length; i++) {
  5960. if (names[i].length > max) {
  5961. max = names[i].length;
  5962. maxI = i;
  5963. }
  5964. }
  5965. return maxI;
  5966. };
  5967. date.setMonth(findMax(this._get(inst, (dateFormat.match(/MM/) ?
  5968. "monthNames" : "monthNamesShort"))));
  5969. date.setDate(findMax(this._get(inst, (dateFormat.match(/DD/) ?
  5970. "dayNames" : "dayNamesShort"))) + 20 - date.getDay());
  5971. }
  5972. inst.input.attr("size", this._formatDate(inst, date).length);
  5973. }
  5974. },
  5975. /* Attach an inline date picker to a div. */
  5976. _inlineDatepicker: function(target, inst) {
  5977. var divSpan = $(target);
  5978. if (divSpan.hasClass(this.markerClassName)) {
  5979. return;
  5980. }
  5981. divSpan.addClass(this.markerClassName).append(inst.dpDiv);
  5982. $.data(target, PROP_NAME, inst);
  5983. this._setDate(inst, this._getDefaultDate(inst), true);
  5984. this._updateDatepicker(inst);
  5985. this._updateAlternate(inst);
  5986. //If disabled option is true, disable the datepicker before showing it (see ticket #5665)
  5987. if( inst.settings.disabled ) {
  5988. this._disableDatepicker( target );
  5989. }
  5990. // Set display:block in place of inst.dpDiv.show() which won't work on disconnected elements
  5991. // http://bugs.jqueryui.com/ticket/7552 - A Datepicker created on a detached div has zero height
  5992. inst.dpDiv.css( "display", "block" );
  5993. },
  5994. /* Pop-up the date picker in a "dialog" box.
  5995. * @param input element - ignored
  5996. * @param date string or Date - the initial date to display
  5997. * @param onSelect function - the function to call when a date is selected
  5998. * @param settings object - update the dialog date picker instance's settings (anonymous object)
  5999. * @param pos int[2] - coordinates for the dialog's position within the screen or
  6000. * event - with x/y coordinates or
  6001. * leave empty for default (screen centre)
  6002. * @return the manager object
  6003. */
  6004. _dialogDatepicker: function(input, date, onSelect, settings, pos) {
  6005. var id, browserWidth, browserHeight, scrollX, scrollY,
  6006. inst = this._dialogInst; // internal instance
  6007. if (!inst) {
  6008. this.uuid += 1;
  6009. id = "dp" + this.uuid;
  6010. this._dialogInput = $("<input type='text' id='" + id +
  6011. "' style='position: absolute; top: -100px; width: 0px;'/>");
  6012. this._dialogInput.keydown(this._doKeyDown);
  6013. $("body").append(this._dialogInput);
  6014. inst = this._dialogInst = this._newInst(this._dialogInput, false);
  6015. inst.settings = {};
  6016. $.data(this._dialogInput[0], PROP_NAME, inst);
  6017. }
  6018. extendRemove(inst.settings, settings || {});
  6019. date = (date && date.constructor === Date ? this._formatDate(inst, date) : date);
  6020. this._dialogInput.val(date);
  6021. this._pos = (pos ? (pos.length ? pos : [pos.pageX, pos.pageY]) : null);
  6022. if (!this._pos) {
  6023. browserWidth = document.documentElement.clientWidth;
  6024. browserHeight = document.documentElement.clientHeight;
  6025. scrollX = document.documentElement.scrollLeft || document.body.scrollLeft;
  6026. scrollY = document.documentElement.scrollTop || document.body.scrollTop;
  6027. this._pos = // should use actual width/height below
  6028. [(browserWidth / 2) - 100 + scrollX, (browserHeight / 2) - 150 + scrollY];
  6029. }
  6030. // move input on screen for focus, but hidden behind dialog
  6031. this._dialogInput.css("left", (this._pos[0] + 20) + "px").css("top", this._pos[1] + "px");
  6032. inst.settings.onSelect = onSelect;
  6033. this._inDialog = true;
  6034. this.dpDiv.addClass(this._dialogClass);
  6035. this._showDatepicker(this._dialogInput[0]);
  6036. if ($.blockUI) {
  6037. $.blockUI(this.dpDiv);
  6038. }
  6039. $.data(this._dialogInput[0], PROP_NAME, inst);
  6040. return this;
  6041. },
  6042. /* Detach a datepicker from its control.
  6043. * @param target element - the target input field or division or span
  6044. */
  6045. _destroyDatepicker: function(target) {
  6046. var nodeName,
  6047. $target = $(target),
  6048. inst = $.data(target, PROP_NAME);
  6049. if (!$target.hasClass(this.markerClassName)) {
  6050. return;
  6051. }
  6052. nodeName = target.nodeName.toLowerCase();
  6053. $.removeData(target, PROP_NAME);
  6054. if (nodeName === "input") {
  6055. inst.append.remove();
  6056. inst.trigger.remove();
  6057. $target.removeClass(this.markerClassName).
  6058. unbind("focus", this._showDatepicker).
  6059. unbind("keydown", this._doKeyDown).
  6060. unbind("keypress", this._doKeyPress).
  6061. unbind("keyup", this._doKeyUp);
  6062. } else if (nodeName === "div" || nodeName === "span") {
  6063. $target.removeClass(this.markerClassName).empty();
  6064. }
  6065. },
  6066. /* Enable the date picker to a jQuery selection.
  6067. * @param target element - the target input field or division or span
  6068. */
  6069. _enableDatepicker: function(target) {
  6070. var nodeName, inline,
  6071. $target = $(target),
  6072. inst = $.data(target, PROP_NAME);
  6073. if (!$target.hasClass(this.markerClassName)) {
  6074. return;
  6075. }
  6076. nodeName = target.nodeName.toLowerCase();
  6077. if (nodeName === "input") {
  6078. target.disabled = false;
  6079. inst.trigger.filter("button").
  6080. each(function() { this.disabled = false; }).end().
  6081. filter("img").css({opacity: "1.0", cursor: ""});
  6082. } else if (nodeName === "div" || nodeName === "span") {
  6083. inline = $target.children("." + this._inlineClass);
  6084. inline.children().removeClass("ui-state-disabled");
  6085. inline.find("select.ui-datepicker-month, select.ui-datepicker-year").
  6086. prop("disabled", false);
  6087. }
  6088. this._disabledInputs = $.map(this._disabledInputs,
  6089. function(value) { return (value === target ? null : value); }); // delete entry
  6090. },
  6091. /* Disable the date picker to a jQuery selection.
  6092. * @param target element - the target input field or division or span
  6093. */
  6094. _disableDatepicker: function(target) {
  6095. var nodeName, inline,
  6096. $target = $(target),
  6097. inst = $.data(target, PROP_NAME);
  6098. if (!$target.hasClass(this.markerClassName)) {
  6099. return;
  6100. }
  6101. nodeName = target.nodeName.toLowerCase();
  6102. if (nodeName === "input") {
  6103. target.disabled = true;
  6104. inst.trigger.filter("button").
  6105. each(function() { this.disabled = true; }).end().
  6106. filter("img").css({opacity: "0.5", cursor: "default"});
  6107. } else if (nodeName === "div" || nodeName === "span") {
  6108. inline = $target.children("." + this._inlineClass);
  6109. inline.children().addClass("ui-state-disabled");
  6110. inline.find("select.ui-datepicker-month, select.ui-datepicker-year").
  6111. prop("disabled", true);
  6112. }
  6113. this._disabledInputs = $.map(this._disabledInputs,
  6114. function(value) { return (value === target ? null : value); }); // delete entry
  6115. this._disabledInputs[this._disabledInputs.length] = target;
  6116. },
  6117. /* Is the first field in a jQuery collection disabled as a datepicker?
  6118. * @param target element - the target input field or division or span
  6119. * @return boolean - true if disabled, false if enabled
  6120. */
  6121. _isDisabledDatepicker: function(target) {
  6122. if (!target) {
  6123. return false;
  6124. }
  6125. for (var i = 0; i < this._disabledInputs.length; i++) {
  6126. if (this._disabledInputs[i] === target) {
  6127. return true;
  6128. }
  6129. }
  6130. return false;
  6131. },
  6132. /* Retrieve the instance data for the target control.
  6133. * @param target element - the target input field or division or span
  6134. * @return object - the associated instance data
  6135. * @throws error if a jQuery problem getting data
  6136. */
  6137. _getInst: function(target) {
  6138. try {
  6139. return $.data(target, PROP_NAME);
  6140. }
  6141. catch (err) {
  6142. throw "Missing instance data for this datepicker";
  6143. }
  6144. },
  6145. /* Update or retrieve the settings for a date picker attached to an input field or division.
  6146. * @param target element - the target input field or division or span
  6147. * @param name object - the new settings to update or
  6148. * string - the name of the setting to change or retrieve,
  6149. * when retrieving also "all" for all instance settings or
  6150. * "defaults" for all global defaults
  6151. * @param value any - the new value for the setting
  6152. * (omit if above is an object or to retrieve a value)
  6153. */
  6154. _optionDatepicker: function(target, name, value) {
  6155. var settings, date, minDate, maxDate,
  6156. inst = this._getInst(target);
  6157. if (arguments.length === 2 && typeof name === "string") {
  6158. return (name === "defaults" ? $.extend({}, $.datepicker._defaults) :
  6159. (inst ? (name === "all" ? $.extend({}, inst.settings) :
  6160. this._get(inst, name)) : null));
  6161. }
  6162. settings = name || {};
  6163. if (typeof name === "string") {
  6164. settings = {};
  6165. settings[name] = value;
  6166. }
  6167. if (inst) {
  6168. if (this._curInst === inst) {
  6169. this._hideDatepicker();
  6170. }
  6171. date = this._getDateDatepicker(target, true);
  6172. minDate = this._getMinMaxDate(inst, "min");
  6173. maxDate = this._getMinMaxDate(inst, "max");
  6174. extendRemove(inst.settings, settings);
  6175. // reformat the old minDate/maxDate values if dateFormat changes and a new minDate/maxDate isn't provided
  6176. if (minDate !== null && settings.dateFormat !== undefined && settings.minDate === undefined) {
  6177. inst.settings.minDate = this._formatDate(inst, minDate);
  6178. }
  6179. if (maxDate !== null && settings.dateFormat !== undefined && settings.maxDate === undefined) {
  6180. inst.settings.maxDate = this._formatDate(inst, maxDate);
  6181. }
  6182. if ( "disabled" in settings ) {
  6183. if ( settings.disabled ) {
  6184. this._disableDatepicker(target);
  6185. } else {
  6186. this._enableDatepicker(target);
  6187. }
  6188. }
  6189. this._attachments($(target), inst);
  6190. this._autoSize(inst);
  6191. this._setDate(inst, date);
  6192. this._updateAlternate(inst);
  6193. this._updateDatepicker(inst);
  6194. }
  6195. },
  6196. // change method deprecated
  6197. _changeDatepicker: function(target, name, value) {
  6198. this._optionDatepicker(target, name, value);
  6199. },
  6200. /* Redraw the date picker attached to an input field or division.
  6201. * @param target element - the target input field or division or span
  6202. */
  6203. _refreshDatepicker: function(target) {
  6204. var inst = this._getInst(target);
  6205. if (inst) {
  6206. this._updateDatepicker(inst);
  6207. }
  6208. },
  6209. /* Set the dates for a jQuery selection.
  6210. * @param target element - the target input field or division or span
  6211. * @param date Date - the new date
  6212. */
  6213. _setDateDatepicker: function(target, date) {
  6214. var inst = this._getInst(target);
  6215. if (inst) {
  6216. this._setDate(inst, date);
  6217. this._updateDatepicker(inst);
  6218. this._updateAlternate(inst);
  6219. }
  6220. },
  6221. /* Get the date(s) for the first entry in a jQuery selection.
  6222. * @param target element - the target input field or division or span
  6223. * @param noDefault boolean - true if no default date is to be used
  6224. * @return Date - the current date
  6225. */
  6226. _getDateDatepicker: function(target, noDefault) {
  6227. var inst = this._getInst(target);
  6228. if (inst && !inst.inline) {
  6229. this._setDateFromField(inst, noDefault);
  6230. }
  6231. return (inst ? this._getDate(inst) : null);
  6232. },
  6233. /* Handle keystrokes. */
  6234. _doKeyDown: function(event) {
  6235. var onSelect, dateStr, sel,
  6236. inst = $.datepicker._getInst(event.target),
  6237. handled = true,
  6238. isRTL = inst.dpDiv.is(".ui-datepicker-rtl");
  6239. inst._keyEvent = true;
  6240. if ($.datepicker._datepickerShowing) {
  6241. switch (event.keyCode) {
  6242. case 9: $.datepicker._hideDatepicker();
  6243. handled = false;
  6244. break; // hide on tab out
  6245. case 13: sel = $("td." + $.datepicker._dayOverClass + ":not(." +
  6246. $.datepicker._currentClass + ")", inst.dpDiv);
  6247. if (sel[0]) {
  6248. $.datepicker._selectDay(event.target, inst.selectedMonth, inst.selectedYear, sel[0]);
  6249. }
  6250. onSelect = $.datepicker._get(inst, "onSelect");
  6251. if (onSelect) {
  6252. dateStr = $.datepicker._formatDate(inst);
  6253. // trigger custom callback
  6254. onSelect.apply((inst.input ? inst.input[0] : null), [dateStr, inst]);
  6255. } else {
  6256. $.datepicker._hideDatepicker();
  6257. }
  6258. return false; // don't submit the form
  6259. case 27: $.datepicker._hideDatepicker();
  6260. break; // hide on escape
  6261. case 33: $.datepicker._adjustDate(event.target, (event.ctrlKey ?
  6262. -$.datepicker._get(inst, "stepBigMonths") :
  6263. -$.datepicker._get(inst, "stepMonths")), "M");
  6264. break; // previous month/year on page up/+ ctrl
  6265. case 34: $.datepicker._adjustDate(event.target, (event.ctrlKey ?
  6266. +$.datepicker._get(inst, "stepBigMonths") :
  6267. +$.datepicker._get(inst, "stepMonths")), "M");
  6268. break; // next month/year on page down/+ ctrl
  6269. case 35: if (event.ctrlKey || event.metaKey) {
  6270. $.datepicker._clearDate(event.target);
  6271. }
  6272. handled = event.ctrlKey || event.metaKey;
  6273. break; // clear on ctrl or command +end
  6274. case 36: if (event.ctrlKey || event.metaKey) {
  6275. $.datepicker._gotoToday(event.target);
  6276. }
  6277. handled = event.ctrlKey || event.metaKey;
  6278. break; // current on ctrl or command +home
  6279. case 37: if (event.ctrlKey || event.metaKey) {
  6280. $.datepicker._adjustDate(event.target, (isRTL ? +1 : -1), "D");
  6281. }
  6282. handled = event.ctrlKey || event.metaKey;
  6283. // -1 day on ctrl or command +left
  6284. if (event.originalEvent.altKey) {
  6285. $.datepicker._adjustDate(event.target, (event.ctrlKey ?
  6286. -$.datepicker._get(inst, "stepBigMonths") :
  6287. -$.datepicker._get(inst, "stepMonths")), "M");
  6288. }
  6289. // next month/year on alt +left on Mac
  6290. break;
  6291. case 38: if (event.ctrlKey || event.metaKey) {
  6292. $.datepicker._adjustDate(event.target, -7, "D");
  6293. }
  6294. handled = event.ctrlKey || event.metaKey;
  6295. break; // -1 week on ctrl or command +up
  6296. case 39: if (event.ctrlKey || event.metaKey) {
  6297. $.datepicker._adjustDate(event.target, (isRTL ? -1 : +1), "D");
  6298. }
  6299. handled = event.ctrlKey || event.metaKey;
  6300. // +1 day on ctrl or command +right
  6301. if (event.originalEvent.altKey) {
  6302. $.datepicker._adjustDate(event.target, (event.ctrlKey ?
  6303. +$.datepicker._get(inst, "stepBigMonths") :
  6304. +$.datepicker._get(inst, "stepMonths")), "M");
  6305. }
  6306. // next month/year on alt +right
  6307. break;
  6308. case 40: if (event.ctrlKey || event.metaKey) {
  6309. $.datepicker._adjustDate(event.target, +7, "D");
  6310. }
  6311. handled = event.ctrlKey || event.metaKey;
  6312. break; // +1 week on ctrl or command +down
  6313. default: handled = false;
  6314. }
  6315. } else if (event.keyCode === 36 && event.ctrlKey) { // display the date picker on ctrl+home
  6316. $.datepicker._showDatepicker(this);
  6317. } else {
  6318. handled = false;
  6319. }
  6320. if (handled) {
  6321. event.preventDefault();
  6322. event.stopPropagation();
  6323. }
  6324. },
  6325. /* Filter entered characters - based on date format. */
  6326. _doKeyPress: function(event) {
  6327. var chars, chr,
  6328. inst = $.datepicker._getInst(event.target);
  6329. if ($.datepicker._get(inst, "constrainInput")) {
  6330. chars = $.datepicker._possibleChars($.datepicker._get(inst, "dateFormat"));
  6331. chr = String.fromCharCode(event.charCode == null ? event.keyCode : event.charCode);
  6332. return event.ctrlKey || event.metaKey || (chr < " " || !chars || chars.indexOf(chr) > -1);
  6333. }
  6334. },
  6335. /* Synchronise manual entry and field/alternate field. */
  6336. _doKeyUp: function(event) {
  6337. var date,
  6338. inst = $.datepicker._getInst(event.target);
  6339. if (inst.input.val() !== inst.lastVal) {
  6340. try {
  6341. date = $.datepicker.parseDate($.datepicker._get(inst, "dateFormat"),
  6342. (inst.input ? inst.input.val() : null),
  6343. $.datepicker._getFormatConfig(inst));
  6344. if (date) { // only if valid
  6345. $.datepicker._setDateFromField(inst);
  6346. $.datepicker._updateAlternate(inst);
  6347. $.datepicker._updateDatepicker(inst);
  6348. }
  6349. }
  6350. catch (err) {
  6351. }
  6352. }
  6353. return true;
  6354. },
  6355. /* Pop-up the date picker for a given input field.
  6356. * If false returned from beforeShow event handler do not show.
  6357. * @param input element - the input field attached to the date picker or
  6358. * event - if triggered by focus
  6359. */
  6360. _showDatepicker: function(input) {
  6361. input = input.target || input;
  6362. if (input.nodeName.toLowerCase() !== "input") { // find from button/image trigger
  6363. input = $("input", input.parentNode)[0];
  6364. }
  6365. if ($.datepicker._isDisabledDatepicker(input) || $.datepicker._lastInput === input) { // already here
  6366. return;
  6367. }
  6368. var inst, beforeShow, beforeShowSettings, isFixed,
  6369. offset, showAnim, duration;
  6370. inst = $.datepicker._getInst(input);
  6371. if ($.datepicker._curInst && $.datepicker._curInst !== inst) {
  6372. $.datepicker._curInst.dpDiv.stop(true, true);
  6373. if ( inst && $.datepicker._datepickerShowing ) {
  6374. $.datepicker._hideDatepicker( $.datepicker._curInst.input[0] );
  6375. }
  6376. }
  6377. beforeShow = $.datepicker._get(inst, "beforeShow");
  6378. beforeShowSettings = beforeShow ? beforeShow.apply(input, [input, inst]) : {};
  6379. if(beforeShowSettings === false){
  6380. return;
  6381. }
  6382. extendRemove(inst.settings, beforeShowSettings);
  6383. inst.lastVal = null;
  6384. $.datepicker._lastInput = input;
  6385. $.datepicker._setDateFromField(inst);
  6386. if ($.datepicker._inDialog) { // hide cursor
  6387. input.value = "";
  6388. }
  6389. if (!$.datepicker._pos) { // position below input
  6390. $.datepicker._pos = $.datepicker._findPos(input);
  6391. $.datepicker._pos[1] += input.offsetHeight; // add the height
  6392. }
  6393. isFixed = false;
  6394. $(input).parents().each(function() {
  6395. isFixed |= $(this).css("position") === "fixed";
  6396. return !isFixed;
  6397. });
  6398. offset = {left: $.datepicker._pos[0], top: $.datepicker._pos[1]};
  6399. $.datepicker._pos = null;
  6400. //to avoid flashes on Firefox
  6401. inst.dpDiv.empty();
  6402. // determine sizing offscreen
  6403. inst.dpDiv.css({position: "absolute", display: "block", top: "-1000px"});
  6404. $.datepicker._updateDatepicker(inst);
  6405. // fix width for dynamic number of date pickers
  6406. // and adjust position before showing
  6407. offset = $.datepicker._checkOffset(inst, offset, isFixed);
  6408. inst.dpDiv.css({position: ($.datepicker._inDialog && $.blockUI ?
  6409. "static" : (isFixed ? "fixed" : "absolute")), display: "none",
  6410. left: offset.left + "px", top: offset.top + "px"});
  6411. if (!inst.inline) {
  6412. showAnim = $.datepicker._get(inst, "showAnim");
  6413. duration = $.datepicker._get(inst, "duration");
  6414. inst.dpDiv.zIndex($(input).zIndex()+1);
  6415. $.datepicker._datepickerShowing = true;
  6416. if ( $.effects && $.effects.effect[ showAnim ] ) {
  6417. inst.dpDiv.show(showAnim, $.datepicker._get(inst, "showOptions"), duration);
  6418. } else {
  6419. inst.dpDiv[showAnim || "show"](showAnim ? duration : null);
  6420. }
  6421. if ( $.datepicker._shouldFocusInput( inst ) ) {
  6422. inst.input.focus();
  6423. }
  6424. $.datepicker._curInst = inst;
  6425. }
  6426. },
  6427. /* Generate the date picker content. */
  6428. _updateDatepicker: function(inst) {
  6429. this.maxRows = 4; //Reset the max number of rows being displayed (see #7043)
  6430. instActive = inst; // for delegate hover events
  6431. inst.dpDiv.empty().append(this._generateHTML(inst));
  6432. this._attachHandlers(inst);
  6433. inst.dpDiv.find("." + this._dayOverClass + " a").mouseover();
  6434. var origyearshtml,
  6435. numMonths = this._getNumberOfMonths(inst),
  6436. cols = numMonths[1],
  6437. width = 17;
  6438. inst.dpDiv.removeClass("ui-datepicker-multi-2 ui-datepicker-multi-3 ui-datepicker-multi-4").width("");
  6439. if (cols > 1) {
  6440. inst.dpDiv.addClass("ui-datepicker-multi-" + cols).css("width", (width * cols) + "em");
  6441. }
  6442. inst.dpDiv[(numMonths[0] !== 1 || numMonths[1] !== 1 ? "add" : "remove") +
  6443. "Class"]("ui-datepicker-multi");
  6444. inst.dpDiv[(this._get(inst, "isRTL") ? "add" : "remove") +
  6445. "Class"]("ui-datepicker-rtl");
  6446. if (inst === $.datepicker._curInst && $.datepicker._datepickerShowing && $.datepicker._shouldFocusInput( inst ) ) {
  6447. inst.input.focus();
  6448. }
  6449. // deffered render of the years select (to avoid flashes on Firefox)
  6450. if( inst.yearshtml ){
  6451. origyearshtml = inst.yearshtml;
  6452. setTimeout(function(){
  6453. //assure that inst.yearshtml didn't change.
  6454. if( origyearshtml === inst.yearshtml && inst.yearshtml ){
  6455. inst.dpDiv.find("select.ui-datepicker-year:first").replaceWith(inst.yearshtml);
  6456. }
  6457. origyearshtml = inst.yearshtml = null;
  6458. }, 0);
  6459. }
  6460. },
  6461. // #6694 - don't focus the input if it's already focused
  6462. // this breaks the change event in IE
  6463. // Support: IE and jQuery <1.9
  6464. _shouldFocusInput: function( inst ) {
  6465. return inst.input && inst.input.is( ":visible" ) && !inst.input.is( ":disabled" ) && !inst.input.is( ":focus" );
  6466. },
  6467. /* Check positioning to remain on screen. */
  6468. _checkOffset: function(inst, offset, isFixed) {
  6469. var dpWidth = inst.dpDiv.outerWidth(),
  6470. dpHeight = inst.dpDiv.outerHeight(),
  6471. inputWidth = inst.input ? inst.input.outerWidth() : 0,
  6472. inputHeight = inst.input ? inst.input.outerHeight() : 0,
  6473. viewWidth = document.documentElement.clientWidth + (isFixed ? 0 : $(document).scrollLeft()),
  6474. viewHeight = document.documentElement.clientHeight + (isFixed ? 0 : $(document).scrollTop());
  6475. offset.left -= (this._get(inst, "isRTL") ? (dpWidth - inputWidth) : 0);
  6476. offset.left -= (isFixed && offset.left === inst.input.offset().left) ? $(document).scrollLeft() : 0;
  6477. offset.top -= (isFixed && offset.top === (inst.input.offset().top + inputHeight)) ? $(document).scrollTop() : 0;
  6478. // now check if datepicker is showing outside window viewport - move to a better place if so.
  6479. offset.left -= Math.min(offset.left, (offset.left + dpWidth > viewWidth && viewWidth > dpWidth) ?
  6480. Math.abs(offset.left + dpWidth - viewWidth) : 0);
  6481. offset.top -= Math.min(offset.top, (offset.top + dpHeight > viewHeight && viewHeight > dpHeight) ?
  6482. Math.abs(dpHeight + inputHeight) : 0);
  6483. return offset;
  6484. },
  6485. /* Find an object's position on the screen. */
  6486. _findPos: function(obj) {
  6487. var position,
  6488. inst = this._getInst(obj),
  6489. isRTL = this._get(inst, "isRTL");
  6490. while (obj && (obj.type === "hidden" || obj.nodeType !== 1 || $.expr.filters.hidden(obj))) {
  6491. obj = obj[isRTL ? "previousSibling" : "nextSibling"];
  6492. }
  6493. position = $(obj).offset();
  6494. return [position.left, position.top];
  6495. },
  6496. /* Hide the date picker from view.
  6497. * @param input element - the input field attached to the date picker
  6498. */
  6499. _hideDatepicker: function(input) {
  6500. var showAnim, duration, postProcess, onClose,
  6501. inst = this._curInst;
  6502. if (!inst || (input && inst !== $.data(input, PROP_NAME))) {
  6503. return;
  6504. }
  6505. if (this._datepickerShowing) {
  6506. showAnim = this._get(inst, "showAnim");
  6507. duration = this._get(inst, "duration");
  6508. postProcess = function() {
  6509. $.datepicker._tidyDialog(inst);
  6510. };
  6511. // DEPRECATED: after BC for 1.8.x $.effects[ showAnim ] is not needed
  6512. if ( $.effects && ( $.effects.effect[ showAnim ] || $.effects[ showAnim ] ) ) {
  6513. inst.dpDiv.hide(showAnim, $.datepicker._get(inst, "showOptions"), duration, postProcess);
  6514. } else {
  6515. inst.dpDiv[(showAnim === "slideDown" ? "slideUp" :
  6516. (showAnim === "fadeIn" ? "fadeOut" : "hide"))]((showAnim ? duration : null), postProcess);
  6517. }
  6518. if (!showAnim) {
  6519. postProcess();
  6520. }
  6521. this._datepickerShowing = false;
  6522. onClose = this._get(inst, "onClose");
  6523. if (onClose) {
  6524. onClose.apply((inst.input ? inst.input[0] : null), [(inst.input ? inst.input.val() : ""), inst]);
  6525. }
  6526. this._lastInput = null;
  6527. if (this._inDialog) {
  6528. this._dialogInput.css({ position: "absolute", left: "0", top: "-100px" });
  6529. if ($.blockUI) {
  6530. $.unblockUI();
  6531. $("body").append(this.dpDiv);
  6532. }
  6533. }
  6534. this._inDialog = false;
  6535. }
  6536. },
  6537. /* Tidy up after a dialog display. */
  6538. _tidyDialog: function(inst) {
  6539. inst.dpDiv.removeClass(this._dialogClass).unbind(".ui-datepicker-calendar");
  6540. },
  6541. /* Close date picker if clicked elsewhere. */
  6542. _checkExternalClick: function(event) {
  6543. if (!$.datepicker._curInst) {
  6544. return;
  6545. }
  6546. var $target = $(event.target),
  6547. inst = $.datepicker._getInst($target[0]);
  6548. if ( ( ( $target[0].id !== $.datepicker._mainDivId &&
  6549. $target.parents("#" + $.datepicker._mainDivId).length === 0 &&
  6550. !$target.hasClass($.datepicker.markerClassName) &&
  6551. !$target.closest("." + $.datepicker._triggerClass).length &&
  6552. $.datepicker._datepickerShowing && !($.datepicker._inDialog && $.blockUI) ) ) ||
  6553. ( $target.hasClass($.datepicker.markerClassName) && $.datepicker._curInst !== inst ) ) {
  6554. $.datepicker._hideDatepicker();
  6555. }
  6556. },
  6557. /* Adjust one of the date sub-fields. */
  6558. _adjustDate: function(id, offset, period) {
  6559. var target = $(id),
  6560. inst = this._getInst(target[0]);
  6561. if (this._isDisabledDatepicker(target[0])) {
  6562. return;
  6563. }
  6564. this._adjustInstDate(inst, offset +
  6565. (period === "M" ? this._get(inst, "showCurrentAtPos") : 0), // undo positioning
  6566. period);
  6567. this._updateDatepicker(inst);
  6568. },
  6569. /* Action for current link. */
  6570. _gotoToday: function(id) {
  6571. var date,
  6572. target = $(id),
  6573. inst = this._getInst(target[0]);
  6574. if (this._get(inst, "gotoCurrent") && inst.currentDay) {
  6575. inst.selectedDay = inst.currentDay;
  6576. inst.drawMonth = inst.selectedMonth = inst.currentMonth;
  6577. inst.drawYear = inst.selectedYear = inst.currentYear;
  6578. } else {
  6579. date = new Date();
  6580. inst.selectedDay = date.getDate();
  6581. inst.drawMonth = inst.selectedMonth = date.getMonth();
  6582. inst.drawYear = inst.selectedYear = date.getFullYear();
  6583. }
  6584. this._notifyChange(inst);
  6585. this._adjustDate(target);
  6586. },
  6587. /* Action for selecting a new month/year. */
  6588. _selectMonthYear: function(id, select, period) {
  6589. var target = $(id),
  6590. inst = this._getInst(target[0]);
  6591. inst["selected" + (period === "M" ? "Month" : "Year")] =
  6592. inst["draw" + (period === "M" ? "Month" : "Year")] =
  6593. parseInt(select.options[select.selectedIndex].value,10);
  6594. this._notifyChange(inst);
  6595. this._adjustDate(target);
  6596. },
  6597. /* Action for selecting a day. */
  6598. _selectDay: function(id, month, year, td) {
  6599. var inst,
  6600. target = $(id);
  6601. if ($(td).hasClass(this._unselectableClass) || this._isDisabledDatepicker(target[0])) {
  6602. return;
  6603. }
  6604. inst = this._getInst(target[0]);
  6605. inst.selectedDay = inst.currentDay = $("a", td).html();
  6606. inst.selectedMonth = inst.currentMonth = month;
  6607. inst.selectedYear = inst.currentYear = year;
  6608. this._selectDate(id, this._formatDate(inst,
  6609. inst.currentDay, inst.currentMonth, inst.currentYear));
  6610. },
  6611. /* Erase the input field and hide the date picker. */
  6612. _clearDate: function(id) {
  6613. var target = $(id);
  6614. this._selectDate(target, "");
  6615. },
  6616. /* Update the input field with the selected date. */
  6617. _selectDate: function(id, dateStr) {
  6618. var onSelect,
  6619. target = $(id),
  6620. inst = this._getInst(target[0]);
  6621. dateStr = (dateStr != null ? dateStr : this._formatDate(inst));
  6622. if (inst.input) {
  6623. inst.input.val(dateStr);
  6624. }
  6625. this._updateAlternate(inst);
  6626. onSelect = this._get(inst, "onSelect");
  6627. if (onSelect) {
  6628. onSelect.apply((inst.input ? inst.input[0] : null), [dateStr, inst]); // trigger custom callback
  6629. } else if (inst.input) {
  6630. inst.input.trigger("change"); // fire the change event
  6631. }
  6632. if (inst.inline){
  6633. this._updateDatepicker(inst);
  6634. } else {
  6635. this._hideDatepicker();
  6636. this._lastInput = inst.input[0];
  6637. if (typeof(inst.input[0]) !== "object") {
  6638. inst.input.focus(); // restore focus
  6639. }
  6640. this._lastInput = null;
  6641. }
  6642. },
  6643. /* Update any alternate field to synchronise with the main field. */
  6644. _updateAlternate: function(inst) {
  6645. var altFormat, date, dateStr,
  6646. altField = this._get(inst, "altField");
  6647. if (altField) { // update alternate field too
  6648. altFormat = this._get(inst, "altFormat") || this._get(inst, "dateFormat");
  6649. date = this._getDate(inst);
  6650. dateStr = this.formatDate(altFormat, date, this._getFormatConfig(inst));
  6651. $(altField).each(function() { $(this).val(dateStr); });
  6652. }
  6653. },
  6654. /* Set as beforeShowDay function to prevent selection of weekends.
  6655. * @param date Date - the date to customise
  6656. * @return [boolean, string] - is this date selectable?, what is its CSS class?
  6657. */
  6658. noWeekends: function(date) {
  6659. var day = date.getDay();
  6660. return [(day > 0 && day < 6), ""];
  6661. },
  6662. /* Set as calculateWeek to determine the week of the year based on the ISO 8601 definition.
  6663. * @param date Date - the date to get the week for
  6664. * @return number - the number of the week within the year that contains this date
  6665. */
  6666. iso8601Week: function(date) {
  6667. var time,
  6668. checkDate = new Date(date.getTime());
  6669. // Find Thursday of this week starting on Monday
  6670. checkDate.setDate(checkDate.getDate() + 4 - (checkDate.getDay() || 7));
  6671. time = checkDate.getTime();
  6672. checkDate.setMonth(0); // Compare with Jan 1
  6673. checkDate.setDate(1);
  6674. return Math.floor(Math.round((time - checkDate) / 86400000) / 7) + 1;
  6675. },
  6676. /* Parse a string value into a date object.
  6677. * See formatDate below for the possible formats.
  6678. *
  6679. * @param format string - the expected format of the date
  6680. * @param value string - the date in the above format
  6681. * @param settings Object - attributes include:
  6682. * shortYearCutoff number - the cutoff year for determining the century (optional)
  6683. * dayNamesShort string[7] - abbreviated names of the days from Sunday (optional)
  6684. * dayNames string[7] - names of the days from Sunday (optional)
  6685. * monthNamesShort string[12] - abbreviated names of the months (optional)
  6686. * monthNames string[12] - names of the months (optional)
  6687. * @return Date - the extracted date value or null if value is blank
  6688. */
  6689. parseDate: function (format, value, settings) {
  6690. if (format == null || value == null) {
  6691. throw "Invalid arguments";
  6692. }
  6693. value = (typeof value === "object" ? value.toString() : value + "");
  6694. if (value === "") {
  6695. return null;
  6696. }
  6697. var iFormat, dim, extra,
  6698. iValue = 0,
  6699. shortYearCutoffTemp = (settings ? settings.shortYearCutoff : null) || this._defaults.shortYearCutoff,
  6700. shortYearCutoff = (typeof shortYearCutoffTemp !== "string" ? shortYearCutoffTemp :
  6701. new Date().getFullYear() % 100 + parseInt(shortYearCutoffTemp, 10)),
  6702. dayNamesShort = (settings ? settings.dayNamesShort : null) || this._defaults.dayNamesShort,
  6703. dayNames = (settings ? settings.dayNames : null) || this._defaults.dayNames,
  6704. monthNamesShort = (settings ? settings.monthNamesShort : null) || this._defaults.monthNamesShort,
  6705. monthNames = (settings ? settings.monthNames : null) || this._defaults.monthNames,
  6706. year = -1,
  6707. month = -1,
  6708. day = -1,
  6709. doy = -1,
  6710. literal = false,
  6711. date,
  6712. // Check whether a format character is doubled
  6713. lookAhead = function(match) {
  6714. var matches = (iFormat + 1 < format.length && format.charAt(iFormat + 1) === match);
  6715. if (matches) {
  6716. iFormat++;
  6717. }
  6718. return matches;
  6719. },
  6720. // Extract a number from the string value
  6721. getNumber = function(match) {
  6722. var isDoubled = lookAhead(match),
  6723. size = (match === "@" ? 14 : (match === "!" ? 20 :
  6724. (match === "y" && isDoubled ? 4 : (match === "o" ? 3 : 2)))),
  6725. digits = new RegExp("^\\d{1," + size + "}"),
  6726. num = value.substring(iValue).match(digits);
  6727. if (!num) {
  6728. throw "Missing number at position " + iValue;
  6729. }
  6730. iValue += num[0].length;
  6731. return parseInt(num[0], 10);
  6732. },
  6733. // Extract a name from the string value and convert to an index
  6734. getName = function(match, shortNames, longNames) {
  6735. var index = -1,
  6736. names = $.map(lookAhead(match) ? longNames : shortNames, function (v, k) {
  6737. return [ [k, v] ];
  6738. }).sort(function (a, b) {
  6739. return -(a[1].length - b[1].length);
  6740. });
  6741. $.each(names, function (i, pair) {
  6742. var name = pair[1];
  6743. if (value.substr(iValue, name.length).toLowerCase() === name.toLowerCase()) {
  6744. index = pair[0];
  6745. iValue += name.length;
  6746. return false;
  6747. }
  6748. });
  6749. if (index !== -1) {
  6750. return index + 1;
  6751. } else {
  6752. throw "Unknown name at position " + iValue;
  6753. }
  6754. },
  6755. // Confirm that a literal character matches the string value
  6756. checkLiteral = function() {
  6757. if (value.charAt(iValue) !== format.charAt(iFormat)) {
  6758. throw "Unexpected literal at position " + iValue;
  6759. }
  6760. iValue++;
  6761. };
  6762. for (iFormat = 0; iFormat < format.length; iFormat++) {
  6763. if (literal) {
  6764. if (format.charAt(iFormat) === "'" && !lookAhead("'")) {
  6765. literal = false;
  6766. } else {
  6767. checkLiteral();
  6768. }
  6769. } else {
  6770. switch (format.charAt(iFormat)) {
  6771. case "d":
  6772. day = getNumber("d");
  6773. break;
  6774. case "D":
  6775. getName("D", dayNamesShort, dayNames);
  6776. break;
  6777. case "o":
  6778. doy = getNumber("o");
  6779. break;
  6780. case "m":
  6781. month = getNumber("m");
  6782. break;
  6783. case "M":
  6784. month = getName("M", monthNamesShort, monthNames);
  6785. break;
  6786. case "y":
  6787. year = getNumber("y");
  6788. break;
  6789. case "@":
  6790. date = new Date(getNumber("@"));
  6791. year = date.getFullYear();
  6792. month = date.getMonth() + 1;
  6793. day = date.getDate();
  6794. break;
  6795. case "!":
  6796. date = new Date((getNumber("!") - this._ticksTo1970) / 10000);
  6797. year = date.getFullYear();
  6798. month = date.getMonth() + 1;
  6799. day = date.getDate();
  6800. break;
  6801. case "'":
  6802. if (lookAhead("'")){
  6803. checkLiteral();
  6804. } else {
  6805. literal = true;
  6806. }
  6807. break;
  6808. default:
  6809. checkLiteral();
  6810. }
  6811. }
  6812. }
  6813. if (iValue < value.length){
  6814. extra = value.substr(iValue);
  6815. if (!/^\s+/.test(extra)) {
  6816. throw "Extra/unparsed characters found in date: " + extra;
  6817. }
  6818. }
  6819. if (year === -1) {
  6820. year = new Date().getFullYear();
  6821. } else if (year < 100) {
  6822. year += new Date().getFullYear() - new Date().getFullYear() % 100 +
  6823. (year <= shortYearCutoff ? 0 : -100);
  6824. }
  6825. if (doy > -1) {
  6826. month = 1;
  6827. day = doy;
  6828. do {
  6829. dim = this._getDaysInMonth(year, month - 1);
  6830. if (day <= dim) {
  6831. break;
  6832. }
  6833. month++;
  6834. day -= dim;
  6835. } while (true);
  6836. }
  6837. date = this._daylightSavingAdjust(new Date(year, month - 1, day));
  6838. if (date.getFullYear() !== year || date.getMonth() + 1 !== month || date.getDate() !== day) {
  6839. throw "Invalid date"; // E.g. 31/02/00
  6840. }
  6841. return date;
  6842. },
  6843. /* Standard date formats. */
  6844. ATOM: "yy-mm-dd", // RFC 3339 (ISO 8601)
  6845. COOKIE: "D, dd M yy",
  6846. ISO_8601: "yy-mm-dd",
  6847. RFC_822: "D, d M y",
  6848. RFC_850: "DD, dd-M-y",
  6849. RFC_1036: "D, d M y",
  6850. RFC_1123: "D, d M yy",
  6851. RFC_2822: "D, d M yy",
  6852. RSS: "D, d M y", // RFC 822
  6853. TICKS: "!",
  6854. TIMESTAMP: "@",
  6855. W3C: "yy-mm-dd", // ISO 8601
  6856. _ticksTo1970: (((1970 - 1) * 365 + Math.floor(1970 / 4) - Math.floor(1970 / 100) +
  6857. Math.floor(1970 / 400)) * 24 * 60 * 60 * 10000000),
  6858. /* Format a date object into a string value.
  6859. * The format can be combinations of the following:
  6860. * d - day of month (no leading zero)
  6861. * dd - day of month (two digit)
  6862. * o - day of year (no leading zeros)
  6863. * oo - day of year (three digit)
  6864. * D - day name short
  6865. * DD - day name long
  6866. * m - month of year (no leading zero)
  6867. * mm - month of year (two digit)
  6868. * M - month name short
  6869. * MM - month name long
  6870. * y - year (two digit)
  6871. * yy - year (four digit)
  6872. * @ - Unix timestamp (ms since 01/01/1970)
  6873. * ! - Windows ticks (100ns since 01/01/0001)
  6874. * "..." - literal text
  6875. * '' - single quote
  6876. *
  6877. * @param format string - the desired format of the date
  6878. * @param date Date - the date value to format
  6879. * @param settings Object - attributes include:
  6880. * dayNamesShort string[7] - abbreviated names of the days from Sunday (optional)
  6881. * dayNames string[7] - names of the days from Sunday (optional)
  6882. * monthNamesShort string[12] - abbreviated names of the months (optional)
  6883. * monthNames string[12] - names of the months (optional)
  6884. * @return string - the date in the above format
  6885. */
  6886. formatDate: function (format, date, settings) {
  6887. if (!date) {
  6888. return "";
  6889. }
  6890. var iFormat,
  6891. dayNamesShort = (settings ? settings.dayNamesShort : null) || this._defaults.dayNamesShort,
  6892. dayNames = (settings ? settings.dayNames : null) || this._defaults.dayNames,
  6893. monthNamesShort = (settings ? settings.monthNamesShort : null) || this._defaults.monthNamesShort,
  6894. monthNames = (settings ? settings.monthNames : null) || this._defaults.monthNames,
  6895. // Check whether a format character is doubled
  6896. lookAhead = function(match) {
  6897. var matches = (iFormat + 1 < format.length && format.charAt(iFormat + 1) === match);
  6898. if (matches) {
  6899. iFormat++;
  6900. }
  6901. return matches;
  6902. },
  6903. // Format a number, with leading zero if necessary
  6904. formatNumber = function(match, value, len) {
  6905. var num = "" + value;
  6906. if (lookAhead(match)) {
  6907. while (num.length < len) {
  6908. num = "0" + num;
  6909. }
  6910. }
  6911. return num;
  6912. },
  6913. // Format a name, short or long as requested
  6914. formatName = function(match, value, shortNames, longNames) {
  6915. return (lookAhead(match) ? longNames[value] : shortNames[value]);
  6916. },
  6917. output = "",
  6918. literal = false;
  6919. if (date) {
  6920. for (iFormat = 0; iFormat < format.length; iFormat++) {
  6921. if (literal) {
  6922. if (format.charAt(iFormat) === "'" && !lookAhead("'")) {
  6923. literal = false;
  6924. } else {
  6925. output += format.charAt(iFormat);
  6926. }
  6927. } else {
  6928. switch (format.charAt(iFormat)) {
  6929. case "d":
  6930. output += formatNumber("d", date.getDate(), 2);
  6931. break;
  6932. case "D":
  6933. output += formatName("D", date.getDay(), dayNamesShort, dayNames);
  6934. break;
  6935. case "o":
  6936. output += formatNumber("o",
  6937. Math.round((new Date(date.getFullYear(), date.getMonth(), date.getDate()).getTime() - new Date(date.getFullYear(), 0, 0).getTime()) / 86400000), 3);
  6938. break;
  6939. case "m":
  6940. output += formatNumber("m", date.getMonth() + 1, 2);
  6941. break;
  6942. case "M":
  6943. output += formatName("M", date.getMonth(), monthNamesShort, monthNames);
  6944. break;
  6945. case "y":
  6946. output += (lookAhead("y") ? date.getFullYear() :
  6947. (date.getYear() % 100 < 10 ? "0" : "") + date.getYear() % 100);
  6948. break;
  6949. case "@":
  6950. output += date.getTime();
  6951. break;
  6952. case "!":
  6953. output += date.getTime() * 10000 + this._ticksTo1970;
  6954. break;
  6955. case "'":
  6956. if (lookAhead("'")) {
  6957. output += "'";
  6958. } else {
  6959. literal = true;
  6960. }
  6961. break;
  6962. default:
  6963. output += format.charAt(iFormat);
  6964. }
  6965. }
  6966. }
  6967. }
  6968. return output;
  6969. },
  6970. /* Extract all possible characters from the date format. */
  6971. _possibleChars: function (format) {
  6972. var iFormat,
  6973. chars = "",
  6974. literal = false,
  6975. // Check whether a format character is doubled
  6976. lookAhead = function(match) {
  6977. var matches = (iFormat + 1 < format.length && format.charAt(iFormat + 1) === match);
  6978. if (matches) {
  6979. iFormat++;
  6980. }
  6981. return matches;
  6982. };
  6983. for (iFormat = 0; iFormat < format.length; iFormat++) {
  6984. if (literal) {
  6985. if (format.charAt(iFormat) === "'" && !lookAhead("'")) {
  6986. literal = false;
  6987. } else {
  6988. chars += format.charAt(iFormat);
  6989. }
  6990. } else {
  6991. switch (format.charAt(iFormat)) {
  6992. case "d": case "m": case "y": case "@":
  6993. chars += "0123456789";
  6994. break;
  6995. case "D": case "M":
  6996. return null; // Accept anything
  6997. case "'":
  6998. if (lookAhead("'")) {
  6999. chars += "'";
  7000. } else {
  7001. literal = true;
  7002. }
  7003. break;
  7004. default:
  7005. chars += format.charAt(iFormat);
  7006. }
  7007. }
  7008. }
  7009. return chars;
  7010. },
  7011. /* Get a setting value, defaulting if necessary. */
  7012. _get: function(inst, name) {
  7013. return inst.settings[name] !== undefined ?
  7014. inst.settings[name] : this._defaults[name];
  7015. },
  7016. /* Parse existing date and initialise date picker. */
  7017. _setDateFromField: function(inst, noDefault) {
  7018. if (inst.input.val() === inst.lastVal) {
  7019. return;
  7020. }
  7021. var dateFormat = this._get(inst, "dateFormat"),
  7022. dates = inst.lastVal = inst.input ? inst.input.val() : null,
  7023. defaultDate = this._getDefaultDate(inst),
  7024. date = defaultDate,
  7025. settings = this._getFormatConfig(inst);
  7026. try {
  7027. date = this.parseDate(dateFormat, dates, settings) || defaultDate;
  7028. } catch (event) {
  7029. dates = (noDefault ? "" : dates);
  7030. }
  7031. inst.selectedDay = date.getDate();
  7032. inst.drawMonth = inst.selectedMonth = date.getMonth();
  7033. inst.drawYear = inst.selectedYear = date.getFullYear();
  7034. inst.currentDay = (dates ? date.getDate() : 0);
  7035. inst.currentMonth = (dates ? date.getMonth() : 0);
  7036. inst.currentYear = (dates ? date.getFullYear() : 0);
  7037. this._adjustInstDate(inst);
  7038. },
  7039. /* Retrieve the default date shown on opening. */
  7040. _getDefaultDate: function(inst) {
  7041. return this._restrictMinMax(inst,
  7042. this._determineDate(inst, this._get(inst, "defaultDate"), new Date()));
  7043. },
  7044. /* A date may be specified as an exact value or a relative one. */
  7045. _determineDate: function(inst, date, defaultDate) {
  7046. var offsetNumeric = function(offset) {
  7047. var date = new Date();
  7048. date.setDate(date.getDate() + offset);
  7049. return date;
  7050. },
  7051. offsetString = function(offset) {
  7052. try {
  7053. return $.datepicker.parseDate($.datepicker._get(inst, "dateFormat"),
  7054. offset, $.datepicker._getFormatConfig(inst));
  7055. }
  7056. catch (e) {
  7057. // Ignore
  7058. }
  7059. var date = (offset.toLowerCase().match(/^c/) ?
  7060. $.datepicker._getDate(inst) : null) || new Date(),
  7061. year = date.getFullYear(),
  7062. month = date.getMonth(),
  7063. day = date.getDate(),
  7064. pattern = /([+\-]?[0-9]+)\s*(d|D|w|W|m|M|y|Y)?/g,
  7065. matches = pattern.exec(offset);
  7066. while (matches) {
  7067. switch (matches[2] || "d") {
  7068. case "d" : case "D" :
  7069. day += parseInt(matches[1],10); break;
  7070. case "w" : case "W" :
  7071. day += parseInt(matches[1],10) * 7; break;
  7072. case "m" : case "M" :
  7073. month += parseInt(matches[1],10);
  7074. day = Math.min(day, $.datepicker._getDaysInMonth(year, month));
  7075. break;
  7076. case "y": case "Y" :
  7077. year += parseInt(matches[1],10);
  7078. day = Math.min(day, $.datepicker._getDaysInMonth(year, month));
  7079. break;
  7080. }
  7081. matches = pattern.exec(offset);
  7082. }
  7083. return new Date(year, month, day);
  7084. },
  7085. newDate = (date == null || date === "" ? defaultDate : (typeof date === "string" ? offsetString(date) :
  7086. (typeof date === "number" ? (isNaN(date) ? defaultDate : offsetNumeric(date)) : new Date(date.getTime()))));
  7087. newDate = (newDate && newDate.toString() === "Invalid Date" ? defaultDate : newDate);
  7088. if (newDate) {
  7089. newDate.setHours(0);
  7090. newDate.setMinutes(0);
  7091. newDate.setSeconds(0);
  7092. newDate.setMilliseconds(0);
  7093. }
  7094. return this._daylightSavingAdjust(newDate);
  7095. },
  7096. /* Handle switch to/from daylight saving.
  7097. * Hours may be non-zero on daylight saving cut-over:
  7098. * > 12 when midnight changeover, but then cannot generate
  7099. * midnight datetime, so jump to 1AM, otherwise reset.
  7100. * @param date (Date) the date to check
  7101. * @return (Date) the corrected date
  7102. */
  7103. _daylightSavingAdjust: function(date) {
  7104. if (!date) {
  7105. return null;
  7106. }
  7107. date.setHours(date.getHours() > 12 ? date.getHours() + 2 : 0);
  7108. return date;
  7109. },
  7110. /* Set the date(s) directly. */
  7111. _setDate: function(inst, date, noChange) {
  7112. var clear = !date,
  7113. origMonth = inst.selectedMonth,
  7114. origYear = inst.selectedYear,
  7115. newDate = this._restrictMinMax(inst, this._determineDate(inst, date, new Date()));
  7116. inst.selectedDay = inst.currentDay = newDate.getDate();
  7117. inst.drawMonth = inst.selectedMonth = inst.currentMonth = newDate.getMonth();
  7118. inst.drawYear = inst.selectedYear = inst.currentYear = newDate.getFullYear();
  7119. if ((origMonth !== inst.selectedMonth || origYear !== inst.selectedYear) && !noChange) {
  7120. this._notifyChange(inst);
  7121. }
  7122. this._adjustInstDate(inst);
  7123. if (inst.input) {
  7124. inst.input.val(clear ? "" : this._formatDate(inst));
  7125. }
  7126. },
  7127. /* Retrieve the date(s) directly. */
  7128. _getDate: function(inst) {
  7129. var startDate = (!inst.currentYear || (inst.input && inst.input.val() === "") ? null :
  7130. this._daylightSavingAdjust(new Date(
  7131. inst.currentYear, inst.currentMonth, inst.currentDay)));
  7132. return startDate;
  7133. },
  7134. /* Attach the onxxx handlers. These are declared statically so
  7135. * they work with static code transformers like Caja.
  7136. */
  7137. _attachHandlers: function(inst) {
  7138. var stepMonths = this._get(inst, "stepMonths"),
  7139. id = "#" + inst.id.replace( /\\\\/g, "\\" );
  7140. inst.dpDiv.find("[data-handler]").map(function () {
  7141. var handler = {
  7142. prev: function () {
  7143. $.datepicker._adjustDate(id, -stepMonths, "M");
  7144. },
  7145. next: function () {
  7146. $.datepicker._adjustDate(id, +stepMonths, "M");
  7147. },
  7148. hide: function () {
  7149. $.datepicker._hideDatepicker();
  7150. },
  7151. today: function () {
  7152. $.datepicker._gotoToday(id);
  7153. },
  7154. selectDay: function () {
  7155. $.datepicker._selectDay(id, +this.getAttribute("data-month"), +this.getAttribute("data-year"), this);
  7156. return false;
  7157. },
  7158. selectMonth: function () {
  7159. $.datepicker._selectMonthYear(id, this, "M");
  7160. return false;
  7161. },
  7162. selectYear: function () {
  7163. $.datepicker._selectMonthYear(id, this, "Y");
  7164. return false;
  7165. }
  7166. };
  7167. $(this).bind(this.getAttribute("data-event"), handler[this.getAttribute("data-handler")]);
  7168. });
  7169. },
  7170. /* Generate the HTML for the current state of the date picker. */
  7171. _generateHTML: function(inst) {
  7172. var maxDraw, prevText, prev, nextText, next, currentText, gotoDate,
  7173. controls, buttonPanel, firstDay, showWeek, dayNames, dayNamesMin,
  7174. monthNames, monthNamesShort, beforeShowDay, showOtherMonths,
  7175. selectOtherMonths, defaultDate, html, dow, row, group, col, selectedDate,
  7176. cornerClass, calender, thead, day, daysInMonth, leadDays, curRows, numRows,
  7177. printDate, dRow, tbody, daySettings, otherMonth, unselectable,
  7178. tempDate = new Date(),
  7179. today = this._daylightSavingAdjust(
  7180. new Date(tempDate.getFullYear(), tempDate.getMonth(), tempDate.getDate())), // clear time
  7181. isRTL = this._get(inst, "isRTL"),
  7182. showButtonPanel = this._get(inst, "showButtonPanel"),
  7183. hideIfNoPrevNext = this._get(inst, "hideIfNoPrevNext"),
  7184. navigationAsDateFormat = this._get(inst, "navigationAsDateFormat"),
  7185. numMonths = this._getNumberOfMonths(inst),
  7186. showCurrentAtPos = this._get(inst, "showCurrentAtPos"),
  7187. stepMonths = this._get(inst, "stepMonths"),
  7188. isMultiMonth = (numMonths[0] !== 1 || numMonths[1] !== 1),
  7189. currentDate = this._daylightSavingAdjust((!inst.currentDay ? new Date(9999, 9, 9) :
  7190. new Date(inst.currentYear, inst.currentMonth, inst.currentDay))),
  7191. minDate = this._getMinMaxDate(inst, "min"),
  7192. maxDate = this._getMinMaxDate(inst, "max"),
  7193. drawMonth = inst.drawMonth - showCurrentAtPos,
  7194. drawYear = inst.drawYear;
  7195. if (drawMonth < 0) {
  7196. drawMonth += 12;
  7197. drawYear--;
  7198. }
  7199. if (maxDate) {
  7200. maxDraw = this._daylightSavingAdjust(new Date(maxDate.getFullYear(),
  7201. maxDate.getMonth() - (numMonths[0] * numMonths[1]) + 1, maxDate.getDate()));
  7202. maxDraw = (minDate && maxDraw < minDate ? minDate : maxDraw);
  7203. while (this._daylightSavingAdjust(new Date(drawYear, drawMonth, 1)) > maxDraw) {
  7204. drawMonth--;
  7205. if (drawMonth < 0) {
  7206. drawMonth = 11;
  7207. drawYear--;
  7208. }
  7209. }
  7210. }
  7211. inst.drawMonth = drawMonth;
  7212. inst.drawYear = drawYear;
  7213. prevText = this._get(inst, "prevText");
  7214. prevText = (!navigationAsDateFormat ? prevText : this.formatDate(prevText,
  7215. this._daylightSavingAdjust(new Date(drawYear, drawMonth - stepMonths, 1)),
  7216. this._getFormatConfig(inst)));
  7217. prev = (this._canAdjustMonth(inst, -1, drawYear, drawMonth) ?
  7218. "<a class='ui-datepicker-prev ui-corner-all' data-handler='prev' data-event='click'" +
  7219. " title='" + prevText + "'><span class='ui-icon ui-icon-circle-triangle-" + ( isRTL ? "e" : "w") + "'>" + prevText + "</span></a>" :
  7220. (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>"));
  7221. nextText = this._get(inst, "nextText");
  7222. nextText = (!navigationAsDateFormat ? nextText : this.formatDate(nextText,
  7223. this._daylightSavingAdjust(new Date(drawYear, drawMonth + stepMonths, 1)),
  7224. this._getFormatConfig(inst)));
  7225. next = (this._canAdjustMonth(inst, +1, drawYear, drawMonth) ?
  7226. "<a class='ui-datepicker-next ui-corner-all' data-handler='next' data-event='click'" +
  7227. " title='" + nextText + "'><span class='ui-icon ui-icon-circle-triangle-" + ( isRTL ? "w" : "e") + "'>" + nextText + "</span></a>" :
  7228. (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>"));
  7229. currentText = this._get(inst, "currentText");
  7230. gotoDate = (this._get(inst, "gotoCurrent") && inst.currentDay ? currentDate : today);
  7231. currentText = (!navigationAsDateFormat ? currentText :
  7232. this.formatDate(currentText, gotoDate, this._getFormatConfig(inst)));
  7233. 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'>" +
  7234. this._get(inst, "closeText") + "</button>" : "");
  7235. buttonPanel = (showButtonPanel) ? "<div class='ui-datepicker-buttonpane ui-widget-content'>" + (isRTL ? controls : "") +
  7236. (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'" +
  7237. ">" + currentText + "</button>" : "") + (isRTL ? "" : controls) + "</div>" : "";
  7238. firstDay = parseInt(this._get(inst, "firstDay"),10);
  7239. firstDay = (isNaN(firstDay) ? 0 : firstDay);
  7240. showWeek = this._get(inst, "showWeek");
  7241. dayNames = this._get(inst, "dayNames");
  7242. dayNamesMin = this._get(inst, "dayNamesMin");
  7243. monthNames = this._get(inst, "monthNames");
  7244. monthNamesShort = this._get(inst, "monthNamesShort");
  7245. beforeShowDay = this._get(inst, "beforeShowDay");
  7246. showOtherMonths = this._get(inst, "showOtherMonths");
  7247. selectOtherMonths = this._get(inst, "selectOtherMonths");
  7248. defaultDate = this._getDefaultDate(inst);
  7249. html = "";
  7250. dow;
  7251. for (row = 0; row < numMonths[0]; row++) {
  7252. group = "";
  7253. this.maxRows = 4;
  7254. for (col = 0; col < numMonths[1]; col++) {
  7255. selectedDate = this._daylightSavingAdjust(new Date(drawYear, drawMonth, inst.selectedDay));
  7256. cornerClass = " ui-corner-all";
  7257. calender = "";
  7258. if (isMultiMonth) {
  7259. calender += "<div class='ui-datepicker-group";
  7260. if (numMonths[1] > 1) {
  7261. switch (col) {
  7262. case 0: calender += " ui-datepicker-group-first";
  7263. cornerClass = " ui-corner-" + (isRTL ? "right" : "left"); break;
  7264. case numMonths[1]-1: calender += " ui-datepicker-group-last";
  7265. cornerClass = " ui-corner-" + (isRTL ? "left" : "right"); break;
  7266. default: calender += " ui-datepicker-group-middle"; cornerClass = ""; break;
  7267. }
  7268. }
  7269. calender += "'>";
  7270. }
  7271. calender += "<div class='ui-datepicker-header ui-widget-header ui-helper-clearfix" + cornerClass + "'>" +
  7272. (/all|left/.test(cornerClass) && row === 0 ? (isRTL ? next : prev) : "") +
  7273. (/all|right/.test(cornerClass) && row === 0 ? (isRTL ? prev : next) : "") +
  7274. this._generateMonthYearHeader(inst, drawMonth, drawYear, minDate, maxDate,
  7275. row > 0 || col > 0, monthNames, monthNamesShort) + // draw month headers
  7276. "</div><table class='ui-datepicker-calendar'><thead>" +
  7277. "<tr>";
  7278. thead = (showWeek ? "<th class='ui-datepicker-week-col'>" + this._get(inst, "weekHeader") + "</th>" : "");
  7279. for (dow = 0; dow < 7; dow++) { // days of the week
  7280. day = (dow + firstDay) % 7;
  7281. thead += "<th" + ((dow + firstDay + 6) % 7 >= 5 ? " class='ui-datepicker-week-end'" : "") + ">" +
  7282. "<span title='" + dayNames[day] + "'>" + dayNamesMin[day] + "</span></th>";
  7283. }
  7284. calender += thead + "</tr></thead><tbody>";
  7285. daysInMonth = this._getDaysInMonth(drawYear, drawMonth);
  7286. if (drawYear === inst.selectedYear && drawMonth === inst.selectedMonth) {
  7287. inst.selectedDay = Math.min(inst.selectedDay, daysInMonth);
  7288. }
  7289. leadDays = (this._getFirstDayOfMonth(drawYear, drawMonth) - firstDay + 7) % 7;
  7290. curRows = Math.ceil((leadDays + daysInMonth) / 7); // calculate the number of rows to generate
  7291. numRows = (isMultiMonth ? this.maxRows > curRows ? this.maxRows : curRows : curRows); //If multiple months, use the higher number of rows (see #7043)
  7292. this.maxRows = numRows;
  7293. printDate = this._daylightSavingAdjust(new Date(drawYear, drawMonth, 1 - leadDays));
  7294. for (dRow = 0; dRow < numRows; dRow++) { // create date picker rows
  7295. calender += "<tr>";
  7296. tbody = (!showWeek ? "" : "<td class='ui-datepicker-week-col'>" +
  7297. this._get(inst, "calculateWeek")(printDate) + "</td>");
  7298. for (dow = 0; dow < 7; dow++) { // create date picker days
  7299. daySettings = (beforeShowDay ?
  7300. beforeShowDay.apply((inst.input ? inst.input[0] : null), [printDate]) : [true, ""]);
  7301. otherMonth = (printDate.getMonth() !== drawMonth);
  7302. unselectable = (otherMonth && !selectOtherMonths) || !daySettings[0] ||
  7303. (minDate && printDate < minDate) || (maxDate && printDate > maxDate);
  7304. tbody += "<td class='" +
  7305. ((dow + firstDay + 6) % 7 >= 5 ? " ui-datepicker-week-end" : "") + // highlight weekends
  7306. (otherMonth ? " ui-datepicker-other-month" : "") + // highlight days from other months
  7307. ((printDate.getTime() === selectedDate.getTime() && drawMonth === inst.selectedMonth && inst._keyEvent) || // user pressed key
  7308. (defaultDate.getTime() === printDate.getTime() && defaultDate.getTime() === selectedDate.getTime()) ?
  7309. // or defaultDate is current printedDate and defaultDate is selectedDate
  7310. " " + this._dayOverClass : "") + // highlight selected day
  7311. (unselectable ? " " + this._unselectableClass + " ui-state-disabled": "") + // highlight unselectable days
  7312. (otherMonth && !showOtherMonths ? "" : " " + daySettings[1] + // highlight custom dates
  7313. (printDate.getTime() === currentDate.getTime() ? " " + this._currentClass : "") + // highlight selected day
  7314. (printDate.getTime() === today.getTime() ? " ui-datepicker-today" : "")) + "'" + // highlight today (if different)
  7315. ((!otherMonth || showOtherMonths) && daySettings[2] ? " title='" + daySettings[2].replace(/'/g, "&#39;") + "'" : "") + // cell title
  7316. (unselectable ? "" : " data-handler='selectDay' data-event='click' data-month='" + printDate.getMonth() + "' data-year='" + printDate.getFullYear() + "'") + ">" + // actions
  7317. (otherMonth && !showOtherMonths ? "&#xa0;" : // display for other months
  7318. (unselectable ? "<span class='ui-state-default'>" + printDate.getDate() + "</span>" : "<a class='ui-state-default" +
  7319. (printDate.getTime() === today.getTime() ? " ui-state-highlight" : "") +
  7320. (printDate.getTime() === currentDate.getTime() ? " ui-state-active" : "") + // highlight selected day
  7321. (otherMonth ? " ui-priority-secondary" : "") + // distinguish dates from other months
  7322. "' href='#'>" + printDate.getDate() + "</a>")) + "</td>"; // display selectable date
  7323. printDate.setDate(printDate.getDate() + 1);
  7324. printDate = this._daylightSavingAdjust(printDate);
  7325. }
  7326. calender += tbody + "</tr>";
  7327. }
  7328. drawMonth++;
  7329. if (drawMonth > 11) {
  7330. drawMonth = 0;
  7331. drawYear++;
  7332. }
  7333. calender += "</tbody></table>" + (isMultiMonth ? "</div>" +
  7334. ((numMonths[0] > 0 && col === numMonths[1]-1) ? "<div class='ui-datepicker-row-break'></div>" : "") : "");
  7335. group += calender;
  7336. }
  7337. html += group;
  7338. }
  7339. html += buttonPanel;
  7340. inst._keyEvent = false;
  7341. return html;
  7342. },
  7343. /* Generate the month and year header. */
  7344. _generateMonthYearHeader: function(inst, drawMonth, drawYear, minDate, maxDate,
  7345. secondary, monthNames, monthNamesShort) {
  7346. var inMinYear, inMaxYear, month, years, thisYear, determineYear, year, endYear,
  7347. changeMonth = this._get(inst, "changeMonth"),
  7348. changeYear = this._get(inst, "changeYear"),
  7349. showMonthAfterYear = this._get(inst, "showMonthAfterYear"),
  7350. html = "<div class='ui-datepicker-title'>",
  7351. monthHtml = "";
  7352. // month selection
  7353. if (secondary || !changeMonth) {
  7354. monthHtml += "<span class='ui-datepicker-month'>" + monthNames[drawMonth] + "</span>";
  7355. } else {
  7356. inMinYear = (minDate && minDate.getFullYear() === drawYear);
  7357. inMaxYear = (maxDate && maxDate.getFullYear() === drawYear);
  7358. monthHtml += "<select class='ui-datepicker-month' data-handler='selectMonth' data-event='change'>";
  7359. for ( month = 0; month < 12; month++) {
  7360. if ((!inMinYear || month >= minDate.getMonth()) && (!inMaxYear || month <= maxDate.getMonth())) {
  7361. monthHtml += "<option value='" + month + "'" +
  7362. (month === drawMonth ? " selected='selected'" : "") +
  7363. ">" + monthNamesShort[month] + "</option>";
  7364. }
  7365. }
  7366. monthHtml += "</select>";
  7367. }
  7368. if (!showMonthAfterYear) {
  7369. html += monthHtml + (secondary || !(changeMonth && changeYear) ? "&#xa0;" : "");
  7370. }
  7371. // year selection
  7372. if ( !inst.yearshtml ) {
  7373. inst.yearshtml = "";
  7374. if (secondary || !changeYear) {
  7375. html += "<span class='ui-datepicker-year'>" + drawYear + "</span>";
  7376. } else {
  7377. // determine range of years to display
  7378. years = this._get(inst, "yearRange").split(":");
  7379. thisYear = new Date().getFullYear();
  7380. determineYear = function(value) {
  7381. var year = (value.match(/c[+\-].*/) ? drawYear + parseInt(value.substring(1), 10) :
  7382. (value.match(/[+\-].*/) ? thisYear + parseInt(value, 10) :
  7383. parseInt(value, 10)));
  7384. return (isNaN(year) ? thisYear : year);
  7385. };
  7386. year = determineYear(years[0]);
  7387. endYear = Math.max(year, determineYear(years[1] || ""));
  7388. year = (minDate ? Math.max(year, minDate.getFullYear()) : year);
  7389. endYear = (maxDate ? Math.min(endYear, maxDate.getFullYear()) : endYear);
  7390. inst.yearshtml += "<select class='ui-datepicker-year' data-handler='selectYear' data-event='change'>";
  7391. for (; year <= endYear; year++) {
  7392. inst.yearshtml += "<option value='" + year + "'" +
  7393. (year === drawYear ? " selected='selected'" : "") +
  7394. ">" + year + "</option>";
  7395. }
  7396. inst.yearshtml += "</select>";
  7397. html += inst.yearshtml;
  7398. inst.yearshtml = null;
  7399. }
  7400. }
  7401. html += this._get(inst, "yearSuffix");
  7402. if (showMonthAfterYear) {
  7403. html += (secondary || !(changeMonth && changeYear) ? "&#xa0;" : "") + monthHtml;
  7404. }
  7405. html += "</div>"; // Close datepicker_header
  7406. return html;
  7407. },
  7408. /* Adjust one of the date sub-fields. */
  7409. _adjustInstDate: function(inst, offset, period) {
  7410. var year = inst.drawYear + (period === "Y" ? offset : 0),
  7411. month = inst.drawMonth + (period === "M" ? offset : 0),
  7412. day = Math.min(inst.selectedDay, this._getDaysInMonth(year, month)) + (period === "D" ? offset : 0),
  7413. date = this._restrictMinMax(inst, this._daylightSavingAdjust(new Date(year, month, day)));
  7414. inst.selectedDay = date.getDate();
  7415. inst.drawMonth = inst.selectedMonth = date.getMonth();
  7416. inst.drawYear = inst.selectedYear = date.getFullYear();
  7417. if (period === "M" || period === "Y") {
  7418. this._notifyChange(inst);
  7419. }
  7420. },
  7421. /* Ensure a date is within any min/max bounds. */
  7422. _restrictMinMax: function(inst, date) {
  7423. var minDate = this._getMinMaxDate(inst, "min"),
  7424. maxDate = this._getMinMaxDate(inst, "max"),
  7425. newDate = (minDate && date < minDate ? minDate : date);
  7426. return (maxDate && newDate > maxDate ? maxDate : newDate);
  7427. },
  7428. /* Notify change of month/year. */
  7429. _notifyChange: function(inst) {
  7430. var onChange = this._get(inst, "onChangeMonthYear");
  7431. if (onChange) {
  7432. onChange.apply((inst.input ? inst.input[0] : null),
  7433. [inst.selectedYear, inst.selectedMonth + 1, inst]);
  7434. }
  7435. },
  7436. /* Determine the number of months to show. */
  7437. _getNumberOfMonths: function(inst) {
  7438. var numMonths = this._get(inst, "numberOfMonths");
  7439. return (numMonths == null ? [1, 1] : (typeof numMonths === "number" ? [1, numMonths] : numMonths));
  7440. },
  7441. /* Determine the current maximum date - ensure no time components are set. */
  7442. _getMinMaxDate: function(inst, minMax) {
  7443. return this._determineDate(inst, this._get(inst, minMax + "Date"), null);
  7444. },
  7445. /* Find the number of days in a given month. */
  7446. _getDaysInMonth: function(year, month) {
  7447. return 32 - this._daylightSavingAdjust(new Date(year, month, 32)).getDate();
  7448. },
  7449. /* Find the day of the week of the first of a month. */
  7450. _getFirstDayOfMonth: function(year, month) {
  7451. return new Date(year, month, 1).getDay();
  7452. },
  7453. /* Determines if we should allow a "next/prev" month display change. */
  7454. _canAdjustMonth: function(inst, offset, curYear, curMonth) {
  7455. var numMonths = this._getNumberOfMonths(inst),
  7456. date = this._daylightSavingAdjust(new Date(curYear,
  7457. curMonth + (offset < 0 ? offset : numMonths[0] * numMonths[1]), 1));
  7458. if (offset < 0) {
  7459. date.setDate(this._getDaysInMonth(date.getFullYear(), date.getMonth()));
  7460. }
  7461. return this._isInRange(inst, date);
  7462. },
  7463. /* Is the given date in the accepted range? */
  7464. _isInRange: function(inst, date) {
  7465. var yearSplit, currentYear,
  7466. minDate = this._getMinMaxDate(inst, "min"),
  7467. maxDate = this._getMinMaxDate(inst, "max"),
  7468. minYear = null,
  7469. maxYear = null,
  7470. years = this._get(inst, "yearRange");
  7471. if (years){
  7472. yearSplit = years.split(":");
  7473. currentYear = new Date().getFullYear();
  7474. minYear = parseInt(yearSplit[0], 10);
  7475. maxYear = parseInt(yearSplit[1], 10);
  7476. if ( yearSplit[0].match(/[+\-].*/) ) {
  7477. minYear += currentYear;
  7478. }
  7479. if ( yearSplit[1].match(/[+\-].*/) ) {
  7480. maxYear += currentYear;
  7481. }
  7482. }
  7483. return ((!minDate || date.getTime() >= minDate.getTime()) &&
  7484. (!maxDate || date.getTime() <= maxDate.getTime()) &&
  7485. (!minYear || date.getFullYear() >= minYear) &&
  7486. (!maxYear || date.getFullYear() <= maxYear));
  7487. },
  7488. /* Provide the configuration settings for formatting/parsing. */
  7489. _getFormatConfig: function(inst) {
  7490. var shortYearCutoff = this._get(inst, "shortYearCutoff");
  7491. shortYearCutoff = (typeof shortYearCutoff !== "string" ? shortYearCutoff :
  7492. new Date().getFullYear() % 100 + parseInt(shortYearCutoff, 10));
  7493. return {shortYearCutoff: shortYearCutoff,
  7494. dayNamesShort: this._get(inst, "dayNamesShort"), dayNames: this._get(inst, "dayNames"),
  7495. monthNamesShort: this._get(inst, "monthNamesShort"), monthNames: this._get(inst, "monthNames")};
  7496. },
  7497. /* Format the given date for display. */
  7498. _formatDate: function(inst, day, month, year) {
  7499. if (!day) {
  7500. inst.currentDay = inst.selectedDay;
  7501. inst.currentMonth = inst.selectedMonth;
  7502. inst.currentYear = inst.selectedYear;
  7503. }
  7504. var date = (day ? (typeof day === "object" ? day :
  7505. this._daylightSavingAdjust(new Date(year, month, day))) :
  7506. this._daylightSavingAdjust(new Date(inst.currentYear, inst.currentMonth, inst.currentDay)));
  7507. return this.formatDate(this._get(inst, "dateFormat"), date, this._getFormatConfig(inst));
  7508. }
  7509. });
  7510. /*
  7511. * Bind hover events for datepicker elements.
  7512. * Done via delegate so the binding only occurs once in the lifetime of the parent div.
  7513. * Global instActive, set by _updateDatepicker allows the handlers to find their way back to the active picker.
  7514. */
  7515. function bindHover(dpDiv) {
  7516. var selector = "button, .ui-datepicker-prev, .ui-datepicker-next, .ui-datepicker-calendar td a";
  7517. return dpDiv.delegate(selector, "mouseout", function() {
  7518. $(this).removeClass("ui-state-hover");
  7519. if (this.className.indexOf("ui-datepicker-prev") !== -1) {
  7520. $(this).removeClass("ui-datepicker-prev-hover");
  7521. }
  7522. if (this.className.indexOf("ui-datepicker-next") !== -1) {
  7523. $(this).removeClass("ui-datepicker-next-hover");
  7524. }
  7525. })
  7526. .delegate(selector, "mouseover", function(){
  7527. if (!$.datepicker._isDisabledDatepicker( instActive.inline ? dpDiv.parent()[0] : instActive.input[0])) {
  7528. $(this).parents(".ui-datepicker-calendar").find("a").removeClass("ui-state-hover");
  7529. $(this).addClass("ui-state-hover");
  7530. if (this.className.indexOf("ui-datepicker-prev") !== -1) {
  7531. $(this).addClass("ui-datepicker-prev-hover");
  7532. }
  7533. if (this.className.indexOf("ui-datepicker-next") !== -1) {
  7534. $(this).addClass("ui-datepicker-next-hover");
  7535. }
  7536. }
  7537. });
  7538. }
  7539. /* jQuery extend now ignores nulls! */
  7540. function extendRemove(target, props) {
  7541. $.extend(target, props);
  7542. for (var name in props) {
  7543. if (props[name] == null) {
  7544. target[name] = props[name];
  7545. }
  7546. }
  7547. return target;
  7548. }
  7549. /* Invoke the datepicker functionality.
  7550. @param options string - a command, optionally followed by additional parameters or
  7551. Object - settings for attaching new datepicker functionality
  7552. @return jQuery object */
  7553. $.fn.datepicker = function(options){
  7554. /* Verify an empty collection wasn't passed - Fixes #6976 */
  7555. if ( !this.length ) {
  7556. return this;
  7557. }
  7558. /* Initialise the date picker. */
  7559. if (!$.datepicker.initialized) {
  7560. $(document).mousedown($.datepicker._checkExternalClick);
  7561. $.datepicker.initialized = true;
  7562. }
  7563. /* Append datepicker main container to body if not exist. */
  7564. if ($("#"+$.datepicker._mainDivId).length === 0) {
  7565. $("body").append($.datepicker.dpDiv);
  7566. }
  7567. var otherArgs = Array.prototype.slice.call(arguments, 1);
  7568. if (typeof options === "string" && (options === "isDisabled" || options === "getDate" || options === "widget")) {
  7569. return $.datepicker["_" + options + "Datepicker"].
  7570. apply($.datepicker, [this[0]].concat(otherArgs));
  7571. }
  7572. if (options === "option" && arguments.length === 2 && typeof arguments[1] === "string") {
  7573. return $.datepicker["_" + options + "Datepicker"].
  7574. apply($.datepicker, [this[0]].concat(otherArgs));
  7575. }
  7576. return this.each(function() {
  7577. typeof options === "string" ?
  7578. $.datepicker["_" + options + "Datepicker"].
  7579. apply($.datepicker, [this].concat(otherArgs)) :
  7580. $.datepicker._attachDatepicker(this, options);
  7581. });
  7582. };
  7583. $.datepicker = new Datepicker(); // singleton instance
  7584. $.datepicker.initialized = false;
  7585. $.datepicker.uuid = new Date().getTime();
  7586. $.datepicker.version = "1.10.3";
  7587. })(jQuery);
  7588. (function( $, undefined ) {
  7589. var sizeRelatedOptions = {
  7590. buttons: true,
  7591. height: true,
  7592. maxHeight: true,
  7593. maxWidth: true,
  7594. minHeight: true,
  7595. minWidth: true,
  7596. width: true
  7597. },
  7598. resizableRelatedOptions = {
  7599. maxHeight: true,
  7600. maxWidth: true,
  7601. minHeight: true,
  7602. minWidth: true
  7603. };
  7604. $.widget( "ui.dialog", {
  7605. version: "1.10.3",
  7606. options: {
  7607. appendTo: "body",
  7608. autoOpen: true,
  7609. buttons: [],
  7610. closeOnEscape: true,
  7611. closeText: "close",
  7612. dialogClass: "",
  7613. draggable: true,
  7614. hide: null,
  7615. height: "auto",
  7616. maxHeight: null,
  7617. maxWidth: null,
  7618. minHeight: 150,
  7619. minWidth: 150,
  7620. modal: false,
  7621. position: {
  7622. my: "center",
  7623. at: "center",
  7624. of: window,
  7625. collision: "fit",
  7626. // Ensure the titlebar is always visible
  7627. using: function( pos ) {
  7628. var topOffset = $( this ).css( pos ).offset().top;
  7629. if ( topOffset < 0 ) {
  7630. $( this ).css( "top", pos.top - topOffset );
  7631. }
  7632. }
  7633. },
  7634. resizable: true,
  7635. show: null,
  7636. title: null,
  7637. width: 300,
  7638. // callbacks
  7639. beforeClose: null,
  7640. close: null,
  7641. drag: null,
  7642. dragStart: null,
  7643. dragStop: null,
  7644. focus: null,
  7645. open: null,
  7646. resize: null,
  7647. resizeStart: null,
  7648. resizeStop: null
  7649. },
  7650. _create: function() {
  7651. this.originalCss = {
  7652. display: this.element[0].style.display,
  7653. width: this.element[0].style.width,
  7654. minHeight: this.element[0].style.minHeight,
  7655. maxHeight: this.element[0].style.maxHeight,
  7656. height: this.element[0].style.height
  7657. };
  7658. this.originalPosition = {
  7659. parent: this.element.parent(),
  7660. index: this.element.parent().children().index( this.element )
  7661. };
  7662. this.originalTitle = this.element.attr("title");
  7663. this.options.title = this.options.title || this.originalTitle;
  7664. this._createWrapper();
  7665. this.element
  7666. .show()
  7667. .removeAttr("title")
  7668. .addClass("ui-dialog-content ui-widget-content")
  7669. .appendTo( this.uiDialog );
  7670. this._createTitlebar();
  7671. this._createButtonPane();
  7672. if ( this.options.draggable && $.fn.draggable ) {
  7673. this._makeDraggable();
  7674. }
  7675. if ( this.options.resizable && $.fn.resizable ) {
  7676. this._makeResizable();
  7677. }
  7678. this._isOpen = false;
  7679. },
  7680. _init: function() {
  7681. if ( this.options.autoOpen ) {
  7682. this.open();
  7683. }
  7684. },
  7685. _appendTo: function() {
  7686. var element = this.options.appendTo;
  7687. if ( element && (element.jquery || element.nodeType) ) {
  7688. return $( element );
  7689. }
  7690. return this.document.find( element || "body" ).eq( 0 );
  7691. },
  7692. _destroy: function() {
  7693. var next,
  7694. originalPosition = this.originalPosition;
  7695. this._destroyOverlay();
  7696. this.element
  7697. .removeUniqueId()
  7698. .removeClass("ui-dialog-content ui-widget-content")
  7699. .css( this.originalCss )
  7700. // Without detaching first, the following becomes really slow
  7701. .detach();
  7702. this.uiDialog.stop( true, true ).remove();
  7703. if ( this.originalTitle ) {
  7704. this.element.attr( "title", this.originalTitle );
  7705. }
  7706. next = originalPosition.parent.children().eq( originalPosition.index );
  7707. // Don't try to place the dialog next to itself (#8613)
  7708. if ( next.length && next[0] !== this.element[0] ) {
  7709. next.before( this.element );
  7710. } else {
  7711. originalPosition.parent.append( this.element );
  7712. }
  7713. },
  7714. widget: function() {
  7715. return this.uiDialog;
  7716. },
  7717. disable: $.noop,
  7718. enable: $.noop,
  7719. close: function( event ) {
  7720. var that = this;
  7721. if ( !this._isOpen || this._trigger( "beforeClose", event ) === false ) {
  7722. return;
  7723. }
  7724. this._isOpen = false;
  7725. this._destroyOverlay();
  7726. if ( !this.opener.filter(":focusable").focus().length ) {
  7727. // Hiding a focused element doesn't trigger blur in WebKit
  7728. // so in case we have nothing to focus on, explicitly blur the active element
  7729. // https://bugs.webkit.org/show_bug.cgi?id=47182
  7730. $( this.document[0].activeElement ).blur();
  7731. }
  7732. this._hide( this.uiDialog, this.options.hide, function() {
  7733. that._trigger( "close", event );
  7734. });
  7735. },
  7736. isOpen: function() {
  7737. return this._isOpen;
  7738. },
  7739. moveToTop: function() {
  7740. this._moveToTop();
  7741. },
  7742. _moveToTop: function( event, silent ) {
  7743. var moved = !!this.uiDialog.nextAll(":visible").insertBefore( this.uiDialog ).length;
  7744. if ( moved && !silent ) {
  7745. this._trigger( "focus", event );
  7746. }
  7747. return moved;
  7748. },
  7749. open: function() {
  7750. var that = this;
  7751. if ( this._isOpen ) {
  7752. if ( this._moveToTop() ) {
  7753. this._focusTabbable();
  7754. }
  7755. return;
  7756. }
  7757. this._isOpen = true;
  7758. this.opener = $( this.document[0].activeElement );
  7759. this._size();
  7760. this._position();
  7761. this._createOverlay();
  7762. this._moveToTop( null, true );
  7763. this._show( this.uiDialog, this.options.show, function() {
  7764. that._focusTabbable();
  7765. that._trigger("focus");
  7766. });
  7767. this._trigger("open");
  7768. },
  7769. _focusTabbable: function() {
  7770. // Set focus to the first match:
  7771. // 1. First element inside the dialog matching [autofocus]
  7772. // 2. Tabbable element inside the content element
  7773. // 3. Tabbable element inside the buttonpane
  7774. // 4. The close button
  7775. // 5. The dialog itself
  7776. var hasFocus = this.element.find("[autofocus]");
  7777. if ( !hasFocus.length ) {
  7778. hasFocus = this.element.find(":tabbable");
  7779. }
  7780. if ( !hasFocus.length ) {
  7781. hasFocus = this.uiDialogButtonPane.find(":tabbable");
  7782. }
  7783. if ( !hasFocus.length ) {
  7784. hasFocus = this.uiDialogTitlebarClose.filter(":tabbable");
  7785. }
  7786. if ( !hasFocus.length ) {
  7787. hasFocus = this.uiDialog;
  7788. }
  7789. hasFocus.eq( 0 ).focus();
  7790. },
  7791. _keepFocus: function( event ) {
  7792. function checkFocus() {
  7793. var activeElement = this.document[0].activeElement,
  7794. isActive = this.uiDialog[0] === activeElement ||
  7795. $.contains( this.uiDialog[0], activeElement );
  7796. if ( !isActive ) {
  7797. this._focusTabbable();
  7798. }
  7799. }
  7800. event.preventDefault();
  7801. checkFocus.call( this );
  7802. // support: IE
  7803. // IE <= 8 doesn't prevent moving focus even with event.preventDefault()
  7804. // so we check again later
  7805. this._delay( checkFocus );
  7806. },
  7807. _createWrapper: function() {
  7808. this.uiDialog = $("<div>")
  7809. .addClass( "ui-dialog ui-widget ui-widget-content ui-corner-all ui-front " +
  7810. this.options.dialogClass )
  7811. .hide()
  7812. .attr({
  7813. // Setting tabIndex makes the div focusable
  7814. tabIndex: -1,
  7815. role: "dialog"
  7816. })
  7817. .appendTo( this._appendTo() );
  7818. this._on( this.uiDialog, {
  7819. keydown: function( event ) {
  7820. if ( this.options.closeOnEscape && !event.isDefaultPrevented() && event.keyCode &&
  7821. event.keyCode === $.ui.keyCode.ESCAPE ) {
  7822. event.preventDefault();
  7823. this.close( event );
  7824. return;
  7825. }
  7826. // prevent tabbing out of dialogs
  7827. if ( event.keyCode !== $.ui.keyCode.TAB ) {
  7828. return;
  7829. }
  7830. var tabbables = this.uiDialog.find(":tabbable"),
  7831. first = tabbables.filter(":first"),
  7832. last = tabbables.filter(":last");
  7833. if ( ( event.target === last[0] || event.target === this.uiDialog[0] ) && !event.shiftKey ) {
  7834. first.focus( 1 );
  7835. event.preventDefault();
  7836. } else if ( ( event.target === first[0] || event.target === this.uiDialog[0] ) && event.shiftKey ) {
  7837. last.focus( 1 );
  7838. event.preventDefault();
  7839. }
  7840. },
  7841. mousedown: function( event ) {
  7842. if ( this._moveToTop( event ) ) {
  7843. this._focusTabbable();
  7844. }
  7845. }
  7846. });
  7847. // We assume that any existing aria-describedby attribute means
  7848. // that the dialog content is marked up properly
  7849. // otherwise we brute force the content as the description
  7850. if ( !this.element.find("[aria-describedby]").length ) {
  7851. this.uiDialog.attr({
  7852. "aria-describedby": this.element.uniqueId().attr("id")
  7853. });
  7854. }
  7855. },
  7856. _createTitlebar: function() {
  7857. var uiDialogTitle;
  7858. this.uiDialogTitlebar = $("<div>")
  7859. .addClass("ui-dialog-titlebar ui-widget-header ui-corner-all ui-helper-clearfix")
  7860. .prependTo( this.uiDialog );
  7861. this._on( this.uiDialogTitlebar, {
  7862. mousedown: function( event ) {
  7863. // Don't prevent click on close button (#8838)
  7864. // Focusing a dialog that is partially scrolled out of view
  7865. // causes the browser to scroll it into view, preventing the click event
  7866. if ( !$( event.target ).closest(".ui-dialog-titlebar-close") ) {
  7867. // Dialog isn't getting focus when dragging (#8063)
  7868. this.uiDialog.focus();
  7869. }
  7870. }
  7871. });
  7872. this.uiDialogTitlebarClose = $("<button></button>")
  7873. .button({
  7874. label: this.options.closeText,
  7875. icons: {
  7876. primary: "ui-icon-closethick"
  7877. },
  7878. text: false
  7879. })
  7880. .addClass("ui-dialog-titlebar-close")
  7881. .appendTo( this.uiDialogTitlebar );
  7882. this._on( this.uiDialogTitlebarClose, {
  7883. click: function( event ) {
  7884. event.preventDefault();
  7885. this.close( event );
  7886. }
  7887. });
  7888. uiDialogTitle = $("<span>")
  7889. .uniqueId()
  7890. .addClass("ui-dialog-title")
  7891. .prependTo( this.uiDialogTitlebar );
  7892. this._title( uiDialogTitle );
  7893. this.uiDialog.attr({
  7894. "aria-labelledby": uiDialogTitle.attr("id")
  7895. });
  7896. },
  7897. _title: function( title ) {
  7898. if ( !this.options.title ) {
  7899. title.html("&#160;");
  7900. }
  7901. title.text( this.options.title );
  7902. },
  7903. _createButtonPane: function() {
  7904. this.uiDialogButtonPane = $("<div>")
  7905. .addClass("ui-dialog-buttonpane ui-widget-content ui-helper-clearfix");
  7906. this.uiButtonSet = $("<div>")
  7907. .addClass("ui-dialog-buttonset")
  7908. .appendTo( this.uiDialogButtonPane );
  7909. this._createButtons();
  7910. },
  7911. _createButtons: function() {
  7912. var that = this,
  7913. buttons = this.options.buttons;
  7914. // if we already have a button pane, remove it
  7915. this.uiDialogButtonPane.remove();
  7916. this.uiButtonSet.empty();
  7917. if ( $.isEmptyObject( buttons ) || ($.isArray( buttons ) && !buttons.length) ) {
  7918. this.uiDialog.removeClass("ui-dialog-buttons");
  7919. return;
  7920. }
  7921. $.each( buttons, function( name, props ) {
  7922. var click, buttonOptions;
  7923. props = $.isFunction( props ) ?
  7924. { click: props, text: name } :
  7925. props;
  7926. // Default to a non-submitting button
  7927. props = $.extend( { type: "button" }, props );
  7928. // Change the context for the click callback to be the main element
  7929. click = props.click;
  7930. props.click = function() {
  7931. click.apply( that.element[0], arguments );
  7932. };
  7933. buttonOptions = {
  7934. icons: props.icons,
  7935. text: props.showText
  7936. };
  7937. delete props.icons;
  7938. delete props.showText;
  7939. $( "<button></button>", props )
  7940. .button( buttonOptions )
  7941. .appendTo( that.uiButtonSet );
  7942. });
  7943. this.uiDialog.addClass("ui-dialog-buttons");
  7944. this.uiDialogButtonPane.appendTo( this.uiDialog );
  7945. },
  7946. _makeDraggable: function() {
  7947. var that = this,
  7948. options = this.options;
  7949. function filteredUi( ui ) {
  7950. return {
  7951. position: ui.position,
  7952. offset: ui.offset
  7953. };
  7954. }
  7955. this.uiDialog.draggable({
  7956. cancel: ".ui-dialog-content, .ui-dialog-titlebar-close",
  7957. handle: ".ui-dialog-titlebar",
  7958. containment: "document",
  7959. start: function( event, ui ) {
  7960. $( this ).addClass("ui-dialog-dragging");
  7961. that._blockFrames();
  7962. that._trigger( "dragStart", event, filteredUi( ui ) );
  7963. },
  7964. drag: function( event, ui ) {
  7965. that._trigger( "drag", event, filteredUi( ui ) );
  7966. },
  7967. stop: function( event, ui ) {
  7968. options.position = [
  7969. ui.position.left - that.document.scrollLeft(),
  7970. ui.position.top - that.document.scrollTop()
  7971. ];
  7972. $( this ).removeClass("ui-dialog-dragging");
  7973. that._unblockFrames();
  7974. that._trigger( "dragStop", event, filteredUi( ui ) );
  7975. }
  7976. });
  7977. },
  7978. _makeResizable: function() {
  7979. var that = this,
  7980. options = this.options,
  7981. handles = options.resizable,
  7982. // .ui-resizable has position: relative defined in the stylesheet
  7983. // but dialogs have to use absolute or fixed positioning
  7984. position = this.uiDialog.css("position"),
  7985. resizeHandles = typeof handles === "string" ?
  7986. handles :
  7987. "n,e,s,w,se,sw,ne,nw";
  7988. function filteredUi( ui ) {
  7989. return {
  7990. originalPosition: ui.originalPosition,
  7991. originalSize: ui.originalSize,
  7992. position: ui.position,
  7993. size: ui.size
  7994. };
  7995. }
  7996. this.uiDialog.resizable({
  7997. cancel: ".ui-dialog-content",
  7998. containment: "document",
  7999. alsoResize: this.element,
  8000. maxWidth: options.maxWidth,
  8001. maxHeight: options.maxHeight,
  8002. minWidth: options.minWidth,
  8003. minHeight: this._minHeight(),
  8004. handles: resizeHandles,
  8005. start: function( event, ui ) {
  8006. $( this ).addClass("ui-dialog-resizing");
  8007. that._blockFrames();
  8008. that._trigger( "resizeStart", event, filteredUi( ui ) );
  8009. },
  8010. resize: function( event, ui ) {
  8011. that._trigger( "resize", event, filteredUi( ui ) );
  8012. },
  8013. stop: function( event, ui ) {
  8014. options.height = $( this ).height();
  8015. options.width = $( this ).width();
  8016. $( this ).removeClass("ui-dialog-resizing");
  8017. that._unblockFrames();
  8018. that._trigger( "resizeStop", event, filteredUi( ui ) );
  8019. }
  8020. })
  8021. .css( "position", position );
  8022. },
  8023. _minHeight: function() {
  8024. var options = this.options;
  8025. return options.height === "auto" ?
  8026. options.minHeight :
  8027. Math.min( options.minHeight, options.height );
  8028. },
  8029. _position: function() {
  8030. // Need to show the dialog to get the actual offset in the position plugin
  8031. var isVisible = this.uiDialog.is(":visible");
  8032. if ( !isVisible ) {
  8033. this.uiDialog.show();
  8034. }
  8035. this.uiDialog.position( this.options.position );
  8036. if ( !isVisible ) {
  8037. this.uiDialog.hide();
  8038. }
  8039. },
  8040. _setOptions: function( options ) {
  8041. var that = this,
  8042. resize = false,
  8043. resizableOptions = {};
  8044. $.each( options, function( key, value ) {
  8045. that._setOption( key, value );
  8046. if ( key in sizeRelatedOptions ) {
  8047. resize = true;
  8048. }
  8049. if ( key in resizableRelatedOptions ) {
  8050. resizableOptions[ key ] = value;
  8051. }
  8052. });
  8053. if ( resize ) {
  8054. this._size();
  8055. this._position();
  8056. }
  8057. if ( this.uiDialog.is(":data(ui-resizable)") ) {
  8058. this.uiDialog.resizable( "option", resizableOptions );
  8059. }
  8060. },
  8061. _setOption: function( key, value ) {
  8062. /*jshint maxcomplexity:15*/
  8063. var isDraggable, isResizable,
  8064. uiDialog = this.uiDialog;
  8065. if ( key === "dialogClass" ) {
  8066. uiDialog
  8067. .removeClass( this.options.dialogClass )
  8068. .addClass( value );
  8069. }
  8070. if ( key === "disabled" ) {
  8071. return;
  8072. }
  8073. this._super( key, value );
  8074. if ( key === "appendTo" ) {
  8075. this.uiDialog.appendTo( this._appendTo() );
  8076. }
  8077. if ( key === "buttons" ) {
  8078. this._createButtons();
  8079. }
  8080. if ( key === "closeText" ) {
  8081. this.uiDialogTitlebarClose.button({
  8082. // Ensure that we always pass a string
  8083. label: "" + value
  8084. });
  8085. }
  8086. if ( key === "draggable" ) {
  8087. isDraggable = uiDialog.is(":data(ui-draggable)");
  8088. if ( isDraggable && !value ) {
  8089. uiDialog.draggable("destroy");
  8090. }
  8091. if ( !isDraggable && value ) {
  8092. this._makeDraggable();
  8093. }
  8094. }
  8095. if ( key === "position" ) {
  8096. this._position();
  8097. }
  8098. if ( key === "resizable" ) {
  8099. // currently resizable, becoming non-resizable
  8100. isResizable = uiDialog.is(":data(ui-resizable)");
  8101. if ( isResizable && !value ) {
  8102. uiDialog.resizable("destroy");
  8103. }
  8104. // currently resizable, changing handles
  8105. if ( isResizable && typeof value === "string" ) {
  8106. uiDialog.resizable( "option", "handles", value );
  8107. }
  8108. // currently non-resizable, becoming resizable
  8109. if ( !isResizable && value !== false ) {
  8110. this._makeResizable();
  8111. }
  8112. }
  8113. if ( key === "title" ) {
  8114. this._title( this.uiDialogTitlebar.find(".ui-dialog-title") );
  8115. }
  8116. },
  8117. _size: function() {
  8118. // If the user has resized the dialog, the .ui-dialog and .ui-dialog-content
  8119. // divs will both have width and height set, so we need to reset them
  8120. var nonContentHeight, minContentHeight, maxContentHeight,
  8121. options = this.options;
  8122. // Reset content sizing
  8123. this.element.show().css({
  8124. width: "auto",
  8125. minHeight: 0,
  8126. maxHeight: "none",
  8127. height: 0
  8128. });
  8129. if ( options.minWidth > options.width ) {
  8130. options.width = options.minWidth;
  8131. }
  8132. // reset wrapper sizing
  8133. // determine the height of all the non-content elements
  8134. nonContentHeight = this.uiDialog.css({
  8135. height: "auto",
  8136. width: options.width
  8137. })
  8138. .outerHeight();
  8139. minContentHeight = Math.max( 0, options.minHeight - nonContentHeight );
  8140. maxContentHeight = typeof options.maxHeight === "number" ?
  8141. Math.max( 0, options.maxHeight - nonContentHeight ) :
  8142. "none";
  8143. if ( options.height === "auto" ) {
  8144. this.element.css({
  8145. minHeight: minContentHeight,
  8146. maxHeight: maxContentHeight,
  8147. height: "auto"
  8148. });
  8149. } else {
  8150. this.element.height( Math.max( 0, options.height - nonContentHeight ) );
  8151. }
  8152. if (this.uiDialog.is(":data(ui-resizable)") ) {
  8153. this.uiDialog.resizable( "option", "minHeight", this._minHeight() );
  8154. }
  8155. },
  8156. _blockFrames: function() {
  8157. this.iframeBlocks = this.document.find( "iframe" ).map(function() {
  8158. var iframe = $( this );
  8159. return $( "<div>" )
  8160. .css({
  8161. position: "absolute",
  8162. width: iframe.outerWidth(),
  8163. height: iframe.outerHeight()
  8164. })
  8165. .appendTo( iframe.parent() )
  8166. .offset( iframe.offset() )[0];
  8167. });
  8168. },
  8169. _unblockFrames: function() {
  8170. if ( this.iframeBlocks ) {
  8171. this.iframeBlocks.remove();
  8172. delete this.iframeBlocks;
  8173. }
  8174. },
  8175. _allowInteraction: function( event ) {
  8176. if ( $( event.target ).closest(".ui-dialog").length ) {
  8177. return true;
  8178. }
  8179. // TODO: Remove hack when datepicker implements
  8180. // the .ui-front logic (#8989)
  8181. return !!$( event.target ).closest(".ui-datepicker").length;
  8182. },
  8183. _createOverlay: function() {
  8184. if ( !this.options.modal ) {
  8185. return;
  8186. }
  8187. var that = this,
  8188. widgetFullName = this.widgetFullName;
  8189. if ( !$.ui.dialog.overlayInstances ) {
  8190. // Prevent use of anchors and inputs.
  8191. // We use a delay in case the overlay is created from an
  8192. // event that we're going to be cancelling. (#2804)
  8193. this._delay(function() {
  8194. // Handle .dialog().dialog("close") (#4065)
  8195. if ( $.ui.dialog.overlayInstances ) {
  8196. this.document.bind( "focusin.dialog", function( event ) {
  8197. if ( !that._allowInteraction( event ) ) {
  8198. event.preventDefault();
  8199. $(".ui-dialog:visible:last .ui-dialog-content")
  8200. .data( widgetFullName )._focusTabbable();
  8201. }
  8202. });
  8203. }
  8204. });
  8205. }
  8206. this.overlay = $("<div>")
  8207. .addClass("ui-widget-overlay ui-front")
  8208. .appendTo( this._appendTo() );
  8209. this._on( this.overlay, {
  8210. mousedown: "_keepFocus"
  8211. });
  8212. $.ui.dialog.overlayInstances++;
  8213. },
  8214. _destroyOverlay: function() {
  8215. if ( !this.options.modal ) {
  8216. return;
  8217. }
  8218. if ( this.overlay ) {
  8219. $.ui.dialog.overlayInstances--;
  8220. if ( !$.ui.dialog.overlayInstances ) {
  8221. this.document.unbind( "focusin.dialog" );
  8222. }
  8223. this.overlay.remove();
  8224. this.overlay = null;
  8225. }
  8226. }
  8227. });
  8228. $.ui.dialog.overlayInstances = 0;
  8229. // DEPRECATED
  8230. if ( $.uiBackCompat !== false ) {
  8231. // position option with array notation
  8232. // just override with old implementation
  8233. $.widget( "ui.dialog", $.ui.dialog, {
  8234. _position: function() {
  8235. var position = this.options.position,
  8236. myAt = [],
  8237. offset = [ 0, 0 ],
  8238. isVisible;
  8239. if ( position ) {
  8240. if ( typeof position === "string" || (typeof position === "object" && "0" in position ) ) {
  8241. myAt = position.split ? position.split(" ") : [ position[0], position[1] ];
  8242. if ( myAt.length === 1 ) {
  8243. myAt[1] = myAt[0];
  8244. }
  8245. $.each( [ "left", "top" ], function( i, offsetPosition ) {
  8246. if ( +myAt[ i ] === myAt[ i ] ) {
  8247. offset[ i ] = myAt[ i ];
  8248. myAt[ i ] = offsetPosition;
  8249. }
  8250. });
  8251. position = {
  8252. my: myAt[0] + (offset[0] < 0 ? offset[0] : "+" + offset[0]) + " " +
  8253. myAt[1] + (offset[1] < 0 ? offset[1] : "+" + offset[1]),
  8254. at: myAt.join(" ")
  8255. };
  8256. }
  8257. position = $.extend( {}, $.ui.dialog.prototype.options.position, position );
  8258. } else {
  8259. position = $.ui.dialog.prototype.options.position;
  8260. }
  8261. // need to show the dialog to get the actual offset in the position plugin
  8262. isVisible = this.uiDialog.is(":visible");
  8263. if ( !isVisible ) {
  8264. this.uiDialog.show();
  8265. }
  8266. this.uiDialog.position( position );
  8267. if ( !isVisible ) {
  8268. this.uiDialog.hide();
  8269. }
  8270. }
  8271. });
  8272. }
  8273. }( jQuery ) );
  8274. (function( $, undefined ) {
  8275. $.widget( "ui.menu", {
  8276. version: "1.10.3",
  8277. defaultElement: "<ul>",
  8278. delay: 300,
  8279. options: {
  8280. icons: {
  8281. submenu: "ui-icon-carat-1-e"
  8282. },
  8283. menus: "ul",
  8284. position: {
  8285. my: "left top",
  8286. at: "right top"
  8287. },
  8288. role: "menu",
  8289. // callbacks
  8290. blur: null,
  8291. focus: null,
  8292. select: null
  8293. },
  8294. _create: function() {
  8295. this.activeMenu = this.element;
  8296. // flag used to prevent firing of the click handler
  8297. // as the event bubbles up through nested menus
  8298. this.mouseHandled = false;
  8299. this.element
  8300. .uniqueId()
  8301. .addClass( "ui-menu ui-widget ui-widget-content ui-corner-all" )
  8302. .toggleClass( "ui-menu-icons", !!this.element.find( ".ui-icon" ).length )
  8303. .attr({
  8304. role: this.options.role,
  8305. tabIndex: 0
  8306. })
  8307. // need to catch all clicks on disabled menu
  8308. // not possible through _on
  8309. .bind( "click" + this.eventNamespace, $.proxy(function( event ) {
  8310. if ( this.options.disabled ) {
  8311. event.preventDefault();
  8312. }
  8313. }, this ));
  8314. if ( this.options.disabled ) {
  8315. this.element
  8316. .addClass( "ui-state-disabled" )
  8317. .attr( "aria-disabled", "true" );
  8318. }
  8319. this._on({
  8320. // Prevent focus from sticking to links inside menu after clicking
  8321. // them (focus should always stay on UL during navigation).
  8322. "mousedown .ui-menu-item > a": function( event ) {
  8323. event.preventDefault();
  8324. },
  8325. "click .ui-state-disabled > a": function( event ) {
  8326. event.preventDefault();
  8327. },
  8328. "click .ui-menu-item:has(a)": function( event ) {
  8329. var target = $( event.target ).closest( ".ui-menu-item" );
  8330. if ( !this.mouseHandled && target.not( ".ui-state-disabled" ).length ) {
  8331. this.mouseHandled = true;
  8332. this.select( event );
  8333. // Open submenu on click
  8334. if ( target.has( ".ui-menu" ).length ) {
  8335. this.expand( event );
  8336. } else if ( !this.element.is( ":focus" ) ) {
  8337. // Redirect focus to the menu
  8338. this.element.trigger( "focus", [ true ] );
  8339. // If the active item is on the top level, let it stay active.
  8340. // Otherwise, blur the active item since it is no longer visible.
  8341. if ( this.active && this.active.parents( ".ui-menu" ).length === 1 ) {
  8342. clearTimeout( this.timer );
  8343. }
  8344. }
  8345. }
  8346. },
  8347. "mouseenter .ui-menu-item": function( event ) {
  8348. var target = $( event.currentTarget );
  8349. // Remove ui-state-active class from siblings of the newly focused menu item
  8350. // to avoid a jump caused by adjacent elements both having a class with a border
  8351. target.siblings().children( ".ui-state-active" ).removeClass( "ui-state-active" );
  8352. this.focus( event, target );
  8353. },
  8354. mouseleave: "collapseAll",
  8355. "mouseleave .ui-menu": "collapseAll",
  8356. focus: function( event, keepActiveItem ) {
  8357. // If there's already an active item, keep it active
  8358. // If not, activate the first item
  8359. var item = this.active || this.element.children( ".ui-menu-item" ).eq( 0 );
  8360. if ( !keepActiveItem ) {
  8361. this.focus( event, item );
  8362. }
  8363. },
  8364. blur: function( event ) {
  8365. this._delay(function() {
  8366. if ( !$.contains( this.element[0], this.document[0].activeElement ) ) {
  8367. this.collapseAll( event );
  8368. }
  8369. });
  8370. },
  8371. keydown: "_keydown"
  8372. });
  8373. this.refresh();
  8374. // Clicks outside of a menu collapse any open menus
  8375. this._on( this.document, {
  8376. click: function( event ) {
  8377. if ( !$( event.target ).closest( ".ui-menu" ).length ) {
  8378. this.collapseAll( event );
  8379. }
  8380. // Reset the mouseHandled flag
  8381. this.mouseHandled = false;
  8382. }
  8383. });
  8384. },
  8385. _destroy: function() {
  8386. // Destroy (sub)menus
  8387. this.element
  8388. .removeAttr( "aria-activedescendant" )
  8389. .find( ".ui-menu" ).addBack()
  8390. .removeClass( "ui-menu ui-widget ui-widget-content ui-corner-all ui-menu-icons" )
  8391. .removeAttr( "role" )
  8392. .removeAttr( "tabIndex" )
  8393. .removeAttr( "aria-labelledby" )
  8394. .removeAttr( "aria-expanded" )
  8395. .removeAttr( "aria-hidden" )
  8396. .removeAttr( "aria-disabled" )
  8397. .removeUniqueId()
  8398. .show();
  8399. // Destroy menu items
  8400. this.element.find( ".ui-menu-item" )
  8401. .removeClass( "ui-menu-item" )
  8402. .removeAttr( "role" )
  8403. .removeAttr( "aria-disabled" )
  8404. .children( "a" )
  8405. .removeUniqueId()
  8406. .removeClass( "ui-corner-all ui-state-hover" )
  8407. .removeAttr( "tabIndex" )
  8408. .removeAttr( "role" )
  8409. .removeAttr( "aria-haspopup" )
  8410. .children().each( function() {
  8411. var elem = $( this );
  8412. if ( elem.data( "ui-menu-submenu-carat" ) ) {
  8413. elem.remove();
  8414. }
  8415. });
  8416. // Destroy menu dividers
  8417. this.element.find( ".ui-menu-divider" ).removeClass( "ui-menu-divider ui-widget-content" );
  8418. },
  8419. _keydown: function( event ) {
  8420. /*jshint maxcomplexity:20*/
  8421. var match, prev, character, skip, regex,
  8422. preventDefault = true;
  8423. function escape( value ) {
  8424. return value.replace( /[\-\[\]{}()*+?.,\\\^$|#\s]/g, "\\$&" );
  8425. }
  8426. switch ( event.keyCode ) {
  8427. case $.ui.keyCode.PAGE_UP:
  8428. this.previousPage( event );
  8429. break;
  8430. case $.ui.keyCode.PAGE_DOWN:
  8431. this.nextPage( event );
  8432. break;
  8433. case $.ui.keyCode.HOME:
  8434. this._move( "first", "first", event );
  8435. break;
  8436. case $.ui.keyCode.END:
  8437. this._move( "last", "last", event );
  8438. break;
  8439. case $.ui.keyCode.UP:
  8440. this.previous( event );
  8441. break;
  8442. case $.ui.keyCode.DOWN:
  8443. this.next( event );
  8444. break;
  8445. case $.ui.keyCode.LEFT:
  8446. this.collapse( event );
  8447. break;
  8448. case $.ui.keyCode.RIGHT:
  8449. if ( this.active && !this.active.is( ".ui-state-disabled" ) ) {
  8450. this.expand( event );
  8451. }
  8452. break;
  8453. case $.ui.keyCode.ENTER:
  8454. case $.ui.keyCode.SPACE:
  8455. this._activate( event );
  8456. break;
  8457. case $.ui.keyCode.ESCAPE:
  8458. this.collapse( event );
  8459. break;
  8460. default:
  8461. preventDefault = false;
  8462. prev = this.previousFilter || "";
  8463. character = String.fromCharCode( event.keyCode );
  8464. skip = false;
  8465. clearTimeout( this.filterTimer );
  8466. if ( character === prev ) {
  8467. skip = true;
  8468. } else {
  8469. character = prev + character;
  8470. }
  8471. regex = new RegExp( "^" + escape( character ), "i" );
  8472. match = this.activeMenu.children( ".ui-menu-item" ).filter(function() {
  8473. return regex.test( $( this ).children( "a" ).text() );
  8474. });
  8475. match = skip && match.index( this.active.next() ) !== -1 ?
  8476. this.active.nextAll( ".ui-menu-item" ) :
  8477. match;
  8478. // If no matches on the current filter, reset to the last character pressed
  8479. // to move down the menu to the first item that starts with that character
  8480. if ( !match.length ) {
  8481. character = String.fromCharCode( event.keyCode );
  8482. regex = new RegExp( "^" + escape( character ), "i" );
  8483. match = this.activeMenu.children( ".ui-menu-item" ).filter(function() {
  8484. return regex.test( $( this ).children( "a" ).text() );
  8485. });
  8486. }
  8487. if ( match.length ) {
  8488. this.focus( event, match );
  8489. if ( match.length > 1 ) {
  8490. this.previousFilter = character;
  8491. this.filterTimer = this._delay(function() {
  8492. delete this.previousFilter;
  8493. }, 1000 );
  8494. } else {
  8495. delete this.previousFilter;
  8496. }
  8497. } else {
  8498. delete this.previousFilter;
  8499. }
  8500. }
  8501. if ( preventDefault ) {
  8502. event.preventDefault();
  8503. }
  8504. },
  8505. _activate: function( event ) {
  8506. if ( !this.active.is( ".ui-state-disabled" ) ) {
  8507. if ( this.active.children( "a[aria-haspopup='true']" ).length ) {
  8508. this.expand( event );
  8509. } else {
  8510. this.select( event );
  8511. }
  8512. }
  8513. },
  8514. refresh: function() {
  8515. var menus,
  8516. icon = this.options.icons.submenu,
  8517. submenus = this.element.find( this.options.menus );
  8518. // Initialize nested menus
  8519. submenus.filter( ":not(.ui-menu)" )
  8520. .addClass( "ui-menu ui-widget ui-widget-content ui-corner-all" )
  8521. .hide()
  8522. .attr({
  8523. role: this.options.role,
  8524. "aria-hidden": "true",
  8525. "aria-expanded": "false"
  8526. })
  8527. .each(function() {
  8528. var menu = $( this ),
  8529. item = menu.prev( "a" ),
  8530. submenuCarat = $( "<span>" )
  8531. .addClass( "ui-menu-icon ui-icon " + icon )
  8532. .data( "ui-menu-submenu-carat", true );
  8533. item
  8534. .attr( "aria-haspopup", "true" )
  8535. .prepend( submenuCarat );
  8536. menu.attr( "aria-labelledby", item.attr( "id" ) );
  8537. });
  8538. menus = submenus.add( this.element );
  8539. // Don't refresh list items that are already adapted
  8540. menus.children( ":not(.ui-menu-item):has(a)" )
  8541. .addClass( "ui-menu-item" )
  8542. .attr( "role", "presentation" )
  8543. .children( "a" )
  8544. .uniqueId()
  8545. .addClass( "ui-corner-all" )
  8546. .attr({
  8547. tabIndex: -1,
  8548. role: this._itemRole()
  8549. });
  8550. // Initialize unlinked menu-items containing spaces and/or dashes only as dividers
  8551. menus.children( ":not(.ui-menu-item)" ).each(function() {
  8552. var item = $( this );
  8553. // hyphen, em dash, en dash
  8554. if ( !/[^\-\u2014\u2013\s]/.test( item.text() ) ) {
  8555. item.addClass( "ui-widget-content ui-menu-divider" );
  8556. }
  8557. });
  8558. // Add aria-disabled attribute to any disabled menu item
  8559. menus.children( ".ui-state-disabled" ).attr( "aria-disabled", "true" );
  8560. // If the active item has been removed, blur the menu
  8561. if ( this.active && !$.contains( this.element[ 0 ], this.active[ 0 ] ) ) {
  8562. this.blur();
  8563. }
  8564. },
  8565. _itemRole: function() {
  8566. return {
  8567. menu: "menuitem",
  8568. listbox: "option"
  8569. }[ this.options.role ];
  8570. },
  8571. _setOption: function( key, value ) {
  8572. if ( key === "icons" ) {
  8573. this.element.find( ".ui-menu-icon" )
  8574. .removeClass( this.options.icons.submenu )
  8575. .addClass( value.submenu );
  8576. }
  8577. this._super( key, value );
  8578. },
  8579. focus: function( event, item ) {
  8580. var nested, focused;
  8581. this.blur( event, event && event.type === "focus" );
  8582. this._scrollIntoView( item );
  8583. this.active = item.first();
  8584. focused = this.active.children( "a" ).addClass( "ui-state-focus" );
  8585. // Only update aria-activedescendant if there's a role
  8586. // otherwise we assume focus is managed elsewhere
  8587. if ( this.options.role ) {
  8588. this.element.attr( "aria-activedescendant", focused.attr( "id" ) );
  8589. }
  8590. // Highlight active parent menu item, if any
  8591. this.active
  8592. .parent()
  8593. .closest( ".ui-menu-item" )
  8594. .children( "a:first" )
  8595. .addClass( "ui-state-active" );
  8596. if ( event && event.type === "keydown" ) {
  8597. this._close();
  8598. } else {
  8599. this.timer = this._delay(function() {
  8600. this._close();
  8601. }, this.delay );
  8602. }
  8603. nested = item.children( ".ui-menu" );
  8604. if ( nested.length && ( /^mouse/.test( event.type ) ) ) {
  8605. this._startOpening(nested);
  8606. }
  8607. this.activeMenu = item.parent();
  8608. this._trigger( "focus", event, { item: item } );
  8609. },
  8610. _scrollIntoView: function( item ) {
  8611. var borderTop, paddingTop, offset, scroll, elementHeight, itemHeight;
  8612. if ( this._hasScroll() ) {
  8613. borderTop = parseFloat( $.css( this.activeMenu[0], "borderTopWidth" ) ) || 0;
  8614. paddingTop = parseFloat( $.css( this.activeMenu[0], "paddingTop" ) ) || 0;
  8615. offset = item.offset().top - this.activeMenu.offset().top - borderTop - paddingTop;
  8616. scroll = this.activeMenu.scrollTop();
  8617. elementHeight = this.activeMenu.height();
  8618. itemHeight = item.height();
  8619. if ( offset < 0 ) {
  8620. this.activeMenu.scrollTop( scroll + offset );
  8621. } else if ( offset + itemHeight > elementHeight ) {
  8622. this.activeMenu.scrollTop( scroll + offset - elementHeight + itemHeight );
  8623. }
  8624. }
  8625. },
  8626. blur: function( event, fromFocus ) {
  8627. if ( !fromFocus ) {
  8628. clearTimeout( this.timer );
  8629. }
  8630. if ( !this.active ) {
  8631. return;
  8632. }
  8633. this.active.children( "a" ).removeClass( "ui-state-focus" );
  8634. this.active = null;
  8635. this._trigger( "blur", event, { item: this.active } );
  8636. },
  8637. _startOpening: function( submenu ) {
  8638. clearTimeout( this.timer );
  8639. // Don't open if already open fixes a Firefox bug that caused a .5 pixel
  8640. // shift in the submenu position when mousing over the carat icon
  8641. if ( submenu.attr( "aria-hidden" ) !== "true" ) {
  8642. return;
  8643. }
  8644. this.timer = this._delay(function() {
  8645. this._close();
  8646. this._open( submenu );
  8647. }, this.delay );
  8648. },
  8649. _open: function( submenu ) {
  8650. var position = $.extend({
  8651. of: this.active
  8652. }, this.options.position );
  8653. clearTimeout( this.timer );
  8654. this.element.find( ".ui-menu" ).not( submenu.parents( ".ui-menu" ) )
  8655. .hide()
  8656. .attr( "aria-hidden", "true" );
  8657. submenu
  8658. .show()
  8659. .removeAttr( "aria-hidden" )
  8660. .attr( "aria-expanded", "true" )
  8661. .position( position );
  8662. },
  8663. collapseAll: function( event, all ) {
  8664. clearTimeout( this.timer );
  8665. this.timer = this._delay(function() {
  8666. // If we were passed an event, look for the submenu that contains the event
  8667. var currentMenu = all ? this.element :
  8668. $( event && event.target ).closest( this.element.find( ".ui-menu" ) );
  8669. // If we found no valid submenu ancestor, use the main menu to close all sub menus anyway
  8670. if ( !currentMenu.length ) {
  8671. currentMenu = this.element;
  8672. }
  8673. this._close( currentMenu );
  8674. this.blur( event );
  8675. this.activeMenu = currentMenu;
  8676. }, this.delay );
  8677. },
  8678. // With no arguments, closes the currently active menu - if nothing is active
  8679. // it closes all menus. If passed an argument, it will search for menus BELOW
  8680. _close: function( startMenu ) {
  8681. if ( !startMenu ) {
  8682. startMenu = this.active ? this.active.parent() : this.element;
  8683. }
  8684. startMenu
  8685. .find( ".ui-menu" )
  8686. .hide()
  8687. .attr( "aria-hidden", "true" )
  8688. .attr( "aria-expanded", "false" )
  8689. .end()
  8690. .find( "a.ui-state-active" )
  8691. .removeClass( "ui-state-active" );
  8692. },
  8693. collapse: function( event ) {
  8694. var newItem = this.active &&
  8695. this.active.parent().closest( ".ui-menu-item", this.element );
  8696. if ( newItem && newItem.length ) {
  8697. this._close();
  8698. this.focus( event, newItem );
  8699. }
  8700. },
  8701. expand: function( event ) {
  8702. var newItem = this.active &&
  8703. this.active
  8704. .children( ".ui-menu " )
  8705. .children( ".ui-menu-item" )
  8706. .first();
  8707. if ( newItem && newItem.length ) {
  8708. this._open( newItem.parent() );
  8709. // Delay so Firefox will not hide activedescendant change in expanding submenu from AT
  8710. this._delay(function() {
  8711. this.focus( event, newItem );
  8712. });
  8713. }
  8714. },
  8715. next: function( event ) {
  8716. this._move( "next", "first", event );
  8717. },
  8718. previous: function( event ) {
  8719. this._move( "prev", "last", event );
  8720. },
  8721. isFirstItem: function() {
  8722. return this.active && !this.active.prevAll( ".ui-menu-item" ).length;
  8723. },
  8724. isLastItem: function() {
  8725. return this.active && !this.active.nextAll( ".ui-menu-item" ).length;
  8726. },
  8727. _move: function( direction, filter, event ) {
  8728. var next;
  8729. if ( this.active ) {
  8730. if ( direction === "first" || direction === "last" ) {
  8731. next = this.active
  8732. [ direction === "first" ? "prevAll" : "nextAll" ]( ".ui-menu-item" )
  8733. .eq( -1 );
  8734. } else {
  8735. next = this.active
  8736. [ direction + "All" ]( ".ui-menu-item" )
  8737. .eq( 0 );
  8738. }
  8739. }
  8740. if ( !next || !next.length || !this.active ) {
  8741. next = this.activeMenu.children( ".ui-menu-item" )[ filter ]();
  8742. }
  8743. this.focus( event, next );
  8744. },
  8745. nextPage: function( event ) {
  8746. var item, base, height;
  8747. if ( !this.active ) {
  8748. this.next( event );
  8749. return;
  8750. }
  8751. if ( this.isLastItem() ) {
  8752. return;
  8753. }
  8754. if ( this._hasScroll() ) {
  8755. base = this.active.offset().top;
  8756. height = this.element.height();
  8757. this.active.nextAll( ".ui-menu-item" ).each(function() {
  8758. item = $( this );
  8759. return item.offset().top - base - height < 0;
  8760. });
  8761. this.focus( event, item );
  8762. } else {
  8763. this.focus( event, this.activeMenu.children( ".ui-menu-item" )
  8764. [ !this.active ? "first" : "last" ]() );
  8765. }
  8766. },
  8767. previousPage: function( event ) {
  8768. var item, base, height;
  8769. if ( !this.active ) {
  8770. this.next( event );
  8771. return;
  8772. }
  8773. if ( this.isFirstItem() ) {
  8774. return;
  8775. }
  8776. if ( this._hasScroll() ) {
  8777. base = this.active.offset().top;
  8778. height = this.element.height();
  8779. this.active.prevAll( ".ui-menu-item" ).each(function() {
  8780. item = $( this );
  8781. return item.offset().top - base + height > 0;
  8782. });
  8783. this.focus( event, item );
  8784. } else {
  8785. this.focus( event, this.activeMenu.children( ".ui-menu-item" ).first() );
  8786. }
  8787. },
  8788. _hasScroll: function() {
  8789. return this.element.outerHeight() < this.element.prop( "scrollHeight" );
  8790. },
  8791. select: function( event ) {
  8792. // TODO: It should never be possible to not have an active item at this
  8793. // point, but the tests don't trigger mouseenter before click.
  8794. this.active = this.active || $( event.target ).closest( ".ui-menu-item" );
  8795. var ui = { item: this.active };
  8796. if ( !this.active.has( ".ui-menu" ).length ) {
  8797. this.collapseAll( event, true );
  8798. }
  8799. this._trigger( "select", event, ui );
  8800. }
  8801. });
  8802. }( jQuery ));
  8803. (function( $, undefined ) {
  8804. $.widget( "ui.progressbar", {
  8805. version: "1.10.3",
  8806. options: {
  8807. max: 100,
  8808. value: 0,
  8809. change: null,
  8810. complete: null
  8811. },
  8812. min: 0,
  8813. _create: function() {
  8814. // Constrain initial value
  8815. this.oldValue = this.options.value = this._constrainedValue();
  8816. this.element
  8817. .addClass( "ui-progressbar ui-widget ui-widget-content ui-corner-all" )
  8818. .attr({
  8819. // Only set static values, aria-valuenow and aria-valuemax are
  8820. // set inside _refreshValue()
  8821. role: "progressbar",
  8822. "aria-valuemin": this.min
  8823. });
  8824. this.valueDiv = $( "<div class='ui-progressbar-value ui-widget-header ui-corner-left'></div>" )
  8825. .appendTo( this.element );
  8826. this._refreshValue();
  8827. },
  8828. _destroy: function() {
  8829. this.element
  8830. .removeClass( "ui-progressbar ui-widget ui-widget-content ui-corner-all" )
  8831. .removeAttr( "role" )
  8832. .removeAttr( "aria-valuemin" )
  8833. .removeAttr( "aria-valuemax" )
  8834. .removeAttr( "aria-valuenow" );
  8835. this.valueDiv.remove();
  8836. },
  8837. value: function( newValue ) {
  8838. if ( newValue === undefined ) {
  8839. return this.options.value;
  8840. }
  8841. this.options.value = this._constrainedValue( newValue );
  8842. this._refreshValue();
  8843. },
  8844. _constrainedValue: function( newValue ) {
  8845. if ( newValue === undefined ) {
  8846. newValue = this.options.value;
  8847. }
  8848. this.indeterminate = newValue === false;
  8849. // sanitize value
  8850. if ( typeof newValue !== "number" ) {
  8851. newValue = 0;
  8852. }
  8853. return this.indeterminate ? false :
  8854. Math.min( this.options.max, Math.max( this.min, newValue ) );
  8855. },
  8856. _setOptions: function( options ) {
  8857. // Ensure "value" option is set after other values (like max)
  8858. var value = options.value;
  8859. delete options.value;
  8860. this._super( options );
  8861. this.options.value = this._constrainedValue( value );
  8862. this._refreshValue();
  8863. },
  8864. _setOption: function( key, value ) {
  8865. if ( key === "max" ) {
  8866. // Don't allow a max less than min
  8867. value = Math.max( this.min, value );
  8868. }
  8869. this._super( key, value );
  8870. },
  8871. _percentage: function() {
  8872. return this.indeterminate ? 100 : 100 * ( this.options.value - this.min ) / ( this.options.max - this.min );
  8873. },
  8874. _refreshValue: function() {
  8875. var value = this.options.value,
  8876. percentage = this._percentage();
  8877. this.valueDiv
  8878. .toggle( this.indeterminate || value > this.min )
  8879. .toggleClass( "ui-corner-right", value === this.options.max )
  8880. .width( percentage.toFixed(0) + "%" );
  8881. this.element.toggleClass( "ui-progressbar-indeterminate", this.indeterminate );
  8882. if ( this.indeterminate ) {
  8883. this.element.removeAttr( "aria-valuenow" );
  8884. if ( !this.overlayDiv ) {
  8885. this.overlayDiv = $( "<div class='ui-progressbar-overlay'></div>" ).appendTo( this.valueDiv );
  8886. }
  8887. } else {
  8888. this.element.attr({
  8889. "aria-valuemax": this.options.max,
  8890. "aria-valuenow": value
  8891. });
  8892. if ( this.overlayDiv ) {
  8893. this.overlayDiv.remove();
  8894. this.overlayDiv = null;
  8895. }
  8896. }
  8897. if ( this.oldValue !== value ) {
  8898. this.oldValue = value;
  8899. this._trigger( "change" );
  8900. }
  8901. if ( value === this.options.max ) {
  8902. this._trigger( "complete" );
  8903. }
  8904. }
  8905. });
  8906. })( jQuery );
  8907. (function( $, undefined ) {
  8908. // number of pages in a slider
  8909. // (how many times can you page up/down to go through the whole range)
  8910. var numPages = 5;
  8911. $.widget( "ui.slider", $.ui.mouse, {
  8912. version: "1.10.3",
  8913. widgetEventPrefix: "slide",
  8914. options: {
  8915. animate: false,
  8916. distance: 0,
  8917. max: 100,
  8918. min: 0,
  8919. orientation: "horizontal",
  8920. range: false,
  8921. step: 1,
  8922. value: 0,
  8923. values: null,
  8924. // callbacks
  8925. change: null,
  8926. slide: null,
  8927. start: null,
  8928. stop: null
  8929. },
  8930. _create: function() {
  8931. this._keySliding = false;
  8932. this._mouseSliding = false;
  8933. this._animateOff = true;
  8934. this._handleIndex = null;
  8935. this._detectOrientation();
  8936. this._mouseInit();
  8937. this.element
  8938. .addClass( "ui-slider" +
  8939. " ui-slider-" + this.orientation +
  8940. " ui-widget" +
  8941. " ui-widget-content" +
  8942. " ui-corner-all");
  8943. this._refresh();
  8944. this._setOption( "disabled", this.options.disabled );
  8945. this._animateOff = false;
  8946. },
  8947. _refresh: function() {
  8948. this._createRange();
  8949. this._createHandles();
  8950. this._setupEvents();
  8951. this._refreshValue();
  8952. },
  8953. _createHandles: function() {
  8954. var i, handleCount,
  8955. options = this.options,
  8956. existingHandles = this.element.find( ".ui-slider-handle" ).addClass( "ui-state-default ui-corner-all" ),
  8957. handle = "<a class='ui-slider-handle ui-state-default ui-corner-all' href='#'></a>",
  8958. handles = [];
  8959. handleCount = ( options.values && options.values.length ) || 1;
  8960. if ( existingHandles.length > handleCount ) {
  8961. existingHandles.slice( handleCount ).remove();
  8962. existingHandles = existingHandles.slice( 0, handleCount );
  8963. }
  8964. for ( i = existingHandles.length; i < handleCount; i++ ) {
  8965. handles.push( handle );
  8966. }
  8967. this.handles = existingHandles.add( $( handles.join( "" ) ).appendTo( this.element ) );
  8968. this.handle = this.handles.eq( 0 );
  8969. this.handles.each(function( i ) {
  8970. $( this ).data( "ui-slider-handle-index", i );
  8971. });
  8972. },
  8973. _createRange: function() {
  8974. var options = this.options,
  8975. classes = "";
  8976. if ( options.range ) {
  8977. if ( options.range === true ) {
  8978. if ( !options.values ) {
  8979. options.values = [ this._valueMin(), this._valueMin() ];
  8980. } else if ( options.values.length && options.values.length !== 2 ) {
  8981. options.values = [ options.values[0], options.values[0] ];
  8982. } else if ( $.isArray( options.values ) ) {
  8983. options.values = options.values.slice(0);
  8984. }
  8985. }
  8986. if ( !this.range || !this.range.length ) {
  8987. this.range = $( "<div></div>" )
  8988. .appendTo( this.element );
  8989. classes = "ui-slider-range" +
  8990. // note: this isn't the most fittingly semantic framework class for this element,
  8991. // but worked best visually with a variety of themes
  8992. " ui-widget-header ui-corner-all";
  8993. } else {
  8994. this.range.removeClass( "ui-slider-range-min ui-slider-range-max" )
  8995. // Handle range switching from true to min/max
  8996. .css({
  8997. "left": "",
  8998. "bottom": ""
  8999. });
  9000. }
  9001. this.range.addClass( classes +
  9002. ( ( options.range === "min" || options.range === "max" ) ? " ui-slider-range-" + options.range : "" ) );
  9003. } else {
  9004. this.range = $([]);
  9005. }
  9006. },
  9007. _setupEvents: function() {
  9008. var elements = this.handles.add( this.range ).filter( "a" );
  9009. this._off( elements );
  9010. this._on( elements, this._handleEvents );
  9011. this._hoverable( elements );
  9012. this._focusable( elements );
  9013. },
  9014. _destroy: function() {
  9015. this.handles.remove();
  9016. this.range.remove();
  9017. this.element
  9018. .removeClass( "ui-slider" +
  9019. " ui-slider-horizontal" +
  9020. " ui-slider-vertical" +
  9021. " ui-widget" +
  9022. " ui-widget-content" +
  9023. " ui-corner-all" );
  9024. this._mouseDestroy();
  9025. },
  9026. _mouseCapture: function( event ) {
  9027. var position, normValue, distance, closestHandle, index, allowed, offset, mouseOverHandle,
  9028. that = this,
  9029. o = this.options;
  9030. if ( o.disabled ) {
  9031. return false;
  9032. }
  9033. this.elementSize = {
  9034. width: this.element.outerWidth(),
  9035. height: this.element.outerHeight()
  9036. };
  9037. this.elementOffset = this.element.offset();
  9038. position = { x: event.pageX, y: event.pageY };
  9039. normValue = this._normValueFromMouse( position );
  9040. distance = this._valueMax() - this._valueMin() + 1;
  9041. this.handles.each(function( i ) {
  9042. var thisDistance = Math.abs( normValue - that.values(i) );
  9043. if (( distance > thisDistance ) ||
  9044. ( distance === thisDistance &&
  9045. (i === that._lastChangedValue || that.values(i) === o.min ))) {
  9046. distance = thisDistance;
  9047. closestHandle = $( this );
  9048. index = i;
  9049. }
  9050. });
  9051. allowed = this._start( event, index );
  9052. if ( allowed === false ) {
  9053. return false;
  9054. }
  9055. this._mouseSliding = true;
  9056. this._handleIndex = index;
  9057. closestHandle
  9058. .addClass( "ui-state-active" )
  9059. .focus();
  9060. offset = closestHandle.offset();
  9061. mouseOverHandle = !$( event.target ).parents().addBack().is( ".ui-slider-handle" );
  9062. this._clickOffset = mouseOverHandle ? { left: 0, top: 0 } : {
  9063. left: event.pageX - offset.left - ( closestHandle.width() / 2 ),
  9064. top: event.pageY - offset.top -
  9065. ( closestHandle.height() / 2 ) -
  9066. ( parseInt( closestHandle.css("borderTopWidth"), 10 ) || 0 ) -
  9067. ( parseInt( closestHandle.css("borderBottomWidth"), 10 ) || 0) +
  9068. ( parseInt( closestHandle.css("marginTop"), 10 ) || 0)
  9069. };
  9070. if ( !this.handles.hasClass( "ui-state-hover" ) ) {
  9071. this._slide( event, index, normValue );
  9072. }
  9073. this._animateOff = true;
  9074. return true;
  9075. },
  9076. _mouseStart: function() {
  9077. return true;
  9078. },
  9079. _mouseDrag: function( event ) {
  9080. var position = { x: event.pageX, y: event.pageY },
  9081. normValue = this._normValueFromMouse( position );
  9082. this._slide( event, this._handleIndex, normValue );
  9083. return false;
  9084. },
  9085. _mouseStop: function( event ) {
  9086. this.handles.removeClass( "ui-state-active" );
  9087. this._mouseSliding = false;
  9088. this._stop( event, this._handleIndex );
  9089. this._change( event, this._handleIndex );
  9090. this._handleIndex = null;
  9091. this._clickOffset = null;
  9092. this._animateOff = false;
  9093. return false;
  9094. },
  9095. _detectOrientation: function() {
  9096. this.orientation = ( this.options.orientation === "vertical" ) ? "vertical" : "horizontal";
  9097. },
  9098. _normValueFromMouse: function( position ) {
  9099. var pixelTotal,
  9100. pixelMouse,
  9101. percentMouse,
  9102. valueTotal,
  9103. valueMouse;
  9104. if ( this.orientation === "horizontal" ) {
  9105. pixelTotal = this.elementSize.width;
  9106. pixelMouse = position.x - this.elementOffset.left - ( this._clickOffset ? this._clickOffset.left : 0 );
  9107. } else {
  9108. pixelTotal = this.elementSize.height;
  9109. pixelMouse = position.y - this.elementOffset.top - ( this._clickOffset ? this._clickOffset.top : 0 );
  9110. }
  9111. percentMouse = ( pixelMouse / pixelTotal );
  9112. if ( percentMouse > 1 ) {
  9113. percentMouse = 1;
  9114. }
  9115. if ( percentMouse < 0 ) {
  9116. percentMouse = 0;
  9117. }
  9118. if ( this.orientation === "vertical" ) {
  9119. percentMouse = 1 - percentMouse;
  9120. }
  9121. valueTotal = this._valueMax() - this._valueMin();
  9122. valueMouse = this._valueMin() + percentMouse * valueTotal;
  9123. return this._trimAlignValue( valueMouse );
  9124. },
  9125. _start: function( event, index ) {
  9126. var uiHash = {
  9127. handle: this.handles[ index ],
  9128. value: this.value()
  9129. };
  9130. if ( this.options.values && this.options.values.length ) {
  9131. uiHash.value = this.values( index );
  9132. uiHash.values = this.values();
  9133. }
  9134. return this._trigger( "start", event, uiHash );
  9135. },
  9136. _slide: function( event, index, newVal ) {
  9137. var otherVal,
  9138. newValues,
  9139. allowed;
  9140. if ( this.options.values && this.options.values.length ) {
  9141. otherVal = this.values( index ? 0 : 1 );
  9142. if ( ( this.options.values.length === 2 && this.options.range === true ) &&
  9143. ( ( index === 0 && newVal > otherVal) || ( index === 1 && newVal < otherVal ) )
  9144. ) {
  9145. newVal = otherVal;
  9146. }
  9147. if ( newVal !== this.values( index ) ) {
  9148. newValues = this.values();
  9149. newValues[ index ] = newVal;
  9150. // A slide can be canceled by returning false from the slide callback
  9151. allowed = this._trigger( "slide", event, {
  9152. handle: this.handles[ index ],
  9153. value: newVal,
  9154. values: newValues
  9155. } );
  9156. otherVal = this.values( index ? 0 : 1 );
  9157. if ( allowed !== false ) {
  9158. this.values( index, newVal, true );
  9159. }
  9160. }
  9161. } else {
  9162. if ( newVal !== this.value() ) {
  9163. // A slide can be canceled by returning false from the slide callback
  9164. allowed = this._trigger( "slide", event, {
  9165. handle: this.handles[ index ],
  9166. value: newVal
  9167. } );
  9168. if ( allowed !== false ) {
  9169. this.value( newVal );
  9170. }
  9171. }
  9172. }
  9173. },
  9174. _stop: function( event, index ) {
  9175. var uiHash = {
  9176. handle: this.handles[ index ],
  9177. value: this.value()
  9178. };
  9179. if ( this.options.values && this.options.values.length ) {
  9180. uiHash.value = this.values( index );
  9181. uiHash.values = this.values();
  9182. }
  9183. this._trigger( "stop", event, uiHash );
  9184. },
  9185. _change: function( event, index ) {
  9186. if ( !this._keySliding && !this._mouseSliding ) {
  9187. var uiHash = {
  9188. handle: this.handles[ index ],
  9189. value: this.value()
  9190. };
  9191. if ( this.options.values && this.options.values.length ) {
  9192. uiHash.value = this.values( index );
  9193. uiHash.values = this.values();
  9194. }
  9195. //store the last changed value index for reference when handles overlap
  9196. this._lastChangedValue = index;
  9197. this._trigger( "change", event, uiHash );
  9198. }
  9199. },
  9200. value: function( newValue ) {
  9201. if ( arguments.length ) {
  9202. this.options.value = this._trimAlignValue( newValue );
  9203. this._refreshValue();
  9204. this._change( null, 0 );
  9205. return;
  9206. }
  9207. return this._value();
  9208. },
  9209. values: function( index, newValue ) {
  9210. var vals,
  9211. newValues,
  9212. i;
  9213. if ( arguments.length > 1 ) {
  9214. this.options.values[ index ] = this._trimAlignValue( newValue );
  9215. this._refreshValue();
  9216. this._change( null, index );
  9217. return;
  9218. }
  9219. if ( arguments.length ) {
  9220. if ( $.isArray( arguments[ 0 ] ) ) {
  9221. vals = this.options.values;
  9222. newValues = arguments[ 0 ];
  9223. for ( i = 0; i < vals.length; i += 1 ) {
  9224. vals[ i ] = this._trimAlignValue( newValues[ i ] );
  9225. this._change( null, i );
  9226. }
  9227. this._refreshValue();
  9228. } else {
  9229. if ( this.options.values && this.options.values.length ) {
  9230. return this._values( index );
  9231. } else {
  9232. return this.value();
  9233. }
  9234. }
  9235. } else {
  9236. return this._values();
  9237. }
  9238. },
  9239. _setOption: function( key, value ) {
  9240. var i,
  9241. valsLength = 0;
  9242. if ( key === "range" && this.options.range === true ) {
  9243. if ( value === "min" ) {
  9244. this.options.value = this._values( 0 );
  9245. this.options.values = null;
  9246. } else if ( value === "max" ) {
  9247. this.options.value = this._values( this.options.values.length-1 );
  9248. this.options.values = null;
  9249. }
  9250. }
  9251. if ( $.isArray( this.options.values ) ) {
  9252. valsLength = this.options.values.length;
  9253. }
  9254. $.Widget.prototype._setOption.apply( this, arguments );
  9255. switch ( key ) {
  9256. case "orientation":
  9257. this._detectOrientation();
  9258. this.element
  9259. .removeClass( "ui-slider-horizontal ui-slider-vertical" )
  9260. .addClass( "ui-slider-" + this.orientation );
  9261. this._refreshValue();
  9262. break;
  9263. case "value":
  9264. this._animateOff = true;
  9265. this._refreshValue();
  9266. this._change( null, 0 );
  9267. this._animateOff = false;
  9268. break;
  9269. case "values":
  9270. this._animateOff = true;
  9271. this._refreshValue();
  9272. for ( i = 0; i < valsLength; i += 1 ) {
  9273. this._change( null, i );
  9274. }
  9275. this._animateOff = false;
  9276. break;
  9277. case "min":
  9278. case "max":
  9279. this._animateOff = true;
  9280. this._refreshValue();
  9281. this._animateOff = false;
  9282. break;
  9283. case "range":
  9284. this._animateOff = true;
  9285. this._refresh();
  9286. this._animateOff = false;
  9287. break;
  9288. }
  9289. },
  9290. //internal value getter
  9291. // _value() returns value trimmed by min and max, aligned by step
  9292. _value: function() {
  9293. var val = this.options.value;
  9294. val = this._trimAlignValue( val );
  9295. return val;
  9296. },
  9297. //internal values getter
  9298. // _values() returns array of values trimmed by min and max, aligned by step
  9299. // _values( index ) returns single value trimmed by min and max, aligned by step
  9300. _values: function( index ) {
  9301. var val,
  9302. vals,
  9303. i;
  9304. if ( arguments.length ) {
  9305. val = this.options.values[ index ];
  9306. val = this._trimAlignValue( val );
  9307. return val;
  9308. } else if ( this.options.values && this.options.values.length ) {
  9309. // .slice() creates a copy of the array
  9310. // this copy gets trimmed by min and max and then returned
  9311. vals = this.options.values.slice();
  9312. for ( i = 0; i < vals.length; i+= 1) {
  9313. vals[ i ] = this._trimAlignValue( vals[ i ] );
  9314. }
  9315. return vals;
  9316. } else {
  9317. return [];
  9318. }
  9319. },
  9320. // returns the step-aligned value that val is closest to, between (inclusive) min and max
  9321. _trimAlignValue: function( val ) {
  9322. if ( val <= this._valueMin() ) {
  9323. return this._valueMin();
  9324. }
  9325. if ( val >= this._valueMax() ) {
  9326. return this._valueMax();
  9327. }
  9328. var step = ( this.options.step > 0 ) ? this.options.step : 1,
  9329. valModStep = (val - this._valueMin()) % step,
  9330. alignValue = val - valModStep;
  9331. if ( Math.abs(valModStep) * 2 >= step ) {
  9332. alignValue += ( valModStep > 0 ) ? step : ( -step );
  9333. }
  9334. // Since JavaScript has problems with large floats, round
  9335. // the final value to 5 digits after the decimal point (see #4124)
  9336. return parseFloat( alignValue.toFixed(5) );
  9337. },
  9338. _valueMin: function() {
  9339. return this.options.min;
  9340. },
  9341. _valueMax: function() {
  9342. return this.options.max;
  9343. },
  9344. _refreshValue: function() {
  9345. var lastValPercent, valPercent, value, valueMin, valueMax,
  9346. oRange = this.options.range,
  9347. o = this.options,
  9348. that = this,
  9349. animate = ( !this._animateOff ) ? o.animate : false,
  9350. _set = {};
  9351. if ( this.options.values && this.options.values.length ) {
  9352. this.handles.each(function( i ) {
  9353. valPercent = ( that.values(i) - that._valueMin() ) / ( that._valueMax() - that._valueMin() ) * 100;
  9354. _set[ that.orientation === "horizontal" ? "left" : "bottom" ] = valPercent + "%";
  9355. $( this ).stop( 1, 1 )[ animate ? "animate" : "css" ]( _set, o.animate );
  9356. if ( that.options.range === true ) {
  9357. if ( that.orientation === "horizontal" ) {
  9358. if ( i === 0 ) {
  9359. that.range.stop( 1, 1 )[ animate ? "animate" : "css" ]( { left: valPercent + "%" }, o.animate );
  9360. }
  9361. if ( i === 1 ) {
  9362. that.range[ animate ? "animate" : "css" ]( { width: ( valPercent - lastValPercent ) + "%" }, { queue: false, duration: o.animate } );
  9363. }
  9364. } else {
  9365. if ( i === 0 ) {
  9366. that.range.stop( 1, 1 )[ animate ? "animate" : "css" ]( { bottom: ( valPercent ) + "%" }, o.animate );
  9367. }
  9368. if ( i === 1 ) {
  9369. that.range[ animate ? "animate" : "css" ]( { height: ( valPercent - lastValPercent ) + "%" }, { queue: false, duration: o.animate } );
  9370. }
  9371. }
  9372. }
  9373. lastValPercent = valPercent;
  9374. });
  9375. } else {
  9376. value = this.value();
  9377. valueMin = this._valueMin();
  9378. valueMax = this._valueMax();
  9379. valPercent = ( valueMax !== valueMin ) ?
  9380. ( value - valueMin ) / ( valueMax - valueMin ) * 100 :
  9381. 0;
  9382. _set[ this.orientation === "horizontal" ? "left" : "bottom" ] = valPercent + "%";
  9383. this.handle.stop( 1, 1 )[ animate ? "animate" : "css" ]( _set, o.animate );
  9384. if ( oRange === "min" && this.orientation === "horizontal" ) {
  9385. this.range.stop( 1, 1 )[ animate ? "animate" : "css" ]( { width: valPercent + "%" }, o.animate );
  9386. }
  9387. if ( oRange === "max" && this.orientation === "horizontal" ) {
  9388. this.range[ animate ? "animate" : "css" ]( { width: ( 100 - valPercent ) + "%" }, { queue: false, duration: o.animate } );
  9389. }
  9390. if ( oRange === "min" && this.orientation === "vertical" ) {
  9391. this.range.stop( 1, 1 )[ animate ? "animate" : "css" ]( { height: valPercent + "%" }, o.animate );
  9392. }
  9393. if ( oRange === "max" && this.orientation === "vertical" ) {
  9394. this.range[ animate ? "animate" : "css" ]( { height: ( 100 - valPercent ) + "%" }, { queue: false, duration: o.animate } );
  9395. }
  9396. }
  9397. },
  9398. _handleEvents: {
  9399. keydown: function( event ) {
  9400. /*jshint maxcomplexity:25*/
  9401. var allowed, curVal, newVal, step,
  9402. index = $( event.target ).data( "ui-slider-handle-index" );
  9403. switch ( event.keyCode ) {
  9404. case $.ui.keyCode.HOME:
  9405. case $.ui.keyCode.END:
  9406. case $.ui.keyCode.PAGE_UP:
  9407. case $.ui.keyCode.PAGE_DOWN:
  9408. case $.ui.keyCode.UP:
  9409. case $.ui.keyCode.RIGHT:
  9410. case $.ui.keyCode.DOWN:
  9411. case $.ui.keyCode.LEFT:
  9412. event.preventDefault();
  9413. if ( !this._keySliding ) {
  9414. this._keySliding = true;
  9415. $( event.target ).addClass( "ui-state-active" );
  9416. allowed = this._start( event, index );
  9417. if ( allowed === false ) {
  9418. return;
  9419. }
  9420. }
  9421. break;
  9422. }
  9423. step = this.options.step;
  9424. if ( this.options.values && this.options.values.length ) {
  9425. curVal = newVal = this.values( index );
  9426. } else {
  9427. curVal = newVal = this.value();
  9428. }
  9429. switch ( event.keyCode ) {
  9430. case $.ui.keyCode.HOME:
  9431. newVal = this._valueMin();
  9432. break;
  9433. case $.ui.keyCode.END:
  9434. newVal = this._valueMax();
  9435. break;
  9436. case $.ui.keyCode.PAGE_UP:
  9437. newVal = this._trimAlignValue( curVal + ( (this._valueMax() - this._valueMin()) / numPages ) );
  9438. break;
  9439. case $.ui.keyCode.PAGE_DOWN:
  9440. newVal = this._trimAlignValue( curVal - ( (this._valueMax() - this._valueMin()) / numPages ) );
  9441. break;
  9442. case $.ui.keyCode.UP:
  9443. case $.ui.keyCode.RIGHT:
  9444. if ( curVal === this._valueMax() ) {
  9445. return;
  9446. }
  9447. newVal = this._trimAlignValue( curVal + step );
  9448. break;
  9449. case $.ui.keyCode.DOWN:
  9450. case $.ui.keyCode.LEFT:
  9451. if ( curVal === this._valueMin() ) {
  9452. return;
  9453. }
  9454. newVal = this._trimAlignValue( curVal - step );
  9455. break;
  9456. }
  9457. this._slide( event, index, newVal );
  9458. },
  9459. click: function( event ) {
  9460. event.preventDefault();
  9461. },
  9462. keyup: function( event ) {
  9463. var index = $( event.target ).data( "ui-slider-handle-index" );
  9464. if ( this._keySliding ) {
  9465. this._keySliding = false;
  9466. this._stop( event, index );
  9467. this._change( event, index );
  9468. $( event.target ).removeClass( "ui-state-active" );
  9469. }
  9470. }
  9471. }
  9472. });
  9473. }(jQuery));
  9474. (function( $ ) {
  9475. function modifier( fn ) {
  9476. return function() {
  9477. var previous = this.element.val();
  9478. fn.apply( this, arguments );
  9479. this._refresh();
  9480. if ( previous !== this.element.val() ) {
  9481. this._trigger( "change" );
  9482. }
  9483. };
  9484. }
  9485. $.widget( "ui.spinner", {
  9486. version: "1.10.3",
  9487. defaultElement: "<input>",
  9488. widgetEventPrefix: "spin",
  9489. options: {
  9490. culture: null,
  9491. icons: {
  9492. down: "ui-icon-triangle-1-s",
  9493. up: "ui-icon-triangle-1-n"
  9494. },
  9495. incremental: true,
  9496. max: null,
  9497. min: null,
  9498. numberFormat: null,
  9499. page: 10,
  9500. step: 1,
  9501. change: null,
  9502. spin: null,
  9503. start: null,
  9504. stop: null
  9505. },
  9506. _create: function() {
  9507. // handle string values that need to be parsed
  9508. this._setOption( "max", this.options.max );
  9509. this._setOption( "min", this.options.min );
  9510. this._setOption( "step", this.options.step );
  9511. // format the value, but don't constrain
  9512. this._value( this.element.val(), true );
  9513. this._draw();
  9514. this._on( this._events );
  9515. this._refresh();
  9516. // turning off autocomplete prevents the browser from remembering the
  9517. // value when navigating through history, so we re-enable autocomplete
  9518. // if the page is unloaded before the widget is destroyed. #7790
  9519. this._on( this.window, {
  9520. beforeunload: function() {
  9521. this.element.removeAttr( "autocomplete" );
  9522. }
  9523. });
  9524. },
  9525. _getCreateOptions: function() {
  9526. var options = {},
  9527. element = this.element;
  9528. $.each( [ "min", "max", "step" ], function( i, option ) {
  9529. var value = element.attr( option );
  9530. if ( value !== undefined && value.length ) {
  9531. options[ option ] = value;
  9532. }
  9533. });
  9534. return options;
  9535. },
  9536. _events: {
  9537. keydown: function( event ) {
  9538. if ( this._start( event ) && this._keydown( event ) ) {
  9539. event.preventDefault();
  9540. }
  9541. },
  9542. keyup: "_stop",
  9543. focus: function() {
  9544. this.previous = this.element.val();
  9545. },
  9546. blur: function( event ) {
  9547. if ( this.cancelBlur ) {
  9548. delete this.cancelBlur;
  9549. return;
  9550. }
  9551. this._stop();
  9552. this._refresh();
  9553. if ( this.previous !== this.element.val() ) {
  9554. this._trigger( "change", event );
  9555. }
  9556. },
  9557. mousewheel: function( event, delta ) {
  9558. if ( !delta ) {
  9559. return;
  9560. }
  9561. if ( !this.spinning && !this._start( event ) ) {
  9562. return false;
  9563. }
  9564. this._spin( (delta > 0 ? 1 : -1) * this.options.step, event );
  9565. clearTimeout( this.mousewheelTimer );
  9566. this.mousewheelTimer = this._delay(function() {
  9567. if ( this.spinning ) {
  9568. this._stop( event );
  9569. }
  9570. }, 100 );
  9571. event.preventDefault();
  9572. },
  9573. "mousedown .ui-spinner-button": function( event ) {
  9574. var previous;
  9575. // We never want the buttons to have focus; whenever the user is
  9576. // interacting with the spinner, the focus should be on the input.
  9577. // If the input is focused then this.previous is properly set from
  9578. // when the input first received focus. If the input is not focused
  9579. // then we need to set this.previous based on the value before spinning.
  9580. previous = this.element[0] === this.document[0].activeElement ?
  9581. this.previous : this.element.val();
  9582. function checkFocus() {
  9583. var isActive = this.element[0] === this.document[0].activeElement;
  9584. if ( !isActive ) {
  9585. this.element.focus();
  9586. this.previous = previous;
  9587. // support: IE
  9588. // IE sets focus asynchronously, so we need to check if focus
  9589. // moved off of the input because the user clicked on the button.
  9590. this._delay(function() {
  9591. this.previous = previous;
  9592. });
  9593. }
  9594. }
  9595. // ensure focus is on (or stays on) the text field
  9596. event.preventDefault();
  9597. checkFocus.call( this );
  9598. // support: IE
  9599. // IE doesn't prevent moving focus even with event.preventDefault()
  9600. // so we set a flag to know when we should ignore the blur event
  9601. // and check (again) if focus moved off of the input.
  9602. this.cancelBlur = true;
  9603. this._delay(function() {
  9604. delete this.cancelBlur;
  9605. checkFocus.call( this );
  9606. });
  9607. if ( this._start( event ) === false ) {
  9608. return;
  9609. }
  9610. this._repeat( null, $( event.currentTarget ).hasClass( "ui-spinner-up" ) ? 1 : -1, event );
  9611. },
  9612. "mouseup .ui-spinner-button": "_stop",
  9613. "mouseenter .ui-spinner-button": function( event ) {
  9614. // button will add ui-state-active if mouse was down while mouseleave and kept down
  9615. if ( !$( event.currentTarget ).hasClass( "ui-state-active" ) ) {
  9616. return;
  9617. }
  9618. if ( this._start( event ) === false ) {
  9619. return false;
  9620. }
  9621. this._repeat( null, $( event.currentTarget ).hasClass( "ui-spinner-up" ) ? 1 : -1, event );
  9622. },
  9623. // TODO: do we really want to consider this a stop?
  9624. // shouldn't we just stop the repeater and wait until mouseup before
  9625. // we trigger the stop event?
  9626. "mouseleave .ui-spinner-button": "_stop"
  9627. },
  9628. _draw: function() {
  9629. var uiSpinner = this.uiSpinner = this.element
  9630. .addClass( "ui-spinner-input" )
  9631. .attr( "autocomplete", "off" )
  9632. .wrap( this._uiSpinnerHtml() )
  9633. .parent()
  9634. // add buttons
  9635. .append( this._buttonHtml() );
  9636. this.element.attr( "role", "spinbutton" );
  9637. // button bindings
  9638. this.buttons = uiSpinner.find( ".ui-spinner-button" )
  9639. .attr( "tabIndex", -1 )
  9640. .button()
  9641. .removeClass( "ui-corner-all" );
  9642. // IE 6 doesn't understand height: 50% for the buttons
  9643. // unless the wrapper has an explicit height
  9644. if ( this.buttons.height() > Math.ceil( uiSpinner.height() * 0.5 ) &&
  9645. uiSpinner.height() > 0 ) {
  9646. uiSpinner.height( uiSpinner.height() );
  9647. }
  9648. // disable spinner if element was already disabled
  9649. if ( this.options.disabled ) {
  9650. this.disable();
  9651. }
  9652. },
  9653. _keydown: function( event ) {
  9654. var options = this.options,
  9655. keyCode = $.ui.keyCode;
  9656. switch ( event.keyCode ) {
  9657. case keyCode.UP:
  9658. this._repeat( null, 1, event );
  9659. return true;
  9660. case keyCode.DOWN:
  9661. this._repeat( null, -1, event );
  9662. return true;
  9663. case keyCode.PAGE_UP:
  9664. this._repeat( null, options.page, event );
  9665. return true;
  9666. case keyCode.PAGE_DOWN:
  9667. this._repeat( null, -options.page, event );
  9668. return true;
  9669. }
  9670. return false;
  9671. },
  9672. _uiSpinnerHtml: function() {
  9673. return "<span class='ui-spinner ui-widget ui-widget-content ui-corner-all'></span>";
  9674. },
  9675. _buttonHtml: function() {
  9676. return "" +
  9677. "<a class='ui-spinner-button ui-spinner-up ui-corner-tr'>" +
  9678. "<span class='ui-icon " + this.options.icons.up + "'>&#9650;</span>" +
  9679. "</a>" +
  9680. "<a class='ui-spinner-button ui-spinner-down ui-corner-br'>" +
  9681. "<span class='ui-icon " + this.options.icons.down + "'>&#9660;</span>" +
  9682. "</a>";
  9683. },
  9684. _start: function( event ) {
  9685. if ( !this.spinning && this._trigger( "start", event ) === false ) {
  9686. return false;
  9687. }
  9688. if ( !this.counter ) {
  9689. this.counter = 1;
  9690. }
  9691. this.spinning = true;
  9692. return true;
  9693. },
  9694. _repeat: function( i, steps, event ) {
  9695. i = i || 500;
  9696. clearTimeout( this.timer );
  9697. this.timer = this._delay(function() {
  9698. this._repeat( 40, steps, event );
  9699. }, i );
  9700. this._spin( steps * this.options.step, event );
  9701. },
  9702. _spin: function( step, event ) {
  9703. var value = this.value() || 0;
  9704. if ( !this.counter ) {
  9705. this.counter = 1;
  9706. }
  9707. value = this._adjustValue( value + step * this._increment( this.counter ) );
  9708. if ( !this.spinning || this._trigger( "spin", event, { value: value } ) !== false) {
  9709. this._value( value );
  9710. this.counter++;
  9711. }
  9712. },
  9713. _increment: function( i ) {
  9714. var incremental = this.options.incremental;
  9715. if ( incremental ) {
  9716. return $.isFunction( incremental ) ?
  9717. incremental( i ) :
  9718. Math.floor( i*i*i/50000 - i*i/500 + 17*i/200 + 1 );
  9719. }
  9720. return 1;
  9721. },
  9722. _precision: function() {
  9723. var precision = this._precisionOf( this.options.step );
  9724. if ( this.options.min !== null ) {
  9725. precision = Math.max( precision, this._precisionOf( this.options.min ) );
  9726. }
  9727. return precision;
  9728. },
  9729. _precisionOf: function( num ) {
  9730. var str = num.toString(),
  9731. decimal = str.indexOf( "." );
  9732. return decimal === -1 ? 0 : str.length - decimal - 1;
  9733. },
  9734. _adjustValue: function( value ) {
  9735. var base, aboveMin,
  9736. options = this.options;
  9737. // make sure we're at a valid step
  9738. // - find out where we are relative to the base (min or 0)
  9739. base = options.min !== null ? options.min : 0;
  9740. aboveMin = value - base;
  9741. // - round to the nearest step
  9742. aboveMin = Math.round(aboveMin / options.step) * options.step;
  9743. // - rounding is based on 0, so adjust back to our base
  9744. value = base + aboveMin;
  9745. // fix precision from bad JS floating point math
  9746. value = parseFloat( value.toFixed( this._precision() ) );
  9747. // clamp the value
  9748. if ( options.max !== null && value > options.max) {
  9749. return options.max;
  9750. }
  9751. if ( options.min !== null && value < options.min ) {
  9752. return options.min;
  9753. }
  9754. return value;
  9755. },
  9756. _stop: function( event ) {
  9757. if ( !this.spinning ) {
  9758. return;
  9759. }
  9760. clearTimeout( this.timer );
  9761. clearTimeout( this.mousewheelTimer );
  9762. this.counter = 0;
  9763. this.spinning = false;
  9764. this._trigger( "stop", event );
  9765. },
  9766. _setOption: function( key, value ) {
  9767. if ( key === "culture" || key === "numberFormat" ) {
  9768. var prevValue = this._parse( this.element.val() );
  9769. this.options[ key ] = value;
  9770. this.element.val( this._format( prevValue ) );
  9771. return;
  9772. }
  9773. if ( key === "max" || key === "min" || key === "step" ) {
  9774. if ( typeof value === "string" ) {
  9775. value = this._parse( value );
  9776. }
  9777. }
  9778. if ( key === "icons" ) {
  9779. this.buttons.first().find( ".ui-icon" )
  9780. .removeClass( this.options.icons.up )
  9781. .addClass( value.up );
  9782. this.buttons.last().find( ".ui-icon" )
  9783. .removeClass( this.options.icons.down )
  9784. .addClass( value.down );
  9785. }
  9786. this._super( key, value );
  9787. if ( key === "disabled" ) {
  9788. if ( value ) {
  9789. this.element.prop( "disabled", true );
  9790. this.buttons.button( "disable" );
  9791. } else {
  9792. this.element.prop( "disabled", false );
  9793. this.buttons.button( "enable" );
  9794. }
  9795. }
  9796. },
  9797. _setOptions: modifier(function( options ) {
  9798. this._super( options );
  9799. this._value( this.element.val() );
  9800. }),
  9801. _parse: function( val ) {
  9802. if ( typeof val === "string" && val !== "" ) {
  9803. val = window.Globalize && this.options.numberFormat ?
  9804. Globalize.parseFloat( val, 10, this.options.culture ) : +val;
  9805. }
  9806. return val === "" || isNaN( val ) ? null : val;
  9807. },
  9808. _format: function( value ) {
  9809. if ( value === "" ) {
  9810. return "";
  9811. }
  9812. return window.Globalize && this.options.numberFormat ?
  9813. Globalize.format( value, this.options.numberFormat, this.options.culture ) :
  9814. value;
  9815. },
  9816. _refresh: function() {
  9817. this.element.attr({
  9818. "aria-valuemin": this.options.min,
  9819. "aria-valuemax": this.options.max,
  9820. // TODO: what should we do with values that can't be parsed?
  9821. "aria-valuenow": this._parse( this.element.val() )
  9822. });
  9823. },
  9824. // update the value without triggering change
  9825. _value: function( value, allowAny ) {
  9826. var parsed;
  9827. if ( value !== "" ) {
  9828. parsed = this._parse( value );
  9829. if ( parsed !== null ) {
  9830. if ( !allowAny ) {
  9831. parsed = this._adjustValue( parsed );
  9832. }
  9833. value = this._format( parsed );
  9834. }
  9835. }
  9836. this.element.val( value );
  9837. this._refresh();
  9838. },
  9839. _destroy: function() {
  9840. this.element
  9841. .removeClass( "ui-spinner-input" )
  9842. .prop( "disabled", false )
  9843. .removeAttr( "autocomplete" )
  9844. .removeAttr( "role" )
  9845. .removeAttr( "aria-valuemin" )
  9846. .removeAttr( "aria-valuemax" )
  9847. .removeAttr( "aria-valuenow" );
  9848. this.uiSpinner.replaceWith( this.element );
  9849. },
  9850. stepUp: modifier(function( steps ) {
  9851. this._stepUp( steps );
  9852. }),
  9853. _stepUp: function( steps ) {
  9854. if ( this._start() ) {
  9855. this._spin( (steps || 1) * this.options.step );
  9856. this._stop();
  9857. }
  9858. },
  9859. stepDown: modifier(function( steps ) {
  9860. this._stepDown( steps );
  9861. }),
  9862. _stepDown: function( steps ) {
  9863. if ( this._start() ) {
  9864. this._spin( (steps || 1) * -this.options.step );
  9865. this._stop();
  9866. }
  9867. },
  9868. pageUp: modifier(function( pages ) {
  9869. this._stepUp( (pages || 1) * this.options.page );
  9870. }),
  9871. pageDown: modifier(function( pages ) {
  9872. this._stepDown( (pages || 1) * this.options.page );
  9873. }),
  9874. value: function( newVal ) {
  9875. if ( !arguments.length ) {
  9876. return this._parse( this.element.val() );
  9877. }
  9878. modifier( this._value ).call( this, newVal );
  9879. },
  9880. widget: function() {
  9881. return this.uiSpinner;
  9882. }
  9883. });
  9884. }( jQuery ) );
  9885. (function( $, undefined ) {
  9886. var tabId = 0,
  9887. rhash = /#.*$/;
  9888. function getNextTabId() {
  9889. return ++tabId;
  9890. }
  9891. function isLocal( anchor ) {
  9892. return anchor.hash.length > 1 &&
  9893. decodeURIComponent( anchor.href.replace( rhash, "" ) ) ===
  9894. decodeURIComponent( location.href.replace( rhash, "" ) );
  9895. }
  9896. $.widget( "ui.tabs", {
  9897. version: "1.10.3",
  9898. delay: 300,
  9899. options: {
  9900. active: null,
  9901. collapsible: false,
  9902. event: "click",
  9903. heightStyle: "content",
  9904. hide: null,
  9905. show: null,
  9906. // callbacks
  9907. activate: null,
  9908. beforeActivate: null,
  9909. beforeLoad: null,
  9910. load: null
  9911. },
  9912. _create: function() {
  9913. var that = this,
  9914. options = this.options;
  9915. this.running = false;
  9916. this.element
  9917. .addClass( "ui-tabs ui-widget ui-widget-content ui-corner-all" )
  9918. .toggleClass( "ui-tabs-collapsible", options.collapsible )
  9919. // Prevent users from focusing disabled tabs via click
  9920. .delegate( ".ui-tabs-nav > li", "mousedown" + this.eventNamespace, function( event ) {
  9921. if ( $( this ).is( ".ui-state-disabled" ) ) {
  9922. event.preventDefault();
  9923. }
  9924. })
  9925. // support: IE <9
  9926. // Preventing the default action in mousedown doesn't prevent IE
  9927. // from focusing the element, so if the anchor gets focused, blur.
  9928. // We don't have to worry about focusing the previously focused
  9929. // element since clicking on a non-focusable element should focus
  9930. // the body anyway.
  9931. .delegate( ".ui-tabs-anchor", "focus" + this.eventNamespace, function() {
  9932. if ( $( this ).closest( "li" ).is( ".ui-state-disabled" ) ) {
  9933. this.blur();
  9934. }
  9935. });
  9936. this._processTabs();
  9937. options.active = this._initialActive();
  9938. // Take disabling tabs via class attribute from HTML
  9939. // into account and update option properly.
  9940. if ( $.isArray( options.disabled ) ) {
  9941. options.disabled = $.unique( options.disabled.concat(
  9942. $.map( this.tabs.filter( ".ui-state-disabled" ), function( li ) {
  9943. return that.tabs.index( li );
  9944. })
  9945. ) ).sort();
  9946. }
  9947. // check for length avoids error when initializing empty list
  9948. if ( this.options.active !== false && this.anchors.length ) {
  9949. this.active = this._findActive( options.active );
  9950. } else {
  9951. this.active = $();
  9952. }
  9953. this._refresh();
  9954. if ( this.active.length ) {
  9955. this.load( options.active );
  9956. }
  9957. },
  9958. _initialActive: function() {
  9959. var active = this.options.active,
  9960. collapsible = this.options.collapsible,
  9961. locationHash = location.hash.substring( 1 );
  9962. if ( active === null ) {
  9963. // check the fragment identifier in the URL
  9964. if ( locationHash ) {
  9965. this.tabs.each(function( i, tab ) {
  9966. if ( $( tab ).attr( "aria-controls" ) === locationHash ) {
  9967. active = i;
  9968. return false;
  9969. }
  9970. });
  9971. }
  9972. // check for a tab marked active via a class
  9973. if ( active === null ) {
  9974. active = this.tabs.index( this.tabs.filter( ".ui-tabs-active" ) );
  9975. }
  9976. // no active tab, set to false
  9977. if ( active === null || active === -1 ) {
  9978. active = this.tabs.length ? 0 : false;
  9979. }
  9980. }
  9981. // handle numbers: negative, out of range
  9982. if ( active !== false ) {
  9983. active = this.tabs.index( this.tabs.eq( active ) );
  9984. if ( active === -1 ) {
  9985. active = collapsible ? false : 0;
  9986. }
  9987. }
  9988. // don't allow collapsible: false and active: false
  9989. if ( !collapsible && active === false && this.anchors.length ) {
  9990. active = 0;
  9991. }
  9992. return active;
  9993. },
  9994. _getCreateEventData: function() {
  9995. return {
  9996. tab: this.active,
  9997. panel: !this.active.length ? $() : this._getPanelForTab( this.active )
  9998. };
  9999. },
  10000. _tabKeydown: function( event ) {
  10001. /*jshint maxcomplexity:15*/
  10002. var focusedTab = $( this.document[0].activeElement ).closest( "li" ),
  10003. selectedIndex = this.tabs.index( focusedTab ),
  10004. goingForward = true;
  10005. if ( this._handlePageNav( event ) ) {
  10006. return;
  10007. }
  10008. switch ( event.keyCode ) {
  10009. case $.ui.keyCode.RIGHT:
  10010. case $.ui.keyCode.DOWN:
  10011. selectedIndex++;
  10012. break;
  10013. case $.ui.keyCode.UP:
  10014. case $.ui.keyCode.LEFT:
  10015. goingForward = false;
  10016. selectedIndex--;
  10017. break;
  10018. case $.ui.keyCode.END:
  10019. selectedIndex = this.anchors.length - 1;
  10020. break;
  10021. case $.ui.keyCode.HOME:
  10022. selectedIndex = 0;
  10023. break;
  10024. case $.ui.keyCode.SPACE:
  10025. // Activate only, no collapsing
  10026. event.preventDefault();
  10027. clearTimeout( this.activating );
  10028. this._activate( selectedIndex );
  10029. return;
  10030. case $.ui.keyCode.ENTER:
  10031. // Toggle (cancel delayed activation, allow collapsing)
  10032. event.preventDefault();
  10033. clearTimeout( this.activating );
  10034. // Determine if we should collapse or activate
  10035. this._activate( selectedIndex === this.options.active ? false : selectedIndex );
  10036. return;
  10037. default:
  10038. return;
  10039. }
  10040. // Focus the appropriate tab, based on which key was pressed
  10041. event.preventDefault();
  10042. clearTimeout( this.activating );
  10043. selectedIndex = this._focusNextTab( selectedIndex, goingForward );
  10044. // Navigating with control key will prevent automatic activation
  10045. if ( !event.ctrlKey ) {
  10046. // Update aria-selected immediately so that AT think the tab is already selected.
  10047. // Otherwise AT may confuse the user by stating that they need to activate the tab,
  10048. // but the tab will already be activated by the time the announcement finishes.
  10049. focusedTab.attr( "aria-selected", "false" );
  10050. this.tabs.eq( selectedIndex ).attr( "aria-selected", "true" );
  10051. this.activating = this._delay(function() {
  10052. this.option( "active", selectedIndex );
  10053. }, this.delay );
  10054. }
  10055. },
  10056. _panelKeydown: function( event ) {
  10057. if ( this._handlePageNav( event ) ) {
  10058. return;
  10059. }
  10060. // Ctrl+up moves focus to the current tab
  10061. if ( event.ctrlKey && event.keyCode === $.ui.keyCode.UP ) {
  10062. event.preventDefault();
  10063. this.active.focus();
  10064. }
  10065. },
  10066. // Alt+page up/down moves focus to the previous/next tab (and activates)
  10067. _handlePageNav: function( event ) {
  10068. if ( event.altKey && event.keyCode === $.ui.keyCode.PAGE_UP ) {
  10069. this._activate( this._focusNextTab( this.options.active - 1, false ) );
  10070. return true;
  10071. }
  10072. if ( event.altKey && event.keyCode === $.ui.keyCode.PAGE_DOWN ) {
  10073. this._activate( this._focusNextTab( this.options.active + 1, true ) );
  10074. return true;
  10075. }
  10076. },
  10077. _findNextTab: function( index, goingForward ) {
  10078. var lastTabIndex = this.tabs.length - 1;
  10079. function constrain() {
  10080. if ( index > lastTabIndex ) {
  10081. index = 0;
  10082. }
  10083. if ( index < 0 ) {
  10084. index = lastTabIndex;
  10085. }
  10086. return index;
  10087. }
  10088. while ( $.inArray( constrain(), this.options.disabled ) !== -1 ) {
  10089. index = goingForward ? index + 1 : index - 1;
  10090. }
  10091. return index;
  10092. },
  10093. _focusNextTab: function( index, goingForward ) {
  10094. index = this._findNextTab( index, goingForward );
  10095. this.tabs.eq( index ).focus();
  10096. return index;
  10097. },
  10098. _setOption: function( key, value ) {
  10099. if ( key === "active" ) {
  10100. // _activate() will handle invalid values and update this.options
  10101. this._activate( value );
  10102. return;
  10103. }
  10104. if ( key === "disabled" ) {
  10105. // don't use the widget factory's disabled handling
  10106. this._setupDisabled( value );
  10107. return;
  10108. }
  10109. this._super( key, value);
  10110. if ( key === "collapsible" ) {
  10111. this.element.toggleClass( "ui-tabs-collapsible", value );
  10112. // Setting collapsible: false while collapsed; open first panel
  10113. if ( !value && this.options.active === false ) {
  10114. this._activate( 0 );
  10115. }
  10116. }
  10117. if ( key === "event" ) {
  10118. this._setupEvents( value );
  10119. }
  10120. if ( key === "heightStyle" ) {
  10121. this._setupHeightStyle( value );
  10122. }
  10123. },
  10124. _tabId: function( tab ) {
  10125. return tab.attr( "aria-controls" ) || "ui-tabs-" + getNextTabId();
  10126. },
  10127. _sanitizeSelector: function( hash ) {
  10128. return hash ? hash.replace( /[!"$%&'()*+,.\/:;<=>?@\[\]\^`{|}~]/g, "\\$&" ) : "";
  10129. },
  10130. refresh: function() {
  10131. var options = this.options,
  10132. lis = this.tablist.children( ":has(a[href])" );
  10133. // get disabled tabs from class attribute from HTML
  10134. // this will get converted to a boolean if needed in _refresh()
  10135. options.disabled = $.map( lis.filter( ".ui-state-disabled" ), function( tab ) {
  10136. return lis.index( tab );
  10137. });
  10138. this._processTabs();
  10139. // was collapsed or no tabs
  10140. if ( options.active === false || !this.anchors.length ) {
  10141. options.active = false;
  10142. this.active = $();
  10143. // was active, but active tab is gone
  10144. } else if ( this.active.length && !$.contains( this.tablist[ 0 ], this.active[ 0 ] ) ) {
  10145. // all remaining tabs are disabled
  10146. if ( this.tabs.length === options.disabled.length ) {
  10147. options.active = false;
  10148. this.active = $();
  10149. // activate previous tab
  10150. } else {
  10151. this._activate( this._findNextTab( Math.max( 0, options.active - 1 ), false ) );
  10152. }
  10153. // was active, active tab still exists
  10154. } else {
  10155. // make sure active index is correct
  10156. options.active = this.tabs.index( this.active );
  10157. }
  10158. this._refresh();
  10159. },
  10160. _refresh: function() {
  10161. this._setupDisabled( this.options.disabled );
  10162. this._setupEvents( this.options.event );
  10163. this._setupHeightStyle( this.options.heightStyle );
  10164. this.tabs.not( this.active ).attr({
  10165. "aria-selected": "false",
  10166. tabIndex: -1
  10167. });
  10168. this.panels.not( this._getPanelForTab( this.active ) )
  10169. .hide()
  10170. .attr({
  10171. "aria-expanded": "false",
  10172. "aria-hidden": "true"
  10173. });
  10174. // Make sure one tab is in the tab order
  10175. if ( !this.active.length ) {
  10176. this.tabs.eq( 0 ).attr( "tabIndex", 0 );
  10177. } else {
  10178. this.active
  10179. .addClass( "ui-tabs-active ui-state-active" )
  10180. .attr({
  10181. "aria-selected": "true",
  10182. tabIndex: 0
  10183. });
  10184. this._getPanelForTab( this.active )
  10185. .show()
  10186. .attr({
  10187. "aria-expanded": "true",
  10188. "aria-hidden": "false"
  10189. });
  10190. }
  10191. },
  10192. _processTabs: function() {
  10193. var that = this;
  10194. this.tablist = this._getList()
  10195. .addClass( "ui-tabs-nav ui-helper-reset ui-helper-clearfix ui-widget-header ui-corner-all" )
  10196. .attr( "role", "tablist" );
  10197. this.tabs = this.tablist.find( "> li:has(a[href])" )
  10198. .addClass( "ui-state-default ui-corner-top" )
  10199. .attr({
  10200. role: "tab",
  10201. tabIndex: -1
  10202. });
  10203. this.anchors = this.tabs.map(function() {
  10204. return $( "a", this )[ 0 ];
  10205. })
  10206. .addClass( "ui-tabs-anchor" )
  10207. .attr({
  10208. role: "presentation",
  10209. tabIndex: -1
  10210. });
  10211. this.panels = $();
  10212. this.anchors.each(function( i, anchor ) {
  10213. var selector, panel, panelId,
  10214. anchorId = $( anchor ).uniqueId().attr( "id" ),
  10215. tab = $( anchor ).closest( "li" ),
  10216. originalAriaControls = tab.attr( "aria-controls" );
  10217. // inline tab
  10218. if ( isLocal( anchor ) ) {
  10219. selector = anchor.hash;
  10220. panel = that.element.find( that._sanitizeSelector( selector ) );
  10221. // remote tab
  10222. } else {
  10223. panelId = that._tabId( tab );
  10224. selector = "#" + panelId;
  10225. panel = that.element.find( selector );
  10226. if ( !panel.length ) {
  10227. panel = that._createPanel( panelId );
  10228. panel.insertAfter( that.panels[ i - 1 ] || that.tablist );
  10229. }
  10230. panel.attr( "aria-live", "polite" );
  10231. }
  10232. if ( panel.length) {
  10233. that.panels = that.panels.add( panel );
  10234. }
  10235. if ( originalAriaControls ) {
  10236. tab.data( "ui-tabs-aria-controls", originalAriaControls );
  10237. }
  10238. tab.attr({
  10239. "aria-controls": selector.substring( 1 ),
  10240. "aria-labelledby": anchorId
  10241. });
  10242. panel.attr( "aria-labelledby", anchorId );
  10243. });
  10244. this.panels
  10245. .addClass( "ui-tabs-panel ui-widget-content ui-corner-bottom" )
  10246. .attr( "role", "tabpanel" );
  10247. },
  10248. // allow overriding how to find the list for rare usage scenarios (#7715)
  10249. _getList: function() {
  10250. return this.element.find( "ol,ul" ).eq( 0 );
  10251. },
  10252. _createPanel: function( id ) {
  10253. return $( "<div>" )
  10254. .attr( "id", id )
  10255. .addClass( "ui-tabs-panel ui-widget-content ui-corner-bottom" )
  10256. .data( "ui-tabs-destroy", true );
  10257. },
  10258. _setupDisabled: function( disabled ) {
  10259. if ( $.isArray( disabled ) ) {
  10260. if ( !disabled.length ) {
  10261. disabled = false;
  10262. } else if ( disabled.length === this.anchors.length ) {
  10263. disabled = true;
  10264. }
  10265. }
  10266. // disable tabs
  10267. for ( var i = 0, li; ( li = this.tabs[ i ] ); i++ ) {
  10268. if ( disabled === true || $.inArray( i, disabled ) !== -1 ) {
  10269. $( li )
  10270. .addClass( "ui-state-disabled" )
  10271. .attr( "aria-disabled", "true" );
  10272. } else {
  10273. $( li )
  10274. .removeClass( "ui-state-disabled" )
  10275. .removeAttr( "aria-disabled" );
  10276. }
  10277. }
  10278. this.options.disabled = disabled;
  10279. },
  10280. _setupEvents: function( event ) {
  10281. var events = {
  10282. click: function( event ) {
  10283. event.preventDefault();
  10284. }
  10285. };
  10286. if ( event ) {
  10287. $.each( event.split(" "), function( index, eventName ) {
  10288. events[ eventName ] = "_eventHandler";
  10289. });
  10290. }
  10291. this._off( this.anchors.add( this.tabs ).add( this.panels ) );
  10292. this._on( this.anchors, events );
  10293. this._on( this.tabs, { keydown: "_tabKeydown" } );
  10294. this._on( this.panels, { keydown: "_panelKeydown" } );
  10295. this._focusable( this.tabs );
  10296. this._hoverable( this.tabs );
  10297. },
  10298. _setupHeightStyle: function( heightStyle ) {
  10299. var maxHeight,
  10300. parent = this.element.parent();
  10301. if ( heightStyle === "fill" ) {
  10302. maxHeight = parent.height();
  10303. maxHeight -= this.element.outerHeight() - this.element.height();
  10304. this.element.siblings( ":visible" ).each(function() {
  10305. var elem = $( this ),
  10306. position = elem.css( "position" );
  10307. if ( position === "absolute" || position === "fixed" ) {
  10308. return;
  10309. }
  10310. maxHeight -= elem.outerHeight( true );
  10311. });
  10312. this.element.children().not( this.panels ).each(function() {
  10313. maxHeight -= $( this ).outerHeight( true );
  10314. });
  10315. this.panels.each(function() {
  10316. $( this ).height( Math.max( 0, maxHeight -
  10317. $( this ).innerHeight() + $( this ).height() ) );
  10318. })
  10319. .css( "overflow", "auto" );
  10320. } else if ( heightStyle === "auto" ) {
  10321. maxHeight = 0;
  10322. this.panels.each(function() {
  10323. maxHeight = Math.max( maxHeight, $( this ).height( "" ).height() );
  10324. }).height( maxHeight );
  10325. }
  10326. },
  10327. _eventHandler: function( event ) {
  10328. var options = this.options,
  10329. active = this.active,
  10330. anchor = $( event.currentTarget ),
  10331. tab = anchor.closest( "li" ),
  10332. clickedIsActive = tab[ 0 ] === active[ 0 ],
  10333. collapsing = clickedIsActive && options.collapsible,
  10334. toShow = collapsing ? $() : this._getPanelForTab( tab ),
  10335. toHide = !active.length ? $() : this._getPanelForTab( active ),
  10336. eventData = {
  10337. oldTab: active,
  10338. oldPanel: toHide,
  10339. newTab: collapsing ? $() : tab,
  10340. newPanel: toShow
  10341. };
  10342. event.preventDefault();
  10343. if ( tab.hasClass( "ui-state-disabled" ) ||
  10344. // tab is already loading
  10345. tab.hasClass( "ui-tabs-loading" ) ||
  10346. // can't switch durning an animation
  10347. this.running ||
  10348. // click on active header, but not collapsible
  10349. ( clickedIsActive && !options.collapsible ) ||
  10350. // allow canceling activation
  10351. ( this._trigger( "beforeActivate", event, eventData ) === false ) ) {
  10352. return;
  10353. }
  10354. options.active = collapsing ? false : this.tabs.index( tab );
  10355. this.active = clickedIsActive ? $() : tab;
  10356. if ( this.xhr ) {
  10357. this.xhr.abort();
  10358. }
  10359. if ( !toHide.length && !toShow.length ) {
  10360. $.error( "jQuery UI Tabs: Mismatching fragment identifier." );
  10361. }
  10362. if ( toShow.length ) {
  10363. this.load( this.tabs.index( tab ), event );
  10364. }
  10365. this._toggle( event, eventData );
  10366. },
  10367. // handles show/hide for selecting tabs
  10368. _toggle: function( event, eventData ) {
  10369. var that = this,
  10370. toShow = eventData.newPanel,
  10371. toHide = eventData.oldPanel;
  10372. this.running = true;
  10373. function complete() {
  10374. that.running = false;
  10375. that._trigger( "activate", event, eventData );
  10376. }
  10377. function show() {
  10378. eventData.newTab.closest( "li" ).addClass( "ui-tabs-active ui-state-active" );
  10379. if ( toShow.length && that.options.show ) {
  10380. that._show( toShow, that.options.show, complete );
  10381. } else {
  10382. toShow.show();
  10383. complete();
  10384. }
  10385. }
  10386. // start out by hiding, then showing, then completing
  10387. if ( toHide.length && this.options.hide ) {
  10388. this._hide( toHide, this.options.hide, function() {
  10389. eventData.oldTab.closest( "li" ).removeClass( "ui-tabs-active ui-state-active" );
  10390. show();
  10391. });
  10392. } else {
  10393. eventData.oldTab.closest( "li" ).removeClass( "ui-tabs-active ui-state-active" );
  10394. toHide.hide();
  10395. show();
  10396. }
  10397. toHide.attr({
  10398. "aria-expanded": "false",
  10399. "aria-hidden": "true"
  10400. });
  10401. eventData.oldTab.attr( "aria-selected", "false" );
  10402. // If we're switching tabs, remove the old tab from the tab order.
  10403. // If we're opening from collapsed state, remove the previous tab from the tab order.
  10404. // If we're collapsing, then keep the collapsing tab in the tab order.
  10405. if ( toShow.length && toHide.length ) {
  10406. eventData.oldTab.attr( "tabIndex", -1 );
  10407. } else if ( toShow.length ) {
  10408. this.tabs.filter(function() {
  10409. return $( this ).attr( "tabIndex" ) === 0;
  10410. })
  10411. .attr( "tabIndex", -1 );
  10412. }
  10413. toShow.attr({
  10414. "aria-expanded": "true",
  10415. "aria-hidden": "false"
  10416. });
  10417. eventData.newTab.attr({
  10418. "aria-selected": "true",
  10419. tabIndex: 0
  10420. });
  10421. },
  10422. _activate: function( index ) {
  10423. var anchor,
  10424. active = this._findActive( index );
  10425. // trying to activate the already active panel
  10426. if ( active[ 0 ] === this.active[ 0 ] ) {
  10427. return;
  10428. }
  10429. // trying to collapse, simulate a click on the current active header
  10430. if ( !active.length ) {
  10431. active = this.active;
  10432. }
  10433. anchor = active.find( ".ui-tabs-anchor" )[ 0 ];
  10434. this._eventHandler({
  10435. target: anchor,
  10436. currentTarget: anchor,
  10437. preventDefault: $.noop
  10438. });
  10439. },
  10440. _findActive: function( index ) {
  10441. return index === false ? $() : this.tabs.eq( index );
  10442. },
  10443. _getIndex: function( index ) {
  10444. // meta-function to give users option to provide a href string instead of a numerical index.
  10445. if ( typeof index === "string" ) {
  10446. index = this.anchors.index( this.anchors.filter( "[href$='" + index + "']" ) );
  10447. }
  10448. return index;
  10449. },
  10450. _destroy: function() {
  10451. if ( this.xhr ) {
  10452. this.xhr.abort();
  10453. }
  10454. this.element.removeClass( "ui-tabs ui-widget ui-widget-content ui-corner-all ui-tabs-collapsible" );
  10455. this.tablist
  10456. .removeClass( "ui-tabs-nav ui-helper-reset ui-helper-clearfix ui-widget-header ui-corner-all" )
  10457. .removeAttr( "role" );
  10458. this.anchors
  10459. .removeClass( "ui-tabs-anchor" )
  10460. .removeAttr( "role" )
  10461. .removeAttr( "tabIndex" )
  10462. .removeUniqueId();
  10463. this.tabs.add( this.panels ).each(function() {
  10464. if ( $.data( this, "ui-tabs-destroy" ) ) {
  10465. $( this ).remove();
  10466. } else {
  10467. $( this )
  10468. .removeClass( "ui-state-default ui-state-active ui-state-disabled " +
  10469. "ui-corner-top ui-corner-bottom ui-widget-content ui-tabs-active ui-tabs-panel" )
  10470. .removeAttr( "tabIndex" )
  10471. .removeAttr( "aria-live" )
  10472. .removeAttr( "aria-busy" )
  10473. .removeAttr( "aria-selected" )
  10474. .removeAttr( "aria-labelledby" )
  10475. .removeAttr( "aria-hidden" )
  10476. .removeAttr( "aria-expanded" )
  10477. .removeAttr( "role" );
  10478. }
  10479. });
  10480. this.tabs.each(function() {
  10481. var li = $( this ),
  10482. prev = li.data( "ui-tabs-aria-controls" );
  10483. if ( prev ) {
  10484. li
  10485. .attr( "aria-controls", prev )
  10486. .removeData( "ui-tabs-aria-controls" );
  10487. } else {
  10488. li.removeAttr( "aria-controls" );
  10489. }
  10490. });
  10491. this.panels.show();
  10492. if ( this.options.heightStyle !== "content" ) {
  10493. this.panels.css( "height", "" );
  10494. }
  10495. },
  10496. enable: function( index ) {
  10497. var disabled = this.options.disabled;
  10498. if ( disabled === false ) {
  10499. return;
  10500. }
  10501. if ( index === undefined ) {
  10502. disabled = false;
  10503. } else {
  10504. index = this._getIndex( index );
  10505. if ( $.isArray( disabled ) ) {
  10506. disabled = $.map( disabled, function( num ) {
  10507. return num !== index ? num : null;
  10508. });
  10509. } else {
  10510. disabled = $.map( this.tabs, function( li, num ) {
  10511. return num !== index ? num : null;
  10512. });
  10513. }
  10514. }
  10515. this._setupDisabled( disabled );
  10516. },
  10517. disable: function( index ) {
  10518. var disabled = this.options.disabled;
  10519. if ( disabled === true ) {
  10520. return;
  10521. }
  10522. if ( index === undefined ) {
  10523. disabled = true;
  10524. } else {
  10525. index = this._getIndex( index );
  10526. if ( $.inArray( index, disabled ) !== -1 ) {
  10527. return;
  10528. }
  10529. if ( $.isArray( disabled ) ) {
  10530. disabled = $.merge( [ index ], disabled ).sort();
  10531. } else {
  10532. disabled = [ index ];
  10533. }
  10534. }
  10535. this._setupDisabled( disabled );
  10536. },
  10537. load: function( index, event ) {
  10538. index = this._getIndex( index );
  10539. var that = this,
  10540. tab = this.tabs.eq( index ),
  10541. anchor = tab.find( ".ui-tabs-anchor" ),
  10542. panel = this._getPanelForTab( tab ),
  10543. eventData = {
  10544. tab: tab,
  10545. panel: panel
  10546. };
  10547. // not remote
  10548. if ( isLocal( anchor[ 0 ] ) ) {
  10549. return;
  10550. }
  10551. this.xhr = $.ajax( this._ajaxSettings( anchor, event, eventData ) );
  10552. // support: jQuery <1.8
  10553. // jQuery <1.8 returns false if the request is canceled in beforeSend,
  10554. // but as of 1.8, $.ajax() always returns a jqXHR object.
  10555. if ( this.xhr && this.xhr.statusText !== "canceled" ) {
  10556. tab.addClass( "ui-tabs-loading" );
  10557. panel.attr( "aria-busy", "true" );
  10558. this.xhr
  10559. .success(function( response ) {
  10560. // support: jQuery <1.8
  10561. // http://bugs.jquery.com/ticket/11778
  10562. setTimeout(function() {
  10563. panel.html( response );
  10564. that._trigger( "load", event, eventData );
  10565. }, 1 );
  10566. })
  10567. .complete(function( jqXHR, status ) {
  10568. // support: jQuery <1.8
  10569. // http://bugs.jquery.com/ticket/11778
  10570. setTimeout(function() {
  10571. if ( status === "abort" ) {
  10572. that.panels.stop( false, true );
  10573. }
  10574. tab.removeClass( "ui-tabs-loading" );
  10575. panel.removeAttr( "aria-busy" );
  10576. if ( jqXHR === that.xhr ) {
  10577. delete that.xhr;
  10578. }
  10579. }, 1 );
  10580. });
  10581. }
  10582. },
  10583. _ajaxSettings: function( anchor, event, eventData ) {
  10584. var that = this;
  10585. return {
  10586. url: anchor.attr( "href" ),
  10587. beforeSend: function( jqXHR, settings ) {
  10588. return that._trigger( "beforeLoad", event,
  10589. $.extend( { jqXHR : jqXHR, ajaxSettings: settings }, eventData ) );
  10590. }
  10591. };
  10592. },
  10593. _getPanelForTab: function( tab ) {
  10594. var id = $( tab ).attr( "aria-controls" );
  10595. return this.element.find( this._sanitizeSelector( "#" + id ) );
  10596. }
  10597. });
  10598. })( jQuery );
  10599. (function( $ ) {
  10600. var increments = 0;
  10601. function addDescribedBy( elem, id ) {
  10602. var describedby = (elem.attr( "aria-describedby" ) || "").split( /\s+/ );
  10603. describedby.push( id );
  10604. elem
  10605. .data( "ui-tooltip-id", id )
  10606. .attr( "aria-describedby", $.trim( describedby.join( " " ) ) );
  10607. }
  10608. function removeDescribedBy( elem ) {
  10609. var id = elem.data( "ui-tooltip-id" ),
  10610. describedby = (elem.attr( "aria-describedby" ) || "").split( /\s+/ ),
  10611. index = $.inArray( id, describedby );
  10612. if ( index !== -1 ) {
  10613. describedby.splice( index, 1 );
  10614. }
  10615. elem.removeData( "ui-tooltip-id" );
  10616. describedby = $.trim( describedby.join( " " ) );
  10617. if ( describedby ) {
  10618. elem.attr( "aria-describedby", describedby );
  10619. } else {
  10620. elem.removeAttr( "aria-describedby" );
  10621. }
  10622. }
  10623. $.widget( "ui.tooltip", {
  10624. version: "1.10.3",
  10625. options: {
  10626. content: function() {
  10627. // support: IE<9, Opera in jQuery <1.7
  10628. // .text() can't accept undefined, so coerce to a string
  10629. var title = $( this ).attr( "title" ) || "";
  10630. // Escape title, since we're going from an attribute to raw HTML
  10631. return $( "<a>" ).text( title ).html();
  10632. },
  10633. hide: true,
  10634. // Disabled elements have inconsistent behavior across browsers (#8661)
  10635. items: "[title]:not([disabled])",
  10636. position: {
  10637. my: "left top+15",
  10638. at: "left bottom",
  10639. collision: "flipfit flip"
  10640. },
  10641. show: true,
  10642. tooltipClass: null,
  10643. track: false,
  10644. // callbacks
  10645. close: null,
  10646. open: null
  10647. },
  10648. _create: function() {
  10649. this._on({
  10650. mouseover: "open",
  10651. focusin: "open"
  10652. });
  10653. // IDs of generated tooltips, needed for destroy
  10654. this.tooltips = {};
  10655. // IDs of parent tooltips where we removed the title attribute
  10656. this.parents = {};
  10657. if ( this.options.disabled ) {
  10658. this._disable();
  10659. }
  10660. },
  10661. _setOption: function( key, value ) {
  10662. var that = this;
  10663. if ( key === "disabled" ) {
  10664. this[ value ? "_disable" : "_enable" ]();
  10665. this.options[ key ] = value;
  10666. // disable element style changes
  10667. return;
  10668. }
  10669. this._super( key, value );
  10670. if ( key === "content" ) {
  10671. $.each( this.tooltips, function( id, element ) {
  10672. that._updateContent( element );
  10673. });
  10674. }
  10675. },
  10676. _disable: function() {
  10677. var that = this;
  10678. // close open tooltips
  10679. $.each( this.tooltips, function( id, element ) {
  10680. var event = $.Event( "blur" );
  10681. event.target = event.currentTarget = element[0];
  10682. that.close( event, true );
  10683. });
  10684. // remove title attributes to prevent native tooltips
  10685. this.element.find( this.options.items ).addBack().each(function() {
  10686. var element = $( this );
  10687. if ( element.is( "[title]" ) ) {
  10688. element
  10689. .data( "ui-tooltip-title", element.attr( "title" ) )
  10690. .attr( "title", "" );
  10691. }
  10692. });
  10693. },
  10694. _enable: function() {
  10695. // restore title attributes
  10696. this.element.find( this.options.items ).addBack().each(function() {
  10697. var element = $( this );
  10698. if ( element.data( "ui-tooltip-title" ) ) {
  10699. element.attr( "title", element.data( "ui-tooltip-title" ) );
  10700. }
  10701. });
  10702. },
  10703. open: function( event ) {
  10704. var that = this,
  10705. target = $( event ? event.target : this.element )
  10706. // we need closest here due to mouseover bubbling,
  10707. // but always pointing at the same event target
  10708. .closest( this.options.items );
  10709. // No element to show a tooltip for or the tooltip is already open
  10710. if ( !target.length || target.data( "ui-tooltip-id" ) ) {
  10711. return;
  10712. }
  10713. if ( target.attr( "title" ) ) {
  10714. target.data( "ui-tooltip-title", target.attr( "title" ) );
  10715. }
  10716. target.data( "ui-tooltip-open", true );
  10717. // kill parent tooltips, custom or native, for hover
  10718. if ( event && event.type === "mouseover" ) {
  10719. target.parents().each(function() {
  10720. var parent = $( this ),
  10721. blurEvent;
  10722. if ( parent.data( "ui-tooltip-open" ) ) {
  10723. blurEvent = $.Event( "blur" );
  10724. blurEvent.target = blurEvent.currentTarget = this;
  10725. that.close( blurEvent, true );
  10726. }
  10727. if ( parent.attr( "title" ) ) {
  10728. parent.uniqueId();
  10729. that.parents[ this.id ] = {
  10730. element: this,
  10731. title: parent.attr( "title" )
  10732. };
  10733. parent.attr( "title", "" );
  10734. }
  10735. });
  10736. }
  10737. this._updateContent( target, event );
  10738. },
  10739. _updateContent: function( target, event ) {
  10740. var content,
  10741. contentOption = this.options.content,
  10742. that = this,
  10743. eventType = event ? event.type : null;
  10744. if ( typeof contentOption === "string" ) {
  10745. return this._open( event, target, contentOption );
  10746. }
  10747. content = contentOption.call( target[0], function( response ) {
  10748. // ignore async response if tooltip was closed already
  10749. if ( !target.data( "ui-tooltip-open" ) ) {
  10750. return;
  10751. }
  10752. // IE may instantly serve a cached response for ajax requests
  10753. // delay this call to _open so the other call to _open runs first
  10754. that._delay(function() {
  10755. // jQuery creates a special event for focusin when it doesn't
  10756. // exist natively. To improve performance, the native event
  10757. // object is reused and the type is changed. Therefore, we can't
  10758. // rely on the type being correct after the event finished
  10759. // bubbling, so we set it back to the previous value. (#8740)
  10760. if ( event ) {
  10761. event.type = eventType;
  10762. }
  10763. this._open( event, target, response );
  10764. });
  10765. });
  10766. if ( content ) {
  10767. this._open( event, target, content );
  10768. }
  10769. },
  10770. _open: function( event, target, content ) {
  10771. var tooltip, events, delayedShow,
  10772. positionOption = $.extend( {}, this.options.position );
  10773. if ( !content ) {
  10774. return;
  10775. }
  10776. // Content can be updated multiple times. If the tooltip already
  10777. // exists, then just update the content and bail.
  10778. tooltip = this._find( target );
  10779. if ( tooltip.length ) {
  10780. tooltip.find( ".ui-tooltip-content" ).html( content );
  10781. return;
  10782. }
  10783. // if we have a title, clear it to prevent the native tooltip
  10784. // we have to check first to avoid defining a title if none exists
  10785. // (we don't want to cause an element to start matching [title])
  10786. //
  10787. // We use removeAttr only for key events, to allow IE to export the correct
  10788. // accessible attributes. For mouse events, set to empty string to avoid
  10789. // native tooltip showing up (happens only when removing inside mouseover).
  10790. if ( target.is( "[title]" ) ) {
  10791. if ( event && event.type === "mouseover" ) {
  10792. target.attr( "title", "" );
  10793. } else {
  10794. target.removeAttr( "title" );
  10795. }
  10796. }
  10797. tooltip = this._tooltip( target );
  10798. addDescribedBy( target, tooltip.attr( "id" ) );
  10799. tooltip.find( ".ui-tooltip-content" ).html( content );
  10800. function position( event ) {
  10801. positionOption.of = event;
  10802. if ( tooltip.is( ":hidden" ) ) {
  10803. return;
  10804. }
  10805. tooltip.position( positionOption );
  10806. }
  10807. if ( this.options.track && event && /^mouse/.test( event.type ) ) {
  10808. this._on( this.document, {
  10809. mousemove: position
  10810. });
  10811. // trigger once to override element-relative positioning
  10812. position( event );
  10813. } else {
  10814. tooltip.position( $.extend({
  10815. of: target
  10816. }, this.options.position ) );
  10817. }
  10818. tooltip.hide();
  10819. this._show( tooltip, this.options.show );
  10820. // Handle tracking tooltips that are shown with a delay (#8644). As soon
  10821. // as the tooltip is visible, position the tooltip using the most recent
  10822. // event.
  10823. if ( this.options.show && this.options.show.delay ) {
  10824. delayedShow = this.delayedShow = setInterval(function() {
  10825. if ( tooltip.is( ":visible" ) ) {
  10826. position( positionOption.of );
  10827. clearInterval( delayedShow );
  10828. }
  10829. }, $.fx.interval );
  10830. }
  10831. this._trigger( "open", event, { tooltip: tooltip } );
  10832. events = {
  10833. keyup: function( event ) {
  10834. if ( event.keyCode === $.ui.keyCode.ESCAPE ) {
  10835. var fakeEvent = $.Event(event);
  10836. fakeEvent.currentTarget = target[0];
  10837. this.close( fakeEvent, true );
  10838. }
  10839. },
  10840. remove: function() {
  10841. this._removeTooltip( tooltip );
  10842. }
  10843. };
  10844. if ( !event || event.type === "mouseover" ) {
  10845. events.mouseleave = "close";
  10846. }
  10847. if ( !event || event.type === "focusin" ) {
  10848. events.focusout = "close";
  10849. }
  10850. this._on( true, target, events );
  10851. },
  10852. close: function( event ) {
  10853. var that = this,
  10854. target = $( event ? event.currentTarget : this.element ),
  10855. tooltip = this._find( target );
  10856. // disabling closes the tooltip, so we need to track when we're closing
  10857. // to avoid an infinite loop in case the tooltip becomes disabled on close
  10858. if ( this.closing ) {
  10859. return;
  10860. }
  10861. // Clear the interval for delayed tracking tooltips
  10862. clearInterval( this.delayedShow );
  10863. // only set title if we had one before (see comment in _open())
  10864. if ( target.data( "ui-tooltip-title" ) ) {
  10865. target.attr( "title", target.data( "ui-tooltip-title" ) );
  10866. }
  10867. removeDescribedBy( target );
  10868. tooltip.stop( true );
  10869. this._hide( tooltip, this.options.hide, function() {
  10870. that._removeTooltip( $( this ) );
  10871. });
  10872. target.removeData( "ui-tooltip-open" );
  10873. this._off( target, "mouseleave focusout keyup" );
  10874. // Remove 'remove' binding only on delegated targets
  10875. if ( target[0] !== this.element[0] ) {
  10876. this._off( target, "remove" );
  10877. }
  10878. this._off( this.document, "mousemove" );
  10879. if ( event && event.type === "mouseleave" ) {
  10880. $.each( this.parents, function( id, parent ) {
  10881. $( parent.element ).attr( "title", parent.title );
  10882. delete that.parents[ id ];
  10883. });
  10884. }
  10885. this.closing = true;
  10886. this._trigger( "close", event, { tooltip: tooltip } );
  10887. this.closing = false;
  10888. },
  10889. _tooltip: function( element ) {
  10890. var id = "ui-tooltip-" + increments++,
  10891. tooltip = $( "<div>" )
  10892. .attr({
  10893. id: id,
  10894. role: "tooltip"
  10895. })
  10896. .addClass( "ui-tooltip ui-widget ui-corner-all ui-widget-content " +
  10897. ( this.options.tooltipClass || "" ) );
  10898. $( "<div>" )
  10899. .addClass( "ui-tooltip-content" )
  10900. .appendTo( tooltip );
  10901. tooltip.appendTo( this.document[0].body );
  10902. this.tooltips[ id ] = element;
  10903. return tooltip;
  10904. },
  10905. _find: function( target ) {
  10906. var id = target.data( "ui-tooltip-id" );
  10907. return id ? $( "#" + id ) : $();
  10908. },
  10909. _removeTooltip: function( tooltip ) {
  10910. tooltip.remove();
  10911. delete this.tooltips[ tooltip.attr( "id" ) ];
  10912. },
  10913. _destroy: function() {
  10914. var that = this;
  10915. // close open tooltips
  10916. $.each( this.tooltips, function( id, element ) {
  10917. // Delegate to close method to handle common cleanup
  10918. var event = $.Event( "blur" );
  10919. event.target = event.currentTarget = element[0];
  10920. that.close( event, true );
  10921. // Remove immediately; destroying an open tooltip doesn't use the
  10922. // hide animation
  10923. $( "#" + id ).remove();
  10924. // Restore the title
  10925. if ( element.data( "ui-tooltip-title" ) ) {
  10926. element.attr( "title", element.data( "ui-tooltip-title" ) );
  10927. element.removeData( "ui-tooltip-title" );
  10928. }
  10929. });
  10930. }
  10931. });
  10932. }( jQuery ) );
  10933. (function($, undefined) {
  10934. var dataSpace = "ui-effects-";
  10935. $.effects = {
  10936. effect: {}
  10937. };
  10938. /*!
  10939. * jQuery Color Animations v2.1.2
  10940. * https://github.com/jquery/jquery-color
  10941. *
  10942. * Copyright 2013 jQuery Foundation and other contributors
  10943. * Released under the MIT license.
  10944. * http://jquery.org/license
  10945. *
  10946. * Date: Wed Jan 16 08:47:09 2013 -0600
  10947. */
  10948. (function( jQuery, undefined ) {
  10949. var stepHooks = "backgroundColor borderBottomColor borderLeftColor borderRightColor borderTopColor color columnRuleColor outlineColor textDecorationColor textEmphasisColor",
  10950. // plusequals test for += 100 -= 100
  10951. rplusequals = /^([\-+])=\s*(\d+\.?\d*)/,
  10952. // a set of RE's that can match strings and generate color tuples.
  10953. stringParsers = [{
  10954. re: /rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(?:,\s*(\d?(?:\.\d+)?)\s*)?\)/,
  10955. parse: function( execResult ) {
  10956. return [
  10957. execResult[ 1 ],
  10958. execResult[ 2 ],
  10959. execResult[ 3 ],
  10960. execResult[ 4 ]
  10961. ];
  10962. }
  10963. }, {
  10964. re: /rgba?\(\s*(\d+(?:\.\d+)?)\%\s*,\s*(\d+(?:\.\d+)?)\%\s*,\s*(\d+(?:\.\d+)?)\%\s*(?:,\s*(\d?(?:\.\d+)?)\s*)?\)/,
  10965. parse: function( execResult ) {
  10966. return [
  10967. execResult[ 1 ] * 2.55,
  10968. execResult[ 2 ] * 2.55,
  10969. execResult[ 3 ] * 2.55,
  10970. execResult[ 4 ]
  10971. ];
  10972. }
  10973. }, {
  10974. // this regex ignores A-F because it's compared against an already lowercased string
  10975. re: /#([a-f0-9]{2})([a-f0-9]{2})([a-f0-9]{2})/,
  10976. parse: function( execResult ) {
  10977. return [
  10978. parseInt( execResult[ 1 ], 16 ),
  10979. parseInt( execResult[ 2 ], 16 ),
  10980. parseInt( execResult[ 3 ], 16 )
  10981. ];
  10982. }
  10983. }, {
  10984. // this regex ignores A-F because it's compared against an already lowercased string
  10985. re: /#([a-f0-9])([a-f0-9])([a-f0-9])/,
  10986. parse: function( execResult ) {
  10987. return [
  10988. parseInt( execResult[ 1 ] + execResult[ 1 ], 16 ),
  10989. parseInt( execResult[ 2 ] + execResult[ 2 ], 16 ),
  10990. parseInt( execResult[ 3 ] + execResult[ 3 ], 16 )
  10991. ];
  10992. }
  10993. }, {
  10994. re: /hsla?\(\s*(\d+(?:\.\d+)?)\s*,\s*(\d+(?:\.\d+)?)\%\s*,\s*(\d+(?:\.\d+)?)\%\s*(?:,\s*(\d?(?:\.\d+)?)\s*)?\)/,
  10995. space: "hsla",
  10996. parse: function( execResult ) {
  10997. return [
  10998. execResult[ 1 ],
  10999. execResult[ 2 ] / 100,
  11000. execResult[ 3 ] / 100,
  11001. execResult[ 4 ]
  11002. ];
  11003. }
  11004. }],
  11005. // jQuery.Color( )
  11006. color = jQuery.Color = function( color, green, blue, alpha ) {
  11007. return new jQuery.Color.fn.parse( color, green, blue, alpha );
  11008. },
  11009. spaces = {
  11010. rgba: {
  11011. props: {
  11012. red: {
  11013. idx: 0,
  11014. type: "byte"
  11015. },
  11016. green: {
  11017. idx: 1,
  11018. type: "byte"
  11019. },
  11020. blue: {
  11021. idx: 2,
  11022. type: "byte"
  11023. }
  11024. }
  11025. },
  11026. hsla: {
  11027. props: {
  11028. hue: {
  11029. idx: 0,
  11030. type: "degrees"
  11031. },
  11032. saturation: {
  11033. idx: 1,
  11034. type: "percent"
  11035. },
  11036. lightness: {
  11037. idx: 2,
  11038. type: "percent"
  11039. }
  11040. }
  11041. }
  11042. },
  11043. propTypes = {
  11044. "byte": {
  11045. floor: true,
  11046. max: 255
  11047. },
  11048. "percent": {
  11049. max: 1
  11050. },
  11051. "degrees": {
  11052. mod: 360,
  11053. floor: true
  11054. }
  11055. },
  11056. support = color.support = {},
  11057. // element for support tests
  11058. supportElem = jQuery( "<p>" )[ 0 ],
  11059. // colors = jQuery.Color.names
  11060. colors,
  11061. // local aliases of functions called often
  11062. each = jQuery.each;
  11063. // determine rgba support immediately
  11064. supportElem.style.cssText = "background-color:rgba(1,1,1,.5)";
  11065. support.rgba = supportElem.style.backgroundColor.indexOf( "rgba" ) > -1;
  11066. // define cache name and alpha properties
  11067. // for rgba and hsla spaces
  11068. each( spaces, function( spaceName, space ) {
  11069. space.cache = "_" + spaceName;
  11070. space.props.alpha = {
  11071. idx: 3,
  11072. type: "percent",
  11073. def: 1
  11074. };
  11075. });
  11076. function clamp( value, prop, allowEmpty ) {
  11077. var type = propTypes[ prop.type ] || {};
  11078. if ( value == null ) {
  11079. return (allowEmpty || !prop.def) ? null : prop.def;
  11080. }
  11081. // ~~ is an short way of doing floor for positive numbers
  11082. value = type.floor ? ~~value : parseFloat( value );
  11083. // IE will pass in empty strings as value for alpha,
  11084. // which will hit this case
  11085. if ( isNaN( value ) ) {
  11086. return prop.def;
  11087. }
  11088. if ( type.mod ) {
  11089. // we add mod before modding to make sure that negatives values
  11090. // get converted properly: -10 -> 350
  11091. return (value + type.mod) % type.mod;
  11092. }
  11093. // for now all property types without mod have min and max
  11094. return 0 > value ? 0 : type.max < value ? type.max : value;
  11095. }
  11096. function stringParse( string ) {
  11097. var inst = color(),
  11098. rgba = inst._rgba = [];
  11099. string = string.toLowerCase();
  11100. each( stringParsers, function( i, parser ) {
  11101. var parsed,
  11102. match = parser.re.exec( string ),
  11103. values = match && parser.parse( match ),
  11104. spaceName = parser.space || "rgba";
  11105. if ( values ) {
  11106. parsed = inst[ spaceName ]( values );
  11107. // if this was an rgba parse the assignment might happen twice
  11108. // oh well....
  11109. inst[ spaces[ spaceName ].cache ] = parsed[ spaces[ spaceName ].cache ];
  11110. rgba = inst._rgba = parsed._rgba;
  11111. // exit each( stringParsers ) here because we matched
  11112. return false;
  11113. }
  11114. });
  11115. // Found a stringParser that handled it
  11116. if ( rgba.length ) {
  11117. // if this came from a parsed string, force "transparent" when alpha is 0
  11118. // chrome, (and maybe others) return "transparent" as rgba(0,0,0,0)
  11119. if ( rgba.join() === "0,0,0,0" ) {
  11120. jQuery.extend( rgba, colors.transparent );
  11121. }
  11122. return inst;
  11123. }
  11124. // named colors
  11125. return colors[ string ];
  11126. }
  11127. color.fn = jQuery.extend( color.prototype, {
  11128. parse: function( red, green, blue, alpha ) {
  11129. if ( red === undefined ) {
  11130. this._rgba = [ null, null, null, null ];
  11131. return this;
  11132. }
  11133. if ( red.jquery || red.nodeType ) {
  11134. red = jQuery( red ).css( green );
  11135. green = undefined;
  11136. }
  11137. var inst = this,
  11138. type = jQuery.type( red ),
  11139. rgba = this._rgba = [];
  11140. // more than 1 argument specified - assume ( red, green, blue, alpha )
  11141. if ( green !== undefined ) {
  11142. red = [ red, green, blue, alpha ];
  11143. type = "array";
  11144. }
  11145. if ( type === "string" ) {
  11146. return this.parse( stringParse( red ) || colors._default );
  11147. }
  11148. if ( type === "array" ) {
  11149. each( spaces.rgba.props, function( key, prop ) {
  11150. rgba[ prop.idx ] = clamp( red[ prop.idx ], prop );
  11151. });
  11152. return this;
  11153. }
  11154. if ( type === "object" ) {
  11155. if ( red instanceof color ) {
  11156. each( spaces, function( spaceName, space ) {
  11157. if ( red[ space.cache ] ) {
  11158. inst[ space.cache ] = red[ space.cache ].slice();
  11159. }
  11160. });
  11161. } else {
  11162. each( spaces, function( spaceName, space ) {
  11163. var cache = space.cache;
  11164. each( space.props, function( key, prop ) {
  11165. // if the cache doesn't exist, and we know how to convert
  11166. if ( !inst[ cache ] && space.to ) {
  11167. // if the value was null, we don't need to copy it
  11168. // if the key was alpha, we don't need to copy it either
  11169. if ( key === "alpha" || red[ key ] == null ) {
  11170. return;
  11171. }
  11172. inst[ cache ] = space.to( inst._rgba );
  11173. }
  11174. // this is the only case where we allow nulls for ALL properties.
  11175. // call clamp with alwaysAllowEmpty
  11176. inst[ cache ][ prop.idx ] = clamp( red[ key ], prop, true );
  11177. });
  11178. // everything defined but alpha?
  11179. if ( inst[ cache ] && jQuery.inArray( null, inst[ cache ].slice( 0, 3 ) ) < 0 ) {
  11180. // use the default of 1
  11181. inst[ cache ][ 3 ] = 1;
  11182. if ( space.from ) {
  11183. inst._rgba = space.from( inst[ cache ] );
  11184. }
  11185. }
  11186. });
  11187. }
  11188. return this;
  11189. }
  11190. },
  11191. is: function( compare ) {
  11192. var is = color( compare ),
  11193. same = true,
  11194. inst = this;
  11195. each( spaces, function( _, space ) {
  11196. var localCache,
  11197. isCache = is[ space.cache ];
  11198. if (isCache) {
  11199. localCache = inst[ space.cache ] || space.to && space.to( inst._rgba ) || [];
  11200. each( space.props, function( _, prop ) {
  11201. if ( isCache[ prop.idx ] != null ) {
  11202. same = ( isCache[ prop.idx ] === localCache[ prop.idx ] );
  11203. return same;
  11204. }
  11205. });
  11206. }
  11207. return same;
  11208. });
  11209. return same;
  11210. },
  11211. _space: function() {
  11212. var used = [],
  11213. inst = this;
  11214. each( spaces, function( spaceName, space ) {
  11215. if ( inst[ space.cache ] ) {
  11216. used.push( spaceName );
  11217. }
  11218. });
  11219. return used.pop();
  11220. },
  11221. transition: function( other, distance ) {
  11222. var end = color( other ),
  11223. spaceName = end._space(),
  11224. space = spaces[ spaceName ],
  11225. startColor = this.alpha() === 0 ? color( "transparent" ) : this,
  11226. start = startColor[ space.cache ] || space.to( startColor._rgba ),
  11227. result = start.slice();
  11228. end = end[ space.cache ];
  11229. each( space.props, function( key, prop ) {
  11230. var index = prop.idx,
  11231. startValue = start[ index ],
  11232. endValue = end[ index ],
  11233. type = propTypes[ prop.type ] || {};
  11234. // if null, don't override start value
  11235. if ( endValue === null ) {
  11236. return;
  11237. }
  11238. // if null - use end
  11239. if ( startValue === null ) {
  11240. result[ index ] = endValue;
  11241. } else {
  11242. if ( type.mod ) {
  11243. if ( endValue - startValue > type.mod / 2 ) {
  11244. startValue += type.mod;
  11245. } else if ( startValue - endValue > type.mod / 2 ) {
  11246. startValue -= type.mod;
  11247. }
  11248. }
  11249. result[ index ] = clamp( ( endValue - startValue ) * distance + startValue, prop );
  11250. }
  11251. });
  11252. return this[ spaceName ]( result );
  11253. },
  11254. blend: function( opaque ) {
  11255. // if we are already opaque - return ourself
  11256. if ( this._rgba[ 3 ] === 1 ) {
  11257. return this;
  11258. }
  11259. var rgb = this._rgba.slice(),
  11260. a = rgb.pop(),
  11261. blend = color( opaque )._rgba;
  11262. return color( jQuery.map( rgb, function( v, i ) {
  11263. return ( 1 - a ) * blend[ i ] + a * v;
  11264. }));
  11265. },
  11266. toRgbaString: function() {
  11267. var prefix = "rgba(",
  11268. rgba = jQuery.map( this._rgba, function( v, i ) {
  11269. return v == null ? ( i > 2 ? 1 : 0 ) : v;
  11270. });
  11271. if ( rgba[ 3 ] === 1 ) {
  11272. rgba.pop();
  11273. prefix = "rgb(";
  11274. }
  11275. return prefix + rgba.join() + ")";
  11276. },
  11277. toHslaString: function() {
  11278. var prefix = "hsla(",
  11279. hsla = jQuery.map( this.hsla(), function( v, i ) {
  11280. if ( v == null ) {
  11281. v = i > 2 ? 1 : 0;
  11282. }
  11283. // catch 1 and 2
  11284. if ( i && i < 3 ) {
  11285. v = Math.round( v * 100 ) + "%";
  11286. }
  11287. return v;
  11288. });
  11289. if ( hsla[ 3 ] === 1 ) {
  11290. hsla.pop();
  11291. prefix = "hsl(";
  11292. }
  11293. return prefix + hsla.join() + ")";
  11294. },
  11295. toHexString: function( includeAlpha ) {
  11296. var rgba = this._rgba.slice(),
  11297. alpha = rgba.pop();
  11298. if ( includeAlpha ) {
  11299. rgba.push( ~~( alpha * 255 ) );
  11300. }
  11301. return "#" + jQuery.map( rgba, function( v ) {
  11302. // default to 0 when nulls exist
  11303. v = ( v || 0 ).toString( 16 );
  11304. return v.length === 1 ? "0" + v : v;
  11305. }).join("");
  11306. },
  11307. toString: function() {
  11308. return this._rgba[ 3 ] === 0 ? "transparent" : this.toRgbaString();
  11309. }
  11310. });
  11311. color.fn.parse.prototype = color.fn;
  11312. // hsla conversions adapted from:
  11313. // https://code.google.com/p/maashaack/source/browse/packages/graphics/trunk/src/graphics/colors/HUE2RGB.as?r=5021
  11314. function hue2rgb( p, q, h ) {
  11315. h = ( h + 1 ) % 1;
  11316. if ( h * 6 < 1 ) {
  11317. return p + (q - p) * h * 6;
  11318. }
  11319. if ( h * 2 < 1) {
  11320. return q;
  11321. }
  11322. if ( h * 3 < 2 ) {
  11323. return p + (q - p) * ((2/3) - h) * 6;
  11324. }
  11325. return p;
  11326. }
  11327. spaces.hsla.to = function ( rgba ) {
  11328. if ( rgba[ 0 ] == null || rgba[ 1 ] == null || rgba[ 2 ] == null ) {
  11329. return [ null, null, null, rgba[ 3 ] ];
  11330. }
  11331. var r = rgba[ 0 ] / 255,
  11332. g = rgba[ 1 ] / 255,
  11333. b = rgba[ 2 ] / 255,
  11334. a = rgba[ 3 ],
  11335. max = Math.max( r, g, b ),
  11336. min = Math.min( r, g, b ),
  11337. diff = max - min,
  11338. add = max + min,
  11339. l = add * 0.5,
  11340. h, s;
  11341. if ( min === max ) {
  11342. h = 0;
  11343. } else if ( r === max ) {
  11344. h = ( 60 * ( g - b ) / diff ) + 360;
  11345. } else if ( g === max ) {
  11346. h = ( 60 * ( b - r ) / diff ) + 120;
  11347. } else {
  11348. h = ( 60 * ( r - g ) / diff ) + 240;
  11349. }
  11350. // chroma (diff) == 0 means greyscale which, by definition, saturation = 0%
  11351. // otherwise, saturation is based on the ratio of chroma (diff) to lightness (add)
  11352. if ( diff === 0 ) {
  11353. s = 0;
  11354. } else if ( l <= 0.5 ) {
  11355. s = diff / add;
  11356. } else {
  11357. s = diff / ( 2 - add );
  11358. }
  11359. return [ Math.round(h) % 360, s, l, a == null ? 1 : a ];
  11360. };
  11361. spaces.hsla.from = function ( hsla ) {
  11362. if ( hsla[ 0 ] == null || hsla[ 1 ] == null || hsla[ 2 ] == null ) {
  11363. return [ null, null, null, hsla[ 3 ] ];
  11364. }
  11365. var h = hsla[ 0 ] / 360,
  11366. s = hsla[ 1 ],
  11367. l = hsla[ 2 ],
  11368. a = hsla[ 3 ],
  11369. q = l <= 0.5 ? l * ( 1 + s ) : l + s - l * s,
  11370. p = 2 * l - q;
  11371. return [
  11372. Math.round( hue2rgb( p, q, h + ( 1 / 3 ) ) * 255 ),
  11373. Math.round( hue2rgb( p, q, h ) * 255 ),
  11374. Math.round( hue2rgb( p, q, h - ( 1 / 3 ) ) * 255 ),
  11375. a
  11376. ];
  11377. };
  11378. each( spaces, function( spaceName, space ) {
  11379. var props = space.props,
  11380. cache = space.cache,
  11381. to = space.to,
  11382. from = space.from;
  11383. // makes rgba() and hsla()
  11384. color.fn[ spaceName ] = function( value ) {
  11385. // generate a cache for this space if it doesn't exist
  11386. if ( to && !this[ cache ] ) {
  11387. this[ cache ] = to( this._rgba );
  11388. }
  11389. if ( value === undefined ) {
  11390. return this[ cache ].slice();
  11391. }
  11392. var ret,
  11393. type = jQuery.type( value ),
  11394. arr = ( type === "array" || type === "object" ) ? value : arguments,
  11395. local = this[ cache ].slice();
  11396. each( props, function( key, prop ) {
  11397. var val = arr[ type === "object" ? key : prop.idx ];
  11398. if ( val == null ) {
  11399. val = local[ prop.idx ];
  11400. }
  11401. local[ prop.idx ] = clamp( val, prop );
  11402. });
  11403. if ( from ) {
  11404. ret = color( from( local ) );
  11405. ret[ cache ] = local;
  11406. return ret;
  11407. } else {
  11408. return color( local );
  11409. }
  11410. };
  11411. // makes red() green() blue() alpha() hue() saturation() lightness()
  11412. each( props, function( key, prop ) {
  11413. // alpha is included in more than one space
  11414. if ( color.fn[ key ] ) {
  11415. return;
  11416. }
  11417. color.fn[ key ] = function( value ) {
  11418. var vtype = jQuery.type( value ),
  11419. fn = ( key === "alpha" ? ( this._hsla ? "hsla" : "rgba" ) : spaceName ),
  11420. local = this[ fn ](),
  11421. cur = local[ prop.idx ],
  11422. match;
  11423. if ( vtype === "undefined" ) {
  11424. return cur;
  11425. }
  11426. if ( vtype === "function" ) {
  11427. value = value.call( this, cur );
  11428. vtype = jQuery.type( value );
  11429. }
  11430. if ( value == null && prop.empty ) {
  11431. return this;
  11432. }
  11433. if ( vtype === "string" ) {
  11434. match = rplusequals.exec( value );
  11435. if ( match ) {
  11436. value = cur + parseFloat( match[ 2 ] ) * ( match[ 1 ] === "+" ? 1 : -1 );
  11437. }
  11438. }
  11439. local[ prop.idx ] = value;
  11440. return this[ fn ]( local );
  11441. };
  11442. });
  11443. });
  11444. // add cssHook and .fx.step function for each named hook.
  11445. // accept a space separated string of properties
  11446. color.hook = function( hook ) {
  11447. var hooks = hook.split( " " );
  11448. each( hooks, function( i, hook ) {
  11449. jQuery.cssHooks[ hook ] = {
  11450. set: function( elem, value ) {
  11451. var parsed, curElem,
  11452. backgroundColor = "";
  11453. if ( value !== "transparent" && ( jQuery.type( value ) !== "string" || ( parsed = stringParse( value ) ) ) ) {
  11454. value = color( parsed || value );
  11455. if ( !support.rgba && value._rgba[ 3 ] !== 1 ) {
  11456. curElem = hook === "backgroundColor" ? elem.parentNode : elem;
  11457. while (
  11458. (backgroundColor === "" || backgroundColor === "transparent") &&
  11459. curElem && curElem.style
  11460. ) {
  11461. try {
  11462. backgroundColor = jQuery.css( curElem, "backgroundColor" );
  11463. curElem = curElem.parentNode;
  11464. } catch ( e ) {
  11465. }
  11466. }
  11467. value = value.blend( backgroundColor && backgroundColor !== "transparent" ?
  11468. backgroundColor :
  11469. "_default" );
  11470. }
  11471. value = value.toRgbaString();
  11472. }
  11473. try {
  11474. elem.style[ hook ] = value;
  11475. } catch( e ) {
  11476. // wrapped to prevent IE from throwing errors on "invalid" values like 'auto' or 'inherit'
  11477. }
  11478. }
  11479. };
  11480. jQuery.fx.step[ hook ] = function( fx ) {
  11481. if ( !fx.colorInit ) {
  11482. fx.start = color( fx.elem, hook );
  11483. fx.end = color( fx.end );
  11484. fx.colorInit = true;
  11485. }
  11486. jQuery.cssHooks[ hook ].set( fx.elem, fx.start.transition( fx.end, fx.pos ) );
  11487. };
  11488. });
  11489. };
  11490. color.hook( stepHooks );
  11491. jQuery.cssHooks.borderColor = {
  11492. expand: function( value ) {
  11493. var expanded = {};
  11494. each( [ "Top", "Right", "Bottom", "Left" ], function( i, part ) {
  11495. expanded[ "border" + part + "Color" ] = value;
  11496. });
  11497. return expanded;
  11498. }
  11499. };
  11500. // Basic color names only.
  11501. // Usage of any of the other color names requires adding yourself or including
  11502. // jquery.color.svg-names.js.
  11503. colors = jQuery.Color.names = {
  11504. // 4.1. Basic color keywords
  11505. aqua: "#00ffff",
  11506. black: "#000000",
  11507. blue: "#0000ff",
  11508. fuchsia: "#ff00ff",
  11509. gray: "#808080",
  11510. green: "#008000",
  11511. lime: "#00ff00",
  11512. maroon: "#800000",
  11513. navy: "#000080",
  11514. olive: "#808000",
  11515. purple: "#800080",
  11516. red: "#ff0000",
  11517. silver: "#c0c0c0",
  11518. teal: "#008080",
  11519. white: "#ffffff",
  11520. yellow: "#ffff00",
  11521. // 4.2.3. "transparent" color keyword
  11522. transparent: [ null, null, null, 0 ],
  11523. _default: "#ffffff"
  11524. };
  11525. })( jQuery );
  11526. /******************************************************************************/
  11527. /****************************** CLASS ANIMATIONS ******************************/
  11528. /******************************************************************************/
  11529. (function() {
  11530. var classAnimationActions = [ "add", "remove", "toggle" ],
  11531. shorthandStyles = {
  11532. border: 1,
  11533. borderBottom: 1,
  11534. borderColor: 1,
  11535. borderLeft: 1,
  11536. borderRight: 1,
  11537. borderTop: 1,
  11538. borderWidth: 1,
  11539. margin: 1,
  11540. padding: 1
  11541. };
  11542. $.each([ "borderLeftStyle", "borderRightStyle", "borderBottomStyle", "borderTopStyle" ], function( _, prop ) {
  11543. $.fx.step[ prop ] = function( fx ) {
  11544. if ( fx.end !== "none" && !fx.setAttr || fx.pos === 1 && !fx.setAttr ) {
  11545. jQuery.style( fx.elem, prop, fx.end );
  11546. fx.setAttr = true;
  11547. }
  11548. };
  11549. });
  11550. function getElementStyles( elem ) {
  11551. var key, len,
  11552. style = elem.ownerDocument.defaultView ?
  11553. elem.ownerDocument.defaultView.getComputedStyle( elem, null ) :
  11554. elem.currentStyle,
  11555. styles = {};
  11556. if ( style && style.length && style[ 0 ] && style[ style[ 0 ] ] ) {
  11557. len = style.length;
  11558. while ( len-- ) {
  11559. key = style[ len ];
  11560. if ( typeof style[ key ] === "string" ) {
  11561. styles[ $.camelCase( key ) ] = style[ key ];
  11562. }
  11563. }
  11564. // support: Opera, IE <9
  11565. } else {
  11566. for ( key in style ) {
  11567. if ( typeof style[ key ] === "string" ) {
  11568. styles[ key ] = style[ key ];
  11569. }
  11570. }
  11571. }
  11572. return styles;
  11573. }
  11574. function styleDifference( oldStyle, newStyle ) {
  11575. var diff = {},
  11576. name, value;
  11577. for ( name in newStyle ) {
  11578. value = newStyle[ name ];
  11579. if ( oldStyle[ name ] !== value ) {
  11580. if ( !shorthandStyles[ name ] ) {
  11581. if ( $.fx.step[ name ] || !isNaN( parseFloat( value ) ) ) {
  11582. diff[ name ] = value;
  11583. }
  11584. }
  11585. }
  11586. }
  11587. return diff;
  11588. }
  11589. // support: jQuery <1.8
  11590. if ( !$.fn.addBack ) {
  11591. $.fn.addBack = function( selector ) {
  11592. return this.add( selector == null ?
  11593. this.prevObject : this.prevObject.filter( selector )
  11594. );
  11595. };
  11596. }
  11597. $.effects.animateClass = function( value, duration, easing, callback ) {
  11598. var o = $.speed( duration, easing, callback );
  11599. return this.queue( function() {
  11600. var animated = $( this ),
  11601. baseClass = animated.attr( "class" ) || "",
  11602. applyClassChange,
  11603. allAnimations = o.children ? animated.find( "*" ).addBack() : animated;
  11604. // map the animated objects to store the original styles.
  11605. allAnimations = allAnimations.map(function() {
  11606. var el = $( this );
  11607. return {
  11608. el: el,
  11609. start: getElementStyles( this )
  11610. };
  11611. });
  11612. // apply class change
  11613. applyClassChange = function() {
  11614. $.each( classAnimationActions, function(i, action) {
  11615. if ( value[ action ] ) {
  11616. animated[ action + "Class" ]( value[ action ] );
  11617. }
  11618. });
  11619. };
  11620. applyClassChange();
  11621. // map all animated objects again - calculate new styles and diff
  11622. allAnimations = allAnimations.map(function() {
  11623. this.end = getElementStyles( this.el[ 0 ] );
  11624. this.diff = styleDifference( this.start, this.end );
  11625. return this;
  11626. });
  11627. // apply original class
  11628. animated.attr( "class", baseClass );
  11629. // map all animated objects again - this time collecting a promise
  11630. allAnimations = allAnimations.map(function() {
  11631. var styleInfo = this,
  11632. dfd = $.Deferred(),
  11633. opts = $.extend({}, o, {
  11634. queue: false,
  11635. complete: function() {
  11636. dfd.resolve( styleInfo );
  11637. }
  11638. });
  11639. this.el.animate( this.diff, opts );
  11640. return dfd.promise();
  11641. });
  11642. // once all animations have completed:
  11643. $.when.apply( $, allAnimations.get() ).done(function() {
  11644. // set the final class
  11645. applyClassChange();
  11646. // for each animated element,
  11647. // clear all css properties that were animated
  11648. $.each( arguments, function() {
  11649. var el = this.el;
  11650. $.each( this.diff, function(key) {
  11651. el.css( key, "" );
  11652. });
  11653. });
  11654. // this is guarnteed to be there if you use jQuery.speed()
  11655. // it also handles dequeuing the next anim...
  11656. o.complete.call( animated[ 0 ] );
  11657. });
  11658. });
  11659. };
  11660. $.fn.extend({
  11661. addClass: (function( orig ) {
  11662. return function( classNames, speed, easing, callback ) {
  11663. return speed ?
  11664. $.effects.animateClass.call( this,
  11665. { add: classNames }, speed, easing, callback ) :
  11666. orig.apply( this, arguments );
  11667. };
  11668. })( $.fn.addClass ),
  11669. removeClass: (function( orig ) {
  11670. return function( classNames, speed, easing, callback ) {
  11671. return arguments.length > 1 ?
  11672. $.effects.animateClass.call( this,
  11673. { remove: classNames }, speed, easing, callback ) :
  11674. orig.apply( this, arguments );
  11675. };
  11676. })( $.fn.removeClass ),
  11677. toggleClass: (function( orig ) {
  11678. return function( classNames, force, speed, easing, callback ) {
  11679. if ( typeof force === "boolean" || force === undefined ) {
  11680. if ( !speed ) {
  11681. // without speed parameter
  11682. return orig.apply( this, arguments );
  11683. } else {
  11684. return $.effects.animateClass.call( this,
  11685. (force ? { add: classNames } : { remove: classNames }),
  11686. speed, easing, callback );
  11687. }
  11688. } else {
  11689. // without force parameter
  11690. return $.effects.animateClass.call( this,
  11691. { toggle: classNames }, force, speed, easing );
  11692. }
  11693. };
  11694. })( $.fn.toggleClass ),
  11695. switchClass: function( remove, add, speed, easing, callback) {
  11696. return $.effects.animateClass.call( this, {
  11697. add: add,
  11698. remove: remove
  11699. }, speed, easing, callback );
  11700. }
  11701. });
  11702. })();
  11703. /******************************************************************************/
  11704. /*********************************** EFFECTS **********************************/
  11705. /******************************************************************************/
  11706. (function() {
  11707. $.extend( $.effects, {
  11708. version: "1.10.3",
  11709. // Saves a set of properties in a data storage
  11710. save: function( element, set ) {
  11711. for( var i=0; i < set.length; i++ ) {
  11712. if ( set[ i ] !== null ) {
  11713. element.data( dataSpace + set[ i ], element[ 0 ].style[ set[ i ] ] );
  11714. }
  11715. }
  11716. },
  11717. // Restores a set of previously saved properties from a data storage
  11718. restore: function( element, set ) {
  11719. var val, i;
  11720. for( i=0; i < set.length; i++ ) {
  11721. if ( set[ i ] !== null ) {
  11722. val = element.data( dataSpace + set[ i ] );
  11723. // support: jQuery 1.6.2
  11724. // http://bugs.jquery.com/ticket/9917
  11725. // jQuery 1.6.2 incorrectly returns undefined for any falsy value.
  11726. // We can't differentiate between "" and 0 here, so we just assume
  11727. // empty string since it's likely to be a more common value...
  11728. if ( val === undefined ) {
  11729. val = "";
  11730. }
  11731. element.css( set[ i ], val );
  11732. }
  11733. }
  11734. },
  11735. setMode: function( el, mode ) {
  11736. if (mode === "toggle") {
  11737. mode = el.is( ":hidden" ) ? "show" : "hide";
  11738. }
  11739. return mode;
  11740. },
  11741. // Translates a [top,left] array into a baseline value
  11742. // this should be a little more flexible in the future to handle a string & hash
  11743. getBaseline: function( origin, original ) {
  11744. var y, x;
  11745. switch ( origin[ 0 ] ) {
  11746. case "top": y = 0; break;
  11747. case "middle": y = 0.5; break;
  11748. case "bottom": y = 1; break;
  11749. default: y = origin[ 0 ] / original.height;
  11750. }
  11751. switch ( origin[ 1 ] ) {
  11752. case "left": x = 0; break;
  11753. case "center": x = 0.5; break;
  11754. case "right": x = 1; break;
  11755. default: x = origin[ 1 ] / original.width;
  11756. }
  11757. return {
  11758. x: x,
  11759. y: y
  11760. };
  11761. },
  11762. // Wraps the element around a wrapper that copies position properties
  11763. createWrapper: function( element ) {
  11764. // if the element is already wrapped, return it
  11765. if ( element.parent().is( ".ui-effects-wrapper" )) {
  11766. return element.parent();
  11767. }
  11768. // wrap the element
  11769. var props = {
  11770. width: element.outerWidth(true),
  11771. height: element.outerHeight(true),
  11772. "float": element.css( "float" )
  11773. },
  11774. wrapper = $( "<div></div>" )
  11775. .addClass( "ui-effects-wrapper" )
  11776. .css({
  11777. fontSize: "100%",
  11778. background: "transparent",
  11779. border: "none",
  11780. margin: 0,
  11781. padding: 0
  11782. }),
  11783. // Store the size in case width/height are defined in % - Fixes #5245
  11784. size = {
  11785. width: element.width(),
  11786. height: element.height()
  11787. },
  11788. active = document.activeElement;
  11789. // support: Firefox
  11790. // Firefox incorrectly exposes anonymous content
  11791. // https://bugzilla.mozilla.org/show_bug.cgi?id=561664
  11792. try {
  11793. active.id;
  11794. } catch( e ) {
  11795. active = document.body;
  11796. }
  11797. element.wrap( wrapper );
  11798. // Fixes #7595 - Elements lose focus when wrapped.
  11799. if ( element[ 0 ] === active || $.contains( element[ 0 ], active ) ) {
  11800. $( active ).focus();
  11801. }
  11802. wrapper = element.parent(); //Hotfix for jQuery 1.4 since some change in wrap() seems to actually lose the reference to the wrapped element
  11803. // transfer positioning properties to the wrapper
  11804. if ( element.css( "position" ) === "static" ) {
  11805. wrapper.css({ position: "relative" });
  11806. element.css({ position: "relative" });
  11807. } else {
  11808. $.extend( props, {
  11809. position: element.css( "position" ),
  11810. zIndex: element.css( "z-index" )
  11811. });
  11812. $.each([ "top", "left", "bottom", "right" ], function(i, pos) {
  11813. props[ pos ] = element.css( pos );
  11814. if ( isNaN( parseInt( props[ pos ], 10 ) ) ) {
  11815. props[ pos ] = "auto";
  11816. }
  11817. });
  11818. element.css({
  11819. position: "relative",
  11820. top: 0,
  11821. left: 0,
  11822. right: "auto",
  11823. bottom: "auto"
  11824. });
  11825. }
  11826. element.css(size);
  11827. return wrapper.css( props ).show();
  11828. },
  11829. removeWrapper: function( element ) {
  11830. var active = document.activeElement;
  11831. if ( element.parent().is( ".ui-effects-wrapper" ) ) {
  11832. element.parent().replaceWith( element );
  11833. // Fixes #7595 - Elements lose focus when wrapped.
  11834. if ( element[ 0 ] === active || $.contains( element[ 0 ], active ) ) {
  11835. $( active ).focus();
  11836. }
  11837. }
  11838. return element;
  11839. },
  11840. setTransition: function( element, list, factor, value ) {
  11841. value = value || {};
  11842. $.each( list, function( i, x ) {
  11843. var unit = element.cssUnit( x );
  11844. if ( unit[ 0 ] > 0 ) {
  11845. value[ x ] = unit[ 0 ] * factor + unit[ 1 ];
  11846. }
  11847. });
  11848. return value;
  11849. }
  11850. });
  11851. // return an effect options object for the given parameters:
  11852. function _normalizeArguments( effect, options, speed, callback ) {
  11853. // allow passing all options as the first parameter
  11854. if ( $.isPlainObject( effect ) ) {
  11855. options = effect;
  11856. effect = effect.effect;
  11857. }
  11858. // convert to an object
  11859. effect = { effect: effect };
  11860. // catch (effect, null, ...)
  11861. if ( options == null ) {
  11862. options = {};
  11863. }
  11864. // catch (effect, callback)
  11865. if ( $.isFunction( options ) ) {
  11866. callback = options;
  11867. speed = null;
  11868. options = {};
  11869. }
  11870. // catch (effect, speed, ?)
  11871. if ( typeof options === "number" || $.fx.speeds[ options ] ) {
  11872. callback = speed;
  11873. speed = options;
  11874. options = {};
  11875. }
  11876. // catch (effect, options, callback)
  11877. if ( $.isFunction( speed ) ) {
  11878. callback = speed;
  11879. speed = null;
  11880. }
  11881. // add options to effect
  11882. if ( options ) {
  11883. $.extend( effect, options );
  11884. }
  11885. speed = speed || options.duration;
  11886. effect.duration = $.fx.off ? 0 :
  11887. typeof speed === "number" ? speed :
  11888. speed in $.fx.speeds ? $.fx.speeds[ speed ] :
  11889. $.fx.speeds._default;
  11890. effect.complete = callback || options.complete;
  11891. return effect;
  11892. }
  11893. function standardAnimationOption( option ) {
  11894. // Valid standard speeds (nothing, number, named speed)
  11895. if ( !option || typeof option === "number" || $.fx.speeds[ option ] ) {
  11896. return true;
  11897. }
  11898. // Invalid strings - treat as "normal" speed
  11899. if ( typeof option === "string" && !$.effects.effect[ option ] ) {
  11900. return true;
  11901. }
  11902. // Complete callback
  11903. if ( $.isFunction( option ) ) {
  11904. return true;
  11905. }
  11906. // Options hash (but not naming an effect)
  11907. if ( typeof option === "object" && !option.effect ) {
  11908. return true;
  11909. }
  11910. // Didn't match any standard API
  11911. return false;
  11912. }
  11913. $.fn.extend({
  11914. effect: function( /* effect, options, speed, callback */ ) {
  11915. var args = _normalizeArguments.apply( this, arguments ),
  11916. mode = args.mode,
  11917. queue = args.queue,
  11918. effectMethod = $.effects.effect[ args.effect ];
  11919. if ( $.fx.off || !effectMethod ) {
  11920. // delegate to the original method (e.g., .show()) if possible
  11921. if ( mode ) {
  11922. return this[ mode ]( args.duration, args.complete );
  11923. } else {
  11924. return this.each( function() {
  11925. if ( args.complete ) {
  11926. args.complete.call( this );
  11927. }
  11928. });
  11929. }
  11930. }
  11931. function run( next ) {
  11932. var elem = $( this ),
  11933. complete = args.complete,
  11934. mode = args.mode;
  11935. function done() {
  11936. if ( $.isFunction( complete ) ) {
  11937. complete.call( elem[0] );
  11938. }
  11939. if ( $.isFunction( next ) ) {
  11940. next();
  11941. }
  11942. }
  11943. // If the element already has the correct final state, delegate to
  11944. // the core methods so the internal tracking of "olddisplay" works.
  11945. if ( elem.is( ":hidden" ) ? mode === "hide" : mode === "show" ) {
  11946. elem[ mode ]();
  11947. done();
  11948. } else {
  11949. effectMethod.call( elem[0], args, done );
  11950. }
  11951. }
  11952. return queue === false ? this.each( run ) : this.queue( queue || "fx", run );
  11953. },
  11954. show: (function( orig ) {
  11955. return function( option ) {
  11956. if ( standardAnimationOption( option ) ) {
  11957. return orig.apply( this, arguments );
  11958. } else {
  11959. var args = _normalizeArguments.apply( this, arguments );
  11960. args.mode = "show";
  11961. return this.effect.call( this, args );
  11962. }
  11963. };
  11964. })( $.fn.show ),
  11965. hide: (function( orig ) {
  11966. return function( option ) {
  11967. if ( standardAnimationOption( option ) ) {
  11968. return orig.apply( this, arguments );
  11969. } else {
  11970. var args = _normalizeArguments.apply( this, arguments );
  11971. args.mode = "hide";
  11972. return this.effect.call( this, args );
  11973. }
  11974. };
  11975. })( $.fn.hide ),
  11976. toggle: (function( orig ) {
  11977. return function( option ) {
  11978. if ( standardAnimationOption( option ) || typeof option === "boolean" ) {
  11979. return orig.apply( this, arguments );
  11980. } else {
  11981. var args = _normalizeArguments.apply( this, arguments );
  11982. args.mode = "toggle";
  11983. return this.effect.call( this, args );
  11984. }
  11985. };
  11986. })( $.fn.toggle ),
  11987. // helper functions
  11988. cssUnit: function(key) {
  11989. var style = this.css( key ),
  11990. val = [];
  11991. $.each( [ "em", "px", "%", "pt" ], function( i, unit ) {
  11992. if ( style.indexOf( unit ) > 0 ) {
  11993. val = [ parseFloat( style ), unit ];
  11994. }
  11995. });
  11996. return val;
  11997. }
  11998. });
  11999. })();
  12000. /******************************************************************************/
  12001. /*********************************** EASING ***********************************/
  12002. /******************************************************************************/
  12003. (function() {
  12004. // based on easing equations from Robert Penner (http://www.robertpenner.com/easing)
  12005. var baseEasings = {};
  12006. $.each( [ "Quad", "Cubic", "Quart", "Quint", "Expo" ], function( i, name ) {
  12007. baseEasings[ name ] = function( p ) {
  12008. return Math.pow( p, i + 2 );
  12009. };
  12010. });
  12011. $.extend( baseEasings, {
  12012. Sine: function ( p ) {
  12013. return 1 - Math.cos( p * Math.PI / 2 );
  12014. },
  12015. Circ: function ( p ) {
  12016. return 1 - Math.sqrt( 1 - p * p );
  12017. },
  12018. Elastic: function( p ) {
  12019. return p === 0 || p === 1 ? p :
  12020. -Math.pow( 2, 8 * (p - 1) ) * Math.sin( ( (p - 1) * 80 - 7.5 ) * Math.PI / 15 );
  12021. },
  12022. Back: function( p ) {
  12023. return p * p * ( 3 * p - 2 );
  12024. },
  12025. Bounce: function ( p ) {
  12026. var pow2,
  12027. bounce = 4;
  12028. while ( p < ( ( pow2 = Math.pow( 2, --bounce ) ) - 1 ) / 11 ) {}
  12029. return 1 / Math.pow( 4, 3 - bounce ) - 7.5625 * Math.pow( ( pow2 * 3 - 2 ) / 22 - p, 2 );
  12030. }
  12031. });
  12032. $.each( baseEasings, function( name, easeIn ) {
  12033. $.easing[ "easeIn" + name ] = easeIn;
  12034. $.easing[ "easeOut" + name ] = function( p ) {
  12035. return 1 - easeIn( 1 - p );
  12036. };
  12037. $.easing[ "easeInOut" + name ] = function( p ) {
  12038. return p < 0.5 ?
  12039. easeIn( p * 2 ) / 2 :
  12040. 1 - easeIn( p * -2 + 2 ) / 2;
  12041. };
  12042. });
  12043. })();
  12044. })(jQuery);
  12045. (function( $, undefined ) {
  12046. var rvertical = /up|down|vertical/,
  12047. rpositivemotion = /up|left|vertical|horizontal/;
  12048. $.effects.effect.blind = function( o, done ) {
  12049. // Create element
  12050. var el = $( this ),
  12051. props = [ "position", "top", "bottom", "left", "right", "height", "width" ],
  12052. mode = $.effects.setMode( el, o.mode || "hide" ),
  12053. direction = o.direction || "up",
  12054. vertical = rvertical.test( direction ),
  12055. ref = vertical ? "height" : "width",
  12056. ref2 = vertical ? "top" : "left",
  12057. motion = rpositivemotion.test( direction ),
  12058. animation = {},
  12059. show = mode === "show",
  12060. wrapper, distance, margin;
  12061. // if already wrapped, the wrapper's properties are my property. #6245
  12062. if ( el.parent().is( ".ui-effects-wrapper" ) ) {
  12063. $.effects.save( el.parent(), props );
  12064. } else {
  12065. $.effects.save( el, props );
  12066. }
  12067. el.show();
  12068. wrapper = $.effects.createWrapper( el ).css({
  12069. overflow: "hidden"
  12070. });
  12071. distance = wrapper[ ref ]();
  12072. margin = parseFloat( wrapper.css( ref2 ) ) || 0;
  12073. animation[ ref ] = show ? distance : 0;
  12074. if ( !motion ) {
  12075. el
  12076. .css( vertical ? "bottom" : "right", 0 )
  12077. .css( vertical ? "top" : "left", "auto" )
  12078. .css({ position: "absolute" });
  12079. animation[ ref2 ] = show ? margin : distance + margin;
  12080. }
  12081. // start at 0 if we are showing
  12082. if ( show ) {
  12083. wrapper.css( ref, 0 );
  12084. if ( ! motion ) {
  12085. wrapper.css( ref2, margin + distance );
  12086. }
  12087. }
  12088. // Animate
  12089. wrapper.animate( animation, {
  12090. duration: o.duration,
  12091. easing: o.easing,
  12092. queue: false,
  12093. complete: function() {
  12094. if ( mode === "hide" ) {
  12095. el.hide();
  12096. }
  12097. $.effects.restore( el, props );
  12098. $.effects.removeWrapper( el );
  12099. done();
  12100. }
  12101. });
  12102. };
  12103. })(jQuery);
  12104. (function( $, undefined ) {
  12105. $.effects.effect.bounce = function( o, done ) {
  12106. var el = $( this ),
  12107. props = [ "position", "top", "bottom", "left", "right", "height", "width" ],
  12108. // defaults:
  12109. mode = $.effects.setMode( el, o.mode || "effect" ),
  12110. hide = mode === "hide",
  12111. show = mode === "show",
  12112. direction = o.direction || "up",
  12113. distance = o.distance,
  12114. times = o.times || 5,
  12115. // number of internal animations
  12116. anims = times * 2 + ( show || hide ? 1 : 0 ),
  12117. speed = o.duration / anims,
  12118. easing = o.easing,
  12119. // utility:
  12120. ref = ( direction === "up" || direction === "down" ) ? "top" : "left",
  12121. motion = ( direction === "up" || direction === "left" ),
  12122. i,
  12123. upAnim,
  12124. downAnim,
  12125. // we will need to re-assemble the queue to stack our animations in place
  12126. queue = el.queue(),
  12127. queuelen = queue.length;
  12128. // Avoid touching opacity to prevent clearType and PNG issues in IE
  12129. if ( show || hide ) {
  12130. props.push( "opacity" );
  12131. }
  12132. $.effects.save( el, props );
  12133. el.show();
  12134. $.effects.createWrapper( el ); // Create Wrapper
  12135. // default distance for the BIGGEST bounce is the outer Distance / 3
  12136. if ( !distance ) {
  12137. distance = el[ ref === "top" ? "outerHeight" : "outerWidth" ]() / 3;
  12138. }
  12139. if ( show ) {
  12140. downAnim = { opacity: 1 };
  12141. downAnim[ ref ] = 0;
  12142. // if we are showing, force opacity 0 and set the initial position
  12143. // then do the "first" animation
  12144. el.css( "opacity", 0 )
  12145. .css( ref, motion ? -distance * 2 : distance * 2 )
  12146. .animate( downAnim, speed, easing );
  12147. }
  12148. // start at the smallest distance if we are hiding
  12149. if ( hide ) {
  12150. distance = distance / Math.pow( 2, times - 1 );
  12151. }
  12152. downAnim = {};
  12153. downAnim[ ref ] = 0;
  12154. // Bounces up/down/left/right then back to 0 -- times * 2 animations happen here
  12155. for ( i = 0; i < times; i++ ) {
  12156. upAnim = {};
  12157. upAnim[ ref ] = ( motion ? "-=" : "+=" ) + distance;
  12158. el.animate( upAnim, speed, easing )
  12159. .animate( downAnim, speed, easing );
  12160. distance = hide ? distance * 2 : distance / 2;
  12161. }
  12162. // Last Bounce when Hiding
  12163. if ( hide ) {
  12164. upAnim = { opacity: 0 };
  12165. upAnim[ ref ] = ( motion ? "-=" : "+=" ) + distance;
  12166. el.animate( upAnim, speed, easing );
  12167. }
  12168. el.queue(function() {
  12169. if ( hide ) {
  12170. el.hide();
  12171. }
  12172. $.effects.restore( el, props );
  12173. $.effects.removeWrapper( el );
  12174. done();
  12175. });
  12176. // inject all the animations we just queued to be first in line (after "inprogress")
  12177. if ( queuelen > 1) {
  12178. queue.splice.apply( queue,
  12179. [ 1, 0 ].concat( queue.splice( queuelen, anims + 1 ) ) );
  12180. }
  12181. el.dequeue();
  12182. };
  12183. })(jQuery);
  12184. (function( $, undefined ) {
  12185. $.effects.effect.clip = function( o, done ) {
  12186. // Create element
  12187. var el = $( this ),
  12188. props = [ "position", "top", "bottom", "left", "right", "height", "width" ],
  12189. mode = $.effects.setMode( el, o.mode || "hide" ),
  12190. show = mode === "show",
  12191. direction = o.direction || "vertical",
  12192. vert = direction === "vertical",
  12193. size = vert ? "height" : "width",
  12194. position = vert ? "top" : "left",
  12195. animation = {},
  12196. wrapper, animate, distance;
  12197. // Save & Show
  12198. $.effects.save( el, props );
  12199. el.show();
  12200. // Create Wrapper
  12201. wrapper = $.effects.createWrapper( el ).css({
  12202. overflow: "hidden"
  12203. });
  12204. animate = ( el[0].tagName === "IMG" ) ? wrapper : el;
  12205. distance = animate[ size ]();
  12206. // Shift
  12207. if ( show ) {
  12208. animate.css( size, 0 );
  12209. animate.css( position, distance / 2 );
  12210. }
  12211. // Create Animation Object:
  12212. animation[ size ] = show ? distance : 0;
  12213. animation[ position ] = show ? 0 : distance / 2;
  12214. // Animate
  12215. animate.animate( animation, {
  12216. queue: false,
  12217. duration: o.duration,
  12218. easing: o.easing,
  12219. complete: function() {
  12220. if ( !show ) {
  12221. el.hide();
  12222. }
  12223. $.effects.restore( el, props );
  12224. $.effects.removeWrapper( el );
  12225. done();
  12226. }
  12227. });
  12228. };
  12229. })(jQuery);
  12230. (function( $, undefined ) {
  12231. $.effects.effect.drop = function( o, done ) {
  12232. var el = $( this ),
  12233. props = [ "position", "top", "bottom", "left", "right", "opacity", "height", "width" ],
  12234. mode = $.effects.setMode( el, o.mode || "hide" ),
  12235. show = mode === "show",
  12236. direction = o.direction || "left",
  12237. ref = ( direction === "up" || direction === "down" ) ? "top" : "left",
  12238. motion = ( direction === "up" || direction === "left" ) ? "pos" : "neg",
  12239. animation = {
  12240. opacity: show ? 1 : 0
  12241. },
  12242. distance;
  12243. // Adjust
  12244. $.effects.save( el, props );
  12245. el.show();
  12246. $.effects.createWrapper( el );
  12247. distance = o.distance || el[ ref === "top" ? "outerHeight": "outerWidth" ]( true ) / 2;
  12248. if ( show ) {
  12249. el
  12250. .css( "opacity", 0 )
  12251. .css( ref, motion === "pos" ? -distance : distance );
  12252. }
  12253. // Animation
  12254. animation[ ref ] = ( show ?
  12255. ( motion === "pos" ? "+=" : "-=" ) :
  12256. ( motion === "pos" ? "-=" : "+=" ) ) +
  12257. distance;
  12258. // Animate
  12259. el.animate( animation, {
  12260. queue: false,
  12261. duration: o.duration,
  12262. easing: o.easing,
  12263. complete: function() {
  12264. if ( mode === "hide" ) {
  12265. el.hide();
  12266. }
  12267. $.effects.restore( el, props );
  12268. $.effects.removeWrapper( el );
  12269. done();
  12270. }
  12271. });
  12272. };
  12273. })(jQuery);
  12274. (function( $, undefined ) {
  12275. $.effects.effect.explode = function( o, done ) {
  12276. var rows = o.pieces ? Math.round( Math.sqrt( o.pieces ) ) : 3,
  12277. cells = rows,
  12278. el = $( this ),
  12279. mode = $.effects.setMode( el, o.mode || "hide" ),
  12280. show = mode === "show",
  12281. // show and then visibility:hidden the element before calculating offset
  12282. offset = el.show().css( "visibility", "hidden" ).offset(),
  12283. // width and height of a piece
  12284. width = Math.ceil( el.outerWidth() / cells ),
  12285. height = Math.ceil( el.outerHeight() / rows ),
  12286. pieces = [],
  12287. // loop
  12288. i, j, left, top, mx, my;
  12289. // children animate complete:
  12290. function childComplete() {
  12291. pieces.push( this );
  12292. if ( pieces.length === rows * cells ) {
  12293. animComplete();
  12294. }
  12295. }
  12296. // clone the element for each row and cell.
  12297. for( i = 0; i < rows ; i++ ) { // ===>
  12298. top = offset.top + i * height;
  12299. my = i - ( rows - 1 ) / 2 ;
  12300. for( j = 0; j < cells ; j++ ) { // |||
  12301. left = offset.left + j * width;
  12302. mx = j - ( cells - 1 ) / 2 ;
  12303. // Create a clone of the now hidden main element that will be absolute positioned
  12304. // within a wrapper div off the -left and -top equal to size of our pieces
  12305. el
  12306. .clone()
  12307. .appendTo( "body" )
  12308. .wrap( "<div></div>" )
  12309. .css({
  12310. position: "absolute",
  12311. visibility: "visible",
  12312. left: -j * width,
  12313. top: -i * height
  12314. })
  12315. // select the wrapper - make it overflow: hidden and absolute positioned based on
  12316. // where the original was located +left and +top equal to the size of pieces
  12317. .parent()
  12318. .addClass( "ui-effects-explode" )
  12319. .css({
  12320. position: "absolute",
  12321. overflow: "hidden",
  12322. width: width,
  12323. height: height,
  12324. left: left + ( show ? mx * width : 0 ),
  12325. top: top + ( show ? my * height : 0 ),
  12326. opacity: show ? 0 : 1
  12327. }).animate({
  12328. left: left + ( show ? 0 : mx * width ),
  12329. top: top + ( show ? 0 : my * height ),
  12330. opacity: show ? 1 : 0
  12331. }, o.duration || 500, o.easing, childComplete );
  12332. }
  12333. }
  12334. function animComplete() {
  12335. el.css({
  12336. visibility: "visible"
  12337. });
  12338. $( pieces ).remove();
  12339. if ( !show ) {
  12340. el.hide();
  12341. }
  12342. done();
  12343. }
  12344. };
  12345. })(jQuery);
  12346. (function( $, undefined ) {
  12347. $.effects.effect.fade = function( o, done ) {
  12348. var el = $( this ),
  12349. mode = $.effects.setMode( el, o.mode || "toggle" );
  12350. el.animate({
  12351. opacity: mode
  12352. }, {
  12353. queue: false,
  12354. duration: o.duration,
  12355. easing: o.easing,
  12356. complete: done
  12357. });
  12358. };
  12359. })( jQuery );
  12360. (function( $, undefined ) {
  12361. $.effects.effect.fold = function( o, done ) {
  12362. // Create element
  12363. var el = $( this ),
  12364. props = [ "position", "top", "bottom", "left", "right", "height", "width" ],
  12365. mode = $.effects.setMode( el, o.mode || "hide" ),
  12366. show = mode === "show",
  12367. hide = mode === "hide",
  12368. size = o.size || 15,
  12369. percent = /([0-9]+)%/.exec( size ),
  12370. horizFirst = !!o.horizFirst,
  12371. widthFirst = show !== horizFirst,
  12372. ref = widthFirst ? [ "width", "height" ] : [ "height", "width" ],
  12373. duration = o.duration / 2,
  12374. wrapper, distance,
  12375. animation1 = {},
  12376. animation2 = {};
  12377. $.effects.save( el, props );
  12378. el.show();
  12379. // Create Wrapper
  12380. wrapper = $.effects.createWrapper( el ).css({
  12381. overflow: "hidden"
  12382. });
  12383. distance = widthFirst ?
  12384. [ wrapper.width(), wrapper.height() ] :
  12385. [ wrapper.height(), wrapper.width() ];
  12386. if ( percent ) {
  12387. size = parseInt( percent[ 1 ], 10 ) / 100 * distance[ hide ? 0 : 1 ];
  12388. }
  12389. if ( show ) {
  12390. wrapper.css( horizFirst ? {
  12391. height: 0,
  12392. width: size
  12393. } : {
  12394. height: size,
  12395. width: 0
  12396. });
  12397. }
  12398. // Animation
  12399. animation1[ ref[ 0 ] ] = show ? distance[ 0 ] : size;
  12400. animation2[ ref[ 1 ] ] = show ? distance[ 1 ] : 0;
  12401. // Animate
  12402. wrapper
  12403. .animate( animation1, duration, o.easing )
  12404. .animate( animation2, duration, o.easing, function() {
  12405. if ( hide ) {
  12406. el.hide();
  12407. }
  12408. $.effects.restore( el, props );
  12409. $.effects.removeWrapper( el );
  12410. done();
  12411. });
  12412. };
  12413. })(jQuery);
  12414. (function( $, undefined ) {
  12415. $.effects.effect.highlight = function( o, done ) {
  12416. var elem = $( this ),
  12417. props = [ "backgroundImage", "backgroundColor", "opacity" ],
  12418. mode = $.effects.setMode( elem, o.mode || "show" ),
  12419. animation = {
  12420. backgroundColor: elem.css( "backgroundColor" )
  12421. };
  12422. if (mode === "hide") {
  12423. animation.opacity = 0;
  12424. }
  12425. $.effects.save( elem, props );
  12426. elem
  12427. .show()
  12428. .css({
  12429. backgroundImage: "none",
  12430. backgroundColor: o.color || "#ffff99"
  12431. })
  12432. .animate( animation, {
  12433. queue: false,
  12434. duration: o.duration,
  12435. easing: o.easing,
  12436. complete: function() {
  12437. if ( mode === "hide" ) {
  12438. elem.hide();
  12439. }
  12440. $.effects.restore( elem, props );
  12441. done();
  12442. }
  12443. });
  12444. };
  12445. })(jQuery);
  12446. (function( $, undefined ) {
  12447. $.effects.effect.pulsate = function( o, done ) {
  12448. var elem = $( this ),
  12449. mode = $.effects.setMode( elem, o.mode || "show" ),
  12450. show = mode === "show",
  12451. hide = mode === "hide",
  12452. showhide = ( show || mode === "hide" ),
  12453. // showing or hiding leaves of the "last" animation
  12454. anims = ( ( o.times || 5 ) * 2 ) + ( showhide ? 1 : 0 ),
  12455. duration = o.duration / anims,
  12456. animateTo = 0,
  12457. queue = elem.queue(),
  12458. queuelen = queue.length,
  12459. i;
  12460. if ( show || !elem.is(":visible")) {
  12461. elem.css( "opacity", 0 ).show();
  12462. animateTo = 1;
  12463. }
  12464. // anims - 1 opacity "toggles"
  12465. for ( i = 1; i < anims; i++ ) {
  12466. elem.animate({
  12467. opacity: animateTo
  12468. }, duration, o.easing );
  12469. animateTo = 1 - animateTo;
  12470. }
  12471. elem.animate({
  12472. opacity: animateTo
  12473. }, duration, o.easing);
  12474. elem.queue(function() {
  12475. if ( hide ) {
  12476. elem.hide();
  12477. }
  12478. done();
  12479. });
  12480. // We just queued up "anims" animations, we need to put them next in the queue
  12481. if ( queuelen > 1 ) {
  12482. queue.splice.apply( queue,
  12483. [ 1, 0 ].concat( queue.splice( queuelen, anims + 1 ) ) );
  12484. }
  12485. elem.dequeue();
  12486. };
  12487. })(jQuery);
  12488. (function( $, undefined ) {
  12489. $.effects.effect.puff = function( o, done ) {
  12490. var elem = $( this ),
  12491. mode = $.effects.setMode( elem, o.mode || "hide" ),
  12492. hide = mode === "hide",
  12493. percent = parseInt( o.percent, 10 ) || 150,
  12494. factor = percent / 100,
  12495. original = {
  12496. height: elem.height(),
  12497. width: elem.width(),
  12498. outerHeight: elem.outerHeight(),
  12499. outerWidth: elem.outerWidth()
  12500. };
  12501. $.extend( o, {
  12502. effect: "scale",
  12503. queue: false,
  12504. fade: true,
  12505. mode: mode,
  12506. complete: done,
  12507. percent: hide ? percent : 100,
  12508. from: hide ?
  12509. original :
  12510. {
  12511. height: original.height * factor,
  12512. width: original.width * factor,
  12513. outerHeight: original.outerHeight * factor,
  12514. outerWidth: original.outerWidth * factor
  12515. }
  12516. });
  12517. elem.effect( o );
  12518. };
  12519. $.effects.effect.scale = function( o, done ) {
  12520. // Create element
  12521. var el = $( this ),
  12522. options = $.extend( true, {}, o ),
  12523. mode = $.effects.setMode( el, o.mode || "effect" ),
  12524. percent = parseInt( o.percent, 10 ) ||
  12525. ( parseInt( o.percent, 10 ) === 0 ? 0 : ( mode === "hide" ? 0 : 100 ) ),
  12526. direction = o.direction || "both",
  12527. origin = o.origin,
  12528. original = {
  12529. height: el.height(),
  12530. width: el.width(),
  12531. outerHeight: el.outerHeight(),
  12532. outerWidth: el.outerWidth()
  12533. },
  12534. factor = {
  12535. y: direction !== "horizontal" ? (percent / 100) : 1,
  12536. x: direction !== "vertical" ? (percent / 100) : 1
  12537. };
  12538. // We are going to pass this effect to the size effect:
  12539. options.effect = "size";
  12540. options.queue = false;
  12541. options.complete = done;
  12542. // Set default origin and restore for show/hide
  12543. if ( mode !== "effect" ) {
  12544. options.origin = origin || ["middle","center"];
  12545. options.restore = true;
  12546. }
  12547. options.from = o.from || ( mode === "show" ? {
  12548. height: 0,
  12549. width: 0,
  12550. outerHeight: 0,
  12551. outerWidth: 0
  12552. } : original );
  12553. options.to = {
  12554. height: original.height * factor.y,
  12555. width: original.width * factor.x,
  12556. outerHeight: original.outerHeight * factor.y,
  12557. outerWidth: original.outerWidth * factor.x
  12558. };
  12559. // Fade option to support puff
  12560. if ( options.fade ) {
  12561. if ( mode === "show" ) {
  12562. options.from.opacity = 0;
  12563. options.to.opacity = 1;
  12564. }
  12565. if ( mode === "hide" ) {
  12566. options.from.opacity = 1;
  12567. options.to.opacity = 0;
  12568. }
  12569. }
  12570. // Animate
  12571. el.effect( options );
  12572. };
  12573. $.effects.effect.size = function( o, done ) {
  12574. // Create element
  12575. var original, baseline, factor,
  12576. el = $( this ),
  12577. props0 = [ "position", "top", "bottom", "left", "right", "width", "height", "overflow", "opacity" ],
  12578. // Always restore
  12579. props1 = [ "position", "top", "bottom", "left", "right", "overflow", "opacity" ],
  12580. // Copy for children
  12581. props2 = [ "width", "height", "overflow" ],
  12582. cProps = [ "fontSize" ],
  12583. vProps = [ "borderTopWidth", "borderBottomWidth", "paddingTop", "paddingBottom" ],
  12584. hProps = [ "borderLeftWidth", "borderRightWidth", "paddingLeft", "paddingRight" ],
  12585. // Set options
  12586. mode = $.effects.setMode( el, o.mode || "effect" ),
  12587. restore = o.restore || mode !== "effect",
  12588. scale = o.scale || "both",
  12589. origin = o.origin || [ "middle", "center" ],
  12590. position = el.css( "position" ),
  12591. props = restore ? props0 : props1,
  12592. zero = {
  12593. height: 0,
  12594. width: 0,
  12595. outerHeight: 0,
  12596. outerWidth: 0
  12597. };
  12598. if ( mode === "show" ) {
  12599. el.show();
  12600. }
  12601. original = {
  12602. height: el.height(),
  12603. width: el.width(),
  12604. outerHeight: el.outerHeight(),
  12605. outerWidth: el.outerWidth()
  12606. };
  12607. if ( o.mode === "toggle" && mode === "show" ) {
  12608. el.from = o.to || zero;
  12609. el.to = o.from || original;
  12610. } else {
  12611. el.from = o.from || ( mode === "show" ? zero : original );
  12612. el.to = o.to || ( mode === "hide" ? zero : original );
  12613. }
  12614. // Set scaling factor
  12615. factor = {
  12616. from: {
  12617. y: el.from.height / original.height,
  12618. x: el.from.width / original.width
  12619. },
  12620. to: {
  12621. y: el.to.height / original.height,
  12622. x: el.to.width / original.width
  12623. }
  12624. };
  12625. // Scale the css box
  12626. if ( scale === "box" || scale === "both" ) {
  12627. // Vertical props scaling
  12628. if ( factor.from.y !== factor.to.y ) {
  12629. props = props.concat( vProps );
  12630. el.from = $.effects.setTransition( el, vProps, factor.from.y, el.from );
  12631. el.to = $.effects.setTransition( el, vProps, factor.to.y, el.to );
  12632. }
  12633. // Horizontal props scaling
  12634. if ( factor.from.x !== factor.to.x ) {
  12635. props = props.concat( hProps );
  12636. el.from = $.effects.setTransition( el, hProps, factor.from.x, el.from );
  12637. el.to = $.effects.setTransition( el, hProps, factor.to.x, el.to );
  12638. }
  12639. }
  12640. // Scale the content
  12641. if ( scale === "content" || scale === "both" ) {
  12642. // Vertical props scaling
  12643. if ( factor.from.y !== factor.to.y ) {
  12644. props = props.concat( cProps ).concat( props2 );
  12645. el.from = $.effects.setTransition( el, cProps, factor.from.y, el.from );
  12646. el.to = $.effects.setTransition( el, cProps, factor.to.y, el.to );
  12647. }
  12648. }
  12649. $.effects.save( el, props );
  12650. el.show();
  12651. $.effects.createWrapper( el );
  12652. el.css( "overflow", "hidden" ).css( el.from );
  12653. // Adjust
  12654. if (origin) { // Calculate baseline shifts
  12655. baseline = $.effects.getBaseline( origin, original );
  12656. el.from.top = ( original.outerHeight - el.outerHeight() ) * baseline.y;
  12657. el.from.left = ( original.outerWidth - el.outerWidth() ) * baseline.x;
  12658. el.to.top = ( original.outerHeight - el.to.outerHeight ) * baseline.y;
  12659. el.to.left = ( original.outerWidth - el.to.outerWidth ) * baseline.x;
  12660. }
  12661. el.css( el.from ); // set top & left
  12662. // Animate
  12663. if ( scale === "content" || scale === "both" ) { // Scale the children
  12664. // Add margins/font-size
  12665. vProps = vProps.concat([ "marginTop", "marginBottom" ]).concat(cProps);
  12666. hProps = hProps.concat([ "marginLeft", "marginRight" ]);
  12667. props2 = props0.concat(vProps).concat(hProps);
  12668. el.find( "*[width]" ).each( function(){
  12669. var child = $( this ),
  12670. c_original = {
  12671. height: child.height(),
  12672. width: child.width(),
  12673. outerHeight: child.outerHeight(),
  12674. outerWidth: child.outerWidth()
  12675. };
  12676. if (restore) {
  12677. $.effects.save(child, props2);
  12678. }
  12679. child.from = {
  12680. height: c_original.height * factor.from.y,
  12681. width: c_original.width * factor.from.x,
  12682. outerHeight: c_original.outerHeight * factor.from.y,
  12683. outerWidth: c_original.outerWidth * factor.from.x
  12684. };
  12685. child.to = {
  12686. height: c_original.height * factor.to.y,
  12687. width: c_original.width * factor.to.x,
  12688. outerHeight: c_original.height * factor.to.y,
  12689. outerWidth: c_original.width * factor.to.x
  12690. };
  12691. // Vertical props scaling
  12692. if ( factor.from.y !== factor.to.y ) {
  12693. child.from = $.effects.setTransition( child, vProps, factor.from.y, child.from );
  12694. child.to = $.effects.setTransition( child, vProps, factor.to.y, child.to );
  12695. }
  12696. // Horizontal props scaling
  12697. if ( factor.from.x !== factor.to.x ) {
  12698. child.from = $.effects.setTransition( child, hProps, factor.from.x, child.from );
  12699. child.to = $.effects.setTransition( child, hProps, factor.to.x, child.to );
  12700. }
  12701. // Animate children
  12702. child.css( child.from );
  12703. child.animate( child.to, o.duration, o.easing, function() {
  12704. // Restore children
  12705. if ( restore ) {
  12706. $.effects.restore( child, props2 );
  12707. }
  12708. });
  12709. });
  12710. }
  12711. // Animate
  12712. el.animate( el.to, {
  12713. queue: false,
  12714. duration: o.duration,
  12715. easing: o.easing,
  12716. complete: function() {
  12717. if ( el.to.opacity === 0 ) {
  12718. el.css( "opacity", el.from.opacity );
  12719. }
  12720. if( mode === "hide" ) {
  12721. el.hide();
  12722. }
  12723. $.effects.restore( el, props );
  12724. if ( !restore ) {
  12725. // we need to calculate our new positioning based on the scaling
  12726. if ( position === "static" ) {
  12727. el.css({
  12728. position: "relative",
  12729. top: el.to.top,
  12730. left: el.to.left
  12731. });
  12732. } else {
  12733. $.each([ "top", "left" ], function( idx, pos ) {
  12734. el.css( pos, function( _, str ) {
  12735. var val = parseInt( str, 10 ),
  12736. toRef = idx ? el.to.left : el.to.top;
  12737. // if original was "auto", recalculate the new value from wrapper
  12738. if ( str === "auto" ) {
  12739. return toRef + "px";
  12740. }
  12741. return val + toRef + "px";
  12742. });
  12743. });
  12744. }
  12745. }
  12746. $.effects.removeWrapper( el );
  12747. done();
  12748. }
  12749. });
  12750. };
  12751. })(jQuery);
  12752. (function( $, undefined ) {
  12753. $.effects.effect.shake = function( o, done ) {
  12754. var el = $( this ),
  12755. props = [ "position", "top", "bottom", "left", "right", "height", "width" ],
  12756. mode = $.effects.setMode( el, o.mode || "effect" ),
  12757. direction = o.direction || "left",
  12758. distance = o.distance || 20,
  12759. times = o.times || 3,
  12760. anims = times * 2 + 1,
  12761. speed = Math.round(o.duration/anims),
  12762. ref = (direction === "up" || direction === "down") ? "top" : "left",
  12763. positiveMotion = (direction === "up" || direction === "left"),
  12764. animation = {},
  12765. animation1 = {},
  12766. animation2 = {},
  12767. i,
  12768. // we will need to re-assemble the queue to stack our animations in place
  12769. queue = el.queue(),
  12770. queuelen = queue.length;
  12771. $.effects.save( el, props );
  12772. el.show();
  12773. $.effects.createWrapper( el );
  12774. // Animation
  12775. animation[ ref ] = ( positiveMotion ? "-=" : "+=" ) + distance;
  12776. animation1[ ref ] = ( positiveMotion ? "+=" : "-=" ) + distance * 2;
  12777. animation2[ ref ] = ( positiveMotion ? "-=" : "+=" ) + distance * 2;
  12778. // Animate
  12779. el.animate( animation, speed, o.easing );
  12780. // Shakes
  12781. for ( i = 1; i < times; i++ ) {
  12782. el.animate( animation1, speed, o.easing ).animate( animation2, speed, o.easing );
  12783. }
  12784. el
  12785. .animate( animation1, speed, o.easing )
  12786. .animate( animation, speed / 2, o.easing )
  12787. .queue(function() {
  12788. if ( mode === "hide" ) {
  12789. el.hide();
  12790. }
  12791. $.effects.restore( el, props );
  12792. $.effects.removeWrapper( el );
  12793. done();
  12794. });
  12795. // inject all the animations we just queued to be first in line (after "inprogress")
  12796. if ( queuelen > 1) {
  12797. queue.splice.apply( queue,
  12798. [ 1, 0 ].concat( queue.splice( queuelen, anims + 1 ) ) );
  12799. }
  12800. el.dequeue();
  12801. };
  12802. })(jQuery);
  12803. (function( $, undefined ) {
  12804. $.effects.effect.slide = function( o, done ) {
  12805. // Create element
  12806. var el = $( this ),
  12807. props = [ "position", "top", "bottom", "left", "right", "width", "height" ],
  12808. mode = $.effects.setMode( el, o.mode || "show" ),
  12809. show = mode === "show",
  12810. direction = o.direction || "left",
  12811. ref = (direction === "up" || direction === "down") ? "top" : "left",
  12812. positiveMotion = (direction === "up" || direction === "left"),
  12813. distance,
  12814. animation = {};
  12815. // Adjust
  12816. $.effects.save( el, props );
  12817. el.show();
  12818. distance = o.distance || el[ ref === "top" ? "outerHeight" : "outerWidth" ]( true );
  12819. $.effects.createWrapper( el ).css({
  12820. overflow: "hidden"
  12821. });
  12822. if ( show ) {
  12823. el.css( ref, positiveMotion ? (isNaN(distance) ? "-" + distance : -distance) : distance );
  12824. }
  12825. // Animation
  12826. animation[ ref ] = ( show ?
  12827. ( positiveMotion ? "+=" : "-=") :
  12828. ( positiveMotion ? "-=" : "+=")) +
  12829. distance;
  12830. // Animate
  12831. el.animate( animation, {
  12832. queue: false,
  12833. duration: o.duration,
  12834. easing: o.easing,
  12835. complete: function() {
  12836. if ( mode === "hide" ) {
  12837. el.hide();
  12838. }
  12839. $.effects.restore( el, props );
  12840. $.effects.removeWrapper( el );
  12841. done();
  12842. }
  12843. });
  12844. };
  12845. })(jQuery);
  12846. (function( $, undefined ) {
  12847. $.effects.effect.transfer = function( o, done ) {
  12848. var elem = $( this ),
  12849. target = $( o.to ),
  12850. targetFixed = target.css( "position" ) === "fixed",
  12851. body = $("body"),
  12852. fixTop = targetFixed ? body.scrollTop() : 0,
  12853. fixLeft = targetFixed ? body.scrollLeft() : 0,
  12854. endPosition = target.offset(),
  12855. animation = {
  12856. top: endPosition.top - fixTop ,
  12857. left: endPosition.left - fixLeft ,
  12858. height: target.innerHeight(),
  12859. width: target.innerWidth()
  12860. },
  12861. startPosition = elem.offset(),
  12862. transfer = $( "<div class='ui-effects-transfer'></div>" )
  12863. .appendTo( document.body )
  12864. .addClass( o.className )
  12865. .css({
  12866. top: startPosition.top - fixTop ,
  12867. left: startPosition.left - fixLeft ,
  12868. height: elem.innerHeight(),
  12869. width: elem.innerWidth(),
  12870. position: targetFixed ? "fixed" : "absolute"
  12871. })
  12872. .animate( animation, o.duration, o.easing, function() {
  12873. transfer.remove();
  12874. done();
  12875. });
  12876. };
  12877. })(jQuery);